@shopify/cli-kit 3.32.0 → 3.33.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/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -1
- package/dist/constants.js.map +1 -1
- package/dist/environment/local.d.ts +0 -1
- package/dist/environment/local.js +0 -3
- package/dist/environment/local.js.map +1 -1
- package/dist/http/fetch.js +1 -1
- package/dist/http/fetch.js.map +1 -1
- package/dist/http.d.ts +0 -1
- package/dist/http.js +0 -1
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -6
- package/dist/index.js.map +1 -1
- package/dist/npm.js +1 -1
- package/dist/npm.js.map +1 -1
- package/dist/private/common/array.d.ts +1 -0
- package/dist/private/common/array.js +4 -0
- package/dist/private/common/array.js.map +1 -0
- package/dist/private/node/analytics.js +2 -2
- package/dist/private/node/analytics.js.map +1 -1
- package/dist/private/node/api/graphql.d.ts +5 -0
- package/dist/private/node/api/graphql.js +63 -0
- package/dist/private/node/api/graphql.js.map +1 -0
- package/dist/{api/common.d.ts → private/node/api/headers.d.ts} +3 -8
- package/dist/{api/common.js → private/node/api/headers.js} +20 -60
- package/dist/private/node/api/headers.js.map +1 -0
- package/dist/private/node/api/rest.d.ts +6 -0
- package/dist/private/node/api/rest.js +27 -0
- package/dist/private/node/api/rest.js.map +1 -0
- package/dist/private/node/ui/components/FullScreen.js +11 -9
- package/dist/private/node/ui/components/FullScreen.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.js +15 -3
- package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
- package/dist/private/node/ui/components/Subdued.d.ts +9 -0
- package/dist/private/node/ui/components/Subdued.js +10 -0
- package/dist/private/node/ui/components/Subdued.js.map +1 -0
- package/dist/private/node/ui/components/Subdued.test.d.ts +1 -0
- package/dist/private/node/ui/components/Subdued.test.js +11 -0
- package/dist/private/node/ui/components/Subdued.test.js.map +1 -0
- package/dist/private/node/ui/components/Table.js +1 -1
- package/dist/private/node/ui/components/Table.js.map +1 -1
- package/dist/private/node/ui/components/TokenizedText.d.ts +4 -1
- package/dist/private/node/ui/components/TokenizedText.js +4 -0
- package/dist/private/node/ui/components/TokenizedText.js.map +1 -1
- package/dist/private/node/ui/components/TokenizedText.test.js +4 -1
- package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -1
- package/dist/public/common/array.d.ts +4 -0
- package/dist/public/common/array.js +4 -0
- package/dist/public/common/array.js.map +1 -1
- package/dist/public/common/collection.js.map +1 -1
- package/dist/public/common/object.d.ts +3 -3
- package/dist/public/common/object.js +5 -7
- package/dist/public/common/object.js.map +1 -1
- package/dist/public/common/string.d.ts +55 -1
- package/dist/public/common/string.js +93 -1
- package/dist/public/common/string.js.map +1 -1
- package/dist/public/common/url.d.ts +2 -1
- package/dist/public/common/url.js +3 -2
- package/dist/public/common/url.js.map +1 -1
- package/dist/public/node/api/admin.d.ts +41 -0
- package/dist/public/node/api/admin.js +98 -0
- package/dist/public/node/api/admin.js.map +1 -0
- package/dist/public/node/api/oxygen.d.ts +22 -0
- package/dist/public/node/api/oxygen.js +40 -0
- package/dist/public/node/api/oxygen.js.map +1 -0
- package/dist/{api → public/node/api}/partners.d.ts +11 -3
- package/dist/public/node/api/partners.js +45 -0
- package/dist/public/node/api/partners.js.map +1 -0
- package/dist/public/node/base-command.js +1 -1
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/crypto.d.ts +42 -0
- package/dist/public/node/crypto.js +55 -0
- package/dist/public/node/crypto.js.map +1 -0
- package/dist/{template.d.ts → public/node/liquid.d.ts} +10 -2
- package/dist/{template.js → public/node/liquid.js} +18 -13
- package/dist/public/node/liquid.js.map +1 -0
- package/dist/public/node/os.d.ts +16 -0
- package/dist/{os.js → public/node/os.js} +33 -28
- package/dist/public/node/os.js.map +1 -0
- package/dist/public/node/presets.js +2 -2
- package/dist/public/node/presets.js.map +1 -1
- package/dist/public/node/ruby.d.ts +11 -7
- package/dist/public/node/ruby.js +90 -22
- package/dist/public/node/ruby.js.map +1 -1
- package/dist/public/node/tcp.d.ts +2 -0
- package/dist/public/node/tcp.js +9 -0
- package/dist/public/node/tcp.js.map +1 -1
- package/dist/public/node/toml.d.ts +15 -0
- package/dist/public/node/toml.js +20 -0
- package/dist/public/node/toml.js.map +1 -0
- package/dist/public/node/ui.d.ts +1 -1
- package/dist/public/node/ui.js.map +1 -1
- package/dist/public/node/vscode.d.ts +14 -0
- package/dist/{vscode.js → public/node/vscode.js} +13 -7
- package/dist/public/node/vscode.js.map +1 -0
- package/dist/session/authorize.d.ts +4 -0
- package/dist/session/authorize.js +7 -2
- package/dist/session/authorize.js.map +1 -1
- package/dist/{api/identity.d.ts → session/identity-token-validation.d.ts} +0 -0
- package/dist/{api/identity.js → session/identity-token-validation.js} +1 -1
- package/dist/session/identity-token-validation.js.map +1 -0
- package/dist/session/schema.d.ts +18 -18
- package/dist/session/store.js +1 -1
- package/dist/session/store.js.map +1 -1
- package/dist/session/validate.js +2 -2
- package/dist/session/validate.js.map +1 -1
- package/dist/session.js +3 -3
- package/dist/session.js.map +1 -1
- package/dist/system.js +1 -1
- package/dist/system.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/inquirer/autocomplete.js +1 -1
- package/dist/ui/inquirer/autocomplete.js.map +1 -1
- package/package.json +2 -2
- package/dist/api/admin.d.ts +0 -3
- package/dist/api/admin.js +0 -56
- package/dist/api/admin.js.map +0 -1
- package/dist/api/common.js.map +0 -1
- package/dist/api/graphql/all_app_extension_registrations.d.ts +0 -20
- package/dist/api/graphql/all_app_extension_registrations.js +0 -20
- package/dist/api/graphql/all_app_extension_registrations.js.map +0 -1
- package/dist/api/graphql/all_dev_stores_by_org.d.ts +0 -18
- package/dist/api/graphql/all_dev_stores_by_org.js +0 -21
- package/dist/api/graphql/all_dev_stores_by_org.js.map +0 -1
- package/dist/api/graphql/all_orgs.d.ts +0 -12
- package/dist/api/graphql/all_orgs.js +0 -14
- package/dist/api/graphql/all_orgs.js.map +0 -1
- package/dist/api/graphql/convert_dev_to_test_store.d.ts +0 -16
- package/dist/api/graphql/convert_dev_to_test_store.js +0 -13
- package/dist/api/graphql/convert_dev_to_test_store.js.map +0 -1
- package/dist/api/graphql/create_app.d.ts +0 -29
- package/dist/api/graphql/create_app.js +0 -33
- package/dist/api/graphql/create_app.js.map +0 -1
- package/dist/api/graphql/create_deployment.d.ts +0 -33
- package/dist/api/graphql/create_deployment.js +0 -25
- package/dist/api/graphql/create_deployment.js.map +0 -1
- package/dist/api/graphql/extension_create.d.ts +0 -30
- package/dist/api/graphql/extension_create.js +0 -26
- package/dist/api/graphql/extension_create.js.map +0 -1
- package/dist/api/graphql/extension_specifications.d.ts +0 -27
- package/dist/api/graphql/extension_specifications.js +0 -22
- package/dist/api/graphql/extension_specifications.js.map +0 -1
- package/dist/api/graphql/find_app.d.ts +0 -14
- package/dist/api/graphql/find_app.js +0 -17
- package/dist/api/graphql/find_app.js.map +0 -1
- package/dist/api/graphql/find_org.d.ts +0 -18
- package/dist/api/graphql/find_org.js +0 -21
- package/dist/api/graphql/find_org.js.map +0 -1
- package/dist/api/graphql/find_org_basic.d.ts +0 -11
- package/dist/api/graphql/find_org_basic.js +0 -14
- package/dist/api/graphql/find_org_basic.js.map +0 -1
- package/dist/api/graphql/find_store_by_domain.d.ts +0 -21
- package/dist/api/graphql/find_store_by_domain.js +0 -24
- package/dist/api/graphql/find_store_by_domain.js.map +0 -1
- package/dist/api/graphql/functions/api_schema_definition.d.ts +0 -9
- package/dist/api/graphql/functions/api_schema_definition.js +0 -7
- package/dist/api/graphql/functions/api_schema_definition.js.map +0 -1
- package/dist/api/graphql/functions/app_function_set.d.ts +0 -30
- package/dist/api/graphql/functions/app_function_set.js +0 -38
- package/dist/api/graphql/functions/app_function_set.js.map +0 -1
- package/dist/api/graphql/functions/function_service_proxy.d.ts +0 -4
- package/dist/api/graphql/functions/function_service_proxy.js +0 -7
- package/dist/api/graphql/functions/function_service_proxy.js.map +0 -1
- package/dist/api/graphql/functions/upload_url_generate.d.ts +0 -12
- package/dist/api/graphql/functions/upload_url_generate.js +0 -11
- package/dist/api/graphql/functions/upload_url_generate.js.map +0 -1
- package/dist/api/graphql/generate_signed_upload_url.d.ts +0 -15
- package/dist/api/graphql/generate_signed_upload_url.js +0 -15
- package/dist/api/graphql/generate_signed_upload_url.js.map +0 -1
- package/dist/api/graphql/get_urls.d.ts +0 -10
- package/dist/api/graphql/get_urls.js +0 -10
- package/dist/api/graphql/get_urls.js.map +0 -1
- package/dist/api/graphql/get_variant_id.d.ts +0 -17
- package/dist/api/graphql/get_variant_id.js +0 -20
- package/dist/api/graphql/get_variant_id.js.map +0 -1
- package/dist/api/graphql/index.d.ts +0 -21
- package/dist/api/graphql/index.js +0 -22
- package/dist/api/graphql/index.js.map +0 -1
- package/dist/api/graphql/update_draft.d.ts +0 -33
- package/dist/api/graphql/update_draft.js +0 -24
- package/dist/api/graphql/update_draft.js.map +0 -1
- package/dist/api/graphql/update_urls.d.ts +0 -14
- package/dist/api/graphql/update_urls.js +0 -12
- package/dist/api/graphql/update_urls.js.map +0 -1
- package/dist/api/identity.js.map +0 -1
- package/dist/api/oxygen.d.ts +0 -5
- package/dist/api/oxygen.js +0 -30
- package/dist/api/oxygen.js.map +0 -1
- package/dist/api/partners.js +0 -44
- package/dist/api/partners.js.map +0 -1
- package/dist/api.d.ts +0 -6
- package/dist/api.js +0 -7
- package/dist/api.js.map +0 -1
- package/dist/http/graphql.d.ts +0 -13
- package/dist/http/graphql.js +0 -12
- package/dist/http/graphql.js.map +0 -1
- package/dist/os.d.ts +0 -11
- package/dist/os.js.map +0 -1
- package/dist/public/node/checksum.d.ts +0 -20
- package/dist/public/node/checksum.js +0 -32
- package/dist/public/node/checksum.js.map +0 -1
- package/dist/string.d.ts +0 -28
- package/dist/string.js +0 -77
- package/dist/string.js.map +0 -1
- package/dist/template.js.map +0 -1
- package/dist/toml.d.ts +0 -3
- package/dist/toml.js +0 -8
- package/dist/toml.js.map +0 -1
- package/dist/vscode.d.ts +0 -8
- package/dist/vscode.js.map +0 -1
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -26,7 +26,6 @@ const constants = {
|
|
|
26
26
|
themeToken: 'SHOPIFY_CLI_THEME_TOKEN',
|
|
27
27
|
unitTest: 'SHOPIFY_UNIT_TEST',
|
|
28
28
|
verbose: 'SHOPIFY_FLAG_VERBOSE',
|
|
29
|
-
functionMatching: 'SHOPIFY_CLI_FUNCTION_MATCHING',
|
|
30
29
|
themeBundling: 'SHOPIFY_THEME_BUNDLING',
|
|
31
30
|
// Variables to detect if the CLI is running in a cloud environment
|
|
32
31
|
codespaceName: 'CODESPACE_NAME',
|
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,oBAAoB,EAAC,MAAM,uCAAuC,CAAA;AAC1E,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,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;Q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wBAAwB;QACvC,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 './public/node/node-package-manager.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 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 themeBundling: 'SHOPIFY_THEME_BUNDLING',\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"]}
|
|
@@ -45,7 +45,6 @@ export declare function analyticsDisabled(env?: NodeJS.ProcessEnv): boolean;
|
|
|
45
45
|
export declare function alwaysLogAnalytics(env?: NodeJS.ProcessEnv): boolean;
|
|
46
46
|
export declare function firstPartyDev(env?: NodeJS.ProcessEnv): boolean;
|
|
47
47
|
export declare function useDeviceAuth(env?: NodeJS.ProcessEnv): boolean;
|
|
48
|
-
export declare function useFunctionMatching(env?: NodeJS.ProcessEnv): boolean;
|
|
49
48
|
export declare function useThemeBundling(env?: NodeJS.ProcessEnv): boolean;
|
|
50
49
|
export declare function gitpodURL(env?: NodeJS.ProcessEnv): string | undefined;
|
|
51
50
|
export declare function codespaceURL(env?: NodeJS.ProcessEnv): string | undefined;
|
|
@@ -76,9 +76,6 @@ export function firstPartyDev(env = process.env) {
|
|
|
76
76
|
export function useDeviceAuth(env = process.env) {
|
|
77
77
|
return isTruthy(env[constants.environmentVariables.deviceAuth]) || isCloudEnvironment(env);
|
|
78
78
|
}
|
|
79
|
-
export function useFunctionMatching(env = process.env) {
|
|
80
|
-
return isTruthy(env[constants.environmentVariables.functionMatching]);
|
|
81
|
-
}
|
|
82
79
|
export function useThemeBundling(env = process.env) {
|
|
83
80
|
return isTruthy(env[constants.environmentVariables.themeBundling]);
|
|
84
81
|
}
|
|
@@ -1 +1 @@
|
|
|
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,IAAI,CAAA;AAE1B;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,aAAa,EAAE,CAAA;AACxB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO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AM,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 '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 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\nexport function useThemeBundling(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.themeBundling])\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,iBAAi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G,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 '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 useDeviceAuth(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.deviceAuth]) || isCloudEnvironment(env)\n}\n\nexport function useThemeBundling(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.themeBundling])\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/http/fetch.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { httpsAgent } from '../http.js';
|
|
2
|
-
import { buildHeaders, sanitizedHeadersOutput } from '../api/common.js';
|
|
3
2
|
import { content, debug } from '../output.js';
|
|
3
|
+
import { buildHeaders, sanitizedHeadersOutput } from '../private/node/api/headers.js';
|
|
4
4
|
import nodeFetch from 'node-fetch';
|
|
5
5
|
import { performance } from 'perf_hooks';
|
|
6
6
|
/**
|
package/dist/http/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/http/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/http/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAC,YAAY,EAAE,sBAAsB,EAAC,MAAM,gCAAgC,CAAA;AACnF,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAA;AAItC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,KAAK,CAAC,GAAgB,EAAE,IAAkB;IACtE,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC3C,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAgB,EAAE,IAAkB;IACrE,MAAM,OAAO,GAAgB;QAC3B,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;QACf,OAAO,EAAE;YACP,GAAG,CAAC,MAAM,YAAY,EAAE,CAAC;YACzB,GAAG,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC;SACzB;KACF,CAAA;IAED,KAAK,CAAC,OAAO,CAAA;UACL,OAAO,CAAC,MAAM,IAAI,KAAK,mBAAmB,GAAG,CAAC,QAAQ,EAAE;EAChE,sBAAsB,CAAC,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,CAA+B,CAAC;CAC/E,CAAC,CAAA;IACA,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;IAC5B,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,EAAC,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,UAAU,EAAE,EAAC,CAAC,CAAA;IAC3E,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;IAC5B,KAAK,CAAC,cAAc,GAAG,CAAC,QAAQ,EAAE,0BAA0B,QAAQ,CAAC,MAAM,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAA;IAC3G,OAAO,QAAQ,CAAA;AACjB,CAAC","sourcesContent":["import {httpsAgent} from '../http.js'\nimport {content, debug} from '../output.js'\nimport {buildHeaders, sanitizedHeadersOutput} from '../private/node/api/headers.js'\nimport nodeFetch from 'node-fetch'\nimport {performance} from 'perf_hooks'\nimport type {RequestInfo, RequestInit} from 'node-fetch'\n\ntype Response = ReturnType<typeof nodeFetch>\n/**\n * An interface that abstracts way node-fetch. When Node has built-in\n * support for \"fetch\" in the standard library, we can drop the node-fetch\n * dependency from here.\n * Note that we are exposing types from \"node-fetch\". The reason being is that\n * they are consistent with the Web API so if we drop node-fetch in the future\n * it won't require changes from the callers.\n * @param url - This defines the resource that you wish to fetch.\n * @param init - An object containing any custom settings that you want to apply to the request\n * @returns A promise that resolves with the response.\n */\nexport default async function fetch(url: RequestInfo, init?: RequestInit): Response {\n const response = await nodeFetch(url, init)\n return response\n}\n\n/**\n * A fetch function to use with Shopify services. The function ensures the right\n * TLS configuragion is used based on the environment in which the service is running\n * (e.g. spin)\n */\nexport async function shopifyFetch(url: RequestInfo, init?: RequestInit): Response {\n const options: RequestInit = {\n ...(init ?? {}),\n headers: {\n ...(await buildHeaders()),\n ...(init?.headers ?? {}),\n },\n }\n\n debug(content`\nSending ${options.method ?? 'GET'} request to URL ${url.toString()} and headers:\n${sanitizedHeadersOutput((options?.headers ?? {}) as {[header: string]: string})}\n`)\n const t0 = performance.now()\n const response = await nodeFetch(url, {...init, agent: await httpsAgent()})\n const t1 = performance.now()\n debug(`Request to ${url.toString()} completed with status ${response.status} in ${Math.round(t1 - t0)} ms`)\n return response\n}\n"]}
|
package/dist/http.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import https from 'https';
|
|
3
3
|
export { default as fetch } from './http/fetch.js';
|
|
4
|
-
export { graphqlClient } from './http/graphql.js';
|
|
5
4
|
export { shopifyFetch } from './http/fetch.js';
|
|
6
5
|
export { default as formData } from './http/formdata.js';
|
|
7
6
|
export { createApp, createRouter, IncomingMessage, ServerResponse, CompatibilityEvent, createError, send, sendError, sendRedirect, H3Error, } from 'h3';
|
package/dist/http.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { serviceEnvironment } from './environment/service.js';
|
|
2
2
|
import https from 'https';
|
|
3
3
|
export { default as fetch } from './http/fetch.js';
|
|
4
|
-
export { graphqlClient } from './http/graphql.js';
|
|
5
4
|
export { shopifyFetch } from './http/fetch.js';
|
|
6
5
|
export { default as formData } from './http/formdata.js';
|
|
7
6
|
export { createApp, createRouter, createError, send, sendError, sendRedirect, H3Error, } from 'h3';
|
package/dist/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,oBAAoB,CAAA;AAEtD,OAAO,EACL,SAAS,EACT,YAAY,EAIZ,WAAW,EACX,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,OAAO,GACR,MAAM,IAAI,CAAA;AAEX;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,EAAC,kBAAkB,EAAE,MAAM,gCAAgC,EAAE,EAAC,CAAC,CAAA;AACxF,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,gCAAgC;IACpD,OAAO,CAAC,MAAM,kBAAkB,EAAE,CAAC,KAAK,MAAM,CAAA;AAChD,CAAC","sourcesContent":["import {serviceEnvironment} from './environment/service.js'\nimport https from 'https'\n\nexport {default as fetch} from './http/fetch.js'\nexport {shopifyFetch} from './http/fetch.js'\nexport {default as formData} from './http/formdata.js'\n\nexport {\n createApp,\n createRouter,\n IncomingMessage,\n ServerResponse,\n CompatibilityEvent,\n createError,\n send,\n sendError,\n sendRedirect,\n H3Error,\n} from 'h3'\n\n/**\n * This utility function returns the https.Agent to use for a given service. The agent\n * includes the right configuration based on the service's environment. For example,\n * if the service is running in a Spin environment, the attribute \"rejectUnauthorized\" is\n * set to false\n */\nexport async function httpsAgent() {\n return new https.Agent({rejectUnauthorized: await shouldRejectUnauthorizedRequests()})\n}\n\n/**\n * Spin stores the CA certificate in the keychain and it should be used when sending HTTP\n * requests to Spin instances. However, Node doesn't read certificates from the Keychain\n * by default, which leads to Shopifolks running into issues that they workaround by setting the\n * NODE_TLS_REJECT_UNAUTHORIZED=0 environment variable, which applies to all the HTTP\n * requests sent from the CLI (context: https://github.com/nodejs/node/issues/39657)\n * This utility function allows controlling the behavior in a per-service level by returning\n * the value of for the \"rejectUnauthorized\" attribute that's used in the https agent.\n *\n * @returns A promise that resolves with a boolean indicating whether\n * unauthorized requests should be rejected or not.\n */\nexport async function shouldRejectUnauthorizedRequests(): Promise<boolean> {\n return (await serviceEnvironment()) !== 'spin'\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { default as constants } from './constants.js';
|
|
2
|
-
export * as api from './api.js';
|
|
3
2
|
export * as cli from './cli.js';
|
|
4
3
|
export * as environment from './environment.js';
|
|
5
4
|
export * as error from './error.js';
|
|
@@ -7,19 +6,14 @@ export * as file from './file.js';
|
|
|
7
6
|
export * as git from './git.js';
|
|
8
7
|
export * as http from './http.js';
|
|
9
8
|
export * as npm from './npm.js';
|
|
10
|
-
export * as os from './os.js';
|
|
11
9
|
export * as output from './output.js';
|
|
12
10
|
export * as path from './path.js';
|
|
13
11
|
export * as plugins from './plugins.js';
|
|
14
12
|
export * as schema from './schema.js';
|
|
15
13
|
export * as session from './session.js';
|
|
16
14
|
export * as store from './store.js';
|
|
17
|
-
export * as string from './string.js';
|
|
18
15
|
export * as system from './system.js';
|
|
19
|
-
export * as template from './template.js';
|
|
20
|
-
export * as toml from './toml.js';
|
|
21
16
|
export * as ui from './ui.js';
|
|
22
|
-
export * as vscode from './vscode.js';
|
|
23
17
|
export * as outputMocker from './testing/output.js';
|
|
24
18
|
export * as metadata from './metadata.js';
|
|
25
19
|
export * as monorail from './monorail.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { default as constants } from './constants.js';
|
|
2
|
-
export * as api from './api.js';
|
|
3
2
|
export * as cli from './cli.js';
|
|
4
3
|
export * as environment from './environment.js';
|
|
5
4
|
export * as error from './error.js';
|
|
@@ -7,19 +6,14 @@ export * as file from './file.js';
|
|
|
7
6
|
export * as git from './git.js';
|
|
8
7
|
export * as http from './http.js';
|
|
9
8
|
export * as npm from './npm.js';
|
|
10
|
-
export * as os from './os.js';
|
|
11
9
|
export * as output from './output.js';
|
|
12
10
|
export * as path from './path.js';
|
|
13
11
|
export * as plugins from './plugins.js';
|
|
14
12
|
export * as schema from './schema.js';
|
|
15
13
|
export * as session from './session.js';
|
|
16
14
|
export * as store from './store.js';
|
|
17
|
-
export * as string from './string.js';
|
|
18
15
|
export * as system from './system.js';
|
|
19
|
-
export * as template from './template.js';
|
|
20
|
-
export * as toml from './toml.js';
|
|
21
16
|
export * as ui from './ui.js';
|
|
22
|
-
export * as vscode from './vscode.js';
|
|
23
17
|
export * as outputMocker from './testing/output.js';
|
|
24
18
|
export * as metadata from './metadata.js';
|
|
25
19
|
export * as monorail from './monorail.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACnD,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACnD,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,YAAY,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA","sourcesContent":["export {default as constants} from './constants.js'\nexport * as cli from './cli.js'\nexport * as environment from './environment.js'\nexport * as error from './error.js'\nexport * as file from './file.js'\nexport * as git from './git.js'\nexport * as http from './http.js'\nexport * as npm from './npm.js'\nexport * as output from './output.js'\nexport * as path from './path.js'\nexport * as plugins from './plugins.js'\nexport * as schema from './schema.js'\nexport * as session from './session.js'\nexport * as store from './store.js'\nexport * as system from './system.js'\nexport * as ui from './ui.js'\nexport * as outputMocker from './testing/output.js'\nexport * as metadata from './metadata.js'\nexport * as monorail from './monorail.js'\n"]}
|
package/dist/npm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { join } from './path.js';
|
|
2
2
|
import * as file from './file.js';
|
|
3
|
-
import * as os from './os.js';
|
|
3
|
+
import * as os from './public/node/os.js';
|
|
4
4
|
import { debug, token, content } from './output.js';
|
|
5
5
|
export async function readPackageJSON(directory) {
|
|
6
6
|
debug(content `Reading and decoding the content from package.json at ${token.path(directory)}...`);
|
package/dist/npm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"npm.js","sourceRoot":"","sources":["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A;IACvB,WAAW,CAAC,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAA;AAClD,CAAC","sourcesContent":["import {join} from './path.js'\nimport * as file from './file.js'\nimport * as os from './public/node/os.js'\nimport {debug, token, content} from './output.js'\n\ninterface JSON {\n [key: string]: JSONValue\n}\n\ntype JSONValue = string | number | boolean | JSON | JSONValue[]\n\nexport interface PackageJSON extends JSON {\n name: string\n author: string\n dependencies: {[key: string]: string}\n devDependencies: {[key: string]: string}\n resolutions: {[key: string]: string}\n overrides: {[key: string]: string}\n scripts: {[key: string]: string}\n}\n\nexport async function readPackageJSON(directory: string): Promise<PackageJSON> {\n debug(content`Reading and decoding the content from package.json at ${token.path(directory)}...`)\n const packagePath = join(directory, 'package.json')\n const packageJSON = JSON.parse(await file.read(packagePath))\n\n return packageJSON\n}\n\nexport async function writePackageJSON(directory: string, packageJSON: JSON): Promise<void> {\n debug(content`JSON-encoding and writing content to package.json at ${token.path(directory)}...`)\n const packagePath = join(directory, 'package.json')\n await file.write(packagePath, JSON.stringify(packageJSON, null, 2))\n}\n\nexport async function updateAppData(packageJSON: JSON, name: string): Promise<void> {\n packageJSON.name = name\n packageJSON.author = (await os.username()) ?? ''\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function unionArrayStrategy(destinationArray: unknown[], sourceArray: unknown[]): unknown[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.js","sourceRoot":"","sources":["../../../src/private/common/array.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,kBAAkB,CAAC,gBAA2B,EAAE,WAAsB;IACpF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,gBAAgB,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;AACnE,CAAC","sourcesContent":["export function unionArrayStrategy(destinationArray: unknown[], sourceArray: unknown[]): unknown[] {\n return Array.from(new Set([...destinationArray, ...sourceArray]))\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { hashString } from '../../public/node/crypto.js';
|
|
1
2
|
import { getPackageManager, packageManagerUsedForCreating } from '../../public/node/node-package-manager.js';
|
|
2
3
|
import * as metadata from '../../metadata.js';
|
|
3
4
|
import { macAddress } from '../../environment/local.js';
|
|
4
|
-
import { platformAndArch } from '../../os.js';
|
|
5
|
-
import { hashString } from '../../string.js';
|
|
5
|
+
import { platformAndArch } from '../../public/node/os.js';
|
|
6
6
|
import * as environment from '../../environment.js';
|
|
7
7
|
export async function startAnalytics({ commandContent, args, currentTime = new Date().getTime(), commandClass, }) {
|
|
8
8
|
let startCommand = commandContent.command;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../../src/private/node/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,6BAA6B,EAAC,MAAM,2CAA2C,CAAA;AAG1G,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAC,eAAe,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../../src/private/node/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAC,iBAAiB,EAAE,6BAA6B,EAAC,MAAM,2CAA2C,CAAA;AAG1G,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAA;AACvD,OAAO,KAAK,WAAW,MAAM,sBAAsB,CAAA;AAUnD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EACnC,cAAc,EACd,IAAI,EACJ,WAAW,GAAG,IAAI,IA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W,CAAC,MAAM,KAAK,cAAc,CAAC,MAAM;QAC7E,4BAA4B,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;QAC5D,SAAS,EAAE,MAAM,CAAC,KAAK;QACvB,WAAW,EAAE,WAAW,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC,MAAM;YACtD,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC,QAAQ;YAC/C,CAAC,CAAC,SAAS;QACb,aAAa,EAAE,UAAU,CAAC,MAAM,UAAU,EAAE,CAAC;QAC7C,SAAS,EAAE,WAAW,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC,QAAQ;QACxD,mBAAmB,EAAE,MAAM,iBAAiB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;KAC5D,CAAA;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,MAAyB;IACzE,OAAO;QACL,wBAAwB,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;KACjE,CAAA;AACH,CAAC;AAED,SAAS,cAAc,CAAC,MAAyB;IAC/C,OAAO,MAAM,CAAC,OAAO;SAClB,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;SAC5B,IAAI,EAAE;SACN,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAA;AACtD,CAAC","sourcesContent":["import {hashString} from '../../public/node/crypto.js'\nimport {getPackageManager, packageManagerUsedForCreating} from '../../public/node/node-package-manager.js'\nimport BaseCommand from '../../public/node/base-command.js'\nimport {CommandContent} from '../../public/node/hooks/prerun.js'\nimport * as metadata from '../../metadata.js'\nimport {macAddress} from '../../environment/local.js'\nimport {platformAndArch} from '../../public/node/os.js'\nimport * as environment from '../../environment.js'\nimport {Interfaces} from '@oclif/core'\n\ninterface StartOptions {\n commandContent: CommandContent\n args: string[]\n currentTime?: number\n commandClass?: Interfaces.Command.Class | typeof BaseCommand\n}\n\nexport async function startAnalytics({\n commandContent,\n args,\n currentTime = new Date().getTime(),\n commandClass,\n}: StartOptions): Promise<void> {\n let startCommand: string = commandContent.command\n if (commandClass && Object.prototype.hasOwnProperty.call(commandClass, 'analyticsNameOverride')) {\n startCommand = (commandClass as typeof BaseCommand).analyticsNameOverride() ?? commandContent.command\n }\n\n await metadata.addSensitive(() => ({\n commandStartOptions: {\n startTime: currentTime,\n startCommand,\n startArgs: args,\n },\n }))\n\n await metadata.addPublic(() => ({\n cmd_all_launcher: packageManagerUsedForCreating(),\n cmd_all_alias_used: commandContent.alias,\n cmd_all_topic: commandContent.topic,\n cmd_all_plugin: commandClass?.plugin?.name,\n }))\n}\n\ninterface EnvironmentData {\n uname: string\n env_ci: boolean\n env_ci_platform?: string\n env_plugin_installed_any_custom: boolean\n env_plugin_installed_shopify: string\n env_shell: string\n env_web_ide: string | undefined\n env_device_id: string\n env_cloud: string\n env_package_manager: string\n}\n\nexport async function getEnvironmentData(config: Interfaces.Config): Promise<EnvironmentData> {\n const ciPlatform = environment.local.ciPlatform()\n\n const pluginNames = getPluginNames(config)\n const shopifyPlugins = pluginNames.filter((plugin) => plugin.startsWith('@shopify/'))\n\n const {platform, arch} = platformAndArch()\n\n return {\n uname: `${platform} ${arch}`,\n env_ci: ciPlatform.isCI,\n env_ci_platform: ciPlatform.name,\n env_plugin_installed_any_custom: pluginNames.length !== shopifyPlugins.length,\n env_plugin_installed_shopify: JSON.stringify(shopifyPlugins),\n env_shell: config.shell,\n env_web_ide: environment.local.cloudEnvironment().editor\n ? environment.local.cloudEnvironment().platform\n : undefined,\n env_device_id: hashString(await macAddress()),\n env_cloud: environment.local.cloudEnvironment().platform,\n env_package_manager: await getPackageManager(process.cwd()),\n }\n}\n\nexport async function getSensitiveEnvironmentData(config: Interfaces.Config) {\n return {\n env_plugin_installed_all: JSON.stringify(getPluginNames(config)),\n }\n}\n\nfunction getPluginNames(config: Interfaces.Config) {\n return config.plugins\n .map((plugin) => plugin.name)\n .sort()\n .filter((plugin) => !plugin.startsWith('@oclif/'))\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RequestDocument, Variables } from 'graphql-request';
|
|
2
|
+
export interface GraphQLVariables {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}
|
|
5
|
+
export declare function graphqlRequest<T>(query: RequestDocument, api: string, url: string, token: string, variables?: Variables, handleErrors?: boolean): Promise<T>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { buildHeaders, RequestClientError, sanitizedHeadersOutput } from './headers.js';
|
|
2
|
+
import { stringifyMessage, content, token as outputToken, token, debug } from '../../../output.js';
|
|
3
|
+
import { Abort } from '../../../error.js';
|
|
4
|
+
import { httpsAgent } from '../../../http.js';
|
|
5
|
+
import { ClientError, GraphQLClient } from 'graphql-request';
|
|
6
|
+
export function graphqlRequest(query, api, url, token, variables, handleErrors = true) {
|
|
7
|
+
const action = async () => {
|
|
8
|
+
const headers = await buildHeaders(token);
|
|
9
|
+
debugLogRequest(api, query, variables, headers);
|
|
10
|
+
const clientOptions = { agent: await httpsAgent(), headers };
|
|
11
|
+
const client = new GraphQLClient(url, clientOptions);
|
|
12
|
+
const t0 = performance.now();
|
|
13
|
+
const response = await client.request(query, variables);
|
|
14
|
+
const t1 = performance.now();
|
|
15
|
+
debug(`Request to ${url.toString()} completed in ${Math.round(t1 - t0)} ms`);
|
|
16
|
+
return response;
|
|
17
|
+
};
|
|
18
|
+
if (handleErrors) {
|
|
19
|
+
return handlingErrors(api, action);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return action();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function debugLogRequest(api, query, variables, headers = {}) {
|
|
26
|
+
debug(content `
|
|
27
|
+
Sending ${token.json(api)} GraphQL request:
|
|
28
|
+
${token.raw(query.toString())}
|
|
29
|
+
|
|
30
|
+
With variables:
|
|
31
|
+
${variables ? JSON.stringify(variables, null, 2) : ''}
|
|
32
|
+
|
|
33
|
+
And headers:
|
|
34
|
+
${sanitizedHeadersOutput(headers)}
|
|
35
|
+
`);
|
|
36
|
+
}
|
|
37
|
+
async function handlingErrors(api, action) {
|
|
38
|
+
try {
|
|
39
|
+
return await action();
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (error instanceof ClientError) {
|
|
43
|
+
const errorMessage = stringifyMessage(content `
|
|
44
|
+
The ${token.raw(api)} GraphQL API responded unsuccessfully with the HTTP status ${`${error.response.status}`} and errors:
|
|
45
|
+
|
|
46
|
+
${outputToken.json(error.response.errors)}
|
|
47
|
+
`);
|
|
48
|
+
let mappedError;
|
|
49
|
+
if (error.response.status < 500) {
|
|
50
|
+
mappedError = new RequestClientError(errorMessage, error.response.status);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
mappedError = new Abort(errorMessage);
|
|
54
|
+
}
|
|
55
|
+
mappedError.stack = error.stack;
|
|
56
|
+
throw mappedError;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=graphql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../../../src/private/node/api/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,kBAAkB,EAAE,sBAAsB,EAAC,MAAM,cAAc,CAAA;AACrF,OAAO,EAAC,gBAAgB,EAAE,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,oBAAoB,CAAA;AAChG,OAAO,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAA;AACvC,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAC,WAAW,EAAE,aAAa,EAA6B,MA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EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;;;EAGnD,sBAAsB,CAAC,OAAO,CAAC;CAChC,CAAC,CAAA;AACF,CAAC;AAED,KAAK,UAAU,cAAc,CAAI,GAAW,EAAE,MAAwB;IACpE,IAAI;QACF,OAAO,MAAM,MAAM,EAAE,CAAA;KACtB;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,KAAK,YAAY,WAAW,EAAE;YAChC,MAAM,YAAY,GAAG,gBAAgB,CAAC,OAAO,CAAA;QAC3C,KAAK,CAAC,GAAG,CACb,GAAG,CACJ,8DAA8D,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE;;IAEvF,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;OACpC,CAAC,CAAA;YACF,IAAI,WAAkB,CAAA;YACtB,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,GAAG,EAAE;gBAC/B,WAAW,GAAG,IAAI,kBAAkB,CAAC,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;aAC1E;iBAAM;gBACL,WAAW,GAAG,IAAI,KAAK,CAAC,YAAY,CAAC,CAAA;aACtC;YACD,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;YAC/B,MAAM,WAAW,CAAA;SAClB;aAAM;YACL,MAAM,KAAK,CAAA;SACZ;KACF;AACH,CAAC","sourcesContent":["import {buildHeaders, RequestClientError, sanitizedHeadersOutput} from './headers.js'\nimport {stringifyMessage, content, token as outputToken, token, debug} from '../../../output.js'\nimport {Abort} from '../../../error.js'\nimport {httpsAgent} from '../../../http.js'\nimport {ClientError, GraphQLClient, RequestDocument, Variables} from 'graphql-request'\n\nexport interface GraphQLVariables {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n}\n\nexport function graphqlRequest<T>(\n query: RequestDocument,\n api: string,\n url: string,\n token: string,\n variables?: Variables,\n handleErrors = true,\n): Promise<T> {\n const action = async () => {\n const headers = await buildHeaders(token)\n debugLogRequest(api, query, variables, headers)\n const clientOptions = {agent: await httpsAgent(), headers}\n const client = new GraphQLClient(url, clientOptions)\n const t0 = performance.now()\n const response = await client.request<T>(query, variables)\n const t1 = performance.now()\n debug(`Request to ${url.toString()} completed in ${Math.round(t1 - t0)} ms`)\n return response\n }\n\n if (handleErrors) {\n return handlingErrors(api, action)\n } else {\n return action()\n }\n}\n\nfunction debugLogRequest<T>(\n api: string,\n query: RequestDocument,\n variables?: Variables,\n headers: {[key: string]: string} = {},\n) {\n debug(content`\nSending ${token.json(api)} GraphQL request:\n${token.raw(query.toString())}\n\nWith variables:\n${variables ? JSON.stringify(variables, null, 2) : ''}\n\nAnd headers:\n${sanitizedHeadersOutput(headers)}\n`)\n}\n\nasync function handlingErrors<T>(api: string, action: () => Promise<T>): Promise<T> {\n try {\n return await action()\n } catch (error) {\n if (error instanceof ClientError) {\n const errorMessage = stringifyMessage(content`\n The ${token.raw(\n api,\n )} GraphQL API responded unsuccessfully with the HTTP status ${`${error.response.status}`} and errors:\n\n ${outputToken.json(error.response.errors)}\n `)\n let mappedError: Error\n if (error.response.status < 500) {\n mappedError = new RequestClientError(errorMessage, error.response.status)\n } else {\n mappedError = new Abort(errorMessage)\n }\n mappedError.stack = error.stack\n throw mappedError\n } else {\n throw error\n }\n }\n}\n"]}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { ExtendableError } from '
|
|
2
|
-
import { RequestDocument, Variables } from 'graphql-request';
|
|
1
|
+
import { ExtendableError } from '../../../error.js';
|
|
3
2
|
export declare class RequestClientError extends ExtendableError {
|
|
4
3
|
statusCode: number;
|
|
5
4
|
constructor(message: string, statusCode: number);
|
|
6
5
|
}
|
|
7
|
-
export declare function buildHeaders(token?: string): Promise<{
|
|
8
|
-
[key: string]: string;
|
|
9
|
-
}>;
|
|
10
6
|
/**
|
|
11
7
|
* Removes the sensitive data from the headers and outputs them as a string.
|
|
12
8
|
* @param headers - HTTP headers.
|
|
@@ -15,7 +11,6 @@ export declare function buildHeaders(token?: string): Promise<{
|
|
|
15
11
|
export declare function sanitizedHeadersOutput(headers: {
|
|
16
12
|
[key: string]: string;
|
|
17
13
|
}): string;
|
|
18
|
-
export declare function
|
|
14
|
+
export declare function buildHeaders(token?: string): Promise<{
|
|
19
15
|
[key: string]: string;
|
|
20
|
-
}
|
|
21
|
-
export declare function handlingErrors<T>(api: string, action: () => Promise<T>): Promise<T>;
|
|
16
|
+
}>;
|
|
@@ -1,32 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { ClientError } from 'graphql-request';
|
|
6
|
-
import { randomUUID } from 'crypto';
|
|
1
|
+
import constants from '../../../constants.js';
|
|
2
|
+
import { firstPartyDev } from '../../../environment/local.js';
|
|
3
|
+
import { ExtendableError } from '../../../error.js';
|
|
4
|
+
import { randomUUID } from '../../../public/node/crypto.js';
|
|
7
5
|
export class RequestClientError extends ExtendableError {
|
|
8
6
|
constructor(message, statusCode) {
|
|
9
7
|
super(message);
|
|
10
8
|
this.statusCode = statusCode;
|
|
11
9
|
}
|
|
12
10
|
}
|
|
13
|
-
export async function buildHeaders(token) {
|
|
14
|
-
const userAgent = `Shopify CLI; v=${await constants.versions.cliKit()}`;
|
|
15
|
-
const headers = {
|
|
16
|
-
'User-Agent': userAgent,
|
|
17
|
-
// 'Sec-CH-UA': secCHUA, This header requires the Git sha.
|
|
18
|
-
'Sec-CH-UA-PLATFORM': process.platform,
|
|
19
|
-
'X-Request-Id': randomUUID(),
|
|
20
|
-
'Content-Type': 'application/json',
|
|
21
|
-
...(firstPartyDev() && { 'X-Shopify-Cli-Employee': '1' }),
|
|
22
|
-
};
|
|
23
|
-
if (token) {
|
|
24
|
-
// eslint-disable-next-line dot-notation
|
|
25
|
-
headers['authorization'] = `Bearer ${token}`;
|
|
26
|
-
headers['X-Shopify-Access-Token'] = `Bearer ${token}`;
|
|
27
|
-
}
|
|
28
|
-
return headers;
|
|
29
|
-
}
|
|
30
11
|
/**
|
|
31
12
|
* Removes the sensitive data from the headers and outputs them as a string.
|
|
32
13
|
* @param headers - HTTP headers.
|
|
@@ -46,42 +27,21 @@ export function sanitizedHeadersOutput(headers) {
|
|
|
46
27
|
})
|
|
47
28
|
.join('\n');
|
|
48
29
|
}
|
|
49
|
-
export function
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return await action();
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
if (error instanceof ClientError) {
|
|
67
|
-
const errorMessage = stringifyMessage(content `
|
|
68
|
-
The ${token.raw(api)} GraphQL API responded unsuccessfully with the HTTP status ${`${error.response.status}`} and errors:
|
|
69
|
-
|
|
70
|
-
${outputToken.json(error.response.errors)}
|
|
71
|
-
`);
|
|
72
|
-
let mappedError;
|
|
73
|
-
if (error.response.status < 500) {
|
|
74
|
-
mappedError = new RequestClientError(errorMessage, error.response.status);
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
mappedError = new Abort(errorMessage);
|
|
78
|
-
}
|
|
79
|
-
mappedError.stack = error.stack;
|
|
80
|
-
throw mappedError;
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
throw error;
|
|
84
|
-
}
|
|
30
|
+
export async function buildHeaders(token) {
|
|
31
|
+
const userAgent = `Shopify CLI; v=${await constants.versions.cliKit()}`;
|
|
32
|
+
const headers = {
|
|
33
|
+
'User-Agent': userAgent,
|
|
34
|
+
// 'Sec-CH-UA': secCHUA, This header requires the Git sha.
|
|
35
|
+
'Sec-CH-UA-PLATFORM': process.platform,
|
|
36
|
+
'X-Request-Id': randomUUID(),
|
|
37
|
+
'Content-Type': 'application/json',
|
|
38
|
+
...(firstPartyDev() && { 'X-Shopify-Cli-Employee': '1' }),
|
|
39
|
+
};
|
|
40
|
+
if (token) {
|
|
41
|
+
// eslint-disable-next-line dot-notation
|
|
42
|
+
headers['authorization'] = `Bearer ${token}`;
|
|
43
|
+
headers['X-Shopify-Access-Token'] = `Bearer ${token}`;
|
|
85
44
|
}
|
|
45
|
+
return headers;
|
|
86
46
|
}
|
|
87
|
-
//# sourceMappingURL=
|
|
47
|
+
//# sourceMappingURL=headers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.js","sourceRoot":"","sources":["../../../../src/private/node/api/headers.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EAAC,aAAa,EAAC,MAAM,+BAA+B,CAAA;AAC3D,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,UAAU,EAAC,MAAM,gCAAgC,CAAA;AAEzD,MAAM,OAAO,kBAAmB,SAAQ,eAAe;IAErD,YAAmB,OAAe,EAAE,UAAkB;QACpD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAgC;IACrE,MAAM,SAAS,GAA4B,EAAE,CAAA;IAC7C,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;IAC3C,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACtC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAK,SAAS,EAAE;YAC1F,SAAS,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAE,CAAA;SACrC;IACH,CAAC,CAAC,CAAA;IACF,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;SAC1B,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACd,OAAO,MAAM,MAAM,KAAK,SAAS,CAAC,MAAM,CAAC,EAAE,CAAA;IAC7C,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAA;AACf,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,KAAc;IAC/C,MAAM,SAAS,GAAG,kBAAkB,MAAM,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAA;IAEvE,MAAM,OAAO,GAA+B;QAC1C,YAAY,EAAE,SAAS;QACvB,0DAA0D;QAC1D,oBAAoB,EAAE,OAAO,CAAC,QAAQ;QACtC,cAAc,EAAE,UAAU,EAAE;QAC5B,cAAc,EAAE,kBAAkB;QAClC,GAAG,CAAC,aAAa,EAAE,IAAI,EAAC,wBAAwB,EAAE,GAAG,EAAC,CAAC;KACxD,CAAA;IACD,IAAI,KAAK,EAAE;QACT,wCAAwC;QACxC,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,KAAK,EAAE,CAAA;QAC5C,OAAO,CAAC,wBAAwB,CAAC,GAAG,UAAU,KAAK,EAAE,CAAA;KACtD;IAED,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["import constants from '../../../constants.js'\nimport {firstPartyDev} from '../../../environment/local.js'\nimport {ExtendableError} from '../../../error.js'\nimport {randomUUID} from '../../../public/node/crypto.js'\n\nexport class RequestClientError extends ExtendableError {\n statusCode: number\n public constructor(message: string, statusCode: number) {\n super(message)\n this.statusCode = statusCode\n }\n}\n\n/**\n * Removes the sensitive data from the headers and outputs them as a string.\n * @param headers - HTTP headers.\n * @returns A sanitized version of the headers as a string.\n */\nexport function sanitizedHeadersOutput(headers: {[key: string]: string}): string {\n const sanitized: {[key: string]: string} = {}\n const keywords = ['token', 'authorization']\n Object.keys(headers).forEach((header) => {\n if (keywords.find((keyword) => header.toLocaleLowerCase().includes(keyword)) === undefined) {\n sanitized[header] = headers[header]!\n }\n })\n return Object.keys(sanitized)\n .map((header) => {\n return ` - ${header}: ${sanitized[header]}`\n })\n .join('\\n')\n}\n\nexport async function buildHeaders(token?: string): Promise<{[key: string]: string}> {\n const userAgent = `Shopify CLI; v=${await constants.versions.cliKit()}`\n\n const headers: {[header: string]: string} = {\n 'User-Agent': userAgent,\n // 'Sec-CH-UA': secCHUA, This header requires the Git sha.\n 'Sec-CH-UA-PLATFORM': process.platform,\n 'X-Request-Id': randomUUID(),\n 'Content-Type': 'application/json',\n ...(firstPartyDev() && {'X-Shopify-Cli-Employee': '1'}),\n }\n if (token) {\n // eslint-disable-next-line dot-notation\n headers['authorization'] = `Bearer ${token}`\n headers['X-Shopify-Access-Token'] = `Bearer ${token}`\n }\n\n return headers\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AdminSession } from '../../../session.js';
|
|
2
|
+
export declare function restRequestBody<T>(requestBody?: T): string | undefined;
|
|
3
|
+
export declare function restRequestUrl(session: AdminSession, apiVersion: string, path: string): string;
|
|
4
|
+
export declare function restRequestHeaders(session: AdminSession): Promise<{
|
|
5
|
+
[key: string]: string;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { buildHeaders } from './headers.js';
|
|
2
|
+
export function restRequestBody(requestBody) {
|
|
3
|
+
if (!requestBody) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
return JSON.stringify(requestBody);
|
|
7
|
+
}
|
|
8
|
+
export function restRequestUrl(session, apiVersion, path) {
|
|
9
|
+
if (isThemeAccessSession(session)) {
|
|
10
|
+
return `https://theme-kit-access.shopifyapps.com/cli/admin/api/${apiVersion}${path}.json`;
|
|
11
|
+
}
|
|
12
|
+
return `https://${session.storeFqdn}/admin/api/${apiVersion}${path}.json`;
|
|
13
|
+
}
|
|
14
|
+
export async function restRequestHeaders(session) {
|
|
15
|
+
const store = session.storeFqdn;
|
|
16
|
+
const token = session.token;
|
|
17
|
+
const headers = await buildHeaders(session.token);
|
|
18
|
+
if (isThemeAccessSession(session)) {
|
|
19
|
+
headers['X-Shopify-Shop'] = store;
|
|
20
|
+
headers['X-Shopify-Access-Token'] = token;
|
|
21
|
+
}
|
|
22
|
+
return headers;
|
|
23
|
+
}
|
|
24
|
+
function isThemeAccessSession(session) {
|
|
25
|
+
return session.token.startsWith('shptka_');
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=rest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rest.js","sourceRoot":"","sources":["../../../../src/private/node/api/rest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAA;AAGzC,MAAM,UAAU,eAAe,CAAI,WAAe;IAChD,IAAI,CAAC,WAAW,EAAE;QAChB,OAAM;KACP;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;AACpC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,OAAqB,EAAE,UAAkB,EAAE,IAAY;IACpF,IAAI,oBAAoB,CAAC,OAAO,CAAC,EAAE;QACjC,OAAO,0DAA0D,UAAU,GAAG,IAAI,OAAO,CAAA;KAC1F;IAED,OAAO,WAAW,OAAO,CAAC,SAAS,cAAc,UAAU,GAAG,IAAI,OAAO,CAAA;AAC3E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAAqB;IAC5D,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAA;IAC/B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAA;IAC3B,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAEjD,IAAI,oBAAoB,CAAC,OAAO,CAAC,EAAE;QACjC,OAAO,CAAC,gBAAgB,CAAC,GAAG,KAAK,CAAA;QACjC,OAAO,CAAC,wBAAwB,CAAC,GAAG,KAAK,CAAA;KAC1C;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAS,oBAAoB,CAAC,OAAqB;IACjD,OAAO,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;AAC5C,CAAC","sourcesContent":["import {buildHeaders} from './headers.js'\nimport {AdminSession} from '../../../session.js'\n\nexport function restRequestBody<T>(requestBody?: T) {\n if (!requestBody) {\n return\n }\n return JSON.stringify(requestBody)\n}\n\nexport function restRequestUrl(session: AdminSession, apiVersion: string, path: string) {\n if (isThemeAccessSession(session)) {\n return `https://theme-kit-access.shopifyapps.com/cli/admin/api/${apiVersion}${path}.json`\n }\n\n return `https://${session.storeFqdn}/admin/api/${apiVersion}${path}.json`\n}\n\nexport async function restRequestHeaders(session: AdminSession) {\n const store = session.storeFqdn\n const token = session.token\n const headers = await buildHeaders(session.token)\n\n if (isThemeAccessSession(session)) {\n headers['X-Shopify-Shop'] = store\n headers['X-Shopify-Access-Token'] = token\n }\n\n return headers\n}\n\nfunction isThemeAccessSession(session: AdminSession) {\n return session.token.startsWith('shptka_')\n}\n"]}
|