@shopify/create-app 3.75.3 → 3.76.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.
@@ -0,0 +1,164 @@
1
+ import {
2
+ CLI_KIT_VERSION,
3
+ z
4
+ } from "./chunk-BR3KKEPN.js";
5
+ import {
6
+ cacheRetrieve,
7
+ cacheStore,
8
+ versionSatisfies
9
+ } from "./chunk-4IZOAUIJ.js";
10
+ import {
11
+ AbortSilentError,
12
+ exec,
13
+ isTruthy,
14
+ jsonOutputEnabled,
15
+ outputDebug,
16
+ renderError,
17
+ renderInfo,
18
+ renderWarning
19
+ } from "./chunk-4HFDUDDU.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-QN5AUYGU.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-IDMI4B5S.js.map
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  fanoutHooks,
3
3
  reportAnalyticsEvent
4
- } from "./chunk-7HUHPP7O.js";
4
+ } from "./chunk-VV6IS7HZ.js";
5
5
  import {
6
6
  CLI_KIT_VERSION,
7
7
  getEnvironmentData
8
- } from "./chunk-5UVQFDVV.js";
8
+ } from "./chunk-BR3KKEPN.js";
9
9
  import {
10
10
  runWithRateLimit
11
- } from "./chunk-GLMO3EKF.js";
11
+ } from "./chunk-4IZOAUIJ.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-JU7XOPSV.js";
26
+ } from "./chunk-4HFDUDDU.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-A6GHFQXL.js.map
2132
+ //# sourceMappingURL=chunk-U4LAO4KY.js.map
@@ -4,10 +4,10 @@ import {
4
4
  getEnvironmentData,
5
5
  getLastSeenUserIdAfterAuth,
6
6
  getSensitiveEnvironmentData
7
- } from "./chunk-5UVQFDVV.js";
7
+ } from "./chunk-BR3KKEPN.js";
8
8
  import {
9
9
  runWithRateLimit
10
- } from "./chunk-GLMO3EKF.js";
10
+ } from "./chunk-4IZOAUIJ.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-JU7XOPSV.js";
27
+ } from "./chunk-4HFDUDDU.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-7HUHPP7O.js.map
15929
+ //# sourceMappingURL=chunk-VV6IS7HZ.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  execaSync,
3
3
  fileExistsSync
4
- } from "./chunk-JU7XOPSV.js";
4
+ } from "./chunk-4HFDUDDU.js";
5
5
  import {
6
6
  require_lib
7
7
  } from "./chunk-S3QEOIDU.js";
@@ -43,4 +43,4 @@ var import_core = __toESM(require_lib(), 1), ShopifyConfig = class extends impor
43
43
  export {
44
44
  ShopifyConfig
45
45
  };
46
- //# sourceMappingURL=custom-oclif-loader-NIJWNTLD.js.map
46
+ //# sourceMappingURL=custom-oclif-loader-SMMR74RK.js.map
@@ -4,12 +4,12 @@ import {
4
4
  errorHandler,
5
5
  registerCleanBugsnagErrorsFromWithinPlugins,
6
6
  sendErrorToBugsnag
7
- } from "./chunk-A6GHFQXL.js";
8
- import "./chunk-7HUHPP7O.js";
9
- import "./chunk-5UVQFDVV.js";
7
+ } from "./chunk-U4LAO4KY.js";
8
+ import "./chunk-VV6IS7HZ.js";
9
+ import "./chunk-BR3KKEPN.js";
10
10
  import "./chunk-25IMI7TH.js";
11
- import "./chunk-GLMO3EKF.js";
12
- import "./chunk-JU7XOPSV.js";
11
+ import "./chunk-4IZOAUIJ.js";
12
+ import "./chunk-4HFDUDDU.js";
13
13
  import "./chunk-S3QEOIDU.js";
14
14
  import "./chunk-3I3GQNEW.js";
15
15
  import "./chunk-ZUCWDIGE.js";
@@ -28,4 +28,4 @@ export {
28
28
  registerCleanBugsnagErrorsFromWithinPlugins,
29
29
  sendErrorToBugsnag
30
30
  };
31
- //# sourceMappingURL=error-handler-5SSNTCMW.js.map
31
+ //# sourceMappingURL=error-handler-QN5AUYGU.js.map
@@ -3,16 +3,16 @@ import {
3
3
  } from "../chunk-CP3BRHWK.js";
4
4
  import {
5
5
  reportAnalyticsEvent
6
- } from "../chunk-7HUHPP7O.js";
7
- import "../chunk-5UVQFDVV.js";
6
+ } from "../chunk-VV6IS7HZ.js";
7
+ import "../chunk-BR3KKEPN.js";
8
8
  import "../chunk-25IMI7TH.js";
9
- import "../chunk-GLMO3EKF.js";
9
+ import "../chunk-4IZOAUIJ.js";
10
10
  import {
11
11
  addSensitiveMetadata,
12
12
  getAllSensitiveMetadata,
13
13
  outputDebug,
14
14
  renderWarning
15
- } from "../chunk-JU7XOPSV.js";
15
+ } from "../chunk-4HFDUDDU.js";
16
16
  import "../chunk-S3QEOIDU.js";
17
17
  import "../chunk-3I3GQNEW.js";
18
18
  import "../chunk-ZUCWDIGE.js";
@@ -71,9 +71,10 @@ async function detectStopCommand(commandClass) {
71
71
  let stopCommand = commandClass.analyticsStopCommand();
72
72
  if (stopCommand) {
73
73
  let { commandStartOptions } = getAllSensitiveMetadata();
74
+ if (!commandStartOptions)
75
+ return;
74
76
  await addSensitiveMetadata(() => ({
75
77
  commandStartOptions: {
76
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
77
78
  ...commandStartOptions,
78
79
  startTime: currentTime,
79
80
  startCommand: stopCommand
@@ -1,14 +1,17 @@
1
+ import {
2
+ fetchNotificationsInBackground
3
+ } from "../chunk-IDMI4B5S.js";
1
4
  import {
2
5
  CLI_KIT_VERSION,
3
6
  startAnalytics
4
- } from "../chunk-5UVQFDVV.js";
7
+ } from "../chunk-BR3KKEPN.js";
5
8
  import "../chunk-25IMI7TH.js";
6
9
  import {
7
10
  checkForCachedNewVersion,
8
11
  checkForNewVersion,
9
12
  packageManagerFromUserAgent,
10
13
  runAtMinimumInterval
11
- } from "../chunk-GLMO3EKF.js";
14
+ } from "../chunk-4IZOAUIJ.js";
12
15
  import {
13
16
  currentProcessIsGlobal,
14
17
  inferPackageManagerForGlobalCLI,
@@ -16,7 +19,7 @@ import {
16
19
  outputDebug,
17
20
  outputToken,
18
21
  outputWarn
19
- } from "../chunk-JU7XOPSV.js";
22
+ } from "../chunk-4HFDUDDU.js";
20
23
  import "../chunk-S3QEOIDU.js";
21
24
  import "../chunk-3I3GQNEW.js";
22
25
  import "../chunk-ZUCWDIGE.js";
@@ -53,7 +56,7 @@ var hook = async (options) => {
53
56
  aliases: options.Command.aliases,
54
57
  pluginAlias: options.Command.plugin?.alias
55
58
  }), args = options.argv;
56
- await warnOnAvailableUpgrade(), outputDebug(`Running command ${commandContent.command}`), await startAnalytics({ commandContent, args, commandClass: options.Command });
59
+ await warnOnAvailableUpgrade(), outputDebug(`Running command ${commandContent.command}`), await startAnalytics({ commandContent, args, commandClass: options.Command }), options.Command.hidden || fetchNotificationsInBackground(options.Command.id);
57
60
  };
58
61
  function parseCommandContent(cmdInfo) {
59
62
  let commandContent = parseCreateCommand(cmdInfo.pluginAlias);