@shopify/cli 3.0.11 → 3.0.12

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,21 @@
1
1
  # @shopify/cli
2
2
 
3
+ ## 3.0.12
4
+
5
+ ### Patch Changes
6
+
7
+ - 11d09f7f: Encourage upgrading if not up-to-date
8
+ - 89a48ba9: Report analytics for every command to Monorail
9
+ - Updated dependencies [e05749dc]
10
+ - Updated dependencies [89a48ba9]
11
+ - Updated dependencies [1f45ddc4]
12
+ - Updated dependencies [8c690cca]
13
+ - Updated dependencies [11d09f7f]
14
+ - Updated dependencies [783a3714]
15
+ - Updated dependencies [e12c82b3]
16
+ - Updated dependencies [cb8e2c25]
17
+ - @shopify/cli-kit@3.0.12
18
+
3
19
  ## 3.0.11
4
20
 
5
21
  ### Patch Changes
@@ -0,0 +1,23 @@
1
+ import { Command } from '@oclif/core';
2
+ import { output, dependency } from '@shopify/cli-kit';
3
+
4
+ const _Version = class extends Command {
5
+ async run() {
6
+ const cliDependency = "@shopify/cli";
7
+ const currentVersion = this.getCurrentVersion();
8
+ output.info(output.content`Current ${_Version.description}: ${output.token.yellow(currentVersion)}`.value);
9
+ const lastVersion = await dependency.checkForNewVersion(cliDependency, currentVersion);
10
+ if (lastVersion) {
11
+ output.info(output.content` Latest ${_Version.description}: ${output.token.yellow(lastVersion)}\nšŸ’”`);
12
+ output.info(dependency.getOutputUpdateCLIReminder(dependency.dependencyManagerUsedForCreating(), [cliDependency]));
13
+ }
14
+ }
15
+ getCurrentVersion() {
16
+ return this.config.version;
17
+ }
18
+ };
19
+ let Version = _Version;
20
+ Version.description = "Shopify CLI version";
21
+
22
+ export { Version as default };
23
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sources":["../../src/cli/commands/version.ts"],"sourcesContent":["import {Command} from '@oclif/core'\nimport {output, dependency} from '@shopify/cli-kit'\n\nexport default class Version extends Command {\n static description = 'Shopify CLI version'\n\n async run(): Promise<void> {\n const cliDependency = '@shopify/cli'\n const currentVersion = this.getCurrentVersion()\n output.info(output.content`Current ${Version.description}: ${output.token.yellow(currentVersion)}`.value)\n const lastVersion = await dependency.checkForNewVersion(cliDependency, currentVersion)\n if (lastVersion) {\n output.info(output.content` Latest ${Version.description}: ${output.token.yellow(lastVersion)}\\nšŸ’”`)\n output.info(dependency.getOutputUpdateCLIReminder(dependency.dependencyManagerUsedForCreating(), [cliDependency]))\n }\n }\n\n getCurrentVersion(): string {\n return this.config.version\n }\n}\n"],"names":[],"mappings":";;;AAGA,MAAqB,QAAA,GAArB,cAAqC,OAAQ,CAAA;AAAA,EAG3C,MAAM,GAAqB,GAAA;AACzB,IAAA,MAAM,aAAgB,GAAA,cAAA,CAAA;AACtB,IAAM,MAAA,cAAA,GAAiB,KAAK,iBAAkB,EAAA,CAAA;AAC9C,IAAO,MAAA,CAAA,IAAA,CAAK,MAAO,CAAA,OAAA,CAAA,QAAA,EAAkB,QAAQ,CAAA,WAAA,CAAA,EAAA,EAAgB,OAAO,KAAM,CAAA,MAAA,CAAO,cAAc,CAAA,CAAA,CAAA,CAAI,KAAK,CAAA,CAAA;AACxG,IAAA,MAAM,WAAc,GAAA,MAAM,UAAW,CAAA,kBAAA,CAAmB,eAAe,cAAc,CAAA,CAAA;AACrF,IAAA,IAAI,WAAa,EAAA;AACf,MAAO,MAAA,CAAA,IAAA,CAAK,OAAO,OAAkB,CAAA,QAAA,EAAA,QAAA,CAAQ,gBAAgB,MAAO,CAAA,KAAA,CAAM,MAAO,CAAA,WAAW,CAAO,CAAA,IAAA,CAAA,CAAA,CAAA;AACnG,MAAO,MAAA,CAAA,IAAA,CAAK,WAAW,0BAA2B,CAAA,UAAA,CAAW,kCAAoC,EAAA,CAAC,aAAa,CAAC,CAAC,CAAA,CAAA;AAAA,KACnH;AAAA,GACF;AAAA,EAEA,iBAA4B,GAAA;AAC1B,IAAA,OAAO,KAAK,MAAO,CAAA,OAAA,CAAA;AAAA,GACrB;AACF,CAAA,CAAA;AAjBA,IAAqB,OAArB,GAAA,SAAA;AAAqB,QACZ,WAAc,GAAA,qBAAA;;;;"}
@@ -0,0 +1,21 @@
1
+ import { reportEvent } from '../services/monorail.js';
2
+ import { environment, output } from '@shopify/cli-kit';
3
+
4
+ const hook = async (options) => {
5
+ try {
6
+ if (environment.local.isDebug() || environment.local.analyticsDisabled()) {
7
+ return;
8
+ }
9
+ const command = options.Command.id.replace(/:/g, " ");
10
+ await reportEvent(command, options.argv);
11
+ } catch (error) {
12
+ const message = "Failed to report usage analytics";
13
+ if (error instanceof Error) {
14
+ message.concat(`: ${error.message}`);
15
+ }
16
+ output.debug(message);
17
+ }
18
+ };
19
+
20
+ export { hook };
21
+ //# sourceMappingURL=monorail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monorail.js","sources":["../../src/hooks/monorail.ts"],"sourcesContent":["import {reportEvent} from '../services/monorail'\nimport {Hook} from '@oclif/core'\nimport {environment, output} from '@shopify/cli-kit'\n\nexport const hook: Hook.Postrun = async (options) => {\n try {\n if (environment.local.isDebug() || environment.local.analyticsDisabled()) {\n return\n }\n const command = options.Command.id.replace(/:/g, ' ')\n await reportEvent(command, options.argv)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n const message = 'Failed to report usage analytics'\n if (error instanceof Error) {\n message.concat(`: ${error.message}`)\n }\n output.debug(message)\n }\n}\n"],"names":[],"mappings":";;;AAIa,MAAA,IAAA,GAAqB,OAAO,OAAY,KAAA;AACnD,EAAI,IAAA;AACF,IAAA,IAAI,YAAY,KAAM,CAAA,OAAA,MAAa,WAAY,CAAA,KAAA,CAAM,mBAAqB,EAAA;AACxE,MAAA,OAAA;AAAA,KACF;AACA,IAAA,MAAM,UAAU,OAAQ,CAAA,OAAA,CAAQ,EAAG,CAAA,OAAA,CAAQ,MAAM,GAAG,CAAA,CAAA;AACpD,IAAM,MAAA,WAAA,CAAY,OAAS,EAAA,OAAA,CAAQ,IAAI,CAAA,CAAA;AAAA,WAEhC,KAAP,EAAA;AACA,IAAA,MAAM,OAAU,GAAA,kCAAA,CAAA;AAChB,IAAA,IAAI,iBAAiB,KAAO,EAAA;AAC1B,MAAQ,OAAA,CAAA,MAAA,CAAO,CAAK,EAAA,EAAA,KAAA,CAAM,OAAS,CAAA,CAAA,CAAA,CAAA;AAAA,KACrC;AACA,IAAA,MAAA,CAAO,MAAM,OAAO,CAAA,CAAA;AAAA,GACtB;AACF;;;;"}
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { settings, run, flush } from '@oclif/core';
2
2
  import Bugsnag from '@bugsnag/js';
3
3
  import { environment, error } from '@shopify/cli-kit';
4
4
 
5
- var version = "3.0.11";
5
+ var version = "3.0.12";
6
6
 
7
7
  function runCLI() {
8
8
  if (environment.local.isDebug()) {
@@ -0,0 +1,55 @@
1
+ import { http, output, path, store, os, ruby, environment } from '@shopify/cli-kit';
2
+
3
+ var version = "3.0.12";
4
+
5
+ const url = "https://monorail-edge.shopifysvc.com/v1/produce";
6
+ const reportEvent = async (command, args) => {
7
+ const currentTime = new Date().getTime();
8
+ const payload = await buildPayload(command, args, currentTime);
9
+ const body = JSON.stringify(payload);
10
+ const headers = buildHeaders(currentTime);
11
+ const response = await http.fetch(url, { method: "POST", body, headers });
12
+ if (response.status === 200) {
13
+ output.debug(`Analytics event sent: ${body}`);
14
+ } else {
15
+ output.debug(`Failed to report usage analytics: ${response.statusText}`);
16
+ }
17
+ };
18
+ const buildHeaders = (currentTime) => {
19
+ return {
20
+ "Content-Type": "application/json; charset=utf-8",
21
+ "X-Monorail-Edge-Event-Created-At-Ms": currentTime.toString(),
22
+ "X-Monorail-Edge-Event-Sent-At-Ms": currentTime.toString()
23
+ };
24
+ };
25
+ const buildPayload = async (command, args = [], currentTime) => {
26
+ let directory = process.cwd();
27
+ const pathFlagIndex = args.indexOf("--path");
28
+ if (pathFlagIndex >= 0) {
29
+ directory = path.resolve(args[pathFlagIndex + 1]);
30
+ }
31
+ const appInfo = store.getAppInfo(directory);
32
+ const { platform, arch } = os.platformAndArch();
33
+ return {
34
+ schema_id: "app_cli3_command/1.0",
35
+ payload: {
36
+ project_type: "node",
37
+ command,
38
+ args: args.join(" "),
39
+ time_start: currentTime,
40
+ time_end: currentTime,
41
+ total_time: 0,
42
+ success: true,
43
+ uname: `${platform} ${arch}`,
44
+ cli_version: version,
45
+ ruby_version: await ruby.version() || "",
46
+ node_version: process.version.replace("v", ""),
47
+ is_employee: await environment.local.isShopify(),
48
+ api_key: appInfo?.appId,
49
+ partner_id: appInfo?.orgId
50
+ }
51
+ };
52
+ };
53
+
54
+ export { reportEvent, url };
55
+ //# sourceMappingURL=monorail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monorail.js","sources":["../../src/services/monorail.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport {version} from '../../package.json'\nimport {environment, http, os, output, path, ruby, store} from '@shopify/cli-kit'\n\nexport const url = 'https://monorail-edge.shopifysvc.com/v1/produce'\n\nexport const reportEvent = async (command: string, args: string[]) => {\n const currentTime = new Date().getTime()\n const payload = await buildPayload(command, args, currentTime)\n const body = JSON.stringify(payload)\n const headers = buildHeaders(currentTime)\n\n const response = await http.fetch(url, {method: 'POST', body, headers})\n if (response.status === 200) {\n output.debug(`Analytics event sent: ${body}`)\n } else {\n output.debug(`Failed to report usage analytics: ${response.statusText}`)\n }\n}\n\nconst buildHeaders = (currentTime: number) => {\n return {\n 'Content-Type': 'application/json; charset=utf-8',\n 'X-Monorail-Edge-Event-Created-At-Ms': currentTime.toString(),\n 'X-Monorail-Edge-Event-Sent-At-Ms': currentTime.toString(),\n }\n}\n\nconst buildPayload = async (command: string, args: string[] = [], currentTime: number) => {\n let directory = process.cwd()\n const pathFlagIndex = args.indexOf('--path')\n if (pathFlagIndex >= 0) {\n directory = path.resolve(args[pathFlagIndex + 1])\n }\n const appInfo = store.getAppInfo(directory)\n const {platform, arch} = os.platformAndArch()\n return {\n schema_id: 'app_cli3_command/1.0',\n payload: {\n project_type: 'node',\n command,\n args: args.join(' '),\n time_start: currentTime,\n time_end: currentTime,\n total_time: 0,\n success: true,\n uname: `${platform} ${arch}`,\n cli_version: version,\n ruby_version: (await ruby.version()) || '',\n node_version: process.version.replace('v', ''),\n is_employee: await environment.local.isShopify(),\n api_key: appInfo?.appId,\n partner_id: appInfo?.orgId,\n },\n }\n}\n"],"names":[],"mappings":";;;;AAIO,MAAM,GAAM,GAAA,kDAAA;AAEN,MAAA,WAAA,GAAc,OAAO,OAAA,EAAiB,IAAmB,KAAA;AACpE,EAAA,MAAM,WAAc,GAAA,IAAI,IAAK,EAAA,CAAE,OAAQ,EAAA,CAAA;AACvC,EAAA,MAAM,OAAU,GAAA,MAAM,YAAa,CAAA,OAAA,EAAS,MAAM,WAAW,CAAA,CAAA;AAC7D,EAAM,MAAA,IAAA,GAAO,IAAK,CAAA,SAAA,CAAU,OAAO,CAAA,CAAA;AACnC,EAAM,MAAA,OAAA,GAAU,aAAa,WAAW,CAAA,CAAA;AAExC,EAAM,MAAA,QAAA,GAAW,MAAM,IAAA,CAAK,KAAM,CAAA,GAAA,EAAK,EAAC,MAAQ,EAAA,MAAA,EAAQ,IAAM,EAAA,OAAA,EAAQ,CAAA,CAAA;AACtE,EAAI,IAAA,QAAA,CAAS,WAAW,GAAK,EAAA;AAC3B,IAAO,MAAA,CAAA,KAAA,CAAM,yBAAyB,IAAM,CAAA,CAAA,CAAA,CAAA;AAAA,GACvC,MAAA;AACL,IAAO,MAAA,CAAA,KAAA,CAAM,CAAqC,kCAAA,EAAA,QAAA,CAAS,UAAY,CAAA,CAAA,CAAA,CAAA;AAAA,GACzE;AACF,EAAA;AAEA,MAAM,YAAA,GAAe,CAAC,WAAwB,KAAA;AAC5C,EAAO,OAAA;AAAA,IACL,cAAgB,EAAA,iCAAA;AAAA,IAChB,qCAAA,EAAuC,YAAY,QAAS,EAAA;AAAA,IAC5D,kCAAA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B,YAAY,OAAS,EAAA,KAAA;AAAA,KACvB;AAAA,GACF,CAAA;AACF,CAAA;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopify/cli",
3
- "version": "3.0.11",
3
+ "version": "3.0.12",
4
4
  "private": false,
5
5
  "description": "A CLI tool to build for the Shopify platform",
6
6
  "type": "module",
@@ -51,7 +51,7 @@
51
51
  "@oclif/core": "1.9.0",
52
52
  "@oclif/plugin-help": "^5.1.12",
53
53
  "@oclif/plugin-plugins": "^2.1.0",
54
- "@shopify/cli-kit": "3.0.11",
54
+ "@shopify/cli-kit": "3.0.12",
55
55
  "@shopify/plugin-ngrok": "^0.2.6"
56
56
  },
57
57
  "devDependencies": {
@@ -94,6 +94,9 @@
94
94
  },
95
95
  "additionalHelpFlags": [
96
96
  "-h"
97
- ]
97
+ ],
98
+ "hooks": {
99
+ "postrun": "dist/hooks/monorail"
100
+ }
98
101
  }
99
102
  }