@akanjs/cli 2.1.0-rc.0 → 2.1.0-rc.1
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/index.js +54 -26
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -8248,6 +8248,7 @@ var Module = createInternalArgToken("Module");
|
|
|
8248
8248
|
var Workspace = createInternalArgToken("Workspace");
|
|
8249
8249
|
// pkgs/@akanjs/devkit/commandDecorators/command.ts
|
|
8250
8250
|
import { confirm, input as input2, select as select2 } from "@inquirer/prompts";
|
|
8251
|
+
import path35 from "path";
|
|
8251
8252
|
import { Logger as Logger11 } from "akanjs/common";
|
|
8252
8253
|
import chalk6 from "chalk";
|
|
8253
8254
|
import { program } from "commander";
|
|
@@ -8714,8 +8715,18 @@ var runCommands = async (...commands) => {
|
|
|
8714
8715
|
process.exit(1);
|
|
8715
8716
|
});
|
|
8716
8717
|
const __dirname2 = getDirname(import.meta.url);
|
|
8717
|
-
const
|
|
8718
|
-
|
|
8718
|
+
const packageJsonCandidates = [`${path35.dirname(Bun.main)}/package.json`, `${__dirname2}/../package.json`];
|
|
8719
|
+
let cliPackageJson = null;
|
|
8720
|
+
for (const packageJsonPath of packageJsonCandidates) {
|
|
8721
|
+
if (!await FileSys.fileExists(packageJsonPath))
|
|
8722
|
+
continue;
|
|
8723
|
+
const packageJson = await FileSys.readJson(packageJsonPath);
|
|
8724
|
+
if (packageJson.name === "@akanjs/cli" || packageJson.name === "@akanjs/devkit") {
|
|
8725
|
+
cliPackageJson = packageJson;
|
|
8726
|
+
break;
|
|
8727
|
+
}
|
|
8728
|
+
}
|
|
8729
|
+
process.env.AKAN_VERSION = cliPackageJson?.version ?? "0.0.1";
|
|
8719
8730
|
const hasHelpFlag = process.argv.includes("--help") || process.argv.includes("-h");
|
|
8720
8731
|
const hasCommand = process.argv.length > 2 && !process.argv[2]?.startsWith("-");
|
|
8721
8732
|
if (hasHelpFlag || !hasCommand) {
|
|
@@ -8982,8 +8993,8 @@ var scanModuleSpecifiers = (source, filePath, includeExports) => {
|
|
|
8982
8993
|
return importSpecifiers;
|
|
8983
8994
|
};
|
|
8984
8995
|
var parseTsConfig = (tsConfigPath = "./tsconfig.json") => {
|
|
8985
|
-
const configFile = ts6.readConfigFile(tsConfigPath, (
|
|
8986
|
-
return ts6.sys.readFile(
|
|
8996
|
+
const configFile = ts6.readConfigFile(tsConfigPath, (path36) => {
|
|
8997
|
+
return ts6.sys.readFile(path36);
|
|
8987
8998
|
});
|
|
8988
8999
|
return ts6.parseJsonConfigFileContent(configFile.config, ts6.sys, realpathSync(tsConfigPath).replace(/[^/\\]+$/, ""));
|
|
8989
9000
|
};
|
|
@@ -9328,7 +9339,7 @@ class LibraryScript extends script("library", [LibraryRunner]) {
|
|
|
9328
9339
|
}
|
|
9329
9340
|
|
|
9330
9341
|
// pkgs/@akanjs/cli/application/application.runner.ts
|
|
9331
|
-
import
|
|
9342
|
+
import path36 from "path";
|
|
9332
9343
|
import { confirm as confirm2, input as input4, select as select5 } from "@inquirer/prompts";
|
|
9333
9344
|
import { StringOutputParser } from "@langchain/core/output_parsers";
|
|
9334
9345
|
import { PromptTemplate as PromptTemplate2 } from "@langchain/core/prompts";
|
|
@@ -9394,7 +9405,7 @@ class ApplicationRunner extends runner("application") {
|
|
|
9394
9405
|
}
|
|
9395
9406
|
async test(exec2) {
|
|
9396
9407
|
const isSignalTarget = exec2 instanceof AppExecutor || exec2 instanceof LibExecutor;
|
|
9397
|
-
const preloadPath =
|
|
9408
|
+
const preloadPath = path36.join(exec2.cwdPath, "../../pkgs/akanjs/test/signalTest.preload.ts");
|
|
9398
9409
|
const env = isSignalTarget ? {
|
|
9399
9410
|
AKAN_TEST_SIGNAL: "1",
|
|
9400
9411
|
AKAN_TEST_TARGET_TYPE: exec2.type,
|
|
@@ -9950,18 +9961,35 @@ class ApplicationCommand extends command("application", [ApplicationScript], ({
|
|
|
9950
9961
|
import { Logger as Logger16 } from "akanjs/common";
|
|
9951
9962
|
|
|
9952
9963
|
// pkgs/@akanjs/cli/package/package.runner.ts
|
|
9953
|
-
import
|
|
9964
|
+
import path37 from "path";
|
|
9954
9965
|
import { Logger as Logger14 } from "akanjs/common";
|
|
9955
9966
|
var {$: $2 } = globalThis.Bun;
|
|
9956
9967
|
|
|
9957
9968
|
class PackageRunner extends runner("package") {
|
|
9958
9969
|
async version(workspace, { log = true } = {}) {
|
|
9959
|
-
const pkgJson =
|
|
9960
|
-
const version = pkgJson.version;
|
|
9970
|
+
const pkgJson = process.env.USE_AKANJS_PKGS === "true" ? await FileSys.readJson(`${workspace?.workspaceRoot ?? process.cwd()}/pkgs/akanjs/package.json`) : await this.#getInstalledPackageJson();
|
|
9971
|
+
const version = pkgJson.name === "akanjs" ? pkgJson.version : pkgJson.dependencies?.akanjs ?? pkgJson.version;
|
|
9961
9972
|
if (log)
|
|
9962
|
-
Logger14.rawLog(
|
|
9973
|
+
Logger14.rawLog(`akanjs@${version}`);
|
|
9963
9974
|
return version;
|
|
9964
9975
|
}
|
|
9976
|
+
async#getInstalledPackageJson() {
|
|
9977
|
+
const packageJsonCandidates = [
|
|
9978
|
+
`${path37.dirname(Bun.main)}/package.json`,
|
|
9979
|
+
`${process.cwd()}/node_modules/akanjs/package.json`
|
|
9980
|
+
];
|
|
9981
|
+
try {
|
|
9982
|
+
packageJsonCandidates.unshift(Bun.resolveSync("akanjs/package.json", path37.dirname(Bun.main)));
|
|
9983
|
+
} catch {}
|
|
9984
|
+
for (const packageJsonPath of packageJsonCandidates) {
|
|
9985
|
+
if (!await Bun.file(packageJsonPath).exists())
|
|
9986
|
+
continue;
|
|
9987
|
+
const packageJson = await FileSys.readJson(packageJsonPath);
|
|
9988
|
+
if (packageJson.name === "akanjs" || packageJson.name === "@akanjs/cli")
|
|
9989
|
+
return packageJson;
|
|
9990
|
+
}
|
|
9991
|
+
throw new Error(`[package] failed to locate akanjs package.json from ${path37.dirname(Bun.main)}`);
|
|
9992
|
+
}
|
|
9965
9993
|
async createPackage(workspace, pkgName) {
|
|
9966
9994
|
await workspace.applyTemplate({ basePath: `pkgs/${pkgName}`, template: "pkgRoot", dict: { pkgName } });
|
|
9967
9995
|
await workspace.setPkgTsPaths(pkgName);
|
|
@@ -10308,14 +10336,14 @@ class GuidelinePrompt extends Prompter {
|
|
|
10308
10336
|
async#getScanFilePaths(matchPattern, { avoidDirs = ["node_modules", ".next"], filterText } = {}) {
|
|
10309
10337
|
const glob = new Bun.Glob(matchPattern);
|
|
10310
10338
|
const paths = [];
|
|
10311
|
-
for await (const
|
|
10312
|
-
if (avoidDirs.some((dir) =>
|
|
10339
|
+
for await (const path38 of glob.scan({ cwd: this.workspace.workspaceRoot, absolute: true })) {
|
|
10340
|
+
if (avoidDirs.some((dir) => path38.includes(dir)))
|
|
10313
10341
|
continue;
|
|
10314
|
-
const fileContent = await FileSys.readText(
|
|
10342
|
+
const fileContent = await FileSys.readText(path38);
|
|
10315
10343
|
const textFilter = filterText ? new RegExp(filterText) : null;
|
|
10316
10344
|
if (filterText && !textFilter?.test(fileContent))
|
|
10317
10345
|
continue;
|
|
10318
|
-
paths.push(
|
|
10346
|
+
paths.push(path38);
|
|
10319
10347
|
}
|
|
10320
10348
|
return paths;
|
|
10321
10349
|
}
|
|
@@ -11405,11 +11433,11 @@ class ScalarCommand extends command("scalar", [ScalarScript], ({ public: target
|
|
|
11405
11433
|
}
|
|
11406
11434
|
|
|
11407
11435
|
// pkgs/@akanjs/cli/workspace/workspace.script.ts
|
|
11408
|
-
import
|
|
11436
|
+
import path39 from "path";
|
|
11409
11437
|
import { Logger as Logger17 } from "akanjs/common";
|
|
11410
11438
|
|
|
11411
11439
|
// pkgs/@akanjs/cli/workspace/workspace.runner.ts
|
|
11412
|
-
import
|
|
11440
|
+
import path38 from "path";
|
|
11413
11441
|
var defaultWorkspacePeerDependencies = new Set([
|
|
11414
11442
|
"react",
|
|
11415
11443
|
"react-dom",
|
|
@@ -11423,7 +11451,7 @@ var defaultWorkspacePeerDependencies = new Set([
|
|
|
11423
11451
|
class WorkspaceRunner extends runner("workspace") {
|
|
11424
11452
|
async createWorkspace(repoName, appName, { dirname: dirname3 = ".", init = true, akanVersion }) {
|
|
11425
11453
|
const cwdPath = process.cwd();
|
|
11426
|
-
const workspaceRoot =
|
|
11454
|
+
const workspaceRoot = path38.join(cwdPath, dirname3, repoName);
|
|
11427
11455
|
const workspace = WorkspaceExecutor.fromRoot({ workspaceRoot, repoName });
|
|
11428
11456
|
const templateSpinner = workspace.spinning(`Creating workspace template files in ${dirname3}/${repoName}...`);
|
|
11429
11457
|
const latestTypesBunVersion = await getLatestPackageVersion("@types/bun");
|
|
@@ -11468,9 +11496,9 @@ class WorkspaceRunner extends runner("workspace") {
|
|
|
11468
11496
|
}
|
|
11469
11497
|
async#getCliPackageJson() {
|
|
11470
11498
|
const packageJsonCandidates = [
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11499
|
+
path38.join(import.meta.dir, "../package.json"),
|
|
11500
|
+
path38.join(import.meta.dir, "package.json"),
|
|
11501
|
+
path38.join(path38.dirname(Bun.main), "package.json")
|
|
11474
11502
|
];
|
|
11475
11503
|
try {
|
|
11476
11504
|
packageJsonCandidates.unshift(Bun.resolveSync("@akanjs/cli/package.json", import.meta.dir));
|
|
@@ -11486,9 +11514,9 @@ class WorkspaceRunner extends runner("workspace") {
|
|
|
11486
11514
|
}
|
|
11487
11515
|
async#getAkanPackageJson() {
|
|
11488
11516
|
const packageJsonCandidates = [
|
|
11489
|
-
|
|
11490
|
-
|
|
11491
|
-
|
|
11517
|
+
path38.join(import.meta.dir, "../../../akanjs/package.json"),
|
|
11518
|
+
path38.join(process.cwd(), "pkgs/akanjs/package.json"),
|
|
11519
|
+
path38.join(path38.dirname(Bun.main), "node_modules/akanjs/package.json")
|
|
11492
11520
|
];
|
|
11493
11521
|
try {
|
|
11494
11522
|
packageJsonCandidates.unshift(Bun.resolveSync("akanjs/package.json", import.meta.dir));
|
|
@@ -11502,13 +11530,13 @@ class WorkspaceRunner extends runner("workspace") {
|
|
|
11502
11530
|
}
|
|
11503
11531
|
let current = import.meta.dir;
|
|
11504
11532
|
for (let depth = 0;depth < 6; depth++) {
|
|
11505
|
-
const packageJsonPath =
|
|
11533
|
+
const packageJsonPath = path38.join(current, "package.json");
|
|
11506
11534
|
if (await Bun.file(packageJsonPath).exists()) {
|
|
11507
11535
|
const packageJson = await FileSys.readJson(packageJsonPath);
|
|
11508
11536
|
if (packageJson.name === "akanjs")
|
|
11509
11537
|
return packageJson;
|
|
11510
11538
|
}
|
|
11511
|
-
const parent =
|
|
11539
|
+
const parent = path38.dirname(current);
|
|
11512
11540
|
if (parent === current)
|
|
11513
11541
|
break;
|
|
11514
11542
|
current = parent;
|
|
@@ -11551,7 +11579,7 @@ class WorkspaceScript extends script("workspace", [
|
|
|
11551
11579
|
} catch (_) {
|
|
11552
11580
|
gitSpinner.fail("Git repository initialization failed. It's not fatal, you can commit manually");
|
|
11553
11581
|
}
|
|
11554
|
-
const workspacePath =
|
|
11582
|
+
const workspacePath = path39.join(dirname3, repoName);
|
|
11555
11583
|
Logger17.rawLog(`
|
|
11556
11584
|
\uD83C\uDF89 Welcome aboard! Workspace created in ${dirname3}/${repoName}`);
|
|
11557
11585
|
Logger17.rawLog(`\uD83D\uDE80 Run \`cd ${workspacePath} && akan start ${appName}\` to start the development server.`);
|