@akanjs/cli 2.1.0-rc.1 → 2.1.0-rc.2
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/incrementalBuilder.proc.js +9615 -0
- package/index.js +119 -11
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1959,6 +1959,45 @@ var staticTemplateFileExtensions = new Set([
|
|
|
1959
1959
|
".woff2",
|
|
1960
1960
|
".xml"
|
|
1961
1961
|
]);
|
|
1962
|
+
var formatCommandArg = (value) => /^[\w@%+=:,./-]+$/.test(value) ? value : JSON.stringify(value);
|
|
1963
|
+
var formatCommandForDisplay = (command, args = []) => [command, ...args].map(formatCommandArg).join(" ");
|
|
1964
|
+
|
|
1965
|
+
class CommandExecutionError extends Error {
|
|
1966
|
+
command;
|
|
1967
|
+
args;
|
|
1968
|
+
cwd;
|
|
1969
|
+
code;
|
|
1970
|
+
signal;
|
|
1971
|
+
stdout;
|
|
1972
|
+
stderr;
|
|
1973
|
+
constructor({
|
|
1974
|
+
command,
|
|
1975
|
+
args = [],
|
|
1976
|
+
cwd,
|
|
1977
|
+
code,
|
|
1978
|
+
signal,
|
|
1979
|
+
stdout = "",
|
|
1980
|
+
stderr = "",
|
|
1981
|
+
cause
|
|
1982
|
+
}) {
|
|
1983
|
+
const displayCommand = formatCommandForDisplay(command, args);
|
|
1984
|
+
const status = signal ? `signal: ${signal}` : `exit code: ${code ?? "unknown"}`;
|
|
1985
|
+
const output = (stderr || stdout).trim();
|
|
1986
|
+
super([`Command failed: ${displayCommand}`, `cwd: ${cwd}`, status, output ? `
|
|
1987
|
+
${output}` : ""].join(`
|
|
1988
|
+
`), {
|
|
1989
|
+
cause
|
|
1990
|
+
});
|
|
1991
|
+
this.name = "CommandExecutionError";
|
|
1992
|
+
this.command = command;
|
|
1993
|
+
this.args = args;
|
|
1994
|
+
this.cwd = cwd;
|
|
1995
|
+
this.code = code;
|
|
1996
|
+
this.signal = signal;
|
|
1997
|
+
this.stdout = stdout;
|
|
1998
|
+
this.stderr = stderr;
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
1962
2001
|
var execEmoji = {
|
|
1963
2002
|
workspace: "\uD83C\uDFE0",
|
|
1964
2003
|
app: "\uD83D\uDE80",
|
|
@@ -2089,23 +2128,32 @@ class Executor {
|
|
|
2089
2128
|
Logger4.raw(chalk4.red(data.toString()));
|
|
2090
2129
|
}
|
|
2091
2130
|
exec(command, options = {}) {
|
|
2131
|
+
const cwd = options.cwd?.toString() ?? this.cwdPath;
|
|
2092
2132
|
const proc = exec(command, { cwd: this.cwdPath, ...options });
|
|
2133
|
+
let stdout = "";
|
|
2134
|
+
let stderr = "";
|
|
2093
2135
|
proc.stdout?.on("data", (data) => {
|
|
2136
|
+
stdout += data.toString();
|
|
2094
2137
|
this.#stdout(data);
|
|
2095
2138
|
});
|
|
2096
2139
|
proc.stderr?.on("data", (data) => {
|
|
2140
|
+
stderr += data.toString();
|
|
2097
2141
|
this.#stdout(data);
|
|
2098
2142
|
});
|
|
2099
2143
|
return new Promise((resolve, reject) => {
|
|
2144
|
+
proc.on("error", (error) => {
|
|
2145
|
+
reject(new CommandExecutionError({ command, cwd, code: null, signal: null, stdout, stderr, cause: error }));
|
|
2146
|
+
});
|
|
2100
2147
|
proc.on("exit", (code, signal) => {
|
|
2101
2148
|
if (!!code || signal)
|
|
2102
|
-
reject({ code, signal });
|
|
2149
|
+
reject(new CommandExecutionError({ command, cwd, code, signal, stdout, stderr }));
|
|
2103
2150
|
else
|
|
2104
2151
|
resolve({ code, signal });
|
|
2105
2152
|
});
|
|
2106
2153
|
});
|
|
2107
2154
|
}
|
|
2108
2155
|
spawn(command, args = [], options = {}) {
|
|
2156
|
+
const cwd = options.cwd?.toString() ?? this.cwdPath;
|
|
2109
2157
|
const proc = spawn(command, args, {
|
|
2110
2158
|
cwd: this.cwdPath,
|
|
2111
2159
|
...options
|
|
@@ -2123,9 +2171,12 @@ class Executor {
|
|
|
2123
2171
|
this.#stdout(data);
|
|
2124
2172
|
});
|
|
2125
2173
|
return new Promise((resolve, reject) => {
|
|
2174
|
+
proc.on("error", (error) => {
|
|
2175
|
+
reject(new CommandExecutionError({ command, args, cwd, code: null, signal: null, stdout, stderr, cause: error }));
|
|
2176
|
+
});
|
|
2126
2177
|
proc.on("close", (code, signal) => {
|
|
2127
2178
|
if (code !== 0 || signal)
|
|
2128
|
-
reject(
|
|
2179
|
+
reject(new CommandExecutionError({ command, args, cwd, code, signal, stdout, stderr }));
|
|
2129
2180
|
else
|
|
2130
2181
|
resolve(stdout);
|
|
2131
2182
|
});
|
|
@@ -2139,20 +2190,37 @@ class Executor {
|
|
|
2139
2190
|
return proc;
|
|
2140
2191
|
}
|
|
2141
2192
|
fork(modulePath, args = [], options = {}) {
|
|
2193
|
+
const cwd = options.cwd?.toString() ?? this.cwdPath;
|
|
2142
2194
|
const proc = fork(modulePath, args, {
|
|
2143
2195
|
cwd: this.cwdPath,
|
|
2144
2196
|
...options
|
|
2145
2197
|
});
|
|
2198
|
+
let stdout = "";
|
|
2199
|
+
let stderr = "";
|
|
2146
2200
|
proc.stdout?.on("data", (data) => {
|
|
2201
|
+
stdout += data.toString();
|
|
2147
2202
|
this.#stdout(data);
|
|
2148
2203
|
});
|
|
2149
2204
|
proc.stderr?.on("data", (data) => {
|
|
2205
|
+
stderr += data.toString();
|
|
2150
2206
|
this.#stderr(data);
|
|
2151
2207
|
});
|
|
2152
2208
|
return new Promise((resolve, reject) => {
|
|
2209
|
+
proc.on("error", (error) => {
|
|
2210
|
+
reject(new CommandExecutionError({
|
|
2211
|
+
command: modulePath,
|
|
2212
|
+
args,
|
|
2213
|
+
cwd,
|
|
2214
|
+
code: null,
|
|
2215
|
+
signal: null,
|
|
2216
|
+
stdout,
|
|
2217
|
+
stderr,
|
|
2218
|
+
cause: error
|
|
2219
|
+
}));
|
|
2220
|
+
});
|
|
2153
2221
|
proc.on("exit", (code, signal) => {
|
|
2154
2222
|
if (!!code || signal)
|
|
2155
|
-
reject({ code, signal });
|
|
2223
|
+
reject(new CommandExecutionError({ command: modulePath, args, cwd, code, signal, stdout, stderr }));
|
|
2156
2224
|
else
|
|
2157
2225
|
resolve({ code, signal });
|
|
2158
2226
|
});
|
|
@@ -3374,6 +3442,7 @@ class IncrementalBuilderHost {
|
|
|
3374
3442
|
const candidates = [
|
|
3375
3443
|
path8.join(app.workspace.workspaceRoot, "pkgs/@akanjs/devkit/incrementalBuilder/incrementalBuilder.proc.ts"),
|
|
3376
3444
|
path8.join(app.workspace.workspaceRoot, "node_modules/@akanjs/devkit/incrementalBuilder/incrementalBuilder.proc.ts"),
|
|
3445
|
+
path8.join(import.meta.dir, "incrementalBuilder.proc.js"),
|
|
3377
3446
|
path8.join(import.meta.dir, "incrementalBuilder.proc.ts")
|
|
3378
3447
|
];
|
|
3379
3448
|
for (const c of candidates)
|
|
@@ -8247,8 +8316,8 @@ var Pkg = createInternalArgToken("Pkg");
|
|
|
8247
8316
|
var Module = createInternalArgToken("Module");
|
|
8248
8317
|
var Workspace = createInternalArgToken("Workspace");
|
|
8249
8318
|
// pkgs/@akanjs/devkit/commandDecorators/command.ts
|
|
8250
|
-
import { confirm, input as input2, select as select2 } from "@inquirer/prompts";
|
|
8251
8319
|
import path35 from "path";
|
|
8320
|
+
import { confirm, input as input2, select as select2 } from "@inquirer/prompts";
|
|
8252
8321
|
import { Logger as Logger11 } from "akanjs/common";
|
|
8253
8322
|
import chalk6 from "chalk";
|
|
8254
8323
|
import { program } from "commander";
|
|
@@ -8506,6 +8575,37 @@ var formatCommandHelp = (command, key) => {
|
|
|
8506
8575
|
|
|
8507
8576
|
// pkgs/@akanjs/devkit/commandDecorators/command.ts
|
|
8508
8577
|
var camelToKebabCase2 = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
8578
|
+
var loggedCliErrorObjects = new WeakSet;
|
|
8579
|
+
var loggedCliErrorMessages = new Set;
|
|
8580
|
+
var formatCliError = (error) => {
|
|
8581
|
+
if (error instanceof Error)
|
|
8582
|
+
return error.message || error.name;
|
|
8583
|
+
if (typeof error === "string")
|
|
8584
|
+
return error.trim() || "Unknown error";
|
|
8585
|
+
if (error === null || error === undefined)
|
|
8586
|
+
return "Unknown error";
|
|
8587
|
+
try {
|
|
8588
|
+
const json = JSON.stringify(error);
|
|
8589
|
+
if (json)
|
|
8590
|
+
return json;
|
|
8591
|
+
} catch {
|
|
8592
|
+
return String(error);
|
|
8593
|
+
}
|
|
8594
|
+
return String(error) || "Unknown error";
|
|
8595
|
+
};
|
|
8596
|
+
var printCliError = (error) => {
|
|
8597
|
+
if (typeof error === "object" && error !== null) {
|
|
8598
|
+
if (loggedCliErrorObjects.has(error))
|
|
8599
|
+
return;
|
|
8600
|
+
loggedCliErrorObjects.add(error);
|
|
8601
|
+
}
|
|
8602
|
+
const message = formatCliError(error);
|
|
8603
|
+
if (loggedCliErrorMessages.has(message))
|
|
8604
|
+
return;
|
|
8605
|
+
loggedCliErrorMessages.add(message);
|
|
8606
|
+
Logger11.rawLog(`
|
|
8607
|
+
${chalk6.red(message)}`);
|
|
8608
|
+
};
|
|
8509
8609
|
var handleOption = (programCommand, argMeta) => {
|
|
8510
8610
|
const {
|
|
8511
8611
|
type,
|
|
@@ -8712,6 +8812,7 @@ var getInternalArgumentValue = async (argMeta, value, workspace) => {
|
|
|
8712
8812
|
};
|
|
8713
8813
|
var runCommands = async (...commands) => {
|
|
8714
8814
|
process.on("unhandledRejection", (error) => {
|
|
8815
|
+
printCliError(error);
|
|
8715
8816
|
process.exit(1);
|
|
8716
8817
|
});
|
|
8717
8818
|
const __dirname2 = getDirname(import.meta.url);
|
|
@@ -8802,9 +8903,7 @@ It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`)
|
|
|
8802
8903
|
await targetMeta.handler.call(cmd, ...commandArgs);
|
|
8803
8904
|
Logger11.rawLog();
|
|
8804
8905
|
} catch (e) {
|
|
8805
|
-
|
|
8806
|
-
Logger11.rawLog(`
|
|
8807
|
-
${chalk6.red(errMsg)}`);
|
|
8906
|
+
printCliError(e);
|
|
8808
8907
|
throw e;
|
|
8809
8908
|
}
|
|
8810
8909
|
});
|
|
@@ -9582,8 +9681,15 @@ class ApplicationRunner extends runner("application") {
|
|
|
9582
9681
|
cwd: `${workspace.workspaceRoot}/local`
|
|
9583
9682
|
});
|
|
9584
9683
|
return wasAlreadyUp;
|
|
9585
|
-
} catch {
|
|
9586
|
-
|
|
9684
|
+
} catch (error) {
|
|
9685
|
+
const detail = error instanceof Error ? error.message : typeof error === "string" ? error : JSON.stringify(error) || "Unknown error";
|
|
9686
|
+
throw new Error([
|
|
9687
|
+
"Docker daemon may not be running. Please install Docker or start the Docker daemon and try again.",
|
|
9688
|
+
`Original error:
|
|
9689
|
+
${detail}`
|
|
9690
|
+
].join(`
|
|
9691
|
+
|
|
9692
|
+
`));
|
|
9587
9693
|
}
|
|
9588
9694
|
}
|
|
9589
9695
|
async dbdown(workspace) {
|
|
@@ -11465,16 +11571,18 @@ class WorkspaceRunner extends runner("workspace") {
|
|
|
11465
11571
|
workspace.getPackageJson(),
|
|
11466
11572
|
this.#getAkanPeerDependencies()
|
|
11467
11573
|
]);
|
|
11574
|
+
const { typescript, ...dependencies } = peerDependencies;
|
|
11468
11575
|
const packageJson = {
|
|
11469
11576
|
...rootPackageJson,
|
|
11470
11577
|
dependencies: {
|
|
11471
11578
|
...rootPackageJson.dependencies,
|
|
11472
|
-
...
|
|
11579
|
+
...dependencies,
|
|
11473
11580
|
akanjs: akanVersion
|
|
11474
11581
|
},
|
|
11475
11582
|
devDependencies: {
|
|
11476
11583
|
...rootPackageJson.devDependencies,
|
|
11477
|
-
"@types/bun": latestTypesBunVersion
|
|
11584
|
+
"@types/bun": latestTypesBunVersion,
|
|
11585
|
+
...typescript ? { typescript } : {}
|
|
11478
11586
|
}
|
|
11479
11587
|
};
|
|
11480
11588
|
await workspace.setPackageJson(packageJson);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/cli",
|
|
3
|
-
"version": "2.1.0-rc.
|
|
3
|
+
"version": "2.1.0-rc.2",
|
|
4
4
|
"sourceType": "module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@langchain/deepseek": "^1.0.26",
|
|
35
35
|
"@langchain/openai": "^1.4.6",
|
|
36
36
|
"@trapezedev/project": "^7.1.4",
|
|
37
|
-
"akanjs": "2.1.0-rc.
|
|
37
|
+
"akanjs": "2.1.0-rc.1",
|
|
38
38
|
"chalk": "^5.6.2",
|
|
39
39
|
"commander": "^14.0.3",
|
|
40
40
|
"fontaine": "^0.8.0",
|