Compare commits

..

22 Commits

Author SHA1 Message Date
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
9 changed files with 774 additions and 382 deletions

2
cli.js
View File

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

View File

@ -1,5 +1,5 @@
#!/usr/bin/env node
process.env.CLI_CALL = 'true';
require('@gitzone/tsrun');
const cliTool = require('./ts/index');
await import('@gitzone/tsrun');
const cliTool = await import('./ts/index.js');
cliTool.runCli();

1029
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,29 +1,33 @@
{
"name": "@gitzone/tsrun",
"version": "1.2.13",
"version": "1.2.24",
"description": "run typescript programs efficiently",
"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)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.24",
"@types/node": "^15.12.4",
"@gitzone/tsbuild": "^2.1.43",
"@pushrocks/smartcli": "^3.0.14",
"@types/node": "^17.0.21",
"node-fetch": "^3.2.2",
"tslint": "^6.1.2",
"tslint-config-prettier": "^1.18.0"
},
"dependencies": {
"@pushrocks/smartfile": "^8.0.10",
"ts-node": "^10.0.0",
"typescript": "^4.3.4"
"@pushrocks/smartfile": "^9.0.6",
"@pushrocks/smartshell": "^2.0.30",
"ts-node": "^10.7.0",
"typescript": "4.7.0-dev.20220311"
},
"private": false,
"files": [

View File

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

View File

@ -1,31 +1,9 @@
import * as path from 'path';
import * as tsNode from 'ts-node';
import { CompilerOptions } from 'typescript';
import * as plugins from './plugins.js';
const defaultTsNodeOptions: tsNode.CreateOptions = {
compilerOptions: {
lib: ['es2017'],
target: <any>'es2017', // Script Target should be a string -> 2 is for ES2015
experimentalDecorators: true,
esModuleInterop: true,
} as CompilerOptions,
skipIgnore: true,
};
import { dirname } from 'path';
import { fileURLToPath } from 'url';
if (process.argv.includes('--web')) {
const previousCompilerOptions = defaultTsNodeOptions.compilerOptions as CompilerOptions;
defaultTsNodeOptions.compilerOptions = {
...previousCompilerOptions,
lib: ['es2016', 'es2017', 'dom'],
target: <any>'es2017', // Script Target should be a string -> 2 is for ES2015
};
}
if (process.argv.includes('--nocache')) {
// currently caching is not used
}
tsNode.register(defaultTsNodeOptions);
const __dirname = dirname(fileURLToPath(import.meta.url));
export const runCli = async () => {
// contents of argv array
@ -33,7 +11,16 @@ export const runCli = async () => {
// process.argv[1] -> tsrun executable
const pathToTsFile = process.argv[2];
const pathToLoad = path.join(process.cwd(), pathToTsFile);
process.argv.shift();
import(pathToLoad);
const tsNodeLoaderPath = plugins.path.join(__dirname, 'loader.js')
const pathToLoad = plugins.path.join(process.cwd(), pathToTsFile);
process.argv.splice(0, 3); // this ensures transparent arguments for the child process
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash'
});
smartshellInstance.exec(`node --loader ${tsNodeLoaderPath} ${pathToLoad} ${process.argv.length > 0 ? process.argv.reduce((prevArg, currentArg) => {
return prevArg + ' ' + currentArg;
}) : ''}`);
};

20
ts/loader.ts Normal file
View 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;

15
ts/plugins.ts Normal file
View File

@ -0,0 +1,15 @@
// @pushrocks scope
import * as smartshell from '@pushrocks/smartshell';
export {
smartshell
}
// third party scope
import * as path from 'path';
import * as tsNode from 'ts-node';
export {
path,
tsNode
}

7
tsconfig.json Normal file
View File

@ -0,0 +1,7 @@
{
"compilerOptions": {
"module": "ES2022",
"target": "ES2020",
"moduleResolution": "Node12"
}
}