Compare commits

...

25 Commits

Author SHA1 Message Date
71abbbb5f1 1.0.23 2021-04-21 09:25:32 +00:00
9dfa1a789e fix(core): update 2021-04-21 09:25:31 +00:00
c68ea1c8fd 1.0.22 2021-04-19 14:34:27 +00:00
8e943512f8 1.0.21 2021-04-19 14:22:42 +00:00
c010319076 fix(core): update 2021-04-19 14:22:42 +00:00
cf03e58c6f 1.0.20 2021-04-19 12:55:12 +00:00
d59875f23f fix(core): update 2021-04-19 12:55:11 +00:00
6b13e46947 1.0.19 2020-10-02 14:39:47 +00:00
096c38de9e fix(core): update 2020-10-02 14:39:46 +00:00
7292b45d33 1.0.18 2020-10-02 13:28:40 +00:00
3ddad53d29 fix(core): update 2020-10-02 13:28:39 +00:00
617b49aaba 1.0.17 2020-06-25 20:04:31 +00:00
2dcd93b431 fix(core): update 2020-06-25 20:04:30 +00:00
0e2dc83409 1.0.16 2020-06-25 20:03:53 +00:00
2cb227632f fix(core): update 2020-06-25 20:03:52 +00:00
d0f6e88388 1.0.15 2020-03-17 00:38:59 +00:00
e72a5cb4af fix(core): update 2020-03-17 00:38:58 +00:00
0d3292dd1e 1.0.14 2020-03-08 19:34:37 +00:00
54db436174 fix(core): update 2020-03-08 19:34:36 +00:00
7075d7b36f 1.0.13 2019-09-06 16:29:46 +02:00
98aca88b49 fix(core): update 2019-09-06 16:29:45 +02:00
5f49845138 1.0.12 2019-09-06 13:22:54 +02:00
1d5e94244b fix(core): update 2019-09-06 13:22:54 +02:00
7cc7c54587 1.0.11 2019-09-06 11:12:23 +02:00
24af38ed8b fix(core): update 2019-09-06 11:12:23 +02:00
25 changed files with 11035 additions and 806 deletions

17
.gitignore vendored
View File

@ -1,5 +1,20 @@
.nogit/
node_modules/
# artifacts
coverage/
public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,10 +1,10 @@
# gitzone standard
image: hosttoday/ht-docker-node:npmci
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: "$CI_BUILD_STAGE"
key: '$CI_BUILD_STAGE'
stages:
- security
@ -19,56 +19,61 @@ mirror:
stage: security
script:
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
snyk:
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
- npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
- notpriv
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags:
- docker
allow_failure: true
# ====================
# test stage
# ====================
testLEGACY:
stage: test
script:
- npmci node install legacy
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
allow_failure: true
testLTS:
stage: test
script:
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
testSTABLE:
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
release:
stage: release
@ -78,6 +83,7 @@ release:
only:
- tags
tags:
- lossless
- docker
- notpriv
@ -86,20 +92,16 @@ release:
# ====================
codequality:
stage: metadata
image: docker:stable
allow_failure: true
services:
- docker:stable-dind
only:
- tags
script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env SOURCE_CODE="$PWD"
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
paths: [codeclimate.json]
- npmci command npm install -g tslint typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
- priv
@ -110,17 +112,20 @@ trigger:
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata
script:
- npmci command npm install -g typedoc typescript
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
@ -130,13 +135,3 @@ pages:
paths:
- public
allow_failure: true
windowsCompatibility:
image: stefanscherer/node-windows:10-build-tools
stage: metadata
script:
- npm install & npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- windows
allow_failure: true

29
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,29 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

2
dist/index.d.ts vendored
View File

@ -1,2 +0,0 @@
export * from './smartnpm.classes.npmregistry';
export * from './smartnpm.classes.npmpackage';

8
dist/index.js vendored
View File

@ -1,8 +0,0 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./smartnpm.classes.npmregistry"));
__export(require("./smartnpm.classes.npmpackage"));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUVBLG9EQUE4QztBQUM5QyxtREFBNkMifQ==

View File

@ -1,32 +0,0 @@
export declare class NpmPackage {
name: string;
scope: string;
version: string;
description: string;
keywords: string[];
date: '2017-08-02T11:22:49.144Z';
links: {
npm: string;
homepage: string;
repository: string;
bugs: string;
};
author: {
name: 'Lossless GmbH';
};
publisher: {
username: 'gitzone';
email: 'npm@git.zone';
};
maintainers: any;
score: {
final: number;
detail: {
quality: number;
popularity: number;
maintenance: number;
};
};
searchScore: number;
constructor(descriptionArg: any);
}

View File

@ -1,24 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class NpmPackage {
constructor(descriptionArg) {
this.name = null;
this.scope = null;
this.version = null;
this.description = null;
this.keywords = null;
this.links = null;
this.author = null;
this.publisher = null;
this.maintainers = null;
this.score = null;
this.searchScore = null;
for (let key in descriptionArg) {
if (this[key] === null) {
this[key] = descriptionArg[key];
}
}
}
}
exports.NpmPackage = NpmPackage;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRucG0uY2xhc3Nlcy5ucG1wYWNrYWdlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRucG0uY2xhc3Nlcy5ucG1wYWNrYWdlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBRUEsTUFBYSxVQUFVO0lBOEJyQixZQUFhLGNBQWM7UUE3QjNCLFNBQUksR0FBVyxJQUFJLENBQUE7UUFDbkIsVUFBSyxHQUFXLElBQUksQ0FBQTtRQUNwQixZQUFPLEdBQVcsSUFBSSxDQUFBO1FBQ3RCLGdCQUFXLEdBQVcsSUFBSSxDQUFBO1FBQzFCLGFBQVEsR0FBYSxJQUFJLENBQUE7UUFFekIsVUFBSyxHQUtELElBQUksQ0FBQTtRQUNSLFdBQU0sR0FFRixJQUFJLENBQUE7UUFDUixjQUFTLEdBRUwsSUFBSSxDQUFBO1FBQ1IsZ0JBQVcsR0FBUSxJQUFJLENBQUE7UUFDdkIsVUFBSyxHQU9ELElBQUksQ0FBQTtRQUNSLGdCQUFXLEdBQVcsSUFBSSxDQUFBO1FBR3hCLEtBQUssSUFBSSxHQUFHLElBQUksY0FBYyxFQUFFO1lBQzlCLElBQUksSUFBSSxDQUFDLEdBQUcsQ0FBQyxLQUFLLElBQUksRUFBRTtnQkFDdEIsSUFBSSxDQUFDLEdBQUcsQ0FBQyxHQUFHLGNBQWMsQ0FBQyxHQUFHLENBQUMsQ0FBQTthQUNoQztTQUNGO0lBQ0gsQ0FBQztDQUNGO0FBckNELGdDQXFDQyJ9

View File

@ -1,6 +0,0 @@
import { ISearchObject } from './smartnpm.interfaces';
import { NpmPackage } from './smartnpm.classes.npmpackage';
export declare class NpmRegistry {
private searchDomain;
search(searchObjectArg: ISearchObject): Promise<NpmPackage[]>;
}

View File

@ -1,104 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./smartnpm.plugins");
// classes
const smartnpm_classes_npmpackage_1 = require("./smartnpm.classes.npmpackage");
class NpmRegistry {
constructor() {
this.searchDomain = 'https://api.npms.io/v2/search?q=';
}
search(searchObjectArg) {
return __awaiter(this, void 0, void 0, function* () {
let searchString = '';
let addToSearchString = (addStringArg) => {
searchString = `${searchString}+${addStringArg}`;
};
// name
if (searchObjectArg.name) {
searchString = `${searchObjectArg.name}`;
}
// metadata
if (searchObjectArg.author) {
addToSearchString(`author:${searchObjectArg.author}`);
}
if (searchObjectArg.maintainer) {
addToSearchString(`maintainer:${searchObjectArg.maintainer}`);
}
if (searchObjectArg.scope) {
addToSearchString(`scope:${searchObjectArg.scope}`);
}
// status
if (searchObjectArg.deprecated) {
if (searchObjectArg.deprecated === true) {
addToSearchString(`is:deprecated`);
}
else {
addToSearchString(`not:deprecated`);
}
}
if (searchObjectArg.unstable) {
if (searchObjectArg.unstable === true) {
addToSearchString(`is:unstable`);
}
else {
addToSearchString(`not:unstable`);
}
}
if (searchObjectArg.insecure) {
if (searchObjectArg.insecure === true) {
addToSearchString(`is:insecure`);
}
else {
addToSearchString(`not:insecure`);
}
}
// search behaviour
if (searchObjectArg.boostExact) {
addToSearchString(`boost-exact:${searchObjectArg.boostExact}`);
}
if (searchObjectArg.scoreEffect) {
addToSearchString(`score-effect:${searchObjectArg.scoreEffect}`);
}
// analytics
if (searchObjectArg.qualityWeight) {
addToSearchString(`author:${searchObjectArg.qualityWeight}`);
}
if (searchObjectArg.popularityWeight) {
addToSearchString(`author:${searchObjectArg.popularityWeight}`);
}
if (searchObjectArg.maintenanceWeight) {
addToSearchString(`author:${searchObjectArg.maintenanceWeight}`);
}
plugins.smartlog.defaultLogger.info(`Search on npm for ${plugins.consolecolor.coloredString(searchString, 'pink')}`);
let body;
try {
let response = (yield plugins.smartrequest.getJson(this.searchDomain + searchString, {}));
body = response.body;
}
catch (_a) {
// we do nothing
}
// lets create the packageArray
let packageArray = [];
// if request failed just return it empty
if (!body || typeof body === 'string') {
return packageArray;
}
for (let packageArg of body.results) {
let localPackage = new smartnpm_classes_npmpackage_1.NpmPackage(packageArg.package);
packageArray.push(localPackage);
}
return packageArray;
});
}
}
exports.NpmRegistry = NpmRegistry;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRucG0uY2xhc3Nlcy5ucG1yZWdpc3RyeS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bnBtLmNsYXNzZXMubnBtcmVnaXN0cnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztBQUFBLDhDQUE2QztBQUs3QyxVQUFVO0FBQ1YsK0VBQTBEO0FBRTFELE1BQWEsV0FBVztJQUF4QjtRQUNVLGlCQUFZLEdBQUcsa0NBQWtDLENBQUE7SUF5RTNELENBQUM7SUF4RU8sTUFBTSxDQUFFLGVBQThCOztZQUMxQyxJQUFJLFlBQVksR0FBRyxFQUFFLENBQUE7WUFDckIsSUFBSSxpQkFBaUIsR0FBRyxDQUFDLFlBQW9CLEVBQUUsRUFBRTtnQkFDL0MsWUFBWSxHQUFHLEdBQUcsWUFBWSxJQUFJLFlBQVksRUFBRSxDQUFBO1lBQ2xELENBQUMsQ0FBQTtZQUVELE9BQU87WUFDUCxJQUFJLGVBQWUsQ0FBQyxJQUFJLEVBQUU7Z0JBQUUsWUFBWSxHQUFHLEdBQUcsZUFBZSxDQUFDLElBQUksRUFBRSxDQUFBO2FBQUU7WUFFdEUsV0FBVztZQUNYLElBQUksZUFBZSxDQUFDLE1BQU0sRUFBRTtnQkFBRSxpQkFBaUIsQ0FBQyxVQUFVLGVBQWUsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxDQUFBO2FBQUU7WUFDckYsSUFBSSxlQUFlL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QUFJLElBQUksT0FBTyxJQUFJLEtBQUssUUFBUSxFQUFFO2dCQUNyQyxPQUFPLFlBQVksQ0FBQTthQUNwQjtZQUVELEtBQUssSUFBSSxVQUFVLElBQUksSUFBSSxDQUFDLE9BQU8sRUFBRTtnQkFDbkMsSUFBSSxZQUFZLEdBQUcsSUFBSSx3Q0FBVSxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUMsQ0FBQTtnQkFDckQsWUFBWSxDQUFDLElBQUksQ0FBQyxZQUFZLENBQUMsQ0FBQTthQUNoQztZQUVELE9BQU8sWUFBWSxDQUFBO1FBQ3JCLENBQUM7S0FBQTtDQUNGO0FBMUVELGtDQTBFQyJ9

View File

@ -1,15 +0,0 @@
export interface ISearchObject {
name?: string;
author?: string;
maintainer?: string;
scope?: string;
keywords?: string[];
deprecated?: boolean;
unstable?: boolean;
insecure?: boolean;
boostExact?: boolean;
scoreEffect?: number;
qualityWeight?: number;
popularityWeight?: number;
maintenanceWeight?: number;
}

View File

@ -1,3 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRucG0uaW50ZXJmYWNlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bnBtLmludGVyZmFjZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9

View File

@ -1,4 +0,0 @@
import * as consolecolor from '@pushrocks/consolecolor';
import * as smartlog from '@pushrocks/smartlog';
import * as smartrequest from '@pushrocks/smartrequest';
export { consolecolor, smartlog, smartrequest };

View File

@ -1,10 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const consolecolor = require("@pushrocks/consolecolor");
exports.consolecolor = consolecolor;
const smartlog = require("@pushrocks/smartlog");
exports.smartlog = smartlog;
smartlog.defaultLogger.enableConsole();
const smartrequest = require("@pushrocks/smartrequest");
exports.smartrequest = smartrequest;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRucG0ucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0bnBtLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSx3REFBd0Q7QUFLL0Msb0NBQVk7QUFKckIsZ0RBQWdEO0FBSXpCLDRCQUFRO0FBSC9CLFFBQVEsQ0FBQyxhQUFhLENBQUMsYUFBYSxFQUFFLENBQUM7QUFDdkMsd0RBQXdEO0FBRXZCLG9DQUFZIn0=

View File

@ -2,5 +2,16 @@
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartnpm",
"shortDescription": "interface with npm to retrieve package information",
"npmPackagename": "@pushrocks/smartnpm",
"license": "MIT"
}
}
}

11422
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,46 @@
{
"name": "@pushrocks/smartnpm",
"version": "1.0.10",
"version": "1.0.23",
"private": false,
"description": "interface with npm to retrieve package information",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
"test": "(tstest test/)",
"build": "(tsbuild)"
"build": "(tsbuild --web)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.0.22",
"@gitzone/tsrun": "^1.1.13",
"@gitzone/tstest": "^1.0.15",
"@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^10.12.3",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0"
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsrun": "^1.2.12",
"@gitzone/tstest": "^1.0.52",
"@pushrocks/tapbundle": "^3.2.14",
"@types/node": "^14.14.41",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},
"dependencies": {
"@pushrocks/consolecolor": "^2.0.1",
"@pushrocks/smartlog": "^2.0.8",
"@pushrocks/smartrequest": "^1.1.14"
}
"@pushrocks/smartarchive": "^2.0.4",
"@pushrocks/smartfile": "^8.0.9",
"@pushrocks/smartpromise": "^3.1.3",
"@pushrocks/smartrequest": "^1.1.51",
"package-json": "^6.5.0"
},
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
}

0
qenv.yml Normal file
View File

View File

@ -1,33 +1,39 @@
# smartnpm
# @pushrocks/smartnpm
interface with npm to retrieve package information
## Availabililty
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartnpm)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartnpm)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartnpm)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartnpm/)
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartnpm)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartnpm)
* [github.com (source mirror)](https://github.com/pushrocks/smartnpm)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartnpm/)
## Status for master
[![build status](https://GitLab.com/pushrocks/smartnpm/badges/master/build.svg)](https://GitLab.com/pushrocks/smartnpm/commits/master)
[![coverage report](https://GitLab.com/pushrocks/smartnpm/badges/master/coverage.svg)](https://GitLab.com/pushrocks/smartnpm/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/smartnpm.svg)](https://www.npmjs.com/package/smartnpm)
[![Dependency Status](https://david-dm.org/pushrocks/smartnpm.svg)](https://david-dm.org/pushrocks/smartnpm)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartnpm/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartnpm/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartnpm/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartnpm)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartnpm/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartnpm/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartnpm)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartnpm)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartnpm)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartnpm)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartnpm)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage
Use TypeScript for best in class instellisense.
For further information read the linked docs at the top of this README.
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
For further information read the linked docs at the top of this readme.
> MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

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

View File

@ -1,27 +1,44 @@
import * as plugins from './smartnpm.plugins';
import { NpmRegistry } from './smartnpm.classes.npmregistry';
export class NpmPackage {
name: string = null;
scope: string = null;
version: string = null;
description: string = null;
keywords: string[] = null;
date: '2017-08-02T11:22:49.144Z';
links: {
public static async createFromFullMetadata(
npmRegistryArg: NpmRegistry,
fullMetadata: plugins.packageJson.FullMetadata
) {
const npmPackage = new NpmPackage(npmRegistryArg);
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: {
npm: string;
homepage: string;
repository: string;
bugs: string;
} = null;
author: {
};
public author: {
name: 'Lossless GmbH';
} = null;
publisher: {
};
public publisher: {
username: 'gitzone';
email: 'npm@git.zone';
} = null;
maintainers: any = null;
score: {
};
public maintainers: any = null;
public dist: {
integrity: string;
shasum: string;
tarball: string;
};
public score: {
final: number;
detail: {
quality: number;
@ -29,13 +46,50 @@ export class NpmPackage {
maintenance: number;
};
} = null;
searchScore: number = null;
public searchScore: number = null;
constructor(descriptionArg) {
for (let key in descriptionArg) {
if (this[key] === null) {
this[key] = descriptionArg[key];
}
}
public npmRegistryRef: NpmRegistry;
constructor(npmRegistryArg: NpmRegistry) {
this.npmRegistryRef = npmRegistryArg;
}
/**
* saves the package to disk
*/
public async saveToDisk(targetDir: string) {
const smartarchiveInstance = new plugins.smartarchive.SmartArchive();
await smartarchiveInstance.extractArchiveFromUrlToFs(this.dist.tarball, targetDir);
}
/**
* saves the package to memory
*/
public async saveToMemory() {}
/**
* get file from package
*/
public async getFileFromPackage(filePath: string): Promise<plugins.smartfile.Smartfile> {
const done = plugins.smartpromise.defer<plugins.smartfile.Smartfile>();
const smartarchiveInstance = new plugins.smartarchive.SmartArchive();
const fileObservable = await smartarchiveInstance.extractArchiveFromUrlToObservable(
this.dist.tarball
);
const wantedFilePath = plugins.path.join('package', filePath);
const subscription = fileObservable.subscribe(
(fileArg) => {
if (fileArg.path === wantedFilePath) {
done.resolve(fileArg);
subscription.unsubscribe();
}
},
(err) => {
console.log(err);
},
() => {
subscription.unsubscribe();
}
);
return done.promise;
}
}

View File

@ -1,4 +1,5 @@
import * as plugins from './smartnpm.plugins';
import * as paths from './smartnpm.paths';
// interfaces
import { ISearchObject } from './smartnpm.interfaces';
@ -6,11 +7,75 @@ import { ISearchObject } from './smartnpm.interfaces';
// classes
import { NpmPackage } from './smartnpm.classes.npmpackage';
export interface INpmRegistryConstructorOptions {
npmRegistryUrl?: string;
}
export class NpmRegistry {
public options: INpmRegistryConstructorOptions;
private searchDomain = 'https://api.npms.io/v2/search?q=';
async search(searchObjectArg: ISearchObject) {
constructor(optionsArg: INpmRegistryConstructorOptions = {}) {
const defaultOptions: INpmRegistryConstructorOptions = {
npmRegistryUrl: 'https://registry.npmjs.org',
};
this.options = {
...defaultOptions,
...optionsArg,
};
}
/**
* gets info about a package
* @param packageName
*/
public async getPackageInfo(packageName: string): Promise<NpmPackage> {
const fullMetadata = await plugins.packageJson(packageName, {
registryUrl: this.options.npmRegistryUrl,
fullMetadata: true,
});
const npmPackage = await NpmPackage.createFromFullMetadata(this, fullMetadata);
return npmPackage;
}
/**
* saves a package to disk
* @param packageName
* @param targetDir
*/
public async savePackageToDisk(packageName: string, targetDir: string): Promise<void> {
plugins.smartfile.fs.ensureDirSync(paths.nogitDir);
const npmPackage = await this.getPackageInfo(packageName);
await npmPackage.saveToDisk(targetDir);
}
/**
* gets a file from a package as Smartfile
*/
public async getFileFromPackage(packageNameArg: string, filePath: string): Promise<plugins.smartfile.Smartfile> {
const npmPackage = await this.getPackageInfo(packageNameArg);
return npmPackage.getFileFromPackage(filePath);
}
public async getPackageAsSmartfileVirtualDir(packageNameArg: string): Promise<plugins.smartfile.VirtualDirectory> {
const baseDir = plugins.path.join(paths.nogitDir, packageNameArg.replace('/', '__'));
await plugins.smartfile.fs.ensureDir(baseDir);
await this.savePackageToDisk(packageNameArg, baseDir);
const virtualDir = await plugins.smartfile.VirtualDirectory.fromFsDirPath(baseDir);
await plugins.smartfile.fs.remove(baseDir);
return virtualDir;
}
/**
* searches for a package on npm
* @param searchObjectArg
*/
public async searchOnNpm(searchObjectArg: ISearchObject) {
if (this.options.npmRegistryUrl !== 'https://registry.npmjs.org') {
throw Error(`cannot search registries other than registry.gitlab.com`);
}
let searchString = '';
let addToSearchString = (addStringArg: string) => {
const addToSearchString = (addStringArg: string) => {
searchString = `${searchString}+${addStringArg}`;
};
@ -72,30 +137,29 @@ export class NpmRegistry {
addToSearchString(`author:${searchObjectArg.maintenanceWeight}`);
}
plugins.smartlog.defaultLogger.log(
'info',
`Search on npm for ${plugins.consolecolor.coloredString(searchString, 'pink')}`
console.log(
`info: Search on npm for ${plugins.consolecolor.coloredString(searchString, 'pink')}`
);
let body: any;
try {
let response = await plugins.smartrequest.getJson(this.searchDomain + searchString, {});
const response = await plugins.smartrequest.getJson(this.searchDomain + searchString, {});
body = response.body;
} catch {
// we do nothing
}
// lets create the packageArray
let packageArray: NpmPackage[] = [];
const packageArray: NpmPackage[] = [];
// if request failed just return it empty
if (!body || typeof body === 'string') {
return packageArray;
}
for (let packageArg of body.results) {
let localPackage = new NpmPackage(packageArg.package);
packageArray.push(localPackage);
for (const packageSearchInfoArg of body.results) {
const npmPackage = await this.getPackageInfo(packageSearchInfoArg.package.name);
packageArray.push(npmPackage);
}
return packageArray;

4
ts/smartnpm.paths.ts Normal file
View File

@ -0,0 +1,4 @@
import * as plugins from './smartnpm.plugins';
export const packageDir = plugins.path.join(__dirname, '../');
export const nogitDir = plugins.path.join(packageDir, '.nogit/');

View File

@ -1,6 +1,18 @@
// node native modules
import * as path from 'path';
export { path };
// @pushrocks scope
import * as consolecolor from '@pushrocks/consolecolor';
import * as smartlog from '@pushrocks/smartlog';
smartlog.defaultLogger.enableConsole();
import * as smartarchive from '@pushrocks/smartarchive';
import * as smartfile from '@pushrocks/smartfile';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrequest from '@pushrocks/smartrequest';
export { consolecolor, smartlog, smartrequest };
export { consolecolor, smartarchive, smartfile, smartpromise, smartrequest };
// third party scope
import packageJson from 'package-json';
export { packageJson };

View File

@ -1,3 +1,17 @@
{
"extends": "tslint-config-standard"
"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"
}