@akanjs/cli 0.0.137 → 0.0.138
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/README.md +18 -1
- package/cjs/index.js +111 -28
- package/cjs/src/templates/app/app/[lang]/admin/layout.js +1 -0
- package/cjs/src/templates/workspaceRoot/package.json.template +1 -0
- package/esm/index.js +111 -28
- package/esm/src/templates/app/app/[lang]/admin/layout.js +1 -0
- package/esm/src/templates/workspaceRoot/package.json.template +1 -0
- package/package.json +1 -1
- package/src/application/application.command.d.ts +1 -1
- package/src/application/application.script.d.ts +1 -2
package/README.md
CHANGED
|
@@ -20,5 +20,22 @@ akan create-workspace
|
|
|
20
20
|
# How to start your project
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
cd <workspace-name> && akan start <app-name> --open
|
|
23
|
+
cd <workspace-name> && akan start <app-name> --open
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
you can navigate to default webpage
|
|
27
|
+
|
|
28
|
+
- home: http://localhost:4200
|
|
29
|
+
|
|
30
|
+
# Recipes
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# set llm model
|
|
34
|
+
akan set-llm
|
|
35
|
+
|
|
36
|
+
# create module
|
|
37
|
+
akan create-module
|
|
38
|
+
|
|
39
|
+
# create scalar with ai (experimental)
|
|
40
|
+
akan create-scalar
|
|
24
41
|
```
|
package/cjs/index.js
CHANGED
|
@@ -914,11 +914,58 @@ var TypeScriptDependencyScanner = class {
|
|
|
914
914
|
}
|
|
915
915
|
};
|
|
916
916
|
|
|
917
|
+
// pkgs/@akanjs/devkit/src/spinner.ts
|
|
918
|
+
var import_ora2 = __toESM(require("ora"));
|
|
919
|
+
var Spinner = class {
|
|
920
|
+
spinner;
|
|
921
|
+
stopWatch;
|
|
922
|
+
startAt;
|
|
923
|
+
message;
|
|
924
|
+
constructor(message, { prefix = "", indent = 0 } = {}) {
|
|
925
|
+
this.message = message;
|
|
926
|
+
this.spinner = (0, import_ora2.default)(message);
|
|
927
|
+
this.spinner.prefixText = prefix;
|
|
928
|
+
this.spinner.indent = indent;
|
|
929
|
+
}
|
|
930
|
+
start() {
|
|
931
|
+
this.startAt = /* @__PURE__ */ new Date();
|
|
932
|
+
const spinner = this.spinner.start();
|
|
933
|
+
this.stopWatch = setInterval(() => {
|
|
934
|
+
spinner.text = `${this.message} (${this.#getElapsedTimeStr()})`;
|
|
935
|
+
}, 1e3);
|
|
936
|
+
return this;
|
|
937
|
+
}
|
|
938
|
+
succeed(message) {
|
|
939
|
+
clearInterval(this.stopWatch);
|
|
940
|
+
this.spinner.succeed(`${message} (${this.#getElapsedTimeStr()})`);
|
|
941
|
+
}
|
|
942
|
+
#getElapsedTimeStr() {
|
|
943
|
+
const ms = (/* @__PURE__ */ new Date()).getTime() - this.startAt.getTime();
|
|
944
|
+
if (ms < 1e3)
|
|
945
|
+
return `${ms}ms`;
|
|
946
|
+
const s = Math.floor(ms / 1e3);
|
|
947
|
+
if (s < 60)
|
|
948
|
+
return `${s}s`;
|
|
949
|
+
const m = Math.floor(s / 60);
|
|
950
|
+
return `${m}m ${s % 60}s`;
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
|
|
917
954
|
// pkgs/@akanjs/devkit/src/executors.ts
|
|
955
|
+
var execEmoji = {
|
|
956
|
+
workspace: "\u{1F3E0}",
|
|
957
|
+
app: "\u{1F680}",
|
|
958
|
+
lib: "\u{1F527}",
|
|
959
|
+
pkg: "\u{1F4E6}",
|
|
960
|
+
dist: "\u{1F4BF}",
|
|
961
|
+
default: "\u2708\uFE0F"
|
|
962
|
+
// for sys executor
|
|
963
|
+
};
|
|
918
964
|
var Executor = class {
|
|
919
965
|
name;
|
|
920
966
|
logger;
|
|
921
967
|
cwdPath;
|
|
968
|
+
emoji = execEmoji.default;
|
|
922
969
|
constructor(name, cwdPath) {
|
|
923
970
|
this.name = name;
|
|
924
971
|
this.logger = new Logger(name);
|
|
@@ -1045,6 +1092,9 @@ var Executor = class {
|
|
|
1045
1092
|
this.logger.verbose(msg);
|
|
1046
1093
|
return this;
|
|
1047
1094
|
}
|
|
1095
|
+
spinning(msg, { prefix = `${this.emoji}${this.name} -`, indent = 0 } = {}) {
|
|
1096
|
+
return new Spinner(msg, { prefix, indent }).start();
|
|
1097
|
+
}
|
|
1048
1098
|
getTsConfig(pathname = "tsconfig.json") {
|
|
1049
1099
|
const tsconfig = this.readJson(pathname);
|
|
1050
1100
|
if (tsconfig.extends) {
|
|
@@ -1131,8 +1181,9 @@ var Executor = class {
|
|
|
1131
1181
|
var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
|
|
1132
1182
|
workspaceRoot;
|
|
1133
1183
|
repoName;
|
|
1184
|
+
emoji = execEmoji.workspace;
|
|
1134
1185
|
constructor({ workspaceRoot, repoName }) {
|
|
1135
|
-
super(
|
|
1186
|
+
super("workspace", workspaceRoot);
|
|
1136
1187
|
this.workspaceRoot = workspaceRoot;
|
|
1137
1188
|
this.repoName = repoName;
|
|
1138
1189
|
}
|
|
@@ -1287,11 +1338,13 @@ var SysExecutor = class extends Executor {
|
|
|
1287
1338
|
workspace;
|
|
1288
1339
|
name;
|
|
1289
1340
|
type;
|
|
1341
|
+
emoji;
|
|
1290
1342
|
constructor({ workspace = WorkspaceExecutor.fromRoot(), name, type }) {
|
|
1291
|
-
super(
|
|
1343
|
+
super(name, `${workspace.workspaceRoot}/${type}s/${name}`);
|
|
1292
1344
|
this.workspace = workspace;
|
|
1293
1345
|
this.name = name;
|
|
1294
1346
|
this.type = type;
|
|
1347
|
+
this.emoji = execEmoji[type];
|
|
1295
1348
|
}
|
|
1296
1349
|
async getConfig(command) {
|
|
1297
1350
|
return this.type === "app" ? await getAppConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name, command }) : await getLibConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "lib", name: this.name, command });
|
|
@@ -1512,9 +1565,10 @@ var SysExecutor = class extends Executor {
|
|
|
1512
1565
|
};
|
|
1513
1566
|
var AppExecutor = class _AppExecutor extends SysExecutor {
|
|
1514
1567
|
dist;
|
|
1568
|
+
emoji = execEmoji.app;
|
|
1515
1569
|
constructor({ workspace, name }) {
|
|
1516
1570
|
super({ workspace, name, type: "app" });
|
|
1517
|
-
this.dist = new Executor(
|
|
1571
|
+
this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/apps/${name}`);
|
|
1518
1572
|
}
|
|
1519
1573
|
static from(executor, name) {
|
|
1520
1574
|
if (executor instanceof WorkspaceExecutor)
|
|
@@ -1548,9 +1602,10 @@ var LibExecutor = class _LibExecutor extends SysExecutor {
|
|
|
1548
1602
|
workspaceRoot;
|
|
1549
1603
|
repoName;
|
|
1550
1604
|
dist;
|
|
1605
|
+
emoji = execEmoji.lib;
|
|
1551
1606
|
constructor({ workspace, name }) {
|
|
1552
1607
|
super({ workspace, name, type: "lib" });
|
|
1553
|
-
this.dist = new Executor(
|
|
1608
|
+
this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/libs/${name}`);
|
|
1554
1609
|
}
|
|
1555
1610
|
static from(executor, name) {
|
|
1556
1611
|
if (executor instanceof WorkspaceExecutor)
|
|
@@ -1570,11 +1625,12 @@ var PkgExecutor = class _PkgExecutor extends Executor {
|
|
|
1570
1625
|
workspace;
|
|
1571
1626
|
name;
|
|
1572
1627
|
dist;
|
|
1628
|
+
emoji = execEmoji.pkg;
|
|
1573
1629
|
constructor({ workspace = WorkspaceExecutor.fromRoot(), name }) {
|
|
1574
|
-
super(
|
|
1630
|
+
super(name, `${workspace.workspaceRoot}/pkgs/${name}`);
|
|
1575
1631
|
this.workspace = workspace;
|
|
1576
1632
|
this.name = name;
|
|
1577
|
-
this.dist = new Executor(
|
|
1633
|
+
this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/pkgs/${name}`);
|
|
1578
1634
|
}
|
|
1579
1635
|
static from(executor, name) {
|
|
1580
1636
|
if (executor instanceof WorkspaceExecutor)
|
|
@@ -2174,10 +2230,10 @@ var runCommands = async (...commands) => {
|
|
|
2174
2230
|
|
|
2175
2231
|
// pkgs/@akanjs/devkit/src/aiEditor.ts
|
|
2176
2232
|
var import_prompts4 = require("@inquirer/prompts");
|
|
2177
|
-
var import_ora2 = __toESM(require("ora"));
|
|
2178
2233
|
var import_messages = require("@langchain/core/messages");
|
|
2179
2234
|
var import_openai2 = require("@langchain/openai");
|
|
2180
2235
|
var import_chalk3 = __toESM(require("chalk"));
|
|
2236
|
+
var import_ora3 = __toESM(require("ora"));
|
|
2181
2237
|
var MAX_ASK_TRY = 300;
|
|
2182
2238
|
var supportedLlmModels = ["deepseek-chat", "deepseek-reasoner"];
|
|
2183
2239
|
var AiSession = class _AiSession {
|
|
@@ -2248,7 +2304,7 @@ var AiSession = class _AiSession {
|
|
|
2248
2304
|
await _AiSession.init();
|
|
2249
2305
|
if (!_AiSession.#chat)
|
|
2250
2306
|
throw new Error("Failed to initialize the AI session");
|
|
2251
|
-
const loader = (0,
|
|
2307
|
+
const loader = (0, import_ora3.default)(`${_AiSession.#chat.model} is thinking...`).start();
|
|
2252
2308
|
try {
|
|
2253
2309
|
const humanMessage = new import_messages.HumanMessage(question);
|
|
2254
2310
|
this.messageHistory.push(humanMessage);
|
|
@@ -2523,7 +2579,7 @@ var import_fs9 = __toESM(require("fs"));
|
|
|
2523
2579
|
var import_promises2 = __toESM(require("fs/promises"));
|
|
2524
2580
|
var import_js_yaml2 = __toESM(require("js-yaml"));
|
|
2525
2581
|
var import_open = __toESM(require("open"));
|
|
2526
|
-
var
|
|
2582
|
+
var import_ora4 = __toESM(require("ora"));
|
|
2527
2583
|
var import_path4 = __toESM(require("path"));
|
|
2528
2584
|
var vite = __toESM(require("vite"));
|
|
2529
2585
|
var import_vite_plugin_commonjs = __toESM(require("vite-plugin-commonjs"));
|
|
@@ -4515,7 +4571,7 @@ var ApplicationRunner = class {
|
|
|
4515
4571
|
async buildFrontend(app) {
|
|
4516
4572
|
const { env } = await this.#prepareCommand(app, "build", "frontend");
|
|
4517
4573
|
const akanConfig = await app.getConfig("build");
|
|
4518
|
-
await app.spawn("npx", ["next", "build", "--no-lint"], { env });
|
|
4574
|
+
await app.spawn("npx", ["next", "build", "--no-lint"], { env, stdio: "ignore" });
|
|
4519
4575
|
const buildResult = await esbuild2.build({
|
|
4520
4576
|
entryPoints: [`${app.cwdPath}/next.config.ts`],
|
|
4521
4577
|
outdir: `${app.dist.cwdPath}/frontend`,
|
|
@@ -4536,9 +4592,7 @@ var ApplicationRunner = class {
|
|
|
4536
4592
|
version: "1.0.0",
|
|
4537
4593
|
engines: { node: ">=22" },
|
|
4538
4594
|
dependencies,
|
|
4539
|
-
scripts: {
|
|
4540
|
-
start: "next start"
|
|
4541
|
-
}
|
|
4595
|
+
scripts: { start: "next start" }
|
|
4542
4596
|
};
|
|
4543
4597
|
app.dist.writeJson("frontend/package.json", appPackageJson);
|
|
4544
4598
|
await Promise.all([
|
|
@@ -4703,10 +4757,13 @@ var ApplicationRunner = class {
|
|
|
4703
4757
|
dict: { repoName: workspace.repoName },
|
|
4704
4758
|
overwrite: false
|
|
4705
4759
|
});
|
|
4706
|
-
await workspace.spawn(`docker`, ["compose", "up", "-d"], {
|
|
4760
|
+
await workspace.spawn(`docker`, ["compose", "up", "-d"], {
|
|
4761
|
+
cwd: `${workspace.workspaceRoot}/local`,
|
|
4762
|
+
stdio: "ignore"
|
|
4763
|
+
});
|
|
4707
4764
|
}
|
|
4708
4765
|
async dbdown(workspace) {
|
|
4709
|
-
await workspace.spawn(`docker`, ["compose", "down"], { cwd: `${workspace.workspaceRoot}/local
|
|
4766
|
+
await workspace.spawn(`docker`, ["compose", "down"], { cwd: `${workspace.workspaceRoot}/local`, stdio: "ignore" });
|
|
4710
4767
|
}
|
|
4711
4768
|
async configureApp(app) {
|
|
4712
4769
|
const capacitorApp = new CapacitorApp(app);
|
|
@@ -4866,7 +4923,7 @@ var ApplicationRunner = class {
|
|
|
4866
4923
|
const chatModel = new import_openai3.ChatOpenAI({ modelName: "gpt-4o", openAIApiKey });
|
|
4867
4924
|
const projectName = await (0, import_prompts5.input)({ message: "please enter project name." });
|
|
4868
4925
|
const projectDesc = await (0, import_prompts5.input)({ message: "please enter project description. (40 ~ 60 characters)" });
|
|
4869
|
-
const spinner = (0,
|
|
4926
|
+
const spinner = (0, import_ora4.default)("Gerating project files...");
|
|
4870
4927
|
const mainPrompt = import_prompts6.PromptTemplate.fromTemplate(requestApplication());
|
|
4871
4928
|
const chain = import_runnables2.RunnableSequence.from([mainPrompt, chatModel, new import_output_parsers.StringOutputParser()]);
|
|
4872
4929
|
const resultOne = await chain.invoke({ projectName, projectDesc });
|
|
@@ -4913,16 +4970,13 @@ var ApplicationScript = class {
|
|
|
4913
4970
|
async removeApplication(app) {
|
|
4914
4971
|
await this.#runner.removeApplication(app);
|
|
4915
4972
|
}
|
|
4916
|
-
async
|
|
4973
|
+
async syncApplication(app, verbose = false) {
|
|
4974
|
+
const spinner = app.spinning("Scanning application...");
|
|
4917
4975
|
const akanConfig = await this.#runner.getConfig(app);
|
|
4918
4976
|
const scanResult = await this.#runner.scanSync(app, akanConfig);
|
|
4919
4977
|
if (verbose)
|
|
4920
4978
|
app.logger.rawLog(JSON.stringify(scanResult, null, 2));
|
|
4921
|
-
|
|
4922
|
-
}
|
|
4923
|
-
async syncApplication(app) {
|
|
4924
|
-
const akanConfig = await this.#runner.getConfig(app);
|
|
4925
|
-
const scanResult = await this.#runner.scanSync(app, akanConfig);
|
|
4979
|
+
spinner.succeed("Application scanned");
|
|
4926
4980
|
return scanResult;
|
|
4927
4981
|
}
|
|
4928
4982
|
async build(app) {
|
|
@@ -4938,7 +4992,9 @@ var ApplicationScript = class {
|
|
|
4938
4992
|
async buildBackend(app, { sync = true } = {}) {
|
|
4939
4993
|
if (sync)
|
|
4940
4994
|
await this.syncApplication(app);
|
|
4995
|
+
const spinner = app.spinning("Building backend...");
|
|
4941
4996
|
await this.#runner.buildBackend(app);
|
|
4997
|
+
spinner.succeed(`Successfully built in dist/apps/${app.name}/backend`);
|
|
4942
4998
|
}
|
|
4943
4999
|
async startBackend(app, { open: open2 = false, sync = true } = {}) {
|
|
4944
5000
|
if (sync)
|
|
@@ -4948,7 +5004,9 @@ var ApplicationScript = class {
|
|
|
4948
5004
|
async buildFrontend(app, { sync = true } = {}) {
|
|
4949
5005
|
if (sync)
|
|
4950
5006
|
await this.syncApplication(app);
|
|
5007
|
+
const spinner = app.spinning("Building frontend...");
|
|
4951
5008
|
await this.#runner.buildFrontend(app);
|
|
5009
|
+
spinner.succeed(`Successfully built in dist/apps/${app.name}/frontend`);
|
|
4952
5010
|
}
|
|
4953
5011
|
async startFrontend(app, { open: open2 = false, turbo = false, sync = true } = {}) {
|
|
4954
5012
|
if (sync)
|
|
@@ -4958,7 +5016,9 @@ var ApplicationScript = class {
|
|
|
4958
5016
|
async buildCsr(app, { sync = true } = {}) {
|
|
4959
5017
|
if (sync)
|
|
4960
5018
|
await this.syncApplication(app);
|
|
5019
|
+
const spinner = app.spinning("Building CSR...");
|
|
4961
5020
|
await this.#runner.buildCsr(app);
|
|
5021
|
+
spinner.succeed(`Successfully built in dist/apps/${app.name}/csr`);
|
|
4962
5022
|
}
|
|
4963
5023
|
async startCsr(app, { open: open2 = false, sync = true } = {}) {
|
|
4964
5024
|
if (sync)
|
|
@@ -5022,10 +5082,16 @@ var ApplicationScript = class {
|
|
|
5022
5082
|
await this.#runner.releaseSource(app, options);
|
|
5023
5083
|
}
|
|
5024
5084
|
async dbup(workspace) {
|
|
5085
|
+
const spinner = workspace.spinning("Starting local database...");
|
|
5025
5086
|
await this.#runner.dbup(workspace);
|
|
5087
|
+
spinner.succeed(
|
|
5088
|
+
"Local database(/local/docker-compose.yaml) is up, you can start your application and connect to the database"
|
|
5089
|
+
);
|
|
5026
5090
|
}
|
|
5027
5091
|
async dbdown(workspace) {
|
|
5092
|
+
const spinner = workspace.spinning("Stopping local database...");
|
|
5028
5093
|
await this.#runner.dbdown(workspace);
|
|
5094
|
+
spinner.succeed("Local database(/local/docker-compose.yaml) is down");
|
|
5029
5095
|
}
|
|
5030
5096
|
async testSys(sys2) {
|
|
5031
5097
|
if (sys2.type === "app")
|
|
@@ -5047,8 +5113,8 @@ var ApplicationCommand = class {
|
|
|
5047
5113
|
async removeApplication(app) {
|
|
5048
5114
|
await this.applicationScript.removeApplication(app);
|
|
5049
5115
|
}
|
|
5050
|
-
async
|
|
5051
|
-
await this.applicationScript.
|
|
5116
|
+
async syncApplication(app, verbose) {
|
|
5117
|
+
await this.applicationScript.syncApplication(app, verbose);
|
|
5052
5118
|
}
|
|
5053
5119
|
async build(app) {
|
|
5054
5120
|
await this.applicationScript.build(app);
|
|
@@ -5129,8 +5195,9 @@ __decorateClass([
|
|
|
5129
5195
|
], ApplicationCommand.prototype, "removeApplication", 1);
|
|
5130
5196
|
__decorateClass([
|
|
5131
5197
|
Target.Public(),
|
|
5132
|
-
__decorateParam(0, App())
|
|
5133
|
-
|
|
5198
|
+
__decorateParam(0, App()),
|
|
5199
|
+
__decorateParam(1, Option("verbose", { type: "boolean", desc: "verbose", default: false }))
|
|
5200
|
+
], ApplicationCommand.prototype, "syncApplication", 1);
|
|
5134
5201
|
__decorateClass([
|
|
5135
5202
|
Target.Public({ short: true }),
|
|
5136
5203
|
__decorateParam(0, App())
|
|
@@ -5610,11 +5677,19 @@ var ModuleRunner = class {
|
|
|
5610
5677
|
async createScalarTemplate(sys2, name) {
|
|
5611
5678
|
const akanConfig = await sys2.getConfig();
|
|
5612
5679
|
const scanResult = await sys2.scan({ akanConfig });
|
|
5680
|
+
const names = (0, import_pluralize.default)(name);
|
|
5613
5681
|
await sys2.applyTemplate({
|
|
5614
5682
|
basePath: "./lib/__scalar",
|
|
5615
5683
|
template: "__scalar",
|
|
5616
5684
|
scanResult,
|
|
5617
|
-
dict: {
|
|
5685
|
+
dict: {
|
|
5686
|
+
model: name,
|
|
5687
|
+
Model: capitalize(name),
|
|
5688
|
+
models: names,
|
|
5689
|
+
Models: capitalize(names),
|
|
5690
|
+
sysName: sys2.name,
|
|
5691
|
+
SysName: capitalize(sys2.name)
|
|
5692
|
+
}
|
|
5618
5693
|
});
|
|
5619
5694
|
await sys2.scan({ akanConfig });
|
|
5620
5695
|
return {
|
|
@@ -5653,11 +5728,19 @@ var ModuleRunner = class {
|
|
|
5653
5728
|
async createModuleTemplate(sys2, name) {
|
|
5654
5729
|
const akanConfig = await sys2.getConfig();
|
|
5655
5730
|
const scanResult = await sys2.scan({ akanConfig });
|
|
5731
|
+
const names = (0, import_pluralize.default)(name);
|
|
5656
5732
|
await sys2.applyTemplate({
|
|
5657
5733
|
basePath: `./lib/${name}`,
|
|
5658
5734
|
template: "module",
|
|
5659
5735
|
scanResult,
|
|
5660
|
-
dict: {
|
|
5736
|
+
dict: {
|
|
5737
|
+
model: name,
|
|
5738
|
+
Model: capitalize(name),
|
|
5739
|
+
models: names,
|
|
5740
|
+
Models: capitalize(names),
|
|
5741
|
+
sysName: sys2.name,
|
|
5742
|
+
SysName: capitalize(sys2.name)
|
|
5743
|
+
}
|
|
5661
5744
|
});
|
|
5662
5745
|
await sys2.scan({ akanConfig });
|
|
5663
5746
|
return {
|
|
@@ -26,6 +26,7 @@ function getContent(scanResult, dict) {
|
|
|
26
26
|
return {
|
|
27
27
|
filename: "layout.tsx",
|
|
28
28
|
content: `
|
|
29
|
+
import "../(${dict.appName})/styles.css";
|
|
29
30
|
import { System } from "@shared/ui";
|
|
30
31
|
import { env } from "@${dict.appName}/env/env.client";
|
|
31
32
|
import { fetch } from "@${dict.appName}/client";
|
package/esm/index.js
CHANGED
|
@@ -901,11 +901,58 @@ var TypeScriptDependencyScanner = class {
|
|
|
901
901
|
}
|
|
902
902
|
};
|
|
903
903
|
|
|
904
|
+
// pkgs/@akanjs/devkit/src/spinner.ts
|
|
905
|
+
import ora2 from "ora";
|
|
906
|
+
var Spinner = class {
|
|
907
|
+
spinner;
|
|
908
|
+
stopWatch;
|
|
909
|
+
startAt;
|
|
910
|
+
message;
|
|
911
|
+
constructor(message, { prefix = "", indent = 0 } = {}) {
|
|
912
|
+
this.message = message;
|
|
913
|
+
this.spinner = ora2(message);
|
|
914
|
+
this.spinner.prefixText = prefix;
|
|
915
|
+
this.spinner.indent = indent;
|
|
916
|
+
}
|
|
917
|
+
start() {
|
|
918
|
+
this.startAt = /* @__PURE__ */ new Date();
|
|
919
|
+
const spinner = this.spinner.start();
|
|
920
|
+
this.stopWatch = setInterval(() => {
|
|
921
|
+
spinner.text = `${this.message} (${this.#getElapsedTimeStr()})`;
|
|
922
|
+
}, 1e3);
|
|
923
|
+
return this;
|
|
924
|
+
}
|
|
925
|
+
succeed(message) {
|
|
926
|
+
clearInterval(this.stopWatch);
|
|
927
|
+
this.spinner.succeed(`${message} (${this.#getElapsedTimeStr()})`);
|
|
928
|
+
}
|
|
929
|
+
#getElapsedTimeStr() {
|
|
930
|
+
const ms = (/* @__PURE__ */ new Date()).getTime() - this.startAt.getTime();
|
|
931
|
+
if (ms < 1e3)
|
|
932
|
+
return `${ms}ms`;
|
|
933
|
+
const s = Math.floor(ms / 1e3);
|
|
934
|
+
if (s < 60)
|
|
935
|
+
return `${s}s`;
|
|
936
|
+
const m = Math.floor(s / 60);
|
|
937
|
+
return `${m}m ${s % 60}s`;
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
|
|
904
941
|
// pkgs/@akanjs/devkit/src/executors.ts
|
|
942
|
+
var execEmoji = {
|
|
943
|
+
workspace: "\u{1F3E0}",
|
|
944
|
+
app: "\u{1F680}",
|
|
945
|
+
lib: "\u{1F527}",
|
|
946
|
+
pkg: "\u{1F4E6}",
|
|
947
|
+
dist: "\u{1F4BF}",
|
|
948
|
+
default: "\u2708\uFE0F"
|
|
949
|
+
// for sys executor
|
|
950
|
+
};
|
|
905
951
|
var Executor = class {
|
|
906
952
|
name;
|
|
907
953
|
logger;
|
|
908
954
|
cwdPath;
|
|
955
|
+
emoji = execEmoji.default;
|
|
909
956
|
constructor(name, cwdPath) {
|
|
910
957
|
this.name = name;
|
|
911
958
|
this.logger = new Logger(name);
|
|
@@ -1032,6 +1079,9 @@ var Executor = class {
|
|
|
1032
1079
|
this.logger.verbose(msg);
|
|
1033
1080
|
return this;
|
|
1034
1081
|
}
|
|
1082
|
+
spinning(msg, { prefix = `${this.emoji}${this.name} -`, indent = 0 } = {}) {
|
|
1083
|
+
return new Spinner(msg, { prefix, indent }).start();
|
|
1084
|
+
}
|
|
1035
1085
|
getTsConfig(pathname = "tsconfig.json") {
|
|
1036
1086
|
const tsconfig = this.readJson(pathname);
|
|
1037
1087
|
if (tsconfig.extends) {
|
|
@@ -1118,8 +1168,9 @@ var Executor = class {
|
|
|
1118
1168
|
var WorkspaceExecutor = class _WorkspaceExecutor extends Executor {
|
|
1119
1169
|
workspaceRoot;
|
|
1120
1170
|
repoName;
|
|
1171
|
+
emoji = execEmoji.workspace;
|
|
1121
1172
|
constructor({ workspaceRoot, repoName }) {
|
|
1122
|
-
super(
|
|
1173
|
+
super("workspace", workspaceRoot);
|
|
1123
1174
|
this.workspaceRoot = workspaceRoot;
|
|
1124
1175
|
this.repoName = repoName;
|
|
1125
1176
|
}
|
|
@@ -1274,11 +1325,13 @@ var SysExecutor = class extends Executor {
|
|
|
1274
1325
|
workspace;
|
|
1275
1326
|
name;
|
|
1276
1327
|
type;
|
|
1328
|
+
emoji;
|
|
1277
1329
|
constructor({ workspace = WorkspaceExecutor.fromRoot(), name, type }) {
|
|
1278
|
-
super(
|
|
1330
|
+
super(name, `${workspace.workspaceRoot}/${type}s/${name}`);
|
|
1279
1331
|
this.workspace = workspace;
|
|
1280
1332
|
this.name = name;
|
|
1281
1333
|
this.type = type;
|
|
1334
|
+
this.emoji = execEmoji[type];
|
|
1282
1335
|
}
|
|
1283
1336
|
async getConfig(command) {
|
|
1284
1337
|
return this.type === "app" ? await getAppConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "app", name: this.name, command }) : await getLibConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "lib", name: this.name, command });
|
|
@@ -1499,9 +1552,10 @@ var SysExecutor = class extends Executor {
|
|
|
1499
1552
|
};
|
|
1500
1553
|
var AppExecutor = class _AppExecutor extends SysExecutor {
|
|
1501
1554
|
dist;
|
|
1555
|
+
emoji = execEmoji.app;
|
|
1502
1556
|
constructor({ workspace, name }) {
|
|
1503
1557
|
super({ workspace, name, type: "app" });
|
|
1504
|
-
this.dist = new Executor(
|
|
1558
|
+
this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/apps/${name}`);
|
|
1505
1559
|
}
|
|
1506
1560
|
static from(executor, name) {
|
|
1507
1561
|
if (executor instanceof WorkspaceExecutor)
|
|
@@ -1535,9 +1589,10 @@ var LibExecutor = class _LibExecutor extends SysExecutor {
|
|
|
1535
1589
|
workspaceRoot;
|
|
1536
1590
|
repoName;
|
|
1537
1591
|
dist;
|
|
1592
|
+
emoji = execEmoji.lib;
|
|
1538
1593
|
constructor({ workspace, name }) {
|
|
1539
1594
|
super({ workspace, name, type: "lib" });
|
|
1540
|
-
this.dist = new Executor(
|
|
1595
|
+
this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/libs/${name}`);
|
|
1541
1596
|
}
|
|
1542
1597
|
static from(executor, name) {
|
|
1543
1598
|
if (executor instanceof WorkspaceExecutor)
|
|
@@ -1557,11 +1612,12 @@ var PkgExecutor = class _PkgExecutor extends Executor {
|
|
|
1557
1612
|
workspace;
|
|
1558
1613
|
name;
|
|
1559
1614
|
dist;
|
|
1615
|
+
emoji = execEmoji.pkg;
|
|
1560
1616
|
constructor({ workspace = WorkspaceExecutor.fromRoot(), name }) {
|
|
1561
|
-
super(
|
|
1617
|
+
super(name, `${workspace.workspaceRoot}/pkgs/${name}`);
|
|
1562
1618
|
this.workspace = workspace;
|
|
1563
1619
|
this.name = name;
|
|
1564
|
-
this.dist = new Executor(
|
|
1620
|
+
this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/pkgs/${name}`);
|
|
1565
1621
|
}
|
|
1566
1622
|
static from(executor, name) {
|
|
1567
1623
|
if (executor instanceof WorkspaceExecutor)
|
|
@@ -2161,10 +2217,10 @@ var runCommands = async (...commands) => {
|
|
|
2161
2217
|
|
|
2162
2218
|
// pkgs/@akanjs/devkit/src/aiEditor.ts
|
|
2163
2219
|
import { input as input2, select as select3 } from "@inquirer/prompts";
|
|
2164
|
-
import ora2 from "ora";
|
|
2165
2220
|
import { AIMessage, HumanMessage } from "@langchain/core/messages";
|
|
2166
2221
|
import { ChatOpenAI as ChatOpenAI2 } from "@langchain/openai";
|
|
2167
2222
|
import chalk3 from "chalk";
|
|
2223
|
+
import ora3 from "ora";
|
|
2168
2224
|
var MAX_ASK_TRY = 300;
|
|
2169
2225
|
var supportedLlmModels = ["deepseek-chat", "deepseek-reasoner"];
|
|
2170
2226
|
var AiSession = class _AiSession {
|
|
@@ -2235,7 +2291,7 @@ var AiSession = class _AiSession {
|
|
|
2235
2291
|
await _AiSession.init();
|
|
2236
2292
|
if (!_AiSession.#chat)
|
|
2237
2293
|
throw new Error("Failed to initialize the AI session");
|
|
2238
|
-
const loader =
|
|
2294
|
+
const loader = ora3(`${_AiSession.#chat.model} is thinking...`).start();
|
|
2239
2295
|
try {
|
|
2240
2296
|
const humanMessage = new HumanMessage(question);
|
|
2241
2297
|
this.messageHistory.push(humanMessage);
|
|
@@ -2510,7 +2566,7 @@ import fs11 from "fs";
|
|
|
2510
2566
|
import fsPromise2 from "fs/promises";
|
|
2511
2567
|
import yaml2 from "js-yaml";
|
|
2512
2568
|
import openBrowser from "open";
|
|
2513
|
-
import
|
|
2569
|
+
import ora4 from "ora";
|
|
2514
2570
|
import path5 from "path";
|
|
2515
2571
|
import * as vite from "vite";
|
|
2516
2572
|
import commonjs from "vite-plugin-commonjs";
|
|
@@ -4502,7 +4558,7 @@ var ApplicationRunner = class {
|
|
|
4502
4558
|
async buildFrontend(app) {
|
|
4503
4559
|
const { env } = await this.#prepareCommand(app, "build", "frontend");
|
|
4504
4560
|
const akanConfig = await app.getConfig("build");
|
|
4505
|
-
await app.spawn("npx", ["next", "build", "--no-lint"], { env });
|
|
4561
|
+
await app.spawn("npx", ["next", "build", "--no-lint"], { env, stdio: "ignore" });
|
|
4506
4562
|
const buildResult = await esbuild2.build({
|
|
4507
4563
|
entryPoints: [`${app.cwdPath}/next.config.ts`],
|
|
4508
4564
|
outdir: `${app.dist.cwdPath}/frontend`,
|
|
@@ -4523,9 +4579,7 @@ var ApplicationRunner = class {
|
|
|
4523
4579
|
version: "1.0.0",
|
|
4524
4580
|
engines: { node: ">=22" },
|
|
4525
4581
|
dependencies,
|
|
4526
|
-
scripts: {
|
|
4527
|
-
start: "next start"
|
|
4528
|
-
}
|
|
4582
|
+
scripts: { start: "next start" }
|
|
4529
4583
|
};
|
|
4530
4584
|
app.dist.writeJson("frontend/package.json", appPackageJson);
|
|
4531
4585
|
await Promise.all([
|
|
@@ -4690,10 +4744,13 @@ var ApplicationRunner = class {
|
|
|
4690
4744
|
dict: { repoName: workspace.repoName },
|
|
4691
4745
|
overwrite: false
|
|
4692
4746
|
});
|
|
4693
|
-
await workspace.spawn(`docker`, ["compose", "up", "-d"], {
|
|
4747
|
+
await workspace.spawn(`docker`, ["compose", "up", "-d"], {
|
|
4748
|
+
cwd: `${workspace.workspaceRoot}/local`,
|
|
4749
|
+
stdio: "ignore"
|
|
4750
|
+
});
|
|
4694
4751
|
}
|
|
4695
4752
|
async dbdown(workspace) {
|
|
4696
|
-
await workspace.spawn(`docker`, ["compose", "down"], { cwd: `${workspace.workspaceRoot}/local
|
|
4753
|
+
await workspace.spawn(`docker`, ["compose", "down"], { cwd: `${workspace.workspaceRoot}/local`, stdio: "ignore" });
|
|
4697
4754
|
}
|
|
4698
4755
|
async configureApp(app) {
|
|
4699
4756
|
const capacitorApp = new CapacitorApp(app);
|
|
@@ -4853,7 +4910,7 @@ var ApplicationRunner = class {
|
|
|
4853
4910
|
const chatModel = new ChatOpenAI3({ modelName: "gpt-4o", openAIApiKey });
|
|
4854
4911
|
const projectName = await input3({ message: "please enter project name." });
|
|
4855
4912
|
const projectDesc = await input3({ message: "please enter project description. (40 ~ 60 characters)" });
|
|
4856
|
-
const spinner =
|
|
4913
|
+
const spinner = ora4("Gerating project files...");
|
|
4857
4914
|
const mainPrompt = PromptTemplate2.fromTemplate(requestApplication());
|
|
4858
4915
|
const chain = RunnableSequence2.from([mainPrompt, chatModel, new StringOutputParser()]);
|
|
4859
4916
|
const resultOne = await chain.invoke({ projectName, projectDesc });
|
|
@@ -4900,16 +4957,13 @@ var ApplicationScript = class {
|
|
|
4900
4957
|
async removeApplication(app) {
|
|
4901
4958
|
await this.#runner.removeApplication(app);
|
|
4902
4959
|
}
|
|
4903
|
-
async
|
|
4960
|
+
async syncApplication(app, verbose = false) {
|
|
4961
|
+
const spinner = app.spinning("Scanning application...");
|
|
4904
4962
|
const akanConfig = await this.#runner.getConfig(app);
|
|
4905
4963
|
const scanResult = await this.#runner.scanSync(app, akanConfig);
|
|
4906
4964
|
if (verbose)
|
|
4907
4965
|
app.logger.rawLog(JSON.stringify(scanResult, null, 2));
|
|
4908
|
-
|
|
4909
|
-
}
|
|
4910
|
-
async syncApplication(app) {
|
|
4911
|
-
const akanConfig = await this.#runner.getConfig(app);
|
|
4912
|
-
const scanResult = await this.#runner.scanSync(app, akanConfig);
|
|
4966
|
+
spinner.succeed("Application scanned");
|
|
4913
4967
|
return scanResult;
|
|
4914
4968
|
}
|
|
4915
4969
|
async build(app) {
|
|
@@ -4925,7 +4979,9 @@ var ApplicationScript = class {
|
|
|
4925
4979
|
async buildBackend(app, { sync = true } = {}) {
|
|
4926
4980
|
if (sync)
|
|
4927
4981
|
await this.syncApplication(app);
|
|
4982
|
+
const spinner = app.spinning("Building backend...");
|
|
4928
4983
|
await this.#runner.buildBackend(app);
|
|
4984
|
+
spinner.succeed(`Successfully built in dist/apps/${app.name}/backend`);
|
|
4929
4985
|
}
|
|
4930
4986
|
async startBackend(app, { open: open2 = false, sync = true } = {}) {
|
|
4931
4987
|
if (sync)
|
|
@@ -4935,7 +4991,9 @@ var ApplicationScript = class {
|
|
|
4935
4991
|
async buildFrontend(app, { sync = true } = {}) {
|
|
4936
4992
|
if (sync)
|
|
4937
4993
|
await this.syncApplication(app);
|
|
4994
|
+
const spinner = app.spinning("Building frontend...");
|
|
4938
4995
|
await this.#runner.buildFrontend(app);
|
|
4996
|
+
spinner.succeed(`Successfully built in dist/apps/${app.name}/frontend`);
|
|
4939
4997
|
}
|
|
4940
4998
|
async startFrontend(app, { open: open2 = false, turbo = false, sync = true } = {}) {
|
|
4941
4999
|
if (sync)
|
|
@@ -4945,7 +5003,9 @@ var ApplicationScript = class {
|
|
|
4945
5003
|
async buildCsr(app, { sync = true } = {}) {
|
|
4946
5004
|
if (sync)
|
|
4947
5005
|
await this.syncApplication(app);
|
|
5006
|
+
const spinner = app.spinning("Building CSR...");
|
|
4948
5007
|
await this.#runner.buildCsr(app);
|
|
5008
|
+
spinner.succeed(`Successfully built in dist/apps/${app.name}/csr`);
|
|
4949
5009
|
}
|
|
4950
5010
|
async startCsr(app, { open: open2 = false, sync = true } = {}) {
|
|
4951
5011
|
if (sync)
|
|
@@ -5009,10 +5069,16 @@ var ApplicationScript = class {
|
|
|
5009
5069
|
await this.#runner.releaseSource(app, options);
|
|
5010
5070
|
}
|
|
5011
5071
|
async dbup(workspace) {
|
|
5072
|
+
const spinner = workspace.spinning("Starting local database...");
|
|
5012
5073
|
await this.#runner.dbup(workspace);
|
|
5074
|
+
spinner.succeed(
|
|
5075
|
+
"Local database(/local/docker-compose.yaml) is up, you can start your application and connect to the database"
|
|
5076
|
+
);
|
|
5013
5077
|
}
|
|
5014
5078
|
async dbdown(workspace) {
|
|
5079
|
+
const spinner = workspace.spinning("Stopping local database...");
|
|
5015
5080
|
await this.#runner.dbdown(workspace);
|
|
5081
|
+
spinner.succeed("Local database(/local/docker-compose.yaml) is down");
|
|
5016
5082
|
}
|
|
5017
5083
|
async testSys(sys2) {
|
|
5018
5084
|
if (sys2.type === "app")
|
|
@@ -5034,8 +5100,8 @@ var ApplicationCommand = class {
|
|
|
5034
5100
|
async removeApplication(app) {
|
|
5035
5101
|
await this.applicationScript.removeApplication(app);
|
|
5036
5102
|
}
|
|
5037
|
-
async
|
|
5038
|
-
await this.applicationScript.
|
|
5103
|
+
async syncApplication(app, verbose) {
|
|
5104
|
+
await this.applicationScript.syncApplication(app, verbose);
|
|
5039
5105
|
}
|
|
5040
5106
|
async build(app) {
|
|
5041
5107
|
await this.applicationScript.build(app);
|
|
@@ -5116,8 +5182,9 @@ __decorateClass([
|
|
|
5116
5182
|
], ApplicationCommand.prototype, "removeApplication", 1);
|
|
5117
5183
|
__decorateClass([
|
|
5118
5184
|
Target.Public(),
|
|
5119
|
-
__decorateParam(0, App())
|
|
5120
|
-
|
|
5185
|
+
__decorateParam(0, App()),
|
|
5186
|
+
__decorateParam(1, Option("verbose", { type: "boolean", desc: "verbose", default: false }))
|
|
5187
|
+
], ApplicationCommand.prototype, "syncApplication", 1);
|
|
5121
5188
|
__decorateClass([
|
|
5122
5189
|
Target.Public({ short: true }),
|
|
5123
5190
|
__decorateParam(0, App())
|
|
@@ -5597,11 +5664,19 @@ var ModuleRunner = class {
|
|
|
5597
5664
|
async createScalarTemplate(sys2, name) {
|
|
5598
5665
|
const akanConfig = await sys2.getConfig();
|
|
5599
5666
|
const scanResult = await sys2.scan({ akanConfig });
|
|
5667
|
+
const names = pluralize(name);
|
|
5600
5668
|
await sys2.applyTemplate({
|
|
5601
5669
|
basePath: "./lib/__scalar",
|
|
5602
5670
|
template: "__scalar",
|
|
5603
5671
|
scanResult,
|
|
5604
|
-
dict: {
|
|
5672
|
+
dict: {
|
|
5673
|
+
model: name,
|
|
5674
|
+
Model: capitalize(name),
|
|
5675
|
+
models: names,
|
|
5676
|
+
Models: capitalize(names),
|
|
5677
|
+
sysName: sys2.name,
|
|
5678
|
+
SysName: capitalize(sys2.name)
|
|
5679
|
+
}
|
|
5605
5680
|
});
|
|
5606
5681
|
await sys2.scan({ akanConfig });
|
|
5607
5682
|
return {
|
|
@@ -5640,11 +5715,19 @@ var ModuleRunner = class {
|
|
|
5640
5715
|
async createModuleTemplate(sys2, name) {
|
|
5641
5716
|
const akanConfig = await sys2.getConfig();
|
|
5642
5717
|
const scanResult = await sys2.scan({ akanConfig });
|
|
5718
|
+
const names = pluralize(name);
|
|
5643
5719
|
await sys2.applyTemplate({
|
|
5644
5720
|
basePath: `./lib/${name}`,
|
|
5645
5721
|
template: "module",
|
|
5646
5722
|
scanResult,
|
|
5647
|
-
dict: {
|
|
5723
|
+
dict: {
|
|
5724
|
+
model: name,
|
|
5725
|
+
Model: capitalize(name),
|
|
5726
|
+
models: names,
|
|
5727
|
+
Models: capitalize(names),
|
|
5728
|
+
sysName: sys2.name,
|
|
5729
|
+
SysName: capitalize(sys2.name)
|
|
5730
|
+
}
|
|
5648
5731
|
});
|
|
5649
5732
|
await sys2.scan({ akanConfig });
|
|
5650
5733
|
return {
|
|
@@ -3,6 +3,7 @@ function getContent(scanResult, dict) {
|
|
|
3
3
|
return {
|
|
4
4
|
filename: "layout.tsx",
|
|
5
5
|
content: `
|
|
6
|
+
import "../(${dict.appName})/styles.css";
|
|
6
7
|
import { System } from "@shared/ui";
|
|
7
8
|
import { env } from "@${dict.appName}/env/env.client";
|
|
8
9
|
import { fetch } from "@${dict.appName}/client";
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ export declare class ApplicationCommand {
|
|
|
4
4
|
applicationScript: ApplicationScript;
|
|
5
5
|
createApplication(name: string, start: boolean, workspace: Workspace): Promise<void>;
|
|
6
6
|
removeApplication(app: App): Promise<void>;
|
|
7
|
-
|
|
7
|
+
syncApplication(app: App, verbose: boolean): Promise<void>;
|
|
8
8
|
build(app: App): Promise<void>;
|
|
9
9
|
buildBackend(app: App): Promise<void>;
|
|
10
10
|
buildFrontend(app: App): Promise<void>;
|
|
@@ -8,8 +8,7 @@ export declare class ApplicationScript {
|
|
|
8
8
|
start?: boolean;
|
|
9
9
|
}): Promise<void>;
|
|
10
10
|
removeApplication(app: App): Promise<void>;
|
|
11
|
-
|
|
12
|
-
syncApplication(app: App): Promise<import("@akanjs/config").AppScanResult | import("@akanjs/config").LibScanResult>;
|
|
11
|
+
syncApplication(app: App, verbose?: boolean): Promise<import("@akanjs/config").AppScanResult | import("@akanjs/config").LibScanResult>;
|
|
13
12
|
build(app: App): Promise<void>;
|
|
14
13
|
start(app: App, { open }?: {
|
|
15
14
|
open?: boolean;
|