@shopify/cli-kit 3.61.2 → 3.63.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 -0
- package/dist/private/node/api/headers.js.map +1 -1
- package/dist/private/node/conf-store.d.ts +2 -0
- package/dist/private/node/conf-store.js.map +1 -1
- package/dist/private/node/content-tokens.d.ts +2 -1
- package/dist/private/node/content-tokens.js +3 -2
- package/dist/private/node/content-tokens.js.map +1 -1
- package/dist/private/node/context/utilities.js +9 -0
- package/dist/private/node/context/utilities.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.d.ts +2 -1
- package/dist/private/node/ui/components/ConcurrentOutput.js +5 -4
- package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.test.js +48 -3
- package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
- package/dist/public/common/lang.d.ts +0 -1
- package/dist/public/common/lang.js +0 -1
- package/dist/public/common/lang.js.map +1 -1
- package/dist/public/common/retry.d.ts +1 -0
- package/dist/public/common/retry.js +1 -0
- package/dist/public/common/retry.js.map +1 -1
- package/dist/public/common/ts/deep-required.d.ts +1 -1
- package/dist/public/common/ts/deep-required.js.map +1 -1
- package/dist/public/common/ts/pick-by-prefix.d.ts +1 -1
- package/dist/public/common/ts/pick-by-prefix.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/api/business-platform.d.ts +11 -0
- package/dist/public/node/api/business-platform.js +33 -8
- package/dist/public/node/api/business-platform.js.map +1 -1
- package/dist/public/node/api/graphql.d.ts +19 -4
- package/dist/public/node/api/graphql.js +30 -7
- package/dist/public/node/api/graphql.js.map +1 -1
- package/dist/public/node/api/partners.d.ts +11 -0
- package/dist/public/node/api/partners.js +36 -8
- package/dist/public/node/api/partners.js.map +1 -1
- package/dist/public/node/base-command.d.ts +3 -2
- package/dist/public/node/base-command.js +3 -0
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/cli.js +1 -1
- package/dist/public/node/cli.js.map +1 -1
- package/dist/public/node/context/local.js +3 -0
- package/dist/public/node/context/local.js.map +1 -1
- package/dist/public/node/custom-oclif-loader.d.ts +0 -6
- package/dist/public/node/custom-oclif-loader.js +1 -15
- package/dist/public/node/custom-oclif-loader.js.map +1 -1
- package/dist/public/node/dot-env.js.map +1 -1
- package/dist/public/node/fs.d.ts +0 -1
- package/dist/public/node/git.d.ts +2 -0
- package/dist/public/node/git.js +2 -0
- package/dist/public/node/git.js.map +1 -1
- package/dist/public/node/is-global.d.ts +3 -5
- package/dist/public/node/is-global.js +22 -8
- package/dist/public/node/is-global.js.map +1 -1
- package/dist/public/node/json-schema.d.ts +27 -0
- package/dist/public/node/json-schema.js +197 -0
- package/dist/public/node/json-schema.js.map +1 -0
- package/dist/public/node/logs.d.ts +1 -1
- package/dist/public/node/logs.js +3 -1
- package/dist/public/node/logs.js.map +1 -1
- package/dist/public/node/monorail.d.ts +1 -1
- package/dist/public/node/monorail.js.map +1 -1
- package/dist/public/node/node-package-manager.d.ts +12 -1
- package/dist/public/node/node-package-manager.js +32 -15
- package/dist/public/node/node-package-manager.js.map +1 -1
- package/dist/public/node/output.d.ts +2 -1
- package/dist/public/node/output.js +5 -2
- package/dist/public/node/output.js.map +1 -1
- package/dist/public/node/path.d.ts +14 -0
- package/dist/public/node/path.js +27 -0
- package/dist/public/node/path.js.map +1 -1
- package/dist/public/node/ruby.d.ts +2 -0
- package/dist/public/node/ruby.js +2 -0
- package/dist/public/node/ruby.js.map +1 -1
- package/dist/public/node/schema.d.ts +20 -1
- package/dist/public/node/schema.js.map +1 -1
- package/dist/public/node/system.d.ts +4 -1
- package/dist/public/node/system.js +7 -1
- package/dist/public/node/system.js.map +1 -1
- package/dist/public/node/tcp.d.ts +1 -1
- package/dist/public/node/tcp.js +1 -1
- package/dist/public/node/tcp.js.map +1 -1
- package/dist/public/node/tree-kill.js +0 -1
- package/dist/public/node/tree-kill.js.map +1 -1
- package/dist/public/node/ui.d.ts +8 -3
- package/dist/public/node/ui.js +7 -4
- package/dist/public/node/ui.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -3
package/dist/public/node/ruby.js
CHANGED
|
@@ -213,6 +213,8 @@ async function shopifyCLIDirectory(embedded = false) {
|
|
|
213
213
|
}
|
|
214
214
|
/**
|
|
215
215
|
* It returns the Ruby version present in the envirronment.
|
|
216
|
+
*
|
|
217
|
+
* @returns The Ruby version, or undefined if it is not found.
|
|
216
218
|
*/
|
|
217
219
|
export async function version() {
|
|
218
220
|
const parseOutput = (version) => version.match(/ruby (\d+\.\d+\.\d+)/)?.[1];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ruby.js","sourceRoot":"","sources":["../../../src/public/node/ruby.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,SAAS,CAAA;AACvC,OAAO,EAAC,aAAa,EAAE,IAAI,EAAc,MAAM,aAAa,CAAA;AAC5D,OAAO,KAAK,IAAI,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAC,MAAM,WAAW,CAAA;AAChD,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAC,MAAM,YAAY,CAAA;AACvD,OAAO,EAAC,uBAAuB,EAAC,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAC,iBAAiB,EAAE,QAAQ,EAAC,MAAM,mBAAmB,CAAA;AAC7D,OAAO,EAAC,aAAa,EAAE,mBAAmB,EAAC,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,aAAa,CAAA;AACtD,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAA;AAC1C,OA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L,OAAO,SAAS,CAAA;KACjB;AACH,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,UAAU,CAAC,IAAc,EAAE,OAAoB;IAC5D,OAAO,IAAI,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE;QACpC,GAAG,OAAO;QACV,GAAG,EAAE;YACH,GAAG,OAAO,CAAC,GAAG;YACd,gBAAgB,EAAE,cAAc,EAAE;YAClC,cAAc,EAAE,kBAAkB;YAClC,WAAW,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,KAAK;SAC5C;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {AbortSignal} from './abort.js'\nimport {platformAndArch} from './os.js'\nimport {captureOutput, exec, ExecOptions} from './system.js'\nimport * as file from './fs.js'\nimport {joinPath, dirname, cwd} from './path.js'\nimport {AbortError, AbortSilentError} from './error.js'\nimport {getEnvironmentVariables} from './environment.js'\nimport {isSpinEnvironment, spinFqdn} from './context/spin.js'\nimport {firstPartyDev, useEmbeddedThemeCLI} from './context/local.js'\nimport {outputContent, outputToken} from './output.js'\nimport {isTruthy} from './context/utilities.js'\nimport {runWithTimer} from './metadata.js'\nimport {pathConstants} from '../../private/node/constants.js'\nimport {CLI_KIT_VERSION} from '../common/version.js'\nimport {coerce, SemVer} from 'semver'\nimport envPaths from 'env-paths'\nimport {Writable} from 'stream'\nimport {fileURLToPath} from 'url'\n\nexport const RubyCLIVersion = '2.35.0'\nconst MinBundlerVersion = '2.3.11'\nconst MinRubyVersion = '2.7.5'\nexport const MinWdmWindowsVersion = '0.1.0'\n\ninterface ExecCLI2Options {\n // Contains store to pass to CLI 2.0 as environment variable\n store?: string\n // Contains token for admin access to pass to CLI 2.0 as environment variable\n adminToken?: string\n // Contains token for storefront access to pass to CLI 2.0 as environment variable\n storefrontToken?: string\n // Contains token for partners access to pass to CLI 2.0 as environment variable\n token?: string\n // Directory in which to execute the command. Otherwise the current directory will be used.\n directory?: string\n // A signal to stop the process execution.\n signal?: AbortSignal\n // Stream to pipe the command's stdout to.\n stdout?: Writable\n // Stream to pipe the command's stdout to.\n stderr?: Writable\n}\n/**\n * Execute CLI 2.0 commands.\n * Installs a version of RubyCLI as a vendor dependency in a hidden folder in the system.\n * User must have a valid ruby+bundler environment to run any command.\n *\n * @param args - List of argumets to execute. (ex: ['theme', 'pull']).\n * @param options - Options to customize the execution of cli2.\n */\nexport async function execCLI2(args: string[], options: ExecCLI2Options = {}): Promise<void> {\n const currentEnv = getEnvironmentVariables()\n const embedded = useEmbeddedThemeCLI(currentEnv) && !currentEnv.SHOPIFY_CLI_2_0_DIRECTORY\n\n await installCLIDependencies(options.stdout ?? process.stdout, embedded)\n const env: NodeJS.ProcessEnv = {\n ...currentEnv,\n SHOPIFY_CLI_STOREFRONT_RENDERER_AUTH_TOKEN: options.storefrontToken,\n SHOPIFY_CLI_ADMIN_AUTH_TOKEN: options.adminToken,\n SHOPIFY_SHOP: options.store,\n SHOPIFY_CLI_AUTH_TOKEN: options.token,\n SHOPIFY_CLI_RUN_AS_SUBPROCESS: 'true',\n SHOPIFY_CLI_RUBY_BIN: rubyExecutable(),\n // Bundler uses this Gemfile to understand which gems are available in the\n // environment. We use this to specify our own Gemfile for CLI2, which exists\n // outside the user's project directory.\n BUNDLE_GEMFILE: joinPath(await shopifyCLIDirectory(embedded), 'Gemfile'),\n ...(await getSpinEnvironmentVariables()),\n SHOPIFY_CLI_1P_DEV: firstPartyDev() ? '1' : '0',\n SHOPIFY_CLI_VERSION: CLI_KIT_VERSION,\n }\n\n try {\n const shopifyExecutable = embedded ? [rubyExecutable(), await embeddedCLIExecutable()] : ['shopify']\n await runBundler(['exec', ...shopifyExecutable, ...args], {\n ...(options.stdout === undefined && {stdio: 'inherit'}),\n cwd: options.directory ?? cwd(),\n env,\n ...(options.stdout !== undefined && {stdout: options.stdout, stderr: options.stderr}),\n signal: options.signal,\n })\n } catch (error) {\n // CLI2 will show it's own errors, we don't need to show an additional CLI3 error\n throw new AbortSilentError()\n }\n}\n\n/**\n * Validate Ruby Enviroment\n * Install RubyCLI and its dependencies\n * Shows a loading spinner if it's the first time installing dependencies\n * or if we are installing a new version of RubyCLI.\n *\n * @param stdout - The Writable stream on which to write the standard output.\n * @param embedded - True when embebbed codebase of CLI should be used.\n */\nasync function installCLIDependencies(stdout: Writable, embedded = false) {\n const localCLI = await shopifyCLIDirectory(embedded)\n const exists = await file.fileExists(localCLI)\n\n if (!exists) stdout.write('Installing theme dependencies...')\n const usingLocalCLI2 = embedded || isTruthy(getEnvironmentVariables().SHOPIFY_CLI_2_0_DIRECTORY)\n await validateRubyEnv()\n if (usingLocalCLI2) {\n await bundleInstallLocalShopifyCLI(localCLI)\n } else {\n await createShopifyCLIWorkingDirectory()\n await createShopifyCLIGemfile()\n await bundleInstallShopifyCLI()\n }\n\n if (!exists) stdout.write('Installed theme dependencies!')\n}\n\n/**\n * A function that validates if the environment in which the CLI is running is set up with Ruby and Bundler.\n */\nasync function validateRubyEnv() {\n await validateRuby()\n await validateBundler()\n}\n\n/**\n * A function that validates if the environment in which the CLI is running is set up with Ruby.\n */\nasync function validateRuby() {\n let version: SemVer | null\n try {\n const stdout = await captureOutput(rubyExecutable(), ['-v'])\n version = coerce(stdout)\n } catch {\n throw new AbortError(\n 'Ruby environment not found',\n `Make sure you have Ruby installed on your system. ${\n outputContent`${outputToken.link('Documentation.', 'https://www.ruby-lang.org/en/documentation/installation/')}`\n .value\n }`,\n )\n }\n\n const isValid = version?.compare(MinRubyVersion)\n if (isValid === -1 || isValid === undefined) {\n throw new AbortError(\n `Ruby version ${outputContent`${outputToken.yellow(version?.raw ?? 'unknown')}`.value} is not supported`,\n `Make sure you have at least Ruby ${\n outputContent`${outputToken.yellow(MinRubyVersion)}`.value\n } installed on your system. ${\n outputContent`${outputToken.link('Documentation.', 'https://www.ruby-lang.org/en/documentation/installation/')}`\n .value\n }`,\n )\n }\n}\n\n/**\n * A function that validates if the environment in which the CLI is running is set up with Bundler.\n */\nasync function validateBundler() {\n let version: SemVer | null\n try {\n const stdout = await captureOutput(bundleExecutable(), ['-v'], {env: {BUNDLE_USER_HOME: bundleUserHome()}})\n version = coerce(stdout)\n } catch {\n throw new AbortError(\n 'Bundler not found',\n `To install the latest version of Bundler, run ${\n outputContent`${outputToken.genericShellCommand(`${gemExecutable()} install bundler`)}`.value\n }`,\n )\n }\n\n const isValid = version?.compare(MinBundlerVersion)\n if (isValid === -1 || isValid === undefined) {\n throw new AbortError(\n `Bundler version ${outputContent`${outputToken.yellow(version?.raw ?? 'unknown')}`.value} is not supported`,\n `To update to the latest version of Bundler, run ${\n outputContent`${outputToken.genericShellCommand(`${gemExecutable()} install bundler`)}`.value\n }`,\n )\n }\n}\n\n/**\n * It creates the directory where the Ruby CLI will be downloaded along its dependencies.\n */\nasync function createShopifyCLIWorkingDirectory(): Promise<void> {\n return file.mkdir(await shopifyCLIDirectory())\n}\n\n/**\n * It creates the Gemfile to install The Ruby CLI and the dependencies.\n */\nasync function createShopifyCLIGemfile(): Promise<void> {\n const directory = await shopifyCLIDirectory()\n const gemfileContent = getBaseGemfileContent().concat(getWindowsDependencies())\n await addContentToGemfile(directory, gemfileContent)\n}\n\n/**\n * It runs bundle install for the dev-managed copy of the Ruby CLI.\n *\n * @param directory - Directory where CLI2 Gemfile is located.\n */\nasync function bundleInstallLocalShopifyCLI(directory: string): Promise<void> {\n await addContentToGemfile(directory, getWindowsDependencies())\n await shopifyBundleInstall(directory)\n}\n\n/**\n * Build the list of lines with the base content of the Gemfile.\n *\n * @returns List of lines with base content.\n */\nfunction getBaseGemfileContent() {\n return [\"source 'https://rubygems.org'\", `gem 'shopify-cli', '${RubyCLIVersion}'`]\n}\n\n/**\n * Build the list of Windows dependencies.\n *\n * @returns List of Windows dependencies.\n */\nfunction getWindowsDependencies() {\n if (platformAndArch().platform === 'windows') {\n // 'wdm' is required by 'listen', see https://github.com/Shopify/cli/issues/780\n // Because it's a Windows-only dependency, it's not included in the `.gemspec` or `Gemfile`.\n // Otherwise it would be installed in non-Windows environments too, where it is not needed.\n return [`gem 'wdm', '>= ${MinWdmWindowsVersion}'`]\n }\n return []\n}\n\n/**\n * Append contente to a Gemfile located in the given directory.\n *\n * @param gemfileDirectory - Directory where Gemfile is located.\n * @param content - Content to append to the Gemfile.\n */\nasync function addContentToGemfile(gemfileDirectory: string, content: string[]) {\n const gemfilePath = joinPath(gemfileDirectory, 'Gemfile')\n if (!(await file.fileExists(gemfilePath))) await file.touchFile(gemfilePath)\n const gemContent = await file.readFile(gemfilePath, {encoding: 'utf8'})\n const contentNoExisting = content.filter((line) => !gemContent.includes(line)).join('\\n')\n if (contentNoExisting) await file.appendFile(gemfilePath, contentNoExisting.concat('\\n'))\n}\n\n/**\n * It runs bundle install for the CLI-managed copy of the Ruby CLI.\n */\nasync function bundleInstallShopifyCLI() {\n await shopifyBundleInstall(await shopifyCLIDirectory())\n}\n\n/**\n * It returns the directory where the Ruby CLI is located.\n *\n * @param embedded - True when embebbed codebase of CLI should be used.\n * @returns The absolute path to the directory.\n */\nasync function shopifyCLIDirectory(embedded = false): Promise<string> {\n const embeddedDirectory = (await file.findPathUp('assets/cli-ruby', {\n type: 'directory',\n cwd: dirname(fileURLToPath(import.meta.url)),\n })) as string\n const bundledDirectory = joinPath(pathConstants.directories.cache.vendor.path(), 'ruby-cli', RubyCLIVersion)\n\n return embedded ? embeddedDirectory : getEnvironmentVariables().SHOPIFY_CLI_2_0_DIRECTORY ?? bundledDirectory\n}\n\n/**\n * It returns the Ruby version present in the envirronment.\n */\nexport async function version(): Promise<string | undefined> {\n const parseOutput = (version: string) => version.match(/ruby (\\d+\\.\\d+\\.\\d+)/)?.[1]\n return captureOutput(rubyExecutable(), ['-v'])\n .then(parseOutput)\n .catch(() => undefined)\n}\n\n/**\n * It returns the Ruby binary path set through the environment variable SHOPIFY_RUBY_BINDIR.\n * This is useful when the CLI is managed by an installer like a Homebrew where we need to\n * point the CLI to the Ruby installation managed by Homebrew.\n *\n * @returns The value of the environment variable.\n */\nfunction getRubyBinDir(): string | undefined {\n return getEnvironmentVariables().SHOPIFY_RUBY_BINDIR\n}\n\n/**\n * It returns the path to the \"ruby\" executable.\n *\n * @returns The path to the executable.\n */\nfunction rubyExecutable(): string {\n const rubyBinDir = getRubyBinDir()\n return rubyBinDir ? joinPath(rubyBinDir, 'ruby') : 'ruby'\n}\n\n/**\n * It returns the path to the \"bundle\" executable.\n *\n * @returns The path to the executable.\n */\nfunction bundleExecutable(): string {\n const rubyBinDir = getRubyBinDir()\n return rubyBinDir ? joinPath(rubyBinDir, 'bundle') : 'bundle'\n}\n\n/**\n * It returns the path to the \"gem\"\" executable.\n *\n * @returns The path to the executable.\n */\nfunction gemExecutable(): string {\n const rubyBinDir = getRubyBinDir()\n return rubyBinDir ? joinPath(rubyBinDir, 'gem') : 'gem'\n}\n\n/**\n * It returns the path to the \"bundle\" executable.\n *\n * @returns The path to the executable.\n */\nasync function embeddedCLIExecutable(): Promise<string> {\n const cliDirectory = await shopifyCLIDirectory(true)\n return joinPath(cliDirectory, 'bin', 'shopify')\n}\n\n/**\n * Get environment variables required by the CLI2 in case the CLI3 is running in a Spin environment.\n *\n * @returns The environment variables to set.\n */\nasync function getSpinEnvironmentVariables() {\n if (!isSpinEnvironment()) return {}\n\n return {\n SPIN_FQDN: await spinFqdn(),\n SPIN: '1',\n }\n}\n\n/**\n * It sets bundler's path to a directory dedicated to shopify gems and runs bundle install.\n * This is desirable because these gems will be isolated from the system gems.\n *\n * @param directory - Directory where the Gemfile is located.\n */\nasync function shopifyBundleInstall(directory: string): Promise<void> {\n return runWithTimer('cmd_all_timing_network_ms')(async () => {\n await runBundler(['install'], {cwd: directory})\n })\n}\n\n/**\n * It returns a custom BUNDLE_USER_HOME. This is required in Windows because\n * bundler will instead crash if the username contains UTF-8 characters.\n *\n * @returns The value of the environment variable.\n */\nexport function bundleUserHome(): string | undefined {\n if (platformAndArch().platform === 'windows' && process.env.PUBLIC) {\n return joinPath(process.env.PUBLIC, 'AppData', 'Local', 'shopify-bundler-nodejs', 'Cache')\n } else {\n return undefined\n }\n}\n\n/**\n * It runs bundler commands by setting the correct BUNDLE_USER_HOME env var.\n *\n * @param args - Arguments to pass to the bundle command.\n * @param options - Options to pass to the exec function.\n */\nasync function runBundler(args: string[], options: ExecOptions) {\n return exec(bundleExecutable(), args, {\n ...options,\n env: {\n ...options.env,\n BUNDLE_USER_HOME: bundleUserHome(),\n BUNDLE_WITHOUT: 'development:test',\n BUNDLE_PATH: envPaths('shopify-gems').cache,\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ruby.js","sourceRoot":"","sources":["../../../src/public/node/ruby.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,SAAS,CAAA;AACvC,OAAO,EAAC,aAAa,EAAE,IAAI,EAAc,MAAM,aAAa,CAAA;AAC5D,OAAO,KAAK,IAAI,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAC,MAAM,WAAW,CAAA;AAChD,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAC,MAAM,YAAY,CAAA;AACvD,OAAO,EAAC,uBAAuB,EAAC,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAC,iBAAiB,EAAE,QAAQ,EAAC,MAAM,mBAAmB,CAAA;AAC7D,OAAO,EAAC,aAAa,EAAE,mBAAmB,EAAC,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,aAAa,CAAA;AACtD,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,iCAAiC,CAAA;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAC,MAAM,EAAS,MAAM,QAAQ,CAAA;AACrC,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAC,aA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AAG,OAAO,CAAC,GAAG;YACd,gBAAgB,EAAE,cAAc,EAAE;YAClC,cAAc,EAAE,kBAAkB;YAClC,WAAW,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,KAAK;SAC5C;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {AbortSignal} from './abort.js'\nimport {platformAndArch} from './os.js'\nimport {captureOutput, exec, ExecOptions} from './system.js'\nimport * as file from './fs.js'\nimport {joinPath, dirname, cwd} from './path.js'\nimport {AbortError, AbortSilentError} from './error.js'\nimport {getEnvironmentVariables} from './environment.js'\nimport {isSpinEnvironment, spinFqdn} from './context/spin.js'\nimport {firstPartyDev, useEmbeddedThemeCLI} from './context/local.js'\nimport {outputContent, outputToken} from './output.js'\nimport {isTruthy} from './context/utilities.js'\nimport {runWithTimer} from './metadata.js'\nimport {pathConstants} from '../../private/node/constants.js'\nimport {CLI_KIT_VERSION} from '../common/version.js'\nimport {coerce, SemVer} from 'semver'\nimport envPaths from 'env-paths'\nimport {Writable} from 'stream'\nimport {fileURLToPath} from 'url'\n\nexport const RubyCLIVersion = '2.35.0'\nconst MinBundlerVersion = '2.3.11'\nconst MinRubyVersion = '2.7.5'\nexport const MinWdmWindowsVersion = '0.1.0'\n\ninterface ExecCLI2Options {\n // Contains store to pass to CLI 2.0 as environment variable\n store?: string\n // Contains token for admin access to pass to CLI 2.0 as environment variable\n adminToken?: string\n // Contains token for storefront access to pass to CLI 2.0 as environment variable\n storefrontToken?: string\n // Contains token for partners access to pass to CLI 2.0 as environment variable\n token?: string\n // Directory in which to execute the command. Otherwise the current directory will be used.\n directory?: string\n // A signal to stop the process execution.\n signal?: AbortSignal\n // Stream to pipe the command's stdout to.\n stdout?: Writable\n // Stream to pipe the command's stdout to.\n stderr?: Writable\n}\n/**\n * Execute CLI 2.0 commands.\n * Installs a version of RubyCLI as a vendor dependency in a hidden folder in the system.\n * User must have a valid ruby+bundler environment to run any command.\n *\n * @param args - List of argumets to execute. (ex: ['theme', 'pull']).\n * @param options - Options to customize the execution of cli2.\n */\nexport async function execCLI2(args: string[], options: ExecCLI2Options = {}): Promise<void> {\n const currentEnv = getEnvironmentVariables()\n const embedded = useEmbeddedThemeCLI(currentEnv) && !currentEnv.SHOPIFY_CLI_2_0_DIRECTORY\n\n await installCLIDependencies(options.stdout ?? process.stdout, embedded)\n const env: NodeJS.ProcessEnv = {\n ...currentEnv,\n SHOPIFY_CLI_STOREFRONT_RENDERER_AUTH_TOKEN: options.storefrontToken,\n SHOPIFY_CLI_ADMIN_AUTH_TOKEN: options.adminToken,\n SHOPIFY_SHOP: options.store,\n SHOPIFY_CLI_AUTH_TOKEN: options.token,\n SHOPIFY_CLI_RUN_AS_SUBPROCESS: 'true',\n SHOPIFY_CLI_RUBY_BIN: rubyExecutable(),\n // Bundler uses this Gemfile to understand which gems are available in the\n // environment. We use this to specify our own Gemfile for CLI2, which exists\n // outside the user's project directory.\n BUNDLE_GEMFILE: joinPath(await shopifyCLIDirectory(embedded), 'Gemfile'),\n ...(await getSpinEnvironmentVariables()),\n SHOPIFY_CLI_1P_DEV: firstPartyDev() ? '1' : '0',\n SHOPIFY_CLI_VERSION: CLI_KIT_VERSION,\n }\n\n try {\n const shopifyExecutable = embedded ? [rubyExecutable(), await embeddedCLIExecutable()] : ['shopify']\n await runBundler(['exec', ...shopifyExecutable, ...args], {\n ...(options.stdout === undefined && {stdio: 'inherit'}),\n cwd: options.directory ?? cwd(),\n env,\n ...(options.stdout !== undefined && {stdout: options.stdout, stderr: options.stderr}),\n signal: options.signal,\n })\n } catch (error) {\n // CLI2 will show it's own errors, we don't need to show an additional CLI3 error\n throw new AbortSilentError()\n }\n}\n\n/**\n * Validate Ruby Enviroment\n * Install RubyCLI and its dependencies\n * Shows a loading spinner if it's the first time installing dependencies\n * or if we are installing a new version of RubyCLI.\n *\n * @param stdout - The Writable stream on which to write the standard output.\n * @param embedded - True when embebbed codebase of CLI should be used.\n */\nasync function installCLIDependencies(stdout: Writable, embedded = false) {\n const localCLI = await shopifyCLIDirectory(embedded)\n const exists = await file.fileExists(localCLI)\n\n if (!exists) stdout.write('Installing theme dependencies...')\n const usingLocalCLI2 = embedded || isTruthy(getEnvironmentVariables().SHOPIFY_CLI_2_0_DIRECTORY)\n await validateRubyEnv()\n if (usingLocalCLI2) {\n await bundleInstallLocalShopifyCLI(localCLI)\n } else {\n await createShopifyCLIWorkingDirectory()\n await createShopifyCLIGemfile()\n await bundleInstallShopifyCLI()\n }\n\n if (!exists) stdout.write('Installed theme dependencies!')\n}\n\n/**\n * A function that validates if the environment in which the CLI is running is set up with Ruby and Bundler.\n */\nasync function validateRubyEnv() {\n await validateRuby()\n await validateBundler()\n}\n\n/**\n * A function that validates if the environment in which the CLI is running is set up with Ruby.\n */\nasync function validateRuby() {\n let version: SemVer | null\n try {\n const stdout = await captureOutput(rubyExecutable(), ['-v'])\n version = coerce(stdout)\n } catch {\n throw new AbortError(\n 'Ruby environment not found',\n `Make sure you have Ruby installed on your system. ${\n outputContent`${outputToken.link('Documentation.', 'https://www.ruby-lang.org/en/documentation/installation/')}`\n .value\n }`,\n )\n }\n\n const isValid = version?.compare(MinRubyVersion)\n if (isValid === -1 || isValid === undefined) {\n throw new AbortError(\n `Ruby version ${outputContent`${outputToken.yellow(version?.raw ?? 'unknown')}`.value} is not supported`,\n `Make sure you have at least Ruby ${\n outputContent`${outputToken.yellow(MinRubyVersion)}`.value\n } installed on your system. ${\n outputContent`${outputToken.link('Documentation.', 'https://www.ruby-lang.org/en/documentation/installation/')}`\n .value\n }`,\n )\n }\n}\n\n/**\n * A function that validates if the environment in which the CLI is running is set up with Bundler.\n */\nasync function validateBundler() {\n let version: SemVer | null\n try {\n const stdout = await captureOutput(bundleExecutable(), ['-v'], {env: {BUNDLE_USER_HOME: bundleUserHome()}})\n version = coerce(stdout)\n } catch {\n throw new AbortError(\n 'Bundler not found',\n `To install the latest version of Bundler, run ${\n outputContent`${outputToken.genericShellCommand(`${gemExecutable()} install bundler`)}`.value\n }`,\n )\n }\n\n const isValid = version?.compare(MinBundlerVersion)\n if (isValid === -1 || isValid === undefined) {\n throw new AbortError(\n `Bundler version ${outputContent`${outputToken.yellow(version?.raw ?? 'unknown')}`.value} is not supported`,\n `To update to the latest version of Bundler, run ${\n outputContent`${outputToken.genericShellCommand(`${gemExecutable()} install bundler`)}`.value\n }`,\n )\n }\n}\n\n/**\n * It creates the directory where the Ruby CLI will be downloaded along its dependencies.\n */\nasync function createShopifyCLIWorkingDirectory(): Promise<void> {\n return file.mkdir(await shopifyCLIDirectory())\n}\n\n/**\n * It creates the Gemfile to install The Ruby CLI and the dependencies.\n */\nasync function createShopifyCLIGemfile(): Promise<void> {\n const directory = await shopifyCLIDirectory()\n const gemfileContent = getBaseGemfileContent().concat(getWindowsDependencies())\n await addContentToGemfile(directory, gemfileContent)\n}\n\n/**\n * It runs bundle install for the dev-managed copy of the Ruby CLI.\n *\n * @param directory - Directory where CLI2 Gemfile is located.\n */\nasync function bundleInstallLocalShopifyCLI(directory: string): Promise<void> {\n await addContentToGemfile(directory, getWindowsDependencies())\n await shopifyBundleInstall(directory)\n}\n\n/**\n * Build the list of lines with the base content of the Gemfile.\n *\n * @returns List of lines with base content.\n */\nfunction getBaseGemfileContent() {\n return [\"source 'https://rubygems.org'\", `gem 'shopify-cli', '${RubyCLIVersion}'`]\n}\n\n/**\n * Build the list of Windows dependencies.\n *\n * @returns List of Windows dependencies.\n */\nfunction getWindowsDependencies() {\n if (platformAndArch().platform === 'windows') {\n // 'wdm' is required by 'listen', see https://github.com/Shopify/cli/issues/780\n // Because it's a Windows-only dependency, it's not included in the `.gemspec` or `Gemfile`.\n // Otherwise it would be installed in non-Windows environments too, where it is not needed.\n return [`gem 'wdm', '>= ${MinWdmWindowsVersion}'`]\n }\n return []\n}\n\n/**\n * Append contente to a Gemfile located in the given directory.\n *\n * @param gemfileDirectory - Directory where Gemfile is located.\n * @param content - Content to append to the Gemfile.\n */\nasync function addContentToGemfile(gemfileDirectory: string, content: string[]) {\n const gemfilePath = joinPath(gemfileDirectory, 'Gemfile')\n if (!(await file.fileExists(gemfilePath))) await file.touchFile(gemfilePath)\n const gemContent = await file.readFile(gemfilePath, {encoding: 'utf8'})\n const contentNoExisting = content.filter((line) => !gemContent.includes(line)).join('\\n')\n if (contentNoExisting) await file.appendFile(gemfilePath, contentNoExisting.concat('\\n'))\n}\n\n/**\n * It runs bundle install for the CLI-managed copy of the Ruby CLI.\n */\nasync function bundleInstallShopifyCLI() {\n await shopifyBundleInstall(await shopifyCLIDirectory())\n}\n\n/**\n * It returns the directory where the Ruby CLI is located.\n *\n * @param embedded - True when embebbed codebase of CLI should be used.\n * @returns The absolute path to the directory.\n */\nasync function shopifyCLIDirectory(embedded = false): Promise<string> {\n const embeddedDirectory = (await file.findPathUp('assets/cli-ruby', {\n type: 'directory',\n cwd: dirname(fileURLToPath(import.meta.url)),\n })) as string\n const bundledDirectory = joinPath(pathConstants.directories.cache.vendor.path(), 'ruby-cli', RubyCLIVersion)\n\n return embedded ? embeddedDirectory : getEnvironmentVariables().SHOPIFY_CLI_2_0_DIRECTORY ?? bundledDirectory\n}\n\n/**\n * It returns the Ruby version present in the envirronment.\n *\n * @returns The Ruby version, or undefined if it is not found.\n */\nexport async function version(): Promise<string | undefined> {\n const parseOutput = (version: string) => version.match(/ruby (\\d+\\.\\d+\\.\\d+)/)?.[1]\n return captureOutput(rubyExecutable(), ['-v'])\n .then(parseOutput)\n .catch(() => undefined)\n}\n\n/**\n * It returns the Ruby binary path set through the environment variable SHOPIFY_RUBY_BINDIR.\n * This is useful when the CLI is managed by an installer like a Homebrew where we need to\n * point the CLI to the Ruby installation managed by Homebrew.\n *\n * @returns The value of the environment variable.\n */\nfunction getRubyBinDir(): string | undefined {\n return getEnvironmentVariables().SHOPIFY_RUBY_BINDIR\n}\n\n/**\n * It returns the path to the \"ruby\" executable.\n *\n * @returns The path to the executable.\n */\nfunction rubyExecutable(): string {\n const rubyBinDir = getRubyBinDir()\n return rubyBinDir ? joinPath(rubyBinDir, 'ruby') : 'ruby'\n}\n\n/**\n * It returns the path to the \"bundle\" executable.\n *\n * @returns The path to the executable.\n */\nfunction bundleExecutable(): string {\n const rubyBinDir = getRubyBinDir()\n return rubyBinDir ? joinPath(rubyBinDir, 'bundle') : 'bundle'\n}\n\n/**\n * It returns the path to the \"gem\"\" executable.\n *\n * @returns The path to the executable.\n */\nfunction gemExecutable(): string {\n const rubyBinDir = getRubyBinDir()\n return rubyBinDir ? joinPath(rubyBinDir, 'gem') : 'gem'\n}\n\n/**\n * It returns the path to the \"bundle\" executable.\n *\n * @returns The path to the executable.\n */\nasync function embeddedCLIExecutable(): Promise<string> {\n const cliDirectory = await shopifyCLIDirectory(true)\n return joinPath(cliDirectory, 'bin', 'shopify')\n}\n\n/**\n * Get environment variables required by the CLI2 in case the CLI3 is running in a Spin environment.\n *\n * @returns The environment variables to set.\n */\nasync function getSpinEnvironmentVariables() {\n if (!isSpinEnvironment()) return {}\n\n return {\n SPIN_FQDN: await spinFqdn(),\n SPIN: '1',\n }\n}\n\n/**\n * It sets bundler's path to a directory dedicated to shopify gems and runs bundle install.\n * This is desirable because these gems will be isolated from the system gems.\n *\n * @param directory - Directory where the Gemfile is located.\n */\nasync function shopifyBundleInstall(directory: string): Promise<void> {\n return runWithTimer('cmd_all_timing_network_ms')(async () => {\n await runBundler(['install'], {cwd: directory})\n })\n}\n\n/**\n * It returns a custom BUNDLE_USER_HOME. This is required in Windows because\n * bundler will instead crash if the username contains UTF-8 characters.\n *\n * @returns The value of the environment variable.\n */\nexport function bundleUserHome(): string | undefined {\n if (platformAndArch().platform === 'windows' && process.env.PUBLIC) {\n return joinPath(process.env.PUBLIC, 'AppData', 'Local', 'shopify-bundler-nodejs', 'Cache')\n } else {\n return undefined\n }\n}\n\n/**\n * It runs bundler commands by setting the correct BUNDLE_USER_HOME env var.\n *\n * @param args - Arguments to pass to the bundle command.\n * @param options - Options to pass to the exec function.\n */\nasync function runBundler(args: string[], options: ExecOptions) {\n return exec(bundleExecutable(), args, {\n ...options,\n env: {\n ...options.env,\n BUNDLE_USER_HOME: bundleUserHome(),\n BUNDLE_WITHOUT: 'development:test',\n BUNDLE_PATH: envPaths('shopify-gems').cache,\n },\n })\n}\n"]}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
1
|
+
import { ZodObject, z } from 'zod';
|
|
2
2
|
export { z as zod } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Type alias for a zod object schema that produces a given shape once parsed.
|
|
5
|
+
*/
|
|
6
|
+
export type ZodObjectOf<T> = ZodObject<any, any, any, T>;
|
|
3
7
|
/**
|
|
4
8
|
* Returns a new schema that is the same as the input schema, but with all nested schemas set to strict.
|
|
5
9
|
*
|
|
@@ -14,3 +18,18 @@ export declare function deepStrict<T>(schema: T): T;
|
|
|
14
18
|
* @returns The human-readable string.
|
|
15
19
|
*/
|
|
16
20
|
export declare function errorsToString(errors: z.ZodIssueBase[]): string;
|
|
21
|
+
/**
|
|
22
|
+
* A neutral type for the result of a parsing/validation operation.
|
|
23
|
+
*
|
|
24
|
+
* As some validation can happen via JSON Schema, we prefer to use a type that isn't wholly dependent on Zod (or
|
|
25
|
+
* JSON Schema).
|
|
26
|
+
*/
|
|
27
|
+
export type ParseConfigurationResult<TConfiguration> = {
|
|
28
|
+
state: 'ok';
|
|
29
|
+
data: TConfiguration;
|
|
30
|
+
errors: undefined;
|
|
31
|
+
} | {
|
|
32
|
+
state: 'error';
|
|
33
|
+
data: undefined;
|
|
34
|
+
errors: Pick<z.ZodIssueBase, 'path' | 'message'>[];
|
|
35
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/public/node/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,WAAW,EAAc,CAAC,EAAC,MAAM,KAAK,CAAA;AAEzD,OAAO,EAAC,CAAC,IAAI,GAAG,EAAC,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/public/node/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,WAAW,EAAc,CAAC,EAAC,MAAM,KAAK,CAAA;AAEzD,OAAO,EAAC,CAAC,IAAI,GAAG,EAAC,MAAM,KAAK,CAAA;AAQ5B;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAI,MAAS;IACrC,IAAI,MAAM,YAAY,SAAS,EAAE;QAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;QAC1B,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CACpC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,UAAU,CAAC,KAAmB,CAAC,CAAC,CAAC,CACpF,CAAA;QACD,OAAO,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,EAAO,CAAA;KAC3C;SAAM,IAAI,MAAM,YAAY,WAAW,EAAE;QACxC,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAA;KACpD;SAAM;QACL,OAAO,MAAM,CAAA;KACd;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAAwB;IACrD,OAAO,MAAM;SACV,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACb,KAAK,CAAC,IAAI;SACP,IAAI,CAAC,GAAG,CAAC;SACT,MAAM,CAAC,IAAI,CAAC;SACZ,MAAM,CAAC,KAAK,CAAC,OAAO,IAAI,cAAc,CAAC,CAC3C;SACA,IAAI,CAAC,IAAI,CAAC,CAAA;AACf,CAAC","sourcesContent":["import {ZodObject, ZodOptional, ZodTypeAny, z} from 'zod'\n\nexport {z as zod} from 'zod'\n\n/**\n * Type alias for a zod object schema that produces a given shape once parsed.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ZodObjectOf<T> = ZodObject<any, any, any, T>\n\n/**\n * Returns a new schema that is the same as the input schema, but with all nested schemas set to strict.\n *\n * @param schema - The schema to make strict.\n * @returns The result strict schema.\n */\nexport function deepStrict<T>(schema: T): T {\n if (schema instanceof ZodObject) {\n const shape = schema.shape\n const strictShape = Object.fromEntries(\n Object.entries(shape).map(([key, value]) => [key, deepStrict(value as ZodTypeAny)]),\n )\n return z.object(strictShape).strict() as T\n } else if (schema instanceof ZodOptional) {\n return deepStrict(schema._def.innerType).optional()\n } else {\n return schema\n }\n}\n\n/**\n * Returns a human-readable string of the list of zod errors.\n *\n * @param errors - The list of zod errors.\n * @returns The human-readable string.\n */\nexport function errorsToString(errors: z.ZodIssueBase[]): string {\n return errors\n .map((error) =>\n error.path\n .join('.')\n .concat(': ')\n .concat(error.message ?? 'Unknow error'),\n )\n .join('\\n')\n}\n\n/**\n * A neutral type for the result of a parsing/validation operation.\n *\n * As some validation can happen via JSON Schema, we prefer to use a type that isn't wholly dependent on Zod (or\n * JSON Schema).\n */\nexport type ParseConfigurationResult<TConfiguration> =\n | {\n state: 'ok'\n data: TConfiguration\n errors: undefined\n }\n | {\n state: 'error'\n data: undefined\n errors: Pick<z.ZodIssueBase, 'path' | 'message'>[]\n }\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
4
|
import { AbortSignal } from './abort.js';
|
|
4
5
|
import { ReadStream } from 'tty';
|
|
5
6
|
import type { Writable, Readable } from 'stream';
|
|
@@ -43,6 +44,7 @@ export declare function exec(command: string, args: string[], options?: ExecOpti
|
|
|
43
44
|
* Waits for a given number of seconds.
|
|
44
45
|
*
|
|
45
46
|
* @param seconds - Number of seconds to wait.
|
|
47
|
+
* @returns A Promise resolving after the number of seconds.
|
|
46
48
|
*/
|
|
47
49
|
export declare function sleep(seconds: number): Promise<void>;
|
|
48
50
|
/**
|
|
@@ -50,6 +52,7 @@ export declare function sleep(seconds: number): Promise<void>;
|
|
|
50
52
|
* will be used.
|
|
51
53
|
*
|
|
52
54
|
* @param stdin - The standard input stream to check.
|
|
55
|
+
* @param env - Environmemnt variables.
|
|
53
56
|
* @returns True in the selected input stream support raw mode.
|
|
54
57
|
*/
|
|
55
|
-
export declare function terminalSupportsRawMode(stdin?: ReadStream): boolean;
|
|
58
|
+
export declare function terminalSupportsRawMode(stdin?: ReadStream, env?: NodeJS.ProcessEnv): boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ExternalError } from './error.js';
|
|
2
2
|
import { cwd } from './path.js';
|
|
3
3
|
import { treeKill } from './tree-kill.js';
|
|
4
|
+
import { isTruthy } from './context/utilities.js';
|
|
4
5
|
import { shouldDisplayColors, outputDebug } from '../../public/node/output.js';
|
|
5
6
|
import { execa } from 'execa';
|
|
6
7
|
/**
|
|
@@ -103,6 +104,7 @@ Running system process:
|
|
|
103
104
|
* Waits for a given number of seconds.
|
|
104
105
|
*
|
|
105
106
|
* @param seconds - Number of seconds to wait.
|
|
107
|
+
* @returns A Promise resolving after the number of seconds.
|
|
106
108
|
*/
|
|
107
109
|
export async function sleep(seconds) {
|
|
108
110
|
return new Promise((resolve) => {
|
|
@@ -114,9 +116,13 @@ export async function sleep(seconds) {
|
|
|
114
116
|
* will be used.
|
|
115
117
|
*
|
|
116
118
|
* @param stdin - The standard input stream to check.
|
|
119
|
+
* @param env - Environmemnt variables.
|
|
117
120
|
* @returns True in the selected input stream support raw mode.
|
|
118
121
|
*/
|
|
119
|
-
export function terminalSupportsRawMode(stdin) {
|
|
122
|
+
export function terminalSupportsRawMode(stdin, env = process.env) {
|
|
123
|
+
if (isTruthy(env.CI)) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
120
126
|
if (stdin)
|
|
121
127
|
return Boolean(stdin.isTTY);
|
|
122
128
|
return process.stdin.isTTY;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.js","sourceRoot":"","sources":["../../../src/public/node/system.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAA;AACxC,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAC7B,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAC,mBAAmB,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AAC5E,OAAO,EAAC,KAAK,EAAoB,MAAM,OAAO,CAAA;AAiB9C;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,GAAW;IACvC,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAA;IACzC,MAAM,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;AACjC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAe,EAAE,IAAc,EAAE,OAAqB;IACxF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;IACtD,OAAO,MAAM,CAAC,MAAM,CAAA;AACtB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,OAAe,EAAE,IAAc,EAAE,OAAqB;IAC/E,MAAM,cAAc,GAAG,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;IACxD,IAAI,OAAO,EAAE,MAAM,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE;QACnD,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAC,GAAG,EAAE,KAAK,EAAC,CAAC,CAAA;KAC1D;IACD,IAAI,OAAO,EAAE,MAAM,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE;QACnD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,CAAC,OAAe;IACzC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,UAAU,CAAC,OAAO,EAAE,IAAI,GAAG,OAAO,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAkB,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG;IAC3E,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QACpB,OAAO,KAAK,CAAA;KACb;IACD,IAAI,KAAK;QAAE,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACtC,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,CAAA;AAC5B,CAAC","sourcesContent":["import {AbortSignal} from './abort.js'\nimport {ExternalError} from './error.js'\nimport {cwd} from './path.js'\nimport {treeKill} from './tree-kill.js'\nimport {isTruthy} from './context/utilities.js'\nimport {shouldDisplayColors, outputDebug} from '../../public/node/output.js'\nimport {execa, ExecaChildProcess} from 'execa'\nimport {ReadStream} from 'tty'\nimport type {Writable, Readable} from 'stream'\n\nexport interface ExecOptions {\n cwd?: string\n env?: {[key: string]: string | undefined}\n stdin?: Readable | 'inherit'\n stdout?: Writable | 'inherit'\n stderr?: Writable | 'inherit'\n stdio?: 'inherit'\n input?: string\n signal?: AbortSignal\n // Custom handler if process exits with a non-zero code\n externalErrorHandler?: (error: unknown) => Promise<void>\n}\n\n/**\n * Opens a URL in the user's default browser.\n *\n * @param url - URL to open.\n */\nexport async function openURL(url: string): Promise<void> {\n const externalOpen = await import('open')\n await externalOpen.default(url)\n}\n\n/**\n * Runs a command asynchronously, aggregates the stdout data, and returns it.\n *\n * @param command - Command to be executed.\n * @param args - Arguments to pass to the command.\n * @param options - Optional settings for how to run the command.\n * @returns A promise that resolves with the aggregatted stdout of the command.\n */\nexport async function captureOutput(command: string, args: string[], options?: ExecOptions): Promise<string> {\n const result = await buildExec(command, args, options)\n return result.stdout\n}\n\n/**\n * Runs a command asynchronously.\n *\n * @param command - Command to be executed.\n * @param args - Arguments to pass to the command.\n * @param options - Optional settings for how to run the command.\n */\nexport async function exec(command: string, args: string[], options?: ExecOptions): Promise<void> {\n const commandProcess = buildExec(command, args, options)\n if (options?.stderr && options.stderr !== 'inherit') {\n commandProcess.stderr?.pipe(options.stderr, {end: false})\n }\n if (options?.stdout && options.stdout !== 'inherit') {\n commandProcess.stdout?.pipe(options.stdout, {end: false})\n }\n let aborted = false\n options?.signal?.addEventListener('abort', () => {\n const pid = commandProcess.pid\n if (pid) {\n outputDebug(`Killing process ${pid}: ${command} ${args.join(' ')}`)\n aborted = true\n treeKill(pid, 'SIGTERM')\n }\n })\n try {\n await commandProcess\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (processError: any) {\n // Windows will throw an error whenever the process is killed, no matter the reason.\n // The aborted flag tell use that we killed it, so we can ignore the error.\n if (aborted) return\n if (options?.externalErrorHandler) {\n await options?.externalErrorHandler(processError)\n } else {\n const abortError = new ExternalError(processError.message, command, args)\n abortError.stack = processError.stack\n throw abortError\n }\n }\n}\n\n/**\n * Runs a command asynchronously.\n *\n * @param command - Command to be executed.\n * @param args - Arguments to pass to the command.\n * @param options - Optional settings for how to run the command.\n * @returns A promise for a result with stdout and stderr properties.\n */\nfunction buildExec(command: string, args: string[], options?: ExecOptions): ExecaChildProcess<string> {\n const env = options?.env ?? process.env\n if (shouldDisplayColors()) {\n env.FORCE_COLOR = '1'\n }\n const commandProcess = execa(command, args, {\n env,\n cwd: options?.cwd,\n input: options?.input,\n stdio: options?.stdio,\n stdin: options?.stdin,\n stdout: options?.stdout === 'inherit' ? 'inherit' : undefined,\n stderr: options?.stderr === 'inherit' ? 'inherit' : undefined,\n // Setting this to false makes it possible to kill the main process\n // and all its sub-processes with Ctrl+C on Windows\n windowsHide: false,\n })\n outputDebug(`\nRunning system process:\n · Command: ${command} ${args.join(' ')}\n · Working directory: ${options?.cwd ?? cwd()}\n`)\n return commandProcess\n}\n\n/**\n * Waits for a given number of seconds.\n *\n * @param seconds - Number of seconds to wait.\n * @returns A Promise resolving after the number of seconds.\n */\nexport async function sleep(seconds: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(resolve, 1000 * seconds)\n })\n}\n\n/**\n * In case an standard input stream is passed check if it supports raw mode. Otherwise default standard input stream\n * will be used.\n *\n * @param stdin - The standard input stream to check.\n * @param env - Environmemnt variables.\n * @returns True in the selected input stream support raw mode.\n */\nexport function terminalSupportsRawMode(stdin?: ReadStream, env = process.env): boolean {\n if (isTruthy(env.CI)) {\n return false\n }\n if (stdin) return Boolean(stdin.isTTY)\n return process.stdin.isTTY\n}\n"]}
|
|
@@ -8,13 +8,13 @@ interface GetTCPPortOptions {
|
|
|
8
8
|
* @param preferredPort - Number of the preferred port to be used if available.
|
|
9
9
|
* @param options - Extra configuration for getting TCP ports.
|
|
10
10
|
* @returns A promise that resolves with an availabe port.
|
|
11
|
-
* @example
|
|
12
11
|
*/
|
|
13
12
|
export declare function getAvailableTCPPort(preferredPort?: number, options?: GetTCPPortOptions): Promise<number>;
|
|
14
13
|
/**
|
|
15
14
|
* Checks if a port is available.
|
|
16
15
|
*
|
|
17
16
|
* @param portNumber - The port number to check.
|
|
17
|
+
* @returns A promise that resolves with a boolean indicating if the port is available.
|
|
18
18
|
*/
|
|
19
19
|
export declare function checkPortAvailability(portNumber: number): Promise<boolean>;
|
|
20
20
|
export {};
|
package/dist/public/node/tcp.js
CHANGED
|
@@ -8,7 +8,6 @@ import * as port from 'get-port-please';
|
|
|
8
8
|
* @param preferredPort - Number of the preferred port to be used if available.
|
|
9
9
|
* @param options - Extra configuration for getting TCP ports.
|
|
10
10
|
* @returns A promise that resolves with an availabe port.
|
|
11
|
-
* @example
|
|
12
11
|
*/
|
|
13
12
|
export async function getAvailableTCPPort(preferredPort, options) {
|
|
14
13
|
if (preferredPort && (await checkPortAvailability(preferredPort))) {
|
|
@@ -24,6 +23,7 @@ export async function getAvailableTCPPort(preferredPort, options) {
|
|
|
24
23
|
* Checks if a port is available.
|
|
25
24
|
*
|
|
26
25
|
* @param portNumber - The port number to check.
|
|
26
|
+
* @returns A promise that resolves with a boolean indicating if the port is available.
|
|
27
27
|
*/
|
|
28
28
|
export async function checkPortAvailability(portNumber) {
|
|
29
29
|
return (await port.checkPort(portNumber)) === portNumber;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tcp.js","sourceRoot":"","sources":["../../../src/public/node/tcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,WAAW,EAAE,aAAa,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACnF,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AAOvC
|
|
1
|
+
{"version":3,"file":"tcp.js","sourceRoot":"","sources":["../../../src/public/node/tcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,WAAW,EAAE,aAAa,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACnF,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AAOvC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,aAAsB,EAAE,OAA2B;IAC3F,IAAI,aAAa,IAAI,CAAC,MAAM,qBAAqB,CAAC,aAAa,CAAC,CAAC,EAAE;QACjE,WAAW,CAAC,aAAa,CAAA,QAAQ,aAAa,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;QACpE,OAAO,aAAa,CAAA;KACrB;IACD,WAAW,CAAC,aAAa,CAAA,0BAA0B,CAAC,CAAA;IACpD,MAAM,UAAU,GAAG,MAAM,YAAY,CACnC,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,EACrC,OAAO,EAAE,QAAQ,EACjB,OAAO,EAAE,iBAAiB,CAC3B,CAAA;IACD,WAAW,CAAC,aAAa,CAAA,yBAAyB,WAAW,CAAC,GAAG,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,CAAC,CAAA;IACrF,OAAO,UAAU,CAAA;AACnB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,UAAkB;IAC5D,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,KAAK,UAAU,CAAA;AAC1D,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,YAAY,CAAI,OAAgB,EAAE,QAAQ,GAAG,CAAC,EAAE,iBAAiB,GAAG,CAAC;IAClF,IAAI,UAAU,GAAG,CAAC,CAAA;IAClB,OAAO,IAAI,EAAE;QACX,IAAI;YACF,4CAA4C;YAC5C,OAAO,MAAM,OAAO,EAAE,CAAA;YACtB,8DAA8D;SAC/D;QAAC,OAAO,KAAU,EAAE;YACnB,IAAI,UAAU,EAAE,GAAG,QAAQ,EAAE;gBAC3B,WAAW,CAAC,aAAa,CAAA,0CAA0C,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;gBACnF,4CAA4C;gBAC5C,MAAM,KAAK,CAAC,iBAAiB,CAAC,CAAA;aAC/B;iBAAM;gBACL,MAAM,IAAI,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;aACpC;SACF;KACF;AACH,CAAC","sourcesContent":["import {sleep} from './system.js'\nimport {AbortError} from './error.js'\nimport {outputDebug, outputContent, outputToken} from '../../public/node/output.js'\nimport * as port from 'get-port-please'\n\ninterface GetTCPPortOptions {\n waitTimeInSeconds?: number\n maxTries?: number\n}\n\n/**\n * Returns an available port in the current environment.\n *\n * @param preferredPort - Number of the preferred port to be used if available.\n * @param options - Extra configuration for getting TCP ports.\n * @returns A promise that resolves with an availabe port.\n */\nexport async function getAvailableTCPPort(preferredPort?: number, options?: GetTCPPortOptions): Promise<number> {\n if (preferredPort && (await checkPortAvailability(preferredPort))) {\n outputDebug(outputContent`Port ${preferredPort.toString()} is free`)\n return preferredPort\n }\n outputDebug(outputContent`Getting a random port...`)\n const randomPort = await retryOnError(\n () => port.getRandomPort('localhost'),\n options?.maxTries,\n options?.waitTimeInSeconds,\n )\n outputDebug(outputContent`Random port obtained: ${outputToken.raw(`${randomPort}`)}`)\n return randomPort\n}\n\n/**\n * Checks if a port is available.\n *\n * @param portNumber - The port number to check.\n * @returns A promise that resolves with a boolean indicating if the port is available.\n */\nexport async function checkPortAvailability(portNumber: number): Promise<boolean> {\n return (await port.checkPort(portNumber)) === portNumber\n}\n\n/**\n * Given a function, it runs it and retries in case of failiure up to the provided number of times.\n *\n * @param execute - The function to execute.\n * @param maxTries - The maximum retries.\n * @param waitTimeInSeconds - The time to wait between retries.\n */\nasync function retryOnError<T>(execute: () => T, maxTries = 5, waitTimeInSeconds = 1) {\n let retryCount = 1\n while (true) {\n try {\n // eslint-disable-next-line no-await-in-loop\n return await execute()\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (retryCount++ < maxTries) {\n outputDebug(outputContent`Unknown problem getting a random port: ${error.message}`)\n // eslint-disable-next-line no-await-in-loop\n await sleep(waitTimeInSeconds)\n } else {\n throw new AbortError(error.message)\n }\n }\n }\n}\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
2
|
/* eslint-disable jsdoc/require-throws */
|
|
3
|
-
/* eslint-disable jsdoc/require-returns */
|
|
4
3
|
/* eslint-disable no-restricted-imports */
|
|
5
4
|
import { outputDebug } from './output.js';
|
|
6
5
|
import { printEventsJson } from '../../private/node/demo-recorder.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-kill.js","sourceRoot":"","sources":["../../../src/public/node/tree-kill.ts"],"names":[],"m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CAAA;IAEF,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE;QAC/B,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;QAE/B,IAAI,IAAI,KAAK,CAAC,EAAE;YACd,2BAA2B;YAC3B,IAAI,aAAa,CAAC,IAAI,KAAK,CAAC,EAAE;gBAC5B,OAAO,EAAE,EAAE,CAAA;aACZ;YACD,OAAM;SACP;QAED,OAAO;aACJ,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC;aACX,OAAO,CAAC,UAAU,IAAI;YACrB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAA;YACzC,IAAI,KAAK,EAAE;gBACT,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAE,CAAA;gBACrB,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAE,CAAA;gBACrB,IAAI,CAAC,SAAS,CAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBAC1B,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;gBACd,WAAW,CAAC,mBAAmB,GAAG,KAAK,GAAG,EAAE,CAAC,CAAA;gBAC7C,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;gBACtB,gBAAgB,CAAC,GAAG,EAAE,IAAI,EAAE,aAAa,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAA;aACxE;QACH,CAAC,CAAC,CAAA;IACN,CAAC,CAAA;IAED,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACzB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n/* eslint-disable jsdoc/require-throws */\n/* eslint-disable jsdoc/require-returns */\n/* eslint-disable no-restricted-imports */\n\nimport {outputDebug} from './output.js'\nimport {printEventsJson} from '../../private/node/demo-recorder.js'\nimport {exec, spawn} from 'child_process'\n\ninterface ProcessTree {\n [key: string]: string[]\n}\n\ntype AfterKillCallback = (error?: Error) => void\n\n/**\n * Kills the process that calls the method and all its children.\n *\n * @param pid - Pid of the process to kill.\n * @param killSignal - Type of kill signal to be used.\n * @param killRoot - Whether to kill the root process.\n * @param callback - Optional callback to run after killing the processes.\n */\nexport function treeKill(\n pid: number | string = process.pid,\n killSignal = 'SIGTERM',\n killRoot = true,\n callback?: AfterKillCallback,\n): void {\n const after =\n callback ??\n ((error?: Error) => {\n if (error) outputDebug(`Failed to kill process ${pid}: ${error}`)\n })\n printEventsJson()\n adaptedTreeKill(pid, killSignal, killRoot, after)\n}\n\n/**\n * Adapted from https://github.com/pkrumins/node-tree-kill.\n *\n * Our implementation allows to skip killing the root process. This is useful for example when\n * gracefully exiting the 'dev' process, as the default tree-kill implementation will cause it\n * to exit with a non-zero code. Instead, we want to treat it as a graceful termination.\n * In addition, we also add debug logging for better visibility in what tree-kill is doing.\n *\n * @param pid - Pid of the process to kill.\n * @param killSignal - Type of kill signal to be used.\n * @param killRoot - Whether to kill the root process.\n * @param callback - Optional callback to run after killing the processes.\n */\nfunction adaptedTreeKill(\n pid: number | string,\n killSignal: string,\n killRoot: boolean,\n callback: (error?: Error) => void,\n): void {\n const rootPid = typeof pid === 'number' ? pid.toString() : pid\n\n if (Number.isNaN(rootPid)) {\n if (callback) {\n return callback(new Error('pid must be a number'))\n } else {\n throw new Error('pid must be a number')\n }\n }\n\n // A map from parent pid to an array of children pids\n const tree: ProcessTree = {}\n tree[rootPid] = []\n\n // A set of pids to visit. We use it to recursively find all the children pids\n const pidsToProcess: Set<string> = new Set()\n pidsToProcess.add(rootPid)\n\n switch (process.platform) {\n case 'win32':\n // @ts-ignore\n exec(`taskkill /pid ${pid} /T /F`, callback)\n break\n case 'darwin':\n buildProcessTree(\n rootPid,\n tree,\n pidsToProcess,\n function (parentPid: string) {\n return spawn('pgrep', ['-lfP', parentPid])\n },\n function () {\n killAll(tree, killSignal, rootPid, killRoot, callback)\n },\n )\n break\n // Linux\n default:\n buildProcessTree(\n rootPid,\n tree,\n pidsToProcess,\n function (parentPid: string) {\n return spawn('ps', ['-o', 'pid command', '--no-headers', '--ppid', parentPid])\n },\n function () {\n killAll(tree, killSignal, rootPid, killRoot, callback)\n },\n )\n break\n }\n}\n\n/**\n * Kills all processes in the process tree.\n *\n * @param tree - Process tree.\n * @param killSignal - Type of kill signal to be used.\n * @param rootPid - Pid of the root process.\n * @param killRoot - Whether to kill the root process.\n * @param callback - Optional callback to run after killing the processes.\n */\nfunction killAll(\n tree: ProcessTree,\n killSignal: string,\n rootPid: string,\n killRoot: boolean,\n callback: AfterKillCallback,\n): void {\n const killed: Set<string> = new Set()\n try {\n Object.keys(tree).forEach(function (pid) {\n tree[pid]!.forEach(function (pidpid) {\n if (!killed.has(pidpid)) {\n killPid(pidpid, killSignal)\n killed.add(pidpid)\n }\n })\n if (pid === rootPid && killRoot && !killed.has(pid)) {\n killPid(pid, killSignal)\n killed.add(pid)\n }\n })\n } catch (err: unknown) {\n if (callback) {\n // @ts-ignore\n return callback(err)\n } else {\n throw err\n }\n }\n if (callback) {\n return callback()\n }\n}\n\n/**\n * Kills a process.\n *\n * @param pid - Pid of the process to kill.\n * @param killSignal - Type of kill signal to be used.\n */\nfunction killPid(pid: string, killSignal: string) {\n try {\n process.kill(parseInt(pid, 10), killSignal)\n } catch (err) {\n // @ts-ignore\n if (err.code !== 'ESRCH') throw err\n }\n}\n\n/**\n * Builds a process tree.\n *\n * @param parentPid - Pid of the parent process.\n * @param tree - Process tree.\n * @param pidsToProcess - Pids to process.\n * @param spawnChildProcessesList - Function to spawn child processes.\n * @param cb - Callback to run after building the process tree.\n */\nfunction buildProcessTree(\n parentPid: string,\n tree: ProcessTree,\n pidsToProcess: Set<string>,\n spawnChildProcessesList: (parentPid: string) => ReturnType<typeof spawn>,\n cb: () => void,\n) {\n const ps = spawnChildProcessesList(parentPid)\n let allData = ''\n ps.stdout?.on('data', function (data: Buffer) {\n const dataStr = data.toString('ascii')\n allData += dataStr\n })\n\n const onClose = (code: number) => {\n pidsToProcess.delete(parentPid)\n\n if (code !== 0) {\n // no more parent processes\n if (pidsToProcess.size === 0) {\n return cb()\n }\n return\n }\n\n allData\n .trim()\n .split('\\n')\n .forEach(function (line) {\n const match = line.match(/^(\\d+)\\s(.*)$/)\n if (match) {\n const pid = match[1]!\n const cmd = match[2]!\n tree[parentPid]!.push(pid)\n tree[pid] = []\n outputDebug(`Killing process ${pid}: ${cmd}`)\n pidsToProcess.add(pid)\n buildProcessTree(pid, tree, pidsToProcess, spawnChildProcessesList, cb)\n }\n })\n }\n\n ps.on('close', onClose)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tree-kill.js","sourceRoot":"","sources":["../../../src/public/node/tree-kill.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,yCAAyC;AACzC,0CAA0C;AAE1C,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAA;AACvC,OAAO,EAAC,eAAe,EAAC,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAC,IAAI,EAAE,KAAK,EAAC,MAAM,eAAe,CAAA;AAQzC;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CACtB,MAAuB,OAAO,CAAC,GAAG,EAClC,UAAU,GAAG,SAAS,EACtB,QAAQ,GAAG,IAAI,EACf,QAA4B;IAE5B,MAAM,KAAK,GACT,QAAQ;QACR,CAAC,CAAC,KAAa,EAAE,EAAE;YACjB,IAAI,KAAK;gBAAE,WAAW,CAAC,0BAA0B,GAAG,KAAK,KAAK,EAAE,CAAC,CAAA;QACnE,CAAC,CAAC,CAAA;IACJ,eAAe,EAAE,CAAA;IACjB,eAAe,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAA;AACnD,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAS,eAAe,CACtB,GAAoB,EACpB,UAAkB,EAClB,QAAiB,EACjB,QAAiC;IAEjC,MAAM,OAAO,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CA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,EAAE,aAAa,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAA;aACxE;QACH,CAAC,CAAC,CAAA;IACN,CAAC,CAAA;IAED,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACzB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n/* eslint-disable jsdoc/require-throws */\n/* eslint-disable no-restricted-imports */\n\nimport {outputDebug} from './output.js'\nimport {printEventsJson} from '../../private/node/demo-recorder.js'\nimport {exec, spawn} from 'child_process'\n\ninterface ProcessTree {\n [key: string]: string[]\n}\n\ntype AfterKillCallback = (error?: Error) => void\n\n/**\n * Kills the process that calls the method and all its children.\n *\n * @param pid - Pid of the process to kill.\n * @param killSignal - Type of kill signal to be used.\n * @param killRoot - Whether to kill the root process.\n * @param callback - Optional callback to run after killing the processes.\n */\nexport function treeKill(\n pid: number | string = process.pid,\n killSignal = 'SIGTERM',\n killRoot = true,\n callback?: AfterKillCallback,\n): void {\n const after =\n callback ??\n ((error?: Error) => {\n if (error) outputDebug(`Failed to kill process ${pid}: ${error}`)\n })\n printEventsJson()\n adaptedTreeKill(pid, killSignal, killRoot, after)\n}\n\n/**\n * Adapted from https://github.com/pkrumins/node-tree-kill.\n *\n * Our implementation allows to skip killing the root process. This is useful for example when\n * gracefully exiting the 'dev' process, as the default tree-kill implementation will cause it\n * to exit with a non-zero code. Instead, we want to treat it as a graceful termination.\n * In addition, we also add debug logging for better visibility in what tree-kill is doing.\n *\n * @param pid - Pid of the process to kill.\n * @param killSignal - Type of kill signal to be used.\n * @param killRoot - Whether to kill the root process.\n * @param callback - Optional callback to run after killing the processes.\n */\nfunction adaptedTreeKill(\n pid: number | string,\n killSignal: string,\n killRoot: boolean,\n callback: (error?: Error) => void,\n): void {\n const rootPid = typeof pid === 'number' ? pid.toString() : pid\n\n if (Number.isNaN(rootPid)) {\n if (callback) {\n return callback(new Error('pid must be a number'))\n } else {\n throw new Error('pid must be a number')\n }\n }\n\n // A map from parent pid to an array of children pids\n const tree: ProcessTree = {}\n tree[rootPid] = []\n\n // A set of pids to visit. We use it to recursively find all the children pids\n const pidsToProcess: Set<string> = new Set()\n pidsToProcess.add(rootPid)\n\n switch (process.platform) {\n case 'win32':\n // @ts-ignore\n exec(`taskkill /pid ${pid} /T /F`, callback)\n break\n case 'darwin':\n buildProcessTree(\n rootPid,\n tree,\n pidsToProcess,\n function (parentPid: string) {\n return spawn('pgrep', ['-lfP', parentPid])\n },\n function () {\n killAll(tree, killSignal, rootPid, killRoot, callback)\n },\n )\n break\n // Linux\n default:\n buildProcessTree(\n rootPid,\n tree,\n pidsToProcess,\n function (parentPid: string) {\n return spawn('ps', ['-o', 'pid command', '--no-headers', '--ppid', parentPid])\n },\n function () {\n killAll(tree, killSignal, rootPid, killRoot, callback)\n },\n )\n break\n }\n}\n\n/**\n * Kills all processes in the process tree.\n *\n * @param tree - Process tree.\n * @param killSignal - Type of kill signal to be used.\n * @param rootPid - Pid of the root process.\n * @param killRoot - Whether to kill the root process.\n * @param callback - Optional callback to run after killing the processes.\n */\nfunction killAll(\n tree: ProcessTree,\n killSignal: string,\n rootPid: string,\n killRoot: boolean,\n callback: AfterKillCallback,\n): void {\n const killed: Set<string> = new Set()\n try {\n Object.keys(tree).forEach(function (pid) {\n tree[pid]!.forEach(function (pidpid) {\n if (!killed.has(pidpid)) {\n killPid(pidpid, killSignal)\n killed.add(pidpid)\n }\n })\n if (pid === rootPid && killRoot && !killed.has(pid)) {\n killPid(pid, killSignal)\n killed.add(pid)\n }\n })\n } catch (err: unknown) {\n if (callback) {\n // @ts-ignore\n return callback(err)\n } else {\n throw err\n }\n }\n if (callback) {\n return callback()\n }\n}\n\n/**\n * Kills a process.\n *\n * @param pid - Pid of the process to kill.\n * @param killSignal - Type of kill signal to be used.\n */\nfunction killPid(pid: string, killSignal: string) {\n try {\n process.kill(parseInt(pid, 10), killSignal)\n } catch (err) {\n // @ts-ignore\n if (err.code !== 'ESRCH') throw err\n }\n}\n\n/**\n * Builds a process tree.\n *\n * @param parentPid - Pid of the parent process.\n * @param tree - Process tree.\n * @param pidsToProcess - Pids to process.\n * @param spawnChildProcessesList - Function to spawn child processes.\n * @param cb - Callback to run after building the process tree.\n */\nfunction buildProcessTree(\n parentPid: string,\n tree: ProcessTree,\n pidsToProcess: Set<string>,\n spawnChildProcessesList: (parentPid: string) => ReturnType<typeof spawn>,\n cb: () => void,\n) {\n const ps = spawnChildProcessesList(parentPid)\n let allData = ''\n ps.stdout?.on('data', function (data: Buffer) {\n const dataStr = data.toString('ascii')\n allData += dataStr\n })\n\n const onClose = (code: number) => {\n pidsToProcess.delete(parentPid)\n\n if (code !== 0) {\n // no more parent processes\n if (pidsToProcess.size === 0) {\n return cb()\n }\n return\n }\n\n allData\n .trim()\n .split('\\n')\n .forEach(function (line) {\n const match = line.match(/^(\\d+)\\s(.*)$/)\n if (match) {\n const pid = match[1]!\n const cmd = match[2]!\n tree[parentPid]!.push(pid)\n tree[pid] = []\n outputDebug(`Killing process ${pid}: ${cmd}`)\n pidsToProcess.add(pid)\n buildProcessTree(pid, tree, pidsToProcess, spawnChildProcessesList, cb)\n }\n })\n }\n\n ps.on('close', onClose)\n}\n"]}
|
package/dist/public/node/ui.d.ts
CHANGED
|
@@ -27,9 +27,9 @@ export interface RenderConcurrentOptions extends PartialBy<ConcurrentOutputProps
|
|
|
27
27
|
/**
|
|
28
28
|
* Renders output from concurrent processes to the terminal with {@link ConcurrentOutput}.
|
|
29
29
|
* @example
|
|
30
|
-
* 00:00:00 │
|
|
31
|
-
* 00:00:00 │
|
|
32
|
-
* 00:00:00 │
|
|
30
|
+
* 00:00:00 │ backend │ first backend message
|
|
31
|
+
* 00:00:00 │ backend │ second backend message
|
|
32
|
+
* 00:00:00 │ backend │ third backend message
|
|
33
33
|
* 00:00:00 │ frontend │ first frontend message
|
|
34
34
|
* 00:00:00 │ frontend │ second frontend message
|
|
35
35
|
* 00:00:00 │ frontend │ third frontend message
|
|
@@ -375,6 +375,11 @@ export declare function renderText({ text, logLevel, logger }: RenderTextOptions
|
|
|
375
375
|
export declare const keypress: (stdin?: NodeJS.ReadStream & {
|
|
376
376
|
fd: 0;
|
|
377
377
|
}, uiDebugOptions?: UIDebugOptions) => Promise<unknown>;
|
|
378
|
+
interface IsTTYOptions {
|
|
379
|
+
stdin?: NodeJS.ReadStream;
|
|
380
|
+
uiDebugOptions?: UIDebugOptions;
|
|
381
|
+
}
|
|
382
|
+
export declare function isTTY({ stdin, uiDebugOptions }: IsTTYOptions): boolean;
|
|
378
383
|
export type Key = InkKey;
|
|
379
384
|
export type InfoMessage = InfoMessageProps['message'];
|
|
380
385
|
export { Task, TokenItem, InlineToken, LinkToken, TableColumn, InfoTableSection, ListToken, render, handleCtrlC };
|
package/dist/public/node/ui.js
CHANGED
|
@@ -24,9 +24,9 @@ const defaultUIDebugOptions = {
|
|
|
24
24
|
/**
|
|
25
25
|
* Renders output from concurrent processes to the terminal with {@link ConcurrentOutput}.
|
|
26
26
|
* @example
|
|
27
|
-
* 00:00:00 │
|
|
28
|
-
* 00:00:00 │
|
|
29
|
-
* 00:00:00 │
|
|
27
|
+
* 00:00:00 │ backend │ first backend message
|
|
28
|
+
* 00:00:00 │ backend │ second backend message
|
|
29
|
+
* 00:00:00 │ backend │ third backend message
|
|
30
30
|
* 00:00:00 │ frontend │ first frontend message
|
|
31
31
|
* 00:00:00 │ frontend │ second frontend message
|
|
32
32
|
* 00:00:00 │ frontend │ third frontend message
|
|
@@ -526,9 +526,12 @@ export const keypress = async (stdin = process.stdin, uiDebugOptions = defaultUI
|
|
|
526
526
|
});
|
|
527
527
|
});
|
|
528
528
|
};
|
|
529
|
+
export function isTTY({ stdin = undefined, uiDebugOptions = defaultUIDebugOptions }) {
|
|
530
|
+
return Boolean(uiDebugOptions.skipTTYCheck || stdin || terminalSupportsRawMode());
|
|
531
|
+
}
|
|
529
532
|
// eslint-disable-next-line max-params
|
|
530
533
|
function throwInNonTTY({ message, stdin = undefined }, uiDebugOptions) {
|
|
531
|
-
if (
|
|
534
|
+
if (isTTY({ stdin, uiDebugOptions }))
|
|
532
535
|
return;
|
|
533
536
|
const promptText = tokenItemToString(message);
|
|
534
537
|
const errorMessage = `Failed to prompt:
|