@shopify/cli-kit 3.0.24 → 3.0.27
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 +32 -0
- package/assets/auth-error.html +2 -4
- package/assets/empty-url.html +2 -4
- package/assets/missing-code.html +2 -4
- package/assets/missing-state.html +2 -4
- package/assets/style.css +5 -8
- package/assets/success.html +1 -1
- package/dist/abort.d.ts +1 -0
- package/dist/abort.js +2 -0
- package/dist/abort.js.map +1 -0
- package/dist/analytics.d.ts +11 -0
- package/dist/analytics.js +96 -0
- package/dist/analytics.js.map +1 -0
- package/dist/api/admin.d.ts +3 -0
- package/dist/api/admin.js +80 -0
- package/dist/api/admin.js.map +1 -0
- package/dist/api/common.d.ts +11 -0
- package/dist/api/common.js +40 -0
- package/dist/api/common.js.map +1 -0
- package/dist/api/graphql/all_app_extension_registrations.d.ts +14 -0
- package/dist/api/graphql/all_app_extension_registrations.js +14 -0
- package/dist/api/graphql/all_app_extension_registrations.js.map +1 -0
- package/dist/api/graphql/all_orgs.d.ts +12 -0
- package/dist/api/graphql/all_orgs.js +14 -0
- package/dist/api/graphql/all_orgs.js.map +1 -0
- package/dist/api/graphql/all_stores_by_org.d.ts +18 -0
- package/dist/api/graphql/all_stores_by_org.js +21 -0
- package/dist/api/graphql/all_stores_by_org.js.map +1 -0
- package/dist/api/graphql/convert_dev_to_test_store.d.ts +16 -0
- package/dist/api/graphql/convert_dev_to_test_store.js +13 -0
- package/dist/api/graphql/convert_dev_to_test_store.js.map +1 -0
- package/dist/api/graphql/create_app.d.ts +28 -0
- package/dist/api/graphql/create_app.js +32 -0
- package/dist/api/graphql/create_app.js.map +1 -0
- package/dist/api/graphql/create_deployment.d.ts +33 -0
- package/dist/api/graphql/create_deployment.js +25 -0
- package/dist/api/graphql/create_deployment.js.map +1 -0
- package/dist/api/graphql/extension_create.d.ts +30 -0
- package/dist/api/graphql/extension_create.js +26 -0
- package/dist/api/graphql/extension_create.js.map +1 -0
- package/dist/api/graphql/extension_specifications.d.ts +18 -0
- package/dist/api/graphql/extension_specifications.js +18 -0
- package/dist/api/graphql/extension_specifications.js.map +1 -0
- package/dist/api/graphql/find_app.d.ts +13 -0
- package/dist/api/graphql/find_app.js +16 -0
- package/dist/api/graphql/find_app.js.map +1 -0
- package/dist/api/graphql/find_org.d.ts +23 -0
- package/dist/api/graphql/find_org.js +26 -0
- package/dist/api/graphql/find_org.js.map +1 -0
- package/dist/api/graphql/find_org_basic.d.ts +11 -0
- package/dist/api/graphql/find_org_basic.js +14 -0
- package/dist/api/graphql/find_org_basic.js.map +1 -0
- package/dist/api/graphql/functions/app_function_set.d.ts +43 -0
- package/dist/api/graphql/functions/app_function_set.js +52 -0
- package/dist/api/graphql/functions/app_function_set.js.map +1 -0
- package/dist/api/graphql/functions/compile_module.d.ts +15 -0
- package/dist/api/graphql/functions/compile_module.js +13 -0
- package/dist/api/graphql/functions/compile_module.js.map +1 -0
- package/dist/api/graphql/functions/function_service_proxy.d.ts +4 -0
- package/dist/api/graphql/functions/function_service_proxy.js +7 -0
- package/dist/api/graphql/functions/function_service_proxy.js.map +1 -0
- package/dist/api/graphql/functions/get_app_functions.d.ts +1 -0
- package/dist/api/graphql/functions/get_app_functions.js +10 -0
- package/dist/api/graphql/functions/get_app_functions.js.map +1 -0
- package/dist/api/graphql/functions/module_compilation_status.d.ts +15 -0
- package/dist/api/graphql/functions/module_compilation_status.js +13 -0
- package/dist/api/graphql/functions/module_compilation_status.js.map +1 -0
- package/dist/api/graphql/functions/module_upload_url_generate.d.ts +18 -0
- package/dist/api/graphql/functions/module_upload_url_generate.js +17 -0
- package/dist/api/graphql/functions/module_upload_url_generate.js.map +1 -0
- package/dist/api/graphql/generate_signed_upload_url.d.ts +15 -0
- package/dist/api/graphql/generate_signed_upload_url.js +15 -0
- package/dist/api/graphql/generate_signed_upload_url.js.map +1 -0
- package/dist/api/graphql/get_variant_id.d.ts +17 -0
- package/dist/api/graphql/get_variant_id.js +20 -0
- package/dist/api/graphql/get_variant_id.js.map +1 -0
- package/dist/api/graphql/index.d.ts +21 -0
- package/dist/api/graphql/index.js +22 -0
- package/dist/api/graphql/index.js.map +1 -0
- package/dist/api/graphql/update_draft.d.ts +33 -0
- package/dist/api/graphql/update_draft.js +24 -0
- package/dist/api/graphql/update_draft.js.map +1 -0
- package/dist/api/graphql/update_urls.d.ts +14 -0
- package/dist/api/graphql/update_urls.js +12 -0
- package/dist/api/graphql/update_urls.js.map +1 -0
- package/dist/api/identity.d.ts +1 -0
- package/dist/api/identity.js +32 -0
- package/dist/api/identity.js.map +1 -0
- package/dist/api/partners.d.ts +25 -0
- package/dist/api/partners.js +100 -0
- package/dist/api/partners.js.map +1 -0
- package/dist/api.d.ts +5 -0
- package/dist/api.js +6 -0
- package/dist/api.js.map +1 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.js +13 -0
- package/dist/cli.js.map +1 -0
- package/dist/colors.d.ts +1 -0
- package/dist/colors.js +8 -0
- package/dist/colors.js.map +1 -0
- package/dist/constants.d.ts +43 -0
- package/dist/constants.js +63 -0
- package/dist/constants.js.map +1 -0
- package/dist/dependency.d.ts +128 -0
- package/dist/dependency.js +302 -0
- package/dist/dependency.js.map +1 -0
- package/dist/environment/fqdn.d.ts +23 -0
- package/dist/environment/fqdn.js +61 -0
- package/dist/environment/fqdn.js.map +1 -0
- package/dist/environment/local.d.ts +48 -0
- package/dist/environment/local.js +82 -0
- package/dist/environment/local.js.map +1 -0
- package/dist/environment/service.d.ts +17 -0
- package/dist/environment/service.js +41 -0
- package/dist/environment/service.js.map +1 -0
- package/dist/environment/spin.d.ts +47 -0
- package/dist/environment/spin.js +83 -0
- package/dist/environment/spin.js.map +1 -0
- package/dist/environment/utilities.d.ts +6 -0
- package/dist/environment/utilities.js +12 -0
- package/dist/environment/utilities.js.map +1 -0
- package/dist/environment.d.ts +5 -0
- package/dist/environment.js +6 -0
- package/dist/environment.js.map +1 -0
- package/dist/error.d.ts +44 -0
- package/dist/error.js +91 -0
- package/dist/error.js.map +1 -0
- package/dist/file.d.ts +67 -0
- package/dist/file.js +165 -0
- package/dist/file.js.map +1 -0
- package/dist/git.d.ts +15 -0
- package/dist/git.js +48 -0
- package/dist/git.js.map +1 -0
- package/dist/github.d.ts +33 -0
- package/dist/github.js +56 -0
- package/dist/github.js.map +1 -0
- package/dist/haiku.d.ts +1 -0
- package/dist/haiku.js +8 -0
- package/dist/haiku.js.map +1 -0
- package/dist/http/fetch.d.ts +16 -0
- package/dist/http/fetch.js +18 -0
- package/dist/http/fetch.js.map +1 -0
- package/dist/http/formdata.d.ts +3 -0
- package/dist/http/formdata.js +6 -0
- package/dist/http/formdata.js.map +1 -0
- package/dist/http.d.ts +2 -0
- package/dist/http.js +3 -0
- package/dist/http.js.map +1 -0
- package/dist/id.d.ts +6 -0
- package/dist/id.js +18 -0
- package/dist/id.js.map +1 -0
- package/dist/index.d.ts +34 -2115
- package/dist/index.js +35 -46
- package/dist/index.js.map +1 -1
- package/dist/network/api.d.ts +2 -0
- package/dist/network/api.js +2 -0
- package/dist/network/api.js.map +1 -0
- package/dist/network/service.d.ts +16 -0
- package/dist/network/service.js +12 -0
- package/dist/network/service.js.map +1 -0
- package/dist/node/archiver.d.ts +6 -0
- package/dist/node/archiver.js +24 -0
- package/dist/node/archiver.js.map +1 -0
- package/dist/node/checksum.d.ts +20 -0
- package/dist/node/checksum.js +32 -0
- package/dist/node/checksum.js.map +1 -0
- package/dist/node/cli.d.ts +18 -0
- package/dist/node/cli.js +91 -0
- package/dist/node/cli.js.map +1 -0
- package/dist/node/dot-env.d.ts +33 -0
- package/dist/node/dot-env.js +36 -0
- package/dist/node/dot-env.js.map +1 -0
- package/dist/node/ruby.d.ts +30 -0
- package/dist/node/ruby.js +197 -0
- package/dist/node/ruby.js.map +1 -0
- package/dist/npm.d.ts +27 -0
- package/dist/npm.js +20 -0
- package/dist/npm.js.map +1 -0
- package/dist/os.d.ts +10 -0
- package/dist/os.js +70 -0
- package/dist/os.js.map +1 -0
- package/dist/output.d.ts +142 -0
- package/dist/output.js +505 -0
- package/dist/output.js.map +1 -0
- package/dist/path.d.ts +22 -0
- package/dist/path.js +43 -0
- package/dist/path.js.map +1 -0
- package/dist/plugins.d.ts +9 -0
- package/dist/plugins.js +12 -0
- package/dist/plugins.js.map +1 -0
- package/dist/port.d.ts +5 -0
- package/dist/port.js +13 -0
- package/dist/port.js.map +1 -0
- package/dist/schema.d.ts +1 -0
- package/dist/schema.js +2 -0
- package/dist/schema.js.map +1 -0
- package/dist/secure-store.d.ts +19 -0
- package/dist/secure-store.js +63 -0
- package/dist/secure-store.js.map +1 -0
- package/dist/semver.d.ts +3 -0
- package/dist/semver.js +6 -0
- package/dist/semver.js.map +1 -0
- package/dist/session/authorize.d.ts +7 -0
- package/dist/session/authorize.js +40 -0
- package/dist/session/authorize.js.map +1 -0
- package/dist/session/exchange.d.ts +42 -0
- package/dist/session/exchange.js +144 -0
- package/dist/session/exchange.js.map +1 -0
- package/dist/session/identity.d.ts +3 -0
- package/dist/session/identity.js +58 -0
- package/dist/session/identity.js.map +1 -0
- package/dist/session/post-auth.d.ts +13 -0
- package/dist/session/post-auth.js +56 -0
- package/dist/session/post-auth.js.map +1 -0
- package/dist/session/redirect-listener.d.ts +34 -0
- package/dist/session/redirect-listener.js +97 -0
- package/dist/session/redirect-listener.js.map +1 -0
- package/dist/session/schema.d.ts +174 -0
- package/dist/session/schema.js +59 -0
- package/dist/session/schema.js.map +1 -0
- package/dist/session/scopes.d.ts +16 -0
- package/dist/session/scopes.js +53 -0
- package/dist/session/scopes.js.map +1 -0
- package/dist/session/store.d.ts +24 -0
- package/dist/session/store.js +88 -0
- package/dist/session/store.js.map +1 -0
- package/dist/session/token.d.ts +40 -0
- package/dist/session/token.js +22 -0
- package/dist/session/token.js.map +1 -0
- package/dist/session/validate.d.ts +17 -0
- package/dist/session/validate.js +75 -0
- package/dist/session/validate.js.map +1 -0
- package/dist/session.d.ts +88 -0
- package/dist/session.js +251 -0
- package/dist/session.js.map +1 -0
- package/dist/store/schema.d.ts +3 -0
- package/dist/store/schema.js +27 -0
- package/dist/store/schema.js.map +1 -0
- package/dist/store.d.ts +32 -0
- package/dist/store.js +102 -0
- package/dist/store.js.map +1 -0
- package/dist/string.d.ts +22 -0
- package/dist/string.js +38 -0
- package/dist/string.js.map +1 -0
- package/dist/system.d.ts +53 -0
- package/dist/system.js +109 -0
- package/dist/system.js.map +1 -0
- package/dist/template.d.ts +11 -0
- package/dist/template.js +50 -0
- package/dist/template.js.map +1 -0
- package/dist/testing/output.d.ts +9 -0
- package/dist/testing/output.js +15 -0
- package/dist/testing/output.js.map +1 -0
- package/dist/testing/store.d.ts +7 -0
- package/dist/testing/store.js +26 -0
- package/dist/testing/store.js.map +1 -0
- package/dist/toml.d.ts +3 -0
- package/dist/toml.js +8 -0
- package/dist/toml.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/ui/autocomplete.d.ts +7 -0
- package/dist/ui/autocomplete.js +43 -0
- package/dist/ui/autocomplete.js.map +1 -0
- package/dist/ui/input.d.ts +7 -0
- package/dist/ui/input.js +48 -0
- package/dist/ui/input.js.map +1 -0
- package/dist/ui/select.d.ts +6 -0
- package/dist/ui/select.js +30 -0
- package/dist/ui/select.js.map +1 -0
- package/dist/ui.d.ts +36 -0
- package/dist/ui.js +124 -0
- package/dist/ui.js.map +1 -0
- package/dist/version.d.ts +19 -0
- package/dist/version.js +34 -0
- package/dist/version.js.map +1 -0
- package/dist/vscode.d.ts +8 -0
- package/dist/vscode.js +36 -0
- package/dist/vscode.js.map +1 -0
- package/dist/yaml.d.ts +2 -0
- package/dist/yaml.js +8 -0
- package/dist/yaml.js.map +1 -0
- package/package.json +32 -21
- package/dist/index-eb280c22.js +0 -175294
- package/dist/index-eb280c22.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/multipart-parser-84c10b92.js +0 -477
- package/dist/multipart-parser-84c10b92.js.map +0 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { isTruthy } from './utilities.js';
|
|
2
|
+
import { isSpin } from './spin.js';
|
|
3
|
+
import constants from '../constants.js';
|
|
4
|
+
import { exists as fileExists } from '../file.js';
|
|
5
|
+
import { exec } from '../system.js';
|
|
6
|
+
import isInteractive from 'is-interactive';
|
|
7
|
+
import { homedir } from 'node:os';
|
|
8
|
+
/**
|
|
9
|
+
* It returns true if the terminal is interactive.
|
|
10
|
+
* @returns {boolean} True if the terminal is interactive.
|
|
11
|
+
*/
|
|
12
|
+
export function isTerminalInteractive() {
|
|
13
|
+
return isInteractive();
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Returns the path to the user's home directory.
|
|
17
|
+
* @returns {string} The path to the user's home directory.
|
|
18
|
+
*/
|
|
19
|
+
export function homeDirectory() {
|
|
20
|
+
return homedir();
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns true if the CLI is running in debug mode.
|
|
24
|
+
* @param env The environment variables from the environment of the current process.
|
|
25
|
+
* @returns true if SHOPIFY_CONFIG is debug
|
|
26
|
+
*/
|
|
27
|
+
export function isDebug(env = process.env) {
|
|
28
|
+
return env[constants.environmentVariables.shopifyConfig] === 'debug';
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Returns true if the CLI is running in verbose mode.
|
|
32
|
+
* @param env The environment variables from the environment of the current process.
|
|
33
|
+
* @returns true if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed
|
|
34
|
+
*/
|
|
35
|
+
export function isVerbose(env = process.env) {
|
|
36
|
+
return isTruthy(env[constants.environmentVariables.verbose]) || process.argv.includes('--verbose');
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns true if the environment in which the CLI is running is either
|
|
40
|
+
* a local environment (where dev is present) or a cloud environment (spin).
|
|
41
|
+
* @returns {boolean} True if the CLI is used in a Shopify environment.
|
|
42
|
+
*/
|
|
43
|
+
export async function isShopify(env = process.env) {
|
|
44
|
+
if (Object.prototype.hasOwnProperty.call(env, constants.environmentVariables.runAsUser)) {
|
|
45
|
+
return !isTruthy(env[constants.environmentVariables.runAsUser]);
|
|
46
|
+
}
|
|
47
|
+
const devInstalled = await fileExists(constants.paths.executables.dev);
|
|
48
|
+
return devInstalled || isSpin();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* This variable is used when running unit tests to indicate that the CLI's business logic
|
|
52
|
+
* is run as a subject of a unit test. We can use this variable to disable output through
|
|
53
|
+
* the standard streams.
|
|
54
|
+
* @param env The environment variables from the environment of the current process.
|
|
55
|
+
* @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.
|
|
56
|
+
*/
|
|
57
|
+
export function isUnitTest(env = process.env) {
|
|
58
|
+
return isTruthy(env[constants.environmentVariables.unitTest]);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Returns true if reporting analytics is enabled.
|
|
62
|
+
* @param env The environment variables from the environment of the current process.
|
|
63
|
+
* @returns true unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.
|
|
64
|
+
*/
|
|
65
|
+
export function analyticsDisabled(env = process.env) {
|
|
66
|
+
return isTruthy(env[constants.environmentVariables.noAnalytics]) || isDebug(env);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Returns whether the environment has Git available.
|
|
70
|
+
* @returns {Promise<boolean>} A promise that resolves with the value.
|
|
71
|
+
*/
|
|
72
|
+
export async function hasGit() {
|
|
73
|
+
try {
|
|
74
|
+
await exec('git', ['--version']);
|
|
75
|
+
return true;
|
|
76
|
+
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/environment/local.ts"],"names":[],"mappings":"AAAA,OAAO,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AAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IACtE,OAAO,YAAY,IAAI,MAAM,EAAE,CAAA;AACjC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IAC1C,OAAO,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAA;AAC/D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACjD,OAAO,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,CAAA;AAClF,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM;IAC1B,IAAI;QACF,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;QAChC,OAAO,IAAI,CAAA;QACX,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC","sourcesContent":["import {isTruthy} 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_CONFIG is debug\n */\nexport function isDebug(env = process.env): boolean {\n return env[constants.environmentVariables.shopifyConfig] === 'debug'\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]) || isDebug(env)\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"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Environment } from '../network/service.js';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the environment to be used for the interactions with the partners' CLI API.
|
|
5
|
+
* @param env The environment variables from the environment of the current process.
|
|
6
|
+
*/
|
|
7
|
+
export declare function partners(env?: NodeJS.ProcessEnv): Environment;
|
|
8
|
+
/**
|
|
9
|
+
* Returns the environment to be used for the interactions with the admin API.
|
|
10
|
+
* @param env The environment variables from the environment of the current process.
|
|
11
|
+
*/
|
|
12
|
+
export declare function shopify(env?: NodeJS.ProcessEnv): Environment;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the environment to be used for the interactions with identity.
|
|
15
|
+
* @param env The environment variables from the environment of the current process.
|
|
16
|
+
*/
|
|
17
|
+
export declare function identity(env?: NodeJS.ProcessEnv): Environment;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Environment } from '../network/service.js';
|
|
2
|
+
import constants from '../constants.js';
|
|
3
|
+
/**
|
|
4
|
+
* Given an environment variable that represents the environment to use for a given serve,
|
|
5
|
+
* it returns the environment as a enum;
|
|
6
|
+
* @param value The environment variable value.
|
|
7
|
+
* @returns {Environment} representing the environment to use.
|
|
8
|
+
*/
|
|
9
|
+
function service(value) {
|
|
10
|
+
if (value === 'local') {
|
|
11
|
+
return Environment.Local;
|
|
12
|
+
}
|
|
13
|
+
else if (value === 'spin') {
|
|
14
|
+
return Environment.Spin;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return Environment.Production;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns the environment to be used for the interactions with the partners' CLI API.
|
|
22
|
+
* @param env The environment variables from the environment of the current process.
|
|
23
|
+
*/
|
|
24
|
+
export function partners(env = process.env) {
|
|
25
|
+
return service(env[constants.environmentVariables.partnersEnv]);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Returns the environment to be used for the interactions with the admin API.
|
|
29
|
+
* @param env The environment variables from the environment of the current process.
|
|
30
|
+
*/
|
|
31
|
+
export function shopify(env = process.env) {
|
|
32
|
+
return service(env[constants.environmentVariables.shopifyEnv]);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns the environment to be used for the interactions with identity.
|
|
36
|
+
* @param env The environment variables from the environment of the current process.
|
|
37
|
+
*/
|
|
38
|
+
export function identity(env = process.env) {
|
|
39
|
+
return service(env[constants.environmentVariables.identityEnv]);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/environment/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAA;AACjD,OAAO,SAAS,MAAM,iBAAiB,CAAA;AAEvC;;;;;GAKG;AACH,SAAS,OAAO,CAAC,KAAyB;IACxC,IAAI,KAAK,KAAK,OAAO,EAAE;QACrB,OAAO,WAAW,CAAC,KAAK,CAAA;KACzB;SAAM,IAAI,KAAK,KAAK,MAAM,EAAE;QAC3B,OAAO,WAAW,CAAC,IAAI,CAAA;KACxB;SAAM;QACL,OAAO,WAAW,CAAC,UAAU,CAAA;KAC9B;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACxC,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAA;AACjE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACvC,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAA;AAChE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACxC,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAA;AACjE,CAAC","sourcesContent":["import {Environment} from '../network/service.js'\nimport constants from '../constants.js'\n\n/**\n * Given an environment variable that represents the environment to use for a given serve,\n * it returns the environment as a enum;\n * @param value The environment variable value.\n * @returns {Environment} representing the environment to use.\n */\nfunction service(value: undefined | string): Environment {\n if (value === 'local') {\n return Environment.Local\n } else if (value === 'spin') {\n return Environment.Spin\n } else {\n return Environment.Production\n }\n}\n\n/**\n * Returns the environment to be used for the interactions with the partners' CLI API.\n * @param env The environment variables from the environment of the current process.\n */\nexport function partners(env = process.env): Environment {\n return service(env[constants.environmentVariables.partnersEnv])\n}\n\n/**\n * Returns the environment to be used for the interactions with the admin API.\n * @param env The environment variables from the environment of the current process.\n */\nexport function shopify(env = process.env): Environment {\n return service(env[constants.environmentVariables.shopifyEnv])\n}\n\n/**\n * Returns the environment to be used for the interactions with identity.\n * @param env The environment variables from the environment of the current process.\n */\nexport function identity(env = process.env): Environment {\n return service(env[constants.environmentVariables.identityEnv])\n}\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Abort } from '../error.js';
|
|
3
|
+
export declare const SpinInstanceNotFound: (spinInstance: string | undefined, error: string) => Abort;
|
|
4
|
+
/**
|
|
5
|
+
* When ran in a Spin environment, it returns the fqdn of the instance.
|
|
6
|
+
* @returns {string} fqdn of the Spin environment.
|
|
7
|
+
*/
|
|
8
|
+
export declare function fqdn(env?: NodeJS.ProcessEnv): Promise<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Runs "spin show" and returns the JSON-parsed output.
|
|
11
|
+
* @param {latest} Whether to pass --latest when running the command.
|
|
12
|
+
* @returns The JSON-parsed output of the Spin CLI.
|
|
13
|
+
* @throws Any error raised from the underlying Spin CLI.
|
|
14
|
+
*/
|
|
15
|
+
export declare function show(spinInstance: string | undefined, env?: NodeJS.ProcessEnv): Promise<{
|
|
16
|
+
fqdn: string;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Returns true if the CLI is running in a Spin environment.
|
|
20
|
+
* @param env {[key: string]: string} Environment variables
|
|
21
|
+
* @returns {boolean} True if the CLI is running in a Spin environment.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isSpin(env?: NodeJS.ProcessEnv): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Returns the value of the SPIN_INSTANCE environment variable.
|
|
26
|
+
* @param env {[key: string]: string} Environment variables
|
|
27
|
+
* @returns {string | undefined} The value of the SPIN_INSTANCE environment variable.
|
|
28
|
+
*/
|
|
29
|
+
export declare function instance(env?: NodeJS.ProcessEnv): string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Returns the value of the SPIN_WORKSPACE environment variable.
|
|
32
|
+
* @param env {[key: string]: string} Environment variables
|
|
33
|
+
* @returns {string | undefined} The value of the SPIN_WORKSPACE environment variable.
|
|
34
|
+
*/
|
|
35
|
+
export declare function workspace(env?: NodeJS.ProcessEnv): string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the value of the SPIN_NAMESPACE environment variable.
|
|
38
|
+
* @param env {[key: string]: string} Environment variables
|
|
39
|
+
* @returns {string | undefined} The value of the SPIN_NAMESPACE environment variable.
|
|
40
|
+
*/
|
|
41
|
+
export declare function namespace(env?: NodeJS.ProcessEnv): string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the value of the SPIN_HOST environment variable.
|
|
44
|
+
* @param env {[key: string]: string} Environment variables
|
|
45
|
+
* @returns {string | undefined} The value of the SPIN_HOST environment variable.
|
|
46
|
+
*/
|
|
47
|
+
export declare function host(env?: NodeJS.ProcessEnv): string | undefined;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { isTruthy } from './utilities.js';
|
|
2
|
+
import constants from '../constants.js';
|
|
3
|
+
import { captureOutput } from '../system.js';
|
|
4
|
+
import { Abort } from '../error.js';
|
|
5
|
+
import { content, token } from '../output.js';
|
|
6
|
+
export const SpinInstanceNotFound = (spinInstance, error) => {
|
|
7
|
+
const errorMessage = content `${token.genericShellCommand(`spin`)} yielded the following error trying to obtain the fully qualified domain name of the Spin instance:
|
|
8
|
+
${error}
|
|
9
|
+
`;
|
|
10
|
+
let nextSteps;
|
|
11
|
+
if (spinInstance) {
|
|
12
|
+
nextSteps = `Make sure ${spinInstance} is the instance name and not a fully qualified domain name`;
|
|
13
|
+
}
|
|
14
|
+
return new Abort(errorMessage, nextSteps);
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* When ran in a Spin environment, it returns the fqdn of the instance.
|
|
18
|
+
* @returns {string} fqdn of the Spin environment.
|
|
19
|
+
*/
|
|
20
|
+
export async function fqdn(env = process.env) {
|
|
21
|
+
const spinInstance = await instance(env);
|
|
22
|
+
const showResponse = await show(spinInstance, env);
|
|
23
|
+
return showResponse.fqdn;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Runs "spin show" and returns the JSON-parsed output.
|
|
27
|
+
* @param {latest} Whether to pass --latest when running the command.
|
|
28
|
+
* @returns The JSON-parsed output of the Spin CLI.
|
|
29
|
+
* @throws Any error raised from the underlying Spin CLI.
|
|
30
|
+
*/
|
|
31
|
+
export async function show(spinInstance, env = process.env) {
|
|
32
|
+
const latest = spinInstance === undefined;
|
|
33
|
+
const args = latest ? ['show', '--latest', '--json'] : ['show', '--json'];
|
|
34
|
+
const output = await captureOutput('spin', args, { env });
|
|
35
|
+
const json = JSON.parse(output);
|
|
36
|
+
if (json.error) {
|
|
37
|
+
throw SpinInstanceNotFound(spinInstance, json.error);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return json;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns true if the CLI is running in a Spin environment.
|
|
45
|
+
* @param env {[key: string]: string} Environment variables
|
|
46
|
+
* @returns {boolean} True if the CLI is running in a Spin environment.
|
|
47
|
+
*/
|
|
48
|
+
export function isSpin(env = process.env) {
|
|
49
|
+
return isTruthy(env[constants.environmentVariables.spin]);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Returns the value of the SPIN_INSTANCE environment variable.
|
|
53
|
+
* @param env {[key: string]: string} Environment variables
|
|
54
|
+
* @returns {string | undefined} The value of the SPIN_INSTANCE environment variable.
|
|
55
|
+
*/
|
|
56
|
+
export function instance(env = process.env) {
|
|
57
|
+
return env[constants.environmentVariables.spinInstance];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Returns the value of the SPIN_WORKSPACE environment variable.
|
|
61
|
+
* @param env {[key: string]: string} Environment variables
|
|
62
|
+
* @returns {string | undefined} The value of the SPIN_WORKSPACE environment variable.
|
|
63
|
+
*/
|
|
64
|
+
export function workspace(env = process.env) {
|
|
65
|
+
return env[constants.environmentVariables.spinWorkspace];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Returns the value of the SPIN_NAMESPACE environment variable.
|
|
69
|
+
* @param env {[key: string]: string} Environment variables
|
|
70
|
+
* @returns {string | undefined} The value of the SPIN_NAMESPACE environment variable.
|
|
71
|
+
*/
|
|
72
|
+
export function namespace(env = process.env) {
|
|
73
|
+
return env[constants.environmentVariables.spinNamespace];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Returns the value of the SPIN_HOST environment variable.
|
|
77
|
+
* @param env {[key: string]: string} Environment variables
|
|
78
|
+
* @returns {string | undefined} The value of the SPIN_HOST environment variable.
|
|
79
|
+
*/
|
|
80
|
+
export function host(env = process.env) {
|
|
81
|
+
return env[constants.environmentVariables.spinHost];
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=spin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spin.js","sourceRoot":"","sources":["../../src/environment/spin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AACvC,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,cAAc,CAAA;AAE3C,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC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CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACtC,OAAO,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAA;AAC3D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACxC,OAAO,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAA;AACzD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACzC,OAAO,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAA;AAC1D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACzC,OAAO,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAA;AAC1D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACpC,OAAO,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAA;AACrD,CAAC","sourcesContent":["import {isTruthy} from './utilities.js'\nimport constants from '../constants.js'\nimport {captureOutput} from '../system.js'\nimport {Abort} from '../error.js'\nimport {content, token} from '../output.js'\n\nexport const SpinInstanceNotFound = (spinInstance: string | undefined, error: string) => {\n const errorMessage = content`${token.genericShellCommand(\n `spin`,\n )} yielded the following error trying to obtain the fully qualified domain name of the Spin instance:\n${error}\n `\n let nextSteps: string | undefined\n if (spinInstance) {\n nextSteps = `Make sure ${spinInstance} is the instance name and not a fully qualified domain name`\n }\n return new Abort(errorMessage, nextSteps)\n}\n\n/**\n * When ran in a Spin environment, it returns the fqdn of the instance.\n * @returns {string} fqdn of the Spin environment.\n */\nexport async function fqdn(env = process.env): Promise<string> {\n const spinInstance = await instance(env)\n const showResponse = await show(spinInstance, env)\n return showResponse.fqdn\n}\n\n/**\n * Runs \"spin show\" and returns the JSON-parsed output.\n * @param {latest} Whether to pass --latest when running the command.\n * @returns The JSON-parsed output of the Spin CLI.\n * @throws Any error raised from the underlying Spin CLI.\n */\nexport async function show(spinInstance: string | undefined, env = process.env): Promise<{fqdn: string}> {\n const latest = spinInstance === undefined\n const args = latest ? ['show', '--latest', '--json'] : ['show', '--json']\n const output = await captureOutput('spin', args, {env})\n const json = JSON.parse(output)\n if (json.error) {\n throw SpinInstanceNotFound(spinInstance, json.error)\n } else {\n return json\n }\n}\n\n/**\n * Returns true if the CLI is running in a Spin environment.\n * @param env {[key: string]: string} Environment variables\n * @returns {boolean} True if the CLI is running in a Spin environment.\n */\nexport function isSpin(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.spin])\n}\n\n/**\n * Returns the value of the SPIN_INSTANCE environment variable.\n * @param env {[key: string]: string} Environment variables\n * @returns {string | undefined} The value of the SPIN_INSTANCE environment variable.\n */\nexport function instance(env = process.env): string | undefined {\n return env[constants.environmentVariables.spinInstance]\n}\n\n/**\n * Returns the value of the SPIN_WORKSPACE environment variable.\n * @param env {[key: string]: string} Environment variables\n * @returns {string | undefined} The value of the SPIN_WORKSPACE environment variable.\n */\nexport function workspace(env = process.env): string | undefined {\n return env[constants.environmentVariables.spinWorkspace]\n}\n\n/**\n * Returns the value of the SPIN_NAMESPACE environment variable.\n * @param env {[key: string]: string} Environment variables\n * @returns {string | undefined} The value of the SPIN_NAMESPACE environment variable.\n */\nexport function namespace(env = process.env): string | undefined {\n return env[constants.environmentVariables.spinNamespace]\n}\n\n/**\n * Returns the value of the SPIN_HOST environment variable.\n * @param env {[key: string]: string} Environment variables\n * @returns {string | undefined} The value of the SPIN_HOST environment variable.\n */\nexport function host(env = process.env): string | undefined {\n return env[constants.environmentVariables.spinHost]\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns whether an environment variable value represents a truthy value.
|
|
3
|
+
* @param variable {string | undefined} Given a environment variable value, it returns true if it represents a truthy value.
|
|
4
|
+
* @returns {boolean}
|
|
5
|
+
*/
|
|
6
|
+
export declare function isTruthy(variable: string | undefined): boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns whether an environment variable value represents a truthy value.
|
|
3
|
+
* @param variable {string | undefined} Given a environment variable value, it returns true if it represents a truthy value.
|
|
4
|
+
* @returns {boolean}
|
|
5
|
+
*/
|
|
6
|
+
export function isTruthy(variable) {
|
|
7
|
+
if (!variable) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
return ['1', 'true', 'TRUE', 'yes', 'YES'].includes(variable);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=utilities.js.map
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as local from './environment/local.js';
|
|
2
|
+
import * as service from './environment/service.js';
|
|
3
|
+
import * as fqdn from './environment/fqdn.js';
|
|
4
|
+
import * as utilities from './environment/utilities.js';
|
|
5
|
+
export { local, service, fqdn, utilities };
|
|
6
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,wBAAwB,CAAA;AAC/C,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAA;AACnD,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAA;AAC7C,OAAO,KAAK,SAAS,MAAM,4BAA4B,CAAA;AAEvD,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAC,CAAA","sourcesContent":["import * as local from './environment/local.js'\nimport * as service from './environment/service.js'\nimport * as fqdn from './environment/fqdn.js'\nimport * as utilities from './environment/utilities.js'\n\nexport {local, service, fqdn, utilities}\n"]}
|
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Message } from './output.js';
|
|
2
|
+
export { ExtendableError } from 'ts-error';
|
|
3
|
+
export { AbortSignal } from 'abort-controller';
|
|
4
|
+
declare enum FatalErrorType {
|
|
5
|
+
Abort = 0,
|
|
6
|
+
AbortSilent = 1,
|
|
7
|
+
Bug = 2
|
|
8
|
+
}
|
|
9
|
+
export declare class CancelExecution extends Error {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A fatal error represents an error shouldn't be rescued and that causes the execution to terminate.
|
|
13
|
+
* There shouldn't be code that catches fatal errors.
|
|
14
|
+
*/
|
|
15
|
+
export declare abstract class Fatal extends Error {
|
|
16
|
+
tryMessage: string | null;
|
|
17
|
+
type: FatalErrorType;
|
|
18
|
+
constructor(message: Message, type: FatalErrorType, tryMessage?: Message | null);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* An abort error is a fatal error that shouldn't be reported as a bug.
|
|
22
|
+
* Those usually represent unexpected scenarios that we can't handle and that usually require some action from the developer
|
|
23
|
+
*/
|
|
24
|
+
export declare class Abort extends Fatal {
|
|
25
|
+
constructor(message: Message, tryMessage?: Message | null);
|
|
26
|
+
}
|
|
27
|
+
export declare class AbortSilent extends Fatal {
|
|
28
|
+
constructor();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A bug error is an error that represents a bug and therefore should be reported.
|
|
32
|
+
*/
|
|
33
|
+
export declare class Bug extends Fatal {
|
|
34
|
+
constructor(message: Message, tryMessage?: string | null);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A function that handles errors that blow up in the CLI.
|
|
38
|
+
* @param error Error to be handled.
|
|
39
|
+
* @returns A promise that resolves with the error passed.
|
|
40
|
+
*/
|
|
41
|
+
export declare function handler(error: Error): Promise<Error>;
|
|
42
|
+
export declare function mapper(error: Error): Promise<Error>;
|
|
43
|
+
export declare function isFatal(error: Error): boolean;
|
|
44
|
+
export declare function shouldReport(error: Error): boolean;
|
package/dist/error.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { stringifyMessage, error as outputError } from './output.js';
|
|
2
|
+
import { Errors } from '@oclif/core';
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
import sourceMapSupport from 'source-map-support';
|
|
6
|
+
export { ExtendableError } from 'ts-error';
|
|
7
|
+
export { AbortSignal } from 'abort-controller';
|
|
8
|
+
sourceMapSupport.install();
|
|
9
|
+
var FatalErrorType;
|
|
10
|
+
(function (FatalErrorType) {
|
|
11
|
+
FatalErrorType[FatalErrorType["Abort"] = 0] = "Abort";
|
|
12
|
+
FatalErrorType[FatalErrorType["AbortSilent"] = 1] = "AbortSilent";
|
|
13
|
+
FatalErrorType[FatalErrorType["Bug"] = 2] = "Bug";
|
|
14
|
+
})(FatalErrorType || (FatalErrorType = {}));
|
|
15
|
+
export class CancelExecution extends Error {
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A fatal error represents an error shouldn't be rescued and that causes the execution to terminate.
|
|
19
|
+
* There shouldn't be code that catches fatal errors.
|
|
20
|
+
*/
|
|
21
|
+
export class Fatal extends Error {
|
|
22
|
+
constructor(message, type, tryMessage = null) {
|
|
23
|
+
super(stringifyMessage(message));
|
|
24
|
+
this.tryMessage = tryMessage ? stringifyMessage(tryMessage) : null;
|
|
25
|
+
this.type = type;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* An abort error is a fatal error that shouldn't be reported as a bug.
|
|
30
|
+
* Those usually represent unexpected scenarios that we can't handle and that usually require some action from the developer
|
|
31
|
+
*/
|
|
32
|
+
export class Abort extends Fatal {
|
|
33
|
+
constructor(message, tryMessage = null) {
|
|
34
|
+
super(message, FatalErrorType.Abort, tryMessage);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export class AbortSilent extends Fatal {
|
|
38
|
+
constructor() {
|
|
39
|
+
super('', FatalErrorType.AbortSilent);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A bug error is an error that represents a bug and therefore should be reported.
|
|
44
|
+
*/
|
|
45
|
+
export class Bug extends Fatal {
|
|
46
|
+
constructor(message, tryMessage = null) {
|
|
47
|
+
super(message, FatalErrorType.Bug, tryMessage);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A function that handles errors that blow up in the CLI.
|
|
52
|
+
* @param error Error to be handled.
|
|
53
|
+
* @returns A promise that resolves with the error passed.
|
|
54
|
+
*/
|
|
55
|
+
export async function handler(error) {
|
|
56
|
+
let fatal;
|
|
57
|
+
if (isFatal(error)) {
|
|
58
|
+
fatal = error;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
fatal = new Bug(error.message);
|
|
62
|
+
}
|
|
63
|
+
if (fatal.type === FatalErrorType.Bug) {
|
|
64
|
+
fatal.stack = error.stack;
|
|
65
|
+
}
|
|
66
|
+
await outputError(fatal);
|
|
67
|
+
return Promise.resolve(error);
|
|
68
|
+
}
|
|
69
|
+
export function mapper(error) {
|
|
70
|
+
if (error instanceof Errors.CLIError) {
|
|
71
|
+
const mappedError = new Abort(error.message);
|
|
72
|
+
mappedError.stack = error.stack;
|
|
73
|
+
return Promise.resolve(mappedError);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
return Promise.resolve(error);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export function isFatal(error) {
|
|
80
|
+
return Object.prototype.hasOwnProperty.call(error, 'type');
|
|
81
|
+
}
|
|
82
|
+
export function shouldReport(error) {
|
|
83
|
+
if (!isFatal(error)) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
if (error.type === FatalErrorType.Bug) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,gBAAgB,EAAE,KAAK,IAAI,WAAW,EAAC,MAAM,aAAa,CAAA;AAC3E,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAElC,6DAA6D;AAC7D,aAAa;AACb,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAC,eAAe,EAAC,MAAM,UAAU,CAAA;AACxC,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAA;AAE5C,gBAAgB,CAAC,OAAO,EAAE,CAAA;AAE1B,IAAK,cAIJ;AAJD,WAAK,cAAc;IACjB,qDAAK,CAAA;IACL,iEAAW,CAAA;IACX,iDAAG,CAAA;AACL,CAAC,EAJI,cAAc,KAAd,cAAc,QAIlB;AAED,MAAM,OAAO,eAAgB,SAAQ,KAAK;CAAG;AAE7C;;;GAGG;AACH,MAAM,OAAgB,KAAM,SAAQ,KAAK;IAGvC,YAAY,OAAgB,EAAE,IAAoB,EAAE,aAA6B,IAAI;QACnF,K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AC,QAAQ,EAAE;QACpC,MAAM,WAAW,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAC5C,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;QAC/B,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;KACpC;SAAM;QACL,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;KAC9B;AACH,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,KAAY;IAClC,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;AAC5D,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAY;IACvC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACnB,OAAO,IAAI,CAAA;KACZ;IACD,IAAK,KAAe,CAAC,IAAI,KAAK,cAAc,CAAC,GAAG,EAAE;QAChD,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import {Message, stringifyMessage, error as outputError} from './output.js'\nimport {Errors} from '@oclif/core'\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport sourceMapSupport from 'source-map-support'\n\nexport {ExtendableError} from 'ts-error'\nexport {AbortSignal} from 'abort-controller'\n\nsourceMapSupport.install()\n\nenum FatalErrorType {\n Abort,\n AbortSilent,\n Bug,\n}\n\nexport class CancelExecution extends Error {}\n\n/**\n * A fatal error represents an error shouldn't be rescued and that causes the execution to terminate.\n * There shouldn't be code that catches fatal errors.\n */\nexport abstract class Fatal extends Error {\n tryMessage: string | null\n type: FatalErrorType\n constructor(message: Message, type: FatalErrorType, tryMessage: Message | null = null) {\n super(stringifyMessage(message))\n this.tryMessage = tryMessage ? stringifyMessage(tryMessage) : null\n this.type = type\n }\n}\n\n/**\n * An abort error is a fatal error that shouldn't be reported as a bug.\n * Those usually represent unexpected scenarios that we can't handle and that usually require some action from the developer\n */\nexport class Abort extends Fatal {\n constructor(message: Message, tryMessage: Message | null = null) {\n super(message, FatalErrorType.Abort, tryMessage)\n }\n}\n\nexport class AbortSilent extends Fatal {\n constructor() {\n super('', FatalErrorType.AbortSilent)\n }\n}\n\n/**\n * A bug error is an error that represents a bug and therefore should be reported.\n */\nexport class Bug extends Fatal {\n constructor(message: Message, tryMessage: string | null = null) {\n super(message, FatalErrorType.Bug, tryMessage)\n }\n}\n\n/**\n * A function that handles errors that blow up in the CLI.\n * @param error Error to be handled.\n * @returns A promise that resolves with the error passed.\n */\nexport async function handler(error: Error): Promise<Error> {\n let fatal: Fatal\n if (isFatal(error)) {\n fatal = error as Fatal\n } else {\n fatal = new Bug(error.message)\n }\n\n if (fatal.type === FatalErrorType.Bug) {\n fatal.stack = error.stack\n }\n\n await outputError(fatal)\n return Promise.resolve(error)\n}\n\nexport function mapper(error: Error): Promise<Error> {\n if (error instanceof Errors.CLIError) {\n const mappedError = new Abort(error.message)\n mappedError.stack = error.stack\n return Promise.resolve(mappedError)\n } else {\n return Promise.resolve(error)\n }\n}\n\nexport function isFatal(error: Error): boolean {\n return Object.prototype.hasOwnProperty.call(error, 'type')\n}\n\nexport function shouldReport(error: Error): boolean {\n if (!isFatal(error)) {\n return true\n }\n if ((error as Fatal).type === FatalErrorType.Bug) {\n return true\n }\n return false\n}\n"]}
|
package/dist/file.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export declare function stripUp(path: string, strip: number): string;
|
|
2
|
+
/**
|
|
3
|
+
* Creates a temporary directory and ties its lifecycle ot the lifecycle of the callback.
|
|
4
|
+
* @param callback - The callback that receives the temporary directory.
|
|
5
|
+
*/
|
|
6
|
+
export declare function inTemporaryDirectory<T>(callback: (tmpDir: string) => T | Promise<T>): Promise<T>;
|
|
7
|
+
/**
|
|
8
|
+
* It reads a file and returns its content as a string using the
|
|
9
|
+
* utf-8 encoding
|
|
10
|
+
* @param path {string} Path to the file to read.
|
|
11
|
+
* @returns {Promise<string>} A promise that resolves with the content of the file.
|
|
12
|
+
*/
|
|
13
|
+
export declare function read(path: string, options?: object): Promise<string>;
|
|
14
|
+
export declare function readSync(path: string, options?: object): string;
|
|
15
|
+
/**
|
|
16
|
+
* Copies a file
|
|
17
|
+
* @param from {string} Path to the directory or file to be copied.
|
|
18
|
+
* @param to {string} Destination path.
|
|
19
|
+
*/
|
|
20
|
+
export declare function copy(from: string, to: string): Promise<void>;
|
|
21
|
+
export declare function touch(path: string): Promise<void>;
|
|
22
|
+
export declare function touchSync(path: string): Promise<void>;
|
|
23
|
+
export declare function write(path: string, data: string): Promise<void>;
|
|
24
|
+
export declare function writeSync(path: string, data: string): void;
|
|
25
|
+
export declare function append(path: string, data: string): Promise<void>;
|
|
26
|
+
export declare function mkdir(path: string): Promise<void>;
|
|
27
|
+
export declare function mkdirSync(path: string): void;
|
|
28
|
+
export declare function remove(path: string): Promise<void>;
|
|
29
|
+
export declare function rmdir(path: string, { force }?: {
|
|
30
|
+
force?: boolean;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
export declare function mkTmpDir(): Promise<string>;
|
|
33
|
+
export declare function isDirectory(path: string): Promise<boolean>;
|
|
34
|
+
export declare function size(path: string): Promise<number>;
|
|
35
|
+
export declare function sizeSync(path: string): number;
|
|
36
|
+
/**
|
|
37
|
+
* Moves a file.
|
|
38
|
+
* @param src {string} File to be moved.
|
|
39
|
+
* @param dest {string} Path to be moved to.
|
|
40
|
+
* @param options {object} Moving options.
|
|
41
|
+
*/
|
|
42
|
+
export declare function move(src: string, dest: string, options?: {
|
|
43
|
+
overwrite?: boolean;
|
|
44
|
+
}): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Changes the permissions of a directory or file.
|
|
47
|
+
* @param path {string} Path to the file or directory whose permissions will be modified.
|
|
48
|
+
* @param mode {string | numbers} Permissions to set to the file or directory.
|
|
49
|
+
*/
|
|
50
|
+
export declare function chmod(path: string, mode: number | string): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Checks if a file has executable permissions.
|
|
53
|
+
* @param path {string} Path to the file whose permissions will be checked.
|
|
54
|
+
*/
|
|
55
|
+
export declare function hasExecutablePermissions(path: string): Promise<boolean>;
|
|
56
|
+
/**
|
|
57
|
+
* Returns true if a file or directory exists
|
|
58
|
+
* @param path {string} Path to the directory or file.
|
|
59
|
+
* @returns {boolean} True if it exists.
|
|
60
|
+
*/
|
|
61
|
+
export declare function exists(path: string): Promise<boolean>;
|
|
62
|
+
/**
|
|
63
|
+
* Format a string using prettier. Return the formatted content.
|
|
64
|
+
*/
|
|
65
|
+
export declare function format(content: string, options: {
|
|
66
|
+
path: string;
|
|
67
|
+
}): Promise<string>;
|