Compare commits
130 Commits
Author | SHA1 | Date | |
---|---|---|---|
5efd905068 | |||
ae01679474 | |||
f0bdfa9a65 | |||
a88cf067a1 | |||
c5cd30e20e | |||
02eb0c5435 | |||
6ab3ed21e0 | |||
2f5374be50 | |||
1577265f6b | |||
3b9532bb70 | |||
bcb1ccc6e7 | |||
1dde4c8277 | |||
3a6fc44fbb | |||
a0d523513b | |||
0715f88189 | |||
4a50ae3b00 | |||
2b7c3b78f6 | |||
142667ac87 | |||
9e55126adf | |||
5271f0153e | |||
ba0aaf2793 | |||
1f46e387e7 | |||
03625bfca4 | |||
cc92e3e9ca | |||
c1e66d498a | |||
bfbb802e88 | |||
655fd8b92e | |||
a240cdfde1 | |||
2af7682cf0 | |||
c62619bd27 | |||
ffaf54f1de | |||
2c6b955819 | |||
9bb13e1ede | |||
d9bd5e5340 | |||
b76de3e04d | |||
808726d1df | |||
d011f10b9b | |||
d1baa20aad | |||
71779693d7 | |||
1113251aea | |||
e41cd896bb | |||
ba44007fb2 | |||
8d1362f14b | |||
61ceb03962 | |||
ab3ec90245 | |||
b51cda08c4 | |||
b8332e1de4 | |||
da9a73bc79 | |||
26bf39abae | |||
b66b2083ab | |||
e40c0151bc | |||
fe97fcd193 | |||
5174d9ccc6 | |||
e89c3eda66 | |||
6d4c9f390a | |||
3fc3421857 | |||
e1803dabfa | |||
282d8b2b93 | |||
76dd9707fe | |||
269e54c717 | |||
dd33a359c3 | |||
0caaac2a67 | |||
14a043be1e | |||
de44be741d | |||
d15500d5a0 | |||
7e99fd703f | |||
fa5462c0bc | |||
f8736d3556 | |||
45bba88f46 | |||
daafe0b6ff | |||
3d905de2be | |||
815008e881 | |||
4641cc7cad | |||
dbf324682c | |||
8f5c302b6c | |||
e5bf2ac20c | |||
731931452a | |||
0b3730f7e5 | |||
aecc54aab0 | |||
e3fa66ff07 | |||
bb3b918521 | |||
ba9eaa5091 | |||
0e281ab257 | |||
0e14522287 | |||
4d93e2e728 | |||
ce9a350521 | |||
df9c7204c7 | |||
568472e715 | |||
0ba6863e28 | |||
d5c63cd24c | |||
460babd675 | |||
98cde0edb4 | |||
1d5766435a | |||
92ac844954 | |||
9ae4f9f82b | |||
3df2922085 | |||
3eb29c729e | |||
cadc2cd629 | |||
399ee0b4ca | |||
ac5d8d1614 | |||
6349753cce | |||
3897e15a7e | |||
2582710e8f | |||
4cd06d040d | |||
5eb3ba901a | |||
dd5b101224 | |||
972583a3a7 | |||
ef3c636976 | |||
b1ec59e042 | |||
84275f6804 | |||
b02edb7536 | |||
4624cce39a | |||
d4938f12cd | |||
78157d474a | |||
8f4f22b83f | |||
90a97cb0eb | |||
5bacff743d | |||
f5d4b9ff5b | |||
4e68019aa9 | |||
022a919adf | |||
d52315382e | |||
5210b09c04 | |||
8e2695a06f | |||
7e8fe1bcba | |||
c603ae0c87 | |||
4e70a1ef1a | |||
74df4b7b2b | |||
51808f230a | |||
42f2f132f1 | |||
a3fb24eba3 |
17
.gitignore
vendored
17
.gitignore
vendored
@ -1,7 +1,20 @@
|
|||||||
.nogit/
|
.nogit/
|
||||||
node_modules/
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
pages/
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
.yarn/
|
.yarn/
|
||||||
tscache
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
# custom
|
134
.gitlab-ci.yml
134
.gitlab-ci.yml
@ -1,125 +1,122 @@
|
|||||||
# 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
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- pnpm install -g pnpm
|
||||||
|
- pnpm install -g @shipzone/npmci
|
||||||
|
- npmci npm prepare
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
# ====================
|
# ====================
|
||||||
mirror:
|
# ====================
|
||||||
|
# security stage
|
||||||
|
# ====================
|
||||||
|
auditProductionDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command pnpm audit --audit-level=high --prod
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
snyk:
|
auditDevDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g snyk
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command pnpm audit --audit-level=high --dev
|
||||||
- npmci command snyk test
|
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# 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:
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci node install lts
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
testBuild:
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm publish
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# metadata stage
|
# metadata stage
|
||||||
# ====================
|
# ====================
|
||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
image: docker:stable
|
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
services:
|
only:
|
||||||
- docker:stable-dind
|
- tags
|
||||||
script:
|
script:
|
||||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
- npmci command npm install -g typescript
|
||||||
- docker run
|
- npmci npm prepare
|
||||||
--env SOURCE_CODE="$PWD"
|
- npmci npm install
|
||||||
--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:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- priv
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci trigger
|
- npmci trigger
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmci
|
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g npmpage
|
- npmci node install stable
|
||||||
- npmci command npmpage
|
- npmci npm install
|
||||||
|
- npmci command npm run buildDocs
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
only:
|
only:
|
||||||
@ -127,4 +124,5 @@ pages:
|
|||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
|
allow_failure: true
|
||||||
|
4
.snyk
4
.snyk
@ -1,4 +0,0 @@
|
|||||||
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
|
|
||||||
version: v1.12.0
|
|
||||||
ignore: {}
|
|
||||||
patch: {}
|
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"command": "npm test",
|
||||||
|
"name": "Run npm test",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "node-terminal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal 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", "wcc"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
4
cli.child.ts
Normal file
4
cli.child.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
process.env.CLI_CALL = 'true';
|
||||||
|
import * as cliTool from './ts/index.js';
|
||||||
|
cliTool.runCli();
|
5
cli.js
5
cli.js
@ -1,3 +1,4 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
process.env.CLI_CALL_TSRUN = 'true'
|
process.env.CLI_CALL = 'true';
|
||||||
var index = require("./dist/index.js");
|
const cliTool = await import('./dist_ts/index.js');
|
||||||
|
cliTool.runCli();
|
||||||
|
5
cli.ts.js
Normal file
5
cli.ts.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
process.env.CLI_CALL = 'true';
|
||||||
|
|
||||||
|
import * as tsrun from '@gitzone/tsrun';
|
||||||
|
tsrun.runPath('./cli.child.js', import.meta.url);
|
@ -1 +0,0 @@
|
|||||||
.gitignore: ../gitignore/
|
|
1
dist/index.d.ts
vendored
1
dist/index.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
export {};
|
|
20
dist/index.js
vendored
20
dist/index.js
vendored
@ -1,20 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const path = require("path");
|
|
||||||
const tsNode = require("./tsnode");
|
|
||||||
tsNode.register({
|
|
||||||
compilerOptions: {
|
|
||||||
lib: ['es2016', 'es2017']
|
|
||||||
},
|
|
||||||
skipIgnore: true,
|
|
||||||
cacheDirectory: path.join(__dirname, '../tscache')
|
|
||||||
});
|
|
||||||
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 pathToLoad = path.join(process.cwd(), pathToTsFile);
|
|
||||||
Promise.resolve().then(() => require(pathToLoad));
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDZCQUE2QjtBQUM3QixtQ0FBbUM7QUFFbkMsTUFBTSxDQUFDLFFBQVEsQ0FBQztJQUNkLGVBQWUsRUFBRTtRQUNmLEdBQUcsRUFBRSxDQUFFLFFBQVEsRUFBRSxRQUFRLENBQUU7S0FDNUI7SUFDRCxVQUFVLEVBQUUsSUFBSTtJQUNoQixjQUFjLEVBQUUsSUFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLEVBQUUsWUFBWSxDQUFDO0NBQ25ELENBQUMsQ0FBQztBQUVILElBQUksT0FBTyxDQUFDLEdBQUcsQ0FBQyxjQUFjLEVBQUU7SUFDOUIseUJBQXlCO0lBQ3pCLHFDQUFxQztJQUNyQyxzQ0FBc0M7SUFDdEMsTUFBTSxZQUFZLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQTtJQUVwQyxNQUFNLFVBQVUsR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsRUFBRSxZQUFZLENBQUMsQ0FBQztJQUMxRCxxQ0FBTyxVQUFVLEdBQUU7Q0FDcEIifQ==
|
|
99
dist/tsnode.d.ts
vendored
99
dist/tsnode.d.ts
vendored
@ -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
439
dist/tsnode.js
vendored
File diff suppressed because one or more lines are too long
@ -1,11 +1,18 @@
|
|||||||
{
|
{
|
||||||
"npmts": {
|
"npmts": {},
|
||||||
},
|
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": [
|
"npmGlobalTools": [],
|
||||||
"@gitzone/npmts",
|
|
||||||
"ts-node"
|
|
||||||
],
|
|
||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "gitzone",
|
||||||
|
"gitrepo": "tsrun",
|
||||||
|
"description": "run typescript programs efficiently",
|
||||||
|
"npmPackagename": "@gitzone/tsrun",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
523
package-lock.json
generated
523
package-lock.json
generated
@ -1,523 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@gitzone/tsrun",
|
|
||||||
"version": "1.0.17",
|
|
||||||
"lockfileVersion": 1,
|
|
||||||
"requires": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@types/fs-extra": {
|
|
||||||
"version": "5.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-5.0.0.tgz",
|
|
||||||
"integrity": "sha512-qtxDULQKUenuaDLW003CgC+0T0eiAfH3BrH+vSt87GLzbz5EZ6Ox6mv9rMttvhDOatbb9nYh0E1m7ydoYwUrAg==",
|
|
||||||
"requires": {
|
|
||||||
"@types/node": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"@types/node": {
|
|
||||||
"version": "10.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.3.0.tgz",
|
|
||||||
"integrity": "sha512-hWzNviaVFIr1TqcRA8ou49JaSHp+Rfabmnqg2kNvusKqLhPU0rIsGPUj5WJJ7ld4Bb7qdgLmIhLfCD1qS08IVA=="
|
|
||||||
},
|
|
||||||
"@types/vinyl": {
|
|
||||||
"version": "2.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/vinyl/-/vinyl-2.0.2.tgz",
|
|
||||||
"integrity": "sha512-2iYpNuOl98SrLPBZfEN9Mh2JCJ2EI9HU35SfgBEb51DcmaHkhp8cKMblYeBqMQiwXMgAD3W60DbQ4i/UdLiXhw==",
|
|
||||||
"requires": {
|
|
||||||
"@types/node": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"argparse": {
|
|
||||||
"version": "1.0.10",
|
|
||||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
|
||||||
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
|
||||||
"requires": {
|
|
||||||
"sprintf-js": "~1.0.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"arrify": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz",
|
|
||||||
"integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0="
|
|
||||||
},
|
|
||||||
"balanced-match": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
|
||||||
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
|
|
||||||
},
|
|
||||||
"brace-expansion": {
|
|
||||||
"version": "1.1.11",
|
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
|
||||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
|
||||||
"requires": {
|
|
||||||
"balanced-match": "^1.0.0",
|
|
||||||
"concat-map": "0.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"buffer-from": {
|
|
||||||
"version": "1.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.0.tgz",
|
|
||||||
"integrity": "sha512-c5mRlguI/Pe2dSZmpER62rSCu0ryKmWddzRYsuXc50U2/g8jMOulc31VZMa4mYx31U5xsmSOpDCgH88Vl9cDGQ=="
|
|
||||||
},
|
|
||||||
"clone": {
|
|
||||||
"version": "2.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.1.tgz",
|
|
||||||
"integrity": "sha1-0hfR6WERjjrJpLi7oyhVU79kfNs="
|
|
||||||
},
|
|
||||||
"clone-buffer": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz",
|
|
||||||
"integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg="
|
|
||||||
},
|
|
||||||
"clone-stats": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz",
|
|
||||||
"integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA="
|
|
||||||
},
|
|
||||||
"cloneable-readable": {
|
|
||||||
"version": "1.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/cloneable-readable/-/cloneable-readable-1.1.2.tgz",
|
|
||||||
"integrity": "sha512-Bq6+4t+lbM8vhTs/Bef5c5AdEMtapp/iFb6+s4/Hh9MVTt8OLKH7ZOOZSCT+Ys7hsHvqv0GuMPJ1lnQJVHvxpg==",
|
|
||||||
"requires": {
|
|
||||||
"inherits": "^2.0.1",
|
|
||||||
"process-nextick-args": "^2.0.0",
|
|
||||||
"readable-stream": "^2.3.5"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"concat-map": {
|
|
||||||
"version": "0.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
|
||||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
|
|
||||||
},
|
|
||||||
"core-util-is": {
|
|
||||||
"version": "1.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
|
||||||
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
|
|
||||||
},
|
|
||||||
"define-properties": {
|
|
||||||
"version": "1.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.2.tgz",
|
|
||||||
"integrity": "sha1-g6c/L+pWmJj7c3GTyPhzyvbUXJQ=",
|
|
||||||
"requires": {
|
|
||||||
"foreach": "^2.0.5",
|
|
||||||
"object-keys": "^1.0.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"es-abstract": {
|
|
||||||
"version": "1.12.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.12.0.tgz",
|
|
||||||
"integrity": "sha512-C8Fx/0jFmV5IPoMOFPA9P9G5NtqW+4cOPit3MIuvR2t7Ag2K15EJTpxnHAYTzL+aYQJIESYeXZmDBfOBE1HcpA==",
|
|
||||||
"requires": {
|
|
||||||
"es-to-primitive": "^1.1.1",
|
|
||||||
"function-bind": "^1.1.1",
|
|
||||||
"has": "^1.0.1",
|
|
||||||
"is-callable": "^1.1.3",
|
|
||||||
"is-regex": "^1.0.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"es-to-primitive": {
|
|
||||||
"version": "1.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.1.1.tgz",
|
|
||||||
"integrity": "sha1-RTVSSKiJeQNLZ5Lhm7gfK3l13Q0=",
|
|
||||||
"requires": {
|
|
||||||
"is-callable": "^1.1.1",
|
|
||||||
"is-date-object": "^1.0.1",
|
|
||||||
"is-symbol": "^1.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"esprima": {
|
|
||||||
"version": "4.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz",
|
|
||||||
"integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw=="
|
|
||||||
},
|
|
||||||
"first-chunk-stream": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-2.0.0.tgz",
|
|
||||||
"integrity": "sha1-G97NuOCDwGZLkZRVgVd6Q6nzHXA=",
|
|
||||||
"requires": {
|
|
||||||
"readable-stream": "^2.0.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"foreach": {
|
|
||||||
"version": "2.0.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz",
|
|
||||||
"integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k="
|
|
||||||
},
|
|
||||||
"fs-extra": {
|
|
||||||
"version": "5.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-5.0.0.tgz",
|
|
||||||
"integrity": "sha512-66Pm4RYbjzdyeuqudYqhFiNBbCIuI9kgRqLPSHIlXHidW8NIQtVdkM1yeZ4lXwuhbTETv3EUGMNHAAw6hiundQ==",
|
|
||||||
"requires": {
|
|
||||||
"graceful-fs": "^4.1.2",
|
|
||||||
"jsonfile": "^4.0.0",
|
|
||||||
"universalify": "^0.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fs.realpath": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
|
||||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
|
||||||
},
|
|
||||||
"function-bind": {
|
|
||||||
"version": "1.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
|
|
||||||
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
|
|
||||||
},
|
|
||||||
"glob": {
|
|
||||||
"version": "7.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
|
|
||||||
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
|
|
||||||
"requires": {
|
|
||||||
"fs.realpath": "^1.0.0",
|
|
||||||
"inflight": "^1.0.4",
|
|
||||||
"inherits": "2",
|
|
||||||
"minimatch": "^3.0.4",
|
|
||||||
"once": "^1.3.0",
|
|
||||||
"path-is-absolute": "^1.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"graceful-fs": {
|
|
||||||
"version": "4.1.11",
|
|
||||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
|
|
||||||
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg="
|
|
||||||
},
|
|
||||||
"has": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
|
|
||||||
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
|
|
||||||
"requires": {
|
|
||||||
"function-bind": "^1.1.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"home": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/home/-/home-1.0.1.tgz",
|
|
||||||
"integrity": "sha1-lqQjzrSbmDeP9e886uBZpVf53TU=",
|
|
||||||
"requires": {
|
|
||||||
"os-homedir": "^1.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"inflight": {
|
|
||||||
"version": "1.0.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
|
||||||
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
|
|
||||||
"requires": {
|
|
||||||
"once": "^1.3.0",
|
|
||||||
"wrappy": "1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"inherits": {
|
|
||||||
"version": "2.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
|
||||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
|
|
||||||
},
|
|
||||||
"is-callable": {
|
|
||||||
"version": "1.1.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.3.tgz",
|
|
||||||
"integrity": "sha1-hut1OSgF3cM69xySoO7fdO52BLI="
|
|
||||||
},
|
|
||||||
"is-date-object": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz",
|
|
||||||
"integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY="
|
|
||||||
},
|
|
||||||
"is-regex": {
|
|
||||||
"version": "1.0.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz",
|
|
||||||
"integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=",
|
|
||||||
"requires": {
|
|
||||||
"has": "^1.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"is-symbol": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz",
|
|
||||||
"integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI="
|
|
||||||
},
|
|
||||||
"is-utf8": {
|
|
||||||
"version": "0.2.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz",
|
|
||||||
"integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI="
|
|
||||||
},
|
|
||||||
"isarray": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
|
||||||
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
|
|
||||||
},
|
|
||||||
"js-yaml": {
|
|
||||||
"version": "3.12.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz",
|
|
||||||
"integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==",
|
|
||||||
"requires": {
|
|
||||||
"argparse": "^1.0.7",
|
|
||||||
"esprima": "^4.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"jsonfile": {
|
|
||||||
"version": "4.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
|
|
||||||
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
|
|
||||||
"requires": {
|
|
||||||
"graceful-fs": "^4.1.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"make-error": {
|
|
||||||
"version": "1.3.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.4.tgz",
|
|
||||||
"integrity": "sha512-0Dab5btKVPhibSalc9QGXb559ED7G7iLjFXBaj9Wq8O3vorueR5K5jaE3hkG6ZQINyhA/JgG6Qk4qdFQjsYV6g=="
|
|
||||||
},
|
|
||||||
"minimatch": {
|
|
||||||
"version": "3.0.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
|
||||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
|
||||||
"requires": {
|
|
||||||
"brace-expansion": "^1.1.7"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"minimist": {
|
|
||||||
"version": "0.0.8",
|
|
||||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
|
||||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
|
|
||||||
},
|
|
||||||
"mkdirp": {
|
|
||||||
"version": "0.5.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
|
||||||
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
|
||||||
"requires": {
|
|
||||||
"minimist": "0.0.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"object-keys": {
|
|
||||||
"version": "1.0.12",
|
|
||||||
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz",
|
|
||||||
"integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag=="
|
|
||||||
},
|
|
||||||
"object.getownpropertydescriptors": {
|
|
||||||
"version": "2.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz",
|
|
||||||
"integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=",
|
|
||||||
"requires": {
|
|
||||||
"define-properties": "^1.1.2",
|
|
||||||
"es-abstract": "^1.5.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"once": {
|
|
||||||
"version": "1.4.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
|
||||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
|
||||||
"requires": {
|
|
||||||
"wrappy": "1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"os-homedir": {
|
|
||||||
"version": "1.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
|
|
||||||
"integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M="
|
|
||||||
},
|
|
||||||
"path-is-absolute": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
|
||||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
|
|
||||||
},
|
|
||||||
"pify": {
|
|
||||||
"version": "2.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
|
|
||||||
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw="
|
|
||||||
},
|
|
||||||
"process-nextick-args": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
|
|
||||||
"integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw=="
|
|
||||||
},
|
|
||||||
"readable-stream": {
|
|
||||||
"version": "2.3.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
|
||||||
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
|
|
||||||
"requires": {
|
|
||||||
"core-util-is": "~1.0.0",
|
|
||||||
"inherits": "~2.0.3",
|
|
||||||
"isarray": "~1.0.0",
|
|
||||||
"process-nextick-args": "~2.0.0",
|
|
||||||
"safe-buffer": "~5.1.1",
|
|
||||||
"string_decoder": "~1.1.1",
|
|
||||||
"util-deprecate": "~1.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"remove-trailing-separator": {
|
|
||||||
"version": "1.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz",
|
|
||||||
"integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8="
|
|
||||||
},
|
|
||||||
"replace-ext": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz",
|
|
||||||
"integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs="
|
|
||||||
},
|
|
||||||
"require-reload": {
|
|
||||||
"version": "0.2.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/require-reload/-/require-reload-0.2.2.tgz",
|
|
||||||
"integrity": "sha1-KadZGEbK+RtuijzamRaD+V+NfUI="
|
|
||||||
},
|
|
||||||
"safe-buffer": {
|
|
||||||
"version": "5.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
|
||||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
|
||||||
},
|
|
||||||
"smartfile": {
|
|
||||||
"version": "4.2.28",
|
|
||||||
"resolved": "https://registry.npmjs.org/smartfile/-/smartfile-4.2.28.tgz",
|
|
||||||
"integrity": "sha512-zUeAOLYftz8xLfKTs9U1NOuNPTA9jlvTQNr7lDIv84kXnr1AEpDb2Xwy1MdK1w733sBil/RkxtezrkvgRVAnNg==",
|
|
||||||
"requires": {
|
|
||||||
"@types/fs-extra": "5.0.0",
|
|
||||||
"@types/vinyl": "^2.0.2",
|
|
||||||
"fs-extra": "^5.0.0",
|
|
||||||
"glob": "^7.1.2",
|
|
||||||
"js-yaml": "^3.10.0",
|
|
||||||
"require-reload": "0.2.2",
|
|
||||||
"smartpath": "^3.2.8",
|
|
||||||
"smartq": "^1.1.6",
|
|
||||||
"smartrequest": "^1.0.8",
|
|
||||||
"vinyl-file": "^3.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"smartpath": {
|
|
||||||
"version": "3.2.8",
|
|
||||||
"resolved": "https://registry.npmjs.org/smartpath/-/smartpath-3.2.8.tgz",
|
|
||||||
"integrity": "sha1-SDS9OouuIpW6rK26I8h6UBlS+UA=",
|
|
||||||
"requires": {
|
|
||||||
"home": "^1.0.1",
|
|
||||||
"typings-global": "^1.0.14"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"smartq": {
|
|
||||||
"version": "1.1.8",
|
|
||||||
"resolved": "https://registry.npmjs.org/smartq/-/smartq-1.1.8.tgz",
|
|
||||||
"integrity": "sha512-FURlYW/C3bLeZjJcBVyw7bxCyQoCXiXbLCZcDUKznhXHaLu35c8m33/a2H8CA0rtb82lvzN8dRLnBZAcNMzNHQ==",
|
|
||||||
"requires": {
|
|
||||||
"util.promisify": "^1.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"smartrequest": {
|
|
||||||
"version": "1.0.13",
|
|
||||||
"resolved": "https://registry.npmjs.org/smartrequest/-/smartrequest-1.0.13.tgz",
|
|
||||||
"integrity": "sha512-OHrvzaxaA8Z8bJr33yxnyJF35nrWyaumsajqXm2Zkv0/2hfWO1NQAj02VVV51rLQfmtU0Hex7Nk19SoC8nOmYg==",
|
|
||||||
"requires": {
|
|
||||||
"smartq": "^1.1.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"source-map": {
|
|
||||||
"version": "0.6.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
|
||||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
|
|
||||||
},
|
|
||||||
"source-map-support": {
|
|
||||||
"version": "0.5.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.6.tgz",
|
|
||||||
"integrity": "sha512-N4KXEz7jcKqPf2b2vZF11lQIz9W5ZMuUcIOGj243lduidkf2fjkVKJS9vNxVWn3u/uxX38AcE8U9nnH9FPcq+g==",
|
|
||||||
"requires": {
|
|
||||||
"buffer-from": "^1.0.0",
|
|
||||||
"source-map": "^0.6.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"sprintf-js": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
|
||||||
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw="
|
|
||||||
},
|
|
||||||
"string_decoder": {
|
|
||||||
"version": "1.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
|
||||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
|
||||||
"requires": {
|
|
||||||
"safe-buffer": "~5.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"strip-bom": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz",
|
|
||||||
"integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=",
|
|
||||||
"requires": {
|
|
||||||
"is-utf8": "^0.2.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"strip-bom-buf": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/strip-bom-buf/-/strip-bom-buf-1.0.0.tgz",
|
|
||||||
"integrity": "sha1-HLRar1dTD0yvhsf3UXnSyaUd1XI=",
|
|
||||||
"requires": {
|
|
||||||
"is-utf8": "^0.2.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"strip-bom-stream": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/strip-bom-stream/-/strip-bom-stream-2.0.0.tgz",
|
|
||||||
"integrity": "sha1-+H217yYT9paKpUWr/h7HKLaoKco=",
|
|
||||||
"requires": {
|
|
||||||
"first-chunk-stream": "^2.0.0",
|
|
||||||
"strip-bom": "^2.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"typescript": {
|
|
||||||
"version": "2.9.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.1.tgz",
|
|
||||||
"integrity": "sha512-h6pM2f/GDchCFlldnriOhs1QHuwbnmj6/v7499eMHqPeW4V2G0elua2eIc2nu8v2NdHV0Gm+tzX83Hr6nUFjQA=="
|
|
||||||
},
|
|
||||||
"typings-global": {
|
|
||||||
"version": "1.0.28",
|
|
||||||
"resolved": "https://registry.npmjs.org/typings-global/-/typings-global-1.0.28.tgz",
|
|
||||||
"integrity": "sha512-6VOwJWEY2971HOMHu/7sURzUXiD4/LiMJPsMAOqkHHAtS3MVpLFE5gzTiHilsH9KY5VE1mBQirWIgWFsDuo90A=="
|
|
||||||
},
|
|
||||||
"universalify": {
|
|
||||||
"version": "0.1.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
|
|
||||||
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="
|
|
||||||
},
|
|
||||||
"util-deprecate": {
|
|
||||||
"version": "1.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
|
||||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
|
||||||
},
|
|
||||||
"util.promisify": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/util.promisify/-/util.promisify-1.0.0.tgz",
|
|
||||||
"integrity": "sha512-i+6qA2MPhvoKLuxnJNpXAGhg7HphQOSUq2LKMZD0m15EiskXUkMvKdF4Uui0WYeCUGea+o2cw/ZuwehtfsrNkA==",
|
|
||||||
"requires": {
|
|
||||||
"define-properties": "^1.1.2",
|
|
||||||
"object.getownpropertydescriptors": "^2.0.3"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"vinyl": {
|
|
||||||
"version": "2.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz",
|
|
||||||
"integrity": "sha512-MBH+yP0kC/GQ5GwBqrTPTzEfiiLjta7hTtvQtbxBgTeSXsmKQRQecjibMbxIXzVT3Y9KJK+drOz1/k+vsu8Nkg==",
|
|
||||||
"requires": {
|
|
||||||
"clone": "^2.1.1",
|
|
||||||
"clone-buffer": "^1.0.0",
|
|
||||||
"clone-stats": "^1.0.0",
|
|
||||||
"cloneable-readable": "^1.0.0",
|
|
||||||
"remove-trailing-separator": "^1.0.1",
|
|
||||||
"replace-ext": "^1.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"vinyl-file": {
|
|
||||||
"version": "3.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/vinyl-file/-/vinyl-file-3.0.0.tgz",
|
|
||||||
"integrity": "sha1-sQTZ5ECf+jJfqt1SBkLQo7SIs2U=",
|
|
||||||
"requires": {
|
|
||||||
"graceful-fs": "^4.1.2",
|
|
||||||
"pify": "^2.3.0",
|
|
||||||
"strip-bom-buf": "^1.0.0",
|
|
||||||
"strip-bom-stream": "^2.0.0",
|
|
||||||
"vinyl": "^2.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"wrappy": {
|
|
||||||
"version": "1.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
|
||||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
|
||||||
},
|
|
||||||
"yn": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz",
|
|
||||||
"integrity": "sha1-5a2ryKz0CPY4X8dklWhMiOavaJo="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
48
package.json
48
package.json
@ -1,31 +1,47 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tsrun",
|
"name": "@git.zone/tsrun",
|
||||||
"version": "1.0.17",
|
"version": "1.2.46",
|
||||||
"description": "run typescript programs efficiently",
|
"description": "run typescript programs efficiently",
|
||||||
"main": "dist/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsrun": "./cli.js"
|
"tsrun": "./cli.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts --notest && node ./cli.js test/test.ts)",
|
"test": "(tsbuild && node ./cli.js test/test.js sayhello)",
|
||||||
"format": "(gitzone format)",
|
"format": "(gitzone format)",
|
||||||
"build": "echo \"Not needed for now\"",
|
"build": "(tsbuild)",
|
||||||
"postinstall": "(node ./cli.js scripts/postinstall.ts)"
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^10.3.0"
|
"@git.zone/tsbuild": "^2.1.69",
|
||||||
|
"@push.rocks/smartcli": "^4.0.8",
|
||||||
|
"@types/node": "^20.5.6",
|
||||||
|
"node-fetch": "^3.3.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"arrify": "^1.0.1",
|
"@push.rocks/smartfile": "^10.0.30",
|
||||||
"make-error": "^1.3.4",
|
"@push.rocks/smartshell": "^3.0.3",
|
||||||
"mkdirp": "^0.5.1",
|
"ts-node": "^10.9.1",
|
||||||
"smartfile": "^4.2.28",
|
"typescript": "5.1.6"
|
||||||
"source-map-support": "^0.5.6",
|
|
||||||
"typescript": "^2.9.1",
|
|
||||||
"yn": "^2.0.0"
|
|
||||||
},
|
},
|
||||||
"private": false
|
"private": false,
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
1136
pnpm-lock.yaml
generated
Normal file
1136
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
47
readme.md
Normal file
47
readme.md
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# @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
|
||||||
|
|
||||||
|
Status Category | Status Badge
|
||||||
|
-- | --
|
||||||
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
|
npm | [](https://lossless.cloud)
|
||||||
|
Snyk | [](https://lossless.cloud)
|
||||||
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
Code Style | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
## Contribution
|
||||||
|
|
||||||
|
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 further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
|
## Legal
|
||||||
|
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
@ -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();
|
|
12
test/test.ts
12
test/test.ts
@ -1,2 +1,14 @@
|
|||||||
const textToPost: string = 'Test runs!';
|
const textToPost: string = 'Test runs!';
|
||||||
console.log(textToPost);
|
console.log(textToPost);
|
||||||
|
|
||||||
|
const run = async () => {
|
||||||
|
const smartcli = await import('@push.rocks/smartcli');
|
||||||
|
const smartcliInstance = new smartcli.Smartcli();
|
||||||
|
console.log(process.argv);
|
||||||
|
smartcliInstance.addCommand('sayhello').subscribe(async (argvArg) => {
|
||||||
|
console.log('hello there');
|
||||||
|
});
|
||||||
|
smartcliInstance.startParse();
|
||||||
|
};
|
||||||
|
|
||||||
|
run();
|
||||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@git.zone/tsrun',
|
||||||
|
version: '1.2.46',
|
||||||
|
description: 'run typescript programs efficiently'
|
||||||
|
}
|
52
ts/index.ts
52
ts/index.ts
@ -1,20 +1,42 @@
|
|||||||
import * as path from 'path';
|
import * as plugins from './plugins.js';
|
||||||
import * as tsNode from './tsnode';
|
const __dirname = plugins.path.dirname(plugins.url.fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
tsNode.register({
|
export const runPath = async (pathArg: string, fromFileUrl?: string) => {
|
||||||
compilerOptions: {
|
pathArg = fromFileUrl
|
||||||
lib: [ 'es2016', 'es2017' ]
|
? plugins.path.join(plugins.path.dirname(plugins.url.fileURLToPath(fromFileUrl)), pathArg)
|
||||||
},
|
: pathArg;
|
||||||
skipIgnore: true,
|
await runCli(pathArg);
|
||||||
cacheDirectory: path.join(__dirname, '../tscache')
|
};
|
||||||
});
|
|
||||||
|
|
||||||
if (process.env.CLI_CALL_TSRUN) {
|
export const runCli = async (pathArg?: string) => {
|
||||||
// contents of argv array
|
// contents of argv array
|
||||||
// process.argv[0] -> node Executable
|
// process.argv[0] -> node Executable
|
||||||
// process.argv[1] -> tsrun executable
|
// process.argv[1] -> tsrun executable
|
||||||
const pathToTsFile = process.argv[2]
|
const relativePathToTsFile = pathArg ? pathArg : process.argv[2];
|
||||||
|
const absolutePathToTsFile = plugins.path.isAbsolute(relativePathToTsFile)
|
||||||
const pathToLoad = path.join(process.cwd(), pathToTsFile);
|
? relativePathToTsFile
|
||||||
import(pathToLoad);
|
: plugins.path.join(process.cwd(), relativePathToTsFile);
|
||||||
}
|
|
||||||
|
// we want to have command line arguments available in the child process.
|
||||||
|
// when we have a path sepcified through a function there is one argeument less to pay respect to.
|
||||||
|
// thus when pathArg is specifed -> we only splice 2
|
||||||
|
pathArg ? process.argv.splice(0, 2) : process.argv.splice(0, 3); // this ensures transparent arguments for the child process
|
||||||
|
|
||||||
|
// lets setup things for execution
|
||||||
|
const smartshellInstance = new plugins.smartshell.Smartshell({
|
||||||
|
executor: 'bash',
|
||||||
|
});
|
||||||
|
|
||||||
|
const tsNodeLoaderPath = plugins.path.join(__dirname, 'loader.js');
|
||||||
|
// note: -> reduce on emtpy array does not work
|
||||||
|
// thus check needed before reducing the argv array
|
||||||
|
smartshellInstance.exec(
|
||||||
|
`node --loader ${tsNodeLoaderPath} ${absolutePathToTsFile} ${
|
||||||
|
process.argv.length > 0
|
||||||
|
? process.argv.reduce((prevArg, currentArg) => {
|
||||||
|
return prevArg + ' ' + currentArg;
|
||||||
|
})
|
||||||
|
: ''
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
};
|
||||||
|
23
ts/loader.ts
Normal file
23
ts/loader.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import * as plugins from './plugins.js';
|
||||||
|
import type { CompilerOptions } from 'typescript';
|
||||||
|
|
||||||
|
const defaultTsNodeOptions: plugins.tsNode.CreateOptions = {
|
||||||
|
compilerOptions: {
|
||||||
|
lib: ['dom'],
|
||||||
|
target: <any>'es2022', // Script Target should be a string -> 2 is for ES2015
|
||||||
|
experimentalDecorators: true,
|
||||||
|
useDefineForClassFields: false,
|
||||||
|
esModuleInterop: true,
|
||||||
|
strictNullChecks: false,
|
||||||
|
moduleResolution: <any>'nodenext',
|
||||||
|
module: <any>'nodenext',
|
||||||
|
verbatimModuleSyntax: true,
|
||||||
|
} as CompilerOptions,
|
||||||
|
esm: true,
|
||||||
|
skipIgnore: true,
|
||||||
|
transpileOnly: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const { resolve, load, getFormat, transformSource } = plugins.tsNode.createEsmHooks(
|
||||||
|
plugins.tsNode.register(defaultTsNodeOptions)
|
||||||
|
) as any;
|
15
ts/plugins.ts
Normal file
15
ts/plugins.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// node native
|
||||||
|
import * as path from 'path';
|
||||||
|
import * as url from 'url';
|
||||||
|
|
||||||
|
export { path, url };
|
||||||
|
|
||||||
|
// @pushrocks scope
|
||||||
|
import * as smartshell from '@push.rocks/smartshell';
|
||||||
|
|
||||||
|
export { smartshell };
|
||||||
|
|
||||||
|
// third party scope
|
||||||
|
import * as tsNode from 'ts-node';
|
||||||
|
|
||||||
|
export { tsNode };
|
613
ts/tsnode.ts
613
ts/tsnode.ts
@ -1,613 +0,0 @@
|
|||||||
import { relative, basename, extname, resolve, dirname, join } from 'path'
|
|
||||||
import { readFileSync, writeFileSync } from 'fs'
|
|
||||||
import { EOL, tmpdir, homedir } from 'os'
|
|
||||||
import sourceMapSupport = require('source-map-support')
|
|
||||||
import mkdirp = require('mkdirp')
|
|
||||||
import crypto = require('crypto')
|
|
||||||
import yn = require('yn')
|
|
||||||
import arrify = require('arrify')
|
|
||||||
import bufferFrom = require('buffer-from')
|
|
||||||
import { BaseError } from 'make-error'
|
|
||||||
import * as util from 'util'
|
|
||||||
import * as _ts from 'typescript'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
export const INSPECT_CUSTOM = util.inspect.custom || 'inspect'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Debugging `ts-node`.
|
|
||||||
*/
|
|
||||||
const shouldDebug = yn(process.env.TS_NODE_DEBUG)
|
|
||||||
const debug = shouldDebug ? console.log.bind(console, 'ts-node') : () => undefined
|
|
||||||
const debugFn = shouldDebug ?
|
|
||||||
<T, U> (key: string, fn: (arg: T) => U) => {
|
|
||||||
return (x: T) => {
|
|
||||||
debug(key, x)
|
|
||||||
return fn(x)
|
|
||||||
}
|
|
||||||
} :
|
|
||||||
<T, U> (_: string, fn: (arg: T) => U) => fn
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 const VERSION = require('../package.json').version
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Track the project information.
|
|
||||||
*/
|
|
||||||
interface MemoryCache {
|
|
||||||
contents: { [path: string]: string | undefined }
|
|
||||||
versions: { [path: string]: number | undefined }
|
|
||||||
outputs: { [path: string]: string }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Information retrieved from type info check.
|
|
||||||
*/
|
|
||||||
export interface TypeInfo {
|
|
||||||
name: string
|
|
||||||
comment: string
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default register options.
|
|
||||||
*/
|
|
||||||
export const DEFAULTS: Options = {
|
|
||||||
files: yn(process.env['TS_NODE_FILES']),
|
|
||||||
cache: yn(process.env['TS_NODE_CACHE'], { default: true }),
|
|
||||||
pretty: yn(process.env['TS_NODE_PRETTY']),
|
|
||||||
cacheDirectory: process.env['TS_NODE_CACHE_DIRECTORY'],
|
|
||||||
compiler: process.env['TS_NODE_COMPILER'],
|
|
||||||
compilerOptions: parse(process.env['TS_NODE_COMPILER_OPTIONS']),
|
|
||||||
ignore: split(process.env['TS_NODE_IGNORE']),
|
|
||||||
project: process.env['TS_NODE_PROJECT'],
|
|
||||||
skipIgnore: yn(process.env['TS_NODE_SKIP_IGNORE']),
|
|
||||||
skipProject: yn(process.env['TS_NODE_SKIP_PROJECT']),
|
|
||||||
ignoreDiagnostics: split(process.env['TS_NODE_IGNORE_DIAGNOSTICS']),
|
|
||||||
typeCheck: yn(process.env['TS_NODE_TYPE_CHECK']),
|
|
||||||
transpileOnly: yn(process.env['TS_NODE_TRANSPILE_ONLY'])
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default TypeScript compiler options required by `ts-node`.
|
|
||||||
*/
|
|
||||||
const DEFAULT_COMPILER_OPTIONS = {
|
|
||||||
sourceMap: true,
|
|
||||||
inlineSourceMap: false,
|
|
||||||
inlineSources: true,
|
|
||||||
declaration: false,
|
|
||||||
noEmit: false,
|
|
||||||
outDir: '$$ts-node$$'
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Split a string array of values.
|
|
||||||
*/
|
|
||||||
export function split (value: string | undefined) {
|
|
||||||
return typeof value === 'string' ? value.split(/ *, */g) : undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse a string as JSON.
|
|
||||||
*/
|
|
||||||
export function parse (value: string | undefined): object | undefined {
|
|
||||||
return typeof value === 'string' ? JSON.parse(value) : undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replace backslashes with forward slashes.
|
|
||||||
*/
|
|
||||||
export function normalizeSlashes (value: string): string {
|
|
||||||
return value.replace(/\\/g, '/')
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TypeScript diagnostics error.
|
|
||||||
*/
|
|
||||||
export class TSError extends BaseError {
|
|
||||||
name = 'TSError'
|
|
||||||
|
|
||||||
constructor (public diagnosticText: string, public diagnosticCodes: number[]) {
|
|
||||||
super(`⨯ Unable to compile TypeScript:\n${diagnosticText}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
[INSPECT_CUSTOM] () {
|
|
||||||
return this.diagnosticText
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a default temp directory based on home directory of user.
|
|
||||||
*/
|
|
||||||
function getTmpDir (): string {
|
|
||||||
const hash = crypto.createHash('sha256').update(homedir(), 'utf8').digest('hex')
|
|
||||||
|
|
||||||
return join(tmpdir(), `ts-node-${hash}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register TypeScript compiler.
|
|
||||||
*/
|
|
||||||
export function register (opts: Options = {}): Register {
|
|
||||||
const options = Object.assign({}, DEFAULTS, opts)
|
|
||||||
const cacheDirectory = options.cacheDirectory || getTmpDir()
|
|
||||||
const originalJsHandler = require.extensions['.js']
|
|
||||||
|
|
||||||
const ignoreDiagnostics = arrify(options.ignoreDiagnostics).concat([
|
|
||||||
6059, // "'rootDir' is expected to contain all source files."
|
|
||||||
18002, // "The 'files' list in config file is empty."
|
|
||||||
18003 // "No inputs were found in config file."
|
|
||||||
]).map(Number)
|
|
||||||
|
|
||||||
const memoryCache: MemoryCache = {
|
|
||||||
contents: Object.create(null),
|
|
||||||
versions: Object.create(null),
|
|
||||||
outputs: Object.create(null)
|
|
||||||
}
|
|
||||||
|
|
||||||
const ignore = options.skipIgnore ? [] : arrify(
|
|
||||||
options.ignore || '/node_modules/'
|
|
||||||
).map(str => new RegExp(str))
|
|
||||||
|
|
||||||
// Install source map support and read from memory cache.
|
|
||||||
sourceMapSupport.install({
|
|
||||||
environment: 'node',
|
|
||||||
retrieveFile (path: string) {
|
|
||||||
return memoryCache.outputs[path]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Require the TypeScript compiler and configuration.
|
|
||||||
const cwd = process.cwd()
|
|
||||||
const { compilerOptions, project, skipProject } = options
|
|
||||||
const compiler = options.compiler || 'typescript'
|
|
||||||
const typeCheck = options.typeCheck === true || options.transpileOnly !== true
|
|
||||||
const ts: typeof _ts = require(compiler)
|
|
||||||
const transformers = options.transformers || undefined
|
|
||||||
const readFile = options.readFile || ts.sys.readFile
|
|
||||||
const fileExists = options.fileExists || ts.sys.fileExists
|
|
||||||
const config = readConfig(cwd, ts, fileExists, readFile, compilerOptions, project, skipProject)
|
|
||||||
const configDiagnosticList = filterDiagnostics(config.errors, ignoreDiagnostics)
|
|
||||||
const extensions = ['.ts', '.tsx']
|
|
||||||
const fileNames = options.files ? config.fileNames : []
|
|
||||||
|
|
||||||
const cachedir = join(
|
|
||||||
resolve(cwd, cacheDirectory),
|
|
||||||
getCompilerDigest({
|
|
||||||
version: ts.version,
|
|
||||||
options: config.options,
|
|
||||||
fileNames,
|
|
||||||
typeCheck,
|
|
||||||
ignoreDiagnostics,
|
|
||||||
compiler
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
const diagnosticHost: _ts.FormatDiagnosticsHost = {
|
|
||||||
getNewLine: () => EOL,
|
|
||||||
getCurrentDirectory: () => cwd,
|
|
||||||
getCanonicalFileName: (path) => path
|
|
||||||
}
|
|
||||||
|
|
||||||
const formatDiagnostics = options.pretty
|
|
||||||
? ts.formatDiagnosticsWithColorAndContext
|
|
||||||
: ts.formatDiagnostics
|
|
||||||
|
|
||||||
function createTSError (diagnostics: ReadonlyArray<_ts.Diagnostic>) {
|
|
||||||
const diagnosticText = formatDiagnostics(diagnostics, diagnosticHost)
|
|
||||||
const diagnosticCodes = diagnostics.map(x => x.code)
|
|
||||||
return new TSError(diagnosticText, diagnosticCodes)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render the configuration errors and exit the script.
|
|
||||||
if (configDiagnosticList.length) throw createTSError(configDiagnosticList)
|
|
||||||
|
|
||||||
// Enable `allowJs` when flag is set.
|
|
||||||
if (config.options.allowJs) {
|
|
||||||
extensions.push('.js')
|
|
||||||
extensions.push('.jsx')
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize files from TypeScript into project.
|
|
||||||
for (const path of fileNames) memoryCache.versions[path] = 1
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the extension for a transpiled file.
|
|
||||||
*/
|
|
||||||
const getExtension = config.options.jsx === ts.JsxEmit.Preserve ?
|
|
||||||
((path: string) => /\.[tj]sx$/.test(path) ? '.jsx' : '.js') :
|
|
||||||
((_: string) => '.js')
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the basic required function using transpile mode.
|
|
||||||
*/
|
|
||||||
let getOutput = function (code: string, fileName: string, lineOffset = 0): SourceOutput {
|
|
||||||
const result = ts.transpileModule(code, {
|
|
||||||
fileName,
|
|
||||||
transformers,
|
|
||||||
compilerOptions: config.options,
|
|
||||||
reportDiagnostics: true
|
|
||||||
})
|
|
||||||
|
|
||||||
const diagnosticList = result.diagnostics ?
|
|
||||||
filterDiagnostics(result.diagnostics, ignoreDiagnostics) :
|
|
||||||
[]
|
|
||||||
|
|
||||||
if (diagnosticList.length) throw createTSError(diagnosticList)
|
|
||||||
|
|
||||||
return [result.outputText, result.sourceMapText as string]
|
|
||||||
}
|
|
||||||
|
|
||||||
let getTypeInfo = function (_code: string, _fileName: string, _position: number): TypeInfo {
|
|
||||||
throw new TypeError(`Type information is unavailable without "--type-check"`)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use full language services when the fast option is disabled.
|
|
||||||
if (typeCheck) {
|
|
||||||
// Set the file contents into cache.
|
|
||||||
const updateMemoryCache = function (code: string, fileName: string) {
|
|
||||||
if (memoryCache.contents[fileName] !== code) {
|
|
||||||
memoryCache.contents[fileName] = code
|
|
||||||
memoryCache.versions[fileName] = (memoryCache.versions[fileName] || 0) + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the compiler host for type checking.
|
|
||||||
const serviceHost = {
|
|
||||||
getScriptFileNames: () => Object.keys(memoryCache.versions),
|
|
||||||
getScriptVersion: (fileName: string) => {
|
|
||||||
const version = memoryCache.versions[fileName]
|
|
||||||
|
|
||||||
// We need to return `undefined` and not a string here because TypeScript will use
|
|
||||||
// `getScriptVersion` and compare against their own version - which can be `undefined`.
|
|
||||||
// If we don't return `undefined` it results in `undefined === "undefined"` and run
|
|
||||||
// `createProgram` again (which is very slow). Using a `string` assertion here to avoid
|
|
||||||
// TypeScript errors from the function signature (expects `(x: string) => string`).
|
|
||||||
return version === undefined ? undefined as any as string : String(version)
|
|
||||||
},
|
|
||||||
getScriptSnapshot (fileName: string) {
|
|
||||||
// Read contents into TypeScript memory cache.
|
|
||||||
if (!Object.prototype.hasOwnProperty.call(memoryCache.contents, fileName)) {
|
|
||||||
memoryCache.contents[fileName] = readFile(fileName)
|
|
||||||
}
|
|
||||||
|
|
||||||
const contents = memoryCache.contents[fileName]
|
|
||||||
if (contents === undefined) return
|
|
||||||
return ts.ScriptSnapshot.fromString(contents)
|
|
||||||
},
|
|
||||||
fileExists: debugFn('fileExists', fileExists),
|
|
||||||
readFile: debugFn('readFile', readFile),
|
|
||||||
readDirectory: debugFn('readDirectory', ts.sys.readDirectory),
|
|
||||||
getDirectories: debugFn('getDirectories', ts.sys.getDirectories),
|
|
||||||
directoryExists: debugFn('directoryExists', ts.sys.directoryExists),
|
|
||||||
getNewLine: () => EOL,
|
|
||||||
getCurrentDirectory: () => cwd,
|
|
||||||
getCompilationSettings: () => config.options,
|
|
||||||
getDefaultLibFileName: () => ts.getDefaultLibFilePath(config.options),
|
|
||||||
getCustomTransformers: () => transformers
|
|
||||||
}
|
|
||||||
|
|
||||||
const service = ts.createLanguageService(serviceHost)
|
|
||||||
|
|
||||||
getOutput = function (code: string, fileName: string, lineOffset: number = 0) {
|
|
||||||
// Must set memory cache before attempting to read file.
|
|
||||||
updateMemoryCache(code, fileName)
|
|
||||||
|
|
||||||
const output = service.getEmitOutput(fileName)
|
|
||||||
|
|
||||||
// Get the relevant diagnostics - this is 3x faster than `getPreEmitDiagnostics`.
|
|
||||||
const diagnostics = service.getCompilerOptionsDiagnostics()
|
|
||||||
.concat(service.getSyntacticDiagnostics(fileName))
|
|
||||||
.concat(service.getSemanticDiagnostics(fileName))
|
|
||||||
|
|
||||||
const diagnosticList = filterDiagnostics(diagnostics, ignoreDiagnostics)
|
|
||||||
|
|
||||||
if (diagnosticList.length) throw createTSError(diagnosticList)
|
|
||||||
|
|
||||||
if (output.emitSkipped) {
|
|
||||||
throw new TypeError(`${relative(cwd, fileName)}: Emit skipped`)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Throw an error when requiring `.d.ts` files.
|
|
||||||
if (output.outputFiles.length === 0) {
|
|
||||||
return ['', ''];
|
|
||||||
}
|
|
||||||
return [output.outputFiles[1].text, output.outputFiles[0].text]
|
|
||||||
}
|
|
||||||
|
|
||||||
getTypeInfo = function (code: string, fileName: string, position: number) {
|
|
||||||
updateMemoryCache(code, fileName)
|
|
||||||
|
|
||||||
const info = service.getQuickInfoAtPosition(fileName, position)
|
|
||||||
const name = ts.displayPartsToString(info ? info.displayParts : [])
|
|
||||||
const comment = ts.displayPartsToString(info ? info.documentation : [])
|
|
||||||
|
|
||||||
return { name, comment }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const compile = readThrough(cachedir, options.cache === true, memoryCache, getOutput, getExtension)
|
|
||||||
const register: Register = { cwd, compile, getTypeInfo, extensions, cachedir, ts }
|
|
||||||
|
|
||||||
// Register the extensions.
|
|
||||||
extensions.forEach(extension => {
|
|
||||||
registerExtension(extension, ignore, register, originalJsHandler)
|
|
||||||
})
|
|
||||||
|
|
||||||
return register
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the filename should be ignored.
|
|
||||||
*/
|
|
||||||
function shouldIgnore (filename: string, ignore: RegExp[]) {
|
|
||||||
const relname = normalizeSlashes(filename)
|
|
||||||
|
|
||||||
return ignore.some(x => x.test(relname))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register the extension for node.
|
|
||||||
*/
|
|
||||||
function registerExtension (
|
|
||||||
ext: string,
|
|
||||||
ignore: RegExp[],
|
|
||||||
register: Register,
|
|
||||||
originalHandler: (m: NodeModule, filename: string) => any
|
|
||||||
) {
|
|
||||||
const old = require.extensions[ext] || originalHandler
|
|
||||||
|
|
||||||
require.extensions[ext] = function (m: any, filename) {
|
|
||||||
if (shouldIgnore(filename, ignore)) {
|
|
||||||
return old(m, filename)
|
|
||||||
}
|
|
||||||
|
|
||||||
const _compile = m._compile
|
|
||||||
|
|
||||||
m._compile = function (code: string, fileName: string) {
|
|
||||||
debug('module._compile', fileName)
|
|
||||||
|
|
||||||
return _compile.call(this, register.compile(code, fileName), fileName)
|
|
||||||
}
|
|
||||||
|
|
||||||
return old(m, filename)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Do post-processing on config options to support `ts-node`.
|
|
||||||
*/
|
|
||||||
function fixConfig (ts: TSCommon, config: _ts.ParsedCommandLine) {
|
|
||||||
// Delete options that *should not* be passed through.
|
|
||||||
delete config.options.out
|
|
||||||
delete config.options.outFile
|
|
||||||
delete config.options.declarationDir
|
|
||||||
delete config.options.declarationMap
|
|
||||||
delete config.options.emitDeclarationOnly
|
|
||||||
|
|
||||||
// Target ES5 output by default (instead of ES3).
|
|
||||||
if (config.options.target === undefined) {
|
|
||||||
config.options.target = ts.ScriptTarget.ES5
|
|
||||||
}
|
|
||||||
|
|
||||||
// Target CommonJS modules by default (instead of magically switching to ES6 when the target is ES6).
|
|
||||||
if (config.options.module === undefined) {
|
|
||||||
config.options.module = ts.ModuleKind.CommonJS
|
|
||||||
}
|
|
||||||
|
|
||||||
return config
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load TypeScript configuration.
|
|
||||||
*/
|
|
||||||
function readConfig (
|
|
||||||
cwd: string,
|
|
||||||
ts: TSCommon,
|
|
||||||
fileExists: (path: string) => boolean,
|
|
||||||
readFile: (path: string) => string | undefined,
|
|
||||||
compilerOptions?: object,
|
|
||||||
project?: string | null,
|
|
||||||
noProject?: boolean | null
|
|
||||||
): _ts.ParsedCommandLine {
|
|
||||||
let config = { compilerOptions: {} }
|
|
||||||
let basePath = normalizeSlashes(cwd)
|
|
||||||
let configFileName: string | undefined = undefined
|
|
||||||
|
|
||||||
// Read project configuration when available.
|
|
||||||
if (!noProject) {
|
|
||||||
configFileName = project
|
|
||||||
? normalizeSlashes(resolve(cwd, project))
|
|
||||||
: ts.findConfigFile(normalizeSlashes(cwd), fileExists)
|
|
||||||
|
|
||||||
if (configFileName) {
|
|
||||||
const result = ts.readConfigFile(configFileName, readFile)
|
|
||||||
|
|
||||||
// Return diagnostics.
|
|
||||||
if (result.error) {
|
|
||||||
return { errors: [result.error], fileNames: [], options: {} }
|
|
||||||
}
|
|
||||||
|
|
||||||
config = result.config
|
|
||||||
basePath = normalizeSlashes(dirname(configFileName))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Override default configuration options `ts-node` requires.
|
|
||||||
config.compilerOptions = Object.assign({}, config.compilerOptions, compilerOptions, DEFAULT_COMPILER_OPTIONS)
|
|
||||||
|
|
||||||
return fixConfig(ts, ts.parseJsonConfigFileContent(config, ts.sys, basePath, undefined, configFileName))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal source output.
|
|
||||||
*/
|
|
||||||
type SourceOutput = [string, string]
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrap the function with caching.
|
|
||||||
*/
|
|
||||||
function readThrough (
|
|
||||||
cachedir: string,
|
|
||||||
shouldCache: boolean,
|
|
||||||
memoryCache: MemoryCache,
|
|
||||||
compile: (code: string, fileName: string, lineOffset?: number) => SourceOutput,
|
|
||||||
getExtension: (fileName: string) => string
|
|
||||||
) {
|
|
||||||
if (shouldCache === false) {
|
|
||||||
return function (code: string, fileName: string, lineOffset?: number) {
|
|
||||||
debug('readThrough', fileName)
|
|
||||||
|
|
||||||
const [value, sourceMap] = compile(code, fileName, lineOffset)
|
|
||||||
const output = updateOutput(value, fileName, sourceMap, getExtension)
|
|
||||||
|
|
||||||
memoryCache.outputs[fileName] = output
|
|
||||||
|
|
||||||
return output
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure the cache directory exists before continuing.
|
|
||||||
mkdirp.sync(cachedir)
|
|
||||||
|
|
||||||
return function (code: string, fileName: string, lineOffset?: number) {
|
|
||||||
debug('readThrough', fileName)
|
|
||||||
|
|
||||||
const cachePath = join(cachedir, getCacheName(code, fileName))
|
|
||||||
const extension = getExtension(fileName)
|
|
||||||
const outputPath = `${cachePath}${extension}`
|
|
||||||
|
|
||||||
try {
|
|
||||||
const output = readFileSync(outputPath, 'utf8')
|
|
||||||
if (isValidCacheContent(output)) {
|
|
||||||
memoryCache.outputs[fileName] = output
|
|
||||||
return output
|
|
||||||
}
|
|
||||||
} catch (err) {/* Ignore. */}
|
|
||||||
|
|
||||||
const [value, sourceMap] = compile(code, fileName, lineOffset)
|
|
||||||
const output = updateOutput(value, fileName, sourceMap, getExtension)
|
|
||||||
|
|
||||||
memoryCache.outputs[fileName] = output
|
|
||||||
writeFileSync(outputPath, output)
|
|
||||||
|
|
||||||
return output
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the output remapping the source map.
|
|
||||||
*/
|
|
||||||
function updateOutput (outputText: string, fileName: string, sourceMap: string, getExtension: (fileName: string) => string) {
|
|
||||||
const base64Map = bufferFrom(updateSourceMap(sourceMap, fileName), 'utf8').toString('base64')
|
|
||||||
const sourceMapContent = `data:application/json;charset=utf-8;base64,${base64Map}`
|
|
||||||
const sourceMapLength = `${basename(fileName)}.map`.length + (getExtension(fileName).length - extname(fileName).length)
|
|
||||||
|
|
||||||
return outputText.slice(0, -sourceMapLength) + sourceMapContent
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the source map contents for improved output.
|
|
||||||
*/
|
|
||||||
function updateSourceMap (sourceMapText: string, fileName: string) {
|
|
||||||
const sourceMap = JSON.parse(sourceMapText)
|
|
||||||
sourceMap.file = fileName
|
|
||||||
sourceMap.sources = [fileName]
|
|
||||||
delete sourceMap.sourceRoot
|
|
||||||
return JSON.stringify(sourceMap)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the file name for the cache entry.
|
|
||||||
*/
|
|
||||||
function getCacheName (sourceCode: string, fileName: string) {
|
|
||||||
return crypto.createHash('sha256')
|
|
||||||
.update(extname(fileName), 'utf8')
|
|
||||||
.update('\x00', 'utf8')
|
|
||||||
.update(sourceCode, 'utf8')
|
|
||||||
.digest('hex')
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ensure the given cached content is valid by sniffing for a base64 encoded '}'
|
|
||||||
* at the end of the content, which should exist if there is a valid sourceMap present.
|
|
||||||
*/
|
|
||||||
function isValidCacheContent (contents: string) {
|
|
||||||
return /(?:9|0=|Q==)$/.test(contents.slice(-3))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a hash of the current configuration.
|
|
||||||
*/
|
|
||||||
function getCompilerDigest (obj: object) {
|
|
||||||
return crypto.createHash('sha256').update(JSON.stringify(obj), 'utf8').digest('hex')
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter diagnostics.
|
|
||||||
*/
|
|
||||||
function filterDiagnostics (diagnostics: _ts.Diagnostic[], ignore: number[]) {
|
|
||||||
return diagnostics.filter(x => ignore.indexOf(x.code) === -1)
|
|
||||||
}
|
|
9
tsconfig.json
Normal file
9
tsconfig.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "ES2022",
|
||||||
|
"moduleResolution": "nodenext"
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "tslint-config-standard"
|
|
||||||
}
|
|
Reference in New Issue
Block a user