@jskit-ai/kernel 0.1.246 → 0.1.247

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.
@@ -207,10 +207,12 @@ async function discoverInstalledPackages({ appRoot } = {}) {
207
207
  }
208
208
 
209
209
  const packageJson = await readJsonFile(packageJsonPath, {});
210
- const manifestPackageId = String(packageJson.name || "").trim();
211
- if (manifestPackageId && manifestPackageId !== packageId) {
210
+ const packageMetadata = createPackageMetadata(packageJson);
211
+ // An npm alias ("alias": "npm:real@1") installs another package under the alias name,
212
+ // which is only an error for JSKIT packages.
213
+ if (packageMetadata && packageMetadata.packageId !== packageId) {
212
214
  throw new Error(
213
- `Installed package manifest mismatch: expected ${packageId}, received ${manifestPackageId}.`
215
+ `Installed package manifest mismatch: expected ${packageId}, received ${packageMetadata.packageId}.`
214
216
  );
215
217
  }
216
218
 
@@ -219,7 +221,6 @@ async function discoverInstalledPackages({ appRoot } = {}) {
219
221
  enqueue({ packageId: dependencyId, parentPackageRoot: roots.packageRoot });
220
222
  }
221
223
 
222
- const packageMetadata = createPackageMetadata(packageJson);
223
224
  if (!packageMetadata) {
224
225
  continue;
225
226
  }
@@ -115,3 +115,36 @@ test("discoverInstalledPackages excludes development-only packages from runtime
115
115
  const packages = await discoverInstalledPackages({ appRoot });
116
116
  assert.deepEqual(packages.map((entry) => entry.packageId), ["@example/runtime"]);
117
117
  });
118
+
119
+ test("discoverInstalledPackages walks npm alias dependencies but rejects aliased JSKIT packages", async (context) => {
120
+ const appRoot = await mkdtemp(path.join(tmpdir(), "jskit-installed-package-alias-"));
121
+ context.after(() => rm(appRoot, { recursive: true, force: true }));
122
+ const aliasRoot = path.join(appRoot, "node_modules", "@example", "sdk-v0_3");
123
+ const runtimeRoot = path.join(appRoot, "node_modules", "@example", "runtime");
124
+ await mkdir(aliasRoot, { recursive: true });
125
+ await mkdir(runtimeRoot, { recursive: true });
126
+ await writeFile(
127
+ path.join(appRoot, "package.json"),
128
+ JSON.stringify({ dependencies: { "@example/sdk-v0_3": "npm:@example/sdk@0.3.0" } })
129
+ );
130
+ await writeFile(
131
+ path.join(aliasRoot, "package.json"),
132
+ JSON.stringify({ name: "@example/sdk", version: "0.3.0", dependencies: { "@example/runtime": "1.0.0" } })
133
+ );
134
+ await writeFile(
135
+ path.join(runtimeRoot, "package.json"),
136
+ JSON.stringify({ name: "@example/runtime", version: "1.0.0", jskit: { kind: "runtime" } })
137
+ );
138
+
139
+ const packages = await discoverInstalledPackages({ appRoot });
140
+ assert.deepEqual(packages.map((entry) => entry.packageId), ["@example/runtime"]);
141
+
142
+ await writeFile(
143
+ path.join(aliasRoot, "package.json"),
144
+ JSON.stringify({ name: "@example/sdk", version: "0.3.0", jskit: { kind: "runtime" } })
145
+ );
146
+ await assert.rejects(
147
+ () => discoverInstalledPackages({ appRoot }),
148
+ /Installed package manifest mismatch: expected @example\/sdk-v0_3, received @example\/sdk\./
149
+ );
150
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/kernel",
3
- "version": "0.1.246",
3
+ "version": "0.1.247",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "json-rest-schema": "^1.0.17"