Compare commits

...

13 Commits

Author SHA1 Message Date
835fba3452 2.1.21 2020-03-13 19:23:02 +00:00
d35cff7135 fix(core): update 2020-03-13 19:23:01 +00:00
6bbfd8b8a5 2.1.20 2020-03-09 15:20:48 +00:00
9e6ab262ed fix(core): update 2020-03-09 15:20:47 +00:00
58246c406d 2.1.19 2020-03-09 15:15:52 +00:00
345df135b9 fix(core): update 2020-03-09 15:15:52 +00:00
31e99a0035 2.1.18 2020-03-09 15:14:07 +00:00
8aa3823e65 fix(core): update 2020-03-09 15:14:06 +00:00
d36a5f7751 2.1.17 2019-08-26 16:28:03 +02:00
6b1c7c4dc8 fix(core): update 2019-08-26 16:28:03 +02:00
dbcfa977fd 2.1.16 2019-08-26 16:15:51 +02:00
fda30f611a 2.1.15 2019-08-26 16:12:24 +02:00
c1e43788a6 2.1.14 2019-08-26 16:01:39 +02:00
14 changed files with 191 additions and 159 deletions

21
.gitignore vendored
View File

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

View File

@ -1,10 +1,10 @@
# gitzone standard # gitzone ci_default
image: hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache: cache:
paths: paths:
- .npmci_cache/ - .npmci_cache/
key: "$CI_BUILD_STAGE" key: '$CI_BUILD_STAGE'
stages: stages:
- security - security
@ -20,17 +20,19 @@ mirror:
script: script:
- npmci git mirror - npmci git mirror
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
snyk: snyk:
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
stage: security stage: security
script: script:
- npmci npm prepare - npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts - npmci command npm install --ignore-scripts
- npmci command snyk test - npmci command snyk test
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
@ -38,19 +40,7 @@ snyk:
# test stage # test stage
# ==================== # ====================
testLTS: testStable:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
testSTABLE:
stage: test stage: test
script: script:
- npmci npm prepare - npmci npm prepare
@ -59,6 +49,20 @@ testSTABLE:
- npmci npm test - npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- lossless
- docker
- priv
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- docker - docker
- notpriv - notpriv
@ -70,6 +74,7 @@ release:
only: only:
- tags - tags
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
@ -78,20 +83,14 @@ release:
# ==================== # ====================
codequality: codequality:
stage: metadata stage: metadata
image: docker:stable
allow_failure: true allow_failure: true
services:
- docker:stable-dind
script: script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/') - npmci command npm install -g tslint typescript
- docker run - npmci npm prepare
--env SOURCE_CODE="$PWD" - npmci npm install
--volume "$PWD":/code - npmci command "tslint -c tslint.json ./ts/**/*.ts"
--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: tags:
- lossless
- docker - docker
- priv - priv
@ -102,18 +101,20 @@ trigger:
only: only:
- tags - tags
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
pages: pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata stage: metadata
script: script:
- npmci command npm install -g typedoc typescript - npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare - npmci npm prepare
- npmci npm install - npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/ - npmci command tsdoc
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
only: only:

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,70 +0,0 @@
# tsn
## Availabililty
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/tsn)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/tsn)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/tsn)
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/tsn/)
## Status for master
[![build status](https://gitlab.com/pushrocks/tsn/badges/master/build.svg)](https://gitlab.com/pushrocks/tsn/commits/master)
[![coverage report](https://gitlab.com/pushrocks/tsn/badges/master/coverage.svg)](https://gitlab.com/pushrocks/tsn/commits/master)
[![Dependency Status](https://david-dm.org/pushrocks/tsn.svg)](https://david-dm.org/pushrocks/tsn)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/tsn/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/tsn/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/tsn/badges/code.svg)](https://www.bithound.io/github/pushrocks/tsn)
[![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
Tsn uses the **next** tagged npm version of typescript
```typescript
import * as tsn from 'tsn';
let myGlobStringObject = {
'./myTsFolder/**/*.ts': './myDestinationFolder/',
'./someOtherTsFolder/**/*.ts': './myOtherDestinationFolder/'
};
let tsOptions = {
target: tsn.ScriptTarget.ES2015,
module: tsn.ModuleKind.CommonJS
};
/*
note: since this only works in code, here are the target numbers
enum ScriptTarget {
ES3 = 0,
ES5 = 1,
ES2015 = 2,
ES2016 = 3,
ES2017 = 4,
ESNext = 5,
Latest = 5,
}
and here are the module kinds
enum ModuleKind {
None = 0,
CommonJS = 1,
AMD = 2,
UMD = 3,
System = 4,
ES2015 = 5,
}
*/
let myCwd = process.cwd();
tsn.compileGlobStringObject(
myGlobStringObject, // the glob string object describing from where to compile what to where
tsOptions, // the options for TypeScript
myCwd // a custom cwd, optional, defaults to process.cwd()
);
```
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)

View File

@ -2,5 +2,16 @@
"npmci": { "npmci": {
"npmGlobalTools": [], "npmGlobalTools": [],
"npmAccessLevel": "public" "npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "gitzone",
"gitrepo": "tsbuild",
"shortDescription": "TypeScript nightly to easily make use of latest features",
"npmPackagename": "@gitzone/tsbuild",
"license": "MIT"
}
} }
} }

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@gitzone/tsbuild", "name": "@gitzone/tsbuild",
"version": "2.1.13", "version": "2.1.21",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,9 +1,9 @@
{ {
"name": "@gitzone/tsbuild", "name": "@gitzone/tsbuild",
"version": "2.1.13", "version": "2.1.21",
"private": false, "private": false,
"description": "TypeScript nightly to easily make use of latest features", "description": "TypeScript nightly to easily make use of latest features",
"main": "dist/index.js", "main": "dist_ts/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
"bin": { "bin": {
"tsbuild": "cli.js" "tsbuild": "cli.js"
@ -40,5 +40,18 @@
"@types/node": "^12.7.2", "@types/node": "^12.7.2",
"tslint": "^5.19.0", "tslint": "^5.19.0",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
} },
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_bundle/**/*",
"dist_web/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
]
} }

View File

@ -12,7 +12,7 @@ export const compilerOptionsDefault: CompilerOptions = {
experimentalDecorators: true, experimentalDecorators: true,
inlineSourceMap: true, inlineSourceMap: true,
noEmitOnError: true, noEmitOnError: true,
outDir: 'dist/', outDir: 'dist_ts/',
module: plugins.typescript.ModuleKind.CommonJS, module: plugins.typescript.ModuleKind.CommonJS,
lib: ['lib.es2017.d.ts'], lib: ['lib.es2017.d.ts'],
noImplicitAny: false, noImplicitAny: false,
@ -28,7 +28,10 @@ export const compilerOptionsWebDefault: CompilerOptions = {
/** /**
* merges compilerOptions with the default compiler options * merges compilerOptions with the default compiler options
*/ */
export const mergeCompilerOptions = (customTsOptions: CompilerOptions, argvArg?: any): CompilerOptions => { export const mergeCompilerOptions = (
customTsOptions: CompilerOptions,
argvArg?: any
): CompilerOptions => {
const defaultOptionsToMerge = (() => { const defaultOptionsToMerge = (() => {
if (argvArg && argvArg.web) { if (argvArg && argvArg.web) {
return compilerOptionsWebDefault; return compilerOptionsWebDefault;
@ -38,7 +41,7 @@ export const mergeCompilerOptions = (customTsOptions: CompilerOptions, argvArg?:
})(); })();
// create merged options // create merged options
let mergedOptions: CompilerOptions = { const mergedOptions: CompilerOptions = {
...defaultOptionsToMerge, ...defaultOptionsToMerge,
...customTsOptions ...customTsOptions
}; };
@ -52,25 +55,25 @@ export const mergeCompilerOptions = (customTsOptions: CompilerOptions, argvArg?:
export const compiler = ( export const compiler = (
fileNames: string[], fileNames: string[],
options: plugins.typescript.CompilerOptions, options: plugins.typescript.CompilerOptions,
argvArg?: any, argvArg?: any
): Promise<any[]> => { ): Promise<any[]> => {
console.log(`Compiling ${fileNames.length} files...`); console.log(`Compiling ${fileNames.length} files...`);
let done = plugins.smartpromise.defer<any[]>(); const done = plugins.smartpromise.defer<any[]>();
let program = plugins.typescript.createProgram(fileNames, options); const program = plugins.typescript.createProgram(fileNames, options);
let emitResult = program.emit(); const emitResult = program.emit();
// implement check only // implement check only
/*let emitResult = program.emit(undefined,(args) => { /*let emitResult = program.emit(undefined,(args) => {
console.log(args) console.log(args)
});*/ });*/
let allDiagnostics = plugins.typescript const allDiagnostics = plugins.typescript
.getPreEmitDiagnostics(program) .getPreEmitDiagnostics(program)
.concat(emitResult.diagnostics); .concat(emitResult.diagnostics);
allDiagnostics.forEach(diagnostic => { allDiagnostics.forEach(diagnostic => {
if (diagnostic.file) { if (diagnostic.file) {
let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!); const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!);
let message = plugins.typescript.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); const message = plugins.typescript.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
} else { } else {
console.log( console.log(
@ -79,7 +82,7 @@ export const compiler = (
} }
}); });
let exitCode = emitResult.emitSkipped ? 1 : 0; const exitCode = emitResult.emitSkipped ? 1 : 0;
if (exitCode === 0) { if (exitCode === 0) {
console.log('TypeScript emit succeeded!'); console.log('TypeScript emit succeeded!');
done.resolve(emitResult.emittedFiles); done.resolve(emitResult.emittedFiles);

View File

@ -6,11 +6,11 @@ const tsbuildCli = new plugins.smartcli.Smartcli();
/** /**
* the standard task compiles anything in ts/ directory to dist directory * the standard task compiles anything in ts/ directory to dist directory
*/ */
tsbuildCli.standardTask().subscribe(argvArg => { tsbuildCli.standardTask().subscribe(async argvArg => {
if (process.env.CLI_CALL_TSBUILD === 'true') { if (process.env.CLI_CALL_TSBUILD === 'true') {
tsbuild.compileGlobStringObject( tsbuild.compileGlobStringObject(
{ {
'./ts/**/*.ts': './dist' './ts/**/*.ts': './dist_ts'
}, },
{}, {},
process.cwd(), process.cwd(),
@ -22,18 +22,24 @@ tsbuildCli.standardTask().subscribe(argvArg => {
/** /**
* the custom command compiles any customDir to dist_customDir * the custom command compiles any customDir to dist_customDir
*/ */
tsbuildCli.addCommand('custom').subscribe(argvArg => { tsbuildCli.addCommand('custom').subscribe(async argvArg => {
const listedDirectories = argvArg._; const listedDirectories = argvArg._;
listedDirectories.shift(); listedDirectories.shift();
const compilationCommandObject: { [key: string]: string } = {}; const compilationCommandObject: { [key: string]: string } = {};
for (const directory of listedDirectories) { for (const directory of listedDirectories) {
compilationCommandObject[`./${directory}/**/*.ts`] = `./dist_${directory}`; compilationCommandObject[`./${directory}/**/*.ts`] = `./dist_${directory}`;
}; }
tsbuild.compileGlobStringObject( await tsbuild.compileGlobStringObject(compilationCommandObject, {}, process.cwd(), argvArg);
compilationCommandObject, });
tsbuildCli.addCommand('element').subscribe(async argvArg => {
await tsbuild.compileGlobStringObject(
{
'./ts_web/**/*.ts': 'dist_ts_web'
},
{}, {},
process.cwd(), process.cwd(),
argvArg { web: true }
); );
}); });

View File

@ -9,7 +9,7 @@ export * from './tsbuild.classes.compiler';
export let compileFileArray = ( export let compileFileArray = (
fileStringArrayArg: string[], fileStringArrayArg: string[],
compilerOptionsArg: CompilerOptions = {}, compilerOptionsArg: CompilerOptions = {},
argvArg?: any, argvArg?: any
): Promise<any[]> => { ): Promise<any[]> => {
return compiler(fileStringArrayArg, mergeCompilerOptions(compilerOptionsArg, argvArg), argvArg); return compiler(fileStringArrayArg, mergeCompilerOptions(compilerOptionsArg, argvArg), argvArg);
}; };
@ -25,7 +25,7 @@ export let compileGlobStringObject = async (
globStringObjectArg: any, globStringObjectArg: any,
tsOptionsArg: CompilerOptions = {}, tsOptionsArg: CompilerOptions = {},
cwdArg: string = process.cwd(), cwdArg: string = process.cwd(),
argvArg?: any, argvArg?: any
) => { ) => {
let compiledFiles = []; let compiledFiles = [];
for (const keyArg in globStringObjectArg) { for (const keyArg in globStringObjectArg) {

View File

@ -1,6 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"outDir": "dist/", "outDir": "dist_ts/",
"module": "commonjs", "module": "commonjs",
"target": "es2015", "target": "es2015",
"lib":[ "lib":[