smartnpm/ts/smartnpm.classes.npmpackage.ts

64 lines
1.5 KiB
TypeScript
Raw Permalink Normal View History

2018-09-01 14:40:42 +00:00
import * as plugins from './smartnpm.plugins';
2020-03-08 19:34:36 +00:00
import { NpmRegistry } from './smartnpm.classes.npmregistry';
2017-08-14 15:50:48 +00:00
2019-09-06 14:29:45 +00:00
export class NpmPackage {
2020-03-17 00:38:58 +00:00
public static async createFromFullMetadata(
npmRegistryArg: NpmRegistry,
fullMetadata: plugins.packageJson.FullMetadata
) {
const npmPackage = new NpmPackage(npmRegistryArg);
2019-09-06 11:22:54 +00:00
Object.assign(npmPackage, fullMetadata);
return npmPackage;
}
// INSTANCE
public name: string = null;
public scope: string = null;
public version: string = null;
public description: string = null;
public keywords: string[] = null;
public date: string;
public license: string;
public links: {
2018-09-01 14:40:42 +00:00
npm: string;
homepage: string;
repository: string;
bugs: string;
2019-09-06 11:22:54 +00:00
};
public author: {
2018-09-01 14:40:42 +00:00
name: 'Lossless GmbH';
2019-09-06 11:22:54 +00:00
};
public publisher: {
2018-09-01 14:40:42 +00:00
username: 'gitzone';
email: 'npm@git.zone';
2019-09-06 11:22:54 +00:00
};
public maintainers: any = null;
2020-03-17 00:38:58 +00:00
public dist: {
integrity: string;
shasum: string;
tarball: string;
};
2019-09-06 11:22:54 +00:00
public score: {
2018-09-01 14:40:42 +00:00
final: number;
2017-08-15 15:03:21 +00:00
detail: {
2018-09-01 14:40:42 +00:00
quality: number;
popularity: number;
maintenance: number;
};
} = null;
2019-09-06 11:22:54 +00:00
public searchScore: number = null;
2020-03-17 00:38:58 +00:00
public npmRegistry: NpmRegistry;
constructor(npmRegistryArg: NpmRegistry) {
this.npmRegistry = npmRegistryArg;
}
/**
* saves the package to disk
*/
public async saveToDisk(targetDir: string) {
const smartarchiveInstance = new plugins.smartarchive.SmartArchive();
await smartarchiveInstance.extractArchiveFromUrl(this.dist.tarball, targetDir);
}
2017-08-14 15:50:48 +00:00
}