dsh-wechat-remote 1.7.3 → 1.7.5

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.
@@ -1,210 +1,210 @@
1
- /* Generated from the shared plugin installation sources. */
2
-
3
- // src/install-profile.ts
4
- import fs from "node:fs";
5
- import path from "node:path";
6
- import { spawn } from "node:child_process";
7
- import { createHash } from "node:crypto";
8
-
9
- // src/secure-file.ts
10
- import { execFileSync } from "node:child_process";
11
- import {
12
- chmodSync,
13
- closeSync,
14
- existsSync,
15
- fsyncSync,
16
- mkdirSync,
17
- openSync,
18
- readFileSync,
19
- renameSync,
20
- rmSync,
21
- writeFileSync
22
- } from "node:fs";
23
- import { dirname } from "node:path";
24
- import { userInfo } from "node:os";
25
- import { randomBytes } from "node:crypto";
26
- function tightenPrivateFile(file) {
27
- try {
28
- chmodSync(file, 384);
29
- } catch {
30
- }
31
- if (process.platform !== "win32") return;
32
- try {
33
- execFileSync("icacls", [file, "/inheritance:r", "/grant:r", `${userInfo().username}:F`], {
34
- timeout: 5e3,
35
- windowsHide: true,
36
- stdio: "ignore"
37
- });
38
- } catch {
39
- }
40
- }
41
- function writePrivateJsonAtomic(file, value) {
42
- const parent = dirname(file);
43
- mkdirSync(parent, { recursive: true, mode: 448 });
44
- const temporary = `${file}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`;
45
- try {
46
- writeFileSync(temporary, `${JSON.stringify(value, null, 2)}
47
- `, {
48
- encoding: "utf8",
49
- mode: 384,
50
- flag: "wx"
51
- });
52
- const fd = openSync(temporary, "r+");
53
- try {
54
- try {
55
- fsyncSync(fd);
56
- } catch {
57
- }
58
- } finally {
59
- closeSync(fd);
60
- }
61
- tightenPrivateFile(temporary);
62
- renameSync(temporary, file);
63
- tightenPrivateFile(file);
64
- } finally {
65
- if (existsSync(temporary)) {
66
- try {
67
- rmSync(temporary, { force: true });
68
- } catch {
69
- }
70
- }
71
- }
72
- }
73
-
74
- // src/install-runtime.ts
75
- var INSTALL_PNPM_VERSION = "11.22.0";
76
-
77
- // src/install-profile.ts
78
- var PLUGIN_PACKAGE = "@harness-remote/dsh-wechat-remote";
79
- function safeProfileName(value) {
80
- return /^[A-Za-z0-9_-]{1,80}$/.test(value);
81
- }
82
- var hash = (file) => createHash("sha256").update(fs.readFileSync(file)).digest("hex");
83
- function assertRelocatableProfile(root) {
84
- const walk = (directory) => {
85
- for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
86
- const file = path.join(directory, entry.name);
87
- if (entry.isSymbolicLink()) {
88
- const relative = path.relative(root, fs.realpathSync(file));
89
- if (path.isAbsolute(fs.readlinkSync(file)) || !relative || relative.startsWith("..") || path.isAbsolute(relative)) {
90
- throw new Error("\u63D2\u4EF6\u4F9D\u8D56\u5305\u542B\u4E0D\u53EF\u8FC1\u79FB\u7684\u94FE\u63A5\uFF0C\u672A\u4FEE\u6539\u5F53\u524D\u5B89\u88C5\u3002");
91
- }
92
- } else if (entry.isDirectory()) walk(file);
93
- }
94
- };
95
- walk(root);
96
- }
97
- function installToolPath(directory, runtime) {
98
- const bin = path.join(directory, "tool-bin");
99
- fs.mkdirSync(bin, { mode: 448 });
100
- const runner = path.join(bin, "pnpm-run.cjs");
101
- fs.writeFileSync(runner, `require('node:child_process').spawnSync(${JSON.stringify(runtime.executable)},[${JSON.stringify(runtime.cli)},...process.argv.slice(2)],{stdio:'inherit',shell:false,windowsHide:true}).status===0?process.exit(0):process.exit(1)
102
- `, { mode: 384 });
103
- if (process.platform === "win32") {
104
- if (/["\r\n]/.test(runtime.executable)) throw new Error("Node \u5B89\u88C5\u8DEF\u5F84\u4E0D\u53D7\u652F\u6301\u3002");
105
- fs.writeFileSync(path.join(bin, "pnpm.cmd"), `@echo off\r
106
- "${runtime.executable.replace(/%/g, "%%")}" "%~dp0pnpm-run.cjs" %*\r
107
- `, { mode: 448 });
108
- } else {
109
- const quote = (s) => "'" + s.replace(/'/g, `'"'"'`) + "'";
110
- fs.writeFileSync(path.join(bin, "pnpm"), `#!/bin/sh
111
- exec ${quote(runtime.executable)} ${quote(runner)} "$@"
112
- `, { mode: 448 });
113
- }
114
- return bin;
115
- }
116
- function runNativePlugin(cli, profile, home, toolPath, runtime, logFile) {
117
- if (!safeProfileName(profile)) throw new Error("\u65E0\u6548\u7684 DSH profile \u540D\u79F0\u3002");
118
- return new Promise((resolve, reject) => {
119
- const log = fs.openSync(logFile, "a", 384);
120
- const child = spawn(runtime.executable, [
121
- cli,
122
- "plugin",
123
- "--profile",
124
- profile,
125
- "add",
126
- "file:harness-remote-update.tgz",
127
- "--ignore-scripts",
128
- "--config.frozen-lockfile=false",
129
- "--prefer-offline",
130
- "--config.manage-package-manager-versions=false",
131
- "--reporter=append-only"
132
- ], {
133
- cwd: home,
134
- shell: false,
135
- windowsHide: true,
136
- stdio: ["ignore", log, log],
137
- env: {
138
- ...process.env,
139
- DSH_HOME: home,
140
- PATH: toolPath + path.delimiter + (process.env.PATH || ""),
141
- CI: "true",
142
- COREPACK_ENABLE_AUTO_PIN: "0",
143
- npm_config_manage_package_manager_versions: "false"
144
- }
145
- });
146
- fs.closeSync(log);
147
- const timer = setTimeout(() => {
148
- child.kill();
149
- reject(new Error("\u4E0B\u8F7D\u6216\u5B89\u88C5\u8D85\u65F6\uFF0C\u539F\u63D2\u4EF6\u672A\u66FF\u6362\u3002"));
150
- }, 24e4);
151
- child.once("error", () => {
152
- clearTimeout(timer);
153
- reject(new Error("\u65E0\u6CD5\u542F\u52A8 DSH \u539F\u751F\u5B89\u88C5\u7A0B\u5E8F\u3002"));
154
- });
155
- child.once("close", (code) => {
156
- clearTimeout(timer);
157
- code === 0 ? resolve() : reject(new Error("\u5B89\u88C5\u672A\u5B8C\u6210\uFF0C\u539F\u63D2\u4EF6\u672A\u66FF\u6362\uFF1B\u8BE6\u60C5\u5DF2\u4FDD\u7559\u5728\u672C\u673A\u5B89\u88C5\u65E5\u5FD7\u3002"));
158
- });
159
- });
160
- }
161
- async function stageProfile(job) {
162
- const scope = path.basename(job.profile);
163
- if (!safeProfileName(scope) || !fs.statSync(job.directory).isDirectory()) throw new Error("\u5B89\u88C5\u76EE\u6807\u4E0D\u660E\u786E\u3002");
164
- const stagingHome = path.join(job.directory, "staging-home"), staged = path.join(stagingHome, "profiles", scope);
165
- fs.mkdirSync(staged, { recursive: true, mode: 448 });
166
- if (fs.existsSync(job.profile)) {
167
- if (fs.lstatSync(job.profile).isSymbolicLink() || fs.realpathSync(job.profile) !== path.resolve(job.profile)) throw new Error("\u4E0D\u652F\u6301\u81EA\u52A8\u66FF\u6362\u94FE\u63A5\u5F62\u5F0F\u7684 profile\u3002");
168
- fs.cpSync(job.profile, staged, {
169
- recursive: true,
170
- dereference: false,
171
- filter: (p) => !["node_modules", ".harness-remote-update.lock"].includes(path.basename(p))
172
- });
173
- }
174
- let before = null;
175
- const filename = path.join(staged, "package.json");
176
- if (fs.existsSync(filename)) {
177
- before = JSON.parse(fs.readFileSync(filename, "utf8"));
178
- for (const [name, spec] of Object.entries(before.dependencies || {})) {
179
- if (name !== PLUGIN_PACKAGE && !/^[~^]?\d+\.\d+\.\d+(?:-[\w.-]+)?$/.test(String(spec))) throw new Error("\u5176\u4ED6\u63D2\u4EF6\u4F7F\u7528\u4E86\u672C\u5730\u94FE\u63A5\u6216\u7279\u6B8A\u6765\u6E90\uFF0C\u672A\u4FEE\u6539\u5F53\u524D\u5B89\u88C5\u3002");
180
- }
181
- for (const e of fs.readdirSync(staged, { withFileTypes: true })) if (e.isSymbolicLink()) throw new Error("profile \u914D\u7F6E\u5305\u542B\u94FE\u63A5\uFF0C\u672A\u4FEE\u6539\u5F53\u524D\u5B89\u88C5\u3002");
182
- if (before.packageManager && !/^pnpm@\d+\.\d+\.\d+(?:\+.*)?$/.test(before.packageManager)) throw new Error("\u5F53\u524D profile \u4F7F\u7528\u4E86\u5176\u4ED6\u5305\u7BA1\u7406\u5668\uFF0C\u672A\u4FEE\u6539\u5B89\u88C5\u3002");
183
- writePrivateJsonAtomic(filename, { ...before, dependencies: {
184
- ...before.dependencies,
185
- [PLUGIN_PACKAGE]: "file:harness-remote-update.tgz"
186
- }, packageManager: `pnpm@${INSTALL_PNPM_VERSION}` });
187
- }
188
- fs.copyFileSync(path.join(job.directory, "release.tgz"), path.join(staged, "harness-remote-update.tgz"));
189
- const tools = installToolPath(job.directory, job.runtime);
190
- await runNativePlugin(job.cli, scope, stagingHome, tools, job.runtime, path.join(job.directory, "install.log"));
191
- const installed = fs.realpathSync(path.join(staged, "node_modules", PLUGIN_PACKAGE));
192
- const relative = path.relative(staged, installed);
193
- if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) throw new Error("\u6682\u5B58\u63D2\u4EF6\u4E0D\u5728\u5B89\u88C5\u76EE\u5F55\u5185\u3002");
194
- if (JSON.parse(fs.readFileSync(path.join(installed, "package.json"), "utf8")).version !== job.targetVersion) throw new Error("\u5B89\u88C5\u540E\u63D2\u4EF6\u7248\u672C\u4E0D\u5339\u914D\u3002");
195
- const after = JSON.parse(fs.readFileSync(filename, "utf8"));
196
- if (!after.dsh?.profile?.bundles?.includes(PLUGIN_PACKAGE)) throw new Error("DSH \u5C1A\u672A\u5C06\u63D2\u4EF6\u6CE8\u518C\u4E3A\u539F\u751F profile \u5C42\u3002");
197
- for (const name of Object.keys(before?.dependencies || {})) if (name !== PLUGIN_PACKAGE) {
198
- if (hash(path.join(job.profile, "node_modules", name, "package.json")) !== hash(path.join(staged, "node_modules", name, "package.json"))) throw new Error("\u5B89\u88C5\u8BD5\u56FE\u6539\u53D8\u5176\u4ED6\u63D2\u4EF6\uFF0C\u539F\u5B89\u88C5\u4FDD\u6301\u4E0D\u53D8\u3002");
199
- }
200
- assertRelocatableProfile(staged);
201
- return staged;
202
- }
203
- export {
204
- PLUGIN_PACKAGE,
205
- assertRelocatableProfile,
206
- installToolPath,
207
- runNativePlugin,
208
- safeProfileName,
209
- stageProfile
210
- };
1
+ /* Generated from the shared plugin installation sources. */
2
+
3
+ // src/install-profile.ts
4
+ import fs from "node:fs";
5
+ import path from "node:path";
6
+ import { spawn } from "node:child_process";
7
+ import { createHash } from "node:crypto";
8
+
9
+ // src/secure-file.ts
10
+ import { execFileSync } from "node:child_process";
11
+ import {
12
+ chmodSync,
13
+ closeSync,
14
+ existsSync,
15
+ fsyncSync,
16
+ mkdirSync,
17
+ openSync,
18
+ readFileSync,
19
+ renameSync,
20
+ rmSync,
21
+ writeFileSync
22
+ } from "node:fs";
23
+ import { dirname } from "node:path";
24
+ import { userInfo } from "node:os";
25
+ import { randomBytes } from "node:crypto";
26
+ function tightenPrivateFile(file) {
27
+ try {
28
+ chmodSync(file, 384);
29
+ } catch {
30
+ }
31
+ if (process.platform !== "win32") return;
32
+ try {
33
+ execFileSync("icacls", [file, "/inheritance:r", "/grant:r", `${userInfo().username}:F`], {
34
+ timeout: 5e3,
35
+ windowsHide: true,
36
+ stdio: "ignore"
37
+ });
38
+ } catch {
39
+ }
40
+ }
41
+ function writePrivateJsonAtomic(file, value) {
42
+ const parent = dirname(file);
43
+ mkdirSync(parent, { recursive: true, mode: 448 });
44
+ const temporary = `${file}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`;
45
+ try {
46
+ writeFileSync(temporary, `${JSON.stringify(value, null, 2)}
47
+ `, {
48
+ encoding: "utf8",
49
+ mode: 384,
50
+ flag: "wx"
51
+ });
52
+ const fd = openSync(temporary, "r+");
53
+ try {
54
+ try {
55
+ fsyncSync(fd);
56
+ } catch {
57
+ }
58
+ } finally {
59
+ closeSync(fd);
60
+ }
61
+ tightenPrivateFile(temporary);
62
+ renameSync(temporary, file);
63
+ tightenPrivateFile(file);
64
+ } finally {
65
+ if (existsSync(temporary)) {
66
+ try {
67
+ rmSync(temporary, { force: true });
68
+ } catch {
69
+ }
70
+ }
71
+ }
72
+ }
73
+
74
+ // src/install-runtime.ts
75
+ var INSTALL_PNPM_VERSION = "11.22.0";
76
+
77
+ // src/install-profile.ts
78
+ var PLUGIN_PACKAGE = "@harness-remote/dsh-wechat-remote";
79
+ function safeProfileName(value) {
80
+ return /^[A-Za-z0-9_-]{1,80}$/.test(value);
81
+ }
82
+ var hash = (file) => createHash("sha256").update(fs.readFileSync(file)).digest("hex");
83
+ function assertRelocatableProfile(root) {
84
+ const walk = (directory) => {
85
+ for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
86
+ const file = path.join(directory, entry.name);
87
+ if (entry.isSymbolicLink()) {
88
+ const relative = path.relative(root, fs.realpathSync(file));
89
+ if (path.isAbsolute(fs.readlinkSync(file)) || !relative || relative.startsWith("..") || path.isAbsolute(relative)) {
90
+ throw new Error("\u63D2\u4EF6\u4F9D\u8D56\u5305\u542B\u4E0D\u53EF\u8FC1\u79FB\u7684\u94FE\u63A5\uFF0C\u672A\u4FEE\u6539\u5F53\u524D\u5B89\u88C5\u3002");
91
+ }
92
+ } else if (entry.isDirectory()) walk(file);
93
+ }
94
+ };
95
+ walk(root);
96
+ }
97
+ function installToolPath(directory, runtime) {
98
+ const bin = path.join(directory, "tool-bin");
99
+ fs.mkdirSync(bin, { mode: 448 });
100
+ const runner = path.join(bin, "pnpm-run.cjs");
101
+ fs.writeFileSync(runner, `require('node:child_process').spawnSync(${JSON.stringify(runtime.executable)},[${JSON.stringify(runtime.cli)},...process.argv.slice(2)],{stdio:'inherit',shell:false,windowsHide:true}).status===0?process.exit(0):process.exit(1)
102
+ `, { mode: 384 });
103
+ if (process.platform === "win32") {
104
+ if (/["\r\n]/.test(runtime.executable)) throw new Error("Node \u5B89\u88C5\u8DEF\u5F84\u4E0D\u53D7\u652F\u6301\u3002");
105
+ fs.writeFileSync(path.join(bin, "pnpm.cmd"), `@echo off\r
106
+ "${runtime.executable.replace(/%/g, "%%")}" "%~dp0pnpm-run.cjs" %*\r
107
+ `, { mode: 448 });
108
+ } else {
109
+ const quote = (s) => "'" + s.replace(/'/g, `'"'"'`) + "'";
110
+ fs.writeFileSync(path.join(bin, "pnpm"), `#!/bin/sh
111
+ exec ${quote(runtime.executable)} ${quote(runner)} "$@"
112
+ `, { mode: 448 });
113
+ }
114
+ return bin;
115
+ }
116
+ function runNativePlugin(cli, profile, home, toolPath, runtime, logFile) {
117
+ if (!safeProfileName(profile)) throw new Error("\u65E0\u6548\u7684 DSH profile \u540D\u79F0\u3002");
118
+ return new Promise((resolve, reject) => {
119
+ const log = fs.openSync(logFile, "a", 384);
120
+ const child = spawn(runtime.executable, [
121
+ cli,
122
+ "plugin",
123
+ "--profile",
124
+ profile,
125
+ "add",
126
+ "file:harness-remote-update.tgz",
127
+ "--ignore-scripts",
128
+ "--config.frozen-lockfile=false",
129
+ "--prefer-offline",
130
+ "--config.manage-package-manager-versions=false",
131
+ "--reporter=append-only"
132
+ ], {
133
+ cwd: home,
134
+ shell: false,
135
+ windowsHide: true,
136
+ stdio: ["ignore", log, log],
137
+ env: {
138
+ ...process.env,
139
+ DSH_HOME: home,
140
+ PATH: toolPath + path.delimiter + (process.env.PATH || ""),
141
+ CI: "true",
142
+ COREPACK_ENABLE_AUTO_PIN: "0",
143
+ npm_config_manage_package_manager_versions: "false"
144
+ }
145
+ });
146
+ fs.closeSync(log);
147
+ const timer = setTimeout(() => {
148
+ child.kill();
149
+ reject(new Error("\u4E0B\u8F7D\u6216\u5B89\u88C5\u8D85\u65F6\uFF0C\u539F\u63D2\u4EF6\u672A\u66FF\u6362\u3002"));
150
+ }, 24e4);
151
+ child.once("error", () => {
152
+ clearTimeout(timer);
153
+ reject(new Error("\u65E0\u6CD5\u542F\u52A8 DSH \u539F\u751F\u5B89\u88C5\u7A0B\u5E8F\u3002"));
154
+ });
155
+ child.once("close", (code) => {
156
+ clearTimeout(timer);
157
+ code === 0 ? resolve() : reject(new Error("\u5B89\u88C5\u672A\u5B8C\u6210\uFF0C\u539F\u63D2\u4EF6\u672A\u66FF\u6362\uFF1B\u8BE6\u60C5\u5DF2\u4FDD\u7559\u5728\u672C\u673A\u5B89\u88C5\u65E5\u5FD7\u3002"));
158
+ });
159
+ });
160
+ }
161
+ async function stageProfile(job) {
162
+ const scope = path.basename(job.profile);
163
+ if (!safeProfileName(scope) || !fs.statSync(job.directory).isDirectory()) throw new Error("\u5B89\u88C5\u76EE\u6807\u4E0D\u660E\u786E\u3002");
164
+ const stagingHome = path.join(job.directory, "staging-home"), staged = path.join(stagingHome, "profiles", scope);
165
+ fs.mkdirSync(staged, { recursive: true, mode: 448 });
166
+ if (fs.existsSync(job.profile)) {
167
+ if (fs.lstatSync(job.profile).isSymbolicLink() || fs.realpathSync(job.profile) !== path.resolve(job.profile)) throw new Error("\u4E0D\u652F\u6301\u81EA\u52A8\u66FF\u6362\u94FE\u63A5\u5F62\u5F0F\u7684 profile\u3002");
168
+ fs.cpSync(job.profile, staged, {
169
+ recursive: true,
170
+ dereference: false,
171
+ filter: (p) => !["node_modules", ".harness-remote-update.lock"].includes(path.basename(p))
172
+ });
173
+ }
174
+ let before = null;
175
+ const filename = path.join(staged, "package.json");
176
+ if (fs.existsSync(filename)) {
177
+ before = JSON.parse(fs.readFileSync(filename, "utf8"));
178
+ for (const [name, spec] of Object.entries(before.dependencies || {})) {
179
+ if (name !== PLUGIN_PACKAGE && !/^[~^]?\d+\.\d+\.\d+(?:-[\w.-]+)?$/.test(String(spec))) throw new Error("\u5176\u4ED6\u63D2\u4EF6\u4F7F\u7528\u4E86\u672C\u5730\u94FE\u63A5\u6216\u7279\u6B8A\u6765\u6E90\uFF0C\u672A\u4FEE\u6539\u5F53\u524D\u5B89\u88C5\u3002");
180
+ }
181
+ for (const e of fs.readdirSync(staged, { withFileTypes: true })) if (e.isSymbolicLink()) throw new Error("profile \u914D\u7F6E\u5305\u542B\u94FE\u63A5\uFF0C\u672A\u4FEE\u6539\u5F53\u524D\u5B89\u88C5\u3002");
182
+ if (before.packageManager && !/^pnpm@\d+\.\d+\.\d+(?:\+.*)?$/.test(before.packageManager)) throw new Error("\u5F53\u524D profile \u4F7F\u7528\u4E86\u5176\u4ED6\u5305\u7BA1\u7406\u5668\uFF0C\u672A\u4FEE\u6539\u5B89\u88C5\u3002");
183
+ writePrivateJsonAtomic(filename, { ...before, dependencies: {
184
+ ...before.dependencies,
185
+ [PLUGIN_PACKAGE]: "file:harness-remote-update.tgz"
186
+ }, packageManager: `pnpm@${INSTALL_PNPM_VERSION}` });
187
+ }
188
+ fs.copyFileSync(path.join(job.directory, "release.tgz"), path.join(staged, "harness-remote-update.tgz"));
189
+ const tools = installToolPath(job.directory, job.runtime);
190
+ await runNativePlugin(job.cli, scope, stagingHome, tools, job.runtime, path.join(job.directory, "install.log"));
191
+ const installed = fs.realpathSync(path.join(staged, "node_modules", PLUGIN_PACKAGE));
192
+ const relative = path.relative(staged, installed);
193
+ if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) throw new Error("\u6682\u5B58\u63D2\u4EF6\u4E0D\u5728\u5B89\u88C5\u76EE\u5F55\u5185\u3002");
194
+ if (JSON.parse(fs.readFileSync(path.join(installed, "package.json"), "utf8")).version !== job.targetVersion) throw new Error("\u5B89\u88C5\u540E\u63D2\u4EF6\u7248\u672C\u4E0D\u5339\u914D\u3002");
195
+ const after = JSON.parse(fs.readFileSync(filename, "utf8"));
196
+ if (!after.dsh?.profile?.bundles?.includes(PLUGIN_PACKAGE)) throw new Error("DSH \u5C1A\u672A\u5C06\u63D2\u4EF6\u6CE8\u518C\u4E3A\u539F\u751F profile \u5C42\u3002");
197
+ for (const name of Object.keys(before?.dependencies || {})) if (name !== PLUGIN_PACKAGE) {
198
+ if (hash(path.join(job.profile, "node_modules", name, "package.json")) !== hash(path.join(staged, "node_modules", name, "package.json"))) throw new Error("\u5B89\u88C5\u8BD5\u56FE\u6539\u53D8\u5176\u4ED6\u63D2\u4EF6\uFF0C\u539F\u5B89\u88C5\u4FDD\u6301\u4E0D\u53D8\u3002");
199
+ }
200
+ assertRelocatableProfile(staged);
201
+ return staged;
202
+ }
203
+ export {
204
+ PLUGIN_PACKAGE,
205
+ assertRelocatableProfile,
206
+ installToolPath,
207
+ runNativePlugin,
208
+ safeProfileName,
209
+ stageProfile
210
+ };
@@ -1,64 +1,64 @@
1
- /* Generated from the shared plugin installation sources. */
2
-
3
- // src/install-runtime.ts
4
- import fs from "node:fs";
5
- import path from "node:path";
6
- import { createRequire } from "node:module";
7
- import { spawn } from "node:child_process";
8
- var INSTALL_PNPM_VERSION = "11.22.0";
9
- function resolveInstallRuntime(owner, executable = process.execPath, nodeVersion = process.versions.node) {
10
- const [major, minor] = nodeVersion.split(".").map(Number);
11
- if (!(major > 22 || major === 22 && minor >= 13)) throw new Error("\u5F53\u524D Node.js \u7248\u672C\u4E0D\u6EE1\u8DB3\u5B89\u88C5\u8981\u6C42\uFF0822.13 \u6216\u66F4\u9AD8\uFF09\uFF0C\u672A\u4FEE\u6539\u63D2\u4EF6\u3002");
12
- const require2 = createRequire(path.resolve(owner, "package.json"));
13
- let filename;
14
- try {
15
- filename = require2.resolve("pnpm");
16
- } catch {
17
- throw new Error("\u5B89\u88C5\u5DE5\u5177\u4E0D\u5B8C\u6574\uFF0C\u8BF7\u4F7F\u7528\u5B98\u65B9\u5B89\u88C5\u547D\u4EE4\u81EA\u52A8\u4FEE\u590D\u3002");
18
- }
19
- const manifest = JSON.parse(fs.readFileSync(filename, "utf8"));
20
- if (manifest.name !== "pnpm" || manifest.version !== INSTALL_PNPM_VERSION) throw new Error("\u5B89\u88C5\u5DE5\u5177\u7248\u672C\u6821\u9A8C\u5931\u8D25\uFF0C\u672A\u4FEE\u6539\u63D2\u4EF6\u3002");
21
- const entry = typeof manifest.bin === "string" ? manifest.bin : manifest.bin?.pnpm;
22
- if (typeof entry !== "string" || path.isAbsolute(entry)) throw new Error("\u5B89\u88C5\u5DE5\u5177\u5165\u53E3\u65E0\u6548\u3002");
23
- const root = fs.realpathSync(path.dirname(filename)), cli = fs.realpathSync(path.resolve(root, entry));
24
- const relative = path.relative(root, cli);
25
- if (!relative || relative.startsWith("..") || path.isAbsolute(relative) || !fs.statSync(cli).isFile()) throw new Error("\u5B89\u88C5\u5DE5\u5177\u5165\u53E3\u4E0D\u5728\u5305\u76EE\u5F55\u5185\u3002");
26
- return { executable: fs.realpathSync(executable), cli, version: manifest.version };
27
- }
28
- function verifyInstallRuntime(runtime) {
29
- return new Promise((resolve, reject) => {
30
- const child = spawn(runtime.executable, [runtime.cli, "--version"], {
31
- windowsHide: true,
32
- shell: false,
33
- stdio: ["ignore", "pipe", "pipe"],
34
- env: { ...process.env, COREPACK_ENABLE_AUTO_PIN: "0", npm_config_manage_package_manager_versions: "false" }
35
- });
36
- let stdout = "", size = 0, settled = false;
37
- const finish = (error) => {
38
- if (settled) return;
39
- settled = true;
40
- clearTimeout(timer);
41
- error ? reject(error) : resolve();
42
- };
43
- const timer = setTimeout(() => {
44
- child.kill();
45
- finish(new Error("\u5B89\u88C5\u5DE5\u5177\u542F\u52A8\u8D85\u65F6\uFF0C\u672A\u4FEE\u6539\u63D2\u4EF6\u3002"));
46
- }, 15e3);
47
- child.stdout.on("data", (b) => {
48
- size += b.length;
49
- if (size > 16384) {
50
- child.kill();
51
- finish(new Error("\u5B89\u88C5\u5DE5\u5177\u54CD\u5E94\u5F02\u5E38\u3002"));
52
- } else stdout += b.toString();
53
- });
54
- child.stderr.on("data", () => {
55
- });
56
- child.once("error", () => finish(new Error("\u65E0\u6CD5\u542F\u52A8\u5B89\u88C5\u5DE5\u5177\uFF0C\u672A\u4FEE\u6539\u63D2\u4EF6\u3002")));
57
- child.once("close", (code) => finish(code === 0 && stdout.trim() === runtime.version ? void 0 : new Error("\u5B89\u88C5\u5DE5\u5177\u8FD0\u884C\u9A8C\u8BC1\u5931\u8D25\uFF0C\u672A\u4FEE\u6539\u63D2\u4EF6\u3002")));
58
- });
59
- }
60
- export {
61
- INSTALL_PNPM_VERSION,
62
- resolveInstallRuntime,
63
- verifyInstallRuntime
64
- };
1
+ /* Generated from the shared plugin installation sources. */
2
+
3
+ // src/install-runtime.ts
4
+ import fs from "node:fs";
5
+ import path from "node:path";
6
+ import { createRequire } from "node:module";
7
+ import { spawn } from "node:child_process";
8
+ var INSTALL_PNPM_VERSION = "11.22.0";
9
+ function resolveInstallRuntime(owner, executable = process.execPath, nodeVersion = process.versions.node) {
10
+ const [major, minor] = nodeVersion.split(".").map(Number);
11
+ if (!(major > 22 || major === 22 && minor >= 13)) throw new Error("\u5F53\u524D Node.js \u7248\u672C\u4E0D\u6EE1\u8DB3\u5B89\u88C5\u8981\u6C42\uFF0822.13 \u6216\u66F4\u9AD8\uFF09\uFF0C\u672A\u4FEE\u6539\u63D2\u4EF6\u3002");
12
+ const require2 = createRequire(path.resolve(owner, "package.json"));
13
+ let filename;
14
+ try {
15
+ filename = require2.resolve("pnpm");
16
+ } catch {
17
+ throw new Error("\u5B89\u88C5\u5DE5\u5177\u4E0D\u5B8C\u6574\uFF0C\u8BF7\u4F7F\u7528\u5B98\u65B9\u5B89\u88C5\u547D\u4EE4\u81EA\u52A8\u4FEE\u590D\u3002");
18
+ }
19
+ const manifest = JSON.parse(fs.readFileSync(filename, "utf8"));
20
+ if (manifest.name !== "pnpm" || manifest.version !== INSTALL_PNPM_VERSION) throw new Error("\u5B89\u88C5\u5DE5\u5177\u7248\u672C\u6821\u9A8C\u5931\u8D25\uFF0C\u672A\u4FEE\u6539\u63D2\u4EF6\u3002");
21
+ const entry = typeof manifest.bin === "string" ? manifest.bin : manifest.bin?.pnpm;
22
+ if (typeof entry !== "string" || path.isAbsolute(entry)) throw new Error("\u5B89\u88C5\u5DE5\u5177\u5165\u53E3\u65E0\u6548\u3002");
23
+ const root = fs.realpathSync(path.dirname(filename)), cli = fs.realpathSync(path.resolve(root, entry));
24
+ const relative = path.relative(root, cli);
25
+ if (!relative || relative.startsWith("..") || path.isAbsolute(relative) || !fs.statSync(cli).isFile()) throw new Error("\u5B89\u88C5\u5DE5\u5177\u5165\u53E3\u4E0D\u5728\u5305\u76EE\u5F55\u5185\u3002");
26
+ return { executable: fs.realpathSync(executable), cli, version: manifest.version };
27
+ }
28
+ function verifyInstallRuntime(runtime) {
29
+ return new Promise((resolve, reject) => {
30
+ const child = spawn(runtime.executable, [runtime.cli, "--version"], {
31
+ windowsHide: true,
32
+ shell: false,
33
+ stdio: ["ignore", "pipe", "pipe"],
34
+ env: { ...process.env, COREPACK_ENABLE_AUTO_PIN: "0", npm_config_manage_package_manager_versions: "false" }
35
+ });
36
+ let stdout = "", size = 0, settled = false;
37
+ const finish = (error) => {
38
+ if (settled) return;
39
+ settled = true;
40
+ clearTimeout(timer);
41
+ error ? reject(error) : resolve();
42
+ };
43
+ const timer = setTimeout(() => {
44
+ child.kill();
45
+ finish(new Error("\u5B89\u88C5\u5DE5\u5177\u542F\u52A8\u8D85\u65F6\uFF0C\u672A\u4FEE\u6539\u63D2\u4EF6\u3002"));
46
+ }, 15e3);
47
+ child.stdout.on("data", (b) => {
48
+ size += b.length;
49
+ if (size > 16384) {
50
+ child.kill();
51
+ finish(new Error("\u5B89\u88C5\u5DE5\u5177\u54CD\u5E94\u5F02\u5E38\u3002"));
52
+ } else stdout += b.toString();
53
+ });
54
+ child.stderr.on("data", () => {
55
+ });
56
+ child.once("error", () => finish(new Error("\u65E0\u6CD5\u542F\u52A8\u5B89\u88C5\u5DE5\u5177\uFF0C\u672A\u4FEE\u6539\u63D2\u4EF6\u3002")));
57
+ child.once("close", (code) => finish(code === 0 && stdout.trim() === runtime.version ? void 0 : new Error("\u5B89\u88C5\u5DE5\u5177\u8FD0\u884C\u9A8C\u8BC1\u5931\u8D25\uFF0C\u672A\u4FEE\u6539\u63D2\u4EF6\u3002")));
58
+ });
59
+ }
60
+ export {
61
+ INSTALL_PNPM_VERSION,
62
+ resolveInstallRuntime,
63
+ verifyInstallRuntime
64
+ };
package/lib/package.json CHANGED
@@ -1 +1 @@
1
- {"type":"module"}
1
+ {"type":"module"}