fix(smartpnpm): harden pnpm license parsing and modernize test and package configuration

This commit is contained in:
2026-05-01 21:39:17 +00:00
parent cc99ce58db
commit 5e8416d7f7
11 changed files with 6896 additions and 4896 deletions
+3 -3
View File
@@ -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.'
}
+8 -12
View File
@@ -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() {
+1 -1
View File
@@ -2,4 +2,4 @@ import * as smartshell from '@push.rocks/smartshell';
export {
smartshell,
}
};