@shopify/cli-kit 2.0.13 → 2.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @shopify/cli-kit
2
2
 
3
+ ## 2.0.14
4
+
5
+ ### Patch Changes
6
+
7
+ - 87e51326: Report errors coming from child processes as abort errors
8
+ - 87e51326: Output the sub-processes that we execute when the user invokes the CLI with --verbose
9
+ - b10ddafc: Output requests' HTTP headers when the user invokes the CLI with --verbose
10
+
3
11
  ## 2.0.13
4
12
 
5
13
  ### Patch Changes
@@ -2190,7 +2190,7 @@ class ArrayPrompt$3 extends Prompt$5 {
2190
2190
  let len = this.choices.length;
2191
2191
  let num = this.num;
2192
2192
 
2193
- let handle = (val, res) => {
2193
+ let handle = (val = false, res) => {
2194
2194
  clearTimeout(this.numberTimeout);
2195
2195
  if (val) res = number(num);
2196
2196
  this.num = '';
@@ -2810,7 +2810,7 @@ const utils$r = utils$z;
2810
2810
  * @api public
2811
2811
  */
2812
2812
 
2813
- var placeholder$2 = (prompt, options) => {
2813
+ var placeholder$2 = (prompt, options = {}) => {
2814
2814
  prompt.cursorHide();
2815
2815
 
2816
2816
  let { input = '', initial = '', pos, showCursor = true, color } = options;
@@ -4059,7 +4059,7 @@ class Item {
4059
4059
  }
4060
4060
  }
4061
4061
 
4062
- const tokenize = async(options = {}, defaults, fn = token => token) => {
4062
+ const tokenize = async(options = {}, defaults = {}, fn = token => token) => {
4063
4063
  let unique = new Set();
4064
4064
  let fields = options.fields || [];
4065
4065
  let input = options.template;
@@ -5610,7 +5610,7 @@ async function pLocate$2(
5610
5610
  {
5611
5611
  concurrency = Number.POSITIVE_INFINITY,
5612
5612
  preserveOrder = true,
5613
- },
5613
+ } = {},
5614
5614
  ) {
5615
5615
  const limit = pLimit$3(concurrency);
5616
5616
 
@@ -5677,7 +5677,7 @@ const toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath)
5677
5677
 
5678
5678
  const findUpStop = Symbol('findUpStop');
5679
5679
 
5680
- async function findUpMultiple(name, options) {
5680
+ async function findUpMultiple(name, options = {}) {
5681
5681
  let directory = path$I.resolve(toPath(options.cwd) || '');
5682
5682
  const {root} = path$I.parse(directory);
5683
5683
  const stopAt = path$I.resolve(directory, options.stopAt || root);
@@ -6611,7 +6611,7 @@ const invalidStep = (step, options) => {
6611
6611
  return [];
6612
6612
  };
6613
6613
 
6614
- const fillNumbers = (start, end, step = 1, options) => {
6614
+ const fillNumbers = (start, end, step = 1, options = {}) => {
6615
6615
  let a = Number(start);
6616
6616
  let b = Number(end);
6617
6617
 
@@ -6663,7 +6663,7 @@ const fillNumbers = (start, end, step = 1, options) => {
6663
6663
  return range;
6664
6664
  };
6665
6665
 
6666
- const fillLetters = (start, end, step = 1, options) => {
6666
+ const fillLetters = (start, end, step = 1, options = {}) => {
6667
6667
  if ((!isNumber$3(start) && start.length > 1) || (!isNumber$3(end) && end.length > 1)) {
6668
6668
  return invalidRange(start, end, options);
6669
6669
  }
@@ -12317,7 +12317,7 @@ var path$w = /*#__PURE__*/Object.freeze({
12317
12317
  });
12318
12318
 
12319
12319
  var name = "@shopify/cli-kit";
12320
- var version$4 = "2.0.13";
12320
+ var version$4 = "2.0.14";
12321
12321
  var description$1 = "A set of utilities, interfaces, and models that are common across all the platform features";
12322
12322
  var keywords = [
12323
12323
  "shopify",
@@ -12432,11 +12432,11 @@ var cliKitPackageJson = {
12432
12432
  devDependencies: devDependencies
12433
12433
  };
12434
12434
 
12435
- var version$3 = "2.0.13";
12435
+ var version$3 = "2.0.14";
12436
12436
 
12437
- var version$2 = "2.0.13";
12437
+ var version$2 = "2.0.14";
12438
12438
 
12439
- var version$1 = "2.0.13";
12439
+ var version$1 = "2.0.14";
12440
12440
 
12441
12441
  const homedir$1 = os$8.homedir();
12442
12442
  const tmpdir$1 = os$8.tmpdir();
@@ -13225,7 +13225,7 @@ function npmRunPath(options = {}) {
13225
13225
  return [...result, path_].join(path$I.delimiter);
13226
13226
  }
13227
13227
 
13228
- function npmRunPathEnv({env = process$2.env, ...options}) {
13228
+ function npmRunPathEnv({env = process$2.env, ...options} = {}) {
13229
13229
  env = {...env};
13230
13230
 
13231
13231
  const path = pathKey({env});
@@ -14674,13 +14674,22 @@ const exec$2 = (command, args, options) => {
14674
14674
  cwd: options?.cwd,
14675
14675
  input: options?.stdin
14676
14676
  });
14677
+ debug$5(`
14678
+ Running system process:
14679
+ \xB7 Command: ${command} ${args.join(" ")}
14680
+ \xB7 Working directory: ${options?.cwd ?? process.cwd()}
14681
+ `);
14677
14682
  if (options?.stderr) {
14678
14683
  commandProcess.stderr?.pipe(options.stderr);
14679
14684
  }
14680
14685
  if (options?.stdout) {
14681
14686
  commandProcess.stdout?.pipe(options.stdout);
14682
14687
  }
14683
- return commandProcess;
14688
+ return commandProcess.catch((processError) => {
14689
+ const abortError = new Abort(processError.message);
14690
+ abortError.stack = processError.stack;
14691
+ throw abortError;
14692
+ });
14684
14693
  };
14685
14694
  const concurrentExec = async (commands) => {
14686
14695
  await concurrent(commands.map((command) => {
@@ -19029,7 +19038,7 @@ const rmkidsSync = (p, options) => {
19029
19038
  var rimraf_1 = rimraf$1;
19030
19039
  rimraf$1.sync = rimrafSync;
19031
19040
 
19032
- var indentString$3 = (string, count, options) => {
19041
+ var indentString$3 = (string, count = 1, options) => {
19033
19042
  options = {
19034
19043
  indent: ' ',
19035
19044
  includeEmptyLines: false,
@@ -19306,7 +19315,9 @@ del$2.exports = async (patterns, {force, dryRun, cwd = process.cwd(), onProgress
19306
19315
  });
19307
19316
  }
19308
19317
 
19309
- const mapper = async (file, fileIndex) => {
19318
+ let deletedCount = 0;
19319
+
19320
+ const mapper = async file => {
19310
19321
  file = path$a.resolve(cwd, file);
19311
19322
 
19312
19323
  if (!force) {
@@ -19317,10 +19328,12 @@ del$2.exports = async (patterns, {force, dryRun, cwd = process.cwd(), onProgress
19317
19328
  await rimrafP(file, rimrafOptions);
19318
19329
  }
19319
19330
 
19331
+ deletedCount += 1;
19332
+
19320
19333
  onProgress({
19321
19334
  totalCount: files.length,
19322
- deletedCount: fileIndex,
19323
- percent: fileIndex / files.length
19335
+ deletedCount,
19336
+ percent: deletedCount / files.length
19324
19337
  });
19325
19338
 
19326
19339
  return file;
@@ -19328,12 +19341,6 @@ del$2.exports = async (patterns, {force, dryRun, cwd = process.cwd(), onProgress
19328
19341
 
19329
19342
  const removedFiles = await pMap(files, mapper, options);
19330
19343
 
19331
- onProgress({
19332
- totalCount: files.length,
19333
- deletedCount: files.length,
19334
- percent: 1
19335
- });
19336
-
19337
19344
  removedFiles.sort((a, b) => a.localeCompare(b));
19338
19345
 
19339
19346
  return removedFiles;
@@ -21094,7 +21101,7 @@ if (typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol") {
21094
21101
  }
21095
21102
 
21096
21103
  class ContentToken {
21097
- constructor(value, metadata, type) {
21104
+ constructor(value, metadata = {}, type) {
21098
21105
  this.type = type;
21099
21106
  this.value = value;
21100
21107
  this.metadata = metadata;
@@ -21131,17 +21138,25 @@ const token = {
21131
21138
  green: (value) => {
21132
21139
  return new ContentToken(value, {}, 9 /* Green */);
21133
21140
  },
21134
- command: (dependencyManager, scriptNameAndArgs) => {
21135
- return new ContentToken(formatPackageManagerCommand(dependencyManager, scriptNameAndArgs), {}, 0 /* Command */);
21141
+ command: (dependencyManager, scriptName, ...scriptArgs) => {
21142
+ return new ContentToken(formatPackageManagerCommand(dependencyManager, scriptName, scriptArgs), {}, 0 /* Command */);
21136
21143
  }
21137
21144
  };
21138
- function formatPackageManagerCommand(dependencyManager, scriptNameAndArgs) {
21145
+ function formatPackageManagerCommand(dependencyManager, scriptName, scriptArgs) {
21139
21146
  switch (dependencyManager) {
21140
- case "yarn":
21141
- return `yarn ${scriptNameAndArgs}`;
21147
+ case "yarn": {
21148
+ const pieces = ["yarn", scriptName, ...scriptArgs];
21149
+ return pieces.join(" ");
21150
+ }
21142
21151
  case "pnpm":
21143
- case "npm":
21144
- return `${dependencyManager} run ${scriptNameAndArgs}`;
21152
+ case "npm": {
21153
+ const pieces = [dependencyManager, "run", scriptName];
21154
+ if (scriptArgs.length > 0) {
21155
+ pieces.push("--");
21156
+ pieces.push(...scriptArgs);
21157
+ }
21158
+ return pieces.join(" ");
21159
+ }
21145
21160
  }
21146
21161
  }
21147
21162
  class TokenizedString {
@@ -21305,7 +21320,7 @@ function stringifyMessage(message2) {
21305
21320
  return message2;
21306
21321
  }
21307
21322
  }
21308
- const message = (content2, level) => {
21323
+ const message = (content2, level = "info") => {
21309
21324
  if (shouldOutput(level)) {
21310
21325
  consoleLog(stringifyMessage(content2));
21311
21326
  }
@@ -21315,7 +21330,8 @@ async function concurrent(processes) {
21315
21330
  const concurrentColors = [token.yellow, token.cyan, token.magenta, token.green];
21316
21331
  const prefixColumnSize = Math.max(...processes.map((process2) => process2.prefix.length));
21317
21332
  function linePrefix(prefix, index) {
21318
- const color = concurrentColors[0];
21333
+ const colorIndex = index < concurrentColors.length ? index : index % concurrentColors.length;
21334
+ const color = concurrentColors[colorIndex];
21319
21335
  return color(`${prefix}${" ".repeat(prefixColumnSize - prefix.length)} ${colors$9.bold("|")} `);
21320
21336
  }
21321
21337
  try {
@@ -21324,7 +21340,7 @@ async function concurrent(processes) {
21324
21340
  write(chunk, _encoding, next) {
21325
21341
  const lines = stripAnsiEraseCursorEscapeCharacters(chunk.toString("ascii")).split(/\n/);
21326
21342
  for (const line of lines) {
21327
- info(content`${linePrefix(process2.prefix)}${line}`);
21343
+ info(content`${linePrefix(process2.prefix, index)}${line}`);
21328
21344
  }
21329
21345
  next();
21330
21346
  }
@@ -21333,7 +21349,7 @@ async function concurrent(processes) {
21333
21349
  write(chunk, _encoding, next) {
21334
21350
  const lines = stripAnsiEraseCursorEscapeCharacters(chunk.toString("ascii")).split(/\n/);
21335
21351
  for (const line of lines) {
21336
- message(content`${linePrefix(process2.prefix)}${colors$9.bold("ERROR")} ${line}`, "error");
21352
+ message(content`${linePrefix(process2.prefix, index)}${colors$9.bold("ERROR")} ${line}`, "error");
21337
21353
  }
21338
21354
  next();
21339
21355
  }
@@ -21439,7 +21455,8 @@ var error$j = /*#__PURE__*/Object.freeze({
21439
21455
  AbortSilent: AbortSilent,
21440
21456
  Bug: Bug,
21441
21457
  handler: handler,
21442
- mapper: mapper$1
21458
+ mapper: mapper$1,
21459
+ AbortSignal: AbortSignal
21443
21460
  });
21444
21461
 
21445
21462
  /******************************************************************************
@@ -35593,7 +35610,7 @@ function isTaskError(result) {
35593
35610
  function getErrorMessage(result) {
35594
35611
  return Buffer.concat([...result.stdOut, ...result.stdErr]);
35595
35612
  }
35596
- function errorDetectionHandler(overwrite, isError = isTaskError, errorMessage = getErrorMessage) {
35613
+ function errorDetectionHandler(overwrite = false, isError = isTaskError, errorMessage = getErrorMessage) {
35597
35614
  return (error, result) => {
35598
35615
  if (!overwrite && error || !isError(result)) {
35599
35616
  return error;
@@ -40106,7 +40123,7 @@ try {
40106
40123
  const POOL_SIZE = 65536;
40107
40124
 
40108
40125
  /** @param {(Blob | Uint8Array)[]} parts */
40109
- async function * toIterator (parts, clone) {
40126
+ async function * toIterator (parts, clone = true) {
40110
40127
  for (const part of parts) {
40111
40128
  if ('stream' in part) {
40112
40129
  yield * (/** @type {AsyncIterableIterator<Uint8Array>} */ (part.stream()));
@@ -40648,7 +40665,7 @@ class Body$1 {
40648
40665
  return formData;
40649
40666
  }
40650
40667
 
40651
- const {toFormData} = await import('./multipart-parser-2aa3d069.js');
40668
+ const {toFormData} = await import('./multipart-parser-e0ecbeb6.js');
40652
40669
  return toFormData(this.body, ct);
40653
40670
  }
40654
40671
 
@@ -41301,7 +41318,7 @@ class Response$3 extends Body$1 {
41301
41318
  * @param {number} status An optional status code for the response (e.g., 302.)
41302
41319
  * @returns {Response} A Response object.
41303
41320
  */
41304
- static redirect(url, status) {
41321
+ static redirect(url, status = 302) {
41305
41322
  if (!isRedirect(status)) {
41306
41323
  throw new RangeError('Failed to execute "redirect" on "response": Invalid status code');
41307
41324
  }
@@ -58020,7 +58037,7 @@ var decompressResponse = response => {
58020
58037
  };
58021
58038
 
58022
58039
  class QuickLRU$2 {
58023
- constructor(options) {
58040
+ constructor(options = {}) {
58024
58041
  if (!(options.maxSize && options.maxSize > 0)) {
58025
58042
  throw new TypeError('`maxSize` must be a number greater than 0');
58026
58043
  }
@@ -65887,7 +65904,7 @@ const compare = compare_1;
65887
65904
  // - If no C has a prerelease and the LT.semver tuple, return false
65888
65905
  // - Else return true
65889
65906
 
65890
- const subset = (sub, dom, options) => {
65907
+ const subset = (sub, dom, options = {}) => {
65891
65908
  if (sub === dom) {
65892
65909
  return true
65893
65910
  }
@@ -84244,7 +84261,7 @@ var mimicFn_1 = mimicFn$1;
84244
84261
 
84245
84262
  const mimicFn = mimicFn_1;
84246
84263
 
84247
- var debounceFn = (inputFunction, options) => {
84264
+ var debounceFn = (inputFunction, options = {}) => {
84248
84265
  if (typeof inputFunction !== 'function') {
84249
84266
  throw new TypeError(`Expected the first argument to be a function, got \`${typeof inputFunction}\``);
84250
84267
  }
@@ -84860,6 +84877,18 @@ async function buildHeaders(token) {
84860
84877
  };
84861
84878
  return headers;
84862
84879
  }
84880
+ function sanitizedHeadersOutput(headers) {
84881
+ const sanitized = {};
84882
+ const keywords = ["token", "authorization"];
84883
+ Object.keys(headers).forEach((header) => {
84884
+ if (keywords.find((keyword) => header.toLocaleLowerCase().includes(keyword)) === void 0) {
84885
+ sanitized[header] = headers[header];
84886
+ }
84887
+ });
84888
+ return Object.keys(sanitized).map((header) => {
84889
+ return ` - ${header}: ${sanitized[header]}`;
84890
+ }).join("\n");
84891
+ }
84863
84892
 
84864
84893
  var dist$1 = {};
84865
84894
 
@@ -170582,7 +170611,7 @@ const printDocASTReducer = {
170582
170611
  * print all items together separated by separator if provided
170583
170612
  */
170584
170613
 
170585
- function join(maybeArray, separator) {
170614
+ function join(maybeArray, separator = '') {
170586
170615
  var _maybeArray$filter$jo;
170587
170616
 
170588
170617
  return (_maybeArray$filter$jo =
@@ -171890,17 +171919,28 @@ function HeadersInstanceToPlainObject(headers) {
171890
171919
 
171891
171920
  }(dist$1));
171892
171921
 
171922
+ const UnauthorizedAccessError = () => {
171923
+ return new Bug(`You can't use Shopify CLI with development stores if you only have Partner staff member access.
171924
+ If you want to use Shopify CLI to work on a development store, then you should be the store owner or create a staff account on the store`, `If you're the store owner, then you need to log in to the store directly using the store URL at least once (for example, using %s.myshopify.com/admin) before you log in using Shopify CLI.
171925
+ Logging in to the Shopify admin directly connects the development store with your Shopify login.`);
171926
+ };
171927
+ const UnknownError = () => {
171928
+ return new Bug(`Unknown error connecting to your store`);
171929
+ };
171893
171930
  async function request$1(query, session, variables) {
171894
- debug$5(`
171895
- Sending Admin GraphQL request:
171896
- ${query}
171897
-
171898
- With variables:
171899
- ${variables ? JSON.stringify(variables, null, 2) : ""}
171900
- `);
171901
171931
  const version = await fetchApiVersion(session);
171902
171932
  const url = adminUrl(session.storeFqdn, version);
171903
171933
  const headers = await buildHeaders(session.token);
171934
+ debug$5(`
171935
+ Sending Admin GraphQL request:
171936
+ ${query}
171937
+
171938
+ With variables:
171939
+ ${variables ? JSON.stringify(variables, null, 2) : ""}
171940
+
171941
+ And headers:
171942
+ ${sanitizedHeadersOutput(headers)}
171943
+ `);
171904
171944
  return dist$1.request(url, query, variables, headers);
171905
171945
  }
171906
171946
  async function fetchApiVersion(session) {
@@ -171911,7 +171951,9 @@ async function fetchApiVersion(session) {
171911
171951
  Sending Admin GraphQL request to URL ${url} with query:
171912
171952
  ${query}
171913
171953
  `);
171914
- const data = await dist$1.request(url, query, {}, headers);
171954
+ const data = await dist$1.request(url, query, {}, headers).catch((err) => {
171955
+ throw err.response.status === 403 ? UnauthorizedAccessError() : UnknownError();
171956
+ });
171915
171957
  return data.publicApiVersions.filter((item) => item.supported).map((item) => item.handle).sort().reverse()[0];
171916
171958
  }
171917
171959
  function adminUrl(store, version) {
@@ -171944,6 +171986,9 @@ ${query}
171944
171986
 
171945
171987
  With variables:
171946
171988
  ${variables ? JSON.stringify(variables, null, 2) : ""}
171989
+
171990
+ And headers:
171991
+ ${sanitizedHeadersOutput(headers)}
171947
171992
  `);
171948
171993
  return dist$1.request(url, query, variables, headers);
171949
171994
  }
@@ -172143,6 +172188,25 @@ const ExtensionCreateQuery = dist$1.gql`
172143
172188
  }
172144
172189
  `;
172145
172190
 
172191
+ const FindProductVariantQuery = dist$1.gql`
172192
+ query {
172193
+ products(first: 1) {
172194
+ edges {
172195
+ node {
172196
+ id
172197
+ variants(first: 1) {
172198
+ edges {
172199
+ node {
172200
+ id
172201
+ }
172202
+ }
172203
+ }
172204
+ }
172205
+ }
172206
+ }
172207
+ }
172208
+ `;
172209
+
172146
172210
  var index = /*#__PURE__*/Object.freeze({
172147
172211
  __proto__: null,
172148
172212
  FindOrganizationQuery: FindOrganizationQuery,
@@ -172155,7 +172219,8 @@ var index = /*#__PURE__*/Object.freeze({
172155
172219
  CreateDeployment: CreateDeployment,
172156
172220
  AllStoresByOrganizationQuery: AllStoresByOrganizationQuery,
172157
172221
  ConvertDevToTestStoreQuery: ConvertDevToTestStoreQuery,
172158
- ExtensionCreateQuery: ExtensionCreateQuery
172222
+ ExtensionCreateQuery: ExtensionCreateQuery,
172223
+ FindProductVariantQuery: FindProductVariantQuery
172159
172224
  });
172160
172225
 
172161
172226
  var api = /*#__PURE__*/Object.freeze({
@@ -172795,4 +172860,4 @@ var plugins = /*#__PURE__*/Object.freeze({
172795
172860
  });
172796
172861
 
172797
172862
  export { npm as A, port as B, cli as C, id as D, temporary as E, FormData$3 as F, dotEnv as G, constants$2 as H, plugins as I, File$1 as a, string as b, github as c, dependency as d, error$j as e, file$1 as f, git as g, os$2 as h, environment as i, session as j, schema$2 as k, toml as l, store as m, api as n, output as o, path$w as p, http$2 as q, archiver as r, system as s, template as t, ui as u, version as v, checksum as w, ruby as x, yaml as y, semver as z };
172798
- //# sourceMappingURL=index-814fd0de.js.map
172863
+ //# sourceMappingURL=index-cf216492.js.map