@shopify/create-app 3.65.2 → 3.66.0

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.
Files changed (86) hide show
  1. package/dist/chunk-2RSJVBMF.js +5625 -0
  2. package/dist/{chunk-Z65QJ5D7.js → chunk-4DRC2PSU.js} +17 -30
  3. package/dist/chunk-4OD45DDO.js +31508 -0
  4. package/dist/chunk-522OB3EU.js +45 -0
  5. package/dist/{chunk-JTKTLA7L.js → chunk-5U24TEX5.js} +5434 -10324
  6. package/dist/{chunk-GJPZCXGT.js → chunk-6A7MXLVB.js} +159 -405
  7. package/dist/{chunk-ZYKRTO5P.js → chunk-7ZCQLP5Y.js} +3 -3
  8. package/dist/{chunk-5LBEKXRW.js → chunk-FIJKOZJF.js} +19 -55
  9. package/dist/{chunk-QSKQTKTB.js → chunk-FT6PCF6E.js} +2441 -5551
  10. package/dist/chunk-GIUM5DCQ.js +2144 -0
  11. package/dist/chunk-HIAKHDLR.js +54 -0
  12. package/dist/chunk-LLSRDN3T.js +15352 -0
  13. package/dist/chunk-LTDD2GRL.js +111 -0
  14. package/dist/{chunk-63QVG2CD.js → chunk-NGBYQF44.js} +9 -9
  15. package/dist/chunk-NLC7NBUB.js +80 -0
  16. package/dist/{chunk-FMKVOTQK.js → chunk-O5K4AU7Q.js} +18 -34
  17. package/dist/chunk-OMDEA7TV.js +10615 -0
  18. package/dist/chunk-PNN7RS7Y.js +105 -0
  19. package/dist/{chunk-ZPL24Y2D.js → chunk-POZ5MGPT.js} +13 -18
  20. package/dist/chunk-T7T35H4F.js +108 -0
  21. package/dist/chunk-UBB7JKND.js +55 -0
  22. package/dist/chunk-VSLR7ET4.js +3034 -0
  23. package/dist/{chunk-SAO7C4LP.js → chunk-VZVGAREJ.js} +46821 -101962
  24. package/dist/{chunk-KDNBKIH4.js → chunk-WBQF4CSV.js} +12 -22
  25. package/dist/chunk-XVNW332R.js +524 -0
  26. package/dist/{chunk-YB6D4XQ7.js → chunk-Y4ECGRAF.js} +13 -23
  27. package/dist/chunk-ZAUZQLNO.js +3774 -0
  28. package/dist/chunk-ZULFH3SL.js +1847 -0
  29. package/dist/commands/init.d.ts +0 -1
  30. package/dist/commands/init.js +27 -27
  31. package/dist/commands/init.test.js +51 -70
  32. package/dist/{constants-24TFXZKQ.js → constants-WG7I7G3O.js} +5 -5
  33. package/dist/custom-oclif-loader-JKRJZ56E.js +47 -0
  34. package/dist/del-NW5KFKFP.js +1820 -0
  35. package/dist/devtools-UBOREV57.js +2572 -0
  36. package/dist/error-handler-26SLAJTC.js +35 -0
  37. package/dist/hooks/postrun.js +35 -42
  38. package/dist/hooks/prerun.js +58 -36
  39. package/dist/index.js +7 -7
  40. package/dist/lib-3K5QYF3J.js +9 -0
  41. package/dist/{local-3VUKCW4R.js → local-H6TW5MNX.js} +13 -13
  42. package/dist/magic-string.es-3RXPUXZF.js +843 -0
  43. package/dist/multipart-parser-QKUAJJP5.js +193 -0
  44. package/dist/{node-package-manager-HYZRZNU6.js → node-package-manager-QAUN6HGS.js} +16 -14
  45. package/dist/open-MZGVNFZO.js +197 -0
  46. package/dist/out-KDGAD475.js +6 -0
  47. package/dist/{path-CFPIDSWV.js → path-L375JOQ2.js} +4 -4
  48. package/dist/prompts/init.js +13 -13
  49. package/dist/prompts/init.test.js +42 -59
  50. package/dist/services/init.js +20 -20
  51. package/dist/services/init.test.js +5 -5
  52. package/dist/system-ZI2HKAKO.js +26 -0
  53. package/dist/tsconfig.tsbuildinfo +1 -1
  54. package/dist/{ui-7NEDEALP.js → ui-727JEZUX.js} +13 -13
  55. package/dist/utils/template/cleanup.js +13 -13
  56. package/dist/utils/template/cleanup.test.js +18 -30
  57. package/dist/utils/template/npm.js +15 -15
  58. package/dist/utils/template/npm.test.js +48 -87
  59. package/oclif.manifest.json +1 -1
  60. package/package.json +3 -4
  61. package/dist/chunk-3US34ZNP.js +0 -145
  62. package/dist/chunk-3XYIOBQ2.js +0 -22131
  63. package/dist/chunk-6IZMEXPW.js +0 -105
  64. package/dist/chunk-7DRS5WXI.js +0 -7843
  65. package/dist/chunk-DL3MKXVR.js +0 -4754
  66. package/dist/chunk-HDVJ5FPK.js +0 -63
  67. package/dist/chunk-IKO7JBOJ.js +0 -14788
  68. package/dist/chunk-LSCXQWNO.js +0 -822
  69. package/dist/chunk-M2VKB6RG.js +0 -146
  70. package/dist/chunk-MCED27CG.js +0 -5626
  71. package/dist/chunk-SWNRLCC6.js +0 -61
  72. package/dist/chunk-T5LLJYYS.js +0 -195
  73. package/dist/chunk-U5LTJVWL.js +0 -3185
  74. package/dist/chunk-WR7YKB6H.js +0 -44962
  75. package/dist/chunk-YC4FLMDD.js +0 -74
  76. package/dist/chunk-ZRUHMMSQ.js +0 -2477
  77. package/dist/custom-oclif-loader-5KBN3RSN.js +0 -83
  78. package/dist/del-ZCPTGWOA.js +0 -2847
  79. package/dist/devtools-5N4JAP3R.js +0 -3588
  80. package/dist/error-handler-GTW2KSRC.js +0 -35
  81. package/dist/lib-CTSCLPNV.js +0 -9
  82. package/dist/magic-string.es-ATGURXGQ.js +0 -1353
  83. package/dist/multipart-parser-KYOHF24X.js +0 -360
  84. package/dist/open-JRS7RW22.js +0 -291
  85. package/dist/out-OKI3G7I5.js +0 -6
  86. package/dist/system-4S4YXUXZ.js +0 -26
@@ -1,2477 +0,0 @@
1
- import {
2
- errorHandler,
3
- registerCleanBugsnagErrorsFromWithinPlugins
4
- } from "./chunk-U5LTJVWL.js";
5
- import {
6
- init_default as init_default2
7
- } from "./chunk-7DRS5WXI.js";
8
- import {
9
- hashString
10
- } from "./chunk-YB6D4XQ7.js";
11
- import {
12
- packageManager,
13
- packageManagerFromUserAgent
14
- } from "./chunk-3XYIOBQ2.js";
15
- import {
16
- globalFlags
17
- } from "./chunk-6IZMEXPW.js";
18
- import {
19
- init_default,
20
- isPredefinedTemplate,
21
- templates,
22
- visibleTemplates
23
- } from "./chunk-3US34ZNP.js";
24
- import {
25
- AbortError,
26
- addPublicMetadata,
27
- addSensitiveMetadata,
28
- findPathUp,
29
- inferPackageManagerForGlobalCLI,
30
- installGlobalShopifyCLI,
31
- isDevelopment,
32
- outputContent,
33
- outputInfo,
34
- outputToken,
35
- readFile,
36
- renderInfo,
37
- renderWarning,
38
- terminalSupportsRawMode,
39
- underscore
40
- } from "./chunk-WR7YKB6H.js";
41
- import {
42
- cwd,
43
- resolvePath
44
- } from "./chunk-Z65QJ5D7.js";
45
- import {
46
- isTruthy
47
- } from "./chunk-M2VKB6RG.js";
48
- import {
49
- require_lib
50
- } from "./chunk-SAO7C4LP.js";
51
- import {
52
- __commonJS,
53
- __require,
54
- __toESM,
55
- init_cjs_shims
56
- } from "./chunk-ZPL24Y2D.js";
57
-
58
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/parser.js
59
- var require_parser = __commonJS({
60
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/parser.js"(exports2, module2) {
61
- "use strict";
62
- init_cjs_shims();
63
- var ParserEND = 1114112;
64
- var ParserError = class _ParserError extends Error {
65
- /* istanbul ignore next */
66
- constructor(msg, filename, linenumber) {
67
- super("[ParserError] " + msg, filename, linenumber);
68
- this.name = "ParserError";
69
- this.code = "ParserError";
70
- if (Error.captureStackTrace)
71
- Error.captureStackTrace(this, _ParserError);
72
- }
73
- };
74
- var State = class {
75
- constructor(parser) {
76
- this.parser = parser;
77
- this.buf = "";
78
- this.returned = null;
79
- this.result = null;
80
- this.resultTable = null;
81
- this.resultArr = null;
82
- }
83
- };
84
- var Parser = class {
85
- constructor() {
86
- this.pos = 0;
87
- this.col = 0;
88
- this.line = 0;
89
- this.obj = {};
90
- this.ctx = this.obj;
91
- this.stack = [];
92
- this._buf = "";
93
- this.char = null;
94
- this.ii = 0;
95
- this.state = new State(this.parseStart);
96
- }
97
- parse(str) {
98
- if (str.length === 0 || str.length == null)
99
- return;
100
- this._buf = String(str);
101
- this.ii = -1;
102
- this.char = -1;
103
- let getNext;
104
- while (getNext === false || this.nextChar()) {
105
- getNext = this.runOne();
106
- }
107
- this._buf = null;
108
- }
109
- nextChar() {
110
- if (this.char === 10) {
111
- ++this.line;
112
- this.col = -1;
113
- }
114
- ++this.ii;
115
- this.char = this._buf.codePointAt(this.ii);
116
- ++this.pos;
117
- ++this.col;
118
- return this.haveBuffer();
119
- }
120
- haveBuffer() {
121
- return this.ii < this._buf.length;
122
- }
123
- runOne() {
124
- return this.state.parser.call(this, this.state.returned);
125
- }
126
- finish() {
127
- this.char = ParserEND;
128
- let last;
129
- do {
130
- last = this.state.parser;
131
- this.runOne();
132
- } while (this.state.parser !== last);
133
- this.ctx = null;
134
- this.state = null;
135
- this._buf = null;
136
- return this.obj;
137
- }
138
- next(fn) {
139
- if (typeof fn !== "function")
140
- throw new ParserError("Tried to set state to non-existent state: " + JSON.stringify(fn));
141
- this.state.parser = fn;
142
- }
143
- goto(fn) {
144
- this.next(fn);
145
- return this.runOne();
146
- }
147
- call(fn, returnWith) {
148
- if (returnWith)
149
- this.next(returnWith);
150
- this.stack.push(this.state);
151
- this.state = new State(fn);
152
- }
153
- callNow(fn, returnWith) {
154
- this.call(fn, returnWith);
155
- return this.runOne();
156
- }
157
- return(value) {
158
- if (this.stack.length === 0)
159
- throw this.error(new ParserError("Stack underflow"));
160
- if (value === void 0)
161
- value = this.state.buf;
162
- this.state = this.stack.pop();
163
- this.state.returned = value;
164
- }
165
- returnNow(value) {
166
- this.return(value);
167
- return this.runOne();
168
- }
169
- consume() {
170
- if (this.char === ParserEND)
171
- throw this.error(new ParserError("Unexpected end-of-buffer"));
172
- this.state.buf += this._buf[this.ii];
173
- }
174
- error(err) {
175
- err.line = this.line;
176
- err.col = this.col;
177
- err.pos = this.pos;
178
- return err;
179
- }
180
- /* istanbul ignore next */
181
- parseStart() {
182
- throw new ParserError("Must declare a parseStart method");
183
- }
184
- };
185
- Parser.END = ParserEND;
186
- Parser.Error = ParserError;
187
- module2.exports = Parser;
188
- }
189
- });
190
-
191
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime.js
192
- var require_create_datetime = __commonJS({
193
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime.js"(exports2, module2) {
194
- "use strict";
195
- init_cjs_shims();
196
- module2.exports = (value) => {
197
- const date = new Date(value);
198
- if (isNaN(date)) {
199
- throw new TypeError("Invalid Datetime");
200
- } else {
201
- return date;
202
- }
203
- };
204
- }
205
- });
206
-
207
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/format-num.js
208
- var require_format_num = __commonJS({
209
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/format-num.js"(exports2, module2) {
210
- "use strict";
211
- init_cjs_shims();
212
- module2.exports = (d, num) => {
213
- num = String(num);
214
- while (num.length < d)
215
- num = "0" + num;
216
- return num;
217
- };
218
- }
219
- });
220
-
221
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime-float.js
222
- var require_create_datetime_float = __commonJS({
223
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-datetime-float.js"(exports2, module2) {
224
- "use strict";
225
- init_cjs_shims();
226
- var f = require_format_num();
227
- var FloatingDateTime = class extends Date {
228
- constructor(value) {
229
- super(value + "Z");
230
- this.isFloating = true;
231
- }
232
- toISOString() {
233
- const date = `${this.getUTCFullYear()}-${f(2, this.getUTCMonth() + 1)}-${f(2, this.getUTCDate())}`;
234
- const time = `${f(2, this.getUTCHours())}:${f(2, this.getUTCMinutes())}:${f(2, this.getUTCSeconds())}.${f(3, this.getUTCMilliseconds())}`;
235
- return `${date}T${time}`;
236
- }
237
- };
238
- module2.exports = (value) => {
239
- const date = new FloatingDateTime(value);
240
- if (isNaN(date)) {
241
- throw new TypeError("Invalid Datetime");
242
- } else {
243
- return date;
244
- }
245
- };
246
- }
247
- });
248
-
249
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-date.js
250
- var require_create_date = __commonJS({
251
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-date.js"(exports2, module2) {
252
- "use strict";
253
- init_cjs_shims();
254
- var f = require_format_num();
255
- var DateTime = global.Date;
256
- var Date2 = class extends DateTime {
257
- constructor(value) {
258
- super(value);
259
- this.isDate = true;
260
- }
261
- toISOString() {
262
- return `${this.getUTCFullYear()}-${f(2, this.getUTCMonth() + 1)}-${f(2, this.getUTCDate())}`;
263
- }
264
- };
265
- module2.exports = (value) => {
266
- const date = new Date2(value);
267
- if (isNaN(date)) {
268
- throw new TypeError("Invalid Datetime");
269
- } else {
270
- return date;
271
- }
272
- };
273
- }
274
- });
275
-
276
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-time.js
277
- var require_create_time = __commonJS({
278
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/create-time.js"(exports2, module2) {
279
- "use strict";
280
- init_cjs_shims();
281
- var f = require_format_num();
282
- var Time = class extends Date {
283
- constructor(value) {
284
- super(`0000-01-01T${value}Z`);
285
- this.isTime = true;
286
- }
287
- toISOString() {
288
- return `${f(2, this.getUTCHours())}:${f(2, this.getUTCMinutes())}:${f(2, this.getUTCSeconds())}.${f(3, this.getUTCMilliseconds())}`;
289
- }
290
- };
291
- module2.exports = (value) => {
292
- const date = new Time(value);
293
- if (isNaN(date)) {
294
- throw new TypeError("Invalid Datetime");
295
- } else {
296
- return date;
297
- }
298
- };
299
- }
300
- });
301
-
302
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/toml-parser.js
303
- var require_toml_parser = __commonJS({
304
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/lib/toml-parser.js"(exports, module) {
305
- "use strict";
306
- init_cjs_shims();
307
- module.exports = makeParserClass(require_parser());
308
- module.exports.makeParserClass = makeParserClass;
309
- var TomlError = class _TomlError extends Error {
310
- constructor(msg) {
311
- super(msg);
312
- this.name = "TomlError";
313
- if (Error.captureStackTrace)
314
- Error.captureStackTrace(this, _TomlError);
315
- this.fromTOML = true;
316
- this.wrapped = null;
317
- }
318
- };
319
- TomlError.wrap = (err) => {
320
- const terr = new TomlError(err.message);
321
- terr.code = err.code;
322
- terr.wrapped = err;
323
- return terr;
324
- };
325
- module.exports.TomlError = TomlError;
326
- var createDateTime = require_create_datetime();
327
- var createDateTimeFloat = require_create_datetime_float();
328
- var createDate = require_create_date();
329
- var createTime = require_create_time();
330
- var CTRL_I = 9;
331
- var CTRL_J = 10;
332
- var CTRL_M = 13;
333
- var CTRL_CHAR_BOUNDARY = 31;
334
- var CHAR_SP = 32;
335
- var CHAR_QUOT = 34;
336
- var CHAR_NUM = 35;
337
- var CHAR_APOS = 39;
338
- var CHAR_PLUS = 43;
339
- var CHAR_COMMA = 44;
340
- var CHAR_HYPHEN = 45;
341
- var CHAR_PERIOD = 46;
342
- var CHAR_0 = 48;
343
- var CHAR_1 = 49;
344
- var CHAR_7 = 55;
345
- var CHAR_9 = 57;
346
- var CHAR_COLON = 58;
347
- var CHAR_EQUALS = 61;
348
- var CHAR_A = 65;
349
- var CHAR_E = 69;
350
- var CHAR_F = 70;
351
- var CHAR_T = 84;
352
- var CHAR_U = 85;
353
- var CHAR_Z = 90;
354
- var CHAR_LOWBAR = 95;
355
- var CHAR_a = 97;
356
- var CHAR_b = 98;
357
- var CHAR_e = 101;
358
- var CHAR_f = 102;
359
- var CHAR_i = 105;
360
- var CHAR_l = 108;
361
- var CHAR_n = 110;
362
- var CHAR_o = 111;
363
- var CHAR_r = 114;
364
- var CHAR_s = 115;
365
- var CHAR_t = 116;
366
- var CHAR_u = 117;
367
- var CHAR_x = 120;
368
- var CHAR_z = 122;
369
- var CHAR_LCUB = 123;
370
- var CHAR_RCUB = 125;
371
- var CHAR_LSQB = 91;
372
- var CHAR_BSOL = 92;
373
- var CHAR_RSQB = 93;
374
- var CHAR_DEL = 127;
375
- var SURROGATE_FIRST = 55296;
376
- var SURROGATE_LAST = 57343;
377
- var escapes = {
378
- [CHAR_b]: "\b",
379
- [CHAR_t]: " ",
380
- [CHAR_n]: "\n",
381
- [CHAR_f]: "\f",
382
- [CHAR_r]: "\r",
383
- [CHAR_QUOT]: '"',
384
- [CHAR_BSOL]: "\\"
385
- };
386
- function isDigit(cp) {
387
- return cp >= CHAR_0 && cp <= CHAR_9;
388
- }
389
- function isHexit(cp) {
390
- return cp >= CHAR_A && cp <= CHAR_F || cp >= CHAR_a && cp <= CHAR_f || cp >= CHAR_0 && cp <= CHAR_9;
391
- }
392
- function isBit(cp) {
393
- return cp === CHAR_1 || cp === CHAR_0;
394
- }
395
- function isOctit(cp) {
396
- return cp >= CHAR_0 && cp <= CHAR_7;
397
- }
398
- function isAlphaNumQuoteHyphen(cp) {
399
- return cp >= CHAR_A && cp <= CHAR_Z || cp >= CHAR_a && cp <= CHAR_z || cp >= CHAR_0 && cp <= CHAR_9 || cp === CHAR_APOS || cp === CHAR_QUOT || cp === CHAR_LOWBAR || cp === CHAR_HYPHEN;
400
- }
401
- function isAlphaNumHyphen(cp) {
402
- return cp >= CHAR_A && cp <= CHAR_Z || cp >= CHAR_a && cp <= CHAR_z || cp >= CHAR_0 && cp <= CHAR_9 || cp === CHAR_LOWBAR || cp === CHAR_HYPHEN;
403
- }
404
- var _type = Symbol("type");
405
- var _declared = Symbol("declared");
406
- var hasOwnProperty = Object.prototype.hasOwnProperty;
407
- var defineProperty = Object.defineProperty;
408
- var descriptor = { configurable: true, enumerable: true, writable: true, value: void 0 };
409
- function hasKey(obj, key) {
410
- if (hasOwnProperty.call(obj, key))
411
- return true;
412
- if (key === "__proto__")
413
- defineProperty(obj, "__proto__", descriptor);
414
- return false;
415
- }
416
- var INLINE_TABLE = Symbol("inline-table");
417
- function InlineTable() {
418
- return Object.defineProperties({}, {
419
- [_type]: { value: INLINE_TABLE }
420
- });
421
- }
422
- function isInlineTable(obj) {
423
- if (obj === null || typeof obj !== "object")
424
- return false;
425
- return obj[_type] === INLINE_TABLE;
426
- }
427
- var TABLE = Symbol("table");
428
- function Table() {
429
- return Object.defineProperties({}, {
430
- [_type]: { value: TABLE },
431
- [_declared]: { value: false, writable: true }
432
- });
433
- }
434
- function isTable(obj) {
435
- if (obj === null || typeof obj !== "object")
436
- return false;
437
- return obj[_type] === TABLE;
438
- }
439
- var _contentType = Symbol("content-type");
440
- var INLINE_LIST = Symbol("inline-list");
441
- function InlineList(type) {
442
- return Object.defineProperties([], {
443
- [_type]: { value: INLINE_LIST },
444
- [_contentType]: { value: type }
445
- });
446
- }
447
- function isInlineList(obj) {
448
- if (obj === null || typeof obj !== "object")
449
- return false;
450
- return obj[_type] === INLINE_LIST;
451
- }
452
- var LIST = Symbol("list");
453
- function List() {
454
- return Object.defineProperties([], {
455
- [_type]: { value: LIST }
456
- });
457
- }
458
- function isList(obj) {
459
- if (obj === null || typeof obj !== "object")
460
- return false;
461
- return obj[_type] === LIST;
462
- }
463
- var _custom;
464
- try {
465
- const utilInspect = eval("require('util').inspect");
466
- _custom = utilInspect.custom;
467
- } catch (_) {
468
- }
469
- var _inspect = _custom || "inspect";
470
- var BoxedBigInt = class {
471
- constructor(value) {
472
- try {
473
- this.value = global.BigInt.asIntN(64, value);
474
- } catch (_) {
475
- this.value = null;
476
- }
477
- Object.defineProperty(this, _type, { value: INTEGER });
478
- }
479
- isNaN() {
480
- return this.value === null;
481
- }
482
- /* istanbul ignore next */
483
- toString() {
484
- return String(this.value);
485
- }
486
- /* istanbul ignore next */
487
- [_inspect]() {
488
- return `[BigInt: ${this.toString()}]}`;
489
- }
490
- valueOf() {
491
- return this.value;
492
- }
493
- };
494
- var INTEGER = Symbol("integer");
495
- function Integer(value) {
496
- let num = Number(value);
497
- if (Object.is(num, -0))
498
- num = 0;
499
- if (global.BigInt && !Number.isSafeInteger(num)) {
500
- return new BoxedBigInt(value);
501
- } else {
502
- return Object.defineProperties(new Number(num), {
503
- isNaN: { value: function() {
504
- return isNaN(this);
505
- } },
506
- [_type]: { value: INTEGER },
507
- [_inspect]: { value: () => `[Integer: ${value}]` }
508
- });
509
- }
510
- }
511
- function isInteger(obj) {
512
- if (obj === null || typeof obj !== "object")
513
- return false;
514
- return obj[_type] === INTEGER;
515
- }
516
- var FLOAT = Symbol("float");
517
- function Float(value) {
518
- return Object.defineProperties(new Number(value), {
519
- [_type]: { value: FLOAT },
520
- [_inspect]: { value: () => `[Float: ${value}]` }
521
- });
522
- }
523
- function isFloat(obj) {
524
- if (obj === null || typeof obj !== "object")
525
- return false;
526
- return obj[_type] === FLOAT;
527
- }
528
- function tomlType(value) {
529
- const type = typeof value;
530
- if (type === "object") {
531
- if (value === null)
532
- return "null";
533
- if (value instanceof Date)
534
- return "datetime";
535
- if (_type in value) {
536
- switch (value[_type]) {
537
- case INLINE_TABLE:
538
- return "inline-table";
539
- case INLINE_LIST:
540
- return "inline-list";
541
- case TABLE:
542
- return "table";
543
- case LIST:
544
- return "list";
545
- case FLOAT:
546
- return "float";
547
- case INTEGER:
548
- return "integer";
549
- }
550
- }
551
- }
552
- return type;
553
- }
554
- function makeParserClass(Parser) {
555
- class TOMLParser extends Parser {
556
- constructor() {
557
- super();
558
- this.ctx = this.obj = Table();
559
- }
560
- /* MATCH HELPER */
561
- atEndOfWord() {
562
- return this.char === CHAR_NUM || this.char === CTRL_I || this.char === CHAR_SP || this.atEndOfLine();
563
- }
564
- atEndOfLine() {
565
- return this.char === Parser.END || this.char === CTRL_J || this.char === CTRL_M;
566
- }
567
- parseStart() {
568
- if (this.char === Parser.END) {
569
- return null;
570
- } else if (this.char === CHAR_LSQB) {
571
- return this.call(this.parseTableOrList);
572
- } else if (this.char === CHAR_NUM) {
573
- return this.call(this.parseComment);
574
- } else if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
575
- return null;
576
- } else if (isAlphaNumQuoteHyphen(this.char)) {
577
- return this.callNow(this.parseAssignStatement);
578
- } else {
579
- throw this.error(new TomlError(`Unknown character "${this.char}"`));
580
- }
581
- }
582
- // HELPER, this strips any whitespace and comments to the end of the line
583
- // then RETURNS. Last state in a production.
584
- parseWhitespaceToEOL() {
585
- if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
586
- return null;
587
- } else if (this.char === CHAR_NUM) {
588
- return this.goto(this.parseComment);
589
- } else if (this.char === Parser.END || this.char === CTRL_J) {
590
- return this.return();
591
- } else {
592
- throw this.error(new TomlError("Unexpected character, expected only whitespace or comments till end of line"));
593
- }
594
- }
595
- /* ASSIGNMENT: key = value */
596
- parseAssignStatement() {
597
- return this.callNow(this.parseAssign, this.recordAssignStatement);
598
- }
599
- recordAssignStatement(kv) {
600
- let target = this.ctx;
601
- let finalKey = kv.key.pop();
602
- for (let kw of kv.key) {
603
- if (hasKey(target, kw) && (!isTable(target[kw]) || target[kw][_declared])) {
604
- throw this.error(new TomlError("Can't redefine existing key"));
605
- }
606
- target = target[kw] = target[kw] || Table();
607
- }
608
- if (hasKey(target, finalKey)) {
609
- throw this.error(new TomlError("Can't redefine existing key"));
610
- }
611
- if (isInteger(kv.value) || isFloat(kv.value)) {
612
- target[finalKey] = kv.value.valueOf();
613
- } else {
614
- target[finalKey] = kv.value;
615
- }
616
- return this.goto(this.parseWhitespaceToEOL);
617
- }
618
- /* ASSSIGNMENT expression, key = value possibly inside an inline table */
619
- parseAssign() {
620
- return this.callNow(this.parseKeyword, this.recordAssignKeyword);
621
- }
622
- recordAssignKeyword(key) {
623
- if (this.state.resultTable) {
624
- this.state.resultTable.push(key);
625
- } else {
626
- this.state.resultTable = [key];
627
- }
628
- return this.goto(this.parseAssignKeywordPreDot);
629
- }
630
- parseAssignKeywordPreDot() {
631
- if (this.char === CHAR_PERIOD) {
632
- return this.next(this.parseAssignKeywordPostDot);
633
- } else if (this.char !== CHAR_SP && this.char !== CTRL_I) {
634
- return this.goto(this.parseAssignEqual);
635
- }
636
- }
637
- parseAssignKeywordPostDot() {
638
- if (this.char !== CHAR_SP && this.char !== CTRL_I) {
639
- return this.callNow(this.parseKeyword, this.recordAssignKeyword);
640
- }
641
- }
642
- parseAssignEqual() {
643
- if (this.char === CHAR_EQUALS) {
644
- return this.next(this.parseAssignPreValue);
645
- } else {
646
- throw this.error(new TomlError('Invalid character, expected "="'));
647
- }
648
- }
649
- parseAssignPreValue() {
650
- if (this.char === CHAR_SP || this.char === CTRL_I) {
651
- return null;
652
- } else {
653
- return this.callNow(this.parseValue, this.recordAssignValue);
654
- }
655
- }
656
- recordAssignValue(value) {
657
- return this.returnNow({ key: this.state.resultTable, value });
658
- }
659
- /* COMMENTS: #...eol */
660
- parseComment() {
661
- do {
662
- if (this.char === Parser.END || this.char === CTRL_J) {
663
- return this.return();
664
- }
665
- } while (this.nextChar());
666
- }
667
- /* TABLES AND LISTS, [foo] and [[foo]] */
668
- parseTableOrList() {
669
- if (this.char === CHAR_LSQB) {
670
- this.next(this.parseList);
671
- } else {
672
- return this.goto(this.parseTable);
673
- }
674
- }
675
- /* TABLE [foo.bar.baz] */
676
- parseTable() {
677
- this.ctx = this.obj;
678
- return this.goto(this.parseTableNext);
679
- }
680
- parseTableNext() {
681
- if (this.char === CHAR_SP || this.char === CTRL_I) {
682
- return null;
683
- } else {
684
- return this.callNow(this.parseKeyword, this.parseTableMore);
685
- }
686
- }
687
- parseTableMore(keyword) {
688
- if (this.char === CHAR_SP || this.char === CTRL_I) {
689
- return null;
690
- } else if (this.char === CHAR_RSQB) {
691
- if (hasKey(this.ctx, keyword) && (!isTable(this.ctx[keyword]) || this.ctx[keyword][_declared])) {
692
- throw this.error(new TomlError("Can't redefine existing key"));
693
- } else {
694
- this.ctx = this.ctx[keyword] = this.ctx[keyword] || Table();
695
- this.ctx[_declared] = true;
696
- }
697
- return this.next(this.parseWhitespaceToEOL);
698
- } else if (this.char === CHAR_PERIOD) {
699
- if (!hasKey(this.ctx, keyword)) {
700
- this.ctx = this.ctx[keyword] = Table();
701
- } else if (isTable(this.ctx[keyword])) {
702
- this.ctx = this.ctx[keyword];
703
- } else if (isList(this.ctx[keyword])) {
704
- this.ctx = this.ctx[keyword][this.ctx[keyword].length - 1];
705
- } else {
706
- throw this.error(new TomlError("Can't redefine existing key"));
707
- }
708
- return this.next(this.parseTableNext);
709
- } else {
710
- throw this.error(new TomlError("Unexpected character, expected whitespace, . or ]"));
711
- }
712
- }
713
- /* LIST [[a.b.c]] */
714
- parseList() {
715
- this.ctx = this.obj;
716
- return this.goto(this.parseListNext);
717
- }
718
- parseListNext() {
719
- if (this.char === CHAR_SP || this.char === CTRL_I) {
720
- return null;
721
- } else {
722
- return this.callNow(this.parseKeyword, this.parseListMore);
723
- }
724
- }
725
- parseListMore(keyword) {
726
- if (this.char === CHAR_SP || this.char === CTRL_I) {
727
- return null;
728
- } else if (this.char === CHAR_RSQB) {
729
- if (!hasKey(this.ctx, keyword)) {
730
- this.ctx[keyword] = List();
731
- }
732
- if (isInlineList(this.ctx[keyword])) {
733
- throw this.error(new TomlError("Can't extend an inline array"));
734
- } else if (isList(this.ctx[keyword])) {
735
- const next = Table();
736
- this.ctx[keyword].push(next);
737
- this.ctx = next;
738
- } else {
739
- throw this.error(new TomlError("Can't redefine an existing key"));
740
- }
741
- return this.next(this.parseListEnd);
742
- } else if (this.char === CHAR_PERIOD) {
743
- if (!hasKey(this.ctx, keyword)) {
744
- this.ctx = this.ctx[keyword] = Table();
745
- } else if (isInlineList(this.ctx[keyword])) {
746
- throw this.error(new TomlError("Can't extend an inline array"));
747
- } else if (isInlineTable(this.ctx[keyword])) {
748
- throw this.error(new TomlError("Can't extend an inline table"));
749
- } else if (isList(this.ctx[keyword])) {
750
- this.ctx = this.ctx[keyword][this.ctx[keyword].length - 1];
751
- } else if (isTable(this.ctx[keyword])) {
752
- this.ctx = this.ctx[keyword];
753
- } else {
754
- throw this.error(new TomlError("Can't redefine an existing key"));
755
- }
756
- return this.next(this.parseListNext);
757
- } else {
758
- throw this.error(new TomlError("Unexpected character, expected whitespace, . or ]"));
759
- }
760
- }
761
- parseListEnd(keyword) {
762
- if (this.char === CHAR_RSQB) {
763
- return this.next(this.parseWhitespaceToEOL);
764
- } else {
765
- throw this.error(new TomlError("Unexpected character, expected whitespace, . or ]"));
766
- }
767
- }
768
- /* VALUE string, number, boolean, inline list, inline object */
769
- parseValue() {
770
- if (this.char === Parser.END) {
771
- throw this.error(new TomlError("Key without value"));
772
- } else if (this.char === CHAR_QUOT) {
773
- return this.next(this.parseDoubleString);
774
- }
775
- if (this.char === CHAR_APOS) {
776
- return this.next(this.parseSingleString);
777
- } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) {
778
- return this.goto(this.parseNumberSign);
779
- } else if (this.char === CHAR_i) {
780
- return this.next(this.parseInf);
781
- } else if (this.char === CHAR_n) {
782
- return this.next(this.parseNan);
783
- } else if (isDigit(this.char)) {
784
- return this.goto(this.parseNumberOrDateTime);
785
- } else if (this.char === CHAR_t || this.char === CHAR_f) {
786
- return this.goto(this.parseBoolean);
787
- } else if (this.char === CHAR_LSQB) {
788
- return this.call(this.parseInlineList, this.recordValue);
789
- } else if (this.char === CHAR_LCUB) {
790
- return this.call(this.parseInlineTable, this.recordValue);
791
- } else {
792
- throw this.error(new TomlError("Unexpected character, expecting string, number, datetime, boolean, inline array or inline table"));
793
- }
794
- }
795
- recordValue(value) {
796
- return this.returnNow(value);
797
- }
798
- parseInf() {
799
- if (this.char === CHAR_n) {
800
- return this.next(this.parseInf2);
801
- } else {
802
- throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"'));
803
- }
804
- }
805
- parseInf2() {
806
- if (this.char === CHAR_f) {
807
- if (this.state.buf === "-") {
808
- return this.return(-Infinity);
809
- } else {
810
- return this.return(Infinity);
811
- }
812
- } else {
813
- throw this.error(new TomlError('Unexpected character, expected "inf", "+inf" or "-inf"'));
814
- }
815
- }
816
- parseNan() {
817
- if (this.char === CHAR_a) {
818
- return this.next(this.parseNan2);
819
- } else {
820
- throw this.error(new TomlError('Unexpected character, expected "nan"'));
821
- }
822
- }
823
- parseNan2() {
824
- if (this.char === CHAR_n) {
825
- return this.return(NaN);
826
- } else {
827
- throw this.error(new TomlError('Unexpected character, expected "nan"'));
828
- }
829
- }
830
- /* KEYS, barewords or basic, literal, or dotted */
831
- parseKeyword() {
832
- if (this.char === CHAR_QUOT) {
833
- return this.next(this.parseBasicString);
834
- } else if (this.char === CHAR_APOS) {
835
- return this.next(this.parseLiteralString);
836
- } else {
837
- return this.goto(this.parseBareKey);
838
- }
839
- }
840
- /* KEYS: barewords */
841
- parseBareKey() {
842
- do {
843
- if (this.char === Parser.END) {
844
- throw this.error(new TomlError("Key ended without value"));
845
- } else if (isAlphaNumHyphen(this.char)) {
846
- this.consume();
847
- } else if (this.state.buf.length === 0) {
848
- throw this.error(new TomlError("Empty bare keys are not allowed"));
849
- } else {
850
- return this.returnNow();
851
- }
852
- } while (this.nextChar());
853
- }
854
- /* STRINGS, single quoted (literal) */
855
- parseSingleString() {
856
- if (this.char === CHAR_APOS) {
857
- return this.next(this.parseLiteralMultiStringMaybe);
858
- } else {
859
- return this.goto(this.parseLiteralString);
860
- }
861
- }
862
- parseLiteralString() {
863
- do {
864
- if (this.char === CHAR_APOS) {
865
- return this.return();
866
- } else if (this.atEndOfLine()) {
867
- throw this.error(new TomlError("Unterminated string"));
868
- } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) {
869
- throw this.errorControlCharInString();
870
- } else {
871
- this.consume();
872
- }
873
- } while (this.nextChar());
874
- }
875
- parseLiteralMultiStringMaybe() {
876
- if (this.char === CHAR_APOS) {
877
- return this.next(this.parseLiteralMultiString);
878
- } else {
879
- return this.returnNow();
880
- }
881
- }
882
- parseLiteralMultiString() {
883
- if (this.char === CTRL_M) {
884
- return null;
885
- } else if (this.char === CTRL_J) {
886
- return this.next(this.parseLiteralMultiStringContent);
887
- } else {
888
- return this.goto(this.parseLiteralMultiStringContent);
889
- }
890
- }
891
- parseLiteralMultiStringContent() {
892
- do {
893
- if (this.char === CHAR_APOS) {
894
- return this.next(this.parseLiteralMultiEnd);
895
- } else if (this.char === Parser.END) {
896
- throw this.error(new TomlError("Unterminated multi-line string"));
897
- } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M) {
898
- throw this.errorControlCharInString();
899
- } else {
900
- this.consume();
901
- }
902
- } while (this.nextChar());
903
- }
904
- parseLiteralMultiEnd() {
905
- if (this.char === CHAR_APOS) {
906
- return this.next(this.parseLiteralMultiEnd2);
907
- } else {
908
- this.state.buf += "'";
909
- return this.goto(this.parseLiteralMultiStringContent);
910
- }
911
- }
912
- parseLiteralMultiEnd2() {
913
- if (this.char === CHAR_APOS) {
914
- return this.return();
915
- } else {
916
- this.state.buf += "''";
917
- return this.goto(this.parseLiteralMultiStringContent);
918
- }
919
- }
920
- /* STRINGS double quoted */
921
- parseDoubleString() {
922
- if (this.char === CHAR_QUOT) {
923
- return this.next(this.parseMultiStringMaybe);
924
- } else {
925
- return this.goto(this.parseBasicString);
926
- }
927
- }
928
- parseBasicString() {
929
- do {
930
- if (this.char === CHAR_BSOL) {
931
- return this.call(this.parseEscape, this.recordEscapeReplacement);
932
- } else if (this.char === CHAR_QUOT) {
933
- return this.return();
934
- } else if (this.atEndOfLine()) {
935
- throw this.error(new TomlError("Unterminated string"));
936
- } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I) {
937
- throw this.errorControlCharInString();
938
- } else {
939
- this.consume();
940
- }
941
- } while (this.nextChar());
942
- }
943
- recordEscapeReplacement(replacement) {
944
- this.state.buf += replacement;
945
- return this.goto(this.parseBasicString);
946
- }
947
- parseMultiStringMaybe() {
948
- if (this.char === CHAR_QUOT) {
949
- return this.next(this.parseMultiString);
950
- } else {
951
- return this.returnNow();
952
- }
953
- }
954
- parseMultiString() {
955
- if (this.char === CTRL_M) {
956
- return null;
957
- } else if (this.char === CTRL_J) {
958
- return this.next(this.parseMultiStringContent);
959
- } else {
960
- return this.goto(this.parseMultiStringContent);
961
- }
962
- }
963
- parseMultiStringContent() {
964
- do {
965
- if (this.char === CHAR_BSOL) {
966
- return this.call(this.parseMultiEscape, this.recordMultiEscapeReplacement);
967
- } else if (this.char === CHAR_QUOT) {
968
- return this.next(this.parseMultiEnd);
969
- } else if (this.char === Parser.END) {
970
- throw this.error(new TomlError("Unterminated multi-line string"));
971
- } else if (this.char === CHAR_DEL || this.char <= CTRL_CHAR_BOUNDARY && this.char !== CTRL_I && this.char !== CTRL_J && this.char !== CTRL_M) {
972
- throw this.errorControlCharInString();
973
- } else {
974
- this.consume();
975
- }
976
- } while (this.nextChar());
977
- }
978
- errorControlCharInString() {
979
- let displayCode = "\\u00";
980
- if (this.char < 16) {
981
- displayCode += "0";
982
- }
983
- displayCode += this.char.toString(16);
984
- return this.error(new TomlError(`Control characters (codes < 0x1f and 0x7f) are not allowed in strings, use ${displayCode} instead`));
985
- }
986
- recordMultiEscapeReplacement(replacement) {
987
- this.state.buf += replacement;
988
- return this.goto(this.parseMultiStringContent);
989
- }
990
- parseMultiEnd() {
991
- if (this.char === CHAR_QUOT) {
992
- return this.next(this.parseMultiEnd2);
993
- } else {
994
- this.state.buf += '"';
995
- return this.goto(this.parseMultiStringContent);
996
- }
997
- }
998
- parseMultiEnd2() {
999
- if (this.char === CHAR_QUOT) {
1000
- return this.return();
1001
- } else {
1002
- this.state.buf += '""';
1003
- return this.goto(this.parseMultiStringContent);
1004
- }
1005
- }
1006
- parseMultiEscape() {
1007
- if (this.char === CTRL_M || this.char === CTRL_J) {
1008
- return this.next(this.parseMultiTrim);
1009
- } else if (this.char === CHAR_SP || this.char === CTRL_I) {
1010
- return this.next(this.parsePreMultiTrim);
1011
- } else {
1012
- return this.goto(this.parseEscape);
1013
- }
1014
- }
1015
- parsePreMultiTrim() {
1016
- if (this.char === CHAR_SP || this.char === CTRL_I) {
1017
- return null;
1018
- } else if (this.char === CTRL_M || this.char === CTRL_J) {
1019
- return this.next(this.parseMultiTrim);
1020
- } else {
1021
- throw this.error(new TomlError("Can't escape whitespace"));
1022
- }
1023
- }
1024
- parseMultiTrim() {
1025
- if (this.char === CTRL_J || this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M) {
1026
- return null;
1027
- } else {
1028
- return this.returnNow();
1029
- }
1030
- }
1031
- parseEscape() {
1032
- if (this.char in escapes) {
1033
- return this.return(escapes[this.char]);
1034
- } else if (this.char === CHAR_u) {
1035
- return this.call(this.parseSmallUnicode, this.parseUnicodeReturn);
1036
- } else if (this.char === CHAR_U) {
1037
- return this.call(this.parseLargeUnicode, this.parseUnicodeReturn);
1038
- } else {
1039
- throw this.error(new TomlError("Unknown escape character: " + this.char));
1040
- }
1041
- }
1042
- parseUnicodeReturn(char) {
1043
- try {
1044
- const codePoint = parseInt(char, 16);
1045
- if (codePoint >= SURROGATE_FIRST && codePoint <= SURROGATE_LAST) {
1046
- throw this.error(new TomlError("Invalid unicode, character in range 0xD800 - 0xDFFF is reserved"));
1047
- }
1048
- return this.returnNow(String.fromCodePoint(codePoint));
1049
- } catch (err) {
1050
- throw this.error(TomlError.wrap(err));
1051
- }
1052
- }
1053
- parseSmallUnicode() {
1054
- if (!isHexit(this.char)) {
1055
- throw this.error(new TomlError("Invalid character in unicode sequence, expected hex"));
1056
- } else {
1057
- this.consume();
1058
- if (this.state.buf.length >= 4)
1059
- return this.return();
1060
- }
1061
- }
1062
- parseLargeUnicode() {
1063
- if (!isHexit(this.char)) {
1064
- throw this.error(new TomlError("Invalid character in unicode sequence, expected hex"));
1065
- } else {
1066
- this.consume();
1067
- if (this.state.buf.length >= 8)
1068
- return this.return();
1069
- }
1070
- }
1071
- /* NUMBERS */
1072
- parseNumberSign() {
1073
- this.consume();
1074
- return this.next(this.parseMaybeSignedInfOrNan);
1075
- }
1076
- parseMaybeSignedInfOrNan() {
1077
- if (this.char === CHAR_i) {
1078
- return this.next(this.parseInf);
1079
- } else if (this.char === CHAR_n) {
1080
- return this.next(this.parseNan);
1081
- } else {
1082
- return this.callNow(this.parseNoUnder, this.parseNumberIntegerStart);
1083
- }
1084
- }
1085
- parseNumberIntegerStart() {
1086
- if (this.char === CHAR_0) {
1087
- this.consume();
1088
- return this.next(this.parseNumberIntegerExponentOrDecimal);
1089
- } else {
1090
- return this.goto(this.parseNumberInteger);
1091
- }
1092
- }
1093
- parseNumberIntegerExponentOrDecimal() {
1094
- if (this.char === CHAR_PERIOD) {
1095
- this.consume();
1096
- return this.call(this.parseNoUnder, this.parseNumberFloat);
1097
- } else if (this.char === CHAR_E || this.char === CHAR_e) {
1098
- this.consume();
1099
- return this.next(this.parseNumberExponentSign);
1100
- } else {
1101
- return this.returnNow(Integer(this.state.buf));
1102
- }
1103
- }
1104
- parseNumberInteger() {
1105
- if (isDigit(this.char)) {
1106
- this.consume();
1107
- } else if (this.char === CHAR_LOWBAR) {
1108
- return this.call(this.parseNoUnder);
1109
- } else if (this.char === CHAR_E || this.char === CHAR_e) {
1110
- this.consume();
1111
- return this.next(this.parseNumberExponentSign);
1112
- } else if (this.char === CHAR_PERIOD) {
1113
- this.consume();
1114
- return this.call(this.parseNoUnder, this.parseNumberFloat);
1115
- } else {
1116
- const result = Integer(this.state.buf);
1117
- if (result.isNaN()) {
1118
- throw this.error(new TomlError("Invalid number"));
1119
- } else {
1120
- return this.returnNow(result);
1121
- }
1122
- }
1123
- }
1124
- parseNoUnder() {
1125
- if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD || this.char === CHAR_E || this.char === CHAR_e) {
1126
- throw this.error(new TomlError("Unexpected character, expected digit"));
1127
- } else if (this.atEndOfWord()) {
1128
- throw this.error(new TomlError("Incomplete number"));
1129
- }
1130
- return this.returnNow();
1131
- }
1132
- parseNoUnderHexOctBinLiteral() {
1133
- if (this.char === CHAR_LOWBAR || this.char === CHAR_PERIOD) {
1134
- throw this.error(new TomlError("Unexpected character, expected digit"));
1135
- } else if (this.atEndOfWord()) {
1136
- throw this.error(new TomlError("Incomplete number"));
1137
- }
1138
- return this.returnNow();
1139
- }
1140
- parseNumberFloat() {
1141
- if (this.char === CHAR_LOWBAR) {
1142
- return this.call(this.parseNoUnder, this.parseNumberFloat);
1143
- } else if (isDigit(this.char)) {
1144
- this.consume();
1145
- } else if (this.char === CHAR_E || this.char === CHAR_e) {
1146
- this.consume();
1147
- return this.next(this.parseNumberExponentSign);
1148
- } else {
1149
- return this.returnNow(Float(this.state.buf));
1150
- }
1151
- }
1152
- parseNumberExponentSign() {
1153
- if (isDigit(this.char)) {
1154
- return this.goto(this.parseNumberExponent);
1155
- } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) {
1156
- this.consume();
1157
- this.call(this.parseNoUnder, this.parseNumberExponent);
1158
- } else {
1159
- throw this.error(new TomlError("Unexpected character, expected -, + or digit"));
1160
- }
1161
- }
1162
- parseNumberExponent() {
1163
- if (isDigit(this.char)) {
1164
- this.consume();
1165
- } else if (this.char === CHAR_LOWBAR) {
1166
- return this.call(this.parseNoUnder);
1167
- } else {
1168
- return this.returnNow(Float(this.state.buf));
1169
- }
1170
- }
1171
- /* NUMBERS or DATETIMES */
1172
- parseNumberOrDateTime() {
1173
- if (this.char === CHAR_0) {
1174
- this.consume();
1175
- return this.next(this.parseNumberBaseOrDateTime);
1176
- } else {
1177
- return this.goto(this.parseNumberOrDateTimeOnly);
1178
- }
1179
- }
1180
- parseNumberOrDateTimeOnly() {
1181
- if (this.char === CHAR_LOWBAR) {
1182
- return this.call(this.parseNoUnder, this.parseNumberInteger);
1183
- } else if (isDigit(this.char)) {
1184
- this.consume();
1185
- if (this.state.buf.length > 4)
1186
- this.next(this.parseNumberInteger);
1187
- } else if (this.char === CHAR_E || this.char === CHAR_e) {
1188
- this.consume();
1189
- return this.next(this.parseNumberExponentSign);
1190
- } else if (this.char === CHAR_PERIOD) {
1191
- this.consume();
1192
- return this.call(this.parseNoUnder, this.parseNumberFloat);
1193
- } else if (this.char === CHAR_HYPHEN) {
1194
- return this.goto(this.parseDateTime);
1195
- } else if (this.char === CHAR_COLON) {
1196
- return this.goto(this.parseOnlyTimeHour);
1197
- } else {
1198
- return this.returnNow(Integer(this.state.buf));
1199
- }
1200
- }
1201
- parseDateTimeOnly() {
1202
- if (this.state.buf.length < 4) {
1203
- if (isDigit(this.char)) {
1204
- return this.consume();
1205
- } else if (this.char === CHAR_COLON) {
1206
- return this.goto(this.parseOnlyTimeHour);
1207
- } else {
1208
- throw this.error(new TomlError("Expected digit while parsing year part of a date"));
1209
- }
1210
- } else {
1211
- if (this.char === CHAR_HYPHEN) {
1212
- return this.goto(this.parseDateTime);
1213
- } else {
1214
- throw this.error(new TomlError("Expected hyphen (-) while parsing year part of date"));
1215
- }
1216
- }
1217
- }
1218
- parseNumberBaseOrDateTime() {
1219
- if (this.char === CHAR_b) {
1220
- this.consume();
1221
- return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerBin);
1222
- } else if (this.char === CHAR_o) {
1223
- this.consume();
1224
- return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerOct);
1225
- } else if (this.char === CHAR_x) {
1226
- this.consume();
1227
- return this.call(this.parseNoUnderHexOctBinLiteral, this.parseIntegerHex);
1228
- } else if (this.char === CHAR_PERIOD) {
1229
- return this.goto(this.parseNumberInteger);
1230
- } else if (isDigit(this.char)) {
1231
- return this.goto(this.parseDateTimeOnly);
1232
- } else {
1233
- return this.returnNow(Integer(this.state.buf));
1234
- }
1235
- }
1236
- parseIntegerHex() {
1237
- if (isHexit(this.char)) {
1238
- this.consume();
1239
- } else if (this.char === CHAR_LOWBAR) {
1240
- return this.call(this.parseNoUnderHexOctBinLiteral);
1241
- } else {
1242
- const result = Integer(this.state.buf);
1243
- if (result.isNaN()) {
1244
- throw this.error(new TomlError("Invalid number"));
1245
- } else {
1246
- return this.returnNow(result);
1247
- }
1248
- }
1249
- }
1250
- parseIntegerOct() {
1251
- if (isOctit(this.char)) {
1252
- this.consume();
1253
- } else if (this.char === CHAR_LOWBAR) {
1254
- return this.call(this.parseNoUnderHexOctBinLiteral);
1255
- } else {
1256
- const result = Integer(this.state.buf);
1257
- if (result.isNaN()) {
1258
- throw this.error(new TomlError("Invalid number"));
1259
- } else {
1260
- return this.returnNow(result);
1261
- }
1262
- }
1263
- }
1264
- parseIntegerBin() {
1265
- if (isBit(this.char)) {
1266
- this.consume();
1267
- } else if (this.char === CHAR_LOWBAR) {
1268
- return this.call(this.parseNoUnderHexOctBinLiteral);
1269
- } else {
1270
- const result = Integer(this.state.buf);
1271
- if (result.isNaN()) {
1272
- throw this.error(new TomlError("Invalid number"));
1273
- } else {
1274
- return this.returnNow(result);
1275
- }
1276
- }
1277
- }
1278
- /* DATETIME */
1279
- parseDateTime() {
1280
- if (this.state.buf.length < 4) {
1281
- throw this.error(new TomlError("Years less than 1000 must be zero padded to four characters"));
1282
- }
1283
- this.state.result = this.state.buf;
1284
- this.state.buf = "";
1285
- return this.next(this.parseDateMonth);
1286
- }
1287
- parseDateMonth() {
1288
- if (this.char === CHAR_HYPHEN) {
1289
- if (this.state.buf.length < 2) {
1290
- throw this.error(new TomlError("Months less than 10 must be zero padded to two characters"));
1291
- }
1292
- this.state.result += "-" + this.state.buf;
1293
- this.state.buf = "";
1294
- return this.next(this.parseDateDay);
1295
- } else if (isDigit(this.char)) {
1296
- this.consume();
1297
- } else {
1298
- throw this.error(new TomlError("Incomplete datetime"));
1299
- }
1300
- }
1301
- parseDateDay() {
1302
- if (this.char === CHAR_T || this.char === CHAR_SP) {
1303
- if (this.state.buf.length < 2) {
1304
- throw this.error(new TomlError("Days less than 10 must be zero padded to two characters"));
1305
- }
1306
- this.state.result += "-" + this.state.buf;
1307
- this.state.buf = "";
1308
- return this.next(this.parseStartTimeHour);
1309
- } else if (this.atEndOfWord()) {
1310
- return this.returnNow(createDate(this.state.result + "-" + this.state.buf));
1311
- } else if (isDigit(this.char)) {
1312
- this.consume();
1313
- } else {
1314
- throw this.error(new TomlError("Incomplete datetime"));
1315
- }
1316
- }
1317
- parseStartTimeHour() {
1318
- if (this.atEndOfWord()) {
1319
- return this.returnNow(createDate(this.state.result));
1320
- } else {
1321
- return this.goto(this.parseTimeHour);
1322
- }
1323
- }
1324
- parseTimeHour() {
1325
- if (this.char === CHAR_COLON) {
1326
- if (this.state.buf.length < 2) {
1327
- throw this.error(new TomlError("Hours less than 10 must be zero padded to two characters"));
1328
- }
1329
- this.state.result += "T" + this.state.buf;
1330
- this.state.buf = "";
1331
- return this.next(this.parseTimeMin);
1332
- } else if (isDigit(this.char)) {
1333
- this.consume();
1334
- } else {
1335
- throw this.error(new TomlError("Incomplete datetime"));
1336
- }
1337
- }
1338
- parseTimeMin() {
1339
- if (this.state.buf.length < 2 && isDigit(this.char)) {
1340
- this.consume();
1341
- } else if (this.state.buf.length === 2 && this.char === CHAR_COLON) {
1342
- this.state.result += ":" + this.state.buf;
1343
- this.state.buf = "";
1344
- return this.next(this.parseTimeSec);
1345
- } else {
1346
- throw this.error(new TomlError("Incomplete datetime"));
1347
- }
1348
- }
1349
- parseTimeSec() {
1350
- if (isDigit(this.char)) {
1351
- this.consume();
1352
- if (this.state.buf.length === 2) {
1353
- this.state.result += ":" + this.state.buf;
1354
- this.state.buf = "";
1355
- return this.next(this.parseTimeZoneOrFraction);
1356
- }
1357
- } else {
1358
- throw this.error(new TomlError("Incomplete datetime"));
1359
- }
1360
- }
1361
- parseOnlyTimeHour() {
1362
- if (this.char === CHAR_COLON) {
1363
- if (this.state.buf.length < 2) {
1364
- throw this.error(new TomlError("Hours less than 10 must be zero padded to two characters"));
1365
- }
1366
- this.state.result = this.state.buf;
1367
- this.state.buf = "";
1368
- return this.next(this.parseOnlyTimeMin);
1369
- } else {
1370
- throw this.error(new TomlError("Incomplete time"));
1371
- }
1372
- }
1373
- parseOnlyTimeMin() {
1374
- if (this.state.buf.length < 2 && isDigit(this.char)) {
1375
- this.consume();
1376
- } else if (this.state.buf.length === 2 && this.char === CHAR_COLON) {
1377
- this.state.result += ":" + this.state.buf;
1378
- this.state.buf = "";
1379
- return this.next(this.parseOnlyTimeSec);
1380
- } else {
1381
- throw this.error(new TomlError("Incomplete time"));
1382
- }
1383
- }
1384
- parseOnlyTimeSec() {
1385
- if (isDigit(this.char)) {
1386
- this.consume();
1387
- if (this.state.buf.length === 2) {
1388
- return this.next(this.parseOnlyTimeFractionMaybe);
1389
- }
1390
- } else {
1391
- throw this.error(new TomlError("Incomplete time"));
1392
- }
1393
- }
1394
- parseOnlyTimeFractionMaybe() {
1395
- this.state.result += ":" + this.state.buf;
1396
- if (this.char === CHAR_PERIOD) {
1397
- this.state.buf = "";
1398
- this.next(this.parseOnlyTimeFraction);
1399
- } else {
1400
- return this.return(createTime(this.state.result));
1401
- }
1402
- }
1403
- parseOnlyTimeFraction() {
1404
- if (isDigit(this.char)) {
1405
- this.consume();
1406
- } else if (this.atEndOfWord()) {
1407
- if (this.state.buf.length === 0)
1408
- throw this.error(new TomlError("Expected digit in milliseconds"));
1409
- return this.returnNow(createTime(this.state.result + "." + this.state.buf));
1410
- } else {
1411
- throw this.error(new TomlError("Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z"));
1412
- }
1413
- }
1414
- parseTimeZoneOrFraction() {
1415
- if (this.char === CHAR_PERIOD) {
1416
- this.consume();
1417
- this.next(this.parseDateTimeFraction);
1418
- } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) {
1419
- this.consume();
1420
- this.next(this.parseTimeZoneHour);
1421
- } else if (this.char === CHAR_Z) {
1422
- this.consume();
1423
- return this.return(createDateTime(this.state.result + this.state.buf));
1424
- } else if (this.atEndOfWord()) {
1425
- return this.returnNow(createDateTimeFloat(this.state.result + this.state.buf));
1426
- } else {
1427
- throw this.error(new TomlError("Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z"));
1428
- }
1429
- }
1430
- parseDateTimeFraction() {
1431
- if (isDigit(this.char)) {
1432
- this.consume();
1433
- } else if (this.state.buf.length === 1) {
1434
- throw this.error(new TomlError("Expected digit in milliseconds"));
1435
- } else if (this.char === CHAR_HYPHEN || this.char === CHAR_PLUS) {
1436
- this.consume();
1437
- this.next(this.parseTimeZoneHour);
1438
- } else if (this.char === CHAR_Z) {
1439
- this.consume();
1440
- return this.return(createDateTime(this.state.result + this.state.buf));
1441
- } else if (this.atEndOfWord()) {
1442
- return this.returnNow(createDateTimeFloat(this.state.result + this.state.buf));
1443
- } else {
1444
- throw this.error(new TomlError("Unexpected character in datetime, expected period (.), minus (-), plus (+) or Z"));
1445
- }
1446
- }
1447
- parseTimeZoneHour() {
1448
- if (isDigit(this.char)) {
1449
- this.consume();
1450
- if (/\d\d$/.test(this.state.buf))
1451
- return this.next(this.parseTimeZoneSep);
1452
- } else {
1453
- throw this.error(new TomlError("Unexpected character in datetime, expected digit"));
1454
- }
1455
- }
1456
- parseTimeZoneSep() {
1457
- if (this.char === CHAR_COLON) {
1458
- this.consume();
1459
- this.next(this.parseTimeZoneMin);
1460
- } else {
1461
- throw this.error(new TomlError("Unexpected character in datetime, expected colon"));
1462
- }
1463
- }
1464
- parseTimeZoneMin() {
1465
- if (isDigit(this.char)) {
1466
- this.consume();
1467
- if (/\d\d$/.test(this.state.buf))
1468
- return this.return(createDateTime(this.state.result + this.state.buf));
1469
- } else {
1470
- throw this.error(new TomlError("Unexpected character in datetime, expected digit"));
1471
- }
1472
- }
1473
- /* BOOLEAN */
1474
- parseBoolean() {
1475
- if (this.char === CHAR_t) {
1476
- this.consume();
1477
- return this.next(this.parseTrue_r);
1478
- } else if (this.char === CHAR_f) {
1479
- this.consume();
1480
- return this.next(this.parseFalse_a);
1481
- }
1482
- }
1483
- parseTrue_r() {
1484
- if (this.char === CHAR_r) {
1485
- this.consume();
1486
- return this.next(this.parseTrue_u);
1487
- } else {
1488
- throw this.error(new TomlError("Invalid boolean, expected true or false"));
1489
- }
1490
- }
1491
- parseTrue_u() {
1492
- if (this.char === CHAR_u) {
1493
- this.consume();
1494
- return this.next(this.parseTrue_e);
1495
- } else {
1496
- throw this.error(new TomlError("Invalid boolean, expected true or false"));
1497
- }
1498
- }
1499
- parseTrue_e() {
1500
- if (this.char === CHAR_e) {
1501
- return this.return(true);
1502
- } else {
1503
- throw this.error(new TomlError("Invalid boolean, expected true or false"));
1504
- }
1505
- }
1506
- parseFalse_a() {
1507
- if (this.char === CHAR_a) {
1508
- this.consume();
1509
- return this.next(this.parseFalse_l);
1510
- } else {
1511
- throw this.error(new TomlError("Invalid boolean, expected true or false"));
1512
- }
1513
- }
1514
- parseFalse_l() {
1515
- if (this.char === CHAR_l) {
1516
- this.consume();
1517
- return this.next(this.parseFalse_s);
1518
- } else {
1519
- throw this.error(new TomlError("Invalid boolean, expected true or false"));
1520
- }
1521
- }
1522
- parseFalse_s() {
1523
- if (this.char === CHAR_s) {
1524
- this.consume();
1525
- return this.next(this.parseFalse_e);
1526
- } else {
1527
- throw this.error(new TomlError("Invalid boolean, expected true or false"));
1528
- }
1529
- }
1530
- parseFalse_e() {
1531
- if (this.char === CHAR_e) {
1532
- return this.return(false);
1533
- } else {
1534
- throw this.error(new TomlError("Invalid boolean, expected true or false"));
1535
- }
1536
- }
1537
- /* INLINE LISTS */
1538
- parseInlineList() {
1539
- if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J) {
1540
- return null;
1541
- } else if (this.char === Parser.END) {
1542
- throw this.error(new TomlError("Unterminated inline array"));
1543
- } else if (this.char === CHAR_NUM) {
1544
- return this.call(this.parseComment);
1545
- } else if (this.char === CHAR_RSQB) {
1546
- return this.return(this.state.resultArr || InlineList());
1547
- } else {
1548
- return this.callNow(this.parseValue, this.recordInlineListValue);
1549
- }
1550
- }
1551
- recordInlineListValue(value) {
1552
- if (this.state.resultArr) {
1553
- const listType = this.state.resultArr[_contentType];
1554
- const valueType = tomlType(value);
1555
- if (listType !== valueType) {
1556
- throw this.error(new TomlError(`Inline lists must be a single type, not a mix of ${listType} and ${valueType}`));
1557
- }
1558
- } else {
1559
- this.state.resultArr = InlineList(tomlType(value));
1560
- }
1561
- if (isFloat(value) || isInteger(value)) {
1562
- this.state.resultArr.push(value.valueOf());
1563
- } else {
1564
- this.state.resultArr.push(value);
1565
- }
1566
- return this.goto(this.parseInlineListNext);
1567
- }
1568
- parseInlineListNext() {
1569
- if (this.char === CHAR_SP || this.char === CTRL_I || this.char === CTRL_M || this.char === CTRL_J) {
1570
- return null;
1571
- } else if (this.char === CHAR_NUM) {
1572
- return this.call(this.parseComment);
1573
- } else if (this.char === CHAR_COMMA) {
1574
- return this.next(this.parseInlineList);
1575
- } else if (this.char === CHAR_RSQB) {
1576
- return this.goto(this.parseInlineList);
1577
- } else {
1578
- throw this.error(new TomlError("Invalid character, expected whitespace, comma (,) or close bracket (])"));
1579
- }
1580
- }
1581
- /* INLINE TABLE */
1582
- parseInlineTable() {
1583
- if (this.char === CHAR_SP || this.char === CTRL_I) {
1584
- return null;
1585
- } else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) {
1586
- throw this.error(new TomlError("Unterminated inline array"));
1587
- } else if (this.char === CHAR_RCUB) {
1588
- return this.return(this.state.resultTable || InlineTable());
1589
- } else {
1590
- if (!this.state.resultTable)
1591
- this.state.resultTable = InlineTable();
1592
- return this.callNow(this.parseAssign, this.recordInlineTableValue);
1593
- }
1594
- }
1595
- recordInlineTableValue(kv) {
1596
- let target = this.state.resultTable;
1597
- let finalKey = kv.key.pop();
1598
- for (let kw of kv.key) {
1599
- if (hasKey(target, kw) && (!isTable(target[kw]) || target[kw][_declared])) {
1600
- throw this.error(new TomlError("Can't redefine existing key"));
1601
- }
1602
- target = target[kw] = target[kw] || Table();
1603
- }
1604
- if (hasKey(target, finalKey)) {
1605
- throw this.error(new TomlError("Can't redefine existing key"));
1606
- }
1607
- if (isInteger(kv.value) || isFloat(kv.value)) {
1608
- target[finalKey] = kv.value.valueOf();
1609
- } else {
1610
- target[finalKey] = kv.value;
1611
- }
1612
- return this.goto(this.parseInlineTableNext);
1613
- }
1614
- parseInlineTableNext() {
1615
- if (this.char === CHAR_SP || this.char === CTRL_I) {
1616
- return null;
1617
- } else if (this.char === Parser.END || this.char === CHAR_NUM || this.char === CTRL_J || this.char === CTRL_M) {
1618
- throw this.error(new TomlError("Unterminated inline array"));
1619
- } else if (this.char === CHAR_COMMA) {
1620
- return this.next(this.parseInlineTable);
1621
- } else if (this.char === CHAR_RCUB) {
1622
- return this.goto(this.parseInlineTable);
1623
- } else {
1624
- throw this.error(new TomlError("Invalid character, expected whitespace, comma (,) or close bracket (])"));
1625
- }
1626
- }
1627
- }
1628
- return TOMLParser;
1629
- }
1630
- }
1631
- });
1632
-
1633
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-pretty-error.js
1634
- var require_parse_pretty_error = __commonJS({
1635
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-pretty-error.js"(exports2, module2) {
1636
- "use strict";
1637
- init_cjs_shims();
1638
- module2.exports = prettyError;
1639
- function prettyError(err, buf) {
1640
- if (err.pos == null || err.line == null)
1641
- return err;
1642
- let msg = err.message;
1643
- msg += ` at row ${err.line + 1}, col ${err.col + 1}, pos ${err.pos}:
1644
- `;
1645
- if (buf && buf.split) {
1646
- const lines = buf.split(/\n/);
1647
- const lineNumWidth = String(Math.min(lines.length, err.line + 3)).length;
1648
- let linePadding = " ";
1649
- while (linePadding.length < lineNumWidth)
1650
- linePadding += " ";
1651
- for (let ii = Math.max(0, err.line - 1); ii < Math.min(lines.length, err.line + 2); ++ii) {
1652
- let lineNum = String(ii + 1);
1653
- if (lineNum.length < lineNumWidth)
1654
- lineNum = " " + lineNum;
1655
- if (err.line === ii) {
1656
- msg += lineNum + "> " + lines[ii] + "\n";
1657
- msg += linePadding + " ";
1658
- for (let hh = 0; hh < err.col; ++hh) {
1659
- msg += " ";
1660
- }
1661
- msg += "^\n";
1662
- } else {
1663
- msg += lineNum + ": " + lines[ii] + "\n";
1664
- }
1665
- }
1666
- }
1667
- err.message = msg + "\n";
1668
- return err;
1669
- }
1670
- }
1671
- });
1672
-
1673
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-string.js
1674
- var require_parse_string = __commonJS({
1675
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-string.js"(exports2, module2) {
1676
- "use strict";
1677
- init_cjs_shims();
1678
- module2.exports = parseString;
1679
- var TOMLParser = require_toml_parser();
1680
- var prettyError = require_parse_pretty_error();
1681
- function parseString(str) {
1682
- if (global.Buffer && global.Buffer.isBuffer(str)) {
1683
- str = str.toString("utf8");
1684
- }
1685
- const parser = new TOMLParser();
1686
- try {
1687
- parser.parse(str);
1688
- return parser.finish();
1689
- } catch (err) {
1690
- throw prettyError(err, str);
1691
- }
1692
- }
1693
- }
1694
- });
1695
-
1696
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-async.js
1697
- var require_parse_async = __commonJS({
1698
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-async.js"(exports2, module2) {
1699
- "use strict";
1700
- init_cjs_shims();
1701
- module2.exports = parseAsync;
1702
- var TOMLParser = require_toml_parser();
1703
- var prettyError = require_parse_pretty_error();
1704
- function parseAsync(str, opts) {
1705
- if (!opts)
1706
- opts = {};
1707
- const index = 0;
1708
- const blocksize = opts.blocksize || 40960;
1709
- const parser = new TOMLParser();
1710
- return new Promise((resolve, reject) => {
1711
- setImmediate(parseAsyncNext, index, blocksize, resolve, reject);
1712
- });
1713
- function parseAsyncNext(index2, blocksize2, resolve, reject) {
1714
- if (index2 >= str.length) {
1715
- try {
1716
- return resolve(parser.finish());
1717
- } catch (err) {
1718
- return reject(prettyError(err, str));
1719
- }
1720
- }
1721
- try {
1722
- parser.parse(str.slice(index2, index2 + blocksize2));
1723
- setImmediate(parseAsyncNext, index2 + blocksize2, blocksize2, resolve, reject);
1724
- } catch (err) {
1725
- reject(prettyError(err, str));
1726
- }
1727
- }
1728
- }
1729
- }
1730
- });
1731
-
1732
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-stream.js
1733
- var require_parse_stream = __commonJS({
1734
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse-stream.js"(exports2, module2) {
1735
- "use strict";
1736
- init_cjs_shims();
1737
- module2.exports = parseStream;
1738
- var stream = __require("stream");
1739
- var TOMLParser = require_toml_parser();
1740
- function parseStream(stm) {
1741
- if (stm) {
1742
- return parseReadable(stm);
1743
- } else {
1744
- return parseTransform(stm);
1745
- }
1746
- }
1747
- function parseReadable(stm) {
1748
- const parser = new TOMLParser();
1749
- stm.setEncoding("utf8");
1750
- return new Promise((resolve, reject) => {
1751
- let readable;
1752
- let ended = false;
1753
- let errored = false;
1754
- function finish() {
1755
- ended = true;
1756
- if (readable)
1757
- return;
1758
- try {
1759
- resolve(parser.finish());
1760
- } catch (err) {
1761
- reject(err);
1762
- }
1763
- }
1764
- function error(err) {
1765
- errored = true;
1766
- reject(err);
1767
- }
1768
- stm.once("end", finish);
1769
- stm.once("error", error);
1770
- readNext();
1771
- function readNext() {
1772
- readable = true;
1773
- let data;
1774
- while ((data = stm.read()) !== null) {
1775
- try {
1776
- parser.parse(data);
1777
- } catch (err) {
1778
- return error(err);
1779
- }
1780
- }
1781
- readable = false;
1782
- if (ended)
1783
- return finish();
1784
- if (errored)
1785
- return;
1786
- stm.once("readable", readNext);
1787
- }
1788
- });
1789
- }
1790
- function parseTransform() {
1791
- const parser = new TOMLParser();
1792
- return new stream.Transform({
1793
- objectMode: true,
1794
- transform(chunk, encoding, cb) {
1795
- try {
1796
- parser.parse(chunk.toString(encoding));
1797
- } catch (err) {
1798
- this.emit("error", err);
1799
- }
1800
- cb();
1801
- },
1802
- flush(cb) {
1803
- try {
1804
- this.push(parser.finish());
1805
- } catch (err) {
1806
- this.emit("error", err);
1807
- }
1808
- cb();
1809
- }
1810
- });
1811
- }
1812
- }
1813
- });
1814
-
1815
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse.js
1816
- var require_parse = __commonJS({
1817
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/parse.js"(exports2, module2) {
1818
- "use strict";
1819
- init_cjs_shims();
1820
- module2.exports = require_parse_string();
1821
- module2.exports.async = require_parse_async();
1822
- module2.exports.stream = require_parse_stream();
1823
- module2.exports.prettyError = require_parse_pretty_error();
1824
- }
1825
- });
1826
-
1827
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/stringify.js
1828
- var require_stringify = __commonJS({
1829
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/stringify.js"(exports2, module2) {
1830
- "use strict";
1831
- init_cjs_shims();
1832
- module2.exports = stringify2;
1833
- module2.exports.value = stringifyInline;
1834
- function stringify2(obj) {
1835
- if (obj === null)
1836
- throw typeError("null");
1837
- if (obj === void 0)
1838
- throw typeError("undefined");
1839
- if (typeof obj !== "object")
1840
- throw typeError(typeof obj);
1841
- if (typeof obj.toJSON === "function")
1842
- obj = obj.toJSON();
1843
- if (obj == null)
1844
- return null;
1845
- const type = tomlType2(obj);
1846
- if (type !== "table")
1847
- throw typeError(type);
1848
- return stringifyObject("", "", obj);
1849
- }
1850
- function typeError(type) {
1851
- return new Error("Can only stringify objects, not " + type);
1852
- }
1853
- function arrayOneTypeError() {
1854
- return new Error("Array values can't have mixed types");
1855
- }
1856
- function getInlineKeys(obj) {
1857
- return Object.keys(obj).filter((key) => isInline(obj[key]));
1858
- }
1859
- function getComplexKeys(obj) {
1860
- return Object.keys(obj).filter((key) => !isInline(obj[key]));
1861
- }
1862
- function toJSON(obj) {
1863
- let nobj = Array.isArray(obj) ? [] : Object.prototype.hasOwnProperty.call(obj, "__proto__") ? { ["__proto__"]: void 0 } : {};
1864
- for (let prop of Object.keys(obj)) {
1865
- if (obj[prop] && typeof obj[prop].toJSON === "function" && !("toISOString" in obj[prop])) {
1866
- nobj[prop] = obj[prop].toJSON();
1867
- } else {
1868
- nobj[prop] = obj[prop];
1869
- }
1870
- }
1871
- return nobj;
1872
- }
1873
- function stringifyObject(prefix, indent, obj) {
1874
- obj = toJSON(obj);
1875
- var inlineKeys;
1876
- var complexKeys;
1877
- inlineKeys = getInlineKeys(obj);
1878
- complexKeys = getComplexKeys(obj);
1879
- var result = [];
1880
- var inlineIndent = indent || "";
1881
- inlineKeys.forEach((key) => {
1882
- var type = tomlType2(obj[key]);
1883
- if (type !== "undefined" && type !== "null") {
1884
- result.push(inlineIndent + stringifyKey(key) + " = " + stringifyAnyInline(obj[key], true));
1885
- }
1886
- });
1887
- if (result.length > 0)
1888
- result.push("");
1889
- var complexIndent = prefix && inlineKeys.length > 0 ? indent + " " : "";
1890
- complexKeys.forEach((key) => {
1891
- result.push(stringifyComplex(prefix, complexIndent, key, obj[key]));
1892
- });
1893
- return result.join("\n");
1894
- }
1895
- function isInline(value) {
1896
- switch (tomlType2(value)) {
1897
- case "undefined":
1898
- case "null":
1899
- case "integer":
1900
- case "nan":
1901
- case "float":
1902
- case "boolean":
1903
- case "string":
1904
- case "datetime":
1905
- return true;
1906
- case "array":
1907
- return value.length === 0 || tomlType2(value[0]) !== "table";
1908
- case "table":
1909
- return Object.keys(value).length === 0;
1910
- default:
1911
- return false;
1912
- }
1913
- }
1914
- function tomlType2(value) {
1915
- if (value === void 0) {
1916
- return "undefined";
1917
- } else if (value === null) {
1918
- return "null";
1919
- } else if (typeof value === "bigint" || Number.isInteger(value) && !Object.is(value, -0)) {
1920
- return "integer";
1921
- } else if (typeof value === "number") {
1922
- return "float";
1923
- } else if (typeof value === "boolean") {
1924
- return "boolean";
1925
- } else if (typeof value === "string") {
1926
- return "string";
1927
- } else if ("toISOString" in value) {
1928
- return isNaN(value) ? "undefined" : "datetime";
1929
- } else if (Array.isArray(value)) {
1930
- return "array";
1931
- } else {
1932
- return "table";
1933
- }
1934
- }
1935
- function stringifyKey(key) {
1936
- var keyStr = String(key);
1937
- if (/^[-A-Za-z0-9_]+$/.test(keyStr)) {
1938
- return keyStr;
1939
- } else {
1940
- return stringifyBasicString(keyStr);
1941
- }
1942
- }
1943
- function stringifyBasicString(str) {
1944
- return '"' + escapeString(str).replace(/"/g, '\\"') + '"';
1945
- }
1946
- function stringifyLiteralString(str) {
1947
- return "'" + str + "'";
1948
- }
1949
- function numpad(num, str) {
1950
- while (str.length < num)
1951
- str = "0" + str;
1952
- return str;
1953
- }
1954
- function escapeString(str) {
1955
- return str.replace(/\\/g, "\\\\").replace(/[\b]/g, "\\b").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\f/g, "\\f").replace(/\r/g, "\\r").replace(/([\u0000-\u001f\u007f])/, (c) => "\\u" + numpad(4, c.codePointAt(0).toString(16)));
1956
- }
1957
- function stringifyMultilineString(str) {
1958
- let escaped = str.split(/\n/).map((str2) => {
1959
- return escapeString(str2).replace(/"(?="")/g, '\\"');
1960
- }).join("\n");
1961
- if (escaped.slice(-1) === '"')
1962
- escaped += "\\\n";
1963
- return '"""\n' + escaped + '"""';
1964
- }
1965
- function stringifyAnyInline(value, multilineOk) {
1966
- let type = tomlType2(value);
1967
- if (type === "string") {
1968
- if (multilineOk && /\n/.test(value)) {
1969
- type = "string-multiline";
1970
- } else if (!/[\b\t\n\f\r']/.test(value) && /"/.test(value)) {
1971
- type = "string-literal";
1972
- }
1973
- }
1974
- return stringifyInline(value, type);
1975
- }
1976
- function stringifyInline(value, type) {
1977
- if (!type)
1978
- type = tomlType2(value);
1979
- switch (type) {
1980
- case "string-multiline":
1981
- return stringifyMultilineString(value);
1982
- case "string":
1983
- return stringifyBasicString(value);
1984
- case "string-literal":
1985
- return stringifyLiteralString(value);
1986
- case "integer":
1987
- return stringifyInteger(value);
1988
- case "float":
1989
- return stringifyFloat(value);
1990
- case "boolean":
1991
- return stringifyBoolean(value);
1992
- case "datetime":
1993
- return stringifyDatetime(value);
1994
- case "array":
1995
- return stringifyInlineArray(value.filter((_) => tomlType2(_) !== "null" && tomlType2(_) !== "undefined" && tomlType2(_) !== "nan"));
1996
- case "table":
1997
- return stringifyInlineTable(value);
1998
- default:
1999
- throw typeError(type);
2000
- }
2001
- }
2002
- function stringifyInteger(value) {
2003
- return String(value).replace(/\B(?=(\d{3})+(?!\d))/g, "_");
2004
- }
2005
- function stringifyFloat(value) {
2006
- if (value === Infinity) {
2007
- return "inf";
2008
- } else if (value === -Infinity) {
2009
- return "-inf";
2010
- } else if (Object.is(value, NaN)) {
2011
- return "nan";
2012
- } else if (Object.is(value, -0)) {
2013
- return "-0.0";
2014
- }
2015
- var chunks = String(value).split(".");
2016
- var int = chunks[0];
2017
- var dec = chunks[1] || 0;
2018
- return stringifyInteger(int) + "." + dec;
2019
- }
2020
- function stringifyBoolean(value) {
2021
- return String(value);
2022
- }
2023
- function stringifyDatetime(value) {
2024
- return value.toISOString();
2025
- }
2026
- function isNumber(type) {
2027
- return type === "float" || type === "integer";
2028
- }
2029
- function arrayType(values) {
2030
- var contentType = tomlType2(values[0]);
2031
- if (values.every((_) => tomlType2(_) === contentType))
2032
- return contentType;
2033
- if (values.every((_) => isNumber(tomlType2(_))))
2034
- return "float";
2035
- return "mixed";
2036
- }
2037
- function validateArray(values) {
2038
- const type = arrayType(values);
2039
- if (type === "mixed") {
2040
- throw arrayOneTypeError();
2041
- }
2042
- return type;
2043
- }
2044
- function stringifyInlineArray(values) {
2045
- values = toJSON(values);
2046
- const type = validateArray(values);
2047
- var result = "[";
2048
- var stringified = values.map((_) => stringifyInline(_, type));
2049
- if (stringified.join(", ").length > 60 || /\n/.test(stringified)) {
2050
- result += "\n " + stringified.join(",\n ") + "\n";
2051
- } else {
2052
- result += " " + stringified.join(", ") + (stringified.length > 0 ? " " : "");
2053
- }
2054
- return result + "]";
2055
- }
2056
- function stringifyInlineTable(value) {
2057
- value = toJSON(value);
2058
- var result = [];
2059
- Object.keys(value).forEach((key) => {
2060
- result.push(stringifyKey(key) + " = " + stringifyAnyInline(value[key], false));
2061
- });
2062
- return "{ " + result.join(", ") + (result.length > 0 ? " " : "") + "}";
2063
- }
2064
- function stringifyComplex(prefix, indent, key, value) {
2065
- var valueType = tomlType2(value);
2066
- if (valueType === "array") {
2067
- return stringifyArrayOfTables(prefix, indent, key, value);
2068
- } else if (valueType === "table") {
2069
- return stringifyComplexTable(prefix, indent, key, value);
2070
- } else {
2071
- throw typeError(valueType);
2072
- }
2073
- }
2074
- function stringifyArrayOfTables(prefix, indent, key, values) {
2075
- values = toJSON(values);
2076
- validateArray(values);
2077
- var firstValueType = tomlType2(values[0]);
2078
- if (firstValueType !== "table")
2079
- throw typeError(firstValueType);
2080
- var fullKey = prefix + stringifyKey(key);
2081
- var result = "";
2082
- values.forEach((table) => {
2083
- if (result.length > 0)
2084
- result += "\n";
2085
- result += indent + "[[" + fullKey + "]]\n";
2086
- result += stringifyObject(fullKey + ".", indent, table);
2087
- });
2088
- return result;
2089
- }
2090
- function stringifyComplexTable(prefix, indent, key, value) {
2091
- var fullKey = prefix + stringifyKey(key);
2092
- var result = "";
2093
- if (getInlineKeys(value).length > 0) {
2094
- result += indent + "[" + fullKey + "]\n";
2095
- }
2096
- return result + stringifyObject(fullKey + ".", indent, value);
2097
- }
2098
- }
2099
- });
2100
-
2101
- // ../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/toml.js
2102
- var require_toml = __commonJS({
2103
- "../../node_modules/.pnpm/@iarna+toml@2.2.5/node_modules/@iarna/toml/toml.js"(exports2) {
2104
- "use strict";
2105
- init_cjs_shims();
2106
- exports2.parse = require_parse();
2107
- exports2.stringify = require_stringify();
2108
- }
2109
- });
2110
-
2111
- // src/commands/init.ts
2112
- init_cjs_shims();
2113
- var import_core2 = __toESM(require_lib(), 1);
2114
-
2115
- // ../cli-kit/src/public/node/base-command.ts
2116
- init_cjs_shims();
2117
-
2118
- // ../cli-kit/src/public/node/environments.ts
2119
- init_cjs_shims();
2120
-
2121
- // ../cli-kit/src/public/node/toml.ts
2122
- init_cjs_shims();
2123
- var toml = __toESM(require_toml(), 1);
2124
- function decodeToml(input) {
2125
- const normalizedInput = input.replace(/\r\n$/g, "\n");
2126
- return toml.parse(normalizedInput);
2127
- }
2128
-
2129
- // ../cli-kit/src/public/node/environments.ts
2130
- async function loadEnvironment(environmentName, fileName, options) {
2131
- const basePath = options?.from && options?.from !== "." ? options.from : cwd();
2132
- const filePath = await findPathUp(fileName, {
2133
- cwd: basePath,
2134
- type: "file"
2135
- });
2136
- if (!filePath) {
2137
- renderWarning({ body: "Environment file not found." });
2138
- return void 0;
2139
- }
2140
- const environmentsJson = decodeToml(await readFile(filePath));
2141
- const environments = environmentsJson.environments;
2142
- if (!environments) {
2143
- renderWarning({
2144
- body: ["No environments found in", { command: filePath }, { char: "." }]
2145
- });
2146
- return void 0;
2147
- }
2148
- const environment = environments[environmentName];
2149
- if (!environment)
2150
- renderWarning({
2151
- body: ["Environment", { command: environmentName }, "not found."]
2152
- });
2153
- await addSensitiveMetadata(() => ({
2154
- environmentFlags: JSON.stringify(environment)
2155
- }));
2156
- return environment;
2157
- }
2158
-
2159
- // ../cli-kit/src/public/node/base-command.ts
2160
- var import_core = __toESM(require_lib(), 1);
2161
- var BaseCommand = class extends import_core.Command {
2162
- static {
2163
- // eslint-disable-next-line @typescript-eslint/ban-types
2164
- this.baseFlags = {};
2165
- }
2166
- // Replace markdown links to plain text like: "link label" (url)
2167
- static descriptionWithoutMarkdown() {
2168
- return (this.descriptionWithMarkdown ?? "").replace(/(\[)(.*?)(])(\()(.*?)(\))/gm, '"$2" ($5)');
2169
- }
2170
- static analyticsNameOverride() {
2171
- return void 0;
2172
- }
2173
- static analyticsStopCommand() {
2174
- return void 0;
2175
- }
2176
- async catch(error) {
2177
- error.skipOclifErrorHandling = true;
2178
- await errorHandler(error, this.config);
2179
- return import_core.Errors.handle(error);
2180
- }
2181
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2182
- async init() {
2183
- this.exitWithTimestampWhenEnvVariablePresent();
2184
- if (!isDevelopment()) {
2185
- await registerCleanBugsnagErrorsFromWithinPlugins(this.config);
2186
- }
2187
- this.showNpmFlagWarning();
2188
- return super.init();
2189
- }
2190
- // NPM creates an environment variable for every flag passed to a script.
2191
- // This function checks for the presence of any of the available CLI flags
2192
- // and warns the user to use the `--` separator.
2193
- showNpmFlagWarning() {
2194
- const commandVariables = this.constructor;
2195
- const commandFlags = Object.keys(commandVariables.flags || {});
2196
- const possibleNpmEnvVars = commandFlags.map((key) => `npm_config_${underscore(key).replace(/^no_/, "")}`);
2197
- if (possibleNpmEnvVars.some((flag) => process.env[flag] !== void 0)) {
2198
- renderWarning({
2199
- body: [
2200
- "NPM scripts require an extra",
2201
- { command: "--" },
2202
- "separator to pass the flags. Example:",
2203
- { command: "npm run dev -- --reset" }
2204
- ]
2205
- });
2206
- }
2207
- }
2208
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
2209
- exitWithTimestampWhenEnvVariablePresent() {
2210
- if (isTruthy(process.env.SHOPIFY_CLI_ENV_STARTUP_PERFORMANCE_RUN)) {
2211
- outputInfo(`
2212
- SHOPIFY_CLI_TIMESTAMP_START
2213
- { "timestamp": ${Date.now()} }
2214
- SHOPIFY_CLI_TIMESTAMP_END
2215
- `);
2216
- process.exit(0);
2217
- }
2218
- }
2219
- async parse(options, argv) {
2220
- let result = await super.parse(options, argv);
2221
- result = await this.resultWithEnvironment(result, options, argv);
2222
- await addFromParsedFlags(result.flags);
2223
- return { ...result, ...{ argv: result.argv } };
2224
- }
2225
- environmentsFilename() {
2226
- return void 0;
2227
- }
2228
- failMissingNonTTYFlags(flags, requiredFlags) {
2229
- if (terminalSupportsRawMode())
2230
- return;
2231
- requiredFlags.forEach((name) => {
2232
- if (!(name in flags)) {
2233
- throw new AbortError(
2234
- outputContent`Flag not specified:
2235
-
2236
- ${outputToken.cyan(name)}
2237
-
2238
- This flag is required in non-interactive terminal environments, such as a CI environment, or when piping input from another process.`,
2239
- "To resolve this, specify the option in the command, or run the command in an interactive environment such as your local terminal."
2240
- );
2241
- }
2242
- });
2243
- }
2244
- async resultWithEnvironment(originalResult, options, argv) {
2245
- const flags = originalResult.flags;
2246
- const environmentsFileName = this.environmentsFilename();
2247
- if (!flags.environment || !environmentsFileName)
2248
- return originalResult;
2249
- const environment = await loadEnvironment(flags.environment, environmentsFileName, { from: flags.path });
2250
- if (!environment)
2251
- return originalResult;
2252
- const noDefaultsResult = await super.parse(noDefaultsOptions(options), argv);
2253
- const result = await super.parse(options, [
2254
- // Need to specify argv default because we're merging with argsFromEnvironment.
2255
- ...argv || this.argv,
2256
- ...argsFromEnvironment(environment, options, noDefaultsResult)
2257
- ]);
2258
- reportEnvironmentApplication(
2259
- noDefaultsResult.flags,
2260
- result.flags,
2261
- flags.environment,
2262
- environment
2263
- );
2264
- return result;
2265
- }
2266
- };
2267
- async function addFromParsedFlags(flags) {
2268
- await addPublicMetadata(() => ({
2269
- cmd_all_verbose: flags.verbose,
2270
- cmd_all_path_override: flags.path !== void 0,
2271
- cmd_all_path_override_hash: flags.path === void 0 ? void 0 : hashString(flags.path)
2272
- }));
2273
- }
2274
- function reportEnvironmentApplication(noDefaultsFlags, flagsWithEnvironments, environmentName, environment) {
2275
- const changes = {};
2276
- for (const [name, value] of Object.entries(flagsWithEnvironments)) {
2277
- const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(noDefaultsFlags, name);
2278
- const environmentContainsFlag = Object.prototype.hasOwnProperty.call(environment, name);
2279
- if (!userSpecifiedThisFlag && environmentContainsFlag) {
2280
- const valueToReport = name === "password" ? `********${value.substr(-4)}` : value;
2281
- changes[name] = valueToReport;
2282
- }
2283
- }
2284
- if (Object.keys(changes).length === 0)
2285
- return;
2286
- const items = Object.entries(changes).map(([name, value]) => `${name}: ${value}`);
2287
- renderInfo({
2288
- headline: ["Using applicable flags from", { userInput: environmentName }, "environment:"],
2289
- body: [{ list: { items } }]
2290
- });
2291
- }
2292
- function noDefaultsOptions(options) {
2293
- if (!options?.flags)
2294
- return options;
2295
- return {
2296
- ...options,
2297
- flags: Object.fromEntries(
2298
- Object.entries(options.flags).map(([label, settings]) => {
2299
- const copiedSettings = { ...settings };
2300
- delete copiedSettings.default;
2301
- return [label, copiedSettings];
2302
- })
2303
- )
2304
- };
2305
- }
2306
- function argsFromEnvironment(environment, options, noDefaultsResult) {
2307
- const args = [];
2308
- for (const [label, value] of Object.entries(environment)) {
2309
- const flagIsRelevantToCommand = options?.flags && Object.prototype.hasOwnProperty.call(options.flags, label);
2310
- const userSpecifiedThisFlag = noDefaultsResult.flags && Object.prototype.hasOwnProperty.call(noDefaultsResult.flags, label);
2311
- if (flagIsRelevantToCommand && !userSpecifiedThisFlag) {
2312
- if (typeof value === "boolean") {
2313
- if (value === true) {
2314
- args.push(`--${label}`);
2315
- } else {
2316
- throw new AbortError(
2317
- outputContent`Environments can only specify true for boolean flags. Attempted to set ${outputToken.yellow(
2318
- label
2319
- )} to false.`
2320
- );
2321
- }
2322
- } else if (Array.isArray(value)) {
2323
- value.forEach((element) => args.push(`--${label}`, `${element}`));
2324
- } else {
2325
- args.push(`--${label}`, `${value}`);
2326
- }
2327
- }
2328
- }
2329
- return args;
2330
- }
2331
- var base_command_default = BaseCommand;
2332
-
2333
- // src/commands/init.ts
2334
- var Init = class _Init extends base_command_default {
2335
- static {
2336
- this.summary = "Create a new app project";
2337
- }
2338
- static {
2339
- this.flags = {
2340
- ...globalFlags,
2341
- name: import_core2.Flags.string({
2342
- char: "n",
2343
- env: "SHOPIFY_FLAG_NAME",
2344
- hidden: false
2345
- }),
2346
- path: import_core2.Flags.string({
2347
- char: "p",
2348
- env: "SHOPIFY_FLAG_PATH",
2349
- parse: async (input) => resolvePath(input),
2350
- default: async () => cwd(),
2351
- hidden: false
2352
- }),
2353
- template: import_core2.Flags.string({
2354
- description: `The app template. Accepts one of the following:
2355
- - <${visibleTemplates.join("|")}>
2356
- - Any GitHub repo with optional branch and subpath, e.g., https://github.com/Shopify/<repository>/[subpath]#[branch]`,
2357
- env: "SHOPIFY_FLAG_TEMPLATE"
2358
- }),
2359
- flavor: import_core2.Flags.string({
2360
- description: "Which flavor of the given template to use.",
2361
- env: "SHOPIFY_FLAG_TEMPLATE_FLAVOR"
2362
- }),
2363
- "package-manager": import_core2.Flags.string({
2364
- char: "d",
2365
- env: "SHOPIFY_FLAG_PACKAGE_MANAGER",
2366
- hidden: false,
2367
- options: ["npm", "yarn", "pnpm", "bun"]
2368
- }),
2369
- local: import_core2.Flags.boolean({
2370
- char: "l",
2371
- env: "SHOPIFY_FLAG_LOCAL",
2372
- default: false,
2373
- hidden: true
2374
- })
2375
- };
2376
- }
2377
- async run() {
2378
- const { flags } = await this.parse(_Init);
2379
- this.validateTemplateValue(flags.template);
2380
- this.validateFlavorValue(flags.template, flags.flavor);
2381
- const inferredPackageManager = this.inferPackageManager(flags["package-manager"]);
2382
- const promptAnswers = await init_default({
2383
- name: flags.name,
2384
- template: flags.template,
2385
- flavor: flags.flavor,
2386
- directory: flags.path
2387
- });
2388
- if (promptAnswers.globalCLIResult.install) {
2389
- await installGlobalShopifyCLI(inferredPackageManager);
2390
- }
2391
- await addPublicMetadata(() => ({
2392
- cmd_create_app_template: promptAnswers.templateType,
2393
- cmd_create_app_template_url: promptAnswers.template
2394
- }));
2395
- await init_default2({
2396
- name: promptAnswers.name,
2397
- packageManager: inferredPackageManager,
2398
- template: promptAnswers.template,
2399
- local: flags.local,
2400
- directory: flags.path,
2401
- useGlobalCLI: promptAnswers.globalCLIResult.alreadyInstalled || promptAnswers.globalCLIResult.install,
2402
- postCloneActions: {
2403
- removeLockfilesFromGitignore: promptAnswers.templateType !== "custom"
2404
- }
2405
- });
2406
- }
2407
- validateTemplateValue(template) {
2408
- if (!template) {
2409
- return;
2410
- }
2411
- const url = this.parseURL(template);
2412
- if (url && url.origin !== "https://github.com")
2413
- throw new AbortError(
2414
- "Only GitHub repository references are supported, e.g., https://github.com/Shopify/<repository>/[subpath]#[branch]"
2415
- );
2416
- if (!url && !isPredefinedTemplate(template))
2417
- throw new AbortError(
2418
- outputContent`Only ${visibleTemplates.map((alias) => outputContent`${outputToken.yellow(alias)}`.value).join(", ")} template aliases are supported, please provide a valid URL`
2419
- );
2420
- }
2421
- validateFlavorValue(template, flavor) {
2422
- if (!template) {
2423
- if (flavor) {
2424
- throw new AbortError(
2425
- outputContent`The ${outputToken.yellow("--flavor")} flag requires the ${outputToken.yellow(
2426
- "--template"
2427
- )} flag to be set`
2428
- );
2429
- } else {
2430
- return;
2431
- }
2432
- }
2433
- if (!flavor) {
2434
- return;
2435
- }
2436
- if (!isPredefinedTemplate(template)) {
2437
- throw new AbortError(
2438
- outputContent`The ${outputToken.yellow("--flavor")} flag is not supported for custom templates`
2439
- );
2440
- }
2441
- const templateConfig = templates[template];
2442
- if (!templateConfig.branches) {
2443
- throw new AbortError(outputContent`The ${outputToken.yellow(template)} template does not support flavors`);
2444
- }
2445
- if (!templateConfig.branches.options[flavor]) {
2446
- throw new AbortError(
2447
- outputContent`Invalid option for ${outputToken.yellow("--flavor")}\nThe ${outputToken.yellow(
2448
- "--flavor"
2449
- )} flag for ${outputToken.yellow(template)} accepts only ${Object.keys(templateConfig.branches.options).map((alias) => outputContent`${outputToken.yellow(alias)}`.value).join(", ")}`
2450
- );
2451
- }
2452
- }
2453
- parseURL(url) {
2454
- try {
2455
- return new URL(url);
2456
- } catch (error) {
2457
- return void 0;
2458
- }
2459
- }
2460
- inferPackageManager(optionsPackageManager) {
2461
- if (optionsPackageManager && packageManager.includes(optionsPackageManager)) {
2462
- return optionsPackageManager;
2463
- }
2464
- const usedPackageManager = packageManagerFromUserAgent();
2465
- if (usedPackageManager !== "unknown")
2466
- return usedPackageManager;
2467
- const globalPackageManager = inferPackageManagerForGlobalCLI();
2468
- if (globalPackageManager !== "unknown")
2469
- return globalPackageManager;
2470
- return "npm";
2471
- }
2472
- };
2473
-
2474
- export {
2475
- Init
2476
- };
2477
- //# sourceMappingURL=chunk-ZRUHMMSQ.js.map