@hot-updater/cloudflare 1.0.0-rc.2 → 1.0.0-rc.4
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/iac/index.cjs +284 -162
- package/dist/iac/index.d.cts +1 -5
- package/dist/iac/index.d.mts +1 -5
- package/dist/iac/index.mjs +280 -158
- package/dist/index.cjs +69 -14
- package/dist/index.d.cts +1 -3
- package/dist/index.d.mts +1 -3
- package/dist/index.mjs +67 -12
- package/dist/worker/index.cjs +71 -15
- package/dist/worker/index.d.cts +2 -3
- package/dist/worker/index.d.mts +2 -3
- package/dist/worker/index.mjs +71 -15
- package/package.json +7 -7
- package/sql/bundles.sql +29 -7
- package/src/d1Database.spec.ts +99 -0
- package/src/d1Database.ts +7 -1
- package/src/d1Implementation.spec.ts +90 -0
- package/src/d1Implementation.ts +42 -3
- package/src/d1Query.ts +3 -0
- package/src/d1Rows.spec.ts +32 -0
- package/src/d1Rows.ts +35 -0
- package/src/worker/d1Database.spec.ts +36 -0
- package/src/worker/d1Database.ts +9 -1
- package/worker/dist/README.md +1 -1
- package/worker/dist/index.js +997 -659
- package/worker/dist/index.js.map +4 -4
- package/worker/migrations/0001_hot-updater_1.0.0.sql +30 -13
- package/worker/src/databaseMigration.integration.spec.ts +62 -1
- package/worker/src/databasePlugins.integration.spec.ts +35 -1
- package/worker/src/insightsMovement.integration.spec.ts +73 -0
package/dist/iac/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import fs from "fs/promises";
|
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { ConfigBuilder, InitError, LegacyInfrastructureError, assertInfrastructureGenerationAtUrl, assertInitInputs, assertInitProviderInputs, confirmInitInputPersistence, copyDirToTmp, createHotUpdaterConfigScaffoldFromBuilder, formatApiKeyNote, getCwd, getHotUpdaterInitInputEnv, getInitProviderEnvVars, getInitProviderTextPromptValues, link, makeEnv, p, readHotUpdaterInitEnv, resolveInitProviderInput, transformTemplate, writeHotUpdaterConfig } from "@hot-updater/cli-tools";
|
|
6
6
|
import { provisionApiKey } from "@hot-updater/server";
|
|
7
|
-
import Cloudflare, { Cloudflare
|
|
7
|
+
import Cloudflare$1, { Cloudflare } from "cloudflare";
|
|
8
8
|
import { createDatabasePlugin, isDatabaseMetadataObject } from "@hot-updater/plugin-core";
|
|
9
9
|
import { createDatabasePluginAdapter } from "@hot-updater/plugin-core/internal";
|
|
10
10
|
import { fileURLToPath } from "node:url";
|
|
@@ -32,7 +32,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
32
32
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
33
33
|
var __getProtoOf = Object.getPrototypeOf;
|
|
34
34
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
35
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
35
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
36
36
|
var __copyProps = (to, from, except, desc) => {
|
|
37
37
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
38
38
|
key = keys[i];
|
|
@@ -43,11 +43,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
43
43
|
}
|
|
44
44
|
return to;
|
|
45
45
|
};
|
|
46
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
46
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
47
47
|
value: mod,
|
|
48
48
|
enumerable: true
|
|
49
49
|
}) : target, mod));
|
|
50
|
-
var __require = /*
|
|
50
|
+
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
51
51
|
//#endregion
|
|
52
52
|
//#region src/d1Rows.ts
|
|
53
53
|
var InvalidD1RowError = class extends Error {
|
|
@@ -156,6 +156,29 @@ const eventRow = (row) => {
|
|
|
156
156
|
received_at_ms: numberValue(row, "received_at_ms", "bundle_events")
|
|
157
157
|
};
|
|
158
158
|
};
|
|
159
|
+
const installationRow = (row) => {
|
|
160
|
+
const type = stringValue(row, "type", "bundle_installations");
|
|
161
|
+
const platform = stringValue(row, "platform", "bundle_installations");
|
|
162
|
+
if (![
|
|
163
|
+
"UPDATE_APPLIED",
|
|
164
|
+
"RECOVERED",
|
|
165
|
+
"RELEASE_ADOPTED",
|
|
166
|
+
"UNCHANGED"
|
|
167
|
+
].includes(type) || platform !== "ios" && platform !== "android") throw new InvalidD1RowError("bundle_installations");
|
|
168
|
+
return {
|
|
169
|
+
id: stringValue(row, "id", "bundle_installations"),
|
|
170
|
+
install_id: stringValue(row, "install_id", "bundle_installations"),
|
|
171
|
+
user_id: nullableString(row, "user_id", "bundle_installations"),
|
|
172
|
+
username: nullableString(row, "username", "bundle_installations"),
|
|
173
|
+
to_bundle_id: stringValue(row, "to_bundle_id", "bundle_installations"),
|
|
174
|
+
type,
|
|
175
|
+
platform,
|
|
176
|
+
app_version: stringValue(row, "app_version", "bundle_installations"),
|
|
177
|
+
channel: stringValue(row, "channel", "bundle_installations"),
|
|
178
|
+
cohort: stringValue(row, "cohort", "bundle_installations"),
|
|
179
|
+
received_at_ms: numberValue(row, "received_at_ms", "bundle_installations")
|
|
180
|
+
};
|
|
181
|
+
};
|
|
159
182
|
const apiKeyRow = (row) => {
|
|
160
183
|
const role = stringValue(row, "role", "api_keys");
|
|
161
184
|
if (role !== "client") throw new InvalidD1RowError("api_keys");
|
|
@@ -230,6 +253,7 @@ function parseD1Row(model, value) {
|
|
|
230
253
|
case "bundle_patches": return patchRow(value);
|
|
231
254
|
case "channels": return channelRow(value);
|
|
232
255
|
case "bundle_events": return eventRow(value);
|
|
256
|
+
case "bundle_installations": return installationRow(value);
|
|
233
257
|
case "api_keys": return apiKeyRow(value);
|
|
234
258
|
case "releases": return releaseRow(value);
|
|
235
259
|
case "release_catalogs": return releaseCatalogRow(value);
|
|
@@ -266,7 +290,8 @@ const stringPredicate = (condition, operator) => {
|
|
|
266
290
|
};
|
|
267
291
|
}
|
|
268
292
|
const literal = escapeLikePattern(condition.value);
|
|
269
|
-
const
|
|
293
|
+
const pattern = operator === "contains" ? `%${literal}%` : operator === "starts_with" ? `${literal}%` : `%${literal}`;
|
|
294
|
+
const parameter = bind(pattern);
|
|
270
295
|
return {
|
|
271
296
|
sql: `lower(${condition.field}) LIKE lower(${parameter.sql}) ESCAPE '\\'`,
|
|
272
297
|
params: parameter.params
|
|
@@ -351,11 +376,13 @@ const d1TableNames = {
|
|
|
351
376
|
bundle_patches: "bundle_patches",
|
|
352
377
|
channels: "channels",
|
|
353
378
|
bundle_events: "bundle_events",
|
|
379
|
+
bundle_installations: "bundle_installations",
|
|
354
380
|
api_keys: "api_keys",
|
|
355
381
|
release_catalogs: "release_catalogs",
|
|
356
382
|
releases: "releases"
|
|
357
383
|
};
|
|
358
384
|
var D1QueryResultError = class extends Error {
|
|
385
|
+
result;
|
|
359
386
|
name = "D1QueryResultError";
|
|
360
387
|
operation = "count";
|
|
361
388
|
constructor(result) {
|
|
@@ -386,6 +413,7 @@ const findManyD1Rows = async (executor, input) => {
|
|
|
386
413
|
case "bundle_patches": return rows.map((row) => parseD1Row("bundle_patches", row));
|
|
387
414
|
case "channels": return rows.map((row) => parseD1Row("channels", row));
|
|
388
415
|
case "bundle_events": return rows.map((row) => parseD1Row("bundle_events", row));
|
|
416
|
+
case "bundle_installations": return rows.map((row) => parseD1Row("bundle_installations", row));
|
|
389
417
|
case "api_keys": return rows.map((row) => parseD1Row("api_keys", row));
|
|
390
418
|
case "releases": return rows.map((row) => parseD1Row("releases", row));
|
|
391
419
|
case "release_catalogs": return rows.map((row) => parseD1Row("release_catalogs", row));
|
|
@@ -393,6 +421,12 @@ const findManyD1Rows = async (executor, input) => {
|
|
|
393
421
|
};
|
|
394
422
|
//#endregion
|
|
395
423
|
//#region src/d1Implementation.ts
|
|
424
|
+
var D1ExecutionError = class extends Error {
|
|
425
|
+
name = "D1ExecutionError";
|
|
426
|
+
constructor() {
|
|
427
|
+
super("D1 did not successfully execute every requested statement");
|
|
428
|
+
}
|
|
429
|
+
};
|
|
396
430
|
const EXPECTATION_CONFLICT_MARKER = "HOT_UPDATER_COMMIT_EXPECTATION_CONFLICT";
|
|
397
431
|
const expectationGuard = (expectations) => {
|
|
398
432
|
const clauses = [];
|
|
@@ -430,7 +464,8 @@ const expectationConflict = async (executor, expectations) => {
|
|
|
430
464
|
const versionField = isRelease ? "revision" : "generation";
|
|
431
465
|
const key = isRelease ? expectation.id : expectation.scopeKey;
|
|
432
466
|
const expectedVersion = isRelease ? expectation.revision : expectation.generation;
|
|
433
|
-
const
|
|
467
|
+
const rows = await executor.query(`SELECT ${versionField} FROM ${table} WHERE ${keyField} = json_extract(?, '$') LIMIT 1`, encodeD1Values([key]));
|
|
468
|
+
const actualVersion = readVersion(rows[0], versionField);
|
|
434
469
|
if (actualVersion !== expectedVersion) return {
|
|
435
470
|
committed: false,
|
|
436
471
|
conflict: {
|
|
@@ -509,14 +544,14 @@ const insertQuery = (input, guard, conflictMode = "returnExisting") => {
|
|
|
509
544
|
values = channelValues(input.data);
|
|
510
545
|
break;
|
|
511
546
|
case "bundle_events":
|
|
547
|
+
case "bundle_installations":
|
|
512
548
|
case "api_keys":
|
|
513
549
|
case "release_catalogs":
|
|
514
550
|
case "releases":
|
|
515
551
|
columns = Object.keys(input.data);
|
|
516
552
|
values = Object.values(input.data);
|
|
517
|
-
break;
|
|
518
553
|
}
|
|
519
|
-
const conflict = input.onConflict !== "ignore" ? "" : input.model === "channels" ? conflictMode === "ignore" ? " ON CONFLICT(name) DO NOTHING" : " ON CONFLICT(name) DO UPDATE SET name = excluded.name" : input.model === "api_keys" ? conflictMode === "ignore" ? " ON CONFLICT(hash) DO NOTHING" : " ON CONFLICT(hash) DO UPDATE SET hash = excluded.hash" : "";
|
|
554
|
+
const conflict = input.onConflict !== "ignore" ? "" : input.model === "channels" ? conflictMode === "ignore" ? " ON CONFLICT(name) DO NOTHING" : " ON CONFLICT(name) DO UPDATE SET name = excluded.name" : input.model === "api_keys" ? conflictMode === "ignore" ? " ON CONFLICT(hash) DO NOTHING" : " ON CONFLICT(hash) DO UPDATE SET hash = excluded.hash" : " ON CONFLICT(install_id) DO UPDATE SET install_id = excluded.install_id";
|
|
520
555
|
return {
|
|
521
556
|
sql: `INSERT INTO ${d1TableNames[input.model]} (${columns.join(", ")}) ${guard === void 0 ? `VALUES (${d1Placeholders(values.length)})` : `SELECT ${d1Placeholders(values.length)} WHERE ${guard.sql}`}${conflict} RETURNING *`,
|
|
522
557
|
params: [...encodeD1Values(values), ...guard?.params ?? []]
|
|
@@ -580,9 +615,7 @@ const channelDeletePrecondition = (changes, changeIndex, channelId) => {
|
|
|
580
615
|
releaseEffects.set(change.row.id, change.row.channel_id);
|
|
581
616
|
break;
|
|
582
617
|
case "update": break;
|
|
583
|
-
case "delete":
|
|
584
|
-
releaseEffects.set(change.where.id, null);
|
|
585
|
-
break;
|
|
618
|
+
case "delete": releaseEffects.set(change.where.id, null);
|
|
586
619
|
}
|
|
587
620
|
}
|
|
588
621
|
return {
|
|
@@ -657,10 +690,6 @@ const changeQuery = (change, guard) => {
|
|
|
657
690
|
sql: `DELETE FROM channels WHERE id = json_extract(?, '$') AND NOT EXISTS (SELECT 1 FROM releases WHERE channel_id = json_extract(?, '$')) AND ${guard.sql}`,
|
|
658
691
|
params: [...encodeD1Values([change.where.id, change.where.id]), ...guard.params]
|
|
659
692
|
};
|
|
660
|
-
case "insights": return insertQuery({
|
|
661
|
-
model: "bundle_events",
|
|
662
|
-
data: change.row
|
|
663
|
-
}, guard);
|
|
664
693
|
case "apiKeys": return change.operation === "insert" ? insertQuery({
|
|
665
694
|
model: "api_keys",
|
|
666
695
|
data: change.row,
|
|
@@ -829,6 +858,25 @@ const deleteChannel = async (executor, input) => {
|
|
|
829
858
|
};
|
|
830
859
|
};
|
|
831
860
|
const createD1Implementation = (executor) => ({
|
|
861
|
+
async recordInsights({ event, installation }) {
|
|
862
|
+
const columns = Object.keys(installation);
|
|
863
|
+
const eventInsert = insertQuery({
|
|
864
|
+
model: "bundle_events",
|
|
865
|
+
data: event
|
|
866
|
+
});
|
|
867
|
+
await executor.batch([{
|
|
868
|
+
sql: `INSERT INTO bundle_installations (${columns.join(", ")})
|
|
869
|
+
SELECT ${d1Placeholders(columns.length)}
|
|
870
|
+
WHERE NOT EXISTS (SELECT 1 FROM bundle_events WHERE id = json_extract(?, '$'))
|
|
871
|
+
ON CONFLICT(install_id) DO UPDATE SET ${columns.filter((column) => column !== "install_id").map((column) => `${column} = excluded.${column}`).join(", ")}
|
|
872
|
+
WHERE (excluded.received_at_ms, excluded.id) >
|
|
873
|
+
(bundle_installations.received_at_ms, bundle_installations.id)`,
|
|
874
|
+
params: encodeD1Values([...Object.values(installation), event.id])
|
|
875
|
+
}, {
|
|
876
|
+
...eventInsert,
|
|
877
|
+
sql: eventInsert.sql.replace(" RETURNING *", " ON CONFLICT(id) DO NOTHING")
|
|
878
|
+
}]);
|
|
879
|
+
},
|
|
832
880
|
async create(input) {
|
|
833
881
|
const query = insertQuery(input);
|
|
834
882
|
const rows = await executor.query(query.sql, query.params);
|
|
@@ -837,6 +885,7 @@ const createD1Implementation = (executor) => ({
|
|
|
837
885
|
case "bundle_patches": return parseD1Row("bundle_patches", rows[0]);
|
|
838
886
|
case "channels": return parseD1Row("channels", rows[0]);
|
|
839
887
|
case "bundle_events": return parseD1Row("bundle_events", rows[0]);
|
|
888
|
+
case "bundle_installations": return parseD1Row("bundle_installations", rows[0]);
|
|
840
889
|
case "api_keys": return parseD1Row("api_keys", rows[0]);
|
|
841
890
|
case "releases": return parseD1Row("releases", rows[0]);
|
|
842
891
|
case "release_catalogs": return parseD1Row("release_catalogs", rows[0]);
|
|
@@ -851,6 +900,7 @@ const createD1Implementation = (executor) => ({
|
|
|
851
900
|
case "api_keys": return parseD1Row("api_keys", rows[0]);
|
|
852
901
|
case "releases": return parseD1Row("releases", rows[0]);
|
|
853
902
|
case "release_catalogs": return parseD1Row("release_catalogs", rows[0]);
|
|
903
|
+
case "bundle_installations": return parseD1Row("bundle_installations", rows[0]);
|
|
854
904
|
}
|
|
855
905
|
},
|
|
856
906
|
async delete(input) {
|
|
@@ -869,6 +919,7 @@ const createD1Implementation = (executor) => ({
|
|
|
869
919
|
case "api_keys": return parseD1Row("api_keys", rows[0]);
|
|
870
920
|
case "releases": return parseD1Row("releases", rows[0]);
|
|
871
921
|
case "release_catalogs": return parseD1Row("release_catalogs", rows[0]);
|
|
922
|
+
case "bundle_installations": return parseD1Row("bundle_installations", rows[0]);
|
|
872
923
|
}
|
|
873
924
|
},
|
|
874
925
|
findMany: (input) => findManyD1Rows(executor, input),
|
|
@@ -901,7 +952,7 @@ const createD1Implementation = (executor) => ({
|
|
|
901
952
|
//#endregion
|
|
902
953
|
//#region src/d1Database.ts
|
|
903
954
|
const d1Database = (config) => {
|
|
904
|
-
const cloudflare = new Cloudflare({ apiToken: config.cloudflareApiToken });
|
|
955
|
+
const cloudflare = new Cloudflare$1({ apiToken: config.cloudflareApiToken });
|
|
905
956
|
const execute = async (statements) => {
|
|
906
957
|
const first = statements[0];
|
|
907
958
|
if (first === void 0) return [];
|
|
@@ -918,7 +969,11 @@ const d1Database = (config) => {
|
|
|
918
969
|
};
|
|
919
970
|
const page = await cloudflare.d1.database.query(config.databaseId, { ...body });
|
|
920
971
|
const results = [];
|
|
921
|
-
for await (const resultPage of page.iterPages()) for (const result of resultPage.result)
|
|
972
|
+
for await (const resultPage of page.iterPages()) for (const result of resultPage.result) {
|
|
973
|
+
if (result.success === false) throw new D1ExecutionError();
|
|
974
|
+
results.push(result.results ?? []);
|
|
975
|
+
}
|
|
976
|
+
if (results.length !== statements.length) throw new D1ExecutionError();
|
|
922
977
|
return results;
|
|
923
978
|
};
|
|
924
979
|
const adapter = createDatabasePluginAdapter("d1Database", createD1Implementation({
|
|
@@ -1036,7 +1091,8 @@ const parseTemplate = ({ templates, expressions, tokens, index, template }) => {
|
|
|
1036
1091
|
const newTokens = concatTokens(tokens, nextTokens, leadingWhitespaces);
|
|
1037
1092
|
if (index === expressions.length) return newTokens;
|
|
1038
1093
|
const expression = expressions[index];
|
|
1039
|
-
|
|
1094
|
+
const expressionTokens = Array.isArray(expression) ? expression.map((expression) => parseExpression(expression)) : [parseExpression(expression)];
|
|
1095
|
+
return concatTokens(newTokens, expressionTokens, trailingWhitespaces);
|
|
1040
1096
|
};
|
|
1041
1097
|
const splitByWhitespaces = (template, rawTemplate) => {
|
|
1042
1098
|
if (rawTemplate.length === 0) return {
|
|
@@ -1069,7 +1125,7 @@ const splitByWhitespaces = (template, rawTemplate) => {
|
|
|
1069
1125
|
trailingWhitespaces
|
|
1070
1126
|
};
|
|
1071
1127
|
};
|
|
1072
|
-
const DELIMITERS = new Set([
|
|
1128
|
+
const DELIMITERS = /* @__PURE__ */ new Set([
|
|
1073
1129
|
" ",
|
|
1074
1130
|
" ",
|
|
1075
1131
|
"\r",
|
|
@@ -1121,7 +1177,8 @@ const normalizeFdSpecificOptions = (options) => {
|
|
|
1121
1177
|
};
|
|
1122
1178
|
const normalizeFdSpecificOption = (options, optionName) => {
|
|
1123
1179
|
const optionBaseArray = Array.from({ length: getStdioLength(options) + 1 });
|
|
1124
|
-
|
|
1180
|
+
const optionArray = normalizeFdSpecificValue(options[optionName], optionBaseArray, optionName);
|
|
1181
|
+
return addDefaultValue$1(optionArray, optionName);
|
|
1125
1182
|
};
|
|
1126
1183
|
const getStdioLength = ({ stdio }) => Array.isArray(stdio) ? Math.max(stdio.length, STANDARD_STREAMS_ALIASES.length) : STANDARD_STREAMS_ALIASES.length;
|
|
1127
1184
|
const normalizeFdSpecificValue = (optionValue, optionArray, optionName) => isPlainObject(optionValue) ? normalizeOptionObject(optionValue, optionArray, optionName) : optionArray.fill(optionValue);
|
|
@@ -1154,7 +1211,7 @@ const addDefaultValue$1 = (optionArray, optionName) => optionArray.map((optionVa
|
|
|
1154
1211
|
const DEFAULT_OPTIONS = {
|
|
1155
1212
|
lines: false,
|
|
1156
1213
|
buffer: true,
|
|
1157
|
-
maxBuffer:
|
|
1214
|
+
maxBuffer: 1e8,
|
|
1158
1215
|
verbose: debuglog("execa").enabled ? "full" : "none",
|
|
1159
1216
|
stripFinalNewline: true
|
|
1160
1217
|
};
|
|
@@ -1202,7 +1259,7 @@ const escapeControlCharacter = (character) => {
|
|
|
1202
1259
|
};
|
|
1203
1260
|
const getSpecialCharRegExp = () => {
|
|
1204
1261
|
try {
|
|
1205
|
-
return
|
|
1262
|
+
return new RegExp("\\p{Separator}|\\p{Other}", "gu");
|
|
1206
1263
|
} catch {
|
|
1207
1264
|
return /[\s\u0000-\u001F\u007F-\u009F\u00AD]/g;
|
|
1208
1265
|
}
|
|
@@ -1622,11 +1679,13 @@ const appendNewline = (printedLine) => printedLine.endsWith("\n") ? printedLine
|
|
|
1622
1679
|
//#endregion
|
|
1623
1680
|
//#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/verbose/log.js
|
|
1624
1681
|
const verboseLog = ({ type, verboseMessage, fdNumber, verboseInfo, result }) => {
|
|
1625
|
-
const
|
|
1682
|
+
const verboseObject = getVerboseObject({
|
|
1626
1683
|
type,
|
|
1627
1684
|
result,
|
|
1628
1685
|
verboseInfo
|
|
1629
|
-
})
|
|
1686
|
+
});
|
|
1687
|
+
const printedLines = getPrintedLines(verboseMessage, verboseObject);
|
|
1688
|
+
const finalLines = applyVerboseOnLines(printedLines, verboseInfo, fdNumber);
|
|
1630
1689
|
if (finalLines !== "") console.warn(finalLines.slice(0, -1));
|
|
1631
1690
|
};
|
|
1632
1691
|
const getVerboseObject = ({ type, result, verboseInfo: { escapedCommand, commandId, rawOptions: { piped = false, ...options } } }) => ({
|
|
@@ -1649,7 +1708,8 @@ const getPrintedLine = (verboseObject) => {
|
|
|
1649
1708
|
};
|
|
1650
1709
|
};
|
|
1651
1710
|
const serializeVerboseMessage = (message) => {
|
|
1652
|
-
|
|
1711
|
+
const messageString = typeof message === "string" ? message : inspect(message);
|
|
1712
|
+
return escapeLines(messageString).replaceAll(" ", " ".repeat(TAB_SIZE));
|
|
1653
1713
|
};
|
|
1654
1714
|
const TAB_SIZE = 2;
|
|
1655
1715
|
//#endregion
|
|
@@ -1694,7 +1754,8 @@ const getDurationMs = (startTime) => Number(hrtime.bigint() - startTime) / 1e6;
|
|
|
1694
1754
|
const handleCommand = (filePath, rawArguments, rawOptions) => {
|
|
1695
1755
|
const startTime = getStartTime();
|
|
1696
1756
|
const { command, escapedCommand } = joinCommand(filePath, rawArguments);
|
|
1697
|
-
const
|
|
1757
|
+
const verbose = normalizeFdSpecificOption(rawOptions, "verbose");
|
|
1758
|
+
const verboseInfo = getVerboseInfo(verbose, escapedCommand, { ...rawOptions });
|
|
1698
1759
|
logCommand(escapedCommand, verboseInfo);
|
|
1699
1760
|
return {
|
|
1700
1761
|
command,
|
|
@@ -1815,7 +1876,8 @@ var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1815
1876
|
const getNotFoundError = (cmd) => Object.assign(/* @__PURE__ */ new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
1816
1877
|
const getPathInfo = (cmd, opt) => {
|
|
1817
1878
|
const colon = opt.colon || COLON;
|
|
1818
|
-
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [...isWindows ? [process.cwd()] : [], ...(opt.path || process.env.PATH ||
|
|
1879
|
+
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [...isWindows ? [process.cwd()] : [], ...(opt.path || process.env.PATH ||
|
|
1880
|
+
/* istanbul ignore next: very unusual */ "").split(colon)];
|
|
1819
1881
|
const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
|
|
1820
1882
|
const pathExt = isWindows ? pathExtExe.split(colon) : [""];
|
|
1821
1883
|
if (isWindows) {
|
|
@@ -1840,14 +1902,17 @@ var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1840
1902
|
const ppRaw = pathEnv[i];
|
|
1841
1903
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
1842
1904
|
const pCmd = path$7.join(pathPart, cmd);
|
|
1843
|
-
|
|
1905
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
1906
|
+
resolve(subStep(p, i, 0));
|
|
1844
1907
|
});
|
|
1845
1908
|
const subStep = (p, i, ii) => new Promise((resolve, reject) => {
|
|
1846
1909
|
if (ii === pathExt.length) return resolve(step(i + 1));
|
|
1847
1910
|
const ext = pathExt[ii];
|
|
1848
1911
|
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
1849
|
-
if (!er && is)
|
|
1850
|
-
|
|
1912
|
+
if (!er && is) {
|
|
1913
|
+
if (opt.all) found.push(p + ext);
|
|
1914
|
+
else return resolve(p + ext);
|
|
1915
|
+
}
|
|
1851
1916
|
return resolve(subStep(p, i, ii + 1));
|
|
1852
1917
|
});
|
|
1853
1918
|
});
|
|
@@ -1865,8 +1930,10 @@ var require_which = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1865
1930
|
for (let j = 0; j < pathExt.length; j++) {
|
|
1866
1931
|
const cur = p + pathExt[j];
|
|
1867
1932
|
try {
|
|
1868
|
-
if (isexe.sync(cur, { pathExt: pathExtExe }))
|
|
1869
|
-
|
|
1933
|
+
if (isexe.sync(cur, { pathExt: pathExtExe })) {
|
|
1934
|
+
if (opt.all) found.push(cur);
|
|
1935
|
+
else return cur;
|
|
1936
|
+
}
|
|
1870
1937
|
} catch (ex) {}
|
|
1871
1938
|
}
|
|
1872
1939
|
}
|
|
@@ -2557,7 +2624,7 @@ const normalizeForceKillAfterDelay = (forceKillAfterDelay) => {
|
|
|
2557
2624
|
if (!Number.isFinite(forceKillAfterDelay) || forceKillAfterDelay < 0) throw new TypeError(`Expected the \`forceKillAfterDelay\` option to be a non-negative integer, got \`${forceKillAfterDelay}\` (${typeof forceKillAfterDelay})`);
|
|
2558
2625
|
return forceKillAfterDelay;
|
|
2559
2626
|
};
|
|
2560
|
-
const DEFAULT_FORCE_KILL_TIMEOUT =
|
|
2627
|
+
const DEFAULT_FORCE_KILL_TIMEOUT = 5e3;
|
|
2561
2628
|
const subprocessKill = ({ kill, options: { forceKillAfterDelay, killSignal }, onInternalError, context, controller }, signalOrError, errorArgument) => {
|
|
2562
2629
|
const { signal, error } = parseKillArguments(signalOrError, errorArgument, killSignal);
|
|
2563
2630
|
emitKillError(error, onInternalError);
|
|
@@ -2659,7 +2726,7 @@ const handleSerializationError = ({ error, methodName, isSubprocess, message })
|
|
|
2659
2726
|
if (isSerializationError(error)) throw new Error(`${getMethodName(methodName, isSubprocess)}'s argument type is invalid: the message cannot be serialized: ${String(message)}.`, { cause: error });
|
|
2660
2727
|
};
|
|
2661
2728
|
const isSerializationError = ({ code, message }) => SERIALIZATION_ERROR_CODES.has(code) || SERIALIZATION_ERROR_MESSAGES.some((serializationErrorMessage) => message.includes(serializationErrorMessage));
|
|
2662
|
-
const SERIALIZATION_ERROR_CODES = new Set(["ERR_MISSING_ARGS", "ERR_INVALID_ARG_TYPE"]);
|
|
2729
|
+
const SERIALIZATION_ERROR_CODES = /* @__PURE__ */ new Set(["ERR_MISSING_ARGS", "ERR_INVALID_ARG_TYPE"]);
|
|
2663
2730
|
const SERIALIZATION_ERROR_MESSAGES = [
|
|
2664
2731
|
"could not be cloned",
|
|
2665
2732
|
"circular structure",
|
|
@@ -2869,7 +2936,8 @@ const isConnected = (anyProcess) => {
|
|
|
2869
2936
|
//#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/ipc/strict.js
|
|
2870
2937
|
const handleSendStrict = ({ anyProcess, channel, isSubprocess, message, strict }) => {
|
|
2871
2938
|
if (!strict) return message;
|
|
2872
|
-
const
|
|
2939
|
+
const ipcEmitter = getIpcEmitter(anyProcess, channel, isSubprocess);
|
|
2940
|
+
const hasListeners = hasMessageListeners(anyProcess, ipcEmitter);
|
|
2873
2941
|
return {
|
|
2874
2942
|
id: count++,
|
|
2875
2943
|
type: REQUEST_TYPE,
|
|
@@ -3101,7 +3169,8 @@ const throwOnGracefulCancel = ({ subprocess, cancelSignal, gracefulCancel, force
|
|
|
3101
3169
|
})] : [];
|
|
3102
3170
|
const sendOnAbort = async ({ subprocess, cancelSignal, forceKillAfterDelay, context, controller: { signal } }) => {
|
|
3103
3171
|
await onAbortedSignal(cancelSignal, signal);
|
|
3104
|
-
|
|
3172
|
+
const reason = getReason(cancelSignal);
|
|
3173
|
+
await sendAbort(subprocess, reason);
|
|
3105
3174
|
killOnTimeout({
|
|
3106
3175
|
kill: subprocess.kill,
|
|
3107
3176
|
forceKillAfterDelay,
|
|
@@ -3213,8 +3282,8 @@ Please rename it to ${serializeEncoding(correctEncoding)}.`);
|
|
|
3213
3282
|
throw new TypeError(`Invalid option \`encoding: ${serializeEncoding(encoding)}\`.
|
|
3214
3283
|
Please rename it to one of: ${correctEncodings}.`);
|
|
3215
3284
|
};
|
|
3216
|
-
const TEXT_ENCODINGS = new Set(["utf8", "utf16le"]);
|
|
3217
|
-
const BINARY_ENCODINGS = new Set([
|
|
3285
|
+
const TEXT_ENCODINGS = /* @__PURE__ */ new Set(["utf8", "utf16le"]);
|
|
3286
|
+
const BINARY_ENCODINGS = /* @__PURE__ */ new Set([
|
|
3218
3287
|
"buffer",
|
|
3219
3288
|
"hex",
|
|
3220
3289
|
"base64",
|
|
@@ -3222,7 +3291,7 @@ const BINARY_ENCODINGS = new Set([
|
|
|
3222
3291
|
"latin1",
|
|
3223
3292
|
"ascii"
|
|
3224
3293
|
]);
|
|
3225
|
-
const ENCODINGS = new Set([...TEXT_ENCODINGS, ...BINARY_ENCODINGS]);
|
|
3294
|
+
const ENCODINGS = /* @__PURE__ */ new Set([...TEXT_ENCODINGS, ...BINARY_ENCODINGS]);
|
|
3226
3295
|
const getCorrectEncoding = (encoding) => {
|
|
3227
3296
|
if (encoding === null) return "buffer";
|
|
3228
3297
|
if (typeof encoding !== "string") return;
|
|
@@ -3269,7 +3338,8 @@ const normalizeOptions = (filePath, rawArguments, rawOptions) => {
|
|
|
3269
3338
|
rawOptions.cwd = normalizeCwd(rawOptions.cwd);
|
|
3270
3339
|
const [processedFile, processedArguments, processedOptions] = handleNodeOption(filePath, rawArguments, rawOptions);
|
|
3271
3340
|
const { command: file, args: commandArguments, options: initialOptions } = import_cross_spawn.default._parse(processedFile, processedArguments, processedOptions);
|
|
3272
|
-
const
|
|
3341
|
+
const fdOptions = normalizeFdSpecificOptions(initialOptions);
|
|
3342
|
+
const options = addDefaultOptions(fdOptions);
|
|
3273
3343
|
validateTimeout(options);
|
|
3274
3344
|
validateEncoding(options);
|
|
3275
3345
|
validateIpcInputOption(options);
|
|
@@ -3470,14 +3540,17 @@ const getStreamContents$1 = async (stream, { init, convertChunk, getSize, trunca
|
|
|
3470
3540
|
const state = init();
|
|
3471
3541
|
state.length = 0;
|
|
3472
3542
|
try {
|
|
3473
|
-
for await (const chunk of asyncIterable)
|
|
3474
|
-
convertedChunk
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3543
|
+
for await (const chunk of asyncIterable) {
|
|
3544
|
+
const convertedChunk = convertChunk[getChunkType(chunk)](chunk, state);
|
|
3545
|
+
appendChunk({
|
|
3546
|
+
convertedChunk,
|
|
3547
|
+
state,
|
|
3548
|
+
getSize,
|
|
3549
|
+
truncateChunk,
|
|
3550
|
+
addChunk,
|
|
3551
|
+
maxBuffer
|
|
3552
|
+
});
|
|
3553
|
+
}
|
|
3481
3554
|
appendFinalChunk({
|
|
3482
3555
|
state,
|
|
3483
3556
|
convertChunk,
|
|
@@ -3763,7 +3836,8 @@ const getErrorPrefix = ({ originalError, timedOut, timeout, isMaxBuffer, maxBuff
|
|
|
3763
3836
|
const getForcefulSuffix = (isForcefullyTerminated, forceKillAfterDelay) => isForcefullyTerminated ? ` and was forcefully terminated after ${forceKillAfterDelay} milliseconds` : "";
|
|
3764
3837
|
const getOriginalMessage = (originalError, cwd) => {
|
|
3765
3838
|
if (originalError instanceof DiscardedError) return;
|
|
3766
|
-
const
|
|
3839
|
+
const originalMessage = isExecaError(originalError) ? originalError.originalMessage : String(originalError?.message ?? originalError);
|
|
3840
|
+
const escapedOriginalMessage = escapeLines(fixCwdError(originalMessage, cwd));
|
|
3767
3841
|
return escapedOriginalMessage === "" ? void 0 : escapedOriginalMessage;
|
|
3768
3842
|
};
|
|
3769
3843
|
const serializeIpcMessage = (ipcMessage) => typeof ipcMessage === "string" ? ipcMessage : inspect(ipcMessage);
|
|
@@ -3974,26 +4048,28 @@ function prettyMilliseconds(milliseconds, options) {
|
|
|
3974
4048
|
add(Number(parsed.hours), "hour", "h");
|
|
3975
4049
|
}
|
|
3976
4050
|
add(Number(parsed.minutes), "minute", "m");
|
|
3977
|
-
if (!options.hideSeconds)
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
4051
|
+
if (!options.hideSeconds) {
|
|
4052
|
+
if (options.separateMilliseconds || options.formatSubMilliseconds || !options.colonNotation && milliseconds < 1e3 && !options.subSecondsAsDecimals) {
|
|
4053
|
+
const seconds = Number(parsed.seconds);
|
|
4054
|
+
const milliseconds = Number(parsed.milliseconds);
|
|
4055
|
+
const microseconds = Number(parsed.microseconds);
|
|
4056
|
+
const nanoseconds = Number(parsed.nanoseconds);
|
|
4057
|
+
add(seconds, "second", "s");
|
|
4058
|
+
if (options.formatSubMilliseconds) {
|
|
4059
|
+
add(milliseconds, "millisecond", "ms");
|
|
4060
|
+
add(microseconds, "microsecond", "µs");
|
|
4061
|
+
add(nanoseconds, "nanosecond", "ns");
|
|
4062
|
+
} else {
|
|
4063
|
+
const millisecondsAndBelow = milliseconds + microseconds / 1e3 + nanoseconds / 1e6;
|
|
4064
|
+
const millisecondsDecimalDigits = typeof options.millisecondsDecimalDigits === "number" ? options.millisecondsDecimalDigits : 0;
|
|
4065
|
+
const millisecondsString = millisecondsDecimalDigits ? millisecondsAndBelow.toFixed(millisecondsDecimalDigits) : millisecondsAndBelow >= 1 ? Math.round(millisecondsAndBelow) : Math.ceil(millisecondsAndBelow);
|
|
4066
|
+
add(Number.parseFloat(millisecondsString), "millisecond", "ms", millisecondsString);
|
|
4067
|
+
}
|
|
3987
4068
|
} else {
|
|
3988
|
-
const
|
|
3989
|
-
const
|
|
3990
|
-
|
|
3991
|
-
add(Number.parseFloat(millisecondsString), "millisecond", "ms", millisecondsString);
|
|
4069
|
+
const secondsFixed = floorDecimals((isBigInt ? Number(milliseconds % ONE_DAY_IN_MILLISECONDS) : milliseconds) / 1e3 % 60, typeof options.secondsDecimalDigits === "number" ? options.secondsDecimalDigits : 1);
|
|
4070
|
+
const secondsString = options.keepDecimalsOnWholeSeconds ? secondsFixed : secondsFixed.replace(/\.0+$/, "");
|
|
4071
|
+
add(Number.parseFloat(secondsString), "second", "s", secondsString);
|
|
3992
4072
|
}
|
|
3993
|
-
} else {
|
|
3994
|
-
const secondsFixed = floorDecimals((isBigInt ? Number(milliseconds % ONE_DAY_IN_MILLISECONDS) : milliseconds) / 1e3 % 60, typeof options.secondsDecimalDigits === "number" ? options.secondsDecimalDigits : 1);
|
|
3995
|
-
const secondsString = options.keepDecimalsOnWholeSeconds ? secondsFixed : secondsFixed.replace(/\.0+$/, "");
|
|
3996
|
-
add(Number.parseFloat(secondsString), "second", "s", secondsString);
|
|
3997
4073
|
}
|
|
3998
4074
|
if (result.length === 0) return sign + "0" + (options.verbose ? " milliseconds" : "ms");
|
|
3999
4075
|
const separator = options.colonNotation ? ":" : " ";
|
|
@@ -4018,9 +4094,10 @@ const logResult = (result, verboseInfo) => {
|
|
|
4018
4094
|
logDuration(result, verboseInfo);
|
|
4019
4095
|
};
|
|
4020
4096
|
const logDuration = (result, verboseInfo) => {
|
|
4097
|
+
const verboseMessage = `(done in ${prettyMilliseconds(result.durationMs)})`;
|
|
4021
4098
|
verboseLog({
|
|
4022
4099
|
type: "duration",
|
|
4023
|
-
verboseMessage
|
|
4100
|
+
verboseMessage,
|
|
4024
4101
|
verboseInfo,
|
|
4025
4102
|
result
|
|
4026
4103
|
});
|
|
@@ -4088,10 +4165,10 @@ const isTransformOptions = (value) => isPlainObject(value) && (value.transform !
|
|
|
4088
4165
|
const isUrl = (value) => Object.prototype.toString.call(value) === "[object URL]";
|
|
4089
4166
|
const isRegularUrl = (value) => isUrl(value) && value.protocol !== "file:";
|
|
4090
4167
|
const isFilePathObject = (value) => isPlainObject(value) && Object.keys(value).length > 0 && Object.keys(value).every((key) => FILE_PATH_KEYS.has(key)) && isFilePathString(value.file);
|
|
4091
|
-
const FILE_PATH_KEYS = new Set(["file", "append"]);
|
|
4168
|
+
const FILE_PATH_KEYS = /* @__PURE__ */ new Set(["file", "append"]);
|
|
4092
4169
|
const isFilePathString = (file) => typeof file === "string";
|
|
4093
4170
|
const isUnknownStdioString = (type, value) => type === "native" && typeof value === "string" && !KNOWN_STDIO_STRINGS.has(value);
|
|
4094
|
-
const KNOWN_STDIO_STRINGS = new Set([
|
|
4171
|
+
const KNOWN_STDIO_STRINGS = /* @__PURE__ */ new Set([
|
|
4095
4172
|
"ipc",
|
|
4096
4173
|
"ignore",
|
|
4097
4174
|
"inherit",
|
|
@@ -4105,24 +4182,24 @@ const isTransformStream = (value) => isReadableStream(value?.readable) && isWrit
|
|
|
4105
4182
|
const isAsyncIterableObject = (value) => isObject(value) && typeof value[Symbol.asyncIterator] === "function";
|
|
4106
4183
|
const isIterableObject = (value) => isObject(value) && typeof value[Symbol.iterator] === "function";
|
|
4107
4184
|
const isObject = (value) => typeof value === "object" && value !== null;
|
|
4108
|
-
const TRANSFORM_TYPES = new Set([
|
|
4185
|
+
const TRANSFORM_TYPES = /* @__PURE__ */ new Set([
|
|
4109
4186
|
"generator",
|
|
4110
4187
|
"asyncGenerator",
|
|
4111
4188
|
"duplex",
|
|
4112
4189
|
"webTransform"
|
|
4113
4190
|
]);
|
|
4114
|
-
const FILE_TYPES = new Set([
|
|
4191
|
+
const FILE_TYPES = /* @__PURE__ */ new Set([
|
|
4115
4192
|
"fileUrl",
|
|
4116
4193
|
"filePath",
|
|
4117
4194
|
"fileNumber"
|
|
4118
4195
|
]);
|
|
4119
|
-
const SPECIAL_DUPLICATE_TYPES_SYNC = new Set(["fileUrl", "filePath"]);
|
|
4120
|
-
const SPECIAL_DUPLICATE_TYPES = new Set([
|
|
4196
|
+
const SPECIAL_DUPLICATE_TYPES_SYNC = /* @__PURE__ */ new Set(["fileUrl", "filePath"]);
|
|
4197
|
+
const SPECIAL_DUPLICATE_TYPES = /* @__PURE__ */ new Set([
|
|
4121
4198
|
...SPECIAL_DUPLICATE_TYPES_SYNC,
|
|
4122
4199
|
"webStream",
|
|
4123
4200
|
"nodeStream"
|
|
4124
4201
|
]);
|
|
4125
|
-
const FORBID_DUPLICATE_TYPES = new Set(["webTransform", "duplex"]);
|
|
4202
|
+
const FORBID_DUPLICATE_TYPES = /* @__PURE__ */ new Set(["webTransform", "duplex"]);
|
|
4126
4203
|
const TYPE_TO_MESSAGE = {
|
|
4127
4204
|
generator: "a generator",
|
|
4128
4205
|
asyncGenerator: "an async generator",
|
|
@@ -4455,7 +4532,8 @@ const validateDuplicateStreamSync = ({ otherStdioItems, type, value, optionName,
|
|
|
4455
4532
|
const getDuplicateStreamInstance = ({ otherStdioItems, type, value, optionName, direction }) => {
|
|
4456
4533
|
const duplicateStdioItems = otherStdioItems.filter((stdioItem) => hasSameValue(stdioItem, value));
|
|
4457
4534
|
if (duplicateStdioItems.length === 0) return;
|
|
4458
|
-
|
|
4535
|
+
const differentStdioItem = duplicateStdioItems.find((stdioItem) => stdioItem.direction !== direction);
|
|
4536
|
+
throwOnDuplicateStream(differentStdioItem, optionName, type);
|
|
4459
4537
|
return direction === "output" ? duplicateStdioItems[0].stream : void 0;
|
|
4460
4538
|
};
|
|
4461
4539
|
const hasSameValue = ({ type, value }, secondValue) => {
|
|
@@ -4464,7 +4542,8 @@ const hasSameValue = ({ type, value }, secondValue) => {
|
|
|
4464
4542
|
return value === secondValue;
|
|
4465
4543
|
};
|
|
4466
4544
|
const validateDuplicateTransform = ({ otherStdioItems, type, value, optionName }) => {
|
|
4467
|
-
|
|
4545
|
+
const duplicateStdioItem = otherStdioItems.find(({ value: { transform } }) => transform === value.transform);
|
|
4546
|
+
throwOnDuplicateStream(duplicateStdioItem, optionName, type);
|
|
4468
4547
|
};
|
|
4469
4548
|
const throwOnDuplicateStream = (stdioItem, optionName, type) => {
|
|
4470
4549
|
if (stdioItem !== void 0) throw new TypeError(`The \`${stdioItem.optionName}\` and \`${optionName}\` options must not target ${TYPE_TO_MESSAGE[type]} that is the same.`);
|
|
@@ -4472,13 +4551,14 @@ const throwOnDuplicateStream = (stdioItem, optionName, type) => {
|
|
|
4472
4551
|
//#endregion
|
|
4473
4552
|
//#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/stdio/handle.js
|
|
4474
4553
|
const handleStdio = (addProperties, options, verboseInfo, isSync) => {
|
|
4554
|
+
const initialFileDescriptors = normalizeStdioOption(options, verboseInfo, isSync).map((stdioOption, fdNumber) => getFileDescriptor({
|
|
4555
|
+
stdioOption,
|
|
4556
|
+
fdNumber,
|
|
4557
|
+
options,
|
|
4558
|
+
isSync
|
|
4559
|
+
}));
|
|
4475
4560
|
const fileDescriptors = getFinalFileDescriptors({
|
|
4476
|
-
initialFileDescriptors
|
|
4477
|
-
stdioOption,
|
|
4478
|
-
fdNumber,
|
|
4479
|
-
options,
|
|
4480
|
-
isSync
|
|
4481
|
-
})),
|
|
4561
|
+
initialFileDescriptors,
|
|
4482
4562
|
addProperties,
|
|
4483
4563
|
options,
|
|
4484
4564
|
isSync
|
|
@@ -4495,13 +4575,14 @@ const getFileDescriptor = ({ stdioOption, fdNumber, options, isSync }) => {
|
|
|
4495
4575
|
optionName
|
|
4496
4576
|
});
|
|
4497
4577
|
const direction = getStreamDirection(initialStdioItems, fdNumber, optionName);
|
|
4498
|
-
const
|
|
4578
|
+
const stdioItems = initialStdioItems.map((stdioItem) => handleNativeStream({
|
|
4499
4579
|
stdioItem,
|
|
4500
4580
|
isStdioArray,
|
|
4501
4581
|
fdNumber,
|
|
4502
4582
|
direction,
|
|
4503
4583
|
isSync
|
|
4504
|
-
}))
|
|
4584
|
+
}));
|
|
4585
|
+
const normalizedStdioItems = normalizeTransforms(stdioItems, optionName, direction, options);
|
|
4505
4586
|
const objectMode = getFdObjectMode(normalizedStdioItems, direction);
|
|
4506
4587
|
validateFileObjectMode(normalizedStdioItems, objectMode);
|
|
4507
4588
|
return {
|
|
@@ -4511,7 +4592,8 @@ const getFileDescriptor = ({ stdioOption, fdNumber, options, isSync }) => {
|
|
|
4511
4592
|
};
|
|
4512
4593
|
};
|
|
4513
4594
|
const initializeStdioItems = ({ stdioOption, fdNumber, options, optionName }) => {
|
|
4514
|
-
const
|
|
4595
|
+
const initialStdioItems = [...(Array.isArray(stdioOption) ? stdioOption : [stdioOption]).map((value) => initializeStdioItem(value, optionName)), ...handleInputOptions(options, fdNumber)];
|
|
4596
|
+
const stdioItems = filterDuplicates(initialStdioItems);
|
|
4515
4597
|
const isStdioArray = stdioItems.length > 1;
|
|
4516
4598
|
validateStdioArray(stdioItems, isStdioArray, optionName);
|
|
4517
4599
|
validateStreams(stdioItems);
|
|
@@ -4530,7 +4612,7 @@ const validateStdioArray = (stdioItems, isStdioArray, optionName) => {
|
|
|
4530
4612
|
if (!isStdioArray) return;
|
|
4531
4613
|
for (const { value, optionName } of stdioItems) if (INVALID_STDIO_ARRAY_OPTIONS.has(value)) throw new Error(`The \`${optionName}\` option must not include \`${value}\`.`);
|
|
4532
4614
|
};
|
|
4533
|
-
const INVALID_STDIO_ARRAY_OPTIONS = new Set(["ignore", "ipc"]);
|
|
4615
|
+
const INVALID_STDIO_ARRAY_OPTIONS = /* @__PURE__ */ new Set(["ignore", "ipc"]);
|
|
4534
4616
|
const validateStreams = (stdioItems) => {
|
|
4535
4617
|
for (const stdioItem of stdioItems) validateFileStdio(stdioItem);
|
|
4536
4618
|
};
|
|
@@ -4859,7 +4941,10 @@ const generatorToStream = ({ value, value: { transform, final, writableObjectMod
|
|
|
4859
4941
|
const runGeneratorsSync = (chunks, stdioItems, encoding, isInput) => {
|
|
4860
4942
|
const generators = stdioItems.filter(({ type }) => type === "generator");
|
|
4861
4943
|
const reversedGenerators = isInput ? generators.reverse() : generators;
|
|
4862
|
-
for (const { value, optionName } of reversedGenerators)
|
|
4944
|
+
for (const { value, optionName } of reversedGenerators) {
|
|
4945
|
+
const generators = addInternalGenerators(value, encoding, optionName);
|
|
4946
|
+
chunks = runTransformSync(generators, chunks);
|
|
4947
|
+
}
|
|
4863
4948
|
return chunks;
|
|
4864
4949
|
};
|
|
4865
4950
|
const addInternalGenerators = ({ transform, final, binary, writableObjectMode, readableObjectMode, preserveNewlines }, encoding, optionName) => {
|
|
@@ -4895,7 +4980,8 @@ const addInputOptionSync = (fileDescriptors, fdNumber, options) => {
|
|
|
4895
4980
|
const [{ type, optionName }] = allStdioItems;
|
|
4896
4981
|
throw new TypeError(`Only the \`stdin\` option, not \`${optionName}\`, can be ${TYPE_TO_MESSAGE[type]} with synchronous methods.`);
|
|
4897
4982
|
}
|
|
4898
|
-
|
|
4983
|
+
const transformedContents = allStdioItems.map(({ contents }) => contents).map((contents) => applySingleInputGeneratorsSync(contents, stdioItems));
|
|
4984
|
+
options.input = joinToUint8Array(transformedContents);
|
|
4899
4985
|
};
|
|
4900
4986
|
const applySingleInputGeneratorsSync = (contents, stdioItems) => {
|
|
4901
4987
|
const newContents = runGeneratorsSync(contents, stdioItems, "utf8", true);
|
|
@@ -4910,7 +4996,7 @@ const validateSerializable = (newContents) => {
|
|
|
4910
4996
|
//#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/verbose/output.js
|
|
4911
4997
|
const shouldLogOutput = ({ stdioItems, encoding, verboseInfo, fdNumber }) => fdNumber !== "all" && isFullVerbose(verboseInfo, fdNumber) && !BINARY_ENCODINGS.has(encoding) && fdUsesVerbose(fdNumber) && (stdioItems.some(({ type, value }) => type === "native" && PIPED_STDIO_VALUES.has(value)) || stdioItems.every(({ type }) => TRANSFORM_TYPES.has(type)));
|
|
4912
4998
|
const fdUsesVerbose = (fdNumber) => fdNumber === 1 || fdNumber === 2;
|
|
4913
|
-
const PIPED_STDIO_VALUES = new Set(["pipe", "overlapped"]);
|
|
4999
|
+
const PIPED_STDIO_VALUES = /* @__PURE__ */ new Set(["pipe", "overlapped"]);
|
|
4914
5000
|
const logLines = async (linesIterable, stream, fdNumber, verboseInfo) => {
|
|
4915
5001
|
for await (const line of linesIterable) if (!isPipingStream(stream)) logLine(line, fdNumber, verboseInfo);
|
|
4916
5002
|
};
|
|
@@ -4919,9 +5005,10 @@ const logLinesSync = (linesArray, fdNumber, verboseInfo) => {
|
|
|
4919
5005
|
};
|
|
4920
5006
|
const isPipingStream = (stream) => stream._readableState.pipes.length > 0;
|
|
4921
5007
|
const logLine = (line, fdNumber, verboseInfo) => {
|
|
5008
|
+
const verboseMessage = serializeVerboseMessage(line);
|
|
4922
5009
|
verboseLog({
|
|
4923
5010
|
type: "output",
|
|
4924
|
-
verboseMessage
|
|
5011
|
+
verboseMessage,
|
|
4925
5012
|
fdNumber,
|
|
4926
5013
|
verboseInfo
|
|
4927
5014
|
});
|
|
@@ -4947,10 +5034,12 @@ const transformOutputSync = ({ fileDescriptors, syncResult: { output }, options,
|
|
|
4947
5034
|
};
|
|
4948
5035
|
const transformOutputResultSync = ({ result, fileDescriptors, fdNumber, state, outputFiles, isMaxBuffer, verboseInfo }, { buffer, encoding, lines, stripFinalNewline, maxBuffer }) => {
|
|
4949
5036
|
if (result === null) return;
|
|
4950
|
-
const
|
|
5037
|
+
const truncatedResult = truncateMaxBufferSync(result, isMaxBuffer, maxBuffer);
|
|
5038
|
+
const uint8ArrayResult = bufferToUint8Array(truncatedResult);
|
|
4951
5039
|
const { stdioItems, objectMode } = fileDescriptors[fdNumber];
|
|
5040
|
+
const chunks = runOutputGeneratorsSync([uint8ArrayResult], stdioItems, encoding, state);
|
|
4952
5041
|
const { serializedResult, finalResult = serializedResult } = serializeChunks({
|
|
4953
|
-
chunks
|
|
5042
|
+
chunks,
|
|
4954
5043
|
objectMode,
|
|
4955
5044
|
encoding,
|
|
4956
5045
|
lines,
|
|
@@ -5074,7 +5163,7 @@ const getResultError = (error, exitCode, signal) => {
|
|
|
5074
5163
|
//#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/methods/main-sync.js
|
|
5075
5164
|
const execaCoreSync = (rawFile, rawArguments, rawOptions) => {
|
|
5076
5165
|
const { file, commandArguments, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors } = handleSyncArguments(rawFile, rawArguments, rawOptions);
|
|
5077
|
-
|
|
5166
|
+
const result = spawnSubprocessSync({
|
|
5078
5167
|
file,
|
|
5079
5168
|
commandArguments,
|
|
5080
5169
|
options,
|
|
@@ -5083,11 +5172,13 @@ const execaCoreSync = (rawFile, rawArguments, rawOptions) => {
|
|
|
5083
5172
|
verboseInfo,
|
|
5084
5173
|
fileDescriptors,
|
|
5085
5174
|
startTime
|
|
5086
|
-
})
|
|
5175
|
+
});
|
|
5176
|
+
return handleResult(result, verboseInfo, options);
|
|
5087
5177
|
};
|
|
5088
5178
|
const handleSyncArguments = (rawFile, rawArguments, rawOptions) => {
|
|
5089
5179
|
const { command, escapedCommand, startTime, verboseInfo } = handleCommand(rawFile, rawArguments, rawOptions);
|
|
5090
|
-
const
|
|
5180
|
+
const syncOptions = normalizeSyncOptions(rawOptions);
|
|
5181
|
+
const { file, commandArguments, options } = normalizeOptions(rawFile, rawArguments, syncOptions);
|
|
5091
5182
|
validateSyncOptions(options);
|
|
5092
5183
|
return {
|
|
5093
5184
|
file,
|
|
@@ -5132,14 +5223,16 @@ const spawnSubprocessSync = ({ file, commandArguments, options, command, escaped
|
|
|
5132
5223
|
isMaxBuffer,
|
|
5133
5224
|
verboseInfo
|
|
5134
5225
|
});
|
|
5226
|
+
const stdio = output.map((stdioOutput, fdNumber) => stripNewline(stdioOutput, options, fdNumber));
|
|
5227
|
+
const all = stripNewline(getAllSync(output, options), options, "all");
|
|
5135
5228
|
return getSyncResult({
|
|
5136
5229
|
error,
|
|
5137
5230
|
exitCode,
|
|
5138
5231
|
signal,
|
|
5139
5232
|
timedOut,
|
|
5140
5233
|
isMaxBuffer,
|
|
5141
|
-
stdio
|
|
5142
|
-
all
|
|
5234
|
+
stdio,
|
|
5235
|
+
all,
|
|
5143
5236
|
options,
|
|
5144
5237
|
command,
|
|
5145
5238
|
escapedCommand,
|
|
@@ -5149,7 +5242,8 @@ const spawnSubprocessSync = ({ file, commandArguments, options, command, escaped
|
|
|
5149
5242
|
const runSubprocessSync = ({ file, commandArguments, options, command, escapedCommand, fileDescriptors, startTime }) => {
|
|
5150
5243
|
try {
|
|
5151
5244
|
addInputOptionsSync(fileDescriptors, options);
|
|
5152
|
-
|
|
5245
|
+
const normalizedOptions = normalizeSpawnSyncOptions(options);
|
|
5246
|
+
return spawnSync(file, commandArguments, normalizedOptions);
|
|
5153
5247
|
} catch (error) {
|
|
5154
5248
|
return makeEarlyError({
|
|
5155
5249
|
error,
|
|
@@ -5363,17 +5457,18 @@ const handleEarlyError = ({ error, command, escapedCommand, fileDescriptors, opt
|
|
|
5363
5457
|
writable,
|
|
5364
5458
|
duplex
|
|
5365
5459
|
});
|
|
5460
|
+
const earlyError = makeEarlyError({
|
|
5461
|
+
error,
|
|
5462
|
+
command,
|
|
5463
|
+
escapedCommand,
|
|
5464
|
+
fileDescriptors,
|
|
5465
|
+
options,
|
|
5466
|
+
startTime,
|
|
5467
|
+
isSync: false
|
|
5468
|
+
});
|
|
5366
5469
|
return {
|
|
5367
5470
|
subprocess,
|
|
5368
|
-
promise: handleDummyPromise(
|
|
5369
|
-
error,
|
|
5370
|
-
command,
|
|
5371
|
-
escapedCommand,
|
|
5372
|
-
fileDescriptors,
|
|
5373
|
-
options,
|
|
5374
|
-
startTime,
|
|
5375
|
-
isSync: false
|
|
5376
|
-
}), verboseInfo, options)
|
|
5471
|
+
promise: handleDummyPromise(earlyError, verboseInfo, options)
|
|
5377
5472
|
};
|
|
5378
5473
|
};
|
|
5379
5474
|
const createDummyStreams = (subprocess, fileDescriptors) => {
|
|
@@ -5557,8 +5652,10 @@ const endWhenStreamsDone = async ({ passThroughStream, stream, streams, ended, a
|
|
|
5557
5652
|
controller.abort();
|
|
5558
5653
|
updateMaxListeners(passThroughStream, -PASSTHROUGH_LISTENERS_PER_STREAM);
|
|
5559
5654
|
}
|
|
5560
|
-
if (streams.size > 0 && streams.size === ended.size + aborted.size)
|
|
5561
|
-
|
|
5655
|
+
if (streams.size > 0 && streams.size === ended.size + aborted.size) {
|
|
5656
|
+
if (ended.size === 0 && aborted.size > 0) abortStream(passThroughStream);
|
|
5657
|
+
else endStream(passThroughStream);
|
|
5658
|
+
}
|
|
5562
5659
|
};
|
|
5563
5660
|
const afterMergedStreamFinished = async (onFinished, stream, { signal }) => {
|
|
5564
5661
|
try {
|
|
@@ -5664,7 +5761,10 @@ const pipeOutputAsync = (subprocess, fileDescriptors, controller) => {
|
|
|
5664
5761
|
controller
|
|
5665
5762
|
});
|
|
5666
5763
|
}
|
|
5667
|
-
for (const [outputStream, inputStreams] of pipeGroups.entries())
|
|
5764
|
+
for (const [outputStream, inputStreams] of pipeGroups.entries()) {
|
|
5765
|
+
const inputStream = inputStreams.length === 1 ? inputStreams[0] : mergeStreams(inputStreams);
|
|
5766
|
+
pipeStreams(inputStream, outputStream);
|
|
5767
|
+
}
|
|
5668
5768
|
};
|
|
5669
5769
|
const pipeTransform = (subprocess, stream, direction, fdNumber) => {
|
|
5670
5770
|
if (direction === "output") pipeStreams(subprocess.stdio[fdNumber], stream);
|
|
@@ -6153,12 +6253,13 @@ const stopReadingOnStreamEnd = async (onStreamEnd, controller, stream) => {
|
|
|
6153
6253
|
}
|
|
6154
6254
|
};
|
|
6155
6255
|
const iterateOnStream = ({ stream, controller, binary, shouldEncode, encoding, shouldSplit, preserveNewlines }) => {
|
|
6256
|
+
const onStdoutChunk = on(stream, "data", {
|
|
6257
|
+
signal: controller.signal,
|
|
6258
|
+
highWaterMark: HIGH_WATER_MARK,
|
|
6259
|
+
highWatermark: HIGH_WATER_MARK
|
|
6260
|
+
});
|
|
6156
6261
|
return iterateOnData({
|
|
6157
|
-
onStdoutChunk
|
|
6158
|
-
signal: controller.signal,
|
|
6159
|
-
highWaterMark: HIGH_WATER_MARK,
|
|
6160
|
-
highWatermark: HIGH_WATER_MARK
|
|
6161
|
-
}),
|
|
6262
|
+
onStdoutChunk,
|
|
6162
6263
|
controller,
|
|
6163
6264
|
binary,
|
|
6164
6265
|
shouldEncode,
|
|
@@ -6202,12 +6303,13 @@ const getStreamOutput = async ({ stream, onStreamEnd, fdNumber, encoding, buffer
|
|
|
6202
6303
|
await Promise.all([resumeStream(stream), logPromise]);
|
|
6203
6304
|
return;
|
|
6204
6305
|
}
|
|
6306
|
+
const stripFinalNewlineValue = getStripFinalNewline(stripFinalNewline, fdNumber);
|
|
6205
6307
|
const iterable = iterateForResult({
|
|
6206
6308
|
stream,
|
|
6207
6309
|
onStreamEnd,
|
|
6208
6310
|
lines,
|
|
6209
6311
|
encoding,
|
|
6210
|
-
stripFinalNewline:
|
|
6312
|
+
stripFinalNewline: stripFinalNewlineValue,
|
|
6211
6313
|
allMixed
|
|
6212
6314
|
});
|
|
6213
6315
|
const [output] = await Promise.all([getStreamContents({
|
|
@@ -6227,14 +6329,15 @@ const logOutputAsync = async ({ stream, onStreamEnd, fdNumber, encoding, allMixe
|
|
|
6227
6329
|
verboseInfo,
|
|
6228
6330
|
fdNumber
|
|
6229
6331
|
})) return;
|
|
6230
|
-
|
|
6332
|
+
const linesIterable = iterateForResult({
|
|
6231
6333
|
stream,
|
|
6232
6334
|
onStreamEnd,
|
|
6233
6335
|
lines: true,
|
|
6234
6336
|
encoding,
|
|
6235
6337
|
stripFinalNewline: true,
|
|
6236
6338
|
allMixed
|
|
6237
|
-
})
|
|
6339
|
+
});
|
|
6340
|
+
await logLines(linesIterable, stream, fdNumber, verboseInfo);
|
|
6238
6341
|
};
|
|
6239
6342
|
const resumeStream = async (stream) => {
|
|
6240
6343
|
await setImmediate();
|
|
@@ -6380,9 +6483,10 @@ const getAllMixed = ({ all, stdout, stderr }) => all && stdout && stderr && stdo
|
|
|
6380
6483
|
//#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/verbose/ipc.js
|
|
6381
6484
|
const shouldLogIpc = (verboseInfo) => isFullVerbose(verboseInfo, "ipc");
|
|
6382
6485
|
const logIpcOutput = (message, verboseInfo) => {
|
|
6486
|
+
const verboseMessage = serializeVerboseMessage(message);
|
|
6383
6487
|
verboseLog({
|
|
6384
6488
|
type: "ipc",
|
|
6385
|
-
verboseMessage
|
|
6489
|
+
verboseMessage,
|
|
6386
6490
|
fdNumber: "ipc",
|
|
6387
6491
|
verboseInfo
|
|
6388
6492
|
});
|
|
@@ -6778,14 +6882,15 @@ const onDuplexDestroy = async ({ subprocessStdout, subprocessStdin, subprocess,
|
|
|
6778
6882
|
const createIterable = (subprocess, encoding, { from, binary: binaryOption = false, preserveNewlines = false } = {}) => {
|
|
6779
6883
|
const binary = binaryOption || BINARY_ENCODINGS.has(encoding);
|
|
6780
6884
|
const subprocessStdout = getFromStream(subprocess, from);
|
|
6781
|
-
|
|
6885
|
+
const onStdoutData = iterateOnSubprocessStream({
|
|
6782
6886
|
subprocessStdout,
|
|
6783
6887
|
subprocess,
|
|
6784
6888
|
binary,
|
|
6785
6889
|
shouldEncode: true,
|
|
6786
6890
|
encoding,
|
|
6787
6891
|
preserveNewlines
|
|
6788
|
-
})
|
|
6892
|
+
});
|
|
6893
|
+
return iterateOnStdoutData(onStdoutData, subprocessStdout, subprocess);
|
|
6789
6894
|
};
|
|
6790
6895
|
const iterateOnStdoutData = async function* (onStdoutData, subprocessStdout, subprocess) {
|
|
6791
6896
|
try {
|
|
@@ -6945,19 +7050,22 @@ const handlePromise = async ({ subprocess, options, startTime, verboseInfo, file
|
|
|
6945
7050
|
});
|
|
6946
7051
|
controller.abort();
|
|
6947
7052
|
onInternalError.resolve();
|
|
6948
|
-
|
|
7053
|
+
const stdio = stdioResults.map((stdioResult, fdNumber) => stripNewline(stdioResult, options, fdNumber));
|
|
7054
|
+
const all = stripNewline(allResult, options, "all");
|
|
7055
|
+
const result = getAsyncResult({
|
|
6949
7056
|
errorInfo,
|
|
6950
7057
|
exitCode,
|
|
6951
7058
|
signal,
|
|
6952
|
-
stdio
|
|
6953
|
-
all
|
|
7059
|
+
stdio,
|
|
7060
|
+
all,
|
|
6954
7061
|
ipcOutput,
|
|
6955
7062
|
context,
|
|
6956
7063
|
options,
|
|
6957
7064
|
command,
|
|
6958
7065
|
escapedCommand,
|
|
6959
7066
|
startTime
|
|
6960
|
-
})
|
|
7067
|
+
});
|
|
7068
|
+
return handleResult(result, verboseInfo, options);
|
|
6961
7069
|
};
|
|
6962
7070
|
const getAsyncResult = ({ errorInfo, exitCode, signal, stdio, all, ipcOutput, context, options, command, escapedCommand, startTime }) => "error" in errorInfo ? makeError({
|
|
6963
7071
|
error: errorInfo.error,
|
|
@@ -7001,7 +7109,7 @@ const mergeOption = (optionName, boundOptionValue, optionValue) => {
|
|
|
7001
7109
|
};
|
|
7002
7110
|
return optionValue;
|
|
7003
7111
|
};
|
|
7004
|
-
const DEEP_OPTIONS = new Set(["env", ...FD_SPECIFIC_OPTIONS]);
|
|
7112
|
+
const DEEP_OPTIONS = /* @__PURE__ */ new Set(["env", ...FD_SPECIFIC_OPTIONS]);
|
|
7005
7113
|
//#endregion
|
|
7006
7114
|
//#region ../../node_modules/.pnpm/execa@9.5.2/node_modules/execa/lib/methods/create.js
|
|
7007
7115
|
const createExeca = (mapArguments, boundOptions, deepOptions, setBoundExeca) => {
|
|
@@ -7028,7 +7136,8 @@ const callBoundExeca = ({ mapArguments, deepOptions = {}, boundOptions = {}, set
|
|
|
7028
7136
|
return isSync ? execaCoreSync(file, commandArguments, options) : execaCoreAsync(file, commandArguments, options, createNested);
|
|
7029
7137
|
};
|
|
7030
7138
|
const parseArguments = ({ mapArguments, firstArgument, nextArguments, deepOptions, boundOptions }) => {
|
|
7031
|
-
const
|
|
7139
|
+
const callArguments = isTemplateString(firstArgument) ? parseTemplates(firstArgument, nextArguments) : [firstArgument, ...nextArguments];
|
|
7140
|
+
const [initialFile, initialArguments, initialOptions] = normalizeParameters(...callArguments);
|
|
7032
7141
|
const mergedOptions = mergeOptions(mergeOptions(deepOptions, boundOptions), initialOptions);
|
|
7033
7142
|
const { file = initialFile, commandArguments = initialArguments, options = mergedOptions, isSync = false } = mapArguments({
|
|
7034
7143
|
file: initialFile,
|
|
@@ -7142,6 +7251,8 @@ const isCloudflareAuthenticationError = (error) => {
|
|
|
7142
7251
|
].some((pattern) => pattern.test(getErrorOutput(error)));
|
|
7143
7252
|
};
|
|
7144
7253
|
var CloudflareAuthenticationError = class extends InitError {
|
|
7254
|
+
source;
|
|
7255
|
+
accountId;
|
|
7145
7256
|
name = "CloudflareAuthenticationError";
|
|
7146
7257
|
constructor(source, accountId, options) {
|
|
7147
7258
|
super([
|
|
@@ -7156,6 +7267,7 @@ var CloudflareAuthenticationError = class extends InitError {
|
|
|
7156
7267
|
}
|
|
7157
7268
|
};
|
|
7158
7269
|
var CloudflarePermissionError = class extends InitError {
|
|
7270
|
+
source;
|
|
7159
7271
|
name = "CloudflarePermissionError";
|
|
7160
7272
|
constructor(source, { accountId, check, requiredPermission }, options) {
|
|
7161
7273
|
super([
|
|
@@ -9294,12 +9406,14 @@ var require_parser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
9294
9406
|
s2 = peg$FAILED;
|
|
9295
9407
|
if (peg$silentFails === 0) peg$fail(peg$c39);
|
|
9296
9408
|
}
|
|
9297
|
-
if (s2 === peg$FAILED)
|
|
9298
|
-
|
|
9299
|
-
|
|
9300
|
-
|
|
9301
|
-
|
|
9302
|
-
|
|
9409
|
+
if (s2 === peg$FAILED) {
|
|
9410
|
+
if (input.charCodeAt(peg$currPos) === 69) {
|
|
9411
|
+
s2 = peg$c40;
|
|
9412
|
+
peg$currPos++;
|
|
9413
|
+
} else {
|
|
9414
|
+
s2 = peg$FAILED;
|
|
9415
|
+
if (peg$silentFails === 0) peg$fail(peg$c41);
|
|
9416
|
+
}
|
|
9303
9417
|
}
|
|
9304
9418
|
if (s2 !== peg$FAILED) {
|
|
9305
9419
|
s3 = peg$parseinteger_text();
|
|
@@ -10468,12 +10582,14 @@ var require_parser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
10468
10582
|
s11 = peg$FAILED;
|
|
10469
10583
|
if (peg$silentFails === 0) peg$fail(peg$c48);
|
|
10470
10584
|
}
|
|
10471
|
-
if (s11 === peg$FAILED)
|
|
10472
|
-
|
|
10473
|
-
|
|
10474
|
-
|
|
10475
|
-
|
|
10476
|
-
|
|
10585
|
+
if (s11 === peg$FAILED) {
|
|
10586
|
+
if (input.charCodeAt(peg$currPos) === 43) {
|
|
10587
|
+
s11 = peg$c44;
|
|
10588
|
+
peg$currPos++;
|
|
10589
|
+
} else {
|
|
10590
|
+
s11 = peg$FAILED;
|
|
10591
|
+
if (peg$silentFails === 0) peg$fail(peg$c45);
|
|
10592
|
+
}
|
|
10477
10593
|
}
|
|
10478
10594
|
if (s11 !== peg$FAILED) {
|
|
10479
10595
|
s12 = peg$parseDIGIT_OR_UNDER();
|
|
@@ -11230,9 +11346,7 @@ var require_compiler = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
11230
11346
|
case "ObjectPath":
|
|
11231
11347
|
setPath(node);
|
|
11232
11348
|
break;
|
|
11233
|
-
case "ArrayPath":
|
|
11234
|
-
addTableArray(node);
|
|
11235
|
-
break;
|
|
11349
|
+
case "ArrayPath": addTableArray(node);
|
|
11236
11350
|
}
|
|
11237
11351
|
}
|
|
11238
11352
|
return data;
|
|
@@ -11312,9 +11426,10 @@ var require_compiler = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
11312
11426
|
var key = keys[i];
|
|
11313
11427
|
traversed.push(key);
|
|
11314
11428
|
traversedPath = traversed.join(".");
|
|
11315
|
-
if (typeof ctx[key] === "undefined")
|
|
11316
|
-
|
|
11317
|
-
|
|
11429
|
+
if (typeof ctx[key] === "undefined") {
|
|
11430
|
+
if (i === keys.length - 1) ctx[key] = value;
|
|
11431
|
+
else ctx[key] = Object.create(null);
|
|
11432
|
+
} else if (i !== keys.length - 1 && valueAssignments.indexOf(traversedPath) > -1) genError("Cannot redefine existing key '" + traversedPath + "'.", line, column);
|
|
11318
11433
|
ctx = ctx[key];
|
|
11319
11434
|
if (ctx instanceof Array && ctx.length && i < keys.length - 1) ctx = ctx[ctx.length - 1];
|
|
11320
11435
|
}
|
|
@@ -12107,7 +12222,7 @@ const inputCloudflareInitSecrets = async ({ accountId, bucketName, apiToken, acc
|
|
|
12107
12222
|
}, { onCancel: () => process.exit(1) });
|
|
12108
12223
|
};
|
|
12109
12224
|
//#endregion
|
|
12110
|
-
//#region iac/
|
|
12225
|
+
//#region iac/configTemplate.ts
|
|
12111
12226
|
const getConfigScaffold = (build) => {
|
|
12112
12227
|
return createHotUpdaterConfigScaffoldFromBuilder(new ConfigBuilder().setBuildType(build).setStorage({
|
|
12113
12228
|
imports: [{
|
|
@@ -12134,6 +12249,8 @@ const getConfigScaffold = (build) => {
|
|
|
12134
12249
|
})`
|
|
12135
12250
|
}));
|
|
12136
12251
|
};
|
|
12252
|
+
//#endregion
|
|
12253
|
+
//#region iac/index.ts
|
|
12137
12254
|
const SOURCE_TEMPLATE = `// add this to your App.tsx
|
|
12138
12255
|
import { HotUpdater } from "@hot-updater/react-native";
|
|
12139
12256
|
|
|
@@ -12154,7 +12271,8 @@ export default App;`;
|
|
|
12154
12271
|
const deployWorker = async (apiToken, accountId, { credentialSource, d1DatabaseId, d1DatabaseName, nonInteractive, r2BucketName, workerName }) => {
|
|
12155
12272
|
const cwd = getCwd();
|
|
12156
12273
|
const cloudflarePackagePath = __require.resolve("@hot-updater/cloudflare/package.json", { paths: [cwd] });
|
|
12157
|
-
const
|
|
12274
|
+
const cloudflarePackageRoot = path.dirname(cloudflarePackagePath);
|
|
12275
|
+
const { tmpDir, removeTmpDir } = await copyDirToTmp(cloudflarePackageRoot);
|
|
12158
12276
|
const workerRoot = path.join(tmpDir, "worker");
|
|
12159
12277
|
try {
|
|
12160
12278
|
const wranglerConfig = JSON.parse(await fs.readFile(path.join(workerRoot, "wrangler.json"), "utf-8"));
|
|
@@ -12217,7 +12335,7 @@ const runInit = async ({ build, envFile }) => {
|
|
|
12217
12335
|
cwd,
|
|
12218
12336
|
nonInteractive
|
|
12219
12337
|
});
|
|
12220
|
-
const cf = new Cloudflare
|
|
12338
|
+
const cf = new Cloudflare({ apiToken: infrastructureApiToken });
|
|
12221
12339
|
const createKey = `create/${Math.random().toString(36).substring(2, 15)}`;
|
|
12222
12340
|
let accountId;
|
|
12223
12341
|
if (nonInteractive && existingAccountId) {
|
|
@@ -12398,7 +12516,7 @@ const runInit = async ({ build, envFile }) => {
|
|
|
12398
12516
|
envFile,
|
|
12399
12517
|
kind: "env-file"
|
|
12400
12518
|
} : { kind: "environment" } : { kind: "prompt" };
|
|
12401
|
-
const credentialClient = new Cloudflare
|
|
12519
|
+
const credentialClient = new Cloudflare({ apiToken });
|
|
12402
12520
|
await validateCloudflareApiToken({
|
|
12403
12521
|
accountId,
|
|
12404
12522
|
probes: [{
|
|
@@ -12424,13 +12542,16 @@ const runInit = async ({ build, envFile }) => {
|
|
|
12424
12542
|
for await (const resultPage of page.iterPages()) for (const result of resultPage.result) rows.push(...result.results ?? []);
|
|
12425
12543
|
return rows;
|
|
12426
12544
|
};
|
|
12427
|
-
if (!createD1Database)
|
|
12545
|
+
if (!createD1Database) {
|
|
12546
|
+
const tables = await queryD1(`
|
|
12428
12547
|
SELECT name
|
|
12429
12548
|
FROM sqlite_schema
|
|
12430
12549
|
WHERE type = 'table'
|
|
12431
12550
|
AND name IN ('bundles', 'release_catalogs')
|
|
12432
12551
|
ORDER BY name
|
|
12433
|
-
`)
|
|
12552
|
+
`);
|
|
12553
|
+
assertCloudflareInfrastructureCanInitialize(tables.flatMap(({ name }) => typeof name === "string" ? [name] : []), d1DatabaseName);
|
|
12554
|
+
}
|
|
12434
12555
|
const workerScripts = await runCloudflareApiRequest({
|
|
12435
12556
|
request: () => cf.workers.scripts.list({ account_id: accountId }),
|
|
12436
12557
|
source: infrastructureCredentialSource
|
|
@@ -12457,13 +12578,14 @@ const runInit = async ({ build, envFile }) => {
|
|
|
12457
12578
|
secretAccessKey,
|
|
12458
12579
|
workerName
|
|
12459
12580
|
};
|
|
12581
|
+
const persistCredentialInputs = await confirmInitInputPersistence({
|
|
12582
|
+
existingEnv: managedEnv,
|
|
12583
|
+
inputs: resolvedInputs,
|
|
12584
|
+
nonInteractive,
|
|
12585
|
+
provider: initProvider
|
|
12586
|
+
});
|
|
12460
12587
|
await makeEnv({ ...getInitProviderEnvVars({
|
|
12461
|
-
includeConsentInputs:
|
|
12462
|
-
existingEnv: managedEnv,
|
|
12463
|
-
inputs: resolvedInputs,
|
|
12464
|
-
nonInteractive,
|
|
12465
|
-
provider: initProvider
|
|
12466
|
-
}),
|
|
12588
|
+
includeConsentInputs: persistCredentialInputs,
|
|
12467
12589
|
inputs: resolvedInputs,
|
|
12468
12590
|
provider: initProvider
|
|
12469
12591
|
}) });
|