@ms-cloudpack/cli 0.77.6 → 0.77.8
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/README.md +1 -3
- package/lib/commands/init/formatInitSummary.js +2 -2
- package/lib/commands/init/formatInitSummary.js.map +1 -1
- package/lib/utilities/CloudpackCommand.d.ts +1 -1
- package/lib/utilities/CloudpackCommand.js +2 -2
- package/lib/utilities/CloudpackCommand.js.map +1 -1
- package/package.json +17 -17
package/README.md
CHANGED
|
@@ -66,13 +66,13 @@ export function formatInitSummary(params) {
|
|
|
66
66
|
`${cyan(plural(totalPackages, 'total package'))} ${action} in ${formatTime(summary.duration)}${incompleteText}`,
|
|
67
67
|
];
|
|
68
68
|
const errorPkgCount = packagesWithErrors.length;
|
|
69
|
-
const
|
|
69
|
+
const successPkgCount = totalPackages - errorPkgCount;
|
|
70
70
|
const warningPkgCount = packagesWithWarnings.length;
|
|
71
71
|
const optionalChangesCount = totalChanges - totalRequiredChanges;
|
|
72
72
|
// See snapshots for examples of this output
|
|
73
73
|
totalLines.push(...[
|
|
74
74
|
// "without errors" because they might have warnings
|
|
75
|
-
formatCount('success',
|
|
75
|
+
formatCount('success', successPkgCount, 'package', `${action} without errors`),
|
|
76
76
|
!errorPkgCount &&
|
|
77
77
|
(check
|
|
78
78
|
? // For --check, only show optional changes if there are no errors, and format the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatInitSummary.js","sourceRoot":"","sources":["../../../src/commands/init/formatInitSummary.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,KAAK,EACL,QAAQ,EACR,MAAM,EACN,SAAS,EACT,MAAM,EACN,GAAG,EACH,gBAAgB,EAChB,MAAM,GACP,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAY9D,MAAM,YAAY,GAAgD;IAChE,KAA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GAAG,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;AACrD,CAAC","sourcesContent":["import {\n bold,\n bulletedList,\n cyan,\n formatTime,\n green,\n darkGrey,\n indent,\n lightCyan,\n plural,\n red,\n prefixCharacters,\n yellow,\n} from '@ms-cloudpack/task-reporter';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { InitPackageResult } from './types/InitPackageResult.js';\nimport type { InitSummary } from './types/InitSummary.js';\nimport { formatLocation } from '@ms-cloudpack/path-utilities';\nimport type { GeneratedChange, RequiredGeneratedChangeType } from './types/GeneratedChange.js';\n\nexport interface FormatSummaryParams extends Pick<InitOptions, 'check'> {\n summary: InitSummary;\n isMultiApp?: boolean;\n verb: 'init' | 'bundle';\n isInterrupted?: boolean;\n}\n\n/** Result types with different colors and symbols for logging purposes */\ntype ResultType = 'error' | 'warn' | 'add' | 'success';\nconst colorsByType: Record<ResultType, (str: string) => string> = {\n error: red,\n warn: yellow,\n add: (str) => str, // no color\n success: green,\n};\nconst statusByType: Record<ResultType, string> = {\n error: prefixCharacters.error,\n warn: prefixCharacters.warn,\n add: '+',\n success: prefixCharacters.complete,\n};\n\n/** \"cloudpack.generated.json\" with color */\nconst generatedConfigFile = cyan('cloudpack.generated.json');\n/** \"cloudpack init\" with color and quotes */\nconst cloudpackInit = `\"${yellow('cloudpack init')}\"`;\n\n/**\n * Given a summary and options, returns a formatted string message to display to the user via console.\n */\nexport function formatInitSummary(params: FormatSummaryParams): string {\n const { summary, check, isInterrupted, isMultiApp, verb } = params;\n /** Sections of the summary that will be joined with two newlines */\n const summarySections: string[] = [];\n\n const {\n totalPackages,\n totalErrors,\n totalWarnings,\n totalChanges,\n totalRequiredChanges,\n packagesWithErrors,\n packagesWithWarnings,\n generatedFileUpdates,\n deletedGeneratedConfig,\n } = summary;\n\n // With --check, show required changes even if there are errors.\n // Otherwise, skip since they'll be applied automatically once errors are fixed.\n const showRequiredChanges = !!(totalRequiredChanges && (!totalErrors || check));\n\n const incompleteText = isInterrupted ? bold(` (incomplete)`) : ``;\n\n let warnings: string | undefined;\n let generatedChanges: string | undefined;\n\n // In single-app mode, report packages with warnings.\n if (!isMultiApp && packagesWithWarnings.length) {\n warnings = formatPackageResults({ results: packagesWithWarnings, issueType: 'warn' });\n }\n\n // Report required changes if appropriate (see showRequiredChanges)\n if (showRequiredChanges) {\n generatedChanges = formatPackageUpdates({ generatedFileUpdates, check, hasErrors: !!totalErrors });\n }\n\n if (check) {\n // With --check, it's most helpful to show warnings then generated changes. Required changes\n // are errors in that context, and if they're listed above warnings, it's easy to miss them,\n // which might lead to confusion.\n warnings && summarySections.push(warnings);\n generatedChanges && summarySections.push(generatedChanges);\n } else {\n // Without --check, show generated changes first, then warnings. In this case, any generated\n // change listing is just informational (the changes were already made), but the warnings\n // require manual intervention if the user wants to fix them.\n generatedChanges && summarySections.push(generatedChanges);\n warnings && summarySections.push(warnings);\n }\n\n // Report packages with errors.\n if (packagesWithErrors.length) {\n summarySections.push(formatPackageResults({ results: packagesWithErrors, issueType: 'error' }));\n }\n\n if (deletedGeneratedConfig) {\n summarySections.push(`Deleted the ${generatedConfigFile} file because it is no longer needed.`);\n }\n\n if (totalPackages > 1 || verb === 'init') {\n // Report totals\n const action = verb === 'init' ? 'evaluated' : 'bundled';\n const totalLines = [\n `${cyan(plural(totalPackages, 'total package'))} ${action} in ${formatTime(summary.duration)}${incompleteText}`,\n ];\n\n const errorPkgCount = packagesWithErrors.length;\n const succesPkgCount = totalPackages - errorPkgCount;\n const warningPkgCount = packagesWithWarnings.length;\n const optionalChangesCount = totalChanges - totalRequiredChanges;\n\n // See snapshots for examples of this output\n totalLines.push(\n ...([\n // \"without errors\" because they might have warnings\n formatCount('success', succesPkgCount, 'package', `${action} without errors`),\n !errorPkgCount &&\n (check\n ? // For --check, only show optional changes if there are no errors, and format the\n // optional changes as warnings. (required changes will be shown below)\n formatCount('warn', optionalChangesCount, 'optional change', 'could be made to generated config')\n : // If updating, show the total changes made.\n formatCount('add', totalChanges, 'change', 'made to generated config')),\n formatCount('warn', warningPkgCount, 'package', 'with warnings', totalWarnings, 'total warning'),\n // For --check, show required changes as errors.\n check && formatCount('error', totalRequiredChanges, 'required change', 'missing from generated config'),\n formatCount('error', errorPkgCount, 'package', 'with errors', totalErrors, 'total error'),\n ].filter(Boolean) as string[]),\n );\n\n if (totalLines.length > 1) {\n // add a colon to the first line if there are other lines\n totalLines[0] += ':';\n }\n\n summarySections.push(totalLines.join('\\n'));\n }\n\n if (isInterrupted) {\n summarySections.push(yellow(bold('Process was interrupted before all tasks could complete.')));\n } else if (check && totalRequiredChanges && !totalErrors) {\n // Skip the instruction to update the generated config if there were errors.\n summarySections.push(\n `Run ${cloudpackInit} in ${summary.appPath} to apply missing changes to the ${generatedConfigFile} file.`,\n );\n }\n\n // Skip the header if there was nothing to report.\n if (summarySections.length) {\n // For bundle, we just say \"summary\" since `appPath` might not actually be the path that was bundled.\n summarySections.unshift(bold(`==== ${verb === 'bundle' ? 'Summary' : `Summary for ${summary.appPath}`} ====`));\n }\n\n const summaryString = summarySections\n .join('\\n\\n')\n // replace >= 3 newlines with 2 newlines\n .replace(/\\n{3,}/g, '\\n\\n');\n // Ensure a final newline for readability, unless it's empty.\n return !summaryString || summaryString.endsWith('\\n') ? summaryString : summaryString + '\\n';\n}\n\n/**\n * If `count > 0`, return a pluralized formatted string like \"+ 5 items description\"\n * (otherwise ignore). `type` determines the status character used, and the color for the\n * status character and item count.\n *\n * `extraCount` and `extraItem` are optional and will be added to the end in parentheses\n * if both are provided.\n */\nfunction formatCount(\n type: ResultType,\n count: number,\n item: string,\n description: string,\n extraCount?: number,\n extraItem?: string,\n): string | undefined {\n if (count > 0) {\n const color = colorsByType[type];\n const statusChar = bold(color(statusByType[type]));\n const itemCount = color(plural(count, item));\n const extra = extraCount && extraItem ? ` (${plural(extraCount, extraItem)})` : '';\n return ` ${statusChar} ${itemCount} ${description}${extra}`;\n }\n return undefined;\n}\n\nfunction formatPackageUpdates(\n params: Pick<InitSummary, 'generatedFileUpdates'> &\n Pick<FormatSummaryParams, 'isInterrupted' | 'check'> & {\n hasErrors: boolean;\n },\n): string {\n const { generatedFileUpdates, check, isInterrupted, hasErrors } = params;\n\n // mapping from change type to [description, optional plural description]\n const descriptions: Record<RequiredGeneratedChangeType, [string, string?]> = {\n 'added-export': [`path$s ${check ? 'missing from' : 'added to'} exports map`],\n 'included-dependency-required': ['dependency required to be included', 'dependencies required to be included'],\n 'changed-export': ['previously unused export path$s now used'],\n 'added-dynamic-import': ['dynamic import$s added'],\n 'removed-excluded-dependency-required': ['dependency is no longer excluded', 'dependencies are no longer excluded'],\n };\n\n const summaryString: string[] = [];\n\n for (const packageUpdates of generatedFileUpdates) {\n // list of update type descriptions and updates of that type\n const updates: [string, GeneratedChange[]][] = [];\n for (const type of Object.keys(descriptions) as RequiredGeneratedChangeType[]) {\n const typeUpdates = packageUpdates.changes.filter((u) => u.type === type);\n\n if (typeUpdates.length) {\n const description = plural(typeUpdates.length, ...descriptions[type]);\n updates.push([description, typeUpdates]);\n }\n }\n\n if (updates.length) {\n summaryString.push(formatPackageHeader(packageUpdates));\n for (const [description, typeUpdates] of updates) {\n summaryString.push(\n // If updates are required, format them as errors.\n formatPackageSubhead({ issueType: check ? 'error' : 'add', description }),\n bulletedList(typeUpdates.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)),\n );\n }\n summaryString.push('');\n }\n }\n\n if (summaryString.length) {\n const needsUpdates = check || isInterrupted;\n const extraInstructions = needsUpdates\n ? hasErrors\n ? `fix errors first, then run ${cloudpackInit}`\n : `run ${cloudpackInit} to fix`\n : '';\n summaryString.unshift(\n bold(`Updates ${needsUpdates ? 'needed for' : 'made to'} ${generatedConfigFile}`) +\n `${extraInstructions ? ` (${extraInstructions})` : ''}:\\n`,\n );\n }\n return summaryString.join('\\n');\n}\n\n/** Helper to format `packagesWithWarnings` or `packagesWithErrors`. */\nfunction formatPackageResults(params: { results: InitPackageResult[]; issueType: 'error' | 'warn' }): string {\n const { results, issueType } = params;\n if (!results.length) {\n return '';\n }\n\n const color = colorsByType[issueType];\n const messageType = issueType === 'error' ? 'errors' : 'warnings';\n const statusChar = bold(color(prefixCharacters[issueType]));\n\n const summaryString = [bold(color(`${plural(results.length, 'package')} with ${messageType}:`)), ''];\n\n for (const result of results) {\n const unformattedMessages = result[messageType];\n if (!unformattedMessages?.length) {\n continue;\n }\n\n const description = plural(unformattedMessages.length, messageType.slice(0, -1) + '$s');\n summaryString.push(formatPackageHeader(result), formatPackageSubhead({ issueType, description }));\n\n const messages = unformattedMessages.map(({ location, text, source }) => {\n // Show the whole path so it can be easily opened with ctrl+click.\n // NOTE: location.file should be relative to the package path, not the app path.\n const filePath = location ? ` ${formatLocation({ ...location, fromPath: result.path })}` : '';\n // Indent the message for readability.\n return `[${source}]${filePath}\\n${color(indent(text, 1))}`;\n });\n\n summaryString.push(bulletedList(messages, undefined, statusChar), '');\n }\n\n return summaryString.join('\\n');\n}\n\n/**\n * Helper to format the package `name@version` and output path.\n */\nfunction formatPackageHeader(params: InitPackageResult): string {\n const { name, version, path: packagePath, outputPath } = params;\n const packageName = bold(lightCyan(`${name}@${version}`));\n\n return `${packageName} - ${packagePath}${outputPath ? '\\n' + darkGrey(`(output: ${outputPath})`) : ''}`;\n}\n\n/**\n * Add a status character and formatting to the subhead description.\n */\nfunction formatPackageSubhead(params: { description: string; issueType: ResultType }): string {\n const { description, issueType } = params;\n const color = colorsByType[issueType];\n const statusChar = bold(color(statusByType[issueType]));\n return `${statusChar} ${bold(color(description))}`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"formatInitSummary.js","sourceRoot":"","sources":["../../../src/commands/init/formatInitSummary.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,KAAK,EACL,QAAQ,EACR,MAAM,EACN,SAAS,EACT,MAAM,EACN,GAAG,EACH,gBAAgB,EAChB,MA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S,CAAC,CAAC;IACtC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACxD,OAAO,GAAG,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;AACrD,CAAC","sourcesContent":["import {\n bold,\n bulletedList,\n cyan,\n formatTime,\n green,\n darkGrey,\n indent,\n lightCyan,\n plural,\n red,\n prefixCharacters,\n yellow,\n} from '@ms-cloudpack/task-reporter';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { InitPackageResult } from './types/InitPackageResult.js';\nimport type { InitSummary } from './types/InitSummary.js';\nimport { formatLocation } from '@ms-cloudpack/path-utilities';\nimport type { GeneratedChange, RequiredGeneratedChangeType } from './types/GeneratedChange.js';\n\nexport interface FormatSummaryParams extends Pick<InitOptions, 'check'> {\n summary: InitSummary;\n isMultiApp?: boolean;\n verb: 'init' | 'bundle';\n isInterrupted?: boolean;\n}\n\n/** Result types with different colors and symbols for logging purposes */\ntype ResultType = 'error' | 'warn' | 'add' | 'success';\nconst colorsByType: Record<ResultType, (str: string) => string> = {\n error: red,\n warn: yellow,\n add: (str) => str, // no color\n success: green,\n};\nconst statusByType: Record<ResultType, string> = {\n error: prefixCharacters.error,\n warn: prefixCharacters.warn,\n add: '+',\n success: prefixCharacters.complete,\n};\n\n/** \"cloudpack.generated.json\" with color */\nconst generatedConfigFile = cyan('cloudpack.generated.json');\n/** \"cloudpack init\" with color and quotes */\nconst cloudpackInit = `\"${yellow('cloudpack init')}\"`;\n\n/**\n * Given a summary and options, returns a formatted string message to display to the user via console.\n */\nexport function formatInitSummary(params: FormatSummaryParams): string {\n const { summary, check, isInterrupted, isMultiApp, verb } = params;\n /** Sections of the summary that will be joined with two newlines */\n const summarySections: string[] = [];\n\n const {\n totalPackages,\n totalErrors,\n totalWarnings,\n totalChanges,\n totalRequiredChanges,\n packagesWithErrors,\n packagesWithWarnings,\n generatedFileUpdates,\n deletedGeneratedConfig,\n } = summary;\n\n // With --check, show required changes even if there are errors.\n // Otherwise, skip since they'll be applied automatically once errors are fixed.\n const showRequiredChanges = !!(totalRequiredChanges && (!totalErrors || check));\n\n const incompleteText = isInterrupted ? bold(` (incomplete)`) : ``;\n\n let warnings: string | undefined;\n let generatedChanges: string | undefined;\n\n // In single-app mode, report packages with warnings.\n if (!isMultiApp && packagesWithWarnings.length) {\n warnings = formatPackageResults({ results: packagesWithWarnings, issueType: 'warn' });\n }\n\n // Report required changes if appropriate (see showRequiredChanges)\n if (showRequiredChanges) {\n generatedChanges = formatPackageUpdates({ generatedFileUpdates, check, hasErrors: !!totalErrors });\n }\n\n if (check) {\n // With --check, it's most helpful to show warnings then generated changes. Required changes\n // are errors in that context, and if they're listed above warnings, it's easy to miss them,\n // which might lead to confusion.\n warnings && summarySections.push(warnings);\n generatedChanges && summarySections.push(generatedChanges);\n } else {\n // Without --check, show generated changes first, then warnings. In this case, any generated\n // change listing is just informational (the changes were already made), but the warnings\n // require manual intervention if the user wants to fix them.\n generatedChanges && summarySections.push(generatedChanges);\n warnings && summarySections.push(warnings);\n }\n\n // Report packages with errors.\n if (packagesWithErrors.length) {\n summarySections.push(formatPackageResults({ results: packagesWithErrors, issueType: 'error' }));\n }\n\n if (deletedGeneratedConfig) {\n summarySections.push(`Deleted the ${generatedConfigFile} file because it is no longer needed.`);\n }\n\n if (totalPackages > 1 || verb === 'init') {\n // Report totals\n const action = verb === 'init' ? 'evaluated' : 'bundled';\n const totalLines = [\n `${cyan(plural(totalPackages, 'total package'))} ${action} in ${formatTime(summary.duration)}${incompleteText}`,\n ];\n\n const errorPkgCount = packagesWithErrors.length;\n const successPkgCount = totalPackages - errorPkgCount;\n const warningPkgCount = packagesWithWarnings.length;\n const optionalChangesCount = totalChanges - totalRequiredChanges;\n\n // See snapshots for examples of this output\n totalLines.push(\n ...([\n // \"without errors\" because they might have warnings\n formatCount('success', successPkgCount, 'package', `${action} without errors`),\n !errorPkgCount &&\n (check\n ? // For --check, only show optional changes if there are no errors, and format the\n // optional changes as warnings. (required changes will be shown below)\n formatCount('warn', optionalChangesCount, 'optional change', 'could be made to generated config')\n : // If updating, show the total changes made.\n formatCount('add', totalChanges, 'change', 'made to generated config')),\n formatCount('warn', warningPkgCount, 'package', 'with warnings', totalWarnings, 'total warning'),\n // For --check, show required changes as errors.\n check && formatCount('error', totalRequiredChanges, 'required change', 'missing from generated config'),\n formatCount('error', errorPkgCount, 'package', 'with errors', totalErrors, 'total error'),\n ].filter(Boolean) as string[]),\n );\n\n if (totalLines.length > 1) {\n // add a colon to the first line if there are other lines\n totalLines[0] += ':';\n }\n\n summarySections.push(totalLines.join('\\n'));\n }\n\n if (isInterrupted) {\n summarySections.push(yellow(bold('Process was interrupted before all tasks could complete.')));\n } else if (check && totalRequiredChanges && !totalErrors) {\n // Skip the instruction to update the generated config if there were errors.\n summarySections.push(\n `Run ${cloudpackInit} in ${summary.appPath} to apply missing changes to the ${generatedConfigFile} file.`,\n );\n }\n\n // Skip the header if there was nothing to report.\n if (summarySections.length) {\n // For bundle, we just say \"summary\" since `appPath` might not actually be the path that was bundled.\n summarySections.unshift(bold(`==== ${verb === 'bundle' ? 'Summary' : `Summary for ${summary.appPath}`} ====`));\n }\n\n const summaryString = summarySections\n .join('\\n\\n')\n // replace >= 3 newlines with 2 newlines\n .replace(/\\n{3,}/g, '\\n\\n');\n // Ensure a final newline for readability, unless it's empty.\n return !summaryString || summaryString.endsWith('\\n') ? summaryString : summaryString + '\\n';\n}\n\n/**\n * If `count > 0`, return a pluralized formatted string like \"+ 5 items description\"\n * (otherwise ignore). `type` determines the status character used, and the color for the\n * status character and item count.\n *\n * `extraCount` and `extraItem` are optional and will be added to the end in parentheses\n * if both are provided.\n */\nfunction formatCount(\n type: ResultType,\n count: number,\n item: string,\n description: string,\n extraCount?: number,\n extraItem?: string,\n): string | undefined {\n if (count > 0) {\n const color = colorsByType[type];\n const statusChar = bold(color(statusByType[type]));\n const itemCount = color(plural(count, item));\n const extra = extraCount && extraItem ? ` (${plural(extraCount, extraItem)})` : '';\n return ` ${statusChar} ${itemCount} ${description}${extra}`;\n }\n return undefined;\n}\n\nfunction formatPackageUpdates(\n params: Pick<InitSummary, 'generatedFileUpdates'> &\n Pick<FormatSummaryParams, 'isInterrupted' | 'check'> & {\n hasErrors: boolean;\n },\n): string {\n const { generatedFileUpdates, check, isInterrupted, hasErrors } = params;\n\n // mapping from change type to [description, optional plural description]\n const descriptions: Record<RequiredGeneratedChangeType, [string, string?]> = {\n 'added-export': [`path$s ${check ? 'missing from' : 'added to'} exports map`],\n 'included-dependency-required': ['dependency required to be included', 'dependencies required to be included'],\n 'changed-export': ['previously unused export path$s now used'],\n 'added-dynamic-import': ['dynamic import$s added'],\n 'removed-excluded-dependency-required': ['dependency is no longer excluded', 'dependencies are no longer excluded'],\n };\n\n const summaryString: string[] = [];\n\n for (const packageUpdates of generatedFileUpdates) {\n // list of update type descriptions and updates of that type\n const updates: [string, GeneratedChange[]][] = [];\n for (const type of Object.keys(descriptions) as RequiredGeneratedChangeType[]) {\n const typeUpdates = packageUpdates.changes.filter((u) => u.type === type);\n\n if (typeUpdates.length) {\n const description = plural(typeUpdates.length, ...descriptions[type]);\n updates.push([description, typeUpdates]);\n }\n }\n\n if (updates.length) {\n summaryString.push(formatPackageHeader(packageUpdates));\n for (const [description, typeUpdates] of updates) {\n summaryString.push(\n // If updates are required, format them as errors.\n formatPackageSubhead({ issueType: check ? 'error' : 'add', description }),\n bulletedList(typeUpdates.map((u) => `${cyan(u.change)}${u.reason ? ` - ${u.reason}` : ''}`)),\n );\n }\n summaryString.push('');\n }\n }\n\n if (summaryString.length) {\n const needsUpdates = check || isInterrupted;\n const extraInstructions = needsUpdates\n ? hasErrors\n ? `fix errors first, then run ${cloudpackInit}`\n : `run ${cloudpackInit} to fix`\n : '';\n summaryString.unshift(\n bold(`Updates ${needsUpdates ? 'needed for' : 'made to'} ${generatedConfigFile}`) +\n `${extraInstructions ? ` (${extraInstructions})` : ''}:\\n`,\n );\n }\n return summaryString.join('\\n');\n}\n\n/** Helper to format `packagesWithWarnings` or `packagesWithErrors`. */\nfunction formatPackageResults(params: { results: InitPackageResult[]; issueType: 'error' | 'warn' }): string {\n const { results, issueType } = params;\n if (!results.length) {\n return '';\n }\n\n const color = colorsByType[issueType];\n const messageType = issueType === 'error' ? 'errors' : 'warnings';\n const statusChar = bold(color(prefixCharacters[issueType]));\n\n const summaryString = [bold(color(`${plural(results.length, 'package')} with ${messageType}:`)), ''];\n\n for (const result of results) {\n const unformattedMessages = result[messageType];\n if (!unformattedMessages?.length) {\n continue;\n }\n\n const description = plural(unformattedMessages.length, messageType.slice(0, -1) + '$s');\n summaryString.push(formatPackageHeader(result), formatPackageSubhead({ issueType, description }));\n\n const messages = unformattedMessages.map(({ location, text, source }) => {\n // Show the whole path so it can be easily opened with ctrl+click.\n // NOTE: location.file should be relative to the package path, not the app path.\n const filePath = location ? ` ${formatLocation({ ...location, fromPath: result.path })}` : '';\n // Indent the message for readability.\n return `[${source}]${filePath}\\n${color(indent(text, 1))}`;\n });\n\n summaryString.push(bulletedList(messages, undefined, statusChar), '');\n }\n\n return summaryString.join('\\n');\n}\n\n/**\n * Helper to format the package `name@version` and output path.\n */\nfunction formatPackageHeader(params: InitPackageResult): string {\n const { name, version, path: packagePath, outputPath } = params;\n const packageName = bold(lightCyan(`${name}@${version}`));\n\n return `${packageName} - ${packagePath}${outputPath ? '\\n' + darkGrey(`(output: ${outputPath})`) : ''}`;\n}\n\n/**\n * Add a status character and formatting to the subhead description.\n */\nfunction formatPackageSubhead(params: { description: string; issueType: ResultType }): string {\n const { description, issueType } = params;\n const color = colorsByType[issueType];\n const statusChar = bold(color(statusByType[issueType]));\n return `${statusChar} ${bold(color(description))}`;\n}\n"]}
|
|
@@ -71,7 +71,7 @@ export declare class CloudpackCommand<TOptions extends object, TArguments extend
|
|
|
71
71
|
/** Run the program (only works on the top-level program command). */
|
|
72
72
|
run(): Promise<void>;
|
|
73
73
|
/** Add arguments. The generic enforces that argument objects are included for all keys of a type. */
|
|
74
|
-
private
|
|
74
|
+
private _addArguments;
|
|
75
75
|
/** Add options. The generic enforces that option objects are included for all keys of a type. */
|
|
76
76
|
private _addOptions;
|
|
77
77
|
private _addAction;
|
|
@@ -42,7 +42,7 @@ export class CloudpackCommand {
|
|
|
42
42
|
params.outputOptions && command.configureOutput(params.outputOptions);
|
|
43
43
|
params.getExecutor && this._addAction(params.getExecutor);
|
|
44
44
|
if (params.args) {
|
|
45
|
-
this.
|
|
45
|
+
this._addArguments(params.args);
|
|
46
46
|
}
|
|
47
47
|
if (params.options) {
|
|
48
48
|
// Add the command-specific options first so they show up first in help
|
|
@@ -94,7 +94,7 @@ export class CloudpackCommand {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
/** Add arguments. The generic enforces that argument objects are included for all keys of a type. */
|
|
97
|
-
|
|
97
|
+
_addArguments(args) {
|
|
98
98
|
for (const argument of Object.values(args)) {
|
|
99
99
|
this._command.addArgument(argument);
|
|
100
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudpackCommand.js","sourceRoot":"","sources":["../../src/utilities/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAqE,MAAM,WAAW,CAAC;AAG/G,OAAO,EAAE,eAAe,EAA8B,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA0DjE;;;;;;;GAOG;AACH,MAAM,OAAO,gBAAgB;IACnB,QAAQ,CAAU;IAClB,gBAAgB,CAGtB;IAEF;;;OAGG;IACH;IACE,4EAA4E;IAC5E,MAIG;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CAAC;gBAClC,2EAA2E;gBAC3E,MAAM,IAAI,KAAK,CAAC,gEAAgE,IAAI,GAAG,CAAC,CAAC;YAC3F,CAAC;YAED,MAAM,eAAe,GAAG,IAAI,eAAe,CAA2B;gBACpE,IAAI,EAAE,aAAa;gBACnB,OAAO;gBACP,OAAO;gBACP,IAAI;gBACJ,GAAG,IAAI,CAAC,gBAAgB;aACzB,CAAC,CAAC;YACH,MAAM,eAAe,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { Command, Option, type AddHelpTextPosition, type Argument, type OutputConfiguration } from 'commander';\nimport type { CommandActionModule } from '../types/CommandAction.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { CommandExecutor, type CommandExecutorParams } from './CommandExecutor.js';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport { parseFeature } from './parseFeature.js';\nimport { parseDefine } from './parseDefine.js';\nimport { CloudpackHelp, optionGroups } from './CloudpackHelp.js';\n\n/**\n * Parameters for creating a command.\n * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.\n */\ninterface CloudpackCommandParams<TOptions extends object, TArguments extends object>\n extends Partial<Pick<CommandExecutorParams<TOptions>, 'discoverAppPaths' | 'applyOptionsToConfig'>> {\n /** Command name */\n name: string;\n\n /** Command description */\n description: string;\n\n /**\n * Options specific to this command. The record ensures that all options are available in the CLI.\n * Allow multiple options for the same key since commander supports it with negatable options.\n */\n options?: Record<keyof TOptions, Option | Option[]>; //\n\n /** Arguments specific to this command. Key order determines the arg order. */\n args?: Record<keyof TArguments, Argument>;\n\n /**\n * Function returning an async import of the command's `src/commands/<name>/execute.ts` module.\n * Importing only on demand makes Cloudpack start up faster since it doesn't have to parse\n * every command's dependencies (many of which may be unrelated to the command being run).\n *\n * This can be undefined for a command that only has sub-commands.\n */\n getExecutor?: () => Promise<CommandActionModule<TOptions>>;\n\n /** Usage message override */\n usage?: string;\n\n /** Alternative name for the command */\n alias?: string;\n\n /** Extra text to be displayed with the built-in help. */\n addHelpText?: {\n /**\n * `'before'` or `'after'` to affect just this command.\n * `'beforeAll'` or `'afterAll'` to affect this command and all its subcommands.\n */\n position: AddHelpTextPosition;\n text: string;\n };\n\n /** Output options override (mainly for testing) */\n outputOptions?: OutputConfiguration;\n\n /**\n * The shared options are relevant for most commands, but this allows omitting them from help\n * where they're not relevant. `true` hides all shared options, or an array hides specific ones.\n */\n hideSharedOptions?: Array<keyof SharedOptions> | true;\n}\n\n/**\n * This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with\n * Cloudpack-specific functionality and simpler APIs.\n *\n * Similar to the pattern from `commander`, this class represents both the program and its sub-commands.\n * - The top-level \"program\" command should be created with `new CloudpackCommand()`.\n * - Sub-commands should be created with the `.addSubCommand` method on the parent.\n */\nexport class CloudpackCommand<TOptions extends object, TArguments extends object> {\n private _command: Command;\n private _executorOptions: Pick<\n CommandExecutorParams<TOptions>,\n 'programOptions' | 'discoverAppPaths' | 'applyOptionsToConfig'\n >;\n\n /**\n * This should only be used directly (outside this class) to create the top-level `program` command.\n * To add sub-commands, use `.addSubCommand` instead.\n */\n constructor(\n // The extra options here shouldn't be exposed to the `createSubCommand` API\n params: CloudpackCommandParams<TOptions, TArguments> &\n Pick<CommandExecutorParams<TOptions>, 'programOptions'> & {\n /** This must be undefined for the top-level program command */\n parent?: Command;\n },\n ) {\n this._executorOptions = {\n programOptions: params.programOptions,\n discoverAppPaths: params.discoverAppPaths,\n applyOptionsToConfig: params.applyOptionsToConfig,\n };\n\n const command = params.parent?.command(params.name) || new Command(params.name);\n this._command = command;\n\n command.version(params.programOptions.version);\n command.description(params.description);\n command.allowExcessArguments(false);\n\n const isTopLevel = !params.parent;\n command.createHelp = () => new CloudpackHelp({ isTopLevel });\n // set the default help group for options\n command.optionsGroup(optionGroups.default);\n\n params.usage && command.usage(params.usage);\n params.alias && command.alias(params.alias);\n params.addHelpText && command.addHelpText(params.addHelpText.position, params.addHelpText.text);\n params.outputOptions && command.configureOutput(params.outputOptions);\n params.getExecutor && this._addAction(params.getExecutor);\n\n if (params.args) {\n this._addArguemnts<TArguments>(params.args);\n }\n\n if (params.options) {\n // Add the command-specific options first so they show up first in help\n this._addOptions<TOptions>(params.options);\n }\n\n // Add shared options. These must be manually added to the program command and each sub-command\n // because commander doesn't natively support inheriting options.\n this._addOptions<SharedOptions>(\n {\n verbose: new Option('-v, --verbose', 'Show additional details in logging.').helpGroup(optionGroups.logging),\n debug: new Option('-d, --debug', 'Show debug information (superset of --verbose).')\n .conflicts('verbose')\n .helpGroup(optionGroups.logging),\n quiet: new Option('-q, --quiet', 'Disable non-essential logging.')\n .conflicts('verbose')\n .conflicts('debug')\n .helpGroup(optionGroups.logging),\n color:\n // In the parsed options, this will be a boolean `color` with default value true (except in tests and CI)\n new Option('-n, --no-color', 'Disable colors in the output.')\n .helpGroup(optionGroups.logging)\n .default(!environmentInfo.isJest && !environmentInfo.isLage && !environmentInfo.isCI),\n logFile: new Option('--log-file', 'Write a log file with all console output.').helpGroup(optionGroups.logging),\n cachePath: new Option(\n '--cache-path <path>',\n 'Custom cache folder. To change the default, run `cloudpack config set cachePath <path>`.',\n ).helpGroup(optionGroups.common),\n config: new Option(\n '-c, --config <filename>',\n 'Custom config file name to use instead of cloudpack.config.json.',\n ).helpGroup(optionGroups.common),\n define: new Option('--define <key=value>', 'Define a global variable. Can be specified multiple times.')\n .helpGroup(optionGroups.common)\n .argParser(parseDefine),\n features: new Option('--features <featureNames...>', 'Enable experimental features.')\n .helpGroup(optionGroups.common)\n .argParser(parseFeature),\n },\n params.hideSharedOptions,\n );\n }\n\n /** Create a child command. */\n public addSubCommand<TChildOptions extends object, TChildArguments extends object = never>(\n params: CloudpackCommandParams<TChildOptions, TChildArguments>,\n ): CloudpackCommand<TChildOptions, TChildArguments> {\n return new CloudpackCommand<TChildOptions, TChildArguments>({\n ...params,\n programOptions: this._executorOptions.programOptions,\n parent: this._command,\n });\n }\n\n /** Run the program (only works on the top-level program command). */\n public async run(): Promise<void> {\n if (this._command.parent) {\n throw new Error('Only the top-level program command can be run directly.');\n }\n\n await this._command.parseAsync(this._executorOptions.programOptions.argv);\n if (this._command.args.length === 0) {\n this._command.help();\n }\n }\n\n /** Add arguments. The generic enforces that argument objects are included for all keys of a type. */\n private _addArguemnts<TAddArguments extends object>(args: Record<keyof TAddArguments, Argument>): void {\n for (const argument of Object.values(args)) {\n this._command.addArgument(argument as Argument);\n }\n }\n\n /** Add options. The generic enforces that option objects are included for all keys of a type. */\n private _addOptions<TAddOptions extends object>(\n options: Record<keyof TAddOptions, Option | Option[]>,\n hideOptions?: Array<keyof TAddOptions> | true,\n ): void {\n for (const [name, optionOrOptions] of Object.entries(options) as [keyof TAddOptions, Option | Option[]][]) {\n const optionArray = Array.isArray(optionOrOptions) ? optionOrOptions : [optionOrOptions];\n for (const option of optionArray) {\n if (hideOptions === true || hideOptions?.includes(name)) {\n option.hideHelp();\n }\n this._command.addOption(option);\n }\n }\n }\n\n private _addAction(getExecutor: NonNullable<CloudpackCommandParams<TOptions, TArguments>['getExecutor']>): void {\n const command = this._command;\n // The action function receives parsed options as its first parameter, but we ignore those\n // because they only contain options *specific to this command*, not shared options like `debug`.\n command.action(async () => {\n // Commander has support for custom parsers that parse arguments.\n // Use processedArgs instead of args to get the parsed arguments.\n const processedArgs = command.processedArgs as string[];\n\n // Get the shared options too, not just the ones for this command.\n // (In `cloudpackCommand`, we added the shared options to each command object so that they show up\n // in help, but commander still seems to respect options only at the first command where they're\n // encountered, which for shared options will always be the program command.)\n const options = command.optsWithGlobals<TOptions & SharedOptions>();\n\n // Usually `command` will be a sub-command (e.g. \"bundle\"), but it could also be a sub-sub-command\n // (e.g. \"cache clean\").\n const verb = command.parent?.parent ? `${command.parent.name()} ${command.name()}` : command.name();\n\n // Dynamically import the execute function\n const { execute } = await getExecutor();\n if (typeof execute !== 'function') {\n // throw instead of exiting politely, since this is a major developer error\n throw new Error(`No execute function was exported from the command module for ${verb}.`);\n }\n\n const commandExecutor = new CommandExecutor<TOptions & SharedOptions>({\n args: processedArgs,\n options,\n execute,\n verb,\n ...this._executorOptions,\n });\n await commandExecutor.execute();\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CloudpackCommand.js","sourceRoot":"","sources":["../../src/utilities/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAqE,MAAM,WAAW,CAAC;AAG/G,OAAO,EAAE,eAAe,EAA8B,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA0DjE;;;;;;;GAOG;AACH,MAAM,OAAO,gBAAgB;IACnB,QAAQ,CAAU;IAClB,gBAAgB,CAGtB;IAEF;;;OAGG;IACH;IACE,4EAA4E;IAC5E,MAIG;QAEH,IAAI,CAAC,gBAAgB,GAAG;YACtB,cAAc,EAAE,MAAM,CAAC,cAAc;YACrC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;YACzC,oBAAoB,EAAE,MAAM,CAAC,oBAAoB;SAClD,CAAC;QAEF,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAChF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAExB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC/C,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACxC,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAEpC,MAAM,UAAU,GAAG,C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,WAAqF;QACtG,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,0FAA0F;QAC1F,iGAAiG;QACjG,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;YACxB,iEAAiE;YACjE,iEAAiE;YACjE,MAAM,aAAa,GAAG,OAAO,CAAC,aAAyB,CAAC;YAExD,kEAAkE;YAClE,kGAAkG;YAClG,gGAAgG;YAChG,6EAA6E;YAC7E,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,EAA4B,CAAC;YAEpE,kGAAkG;YAClG,wBAAwB;YACxB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAEpG,0CAA0C;YAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,WAAW,EAAE,CAAC;YACxC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;gBAClC,2EAA2E;gBAC3E,MAAM,IAAI,KAAK,CAAC,gEAAgE,IAAI,GAAG,CAAC,CAAC;YAC3F,CAAC;YAED,MAAM,eAAe,GAAG,IAAI,eAAe,CAA2B;gBACpE,IAAI,EAAE,aAAa;gBACnB,OAAO;gBACP,OAAO;gBACP,IAAI;gBACJ,GAAG,IAAI,CAAC,gBAAgB;aACzB,CAAC,CAAC;YACH,MAAM,eAAe,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { Command, Option, type AddHelpTextPosition, type Argument, type OutputConfiguration } from 'commander';\nimport type { CommandActionModule } from '../types/CommandAction.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { CommandExecutor, type CommandExecutorParams } from './CommandExecutor.js';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport { parseFeature } from './parseFeature.js';\nimport { parseDefine } from './parseDefine.js';\nimport { CloudpackHelp, optionGroups } from './CloudpackHelp.js';\n\n/**\n * Parameters for creating a command.\n * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.\n */\ninterface CloudpackCommandParams<TOptions extends object, TArguments extends object>\n extends Partial<Pick<CommandExecutorParams<TOptions>, 'discoverAppPaths' | 'applyOptionsToConfig'>> {\n /** Command name */\n name: string;\n\n /** Command description */\n description: string;\n\n /**\n * Options specific to this command. The record ensures that all options are available in the CLI.\n * Allow multiple options for the same key since commander supports it with negatable options.\n */\n options?: Record<keyof TOptions, Option | Option[]>; //\n\n /** Arguments specific to this command. Key order determines the arg order. */\n args?: Record<keyof TArguments, Argument>;\n\n /**\n * Function returning an async import of the command's `src/commands/<name>/execute.ts` module.\n * Importing only on demand makes Cloudpack start up faster since it doesn't have to parse\n * every command's dependencies (many of which may be unrelated to the command being run).\n *\n * This can be undefined for a command that only has sub-commands.\n */\n getExecutor?: () => Promise<CommandActionModule<TOptions>>;\n\n /** Usage message override */\n usage?: string;\n\n /** Alternative name for the command */\n alias?: string;\n\n /** Extra text to be displayed with the built-in help. */\n addHelpText?: {\n /**\n * `'before'` or `'after'` to affect just this command.\n * `'beforeAll'` or `'afterAll'` to affect this command and all its subcommands.\n */\n position: AddHelpTextPosition;\n text: string;\n };\n\n /** Output options override (mainly for testing) */\n outputOptions?: OutputConfiguration;\n\n /**\n * The shared options are relevant for most commands, but this allows omitting them from help\n * where they're not relevant. `true` hides all shared options, or an array hides specific ones.\n */\n hideSharedOptions?: Array<keyof SharedOptions> | true;\n}\n\n/**\n * This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with\n * Cloudpack-specific functionality and simpler APIs.\n *\n * Similar to the pattern from `commander`, this class represents both the program and its sub-commands.\n * - The top-level \"program\" command should be created with `new CloudpackCommand()`.\n * - Sub-commands should be created with the `.addSubCommand` method on the parent.\n */\nexport class CloudpackCommand<TOptions extends object, TArguments extends object> {\n private _command: Command;\n private _executorOptions: Pick<\n CommandExecutorParams<TOptions>,\n 'programOptions' | 'discoverAppPaths' | 'applyOptionsToConfig'\n >;\n\n /**\n * This should only be used directly (outside this class) to create the top-level `program` command.\n * To add sub-commands, use `.addSubCommand` instead.\n */\n constructor(\n // The extra options here shouldn't be exposed to the `createSubCommand` API\n params: CloudpackCommandParams<TOptions, TArguments> &\n Pick<CommandExecutorParams<TOptions>, 'programOptions'> & {\n /** This must be undefined for the top-level program command */\n parent?: Command;\n },\n ) {\n this._executorOptions = {\n programOptions: params.programOptions,\n discoverAppPaths: params.discoverAppPaths,\n applyOptionsToConfig: params.applyOptionsToConfig,\n };\n\n const command = params.parent?.command(params.name) || new Command(params.name);\n this._command = command;\n\n command.version(params.programOptions.version);\n command.description(params.description);\n command.allowExcessArguments(false);\n\n const isTopLevel = !params.parent;\n command.createHelp = () => new CloudpackHelp({ isTopLevel });\n // set the default help group for options\n command.optionsGroup(optionGroups.default);\n\n params.usage && command.usage(params.usage);\n params.alias && command.alias(params.alias);\n params.addHelpText && command.addHelpText(params.addHelpText.position, params.addHelpText.text);\n params.outputOptions && command.configureOutput(params.outputOptions);\n params.getExecutor && this._addAction(params.getExecutor);\n\n if (params.args) {\n this._addArguments<TArguments>(params.args);\n }\n\n if (params.options) {\n // Add the command-specific options first so they show up first in help\n this._addOptions<TOptions>(params.options);\n }\n\n // Add shared options. These must be manually added to the program command and each sub-command\n // because commander doesn't natively support inheriting options.\n this._addOptions<SharedOptions>(\n {\n verbose: new Option('-v, --verbose', 'Show additional details in logging.').helpGroup(optionGroups.logging),\n debug: new Option('-d, --debug', 'Show debug information (superset of --verbose).')\n .conflicts('verbose')\n .helpGroup(optionGroups.logging),\n quiet: new Option('-q, --quiet', 'Disable non-essential logging.')\n .conflicts('verbose')\n .conflicts('debug')\n .helpGroup(optionGroups.logging),\n color:\n // In the parsed options, this will be a boolean `color` with default value true (except in tests and CI)\n new Option('-n, --no-color', 'Disable colors in the output.')\n .helpGroup(optionGroups.logging)\n .default(!environmentInfo.isJest && !environmentInfo.isLage && !environmentInfo.isCI),\n logFile: new Option('--log-file', 'Write a log file with all console output.').helpGroup(optionGroups.logging),\n cachePath: new Option(\n '--cache-path <path>',\n 'Custom cache folder. To change the default, run `cloudpack config set cachePath <path>`.',\n ).helpGroup(optionGroups.common),\n config: new Option(\n '-c, --config <filename>',\n 'Custom config file name to use instead of cloudpack.config.json.',\n ).helpGroup(optionGroups.common),\n define: new Option('--define <key=value>', 'Define a global variable. Can be specified multiple times.')\n .helpGroup(optionGroups.common)\n .argParser(parseDefine),\n features: new Option('--features <featureNames...>', 'Enable experimental features.')\n .helpGroup(optionGroups.common)\n .argParser(parseFeature),\n },\n params.hideSharedOptions,\n );\n }\n\n /** Create a child command. */\n public addSubCommand<TChildOptions extends object, TChildArguments extends object = never>(\n params: CloudpackCommandParams<TChildOptions, TChildArguments>,\n ): CloudpackCommand<TChildOptions, TChildArguments> {\n return new CloudpackCommand<TChildOptions, TChildArguments>({\n ...params,\n programOptions: this._executorOptions.programOptions,\n parent: this._command,\n });\n }\n\n /** Run the program (only works on the top-level program command). */\n public async run(): Promise<void> {\n if (this._command.parent) {\n throw new Error('Only the top-level program command can be run directly.');\n }\n\n await this._command.parseAsync(this._executorOptions.programOptions.argv);\n if (this._command.args.length === 0) {\n this._command.help();\n }\n }\n\n /** Add arguments. The generic enforces that argument objects are included for all keys of a type. */\n private _addArguments<TAddArguments extends object>(args: Record<keyof TAddArguments, Argument>): void {\n for (const argument of Object.values(args)) {\n this._command.addArgument(argument as Argument);\n }\n }\n\n /** Add options. The generic enforces that option objects are included for all keys of a type. */\n private _addOptions<TAddOptions extends object>(\n options: Record<keyof TAddOptions, Option | Option[]>,\n hideOptions?: Array<keyof TAddOptions> | true,\n ): void {\n for (const [name, optionOrOptions] of Object.entries(options) as [keyof TAddOptions, Option | Option[]][]) {\n const optionArray = Array.isArray(optionOrOptions) ? optionOrOptions : [optionOrOptions];\n for (const option of optionArray) {\n if (hideOptions === true || hideOptions?.includes(name)) {\n option.hideHelp();\n }\n this._command.addOption(option);\n }\n }\n }\n\n private _addAction(getExecutor: NonNullable<CloudpackCommandParams<TOptions, TArguments>['getExecutor']>): void {\n const command = this._command;\n // The action function receives parsed options as its first parameter, but we ignore those\n // because they only contain options *specific to this command*, not shared options like `debug`.\n command.action(async () => {\n // Commander has support for custom parsers that parse arguments.\n // Use processedArgs instead of args to get the parsed arguments.\n const processedArgs = command.processedArgs as string[];\n\n // Get the shared options too, not just the ones for this command.\n // (In `cloudpackCommand`, we added the shared options to each command object so that they show up\n // in help, but commander still seems to respect options only at the first command where they're\n // encountered, which for shared options will always be the program command.)\n const options = command.optsWithGlobals<TOptions & SharedOptions>();\n\n // Usually `command` will be a sub-command (e.g. \"bundle\"), but it could also be a sub-sub-command\n // (e.g. \"cache clean\").\n const verb = command.parent?.parent ? `${command.parent.name()} ${command.name()}` : command.name();\n\n // Dynamically import the execute function\n const { execute } = await getExecutor();\n if (typeof execute !== 'function') {\n // throw instead of exiting politely, since this is a major developer error\n throw new Error(`No execute function was exported from the command module for ${verb}.`);\n }\n\n const commandExecutor = new CommandExecutor<TOptions & SharedOptions>({\n args: processedArgs,\n options,\n execute,\n verb,\n ...this._executorOptions,\n });\n await commandExecutor.execute();\n });\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/cli",
|
|
3
|
-
"version": "0.77.
|
|
3
|
+
"version": "0.77.8",
|
|
4
4
|
"description": "The Cloudpack command line interface - a tool for managing fast inner and outer looping in web apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -18,25 +18,25 @@
|
|
|
18
18
|
"cloudpack": "./bin/cloudpack.js"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@ms-cloudpack/api-server": "^0.64.
|
|
22
|
-
"@ms-cloudpack/app-server": "^0.20.
|
|
23
|
-
"@ms-cloudpack/bundler": "^0.
|
|
24
|
-
"@ms-cloudpack/bundler-capabilities": "^0.3.
|
|
25
|
-
"@ms-cloudpack/common-types": "^0.
|
|
26
|
-
"@ms-cloudpack/config": "^0.38.
|
|
27
|
-
"@ms-cloudpack/create-express-app": "^1.10.
|
|
21
|
+
"@ms-cloudpack/api-server": "^0.64.22",
|
|
22
|
+
"@ms-cloudpack/app-server": "^0.20.14",
|
|
23
|
+
"@ms-cloudpack/bundler": "^0.26.0",
|
|
24
|
+
"@ms-cloudpack/bundler-capabilities": "^0.3.3",
|
|
25
|
+
"@ms-cloudpack/common-types": "^0.28.0",
|
|
26
|
+
"@ms-cloudpack/config": "^0.38.5",
|
|
27
|
+
"@ms-cloudpack/create-express-app": "^1.10.52",
|
|
28
28
|
"@ms-cloudpack/environment": "^0.1.1",
|
|
29
|
-
"@ms-cloudpack/file-watcher": "^0.4.
|
|
29
|
+
"@ms-cloudpack/file-watcher": "^0.4.10",
|
|
30
30
|
"@ms-cloudpack/json-utilities": "^0.1.11",
|
|
31
|
-
"@ms-cloudpack/link-proxy": "^0.2.
|
|
32
|
-
"@ms-cloudpack/overlay": "^0.19.
|
|
33
|
-
"@ms-cloudpack/package-utilities": "^12.5.
|
|
31
|
+
"@ms-cloudpack/link-proxy": "^0.2.36",
|
|
32
|
+
"@ms-cloudpack/overlay": "^0.19.32",
|
|
33
|
+
"@ms-cloudpack/package-utilities": "^12.5.2",
|
|
34
34
|
"@ms-cloudpack/path-string-parsing": "^1.2.7",
|
|
35
|
-
"@ms-cloudpack/path-utilities": "^3.1.
|
|
36
|
-
"@ms-cloudpack/remote-cache": "^0.11.
|
|
37
|
-
"@ms-cloudpack/setup-utilities": "^0.5.
|
|
35
|
+
"@ms-cloudpack/path-utilities": "^3.1.23",
|
|
36
|
+
"@ms-cloudpack/remote-cache": "^0.11.40",
|
|
37
|
+
"@ms-cloudpack/setup-utilities": "^0.5.44",
|
|
38
38
|
"@ms-cloudpack/task-reporter": "^0.17.4",
|
|
39
|
-
"@ms-cloudpack/telemetry": "^0.11.
|
|
39
|
+
"@ms-cloudpack/telemetry": "^0.11.41",
|
|
40
40
|
"@yarnpkg/lockfile": "^1.1.0",
|
|
41
41
|
"commander": "^14.0.0",
|
|
42
42
|
"cross-spawn": "^7.0.3",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"workspace-tools": "^0.38.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@ms-cloudpack/common-types": "^0.
|
|
52
|
+
"@ms-cloudpack/common-types": "^0.28.0",
|
|
53
53
|
"@ms-cloudpack/common-types-browser": "^0.6.3",
|
|
54
54
|
"@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
|
|
55
55
|
"@ms-cloudpack/scripts": "^0.0.1",
|