Skip to content

Commit 431ae7f

Browse files
committed
Features Added: Project relocation, add existing, open in vs code.
- Added `relocate` feature in `codemanager` for missing projects. - Added `add` command in `codemg` to add existing projects. - Added `open_with_vscode` feature in `codemanager` to open an project in VSCode. - Saving different dependency `build caches` separately, in GitHub Actions. - *Fixed some command related bugs in `python scripts`.
1 parent c238aa0 commit 431ae7f

30 files changed

+539
-260
lines changed

.github/workflows/build_and_release.yml

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,45 +42,60 @@ jobs:
4242
- name: Checkout code
4343
uses: actions/checkout@v4
4444

45-
- name: Cached libraries
46-
id: cache-libraries
47-
uses: actions/cache@v3
45+
- name: Cached Python dependencies
46+
uses: actions/cache@v4
47+
with:
48+
path: .venv
49+
key: ${{ runner.os }}-python-${{ hashFiles('scripts/requirements.txt') }}
50+
51+
- name: Cached Vcpkg libraries
52+
id: cache-vcpkg
53+
uses: actions/cache@v4
54+
with:
55+
path: vcpkg
56+
key: ${{ runner.os }}-vcpkg
57+
58+
- name: Cached Node dependencies
59+
uses: actions/cache@v4
60+
with:
61+
path: node_modules
62+
key: ${{ runner.os }}-node_modules-${{ hashFiles('bun.lockb') }}
63+
64+
- name: Cached Rust & Tauri dependencies
65+
uses: actions/cache@v4
4866
with:
4967
path: |
50-
.venv
51-
vcpkg
52-
node_modules
5368
~/.cargo/registry
5469
~/.cargo/git
5570
src-tauri/target
56-
key: ${{ runner.os }}-codemanager-${{ hashFiles('package.json', 'src-tauri/Cargo.lock') }}
71+
key: ${{ runner.os }}-rust-${{ hashFiles('src-tauri/Cargo.lock') }}
5772

5873
- name: Set up Python
59-
uses: actions/setup-python@v2
74+
uses: actions/setup-python@v5
6075
with:
6176
python-version: "3.12"
6277
cache: "pip"
6378
cache-dependency-path: scripts/requirements.txt
6479

6580
- name: Set up Rust
66-
uses: actions-rs/toolchain@v1
81+
uses: actions-rs/toolchain@v1.0.6
6782
with:
6883
toolchain: "1.78.0" # stable
6984
default: true
7085
override: true
7186

7287
- name: Set up Bun
73-
uses: oven-sh/setup-bun@v1
88+
uses: oven-sh/setup-bun@v2
7489
with:
75-
bun-version: "1.1.13"
90+
bun-version: "1.1.30"
7691

7792
- name: Set up MSBuild
7893
uses: microsoft/setup-msbuild@v2
7994
with:
8095
msbuild-architecture: "x64"
8196

8297
- name: Install OpenSSL using vcpkg
83-
if: steps.cache-libraries.outputs.cache-hit != 'true'
98+
if: steps.cache-vcpkg.outputs.cache-hit != 'true'
8499
shell: pwsh
85100
run: |
86101
$env:VCPKG_ROOT = "${{ github.workspace }}\vcpkg"

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"python.analysis.typeCheckingMode": "basic"
2+
"python.analysis.typeCheckingMode": "basic",
3+
"python.analysis.autoImportCompletions": true
34
}

CHANGELOG.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
Codemanager installer `codemg-setup.msi` using `WiX Toolset v5`. ✨🎉
1+
**Features Added**: Project relocation, add existing, open in vs code.
22

3-
- Generating custom `codemg-setup.msi` installer using `wix toolset`.
4-
- Python scripts Error printing into `stderr` stream.
5-
- In-activated Tauri bundle creation: `msi, nish`.
3+
- Added `relocate` feature in `codemanager` for missing projects.
4+
- Added `add` command in `codemg` to add existing projects.
5+
- Added `open_with_vscode` feature in `codemanager` to open an project in VSCode.
6+
- Saving different dependency `build caches` separately, in GitHub Actions.
7+
- *Fixed some command related bugs in `python scripts`.

scripts/cli/args_parser.py

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,92 @@
66
from .utils import reset_terminal_colors
77

88

9+
class CustomHelpFormatter(argparse.HelpFormatter):
10+
def __init__(self, prog):
11+
super().__init__(prog, max_help_position=40, width=80)
12+
13+
def _format_action_invocation(self, action):
14+
if not action.option_strings or action.nargs == 0:
15+
return super()._format_action_invocation(action)
16+
default = self._get_default_metavar_for_optional(action)
17+
args_string = self._format_args(action, default)
18+
return ", ".join(action.option_strings) + " " + args_string
19+
20+
921
def get_cli_args():
22+
fmt = lambda prog: CustomHelpFormatter(prog)
1023
parser = argparse.ArgumentParser(
11-
prog="CodeManager - CLI",
12-
description="Organizes all coding projects on the device",
24+
prog="codemg",
25+
description="CodeManager - CLI: Organizes all coding projects on the device",
26+
formatter_class=fmt,
1327
)
1428

1529
parser.add_argument(
16-
"--list-templates", action="store_true", help="List all templates"
30+
"-lt",
31+
"--list-templates",
32+
action="store_true",
33+
help="list all templates",
1734
)
1835

1936
subparsers = parser.add_subparsers(dest="command")
20-
project_creator = subparsers.add_parser("create")
37+
project_creator = subparsers.add_parser(
38+
"create",
39+
help="create a new project",
40+
formatter_class=fmt,
41+
)
42+
project_adder = subparsers.add_parser(
43+
"add",
44+
help="add an existing project",
45+
formatter_class=fmt,
46+
)
2147

48+
# Project Creator arguments
2249
project_creator.add_argument(
2350
"project_template",
2451
metavar="template",
25-
help="Template to create the project",
2652
choices=get_args(TEMPLATE),
53+
help="template to create the project",
2754
)
2855
project_creator.add_argument(
29-
"directory", help="Destination directory to create the project"
56+
"directory",
57+
help="destination directory to create the project",
3058
)
3159

3260
project_creator.add_argument(
3361
"--git",
34-
help="Initializes git version control system in the project",
62+
help="initializes git version control system in the project",
3563
action="store_true",
3664
)
37-
3865
project_creator.add_argument(
3966
"-rc",
40-
help="Reuses current vscode instance",
67+
help="reuses current vscode instance",
4168
action="store_true",
4269
)
43-
4470
project_creator.add_argument(
4571
"-nc",
46-
help="Creates project without opening the project in vscode",
72+
help="creates project without opening the project in vscode",
4773
action="store_true",
4874
)
49-
5075
project_creator.add_argument(
5176
"--jpm",
52-
metavar="JS package manager",
53-
help="Package manager for JavaScript",
54-
type=str,
5577
default="npm",
5678
choices=JS_PACKAGE_MANAGERS,
79+
metavar="<package-manager>",
80+
help="package manager for JavaScript",
81+
)
82+
83+
# Project Adder arguments
84+
project_adder.add_argument(
85+
"directory",
86+
help="project directory to add",
87+
)
88+
project_adder.add_argument(
89+
"-t",
90+
"--template",
91+
default="normal",
92+
metavar="<template>",
93+
choices=get_args(TEMPLATE),
94+
help="specifies the project template",
5795
)
5896

5997
args = parser.parse_args()

scripts/cli/config.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,32 @@ class JS_PACKAGE_MANAGERS(Enum):
1111
npm = JS_PACKAGE_MANAGER(
1212
package_manager="npm",
1313
package_executor="npx",
14-
install_cmd="npm i",
15-
dev_install_cmd="npm i -D",
16-
install_all_cmd="npm i",
14+
install_cmd=["npm", "i"],
15+
dev_install_cmd=["npm", "i", "-D"],
16+
install_all_cmd=["npm", "i"],
1717
)
1818
yarn = JS_PACKAGE_MANAGER(
1919
package_manager="yarn",
2020
package_executor="yarn",
21-
install_cmd="yarn add",
22-
dev_install_cmd="yarn add -D",
23-
install_all_cmd="yarn",
21+
install_cmd=["yarn", "add"],
22+
dev_install_cmd=["yarn", "add", "-D"],
23+
install_all_cmd=["yarn"],
2424
)
2525
pnpm = JS_PACKAGE_MANAGER(
2626
package_manager="pnpm",
2727
package_executor="pnpx",
28-
install_cmd="pnpm i",
29-
dev_install_cmd="pnpm i -D",
30-
install_all_cmd="pnpm i",
28+
install_cmd=["pnpm", "i"],
29+
dev_install_cmd=["pnpm", "i", "-D"],
30+
install_all_cmd=["pnpm", "i"],
3131
)
3232

3333
if OPERATING_SYSTEM in ("Linux", "Darwin"):
3434
bun = JS_PACKAGE_MANAGER(
3535
package_manager="bun",
3636
package_executor="bunx",
37-
install_cmd="bun install",
38-
dev_install_cmd="bun install -D",
39-
install_all_cmd="bun install",
37+
install_cmd=["bun", "install"],
38+
dev_install_cmd=["bun", "install", "-D"],
39+
install_all_cmd=["bun", "install"],
4040
)
4141

4242
@staticmethod

scripts/cli/custom_classes.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from dataclasses import dataclass, asdict
1+
from pathlib import Path
22
from typing import Callable, TypedDict
3+
from dataclasses import dataclass, asdict
34

45

56
@dataclass
@@ -35,9 +36,9 @@ def all_templates(self) -> list[Template[TEMPLATE]]:
3536
class JS_PACKAGE_MANAGER:
3637
package_manager: str
3738
package_executor: str
38-
install_cmd: str
39-
dev_install_cmd: str
40-
install_all_cmd: str
39+
install_cmd: list[str | Path]
40+
dev_install_cmd: list[str | Path]
41+
install_all_cmd: list[str | Path]
4142

4243

4344
@dataclass

scripts/cli/db_functions.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,21 @@
1717
secrets = dotenv_values(secrets_path)
1818

1919

20+
def generate_adder_id():
21+
adder_uuid = uuid.uuid4()
22+
adder_spawn_time = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S.%f %Z")
23+
adder_id = f"{adder_uuid}_<a:r:i:d>_{adder_spawn_time}"
24+
return adder_id
25+
26+
2027
def create_project_db(
2128
name: str,
2229
path: str,
2330
template: TEMPLATE,
2431
):
2532

2633
try:
27-
adder_uuid = uuid.uuid4()
28-
adder_spawn_time = datetime.now(timezone.utc).strftime(
29-
"%Y-%m-%d %H:%M:%S.%f %Z"
30-
)
31-
adder_id = f"{adder_uuid}_<a:r:i:d>_{adder_spawn_time}"
32-
34+
adder_id = generate_adder_id()
3335
new_project = NewProject(name, template, path, adder_id)
3436
project_data = new_project.json()
3537

0 commit comments

Comments
 (0)