@shopify/cli-kit 3.94.3 → 4.0.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/private/node/api/headers.js +1 -1
- package/dist/private/node/api/headers.js.map +1 -1
- package/dist/private/node/conf-store.d.ts +3 -2
- package/dist/private/node/conf-store.js +3 -2
- package/dist/private/node/conf-store.js.map +1 -1
- package/dist/private/node/constants.d.ts +2 -1
- package/dist/private/node/constants.js +2 -1
- package/dist/private/node/constants.js.map +1 -1
- package/dist/private/node/ui/components/Alert.test.js +29 -0
- package/dist/private/node/ui/components/Alert.test.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.d.ts +8 -1
- package/dist/private/node/ui/components/AutocompletePrompt.js +3 -2
- package/dist/private/node/ui/components/AutocompletePrompt.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.test.js +16 -0
- package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/FatalError.js +6 -1
- package/dist/private/node/ui/components/FatalError.js.map +1 -1
- package/dist/private/node/ui/components/FatalError.test.js +28 -0
- package/dist/private/node/ui/components/FatalError.test.js.map +1 -1
- package/dist/private/node/ui/components/Link.js +8 -4
- package/dist/private/node/ui/components/Link.js.map +1 -1
- package/dist/private/node/ui/components/Link.test.js +45 -0
- package/dist/private/node/ui/components/Link.test.js.map +1 -1
- package/dist/private/node/ui/components/TokenizedText.js +61 -2
- package/dist/private/node/ui/components/TokenizedText.js.map +1 -1
- package/dist/private/node/ui/components/TokenizedText.test.js +109 -2
- package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -1
- package/dist/public/common/string.js +15 -19
- package/dist/public/common/string.js.map +1 -1
- package/dist/public/common/version.d.ts +1 -1
- package/dist/public/common/version.js +1 -1
- package/dist/public/common/version.js.map +1 -1
- package/dist/public/node/base-command.js +23 -14
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/cli-launcher.d.ts +2 -0
- package/dist/public/node/cli-launcher.js +7 -3
- package/dist/public/node/cli-launcher.js.map +1 -1
- package/dist/public/node/cli.d.ts +5 -1
- package/dist/public/node/cli.js +3 -3
- package/dist/public/node/cli.js.map +1 -1
- package/dist/public/node/context/local.d.ts +8 -8
- package/dist/public/node/context/local.js +25 -15
- package/dist/public/node/context/local.js.map +1 -1
- package/dist/public/node/custom-oclif-loader.d.ts +31 -0
- package/dist/public/node/custom-oclif-loader.js +45 -0
- package/dist/public/node/custom-oclif-loader.js.map +1 -0
- package/dist/public/node/error.d.ts +1 -1
- package/dist/public/node/error.js +1 -1
- package/dist/public/node/error.js.map +1 -1
- package/dist/public/node/fs.js +12 -16
- package/dist/public/node/fs.js.map +1 -1
- package/dist/public/node/git.js +1 -2
- package/dist/public/node/git.js.map +1 -1
- package/dist/public/node/hooks/postrun.d.ts +15 -0
- package/dist/public/node/hooks/postrun.js +75 -14
- package/dist/public/node/hooks/postrun.js.map +1 -1
- package/dist/public/node/hooks/prerun.d.ts +1 -1
- package/dist/public/node/hooks/prerun.js +17 -10
- package/dist/public/node/hooks/prerun.js.map +1 -1
- package/dist/public/node/is-global.d.ts +1 -1
- package/dist/public/node/is-global.js +27 -11
- package/dist/public/node/is-global.js.map +1 -1
- package/dist/public/node/monorail.d.ts +2 -1
- package/dist/public/node/monorail.js +1 -1
- package/dist/public/node/monorail.js.map +1 -1
- package/dist/public/node/node-package-manager.d.ts +2 -2
- package/dist/public/node/node-package-manager.js +10 -10
- package/dist/public/node/node-package-manager.js.map +1 -1
- package/dist/public/node/notifications-system.d.ts +6 -6
- package/dist/public/node/output.js.map +1 -1
- package/dist/public/node/path.js +0 -2
- package/dist/public/node/path.js.map +1 -1
- package/dist/public/node/session.d.ts +6 -0
- package/dist/public/node/session.js +8 -0
- package/dist/public/node/session.js.map +1 -1
- package/dist/public/node/system.js +20 -3
- package/dist/public/node/system.js.map +1 -1
- package/dist/public/node/tree-kill.js +17 -5
- package/dist/public/node/tree-kill.js.map +1 -1
- package/dist/public/node/ui.js +6 -0
- package/dist/public/node/ui.js.map +1 -1
- package/dist/public/node/upgrade.d.ts +27 -8
- package/dist/public/node/upgrade.js +50 -21
- package/dist/public/node/upgrade.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { errorHandler, registerCleanBugsnagErrorsFromWithinPlugins } from './error-handler.js';
|
|
2
|
-
import { loadEnvironment, environmentFilePath } from './environments.js';
|
|
3
1
|
import { isDevelopment } from './context/local.js';
|
|
4
2
|
import { addPublicMetadata } from './metadata.js';
|
|
5
3
|
import { AbortError } from './error.js';
|
|
6
|
-
import { renderInfo, renderWarning } from './ui.js';
|
|
7
4
|
import { outputContent, outputResult, outputToken } from './output.js';
|
|
8
5
|
import { terminalSupportsPrompting } from './system.js';
|
|
9
6
|
import { hashString } from './crypto.js';
|
|
10
7
|
import { isTruthy } from './context/utilities.js';
|
|
11
|
-
import { showNotificationsIfNeeded } from './notifications-system.js';
|
|
12
8
|
import { setCurrentCommandId } from './global-context.js';
|
|
13
9
|
import { underscore } from '../common/string.js';
|
|
14
10
|
import { Command, Errors } from '@oclif/core';
|
|
@@ -26,6 +22,7 @@ class BaseCommand extends Command {
|
|
|
26
22
|
}
|
|
27
23
|
async catch(error) {
|
|
28
24
|
error.skipOclifErrorHandling = true;
|
|
25
|
+
const { errorHandler } = await import('./error-handler.js');
|
|
29
26
|
await errorHandler(error, this.config);
|
|
30
27
|
return Errors.handle(error);
|
|
31
28
|
}
|
|
@@ -34,10 +31,12 @@ class BaseCommand extends Command {
|
|
|
34
31
|
setCurrentCommandId(this.id ?? '');
|
|
35
32
|
if (!isDevelopment()) {
|
|
36
33
|
// This function runs just prior to `run`
|
|
34
|
+
const { registerCleanBugsnagErrorsFromWithinPlugins } = await import('./error-handler.js');
|
|
37
35
|
await registerCleanBugsnagErrorsFromWithinPlugins(this.config);
|
|
38
36
|
}
|
|
39
37
|
await removeDuplicatedPlugins(this.config);
|
|
40
38
|
this.showNpmFlagWarning();
|
|
39
|
+
const { showNotificationsIfNeeded } = await import('./notifications-system.js');
|
|
41
40
|
await showNotificationsIfNeeded();
|
|
42
41
|
return super.init();
|
|
43
42
|
}
|
|
@@ -49,13 +48,16 @@ class BaseCommand extends Command {
|
|
|
49
48
|
const commandFlags = Object.keys(commandVariables.flags || {});
|
|
50
49
|
const possibleNpmEnvVars = commandFlags.map((key) => `npm_config_${underscore(key).replace(/^no_/, '')}`);
|
|
51
50
|
if (possibleNpmEnvVars.some((flag) => process.env[flag] !== undefined)) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
// eslint-disable-next-line no-void
|
|
52
|
+
void import('./ui.js').then(({ renderWarning }) => {
|
|
53
|
+
renderWarning({
|
|
54
|
+
body: [
|
|
55
|
+
'NPM scripts require an extra',
|
|
56
|
+
{ command: '--' },
|
|
57
|
+
'separator to pass the flags. Example:',
|
|
58
|
+
{ command: 'npm run dev -- --reset' },
|
|
59
|
+
],
|
|
60
|
+
});
|
|
59
61
|
});
|
|
60
62
|
}
|
|
61
63
|
}
|
|
@@ -97,6 +99,7 @@ This flag is required in non-interactive terminal environments, such as a CI env
|
|
|
97
99
|
const environmentsFileName = this.environmentsFilename();
|
|
98
100
|
if (!environmentsFileName)
|
|
99
101
|
return originalResult;
|
|
102
|
+
const { environmentFilePath } = await import('./environments.js');
|
|
100
103
|
const environmentFileExists = await environmentFilePath(environmentsFileName, { from: flags.path });
|
|
101
104
|
// Handle both string and array cases for environment flag
|
|
102
105
|
let environments = [];
|
|
@@ -136,6 +139,7 @@ This flag is required in non-interactive terminal environments, such as a CI env
|
|
|
136
139
|
* is specified it will try to load a default environment.
|
|
137
140
|
*/
|
|
138
141
|
async loadEnvironmentForCommand(path, environmentsFileName, specifiedEnvironment) {
|
|
142
|
+
const { loadEnvironment } = await import('./environments.js');
|
|
139
143
|
if (specifiedEnvironment) {
|
|
140
144
|
const environment = await loadEnvironment(specifiedEnvironment, environmentsFileName, { from: path });
|
|
141
145
|
return { environment, isDefaultEnvironment: false };
|
|
@@ -177,9 +181,12 @@ function reportEnvironmentApplication(noDefaultsFlags, flagsWithEnvironments, en
|
|
|
177
181
|
if (Object.keys(changes).length === 0)
|
|
178
182
|
return;
|
|
179
183
|
const items = Object.entries(changes).map(([name, value]) => `${name}: ${value}`);
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
184
|
+
// eslint-disable-next-line no-void
|
|
185
|
+
void import('./ui.js').then(({ renderInfo }) => {
|
|
186
|
+
renderInfo({
|
|
187
|
+
headline: ['Using applicable flags from', { userInput: environmentName }, 'environment:'],
|
|
188
|
+
body: [{ list: { items } }],
|
|
189
|
+
});
|
|
183
190
|
});
|
|
184
191
|
}
|
|
185
192
|
/**
|
|
@@ -252,6 +259,7 @@ async function removeDuplicatedPlugins(config) {
|
|
|
252
259
|
const pluginsToRemove = plugins.filter((plugin) => bundlePlugins.includes(plugin.name));
|
|
253
260
|
if (pluginsToRemove.length > 0) {
|
|
254
261
|
const commandsToRun = pluginsToRemove.map((plugin) => ` - shopify plugins remove ${plugin.name}`).join('\n');
|
|
262
|
+
const { renderWarning } = await import('./ui.js');
|
|
255
263
|
renderWarning({
|
|
256
264
|
headline: `Unsupported plugins detected: ${pluginsToRemove.map((plugin) => plugin.name).join(', ')}`,
|
|
257
265
|
body: [
|
|
@@ -261,6 +269,7 @@ async function removeDuplicatedPlugins(config) {
|
|
|
261
269
|
});
|
|
262
270
|
}
|
|
263
271
|
const filteredPlugins = plugins.filter((plugin) => !bundlePlugins.includes(plugin.name));
|
|
272
|
+
// eslint-disable-next-line require-atomic-updates -- config.plugins won't be modified by renderWarning above
|
|
264
273
|
config.plugins = new Map(filteredPlugins.map((plugin) => [plugin.name, plugin]));
|
|
265
274
|
}
|
|
266
275
|
export default BaseCommand;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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AAa,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,8BAA8B,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC7G,aAAa,CAAC;YACZ,QAAQ,EAAE,iCAAiC,eAAe,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACpG,IAAI,EAAE;gBACJ,iGAAiG;gBACjG,+BAA+B,aAAa,EAAE;aAC/C;SACF,CAAC,CAAA;IACJ,CAAC;IACD,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;IACxF,MAAM,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;AAClF,CAAC;AAED,eAAe,WAAW,CAAA","sourcesContent":["import {errorHandler, registerCleanBugsnagErrorsFromWithinPlugins} from './error-handler.js'\nimport {loadEnvironment, environmentFilePath} from './environments.js'\nimport {isDevelopment} from './context/local.js'\nimport {addPublicMetadata} from './metadata.js'\nimport {AbortError} from './error.js'\nimport {renderInfo, renderWarning} from './ui.js'\nimport {outputContent, outputResult, outputToken} from './output.js'\nimport {terminalSupportsPrompting} from './system.js'\nimport {hashString} from './crypto.js'\nimport {isTruthy} from './context/utilities.js'\nimport {showNotificationsIfNeeded} from './notifications-system.js'\nimport {setCurrentCommandId} from './global-context.js'\nimport {JsonMap} from '../../private/common/json.js'\nimport {underscore} from '../common/string.js'\n\nimport {Command, Config, Errors} from '@oclif/core'\nimport {OutputFlags, Input, ParserOutput, FlagInput, OutputArgs} from '@oclif/core/parser'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ArgOutput = OutputArgs<any>\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type FlagOutput = OutputFlags<any>\n\ninterface EnvironmentFlags {\n environment?: string[]\n path?: string\n}\n\nabstract class BaseCommand extends Command {\n static baseFlags: FlagInput<{}> = {}\n\n // Replace markdown links to plain text like: \"link label\" (url)\n public static descriptionWithoutMarkdown(): string | undefined {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return ((this as any).descriptionWithMarkdown ?? '').replace(/(\\[)(.*?)(])(\\()(.*?)(\\))/gm, '\"$2\" ($5)')\n }\n\n public static analyticsNameOverride(): string | undefined {\n return undefined\n }\n\n public static analyticsStopCommand(): string | undefined {\n return undefined\n }\n\n async catch(error: Error & {skipOclifErrorHandling: boolean}): Promise<void> {\n error.skipOclifErrorHandling = true\n await errorHandler(error, this.config)\n return Errors.handle(error)\n }\n\n protected async init(): Promise<unknown> {\n this.exitWithTimestampWhenEnvVariablePresent()\n setCurrentCommandId(this.id ?? '')\n if (!isDevelopment()) {\n // This function runs just prior to `run`\n await registerCleanBugsnagErrorsFromWithinPlugins(this.config)\n }\n await removeDuplicatedPlugins(this.config)\n this.showNpmFlagWarning()\n await showNotificationsIfNeeded()\n return super.init()\n }\n\n // NPM creates an environment variable for every flag passed to a script.\n // This function checks for the presence of any of the available CLI flags\n // and warns the user to use the `--` separator.\n protected showNpmFlagWarning(): void {\n const commandVariables = this.constructor as unknown as {flags: JsonMap}\n const commandFlags = Object.keys(commandVariables.flags || {})\n const possibleNpmEnvVars = commandFlags.map((key) => `npm_config_${underscore(key).replace(/^no_/, '')}`)\n\n if (possibleNpmEnvVars.some((flag) => process.env[flag] !== undefined)) {\n renderWarning({\n body: [\n 'NPM scripts require an extra',\n {command: '--'},\n 'separator to pass the flags. Example:',\n {command: 'npm run dev -- --reset'},\n ],\n })\n }\n }\n\n protected exitWithTimestampWhenEnvVariablePresent() {\n if (isTruthy(process.env.SHOPIFY_CLI_ENV_STARTUP_PERFORMANCE_RUN)) {\n outputResult(`\n SHOPIFY_CLI_TIMESTAMP_START\n { \"timestamp\": ${Date.now()} }\n SHOPIFY_CLI_TIMESTAMP_END\n `)\n process.exit(0)\n }\n }\n\n protected async parse<\n TFlags extends FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(\n options?: Input<TFlags, TGlobalFlags, TArgs>,\n argv?: string[],\n ): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs> & {argv: string[]}> {\n let result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, argv)\n result = await this.resultWithEnvironment<TFlags, TGlobalFlags, TArgs>(result, options, argv)\n await addFromParsedFlags(result.flags)\n return {...result, ...{argv: result.argv as string[]}}\n }\n\n protected environmentsFilename(): string | undefined {\n // To be re-implemented if needed\n return undefined\n }\n\n protected failMissingNonTTYFlags(flags: FlagOutput, requiredFlags: string[]): void {\n if (terminalSupportsPrompting()) return\n\n requiredFlags.forEach((name: string) => {\n if (!(name in flags)) {\n throw new AbortError(\n outputContent`Flag not specified:\n\n${outputToken.cyan(name)}\n\nThis flag is required in non-interactive terminal environments, such as a CI environment, or when piping input from another process.`,\n 'To resolve this, specify the option in the command, or run the command in an interactive environment such as your local terminal.',\n )\n }\n })\n }\n\n private async resultWithEnvironment<\n TFlags extends FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(\n originalResult: ParserOutput<TFlags, TGlobalFlags, TArgs>,\n options?: Input<TFlags, TGlobalFlags, TArgs>,\n argv?: string[],\n ): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n const flags = originalResult.flags as EnvironmentFlags\n const environmentsFileName = this.environmentsFilename()\n\n if (!environmentsFileName) return originalResult\n\n const environmentFileExists = await environmentFilePath(environmentsFileName, {from: flags.path})\n\n // Handle both string and array cases for environment flag\n let environments: string[] = []\n if (flags.environment) {\n environments = Array.isArray(flags.environment) ? flags.environment : [flags.environment]\n }\n\n const environmentSpecified = environments.length > 0\n\n // Noop if no environment file exists and none was specified\n if (!environmentFileExists && !environmentSpecified) return originalResult\n\n // Noop if multiple environments were specified (let commands handle this)\n if (environmentSpecified && environments.length > 1) return originalResult\n\n const {environment, isDefaultEnvironment} = await this.loadEnvironmentForCommand(\n flags.path,\n environmentsFileName,\n environments[0],\n )\n\n if (!environment) return originalResult\n if (isDefaultEnvironment && !commandSupportsFlag(options?.flags, 'environment')) return originalResult\n\n // Parse using noDefaultsOptions to derive a list of flags specified as\n // command-line arguments.\n const noDefaultsResult = await super.parse<TFlags, TGlobalFlags, TArgs>(noDefaultsOptions(options), argv)\n\n // Add the environment's settings to argv and pass them to `super.parse`. This\n // invokes oclif's validation system without breaking the oclif black box.\n // Replace the original result with this one.\n const result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, [\n // Need to specify argv default because we're merging with argsFromEnvironment.\n ...(argv ?? this.argv),\n ...argsFromEnvironment<TFlags, TGlobalFlags, TArgs>(environment, options, noDefaultsResult),\n ...(isDefaultEnvironment ? ['--environment', 'default'] : []),\n ])\n\n // Report successful application of the environment.\n reportEnvironmentApplication<TFlags, TGlobalFlags, TArgs>(\n noDefaultsResult.flags,\n result.flags,\n isDefaultEnvironment ? 'default' : (environments[0] as string),\n environment,\n )\n\n return result\n }\n\n /**\n * Tries to load an environment to forward to the command. If no environment\n * is specified it will try to load a default environment.\n */\n private async loadEnvironmentForCommand(\n path: string | undefined,\n environmentsFileName: string,\n specifiedEnvironment: string | undefined,\n ): Promise<{environment: JsonMap | undefined; isDefaultEnvironment: boolean}> {\n if (specifiedEnvironment) {\n const environment = await loadEnvironment(specifiedEnvironment, environmentsFileName, {from: path})\n return {environment, isDefaultEnvironment: false}\n }\n\n const environment = await loadEnvironment('default', environmentsFileName, {from: path, silent: true})\n return {environment, isDefaultEnvironment: true}\n }\n}\n\nexport async function addFromParsedFlags(flags: {path?: string; verbose?: boolean}): Promise<void> {\n await addPublicMetadata(() => ({\n cmd_all_verbose: flags.verbose,\n cmd_all_path_override: flags.path !== undefined,\n cmd_all_path_override_hash: flags.path === undefined ? undefined : hashString(flags.path),\n }))\n}\n\n/**\n * Any flag which is:\n *\n * 1. Present in the final set of flags\n * 2. Specified in the environment\n * 3. Not specified by the user as a command line argument\n *\n * should be reported.\n *\n * It doesn't matter if the environment flag's value was the same as the default; from\n * the user's perspective, they want to know their environment was applied.\n */\nfunction reportEnvironmentApplication<\n TFlags extends FlagOutput,\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n>(\n noDefaultsFlags: ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n flagsWithEnvironments: ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n environmentName: string,\n environment: JsonMap,\n): void {\n const changes: JsonMap = {}\n for (const [name, value] of Object.entries(flagsWithEnvironments)) {\n const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(noDefaultsFlags, name)\n const environmentContainsFlag = Object.prototype.hasOwnProperty.call(environment, name)\n if (!userSpecifiedThisFlag && environmentContainsFlag) {\n const valueToReport = name === 'password' ? `********${value.substr(-4)}` : value\n changes[name] = valueToReport\n }\n }\n if (Object.keys(changes).length === 0) return\n\n const items = Object.entries(changes).map(([name, value]) => `${name}: ${value}`)\n renderInfo({\n headline: ['Using applicable flags from', {userInput: environmentName}, 'environment:'],\n body: [{list: {items}}],\n })\n}\n\n/**\n * Strips the defaults from configured flags. For example, if flags contains:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag',\n * default: false\n * })\n * ```\n *\n * it becomes:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag'\n * })\n * ```\n *\n * If we parse using this configuration, the only specified flags will be those\n * the user actually passed on the command line.\n */\nexport function noDefaultsOptions<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(\n options: Input<TFlags, TGlobalFlags, TArgs> | undefined,\n): Input<TFlags, TGlobalFlags, TArgs> | undefined {\n if (!options?.flags) return options\n return {\n ...options,\n flags: Object.fromEntries(\n Object.entries(options.flags).map(([label, settings]) => {\n const copiedSettings = {...(settings as {default?: unknown})}\n delete copiedSettings.default\n return [label, copiedSettings]\n }),\n ) as FlagInput<TFlags>,\n }\n}\n\n/**\n * Converts the environment's settings to arguments as though passed on the command\n * line, skipping any arguments the user specified on the command line.\n */\nfunction argsFromEnvironment<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(\n environment: JsonMap,\n options: Input<TFlags, TGlobalFlags, TArgs> | undefined,\n noDefaultsResult: ParserOutput<TFlags, TArgs>,\n): string[] {\n const args: string[] = []\n for (const [label, value] of Object.entries(environment)) {\n const flagIsRelevantToCommand = commandSupportsFlag(options?.flags, label)\n const userSpecifiedThisFlag =\n noDefaultsResult.flags && Object.prototype.hasOwnProperty.call(noDefaultsResult.flags, label)\n if (flagIsRelevantToCommand && !userSpecifiedThisFlag) {\n if (typeof value === 'boolean') {\n if (value) {\n args.push(`--${label}`)\n } else {\n throw new AbortError(\n outputContent`Environments can only specify true for boolean flags. Attempted to set ${outputToken.yellow(\n label,\n )} to false.`,\n )\n }\n } else if (Array.isArray(value)) {\n value.forEach((element) => args.push(`--${label}`, `${element}`))\n } else {\n args.push(`--${label}`, `${value}`)\n }\n }\n }\n return args\n}\n\nfunction commandSupportsFlag(flags: FlagInput | undefined, flagName: string): boolean {\n return Boolean(flags) && Object.prototype.hasOwnProperty.call(flags, flagName)\n}\n\nasync function removeDuplicatedPlugins(config: Config): Promise<void> {\n const plugins = Array.from(config.plugins.values())\n const bundlePlugins = ['@shopify/app', '@shopify/plugin-cloudflare']\n const pluginsToRemove = plugins.filter((plugin) => bundlePlugins.includes(plugin.name))\n if (pluginsToRemove.length > 0) {\n const commandsToRun = pluginsToRemove.map((plugin) => ` - shopify plugins remove ${plugin.name}`).join('\\n')\n renderWarning({\n headline: `Unsupported plugins detected: ${pluginsToRemove.map((plugin) => plugin.name).join(', ')}`,\n body: [\n 'They are already included in the CLI and installing them as custom plugins can cause conflicts.',\n `You can fix it by running:\\n${commandsToRun}`,\n ],\n })\n }\n const filteredPlugins = plugins.filter((plugin) => !bundlePlugins.includes(plugin.name))\n config.plugins = new Map(filteredPlugins.map((plugin) => [plugin.name, plugin]))\n}\n\nexport default BaseCommand\n"]}
|
|
1
|
+
{"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../../src/public/node/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,aAAa,EAAE,YAAY,EAAE,WAAW,EAAC,MAAM,aAAa,CAAA;AACpE,OAAO,EAAC,yBAAyB,EAAC,MAAM,aAAa,CAAA;AACrD,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,mBAAmB,EAAC,MAAM,qBAAqB,CAAA;AAEvD,OAAO,EAAC,UAAU,EAAC,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAC,OAAO,EAAU,MAAM,EAAC,MAAM,aAAa,CAAA;AAanD,MAAe,WAAY,SAAQ,OAAO;IAGxC,gEAAgE;IACzD,MAAM,CAAC,0BAA0B;QACtC,8DAA8D;QAC9D,OAAO,CAAE,IAAY,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,6BAA6B,EAAE,WAAW,CAAC,CAAA;IAC1G,CAAC;IAEM,MAAM,CAAC,qBAAqB;QACjC,OAAO,SAAS,CAAA;IAClB,CAAC;IAEM,MAAM,CAAC,oBAAoB;QAChC,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,KAAgD;QAC1D,KAAK,CAAC,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AI,CAAC,CAAC,CAAA;IACxF,6GAA6G;IAC7G,MAAM,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;AAClF,CAAC;AAED,eAAe,WAAW,CAAA","sourcesContent":["import {isDevelopment} from './context/local.js'\nimport {addPublicMetadata} from './metadata.js'\nimport {AbortError} from './error.js'\nimport {outputContent, outputResult, outputToken} from './output.js'\nimport {terminalSupportsPrompting} from './system.js'\nimport {hashString} from './crypto.js'\nimport {isTruthy} from './context/utilities.js'\nimport {setCurrentCommandId} from './global-context.js'\nimport {JsonMap} from '../../private/common/json.js'\nimport {underscore} from '../common/string.js'\nimport {Command, Config, Errors} from '@oclif/core'\nimport {OutputFlags, Input, ParserOutput, FlagInput, OutputArgs} from '@oclif/core/parser'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ArgOutput = OutputArgs<any>\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type FlagOutput = OutputFlags<any>\n\ninterface EnvironmentFlags {\n environment?: string[]\n path?: string\n}\n\nabstract class BaseCommand extends Command {\n static baseFlags: FlagInput<{}> = {}\n\n // Replace markdown links to plain text like: \"link label\" (url)\n public static descriptionWithoutMarkdown(): string | undefined {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return ((this as any).descriptionWithMarkdown ?? '').replace(/(\\[)(.*?)(])(\\()(.*?)(\\))/gm, '\"$2\" ($5)')\n }\n\n public static analyticsNameOverride(): string | undefined {\n return undefined\n }\n\n public static analyticsStopCommand(): string | undefined {\n return undefined\n }\n\n async catch(error: Error & {skipOclifErrorHandling: boolean}): Promise<void> {\n error.skipOclifErrorHandling = true\n const {errorHandler} = await import('./error-handler.js')\n await errorHandler(error, this.config)\n return Errors.handle(error)\n }\n\n protected async init(): Promise<unknown> {\n this.exitWithTimestampWhenEnvVariablePresent()\n setCurrentCommandId(this.id ?? '')\n if (!isDevelopment()) {\n // This function runs just prior to `run`\n const {registerCleanBugsnagErrorsFromWithinPlugins} = await import('./error-handler.js')\n await registerCleanBugsnagErrorsFromWithinPlugins(this.config)\n }\n await removeDuplicatedPlugins(this.config)\n this.showNpmFlagWarning()\n const {showNotificationsIfNeeded} = await import('./notifications-system.js')\n await showNotificationsIfNeeded()\n return super.init()\n }\n\n // NPM creates an environment variable for every flag passed to a script.\n // This function checks for the presence of any of the available CLI flags\n // and warns the user to use the `--` separator.\n protected showNpmFlagWarning(): void {\n const commandVariables = this.constructor as unknown as {flags: JsonMap}\n const commandFlags = Object.keys(commandVariables.flags || {})\n const possibleNpmEnvVars = commandFlags.map((key) => `npm_config_${underscore(key).replace(/^no_/, '')}`)\n\n if (possibleNpmEnvVars.some((flag) => process.env[flag] !== undefined)) {\n // eslint-disable-next-line no-void\n void import('./ui.js').then(({renderWarning}) => {\n renderWarning({\n body: [\n 'NPM scripts require an extra',\n {command: '--'},\n 'separator to pass the flags. Example:',\n {command: 'npm run dev -- --reset'},\n ],\n })\n })\n }\n }\n\n protected exitWithTimestampWhenEnvVariablePresent() {\n if (isTruthy(process.env.SHOPIFY_CLI_ENV_STARTUP_PERFORMANCE_RUN)) {\n outputResult(`\n SHOPIFY_CLI_TIMESTAMP_START\n { \"timestamp\": ${Date.now()} }\n SHOPIFY_CLI_TIMESTAMP_END\n `)\n process.exit(0)\n }\n }\n\n protected async parse<\n TFlags extends FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(\n options?: Input<TFlags, TGlobalFlags, TArgs>,\n argv?: string[],\n ): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs> & {argv: string[]}> {\n let result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, argv)\n result = await this.resultWithEnvironment<TFlags, TGlobalFlags, TArgs>(result, options, argv)\n await addFromParsedFlags(result.flags)\n return {...result, ...{argv: result.argv as string[]}}\n }\n\n protected environmentsFilename(): string | undefined {\n // To be re-implemented if needed\n return undefined\n }\n\n protected failMissingNonTTYFlags(flags: FlagOutput, requiredFlags: string[]): void {\n if (terminalSupportsPrompting()) return\n\n requiredFlags.forEach((name: string) => {\n if (!(name in flags)) {\n throw new AbortError(\n outputContent`Flag not specified:\n\n${outputToken.cyan(name)}\n\nThis flag is required in non-interactive terminal environments, such as a CI environment, or when piping input from another process.`,\n 'To resolve this, specify the option in the command, or run the command in an interactive environment such as your local terminal.',\n )\n }\n })\n }\n\n private async resultWithEnvironment<\n TFlags extends FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(\n originalResult: ParserOutput<TFlags, TGlobalFlags, TArgs>,\n options?: Input<TFlags, TGlobalFlags, TArgs>,\n argv?: string[],\n ): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n const flags = originalResult.flags as EnvironmentFlags\n const environmentsFileName = this.environmentsFilename()\n\n if (!environmentsFileName) return originalResult\n\n const {environmentFilePath} = await import('./environments.js')\n const environmentFileExists = await environmentFilePath(environmentsFileName, {from: flags.path})\n\n // Handle both string and array cases for environment flag\n let environments: string[] = []\n if (flags.environment) {\n environments = Array.isArray(flags.environment) ? flags.environment : [flags.environment]\n }\n\n const environmentSpecified = environments.length > 0\n\n // Noop if no environment file exists and none was specified\n if (!environmentFileExists && !environmentSpecified) return originalResult\n\n // Noop if multiple environments were specified (let commands handle this)\n if (environmentSpecified && environments.length > 1) return originalResult\n\n const {environment, isDefaultEnvironment} = await this.loadEnvironmentForCommand(\n flags.path,\n environmentsFileName,\n environments[0],\n )\n\n if (!environment) return originalResult\n if (isDefaultEnvironment && !commandSupportsFlag(options?.flags, 'environment')) return originalResult\n\n // Parse using noDefaultsOptions to derive a list of flags specified as\n // command-line arguments.\n const noDefaultsResult = await super.parse<TFlags, TGlobalFlags, TArgs>(noDefaultsOptions(options), argv)\n\n // Add the environment's settings to argv and pass them to `super.parse`. This\n // invokes oclif's validation system without breaking the oclif black box.\n // Replace the original result with this one.\n const result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, [\n // Need to specify argv default because we're merging with argsFromEnvironment.\n ...(argv ?? this.argv),\n ...argsFromEnvironment<TFlags, TGlobalFlags, TArgs>(environment, options, noDefaultsResult),\n ...(isDefaultEnvironment ? ['--environment', 'default'] : []),\n ])\n\n // Report successful application of the environment.\n reportEnvironmentApplication<TFlags, TGlobalFlags, TArgs>(\n noDefaultsResult.flags,\n result.flags,\n isDefaultEnvironment ? 'default' : (environments[0] as string),\n environment,\n )\n\n return result\n }\n\n /**\n * Tries to load an environment to forward to the command. If no environment\n * is specified it will try to load a default environment.\n */\n private async loadEnvironmentForCommand(\n path: string | undefined,\n environmentsFileName: string,\n specifiedEnvironment: string | undefined,\n ): Promise<{environment: JsonMap | undefined; isDefaultEnvironment: boolean}> {\n const {loadEnvironment} = await import('./environments.js')\n if (specifiedEnvironment) {\n const environment = await loadEnvironment(specifiedEnvironment, environmentsFileName, {from: path})\n return {environment, isDefaultEnvironment: false}\n }\n\n const environment = await loadEnvironment('default', environmentsFileName, {from: path, silent: true})\n return {environment, isDefaultEnvironment: true}\n }\n}\n\nexport async function addFromParsedFlags(flags: {path?: string; verbose?: boolean}): Promise<void> {\n await addPublicMetadata(() => ({\n cmd_all_verbose: flags.verbose,\n cmd_all_path_override: flags.path !== undefined,\n cmd_all_path_override_hash: flags.path === undefined ? undefined : hashString(flags.path),\n }))\n}\n\n/**\n * Any flag which is:\n *\n * 1. Present in the final set of flags\n * 2. Specified in the environment\n * 3. Not specified by the user as a command line argument\n *\n * should be reported.\n *\n * It doesn't matter if the environment flag's value was the same as the default; from\n * the user's perspective, they want to know their environment was applied.\n */\nfunction reportEnvironmentApplication<\n TFlags extends FlagOutput,\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n>(\n noDefaultsFlags: ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n flagsWithEnvironments: ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n environmentName: string,\n environment: JsonMap,\n): void {\n const changes: JsonMap = {}\n for (const [name, value] of Object.entries(flagsWithEnvironments)) {\n const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(noDefaultsFlags, name)\n const environmentContainsFlag = Object.prototype.hasOwnProperty.call(environment, name)\n if (!userSpecifiedThisFlag && environmentContainsFlag) {\n const valueToReport = name === 'password' ? `********${value.substr(-4)}` : value\n changes[name] = valueToReport\n }\n }\n if (Object.keys(changes).length === 0) return\n\n const items = Object.entries(changes).map(([name, value]) => `${name}: ${value}`)\n // eslint-disable-next-line no-void\n void import('./ui.js').then(({renderInfo}) => {\n renderInfo({\n headline: ['Using applicable flags from', {userInput: environmentName}, 'environment:'],\n body: [{list: {items}}],\n })\n })\n}\n\n/**\n * Strips the defaults from configured flags. For example, if flags contains:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag',\n * default: false\n * })\n * ```\n *\n * it becomes:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag'\n * })\n * ```\n *\n * If we parse using this configuration, the only specified flags will be those\n * the user actually passed on the command line.\n */\nexport function noDefaultsOptions<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(\n options: Input<TFlags, TGlobalFlags, TArgs> | undefined,\n): Input<TFlags, TGlobalFlags, TArgs> | undefined {\n if (!options?.flags) return options\n return {\n ...options,\n flags: Object.fromEntries(\n Object.entries(options.flags).map(([label, settings]) => {\n const copiedSettings = {...(settings as {default?: unknown})}\n delete copiedSettings.default\n return [label, copiedSettings]\n }),\n ) as FlagInput<TFlags>,\n }\n}\n\n/**\n * Converts the environment's settings to arguments as though passed on the command\n * line, skipping any arguments the user specified on the command line.\n */\nfunction argsFromEnvironment<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(\n environment: JsonMap,\n options: Input<TFlags, TGlobalFlags, TArgs> | undefined,\n noDefaultsResult: ParserOutput<TFlags, TArgs>,\n): string[] {\n const args: string[] = []\n for (const [label, value] of Object.entries(environment)) {\n const flagIsRelevantToCommand = commandSupportsFlag(options?.flags, label)\n const userSpecifiedThisFlag =\n noDefaultsResult.flags && Object.prototype.hasOwnProperty.call(noDefaultsResult.flags, label)\n if (flagIsRelevantToCommand && !userSpecifiedThisFlag) {\n if (typeof value === 'boolean') {\n if (value) {\n args.push(`--${label}`)\n } else {\n throw new AbortError(\n outputContent`Environments can only specify true for boolean flags. Attempted to set ${outputToken.yellow(\n label,\n )} to false.`,\n )\n }\n } else if (Array.isArray(value)) {\n value.forEach((element) => args.push(`--${label}`, `${element}`))\n } else {\n args.push(`--${label}`, `${value}`)\n }\n }\n }\n return args\n}\n\nfunction commandSupportsFlag(flags: FlagInput | undefined, flagName: string): boolean {\n return Boolean(flags) && Object.prototype.hasOwnProperty.call(flags, flagName)\n}\n\nasync function removeDuplicatedPlugins(config: Config): Promise<void> {\n const plugins = Array.from(config.plugins.values())\n const bundlePlugins = ['@shopify/app', '@shopify/plugin-cloudflare']\n const pluginsToRemove = plugins.filter((plugin) => bundlePlugins.includes(plugin.name))\n if (pluginsToRemove.length > 0) {\n const commandsToRun = pluginsToRemove.map((plugin) => ` - shopify plugins remove ${plugin.name}`).join('\\n')\n const {renderWarning} = await import('./ui.js')\n renderWarning({\n headline: `Unsupported plugins detected: ${pluginsToRemove.map((plugin) => plugin.name).join(', ')}`,\n body: [\n 'They are already included in the CLI and installing them as custom plugins can cause conflicts.',\n `You can fix it by running:\\n${commandsToRun}`,\n ],\n })\n }\n const filteredPlugins = plugins.filter((plugin) => !bundlePlugins.includes(plugin.name))\n // eslint-disable-next-line require-atomic-updates -- config.plugins won't be modified by renderWarning above\n config.plugins = new Map(filteredPlugins.map((plugin) => [plugin.name, plugin]))\n}\n\nexport default BaseCommand\n"]}
|
|
@@ -6,22 +6,26 @@ import { fileURLToPath } from 'node:url';
|
|
|
6
6
|
* @returns A promise that resolves when the CLI has been launched.
|
|
7
7
|
*/
|
|
8
8
|
export async function launchCLI(options) {
|
|
9
|
-
const { errorHandler } = await import('./error-handler.js');
|
|
10
9
|
const { isDevelopment } = await import('./context/local.js');
|
|
10
|
+
const { ShopifyConfig } = await import('./custom-oclif-loader.js');
|
|
11
11
|
const oclifModule = await import('@oclif/core');
|
|
12
12
|
// esbuild wraps CJS dynamic imports under .default when bundling as ESM with code splitting
|
|
13
|
-
const {
|
|
13
|
+
const { run, flush, Errors, settings } = oclifModule.default ?? oclifModule;
|
|
14
14
|
if (isDevelopment()) {
|
|
15
15
|
settings.debug = true;
|
|
16
16
|
}
|
|
17
17
|
try {
|
|
18
|
-
const config = new
|
|
18
|
+
const config = new ShopifyConfig({ root: fileURLToPath(options.moduleURL) });
|
|
19
19
|
await config.load();
|
|
20
|
+
if (options.lazyCommandLoader) {
|
|
21
|
+
config.setLazyCommandLoader(options.lazyCommandLoader);
|
|
22
|
+
}
|
|
20
23
|
await run(options.argv, config);
|
|
21
24
|
await flush();
|
|
22
25
|
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
23
26
|
}
|
|
24
27
|
catch (error) {
|
|
28
|
+
const { errorHandler } = await import('./error-handler.js');
|
|
25
29
|
await errorHandler(error);
|
|
26
30
|
return Errors.handle(error);
|
|
27
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-launcher.js","sourceRoot":"","sources":["../../../src/public/node/cli-launcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"cli-launcher.js","sourceRoot":"","sources":["../../../src/public/node/cli-launcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAA;AAStC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAgB;IAC9C,MAAM,EAAC,aAAa,EAAC,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC1D,MAAM,EAAC,aAAa,EAAC,GAAG,MAAM,MAAM,CAAC,0BAA0B,CAAC,CAAA;IAEhE,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAA;IAC/C,4FAA4F;IAC5F,MAAM,EAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAC,GACjC,WAAiD,CAAC,OAAO,IAAI,WAAW,CAAA;IAE3E,IAAI,aAAa,EAAE,EAAE,CAAC;QACpB,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAA;IACvB,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,EAAC,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,EAAC,CAAC,CAAA;QAC1E,MAAM,MAAM,CAAC,IAAI,EAAE,CAAA;QAEnB,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAC9B,MAAM,CAAC,oBAAoB,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;QACxD,CAAC;QAED,MAAM,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QAC/B,MAAM,KAAK,EAAE,CAAA;QACb,qDAAqD;IACvD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,EAAC,YAAY,EAAC,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAA;QACzD,MAAM,YAAY,CAAC,KAAc,CAAC,CAAA;QAClC,OAAO,MAAM,CAAC,MAAM,CAAC,KAAc,CAAC,CAAA;IACtC,CAAC;AACH,CAAC","sourcesContent":["import {fileURLToPath} from 'node:url'\nimport type {LazyCommandLoader} from './custom-oclif-loader.js'\n\ninterface Options {\n moduleURL: string\n argv?: string[]\n lazyCommandLoader?: LazyCommandLoader\n}\n\n/**\n * Launches the CLI.\n *\n * @param options - Options.\n * @returns A promise that resolves when the CLI has been launched.\n */\nexport async function launchCLI(options: Options): Promise<void> {\n const {isDevelopment} = await import('./context/local.js')\n const {ShopifyConfig} = await import('./custom-oclif-loader.js')\n type OclifCore = typeof import('@oclif/core')\n const oclifModule = await import('@oclif/core')\n // esbuild wraps CJS dynamic imports under .default when bundling as ESM with code splitting\n const {run, flush, Errors, settings}: OclifCore =\n (oclifModule as OclifCore & {default?: OclifCore}).default ?? oclifModule\n\n if (isDevelopment()) {\n settings.debug = true\n }\n\n try {\n const config = new ShopifyConfig({root: fileURLToPath(options.moduleURL)})\n await config.load()\n\n if (options.lazyCommandLoader) {\n config.setLazyCommandLoader(options.lazyCommandLoader)\n }\n\n await run(options.argv, config)\n await flush()\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n const {errorHandler} = await import('./error-handler.js')\n await errorHandler(error as Error)\n return Errors.handle(error as Error)\n }\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LazyCommandLoader } from './custom-oclif-loader.js';
|
|
1
2
|
/**
|
|
2
3
|
* IMPORTANT NOTE: Imports in this module are dynamic to ensure that "setupEnvironmentVariables" can dynamically
|
|
3
4
|
* set the DEBUG environment variable before the 'debug' package sets up its configuration when modules
|
|
@@ -7,6 +8,8 @@ interface RunCLIOptions {
|
|
|
7
8
|
/** The value of import.meta.url of the CLI executable module */
|
|
8
9
|
moduleURL: string;
|
|
9
10
|
development: boolean;
|
|
11
|
+
/** Optional lazy command loader for on-demand command loading */
|
|
12
|
+
lazyCommandLoader?: LazyCommandLoader;
|
|
10
13
|
}
|
|
11
14
|
/**
|
|
12
15
|
* A function that abstracts away setting up the environment and running
|
|
@@ -17,6 +20,7 @@ export declare function runCLI(options: RunCLIOptions & {
|
|
|
17
20
|
runInCreateMode?: boolean;
|
|
18
21
|
}, launchCLI?: (options: {
|
|
19
22
|
moduleURL: string;
|
|
23
|
+
lazyCommandLoader?: LazyCommandLoader;
|
|
20
24
|
}) => Promise<void>, argv?: string[], env?: NodeJS.ProcessEnv, versions?: NodeJS.ProcessVersions): Promise<void>;
|
|
21
25
|
/**
|
|
22
26
|
* A function for create-x CLIs that automatically runs the "init" command.
|
|
@@ -38,5 +42,5 @@ export declare const jsonFlag: {
|
|
|
38
42
|
/**
|
|
39
43
|
* Clear the CLI cache, used to store some API responses and handle notifications status
|
|
40
44
|
*/
|
|
41
|
-
export declare function clearCache(): void
|
|
45
|
+
export declare function clearCache(): Promise<void>;
|
|
42
46
|
export {};
|
package/dist/public/node/cli.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isTruthy } from './context/utilities.js';
|
|
2
2
|
import { launchCLI as defaultLaunchCli } from './cli-launcher.js';
|
|
3
|
-
import { cacheClear } from '../../private/node/conf-store.js';
|
|
4
3
|
import { environmentVariables } from '../../private/node/constants.js';
|
|
5
4
|
import { Flags } from '@oclif/core';
|
|
6
5
|
async function exitIfOldNodeVersion(versions = process.versions) {
|
|
@@ -62,7 +61,7 @@ export async function runCLI(options, launchCLI = defaultLaunchCli, argv = proce
|
|
|
62
61
|
}
|
|
63
62
|
forceNoColor(argv, env);
|
|
64
63
|
await exitIfOldNodeVersion(versions);
|
|
65
|
-
return launchCLI({ moduleURL: options.moduleURL });
|
|
64
|
+
return launchCLI({ moduleURL: options.moduleURL, lazyCommandLoader: options.lazyCommandLoader });
|
|
66
65
|
}
|
|
67
66
|
async function addInitToArgvWhenRunningCreateCLI(options, argv = process.argv) {
|
|
68
67
|
const { findUpAndReadPackageJson } = await import('./node-package-manager.js');
|
|
@@ -111,7 +110,8 @@ export const jsonFlag = {
|
|
|
111
110
|
/**
|
|
112
111
|
* Clear the CLI cache, used to store some API responses and handle notifications status
|
|
113
112
|
*/
|
|
114
|
-
export function clearCache() {
|
|
113
|
+
export async function clearCache() {
|
|
114
|
+
const { cacheClear } = await import('../../private/node/conf-store.js');
|
|
115
115
|
cacheClear();
|
|
116
116
|
}
|
|
117
117
|
//# sourceMappingURL=cli.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src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ACpC,WAAmC,OAAO,CAAC,QAAQ;IAEnD,OAAO,MAAM,CAAC,EAAC,GAAG,OAAO,EAAE,eAAe,EAAE,IAAI,EAAC,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAA;AACpF,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC;QACxB,MAAM,EAAE,KAAK;QACb,WAAW,EAAE,uBAAuB;QACpC,GAAG,EAAE,uBAAuB;KAC7B,CAAC;IACF,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;QACrB,MAAM,EAAE,KAAK;QACb,WAAW,EAAE,uCAAuC;QACpD,GAAG,EAAE,sBAAsB;KAC5B,CAAC;CACH,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC;QAClB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,iEAAiE;QAC9E,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,KAAK;QACd,GAAG,EAAE,oBAAoB,CAAC,IAAI;KAC/B,CAAC;CACH,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,EAAC,UAAU,EAAC,GAAG,MAAM,MAAM,CAAC,kCAAkC,CAAC,CAAA;IACrE,UAAU,EAAE,CAAA;AACd,CAAC","sourcesContent":["import {isTruthy} from './context/utilities.js'\nimport {launchCLI as defaultLaunchCli} from './cli-launcher.js'\nimport {environmentVariables} from '../../private/node/constants.js'\nimport {Flags} from '@oclif/core'\nimport type {LazyCommandLoader} from './custom-oclif-loader.js'\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 /** Optional lazy command loader for on-demand command loading */\n lazyCommandLoader?: LazyCommandLoader\n}\n\nasync function exitIfOldNodeVersion(versions: NodeJS.ProcessVersions = process.versions) {\n const nodeVersion = versions.node\n const nodeMajorVersion = Number(nodeVersion.split('.')[0])\n\n const currentSupportedNodeVersion = 18\n if (nodeMajorVersion < currentSupportedNodeVersion) {\n const {renderError} = await import('./ui.js')\n renderError({\n headline: 'Upgrade to a supported Node version now.',\n body: [\n `Node ${nodeMajorVersion} has reached end-of-life and poses security risks. When you upgrade to a`,\n {\n link: {\n url: 'https://nodejs.dev/en/about/previous-releases',\n label: 'supported version',\n },\n },\n {char: ','},\n \"you'll be able to use Shopify CLI without interruption.\",\n ],\n })\n process.exit(1)\n }\n}\n\nfunction setupEnvironmentVariables(\n options: Pick<RunCLIOptions, 'development'>,\n argv: string[] = process.argv,\n env: NodeJS.ProcessEnv = process.env,\n) {\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 (argv.includes('--verbose')) {\n env.DEBUG = env.DEBUG ?? '*'\n }\n if (options.development) {\n env.SHOPIFY_CLI_ENV = env.SHOPIFY_CLI_ENV ?? 'development'\n }\n}\n\nfunction forceNoColor(argv: string[] = process.argv, env: NodeJS.ProcessEnv = process.env) {\n if (\n argv.includes('--no-color') ||\n argv.includes('--json') ||\n argv.includes('-j') ||\n isTruthy(env.NO_COLOR) ||\n isTruthy(env.SHOPIFY_FLAG_NO_COLOR) ||\n isTruthy(env[environmentVariables.json]) ||\n env.TERM === 'dumb'\n ) {\n env.FORCE_COLOR = '0'\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(\n options: RunCLIOptions & {runInCreateMode?: boolean},\n launchCLI: (options: {moduleURL: string; lazyCommandLoader?: LazyCommandLoader}) => Promise<void> = defaultLaunchCli,\n argv: string[] = process.argv,\n env: NodeJS.ProcessEnv = process.env,\n versions: NodeJS.ProcessVersions = process.versions,\n): Promise<void> {\n setupEnvironmentVariables(options, argv, env)\n if (options.runInCreateMode) {\n await addInitToArgvWhenRunningCreateCLI(options, argv)\n }\n forceNoColor(argv, env)\n await exitIfOldNodeVersion(versions)\n return launchCLI({moduleURL: options.moduleURL, lazyCommandLoader: options.lazyCommandLoader})\n}\n\nasync function addInitToArgvWhenRunningCreateCLI(\n options: Pick<RunCLIOptions, 'moduleURL'>,\n argv: string[] = process.argv,\n): Promise<void> {\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 = argv.findIndex((arg) => arg.includes('init'))\n if (initIndex === -1) {\n const initIndex = argv.findIndex((arg) => arg.match(new RegExp(`bin(\\\\/|\\\\\\\\)+(create-${name}|dev|run)`))) + 1\n argv.splice(initIndex, 0, 'init')\n }\n}\n\n/**\n * A function for create-x CLIs that automatically runs the \"init\" command.\n */\nexport async function runCreateCLI(\n options: RunCLIOptions,\n launchCLI: (options: {moduleURL: string}) => Promise<void> = defaultLaunchCli,\n argv: string[] = process.argv,\n env: NodeJS.ProcessEnv = process.env,\n versions: NodeJS.ProcessVersions = process.versions,\n): Promise<void> {\n return runCLI({...options, runInCreateMode: true}, launchCLI, argv, env, versions)\n}\n\n/**\n * An object that contains the flags that\n * are shared across all the commands.\n */\nexport const globalFlags = {\n 'no-color': Flags.boolean({\n hidden: false,\n description: 'Disable color output.',\n env: 'SHOPIFY_FLAG_NO_COLOR',\n }),\n verbose: Flags.boolean({\n hidden: false,\n description: 'Increase the verbosity of the output.',\n env: 'SHOPIFY_FLAG_VERBOSE',\n }),\n}\n\nexport const jsonFlag = {\n json: Flags.boolean({\n char: 'j',\n description: 'Output the result as JSON. Automatically disables color output.',\n hidden: false,\n default: false,\n env: environmentVariables.json,\n }),\n}\n\n/**\n * Clear the CLI cache, used to store some API responses and handle notifications status\n */\nexport async function clearCache(): Promise<void> {\n const {cacheClear} = await import('../../private/node/conf-store.js')\n cacheClear()\n}\n"]}
|
|
@@ -25,13 +25,6 @@ export declare function isDevelopment(env?: NodeJS.ProcessEnv): boolean;
|
|
|
25
25
|
* @returns True if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed.
|
|
26
26
|
*/
|
|
27
27
|
export declare function isVerbose(env?: NodeJS.ProcessEnv): boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Returns true if the hosted apps mode is enabled.
|
|
30
|
-
*
|
|
31
|
-
* @param env - The environment variables from the environment of the current process.
|
|
32
|
-
* @returns True if HOSTED_APPS is truthy.
|
|
33
|
-
*/
|
|
34
|
-
export declare function isHostedAppsMode(env?: NodeJS.ProcessEnv): boolean;
|
|
35
28
|
/**
|
|
36
29
|
* Returns true if the environment in which the CLI is running is either
|
|
37
30
|
* a local environment (where dev is present).
|
|
@@ -49,11 +42,18 @@ export declare function isShopify(env?: NodeJS.ProcessEnv): Promise<boolean>;
|
|
|
49
42
|
* @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.
|
|
50
43
|
*/
|
|
51
44
|
export declare function isUnitTest(env?: NodeJS.ProcessEnv): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Returns true if the CLI is running in hosted apps mode.
|
|
47
|
+
*
|
|
48
|
+
* @param env - The environment variables from the environment of the current process.
|
|
49
|
+
* @returns True if the HOSTED_APPS environment variable is truthy.
|
|
50
|
+
*/
|
|
51
|
+
export declare function isHostedAppsMode(env?: NodeJS.ProcessEnv): boolean;
|
|
52
52
|
/**
|
|
53
53
|
* Returns true if reporting analytics is enabled.
|
|
54
54
|
*
|
|
55
55
|
* @param env - The environment variables from the environment of the current process.
|
|
56
|
-
* @returns True unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.
|
|
56
|
+
* @returns True unless SHOPIFY_CLI_NO_ANALYTICS or OPT_OUT_INSTRUMENTATION is truthy, or debug mode is enabled.
|
|
57
57
|
*/
|
|
58
58
|
export declare function analyticsDisabled(env?: NodeJS.ProcessEnv): boolean;
|
|
59
59
|
/**
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { isTruthy } from './utilities.js';
|
|
2
2
|
import { getCIMetadata, isSet } from '../../../private/node/context/utilities.js';
|
|
3
3
|
import { defaultThemeKitAccessDomain, environmentVariables, pathConstants } from '../../../private/node/constants.js';
|
|
4
|
-
import { fileExists } from '../fs.js';
|
|
5
|
-
import { exec } from '../system.js';
|
|
6
4
|
import macaddress from 'macaddress';
|
|
7
5
|
import { homedir } from 'os';
|
|
6
|
+
// Dynamic imports to avoid circular dependency: context/local → fs → output → context/local
|
|
7
|
+
// fileExists and exec are only used in specific async functions, not at module init.
|
|
8
|
+
async function lazyFileExists(path) {
|
|
9
|
+
const { fileExists } = await import('../fs.js');
|
|
10
|
+
return fileExists(path);
|
|
11
|
+
}
|
|
12
|
+
async function lazyExec(command, args) {
|
|
13
|
+
const { exec } = await import('../system.js');
|
|
14
|
+
await exec(command, args);
|
|
15
|
+
}
|
|
8
16
|
/**
|
|
9
17
|
* It returns true if the terminal is interactive.
|
|
10
18
|
*
|
|
@@ -39,15 +47,6 @@ export function isDevelopment(env = process.env) {
|
|
|
39
47
|
export function isVerbose(env = process.env) {
|
|
40
48
|
return isTruthy(env[environmentVariables.verbose]) || process.argv.includes('--verbose');
|
|
41
49
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Returns true if the hosted apps mode is enabled.
|
|
44
|
-
*
|
|
45
|
-
* @param env - The environment variables from the environment of the current process.
|
|
46
|
-
* @returns True if HOSTED_APPS is truthy.
|
|
47
|
-
*/
|
|
48
|
-
export function isHostedAppsMode(env = process.env) {
|
|
49
|
-
return isTruthy(env[environmentVariables.hostedApps]);
|
|
50
|
-
}
|
|
51
50
|
/**
|
|
52
51
|
* Returns true if the environment in which the CLI is running is either
|
|
53
52
|
* a local environment (where dev is present).
|
|
@@ -59,7 +58,7 @@ export async function isShopify(env = process.env) {
|
|
|
59
58
|
if (Object.prototype.hasOwnProperty.call(env, environmentVariables.runAsUser)) {
|
|
60
59
|
return !isTruthy(env[environmentVariables.runAsUser]);
|
|
61
60
|
}
|
|
62
|
-
const devInstalled = await
|
|
61
|
+
const devInstalled = await lazyFileExists(pathConstants.executables.dev);
|
|
63
62
|
return devInstalled;
|
|
64
63
|
}
|
|
65
64
|
/**
|
|
@@ -73,14 +72,25 @@ export async function isShopify(env = process.env) {
|
|
|
73
72
|
export function isUnitTest(env = process.env) {
|
|
74
73
|
return isTruthy(env[environmentVariables.unitTest]);
|
|
75
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Returns true if the CLI is running in hosted apps mode.
|
|
77
|
+
*
|
|
78
|
+
* @param env - The environment variables from the environment of the current process.
|
|
79
|
+
* @returns True if the HOSTED_APPS environment variable is truthy.
|
|
80
|
+
*/
|
|
81
|
+
export function isHostedAppsMode(env = process.env) {
|
|
82
|
+
return isTruthy(env[environmentVariables.hostedApps]);
|
|
83
|
+
}
|
|
76
84
|
/**
|
|
77
85
|
* Returns true if reporting analytics is enabled.
|
|
78
86
|
*
|
|
79
87
|
* @param env - The environment variables from the environment of the current process.
|
|
80
|
-
* @returns True unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.
|
|
88
|
+
* @returns True unless SHOPIFY_CLI_NO_ANALYTICS or OPT_OUT_INSTRUMENTATION is truthy, or debug mode is enabled.
|
|
81
89
|
*/
|
|
82
90
|
export function analyticsDisabled(env = process.env) {
|
|
83
|
-
return isTruthy(env[environmentVariables.noAnalytics]) ||
|
|
91
|
+
return (isTruthy(env[environmentVariables.noAnalytics]) ||
|
|
92
|
+
isTruthy(env[environmentVariables.optOutInstrumentation]) ||
|
|
93
|
+
isDevelopment(env));
|
|
84
94
|
}
|
|
85
95
|
/**
|
|
86
96
|
* Returns true if reporting analytics should always happen, regardless of DEBUG mode etc.
|
|
@@ -192,7 +202,7 @@ export function cloudEnvironment(env = process.env) {
|
|
|
192
202
|
*/
|
|
193
203
|
export async function hasGit() {
|
|
194
204
|
try {
|
|
195
|
-
await
|
|
205
|
+
await lazyExec('git', ['--version']);
|
|
196
206
|
return true;
|
|
197
207
|
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
198
208
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../src/public/node/context/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAC,aAAa,EAAE,KAAK,EAAW,MAAM,4CAA4C,CAAA;AACzF,OAAO,EAAC,2BAA2B,EAAE,oBAAoB,EAAE,aAAa,EAAC,MAAM,oCAAoC,CAAA;AACnH,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAA;AACnC,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AAEjC,OAAO,UAAU,MAAM,YAAY,CAAA;AAEnC,OAAO,EAAC,OAAO,EAAC,MAAM,IAAI,CAAA;AAE1B;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;AAC/F,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,oBAAoB,CAAC,GAAG,CAAC,KAAK,aAAa,CAAA;AACxD,CAAC;AAED;;;;;GAKG;AACH,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GAAG,OAAO,CAAC,GAAG;IACnD,MAAM,MAAM,GAAG,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;IAEhD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,iDAAiD,CAAA;AACnF,CAAC","sourcesContent":["import {isTruthy} from './utilities.js'\nimport {getCIMetadata, isSet, Metadata} from '../../../private/node/context/utilities.js'\nimport {defaultThemeKitAccessDomain, environmentVariables, pathConstants} from '../../../private/node/constants.js'\nimport {fileExists} from '../fs.js'\nimport {exec} from '../system.js'\n\nimport macaddress from 'macaddress'\n\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 Boolean(process.stdout.isTTY && process.env.TERM !== 'dumb' && !('CI' in process.env))\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[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[environmentVariables.verbose]) || process.argv.includes('--verbose')\n}\n\n/**\n * Returns true if the hosted apps mode is enabled.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if HOSTED_APPS is truthy.\n */\nexport function isHostedAppsMode(env = process.env): boolean {\n return isTruthy(env[environmentVariables.hostedApps])\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).\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, environmentVariables.runAsUser)) {\n return !isTruthy(env[environmentVariables.runAsUser])\n }\n const devInstalled = await fileExists(pathConstants.executables.dev)\n return devInstalled\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[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[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[environmentVariables.alwaysLogAnalytics])\n}\n\n/**\n * Returns true if reporting metrics 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_METRICS is truthy.\n */\nexport function alwaysLogMetrics(env = process.env): boolean {\n return isTruthy(env[environmentVariables.alwaysLogMetrics])\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[environmentVariables.firstPartyDev])\n}\n\n/**\n * Returns true if the CLI can run the \"doctor-release\" command.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the CLI can run the \"doctor-release\" command.\n */\nexport function canRunDoctorRelease(env = process.env): boolean {\n return isTruthy(env[environmentVariables.doctor])\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[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[environmentVariables.codespaceName]\n}\n\n/**\n * Return codespacePortForwardingDomain 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 port forwarding domain.\n */\nexport function codespacePortForwardingDomain(env = process.env): string | undefined {\n return env[environmentVariables.codespacePortForwardingDomain]\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 * The token used to run a theme command with a custom password.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns A string with the token.\n */\nexport function themeToken(env = process.env): string | undefined {\n return env[environmentVariables.themeToken]\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: 'codespaces' | 'gitpod' | 'cloudShell' | 'localhost'\n editor: boolean\n} {\n if (isSet(env[environmentVariables.codespaces])) {\n return {platform: 'codespaces', editor: true}\n }\n if (isSet(env[environmentVariables.gitpod])) {\n return {platform: 'gitpod', editor: true}\n }\n if (isSet(env[environmentVariables.cloudShell])) {\n return {platform: 'cloudShell', editor: true}\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(\n env = process.env,\n): {isCI: true; name: string; metadata: Metadata} | {isCI: false; name?: undefined; metadata?: undefined} {\n if (isTruthy(env.CI)) {\n let name = 'unknown'\n if (isSet(env.BITBUCKET_BUILD_NUMBER)) {\n name = 'bitbucket'\n } else 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 } else if (isSet(env.BUILDKITE)) {\n name = 'buildkite'\n }\n\n return {\n isCI: true,\n name,\n metadata: getCIMetadata(name, env),\n }\n } else if (isTruthy(env.TF_BUILD)) {\n return {\n isCI: true,\n name: 'azure',\n metadata: getCIMetadata('azure', env),\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\n/**\n * Get the domain for theme kit access.\n *\n * It can be overridden via the SHOPIFY_CLI_THEME_KIT_ACCESS_DOMAIN environment\n * variable.\n *\n * @param env - The environment variables from the environment of the process.\n *\n * @returns The domain for theme kit access.\n */\nexport function getThemeKitAccessDomain(env = process.env): string {\n const domain = env[environmentVariables.themeKitAccessDomain]\n\n return isSet(domain) ? domain : defaultThemeKitAccessDomain\n}\n\n/**\n * Get the domain to send OTEL metrics to.\n *\n * It can be overridden via the SHOPIFY_CLI_OTEL_EXPORTER_OTLP_ENDPOINT environment variable.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The domain to send OTEL metrics to.\n */\nexport function opentelemetryDomain(env = process.env): string {\n const domain = env[environmentVariables.otelURL]\n\n return isSet(domain) ? domain : 'https://otlp-http-production-cli.shopifysvc.com'\n}\n\nexport type CIMetadata = Metadata\n"]}
|
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../src/public/node/context/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAC,aAAa,EAAE,KAAK,EAAW,MAAM,4CAA4C,CAAA;AACzF,OAAO,EAAC,2BAA2B,EAAE,oBAAoB,EAAE,aAAa,EAAC,MAAM,oCAAoC,CAAA;AACnH,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,EAAC,OAAO,EAAC,MAAM,IAAI,CAAA;AAE1B,4FAA4F;AAC5F,qFAAqF;AACrF,KAAK,UAAU,cAAc,CAAC,IAAY;IACxC,MAAM,EAAC,UAAU,EAAC,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAA;IAC7C,OAAO,UAAU,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC;AAED,KAAK,UAAU,QAAQ,CAAC,OAAe,EAAE,IAAc;IACrD,MAAM,EAAC,IAAI,EAAC,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAA;IAC3C,MAAM,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AAC3B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;AAC/F,CAAC;AAED;;;;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AACzB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACvD,MAAM,MAAM,GAAG,GAAG,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,CAAA;IAE7D,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,2BAA2B,CAAA;AAC7D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACnD,MAAM,MAAM,GAAG,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;IAEhD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,iDAAiD,CAAA;AACnF,CAAC","sourcesContent":["import {isTruthy} from './utilities.js'\nimport {getCIMetadata, isSet, Metadata} from '../../../private/node/context/utilities.js'\nimport {defaultThemeKitAccessDomain, environmentVariables, pathConstants} from '../../../private/node/constants.js'\nimport macaddress from 'macaddress'\nimport {homedir} from 'os'\n\n// Dynamic imports to avoid circular dependency: context/local → fs → output → context/local\n// fileExists and exec are only used in specific async functions, not at module init.\nasync function lazyFileExists(path: string): Promise<boolean> {\n const {fileExists} = await import('../fs.js')\n return fileExists(path)\n}\n\nasync function lazyExec(command: string, args: string[]): Promise<void> {\n const {exec} = await import('../system.js')\n await exec(command, args)\n}\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 Boolean(process.stdout.isTTY && process.env.TERM !== 'dumb' && !('CI' in process.env))\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[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[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).\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, environmentVariables.runAsUser)) {\n return !isTruthy(env[environmentVariables.runAsUser])\n }\n const devInstalled = await lazyFileExists(pathConstants.executables.dev)\n return devInstalled\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[environmentVariables.unitTest])\n}\n\n/**\n * Returns true if the CLI is running in hosted apps mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the HOSTED_APPS environment variable is truthy.\n */\nexport function isHostedAppsMode(env = process.env): boolean {\n return isTruthy(env[environmentVariables.hostedApps])\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 or OPT_OUT_INSTRUMENTATION is truthy, or debug mode is enabled.\n */\nexport function analyticsDisabled(env = process.env): boolean {\n return (\n isTruthy(env[environmentVariables.noAnalytics]) ||\n isTruthy(env[environmentVariables.optOutInstrumentation]) ||\n isDevelopment(env)\n )\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[environmentVariables.alwaysLogAnalytics])\n}\n\n/**\n * Returns true if reporting metrics 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_METRICS is truthy.\n */\nexport function alwaysLogMetrics(env = process.env): boolean {\n return isTruthy(env[environmentVariables.alwaysLogMetrics])\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[environmentVariables.firstPartyDev])\n}\n\n/**\n * Returns true if the CLI can run the \"doctor-release\" command.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the CLI can run the \"doctor-release\" command.\n */\nexport function canRunDoctorRelease(env = process.env): boolean {\n return isTruthy(env[environmentVariables.doctor])\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[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[environmentVariables.codespaceName]\n}\n\n/**\n * Return codespacePortForwardingDomain 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 port forwarding domain.\n */\nexport function codespacePortForwardingDomain(env = process.env): string | undefined {\n return env[environmentVariables.codespacePortForwardingDomain]\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 * The token used to run a theme command with a custom password.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns A string with the token.\n */\nexport function themeToken(env = process.env): string | undefined {\n return env[environmentVariables.themeToken]\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: 'codespaces' | 'gitpod' | 'cloudShell' | 'localhost'\n editor: boolean\n} {\n if (isSet(env[environmentVariables.codespaces])) {\n return {platform: 'codespaces', editor: true}\n }\n if (isSet(env[environmentVariables.gitpod])) {\n return {platform: 'gitpod', editor: true}\n }\n if (isSet(env[environmentVariables.cloudShell])) {\n return {platform: 'cloudShell', editor: true}\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 lazyExec('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(\n env = process.env,\n): {isCI: true; name: string; metadata: Metadata} | {isCI: false; name?: undefined; metadata?: undefined} {\n if (isTruthy(env.CI)) {\n let name = 'unknown'\n if (isSet(env.BITBUCKET_BUILD_NUMBER)) {\n name = 'bitbucket'\n } else 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 } else if (isSet(env.BUILDKITE)) {\n name = 'buildkite'\n }\n\n return {\n isCI: true,\n name,\n metadata: getCIMetadata(name, env),\n }\n } else if (isTruthy(env.TF_BUILD)) {\n return {\n isCI: true,\n name: 'azure',\n metadata: getCIMetadata('azure', env),\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\n/**\n * Get the domain for theme kit access.\n *\n * It can be overridden via the SHOPIFY_CLI_THEME_KIT_ACCESS_DOMAIN environment\n * variable.\n *\n * @param env - The environment variables from the environment of the process.\n *\n * @returns The domain for theme kit access.\n */\nexport function getThemeKitAccessDomain(env = process.env): string {\n const domain = env[environmentVariables.themeKitAccessDomain]\n\n return isSet(domain) ? domain : defaultThemeKitAccessDomain\n}\n\n/**\n * Get the domain to send OTEL metrics to.\n *\n * It can be overridden via the SHOPIFY_CLI_OTEL_EXPORTER_OTLP_ENDPOINT environment variable.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The domain to send OTEL metrics to.\n */\nexport function opentelemetryDomain(env = process.env): string {\n const domain = env[environmentVariables.otelURL]\n\n return isSet(domain) ? domain : 'https://otlp-http-production-cli.shopifysvc.com'\n}\n\nexport type CIMetadata = Metadata\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Command, Config } from '@oclif/core';
|
|
2
|
+
/**
|
|
3
|
+
* Optional lazy command loader function.
|
|
4
|
+
* If set, ShopifyConfig will use it to load individual commands on demand
|
|
5
|
+
* instead of importing the entire COMMANDS module (which triggers loading all packages).
|
|
6
|
+
*/
|
|
7
|
+
export type LazyCommandLoader = (id: string) => Promise<typeof Command | undefined>;
|
|
8
|
+
/**
|
|
9
|
+
* Subclass of oclif's Config that loads command classes on demand for faster CLI startup.
|
|
10
|
+
*/
|
|
11
|
+
export declare class ShopifyConfig extends Config {
|
|
12
|
+
private lazyCommandLoader?;
|
|
13
|
+
/**
|
|
14
|
+
* Set a lazy command loader that will be used to load individual command classes on demand,
|
|
15
|
+
* bypassing the default oclif behavior of importing the entire COMMANDS module.
|
|
16
|
+
*
|
|
17
|
+
* @param loader - The lazy command loader function.
|
|
18
|
+
*/
|
|
19
|
+
setLazyCommandLoader(loader: LazyCommandLoader): void;
|
|
20
|
+
/**
|
|
21
|
+
* Override runCommand to use lazy loading when available.
|
|
22
|
+
* Instead of calling cmd.load() which triggers loading ALL commands via index.js,
|
|
23
|
+
* we directly import only the needed command module.
|
|
24
|
+
*
|
|
25
|
+
* @param id - The command ID to run.
|
|
26
|
+
* @param argv - The arguments to pass to the command.
|
|
27
|
+
* @param cachedCommand - An optional cached command loadable.
|
|
28
|
+
* @returns The command result.
|
|
29
|
+
*/
|
|
30
|
+
runCommand<T = unknown>(id: string, argv?: string[], cachedCommand?: Command.Loadable | null): Promise<T>;
|
|
31
|
+
}
|