Compare commits
36 Commits
Author | SHA1 | Date | |
---|---|---|---|
dbcfa977fd | |||
fda30f611a | |||
c1e43788a6 | |||
3a0efa37cc | |||
d238012b68 | |||
990fbaf785 | |||
aaa459e4b7 | |||
fbad295644 | |||
334d3c0c82 | |||
b9523d25e6 | |||
fdf3d14456 | |||
5a68e83abf | |||
def7dc65c8 | |||
649ca48d03 | |||
abc515c742 | |||
1eb2b727aa | |||
93a332ba50 | |||
109ba0b0ee | |||
ee3ef5d6e9 | |||
d5852ce85d | |||
f36dea3875 | |||
d36bf42f8b | |||
730c739c14 | |||
dd1f007246 | |||
41ca4805e6 | |||
68dcf1cca9 | |||
53ba4a64b3 | |||
fa8dc2bec5 | |||
1ef8a502e3 | |||
bbcb8e6b3f | |||
fee2a60162 | |||
0a2fee42ca | |||
13827541c8 | |||
eeb6d6b963 | |||
bc6039e5ed | |||
58c783dc54 |
@ -26,6 +26,7 @@ mirror:
|
|||||||
snyk:
|
snyk:
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
- npmci command npm install -g snyk
|
- 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
|
||||||
@ -36,21 +37,11 @@ snyk:
|
|||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
# ====================
|
# ====================
|
||||||
testLEGACY:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci node install legacy
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
testLTS:
|
testLTS:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
- npmci node install lts
|
- npmci node install lts
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm test
|
||||||
@ -62,6 +53,7 @@ testLTS:
|
|||||||
testSTABLE:
|
testSTABLE:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm test
|
||||||
@ -118,6 +110,7 @@ pages:
|
|||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g typedoc typescript
|
- npmci command npm install -g typedoc typescript
|
||||||
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
||||||
tags:
|
tags:
|
||||||
@ -130,13 +123,3 @@ pages:
|
|||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
windowsCompatibility:
|
|
||||||
image: stefanscherer/node-windows:10-build-tools
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npm install & npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- windows
|
|
||||||
allow_failure: true
|
|
||||||
|
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.13.3
|
||||||
|
ignore: {}
|
||||||
|
patch: {}
|
1414
package-lock.json
generated
1414
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tsbuild",
|
"name": "@gitzone/tsbuild",
|
||||||
"version": "2.0.19",
|
"version": "2.1.16",
|
||||||
"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/index.js",
|
||||||
@ -10,6 +10,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "tsrun test/test.ts",
|
"test": "tsrun test/test.ts",
|
||||||
|
"testCustom": "node cli.ts.js custom ts_web",
|
||||||
"build": "node cli.ts.js"
|
"build": "node cli.ts.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@ -26,15 +27,18 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/tsn#README",
|
"homepage": "https://gitlab.com/pushrocks/tsn#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartfile": "^6.0.3",
|
"@pushrocks/smartcli": "^3.0.7",
|
||||||
|
"@pushrocks/smartfile": "^7.0.2",
|
||||||
|
"@pushrocks/smartlog": "^2.0.19",
|
||||||
"@pushrocks/smartpath": "^4.0.1",
|
"@pushrocks/smartpath": "^4.0.1",
|
||||||
"@pushrocks/smartpromise": "^2.0.5",
|
"@pushrocks/smartpromise": "^3.0.2",
|
||||||
"smartlog": "^1.0.3",
|
"typescript": "^3.5.2"
|
||||||
"typescript": "^2.9.2"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsrun": "^1.1.9",
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
"@pushrocks/tapbundle": "^3.0.1",
|
"@pushrocks/tapbundle": "^3.0.13",
|
||||||
"@types/node": "^10.5.3"
|
"@types/node": "^12.7.2",
|
||||||
|
"tslint": "^5.19.0",
|
||||||
|
"tslint-config-prettier": "^1.18.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
test/assets/output/tocompile.d.ts
vendored
3
test/assets/output/tocompile.d.ts
vendored
@ -1,4 +1,5 @@
|
|||||||
declare class test {
|
declare class test2 {
|
||||||
test: string[];
|
test: string[];
|
||||||
constructor();
|
constructor();
|
||||||
}
|
}
|
||||||
|
declare const run: () => Promise<string>;
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
console.log('test');
|
console.log('test');
|
||||||
console.log('test2');
|
console.log('test2');
|
||||||
class test {
|
class test2 {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.test = [];
|
this.test = [];
|
||||||
console.log('hi');
|
console.log('hi');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9jb21waWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdG9jb21waWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sQ0FBQyxHQUFHLENBQUMsTUFBTSxDQUFDLENBQUM7QUFDcEIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsQ0FBQztBQUNyQjtJQUVFO1FBREEsU0FBSSxHQUFhLEVBQUUsQ0FBQztRQUVsQixPQUFPLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxDQUFDO0lBQ3BCLENBQUM7Q0FDRiJ9
|
const run = async () => {
|
||||||
|
return 'hi';
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9jb21waWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdG9jb21waWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sQ0FBQyxHQUFHLENBQUMsTUFBTSxDQUFDLENBQUM7QUFDcEIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsQ0FBQztBQUNyQixNQUFNLEtBQUs7SUFFVDtRQURBLFNBQUksR0FBYSxFQUFFLENBQUM7UUFFbEIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUNwQixDQUFDO0NBQ0Y7QUFFRCxNQUFNLEdBQUcsR0FBRyxLQUFLLElBQXFCLEVBQUU7SUFDdEMsT0FBTyxJQUFJLENBQUM7QUFDZCxDQUFDLENBQUMifQ==
|
@ -1,8 +1,12 @@
|
|||||||
console.log('test');
|
console.log('test');
|
||||||
console.log('test2');
|
console.log('test2');
|
||||||
class test {
|
class test2 {
|
||||||
test: string[] = [];
|
test: string[] = [];
|
||||||
constructor() {
|
constructor() {
|
||||||
console.log('hi');
|
console.log('hi');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const run = async (): Promise<string> => {
|
||||||
|
return 'hi';
|
||||||
|
};
|
||||||
|
10
ts/index.ts
10
ts/index.ts
@ -1,9 +1,3 @@
|
|||||||
export * from "./tsbuild.exports";
|
export * from './tsbuild.exports';
|
||||||
|
|
||||||
import * as tsbuild from './tsbuild.exports'
|
import './tsbuild.cli';
|
||||||
|
|
||||||
if (process.env.CLI_CALL_TSBUILD === "true") {
|
|
||||||
tsbuild.compileGlobStringObject({
|
|
||||||
"./ts/**/*.ts": "./dist"
|
|
||||||
})
|
|
||||||
}
|
|
@ -11,24 +11,35 @@ export const compilerOptionsDefault: CompilerOptions = {
|
|||||||
emitDecoratorMetadata: true,
|
emitDecoratorMetadata: true,
|
||||||
experimentalDecorators: true,
|
experimentalDecorators: true,
|
||||||
inlineSourceMap: true,
|
inlineSourceMap: true,
|
||||||
noEmitOnError: false,
|
noEmitOnError: true,
|
||||||
outDir: 'dist/',
|
outDir: 'dist/',
|
||||||
module: plugins.typescript.ModuleKind.CommonJS,
|
module: plugins.typescript.ModuleKind.CommonJS,
|
||||||
lib: [
|
lib: ['lib.es2017.d.ts'],
|
||||||
'es2016',
|
|
||||||
'es2017'
|
|
||||||
],
|
|
||||||
noImplicitAny: false,
|
noImplicitAny: false,
|
||||||
target: plugins.typescript.ScriptTarget.ES2015
|
esModuleInterop: true,
|
||||||
|
target: plugins.typescript.ScriptTarget.ES2017
|
||||||
|
};
|
||||||
|
|
||||||
|
export const compilerOptionsWebDefault: CompilerOptions = {
|
||||||
|
...compilerOptionsDefault,
|
||||||
|
lib: [...compilerOptionsDefault.lib, 'lib.dom.d.ts']
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* merges compilerOptions with the default compiler options
|
* merges compilerOptions with the default compiler options
|
||||||
*/
|
*/
|
||||||
export const mergeCompilerOptions = function(customTsOptions: CompilerOptions): CompilerOptions {
|
export const mergeCompilerOptions = (customTsOptions: CompilerOptions, argvArg?: any): CompilerOptions => {
|
||||||
|
const defaultOptionsToMerge = (() => {
|
||||||
|
if (argvArg && argvArg.web) {
|
||||||
|
return compilerOptionsWebDefault;
|
||||||
|
} else {
|
||||||
|
return compilerOptionsDefault;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
// create merged options
|
// create merged options
|
||||||
let mergedOptions: CompilerOptions = {
|
let mergedOptions: CompilerOptions = {
|
||||||
...compilerOptionsDefault,
|
...defaultOptionsToMerge,
|
||||||
...customTsOptions
|
...customTsOptions
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -40,9 +51,10 @@ export const mergeCompilerOptions = function(customTsOptions: CompilerOptions):
|
|||||||
*/
|
*/
|
||||||
export const compiler = (
|
export const compiler = (
|
||||||
fileNames: string[],
|
fileNames: string[],
|
||||||
options: plugins.typescript.CompilerOptions
|
options: plugins.typescript.CompilerOptions,
|
||||||
|
argvArg?: any,
|
||||||
): Promise<any[]> => {
|
): Promise<any[]> => {
|
||||||
console.log(options);
|
console.log(`Compiling ${fileNames.length} files...`);
|
||||||
let done = plugins.smartpromise.defer<any[]>();
|
let done = plugins.smartpromise.defer<any[]>();
|
||||||
let program = plugins.typescript.createProgram(fileNames, options);
|
let program = plugins.typescript.createProgram(fileNames, options);
|
||||||
let emitResult = program.emit();
|
let emitResult = program.emit();
|
||||||
@ -55,15 +67,17 @@ export const compiler = (
|
|||||||
let allDiagnostics = plugins.typescript
|
let allDiagnostics = plugins.typescript
|
||||||
.getPreEmitDiagnostics(program)
|
.getPreEmitDiagnostics(program)
|
||||||
.concat(emitResult.diagnostics);
|
.concat(emitResult.diagnostics);
|
||||||
try {
|
allDiagnostics.forEach(diagnostic => {
|
||||||
allDiagnostics.forEach(diagnostic => {
|
if (diagnostic.file) {
|
||||||
let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!);
|
||||||
let message = plugins.typescript.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
|
let 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 {
|
||||||
} catch (err) {
|
console.log(
|
||||||
// console.log(allDiagnostics)
|
`${plugins.typescript.flattenDiagnosticMessageText(diagnostic.messageText, '\n')}`
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let exitCode = emitResult.emitSkipped ? 1 : 0;
|
let exitCode = emitResult.emitSkipped ? 1 : 0;
|
||||||
if (exitCode === 0) {
|
if (exitCode === 0) {
|
||||||
|
40
ts/tsbuild.cli.ts
Normal file
40
ts/tsbuild.cli.ts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import * as plugins from './tsbuild.plugins';
|
||||||
|
import * as tsbuild from './tsbuild.exports';
|
||||||
|
|
||||||
|
const tsbuildCli = new plugins.smartcli.Smartcli();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the standard task compiles anything in ts/ directory to dist directory
|
||||||
|
*/
|
||||||
|
tsbuildCli.standardTask().subscribe(argvArg => {
|
||||||
|
if (process.env.CLI_CALL_TSBUILD === 'true') {
|
||||||
|
tsbuild.compileGlobStringObject(
|
||||||
|
{
|
||||||
|
'./ts/**/*.ts': './dist'
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
process.cwd(),
|
||||||
|
argvArg
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the custom command compiles any customDir to dist_customDir
|
||||||
|
*/
|
||||||
|
tsbuildCli.addCommand('custom').subscribe(argvArg => {
|
||||||
|
const listedDirectories = argvArg._;
|
||||||
|
listedDirectories.shift();
|
||||||
|
const compilationCommandObject: {[key: string]: string} = {};
|
||||||
|
for (const directory of listedDirectories) {
|
||||||
|
compilationCommandObject[`./${directory}/**/*.ts`] = `./dist_${directory}`;
|
||||||
|
};
|
||||||
|
tsbuild.compileGlobStringObject(
|
||||||
|
compilationCommandObject,
|
||||||
|
{},
|
||||||
|
process.cwd(),
|
||||||
|
argvArg
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
tsbuildCli.startParse();
|
@ -8,9 +8,10 @@ export * from './tsbuild.classes.compiler';
|
|||||||
*/
|
*/
|
||||||
export let compileFileArray = (
|
export let compileFileArray = (
|
||||||
fileStringArrayArg: string[],
|
fileStringArrayArg: string[],
|
||||||
compilerOptionsArg: CompilerOptions = {}
|
compilerOptionsArg: CompilerOptions = {},
|
||||||
|
argvArg?: any,
|
||||||
): Promise<any[]> => {
|
): Promise<any[]> => {
|
||||||
return compiler(fileStringArrayArg, mergeCompilerOptions(compilerOptionsArg));
|
return compiler(fileStringArrayArg, mergeCompilerOptions(compilerOptionsArg, argvArg), argvArg);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,30 +24,33 @@ export let compileFileArray = (
|
|||||||
export let compileGlobStringObject = async (
|
export let compileGlobStringObject = async (
|
||||||
globStringObjectArg: any,
|
globStringObjectArg: any,
|
||||||
tsOptionsArg: CompilerOptions = {},
|
tsOptionsArg: CompilerOptions = {},
|
||||||
cwdArg: string = process.cwd()
|
cwdArg: string = process.cwd(),
|
||||||
|
argvArg?: any,
|
||||||
) => {
|
) => {
|
||||||
let compiledFiles = [];
|
let compiledFiles = [];
|
||||||
for (let keyArg in globStringObjectArg) {
|
for (const keyArg in globStringObjectArg) {
|
||||||
console.log(
|
if(globStringObjectArg[keyArg]) {
|
||||||
`TypeScript assignment: transpile from ${keyArg} to ${globStringObjectArg[keyArg]}`
|
console.log(
|
||||||
);
|
`TypeScript assignment: transpile from ${keyArg} to ${globStringObjectArg[keyArg]}`
|
||||||
const fileTreeArray = await plugins.smartfile.fs.listFileTree(cwdArg, keyArg);
|
);
|
||||||
let absoluteFilePathArray: string[] = plugins.smartpath.transform.toAbsolute(
|
const fileTreeArray = await plugins.smartfile.fs.listFileTree(cwdArg, keyArg);
|
||||||
fileTreeArray,
|
let absoluteFilePathArray: string[] = plugins.smartpath.transform.toAbsolute(
|
||||||
cwdArg
|
fileTreeArray,
|
||||||
);
|
cwdArg
|
||||||
let destDir: string = plugins.smartpath.transform.toAbsolute(
|
);
|
||||||
globStringObjectArg[keyArg],
|
let destDir: string = plugins.smartpath.transform.toAbsolute(
|
||||||
cwdArg
|
globStringObjectArg[keyArg],
|
||||||
);
|
cwdArg
|
||||||
tsOptionsArg = {
|
);
|
||||||
...tsOptionsArg,
|
tsOptionsArg = {
|
||||||
outDir: destDir
|
...tsOptionsArg,
|
||||||
};
|
outDir: destDir
|
||||||
compiledFiles = compiledFiles.concat(
|
};
|
||||||
compiledFiles,
|
compiledFiles = compiledFiles.concat(
|
||||||
await compileFileArray(absoluteFilePathArray, tsOptionsArg)
|
compiledFiles,
|
||||||
);
|
await compileFileArray(absoluteFilePathArray, tsOptionsArg, argvArg)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return compiledFiles;
|
return compiledFiles;
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
import * as smartcli from '@pushrocks/smartcli';
|
||||||
import * as smartfile from '@pushrocks/smartfile';
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
import * as smartpath from '@pushrocks/smartpath';
|
import * as smartpath from '@pushrocks/smartpath';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
import * as typescript from 'typescript';
|
import * as typescript from 'typescript';
|
||||||
|
|
||||||
export { smartfile, smartpath, smartpromise, typescript };
|
export { smartcli, smartfile, smartpath, smartpromise, typescript };
|
||||||
|
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