@akanjs/cli 0.9.60-canary.0 → 0.9.60-canary.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/cjs/index.js +109 -62
- package/cjs/src/templates/__scalar/__model__/__model__.dictionary.js +6 -13
- package/cjs/src/templates/app/akan.config.js +2 -4
- package/cjs/src/templates/env/{env.server.type.js → _env.server.type.js} +6 -3
- package/cjs/src/templates/lib/__lib/lib.constant.js +1 -1
- package/cjs/src/templates/lib/__lib/lib.dictionary.js +1 -1
- package/cjs/src/templates/libRoot/akan.config.js +1 -3
- package/cjs/src/templates/module/__model__.dictionary.js +0 -1
- package/esm/index.js +109 -62
- package/esm/src/templates/__scalar/__model__/__model__.dictionary.js +6 -13
- package/esm/src/templates/app/akan.config.js +2 -4
- package/esm/src/templates/env/{env.server.type.js → _env.server.type.js} +6 -3
- package/esm/src/templates/lib/__lib/lib.constant.js +1 -1
- package/esm/src/templates/lib/__lib/lib.dictionary.js +1 -1
- package/esm/src/templates/libRoot/akan.config.js +1 -3
- package/esm/src/templates/module/__model__.dictionary.js +0 -1
- package/package.json +2 -1
- package/src/scalar/scalar.command.d.ts +2 -2
- package/src/scalar/scalar.runner.d.ts +1 -0
- package/src/scalar/scalar.script.d.ts +1 -0
- package/src/templates/app/akan.config.d.ts +1 -3
- package/src/templates/env/{env.server.type.d.ts → _env.server.type.d.ts} +4 -1
- package/src/workspace/workspace.command.d.ts +1 -1
- package/src/workspace/workspace.runner.d.ts +4 -1
- package/src/workspace/workspace.script.d.ts +5 -1
- package/cjs/src/templates/module/__model__.signal.spec.js +0 -27
- package/cjs/src/templates/module/__model__.signal.test.js +0 -27
- package/esm/src/templates/module/__model__.signal.spec.js +0 -7
- package/esm/src/templates/module/__model__.signal.test.js +0 -7
- package/src/templates/module/__model__.signal.spec.d.ts +0 -8
- package/src/templates/module/__model__.signal.test.d.ts +0 -8
package/esm/index.js
CHANGED
|
@@ -573,7 +573,7 @@ var composePlugins = (...plugins) => {
|
|
|
573
573
|
};
|
|
574
574
|
var commandType = process.env.AKAN_COMMAND_TYPE?.includes("start") ? "start" : process.env.AKAN_COMMAND_TYPE?.includes("build") ? "build" : "deploy";
|
|
575
575
|
var devDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "akanjs.com";
|
|
576
|
-
var withBase = (appName, config,
|
|
576
|
+
var withBase = (appName, config, optimizeLibs, routes = []) => {
|
|
577
577
|
const withPWA = pwa({
|
|
578
578
|
dest: "public",
|
|
579
579
|
register: true,
|
|
@@ -597,8 +597,7 @@ var withBase = (appName, config, libs, routes = []) => {
|
|
|
597
597
|
experimental: {
|
|
598
598
|
...config.experimental ?? {},
|
|
599
599
|
optimizePackageImports: [
|
|
600
|
-
...[appName, ...
|
|
601
|
-
"@contract",
|
|
600
|
+
...[appName, ...optimizeLibs].map((lib) => [`@${lib}/ui`, `@${lib}/next`, `@${lib}/common`, `@${lib}/client`]).flat(),
|
|
602
601
|
"@akanjs/next",
|
|
603
602
|
"@akanjs/common",
|
|
604
603
|
"@akanjs/ui"
|
|
@@ -619,7 +618,7 @@ var withBase = (appName, config, libs, routes = []) => {
|
|
|
619
618
|
},
|
|
620
619
|
webpack: (config2) => {
|
|
621
620
|
const watchOptions = config2.watchOptions;
|
|
622
|
-
const ignored = watchOptions?.ignored ? typeof watchOptions.ignored === "string" ? [watchOptions.ignored] : Array.isArray(watchOptions.ignored) ? watchOptions.ignored.filter((
|
|
621
|
+
const ignored = watchOptions?.ignored ? typeof watchOptions.ignored === "string" ? [watchOptions.ignored] : Array.isArray(watchOptions.ignored) ? watchOptions.ignored.filter((ignore2) => typeof ignore2 === "string") : [] : [];
|
|
623
622
|
config2.watchOptions = {
|
|
624
623
|
...config2.watchOptions ?? {},
|
|
625
624
|
...{ ignored: [...ignored, "**/node_modules/**", "**/.git/**", "**/.next/**", "**/dist/**", "**/local/**"] }
|
|
@@ -687,10 +686,9 @@ export default getNextConfig(config, appInfo);
|
|
|
687
686
|
var archs = ["amd64", "arm64"];
|
|
688
687
|
|
|
689
688
|
// pkgs/@akanjs/config/src/akanConfig.ts
|
|
690
|
-
var makeAppConfig = (config, props) => {
|
|
689
|
+
var makeAppConfig = (config, props, optimizeLibs) => {
|
|
691
690
|
const { name, repoName } = props;
|
|
692
691
|
return {
|
|
693
|
-
libs: config.libs ?? [],
|
|
694
692
|
backend: {
|
|
695
693
|
docker: makeDockerfile("backend", config.backend?.docker ?? {}, props),
|
|
696
694
|
explicitDependencies: config.backend?.explicitDependencies ?? []
|
|
@@ -700,7 +698,7 @@ var makeAppConfig = (config, props) => {
|
|
|
700
698
|
nextConfig: withBase(
|
|
701
699
|
name,
|
|
702
700
|
config.frontend?.nextConfig ? typeof config.frontend.nextConfig === "function" ? config.frontend.nextConfig() : config.frontend.nextConfig : {},
|
|
703
|
-
|
|
701
|
+
optimizeLibs,
|
|
704
702
|
config.frontend?.routes
|
|
705
703
|
),
|
|
706
704
|
routes: config.frontend?.routes,
|
|
@@ -716,7 +714,7 @@ var makeAppConfig = (config, props) => {
|
|
|
716
714
|
}
|
|
717
715
|
};
|
|
718
716
|
};
|
|
719
|
-
var getAppConfig = async (appRoot, props) => {
|
|
717
|
+
var getAppConfig = async (appRoot, props, tsconfig) => {
|
|
720
718
|
const akanConfigPath = path.join(appRoot, "akan.config.ts");
|
|
721
719
|
if (!fs4.existsSync(akanConfigPath))
|
|
722
720
|
throw new Error(`application akan.config.ts is not found ${appRoot}`);
|
|
@@ -727,11 +725,13 @@ var getAppConfig = async (appRoot, props) => {
|
|
|
727
725
|
});
|
|
728
726
|
const configImp = (await jiti.import(akanConfigPath)).default;
|
|
729
727
|
const config = typeof configImp === "function" ? configImp(props) : configImp;
|
|
730
|
-
|
|
728
|
+
const optimizeLibs = Object.entries(tsconfig.compilerOptions.paths ?? {}).filter(
|
|
729
|
+
([key, resolves]) => key.startsWith("@") && resolves.at(0)?.startsWith("libs/") && resolves.at(0)?.endsWith("/index.ts")
|
|
730
|
+
).map(([key]) => key.slice(1));
|
|
731
|
+
return makeAppConfig(config, props, optimizeLibs);
|
|
731
732
|
};
|
|
732
733
|
var makeLibConfig = (config, props) => {
|
|
733
734
|
return {
|
|
734
|
-
libs: config.libs ?? [],
|
|
735
735
|
backend: {
|
|
736
736
|
explicitDependencies: config.backend?.explicitDependencies ?? []
|
|
737
737
|
},
|
|
@@ -835,8 +835,8 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
|
|
|
835
835
|
};
|
|
836
836
|
}
|
|
837
837
|
};
|
|
838
|
-
var increaseBuildNum = async (appRoot, props) => {
|
|
839
|
-
const appConfig = await getAppConfig(appRoot, props);
|
|
838
|
+
var increaseBuildNum = async (appRoot, props, tsconfig) => {
|
|
839
|
+
const appConfig = await getAppConfig(appRoot, props, tsconfig);
|
|
840
840
|
const akanConfigPath = path.join(appRoot, "akan.config.ts");
|
|
841
841
|
const akanConfig = fs4.readFileSync(akanConfigPath, "utf8");
|
|
842
842
|
const akanConfigContent = akanConfig.replace(
|
|
@@ -845,8 +845,8 @@ var increaseBuildNum = async (appRoot, props) => {
|
|
|
845
845
|
);
|
|
846
846
|
fs4.writeFileSync(akanConfigPath, akanConfigContent);
|
|
847
847
|
};
|
|
848
|
-
var decreaseBuildNum = async (appRoot, props) => {
|
|
849
|
-
const appConfig = await getAppConfig(appRoot, props);
|
|
848
|
+
var decreaseBuildNum = async (appRoot, props, tsconfig) => {
|
|
849
|
+
const appConfig = await getAppConfig(appRoot, props, tsconfig);
|
|
850
850
|
const akanConfigPath = path.join(appRoot, "akan.config.ts");
|
|
851
851
|
const akanConfig = fs4.readFileSync(akanConfigPath, "utf8");
|
|
852
852
|
const akanConfigContent = akanConfig.replace(
|
|
@@ -1076,6 +1076,7 @@ import path5 from "path";
|
|
|
1076
1076
|
|
|
1077
1077
|
// pkgs/@akanjs/devkit/src/dependencyScanner.ts
|
|
1078
1078
|
import * as fs6 from "fs";
|
|
1079
|
+
import ignore from "ignore";
|
|
1079
1080
|
import * as path4 from "path";
|
|
1080
1081
|
import * as ts2 from "typescript";
|
|
1081
1082
|
var TypeScriptDependencyScanner = class {
|
|
@@ -1084,10 +1085,19 @@ var TypeScriptDependencyScanner = class {
|
|
|
1084
1085
|
directory;
|
|
1085
1086
|
tsconfig;
|
|
1086
1087
|
rootPackageJson;
|
|
1087
|
-
|
|
1088
|
+
ig;
|
|
1089
|
+
workspaceRoot;
|
|
1090
|
+
constructor(directory, {
|
|
1091
|
+
workspaceRoot,
|
|
1092
|
+
tsconfig,
|
|
1093
|
+
rootPackageJson,
|
|
1094
|
+
gitignorePatterns = []
|
|
1095
|
+
}) {
|
|
1088
1096
|
this.directory = directory;
|
|
1089
1097
|
this.tsconfig = tsconfig;
|
|
1090
1098
|
this.rootPackageJson = rootPackageJson;
|
|
1099
|
+
this.ig = ignore().add(gitignorePatterns);
|
|
1100
|
+
this.workspaceRoot = workspaceRoot;
|
|
1091
1101
|
}
|
|
1092
1102
|
async getMonorepoDependencies(projectName) {
|
|
1093
1103
|
const npmSet = new Set(
|
|
@@ -1149,6 +1159,9 @@ var TypeScriptDependencyScanner = class {
|
|
|
1149
1159
|
const entries = await fs6.promises.readdir(dir, { withFileTypes: true });
|
|
1150
1160
|
for (const entry of entries) {
|
|
1151
1161
|
const fullPath = path4.join(dir, entry.name);
|
|
1162
|
+
const relativePath = path4.relative(this.workspaceRoot, fullPath);
|
|
1163
|
+
if (this.ig.ignores(relativePath))
|
|
1164
|
+
continue;
|
|
1152
1165
|
if (entry.isDirectory()) {
|
|
1153
1166
|
if (!["node_modules", "dist", "build", ".git", ".next", "public", "ios", "android"].includes(entry.name))
|
|
1154
1167
|
await processDirectory(fullPath);
|
|
@@ -1277,7 +1290,13 @@ var ScanInfo = class {
|
|
|
1277
1290
|
const akanConfig = await exec2.getConfig();
|
|
1278
1291
|
const tsconfig = exec2.getTsConfig();
|
|
1279
1292
|
const rootPackageJson = exec2.workspace.getPackageJson();
|
|
1280
|
-
const
|
|
1293
|
+
const gitignorePatterns = exec2.workspace.getGitignorePatterns();
|
|
1294
|
+
const scanner = new TypeScriptDependencyScanner(exec2.cwdPath, {
|
|
1295
|
+
workspaceRoot: exec2.workspace.cwdPath,
|
|
1296
|
+
tsconfig,
|
|
1297
|
+
rootPackageJson,
|
|
1298
|
+
gitignorePatterns
|
|
1299
|
+
});
|
|
1281
1300
|
const { pkgDeps, libDeps, npmDeps } = await scanner.getMonorepoDependencies(exec2.name);
|
|
1282
1301
|
const files = {
|
|
1283
1302
|
constant: { databases: [], scalars: [] },
|
|
@@ -1381,15 +1400,6 @@ var ScanInfo = class {
|
|
|
1381
1400
|
});
|
|
1382
1401
|
})
|
|
1383
1402
|
]);
|
|
1384
|
-
const missingLibDeps = [];
|
|
1385
|
-
libDeps.forEach((libName) => {
|
|
1386
|
-
if (!akanConfig.libs.includes(libName))
|
|
1387
|
-
missingLibDeps.push(libName);
|
|
1388
|
-
});
|
|
1389
|
-
if (missingLibDeps.length)
|
|
1390
|
-
throw new Error(
|
|
1391
|
-
`Missing libs: ${missingLibDeps.join(", ")}, add these dependencies in akan.config.ts as { libs: [...other deps, ${missingLibDeps.join(", ")}] }`
|
|
1392
|
-
);
|
|
1393
1403
|
const scanResult = {
|
|
1394
1404
|
name: exec2.name,
|
|
1395
1405
|
type: exec2.type,
|
|
@@ -1479,7 +1489,7 @@ var AppInfo = class _AppInfo extends ScanInfo {
|
|
|
1479
1489
|
if (this.#sortedLibs)
|
|
1480
1490
|
return this.#sortedLibs;
|
|
1481
1491
|
const libIndices = LibInfo.getSortedLibIndices();
|
|
1482
|
-
this.#sortedLibs = this.
|
|
1492
|
+
this.#sortedLibs = this.getScanResult().libDeps.sort((libNameA, libNameB) => {
|
|
1483
1493
|
const indexA = libIndices.get(libNameA);
|
|
1484
1494
|
const indexB = libIndices.get(libNameB);
|
|
1485
1495
|
if (indexA === void 0 || indexB === void 0)
|
|
@@ -1519,7 +1529,7 @@ var LibInfo = class _LibInfo extends ScanInfo {
|
|
|
1519
1529
|
if (this.#sortedLibIndices)
|
|
1520
1530
|
return this.#sortedLibIndices;
|
|
1521
1531
|
this.#sortedLibIndices = new Map(
|
|
1522
|
-
[...this.libInfos.entries()].sort(([_, libInfoA], [__, libInfoB]) => libInfoA.
|
|
1532
|
+
[...this.libInfos.entries()].sort(([_, libInfoA], [__, libInfoB]) => libInfoA.getScanResult().libDeps.includes(libInfoB.name) ? 1 : -1).map(([libName], index) => [libName, index])
|
|
1523
1533
|
);
|
|
1524
1534
|
return this.#sortedLibIndices;
|
|
1525
1535
|
}
|
|
@@ -1553,7 +1563,7 @@ var LibInfo = class _LibInfo extends ScanInfo {
|
|
|
1553
1563
|
if (this.#sortedLibs)
|
|
1554
1564
|
return this.#sortedLibs;
|
|
1555
1565
|
const libs = _LibInfo.getSortedLibIndices();
|
|
1556
|
-
this.#sortedLibs = this.
|
|
1566
|
+
this.#sortedLibs = this.scanResult.libDeps.sort((libNameA, libNameB) => {
|
|
1557
1567
|
const indexA = libs.get(libNameA);
|
|
1558
1568
|
const indexB = libs.get(libNameB);
|
|
1559
1569
|
if (indexA === void 0 || indexB === void 0)
|
|
@@ -1566,7 +1576,7 @@ var LibInfo = class _LibInfo extends ScanInfo {
|
|
|
1566
1576
|
return this.#getSortedLibs();
|
|
1567
1577
|
}
|
|
1568
1578
|
getLibInfo(libName) {
|
|
1569
|
-
if (!this.getScanResult().
|
|
1579
|
+
if (!this.getScanResult().libDeps.includes(libName))
|
|
1570
1580
|
return void 0;
|
|
1571
1581
|
const libSet = new Set(this.#getSortedLibs());
|
|
1572
1582
|
if (!libSet.has(libName))
|
|
@@ -1591,7 +1601,13 @@ var PkgInfo = class _PkgInfo {
|
|
|
1591
1601
|
static async getScanResult(exec2) {
|
|
1592
1602
|
const tsconfig = exec2.getTsConfig();
|
|
1593
1603
|
const rootPackageJson = exec2.workspace.getPackageJson();
|
|
1594
|
-
const
|
|
1604
|
+
const gitignorePatterns = exec2.workspace.getGitignorePatterns();
|
|
1605
|
+
const scanner = new TypeScriptDependencyScanner(exec2.cwdPath, {
|
|
1606
|
+
workspaceRoot: exec2.workspace.cwdPath,
|
|
1607
|
+
tsconfig,
|
|
1608
|
+
rootPackageJson,
|
|
1609
|
+
gitignorePatterns
|
|
1610
|
+
});
|
|
1595
1611
|
const npmSet = new Set(Object.keys({ ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies }));
|
|
1596
1612
|
const pkgPathSet = new Set(
|
|
1597
1613
|
Object.keys(tsconfig.compilerOptions.paths ?? {}).filter((path10) => tsconfig.compilerOptions.paths?.[path10]?.some((resolve) => resolve.startsWith("pkgs/"))).map((path10) => path10.replace("/*", ""))
|
|
@@ -2115,6 +2131,14 @@ var Executor = class _Executor {
|
|
|
2115
2131
|
this.writeJson("package.json", packageJson);
|
|
2116
2132
|
this.#packageJson = packageJson;
|
|
2117
2133
|
}
|
|
2134
|
+
#gitignorePatterns = [];
|
|
2135
|
+
getGitignorePatterns() {
|
|
2136
|
+
if (this.#gitignorePatterns.length)
|
|
2137
|
+
return this.#gitignorePatterns;
|
|
2138
|
+
const gitignore = this.readFile(".gitignore");
|
|
2139
|
+
this.#gitignorePatterns = gitignore.split("\n").map((line) => line.trim()).filter((line) => !!line && !line.startsWith("#"));
|
|
2140
|
+
return this.#gitignorePatterns;
|
|
2141
|
+
}
|
|
2118
2142
|
async #applyTemplateFile({
|
|
2119
2143
|
templatePath,
|
|
2120
2144
|
targetPath,
|
|
@@ -2410,7 +2434,12 @@ var SysExecutor = class extends Executor {
|
|
|
2410
2434
|
async getConfig({ refresh } = {}) {
|
|
2411
2435
|
if (this.#akanConfig && !refresh)
|
|
2412
2436
|
return this.#akanConfig;
|
|
2413
|
-
|
|
2437
|
+
const tsconfig = this.getTsConfig();
|
|
2438
|
+
this.#akanConfig = this.type === "app" ? await getAppConfig(
|
|
2439
|
+
this.cwdPath,
|
|
2440
|
+
{ ...this.workspace.getBaseDevEnv(), type: "app", name: this.name },
|
|
2441
|
+
tsconfig
|
|
2442
|
+
) : await getLibConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "lib", name: this.name });
|
|
2414
2443
|
return this.#akanConfig;
|
|
2415
2444
|
}
|
|
2416
2445
|
async getModules() {
|
|
@@ -2564,11 +2593,11 @@ var SysExecutor = class extends Executor {
|
|
|
2564
2593
|
return modules.map((module) => this.getLocalFile(`lib/${module}/${module}.constant.ts`));
|
|
2565
2594
|
}
|
|
2566
2595
|
async getConstantFilesWithLibs() {
|
|
2567
|
-
const
|
|
2596
|
+
const scanInfo = this.type === "app" ? await AppInfo.fromExecutor(this) : await LibInfo.fromExecutor(this);
|
|
2568
2597
|
const sysContantFiles = await this.getConstantFiles();
|
|
2569
2598
|
const sysScalarConstantFiles = await this.getScalarConstantFiles();
|
|
2570
2599
|
const libConstantFiles = await Promise.all(
|
|
2571
|
-
|
|
2600
|
+
scanInfo.getLibs().map(async (lib) => [
|
|
2572
2601
|
...await LibExecutor.from(this, lib).getConstantFiles(),
|
|
2573
2602
|
...await LibExecutor.from(this, lib).getScalarConstantFiles()
|
|
2574
2603
|
])
|
|
@@ -2621,11 +2650,11 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
|
|
|
2621
2650
|
async getConfig({ refresh } = {}) {
|
|
2622
2651
|
if (this.#akanConfig && !refresh)
|
|
2623
2652
|
return this.#akanConfig;
|
|
2624
|
-
this.#akanConfig = await getAppConfig(
|
|
2625
|
-
|
|
2626
|
-
type: "app",
|
|
2627
|
-
|
|
2628
|
-
|
|
2653
|
+
this.#akanConfig = await getAppConfig(
|
|
2654
|
+
this.cwdPath,
|
|
2655
|
+
{ ...this.workspace.getBaseDevEnv(), type: "app", name: this.name },
|
|
2656
|
+
this.getTsConfig()
|
|
2657
|
+
);
|
|
2629
2658
|
return this.#akanConfig;
|
|
2630
2659
|
}
|
|
2631
2660
|
async syncAssets(libDeps) {
|
|
@@ -2648,10 +2677,18 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
|
|
|
2648
2677
|
]);
|
|
2649
2678
|
}
|
|
2650
2679
|
async increaseBuildNum() {
|
|
2651
|
-
await increaseBuildNum(
|
|
2680
|
+
await increaseBuildNum(
|
|
2681
|
+
this.cwdPath,
|
|
2682
|
+
{ ...this.workspace.getBaseDevEnv(), type: "app", name: this.name },
|
|
2683
|
+
this.getTsConfig()
|
|
2684
|
+
);
|
|
2652
2685
|
}
|
|
2653
2686
|
async decreaseBuildNum() {
|
|
2654
|
-
await decreaseBuildNum(
|
|
2687
|
+
await decreaseBuildNum(
|
|
2688
|
+
this.cwdPath,
|
|
2689
|
+
{ ...this.workspace.getBaseDevEnv(), type: "app", name: this.name },
|
|
2690
|
+
this.getTsConfig()
|
|
2691
|
+
);
|
|
2655
2692
|
}
|
|
2656
2693
|
};
|
|
2657
2694
|
var LibExecutor = class _LibExecutor extends SysExecutor {
|
|
@@ -4457,7 +4494,7 @@ var ApplicationRunner = class {
|
|
|
4457
4494
|
}
|
|
4458
4495
|
async scanSync(app, { refresh = false } = {}) {
|
|
4459
4496
|
const scanInfo = await app.scan({ refresh });
|
|
4460
|
-
await app.syncAssets(scanInfo.getScanResult().
|
|
4497
|
+
await app.syncAssets(scanInfo.getScanResult().libDeps);
|
|
4461
4498
|
return scanInfo;
|
|
4462
4499
|
}
|
|
4463
4500
|
async getScriptFilename(app) {
|
|
@@ -6669,7 +6706,7 @@ import latestVersion2 from "latest-version";
|
|
|
6669
6706
|
import path9 from "path";
|
|
6670
6707
|
import { v5 as uuid } from "uuid";
|
|
6671
6708
|
var WorkspaceRunner = class {
|
|
6672
|
-
async createWorkspace(repoName, appName, dirname3 = ".") {
|
|
6709
|
+
async createWorkspace(repoName, appName, { dirname: dirname3 = ".", tag = "latest" }) {
|
|
6673
6710
|
const cwdPath = process.cwd();
|
|
6674
6711
|
const workspaceRoot = path9.join(cwdPath, dirname3, repoName);
|
|
6675
6712
|
const workspace = WorkspaceExecutor.fromRoot({ workspaceRoot, repoName });
|
|
@@ -6699,7 +6736,7 @@ var WorkspaceRunner = class {
|
|
|
6699
6736
|
"@akanjs/ui"
|
|
6700
6737
|
];
|
|
6701
6738
|
const devDependencies = ["@akanjs/devkit", "@akanjs/lint", "@akanjs/test"];
|
|
6702
|
-
const latestPublishedVersionOfBase = await latestVersion2("@akanjs/base");
|
|
6739
|
+
const latestPublishedVersionOfBase = await latestVersion2("@akanjs/base", { version: tag });
|
|
6703
6740
|
const packageJson = {
|
|
6704
6741
|
...rootPackageJson,
|
|
6705
6742
|
dependencies: {
|
|
@@ -6768,8 +6805,8 @@ var WorkspaceScript = class {
|
|
|
6768
6805
|
#runner = new WorkspaceRunner();
|
|
6769
6806
|
applicationScript = new ApplicationScript();
|
|
6770
6807
|
libraryScript = new LibraryScript();
|
|
6771
|
-
async createWorkspace(repoName, appName, dirname3 = ".", installLibs) {
|
|
6772
|
-
const workspace = await this.#runner.createWorkspace(repoName, appName, dirname3);
|
|
6808
|
+
async createWorkspace(repoName, appName, { dirname: dirname3 = ".", installLibs = false, tag = "latest" }) {
|
|
6809
|
+
const workspace = await this.#runner.createWorkspace(repoName, appName, { dirname: dirname3, tag });
|
|
6773
6810
|
if (installLibs) {
|
|
6774
6811
|
await this.libraryScript.installLibrary(workspace, "util");
|
|
6775
6812
|
await this.libraryScript.installLibrary(workspace, "shared");
|
|
@@ -6834,12 +6871,11 @@ var WorkspaceScript = class {
|
|
|
6834
6871
|
// pkgs/@akanjs/cli/src/workspace/workspace.command.ts
|
|
6835
6872
|
var WorkspaceCommand = class {
|
|
6836
6873
|
workspaceScript = new WorkspaceScript();
|
|
6837
|
-
async createWorkspace(workspaceName, app, dir, libs) {
|
|
6874
|
+
async createWorkspace(workspaceName, app, dir, libs, tag) {
|
|
6838
6875
|
await this.workspaceScript.createWorkspace(
|
|
6839
6876
|
workspaceName.toLowerCase().replace(/ /g, "-"),
|
|
6840
6877
|
app.toLowerCase().replace(/ /g, "-"),
|
|
6841
|
-
dir,
|
|
6842
|
-
libs
|
|
6878
|
+
{ dirname: dir, installLibs: libs, tag }
|
|
6843
6879
|
);
|
|
6844
6880
|
}
|
|
6845
6881
|
async generateMongo(workspace) {
|
|
@@ -6876,6 +6912,11 @@ __decorateClass([
|
|
|
6876
6912
|
value: true
|
|
6877
6913
|
}
|
|
6878
6914
|
]
|
|
6915
|
+
})),
|
|
6916
|
+
__decorateParam(4, Option("tag", {
|
|
6917
|
+
desc: "tag of the update",
|
|
6918
|
+
default: "latest",
|
|
6919
|
+
enum: ["latest", "dev", "canary", "beta", "rc", "alpha"]
|
|
6879
6920
|
}))
|
|
6880
6921
|
], WorkspaceCommand.prototype, "createWorkspace", 1);
|
|
6881
6922
|
__decorateClass([
|
|
@@ -7290,7 +7331,7 @@ var ScalarPrompt = class extends Prompter {
|
|
|
7290
7331
|
boilerplate,
|
|
7291
7332
|
constantFiles
|
|
7292
7333
|
}) {
|
|
7293
|
-
const
|
|
7334
|
+
const scanInfo = await this.sys.scan();
|
|
7294
7335
|
const guideJson = await Prompter.getGuideJson("scalarConstant");
|
|
7295
7336
|
const request = await this.makeTsFileUpdatePrompt({
|
|
7296
7337
|
context: `
|
|
@@ -7303,7 +7344,7 @@ ${await this.getDocumentation("enumConstant")}
|
|
|
7303
7344
|
3. How to write Fields in __scalar/<model>/<model>.constant.ts file
|
|
7304
7345
|
${await this.getDocumentation("fieldDecorator")}
|
|
7305
7346
|
|
|
7306
|
-
4. List of constant.ts files in other libraries connected to current ${this.sys.name} ${this.sys.type === "app" ? "Application" : "Library"} ${
|
|
7347
|
+
4. List of constant.ts files in other libraries connected to current ${this.sys.name} ${this.sys.type === "app" ? "Application" : "Library"} ${scanInfo.getLibs().map((lib) => lib).join(", ")}
|
|
7307
7348
|
Please understand the content and file patterns below, and feel free to reuse any constants or enums if available.
|
|
7308
7349
|
${constantFiles.map(
|
|
7309
7350
|
(constant) => `
|
|
@@ -7381,6 +7422,14 @@ ${boilerplate}
|
|
|
7381
7422
|
|
|
7382
7423
|
// pkgs/@akanjs/cli/src/scalar/scalar.runner.ts
|
|
7383
7424
|
var ScalarRunner = class {
|
|
7425
|
+
async applyScalarTemplate(sys3, scalarName) {
|
|
7426
|
+
await sys3.applyTemplate({
|
|
7427
|
+
basePath: "./lib/__scalar",
|
|
7428
|
+
template: "__scalar",
|
|
7429
|
+
dict: { model: scalarName, models: pluralize2(scalarName), sysName: sys3.name },
|
|
7430
|
+
overwrite: false
|
|
7431
|
+
});
|
|
7432
|
+
}
|
|
7384
7433
|
async createScalarConstant(sys3, scalarName) {
|
|
7385
7434
|
const isContinued = sys3.exists(`lib/__scalar/${scalarName}/${scalarName}.constant.ts`);
|
|
7386
7435
|
const prompt = new ScalarPrompt(sys3, scalarName);
|
|
@@ -7389,12 +7438,7 @@ var ScalarRunner = class {
|
|
|
7389
7438
|
const writes = await session.writeTypescripts(request, sys3, { validate });
|
|
7390
7439
|
const scalarNames = writes.map(({ filePath }) => filePath.split("/").at(-2)).filter((name) => !!name);
|
|
7391
7440
|
for (const name of scalarNames)
|
|
7392
|
-
await
|
|
7393
|
-
basePath: "./lib/__scalar",
|
|
7394
|
-
template: "__scalar",
|
|
7395
|
-
dict: { model: name, models: pluralize2(name), sysName: sys3.name },
|
|
7396
|
-
overwrite: false
|
|
7397
|
-
});
|
|
7441
|
+
await this.applyScalarTemplate(sys3, name);
|
|
7398
7442
|
return { session, scalarNames, writes, prompt };
|
|
7399
7443
|
}
|
|
7400
7444
|
async updateScalarDictionaries(sys3, scalarNames, { session }) {
|
|
@@ -7414,6 +7458,9 @@ var ScalarRunner = class {
|
|
|
7414
7458
|
var ScalarScript = class {
|
|
7415
7459
|
#runner = new ScalarRunner();
|
|
7416
7460
|
async createScalar(sys3, scalarName) {
|
|
7461
|
+
await this.#runner.applyScalarTemplate(sys3, scalarName);
|
|
7462
|
+
}
|
|
7463
|
+
async createScalarWithAi(sys3, scalarName) {
|
|
7417
7464
|
const { session, scalarNames } = await this.#runner.createScalarConstant(sys3, scalarName);
|
|
7418
7465
|
await this.#runner.updateScalarDictionaries(sys3, scalarNames, { session });
|
|
7419
7466
|
}
|
|
@@ -7425,22 +7472,22 @@ var ScalarScript = class {
|
|
|
7425
7472
|
// pkgs/@akanjs/cli/src/scalar/scalar.command.ts
|
|
7426
7473
|
var ScalarCommand = class {
|
|
7427
7474
|
scalarScript = new ScalarScript();
|
|
7428
|
-
async createScalar(
|
|
7475
|
+
async createScalar(scalarName, sys3) {
|
|
7429
7476
|
await this.scalarScript.createScalar(sys3, lowerlize(scalarName.replace(/ /g, "")));
|
|
7430
7477
|
}
|
|
7431
|
-
async removeScalar(
|
|
7478
|
+
async removeScalar(scalarName, sys3) {
|
|
7432
7479
|
await this.scalarScript.removeScalar(sys3, scalarName);
|
|
7433
7480
|
}
|
|
7434
7481
|
};
|
|
7435
7482
|
__decorateClass([
|
|
7436
7483
|
Target.Public(),
|
|
7437
|
-
__decorateParam(0,
|
|
7438
|
-
__decorateParam(1,
|
|
7484
|
+
__decorateParam(0, Argument("scalarName", { desc: "name of scalar scalar" })),
|
|
7485
|
+
__decorateParam(1, Sys())
|
|
7439
7486
|
], ScalarCommand.prototype, "createScalar", 1);
|
|
7440
7487
|
__decorateClass([
|
|
7441
7488
|
Target.Public(),
|
|
7442
|
-
__decorateParam(0,
|
|
7443
|
-
__decorateParam(1,
|
|
7489
|
+
__decorateParam(0, Argument("scalarName", { desc: "name of scalar scalar" })),
|
|
7490
|
+
__decorateParam(1, Sys())
|
|
7444
7491
|
], ScalarCommand.prototype, "removeScalar", 1);
|
|
7445
7492
|
ScalarCommand = __decorateClass([
|
|
7446
7493
|
Commands()
|
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
// pkgs/@akanjs/cli/src/templates/__scalar/__model__/__model__.dictionary.ts
|
|
2
2
|
function getContent(scanInfo, dict) {
|
|
3
3
|
return `
|
|
4
|
-
import {
|
|
4
|
+
import { scalarDictionary } from "@akanjs/dictionary";
|
|
5
5
|
|
|
6
6
|
import type { ${dict.Model} } from "./${dict.model}.constant";
|
|
7
7
|
|
|
8
|
-
export const dictionary =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
field: ["Field", "\uD544\uB4DC"],
|
|
14
|
-
"desc-field": ["Field", "\uD544\uB4DC"],
|
|
15
|
-
// * ==================== Model ==================== * //
|
|
16
|
-
|
|
17
|
-
// * ==================== Etc ==================== * //
|
|
18
|
-
// * ==================== Etc ==================== * //
|
|
19
|
-
} satisfies ModelDictionary<${dict.Model}>;
|
|
8
|
+
export const dictionary = scalarDictionary(["en", "ko"])
|
|
9
|
+
.of((t) => t(["${dict.Model}", "${dict.Model}"]).desc(["${dict.Model} description", "${dict.Model} \uC124\uBA85"]))
|
|
10
|
+
.model<${dict.Model}>((t) => ({
|
|
11
|
+
field: t(["Field", "\uD544\uB4DC"]).desc(["Field Description", "\uD544\uB4DC \uC124\uBA85"]),
|
|
12
|
+
}));
|
|
20
13
|
`;
|
|
21
14
|
}
|
|
22
15
|
export {
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
// pkgs/@akanjs/cli/src/templates/app/akan.config.ts
|
|
2
|
-
function getContent(scanInfo, dict
|
|
2
|
+
function getContent(scanInfo, dict) {
|
|
3
3
|
return `
|
|
4
4
|
import type { AppConfig } from "@akanjs/config";
|
|
5
5
|
|
|
6
|
-
const config: AppConfig =
|
|
7
|
-
libs: ["util", "shared"],
|
|
8
|
-
}` : "{}"};
|
|
6
|
+
const config: AppConfig = {};
|
|
9
7
|
|
|
10
8
|
export default config;
|
|
11
9
|
`;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
// pkgs/@akanjs/cli/src/templates/env/
|
|
1
|
+
// pkgs/@akanjs/cli/src/templates/env/_env.server.type.ts
|
|
2
2
|
function getContent(scanInfo, dict = {}) {
|
|
3
3
|
if (!scanInfo)
|
|
4
4
|
return null;
|
|
5
5
|
const libs = scanInfo.getLibs();
|
|
6
|
-
return
|
|
6
|
+
return {
|
|
7
|
+
filename: "env.server.type.ts",
|
|
8
|
+
content: `
|
|
7
9
|
${libs.length ? libs.map((lib) => `import { env as ${lib}Option } from "@${lib}/server";`).join("\n") : 'import { baseEnv } from "@akanjs/base";'}
|
|
8
10
|
|
|
9
11
|
export const libEnv = {
|
|
10
12
|
${libs.length ? libs.map((lib) => ` ...${lib}Option,`).join("\n") : " ...baseEnv,"}
|
|
11
13
|
};
|
|
12
|
-
|
|
14
|
+
`
|
|
15
|
+
};
|
|
13
16
|
}
|
|
14
17
|
export {
|
|
15
18
|
getContent as default
|
|
@@ -4,7 +4,7 @@ function getContent(scanInfo, dict = {}) {
|
|
|
4
4
|
if (!scanInfo)
|
|
5
5
|
return null;
|
|
6
6
|
const scanResult = scanInfo.getScanResult();
|
|
7
|
-
const libs = scanResult.
|
|
7
|
+
const libs = scanResult.libDeps;
|
|
8
8
|
const libInfos = scanInfo.getLibInfos();
|
|
9
9
|
const extendedModels = Object.fromEntries(
|
|
10
10
|
[...scanInfo.file.constant.databases].map(
|
|
@@ -3,7 +3,7 @@ function getContent(scanInfo, dict = {}) {
|
|
|
3
3
|
if (!scanInfo)
|
|
4
4
|
return null;
|
|
5
5
|
const scanResult = scanInfo.getScanResult();
|
|
6
|
-
const libs =
|
|
6
|
+
const libs = scanResult.libDeps;
|
|
7
7
|
const libInfos = scanInfo.getLibInfos();
|
|
8
8
|
const extendedModels = Object.fromEntries(
|
|
9
9
|
[...scanInfo.file.dictionary.databases].map(
|
|
@@ -4,7 +4,6 @@ function getContent(scanInfo, dict) {
|
|
|
4
4
|
import { modelDictionary } from "@akanjs/dictionary";
|
|
5
5
|
|
|
6
6
|
import type { ${dict.Model}, ${dict.Model}Insight } from "./${dict.model}.constant";
|
|
7
|
-
import type { ${dict.Model}Filter } from "./${dict.model}.document";
|
|
8
7
|
import type { ${dict.Model}Endpoint, ${dict.Model}Slice } from "./${dict.model}.signal";
|
|
9
8
|
|
|
10
9
|
export const dictionary = modelDictionary(["en", "ko"])
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"type": "module",
|
|
3
3
|
"sourceType": "module",
|
|
4
4
|
"name": "@akanjs/cli",
|
|
5
|
-
"version": "0.9.60-canary.
|
|
5
|
+
"version": "0.9.60-canary.2",
|
|
6
6
|
"bin": {
|
|
7
7
|
"akan": "esm/index.js"
|
|
8
8
|
},
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"esbuild-plugin-d.ts": "^1.3.1",
|
|
37
37
|
"eslint": "^9.19.0",
|
|
38
38
|
"form-data": "^4.0.1",
|
|
39
|
+
"ignore": "^7.0.5",
|
|
39
40
|
"ink": "^6.1.0",
|
|
40
41
|
"jiti": "^2.4.2",
|
|
41
42
|
"js-yaml": "^4.1.0",
|
|
@@ -2,6 +2,6 @@ import { Sys } from "@akanjs/devkit";
|
|
|
2
2
|
import { ScalarScript } from "./scalar.script";
|
|
3
3
|
export declare class ScalarCommand {
|
|
4
4
|
scalarScript: ScalarScript;
|
|
5
|
-
createScalar(
|
|
6
|
-
removeScalar(
|
|
5
|
+
createScalar(scalarName: string, sys: Sys): Promise<void>;
|
|
6
|
+
removeScalar(scalarName: string, sys: Sys): Promise<void>;
|
|
7
7
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AiSession, type Sys } from "@akanjs/devkit";
|
|
2
2
|
import { ScalarPrompt } from "./scalar.prompt";
|
|
3
3
|
export declare class ScalarRunner {
|
|
4
|
+
applyScalarTemplate(sys: Sys, scalarName: string): Promise<void>;
|
|
4
5
|
createScalarConstant(sys: Sys, scalarName: string): Promise<{
|
|
5
6
|
session: AiSession;
|
|
6
7
|
scalarNames: string[];
|
|
@@ -2,5 +2,6 @@ import { type Sys } from "@akanjs/devkit";
|
|
|
2
2
|
export declare class ScalarScript {
|
|
3
3
|
#private;
|
|
4
4
|
createScalar(sys: Sys, scalarName: string): Promise<void>;
|
|
5
|
+
createScalarWithAi(sys: Sys, scalarName: string): Promise<void>;
|
|
5
6
|
removeScalar(sys: Sys, scalarName: string): Promise<void>;
|
|
6
7
|
}
|
|
@@ -2,7 +2,5 @@ import type { AppInfo, LibInfo } from "@akanjs/devkit";
|
|
|
2
2
|
interface Dict {
|
|
3
3
|
appName: string;
|
|
4
4
|
}
|
|
5
|
-
export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict
|
|
6
|
-
libs: string[];
|
|
7
|
-
}): string;
|
|
5
|
+
export default function getContent(scanInfo: AppInfo | LibInfo | null, dict: Dict): string;
|
|
8
6
|
export {};
|
|
@@ -2,7 +2,7 @@ import { Exec, Workspace } from "@akanjs/devkit";
|
|
|
2
2
|
import { WorkspaceScript } from "./workspace.script";
|
|
3
3
|
export declare class WorkspaceCommand {
|
|
4
4
|
workspaceScript: WorkspaceScript;
|
|
5
|
-
createWorkspace(workspaceName: string, app: string, dir: string, libs: boolean): Promise<void>;
|
|
5
|
+
createWorkspace(workspaceName: string, app: string, dir: string, libs: boolean, tag: string): Promise<void>;
|
|
6
6
|
generateMongo(workspace: Workspace): Promise<void>;
|
|
7
7
|
lint(exec: Exec, fix: boolean, workspace: Workspace): Promise<void>;
|
|
8
8
|
lintAll(fix: boolean, workspace: Workspace): Promise<void>;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Exec, type Workspace } from "@akanjs/devkit";
|
|
2
2
|
import { WorkspaceExecutor } from "@akanjs/devkit";
|
|
3
3
|
export declare class WorkspaceRunner {
|
|
4
|
-
createWorkspace(repoName: string, appName: string, dirname
|
|
4
|
+
createWorkspace(repoName: string, appName: string, { dirname, tag }: {
|
|
5
|
+
dirname?: string;
|
|
6
|
+
tag?: string;
|
|
7
|
+
}): Promise<WorkspaceExecutor>;
|
|
5
8
|
generateMongo(workspace: Workspace): Promise<void>;
|
|
6
9
|
lint(exec: Exec, workspace: Workspace, { fix }?: {
|
|
7
10
|
fix?: boolean;
|
|
@@ -5,7 +5,11 @@ export declare class WorkspaceScript {
|
|
|
5
5
|
#private;
|
|
6
6
|
applicationScript: ApplicationScript;
|
|
7
7
|
libraryScript: LibraryScript;
|
|
8
|
-
createWorkspace(repoName: string, appName: string, dirname
|
|
8
|
+
createWorkspace(repoName: string, appName: string, { dirname, installLibs, tag }: {
|
|
9
|
+
dirname?: string;
|
|
10
|
+
installLibs?: boolean;
|
|
11
|
+
tag?: string;
|
|
12
|
+
}): Promise<void>;
|
|
9
13
|
generateMongo(workspace: Workspace): Promise<void>;
|
|
10
14
|
lint(exec: Exec, workspace: Workspace, { fix }?: {
|
|
11
15
|
fix?: boolean;
|