Compare commits
41 Commits
Author | SHA1 | Date | |
---|---|---|---|
fedc4c5f5b | |||
39ef242615 | |||
211529ffff | |||
d4f5d19231 | |||
80d6a5103a | |||
c22bbe2daf | |||
82af55fae9 | |||
90f8ee4e9d | |||
4fe85134c4 | |||
c307b7c7b0 | |||
e4f608f7eb | |||
0689e33ae6 | |||
7109b666f5 | |||
11bb21e0e0 | |||
4fdc985461 | |||
bd4de83e83 | |||
545e792751 | |||
4fa25477ad | |||
95de67fe17 | |||
2ec33a118a | |||
bb1293c764 | |||
344f144c2c | |||
07cdcb074d | |||
09d9fd45cf | |||
9883067d8b | |||
854dac5732 | |||
73c37d8bf8 | |||
f0664d4c7d | |||
3dff5dbbc6 | |||
15e3497c55 | |||
4184e8f20f | |||
5ebee20a7a | |||
a6aa1b06da | |||
07610c007c | |||
f056e062b3 | |||
00855e3d63 | |||
d5fea19831 | |||
4c3715f655 | |||
513bb686ef | |||
b1f8c79b8d | |||
b0dbb9b8a0 |
20
.gitignore
vendored
20
.gitignore
vendored
@ -1,4 +1,20 @@
|
|||||||
node_modules/
|
.nogit/
|
||||||
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
pages/
|
|
||||||
public/
|
public/
|
||||||
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
# custom
|
121
.gitlab-ci.yml
121
.gitlab-ci.yml
@ -1,48 +1,137 @@
|
|||||||
image: hosttoday/ht-docker-node:npmts
|
# gitzone ci_default
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .npmci_cache/
|
||||||
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- test
|
- security
|
||||||
- release
|
- test
|
||||||
- page
|
- release
|
||||||
|
- metadata
|
||||||
|
|
||||||
testLEGACY:
|
# ====================
|
||||||
stage: test
|
# security stage
|
||||||
|
# ====================
|
||||||
|
mirror:
|
||||||
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci test legacy
|
- npmci git mirror
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
auditProductionDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- 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:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
testLTS:
|
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
|
||||||
|
# ====================
|
||||||
|
|
||||||
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test lts
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
testSTABLE:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test stable
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci publish
|
- npmci node install stable
|
||||||
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# metadata stage
|
||||||
|
# ====================
|
||||||
|
codequality:
|
||||||
|
stage: metadata
|
||||||
|
allow_failure: true
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
script:
|
||||||
|
- 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
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
stage: metadata
|
||||||
|
script:
|
||||||
|
- npmci trigger
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmpage
|
stage: metadata
|
||||||
stage: page
|
|
||||||
script:
|
script:
|
||||||
- npmci command npmpage --host gitlab
|
- npmci node install lts
|
||||||
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command tsdoc
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
|
allow_failure: true
|
||||||
|
4
.snyk
Normal file
4
.snyk
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
|
||||||
|
version: v1.12.0
|
||||||
|
ignore: {}
|
||||||
|
patch: {}
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal 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
26
.vscode/settings.json
vendored
Normal 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"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
47
README.md
47
README.md
@ -1,47 +0,0 @@
|
|||||||
# npmextra
|
|
||||||
do more with npm.
|
|
||||||
|
|
||||||
npmextra is a hub for a series of js tools that help writing, documenting and maintaining npm modules.
|
|
||||||
|
|
||||||
## Availabililty
|
|
||||||
[](https://www.npmjs.com/package/npmextra)
|
|
||||||
[](https://gitlab.com/pushrocks/npmextra)
|
|
||||||
[](https://github.com/pushrocks/npmextra)
|
|
||||||
[](https://pushrocks.gitlab.io/npmextra/)
|
|
||||||
|
|
||||||
## Status for master
|
|
||||||
[](https://gitlab.com/pushrocks/npmextra/commits/master)
|
|
||||||
[](https://gitlab.com/pushrocks/npmextra/commits/master)
|
|
||||||
[](https://david-dm.org/pushrocks/npmextra)
|
|
||||||
[](https://www.bithound.io/github/pushrocks/npmextra/master/dependencies/npm)
|
|
||||||
[](https://www.bithound.io/github/pushrocks/npmextra)
|
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[](http://standardjs.com/)
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
The main purpose of npmextra is to configure different tools using one npmextra.json. This way complex setups avoid additional complexity caused by too many configuration files.
|
|
||||||
|
|
||||||
npmextra.json
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"sometool": {
|
|
||||||
"defaultKey1": "awesomeValueFromConfig"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
import * as npmextra from 'npmextra'
|
|
||||||
|
|
||||||
npmextra.dataFor({
|
|
||||||
toolName:'sometool',
|
|
||||||
defaultSettings: { // gets merged with whatever is in the configfile
|
|
||||||
defaultKey1: 'defaultValue1', // so this will get overwritten with "awesomeValueFromConfig"
|
|
||||||
defaultKey2: 'defaultValue2' // this one will pass through unaltered
|
|
||||||
},
|
|
||||||
cwd?: string // lets you specifiy a custom current working directory to look for the npmextra.json
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
[](https://push.rocks)
|
|
2
dist/index.d.ts
vendored
2
dist/index.d.ts
vendored
@ -1,2 +0,0 @@
|
|||||||
export * from './npmextra.classes.npmextra';
|
|
||||||
export * from './npmextra.classes.keyvaluestore';
|
|
7
dist/index.js
vendored
7
dist/index.js
vendored
@ -1,7 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
function __export(m) {
|
|
||||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
||||||
}
|
|
||||||
__export(require("./npmextra.classes.npmextra"));
|
|
||||||
__export(require("./npmextra.classes.keyvaluestore"));
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBRUEsaURBQTJDO0FBQzNDLHNEQUFnRCJ9
|
|
6
dist/npmextra.classes.keyValueStore.d.ts
vendored
6
dist/npmextra.classes.keyValueStore.d.ts
vendored
@ -1,6 +0,0 @@
|
|||||||
export declare type keyValueStoreTypes = 'path' | 'gitProject';
|
|
||||||
export declare class KeyValueStore {
|
|
||||||
constructor(optionsArg: {
|
|
||||||
type: keyValueStoreTypes;
|
|
||||||
});
|
|
||||||
}
|
|
22
dist/npmextra.classes.keyValueStore.js
vendored
22
dist/npmextra.classes.keyValueStore.js
vendored
@ -1,22 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
class KeyValueStore {
|
|
||||||
constructor(optionsArg) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.KeyValueStore = KeyValueStore;
|
|
||||||
/**
|
|
||||||
* reads a keyValueFile from disk
|
|
||||||
*/
|
|
||||||
let kvRead = () => {
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* writes a key value file to disk
|
|
||||||
*/
|
|
||||||
let kvWrite = () => {
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* wipes a key value store from disk
|
|
||||||
*/
|
|
||||||
let kevWipe = () => {
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZXh0cmEuY2xhc3Nlcy5rZXl2YWx1ZXN0b3JlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtZXh0cmEuY2xhc3Nlcy5rZXl2YWx1ZXN0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFNQTtJQUNJLFlBQVksVUFFWDtJQUVELENBQUM7Q0FBQTtBQUxMLHNDQUtLO0FBQ0Q7O0VBRUQ7QUFDSCxJQUFJLE1BQU0sR0FBQztBQUVYLENBQUMsQ0FBQTtBQUVEOztHQUVHO0FBQ0gsSUFBSSxPQUFPLEdBQUM7QUFFWixDQUFDLENBQUE7QUFFRDs7R0FFRztBQUNILElBQUksT0FBTyxHQUFDO0FBRVosQ0FBQyxDQUFBIn0=
|
|
29
dist/npmextra.classes.npmextra.d.ts
vendored
29
dist/npmextra.classes.npmextra.d.ts
vendored
@ -1,29 +0,0 @@
|
|||||||
/**
|
|
||||||
* Npmextra class allows easy configuration of tools
|
|
||||||
*/
|
|
||||||
export declare class Npmextra {
|
|
||||||
cwd: string;
|
|
||||||
lookupPath: string;
|
|
||||||
npmextraJsonExists: boolean;
|
|
||||||
npmextraJsonData: boolean;
|
|
||||||
/**
|
|
||||||
* creates instance of Npmextra
|
|
||||||
*/
|
|
||||||
constructor(cwdArg?: string);
|
|
||||||
/**
|
|
||||||
* merges the supplied options with the ones from npmextra.json
|
|
||||||
*/
|
|
||||||
dataFor(toolnameArg: string, defaultOptionsArg: any): any;
|
|
||||||
/**
|
|
||||||
* checks if the JSON exists
|
|
||||||
*/
|
|
||||||
private checkNpmextraJsonExists();
|
|
||||||
/**
|
|
||||||
* gets lookupPath
|
|
||||||
*/
|
|
||||||
private checkLookupPath();
|
|
||||||
/**
|
|
||||||
* get npmextraJsonData
|
|
||||||
*/
|
|
||||||
private checkNpmextraJsonData();
|
|
||||||
}
|
|
64
dist/npmextra.classes.npmextra.js
vendored
64
dist/npmextra.classes.npmextra.js
vendored
@ -1,64 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
const plugins = require("./npmextra.plugins");
|
|
||||||
const paths = require("./npmextra.paths");
|
|
||||||
/**
|
|
||||||
* Npmextra class allows easy configuration of tools
|
|
||||||
*/
|
|
||||||
class Npmextra {
|
|
||||||
/**
|
|
||||||
* creates instance of Npmextra
|
|
||||||
*/
|
|
||||||
constructor(cwdArg) {
|
|
||||||
if (cwdArg) {
|
|
||||||
this.cwd = cwdArg;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.cwd = paths.cwd;
|
|
||||||
}
|
|
||||||
this.checkLookupPath();
|
|
||||||
this.checkNpmextraJsonExists();
|
|
||||||
this.checkNpmextraJsonData();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* merges the supplied options with the ones from npmextra.json
|
|
||||||
*/
|
|
||||||
dataFor(toolnameArg, defaultOptionsArg) {
|
|
||||||
let npmextraToolOptions;
|
|
||||||
if (this.npmextraJsonData[toolnameArg]) {
|
|
||||||
npmextraToolOptions = this.npmextraJsonData[toolnameArg];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
npmextraToolOptions = {};
|
|
||||||
}
|
|
||||||
let mergedOptions = plugins.lodash.merge({}, defaultOptionsArg, npmextraToolOptions);
|
|
||||||
return mergedOptions;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* checks if the JSON exists
|
|
||||||
*/
|
|
||||||
checkNpmextraJsonExists() {
|
|
||||||
this.npmextraJsonExists = plugins.smartfile.fs.fileExistsSync(this.lookupPath);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* gets lookupPath
|
|
||||||
*/
|
|
||||||
checkLookupPath() {
|
|
||||||
if (this.cwd) {
|
|
||||||
this.lookupPath = plugins.path.join(this.cwd, 'npmextra.json');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.lookupPath = paths.configFile;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* get npmextraJsonData
|
|
||||||
*/
|
|
||||||
checkNpmextraJsonData() {
|
|
||||||
if (this.npmextraJsonExists) {
|
|
||||||
this.npmextraJsonData = plugins.smartfile.fs.toObjectSync(this.lookupPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.Npmextra = Npmextra;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZXh0cmEuY2xhc3Nlcy5ucG1leHRyYS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWV4dHJhLmNsYXNzZXMubnBtZXh0cmEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDhDQUE2QztBQUM3QywwQ0FBeUM7QUFFekM7O0dBRUc7QUFDSDtJQU1JOztPQUVHO0lBQ0gsWUFBWSxNQUFlO1FBQ3ZCLEVBQUUsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUM7WUFDVCxJQUFJLENBQUMsR0FBRyxHQUFHLE1BQU0sQ0FBQTtRQUNyQixDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDSixJQUFJLENBQUMsR0FBRyxHQUFHLEtBQUssQ0FBQyxHQUFHLENBQUE7UUFDeEIsQ0FBQztRQUNELElBQUksQ0FBQyxlQUFlLEVBQUUsQ0FBQTtRQUN0QixJQUFJLENBQUMsdUJBQXVCLEVBQUUsQ0FBQTtRQUM5QixJQUFJLENBQUMscUJBQXFCLEVBQUUsQ0FBQTtJQUNoQyxDQUFDO0lBRUQ7O09BRUc7SUFDSCxPQUFPLENBQUMsV0FBbUIsRUFBRSxpQkFBc0I7UUFDL0MsSUFBSSxtQkFBbUIsQ0FBQTtRQUN2QixFQUFFLENBQUEsQ0FBQyxJQUFJLENBQUMsZ0JBQWdCLENBQUMsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBQ3BDLG1CQUFtQixHQUFHLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxXQUFXLENBQUMsQ0FBQTtRQUM1RCxDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDSixtQkFBbUIsR0FBRyxFQUFFLENBQUE7UUFDNUIsQ0FBQztRQUNELElBQUksYUFBYSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLEVBQUUsRUFBRSxpQkFBaUIsRUFBRSxtQkFBbUIsQ0FBQyxDQUFBO1FBQ3BGLE1BQU0sQ0FBQyxhQUFhLENBQUE7SUFDeEIsQ0FBQztJQUVEOztPQUVHO0lBQ0ssdUJBQXVCO1FBQzNCLElBQUksQ0FBQyxrQkFBa0IsR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyxjQUFjLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQyxDQUFBO0lBQ2xGLENBQUM7SUFFRDs7T0FFRztJQUNLLGVBQWU7UUFDbkIsRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUM7WUFDWCxJQUFJLENBQUMsVUFBVSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxHQUFHLEVBQUUsZUFBZSxDQUFDLENBQUE7UUFDbEUsQ0FBQztRQUFDLElBQUksQ0FBQyxDQUFDO1lBQ0osSUFBSSxDQUFDLFVBQVUsR0FBRyxLQUFLLENBQUMsVUFBVSxDQUFBO1FBQ3RDLENBQUM7UUFBQSxDQUFDO0lBQ04sQ0FBQztJQUVEOztPQUVHO0lBQ0sscUJBQXFCO1FBQ3pCLEVBQUUsQ0FBQyxDQUFDLElBQUksQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDLENBQUM7WUFDMUIsSUFBSSxDQUFDLGdCQUFnQixHQUFHLE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLFlBQVksQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLENBQUE7UUFDOUUsQ0FBQztJQUNMLENBQUM7Q0FFSjtBQTdERCw0QkE2REMifQ==
|
|
3
dist/npmextra.paths.d.ts
vendored
3
dist/npmextra.paths.d.ts
vendored
@ -1,3 +0,0 @@
|
|||||||
export declare let cwd: string;
|
|
||||||
export declare let packageDir: string;
|
|
||||||
export declare let configFile: string;
|
|
8
dist/npmextra.paths.js
vendored
8
dist/npmextra.paths.js
vendored
@ -1,8 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
const plugins = require("./npmextra.plugins");
|
|
||||||
// directories
|
|
||||||
exports.cwd = process.cwd();
|
|
||||||
exports.packageDir = plugins.path.join(__dirname, '../');
|
|
||||||
// files
|
|
||||||
exports.configFile = plugins.path.join(exports.cwd, 'npmextra.json');
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZXh0cmEucGF0aHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9ucG1leHRyYS5wYXRocy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsOENBQTZDO0FBRTdDLGNBQWM7QUFDSCxRQUFBLEdBQUcsR0FBRyxPQUFPLENBQUMsR0FBRyxFQUFFLENBQUE7QUFDbkIsUUFBQSxVQUFVLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFDLEtBQUssQ0FBQyxDQUFBO0FBRTFELFFBQVE7QUFDRyxRQUFBLFVBQVUsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFHLEVBQUMsZUFBZSxDQUFDLENBQUEifQ==
|
|
6
dist/npmextra.plugins.d.ts
vendored
6
dist/npmextra.plugins.d.ts
vendored
@ -1,6 +0,0 @@
|
|||||||
import 'typings-global';
|
|
||||||
export import beautylog = require('beautylog');
|
|
||||||
export import lodash = require('lodash');
|
|
||||||
export import path = require('path');
|
|
||||||
export import smartfile = require('smartfile');
|
|
||||||
export import q = require('q');
|
|
8
dist/npmextra.plugins.js
vendored
8
dist/npmextra.plugins.js
vendored
@ -1,8 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-global");
|
|
||||||
exports.beautylog = require("beautylog");
|
|
||||||
exports.lodash = require("lodash");
|
|
||||||
exports.path = require("path");
|
|
||||||
exports.smartfile = require("smartfile");
|
|
||||||
exports.q = require("q");
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZXh0cmEucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWV4dHJhLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUN2Qix5Q0FBOEM7QUFDOUMsbUNBQXdDO0FBQ3hDLCtCQUFvQztBQUNwQyx5Q0FBOEM7QUFDOUMseUJBQThCIn0=
|
|
22
npmextra.json
Normal file
22
npmextra.json
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"npmci": {
|
||||||
|
"globalNpmTools": [],
|
||||||
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"npmts": {
|
||||||
|
"testConfig": {
|
||||||
|
"parallel": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "pushrocks",
|
||||||
|
"gitrepo": "npmextra",
|
||||||
|
"shortDescription": "do more with npm",
|
||||||
|
"npmPackagename": "@pushrocks/npmextra",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11183
package-lock.json
generated
Normal file
11183
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
50
package.json
50
package.json
@ -1,11 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "npmextra",
|
"name": "@pushrocks/npmextra",
|
||||||
"version": "2.0.0",
|
"version": "3.0.8",
|
||||||
|
"private": false,
|
||||||
"description": "do more with npm",
|
"description": "do more with npm",
|
||||||
"main": "dist/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)"
|
"test": "(tstest test/)",
|
||||||
|
"build": "(tsbuild)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -18,16 +20,34 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/npmextra#README",
|
"homepage": "https://gitlab.com/pushrocks/npmextra#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/q": "^0.x.x",
|
"@pushrocks/smartfile": "^8.0.8",
|
||||||
"beautylog": "^5.0.23",
|
"@pushrocks/smartlog": "^2.0.39",
|
||||||
"lodash": "^4.16.1",
|
"@pushrocks/smartpath": "^4.0.3",
|
||||||
"q": "^1.4.1",
|
"@pushrocks/smartpromise": "^3.1.3",
|
||||||
"smartfile": "^4.0.20",
|
"@pushrocks/taskbuffer": "^2.1.13"
|
||||||
"typings-global": "^1.0.14"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/should": "^8.1.30",
|
"@gitzone/tsbuild": "^2.1.25",
|
||||||
"should": "^11.1.0",
|
"@gitzone/tsrun": "^1.2.12",
|
||||||
"typings-test": "^1.0.3"
|
"@gitzone/tstest": "^1.0.52",
|
||||||
}
|
"@pushrocks/tapbundle": "^3.2.10",
|
||||||
|
"@types/node": "^14.14.22",
|
||||||
|
"tslint": "^6.1.3",
|
||||||
|
"tslint-config-prettier": "^1.18.0"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
1
test/test.d.ts
vendored
1
test/test.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
import 'typings-test';
|
|
27
test/test.js
27
test/test.js
@ -1,27 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-test");
|
|
||||||
const should = require("should");
|
|
||||||
const npmExtra = require("../dist/index");
|
|
||||||
let testNpmextra;
|
|
||||||
describe('npmextra', function () {
|
|
||||||
it('should create a new Npmtextra instance', function () {
|
|
||||||
testNpmextra = new npmExtra.Npmextra('./test/');
|
|
||||||
should(testNpmextra).be.instanceof(npmExtra.Npmextra);
|
|
||||||
});
|
|
||||||
it('should state wether a npmextra.json exists', function () {
|
|
||||||
should(testNpmextra.npmextraJsonExists).be.true();
|
|
||||||
});
|
|
||||||
it('should pass through default value, if not overriden by config from file', function () {
|
|
||||||
let testData = testNpmextra.dataFor('testTool', { someKey2: 'someValue2' });
|
|
||||||
console.log(testData);
|
|
||||||
should(testData).have.ownProperty('someKey2');
|
|
||||||
});
|
|
||||||
it('should read a config file', function () {
|
|
||||||
let testData = testNpmextra.dataFor('testTool', {
|
|
||||||
someKey2: 'someValue2'
|
|
||||||
});
|
|
||||||
should(testData).have.ownProperty('someKey2');
|
|
||||||
should(testData.testValue).equal(2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUVyQixpQ0FBZ0M7QUFFaEMsMENBQTBDO0FBRTFDLElBQUksWUFBK0IsQ0FBQTtBQUVuQyxRQUFRLENBQUMsVUFBVSxFQUFDO0lBQ2hCLEVBQUUsQ0FBQyx3Q0FBd0MsRUFBRTtRQUN6QyxZQUFZLEdBQUcsSUFBSSxRQUFRLENBQUMsUUFBUSxDQUFDLFNBQVMsQ0FBQyxDQUFBO1FBQy9DLE1BQU0sQ0FBQyxZQUFZLENBQUMsQ0FBQyxFQUFFLENBQUMsVUFBVSxDQUFDLFFBQVEsQ0FBQyxRQUFRLENBQUMsQ0FBQTtJQUN6RCxDQUFDLENBQUMsQ0FBQTtJQUNGLEVBQUUsQ0FBQyw0Q0FBNEMsRUFBRTtRQUM3QyxNQUFNLENBQUMsWUFBWSxDQUFDLGtCQUFrQixDQUFDLENBQUMsRUFBRSxDQUFDLElBQUksRUFBRSxDQUFBO0lBQ3JELENBQUMsQ0FBQyxDQUFBO0lBQ0YsRUFBRSxDQUFDLHlFQUF5RSxFQUFDO1FBQ3pFLElBQUksUUFBUSxHQUFHLFlBQVksQ0FBQyxPQUFPLENBQUMsVUFBVSxFQUFFLEVBQUMsUUFBUSxFQUFFLFlBQVksRUFBQyxDQUFDLENBQUE7UUFDekUsT0FBTyxDQUFDLEdBQUcsQ0FBQyxRQUFRLENBQUMsQ0FBQTtRQUNyQixNQUFNLENBQUMsUUFBUSxDQUFDLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxVQUFVLENBQUMsQ0FBQTtJQUNqRCxDQUFDLENBQUMsQ0FBQTtJQUNGLEVBQUUsQ0FBQywyQkFBMkIsRUFBQztRQUMzQixJQUFJLFFBQVEsR0FBRyxZQUFZLENBQUMsT0FBTyxDQUMvQixVQUFVLEVBQ1Y7WUFDSSxRQUFRLEVBQUUsWUFBWTtTQUN6QixDQUNKLENBQUE7UUFDRCxNQUFNLENBQUMsUUFBUSxDQUFDLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxVQUFVLENBQUMsQ0FBQTtRQUM3QyxNQUFNLENBQUMsUUFBUSxDQUFDLFNBQVMsQ0FBQyxDQUFDLEtBQUssQ0FBQyxDQUFDLENBQUMsQ0FBQTtJQUN2QyxDQUFDLENBQUMsQ0FBQTtBQUNOLENBQUMsQ0FBQyxDQUFBIn0=
|
|
25
test/test.kvstore.ts
Normal file
25
test/test.kvstore.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
|
|
||||||
|
import * as npmextra from '../ts/index';
|
||||||
|
|
||||||
|
let myKeyValueStore: npmextra.KeyValueStore;
|
||||||
|
|
||||||
|
tap.test('should create a keyValueStore', async () => {
|
||||||
|
myKeyValueStore = new npmextra.KeyValueStore('custom', 'test');
|
||||||
|
expect(myKeyValueStore).to.be.instanceof(npmextra.KeyValueStore);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('expect result to be empty', async () => {
|
||||||
|
let result = myKeyValueStore.readAll();
|
||||||
|
// tslint:disable-next-line:no-unused-expression
|
||||||
|
expect(result).to.be.empty;
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('expect to add an object to the kv Store', async () => {
|
||||||
|
await myKeyValueStore.writeAll({
|
||||||
|
myKey: 'myValue',
|
||||||
|
});
|
||||||
|
await expect(myKeyValueStore.readKey('myKey')).to.eventually.equal('myValue');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
59
test/test.ts
59
test/test.ts
@ -1,32 +1,33 @@
|
|||||||
import 'typings-test'
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
import path = require('path')
|
import path = require('path');
|
||||||
import * as should from 'should'
|
|
||||||
|
|
||||||
import npmExtra = require('../dist/index')
|
// module to test
|
||||||
|
import npmExtra = require('../ts/index');
|
||||||
|
|
||||||
let testNpmextra: npmExtra.Npmextra
|
let testNpmextra: npmExtra.Npmextra;
|
||||||
|
|
||||||
describe('npmextra',function(){
|
tap.test('should create a new Npmtextra instance', async () => {
|
||||||
it('should create a new Npmtextra instance', function(){
|
testNpmextra = new npmExtra.Npmextra('./test/');
|
||||||
testNpmextra = new npmExtra.Npmextra('./test/')
|
expect(testNpmextra).be.instanceof(npmExtra.Npmextra);
|
||||||
should(testNpmextra).be.instanceof(npmExtra.Npmextra)
|
});
|
||||||
})
|
|
||||||
it('should state wether a npmextra.json exists', function() {
|
tap.test('should state wether a npmextra.json exists', async () => {
|
||||||
should(testNpmextra.npmextraJsonExists).be.true()
|
// tslint:disable-next-line:no-unused-expression
|
||||||
})
|
expect(testNpmextra.npmextraJsonExists).be.true;
|
||||||
it('should pass through default value, if not overriden by config from file',function(){
|
});
|
||||||
let testData = testNpmextra.dataFor('testTool', {someKey2: 'someValue2'})
|
|
||||||
console.log(testData)
|
tap.test('should pass through default value, if not overriden by config from file', async () => {
|
||||||
should(testData).have.ownProperty('someKey2')
|
let testData = testNpmextra.dataFor('testTool', { someKey2: 'someValue2' });
|
||||||
})
|
console.log(testData);
|
||||||
it('should read a config file',function(){
|
expect(testData).have.ownProperty('someKey2');
|
||||||
let testData = testNpmextra.dataFor(
|
});
|
||||||
'testTool',
|
|
||||||
{
|
tap.test('should read a config file', async () => {
|
||||||
someKey2: 'someValue2'
|
let testData = testNpmextra.dataFor<any>('testTool', {
|
||||||
}
|
someKey2: 'someValue2',
|
||||||
)
|
});
|
||||||
should(testData).have.ownProperty('someKey2')
|
expect(testData).have.ownProperty('someKey2');
|
||||||
should(testData.testValue).equal(2)
|
expect(testData.testValue).equal(2);
|
||||||
})
|
});
|
||||||
})
|
|
||||||
|
tap.start();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './npmextra.plugins'
|
import * as plugins from './npmextra.plugins';
|
||||||
|
|
||||||
export * from './npmextra.classes.npmextra'
|
export * from './npmextra.classes.npmextra';
|
||||||
export * from './npmextra.classes.keyvaluestore'
|
export * from './npmextra.classes.keyvaluestore';
|
||||||
|
@ -1,33 +1,112 @@
|
|||||||
import * as plugins from './npmextra.plugins'
|
import * as plugins from './npmextra.plugins';
|
||||||
|
import * as paths from './npmextra.paths';
|
||||||
export type keyValueStoreTypes = 'path' | 'gitProject'
|
|
||||||
|
|
||||||
|
import { Task } from '@pushrocks/taskbuffer';
|
||||||
|
|
||||||
|
export type TKeyValueStore = 'path' | 'gitProject' | 'custom';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* kvStore is a simple key vlaue store to store data about projects between runs
|
||||||
|
*/
|
||||||
export class KeyValueStore {
|
export class KeyValueStore {
|
||||||
constructor(optionsArg: {
|
private dataObject: any = {};
|
||||||
type: keyValueStoreTypes
|
private deletedObject: any = {};
|
||||||
}) {
|
public syncTask = new Task({
|
||||||
|
name: 'syncTask',
|
||||||
|
buffered: true,
|
||||||
|
bufferMax: 1,
|
||||||
|
execDelay: 0,
|
||||||
|
taskFunction: async () => {
|
||||||
|
this.dataObject = {
|
||||||
|
...plugins.smartfile.fs.toObjectSync(this.filePath),
|
||||||
|
...this.dataObject,
|
||||||
|
};
|
||||||
|
for (const key of Object.keys(this.deletedObject)) {
|
||||||
|
delete this.dataObject[key];
|
||||||
|
}
|
||||||
|
this.deletedObject = {};
|
||||||
|
await plugins.smartfile.memory.toFs(JSON.stringify(this.dataObject), this.filePath);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
/**
|
||||||
|
* computes the identity
|
||||||
|
*/
|
||||||
|
private initFilePath = () => {
|
||||||
|
// determine the right base directory
|
||||||
|
let baseDir: string;
|
||||||
|
if (this.type === 'custom') {
|
||||||
|
baseDir = paths.kvCustomDir;
|
||||||
|
} else if (this.type === 'gitProject') {
|
||||||
|
baseDir = paths.kvGitDir;
|
||||||
|
} else if (this.type === 'path') {
|
||||||
|
baseDir = paths.kvPathDir;
|
||||||
}
|
}
|
||||||
/**
|
this.filePath = plugins.path.join(baseDir, this.identity + '.json');
|
||||||
* reads a keyValueFile from disk
|
plugins.smartfile.fs.ensureDirSync(paths.kvCustomDir);
|
||||||
*/
|
plugins.smartfile.fs.ensureDirSync(paths.kvGitDir);
|
||||||
let kvRead () {
|
plugins.smartfile.fs.ensureDirSync(paths.kvPathDir);
|
||||||
|
plugins.smartfile.fs.ensureFileSync(this.filePath, '{}');
|
||||||
|
};
|
||||||
|
|
||||||
}
|
public type: TKeyValueStore; // the type of the kvStore
|
||||||
|
public identity: string; // the identity of the kvStore
|
||||||
/**
|
public filePath: string; // the filePath of the kvStore
|
||||||
* writes a key value file to disk
|
|
||||||
*/
|
/**
|
||||||
let kvWrite () {
|
* the constructor of keyvalue store
|
||||||
|
* @param typeArg
|
||||||
}
|
* @param customStringArg
|
||||||
|
*/
|
||||||
/**
|
constructor(typeArg: TKeyValueStore, customStringArg: string) {
|
||||||
* wipes a key value store from disk
|
// set kvStoreType
|
||||||
*/
|
this.type = typeArg;
|
||||||
let kevWipe () {
|
this.identity = customStringArg;
|
||||||
|
this.initFilePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* reads all keyValue pairs at once and returns them
|
||||||
|
*/
|
||||||
|
public async readAll() {
|
||||||
|
await this.syncTask.trigger();
|
||||||
|
return this.dataObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* reads a keyValueFile from disk
|
||||||
|
*/
|
||||||
|
public async readKey(keyArg: string) {
|
||||||
|
await this.syncTask.trigger();
|
||||||
|
return this.dataObject[keyArg];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* writes a specific key to the keyValueStore
|
||||||
|
*/
|
||||||
|
public async writeKey(keyArg: string, valueArg: any) {
|
||||||
|
await this.writeAll({
|
||||||
|
[keyArg]: valueArg,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public async deleteKey(keyArg: string) {
|
||||||
|
this.deletedObject[keyArg] = this.dataObject[keyArg];
|
||||||
|
await this.syncTask.trigger();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* writes all keyValue pairs in the object argument
|
||||||
|
*/
|
||||||
|
public async writeAll(keyValueObject) {
|
||||||
|
this.dataObject = { ...this.dataObject, ...keyValueObject };
|
||||||
|
await this.syncTask.trigger();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wipes a key value store from disk
|
||||||
|
*/
|
||||||
|
public async wipe() {
|
||||||
|
this.dataObject = {};
|
||||||
|
await plugins.smartfile.fs.remove(this.filePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,68 +1,72 @@
|
|||||||
import * as plugins from './npmextra.plugins'
|
import * as plugins from './npmextra.plugins';
|
||||||
import * as paths from './npmextra.paths'
|
import * as paths from './npmextra.paths';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Npmextra class allows easy configuration of tools
|
* Npmextra class allows easy configuration of tools
|
||||||
*/
|
*/
|
||||||
export class Npmextra {
|
export class Npmextra {
|
||||||
cwd: string
|
cwd: string;
|
||||||
lookupPath: string
|
lookupPath: string;
|
||||||
npmextraJsonExists: boolean
|
npmextraJsonExists: boolean;
|
||||||
npmextraJsonData: boolean
|
npmextraJsonData: any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates instance of Npmextra
|
* creates instance of Npmextra
|
||||||
*/
|
*/
|
||||||
constructor(cwdArg?: string) {
|
constructor(cwdArg?: string) {
|
||||||
if (cwdArg) {
|
if (cwdArg) {
|
||||||
this.cwd = cwdArg
|
this.cwd = cwdArg;
|
||||||
} else {
|
} else {
|
||||||
this.cwd = paths.cwd
|
this.cwd = paths.cwd;
|
||||||
}
|
|
||||||
this.checkLookupPath()
|
|
||||||
this.checkNpmextraJsonExists()
|
|
||||||
this.checkNpmextraJsonData()
|
|
||||||
}
|
}
|
||||||
|
this.checkLookupPath();
|
||||||
|
this.checkNpmextraJsonExists();
|
||||||
|
this.checkNpmextraJsonData();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* merges the supplied options with the ones from npmextra.json
|
* merges the supplied options with the ones from npmextra.json
|
||||||
*/
|
*/
|
||||||
dataFor(toolnameArg: string, defaultOptionsArg: any) {
|
dataFor<IToolConfig>(toolnameArg: string, defaultOptionsArg: any): IToolConfig {
|
||||||
let npmextraToolOptions
|
let npmextraToolOptions;
|
||||||
if(this.npmextraJsonData[toolnameArg]) {
|
if (this.npmextraJsonData[toolnameArg]) {
|
||||||
npmextraToolOptions = this.npmextraJsonData[toolnameArg]
|
npmextraToolOptions = this.npmextraJsonData[toolnameArg];
|
||||||
} else {
|
} else {
|
||||||
npmextraToolOptions = {}
|
npmextraToolOptions = {};
|
||||||
}
|
|
||||||
let mergedOptions = plugins.lodash.merge({}, defaultOptionsArg, npmextraToolOptions)
|
|
||||||
return mergedOptions
|
|
||||||
}
|
}
|
||||||
|
let mergedOptions = {
|
||||||
|
...defaultOptionsArg,
|
||||||
|
...npmextraToolOptions,
|
||||||
|
};
|
||||||
|
return mergedOptions;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks if the JSON exists
|
* checks if the JSON exists
|
||||||
*/
|
*/
|
||||||
private checkNpmextraJsonExists() {
|
private checkNpmextraJsonExists() {
|
||||||
this.npmextraJsonExists = plugins.smartfile.fs.fileExistsSync(this.lookupPath)
|
this.npmextraJsonExists = plugins.smartfile.fs.fileExistsSync(this.lookupPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets lookupPath
|
||||||
|
*/
|
||||||
|
private checkLookupPath() {
|
||||||
|
if (this.cwd) {
|
||||||
|
this.lookupPath = plugins.path.join(this.cwd, 'npmextra.json');
|
||||||
|
} else {
|
||||||
|
this.lookupPath = paths.configFile;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets lookupPath
|
* get npmextraJsonData
|
||||||
*/
|
*/
|
||||||
private checkLookupPath() {
|
private checkNpmextraJsonData() {
|
||||||
if (this.cwd) {
|
if (this.npmextraJsonExists) {
|
||||||
this.lookupPath = plugins.path.join(this.cwd, 'npmextra.json')
|
this.npmextraJsonData = plugins.smartfile.fs.toObjectSync(this.lookupPath);
|
||||||
} else {
|
} else {
|
||||||
this.lookupPath = paths.configFile
|
this.npmextraJsonData = {};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* get npmextraJsonData
|
|
||||||
*/
|
|
||||||
private checkNpmextraJsonData() {
|
|
||||||
if (this.npmextraJsonExists) {
|
|
||||||
this.npmextraJsonData = plugins.smartfile.fs.toObjectSync(this.lookupPath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,34 @@
|
|||||||
import * as plugins from './npmextra.plugins'
|
import * as plugins from './npmextra.plugins';
|
||||||
|
|
||||||
// directories
|
// directories
|
||||||
export let cwd = process.cwd()
|
export let cwd = process.cwd();
|
||||||
export let packageDir = plugins.path.join(__dirname,'../')
|
export let packageDir = plugins.path.join(__dirname, '../');
|
||||||
|
|
||||||
|
// ----------------------
|
||||||
|
// keyValueStore specific
|
||||||
|
// ----------------------
|
||||||
|
|
||||||
|
export let home = plugins.smartpath.get.home();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* keyValue base path
|
||||||
|
*/
|
||||||
|
export let kvBase = plugins.path.join(home, '.npmextra/kv');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the base directory for custom string based key value store
|
||||||
|
*/
|
||||||
|
export let kvCustomDir = plugins.path.join(kvBase, 'custom');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the subdir for git based keyValue
|
||||||
|
*/
|
||||||
|
export let kvGitDir = plugins.path.join(kvBase, 'git');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* keyValue for path based keyValue store
|
||||||
|
*/
|
||||||
|
export let kvPathDir = plugins.path.join(kvBase, 'path');
|
||||||
|
|
||||||
// files
|
// files
|
||||||
export let configFile = plugins.path.join(cwd,'npmextra.json')
|
export let configFile = plugins.path.join(cwd, 'npmextra.json');
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import 'typings-global'
|
import * as beautylog from '@pushrocks/smartlog';
|
||||||
export import beautylog = require('beautylog')
|
import * as path from 'path';
|
||||||
export import lodash = require('lodash')
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
export import path = require('path')
|
import * as smartpath from '@pushrocks/smartpath';
|
||||||
export import smartfile = require('smartfile')
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
export import q = require('q')
|
import * as taskbuffer from '@pushrocks/taskbuffer';
|
||||||
|
|
||||||
|
export { beautylog, path, smartfile, smartpath, smartpromise, taskbuffer };
|
||||||
|
18
tslint.json
18
tslint.json
@ -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"
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user