@shopify/cli-kit 3.57.1 → 3.58.1
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/session/exchange.js +7 -2
- package/dist/private/node/session/exchange.js.map +1 -1
- package/dist/private/node/ui/components/SelectInput.js +1 -3
- package/dist/private/node/ui/components/SelectInput.js.map +1 -1
- package/dist/public/common/array.d.ts +7 -0
- package/dist/public/common/array.js +11 -4
- package/dist/public/common/array.js.map +1 -1
- package/dist/public/common/collection.js +3 -5
- package/dist/public/common/collection.js.map +1 -1
- package/dist/public/common/function.js +3 -5
- package/dist/public/common/function.js.map +1 -1
- package/dist/public/common/lang.js +1 -3
- package/dist/public/common/lang.js.map +1 -1
- package/dist/public/common/object.d.ts +8 -1
- package/dist/public/common/object.js +19 -13
- package/dist/public/common/object.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/shopify-developers.d.ts +18 -0
- package/dist/public/node/api/shopify-developers.js +52 -0
- package/dist/public/node/api/shopify-developers.js.map +1 -0
- package/dist/public/node/base-command.d.ts +1 -0
- package/dist/public/node/base-command.js +5 -0
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/cli.js +7 -1
- package/dist/public/node/cli.js.map +1 -1
- package/dist/public/node/context/fqdn.d.ts +6 -0
- package/dist/public/node/context/fqdn.js +17 -0
- package/dist/public/node/context/fqdn.js.map +1 -1
- package/dist/public/node/context/spin.d.ts +13 -0
- package/dist/public/node/context/spin.js +42 -1
- package/dist/public/node/context/spin.js.map +1 -1
- package/dist/public/node/custom-oclif-loader.d.ts +6 -0
- package/dist/public/node/custom-oclif-loader.js +54 -0
- package/dist/public/node/custom-oclif-loader.js.map +1 -0
- package/dist/public/node/dot-env.d.ts +1 -0
- package/dist/public/node/dot-env.js +51 -9
- package/dist/public/node/dot-env.js.map +1 -1
- package/dist/public/node/error-handler.js +4 -1
- package/dist/public/node/error-handler.js.map +1 -1
- package/dist/public/node/fs.d.ts +11 -0
- package/dist/public/node/fs.js +11 -0
- package/dist/public/node/fs.js.map +1 -1
- package/dist/public/node/is-global.d.ts +8 -0
- package/dist/public/node/is-global.js +12 -0
- package/dist/public/node/is-global.js.map +1 -0
- package/dist/public/node/node-package-manager.js +2 -2
- package/dist/public/node/node-package-manager.js.map +1 -1
- package/dist/public/node/output.js +4 -0
- package/dist/public/node/output.js.map +1 -1
- package/dist/public/node/ruby.js +5 -5
- package/dist/public/node/ruby.js.map +1 -1
- package/dist/public/node/themes/api.d.ts +3 -3
- package/dist/public/node/themes/api.js +1 -4
- package/dist/public/node/themes/api.js.map +1 -1
- package/dist/public/node/themes/factories.d.ts +8 -5
- package/dist/public/node/themes/factories.js +16 -9
- package/dist/public/node/themes/factories.js.map +1 -1
- package/dist/public/node/themes/theme-manager.d.ts +2 -1
- package/dist/public/node/themes/theme-manager.js +3 -3
- package/dist/public/node/themes/theme-manager.js.map +1 -1
- package/dist/public/node/themes/types.d.ts +15 -11
- package/dist/public/node/themes/types.js +5 -1
- package/dist/public/node/themes/types.js.map +1 -1
- package/dist/public/node/themes/utils.d.ts +3 -0
- package/dist/public/node/themes/utils.js +2 -0
- package/dist/public/node/themes/utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -2
- package/dist/private/node/error-handler.d.ts +0 -2
- package/dist/private/node/error-handler.js +0 -5
- package/dist/private/node/error-handler.js.map +0 -1
- package/dist/private/node/semver.d.ts +0 -3
- package/dist/private/node/semver.js +0 -6
- package/dist/private/node/semver.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../../src/public/node/output.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,oBAAoB,CAAA;AAGxD,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,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E,aAAa,CAAC,EAAE;QAClD,OAAO,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;KACjC;SAAM;QACL,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;KAC7B;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CAAC,cAA0C,EAAE,OAAe;IACpG,MAAM,cAAc,GAAG,cAAc,OAAO,aAAa,CAAA;IACzD,IAAI,CAAC,cAAc,IAAI,cAAc,KAAK,SAAS;QAAE,OAAO,cAAc,CAAA;IAE1E,MAAM,aAAa,GAAG,WAAW,CAAC,iBAAiB,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAA;IACtF,OAAO,aAAa,CAAA,GAAG,cAAc,QAAQ,aAAa,EAAE,CAAC,KAAK,CAAA;AACpE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,IAAY;IACvD,MAAM,cAAc,GAAG,GAAG,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAA;IAC/E,OAAO,aAAa,CAAA,GAAG,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAA;AAC7E,CAAC;AAED,8BAA8B","sourcesContent":["/* eslint-disable no-console */\nimport {isUnitTest, isVerbose} from './context/local.js'\nimport {PackageManager} from './node-package-manager.js'\nimport {AbortSignal} from './abort.js'\nimport colors from './colors.js'\nimport {isTruthy} from './context/utilities.js'\nimport {TokenItem} from './ui.js'\nimport {\n ColorContentToken,\n CommandContentToken,\n ContentToken,\n ErrorContentToken,\n HeadingContentToken,\n ItalicContentToken,\n JsonContentToken,\n LinesDiffContentToken,\n LinkContentToken,\n PathContentToken,\n RawContentToken,\n SubHeadingContentToken,\n} from '../../private/node/content-tokens.js'\nimport {recordUIEvent} from '../../private/node/demo-recorder.js'\nimport {tokenItemToString} from '../../private/node/ui/components/TokenizedText.js'\nimport stripAnsi from 'strip-ansi'\nimport {Writable} from 'stream'\nimport type {Change} from 'diff'\n\nexport type Logger = Writable | ((message: string, logLevel?: LogLevel) => void)\n\nexport class TokenizedString {\n value: string\n constructor(value: string) {\n this.value = value\n }\n}\n\nexport type OutputMessage = string | TokenizedString\n\nexport const outputToken = {\n raw(value: string): RawContentToken {\n return new RawContentToken(value)\n },\n genericShellCommand(value: OutputMessage): CommandContentToken {\n return new CommandContentToken(value)\n },\n json(value: unknown): JsonContentToken {\n return new JsonContentToken(value)\n },\n path(value: OutputMessage): PathContentToken {\n return new PathContentToken(value)\n },\n link(value: OutputMessage, link: string): LinkContentToken {\n return new LinkContentToken(value, link)\n },\n heading(value: OutputMessage): HeadingContentToken {\n return new HeadingContentToken(value)\n },\n subheading(value: OutputMessage): SubHeadingContentToken {\n return new SubHeadingContentToken(value)\n },\n italic(value: OutputMessage): ItalicContentToken {\n return new ItalicContentToken(value)\n },\n errorText(value: OutputMessage): ErrorContentToken {\n return new ErrorContentToken(value)\n },\n cyan(value: OutputMessage): ColorContentToken {\n return new ColorContentToken(value, colors.cyan)\n },\n yellow(value: OutputMessage): ColorContentToken {\n return new ColorContentToken(value, colors.yellow)\n },\n magenta(value: OutputMessage): ColorContentToken {\n return new ColorContentToken(value, colors.magenta)\n },\n green(value: OutputMessage): ColorContentToken {\n return new ColorContentToken(value, colors.green)\n },\n packagejsonScript(packageManager: PackageManager, scriptName: string, ...scriptArgs: string[]): CommandContentToken {\n return new CommandContentToken(formatPackageManagerCommand(packageManager, scriptName, ...scriptArgs))\n },\n successIcon(): ColorContentToken {\n return new ColorContentToken('✔', colors.green)\n },\n failIcon(): ErrorContentToken {\n return new ErrorContentToken('✖')\n },\n linesDiff(value: Change[]): LinesDiffContentToken {\n return new LinesDiffContentToken(value)\n },\n}\n\n/**\n * Given a command and its arguments, it formats it depending on the package manager.\n *\n * @param packageManager - The package manager to use (pnpm, npm, yarn).\n * @param scriptName - The name of the script to run.\n * @param scriptArgs - The arguments to pass to the script.\n * @returns The formatted command.\n */\nexport function formatPackageManagerCommand(\n packageManager: PackageManager,\n scriptName: string,\n ...scriptArgs: string[]\n): string {\n switch (packageManager) {\n case 'pnpm':\n case 'bun':\n case 'yarn': {\n const pieces = [packageManager, scriptName, ...scriptArgs]\n return pieces.join(' ')\n }\n case 'npm': {\n const pieces = ['npm', 'run', scriptName]\n if (scriptArgs.length > 0) {\n pieces.push('--')\n pieces.push(...scriptArgs)\n }\n return pieces.join(' ')\n }\n case 'unknown': {\n const pieces = [scriptName, ...scriptArgs]\n return pieces.join(' ')\n }\n }\n}\n\n/**\n * Creates a tokenized string from an array of strings and tokens.\n *\n * @param strings - The strings to join.\n * @param keys - Array of tokens or strings to join.\n * @returns The tokenized string.\n */\nexport function outputContent(\n strings: TemplateStringsArray,\n ...keys: (ContentToken<unknown> | string)[]\n): TokenizedString {\n let output = ``\n strings.forEach((string, i) => {\n output += string\n if (i >= keys.length) {\n return\n }\n const token = keys[i]!\n\n if (typeof token === 'string') {\n output += token\n } else {\n const enumTokenOutput = token.output()\n\n if (Array.isArray(enumTokenOutput)) {\n enumTokenOutput.forEach((line: string) => {\n output += line\n })\n } else {\n output += enumTokenOutput\n }\n }\n })\n return new TokenizedString(output)\n}\n\n/** Log levels. */\nexport type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent'\n\n/**\n * It maps a level to a numeric value.\n *\n * @param level - The level for which we'll return its numeric value.\n * @returns The numeric value of the level.\n */\nfunction logLevelValue(level: LogLevel): number {\n switch (level) {\n case 'trace':\n return 10\n case 'debug':\n return 20\n case 'info':\n return 30\n case 'warn':\n return 40\n case 'error':\n return 50\n case 'fatal':\n return 60\n default:\n return 30\n }\n}\n\n/**\n * It returns the current log level (debug or info).\n *\n * @returns The log level set by the user.\n */\nfunction currentLogLevel(): LogLevel {\n if (isVerbose()) {\n return 'debug'\n } else {\n return 'info'\n }\n}\n\n/**\n * It checks if the message should be outputted or not.\n *\n * @param logLevel - The desired log level for the message.\n * @returns True if the message should be outputted, false otherwise.\n */\nfunction shouldOutput(logLevel: LogLevel): boolean {\n if (isUnitTest()) {\n return false\n }\n const currentLogLevelValue = logLevelValue(currentLogLevel())\n const messageLogLevelValue = logLevelValue(logLevel)\n return messageLogLevelValue >= currentLogLevelValue\n}\n\n// eslint-disable-next-line import/no-mutable-exports\nexport let collectedLogs: {[key: string]: string[]} = {}\n\n/**\n * This is only used during UnitTesting.\n * If we are in a testing context, instead of printing the logs to the console,\n * we will store them in a variable that can be accessed from the tests.\n *\n * @param key - The key of the log.\n * @param content - The content of the log.\n */\nexport function collectLog(key: string, content: OutputMessage): void {\n const output = collectedLogs.output ?? []\n const data = collectedLogs[key] ?? []\n data.push(stripAnsi(stringifyMessage(content) ?? ''))\n output.push(stripAnsi(stringifyMessage(content) ?? ''))\n collectedLogs[key] = data\n collectedLogs.output = output\n}\n\nexport const clearCollectedLogs = (): void => {\n // console.log('clearCollectLogs')\n collectedLogs = {}\n // console.log(collectedLogs)\n}\n\n/**\n * Ouputs information to the user.\n * Info messages don't get additional formatting.\n * Note: Info messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputInfo(content: OutputMessage, logger: Logger = consoleLog): void {\n const message = stringifyMessage(content)\n if (isUnitTest()) collectLog('info', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a success message to the user.\n * Success messages receive a special formatting to make them stand out in the console.\n * Note: Success messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputSuccess(content: OutputMessage, logger: Logger = consoleLog): void {\n const message = colors.bold(`✅ Success! ${stringifyMessage(content)}.`)\n if (isUnitTest()) collectLog('success', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a completed message to the user.\n * Completed message receive a special formatting to make them stand out in the console.\n * Note: Completed messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputCompleted(content: OutputMessage, logger: Logger = consoleLog): void {\n const message = `${colors.green('✔')} ${stringifyMessage(content)}`\n if (isUnitTest()) collectLog('completed', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Ouputs debug information to the user. By default these output is hidden unless the user calls the CLI with --verbose.\n * Debug messages don't get additional formatting.\n * Note: Debug messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputDebug(content: OutputMessage, logger: Logger = consoleLog): void {\n if (isUnitTest()) collectLog('debug', content)\n const message = colors.gray(stringifyMessage(content))\n outputWhereAppropriate('debug', logger, `${new Date().toISOString()}: ${message}`)\n}\n\n/**\n * Outputs a warning message to the user.\n * Warning messages receive a special formatting to make them stand out in the console.\n * Note: Warning messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputWarn(content: OutputMessage, logger: Logger = consoleWarn): void {\n if (isUnitTest()) collectLog('warn', content)\n const message = colors.yellow(stringifyMessage(content))\n outputWhereAppropriate('warn', logger, message)\n}\n\n/**\n * Prints a new line in the terminal.\n */\nexport function outputNewline(): void {\n console.log()\n}\n\n/**\n * Converts a Message to string.\n *\n * @param message - The message to convert to string.\n * @returns The string representation of the message.\n */\nexport function stringifyMessage(message: OutputMessage): string {\n if (message instanceof TokenizedString) {\n return message.value\n } else {\n return message\n }\n}\n\n/**\n * Convert a TokenItem to string.\n *\n * @param item - The item to convert to string.\n * @returns The string representation of the item.\n */\nexport function itemToString(item: TokenItem): string {\n return tokenItemToString(item)\n}\n\nexport interface OutputProcess {\n /**\n * The prefix to include in the logs\n * [vite] Output coming from Vite.\n */\n prefix: string\n /**\n * A callback to invoke the process. Stdout and stderr should be used\n * to send standard output and error data that gets formatted with the\n * right prefix.\n */\n action: (stdout: Writable, stderr: Writable, signal: AbortSignal) => Promise<void>\n}\n\n/**\n * Prints a log message in the console.\n *\n * @param message - The message to print.\n */\nexport function consoleLog(message: string): void {\n console.log(withOrWithoutStyle(message))\n}\n\n/**\n * Prints an error message in the console.\n *\n * @param message - The message to print.\n */\nexport function consoleError(message: string): void {\n console.error(withOrWithoutStyle(message))\n}\n\n/**\n * Prints a warning message in the console.\n *\n * @param message - The message to print.\n */\nexport function consoleWarn(message: string): void {\n console.warn(withOrWithoutStyle(message))\n}\n\ninterface OutputWhereAppropriateOptions {\n skipUIEvent?: boolean\n}\n\n/**\n * Writes a message to the appropiated logger.\n *\n * @param logLevel - The log level to use to determine if the message should be output.\n * @param logger - The logger to use to output the message.\n * @param message - The message to output.\n * @param options - Additional options.\n */\nexport function outputWhereAppropriate(\n logLevel: LogLevel,\n logger: Logger,\n message: string,\n options: OutputWhereAppropriateOptions = {skipUIEvent: false},\n): void {\n if (shouldOutput(logLevel)) {\n if (logger instanceof Writable) {\n logger.write(message)\n } else {\n logger(message, logLevel)\n }\n if (!options?.skipUIEvent) recordUIEvent({type: 'output', properties: {content: message}})\n }\n}\n\n/**\n * Returns a colored or uncolored version of a message, depending on the environment.\n *\n * @param message - The message to color or not.\n * @returns The message with or without colors.\n */\nfunction withOrWithoutStyle(message: string): string {\n if (shouldDisplayColors()) {\n return message\n } else {\n return unstyled(message)\n }\n}\n\n/**\n * Returns a message without styles (colors or any ANSI escape codes).\n *\n * @param message - The message to remove styles from.\n * @returns The message without styles.\n */\nexport function unstyled(message: string): string {\n return stripAnsi(message)\n}\n\n/**\n * Checks if the console outputs should display colors or not.\n *\n * @param _process - Optional, the process-like object to use to check if the console should display colors. Defaults to the global process.\n * @returns True if the console outputs should display colors, false otherwise.\n */\nexport function shouldDisplayColors(_process = process): boolean {\n const {env, stdout} = _process\n if (Object.hasOwnProperty.call(env, 'FORCE_COLOR')) {\n return isTruthy(env.FORCE_COLOR)\n } else {\n return Boolean(stdout.isTTY)\n }\n}\n\n/**\n * Generates a message to remind the user to update the CLI.\n *\n * @param packageManager - The package manager that is being used.\n * @param version - The version to update to.\n * @returns The message to remind the user to update the CLI.\n */\nexport function getOutputUpdateCLIReminder(packageManager: PackageManager | undefined, version: string): string {\n const versionMessage = `💡 Version ${version} available!`\n if (!packageManager || packageManager === 'unknown') return versionMessage\n\n const updateCommand = outputToken.packagejsonScript(packageManager, 'shopify upgrade')\n return outputContent`${versionMessage} Run ${updateCommand}`.value\n}\n\n/**\n * Parse title and body to be a single formatted string.\n *\n * @param title - The title of the message. Will be formatted as a heading.\n * @param body - The body of the message. Will respect the original formatting.\n * @returns The formatted message.\n */\nexport function formatSection(title: string, body: string): string {\n const formattedTitle = `${title.toUpperCase()}${' '.repeat(35 - title.length)}`\n return outputContent`${outputToken.heading(formattedTitle)}\\n${body}`.value\n}\n\n/* eslint-enable no-console */\n"]}
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../../src/public/node/output.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,oBAAoB,CAAA;AAExD,OAAO,EAAC,sBAAsB,EAAC,MAAM,gBAAgB,CAAA;AAErD,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAE/C,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EAEnB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,sBAAsB,GACvB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EAAC,aAAa,EAAC,MAAM,qCAAqC,CAAA;AACjE,OAAO,EAAC,iBAAiB,EAAC,MAAM,mDAAmD,CAAA;AACnF,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,EAAC,QAAQ,EAAC,MAAM,QAAQ,CAAA;AAK/B,MAAM,OAAO,eAAe;IAE1B,YAAY,KAAa;QACvB,IAAI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a,GAAG,WAAW,CAAC,iBAAiB,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAA;IACtF,OAAO,aAAa,CAAA,GAAG,cAAc,QAAQ,aAAa,EAAE,CAAC,KAAK,CAAA;AACpE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,IAAY;IACvD,MAAM,cAAc,GAAG,GAAG,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAA;IAC/E,OAAO,aAAa,CAAA,GAAG,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAA;AAC7E,CAAC;AAED,8BAA8B","sourcesContent":["/* eslint-disable no-console */\nimport {isUnitTest, isVerbose} from './context/local.js'\nimport {PackageManager} from './node-package-manager.js'\nimport {currentProcessIsGlobal} from './is-global.js'\nimport {AbortSignal} from './abort.js'\nimport colors from './colors.js'\nimport {isTruthy} from './context/utilities.js'\nimport {TokenItem} from './ui.js'\nimport {\n ColorContentToken,\n CommandContentToken,\n ContentToken,\n ErrorContentToken,\n HeadingContentToken,\n ItalicContentToken,\n JsonContentToken,\n LinesDiffContentToken,\n LinkContentToken,\n PathContentToken,\n RawContentToken,\n SubHeadingContentToken,\n} from '../../private/node/content-tokens.js'\nimport {recordUIEvent} from '../../private/node/demo-recorder.js'\nimport {tokenItemToString} from '../../private/node/ui/components/TokenizedText.js'\nimport stripAnsi from 'strip-ansi'\nimport {Writable} from 'stream'\nimport type {Change} from 'diff'\n\nexport type Logger = Writable | ((message: string, logLevel?: LogLevel) => void)\n\nexport class TokenizedString {\n value: string\n constructor(value: string) {\n this.value = value\n }\n}\n\nexport type OutputMessage = string | TokenizedString\n\nexport const outputToken = {\n raw(value: string): RawContentToken {\n return new RawContentToken(value)\n },\n genericShellCommand(value: OutputMessage): CommandContentToken {\n return new CommandContentToken(value)\n },\n json(value: unknown): JsonContentToken {\n return new JsonContentToken(value)\n },\n path(value: OutputMessage): PathContentToken {\n return new PathContentToken(value)\n },\n link(value: OutputMessage, link: string): LinkContentToken {\n return new LinkContentToken(value, link)\n },\n heading(value: OutputMessage): HeadingContentToken {\n return new HeadingContentToken(value)\n },\n subheading(value: OutputMessage): SubHeadingContentToken {\n return new SubHeadingContentToken(value)\n },\n italic(value: OutputMessage): ItalicContentToken {\n return new ItalicContentToken(value)\n },\n errorText(value: OutputMessage): ErrorContentToken {\n return new ErrorContentToken(value)\n },\n cyan(value: OutputMessage): ColorContentToken {\n return new ColorContentToken(value, colors.cyan)\n },\n yellow(value: OutputMessage): ColorContentToken {\n return new ColorContentToken(value, colors.yellow)\n },\n magenta(value: OutputMessage): ColorContentToken {\n return new ColorContentToken(value, colors.magenta)\n },\n green(value: OutputMessage): ColorContentToken {\n return new ColorContentToken(value, colors.green)\n },\n packagejsonScript(packageManager: PackageManager, scriptName: string, ...scriptArgs: string[]): CommandContentToken {\n return new CommandContentToken(formatPackageManagerCommand(packageManager, scriptName, ...scriptArgs))\n },\n successIcon(): ColorContentToken {\n return new ColorContentToken('✔', colors.green)\n },\n failIcon(): ErrorContentToken {\n return new ErrorContentToken('✖')\n },\n linesDiff(value: Change[]): LinesDiffContentToken {\n return new LinesDiffContentToken(value)\n },\n}\n\n/**\n * Given a command and its arguments, it formats it depending on the package manager.\n *\n * @param packageManager - The package manager to use (pnpm, npm, yarn).\n * @param scriptName - The name of the script to run.\n * @param scriptArgs - The arguments to pass to the script.\n * @returns The formatted command.\n */\nexport function formatPackageManagerCommand(\n packageManager: PackageManager,\n scriptName: string,\n ...scriptArgs: string[]\n): string {\n if (currentProcessIsGlobal()) {\n return [scriptName, ...scriptArgs].join(' ')\n }\n switch (packageManager) {\n case 'pnpm':\n case 'bun':\n case 'yarn': {\n const pieces = [packageManager, scriptName, ...scriptArgs]\n return pieces.join(' ')\n }\n case 'npm': {\n const pieces = ['npm', 'run', scriptName]\n if (scriptArgs.length > 0) {\n pieces.push('--')\n pieces.push(...scriptArgs)\n }\n return pieces.join(' ')\n }\n case 'unknown': {\n const pieces = [scriptName, ...scriptArgs]\n return pieces.join(' ')\n }\n }\n}\n\n/**\n * Creates a tokenized string from an array of strings and tokens.\n *\n * @param strings - The strings to join.\n * @param keys - Array of tokens or strings to join.\n * @returns The tokenized string.\n */\nexport function outputContent(\n strings: TemplateStringsArray,\n ...keys: (ContentToken<unknown> | string)[]\n): TokenizedString {\n let output = ``\n strings.forEach((string, i) => {\n output += string\n if (i >= keys.length) {\n return\n }\n const token = keys[i]!\n\n if (typeof token === 'string') {\n output += token\n } else {\n const enumTokenOutput = token.output()\n\n if (Array.isArray(enumTokenOutput)) {\n enumTokenOutput.forEach((line: string) => {\n output += line\n })\n } else {\n output += enumTokenOutput\n }\n }\n })\n return new TokenizedString(output)\n}\n\n/** Log levels. */\nexport type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent'\n\n/**\n * It maps a level to a numeric value.\n *\n * @param level - The level for which we'll return its numeric value.\n * @returns The numeric value of the level.\n */\nfunction logLevelValue(level: LogLevel): number {\n switch (level) {\n case 'trace':\n return 10\n case 'debug':\n return 20\n case 'info':\n return 30\n case 'warn':\n return 40\n case 'error':\n return 50\n case 'fatal':\n return 60\n default:\n return 30\n }\n}\n\n/**\n * It returns the current log level (debug or info).\n *\n * @returns The log level set by the user.\n */\nfunction currentLogLevel(): LogLevel {\n if (isVerbose()) {\n return 'debug'\n } else {\n return 'info'\n }\n}\n\n/**\n * It checks if the message should be outputted or not.\n *\n * @param logLevel - The desired log level for the message.\n * @returns True if the message should be outputted, false otherwise.\n */\nfunction shouldOutput(logLevel: LogLevel): boolean {\n if (isUnitTest()) {\n return false\n }\n const currentLogLevelValue = logLevelValue(currentLogLevel())\n const messageLogLevelValue = logLevelValue(logLevel)\n return messageLogLevelValue >= currentLogLevelValue\n}\n\n// eslint-disable-next-line import/no-mutable-exports\nexport let collectedLogs: {[key: string]: string[]} = {}\n\n/**\n * This is only used during UnitTesting.\n * If we are in a testing context, instead of printing the logs to the console,\n * we will store them in a variable that can be accessed from the tests.\n *\n * @param key - The key of the log.\n * @param content - The content of the log.\n */\nexport function collectLog(key: string, content: OutputMessage): void {\n const output = collectedLogs.output ?? []\n const data = collectedLogs[key] ?? []\n data.push(stripAnsi(stringifyMessage(content) ?? ''))\n output.push(stripAnsi(stringifyMessage(content) ?? ''))\n collectedLogs[key] = data\n collectedLogs.output = output\n}\n\nexport const clearCollectedLogs = (): void => {\n // console.log('clearCollectLogs')\n collectedLogs = {}\n // console.log(collectedLogs)\n}\n\n/**\n * Ouputs information to the user.\n * Info messages don't get additional formatting.\n * Note: Info messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputInfo(content: OutputMessage, logger: Logger = consoleLog): void {\n const message = stringifyMessage(content)\n if (isUnitTest()) collectLog('info', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a success message to the user.\n * Success messages receive a special formatting to make them stand out in the console.\n * Note: Success messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputSuccess(content: OutputMessage, logger: Logger = consoleLog): void {\n const message = colors.bold(`✅ Success! ${stringifyMessage(content)}.`)\n if (isUnitTest()) collectLog('success', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a completed message to the user.\n * Completed message receive a special formatting to make them stand out in the console.\n * Note: Completed messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputCompleted(content: OutputMessage, logger: Logger = consoleLog): void {\n const message = `${colors.green('✔')} ${stringifyMessage(content)}`\n if (isUnitTest()) collectLog('completed', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Ouputs debug information to the user. By default these output is hidden unless the user calls the CLI with --verbose.\n * Debug messages don't get additional formatting.\n * Note: Debug messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputDebug(content: OutputMessage, logger: Logger = consoleLog): void {\n if (isUnitTest()) collectLog('debug', content)\n const message = colors.gray(stringifyMessage(content))\n outputWhereAppropriate('debug', logger, `${new Date().toISOString()}: ${message}`)\n}\n\n/**\n * Outputs a warning message to the user.\n * Warning messages receive a special formatting to make them stand out in the console.\n * Note: Warning messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputWarn(content: OutputMessage, logger: Logger = consoleWarn): void {\n if (isUnitTest()) collectLog('warn', content)\n const message = colors.yellow(stringifyMessage(content))\n outputWhereAppropriate('warn', logger, message)\n}\n\n/**\n * Prints a new line in the terminal.\n */\nexport function outputNewline(): void {\n console.log()\n}\n\n/**\n * Converts a Message to string.\n *\n * @param message - The message to convert to string.\n * @returns The string representation of the message.\n */\nexport function stringifyMessage(message: OutputMessage): string {\n if (message instanceof TokenizedString) {\n return message.value\n } else {\n return message\n }\n}\n\n/**\n * Convert a TokenItem to string.\n *\n * @param item - The item to convert to string.\n * @returns The string representation of the item.\n */\nexport function itemToString(item: TokenItem): string {\n return tokenItemToString(item)\n}\n\nexport interface OutputProcess {\n /**\n * The prefix to include in the logs\n * [vite] Output coming from Vite.\n */\n prefix: string\n /**\n * A callback to invoke the process. Stdout and stderr should be used\n * to send standard output and error data that gets formatted with the\n * right prefix.\n */\n action: (stdout: Writable, stderr: Writable, signal: AbortSignal) => Promise<void>\n}\n\n/**\n * Prints a log message in the console.\n *\n * @param message - The message to print.\n */\nexport function consoleLog(message: string): void {\n console.log(withOrWithoutStyle(message))\n}\n\n/**\n * Prints an error message in the console.\n *\n * @param message - The message to print.\n */\nexport function consoleError(message: string): void {\n console.error(withOrWithoutStyle(message))\n}\n\n/**\n * Prints a warning message in the console.\n *\n * @param message - The message to print.\n */\nexport function consoleWarn(message: string): void {\n console.warn(withOrWithoutStyle(message))\n}\n\ninterface OutputWhereAppropriateOptions {\n skipUIEvent?: boolean\n}\n\n/**\n * Writes a message to the appropiated logger.\n *\n * @param logLevel - The log level to use to determine if the message should be output.\n * @param logger - The logger to use to output the message.\n * @param message - The message to output.\n * @param options - Additional options.\n */\nexport function outputWhereAppropriate(\n logLevel: LogLevel,\n logger: Logger,\n message: string,\n options: OutputWhereAppropriateOptions = {skipUIEvent: false},\n): void {\n if (shouldOutput(logLevel)) {\n if (logger instanceof Writable) {\n logger.write(message)\n } else {\n logger(message, logLevel)\n }\n if (!options?.skipUIEvent) recordUIEvent({type: 'output', properties: {content: message}})\n }\n}\n\n/**\n * Returns a colored or uncolored version of a message, depending on the environment.\n *\n * @param message - The message to color or not.\n * @returns The message with or without colors.\n */\nfunction withOrWithoutStyle(message: string): string {\n if (shouldDisplayColors()) {\n return message\n } else {\n return unstyled(message)\n }\n}\n\n/**\n * Returns a message without styles (colors or any ANSI escape codes).\n *\n * @param message - The message to remove styles from.\n * @returns The message without styles.\n */\nexport function unstyled(message: string): string {\n return stripAnsi(message)\n}\n\n/**\n * Checks if the console outputs should display colors or not.\n *\n * @param _process - Optional, the process-like object to use to check if the console should display colors. Defaults to the global process.\n * @returns True if the console outputs should display colors, false otherwise.\n */\nexport function shouldDisplayColors(_process = process): boolean {\n const {env, stdout} = _process\n if (Object.hasOwnProperty.call(env, 'FORCE_COLOR')) {\n return isTruthy(env.FORCE_COLOR)\n } else {\n return Boolean(stdout.isTTY)\n }\n}\n\n/**\n * Generates a message to remind the user to update the CLI.\n *\n * @param packageManager - The package manager that is being used.\n * @param version - The version to update to.\n * @returns The message to remind the user to update the CLI.\n */\nexport function getOutputUpdateCLIReminder(packageManager: PackageManager | undefined, version: string): string {\n const versionMessage = `💡 Version ${version} available!`\n if (!packageManager || packageManager === 'unknown') return versionMessage\n\n const updateCommand = outputToken.packagejsonScript(packageManager, 'shopify upgrade')\n return outputContent`${versionMessage} Run ${updateCommand}`.value\n}\n\n/**\n * Parse title and body to be a single formatted string.\n *\n * @param title - The title of the message. Will be formatted as a heading.\n * @param body - The body of the message. Will respect the original formatting.\n * @returns The formatted message.\n */\nexport function formatSection(title: string, body: string): string {\n const formattedTitle = `${title.toUpperCase()}${' '.repeat(35 - title.length)}`\n return outputContent`${outputToken.heading(formattedTitle)}\\n${body}`.value\n}\n\n/* eslint-enable no-console */\n"]}
|
package/dist/public/node/ruby.js
CHANGED
|
@@ -10,8 +10,8 @@ import { outputContent, outputToken } from './output.js';
|
|
|
10
10
|
import { isTruthy } from './context/utilities.js';
|
|
11
11
|
import { runWithTimer } from './metadata.js';
|
|
12
12
|
import { pathConstants } from '../../private/node/constants.js';
|
|
13
|
-
import { coerceSemverVersion } from '../../private/node/semver.js';
|
|
14
13
|
import { CLI_KIT_VERSION } from '../common/version.js';
|
|
14
|
+
import { coerce } from 'semver';
|
|
15
15
|
import envPaths from 'env-paths';
|
|
16
16
|
import { fileURLToPath } from 'url';
|
|
17
17
|
export const RubyCLIVersion = '2.35.0';
|
|
@@ -102,7 +102,7 @@ async function validateRuby() {
|
|
|
102
102
|
let version;
|
|
103
103
|
try {
|
|
104
104
|
const stdout = await captureOutput(rubyExecutable(), ['-v']);
|
|
105
|
-
version =
|
|
105
|
+
version = coerce(stdout);
|
|
106
106
|
}
|
|
107
107
|
catch {
|
|
108
108
|
throw new AbortError('Ruby environment not found', `Make sure you have Ruby installed on your system. ${outputContent `${outputToken.link('Documentation.', 'https://www.ruby-lang.org/en/documentation/installation/')}`
|
|
@@ -110,7 +110,7 @@ async function validateRuby() {
|
|
|
110
110
|
}
|
|
111
111
|
const isValid = version?.compare(MinRubyVersion);
|
|
112
112
|
if (isValid === -1 || isValid === undefined) {
|
|
113
|
-
throw new AbortError(`Ruby version ${outputContent `${outputToken.yellow(version
|
|
113
|
+
throw new AbortError(`Ruby version ${outputContent `${outputToken.yellow(version?.raw ?? 'unknown')}`.value} is not supported`, `Make sure you have at least Ruby ${outputContent `${outputToken.yellow(MinRubyVersion)}`.value} installed on your system. ${outputContent `${outputToken.link('Documentation.', 'https://www.ruby-lang.org/en/documentation/installation/')}`
|
|
114
114
|
.value}`);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
@@ -121,14 +121,14 @@ async function validateBundler() {
|
|
|
121
121
|
let version;
|
|
122
122
|
try {
|
|
123
123
|
const stdout = await captureOutput(bundleExecutable(), ['-v'], { env: { BUNDLE_USER_HOME: bundleUserHome() } });
|
|
124
|
-
version =
|
|
124
|
+
version = coerce(stdout);
|
|
125
125
|
}
|
|
126
126
|
catch {
|
|
127
127
|
throw new AbortError('Bundler not found', `To install the latest version of Bundler, run ${outputContent `${outputToken.genericShellCommand(`${gemExecutable()} install bundler`)}`.value}`);
|
|
128
128
|
}
|
|
129
129
|
const isValid = version?.compare(MinBundlerVersion);
|
|
130
130
|
if (isValid === -1 || isValid === undefined) {
|
|
131
|
-
throw new AbortError(`Bundler version ${outputContent `${outputToken.yellow(version
|
|
131
|
+
throw new AbortError(`Bundler version ${outputContent `${outputToken.yellow(version?.raw ?? 'unknown')}`.value} is not supported`, `To update to the latest version of Bundler, run ${outputContent `${outputToken.genericShellCommand(`${gemExecutable()} install bundler`)}`.value}`);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
/**
|
|
@@ -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,EA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KG;AACH,MAAM,UAAU,cAAc;IAC5B,IAAI,eAAe,EAAE,CAAC,QAAQ,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE;QAClE,OAAO,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,wBAAwB,EAAE,OAAO,CAAC,CAAA;KAC3F;SAAM;QACL,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 {coerceSemverVersion} from '../../private/node/semver.js'\nimport {CLI_KIT_VERSION} from '../common/version.js'\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\n try {\n const stdout = await captureOutput(rubyExecutable(), ['-v'])\n version = coerceSemverVersion(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)}`.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\n try {\n const stdout = await captureOutput(bundleExecutable(), ['-v'], {env: {BUNDLE_USER_HOME: bundleUserHome()}})\n version = coerceSemverVersion(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)}`.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,YAA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E,OAAO,CAAC,CAAA;KAC3F;SAAM;QACL,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,13 +1,13 @@
|
|
|
1
1
|
import { AdminSession } from '@shopify/cli-kit/node/session';
|
|
2
|
-
import {
|
|
2
|
+
import { Result, Checksum, Key, Theme, ThemeAsset } from '@shopify/cli-kit/node/themes/types';
|
|
3
3
|
export type ThemeParams = Partial<Pick<Theme, 'name' | 'role' | 'processing'>>;
|
|
4
|
-
export type AssetParams = Partial<Pick<ThemeAsset, '
|
|
4
|
+
export type AssetParams = Pick<ThemeAsset, 'key'> & Partial<Pick<ThemeAsset, 'value' | 'attachment'>>;
|
|
5
5
|
export declare function fetchTheme(id: number, session: AdminSession): Promise<Theme | undefined>;
|
|
6
6
|
export declare function fetchThemes(session: AdminSession): Promise<Theme[]>;
|
|
7
7
|
export declare function createTheme(params: ThemeParams, session: AdminSession): Promise<Theme | undefined>;
|
|
8
8
|
export declare function fetchThemeAsset(id: number, key: Key, session: AdminSession): Promise<ThemeAsset | undefined>;
|
|
9
9
|
export declare function deleteThemeAsset(id: number, key: Key, session: AdminSession): Promise<boolean>;
|
|
10
|
-
export declare function bulkUploadThemeAssets(id: number, assets: AssetParams[], session: AdminSession): Promise<
|
|
10
|
+
export declare function bulkUploadThemeAssets(id: number, assets: AssetParams[], session: AdminSession): Promise<Result[]>;
|
|
11
11
|
export declare function fetchChecksums(id: number, session: AdminSession): Promise<Checksum[]>;
|
|
12
12
|
interface UpgradeThemeOptions {
|
|
13
13
|
fromTheme: number;
|
|
@@ -34,10 +34,7 @@ export async function deleteThemeAsset(id, key, session) {
|
|
|
34
34
|
}
|
|
35
35
|
export async function bulkUploadThemeAssets(id, assets, session) {
|
|
36
36
|
const response = await request('PUT', `/themes/${id}/assets/bulk`, session, { assets });
|
|
37
|
-
|
|
38
|
-
if (bulkResults?.length > 0)
|
|
39
|
-
return bulkResults.map(buildBulkUploadResults);
|
|
40
|
-
return [];
|
|
37
|
+
return buildBulkUploadResults(response.json.results, assets);
|
|
41
38
|
}
|
|
42
39
|
export async function fetchChecksums(id, session) {
|
|
43
40
|
const response = await request('GET', `/themes/${id}/assets`, session, undefined, { fields: 'key,checksum' });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../src/public/node/themes/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sDAAsD,CAAA;AACjF,OAAO,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,oDAAoD,CAAA;AAC3F,OAAO,EAAC,KAAK,EAAC,MAAM,kDAAkD,CAAA;AACtE,OAAO,EAAC,WAAW,EAAe,MAAM,iCAAiC,CAAA;AAEzE,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAA;AACtD,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,UAAU,EACV,eAAe,GAChB,MAAM,wCAAwC,CAAA;AAM/C,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,EAAU,EAAE,OAAqB;IAChE,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,EAAC,MAAM,EAAE,yBAAyB,EAAC,CAAC,CAAA;IAC/G,OAAO,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AACxC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAqB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iF;QACjF,gCAAgC,CACnC,CAAA;AACH,CAAC;AAED,SAAS,MAAM,CAAC,QAAsB;IACpC,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;AAC9C,CAAC","sourcesContent":["import {storeAdminUrl} from './urls.js'\nimport * as throttler from '../../../private/node/themes/themes-api/throttler.js'\nimport {apiCallLimit, retryAfter} from '../../../private/node/themes/themes-api/headers.js'\nimport {retry} from '../../../private/node/themes/themes-api/retry.js'\nimport {restRequest, RestResponse} from '@shopify/cli-kit/node/api/admin'\nimport {AdminSession} from '@shopify/cli-kit/node/session'\nimport {AbortError} from '@shopify/cli-kit/node/error'\nimport {\n buildBulkUploadResults,\n buildChecksum,\n buildTheme,\n buildThemeAsset,\n} from '@shopify/cli-kit/node/themes/factories'\nimport {BulkUploadResult, Checksum, Key, Theme, ThemeAsset} from '@shopify/cli-kit/node/themes/types'\n\nexport type ThemeParams = Partial<Pick<Theme, 'name' | 'role' | 'processing'>>\nexport type AssetParams = Partial<Pick<ThemeAsset, 'key' | 'value'>>\n\nexport async function fetchTheme(id: number, session: AdminSession): Promise<Theme | undefined> {\n const response = await request('GET', `/themes/${id}`, session, undefined, {fields: 'id,name,role,processing'})\n return buildTheme(response.json.theme)\n}\n\nexport async function fetchThemes(session: AdminSession): Promise<Theme[]> {\n const response = await request('GET', '/themes', session, undefined, {fields: 'id,name,role,processing'})\n const themes = response.json?.themes\n if (themes?.length > 0) return themes.map(buildTheme)\n return []\n}\n\nexport async function createTheme(params: ThemeParams, session: AdminSession): Promise<Theme | undefined> {\n const response = await request('POST', '/themes', session, {theme: {...params}})\n return buildTheme({...response.json.theme, createdAtRuntime: true})\n}\n\nexport async function fetchThemeAsset(id: number, key: Key, session: AdminSession): Promise<ThemeAsset | undefined> {\n const response = await request('GET', `/themes/${id}/assets`, session, undefined, {\n 'asset[key]': key,\n })\n return buildThemeAsset(response.json.asset)\n}\n\nexport async function deleteThemeAsset(id: number, key: Key, session: AdminSession): Promise<boolean> {\n const response = await request('DELETE', `/themes/${id}/assets`, session, undefined, {\n 'asset[key]': key,\n })\n return Boolean(response.json.message)\n}\n\nexport async function bulkUploadThemeAssets(\n id: number,\n assets: AssetParams[],\n session: AdminSession,\n): Promise<BulkUploadResult[]> {\n const response = await request('PUT', `/themes/${id}/assets/bulk`, session, {assets})\n const bulkResults = response.json.results\n\n if (bulkResults?.length > 0) return bulkResults.map(buildBulkUploadResults)\n\n return []\n}\n\nexport async function fetchChecksums(id: number, session: AdminSession): Promise<Checksum[]> {\n const response = await request('GET', `/themes/${id}/assets`, session, undefined, {fields: 'key,checksum'})\n const assets = response.json.assets\n\n if (assets?.length > 0) return assets.map(buildChecksum)\n\n return []\n}\n\ninterface UpgradeThemeOptions {\n fromTheme: number\n toTheme: number\n script?: string\n session: AdminSession\n}\n\nexport async function upgradeTheme(upgradeOptions: UpgradeThemeOptions): Promise<Theme | undefined> {\n const {fromTheme, toTheme, session, script} = upgradeOptions\n const params = {from_theme: fromTheme, to_theme: toTheme, ...(script && {script})}\n const response = await request('POST', `/themes`, session, params)\n return buildTheme(response.json.theme)\n}\n\nexport async function updateTheme(id: number, params: ThemeParams, session: AdminSession): Promise<Theme | undefined> {\n const response = await request('PUT', `/themes/${id}`, session, {theme: {id, ...params}})\n return buildTheme(response.json.theme)\n}\n\nexport async function publishTheme(id: number, session: AdminSession): Promise<Theme | undefined> {\n return updateTheme(id, {role: 'main'}, session)\n}\n\nexport async function deleteTheme(id: number, session: AdminSession): Promise<Theme | undefined> {\n const response = await request('DELETE', `/themes/${id}`, session)\n return buildTheme(response.json.theme)\n}\n\nasync function request<T>(\n method: string,\n path: string,\n session: AdminSession,\n params?: T,\n searchParams: {[name: string]: string} = {},\n): Promise<RestResponse> {\n const response = await throttler.throttle(() => restRequest(method, path, session, params, searchParams))\n\n const status = response.status\n const callLimit = apiCallLimit(response)\n\n throttler.updateApiCallLimit(callLimit)\n\n switch (true) {\n case status >= 200 && status <= 399:\n // Returns the successful reponse\n return response\n case status === 404:\n // Defer the decision when a resource is not found\n return response\n case status === 429:\n // Retry following the \"retry-after\" header\n return retry(() => request(method, path, session, params, searchParams), retryAfter(response))\n case status === 403:\n return handleForbiddenError(session)\n case status === 401:\n throw new AbortError(`[${status}] API request unauthorized error`)\n case status === 422:\n throw new AbortError(`[${status}] API request unprocessable content: ${errors(response)}`)\n case status >= 400 && status <= 499:\n throw new AbortError(`[${status}] API request client error`)\n case status >= 500 && status <= 599:\n throw new AbortError(`[${status}] API request server error`)\n default:\n throw new AbortError(`[${status}] API request unexpected error`)\n }\n}\n\nfunction handleForbiddenError(session: AdminSession): never {\n const store = session.storeFqdn\n const adminUrl = storeAdminUrl(session)\n\n throw new AbortError(\n `You are not authorized to edit themes on \"${store}\".`,\n \"You can't use Shopify CLI with development stores if you only have Partner staff \" +\n 'member access. If you want to use Shopify CLI to work on a development store, then ' +\n 'you should be the store owner or create a staff account on the store.' +\n '\\n\\n' +\n \"If you're the store owner, then you need to log in to the store directly using the \" +\n `store URL at least once (for example, using \"${adminUrl}\") before you log in using ` +\n 'Shopify CLI. Logging in to the Shopify admin directly connects the development ' +\n 'store with your Shopify login.',\n )\n}\n\nfunction errors(response: RestResponse) {\n return JSON.stringify(response.json?.errors)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../src/public/node/themes/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,sDAAsD,CAAA;AACjF,OAAO,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,oDAAoD,CAAA;AAC3F,OAAO,EAAC,KAAK,EAAC,MAAM,kDAAkD,CAAA;AACtE,OAAO,EAAC,WAAW,EAAe,MAAM,iCAAiC,CAAA;AAEzE,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAA;AACtD,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,UAAU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,OAAqB;IACjD,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAA;IAC/B,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,CAAA;IAEvC,MAAM,IAAI,UAAU,CAClB,6CAA6C,KAAK,IAAI,EACtD,mFAAmF;QACjF,qFAAqF;QACrF,uEAAuE;QACvE,MAAM;QACN,qFAAqF;QACrF,gDAAgD,QAAQ,6BAA6B;QACrF,iFAAiF;QACjF,gCAAgC,CACnC,CAAA;AACH,CAAC;AAED,SAAS,MAAM,CAAC,QAAsB;IACpC,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;AAC9C,CAAC","sourcesContent":["import {storeAdminUrl} from './urls.js'\nimport * as throttler from '../../../private/node/themes/themes-api/throttler.js'\nimport {apiCallLimit, retryAfter} from '../../../private/node/themes/themes-api/headers.js'\nimport {retry} from '../../../private/node/themes/themes-api/retry.js'\nimport {restRequest, RestResponse} from '@shopify/cli-kit/node/api/admin'\nimport {AdminSession} from '@shopify/cli-kit/node/session'\nimport {AbortError} from '@shopify/cli-kit/node/error'\nimport {\n buildBulkUploadResults,\n buildChecksum,\n buildTheme,\n buildThemeAsset,\n} from '@shopify/cli-kit/node/themes/factories'\nimport {Result, Checksum, Key, Theme, ThemeAsset} from '@shopify/cli-kit/node/themes/types'\n\nexport type ThemeParams = Partial<Pick<Theme, 'name' | 'role' | 'processing'>>\nexport type AssetParams = Pick<ThemeAsset, 'key'> & Partial<Pick<ThemeAsset, 'value' | 'attachment'>>\n\nexport async function fetchTheme(id: number, session: AdminSession): Promise<Theme | undefined> {\n const response = await request('GET', `/themes/${id}`, session, undefined, {fields: 'id,name,role,processing'})\n return buildTheme(response.json.theme)\n}\n\nexport async function fetchThemes(session: AdminSession): Promise<Theme[]> {\n const response = await request('GET', '/themes', session, undefined, {fields: 'id,name,role,processing'})\n const themes = response.json?.themes\n if (themes?.length > 0) return themes.map(buildTheme)\n return []\n}\n\nexport async function createTheme(params: ThemeParams, session: AdminSession): Promise<Theme | undefined> {\n const response = await request('POST', '/themes', session, {theme: {...params}})\n return buildTheme({...response.json.theme, createdAtRuntime: true})\n}\n\nexport async function fetchThemeAsset(id: number, key: Key, session: AdminSession): Promise<ThemeAsset | undefined> {\n const response = await request('GET', `/themes/${id}/assets`, session, undefined, {\n 'asset[key]': key,\n })\n return buildThemeAsset(response.json.asset)\n}\n\nexport async function deleteThemeAsset(id: number, key: Key, session: AdminSession): Promise<boolean> {\n const response = await request('DELETE', `/themes/${id}/assets`, session, undefined, {\n 'asset[key]': key,\n })\n return Boolean(response.json.message)\n}\n\nexport async function bulkUploadThemeAssets(\n id: number,\n assets: AssetParams[],\n session: AdminSession,\n): Promise<Result[]> {\n const response = await request('PUT', `/themes/${id}/assets/bulk`, session, {assets})\n return buildBulkUploadResults(response.json.results, assets)\n}\n\nexport async function fetchChecksums(id: number, session: AdminSession): Promise<Checksum[]> {\n const response = await request('GET', `/themes/${id}/assets`, session, undefined, {fields: 'key,checksum'})\n const assets = response.json.assets\n\n if (assets?.length > 0) return assets.map(buildChecksum)\n\n return []\n}\n\ninterface UpgradeThemeOptions {\n fromTheme: number\n toTheme: number\n script?: string\n session: AdminSession\n}\n\nexport async function upgradeTheme(upgradeOptions: UpgradeThemeOptions): Promise<Theme | undefined> {\n const {fromTheme, toTheme, session, script} = upgradeOptions\n const params = {from_theme: fromTheme, to_theme: toTheme, ...(script && {script})}\n const response = await request('POST', `/themes`, session, params)\n return buildTheme(response.json.theme)\n}\n\nexport async function updateTheme(id: number, params: ThemeParams, session: AdminSession): Promise<Theme | undefined> {\n const response = await request('PUT', `/themes/${id}`, session, {theme: {id, ...params}})\n return buildTheme(response.json.theme)\n}\n\nexport async function publishTheme(id: number, session: AdminSession): Promise<Theme | undefined> {\n return updateTheme(id, {role: 'main'}, session)\n}\n\nexport async function deleteTheme(id: number, session: AdminSession): Promise<Theme | undefined> {\n const response = await request('DELETE', `/themes/${id}`, session)\n return buildTheme(response.json.theme)\n}\n\nasync function request<T>(\n method: string,\n path: string,\n session: AdminSession,\n params?: T,\n searchParams: {[name: string]: string} = {},\n): Promise<RestResponse> {\n const response = await throttler.throttle(() => restRequest(method, path, session, params, searchParams))\n\n const status = response.status\n const callLimit = apiCallLimit(response)\n\n throttler.updateApiCallLimit(callLimit)\n\n switch (true) {\n case status >= 200 && status <= 399:\n // Returns the successful reponse\n return response\n case status === 404:\n // Defer the decision when a resource is not found\n return response\n case status === 429:\n // Retry following the \"retry-after\" header\n return retry(() => request(method, path, session, params, searchParams), retryAfter(response))\n case status === 403:\n return handleForbiddenError(session)\n case status === 401:\n throw new AbortError(`[${status}] API request unauthorized error`)\n case status === 422:\n throw new AbortError(`[${status}] API request unprocessable content: ${errors(response)}`)\n case status >= 400 && status <= 499:\n throw new AbortError(`[${status}] API request client error`)\n case status >= 500 && status <= 599:\n throw new AbortError(`[${status}] API request server error`)\n default:\n throw new AbortError(`[${status}] API request unexpected error`)\n }\n}\n\nfunction handleForbiddenError(session: AdminSession): never {\n const store = session.storeFqdn\n const adminUrl = storeAdminUrl(session)\n\n throw new AbortError(\n `You are not authorized to edit themes on \"${store}\".`,\n \"You can't use Shopify CLI with development stores if you only have Partner staff \" +\n 'member access. If you want to use Shopify CLI to work on a development store, then ' +\n 'you should be the store owner or create a staff account on the store.' +\n '\\n\\n' +\n \"If you're the store owner, then you need to log in to the store directly using the \" +\n `store URL at least once (for example, using \"${adminUrl}\") before you log in using ` +\n 'Shopify CLI. Logging in to the Shopify admin directly connects the development ' +\n 'store with your Shopify login.',\n )\n}\n\nfunction errors(response: RestResponse) {\n return JSON.stringify(response.json?.errors)\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AssetParams } from './api.js';
|
|
2
|
+
import { Result, Checksum, Theme, ThemeAsset } from '@shopify/cli-kit/node/themes/types';
|
|
2
3
|
interface RemoteThemeResponse {
|
|
3
4
|
id: number;
|
|
4
5
|
name: string;
|
|
@@ -12,15 +13,17 @@ interface RemoteAssetResponse {
|
|
|
12
13
|
attachment: string;
|
|
13
14
|
value: string;
|
|
14
15
|
}
|
|
15
|
-
interface RemoteBulkUploadResponse {
|
|
16
|
+
export interface RemoteBulkUploadResponse {
|
|
16
17
|
body: {
|
|
17
|
-
asset
|
|
18
|
+
asset?: RemoteAssetResponse;
|
|
19
|
+
errors?: {
|
|
20
|
+
asset: string[];
|
|
21
|
+
};
|
|
18
22
|
};
|
|
19
23
|
code: number;
|
|
20
|
-
errors?: string[];
|
|
21
24
|
}
|
|
22
25
|
export declare function buildTheme(themeJson?: RemoteThemeResponse): Theme | undefined;
|
|
23
26
|
export declare function buildChecksum(asset?: RemoteAssetResponse): Checksum | undefined;
|
|
24
27
|
export declare function buildThemeAsset(asset?: RemoteAssetResponse): ThemeAsset | undefined;
|
|
25
|
-
export declare function buildBulkUploadResults(
|
|
28
|
+
export declare function buildBulkUploadResults(bulkUploadResponse: RemoteBulkUploadResponse[], assets: AssetParams[]): Result[];
|
|
26
29
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Operation } from '@shopify/cli-kit/node/themes/types';
|
|
1
2
|
export function buildTheme(themeJson) {
|
|
2
3
|
if (!themeJson)
|
|
3
4
|
return;
|
|
@@ -24,14 +25,20 @@ export function buildThemeAsset(asset) {
|
|
|
24
25
|
const { key, checksum, attachment, value } = asset;
|
|
25
26
|
return { key, checksum, attachment, value };
|
|
26
27
|
}
|
|
27
|
-
export function buildBulkUploadResults(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
export function buildBulkUploadResults(bulkUploadResponse, assets) {
|
|
29
|
+
const results = [];
|
|
30
|
+
if (!bulkUploadResponse)
|
|
31
|
+
return results;
|
|
32
|
+
bulkUploadResponse.forEach((bulkUpload, index) => {
|
|
33
|
+
const asset = assets[index];
|
|
34
|
+
results.push({
|
|
35
|
+
key: asset?.key || '',
|
|
36
|
+
success: bulkUpload.code === 200,
|
|
37
|
+
errors: bulkUpload.body.errors || {},
|
|
38
|
+
asset: bulkUpload.body.asset,
|
|
39
|
+
operation: Operation.Upload,
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
return results;
|
|
36
43
|
}
|
|
37
44
|
//# sourceMappingURL=factories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factories.js","sourceRoot":"","sources":["../../../../src/public/node/themes/factories.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"factories.js","sourceRoot":"","sources":["../../../../src/public/node/themes/factories.ts"],"names":[],"mappings":"AACA,OAAO,EAAsC,SAAS,EAAC,MAAM,oCAAoC,CAAA;AAsBjG,MAAM,UAAU,UAAU,CAAC,SAA+B;IACxD,IAAI,CAAC,SAAS;QAAE,OAAM;IAEtB,SAAS,CAAC,UAAU,KAApB,SAAS,CAAC,UAAU,GAAK,KAAK,EAAA;IAC9B,SAAS,CAAC,gBAAgB,KAA1B,SAAS,CAAC,gBAAgB,GAAK,KAAK,EAAA;IAEpC,MAAM,EAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,EAAC,GAAG,SAAS,CAAA;IAEhE,OAAO;QACL,EAAE;QACF,IAAI;QACJ,UAAU;QACV,gBAAgB;QAChB,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI;KACtC,CAAA;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAA2B;IACvD,IAAI,CAAC,KAAK;QAAE,OAAM;IAElB,MAAM,EAAC,GAAG,EAAE,QAAQ,EAAC,GAAG,KAAK,CAAA;IAC7B,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAC,CAAA;AACxB,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAA2B;IACzD,IAAI,CAAC,KAAK;QAAE,OAAM;IAElB,MAAM,EAAC,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAC,GAAG,KAAK,CAAA;IAChD,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAC,CAAA;AAC3C,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,kBAA8C,EAC9C,MAAqB;IAErB,MAAM,OAAO,GAAa,EAAE,CAAA;IAC5B,IAAI,CAAC,kBAAkB;QAAE,OAAO,OAAO,CAAA;IAEvC,kBAAkB,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE;QAC/C,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;QAC3B,OAAO,CAAC,IAAI,CAAC;YACX,GAAG,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE;YACrB,OAAO,EAAE,UAAU,CAAC,IAAI,KAAK,GAAG;YAChC,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE;YACpC,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,KAAK;YAC5B,SAAS,EAAE,SAAS,CAAC,MAAM;SAC5B,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IACF,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["import {AssetParams} from './api.js'\nimport {Result, Checksum, Theme, ThemeAsset, Operation} from '@shopify/cli-kit/node/themes/types'\n\ninterface RemoteThemeResponse {\n id: number\n name: string\n role: string\n createdAtRuntime?: boolean\n processing?: boolean\n}\n\ninterface RemoteAssetResponse {\n key: string\n checksum: string\n attachment: string\n value: string\n}\n\nexport interface RemoteBulkUploadResponse {\n body: {asset?: RemoteAssetResponse; errors?: {asset: string[]}}\n code: number\n}\n\nexport function buildTheme(themeJson?: RemoteThemeResponse): Theme | undefined {\n if (!themeJson) return\n\n themeJson.processing ??= false\n themeJson.createdAtRuntime ??= false\n\n const {id, name, role, processing, createdAtRuntime} = themeJson\n\n return {\n id,\n name,\n processing,\n createdAtRuntime,\n role: role === 'main' ? 'live' : role,\n }\n}\n\nexport function buildChecksum(asset?: RemoteAssetResponse): Checksum | undefined {\n if (!asset) return\n\n const {key, checksum} = asset\n return {key, checksum}\n}\n\nexport function buildThemeAsset(asset?: RemoteAssetResponse): ThemeAsset | undefined {\n if (!asset) return\n\n const {key, checksum, attachment, value} = asset\n return {key, checksum, attachment, value}\n}\n\nexport function buildBulkUploadResults(\n bulkUploadResponse: RemoteBulkUploadResponse[],\n assets: AssetParams[],\n): Result[] {\n const results: Result[] = []\n if (!bulkUploadResponse) return results\n\n bulkUploadResponse.forEach((bulkUpload, index) => {\n const asset = assets[index]\n results.push({\n key: asset?.key || '',\n success: bulkUpload.code === 200,\n errors: bulkUpload.body.errors || {},\n asset: bulkUpload.body.asset,\n operation: Operation.Upload,\n })\n })\n return results\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AdminSession } from '@shopify/cli-kit/node/session';
|
|
2
2
|
import { Theme } from '@shopify/cli-kit/node/themes/types';
|
|
3
|
+
import { Role } from '@shopify/cli-kit/node/themes/utils';
|
|
3
4
|
export declare abstract class ThemeManager {
|
|
4
5
|
protected adminSession: AdminSession;
|
|
5
6
|
protected themeId: string | undefined;
|
|
@@ -9,5 +10,5 @@ export declare abstract class ThemeManager {
|
|
|
9
10
|
constructor(adminSession: AdminSession);
|
|
10
11
|
findOrCreate(): Promise<Theme>;
|
|
11
12
|
fetch(): Promise<Theme | undefined>;
|
|
12
|
-
|
|
13
|
+
create(themeRole?: Role, themeName?: string): Promise<Theme>;
|
|
13
14
|
}
|
|
@@ -23,9 +23,9 @@ export class ThemeManager {
|
|
|
23
23
|
}
|
|
24
24
|
return theme;
|
|
25
25
|
}
|
|
26
|
-
async create() {
|
|
27
|
-
const name = generateThemeName(this.context);
|
|
28
|
-
const role = DEVELOPMENT_THEME_ROLE;
|
|
26
|
+
async create(themeRole, themeName) {
|
|
27
|
+
const name = themeName || generateThemeName(this.context);
|
|
28
|
+
const role = themeRole || DEVELOPMENT_THEME_ROLE;
|
|
29
29
|
const theme = await createTheme({
|
|
30
30
|
name,
|
|
31
31
|
role,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-manager.js","sourceRoot":"","sources":["../../../../src/public/node/themes/theme-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,UAAU,CAAA;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qDAAqD,CAAA;AAErF,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAA;AAEpD,OAAO,EAAC,sBAAsB,
|
|
1
|
+
{"version":3,"file":"theme-manager.js","sourceRoot":"","sources":["../../../../src/public/node/themes/theme-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,UAAU,CAAA;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qDAAqD,CAAA;AAErF,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAA;AAEpD,OAAO,EAAC,sBAAsB,EAAO,MAAM,oCAAoC,CAAA;AAE/E,MAAM,OAAgB,YAAY;IAMhC,YAAsB,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAEpD,KAAK,CAAC,YAAY;QAChB,IAAI,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;QAC9B,IAAI,CAAC,KAAK,EAAE;YACV,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,CAAA;SAC5B;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,OAAM;SACP;QACD,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;QAC7E,IAAI,CAAC,KAAK,EAAE;YACV,IAAI,CAAC,WAAW,EAAE,CAAA;SACnB;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,SAAgB,EAAE,SAAkB;QAC/C,MAAM,IAAI,GAAG,SAAS,IAAI,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACzD,MAAM,IAAI,GAAG,SAAS,IAAI,sBAAsB,CAAA;QAChD,MAAM,KAAK,GAAG,MAAM,WAAW,CAC7B;YACE,IAAI;YACJ,IAAI;SACL,EACD,IAAI,CAAC,YAAY,CAClB,CAAA;QACD,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,QAAQ,CAAC,qCAAqC,IAAI,eAAe,IAAI,GAAG,CAAC,CAAA;SACpF;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAA;QAClC,OAAO,KAAK,CAAA;IACd,CAAC;CACF","sourcesContent":["import {fetchTheme, createTheme} from './api.js'\nimport {generateThemeName} from '../../../private/node/themes/generate-theme-name.js'\nimport {AdminSession} from '@shopify/cli-kit/node/session'\nimport {BugError} from '@shopify/cli-kit/node/error'\nimport {Theme} from '@shopify/cli-kit/node/themes/types'\nimport {DEVELOPMENT_THEME_ROLE, Role} from '@shopify/cli-kit/node/themes/utils'\n\nexport abstract class ThemeManager {\n protected themeId: string | undefined\n protected abstract setTheme(themeId: string): void\n protected abstract removeTheme(): void\n protected abstract context: string\n\n constructor(protected adminSession: AdminSession) {}\n\n async findOrCreate(): Promise<Theme> {\n let theme = await this.fetch()\n if (!theme) {\n theme = await this.create()\n }\n return theme\n }\n\n async fetch() {\n if (!this.themeId) {\n return\n }\n const theme = await fetchTheme(parseInt(this.themeId, 10), this.adminSession)\n if (!theme) {\n this.removeTheme()\n }\n return theme\n }\n\n async create(themeRole?: Role, themeName?: string) {\n const name = themeName || generateThemeName(this.context)\n const role = themeRole || DEVELOPMENT_THEME_ROLE\n const theme = await createTheme(\n {\n name,\n role,\n },\n this.adminSession,\n )\n if (!theme) {\n throw new BugError(`Could not create theme with name \"${name}\" and role \"${role}\"`)\n }\n this.setTheme(theme.id.toString())\n return theme\n }\n}\n"]}
|
|
@@ -67,25 +67,29 @@ export interface ThemeAsset extends Checksum {
|
|
|
67
67
|
value?: string;
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
|
-
* Represents a single result
|
|
71
|
-
* Each result includes the unique identifier for the file
|
|
72
|
-
* the status of the
|
|
70
|
+
* Represents a single result for a upload or delete operation on a single file
|
|
71
|
+
* Each result includes the unique identifier for the file, the type of the operation,
|
|
72
|
+
* the sucesss status of the operation, any errors that occurred, and the asset value of the file.
|
|
73
73
|
*/
|
|
74
|
-
export interface
|
|
74
|
+
export interface Result {
|
|
75
75
|
/**
|
|
76
76
|
* The unique identifier for the file being uploaded.
|
|
77
77
|
*/
|
|
78
78
|
key: string;
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
80
|
+
* The operation associated with the result.
|
|
81
81
|
*/
|
|
82
|
+
operation: Operation;
|
|
82
83
|
success: boolean;
|
|
83
84
|
/**
|
|
84
|
-
*
|
|
85
|
+
* Error message that was generated during the upload operation for this file.
|
|
85
86
|
*/
|
|
86
|
-
errors?:
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
errors?: {
|
|
88
|
+
asset?: string[];
|
|
89
|
+
};
|
|
90
|
+
asset?: ThemeAsset;
|
|
91
|
+
}
|
|
92
|
+
export declare enum Operation {
|
|
93
|
+
Delete = "DELETE",
|
|
94
|
+
Upload = "UPLOAD"
|
|
91
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/public/node/themes/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * {@link Key} represents the unique identifier of a file in a theme.\n */\nexport type Key = string\n\n/**\n * Represents a theme on the file system.\n */\nexport interface ThemeFileSystem {\n /**\n * The root path of the theme.\n */\n root: string\n\n /**\n * Local theme files.\n */\n files: Map<Key, ThemeAsset>\n}\n\n/**\n * Represents a theme.\n */\nexport interface Theme {\n /**\n * The remote ID of the theme.\n */\n id: number\n\n /**\n * The remote name of the theme.\n */\n name: string\n\n /**\n * A boolean determining whether or not the theme was created at runtime.\n */\n createdAtRuntime: boolean\n\n /**\n * A boolean determining if the theme is processing at the theme library.\n */\n processing: boolean\n\n /**\n * The remote role of the theme.\n */\n role: string\n}\n\n/**\n * Represents the remote checksum for a file in a theme.\n */\nexport interface Checksum {\n /**\n * Identifier of the theme file.\n */\n key: Key\n\n /**\n * Reresents the checksum value of the theme file.\n */\n checksum: string\n}\n\n/**\n * Represents a file in a theme.\n */\nexport interface ThemeAsset extends Checksum {\n /**\n * A base64-encoded image.\n */\n attachment?: string\n\n /**\n * The text content of the asset, such as the HTML and Liquid markup of a template file.\n */\n value?: string\n}\n\n/**\n * Represents a single result
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/public/node/themes/types.ts"],"names":[],"mappings":"AAgHA,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,8BAAiB,CAAA;IACjB,8BAAiB,CAAA;AACnB,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB","sourcesContent":["/**\n * {@link Key} represents the unique identifier of a file in a theme.\n */\nexport type Key = string\n\n/**\n * Represents a theme on the file system.\n */\nexport interface ThemeFileSystem {\n /**\n * The root path of the theme.\n */\n root: string\n\n /**\n * Local theme files.\n */\n files: Map<Key, ThemeAsset>\n}\n\n/**\n * Represents a theme.\n */\nexport interface Theme {\n /**\n * The remote ID of the theme.\n */\n id: number\n\n /**\n * The remote name of the theme.\n */\n name: string\n\n /**\n * A boolean determining whether or not the theme was created at runtime.\n */\n createdAtRuntime: boolean\n\n /**\n * A boolean determining if the theme is processing at the theme library.\n */\n processing: boolean\n\n /**\n * The remote role of the theme.\n */\n role: string\n}\n\n/**\n * Represents the remote checksum for a file in a theme.\n */\nexport interface Checksum {\n /**\n * Identifier of the theme file.\n */\n key: Key\n\n /**\n * Reresents the checksum value of the theme file.\n */\n checksum: string\n}\n\n/**\n * Represents a file in a theme.\n */\nexport interface ThemeAsset extends Checksum {\n /**\n * A base64-encoded image.\n */\n attachment?: string\n\n /**\n * The text content of the asset, such as the HTML and Liquid markup of a template file.\n */\n value?: string\n}\n\n/**\n * Represents a single result for a upload or delete operation on a single file\n * Each result includes the unique identifier for the file, the type of the operation,\n * the sucesss status of the operation, any errors that occurred, and the asset value of the file.\n */\nexport interface Result {\n /**\n * The unique identifier for the file being uploaded.\n */\n key: string\n\n /**\n * The operation associated with the result.\n */\n operation: Operation\n\n /* *\n * Indicates whether the upload operation for this file was successful.\n */\n success: boolean\n\n /**\n * Error message that was generated during the upload operation for this file.\n */\n errors?: {asset?: string[]}\n\n /* *\n * The asset that was uploaded as part of the upload operation for this file.\n */\n asset?: ThemeAsset\n}\n\nexport enum Operation {\n Delete = 'DELETE',\n Upload = 'UPLOAD',\n}\n"]}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { Theme } from '@shopify/cli-kit/node/themes/types';
|
|
2
2
|
export declare const DEVELOPMENT_THEME_ROLE = "development";
|
|
3
|
+
export declare const LIVE_THEME_ROLE = "live";
|
|
4
|
+
export declare const UNPUBLISHED_THEME_ROLE = "unpublished";
|
|
5
|
+
export type Role = typeof DEVELOPMENT_THEME_ROLE | typeof LIVE_THEME_ROLE | typeof UNPUBLISHED_THEME_ROLE;
|
|
3
6
|
export declare function isDevelopmentTheme(theme: Theme): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/public/node/themes/utils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/public/node/themes/utils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CAAA;AACnD,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAA;AACrC,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CAAA;AAInD,MAAM,UAAU,kBAAkB,CAAC,KAAY;IAC7C,OAAO,KAAK,CAAC,IAAI,KAAK,sBAAsB,CAAA;AAC9C,CAAC","sourcesContent":["import {Theme} from '@shopify/cli-kit/node/themes/types'\n\nexport const DEVELOPMENT_THEME_ROLE = 'development'\nexport const LIVE_THEME_ROLE = 'live'\nexport const UNPUBLISHED_THEME_ROLE = 'unpublished'\n\nexport type Role = typeof DEVELOPMENT_THEME_ROLE | typeof LIVE_THEME_ROLE | typeof UNPUBLISHED_THEME_ROLE\n\nexport function isDevelopmentTheme(theme: Theme) {\n return theme.role === DEVELOPMENT_THEME_ROLE\n}\n"]}
|