@akanjs/cli 3.0.0-alpha.8 → 3.0.0-alpha.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.build-stamp +1 -1
- package/README.ko.md +1 -1
- package/README.md +1 -1
- package/{abstractCompactor-e5yq60qz.js → abstractCompactor-pwc6d6yk.js} +3 -5
- package/{agent.command-pggr92jj.js → agent.command-180hh0ye.js} +11 -12
- package/{application.command-692yap1d.js → application.command-gmcgen9y.js} +59 -35
- package/{applicationBuildRunner-ha3y8ew8.js → applicationBuildRunner-tavpx3fv.js} +22 -20
- package/{applicationReleasePackager-gg8ccbeh.js → applicationReleasePackager-ktjt0erc.js} +8 -9
- package/buildBatch.proc.js +12 -13
- package/capacitorApp-kwa67kzs.js +12 -0
- package/{cloud.command-wqfsyzv2.js → cloud.command-gpq7qxrc.js} +15 -17
- package/commandManifest.json +1 -1
- package/{context.command-9bxtdn0w.js → context.command-dk2m2sjx.js} +19 -22
- package/dependencyScanner-c64m6fxp.js +8 -0
- package/fleet.command-3bkyyd3a.js +836 -0
- package/getDirname-dr3jz1xg.js +7 -0
- package/{guideline.command-nfqahxex.js → guideline.command-w6ddv13r.js} +16 -17
- package/guidelines/agentRule/agentRule.generate.json +31 -0
- package/guidelines/agentRule/agentRule.instruction.md +525 -0
- package/guidelines/conventions/conventions.generate.json +25 -0
- package/guidelines/conventions/conventions.instruction.md +847 -0
- package/guidelines/cssRule/cssRule.instruction.md +7 -0
- package/guidelines/framework/framework.generate.json +3 -2
- package/guidelines/framework/framework.instruction.md +1 -9
- package/guidelines/mcpRule/mcpRule.generate.json +25 -0
- package/guidelines/mcpRule/mcpRule.instruction.md +217 -0
- package/guidelines/queryRule/queryRule.generate.json +31 -0
- package/guidelines/queryRule/queryRule.instruction.md +143 -0
- package/guidelines/runtimeRule/runtimeRule.generate.json +25 -0
- package/guidelines/runtimeRule/runtimeRule.instruction.md +176 -0
- package/guidelines/ssrRule/ssrRule.instruction.md +49 -5
- package/guidelines/transportRule/transportRule.generate.json +31 -0
- package/guidelines/transportRule/transportRule.instruction.md +60 -0
- package/guidelines/workspaceOnboarding/workspaceOnboarding.generate.json +24 -0
- package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +263 -0
- package/guidelines/workspaceRecipes/workspaceRecipes.generate.json +33 -0
- package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +402 -0
- package/incrementalBuilder.proc.js +21 -22
- package/{index-4hek879p.js → index-1kzsn94d.js} +1 -1
- package/{index-p3f4q532.js → index-3c9n3nt8.js} +31 -30
- package/index-3d9y066c.js +76 -0
- package/{index-76rn3g2c.js → index-47pj3aee.js} +4 -4
- package/{index-gex7c8kd.js → index-5n0hf8r9.js} +65 -38
- package/{index-mssqn2sq.js → index-5y7qba1c.js} +79 -33
- package/index-6wwzs1bc.js +7 -0
- package/{index-wnp7hwq7.js → index-92zztqy1.js} +7 -7
- package/{index-fgc8r6dj.js → index-a5vmm6x4.js} +3 -1
- package/{index-azv0xjb5.js → index-a8h184wr.js} +15 -11
- package/{index-67546d0j.js → index-ayy5ecax.js} +1 -1
- package/{index-xhgtkekh.js → index-b2nt0w0k.js} +27 -27
- package/{index-xys926f2.js → index-by5gpp8x.js} +4 -4
- package/{index-bz2sfzzt.js → index-cd5x18qh.js} +32 -32
- package/{index-bjpxzr6s.js → index-ctphds8v.js} +1 -1
- package/{index-w6wbb612.js → index-dq6wq1tv.js} +94 -61
- package/{index-js368gk9.js → index-ee8z8adx.js} +13 -13
- package/{index-5dw57f0d.js → index-f7wewj2v.js} +155 -76
- package/{index-6rhabeev.js → index-ft1sfjz0.js} +36 -25
- package/{index-7myvn0f0.js → index-h7yw2z9n.js} +7 -7
- package/{index-5pmx7bkg.js → index-j9vnq8tr.js} +18 -18
- package/{index-vg0sj9nc.js → index-k1n0h7dk.js} +840 -201
- package/{index-vtj3zps1.js → index-k86zc21w.js} +57 -57
- package/{index-46tjzh6s.js → index-mfm35dhh.js} +29 -29
- package/{index-xjd3rqzj.js → index-n68jx79w.js} +6 -15
- package/{index-ztpw544k.js → index-qcracvc9.js} +8 -8
- package/{index-2c3e2xh8.js → index-saheq2bs.js} +4 -4
- package/{index-gmy45vz2.js → index-v0s24t8j.js} +14 -14
- package/{index-0cj2zxbm.js → index-wet2ytnr.js} +12 -11
- package/{index-j9cxndc0.js → index-x23688ar.js} +12 -7
- package/index-xnhf8tr9.js +109 -0
- package/{index-a1e0j63x.js → index-xxe90kqy.js} +58 -25
- package/{index-qb61h0k7.js → index-z3c9mmw4.js} +1098 -1360
- package/index.js +22 -24
- package/{library.command-md9715jz.js → library.command-wpedct6c.js} +11 -9
- package/{localRegistry.command-exkbamyj.js → localRegistry.command-pjdxa01g.js} +20 -22
- package/{module.command-w5aaddxk.js → module.command-8n4kct3e.js} +13 -15
- package/{package.command-yfkrcy0z.js → package.command-fcbd0b1d.js} +8 -9
- package/package.json +5 -7
- package/{page.command-echbavp4.js → page.command-x4379grq.js} +7 -8
- package/{primitive.command-9fbhspw2.js → primitive.command-8etmnqhq.js} +13 -15
- package/{quality.command-3pnt9yep.js → quality.command-hfx7z8yr.js} +226 -104
- package/recipeScanner-fpagtgc1.js +11 -0
- package/{repair.command-carj4vax.js → repair.command-j0fs5qkz.js} +12 -13
- package/{routeSourceValidator-e4jmbfcx.js → routeSourceValidator-ze6x894c.js} +0 -2
- package/{scalar.command-51ryzypc.js → scalar.command-2emk89eh.js} +11 -13
- package/templates/app/env/env.client.debug.ts.template +1 -5
- package/templates/app/env/env.client.develop.ts.template +1 -5
- package/templates/app/env/env.client.local.ts.template +1 -5
- package/templates/app/env/env.client.main.ts.template +1 -5
- package/templates/app/env/env.client.testing.ts.template +1 -5
- package/templates/app/env/env.client.type.ts +2 -6
- package/templates/app/env/env.server.debug.ts.template +1 -5
- package/templates/app/env/env.server.develop.ts.template +1 -5
- package/templates/app/env/env.server.local.ts.template +1 -5
- package/templates/app/env/env.server.main.ts.template +1 -5
- package/templates/app/main.ts +3 -1
- package/templates/appSample/lib/task/task.signal.ts +11 -6
- package/templates/appSample/srvkit/AuthGuard.ts +9 -5
- package/templates/appSample/srvkit/SessionInternalArg.ts +4 -3
- package/templates/crudPages/[__model__Id]/edit/page.tsx +6 -6
- package/templates/crudPages/[__model__Id]/page.tsx +10 -13
- package/templates/crudPages/new/page.tsx +6 -6
- package/templates/crudPages/page.tsx +9 -9
- package/templates/crudSinglePage/page.tsx +11 -7
- package/templates/env/_env.server.type.ts +7 -5
- package/templates/lib/db.ts +1 -1
- package/templates/lib/dict.ts +1 -1
- package/templates/lib/sig.ts +1 -1
- package/templates/lib/srv.ts +6 -2
- package/templates/module/__Model__.Util.tsx +1 -1
- package/templates/module/__Model__.Zone.tsx +3 -5
- package/templates/module/__model__.dictionary.ts +4 -1
- package/templates/module/__model__.signal.ts +2 -3
- package/templates/module/__model__.store.ts +1 -2
- package/templates/workspaceRoot/.gitignore.template +0 -1
- package/templates/workspaceRoot/AGENTS.md.template +4 -972
- package/templates/workspaceRoot/CLAUDE.md.template +19 -0
- package/templates/workspaceRoot/biome.json.template +4 -244
- package/templates/workspaceRoot/docs/AI-DEVELOPMENT.md.template +10 -14
- package/templates/workspaceRoot/docs/GENERATED.md.template +12 -10
- package/templates/workspaceRoot/package.json.template +2 -4
- package/typeChecker-3xgrzc2v.js +7 -0
- package/typecheck.proc.js +4 -5
- package/{workflow.command-91wmvm8k.js → workflow.command-cvpmzwjg.js} +21 -23
- package/{workspace.command-wa10mfd9.js → workspace.command-mbb5s3wx.js} +108 -91
- package/capacitorApp-p0z5yab2.js +0 -60
- package/dependencyScanner-f6grrep3.js +0 -9
- package/index-mxvakhsm.js +0 -66
- package/index-r24hmh0q.js +0 -4
- package/recipeScanner-tghkzrrt.js +0 -12
- package/templates/workspaceRoot/.cursor/rules/akan-page-routing.mdc.template +0 -43
- package/templates/workspaceRoot/.cursor/rules/akan-sync-conventions.mdc.template +0 -34
- package/templates/workspaceRoot/.cursor/rules/application-test-commands.mdc.template +0 -16
- package/templates/workspaceRoot/.cursor/rules/change-scope.mdc.template +0 -12
- package/templates/workspaceRoot/.cursor/rules/client-server-boundaries.mdc.template +0 -18
- package/templates/workspaceRoot/.cursor/rules/coding-comments.mdc.template +0 -25
- package/templates/workspaceRoot/.cursor/rules/coding-style.mdc.template +0 -44
- package/templates/workspaceRoot/.cursor/rules/domain-module-conventions.mdc.template +0 -17
- package/templates/workspaceRoot/.cursor/rules/format-lint.mdc.template +0 -12
- package/templates/workspaceRoot/.cursor/rules/lint-enforced-rules.mdc.template +0 -19
- package/templates/workspaceRoot/.cursor/rules/module-file-playbook.mdc.template +0 -62
- package/templates/workspaceRoot/.cursor/rules/naming-conventions.mdc.template +0 -15
- package/templates/workspaceRoot/.cursor/rules/react-component-style.mdc.template +0 -21
- package/templates/workspaceRoot/.cursor/rules/repo-overview.mdc.template +0 -17
- package/templates/workspaceRoot/.cursor/rules/scalar-modeling.mdc.template +0 -99
- package/templates/workspaceRoot/.cursor/rules/secrets-and-env.mdc.template +0 -13
- package/templates/workspaceRoot/.cursor/rules/service-signal-conventions.mdc.template +0 -83
- package/templates/workspaceRoot/.cursor/rules/srvkit-adapters-and-guards.mdc.template +0 -50
- package/templates/workspaceRoot/.cursor/rules/ssr-first.mdc.template +0 -59
- package/templates/workspaceRoot/.cursor/rules/typescript-imports.mdc.template +0 -16
- package/typeChecker-kravn7ns.js +0 -8
- /package/{index-0wae5ebk.js → index-meh558jy.js} +0 -0
- /package/{index-ss469dec.js → index-nz8prx9g.js} +0 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
AppInfo
|
|
4
|
+
} from "./index-k1n0h7dk.js";
|
|
5
|
+
|
|
6
|
+
// pkgs/@akanjs/devkit/slicePlanner.ts
|
|
7
|
+
class SlicePlanner {
|
|
8
|
+
static memberDirs = ["apps", "libs", "pkgs"];
|
|
9
|
+
static toolchainDependencies = [
|
|
10
|
+
"@akanjs/cli",
|
|
11
|
+
"@akanjs/devkit",
|
|
12
|
+
"@biomejs/biome",
|
|
13
|
+
"@types/bun",
|
|
14
|
+
"akanjs",
|
|
15
|
+
"typescript"
|
|
16
|
+
];
|
|
17
|
+
#app;
|
|
18
|
+
constructor(app) {
|
|
19
|
+
this.#app = app;
|
|
20
|
+
}
|
|
21
|
+
async#trackedFiles(paths) {
|
|
22
|
+
return await this.#app.workspace.listGitFiles(paths);
|
|
23
|
+
}
|
|
24
|
+
async#untrackedFiles(paths) {
|
|
25
|
+
const [tracked, all] = await Promise.all([
|
|
26
|
+
this.#app.workspace.listGitFiles(paths),
|
|
27
|
+
this.#app.workspace.listGitFiles(paths, { untracked: true })
|
|
28
|
+
]);
|
|
29
|
+
const trackedSet = new Set(tracked);
|
|
30
|
+
return all.filter((file) => !trackedSet.has(file));
|
|
31
|
+
}
|
|
32
|
+
#isMemberFile(file) {
|
|
33
|
+
return SlicePlanner.memberDirs.includes(file.split("/")[0] ?? "");
|
|
34
|
+
}
|
|
35
|
+
static #requiredDependencies(appInfo) {
|
|
36
|
+
const scanResults = [
|
|
37
|
+
appInfo.getScanResult(),
|
|
38
|
+
...[...appInfo.getLibInfos().values()].map((lib) => lib.getScanResult())
|
|
39
|
+
];
|
|
40
|
+
return new Set([
|
|
41
|
+
...SlicePlanner.toolchainDependencies,
|
|
42
|
+
...scanResults.flatMap((scanResult) => [
|
|
43
|
+
...scanResult.dependencies,
|
|
44
|
+
...scanResult.devDependencies,
|
|
45
|
+
...scanResult.pkgDeps
|
|
46
|
+
])
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
async#patchWarnings(packageJson) {
|
|
50
|
+
const patchedDependencies = packageJson.patchedDependencies ?? {};
|
|
51
|
+
const missing = (await Promise.all(Object.entries(patchedDependencies).map(async ([spec, patchPath]) => await this.#app.workspace.exists(patchPath) ? null : `${spec} -> ${patchPath}`))).filter((entry) => !!entry);
|
|
52
|
+
return missing.length ? [`patchedDependencies references a missing patch file: ${missing.join(", ")}`] : [];
|
|
53
|
+
}
|
|
54
|
+
async plan() {
|
|
55
|
+
const appInfo = await AppInfo.fromExecutor(this.#app);
|
|
56
|
+
const libs = appInfo.getLibs();
|
|
57
|
+
const slicePaths = [`apps/${this.#app.name}`, ...libs.map((lib) => `libs/${lib}`)];
|
|
58
|
+
const [appFiles, allTracked, untracked, rootPackageJson] = await Promise.all([
|
|
59
|
+
this.#trackedFiles([`apps/${this.#app.name}`]),
|
|
60
|
+
this.#trackedFiles(["."]),
|
|
61
|
+
this.#untrackedFiles(slicePaths),
|
|
62
|
+
this.#app.workspace.getPackageJson()
|
|
63
|
+
]);
|
|
64
|
+
const libFiles = Object.fromEntries(await Promise.all(libs.map(async (lib) => [lib, await this.#trackedFiles([`libs/${lib}`])])));
|
|
65
|
+
const rootFiles = allTracked.filter((file) => !this.#isMemberFile(file));
|
|
66
|
+
const required = SlicePlanner.#requiredDependencies(appInfo);
|
|
67
|
+
const rootDependencies = { ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies };
|
|
68
|
+
const unusedDependencies = Object.keys(rootDependencies).filter((dep) => !required.has(dep)).sort();
|
|
69
|
+
const { workspaces: _workspaces, ...slicePackageJson } = rootPackageJson;
|
|
70
|
+
const warnings = [
|
|
71
|
+
...untracked.length ? [`${untracked.length} untracked file(s) under the slice paths: ${untracked.join(", ")}`] : [],
|
|
72
|
+
...rootPackageJson.workspaces ? ["root `workspaces` dropped \u2014 a slice consumes akanjs from the registry"] : [],
|
|
73
|
+
...await this.#patchWarnings(rootPackageJson)
|
|
74
|
+
];
|
|
75
|
+
return {
|
|
76
|
+
app: this.#app.name,
|
|
77
|
+
libs,
|
|
78
|
+
appFiles,
|
|
79
|
+
libFiles,
|
|
80
|
+
rootFiles,
|
|
81
|
+
packageJson: slicePackageJson,
|
|
82
|
+
unusedDependencies,
|
|
83
|
+
warnings
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
var rootEntriesOf = (rootFiles) => [...new Set(rootFiles.map((file) => file.split("/")[0] ?? file))].sort();
|
|
88
|
+
function formatSlicePlan(plan) {
|
|
89
|
+
const libCounts = Object.entries(plan.libFiles).map(([lib, files]) => ` - libs/${lib}: ${files.length} files`);
|
|
90
|
+
const sections = [
|
|
91
|
+
"Akan Slice Plan",
|
|
92
|
+
`app: ${plan.app} (apps/${plan.app}: ${plan.appFiles.length} files)`,
|
|
93
|
+
`libs: ${plan.libs.length ? plan.libs.join(", ") : "(none)"}`,
|
|
94
|
+
...libCounts,
|
|
95
|
+
`workspace shell: ${plan.rootFiles.length} files across ${rootEntriesOf(plan.rootFiles).join(", ")}`,
|
|
96
|
+
"",
|
|
97
|
+
`Unused root dependencies (${plan.unusedDependencies.length}) \u2014 prune candidates, not pruned:`,
|
|
98
|
+
"",
|
|
99
|
+
...plan.unusedDependencies.length ? plan.unusedDependencies.map((dep) => ` - ${dep}`) : [" (none)"],
|
|
100
|
+
"",
|
|
101
|
+
`Warnings (${plan.warnings.length}):`,
|
|
102
|
+
"",
|
|
103
|
+
...plan.warnings.length ? plan.warnings.map((warning) => ` - ${warning}`) : [" (none)"]
|
|
104
|
+
];
|
|
105
|
+
return sections.join(`
|
|
106
|
+
`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { SlicePlanner, formatSlicePlan };
|
|
@@ -2,16 +2,24 @@
|
|
|
2
2
|
import {
|
|
3
3
|
runner,
|
|
4
4
|
script
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-ft1sfjz0.js";
|
|
6
6
|
import {
|
|
7
7
|
LibExecutor
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-k1n0h7dk.js";
|
|
9
|
+
import {
|
|
10
|
+
LibSource,
|
|
11
|
+
formatLibStatuses
|
|
12
|
+
} from "./index-3d9y066c.js";
|
|
13
|
+
|
|
14
|
+
// pkgs/@akanjs/cli/library/library.script.ts
|
|
15
|
+
import { Logger } from "akanjs/common";
|
|
9
16
|
|
|
10
|
-
// pkgs/@akanjs/
|
|
11
|
-
|
|
17
|
+
// pkgs/@akanjs/devkit/semver.ts
|
|
18
|
+
var stripRangeOperator = (version) => version.replace(/^[\s^~>=<v]+/, "").trim();
|
|
19
|
+
var parseVersion = (version) => {
|
|
12
20
|
return version.replace(/^[^\d]*/, "").split(/[.-]/).map((part) => Number.parseInt(part, 10)).map((part) => Number.isFinite(part) ? part : 0);
|
|
13
|
-
}
|
|
14
|
-
|
|
21
|
+
};
|
|
22
|
+
var compareNumeric = (a, b) => {
|
|
15
23
|
const left = parseVersion(a);
|
|
16
24
|
const right = parseVersion(b);
|
|
17
25
|
const length = Math.max(left.length, right.length);
|
|
@@ -21,40 +29,64 @@ function compareSemver(a, b) {
|
|
|
21
29
|
return diff > 0 ? 1 : -1;
|
|
22
30
|
}
|
|
23
31
|
return 0;
|
|
24
|
-
}
|
|
32
|
+
};
|
|
33
|
+
var compareSemver = (a, b) => {
|
|
34
|
+
try {
|
|
35
|
+
return Bun.semver.order(stripRangeOperator(a), stripRangeOperator(b));
|
|
36
|
+
} catch {
|
|
37
|
+
return compareNumeric(a, b);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
25
40
|
|
|
26
41
|
// pkgs/@akanjs/cli/library/library.runner.ts
|
|
27
42
|
class LibraryRunner extends runner("library") {
|
|
43
|
+
static libraryRepository = "https://github.com/akan-team/akanjs.git";
|
|
28
44
|
async createLibrary(libName, workspace) {
|
|
29
|
-
await workspace.
|
|
45
|
+
await workspace.mkdir(`libs/${libName}`);
|
|
30
46
|
await workspace.applyTemplate({ basePath: `libs/${libName}`, template: "libRoot", dict: { libName } });
|
|
31
47
|
const lib = LibExecutor.from(workspace, libName);
|
|
32
48
|
return lib;
|
|
33
49
|
}
|
|
34
50
|
async removeLibrary(lib) {
|
|
35
|
-
await lib.workspace.
|
|
51
|
+
await lib.workspace.removeDir(`libs/${lib.name}`);
|
|
36
52
|
}
|
|
37
53
|
async#copyInstalledLibrary(workspace, libName) {
|
|
38
54
|
const installedPackageJson = `node_modules/akanjs/libs/${libName}/package.json`;
|
|
39
55
|
if (!await workspace.exists(installedPackageJson))
|
|
40
|
-
return
|
|
56
|
+
return null;
|
|
41
57
|
await workspace.cp(`node_modules/akanjs/libs/${libName}`, `libs/${libName}`);
|
|
42
|
-
return
|
|
58
|
+
return { origin: "akanjs", sha: await this.#installedAkanVersion(workspace) };
|
|
59
|
+
}
|
|
60
|
+
async#installedAkanVersion(workspace) {
|
|
61
|
+
const manifestPath = "node_modules/akanjs/package.json";
|
|
62
|
+
if (!await workspace.exists(manifestPath))
|
|
63
|
+
return "unknown";
|
|
64
|
+
const { version } = await workspace.readJson(manifestPath);
|
|
65
|
+
return version ?? "unknown";
|
|
43
66
|
}
|
|
44
67
|
async#copyLibraryFromRepository(workspace, libName) {
|
|
45
68
|
await workspace.mkdir("node_modules/.akan");
|
|
46
69
|
if (await workspace.exists("node_modules/.akan/akanjs"))
|
|
47
70
|
await workspace.removeDir("node_modules/.akan/akanjs");
|
|
48
|
-
await workspace.exec(`cd node_modules/.akan && git clone
|
|
71
|
+
await workspace.exec(`cd node_modules/.akan && git clone ${LibraryRunner.libraryRepository}`);
|
|
49
72
|
await workspace.cp(`node_modules/.akan/akanjs/libs/${libName}`, `libs/${libName}`);
|
|
73
|
+
const sha = await workspace.spawn("git", ["-C", "node_modules/.akan/akanjs", "rev-parse", "HEAD"]);
|
|
74
|
+
return { origin: LibraryRunner.libraryRepository, sha: sha.trim().slice(0, 12) };
|
|
50
75
|
}
|
|
51
76
|
async installLibrary(workspace, libName) {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
77
|
+
const source = await this.#copyInstalledLibrary(workspace, libName) ?? await this.#copyLibraryFromRepository(workspace, libName);
|
|
78
|
+
const testingEnv = `libs/${libName}/env/env.server.testing.ts`;
|
|
79
|
+
if (!await workspace.exists(testingEnv))
|
|
80
|
+
await workspace.cp(`libs/${libName}/env/env.server.example.ts`, testingEnv);
|
|
81
|
+
const lib = LibExecutor.from(workspace, libName);
|
|
82
|
+
const stamp = await new LibSource(lib).write(source);
|
|
83
|
+
if (await workspace.hasChanges())
|
|
84
|
+
await workspace.commit(`Install ${libName} library from ${stamp.origin}`);
|
|
85
|
+
return lib;
|
|
86
|
+
}
|
|
87
|
+
async libraryStatuses(workspace) {
|
|
88
|
+
const libNames = await workspace.getLibs();
|
|
89
|
+
return await Promise.all(libNames.map((libName) => new LibSource(LibExecutor.from(workspace, libName)).status()));
|
|
58
90
|
}
|
|
59
91
|
async mergeLibraryDependencies(lib) {
|
|
60
92
|
const libPackageJson = await lib.getPackageJson();
|
|
@@ -70,7 +102,7 @@ class LibraryRunner extends runner("library") {
|
|
|
70
102
|
return [dep, newerVersion];
|
|
71
103
|
}));
|
|
72
104
|
Object.keys(allDependencies).sort().forEach((dep) => {
|
|
73
|
-
if (
|
|
105
|
+
if (libPackageJson.dependencies?.[dep] || rootPackageJson.dependencies?.[dep])
|
|
74
106
|
dependencies[dep] = allDependencies[dep];
|
|
75
107
|
else
|
|
76
108
|
devDependencies[dep] = allDependencies[dep];
|
|
@@ -80,7 +112,6 @@ class LibraryRunner extends runner("library") {
|
|
|
80
112
|
await lib.workspace.spawn("bun", ["install"]);
|
|
81
113
|
await lib.workspace.commit(`Merge ${lib.name} library dependencies`);
|
|
82
114
|
}
|
|
83
|
-
async testLibrary(lib) {}
|
|
84
115
|
}
|
|
85
116
|
|
|
86
117
|
// pkgs/@akanjs/cli/library/library.script.ts
|
|
@@ -102,6 +133,13 @@ class LibraryScript extends script("library", [LibraryRunner]) {
|
|
|
102
133
|
await this.libraryRunner.removeLibrary(lib);
|
|
103
134
|
spinner.succeed(`Library ${lib.name} (libs/${lib.name}) is removed`);
|
|
104
135
|
}
|
|
136
|
+
async libraryStatus(workspace, format = "text") {
|
|
137
|
+
const spinner = workspace.spinning("Checking library sources...");
|
|
138
|
+
const statuses = await this.libraryRunner.libraryStatuses(workspace);
|
|
139
|
+
const drifted = statuses.filter((status) => status.drift === "drifted").length;
|
|
140
|
+
spinner.succeed(`Checked ${statuses.length} libraries (${drifted} drifted)`);
|
|
141
|
+
Logger.rawLog(format === "json" ? JSON.stringify(statuses, null, 2) : formatLibStatuses(statuses));
|
|
142
|
+
}
|
|
105
143
|
async installLibrary(workspace, libName) {
|
|
106
144
|
const installSpinner = workspace.spinning(`Installing ${libName} library`);
|
|
107
145
|
const lib = await this.libraryRunner.installLibrary(workspace, libName);
|
|
@@ -110,11 +148,6 @@ class LibraryScript extends script("library", [LibraryRunner]) {
|
|
|
110
148
|
await this.libraryRunner.mergeLibraryDependencies(lib);
|
|
111
149
|
mergeSpinner.succeed(`${libName} library (libs/${libName}) dependencies merged to root package.json`);
|
|
112
150
|
}
|
|
113
|
-
async testLibrary(lib) {
|
|
114
|
-
const spinner = lib.spinning("Testing library...");
|
|
115
|
-
await this.libraryRunner.testLibrary(lib);
|
|
116
|
-
spinner.succeed(`Library ${lib.name} (libs/${lib.name}) test is successful`);
|
|
117
|
-
}
|
|
118
151
|
}
|
|
119
152
|
|
|
120
153
|
export { LibraryScript };
|