now adheres to standard js

This commit is contained in:
Philipp Kunz 2016-09-16 22:28:38 +02:00
parent febc3aa164
commit 3b83cfaaac
14 changed files with 196 additions and 97 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
node_modules/
coverage/
docs/
pages/
public/

View File

@ -1,15 +1,47 @@
# npmextra
do more with npm
do more with npm.
npmextra is a hub for a series of js tools that help writing, documenting and maintaining npm modules.
## Availabililty
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/npmpage)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/npmpage)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/npmpage)
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/npmpage/gitbook)
## Status for master
[![build status](https://gitlab.com/pushrocks/npmpage/badges/master/build.svg)](https://gitlab.com/pushrocks/npmpage/commits/master)
[![coverage report](https://gitlab.com/pushrocks/npmpage/badges/master/coverage.svg)](https://gitlab.com/pushrocks/npmpage/commits/master)
[![Dependency Status](https://david-dm.org/pushrocks/npmpage.svg)](https://david-dm.org/pushrocks/npmpage)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/npmpage/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/npmpage/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/npmpage/badges/code.svg)](https://www.bithound.io/github/pushrocks/npmpage)
[![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/)
## Usage
The main purpose of npmextra is to configure different tools using one npmextra.json. This way complex setups avaoid complexity through many configuration files.
```typescript
let npmextra = require("npmextra");
npmextra.dataFor({
toolName:"sometool",
});
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
})
```
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)

13
dist/index.d.ts vendored
View File

@ -3,5 +3,14 @@ export interface IDataFor {
defaultSettings?: any;
cwd?: string;
}
export declare let dataFor: (optionsArg: IDataFor) => any;
export declare let configFilePresent: () => boolean;
/**
* gets you the configuration data for
* @executes SYNC
*/
export declare let dataFor: <IOptions>(optionsArg: IDataFor) => IOptions;
/**
* tells you if a configfile is present
*/
export declare let configFilePresent: (optionsArg: {
cwd?: string;
}) => boolean;

31
dist/index.js vendored
View File

@ -1,10 +1,14 @@
"use strict";
const plugins = require("./npmextra.plugins");
const paths = require("./npmextra.paths");
const plugins = require('./npmextra.plugins');
const paths = require('./npmextra.paths');
/**
* gets you the configuration data for
* @executes SYNC
*/
exports.dataFor = (optionsArg) => {
// handle default settings
if (typeof optionsArg.toolName != undefined
&& typeof optionsArg.defaultSettings != undefined) {
if (typeof optionsArg.toolName !== undefined
&& typeof optionsArg.defaultSettings !== undefined) {
let newDefaultOptions = {};
newDefaultOptions[optionsArg.toolName] = optionsArg.defaultSettings;
optionsArg.defaultSettings = newDefaultOptions;
@ -13,7 +17,7 @@ exports.dataFor = (optionsArg) => {
// set lookup path
let lookupPath;
if (optionsArg.cwd) {
lookupPath = plugins.path.join(optionsArg.cwd, "npmextra.json");
lookupPath = plugins.path.join(optionsArg.cwd, 'npmextra.json');
}
else {
lookupPath = paths.configFile;
@ -44,7 +48,18 @@ exports.dataFor = (optionsArg) => {
return allData;
}
};
exports.configFilePresent = () => {
return plugins.smartfile.fs.fileExistsSync(paths.configFile);
/**
* tells you if a configfile is present
*/
exports.configFilePresent = (optionsArg) => {
let lookupPath;
if (optionsArg.cwd) {
lookupPath = plugins.path.join(optionsArg.cwd, 'npmextra.json');
}
else {
lookupPath = paths.configFile;
}
;
return plugins.smartfile.fs.fileExistsSync(lookupPath);
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsTUFBWSxPQUFPLFdBQU0sb0JBQ3pCLENBQUMsQ0FENEM7QUFDN0MsTUFBWSxLQUFLLFdBQU0sa0JBQWtCLENBQUMsQ0FBQTtBQVEvQixlQUFPLEdBQUcsQ0FBQyxVQUFtQjtJQUVyQywwQkFBMEI7SUFDMUIsRUFBRSxDQUFBLENBQ0UsT0FBTyxVQUFVLENBQUMsUUFBUSxJQUFJLFNBQVM7V0FDcEMsT0FBTyxVQUFVLENBQUMsZUFBZSxJQUFJLFNBQzVDLENBQUMsQ0FBQSxDQUFDO1FBQ0UsSUFBSSxpQkFBaUIsR0FBRyxFQUFFLENBQUM7UUFDM0IsaUJBQWlCLENBQUMsVUFBVSxDQUFDLFFBQVEsQ0FBQyxHQUFHLFVBQVUsQ0FBQyxlQUFlLENBQUM7UUFDcEUsVUFBVSxDQUFDLGVBQWUsR0FBRyxpQkFBaUIsQ0FBQztJQUNuRCxDQUFDO0lBQUEsQ0FBQztJQUVGLGtCQUFrQjtJQUNsQixJQUFJLFVBQWlCLENBQUM7SUFDdEIsRUFBRSxDQUFBLENBQUMsVUFBVSxDQUFDLEdBQUcsQ0FBQyxDQUFBLENBQUM7UUFDZixVQUFVLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLEdBQUcsRUFBQyxlQUFlLENBQUMsQ0FBQztJQUNuRSxDQUFDO0lBQUMsSUFBSSxDQUFDLENBQU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Q0FBQTtRQUN2QyxDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDSixPQUFPLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyx3QkFBd0IsVUFBVSxDQUFDLFFBQVEsRUFBRSxDQUFDLENBQUE7WUFDdEUsTUFBTSxDQUFDLFNBQVMsQ0FBQTtRQUNwQixDQUFDO0lBQ0wsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ0osTUFBTSxDQUFDLE9BQU8sQ0FBQTtJQUNsQixDQUFDO0FBQ0wsQ0FBQyxDQUFBO0FBRUQ7O0dBRUc7QUFDUSx5QkFBaUIsR0FBRyxDQUFDLFVBQTBCO0lBQ3RELElBQUksVUFBa0IsQ0FBQTtJQUN0QixFQUFFLENBQUMsQ0FBQyxVQUFVLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQztRQUNqQixVQUFVLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDLEdBQUcsRUFBQyxlQUFlLENBQUMsQ0FBQTtJQUNsRSxDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDSixVQUFVLEdBQUcsS0FBSyxDQUFDLFVBQVUsQ0FBQTtJQUNqQyxDQUFDO0lBQUEsQ0FBQztJQUNGLE1BQU0sQ0FBQyxPQUFPLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyxjQUFjLENBQUMsVUFBVSxDQUFDLENBQUE7QUFDMUQsQ0FBQyxDQUFBIn0=

View File

@ -0,0 +1,6 @@
export declare type keyValueStoreTypes = 'path' | 'gitProject';
export declare class KeyValueStore {
constructor(optionsArg: {
type: keyValueStoreTypes;
});
}

22
dist/npmextra.classes.keyValueStore.js vendored Normal file
View File

@ -0,0 +1,22 @@
"use strict";
/**
* 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 = () => {
};
class KeyValueStore {
constructor(optionsArg) {
}
}
exports.KeyValueStore = KeyValueStore;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZXh0cmEuY2xhc3Nlcy5rZXlWYWx1ZVN0b3JlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtZXh0cmEuY2xhc3Nlcy5rZXlWYWx1ZVN0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFJQTs7R0FFRztBQUNILElBQUksTUFBTSxHQUFHO0FBRWIsQ0FBQyxDQUFBO0FBRUQ7O0dBRUc7QUFDSCxJQUFJLE9BQU8sR0FBRztBQUVkLENBQUMsQ0FBQTtBQUVEOztHQUVHO0FBQ0gsSUFBSSxPQUFPLEdBQUc7QUFFZCxDQUFDLENBQUE7QUFFRDtJQUNJLFlBQVksVUFFWDtJQUVELENBQUM7QUFDTCxDQUFDO0FBTlkscUJBQWEsZ0JBTXpCLENBQUEifQ==

View File

@ -1,8 +1,8 @@
"use strict";
const plugins = require("./npmextra.plugins");
const plugins = require('./npmextra.plugins');
// directories
exports.cwd = process.cwd();
exports.packageDir = plugins.path.join(__dirname, "../");
//
exports.configFile = plugins.path.join(exports.cwd, "npmextra.json");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZXh0cmEucGF0aHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9ucG1leHRyYS5wYXRocy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsTUFBWSxPQUFPLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUU5QyxjQUFjO0FBQ0gsV0FBRyxHQUFHLE9BQU8sQ0FBQyxHQUFHLEVBQUUsQ0FBQztBQUNwQixrQkFBVSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFNBQVMsRUFBQyxLQUFLLENBQUMsQ0FBQztBQUUzRCxFQUFFO0FBQ1Msa0JBQVUsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFHLEVBQUMsZUFBZSxDQUFDLENBQUMifQ==
exports.packageDir = plugins.path.join(__dirname, '../');
// files
exports.configFile = plugins.path.join(exports.cwd, 'npmextra.json');
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZXh0cmEucGF0aHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9ucG1leHRyYS5wYXRocy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsTUFBWSxPQUFPLFdBQU0sb0JBR3pCLENBQUMsQ0FINEM7QUFFN0MsY0FBYztBQUNILFdBQUcsR0FBRyxPQUFPLENBQUMsR0FBRyxFQUFFLENBQUE7QUFDbkIsa0JBQVUsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLEVBQUMsS0FBSyxDQUFDLENBQUE7QUFFMUQsUUFBUTtBQUNHLGtCQUFVLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsV0FBRyxFQUFDLGVBQWUsQ0FBQyxDQUFBIn0=

View File

@ -1,6 +1,6 @@
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");
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');

View File

@ -1,8 +1,8 @@
"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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZXh0cmEucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWV4dHJhLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUNWLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDakMsY0FBTSxXQUFXLFFBQVEsQ0FBQyxDQUFDO0FBQzNCLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUN2QixpQkFBUyxXQUFXLFdBQVcsQ0FBQyxDQUFDO0FBQ2pDLFNBQUMsV0FBVyxHQUFHLENBQUMsQ0FBQyJ9
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZXh0cmEucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWV4dHJhLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQ1AsQ0FBQyxDQURzQjtBQUNULGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUE7QUFDaEMsY0FBTSxXQUFXLFFBQVEsQ0FBQyxDQUFBO0FBQzFCLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQTtBQUN0QixpQkFBUyxXQUFXLFdBQVcsQ0FBQyxDQUFBO0FBQ2hDLFNBQUMsV0FBVyxHQUFHLENBQUMsQ0FBQSJ9

View File

@ -1,55 +1,68 @@
import * as plugins from "./npmextra.plugins"
import * as paths from "./npmextra.paths";
import * as plugins from './npmextra.plugins'
import * as paths from './npmextra.paths'
export interface IDataFor {
toolName:string;
defaultSettings?;
toolName: string
defaultSettings?
cwd?: string
}
export let dataFor = (optionsArg:IDataFor) => {
/**
* gets you the configuration data for
* @executes SYNC
*/
export let dataFor = <IOptions>(optionsArg: IDataFor): IOptions => {
// handle default settings
if (
typeof optionsArg.toolName != undefined
&& typeof optionsArg.defaultSettings != undefined
typeof optionsArg.toolName !== undefined
&& typeof optionsArg.defaultSettings !== undefined
) {
let newDefaultOptions = {};
newDefaultOptions[optionsArg.toolName] = optionsArg.defaultSettings;
optionsArg.defaultSettings = newDefaultOptions;
let newDefaultOptions = {}
newDefaultOptions[optionsArg.toolName] = optionsArg.defaultSettings
optionsArg.defaultSettings = newDefaultOptions
};
// set lookup path
let lookupPath:string;
let lookupPath: string
if (optionsArg.cwd) {
lookupPath = plugins.path.join(optionsArg.cwd,"npmextra.json");
lookupPath = plugins.path.join(optionsArg.cwd,'npmextra.json')
} else {
lookupPath = paths.configFile;
lookupPath = paths.configFile
};
// get allData
let allData;
let allData
if (plugins.smartfile.fs.fileExistsSync(lookupPath)) {
allData = plugins.smartfile.fs.toObjectSync(lookupPath);
allData = plugins.smartfile.fs.toObjectSync(lookupPath)
} else {
plugins.beautylog.warn(`${lookupPath} is missing!`);
allData = {};
plugins.beautylog.warn(`${lookupPath} is missing!`)
allData = {}
};
// assign all data
allData = plugins.lodash.merge({},optionsArg.defaultSettings,allData);
allData = plugins.lodash.merge({},optionsArg.defaultSettings,allData)
if (optionsArg.toolName) {
if (allData[optionsArg.toolName]) {
return allData[optionsArg.toolName];
return allData[optionsArg.toolName]
} else {
plugins.beautylog.error(`There is no data for ${optionsArg.toolName}`);
return undefined;
plugins.beautylog.error(`There is no data for ${optionsArg.toolName}`)
return undefined
}
} else {
return allData;
return allData
}
}
};
export let configFilePresent = ():boolean => {
return plugins.smartfile.fs.fileExistsSync(paths.configFile);
/**
* tells you if a configfile is present
*/
export let configFilePresent = (optionsArg: {cwd?: string}): boolean => {
let lookupPath: string
if (optionsArg.cwd) {
lookupPath = plugins.path.join(optionsArg.cwd,'npmextra.json')
} else {
lookupPath = paths.configFile
};
return plugins.smartfile.fs.fileExistsSync(lookupPath)
}

View File

@ -1,20 +1,20 @@
import * as plugins from "./npmextra.plugins";
import * as plugins from './npmextra.plugins'
type keyValueStoreTypes = "path" | "gitProject"
export type keyValueStoreTypes = 'path' | 'gitProject'
/**
* reads a keyValueFile from disk
*/
let kvRead = () => {
};
}
/**
* writes a key value file to disk
*/
let kvWrite = () => {
};
}
/**
* wipes a key value store from disk
@ -28,7 +28,5 @@ export class KeyValueStore {
type: keyValueStoreTypes
}) {
};
}
}

View File

@ -1,8 +1,8 @@
import * as plugins from "./npmextra.plugins";
import * as plugins from './npmextra.plugins'
// directories
export let cwd = process.cwd();
export let packageDir = plugins.path.join(__dirname,"../");
export let cwd = process.cwd()
export let packageDir = plugins.path.join(__dirname,'../')
//
export let configFile = plugins.path.join(cwd,"npmextra.json");
// files
export let configFile = plugins.path.join(cwd,'npmextra.json')

View File

@ -1,6 +1,6 @@
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");
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')

3
tslint.json Normal file
View File

@ -0,0 +1,3 @@
{
"extends": "tslint-config-standard"
}