@akanjs/cli 0.9.60-canary.0 → 0.9.60-canary.11
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 +126 -110
- package/cjs/src/guidelines/scalarConstant/scalarConstant.generate.json +24 -20
- package/cjs/src/guidelines/scalarConstant/scalarConstant.instruction.md +284 -326
- package/cjs/src/guidelines/scalarDictionary/scalarDictionary.generate.json +32 -32
- package/cjs/src/guidelines/scalarDictionary/scalarDictionary.instruction.md +175 -249
- 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__.Unit.js +1 -1
- package/cjs/src/templates/module/__Model__.View.js +2 -3
- package/cjs/src/templates/module/__model__.constant.js +0 -1
- package/cjs/src/templates/module/__model__.dictionary.js +0 -1
- package/cjs/src/templates/workspaceRoot/package.json.template +5 -5
- package/esm/index.js +126 -110
- package/esm/src/guidelines/scalarConstant/scalarConstant.generate.json +24 -20
- package/esm/src/guidelines/scalarConstant/scalarConstant.instruction.md +284 -326
- package/esm/src/guidelines/scalarDictionary/scalarDictionary.generate.json +32 -32
- package/esm/src/guidelines/scalarDictionary/scalarDictionary.instruction.md +175 -249
- 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__.Unit.js +1 -1
- package/esm/src/templates/module/__Model__.View.js +2 -3
- package/esm/src/templates/module/__model__.constant.js +0 -1
- package/esm/src/templates/module/__model__.dictionary.js +0 -1
- package/esm/src/templates/workspaceRoot/package.json.template +5 -5
- package/package.json +5 -4
- package/src/guidelines/scalarConstant/scalarConstant.instruction.md +284 -326
- package/src/guidelines/scalarDictionary/scalarDictionary.instruction.md +175 -249
- package/src/library/library.command.d.ts +0 -2
- package/src/library/library.runner.d.ts +0 -2
- package/src/library/library.script.d.ts +0 -2
- package/src/module/module.runner.d.ts +0 -4
- 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/guidelines/fieldDecorator/fieldDecorator.generate.json +0 -135
- package/cjs/src/guidelines/fieldDecorator/fieldDecorator.instruction.md +0 -606
- 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/guidelines/fieldDecorator/fieldDecorator.generate.json +0 -135
- package/esm/src/guidelines/fieldDecorator/fieldDecorator.instruction.md +0 -606
- package/esm/src/templates/module/__model__.signal.spec.js +0 -7
- package/esm/src/templates/module/__model__.signal.test.js +0 -7
- package/src/guidelines/fieldDecorator/fieldDecorator.instruction.md +0 -606
- 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("/*", ""))
|
|
@@ -1713,7 +1729,8 @@ ${errorMessages}`);
|
|
|
1713
1729
|
const diagnostics = [
|
|
1714
1730
|
...program2.getSemanticDiagnostics(),
|
|
1715
1731
|
...program2.getSyntacticDiagnostics(),
|
|
1716
|
-
|
|
1732
|
+
// Only check declaration diagnostics when declaration emit is enabled
|
|
1733
|
+
...this.config.options.declaration ? program2.getDeclarationDiagnostics() : []
|
|
1717
1734
|
];
|
|
1718
1735
|
const errors = diagnostics.filter((diagnostic) => diagnostic.category === ts3.DiagnosticCategory.Error);
|
|
1719
1736
|
const warnings = diagnostics.filter((diagnostic) => diagnostic.category === ts3.DiagnosticCategory.Warning);
|
|
@@ -2115,6 +2132,14 @@ var Executor = class _Executor {
|
|
|
2115
2132
|
this.writeJson("package.json", packageJson);
|
|
2116
2133
|
this.#packageJson = packageJson;
|
|
2117
2134
|
}
|
|
2135
|
+
#gitignorePatterns = [];
|
|
2136
|
+
getGitignorePatterns() {
|
|
2137
|
+
if (this.#gitignorePatterns.length)
|
|
2138
|
+
return this.#gitignorePatterns;
|
|
2139
|
+
const gitignore = this.readFile(".gitignore");
|
|
2140
|
+
this.#gitignorePatterns = gitignore.split("\n").map((line) => line.trim()).filter((line) => !!line && !line.startsWith("#"));
|
|
2141
|
+
return this.#gitignorePatterns;
|
|
2142
|
+
}
|
|
2118
2143
|
async #applyTemplateFile({
|
|
2119
2144
|
templatePath,
|
|
2120
2145
|
targetPath,
|
|
@@ -2410,7 +2435,12 @@ var SysExecutor = class extends Executor {
|
|
|
2410
2435
|
async getConfig({ refresh } = {}) {
|
|
2411
2436
|
if (this.#akanConfig && !refresh)
|
|
2412
2437
|
return this.#akanConfig;
|
|
2413
|
-
|
|
2438
|
+
const tsconfig = this.getTsConfig();
|
|
2439
|
+
this.#akanConfig = this.type === "app" ? await getAppConfig(
|
|
2440
|
+
this.cwdPath,
|
|
2441
|
+
{ ...this.workspace.getBaseDevEnv(), type: "app", name: this.name },
|
|
2442
|
+
tsconfig
|
|
2443
|
+
) : await getLibConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), type: "lib", name: this.name });
|
|
2414
2444
|
return this.#akanConfig;
|
|
2415
2445
|
}
|
|
2416
2446
|
async getModules() {
|
|
@@ -2564,11 +2594,11 @@ var SysExecutor = class extends Executor {
|
|
|
2564
2594
|
return modules.map((module) => this.getLocalFile(`lib/${module}/${module}.constant.ts`));
|
|
2565
2595
|
}
|
|
2566
2596
|
async getConstantFilesWithLibs() {
|
|
2567
|
-
const
|
|
2597
|
+
const scanInfo = this.type === "app" ? await AppInfo.fromExecutor(this) : await LibInfo.fromExecutor(this);
|
|
2568
2598
|
const sysContantFiles = await this.getConstantFiles();
|
|
2569
2599
|
const sysScalarConstantFiles = await this.getScalarConstantFiles();
|
|
2570
2600
|
const libConstantFiles = await Promise.all(
|
|
2571
|
-
|
|
2601
|
+
scanInfo.getLibs().map(async (lib) => [
|
|
2572
2602
|
...await LibExecutor.from(this, lib).getConstantFiles(),
|
|
2573
2603
|
...await LibExecutor.from(this, lib).getScalarConstantFiles()
|
|
2574
2604
|
])
|
|
@@ -2621,11 +2651,11 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
|
|
|
2621
2651
|
async getConfig({ refresh } = {}) {
|
|
2622
2652
|
if (this.#akanConfig && !refresh)
|
|
2623
2653
|
return this.#akanConfig;
|
|
2624
|
-
this.#akanConfig = await getAppConfig(
|
|
2625
|
-
|
|
2626
|
-
type: "app",
|
|
2627
|
-
|
|
2628
|
-
|
|
2654
|
+
this.#akanConfig = await getAppConfig(
|
|
2655
|
+
this.cwdPath,
|
|
2656
|
+
{ ...this.workspace.getBaseDevEnv(), type: "app", name: this.name },
|
|
2657
|
+
this.getTsConfig()
|
|
2658
|
+
);
|
|
2629
2659
|
return this.#akanConfig;
|
|
2630
2660
|
}
|
|
2631
2661
|
async syncAssets(libDeps) {
|
|
@@ -2648,10 +2678,18 @@ var AppExecutor = class _AppExecutor extends SysExecutor {
|
|
|
2648
2678
|
]);
|
|
2649
2679
|
}
|
|
2650
2680
|
async increaseBuildNum() {
|
|
2651
|
-
await increaseBuildNum(
|
|
2681
|
+
await increaseBuildNum(
|
|
2682
|
+
this.cwdPath,
|
|
2683
|
+
{ ...this.workspace.getBaseDevEnv(), type: "app", name: this.name },
|
|
2684
|
+
this.getTsConfig()
|
|
2685
|
+
);
|
|
2652
2686
|
}
|
|
2653
2687
|
async decreaseBuildNum() {
|
|
2654
|
-
await decreaseBuildNum(
|
|
2688
|
+
await decreaseBuildNum(
|
|
2689
|
+
this.cwdPath,
|
|
2690
|
+
{ ...this.workspace.getBaseDevEnv(), type: "app", name: this.name },
|
|
2691
|
+
this.getTsConfig()
|
|
2692
|
+
);
|
|
2655
2693
|
}
|
|
2656
2694
|
};
|
|
2657
2695
|
var LibExecutor = class _LibExecutor extends SysExecutor {
|
|
@@ -3991,7 +4029,11 @@ var LibraryRunner = class {
|
|
|
3991
4029
|
lib.workspace.unsetTsPaths("lib", lib.name);
|
|
3992
4030
|
}
|
|
3993
4031
|
async installLibrary(workspace, libName) {
|
|
3994
|
-
|
|
4032
|
+
workspace.mkdir("node_modules/.akan");
|
|
4033
|
+
if (workspace.exists("node_modules/.akan/akanjs"))
|
|
4034
|
+
await workspace.removeDir("node_modules/.akan/akanjs");
|
|
4035
|
+
await workspace.exec(`cd node_modules/.akan && git clone git@github.com:akan-team/${libName}.git`);
|
|
4036
|
+
await workspace.cp(`node_modules/.akan/akanjs/libs/${libName}`, `libs/${libName}`);
|
|
3995
4037
|
await workspace.cp(`libs/${libName}/env/env.server.example.ts`, `libs/${libName}/env/env.server.testing.ts`);
|
|
3996
4038
|
workspace.setTsPaths("lib", libName);
|
|
3997
4039
|
await workspace.commit(`Add ${libName} library`);
|
|
@@ -4023,16 +4065,6 @@ var LibraryRunner = class {
|
|
|
4023
4065
|
await lib.workspace.spawn("pnpm", ["install", "--reporter=silent"]);
|
|
4024
4066
|
await lib.workspace.commit(`Merge ${lib.name} library dependencies`);
|
|
4025
4067
|
}
|
|
4026
|
-
async pushLibrary(lib, branch) {
|
|
4027
|
-
await lib.workspace.exec(
|
|
4028
|
-
`git subtree push --prefix=libs/${lib.name} git@github.com:akan-team/${lib.name}.git ${branch}`
|
|
4029
|
-
);
|
|
4030
|
-
}
|
|
4031
|
-
async pullLibrary(lib, branch) {
|
|
4032
|
-
await lib.workspace.exec(
|
|
4033
|
-
`git subtree pull --prefix=libs/${lib.name} git@github.com:akan-team/${lib.name}.git ${branch}`
|
|
4034
|
-
);
|
|
4035
|
-
}
|
|
4036
4068
|
#getEnv(lib, env = {}) {
|
|
4037
4069
|
const rootEnv = dotenv2.parse(lib.workspace.readFile(".env"));
|
|
4038
4070
|
return {
|
|
@@ -4088,19 +4120,6 @@ var LibraryScript = class {
|
|
|
4088
4120
|
await this.#runner.mergeLibraryDependencies(lib);
|
|
4089
4121
|
mergeSpinner.succeed(`${libName} library (libs/${libName}) dependencies merged to root package.json`);
|
|
4090
4122
|
}
|
|
4091
|
-
async pushLibrary(lib, branch) {
|
|
4092
|
-
const pushSpinner = lib.spinning("Pushing library...");
|
|
4093
|
-
await this.#runner.pushLibrary(lib, branch);
|
|
4094
|
-
pushSpinner.succeed(`Library ${lib.name} (libs/${lib.name}) pushed to ${branch} branch`);
|
|
4095
|
-
}
|
|
4096
|
-
async pullLibrary(lib, branch) {
|
|
4097
|
-
const pullSpinner = lib.spinning("Pulling library...");
|
|
4098
|
-
await this.#runner.pullLibrary(lib, branch);
|
|
4099
|
-
pullSpinner.succeed(`Library ${lib.name} (libs/${lib.name}) pulled from ${branch} branch`);
|
|
4100
|
-
const mergeSpinner = lib.spinning("Merging library dependencies...");
|
|
4101
|
-
await this.#runner.mergeLibraryDependencies(lib);
|
|
4102
|
-
mergeSpinner.succeed(`Library ${lib.name} (libs/${lib.name}) dependencies merged to root package.json`);
|
|
4103
|
-
}
|
|
4104
4123
|
async testLibrary(lib) {
|
|
4105
4124
|
const spinner = lib.spinning("Testing library...");
|
|
4106
4125
|
await this.#runner.testLibrary(lib);
|
|
@@ -4457,7 +4476,7 @@ var ApplicationRunner = class {
|
|
|
4457
4476
|
}
|
|
4458
4477
|
async scanSync(app, { refresh = false } = {}) {
|
|
4459
4478
|
const scanInfo = await app.scan({ refresh });
|
|
4460
|
-
await app.syncAssets(scanInfo.getScanResult().
|
|
4479
|
+
await app.syncAssets(scanInfo.getScanResult().libDeps);
|
|
4461
4480
|
return scanInfo;
|
|
4462
4481
|
}
|
|
4463
4482
|
async getScriptFilename(app) {
|
|
@@ -5993,12 +6012,6 @@ var LibraryCommand = class {
|
|
|
5993
6012
|
async installLibrary(libName, workspace) {
|
|
5994
6013
|
await this.libraryScript.installLibrary(workspace, libName);
|
|
5995
6014
|
}
|
|
5996
|
-
async pushLibrary(lib, branch) {
|
|
5997
|
-
await this.libraryScript.pushLibrary(lib, branch);
|
|
5998
|
-
}
|
|
5999
|
-
async pullLibrary(lib, branch) {
|
|
6000
|
-
await this.libraryScript.pullLibrary(lib, branch);
|
|
6001
|
-
}
|
|
6002
6015
|
};
|
|
6003
6016
|
__decorateClass([
|
|
6004
6017
|
Target.Public(),
|
|
@@ -6018,16 +6031,6 @@ __decorateClass([
|
|
|
6018
6031
|
__decorateParam(0, Argument("libName", { desc: "name of library", nullable: true })),
|
|
6019
6032
|
__decorateParam(1, Workspace())
|
|
6020
6033
|
], LibraryCommand.prototype, "installLibrary", 1);
|
|
6021
|
-
__decorateClass([
|
|
6022
|
-
Target.Public({ devOnly: true }),
|
|
6023
|
-
__decorateParam(0, Lib()),
|
|
6024
|
-
__decorateParam(1, Option("branch", { desc: "branch to push", default: "main" }))
|
|
6025
|
-
], LibraryCommand.prototype, "pushLibrary", 1);
|
|
6026
|
-
__decorateClass([
|
|
6027
|
-
Target.Public(),
|
|
6028
|
-
__decorateParam(0, Lib()),
|
|
6029
|
-
__decorateParam(1, Option("branch", { desc: "branch to pull", default: "main" }))
|
|
6030
|
-
], LibraryCommand.prototype, "pullLibrary", 1);
|
|
6031
6034
|
LibraryCommand = __decorateClass([
|
|
6032
6035
|
Commands()
|
|
6033
6036
|
], LibraryCommand);
|
|
@@ -6396,12 +6399,12 @@ var ModuleRunner = class {
|
|
|
6396
6399
|
},
|
|
6397
6400
|
signal: {
|
|
6398
6401
|
filename: `${module.name}.signal.ts`,
|
|
6399
|
-
content: module.readFile(`${module.name}.signal.
|
|
6400
|
-
},
|
|
6401
|
-
test: {
|
|
6402
|
-
filename: `${module.name}.test.ts`,
|
|
6403
|
-
content: module.readFile(`${module.name}.signal.test.ts`)
|
|
6402
|
+
content: module.readFile(`${module.name}.signal.ts`)
|
|
6404
6403
|
},
|
|
6404
|
+
// test: {
|
|
6405
|
+
// filename: `${module.name}.test.ts`,
|
|
6406
|
+
// content: module.readFile(`${module.name}.signal.test.ts`),
|
|
6407
|
+
// },
|
|
6405
6408
|
unit: {
|
|
6406
6409
|
filename: `${module.name}.Unit.tsx`,
|
|
6407
6410
|
content: module.readFile(`${module.name}.Unit.tsx`)
|
|
@@ -6669,7 +6672,7 @@ import latestVersion2 from "latest-version";
|
|
|
6669
6672
|
import path9 from "path";
|
|
6670
6673
|
import { v5 as uuid } from "uuid";
|
|
6671
6674
|
var WorkspaceRunner = class {
|
|
6672
|
-
async createWorkspace(repoName, appName, dirname3 = ".") {
|
|
6675
|
+
async createWorkspace(repoName, appName, { dirname: dirname3 = ".", tag = "latest" }) {
|
|
6673
6676
|
const cwdPath = process.cwd();
|
|
6674
6677
|
const workspaceRoot = path9.join(cwdPath, dirname3, repoName);
|
|
6675
6678
|
const workspace = WorkspaceExecutor.fromRoot({ workspaceRoot, repoName });
|
|
@@ -6699,7 +6702,7 @@ var WorkspaceRunner = class {
|
|
|
6699
6702
|
"@akanjs/ui"
|
|
6700
6703
|
];
|
|
6701
6704
|
const devDependencies = ["@akanjs/devkit", "@akanjs/lint", "@akanjs/test"];
|
|
6702
|
-
const latestPublishedVersionOfBase = await latestVersion2("@akanjs/base");
|
|
6705
|
+
const latestPublishedVersionOfBase = await latestVersion2("@akanjs/base", { version: tag });
|
|
6703
6706
|
const packageJson = {
|
|
6704
6707
|
...rootPackageJson,
|
|
6705
6708
|
dependencies: {
|
|
@@ -6768,8 +6771,8 @@ var WorkspaceScript = class {
|
|
|
6768
6771
|
#runner = new WorkspaceRunner();
|
|
6769
6772
|
applicationScript = new ApplicationScript();
|
|
6770
6773
|
libraryScript = new LibraryScript();
|
|
6771
|
-
async createWorkspace(repoName, appName, dirname3 = ".", installLibs) {
|
|
6772
|
-
const workspace = await this.#runner.createWorkspace(repoName, appName, dirname3);
|
|
6774
|
+
async createWorkspace(repoName, appName, { dirname: dirname3 = ".", installLibs = false, tag = "latest" }) {
|
|
6775
|
+
const workspace = await this.#runner.createWorkspace(repoName, appName, { dirname: dirname3, tag });
|
|
6773
6776
|
if (installLibs) {
|
|
6774
6777
|
await this.libraryScript.installLibrary(workspace, "util");
|
|
6775
6778
|
await this.libraryScript.installLibrary(workspace, "shared");
|
|
@@ -6834,12 +6837,11 @@ var WorkspaceScript = class {
|
|
|
6834
6837
|
// pkgs/@akanjs/cli/src/workspace/workspace.command.ts
|
|
6835
6838
|
var WorkspaceCommand = class {
|
|
6836
6839
|
workspaceScript = new WorkspaceScript();
|
|
6837
|
-
async createWorkspace(workspaceName, app, dir, libs) {
|
|
6840
|
+
async createWorkspace(workspaceName, app, dir, libs, tag) {
|
|
6838
6841
|
await this.workspaceScript.createWorkspace(
|
|
6839
6842
|
workspaceName.toLowerCase().replace(/ /g, "-"),
|
|
6840
6843
|
app.toLowerCase().replace(/ /g, "-"),
|
|
6841
|
-
dir,
|
|
6842
|
-
libs
|
|
6844
|
+
{ dirname: dir, installLibs: libs, tag }
|
|
6843
6845
|
);
|
|
6844
6846
|
}
|
|
6845
6847
|
async generateMongo(workspace) {
|
|
@@ -6876,6 +6878,11 @@ __decorateClass([
|
|
|
6876
6878
|
value: true
|
|
6877
6879
|
}
|
|
6878
6880
|
]
|
|
6881
|
+
})),
|
|
6882
|
+
__decorateParam(4, Option("tag", {
|
|
6883
|
+
desc: "tag of the update",
|
|
6884
|
+
default: "latest",
|
|
6885
|
+
enum: ["latest", "dev", "canary", "beta", "rc", "alpha"]
|
|
6879
6886
|
}))
|
|
6880
6887
|
], WorkspaceCommand.prototype, "createWorkspace", 1);
|
|
6881
6888
|
__decorateClass([
|
|
@@ -7269,8 +7276,8 @@ var ScalarPrompt = class extends Prompter {
|
|
|
7269
7276
|
}
|
|
7270
7277
|
async requestCreateConstant() {
|
|
7271
7278
|
const constantFiles = await this.sys.getConstantFilesWithLibs();
|
|
7272
|
-
const description = await input5({ message: "description of scalar
|
|
7273
|
-
const schemaDescription = await input5({ message: "schema description of scalar
|
|
7279
|
+
const description = await input5({ message: "description of scalar" });
|
|
7280
|
+
const schemaDescription = await input5({ message: "schema description of scalar" });
|
|
7274
7281
|
await this.sys.applyTemplate({
|
|
7275
7282
|
basePath: "./lib/__scalar",
|
|
7276
7283
|
template: "__scalar",
|
|
@@ -7290,7 +7297,7 @@ var ScalarPrompt = class extends Prompter {
|
|
|
7290
7297
|
boilerplate,
|
|
7291
7298
|
constantFiles
|
|
7292
7299
|
}) {
|
|
7293
|
-
const
|
|
7300
|
+
const scanInfo = await this.sys.scan();
|
|
7294
7301
|
const guideJson = await Prompter.getGuideJson("scalarConstant");
|
|
7295
7302
|
const request = await this.makeTsFileUpdatePrompt({
|
|
7296
7303
|
context: `
|
|
@@ -7303,7 +7310,7 @@ ${await this.getDocumentation("enumConstant")}
|
|
|
7303
7310
|
3. How to write Fields in __scalar/<model>/<model>.constant.ts file
|
|
7304
7311
|
${await this.getDocumentation("fieldDecorator")}
|
|
7305
7312
|
|
|
7306
|
-
4. List of constant.ts files in other libraries connected to current ${this.sys.name} ${this.sys.type === "app" ? "Application" : "Library"} ${
|
|
7313
|
+
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
7314
|
Please understand the content and file patterns below, and feel free to reuse any constants or enums if available.
|
|
7308
7315
|
${constantFiles.map(
|
|
7309
7316
|
(constant) => `
|
|
@@ -7381,6 +7388,14 @@ ${boilerplate}
|
|
|
7381
7388
|
|
|
7382
7389
|
// pkgs/@akanjs/cli/src/scalar/scalar.runner.ts
|
|
7383
7390
|
var ScalarRunner = class {
|
|
7391
|
+
async applyScalarTemplate(sys3, scalarName) {
|
|
7392
|
+
await sys3.applyTemplate({
|
|
7393
|
+
basePath: "./lib/__scalar",
|
|
7394
|
+
template: "__scalar",
|
|
7395
|
+
dict: { model: scalarName, models: pluralize2(scalarName), sysName: sys3.name },
|
|
7396
|
+
overwrite: false
|
|
7397
|
+
});
|
|
7398
|
+
}
|
|
7384
7399
|
async createScalarConstant(sys3, scalarName) {
|
|
7385
7400
|
const isContinued = sys3.exists(`lib/__scalar/${scalarName}/${scalarName}.constant.ts`);
|
|
7386
7401
|
const prompt = new ScalarPrompt(sys3, scalarName);
|
|
@@ -7389,12 +7404,7 @@ var ScalarRunner = class {
|
|
|
7389
7404
|
const writes = await session.writeTypescripts(request, sys3, { validate });
|
|
7390
7405
|
const scalarNames = writes.map(({ filePath }) => filePath.split("/").at(-2)).filter((name) => !!name);
|
|
7391
7406
|
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
|
-
});
|
|
7407
|
+
await this.applyScalarTemplate(sys3, name);
|
|
7398
7408
|
return { session, scalarNames, writes, prompt };
|
|
7399
7409
|
}
|
|
7400
7410
|
async updateScalarDictionaries(sys3, scalarNames, { session }) {
|
|
@@ -7414,6 +7424,9 @@ var ScalarRunner = class {
|
|
|
7414
7424
|
var ScalarScript = class {
|
|
7415
7425
|
#runner = new ScalarRunner();
|
|
7416
7426
|
async createScalar(sys3, scalarName) {
|
|
7427
|
+
await this.#runner.applyScalarTemplate(sys3, scalarName);
|
|
7428
|
+
}
|
|
7429
|
+
async createScalarWithAi(sys3, scalarName) {
|
|
7417
7430
|
const { session, scalarNames } = await this.#runner.createScalarConstant(sys3, scalarName);
|
|
7418
7431
|
await this.#runner.updateScalarDictionaries(sys3, scalarNames, { session });
|
|
7419
7432
|
}
|
|
@@ -7425,22 +7438,25 @@ var ScalarScript = class {
|
|
|
7425
7438
|
// pkgs/@akanjs/cli/src/scalar/scalar.command.ts
|
|
7426
7439
|
var ScalarCommand = class {
|
|
7427
7440
|
scalarScript = new ScalarScript();
|
|
7428
|
-
async createScalar(
|
|
7441
|
+
async createScalar(scalarName, ai, sys3) {
|
|
7442
|
+
if (ai)
|
|
7443
|
+
await this.scalarScript.createScalarWithAi(sys3, lowerlize(scalarName.replace(/ /g, "")));
|
|
7429
7444
|
await this.scalarScript.createScalar(sys3, lowerlize(scalarName.replace(/ /g, "")));
|
|
7430
7445
|
}
|
|
7431
|
-
async removeScalar(
|
|
7446
|
+
async removeScalar(scalarName, sys3) {
|
|
7432
7447
|
await this.scalarScript.removeScalar(sys3, scalarName);
|
|
7433
7448
|
}
|
|
7434
7449
|
};
|
|
7435
7450
|
__decorateClass([
|
|
7436
7451
|
Target.Public(),
|
|
7437
|
-
__decorateParam(0,
|
|
7438
|
-
__decorateParam(1,
|
|
7452
|
+
__decorateParam(0, Argument("scalarName", { desc: "name of scalar" })),
|
|
7453
|
+
__decorateParam(1, Option("ai", { type: "boolean", default: false, desc: "use ai to create scalar" })),
|
|
7454
|
+
__decorateParam(2, Sys())
|
|
7439
7455
|
], ScalarCommand.prototype, "createScalar", 1);
|
|
7440
7456
|
__decorateClass([
|
|
7441
7457
|
Target.Public(),
|
|
7442
|
-
__decorateParam(0,
|
|
7443
|
-
__decorateParam(1,
|
|
7458
|
+
__decorateParam(0, Argument("scalarName", { desc: "name of scalar" })),
|
|
7459
|
+
__decorateParam(1, Sys())
|
|
7444
7460
|
], ScalarCommand.prototype, "removeScalar", 1);
|
|
7445
7461
|
ScalarCommand = __decorateClass([
|
|
7446
7462
|
Commands()
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"type": "source",
|
|
17
|
-
"description": "scalar
|
|
18
|
-
"path": "pkgs/@akanjs/constant/src/
|
|
17
|
+
"description": "via() function and scalar implementation",
|
|
18
|
+
"path": "pkgs/@akanjs/constant/src/baseGql.ts"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"type": "source",
|
|
@@ -72,30 +72,34 @@
|
|
|
72
72
|
"Purpose of scalar constants in Akan.js",
|
|
73
73
|
"File structure and location conventions",
|
|
74
74
|
"Naming standards for directories, files, classes and enums",
|
|
75
|
-
"Required imports and
|
|
76
|
-
"
|
|
77
|
-
"Field definitions with
|
|
78
|
-
"Field options reference table",
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
75
|
+
"Required imports from @akanjs/constant and @akanjs/base",
|
|
76
|
+
"Basic syntax with via() function",
|
|
77
|
+
"Field definitions with field() helper function",
|
|
78
|
+
"Field options reference table (default, min, max, minlength, maxlength, validate, example)",
|
|
79
|
+
"Available field types (String, Int, Float, Boolean, Date, ID)",
|
|
80
|
+
"Array fields using bracket notation [Type]",
|
|
81
|
+
"Optional fields using .optional() chain method",
|
|
82
|
+
"Enum definition with enumOf(name, values) class pattern",
|
|
83
|
+
"Instance methods in scalar classes",
|
|
82
84
|
"Static methods in scalar classes",
|
|
83
|
-
"Validation rules and checklists",
|
|
84
85
|
"Common mistakes and fixes",
|
|
86
|
+
"Implementation checklist",
|
|
85
87
|
"Full examples of scalar.constant.ts files"
|
|
86
88
|
],
|
|
87
89
|
"rules": [
|
|
88
|
-
"One scalar.constant.ts should contain only one
|
|
89
|
-
"The directory and filename convention is camelCase, such as `
|
|
90
|
-
"The class name should be PascalCase, matching the camelCase directory name (e.g.,
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
90
|
+
"One scalar.constant.ts should contain only one scalar class extending via(). If you need more than one scalar model, make another scalar.constant.ts file.",
|
|
91
|
+
"The directory and filename convention is camelCase, such as `encourageInfo/encourageInfo.constant.ts`",
|
|
92
|
+
"The class name should be PascalCase, matching the camelCase directory name (e.g., EncourageInfo for encourageInfo)",
|
|
93
|
+
"Use `extends via((field) => ({...}))` pattern to define scalar classes, not decorators",
|
|
94
|
+
"Import `via` from `@akanjs/constant` and `enumOf`, `ID`, `Int`, `Float`, `dayjs` from `@akanjs/base`",
|
|
95
|
+
"The values of enum strings must be camelCase (e.g., 'waitPay', not 'WAIT_PAY')",
|
|
96
|
+
"Define enums using class pattern: `export class EnumName extends enumOf('enumName', [...] as const) {}`",
|
|
97
|
+
"The first argument of enumOf() is the enum name string used in dictionary/GraphQL",
|
|
98
|
+
"Use .optional() chain method for nullable fields, not { nullable: true } option",
|
|
97
99
|
"Use bracket notation for arrays ([Type]) rather than generics (Array<Type>)",
|
|
98
|
-
"
|
|
100
|
+
"Use factory functions for dynamic defaults: { default: () => dayjs() }, not { default: dayjs() }",
|
|
101
|
+
"Always export both the scalar class and enum classes",
|
|
102
|
+
"Add 'as const' to enum value arrays for better TypeScript type inference"
|
|
99
103
|
]
|
|
100
104
|
},
|
|
101
105
|
"page": "/[lang]/akanjs/(docs)/docs/scalar/constant/page.tsx"
|