@nexical/cli 0.11.10 → 0.11.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-Q7YLW5HJ.js → chunk-GEESHGE4.js} +36 -3
- package/dist/chunk-GEESHGE4.js.map +1 -0
- package/dist/chunk-GUUPSHWC.js +70 -0
- package/dist/chunk-GUUPSHWC.js.map +1 -0
- package/dist/index.js +14 -12
- package/dist/index.js.map +1 -1
- package/dist/src/commands/init.js +11 -4
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/module/add.js +6 -5
- package/dist/src/commands/module/add.js.map +1 -1
- package/dist/src/commands/setup.js +4 -61
- package/dist/src/commands/setup.js.map +1 -1
- package/dist/src/utils/git.d.ts +2 -1
- package/dist/src/utils/git.js +3 -1
- package/package.json +14 -12
- package/src/commands/init.ts +7 -0
- package/src/commands/module/add.ts +2 -2
- package/src/commands/setup.ts +6 -13
- package/src/utils/git.ts +43 -2
- package/test/e2e/lifecycle.e2e.test.ts +5 -4
- package/test/integration/commands/init.integration.test.ts +3 -0
- package/test/unit/commands/deploy.test.ts +70 -0
- package/test/unit/commands/init.test.ts +19 -1
- package/test/unit/commands/module/add.test.ts +220 -20
- package/test/unit/commands/module/list.test.ts +205 -0
- package/test/unit/commands/module/remove.test.ts +30 -0
- package/test/unit/commands/run.test.ts +7 -0
- package/test/unit/commands/setup.test.ts +43 -1
- package/test/unit/deploy/registry.test.ts +41 -0
- package/test/unit/utils/git.test.ts +88 -0
- package/test/unit/utils/git_utils.test.ts +7 -0
- package/dist/chunk-Q7YLW5HJ.js.map +0 -1
|
@@ -11,8 +11,22 @@ import { promisify } from "util";
|
|
|
11
11
|
var execAsync = promisify(exec);
|
|
12
12
|
async function clone(url, destination, options = {}) {
|
|
13
13
|
const { recursive = false, depth } = options;
|
|
14
|
-
const
|
|
15
|
-
|
|
14
|
+
const args = `${recursive ? "--recursive " : ""}${depth ? `--depth ${depth} ` : ""}${url} .`;
|
|
15
|
+
try {
|
|
16
|
+
const cmd2 = `git -c credential.helper= clone ${args}`;
|
|
17
|
+
logger.debug(`Git clone (anonymous): ${url} to ${destination}`);
|
|
18
|
+
const { stdout } = await execAsync(cmd2, { cwd: destination });
|
|
19
|
+
if (stdout) {
|
|
20
|
+
console.log(stdout);
|
|
21
|
+
}
|
|
22
|
+
return;
|
|
23
|
+
} catch (e) {
|
|
24
|
+
logger.debug(
|
|
25
|
+
`Anonymous clone failed (${e instanceof Error ? e.message : String(e)}), retrying with default credentials...`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
const cmd = `git clone ${args}`;
|
|
29
|
+
logger.debug(`Git clone (authenticated): ${url} to ${destination}`);
|
|
16
30
|
await runCommand(cmd, destination);
|
|
17
31
|
}
|
|
18
32
|
async function getRemoteUrl(cwd, remote = "origin") {
|
|
@@ -31,6 +45,24 @@ async function updateSubmodules(cwd) {
|
|
|
31
45
|
cwd
|
|
32
46
|
);
|
|
33
47
|
}
|
|
48
|
+
async function addSubmodule(url, path, cwd) {
|
|
49
|
+
try {
|
|
50
|
+
const cmd2 = `git -c credential.helper= submodule add ${url} ${path}`;
|
|
51
|
+
logger.debug(`Git submodule add (anonymous): ${url} to ${path}`);
|
|
52
|
+
const { stdout } = await execAsync(cmd2, { cwd });
|
|
53
|
+
if (stdout) {
|
|
54
|
+
console.log(stdout);
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
|
+
} catch (e) {
|
|
58
|
+
logger.debug(
|
|
59
|
+
`Anonymous submodule add failed (${e instanceof Error ? e.message : String(e)}), retrying with default credentials...`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
const cmd = `git submodule add ${url} ${path}`;
|
|
63
|
+
logger.debug(`Git submodule add (authenticated): ${url} to ${path}`);
|
|
64
|
+
await runCommand(cmd, cwd);
|
|
65
|
+
}
|
|
34
66
|
async function checkoutOrphan(branch, cwd) {
|
|
35
67
|
await runCommand(`git checkout --orphan ${branch}`, cwd);
|
|
36
68
|
}
|
|
@@ -65,6 +97,7 @@ export {
|
|
|
65
97
|
clone,
|
|
66
98
|
getRemoteUrl,
|
|
67
99
|
updateSubmodules,
|
|
100
|
+
addSubmodule,
|
|
68
101
|
checkoutOrphan,
|
|
69
102
|
addAll,
|
|
70
103
|
commit,
|
|
@@ -74,4 +107,4 @@ export {
|
|
|
74
107
|
renameRemote,
|
|
75
108
|
branchExists
|
|
76
109
|
};
|
|
77
|
-
//# sourceMappingURL=chunk-
|
|
110
|
+
//# sourceMappingURL=chunk-GEESHGE4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/git.ts"],"sourcesContent":["import { logger, runCommand } from '@nexical/cli-core';\nimport { exec } from 'node:child_process';\nimport { promisify } from 'node:util';\n\nconst execAsync = promisify(exec);\n\nexport async function clone(\n url: string,\n destination: string,\n options: { recursive?: boolean; depth?: number } = {},\n): Promise<void> {\n const { recursive = false, depth } = options;\n const args = `${recursive ? '--recursive ' : ''}${depth ? `--depth ${depth} ` : ''}${url} .`;\n\n // Attempt 1: Anonymous (no credentials)\n // We use execAsync directly here to handle the error silently if it fails due to auth\n try {\n const cmd = `git -c credential.helper= clone ${args}`;\n logger.debug(`Git clone (anonymous): ${url} to ${destination}`);\n const { stdout } = await execAsync(cmd, { cwd: destination });\n if (stdout) {\n console.log(stdout);\n }\n return;\n } catch (e) {\n logger.debug(\n `Anonymous clone failed (${e instanceof Error ? e.message : String(e)}), retrying with default credentials...`,\n );\n }\n\n // Attempt 2: Default (Authenticated or whatever is configured)\n const cmd = `git clone ${args}`;\n logger.debug(`Git clone (authenticated): ${url} to ${destination}`);\n await runCommand(cmd, destination);\n}\n\nexport async function getRemoteUrl(cwd: string, remote = 'origin'): Promise<string> {\n try {\n const { stdout } = await execAsync(`git remote get-url ${remote}`, { cwd });\n return stdout.trim();\n } catch (e) {\n console.error('getRemoteUrl failed:', e);\n return '';\n }\n}\n\nexport async function updateSubmodules(cwd: string): Promise<void> {\n logger.debug(`Updating submodules in ${cwd}`);\n await runCommand(\n 'git submodule foreach --recursive \"git checkout main && git pull origin main\"',\n cwd,\n );\n}\n\nexport async function addSubmodule(url: string, path: string, cwd: string): Promise<void> {\n // Attempt 1: Anonymous\n try {\n const cmd = `git -c credential.helper= submodule add ${url} ${path}`;\n logger.debug(`Git submodule add (anonymous): ${url} to ${path}`);\n const { stdout } = await execAsync(cmd, { cwd });\n if (stdout) {\n console.log(stdout);\n }\n return;\n } catch (e) {\n logger.debug(\n `Anonymous submodule add failed (${e instanceof Error ? e.message : String(e)}), retrying with default credentials...`,\n );\n }\n\n // Attempt 2: Default\n const cmd = `git submodule add ${url} ${path}`;\n logger.debug(`Git submodule add (authenticated): ${url} to ${path}`);\n await runCommand(cmd, cwd);\n}\n\nexport async function checkoutOrphan(branch: string, cwd: string): Promise<void> {\n await runCommand(`git checkout --orphan ${branch}`, cwd);\n}\n\nexport async function addAll(cwd: string): Promise<void> {\n await runCommand('git add -A', cwd);\n}\n\nexport async function commit(message: string, cwd: string): Promise<void> {\n // Escape quotes in message if needed, for now assuming simple messages\n await runCommand(`git commit -m \"${message}\"`, cwd);\n}\n\nexport async function deleteBranch(branch: string, cwd: string): Promise<void> {\n await runCommand(`git branch -D ${branch}`, cwd);\n}\n\nexport async function renameBranch(branch: string, cwd: string): Promise<void> {\n await runCommand(`git branch -m ${branch}`, cwd);\n}\n\nexport async function removeRemote(remote: string, cwd: string): Promise<void> {\n await runCommand(`git remote remove ${remote}`, cwd);\n}\n\nexport async function renameRemote(oldName: string, newName: string, cwd: string): Promise<void> {\n await runCommand(`git remote rename ${oldName} ${newName}`, cwd);\n}\n\nexport async function branchExists(branch: string, cwd: string): Promise<boolean> {\n try {\n await execAsync(`git show-ref --verify --quiet refs/heads/${branch}`, { cwd });\n return true;\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;AAAA;AAAA,SAAS,QAAQ,kBAAkB;AACnC,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAE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AK,EAAE,IAAI,CAAC;AAC/C,QAAI,QAAQ;AACV,cAAQ,IAAI,MAAM;AAAA,IACpB;AACA;AAAA,EACF,SAAS,GAAG;AACV,WAAO;AAAA,MACL,mCAAmC,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,CAAC;AAAA,IAC/E;AAAA,EACF;AAGA,QAAM,MAAM,qBAAqB,GAAG,IAAI,IAAI;AAC5C,SAAO,MAAM,sCAAsC,GAAG,OAAO,IAAI,EAAE;AACnE,QAAM,WAAW,KAAK,GAAG;AAC3B;AAEA,eAAsB,eAAe,QAAgB,KAA4B;AAC/E,QAAM,WAAW,yBAAyB,MAAM,IAAI,GAAG;AACzD;AAEA,eAAsB,OAAO,KAA4B;AACvD,QAAM,WAAW,cAAc,GAAG;AACpC;AAEA,eAAsB,OAAO,SAAiB,KAA4B;AAExE,QAAM,WAAW,kBAAkB,OAAO,KAAK,GAAG;AACpD;AAEA,eAAsB,aAAa,QAAgB,KAA4B;AAC7E,QAAM,WAAW,iBAAiB,MAAM,IAAI,GAAG;AACjD;AAEA,eAAsB,aAAa,QAAgB,KAA4B;AAC7E,QAAM,WAAW,iBAAiB,MAAM,IAAI,GAAG;AACjD;AAEA,eAAsB,aAAa,QAAgB,KAA4B;AAC7E,QAAM,WAAW,qBAAqB,MAAM,IAAI,GAAG;AACrD;AAEA,eAAsB,aAAa,SAAiB,SAAiB,KAA4B;AAC/F,QAAM,WAAW,qBAAqB,OAAO,IAAI,OAAO,IAAI,GAAG;AACjE;AAEA,eAAsB,aAAa,QAAgB,KAA+B;AAChF,MAAI;AACF,UAAM,UAAU,4CAA4C,MAAM,IAAI,EAAE,IAAI,CAAC;AAC7E,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":["cmd"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createRequire } from "module"; const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
require_lib
|
|
4
|
+
} from "./chunk-OUGA4CB4.js";
|
|
5
|
+
import {
|
|
6
|
+
__toESM,
|
|
7
|
+
init_esm_shims
|
|
8
|
+
} from "./chunk-OYFWMYPG.js";
|
|
9
|
+
|
|
10
|
+
// src/commands/setup.ts
|
|
11
|
+
init_esm_shims();
|
|
12
|
+
var import_fs_extra = __toESM(require_lib(), 1);
|
|
13
|
+
import { BaseCommand, logger } from "@nexical/cli-core";
|
|
14
|
+
import path from "path";
|
|
15
|
+
var SetupCommand = class extends BaseCommand {
|
|
16
|
+
static description = "Setup the application environment by symlinking core assets.";
|
|
17
|
+
async run() {
|
|
18
|
+
const rootDir = this.projectRoot || process.cwd();
|
|
19
|
+
if (!import_fs_extra.default.existsSync(path.join(rootDir, "core"))) {
|
|
20
|
+
this.error('Could not find "core" directory. Are you in the project root?');
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
const apps = ["frontend", "backend"];
|
|
24
|
+
const sharedAssets = ["prisma", "src", "public", "locales", "scripts"];
|
|
25
|
+
for (const app of apps) {
|
|
26
|
+
const appDir = path.join(rootDir, "apps", app);
|
|
27
|
+
if (!import_fs_extra.default.existsSync(appDir)) {
|
|
28
|
+
this.warn(`App directory ${app} not found. Skipping.`);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
this.info(`Setting up ${app}...`);
|
|
32
|
+
for (const asset of sharedAssets) {
|
|
33
|
+
const source = path.join(rootDir, "core", asset);
|
|
34
|
+
const dest = path.join(appDir, asset);
|
|
35
|
+
if (!import_fs_extra.default.existsSync(source)) {
|
|
36
|
+
this.warn(`Source asset ${asset} not found in core.`);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const destDir = path.dirname(dest);
|
|
41
|
+
await import_fs_extra.default.ensureDir(destDir);
|
|
42
|
+
try {
|
|
43
|
+
import_fs_extra.default.lstatSync(dest);
|
|
44
|
+
import_fs_extra.default.removeSync(dest);
|
|
45
|
+
} catch (e) {
|
|
46
|
+
const isEnoent = e && typeof e === "object" && "code" in e && e.code === "ENOENT";
|
|
47
|
+
if (!isEnoent) {
|
|
48
|
+
throw e;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const relSource = path.relative(destDir, source);
|
|
52
|
+
await import_fs_extra.default.symlink(relSource, dest);
|
|
53
|
+
logger.debug(`Symlinked ${asset} to ${app}`);
|
|
54
|
+
} catch (e) {
|
|
55
|
+
if (e instanceof Error) {
|
|
56
|
+
this.error(`Failed to symlink ${asset} to ${app}: ${e.message}`);
|
|
57
|
+
} else {
|
|
58
|
+
this.error(`Failed to symlink ${asset} to ${app}: ${String(e)}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
this.success("Application setup complete.");
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export {
|
|
68
|
+
SetupCommand
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=chunk-GUUPSHWC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/setup.ts"],"sourcesContent":["import { BaseCommand, logger } from '@nexical/cli-core';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nexport default class SetupCommand extends BaseCommand {\n static description = 'Setup the application environment by symlinking core assets.';\n\n async run() {\n // Use projectRoot from BaseCommand if available, fallback to cwd\n const rootDir = this.projectRoot || process.cwd();\n\n // Verify we are in the right place\n if (!fs.existsSync(path.join(rootDir, 'core'))) {\n this.error('Could not find \"core\" directory. Are you in the project root?');\n process.exit(1);\n }\n\n const apps = ['frontend', 'backend'];\n const sharedAssets = ['prisma', 'src', 'public', 'locales', 'scripts']; // tsconfig might be needed if extended\n\n for (const app of apps) {\n const appDir = path.join(rootDir, 'apps', app);\n if (!fs.existsSync(appDir)) {\n this.warn(`App directory ${app} not found. Skipping.`);\n continue;\n }\n\n this.info(`Setting up ${app}...`);\n\n for (const asset of sharedAssets) {\n const source = path.join(rootDir, 'core', asset);\n const dest = path.join(appDir, asset);\n\n if (!fs.existsSync(source)) {\n this.warn(`Source asset ${asset} not found in core.`);\n continue;\n }\n\n try {\n // Remove existing destination if it exists (to ensure clean symlink)\n // Be careful not to delete real files if they aren't symlinks?\n // For now, we assume setup controls these.\n\n const destDir = path.dirname(dest);\n await fs.ensureDir(destDir);\n\n try {\n fs.lstatSync(dest);\n fs.removeSync(dest);\n } catch (e: unknown) {\n const isEnoent =\n e &&\n typeof e === 'object' &&\n 'code' in e &&\n (e as { code: string }).code === 'ENOENT';\n if (!isEnoent) {\n throw e;\n }\n }\n\n const relSource = path.relative(destDir, source);\n await fs.symlink(relSource, dest);\n\n logger.debug(`Symlinked ${asset} to ${app}`);\n } catch (e: unknown) {\n if (e instanceof Error) {\n this.error(`Failed to symlink ${asset} to ${app}: ${e.message}`);\n } else {\n this.error(`Failed to symlink ${asset} to ${app}: ${String(e)}`);\n }\n }\n }\n }\n\n this.success('Application setup complete.');\n }\n}\n"],"mappings":";;;;;;;;;;AAAA;AACA,sBAAe;AADf,SAAS,aAAa,cAAc;AAEpC,OAAO,UAAU;AAEjB,IAAqB,eAArB,cAA0C,YAAY;AAAA,EACpD,OAAO,cAAc;AAAA,EAErB,MAAM,MAAM;AAEV,UAAM,UAAU,KAAK,eAAe,QAAQ,IAAI;AAGhD,QAAI,CAAC,gBAAAA,QAAG,WAAW,KAAK,KAAK,SAAS,MAAM,CAAC,GAAG;AAC9C,WAAK,MAAM,+DAA+D;AAC1E,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,UAAM,OAAO,CAAC,YAAY,SAAS;AACnC,UAAM,eAAe,CAAC,UAAU,OAAO,UAAU,WAAW,SAAS;AAErE,eAAW,OAAO,MAAM;AACtB,YAAM,SAAS,KAAK,KAAK,SAAS,QAAQ,GAAG;AAC7C,UAAI,CAAC,gBAAAA,QAAG,WAAW,MAAM,GAAG;AAC1B,aAAK,KAAK,iBAAiB,GAAG,uBAAuB;AACrD;AAAA,MACF;AAEA,WAAK,KAAK,cAAc,GAAG,KAAK;AAEhC,iBAAW,SAAS,cAAc;AAChC,cAAM,SAAS,KAAK,KAAK,SAAS,QAAQ,KAAK;AAC/C,cAAM,OAAO,KAAK,KAAK,QAAQ,KAAK;AAEpC,YAAI,CAAC,gBAAAA,QAAG,WAAW,MAAM,GAAG;AAC1B,eAAK,KAAK,gBAAgB,KAAK,qBAAqB;AACpD;AAAA,QACF;AAEA,YAAI;AAKF,gBAAM,UAAU,KAAK,QAAQ,IAAI;AACjC,gBAAM,gBAAAA,QAAG,UAAU,OAAO;AAE1B,cAAI;AACF,4BAAAA,QAAG,UAAU,IAAI;AACjB,4BAAAA,QAAG,WAAW,IAAI;AAAA,UACpB,SAAS,GAAY;AACnB,kBAAM,WACJ,KACA,OAAO,MAAM,YACb,UAAU,KACT,EAAuB,SAAS;AACnC,gBAAI,CAAC,UAAU;AACb,oBAAM;AAAA,YACR;AAAA,UACF;AAEA,gBAAM,YAAY,KAAK,SAAS,SAAS,MAAM;AAC/C,gBAAM,gBAAAA,QAAG,QAAQ,WAAW,IAAI;AAEhC,iBAAO,MAAM,aAAa,KAAK,OAAO,GAAG,EAAE;AAAA,QAC7C,SAAS,GAAY;AACnB,cAAI,aAAa,OAAO;AACtB,iBAAK,MAAM,qBAAqB,KAAK,OAAO,GAAG,KAAK,EAAE,OAAO,EAAE;AAAA,UACjE,OAAO;AACL,iBAAK,MAAM,qBAAqB,KAAK,OAAO,GAAG,KAAK,OAAO,CAAC,CAAC,EAAE;AAAA,UACjE;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,SAAK,QAAQ,6BAA6B;AAAA,EAC5C;AACF;","names":["fs"]}
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,8 @@ import { fileURLToPath } from "url";
|
|
|
15
15
|
// package.json
|
|
16
16
|
var package_default = {
|
|
17
17
|
name: "@nexical/cli",
|
|
18
|
-
version: "0.11.
|
|
18
|
+
version: "0.11.15",
|
|
19
|
+
license: "Apache-2.0",
|
|
19
20
|
type: "module",
|
|
20
21
|
bin: {
|
|
21
22
|
nexical: "./dist/index.js"
|
|
@@ -43,34 +44,35 @@ var package_default = {
|
|
|
43
44
|
]
|
|
44
45
|
},
|
|
45
46
|
dependencies: {
|
|
46
|
-
"@nexical/cli-core": "^0.1.
|
|
47
|
+
"@nexical/cli-core": "^0.1.16",
|
|
47
48
|
dotenv: "^17.3.1",
|
|
48
49
|
"fast-glob": "^3.3.3",
|
|
50
|
+
glob: "^13.0.5",
|
|
49
51
|
jiti: "^2.6.1",
|
|
50
|
-
yaml: "^2.
|
|
52
|
+
yaml: "^2.8.2"
|
|
51
53
|
},
|
|
52
54
|
devDependencies: {
|
|
53
55
|
"@eslint/js": "^9.39.2",
|
|
54
56
|
"@types/fs-extra": "^11.0.4",
|
|
55
|
-
"@types/node": "^
|
|
56
|
-
"@vitest/coverage-v8": "^4.0.
|
|
57
|
+
"@types/node": "^25.3.0",
|
|
58
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
57
59
|
eslint: "^9.39.2",
|
|
58
60
|
"eslint-config-prettier": "^10.1.8",
|
|
59
|
-
"eslint-plugin-astro": "^1.
|
|
61
|
+
"eslint-plugin-astro": "^1.6.0",
|
|
60
62
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
61
63
|
"eslint-plugin-react": "^7.37.5",
|
|
62
64
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
63
65
|
execa: "^9.6.1",
|
|
64
|
-
"fs-extra": "^11.3.
|
|
65
|
-
globals: "^17.
|
|
66
|
+
"fs-extra": "^11.3.3",
|
|
67
|
+
globals: "^17.3.0",
|
|
66
68
|
husky: "^9.1.7",
|
|
67
69
|
"lint-staged": "^16.2.7",
|
|
68
70
|
prettier: "^3.8.1",
|
|
69
|
-
tsup: "^8.
|
|
71
|
+
tsup: "^8.5.1",
|
|
70
72
|
tsx: "^4.21.0",
|
|
71
|
-
typescript: "^5.
|
|
72
|
-
"typescript-eslint": "^8.
|
|
73
|
-
vitest: "^4.0.
|
|
73
|
+
typescript: "^5.9.3",
|
|
74
|
+
"typescript-eslint": "^8.56.0",
|
|
75
|
+
vitest: "^4.0.18"
|
|
74
76
|
}
|
|
75
77
|
};
|
|
76
78
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts","../package.json"],"sourcesContent":["#!/usr/bin/env node\nimport { CLI, findProjectRoot } from '@nexical/cli-core';\nimport { fileURLToPath } from 'node:url';\nimport { discoverCommandDirectories } from './src/utils/discovery.js';\nimport pkg from './package.json';\nimport path from 'node:path';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nconst commandName = 'nexical';\nconst projectRoot = (await findProjectRoot(commandName, process.cwd())) || process.cwd();\nconst coreCommandsDir = path.resolve(__dirname, './src/commands');\nconst additionalCommands = discoverCommandDirectories(projectRoot);\n\n// Filter out duplicate core commands and source versions\nconst filteredAdditional = additionalCommands.filter((dir) => {\n const resolvedDir = path.resolve(dir);\n const resolvedCore = path.resolve(coreCommandsDir);\n\n if (resolvedDir === resolvedCore) return false;\n\n // Check if this is another instance of the core CLI commands (by checking path suffix)\n const coreSuffix = path.join('@nexical', 'cli', 'dist', 'src', 'commands');\n const coreSuffixSrc = path.join('packages', 'cli', 'dist', 'src', 'commands');\n const coreSuffixRawSrc = path.join('packages', 'cli', 'src', 'commands');\n\n if (\n resolvedDir.endsWith(coreSuffix) ||\n resolvedDir.endsWith(coreSuffixSrc) ||\n resolvedDir.endsWith(coreSuffixRawSrc)\n ) {\n return false;\n }\n\n // Handle mismatch between dist/src and src/\n if (resolvedCore.includes(path.join(path.sep, 'dist', 'src', 'commands'))) {\n const srcVersion = resolvedCore.replace(\n path.join(path.sep, 'dist', 'src', 'commands'),\n path.join(path.sep, 'src', 'commands'),\n );\n if (resolvedDir === srcVersion) return false;\n }\n\n return true;\n});\n\nconst app = new CLI({\n version: pkg.version,\n commandName: commandName,\n searchDirectories: [...new Set([coreCommandsDir, ...filteredAdditional])],\n});\napp.start();\n","{\n \"name\": \"@nexical/cli\",\n \"version\": \"0.11.
|
|
1
|
+
{"version":3,"sources":["../index.ts","../package.json"],"sourcesContent":["#!/usr/bin/env node\nimport { CLI, findProjectRoot } from '@nexical/cli-core';\nimport { fileURLToPath } from 'node:url';\nimport { discoverCommandDirectories } from './src/utils/discovery.js';\nimport pkg from './package.json';\nimport path from 'node:path';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nconst commandName = 'nexical';\nconst projectRoot = (await findProjectRoot(commandName, process.cwd())) || process.cwd();\nconst coreCommandsDir = path.resolve(__dirname, './src/commands');\nconst additionalCommands = discoverCommandDirectories(projectRoot);\n\n// Filter out duplicate core commands and source versions\nconst filteredAdditional = additionalCommands.filter((dir) => {\n const resolvedDir = path.resolve(dir);\n const resolvedCore = path.resolve(coreCommandsDir);\n\n if (resolvedDir === resolvedCore) return false;\n\n // Check if this is another instance of the core CLI commands (by checking path suffix)\n const coreSuffix = path.join('@nexical', 'cli', 'dist', 'src', 'commands');\n const coreSuffixSrc = path.join('packages', 'cli', 'dist', 'src', 'commands');\n const coreSuffixRawSrc = path.join('packages', 'cli', 'src', 'commands');\n\n if (\n resolvedDir.endsWith(coreSuffix) ||\n resolvedDir.endsWith(coreSuffixSrc) ||\n resolvedDir.endsWith(coreSuffixRawSrc)\n ) {\n return false;\n }\n\n // Handle mismatch between dist/src and src/\n if (resolvedCore.includes(path.join(path.sep, 'dist', 'src', 'commands'))) {\n const srcVersion = resolvedCore.replace(\n path.join(path.sep, 'dist', 'src', 'commands'),\n path.join(path.sep, 'src', 'commands'),\n );\n if (resolvedDir === srcVersion) return false;\n }\n\n return true;\n});\n\nconst app = new CLI({\n version: pkg.version,\n commandName: commandName,\n searchDirectories: [...new Set([coreCommandsDir, ...filteredAdditional])],\n});\napp.start();\n","{\n \"name\": \"@nexical/cli\",\n \"version\": \"0.11.15\",\n \"license\": \"Apache-2.0\",\n \"type\": \"module\",\n \"bin\": {\n \"nexical\": \"./dist/index.js\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"start\": \"node dist/index.js\",\n \"test\": \"npm run test:unit && npm run test:integration && npm run test:e2e\",\n \"test:unit\": \"vitest run --config vitest.config.ts --coverage\",\n \"test:integration\": \"vitest run --config vitest.integration.config.ts\",\n \"test:e2e\": \"npm run build && vitest run --config vitest.e2e.config.ts\",\n \"test:watch\": \"vitest\",\n \"format\": \"prettier --write .\",\n \"lint\": \"eslint .\",\n \"lint:fix\": \"eslint . --fix\",\n \"prepare\": \"husky\"\n },\n \"lint-staged\": {\n \"**/*\": [\n \"prettier --write --ignore-unknown\"\n ],\n \"**/*.{js,jsx,ts,tsx,astro}\": [\n \"eslint --fix\"\n ]\n },\n \"dependencies\": {\n \"@nexical/cli-core\": \"^0.1.16\",\n \"dotenv\": \"^17.3.1\",\n \"fast-glob\": \"^3.3.3\",\n \"glob\": \"^13.0.5\",\n \"jiti\": \"^2.6.1\",\n \"yaml\": \"^2.8.2\"\n },\n \"devDependencies\": {\n \"@eslint/js\": \"^9.39.2\",\n \"@types/fs-extra\": \"^11.0.4\",\n \"@types/node\": \"^25.3.0\",\n \"@vitest/coverage-v8\": \"^4.0.18\",\n \"eslint\": \"^9.39.2\",\n \"eslint-config-prettier\": \"^10.1.8\",\n \"eslint-plugin-astro\": \"^1.6.0\",\n \"eslint-plugin-jsx-a11y\": \"^6.10.2\",\n \"eslint-plugin-react\": \"^7.37.5\",\n \"eslint-plugin-react-hooks\": \"^7.0.1\",\n \"execa\": \"^9.6.1\",\n \"fs-extra\": \"^11.3.3\",\n \"globals\": \"^17.3.0\",\n \"husky\": \"^9.1.7\",\n \"lint-staged\": \"^16.2.7\",\n \"prettier\": \"^3.8.1\",\n \"tsup\": \"^8.5.1\",\n \"tsx\": \"^4.21.0\",\n \"typescript\": \"^5.9.3\",\n \"typescript-eslint\": \"^8.56.0\",\n \"vitest\": \"^4.0.18\"\n }\n}\n"],"mappings":";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Aa,QAAQ,IAAI,CAAC,KAAM,QAAQ,IAAI;AACvF,IAAM,kBAAkB,KAAK,QAAQ,WAAW,gBAAgB;AAChE,IAAM,qBAAqB,2BAA2B,WAAW;AAGjE,IAAM,qBAAqB,mBAAmB,OAAO,CAAC,QAAQ;AAC5D,QAAM,cAAc,KAAK,QAAQ,GAAG;AACpC,QAAM,eAAe,KAAK,QAAQ,eAAe;AAEjD,MAAI,gBAAgB,aAAc,QAAO;AAGzC,QAAM,aAAa,KAAK,KAAK,YAAY,OAAO,QAAQ,OAAO,UAAU;AACzE,QAAM,gBAAgB,KAAK,KAAK,YAAY,OAAO,QAAQ,OAAO,UAAU;AAC5E,QAAM,mBAAmB,KAAK,KAAK,YAAY,OAAO,OAAO,UAAU;AAEvE,MACE,YAAY,SAAS,UAAU,KAC/B,YAAY,SAAS,aAAa,KAClC,YAAY,SAAS,gBAAgB,GACrC;AACA,WAAO;AAAA,EACT;AAGA,MAAI,aAAa,SAAS,KAAK,KAAK,KAAK,KAAK,QAAQ,OAAO,UAAU,CAAC,GAAG;AACzE,UAAM,aAAa,aAAa;AAAA,MAC9B,KAAK,KAAK,KAAK,KAAK,QAAQ,OAAO,UAAU;AAAA,MAC7C,KAAK,KAAK,KAAK,KAAK,OAAO,UAAU;AAAA,IACvC;AACA,QAAI,gBAAgB,WAAY,QAAO;AAAA,EACzC;AAEA,SAAO;AACT,CAAC;AAED,IAAM,MAAM,IAAI,IAAI;AAAA,EAClB,SAAS,gBAAI;AAAA,EACb;AAAA,EACA,mBAAmB,CAAC,GAAG,oBAAI,IAAI,CAAC,iBAAiB,GAAG,kBAAkB,CAAC,CAAC;AAC1E,CAAC;AACD,IAAI,MAAM;","names":[]}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { createRequire } from "module"; const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
SetupCommand
|
|
4
|
+
} from "../../chunk-GUUPSHWC.js";
|
|
5
|
+
import {
|
|
6
|
+
require_lib
|
|
7
|
+
} from "../../chunk-OUGA4CB4.js";
|
|
2
8
|
import {
|
|
3
9
|
addAll,
|
|
4
10
|
clone,
|
|
5
11
|
commit,
|
|
6
12
|
renameRemote,
|
|
7
13
|
updateSubmodules
|
|
8
|
-
} from "../../chunk-
|
|
14
|
+
} from "../../chunk-GEESHGE4.js";
|
|
9
15
|
import {
|
|
10
16
|
resolveGitUrl
|
|
11
17
|
} from "../../chunk-PJIOCW2A.js";
|
|
12
|
-
import {
|
|
13
|
-
require_lib
|
|
14
|
-
} from "../../chunk-OUGA4CB4.js";
|
|
15
18
|
import {
|
|
16
19
|
__toESM,
|
|
17
20
|
init_esm_shims
|
|
@@ -62,6 +65,10 @@ var InitCommand = class extends BaseCommand {
|
|
|
62
65
|
await runCommand("npm install", targetPath);
|
|
63
66
|
this.info("Setting up upstream remote...");
|
|
64
67
|
await renameRemote("origin", "upstream", targetPath);
|
|
68
|
+
this.info("Initializing project assets...");
|
|
69
|
+
const setup = new SetupCommand(this.cli, { ...this.globalOptions, rootDir: targetPath });
|
|
70
|
+
await setup.init();
|
|
71
|
+
await setup.run();
|
|
65
72
|
this.info("Running project setup...");
|
|
66
73
|
await runCommand("npm run setup", targetPath);
|
|
67
74
|
const configPath = path.join(targetPath, "nexical.yaml");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/init.ts"],"sourcesContent":["import { type CommandDefinition, BaseCommand, logger, runCommand } from '@nexical/cli-core';\nimport * as git from '../utils/git.js';\nimport { resolveGitUrl } from '../utils/url-resolver.js';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nexport default class InitCommand extends BaseCommand {\n static usage = 'init';\n static description = 'Initialize a new Nexical project.';\n static requiresProject = false;\n\n static args: CommandDefinition = {\n args: [\n { name: 'directory', required: true, description: 'Directory to initialize the project in' },\n ],\n options: [\n {\n name: '--repo <url>',\n description: 'Starter repository URL (supports gh@owner/repo syntax)',\n default: 'gh@nexical/app-starter',\n },\n ],\n };\n\n async run(options: { directory: string; repo: string }) {\n const directory = options.directory;\n const targetPath = path.resolve(process.cwd(), directory);\n const repoUrl = resolveGitUrl(options.repo);\n\n logger.debug('Init options:', { directory, targetPath, repoUrl });\n\n this.info(`Initializing project in: ${targetPath}`);\n this.info(`Using starter repository: ${repoUrl}`);\n\n if (await fs.pathExists(targetPath)) {\n if ((await fs.readdir(targetPath)).length > 0) {\n this.error(`Directory ${directory} is not empty.`);\n process.exit(1);\n }\n } else {\n await fs.mkdir(targetPath, { recursive: true });\n }\n\n try {\n this.info('Cloning starter repository...');\n await git.clone(repoUrl, targetPath, { recursive: true });\n\n this.info('Updating submodules...');\n await git.updateSubmodules(targetPath);\n\n this.info('Installing dependencies...');\n await runCommand('npm install', targetPath);\n\n this.info('Setting up upstream remote...');\n await git.renameRemote('origin', 'upstream', targetPath);\n\n // Run setup script\n this.info('Running project setup...');\n await runCommand('npm run setup', targetPath);\n\n // Check for nexical.yaml, if not present create a default one\n const configPath = path.join(targetPath, 'nexical.yaml');\n if (!(await fs.pathExists(configPath))) {\n this.info('Creating default nexical.yaml...');\n await fs.writeFile(configPath, 'name: ' + path.basename(targetPath) + '\\nmodules: []\\n');\n }\n\n // Create VERSION file\n const versionPath = path.join(targetPath, 'VERSION');\n // Check if version file exists, if not create it\n if (!(await fs.pathExists(versionPath))) {\n this.info('Creating VERSION file with 0.1.0...');\n await fs.writeFile(versionPath, '0.1.0');\n }\n\n await git.addAll(targetPath);\n await git.commit('Initial site commit', targetPath);\n\n this.success(`Project initialized successfully in ${directory}!`);\n } catch (error: unknown) {\n if (error instanceof Error) {\n this.error(`Failed to initialize project: ${error.message}`);\n } else {\n this.error(`Failed to initialize project: ${String(error)}`);\n }\n process.exit(1);\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/init.ts"],"sourcesContent":["import { type CommandDefinition, BaseCommand, logger, runCommand } from '@nexical/cli-core';\nimport * as git from '../utils/git.js';\nimport { resolveGitUrl } from '../utils/url-resolver.js';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport SetupCommand from './setup.js';\n\nexport default class InitCommand extends BaseCommand {\n static usage = 'init';\n static description = 'Initialize a new Nexical project.';\n static requiresProject = false;\n\n static args: CommandDefinition = {\n args: [\n { name: 'directory', required: true, description: 'Directory to initialize the project in' },\n ],\n options: [\n {\n name: '--repo <url>',\n description: 'Starter repository URL (supports gh@owner/repo syntax)',\n default: 'gh@nexical/app-starter',\n },\n ],\n };\n\n async run(options: { directory: string; repo: string }) {\n const directory = options.directory;\n const targetPath = path.resolve(process.cwd(), directory);\n const repoUrl = resolveGitUrl(options.repo);\n\n logger.debug('Init options:', { directory, targetPath, repoUrl });\n\n this.info(`Initializing project in: ${targetPath}`);\n this.info(`Using starter repository: ${repoUrl}`);\n\n if (await fs.pathExists(targetPath)) {\n if ((await fs.readdir(targetPath)).length > 0) {\n this.error(`Directory ${directory} is not empty.`);\n process.exit(1);\n }\n } else {\n await fs.mkdir(targetPath, { recursive: true });\n }\n\n try {\n this.info('Cloning starter repository...');\n await git.clone(repoUrl, targetPath, { recursive: true });\n\n this.info('Updating submodules...');\n await git.updateSubmodules(targetPath);\n\n this.info('Installing dependencies...');\n await runCommand('npm install', targetPath);\n\n this.info('Setting up upstream remote...');\n await git.renameRemote('origin', 'upstream', targetPath);\n\n // Run Nexical CLI setup command\n this.info('Initializing project assets...');\n const setup = new SetupCommand(this.cli, { ...this.globalOptions, rootDir: targetPath });\n await setup.init();\n await setup.run();\n\n // Run setup script\n this.info('Running project setup...');\n await runCommand('npm run setup', targetPath);\n\n // Check for nexical.yaml, if not present create a default one\n const configPath = path.join(targetPath, 'nexical.yaml');\n if (!(await fs.pathExists(configPath))) {\n this.info('Creating default nexical.yaml...');\n await fs.writeFile(configPath, 'name: ' + path.basename(targetPath) + '\\nmodules: []\\n');\n }\n\n // Create VERSION file\n const versionPath = path.join(targetPath, 'VERSION');\n // Check if version file exists, if not create it\n if (!(await fs.pathExists(versionPath))) {\n this.info('Creating VERSION file with 0.1.0...');\n await fs.writeFile(versionPath, '0.1.0');\n }\n\n await git.addAll(targetPath);\n await git.commit('Initial site commit', targetPath);\n\n this.success(`Project initialized successfully in ${directory}!`);\n } catch (error: unknown) {\n if (error instanceof Error) {\n this.error(`Failed to initialize project: ${error.message}`);\n } else {\n this.error(`Failed to initialize project: ${String(error)}`);\n }\n process.exit(1);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,SAAiC,aAAa,QAAQ,kBAAkB;AAGxE,sBAAe;AACf,OAAO,UAAU;AAGjB,IAAqB,cAArB,cAAyC,YAAY;AAAA,EACnD,OAAO,QAAQ;AAAA,EACf,OAAO,cAAc;AAAA,EACrB,OAAO,kBAAkB;AAAA,EAEzB,OAAO,OAA0B;AAAA,IAC/B,MAAM;AAAA,MACJ,EAAE,MAAM,aAAa,UAAU,MAAM,aAAa,yCAAyC;AAAA,IAC7F;AAAA,IACA,SAAS;AAAA,MACP;AAAA,QACE,MAAM;AAAA,QACN,aAAa;AAAA,QACb,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,IAAI,SAA8C;AACtD,UAAM,YAAY,QAAQ;AAC1B,UAAM,aAAa,KAAK,QAAQ,QAAQ,IAAI,GAAG,SAAS;AACxD,UAAM,UAAU,cAAc,QAAQ,IAAI;AAE1C,WAAO,MAAM,iBAAiB,EAAE,WAAW,YAAY,QAAQ,CAAC;AAEhE,SAAK,KAAK,4BAA4B,UAAU,EAAE;AAClD,SAAK,KAAK,6BAA6B,OAAO,EAAE;AAEhD,QAAI,MAAM,gBAAAA,QAAG,WAAW,UAAU,GAAG;AACnC,WAAK,MAAM,gBAAAA,QAAG,QAAQ,UAAU,GAAG,SAAS,GAAG;AAC7C,aAAK,MAAM,aAAa,SAAS,gBAAgB;AACjD,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAAA,IACF,OAAO;AACL,YAAM,gBAAAA,QAAG,MAAM,YAAY,EAAE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AAAA,EACF;AACF;","names":["fs"]}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { createRequire } from "module"; const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
+
require_lib
|
|
4
|
+
} from "../../../chunk-OUGA4CB4.js";
|
|
5
|
+
import {
|
|
6
|
+
addSubmodule,
|
|
3
7
|
clone,
|
|
4
8
|
getRemoteUrl
|
|
5
|
-
} from "../../../chunk-
|
|
9
|
+
} from "../../../chunk-GEESHGE4.js";
|
|
6
10
|
import {
|
|
7
11
|
resolveGitUrl
|
|
8
12
|
} from "../../../chunk-PJIOCW2A.js";
|
|
9
|
-
import {
|
|
10
|
-
require_lib
|
|
11
|
-
} from "../../../chunk-OUGA4CB4.js";
|
|
12
13
|
import {
|
|
13
14
|
__toESM,
|
|
14
15
|
init_esm_shims
|
|
@@ -132,7 +133,7 @@ var ModuleAddCommand = class extends BaseCommand {
|
|
|
132
133
|
} else {
|
|
133
134
|
this.info(`Installing ${moduleName} (${moduleType}) to ${relativeTargetDir}...`);
|
|
134
135
|
await import_fs_extra.default.ensureDir(path.dirname(targetDir));
|
|
135
|
-
await
|
|
136
|
+
await addSubmodule(cleanUrl, relativeTargetDir, projectRoot);
|
|
136
137
|
}
|
|
137
138
|
await this.addToConfig(moduleName, moduleType);
|
|
138
139
|
if (dependencies.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/commands/module/add.ts"],"sourcesContent":["import { type CommandDefinition, BaseCommand, logger, runCommand } from '@nexical/cli-core';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport { clone, getRemoteUrl } from '../../utils/git.js';\nimport { resolveGitUrl } from '../../utils/url-resolver.js';\nimport YAML from 'yaml';\n\nexport default class ModuleAddCommand extends BaseCommand {\n static usage = 'module add <url>';\n static description = 'Add a module and its dependencies as git submodules.';\n static requiresProject = true;\n\n static args: CommandDefinition = {\n args: [{ name: 'url', required: true, description: 'Git repository URL or gh@org/repo' }],\n };\n\n private visited = new Set<string>();\n\n async run(options: { url: string }) {\n const projectRoot = this.projectRoot as string;\n const { url } = options;\n\n if (!url) {\n this.error('Please specify a repository URL.');\n return;\n }\n\n try {\n await this.installModule(url);\n\n this.info('Syncing workspace dependencies...');\n await runCommand('npm install', projectRoot);\n\n this.success('All modules installed successfully.');\n } catch (e: unknown) {\n if (e instanceof Error) {\n this.error(`Failed to add module: ${e.message}`);\n } else {\n this.error(`Failed to add module: ${String(e)}`);\n }\n }\n }\n\n private async installModule(url: string) {\n const projectRoot = this.projectRoot as string;\n\n // Resolve URL using utility\n url = resolveGitUrl(url);\n\n const [repoUrl, subPath] = url.split('.git//');\n const cleanUrl = subPath ? repoUrl + '.git' : url;\n\n if (this.visited.has(cleanUrl)) {\n logger.debug(`Already visited ${cleanUrl}, skipping.`);\n return;\n }\n this.visited.add(cleanUrl);\n\n this.info(`Inspecting ${cleanUrl}...`);\n\n // Stage 1: Inspect (Temp Clone)\n const stagingDir = path.resolve(\n projectRoot!,\n '.nexical',\n 'cache',\n `staging-${Date.now()}-${Math.random().toString(36).substring(7)}`,\n );\n let moduleName = '';\n let moduleType: 'backend' | 'frontend' = 'backend'; // Default to backend if uncertain, but we should detect.\n let dependencies: string[] = [];\n\n try {\n await fs.ensureDir(stagingDir);\n\n // Shallow clone to inspect\n await clone(cleanUrl, stagingDir, { depth: 1 });\n\n // Search path handling\n const searchPath = subPath ? path.join(stagingDir, subPath) : stagingDir;\n\n // 1. Detect Module Name & Dependencies\n const moduleYamlPath = path.join(searchPath, 'module.yaml');\n const moduleYmlPath = path.join(searchPath, 'module.yml');\n const pkgJsonPath = path.join(searchPath, 'package.json');\n\n let configPath = '';\n if (await fs.pathExists(moduleYamlPath)) configPath = moduleYamlPath;\n else if (await fs.pathExists(moduleYmlPath)) configPath = moduleYmlPath;\n\n // Try to get name from module.yaml/yml\n if (configPath) {\n const configContent = await fs.readFile(configPath, 'utf8');\n const config = YAML.parse(configContent);\n if (config.name) moduleName = config.name;\n dependencies = config.dependencies || [];\n }\n\n // If no name yet, try package.json\n if (!moduleName && (await fs.pathExists(pkgJsonPath))) {\n try {\n const pkg = await fs.readJson(pkgJsonPath);\n if (pkg.name) {\n // Handle scoped packages @modules/name -> name\n moduleName = pkg.name.startsWith('@modules/') ? pkg.name.split('/')[1] : pkg.name;\n }\n } catch {\n /* ignore */\n }\n }\n\n // Fallback to git repo name if still no name\n if (!moduleName) {\n moduleName = path.basename(cleanUrl, '.git');\n }\n\n // 2. Detect Module Type\n // Frontend indicators: ui.yaml, or specifically typed in module.config.mjs (harder to parse statically), or package.json dependencies like 'react'/'astro' (maybe too broad).\n // Backend indicators: models.yaml, api.yaml, access.yaml.\n\n const hasUiYaml = await fs.pathExists(path.join(searchPath, 'ui.yaml'));\n const hasModelsYaml = await fs.pathExists(path.join(searchPath, 'models.yaml'));\n const hasApiYaml = await fs.pathExists(path.join(searchPath, 'api.yaml'));\n\n if (hasUiYaml) {\n moduleType = 'frontend';\n } else if (hasModelsYaml || hasApiYaml) {\n moduleType = 'backend';\n } else {\n // Fallback: Check checking package.json for \"auth-astro\" which is common in both, but maybe \"react\" or \"vue\" for frontend?\n // Let's assume Backend default if ambiguous for now, or check for specific folder structure?\n // Let's look for `src/components` vs `src/services`.\n if (await fs.pathExists(path.join(searchPath, 'src', 'components'))) {\n moduleType = 'frontend';\n } else {\n moduleType = 'backend';\n }\n }\n\n // Normalize dependencies\n if (dependencies && !Array.isArray(dependencies)) {\n dependencies = Object.keys(dependencies);\n }\n } finally {\n // Cleanup staging always\n await fs.remove(stagingDir);\n }\n\n // Stage 2: Conflict Detection & Path Resolution\n const modulesBaseDir =\n moduleType === 'frontend' ? 'apps/frontend/modules' : 'apps/backend/modules';\n const relativeTargetDir = path.join(modulesBaseDir, moduleName);\n const targetDir = path.join(projectRoot!, relativeTargetDir);\n\n if (await fs.pathExists(targetDir)) {\n // Check origin\n const existingRemote = await getRemoteUrl(targetDir);\n const normExisting = existingRemote.replace(/\\.git$/, '');\n const normNew = cleanUrl.replace(/\\.git$/, '');\n\n if (normExisting !== normNew && existingRemote !== '') {\n throw new Error(\n `Dependency Conflict! Module '${moduleName}' exists in ${moduleType} but remote '${existingRemote}' does not match '${cleanUrl}'.`,\n );\n }\n\n this.info(`Module ${moduleName} already installed in ${moduleType}.`);\n } else {\n // Stage 3: Submodule Add\n this.info(`Installing ${moduleName} (${moduleType}) to ${relativeTargetDir}...`);\n await fs.ensureDir(path.dirname(targetDir)); // Ensure apps/backend/modules exists\n await runCommand(`git submodule add ${cleanUrl} ${relativeTargetDir}`, projectRoot!);\n }\n\n // Update nexical.yaml\n await this.addToConfig(moduleName, moduleType);\n\n // Stage 4: Recurse\n if (dependencies.length > 0) {\n this.info(`Resolving ${dependencies.length} dependencies for ${moduleName}...`);\n for (const depUrl of dependencies) {\n await this.installModule(depUrl);\n }\n }\n }\n\n private async addToConfig(moduleName: string, type: 'backend' | 'frontend') {\n const projectRoot = this.projectRoot as string;\n const configPath = path.join(projectRoot, 'nexical.yaml');\n\n if (!(await fs.pathExists(configPath))) {\n logger.warn('nexical.yaml not found, skipping module list update.');\n return;\n }\n\n try {\n const content = await fs.readFile(configPath, 'utf8');\n const config = YAML.parse(content) || {};\n\n if (!config.modules) config.modules = {};\n\n // Migration: If modules is array, convert to object\n if (Array.isArray(config.modules)) {\n const oldModules = config.modules;\n config.modules = { backend: oldModules, frontend: [] }; // Assume old were backend? Or just move them to backend for safety.\n }\n\n if (!config.modules[type]) config.modules[type] = [];\n\n if (!config.modules[type].includes(moduleName)) {\n config.modules[type].push(moduleName);\n await fs.writeFile(configPath, YAML.stringify(config));\n logger.debug(`Added ${moduleName} to nexical.yaml modules.${type} list.`);\n }\n } catch (e: unknown) {\n if (e instanceof Error) {\n logger.warn(`Failed to update nexical.yaml: ${e.message}`);\n } else {\n logger.warn(`Failed to update nexical.yaml: ${String(e)}`);\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA,sBAAe;AADf,SAAiC,a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,EACF;AACF;","names":["fs"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/module/add.ts"],"sourcesContent":["import { type CommandDefinition, BaseCommand, logger, runCommand } from '@nexical/cli-core';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport { clone, getRemoteUrl, addSubmodule } from '../../utils/git.js';\nimport { resolveGitUrl } from '../../utils/url-resolver.js';\nimport YAML from 'yaml';\n\nexport default class ModuleAddCommand extends BaseCommand {\n static usage = 'module add <url>';\n static description = 'Add a module and its dependencies as git submodules.';\n static requiresProject = true;\n\n static args: CommandDefinition = {\n args: [{ name: 'url', required: true, description: 'Git repository URL or gh@org/repo' }],\n };\n\n private visited = new Set<string>();\n\n async run(options: { url: string }) {\n const projectRoot = this.projectRoot as string;\n const { url } = options;\n\n if (!url) {\n this.error('Please specify a repository URL.');\n return;\n }\n\n try {\n await this.installModule(url);\n\n this.info('Syncing workspace dependencies...');\n await runCommand('npm install', projectRoot);\n\n this.success('All modules installed successfully.');\n } catch (e: unknown) {\n if (e instanceof Error) {\n this.error(`Failed to add module: ${e.message}`);\n } else {\n this.error(`Failed to add module: ${String(e)}`);\n }\n }\n }\n\n private async installModule(url: string) {\n const projectRoot = this.projectRoot as string;\n\n // Resolve URL using utility\n url = resolveGitUrl(url);\n\n const [repoUrl, subPath] = url.split('.git//');\n const cleanUrl = subPath ? repoUrl + '.git' : url;\n\n if (this.visited.has(cleanUrl)) {\n logger.debug(`Already visited ${cleanUrl}, skipping.`);\n return;\n }\n this.visited.add(cleanUrl);\n\n this.info(`Inspecting ${cleanUrl}...`);\n\n // Stage 1: Inspect (Temp Clone)\n const stagingDir = path.resolve(\n projectRoot!,\n '.nexical',\n 'cache',\n `staging-${Date.now()}-${Math.random().toString(36).substring(7)}`,\n );\n let moduleName = '';\n let moduleType: 'backend' | 'frontend' = 'backend'; // Default to backend if uncertain, but we should detect.\n let dependencies: string[] = [];\n\n try {\n await fs.ensureDir(stagingDir);\n\n // Shallow clone to inspect\n await clone(cleanUrl, stagingDir, { depth: 1 });\n\n // Search path handling\n const searchPath = subPath ? path.join(stagingDir, subPath) : stagingDir;\n\n // 1. Detect Module Name & Dependencies\n const moduleYamlPath = path.join(searchPath, 'module.yaml');\n const moduleYmlPath = path.join(searchPath, 'module.yml');\n const pkgJsonPath = path.join(searchPath, 'package.json');\n\n let configPath = '';\n if (await fs.pathExists(moduleYamlPath)) configPath = moduleYamlPath;\n else if (await fs.pathExists(moduleYmlPath)) configPath = moduleYmlPath;\n\n // Try to get name from module.yaml/yml\n if (configPath) {\n const configContent = await fs.readFile(configPath, 'utf8');\n const config = YAML.parse(configContent);\n if (config.name) moduleName = config.name;\n dependencies = config.dependencies || [];\n }\n\n // If no name yet, try package.json\n if (!moduleName && (await fs.pathExists(pkgJsonPath))) {\n try {\n const pkg = await fs.readJson(pkgJsonPath);\n if (pkg.name) {\n // Handle scoped packages @modules/name -> name\n moduleName = pkg.name.startsWith('@modules/') ? pkg.name.split('/')[1] : pkg.name;\n }\n } catch {\n /* ignore */\n }\n }\n\n // Fallback to git repo name if still no name\n if (!moduleName) {\n moduleName = path.basename(cleanUrl, '.git');\n }\n\n // 2. Detect Module Type\n // Frontend indicators: ui.yaml, or specifically typed in module.config.mjs (harder to parse statically), or package.json dependencies like 'react'/'astro' (maybe too broad).\n // Backend indicators: models.yaml, api.yaml, access.yaml.\n\n const hasUiYaml = await fs.pathExists(path.join(searchPath, 'ui.yaml'));\n const hasModelsYaml = await fs.pathExists(path.join(searchPath, 'models.yaml'));\n const hasApiYaml = await fs.pathExists(path.join(searchPath, 'api.yaml'));\n\n if (hasUiYaml) {\n moduleType = 'frontend';\n } else if (hasModelsYaml || hasApiYaml) {\n moduleType = 'backend';\n } else {\n // Fallback: Check checking package.json for \"auth-astro\" which is common in both, but maybe \"react\" or \"vue\" for frontend?\n // Let's assume Backend default if ambiguous for now, or check for specific folder structure?\n // Let's look for `src/components` vs `src/services`.\n if (await fs.pathExists(path.join(searchPath, 'src', 'components'))) {\n moduleType = 'frontend';\n } else {\n moduleType = 'backend';\n }\n }\n\n // Normalize dependencies\n if (dependencies && !Array.isArray(dependencies)) {\n dependencies = Object.keys(dependencies);\n }\n } finally {\n // Cleanup staging always\n await fs.remove(stagingDir);\n }\n\n // Stage 2: Conflict Detection & Path Resolution\n const modulesBaseDir =\n moduleType === 'frontend' ? 'apps/frontend/modules' : 'apps/backend/modules';\n const relativeTargetDir = path.join(modulesBaseDir, moduleName);\n const targetDir = path.join(projectRoot!, relativeTargetDir);\n\n if (await fs.pathExists(targetDir)) {\n // Check origin\n const existingRemote = await getRemoteUrl(targetDir);\n const normExisting = existingRemote.replace(/\\.git$/, '');\n const normNew = cleanUrl.replace(/\\.git$/, '');\n\n if (normExisting !== normNew && existingRemote !== '') {\n throw new Error(\n `Dependency Conflict! Module '${moduleName}' exists in ${moduleType} but remote '${existingRemote}' does not match '${cleanUrl}'.`,\n );\n }\n\n this.info(`Module ${moduleName} already installed in ${moduleType}.`);\n } else {\n // Stage 3: Submodule Add\n this.info(`Installing ${moduleName} (${moduleType}) to ${relativeTargetDir}...`);\n await fs.ensureDir(path.dirname(targetDir)); // Ensure apps/backend/modules exists\n await addSubmodule(cleanUrl, relativeTargetDir, projectRoot!);\n }\n\n // Update nexical.yaml\n await this.addToConfig(moduleName, moduleType);\n\n // Stage 4: Recurse\n if (dependencies.length > 0) {\n this.info(`Resolving ${dependencies.length} dependencies for ${moduleName}...`);\n for (const depUrl of dependencies) {\n await this.installModule(depUrl);\n }\n }\n }\n\n private async addToConfig(moduleName: string, type: 'backend' | 'frontend') {\n const projectRoot = this.projectRoot as string;\n const configPath = path.join(projectRoot, 'nexical.yaml');\n\n if (!(await fs.pathExists(configPath))) {\n logger.warn('nexical.yaml not found, skipping module list update.');\n return;\n }\n\n try {\n const content = await fs.readFile(configPath, 'utf8');\n const config = YAML.parse(content) || {};\n\n if (!config.modules) config.modules = {};\n\n // Migration: If modules is array, convert to object\n if (Array.isArray(config.modules)) {\n const oldModules = config.modules;\n config.modules = { backend: oldModules, frontend: [] }; // Assume old were backend? Or just move them to backend for safety.\n }\n\n if (!config.modules[type]) config.modules[type] = [];\n\n if (!config.modules[type].includes(moduleName)) {\n config.modules[type].push(moduleName);\n await fs.writeFile(configPath, YAML.stringify(config));\n logger.debug(`Added ${moduleName} to nexical.yaml modules.${type} list.`);\n }\n } catch (e: unknown) {\n if (e instanceof Error) {\n logger.warn(`Failed to update nexical.yaml: ${e.message}`);\n } else {\n logger.warn(`Failed to update nexical.yaml: ${String(e)}`);\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AACA,sBAAe;AADf,SAAiC,aAAa,QAAQ,kBAAkB;AAExE,OAAO,UAAU;AAGjB,OAAO,UAAU;AAEjB,IAAqB,mBAArB,cAA8C,YAAY;AAAA,EACxD,OAAO,QAAQ;AAAA,EACf,OAAO,cAAc;AAAA,EACrB,OAAO,kBAAkB;AAAA,EAEzB,OAAO,OAA0B;AAAA,IAC/B,MAAM,CAAC,EAAE,MAAM,OAAO,UAAU,MAAM,aAAa,oCAAoC,CAAC;AAAA,EAC1F;AAAA,EAEQ,UAAU,oBAAI,IAAY;AAAA,EAElC,MAAM,IAAI,SAA0B;AAClC,UAAM,cAAc,KAAK;AACzB,UAAM,EAAE,IAAI,IAAI;AAEhB,QAAI,CAAC,KAAK;AACR,WAAK,MAAM,kCAAkC;AAC7C;AAAA,IACF;AAEA,QAAI;AACF,YAAM,KAAK,cAAc,GAAG;AAE5B,WAAK,KAAK,mCAAmC;AAC7C,YAAM,WAAW,eAAe,WAAW;AAE3C,WAAK,QAAQ,qCAAqC;AAAA,IACpD,SAAS,GAAY;AACnB,UAAI,aAAa,OAAO;AACtB,aAAK,MAAM,yBAAyB,EAAE,OAAO,EAAE;AAAA,MACjD,OAAO;AACL,aAAK,MAAM,yBAAyB,OAAO,CAAC,CAAC,EAAE;AAAA,MACjD;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAc,cAAc,KAAa;AACvC,UAAM,cAA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,UAAU,GAAG;AAC9C,eAAO,QAAQ,IAAI,EAAE,KAAK,UAAU;AACpC,cAAM,gBAAAA,QAAG,UAAU,YAAY,KAAK,UAAU,MAAM,CAAC;AACrD,eAAO,MAAM,SAAS,UAAU,4BAA4B,IAAI,QAAQ;AAAA,MAC1E;AAAA,IACF,SAAS,GAAY;AACnB,UAAI,aAAa,OAAO;AACtB,eAAO,KAAK,kCAAkC,EAAE,OAAO,EAAE;AAAA,MAC3D,OAAO;AACL,eAAO,KAAK,kCAAkC,OAAO,CAAC,CAAC,EAAE;AAAA,MAC3D;AAAA,IACF;AAAA,EACF;AACF;","names":["fs"]}
|
|
@@ -1,66 +1,9 @@
|
|
|
1
1
|
import { createRequire } from "module"; const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
init_esm_shims
|
|
8
|
-
} from "../../chunk-OYFWMYPG.js";
|
|
9
|
-
|
|
10
|
-
// src/commands/setup.ts
|
|
11
|
-
init_esm_shims();
|
|
12
|
-
var import_fs_extra = __toESM(require_lib(), 1);
|
|
13
|
-
import { BaseCommand, logger } from "@nexical/cli-core";
|
|
14
|
-
import path from "path";
|
|
15
|
-
var SetupCommand = class extends BaseCommand {
|
|
16
|
-
static description = "Setup the application environment by symlinking core assets.";
|
|
17
|
-
async run() {
|
|
18
|
-
const rootDir = process.cwd();
|
|
19
|
-
if (!import_fs_extra.default.existsSync(path.join(rootDir, "core"))) {
|
|
20
|
-
this.error('Could not find "core" directory. Are you in the project root?');
|
|
21
|
-
process.exit(1);
|
|
22
|
-
}
|
|
23
|
-
const apps = ["frontend", "backend"];
|
|
24
|
-
const sharedAssets = ["prisma", "src", "public", "locales", "scripts"];
|
|
25
|
-
for (const app of apps) {
|
|
26
|
-
const appDir = path.join(rootDir, "apps", app);
|
|
27
|
-
if (!import_fs_extra.default.existsSync(appDir)) {
|
|
28
|
-
this.warn(`App directory ${app} not found. Skipping.`);
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
this.info(`Setting up ${app}...`);
|
|
32
|
-
for (const asset of sharedAssets) {
|
|
33
|
-
const source = path.join(rootDir, "core", asset);
|
|
34
|
-
const dest = path.join(appDir, asset);
|
|
35
|
-
if (!import_fs_extra.default.existsSync(source)) {
|
|
36
|
-
this.warn(`Source asset ${asset} not found in core.`);
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
try {
|
|
40
|
-
const destDir = path.dirname(dest);
|
|
41
|
-
await import_fs_extra.default.ensureDir(destDir);
|
|
42
|
-
try {
|
|
43
|
-
import_fs_extra.default.lstatSync(dest);
|
|
44
|
-
import_fs_extra.default.removeSync(dest);
|
|
45
|
-
} catch (e) {
|
|
46
|
-
if (e && typeof e === "object" && "code" in e && e.code !== "ENOENT")
|
|
47
|
-
throw e;
|
|
48
|
-
}
|
|
49
|
-
const relSource = path.relative(destDir, source);
|
|
50
|
-
await import_fs_extra.default.symlink(relSource, dest);
|
|
51
|
-
logger.debug(`Symlinked ${asset} to ${app}`);
|
|
52
|
-
} catch (e) {
|
|
53
|
-
if (e instanceof Error) {
|
|
54
|
-
this.error(`Failed to symlink ${asset} to ${app}: ${e.message}`);
|
|
55
|
-
} else {
|
|
56
|
-
this.error(`Failed to symlink ${asset} to ${app}: ${String(e)}`);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
this.success("Application setup complete.");
|
|
62
|
-
}
|
|
63
|
-
};
|
|
3
|
+
SetupCommand
|
|
4
|
+
} from "../../chunk-GUUPSHWC.js";
|
|
5
|
+
import "../../chunk-OUGA4CB4.js";
|
|
6
|
+
import "../../chunk-OYFWMYPG.js";
|
|
64
7
|
export {
|
|
65
8
|
SetupCommand as default
|
|
66
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/src/utils/git.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ declare function clone(url: string, destination: string, options?: {
|
|
|
4
4
|
}): Promise<void>;
|
|
5
5
|
declare function getRemoteUrl(cwd: string, remote?: string): Promise<string>;
|
|
6
6
|
declare function updateSubmodules(cwd: string): Promise<void>;
|
|
7
|
+
declare function addSubmodule(url: string, path: string, cwd: string): Promise<void>;
|
|
7
8
|
declare function checkoutOrphan(branch: string, cwd: string): Promise<void>;
|
|
8
9
|
declare function addAll(cwd: string): Promise<void>;
|
|
9
10
|
declare function commit(message: string, cwd: string): Promise<void>;
|
|
@@ -13,4 +14,4 @@ declare function removeRemote(remote: string, cwd: string): Promise<void>;
|
|
|
13
14
|
declare function renameRemote(oldName: string, newName: string, cwd: string): Promise<void>;
|
|
14
15
|
declare function branchExists(branch: string, cwd: string): Promise<boolean>;
|
|
15
16
|
|
|
16
|
-
export { addAll, branchExists, checkoutOrphan, clone, commit, deleteBranch, getRemoteUrl, removeRemote, renameBranch, renameRemote, updateSubmodules };
|
|
17
|
+
export { addAll, addSubmodule, branchExists, checkoutOrphan, clone, commit, deleteBranch, getRemoteUrl, removeRemote, renameBranch, renameRemote, updateSubmodules };
|
package/dist/src/utils/git.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createRequire } from "module"; const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
addAll,
|
|
4
|
+
addSubmodule,
|
|
4
5
|
branchExists,
|
|
5
6
|
checkoutOrphan,
|
|
6
7
|
clone,
|
|
@@ -11,10 +12,11 @@ import {
|
|
|
11
12
|
renameBranch,
|
|
12
13
|
renameRemote,
|
|
13
14
|
updateSubmodules
|
|
14
|
-
} from "../../chunk-
|
|
15
|
+
} from "../../chunk-GEESHGE4.js";
|
|
15
16
|
import "../../chunk-OYFWMYPG.js";
|
|
16
17
|
export {
|
|
17
18
|
addAll,
|
|
19
|
+
addSubmodule,
|
|
18
20
|
branchExists,
|
|
19
21
|
checkoutOrphan,
|
|
20
22
|
clone,
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexical/cli",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.15",
|
|
4
|
+
"license": "Apache-2.0",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"bin": {
|
|
6
7
|
"nexical": "./dist/index.js"
|
|
@@ -28,33 +29,34 @@
|
|
|
28
29
|
]
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@nexical/cli-core": "^0.1.
|
|
32
|
+
"@nexical/cli-core": "^0.1.16",
|
|
32
33
|
"dotenv": "^17.3.1",
|
|
33
34
|
"fast-glob": "^3.3.3",
|
|
35
|
+
"glob": "^13.0.5",
|
|
34
36
|
"jiti": "^2.6.1",
|
|
35
|
-
"yaml": "^2.
|
|
37
|
+
"yaml": "^2.8.2"
|
|
36
38
|
},
|
|
37
39
|
"devDependencies": {
|
|
38
40
|
"@eslint/js": "^9.39.2",
|
|
39
41
|
"@types/fs-extra": "^11.0.4",
|
|
40
|
-
"@types/node": "^
|
|
41
|
-
"@vitest/coverage-v8": "^4.0.
|
|
42
|
+
"@types/node": "^25.3.0",
|
|
43
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
42
44
|
"eslint": "^9.39.2",
|
|
43
45
|
"eslint-config-prettier": "^10.1.8",
|
|
44
|
-
"eslint-plugin-astro": "^1.
|
|
46
|
+
"eslint-plugin-astro": "^1.6.0",
|
|
45
47
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
46
48
|
"eslint-plugin-react": "^7.37.5",
|
|
47
49
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
48
50
|
"execa": "^9.6.1",
|
|
49
|
-
"fs-extra": "^11.3.
|
|
50
|
-
"globals": "^17.
|
|
51
|
+
"fs-extra": "^11.3.3",
|
|
52
|
+
"globals": "^17.3.0",
|
|
51
53
|
"husky": "^9.1.7",
|
|
52
54
|
"lint-staged": "^16.2.7",
|
|
53
55
|
"prettier": "^3.8.1",
|
|
54
|
-
"tsup": "^8.
|
|
56
|
+
"tsup": "^8.5.1",
|
|
55
57
|
"tsx": "^4.21.0",
|
|
56
|
-
"typescript": "^5.
|
|
57
|
-
"typescript-eslint": "^8.
|
|
58
|
-
"vitest": "^4.0.
|
|
58
|
+
"typescript": "^5.9.3",
|
|
59
|
+
"typescript-eslint": "^8.56.0",
|
|
60
|
+
"vitest": "^4.0.18"
|
|
59
61
|
}
|
|
60
62
|
}
|
package/src/commands/init.ts
CHANGED
|
@@ -3,6 +3,7 @@ import * as git from '../utils/git.js';
|
|
|
3
3
|
import { resolveGitUrl } from '../utils/url-resolver.js';
|
|
4
4
|
import fs from 'fs-extra';
|
|
5
5
|
import path from 'path';
|
|
6
|
+
import SetupCommand from './setup.js';
|
|
6
7
|
|
|
7
8
|
export default class InitCommand extends BaseCommand {
|
|
8
9
|
static usage = 'init';
|
|
@@ -54,6 +55,12 @@ export default class InitCommand extends BaseCommand {
|
|
|
54
55
|
this.info('Setting up upstream remote...');
|
|
55
56
|
await git.renameRemote('origin', 'upstream', targetPath);
|
|
56
57
|
|
|
58
|
+
// Run Nexical CLI setup command
|
|
59
|
+
this.info('Initializing project assets...');
|
|
60
|
+
const setup = new SetupCommand(this.cli, { ...this.globalOptions, rootDir: targetPath });
|
|
61
|
+
await setup.init();
|
|
62
|
+
await setup.run();
|
|
63
|
+
|
|
57
64
|
// Run setup script
|
|
58
65
|
this.info('Running project setup...');
|
|
59
66
|
await runCommand('npm run setup', targetPath);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type CommandDefinition, BaseCommand, logger, runCommand } from '@nexical/cli-core';
|
|
2
2
|
import fs from 'fs-extra';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import { clone, getRemoteUrl } from '../../utils/git.js';
|
|
4
|
+
import { clone, getRemoteUrl, addSubmodule } from '../../utils/git.js';
|
|
5
5
|
import { resolveGitUrl } from '../../utils/url-resolver.js';
|
|
6
6
|
import YAML from 'yaml';
|
|
7
7
|
|
|
@@ -168,7 +168,7 @@ export default class ModuleAddCommand extends BaseCommand {
|
|
|
168
168
|
// Stage 3: Submodule Add
|
|
169
169
|
this.info(`Installing ${moduleName} (${moduleType}) to ${relativeTargetDir}...`);
|
|
170
170
|
await fs.ensureDir(path.dirname(targetDir)); // Ensure apps/backend/modules exists
|
|
171
|
-
await
|
|
171
|
+
await addSubmodule(cleanUrl, relativeTargetDir, projectRoot!);
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
// Update nexical.yaml
|