uni-run 1.0.1 → 1.0.3

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.
@@ -1,6 +1,7 @@
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<{
@@ -13,6 +14,21 @@ export declare const executionConfig: {
13
14
  default: false;
14
15
  description: "Run the script in a shell for more low-level control";
15
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";
31
+ }>;
16
32
  readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
17
33
  description: "Clear the console before running the script";
18
34
  required: true;
@@ -73,4 +89,4 @@ export declare const executionConfig: {
73
89
  readonly helpUsageTrailingArgsLabel: "...[args/flags for script]";
74
90
  };
75
91
  };
76
- export declare function mapFlagsToOptions(flags: NoArg.InferFlags<typeof app>, watchExtensions?: string[]): ExecuteOptions;
92
+ export declare function mapFlagsToOptions(flags: NoArg.InferFlags<typeof app>, bin?: Executor): ExecuteOptions;
@@ -11,6 +11,15 @@ exports.executionConfig = noarg_1.default.defineConfig({
11
11
  shell: noarg_1.default.boolean()
12
12
  .default(false)
13
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'),
14
23
  clear: noarg_1.default.boolean()
15
24
  .default(true)
16
25
  .description('Clear the console before running the script')
@@ -52,20 +61,24 @@ exports.executionConfig = noarg_1.default.defineConfig({
52
61
  helpUsageTrailingArgsLabel: '...[args/flags for script]',
53
62
  },
54
63
  });
55
- function mapFlagsToOptions(flags, watchExtensions) {
64
+ function mapFlagsToOptions(flags, bin) {
65
+ var _a, _b;
56
66
  return {
57
67
  cwd: flags.cwd,
58
68
  shell: flags.shell,
69
+ showInfo: flags.info,
70
+ showTime: flags.time,
71
+ benchmark: flags.bench,
59
72
  clearOnReload: flags.clear,
60
73
  readlineReload: flags.reloadKey,
74
+ watch: flags.watch,
75
+ watchDelay: flags.delay,
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 : [],
77
+ watchIgnore: flags.ignore,
61
78
  env: Object.assign(Object.assign({}, flags.env.reduce((acc, env) => {
62
79
  const [key, value] = env.split('=');
63
80
  acc[key] = value;
64
81
  return acc;
65
82
  }, {})), (flags.nodeDev ? { NODE_ENV: 'development' } : {})),
66
- watch: flags.watch,
67
- watchDelay: flags.delay,
68
- watchExtensions: flags.ext.length ? flags.ext : watchExtensions !== null && watchExtensions !== void 0 ? watchExtensions : [],
69
- watchIgnore: flags.ignore,
70
83
  };
71
84
  }
package/dist/arg.d.ts CHANGED
@@ -32,6 +32,21 @@ export declare const app: NoArg<"uni-run", {
32
32
  default: false;
33
33
  description: "Run the script in a shell for more low-level control";
34
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";
49
+ }>;
35
50
  readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
36
51
  description: "Clear the console before running the script";
37
52
  required: true;
@@ -114,6 +129,21 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
114
129
  default: false;
115
130
  description: "Run the script in a shell for more low-level control";
116
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";
146
+ }>;
117
147
  readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
118
148
  description: "Clear the console before running the script";
119
149
  required: true;
@@ -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'] },
@@ -20,4 +20,7 @@ export type ExecuteOptions = {
20
20
  watchExtensions: string[];
21
21
  env: Record<string, string>;
22
22
  shell: boolean;
23
+ showInfo: boolean;
24
+ showTime: boolean;
25
+ benchmark: boolean;
23
26
  };
@@ -43,6 +43,12 @@ 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',
48
54
  argv0: this.command,
@@ -53,11 +59,18 @@ class Execution {
53
59
  this.child.on('error', console.error);
54
60
  this.child.on('exit', (code) => {
55
61
  if (code && code > 0) {
56
- console.log('');
57
62
  console.log(colors_1.default.red(`Process exited with code: ${colors_1.default.yellow(String(code))}`));
58
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
+ }
59
72
  if (this.options.readlineReload) {
60
- console.log(colors_1.default.blue.dim(`⟳ Press ${colors_1.default.yellow('F5')} or ${colors_1.default.yellow('^R')} to reload...`));
73
+ console.log(colors_1.default.blue.dim(`> Press ${colors_1.default.yellow('F5')} or ${colors_1.default.yellow('^R')} to reload...`));
61
74
  }
62
75
  });
63
76
  }
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.config.watchExtensions));
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));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "uni-run",
3
3
  "description": "Universal Runner for many language",
4
- "version": "1.0.1",
4
+ "version": "1.0.3",
5
5
  "type": "commonjs",
6
6
  "scripts": {
7
7
  "ts": "run ./src/__lab__/index.ts",