dsh-client-auto-continue 0.10.1 → 0.10.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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-client-auto-continue",
|
|
3
3
|
"description": "DSH Web UI plugin: automatically sends a localized continue prompt when a request is interrupted by network errors or other non-human causes",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/types/index.d.ts",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"build": "node build.mjs && tsc -p tsconfig.build.json",
|
|
47
47
|
"watch": "node build.mjs --watch",
|
|
48
48
|
"typecheck": "tsc --noEmit",
|
|
49
|
-
"test": "node tests/simulate-host.mjs && node tests/simulate-client-loader.mjs",
|
|
49
|
+
"test": "node tests/simulate-host.mjs && node tests/simulate-client-loader.mjs && node tests/prepare-github-package.mjs",
|
|
50
50
|
"prepack": "npm run build"
|
|
51
51
|
},
|
|
52
52
|
"keywords": [
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
export const SOURCE_PACKAGE_NAME = 'dsh-client-auto-continue';
|
|
6
|
+
export const GITHUB_PACKAGE_NAME = '@hsiangnianian/dsh-auto-continue';
|
|
7
|
+
|
|
8
|
+
const sourceEntry = `name: '${SOURCE_PACKAGE_NAME}'`;
|
|
9
|
+
const githubEntry = `name: '${GITHUB_PACKAGE_NAME}'`;
|
|
10
|
+
|
|
11
|
+
/** Rewrite the publish-only package identity and its DSH loader row together. */
|
|
12
|
+
export function prepareGitHubPackage(root) {
|
|
13
|
+
const manifestPath = join(root, 'package.json');
|
|
14
|
+
const patchPath = join(root, 'cordis.patch.yml');
|
|
15
|
+
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
|
16
|
+
const patch = readFileSync(patchPath, 'utf8');
|
|
17
|
+
|
|
18
|
+
if (manifest.name !== SOURCE_PACKAGE_NAME) {
|
|
19
|
+
throw new Error(`Expected package name ${SOURCE_PACKAGE_NAME}, received ${String(manifest.name)}`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const entryCount = patch.split(sourceEntry).length - 1;
|
|
23
|
+
if (entryCount !== 1) {
|
|
24
|
+
throw new Error(`Cordis patch must reference ${SOURCE_PACKAGE_NAME} exactly once`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
manifest.name = GITHUB_PACKAGE_NAME;
|
|
28
|
+
writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
|
|
29
|
+
writeFileSync(patchPath, patch.replace(sourceEntry, githubEntry));
|
|
30
|
+
|
|
31
|
+
return { sourceName: SOURCE_PACKAGE_NAME, packageName: GITHUB_PACKAGE_NAME };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const scriptPath = fileURLToPath(import.meta.url);
|
|
35
|
+
if (process.argv[1] && resolve(process.argv[1]) === scriptPath) {
|
|
36
|
+
const root = process.argv[2] ? resolve(process.argv[2]) : resolve(dirname(scriptPath), '..');
|
|
37
|
+
const result = prepareGitHubPackage(root);
|
|
38
|
+
console.log(`Prepared ${result.packageName} from ${result.sourceName}`);
|
|
39
|
+
}
|