uni-run 1.0.13 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -25
- package/dist/app.js +79 -0
- package/dist/{arg.d.cts → arg.d.ts} +1 -1
- package/dist/{arg.cjs → arg.js} +3 -3
- package/dist/{arg-helper.d.cts → argHelper.d.ts} +3 -4
- package/dist/{arg-helper.cjs → argHelper.js} +2 -2
- package/dist/{bin.d.cts → bin.d.ts} +1 -1
- package/dist/{bin.cjs → bin.js} +2 -2
- package/dist/execution/{index.d.mts → index.d.ts} +1 -1
- package/dist/execution/{index.cjs → index.js} +3 -3
- package/dist/execution/{kill-process.d.cts → kill-process.d.ts} +1 -1
- package/dist/execution/{watcher.cjs → watcher.js} +2 -2
- package/dist/helpers/as.d.ts +1 -0
- package/dist/helpers/as.js +6 -0
- package/dist/helpers/get-config.d.ts +1 -0
- package/dist/helpers/get-config.js +30 -0
- package/dist/helpers/getConfig.d.ts +1 -0
- package/dist/helpers/getConfig.js +24 -0
- package/dist/helpers/getUserExecutors.d.ts +2 -0
- package/dist/helpers/getUserExecutors.js +18 -0
- package/dist/helpers/utils.d.ts +2 -0
- package/dist/helpers/utils.js +18 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +16 -0
- package/dist/lib/{colors.d.cts → colors.d.ts} +1 -1
- package/dist/lib/{colors.cjs → colors.js} +1 -1
- package/dist/scriptExecutors/checkRuntime.d.ts +2 -0
- package/dist/scriptExecutors/checkRuntime.js +42 -0
- package/dist/scriptExecutors/index.d.ts +3 -0
- package/dist/scriptExecutors/index.js +170 -0
- package/dist/scriptExecutors/types.t.d.ts +17 -0
- package/dist/scriptExecutors/types.t.js +2 -0
- package/package.json +9 -12
- package/dist/app.cjs +0 -60
- package/dist/app.d.mts +0 -1
- package/dist/app.mjs +0 -32
- package/dist/arg-helper.d.mts +0 -141
- package/dist/arg-helper.mjs +0 -108
- package/dist/arg.d.mts +0 -277
- package/dist/arg.mjs +0 -9
- package/dist/bin.d.mts +0 -2
- package/dist/bin.mjs +0 -4
- package/dist/builtin-bin/Executor.cjs +0 -67
- package/dist/builtin-bin/Executor.d.cts +0 -21
- package/dist/builtin-bin/Executor.d.mts +0 -21
- package/dist/builtin-bin/Executor.mjs +0 -61
- package/dist/builtin-bin/index.cjs +0 -107
- package/dist/builtin-bin/index.d.cts +0 -3
- package/dist/builtin-bin/index.d.mts +0 -3
- package/dist/builtin-bin/index.mjs +0 -102
- package/dist/execution/gitignore.d.mts +0 -1
- package/dist/execution/gitignore.mjs +0 -11
- package/dist/execution/index.d.cts +0 -17
- package/dist/execution/index.mjs +0 -127
- package/dist/execution/kill-process.d.mts +0 -2
- package/dist/execution/kill-process.mjs +0 -24
- package/dist/execution/watcher.d.mts +0 -6
- package/dist/execution/watcher.mjs +0 -31
- package/dist/index.cjs +0 -19
- package/dist/index.d.cts +0 -8
- package/dist/index.d.mts +0 -8
- package/dist/index.mjs +0 -13
- package/dist/lib/colors.d.mts +0 -3
- package/dist/lib/colors.mjs +0 -4
- package/dist/lib/currentModule.d.mts +0 -5
- package/dist/lib/currentModule.mjs +0 -17
- package/dist/utils/debounce.d.mts +0 -1
- package/dist/utils/debounce.mjs +0 -7
- /package/dist/{app.d.cts → app.d.ts} +0 -0
- /package/dist/execution/{gitignore.d.cts → gitignore.d.ts} +0 -0
- /package/dist/execution/{gitignore.cjs → gitignore.js} +0 -0
- /package/dist/execution/{kill-process.cjs → kill-process.js} +0 -0
- /package/dist/execution/{watcher.d.cts → watcher.d.ts} +0 -0
- /package/dist/{utils/debounce.d.cts → helpers/debounce.d.ts} +0 -0
- /package/dist/{utils/debounce.cjs → helpers/debounce.js} +0 -0
- /package/dist/lib/{currentModule.d.cts → currentModule.d.ts} +0 -0
- /package/dist/lib/{currentModule.cjs → currentModule.js} +0 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const as_1 = __importDefault(require("../helpers/as"));
|
|
7
|
+
exports.default = (0, as_1.default)([
|
|
8
|
+
{
|
|
9
|
+
name: 'JavaScript',
|
|
10
|
+
exts: ['js', 'javascript', 'jsx', 'cjs', 'cjsx', 'mjs', 'mjsx'],
|
|
11
|
+
getRuntime(args, options, config) {
|
|
12
|
+
let installHints;
|
|
13
|
+
const runtime = config['javascript-runtime'] || 'node';
|
|
14
|
+
switch (runtime) {
|
|
15
|
+
case 'node':
|
|
16
|
+
installHints = ['Please install Node.js from https://nodejs.org'];
|
|
17
|
+
break;
|
|
18
|
+
case 'deno':
|
|
19
|
+
installHints = ['Please install Deno from https://deno.land'];
|
|
20
|
+
break;
|
|
21
|
+
case 'bun':
|
|
22
|
+
installHints = ['Please install Bun from https://bun.sh'];
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
run: [runtime, ...args],
|
|
27
|
+
isInstalled: [runtime, '--version'],
|
|
28
|
+
installHints,
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'TypeScript',
|
|
34
|
+
exts: ['ts', 'tsx', 'cts', 'ctsx', 'mts', 'mtsx'],
|
|
35
|
+
getRuntime(args, options, config) {
|
|
36
|
+
let installHints;
|
|
37
|
+
const runtime = options.tsNode
|
|
38
|
+
? 'ts-node'
|
|
39
|
+
: config['typescript-runtime'] || 'tsx';
|
|
40
|
+
switch (runtime) {
|
|
41
|
+
case 'tsx':
|
|
42
|
+
installHints = ['Please install tsx from https://tsx.is'];
|
|
43
|
+
break;
|
|
44
|
+
case 'ts-node':
|
|
45
|
+
installHints = [
|
|
46
|
+
'Please install ts-node from https://www.npmjs.com/package/ts-node',
|
|
47
|
+
];
|
|
48
|
+
break;
|
|
49
|
+
case 'deno':
|
|
50
|
+
installHints = ['Please install Deno from https://deno.land'];
|
|
51
|
+
break;
|
|
52
|
+
case 'bun':
|
|
53
|
+
installHints = ['Please install Bun from https://bun.sh'];
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
run: [runtime, ...args],
|
|
58
|
+
isInstalled: [runtime, '--version'],
|
|
59
|
+
installHints,
|
|
60
|
+
watchExts: ['js', 'javascript', 'jsx', 'cjs', 'cjsx', 'mjs', 'mjsx'],
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'Python',
|
|
66
|
+
exts: ['py'],
|
|
67
|
+
getRuntime(args, options, config) {
|
|
68
|
+
return {
|
|
69
|
+
run: ['python', ...args],
|
|
70
|
+
isInstalled: ['python', '--version'],
|
|
71
|
+
installHints: ['Please install Python from https://www.python.org'],
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'Java',
|
|
77
|
+
exts: ['java'],
|
|
78
|
+
getRuntime(args, options, config) {
|
|
79
|
+
return {
|
|
80
|
+
run: ['java', ...args],
|
|
81
|
+
isInstalled: ['java', '--version'],
|
|
82
|
+
installHints: ['Please install Java from https://www.oracle.com/java'],
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'Powershell',
|
|
88
|
+
exts: ['ps1'],
|
|
89
|
+
getRuntime(args, options, config) {
|
|
90
|
+
return {
|
|
91
|
+
run: ['powershell', '-File', ...args],
|
|
92
|
+
isInstalled: ['powershell', '-command', 'echo ok'],
|
|
93
|
+
installHints: [
|
|
94
|
+
'Please install Powershell from https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell',
|
|
95
|
+
],
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'Command Prompt',
|
|
101
|
+
exts: ['cmd', 'bat'],
|
|
102
|
+
getRuntime(args, options, config) {
|
|
103
|
+
return {
|
|
104
|
+
run: ['cmd', '/c', ...args],
|
|
105
|
+
isInstalled: ['cmd', '/c', 'echo ok'],
|
|
106
|
+
installHints: ['Please install Command Prompt from Windows'],
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: 'Shell Script',
|
|
112
|
+
exts: ['sh'],
|
|
113
|
+
getRuntime(args, options, config) {
|
|
114
|
+
return {
|
|
115
|
+
run: ['bash', ...args],
|
|
116
|
+
isInstalled: ['bash', '--version'],
|
|
117
|
+
installHints: [
|
|
118
|
+
'Please install Bash from https://www.gnu.org/software/bash',
|
|
119
|
+
],
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: 'Fish Shell Script',
|
|
125
|
+
exts: ['fish'],
|
|
126
|
+
getRuntime(args, options, config) {
|
|
127
|
+
return {
|
|
128
|
+
run: ['fish', ...args],
|
|
129
|
+
isInstalled: ['fish', '--version'],
|
|
130
|
+
installHints: ['Please install Fish from https://fishshell.com'],
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: 'Lua',
|
|
136
|
+
exts: ['lua'],
|
|
137
|
+
getRuntime(args, options, config) {
|
|
138
|
+
return {
|
|
139
|
+
run: ['lua', ...args],
|
|
140
|
+
isInstalled: ['lua', '-v'],
|
|
141
|
+
installHints: ['Please install Lua from https://www.lua.org'],
|
|
142
|
+
};
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: 'SASS (CSS)',
|
|
147
|
+
exts: ['sass', 'scss'],
|
|
148
|
+
getRuntime(args, options, config) {
|
|
149
|
+
return {
|
|
150
|
+
run: ['sass', ...args],
|
|
151
|
+
isInstalled: ['sass', '--version'],
|
|
152
|
+
installHints: ['Please install SASS from https://sass-lang.com'],
|
|
153
|
+
};
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: 'HTML Server',
|
|
158
|
+
exts: ['html', 'htm'],
|
|
159
|
+
getRuntime(args, options, config) {
|
|
160
|
+
return {
|
|
161
|
+
run: ['http-server', ...args],
|
|
162
|
+
isInstalled: ['http-server', '--version'],
|
|
163
|
+
installHints: [
|
|
164
|
+
'Please install http-server from https://www.npmjs.com/package/http-server',
|
|
165
|
+
],
|
|
166
|
+
watchExts: ['css', 'js', 'javascript', 'json'],
|
|
167
|
+
};
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
]);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ExecuteOptions } from '../argHelper';
|
|
2
|
+
export type ExecutorConfig = Partial<{
|
|
3
|
+
'javascript-runtime': string;
|
|
4
|
+
'typescript-runtime': string;
|
|
5
|
+
}>;
|
|
6
|
+
export type RuntimeOptions = {
|
|
7
|
+
run: string[];
|
|
8
|
+
install?: string[];
|
|
9
|
+
installHints?: string[];
|
|
10
|
+
isInstalled?: string[];
|
|
11
|
+
watchExts?: string[];
|
|
12
|
+
};
|
|
13
|
+
export type ScriptExecutorOptions = {
|
|
14
|
+
name: string;
|
|
15
|
+
exts: string[];
|
|
16
|
+
getRuntime(args: string[], options: Omit<ExecuteOptions, 'watchExtensions'>, config: ExecutorConfig): RuntimeOptions;
|
|
17
|
+
};
|
package/package.json
CHANGED
|
@@ -1,32 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uni-run",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Universal Runner for many language",
|
|
5
|
+
"type": "commonjs",
|
|
5
6
|
"scripts": {
|
|
6
|
-
"
|
|
7
|
-
"
|
|
7
|
+
"build": "tsc",
|
|
8
|
+
"dev": "tsc --watch",
|
|
8
9
|
"tsc": "tsc --watch --noEmit",
|
|
9
|
-
"cjs": "node --watch ./dist/__lab__/index.cjs",
|
|
10
|
-
"mjs": "node --watch ./dist/__lab__/index.mjs",
|
|
11
10
|
"lab": "run ./src/__lab__/index.ts --focus ./src"
|
|
12
11
|
},
|
|
13
|
-
"main": "./dist/index.
|
|
14
|
-
"module": "./dist/index.mjs",
|
|
12
|
+
"main": "./dist/index.js",
|
|
15
13
|
"bin": {
|
|
16
|
-
"run": "./dist/bin.
|
|
17
|
-
"uni-run": "./dist/bin.
|
|
14
|
+
"run": "./dist/bin.js",
|
|
15
|
+
"uni-run": "./dist/bin.js"
|
|
18
16
|
},
|
|
19
17
|
"dependencies": {
|
|
20
18
|
"ansi-colors": "^4.1.3",
|
|
21
19
|
"chokidar": "^4.0.1",
|
|
22
20
|
"cross-spawn": "^7.0.3",
|
|
23
21
|
"ignore": "^6.0.2",
|
|
24
|
-
"noarg": "^3.1.
|
|
22
|
+
"noarg": "^3.1.6"
|
|
25
23
|
},
|
|
26
24
|
"devDependencies": {
|
|
27
25
|
"@types/cross-spawn": "^6.0.6",
|
|
28
|
-
"@types/node": "^22.7.
|
|
29
|
-
"npmize": "^1.1.9",
|
|
26
|
+
"@types/node": "^22.7.4",
|
|
30
27
|
"typescript": "^5.6.2"
|
|
31
28
|
},
|
|
32
29
|
"repository": {
|
package/dist/app.cjs
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const arg = __importStar(require("./arg.cjs"));
|
|
30
|
-
const execution_1 = __importDefault(require("./execution/index.cjs"));
|
|
31
|
-
const builtin_bin_1 = __importDefault(require("./builtin-bin/index.cjs"));
|
|
32
|
-
const arg_helper_1 = require("./arg-helper.cjs");
|
|
33
|
-
arg.app.on(([script, listArs, trailingArgs], flags) => {
|
|
34
|
-
const bin = builtin_bin_1.default.find((bin) => bin.isSupported(script));
|
|
35
|
-
if (!bin) {
|
|
36
|
-
console.log('Unsupported script:', script);
|
|
37
|
-
return console.log('You may try "ur exec bin script.ext - --flags"');
|
|
38
|
-
}
|
|
39
|
-
const executionOptions = (0, arg_helper_1.mapFlagsToOptions)(flags, bin);
|
|
40
|
-
bin.start(executionOptions, [script, ...listArs, ...trailingArgs]);
|
|
41
|
-
});
|
|
42
|
-
arg.exec.on(([listArs, trailingArgs], flags) => {
|
|
43
|
-
execution_1.default.start([...listArs, ...trailingArgs], (0, arg_helper_1.mapFlagsToOptions)(flags));
|
|
44
|
-
});
|
|
45
|
-
arg.list.on(() => {
|
|
46
|
-
console.log('Supported scripts:');
|
|
47
|
-
builtin_bin_1.default
|
|
48
|
-
.sort((a, b) => {
|
|
49
|
-
const aName = a.getName();
|
|
50
|
-
const bName = b.getName();
|
|
51
|
-
if (aName < bName)
|
|
52
|
-
return -1;
|
|
53
|
-
if (aName > bName)
|
|
54
|
-
return 1;
|
|
55
|
-
return 0;
|
|
56
|
-
})
|
|
57
|
-
.forEach((bin) => {
|
|
58
|
-
console.log(`- ${bin.getName()}`);
|
|
59
|
-
});
|
|
60
|
-
});
|
package/dist/app.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/app.mjs
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import * as arg from "./arg.mjs";
|
|
2
|
-
import Execution from "./execution/index.mjs";
|
|
3
|
-
import builtinBin from "./builtin-bin/index.mjs";
|
|
4
|
-
import { mapFlagsToOptions } from "./arg-helper.mjs";
|
|
5
|
-
arg.app.on(([script, listArs, trailingArgs], flags) => {
|
|
6
|
-
const bin = builtinBin.find((bin) => bin.isSupported(script));
|
|
7
|
-
if (!bin) {
|
|
8
|
-
console.log('Unsupported script:', script);
|
|
9
|
-
return console.log('You may try "ur exec bin script.ext - --flags"');
|
|
10
|
-
}
|
|
11
|
-
const executionOptions = mapFlagsToOptions(flags, bin);
|
|
12
|
-
bin.start(executionOptions, [script, ...listArs, ...trailingArgs]);
|
|
13
|
-
});
|
|
14
|
-
arg.exec.on(([listArs, trailingArgs], flags) => {
|
|
15
|
-
Execution.start([...listArs, ...trailingArgs], mapFlagsToOptions(flags));
|
|
16
|
-
});
|
|
17
|
-
arg.list.on(() => {
|
|
18
|
-
console.log('Supported scripts:');
|
|
19
|
-
builtinBin
|
|
20
|
-
.sort((a, b) => {
|
|
21
|
-
const aName = a.getName();
|
|
22
|
-
const bName = b.getName();
|
|
23
|
-
if (aName < bName)
|
|
24
|
-
return -1;
|
|
25
|
-
if (aName > bName)
|
|
26
|
-
return 1;
|
|
27
|
-
return 0;
|
|
28
|
-
})
|
|
29
|
-
.forEach((bin) => {
|
|
30
|
-
console.log(`- ${bin.getName()}`);
|
|
31
|
-
});
|
|
32
|
-
});
|
package/dist/arg-helper.d.mts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import NoArg from "noarg";
|
|
2
|
-
import type { app } from "./arg.mjs";
|
|
3
|
-
import Executor from "./builtin-bin/Executor.mjs";
|
|
4
|
-
export declare const executionConfig: {
|
|
5
|
-
readonly flags: {
|
|
6
|
-
readonly 'key-reload': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
7
|
-
aliases: ["k"];
|
|
8
|
-
required: true;
|
|
9
|
-
default: true;
|
|
10
|
-
description: "Reload the page when pressing 'Ctrl+R' or 'F5'";
|
|
11
|
-
}>;
|
|
12
|
-
readonly watch: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
13
|
-
aliases: ["w"];
|
|
14
|
-
required: true;
|
|
15
|
-
default: true;
|
|
16
|
-
description: "Watch for file changes and reload the script";
|
|
17
|
-
}>;
|
|
18
|
-
readonly exit: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
19
|
-
required: true;
|
|
20
|
-
default: false;
|
|
21
|
-
description: "Exit after code execution, disabling `watch` and `reloadKey`";
|
|
22
|
-
}>;
|
|
23
|
-
readonly delay: import("noarg/dist/schema/TypeNumber.cjs").TypeNumber<{
|
|
24
|
-
aliases: ["d"];
|
|
25
|
-
required: true;
|
|
26
|
-
default: 100;
|
|
27
|
-
description: "The delay to wait for the watcher to trigger";
|
|
28
|
-
}>;
|
|
29
|
-
readonly ext: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
|
|
30
|
-
aliases: ["e"];
|
|
31
|
-
required: true;
|
|
32
|
-
default: never[];
|
|
33
|
-
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
34
|
-
description: "Looks for changes only of the given extensions";
|
|
35
|
-
}>;
|
|
36
|
-
readonly focus: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
|
|
37
|
-
aliases: ["f"];
|
|
38
|
-
required: true;
|
|
39
|
-
default: never[];
|
|
40
|
-
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
41
|
-
description: "Only watch the given items. `chokidar` syntax";
|
|
42
|
-
}>;
|
|
43
|
-
readonly ignore: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
|
|
44
|
-
aliases: ["ig"];
|
|
45
|
-
required: true;
|
|
46
|
-
default: never[];
|
|
47
|
-
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
48
|
-
description: "Exclude the given items. `gitignore` syntax";
|
|
49
|
-
}>;
|
|
50
|
-
readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
51
|
-
aliases: ["b"];
|
|
52
|
-
description: "Calculate the execution time";
|
|
53
|
-
}>;
|
|
54
|
-
readonly 'bench-prefix': import("noarg/dist/schema/TypeString.cjs").TypeString<{
|
|
55
|
-
aliases: ["bp"];
|
|
56
|
-
minLength: 1;
|
|
57
|
-
description: "The prefix to show before the execution time";
|
|
58
|
-
}>;
|
|
59
|
-
readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
60
|
-
aliases: ["c"];
|
|
61
|
-
required: true;
|
|
62
|
-
default: true;
|
|
63
|
-
description: "Clear the console before running the script";
|
|
64
|
-
}>;
|
|
65
|
-
readonly silent: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
66
|
-
required: true;
|
|
67
|
-
default: false;
|
|
68
|
-
description: "Do not show any output of the script";
|
|
69
|
-
}>;
|
|
70
|
-
readonly cwd: import("noarg/dist/schema/TypeString.cjs").TypeString<{
|
|
71
|
-
required: true;
|
|
72
|
-
default: string;
|
|
73
|
-
description: "Current working directory";
|
|
74
|
-
}>;
|
|
75
|
-
readonly shell: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
76
|
-
required: true;
|
|
77
|
-
default: false;
|
|
78
|
-
description: "Run the script in a shell for more low-level control";
|
|
79
|
-
}>;
|
|
80
|
-
readonly 'safe-stdin': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
81
|
-
required: true;
|
|
82
|
-
default: false;
|
|
83
|
-
description: "Disable raw mode for stdin (useful for some scripts)";
|
|
84
|
-
}>;
|
|
85
|
-
readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
86
|
-
required: true;
|
|
87
|
-
default: false;
|
|
88
|
-
description: "Show information about the script";
|
|
89
|
-
}>;
|
|
90
|
-
readonly time: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
91
|
-
required: true;
|
|
92
|
-
default: false;
|
|
93
|
-
description: "Show the execution time at the start";
|
|
94
|
-
}>;
|
|
95
|
-
readonly env: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
|
|
96
|
-
required: true;
|
|
97
|
-
default: never[];
|
|
98
|
-
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
99
|
-
description: "Environment variables";
|
|
100
|
-
}>;
|
|
101
|
-
readonly 'node-dev': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
102
|
-
required: true;
|
|
103
|
-
default: false;
|
|
104
|
-
description: "Set NODE_ENV to \"development\"";
|
|
105
|
-
}>;
|
|
106
|
-
readonly tsn: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
107
|
-
required: true;
|
|
108
|
-
default: false;
|
|
109
|
-
description: "Run the script with ts-node (TypeScript)";
|
|
110
|
-
}>;
|
|
111
|
-
};
|
|
112
|
-
readonly listArgument: {
|
|
113
|
-
readonly name: "args for script";
|
|
114
|
-
readonly description: "The arguments to pass to the script";
|
|
115
|
-
readonly type: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
116
|
-
};
|
|
117
|
-
readonly trailingArguments: "--";
|
|
118
|
-
readonly customRenderHelp: {
|
|
119
|
-
readonly helpUsageTrailingArgsLabel: "...[args/flags for script]";
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
export type ExecuteOptions = ReturnType<typeof mapFlagsToOptions>;
|
|
123
|
-
export declare function mapFlagsToOptions(flags: NoArg.InferFlags<typeof app>, bin?: Executor): {
|
|
124
|
-
cwd: string;
|
|
125
|
-
shell: boolean;
|
|
126
|
-
silent: boolean;
|
|
127
|
-
stdinSafeMode: boolean;
|
|
128
|
-
showInfo: boolean;
|
|
129
|
-
showTime: boolean;
|
|
130
|
-
benchmark: boolean;
|
|
131
|
-
benchmarkPrefix: string | undefined;
|
|
132
|
-
clearOnReload: boolean;
|
|
133
|
-
keystrokeReload: boolean;
|
|
134
|
-
watch: boolean;
|
|
135
|
-
watchDelay: number;
|
|
136
|
-
watchFocus: string[];
|
|
137
|
-
watchIgnore: string[];
|
|
138
|
-
watchExtensions: string[];
|
|
139
|
-
tsNode: boolean;
|
|
140
|
-
env: NodeJS.ProcessEnv;
|
|
141
|
-
};
|
package/dist/arg-helper.mjs
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import NoArg from "noarg";
|
|
2
|
-
export const executionConfig = NoArg.defineConfig({
|
|
3
|
-
flags: {
|
|
4
|
-
// Watch/Reload flags
|
|
5
|
-
'key-reload': NoArg.boolean()
|
|
6
|
-
.aliases('k')
|
|
7
|
-
.default(true)
|
|
8
|
-
.description("Reload the page when pressing 'Ctrl+R' or 'F5'"),
|
|
9
|
-
watch: NoArg.boolean()
|
|
10
|
-
.aliases('w')
|
|
11
|
-
.default(true)
|
|
12
|
-
.description('Watch for file changes and reload the script'),
|
|
13
|
-
exit: NoArg.boolean()
|
|
14
|
-
.default(false)
|
|
15
|
-
.description('Exit after code execution, disabling `watch` and `reloadKey`'),
|
|
16
|
-
delay: NoArg.number()
|
|
17
|
-
.aliases('d')
|
|
18
|
-
.default(100)
|
|
19
|
-
.description('The delay to wait for the watcher to trigger'),
|
|
20
|
-
ext: NoArg.array(NoArg.string())
|
|
21
|
-
.aliases('e')
|
|
22
|
-
.default([])
|
|
23
|
-
.description('Looks for changes only of the given extensions'),
|
|
24
|
-
focus: NoArg.array(NoArg.string())
|
|
25
|
-
.aliases('f')
|
|
26
|
-
.default([])
|
|
27
|
-
.description('Only watch the given items. `chokidar` syntax'),
|
|
28
|
-
ignore: NoArg.array(NoArg.string())
|
|
29
|
-
.aliases('ig')
|
|
30
|
-
.default([])
|
|
31
|
-
.description('Exclude the given items. `gitignore` syntax'),
|
|
32
|
-
// Benchmark flags
|
|
33
|
-
bench: NoArg.boolean()
|
|
34
|
-
.aliases('b')
|
|
35
|
-
.description('Calculate the execution time'),
|
|
36
|
-
'bench-prefix': NoArg.string()
|
|
37
|
-
.aliases('bp')
|
|
38
|
-
.minLength(1)
|
|
39
|
-
.description('The prefix to show before the execution time'),
|
|
40
|
-
clear: NoArg.boolean()
|
|
41
|
-
.aliases('c')
|
|
42
|
-
.default(true)
|
|
43
|
-
.description('Clear the console before running the script'),
|
|
44
|
-
silent: NoArg.boolean()
|
|
45
|
-
.default(false)
|
|
46
|
-
.description('Do not show any output of the script'),
|
|
47
|
-
cwd: NoArg.string()
|
|
48
|
-
.default(process.cwd())
|
|
49
|
-
.description('Current working directory'),
|
|
50
|
-
shell: NoArg.boolean()
|
|
51
|
-
.default(false)
|
|
52
|
-
.description('Run the script in a shell for more low-level control'),
|
|
53
|
-
'safe-stdin': NoArg.boolean()
|
|
54
|
-
.default(false)
|
|
55
|
-
.description('Disable raw mode for stdin (useful for some scripts)'),
|
|
56
|
-
info: NoArg.boolean()
|
|
57
|
-
.default(false)
|
|
58
|
-
.description('Show information about the script'),
|
|
59
|
-
time: NoArg.boolean()
|
|
60
|
-
.default(false)
|
|
61
|
-
.description('Show the execution time at the start'),
|
|
62
|
-
env: NoArg.array(NoArg.string())
|
|
63
|
-
.default([])
|
|
64
|
-
.description('Environment variables'),
|
|
65
|
-
// Extra flags
|
|
66
|
-
'node-dev': NoArg.boolean()
|
|
67
|
-
.default(false)
|
|
68
|
-
.description('Set NODE_ENV to "development"'),
|
|
69
|
-
tsn: NoArg.boolean()
|
|
70
|
-
.default(false)
|
|
71
|
-
.description('Run the script with ts-node (TypeScript)'),
|
|
72
|
-
},
|
|
73
|
-
listArgument: {
|
|
74
|
-
name: 'args for script',
|
|
75
|
-
description: 'The arguments to pass to the script',
|
|
76
|
-
type: NoArg.string(),
|
|
77
|
-
},
|
|
78
|
-
trailingArguments: '--',
|
|
79
|
-
customRenderHelp: {
|
|
80
|
-
helpUsageTrailingArgsLabel: '...[args/flags for script]',
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
export function mapFlagsToOptions(flags, bin) {
|
|
84
|
-
var _a;
|
|
85
|
-
return {
|
|
86
|
-
cwd: flags.cwd,
|
|
87
|
-
shell: flags.shell,
|
|
88
|
-
silent: flags.silent,
|
|
89
|
-
stdinSafeMode: flags['safe-stdin'],
|
|
90
|
-
showInfo: flags.info,
|
|
91
|
-
showTime: flags.time,
|
|
92
|
-
benchmark: (_a = flags.bench) !== null && _a !== void 0 ? _a : Boolean(flags['bench-prefix']),
|
|
93
|
-
benchmarkPrefix: flags['bench-prefix'],
|
|
94
|
-
clearOnReload: flags.clear,
|
|
95
|
-
keystrokeReload: flags.exit ? false : flags['key-reload'],
|
|
96
|
-
watch: flags.exit ? false : flags.watch,
|
|
97
|
-
watchDelay: flags.delay,
|
|
98
|
-
watchFocus: flags.focus.length ? flags.focus : [flags.cwd],
|
|
99
|
-
watchIgnore: flags.ignore,
|
|
100
|
-
watchExtensions: (flags.ext.length ? flags.ext : bin === null || bin === void 0 ? void 0 : bin.getRelatedExts()) || [],
|
|
101
|
-
tsNode: flags['tsn'],
|
|
102
|
-
env: Object.assign(Object.assign({}, flags.env.reduce((acc, env) => {
|
|
103
|
-
const [key, value] = env.split('=');
|
|
104
|
-
acc[key] = value;
|
|
105
|
-
return acc;
|
|
106
|
-
}, {})), (flags['node-dev'] ? { NODE_ENV: 'development' } : {})),
|
|
107
|
-
};
|
|
108
|
-
}
|