({
'mode': mode,
'feature': featureId,
'log-level': inputLogLevel,
'output-format': outputFormat,
}: FeaturesInfoArgs)
| 32 | } |
| 33 | |
| 34 | async function featuresInfo({ |
| 35 | 'mode': mode, |
| 36 | 'feature': featureId, |
| 37 | 'log-level': inputLogLevel, |
| 38 | 'output-format': outputFormat, |
| 39 | }: FeaturesInfoArgs) { |
| 40 | const disposables: (() => Promise<unknown> | undefined)[] = []; |
| 41 | const dispose = async () => { |
| 42 | await Promise.all(disposables.map(d => d())); |
| 43 | }; |
| 44 | |
| 45 | const pkg = getPackageConfig(); |
| 46 | |
| 47 | const output = createLog({ |
| 48 | logLevel: mapLogLevel(inputLogLevel), |
| 49 | logFormat: 'text', |
| 50 | log: (str) => process.stderr.write(str), |
| 51 | terminalDimensions: undefined, |
| 52 | }, pkg, new Date(), disposables, true); |
| 53 | |
| 54 | const params = { output, env: process.env, outputFormat }; |
| 55 | |
| 56 | const jsonOutput: InfoJsonOutput = {}; |
| 57 | |
| 58 | // Parse the provided Feature Id |
| 59 | const featureRef = getRef(output, featureId); |
| 60 | if (!featureRef) { |
| 61 | if (outputFormat === 'json') { |
| 62 | console.log(JSON.stringify({}), LogLevel.Info); |
| 63 | } else { |
| 64 | console.log(`Failed to parse Feature identifier '${featureId}'\n`, LogLevel.Error); |
| 65 | } |
| 66 | process.exit(1); |
| 67 | } |
| 68 | |
| 69 | const manifestContainer = await getManifest(params, featureRef); |
| 70 | if (!manifestContainer) { |
| 71 | process.exit(1); |
| 72 | } |
| 73 | |
| 74 | // -- Display the manifest |
| 75 | if (mode === 'manifest' || mode === 'verbose') { |
| 76 | const { manifestObj, canonicalId } = manifestContainer; |
| 77 | if (outputFormat === 'text') { |
| 78 | console.log(encloseStringInBox('Manifest')); |
| 79 | console.log(`${JSON.stringify(manifestObj, undefined, 2)}\n`); |
| 80 | console.log(encloseStringInBox('Canonical Identifier')); |
| 81 | console.log(`${canonicalId}\n`); |
| 82 | } else { |
| 83 | jsonOutput.manifest = manifestObj; |
| 84 | jsonOutput.canonicalId = canonicalId; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | // --- Get all published tags for resource |
| 89 | if (mode === 'tags' || mode === 'verbose') { |
| 90 | const publishedTags = await getTags(params, featureRef); |
| 91 | if (outputFormat === 'text') { |
nothing calls this directly
no test coverage detected