@shopify/cli-kit 3.38.0 → 3.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/private/common/json.d.ts +2 -2
- package/dist/private/common/lodash.d.ts +4 -4
- package/dist/private/common/ts/overloaded-parameters.d.ts +5 -5
- package/dist/private/node/api/headers.d.ts +1 -1
- package/dist/private/node/api.d.ts +1 -1
- package/dist/private/node/constants.d.ts +2 -2
- package/dist/private/node/environment/service.d.ts +1 -1
- package/dist/private/node/error-handler.d.ts +2 -0
- package/dist/private/node/error-handler.js +5 -0
- package/dist/private/node/error-handler.js.map +1 -0
- package/dist/private/node/session/exchange.d.ts +1 -1
- package/dist/private/node/session/redirect-listener.d.ts +1 -1
- package/dist/private/node/session/redirect-listener.js +5 -5
- package/dist/private/node/session/redirect-listener.js.map +1 -1
- package/dist/private/node/session/schema.d.ts +3 -3
- package/dist/private/node/session/validate.d.ts +1 -1
- package/dist/private/node/session.d.ts +4 -4
- package/dist/private/node/ui/components/AutocompletePrompt.d.ts +9 -2
- package/dist/private/node/ui/components/AutocompletePrompt.js +8 -4
- package/dist/private/node/ui/components/AutocompletePrompt.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.test.js +62 -8
- package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/Banner.d.ts +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.d.ts +2 -2
- package/dist/private/node/ui/components/SelectInput.d.ts +3 -1
- package/dist/private/node/ui/components/SelectInput.js +8 -2
- package/dist/private/node/ui/components/SelectInput.js.map +1 -1
- package/dist/private/node/ui/components/SelectInput.test.js +26 -0
- package/dist/private/node/ui/components/SelectInput.test.js.map +1 -1
- package/dist/private/node/ui/components/Table/Row.d.ts +1 -1
- package/dist/private/node/ui/components/Table/ScalarDict.d.ts +1 -1
- package/dist/private/node/ui/components/Table/Table.d.ts +1 -1
- package/dist/private/node/ui/components/Tasks.d.ts +5 -1
- package/dist/private/node/ui/components/Tasks.js +31 -6
- package/dist/private/node/ui/components/Tasks.js.map +1 -1
- package/dist/private/node/ui/components/Tasks.test.js +259 -19
- package/dist/private/node/ui/components/Tasks.test.js.map +1 -1
- package/dist/private/node/ui/components/TokenizedText.d.ts +2 -2
- package/dist/private/node/ui.d.ts +1 -1
- package/dist/public/common/string.d.ts +1 -1
- package/dist/{private → public}/common/ts/deep-required.d.ts +2 -1
- package/dist/{private → public}/common/ts/deep-required.js +0 -0
- package/dist/public/common/ts/deep-required.js.map +1 -0
- package/dist/public/common/ts/pick-by-prefix.d.ts +2 -1
- package/dist/public/common/ts/pick-by-prefix.js.map +1 -1
- package/dist/public/common/version.d.ts +1 -1
- package/dist/public/common/version.js +1 -1
- package/dist/public/common/version.js.map +1 -1
- package/dist/public/node/api/http.d.ts +1 -0
- package/dist/public/node/api/http.js +1 -1
- package/dist/public/node/archiver.d.ts +20 -6
- package/dist/public/node/archiver.js +14 -13
- package/dist/public/node/archiver.js.map +1 -1
- package/dist/public/node/crypto.d.ts +1 -1
- package/dist/public/node/dot-env.js +2 -0
- package/dist/public/node/dot-env.js.map +1 -1
- package/dist/public/node/environment/local.d.ts +1 -1
- package/dist/public/node/environment/spin.d.ts +1 -1
- package/dist/public/node/error-handler.d.ts +1 -2
- package/dist/public/node/error-handler.js +12 -2
- package/dist/public/node/error-handler.js.map +1 -1
- package/dist/public/node/fs.d.ts +24 -4
- package/dist/public/node/fs.js +31 -2
- package/dist/public/node/fs.js.map +1 -1
- package/dist/public/node/git.d.ts +9 -1
- package/dist/public/node/git.js +31 -1
- package/dist/public/node/git.js.map +1 -1
- package/dist/public/node/http.d.ts +9 -1
- package/dist/public/node/http.js +34 -0
- package/dist/public/node/http.js.map +1 -1
- package/dist/public/node/metadata.d.ts +7 -7
- package/dist/public/node/monorail.d.ts +6 -6
- package/dist/public/node/monorail.js.map +1 -1
- package/dist/public/node/node-package-manager.d.ts +5 -5
- package/dist/public/node/os.d.ts +2 -2
- package/dist/public/node/output.d.ts +4 -4
- package/dist/public/node/path.d.ts +1 -1
- package/dist/public/node/plugins/tunnel.d.ts +5 -5
- package/dist/public/node/plugins.d.ts +4 -4
- package/dist/public/node/result.d.ts +1 -1
- package/dist/public/node/ruby.d.ts +1 -1
- package/dist/public/node/session.d.ts +1 -1
- package/dist/public/node/system.d.ts +1 -1
- package/dist/public/node/ui.d.ts +10 -5
- package/dist/public/node/ui.js +4 -3
- package/dist/public/node/ui.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui.d.ts +6 -20
- package/dist/ui.js +1 -21
- package/dist/ui.js.map +1 -1
- package/package.json +6 -7
- package/dist/private/common/ts/deep-required.js.map +0 -1
- package/dist/private/node/simple-definitions.d.ts +0 -4
- package/dist/private/node/simple-definitions.js +0 -2
- package/dist/private/node/simple-definitions.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../../src/public/node/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,qBAAqB,EAAC,MAAM,wBAAwB,CAAA;AACpE,OAAO,EAAC,cAAc,EAAC,MAAM,SAAS,CAAA;AACtC,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAC7B,OAAO,EAAC,aAAa,EAAE,WAAW,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACnF,OAAO,GAAoF,MAAM,YAAY,CAAA;AAE7G,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAA;AAE7B;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,SAAiB,EAAE,aAAa,GAAG,MAAM;IACrF,WAAW,CAAC,aAAa,CAAA,kCAAkC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAC5F,MAAM,yBAAyB,EAAE,CAAA;IACj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A;KACrG;AACH,CAAC","sourcesContent":["import {hasGit, isTerminalInteractive} from './environment/local.js'\nimport {appendFileSync} from './fs.js'\nimport {AbortError} from './error.js'\nimport {cwd} from './path.js'\nimport {outputContent, outputToken, outputDebug} from '../../public/node/output.js'\nimport git, {TaskOptions, SimpleGitProgressEvent, DefaultLogFields, ListLogLine, SimpleGit} from 'simple-git'\n\nexport const gitFactory = git\n\n/**\n * Initialize a git repository at the given directory.\n *\n * @param directory - The directory where the git repository will be initialized.\n * @param initialBranch - The name of the initial branch.\n */\nexport async function initializeGitRepository(directory: string, initialBranch = 'main'): Promise<void> {\n outputDebug(outputContent`Initializing git repository at ${outputToken.path(directory)}...`)\n await ensureGitIsPresentOrAbort()\n // We use init and checkout instead of `init --initial-branch` because the latter is only supported in git 2.28+\n const repo = git(directory)\n await repo.init()\n await repo.checkoutLocalBranch(initialBranch)\n}\n\nexport interface GitIgnoreTemplate {\n [section: string]: string[]\n}\n/**\n * Create a .gitignore file in the given directory.\n *\n * @param directory - The directory where the .gitignore file will be created.\n * @param template - The template to use to create the .gitignore file.\n */\nexport function createGitIgnore(directory: string, template: GitIgnoreTemplate): void {\n outputDebug(outputContent`Creating .gitignore at ${outputToken.path(directory)}...`)\n const filePath = `${directory}/.gitignore`\n\n let fileContent = ''\n for (const [section, lines] of Object.entries(template)) {\n fileContent += `# ${section}\\n`\n fileContent += `${lines.join('\\n')}\\n\\n`\n }\n\n appendFileSync(filePath, fileContent)\n}\n\n/**\n * Options to use when cloning a git repository.\n *\n * @param repoUrl - The URL of the repository to clone.\n * @param destination - The directory where the repository will be cloned.\n * @param progressUpdater - A function that will be called with the progress of the clone.\n * @param shallow - Whether to clone the repository shallowly.\n * @param latestTag - Whether to clone the latest tag instead of the default branch.\n */\nexport interface GitCloneOptions {\n repoUrl: string\n destination: string\n progressUpdater?: (statusString: string) => void\n shallow?: boolean\n latestTag?: boolean\n}\n/**\n * Clone a git repository.\n *\n * @param cloneOptions - The options to use to clone the repository.\n * @returns A promise that resolves when the clone is complete.\n */\nexport async function downloadGitRepository(cloneOptions: GitCloneOptions): Promise<void> {\n const {repoUrl, destination, progressUpdater, shallow, latestTag} = cloneOptions\n outputDebug(outputContent`Git-cloning repository ${repoUrl} into ${outputToken.path(destination)}...`)\n await ensureGitIsPresentOrAbort()\n const [repository, branch] = repoUrl.split('#')\n const options: TaskOptions = {'--recurse-submodules': null}\n\n if (branch && latestTag) {\n throw new AbortError(\"Error cloning the repository. Git can't clone the latest release with a 'branch'.\")\n }\n if (branch) {\n options['--branch'] = branch\n }\n\n if (shallow && latestTag) {\n throw new AbortError(\n \"Error cloning the repository. Git can't clone the latest release with the 'shallow' property.\",\n )\n }\n if (shallow) {\n options['--depth'] = 1\n }\n\n const progress = ({stage, progress, processed, total}: SimpleGitProgressEvent) => {\n const updateString = `${stage}, ${processed}/${total} objects (${progress}% complete)`\n if (progressUpdater) progressUpdater(updateString)\n }\n\n const simpleGitOptions = {\n progress,\n ...(!isTerminalInteractive() && {config: ['core.askpass=true']}),\n }\n try {\n await git(simpleGitOptions).clone(repository!, destination, options)\n\n if (latestTag) {\n const localGitRepository = git(destination)\n const latestTag = await getLocalLatestTag(localGitRepository, repoUrl)\n await localGitRepository.checkout(latestTag)\n }\n } catch (err) {\n if (err instanceof Error) {\n const abortError = new AbortError(err.message)\n abortError.stack = err.stack\n throw abortError\n }\n throw err\n }\n}\n\n/**\n * Get the most recent tag of a local git repository.\n *\n * @param repository - The local git repository.\n * @param repoUrl - The URL of the repository.\n * @returns The most recent tag of the repository.\n */\nasync function getLocalLatestTag(repository: SimpleGit, repoUrl: string): Promise<string> {\n const latest = (await repository.tags()).latest\n\n if (!latest) {\n throw new AbortError(`Couldn't obtain the most recent tag of the repository ${repoUrl}`)\n }\n\n return latest\n}\n\n/**\n * Get the latest commit of a git repository.\n *\n * @param directory - The directory of the git repository.\n * @returns The latest commit of the repository.\n */\nexport async function getLatestGitCommit(directory?: string): Promise<DefaultLogFields & ListLogLine> {\n const logs = await git({baseDir: directory}).log({\n maxCount: 1,\n })\n if (!logs.latest) {\n throw new AbortError(\n 'Must have at least one commit to run command',\n outputContent`Run ${outputToken.genericShellCommand(\n \"git commit -m 'Initial commit'\",\n )} to create your first commit.`,\n )\n }\n return logs.latest\n}\n\n/**\n * Add all files to the git index from the given directory.\n *\n * @param directory - The directory where the git repository is located.\n * @returns A promise that resolves when the files are added to the index.\n */\nexport async function addAllToGitFromDirectory(directory?: string): Promise<void> {\n const simpleGit = git({baseDir: directory})\n await simpleGit.raw('add', '--all')\n}\n\nexport interface CreateGitCommitOptions {\n directory?: string\n author?: string\n}\n\n/**\n * Create a git commit.\n *\n * @param message - The message of the commit.\n * @param options - The options to use to create the commit.\n * @returns The hash of the created commit.\n */\nexport async function createGitCommit(message: string, options?: CreateGitCommitOptions): Promise<string> {\n const simpleGit = git({baseDir: options?.directory})\n\n const commitOptions = options?.author ? {'--author': options.author} : undefined\n const result = await simpleGit.commit(message, commitOptions)\n\n return result.commit\n}\n\n/**\n * Get the HEAD symbolic reference of a git repository.\n *\n * @param directory - The directory of the git repository.\n * @returns The HEAD symbolic reference of the repository.\n */\nexport async function getHeadSymbolicRef(directory?: string): Promise<string> {\n const ref = await git({baseDir: directory}).raw('symbolic-ref', '-q', 'HEAD')\n if (!ref) {\n throw new AbortError(\n \"Git HEAD can't be detached to run command\",\n outputContent`Run ${outputToken.genericShellCommand(\n 'git checkout [branchName]',\n )} to reattach HEAD or see git ${outputToken.link(\n 'documentation',\n 'https://git-scm.com/book/en/v2/Git-Internals-Git-References',\n )} for more details`,\n )\n }\n return ref.trim()\n}\n\n/**\n * If \"git\" is not present in the environment it throws\n * an abort error.\n */\nexport async function ensureGitIsPresentOrAbort(): Promise<void> {\n if (!(await hasGit())) {\n throw new AbortError(\n `Git is necessary in the environment to continue`,\n outputContent`Install ${outputToken.link(\n 'git',\n 'https://git-scm.com/book/en/v2/Getting-Started-Installing-Git',\n )}`,\n )\n }\n}\n\nexport class OutsideGitDirectoryError extends AbortError {}\n/**\n * If command run from outside a .git directory tree\n * it throws an abort error.\n *\n * @param directory - The directory to check.\n */\nexport async function ensureInsideGitDirectory(directory?: string): Promise<void> {\n if (!(await git({baseDir: directory}).checkIsRepo())) {\n throw new OutsideGitDirectoryError(`${outputToken.path(directory || cwd())} is not a Git directory`)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../../src/public/node/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,qBAAqB,EAAC,MAAM,wBAAwB,CAAA;AACpE,OAAO,EAAC,cAAc,EAAC,MAAM,SAAS,CAAA;AACtC,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAC7B,OAAO,EAAC,aAAa,EAAE,WAAW,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACnF,OAAO,GAAoF,MAAM,YAAY,CAAA;AAE7G;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,SAAiB,EAAE,aAAa,GAAG,MAAM;IACrF,WAAW,CAAC,aAAa,CAAA,kCAAkC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAC5F,MAAM,yBAAyB,EAAE,CAAA;IACjC,gHAAgH;IAChH,6DAA6D;IAC7D,aAAa;IACb,MAAM,IAAI,GAAG,GAAG,CAAC,SAAS,CAAC,CAAA;IAC3B,MAAM,IAAI,CAAC,IAAI,EAAE,CAAA;IACjB,MAAM,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAA;AAC/C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAAC,SAAiB,EAAE,KAAe;IACpF,6DAA6D;IAC7D,aAAa;IACb,MAAM,IAAI,GAAG,GAAG,CAAC,SAAS,CAAC,CAAA;IAC3B,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,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,WAAW,CAAC,IAAI,CAAC,SAAS,IAAI,GAAG,EAAE,CAAC,yBAAyB,CAAC,CAAA;KACrG;AACH,CAAC","sourcesContent":["import {hasGit, isTerminalInteractive} from './environment/local.js'\nimport {appendFileSync} from './fs.js'\nimport {AbortError} from './error.js'\nimport {cwd} from './path.js'\nimport {outputContent, outputToken, outputDebug} from '../../public/node/output.js'\nimport git, {TaskOptions, SimpleGitProgressEvent, DefaultLogFields, ListLogLine, SimpleGit} from 'simple-git'\n\n/**\n * Initialize a git repository at the given directory.\n *\n * @param directory - The directory where the git repository will be initialized.\n * @param initialBranch - The name of the initial branch.\n */\nexport async function initializeGitRepository(directory: string, initialBranch = 'main'): Promise<void> {\n outputDebug(outputContent`Initializing git repository at ${outputToken.path(directory)}...`)\n await ensureGitIsPresentOrAbort()\n // We use init and checkout instead of `init --initial-branch` because the latter is only supported in git 2.28+\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const repo = git(directory)\n await repo.init()\n await repo.checkoutLocalBranch(initialBranch)\n}\n\n/**\n * Given a Git repository and a list of absolute paths to files contained\n * in the repository, it filters and returns the files that are ignored\n * by the .gitignore.\n *\n * @param directory - The absolute path to the directory containing the files.\n * @param files - The list of files to check against.\n */\nexport async function checkIfIgnoredInGitRepository(directory: string, files: string[]): Promise<string[]> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const repo = git(directory)\n const ignoredLockfile = await repo.checkIgnore(files)\n return ignoredLockfile\n}\n\nexport interface GitIgnoreTemplate {\n [section: string]: string[]\n}\n/**\n * Create a .gitignore file in the given directory.\n *\n * @param directory - The directory where the .gitignore file will be created.\n * @param template - The template to use to create the .gitignore file.\n */\nexport function createGitIgnore(directory: string, template: GitIgnoreTemplate): void {\n outputDebug(outputContent`Creating .gitignore at ${outputToken.path(directory)}...`)\n const filePath = `${directory}/.gitignore`\n\n let fileContent = ''\n for (const [section, lines] of Object.entries(template)) {\n fileContent += `# ${section}\\n`\n fileContent += `${lines.join('\\n')}\\n\\n`\n }\n\n appendFileSync(filePath, fileContent)\n}\n\n/**\n * Options to use when cloning a git repository.\n *\n * @param repoUrl - The URL of the repository to clone.\n * @param destination - The directory where the repository will be cloned.\n * @param progressUpdater - A function that will be called with the progress of the clone.\n * @param shallow - Whether to clone the repository shallowly.\n * @param latestTag - Whether to clone the latest tag instead of the default branch.\n */\nexport interface GitCloneOptions {\n repoUrl: string\n destination: string\n progressUpdater?: (statusString: string) => void\n shallow?: boolean\n latestTag?: boolean\n}\n/**\n * Clone a git repository.\n *\n * @param cloneOptions - The options to use to clone the repository.\n * @returns A promise that resolves when the clone is complete.\n */\nexport async function downloadGitRepository(cloneOptions: GitCloneOptions): Promise<void> {\n const {repoUrl, destination, progressUpdater, shallow, latestTag} = cloneOptions\n outputDebug(outputContent`Git-cloning repository ${repoUrl} into ${outputToken.path(destination)}...`)\n await ensureGitIsPresentOrAbort()\n const [repository, branch] = repoUrl.split('#')\n const options: TaskOptions = {'--recurse-submodules': null}\n\n if (branch && latestTag) {\n throw new AbortError(\"Error cloning the repository. Git can't clone the latest release with a 'branch'.\")\n }\n if (branch) {\n options['--branch'] = branch\n }\n\n if (shallow && latestTag) {\n throw new AbortError(\n \"Error cloning the repository. Git can't clone the latest release with the 'shallow' property.\",\n )\n }\n if (shallow) {\n options['--depth'] = 1\n }\n\n const progress = ({stage, progress, processed, total}: SimpleGitProgressEvent) => {\n const updateString = `${stage}, ${processed}/${total} objects (${progress}% complete)`\n if (progressUpdater) progressUpdater(updateString)\n }\n\n const simpleGitOptions = {\n progress,\n ...(!isTerminalInteractive() && {config: ['core.askpass=true']}),\n }\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n await git(simpleGitOptions).clone(repository!, destination, options)\n\n if (latestTag) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const localGitRepository = git(destination)\n const latestTag = await getLocalLatestTag(localGitRepository, repoUrl)\n await localGitRepository.checkout(latestTag)\n }\n } catch (err) {\n if (err instanceof Error) {\n const abortError = new AbortError(err.message)\n abortError.stack = err.stack\n throw abortError\n }\n throw err\n }\n}\n\n/**\n * Get the most recent tag of a local git repository.\n *\n * @param repository - The local git repository.\n * @param repoUrl - The URL of the repository.\n * @returns The most recent tag of the repository.\n */\nasync function getLocalLatestTag(repository: SimpleGit, repoUrl: string): Promise<string> {\n const latest = (await repository.tags()).latest\n\n if (!latest) {\n throw new AbortError(`Couldn't obtain the most recent tag of the repository ${repoUrl}`)\n }\n\n return latest\n}\n\n/**\n * Get the latest commit of a git repository.\n *\n * @param directory - The directory of the git repository.\n * @returns The latest commit of the repository.\n */\nexport async function getLatestGitCommit(directory?: string): Promise<DefaultLogFields & ListLogLine> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const logs = await git({baseDir: directory}).log({\n maxCount: 1,\n })\n if (!logs.latest) {\n throw new AbortError(\n 'Must have at least one commit to run command',\n outputContent`Run ${outputToken.genericShellCommand(\n \"git commit -m 'Initial commit'\",\n )} to create your first commit.`,\n )\n }\n return logs.latest\n}\n\n/**\n * Add all files to the git index from the given directory.\n *\n * @param directory - The directory where the git repository is located.\n * @returns A promise that resolves when the files are added to the index.\n */\nexport async function addAllToGitFromDirectory(directory?: string): Promise<void> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const simpleGit = git({baseDir: directory})\n await simpleGit.raw('add', '--all')\n}\n\nexport interface CreateGitCommitOptions {\n directory?: string\n author?: string\n}\n\n/**\n * Create a git commit.\n *\n * @param message - The message of the commit.\n * @param options - The options to use to create the commit.\n * @returns The hash of the created commit.\n */\nexport async function createGitCommit(message: string, options?: CreateGitCommitOptions): Promise<string> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const simpleGit = git({baseDir: options?.directory})\n\n const commitOptions = options?.author ? {'--author': options.author} : undefined\n const result = await simpleGit.commit(message, commitOptions)\n\n return result.commit\n}\n\n/**\n * Get the HEAD symbolic reference of a git repository.\n *\n * @param directory - The directory of the git repository.\n * @returns The HEAD symbolic reference of the repository.\n */\nexport async function getHeadSymbolicRef(directory?: string): Promise<string> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const ref = await git({baseDir: directory}).raw('symbolic-ref', '-q', 'HEAD')\n if (!ref) {\n throw new AbortError(\n \"Git HEAD can't be detached to run command\",\n outputContent`Run ${outputToken.genericShellCommand(\n 'git checkout [branchName]',\n )} to reattach HEAD or see git ${outputToken.link(\n 'documentation',\n 'https://git-scm.com/book/en/v2/Git-Internals-Git-References',\n )} for more details`,\n )\n }\n return ref.trim()\n}\n\n/**\n * If \"git\" is not present in the environment it throws\n * an abort error.\n */\nexport async function ensureGitIsPresentOrAbort(): Promise<void> {\n if (!(await hasGit())) {\n throw new AbortError(\n `Git is necessary in the environment to continue`,\n outputContent`Install ${outputToken.link(\n 'git',\n 'https://git-scm.com/book/en/v2/Getting-Started-Installing-Git',\n )}`,\n )\n }\n}\n\nexport class OutsideGitDirectoryError extends AbortError {}\n/**\n * If command run from outside a .git directory tree\n * it throws an abort error.\n *\n * @param directory - The directory to check.\n */\nexport async function ensureInsideGitDirectory(directory?: string): Promise<void> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (!(await git({baseDir: directory}).checkIsRepo())) {\n throw new OutsideGitDirectoryError(`${outputToken.path(directory || cwd())} is not a Git directory`)\n }\n}\n"]}
|
|
@@ -7,7 +7,7 @@ export { createApp, createRouter, IncomingMessage, ServerResponse, Compatibility
|
|
|
7
7
|
* @returns A FormData object.
|
|
8
8
|
*/
|
|
9
9
|
export declare function formData(): FormData;
|
|
10
|
-
export
|
|
10
|
+
export type Response = ReturnType<typeof nodeFetch>;
|
|
11
11
|
/**
|
|
12
12
|
* An interface that abstracts way node-fetch. When Node has built-in
|
|
13
13
|
* support for "fetch" in the standard library, we can drop the node-fetch
|
|
@@ -31,3 +31,11 @@ export declare function fetch(url: RequestInfo, init?: RequestInit): Response;
|
|
|
31
31
|
* @returns A promise that resolves with the response.
|
|
32
32
|
*/
|
|
33
33
|
export declare function shopifyFetch(url: RequestInfo, init?: RequestInit): Response;
|
|
34
|
+
/**
|
|
35
|
+
* Download a file from a URL to a local path.
|
|
36
|
+
*
|
|
37
|
+
* @param url - The URL to download from.
|
|
38
|
+
* @param to - The local path to download to.
|
|
39
|
+
* @returns - A promise that resolves with the local path.
|
|
40
|
+
*/
|
|
41
|
+
export declare function downloadFile(url: string, to: string): Promise<string>;
|
package/dist/public/node/http.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { dirname } from './path.js';
|
|
2
|
+
import { createFileWriteStream, fileExistsSync, mkdirSync, unlinkFileSync } from './fs.js';
|
|
1
3
|
import { buildHeaders, httpsAgent, sanitizedHeadersOutput } from '../../private/node/api/headers.js';
|
|
2
4
|
import { outputContent, outputDebug } from '../../public/node/output.js';
|
|
3
5
|
import FormData from 'form-data';
|
|
@@ -55,4 +57,36 @@ ${sanitizedHeadersOutput((options?.headers ?? {}))}
|
|
|
55
57
|
outputDebug(`Request to ${url.toString()} completed with status ${response.status} in ${Math.round(t1 - t0)} ms`);
|
|
56
58
|
return response;
|
|
57
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Download a file from a URL to a local path.
|
|
62
|
+
*
|
|
63
|
+
* @param url - The URL to download from.
|
|
64
|
+
* @param to - The local path to download to.
|
|
65
|
+
* @returns - A promise that resolves with the local path.
|
|
66
|
+
*/
|
|
67
|
+
export function downloadFile(url, to) {
|
|
68
|
+
outputDebug(`Downloading ${url} to ${to}`);
|
|
69
|
+
return new Promise((resolve, reject) => {
|
|
70
|
+
if (!fileExistsSync(dirname(to))) {
|
|
71
|
+
mkdirSync(dirname(to));
|
|
72
|
+
}
|
|
73
|
+
const file = createFileWriteStream(to);
|
|
74
|
+
file.on('finish', () => {
|
|
75
|
+
file.close();
|
|
76
|
+
resolve(to);
|
|
77
|
+
});
|
|
78
|
+
file.on('error', (err) => {
|
|
79
|
+
unlinkFileSync(to);
|
|
80
|
+
reject(err);
|
|
81
|
+
});
|
|
82
|
+
nodeFetch(url, { redirect: 'follow' })
|
|
83
|
+
.then((res) => {
|
|
84
|
+
res.body?.pipe(file);
|
|
85
|
+
})
|
|
86
|
+
.catch((err) => {
|
|
87
|
+
unlinkFileSync(to);
|
|
88
|
+
reject(err);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
58
92
|
//# sourceMappingURL=http.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/public/node/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,UAAU,EAAE,sBAAsB,EAAC,MAAM,mCAAmC,CAAA;AAClG,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACtE,OAAO,QAAQ,MAAM,WAAW,CAAA;AAChC,OAAO,SAAqC,MAAM,YAAY,CAAA;AAC9D,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAA;AAEtC,OAAO,EACL,SAAS,EACT,YAAY,EAIZ,WAAW,EACX,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,OAAO,GACR,MAAM,IAAI,CAAA;AAEX;;;;GAIG;AACH,MAAM,UAAU,QAAQ;IACtB,OAAO,IAAI,QAAQ,EAAE,CAAA;AACvB,CAAC;AAID;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,GAAgB,EAAE,IAAkB;IAC9D,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC3C,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAgB,EAAE,IAAkB;IACrE,MAAM,OAAO,GAAgB;QAC3B,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;QACf,OAAO,EAAE;YACP,GAAG,CAAC,MAAM,YAAY,EAAE,CAAC;YACzB,GAAG,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC;SACzB;KACF,CAAA;IAED,WAAW,CAAC,aAAa,CAAA;UACjB,OAAO,CAAC,MAAM,IAAI,KAAK,mBAAmB,GAAG,CAAC,QAAQ,EAAE;EAChE,sBAAsB,CAAC,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,CAA+B,CAAC;CAC/E,CAAC,CAAA;IACA,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;IAC5B,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,EAAC,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,UAAU,EAAE,EAAC,CAAC,CAAA;IAC3E,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;IAC5B,WAAW,CAAC,cAAc,GAAG,CAAC,QAAQ,EAAE,0BAA0B,QAAQ,CAAC,MAAM,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAA;IACjH,OAAO,QAAQ,CAAA;AACjB,CAAC","sourcesContent":["import {buildHeaders, httpsAgent, sanitizedHeadersOutput} from '../../private/node/api/headers.js'\nimport {outputContent, outputDebug} from '../../public/node/output.js'\nimport FormData from 'form-data'\nimport nodeFetch, {RequestInfo, RequestInit} from 'node-fetch'\nimport {performance} from 'perf_hooks'\n\nexport {\n createApp,\n createRouter,\n IncomingMessage,\n ServerResponse,\n CompatibilityEvent,\n createError,\n send,\n sendError,\n sendRedirect,\n H3Error,\n} from 'h3'\n\n/**\n * Create a new FormData object.\n *\n * @returns A FormData object.\n */\nexport function formData(): FormData {\n return new FormData()\n}\n\nexport type Response = ReturnType<typeof nodeFetch>\n\n/**\n * An interface that abstracts way node-fetch. When Node has built-in\n * support for \"fetch\" in the standard library, we can drop the node-fetch\n * dependency from here.\n * Note that we are exposing types from \"node-fetch\". The reason being is that\n * they are consistent with the Web API so if we drop node-fetch in the future\n * it won't require changes from the callers.\n *\n * @param url - This defines the resource that you wish to fetch.\n * @param init - An object containing any custom settings that you want to apply to the request.\n * @returns A promise that resolves with the response.\n */\nexport async function fetch(url: RequestInfo, init?: RequestInit): Response {\n const response = await nodeFetch(url, init)\n return response\n}\n\n/**\n * A fetch function to use with Shopify services. The function ensures the right\n * TLS configuragion is used based on the environment in which the service is running\n * (e.g. Spin).\n *\n * @param url - This defines the resource that you wish to fetch.\n * @param init - An object containing any custom settings that you want to apply to the request.\n * @returns A promise that resolves with the response.\n */\nexport async function shopifyFetch(url: RequestInfo, init?: RequestInit): Response {\n const options: RequestInit = {\n ...(init ?? {}),\n headers: {\n ...(await buildHeaders()),\n ...(init?.headers ?? {}),\n },\n }\n\n outputDebug(outputContent`\nSending ${options.method ?? 'GET'} request to URL ${url.toString()} and headers:\n${sanitizedHeadersOutput((options?.headers ?? {}) as {[header: string]: string})}\n`)\n const t0 = performance.now()\n const response = await nodeFetch(url, {...init, agent: await httpsAgent()})\n const t1 = performance.now()\n outputDebug(`Request to ${url.toString()} completed with status ${response.status} in ${Math.round(t1 - t0)} ms`)\n return response\n}\n"]}
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/public/node/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,qBAAqB,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAC,MAAM,SAAS,CAAA;AACxF,OAAO,EAAC,YAAY,EAAE,UAAU,EAAE,sBAAsB,EAAC,MAAM,mCAAmC,CAAA;AAClG,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACtE,OAAO,QAAQ,MAAM,WAAW,CAAA;AAChC,OAAO,SAAqC,MAAM,YAAY,CAAA;AAC9D,OAAO,EAAC,WAAW,EAAC,MA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AE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAA;IACjH,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,EAAU;IAClD,WAAW,CAAC,eAAe,GAAG,OAAO,EAAE,EAAE,CAAC,CAAA;IAE1C,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7C,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE;YAChC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAA;SACvB;QAED,MAAM,IAAI,GAAG,qBAAqB,CAAC,EAAE,CAAC,CAAA;QAEtC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YACrB,IAAI,CAAC,KAAK,EAAE,CAAA;YACZ,OAAO,CAAC,EAAE,CAAC,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACvB,cAAc,CAAC,EAAE,CAAC,CAAA;YAClB,MAAM,CAAC,GAAG,CAAC,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,SAAS,CAAC,GAAG,EAAE,EAAC,QAAQ,EAAE,QAAQ,EAAC,CAAC;aACjC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YACZ,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;QACtB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACb,cAAc,CAAC,EAAE,CAAC,CAAA;YAClB,MAAM,CAAC,GAAG,CAAC,CAAA;QACb,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {dirname} from './path.js'\nimport {createFileWriteStream, fileExistsSync, mkdirSync, unlinkFileSync} from './fs.js'\nimport {buildHeaders, httpsAgent, sanitizedHeadersOutput} from '../../private/node/api/headers.js'\nimport {outputContent, outputDebug} from '../../public/node/output.js'\nimport FormData from 'form-data'\nimport nodeFetch, {RequestInfo, RequestInit} from 'node-fetch'\nimport {performance} from 'perf_hooks'\n\nexport {\n createApp,\n createRouter,\n IncomingMessage,\n ServerResponse,\n CompatibilityEvent,\n createError,\n send,\n sendError,\n sendRedirect,\n H3Error,\n} from 'h3'\n\n/**\n * Create a new FormData object.\n *\n * @returns A FormData object.\n */\nexport function formData(): FormData {\n return new FormData()\n}\n\nexport type Response = ReturnType<typeof nodeFetch>\n\n/**\n * An interface that abstracts way node-fetch. When Node has built-in\n * support for \"fetch\" in the standard library, we can drop the node-fetch\n * dependency from here.\n * Note that we are exposing types from \"node-fetch\". The reason being is that\n * they are consistent with the Web API so if we drop node-fetch in the future\n * it won't require changes from the callers.\n *\n * @param url - This defines the resource that you wish to fetch.\n * @param init - An object containing any custom settings that you want to apply to the request.\n * @returns A promise that resolves with the response.\n */\nexport async function fetch(url: RequestInfo, init?: RequestInit): Response {\n const response = await nodeFetch(url, init)\n return response\n}\n\n/**\n * A fetch function to use with Shopify services. The function ensures the right\n * TLS configuragion is used based on the environment in which the service is running\n * (e.g. Spin).\n *\n * @param url - This defines the resource that you wish to fetch.\n * @param init - An object containing any custom settings that you want to apply to the request.\n * @returns A promise that resolves with the response.\n */\nexport async function shopifyFetch(url: RequestInfo, init?: RequestInit): Response {\n const options: RequestInit = {\n ...(init ?? {}),\n headers: {\n ...(await buildHeaders()),\n ...(init?.headers ?? {}),\n },\n }\n\n outputDebug(outputContent`\nSending ${options.method ?? 'GET'} request to URL ${url.toString()} and headers:\n${sanitizedHeadersOutput((options?.headers ?? {}) as {[header: string]: string})}\n`)\n const t0 = performance.now()\n const response = await nodeFetch(url, {...init, agent: await httpsAgent()})\n const t1 = performance.now()\n outputDebug(`Request to ${url.toString()} completed with status ${response.status} in ${Math.round(t1 - t0)} ms`)\n return response\n}\n\n/**\n * Download a file from a URL to a local path.\n *\n * @param url - The URL to download from.\n * @param to - The local path to download to.\n * @returns - A promise that resolves with the local path.\n */\nexport function downloadFile(url: string, to: string): Promise<string> {\n outputDebug(`Downloading ${url} to ${to}`)\n\n return new Promise<string>((resolve, reject) => {\n if (!fileExistsSync(dirname(to))) {\n mkdirSync(dirname(to))\n }\n\n const file = createFileWriteStream(to)\n\n file.on('finish', () => {\n file.close()\n resolve(to)\n })\n\n file.on('error', (err) => {\n unlinkFileSync(to)\n reject(err)\n })\n\n nodeFetch(url, {redirect: 'follow'})\n .then((res) => {\n res.body?.pipe(file)\n })\n .catch((err) => {\n unlinkFileSync(to)\n reject(err)\n })\n })\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MonorailEventPublic } from './monorail.js';
|
|
2
2
|
import { PickByPrefix } from '../common/ts/pick-by-prefix.js';
|
|
3
3
|
import { AnyJson } from '../../private/common/json.js';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
type ProvideMetadata<T> = () => Partial<T> | Promise<Partial<T>>;
|
|
5
|
+
type MetadataErrorHandling = 'auto' | 'mute-and-report' | 'bubble';
|
|
6
6
|
export interface RuntimeMetadataManager<TPublic extends AnyJson, TSensitive extends AnyJson> {
|
|
7
7
|
/** Add some public metadata -- this should not contain any PII. */
|
|
8
8
|
addPublicMetadata: (getData: ProvideMetadata<TPublic>, onError?: MetadataErrorHandling) => Promise<void>;
|
|
@@ -13,8 +13,8 @@ export interface RuntimeMetadataManager<TPublic extends AnyJson, TSensitive exte
|
|
|
13
13
|
/** Get a snapshot of the tracked sensitive data. */
|
|
14
14
|
getAllSensitiveMetadata: () => Partial<TSensitive>;
|
|
15
15
|
}
|
|
16
|
-
export
|
|
17
|
-
export
|
|
16
|
+
export type PublicSchema<T> = T extends RuntimeMetadataManager<infer TPublic, infer _TSensitive> ? TPublic : never;
|
|
17
|
+
export type SensitiveSchema<T> = T extends RuntimeMetadataManager<infer _TPublic, infer TSensitive> ? TSensitive : never;
|
|
18
18
|
/**
|
|
19
19
|
* Creates a container for metadata collected at runtime.
|
|
20
20
|
* The container provides async-safe functions for extracting the gathered metadata, and for setting it.
|
|
@@ -24,7 +24,7 @@ export declare type SensitiveSchema<T> = T extends RuntimeMetadataManager<infer
|
|
|
24
24
|
export declare function createRuntimeMetadataContainer<TPublic extends AnyJson, TSensitive extends AnyJson = {
|
|
25
25
|
[key: string]: never;
|
|
26
26
|
}>(): RuntimeMetadataManager<TPublic, TSensitive>;
|
|
27
|
-
|
|
27
|
+
type CmdFieldsFromMonorail = PickByPrefix<MonorailEventPublic, 'cmd_all_'> & PickByPrefix<MonorailEventPublic, 'cmd_app_'>;
|
|
28
28
|
declare const coreData: RuntimeMetadataManager<CmdFieldsFromMonorail, {
|
|
29
29
|
commandStartOptions: {
|
|
30
30
|
startTime: number;
|
|
@@ -48,6 +48,6 @@ export declare const getAllPublicMetadata: () => Partial<CmdFieldsFromMonorail>,
|
|
|
48
48
|
startArgs: string[];
|
|
49
49
|
};
|
|
50
50
|
}>, onError?: MetadataErrorHandling) => Promise<void>;
|
|
51
|
-
export
|
|
52
|
-
export
|
|
51
|
+
export type Public = PublicSchema<typeof coreData>;
|
|
52
|
+
export type Sensitive = SensitiveSchema<typeof coreData>;
|
|
53
53
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { JsonMap } from '../../private/common/json.js';
|
|
2
|
-
import { DeepRequired } from '
|
|
3
|
-
|
|
2
|
+
import { DeepRequired } from '../common/ts/deep-required.js';
|
|
3
|
+
export { DeepRequired };
|
|
4
|
+
type Optional<T> = T | null;
|
|
4
5
|
export declare const MONORAIL_COMMAND_TOPIC: "app_cli3_command/1.2";
|
|
5
6
|
export interface Schemas {
|
|
6
7
|
[MONORAIL_COMMAND_TOPIC]: {
|
|
@@ -88,9 +89,9 @@ export interface Schemas {
|
|
|
88
89
|
public: JsonMap;
|
|
89
90
|
};
|
|
90
91
|
}
|
|
91
|
-
export
|
|
92
|
-
export
|
|
93
|
-
|
|
92
|
+
export type MonorailEventPublic = DeepRequired<Schemas[typeof MONORAIL_COMMAND_TOPIC]['public']>;
|
|
93
|
+
export type MonorailEventSensitive = Schemas[typeof MONORAIL_COMMAND_TOPIC]['sensitive'];
|
|
94
|
+
type MonorailResult = {
|
|
94
95
|
type: 'ok';
|
|
95
96
|
} | {
|
|
96
97
|
type: 'error';
|
|
@@ -105,4 +106,3 @@ declare type MonorailResult = {
|
|
|
105
106
|
* @returns A result indicating whether the event was successfully published.
|
|
106
107
|
*/
|
|
107
108
|
export declare function publishMonorailEvent<TSchemaId extends keyof Schemas, TPayload extends Schemas[TSchemaId]>(schemaId: TSchemaId, publicData: TPayload['public'], sensitiveData: TPayload['sensitive']): Promise<MonorailResult>;
|
|
108
|
-
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monorail.js","sourceRoot":"","sources":["../../../src/public/node/monorail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"monorail.js","sourceRoot":"","sources":["../../../src/public/node/monorail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,WAAW,CAAA;AAE/B,OAAO,EAAC,WAAW,EAAE,aAAa,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AAKnF,MAAM,GAAG,GAAG,iDAAiD,CAAA;AAI7D,mFAAmF;AACnF,MAAM,CAAC,MAAM,sBAAsB,GAAG,sBAA+B,CAAA;AA+GrE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,QAAmB,EACnB,UAA8B,EAC9B,aAAoC;IAEpC,IAAI;QACF,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;QACxC,MAAM,OAAO,GAAG,EAAC,GAAG,UAAU,EAAE,GAAG,aAAa,EAAC,CAAA;QACjD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,EAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAC,CAAC,CAAA;QAC3D,MAAM,OAAO,GAAG,YAAY,CAAC,WAAW,CAAC,CAAA;QAEzC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAC,CAAC,CAAA;QAElE,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;YAC3B,WAAW,CAAC,aAAa,CAAA,yBAAyB,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;YAC9E,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,CAAA;SACpB;aAAM;YACL,WAAW,CAAC,qCAAqC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;YACvE,OAAO,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,UAAU,EAAC,CAAA;SACrD;QACD,qDAAqD;KACtD;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,OAAO,GAAG,kCAAkC,CAAA;QAChD,IAAI,KAAK,YAAY,KAAK,EAAE;YAC1B,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;SAC/C;QACD,WAAW,CAAC,OAAO,CAAC,CAAA;QACpB,OAAO,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAC,CAAA;KAChC;AACH,CAAC;AAED,MAAM,YAAY,GAAG,CAAC,WAAmB,EAAE,EAAE;IAC3C,OAAO;QACL,cAAc,EAAE,iCAAiC;QACjD,qCAAqC,EAAE,WAAW,CAAC,QAAQ,EAAE;QAC7D,kCAAkC,EAAE,WAAW,CAAC,QAAQ,EAAE;KAC3D,CAAA;AACH,CAAC,CAAA","sourcesContent":["import {fetch} from './http.js'\nimport {JsonMap} from '../../private/common/json.js'\nimport {outputDebug, outputContent, outputToken} from '../../public/node/output.js'\nimport {DeepRequired} from '../common/ts/deep-required.js'\n\nexport {DeepRequired}\n\nconst url = 'https://monorail-edge.shopifysvc.com/v1/produce'\n\ntype Optional<T> = T | null\n\n// This is the topic name of the main event we log to Monorail, the command tracker\nexport const MONORAIL_COMMAND_TOPIC = 'app_cli3_command/1.2' as const\n\nexport interface Schemas {\n [MONORAIL_COMMAND_TOPIC]: {\n sensitive: {\n args: string\n error_message?: Optional<string>\n app_name?: Optional<string>\n metadata?: Optional<string>\n store_fqdn?: Optional<string>\n\n // Dev related commands\n cmd_dev_tunnel_custom?: Optional<string>\n\n // Environment\n env_plugin_installed_all?: Optional<string>\n }\n public: {\n partner_id?: Optional<number>\n command: string\n project_type?: Optional<string>\n time_start: number\n time_end: number\n total_time: number\n success: boolean\n api_key?: Optional<string>\n cli_version: string\n uname: string\n ruby_version: string\n node_version: string\n is_employee: boolean\n store_fqdn_hash?: Optional<string>\n\n // Any and all commands\n cmd_all_alias_used?: Optional<string>\n cmd_all_launcher?: Optional<string>\n cmd_all_path_override?: Optional<boolean>\n cmd_all_path_override_hash?: Optional<string>\n cmd_all_plugin?: Optional<string>\n cmd_all_topic?: Optional<string>\n cmd_all_verbose?: Optional<boolean>\n\n // Any extension related command\n cmd_extensions_binary_from_source?: Optional<boolean>\n\n // Scaffolding related commands\n cmd_scaffold_required_auth?: Optional<boolean>\n cmd_scaffold_template_custom?: Optional<boolean>\n cmd_scaffold_template_flavor?: Optional<string>\n cmd_scaffold_type?: Optional<string>\n cmd_scaffold_type_category?: Optional<string>\n cmd_scaffold_type_gated?: Optional<boolean>\n cmd_scaffold_type_owner?: Optional<string>\n cmd_scaffold_used_prompts_for_type?: Optional<boolean>\n\n // Used in several but not all commands\n cmd_app_dependency_installation_skipped?: Optional<boolean>\n cmd_app_reset_used?: Optional<boolean>\n\n // Dev related commands\n cmd_dev_tunnel_type?: Optional<string>\n cmd_dev_tunnel_custom_hash?: Optional<string>\n cmd_dev_urls_updated?: Optional<boolean>\n\n // App setup\n app_extensions_any?: Optional<boolean>\n app_extensions_breakdown?: Optional<string>\n app_extensions_count?: Optional<number>\n app_extensions_custom_layout?: Optional<boolean>\n app_extensions_function_any?: Optional<boolean>\n app_extensions_function_count?: Optional<number>\n app_extensions_function_custom_layout?: Optional<boolean>\n app_extensions_theme_any?: Optional<boolean>\n app_extensions_theme_count?: Optional<number>\n app_extensions_theme_custom_layout?: Optional<boolean>\n app_extensions_ui_any?: Optional<boolean>\n app_extensions_ui_count?: Optional<number>\n app_extensions_ui_custom_layout?: Optional<boolean>\n app_name_hash?: Optional<string>\n app_path_hash?: Optional<string>\n app_scopes?: Optional<string>\n app_web_backend_any?: Optional<boolean>\n app_web_backend_count?: Optional<number>\n app_web_custom_layout?: Optional<boolean>\n app_web_framework?: Optional<string>\n app_web_frontend_any?: Optional<boolean>\n app_web_frontend_count?: Optional<number>\n\n // Environment\n env_ci?: Optional<boolean>\n env_ci_platform?: Optional<string>\n env_device_id?: Optional<string>\n env_package_manager?: Optional<string>\n env_package_manager_workspaces?: Optional<boolean>\n env_plugin_installed_any_custom?: Optional<boolean>\n env_plugin_installed_shopify?: Optional<string>\n env_shell?: Optional<string>\n env_web_ide?: Optional<string>\n env_cloud?: Optional<string>\n }\n }\n [schemaId: string]: {sensitive: JsonMap; public: JsonMap}\n}\n\n// In reality, we're normally most interested in just this from Schemas, so export it for ease of use.\n// The monorail schema itself has lots of optional values as it must be backwards-compatible. For our schema we want mandatory values instead.\nexport type MonorailEventPublic = DeepRequired<Schemas[typeof MONORAIL_COMMAND_TOPIC]['public']>\nexport type MonorailEventSensitive = Schemas[typeof MONORAIL_COMMAND_TOPIC]['sensitive']\n\ntype MonorailResult = {type: 'ok'} | {type: 'error'; message: string}\n\n/**\n * Publishes an event to Monorail.\n *\n * @param schemaId - The schema ID of the event to publish.\n * @param publicData - The public data to publish.\n * @param sensitiveData - The sensitive data to publish.\n * @returns A result indicating whether the event was successfully published.\n */\nexport async function publishMonorailEvent<TSchemaId extends keyof Schemas, TPayload extends Schemas[TSchemaId]>(\n schemaId: TSchemaId,\n publicData: TPayload['public'],\n sensitiveData: TPayload['sensitive'],\n): Promise<MonorailResult> {\n try {\n const currentTime = new Date().getTime()\n const payload = {...publicData, ...sensitiveData}\n const body = JSON.stringify({schema_id: schemaId, payload})\n const headers = buildHeaders(currentTime)\n\n const response = await fetch(url, {method: 'POST', body, headers})\n\n if (response.status === 200) {\n outputDebug(outputContent`Analytics event sent: ${outputToken.json(payload)}`)\n return {type: 'ok'}\n } else {\n outputDebug(`Failed to report usage analytics: ${response.statusText}`)\n return {type: 'error', message: response.statusText}\n }\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n let message = 'Failed to report usage analytics'\n if (error instanceof Error) {\n message = message.concat(`: ${error.message}`)\n }\n outputDebug(message)\n return {type: 'error', message}\n }\n}\n\nconst buildHeaders = (currentTime: number) => {\n return {\n 'Content-Type': 'application/json; charset=utf-8',\n 'X-Monorail-Edge-Event-Created-At-Ms': currentTime.toString(),\n 'X-Monorail-Edge-Event-Sent-At-Ms': currentTime.toString(),\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
import { AbortError, BugError } from './error.js';
|
|
4
4
|
import { AbortSignal } from './abort.js';
|
|
5
5
|
import type { Writable } from 'stream';
|
|
@@ -13,19 +13,19 @@ export declare const pnpmLockfile = "pnpm-lock.yaml";
|
|
|
13
13
|
export declare const pnpmWorkspaceFile = "pnpm-workspace.yaml";
|
|
14
14
|
/** An array containing the lockfiles from all the package managers */
|
|
15
15
|
export declare const lockfiles: Lockfile[];
|
|
16
|
-
export
|
|
16
|
+
export type Lockfile = 'yarn.lock' | 'package-lock.json' | 'pnpm-lock.yaml';
|
|
17
17
|
/**
|
|
18
18
|
* A union type that represents the type of dependencies in the package.json
|
|
19
19
|
* - dev: devDependencies
|
|
20
20
|
* - prod: dependencies
|
|
21
21
|
* - peer: peerDependencies
|
|
22
22
|
*/
|
|
23
|
-
export
|
|
23
|
+
export type DependencyType = 'dev' | 'prod' | 'peer';
|
|
24
24
|
/**
|
|
25
25
|
* A union that represents the package managers available.
|
|
26
26
|
*/
|
|
27
27
|
export declare const packageManager: readonly ["yarn", "npm", "pnpm"];
|
|
28
|
-
export
|
|
28
|
+
export type PackageManager = typeof packageManager[number];
|
|
29
29
|
/**
|
|
30
30
|
* Returns an abort error that's thrown when a directory that's expected to have
|
|
31
31
|
* a package.json doesn't have it.
|
package/dist/public/node/os.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* @returns The username of the current user.
|
|
4
4
|
*/
|
|
5
5
|
export declare function username(platform?: typeof process.platform): Promise<string | null>;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
type PlatformArch = Exclude<typeof process.arch, 'x64' | 'ia32'> | 'amd64' | '386';
|
|
7
|
+
type PlatformStrings = Exclude<typeof process.platform, 'win32'> | 'windows';
|
|
8
8
|
/**
|
|
9
9
|
* Returns the platform and architecture.
|
|
10
10
|
* @returns Returns the current platform and architecture.
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import { PackageManager } from './node-package-manager.js';
|
|
3
3
|
import { ColorContentToken, CommandContentToken, ContentToken, ErrorContentToken, HeadingContentToken, ItalicContentToken, JsonContentToken, LinesDiffContentToken, LinkContentToken, PathContentToken, RawContentToken, SubHeadingContentToken } from '../../private/node/content-tokens.js';
|
|
4
4
|
import { AbortSignal } from '@shopify/cli-kit/node/abort';
|
|
5
5
|
import { Writable } from 'stream';
|
|
6
6
|
import type { Change } from 'diff';
|
|
7
7
|
export { default as logUpdate } from 'log-update';
|
|
8
|
-
export
|
|
8
|
+
export type Logger = Writable | ((message: string) => void);
|
|
9
9
|
export declare class TokenizedString {
|
|
10
10
|
value: string;
|
|
11
11
|
constructor(value: string);
|
|
12
12
|
}
|
|
13
|
-
export
|
|
13
|
+
export type OutputMessage = string | TokenizedString;
|
|
14
14
|
export declare const outputToken: {
|
|
15
15
|
raw(value: string): RawContentToken;
|
|
16
16
|
genericShellCommand(value: OutputMessage): CommandContentToken;
|
|
@@ -48,7 +48,7 @@ export declare function formatPackageManagerCommand(packageManager: PackageManag
|
|
|
48
48
|
*/
|
|
49
49
|
export declare function outputContent(strings: TemplateStringsArray, ...keys: (ContentToken<unknown> | string)[]): TokenizedString;
|
|
50
50
|
/** Log levels. */
|
|
51
|
-
export
|
|
51
|
+
export type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent';
|
|
52
52
|
export declare let collectedLogs: {
|
|
53
53
|
[key: string]: string[];
|
|
54
54
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import { relative, dirname, join, normalize, resolve, basename, extname, isAbsolute } from 'pathe';
|
|
3
3
|
import type { URL } from 'url';
|
|
4
4
|
export { join as joinPath, relative as relativePath, normalize as normalizePath, resolve as resolvePath, isAbsolute as isAbsolutePath, dirname, basename, extname, };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Result } from '../result.js';
|
|
2
2
|
import { ExtendableError } from '../error.js';
|
|
3
3
|
import { FanoutHookFunction, PluginReturnsForHook } from '../plugins.js';
|
|
4
|
-
export
|
|
4
|
+
export type TunnelErrorType = 'invalid-provider' | 'tunnel-already-running' | 'wrong-credentials' | 'unknown';
|
|
5
5
|
export declare class TunnelError extends ExtendableError {
|
|
6
6
|
type: TunnelErrorType;
|
|
7
7
|
constructor(type: TunnelErrorType, message?: string);
|
|
@@ -34,10 +34,10 @@ export interface HookReturnPerTunnelPlugin {
|
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
export
|
|
37
|
+
export type TunnelProviderFunction = FanoutHookFunction<'tunnel_provider', ''>;
|
|
38
|
+
export type TunnelStartFunction = FanoutHookFunction<'tunnel_start', ''>;
|
|
39
|
+
export type TunnelStartReturn = PluginReturnsForHook<'tunnel_start', ''>;
|
|
40
|
+
export type TunnelStartAction = (port: number) => Promise<TunnelStartReturn>;
|
|
41
41
|
export declare const defineProvider: (input: {
|
|
42
42
|
name: string;
|
|
43
43
|
}) => TunnelProviderFunction;
|
|
@@ -16,8 +16,8 @@ import { Config, Interfaces } from '@oclif/core';
|
|
|
16
16
|
* @returns A dictionary of plug-in names to the response from the hook.
|
|
17
17
|
*/
|
|
18
18
|
export declare function fanoutHooks<TPluginMap extends HookReturnsPerPlugin, TEvent extends string & keyof TPluginMap>(config: Interfaces.Config, event: TEvent, options: TPluginMap[typeof event]['options'], timeout?: number): Promise<Partial<TPluginMap[typeof event]['pluginReturns']>>;
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
type AppSpecificMonorailFields = PickByPrefix<MonorailEventPublic, 'app_', 'project_type' | 'api_key' | 'partner_id'> & PickByPrefix<MonorailEventPublic, 'cmd_extensions_'> & PickByPrefix<MonorailEventPublic, 'cmd_scaffold_'>;
|
|
20
|
+
type AppSpecificSensitiveMonorailFields = PickByPrefix<MonorailEventSensitive, 'app_'>;
|
|
21
21
|
export interface HookReturnsPerPlugin extends HookReturnPerTunnelPlugin {
|
|
22
22
|
public_command_metadata: {
|
|
23
23
|
options: {
|
|
@@ -46,8 +46,8 @@ export interface HookReturnsPerPlugin extends HookReturnPerTunnelPlugin {
|
|
|
46
46
|
};
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
export
|
|
50
|
-
export
|
|
49
|
+
export type PluginReturnsForHook<TEvent extends keyof TPluginMap, TPluginName extends keyof TPluginMap[TEvent]['pluginReturns'], TPluginMap extends HookReturnsPerPlugin = HookReturnsPerPlugin> = TPluginMap[TEvent]['pluginReturns'][TPluginName];
|
|
50
|
+
export type FanoutHookFunction<TEvent extends keyof TPluginMap = string, TPluginName extends keyof TPluginMap[TEvent]['pluginReturns'] = string, TPluginMap extends HookReturnsPerPlugin = HookReturnsPerPlugin> = (this: Interfaces.Hook.Context, options: TPluginMap[TEvent]['options'] & {
|
|
51
51
|
config: Interfaces.Config;
|
|
52
52
|
}) => Promise<PluginReturnsForHook<TEvent, TPluginName, TPluginMap>>;
|
|
53
53
|
/**
|
package/dist/public/node/ui.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { FatalError as Fatal } from './error.js';
|
|
2
2
|
import { OutputProcess } from './output.js';
|
|
3
|
-
import { AlertProps } from '../../private/node/ui/components/Alert.js';
|
|
3
|
+
import { AlertProps, CustomSection } from '../../private/node/ui/components/Alert.js';
|
|
4
4
|
import ScalarDict from '../../private/node/ui/components/Table/ScalarDict.js';
|
|
5
5
|
import { TableProps } from '../../private/node/ui/components/Table/Table.js';
|
|
6
6
|
import { Props as SelectPromptProps } from '../../private/node/ui/components/SelectPrompt.js';
|
|
7
7
|
import { Task } from '../../private/node/ui/components/Tasks.js';
|
|
8
8
|
import { Props as TextPromptProps } from '../../private/node/ui/components/TextPrompt.js';
|
|
9
|
-
import {
|
|
9
|
+
import { Props as SelectProps } from '../../private/node/ui/components/SelectInput.js';
|
|
10
10
|
import { Props as InfoTableProps } from '../../private/node/ui/components/Prompts/InfoTable.js';
|
|
11
|
+
import { SearchResults } from '../../private/node/ui/components/AutocompletePrompt.js';
|
|
12
|
+
import { TokenItem } from '../../private/node/ui/components/TokenizedText.js';
|
|
11
13
|
import { RenderOptions } from 'ink';
|
|
12
14
|
import { AbortController } from '@shopify/cli-kit/node/abort';
|
|
15
|
+
export { TokenItem };
|
|
13
16
|
interface RenderConcurrentOptions {
|
|
14
17
|
processes: OutputProcess[];
|
|
15
18
|
abortController?: AbortController;
|
|
@@ -20,7 +23,8 @@ interface RenderConcurrentOptions {
|
|
|
20
23
|
* Renders output from concurrent processes to the terminal with {@link ConcurrentOutput}.
|
|
21
24
|
*/
|
|
22
25
|
export declare function renderConcurrent({ processes, abortController, showTimestamps, renderOptions, }: RenderConcurrentOptions): Promise<void>;
|
|
23
|
-
export
|
|
26
|
+
export type AlertCustomSection = CustomSection;
|
|
27
|
+
export type RenderAlertOptions = Omit<AlertProps, 'type'>;
|
|
24
28
|
/**
|
|
25
29
|
* Renders an information banner to the console.
|
|
26
30
|
*
|
|
@@ -195,7 +199,8 @@ interface RenderAutocompletePromptProps<T> {
|
|
|
195
199
|
message: string;
|
|
196
200
|
choices: SelectProps<T>['items'];
|
|
197
201
|
infoTable?: InfoTableProps['table'];
|
|
198
|
-
search?: (term: string) => Promise<
|
|
202
|
+
search?: (term: string) => Promise<SearchResults<T>>;
|
|
203
|
+
hasMorePages?: boolean;
|
|
199
204
|
}
|
|
200
205
|
/**
|
|
201
206
|
* Renders an autocomplete prompt to the console.
|
|
@@ -223,6 +228,7 @@ export declare function renderAutocompletePrompt<T>(props: RenderAutocompletePro
|
|
|
223
228
|
* ```
|
|
224
229
|
*/
|
|
225
230
|
export declare function renderTable<T extends ScalarDict>(props: TableProps<T>): void;
|
|
231
|
+
export { Task };
|
|
226
232
|
/**
|
|
227
233
|
* Runs async tasks and displays their progress to the console.
|
|
228
234
|
*/
|
|
@@ -235,4 +241,3 @@ export declare function renderTasks<TContext>(tasks: Task<TContext>[]): Promise<
|
|
|
235
241
|
* ```
|
|
236
242
|
*/
|
|
237
243
|
export declare function renderTextPrompt(props: Omit<TextPromptProps, 'onSubmit'>): Promise<string>;
|
|
238
|
-
export {};
|
package/dist/public/node/ui.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isUnitTest } from './environment/local.js';
|
|
2
1
|
import { consoleError } from './output.js';
|
|
3
2
|
import ConcurrentOutput from '../../private/node/ui/components/ConcurrentOutput.js';
|
|
4
3
|
import { render, renderOnce } from '../../private/node/ui.js';
|
|
@@ -230,7 +229,9 @@ export function renderConfirmationPrompt({ message, infoTable, confirmationMessa
|
|
|
230
229
|
export function renderAutocompletePrompt(props) {
|
|
231
230
|
const newProps = {
|
|
232
231
|
search(term) {
|
|
233
|
-
return Promise.resolve(
|
|
232
|
+
return Promise.resolve({
|
|
233
|
+
data: props.choices.filter((item) => item.label.toLowerCase().includes(term.toLowerCase())),
|
|
234
|
+
});
|
|
234
235
|
},
|
|
235
236
|
...props,
|
|
236
237
|
};
|
|
@@ -259,7 +260,7 @@ export function renderTable(props) {
|
|
|
259
260
|
* Runs async tasks and displays their progress to the console.
|
|
260
261
|
*/
|
|
261
262
|
export async function renderTasks(tasks) {
|
|
262
|
-
return render(React.createElement(Tasks, { tasks: tasks
|
|
263
|
+
return render(React.createElement(Tasks, { tasks: tasks }));
|
|
263
264
|
}
|
|
264
265
|
/**
|
|
265
266
|
* Renders a text prompt to the console.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/public/node/ui.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAA;AAEjD,OAAO,EAAC,YAAY,EAAgB,MAAM,aAAa,CAAA;AACvD,OAAO,gBAAgB,MAAM,sDAAsD,CAAA;AACnF,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAC,KAAK,EAAC,MAAM,gCAAgC,CAAA;AAEpD,OAAO,EAAC,UAAU,EAAC,MAAM,gDAAgD,CAAA;AAEzE,OAAO,KAAmB,MAAM,iDAAiD,CAAA;AACjF,OAAO,EAAC,YAAY,EAA6B,MAAM,kDAAkD,CAAA;AACzG,OAAO,EAAC,KAAK,EAAO,MAAM,2CAA2C,CAAA;AACrE,OAAO,EAAC,UAAU,EAA2B,MAAM,gDAAgD,CAAA;AAGnG,OAAO,EAAC,kBAAkB,EAAC,MAAM,wDAAwD,CAAA;AACzF,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,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EAAE,KAAK;SACnB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAClB,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,WAAW,CAAuB,KAAoB;IACpE,OAAO,UAAU,CAAC,oBAAC,KAAK,OAAK,KAAK,GAAI,CAAC,CAAA;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAW,KAAuB;IACjE,OAAO,MAAM,CAAC,oBAAC,KAAK,IAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,GAAI,CAAC,CAAA;AAC9D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAwC;IACvE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,CAAC,oBAAC,UAAU,OAAK,KAAK,EAAE,QAAQ,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAI,EAAE;YAC7E,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAClB,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {isUnitTest} from './environment/local.js'\nimport {FatalError as Fatal} from './error.js'\nimport {consoleError, OutputProcess} from './output.js'\nimport ConcurrentOutput from '../../private/node/ui/components/ConcurrentOutput.js'\nimport {render, renderOnce} from '../../private/node/ui.js'\nimport {alert} from '../../private/node/ui/alert.js'\nimport {AlertProps} from '../../private/node/ui/components/Alert.js'\nimport {FatalError} from '../../private/node/ui/components/FatalError.js'\nimport ScalarDict from '../../private/node/ui/components/Table/ScalarDict.js'\nimport Table, {TableProps} from '../../private/node/ui/components/Table/Table.js'\nimport {SelectPrompt, Props as SelectPromptProps} from '../../private/node/ui/components/SelectPrompt.js'\nimport {Tasks, Task} from '../../private/node/ui/components/Tasks.js'\nimport {TextPrompt, Props as TextPromptProps} from '../../private/node/ui/components/TextPrompt.js'\nimport {Item as SelectItem, Props as SelectProps} from '../../private/node/ui/components/SelectInput.js'\nimport {Props as InfoTableProps} from '../../private/node/ui/components/Prompts/InfoTable.js'\nimport {AutocompletePrompt} from '../../private/node/ui/components/AutocompletePrompt.js'\nimport React from 'react'\nimport {RenderOptions} from 'ink'\nimport {AbortController} from '@shopify/cli-kit/node/abort'\n\ninterface RenderConcurrentOptions {\n processes: OutputProcess[]\n abortController?: AbortController\n showTimestamps?: boolean\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders output from concurrent processes to the terminal with {@link ConcurrentOutput}.\n */\nexport async function renderConcurrent({\n processes,\n abortController,\n showTimestamps = true,\n renderOptions = {},\n}: RenderConcurrentOptions) {\n return render(\n <ConcurrentOutput\n processes={processes}\n abortController={abortController ?? new AbortController()}\n showTimestamps={showTimestamps}\n />,\n renderOptions,\n )\n}\n\nexport type RenderAlertOptions = Omit<AlertProps, 'type'>\n\n/**\n * Renders an information banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ Body │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderInfo(options: RenderAlertOptions) {\n return alert({...options, type: 'info'})\n}\n\n/**\n * Renders a success banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderSuccess(options: RenderAlertOptions) {\n return alert({...options, type: 'success'})\n}\n\n/**\n * Renders a warning banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderWarning(options: RenderAlertOptions) {\n return alert({...options, type: 'warning'})\n}\n\n/**\n * Renders a Fatal error to the console inside a banner.\n *\n * ```\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ Couldn't connect to the Shopify Partner Dashboard. │\n * │ │\n * │ Check your internet connection and try again. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderFatalError(error: Fatal) {\n return renderOnce(<FatalError error={error} />, 'error', consoleError)\n}\n\n/**\n * Renders a select prompt to the console.\n *\n * ```\n * ? Associate your project with the org Castile Ventures?\n *\n * Add: • new-ext\n *\n * Remove: • integrated-demand-ext\n * • order-discount\n *\n * \\> (f) first\n * (s) second\n * (3) third\n * (4) fourth\n * (5) seventh\n * (6) tenth\n *\n * Automations\n * (7) fifth\n * (8) sixth\n *\n * Merchant Admin\n * (9) eighth\n * (10) ninth\n *\n * Press ↑↓ arrows to select, enter to confirm\n * ```\n */\nexport function renderSelectPrompt<T>(props: Omit<SelectPromptProps<T>, 'onSubmit'>): Promise<T> {\n return new Promise((resolve, reject) => {\n render(<SelectPrompt {...props} onSubmit={(value: T) => resolve(value)} />, {\n exitOnCtrlC: false,\n }).catch(reject)\n })\n}\n\ninterface RenderConfirmationPromptOptions extends Pick<SelectPromptProps<boolean>, 'message' | 'infoTable'> {\n confirmationMessage?: string\n cancellationMessage?: string\n}\n\n/**\n * Renders a confirmation prompt to the console.\n *\n * ? Do you want to continue?\n *\n * \\> (y) Yes, confirm\n * (n) No, canccel\n *\n * Press ↑↓ arrows to select, enter to confirm\n */\nexport function renderConfirmationPrompt({\n message,\n infoTable,\n confirmationMessage = 'Yes, confirm',\n cancellationMessage = 'No, cancel',\n}: RenderConfirmationPromptOptions): Promise<boolean> {\n const choices = [\n {\n label: confirmationMessage,\n value: true,\n key: 'y',\n },\n {\n label: cancellationMessage,\n value: false,\n key: 'n',\n },\n ]\n\n return renderSelectPrompt({\n choices,\n message,\n infoTable,\n })\n}\n\ninterface RenderAutocompletePromptProps<T> {\n message: string\n choices: SelectProps<T>['items']\n infoTable?: InfoTableProps['table']\n search?: (term: string) => Promise<SelectItem<T>[]>\n}\n\n/**\n * Renders an autocomplete prompt to the console.\n * ```\n * ? Select a template Type to search...\n\n * \\> first\n * second\n * third\n\n * Press ↑↓ arrows to select, enter to confirm\n * ```\n */\nexport function renderAutocompletePrompt<T>(props: RenderAutocompletePromptProps<T>): Promise<T> {\n const newProps = {\n search(term: string) {\n return Promise.resolve(props.choices.filter((item) => item.label.toLowerCase().includes(term.toLowerCase())))\n },\n ...props,\n }\n\n return new Promise((resolve, reject) => {\n render(<AutocompletePrompt {...newProps} onSubmit={(value: T) => resolve(value)} />, {\n exitOnCtrlC: false,\n }).catch(reject)\n })\n}\n\n/**\n * Renders a table to the console.\n *\n * ```\n * name role Identifier\n * ──────────────────────── ───────────── ──────────\n * Dawn [live] #1361\n * Studio #1363\n * Debut [unpublished] #1374\n * Development (1a23b4-MBP) [development] #1368\n * ```\n */\nexport function renderTable<T extends ScalarDict>(props: TableProps<T>) {\n return renderOnce(<Table {...props} />)\n}\n\n/**\n * Runs async tasks and displays their progress to the console.\n */\nexport async function renderTasks<TContext>(tasks: Task<TContext>[]) {\n return render(<Tasks tasks={tasks} silent={isUnitTest()} />)\n}\n\n/**\n * Renders a text prompt to the console.\n * ```\n * ? What is your name?\n * \\> John\n * ```\n */\nexport function renderTextPrompt(props: Omit<TextPromptProps, 'onSubmit'>): Promise<string> {\n return new Promise((resolve, reject) => {\n render(<TextPrompt {...props} onSubmit={(value: string) => resolve(value)} />, {\n exitOnCtrlC: false,\n }).catch(reject)\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/public/node/ui.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAgB,MAAM,aAAa,CAAA;AACvD,OAAO,gBAAgB,MAAM,sDAAsD,CAAA;AACnF,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAC,KAAK,EAAC,MAAM,gCAAgC,CAAA;AAEpD,OAAO,EAAC,UAAU,EAAC,MAAM,gDAAgD,CAAA;AAEzE,OAAO,KAAmB,MAAM,iDAAiD,CAAA;AACjF,OAAO,EAAC,YAAY,EAA6B,MAAM,kDAAkD,CAAA;AACzG,OAAO,EAAC,KAAK,EAAO,MAAM,2CAA2C,CAAA;AACrE,OAAO,EAAC,UAAU,EAA2B,MAAM,gDAAgD,CAAA;AAGnG,OAAO,EAAC,kBAAkB,EAAgB,MAAM,wDAAwD,CAAA;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AQ,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAI,EAAE;YACnF,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAClB,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,WAAW,CAAuB,KAAoB;IACpE,OAAO,UAAU,CAAC,oBAAC,KAAK,OAAK,KAAK,GAAI,CAAC,CAAA;AACzC,CAAC;AAID;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAW,KAAuB;IACjE,OAAO,MAAM,CAAC,oBAAC,KAAK,IAAC,KAAK,EAAE,KAAK,GAAI,CAAC,CAAA;AACxC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAwC;IACvE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,CAAC,oBAAC,UAAU,OAAK,KAAK,EAAE,QAAQ,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAI,EAAE;YAC7E,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAClB,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {FatalError as Fatal} from './error.js'\nimport {consoleError, OutputProcess} from './output.js'\nimport ConcurrentOutput from '../../private/node/ui/components/ConcurrentOutput.js'\nimport {render, renderOnce} from '../../private/node/ui.js'\nimport {alert} from '../../private/node/ui/alert.js'\nimport {AlertProps, CustomSection} from '../../private/node/ui/components/Alert.js'\nimport {FatalError} from '../../private/node/ui/components/FatalError.js'\nimport ScalarDict from '../../private/node/ui/components/Table/ScalarDict.js'\nimport Table, {TableProps} from '../../private/node/ui/components/Table/Table.js'\nimport {SelectPrompt, Props as SelectPromptProps} from '../../private/node/ui/components/SelectPrompt.js'\nimport {Tasks, Task} from '../../private/node/ui/components/Tasks.js'\nimport {TextPrompt, Props as TextPromptProps} from '../../private/node/ui/components/TextPrompt.js'\nimport {Props as SelectProps} from '../../private/node/ui/components/SelectInput.js'\nimport {Props as InfoTableProps} from '../../private/node/ui/components/Prompts/InfoTable.js'\nimport {AutocompletePrompt, SearchResults} from '../../private/node/ui/components/AutocompletePrompt.js'\nimport {TokenItem} from '../../private/node/ui/components/TokenizedText.js'\nimport React from 'react'\nimport {RenderOptions} from 'ink'\nimport {AbortController} from '@shopify/cli-kit/node/abort'\n\nexport {TokenItem}\n\ninterface RenderConcurrentOptions {\n processes: OutputProcess[]\n abortController?: AbortController\n showTimestamps?: boolean\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders output from concurrent processes to the terminal with {@link ConcurrentOutput}.\n */\nexport async function renderConcurrent({\n processes,\n abortController,\n showTimestamps = true,\n renderOptions = {},\n}: RenderConcurrentOptions) {\n return render(\n <ConcurrentOutput\n processes={processes}\n abortController={abortController ?? new AbortController()}\n showTimestamps={showTimestamps}\n />,\n renderOptions,\n )\n}\n\nexport type AlertCustomSection = CustomSection\nexport type RenderAlertOptions = Omit<AlertProps, 'type'>\n\n/**\n * Renders an information banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ Body │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderInfo(options: RenderAlertOptions) {\n return alert({...options, type: 'info'})\n}\n\n/**\n * Renders a success banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderSuccess(options: RenderAlertOptions) {\n return alert({...options, type: 'success'})\n}\n\n/**\n * Renders a warning banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderWarning(options: RenderAlertOptions) {\n return alert({...options, type: 'warning'})\n}\n\n/**\n * Renders a Fatal error to the console inside a banner.\n *\n * ```\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ Couldn't connect to the Shopify Partner Dashboard. │\n * │ │\n * │ Check your internet connection and try again. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderFatalError(error: Fatal) {\n return renderOnce(<FatalError error={error} />, 'error', consoleError)\n}\n\n/**\n * Renders a select prompt to the console.\n *\n * ```\n * ? Associate your project with the org Castile Ventures?\n *\n * Add: • new-ext\n *\n * Remove: • integrated-demand-ext\n * • order-discount\n *\n * \\> (f) first\n * (s) second\n * (3) third\n * (4) fourth\n * (5) seventh\n * (6) tenth\n *\n * Automations\n * (7) fifth\n * (8) sixth\n *\n * Merchant Admin\n * (9) eighth\n * (10) ninth\n *\n * Press ↑↓ arrows to select, enter to confirm\n * ```\n */\nexport function renderSelectPrompt<T>(props: Omit<SelectPromptProps<T>, 'onSubmit'>): Promise<T> {\n return new Promise((resolve, reject) => {\n render(<SelectPrompt {...props} onSubmit={(value: T) => resolve(value)} />, {\n exitOnCtrlC: false,\n }).catch(reject)\n })\n}\n\ninterface RenderConfirmationPromptOptions extends Pick<SelectPromptProps<boolean>, 'message' | 'infoTable'> {\n confirmationMessage?: string\n cancellationMessage?: string\n}\n\n/**\n * Renders a confirmation prompt to the console.\n *\n * ? Do you want to continue?\n *\n * \\> (y) Yes, confirm\n * (n) No, canccel\n *\n * Press ↑↓ arrows to select, enter to confirm\n */\nexport function renderConfirmationPrompt({\n message,\n infoTable,\n confirmationMessage = 'Yes, confirm',\n cancellationMessage = 'No, cancel',\n}: RenderConfirmationPromptOptions): Promise<boolean> {\n const choices = [\n {\n label: confirmationMessage,\n value: true,\n key: 'y',\n },\n {\n label: cancellationMessage,\n value: false,\n key: 'n',\n },\n ]\n\n return renderSelectPrompt({\n choices,\n message,\n infoTable,\n })\n}\n\ninterface RenderAutocompletePromptProps<T> {\n message: string\n choices: SelectProps<T>['items']\n infoTable?: InfoTableProps['table']\n search?: (term: string) => Promise<SearchResults<T>>\n hasMorePages?: boolean\n}\n\n/**\n * Renders an autocomplete prompt to the console.\n * ```\n * ? Select a template Type to search...\n\n * \\> first\n * second\n * third\n\n * Press ↑↓ arrows to select, enter to confirm\n * ```\n */\nexport function renderAutocompletePrompt<T>(props: RenderAutocompletePromptProps<T>): Promise<T> {\n const newProps = {\n search(term: string) {\n return Promise.resolve({\n data: props.choices.filter((item) => item.label.toLowerCase().includes(term.toLowerCase())),\n })\n },\n ...props,\n }\n\n return new Promise((resolve, reject) => {\n render(<AutocompletePrompt {...newProps} onSubmit={(value: T) => resolve(value)} />, {\n exitOnCtrlC: false,\n }).catch(reject)\n })\n}\n\n/**\n * Renders a table to the console.\n *\n * ```\n * name role Identifier\n * ──────────────────────── ───────────── ──────────\n * Dawn [live] #1361\n * Studio #1363\n * Debut [unpublished] #1374\n * Development (1a23b4-MBP) [development] #1368\n * ```\n */\nexport function renderTable<T extends ScalarDict>(props: TableProps<T>) {\n return renderOnce(<Table {...props} />)\n}\n\nexport {Task}\n\n/**\n * Runs async tasks and displays their progress to the console.\n */\nexport async function renderTasks<TContext>(tasks: Task<TContext>[]) {\n return render(<Tasks tasks={tasks} />)\n}\n\n/**\n * Renders a text prompt to the console.\n * ```\n * ? What is your name?\n * \\> John\n * ```\n */\nexport function renderTextPrompt(props: Omit<TextPromptProps, 'onSubmit'>): Promise<string> {\n return new Promise((resolve, reject) => {\n render(<TextPrompt {...props} onSubmit={(value: string) => resolve(value)} />, {\n exitOnCtrlC: false,\n }).catch(reject)\n })\n}\n"]}
|