@shopify/cli-kit 3.33.0 → 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 -5
- package/dist/constants.js +0 -3
- 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 -4
- package/dist/index.js +0 -4
- 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/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 +1 -1
- package/dist/private/node/api/rest.js.map +1 -1
- 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 +3 -3
- 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.js +1 -1
- package/dist/private/node/ui.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 +1 -1
- package/dist/public/node/api/admin.js.map +1 -1
- package/dist/public/node/api/partners.js +1 -1
- 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 -15
- package/dist/{environment → public/node/environment}/local.js +66 -21
- 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 +11 -12
- 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/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 -6
- 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/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
package/dist/public/node/cli.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
1
2
|
function setupEnvironmentVariables(options) {
|
|
2
3
|
/**
|
|
3
4
|
* By setting DEBUG=* when --verbose is passed we are increasing the
|
|
@@ -24,7 +25,7 @@ export async function runCLI(options) {
|
|
|
24
25
|
* and therefore it has no effect.
|
|
25
26
|
*/
|
|
26
27
|
const { errorHandler } = await import('./error-handler.js');
|
|
27
|
-
const { isDevelopment } = await import('
|
|
28
|
+
const { isDevelopment } = await import('./environment/local.js');
|
|
28
29
|
const { run, settings, flush } = await import('@oclif/core');
|
|
29
30
|
if (isDevelopment()) {
|
|
30
31
|
settings.debug = true;
|
|
@@ -52,10 +53,10 @@ export async function runCreateCLI(options) {
|
|
|
52
53
|
await runCLI(options);
|
|
53
54
|
}
|
|
54
55
|
export async function useLocalCLIIfDetected(filepath) {
|
|
55
|
-
const { isTruthy } = await import('../../environment/utilities.js');
|
|
56
|
+
const { isTruthy } = await import('../../private/node/environment/utilities.js');
|
|
56
57
|
const constants = await import('../../constants.js');
|
|
57
58
|
const { join } = await import('../../path.js');
|
|
58
|
-
const { exec } = await import('
|
|
59
|
+
const { exec } = await import('./system.js');
|
|
59
60
|
// Temporary flag while we test out this feature and ensure it won't break anything!
|
|
60
61
|
if (!isTruthy(process.env[constants.default.environmentVariables.enableCliRedirect]))
|
|
61
62
|
return false;
|
|
@@ -84,7 +85,7 @@ export async function useLocalCLIIfDetected(filepath) {
|
|
|
84
85
|
return true;
|
|
85
86
|
}
|
|
86
87
|
export async function localCliPackage() {
|
|
87
|
-
const { captureOutput } = await import('
|
|
88
|
+
const { captureOutput } = await import('./system.js');
|
|
88
89
|
let npmListOutput = '';
|
|
89
90
|
let localShopifyCLI = {};
|
|
90
91
|
try {
|
|
@@ -102,5 +103,21 @@ export async function localCliPackage() {
|
|
|
102
103
|
};
|
|
103
104
|
return dependenciesList['@shopify/cli'];
|
|
104
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* An object that contains the flags that
|
|
108
|
+
* are shared across all the commands.
|
|
109
|
+
*/
|
|
110
|
+
export const globalFlags = {
|
|
111
|
+
preset: Flags.string({
|
|
112
|
+
hidden: true,
|
|
113
|
+
description: 'The preset to apply to the current command.',
|
|
114
|
+
env: 'SHOPIFY_FLAG_PRESET',
|
|
115
|
+
}),
|
|
116
|
+
verbose: Flags.boolean({
|
|
117
|
+
hidden: false,
|
|
118
|
+
description: 'Increase the verbosity of the logs.',
|
|
119
|
+
env: 'SHOPIFY_FLAG_VERBOSE',
|
|
120
|
+
}),
|
|
121
|
+
};
|
|
105
122
|
export default runCLI;
|
|
106
123
|
//# sourceMappingURL=cli.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/public/node/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/public/node/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAajC,SAAS,yBAAyB,CAAC,OAA2C;IAC5E;;;;OAI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AAC,CAAA;QAC3C,qDAAqD;KACtD;IAAC,OAAO,GAAG,EAAE;QACZ,OAAM;KACP;IACD,MAAM,gBAAgB,GAAG;QACvB,GAAG,eAAe,CAAC,gBAAgB;QACnC,GAAG,eAAe,CAAC,eAAe;QAClC,GAAG,eAAe,CAAC,YAAY;KAChC,CAAA;IACD,OAAO,gBAAgB,CAAC,cAAc,CAAC,CAAA;AACzC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;QACnB,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,6CAA6C;QAC1D,GAAG,EAAE,qBAAqB;KAC3B,CAAC;IACF,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;QACrB,MAAM,EAAE,KAAK;QACb,WAAW,EAAE,qCAAqC;QAClD,GAAG,EAAE,sBAAsB;KAC5B,CAAC;CACH,CAAA;AAED,eAAe,MAAM,CAAA","sourcesContent":["import {Flags} from '@oclif/core'\n\n/**\n * IMPORTANT NOTE: Imports in this module are dynamic to ensure that \"setupEnvironmentVariables\" can dynamically\n * set the DEBUG environment variable before the 'debug' package sets up its configuration when modules\n * are loaded statically.\n */\ninterface RunCLIOptions {\n /** The value of import.meta.url of the CLI executable module */\n moduleURL: string\n development: boolean\n}\n\nfunction setupEnvironmentVariables(options: Pick<RunCLIOptions, 'development'>) {\n /**\n * By setting DEBUG=* when --verbose is passed we are increasing the\n * verbosity of oclif. Oclif uses debug (https://www.npmjs.com/package/debug)\n * for logging, and it's configured through the DEBUG= environment variable.\n */\n if (process.argv.includes('--verbose')) {\n process.env.DEBUG = process.env.DEBUG ?? '*'\n }\n if (options.development) {\n process.env.SHOPIFY_CLI_ENV = process.env.SHOPIFY_CLI_ENV ?? 'development'\n }\n}\n\n/**\n * A function that abstracts away setting up the environment and running\n * a CLI\n * @param options - Options.\n */\nexport async function runCLI(options: RunCLIOptions): Promise<void> {\n setupEnvironmentVariables(options)\n /**\n * These imports need to be dynamic because if they are static\n * they are loaded before we set the DEBUG=* environment variable\n * and therefore it has no effect.\n */\n const {errorHandler} = await import('./error-handler.js')\n const {isDevelopment} = await import('./environment/local.js')\n const {run, settings, flush} = await import('@oclif/core')\n\n if (isDevelopment()) {\n settings.debug = true\n }\n\n run(undefined, options.moduleURL)\n .then(() => flush())\n .catch(errorHandler)\n}\n\n/**\n * A function for create-x CLIs that automatically runs the \"init\" command.\n */\nexport async function runCreateCLI(options: RunCLIOptions): Promise<void> {\n setupEnvironmentVariables(options)\n\n const {findUpAndReadPackageJson} = await import('./node-package-manager.js')\n const {moduleDirectory} = await import('../../path.js')\n\n const packageJson = await findUpAndReadPackageJson(moduleDirectory(options.moduleURL))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const packageName = (packageJson.content as any).name as string\n const name = packageName.replace('@shopify/create-', '')\n const initIndex = process.argv.findIndex((arg) => arg.includes('init'))\n if (initIndex === -1) {\n const initIndex =\n process.argv.findIndex((arg) => arg.match(new RegExp(`bin(\\\\/|\\\\\\\\)+(create-${name}|dev|run)`))) + 1\n process.argv.splice(initIndex, 0, 'init')\n }\n await runCLI(options)\n}\n\nexport async function useLocalCLIIfDetected(filepath: string): Promise<boolean> {\n const {isTruthy} = await import('../../private/node/environment/utilities.js')\n const constants = await import('../../constants.js')\n const {join} = await import('../../path.js')\n const {exec} = await import('./system.js')\n\n // Temporary flag while we test out this feature and ensure it won't break anything!\n if (!isTruthy(process.env[constants.default.environmentVariables.enableCliRedirect])) return false\n\n // Setting an env variable in the child process prevents accidental recursion.\n if (isTruthy(process.env[constants.default.environmentVariables.skipCliRedirect])) return false\n\n // If already running via package manager, we can assume it's running correctly already.\n if (process.env.npm_config_user_agent) return false\n\n const cliPackage = await localCliPackage()\n if (!cliPackage) return false\n\n const correctExecutablePath = join(cliPackage.path, cliPackage.bin.shopify)\n if (correctExecutablePath === filepath) return false\n try {\n await exec(correctExecutablePath, process.argv.slice(2, process.argv.length), {\n stdio: 'inherit',\n env: {[constants.default.environmentVariables.skipCliRedirect]: '1'},\n })\n // eslint-disable-next-line no-catch-all/no-catch-all, @typescript-eslint/no-explicit-any\n } catch (processError: any) {\n process.exit(processError.exitCode)\n }\n return true\n}\n\ninterface CliPackageInfo {\n path: string\n bin: {shopify: string}\n}\n\ninterface PackageJSON {\n dependencies?: {[packageName: string]: CliPackageInfo}\n devDependencies?: {[packageName: string]: CliPackageInfo}\n peerDependencies?: {[packageName: string]: CliPackageInfo}\n}\n\nexport async function localCliPackage(): Promise<CliPackageInfo | undefined> {\n const {captureOutput} = await import('./system.js')\n\n let npmListOutput = ''\n let localShopifyCLI: PackageJSON = {}\n try {\n npmListOutput = await captureOutput('npm', ['list', '@shopify/cli', '--json', '-l'])\n localShopifyCLI = JSON.parse(npmListOutput)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (err) {\n return\n }\n const dependenciesList = {\n ...localShopifyCLI.peerDependencies,\n ...localShopifyCLI.devDependencies,\n ...localShopifyCLI.dependencies,\n }\n return dependenciesList['@shopify/cli']\n}\n\n/**\n * An object that contains the flags that\n * are shared across all the commands.\n */\nexport const globalFlags = {\n preset: Flags.string({\n hidden: true,\n description: 'The preset to apply to the current command.',\n env: 'SHOPIFY_FLAG_PRESET',\n }),\n verbose: Flags.boolean({\n hidden: false,\n description: 'Increase the verbosity of the logs.',\n env: 'SHOPIFY_FLAG_VERBOSE',\n }),\n}\n\nexport default runCLI\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Abort } from '../../../error.js';
|
|
2
|
+
export declare const CouldntObtainPartnersSpinFQDNError: Abort;
|
|
3
|
+
export declare const CouldntObtainIdentitySpinFQDNError: Abort;
|
|
4
|
+
export declare const CouldntObtainShopifySpinFQDNError: Abort;
|
|
5
|
+
export declare const NotProvidedStoreFQDNError: Abort;
|
|
6
|
+
/**
|
|
7
|
+
* It returns the Partners' API service we should interact with.
|
|
8
|
+
*
|
|
9
|
+
* @returns Fully-qualified domain of the partners service we should interact with.
|
|
10
|
+
*/
|
|
11
|
+
export declare function partnersFqdn(): Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* It returns the Identity service we should interact with.
|
|
14
|
+
*
|
|
15
|
+
* @returns Fully-qualified domain of the Identity service we should interact with.
|
|
16
|
+
*/
|
|
17
|
+
export declare function identityFqdn(): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Normalize the store name to be used in the CLI.
|
|
20
|
+
* It will add the .myshopify.com domain if it's not present.
|
|
21
|
+
* It will add the spin domain if it's not present and we're in a Spin environment.
|
|
22
|
+
*
|
|
23
|
+
* @param store - Store name.
|
|
24
|
+
* @returns Normalized store name.
|
|
25
|
+
*/
|
|
26
|
+
export declare function normalizeStoreFqdn(store: string): Promise<string>;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { isSpinEnvironment, spinFqdn } from './spin.js';
|
|
2
|
+
import { Abort } from '../../../error.js';
|
|
3
|
+
import { serviceEnvironment } from '../../../private/node/environment/service.js';
|
|
4
4
|
export const CouldntObtainPartnersSpinFQDNError = new Abort("Couldn't obtain the Spin FQDN for Partners when the CLI is not running from a Spin environment.");
|
|
5
5
|
export const CouldntObtainIdentitySpinFQDNError = new Abort("Couldn't obtain the Spin FQDN for Identity when the CLI is not running from a Spin environment.");
|
|
6
6
|
export const CouldntObtainShopifySpinFQDNError = new Abort("Couldn't obtain the Spin FQDN for Shopify when the CLI is not running from a Spin environment.");
|
|
7
7
|
export const NotProvidedStoreFQDNError = new Abort("Couldn't obtain the Shopify FQDN because the store FQDN was not provided.");
|
|
8
8
|
/**
|
|
9
9
|
* It returns the Partners' API service we should interact with.
|
|
10
|
+
*
|
|
10
11
|
* @returns Fully-qualified domain of the partners service we should interact with.
|
|
11
12
|
*/
|
|
12
|
-
export async function
|
|
13
|
+
export async function partnersFqdn() {
|
|
13
14
|
const environment = serviceEnvironment();
|
|
14
15
|
const productionFqdn = 'partners.shopify.com';
|
|
15
16
|
switch (environment) {
|
|
@@ -23,9 +24,10 @@ export async function partners() {
|
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* It returns the Identity service we should interact with.
|
|
27
|
+
*
|
|
26
28
|
* @returns Fully-qualified domain of the Identity service we should interact with.
|
|
27
29
|
*/
|
|
28
|
-
export async function
|
|
30
|
+
export async function identityFqdn() {
|
|
29
31
|
const environment = serviceEnvironment();
|
|
30
32
|
const productionFqdn = 'accounts.shopify.com';
|
|
31
33
|
switch (environment) {
|
|
@@ -38,34 +40,16 @@ export async function identity() {
|
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
43
|
+
* Normalize the store name to be used in the CLI.
|
|
44
|
+
* It will add the .myshopify.com domain if it's not present.
|
|
45
|
+
* It will add the spin domain if it's not present and we're in a Spin environment.
|
|
46
|
+
*
|
|
47
|
+
* @param store - Store name.
|
|
48
|
+
* @returns Normalized store name.
|
|
44
49
|
*/
|
|
45
|
-
export async function
|
|
46
|
-
const environment = serviceEnvironment();
|
|
47
|
-
switch (environment) {
|
|
48
|
-
case 'local':
|
|
49
|
-
return 'shopify.myshopify.io';
|
|
50
|
-
case 'spin':
|
|
51
|
-
return `identity.${await spinFqdn()}`;
|
|
52
|
-
default:
|
|
53
|
-
if (options.storeFqdn) {
|
|
54
|
-
return options.storeFqdn;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
throw NotProvidedStoreFQDNError;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Given a store, returns a valid store fqdn removing protocol and adding the proper domain in case is missing
|
|
63
|
-
* @param store - Original store name provided by the user
|
|
64
|
-
* @returns a valid store fqdn
|
|
65
|
-
*/
|
|
66
|
-
export async function normalizeStoreName(store) {
|
|
50
|
+
export async function normalizeStoreFqdn(store) {
|
|
67
51
|
const storeFqdn = store.replace(/^https?:\/\//, '').replace(/\/$/, '');
|
|
68
|
-
const addDomain = async (storeFqdn) => isSpinEnvironment() ? `${storeFqdn}.shopify.${await
|
|
52
|
+
const addDomain = async (storeFqdn) => isSpinEnvironment() ? `${storeFqdn}.shopify.${await spinFqdn()}` : `${storeFqdn}.myshopify.com`;
|
|
69
53
|
const containDomain = (storeFqdn) => storeFqdn.includes('.myshopify.com') || storeFqdn.includes('spin.dev');
|
|
70
54
|
return containDomain(storeFqdn) ? storeFqdn : addDomain(storeFqdn);
|
|
71
55
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fqdn.js","sourceRoot":"","sources":["../../../../src/public/node/environment/fqdn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AACrD,OAAO,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAA;AACvC,OAAO,EAAC,kBAAkB,EAAC,MAAM,8CAA8C,CAAA;AAE/E,MAAM,CAAC,MAAM,kCAAkC,GAAG,IAAI,KAAK,CACzD,iGAAiG,CAClG,CAAA;AACD,MAAM,CAAC,MAAM,kCAAkC,GAAG,IAAI,KAAK,CACzD,iGAAiG,CAClG,CAAA;AACD,MAAM,CAAC,MAAM,iCAAiC,GAAG,IAAI,KAAK,CACxD,gGAAgG,CACjG,CAAA;AACD,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,KAAK,CAChD,2EAA2E,CAC5E,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,MAAM,WAAW,GAAG,kBAAkB,EAAE,CAAA;IACxC,MAAM,cAAc,GAAG,sBAAsB,CAAA;IAC7C,QAAQ,WAAW,EAAE;QACnB,KAAK,OAAO;YACV,OAAO,uBAAuB,CAAA;QAChC,KAAK,MAAM;YACT,OAAO,YAAY,MAAM,QAAQ,EAAE,EAAE,CAAA;QACvC;YACE,OAAO,cAAc,CAAA;KACxB;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,MAAM,WAAW,GAAG,kBAAkB,EAAE,CAAA;IACxC,MAAM,cAAc,GAAG,sBAAsB,CAAA;IAC7C,QAAQ,WAAW,EAAE;QACnB,KAAK,OAAO;YACV,OAAO,uBAAuB,CAAA;QAChC,KAAK,MAAM;YACT,OAAO,YAAY,MAAM,QAAQ,EAAE,EAAE,CAAA;QACvC;YACE,OAAO,cAAc,CAAA;KACxB;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,KAAa;IACpD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IACtE,MAAM,SAAS,GAAG,KAAK,EAAE,SAAiB,EAAE,EAAE,CAC5C,iBAAiB,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,YAAY,MAAM,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,gBAAgB,CAAA;IACjG,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;IACnH,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;AACpE,CAAC","sourcesContent":["import {isSpinEnvironment, spinFqdn} from './spin.js'\nimport {Abort} from '../../../error.js'\nimport {serviceEnvironment} from '../../../private/node/environment/service.js'\n\nexport const CouldntObtainPartnersSpinFQDNError = new Abort(\n \"Couldn't obtain the Spin FQDN for Partners when the CLI is not running from a Spin environment.\",\n)\nexport const CouldntObtainIdentitySpinFQDNError = new Abort(\n \"Couldn't obtain the Spin FQDN for Identity when the CLI is not running from a Spin environment.\",\n)\nexport const CouldntObtainShopifySpinFQDNError = new Abort(\n \"Couldn't obtain the Spin FQDN for Shopify when the CLI is not running from a Spin environment.\",\n)\nexport const NotProvidedStoreFQDNError = new Abort(\n \"Couldn't obtain the Shopify FQDN because the store FQDN was not provided.\",\n)\n\n/**\n * It returns the Partners' API service we should interact with.\n *\n * @returns Fully-qualified domain of the partners service we should interact with.\n */\nexport async function partnersFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'partners.shopify.com'\n switch (environment) {\n case 'local':\n return 'partners.myshopify.io'\n case 'spin':\n return `partners.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * It returns the Identity service we should interact with.\n *\n * @returns Fully-qualified domain of the Identity service we should interact with.\n */\nexport async function identityFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'accounts.shopify.com'\n switch (environment) {\n case 'local':\n return 'identity.myshopify.io'\n case 'spin':\n return `identity.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * Normalize the store name to be used in the CLI.\n * It will add the .myshopify.com domain if it's not present.\n * It will add the spin domain if it's not present and we're in a Spin environment.\n *\n * @param store - Store name.\n * @returns Normalized store name.\n */\nexport async function normalizeStoreFqdn(store: string): Promise<string> {\n const storeFqdn = store.replace(/^https?:\\/\\//, '').replace(/\\/$/, '')\n const addDomain = async (storeFqdn: string) =>\n isSpinEnvironment() ? `${storeFqdn}.shopify.${await spinFqdn()}` : `${storeFqdn}.myshopify.com`\n const containDomain = (storeFqdn: string) => storeFqdn.includes('.myshopify.com') || storeFqdn.includes('spin.dev')\n return containDomain(storeFqdn) ? storeFqdn : addDomain(storeFqdn)\n}\n"]}
|
|
@@ -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,38 +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;
|
|
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
|
+
*/
|
|
48
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
|
+
*/
|
|
49
87
|
export declare function gitpodURL(env?: NodeJS.ProcessEnv): string | undefined;
|
|
50
|
-
export declare function codespaceURL(env?: NodeJS.ProcessEnv): string | undefined;
|
|
51
88
|
/**
|
|
52
|
-
*
|
|
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.
|
|
53
91
|
*
|
|
54
|
-
* @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.
|
|
55
98
|
*
|
|
56
|
-
* @
|
|
99
|
+
* @param env - Environment variables used when the cli is launched.
|
|
100
|
+
* @returns True in case the CLI is run from a cloud environment.
|
|
57
101
|
*/
|
|
58
102
|
export declare function isCloudEnvironment(env?: NodeJS.ProcessEnv): boolean;
|
|
59
103
|
/**
|
|
60
104
|
* Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of
|
|
61
|
-
* them. Platform name 'localhost' is returned otherwise
|
|
105
|
+
* them. Platform name 'localhost' is returned otherwise.
|
|
62
106
|
*
|
|
63
|
-
* @param env - Environment variables used when the cli is launched
|
|
64
|
-
*
|
|
65
|
-
* @returns Cloud platform information
|
|
107
|
+
* @param env - Environment variables used when the cli is launched.
|
|
108
|
+
* @returns Cloud platform information.
|
|
66
109
|
*/
|
|
67
110
|
export declare function cloudEnvironment(env?: NodeJS.ProcessEnv): {
|
|
68
111
|
platform: 'spin' | 'codespaces' | 'gitpod' | 'localhost';
|
|
@@ -70,11 +113,15 @@ export declare function cloudEnvironment(env?: NodeJS.ProcessEnv): {
|
|
|
70
113
|
};
|
|
71
114
|
/**
|
|
72
115
|
* Returns whether the environment has Git available.
|
|
116
|
+
*
|
|
73
117
|
* @returns A promise that resolves with the value.
|
|
74
118
|
*/
|
|
75
119
|
export declare function hasGit(): Promise<boolean>;
|
|
76
120
|
/**
|
|
77
|
-
* 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.
|
|
78
125
|
*/
|
|
79
126
|
export declare function ciPlatform(env?: NodeJS.ProcessEnv): {
|
|
80
127
|
isCI: true;
|
|
@@ -84,8 +131,8 @@ export declare function ciPlatform(env?: NodeJS.ProcessEnv): {
|
|
|
84
131
|
name?: undefined;
|
|
85
132
|
};
|
|
86
133
|
/**
|
|
87
|
-
* Returns the first mac address found
|
|
134
|
+
* Returns the first mac address found.
|
|
88
135
|
*
|
|
89
|
-
* @returns Mac address
|
|
136
|
+
* @returns Mac address.
|
|
90
137
|
*/
|
|
91
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,50 +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
|
}
|
|
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
|
+
*/
|
|
79
110
|
export function useThemeBundling(env = process.env) {
|
|
80
111
|
return isTruthy(env[constants.environmentVariables.themeBundling]);
|
|
81
112
|
}
|
|
82
|
-
|
|
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
|
+
*/
|
|
83
120
|
export function gitpodURL(env = process.env) {
|
|
84
121
|
return env[constants.environmentVariables.gitpod];
|
|
85
122
|
}
|
|
86
|
-
|
|
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
|
+
*/
|
|
87
130
|
export function codespaceURL(env = process.env) {
|
|
88
131
|
return env[constants.environmentVariables.codespaceName];
|
|
89
132
|
}
|
|
90
133
|
/**
|
|
91
|
-
* Checks if the CLI is run from a cloud environment
|
|
92
|
-
*
|
|
93
|
-
* @param env - Environment variables used when the cli is launched
|
|
134
|
+
* Checks if the CLI is run from a cloud environment.
|
|
94
135
|
*
|
|
95
|
-
* @
|
|
136
|
+
* @param env - Environment variables used when the cli is launched.
|
|
137
|
+
* @returns True in case the CLI is run from a cloud environment.
|
|
96
138
|
*/
|
|
97
139
|
export function isCloudEnvironment(env = process.env) {
|
|
98
140
|
return cloudEnvironment(env).platform !== 'localhost';
|
|
99
141
|
}
|
|
100
142
|
/**
|
|
101
143
|
* Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of
|
|
102
|
-
* them. Platform name 'localhost' is returned otherwise
|
|
144
|
+
* them. Platform name 'localhost' is returned otherwise.
|
|
103
145
|
*
|
|
104
|
-
* @param env - Environment variables used when the cli is launched
|
|
105
|
-
*
|
|
106
|
-
* @returns Cloud platform information
|
|
146
|
+
* @param env - Environment variables used when the cli is launched.
|
|
147
|
+
* @returns Cloud platform information.
|
|
107
148
|
*/
|
|
108
149
|
export function cloudEnvironment(env = process.env) {
|
|
109
150
|
if (isSet(env[constants.environmentVariables.codespaces])) {
|
|
@@ -119,6 +160,7 @@ export function cloudEnvironment(env = process.env) {
|
|
|
119
160
|
}
|
|
120
161
|
/**
|
|
121
162
|
* Returns whether the environment has Git available.
|
|
163
|
+
*
|
|
122
164
|
* @returns A promise that resolves with the value.
|
|
123
165
|
*/
|
|
124
166
|
export async function hasGit() {
|
|
@@ -132,7 +174,10 @@ export async function hasGit() {
|
|
|
132
174
|
}
|
|
133
175
|
}
|
|
134
176
|
/**
|
|
135
|
-
* 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.
|
|
136
181
|
*/
|
|
137
182
|
export function ciPlatform(env = process.env) {
|
|
138
183
|
if (isTruthy(env.CI)) {
|
|
@@ -156,9 +201,9 @@ export function ciPlatform(env = process.env) {
|
|
|
156
201
|
};
|
|
157
202
|
}
|
|
158
203
|
/**
|
|
159
|
-
* Returns the first mac address found
|
|
204
|
+
* Returns the first mac address found.
|
|
160
205
|
*
|
|
161
|
-
* @returns Mac address
|
|
206
|
+
* @returns Mac address.
|
|
162
207
|
*/
|
|
163
208
|
export function macAddress() {
|
|
164
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,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;AACpG,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IAC/C,IAAI,MAAM,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K,EAAC,CAAA;KACzC;IACD,OAAO,EAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAC,CAAA;AAC/C,CAAC;AAED;;;;GAIG;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;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IAC1C,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QACpB,IAAI,IAAI,GAAG,SAAS,CAAA;QACpB,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAC1B,IAAI,GAAG,UAAU,CAAA;SAClB;aAAM,IAAI,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YACnC,IAAI,GAAG,QAAQ,CAAA;SAChB;aAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAClC,IAAI,GAAG,QAAQ,CAAA;SAChB;QAED,OAAO;YACL,IAAI,EAAE,IAAI;YACV,IAAI;SACL,CAAA;KACF;IACD,OAAO;QACL,IAAI,EAAE,KAAK;KACZ,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,UAAU,CAAC,GAAG,EAAE,CAAA;AACzB,CAAC","sourcesContent":["import {isTruthy, isSet} from '../../../private/node/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;
|