fix(core): update

This commit is contained in:
2023-10-11 18:12:09 +02:00
commit e46ede98f2
16 changed files with 6196 additions and 0 deletions

8
ts/00_commitinfo_data.ts Normal file
View 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
View File

@ -0,0 +1 @@
export * from './smartpnpm.classes.smartpnpm.js';

View 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
View File

@ -0,0 +1,5 @@
import * as smartshell from '@push.rocks/smartshell';
export {
smartshell,
}