@shopify/cli-kit 3.6.2 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +61 -0
- package/dist/analytics.d.ts +11 -1
- package/dist/analytics.js +33 -23
- package/dist/analytics.js.map +1 -1
- package/dist/api/admin.js.map +1 -1
- package/dist/api/common.d.ts +1 -1
- package/dist/api/common.js +1 -1
- package/dist/api/common.js.map +1 -1
- package/dist/api/graphql/extension_specifications.js.map +1 -1
- package/dist/api/graphql/functions/app_function_set.d.ts +9 -23
- package/dist/api/graphql/functions/app_function_set.js +18 -27
- package/dist/api/graphql/functions/app_function_set.js.map +1 -1
- package/dist/api/graphql/functions/upload_url_generate.d.ts +12 -0
- package/dist/api/graphql/functions/upload_url_generate.js +11 -0
- package/dist/api/graphql/functions/upload_url_generate.js.map +1 -0
- package/dist/api/graphql/get_urls.d.ts +10 -0
- package/dist/api/graphql/get_urls.js +10 -0
- package/dist/api/graphql/get_urls.js.map +1 -0
- package/dist/api/graphql/index.d.ts +19 -14
- package/dist/api/graphql/index.js +19 -14
- package/dist/api/graphql/index.js.map +1 -1
- package/dist/api/graphql/update_draft.js.map +1 -1
- package/dist/api/graphql/update_urls.d.ts +2 -2
- package/dist/api/graphql/update_urls.js +2 -2
- package/dist/api/graphql/update_urls.js.map +1 -1
- package/dist/array.d.ts +1 -1
- package/dist/constants.d.ts +3 -1
- package/dist/constants.js +3 -1
- package/dist/constants.js.map +1 -1
- package/dist/content-tokens.d.ts +44 -0
- package/dist/content-tokens.js +103 -0
- package/dist/content-tokens.js.map +1 -0
- package/dist/environment/local.d.ts +19 -2
- package/dist/environment/local.js +45 -5
- package/dist/environment/local.js.map +1 -1
- package/dist/environment/utilities.d.ts +4 -0
- package/dist/environment/utilities.js +9 -0
- package/dist/environment/utilities.js.map +1 -1
- package/dist/error.d.ts +4 -4
- package/dist/error.js +16 -4
- package/dist/error.js.map +1 -1
- package/dist/file.d.ts +9 -1
- package/dist/file.js +15 -2
- package/dist/file.js.map +1 -1
- package/dist/git.js.map +1 -1
- package/dist/github.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/metadata.d.ts +180 -12
- package/dist/metadata.js +39 -6
- package/dist/metadata.js.map +1 -1
- package/dist/monorail.d.ts +48 -1
- package/dist/monorail.js +2 -1
- package/dist/monorail.js.map +1 -1
- package/dist/node/archiver.js +1 -0
- package/dist/node/archiver.js.map +1 -1
- package/dist/node/base-command.d.ts +11 -1
- package/dist/node/base-command.js +19 -4
- package/dist/node/base-command.js.map +1 -1
- package/dist/node/checksum.js.map +1 -1
- package/dist/node/cli.js +2 -2
- package/dist/node/cli.js.map +1 -1
- package/dist/node/dot-env.d.ts +9 -0
- package/dist/node/dot-env.js +31 -0
- package/dist/node/dot-env.js.map +1 -1
- package/dist/node/error-handler.d.ts +14 -2
- package/dist/node/error-handler.js +58 -13
- package/dist/node/error-handler.js.map +1 -1
- package/dist/node/hooks/prerun.js +1 -1
- package/dist/node/hooks/prerun.js.map +1 -1
- package/dist/node/node-package-manager.d.ts +12 -18
- package/dist/node/node-package-manager.js +23 -14
- package/dist/node/node-package-manager.js.map +1 -1
- package/dist/node/ruby.js +2 -1
- package/dist/node/ruby.js.map +1 -1
- package/dist/output.d.ts +22 -43
- package/dist/output.js +31 -91
- package/dist/output.js.map +1 -1
- package/dist/path.d.ts +1 -0
- package/dist/plugins/tunnel.d.ts +40 -0
- package/dist/plugins/tunnel.js +11 -0
- package/dist/plugins/tunnel.js.map +1 -0
- package/dist/plugins.d.ts +11 -13
- package/dist/plugins.js +0 -1
- package/dist/plugins.js.map +1 -1
- package/dist/session/authorize.js +1 -1
- package/dist/session/authorize.js.map +1 -1
- package/dist/session/exchange.js +1 -2
- package/dist/session/exchange.js.map +1 -1
- package/dist/session/post-auth.js +7 -1
- package/dist/session/post-auth.js.map +1 -1
- package/dist/session/redirect-listener.js +6 -5
- package/dist/session/redirect-listener.js.map +1 -1
- package/dist/session/validate.js.map +1 -1
- package/dist/session.js +1 -1
- package/dist/session.js.map +1 -1
- package/dist/store.d.ts +4 -2
- package/dist/store.js +3 -4
- package/dist/store.js.map +1 -1
- package/dist/string.d.ts +1 -0
- package/dist/string.js +3 -0
- package/dist/string.js.map +1 -1
- package/dist/system.d.ts +2 -2
- package/dist/testing/output.js +6 -6
- package/dist/testing/output.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typing/deep-required.d.ts +12 -0
- package/dist/typing/deep-required.js +2 -0
- package/dist/typing/deep-required.js.map +1 -0
- package/dist/typing/pick-by-prefix.d.ts +12 -0
- package/dist/typing/pick-by-prefix.js +2 -0
- package/dist/typing/pick-by-prefix.js.map +1 -0
- package/dist/ui/executor.d.ts +14 -0
- package/dist/ui/executor.js +88 -0
- package/dist/ui/executor.js.map +1 -0
- package/dist/ui/inquirer/autocomplete.d.ts +11 -0
- package/dist/ui/inquirer/autocomplete.js +105 -0
- package/dist/ui/inquirer/autocomplete.js.map +1 -0
- package/dist/ui/inquirer/input.d.ts +16 -0
- package/dist/ui/inquirer/input.js +46 -0
- package/dist/ui/inquirer/input.js.map +1 -0
- package/dist/ui/inquirer/password.d.ts +7 -0
- package/dist/ui/inquirer/password.js +8 -0
- package/dist/ui/inquirer/password.js.map +1 -0
- package/dist/ui/inquirer/select.d.ts +14 -0
- package/dist/ui/inquirer/select.js +27 -0
- package/dist/ui/inquirer/select.js.map +1 -0
- package/dist/ui.d.ts +12 -23
- package/dist/ui.js +14 -61
- package/dist/ui.js.map +1 -1
- package/dist/version.d.ts +1 -0
- package/package.json +23 -13
- package/dist/api/graphql/functions/module_upload_url_generate.d.ts +0 -18
- package/dist/api/graphql/functions/module_upload_url_generate.js +0 -17
- package/dist/api/graphql/functions/module_upload_url_generate.js.map +0 -1
- package/dist/ui/autocomplete.d.ts +0 -7
- package/dist/ui/autocomplete.js +0 -43
- package/dist/ui/autocomplete.js.map +0 -1
- package/dist/ui/input.d.ts +0 -7
- package/dist/ui/input.js +0 -48
- package/dist/ui/input.js.map +0 -1
- package/dist/ui/select.d.ts +0 -6
- package/dist/ui/select.js +0 -30
- package/dist/ui/select.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/graphql/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/graphql/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAA;AACpD,cAAc,sCAAsC,CAAA;AACpD,cAAc,eAAe,CAAA;AAC7B,cAAc,wBAAwB,CAAA;AACtC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,eAAe,CAAA;AAC7B,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,2BAA2B,CAAA;AACzC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,uCAAuC,CAAA;AACrD,cAAc,uCAAuC,CAAA;AACrD,cAAc,kCAAkC,CAAA;AAChD,cAAc,kCAAkC,CAAA;AAChD,cAAc,0CAA0C,CAAA;AACxD,cAAc,oCAAoC,CAAA;AAClD,cAAc,iCAAiC,CAAA;AAC/C,cAAc,eAAe,CAAA;AAC7B,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA","sourcesContent":["export * from './all_app_extension_registrations.js'\nexport * from './all_app_extension_registrations.js'\nexport * from './all_orgs.js'\nexport * from './all_stores_by_org.js'\nexport * from './convert_dev_to_test_store.js'\nexport * from './create_app.js'\nexport * from './create_deployment.js'\nexport * from './extension_create.js'\nexport * from './extension_specifications.js'\nexport * from './find_app.js'\nexport * from './find_org_basic.js'\nexport * from './find_org.js'\nexport * from './find_store_by_domain.js'\nexport * from './functions/app_function_set.js'\nexport * from './functions/compile_module.js'\nexport * from './functions/function_service_proxy.js'\nexport * from './functions/function_service_proxy.js'\nexport * from './functions/get_app_functions.js'\nexport * from './functions/get_app_functions.js'\nexport * from './functions/module_compilation_status.js'\nexport * from './functions/upload_url_generate.js'\nexport * from './generate_signed_upload_url.js'\nexport * from './get_urls.js'\nexport * from './get_variant_id.js'\nexport * from './get_variant_id.js'\nexport * from './update_draft.js'\nexport * from './update_urls.js'\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update_draft.js","sourceRoot":"","sources":["../../../src/api/graphql/update_draft.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAEnC,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;CAqB9C,CAAA","sourcesContent":["import {gql} from 'graphql-request'\n\nexport const ExtensionUpdateDraftMutation = gql`\n mutation ExtensionUpdateDraft($apiKey: String!, $registrationId: ID!, $config: JSON!, $context: String) {\n extensionUpdateDraft(\n input: {apiKey: $apiKey, registrationId: $registrationId, config: $config, context: $context}\n ) {\n extensionVersion {\n registrationId\n context\n lastUserInteractionAt\n location\n validationErrors {\n field\n message\n }\n }\n userErrors {\n field\n message\n }\n }\n }\n`\n\nexport interface ExtensionUpdateDraftInput {\n apiKey: string\n config: string\n // not all extensions require configs, e.g. subscription\n context: string | undefined\n registrationId: string\n}\n\n// \"\"\"\n// Autogenerated return type of ExtensionUpdateDraft\n// \"\"\"\nexport interface ExtensionUpdateDraftPayload {\n // \"\"\"\n // A unique identifier for the client performing the mutation.\n // \"\"\"\n clientMutationId: string\n extensionVersion: ExtensionVersion\n // userErrors: [UserError]\n userErrors: {\n field: string[]\n message: string\n }[]\n}\n\n// \"\"\"\n// A particular version of an extension belonging to a Shopify Partner App.\n// \"\"\"\nexport interface ExtensionVersion {\n // \"\"\"\n // The serialized JSON config for the extension version\n // \"\"\"\n config: string\n\n // \"\"\"\n // The context of an extension version, indicating where it will be rendered\n // \"\"\"\n context: string\n\n // \"\"\"\n // The unique identifier of the extension version\n // \"\"\"\n // id: ID\n id: string\n\n // \"\"\"\n // The last time a user updated an extension version\n // \"\"\"\n // lastUserInteractionAt: DateTime\n lastUserInteractionAt: string\n\n // \"\"\"\n // The URL to view the app extension version in the
|
|
1
|
+
{"version":3,"file":"update_draft.js","sourceRoot":"","sources":["../../../src/api/graphql/update_draft.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAEnC,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;CAqB9C,CAAA","sourcesContent":["import {gql} from 'graphql-request'\n\nexport const ExtensionUpdateDraftMutation = gql`\n mutation ExtensionUpdateDraft($apiKey: String!, $registrationId: ID!, $config: JSON!, $context: String) {\n extensionUpdateDraft(\n input: {apiKey: $apiKey, registrationId: $registrationId, config: $config, context: $context}\n ) {\n extensionVersion {\n registrationId\n context\n lastUserInteractionAt\n location\n validationErrors {\n field\n message\n }\n }\n userErrors {\n field\n message\n }\n }\n }\n`\n\nexport interface ExtensionUpdateDraftInput {\n apiKey: string\n config: string\n // not all extensions require configs, e.g. subscription\n context: string | undefined\n registrationId: string\n}\n\n// \"\"\"\n// Autogenerated return type of ExtensionUpdateDraft\n// \"\"\"\nexport interface ExtensionUpdateDraftPayload {\n // \"\"\"\n // A unique identifier for the client performing the mutation.\n // \"\"\"\n clientMutationId: string\n extensionVersion: ExtensionVersion\n // userErrors: [UserError]\n userErrors: {\n field: string[]\n message: string\n }[]\n}\n\n// \"\"\"\n// A particular version of an extension belonging to a Shopify Partner App.\n// \"\"\"\nexport interface ExtensionVersion {\n // \"\"\"\n // The serialized JSON config for the extension version\n // \"\"\"\n config: string\n\n // \"\"\"\n // The context of an extension version, indicating where it will be rendered\n // \"\"\"\n context: string\n\n // \"\"\"\n // The unique identifier of the extension version\n // \"\"\"\n // id: ID\n id: string\n\n // \"\"\"\n // The last time a user updated an extension version\n // \"\"\"\n // lastUserInteractionAt: DateTime\n lastUserInteractionAt: string\n\n // \"\"\"\n // The URL to view the app extension version in the Partners Dashboard\n // \"\"\"\n // location: Url\n location: string\n\n // \"\"\"\n // The unique identifier of the extension registration this version belongs to\n // \"\"\"\n // registrationId: ID\n registrationId: string\n\n // \"\"\"\n // The uuid of the extension registration this version belongs to\n // \"\"\"\n registrationUuid: string\n\n // \"\"\"\n // The uuid of the extension version\n // \"\"\"\n uuid: string\n\n // \"\"\"\n // The validation errors for an extension version\n // \"\"\"\n // validationErrors: [ValidationError]\n validationErrors: {\n field: string[]\n message: string\n }[]\n\n // \"\"\"\n // The version tag of the extension version\n // \"\"\"\n versionTag: string\n}\n\nexport interface ExtensionUpdateSchema {\n extensionUpdateDraft: ExtensionUpdateDraftPayload\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const UpdateURLsQuery: string;
|
|
2
2
|
export interface UpdateURLsQueryVariables {
|
|
3
3
|
apiKey: string;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
applicationUrl: string;
|
|
5
|
+
redirectUrlWhitelist: string[];
|
|
6
6
|
}
|
|
7
7
|
export interface UpdateURLsQuerySchema {
|
|
8
8
|
appUpdate: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { gql } from 'graphql-request';
|
|
2
2
|
export const UpdateURLsQuery = gql `
|
|
3
|
-
mutation appUpdate($apiKey: String!, $
|
|
4
|
-
appUpdate(input: {apiKey: $apiKey, applicationUrl: $
|
|
3
|
+
mutation appUpdate($apiKey: String!, $applicationUrl: Url!, $redirectUrlWhitelist: [Url]!) {
|
|
4
|
+
appUpdate(input: {apiKey: $apiKey, applicationUrl: $applicationUrl, redirectUrlWhitelist: $redirectUrlWhitelist}) {
|
|
5
5
|
userErrors {
|
|
6
6
|
message
|
|
7
7
|
field
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update_urls.js","sourceRoot":"","sources":["../../../src/api/graphql/update_urls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAEnC,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAA;;;;;;;;;CASjC,CAAA","sourcesContent":["import {gql} from 'graphql-request'\n\nexport const UpdateURLsQuery = gql`\n mutation appUpdate($apiKey: String!, $
|
|
1
|
+
{"version":3,"file":"update_urls.js","sourceRoot":"","sources":["../../../src/api/graphql/update_urls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAEnC,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAA;;;;;;;;;CASjC,CAAA","sourcesContent":["import {gql} from 'graphql-request'\n\nexport const UpdateURLsQuery = gql`\n mutation appUpdate($apiKey: String!, $applicationUrl: Url!, $redirectUrlWhitelist: [Url]!) {\n appUpdate(input: {apiKey: $apiKey, applicationUrl: $applicationUrl, redirectUrlWhitelist: $redirectUrlWhitelist}) {\n userErrors {\n message\n field\n }\n }\n }\n`\n\nexport interface UpdateURLsQueryVariables {\n apiKey: string\n applicationUrl: string\n redirectUrlWhitelist: string[]\n}\n\nexport interface UpdateURLsQuerySchema {\n appUpdate: {\n userErrors: {\n field: string[]\n message: string\n }[]\n }\n}\n"]}
|
package/dist/array.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function randomPick<T>(array: T[]): T;
|
|
1
|
+
export declare function randomPick<T>(array: T[]): T | undefined;
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare const constants: {
|
|
2
2
|
environmentVariables: {
|
|
3
3
|
unitTest: string;
|
|
4
|
-
|
|
4
|
+
env: string;
|
|
5
5
|
runAsUser: string;
|
|
6
6
|
partnersEnv: string;
|
|
7
7
|
shopifyEnv: string;
|
|
@@ -14,7 +14,9 @@ declare const constants: {
|
|
|
14
14
|
partnersToken: string;
|
|
15
15
|
verbose: string;
|
|
16
16
|
noAnalytics: string;
|
|
17
|
+
alwaysLogAnalytics: string;
|
|
17
18
|
firstPartyDev: string;
|
|
19
|
+
debugGoBinary: string;
|
|
18
20
|
};
|
|
19
21
|
paths: {
|
|
20
22
|
executables: {
|
package/dist/constants.js
CHANGED
|
@@ -10,7 +10,7 @@ const cacheFolder = () => {
|
|
|
10
10
|
const constants = {
|
|
11
11
|
environmentVariables: {
|
|
12
12
|
unitTest: 'SHOPIFY_UNIT_TEST',
|
|
13
|
-
|
|
13
|
+
env: 'SHOPIFY_ENV',
|
|
14
14
|
runAsUser: 'SHOPIFY_RUN_AS_USER',
|
|
15
15
|
partnersEnv: 'SHOPIFY_PARTNERS_ENV',
|
|
16
16
|
shopifyEnv: 'SHOPIFY_SHOPIFY_ENV',
|
|
@@ -23,7 +23,9 @@ const constants = {
|
|
|
23
23
|
partnersToken: 'SHOPIFY_CLI_PARTNERS_TOKEN',
|
|
24
24
|
verbose: 'SHOPIFY_FLAG_VERBOSE',
|
|
25
25
|
noAnalytics: 'SHOPIFY_CLI_NO_ANALYTICS',
|
|
26
|
+
alwaysLogAnalytics: 'SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS',
|
|
26
27
|
firstPartyDev: 'SHOPIFY_CLI_1P_DEV',
|
|
28
|
+
debugGoBinary: 'SHOPIFY_DEBUG_GO_BINARY',
|
|
27
29
|
},
|
|
28
30
|
paths: {
|
|
29
31
|
executables: {
|
package/dist/constants.js.map
CHANGED
|
@@ -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,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;QAC/B,WAAW,EAAE,0BAA0B;QACvC,kBAAkB,EAAE,kCAAkC;QACtD,aAAa,EAAE,oBAAoB;QACnC,aAAa,EAAE,yBAAyB;KACzC;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 unitTest: 'SHOPIFY_UNIT_TEST',\n env: 'SHOPIFY_ENV',\n runAsUser: 'SHOPIFY_RUN_AS_USER',\n partnersEnv: 'SHOPIFY_PARTNERS_ENV',\n shopifyEnv: 'SHOPIFY_SHOPIFY_ENV',\n identityEnv: 'SHOPIFY_IDENTITY_ENV',\n spin: 'SPIN',\n spinInstance: 'SPIN_INSTANCE',\n spinWorkspace: 'SPIN_WORKSPACE',\n spinNamespace: 'SPIN_NAMESPACE',\n spinHost: 'SPIN_HOST',\n partnersToken: 'SHOPIFY_CLI_PARTNERS_TOKEN',\n verbose: 'SHOPIFY_FLAG_VERBOSE',\n noAnalytics: 'SHOPIFY_CLI_NO_ANALYTICS',\n alwaysLogAnalytics: 'SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS',\n firstPartyDev: 'SHOPIFY_CLI_1P_DEV',\n debugGoBinary: 'SHOPIFY_DEBUG_GO_BINARY',\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"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Message } from './output.js';
|
|
2
|
+
import type { Change } from 'diff';
|
|
3
|
+
export declare abstract class ContentToken<T> {
|
|
4
|
+
value: T;
|
|
5
|
+
constructor(value: T);
|
|
6
|
+
abstract output(): string | string[];
|
|
7
|
+
}
|
|
8
|
+
export declare class RawContentToken extends ContentToken<string> {
|
|
9
|
+
output(): string;
|
|
10
|
+
}
|
|
11
|
+
export declare class LinkContentToken extends ContentToken<Message> {
|
|
12
|
+
link: string;
|
|
13
|
+
constructor(value: Message, link: string);
|
|
14
|
+
output(): string;
|
|
15
|
+
}
|
|
16
|
+
export declare class CommandContentToken extends ContentToken<Message> {
|
|
17
|
+
output(): string;
|
|
18
|
+
}
|
|
19
|
+
export declare class JsonContentToken extends ContentToken<any> {
|
|
20
|
+
output(): string;
|
|
21
|
+
}
|
|
22
|
+
export declare class LinesDiffContentToken extends ContentToken<Change[]> {
|
|
23
|
+
output(): string[];
|
|
24
|
+
}
|
|
25
|
+
export declare class ColorContentToken extends ContentToken<Message> {
|
|
26
|
+
color: (text: string) => string;
|
|
27
|
+
constructor(value: Message, color: (text: string) => string);
|
|
28
|
+
output(): string;
|
|
29
|
+
}
|
|
30
|
+
export declare class ErrorContentToken extends ContentToken<Message> {
|
|
31
|
+
output(): string;
|
|
32
|
+
}
|
|
33
|
+
export declare class PathContentToken extends ContentToken<Message> {
|
|
34
|
+
output(): string;
|
|
35
|
+
}
|
|
36
|
+
export declare class HeadingContentToken extends ContentToken<Message> {
|
|
37
|
+
output(): string;
|
|
38
|
+
}
|
|
39
|
+
export declare class SubHeadingContentToken extends ContentToken<Message> {
|
|
40
|
+
output(): string;
|
|
41
|
+
}
|
|
42
|
+
export declare class ItalicContentToken extends ContentToken<Message> {
|
|
43
|
+
output(): string;
|
|
44
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { relativize as relativizePath } from './path.js';
|
|
2
|
+
import { colors } from './node/colors.js';
|
|
3
|
+
import { stringifyMessage } from './output.js';
|
|
4
|
+
import terminalLink from 'terminal-link';
|
|
5
|
+
import cjs from 'color-json';
|
|
6
|
+
export class ContentToken {
|
|
7
|
+
constructor(value) {
|
|
8
|
+
this.value = value;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export class RawContentToken extends ContentToken {
|
|
12
|
+
output() {
|
|
13
|
+
return this.value;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export class LinkContentToken extends ContentToken {
|
|
17
|
+
constructor(value, link) {
|
|
18
|
+
super(value);
|
|
19
|
+
this.link = link;
|
|
20
|
+
}
|
|
21
|
+
output() {
|
|
22
|
+
return terminalLink(colors.green(stringifyMessage(this.value)), this.link ?? '');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class CommandContentToken extends ContentToken {
|
|
26
|
+
output() {
|
|
27
|
+
return colors.bold(colors.yellow(stringifyMessage(this.value)));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
export class JsonContentToken extends ContentToken {
|
|
32
|
+
output() {
|
|
33
|
+
try {
|
|
34
|
+
return cjs(stringifyMessage(this.value) ?? {});
|
|
35
|
+
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
36
|
+
}
|
|
37
|
+
catch (_) {
|
|
38
|
+
return JSON.stringify(stringifyMessage(this.value) ?? {}, null, 2);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export class LinesDiffContentToken extends ContentToken {
|
|
43
|
+
output() {
|
|
44
|
+
return this.value
|
|
45
|
+
.map((part) => {
|
|
46
|
+
if (part.added) {
|
|
47
|
+
return part.value
|
|
48
|
+
.split(/\n/)
|
|
49
|
+
.filter((line) => line !== '')
|
|
50
|
+
.map((line) => {
|
|
51
|
+
return colors.green(`+ ${line}\n`);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
else if (part.removed) {
|
|
55
|
+
return part.value
|
|
56
|
+
.split(/\n/)
|
|
57
|
+
.filter((line) => line !== '')
|
|
58
|
+
.map((line) => {
|
|
59
|
+
return colors.magenta(`- ${line}\n`);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return part.value;
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
.flat();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export class ColorContentToken extends ContentToken {
|
|
70
|
+
constructor(value, color) {
|
|
71
|
+
super(value);
|
|
72
|
+
this.color = color;
|
|
73
|
+
}
|
|
74
|
+
output() {
|
|
75
|
+
return this.color(stringifyMessage(this.value));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export class ErrorContentToken extends ContentToken {
|
|
79
|
+
output() {
|
|
80
|
+
return colors.bold.redBright(stringifyMessage(this.value));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export class PathContentToken extends ContentToken {
|
|
84
|
+
output() {
|
|
85
|
+
return relativizePath(stringifyMessage(this.value));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export class HeadingContentToken extends ContentToken {
|
|
89
|
+
output() {
|
|
90
|
+
return colors.bold.underline(stringifyMessage(this.value));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export class SubHeadingContentToken extends ContentToken {
|
|
94
|
+
output() {
|
|
95
|
+
return colors.underline(stringifyMessage(this.value));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export class ItalicContentToken extends ContentToken {
|
|
99
|
+
output() {
|
|
100
|
+
return colors.italic(stringifyMessage(this.value));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=content-tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-tokens.js","sourceRoot":"","sources":["../src/content-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,IAAI,cAAc,EAAC,MAAM,WAAW,CAAA;AACtD,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAU,gBAAgB,EAAC,MAAM,aAAa,CAAA;AACrD,OAAO,YAAY,MAAM,eAAe,CAAA;AACxC,OAAO,GAAG,MAAM,YAAY,CAAA;AAG5B,MAAM,OAAgB,YAAY;IAGhC,YAAY,KAAQ;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;CAGF;AAED,MAAM,OAAO,eAAgB,SAAQ,YAAoB;IACvD,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;CACF;AAED,MAAM,OA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CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,YAAqB;IAC/D,MAAM;QACJ,OAAO,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACvD,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,YAAqB;IAC3D,MAAM;QACJ,OAAO,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACpD,CAAC;CACF","sourcesContent":["import {relativize as relativizePath} from './path.js'\nimport {colors} from './node/colors.js'\nimport {Message, stringifyMessage} from './output.js'\nimport terminalLink from 'terminal-link'\nimport cjs from 'color-json'\nimport type {Change} from 'diff'\n\nexport abstract class ContentToken<T> {\n value: T\n\n constructor(value: T) {\n this.value = value\n }\n\n abstract output(): string | string[]\n}\n\nexport class RawContentToken extends ContentToken<string> {\n output(): string {\n return this.value\n }\n}\n\nexport class LinkContentToken extends ContentToken<Message> {\n link: string\n\n constructor(value: Message, link: string) {\n super(value)\n this.link = link\n }\n\n output() {\n return terminalLink(colors.green(stringifyMessage(this.value)), this.link ?? '')\n }\n}\n\nexport class CommandContentToken extends ContentToken<Message> {\n output(): string {\n return colors.bold(colors.yellow(stringifyMessage(this.value)))\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class JsonContentToken extends ContentToken<any> {\n output(): string {\n try {\n return cjs(stringifyMessage(this.value) ?? {})\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (_) {\n return JSON.stringify(stringifyMessage(this.value) ?? {}, null, 2)\n }\n }\n}\n\nexport class LinesDiffContentToken extends ContentToken<Change[]> {\n output(): string[] {\n return this.value\n .map((part) => {\n if (part.added) {\n return part.value\n .split(/\\n/)\n .filter((line) => line !== '')\n .map((line) => {\n return colors.green(`+ ${line}\\n`) as string\n })\n } else if (part.removed) {\n return part.value\n .split(/\\n/)\n .filter((line) => line !== '')\n .map((line) => {\n return colors.magenta(`- ${line}\\n`) as string\n })\n } else {\n return part.value\n }\n })\n .flat()\n }\n}\n\nexport class ColorContentToken extends ContentToken<Message> {\n color: (text: string) => string\n\n constructor(value: Message, color: (text: string) => string) {\n super(value)\n this.color = color\n }\n\n output(): string {\n return this.color(stringifyMessage(this.value))\n }\n}\n\nexport class ErrorContentToken extends ContentToken<Message> {\n output(): string {\n return colors.bold.redBright(stringifyMessage(this.value))\n }\n}\n\nexport class PathContentToken extends ContentToken<Message> {\n output(): string {\n return relativizePath(stringifyMessage(this.value))\n }\n}\n\nexport class HeadingContentToken extends ContentToken<Message> {\n output(): string {\n return colors.bold.underline(stringifyMessage(this.value))\n }\n}\n\nexport class SubHeadingContentToken extends ContentToken<Message> {\n output(): string {\n return colors.underline(stringifyMessage(this.value))\n }\n}\n\nexport class ItalicContentToken extends ContentToken<Message> {\n output(): string {\n return colors.italic(stringifyMessage(this.value))\n }\n}\n"]}
|
|
@@ -12,9 +12,9 @@ export declare function homeDirectory(): string;
|
|
|
12
12
|
/**
|
|
13
13
|
* Returns true if the CLI is running in debug mode.
|
|
14
14
|
* @param env The environment variables from the environment of the current process.
|
|
15
|
-
* @returns true if
|
|
15
|
+
* @returns true if SHOPIFY_ENV is development
|
|
16
16
|
*/
|
|
17
|
-
export declare function
|
|
17
|
+
export declare function isDevelopment(env?: NodeJS.ProcessEnv): boolean;
|
|
18
18
|
/**
|
|
19
19
|
* Returns true if the CLI is running in verbose mode.
|
|
20
20
|
* @param env The environment variables from the environment of the current process.
|
|
@@ -41,9 +41,26 @@ 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
|
+
/** Returns true if reporting analytics should always happen, regardless of DEBUG mode etc. */
|
|
45
|
+
export declare function alwaysLogAnalytics(env?: NodeJS.ProcessEnv): boolean;
|
|
44
46
|
export declare function firstPartyDev(env?: NodeJS.ProcessEnv): boolean;
|
|
47
|
+
export declare function isDebugGoBinary(env?: NodeJS.ProcessEnv): boolean;
|
|
45
48
|
/**
|
|
46
49
|
* Returns whether the environment has Git available.
|
|
47
50
|
* @returns {Promise<boolean>} A promise that resolves with the value.
|
|
48
51
|
*/
|
|
49
52
|
export declare function hasGit(): Promise<boolean>;
|
|
53
|
+
/**
|
|
54
|
+
* Gets info on the CI platform the CLI is running on, if applicable
|
|
55
|
+
*/
|
|
56
|
+
export declare function ciPlatform(env?: NodeJS.ProcessEnv): {
|
|
57
|
+
isCI: true;
|
|
58
|
+
name: string;
|
|
59
|
+
} | {
|
|
60
|
+
isCI: false;
|
|
61
|
+
name?: undefined;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Gets info on the Web IDE platform the CLI is running on, if applicable
|
|
65
|
+
*/
|
|
66
|
+
export declare function webIDEPlatform(env?: NodeJS.ProcessEnv): "codespaces" | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isTruthy } from './utilities.js';
|
|
1
|
+
import { isTruthy, isSet } from './utilities.js';
|
|
2
2
|
import { isSpin } from './spin.js';
|
|
3
3
|
import constants from '../constants.js';
|
|
4
4
|
import { exists as fileExists } from '../file.js';
|
|
@@ -22,10 +22,10 @@ export function homeDirectory() {
|
|
|
22
22
|
/**
|
|
23
23
|
* Returns true if the CLI is running in debug mode.
|
|
24
24
|
* @param env The environment variables from the environment of the current process.
|
|
25
|
-
* @returns true if
|
|
25
|
+
* @returns true if SHOPIFY_ENV is development
|
|
26
26
|
*/
|
|
27
|
-
export function
|
|
28
|
-
return env[constants.environmentVariables.
|
|
27
|
+
export function isDevelopment(env = process.env) {
|
|
28
|
+
return env[constants.environmentVariables.env] === 'development';
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* Returns true if the CLI is running in verbose mode.
|
|
@@ -63,11 +63,18 @@ export function isUnitTest(env = process.env) {
|
|
|
63
63
|
* @returns true unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.
|
|
64
64
|
*/
|
|
65
65
|
export function analyticsDisabled(env = process.env) {
|
|
66
|
-
return isTruthy(env[constants.environmentVariables.noAnalytics]) ||
|
|
66
|
+
return isTruthy(env[constants.environmentVariables.noAnalytics]) || isDevelopment(env);
|
|
67
|
+
}
|
|
68
|
+
/** Returns true if reporting analytics should always happen, regardless of DEBUG mode etc. */
|
|
69
|
+
export function alwaysLogAnalytics(env = process.env) {
|
|
70
|
+
return isTruthy(env[constants.environmentVariables.alwaysLogAnalytics]);
|
|
67
71
|
}
|
|
68
72
|
export function firstPartyDev(env = process.env) {
|
|
69
73
|
return isTruthy(env[constants.environmentVariables.firstPartyDev]);
|
|
70
74
|
}
|
|
75
|
+
export function isDebugGoBinary(env = process.env) {
|
|
76
|
+
return isTruthy(env[constants.environmentVariables.debugGoBinary]);
|
|
77
|
+
}
|
|
71
78
|
/**
|
|
72
79
|
* Returns whether the environment has Git available.
|
|
73
80
|
* @returns {Promise<boolean>} A promise that resolves with the value.
|
|
@@ -82,4 +89,37 @@ export async function hasGit() {
|
|
|
82
89
|
return false;
|
|
83
90
|
}
|
|
84
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Gets info on the CI platform the CLI is running on, if applicable
|
|
94
|
+
*/
|
|
95
|
+
export function ciPlatform(env = process.env) {
|
|
96
|
+
if (isTruthy(env.CI)) {
|
|
97
|
+
let name = 'unknown';
|
|
98
|
+
if (isTruthy(env.CIRCLECI)) {
|
|
99
|
+
name = 'circleci';
|
|
100
|
+
}
|
|
101
|
+
else if (isSet(env.GITHUB_ACTION)) {
|
|
102
|
+
name = 'github';
|
|
103
|
+
}
|
|
104
|
+
else if (isTruthy(env.GITLAB_CI)) {
|
|
105
|
+
name = 'gitlab';
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
isCI: true,
|
|
109
|
+
name,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
isCI: false,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Gets info on the Web IDE platform the CLI is running on, if applicable
|
|
118
|
+
*/
|
|
119
|
+
export function webIDEPlatform(env = process.env) {
|
|
120
|
+
if (isTruthy(env.CODESPACES)) {
|
|
121
|
+
return 'codespaces';
|
|
122
|
+
}
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
85
125
|
//# sourceMappingURL=local.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/environment/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;
|
|
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,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;A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AAO,YAAY,CAAA;KACpB;IACD,OAAO,SAAS,CAAA;AAClB,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 {homedir} from 'node:os'\n\n/**\n * It returns true if the terminal is interactive.\n * @returns {boolean} 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 {string} 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 {boolean} 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()\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\n/**\n * Returns whether the environment has Git available.\n * @returns {Promise<boolean>} 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 * Gets info on the Web IDE platform the CLI is running on, if applicable\n */\nexport function webIDEPlatform(env = process.env) {\n if (isTruthy(env.CODESPACES)) {\n return 'codespaces'\n }\n return undefined\n}\n"]}
|
|
@@ -9,4 +9,13 @@ export function isTruthy(variable) {
|
|
|
9
9
|
}
|
|
10
10
|
return ['1', 'true', 'TRUE', 'yes', 'YES'].includes(variable);
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Returns whether an environment variable has been set and is non-empty
|
|
14
|
+
*/
|
|
15
|
+
export function isSet(variable) {
|
|
16
|
+
if (variable === undefined || variable.trim() === '') {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
12
21
|
//# sourceMappingURL=utilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../src/environment/utilities.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,QAA4B;IACnD,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,KAAK,CAAA;KACb;IACD,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AAC/D,CAAC","sourcesContent":["/**\n * Returns whether an environment variable value represents a truthy value.\n * @param variable {string | undefined} Given a environment variable value, it returns true if it represents a truthy value.\n * @returns {boolean}\n */\nexport function isTruthy(variable: string | undefined): boolean {\n if (!variable) {\n return false\n }\n return ['1', 'true', 'TRUE', 'yes', 'YES'].includes(variable)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../src/environment/utilities.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,QAA4B;IACnD,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,KAAK,CAAA;KACb;IACD,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AAC/D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,QAA4B;IAChD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACpD,OAAO,KAAK,CAAA;KACb;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["/**\n * Returns whether an environment variable value represents a truthy value.\n * @param variable {string | undefined} Given a environment variable value, it returns true if it represents a truthy value.\n * @returns {boolean}\n */\nexport function isTruthy(variable: string | undefined): boolean {\n if (!variable) {\n return false\n }\n return ['1', 'true', 'TRUE', 'yes', 'YES'].includes(variable)\n}\n\n/**\n * Returns whether an environment variable has been set and is non-empty\n */\nexport function isSet(variable: string | undefined): boolean {\n if (variable === undefined || variable.trim() === '') {\n return false\n }\n return true\n}\n"]}
|
package/dist/error.d.ts
CHANGED
|
@@ -38,10 +38,10 @@ export declare class Bug extends Fatal {
|
|
|
38
38
|
* @param error Error to be handled.
|
|
39
39
|
* @returns A promise that resolves with the error passed.
|
|
40
40
|
*/
|
|
41
|
-
export declare function handler(error:
|
|
42
|
-
export declare function mapper(error:
|
|
43
|
-
export declare function isFatal(error:
|
|
44
|
-
export declare function shouldReport(error:
|
|
41
|
+
export declare function handler(error: unknown): Promise<unknown>;
|
|
42
|
+
export declare function mapper(error: unknown): Promise<unknown>;
|
|
43
|
+
export declare function isFatal(error: unknown): error is Fatal;
|
|
44
|
+
export declare function shouldReport(error: unknown): boolean;
|
|
45
45
|
/**
|
|
46
46
|
* Stack traces usually have file:// - we strip that and also remove the Windows drive designation
|
|
47
47
|
*
|
package/dist/error.js
CHANGED
|
@@ -57,12 +57,18 @@ export async function handler(error) {
|
|
|
57
57
|
else if (typeof error === 'string') {
|
|
58
58
|
fatal = new Bug(error);
|
|
59
59
|
}
|
|
60
|
-
else {
|
|
60
|
+
else if (error instanceof Error) {
|
|
61
61
|
fatal = new Bug(error.message);
|
|
62
62
|
fatal.stack = error.stack;
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
else {
|
|
65
|
+
// errors can come in all shapes and sizes...
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
|
+
const maybeError = error;
|
|
68
|
+
fatal = new Bug(maybeError?.message ?? 'Unknown error');
|
|
69
|
+
if (maybeError?.stack) {
|
|
70
|
+
fatal.stack = maybeError?.stack;
|
|
71
|
+
}
|
|
66
72
|
}
|
|
67
73
|
await outputError(fatal);
|
|
68
74
|
return Promise.resolve(error);
|
|
@@ -78,7 +84,13 @@ export function mapper(error) {
|
|
|
78
84
|
}
|
|
79
85
|
}
|
|
80
86
|
export function isFatal(error) {
|
|
81
|
-
|
|
87
|
+
try {
|
|
88
|
+
return Object.prototype.hasOwnProperty.call(error, 'type');
|
|
89
|
+
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
82
94
|
}
|
|
83
95
|
export function shouldReport(error) {
|
|
84
96
|
if (!isFatal(error)) {
|
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,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,CAA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C,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: 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 await outputError(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"]}
|
package/dist/file.d.ts
CHANGED
|
@@ -11,6 +11,13 @@ export declare function inTemporaryDirectory<T>(callback: (tmpDir: string) => T
|
|
|
11
11
|
* @returns {Promise<string>} A promise that resolves with the content of the file.
|
|
12
12
|
*/
|
|
13
13
|
export declare function read(path: string, options?: object): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Given a path, it determines the actual path. This is useful when working
|
|
16
|
+
* with paths that represent symlinks.
|
|
17
|
+
* @param path {string} Path whose real path will be returned.
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export declare function realpath(path: string): Promise<string>;
|
|
14
21
|
export declare function readSync(path: string, options?: object): string;
|
|
15
22
|
/**
|
|
16
23
|
* Copies a file
|
|
@@ -20,7 +27,7 @@ export declare function readSync(path: string, options?: object): string;
|
|
|
20
27
|
export declare function copy(from: string, to: string): Promise<void>;
|
|
21
28
|
export declare function touch(path: string): Promise<void>;
|
|
22
29
|
export declare function appendFile(path: string, content: string): Promise<void>;
|
|
23
|
-
export declare function touchSync(path: string):
|
|
30
|
+
export declare function touchSync(path: string): void;
|
|
24
31
|
export declare function write(path: string, data: string): Promise<void>;
|
|
25
32
|
export declare function writeSync(path: string, data: string): void;
|
|
26
33
|
export declare function append(path: string, data: string): Promise<void>;
|
|
@@ -28,6 +35,7 @@ export declare function appendSync(path: string, data: string): void;
|
|
|
28
35
|
export declare function mkdir(path: string): Promise<void>;
|
|
29
36
|
export declare function mkdirSync(path: string): void;
|
|
30
37
|
export declare function remove(path: string): Promise<void>;
|
|
38
|
+
export declare function removeSync(path: string): void;
|
|
31
39
|
export declare function rmdir(path: string, { force }?: {
|
|
32
40
|
force?: boolean;
|
|
33
41
|
}): Promise<void>;
|
package/dist/file.js
CHANGED
|
@@ -32,6 +32,15 @@ export async function read(path, options = { encoding: 'utf-8' }) {
|
|
|
32
32
|
const content = await fs.readFile(path, options);
|
|
33
33
|
return content;
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Given a path, it determines the actual path. This is useful when working
|
|
37
|
+
* with paths that represent symlinks.
|
|
38
|
+
* @param path {string} Path whose real path will be returned.
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
export async function realpath(path) {
|
|
42
|
+
return fs.promises.realpath(path);
|
|
43
|
+
}
|
|
35
44
|
export function readSync(path, options = { encoding: 'utf-8' }) {
|
|
36
45
|
debug(outputContent `Sync-reading the content of file at ${token.path(path)}...`);
|
|
37
46
|
const content = fs.readFileSync(path, options);
|
|
@@ -59,9 +68,9 @@ export async function appendFile(path, content) {
|
|
|
59
68
|
`);
|
|
60
69
|
await fs.appendFile(path, content);
|
|
61
70
|
}
|
|
62
|
-
export
|
|
71
|
+
export function touchSync(path) {
|
|
63
72
|
debug(outputContent `Creating an empty file at ${token.path(path)}...`);
|
|
64
|
-
|
|
73
|
+
fs.ensureFileSync(path);
|
|
65
74
|
}
|
|
66
75
|
export async function write(path, data) {
|
|
67
76
|
debug(outputContent `Writing some content to file at ${token.path(path)}...`);
|
|
@@ -89,6 +98,10 @@ export async function remove(path) {
|
|
|
89
98
|
debug(outputContent `Removing file at ${token.path(path)}...`);
|
|
90
99
|
await fs.remove(path);
|
|
91
100
|
}
|
|
101
|
+
export function removeSync(path) {
|
|
102
|
+
debug(outputContent `Sync-removing file at ${token.path(path)}...`);
|
|
103
|
+
fs.removeSync(path);
|
|
104
|
+
}
|
|
92
105
|
export async function rmdir(path, { force } = {}) {
|
|
93
106
|
debug(outputContent `Removing directory at ${token.path(path)}...`);
|
|
94
107
|
await del(path, { force });
|