Compare commits
54 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 |
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
|
108
.gitlab-ci.yml
108
.gitlab-ci.yml
@ -1,16 +1,16 @@
|
|||||||
# 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
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
@ -19,63 +19,42 @@ mirror:
|
|||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
snyk:
|
auditProductionDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci command npm install -g snyk
|
- npmci command npm install --production --ignore-scripts
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
- npmci command snyk test
|
- npmci command npm audit --audit-level=high --only=prod --production
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
|
||||||
sast:
|
|
||||||
stage: security
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-dbase:npmci
|
|
||||||
variables:
|
|
||||||
DOCKER_DRIVER: overlay2
|
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
auditDevDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command npm run build
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
- npmci command npm audit --audit-level=high --only=dev
|
||||||
- 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:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- priv
|
allow_failure: true
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
# ====================
|
# ====================
|
||||||
|
|
||||||
testLTS:
|
testStable:
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
@ -85,7 +64,17 @@ testSTABLE:
|
|||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
testBuild:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
@ -95,6 +84,7 @@ release:
|
|||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
@ -103,20 +93,16 @@ release:
|
|||||||
# ====================
|
# ====================
|
||||||
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 tslint typescript
|
||||||
- docker run
|
- npmci npm prepare
|
||||||
--env SOURCE_CODE="$PWD"
|
- npmci npm install
|
||||||
--volume "$PWD":/code
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
|
||||||
artifacts:
|
|
||||||
paths: [codeclimate.json]
|
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- priv
|
- priv
|
||||||
|
|
||||||
@ -127,18 +113,20 @@ trigger:
|
|||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmci
|
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g typedoc typescript
|
- npmci node install lts
|
||||||
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
only:
|
only:
|
||||||
|
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: {}
|
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "current file",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [
|
||||||
|
"${relativeFile}"
|
||||||
|
],
|
||||||
|
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"protocol": "inspector",
|
||||||
|
"internalConsoleOptions": "openOnSessionStart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "test.ts",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [
|
||||||
|
"test/test.ts"
|
||||||
|
],
|
||||||
|
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"protocol": "inspector",
|
||||||
|
"internalConsoleOptions": "openOnSessionStart"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
26
.vscode/settings.json
vendored
Normal file
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"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
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';
|
||||||
|
await import('@gitzone/tsrun');
|
||||||
|
const cliTool = await import('./ts/index.js');
|
||||||
|
cliTool.runCli();
|
@ -1 +0,0 @@
|
|||||||
.gitignore: ../gitignore/
|
|
1
dist/index.d.ts
vendored
1
dist/index.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
export {};
|
|
30
dist/index.js
vendored
30
dist/index.js
vendored
@ -1,30 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const path = require("path");
|
|
||||||
const tsNode = require("ts-node");
|
|
||||||
const defaultTsNodeOptions = {
|
|
||||||
compilerOptions: {
|
|
||||||
lib: ['es2016', 'es2017'],
|
|
||||||
target: 'es2017',
|
|
||||||
experimentalDecorators: true
|
|
||||||
},
|
|
||||||
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
|
|
||||||
// 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDZCQUE2QjtBQUM3QixrQ0FBa0M7QUFHbEMsTUFBTSxvQkFBb0IsR0FBbUI7SUFDM0MsZUFBZSxFQUFtQjtRQUNoQyxHQUFHLEVBQUUsQ0FBQyxRQUFRLEVBQUUsUUFBUSxDQUFDO1FBQ3pCLE1BQU0sRUFBTyxRQUFRO1FBQ3JCLHNCQUFzQixFQUFFLElBQUk7S0FDN0I7SUFDRCxVQUFVLEVBQUUsSUFBSTtDQUNqQixDQUFDO0FBRUYsSUFBSSxPQUFPLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxPQUFPLENBQUMsRUFBRTtJQUNsQyxNQUFNLHVCQUF1QixHQUFHLG9CQUFvQixDQUFDLGVBQWtDLENBQUM7SUFDeEYsb0JBQW9CLENBQUMsZUFBZSxxQkFDL0IsdUJBQXVCLElBQzFCLEdBQUcsRUFBRSxDQUFDLFFBQVEsRUFBRSxRQUFRLEVBQUUsS0FBSyxDQUFDLEVBQ2hDLE1BQU0sRUFBTyxRQUFRLENBQUMsc0RBQXNEO09BQzdFLENBQUM7Q0FDSDtBQUVELElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsV0FBVyxDQUFDLEVBQUU7SUFDdEMsZ0NBQWdDO0NBQ2pDO0FBRUQsTUFBTSxDQUFDLFFBQVEsQ0FBQyxvQkFBb0IsQ0FBQyxDQUFDO0FBRXRDLElBQUksT0FBTyxDQUFDLEdBQUcsQ0FBQyxjQUFjLEVBQUU7SUFDOUIseUJBQXlCO0lBQ3pCLHFDQUFxQztJQUNyQyxzQ0FBc0M7SUFDdEMsTUFBTSxZQUFZLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQztJQUVyQyxNQUFNLFVBQVUsR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsRUFBRSxZQUFZLENBQUMsQ0FBQztJQUMxRCxxQ0FBTyxVQUFVLEdBQUU7Q0FDcEIifQ==
|
|
@ -5,6 +5,7 @@
|
|||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
},
|
},
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "gitzone",
|
"gitscope": "gitzone",
|
||||||
|
3143
package-lock.json
generated
3143
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
41
package.json
41
package.json
@ -1,29 +1,46 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tsrun",
|
"name": "@gitzone/tsrun",
|
||||||
"version": "1.2.2",
|
"version": "1.2.29",
|
||||||
"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": "(tsbuild && node ./cli.js test/test.ts)",
|
"test": "(tsbuild && node ./cli.js test/test.js sayhello)",
|
||||||
"format": "(gitzone format)",
|
"format": "(gitzone format)",
|
||||||
"build": "(tsbuild)"
|
"build": "(tsbuild)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^11.10.4",
|
"@gitzone/tsbuild": "^2.1.43",
|
||||||
"tslint": "^5.13.1",
|
"@pushrocks/smartcli": "^3.0.14",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"@types/node": "^17.0.21",
|
||||||
|
"node-fetch": "^3.2.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.8",
|
"@pushrocks/smartfile": "^9.0.6",
|
||||||
"@pushrocks/smartfile": "^7.0.0",
|
"@pushrocks/smartshell": "^2.0.30",
|
||||||
"ts-node": "^8.0.2",
|
"ts-node": "^10.7.0",
|
||||||
"typescript": "^3.3.3333"
|
"typescript": "4.7.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"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
29
readme.md
29
readme.md
@ -8,13 +8,20 @@ run typescript programs efficiently
|
|||||||
* [docs (typedoc)](https://gitzone.gitlab.io/tsrun/)
|
* [docs (typedoc)](https://gitzone.gitlab.io/tsrun/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
[](https://gitlab.com/gitzone/tsrun/commits/master)
|
|
||||||
[](https://gitlab.com/gitzone/tsrun/commits/master)
|
Status Category | Status Badge
|
||||||
[](https://www.npmjs.com/package/@gitzone/tsrun)
|
-- | --
|
||||||
[](https://snyk.io/test/npm/@gitzone/tsrun)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
npm | [](https://lossless.cloud)
|
||||||
[](https://prettier.io/)
|
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)
|
||||||
|
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -30,9 +37,13 @@ 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.
|
- `--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.
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
[](https://maintainedby.lossless.com)
|
||||||
|
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('@pushrocks/smartcli');
|
||||||
|
const smartcliInstance = new smartcli.Smartcli();
|
||||||
|
console.log(process.argv)
|
||||||
|
smartcliInstance.addCommand('sayhello').subscribe(async argvArg => {
|
||||||
|
console.log('hello there');
|
||||||
|
})
|
||||||
|
smartcliInstance.startParse();
|
||||||
|
}
|
||||||
|
|
||||||
|
run();
|
62
ts/index.ts
62
ts/index.ts
@ -1,37 +1,39 @@
|
|||||||
import * as path from 'path';
|
import * as plugins from './plugins.js';
|
||||||
import * as tsNode from 'ts-node';
|
const __dirname = plugins.path.dirname(plugins.url.fileURLToPath(import.meta.url));
|
||||||
import { CompilerOptions } from 'typescript';
|
|
||||||
|
|
||||||
const defaultTsNodeOptions: tsNode.Options = {
|
export const runPath = async (pathArg: string, fromFileUrl?: string) => {
|
||||||
compilerOptions: <CompilerOptions>{
|
pathArg = fromFileUrl
|
||||||
lib: ['es2016', 'es2017'],
|
? plugins.path.join(plugins.path.dirname(plugins.url.fileURLToPath(fromFileUrl)), pathArg)
|
||||||
target: <any>'es2017', // Script Target should be a string -> 2 is for ES2015
|
: pathArg;
|
||||||
experimentalDecorators: true
|
await runCli(pathArg);
|
||||||
},
|
|
||||||
skipIgnore: true
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (process.argv.includes('--web')) {
|
export const runCli = async (pathArg?: string) => {
|
||||||
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
|
// 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)
|
||||||
|
? relativePathToTsFile
|
||||||
|
: plugins.path.join(process.cwd(), relativePathToTsFile);
|
||||||
|
|
||||||
const pathToLoad = path.join(process.cwd(), pathToTsFile);
|
process.argv.splice(0, 3); // this ensures transparent arguments for the child process
|
||||||
import(pathToLoad);
|
|
||||||
}
|
// 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;
|
||||||
|
})
|
||||||
|
: ''
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
};
|
||||||
|
20
ts/loader.ts
Normal file
20
ts/loader.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import * as plugins from './plugins.js';
|
||||||
|
import type { CompilerOptions } from 'typescript';
|
||||||
|
|
||||||
|
const defaultTsNodeOptions: plugins.tsNode.CreateOptions = {
|
||||||
|
compilerOptions: {
|
||||||
|
lib: ['dom'],
|
||||||
|
target: <any>'es2020', // Script Target should be a string -> 2 is for ES2015
|
||||||
|
experimentalDecorators: true,
|
||||||
|
esModuleInterop: true,
|
||||||
|
strictNullChecks: false,
|
||||||
|
moduleResolution: <any>'node12',
|
||||||
|
module: <any>'ESNext',
|
||||||
|
importsNotUsedAsValues: <any>'preserve',
|
||||||
|
} as CompilerOptions,
|
||||||
|
esm: true,
|
||||||
|
skipIgnore: true,
|
||||||
|
transpileOnly: true
|
||||||
|
};
|
||||||
|
|
||||||
|
export const { resolve, load, getFormat, transformSource } = plugins.tsNode.createEsmHooks(plugins.tsNode.register(defaultTsNodeOptions)) as any;
|
22
ts/plugins.ts
Normal file
22
ts/plugins.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// node native
|
||||||
|
import * as path from 'path';
|
||||||
|
import * as url from 'url';
|
||||||
|
|
||||||
|
export {
|
||||||
|
path,
|
||||||
|
url
|
||||||
|
}
|
||||||
|
|
||||||
|
// @pushrocks scope
|
||||||
|
import * as smartshell from '@pushrocks/smartshell';
|
||||||
|
|
||||||
|
export {
|
||||||
|
smartshell
|
||||||
|
}
|
||||||
|
|
||||||
|
// third party scope
|
||||||
|
import * as tsNode from 'ts-node';
|
||||||
|
|
||||||
|
export {
|
||||||
|
tsNode
|
||||||
|
}
|
7
tsconfig.json
Normal file
7
tsconfig.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "ES2022",
|
||||||
|
"target": "ES2020",
|
||||||
|
"moduleResolution": "Node12"
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user