@shopify/cli-kit 3.3.1 → 3.4.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/api/admin.js +20 -34
  3. package/dist/api/admin.js.map +1 -1
  4. package/dist/api/common.d.ts +11 -1
  5. package/dist/api/common.js +50 -4
  6. package/dist/api/common.js.map +1 -1
  7. package/dist/api/identity.js +3 -3
  8. package/dist/api/identity.js.map +1 -1
  9. package/dist/api/partners.d.ts +0 -5
  10. package/dist/api/partners.js +22 -42
  11. package/dist/api/partners.js.map +1 -1
  12. package/dist/constants.d.ts +1 -0
  13. package/dist/constants.js +1 -0
  14. package/dist/constants.js.map +1 -1
  15. package/dist/environment/local.d.ts +1 -0
  16. package/dist/environment/local.js +3 -0
  17. package/dist/environment/local.js.map +1 -1
  18. package/dist/environment/service.d.ts +2 -1
  19. package/dist/environment/service.js +16 -0
  20. package/dist/environment/service.js.map +1 -1
  21. package/dist/error.d.ts +5 -0
  22. package/dist/error.js +10 -4
  23. package/dist/error.js.map +1 -1
  24. package/dist/file.d.ts +2 -0
  25. package/dist/file.js +13 -1
  26. package/dist/file.js.map +1 -1
  27. package/dist/git.js +12 -4
  28. package/dist/git.js.map +1 -1
  29. package/dist/http/fetch.d.ts +9 -2
  30. package/dist/http/fetch.js +11 -2
  31. package/dist/http/fetch.js.map +1 -1
  32. package/dist/http/graphql.d.ts +15 -0
  33. package/dist/http/graphql.js +12 -0
  34. package/dist/http/graphql.js.map +1 -0
  35. package/dist/http.d.ts +24 -0
  36. package/dist/http.js +27 -0
  37. package/dist/http.js.map +1 -1
  38. package/dist/network/service.d.ts +1 -1
  39. package/dist/network/service.js.map +1 -1
  40. package/dist/node/base-command.d.ts +1 -0
  41. package/dist/node/base-command.js +10 -1
  42. package/dist/node/base-command.js.map +1 -1
  43. package/dist/node/cli.d.ts +0 -2
  44. package/dist/node/cli.js +0 -4
  45. package/dist/node/cli.js.map +1 -1
  46. package/dist/node/error-handler.d.ts +20 -0
  47. package/dist/node/error-handler.js +40 -3
  48. package/dist/node/error-handler.js.map +1 -1
  49. package/dist/node/hooks/init.d.ts +2 -0
  50. package/dist/node/hooks/init.js +7 -0
  51. package/dist/node/hooks/init.js.map +1 -0
  52. package/dist/node/hooks/postrun.js +4 -1
  53. package/dist/node/hooks/postrun.js.map +1 -1
  54. package/dist/node/hooks/prerun.js +2 -0
  55. package/dist/node/hooks/prerun.js.map +1 -1
  56. package/dist/node/ruby.d.ts +7 -2
  57. package/dist/node/ruby.js +24 -12
  58. package/dist/node/ruby.js.map +1 -1
  59. package/dist/output.d.ts +18 -11
  60. package/dist/output.js +96 -26
  61. package/dist/output.js.map +1 -1
  62. package/dist/session/exchange.js +2 -2
  63. package/dist/session/exchange.js.map +1 -1
  64. package/dist/session/validate.js +3 -0
  65. package/dist/session/validate.js.map +1 -1
  66. package/dist/session.js +7 -1
  67. package/dist/session.js.map +1 -1
  68. package/dist/string.js +3 -1
  69. package/dist/string.js.map +1 -1
  70. package/dist/system.d.ts +4 -3
  71. package/dist/system.js +5 -2
  72. package/dist/system.js.map +1 -1
  73. package/dist/tsconfig.tsbuildinfo +1 -1
  74. package/dist/ui.d.ts +11 -0
  75. package/dist/ui.js +35 -5
  76. package/dist/ui.js.map +1 -1
  77. package/package.json +2 -1
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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E;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"]}
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,SAAS,EAAC,MAAM,WAAW,CAAA;AACnC,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAElC,OAAO,EAAC,eAAe,EAAC,MAAM,UAAU,CAAA;AACxC,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAA;AAE5C,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,EAAE,IAAoB,EAAE,aAA6B,IAAI;QACnF,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAA;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QAClE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,KAAM,SAAQ,KAAK;IAC9B,YAAY,OAAgB,EAAE,aAA6B,IAAI;QAC7D,KAAK,CAAC,OAAO,EAAE,cAAc,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;IAClD,CAAC;CACF;AAED,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC;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;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;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAAgB;IACxD,OAAO,SAAS,CAAC,QAAQ,CAAC;SACvB,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAA;AAC9B,CAAC","sourcesContent":["import {Message, stringifyMessage, error as outputError} from './output.js'\nimport {normalize} from './path.js'\nimport {Errors} from '@oclif/core'\n\nexport {ExtendableError} from 'ts-error'\nexport {AbortSignal} from 'abort-controller'\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\n/**\n * Stack traces usually have file:// - we strip that and also remove the Windows drive designation\n *\n */\nexport function cleanSingleStackTracePath(filePath: string): string {\n return normalize(filePath)\n .replace('file:/', '/')\n .replace(/^\\/?[A-Z]:/, '')\n}\n"]}
package/dist/file.d.ts CHANGED
@@ -19,10 +19,12 @@ export declare function readSync(path: string, options?: object): string;
19
19
  */
20
20
  export declare function copy(from: string, to: string): Promise<void>;
21
21
  export declare function touch(path: string): Promise<void>;
22
+ export declare function appendFile(path: string, content: string): Promise<void>;
22
23
  export declare function touchSync(path: string): Promise<void>;
23
24
  export declare function write(path: string, data: string): Promise<void>;
24
25
  export declare function writeSync(path: string, data: string): void;
25
26
  export declare function append(path: string, data: string): Promise<void>;
27
+ export declare function appendSync(path: string, data: string): void;
26
28
  export declare function mkdir(path: string): Promise<void>;
27
29
  export declare function mkdirSync(path: string): void;
28
30
  export declare function remove(path: string): Promise<void>;
package/dist/file.js CHANGED
@@ -50,6 +50,15 @@ export async function touch(path) {
50
50
  debug(outputContent `Creating an empty file at ${token.path(path)}...`);
51
51
  await fs.ensureFile(path);
52
52
  }
53
+ export async function appendFile(path, content) {
54
+ debug(outputContent `Appending the following content to ${token.path(path)}:
55
+ ${content
56
+ .split('\n')
57
+ .map((line) => ` ${line}`)
58
+ .join('\n')}
59
+ `);
60
+ await fs.appendFile(path, content);
61
+ }
53
62
  export async function touchSync(path) {
54
63
  debug(outputContent `Creating an empty file at ${token.path(path)}...`);
55
64
  await fs.ensureFileSync(path);
@@ -65,12 +74,15 @@ export function writeSync(path, data) {
65
74
  export async function append(path, data) {
66
75
  await fs.appendFile(path, data);
67
76
  }
77
+ export function appendSync(path, data) {
78
+ fs.appendFileSync(path, data);
79
+ }
68
80
  export async function mkdir(path) {
69
81
  debug(outputContent `Creating directory at ${token.path(path)}...`);
70
82
  await fs.mkdirp(path);
71
83
  }
72
84
  export function mkdirSync(path) {
73
- debug(outputContent `Sync-reating directory at ${token.path(path)}...`);
85
+ debug(outputContent `Sync-creating directory at ${token.path(path)}...`);
74
86
  fs.mkdirpSync(path);
75
87
  }
76
88
  export async function remove(path) {
package/dist/file.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"file.js","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,aAAa,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAC,sBAAsB,EAAC,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAC,MAAM,OAAO,CAAA;AACxC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAG/B,MAAM,uBA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AM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAe,EAAE,OAAuB;IACnE,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACjC,MAAM,cAAc,GAAY;QAC9B,GAAG,uBAAuB;QAC1B,MAAM,EAAE,OAAO;KAChB,CAAA;IAED,QAAQ,GAAG,EAAE;QACX,KAAK,OAAO,CAAC;QACb,KAAK,MAAM;YACT,cAAc,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;YACpC,MAAK;KACR;IAED,MAAM,gBAAgB,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAAA;IAEvE,OAAO,gBAAgB,CAAA;AACzB,CAAC","sourcesContent":["import {content as outputContent, token, debug} from './output.js'\nimport fs from 'fs-extra'\nimport del from 'del'\nimport {temporaryDirectoryTask} from 'tempy'\nimport {sep, join, extname} from 'pathe'\nimport prettier from 'prettier'\nimport type {Options} from 'prettier'\n\nconst DEFAULT_PRETTIER_CONFIG: Options = {\n arrowParens: 'always',\n singleQuote: true,\n bracketSpacing: false,\n trailingComma: 'all',\n}\n\nexport function stripUp(path: string, strip: number) {\n const parts = path.split(sep)\n return join(...parts.slice(strip))\n}\n\n/**\n * Creates a temporary directory and ties its lifecycle ot the lifecycle of the callback.\n * @param callback - The callback that receives the temporary directory.\n */\nexport async function inTemporaryDirectory<T>(callback: (tmpDir: string) => T | Promise<T>): Promise<T> {\n return temporaryDirectoryTask(callback)\n}\n\n/**\n * It reads a file and returns its content as a string using the\n * utf-8 encoding\n * @param path {string} Path to the file to read.\n * @returns {Promise<string>} A promise that resolves with the content of the file.\n */\nexport async function read(path: string, options: object = {encoding: 'utf-8'}): Promise<string> {\n debug(outputContent`Reading the content of file at ${token.path(path)}...`)\n const content = await fs.readFile(path, options)\n return content\n}\n\nexport function readSync(path: string, options: object = {encoding: 'utf-8'}): string {\n debug(outputContent`Sync-reading the content of file at ${token.path(path)}...`)\n const content = fs.readFileSync(path, options)\n return content.toString()\n}\n\n/**\n * Copies a file\n * @param from {string} Path to the directory or file to be copied.\n * @param to {string} Destination path.\n */\nexport async function copy(from: string, to: string): Promise<void> {\n debug(outputContent`Copying file from ${token.path(from)} to ${token.path(to)}...`)\n await fs.copy(from, to)\n}\n\nexport async function touch(path: string): Promise<void> {\n debug(outputContent`Creating an empty file at ${token.path(path)}...`)\n await fs.ensureFile(path)\n}\n\nexport async function touchSync(path: string): Promise<void> {\n debug(outputContent`Creating an empty file at ${token.path(path)}...`)\n await fs.ensureFileSync(path)\n}\n\nexport async function write(path: string, data: string): Promise<void> {\n debug(outputContent`Writing some content to file at ${token.path(path)}...`)\n await fs.writeFile(path, data)\n}\n\nexport function writeSync(path: string, data: string): void {\n debug(outputContent`File-writing some content to file at ${token.path(path)}...`)\n fs.writeFileSync(path, data)\n}\n\nexport async function append(path: string, data: string): Promise<void> {\n await fs.appendFile(path, data)\n}\n\nexport async function mkdir(path: string): Promise<void> {\n debug(outputContent`Creating directory at ${token.path(path)}...`)\n await fs.mkdirp(path)\n}\n\nexport function mkdirSync(path: string): void {\n debug(outputContent`Sync-reating directory at ${token.path(path)}...`)\n fs.mkdirpSync(path)\n}\n\nexport async function remove(path: string): Promise<void> {\n debug(outputContent`Removing file at ${token.path(path)}...`)\n await fs.remove(path)\n}\n\nexport async function rmdir(path: string, {force}: {force?: boolean} = {}): Promise<void> {\n debug(outputContent`Removing directory at ${token.path(path)}...`)\n await del(path, {force})\n}\n\nexport async function mkTmpDir(): Promise<string> {\n debug(outputContent`Creating a temporary directory...`)\n const directory = await fs.mkdtemp('tmp-')\n return directory\n}\n\nexport async function isDirectory(path: string): Promise<boolean> {\n debug(outputContent`Checking if ${token.path(path)} is a directory...`)\n return (await fs.promises.lstat(path)).isDirectory()\n}\n\nexport async function size(path: string): Promise<number> {\n debug(outputContent`Getting the size of file file at ${token.path(path)}...`)\n return (await fs.stat(path)).size\n}\n\nexport function sizeSync(path: string): number {\n debug(outputContent`Sync-getting the size of file file at ${token.path(path)}...`)\n return fs.statSync(path).size\n}\n\n/**\n * Moves a file.\n * @param src {string} File to be moved.\n * @param dest {string} Path to be moved to.\n * @param options {object} Moving options.\n */\nexport async function move(src: string, dest: string, options: {overwrite?: boolean} = {}): Promise<void> {\n await fs.move(src, dest, options)\n}\n\n/**\n * Changes the permissions of a directory or file.\n * @param path {string} Path to the file or directory whose permissions will be modified.\n * @param mode {string | numbers} Permissions to set to the file or directory.\n */\nexport async function chmod(path: string, mode: number | string): Promise<void> {\n await fs.promises.chmod(path, mode)\n}\n\n/**\n * Checks if a file has executable permissions.\n * @param path {string} Path to the file whose permissions will be checked.\n */\nexport async function hasExecutablePermissions(path: string): Promise<boolean> {\n try {\n await fs.promises.access(path, fs.constants.X_OK)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Returns true if a file or directory exists\n * @param path {string} Path to the directory or file.\n * @returns {boolean} True if it exists.\n */\nexport async function exists(path: string): Promise<boolean> {\n try {\n await fs.promises.access(path)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Format a string using prettier. Return the formatted content.\n */\nexport async function format(content: string, options: {path: string}) {\n const ext = extname(options.path)\n const prettierConfig: Options = {\n ...DEFAULT_PRETTIER_CONFIG,\n parser: 'babel',\n }\n\n switch (ext) {\n case '.html':\n case '.css':\n prettierConfig.parser = ext.slice(1)\n break\n }\n\n const formattedContent = await prettier.format(content, prettierConfig)\n\n return formattedContent\n}\n"]}
1
+ {"version":3,"file":"file.js","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,aAAa,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,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zB,CAAC","sourcesContent":["import {content as outputContent, token, debug} from './output.js'\nimport fs from 'fs-extra'\nimport del from 'del'\nimport {temporaryDirectoryTask} from 'tempy'\nimport {sep, join, extname} from 'pathe'\nimport prettier from 'prettier'\nimport type {Options} from 'prettier'\n\nconst DEFAULT_PRETTIER_CONFIG: Options = {\n arrowParens: 'always',\n singleQuote: true,\n bracketSpacing: false,\n trailingComma: 'all',\n}\n\nexport function stripUp(path: string, strip: number) {\n const parts = path.split(sep)\n return join(...parts.slice(strip))\n}\n\n/**\n * Creates a temporary directory and ties its lifecycle ot the lifecycle of the callback.\n * @param callback - The callback that receives the temporary directory.\n */\nexport async function inTemporaryDirectory<T>(callback: (tmpDir: string) => T | Promise<T>): Promise<T> {\n return temporaryDirectoryTask(callback)\n}\n\n/**\n * It reads a file and returns its content as a string using the\n * utf-8 encoding\n * @param path {string} Path to the file to read.\n * @returns {Promise<string>} A promise that resolves with the content of the file.\n */\nexport async function read(path: string, options: object = {encoding: 'utf-8'}): Promise<string> {\n debug(outputContent`Reading the content of file at ${token.path(path)}...`)\n const content = await fs.readFile(path, options)\n return content\n}\n\nexport function readSync(path: string, options: object = {encoding: 'utf-8'}): string {\n debug(outputContent`Sync-reading the content of file at ${token.path(path)}...`)\n const content = fs.readFileSync(path, options)\n return content.toString()\n}\n\n/**\n * Copies a file\n * @param from {string} Path to the directory or file to be copied.\n * @param to {string} Destination path.\n */\nexport async function copy(from: string, to: string): Promise<void> {\n debug(outputContent`Copying file from ${token.path(from)} to ${token.path(to)}...`)\n await fs.copy(from, to)\n}\n\nexport async function touch(path: string): Promise<void> {\n debug(outputContent`Creating an empty file at ${token.path(path)}...`)\n await fs.ensureFile(path)\n}\n\nexport async function appendFile(path: string, content: string): Promise<void> {\n debug(outputContent`Appending the following content to ${token.path(path)}:\n ${content\n .split('\\n')\n .map((line) => ` ${line}`)\n .join('\\n')}\n `)\n await fs.appendFile(path, content)\n}\n\nexport async function touchSync(path: string): Promise<void> {\n debug(outputContent`Creating an empty file at ${token.path(path)}...`)\n await fs.ensureFileSync(path)\n}\n\nexport async function write(path: string, data: string): Promise<void> {\n debug(outputContent`Writing some content to file at ${token.path(path)}...`)\n await fs.writeFile(path, data)\n}\n\nexport function writeSync(path: string, data: string): void {\n debug(outputContent`File-writing some content to file at ${token.path(path)}...`)\n fs.writeFileSync(path, data)\n}\n\nexport async function append(path: string, data: string): Promise<void> {\n await fs.appendFile(path, data)\n}\n\nexport function appendSync(path: string, data: string): void {\n fs.appendFileSync(path, data)\n}\n\nexport async function mkdir(path: string): Promise<void> {\n debug(outputContent`Creating directory at ${token.path(path)}...`)\n await fs.mkdirp(path)\n}\n\nexport function mkdirSync(path: string): void {\n debug(outputContent`Sync-creating directory at ${token.path(path)}...`)\n fs.mkdirpSync(path)\n}\n\nexport async function remove(path: string): Promise<void> {\n debug(outputContent`Removing file at ${token.path(path)}...`)\n await fs.remove(path)\n}\n\nexport async function rmdir(path: string, {force}: {force?: boolean} = {}): Promise<void> {\n debug(outputContent`Removing directory at ${token.path(path)}...`)\n await del(path, {force})\n}\n\nexport async function mkTmpDir(): Promise<string> {\n debug(outputContent`Creating a temporary directory...`)\n const directory = await fs.mkdtemp('tmp-')\n return directory\n}\n\nexport async function isDirectory(path: string): Promise<boolean> {\n debug(outputContent`Checking if ${token.path(path)} is a directory...`)\n return (await fs.promises.lstat(path)).isDirectory()\n}\n\nexport async function size(path: string): Promise<number> {\n debug(outputContent`Getting the size of file file at ${token.path(path)}...`)\n return (await fs.stat(path)).size\n}\n\nexport function sizeSync(path: string): number {\n debug(outputContent`Sync-getting the size of file file at ${token.path(path)}...`)\n return fs.statSync(path).size\n}\n\n/**\n * Moves a file.\n * @param src {string} File to be moved.\n * @param dest {string} Path to be moved to.\n * @param options {object} Moving options.\n */\nexport async function move(src: string, dest: string, options: {overwrite?: boolean} = {}): Promise<void> {\n await fs.move(src, dest, options)\n}\n\n/**\n * Changes the permissions of a directory or file.\n * @param path {string} Path to the file or directory whose permissions will be modified.\n * @param mode {string | numbers} Permissions to set to the file or directory.\n */\nexport async function chmod(path: string, mode: number | string): Promise<void> {\n await fs.promises.chmod(path, mode)\n}\n\n/**\n * Checks if a file has executable permissions.\n * @param path {string} Path to the file whose permissions will be checked.\n */\nexport async function hasExecutablePermissions(path: string): Promise<boolean> {\n try {\n await fs.promises.access(path, fs.constants.X_OK)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Returns true if a file or directory exists\n * @param path {string} Path to the directory or file.\n * @returns {boolean} True if it exists.\n */\nexport async function exists(path: string): Promise<boolean> {\n try {\n await fs.promises.access(path)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Format a string using prettier. Return the formatted content.\n */\nexport async function format(content: string, options: {path: string}) {\n const ext = extname(options.path)\n const prettierConfig: Options = {\n ...DEFAULT_PRETTIER_CONFIG,\n parser: 'babel',\n }\n\n switch (ext) {\n case '.html':\n case '.css':\n prettierConfig.parser = ext.slice(1)\n break\n }\n\n const formattedContent = await prettier.format(content, prettierConfig)\n\n return formattedContent\n}\n"]}
package/dist/git.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Abort } from './error.js';
2
- import { hasGit } from './environment/local.js';
2
+ import { hasGit, isTerminalInteractive } from './environment/local.js';
3
3
  import { content, token, debug } from './output.js';
4
4
  import git from 'simple-git';
5
5
  export const factory = git;
@@ -28,13 +28,21 @@ export async function downloadRepository({ repoUrl, destination, progressUpdater
28
28
  if (progressUpdater)
29
29
  progressUpdater(updateString);
30
30
  };
31
- await git({ progress }).clone(repository, destination, options, (err) => {
32
- if (err) {
31
+ const simpleGitOptions = {
32
+ progress,
33
+ ...(!isTerminalInteractive() && { config: ['core.askpass=true'] }),
34
+ };
35
+ try {
36
+ await git(simpleGitOptions).clone(repository, destination, options);
37
+ }
38
+ catch (err) {
39
+ if (err instanceof Error) {
33
40
  const abortError = new Abort(err.message);
34
41
  abortError.stack = err.stack;
35
42
  throw abortError;
36
43
  }
37
- });
44
+ throw err;
45
+ }
38
46
  }
39
47
  /**
40
48
  * If "git" is not present in the environment it throws
package/dist/git.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAA;AAChC,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AACjD,OAAO,GAA0C,MAAM,YAAY,CAAA;AAEnE,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAA;AAE1B,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,OAAO,IAAI,KAAK,CACd,iDAAiD,EACjD,OAAO,CAAA,WAAW,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,+DAA+D,CAAC,EAAE,CACvG,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,SAAiB;IAC1D,KAAK,CAAC,OAAO,CAAA,kCAAkC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAC1E,MAAM,oBAAoB,EAAE,CAAA;IAC5B,MAAM,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAA;AAC7B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,EACvC,OAAO,EACP,WAAW,EACX,eAAe,EACf,OAAO,GAMR;IACC,KAAK,CAAC,OAAO,CAAA,0BAA0B,OAAO,SAAS,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;IACpF,MAAM,oBAAoB,EAAE,CAAA;IAC5B,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC/C,gEAAgE;IAChE,MAAM,OAAO,GAAgB,EAAC,sBAAsB,EAAE,IAAI,EAAC,CAAA;IAC3D,IAAI,MAAM,EAAE;QACV,OAAO,CAAC,UAAU,CAAC,GAAG,MAAM,CAAA;KAC7B;IACD,IAAI,OAAO,EAAE;QACX,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;KACvB;IACD,MAAM,QAAQ,GAAG,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAyB,EAAE,EAAE;QAC/E,MAAM,YAAY,GAAG,GAAG,KAAK,KAAK,SAAS,IAAI,KAAK,aAAa,QAAQ,aAAa,CAAA;QACtF,IAAI,eAAe;YAAE,eAAe,CAAC,YAAY,CAAC,CAAA;IACpD,CAAC,CAAA;IAED,MAAM,GAAG,CAAC,EAAC,QAAQ,EAAC,CAAC,CAAC,KAAK,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;QACpE,IAAI,GAAG,EAAE;YACP,MAAM,UAAU,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YACzC,UAAU,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAA;YAC5B,MAAM,UAAU,CAAA;SACjB;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACxC,IAAI,CAAC,CAAC,MAAM,MAAM,EAAE,CAAC,EAAE;QACrB,MAAM,kBAAkB,EAAE,CAAA;KAC3B;AACH,CAAC","sourcesContent":["import {Abort} from './error.js'\nimport {hasGit} from './environment/local.js'\nimport {content, token, debug} from './output.js'\nimport git, {TaskOptions, SimpleGitProgressEvent} from 'simple-git'\n\nexport const factory = git\n\nexport const GitNotPresentError = () => {\n return new Abort(\n `Git is necessary in the environment to continue`,\n content`Install ${token.link('git', 'https://git-scm.com/book/en/v2/Getting-Started-Installing-Git')}`,\n )\n}\n\nexport async function initializeRepository(directory: string) {\n debug(content`Initializing git repository at ${token.path(directory)}...`)\n await ensurePresentOrAbort()\n await git(directory).init()\n}\n\nexport async function downloadRepository({\n repoUrl,\n destination,\n progressUpdater,\n shallow,\n}: {\n repoUrl: string\n destination: string\n progressUpdater?: (statusString: string) => void\n shallow?: boolean\n}) {\n debug(content`Git-cloning repository ${repoUrl} into ${token.path(destination)}...`)\n await ensurePresentOrAbort()\n const [repository, branch] = repoUrl.split('#')\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const options: TaskOptions = {'--recurse-submodules': null}\n if (branch) {\n options['--branch'] = branch\n }\n if (shallow) {\n options['--depth'] = 1\n }\n const progress = ({stage, progress, processed, total}: SimpleGitProgressEvent) => {\n const updateString = `${stage}, ${processed}/${total} objects (${progress}% complete)`\n if (progressUpdater) progressUpdater(updateString)\n }\n\n await git({progress}).clone(repository, destination, options, (err) => {\n if (err) {\n const abortError = new Abort(err.message)\n abortError.stack = err.stack\n throw abortError\n }\n })\n}\n\n/**\n * If \"git\" is not present in the environment it throws\n * an abort error.\n */\nexport async function ensurePresentOrAbort() {\n if (!(await hasGit())) {\n throw GitNotPresentError()\n }\n}\n"]}
1
+ {"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAA;AAChC,OAAO,EAAC,MAAM,EAAE,qBAAqB,EAAC,MAAM,wBAAwB,CAAA;AACpE,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AACjD,OAAO,GAA0C,MAAM,YAAY,CAAA;AAEnE,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAA;AAE1B,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,OAAO,IAAI,KAAK,CACd,iDAAiD,EACjD,OAAO,CAAA,WAAW,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,+DAA+D,CAAC,EAAE,CACvG,C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IACD,IAAI;QACF,MAAM,GAAG,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;KACpE;IAAC,OAAO,GAAG,EAAE;QACZ,IAAI,GAAG,YAAY,KAAK,EAAE;YACxB,MAAM,UAAU,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YACzC,UAAU,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAA;YAC5B,MAAM,UAAU,CAAA;SACjB;QACD,MAAM,GAAG,CAAA;KACV;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACxC,IAAI,CAAC,CAAC,MAAM,MAAM,EAAE,CAAC,EAAE;QACrB,MAAM,kBAAkB,EAAE,CAAA;KAC3B;AACH,CAAC","sourcesContent":["import {Abort} from './error.js'\nimport {hasGit, isTerminalInteractive} from './environment/local.js'\nimport {content, token, debug} from './output.js'\nimport git, {TaskOptions, SimpleGitProgressEvent} from 'simple-git'\n\nexport const factory = git\n\nexport const GitNotPresentError = () => {\n return new Abort(\n `Git is necessary in the environment to continue`,\n content`Install ${token.link('git', 'https://git-scm.com/book/en/v2/Getting-Started-Installing-Git')}`,\n )\n}\n\nexport async function initializeRepository(directory: string) {\n debug(content`Initializing git repository at ${token.path(directory)}...`)\n await ensurePresentOrAbort()\n await git(directory).init()\n}\n\nexport async function downloadRepository({\n repoUrl,\n destination,\n progressUpdater,\n shallow,\n}: {\n repoUrl: string\n destination: string\n progressUpdater?: (statusString: string) => void\n shallow?: boolean\n}) {\n debug(content`Git-cloning repository ${repoUrl} into ${token.path(destination)}...`)\n await ensurePresentOrAbort()\n const [repository, branch] = repoUrl.split('#')\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const options: TaskOptions = {'--recurse-submodules': null}\n if (branch) {\n options['--branch'] = branch\n }\n if (shallow) {\n options['--depth'] = 1\n }\n const progress = ({stage, progress, processed, total}: SimpleGitProgressEvent) => {\n const updateString = `${stage}, ${processed}/${total} objects (${progress}% complete)`\n if (progressUpdater) progressUpdater(updateString)\n }\n\n const simpleGitOptions = {\n progress,\n ...(!isTerminalInteractive() && {config: ['core.askpass=true']}),\n }\n try {\n await git(simpleGitOptions).clone(repository, destination, options)\n } catch (err) {\n if (err instanceof Error) {\n const abortError = new Abort(err.message)\n abortError.stack = err.stack\n throw abortError\n }\n throw err\n }\n}\n\n/**\n * If \"git\" is not present in the environment it throws\n * an abort error.\n */\nexport async function ensurePresentOrAbort() {\n if (!(await hasGit())) {\n throw GitNotPresentError()\n }\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { Service } from '../network/service.js';
1
2
  import nodeFetch from 'node-fetch';
2
3
  import type { RequestInfo, RequestInit } from 'node-fetch';
3
4
  declare type Response = ReturnType<typeof nodeFetch>;
@@ -12,5 +13,11 @@ declare type Response = ReturnType<typeof nodeFetch>;
12
13
  * @param init {RequestInit} An object containing any custom settings that you want to apply to the request
13
14
  * @returns A promise that resolves with the response.
14
15
  */
15
- declare function fetch(url: RequestInfo, init?: RequestInit): Response;
16
- export default fetch;
16
+ export default function fetch(url: RequestInfo, init?: RequestInit): Response;
17
+ /**
18
+ * A fetch function to use with Shopify services. The function ensures the right
19
+ * TLS configuragion is used based on the environment in which the service is running
20
+ * (e.g. spin)
21
+ */
22
+ export declare function shopifyFetch(service: Service, url: RequestInfo, init?: RequestInit): Response;
23
+ export {};
@@ -1,3 +1,4 @@
1
+ import { httpsAgent } from '../http.js';
1
2
  import nodeFetch from 'node-fetch';
2
3
  /**
3
4
  * An interface that abstracts way node-fetch. When Node has built-in
@@ -10,9 +11,17 @@ import nodeFetch from 'node-fetch';
10
11
  * @param init {RequestInit} An object containing any custom settings that you want to apply to the request
11
12
  * @returns A promise that resolves with the response.
12
13
  */
13
- async function fetch(url, init) {
14
+ export default async function fetch(url, init) {
14
15
  const response = await nodeFetch(url, init);
15
16
  return response;
16
17
  }
17
- export default fetch;
18
+ /**
19
+ * A fetch function to use with Shopify services. The function ensures the right
20
+ * TLS configuragion is used based on the environment in which the service is running
21
+ * (e.g. spin)
22
+ */
23
+ export async function shopifyFetch(service, url, init) {
24
+ const response = await nodeFetch(url, { ...init, agent: await httpsAgent(service) });
25
+ return response;
26
+ }
18
27
  //# sourceMappingURL=fetch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/http/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAA;AAIlC;;;;;;;;;;GAUG;AACH,KAAK,UAAU,KAAK,CAAC,GAAgB,EAAE,IAAkB;IACvD,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC3C,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,eAAe,KAAK,CAAA","sourcesContent":["import nodeFetch from 'node-fetch'\nimport type {RequestInfo, RequestInit} from 'node-fetch'\n\ntype Response = ReturnType<typeof nodeFetch>\n/**\n * An interface that abstracts way node-fetch. When Node has built-in\n * support for \"fetch\" in the standard library, we can drop the node-fetch\n * dependency from here.\n * Note that we are exposing types from \"node-fetch\". The reason being is that\n * they are consistent with the Web API so if we drop node-fetch in the future\n * it won't require changes from the callers.\n * @param url {RequestInfo} This defines the resource that you wish to fetch.\n * @param init {RequestInit} An object containing any custom settings that you want to apply to the request\n * @returns A promise that resolves with the response.\n */\nasync function fetch(url: RequestInfo, init?: RequestInit): Response {\n const response = await nodeFetch(url, init)\n return response\n}\n\nexport default fetch\n"]}
1
+ {"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/http/fetch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,SAAS,MAAM,YAAY,CAAA;AAIlC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,KAAK,CAAC,GAAgB,EAAE,IAAkB;IACtE,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC3C,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAgB,EAAE,GAAgB,EAAE,IAAkB;IACvF,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,EAAC,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC,OAAO,CAAC,EAAC,CAAC,CAAA;IAClF,OAAO,QAAQ,CAAA;AACjB,CAAC","sourcesContent":["import {Service} from '../network/service.js'\n\nimport {httpsAgent} from '../http.js'\nimport nodeFetch from 'node-fetch'\nimport type {RequestInfo, RequestInit} from 'node-fetch'\n\ntype Response = ReturnType<typeof nodeFetch>\n/**\n * An interface that abstracts way node-fetch. When Node has built-in\n * support for \"fetch\" in the standard library, we can drop the node-fetch\n * dependency from here.\n * Note that we are exposing types from \"node-fetch\". The reason being is that\n * they are consistent with the Web API so if we drop node-fetch in the future\n * it won't require changes from the callers.\n * @param url {RequestInfo} This defines the resource that you wish to fetch.\n * @param init {RequestInit} An object containing any custom settings that you want to apply to the request\n * @returns A promise that resolves with the response.\n */\nexport default async function fetch(url: RequestInfo, init?: RequestInit): Response {\n const response = await nodeFetch(url, init)\n return response\n}\n\n/**\n * A fetch function to use with Shopify services. The function ensures the right\n * TLS configuragion is used based on the environment in which the service is running\n * (e.g. spin)\n */\nexport async function shopifyFetch(service: Service, url: RequestInfo, init?: RequestInit): Response {\n const response = await nodeFetch(url, {...init, agent: await httpsAgent(service)})\n return response\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import { Service } from '../network/service.js';
2
+ import { GraphQLClient } from 'graphql-request';
3
+ interface GraphqlClientOptions {
4
+ url: string;
5
+ service: Service;
6
+ headers: {
7
+ [key: string]: string;
8
+ };
9
+ }
10
+ /**
11
+ * Creates a GraphQLClient instance with the right HTTPs agent baed on the service
12
+ * the client will interact with.
13
+ */
14
+ export declare function graphqlClient(options: GraphqlClientOptions): Promise<GraphQLClient>;
15
+ export {};
@@ -0,0 +1,12 @@
1
+ import { httpsAgent } from '../http.js';
2
+ import { GraphQLClient } from 'graphql-request';
3
+ /**
4
+ * Creates a GraphQLClient instance with the right HTTPs agent baed on the service
5
+ * the client will interact with.
6
+ */
7
+ export async function graphqlClient(options) {
8
+ const clientOptions = { agent: await httpsAgent(options.service), headers: options.headers };
9
+ const client = new GraphQLClient(options.url, clientOptions);
10
+ return client;
11
+ }
12
+ //# sourceMappingURL=graphql.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../src/http/graphql.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAQ7C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA6B;IAC/D,MAAM,aAAa,GAAG,EAAC,KAAK,EAAE,MAAM,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAC,CAAA;IAC1F,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,aAAa,CAAC,CAAA;IAC5D,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import {Service} from '../network/service.js'\nimport {httpsAgent} from '../http.js'\nimport {GraphQLClient} from 'graphql-request'\n\ninterface GraphqlClientOptions {\n url: string\n service: Service\n headers: {[key: string]: string}\n}\n\n/**\n * Creates a GraphQLClient instance with the right HTTPs agent baed on the service\n * the client will interact with.\n */\nexport async function graphqlClient(options: GraphqlClientOptions) {\n const clientOptions = {agent: await httpsAgent(options.service), headers: options.headers}\n const client = new GraphQLClient(options.url, clientOptions)\n return client\n}\n"]}
package/dist/http.d.ts CHANGED
@@ -1,2 +1,26 @@
1
+ /// <reference types="node" />
2
+ import { Service } from './network/service.js';
3
+ import https from 'https';
1
4
  export { default as fetch } from './http/fetch.js';
5
+ export { shopifyFetch } from './http/fetch.js';
2
6
  export { default as formData } from './http/formdata.js';
7
+ /**
8
+ * This utility function returns the https.Agent to use for a given service. The agent
9
+ * includes the right configuration based on the service's environment. For example,
10
+ * if the service is running in a Spin environment, the attribute "rejectUnauthorized" is
11
+ * set to false
12
+ */
13
+ export declare function httpsAgent(service: Service): Promise<https.Agent>;
14
+ /**
15
+ * Spin stores the CA certificate in the keychain and it should be used when sending HTTP
16
+ * requests to Spin instances. However, Node doesn't read certificates from the Keychain
17
+ * by default, which leads to Shopifolks running into issues that they workaround by setting the
18
+ * NODE_TLS_REJECT_UNAUTHORIZED=0 environment variable, which applies to all the HTTP
19
+ * requests sent from the CLI (context: https://github.com/nodejs/node/issues/39657)
20
+ * This utility function allows controlling the behavior in a per-service level by returning
21
+ * the value of for the "rejectUnauthorized" attribute that's used in the https agent.
22
+ *
23
+ * @returns {Promise<boolean>} A promise that resolves with a boolean indicating whether
24
+ * unauthorized requests should be rejected or not.
25
+ */
26
+ export declare function shouldRejectUnauthorizedRequests(service: Service): Promise<boolean>;
package/dist/http.js CHANGED
@@ -1,3 +1,30 @@
1
+ import { environmentForService } from './environment/service.js';
2
+ import https from 'https';
1
3
  export { default as fetch } from './http/fetch.js';
4
+ export { shopifyFetch } from './http/fetch.js';
2
5
  export { default as formData } from './http/formdata.js';
6
+ /**
7
+ * This utility function returns the https.Agent to use for a given service. The agent
8
+ * includes the right configuration based on the service's environment. For example,
9
+ * if the service is running in a Spin environment, the attribute "rejectUnauthorized" is
10
+ * set to false
11
+ */
12
+ export async function httpsAgent(service) {
13
+ return new https.Agent({ rejectUnauthorized: await shouldRejectUnauthorizedRequests(service) });
14
+ }
15
+ /**
16
+ * Spin stores the CA certificate in the keychain and it should be used when sending HTTP
17
+ * requests to Spin instances. However, Node doesn't read certificates from the Keychain
18
+ * by default, which leads to Shopifolks running into issues that they workaround by setting the
19
+ * NODE_TLS_REJECT_UNAUTHORIZED=0 environment variable, which applies to all the HTTP
20
+ * requests sent from the CLI (context: https://github.com/nodejs/node/issues/39657)
21
+ * This utility function allows controlling the behavior in a per-service level by returning
22
+ * the value of for the "rejectUnauthorized" attribute that's used in the https agent.
23
+ *
24
+ * @returns {Promise<boolean>} A promise that resolves with a boolean indicating whether
25
+ * unauthorized requests should be rejected or not.
26
+ */
27
+ export async function shouldRejectUnauthorizedRequests(service) {
28
+ return (await environmentForService(service)) !== 'spin';
29
+ }
3
30
  //# sourceMappingURL=http.js.map
package/dist/http.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,oBAAoB,CAAA","sourcesContent":["export {default as fetch} from './http/fetch.js'\nexport {default as formData} from './http/formdata.js'\n"]}
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,qBAAqB,EAAC,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,oBAAoB,CAAA;AAEtD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAgB;IAC/C,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,EAAC,kBAAkB,EAAE,MAAM,gCAAgC,CAAC,OAAO,CAAC,EAAC,CAAC,CAAA;AAC/F,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,gCAAgC,CAAC,OAAgB;IACrE,OAAO,CAAC,MAAM,qBAAqB,CAAC,OAAO,CAAC,CAAC,KAAK,MAAM,CAAA;AAC1D,CAAC","sourcesContent":["import {Service} from './network/service.js'\nimport {environmentForService} from './environment/service.js'\nimport https from 'https'\n\nexport {default as fetch} from './http/fetch.js'\nexport {shopifyFetch} from './http/fetch.js'\nexport {default as formData} from './http/formdata.js'\n\n/**\n * This utility function returns the https.Agent to use for a given service. The agent\n * includes the right configuration based on the service's environment. For example,\n * if the service is running in a Spin environment, the attribute \"rejectUnauthorized\" is\n * set to false\n */\nexport async function httpsAgent(service: Service) {\n return new https.Agent({rejectUnauthorized: await shouldRejectUnauthorizedRequests(service)})\n}\n\n/**\n * Spin stores the CA certificate in the keychain and it should be used when sending HTTP\n * requests to Spin instances. However, Node doesn't read certificates from the Keychain\n * by default, which leads to Shopifolks running into issues that they workaround by setting the\n * NODE_TLS_REJECT_UNAUTHORIZED=0 environment variable, which applies to all the HTTP\n * requests sent from the CLI (context: https://github.com/nodejs/node/issues/39657)\n * This utility function allows controlling the behavior in a per-service level by returning\n * the value of for the \"rejectUnauthorized\" attribute that's used in the https agent.\n *\n * @returns {Promise<boolean>} A promise that resolves with a boolean indicating whether\n * unauthorized requests should be rejected or not.\n */\nexport async function shouldRejectUnauthorizedRequests(service: Service): Promise<boolean> {\n return (await environmentForService(service)) !== 'spin'\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  * @readonly
4
4
  * @enum {number}
5
5
  */
6
- export declare type Service = 'shopify' | 'admin' | 'identity';
6
+ export declare type Service = 'shopify' | 'partners' | 'identity';
7
7
  /**
8
8
  * Enum that represents the environment to use for a given service.
9
9
  * @readonly
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/network/service.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,8BAAe,CAAA;IACf,wCAAyB,CAAA;IACzB,4BAAa,CAAA;AACf,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB","sourcesContent":["/**\n * Enum for the differnet APIs the CLI can interact with.\n * @readonly\n * @enum {number}\n */\nexport type Service = 'shopify' | 'admin' | 'identity'\n\n/**\n * Enum that represents the environment to use for a given service.\n * @readonly\n * @enum {number}\n */\nexport enum Environment {\n Local = 'local',\n Production = 'production',\n Spin = 'spin',\n}\n"]}
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/network/service.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,8BAAe,CAAA;IACf,wCAAyB,CAAA;IACzB,4BAAa,CAAA;AACf,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB","sourcesContent":["/**\n * Enum for the differnet APIs the CLI can interact with.\n * @readonly\n * @enum {number}\n */\nexport type Service = 'shopify' | 'partners' | 'identity'\n\n/**\n * Enum that represents the environment to use for a given service.\n * @readonly\n * @enum {number}\n */\nexport enum Environment {\n Local = 'local',\n Production = 'production',\n Spin = 'spin',\n}\n"]}
@@ -3,4 +3,5 @@ export default abstract class extends Command {
3
3
  catch(error: Error & {
4
4
  exitCode?: number | undefined;
5
5
  }): Promise<void>;
6
+ protected init(): Promise<any>;
6
7
  }
@@ -1,9 +1,18 @@
1
- import { errorHandler } from './error-handler.js';
1
+ import { errorHandler, registerCleanBugsnagErrorsFromWithinPlugins } from './error-handler.js';
2
+ import { isDebug } from '../environment/local.js';
2
3
  import { Command } from '@oclif/core';
3
4
  // eslint-disable-next-line import/no-anonymous-default-export
4
5
  export default class extends Command {
5
6
  async catch(error) {
6
7
  errorHandler(error);
7
8
  }
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ async init() {
11
+ if (!isDebug()) {
12
+ // This function runs just prior to `run`
13
+ registerCleanBugsnagErrorsFromWithinPlugins(this.config.plugins);
14
+ }
15
+ return super.init();
16
+ }
8
17
  }
9
18
  //# sourceMappingURL=base-command.js.map
@@ -1 +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"]}
1
+ {"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../src/node/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,2CAA2C,EAAC,MAAM,oBAAoB,CAAA;AAC5F,OAAO,EAAC,OAAO,EAAC,MAAM,yBAAyB,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;IAED,8DAA8D;IACpD,KAAK,CAAC,IAAI;QAClB,IAAI,CAAC,OAAO,EAAE,EAAE;YACd,yCAAyC;YACzC,2CAA2C,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;SACjE;QACD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAA;IACrB,CAAC;CACF","sourcesContent":["import {errorHandler, registerCleanBugsnagErrorsFromWithinPlugins} from './error-handler.js'\nimport {isDebug} from '../environment/local.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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected async init(): Promise<any> {\n if (!isDebug()) {\n // This function runs just prior to `run`\n registerCleanBugsnagErrorsFromWithinPlugins(this.config.plugins)\n }\n return super.init()\n }\n}\n"]}
@@ -1,8 +1,6 @@
1
1
  interface RunCLIOptions {
2
2
  /** The value of import.meta.url of the CLI executable module */
3
3
  moduleURL: string;
4
- /** The logs file name */
5
- logFilename: string;
6
4
  }
7
5
  /**
8
6
  * A function that abstracts away setting up the environment and running
package/dist/node/cli.js CHANGED
@@ -1,8 +1,6 @@
1
1
  // CLI
2
2
  import { findUpAndReadPackageJson } from './node-package-manager.js';
3
3
  import { errorHandler } from './error-handler.js';
4
- import { initializeCliKitStore } from '../store.js';
5
- import { initiateLogging } from '../output.js';
6
4
  import { isDebug } from '../environment/local.js';
7
5
  import constants, { bugsnagApiKey } from '../constants.js';
8
6
  import { moduleDirectory } from '../path.js';
@@ -14,8 +12,6 @@ import Bugsnag from '@bugsnag/js';
14
12
  * @param module {RunCLIOptions} Options.
15
13
  */
16
14
  export async function runCLI(options) {
17
- await initializeCliKitStore();
18
- initiateLogging({ filename: options.logFilename });
19
15
  if (isDebug()) {
20
16
  settings.debug = true;
21
17
  }
@@ -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,YAAY,EAAC,MAAM,oBAAoB,CAAA;AAC/C,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,EA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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"]}
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,OAAO,EAAC,MAAM,yBAAyB,CAAA;AAC/C,OAAO,SAAS,EAAE,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAChD,OAAO,OAAO,MAAM,aAAa,CAAA;AAOjC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAsB;IACjD,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;YAC7C,iBAAiB,EAAE,KAAK;YACxB,gBAAgB,EAAE,KAAK;SACxB,CAAC,CAAA;KACH;IAED,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;AACnE,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAsB;IACvD,MAAM,WAAW,GAAG,MAAM,wBAAwB,CAAC,eAAe,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAA;IACtF,8DAA8D;IAC9D,MAAM,WAAW,GAAI,WAAW,CAAC,OAAe,CAAC,IAAc,CAAA;IAC/D,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAA;IACxD,MAAM,SAAS,GAAG,OAAO,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 {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}\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 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"]}
@@ -1,3 +1,23 @@
1
+ import { Interfaces } from '@oclif/core';
1
2
  export declare function errorHandler(error: Error & {
2
3
  exitCode?: number | undefined;
3
4
  }): Promise<never> | undefined;
5
+ /**
6
+ * If the given file path comes from within a plugin, return the relative path, plus the plugin name.
7
+ *
8
+ * This gives us very consistent paths for errors thrown from plugin code.
9
+ *
10
+ */
11
+ export declare function cleanStackFrameFilePath({ currentFilePath, projectRoot, pluginLocations, }: {
12
+ currentFilePath: string;
13
+ projectRoot: string;
14
+ pluginLocations: {
15
+ name: string;
16
+ pluginPath: string;
17
+ }[];
18
+ }): string;
19
+ /**
20
+ * Register a Bugsnag error listener to clean up stack traces for errors within plugin code.
21
+ *
22
+ */
23
+ export declare function registerCleanBugsnagErrorsFromWithinPlugins(plugins: Interfaces.Plugin[]): Promise<void>;
@@ -1,10 +1,11 @@
1
- import { AbortSilent, CancelExecution, mapper as errorMapper, shouldReport as shouldReportError, handler, } from '../error.js';
1
+ import { AbortSilent, CancelExecution, mapper as errorMapper, shouldReport as shouldReportError, handler, cleanSingleStackTracePath, } from '../error.js';
2
2
  import { info } from '../output.js';
3
3
  import { reportEvent } from '../analytics.js';
4
- import { normalize } from '../path.js';
4
+ import * as path from '../path.js';
5
5
  import { settings } from '@oclif/core';
6
6
  import StackTracey from 'stacktracey';
7
7
  import Bugsnag from '@bugsnag/js';
8
+ import { realpath } from 'fs/promises';
8
9
  export function errorHandler(error) {
9
10
  if (error instanceof CancelExecution) {
10
11
  if (error.message && error.message !== '') {
@@ -57,7 +58,7 @@ const reportError = async (error) => {
57
58
  const formattedStacktrace = new StackTracey(stacktrace ?? '')
58
59
  .clean()
59
60
  .items.map((item) => {
60
- const filePath = normalize(item.file).replace('file:/', '/').replace('C:/', '');
61
+ const filePath = cleanSingleStackTracePath(item.file);
61
62
  return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`;
62
63
  })
63
64
  .join('\n');
@@ -76,4 +77,40 @@ const reportError = async (error) => {
76
77
  }
77
78
  return reportableError;
78
79
  };
80
+ /**
81
+ * If the given file path comes from within a plugin, return the relative path, plus the plugin name.
82
+ *
83
+ * This gives us very consistent paths for errors thrown from plugin code.
84
+ *
85
+ */
86
+ export function cleanStackFrameFilePath({ currentFilePath, projectRoot, pluginLocations, }) {
87
+ const fullLocation = path.isAbsolute(currentFilePath) ? currentFilePath : path.join(projectRoot, currentFilePath);
88
+ const matchingPluginPath = pluginLocations.filter(({ pluginPath }) => fullLocation.indexOf(pluginPath) === 0)[0];
89
+ if (matchingPluginPath !== undefined) {
90
+ // the plugin name (e.g. @shopify/cli-kit), plus the relative path of the error line from within the plugin's code (e.g. dist/something.js )
91
+ return path.join(matchingPluginPath.name, path.relative(matchingPluginPath.pluginPath, fullLocation));
92
+ }
93
+ return currentFilePath;
94
+ }
95
+ /**
96
+ * Register a Bugsnag error listener to clean up stack traces for errors within plugin code.
97
+ *
98
+ */
99
+ export async function registerCleanBugsnagErrorsFromWithinPlugins(plugins) {
100
+ // Bugsnag have their own plug-ins that use this private field
101
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
102
+ const bugsnagConfigProjectRoot = Bugsnag?._client?._config?.projectRoot ?? process.cwd();
103
+ const projectRoot = path.normalize(bugsnagConfigProjectRoot);
104
+ const pluginLocations = await Promise.all(plugins.map(async (plugin) => {
105
+ const followSymlinks = await realpath(plugin.root);
106
+ return { name: plugin.name, pluginPath: path.normalize(followSymlinks) };
107
+ }));
108
+ Bugsnag.addOnError((event) => {
109
+ event.errors.forEach((error) => {
110
+ error.stacktrace.forEach((stackFrame) => {
111
+ stackFrame.file = cleanStackFrameFilePath({ currentFilePath: stackFrame.file, projectRoot, pluginLocations });
112
+ });
113
+ });
114
+ });
115
+ }
79
116
  //# sourceMappingURL=error-handler.js.map
@@ -1 +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,UAAU,YAAY,CAAC,KAA8C;IACzE,IAAI,KAAK,YAAY,eAAe,EAAE;QACpC,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,KAAK,EAAE,EAAE;YACzC,IAAI,CAAC,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;SAC5B;KACF;SAAM,IAAI,KAAK,YAAY,WAAW,EAAE;QACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAChB;SAAM;QACL,OAAO,WAAW,CAAC,KAAK,CAAC;aACtB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AAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAClB,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;QAC/E,OAAO,UAAU,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAA;IAC1E,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAA;IACb,eAAe,CAAC,KAAK,GAAG,UAAU,eAAe,CAAC,OAAO,KAAK,mBAAmB,EAAE,CAAA;IAEnF,IAAI,MAAM,EAAE;QACV,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACpC,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;gBAC1D,IAAI,KAAK,EAAE;oBACT,MAAM,CAAC,KAAK,CAAC,CAAA;iBACd;qBAAM;oBACL,OAAO,CAAC,eAAe,CAAC,CAAA;iBACzB;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;KACH;IACD,OAAO,eAAe,CAAA;AACxB,CAAC,CAAA","sourcesContent":["import {\n AbortSilent,\n CancelExecution,\n mapper as errorMapper,\n shouldReport as shouldReportError,\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"]}
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,EACP,yBAAyB,GAC1B,MAAM,aAAa,CAAA;AACpB,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,YAAY,CAAA;AAClC,O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EAAC,CAAA;IACxE,CAAC,CAAC,CACH,CAAA;IACD,OAAO,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3B,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YAC7B,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;gBACtC,UAAU,CAAC,IAAI,GAAG,uBAAuB,CAAC,EAAC,eAAe,EAAE,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,eAAe,EAAC,CAAC,CAAA;YAC7G,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {\n AbortSilent,\n CancelExecution,\n mapper as errorMapper,\n shouldReport as shouldReportError,\n handler,\n cleanSingleStackTracePath,\n} from '../error.js'\nimport {info} from '../output.js'\nimport {reportEvent} from '../analytics.js'\nimport * as path from '../path.js'\nimport {settings, Interfaces} from '@oclif/core'\nimport StackTracey from 'stacktracey'\nimport Bugsnag from '@bugsnag/js'\nimport {realpath} from 'fs/promises'\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 = cleanSingleStackTracePath(item.file)\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\n/**\n * If the given file path comes from within a plugin, return the relative path, plus the plugin name.\n *\n * This gives us very consistent paths for errors thrown from plugin code.\n *\n */\nexport function cleanStackFrameFilePath({\n currentFilePath,\n projectRoot,\n pluginLocations,\n}: {\n currentFilePath: string\n projectRoot: string\n pluginLocations: {name: string; pluginPath: string}[]\n}): string {\n const fullLocation = path.isAbsolute(currentFilePath) ? currentFilePath : path.join(projectRoot, currentFilePath)\n\n const matchingPluginPath = pluginLocations.filter(({pluginPath}) => fullLocation.indexOf(pluginPath) === 0)[0]\n\n if (matchingPluginPath !== undefined) {\n // the plugin name (e.g. @shopify/cli-kit), plus the relative path of the error line from within the plugin's code (e.g. dist/something.js )\n return path.join(matchingPluginPath.name, path.relative(matchingPluginPath.pluginPath, fullLocation))\n }\n return currentFilePath\n}\n\n/**\n * Register a Bugsnag error listener to clean up stack traces for errors within plugin code.\n *\n */\nexport async function registerCleanBugsnagErrorsFromWithinPlugins(plugins: Interfaces.Plugin[]) {\n // Bugsnag have their own plug-ins that use this private field\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const bugsnagConfigProjectRoot: string = (Bugsnag as any)?._client?._config?.projectRoot ?? process.cwd()\n const projectRoot = path.normalize(bugsnagConfigProjectRoot)\n const pluginLocations = await Promise.all(\n plugins.map(async (plugin) => {\n const followSymlinks = await realpath(plugin.root)\n return {name: plugin.name, pluginPath: path.normalize(followSymlinks)}\n }),\n )\n Bugsnag.addOnError((event) => {\n event.errors.forEach((error) => {\n error.stacktrace.forEach((stackFrame) => {\n stackFrame.file = cleanStackFrameFilePath({currentFilePath: stackFrame.file, projectRoot, pluginLocations})\n })\n })\n })\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { Hook } from '@oclif/core';
2
+ export declare const hook: Hook.Init;
@@ -0,0 +1,7 @@
1
+ import { initiateLogging } from '../../output.js';
2
+ import { initializeCliKitStore } from '../../store.js';
3
+ export const hook = async (options) => {
4
+ await initializeCliKitStore();
5
+ initiateLogging();
6
+ };
7
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/node/hooks/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAC,qBAAqB,EAAC,MAAM,gBAAgB,CAAA;AAGpD,MAAM,CAAC,MAAM,IAAI,GAAc,KAAK,EAAE,OAAO,EAAE,EAAE;IAC/C,MAAM,qBAAqB,EAAE,CAAA;IAC7B,eAAe,EAAE,CAAA;AACnB,CAAC,CAAA","sourcesContent":["import {initiateLogging} from '../../output.js'\nimport {initializeCliKitStore} from '../../store.js'\nimport {Hook} from '@oclif/core'\n\nexport const hook: Hook.Init = async (options) => {\n await initializeCliKitStore()\n initiateLogging()\n}\n"]}
@@ -1,6 +1,9 @@
1
1
  import { reportEvent } from '../../analytics.js';
2
+ import { debug } from '../../output.js';
2
3
  // This hook is called after each successful command run. More info: https://oclif.io/docs/hooks
3
- export const hookPost = async (_options) => {
4
+ export const hookPost = async (options) => {
4
5
  await reportEvent();
6
+ const command = options.Command?.id?.replace(/:/g, ' ');
7
+ debug(`Completed command ${command}`);
5
8
  };
6
9
  //# sourceMappingURL=postrun.js.map