@akanjs/cli 3.0.0-alpha.1 → 3.0.0-alpha.100
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/.build-stamp +1 -1
- package/README.ko.md +1 -1
- package/README.md +1 -1
- package/{abstractCompactor-e5yq60qz.js → abstractCompactor-byytxs22.js} +3 -5
- package/{agent.command-yv00p0s0.js → agent.command-v1a4746v.js} +11 -12
- package/{application.command-0qsczf4k.js → application.command-fzdcnzhg.js} +65 -37
- package/{applicationBuildRunner-ct2pxyvw.js → applicationBuildRunner-s4gsk728.js} +28 -24
- package/{applicationReleasePackager-gg8ccbeh.js → applicationReleasePackager-28v9vbzk.js} +8 -9
- package/buildBatch.proc.js +12 -13
- package/capacitorApp-8d6d4zkm.js +12 -0
- package/{cloud.command-dxfv18sa.js → cloud.command-wygy2z05.js} +15 -17
- package/commandManifest.json +1 -1
- package/{context.command-8d9e3k6b.js → context.command-4vdt1aqq.js} +19 -22
- package/dependencyScanner-shs82ynp.js +8 -0
- package/devTui-qnf1txdz.js +553 -0
- package/devTuiView-yzct2cq6.js +9 -0
- package/getDirname-dr3jz1xg.js +7 -0
- package/{guideline.command-3jbkxzh6.js → guideline.command-p92dq6ts.js} +16 -17
- package/guidelines/agentRule/agentRule.generate.json +31 -0
- package/guidelines/agentRule/agentRule.instruction.md +533 -0
- package/guidelines/conventions/conventions.generate.json +25 -0
- package/guidelines/conventions/conventions.instruction.md +908 -0
- package/guidelines/cssRule/cssRule.instruction.md +7 -0
- package/guidelines/framework/framework.generate.json +3 -2
- package/guidelines/framework/framework.instruction.md +1 -9
- package/guidelines/mcpRule/mcpRule.generate.json +25 -0
- package/guidelines/mcpRule/mcpRule.instruction.md +217 -0
- package/guidelines/modelStore/modelStore.instruction.md +12 -0
- package/guidelines/modelTemplate/modelTemplate.instruction.md +5 -0
- package/guidelines/queryRule/queryRule.generate.json +31 -0
- package/guidelines/queryRule/queryRule.instruction.md +175 -0
- package/guidelines/runtimeRule/runtimeRule.generate.json +25 -0
- package/guidelines/runtimeRule/runtimeRule.instruction.md +220 -0
- package/guidelines/ssrRule/ssrRule.instruction.md +49 -5
- package/guidelines/transportRule/transportRule.generate.json +31 -0
- package/guidelines/transportRule/transportRule.instruction.md +60 -0
- package/guidelines/workspaceOnboarding/workspaceOnboarding.generate.json +24 -0
- package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +263 -0
- package/guidelines/workspaceRecipes/workspaceRecipes.generate.json +33 -0
- package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +402 -0
- package/incrementalBuilder.proc.js +26 -24
- package/{index-mr5s7mqd.js → index-0amdxycf.js} +8 -8
- package/{index-t3723f99.js → index-1yxtbmbj.js} +111 -42
- package/{index-ej426mcr.js → index-29sxqfaw.js} +65 -38
- package/index-3d9y066c.js +76 -0
- package/{index-76rn3g2c.js → index-47pj3aee.js} +4 -4
- package/index-5svjba73.js +159 -0
- package/index-6wwzs1bc.js +7 -0
- package/{index-k95xkh4p.js → index-7d6vny25.js} +16 -12
- package/{index-ec09pws3.js → index-8p8p0cf8.js} +14 -14
- package/{index-wnp7hwq7.js → index-92zztqy1.js} +7 -7
- package/{index-fgc8r6dj.js → index-a5vmm6x4.js} +3 -1
- package/{index-xys926f2.js → index-by5gpp8x.js} +4 -4
- package/{index-0cj2zxbm.js → index-c69j78kk.js} +12 -11
- package/{index-rzwcpcc3.js → index-fc1bh0a7.js} +4 -4
- package/{index-7c6k4yvg.js → index-gq44bqjt.js} +58 -25
- package/{index-a00jg8x8.js → index-gtmz74tj.js} +79 -55
- package/{index-tdbas9r0.js → index-h7yw2z9n.js} +7 -7
- package/{index-bjpxzr6s.js → index-hwkygn9s.js} +51 -3
- package/{index-bbkek1bp.js → index-hyywke0f.js} +1 -1
- package/{index-46tjzh6s.js → index-kcxmv48c.js} +29 -29
- package/{index-xjd3rqzj.js → index-n68jx79w.js} +6 -15
- package/{index-pyt2b4nw.js → index-p5neav9b.js} +1129 -1356
- package/{index-67546d0j.js → index-q0y2jq9j.js} +14 -2
- package/{index-bekddz9q.js → index-qkk27bk6.js} +32 -32
- package/{index-hgna5rjy.js → index-qsq3q8fy.js} +1034 -257
- package/{index-2q1f5j9k.js → index-srdssqj7.js} +18 -18
- package/{index-rh16j3c7.js → index-w8kmx1b6.js} +23 -13
- package/{index-nm6wghb6.js → index-yks023mb.js} +13 -13
- package/{index-1pvex4az.js → index-yza7zkpt.js} +94 -61
- package/{index-yzmhasdb.js → index-zmjppp25.js} +57 -57
- package/{index-8hsbnyes.js → index-znynzt5w.js} +100 -30
- package/{index-zasydjxd.js → index-zxgr3s8s.js} +31 -30
- package/{index-e16gnn26.js → index-zz5jyd94.js} +1002 -128
- package/index.js +22 -24
- package/{library.command-ebdj1vnm.js → library.command-s4fszngs.js} +11 -9
- package/{localRegistry.command-gb178ne8.js → localRegistry.command-gyw4da9z.js} +20 -22
- package/{module.command-9c1bnsx4.js → module.command-6n7dwvav.js} +13 -15
- package/{package.command-t93p4jkj.js → package.command-gr82ypnr.js} +8 -9
- package/package.json +5 -7
- package/{page.command-k3k0meh2.js → page.command-7gvgb3jb.js} +7 -8
- package/{primitive.command-de6nktdt.js → primitive.command-tk5ckw38.js} +13 -15
- package/{quality.command-z5kth2wa.js → quality.command-38v81baf.js} +229 -138
- package/recipeScanner-fpagtgc1.js +11 -0
- package/{repair.command-ehf2g112.js → repair.command-5xbwvsxp.js} +12 -13
- package/{routeSourceValidator-cncd92fv.js → routeSourceValidator-ze6x894c.js} +2 -40
- package/{scalar.command-7a2jtv33.js → scalar.command-0epwcr5k.js} +11 -13
- package/subspace.command-e2t36xb2.js +755 -0
- package/templates/app/env/env.client.debug.ts.template +1 -5
- package/templates/app/env/env.client.develop.ts.template +1 -5
- package/templates/app/env/env.client.local.ts.template +1 -5
- package/templates/app/env/env.client.main.ts.template +1 -5
- package/templates/app/env/env.client.testing.ts.template +1 -5
- package/templates/app/env/env.client.type.ts +2 -6
- package/templates/app/env/env.server.debug.ts.template +1 -5
- package/templates/app/env/env.server.develop.ts.template +1 -5
- package/templates/app/env/env.server.local.ts.template +1 -5
- package/templates/app/env/env.server.main.ts.template +1 -5
- package/templates/app/main.ts +3 -1
- package/templates/app/page/styles.css.template +3 -3
- package/templates/appSample/lib/task/task.signal.ts +11 -6
- package/templates/appSample/srvkit/AuthGuard.ts +9 -5
- package/templates/appSample/srvkit/SessionInternalArg.ts +4 -3
- package/templates/crudPages/[__model__Id]/edit/page.tsx +6 -6
- package/templates/crudPages/[__model__Id]/page.tsx +10 -13
- package/templates/crudPages/new/page.tsx +6 -6
- package/templates/crudPages/page.tsx +9 -9
- package/templates/crudSinglePage/page.tsx +11 -7
- package/templates/env/_env.server.type.ts +7 -5
- package/templates/lib/db.ts +4 -2
- package/templates/lib/dict.ts +1 -1
- package/templates/lib/sig.ts +5 -1
- package/templates/lib/srv.ts +6 -2
- package/templates/lib/useClient.ts +9 -3
- package/templates/module/__Model__.Util.tsx +1 -1
- package/templates/module/__Model__.Zone.tsx +3 -5
- package/templates/module/__model__.dictionary.ts +4 -1
- package/templates/module/__model__.signal.ts +2 -3
- package/templates/module/__model__.store.ts +1 -2
- package/templates/workspaceRoot/.gitignore.template +0 -1
- package/templates/workspaceRoot/.husky/pre-commit.template +16 -0
- package/templates/workspaceRoot/.vscode/settings.json.template +1 -1
- package/templates/workspaceRoot/AGENTS.md.template +4 -948
- package/templates/workspaceRoot/CLAUDE.md.template +19 -0
- package/templates/workspaceRoot/biome.json.template +4 -198
- package/templates/workspaceRoot/docs/AI-DEVELOPMENT.md.template +15 -16
- package/templates/workspaceRoot/docs/GENERATED.md.template +12 -10
- package/templates/workspaceRoot/package.json.template +2 -4
- package/typeChecker-3xgrzc2v.js +7 -0
- package/typecheck.proc.js +4 -5
- package/{workflow.command-e0tt0vk2.js → workflow.command-kphbr7eh.js} +21 -23
- package/{workspace.command-fpda0evj.js → workspace.command-j1gatz3d.js} +108 -91
- package/capacitorApp-4r9sm3qg.js +0 -58
- package/dependencyScanner-f6grrep3.js +0 -9
- package/index-mxvakhsm.js +0 -66
- package/index-r24hmh0q.js +0 -4
- package/recipeScanner-tghkzrrt.js +0 -12
- package/templates/libRoot/base/baseLogic.ts +0 -14
- package/templates/libRoot/base/index.ts +0 -8
- package/templates/workspaceRoot/.cursor/rules/akan-page-routing.mdc.template +0 -43
- package/templates/workspaceRoot/.cursor/rules/akan-sync-conventions.mdc.template +0 -33
- package/templates/workspaceRoot/.cursor/rules/application-test-commands.mdc.template +0 -16
- package/templates/workspaceRoot/.cursor/rules/change-scope.mdc.template +0 -12
- package/templates/workspaceRoot/.cursor/rules/client-server-boundaries.mdc.template +0 -18
- package/templates/workspaceRoot/.cursor/rules/coding-comments.mdc.template +0 -25
- package/templates/workspaceRoot/.cursor/rules/coding-style.mdc.template +0 -44
- package/templates/workspaceRoot/.cursor/rules/domain-module-conventions.mdc.template +0 -17
- package/templates/workspaceRoot/.cursor/rules/format-lint.mdc.template +0 -12
- package/templates/workspaceRoot/.cursor/rules/lint-enforced-rules.mdc.template +0 -18
- package/templates/workspaceRoot/.cursor/rules/module-file-playbook.mdc.template +0 -61
- package/templates/workspaceRoot/.cursor/rules/naming-conventions.mdc.template +0 -15
- package/templates/workspaceRoot/.cursor/rules/react-component-style.mdc.template +0 -21
- package/templates/workspaceRoot/.cursor/rules/repo-overview.mdc.template +0 -17
- package/templates/workspaceRoot/.cursor/rules/scalar-modeling.mdc.template +0 -58
- package/templates/workspaceRoot/.cursor/rules/secrets-and-env.mdc.template +0 -13
- package/templates/workspaceRoot/.cursor/rules/service-signal-conventions.mdc.template +0 -83
- package/templates/workspaceRoot/.cursor/rules/srvkit-adapters-and-guards.mdc.template +0 -50
- package/templates/workspaceRoot/.cursor/rules/ssr-first.mdc.template +0 -59
- package/templates/workspaceRoot/.cursor/rules/typescript-imports.mdc.template +0 -16
- package/typeChecker-kravn7ns.js +0 -8
- /package/{index-0wae5ebk.js → index-meh558jy.js} +0 -0
- /package/{index-ss469dec.js → index-nz8prx9g.js} +0 -0
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
} from "./index-
|
|
5
|
-
import {
|
|
6
|
-
pluralizeName
|
|
7
|
-
} from "./index-ss469dec.js";
|
|
3
|
+
FileSys
|
|
4
|
+
} from "./index-q0y2jq9j.js";
|
|
8
5
|
import {
|
|
9
6
|
AiSession
|
|
10
|
-
} from "./index-
|
|
7
|
+
} from "./index-c69j78kk.js";
|
|
11
8
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
createPassedPrimitiveReport,
|
|
15
|
-
generatedFilesForSync,
|
|
16
|
-
moduleSourcePaths,
|
|
17
|
-
sourceFile
|
|
18
|
-
} from "./index-rzwcpcc3.js";
|
|
19
|
-
import {
|
|
20
|
-
Prompter
|
|
21
|
-
} from "./index-tdbas9r0.js";
|
|
9
|
+
ModuleExecutor
|
|
10
|
+
} from "./index-qsq3q8fy.js";
|
|
22
11
|
import {
|
|
23
12
|
runner,
|
|
24
13
|
script
|
|
25
|
-
} from "./index-
|
|
14
|
+
} from "./index-znynzt5w.js";
|
|
26
15
|
import {
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
sourceFile,
|
|
17
|
+
moduleSourcePaths,
|
|
18
|
+
generatedFilesForSync,
|
|
19
|
+
createPassedPrimitiveReport,
|
|
20
|
+
bilingualLabelForField,
|
|
21
|
+
bilingualDescriptionForField
|
|
22
|
+
} from "./index-fc1bh0a7.js";
|
|
29
23
|
import {
|
|
30
|
-
|
|
31
|
-
} from "./index-
|
|
24
|
+
PageScript
|
|
25
|
+
} from "./index-hyywke0f.js";
|
|
26
|
+
import {
|
|
27
|
+
Prompter
|
|
28
|
+
} from "./index-h7yw2z9n.js";
|
|
29
|
+
import {
|
|
30
|
+
pluralizeName
|
|
31
|
+
} from "./index-nz8prx9g.js";
|
|
32
32
|
|
|
33
33
|
// pkgs/@akanjs/devkit/getRelatedCnsts.ts
|
|
34
34
|
import { readFileSync, realpathSync } from "fs";
|
|
@@ -662,39 +662,39 @@ class ModuleRunner extends runner("module") {
|
|
|
662
662
|
}
|
|
663
663
|
|
|
664
664
|
// pkgs/@akanjs/cli/module/module.script.ts
|
|
665
|
-
var moduleChangedFiles = (
|
|
665
|
+
var moduleChangedFiles = (sys, moduleName, files) => Object.values(files).map((file) => sourceFile(sys, `lib/${moduleName}/${file.filename}`, "create", "Module source file was created."));
|
|
666
666
|
|
|
667
667
|
class ModuleScript extends script("module", [ModuleRunner, PageScript]) {
|
|
668
|
-
async createModuleTemplate(
|
|
669
|
-
const mod = ModuleExecutor.from(
|
|
668
|
+
async createModuleTemplate(sys, name, { page = false } = {}) {
|
|
669
|
+
const mod = ModuleExecutor.from(sys, name);
|
|
670
670
|
const files = await this.moduleRunner.createModuleTemplate(mod);
|
|
671
|
-
if (page &&
|
|
672
|
-
await this.pageScript.createCrudPage(mod, { app:
|
|
673
|
-
await
|
|
671
|
+
if (page && sys.type === "app")
|
|
672
|
+
await this.pageScript.createCrudPage(mod, { app: sys, basePath: null, single: false });
|
|
673
|
+
await sys.scan();
|
|
674
674
|
return createPassedPrimitiveReport({
|
|
675
675
|
command: "create-module",
|
|
676
|
-
changedFiles: moduleChangedFiles(
|
|
677
|
-
generatedFiles: generatedFilesForSync(
|
|
678
|
-
target:
|
|
676
|
+
changedFiles: moduleChangedFiles(sys, name, files),
|
|
677
|
+
generatedFiles: generatedFilesForSync(sys, "Generated files were refreshed after module creation."),
|
|
678
|
+
target: sys.name
|
|
679
679
|
});
|
|
680
680
|
}
|
|
681
|
-
async createModule(
|
|
681
|
+
async createModule(sys, name, {
|
|
682
682
|
page = false,
|
|
683
683
|
description,
|
|
684
684
|
schemaDescription
|
|
685
685
|
} = {}) {
|
|
686
|
-
const isContinued = await
|
|
687
|
-
const session = new AiSession("createModule", { workspace:
|
|
688
|
-
const moduleConstantExampleFiles = await
|
|
689
|
-
const executor = ModuleExecutor.from(
|
|
686
|
+
const isContinued = await sys.exists(`lib/${name}/${name}.constant.ts`);
|
|
687
|
+
const session = new AiSession("createModule", { workspace: sys.workspace, cacheKey: name, isContinued });
|
|
688
|
+
const moduleConstantExampleFiles = await sys.workspace.getConstantFiles();
|
|
689
|
+
const executor = ModuleExecutor.from(sys, name);
|
|
690
690
|
const files = await this.moduleRunner.createModuleTemplate(executor);
|
|
691
691
|
const { constant, dictionary } = files;
|
|
692
|
-
if (page &&
|
|
693
|
-
await this.pageScript.createCrudPage(executor, { app:
|
|
692
|
+
if (page && sys.type === "app")
|
|
693
|
+
await this.pageScript.createCrudPage(executor, { app: sys, basePath: null, single: false });
|
|
694
694
|
const modelDesc = description ?? await input({ message: "description of module" });
|
|
695
695
|
const modelSchemaDesign = schemaDescription ?? await input({ message: "schema description of module" });
|
|
696
|
-
const config = await
|
|
697
|
-
const moduleRequest = new ModuleRequest({ sysType:
|
|
696
|
+
const config = await sys.getConfig();
|
|
697
|
+
const moduleRequest = new ModuleRequest({ sysType: sys.type, sysName: sys.name, modelName: name, config });
|
|
698
698
|
const constantRequestPrompt = await moduleRequest.requestModelConstant({
|
|
699
699
|
modelDesc,
|
|
700
700
|
modelSchemaDesign,
|
|
@@ -702,38 +702,38 @@ class ModuleScript extends script("module", [ModuleRunner, PageScript]) {
|
|
|
702
702
|
exampleFiles: randomPicks(moduleConstantExampleFiles, Math.min(10, moduleConstantExampleFiles.length))
|
|
703
703
|
});
|
|
704
704
|
const constantGuide = await ModuleRequest.getGuideJson("modelConstant");
|
|
705
|
-
const constantWrites = await session.writeTypescripts(constantRequestPrompt,
|
|
705
|
+
const constantWrites = await session.writeTypescripts(constantRequestPrompt, sys, {
|
|
706
706
|
validate: constantGuide.update.rules
|
|
707
707
|
});
|
|
708
708
|
for (const scalarName of this.#getCreatedScalarNames(constantWrites.map(({ filePath }) => filePath))) {
|
|
709
|
-
await
|
|
709
|
+
await sys.applyTemplate({
|
|
710
710
|
basePath: "./lib/__scalar",
|
|
711
711
|
template: "__scalar",
|
|
712
|
-
dict: { model: scalarName, models: pluralizeName(scalarName), sysName:
|
|
712
|
+
dict: { model: scalarName, models: pluralizeName(scalarName), sysName: sys.name },
|
|
713
713
|
overwrite: false
|
|
714
714
|
});
|
|
715
715
|
}
|
|
716
|
-
const constantContent = await
|
|
716
|
+
const constantContent = await sys.readFile(`lib/${name}/${name}.constant.ts`);
|
|
717
717
|
const dictionaryGuide = await ModuleRequest.getGuideJson("modelDictionary");
|
|
718
718
|
await session.writeTypescripts(requestDictionary({
|
|
719
|
-
sysName:
|
|
719
|
+
sysName: sys.name,
|
|
720
720
|
modelName: name,
|
|
721
721
|
constant: constantContent,
|
|
722
722
|
modelDesc,
|
|
723
723
|
modelSchemaDesign,
|
|
724
724
|
boilerplate: dictionary.content,
|
|
725
725
|
exampleFiles: randomPicks(moduleConstantExampleFiles, Math.min(10, moduleConstantExampleFiles.length))
|
|
726
|
-
}),
|
|
727
|
-
await
|
|
728
|
-
|
|
726
|
+
}), sys, { validate: dictionaryGuide.update.rules });
|
|
727
|
+
await sys.scan();
|
|
728
|
+
sys.log(`Module ${name} created in ${sys.type}s/${sys.name}/lib/${name}`);
|
|
729
729
|
return createPassedPrimitiveReport({
|
|
730
730
|
command: "create-module",
|
|
731
731
|
changedFiles: [
|
|
732
|
-
...moduleChangedFiles(
|
|
733
|
-
...constantWrites.map((write) => sourceFile(
|
|
732
|
+
...moduleChangedFiles(sys, name, files),
|
|
733
|
+
...constantWrites.map((write) => sourceFile(sys, write.filePath, "modify", "AI-assisted module constant source was updated."))
|
|
734
734
|
],
|
|
735
|
-
generatedFiles: generatedFilesForSync(
|
|
736
|
-
target:
|
|
735
|
+
generatedFiles: generatedFilesForSync(sys, "Generated files were refreshed after module creation."),
|
|
736
|
+
target: sys.name
|
|
737
737
|
});
|
|
738
738
|
}
|
|
739
739
|
#getCreatedScalarNames(filePaths) {
|
|
@@ -744,15 +744,15 @@ class ModuleScript extends script("module", [ModuleRunner, PageScript]) {
|
|
|
744
744
|
async removeModule(mod) {
|
|
745
745
|
await this.moduleRunner.removeModule(mod);
|
|
746
746
|
}
|
|
747
|
-
async createService(
|
|
748
|
-
const service = ModuleExecutor.from(
|
|
747
|
+
async createService(sys, name) {
|
|
748
|
+
const service = ModuleExecutor.from(sys, `_${name}`);
|
|
749
749
|
const files = await this.moduleRunner.createService(service);
|
|
750
|
-
await
|
|
750
|
+
await sys.scan();
|
|
751
751
|
return createPassedPrimitiveReport({
|
|
752
752
|
command: "create-service",
|
|
753
|
-
changedFiles: moduleChangedFiles(
|
|
754
|
-
generatedFiles: generatedFilesForSync(
|
|
755
|
-
target:
|
|
753
|
+
changedFiles: moduleChangedFiles(sys, `_${name}`, files),
|
|
754
|
+
generatedFiles: generatedFilesForSync(sys, "Generated files were refreshed after service creation."),
|
|
755
|
+
target: sys.name
|
|
756
756
|
});
|
|
757
757
|
}
|
|
758
758
|
async createTest(workspace, name) {}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
FileSys
|
|
4
|
+
} from "./index-q0y2jq9j.js";
|
|
5
|
+
import {
|
|
4
6
|
Executor,
|
|
7
|
+
WorkspaceExecutor,
|
|
8
|
+
AppExecutor,
|
|
5
9
|
LibExecutor,
|
|
6
|
-
ModuleExecutor,
|
|
7
10
|
PkgExecutor,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "./index-hgna5rjy.js";
|
|
11
|
+
ModuleExecutor
|
|
12
|
+
} from "./index-qsq3q8fy.js";
|
|
11
13
|
import {
|
|
12
|
-
|
|
13
|
-
} from "./index-
|
|
14
|
-
import {
|
|
15
|
-
__require
|
|
16
|
-
} from "./index-r24hmh0q.js";
|
|
14
|
+
getDirname2
|
|
15
|
+
} from "./index-6wwzs1bc.js";
|
|
17
16
|
|
|
18
17
|
// pkgs/@akanjs/devkit/commandDecorators/targetMeta.ts
|
|
19
18
|
var COMMAND_META = Symbol("akan.command.meta");
|
|
@@ -52,6 +51,7 @@ var normalizePrimitiveArgType = (type) => {
|
|
|
52
51
|
throw new Error(`Invalid primitive argument type: ${type}`);
|
|
53
52
|
};
|
|
54
53
|
var App = createInternalArgToken("App");
|
|
54
|
+
var Apps = createInternalArgToken("Apps");
|
|
55
55
|
var Lib = createInternalArgToken("Lib");
|
|
56
56
|
var Sys = createInternalArgToken("Sys");
|
|
57
57
|
var Exec = createInternalArgToken("Exec");
|
|
@@ -60,11 +60,29 @@ var Module = createInternalArgToken("Module");
|
|
|
60
60
|
var Workspace = createInternalArgToken("Workspace");
|
|
61
61
|
|
|
62
62
|
// pkgs/@akanjs/devkit/commandDecorators/command.ts
|
|
63
|
-
import
|
|
63
|
+
import path2 from "path";
|
|
64
64
|
import { Logger } from "akanjs/common";
|
|
65
65
|
import chalk2 from "chalk";
|
|
66
66
|
import { program } from "commander";
|
|
67
67
|
|
|
68
|
+
// pkgs/@akanjs/devkit/appSelectionMemory.ts
|
|
69
|
+
import path from "path";
|
|
70
|
+
class AppSelectionMemory {
|
|
71
|
+
static pathIn(workspaceRoot) {
|
|
72
|
+
return path.join(workspaceRoot, "local", ".akan", "lastStart.json");
|
|
73
|
+
}
|
|
74
|
+
static async read(workspaceRoot) {
|
|
75
|
+
const stored = await Bun.file(AppSelectionMemory.pathIn(workspaceRoot)).json().catch(() => null);
|
|
76
|
+
const apps = stored?.apps;
|
|
77
|
+
return Array.isArray(apps) ? apps.filter((name) => typeof name === "string") : [];
|
|
78
|
+
}
|
|
79
|
+
static async write(workspaceRoot, apps) {
|
|
80
|
+
await FileSys.writeJson(AppSelectionMemory.pathIn(workspaceRoot), { apps }).catch(() => {
|
|
81
|
+
return;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
68
86
|
// pkgs/@akanjs/devkit/commandDecorators/dependencyBuilder.ts
|
|
69
87
|
var capitalize = (value) => value.slice(0, 1).toUpperCase() + value.slice(1);
|
|
70
88
|
var createDependencyKey = (refName, kind) => `${refName}${capitalize(kind)}`;
|
|
@@ -262,6 +280,8 @@ var formatCommandHelp = (command, key) => {
|
|
|
262
280
|
return "";
|
|
263
281
|
if (arg.type === "Module")
|
|
264
282
|
return "[sys:module]";
|
|
283
|
+
if (arg.type === "Apps")
|
|
284
|
+
return "[apps...]";
|
|
265
285
|
if (arg.type === "Argument") {
|
|
266
286
|
return `[${camelToKebabCase2(arg.name)}]`;
|
|
267
287
|
}
|
|
@@ -288,6 +308,9 @@ var formatCommandHelp = (command, key) => {
|
|
|
288
308
|
} else if (arg.type === "Module") {
|
|
289
309
|
argName = "sys:module";
|
|
290
310
|
argDesc = "Module in format: app-name:module-name or lib-name:module-name";
|
|
311
|
+
} else if (arg.type === "Apps") {
|
|
312
|
+
argName = "apps...";
|
|
313
|
+
argDesc = "App names, space- or comma-separated, or all. Omit to pick them interactively";
|
|
291
314
|
} else {
|
|
292
315
|
argName = arg.type.toLowerCase();
|
|
293
316
|
argDesc = `${arg.type} name in this workspace`;
|
|
@@ -381,6 +404,17 @@ var prompts = async () => await import("@inquirer/prompts");
|
|
|
381
404
|
var select = (config, context) => prompts().then((m) => m.select(config, context));
|
|
382
405
|
var confirm = (config, context) => prompts().then((m) => m.confirm(config, context));
|
|
383
406
|
var input = (config, context) => prompts().then((m) => m.input(config, context));
|
|
407
|
+
var checkbox = (config, context) => prompts().then((m) => m.checkbox(config, context));
|
|
408
|
+
var assertEnumChoice = (argMeta, value) => {
|
|
409
|
+
const enumChoices = argMeta.argsOption.enum;
|
|
410
|
+
if (!enumChoices || typeof enumChoices === "function")
|
|
411
|
+
return;
|
|
412
|
+
const choices = normalizeEnumChoices(enumChoices);
|
|
413
|
+
if (choices.some((choice) => String(choice.value) === String(value)))
|
|
414
|
+
return;
|
|
415
|
+
const label = argMeta.type === "Option" ? `option '--${camelToKebabCase3(argMeta.name)}'` : `argument '${argMeta.name}'`;
|
|
416
|
+
throw new Error(`${label} argument '${String(value)}' is invalid. Allowed choices are ${choices.map((choice) => choice.name).join(", ")}.`);
|
|
417
|
+
};
|
|
384
418
|
var resolveEnumChoices = async (argMeta, context) => {
|
|
385
419
|
const enumChoices = argMeta.argsOption.enum;
|
|
386
420
|
if (!enumChoices)
|
|
@@ -394,9 +428,10 @@ var getOptionValue = async (argMeta, opt, context) => {
|
|
|
394
428
|
name,
|
|
395
429
|
argsOption: { enum: enumChoices, default: defaultValue, type, desc, nullable, example, ask }
|
|
396
430
|
} = argMeta;
|
|
397
|
-
if (opt[argMeta.name] !== undefined)
|
|
431
|
+
if (opt[argMeta.name] !== undefined) {
|
|
432
|
+
assertEnumChoice(argMeta, opt[argMeta.name]);
|
|
398
433
|
return convertArgValue(opt[argMeta.name], type ?? "string");
|
|
399
|
-
else if (defaultValue !== undefined)
|
|
434
|
+
} else if (defaultValue !== undefined)
|
|
400
435
|
return defaultValue;
|
|
401
436
|
if (enumChoices) {
|
|
402
437
|
const choices = normalizeEnumChoices(await resolveEnumChoices(argMeta, context) ?? []);
|
|
@@ -422,9 +457,10 @@ var getArgumentValue = async (argMeta, value) => {
|
|
|
422
457
|
name,
|
|
423
458
|
argsOption: { default: defaultValue, type, desc, nullable, example, ask }
|
|
424
459
|
} = argMeta;
|
|
425
|
-
if (value !== undefined)
|
|
460
|
+
if (value !== undefined) {
|
|
461
|
+
assertEnumChoice(argMeta, value);
|
|
426
462
|
return convertArgValue(value, type ?? "string");
|
|
427
|
-
else if (defaultValue !== undefined)
|
|
463
|
+
} else if (defaultValue !== undefined)
|
|
428
464
|
return defaultValue;
|
|
429
465
|
else if (nullable)
|
|
430
466
|
return null;
|
|
@@ -463,6 +499,31 @@ var assertCurrentDirectoryIsWorkspaceRoot = async () => {
|
|
|
463
499
|
].join(`
|
|
464
500
|
`));
|
|
465
501
|
};
|
|
502
|
+
var parseAppNameList = (value) => (Array.isArray(value) ? value : value === undefined ? [] : [value]).flatMap((entry) => entry.split(",")).map((entry) => entry.trim()).filter(Boolean);
|
|
503
|
+
var getAppsArgumentValue = async (value, workspace) => {
|
|
504
|
+
const appNames = await workspace.getApps();
|
|
505
|
+
if (appNames.length === 0)
|
|
506
|
+
throw new Error("No apps found in this workspace (apps/<appName>/akan.config.ts)");
|
|
507
|
+
const requested = parseAppNameList(value);
|
|
508
|
+
if (requested.includes("all"))
|
|
509
|
+
return appNames.map((name) => AppExecutor.from(workspace, name));
|
|
510
|
+
if (requested.length) {
|
|
511
|
+
const unknown = requested.filter((name) => !appNames.includes(name));
|
|
512
|
+
if (unknown.length)
|
|
513
|
+
throw new Error(`Unknown app${unknown.length > 1 ? "s" : ""}: ${unknown.join(", ")}. Available: ${appNames.join(", ")}, all`);
|
|
514
|
+
return [...new Set(requested)].map((name) => AppExecutor.from(workspace, name));
|
|
515
|
+
}
|
|
516
|
+
if (appNames.length === 1 && appNames[0])
|
|
517
|
+
return [AppExecutor.from(workspace, appNames[0])];
|
|
518
|
+
const remembered = new Set(await AppSelectionMemory.read(workspace.workspaceRoot));
|
|
519
|
+
const picked = await checkbox({
|
|
520
|
+
message: "Select the apps to run (space to toggle, enter to confirm)",
|
|
521
|
+
choices: appNames.map((name) => ({ name, value: name, checked: remembered.has(name) })),
|
|
522
|
+
required: true
|
|
523
|
+
});
|
|
524
|
+
await AppSelectionMemory.write(workspace.workspaceRoot, picked);
|
|
525
|
+
return picked.map((name) => AppExecutor.from(workspace, name));
|
|
526
|
+
};
|
|
466
527
|
var getInternalArgumentValue = async (argMeta, value, workspace) => {
|
|
467
528
|
if (argMeta.type === "Workspace")
|
|
468
529
|
return workspace;
|
|
@@ -526,36 +587,36 @@ var getInternalArgumentValue = async (argMeta, value, workspace) => {
|
|
|
526
587
|
return PkgExecutor.from(workspace, pkgName);
|
|
527
588
|
} else if (sysType === "module") {
|
|
528
589
|
if (value) {
|
|
529
|
-
const [sysName,
|
|
530
|
-
if (!sysName || !
|
|
590
|
+
const [sysName, moduleName] = value.split(":");
|
|
591
|
+
if (!sysName || !moduleName)
|
|
531
592
|
throw new Error(`Invalid module name: ${value}`);
|
|
532
593
|
if (appNames.includes(sysName)) {
|
|
533
594
|
const app = AppExecutor.from(workspace, sysName);
|
|
534
|
-
const
|
|
535
|
-
if (
|
|
536
|
-
return ModuleExecutor.from(app,
|
|
595
|
+
const modules = await app.getModules();
|
|
596
|
+
if (modules.includes(moduleName))
|
|
597
|
+
return ModuleExecutor.from(app, moduleName);
|
|
537
598
|
else
|
|
538
|
-
throw new Error(`Invalid module name: ${
|
|
599
|
+
throw new Error(`Invalid module name: ${moduleName}`);
|
|
539
600
|
} else if (libNames.includes(sysName)) {
|
|
540
601
|
const lib = LibExecutor.from(workspace, sysName);
|
|
541
|
-
const
|
|
542
|
-
if (
|
|
543
|
-
return ModuleExecutor.from(lib,
|
|
602
|
+
const modules = await lib.getModules();
|
|
603
|
+
if (modules.includes(moduleName))
|
|
604
|
+
return ModuleExecutor.from(lib, moduleName);
|
|
544
605
|
} else
|
|
545
606
|
throw new Error(`Invalid system name: ${sysName}`);
|
|
546
607
|
}
|
|
547
608
|
const { type, name } = await select({
|
|
548
609
|
message: `select the App or Lib name`,
|
|
549
610
|
choices: [
|
|
550
|
-
...appNames.map((
|
|
551
|
-
...libNames.map((
|
|
611
|
+
...appNames.map((name) => ({ name, value: { type: "app", name } })),
|
|
612
|
+
...libNames.map((name) => ({ name, value: { type: "lib", name } }))
|
|
552
613
|
]
|
|
553
614
|
});
|
|
554
615
|
const executor = type === "app" ? AppExecutor.from(workspace, name) : LibExecutor.from(workspace, name);
|
|
555
616
|
const modules = await executor.getModules();
|
|
556
617
|
const moduleName = await select({
|
|
557
618
|
message: `Select the module name`,
|
|
558
|
-
choices: modules.map((
|
|
619
|
+
choices: modules.map((name) => ({ name: `${executor.name}:${name}`, value: name }))
|
|
559
620
|
});
|
|
560
621
|
return ModuleExecutor.from(executor, moduleName);
|
|
561
622
|
} else
|
|
@@ -566,8 +627,8 @@ var runCommands = async (...commands) => {
|
|
|
566
627
|
printCliError(error);
|
|
567
628
|
process.exit(1);
|
|
568
629
|
});
|
|
569
|
-
const __dirname2 =
|
|
570
|
-
const packageJsonCandidates = [`${
|
|
630
|
+
const __dirname2 = getDirname2(import.meta.url);
|
|
631
|
+
const packageJsonCandidates = [`${path2.dirname(Bun.main)}/package.json`, `${__dirname2}/../package.json`];
|
|
571
632
|
let cliPackageJson = null;
|
|
572
633
|
for (const packageJsonPath of packageJsonCandidates) {
|
|
573
634
|
if (!await FileSys.fileExists(packageJsonPath))
|
|
@@ -614,6 +675,8 @@ It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`)
|
|
|
614
675
|
continue;
|
|
615
676
|
else if (argMeta.type === "Module") {
|
|
616
677
|
programCommand = programCommand.argument(`[sys-name:module-name]`, `${argMeta.type} in this workspace (apps|libs)/<sys-name>/lib/<module-name>`);
|
|
678
|
+
} else if (argMeta.type === "Apps") {
|
|
679
|
+
programCommand = programCommand.argument(`[apps...]`, `apps in this workspace apps/<appName>, or all (space- or comma-separated; omit to pick interactively)`);
|
|
617
680
|
} else {
|
|
618
681
|
const sysType = argMeta.type.toLowerCase();
|
|
619
682
|
programCommand = programCommand.argument(`[${sysType}]`, `${sysType} in this workspace ${sysType}s/<${sysType}Name>`);
|
|
@@ -638,10 +701,17 @@ It may cause unexpected behavior. Run \`akan update\` to update latest akanjs.`)
|
|
|
638
701
|
commandArgs[argMeta.idx] = await getOptionValue(argMeta, opt, commandContext);
|
|
639
702
|
else if (argMeta.type === "Argument")
|
|
640
703
|
commandArgs[argMeta.idx] = await getArgumentValue(argMeta, cmdArgs[argMeta.idx]);
|
|
704
|
+
else if (argMeta.type === "Apps")
|
|
705
|
+
commandArgs[argMeta.idx] = await getAppsArgumentValue(cmdArgs[argMeta.idx], workspace);
|
|
641
706
|
else
|
|
642
707
|
commandArgs[argMeta.idx] = await getInternalArgumentValue(argMeta, cmdArgs[argMeta.idx], workspace);
|
|
643
708
|
if (commandArgs[argMeta.idx] instanceof AppExecutor)
|
|
644
709
|
process.env.AKAN_PUBLIC_APP_NAME = commandArgs[argMeta.idx].name;
|
|
710
|
+
else if (Array.isArray(commandArgs[argMeta.idx])) {
|
|
711
|
+
const apps = commandArgs[argMeta.idx];
|
|
712
|
+
if (apps.length === 1 && apps[0])
|
|
713
|
+
process.env.AKAN_PUBLIC_APP_NAME = apps[0].name;
|
|
714
|
+
}
|
|
645
715
|
assignCommandContext(commandContext, argMeta, commandArgs[argMeta.idx]);
|
|
646
716
|
if (opt.verbose)
|
|
647
717
|
Executor.setVerbose(true);
|
|
@@ -761,4 +831,4 @@ function command(refName, depsOrBuilder, builder) {
|
|
|
761
831
|
}
|
|
762
832
|
return CommandBase;
|
|
763
833
|
}
|
|
764
|
-
export { getTargetMetas, getTargetCommandNames, App, Lib, Sys, Exec, Pkg, Module, Workspace, CommandContainer, runner, script, runCommands, command };
|
|
834
|
+
export { getTargetMetas, getTargetCommandNames, App, Apps, Lib, Sys, Exec, Pkg, Module, Workspace, CommandContainer, runner, script, runCommands, command };
|
|
@@ -1,27 +1,20 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
CloudApi,
|
|
3
|
+
getDefaultHostConfig,
|
|
5
4
|
GlobalConfig,
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
CloudApi,
|
|
6
|
+
AiSession
|
|
7
|
+
} from "./index-c69j78kk.js";
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
WorkspaceExecutor,
|
|
10
|
+
AppExecutor
|
|
11
|
+
} from "./index-qsq3q8fy.js";
|
|
11
12
|
import {
|
|
12
13
|
runner
|
|
13
|
-
} from "./index-
|
|
14
|
+
} from "./index-znynzt5w.js";
|
|
14
15
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from "./index-hgna5rjy.js";
|
|
18
|
-
|
|
19
|
-
// pkgs/@akanjs/cli/cloud/cloud.runner.ts
|
|
20
|
-
import path from "path";
|
|
21
|
-
import { confirm, input, select } from "@inquirer/prompts";
|
|
22
|
-
import { Logger, sleep } from "akanjs/common";
|
|
23
|
-
import chalk from "chalk";
|
|
24
|
-
import * as QRcode from "qrcode";
|
|
16
|
+
openBrowser
|
|
17
|
+
} from "./index-zz5jyd94.js";
|
|
25
18
|
|
|
26
19
|
// pkgs/@akanjs/cli/npmRegistry.ts
|
|
27
20
|
var defaultNpmRegistry = "https://registry.npmjs.org";
|
|
@@ -40,6 +33,11 @@ async function getLatestPackageVersion(packageName, tag = "latest", registryUrl)
|
|
|
40
33
|
}
|
|
41
34
|
|
|
42
35
|
// pkgs/@akanjs/cli/cloud/cloud.runner.ts
|
|
36
|
+
import path from "path";
|
|
37
|
+
import { confirm, input, select } from "@inquirer/prompts";
|
|
38
|
+
import { Logger, sleep } from "akanjs/common";
|
|
39
|
+
import chalk from "chalk";
|
|
40
|
+
import * as QRcode from "qrcode";
|
|
43
41
|
var addRemoteEnvServerValue = "__addRemoteEnvServer";
|
|
44
42
|
var removeRemoteEnvServerValue = "__removeRemoteEnvServer";
|
|
45
43
|
|
|
@@ -100,8 +98,8 @@ class CloudRunner extends runner("cloud") {
|
|
|
100
98
|
const selectedName = await select({
|
|
101
99
|
message: "Select the remote env server",
|
|
102
100
|
choices: [
|
|
103
|
-
...serverEntries.map(([name,
|
|
104
|
-
name: `${name} (${
|
|
101
|
+
...serverEntries.map(([name, config]) => ({
|
|
102
|
+
name: `${name} (${config.username ? `${config.username}@` : ""}${config.host}${config.port ? `:${config.port}` : ""})`,
|
|
105
103
|
value: name
|
|
106
104
|
})),
|
|
107
105
|
{ name: "Add new remote server", value: addRemoteEnvServerValue },
|
|
@@ -205,12 +203,12 @@ ${chalk.green("\u27A4")} Authentication Required`));
|
|
|
205
203
|
const MAX_RETRY = 300;
|
|
206
204
|
for (let i = 0;i < MAX_RETRY; i++) {
|
|
207
205
|
const accessToken = await cloudApi.getRemoteAuthToken(remoteId);
|
|
208
|
-
const
|
|
209
|
-
if (accessToken &&
|
|
210
|
-
await GlobalConfig.setHostConfig({ host: config.host, auth: { accessToken, self
|
|
206
|
+
const self = await cloudApi.getRemoteSelf();
|
|
207
|
+
if (accessToken && self) {
|
|
208
|
+
await GlobalConfig.setHostConfig({ host: config.host, auth: { accessToken, self } });
|
|
211
209
|
Logger.rawLog(chalk.green(`\r\u2713 Authentication successful!`));
|
|
212
210
|
Logger.rawLog(chalk.green.bold(`
|
|
213
|
-
\u2728 Welcome aboard, ${
|
|
211
|
+
\u2728 Welcome aboard, ${self.nickname ?? "anonymous"}!`));
|
|
214
212
|
Logger.rawLog(chalk.dim(`You're now ready to use Akan CLI!
|
|
215
213
|
`));
|
|
216
214
|
return true;
|
|
@@ -255,12 +253,12 @@ ${chalk.green("\u27A4")} Authentication Required`));
|
|
|
255
253
|
const isOfficialRelease = !devPatchVersion;
|
|
256
254
|
const targetVersionPrefix = isOfficialRelease ? `${majorVersion}.${minorVersion}` : `${majorVersion}.${minorVersion}.${patchVersion}`;
|
|
257
255
|
const tag = distTag ?? (isOfficialRelease ? "latest" : patchVersion.split("-").at(1) ?? "dev");
|
|
258
|
-
const getNextVersion = async (prefix,
|
|
256
|
+
const getNextVersion = async (prefix, tag) => {
|
|
259
257
|
try {
|
|
260
|
-
const
|
|
261
|
-
const latestPatch =
|
|
262
|
-
const
|
|
263
|
-
return { nextVersion
|
|
258
|
+
const latestPublishedVersion = await getLatestPackageVersion("akanjs", tag, registry);
|
|
259
|
+
const latestPatch = latestPublishedVersion.startsWith(prefix) ? parseInt(latestPublishedVersion.split(".").at(-1) ?? "-1") : -1;
|
|
260
|
+
const nextVersion = `${prefix}.${latestPatch + 1}`;
|
|
261
|
+
return { nextVersion, latestPublishedVersion };
|
|
264
262
|
} catch {
|
|
265
263
|
return { nextVersion: `${prefix}.0`, latestPublishedVersion: null };
|
|
266
264
|
}
|
|
@@ -285,7 +283,10 @@ ${chalk.green("\u27A4")} Authentication Required`));
|
|
|
285
283
|
return;
|
|
286
284
|
}
|
|
287
285
|
}
|
|
288
|
-
|
|
286
|
+
Logger.info("Logging in to npm...");
|
|
287
|
+
await workspace.spawn("npm", ["login"], { stdio: "inherit" });
|
|
288
|
+
Logger.info("Logged in to npm");
|
|
289
|
+
for (const library of akanPkgs) {
|
|
289
290
|
Logger.info(`Publishing ${library}@${nextVersion} to ${registry ?? "npm"}...`);
|
|
290
291
|
await workspace.spawn("npm", ["publish", "--tag", tag, ...this.#getRegistryArgs(registry), ...this.#getLocalRegistryAuthArgs(registry)], {
|
|
291
292
|
cwd: path.join(workspace.workspaceRoot, "dist/pkgs", library),
|
|
@@ -293,7 +294,7 @@ ${chalk.green("\u27A4")} Authentication Required`));
|
|
|
293
294
|
stdio: "inherit"
|
|
294
295
|
});
|
|
295
296
|
Logger.info(`${library}@${nextVersion} is published to ${registry ?? "npm"}`);
|
|
296
|
-
}
|
|
297
|
+
}
|
|
297
298
|
Logger.info(`All libraries are published to ${registry ?? "npm"}`);
|
|
298
299
|
}
|
|
299
300
|
async update(workspace, tag = "latest", { registryUrl } = {}) {
|