@shopify/cli-kit 3.1.0 → 3.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @shopify/cli-kit
2
2
 
3
+ ## 3.2.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 86b04187: Exit without error message on deliberate user actions
8
+
3
9
  ## 3.1.0
4
10
 
5
11
  ### Minor Changes
package/dist/error.js CHANGED
@@ -57,8 +57,12 @@ export async function handler(error) {
57
57
  if (isFatal(error)) {
58
58
  fatal = error;
59
59
  }
60
+ else if (typeof error === 'string') {
61
+ fatal = new Bug(error);
62
+ }
60
63
  else {
61
64
  fatal = new Bug(error.message);
65
+ fatal.stack = error.stack;
62
66
  }
63
67
  if (fatal.type === FatalErrorType.Bug) {
64
68
  fatal.stack = error.stack;
package/dist/error.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,gBAAgB,EAAE,KAAK,IAAI,WAAW,EAAC,MAAM,aAAa,CAAA;AAC3E,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAElC,6DAA6D;AAC7D,aAAa;AACb,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAC,eAAe,EAAC,MAAM,UAAU,CAAA;AACxC,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAA;AAE5C,gBAAgB,CAAC,OAAO,EAAE,CAAA;AAE1B,IAAK,cAIJ;AAJD,WAAK,cAAc;IACjB,qDAAK,CAAA;IACL,iEAAW,CAAA;IACX,iDAAG,CAAA;AACL,CAAC,EAJI,cAAc,KAAd,cAAc,QAIlB;AAED,MAAM,OAAO,eAAgB,SAAQ,KAAK;CAAG;AAE7C;;;GAGG;AACH,MAAM,OAAgB,KAAM,SAAQ,KAAK;IAGvC,YAAY,OAAgB,E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KAAY;IACjC,IAAI,KAAK,YAAY,MAAM,CAAC,QAAQ,EAAE;QACpC,MAAM,WAAW,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAC5C,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;QAC/B,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;KACpC;SAAM;QACL,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;KAC9B;AACH,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,KAAY;IAClC,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;AAC5D,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAY;IACvC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACnB,OAAO,IAAI,CAAA;KACZ;IACD,IAAK,KAAe,CAAC,IAAI,KAAK,cAAc,CAAC,GAAG,EAAE;QAChD,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import {Message, stringifyMessage, error as outputError} from './output.js'\nimport {Errors} from '@oclif/core'\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport sourceMapSupport from 'source-map-support'\n\nexport {ExtendableError} from 'ts-error'\nexport {AbortSignal} from 'abort-controller'\n\nsourceMapSupport.install()\n\nenum FatalErrorType {\n Abort,\n AbortSilent,\n Bug,\n}\n\nexport class CancelExecution extends Error {}\n\n/**\n * A fatal error represents an error shouldn't be rescued and that causes the execution to terminate.\n * There shouldn't be code that catches fatal errors.\n */\nexport abstract class Fatal extends Error {\n tryMessage: string | null\n type: FatalErrorType\n constructor(message: Message, type: FatalErrorType, tryMessage: Message | null = null) {\n super(stringifyMessage(message))\n this.tryMessage = tryMessage ? stringifyMessage(tryMessage) : null\n this.type = type\n }\n}\n\n/**\n * An abort error is a fatal error that shouldn't be reported as a bug.\n * Those usually represent unexpected scenarios that we can't handle and that usually require some action from the developer\n */\nexport class Abort extends Fatal {\n constructor(message: Message, tryMessage: Message | null = null) {\n super(message, FatalErrorType.Abort, tryMessage)\n }\n}\n\nexport class AbortSilent extends Fatal {\n constructor() {\n super('', FatalErrorType.AbortSilent)\n }\n}\n\n/**\n * A bug error is an error that represents a bug and therefore should be reported.\n */\nexport class Bug extends Fatal {\n constructor(message: Message, tryMessage: string | null = null) {\n super(message, FatalErrorType.Bug, tryMessage)\n }\n}\n\n/**\n * A function that handles errors that blow up in the CLI.\n * @param error Error to be handled.\n * @returns A promise that resolves with the error passed.\n */\nexport async function handler(error: Error): Promise<Error> {\n let fatal: Fatal\n if (isFatal(error)) {\n fatal = error as Fatal\n } else {\n fatal = new Bug(error.message)\n }\n\n if (fatal.type === FatalErrorType.Bug) {\n fatal.stack = error.stack\n }\n\n await outputError(fatal)\n return Promise.resolve(error)\n}\n\nexport function mapper(error: Error): Promise<Error> {\n if (error instanceof Errors.CLIError) {\n const mappedError = new Abort(error.message)\n mappedError.stack = error.stack\n return Promise.resolve(mappedError)\n } else {\n return Promise.resolve(error)\n }\n}\n\nexport function isFatal(error: Error): boolean {\n return Object.prototype.hasOwnProperty.call(error, 'type')\n}\n\nexport function shouldReport(error: Error): boolean {\n if (!isFatal(error)) {\n return true\n }\n if ((error as Fatal).type === FatalErrorType.Bug) {\n return true\n }\n return false\n}\n"]}
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,gBAAgB,EAAE,KAAK,IAAI,WAAW,EAAC,MAAM,aAAa,CAAA;AAC3E,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAElC,6DAA6D;AAC7D,aAAa;AACb,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAC,eAAe,EAAC,MAAM,UAAU,CAAA;AACxC,OAAO,EAAC,WAAW,EAAC,MAAM,k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,QAAQ,EAAE;QACpC,KAAK,GAAG,IAAI,GAAG,CAAC,KAAe,CAAC,CAAA;KACjC;SAAM;QACL,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAC9B,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;KAC1B;IAED,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,CAAC,GAAG,EAAE;QACrC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;KAC1B;IAED,MAAM,WAAW,CAAC,KAAK,CAAC,CAAA;IACxB,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC/B,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,KAAY;IACjC,IAAI,KAAK,YAAY,MAAM,CAAC,QAAQ,EAAE;QACpC,MAAM,WAAW,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAC5C,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;QAC/B,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;KACpC;SAAM;QACL,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;KAC9B;AACH,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,KAAY;IAClC,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;AAC5D,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAY;IACvC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACnB,OAAO,IAAI,CAAA;KACZ;IACD,IAAK,KAAe,CAAC,IAAI,KAAK,cAAc,CAAC,GAAG,EAAE;QAChD,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import {Message, stringifyMessage, error as outputError} from './output.js'\nimport {Errors} from '@oclif/core'\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport sourceMapSupport from 'source-map-support'\n\nexport {ExtendableError} from 'ts-error'\nexport {AbortSignal} from 'abort-controller'\n\nsourceMapSupport.install()\n\nenum FatalErrorType {\n Abort,\n AbortSilent,\n Bug,\n}\n\nexport class CancelExecution extends Error {}\n\n/**\n * A fatal error represents an error shouldn't be rescued and that causes the execution to terminate.\n * There shouldn't be code that catches fatal errors.\n */\nexport abstract class Fatal extends Error {\n tryMessage: string | null\n type: FatalErrorType\n constructor(message: Message, type: FatalErrorType, tryMessage: Message | null = null) {\n super(stringifyMessage(message))\n this.tryMessage = tryMessage ? stringifyMessage(tryMessage) : null\n this.type = type\n }\n}\n\n/**\n * An abort error is a fatal error that shouldn't be reported as a bug.\n * Those usually represent unexpected scenarios that we can't handle and that usually require some action from the developer\n */\nexport class Abort extends Fatal {\n constructor(message: Message, tryMessage: Message | null = null) {\n super(message, FatalErrorType.Abort, tryMessage)\n }\n}\n\nexport class AbortSilent extends Fatal {\n constructor() {\n super('', FatalErrorType.AbortSilent)\n }\n}\n\n/**\n * A bug error is an error that represents a bug and therefore should be reported.\n */\nexport class Bug extends Fatal {\n constructor(message: Message, tryMessage: string | null = null) {\n super(message, FatalErrorType.Bug, tryMessage)\n }\n}\n\n/**\n * A function that handles errors that blow up in the CLI.\n * @param error Error to be handled.\n * @returns A promise that resolves with the error passed.\n */\nexport async function handler(error: Error): Promise<Error> {\n let fatal: Fatal\n if (isFatal(error)) {\n fatal = error as Fatal\n } else if (typeof error === 'string') {\n fatal = new Bug(error as string)\n } else {\n fatal = new Bug(error.message)\n fatal.stack = error.stack\n }\n\n if (fatal.type === FatalErrorType.Bug) {\n fatal.stack = error.stack\n }\n\n await outputError(fatal)\n return Promise.resolve(error)\n}\n\nexport function mapper(error: Error): Promise<Error> {\n if (error instanceof Errors.CLIError) {\n const mappedError = new Abort(error.message)\n mappedError.stack = error.stack\n return Promise.resolve(mappedError)\n } else {\n return Promise.resolve(error)\n }\n}\n\nexport function isFatal(error: Error): boolean {\n return Object.prototype.hasOwnProperty.call(error, 'type')\n}\n\nexport function shouldReport(error: Error): boolean {\n if (!isFatal(error)) {\n return true\n }\n if ((error as Fatal).type === FatalErrorType.Bug) {\n return true\n }\n return false\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import { Command } from '@oclif/core';
2
+ export default abstract class extends Command {
3
+ catch(error: Error & {
4
+ exitCode?: number | undefined;
5
+ }): Promise<void>;
6
+ }
@@ -0,0 +1,9 @@
1
+ import { errorHandler } from './error-handler.js';
2
+ import { Command } from '@oclif/core';
3
+ // eslint-disable-next-line import/no-anonymous-default-export
4
+ export default class extends Command {
5
+ async catch(error) {
6
+ errorHandler(error);
7
+ }
8
+ }
9
+ //# sourceMappingURL=base-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../src/node/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAC,OAAO,EAAC,MAAM,aAAa,CAAA;AAEnC,8DAA8D;AAC9D,MAAM,CAAC,OAAO,MAAgB,SAAQ,OAAO;IAC3C,KAAK,CAAC,KAAK,CAAC,KAA8C;QACxD,YAAY,CAAC,KAAK,CAAC,CAAA;IACrB,CAAC;CACF","sourcesContent":["import {errorHandler} from './error-handler.js'\nimport {Command} from '@oclif/core'\n\n// eslint-disable-next-line import/no-anonymous-default-export\nexport default abstract class extends Command {\n async catch(error: Error & {exitCode?: number | undefined}) {\n errorHandler(error)\n }\n}\n"]}
package/dist/node/cli.js CHANGED
@@ -1,13 +1,11 @@
1
1
  // CLI
2
2
  import { findUpAndReadPackageJson } from './node-package-manager.js';
3
+ import { errorHandler } from './error-handler.js';
3
4
  import { initializeCliKitStore } from '../store.js';
4
5
  import { initiateLogging } from '../output.js';
5
6
  import { isDebug } from '../environment/local.js';
6
7
  import constants, { bugsnagApiKey } from '../constants.js';
7
- import { reportEvent } from '../analytics.js';
8
- import { mapper as errorMapper, handler as errorHandler, AbortSilent, shouldReport as shouldReportError, } from '../error.js';
9
- import { moduleDirectory, normalize } from '../path.js';
10
- import StackTracey from 'stacktracey';
8
+ import { moduleDirectory } from '../path.js';
11
9
  import { run, settings, flush } from '@oclif/core';
12
10
  import Bugsnag from '@bugsnag/js';
13
11
  /**
@@ -31,22 +29,7 @@ export async function runCLI(options) {
31
29
  autoDetectErrors: false,
32
30
  });
33
31
  }
34
- run(undefined, options.moduleURL)
35
- .then(flush)
36
- .catch((error) => {
37
- if (error instanceof AbortSilent) {
38
- process.exit(1);
39
- }
40
- // eslint-disable-next-line promise/no-nesting
41
- return errorMapper(error)
42
- .then((error) => {
43
- return errorHandler(error);
44
- })
45
- .then(reportError)
46
- .then(() => {
47
- process.exit(1);
48
- });
49
- });
32
+ run(undefined, options.moduleURL).then(flush).catch(errorHandler);
50
33
  }
51
34
  /**
52
35
  * A function for create-x CLIs that automatically runs the "init" command.
@@ -64,33 +47,5 @@ export async function runCreateCLI(options) {
64
47
  }
65
48
  await runCLI(options);
66
49
  }
67
- const reportError = async (errorToReport) => {
68
- await reportEvent({ errorMessage: errorToReport.message });
69
- if (settings.debug || !shouldReportError(errorToReport))
70
- return errorToReport;
71
- let mappedError;
72
- // eslint-disable-next-line no-prototype-builtins
73
- if (Error.prototype.isPrototypeOf(errorToReport)) {
74
- mappedError = new Error(errorToReport.message);
75
- const mappedStacktrace = new StackTracey(errorToReport)
76
- .clean()
77
- .items.map((item) => {
78
- const filePath = normalize(item.file).replace('file:/', '/').replace('C:/', '');
79
- return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`;
80
- })
81
- .join('\n');
82
- mappedError.stack = `Error: ${errorToReport.message}\n${mappedStacktrace}`;
83
- }
84
- else if (typeof errorToReport === 'string') {
85
- mappedError = new Error(errorToReport);
86
- }
87
- else {
88
- mappedError = new Error('Unknown error');
89
- }
90
- await new Promise((resolve, reject) => {
91
- Bugsnag.notify(mappedError, undefined, resolve);
92
- });
93
- return mappedError;
94
- };
95
50
  export default runCLI;
96
51
  //# sourceMappingURL=cli.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/node/cli.ts"],"names":[],"mappings":"AAAA,MAAM;AACN,OAAO,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAC,qBAAqB,EAAC,MAAM,aAAa,CAAA;AACjD,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAC,OAAO,EAAC,MAAM,yBAAyB,CAAA;AAC/C,OAAO,SAAS,EAAE,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EACL,MAAM,IAAI,WAAW,EACrB,OAAO,IAAI,YAAY,EACvB,WAAW,EACX,YAAY,IAAI,iBAAiB,GAClC,MAAM,aAAa,CAAA;AACpB,OAAO,EAAC,eAAe,EAAE,SAAS,EAAC,MAAM,YAAY,CAAA;AACrD,OAAO,WAAW,MAAM,aAAa,CAAA;AACrC,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAChD,OAAO,OAAO,MAAM,aAAa,CAAA;AASjC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAsB;IACjD,MAAM,qBAAqB,EAAE,CAAA;IAC7B,eAAe,CAAC,EAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,EAAC,CAAC,CAAA;IAChD,IAAI,OAAO,EAAE,EAAE;QACb,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAA;KACtB;SAAM;QACL,OAAO,CAAC,KAAK,CAAC;YACZ,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,aAAa;YACrB,MAAM,EAAE,IAAI;YACZ,UAAU,EAAE,MAAM,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE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C,CAAA;KACvC;SAAM;QACL,WAAW,GAAG,IAAI,KAAK,CAAC,eAAe,CAAC,CAAA;KACzC;IAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACpC,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;IACjD,CAAC,CAAC,CAAA;IACF,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA;AAED,eAAe,MAAM,CAAA","sourcesContent":["// CLI\nimport {findUpAndReadPackageJson} from './node-package-manager.js'\nimport {initializeCliKitStore} from '../store.js'\nimport {initiateLogging} from '../output.js'\nimport {isDebug} from '../environment/local.js'\nimport constants, {bugsnagApiKey} from '../constants.js'\nimport {reportEvent} from '../analytics.js'\nimport {\n mapper as errorMapper,\n handler as errorHandler,\n AbortSilent,\n shouldReport as shouldReportError,\n} from '../error.js'\nimport {moduleDirectory, normalize} from '../path.js'\nimport StackTracey from 'stacktracey'\nimport {run, settings, flush} from '@oclif/core'\nimport Bugsnag from '@bugsnag/js'\n\ninterface RunCLIOptions {\n /** The value of import.meta.url of the CLI executable module */\n moduleURL: string\n /** The logs file name */\n logFilename: string\n}\n\n/**\n * A function that abstracts away setting up the environment and running\n * a CLI\n * @param module {RunCLIOptions} Options.\n */\nexport async function runCLI(options: RunCLIOptions) {\n await initializeCliKitStore()\n initiateLogging({filename: options.logFilename})\n if (isDebug()) {\n settings.debug = true\n } else {\n Bugsnag.start({\n appType: 'node',\n apiKey: bugsnagApiKey,\n logger: null,\n appVersion: await constants.versions.cliKit(),\n autoTrackSessions: false,\n autoDetectErrors: false,\n })\n }\n\n run(undefined, options.moduleURL)\n .then(flush)\n .catch((error: Error): Promise<void | Error> => {\n if (error instanceof AbortSilent) {\n process.exit(1)\n }\n // eslint-disable-next-line promise/no-nesting\n return errorMapper(error)\n .then((error: Error) => {\n return errorHandler(error)\n })\n .then(reportError)\n .then(() => {\n process.exit(1)\n })\n })\n}\n\n/**\n * A function for create-x CLIs that automatically runs the \"init\" command.\n * @param options\n */\nexport async function runCreateCLI(options: RunCLIOptions) {\n const packageJson = await findUpAndReadPackageJson(moduleDirectory(options.moduleURL))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const packageName = (packageJson.content as any).name as string\n const name = packageName.replace('@shopify/create-', '')\n const initIndex = process.argv.findIndex((arg) => arg.includes('init'))\n if (initIndex === -1) {\n const initIndex =\n process.argv.findIndex((arg) => arg.match(new RegExp(`bin(\\\\/|\\\\\\\\)+(create-${name}|dev|run)`))) + 1\n process.argv.splice(initIndex, 0, 'init')\n }\n await runCLI(options)\n}\n\nconst reportError = async (errorToReport: Error): Promise<Error> => {\n await reportEvent({errorMessage: errorToReport.message})\n if (settings.debug || !shouldReportError(errorToReport)) return errorToReport\n\n let mappedError: Error\n\n // eslint-disable-next-line no-prototype-builtins\n if (Error.prototype.isPrototypeOf(errorToReport)) {\n mappedError = new Error(errorToReport.message)\n const mappedStacktrace = new StackTracey(errorToReport)\n .clean()\n .items.map((item) => {\n const filePath = normalize(item.file).replace('file:/', '/').replace('C:/', '')\n return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`\n })\n .join('\\n')\n mappedError.stack = `Error: ${errorToReport.message}\\n${mappedStacktrace}`\n } else if (typeof errorToReport === 'string') {\n mappedError = new Error(errorToReport)\n } else {\n mappedError = new Error('Unknown error')\n }\n\n await new Promise((resolve, reject) => {\n Bugsnag.notify(mappedError, undefined, resolve)\n })\n return mappedError\n}\n\nexport default runCLI\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/node/cli.ts"],"names":[],"mappings":"AAAA,MAAM;AACN,OAAO,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAC,qBAAqB,EAAC,MAAM,aAAa,CAAA;AACjD,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAA;AAC5C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O,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;IACvE,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE;QACpB,MAAM,SAAS,GACb,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,yBAAyB,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;QACtG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,EAAE,MAAM,CAAC,CAAA;KAC1C;IACD,MAAM,MAAM,CAAC,OAAO,CAAC,CAAA;AACvB,CAAC;AAED,eAAe,MAAM,CAAA","sourcesContent":["// CLI\nimport {findUpAndReadPackageJson} from './node-package-manager.js'\nimport {errorHandler} from './error-handler.js'\nimport {initializeCliKitStore} from '../store.js'\nimport {initiateLogging} from '../output.js'\nimport {isDebug} from '../environment/local.js'\nimport constants, {bugsnagApiKey} from '../constants.js'\nimport {moduleDirectory} from '../path.js'\nimport {run, settings, flush} from '@oclif/core'\nimport Bugsnag from '@bugsnag/js'\n\ninterface RunCLIOptions {\n /** The value of import.meta.url of the CLI executable module */\n moduleURL: string\n /** The logs file name */\n logFilename: string\n}\n\n/**\n * A function that abstracts away setting up the environment and running\n * a CLI\n * @param module {RunCLIOptions} Options.\n */\nexport async function runCLI(options: RunCLIOptions) {\n await initializeCliKitStore()\n initiateLogging({filename: options.logFilename})\n if (isDebug()) {\n settings.debug = true\n } else {\n Bugsnag.start({\n appType: 'node',\n apiKey: bugsnagApiKey,\n logger: null,\n appVersion: await constants.versions.cliKit(),\n autoTrackSessions: false,\n autoDetectErrors: false,\n })\n }\n\n run(undefined, options.moduleURL).then(flush).catch(errorHandler)\n}\n\n/**\n * A function for create-x CLIs that automatically runs the \"init\" command.\n * @param options\n */\nexport async function runCreateCLI(options: RunCLIOptions) {\n const packageJson = await findUpAndReadPackageJson(moduleDirectory(options.moduleURL))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const packageName = (packageJson.content as any).name as string\n const name = packageName.replace('@shopify/create-', '')\n const initIndex = process.argv.findIndex((arg) => arg.includes('init'))\n if (initIndex === -1) {\n const initIndex =\n process.argv.findIndex((arg) => arg.match(new RegExp(`bin(\\\\/|\\\\\\\\)+(create-${name}|dev|run)`))) + 1\n process.argv.splice(initIndex, 0, 'init')\n }\n await runCLI(options)\n}\n\nexport default runCLI\n"]}
@@ -0,0 +1,3 @@
1
+ export declare function errorHandler(error: Error & {
2
+ exitCode?: number | undefined;
3
+ }): Promise<never> | undefined;
@@ -0,0 +1,79 @@
1
+ import { AbortSilent, CancelExecution, mapper as errorMapper, shouldReport as shouldReportError, handler, } from '../error.js';
2
+ import { info } from '../output.js';
3
+ import { reportEvent } from '../analytics.js';
4
+ import { normalize } from '../path.js';
5
+ import { settings } from '@oclif/core';
6
+ import StackTracey from 'stacktracey';
7
+ import Bugsnag from '@bugsnag/js';
8
+ export function errorHandler(error) {
9
+ if (error instanceof CancelExecution) {
10
+ if (error.message && error.message !== '') {
11
+ info(`✨ ${error.message}`);
12
+ }
13
+ }
14
+ else if (error instanceof AbortSilent) {
15
+ process.exit(1);
16
+ }
17
+ else {
18
+ return errorMapper(error)
19
+ .then((error) => {
20
+ return handler(error);
21
+ })
22
+ .then(reportError)
23
+ .then(() => {
24
+ process.exit(1);
25
+ });
26
+ }
27
+ }
28
+ const reportError = async (error) => {
29
+ await reportEvent({ errorMessage: error.message });
30
+ if (settings.debug || !shouldReportError(error))
31
+ return error;
32
+ let reportableError;
33
+ let stacktrace;
34
+ let report = false;
35
+ // eslint-disable-next-line no-prototype-builtins
36
+ if (Error.prototype.isPrototypeOf(error)) {
37
+ report = true;
38
+ reportableError = new Error(error.message);
39
+ stacktrace = error.stack;
40
+ /**
41
+ * Some errors that reach this point have an empty string. For example:
42
+ * https://app.bugsnag.com/shopify/cli/errors/62cd5d31fd5040000814086c?filters[event.since]=30d&filters[error.status]=new&filters[release.seen_in]=3.1.0
43
+ *
44
+ * Because at this point we have neither the error message nor a stack trace reporting them
45
+ * to Bugsnag is pointless and adds noise.
46
+ */
47
+ }
48
+ else if (typeof error === 'string' && error.trim().length !== 0) {
49
+ report = true;
50
+ reportableError = new Error(error);
51
+ stacktrace = reportableError.stack;
52
+ }
53
+ else {
54
+ report = false;
55
+ reportableError = new Error('Unknown error');
56
+ }
57
+ const formattedStacktrace = new StackTracey(stacktrace ?? '')
58
+ .clean()
59
+ .items.map((item) => {
60
+ const filePath = normalize(item.file).replace('file:/', '/').replace('C:/', '');
61
+ return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`;
62
+ })
63
+ .join('\n');
64
+ reportableError.stack = `Error: ${reportableError.message}\n${formattedStacktrace}`;
65
+ if (report) {
66
+ await new Promise((resolve, reject) => {
67
+ Bugsnag.notify(reportableError, undefined, (error, event) => {
68
+ if (error) {
69
+ reject(error);
70
+ }
71
+ else {
72
+ resolve(reportableError);
73
+ }
74
+ });
75
+ });
76
+ }
77
+ return reportableError;
78
+ };
79
+ //# sourceMappingURL=error-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/node/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,eAAe,EACf,MAAM,IAAI,WAAW,EACrB,YAAY,IAAI,iBAAiB,EACjC,OAAO,GACR,MAAM,aAAa,CAAA;AACpB,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAC,SAAS,EAAC,MAAM,YAAY,CAAA;AACpC,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAA;AACpC,OAAO,WAAW,MAAM,aAAa,CAAA;AACrC,OAAO,OAAO,MAAM,aAAa,CAAA;AAEjC,MAAM,U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n handler,\n} from '../error.js'\nimport {info} from '../output.js'\nimport {reportEvent} from '../analytics.js'\nimport {normalize} from '../path.js'\nimport {settings} from '@oclif/core'\nimport StackTracey from 'stacktracey'\nimport Bugsnag from '@bugsnag/js'\n\nexport function errorHandler(error: Error & {exitCode?: number | undefined}) {\n if (error instanceof CancelExecution) {\n if (error.message && error.message !== '') {\n info(`✨ ${error.message}`)\n }\n } else if (error instanceof AbortSilent) {\n process.exit(1)\n } else {\n return errorMapper(error)\n .then((error: Error) => {\n return handler(error)\n })\n .then(reportError)\n .then(() => {\n process.exit(1)\n })\n }\n}\n\nconst reportError = async (error: Error): Promise<Error> => {\n await reportEvent({errorMessage: error.message})\n if (settings.debug || !shouldReportError(error)) return error\n\n let reportableError: Error\n let stacktrace: string | undefined\n let report = false\n\n // eslint-disable-next-line no-prototype-builtins\n if (Error.prototype.isPrototypeOf(error)) {\n report = true\n reportableError = new Error(error.message)\n stacktrace = error.stack\n\n /**\n * Some errors that reach this point have an empty string. For example:\n * https://app.bugsnag.com/shopify/cli/errors/62cd5d31fd5040000814086c?filters[event.since]=30d&filters[error.status]=new&filters[release.seen_in]=3.1.0\n *\n * Because at this point we have neither the error message nor a stack trace reporting them\n * to Bugsnag is pointless and adds noise.\n */\n } else if (typeof error === 'string' && (error as string).trim().length !== 0) {\n report = true\n reportableError = new Error(error)\n stacktrace = reportableError.stack\n } else {\n report = false\n reportableError = new Error('Unknown error')\n }\n\n const formattedStacktrace = new StackTracey(stacktrace ?? '')\n .clean()\n .items.map((item) => {\n const filePath = normalize(item.file).replace('file:/', '/').replace('C:/', '')\n return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`\n })\n .join('\\n')\n reportableError.stack = `Error: ${reportableError.message}\\n${formattedStacktrace}`\n\n if (report) {\n await new Promise((resolve, reject) => {\n Bugsnag.notify(reportableError, undefined, (error, event) => {\n if (error) {\n reject(error)\n } else {\n resolve(reportableError)\n }\n })\n })\n }\n return reportableError\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { Hook } from '@oclif/core';
2
+ export declare const hookPost: Hook.Postrun;
@@ -0,0 +1,6 @@
1
+ import { reportEvent } from '../../analytics.js';
2
+ // This hook is called after each successful command run. More info: https://oclif.io/docs/hooks
3
+ export const hookPost = async (_options) => {
4
+ await reportEvent();
5
+ };
6
+ //# sourceMappingURL=postrun.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postrun.js","sourceRoot":"","sources":["../../../src/node/hooks/postrun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAA;AAG9C,gGAAgG;AAChG,MAAM,CAAC,MAAM,QAAQ,GAAiB,KAAK,EAAE,QAAQ,EAAE,EAAE;IACvD,MAAM,WAAW,EAAE,CAAA;AACrB,CAAC,CAAA","sourcesContent":["import {reportEvent} from '../../analytics.js'\nimport {Hook} from '@oclif/core'\n\n// This hook is called after each successful command run. More info: https://oclif.io/docs/hooks\nexport const hookPost: Hook.Postrun = async (_options) => {\n await reportEvent()\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { Hook } from '@oclif/core';
2
+ export declare const hook: Hook.Prerun;
@@ -0,0 +1,9 @@
1
+ import { start } from '../../analytics.js';
2
+ // This hook is called before each command run. More info: https://oclif.io/docs/hooks
3
+ export const hook = async (options) => {
4
+ const cmd = options.Command.aliases.length === 0 ? options.Command.id : options.Command.aliases[0];
5
+ const command = cmd.replace(/:/g, ' ');
6
+ const args = options.argv;
7
+ start({ command, args });
8
+ };
9
+ //# sourceMappingURL=prerun.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prerun.js","sourceRoot":"","sources":["../../../src/node/hooks/prerun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAA;AAGxC,sFAAsF;AACtF,MAAM,CAAC,MAAM,IAAI,GAAgB,KAAK,EAAE,OAAO,EAAE,EAAE;IACjD,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAClG,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IACtC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;IACzB,KAAK,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC,CAAA;AACxB,CAAC,CAAA","sourcesContent":["import {start} from '../../analytics.js'\nimport {Hook} from '@oclif/core'\n\n// This hook is called before each command run. More info: https://oclif.io/docs/hooks\nexport const hook: Hook.Prerun = async (options) => {\n const cmd = options.Command.aliases.length === 0 ? options.Command.id : options.Command.aliases[0]\n const command = cmd.replace(/:/g, ' ')\n const args = options.argv\n start({command, args})\n}\n"]}