Compare commits

...

42 Commits

Author SHA1 Message Date
df9c7204c7 1.2.3 2019-04-08 16:30:24 +02:00
568472e715 fix(core): update ES2017 2019-04-08 16:30:24 +02:00
0ba6863e28 1.2.2 2019-04-08 16:17:58 +02:00
d5c63cd24c fix(core): update 2019-04-08 16:17:57 +02:00
460babd675 1.2.1 2019-03-02 23:03:06 +01:00
98cde0edb4 fix(readme): update 2019-03-02 23:03:05 +01:00
1d5766435a 1.2.0 2019-03-02 22:38:01 +01:00
92ac844954 feat(dependencies and cache): remove caching 2019-03-02 22:38:01 +01:00
9ae4f9f82b 1.1.17 2018-12-06 00:46:26 +01:00
3df2922085 fix(core): update 2018-12-06 00:46:26 +01:00
3eb29c729e 1.1.16 2018-12-06 00:26:17 +01:00
cadc2cd629 fix(core): update 2018-12-06 00:26:17 +01:00
399ee0b4ca 1.1.15 2018-12-06 00:22:12 +01:00
ac5d8d1614 fix(core): update 2018-12-06 00:22:12 +01:00
6349753cce 1.1.14 2018-12-06 00:21:20 +01:00
3897e15a7e fix(core): update 2018-12-06 00:21:20 +01:00
2582710e8f 1.1.13 2018-10-14 18:51:41 +02:00
4cd06d040d 1.1.12 2018-08-08 23:14:11 +02:00
5eb3ba901a fix(dependencies): update 2018-08-08 23:14:11 +02:00
dd5b101224 1.1.11 2018-08-08 22:36:17 +02:00
972583a3a7 fix(CI): remove obsolete build dependencies 2018-08-08 22:36:16 +02:00
ef3c636976 1.1.10 2018-08-08 22:33:07 +02:00
b1ec59e042 fix(dependencies): update 2018-08-08 22:33:07 +02:00
84275f6804 1.1.9 2018-07-13 23:16:45 +02:00
b02edb7536 fix(core): add readme 2018-07-13 23:16:45 +02:00
4624cce39a 1.1.8 2018-07-13 23:14:45 +02:00
d4938f12cd fix(documentation): update 2018-07-13 23:14:45 +02:00
78157d474a 1.1.7 2018-07-13 23:01:10 +02:00
8f4f22b83f fix(core): update 2018-07-13 23:01:09 +02:00
90a97cb0eb 1.1.6 2018-07-13 22:51:10 +02:00
5bacff743d fix(core): update 2018-07-13 22:51:10 +02:00
f5d4b9ff5b 1.1.5 2018-07-13 22:37:56 +02:00
4e68019aa9 fix(add typedoc): update 2018-07-13 22:37:55 +02:00
022a919adf 1.1.4 2018-07-13 22:33:10 +02:00
d52315382e 1.1.3 2018-07-13 22:33:03 +02:00
5210b09c04 fix(core): update 2018-07-13 22:33:02 +02:00
8e2695a06f 1.1.2 2018-07-09 00:00:08 +02:00
7e8fe1bcba fix(typescript): add experimentalDecorators = true to CompilerOptions 2018-07-09 00:00:07 +02:00
c603ae0c87 1.1.1 2018-07-03 14:44:58 +02:00
4e70a1ef1a fix(CI): update default ci config 2018-07-03 14:44:57 +02:00
74df4b7b2b 1.1.0 2018-07-03 14:40:59 +02:00
51808f230a feat(cache): enable --nocache cli option 2018-07-03 14:40:58 +02:00
11 changed files with 1045 additions and 786 deletions

View File

@ -26,6 +26,7 @@ mirror:
snyk:
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
@ -33,24 +34,39 @@ snyk:
- docker
- notpriv
sast:
stage: security
image: registry.gitlab.com/hosttoday/ht-docker-dbase:npmci
variables:
DOCKER_DRIVER: overlay2
allow_failure: true
services:
- docker:stable-dind
script:
- npmci npm prepare
- npmci npm install
- npmci command npm run build
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env SAST_CONFIDENCE_LEVEL="${SAST_CONFIDENCE_LEVEL:-3}"
--volume "$PWD:/code"
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/sast:$SP_VERSION" /app/bin/run /code
artifacts:
reports:
sast: gl-sast-report.json
tags:
- docker
- priv
# ====================
# 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 npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
@ -62,6 +78,7 @@ testLTS:
testSTABLE:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
@ -117,8 +134,10 @@ pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata
script:
- npmci command npm install -g npmpage
- npmci command npmpage
- npmci command npm install -g typedoc typescript
- npmci npm prepare
- npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
tags:
- docker
- notpriv
@ -128,3 +147,4 @@ pages:
expire_in: 1 week
paths:
- public
allow_failure: true

24
dist/index.js vendored
View File

@ -1,14 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
const tsNode = require("./tsnode");
tsNode.register({
const tsNode = require("ts-node");
const defaultTsNodeOptions = {
compilerOptions: {
lib: ['es2016', 'es2017']
lib: ['es2016', 'es2017'],
target: 'es2017',
experimentalDecorators: true
},
skipIgnore: true,
cacheDirectory: path.join(__dirname, '../tscache')
});
skipIgnore: true
};
if (process.argv.includes('--web')) {
const previousCompilerOptions = defaultTsNodeOptions.compilerOptions;
defaultTsNodeOptions.compilerOptions = Object.assign({}, previousCompilerOptions, { lib: ['es2016', 'es2017', 'dom'], target: 'es2015' // Script Target should be a string -> 2 is for ES2015
});
}
if (process.argv.includes('--nocache')) {
// currently caching is not used
}
tsNode.register(defaultTsNodeOptions);
if (process.env.CLI_CALL_TSRUN) {
// contents of argv array
// process.argv[0] -> node Executable
@ -17,4 +27,4 @@ if (process.env.CLI_CALL_TSRUN) {
const pathToLoad = path.join(process.cwd(), pathToTsFile);
Promise.resolve().then(() => require(pathToLoad));
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDZCQUE2QjtBQUM3Q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FPLENBQUMsRUFBRTtJQUNsQyxNQUFNLHVCQUF1QixHQUFHLG9CQUFvQixDQUFDLGVBQWtDLENBQUM7SUFDeEYsb0JBQW9CLENBQUMsZUFBZSxxQkFDL0IsdUJBQXVCLElBQzFCLEdBQUcsRUFBRSxDQUFDLFFBQVEsRUFBRSxRQUFRLEVBQUUsS0FBSyxDQUFDLEVBQ2hDLE1BQU0sRUFBTyxRQUFRLENBQUMsc0RBQXNEO09BQzdFLENBQUM7Q0FDSDtBQUVELElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsV0FBVyxDQUFDLEVBQUU7SUFDdEMsZ0NBQWdDO0NBQ2pDO0FBRUQsTUFBTSxDQUFDLFFBQVEsQ0FBQyxvQkFBb0IsQ0FBQyxDQUFDO0FBRXRDLElBQUksT0FBTyxDQUFDLEdBQUcsQ0FBQyxjQUFjLEVBQUU7SUFDOUIseUJBQXlCO0lBQ3pCLHFDQUFxQztJQUNyQyxzQ0FBc0M7SUFDdEMsTUFBTSxZQUFZLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQztJQUVyQyxNQUFNLFVBQVUsR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsRUFBRSxZQUFZLENBQUMsQ0FBQztJQUMxRCxxQ0FBTyxVQUFVLEdBQUU7Q0FDcEIifQ==

99
dist/tsnode.d.ts vendored
View File

@ -1,99 +0,0 @@
import { BaseError } from 'make-error';
import * as _ts from 'typescript';
/**
* @internal
*/
export declare const INSPECT_CUSTOM: string | symbol;
/**
* Common TypeScript interfaces between versions.
*/
export interface TSCommon {
version: typeof _ts.version;
sys: typeof _ts.sys;
ScriptSnapshot: typeof _ts.ScriptSnapshot;
displayPartsToString: typeof _ts.displayPartsToString;
createLanguageService: typeof _ts.createLanguageService;
getDefaultLibFilePath: typeof _ts.getDefaultLibFilePath;
getPreEmitDiagnostics: typeof _ts.getPreEmitDiagnostics;
flattenDiagnosticMessageText: typeof _ts.flattenDiagnosticMessageText;
transpileModule: typeof _ts.transpileModule;
ModuleKind: typeof _ts.ModuleKind;
ScriptTarget: typeof _ts.ScriptTarget;
findConfigFile: typeof _ts.findConfigFile;
readConfigFile: typeof _ts.readConfigFile;
parseJsonConfigFileContent: typeof _ts.parseJsonConfigFileContent;
formatDiagnostics: typeof _ts.formatDiagnostics;
formatDiagnosticsWithColorAndContext: typeof _ts.formatDiagnosticsWithColorAndContext;
}
/**
* Export the current version.
*/
export declare const VERSION: any;
/**
* Registration options.
*/
export interface Options {
pretty?: boolean | null;
typeCheck?: boolean | null;
transpileOnly?: boolean | null;
files?: boolean | null;
cache?: boolean | null;
cacheDirectory?: string;
compiler?: string;
ignore?: string | string[];
project?: string;
skipIgnore?: boolean | null;
skipProject?: boolean | null;
compilerOptions?: object;
ignoreDiagnostics?: number | string | Array<number | string>;
readFile?: (path: string) => string | undefined;
fileExists?: (path: string) => boolean;
transformers?: _ts.CustomTransformers;
}
/**
* Information retrieved from type info check.
*/
export interface TypeInfo {
name: string;
comment: string;
}
/**
* Default register options.
*/
export declare const DEFAULTS: Options;
/**
* Split a string array of values.
*/
export declare function split(value: string | undefined): string[];
/**
* Parse a string as JSON.
*/
export declare function parse(value: string | undefined): object | undefined;
/**
* Replace backslashes with forward slashes.
*/
export declare function normalizeSlashes(value: string): string;
/**
* TypeScript diagnostics error.
*/
export declare class TSError extends BaseError {
diagnosticText: string;
diagnosticCodes: number[];
name: string;
constructor(diagnosticText: string, diagnosticCodes: number[]);
}
/**
* Return type for registering `ts-node`.
*/
export interface Register {
cwd: string;
extensions: string[];
cachedir: string;
ts: TSCommon;
compile(code: string, fileName: string, lineOffset?: number): string;
getTypeInfo(code: string, fileName: string, position: number): TypeInfo;
}
/**
* Register TypeScript compiler.
*/
export declare function register(opts?: Options): Register;

439
dist/tsnode.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,11 +1,17 @@
{
"npmts": {
},
"npmts": {},
"npmci": {
"npmGlobalTools": [
"@gitzone/npmts",
"ts-node"
],
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"gitzone": {
"module": {
"githost": "gitlab.com",
"gitscope": "gitzone",
"gitrepo": "tsrun",
"shortDescription": "run typescript programs efficiently",
"npmPackagename": "@gitzone/tsrun",
"license": "MIT"
}
}
}

1090
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@gitzone/tsrun",
"version": "1.0.18",
"version": "1.2.3",
"description": "run typescript programs efficiently",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
@ -10,18 +10,20 @@
"tsrun": "./cli.js"
},
"scripts": {
"test": "(npmts --notest && node ./cli.js test/test.ts)",
"test": "(tsbuild && node ./cli.js test/test.ts)",
"format": "(gitzone format)",
"build": "echo \"Not needed for now\"",
"postinstall": "(node ./cli.js scripts/postinstall.ts)"
"build": "(tsbuild)"
},
"devDependencies": {
"@types/node": "^10.3.0"
"@types/node": "^11.13.0",
"tslint": "^5.15.0",
"tslint-config-prettier": "^1.18.0"
},
"dependencies": {
"smartfile": "^4.2.28",
"ts-node": "^7.0.0",
"typescript": "^2.9.1"
"@gitzone/tsbuild": "^2.1.8",
"@pushrocks/smartfile": "^7.0.0",
"ts-node": "^8.0.3",
"typescript": "^3.4.2"
},
"private": false
}

38
readme.md Normal file
View File

@ -0,0 +1,38 @@
# @gitzone/tsrun
run typescript programs efficiently
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@gitzone/tsrun)
* [gitlab.com (source)](https://gitlab.com/gitzone/tsrun)
* [github.com (source mirror)](https://github.com/gitzone/tsrun)
* [docs (typedoc)](https://gitzone.gitlab.io/tsrun/)
## Status for master
[![build status](https://gitlab.com/gitzone/tsrun/badges/master/build.svg)](https://gitlab.com/gitzone/tsrun/commits/master)
[![coverage report](https://gitlab.com/gitzone/tsrun/badges/master/coverage.svg)](https://gitlab.com/gitzone/tsrun/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@gitzone/tsrun.svg)](https://www.npmjs.com/package/@gitzone/tsrun)
[![Known Vulnerabilities](https://snyk.io/test/npm/@gitzone/tsrun/badge.svg)](https://snyk.io/test/npm/@gitzone/tsrun)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
## Usage
Use TypeScript for best in class instellisense.
To simply run a TypeScript file on the fly type
```typescript
tsrun myfiletorun.ts
```
There are options available:
- `--web` will inject browser types. this is useful when testing code with polyfills on node, but that is meant for the browser later on.
For further information read the linked docs at the top of this readme.
> MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://gitzone.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)

View File

@ -1,10 +0,0 @@
// This file takes care of some postinstall actions like clearing the TypeScript cache.
import * as smartfile from 'smartfile';
import * as path from 'path';
const run = async () => {
const tsCacheDir = path.join(__dirname, '../tscache');
await smartfile.fs.ensureEmptyDir(tsCacheDir);
}
run();

View File

@ -1,20 +1,37 @@
import * as path from 'path';
import * as tsNode from 'ts-node';
import { CompilerOptions } from 'typescript';
tsNode.register({
compilerOptions: {
lib: [ 'es2016', 'es2017' ]
const defaultTsNodeOptions: tsNode.Options = {
compilerOptions: <CompilerOptions>{
lib: ['es2016', 'es2017'],
target: <any>'es2017', // Script Target should be a string -> 2 is for ES2015
experimentalDecorators: true
},
skipIgnore: true,
cacheDirectory: path.join(__dirname, '../tscache')
});
skipIgnore: true
};
if (process.argv.includes('--web')) {
const previousCompilerOptions = defaultTsNodeOptions.compilerOptions as CompilerOptions;
defaultTsNodeOptions.compilerOptions = {
...previousCompilerOptions,
lib: ['es2016', 'es2017', 'dom'],
target: <any>'es2015' // Script Target should be a string -> 2 is for ES2015
};
}
if (process.argv.includes('--nocache')) {
// currently caching is not used
}
tsNode.register(defaultTsNodeOptions);
if (process.env.CLI_CALL_TSRUN) {
// contents of argv array
// process.argv[0] -> node Executable
// process.argv[1] -> tsrun executable
const pathToTsFile = process.argv[2]
const pathToTsFile = process.argv[2];
const pathToLoad = path.join(process.cwd(), pathToTsFile);
import(pathToLoad);
}

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