UNPKG

@supernovaio/cli

Version:

Supernova.io Command Line Interface

84 lines (82 loc) 3.62 kB
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="eaec22cd-2630-564d-811b-c665d9411e20")}catch(e){}}(); import inquirer from "inquirer"; import { splitCsv } from "../../helpers.js"; import { colorize, emphasis, muted, renderFramedLines } from "../../ui.js"; import { PRIVATE_DEPENDENCIES_DOCS_URL } from "../../constants.js"; export async function promptDependencyPackageNames(context, error, log) { if (context.componentPackages?.length) { log(muted(`Discovered packages: ${context.componentPackages.join(", ")}`)); } const response = await inquirer.prompt([ { default: context.dependencyPackageNames?.join(", ") ?? context.componentPackages?.join(", ") ?? "", message: colorize("Which design system packages should we add? (comma-separated)", "blue"), name: "packageNames", type: "input", }, ]); const packageNames = splitCsv(response.packageNames); if (packageNames.length === 0) { error("At least one design system package is required."); } const invalid = packageNames.find(name => name.endsWith("/*")); if (invalid) { error(`Package "${invalid}" must be an exact package name.`); } return packageNames; } export async function promptPrivateRegistryConfiguration(input) { const modeResponse = await inquirer.prompt([ { choices: [ { name: "Packages are private requiring a registry access token", value: "Private" }, { name: "Packages are public", value: "Public" }, ], default: input.context.dependencyMode ?? "Private", message: colorize("Are your packages private or public?", "blue"), name: "dependencyMode", type: "list", }, ]); if (modeResponse.dependencyMode === "Public") { return { dependencyMode: "Public" }; } if (!input.context.templateDestinationPath) { input.error("Template destination path is missing."); } const npmrcPath = await input.ensureLocalNpmrcFile(input.context.templateDestinationPath); input.log(renderFramedLines([ "Private packages are installed during the Docker build with an npm token passed as a Docker secret.", "The token is kept in memory for this setup run, passed to template upload, and not saved to the template or setup session.", "", `${emphasis(".npmrc uses:")} //registry.npmjs.org/:_authToken=\${NPM_TOKEN}`, `${emphasis(".npmrc path:")} ${npmrcPath}`, "", `${emphasis("📘 Docs:")} ${PRIVATE_DEPENDENCIES_DOCS_URL}`, ])); const npmToken = await promptNpmToken(input.error); return { dependencyMode: "Private", npmToken, }; } export async function promptNpmToken(error) { const tokenResponse = await inquirer.prompt([ { mask: "*", message: colorize("NPM token:", "blue"), name: "npmToken", type: "password", validate(value) { return value.trim().length > 0 || "NPM token is required for private packages."; }, }, ]); const npmToken = tokenResponse.npmToken.trim(); if (!npmToken) { error("NPM token is required for private packages."); } return npmToken; } //# sourceMappingURL=prompts.js.map //# debugId=eaec22cd-2630-564d-811b-c665d9411e20