@nexum-hub/agent 0.0.3-next.11 → 0.0.3-next.13

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.
@@ -33,6 +33,22 @@ const npmBin = (root) =>
33
33
  ? "node_modules/npm/bin/npm-cli.js"
34
34
  : "lib/node_modules/npm/bin/npm-cli.js",
35
35
  );
36
+ // Mainland timezone IDs, not an ambiguous UTC+8 offset, select the China mirror.
37
+ export function npmRegistries(
38
+ timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone,
39
+ ) {
40
+ const mainland = [
41
+ "Asia/Shanghai",
42
+ "Asia/Chongqing",
43
+ "Asia/Harbin",
44
+ "Asia/Urumqi",
45
+ "PRC",
46
+ ].includes(timeZone);
47
+ return [
48
+ ...(mainland ? ["https://registry.npmmirror.com/"] : []),
49
+ "https://registry.npmjs.org/",
50
+ ];
51
+ }
36
52
  const fail = (condition, reason) => {
37
53
  if (!condition) throw new Error(reason);
38
54
  };
@@ -159,20 +175,30 @@ async function packageStage(stage, version, managedNode, source) {
159
175
  const scratch = path.join(stage, ".resolve");
160
176
  let from = source;
161
177
  if (!from) {
162
- await directory(scratch);
163
- exec(nodeBin(managedNode), [
164
- npmBin(managedNode),
165
- "install",
166
- "--prefix",
167
- scratch,
168
- "--no-save",
169
- "--no-package-lock",
170
- "--omit=dev",
171
- "--no-audit",
172
- "--no-fund",
173
- "--registry=https://registry.npmjs.org/",
174
- `@nexum-hub/agent@${version}`,
175
- ]);
178
+ const registries = npmRegistries();
179
+ for (const [index, registry] of registries.entries()) {
180
+ // Retry package resolution only; the Agent is activated after this stage.
181
+ await rm(scratch, { recursive: true, force: true });
182
+ await directory(scratch);
183
+ try {
184
+ exec(nodeBin(managedNode), [
185
+ npmBin(managedNode),
186
+ "install",
187
+ "--prefix",
188
+ scratch,
189
+ "--no-save",
190
+ "--no-package-lock",
191
+ "--omit=dev",
192
+ "--no-audit",
193
+ "--no-fund",
194
+ `--registry=${registry}`,
195
+ `@nexum-hub/agent@${version}`,
196
+ ]);
197
+ break;
198
+ } catch (error) {
199
+ if (index === registries.length - 1) throw error;
200
+ }
201
+ }
176
202
  from = path.join(scratch, "node_modules", "@nexum-hub", "agent");
177
203
  }
178
204
  const manifest = JSON.parse(
@@ -239,6 +239,9 @@ export function servicePlan({
239
239
  "-NoLogo",
240
240
  "-NoProfile",
241
241
  "-NonInteractive",
242
+ // Task Scheduler must not expose a console window that a user can close.
243
+ "-WindowStyle",
244
+ "Hidden",
242
245
  "-ExecutionPolicy",
243
246
  "Bypass",
244
247
  "-File",