fix(core): update

This commit is contained in:
Philipp Kunz 2020-06-03 11:13:50 +00:00
parent 668fd0998f
commit 15bdab9ba6
37 changed files with 11590 additions and 9044 deletions

24
.gitignore vendored
View File

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

View File

@ -1,118 +1,121 @@
# gitzone standard
image: hosttoday/ht-docker-node:npmci
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .yarn/
key: "$CI_BUILD_STAGE"
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- security
- test
- release
- trigger
- pages
- security
- test
- release
- metadata
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
- npmci git mirror
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
snyk:
audit:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci command yarn global add snyk
- npmci command yarn install --ignore-scripts
- npmci command snyk test
- 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
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
codequality:
stage: security
image: docker:stable
allow_failure: true
services:
- docker:stable-dind
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]
tags:
- docker
- priv
# ====================
# test stage
# ====================
testLEGACY:
testStable:
stage: test
script:
- npmci node install legacy
- npmci npm install
- npmci npm test
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
allow_failure: true
- lossless
- docker
- priv
testLTS:
testBuild:
stage: test
script:
- npmci node install lts
- npmci npm install
- npmci npm test
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
testSTABLE:
stage: test
script:
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
release:
stage: release
script:
- npmci node install stable
- npmci npm prepare
- npmci npm publish
- npmci node install stable
- npmci npm publish
only:
- tags
- tags
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
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: trigger
stage: metadata
script:
- npmci trigger
- npmci trigger
only:
- tags
- tags
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
stage: pages
stage: metadata
script:
- npmci command yarn global add npmpage
- npmci command npmpage
- 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:
@ -120,4 +123,5 @@ pages:
artifacts:
expire_in: 1 week
paths:
- public
- public
allow_failure: true

111
.snyk
View File

@ -1,111 +0,0 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
'npm:debug:20170905':
- node-pre-gyp > tar-pack > debug:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- smartchok > chokidar > fsevents > node-pre-gyp > tar-pack > debug:
reason: None given
expires: '2018-05-08T23:12:05.487Z'
'npm:tough-cookie:20170905':
- node-pre-gyp > request > tough-cookie:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- smartchok > chokidar > fsevents > node-pre-gyp > request > tough-cookie:
reason: None given
expires: '2018-05-08T23:12:05.487Z'
'npm:hoek:20180212':
- boom > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- cryptiles > boom > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- hawk > cryptiles > boom > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- node-pre-gyp > hawk > cryptiles > boom > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- smartchok > chokidar > fsevents > node-pre-gyp > hawk > cryptiles > boom > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- node-pre-gyp > request > hawk > cryptiles > boom > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- smartchok > chokidar > fsevents > node-pre-gyp > request > hawk > cryptiles > boom > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- hawk > boom > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- node-pre-gyp > hawk > boom > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- smartchok > chokidar > fsevents > node-pre-gyp > hawk > boom > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- node-pre-gyp > request > hawk > boom > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- smartchok > chokidar > fsevents > node-pre-gyp > request > hawk > boom > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- hawk > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- node-pre-gyp > hawk > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- smartchok > chokidar > fsevents > node-pre-gyp > hawk > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- node-pre-gyp > request > hawk > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- smartchok > chokidar > fsevents > node-pre-gyp > request > hawk > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- hawk > sntp > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- node-pre-gyp > hawk > sntp > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- smartchok > chokidar > fsevents > node-pre-gyp > hawk > sntp > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- node-pre-gyp > request > hawk > sntp > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
- smartchok > chokidar > fsevents > node-pre-gyp > request > hawk > sntp > hoek:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
'npm:shelljs:20140723':
- tapbuffer > smartshell > shelljs:
reason: None given
expires: '2018-05-08T23:10:17.169Z'
'npm:atob:20180429':
- gulp-sourcemaps > css > source-map-resolve > atob:
reason: None given
expires: '2018-06-02T10:44:49.656Z'
- gulp-sourcemaps > @gulp-sourcemaps/identity-map > css > source-map-resolve > atob:
reason: None given
expires: '2018-06-02T10:44:49.656Z'
'npm:deep-extend:20180409':
- smartchok > chokidar > fsevents > node-pre-gyp > rc > deep-extend:
reason: None given
expires: '2018-06-02T10:44:49.656Z'
- deep-extend:
reason: None given
expires: '2018-06-02T10:44:49.656Z'
- node-pre-gyp > rc > deep-extend:
reason: None given
expires: '2018-06-02T10:44:49.656Z'
'npm:sshpk:20180409':
- smartchok > chokidar > fsevents > node-pre-gyp > request > http-signature > sshpk:
reason: None given
expires: '2018-06-02T10:44:49.656Z'
patch: {}

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"]
}
}
}
}
}
}
]
}

View File

@ -1,3 +0,0 @@
#!/usr/bin/env node
process.env.CLI_CALL = 'true'
var index = require("../{{pathToIndex}}");

View File

@ -1,2 +0,0 @@
#!/usr/bin/env node
var index = require("../dist/index.js");

4
cli.js Normal file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env node
process.env.CLI_CALL = 'true';
const cliTool = require('./dist_ts/index');
cliTool.runCli();

5
cli.ts.js Normal file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env node
process.env.CLI_CALL = 'true';
require('@gitzone/tsrun');
const cliTool = require('./ts/index');
cliTool.runCli();

View File

@ -17,7 +17,7 @@ modules that use npmts in theis development workflow
### Tips and tricks:
* Use [npmts-g](https://www.npmjs.com/package/npmts-g) to use globally installed npmts and install npmts locally if no global npmts is available.
* Use [npmpage](https://www.npmjs.com/package/npmpage) to create a webpage from coverage reports and TypeDoc for the module
* Use [hosttoday/ht-docker-node:npmci](https://hub.docker.com/r/hosttoday/ht-docker-node/) for speedy CI builds
* Use [npmdocker](https://www.npmjs.com/package/npmdocker) for running tests consistently with docker.
- Use [npmts-g](https://www.npmjs.com/package/npmts-g) to use globally installed npmts and install npmts locally if no global npmts is available.
- Use [npmpage](https://www.npmjs.com/package/npmpage) to create a webpage from coverage reports and TypeDoc for the module
- Use [hosttoday/ht-docker-node:npmci](https://hub.docker.com/r/hosttoday/ht-docker-node/) for speedy CI builds
- Use [npmdocker](https://www.npmjs.com/package/npmdocker) for running tests consistently with docker.

View File

View File

@ -1,5 +1,16 @@
{
"npmci": {
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "gitzone",
"gitrepo": "tscoverage",
"shortDescription": "get coverage information for gitzone projects",
"npmPackagename": "@gitzone/tscoverage",
"license": "MIT"
}
}
}

11355
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,24 +1,15 @@
{
"name": "@gitzone/npmts",
"version": "8.0.38",
"description": "best practice npm TypeScript modules",
"main": "dist/index.js",
"name": "@gitzone/tscoverage",
"version": "1.0.1",
"description": "get coverage information for gitzone projects",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"bin": {
"npmts": "assets/cliNpmts.js"
"tscoverage": "cli.js"
},
"scripts": {
"test": "(npm run compile && npm run prepareTest && npm run setupCheck && npm run check && npm run checkVersion && npm run checkNoTest && npm run checkNoDocs)",
"build": "npm test",
"testShort": "(npm run compile && npm run check)",
"prepareTest": "(rm -rf test/)",
"compile": "(rm -rf dist/ && tsc)",
"setupCheck": "(git clone https://gitlab.com/sandboxzone/sandbox-npmts.git test/)",
"typedoc": "(typedoc --out ./pages/api --target ES6 ./ts/)",
"npmpage": "(npmpage)",
"check": "(cd test && yarn install && node ../dist/index.js)",
"checkVersion": "(cd test/ && node ../dist/index.js -v)",
"checkNoTest": "(cd test && node ../dist/index.js --notest)",
"checkNoDocs": "(cd test && node ../dist/index.js --nodocs)"
"test": "(tstest test/)",
"build": "(tsbuild --web)"
},
"repository": {
"type": "git",
@ -34,38 +25,26 @@
"url": "https://gitlab.com/gitzone/npmts/issues"
},
"homepage": "https://gitlab.com/gitzone/npmts#readme",
"dependencies": {
"@pushrocks/smartcli": "^3.0.1",
"@types/gulp-sourcemaps": "0.0.32",
"@types/minimatch": "^3.0.1",
"@types/through2": "^2.0.33",
"beautylog": "^6.1.10",
"depcheck": "^0.6.9",
"early": "^2.1.1",
"gulp-function": "^2.2.9",
"gulp-sourcemaps": "^2.6.1",
"gulp-typescript": "^4.0.2",
"lodash": "^4.17.10",
"npmextra": "^2.0.9",
"projectinfo": "^3.0.4",
"smartanalytics": "^2.0.9",
"smartchok": "1.0.14",
"smartcov": "^1.0.2",
"smarterror": "^1.0.3",
"smartfile": "^4.2.26",
"smartgulp": "^1.0.6",
"smartpath": "^3.2.8",
"smartq": "^1.1.8",
"smartstream": "^1.0.10",
"smartstring": "^2.0.28",
"smartsystem": "^2.0.2",
"smartupdate": "^1.0.13",
"tapbuffer": "^1.0.31",
"through2": "^2.0.3",
"tsn": "^2.0.15",
"typescript": "^2.8.3"
},
"dependencies": {},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.24",
"@gitzone/tsbundle": "^1.0.69",
"@gitzone/tstest": "^1.0.33",
"@gitzone/tswatch": "^1.0.46",
"@pushrocks/tapbundle": "^3.2.1",
"@types/node": "^10.0.3"
}
},
"private": true,
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
]
}

View File

@ -1,55 +1,14 @@
# npmts
best practice npm TypeScript modules
## Availabililty
[![npm](https://gitzone.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/@gitzone/npmts)
[![git](https://gitzone.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/gitzone/npmts)
[![git](https://gitzone.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/gitzone/npmts)
[![docs](https://gitzone.gitlab.io/assets/repo-button-docs.svg)](https://gitzone.gitlab.io/npmts/)
## Status for master
[![build status](https://GitLab.com/gitzone/npmts/badges/master/build.svg)](https://GitLab.com/gitzone/npmts/commits/master)
[![coverage report](https://GitLab.com/gitzone/npmts/badges/master/coverage.svg)](https://GitLab.com/gitzone/npmts/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@gitzone/npmts.svg)](https://www.npmjs.com/package/npmts)
[![bitHound Dependencies](https://www.bithound.io/github/gitzonetools/npmts/badges/dependencies.svg)](https://www.bithound.io/github/gitzonetools/npmts/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/gitzonetools/npmts/badges/code.svg)](https://www.bithound.io/github/gitzonetools/npmts)
[![Known Vulnerabilities](https://snyk.io/test/npm/@gitzone/npmts/badge.svg)]
[![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/)
## Quick Demo
[![asciicast](https://asciinema.org/a/9c3assmh21i49qhe5lmi48sze.png)](https://asciinema.org/a/9c3assmh21i49qhe5lmi48sze?speed=2&t=0)
## Usage
NPMTS is your friend when writing, testing, publishing and documenting npm modules written in TypeScript.
tscoverage will run tests while computing coverage for your gitzone project.
npmts will
## Contribution
1. check your dependencies and package.json (unused, missing, updates, security)
1. transpile your code with tsc,
1. test your code with tap (supports the fancy stuff like Promises, Generators, async/await, sourcemaps, parallel test execution in child processes)
1. create coverage with istanbul (supports tracing of the originating TypeScript)
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 more information on how tests are run check out the [tapbuffer module](https://www.npmjs.com/package/tapbuffer).
For more information about how to best write tap tests check out the [tapbundle module's linked docs](https://www.npmjs.com/package/tapbundle).
This works on your machine and in CI. There is a prebuild docker image available that includes npmts to make CI a breeze:
[hosttoday/ht-docker-node:npmts on Dockerhub](https://hub.docker.com/r/hosttoday/ht-docker-node/)
## Changelog
For breaking changes please see the [changelog](https://gitzone.gitlab.io/npmts/changelog.html).
For further information read the linked docs at the top of this README.
For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [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://gitzone.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

7
test/test.ts Normal file
View File

@ -0,0 +1,7 @@
import {tap, expect } from '@pushrocks/tapbundle';
tap.test('should run a test', async () => {
console.log('hi there');
})
tap.start();

View File

@ -1,13 +1 @@
/* ================================================== *
**** NPMTS ****
Fabulous TypeScript development
* ================================================== */
import * as early from 'early';
early.start('NPMTS');
import * as plugins from './npmts.plugins';
import * as cli from './npmts.cli';
early.stop().then(() => {
let loaded = plugins; // to make sure plugins get actually loaded
cli.run();
});
console.log('tscoverage');

View File

@ -1,27 +0,0 @@
/* ------------------------------------------
* This module compiles the module's TypeScript files
* Note: Test files are only compiled in memory
* -------------------------------------------- */
import * as q from 'smartq';
import { INpmtsConfig } from '../npmts.config';
import * as plugins from './mod.plugins';
import * as NpmtsAssets from './mod.assets';
import * as NpmtsCheck from './mod.check';
import * as NpmtsClean from './mod.clean';
import * as NpmtsCompile from './mod.compile';
export let run = function(configArg: INpmtsConfig): Promise<INpmtsConfig> {
let done = q.defer<INpmtsConfig>();
plugins.beautylog.ora.text('starting TypeScript Compilation');
NpmtsClean.run(configArg)
.then(NpmtsCheck.run)
.then(NpmtsCompile.run)
.then(NpmtsAssets.run)
.then(function() {
done.resolve(configArg);
});
return done.promise;
};

View File

@ -1,26 +0,0 @@
import * as q from 'smartq';
import paths = require('../npmts.paths');
import plugins = require('./mod.plugins');
import { projectInfo } from '../mod_compile/mod.check';
export let run = function(configArg) {
let done = q.defer();
let config = configArg;
plugins.beautylog.ora.text('now looking at ' + 'required assets');
if (config.cli === true) {
let mainJsPath = projectInfo.packageJson.main;
let cliJsString: string = plugins.smartfile.fs.toStringSync(
plugins.path.join(paths.npmtsAssetsDir, 'cli.js')
);
cliJsString = cliJsString.replace('{{pathToIndex}}', mainJsPath);
plugins.smartfile.memory.toFsSync(cliJsString, plugins.path.join(paths.distDir, 'cli.js'));
plugins.beautylog.ok('installed CLI assets!');
done.resolve(config);
} else {
plugins.beautylog.ok('No additional assets required!');
done.resolve(config);
}
return done.promise;
};

View File

@ -1,139 +0,0 @@
import * as q from 'smartq';
import { ProjectinfoNpm } from 'projectinfo';
// interfaces
import { INpmtsConfig } from '../npmts.config';
import * as paths from '../npmts.paths';
import * as plugins from './mod.plugins';
export let projectInfo: ProjectinfoNpm;
let checkProjectTypings = (configArg: INpmtsConfig) => {
let done = q.defer<INpmtsConfig>();
plugins.beautylog.ora.text('Check Module: Check Project Typings...');
projectInfo = new ProjectinfoNpm(paths.cwd);
if (typeof projectInfo.packageJson.typings === 'undefined') {
plugins.beautylog.error(`please add typings field to package.json`);
process.exit(1);
}
done.resolve(configArg);
return done.promise;
};
const depcheckOptions = {
ignoreBinPackage: false, // ignore the packages with bin entry
parsers: {
// the target parsers
'*.ts': plugins.depcheck.parser.typescript
},
detectors: [
// the target detectors
plugins.depcheck.detector.requireCallExpression,
plugins.depcheck.detector.importDeclaration
],
specials: [
// the target special parsers
plugins.depcheck.special.eslint,
plugins.depcheck.special.webpack
]
};
let checkDependencies = (configArg: INpmtsConfig) => {
let done = q.defer<INpmtsConfig>();
plugins.beautylog.ora.text('Check Module: Check Dependencies...');
let depcheckOptionsMerged = plugins.lodash.merge(depcheckOptions, {
ignoreDirs: [
// folder with these names will be ignored
'test',
'dist',
'bower_components'
],
ignoreMatches: [
// ignore dependencies that matches these globs
'@types/*',
'babel-preset-*'
]
});
plugins.depcheck(paths.cwd, depcheckOptionsMerged, unused => {
for (let item of unused.dependencies) {
plugins.beautylog.warn(`Watch out: unused dependency "${item}"`);
}
for (let item in unused.missing) {
plugins.beautylog.error(`missing dependency "${item}" in package.json`);
}
if (unused.missing.length > 0) {
plugins.beautylog.info('exiting due to missing dependencies in package.json');
process.exit(1);
}
for (let item in unused.invalidFiles) {
plugins.beautylog.warn(`Watch out: could not parse file ${item}`);
}
for (let item in unused.invalidDirs) {
plugins.beautylog.warn(`Watch out: could not parse directory ${item}`);
}
done.resolve(configArg);
});
return done.promise;
};
let checkDevDependencies = (configArg: INpmtsConfig) => {
let done = q.defer<INpmtsConfig>();
plugins.beautylog.ora.text('Check Module: Check devDependencies...');
let depcheckOptionsMerged = plugins.lodash.merge(depcheckOptions, {
ignoreDirs: [
// folder with these names will be ignored
'ts',
'dist',
'bower_components'
],
ignoreMatches: [
// ignore dependencies that matches these globs
'@types/*',
'babel-preset-*'
]
});
plugins.depcheck(paths.cwd, depcheckOptionsMerged, unused => {
for (let item of unused.devDependencies) {
plugins.beautylog.log(`unused devDependency ${item}`);
}
for (let item in unused.missing) {
plugins.beautylog.error(`missing devDependency ${item}`);
}
if (unused.missing.length > 0) {
plugins.beautylog.info('exiting due to missing dependencies in package.json');
process.exit(1);
}
for (let item in unused.invalidFiles) {
plugins.beautylog.warn(`Watch out: could not parse file ${item}`);
}
for (let item in unused.invalidDirs) {
plugins.beautylog.warn(`Watch out: could not parse directory ${item}`);
}
done.resolve(configArg);
});
return done.promise;
};
let checkNodeVersion = (configArg: INpmtsConfig) => {
let done = q.defer<INpmtsConfig>();
plugins.beautylog.ora.text('checking node version');
done.resolve(configArg);
return done.promise;
};
export let run = async (configArg: INpmtsConfig) => {
plugins.beautylog.ora.text('Check Module: ...');
if (configArg.checkDependencies) {
configArg = await checkProjectTypings(configArg);
configArg = await checkDependencies(configArg);
configArg = await checkDevDependencies(configArg);
configArg = await checkNodeVersion(configArg);
return configArg;
} else {
configArg = await checkProjectTypings(configArg);
return configArg;
}
};

View File

@ -1,32 +0,0 @@
import * as q from 'smartq';
import paths = require('../npmts.paths');
import plugins = require('./mod.plugins');
/**
* removes the dist directory which will be entirely rebuild
*/
let removeDist = function() {
plugins.beautylog.ora.text('cleaning dist folder');
return plugins.smartfile.fs.remove(paths.distDir);
};
/**
* remove old pages
*/
let removePages = function() {
plugins.beautylog.ora.text('cleaning pages folder');
return plugins.smartfile.fs.remove(paths.pagesDir);
};
export let run = function(configArg) {
plugins.beautylog.ora.text('cleaning up from previous builds...');
let done = q.defer();
removeDist()
.then(removePages)
.then(function() {
plugins.beautylog.ok('Cleaned up from previous builds!');
done.resolve(configArg);
});
return done.promise;
};

View File

@ -1,21 +0,0 @@
import * as q from 'smartq';
import * as paths from '../npmts.paths';
import * as plugins from './mod.plugins';
export let run = function(configArg) {
let done = q.defer();
let config = configArg;
plugins.beautylog.ora.text('now compiling ' + 'TypeScript');
plugins.tsn
.compileGlobStringObject(config.ts, config.tsOptions, paths.cwd)
.then(() => {
plugins.beautylog.ok(`compiled the module's TypeScript!`);
done.resolve(config);
})
.catch(err => {
console.log(err);
});
return done.promise;
};

View File

@ -1,7 +0,0 @@
export * from '../npmts.plugins';
import * as tsn from 'tsn';
import * as smartchok from 'smartchok';
import * as smartstream from 'smartstream';
export { tsn, smartchok, smartstream };

View File

@ -1,15 +0,0 @@
/* ------------------------------------------
* This module creates TypeScript documentation
* -------------------------------------------- */
import * as q from 'smartq';
import * as paths from '../npmts.paths';
import { INpmtsConfig } from '../npmts.config';
import * as plugins from './mod.plugins';
export let run = function(configArg: INpmtsConfig) {
let done = q.defer<INpmtsConfig>();
done.resolve(configArg);
return done.promise;
};

View File

@ -1 +0,0 @@
export * from '../npmts.plugins';

View File

@ -1,145 +0,0 @@
/* ------------------------------------------
* This module tests the compiled TypeScript files
* -------------------------------------------- */
import plugins = require('./mod.plugins');
import paths = require('../npmts.paths');
import * as q from 'smartq';
// interfaces
import { INpmtsConfig } from '../npmts.config';
import { Smartfile } from 'smartfile';
let testTypeScriptConfig = {
target: 'ES5',
emitDecoratorMetadata: true,
experimentalDecorators: true,
lib: ['DOM', 'ESNext']
};
/**
* runs mocha
* @returns INpmtsConfig
*/
let tap = function(configArg: INpmtsConfig) {
let done = q.defer();
/**
* the TabBuffer for npmts
*/
let npmtsTapBuffer = new plugins.tapbuffer.TabBuffer();
npmtsTapBuffer.setConfig(configArg.testConfig);
/**
* handle the testable files
*/
let testableFilesSmartstream = new plugins.smartstream.Smartstream([
plugins.smartgulp.src([plugins.path.join(paths.cwd, './ts/**/*.ts')]),
plugins.gulpSourcemaps.init(),
plugins.gulpTypeScript(testTypeScriptConfig),
plugins.gulpSourcemaps.write(),
npmtsTapBuffer.pipeTestableFiles(),
plugins.smartstream.cleanPipe()
]);
/**
* handle the test files
*/
let testFilesSmartstream = new plugins.smartstream.Smartstream([
plugins.smartgulp.src([plugins.path.join(paths.cwd, 'test/*.ts')]),
plugins.gulpSourcemaps.init(),
plugins.gulpTypeScript(testTypeScriptConfig),
plugins.gulpSourcemaps.write(),
npmtsTapBuffer.pipeTestFiles(),
plugins.smartstream.cleanPipe()
]);
// lets run the smartstream
Promise.all([testableFilesSmartstream.run(), testFilesSmartstream.run()]).then(
async () => {
configArg.runData.coverageLcovInfo = await npmtsTapBuffer.runTests();
done.resolve(configArg);
},
err => {
plugins.beautylog.error('Tests failed!');
console.log(err);
if (configArg.watch) {
done.resolve(configArg);
} else {
process.exit(1);
}
}
);
return done.promise;
};
let handleCoverageData = async (configArg: INpmtsConfig) => {
let coverageResult: number = 0; // the coverage in percent
if (configArg.runData.coverageLcovInfo) {
coverageResult = await plugins.smartcov.get.percentageFromLcovString(
configArg.runData.coverageLcovInfo,
2
);
} else {
plugins.beautylog.warn(
'Hey... Did your tests import and use your module that you are trying to test?'
);
}
if (coverageResult >= configArg.coverageTreshold) {
plugins.beautylog.ok(
`${coverageResult.toString()}% ` +
`coverage exceeds your treshold of ` +
`${configArg.coverageTreshold.toString()}%`
);
} else {
plugins.beautylog.warn(
`${coverageResult.toString()}% ` +
`coverage fails your treshold of ` +
`${configArg.coverageTreshold.toString()}%`
);
plugins.beautylog.error('exiting due to coverage failure');
if (!configArg.watch) {
process.exit(1);
}
}
return configArg;
};
/**
* run this module
* @param configArg some config for how to run this module
*/
export let run = function(configArg: INpmtsConfig) {
let done = q.defer<INpmtsConfig>();
let config = configArg;
if (config.test === true) {
plugins.beautylog.ora.text('now starting tests');
plugins.beautylog.ora.end();
plugins.beautylog.log('ready for tapbuffer:');
if (configArg.testConfig.coverage) {
tap(config)
.then(handleCoverageData)
.then(() => {
done.resolve(config);
})
.catch(err => {
console.log(err);
});
} else {
tap(config)
.then(() => {
done.resolve(config);
})
.catch(err => {
console.log(err);
});
}
} else {
plugins.beautylog.ora.end();
done.resolve(config);
}
return done.promise;
};

View File

@ -1,10 +0,0 @@
export * from '../npmts.plugins';
import * as gulpFunction from 'gulp-function';
import * as gulpSourcemaps from 'gulp-sourcemaps';
import * as gulpTypeScript from 'gulp-typescript';
import * as smartcov from 'smartcov';
import * as smartgulp from 'smartgulp';
import * as tapbuffer from 'tapbuffer';
export { gulpFunction, gulpSourcemaps, gulpTypeScript, smartcov, smartgulp, tapbuffer };

View File

@ -1,115 +0,0 @@
import * as q from 'smartq';
import * as plugins from './npmts.plugins';
import * as paths from './npmts.paths';
import * as NpmtsConfig from './npmts.config';
import * as NpmtsMods from './npmts.mods';
import * as NpmtsWatch from './npmts.watch';
import * as NpmtsShip from './npmts.ship';
/**
* smartanalytics
* this data is fully anonymized (no Ips or any other personal information is tracked).
* It just keeps track which of our tools are really used...
* ... so we know where to spend our limited resources for improving them.
* Since yarn is out and there is heavy caching going on,
* pure download stats are just not reliable enough for us anymore
* Feel free to dig into the smartanalytics package, if you are interested in how it works.
* It is just an https call to our own Lossless Analytics API.
* Our privacy policy can be found here: https://lossless.gmbh/privacy.html
*/
let npmtsAnalytics = new plugins.smartanalytics.Analytics({
apiEndPoint: 'https://pubapi.lossless.one/analytics',
projectId: 'gitzone',
appName: 'npmts'
});
process.nextTick(async () => {
// make the analytics call
npmtsAnalytics
.recordEvent('npmToolExecution', {
executionMode: (await NpmtsConfig.configPromise).mode,
tsOptions: (await NpmtsConfig.configPromise).tsOptions,
watch: (await NpmtsConfig.configPromise).watch,
coverageTreshold: (await NpmtsConfig.configPromise).coverageTreshold
})
.catch(err => {
plugins.beautylog.warn('Lossless Analytics API not available...');
});
});
export let run = async () => {
let done = q.defer();
plugins.beautylog.figletSync('NPMTS');
let npmtsProjectInfo = new plugins.projectinfo.ProjectinfoNpm(paths.npmtsPackageRoot);
// check for updates
await plugins.smartupdate.standardHandler.check(
'npmts',
npmtsProjectInfo.version,
'http://gitzone.gitlab.io/npmts/changelog.html'
);
plugins.beautylog.log('---------------------------------------------');
let npmtsCli = new plugins.smartcli.Smartcli();
// build
npmtsCli.addCommand('build').subscribe(
async argvArg => {
let done = q.defer();
plugins.beautylog.info('npmts version: ' + npmtsProjectInfo.version);
const configArg: NpmtsConfig.INpmtsConfig = await NpmtsConfig.run(argvArg);
plugins.beautylog.ora.start('loading additional modules...');
NpmtsMods.modCompile
.load()
.then(modCompile => {
return modCompile.run(configArg);
})
.then(configArg => {
let done = q.defer<NpmtsConfig.INpmtsConfig>();
NpmtsMods.modDocs
.load()
.then(modDocs => {
return modDocs.run(configArg);
})
.then(configArg => {
done.resolve(configArg);
});
return done.promise;
})
.then(configArg => {
let done = q.defer<NpmtsConfig.INpmtsConfig>();
NpmtsMods.modTest
.load()
.then(modTest => {
return modTest.run(configArg);
})
.then(configArg => {
done.resolve(configArg);
});
return done.promise;
})
.then(NpmtsWatch.run)
.then(NpmtsShip.run);
return done.promise;
},
err => {
if (err instanceof Error) {
console.log(err);
}
}
);
// standard task
npmtsCli.standardTask().subscribe(async argvArg => {
await npmtsCli.trigger('build');
});
// cli metadata
npmtsCli.addVersion(npmtsProjectInfo.version);
// start parsing
npmtsCli.startParse();
return await done.promise;
};

View File

@ -1,110 +0,0 @@
import plugins = require('./npmts.plugins');
import paths = require('./npmts.paths');
import * as smartq from 'smartq';
// interfaces
import { ITapbufferConfig } from 'tapbuffer';
/**
* specifies the different modes available
* default -> uses default options no matterm what
* merge -> uses merged default + custom options
* custom -> only uses specified options
*/
export type npmtsMode = 'default' | 'custom' | 'merge';
export interface INpmtsConfig {
argv: any;
coverageTreshold: number;
checkDependencies: boolean;
mode: npmtsMode;
test: boolean;
testTs: any;
testConfig: ITapbufferConfig;
ts: any;
tsOptions: any;
watch: boolean;
runData: {
coverageLcovInfo?: string;
coverageResult?: number;
};
}
export let run = function(argvArg) {
let done = smartq.defer<INpmtsConfig>();
let defaultConfig: INpmtsConfig = {
argv: undefined,
coverageTreshold: 70,
checkDependencies: true,
mode: 'default',
test: true,
testTs: {},
testConfig: {
parallel: true,
coverage: true
},
ts: {},
tsOptions: {},
watch: false,
runData: {}
};
// mix with configfile
plugins.beautylog.ora.text('running npmextra');
let localNpmextra = new plugins.npmextra.Npmextra(paths.cwd);
let config: INpmtsConfig = localNpmextra.dataFor<INpmtsConfig>('npmts', defaultConfig);
// add argv
config.argv = argvArg;
// check mode
switch (config.mode) {
case 'default':
case 'custom':
case 'merge':
plugins.beautylog.ok('mode is ' + config.mode);
done.resolve(config);
break;
default:
plugins.beautylog.error(`mode not recognised! Can be default or custom`);
process.exit(1);
}
// handle default mode
if (config.mode === 'default' || config.mode === 'merge') {
config.ts = {
'./ts/**/*.ts': './dist/'
};
config.testTs = {
'./test/**/*.ts': './test/'
};
}
// mix with commandline
if (config.argv.notest) {
config.test = false;
}
if (config.argv.nocoverage) {
config.testConfig.coverage = false;
}
if (config.argv.nochecks) {
config.checkDependencies = false;
}
if (config.argv.watch) {
config.watch = true;
}
plugins.beautylog.ok('build options are ready!');
done.resolve(config);
configDeferred.resolve(config);
return done.promise;
};
// config deferred usage
let configDeferred = smartq.defer<INpmtsConfig>();
export let configPromise = configDeferred.promise;

View File

@ -1,11 +0,0 @@
import * as plugins from './npmts.plugins';
import { LazyModule } from 'smartsystem';
import * as _modCompile from './mod_compile/index';
import * as _modDocs from './mod_docs/index';
import * as _modTest from './mod_test/index';
export let modCompile = new LazyModule<typeof _modCompile>('./mod_compile/index', __dirname);
export let modDocs = new LazyModule<typeof _modDocs>('./mod_docs/index', __dirname);
export let modTest = new LazyModule<typeof _modTest>('./mod_test/index', __dirname);

View File

@ -1,24 +0,0 @@
import plugins = require('./npmts.plugins');
// NPMTS Paths
export let npmtsPackageRoot = plugins.path.join(__dirname, '../');
// Project paths
export let cwd = process.cwd();
// Directories
export let tsDir = plugins.path.join(cwd, 'ts/');
export let distDir = plugins.path.join(cwd, 'dist/');
export let testDir = plugins.path.join(cwd, 'test/');
export let typingsDir = plugins.path.join(cwd, 'ts/typings/');
export let coverageDir = plugins.path.join(cwd, 'coverage/');
// Pages
export let pagesDir = plugins.path.join(cwd, 'pages/');
export let pagesApiDir = plugins.path.join(pagesDir, '/api');
export let npmtsAssetsDir = plugins.path.join(__dirname, '../assets/');
// Files
export let indexTS = plugins.path.join(cwd, 'ts/index.ts');
export let testTS = plugins.path.join(cwd, 'ts/test.ts');

View File

@ -1,36 +0,0 @@
import * as beautylog from 'beautylog';
let depcheck = require('depcheck');
import * as lodash from 'lodash';
import * as npmextra from 'npmextra';
import * as projectinfo from 'projectinfo';
import * as path from 'path';
import * as smartanalytics from 'smartanalytics';
import * as smartcli from '@pushrocks/smartcli';
import * as smarterror from 'smarterror';
import * as smartfile from 'smartfile';
import * as smartpath from 'smartpath';
import * as smartstream from 'smartstream';
import * as smartstring from 'smartstring';
import * as smartsystem from 'smartsystem';
import * as smartupdate from 'smartupdate';
import * as through2 from 'through2';
export {
beautylog,
depcheck,
lodash,
npmextra,
projectinfo,
path,
smartanalytics,
smartcli,
smarterror,
smartfile,
smartpath,
smartstream,
smartstring,
smartsystem,
smartupdate,
through2
};

View File

@ -1,31 +0,0 @@
import * as q from 'smartq';
import * as plugins from './npmts.plugins';
import { INpmtsConfig } from './npmts.config';
export let run = (configArg: INpmtsConfig) => {
let done = q.defer();
let shipString =
'' +
'\n' +
'\n' +
' # # ( )\n' +
' ___#_#___|__\n' +
' _ |____________| _\n' +
' _=====| | | | | |==== _\n' +
' =====| |.---------------------------. | |====\n' +
" <--------------------' . . . . . . . . '--------------/\n" +
' \\ /\n' +
' \\___________________________________________________________/\n' +
' wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\n' +
' wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\n' +
' wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\n';
if (process.env.CI) {
console.log(shipString);
plugins.beautylog.success('READY TO SHIP!');
} else {
plugins.beautylog.success('Done!');
}
done.resolve(configArg);
};

View File

@ -1,34 +0,0 @@
import * as q from 'smartq';
import * as smartchok from 'smartchok';
import * as plugins from './npmts.plugins';
import * as cli from './npmts.cli';
import { INpmtsConfig } from './npmts.config';
let npmtsSmartchok: smartchok.Smartchok = null;
export let run = (configArg: INpmtsConfig) => {
let done = q.defer();
if (configArg.watch && npmtsSmartchok === null) {
let pathsToWatch: string[] = [];
for (let key in configArg.ts) {
pathsToWatch.push(key);
}
for (let key in configArg.testTs) {
pathsToWatch.push(key);
}
npmtsSmartchok = new smartchok.Smartchok(pathsToWatch);
npmtsSmartchok.getObservableFor('change').then(changeObservableArg => {
plugins.beautylog.info('now watching...');
changeObservableArg.subscribe(() => {
cli.run();
});
});
npmtsSmartchok.start();
done.resolve(configArg);
} else {
plugins.beautylog.info('not watching');
done.resolve(configArg);
}
return done.promise;
};

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"
}

File diff suppressed because it is too large Load Diff

3921
yarn.lock

File diff suppressed because it is too large Load Diff