fix(core): update
This commit is contained in:
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartpnpm',
|
||||
version: '1.0.2',
|
||||
description: 'use pnpm in your code'
|
||||
}
|
1
ts/index.ts
Normal file
1
ts/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './smartpnpm.classes.smartpnpm.js';
|
73
ts/smartpnpm.classes.smartpnpm.ts
Normal file
73
ts/smartpnpm.classes.smartpnpm.ts
Normal file
@ -0,0 +1,73 @@
|
||||
import * as plugins from './smartpnpm.plugins.js';
|
||||
|
||||
export class SmartPnpm {
|
||||
public projectDir: string;
|
||||
|
||||
constructor(projectDirArg: string) {
|
||||
this.projectDir = projectDirArg;
|
||||
}
|
||||
|
||||
private smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash',
|
||||
})
|
||||
|
||||
async getDependencyLicenseJson() {
|
||||
try {
|
||||
// Get store directory
|
||||
const execResult = await this.smartshellInstance.execSilent('pnpm licenses list --json');
|
||||
const licenseJson: {[key: string]: Array<{
|
||||
"name": string;
|
||||
"version": string;
|
||||
"path": string;
|
||||
"license": string;
|
||||
"author": string;
|
||||
"homepage": string;
|
||||
"description": string;
|
||||
}>} = JSON.parse(execResult.stdout);
|
||||
return licenseJson;
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
}
|
||||
}
|
||||
|
||||
public async printDependencyLicenseSummary() {
|
||||
const result = await this.getDependencyLicenseJson();
|
||||
for (const licenseType of Object.keys(result)) {
|
||||
const refArray = result[licenseType];
|
||||
console.log(`${licenseType}: ${refArray.length} packages.`);
|
||||
if (licenseType !== 'MIT' && licenseType !== 'ISC') {
|
||||
for (const ref of refArray) {
|
||||
console.log(`|-- ${ref.name} (${ref.version})`);
|
||||
}
|
||||
} else {
|
||||
console.log(`|-- ${refArray.length} packages. Not detailing this license type.`);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public async getDependencyLicenseFlatArray() {
|
||||
const result = await this.getDependencyLicenseJson();
|
||||
const licenseArray: Array<{
|
||||
"name": string;
|
||||
"version": string;
|
||||
"path": string;
|
||||
"license": string;
|
||||
"author": string;
|
||||
"homepage": string;
|
||||
"description": string;
|
||||
}> = [];
|
||||
for (const licenseType of Object.keys(result)) {
|
||||
const refArray = result[licenseType];
|
||||
for (const ref of refArray) {
|
||||
licenseArray.push(ref);
|
||||
}
|
||||
}
|
||||
return licenseArray;
|
||||
}
|
||||
|
||||
public async getDependencyLicenseArray() {
|
||||
const result = await this.getDependencyLicenseJson();
|
||||
return Object.keys(result);
|
||||
}
|
||||
}
|
5
ts/smartpnpm.plugins.ts
Normal file
5
ts/smartpnpm.plugins.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import * as smartshell from '@push.rocks/smartshell';
|
||||
|
||||
export {
|
||||
smartshell,
|
||||
}
|
Reference in New Issue
Block a user