@jskit-ai/jskit-catalog 0.1.294 → 0.1.296
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/catalog/packages.json +268 -281
- package/package.json +1 -1
- package/scripts/build-catalog.mjs +9 -127
- package/scripts/framework-packages.mjs +52 -0
- package/scripts/verify-packages.mjs +4 -31
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import process from "node:process";
|
|
3
|
-
import {
|
|
3
|
+
import { writeFile, mkdir } from "node:fs/promises";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { collectSingletonPackageIds, discoverFrameworkPackages } from "./framework-packages.mjs";
|
|
5
6
|
import {
|
|
6
7
|
assertUniquePatternIds,
|
|
7
8
|
discoverPackagePatterns
|
|
8
9
|
} from "./pattern-assets.mjs";
|
|
10
|
+
import { discoverProjectManifests } from "./project-packages.mjs";
|
|
9
11
|
|
|
10
12
|
const SCRIPT_PATH = fileURLToPath(import.meta.url);
|
|
11
13
|
const PACKAGE_ROOT = path.resolve(path.dirname(SCRIPT_PATH), "..");
|
|
12
14
|
const DEFAULT_REPO_ROOT = path.resolve(PACKAGE_ROOT, "../..");
|
|
13
|
-
const BUILTIN_SINGLETON_PACKAGE_IDS = Object.freeze(["@jskit-ai/kernel"]);
|
|
14
15
|
|
|
15
16
|
function parseInlineArg(name) {
|
|
16
17
|
const args = process.argv.slice(2);
|
|
@@ -31,120 +32,13 @@ function parseInlineArg(name) {
|
|
|
31
32
|
return "";
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
function toSortedUniqueStrings(values) {
|
|
35
|
-
return [...new Set(values)].sort((left, right) => left.localeCompare(right));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async function fileExists(absolutePath) {
|
|
39
|
-
try {
|
|
40
|
-
await access(absolutePath);
|
|
41
|
-
return true;
|
|
42
|
-
} catch {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async function collectPackageRoots(packagesRoot) {
|
|
48
|
-
const directories = [];
|
|
49
|
-
const levelOne = await readdir(packagesRoot, { withFileTypes: true });
|
|
50
|
-
|
|
51
|
-
for (const entry of levelOne) {
|
|
52
|
-
if (!entry.isDirectory()) {
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
if (entry.name.startsWith(".")) {
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const absolute = path.join(packagesRoot, entry.name);
|
|
60
|
-
const packageJsonPath = path.join(absolute, "package.json");
|
|
61
|
-
if (await fileExists(packageJsonPath) && Object.keys((await readJson(packageJsonPath)).jskit || {}).length > 0) {
|
|
62
|
-
directories.push(absolute);
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const nested = await readdir(absolute, { withFileTypes: true }).catch(() => []);
|
|
67
|
-
for (const child of nested) {
|
|
68
|
-
if (!child.isDirectory() || child.name.startsWith(".")) {
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
const nestedAbsolute = path.join(absolute, child.name);
|
|
72
|
-
const nestedPackageJsonPath = path.join(nestedAbsolute, "package.json");
|
|
73
|
-
if (
|
|
74
|
-
await fileExists(nestedPackageJsonPath) &&
|
|
75
|
-
Object.keys((await readJson(nestedPackageJsonPath)).jskit || {}).length > 0
|
|
76
|
-
) {
|
|
77
|
-
directories.push(nestedAbsolute);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return toSortedUniqueStrings(directories);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function normalizeWorkspacePatterns(value) {
|
|
86
|
-
if (Array.isArray(value)) {
|
|
87
|
-
return value;
|
|
88
|
-
}
|
|
89
|
-
if (value && typeof value === "object" && Array.isArray(value.packages)) {
|
|
90
|
-
return value.packages;
|
|
91
|
-
}
|
|
92
|
-
return [];
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function createWorkspaceSegmentPattern(segment = "") {
|
|
96
|
-
const escaped = String(segment || "").replace(/[.+^${}()|[\]\\]/gu, "\\$&");
|
|
97
|
-
return new RegExp(`^${escaped.replace(/\*/gu, "[^/]*").replace(/\?/gu, "[^/]")}$`, "u");
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
async function expandWorkspacePattern(repoRoot, workspacePattern = "") {
|
|
101
|
-
const segments = String(workspacePattern || "")
|
|
102
|
-
.replace(/\\/gu, "/")
|
|
103
|
-
.replace(/^\.\//u, "")
|
|
104
|
-
.split("/")
|
|
105
|
-
.filter(Boolean);
|
|
106
|
-
if (segments.length < 1 || segments.includes("**")) {
|
|
107
|
-
return [];
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
let directories = [repoRoot];
|
|
111
|
-
for (const segment of segments) {
|
|
112
|
-
const matcher = createWorkspaceSegmentPattern(segment);
|
|
113
|
-
const nextDirectories = [];
|
|
114
|
-
for (const directory of directories) {
|
|
115
|
-
for (const entry of await readdir(directory, { withFileTypes: true }).catch(() => [])) {
|
|
116
|
-
if (entry.isDirectory() && matcher.test(entry.name)) {
|
|
117
|
-
nextDirectories.push(path.join(directory, entry.name));
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
directories = nextDirectories;
|
|
122
|
-
}
|
|
123
|
-
return directories;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
35
|
async function collectReleasePackageVersions(repoRoot) {
|
|
127
|
-
const
|
|
128
|
-
const workspacePatterns = normalizeWorkspacePatterns(rootPackageJson.workspaces)
|
|
129
|
-
.map((entry) => String(entry || "").trim())
|
|
130
|
-
.filter((entry) => entry && !entry.startsWith("!"));
|
|
131
|
-
const workspaceDirectories = new Set();
|
|
132
|
-
for (const workspacePattern of workspacePatterns) {
|
|
133
|
-
for (const directory of await expandWorkspacePattern(repoRoot, workspacePattern)) {
|
|
134
|
-
workspaceDirectories.add(directory);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
36
|
+
const rootManifestPath = path.join(repoRoot, "package.json");
|
|
138
37
|
const versions = new Map();
|
|
139
|
-
for (const
|
|
140
|
-
const packageJsonPath = path.join(directory, "package.json");
|
|
141
|
-
if (!(await fileExists(packageJsonPath))) {
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
const packageJson = await readJson(packageJsonPath);
|
|
38
|
+
for (const { absolutePath, value: packageJson } of await discoverProjectManifests(repoRoot)) {
|
|
145
39
|
const packageId = String(packageJson?.name || "").trim();
|
|
146
40
|
const version = String(packageJson?.version || "").trim();
|
|
147
|
-
if (!packageId.startsWith("@jskit-ai/") || packageJson.private === true) {
|
|
41
|
+
if (absolutePath === rootManifestPath || !packageId.startsWith("@jskit-ai/") || packageJson.private === true) {
|
|
148
42
|
continue;
|
|
149
43
|
}
|
|
150
44
|
if (!/^\d+\.\d+\.\d+$/u.test(version)) {
|
|
@@ -156,19 +50,12 @@ async function collectReleasePackageVersions(repoRoot) {
|
|
|
156
50
|
return Object.fromEntries([...versions].sort(([left], [right]) => left.localeCompare(right)));
|
|
157
51
|
}
|
|
158
52
|
|
|
159
|
-
async function readJson(absolutePath) {
|
|
160
|
-
const raw = await readFile(absolutePath, "utf8");
|
|
161
|
-
return JSON.parse(raw);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
53
|
async function buildCatalog({ repoRoot, packagesRoot, outputPath }) {
|
|
165
|
-
const
|
|
54
|
+
const frameworkPackages = await discoverFrameworkPackages(packagesRoot);
|
|
166
55
|
const entries = [];
|
|
167
56
|
const patterns = [];
|
|
168
57
|
|
|
169
|
-
for (const packageRoot of
|
|
170
|
-
const packageJsonPath = path.join(packageRoot, "package.json");
|
|
171
|
-
const packageJson = await readJson(packageJsonPath);
|
|
58
|
+
for (const { packageRoot, manifestPath: packageJsonPath, packageJson } of frameworkPackages) {
|
|
172
59
|
const packageId = String(packageJson?.name || "").trim();
|
|
173
60
|
const version = String(packageJson?.version || "").trim();
|
|
174
61
|
const jskit = packageJson?.jskit && typeof packageJson.jskit === "object" && !Array.isArray(packageJson.jskit)
|
|
@@ -214,12 +101,7 @@ async function buildCatalog({ repoRoot, packagesRoot, outputPath }) {
|
|
|
214
101
|
},
|
|
215
102
|
release: {
|
|
216
103
|
packages: await collectReleasePackageVersions(repoRoot),
|
|
217
|
-
singletonPackages:
|
|
218
|
-
...BUILTIN_SINGLETON_PACKAGE_IDS,
|
|
219
|
-
...entries
|
|
220
|
-
.filter((entry) => entry?.jskit?.metadata?.client?.singleton === true)
|
|
221
|
-
.map((entry) => entry.packageId)
|
|
222
|
-
])
|
|
104
|
+
singletonPackages: collectSingletonPackageIds(frameworkPackages.map(({ packageJson }) => packageJson))
|
|
223
105
|
},
|
|
224
106
|
packages: entries.sort((left, right) => left.packageId.localeCompare(right.packageId)),
|
|
225
107
|
patterns: patterns.sort((left, right) => left.id.localeCompare(right.id))
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { access, readdir, readFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
const BUILTIN_SINGLETON_PACKAGE_IDS = Object.freeze(["@jskit-ai/kernel"]);
|
|
5
|
+
|
|
6
|
+
async function fileExists(filePath) {
|
|
7
|
+
try {
|
|
8
|
+
await access(filePath);
|
|
9
|
+
return true;
|
|
10
|
+
} catch {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// The JSKIT framework packages are the direct children of packagesRoot whose
|
|
16
|
+
// package.json declares `jskit` metadata. The catalog builder and the package
|
|
17
|
+
// verifier both read this one set.
|
|
18
|
+
async function discoverFrameworkPackages(packagesRoot) {
|
|
19
|
+
const packages = [];
|
|
20
|
+
for (const entry of await readdir(packagesRoot, { withFileTypes: true })) {
|
|
21
|
+
if (!entry.isDirectory()) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const packageRoot = path.join(packagesRoot, entry.name);
|
|
25
|
+
const manifestPath = path.join(packageRoot, "package.json");
|
|
26
|
+
if (!(await fileExists(manifestPath))) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const packageJson = JSON.parse(await readFile(manifestPath, "utf8"));
|
|
30
|
+
if (!packageJson.jskit) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
packages.push({ packageRoot, manifestPath, packageJson });
|
|
34
|
+
}
|
|
35
|
+
return packages.sort((left, right) => String(left.packageJson.name || "").localeCompare(String(right.packageJson.name || "")));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Packages that own shared client runtime state: the kernel plus every package
|
|
39
|
+
// marked `jskit.metadata.client.singleton`.
|
|
40
|
+
function collectSingletonPackageIds(packageJsons) {
|
|
41
|
+
return [...new Set([
|
|
42
|
+
...BUILTIN_SINGLETON_PACKAGE_IDS,
|
|
43
|
+
...packageJsons
|
|
44
|
+
.filter((packageJson) => packageJson?.jskit?.metadata?.client?.singleton === true)
|
|
45
|
+
.map((packageJson) => packageJson.name)
|
|
46
|
+
])].sort((left, right) => left.localeCompare(right));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
collectSingletonPackageIds,
|
|
51
|
+
discoverFrameworkPackages
|
|
52
|
+
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { access,
|
|
2
|
+
import { access, readdir } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
5
|
import {
|
|
6
6
|
assertUniquePatternIds,
|
|
7
7
|
discoverPackagePatterns
|
|
8
8
|
} from "./pattern-assets.mjs";
|
|
9
|
+
import { collectSingletonPackageIds, discoverFrameworkPackages } from "./framework-packages.mjs";
|
|
9
10
|
|
|
10
11
|
const SCRIPT_PATH = fileURLToPath(import.meta.url);
|
|
11
12
|
const REPO_ROOT = path.resolve(path.dirname(SCRIPT_PATH), "../../..");
|
|
@@ -32,7 +33,6 @@ const BUILTIN_CAPABILITIES = new Set([
|
|
|
32
33
|
"runtime.http",
|
|
33
34
|
"runtime.logger"
|
|
34
35
|
]);
|
|
35
|
-
const BUILTIN_SINGLETON_PACKAGE_IDS = new Set(["@jskit-ai/kernel"]);
|
|
36
36
|
const ALLOWED_JSKIT_FIELDS = new Set([
|
|
37
37
|
"capabilities",
|
|
38
38
|
"kind",
|
|
@@ -58,26 +58,6 @@ async function fileExists(filePath) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
async function discoverFrameworkPackages() {
|
|
62
|
-
const packages = [];
|
|
63
|
-
for (const entry of await readdir(PACKAGES_ROOT, { withFileTypes: true })) {
|
|
64
|
-
if (!entry.isDirectory()) {
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
const packageRoot = path.join(PACKAGES_ROOT, entry.name);
|
|
68
|
-
const manifestPath = path.join(packageRoot, "package.json");
|
|
69
|
-
if (!(await fileExists(manifestPath))) {
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
const packageJson = JSON.parse(await readFile(manifestPath, "utf8"));
|
|
73
|
-
if (!packageJson.jskit) {
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
packages.push({ packageRoot, manifestPath, packageJson });
|
|
77
|
-
}
|
|
78
|
-
return packages.sort((left, right) => left.packageJson.name.localeCompare(right.packageJson.name));
|
|
79
|
-
}
|
|
80
|
-
|
|
81
61
|
function requireStringArray(value, label) {
|
|
82
62
|
if (!Array.isArray(value) || value.some((item) => !String(item || "").trim())) {
|
|
83
63
|
throw new Error(`${label} must be an array of non-empty strings.`);
|
|
@@ -324,14 +304,7 @@ function validateCapabilityClosure(packages, { builtinCapabilities = BUILTIN_CAP
|
|
|
324
304
|
}
|
|
325
305
|
|
|
326
306
|
function validateSingletonPeerDependencies(packages) {
|
|
327
|
-
const singletonPackageIds = new Set(
|
|
328
|
-
[
|
|
329
|
-
...BUILTIN_SINGLETON_PACKAGE_IDS,
|
|
330
|
-
...packages
|
|
331
|
-
.filter(({ packageJson }) => packageJson.jskit?.metadata?.client?.singleton === true)
|
|
332
|
-
.map(({ packageJson }) => packageJson.name)
|
|
333
|
-
]
|
|
334
|
-
);
|
|
307
|
+
const singletonPackageIds = new Set(collectSingletonPackageIds(packages.map(({ packageJson }) => packageJson)));
|
|
335
308
|
|
|
336
309
|
for (const { packageJson } of packages) {
|
|
337
310
|
for (const section of ["dependencies", "optionalDependencies"]) {
|
|
@@ -349,7 +322,7 @@ function validateSingletonPeerDependencies(packages) {
|
|
|
349
322
|
}
|
|
350
323
|
|
|
351
324
|
async function main() {
|
|
352
|
-
const packages = await discoverFrameworkPackages();
|
|
325
|
+
const packages = await discoverFrameworkPackages(PACKAGES_ROOT);
|
|
353
326
|
const localVersions = new Map(packages.map(({ packageJson }) => [packageJson.name, packageJson.version]));
|
|
354
327
|
const migrationOwners = new Map();
|
|
355
328
|
const patterns = [];
|