Compare commits

...

8 Commits

Author SHA1 Message Date
ba57be2fe5 2.0.1 2022-06-01 20:55:46 +02:00
2b308e8824 fix(core): update 2022-06-01 20:55:45 +02:00
0b1b6deb98 2.0.0 2022-04-13 15:50:58 +02:00
d5636aaf9a 1.0.40 2022-04-13 15:50:14 +02:00
0276faa949 fix tests 2022-04-13 15:50:11 +02:00
c0d64926a0 update 2022-04-04 23:21:49 +02:00
7737014464 1.0.39 2021-06-07 13:59:57 +02:00
349360cdc6 fix(core): update 2021-06-07 13:59:56 +02:00
14 changed files with 10044 additions and 9229 deletions

19136
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,35 +1,35 @@
{ {
"name": "@pushrocks/smartnpm", "name": "@pushrocks/smartnpm",
"version": "1.0.38", "version": "2.0.1",
"private": false, "private": false,
"description": "interface with npm to retrieve package information", "description": "interface with npm to retrieve package information",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
"type": "module",
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(tstest test/)",
"build": "(tsbuild --web)" "build": "(tsbuild --web --allowimplicitany)"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.25", "@gitzone/tsbuild": "^2.1.63",
"@gitzone/tsrun": "^1.2.12", "@gitzone/tsrun": "^1.2.34",
"@gitzone/tstest": "^1.0.54", "@gitzone/tstest": "^1.0.71",
"@pushrocks/tapbundle": "^3.2.14", "@pushrocks/tapbundle": "^5.0.3",
"@types/node": "^15.0.2", "@types/node": "^17.0.38"
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/consolecolor": "^2.0.1", "@pushrocks/consolecolor": "^2.0.1",
"@pushrocks/levelcache": "^1.0.10", "@pushrocks/levelcache": "^3.0.1",
"@pushrocks/smartarchive": "^2.0.4", "@pushrocks/smartarchive": "^3.0.2",
"@pushrocks/smartfile": "^8.0.10", "@pushrocks/smartfile": "^9.0.6",
"@pushrocks/smartpromise": "^3.1.5", "@pushrocks/smartpath": "^5.0.5",
"@pushrocks/smartrequest": "^1.1.51", "@pushrocks/smartpromise": "^3.1.7",
"@pushrocks/smarttime": "^3.0.38", "@pushrocks/smartrequest": "^1.1.56",
"@pushrocks/smartversion": "^2.0.7", "@pushrocks/smarttime": "^3.0.45",
"package-json": "^6.5.0" "@pushrocks/smartversion": "^3.0.2",
"package-json": "^7.0.0"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",

View File

@ -1,6 +1,6 @@
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@pushrocks/tapbundle';
import * as smartnpm from '../ts/index'; import * as smartnpm from '../ts/index.js';
import { NpmRegistry } from '../ts/index'; import { NpmRegistry } from '../ts/index.js';
let npmRegistry: smartnpm.NpmRegistry; let npmRegistry: smartnpm.NpmRegistry;
let verdaccioRegistry: smartnpm.NpmRegistry; let verdaccioRegistry: smartnpm.NpmRegistry;
@ -9,17 +9,17 @@ let testPackage: smartnpm.NpmPackage;
// lets test things with the standard npm registry // lets test things with the standard npm registry
tap.test('should create valid instances', async () => { tap.test('should create valid instances', async () => {
npmRegistry = new smartnpm.NpmRegistry(); npmRegistry = new smartnpm.NpmRegistry();
expect(npmRegistry).to.be.instanceof(smartnpm.NpmRegistry); expect(npmRegistry).toBeInstanceOf(smartnpm.NpmRegistry);
testPackage = new smartnpm.NpmPackage(npmRegistry); testPackage = new smartnpm.NpmPackage(npmRegistry);
expect(testPackage).to.be.instanceof(smartnpm.NpmPackage); expect(testPackage).toBeInstanceOf(smartnpm.NpmPackage);
}); });
tap.test('should produce a valid search string and this return npmts', async () => { tap.test('should produce a valid search string and this return npmts', async () => {
const packages = await npmRegistry.searchOnNpm({ const packages = await npmRegistry.searchOnNpm({
name: '@pushrocks/smartupdate', name: '@pushrocks/smartupdate',
}); });
expect(packages[0].name).to.equal('@pushrocks/smartupdate'); expect(packages[0].name).toEqual('@pushrocks/smartupdate');
}); });
// lets test things with the verdaccio registry // lets test things with the verdaccio registry
@ -27,18 +27,18 @@ tap.test('should create a verdaccio registry', async () => {
verdaccioRegistry = new NpmRegistry({ verdaccioRegistry = new NpmRegistry({
npmRegistryUrl: 'https://verdaccio.lossless.one', npmRegistryUrl: 'https://verdaccio.lossless.one',
}); });
expect(verdaccioRegistry).to.be.instanceOf(smartnpm.NpmRegistry); expect(verdaccioRegistry).toBeInstanceOf(smartnpm.NpmRegistry);
}); });
tap.test('should get package from verdaccio', async () => { tap.test('should get package from verdaccio', async () => {
const npmPackage = await verdaccioRegistry.getPackageInfo('@pushrocks/smartupdate'); const npmPackage = await verdaccioRegistry.getPackageInfo('@pushrocks/smartupdate');
expect(npmPackage.license).to.equal('MIT'); expect(npmPackage.license).toEqual('MIT');
}); });
tap.test('should get a specific file from a package', async () => { tap.test('should get a specific file from a package', async () => {
const wantedFile = await verdaccioRegistry.getFileFromPackage( const wantedFile = await verdaccioRegistry.getFileFromPackage(
'@pushrocks/websetup', '@pushrocks/websetup',
'ts/index.ts' './ts/index.ts'
); );
console.log(wantedFile.contentBuffer.toString()); console.log(wantedFile.contentBuffer.toString());
}); });
@ -53,4 +53,12 @@ tap.test('should get a specific file from a package', async () => {
} }
}); });
tap.test('should not get a nonexisting file from a package', async () => {
const wantedFileNotThere = await verdaccioRegistry.getFileFromPackage(
'@pushrocks/websetup',
'ts/notthere'
);
expect(wantedFileNotThere).toBeNull();
});
tap.start(); tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@pushrocks/smartnpm',
version: '2.0.1',
description: 'interface with npm to retrieve package information'
}

View File

@ -1,4 +1,4 @@
import * as plugins from './smartnpm.plugins'; import * as plugins from './smartnpm.plugins.js';
export * from './smartnpm.classes.npmregistry'; export * from './smartnpm.classes.npmregistry.js';
export * from './smartnpm.classes.npmpackage'; export * from './smartnpm.classes.npmpackage.js';

View File

@ -1,7 +1,7 @@
import * as plugins from './smartnpm.plugins'; import * as plugins from './smartnpm.plugins.js';
import { NpmRegistry } from './smartnpm.classes.npmregistry'; import { NpmRegistry } from './smartnpm.classes.npmregistry.js';
import { PackageDisttag } from './smartnpm.classes.packagedisttag'; import { PackageDisttag } from './smartnpm.classes.packagedisttag.js';
import { PackageVersion, IVersionData } from './smartnpm.classes.packageversion'; import { PackageVersion, IVersionData } from './smartnpm.classes.packageversion.js';
export class NpmPackage { export class NpmPackage {
public static async createFromFullMetadataAndVersionData( public static async createFromFullMetadataAndVersionData(
@ -165,7 +165,7 @@ export class NpmPackage {
} }
): Promise<plugins.smartfile.Smartfile> { ): Promise<plugins.smartfile.Smartfile> {
const result = await this.getFilesFromPackage(filePath, optionsArg, true); const result = await this.getFilesFromPackage(filePath, optionsArg, true);
return result[0]; return result[0] || null;
} }
/** /**

View File

@ -1,12 +1,12 @@
import * as plugins from './smartnpm.plugins'; import * as plugins from './smartnpm.plugins.js';
import * as paths from './smartnpm.paths'; import * as paths from './smartnpm.paths.js';
// interfaces // interfaces
import { ISearchObject } from './smartnpm.interfaces'; import { ISearchObject } from './smartnpm.interfaces.js';
// classes // classes
import { NpmPackage } from './smartnpm.classes.npmpackage'; import { NpmPackage } from './smartnpm.classes.npmpackage.js';
import { ICacheDescriptor, RegistryCache } from './smartnpm.classes.registrycache'; import { ICacheDescriptor, RegistryCache } from './smartnpm.classes.registrycache.js';
export interface INpmRegistryConstructorOptions { export interface INpmRegistryConstructorOptions {
npmRegistryUrl?: string; npmRegistryUrl?: string;
@ -90,7 +90,9 @@ export class NpmRegistry {
} }
} }
const fileResult = await npmPackage.getFileFromPackage(filePathArg, optionsArg); const fileResult = await npmPackage.getFileFromPackage(filePathArg, optionsArg);
this.registryCache.cacheSmartFile(cacheDescriptor, fileResult); if (fileResult) {
this.registryCache.cacheSmartFile(cacheDescriptor, fileResult);
}
return fileResult; return fileResult;
} else { } else {
return cachedFile; return cachedFile;

View File

@ -1,4 +1,4 @@
import * as plugins from './smartnpm.plugins'; import * as plugins from './smartnpm.plugins.js';
export class PackageDisttag { export class PackageDisttag {
name: string; name: string;

View File

@ -1,4 +1,4 @@
import * as plugins from './smartnpm.plugins'; import * as plugins from './smartnpm.plugins.js';
export interface IVersionData { export interface IVersionData {
name: string; name: string;

View File

@ -1,5 +1,5 @@
import { NpmRegistry } from './smartnpm.classes.npmregistry'; import { NpmRegistry } from './smartnpm.classes.npmregistry.js';
import * as plugins from './smartnpm.plugins'; import * as plugins from './smartnpm.plugins.js';
export interface ICacheDescriptor { export interface ICacheDescriptor {

View File

@ -1,4 +1,4 @@
import * as plugins from './smartnpm.plugins'; import * as plugins from './smartnpm.plugins.js';
export const packageDir = plugins.path.join(__dirname, '../'); export const packageDir = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
export const nogitDir = plugins.path.join(packageDir, '.nogit/'); export const nogitDir = plugins.path.join(packageDir, '.nogit/');

View File

@ -8,12 +8,13 @@ import * as consolecolor from '@pushrocks/consolecolor';
import * as levelcache from '@pushrocks/levelcache'; import * as levelcache from '@pushrocks/levelcache';
import * as smartarchive from '@pushrocks/smartarchive'; import * as smartarchive from '@pushrocks/smartarchive';
import * as smartfile from '@pushrocks/smartfile'; import * as smartfile from '@pushrocks/smartfile';
import * as smartpath from '@pushrocks/smartpath';
import * as smartpromise from '@pushrocks/smartpromise'; import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrequest from '@pushrocks/smartrequest'; import * as smartrequest from '@pushrocks/smartrequest';
import * as smartversion from '@pushrocks/smartversion'; import * as smartversion from '@pushrocks/smartversion';
import * as smarttime from '@pushrocks/smarttime'; import * as smarttime from '@pushrocks/smarttime';
export { consolecolor, levelcache, smartarchive, smartfile, smartpromise, smartrequest, smartversion, smarttime }; export { consolecolor, levelcache, smartarchive, smartfile, smartpath, smartpromise, smartrequest, smartversion, smarttime };
// third party scope // third party scope
import packageJson from 'package-json'; import packageJson from 'package-json';

9
tsconfig.json Normal file
View File

@ -0,0 +1,9 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext"
}
}

View File

@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}