Compare commits
22 Commits
Author | SHA1 | Date | |
---|---|---|---|
9e55126adf | |||
5271f0153e | |||
ba0aaf2793 | |||
1f46e387e7 | |||
03625bfca4 | |||
cc92e3e9ca | |||
c1e66d498a | |||
bfbb802e88 | |||
655fd8b92e | |||
a240cdfde1 | |||
2af7682cf0 | |||
c62619bd27 | |||
ffaf54f1de | |||
2c6b955819 | |||
9bb13e1ede | |||
d9bd5e5340 | |||
b76de3e04d | |||
808726d1df | |||
d011f10b9b | |||
d1baa20aad | |||
71779693d7 | |||
1113251aea |
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();
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
process.env.CLI_CALL = 'true';
|
process.env.CLI_CALL = 'true';
|
||||||
await import('@gitzone/tsrun');
|
|
||||||
const cliTool = await import('./ts/index.js');
|
import * as tsrun from '@gitzone/tsrun';
|
||||||
cliTool.runCli();
|
tsrun.runPath('./cli.child.js', import.meta.url);
|
||||||
|
1305
package-lock.json
generated
1305
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
16
package.json
16
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tsrun",
|
"name": "@gitzone/tsrun",
|
||||||
"version": "1.2.26",
|
"version": "1.2.37",
|
||||||
"description": "run typescript programs efficiently",
|
"description": "run typescript programs efficiently",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
@ -16,18 +16,16 @@
|
|||||||
"build": "(tsbuild)"
|
"build": "(tsbuild)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.43",
|
"@gitzone/tsbuild": "^2.1.63",
|
||||||
"@pushrocks/smartcli": "^3.0.14",
|
"@pushrocks/smartcli": "^3.0.14",
|
||||||
"@types/node": "^17.0.21",
|
"@types/node": "^17.0.42",
|
||||||
"node-fetch": "^3.2.2",
|
"node-fetch": "^3.2.6"
|
||||||
"tslint": "^6.1.2",
|
|
||||||
"tslint-config-prettier": "^1.18.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartfile": "^9.0.6",
|
"@pushrocks/smartfile": "^10.0.2",
|
||||||
"@pushrocks/smartshell": "^2.0.30",
|
"@pushrocks/smartshell": "^2.0.30",
|
||||||
"ts-node": "^10.7.0",
|
"ts-node": "^10.8.1",
|
||||||
"typescript": "4.7.0-dev.20220311"
|
"typescript": "^4.7.3"
|
||||||
},
|
},
|
||||||
"private": false,
|
"private": false,
|
||||||
"files": [
|
"files": [
|
||||||
|
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: '@gitzone/tsrun',
|
||||||
|
version: '1.2.37',
|
||||||
|
description: 'run typescript programs efficiently'
|
||||||
|
}
|
43
ts/index.ts
43
ts/index.ts
@ -1,35 +1,42 @@
|
|||||||
import * as plugins from './plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
|
const __dirname = plugins.path.dirname(plugins.url.fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
import { dirname } from 'path';
|
export const runPath = async (pathArg: string, fromFileUrl?: string) => {
|
||||||
import { fileURLToPath } from 'url';
|
pathArg = fromFileUrl
|
||||||
|
? plugins.path.join(plugins.path.dirname(plugins.url.fileURLToPath(fromFileUrl)), pathArg)
|
||||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
: pathArg;
|
||||||
|
|
||||||
export const runPath = async (pathArg: string) => {
|
|
||||||
await runCli(pathArg);
|
await runCli(pathArg);
|
||||||
}
|
};
|
||||||
|
|
||||||
export const runCli = async (pathArg?: string) => {
|
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 relativePathToTsFile = pathArg ? pathArg : process.argv[2];
|
const relativePathToTsFile = pathArg ? pathArg : process.argv[2];
|
||||||
const absolutePathToTsFile = plugins.path.join(process.cwd(), relativePathToTsFile);
|
const absolutePathToTsFile = plugins.path.isAbsolute(relativePathToTsFile)
|
||||||
|
? relativePathToTsFile
|
||||||
|
: plugins.path.join(process.cwd(), relativePathToTsFile);
|
||||||
process.argv.splice(0, 3); // this ensures transparent arguments for the child process
|
|
||||||
|
// 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
|
// lets setup things for execution
|
||||||
const smartshellInstance = new plugins.smartshell.Smartshell({
|
const smartshellInstance = new plugins.smartshell.Smartshell({
|
||||||
executor: 'bash'
|
executor: 'bash',
|
||||||
});
|
});
|
||||||
|
|
||||||
const tsNodeLoaderPath = plugins.path.join(__dirname, 'loader.js')
|
const tsNodeLoaderPath = plugins.path.join(__dirname, 'loader.js');
|
||||||
// note: -> reduce on emtpy array does not work
|
// note: -> reduce on emtpy array does not work
|
||||||
// thus check needed before reducing the argv array
|
// thus check needed before reducing the argv array
|
||||||
smartshellInstance.exec(`node --loader ${tsNodeLoaderPath} ${absolutePathToTsFile} ${process.argv.length > 0 ? process.argv.reduce((prevArg, currentArg) => {
|
smartshellInstance.exec(
|
||||||
return prevArg + ' ' + currentArg;
|
`node --loader ${tsNodeLoaderPath} ${absolutePathToTsFile} ${
|
||||||
}) : ''}`);
|
process.argv.length > 0
|
||||||
|
? process.argv.reduce((prevArg, currentArg) => {
|
||||||
|
return prevArg + ' ' + currentArg;
|
||||||
|
})
|
||||||
|
: ''
|
||||||
|
}`
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
@ -4,11 +4,12 @@ import type { CompilerOptions } from 'typescript';
|
|||||||
const defaultTsNodeOptions: plugins.tsNode.CreateOptions = {
|
const defaultTsNodeOptions: plugins.tsNode.CreateOptions = {
|
||||||
compilerOptions: {
|
compilerOptions: {
|
||||||
lib: ['dom'],
|
lib: ['dom'],
|
||||||
target: <any>'es2020', // Script Target should be a string -> 2 is for ES2015
|
target: <any>'es2022', // Script Target should be a string -> 2 is for ES2015
|
||||||
experimentalDecorators: true,
|
experimentalDecorators: true,
|
||||||
|
useDefineForClassFields: false,
|
||||||
esModuleInterop: true,
|
esModuleInterop: true,
|
||||||
strictNullChecks: false,
|
strictNullChecks: false,
|
||||||
moduleResolution: <any>'node12',
|
moduleResolution: <any>'nodenext',
|
||||||
module: <any>'ESNext',
|
module: <any>'ESNext',
|
||||||
importsNotUsedAsValues: <any>'preserve',
|
importsNotUsedAsValues: <any>'preserve',
|
||||||
} as CompilerOptions,
|
} as CompilerOptions,
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
// node native
|
||||||
|
import * as path from 'path';
|
||||||
|
import * as url from 'url';
|
||||||
|
|
||||||
|
export {
|
||||||
|
path,
|
||||||
|
url
|
||||||
|
}
|
||||||
|
|
||||||
// @pushrocks scope
|
// @pushrocks scope
|
||||||
import * as smartshell from '@pushrocks/smartshell';
|
import * as smartshell from '@pushrocks/smartshell';
|
||||||
|
|
||||||
@ -6,10 +15,8 @@ export {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// third party scope
|
// third party scope
|
||||||
import * as path from 'path';
|
|
||||||
import * as tsNode from 'ts-node';
|
import * as tsNode from 'ts-node';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
path,
|
|
||||||
tsNode
|
tsNode
|
||||||
}
|
}
|
@ -1,7 +1,9 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
"module": "ES2022",
|
"module": "ES2022",
|
||||||
"target": "ES2020",
|
"moduleResolution": "nodenext"
|
||||||
"moduleResolution": "Node12"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user