uni-run 1.0.0 → 1.0.2
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/dist/arg-helper.d.ts +31 -5
- package/dist/arg-helper.js +31 -11
- package/dist/arg.d.ts +58 -8
- package/dist/builtin-bin/index.js +1 -1
- package/dist/execution/index.d.ts +4 -0
- package/dist/execution/index.js +18 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/arg-helper.d.ts
CHANGED
|
@@ -1,12 +1,33 @@
|
|
|
1
1
|
import NoArg from 'noarg';
|
|
2
2
|
import type { app } from './arg';
|
|
3
3
|
import { ExecuteOptions } from './execution';
|
|
4
|
+
import Executor from './builtin-bin/Executor';
|
|
4
5
|
export declare const executionConfig: {
|
|
5
6
|
readonly flags: {
|
|
6
7
|
readonly cwd: import("noarg/dist/schema/TypeString.cjs").TypeString<{
|
|
7
8
|
required: true;
|
|
8
9
|
default: string;
|
|
9
|
-
description: "
|
|
10
|
+
description: "Current working directory";
|
|
11
|
+
}>;
|
|
12
|
+
readonly shell: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
13
|
+
required: true;
|
|
14
|
+
default: false;
|
|
15
|
+
description: "Run the script in a shell for more low-level control";
|
|
16
|
+
}>;
|
|
17
|
+
readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
18
|
+
required: true;
|
|
19
|
+
default: false;
|
|
20
|
+
description: "Show information about the script";
|
|
21
|
+
}>;
|
|
22
|
+
readonly time: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
23
|
+
required: true;
|
|
24
|
+
default: false;
|
|
25
|
+
description: "Show the execution time at the start";
|
|
26
|
+
}>;
|
|
27
|
+
readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
28
|
+
required: true;
|
|
29
|
+
default: false;
|
|
30
|
+
description: "Show the execution time";
|
|
10
31
|
}>;
|
|
11
32
|
readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
12
33
|
description: "Clear the console before running the script";
|
|
@@ -15,7 +36,7 @@ export declare const executionConfig: {
|
|
|
15
36
|
aliases: [string];
|
|
16
37
|
}>;
|
|
17
38
|
readonly reloadKey: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
18
|
-
description: "Reload the page when pressing
|
|
39
|
+
description: "Reload the page when pressing 'Ctrl+R' or 'F5'";
|
|
19
40
|
required: true;
|
|
20
41
|
default: true;
|
|
21
42
|
aliases: [string];
|
|
@@ -40,7 +61,7 @@ export declare const executionConfig: {
|
|
|
40
61
|
aliases: [string];
|
|
41
62
|
}>;
|
|
42
63
|
readonly ignore: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
|
|
43
|
-
description: "Ignore the given
|
|
64
|
+
description: "Ignore the given folders/files";
|
|
44
65
|
required: true;
|
|
45
66
|
default: never[];
|
|
46
67
|
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
@@ -52,6 +73,11 @@ export declare const executionConfig: {
|
|
|
52
73
|
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
53
74
|
description: "Environment variables";
|
|
54
75
|
}>;
|
|
76
|
+
readonly nodeDev: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
77
|
+
required: true;
|
|
78
|
+
default: false;
|
|
79
|
+
description: "Set NODE_ENV to \"development\"";
|
|
80
|
+
}>;
|
|
55
81
|
};
|
|
56
82
|
readonly listArgument: {
|
|
57
83
|
readonly name: "args for script";
|
|
@@ -60,7 +86,7 @@ export declare const executionConfig: {
|
|
|
60
86
|
};
|
|
61
87
|
readonly trailingArguments: "--";
|
|
62
88
|
readonly customRenderHelp: {
|
|
63
|
-
readonly helpUsageTrailingArgsLabel: "
|
|
89
|
+
readonly helpUsageTrailingArgsLabel: "...[args/flags for script]";
|
|
64
90
|
};
|
|
65
91
|
};
|
|
66
|
-
export declare function mapFlagsToOptions(flags: NoArg.InferFlags<typeof app>,
|
|
92
|
+
export declare function mapFlagsToOptions(flags: NoArg.InferFlags<typeof app>, bin?: Executor): ExecuteOptions;
|
package/dist/arg-helper.js
CHANGED
|
@@ -7,14 +7,26 @@ exports.executionConfig = noarg_1.default.defineConfig({
|
|
|
7
7
|
flags: {
|
|
8
8
|
cwd: noarg_1.default.string()
|
|
9
9
|
.default(process.cwd())
|
|
10
|
-
.description('
|
|
10
|
+
.description('Current working directory'),
|
|
11
|
+
shell: noarg_1.default.boolean()
|
|
12
|
+
.default(false)
|
|
13
|
+
.description('Run the script in a shell for more low-level control'),
|
|
14
|
+
info: noarg_1.default.boolean()
|
|
15
|
+
.default(false)
|
|
16
|
+
.description('Show information about the script'),
|
|
17
|
+
time: noarg_1.default.boolean()
|
|
18
|
+
.default(false)
|
|
19
|
+
.description('Show the execution time at the start'),
|
|
20
|
+
bench: noarg_1.default.boolean()
|
|
21
|
+
.default(false)
|
|
22
|
+
.description('Show the execution time'),
|
|
11
23
|
clear: noarg_1.default.boolean()
|
|
12
24
|
.default(true)
|
|
13
25
|
.description('Clear the console before running the script')
|
|
14
26
|
.aliases('c'),
|
|
15
27
|
reloadKey: noarg_1.default.boolean()
|
|
16
28
|
.default(true)
|
|
17
|
-
.description(
|
|
29
|
+
.description("Reload the page when pressing 'Ctrl+R' or 'F5'")
|
|
18
30
|
.aliases('rk'),
|
|
19
31
|
watch: noarg_1.default.boolean()
|
|
20
32
|
.default(true)
|
|
@@ -30,11 +42,14 @@ exports.executionConfig = noarg_1.default.defineConfig({
|
|
|
30
42
|
.aliases('e'),
|
|
31
43
|
ignore: noarg_1.default.array(noarg_1.default.string())
|
|
32
44
|
.default([])
|
|
33
|
-
.description('Ignore the given
|
|
45
|
+
.description('Ignore the given folders/files')
|
|
34
46
|
.aliases('ig'),
|
|
35
47
|
env: noarg_1.default.array(noarg_1.default.string())
|
|
36
48
|
.default([])
|
|
37
49
|
.description('Environment variables'),
|
|
50
|
+
nodeDev: noarg_1.default.boolean()
|
|
51
|
+
.default(false)
|
|
52
|
+
.description('Set NODE_ENV to "development"'),
|
|
38
53
|
},
|
|
39
54
|
listArgument: {
|
|
40
55
|
name: 'args for script',
|
|
@@ -43,22 +58,27 @@ exports.executionConfig = noarg_1.default.defineConfig({
|
|
|
43
58
|
},
|
|
44
59
|
trailingArguments: '--',
|
|
45
60
|
customRenderHelp: {
|
|
46
|
-
helpUsageTrailingArgsLabel: '
|
|
61
|
+
helpUsageTrailingArgsLabel: '...[args/flags for script]',
|
|
47
62
|
},
|
|
48
63
|
});
|
|
49
|
-
function mapFlagsToOptions(flags,
|
|
64
|
+
function mapFlagsToOptions(flags, bin) {
|
|
65
|
+
var _a, _b;
|
|
50
66
|
return {
|
|
51
67
|
cwd: flags.cwd,
|
|
68
|
+
shell: flags.shell,
|
|
69
|
+
showInfo: flags.info,
|
|
70
|
+
showTime: flags.time,
|
|
71
|
+
benchmark: flags.bench,
|
|
52
72
|
clearOnReload: flags.clear,
|
|
53
73
|
readlineReload: flags.reloadKey,
|
|
54
|
-
env: flags.env.reduce((acc, env) => {
|
|
55
|
-
const [key, value] = env.split('=');
|
|
56
|
-
acc[key] = value;
|
|
57
|
-
return acc;
|
|
58
|
-
}, {}),
|
|
59
74
|
watch: flags.watch,
|
|
60
75
|
watchDelay: flags.delay,
|
|
61
|
-
watchExtensions: flags.ext.length ? flags.ext : watchExtensions !== null &&
|
|
76
|
+
watchExtensions: (_b = (_a = (flags.ext.length ? flags.ext : bin === null || bin === void 0 ? void 0 : bin.config.watchExtensions)) !== null && _a !== void 0 ? _a : bin === null || bin === void 0 ? void 0 : bin.config.extensions) !== null && _b !== void 0 ? _b : [],
|
|
62
77
|
watchIgnore: flags.ignore,
|
|
78
|
+
env: Object.assign(Object.assign({}, flags.env.reduce((acc, env) => {
|
|
79
|
+
const [key, value] = env.split('=');
|
|
80
|
+
acc[key] = value;
|
|
81
|
+
return acc;
|
|
82
|
+
}, {})), (flags.nodeDev ? { NODE_ENV: 'development' } : {})),
|
|
63
83
|
};
|
|
64
84
|
}
|
package/dist/arg.d.ts
CHANGED
|
@@ -25,7 +25,27 @@ export declare const app: NoArg<"uni-run", {
|
|
|
25
25
|
readonly cwd: import("noarg/dist/schema/TypeString.cjs").TypeString<{
|
|
26
26
|
required: true;
|
|
27
27
|
default: string;
|
|
28
|
-
description: "
|
|
28
|
+
description: "Current working directory";
|
|
29
|
+
}>;
|
|
30
|
+
readonly shell: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
31
|
+
required: true;
|
|
32
|
+
default: false;
|
|
33
|
+
description: "Run the script in a shell for more low-level control";
|
|
34
|
+
}>;
|
|
35
|
+
readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
36
|
+
required: true;
|
|
37
|
+
default: false;
|
|
38
|
+
description: "Show information about the script";
|
|
39
|
+
}>;
|
|
40
|
+
readonly time: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
41
|
+
required: true;
|
|
42
|
+
default: false;
|
|
43
|
+
description: "Show the execution time at the start";
|
|
44
|
+
}>;
|
|
45
|
+
readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
46
|
+
required: true;
|
|
47
|
+
default: false;
|
|
48
|
+
description: "Show the execution time";
|
|
29
49
|
}>;
|
|
30
50
|
readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
31
51
|
description: "Clear the console before running the script";
|
|
@@ -34,7 +54,7 @@ export declare const app: NoArg<"uni-run", {
|
|
|
34
54
|
aliases: [string];
|
|
35
55
|
}>;
|
|
36
56
|
readonly reloadKey: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
37
|
-
description: "Reload the page when pressing
|
|
57
|
+
description: "Reload the page when pressing 'Ctrl+R' or 'F5'";
|
|
38
58
|
required: true;
|
|
39
59
|
default: true;
|
|
40
60
|
aliases: [string];
|
|
@@ -59,7 +79,7 @@ export declare const app: NoArg<"uni-run", {
|
|
|
59
79
|
aliases: [string];
|
|
60
80
|
}>;
|
|
61
81
|
readonly ignore: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
|
|
62
|
-
description: "Ignore the given
|
|
82
|
+
description: "Ignore the given folders/files";
|
|
63
83
|
required: true;
|
|
64
84
|
default: never[];
|
|
65
85
|
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
@@ -71,9 +91,14 @@ export declare const app: NoArg<"uni-run", {
|
|
|
71
91
|
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
72
92
|
description: "Environment variables";
|
|
73
93
|
}>;
|
|
94
|
+
readonly nodeDev: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
95
|
+
required: true;
|
|
96
|
+
default: false;
|
|
97
|
+
description: "Set NODE_ENV to \"development\"";
|
|
98
|
+
}>;
|
|
74
99
|
};
|
|
75
100
|
readonly customRenderHelp: {
|
|
76
|
-
readonly helpUsageTrailingArgsLabel: "
|
|
101
|
+
readonly helpUsageTrailingArgsLabel: "...[args/flags for script]";
|
|
77
102
|
};
|
|
78
103
|
}>;
|
|
79
104
|
export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProgram<"exec", {
|
|
@@ -97,7 +122,27 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
|
|
|
97
122
|
readonly cwd: import("noarg/dist/schema/TypeString.cjs").TypeString<{
|
|
98
123
|
required: true;
|
|
99
124
|
default: string;
|
|
100
|
-
description: "
|
|
125
|
+
description: "Current working directory";
|
|
126
|
+
}>;
|
|
127
|
+
readonly shell: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
128
|
+
required: true;
|
|
129
|
+
default: false;
|
|
130
|
+
description: "Run the script in a shell for more low-level control";
|
|
131
|
+
}>;
|
|
132
|
+
readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
133
|
+
required: true;
|
|
134
|
+
default: false;
|
|
135
|
+
description: "Show information about the script";
|
|
136
|
+
}>;
|
|
137
|
+
readonly time: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
138
|
+
required: true;
|
|
139
|
+
default: false;
|
|
140
|
+
description: "Show the execution time at the start";
|
|
141
|
+
}>;
|
|
142
|
+
readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
143
|
+
required: true;
|
|
144
|
+
default: false;
|
|
145
|
+
description: "Show the execution time";
|
|
101
146
|
}>;
|
|
102
147
|
readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
103
148
|
description: "Clear the console before running the script";
|
|
@@ -106,7 +151,7 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
|
|
|
106
151
|
aliases: [string];
|
|
107
152
|
}>;
|
|
108
153
|
readonly reloadKey: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
109
|
-
description: "Reload the page when pressing
|
|
154
|
+
description: "Reload the page when pressing 'Ctrl+R' or 'F5'";
|
|
110
155
|
required: true;
|
|
111
156
|
default: true;
|
|
112
157
|
aliases: [string];
|
|
@@ -131,7 +176,7 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
|
|
|
131
176
|
aliases: [string];
|
|
132
177
|
}>;
|
|
133
178
|
readonly ignore: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
|
|
134
|
-
description: "Ignore the given
|
|
179
|
+
description: "Ignore the given folders/files";
|
|
135
180
|
required: true;
|
|
136
181
|
default: never[];
|
|
137
182
|
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
@@ -143,9 +188,14 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
|
|
|
143
188
|
schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
|
|
144
189
|
description: "Environment variables";
|
|
145
190
|
}>;
|
|
191
|
+
readonly nodeDev: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
|
|
192
|
+
required: true;
|
|
193
|
+
default: false;
|
|
194
|
+
description: "Set NODE_ENV to \"development\"";
|
|
195
|
+
}>;
|
|
146
196
|
};
|
|
147
197
|
readonly customRenderHelp: {
|
|
148
|
-
readonly helpUsageTrailingArgsLabel: "
|
|
198
|
+
readonly helpUsageTrailingArgsLabel: "...[args/flags for script]";
|
|
149
199
|
};
|
|
150
200
|
globalFlags: {};
|
|
151
201
|
}>;
|
|
@@ -93,7 +93,7 @@ exports.default = [
|
|
|
93
93
|
new Executor_1.default('HTML Server', {
|
|
94
94
|
command: 'http-server',
|
|
95
95
|
extensions: ['html', 'htm'],
|
|
96
|
-
watchExtensions: ['css', 'js', 'json'],
|
|
96
|
+
watchExtensions: ['css', 'js', 'javascript', 'json'],
|
|
97
97
|
checkInstallationArgs: ['--version'],
|
|
98
98
|
installCommands: [
|
|
99
99
|
{ command: 'npm', args: ['install', '-g', 'http-server'] },
|
package/dist/execution/index.js
CHANGED
|
@@ -43,19 +43,34 @@ class Execution {
|
|
|
43
43
|
runProcess() {
|
|
44
44
|
this.killProcess();
|
|
45
45
|
this.clearBeforeStart();
|
|
46
|
+
if (this.options.showTime) {
|
|
47
|
+
console.log('@', colors_1.default.yellow(new Date().toLocaleString()));
|
|
48
|
+
}
|
|
49
|
+
if (this.options.benchmark) {
|
|
50
|
+
console.time(colors_1.default.dim.blue('> Execution time'));
|
|
51
|
+
}
|
|
46
52
|
this.child = (0, cross_spawn_1.spawn)(this.command, this.args, {
|
|
47
53
|
stdio: 'inherit',
|
|
54
|
+
argv0: this.command,
|
|
48
55
|
cwd: this.options.cwd,
|
|
56
|
+
shell: this.options.shell,
|
|
49
57
|
env: Object.assign({}, this.options.env),
|
|
50
58
|
});
|
|
51
59
|
this.child.on('error', console.error);
|
|
52
60
|
this.child.on('exit', (code) => {
|
|
53
61
|
if (code && code > 0) {
|
|
54
|
-
console.log('');
|
|
55
62
|
console.log(colors_1.default.red(`Process exited with code: ${colors_1.default.yellow(String(code))}`));
|
|
56
63
|
}
|
|
64
|
+
if (this.options.benchmark) {
|
|
65
|
+
console.timeEnd(colors_1.default.dim.blue('> Execution time'));
|
|
66
|
+
}
|
|
67
|
+
if (this.options.watch && this.options.showInfo) {
|
|
68
|
+
console.log(colors_1.default.dim.blue('> Watching for extensions:'), colors_1.default.dim(this.options.watchExtensions
|
|
69
|
+
.map((ext) => colors_1.default.yellow(ext))
|
|
70
|
+
.join(', ') || colors_1.default.yellow('*')));
|
|
71
|
+
}
|
|
57
72
|
if (this.options.readlineReload) {
|
|
58
|
-
console.log(colors_1.default.blue.dim(
|
|
73
|
+
console.log(colors_1.default.blue.dim(`> Press ${colors_1.default.yellow('F5')} or ${colors_1.default.yellow('^R')} to reload...`));
|
|
59
74
|
}
|
|
60
75
|
});
|
|
61
76
|
}
|
|
@@ -69,6 +84,7 @@ class Execution {
|
|
|
69
84
|
this.child = null;
|
|
70
85
|
}
|
|
71
86
|
clearBeforeStart() {
|
|
87
|
+
return;
|
|
72
88
|
if (this.options.clearOnReload) {
|
|
73
89
|
process.stdout.write('\x1Bc');
|
|
74
90
|
console.clear();
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ arg.app.on(([script, listArs, trailingArgs], flags) => {
|
|
|
13
13
|
if (!bin.isInstalled()) {
|
|
14
14
|
return bin.renderHowToInstall();
|
|
15
15
|
}
|
|
16
|
-
execution_1.default.start(bin.getArgs(script, ...listArs, ...trailingArgs), (0, arg_helper_1.mapFlagsToOptions)(flags, bin
|
|
16
|
+
execution_1.default.start(bin.getArgs(script, ...listArs, ...trailingArgs), (0, arg_helper_1.mapFlagsToOptions)(flags, bin));
|
|
17
17
|
});
|
|
18
18
|
arg.exec.on(([listArs, trailingArgs], flags) => {
|
|
19
19
|
execution_1.default.start([...listArs, ...trailingArgs], (0, arg_helper_1.mapFlagsToOptions)(flags));
|