@shopify/cli-kit 3.19.0 → 3.20.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 (41) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/api/graphql/all_app_extension_registrations.d.ts +6 -0
  3. package/dist/api/graphql/all_app_extension_registrations.js +6 -0
  4. package/dist/api/graphql/all_app_extension_registrations.js.map +1 -1
  5. package/dist/cli.d.ts +1 -0
  6. package/dist/cli.js +5 -0
  7. package/dist/cli.js.map +1 -1
  8. package/dist/constants.d.ts +2 -0
  9. package/dist/constants.js +2 -0
  10. package/dist/constants.js.map +1 -1
  11. package/dist/environment/local.d.ts +2 -0
  12. package/dist/environment/local.js +6 -0
  13. package/dist/environment/local.js.map +1 -1
  14. package/dist/error.d.ts +13 -4
  15. package/dist/error.js +20 -2
  16. package/dist/error.js.map +1 -1
  17. package/dist/node/base-command.d.ts +11 -5
  18. package/dist/node/base-command.js +126 -3
  19. package/dist/node/base-command.js.map +1 -1
  20. package/dist/node/cli.js +3 -1
  21. package/dist/node/cli.js.map +1 -1
  22. package/dist/node/ruby.d.ts +3 -1
  23. package/dist/node/ruby.js +2 -1
  24. package/dist/node/ruby.js.map +1 -1
  25. package/dist/private/node/ui/components/Link.d.ts +1 -1
  26. package/dist/private/node/ui/components/Link.js +1 -1
  27. package/dist/private/node/ui/components/Link.js.map +1 -1
  28. package/dist/private/node/ui/components/TokenizedText.d.ts +1 -1
  29. package/dist/private/node/ui/components/TokenizedText.js.map +1 -1
  30. package/dist/public/node/presets.d.ts +3 -1
  31. package/dist/public/node/presets.js +3 -3
  32. package/dist/public/node/presets.js.map +1 -1
  33. package/dist/session.d.ts +3 -3
  34. package/dist/session.js +6 -6
  35. package/dist/session.js.map +1 -1
  36. package/dist/testing/fixtures/render-concurrent.js +1 -3
  37. package/dist/testing/fixtures/render-concurrent.js.map +1 -1
  38. package/dist/testing/ui.js +5 -3
  39. package/dist/testing/ui.js.map +1 -1
  40. package/dist/tsconfig.tsbuildinfo +1 -1
  41. package/package.json +5 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @shopify/cli-kit
2
2
 
3
+ ## 3.20.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 96d5b175: Enable experimental presets feature for apps and themes
8
+ - 4bd05555: Add experimental preset flag for pre-specifying command line flags
9
+
10
+ ### Patch Changes
11
+
12
+ - 0a8ee2a3: Document how to style error messages
13
+ - efa5b071: Refresh theme dev session every 90 minutes
14
+
3
15
  ## 3.19.0
4
16
 
5
17
  ### Minor Changes
@@ -10,5 +10,11 @@ export interface AllAppExtensionRegistrationsQuerySchema {
10
10
  title: string;
11
11
  type: string;
12
12
  }[];
13
+ functions: {
14
+ id: string;
15
+ uuid: string;
16
+ title: string;
17
+ type: string;
18
+ }[];
13
19
  };
14
20
  }
@@ -8,6 +8,12 @@ export const AllAppExtensionRegistrationsQuery = gql `
8
8
  title
9
9
  type
10
10
  }
11
+ functions {
12
+ id
13
+ uuid
14
+ title
15
+ type: apiType
16
+ }
11
17
  }
12
18
  }
13
19
  `;
@@ -1 +1 @@
1
- {"version":3,"file":"all_app_extension_registrations.js","sourceRoot":"","sources":["../../../src/api/graphql/all_app_extension_registrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAEnC,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAG,CAAA;;;;;;;;;;;CAWnD,CAAA","sourcesContent":["import {gql} from 'graphql-request'\n\nexport const AllAppExtensionRegistrationsQuery = gql`\n query allAppExtensionRegistrations($apiKey: String!) {\n app(apiKey: $apiKey) {\n extensionRegistrations {\n id\n uuid\n title\n type\n }\n }\n }\n`\n\nexport interface AllAppExtensionRegistrationsQueryVariables {\n apiKey: string\n}\n\nexport interface AllAppExtensionRegistrationsQuerySchema {\n app: {\n extensionRegistrations: {\n id: string\n uuid: string\n title: string\n type: string\n }[]\n }\n}\n"]}
1
+ {"version":3,"file":"all_app_extension_registrations.js","sourceRoot":"","sources":["../../../src/api/graphql/all_app_extension_registrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAEnC,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;CAiBnD,CAAA","sourcesContent":["import {gql} from 'graphql-request'\n\nexport const AllAppExtensionRegistrationsQuery = gql`\n query allAppExtensionRegistrations($apiKey: String!) {\n app(apiKey: $apiKey) {\n extensionRegistrations {\n id\n uuid\n title\n type\n }\n functions {\n id\n uuid\n title\n type: apiType\n }\n }\n }\n`\n\nexport interface AllAppExtensionRegistrationsQueryVariables {\n apiKey: string\n}\n\nexport interface AllAppExtensionRegistrationsQuerySchema {\n app: {\n extensionRegistrations: {\n id: string\n uuid: string\n title: string\n type: string\n }[]\n functions: {\n id: string\n uuid: string\n title: string\n type: string\n }[]\n }\n}\n"]}
package/dist/cli.d.ts CHANGED
@@ -3,5 +3,6 @@
3
3
  * are shared across all the commands.
4
4
  */
5
5
  export declare const globalFlags: {
6
+ preset: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
6
7
  verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
8
  };
package/dist/cli.js CHANGED
@@ -4,6 +4,11 @@ import { Flags } from '@oclif/core';
4
4
  * are shared across all the commands.
5
5
  */
6
6
  export const globalFlags = {
7
+ preset: Flags.string({
8
+ hidden: true,
9
+ description: 'The preset to apply to the current command.',
10
+ env: 'SHOPIFY_FLAG_PRESET',
11
+ }),
7
12
  verbose: Flags.boolean({
8
13
  hidden: false,
9
14
  description: 'Increase the verbosity of the logs.',
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAEjC;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;QACrB,MAAM,EAAE,KAAK;QACb,WAAW,EAAE,qCAAqC;QAClD,GAAG,EAAE,sBAAsB;KAC5B,CAAC;CACH,CAAA","sourcesContent":["import {Flags} from '@oclif/core'\n\n/**\n * An object that contains the flags that\n * are shared across all the commands.\n */\nexport const globalFlags = {\n verbose: Flags.boolean({\n hidden: false,\n description: 'Increase the verbosity of the logs.',\n env: 'SHOPIFY_FLAG_VERBOSE',\n }),\n}\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAEjC;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;QACnB,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,6CAA6C;QAC1D,GAAG,EAAE,qBAAqB;KAC3B,CAAC;IACF,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;QACrB,MAAM,EAAE,KAAK;QACb,WAAW,EAAE,qCAAqC;QAClD,GAAG,EAAE,sBAAsB;KAC5B,CAAC;CACH,CAAA","sourcesContent":["import {Flags} from '@oclif/core'\n\n/**\n * An object that contains the flags that\n * are shared across all the commands.\n */\nexport const globalFlags = {\n preset: Flags.string({\n hidden: true,\n description: 'The preset to apply to the current command.',\n env: 'SHOPIFY_FLAG_PRESET',\n }),\n verbose: Flags.boolean({\n hidden: false,\n description: 'Increase the verbosity of the logs.',\n env: 'SHOPIFY_FLAG_VERBOSE',\n }),\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  declare const constants: {
2
2
  environmentVariables: {
3
3
  alwaysLogAnalytics: string;
4
+ useGoBinary: string;
4
5
  debugGoBinary: string;
5
6
  deviceAuth: string;
6
7
  enableCliRedirect: string;
@@ -18,6 +19,7 @@ declare const constants: {
18
19
  themeToken: string;
19
20
  unitTest: string;
20
21
  verbose: string;
22
+ functionMatching: string;
21
23
  codespaceName: string;
22
24
  codespaces: string;
23
25
  gitpod: string;
package/dist/constants.js CHANGED
@@ -10,6 +10,7 @@ const cacheFolder = () => {
10
10
  const constants = {
11
11
  environmentVariables: {
12
12
  alwaysLogAnalytics: 'SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS',
13
+ useGoBinary: 'SHOPIFY_CLI_USE_GO_BINARY',
13
14
  debugGoBinary: 'SHOPIFY_DEBUG_GO_BINARY',
14
15
  deviceAuth: 'SHOPIFY_CLI_DEVICE_AUTH',
15
16
  enableCliRedirect: 'SHOPIFY_CLI_ENABLE_CLI_REDIRECT',
@@ -27,6 +28,7 @@ const constants = {
27
28
  themeToken: 'SHOPIFY_CLI_THEME_TOKEN',
28
29
  unitTest: 'SHOPIFY_UNIT_TEST',
29
30
  verbose: 'SHOPIFY_FLAG_VERBOSE',
31
+ functionMatching: 'SHOPIFY_CLI_FUNCTION_MATCHING',
30
32
  // Variables to detect if the CLI is running in a cloud environment
31
33
  codespaceName: 'CODESPACE_NAME',
32
34
  codespaces: 'CODESPACES',
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAC,oBAAoB,EAAC,MAAM,cAAc,CAAA;AACjD,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,MAAM,UAAU,GAAG,aAAa,CAAA;AAEhC,MAAM,WAAW,GAAG,GAAG,EAAE;IACvB,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,CAAA;IACjE,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC,KAAK,CAAA;AACnC,CAAC,CAAA;AAED,MAAM,SAAS,GAAG;IAChB,oBAAoB,EAAE;QACpB,kBAAkB,EAA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KACvB;IACD,OAAO,EAAE;QACP,6BAA6B,EAAE,CAAC;KACjC;CACF,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,kCAAkC,CAAA;AAE/D,eAAe,SAAS,CAAA","sourcesContent":["import {join as pathJoin} from './path.js'\nimport {findPackageVersionUp} from './version.js'\nimport envPaths from 'env-paths'\n\nconst identifier = 'shopify-cli'\n\nconst cacheFolder = () => {\n if (process.env.XDG_CACHE_HOME) return process.env.XDG_CACHE_HOME\n return envPaths(identifier).cache\n}\n\nconst constants = {\n environmentVariables: {\n alwaysLogAnalytics: 'SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS',\n debugGoBinary: 'SHOPIFY_DEBUG_GO_BINARY',\n deviceAuth: 'SHOPIFY_CLI_DEVICE_AUTH',\n enableCliRedirect: 'SHOPIFY_CLI_ENABLE_CLI_REDIRECT',\n env: 'SHOPIFY_CLI_ENV',\n firstPartyDev: 'SHOPIFY_CLI_1P_DEV',\n noAnalytics: 'SHOPIFY_CLI_NO_ANALYTICS',\n partnersToken: 'SHOPIFY_CLI_PARTNERS_TOKEN',\n runAsUser: 'SHOPIFY_RUN_AS_USER',\n serviceEnv: 'SHOPIFY_SERVICE_ENV',\n skipCliRedirect: 'SHOPIFY_CLI_SKIP_CLI_REDIRECT',\n spinHost: 'SPIN_HOST',\n spinInstance: 'SPIN_INSTANCE',\n spinNamespace: 'SPIN_NAMESPACE',\n spinWorkspace: 'SPIN_WORKSPACE',\n themeToken: 'SHOPIFY_CLI_THEME_TOKEN',\n unitTest: 'SHOPIFY_UNIT_TEST',\n verbose: 'SHOPIFY_FLAG_VERBOSE',\n // Variables to detect if the CLI is running in a cloud environment\n codespaceName: 'CODESPACE_NAME',\n codespaces: 'CODESPACES',\n gitpod: 'GITPOD_WORKSPACE_URL',\n spin: 'SPIN',\n },\n paths: {\n executables: {\n dev: '/opt/dev/bin/dev',\n },\n directories: {\n cache: {\n path: () => {\n return cacheFolder()\n },\n vendor: {\n path: () => {\n return pathJoin(cacheFolder(), 'vendor')\n },\n binaries: () => {\n return pathJoin(cacheFolder(), 'vendor', 'binaries')\n },\n },\n },\n },\n },\n versions: {\n cliKit: async () => {\n return findPackageVersionUp({fromModuleURL: import.meta.url})\n },\n },\n keychain: {\n service: 'shopify-cli',\n },\n session: {\n expirationTimeMarginInMinutes: 4,\n },\n}\n\nexport const bugsnagApiKey = '9e1e6889176fd0c795d5c659225e0fae'\n\nexport default constants\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAC,oBAAoB,EAAC,MAAM,cAAc,CAAA;AACjD,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,MAAM,UAAU,GAAG,aAAa,CAAA;AAEhC,MAAM,WAAW,GAAG,GAAG,EAAE;IACvB,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,CAAA;IACjE,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC,KAAK,CAAA;AACnC,CAAC,CAAA;AAED,MAAM,SAAS,GAAG;IAChB,oBAAoB,EAAE;QACpB,kBAAkB,EAAE,kCAAkC;QACtD,WAAW,EAAE,2BAA2B;QACxC,aAAa,EAAE,yBAAyB;QACxC,UAAU,EAAE,yBAAyB;QACrC,iBAAiB,EAAE,iCAAiC;QACpD,GAAG,EAAE,iBAAiB;QACtB,aAAa,EAAE,oBAAoB;QACnC,WAAW,EAAE,0BAA0B;QACvC,aAAa,EAAE,4BAA4B;QAC3C,SAAS,EAAE,qBAAqB;QAChC,UAAU,EAAE,qBAAqB;QACjC,eAAe,EAAE,+BAA+B;QAChD,QAAQ,EAAE,WAAW;QACrB,YAAY,EAAE,eAAe;QAC7B,aAAa,EAAE,gBAAgB;QAC/B,aAAa,EAAE,gBAAgB;QAC/B,UAAU,EAAE,yBAAyB;QACrC,QAAQ,EAAE,mBAAmB;QAC7B,OAAO,EAAE,sBAAsB;QAC/B,gBAAgB,EAAE,+BAA+B;QACjD,mEAAmE;QACnE,aAAa,EAAE,gBAAgB;QAC/B,UAAU,EAAE,YAAY;QACxB,MAAM,EAAE,sBAAsB;QAC9B,IAAI,EAAE,MAAM;KACb;IACD,KAAK,EAAE;QACL,WAAW,EAAE;YACX,GAAG,EAAE,kBAAkB;SACxB;QACD,WAAW,EAAE;YACX,KAAK,EAAE;gBACL,IAAI,EAAE,GAAG,EAAE;oBACT,OAAO,WAAW,EAAE,CAAA;gBACtB,CAAC;gBACD,MAAM,EAAE;oBACN,IAAI,EAAE,GAAG,EAAE;wBACT,OAAO,QAAQ,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAA;oBAC1C,CAAC;oBACD,QAAQ,EAAE,GAAG,EAAE;wBACb,OAAO,QAAQ,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA;oBACtD,CAAC;iBACF;aACF;SACF;KACF;IACD,QAAQ,EAAE;QACR,MAAM,EAAE,KAAK,IAAI,EAAE;YACjB,OAAO,oBAAoB,CAAC,EAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAC,CAAC,CAAA;QAC/D,CAAC;KACF;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,aAAa;KACvB;IACD,OAAO,EAAE;QACP,6BAA6B,EAAE,CAAC;KACjC;CACF,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,kCAAkC,CAAA;AAE/D,eAAe,SAAS,CAAA","sourcesContent":["import {join as pathJoin} from './path.js'\nimport {findPackageVersionUp} from './version.js'\nimport envPaths from 'env-paths'\n\nconst identifier = 'shopify-cli'\n\nconst cacheFolder = () => {\n if (process.env.XDG_CACHE_HOME) return process.env.XDG_CACHE_HOME\n return envPaths(identifier).cache\n}\n\nconst constants = {\n environmentVariables: {\n alwaysLogAnalytics: 'SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS',\n useGoBinary: 'SHOPIFY_CLI_USE_GO_BINARY',\n debugGoBinary: 'SHOPIFY_DEBUG_GO_BINARY',\n deviceAuth: 'SHOPIFY_CLI_DEVICE_AUTH',\n enableCliRedirect: 'SHOPIFY_CLI_ENABLE_CLI_REDIRECT',\n env: 'SHOPIFY_CLI_ENV',\n firstPartyDev: 'SHOPIFY_CLI_1P_DEV',\n noAnalytics: 'SHOPIFY_CLI_NO_ANALYTICS',\n partnersToken: 'SHOPIFY_CLI_PARTNERS_TOKEN',\n runAsUser: 'SHOPIFY_RUN_AS_USER',\n serviceEnv: 'SHOPIFY_SERVICE_ENV',\n skipCliRedirect: 'SHOPIFY_CLI_SKIP_CLI_REDIRECT',\n spinHost: 'SPIN_HOST',\n spinInstance: 'SPIN_INSTANCE',\n spinNamespace: 'SPIN_NAMESPACE',\n spinWorkspace: 'SPIN_WORKSPACE',\n themeToken: 'SHOPIFY_CLI_THEME_TOKEN',\n unitTest: 'SHOPIFY_UNIT_TEST',\n verbose: 'SHOPIFY_FLAG_VERBOSE',\n functionMatching: 'SHOPIFY_CLI_FUNCTION_MATCHING',\n // Variables to detect if the CLI is running in a cloud environment\n codespaceName: 'CODESPACE_NAME',\n codespaces: 'CODESPACES',\n gitpod: 'GITPOD_WORKSPACE_URL',\n spin: 'SPIN',\n },\n paths: {\n executables: {\n dev: '/opt/dev/bin/dev',\n },\n directories: {\n cache: {\n path: () => {\n return cacheFolder()\n },\n vendor: {\n path: () => {\n return pathJoin(cacheFolder(), 'vendor')\n },\n binaries: () => {\n return pathJoin(cacheFolder(), 'vendor', 'binaries')\n },\n },\n },\n },\n },\n versions: {\n cliKit: async () => {\n return findPackageVersionUp({fromModuleURL: import.meta.url})\n },\n },\n keychain: {\n service: 'shopify-cli',\n },\n session: {\n expirationTimeMarginInMinutes: 4,\n },\n}\n\nexport const bugsnagApiKey = '9e1e6889176fd0c795d5c659225e0fae'\n\nexport default constants\n"]}
@@ -41,11 +41,13 @@ export declare function isUnitTest(env?: NodeJS.ProcessEnv): boolean;
41
41
  * @returns true unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.
42
42
  */
43
43
  export declare function analyticsDisabled(env?: NodeJS.ProcessEnv): boolean;
44
+ export declare function useGoBinary(env?: NodeJS.ProcessEnv): boolean;
44
45
  /** Returns true if reporting analytics should always happen, regardless of DEBUG mode etc. */
45
46
  export declare function alwaysLogAnalytics(env?: NodeJS.ProcessEnv): boolean;
46
47
  export declare function firstPartyDev(env?: NodeJS.ProcessEnv): boolean;
47
48
  export declare function isDebugGoBinary(env?: NodeJS.ProcessEnv): boolean;
48
49
  export declare function useDeviceAuth(env?: NodeJS.ProcessEnv): boolean;
50
+ export declare function useFunctionMatching(env?: NodeJS.ProcessEnv): boolean;
49
51
  export declare function gitpodURL(env?: NodeJS.ProcessEnv): string | undefined;
50
52
  export declare function codespaceURL(env?: NodeJS.ProcessEnv): string | undefined;
51
53
  /**
@@ -66,6 +66,9 @@ export function isUnitTest(env = process.env) {
66
66
  export function analyticsDisabled(env = process.env) {
67
67
  return isTruthy(env[constants.environmentVariables.noAnalytics]) || isDevelopment(env);
68
68
  }
69
+ export function useGoBinary(env = process.env) {
70
+ return isTruthy(env[constants.environmentVariables.useGoBinary]);
71
+ }
69
72
  /** Returns true if reporting analytics should always happen, regardless of DEBUG mode etc. */
70
73
  export function alwaysLogAnalytics(env = process.env) {
71
74
  return isTruthy(env[constants.environmentVariables.alwaysLogAnalytics]);
@@ -79,6 +82,9 @@ export function isDebugGoBinary(env = process.env) {
79
82
  export function useDeviceAuth(env = process.env) {
80
83
  return isTruthy(env[constants.environmentVariables.deviceAuth]) || isCloudEnvironment(env);
81
84
  }
85
+ export function useFunctionMatching(env = process.env) {
86
+ return isTruthy(env[constants.environmentVariables.functionMatching]);
87
+ }
82
88
  // https://www.gitpod.io/docs/environment-variables#default-environment-variables
83
89
  export function gitpodURL(env = process.env) {
84
90
  return env[constants.environmentVariables.gitpod];
@@ -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,IAAI;QACF,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;QAChC,OAAO,IAAI,CAAA;QACX,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IAC1C,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QACpB,IAAI,IAAI,GAAG,SAAS,CAAA;QACpB,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAC1B,IAAI,GAAG,UAAU,CAAA;SAClB;aAAM,IAAI,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YACnC,IAAI,GAAG,QAAQ,CAAA;SAChB;aAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAClC,IAAI,GAAG,QAAQ,CAAA;SAChB;QAED,OAAO;YACL,IAAI,EAAE,IAAI;YACV,IAAI;SACL,CAAA;KACF;IACD,OAAO;QACL,IAAI,EAAE,KAAK;KACZ,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,UAAU,CAAC,GAAG,EAAE,CAAA;AACzB,CAAC","sourcesContent":["import {isTruthy, isSet} from './utilities.js'\nimport {isSpin} from './spin.js'\nimport constants from '../constants.js'\nimport {exists as fileExists} from '../file.js'\nimport {exec} from '../system.js'\nimport isInteractive from 'is-interactive'\nimport macaddress from 'macaddress'\nimport {homedir} from 'node:os'\n\n/**\n * It returns true if the terminal is interactive.\n * @returns True if the terminal is interactive.\n */\nexport function isTerminalInteractive(): boolean {\n return isInteractive()\n}\n\n/**\n * Returns the path to the user's home directory.\n * @returns The path to the user's home directory.\n */\nexport function homeDirectory(): string {\n return homedir()\n}\n\n/**\n * Returns true if the CLI is running in debug mode.\n * @param env - The environment variables from the environment of the current process.\n * @returns true if SHOPIFY_ENV is development\n */\nexport function isDevelopment(env = process.env): boolean {\n return env[constants.environmentVariables.env] === 'development'\n}\n\n/**\n * Returns true if the CLI is running in verbose mode.\n * @param env - The environment variables from the environment of the current process.\n * @returns true if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed\n */\nexport function isVerbose(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.verbose]) || process.argv.includes('--verbose')\n}\n\n/**\n * Returns true if the environment in which the CLI is running is either\n * a local environment (where dev is present) or a cloud environment (spin).\n * @returns True if the CLI is used in a Shopify environment.\n */\nexport async function isShopify(env = process.env): Promise<boolean> {\n if (Object.prototype.hasOwnProperty.call(env, constants.environmentVariables.runAsUser)) {\n return !isTruthy(env[constants.environmentVariables.runAsUser])\n }\n const devInstalled = await fileExists(constants.paths.executables.dev)\n return devInstalled || isSpin(env)\n}\n\n/**\n * This variable is used when running unit tests to indicate that the CLI's business logic\n * is run as a subject of a unit test. We can use this variable to disable output through\n * the standard streams.\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.\n */\nexport function isUnitTest(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.unitTest])\n}\n\n/**\n * Returns true if reporting analytics is enabled.\n * @param env - The environment variables from the environment of the current process.\n * @returns true unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.\n */\nexport function analyticsDisabled(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.noAnalytics]) || isDevelopment(env)\n}\n\n/** Returns true if reporting analytics should always happen, regardless of DEBUG mode etc. */\nexport function alwaysLogAnalytics(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.alwaysLogAnalytics])\n}\n\nexport function firstPartyDev(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.firstPartyDev])\n}\n\nexport function isDebugGoBinary(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.debugGoBinary])\n}\n\nexport function useDeviceAuth(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.deviceAuth]) || isCloudEnvironment(env)\n}\n\n// https://www.gitpod.io/docs/environment-variables#default-environment-variables\nexport function gitpodURL(env = process.env): string | undefined {\n return env[constants.environmentVariables.gitpod]\n}\n\n// https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables\nexport function codespaceURL(env = process.env): string | undefined {\n return env[constants.environmentVariables.codespaceName]\n}\n\n/**\n * Checks if the CLI is run from a cloud environment\n *\n * @param env - Environment variables used when the cli is launched\n *\n * @returns True in case the CLI is run from a cloud environment\n */\nexport function isCloudEnvironment(env: NodeJS.ProcessEnv = process.env): boolean {\n return cloudEnvironment(env).platform !== 'localhost'\n}\n\n/**\n * Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of\n * them. Platform name 'localhost' is returned otherwise\n *\n * @param env - Environment variables used when the cli is launched\n *\n * @returns Cloud platform information\n */\nexport function cloudEnvironment(env: NodeJS.ProcessEnv = process.env): {\n platform: 'spin' | 'codespaces' | 'gitpod' | 'localhost'\n editor: boolean\n} {\n if (isSet(env[constants.environmentVariables.codespaces])) {\n return {platform: 'codespaces', editor: true}\n }\n if (isSet(env[constants.environmentVariables.gitpod])) {\n return {platform: 'gitpod', editor: true}\n }\n if (isSpin(env)) {\n return {platform: 'spin', editor: false}\n }\n return {platform: 'localhost', editor: false}\n}\n\n/**\n * Returns whether the environment has Git available.\n * @returns A promise that resolves with the value.\n */\nexport async function hasGit(): Promise<boolean> {\n try {\n await exec('git', ['--version'])\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Gets info on the CI platform the CLI is running on, if applicable\n */\nexport function ciPlatform(env = process.env): {isCI: true; name: string} | {isCI: false; name?: undefined} {\n if (isTruthy(env.CI)) {\n let name = 'unknown'\n if (isTruthy(env.CIRCLECI)) {\n name = 'circleci'\n } else if (isSet(env.GITHUB_ACTION)) {\n name = 'github'\n } else if (isTruthy(env.GITLAB_CI)) {\n name = 'gitlab'\n }\n\n return {\n isCI: true,\n name,\n }\n }\n return {\n isCI: false,\n }\n}\n\n/**\n * Returns the first mac address found\n *\n * @returns Mac address\n */\nexport function macAddress() {\n return macaddress.one()\n}\n"]}
1
+ {"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/environment/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAC,MAAM,IAAI,UAAU,EAAC,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,aAAa,MAAM,gBAAgB,CAAA;AAC1C,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAA;AAE/B;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,aAAa,EAAE,CAAA;AACxB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,OAAO,EAAE,CAAA;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IAC7C,OAAO,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,GAAG,CAAC,KAAK,aAAa,CAAA;AAClE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACzC,OAAO,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;AACpG,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAG,GAAG,OAAO,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OAAO,UAAU,CAAC,GAAG,EAAE,CAAA;AACzB,CAAC","sourcesContent":["import {isTruthy, isSet} from './utilities.js'\nimport {isSpin} from './spin.js'\nimport constants from '../constants.js'\nimport {exists as fileExists} from '../file.js'\nimport {exec} from '../system.js'\nimport isInteractive from 'is-interactive'\nimport macaddress from 'macaddress'\nimport {homedir} from 'node:os'\n\n/**\n * It returns true if the terminal is interactive.\n * @returns True if the terminal is interactive.\n */\nexport function isTerminalInteractive(): boolean {\n return isInteractive()\n}\n\n/**\n * Returns the path to the user's home directory.\n * @returns The path to the user's home directory.\n */\nexport function homeDirectory(): string {\n return homedir()\n}\n\n/**\n * Returns true if the CLI is running in debug mode.\n * @param env - The environment variables from the environment of the current process.\n * @returns true if SHOPIFY_ENV is development\n */\nexport function isDevelopment(env = process.env): boolean {\n return env[constants.environmentVariables.env] === 'development'\n}\n\n/**\n * Returns true if the CLI is running in verbose mode.\n * @param env - The environment variables from the environment of the current process.\n * @returns true if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed\n */\nexport function isVerbose(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.verbose]) || process.argv.includes('--verbose')\n}\n\n/**\n * Returns true if the environment in which the CLI is running is either\n * a local environment (where dev is present) or a cloud environment (spin).\n * @returns True if the CLI is used in a Shopify environment.\n */\nexport async function isShopify(env = process.env): Promise<boolean> {\n if (Object.prototype.hasOwnProperty.call(env, constants.environmentVariables.runAsUser)) {\n return !isTruthy(env[constants.environmentVariables.runAsUser])\n }\n const devInstalled = await fileExists(constants.paths.executables.dev)\n return devInstalled || isSpin(env)\n}\n\n/**\n * This variable is used when running unit tests to indicate that the CLI's business logic\n * is run as a subject of a unit test. We can use this variable to disable output through\n * the standard streams.\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.\n */\nexport function isUnitTest(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.unitTest])\n}\n\n/**\n * Returns true if reporting analytics is enabled.\n * @param env - The environment variables from the environment of the current process.\n * @returns true unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.\n */\nexport function analyticsDisabled(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.noAnalytics]) || isDevelopment(env)\n}\n\nexport function useGoBinary(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.useGoBinary])\n}\n\n/** Returns true if reporting analytics should always happen, regardless of DEBUG mode etc. */\nexport function alwaysLogAnalytics(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.alwaysLogAnalytics])\n}\n\nexport function firstPartyDev(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.firstPartyDev])\n}\n\nexport function isDebugGoBinary(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.debugGoBinary])\n}\n\nexport function useDeviceAuth(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.deviceAuth]) || isCloudEnvironment(env)\n}\n\nexport function useFunctionMatching(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.functionMatching])\n}\n\n// https://www.gitpod.io/docs/environment-variables#default-environment-variables\nexport function gitpodURL(env = process.env): string | undefined {\n return env[constants.environmentVariables.gitpod]\n}\n\n// https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables\nexport function codespaceURL(env = process.env): string | undefined {\n return env[constants.environmentVariables.codespaceName]\n}\n\n/**\n * Checks if the CLI is run from a cloud environment\n *\n * @param env - Environment variables used when the cli is launched\n *\n * @returns True in case the CLI is run from a cloud environment\n */\nexport function isCloudEnvironment(env: NodeJS.ProcessEnv = process.env): boolean {\n return cloudEnvironment(env).platform !== 'localhost'\n}\n\n/**\n * Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of\n * them. Platform name 'localhost' is returned otherwise\n *\n * @param env - Environment variables used when the cli is launched\n *\n * @returns Cloud platform information\n */\nexport function cloudEnvironment(env: NodeJS.ProcessEnv = process.env): {\n platform: 'spin' | 'codespaces' | 'gitpod' | 'localhost'\n editor: boolean\n} {\n if (isSet(env[constants.environmentVariables.codespaces])) {\n return {platform: 'codespaces', editor: true}\n }\n if (isSet(env[constants.environmentVariables.gitpod])) {\n return {platform: 'gitpod', editor: true}\n }\n if (isSpin(env)) {\n return {platform: 'spin', editor: false}\n }\n return {platform: 'localhost', editor: false}\n}\n\n/**\n * Returns whether the environment has Git available.\n * @returns A promise that resolves with the value.\n */\nexport async function hasGit(): Promise<boolean> {\n try {\n await exec('git', ['--version'])\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Gets info on the CI platform the CLI is running on, if applicable\n */\nexport function ciPlatform(env = process.env): {isCI: true; name: string} | {isCI: false; name?: undefined} {\n if (isTruthy(env.CI)) {\n let name = 'unknown'\n if (isTruthy(env.CIRCLECI)) {\n name = 'circleci'\n } else if (isSet(env.GITHUB_ACTION)) {\n name = 'github'\n } else if (isTruthy(env.GITLAB_CI)) {\n name = 'gitlab'\n }\n\n return {\n isCI: true,\n name,\n }\n }\n return {\n isCI: false,\n }\n}\n\n/**\n * Returns the first mac address found\n *\n * @returns Mac address\n */\nexport function macAddress() {\n return macaddress.one()\n}\n"]}
package/dist/error.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Message } from './output.js';
2
+ import { TextTokenItem } from './private/node/ui/components/TokenizedText.js';
2
3
  export { ExtendableError } from 'ts-error';
3
4
  declare enum FatalErrorType {
4
5
  Abort = 0,
@@ -12,16 +13,24 @@ export declare class CancelExecution extends Error {
12
13
  * There shouldn't be code that catches fatal errors.
13
14
  */
14
15
  export declare abstract class Fatal extends Error {
15
- tryMessage: string | null;
16
+ tryMessage: TextTokenItem | null;
16
17
  type: FatalErrorType;
17
- constructor(message: Message, type: FatalErrorType, tryMessage?: Message | null);
18
+ /**
19
+ *
20
+ * @param message - The error message
21
+ * @param type - The type of fatal error
22
+ * @param tryMessage - The message that recommends next steps to the user.
23
+ * You can pass a string a {@link TokenizedString} or a {@link TextTokenItem}
24
+ * if you need to style the message inside the error Banner component.
25
+ */
26
+ constructor(message: Message, type: FatalErrorType, tryMessage?: TextTokenItem | Message | null);
18
27
  }
19
28
  /**
20
29
  * An abort error is a fatal error that shouldn't be reported as a bug.
21
30
  * Those usually represent unexpected scenarios that we can't handle and that usually require some action from the developer
22
31
  */
23
32
  export declare class Abort extends Fatal {
24
- constructor(message: Message, tryMessage?: Message | null);
33
+ constructor(message: Message, tryMessage?: TextTokenItem | Message | null);
25
34
  }
26
35
  export declare class AbortSilent extends Fatal {
27
36
  constructor();
@@ -30,7 +39,7 @@ export declare class AbortSilent extends Fatal {
30
39
  * A bug error is an error that represents a bug and therefore should be reported.
31
40
  */
32
41
  export declare class Bug extends Fatal {
33
- constructor(message: Message, tryMessage?: string | null);
42
+ constructor(message: Message, tryMessage?: TextTokenItem | null);
34
43
  }
35
44
  /**
36
45
  * A function that handles errors that blow up in the CLI.
package/dist/error.js CHANGED
@@ -1,4 +1,4 @@
1
- import { stringifyMessage } from './output.js';
1
+ import { stringifyMessage, TokenizedString } from './output.js';
2
2
  import { normalize } from './path.js';
3
3
  import { renderFatalError } from './public/node/ui.js';
4
4
  import { Errors } from '@oclif/core';
@@ -16,9 +16,27 @@ export class CancelExecution extends Error {
16
16
  * There shouldn't be code that catches fatal errors.
17
17
  */
18
18
  export class Fatal extends Error {
19
+ /**
20
+ *
21
+ * @param message - The error message
22
+ * @param type - The type of fatal error
23
+ * @param tryMessage - The message that recommends next steps to the user.
24
+ * You can pass a string a {@link TokenizedString} or a {@link TextTokenItem}
25
+ * if you need to style the message inside the error Banner component.
26
+ */
19
27
  constructor(message, type, tryMessage = null) {
20
28
  super(stringifyMessage(message));
21
- this.tryMessage = tryMessage ? stringifyMessage(tryMessage) : null;
29
+ if (tryMessage) {
30
+ if (tryMessage instanceof TokenizedString) {
31
+ this.tryMessage = stringifyMessage(tryMessage);
32
+ }
33
+ else {
34
+ this.tryMessage = tryMessage;
35
+ }
36
+ }
37
+ else {
38
+ this.tryMessage = null;
39
+ }
22
40
  this.type = type;
23
41
  }
24
42
  }
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,EAAC,MAAM,aAAa,CAAA;AACrD,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAA;AACnC,OAAO,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAElC,OAAO,EAAC,eAAe,EAAC,MAAM,UAAU,CAAA;AAExC,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;QACE,KAAK,CAAC,EAAE,EAAE,cAAc,CAAC,WAAW,CAAC,CAAA;IACvC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,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O,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;KAC9B;AACH,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,IAAI;QACF,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAC1D,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACnB,OAAO,IAAI,CAAA;KACZ;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,CAAC,GAAG,EAAE;QACrC,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} from './output.js'\nimport {normalize} from './path.js'\nimport {renderFatalError} from './public/node/ui.js'\nimport {Errors} from '@oclif/core'\n\nexport {ExtendableError} from 'ts-error'\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: unknown): Promise<unknown> {\n let fatal: Fatal\n if (isFatal(error)) {\n fatal = error\n } else if (typeof error === 'string') {\n fatal = new Bug(error)\n } else if (error instanceof Error) {\n fatal = new Bug(error.message)\n fatal.stack = error.stack\n } else {\n // errors can come in all shapes and sizes...\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const maybeError = error as any\n fatal = new Bug(maybeError?.message ?? 'Unknown error')\n if (maybeError?.stack) {\n fatal.stack = maybeError?.stack\n }\n }\n\n renderFatalError(fatal)\n return Promise.resolve(error)\n}\n\nexport function mapper(error: unknown): Promise<unknown> {\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: unknown): error is Fatal {\n try {\n return Object.prototype.hasOwnProperty.call(error, 'type')\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\nexport function shouldReport(error: unknown): boolean {\n if (!isFatal(error)) {\n return true\n }\n if (error.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"]}
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"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;SAAM;QACL,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;KAC9B;AACH,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,IAAI;QACF,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAC1D,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACnB,OAAO,IAAI,CAAA;KACZ;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,CAAC,GAAG,EAAE;QACrC,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, TokenizedString} from './output.js'\nimport {normalize} from './path.js'\nimport {renderFatalError} from './public/node/ui.js'\nimport {TextTokenItem} from './private/node/ui/components/TokenizedText.js'\nimport {Errors} from '@oclif/core'\n\nexport {ExtendableError} from 'ts-error'\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: TextTokenItem | null\n type: FatalErrorType\n /**\n *\n * @param message - The error message\n * @param type - The type of fatal error\n * @param tryMessage - The message that recommends next steps to the user.\n * You can pass a string a {@link TokenizedString} or a {@link TextTokenItem}\n * if you need to style the message inside the error Banner component.\n */\n constructor(message: Message, type: FatalErrorType, tryMessage: TextTokenItem | Message | null = null) {\n super(stringifyMessage(message))\n\n if (tryMessage) {\n if (tryMessage instanceof TokenizedString) {\n this.tryMessage = stringifyMessage(tryMessage)\n } else {\n this.tryMessage = tryMessage\n }\n } else {\n this.tryMessage = null\n }\n\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: TextTokenItem | 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: TextTokenItem | 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: unknown): Promise<unknown> {\n let fatal: Fatal\n if (isFatal(error)) {\n fatal = error\n } else if (typeof error === 'string') {\n fatal = new Bug(error)\n } else if (error instanceof Error) {\n fatal = new Bug(error.message)\n fatal.stack = error.stack\n } else {\n // errors can come in all shapes and sizes...\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const maybeError = error as any\n fatal = new Bug(maybeError?.message ?? 'Unknown error')\n if (maybeError?.stack) {\n fatal.stack = maybeError?.stack\n }\n }\n\n renderFatalError(fatal)\n return Promise.resolve(error)\n}\n\nexport function mapper(error: unknown): Promise<unknown> {\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: unknown): error is Fatal {\n try {\n return Object.prototype.hasOwnProperty.call(error, 'type')\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\nexport function shouldReport(error: unknown): boolean {\n if (!isFatal(error)) {\n return true\n }\n if (error.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"]}
@@ -5,15 +5,21 @@ declare abstract class BaseCommand extends Command {
5
5
  exitCode?: number | undefined;
6
6
  }): Promise<void>;
7
7
  protected init(): Promise<any>;
8
- protected parse<TFlags extends {
8
+ protected parse<TFlags extends Interfaces.FlagOutput & {
9
9
  path?: string;
10
10
  verbose?: boolean;
11
- }, TArgs extends {
12
- [name: string]: any;
13
- }>(options?: Interfaces.Input<TFlags> | undefined, argv?: string[] | undefined): Promise<Interfaces.ParserOutput<TFlags, TArgs>>;
11
+ }, TArgs extends Interfaces.OutputArgs>(options?: Interfaces.Input<TFlags> | undefined, argv?: string[] | undefined): Promise<Interfaces.ParserOutput<TFlags, TArgs>>;
12
+ protected resultWithPreset<TFlags extends Interfaces.FlagOutput & {
13
+ path?: string;
14
+ verbose?: boolean;
15
+ }, TArgs extends Interfaces.OutputArgs>(options: Interfaces.Input<TFlags> | undefined, argv: string[] | undefined, originalResult: Interfaces.ParserOutput<TFlags, TArgs>): Promise<Interfaces.ParserOutput<TFlags, TArgs>>;
16
+ protected presetsPath(rawFlags: {
17
+ path?: string;
18
+ }): Promise<string>;
19
+ protected findUpForPresets(): boolean;
14
20
  }
15
- export default BaseCommand;
16
21
  export declare function addFromParsedFlags(flags: {
17
22
  path?: string;
18
23
  verbose?: boolean;
19
24
  }): Promise<void>;
25
+ export default BaseCommand;
@@ -1,7 +1,10 @@
1
1
  import { errorHandler, registerCleanBugsnagErrorsFromWithinPlugins } from './error-handler.js';
2
2
  import { isDevelopment } from '../environment/local.js';
3
+ import { Abort } from '../error.js';
3
4
  import { addPublic } from '../metadata.js';
5
+ import { content, info, token } from '../output.js';
4
6
  import { hashString } from '../string.js';
7
+ import { loadPresetsFromDirectory } from '../public/node/presets.js';
5
8
  import { Command } from '@oclif/core';
6
9
  class BaseCommand extends Command {
7
10
  static analyticsNameOverride() {
@@ -18,14 +21,44 @@ class BaseCommand extends Command {
18
21
  }
19
22
  return super.init();
20
23
  }
21
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
24
  async parse(options, argv) {
23
- const result = await super.parse(options, argv);
25
+ let result = await super.parse(options, argv);
26
+ result = await this.resultWithPreset(options, argv, result);
24
27
  await addFromParsedFlags(result.flags);
25
28
  return result;
26
29
  }
30
+ async resultWithPreset(options, argv, originalResult) {
31
+ // If no preset is specified, don't modify the results
32
+ const flags = originalResult.flags;
33
+ if (!flags.preset)
34
+ return originalResult;
35
+ // If the specified preset isn't found, don't modify the results
36
+ const presets = await loadPresetsFromDirectory(await this.presetsPath(flags), { findUp: this.findUpForPresets() });
37
+ const preset = presets[flags.preset];
38
+ if (!preset)
39
+ return originalResult;
40
+ // Parse using noDefaultsOptions to derive a list of flags specified as
41
+ // command-line arguments.
42
+ const noDefaultsResult = await super.parse(noDefaultsOptions(options), argv);
43
+ // Add the preset's settings to argv and pass them to `super.parse`. This
44
+ // invokes oclif's validation system without breaking the oclif black box.
45
+ // Replace the original result with this one.
46
+ const result = await super.parse(options, [
47
+ // Need to specify argv default because we're merging with argsFromPreset.
48
+ ...(argv || this.argv),
49
+ ...argsFromPreset(preset, options, noDefaultsResult),
50
+ ]);
51
+ // Report successful application of the preset.
52
+ reportPresetApplication(noDefaultsResult.flags, result.flags, flags.preset, preset);
53
+ return result;
54
+ }
55
+ async presetsPath(rawFlags) {
56
+ return rawFlags.path || process.cwd();
57
+ }
58
+ findUpForPresets() {
59
+ return true;
60
+ }
27
61
  }
28
- export default BaseCommand;
29
62
  export async function addFromParsedFlags(flags) {
30
63
  await addPublic(() => ({
31
64
  cmd_all_verbose: flags.verbose,
@@ -33,4 +66,94 @@ export async function addFromParsedFlags(flags) {
33
66
  cmd_all_path_override_hash: flags.path === undefined ? undefined : hashString(flags.path),
34
67
  }));
35
68
  }
69
+ /**
70
+ * Any flag which is:
71
+ *
72
+ * 1. Present in the final set of flags
73
+ * 2. Specified in the preset
74
+ * 3. Not specified by the user as a command line argument
75
+ *
76
+ * should be reported.
77
+ *
78
+ * It doesn't matter if the preset flag's value was the same as the default; from
79
+ * the user's perspective, they want to know their preset was applied.
80
+ */
81
+ function reportPresetApplication(noDefaultsFlags, flagsWithPresets, presetName, preset) {
82
+ const changes = {};
83
+ for (const [name, value] of Object.entries(flagsWithPresets)) {
84
+ const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(noDefaultsFlags, name);
85
+ const presetContainsFlag = Object.prototype.hasOwnProperty.call(preset, name);
86
+ if (!userSpecifiedThisFlag && presetContainsFlag)
87
+ changes[name] = value;
88
+ }
89
+ if (Object.keys(changes).length === 0)
90
+ return;
91
+ info(content `Using applicable flags from the preset ${token.yellow(presetName)}:
92
+
93
+ ${Object.entries(changes)
94
+ .map(([name, value]) => `• ${name} = ${value}`)
95
+ .join('\n')}\n`);
96
+ }
97
+ /**
98
+ * Strips the defaults from configured flags. For example, if flags contains:
99
+ *
100
+ * ```
101
+ * someFlag: Flags.boolean({
102
+ * description: 'some flag',
103
+ * default: false
104
+ * })
105
+ * ```
106
+ *
107
+ * it becomes:
108
+ *
109
+ * ```
110
+ * someFlag: Flags.boolean({
111
+ * description: 'some flag'
112
+ * })
113
+ * ```
114
+ *
115
+ * If we parse using this configuration, the only specified flags will be those
116
+ * the user actually passed on the command line.
117
+ */
118
+ function noDefaultsOptions(options) {
119
+ if (!options?.flags)
120
+ return options;
121
+ return {
122
+ ...options,
123
+ flags: Object.fromEntries(Object.entries(options.flags).map(([label, settings]) => {
124
+ const copiedSettings = { ...settings };
125
+ delete copiedSettings.default;
126
+ return [label, copiedSettings];
127
+ })),
128
+ };
129
+ }
130
+ /**
131
+ * Converts the preset's settings to arguments as though passed on the command
132
+ * line, skipping any arguments the user specified on the command line.
133
+ */
134
+ function argsFromPreset(preset, options, noDefaultsResult) {
135
+ const args = [];
136
+ for (const [label, value] of Object.entries(preset)) {
137
+ const flagIsRelevantToCommand = options?.flags && Object.prototype.hasOwnProperty.call(options.flags, label);
138
+ const userSpecifiedThisFlag = noDefaultsResult.flags && Object.prototype.hasOwnProperty.call(noDefaultsResult.flags, label);
139
+ if (flagIsRelevantToCommand && !userSpecifiedThisFlag) {
140
+ if (typeof value === 'boolean') {
141
+ if (value === true) {
142
+ args.push(`--${label}`);
143
+ }
144
+ else {
145
+ throw new Abort(content `Presets can only specify true for boolean flags. Attempted to set ${token.yellow(label)} to false.`);
146
+ }
147
+ }
148
+ else if (Array.isArray(value)) {
149
+ value.forEach((element) => args.push(`--${label}`, `${element}`));
150
+ }
151
+ else {
152
+ args.push(`--${label}`, `${value}`);
153
+ }
154
+ }
155
+ }
156
+ return args;
157
+ }
158
+ export default BaseCommand;
36
159
  //# 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,EAAE,2CAA2C,EAAC,MAAM,oBAAoB,CAAA;AAC5F,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AACvC,OAAO,EAAC,OAAO,EAAa,MAAM,aAAa,CAAA;AAE/C,MAAe,WAAY,SAAQ,OAAO;IACjC,MAAM,CAAC,qBAAqB;QACjC,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,KAA8C;QACxD,MAAM,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IACxC,CAAC;IAED,8DAA8D;IACpD,KAAK,CAAC,IAAI;QAClB,IAAI,CAAC,aAAa,EAAE,EAAE;YACpB,yCAAyC;YACzC,MAAM,2CAA2C,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;SAC/D;QACD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAA;IACrB,CAAC;IAED,8DAA8D;IACpD,KAAK,CAAC,KAAK,CACnB,OAA8C,EAC9C,IAA2B;QAE3B,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,KAAK,CAAgB,OAAO,EAAE,IAAI,CAAC,CAAA;QAC9D,MAAM,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACtC,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,eAAe,WAAW,CAAA;AAE1B,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,KAAyC;IAChF,MAAM,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC;QACrB,eAAe,EAAE,KAAK,CAAC,OAAO;QAC9B,qBAAqB,EAAE,KAAK,CAAC,IAAI,KAAK,SAAS;QAC/C,0BAA0B,EAAE,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC;KAC1F,CAAC,CAAC,CAAA;AACL,CAAC","sourcesContent":["import {errorHandler, registerCleanBugsnagErrorsFromWithinPlugins} from './error-handler.js'\nimport {isDevelopment} from '../environment/local.js'\nimport {addPublic} from '../metadata.js'\nimport {hashString} from '../string.js'\nimport {Command, Interfaces} from '@oclif/core'\n\nabstract class BaseCommand extends Command {\n public static analyticsNameOverride(): string | undefined {\n return undefined\n }\n\n async catch(error: Error & {exitCode?: number | undefined}) {\n await errorHandler(error, this.config)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected async init(): Promise<any> {\n if (!isDevelopment()) {\n // This function runs just prior to `run`\n await registerCleanBugsnagErrorsFromWithinPlugins(this.config)\n }\n return super.init()\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected async parse<TFlags extends {path?: string; verbose?: boolean}, TArgs extends {[name: string]: any}>(\n options?: Interfaces.Input<TFlags> | undefined,\n argv?: string[] | undefined,\n ): Promise<Interfaces.ParserOutput<TFlags, TArgs>> {\n const result = await super.parse<TFlags, TArgs>(options, argv)\n await addFromParsedFlags(result.flags)\n return result\n }\n}\n\nexport default BaseCommand\n\nexport async function addFromParsedFlags(flags: {path?: string; verbose?: boolean}) {\n await addPublic(() => ({\n cmd_all_verbose: flags.verbose,\n cmd_all_path_override: flags.path !== undefined,\n cmd_all_path_override_hash: flags.path === undefined ? undefined : hashString(flags.path),\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;AAE5F,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAC,MAAM,cAAc,CAAA;AACjD,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AACvC,OAAO,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAC,OAAO,EAAa,MAAM,aAAa,CAAA;AAO/C,MAAe,WAAY,SAAQ,OAAO;IACjC,MAAM,CAAC,qBAAqB;QACjC,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,KAA8C;QACxD,MAAM,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IACxC,CAAC;IAED,8DAA8D;IACpD,KAAK,CAAC,IAAI;QAClB,IAAI,CAAC,aAAa,EAAE,EAAE;YACpB,yCAAyC;YACzC,MAAM,2CAA2C,CAAC,IAAI,CAA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,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QAC5G,MAAM,qBAAqB,GACzB,gBAAgB,CAAC,KAAK,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QAC/F,IAAI,uBAAuB,IAAI,CAAC,qBAAqB,EAAE;YACrD,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;gBAC9B,IAAI,KAAK,KAAK,IAAI,EAAE;oBAClB,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC,CAAA;iBACxB;qBAAM;oBACL,MAAM,IAAI,KAAK,CACb,OAAO,CAAA,qEAAqE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAC5G,CAAA;iBACF;aACF;iBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBAC/B,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAA;aAClE;iBAAM;gBACL,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,CAAC,CAAA;aACpC;SACF;KACF;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,eAAe,WAAW,CAAA","sourcesContent":["import {errorHandler, registerCleanBugsnagErrorsFromWithinPlugins} from './error-handler.js'\nimport {JsonMap} from '../json.js'\nimport {isDevelopment} from '../environment/local.js'\nimport {Abort} from '../error.js'\nimport {addPublic} from '../metadata.js'\nimport {content, info, token} from '../output.js'\nimport {hashString} from '../string.js'\nimport {loadPresetsFromDirectory} from '../public/node/presets.js'\nimport {Command, Interfaces} from '@oclif/core'\n\ninterface PresettableFlags {\n preset?: string\n path?: string\n}\n\nabstract class BaseCommand extends Command {\n public static analyticsNameOverride(): string | undefined {\n return undefined\n }\n\n async catch(error: Error & {exitCode?: number | undefined}) {\n await errorHandler(error, this.config)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected async init(): Promise<any> {\n if (!isDevelopment()) {\n // This function runs just prior to `run`\n await registerCleanBugsnagErrorsFromWithinPlugins(this.config)\n }\n return super.init()\n }\n\n protected async parse<\n TFlags extends Interfaces.FlagOutput & {path?: string; verbose?: boolean},\n TArgs extends Interfaces.OutputArgs,\n >(\n options?: Interfaces.Input<TFlags> | undefined,\n argv?: string[] | undefined,\n ): Promise<Interfaces.ParserOutput<TFlags, TArgs>> {\n let result = await super.parse<TFlags, TArgs>(options, argv)\n result = await this.resultWithPreset<TFlags, TArgs>(options, argv, result)\n await addFromParsedFlags(result.flags)\n return result\n }\n\n protected async resultWithPreset<\n TFlags extends Interfaces.FlagOutput & {path?: string; verbose?: boolean},\n TArgs extends Interfaces.OutputArgs,\n >(\n options: Interfaces.Input<TFlags> | undefined,\n argv: string[] | undefined,\n originalResult: Interfaces.ParserOutput<TFlags, TArgs>,\n ): Promise<Interfaces.ParserOutput<TFlags, TArgs>> {\n // If no preset is specified, don't modify the results\n const flags = originalResult.flags as PresettableFlags\n if (!flags.preset) return originalResult\n\n // If the specified preset isn't found, don't modify the results\n const presets = await loadPresetsFromDirectory(await this.presetsPath(flags), {findUp: this.findUpForPresets()})\n const preset = presets[flags.preset]\n if (!preset) return originalResult\n\n // Parse using noDefaultsOptions to derive a list of flags specified as\n // command-line arguments.\n const noDefaultsResult = await super.parse<TFlags, TArgs>(noDefaultsOptions(options), argv)\n\n // Add the preset's settings to argv and pass them to `super.parse`. This\n // invokes oclif's validation system without breaking the oclif black box.\n // Replace the original result with this one.\n const result = await super.parse<TFlags, TArgs>(options, [\n // Need to specify argv default because we're merging with argsFromPreset.\n ...(argv || this.argv),\n ...argsFromPreset<TFlags, TArgs>(preset, options, noDefaultsResult),\n ])\n\n // Report successful application of the preset.\n reportPresetApplication<TFlags, TArgs>(noDefaultsResult.flags, result.flags, flags.preset, preset)\n\n return result\n }\n\n protected async presetsPath(rawFlags: {path?: string}): Promise<string> {\n return rawFlags.path || process.cwd()\n }\n\n protected findUpForPresets(): boolean {\n return true\n }\n}\n\nexport async function addFromParsedFlags(flags: {path?: string; verbose?: boolean}) {\n await addPublic(() => ({\n cmd_all_verbose: flags.verbose,\n cmd_all_path_override: flags.path !== undefined,\n cmd_all_path_override_hash: flags.path === undefined ? undefined : hashString(flags.path),\n }))\n}\n\n/**\n * Any flag which is:\n *\n * 1. Present in the final set of flags\n * 2. Specified in the preset\n * 3. Not specified by the user as a command line argument\n *\n * should be reported.\n *\n * It doesn't matter if the preset flag's value was the same as the default; from\n * the user's perspective, they want to know their preset was applied.\n */\nfunction reportPresetApplication<TFlags extends Interfaces.FlagOutput, TArgs extends Interfaces.OutputArgs>(\n noDefaultsFlags: Interfaces.ParserOutput<TFlags, TArgs>['flags'],\n flagsWithPresets: Interfaces.ParserOutput<TFlags, TArgs>['flags'],\n presetName: string,\n preset: JsonMap,\n): void {\n const changes: JsonMap = {}\n for (const [name, value] of Object.entries(flagsWithPresets)) {\n const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(noDefaultsFlags, name)\n const presetContainsFlag = Object.prototype.hasOwnProperty.call(preset, name)\n if (!userSpecifiedThisFlag && presetContainsFlag) changes[name] = value\n }\n if (Object.keys(changes).length === 0) return\n info(content`Using applicable flags from the preset ${token.yellow(presetName)}:\n\n${Object.entries(changes)\n .map(([name, value]) => `• ${name} = ${value}`)\n .join('\\n')}\\n`)\n}\n\n/**\n * Strips the defaults from configured flags. For example, if flags contains:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag',\n * default: false\n * })\n * ```\n *\n * it becomes:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag'\n * })\n * ```\n *\n * If we parse using this configuration, the only specified flags will be those\n * the user actually passed on the command line.\n */\n\nfunction noDefaultsOptions<TFlags extends Interfaces.FlagOutput>(\n options: Interfaces.Input<TFlags> | undefined,\n): Interfaces.Input<TFlags> | undefined {\n if (!options?.flags) return options\n return {\n ...options,\n flags: Object.fromEntries(\n Object.entries(options.flags).map(([label, settings]) => {\n const copiedSettings = {...(settings as {default?: unknown})}\n delete copiedSettings.default\n return [label, copiedSettings]\n }),\n ) as Interfaces.FlagInput<TFlags>,\n }\n}\n\n/**\n * Converts the preset's settings to arguments as though passed on the command\n * line, skipping any arguments the user specified on the command line.\n */\nfunction argsFromPreset<TFlags extends Interfaces.FlagOutput, TArgs extends Interfaces.OutputArgs>(\n preset: JsonMap,\n options: Interfaces.Input<TFlags> | undefined,\n noDefaultsResult: Interfaces.ParserOutput<TFlags, TArgs>,\n): string[] {\n const args: string[] = []\n for (const [label, value] of Object.entries(preset)) {\n const flagIsRelevantToCommand = options?.flags && Object.prototype.hasOwnProperty.call(options.flags, label)\n const userSpecifiedThisFlag =\n noDefaultsResult.flags && Object.prototype.hasOwnProperty.call(noDefaultsResult.flags, label)\n if (flagIsRelevantToCommand && !userSpecifiedThisFlag) {\n if (typeof value === 'boolean') {\n if (value === true) {\n args.push(`--${label}`)\n } else {\n throw new Abort(\n content`Presets can only specify true for boolean flags. Attempted to set ${token.yellow(label)} to false.`,\n )\n }\n } else if (Array.isArray(value)) {\n value.forEach((element) => args.push(`--${label}`, `${element}`))\n } else {\n args.push(`--${label}`, `${value}`)\n }\n }\n }\n return args\n}\n\nexport default BaseCommand\n"]}
package/dist/node/cli.js CHANGED
@@ -29,7 +29,9 @@ export async function runCLI(options) {
29
29
  if (isDevelopment()) {
30
30
  settings.debug = true;
31
31
  }
32
- run(undefined, options.moduleURL).then(flush).catch(errorHandler);
32
+ run(undefined, options.moduleURL)
33
+ .then(() => flush())
34
+ .catch(errorHandler);
33
35
  }
34
36
  /**
35
37
  * A function for create-x CLIs that automatically runs the "init" command.
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/node/cli.ts"],"names":[],"mappings":"AAWA,SAAS,yBAAyB,CAAC,OAA2C;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AC3C,qDAAqD;KACtD;IAAC,OAAO,GAAG,EAAE;QACZ,OAAM;KACP;IACD,MAAM,gBAAgB,GAAG;QACvB,GAAG,eAAe,CAAC,gBAAgB;QACnC,GAAG,eAAe,CAAC,eAAe;QAClC,GAAG,eAAe,CAAC,YAAY;KAChC,CAAA;IACD,OAAO,gBAAgB,CAAC,cAAc,CAAC,CAAA;AACzC,CAAC;AAED,eAAe,MAAM,CAAA","sourcesContent":["/**\n * IMPORTANT NOTE: Imports in this module are dynamic to ensure that \"setupEnvironmentVariables\" can dynamically\n * set the DEBUG environment variable before the 'debug' package sets up its configuration when modules\n * are loaded statically.\n */\ninterface RunCLIOptions {\n /** The value of import.meta.url of the CLI executable module */\n moduleURL: string\n development: boolean\n}\n\nfunction setupEnvironmentVariables(options: Pick<RunCLIOptions, 'development'>) {\n /**\n * By setting DEBUG=* when --verbose is passed we are increasing the\n * verbosity of oclif. Oclif uses debug (https://www.npmjs.com/package/debug)\n * for logging, and it's configured through the DEBUG= environment variable.\n */\n if (process.argv.includes('--verbose')) {\n process.env.DEBUG = process.env.DEBUG ?? '*'\n }\n if (options.development) {\n process.env.SHOPIFY_CLI_ENV = process.env.SHOPIFY_CLI_ENV ?? 'development'\n }\n}\n\n/**\n * A function that abstracts away setting up the environment and running\n * a CLI\n * @param options - Options.\n */\nexport async function runCLI(options: RunCLIOptions) {\n setupEnvironmentVariables(options)\n /**\n * These imports need to be dynamic because if they are static\n * they are loaded before we set the DEBUG=* environment variable\n * and therefore it has no effect.\n */\n const {errorHandler} = await import('./error-handler.js')\n const {isDevelopment} = await import('../environment/local.js')\n const {run, settings, flush} = await import('@oclif/core')\n\n if (isDevelopment()) {\n settings.debug = true\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 */\nexport async function runCreateCLI(options: RunCLIOptions) {\n setupEnvironmentVariables(options)\n\n const {findUpAndReadPackageJson} = await import('./node-package-manager.js')\n const {moduleDirectory} = await import('../path.js')\n\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 async function useLocalCLIIfDetected(filepath: string): Promise<boolean> {\n const {isTruthy} = await import('../environment/utilities.js')\n const constants = await import('../constants.js')\n const {join} = await import('../path.js')\n const {exec} = await import('../system.js')\n\n // Temporary flag while we test out this feature and ensure it won't break anything!\n if (!isTruthy(process.env[constants.default.environmentVariables.enableCliRedirect])) return false\n\n // Setting an env variable in the child process prevents accidental recursion.\n if (isTruthy(process.env[constants.default.environmentVariables.skipCliRedirect])) return false\n\n // If already running via package manager, we can assume it's running correctly already.\n if (process.env.npm_config_user_agent) return false\n\n const cliPackage = await localCliPackage()\n if (!cliPackage) return false\n\n const correctExecutablePath = join(cliPackage.path, cliPackage.bin.shopify)\n if (correctExecutablePath === filepath) return false\n try {\n await exec(correctExecutablePath, process.argv.slice(2, process.argv.length), {\n stdio: 'inherit',\n env: {[constants.default.environmentVariables.skipCliRedirect]: '1'},\n })\n // eslint-disable-next-line no-catch-all/no-catch-all, @typescript-eslint/no-explicit-any\n } catch (processError: any) {\n process.exit(processError.exitCode)\n }\n return true\n}\n\ninterface CliPackageInfo {\n path: string\n bin: {shopify: string}\n}\n\ninterface PackageJSON {\n dependencies?: {[packageName: string]: CliPackageInfo}\n devDependencies?: {[packageName: string]: CliPackageInfo}\n peerDependencies?: {[packageName: string]: CliPackageInfo}\n}\n\nexport async function localCliPackage(): Promise<CliPackageInfo | undefined> {\n const {captureOutput} = await import('../system.js')\n\n let npmListOutput = ''\n let localShopifyCLI: PackageJSON = {}\n try {\n npmListOutput = await captureOutput('npm', ['list', '@shopify/cli', '--json', '-l'])\n localShopifyCLI = JSON.parse(npmListOutput)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (err) {\n return\n }\n const dependenciesList = {\n ...localShopifyCLI.peerDependencies,\n ...localShopifyCLI.devDependencies,\n ...localShopifyCLI.dependencies,\n }\n return dependenciesList['@shopify/cli']\n}\n\nexport default runCLI\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/node/cli.ts"],"names":[],"mappings":"AAWA,SAAS,yBAAyB,CAAC,OAA2C;IAC5E;;;;OAIG;IACH,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QACtC,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAA;KAC7C;IACD,IAAI,OAAO,CAAC,WAAW,EAAE;QACvB,OAAO,CAAC,GAAG,CAAC,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,aAAa,CAAA;KAC3E;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAsB;IACjD,yBAAyB,CAAC,OAAO,CAAC,CAAA;IAClC;;;;OAIG;IACH,MAAM,EAAC,YAAY,EAAC,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAA;IACzD,MAAM,EAAC,aAAa,EAAC,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAA;IAC/D,MAAM,EAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAC,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAA;IAE1D,IAAI,aAAa,EAAE,EAAE;QACnB,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAA;KACtB;IAED,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC;SAC9B,IAAI,CAAC,GAAG,E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KACpC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAaD,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,MAAM,EAAC,aAAa,EAAC,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAA;IAEpD,IAAI,aAAa,GAAG,EAAE,CAAA;IACtB,IAAI,eAAe,GAAgB,EAAE,CAAA;IACrC,IAAI;QACF,aAAa,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAA;QACpF,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;QAC3C,qDAAqD;KACtD;IAAC,OAAO,GAAG,EAAE;QACZ,OAAM;KACP;IACD,MAAM,gBAAgB,GAAG;QACvB,GAAG,eAAe,CAAC,gBAAgB;QACnC,GAAG,eAAe,CAAC,eAAe;QAClC,GAAG,eAAe,CAAC,YAAY;KAChC,CAAA;IACD,OAAO,gBAAgB,CAAC,cAAc,CAAC,CAAA;AACzC,CAAC;AAED,eAAe,MAAM,CAAA","sourcesContent":["/**\n * IMPORTANT NOTE: Imports in this module are dynamic to ensure that \"setupEnvironmentVariables\" can dynamically\n * set the DEBUG environment variable before the 'debug' package sets up its configuration when modules\n * are loaded statically.\n */\ninterface RunCLIOptions {\n /** The value of import.meta.url of the CLI executable module */\n moduleURL: string\n development: boolean\n}\n\nfunction setupEnvironmentVariables(options: Pick<RunCLIOptions, 'development'>) {\n /**\n * By setting DEBUG=* when --verbose is passed we are increasing the\n * verbosity of oclif. Oclif uses debug (https://www.npmjs.com/package/debug)\n * for logging, and it's configured through the DEBUG= environment variable.\n */\n if (process.argv.includes('--verbose')) {\n process.env.DEBUG = process.env.DEBUG ?? '*'\n }\n if (options.development) {\n process.env.SHOPIFY_CLI_ENV = process.env.SHOPIFY_CLI_ENV ?? 'development'\n }\n}\n\n/**\n * A function that abstracts away setting up the environment and running\n * a CLI\n * @param options - Options.\n */\nexport async function runCLI(options: RunCLIOptions) {\n setupEnvironmentVariables(options)\n /**\n * These imports need to be dynamic because if they are static\n * they are loaded before we set the DEBUG=* environment variable\n * and therefore it has no effect.\n */\n const {errorHandler} = await import('./error-handler.js')\n const {isDevelopment} = await import('../environment/local.js')\n const {run, settings, flush} = await import('@oclif/core')\n\n if (isDevelopment()) {\n settings.debug = true\n }\n\n run(undefined, options.moduleURL)\n .then(() => flush())\n .catch(errorHandler)\n}\n\n/**\n * A function for create-x CLIs that automatically runs the \"init\" command.\n */\nexport async function runCreateCLI(options: RunCLIOptions) {\n setupEnvironmentVariables(options)\n\n const {findUpAndReadPackageJson} = await import('./node-package-manager.js')\n const {moduleDirectory} = await import('../path.js')\n\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 async function useLocalCLIIfDetected(filepath: string): Promise<boolean> {\n const {isTruthy} = await import('../environment/utilities.js')\n const constants = await import('../constants.js')\n const {join} = await import('../path.js')\n const {exec} = await import('../system.js')\n\n // Temporary flag while we test out this feature and ensure it won't break anything!\n if (!isTruthy(process.env[constants.default.environmentVariables.enableCliRedirect])) return false\n\n // Setting an env variable in the child process prevents accidental recursion.\n if (isTruthy(process.env[constants.default.environmentVariables.skipCliRedirect])) return false\n\n // If already running via package manager, we can assume it's running correctly already.\n if (process.env.npm_config_user_agent) return false\n\n const cliPackage = await localCliPackage()\n if (!cliPackage) return false\n\n const correctExecutablePath = join(cliPackage.path, cliPackage.bin.shopify)\n if (correctExecutablePath === filepath) return false\n try {\n await exec(correctExecutablePath, process.argv.slice(2, process.argv.length), {\n stdio: 'inherit',\n env: {[constants.default.environmentVariables.skipCliRedirect]: '1'},\n })\n // eslint-disable-next-line no-catch-all/no-catch-all, @typescript-eslint/no-explicit-any\n } catch (processError: any) {\n process.exit(processError.exitCode)\n }\n return true\n}\n\ninterface CliPackageInfo {\n path: string\n bin: {shopify: string}\n}\n\ninterface PackageJSON {\n dependencies?: {[packageName: string]: CliPackageInfo}\n devDependencies?: {[packageName: string]: CliPackageInfo}\n peerDependencies?: {[packageName: string]: CliPackageInfo}\n}\n\nexport async function localCliPackage(): Promise<CliPackageInfo | undefined> {\n const {captureOutput} = await import('../system.js')\n\n let npmListOutput = ''\n let localShopifyCLI: PackageJSON = {}\n try {\n npmListOutput = await captureOutput('npm', ['list', '@shopify/cli', '--json', '-l'])\n localShopifyCLI = JSON.parse(npmListOutput)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (err) {\n return\n }\n const dependenciesList = {\n ...localShopifyCLI.peerDependencies,\n ...localShopifyCLI.devDependencies,\n ...localShopifyCLI.dependencies,\n }\n return dependenciesList['@shopify/cli']\n}\n\nexport default runCLI\n"]}