@shopify/create-app 3.75.4 → 3.76.1

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.
@@ -22455,7 +22455,7 @@ function createRuntimeMetadataContainer(defaultPublicMetadata = {}) {
22455
22455
  try {
22456
22456
  await getAndSet();
22457
22457
  } catch (error) {
22458
- let { sendErrorToBugsnag } = await import("./error-handler-R2NW6F5D.js");
22458
+ let { sendErrorToBugsnag } = await import("./error-handler-RBKB2PK5.js");
22459
22459
  await sendErrorToBugsnag(error, "unexpected_error");
22460
22460
  }
22461
22461
  }, durationStack = [];
@@ -28065,7 +28065,7 @@ function AutocompletePrompt({ message, choices, infoTable, onSubmit, search, has
28065
28065
  }
28066
28066
 
28067
28067
  // ../cli-kit/dist/public/node/ui.js
28068
- var import_react55 = __toESM(require_react()), defaultUIDebugOptions = {
28068
+ var import_react55 = __toESM(require_react(), 1), defaultUIDebugOptions = {
28069
28069
  skipTTYCheck: !1
28070
28070
  };
28071
28071
  async function renderConcurrent({ renderOptions, ...props }) {
@@ -28300,6 +28300,9 @@ function errorMessageImpliesEnvironmentIssue(message) {
28300
28300
  ].some((issueMessage) => message.includes(issueMessage));
28301
28301
  }
28302
28302
 
28303
+ // ../cli-kit/dist/public/node/os.js
28304
+ init_cjs_shims();
28305
+
28303
28306
  // ../../node_modules/.pnpm/execa@7.2.0/node_modules/execa/index.js
28304
28307
  init_cjs_shims();
28305
28308
  var import_cross_spawn = __toESM(require_cross_spawn(), 1);
@@ -29150,17 +29153,74 @@ function create$(options) {
29150
29153
  }
29151
29154
  var $ = create$();
29152
29155
 
29156
+ // ../cli-kit/dist/public/node/os.js
29157
+ import { userInfo as osUserInfo } from "os";
29158
+ async function username(platform2 = process.platform) {
29159
+ outputDebug(outputContent`Obtaining user name...`);
29160
+ let environmentVariable = getEnvironmentVariable();
29161
+ if (environmentVariable)
29162
+ return environmentVariable;
29163
+ let userInfoUsername = getUsernameFromOsUserInfo();
29164
+ if (userInfoUsername)
29165
+ return userInfoUsername;
29166
+ try {
29167
+ if (platform2 === "win32") {
29168
+ let { stdout } = await execa("whoami");
29169
+ return cleanWindowsCommand(stdout);
29170
+ }
29171
+ let { stdout: userId } = await execa("id", ["-u"]);
29172
+ try {
29173
+ let { stdout } = await execa("id", ["-un", userId]);
29174
+ return stdout;
29175
+ } catch {
29176
+ }
29177
+ return makeUsernameFromId(userId);
29178
+ } catch {
29179
+ return null;
29180
+ }
29181
+ }
29182
+ function platformAndArch(platform2 = process.platform, arch = process.arch) {
29183
+ let archString;
29184
+ return arch === "x64" ? archString = "amd64" : arch === "ia32" ? archString = "386" : archString = arch, { platform: platform2.match(/^win.+/) ? "windows" : platform2, arch: archString };
29185
+ }
29186
+ function getEnvironmentVariable() {
29187
+ let { env: env3 } = process;
29188
+ return env3.SUDO_USER || env3.C9_USER || env3.LOGNAME || env3.USER || env3.LNAME || env3.USERNAME;
29189
+ }
29190
+ function getUsernameFromOsUserInfo() {
29191
+ try {
29192
+ return osUserInfo().username;
29193
+ } catch {
29194
+ return null;
29195
+ }
29196
+ }
29197
+ function cleanWindowsCommand(value) {
29198
+ return value.replace(/^.*\\/, "");
29199
+ }
29200
+ function makeUsernameFromId(userId) {
29201
+ return `no-username-${userId}`;
29202
+ }
29203
+
29153
29204
  // ../cli-kit/dist/public/node/system.js
29154
29205
  var import_which = __toESM(require_lib2(), 1);
29155
29206
  async function openURL(url) {
29156
- await (await import("./open-BHIF7E3E.js")).default(url);
29207
+ let externalOpen = await import("./open-BHIF7E3E.js");
29208
+ try {
29209
+ return await externalOpen.default(url), !0;
29210
+ } catch {
29211
+ return !1;
29212
+ }
29157
29213
  }
29158
29214
  async function captureOutput(command, args, options) {
29159
29215
  return (await buildExec(command, args, options)).stdout;
29160
29216
  }
29161
29217
  async function exec3(command, args, options) {
29218
+ if (options) {
29219
+ let runningOnWindows = platformAndArch().platform === "windows";
29220
+ options.background = runningOnWindows ? !1 : options.background;
29221
+ }
29162
29222
  let commandProcess = buildExec(command, args, options);
29163
- options?.stderr && options.stderr !== "inherit" && commandProcess.stderr?.pipe(options.stderr, { end: !1 }), options?.stdout && options.stdout !== "inherit" && commandProcess.stdout?.pipe(options.stdout, { end: !1 });
29223
+ options?.background && commandProcess.unref(), options?.stderr && options.stderr !== "inherit" && commandProcess.stderr?.pipe(options.stderr, { end: !1 }), options?.stdout && options.stdout !== "inherit" && commandProcess.stdout?.pipe(options.stdout, { end: !1 });
29164
29224
  let aborted = !1;
29165
29225
  options?.signal?.addEventListener("abort", () => {
29166
29226
  let pid = commandProcess.pid;
@@ -29188,16 +29248,18 @@ function buildExec(command, args, options) {
29188
29248
  env: env3,
29189
29249
  cwd: executionCwd,
29190
29250
  input: options?.input,
29191
- stdio: options?.stdio,
29251
+ stdio: options?.background ? "ignore" : options?.stdio,
29192
29252
  stdin: options?.stdin,
29193
29253
  stdout: options?.stdout === "inherit" ? "inherit" : void 0,
29194
29254
  stderr: options?.stderr === "inherit" ? "inherit" : void 0,
29195
29255
  // Setting this to false makes it possible to kill the main process
29196
29256
  // and all its sub-processes with Ctrl+C on Windows
29197
- windowsHide: !1
29257
+ windowsHide: !1,
29258
+ detached: options?.background,
29259
+ cleanup: !options?.background
29198
29260
  });
29199
29261
  return outputDebug(`
29200
- Running system process:
29262
+ Running system process${options?.background ? " in background" : ""}:
29201
29263
  \xB7 Command: ${command} ${args.join(" ")}
29202
29264
  \xB7 Working directory: ${executionCwd}
29203
29265
  `), commandProcess;
@@ -30940,14 +31002,14 @@ var homedir = os5.homedir(), tmpdir2 = os5.tmpdir(), { env: env2 } = process20,
30940
31002
  temp: path7.join(tmpdir2, name)
30941
31003
  };
30942
31004
  }, linux = (name) => {
30943
- let username = path7.basename(homedir);
31005
+ let username2 = path7.basename(homedir);
30944
31006
  return {
30945
31007
  data: path7.join(env2.XDG_DATA_HOME || path7.join(homedir, ".local", "share"), name),
30946
31008
  config: path7.join(env2.XDG_CONFIG_HOME || path7.join(homedir, ".config"), name),
30947
31009
  cache: path7.join(env2.XDG_CACHE_HOME || path7.join(homedir, ".cache"), name),
30948
31010
  // https://wiki.debian.org/XDGBaseDirectorySpecification#state
30949
31011
  log: path7.join(env2.XDG_STATE_HOME || path7.join(homedir, ".local", "state"), name),
30950
- temp: path7.join(tmpdir2, username, name)
31012
+ temp: path7.join(tmpdir2, username2, name)
30951
31013
  };
30952
31014
  };
30953
31015
  function envPaths(name, { suffix = "nodejs" } = {}) {
@@ -31415,8 +31477,9 @@ export {
31415
31477
  mimicFunction,
31416
31478
  require_signal_exit,
31417
31479
  require_get_stream,
31418
- execa,
31419
31480
  execaSync,
31481
+ username,
31482
+ platformAndArch,
31420
31483
  openURL,
31421
31484
  captureOutput,
31422
31485
  exec3 as exec,
@@ -31629,4 +31692,4 @@ react-reconciler/cjs/react-reconciler-constants.development.js:
31629
31692
  * LICENSE file in the root directory of this source tree.
31630
31693
  *)
31631
31694
  */
31632
- //# sourceMappingURL=chunk-7GEGPVQ4.js.map
31695
+ //# sourceMappingURL=chunk-2SXZ4HIN.js.map
@@ -0,0 +1,164 @@
1
+ import {
2
+ CLI_KIT_VERSION,
3
+ z
4
+ } from "./chunk-U4CNJTWH.js";
5
+ import {
6
+ cacheRetrieve,
7
+ cacheStore,
8
+ versionSatisfies
9
+ } from "./chunk-UMKUGEPL.js";
10
+ import {
11
+ AbortSilentError,
12
+ exec,
13
+ isTruthy,
14
+ jsonOutputEnabled,
15
+ outputDebug,
16
+ renderError,
17
+ renderInfo,
18
+ renderWarning
19
+ } from "./chunk-2SXZ4HIN.js";
20
+ import {
21
+ init_cjs_shims
22
+ } from "./chunk-PKR7KJ6P.js";
23
+
24
+ // ../cli-kit/dist/public/node/notifications-system.js
25
+ init_cjs_shims();
26
+
27
+ // ../cli-kit/dist/public/node/global-context.js
28
+ init_cjs_shims();
29
+ var _globalContext;
30
+ function getGlobalContext() {
31
+ return _globalContext || (_globalContext = { currentCommandId: "" }), _globalContext;
32
+ }
33
+ function getCurrentCommandId() {
34
+ return getGlobalContext().currentCommandId;
35
+ }
36
+ function setCurrentCommandId(commandId) {
37
+ getGlobalContext().currentCommandId = commandId;
38
+ }
39
+
40
+ // ../cli-kit/dist/public/node/notifications-system.js
41
+ var URL = "https://cdn.shopify.com/static/cli/notifications.json", EMPTY_CACHE_MESSAGE = "Cache is empty";
42
+ function url() {
43
+ return process.env.SHOPIFY_CLI_NOTIFICATIONS_URL ?? URL;
44
+ }
45
+ var NotificationSchema = z.object({
46
+ id: z.string(),
47
+ message: z.string(),
48
+ type: z.enum(["info", "warning", "error"]),
49
+ frequency: z.enum(["always", "once", "once_a_day", "once_a_week"]),
50
+ ownerChannel: z.string(),
51
+ cta: z.object({
52
+ label: z.string(),
53
+ url: z.string().url()
54
+ }).optional(),
55
+ title: z.string().optional(),
56
+ minVersion: z.string().optional(),
57
+ maxVersion: z.string().optional(),
58
+ minDate: z.string().optional(),
59
+ maxDate: z.string().optional(),
60
+ commands: z.array(z.string()).optional(),
61
+ surface: z.string().optional()
62
+ }), NotificationsSchema = z.object({ notifications: z.array(NotificationSchema) });
63
+ async function showNotificationsIfNeeded(currentSurfaces, environment = process.env) {
64
+ try {
65
+ if (skipNotifications(environment) || jsonOutputEnabled(environment))
66
+ return;
67
+ let notifications = await getNotifications(), commandId = getCurrentCommandId(), notificationsToShow = filterNotifications(notifications.notifications, commandId, currentSurfaces);
68
+ outputDebug(`Notifications to show: ${notificationsToShow.length}`), await renderNotifications(notificationsToShow);
69
+ } catch (error) {
70
+ if (error.message === "abort")
71
+ throw new AbortSilentError();
72
+ let errorMessage = `Error retrieving notifications: ${error.message}`;
73
+ if (outputDebug(errorMessage), error.message === EMPTY_CACHE_MESSAGE)
74
+ return;
75
+ let { sendErrorToBugsnag } = await import("./error-handler-RBKB2PK5.js");
76
+ await sendErrorToBugsnag(errorMessage, "unexpected_error");
77
+ }
78
+ }
79
+ function skipNotifications(environment = process.env) {
80
+ return isTruthy(environment.CI) || isTruthy(environment.SHOPIFY_UNIT_TEST);
81
+ }
82
+ async function renderNotifications(notifications) {
83
+ notifications.slice(0, 2).forEach((notification) => {
84
+ let content = {
85
+ headline: notification.title,
86
+ body: notification.message.replaceAll("\\n", `
87
+ `),
88
+ link: notification.cta
89
+ };
90
+ switch (notification.type) {
91
+ case "info": {
92
+ renderInfo(content);
93
+ break;
94
+ }
95
+ case "warning": {
96
+ renderWarning(content);
97
+ break;
98
+ }
99
+ case "error":
100
+ throw renderError(content), new Error("abort");
101
+ }
102
+ cacheStore(`notification-${notification.id}`, (/* @__PURE__ */ new Date()).getTime().toString());
103
+ });
104
+ }
105
+ async function getNotifications() {
106
+ let cacheKey = `notifications-${url()}`, rawNotifications = cacheRetrieve(cacheKey)?.value;
107
+ if (!rawNotifications)
108
+ throw new Error(EMPTY_CACHE_MESSAGE);
109
+ let notifications = JSON.parse(rawNotifications);
110
+ return NotificationsSchema.parse(notifications);
111
+ }
112
+ function fetchNotificationsInBackground(currentCommand, argv = process.argv, environment = process.env) {
113
+ if (skipNotifications(environment))
114
+ return;
115
+ let command = "shopify", args = ["notifications", "list"];
116
+ if (argv[0] && argv[0] !== "shopify") {
117
+ command = argv[0];
118
+ let indexValue = currentCommand.split(":")[0] ?? "", index = argv.indexOf(indexValue);
119
+ index > 0 && args.unshift(...argv.slice(1, index));
120
+ }
121
+ exec(command, args, { background: !0, env: { ...process.env, SHOPIFY_CLI_NO_ANALYTICS: "1" } });
122
+ }
123
+ function filterNotifications(notifications, commandId, currentSurfaces, today = new Date((/* @__PURE__ */ new Date()).setUTCHours(0, 0, 0, 0)), currentVersion = CLI_KIT_VERSION) {
124
+ return notifications.filter((notification) => filterByVersion(notification, currentVersion)).filter((notifications2) => filterByDate(notifications2, today)).filter((notification) => filterByCommand(notification, commandId)).filter((notification) => filterBySurface(notification, commandId, currentSurfaces)).filter((notification) => filterByFrequency(notification));
125
+ }
126
+ function filterByVersion(notification, currentVersion) {
127
+ let minVersion = !notification.minVersion || versionSatisfies(currentVersion, `>=${notification.minVersion}`), maxVersion = !notification.maxVersion || versionSatisfies(currentVersion, `<=${notification.maxVersion}`);
128
+ return minVersion && maxVersion;
129
+ }
130
+ function filterByDate(notification, today) {
131
+ let minDate = !notification.minDate || new Date(notification.minDate) <= today, maxDate = !notification.maxDate || new Date(notification.maxDate) >= today;
132
+ return minDate && maxDate;
133
+ }
134
+ function filterByCommand(notification, commandId) {
135
+ return commandId === "" ? !0 : !notification.commands || notification.commands.includes(commandId);
136
+ }
137
+ function filterBySurface(notification, commandId, surfacesFromContext) {
138
+ let surfaceFromCommand = commandId.split(":")[0] ?? "all", notificationSurface = notification.surface ?? "all";
139
+ return surfacesFromContext ? surfacesFromContext.includes(notificationSurface) : notificationSurface === surfaceFromCommand || notificationSurface === "all";
140
+ }
141
+ function filterByFrequency(notification) {
142
+ if (!notification.frequency)
143
+ return !0;
144
+ let cacheKey = `notification-${notification.id}`, lastShown = cacheRetrieve(cacheKey)?.value;
145
+ if (!lastShown)
146
+ return !0;
147
+ switch (notification.frequency) {
148
+ case "always":
149
+ return !0;
150
+ case "once":
151
+ return !1;
152
+ case "once_a_day":
153
+ return (/* @__PURE__ */ new Date()).getTime() - Number(lastShown) > 24 * 3600 * 1e3;
154
+ case "once_a_week":
155
+ return (/* @__PURE__ */ new Date()).getTime() - Number(lastShown) > 7 * 24 * 3600 * 1e3;
156
+ }
157
+ }
158
+
159
+ export {
160
+ setCurrentCommandId,
161
+ showNotificationsIfNeeded,
162
+ fetchNotificationsInBackground
163
+ };
164
+ //# sourceMappingURL=chunk-6DVPWDT2.js.map
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  fanoutHooks,
3
3
  reportAnalyticsEvent
4
- } from "./chunk-PSC5XMO4.js";
4
+ } from "./chunk-TYR4LFUO.js";
5
5
  import {
6
6
  CLI_KIT_VERSION,
7
7
  getEnvironmentData
8
- } from "./chunk-KVD7B3JW.js";
8
+ } from "./chunk-U4CNJTWH.js";
9
9
  import {
10
10
  runWithRateLimit
11
- } from "./chunk-VCHNXIMX.js";
11
+ } from "./chunk-UMKUGEPL.js";
12
12
  import {
13
13
  AbortSilentError,
14
14
  CancelExecution,
@@ -23,7 +23,7 @@ import {
23
23
  reportingRateLimit,
24
24
  require_stacktracey,
25
25
  shouldReportErrorAsUnexpected
26
- } from "./chunk-7GEGPVQ4.js";
26
+ } from "./chunk-2SXZ4HIN.js";
27
27
  import {
28
28
  require_lib
29
29
  } from "./chunk-S3QEOIDU.js";
@@ -2129,4 +2129,4 @@ export {
2129
2129
  registerCleanBugsnagErrorsFromWithinPlugins,
2130
2130
  addBugsnagMetadata
2131
2131
  };
2132
- //# sourceMappingURL=chunk-FWAU3T7G.js.map
2132
+ //# sourceMappingURL=chunk-O2TTT575.js.map
@@ -4,10 +4,10 @@ import {
4
4
  getEnvironmentData,
5
5
  getLastSeenUserIdAfterAuth,
6
6
  getSensitiveEnvironmentData
7
- } from "./chunk-KVD7B3JW.js";
7
+ } from "./chunk-U4CNJTWH.js";
8
8
  import {
9
9
  runWithRateLimit
10
- } from "./chunk-VCHNXIMX.js";
10
+ } from "./chunk-UMKUGEPL.js";
11
11
  import {
12
12
  alwaysLogAnalytics,
13
13
  alwaysLogMetrics,
@@ -24,7 +24,7 @@ import {
24
24
  outputDebug,
25
25
  outputToken,
26
26
  reportingRateLimit
27
- } from "./chunk-7GEGPVQ4.js";
27
+ } from "./chunk-2SXZ4HIN.js";
28
28
  import {
29
29
  __commonJS,
30
30
  __esm,
@@ -15926,4 +15926,4 @@ export {
15926
15926
  requestIdsCollection,
15927
15927
  reportAnalyticsEvent
15928
15928
  };
15929
- //# sourceMappingURL=chunk-PSC5XMO4.js.map
15929
+ //# sourceMappingURL=chunk-TYR4LFUO.js.map