@akanjs/cli 2.4.1-rc.1 → 2.4.1-rc.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/{cloud.command-qgjxja3n.js → cloud.command-hxcgsf80.js} +2 -2
- package/{index-z9gvz7b0.js → index-mq6ns0f9.js} +1 -1
- package/{index-wq8jwx8z.js → index-n6h3482q.js} +161 -6
- package/index.js +4 -4
- package/{localRegistry.command-p1pgxw78.js → localRegistry.command-6z4s13mj.js} +1 -1
- package/{package.command-r8sq5kzp.js → package.command-5x5m0ej1.js} +1 -1
- package/package.json +2 -2
- package/{workspace.command-xk68sd6c.js → workspace.command-875aj35r.js} +2 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
CloudScript
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-mq6ns0f9.js";
|
|
5
5
|
import"./index-sgmas1fc.js";
|
|
6
6
|
import"./index-77crfweb.js";
|
|
7
7
|
import"./index-76rn3g2c.js";
|
|
8
8
|
import"./index-pmm9e2jf.js";
|
|
9
|
-
import"./index-
|
|
9
|
+
import"./index-n6h3482q.js";
|
|
10
10
|
import {
|
|
11
11
|
GlobalConfig
|
|
12
12
|
} from "./index-5vvwc0cz.js";
|
|
@@ -14,7 +14,93 @@ import {
|
|
|
14
14
|
} from "./index-61keag0s.js";
|
|
15
15
|
|
|
16
16
|
// pkgs/@akanjs/cli/package/package.runner.ts
|
|
17
|
+
import path2 from "path";
|
|
18
|
+
|
|
19
|
+
// pkgs/@akanjs/devkit/packageExportsMap.ts
|
|
20
|
+
import { statSync } from "fs";
|
|
17
21
|
import path from "path";
|
|
22
|
+
|
|
23
|
+
class PackageExportsMap {
|
|
24
|
+
static async from(packageDir) {
|
|
25
|
+
const manifest = await Bun.file(path.join(packageDir, "package.json")).json();
|
|
26
|
+
return new PackageExportsMap(packageDir, manifest.exports);
|
|
27
|
+
}
|
|
28
|
+
static #runtimeTargetOf(value) {
|
|
29
|
+
if (typeof value === "string")
|
|
30
|
+
return value;
|
|
31
|
+
if (Array.isArray(value)) {
|
|
32
|
+
for (const entry of value) {
|
|
33
|
+
const target = PackageExportsMap.#runtimeTargetOf(entry);
|
|
34
|
+
if (target)
|
|
35
|
+
return target;
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
if (!value || typeof value !== "object")
|
|
40
|
+
return null;
|
|
41
|
+
const conditions = value;
|
|
42
|
+
for (const condition of ["bun", "import", "default", "require", "types"]) {
|
|
43
|
+
if (!(condition in conditions))
|
|
44
|
+
continue;
|
|
45
|
+
const target = PackageExportsMap.#runtimeTargetOf(conditions[condition]);
|
|
46
|
+
if (target)
|
|
47
|
+
return target;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
#packageDir;
|
|
52
|
+
#literals = new Map;
|
|
53
|
+
#patterns = [];
|
|
54
|
+
constructor(packageDir, exportsField) {
|
|
55
|
+
this.#packageDir = packageDir;
|
|
56
|
+
if (!exportsField || typeof exportsField !== "object")
|
|
57
|
+
return;
|
|
58
|
+
for (const [key, value] of Object.entries(exportsField)) {
|
|
59
|
+
if (!key.startsWith("."))
|
|
60
|
+
continue;
|
|
61
|
+
const target = PackageExportsMap.#runtimeTargetOf(value);
|
|
62
|
+
if (!target)
|
|
63
|
+
continue;
|
|
64
|
+
const star = key.indexOf("*");
|
|
65
|
+
if (star === -1)
|
|
66
|
+
this.#literals.set(key, target);
|
|
67
|
+
else
|
|
68
|
+
this.#patterns.push({ prefix: key.slice(0, star), suffix: key.slice(star + 1), target });
|
|
69
|
+
}
|
|
70
|
+
this.#patterns.sort((a, b) => b.prefix.length - a.prefix.length || b.suffix.length - a.suffix.length);
|
|
71
|
+
}
|
|
72
|
+
resolve(subpath) {
|
|
73
|
+
const literal = this.#literals.get(subpath);
|
|
74
|
+
if (literal)
|
|
75
|
+
return literal;
|
|
76
|
+
for (const { prefix, suffix, target } of this.#patterns) {
|
|
77
|
+
if (!subpath.startsWith(prefix) || !subpath.endsWith(suffix))
|
|
78
|
+
continue;
|
|
79
|
+
if (subpath.length < prefix.length + suffix.length)
|
|
80
|
+
continue;
|
|
81
|
+
return target.replace("*", subpath.slice(prefix.length, subpath.length - suffix.length));
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
resolveToFile(subpath) {
|
|
86
|
+
const target = this.resolve(subpath);
|
|
87
|
+
if (!target)
|
|
88
|
+
return { target: null, exists: false };
|
|
89
|
+
const stat = statSync(path.join(this.#packageDir, target), { throwIfNoEntry: false });
|
|
90
|
+
return { target, exists: !!stat?.isFile() };
|
|
91
|
+
}
|
|
92
|
+
findUnreachable(subpaths) {
|
|
93
|
+
const unreachable = [];
|
|
94
|
+
for (const subpath of subpaths) {
|
|
95
|
+
const { target, exists } = this.resolveToFile(subpath);
|
|
96
|
+
if (!exists)
|
|
97
|
+
unreachable.push({ subpath, target });
|
|
98
|
+
}
|
|
99
|
+
return unreachable;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// pkgs/@akanjs/cli/package/package.runner.ts
|
|
18
104
|
import { Logger } from "akanjs/common";
|
|
19
105
|
var {$ } = globalThis.Bun;
|
|
20
106
|
|
|
@@ -34,11 +120,11 @@ class PackageRunner extends runner("package") {
|
|
|
34
120
|
}
|
|
35
121
|
async#getInstalledPackageJson() {
|
|
36
122
|
const packageJsonCandidates = [
|
|
37
|
-
`${
|
|
123
|
+
`${path2.dirname(Bun.main)}/package.json`,
|
|
38
124
|
`${process.cwd()}/node_modules/akanjs/package.json`
|
|
39
125
|
];
|
|
40
126
|
try {
|
|
41
|
-
packageJsonCandidates.unshift(Bun.resolveSync("akanjs/package.json",
|
|
127
|
+
packageJsonCandidates.unshift(Bun.resolveSync("akanjs/package.json", path2.dirname(Bun.main)));
|
|
42
128
|
} catch {}
|
|
43
129
|
for (const packageJsonPath of packageJsonCandidates) {
|
|
44
130
|
if (!await Bun.file(packageJsonPath).exists())
|
|
@@ -47,7 +133,7 @@ class PackageRunner extends runner("package") {
|
|
|
47
133
|
if (packageJson.name === "akanjs" || packageJson.name === "@akanjs/cli")
|
|
48
134
|
return packageJson;
|
|
49
135
|
}
|
|
50
|
-
throw new Error(`[package] failed to locate akanjs package.json from ${
|
|
136
|
+
throw new Error(`[package] failed to locate akanjs package.json from ${path2.dirname(Bun.main)}`);
|
|
51
137
|
}
|
|
52
138
|
async createPackage(workspace, pkgName) {
|
|
53
139
|
await workspace.applyTemplate({ basePath: `pkgs/${pkgName}`, template: "pkgRoot", dict: { pkgName } });
|
|
@@ -111,7 +197,68 @@ class PackageRunner extends runner("package") {
|
|
|
111
197
|
}
|
|
112
198
|
await this.#copyPackageReadmes(pkg);
|
|
113
199
|
}
|
|
114
|
-
|
|
200
|
+
static #scannableDistFiles = "**/*.{ts,tsx,js,jsx,mjs,cjs}";
|
|
201
|
+
static #importPosition = /(?:\bfrom\s*|\brequire\s*\(\s*|\bimport\s*\(\s*|\bimport\s+)$/;
|
|
202
|
+
static #splitSpecifier(specifier) {
|
|
203
|
+
const segments = specifier.split("/");
|
|
204
|
+
const name = specifier.startsWith("@") ? segments.slice(0, 2).join("/") : segments[0];
|
|
205
|
+
const subpath = specifier.slice(name.length).replace(/^\//, "");
|
|
206
|
+
return { name, subpath: subpath ? `./${subpath}` : "." };
|
|
207
|
+
}
|
|
208
|
+
async#collectDistAkanImports(distPath, packageNames) {
|
|
209
|
+
const alternatives = [...new Set(packageNames)].map((name) => name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
210
|
+
const specifierPattern = new RegExp(`["'](${alternatives.join("|")})((?:/[^"'\\s]*)?)["']`, "g");
|
|
211
|
+
const glob = new Bun.Glob(PackageRunner.#scannableDistFiles);
|
|
212
|
+
const imports = new Map;
|
|
213
|
+
for await (const relative of glob.scan({ cwd: distPath })) {
|
|
214
|
+
if (relative.includes("node_modules/") || relative.endsWith(".d.ts"))
|
|
215
|
+
continue;
|
|
216
|
+
if (/\.(test|spec)\.[a-z]+$/.test(relative))
|
|
217
|
+
continue;
|
|
218
|
+
const source = await Bun.file(`${distPath}/${relative}`).text();
|
|
219
|
+
for (const line of source.split(`
|
|
220
|
+
`)) {
|
|
221
|
+
const trimmed = line.trimStart();
|
|
222
|
+
if (trimmed.startsWith("//") || trimmed.startsWith("*") || trimmed.startsWith("/*"))
|
|
223
|
+
continue;
|
|
224
|
+
for (const match of line.matchAll(specifierPattern)) {
|
|
225
|
+
if (!PackageRunner.#importPosition.test(line.slice(0, match.index)))
|
|
226
|
+
continue;
|
|
227
|
+
const specifier = `${match[1]}${match[2] ?? ""}`;
|
|
228
|
+
const importers = imports.get(specifier) ?? new Set;
|
|
229
|
+
imports.set(specifier, importers.add(relative));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return imports;
|
|
234
|
+
}
|
|
235
|
+
async#verifyDistExportsReachable(pkg, peerExportsMaps) {
|
|
236
|
+
const exportsMaps = new Map(peerExportsMaps).set(pkg.name, await PackageExportsMap.from(pkg.dist.cwdPath));
|
|
237
|
+
const imports = await this.#collectDistAkanImports(pkg.dist.cwdPath, exportsMaps.keys());
|
|
238
|
+
const failures = [];
|
|
239
|
+
for (const [specifier, importers] of imports) {
|
|
240
|
+
const { name, subpath } = PackageRunner.#splitSpecifier(specifier);
|
|
241
|
+
const exportsMap = exportsMaps.get(name);
|
|
242
|
+
if (!exportsMap)
|
|
243
|
+
continue;
|
|
244
|
+
const [unreachable] = exportsMap.findUnreachable([subpath]);
|
|
245
|
+
if (!unreachable)
|
|
246
|
+
continue;
|
|
247
|
+
const reason = unreachable.target ? `its exports map yields ${unreachable.target}, which is not a file` : "no exports entry matches it";
|
|
248
|
+
const files = [...importers].sort();
|
|
249
|
+
const shown = files.slice(0, 3).join(", ") + (files.length > 3 ? ` (+${files.length - 3} more)` : "");
|
|
250
|
+
failures.push(` ${specifier} \u2014 ${reason}; imported by ${shown}`);
|
|
251
|
+
}
|
|
252
|
+
if (!failures.length)
|
|
253
|
+
return;
|
|
254
|
+
throw new Error(`[package] ${pkg.name} dist imports ${failures.length} subpath(s) no consumer can resolve:
|
|
255
|
+
` + `${failures.sort().join(`
|
|
256
|
+
`)}
|
|
257
|
+
` + `Add the missing "exports" entries: a bare file facet needs "./*": "./*.ts", a directory facet ` + `needs its own "./name": "./name/index.ts", and "./*.ts": "./*.ts" keeps an already-suffixed ` + `specifier from gaining a second extension.`);
|
|
258
|
+
}
|
|
259
|
+
async verifyDistPackage(pkg, {
|
|
260
|
+
peerExportsMaps = new Map
|
|
261
|
+
} = {}) {
|
|
115
262
|
const distPackageJsonPath = `${pkg.dist.cwdPath}/package.json`;
|
|
116
263
|
if (!await Bun.file(distPackageJsonPath).exists()) {
|
|
117
264
|
throw new Error(`[package] dist package not found for ${pkg.name}. Run build-package first.`);
|
|
@@ -142,6 +289,7 @@ class PackageRunner extends runner("package") {
|
|
|
142
289
|
throw new Error("[package] akanjs dist exports must point type declarations at ./types");
|
|
143
290
|
}
|
|
144
291
|
}
|
|
292
|
+
await this.#verifyDistExportsReachable(pkg, peerExportsMaps);
|
|
145
293
|
const packOutput = await pkg.workspace.spawn("npm", ["pack", "--dry-run", "--json", pkg.dist.cwdPath], {
|
|
146
294
|
cwd: pkg.workspace.workspaceRoot
|
|
147
295
|
});
|
|
@@ -154,9 +302,16 @@ class PackageRunner extends runner("package") {
|
|
|
154
302
|
};
|
|
155
303
|
}
|
|
156
304
|
async verifyAkanPublishPackages(workspace) {
|
|
305
|
+
const pkgs = PackageRunner.publishableAkanPackages.map((pkgName) => PkgExecutor.from(workspace, pkgName));
|
|
306
|
+
const peerExportsMaps = new Map;
|
|
307
|
+
for (const pkg of pkgs) {
|
|
308
|
+
if (!await Bun.file(`${pkg.dist.cwdPath}/package.json`).exists())
|
|
309
|
+
continue;
|
|
310
|
+
peerExportsMaps.set(pkg.name, await PackageExportsMap.from(pkg.dist.cwdPath));
|
|
311
|
+
}
|
|
157
312
|
const results = [];
|
|
158
|
-
for (const
|
|
159
|
-
results.push(await this.verifyDistPackage(
|
|
313
|
+
for (const pkg of pkgs) {
|
|
314
|
+
results.push(await this.verifyDistPackage(pkg, { peerExportsMaps }));
|
|
160
315
|
}
|
|
161
316
|
return results;
|
|
162
317
|
}
|
package/index.js
CHANGED
|
@@ -17,16 +17,16 @@ import path from "path";
|
|
|
17
17
|
|
|
18
18
|
// pkgs/@akanjs/cli/commandModules.ts
|
|
19
19
|
var commandModules = {
|
|
20
|
-
workspace: async () => (await import("./workspace.command-
|
|
20
|
+
workspace: async () => (await import("./workspace.command-875aj35r.js")).WorkspaceCommand,
|
|
21
21
|
agent: async () => (await import("./agent.command-h4afc69n.js")).AgentCommand,
|
|
22
22
|
application: async () => (await import("./application.command-47mj9qsy.js")).ApplicationCommand,
|
|
23
23
|
library: async () => (await import("./library.command-r15zdqvp.js")).LibraryCommand,
|
|
24
|
-
localRegistry: async () => (await import("./localRegistry.command-
|
|
25
|
-
package: async () => (await import("./package.command-
|
|
24
|
+
localRegistry: async () => (await import("./localRegistry.command-6z4s13mj.js")).LocalRegistryCommand,
|
|
25
|
+
package: async () => (await import("./package.command-5x5m0ej1.js")).PackageCommand,
|
|
26
26
|
module: async () => (await import("./module.command-qrj3kmyz.js")).ModuleCommand,
|
|
27
27
|
page: async () => (await import("./page.command-c6xdx0xm.js")).PageCommand,
|
|
28
28
|
context: async () => (await import("./context.command-nqbtak4f.js")).ContextCommand,
|
|
29
|
-
cloud: async () => (await import("./cloud.command-
|
|
29
|
+
cloud: async () => (await import("./cloud.command-hxcgsf80.js")).CloudCommand,
|
|
30
30
|
guideline: async () => (await import("./guideline.command-ya0dh44f.js")).GuidelineCommand,
|
|
31
31
|
scalar: async () => (await import("./scalar.command-kabkd6wd.js")).ScalarCommand,
|
|
32
32
|
primitive: async () => (await import("./primitive.command-pv9ssmtf.js")).PrimitiveCommand,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/cli",
|
|
3
|
-
"version": "2.4.1-rc.
|
|
3
|
+
"version": "2.4.1-rc.2",
|
|
4
4
|
"sourceType": "module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@langchain/openai": "^1.4.6",
|
|
35
35
|
"@tailwindcss/node": "^4.3.0",
|
|
36
36
|
"@trapezedev/project": "^7.1.4",
|
|
37
|
-
"akanjs": "2.4.1-rc.
|
|
37
|
+
"akanjs": "2.4.1-rc.2",
|
|
38
38
|
"chalk": "^5.6.2",
|
|
39
39
|
"commander": "^14.0.3",
|
|
40
40
|
"daisyui": "5.5.23",
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
import"./index-45aj5ry0.js";
|
|
6
6
|
import {
|
|
7
7
|
CloudScript
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-mq6ns0f9.js";
|
|
9
9
|
import"./index-y3hdhy4p.js";
|
|
10
10
|
import"./index-73pr2cmy.js";
|
|
11
11
|
import"./index-85msc0wg.js";
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
} from "./index-pmm9e2jf.js";
|
|
28
28
|
import {
|
|
29
29
|
PackageScript
|
|
30
|
-
} from "./index-
|
|
30
|
+
} from "./index-n6h3482q.js";
|
|
31
31
|
import"./index-8pkbzj26.js";
|
|
32
32
|
import"./index-swf4bmbg.js";
|
|
33
33
|
import"./index-ss469dec.js";
|