fix(core): initial
This commit is contained in:
		
							
								
								
									
										7
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | |||||||
|  | # gitzone standard | ||||||
|  | node_modules/ | ||||||
|  | coverage/ | ||||||
|  | pages/ | ||||||
|  | public/ | ||||||
|  | assets/output/ | ||||||
|  | dist/ | ||||||
							
								
								
									
										142
									
								
								.gitlab-ci.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										142
									
								
								.gitlab-ci.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,142 @@ | |||||||
|  | # gitzone standard | ||||||
|  | image: hosttoday/ht-docker-node:npmci | ||||||
|  |  | ||||||
|  | cache: | ||||||
|  |   paths: | ||||||
|  |   - .npmci_cache/ | ||||||
|  |   key: "$CI_BUILD_STAGE" | ||||||
|  |  | ||||||
|  | stages: | ||||||
|  | - security | ||||||
|  | - test | ||||||
|  | - release | ||||||
|  | - metadata | ||||||
|  |  | ||||||
|  | # ==================== | ||||||
|  | # security stage | ||||||
|  | # ==================== | ||||||
|  | mirror: | ||||||
|  |   stage: security | ||||||
|  |   script: | ||||||
|  |   - npmci git mirror | ||||||
|  |   tags: | ||||||
|  |   - docker | ||||||
|  |   - notpriv | ||||||
|  |  | ||||||
|  | snyk: | ||||||
|  |   stage: security | ||||||
|  |   script: | ||||||
|  |     - npmci command npm install -g snyk | ||||||
|  |     - npmci command npm install --ignore-scripts | ||||||
|  |     - npmci command snyk test | ||||||
|  |   tags: | ||||||
|  |   - docker | ||||||
|  |   - notpriv | ||||||
|  |  | ||||||
|  | # ==================== | ||||||
|  | # 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: | ||||||
|  |   stage: test | ||||||
|  |   script: | ||||||
|  |   - npmci node install lts | ||||||
|  |   - npmci npm install | ||||||
|  |   - npmci npm test | ||||||
|  |   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 | ||||||
|  |  | ||||||
|  | release: | ||||||
|  |   stage: release | ||||||
|  |   script: | ||||||
|  |   - npmci node install stable | ||||||
|  |   - npmci npm publish | ||||||
|  |   only: | ||||||
|  |   - tags | ||||||
|  |   tags: | ||||||
|  |   - docker | ||||||
|  |   - notpriv | ||||||
|  |  | ||||||
|  | # ==================== | ||||||
|  | # metadata stage | ||||||
|  | # ==================== | ||||||
|  | codequality: | ||||||
|  |   stage: metadata | ||||||
|  |   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 | ||||||
|  |  | ||||||
|  | trigger: | ||||||
|  |   stage: metadata | ||||||
|  |   script: | ||||||
|  |   - npmci trigger | ||||||
|  |   only: | ||||||
|  |   - tags | ||||||
|  |   tags: | ||||||
|  |   - docker | ||||||
|  |   - notpriv | ||||||
|  |  | ||||||
|  | pages: | ||||||
|  |   image: hosttoday/ht-docker-node:npmci | ||||||
|  |   stage: metadata | ||||||
|  |   script: | ||||||
|  |     - npmci command npm install -g typedoc typescript | ||||||
|  |     - npmci npm install | ||||||
|  |     - npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/ | ||||||
|  |   tags: | ||||||
|  |     - docker | ||||||
|  |     - notpriv | ||||||
|  |   only: | ||||||
|  |     - tags | ||||||
|  |   artifacts: | ||||||
|  |     expire_in: 1 week | ||||||
|  |     paths: | ||||||
|  |     - public | ||||||
|  |   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 | ||||||
							
								
								
									
										70
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,70 @@ | |||||||
|  | # tsn | ||||||
|  |  | ||||||
|  | ## Availabililty | ||||||
|  |  | ||||||
|  | [](https://www.npmjs.com/package/tsn) | ||||||
|  | [](https://gitlab.com/pushrocks/tsn) | ||||||
|  | [](https://github.com/pushrocks/tsn) | ||||||
|  | [](https://pushrocks.gitlab.io/tsn/) | ||||||
|  |  | ||||||
|  | ## Status for master | ||||||
|  |  | ||||||
|  | [](https://gitlab.com/pushrocks/tsn/commits/master) | ||||||
|  | [](https://gitlab.com/pushrocks/tsn/commits/master) | ||||||
|  | [](https://david-dm.org/pushrocks/tsn) | ||||||
|  | [](https://www.bithound.io/github/pushrocks/tsn/master/dependencies/npm) | ||||||
|  | [](https://www.bithound.io/github/pushrocks/tsn) | ||||||
|  | [](https://nodejs.org/dist/latest-v6.x/docs/api/) | ||||||
|  | [](https://nodejs.org/dist/latest-v6.x/docs/api/) | ||||||
|  | [](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() | ||||||
|  | ); | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | [](https://push.rocks) | ||||||
							
								
								
									
										3
									
								
								cli.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								cli.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | |||||||
|  | #!/usr/bin/env node | ||||||
|  | process.env.CLI_CALL_TSBUILD = 'true' | ||||||
|  | var index = require("./dist/index.js"); | ||||||
							
								
								
									
										4
									
								
								cli.ts.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								cli.ts.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | |||||||
|  | #!/usr/bin/env node | ||||||
|  | process.env.CLI_CALL_TSBUILD = 'true'; | ||||||
|  | require('@gitzone/tsrun'); | ||||||
|  | require('./ts/index'); | ||||||
							
								
								
									
										8
									
								
								npmextra.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								npmextra.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | |||||||
|  | { | ||||||
|  |   "npmci": { | ||||||
|  |     "npmGlobalTools": [ | ||||||
|  |       "typescript" | ||||||
|  |     ], | ||||||
|  |     "npmAccessLevel": "public" | ||||||
|  |   } | ||||||
|  | } | ||||||
							
								
								
									
										1043
									
								
								package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										1043
									
								
								package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										37
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | |||||||
|  | { | ||||||
|  |   "name": "tsn", | ||||||
|  |   "version": "2.0.15", | ||||||
|  |   "private": false, | ||||||
|  |   "description": "TypeScript nightly to easily make use of latest features", | ||||||
|  |   "main": "dist/index.js", | ||||||
|  |   "typings": "dist/index.d.ts", | ||||||
|  |   "scripts": { | ||||||
|  |     "test": "tsrun test/test.ts", | ||||||
|  |     "build": "node cli.ts.js" | ||||||
|  |   }, | ||||||
|  |   "repository": { | ||||||
|  |     "type": "git", | ||||||
|  |     "url": "git+ssh://git@gitlab.com/pushrocks/tsn.git" | ||||||
|  |   }, | ||||||
|  |   "keywords": [ | ||||||
|  |     "TypeScript" | ||||||
|  |   ], | ||||||
|  |   "author": "Lossless GmbH", | ||||||
|  |   "license": "MIT", | ||||||
|  |   "bugs": { | ||||||
|  |     "url": "https://gitlab.com/pushrocks/tsn/issues" | ||||||
|  |   }, | ||||||
|  |   "homepage": "https://gitlab.com/pushrocks/tsn#README", | ||||||
|  |   "dependencies": { | ||||||
|  |     "@pushrocks/smartfile": "^6.0.3", | ||||||
|  |     "@pushrocks/smartpath": "^4.0.1", | ||||||
|  |     "@pushrocks/smartpromise": "^2.0.5", | ||||||
|  |     "smartlog": "^1.0.3", | ||||||
|  |     "typescript": "^2.9.2" | ||||||
|  |   }, | ||||||
|  |   "devDependencies": { | ||||||
|  |     "@gitzone/tsrun": "^1.1.9", | ||||||
|  |     "@pushrocks/tapbundle": "^3.0.1", | ||||||
|  |     "@types/node": "^10.5.3" | ||||||
|  |   } | ||||||
|  | } | ||||||
							
								
								
									
										4
									
								
								test/assets/output/tocompile.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								test/assets/output/tocompile.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | |||||||
|  | declare class test { | ||||||
|  |     test: string[]; | ||||||
|  |     constructor(); | ||||||
|  | } | ||||||
							
								
								
									
										9
									
								
								test/assets/output/tocompile.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								test/assets/output/tocompile.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | |||||||
|  | console.log('test'); | ||||||
|  | console.log('test2'); | ||||||
|  | class test { | ||||||
|  |     constructor() { | ||||||
|  |         this.test = []; | ||||||
|  |         console.log('hi'); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9jb21waWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdG9jb21waWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sQ0FBQyxHQUFHLENBQUMsTUFBTSxDQUFDLENBQUM7QUFDcEIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsQ0FBQztBQUNyQjtJQUVFO1FBREEsU0FBSSxHQUFhLEVBQUUsQ0FBQztRQUVsQixPQUFPLENBQUMsR0FBRyxDQUFDLElBQUksQ0FBQyxDQUFDO0lBQ3BCLENBQUM7Q0FDRiJ9 | ||||||
							
								
								
									
										0
									
								
								test/assets/output/tocompile2.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								test/assets/output/tocompile2.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
								
								
									
										2
									
								
								test/assets/output/tocompile2.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								test/assets/output/tocompile2.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | |||||||
|  | console.log('hello'); | ||||||
|  | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9jb21waWxlMi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RvY29tcGlsZTIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsQ0FBQyJ9 | ||||||
							
								
								
									
										8
									
								
								test/assets/tocompile.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								test/assets/tocompile.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | |||||||
|  | console.log('test'); | ||||||
|  | console.log('test2'); | ||||||
|  | class test { | ||||||
|  |   test: string[] = []; | ||||||
|  |   constructor() { | ||||||
|  |     console.log('hi'); | ||||||
|  |   } | ||||||
|  | } | ||||||
							
								
								
									
										1
									
								
								test/assets/tocompile2.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								test/assets/tocompile2.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | |||||||
|  | console.log('hello'); | ||||||
							
								
								
									
										19
									
								
								test/test.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								test/test.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | |||||||
|  | import { tap, expect } from '@pushrocks/tapbundle'; | ||||||
|  |  | ||||||
|  | import * as tsn from '../ts/index'; | ||||||
|  |  | ||||||
|  | let assetfiles: string[] = ['./test/assets/tocompile.ts', './test/assets/tocompile2.ts']; | ||||||
|  |  | ||||||
|  | let assetfiles2 = { | ||||||
|  |   './test/assets/**/!(*.d.ts|*.js|output)': './test/assets/output' | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | tap.test('should convert files from an array with single files to output', async tools => { | ||||||
|  |   tsn.compileFileArray(assetfiles, { outDir: './test/assets/output' }); | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | tap.test('should convert files from an array with single files to output', async tools => { | ||||||
|  |   tsn.compileGlobStringObject(assetfiles2); | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | tap.start(); | ||||||
							
								
								
									
										9
									
								
								ts/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								ts/index.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | |||||||
|  | export * from "./tsbuild.exports"; | ||||||
|  |  | ||||||
|  | import * as tsbuild from './tsbuild.exports' | ||||||
|  |  | ||||||
|  | if (process.env.CLI_CALL_TSBUILD === "true") { | ||||||
|  |   tsbuild.compileGlobStringObject({ | ||||||
|  |     "./ts/**/*.ts": "./dist" | ||||||
|  |   }) | ||||||
|  | } | ||||||
							
								
								
									
										78
									
								
								ts/tsbuild.classes.compiler.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								ts/tsbuild.classes.compiler.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,78 @@ | |||||||
|  | // import all the stuff we need | ||||||
|  | import * as plugins from './tsbuild.plugins'; | ||||||
|  | import { CompilerOptions } from 'typescript'; | ||||||
|  | export { CompilerOptions, ScriptTarget, ModuleKind } from 'typescript'; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * the default typescript compilerOptions | ||||||
|  |  */ | ||||||
|  | export const compilerOptionsDefault: CompilerOptions = { | ||||||
|  |   declaration: true, | ||||||
|  |   emitDecoratorMetadata: true, | ||||||
|  |   experimentalDecorators: true, | ||||||
|  |   inlineSourceMap: true, | ||||||
|  |   noEmitOnError: false, | ||||||
|  |   outDir: 'dist/', | ||||||
|  |   module: plugins.typescript.ModuleKind.CommonJS, | ||||||
|  |   lib: [ | ||||||
|  |     'es2016', | ||||||
|  |     'es2017' | ||||||
|  |   ], | ||||||
|  |   noImplicitAny: false, | ||||||
|  |   target: plugins.typescript.ScriptTarget.ES2015 | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * merges compilerOptions with the default compiler options | ||||||
|  |  */ | ||||||
|  | export const mergeCompilerOptions = function(customTsOptions: CompilerOptions): CompilerOptions { | ||||||
|  |   // create merged options | ||||||
|  |   let mergedOptions: CompilerOptions = { | ||||||
|  |     ...compilerOptionsDefault, | ||||||
|  |     ...customTsOptions | ||||||
|  |   }; | ||||||
|  |  | ||||||
|  |   return mergedOptions; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * the internal main compiler function that compiles the files | ||||||
|  |  */ | ||||||
|  | export const compiler = ( | ||||||
|  |   fileNames: string[], | ||||||
|  |   options: plugins.typescript.CompilerOptions | ||||||
|  | ): Promise<any[]> => { | ||||||
|  |   console.log(options); | ||||||
|  |   let done = plugins.smartpromise.defer<any[]>(); | ||||||
|  |   let program = plugins.typescript.createProgram(fileNames, options); | ||||||
|  |   let emitResult = program.emit(); | ||||||
|  |  | ||||||
|  |   // implement check only | ||||||
|  |   /*let emitResult = program.emit(undefined,(args) => { | ||||||
|  |     console.log(args) | ||||||
|  |   });*/ | ||||||
|  |  | ||||||
|  |   let allDiagnostics = plugins.typescript | ||||||
|  |     .getPreEmitDiagnostics(program) | ||||||
|  |     .concat(emitResult.diagnostics); | ||||||
|  |   try { | ||||||
|  |     allDiagnostics.forEach(diagnostic => { | ||||||
|  |       let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); | ||||||
|  |       let message = plugins.typescript.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); | ||||||
|  |       console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); | ||||||
|  |     }); | ||||||
|  |   } catch (err) { | ||||||
|  |     // console.log(allDiagnostics) | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   let exitCode = emitResult.emitSkipped ? 1 : 0; | ||||||
|  |   if (exitCode === 0) { | ||||||
|  |     console.log('TypeScript emit succeeded!'); | ||||||
|  |     done.resolve(emitResult.emittedFiles); | ||||||
|  |   } else { | ||||||
|  |     console.error('TypeScript emit failed. Please investigate!'); | ||||||
|  |     process.exit(exitCode); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   return done.promise; | ||||||
|  | }; | ||||||
							
								
								
									
										52
									
								
								ts/tsbuild.exports.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								ts/tsbuild.exports.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | |||||||
|  | import * as plugins from './tsbuild.plugins'; | ||||||
|  | import { compiler, CompilerOptions, mergeCompilerOptions } from './tsbuild.classes.compiler'; | ||||||
|  |  | ||||||
|  | export * from './tsbuild.classes.compiler'; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * compile am array of absolute file paths | ||||||
|  |  */ | ||||||
|  | export let compileFileArray = ( | ||||||
|  |   fileStringArrayArg: string[], | ||||||
|  |   compilerOptionsArg: CompilerOptions = {} | ||||||
|  | ): Promise<any[]> => { | ||||||
|  |   return compiler(fileStringArrayArg, mergeCompilerOptions(compilerOptionsArg)); | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * compile advanced glob configurations | ||||||
|  |  * @param globStringArrayArg a array of glob strings | ||||||
|  |  * { | ||||||
|  |  *     './some/origin/folder/**\/*.ts': './some/destination/folder' | ||||||
|  |  * } | ||||||
|  |  */ | ||||||
|  | export let compileGlobStringObject = async ( | ||||||
|  |   globStringObjectArg: any, | ||||||
|  |   tsOptionsArg: CompilerOptions = {}, | ||||||
|  |   cwdArg: string = process.cwd() | ||||||
|  | ) => { | ||||||
|  |   let compiledFiles = []; | ||||||
|  |   for (let keyArg in globStringObjectArg) { | ||||||
|  |     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( | ||||||
|  |       fileTreeArray, | ||||||
|  |       cwdArg | ||||||
|  |     ); | ||||||
|  |     let destDir: string = plugins.smartpath.transform.toAbsolute( | ||||||
|  |       globStringObjectArg[keyArg], | ||||||
|  |       cwdArg | ||||||
|  |     ); | ||||||
|  |     tsOptionsArg = { | ||||||
|  |       ...tsOptionsArg, | ||||||
|  |       outDir: destDir | ||||||
|  |     }; | ||||||
|  |     compiledFiles = compiledFiles.concat( | ||||||
|  |       compiledFiles, | ||||||
|  |       await compileFileArray(absoluteFilePathArray, tsOptionsArg) | ||||||
|  |     ); | ||||||
|  |   } | ||||||
|  |   return compiledFiles; | ||||||
|  | }; | ||||||
							
								
								
									
										6
									
								
								ts/tsbuild.plugins.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								ts/tsbuild.plugins.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | |||||||
|  | import * as smartfile from '@pushrocks/smartfile'; | ||||||
|  | import * as smartpath from '@pushrocks/smartpath'; | ||||||
|  | import * as smartpromise from '@pushrocks/smartpromise'; | ||||||
|  | import * as typescript from 'typescript'; | ||||||
|  |  | ||||||
|  | export { smartfile, smartpath, smartpromise, typescript }; | ||||||
							
								
								
									
										14
									
								
								tsconfig.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								tsconfig.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | |||||||
|  | { | ||||||
|  |   "compilerOptions": { | ||||||
|  |     "outDir": "dist/", | ||||||
|  |     "module": "commonjs", | ||||||
|  |     "target": "es2015", | ||||||
|  |     "lib":[ | ||||||
|  |       "es2016", | ||||||
|  |       "es2017" | ||||||
|  |     ] | ||||||
|  |   }, | ||||||
|  |   "include": [ | ||||||
|  |     "ts/**/*.ts" | ||||||
|  |   ] | ||||||
|  | } | ||||||
							
								
								
									
										3
									
								
								tslint.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								tslint.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | |||||||
|  | { | ||||||
|  |     "extends": "tslint-config-standard" | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user