fix(smartpnpm): harden pnpm license parsing and modernize test and package configuration
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartpnpm',
|
||||
version: '1.0.6',
|
||||
description: 'use pnpm in your code'
|
||||
version: '1.0.7',
|
||||
description: 'A library for integrating pnpm package management capabilities within your code.'
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ export interface IPnpmLicenseResult {
|
||||
"description": string;
|
||||
}
|
||||
|
||||
export type TPnpmLicenseMap = Record<string, IPnpmLicenseResult[]>;
|
||||
|
||||
export class SmartPnpm {
|
||||
public projectDir: string;
|
||||
|
||||
@@ -19,18 +21,12 @@ export class SmartPnpm {
|
||||
|
||||
private smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash',
|
||||
})
|
||||
});
|
||||
|
||||
async getDependencyLicenseJson() {
|
||||
try {
|
||||
// Get store directory
|
||||
const execResult = await this.smartshellInstance.execSilent(`(cd ${this.projectDir} && pnpm licenses list --json)`);
|
||||
const licenseJson: {[key: string]: Array<IPnpmLicenseResult>} = JSON.parse(execResult.stdout);
|
||||
return licenseJson;
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
}
|
||||
async getDependencyLicenseJson(): Promise<TPnpmLicenseMap> {
|
||||
const projectDir = this.projectDir.replace(/(["\\$`])/g, '\\$1');
|
||||
const execResult = await this.smartshellInstance.execSilent(`(cd "${projectDir}" && pnpm licenses list --json)`);
|
||||
return JSON.parse(execResult.stdout) as TPnpmLicenseMap;
|
||||
}
|
||||
|
||||
public async printDependencyLicenseSummary() {
|
||||
@@ -45,7 +41,7 @@ export class SmartPnpm {
|
||||
} else {
|
||||
console.log(`|-- ${refArray.length} packages. Not detailing this license type.`);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async getDependencyLicenseFlatArray() {
|
||||
|
||||
@@ -2,4 +2,4 @@ import * as smartshell from '@push.rocks/smartshell';
|
||||
|
||||
export {
|
||||
smartshell,
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user