@shopify/cli-kit 3.32.1 → 3.34.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 +2 -6
- package/dist/constants.js +0 -4
- package/dist/constants.js.map +1 -1
- package/dist/file.d.ts +1 -1
- package/dist/git.js +1 -1
- package/dist/git.js.map +1 -1
- package/dist/http.js +2 -2
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -5
- package/dist/index.js.map +1 -1
- package/dist/metadata.js +1 -1
- package/dist/metadata.js.map +1 -1
- package/dist/output.js +1 -1
- package/dist/output.js.map +1 -1
- package/dist/path.d.ts +1 -1
- package/dist/path.js +5 -3
- package/dist/path.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 +6 -9
- package/dist/private/node/analytics.js.map +1 -1
- package/dist/private/node/api/graphql.js +1 -0
- package/dist/private/node/api/graphql.js.map +1 -1
- package/dist/private/node/api/headers.js +1 -1
- package/dist/private/node/api/headers.js.map +1 -1
- 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/environment/service.d.ts +18 -0
- package/dist/private/node/environment/service.js +32 -0
- package/dist/private/node/environment/service.js.map +1 -0
- package/dist/{environment → private/node/environment}/spin-cache.d.ts +0 -0
- package/dist/{environment → private/node/environment}/spin-cache.js +0 -0
- package/dist/private/node/environment/spin-cache.js.map +1 -0
- package/dist/{environment → private/node/environment}/utilities.d.ts +0 -0
- package/dist/{environment → private/node/environment}/utilities.js +0 -0
- package/dist/private/node/environment/utilities.js.map +1 -0
- package/dist/{session → private/node/session}/authorize.d.ts +1 -5
- package/dist/{session → private/node/session}/authorize.js +9 -9
- package/dist/private/node/session/authorize.js.map +1 -0
- package/dist/{session → private/node/session}/device-authorization.d.ts +0 -0
- package/dist/{session → private/node/session}/device-authorization.js +7 -9
- package/dist/private/node/session/device-authorization.js.map +1 -0
- package/dist/{session → private/node/session}/exchange.d.ts +2 -2
- package/dist/{session → private/node/session}/exchange.js +5 -5
- package/dist/private/node/session/exchange.js.map +1 -0
- package/dist/{session → private/node/session}/identity-token-validation.d.ts +0 -0
- package/dist/{session → private/node/session}/identity-token-validation.js +4 -4
- package/dist/private/node/session/identity-token-validation.js.map +1 -0
- package/dist/{session → private/node/session}/identity.d.ts +1 -1
- package/dist/{session → private/node/session}/identity.js +2 -3
- package/dist/private/node/session/identity.js.map +1 -0
- package/dist/{session → private/node/session}/post-auth.d.ts +1 -1
- package/dist/{session → private/node/session}/post-auth.js +3 -3
- package/dist/private/node/session/post-auth.js.map +1 -0
- package/dist/{session → private/node/session}/redirect-listener.d.ts +0 -0
- package/dist/{session → private/node/session}/redirect-listener.js +2 -2
- package/dist/private/node/session/redirect-listener.js.map +1 -0
- package/dist/{session → private/node/session}/schema.d.ts +1 -1
- package/dist/{session → private/node/session}/schema.js +1 -1
- package/dist/private/node/session/schema.js.map +1 -0
- package/dist/{session → private/node/session}/scopes.d.ts +1 -1
- package/dist/{session → private/node/session}/scopes.js +2 -2
- package/dist/private/node/session/scopes.js.map +1 -0
- package/dist/{session → private/node/session}/store.d.ts +0 -0
- package/dist/{session → private/node/session}/store.js +5 -5
- package/dist/private/node/session/store.js.map +1 -0
- package/dist/{session → private/node/session}/validate.d.ts +0 -0
- package/dist/{session → private/node/session}/validate.js +5 -5
- package/dist/private/node/session/validate.js.map +1 -0
- package/dist/private/node/session.d.ts +56 -0
- package/dist/{session.js → private/node/session.js} +97 -133
- package/dist/private/node/session.js.map +1 -0
- 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/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/private/node/ui.js +1 -1
- package/dist/private/node/ui.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/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/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/analytics.js +3 -3
- package/dist/public/node/analytics.js.map +1 -1
- package/dist/public/node/api/admin.d.ts +31 -1
- package/dist/public/node/api/admin.js +28 -0
- package/dist/public/node/api/admin.js.map +1 -1
- package/dist/public/node/api/partners.js +7 -2
- package/dist/public/node/api/partners.js.map +1 -1
- package/dist/public/node/base-command.js +2 -2
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/cli.d.ts +8 -0
- package/dist/public/node/cli.js +21 -4
- package/dist/public/node/cli.js.map +1 -1
- package/dist/public/node/environment/fqdn.d.ts +26 -0
- package/dist/{environment → public/node/environment}/fqdn.js +15 -31
- package/dist/public/node/environment/fqdn.js.map +1 -0
- package/dist/{environment → public/node/environment}/local.d.ts +62 -16
- package/dist/{environment → public/node/environment}/local.js +66 -24
- package/dist/public/node/environment/local.js.map +1 -0
- package/dist/public/node/environment/spin.d.ts +43 -0
- package/dist/{environment → public/node/environment}/spin.js +28 -35
- package/dist/public/node/environment/spin.js.map +1 -0
- package/dist/public/node/node-package-manager.js +1 -1
- package/dist/public/node/node-package-manager.js.map +1 -1
- package/dist/public/node/ruby.d.ts +1 -1
- package/dist/public/node/ruby.js +12 -13
- package/dist/public/node/ruby.js.map +1 -1
- package/dist/public/node/session.d.ts +53 -0
- package/dist/public/node/session.js +95 -0
- package/dist/public/node/session.js.map +1 -0
- package/dist/public/node/system.d.ts +44 -0
- package/dist/{system.js → public/node/system.js} +34 -54
- package/dist/public/node/system.js.map +1 -0
- package/dist/public/node/tcp.js +1 -1
- package/dist/public/node/tcp.js.map +1 -1
- package/dist/public/node/ui.d.ts +1 -1
- package/dist/public/node/ui.js.map +1 -1
- package/dist/testing/ui.js +1 -1
- package/dist/testing/ui.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui.js +1 -1
- package/dist/ui.js.map +1 -1
- package/package.json +9 -7
- 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.d.ts +0 -3
- package/dist/api.js +0 -4
- package/dist/api.js.map +0 -1
- package/dist/cli.d.ts +0 -8
- package/dist/cli.js +0 -18
- package/dist/cli.js.map +0 -1
- package/dist/environment/fqdn.d.ts +0 -29
- package/dist/environment/fqdn.js.map +0 -1
- package/dist/environment/local.js.map +0 -1
- package/dist/environment/service.d.ts +0 -4
- package/dist/environment/service.js +0 -19
- package/dist/environment/service.js.map +0 -1
- package/dist/environment/spin-cache.js.map +0 -1
- package/dist/environment/spin.d.ts +0 -50
- package/dist/environment/spin.js.map +0 -1
- package/dist/environment/utilities.js.map +0 -1
- package/dist/environment.d.ts +0 -7
- package/dist/environment.js +0 -8
- package/dist/environment.js.map +0 -1
- package/dist/network/service.d.ts +0 -14
- package/dist/network/service.js +0 -11
- package/dist/network/service.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/session/authorize.js.map +0 -1
- package/dist/session/device-authorization.js.map +0 -1
- package/dist/session/exchange.js.map +0 -1
- package/dist/session/identity-token-validation.js.map +0 -1
- package/dist/session/identity.js.map +0 -1
- package/dist/session/post-auth.js.map +0 -1
- package/dist/session/redirect-listener.js.map +0 -1
- package/dist/session/schema.js.map +0 -1
- package/dist/session/scopes.js.map +0 -1
- package/dist/session/store.js.map +0 -1
- package/dist/session/token.d.ts +0 -40
- package/dist/session/token.js +0 -22
- package/dist/session/token.js.map +0 -1
- package/dist/session/validate.js.map +0 -1
- package/dist/session.d.ts +0 -96
- package/dist/session.js.map +0 -1
- package/dist/system.d.ts +0 -51
- package/dist/system.js.map +0 -1
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/**
|
|
3
3
|
* It returns true if the terminal is interactive.
|
|
4
|
+
*
|
|
4
5
|
* @returns True if the terminal is interactive.
|
|
5
6
|
*/
|
|
6
7
|
export declare function isTerminalInteractive(): boolean;
|
|
7
8
|
/**
|
|
8
9
|
* Returns the path to the user's home directory.
|
|
10
|
+
*
|
|
9
11
|
* @returns The path to the user's home directory.
|
|
10
12
|
*/
|
|
11
13
|
export declare function homeDirectory(): string;
|
|
12
14
|
/**
|
|
13
15
|
* Returns true if the CLI is running in debug mode.
|
|
16
|
+
*
|
|
14
17
|
* @param env - The environment variables from the environment of the current process.
|
|
15
|
-
* @returns
|
|
18
|
+
* @returns True if SHOPIFY_ENV is development.
|
|
16
19
|
*/
|
|
17
20
|
export declare function isDevelopment(env?: NodeJS.ProcessEnv): boolean;
|
|
18
21
|
/**
|
|
19
22
|
* Returns true if the CLI is running in verbose mode.
|
|
23
|
+
*
|
|
20
24
|
* @param env - The environment variables from the environment of the current process.
|
|
21
|
-
* @returns
|
|
25
|
+
* @returns True if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed.
|
|
22
26
|
*/
|
|
23
27
|
export declare function isVerbose(env?: NodeJS.ProcessEnv): boolean;
|
|
24
28
|
/**
|
|
25
29
|
* Returns true if the environment in which the CLI is running is either
|
|
26
30
|
* a local environment (where dev is present) or a cloud environment (spin).
|
|
31
|
+
*
|
|
32
|
+
* @param env - The environment variables from the environment of the current process.
|
|
27
33
|
* @returns True if the CLI is used in a Shopify environment.
|
|
28
34
|
*/
|
|
29
35
|
export declare function isShopify(env?: NodeJS.ProcessEnv): Promise<boolean>;
|
|
@@ -31,39 +37,75 @@ export declare function isShopify(env?: NodeJS.ProcessEnv): Promise<boolean>;
|
|
|
31
37
|
* This variable is used when running unit tests to indicate that the CLI's business logic
|
|
32
38
|
* is run as a subject of a unit test. We can use this variable to disable output through
|
|
33
39
|
* the standard streams.
|
|
40
|
+
*
|
|
34
41
|
* @param env - The environment variables from the environment of the current process.
|
|
35
42
|
* @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.
|
|
36
43
|
*/
|
|
37
44
|
export declare function isUnitTest(env?: NodeJS.ProcessEnv): boolean;
|
|
38
45
|
/**
|
|
39
46
|
* Returns true if reporting analytics is enabled.
|
|
47
|
+
*
|
|
40
48
|
* @param env - The environment variables from the environment of the current process.
|
|
41
|
-
* @returns
|
|
49
|
+
* @returns True unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.
|
|
42
50
|
*/
|
|
43
51
|
export declare function analyticsDisabled(env?: NodeJS.ProcessEnv): boolean;
|
|
44
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* Returns true if reporting analytics should always happen, regardless of DEBUG mode etc.
|
|
54
|
+
*
|
|
55
|
+
* @param env - The environment variables from the environment of the current process.
|
|
56
|
+
* @returns True if SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS is truthy.
|
|
57
|
+
*/
|
|
45
58
|
export declare function alwaysLogAnalytics(env?: NodeJS.ProcessEnv): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Returns true if the CLI User is 1P.
|
|
61
|
+
*
|
|
62
|
+
* @param env - The environment variables from the environment of the current process.
|
|
63
|
+
* @returns True if SHOPIFY_CLI_1P is truthy.
|
|
64
|
+
*/
|
|
46
65
|
export declare function firstPartyDev(env?: NodeJS.ProcessEnv): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Returns true if the CLI should use device auth.
|
|
68
|
+
*
|
|
69
|
+
* @param env - The environment variables from the environment of the current process.
|
|
70
|
+
* @returns True if SHOPIFY_CLI_DEVICE_AUTH is truthy or the CLI is run from a cloud environment.
|
|
71
|
+
*/
|
|
47
72
|
export declare function useDeviceAuth(env?: NodeJS.ProcessEnv): boolean;
|
|
48
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Returns true if the CLI should use theme bundling.
|
|
75
|
+
*
|
|
76
|
+
* @param env - The environment variables from the environment of the current process.
|
|
77
|
+
* @returns True if SHOPIFY_CLI_THEME_BUNDLING is truthy.
|
|
78
|
+
*/
|
|
49
79
|
export declare function useThemeBundling(env?: NodeJS.ProcessEnv): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Return gitpodURL if we are running in gitpod.
|
|
82
|
+
* Https://www.gitpod.io/docs/environment-variables#default-environment-variables.
|
|
83
|
+
*
|
|
84
|
+
* @param env - The environment variables from the environment of the current process.
|
|
85
|
+
* @returns The gitpod URL.
|
|
86
|
+
*/
|
|
50
87
|
export declare function gitpodURL(env?: NodeJS.ProcessEnv): string | undefined;
|
|
51
|
-
export declare function codespaceURL(env?: NodeJS.ProcessEnv): string | undefined;
|
|
52
88
|
/**
|
|
53
|
-
*
|
|
89
|
+
* Return codespaceURL if we are running in codespaces.
|
|
90
|
+
* Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.
|
|
54
91
|
*
|
|
55
|
-
* @param env -
|
|
92
|
+
* @param env - The environment variables from the environment of the current process.
|
|
93
|
+
* @returns The codespace URL.
|
|
94
|
+
*/
|
|
95
|
+
export declare function codespaceURL(env?: NodeJS.ProcessEnv): string | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Checks if the CLI is run from a cloud environment.
|
|
56
98
|
*
|
|
57
|
-
* @
|
|
99
|
+
* @param env - Environment variables used when the cli is launched.
|
|
100
|
+
* @returns True in case the CLI is run from a cloud environment.
|
|
58
101
|
*/
|
|
59
102
|
export declare function isCloudEnvironment(env?: NodeJS.ProcessEnv): boolean;
|
|
60
103
|
/**
|
|
61
104
|
* Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of
|
|
62
|
-
* them. Platform name 'localhost' is returned otherwise
|
|
105
|
+
* them. Platform name 'localhost' is returned otherwise.
|
|
63
106
|
*
|
|
64
|
-
* @param env - Environment variables used when the cli is launched
|
|
65
|
-
*
|
|
66
|
-
* @returns Cloud platform information
|
|
107
|
+
* @param env - Environment variables used when the cli is launched.
|
|
108
|
+
* @returns Cloud platform information.
|
|
67
109
|
*/
|
|
68
110
|
export declare function cloudEnvironment(env?: NodeJS.ProcessEnv): {
|
|
69
111
|
platform: 'spin' | 'codespaces' | 'gitpod' | 'localhost';
|
|
@@ -71,11 +113,15 @@ export declare function cloudEnvironment(env?: NodeJS.ProcessEnv): {
|
|
|
71
113
|
};
|
|
72
114
|
/**
|
|
73
115
|
* Returns whether the environment has Git available.
|
|
116
|
+
*
|
|
74
117
|
* @returns A promise that resolves with the value.
|
|
75
118
|
*/
|
|
76
119
|
export declare function hasGit(): Promise<boolean>;
|
|
77
120
|
/**
|
|
78
|
-
* Gets info on the CI platform the CLI is running on, if applicable
|
|
121
|
+
* Gets info on the CI platform the CLI is running on, if applicable.
|
|
122
|
+
*
|
|
123
|
+
* @param env - The environment variables from the environment of the current process.
|
|
124
|
+
* @returns The CI platform info.
|
|
79
125
|
*/
|
|
80
126
|
export declare function ciPlatform(env?: NodeJS.ProcessEnv): {
|
|
81
127
|
isCI: true;
|
|
@@ -85,8 +131,8 @@ export declare function ciPlatform(env?: NodeJS.ProcessEnv): {
|
|
|
85
131
|
name?: undefined;
|
|
86
132
|
};
|
|
87
133
|
/**
|
|
88
|
-
* Returns the first mac address found
|
|
134
|
+
* Returns the first mac address found.
|
|
89
135
|
*
|
|
90
|
-
* @returns Mac address
|
|
136
|
+
* @returns Mac address.
|
|
91
137
|
*/
|
|
92
138
|
export declare function macAddress(): Promise<string>;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { isTruthy, isSet } from '
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { exists as fileExists } from '../file.js';
|
|
1
|
+
import { isTruthy, isSet } from '../../../private/node/environment/utilities.js';
|
|
2
|
+
import constants from '../../../constants.js';
|
|
3
|
+
import { exists as fileExists } from '../../../file.js';
|
|
5
4
|
import { exec } from '../system.js';
|
|
5
|
+
import { isSpin } from '../environment/spin.js';
|
|
6
6
|
import isInteractive from 'is-interactive';
|
|
7
7
|
import macaddress from 'macaddress';
|
|
8
8
|
import { homedir } from 'os';
|
|
9
9
|
/**
|
|
10
10
|
* It returns true if the terminal is interactive.
|
|
11
|
+
*
|
|
11
12
|
* @returns True if the terminal is interactive.
|
|
12
13
|
*/
|
|
13
14
|
export function isTerminalInteractive() {
|
|
@@ -15,6 +16,7 @@ export function isTerminalInteractive() {
|
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
18
|
* Returns the path to the user's home directory.
|
|
19
|
+
*
|
|
18
20
|
* @returns The path to the user's home directory.
|
|
19
21
|
*/
|
|
20
22
|
export function homeDirectory() {
|
|
@@ -22,16 +24,18 @@ export function homeDirectory() {
|
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
26
|
* Returns true if the CLI is running in debug mode.
|
|
27
|
+
*
|
|
25
28
|
* @param env - The environment variables from the environment of the current process.
|
|
26
|
-
* @returns
|
|
29
|
+
* @returns True if SHOPIFY_ENV is development.
|
|
27
30
|
*/
|
|
28
31
|
export function isDevelopment(env = process.env) {
|
|
29
32
|
return env[constants.environmentVariables.env] === 'development';
|
|
30
33
|
}
|
|
31
34
|
/**
|
|
32
35
|
* Returns true if the CLI is running in verbose mode.
|
|
36
|
+
*
|
|
33
37
|
* @param env - The environment variables from the environment of the current process.
|
|
34
|
-
* @returns
|
|
38
|
+
* @returns True if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed.
|
|
35
39
|
*/
|
|
36
40
|
export function isVerbose(env = process.env) {
|
|
37
41
|
return isTruthy(env[constants.environmentVariables.verbose]) || process.argv.includes('--verbose');
|
|
@@ -39,6 +43,8 @@ export function isVerbose(env = process.env) {
|
|
|
39
43
|
/**
|
|
40
44
|
* Returns true if the environment in which the CLI is running is either
|
|
41
45
|
* a local environment (where dev is present) or a cloud environment (spin).
|
|
46
|
+
*
|
|
47
|
+
* @param env - The environment variables from the environment of the current process.
|
|
42
48
|
* @returns True if the CLI is used in a Shopify environment.
|
|
43
49
|
*/
|
|
44
50
|
export async function isShopify(env = process.env) {
|
|
@@ -52,6 +58,7 @@ export async function isShopify(env = process.env) {
|
|
|
52
58
|
* This variable is used when running unit tests to indicate that the CLI's business logic
|
|
53
59
|
* is run as a subject of a unit test. We can use this variable to disable output through
|
|
54
60
|
* the standard streams.
|
|
61
|
+
*
|
|
55
62
|
* @param env - The environment variables from the environment of the current process.
|
|
56
63
|
* @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.
|
|
57
64
|
*/
|
|
@@ -60,53 +67,84 @@ export function isUnitTest(env = process.env) {
|
|
|
60
67
|
}
|
|
61
68
|
/**
|
|
62
69
|
* Returns true if reporting analytics is enabled.
|
|
70
|
+
*
|
|
63
71
|
* @param env - The environment variables from the environment of the current process.
|
|
64
|
-
* @returns
|
|
72
|
+
* @returns True unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.
|
|
65
73
|
*/
|
|
66
74
|
export function analyticsDisabled(env = process.env) {
|
|
67
75
|
return isTruthy(env[constants.environmentVariables.noAnalytics]) || isDevelopment(env);
|
|
68
76
|
}
|
|
69
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* Returns true if reporting analytics should always happen, regardless of DEBUG mode etc.
|
|
79
|
+
*
|
|
80
|
+
* @param env - The environment variables from the environment of the current process.
|
|
81
|
+
* @returns True if SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS is truthy.
|
|
82
|
+
*/
|
|
70
83
|
export function alwaysLogAnalytics(env = process.env) {
|
|
71
84
|
return isTruthy(env[constants.environmentVariables.alwaysLogAnalytics]);
|
|
72
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Returns true if the CLI User is 1P.
|
|
88
|
+
*
|
|
89
|
+
* @param env - The environment variables from the environment of the current process.
|
|
90
|
+
* @returns True if SHOPIFY_CLI_1P is truthy.
|
|
91
|
+
*/
|
|
73
92
|
export function firstPartyDev(env = process.env) {
|
|
74
93
|
return isTruthy(env[constants.environmentVariables.firstPartyDev]);
|
|
75
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Returns true if the CLI should use device auth.
|
|
97
|
+
*
|
|
98
|
+
* @param env - The environment variables from the environment of the current process.
|
|
99
|
+
* @returns True if SHOPIFY_CLI_DEVICE_AUTH is truthy or the CLI is run from a cloud environment.
|
|
100
|
+
*/
|
|
76
101
|
export function useDeviceAuth(env = process.env) {
|
|
77
102
|
return isTruthy(env[constants.environmentVariables.deviceAuth]) || isCloudEnvironment(env);
|
|
78
103
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Returns true if the CLI should use theme bundling.
|
|
106
|
+
*
|
|
107
|
+
* @param env - The environment variables from the environment of the current process.
|
|
108
|
+
* @returns True if SHOPIFY_CLI_THEME_BUNDLING is truthy.
|
|
109
|
+
*/
|
|
82
110
|
export function useThemeBundling(env = process.env) {
|
|
83
111
|
return isTruthy(env[constants.environmentVariables.themeBundling]);
|
|
84
112
|
}
|
|
85
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Return gitpodURL if we are running in gitpod.
|
|
115
|
+
* Https://www.gitpod.io/docs/environment-variables#default-environment-variables.
|
|
116
|
+
*
|
|
117
|
+
* @param env - The environment variables from the environment of the current process.
|
|
118
|
+
* @returns The gitpod URL.
|
|
119
|
+
*/
|
|
86
120
|
export function gitpodURL(env = process.env) {
|
|
87
121
|
return env[constants.environmentVariables.gitpod];
|
|
88
122
|
}
|
|
89
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Return codespaceURL if we are running in codespaces.
|
|
125
|
+
* Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.
|
|
126
|
+
*
|
|
127
|
+
* @param env - The environment variables from the environment of the current process.
|
|
128
|
+
* @returns The codespace URL.
|
|
129
|
+
*/
|
|
90
130
|
export function codespaceURL(env = process.env) {
|
|
91
131
|
return env[constants.environmentVariables.codespaceName];
|
|
92
132
|
}
|
|
93
133
|
/**
|
|
94
|
-
* Checks if the CLI is run from a cloud environment
|
|
95
|
-
*
|
|
96
|
-
* @param env - Environment variables used when the cli is launched
|
|
134
|
+
* Checks if the CLI is run from a cloud environment.
|
|
97
135
|
*
|
|
98
|
-
* @
|
|
136
|
+
* @param env - Environment variables used when the cli is launched.
|
|
137
|
+
* @returns True in case the CLI is run from a cloud environment.
|
|
99
138
|
*/
|
|
100
139
|
export function isCloudEnvironment(env = process.env) {
|
|
101
140
|
return cloudEnvironment(env).platform !== 'localhost';
|
|
102
141
|
}
|
|
103
142
|
/**
|
|
104
143
|
* Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of
|
|
105
|
-
* them. Platform name 'localhost' is returned otherwise
|
|
144
|
+
* them. Platform name 'localhost' is returned otherwise.
|
|
106
145
|
*
|
|
107
|
-
* @param env - Environment variables used when the cli is launched
|
|
108
|
-
*
|
|
109
|
-
* @returns Cloud platform information
|
|
146
|
+
* @param env - Environment variables used when the cli is launched.
|
|
147
|
+
* @returns Cloud platform information.
|
|
110
148
|
*/
|
|
111
149
|
export function cloudEnvironment(env = process.env) {
|
|
112
150
|
if (isSet(env[constants.environmentVariables.codespaces])) {
|
|
@@ -122,6 +160,7 @@ export function cloudEnvironment(env = process.env) {
|
|
|
122
160
|
}
|
|
123
161
|
/**
|
|
124
162
|
* Returns whether the environment has Git available.
|
|
163
|
+
*
|
|
125
164
|
* @returns A promise that resolves with the value.
|
|
126
165
|
*/
|
|
127
166
|
export async function hasGit() {
|
|
@@ -135,7 +174,10 @@ export async function hasGit() {
|
|
|
135
174
|
}
|
|
136
175
|
}
|
|
137
176
|
/**
|
|
138
|
-
* Gets info on the CI platform the CLI is running on, if applicable
|
|
177
|
+
* Gets info on the CI platform the CLI is running on, if applicable.
|
|
178
|
+
*
|
|
179
|
+
* @param env - The environment variables from the environment of the current process.
|
|
180
|
+
* @returns The CI platform info.
|
|
139
181
|
*/
|
|
140
182
|
export function ciPlatform(env = process.env) {
|
|
141
183
|
if (isTruthy(env.CI)) {
|
|
@@ -159,9 +201,9 @@ export function ciPlatform(env = process.env) {
|
|
|
159
201
|
};
|
|
160
202
|
}
|
|
161
203
|
/**
|
|
162
|
-
* Returns the first mac address found
|
|
204
|
+
* Returns the first mac address found.
|
|
163
205
|
*
|
|
164
|
-
* @returns Mac address
|
|
206
|
+
* @returns Mac address.
|
|
165
207
|
*/
|
|
166
208
|
export function macAddress() {
|
|
167
209
|
return macaddress.one();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../src/public/node/environment/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,gDAAgD,CAAA;AAC9E,OAAO,SAAS,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EAAC,MAAM,IAAI,UAAU,EAAC,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAA;AAC7C,OAAO,aAAa,MAAM,gBAAgB,CAAA;AAC1C,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,EAAC,OAAO,EAAC,MAAM,IAAI,CAAA;AAE1B;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,aAAa,EAAE,CAAA;AACxB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,OAAO,EAAE,CAAA;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IAC7C,OAAO,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,GAAG,CAAC,KAAK,aAAa,CAAA;AAClE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACzC,OAAO,QAAQ,CAAC,GAAG,CAAC,SAAS,CA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environment/utilities.js'\nimport constants from '../../../constants.js'\nimport {exists as fileExists} from '../../../file.js'\nimport {exec} from '../system.js'\nimport {isSpin} from '../environment/spin.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 *\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 *\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 *\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 *\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 *\n * @param env - The environment variables from the environment of the current process.\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 *\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 *\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/**\n * Returns true if reporting analytics should always happen, regardless of DEBUG mode etc.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS is truthy.\n */\nexport function alwaysLogAnalytics(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.alwaysLogAnalytics])\n}\n\n/**\n * Returns true if the CLI User is 1P.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_1P is truthy.\n */\nexport function firstPartyDev(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.firstPartyDev])\n}\n\n/**\n * Returns true if the CLI should use device auth.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_DEVICE_AUTH is truthy or the CLI is run from a cloud environment.\n */\nexport function useDeviceAuth(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.deviceAuth]) || isCloudEnvironment(env)\n}\n\n/**\n * Returns true if the CLI should use theme bundling.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_THEME_BUNDLING is truthy.\n */\nexport function useThemeBundling(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.themeBundling])\n}\n\n/**\n * Return gitpodURL if we are running in gitpod.\n * Https://www.gitpod.io/docs/environment-variables#default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The gitpod URL.\n */\nexport function gitpodURL(env = process.env): string | undefined {\n return env[constants.environmentVariables.gitpod]\n}\n\n/**\n * Return codespaceURL if we are running in codespaces.\n * Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The codespace URL.\n */\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 * @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 * @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 *\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 *\n * @param env - The environment variables from the environment of the current process.\n * @returns The CI platform info.\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(): Promise<string> {\n return macaddress.one()\n}\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* When ran in a Spin environment, it returns the fqdn of the instance.
|
|
4
|
+
*
|
|
5
|
+
* Will cache the value of the Spin FQDN during the execution of the CLI.
|
|
6
|
+
* To avoid multiple calls to `readSync` or `show`.
|
|
7
|
+
*
|
|
8
|
+
* @param env - Environment variables.
|
|
9
|
+
* @returns Fqdn of the Spin environment.
|
|
10
|
+
*/
|
|
11
|
+
export declare function spinFqdn(env?: NodeJS.ProcessEnv): Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Runs "spin show" and returns the JSON-parsed output.
|
|
14
|
+
*
|
|
15
|
+
* @param spinInstance - When it's undefined, we'll fetch the latest one.
|
|
16
|
+
* @param env - Environment variables.
|
|
17
|
+
* @returns The JSON-parsed output of the Spin CLI.
|
|
18
|
+
* @throws Any error raised from the underlying Spin CLI.
|
|
19
|
+
*/
|
|
20
|
+
export declare function show(spinInstance: string | undefined, env?: NodeJS.ProcessEnv): Promise<{
|
|
21
|
+
fqdn: string;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Returns true if the CLI is running in a Spin environment.
|
|
25
|
+
*
|
|
26
|
+
* @param env - Environment variables.
|
|
27
|
+
* @returns True if the CLI is running in a Spin environment.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isSpin(env?: NodeJS.ProcessEnv): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Returns the value of the SPIN_INSTANCE environment variable.
|
|
32
|
+
*
|
|
33
|
+
* @param env - Environment variables.
|
|
34
|
+
* @returns The value of the SPIN_INSTANCE environment variable.
|
|
35
|
+
*/
|
|
36
|
+
export declare function instance(env?: NodeJS.ProcessEnv): string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Returns true if the CLI is running in a Spin environment.
|
|
39
|
+
*
|
|
40
|
+
* @param env - Environment variables.
|
|
41
|
+
* @returns True if the CLI is running in a Spin environment.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isSpinEnvironment(env?: NodeJS.ProcessEnv): boolean;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { isTruthy } from '
|
|
2
|
-
import
|
|
3
|
-
import constants from '../constants.js';
|
|
1
|
+
import { isTruthy } from '../../../private/node/environment/utilities.js';
|
|
2
|
+
import constants from '../../../constants.js';
|
|
4
3
|
import { captureOutput } from '../system.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
4
|
+
import { content, token } from '../../../output.js';
|
|
5
|
+
import { exists, readSync } from '../../../file.js';
|
|
6
|
+
import { getCachedSpinFqdn, setCachedSpinFqdn } from '../../../private/node/environment/spin-cache.js';
|
|
7
|
+
import { Abort } from '../../../error.js';
|
|
8
|
+
import { Environment, serviceEnvironment } from '../../../private/node/environment/service.js';
|
|
9
|
+
const SpinInstanceNotFoundMessages = (spinInstance, error) => {
|
|
9
10
|
const errorMessage = content `${token.genericShellCommand(`spin`)} yielded the following error trying to obtain the fully qualified domain name of the Spin instance:
|
|
10
11
|
${error}
|
|
11
12
|
`;
|
|
@@ -13,17 +14,19 @@ ${error}
|
|
|
13
14
|
if (spinInstance) {
|
|
14
15
|
nextSteps = `Make sure ${spinInstance} is the instance name and not a fully qualified domain name`;
|
|
15
16
|
}
|
|
16
|
-
return
|
|
17
|
+
return { errorMessage, nextSteps };
|
|
17
18
|
};
|
|
18
19
|
const spinFqdnFilePath = '/etc/spin/machine/fqdn';
|
|
19
20
|
/**
|
|
20
21
|
* When ran in a Spin environment, it returns the fqdn of the instance.
|
|
21
22
|
*
|
|
22
23
|
* Will cache the value of the Spin FQDN during the execution of the CLI.
|
|
23
|
-
* To avoid multiple calls to `readSync` or `show
|
|
24
|
-
*
|
|
24
|
+
* To avoid multiple calls to `readSync` or `show`.
|
|
25
|
+
*
|
|
26
|
+
* @param env - Environment variables.
|
|
27
|
+
* @returns Fqdn of the Spin environment.
|
|
25
28
|
*/
|
|
26
|
-
export async function
|
|
29
|
+
export async function spinFqdn(env = process.env) {
|
|
27
30
|
let spinFqdn = getCachedSpinFqdn();
|
|
28
31
|
if (spinFqdn)
|
|
29
32
|
return spinFqdn;
|
|
@@ -40,7 +43,9 @@ export async function fqdn(env = process.env) {
|
|
|
40
43
|
}
|
|
41
44
|
/**
|
|
42
45
|
* Runs "spin show" and returns the JSON-parsed output.
|
|
46
|
+
*
|
|
43
47
|
* @param spinInstance - When it's undefined, we'll fetch the latest one.
|
|
48
|
+
* @param env - Environment variables.
|
|
44
49
|
* @returns The JSON-parsed output of the Spin CLI.
|
|
45
50
|
* @throws Any error raised from the underlying Spin CLI.
|
|
46
51
|
*/
|
|
@@ -50,7 +55,8 @@ export async function show(spinInstance, env = process.env) {
|
|
|
50
55
|
const output = await captureOutput('spin', args, { env });
|
|
51
56
|
const json = JSON.parse(output);
|
|
52
57
|
if (json.error) {
|
|
53
|
-
|
|
58
|
+
const { errorMessage, nextSteps } = SpinInstanceNotFoundMessages(spinInstance, json.error);
|
|
59
|
+
throw new Abort(errorMessage, nextSteps);
|
|
54
60
|
}
|
|
55
61
|
else {
|
|
56
62
|
return json;
|
|
@@ -58,7 +64,8 @@ export async function show(spinInstance, env = process.env) {
|
|
|
58
64
|
}
|
|
59
65
|
/**
|
|
60
66
|
* Returns true if the CLI is running in a Spin environment.
|
|
61
|
-
*
|
|
67
|
+
*
|
|
68
|
+
* @param env - Environment variables.
|
|
62
69
|
* @returns True if the CLI is running in a Spin environment.
|
|
63
70
|
*/
|
|
64
71
|
export function isSpin(env = process.env) {
|
|
@@ -66,34 +73,20 @@ export function isSpin(env = process.env) {
|
|
|
66
73
|
}
|
|
67
74
|
/**
|
|
68
75
|
* Returns the value of the SPIN_INSTANCE environment variable.
|
|
69
|
-
*
|
|
76
|
+
*
|
|
77
|
+
* @param env - Environment variables.
|
|
70
78
|
* @returns The value of the SPIN_INSTANCE environment variable.
|
|
71
79
|
*/
|
|
72
80
|
export function instance(env = process.env) {
|
|
73
81
|
return env[constants.environmentVariables.spinInstance];
|
|
74
82
|
}
|
|
75
83
|
/**
|
|
76
|
-
* Returns the
|
|
77
|
-
*
|
|
78
|
-
* @
|
|
79
|
-
|
|
80
|
-
export function workspace(env = process.env) {
|
|
81
|
-
return env[constants.environmentVariables.spinWorkspace];
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Returns the value of the SPIN_NAMESPACE environment variable.
|
|
85
|
-
* @param env - Environment variables
|
|
86
|
-
* @returns The value of the SPIN_NAMESPACE environment variable.
|
|
87
|
-
*/
|
|
88
|
-
export function namespace(env = process.env) {
|
|
89
|
-
return env[constants.environmentVariables.spinNamespace];
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Returns the value of the SPIN_HOST environment variable.
|
|
93
|
-
* @param env - Environment variables
|
|
94
|
-
* @returns The value of the SPIN_HOST environment variable.
|
|
84
|
+
* Returns true if the CLI is running in a Spin environment.
|
|
85
|
+
*
|
|
86
|
+
* @param env - Environment variables.
|
|
87
|
+
* @returns True if the CLI is running in a Spin environment.
|
|
95
88
|
*/
|
|
96
|
-
export function
|
|
97
|
-
return env
|
|
89
|
+
export function isSpinEnvironment(env = process.env) {
|
|
90
|
+
return serviceEnvironment(env) === Environment.Spin;
|
|
98
91
|
}
|
|
99
92
|
//# sourceMappingURL=spin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spin.js","sourceRoot":"","sources":["../../../../src/public/node/environment/spin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,gDAAgD,CAAA;AACvE,OAAO,SAAS,MAAM,uBAAuB,CAAA;AAC7C,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAC,iBAAiB,EAAE,iBAAi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AY,KAAK,SAAS,CAAA;IACzC,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IACzE,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,EAAC,GAAG,EAAC,CAAC,CAAA;IACvD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAC/B,IAAI,IAAI,CAAC,KAAK,EAAE;QACd,MAAM,EAAC,YAAY,EAAE,SAAS,EAAC,GAAG,4BAA4B,CAAC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;QACxF,MAAM,IAAI,KAAK,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA;KACzC;SAAM;QACL,OAAO,IAAI,CAAA;KACZ;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACtC,OAAO,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAA;AAC3D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACxC,OAAO,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAA;AACzD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACjD,OAAO,kBAAkB,CAAC,GAAG,CAAC,KAAK,WAAW,CAAC,IAAI,CAAA;AACrD,CAAC","sourcesContent":["import {isTruthy} from '../../../private/node/environment/utilities.js'\nimport constants from '../../../constants.js'\nimport {captureOutput} from '../system.js'\nimport {content, token} from '../../../output.js'\nimport {exists, readSync} from '../../../file.js'\nimport {getCachedSpinFqdn, setCachedSpinFqdn} from '../../../private/node/environment/spin-cache.js'\nimport {Abort} from '../../../error.js'\nimport {Environment, serviceEnvironment} from '../../../private/node/environment/service.js'\n\nconst SpinInstanceNotFoundMessages = (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 {errorMessage, nextSteps}\n}\n\nconst spinFqdnFilePath = '/etc/spin/machine/fqdn'\n\n/**\n * When ran in a Spin environment, it returns the fqdn of the instance.\n *\n * Will cache the value of the Spin FQDN during the execution of the CLI.\n * To avoid multiple calls to `readSync` or `show`.\n *\n * @param env - Environment variables.\n * @returns Fqdn of the Spin environment.\n */\nexport async function spinFqdn(env = process.env): Promise<string> {\n let spinFqdn = getCachedSpinFqdn()\n if (spinFqdn) return spinFqdn\n\n if (await exists(spinFqdnFilePath)) {\n spinFqdn = await readSync(spinFqdnFilePath).toString()\n } else {\n const spinInstance = await instance(env)\n const showResponse = await show(spinInstance, env)\n\n spinFqdn = showResponse.fqdn\n }\n setCachedSpinFqdn(spinFqdn)\n return spinFqdn\n}\n\n/**\n * Runs \"spin show\" and returns the JSON-parsed output.\n *\n * @param spinInstance - When it's undefined, we'll fetch the latest one.\n * @param env - Environment variables.\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 const {errorMessage, nextSteps} = SpinInstanceNotFoundMessages(spinInstance, json.error)\n throw new Abort(errorMessage, nextSteps)\n } else {\n return json\n }\n}\n\n/**\n * Returns true if the CLI is running in a Spin environment.\n *\n * @param env - Environment variables.\n * @returns 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 *\n * @param env - Environment variables.\n * @returns 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 true if the CLI is running in a Spin environment.\n *\n * @param env - Environment variables.\n * @returns True if the CLI is running in a Spin environment.\n */\nexport function isSpinEnvironment(env = process.env): boolean {\n return serviceEnvironment(env) === Environment.Spin\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AbortError, BugError } from './error.js';
|
|
2
2
|
import { Version } from './semver.js';
|
|
3
3
|
import { AbortController } from './abort.js';
|
|
4
|
-
import { exec } from '
|
|
4
|
+
import { exec } from './system.js';
|
|
5
5
|
import { exists as fileExists, read as readFile, write as writeFile } from '../../file.js';
|
|
6
6
|
import { glob, dirname, join as pathJoin, findUp, moduleDirectory } from '../../path.js';
|
|
7
7
|
import { token, content, debug } from '../../output.js';
|