@shopify/cli-kit 3.0.21 → 3.0.24

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,16 @@
1
1
  # @shopify/cli-kit
2
2
 
3
+ ## 3.0.24
4
+
5
+ ## 3.0.23
6
+
7
+ ## 3.0.22
8
+
9
+ ### Patch Changes
10
+
11
+ - 7f32e9ac: Add an interface to delete the global store
12
+ - 7f32e9ac: Make sure the user has a partner organization associated to the session
13
+
3
14
  ## 3.0.21
4
15
 
5
16
  ## 3.0.20
@@ -7156,7 +7156,7 @@ var path$w = /*#__PURE__*/Object.freeze({
7156
7156
  });
7157
7157
 
7158
7158
  var name = "@shopify/cli-kit";
7159
- var version$2 = "3.0.21";
7159
+ var version$2 = "3.0.24";
7160
7160
  var description$1 = "A set of utilities, interfaces, and models that are common across all the platform features";
7161
7161
  var keywords = [
7162
7162
  "shopify",
@@ -7207,13 +7207,13 @@ var os$7 = [
7207
7207
  var dependencies$1 = {
7208
7208
  "@oclif/core": "^1.0",
7209
7209
  envfile: "^6.17.0",
7210
+ fastify: "^4.0.0-rc.4",
7210
7211
  inquirer: "^8.2.4",
7211
7212
  keytar: "^7.9.0",
7212
7213
  open: "^8.4.0",
7213
7214
  prettier: "^2.6.2",
7214
7215
  "source-map-support": "^0.5.21",
7215
- stacktracey: "^2.1.8",
7216
- fastify: "^4.0.0-rc.4"
7216
+ stacktracey: "^2.1.8"
7217
7217
  };
7218
7218
  var devDependencies = {
7219
7219
  "@iarna/toml": "^2.2.5",
@@ -7254,6 +7254,7 @@ var devDependencies = {
7254
7254
  tempy: "^2.0.0",
7255
7255
  "term-size": "^3.0.1",
7256
7256
  "terminal-link": "^3.0.0",
7257
+ "ts-error": "^1.0.6",
7257
7258
  vitest: "^0.15.1",
7258
7259
  zod: "^3.17.3"
7259
7260
  };
@@ -8389,6 +8390,45 @@ var utilities = /*#__PURE__*/Object.freeze({
8389
8390
  isTruthy: isTruthy$1
8390
8391
  });
8391
8392
 
8393
+ class ExtendableError extends Error {
8394
+ constructor(...params) {
8395
+ super(...params);
8396
+ var message =
8397
+ params.length > 0 && typeof params[0] === "string" ? params[0] : "";
8398
+
8399
+ // Replace Error with ClassName of the constructor, if it has not been overwritten already
8400
+ if (this.name === undefined || this.name === "Error") {
8401
+ Object.defineProperty(this, "name", {
8402
+ configurable: true,
8403
+ enumerable: false,
8404
+ value: this.constructor.name,
8405
+ writable: true,
8406
+ });
8407
+ }
8408
+
8409
+ Object.defineProperty(this, "message", {
8410
+ configurable: true,
8411
+ enumerable: false,
8412
+ value: message,
8413
+ writable: true,
8414
+ });
8415
+
8416
+ Object.defineProperty(this, "stack", {
8417
+ configurable: true,
8418
+ enumerable: false,
8419
+ value: "",
8420
+ writable: true,
8421
+ });
8422
+
8423
+ // Maintains proper stack trace for where our error was thrown (only available on V8)
8424
+ if (Error.captureStackTrace) {
8425
+ Error.captureStackTrace(this, this.constructor);
8426
+ } else if (this.stack === "") {
8427
+ this.stack = new Error(message).stack;
8428
+ }
8429
+ }
8430
+ }
8431
+
8392
8432
  sourceMapSupport.install();
8393
8433
  class CancelExecution extends Error {
8394
8434
  }
@@ -8460,6 +8500,7 @@ var error$k = /*#__PURE__*/Object.freeze({
8460
8500
  mapper: mapper$1,
8461
8501
  isFatal: isFatal,
8462
8502
  shouldReport: shouldReport,
8503
+ ExtendableError: ExtendableError,
8463
8504
  AbortSignal: AbortSignal
8464
8505
  });
8465
8506
 
@@ -10530,7 +10571,7 @@ const fs$t = gracefulFs$1;
10530
10571
  const u$7 = universalify$1.fromCallback;
10531
10572
  const rimraf$2 = rimraf_1$1;
10532
10573
 
10533
- function remove$7 (path, callback) {
10574
+ function remove$8 (path, callback) {
10534
10575
  // Node 14.14.0+
10535
10576
  if (fs$t.rm) return fs$t.rm(path, { recursive: true, force: true }, callback)
10536
10577
  rimraf$2(path, callback);
@@ -10543,7 +10584,7 @@ function removeSync$1 (path) {
10543
10584
  }
10544
10585
 
10545
10586
  var remove_1 = {
10546
- remove: u$7(remove$7),
10587
+ remove: u$7(remove$8),
10547
10588
  removeSync: removeSync$1
10548
10589
  };
10549
10590
 
@@ -10551,7 +10592,7 @@ const u$6 = universalify$1.fromPromise;
10551
10592
  const fs$s = fs$C;
10552
10593
  const path$q = require$$0$2;
10553
10594
  const mkdir$4 = mkdirs$2;
10554
- const remove$6 = remove_1;
10595
+ const remove$7 = remove_1;
10555
10596
 
10556
10597
  const emptyDir = u$6(async function emptyDir (dir) {
10557
10598
  let items;
@@ -10561,7 +10602,7 @@ const emptyDir = u$6(async function emptyDir (dir) {
10561
10602
  return mkdir$4.mkdirs(dir)
10562
10603
  }
10563
10604
 
10564
- return Promise.all(items.map(item => remove$6.remove(path$q.join(dir, item))))
10605
+ return Promise.all(items.map(item => remove$7.remove(path$q.join(dir, item))))
10565
10606
  });
10566
10607
 
10567
10608
  function emptyDirSync (dir) {
@@ -10574,7 +10615,7 @@ function emptyDirSync (dir) {
10574
10615
 
10575
10616
  items.forEach(item => {
10576
10617
  item = path$q.join(dir, item);
10577
- remove$6.removeSync(item);
10618
+ remove$7.removeSync(item);
10578
10619
  });
10579
10620
  }
10580
10621
 
@@ -11140,7 +11181,7 @@ var json$2 = jsonFile;
11140
11181
  const fs$l = gracefulFs$1;
11141
11182
  const path$k = require$$0$2;
11142
11183
  const copy$1 = copy$2.copy;
11143
- const remove$5 = remove_1.remove;
11184
+ const remove$6 = remove_1.remove;
11144
11185
  const mkdirp = mkdirs$2.mkdirp;
11145
11186
  const pathExists$2 = pathExists_1.pathExists;
11146
11187
  const stat$1 = stat$4;
@@ -11178,7 +11219,7 @@ function isParentRoot$1 (dest) {
11178
11219
  function doRename$1 (src, dest, overwrite, isChangingCase, cb) {
11179
11220
  if (isChangingCase) return rename$1(src, dest, overwrite, cb)
11180
11221
  if (overwrite) {
11181
- return remove$5(dest, err => {
11222
+ return remove$6(dest, err => {
11182
11223
  if (err) return cb(err)
11183
11224
  return rename$1(src, dest, overwrite, cb)
11184
11225
  })
@@ -11205,7 +11246,7 @@ function moveAcrossDevice$1 (src, dest, overwrite, cb) {
11205
11246
  };
11206
11247
  copy$1(src, dest, opts, err => {
11207
11248
  if (err) return cb(err)
11208
- return remove$5(src, cb)
11249
+ return remove$6(src, cb)
11209
11250
  });
11210
11251
  }
11211
11252
 
@@ -13395,7 +13436,7 @@ function mkdirSync(path) {
13395
13436
  debug$5(content`Sync-reating directory at ${token.path(path)}...`);
13396
13437
  fs$j.mkdirpSync(path);
13397
13438
  }
13398
- async function remove$4(path) {
13439
+ async function remove$5(path) {
13399
13440
  debug$5(content`Removing file at ${token.path(path)}...`);
13400
13441
  await fs$j.remove(path);
13401
13442
  }
@@ -13471,7 +13512,7 @@ var file$1 = /*#__PURE__*/Object.freeze({
13471
13512
  append: append$2,
13472
13513
  mkdir: mkdir,
13473
13514
  mkdirSync: mkdirSync,
13474
- remove: remove$4,
13515
+ remove: remove$5,
13475
13516
  rmdir: rmdir,
13476
13517
  mkTmpDir: mkTmpDir,
13477
13518
  isDirectory: isDirectory,
@@ -14326,7 +14367,7 @@ function content(strings, ...keys) {
14326
14367
  output += colors$9.bold(colors$9.yellow(stringifyMessage(enumToken.value)));
14327
14368
  break;
14328
14369
  case 3 /* Path */:
14329
- output += colors$9.cyan(relativize(stringifyMessage(enumToken.value)));
14370
+ output += relativize(stringifyMessage(enumToken.value));
14330
14371
  break;
14331
14372
  case 2 /* Json */:
14332
14373
  try {
@@ -14461,7 +14502,8 @@ ${padding}${colors$9.bold("What to try:")}
14461
14502
  ${padding}${colors$9.bold("Stack trace:")}`;
14462
14503
  const stackLines = stack.asTable({}).split("\n");
14463
14504
  for (const stackLine of stackLines) {
14464
- outputString += `${padding}${stackLine}`;
14505
+ outputString += `${padding}${stackLine}
14506
+ `;
14465
14507
  }
14466
14508
  }
14467
14509
  }
@@ -16815,6 +16857,11 @@ async function page(filename) {
16815
16857
  const [command, ...args] = [...executable.split(" "), filename];
16816
16858
  await exec$2(command, args, { stdout: "inherit", stdin: "inherit" });
16817
16859
  }
16860
+ async function sleep(seconds) {
16861
+ return new Promise((resolve) => {
16862
+ setTimeout(resolve, 1e3 * seconds);
16863
+ });
16864
+ }
16818
16865
 
16819
16866
  var system = /*#__PURE__*/Object.freeze({
16820
16867
  __proto__: null,
@@ -16822,7 +16869,8 @@ var system = /*#__PURE__*/Object.freeze({
16822
16869
  captureOutput: captureOutput,
16823
16870
  exec: exec$2,
16824
16871
  concurrentExec: concurrentExec,
16825
- page: page
16872
+ page: page,
16873
+ sleep: sleep
16826
16874
  });
16827
16875
 
16828
16876
  const SpinInstanceNotFound = (spinInstance, error) => {
@@ -21876,7 +21924,7 @@ class Body$1 {
21876
21924
  return formData;
21877
21925
  }
21878
21926
 
21879
- const {toFormData} = await import('./multipart-parser-6958f711.js');
21927
+ const {toFormData} = await import('./multipart-parser-84c10b92.js');
21880
21928
  return toFormData(this.body, ct);
21881
21929
  }
21882
21930
 
@@ -45576,7 +45624,7 @@ async function nonEmptyDirectoryPrompt(directory) {
45576
45624
  if (choice.value === "abort") {
45577
45625
  throw new AbortSilent();
45578
45626
  }
45579
- remove$4(directory);
45627
+ remove$5(directory);
45580
45628
  }
45581
45629
  }
45582
45630
  const keypress = async () => {
@@ -57647,6 +57695,9 @@ const cliKit = new Conf({
57647
57695
  projectName: "shopify-cli-kit",
57648
57696
  projectVersion: cliKitPackageJson.version
57649
57697
  });
57698
+ function remove$4() {
57699
+ cliKit.clear();
57700
+ }
57650
57701
  function getAppInfo(directory) {
57651
57702
  debug$5(content`Reading cached app information for directory ${token.path(directory)}...`);
57652
57703
  const apps = cliKit.get("appInfo") ?? [];
@@ -57693,6 +57744,7 @@ function setThemeStore(store) {
57693
57744
  var store$2 = /*#__PURE__*/Object.freeze({
57694
57745
  __proto__: null,
57695
57746
  cliKit: cliKit,
57747
+ remove: remove$4,
57696
57748
  getAppInfo: getAppInfo,
57697
57749
  setAppInfo: setAppInfo,
57698
57750
  clearAppInfo: clearAppInfo,
@@ -154316,6 +154368,12 @@ var index = /*#__PURE__*/Object.freeze({
154316
154368
  FindOrganizationBasicQuery: FindOrganizationBasicQuery
154317
154369
  });
154318
154370
 
154371
+ class RequestClientError extends ExtendableError {
154372
+ constructor(message, statusCode) {
154373
+ super(message);
154374
+ this.statusCode = statusCode;
154375
+ }
154376
+ }
154319
154377
  async function request(query, token$1, variables) {
154320
154378
  const fqdn = await partners$1();
154321
154379
  const url = `https://${fqdn}/api/cli/graphql`;
@@ -154335,14 +154393,14 @@ ${sanitizedHeadersOutput(headers)}
154335
154393
  return response;
154336
154394
  } catch (error) {
154337
154395
  if (error instanceof dist$3.ClientError) {
154338
- const errorMessage = content`
154396
+ const errorMessage = stringifyMessage(content`
154339
154397
  The Partners GraphQL API responded unsuccessfully with the HTTP status ${`${error.response.status}`} and errors:
154340
154398
 
154341
154399
  ${token.json(error.response.errors)}
154342
- `;
154343
- const abortError = new Abort(errorMessage);
154344
- abortError.stack = error.stack;
154345
- throw abortError;
154400
+ `);
154401
+ const mappedError = new RequestClientError(errorMessage, error.response.status);
154402
+ mappedError.stack = error.stack;
154403
+ throw mappedError;
154346
154404
  } else {
154347
154405
  throw error;
154348
154406
  }
@@ -154385,6 +154443,7 @@ async function functionProxyRequest(apiKey, query, token, variables) {
154385
154443
 
154386
154444
  var partners = /*#__PURE__*/Object.freeze({
154387
154445
  __proto__: null,
154446
+ RequestClientError: RequestClientError,
154388
154447
  request: request,
154389
154448
  checkIfTokenIsRevoked: checkIfTokenIsRevoked,
154390
154449
  functionProxyRequest: functionProxyRequest
@@ -164598,6 +164657,9 @@ const NoSessionError = new Bug("No session found after ensuring authenticated");
164598
164657
  const MissingPartnerTokenError = new Bug("No partners token found after ensuring authenticated");
164599
164658
  const MissingAdminTokenError = new Bug("No admin token found after ensuring authenticated");
164600
164659
  const MissingStorefrontTokenError = new Bug("No storefront token found after ensuring authenticated");
164660
+ const PartnerOrganizationNotFoundError = () => {
164661
+ return new Abort(`Couldn't find your Shopify Partners organization`, `Have you confirmed your accounts from the emails you received?`);
164662
+ };
164601
164663
  async function ensureAuthenticatedPartners(scopes = [], env = process.env) {
164602
164664
  debug$5(content`Ensuring that the user is authenticated with the Partners API with the following scopes:
164603
164665
  ${token.json(scopes)}
@@ -164669,8 +164731,47 @@ ${token.json(applications)}
164669
164731
  if (envToken && applications.partnersApi) {
164670
164732
  tokens.partners = (await exchangeCustomPartnerToken(envToken)).accessToken;
164671
164733
  }
164734
+ if (!envToken && tokens.partners) {
164735
+ await ensureUserHasPartnerAccount(tokens.partners);
164736
+ }
164672
164737
  return tokens;
164673
164738
  }
164739
+ async function hasPartnerAccount(partnersToken) {
164740
+ try {
164741
+ await request(dist$3.gql`
164742
+ {
164743
+ organizations(first: 1) {
164744
+ nodes {
164745
+ id
164746
+ }
164747
+ }
164748
+ }
164749
+ `, partnersToken);
164750
+ return true;
164751
+ } catch (error) {
164752
+ if (error instanceof RequestClientError && error.statusCode === 404) {
164753
+ return false;
164754
+ } else {
164755
+ return true;
164756
+ }
164757
+ }
164758
+ }
164759
+ async function ensureUserHasPartnerAccount(partnersToken) {
164760
+ debug$5(content`Verifying that the user has a Partner organization`);
164761
+ if (!await hasPartnerAccount(partnersToken)) {
164762
+ info(`
164763
+ A Shopify Partners organization is needed to proceed.`);
164764
+ info(`\u{1F449} Press any key to create one`);
164765
+ await keypress();
164766
+ open(`https://partners.shopify.com/signup`);
164767
+ info(content`👉 Press any key when you have ${token.cyan("created the organization")}`);
164768
+ warn(content`Make sure you've confirmed your Shopify and the Partner organization from the email`);
164769
+ await keypress();
164770
+ if (!await hasPartnerAccount(partnersToken)) {
164771
+ throw PartnerOrganizationNotFoundError();
164772
+ }
164773
+ }
164774
+ }
164674
164775
  async function executeCompleteFlow(applications, identityFqdn2) {
164675
164776
  const scopes = getFlattenScopes(applications);
164676
164777
  const exchangeScopes = getExchangeScopes(applications);
@@ -164748,10 +164849,13 @@ function logout() {
164748
164849
 
164749
164850
  var session = /*#__PURE__*/Object.freeze({
164750
164851
  __proto__: null,
164852
+ PartnerOrganizationNotFoundError: PartnerOrganizationNotFoundError,
164751
164853
  ensureAuthenticatedPartners: ensureAuthenticatedPartners,
164752
164854
  ensureAuthenticatedStorefront: ensureAuthenticatedStorefront,
164753
164855
  ensureAuthenticatedAdmin: ensureAuthenticatedAdmin,
164754
164856
  ensureAuthenticated: ensureAuthenticated,
164857
+ hasPartnerAccount: hasPartnerAccount,
164858
+ ensureUserHasPartnerAccount: ensureUserHasPartnerAccount,
164755
164859
  logout: logout
164756
164860
  });
164757
164861
 
@@ -175187,4 +175291,4 @@ var yaml = /*#__PURE__*/Object.freeze({
175187
175291
  });
175188
175292
 
175189
175293
  export { semver$2 as A, session as B, store$2 as C, string as D, system as E, FormData$3 as F, template as G, temporary as H, toml as I, ui as J, version as K, vscode as L, yaml as M, File$1 as a, abort$3 as b, constants$2 as c, analytics as d, api as e, archiver as f, checksum as g, cli as h, dependency as i, dotEnv as j, environment as k, error$k as l, file$1 as m, git as n, github as o, haiku as p, http$2 as q, id as r, npm as s, os$3 as t, output as u, path$w as v, plugins as w, port as x, ruby as y, schema$1 as z };
175190
- //# sourceMappingURL=index-21b8e2fe.js.map
175294
+ //# sourceMappingURL=index-eb280c22.js.map