@jskit-ai/jskit-cli 0.2.24 → 0.2.26
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/package.json +2 -2
- package/src/server/argParser.js +23 -4
- package/src/server/cliRuntime.js +410 -121
- package/src/server/commandHandlers.js +462 -13
- package/src/server/pathResolution.js +0 -64
- package/src/server/runCli.js +16 -0
- package/src/server/runtimeDeps.js +1 -0
|
@@ -8,66 +8,6 @@ import { createCliError } from "./cliError.js";
|
|
|
8
8
|
const CLI_PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
|
9
9
|
const require = createRequire(import.meta.url);
|
|
10
10
|
|
|
11
|
-
function isWorkspaceRoot(candidateRoot) {
|
|
12
|
-
if (!candidateRoot) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
return (
|
|
16
|
-
existsSync(path.join(candidateRoot, "packages")) &&
|
|
17
|
-
existsSync(path.join(candidateRoot, "packages", "kernel")) &&
|
|
18
|
-
existsSync(path.join(candidateRoot, "tooling", "jskit-cli"))
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function collectAncestorDirectories(startDirectory) {
|
|
23
|
-
const ancestors = [];
|
|
24
|
-
let current = path.resolve(startDirectory);
|
|
25
|
-
while (true) {
|
|
26
|
-
ancestors.push(current);
|
|
27
|
-
const parent = path.dirname(current);
|
|
28
|
-
if (parent === current) {
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
current = parent;
|
|
32
|
-
}
|
|
33
|
-
return ancestors;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function resolveWorkspaceRoot() {
|
|
37
|
-
const candidates = [];
|
|
38
|
-
const seen = new Set();
|
|
39
|
-
const appendCandidate = (candidatePath) => {
|
|
40
|
-
const raw = String(candidatePath || "").trim();
|
|
41
|
-
if (!raw) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const absolute = path.resolve(raw);
|
|
45
|
-
if (seen.has(absolute)) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
seen.add(absolute);
|
|
49
|
-
candidates.push(absolute);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
appendCandidate(process.env.JSKIT_REPO_ROOT);
|
|
53
|
-
appendCandidate(path.resolve(CLI_PACKAGE_ROOT, "../.."));
|
|
54
|
-
appendCandidate(CLI_PACKAGE_ROOT);
|
|
55
|
-
|
|
56
|
-
const cwdAncestors = collectAncestorDirectories(process.cwd());
|
|
57
|
-
for (const ancestor of cwdAncestors) {
|
|
58
|
-
appendCandidate(ancestor);
|
|
59
|
-
appendCandidate(path.join(ancestor, "jskit-ai"));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
for (const candidate of candidates) {
|
|
63
|
-
if (isWorkspaceRoot(candidate)) {
|
|
64
|
-
return candidate;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return "";
|
|
69
|
-
}
|
|
70
|
-
|
|
71
11
|
function resolveCatalogPackagesPath() {
|
|
72
12
|
const explicitPath = String(process.env.JSKIT_CATALOG_PACKAGES_PATH || "").trim();
|
|
73
13
|
if (explicitPath) {
|
|
@@ -92,15 +32,11 @@ function resolveCatalogPackagesPath() {
|
|
|
92
32
|
);
|
|
93
33
|
}
|
|
94
34
|
|
|
95
|
-
const WORKSPACE_ROOT = resolveWorkspaceRoot();
|
|
96
|
-
const MODULES_ROOT = WORKSPACE_ROOT ? path.join(WORKSPACE_ROOT, "packages") : "";
|
|
97
35
|
const BUNDLES_ROOT = path.join(CLI_PACKAGE_ROOT, "bundles");
|
|
98
36
|
const CATALOG_PACKAGES_PATH = resolveCatalogPackagesPath();
|
|
99
37
|
|
|
100
38
|
export {
|
|
101
39
|
CLI_PACKAGE_ROOT,
|
|
102
|
-
WORKSPACE_ROOT,
|
|
103
|
-
MODULES_ROOT,
|
|
104
40
|
BUNDLES_ROOT,
|
|
105
41
|
CATALOG_PACKAGES_PATH
|
|
106
42
|
};
|
package/src/server/runCli.js
CHANGED
|
@@ -48,6 +48,14 @@ function createRunCli({
|
|
|
48
48
|
if (command === "show") {
|
|
49
49
|
return await commandHandlers.commandShow({ positional, options, stdout });
|
|
50
50
|
}
|
|
51
|
+
if (command === "migrations") {
|
|
52
|
+
return await commandHandlers.commandMigrations({
|
|
53
|
+
positional,
|
|
54
|
+
options,
|
|
55
|
+
cwd,
|
|
56
|
+
io: { stdin, stdout, stderr }
|
|
57
|
+
});
|
|
58
|
+
}
|
|
51
59
|
if (command === "add") {
|
|
52
60
|
return await commandHandlers.commandAdd({
|
|
53
61
|
positional,
|
|
@@ -56,6 +64,14 @@ function createRunCli({
|
|
|
56
64
|
io: { stdin, stdout, stderr }
|
|
57
65
|
});
|
|
58
66
|
}
|
|
67
|
+
if (command === "generate") {
|
|
68
|
+
return await commandHandlers.commandGenerate({
|
|
69
|
+
positional,
|
|
70
|
+
options,
|
|
71
|
+
cwd,
|
|
72
|
+
io: { stdin, stdout, stderr }
|
|
73
|
+
});
|
|
74
|
+
}
|
|
59
75
|
if (command === "position") {
|
|
60
76
|
return await commandHandlers.commandPosition({
|
|
61
77
|
positional,
|
|
@@ -21,6 +21,7 @@ function createCommandHandlerDeps(deps = {}) {
|
|
|
21
21
|
validatePlannedCapabilityClosure: deps.validatePlannedCapabilityClosure,
|
|
22
22
|
resolvePackageOptions: deps.resolvePackageOptions,
|
|
23
23
|
applyPackageInstall: deps.applyPackageInstall,
|
|
24
|
+
applyPackageMigrationsOnly: deps.applyPackageMigrationsOnly,
|
|
24
25
|
applyPackagePositioning: deps.applyPackagePositioning,
|
|
25
26
|
adoptAppLocalPackageDependencies: deps.adoptAppLocalPackageDependencies,
|
|
26
27
|
loadAppPackageJson: deps.loadAppPackageJson,
|