Compare commits

...

92 Commits

Author SHA1 Message Date
5efd905068 1.2.46 2023-08-26 14:43:08 +02:00
ae01679474 fix(core): update 2023-08-26 14:43:08 +02:00
f0bdfa9a65 1.2.45 2023-08-26 13:32:29 +02:00
a88cf067a1 fix(core): update 2023-08-26 13:32:28 +02:00
c5cd30e20e 1.2.44 2023-07-13 02:53:32 +02:00
02eb0c5435 fix(core): update 2023-07-13 02:53:31 +02:00
6ab3ed21e0 1.2.43 2023-07-13 01:33:17 +02:00
2f5374be50 fix(core): update 2023-07-13 01:33:17 +02:00
1577265f6b 1.2.42 2023-06-03 16:44:04 +02:00
3b9532bb70 fix(core): update 2023-06-03 16:44:04 +02:00
bcb1ccc6e7 1.2.41 2023-06-03 16:10:38 +02:00
1dde4c8277 fix(core): update 2023-06-03 16:10:37 +02:00
3a6fc44fbb 1.2.40 2023-06-03 16:09:01 +02:00
a0d523513b fix(core): update 2023-06-03 16:09:01 +02:00
0715f88189 1.2.39 2022-10-20 14:15:04 +02:00
4a50ae3b00 fix(core): update 2022-10-20 14:15:04 +02:00
2b7c3b78f6 1.2.38 2022-10-12 17:21:04 +02:00
142667ac87 fix(core): update 2022-10-12 17:21:03 +02:00
9e55126adf 1.2.37 2022-06-14 21:42:07 +02:00
5271f0153e fix(core): update 2022-06-14 21:42:07 +02:00
ba0aaf2793 1.2.36 2022-06-14 21:33:04 +02:00
1f46e387e7 fix(core): update 2022-06-14 21:33:03 +02:00
03625bfca4 1.2.35 2022-06-02 00:23:45 +02:00
cc92e3e9ca fix(core): update 2022-06-02 00:23:45 +02:00
c1e66d498a 1.2.34 2022-05-25 10:55:36 +02:00
bfbb802e88 fix(core): update 2022-05-25 10:55:35 +02:00
655fd8b92e 1.2.33 2022-05-25 10:11:15 +02:00
a240cdfde1 fix(core): update 2022-05-25 10:11:14 +02:00
2af7682cf0 1.2.32 2022-03-24 18:47:16 +01:00
c62619bd27 fix(core): update 2022-03-24 18:47:16 +01:00
ffaf54f1de 1.2.31 2022-03-13 00:02:20 +01:00
2c6b955819 fix(core): update 2022-03-13 00:02:20 +01:00
9bb13e1ede 1.2.30 2022-03-13 00:01:40 +01:00
d9bd5e5340 fix(core): update 2022-03-13 00:01:40 +01:00
b76de3e04d 1.2.29 2022-03-12 22:54:05 +01:00
808726d1df fix(core): update 2022-03-12 22:54:04 +01:00
d011f10b9b 1.2.28 2022-03-12 21:59:15 +01:00
d1baa20aad fix(core): update 2022-03-12 21:59:14 +01:00
71779693d7 1.2.27 2022-03-12 21:52:14 +01:00
1113251aea fix(core): update 2022-03-12 21:52:14 +01:00
e41cd896bb 1.2.26 2022-03-12 19:13:56 +01:00
ba44007fb2 fix(core): update 2022-03-12 19:13:56 +01:00
8d1362f14b 1.2.25 2022-03-12 18:54:20 +01:00
61ceb03962 fix(core): update 2022-03-12 18:54:19 +01:00
ab3ec90245 1.2.24 2022-03-12 18:50:18 +01:00
b51cda08c4 fix(core): update 2022-03-12 18:50:17 +01:00
b8332e1de4 1.2.23 2022-03-12 14:52:42 +01:00
da9a73bc79 fix(core): update 2022-03-12 14:52:42 +01:00
26bf39abae 1.2.22 2022-03-12 14:43:54 +01:00
b66b2083ab fix(core): update 2022-03-12 14:43:54 +01:00
e40c0151bc 1.2.21 2022-03-11 18:09:35 +01:00
fe97fcd193 fix(core): update 2022-03-11 18:09:35 +01:00
5174d9ccc6 1.2.20 2022-03-11 17:56:09 +01:00
e89c3eda66 fix(core): update 2022-03-11 17:56:08 +01:00
6d4c9f390a 1.2.19 2022-03-11 17:26:50 +01:00
3fc3421857 fix(core): update 2022-03-11 17:26:50 +01:00
e1803dabfa 1.2.18 2021-10-06 13:06:25 +02:00
282d8b2b93 fix(core): update 2021-10-06 13:06:24 +02:00
76dd9707fe 1.2.17 2021-06-24 10:58:47 +02:00
269e54c717 fix(core): update 2021-06-24 10:58:46 +02:00
dd33a359c3 1.2.16 2021-06-23 15:57:58 +02:00
0caaac2a67 fix(core): update 2021-06-23 15:57:57 +02:00
14a043be1e 1.2.15 2021-06-23 15:45:35 +02:00
de44be741d fix(core): update 2021-06-23 15:45:34 +02:00
d15500d5a0 1.2.14 2021-06-23 15:30:55 +02:00
7e99fd703f fix(core): update 2021-06-23 15:30:55 +02:00
fa5462c0bc 1.2.13 2021-06-23 15:26:56 +02:00
f8736d3556 fix(core): update 2021-06-23 15:26:55 +02:00
45bba88f46 1.2.12 2020-06-01 19:38:19 +00:00
daafe0b6ff fix(core): update 2020-06-01 19:38:19 +00:00
3d905de2be 1.2.11 2020-06-01 19:37:12 +00:00
815008e881 fix(core): update 2020-06-01 19:37:11 +00:00
4641cc7cad 1.2.10 2020-06-01 18:32:33 +00:00
dbf324682c fix(core): update 2020-06-01 18:32:33 +00:00
8f5c302b6c 1.2.9 2020-06-01 18:19:37 +00:00
e5bf2ac20c fix(core): update 2020-06-01 18:19:37 +00:00
731931452a 1.2.8 2019-07-17 13:26:52 +02:00
0b3730f7e5 fix(core): update 2019-07-17 13:26:52 +02:00
aecc54aab0 1.2.7 2019-07-17 13:22:38 +02:00
e3fa66ff07 fix(core): update 2019-07-17 13:22:38 +02:00
bb3b918521 1.2.6 2019-04-30 12:33:08 +02:00
ba9eaa5091 fix(core): update 2019-04-30 12:33:07 +02:00
0e281ab257 1.2.5 2019-04-08 17:10:10 +02:00
0e14522287 fix(core): update 2019-04-08 17:10:10 +02:00
4d93e2e728 1.2.4 2019-04-08 17:08:27 +02:00
ce9a350521 fix(core): update 2019-04-08 17:08:26 +02:00
df9c7204c7 1.2.3 2019-04-08 16:30:24 +02:00
568472e715 fix(core): update ES2017 2019-04-08 16:30:24 +02:00
0ba6863e28 1.2.2 2019-04-08 16:17:58 +02:00
d5c63cd24c fix(core): update 2019-04-08 16:17:57 +02:00
460babd675 1.2.1 2019-03-02 23:03:06 +01:00
98cde0edb4 fix(readme): update 2019-03-02 23:03:05 +01:00
23 changed files with 1438 additions and 1439 deletions

17
.gitignore vendored
View File

@ -1,7 +1,20 @@
.nogit/
node_modules/
# artifacts
coverage/
public/
pages/
# installs
node_modules/
# caches
.yarn/
tscache
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,126 +1,122 @@
# gitzone standard
image: hosttoday/ht-docker-node:npmci
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: "$CI_BUILD_STAGE"
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- security
- test
- release
- metadata
- security
- test
- release
- metadata
before_script:
- pnpm install -g pnpm
- pnpm install -g @shipzone/npmci
- npmci npm prepare
# ====================
# security stage
# ====================
mirror:
# ====================
# security stage
# ====================
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci git mirror
- npmci command npm config set registry https://registry.npmjs.org
- npmci command pnpm audit --audit-level=high --prod
tags:
- docker
- notpriv
- lossless
- docker
allow_failure: true
snyk:
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
- npmci command npm config set registry https://registry.npmjs.org
- npmci command pnpm audit --audit-level=high --dev
tags:
- docker
- notpriv
- lossless
- docker
allow_failure: true
# ====================
# 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
script:
- npmci node install lts
- npmci npm install
- npmci npm test
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
testSTABLE:
- docker
testBuild:
stage: test
script:
- npmci node install stable
- npmci npm install
- npmci npm test
- npmci node install stable
- npmci npm install
- npmci npm build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
- docker
release:
stage: release
script:
- npmci node install stable
- npmci npm publish
- npmci node install stable
- npmci npm publish
only:
- tags
- tags
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
image: docker:stable
allow_failure: true
services:
- docker:stable-dind
only:
- tags
script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env SOURCE_CODE="$PWD"
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
paths: [codeclimate.json]
- npmci command npm install -g typescript
- npmci npm prepare
- npmci npm install
tags:
- docker
- priv
- lossless
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
- npmci trigger
only:
- tags
- tags
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata
script:
- npmci command npm install -g typedoc typescript
- npmci node install stable
- npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
- npmci command npm run buildDocs
tags:
- lossless
- docker
- notpriv
only:
@ -128,15 +124,5 @@ pages:
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true
windowsCompatibility:
image: stefanscherer/node-windows:10-build-tools
stage: metadata
script:
- npm install & npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- windows
- public
allow_failure: true

4
.snyk
View File

@ -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
View 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
View 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
View 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
View File

@ -1,3 +1,4 @@
#!/usr/bin/env node
process.env.CLI_CALL_TSRUN = 'true'
var index = require("./dist/index.js");
process.env.CLI_CALL = 'true';
const cliTool = await import('./dist_ts/index.js');
cliTool.runCli();

5
cli.ts.js Normal file
View 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);

View File

@ -1 +0,0 @@
.gitignore: ../gitignore/

1
dist/index.d.ts vendored
View File

@ -1 +0,0 @@
export {};

29
dist/index.js vendored
View File

@ -1,29 +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: 'es2015',
experimentalDecorators: true
},
skipIgnore: true
};
if (process.argv.includes('--web')) {
const previousCompilerOptions = defaultTsNodeOptions.compilerOptions;
defaultTsNodeOptions.compilerOptions = Object.assign({}, previousCompilerOptions, { lib: [...previousCompilerOptions.lib, 'dom'] });
}
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDZCQUE2QjtBQUM3QixrQ0FBa0M7QUFHbEMsTUFBTSxvQkFBb0IsR0FBbUI7SUFDM0MsZUFBZSxFQUFtQjtRQUNoQyxHQUFHLEVBQUUsQ0FBQyxRQUFRLEVBQUUsUUFBUSxDQUFDO1FBQ3pCLE1BQU0sRUFBTyxRQUFRO1FBQ3JCLHNCQUFzQixFQUFFLElBQUk7S0FDN0I7SUFDRCxVQUFVLEVBQUUsSUFBSTtDQUNqQixDQUFDO0FBRUYsSUFBSSxPQUFPLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxPQUFPLENBQUMsRUFBRTtJQUNsQyxNQUFNLHVCQUF1QixHQUFHLG9CQUFvQixDQUFDLGVBQWtDLENBQUM7SUFDeEYsb0JBQW9CLENBQUMsZUFBZSxxQkFDL0IsdUJBQXVCLElBQzFCLEdBQUcsRUFBRSxDQUFDLEdBQUcsdUJBQXVCLENBQUMsR0FBRyxFQUFFLEtBQUssQ0FBQyxHQUM3QyxDQUFBO0NBQ0Y7QUFFRCxJQUFJLE9BQU8sQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDLFdBQVcsQ0FBQyxFQUFFO0lBQ3RDLGdDQUFnQztDQUNqQztBQUVELE1BQU0sQ0FBQyxRQUFRLENBQUMsb0JBQW9CLENBQUMsQ0FBQztBQUV0QyxJQUFJLE9BQU8sQ0FBQyxHQUFHLENBQUMsY0FBYyxFQUFFO0lBQzlCLHlCQUF5QjtJQUN6QixxQ0FBcUM7SUFDckMsc0NBQXNDO0lBQ3RDLE1BQU0sWUFBWSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUM7SUFFckMsTUFBTSxVQUFVLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLEVBQUUsWUFBWSxDQUFDLENBQUM7SUFDMUQscUNBQU8sVUFBVSxHQUFFO0NBQ3BCIn0=

View File

@ -1,8 +1,18 @@
{
"npmts": {
},
"npmts": {},
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "gitzone",
"gitrepo": "tsrun",
"description": "run typescript programs efficiently",
"npmPackagename": "@gitzone/tsrun",
"license": "MIT"
}
}
}

1250
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,29 +1,47 @@
{
"name": "@gitzone/tsrun",
"version": "1.2.0",
"name": "@git.zone/tsrun",
"version": "1.2.46",
"description": "run typescript programs efficiently",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"author": "Lossless GmbH",
"license": "MIT",
"bin": {
"tsrun": "./cli.js"
},
"scripts": {
"test": "(tsbuild && node ./cli.js test/test.ts)",
"test": "(tsbuild && node ./cli.js test/test.js sayhello)",
"format": "(gitzone format)",
"build": "(tsbuild)"
"build": "(tsbuild)",
"buildDocs": "tsdoc"
},
"devDependencies": {
"@types/node": "^11.10.4",
"tslint": "^5.13.1",
"tslint-config-prettier": "^1.18.0"
"@git.zone/tsbuild": "^2.1.69",
"@push.rocks/smartcli": "^4.0.8",
"@types/node": "^20.5.6",
"node-fetch": "^3.3.2"
},
"dependencies": {
"@gitzone/tsbuild": "^2.1.8",
"@pushrocks/smartfile": "^7.0.0",
"ts-node": "^8.0.2",
"typescript": "^3.3.3333"
"@push.rocks/smartfile": "^10.0.30",
"@push.rocks/smartshell": "^3.0.3",
"ts-node": "^10.9.1",
"typescript": "5.1.6"
},
"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

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +1,26 @@
# tsrun
# @gitzone/tsrun
run typescript programs efficiently
## Availabililty
[![npm](https://gitzone.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/@gitzone/tsrun)
[![git](https://gitzone.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/gitzone/tsrun)
[![git](https://gitzone.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/gitzone/tsrun)
[![docs](https://gitzone.gitlab.io/assets/repo-button-docs.svg)](https://gitzone.gitlab.io/tsrun/)
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@gitzone/tsrun)
* [gitlab.com (source)](https://gitlab.com/gitzone/tsrun)
* [github.com (source mirror)](https://github.com/gitzone/tsrun)
* [docs (typedoc)](https://gitzone.gitlab.io/tsrun/)
## Status for master
[![build status](https://GitLab.com/gitzone/tsrun/badges/master/build.svg)](https://GitLab.com/gitzone/tsrun/commits/master)
[![coverage report](https://GitLab.com/gitzone/tsrun/badges/master/coverage.svg)](https://GitLab.com/gitzone/tsrun/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@gitzone/tsrun.svg)](https://www.npmjs.com/package/@gitzone/tsrun)
[![bitHound Dependencies](https://www.bithound.io/github/gitzonetools/tsrun/badges/dependencies.svg)](https://www.bithound.io/github/gitzonetools/tsrun/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/gitzonetools/tsrun/badges/code.svg)](https://www.bithound.io/github/gitzonetools/tsrun)
[![Known Vulnerabilities](https://snyk.io/test/npm/@gitzone/tsrun/badge.svg)](https://snyk.io/test/npm/@gitzone/tsrun)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/gitzone/tsrun/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/gitzone/tsrun/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@gitzone/tsrun)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/gitzone/tsrun)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@gitzone/tsrun)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@gitzone/tsrun)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@gitzone/tsrun)](https://lossless.cloud)
## Usage
@ -31,13 +32,16 @@ To simply run a TypeScript file on the fly type
tsrun myfiletorun.ts
```
There are two options available:
* `--nocache` will disable any caching. Caching speeds up execution, but causes problems in read only environments (e.g. sometimes docker containers are readonly)
* `--web` will inject browser types. this is useful when testing code with polyfills on node, but that is meant for the browser later on.
There are options available:
For further information read the linked docs at the top of this README.
- `--web` will inject browser types. this is useful when testing code with polyfills on node, but that is meant for the browser later on.
> licensed | **©** [Lossless GmbH](https://lossless.gmbh)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
## Contribution
[![repo-footer](https://gitzone.gitlab.io/assets/repo-footer.svg)](https://git.zone)
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)

View File

@ -1,2 +1,14 @@
const textToPost: string = 'Test runs!';
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
View 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'
}

View File

@ -1,36 +1,42 @@
import * as path from 'path';
import * as tsNode from 'ts-node';
import { CompilerOptions } from 'typescript';
import * as plugins from './plugins.js';
const __dirname = plugins.path.dirname(plugins.url.fileURLToPath(import.meta.url));
const defaultTsNodeOptions: tsNode.Options = {
compilerOptions: <CompilerOptions>{
lib: ['es2016', 'es2017'],
target: <any>'es2015', // Script Target should be a string -> 2 is for ES2015
experimentalDecorators: true
},
skipIgnore: true
export const runPath = async (pathArg: string, fromFileUrl?: string) => {
pathArg = fromFileUrl
? plugins.path.join(plugins.path.dirname(plugins.url.fileURLToPath(fromFileUrl)), pathArg)
: pathArg;
await runCli(pathArg);
};
if (process.argv.includes('--web')) {
const previousCompilerOptions = defaultTsNodeOptions.compilerOptions as CompilerOptions;
defaultTsNodeOptions.compilerOptions = {
...previousCompilerOptions,
lib: [...previousCompilerOptions.lib, 'dom']
}
}
if (process.argv.includes('--nocache')) {
// currently caching is not used
}
tsNode.register(defaultTsNodeOptions);
if (process.env.CLI_CALL_TSRUN) {
export const runCli = async (pathArg?: string) => {
// contents of argv array
// process.argv[0] -> node 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);
import(pathToLoad);
}
// 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
View 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
View 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 };

9
tsconfig.json Normal file
View File

@ -0,0 +1,9 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext"
}
}

View File

@ -1,3 +0,0 @@
{
"extends": "tslint-config-standard"
}