neoctl 0.2.13 → 0.2.14

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.
@@ -56,6 +56,10 @@ try {
56
56
  console.log("[release-local] --no-publish: skipping npm publish");
57
57
  }
58
58
 
59
+ if (!skipPublish) {
60
+ await waitForPublishedVersion(packageName, targetVersion, registry, root);
61
+ }
62
+
59
63
  if (!skipInstall) {
60
64
  await run("npm", ["install", "-g", `${packageName}@${targetVersion}`, "--registry", registry], { cwd: root });
61
65
  } else {
@@ -122,6 +126,26 @@ async function writeTempNpmrc(registry, token) {
122
126
  return file;
123
127
  }
124
128
 
129
+ async function waitForPublishedVersion(packageName, targetVersion, registry, cwd) {
130
+ const deadline = Date.now() + 180_000;
131
+ console.log(`[release-local] waiting for ${packageName}@${targetVersion} to be visible on ${registry}`);
132
+ while (Date.now() < deadline) {
133
+ const result = await runCapture("npm", ["view", packageName, "version", "--registry", registry], { cwd });
134
+ const version = result.stdout.trim();
135
+ if (result.code === 0 && version === targetVersion) {
136
+ console.log(`[release-local] registry version visible: ${version}`);
137
+ return;
138
+ }
139
+ console.log(`[release-local] registry version is ${version || "unavailable"}; retrying...`);
140
+ await delay(5_000);
141
+ }
142
+ throw new Error(`Timed out waiting for ${packageName}@${targetVersion} to be visible on ${registry}`);
143
+ }
144
+
145
+ function delay(ms) {
146
+ return new Promise((resolve) => setTimeout(resolve, ms));
147
+ }
148
+
125
149
  function run(command, commandArgs, options = {}) {
126
150
  console.log(`[release-local] $ ${command} ${commandArgs.map(quoteArg).join(" ")}`);
127
151
  return new Promise((resolve, reject) => {
@@ -139,6 +163,24 @@ function run(command, commandArgs, options = {}) {
139
163
  });
140
164
  }
141
165
 
166
+ function runCapture(command, commandArgs, options = {}) {
167
+ console.log(`[release-local] $ ${command} ${commandArgs.map(quoteArg).join(" ")}`);
168
+ return new Promise((resolve, reject) => {
169
+ const child = spawn(command, commandArgs, {
170
+ cwd: options.cwd,
171
+ shell: process.platform === "win32",
172
+ stdio: ["ignore", "pipe", "pipe"],
173
+ env: process.env,
174
+ });
175
+ let stdout = "";
176
+ let stderr = "";
177
+ child.stdout.on("data", (chunk) => { stdout += String(chunk); });
178
+ child.stderr.on("data", (chunk) => { stderr += String(chunk); });
179
+ child.on("error", reject);
180
+ child.on("exit", (code, signal) => resolve({ code: code ?? 1, signal, stdout, stderr }));
181
+ });
182
+ }
183
+
142
184
  function quoteArg(arg) {
143
185
  return /\s/.test(arg) ? JSON.stringify(arg) : arg;
144
186
  }