@allwright.dev/core 0.0.40 → 0.0.41
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/dist/bootstrap.js +64 -14
- package/package.json +1 -1
package/dist/bootstrap.js
CHANGED
|
@@ -12,7 +12,7 @@ const ALLWRIGHT_HOME_ENV_VAR = "ALLWRIGHT_HOME";
|
|
|
12
12
|
const ALLWRIGHT_REPOSITORY_ENV_VAR = "ALLWRIGHT_REPOSITORY";
|
|
13
13
|
const ALLWRIGHT_VERSION_ENV_VAR = "ALLWRIGHT_VERSION";
|
|
14
14
|
const DEFAULT_RELEASE_REPOSITORY = "allwright-dev/allwright";
|
|
15
|
-
const DEFAULT_RELEASE_VERSION = "0.0.
|
|
15
|
+
const DEFAULT_RELEASE_VERSION = "0.0.41";
|
|
16
16
|
const STARTUP_TIMEOUT_MS = 20_000;
|
|
17
17
|
const PING_TIMEOUT_MS = 1_000;
|
|
18
18
|
const PROTO_ROOT = fileURLToPath(new URL("../proto/", import.meta.url));
|
|
@@ -143,10 +143,20 @@ function ensureWebPlugin(cliPath, expectedVersion) {
|
|
|
143
143
|
return;
|
|
144
144
|
}
|
|
145
145
|
const result = spawnSync(cliPath, ["plugin", "install", "web", "--version", expectedVersion], {
|
|
146
|
-
|
|
146
|
+
encoding: "utf8",
|
|
147
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
147
148
|
});
|
|
149
|
+
if (result.error) {
|
|
150
|
+
throw new Error(`failed to install allwright web plugin with ${cliPath}: ${result.error.message}`);
|
|
151
|
+
}
|
|
148
152
|
if (result.status !== 0 || !isFile(pluginPath)) {
|
|
149
|
-
|
|
153
|
+
const details = [result.stdout, result.stderr]
|
|
154
|
+
.map((value) => value?.trim())
|
|
155
|
+
.filter((value) => !!value)
|
|
156
|
+
.join("\n");
|
|
157
|
+
throw new Error(details
|
|
158
|
+
? `allwright attempted to install the \`web\` plugin automatically, but the install did not complete successfully:\n${details}`
|
|
159
|
+
: "allwright attempted to install the `web` plugin automatically, but the install did not complete successfully");
|
|
150
160
|
}
|
|
151
161
|
if (installedPluginVersion("web") !== expectedVersion) {
|
|
152
162
|
throw new Error(`allwright attempted to install the \`web\` plugin automatically, but version ${expectedVersion} is still not active`);
|
|
@@ -170,33 +180,53 @@ async function resolveReleaseTag() {
|
|
|
170
180
|
return payload.tag_name;
|
|
171
181
|
}
|
|
172
182
|
function extractCliArchive(archivePath, cliPath) {
|
|
183
|
+
const extractRoot = fs.mkdtempSync(path.join(os.tmpdir(), "allwright-cli-"));
|
|
173
184
|
if (archivePath.endsWith(".zip")) {
|
|
174
185
|
const result = spawnSync("powershell", [
|
|
175
186
|
"-NoProfile",
|
|
176
187
|
"-Command",
|
|
177
|
-
`Expand-Archive -Path '${archivePath.replaceAll("'", "''")}' -DestinationPath '${
|
|
178
|
-
], { stdio: "ignore" });
|
|
188
|
+
`Expand-Archive -Path '${archivePath.replaceAll("'", "''")}' -DestinationPath '${extractRoot.replaceAll("'", "''")}' -Force`,
|
|
189
|
+
], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
190
|
+
if (result.error) {
|
|
191
|
+
fs.rmSync(extractRoot, { recursive: true, force: true });
|
|
192
|
+
throw new Error(`failed to extract allwright CLI zip archive: ${result.error.message}`);
|
|
193
|
+
}
|
|
179
194
|
if (result.status !== 0) {
|
|
180
|
-
|
|
195
|
+
const details = [result.stdout, result.stderr].map((value) => value?.trim()).filter(Boolean).join("\n");
|
|
196
|
+
fs.rmSync(extractRoot, { recursive: true, force: true });
|
|
197
|
+
throw new Error(details ? `failed to extract allwright CLI zip archive:\n${details}` : "failed to extract allwright CLI zip archive");
|
|
198
|
+
}
|
|
199
|
+
const extracted = findExtractedCli(extractRoot);
|
|
200
|
+
if (!extracted) {
|
|
201
|
+
fs.rmSync(extractRoot, { recursive: true, force: true });
|
|
202
|
+
throw new Error(`allwright CLI zip archive did not contain bin/${cliFilename()}`);
|
|
181
203
|
}
|
|
182
|
-
const extracted = path.join(path.dirname(cliPath), "bin", cliFilename());
|
|
183
204
|
fs.copyFileSync(extracted, cliPath);
|
|
184
|
-
fs.rmSync(
|
|
205
|
+
fs.rmSync(extractRoot, { recursive: true, force: true });
|
|
185
206
|
return;
|
|
186
207
|
}
|
|
187
208
|
const result = spawnSync("tar", [
|
|
188
209
|
"-xzf",
|
|
189
210
|
archivePath,
|
|
190
211
|
"-C",
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
212
|
+
extractRoot,
|
|
213
|
+
], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
214
|
+
if (result.error) {
|
|
215
|
+
fs.rmSync(extractRoot, { recursive: true, force: true });
|
|
216
|
+
throw new Error(`failed to extract allwright CLI tar archive: ${result.error.message}`);
|
|
217
|
+
}
|
|
194
218
|
if (result.status !== 0) {
|
|
195
|
-
|
|
219
|
+
const details = [result.stdout, result.stderr].map((value) => value?.trim()).filter(Boolean).join("\n");
|
|
220
|
+
fs.rmSync(extractRoot, { recursive: true, force: true });
|
|
221
|
+
throw new Error(details ? `failed to extract allwright CLI tar archive:\n${details}` : "failed to extract allwright CLI tar archive");
|
|
222
|
+
}
|
|
223
|
+
const extracted = findExtractedCli(extractRoot);
|
|
224
|
+
if (!extracted) {
|
|
225
|
+
fs.rmSync(extractRoot, { recursive: true, force: true });
|
|
226
|
+
throw new Error(`allwright CLI archive did not contain bin/${cliFilename()}`);
|
|
196
227
|
}
|
|
197
|
-
const extracted = path.join(path.dirname(cliPath), "bin", cliFilename());
|
|
198
228
|
fs.copyFileSync(extracted, cliPath);
|
|
199
|
-
fs.rmSync(
|
|
229
|
+
fs.rmSync(extractRoot, { recursive: true, force: true });
|
|
200
230
|
}
|
|
201
231
|
function cliAssetName(versionTag) {
|
|
202
232
|
const targets = new Map([
|
|
@@ -316,6 +346,26 @@ function allwrightHome() {
|
|
|
316
346
|
function cliFilename() {
|
|
317
347
|
return process.platform === "win32" ? "allwright.exe" : "allwright";
|
|
318
348
|
}
|
|
349
|
+
function findExtractedCli(extractRoot) {
|
|
350
|
+
const queue = [extractRoot];
|
|
351
|
+
while (queue.length > 0) {
|
|
352
|
+
const current = queue.shift();
|
|
353
|
+
if (!current) {
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
for (const entry of fs.readdirSync(current, { withFileTypes: true })) {
|
|
357
|
+
const entryPath = path.join(current, entry.name);
|
|
358
|
+
if (entry.isDirectory()) {
|
|
359
|
+
queue.push(entryPath);
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
if (entry.isFile() && entry.name === cliFilename() && path.basename(path.dirname(entryPath)) === "bin") {
|
|
363
|
+
return entryPath;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
319
369
|
function webPluginFilename() {
|
|
320
370
|
if (process.platform === "darwin") {
|
|
321
371
|
return "liballwright_surface_web.dylib";
|