@sparkelf/dsh-plus 0.1.0-rc.36 → 0.1.0-rc.38
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/lib/bin.js +50 -4
- package/lib/types/standalone-profile.d.ts +17 -0
- package/lib/types/standalone-profile.js +52 -4
- package/package.json +1 -1
package/lib/bin.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { r as runApply } from "./apply-e0aMC4B4.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
5
|
-
import { createWriteStream, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { createWriteStream, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { dirname, join, posix, resolve, win32 } from "node:path";
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
8
|
import semver from "semver";
|
|
@@ -364,13 +364,59 @@ function installProfilePackages(paths, consumerDirectory) {
|
|
|
364
364
|
return;
|
|
365
365
|
}
|
|
366
366
|
runPnpm(paths.profileDirectory, ["install", "--no-frozen-lockfile"], "pnpm install in the plus profile");
|
|
367
|
+
alignReplacedPackageNames(profileModules);
|
|
367
368
|
linkNestedBundles(paths, profileModules);
|
|
368
369
|
}
|
|
369
|
-
/**
|
|
370
|
+
/**
|
|
371
|
+
* Make each replaced package declare the name of the location it occupies.
|
|
372
|
+
*
|
|
373
|
+
* \`overrides\` installs our build at the official path, but the manifest inside still
|
|
374
|
+
* names our scope. The client module system resolves a loader entry's declared name and
|
|
375
|
+
* then requires the manifest it finds to declare that same name
|
|
376
|
+
* (\`client/modules\`: \`name === expectedPackageName\`); a mismatch makes the package own no
|
|
377
|
+
* browser module at all. The symptom is silent — the packages install, the server starts,
|
|
378
|
+
* and the panels those packages render simply never appear.
|
|
379
|
+
*
|
|
380
|
+
* The rewrite replaces the file rather than writing through it: pnpm hard-links a package
|
|
381
|
+
* manifest into its content-addressed store, so an in-place write would edit every
|
|
382
|
+
* profile sharing that store entry.
|
|
383
|
+
*
|
|
384
|
+
* @param profileModules - the profile's \`node_modules\` directory.
|
|
385
|
+
*/
|
|
386
|
+
function alignReplacedPackageNames(profileModules) {
|
|
387
|
+
const scoped = join(profileModules, "@deepseek-ai");
|
|
388
|
+
if (!existsSync(scoped)) return;
|
|
389
|
+
for (const entry of readdirSync(scoped)) {
|
|
390
|
+
const manifestPath = join(scoped, entry, "package.json");
|
|
391
|
+
if (!existsSync(manifestPath)) continue;
|
|
392
|
+
const declared = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
393
|
+
const expected = "@deepseek-ai/" + entry;
|
|
394
|
+
if (declared.name === expected) continue;
|
|
395
|
+
const replaced = {
|
|
396
|
+
...declared,
|
|
397
|
+
name: expected
|
|
398
|
+
};
|
|
399
|
+
const temporary = manifestPath + ".dsh-name";
|
|
400
|
+
writeFileSync(temporary, JSON.stringify(replaced, null, 2) + "\n");
|
|
401
|
+
renameSync(temporary, manifestPath);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Run pnpm in one directory, inheriting its output.
|
|
406
|
+
*
|
|
407
|
+
* Windows resolves a command through its shell: \`spawnSync\` on a \`.cmd\` shim fails
|
|
408
|
+
* with EINVAL, so the call goes through \`cmd.exe\` there. This matches the runner in
|
|
409
|
+
* \`apply.ts\`, which the apply path has used on Windows since it shipped.
|
|
410
|
+
*
|
|
411
|
+
* @param cwd - the directory pnpm runs in.
|
|
412
|
+
* @param args - pnpm arguments, without the executable.
|
|
413
|
+
* @param label - the failing step's name, for the error.
|
|
414
|
+
*/
|
|
370
415
|
function runPnpm(cwd, args, label) {
|
|
371
|
-
const result = spawnSync(
|
|
416
|
+
const result = spawnSync("pnpm", [...args], {
|
|
372
417
|
cwd,
|
|
373
|
-
stdio: "inherit"
|
|
418
|
+
stdio: "inherit",
|
|
419
|
+
shell: process.platform === "win32"
|
|
374
420
|
});
|
|
375
421
|
if (result.error !== void 0) throw result.error;
|
|
376
422
|
if (result.status !== 0) throw new Error(label + " failed with exit code " + String(result.status));
|
|
@@ -77,6 +77,23 @@ export declare function readDistributionProfile(distributionDirectory: string):
|
|
|
77
77
|
* @param consumerDirectory - directory whose `node_modules` holds the installation.
|
|
78
78
|
*/
|
|
79
79
|
export declare function installProfilePackages(paths: StandalonePaths, consumerDirectory: string): void;
|
|
80
|
+
/**
|
|
81
|
+
* Make each replaced package declare the name of the location it occupies.
|
|
82
|
+
*
|
|
83
|
+
* \`overrides\` installs our build at the official path, but the manifest inside still
|
|
84
|
+
* names our scope. The client module system resolves a loader entry's declared name and
|
|
85
|
+
* then requires the manifest it finds to declare that same name
|
|
86
|
+
* (\`client/modules\`: \`name === expectedPackageName\`); a mismatch makes the package own no
|
|
87
|
+
* browser module at all. The symptom is silent — the packages install, the server starts,
|
|
88
|
+
* and the panels those packages render simply never appear.
|
|
89
|
+
*
|
|
90
|
+
* The rewrite replaces the file rather than writing through it: pnpm hard-links a package
|
|
91
|
+
* manifest into its content-addressed store, so an in-place write would edit every
|
|
92
|
+
* profile sharing that store entry.
|
|
93
|
+
*
|
|
94
|
+
* @param profileModules - the profile's \`node_modules\` directory.
|
|
95
|
+
*/
|
|
96
|
+
export declare function alignReplacedPackageNames(profileModules: string): void;
|
|
80
97
|
/** Resolve every path a command needs, without creating anything. */
|
|
81
98
|
export declare function resolvePaths(anchor: string, env?: NodeJS.ProcessEnv): StandalonePaths;
|
|
82
99
|
/**
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* bundle's own list.
|
|
10
10
|
*/
|
|
11
11
|
import { spawnSync } from 'node:child_process';
|
|
12
|
-
import { existsSync, mkdirSync, readdirSync, readFileSync, symlinkSync, writeFileSync } from 'node:fs';
|
|
12
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, symlinkSync, writeFileSync } from 'node:fs';
|
|
13
13
|
import { createRequire } from 'node:module';
|
|
14
14
|
import { homedir } from 'node:os';
|
|
15
15
|
import { dirname, join, posix, resolve, win32 } from 'node:path';
|
|
@@ -160,12 +160,60 @@ export function installProfilePackages(paths, consumerDirectory) {
|
|
|
160
160
|
return;
|
|
161
161
|
}
|
|
162
162
|
runPnpm(paths.profileDirectory, ['install', '--no-frozen-lockfile'], 'pnpm install in the plus profile');
|
|
163
|
+
alignReplacedPackageNames(profileModules);
|
|
163
164
|
linkNestedBundles(paths, profileModules);
|
|
164
165
|
}
|
|
165
|
-
/**
|
|
166
|
+
/**
|
|
167
|
+
* Make each replaced package declare the name of the location it occupies.
|
|
168
|
+
*
|
|
169
|
+
* \`overrides\` installs our build at the official path, but the manifest inside still
|
|
170
|
+
* names our scope. The client module system resolves a loader entry's declared name and
|
|
171
|
+
* then requires the manifest it finds to declare that same name
|
|
172
|
+
* (\`client/modules\`: \`name === expectedPackageName\`); a mismatch makes the package own no
|
|
173
|
+
* browser module at all. The symptom is silent — the packages install, the server starts,
|
|
174
|
+
* and the panels those packages render simply never appear.
|
|
175
|
+
*
|
|
176
|
+
* The rewrite replaces the file rather than writing through it: pnpm hard-links a package
|
|
177
|
+
* manifest into its content-addressed store, so an in-place write would edit every
|
|
178
|
+
* profile sharing that store entry.
|
|
179
|
+
*
|
|
180
|
+
* @param profileModules - the profile's \`node_modules\` directory.
|
|
181
|
+
*/
|
|
182
|
+
export function alignReplacedPackageNames(profileModules) {
|
|
183
|
+
const scoped = join(profileModules, '@deepseek-ai');
|
|
184
|
+
if (!existsSync(scoped))
|
|
185
|
+
return;
|
|
186
|
+
for (const entry of readdirSync(scoped)) {
|
|
187
|
+
const manifestPath = join(scoped, entry, 'package.json');
|
|
188
|
+
if (!existsSync(manifestPath))
|
|
189
|
+
continue;
|
|
190
|
+
const declared = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
|
191
|
+
const expected = '@deepseek-ai/' + entry;
|
|
192
|
+
if (declared.name === expected)
|
|
193
|
+
continue;
|
|
194
|
+
const replaced = { ...declared, name: expected };
|
|
195
|
+
const temporary = manifestPath + '.dsh-name';
|
|
196
|
+
writeFileSync(temporary, JSON.stringify(replaced, null, 2) + '\n');
|
|
197
|
+
renameSync(temporary, manifestPath);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Run pnpm in one directory, inheriting its output.
|
|
202
|
+
*
|
|
203
|
+
* Windows resolves a command through its shell: \`spawnSync\` on a \`.cmd\` shim fails
|
|
204
|
+
* with EINVAL, so the call goes through \`cmd.exe\` there. This matches the runner in
|
|
205
|
+
* \`apply.ts\`, which the apply path has used on Windows since it shipped.
|
|
206
|
+
*
|
|
207
|
+
* @param cwd - the directory pnpm runs in.
|
|
208
|
+
* @param args - pnpm arguments, without the executable.
|
|
209
|
+
* @param label - the failing step's name, for the error.
|
|
210
|
+
*/
|
|
166
211
|
function runPnpm(cwd, args, label) {
|
|
167
|
-
const
|
|
168
|
-
|
|
212
|
+
const result = spawnSync('pnpm', [...args], {
|
|
213
|
+
cwd,
|
|
214
|
+
stdio: 'inherit',
|
|
215
|
+
shell: process.platform === 'win32',
|
|
216
|
+
});
|
|
169
217
|
if (result.error !== undefined)
|
|
170
218
|
throw result.error;
|
|
171
219
|
if (result.status !== 0)
|
package/package.json
CHANGED