11import { setTimeout } from 'node:timers/promises' ;
22import { search } from '@inquirer/prompts' ;
3- import { getLicenseList , LicensesMap } from '.. /lib/spdx' ;
4- import { CalInfo , InventoryLicense , pushLicense } from '.. /lib/inventory' ;
5- import { getCALData } from '.. /lib/chooseALicense' ;
3+ import { getLicenseList , LicensesMap } from '@ /lib/spdx' ;
4+ import { CalInfo , InventoryLicense , pushLicense } from '@ /lib/inventory' ;
5+ import { getCALData } from '@ /lib/chooseALicense' ;
66
77// const answer = await input({ message: 'Enter your name' });
88
@@ -14,6 +14,7 @@ type Option = {
1414type AddLicenseCMDOptions = {
1515 spdxID ?: string ;
1616 requireCal ?: boolean ;
17+ allowDeprecated ?: boolean ;
1718} ;
1819
1920async function promptForSPDXID ( licenseList : LicensesMap ) : Promise < string > {
@@ -40,7 +41,7 @@ async function promptForSPDXID(licenseList: LicensesMap): Promise<string> {
4041// TODO: add multiple licenses at the same time
4142async function addLicenseCMD ( liURL : string , options ?: AddLicenseCMDOptions ) {
4243 console . info ( 'fetching license list from `spdx.org`' ) ;
43- const licenseList = await getLicenseList ( ) ;
44+ const licenseList = await getLicenseList ( options ?. allowDeprecated ?? false ) ;
4445 console . info ( 'done fetching' ) ;
4546
4647 const selectedLicenseID = options ?. spdxID ?? ( await promptForSPDXID ( licenseList ) ) ;
@@ -58,9 +59,13 @@ async function addLicenseCMD(liURL: string, options?: AddLicenseCMDOptions) {
5859 const cal = await getCALData ( selectedLicense . licenseId . toLowerCase ( ) ) ;
5960 chooseALicenseInfo = cal ;
6061 } catch ( e ) {
61- console . log ( 'failed to get info from Choose A License' ) ;
62+ const errMsg = 'failed to get info from Choose A License' ;
63+
6264 if ( options ?. requireCal ) {
65+ console . error ( errMsg ) ;
6366 throw new Error ( 'forced the need for CAL data' ) ;
67+ } else {
68+ console . warn ( errMsg + ', continuing...' ) ;
6469 }
6570 }
6671
0 commit comments