@shopify/create-app
Version:
A CLI tool to create a new Shopify app.
76 lines (71 loc) • 2.88 kB
JavaScript
import {
isTruthy
} from "../chunk-HNIAZN6U.js";
import {
init_cjs_shims
} from "../chunk-3XNI6LP4.js";
// src/hooks/prerun.ts
init_cjs_shims();
// ../cli-kit/dist/public/node/hooks/prerun.js
init_cjs_shims();
// ../cli-kit/dist/private/node/plugin-hints.js
init_cjs_shims();
var SHOPIFY_AI_TOOLKIT_PLUGIN_HINT = '<claude-code-hint v="1" type="plugin" value="shopify-ai-toolkit@claude-plugins-official" />';
function runningUnderClaudeCode(environment = process.env) {
return isTruthy(environment.CLAUDECODE) || isTruthy(environment.CLAUDE_CODE_CHILD_SESSION);
}
function emitClaudeCodePluginHint(environment = process.env) {
runningUnderClaudeCode(environment) && process.stderr.write(`${SHOPIFY_AI_TOOLKIT_PLUGIN_HINT}
`);
}
// ../cli-kit/dist/public/node/hooks/prerun.js
var hook = async (options) => {
let commandContent = parseCommandContent({
id: options.Command.id,
aliases: options.Command.aliases,
pluginAlias: options.Command.plugin?.alias
}), args = options.argv;
emitClaudeCodePluginHint();
let [{ outputDebug }, analyticsMod, notificationsMod] = await Promise.all([
import("../output-2RGSJNA6.js"),
import("../analytics-A7XUM3DE.js"),
import("../notifications-system-ZK44GBNG.js")
]);
checkForNewVersionInBackground(), outputDebug(`Running command ${commandContent.command}`), await analyticsMod.startAnalytics({ commandContent, args, commandClass: options.Command }), notificationsMod.fetchNotificationsInBackground(options.Command.id);
};
function parseCommandContent(cmdInfo) {
let commandContent = parseCreateCommand(cmdInfo.pluginAlias);
return commandContent ??= parseNormalCommand(cmdInfo.id, cmdInfo.aliases), commandContent;
}
function parseNormalCommand(id, aliases) {
return {
command: id.replace(/:/g, " "),
topic: parseTopic(id),
alias: findAlias(aliases)
};
}
function parseCreateCommand(pluginAlias) {
if (pluginAlias?.startsWith("@shopify/create-"))
return { command: pluginAlias.substring(pluginAlias.indexOf("/") + 1) };
}
function parseTopic(cmd) {
if (cmd.lastIndexOf(":") !== -1)
return cmd.slice(0, cmd.lastIndexOf(":")).replace(/:/g, " ");
}
function findAlias(aliases) {
let existingAlias = aliases.find((alias) => alias.split(":").every((aliasToken) => process.argv.includes(aliasToken)));
if (existingAlias)
return existingAlias.replace(/:/g, " ");
}
async function checkForNewVersionInBackground() {
let [{ CLI_KIT_VERSION }, { isPreReleaseVersion }, { checkForNewVersion }] = await Promise.all([
import("../version-AALUTWIR.js"),
import("../version-6CVFB4SF.js"),
import("../node-package-manager-JO3BBXYZ.js")
]), currentVersion = CLI_KIT_VERSION;
isPreReleaseVersion(currentVersion) || checkForNewVersion("@shopify/cli", currentVersion, { cacheExpiryInHours: 24 });
}
export {
hook as default
};
//# sourceMappingURL=prerun.js.map