uni-run 1.0.5 → 1.0.6

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.
Files changed (61) hide show
  1. package/README.md +122 -0
  2. package/dist/app.cjs +60 -0
  3. package/dist/app.d.mts +1 -0
  4. package/dist/{index.js → app.mjs} +8 -10
  5. package/dist/{arg-helper.js → arg-helper.cjs} +43 -32
  6. package/dist/{arg-helper.d.ts → arg-helper.d.cts} +51 -45
  7. package/dist/arg-helper.d.mts +121 -0
  8. package/dist/arg-helper.mjs +93 -0
  9. package/dist/{arg.js → arg.cjs} +5 -2
  10. package/dist/{arg.d.ts → arg.d.cts} +95 -83
  11. package/dist/arg.d.mts +243 -0
  12. package/dist/arg.mjs +9 -0
  13. package/dist/{bin.js → bin.cjs} +2 -2
  14. package/dist/{bin.d.ts → bin.d.cts} +1 -1
  15. package/dist/bin.d.mts +2 -0
  16. package/dist/bin.mjs +4 -0
  17. package/dist/builtin-bin/{Executor.js → Executor.cjs} +5 -2
  18. package/dist/builtin-bin/{Executor.d.ts → Executor.d.cts} +1 -1
  19. package/dist/builtin-bin/Executor.d.mts +21 -0
  20. package/dist/builtin-bin/Executor.mjs +61 -0
  21. package/dist/builtin-bin/{index.js → index.cjs} +4 -1
  22. package/dist/builtin-bin/{index.d.ts → index.d.cts} +1 -1
  23. package/dist/builtin-bin/index.d.mts +3 -0
  24. package/dist/builtin-bin/index.mjs +94 -0
  25. package/dist/execution/gitignore.cjs +40 -0
  26. package/dist/execution/gitignore.d.mts +1 -0
  27. package/dist/execution/gitignore.mjs +11 -0
  28. package/dist/execution/{index.js → index.cjs} +32 -6
  29. package/dist/execution/{index.d.ts → index.d.cts} +1 -1
  30. package/dist/execution/index.d.mts +15 -0
  31. package/dist/execution/index.mjs +103 -0
  32. package/dist/execution/kill-process.cjs +50 -0
  33. package/dist/execution/{kill-process.d.ts → kill-process.d.cts} +1 -1
  34. package/dist/execution/kill-process.d.mts +2 -0
  35. package/dist/execution/{kill-process.js → kill-process.mjs} +4 -7
  36. package/dist/execution/watcher.cjs +64 -0
  37. package/dist/execution/watcher.d.mts +6 -0
  38. package/dist/execution/{watcher.js → watcher.mjs} +7 -10
  39. package/dist/index.cjs +19 -0
  40. package/dist/index.d.cts +8 -0
  41. package/dist/index.d.mts +8 -0
  42. package/dist/index.mjs +13 -0
  43. package/dist/lib/colors.cjs +32 -0
  44. package/dist/lib/colors.d.cts +3 -0
  45. package/dist/lib/colors.d.mts +3 -0
  46. package/dist/lib/colors.mjs +4 -0
  47. package/dist/lib/currentModule.cjs +19 -0
  48. package/dist/lib/currentModule.d.cts +5 -0
  49. package/dist/lib/currentModule.d.mts +5 -0
  50. package/dist/lib/currentModule.mjs +17 -0
  51. package/dist/utils/debounce.d.mts +1 -0
  52. package/dist/utils/debounce.mjs +7 -0
  53. package/package.json +12 -8
  54. package/dist/execution/gitignore.js +0 -14
  55. package/dist/lib/colors.d.ts +0 -2
  56. package/dist/lib/colors.js +0 -4
  57. /package/dist/{index.d.ts → app.d.cts} +0 -0
  58. /package/dist/execution/{gitignore.d.ts → gitignore.d.cts} +0 -0
  59. /package/dist/execution/{watcher.d.ts → watcher.d.cts} +0 -0
  60. /package/dist/utils/{debounce.js → debounce.cjs} +0 -0
  61. /package/dist/utils/{debounce.d.ts → debounce.d.cts} +0 -0
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.list = exports.exec = exports.app = void 0;
4
- const noarg_1 = require("noarg");
5
- const arg_helper_1 = require("./arg-helper");
7
+ const noarg_1 = __importDefault(require("noarg"));
8
+ const arg_helper_1 = require("./arg-helper.cjs");
6
9
  exports.app = noarg_1.default.create('uni-run', Object.assign(Object.assign({}, arg_helper_1.executionConfig), { description: 'A universal runner for scripts', system: { splitListByComma: true }, arguments: [
7
10
  { name: 'script', type: noarg_1.default.string(), description: 'Run a script' },
8
11
  ] }));
@@ -1,4 +1,4 @@
1
- import NoArg from 'noarg';
1
+ import NoArg from "noarg";
2
2
  export declare const app: NoArg<"uni-run", {
3
3
  readonly allowEqualAssign: true;
4
4
  readonly booleanNotSyntaxEnding: "\\";
@@ -22,71 +22,77 @@ export declare const app: NoArg<"uni-run", {
22
22
  };
23
23
  readonly trailingArguments: "--";
24
24
  readonly flags: {
25
- readonly cwd: import("noarg/dist/schema/TypeString.cjs").TypeString<{
26
- required: true;
27
- default: string;
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<{
25
+ readonly reloadKey: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
26
+ aliases: ["rk"];
36
27
  required: true;
37
- default: false;
38
- description: "Show information about the script";
28
+ default: true;
29
+ description: "Reload the page when pressing 'Ctrl+R' or 'F5'";
39
30
  }>;
40
- readonly time: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
31
+ readonly watch: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
32
+ aliases: ["w"];
41
33
  required: true;
42
- default: false;
43
- description: "Show the execution time at the start";
34
+ default: true;
35
+ description: "Watch for changes";
44
36
  }>;
45
- readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
37
+ readonly noWatch: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
46
38
  required: true;
47
39
  default: false;
48
- description: "Show the execution time";
49
- }>;
50
- readonly benchPrefix: import("noarg/dist/schema/TypeString.cjs").TypeString<{
51
- description: "The prefix for the benchmark to show at the start of the line";
40
+ description: "Disable `watch` and `reloadKey` features";
52
41
  }>;
53
42
  readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
54
- description: "Clear the console before running the script";
43
+ aliases: ["c"];
55
44
  required: true;
56
45
  default: true;
57
- aliases: [string];
58
- }>;
59
- readonly reloadKey: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
60
- description: "Reload the page when pressing 'Ctrl+R' or 'F5'";
61
- required: true;
62
- default: true;
63
- aliases: [string];
64
- }>;
65
- readonly watch: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
66
- description: "Watch for changes";
67
- required: true;
68
- default: true;
69
- aliases: [string];
46
+ description: "Clear the console before running the script";
70
47
  }>;
71
48
  readonly delay: import("noarg/dist/schema/TypeNumber.cjs").TypeNumber<{
72
- description: "The delay to wait for the watcher to trigger";
49
+ aliases: ["d"];
73
50
  required: true;
74
51
  default: 100;
75
- aliases: [string];
52
+ description: "The delay to wait for the watcher to trigger";
76
53
  }>;
77
54
  readonly ext: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
78
- description: "Looks for changes only of the given extensions";
55
+ aliases: ["e"];
79
56
  required: true;
80
57
  default: never[];
81
58
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
82
- aliases: [string];
59
+ description: "Looks for changes only of the given extensions";
83
60
  }>;
84
61
  readonly ignore: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
85
- description: "Ignore the given folders/files";
62
+ aliases: ["ig"];
86
63
  required: true;
87
64
  default: never[];
88
65
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
89
- aliases: [string];
66
+ description: "Ignore the given folders/files";
67
+ }>;
68
+ readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
69
+ aliases: ["b"];
70
+ description: "Calculate the execution time";
71
+ }>;
72
+ readonly benchPrefix: import("noarg/dist/schema/TypeString.cjs").TypeString<{
73
+ aliases: ["bp"];
74
+ minLength: 1;
75
+ description: "The prefix to show before the execution time";
76
+ }>;
77
+ readonly cwd: import("noarg/dist/schema/TypeString.cjs").TypeString<{
78
+ required: true;
79
+ default: string;
80
+ description: "Current working directory";
81
+ }>;
82
+ readonly shell: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
83
+ required: true;
84
+ default: false;
85
+ description: "Run the script in a shell for more low-level control";
86
+ }>;
87
+ readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
88
+ required: true;
89
+ default: false;
90
+ description: "Show information about the script";
91
+ }>;
92
+ readonly time: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
93
+ required: true;
94
+ default: false;
95
+ description: "Show the execution time at the start";
90
96
  }>;
91
97
  readonly env: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
92
98
  required: true;
@@ -127,71 +133,77 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
127
133
  };
128
134
  readonly trailingArguments: "--";
129
135
  readonly flags: {
130
- readonly cwd: import("noarg/dist/schema/TypeString.cjs").TypeString<{
131
- required: true;
132
- default: string;
133
- description: "Current working directory";
134
- }>;
135
- readonly shell: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
136
- required: true;
137
- default: false;
138
- description: "Run the script in a shell for more low-level control";
139
- }>;
140
- readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
136
+ readonly reloadKey: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
137
+ aliases: ["rk"];
141
138
  required: true;
142
- default: false;
143
- description: "Show information about the script";
139
+ default: true;
140
+ description: "Reload the page when pressing 'Ctrl+R' or 'F5'";
144
141
  }>;
145
- readonly time: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
142
+ readonly watch: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
143
+ aliases: ["w"];
146
144
  required: true;
147
- default: false;
148
- description: "Show the execution time at the start";
145
+ default: true;
146
+ description: "Watch for changes";
149
147
  }>;
150
- readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
148
+ readonly noWatch: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
151
149
  required: true;
152
150
  default: false;
153
- description: "Show the execution time";
154
- }>;
155
- readonly benchPrefix: import("noarg/dist/schema/TypeString.cjs").TypeString<{
156
- description: "The prefix for the benchmark to show at the start of the line";
151
+ description: "Disable `watch` and `reloadKey` features";
157
152
  }>;
158
153
  readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
159
- description: "Clear the console before running the script";
154
+ aliases: ["c"];
160
155
  required: true;
161
156
  default: true;
162
- aliases: [string];
163
- }>;
164
- readonly reloadKey: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
165
- description: "Reload the page when pressing 'Ctrl+R' or 'F5'";
166
- required: true;
167
- default: true;
168
- aliases: [string];
169
- }>;
170
- readonly watch: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
171
- description: "Watch for changes";
172
- required: true;
173
- default: true;
174
- aliases: [string];
157
+ description: "Clear the console before running the script";
175
158
  }>;
176
159
  readonly delay: import("noarg/dist/schema/TypeNumber.cjs").TypeNumber<{
177
- description: "The delay to wait for the watcher to trigger";
160
+ aliases: ["d"];
178
161
  required: true;
179
162
  default: 100;
180
- aliases: [string];
163
+ description: "The delay to wait for the watcher to trigger";
181
164
  }>;
182
165
  readonly ext: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
183
- description: "Looks for changes only of the given extensions";
166
+ aliases: ["e"];
184
167
  required: true;
185
168
  default: never[];
186
169
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
187
- aliases: [string];
170
+ description: "Looks for changes only of the given extensions";
188
171
  }>;
189
172
  readonly ignore: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
190
- description: "Ignore the given folders/files";
173
+ aliases: ["ig"];
191
174
  required: true;
192
175
  default: never[];
193
176
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
194
- aliases: [string];
177
+ description: "Ignore the given folders/files";
178
+ }>;
179
+ readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
180
+ aliases: ["b"];
181
+ description: "Calculate the execution time";
182
+ }>;
183
+ readonly benchPrefix: import("noarg/dist/schema/TypeString.cjs").TypeString<{
184
+ aliases: ["bp"];
185
+ minLength: 1;
186
+ description: "The prefix to show before the execution time";
187
+ }>;
188
+ readonly cwd: import("noarg/dist/schema/TypeString.cjs").TypeString<{
189
+ required: true;
190
+ default: string;
191
+ description: "Current working directory";
192
+ }>;
193
+ readonly shell: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
194
+ required: true;
195
+ default: false;
196
+ description: "Run the script in a shell for more low-level control";
197
+ }>;
198
+ readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
199
+ required: true;
200
+ default: false;
201
+ description: "Show information about the script";
202
+ }>;
203
+ readonly time: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
204
+ required: true;
205
+ default: false;
206
+ description: "Show the execution time at the start";
195
207
  }>;
196
208
  readonly env: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
197
209
  required: true;
package/dist/arg.d.mts ADDED
@@ -0,0 +1,243 @@
1
+ import NoArg from "noarg";
2
+ export declare const app: NoArg<"uni-run", {
3
+ readonly allowEqualAssign: true;
4
+ readonly booleanNotSyntaxEnding: "\\";
5
+ readonly allowDuplicateFlagForList: true;
6
+ readonly splitListByComma: true;
7
+ }, {
8
+ readonly help: true;
9
+ }, {
10
+ readonly optionalArguments: [];
11
+ readonly globalFlags: {};
12
+ readonly description: "A universal runner for scripts";
13
+ readonly arguments: [{
14
+ readonly name: "script";
15
+ readonly type: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
16
+ readonly description: "Run a script";
17
+ }];
18
+ readonly listArgument: {
19
+ readonly name: "args for script";
20
+ readonly description: "The arguments to pass to the script";
21
+ readonly type: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
22
+ };
23
+ readonly trailingArguments: "--";
24
+ readonly flags: {
25
+ readonly reloadKey: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
26
+ aliases: ["rk"];
27
+ required: true;
28
+ default: true;
29
+ description: "Reload the page when pressing 'Ctrl+R' or 'F5'";
30
+ }>;
31
+ readonly watch: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
32
+ aliases: ["w"];
33
+ required: true;
34
+ default: true;
35
+ description: "Watch for changes";
36
+ }>;
37
+ readonly noWatch: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
38
+ required: true;
39
+ default: false;
40
+ description: "Disable `watch` and `reloadKey` features";
41
+ }>;
42
+ readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
43
+ aliases: ["c"];
44
+ required: true;
45
+ default: true;
46
+ description: "Clear the console before running the script";
47
+ }>;
48
+ readonly delay: import("noarg/dist/schema/TypeNumber.cjs").TypeNumber<{
49
+ aliases: ["d"];
50
+ required: true;
51
+ default: 100;
52
+ description: "The delay to wait for the watcher to trigger";
53
+ }>;
54
+ readonly ext: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
55
+ aliases: ["e"];
56
+ required: true;
57
+ default: never[];
58
+ schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
59
+ description: "Looks for changes only of the given extensions";
60
+ }>;
61
+ readonly ignore: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
62
+ aliases: ["ig"];
63
+ required: true;
64
+ default: never[];
65
+ schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
66
+ description: "Ignore the given folders/files";
67
+ }>;
68
+ readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
69
+ aliases: ["b"];
70
+ description: "Calculate the execution time";
71
+ }>;
72
+ readonly benchPrefix: import("noarg/dist/schema/TypeString.cjs").TypeString<{
73
+ aliases: ["bp"];
74
+ minLength: 1;
75
+ description: "The prefix to show before the execution time";
76
+ }>;
77
+ readonly cwd: import("noarg/dist/schema/TypeString.cjs").TypeString<{
78
+ required: true;
79
+ default: string;
80
+ description: "Current working directory";
81
+ }>;
82
+ readonly shell: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
83
+ required: true;
84
+ default: false;
85
+ description: "Run the script in a shell for more low-level control";
86
+ }>;
87
+ readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
88
+ required: true;
89
+ default: false;
90
+ description: "Show information about the script";
91
+ }>;
92
+ readonly time: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
93
+ required: true;
94
+ default: false;
95
+ description: "Show the execution time at the start";
96
+ }>;
97
+ readonly env: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
98
+ required: true;
99
+ default: never[];
100
+ schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
101
+ description: "Environment variables";
102
+ }>;
103
+ readonly nodeDev: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
104
+ required: true;
105
+ default: false;
106
+ description: "Set NODE_ENV to \"development\"";
107
+ }>;
108
+ readonly tsn: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
109
+ required: true;
110
+ default: false;
111
+ description: "Run the script with ts-node";
112
+ }>;
113
+ };
114
+ readonly customRenderHelp: {
115
+ readonly helpUsageTrailingArgsLabel: "...[args/flags for script]";
116
+ };
117
+ }>;
118
+ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProgram<"exec", {
119
+ readonly allowEqualAssign: true;
120
+ readonly booleanNotSyntaxEnding: "\\";
121
+ readonly allowDuplicateFlagForList: true;
122
+ readonly splitListByComma: true;
123
+ }, {
124
+ readonly help: true;
125
+ }, {
126
+ readonly description: "Execute a script with the given binary";
127
+ readonly arguments: [];
128
+ readonly optionalArguments: [];
129
+ readonly listArgument: {
130
+ readonly name: "args for script";
131
+ readonly description: "The arguments to pass to the script";
132
+ readonly type: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
133
+ };
134
+ readonly trailingArguments: "--";
135
+ readonly flags: {
136
+ readonly reloadKey: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
137
+ aliases: ["rk"];
138
+ required: true;
139
+ default: true;
140
+ description: "Reload the page when pressing 'Ctrl+R' or 'F5'";
141
+ }>;
142
+ readonly watch: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
143
+ aliases: ["w"];
144
+ required: true;
145
+ default: true;
146
+ description: "Watch for changes";
147
+ }>;
148
+ readonly noWatch: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
149
+ required: true;
150
+ default: false;
151
+ description: "Disable `watch` and `reloadKey` features";
152
+ }>;
153
+ readonly clear: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
154
+ aliases: ["c"];
155
+ required: true;
156
+ default: true;
157
+ description: "Clear the console before running the script";
158
+ }>;
159
+ readonly delay: import("noarg/dist/schema/TypeNumber.cjs").TypeNumber<{
160
+ aliases: ["d"];
161
+ required: true;
162
+ default: 100;
163
+ description: "The delay to wait for the watcher to trigger";
164
+ }>;
165
+ readonly ext: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
166
+ aliases: ["e"];
167
+ required: true;
168
+ default: never[];
169
+ schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
170
+ description: "Looks for changes only of the given extensions";
171
+ }>;
172
+ readonly ignore: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
173
+ aliases: ["ig"];
174
+ required: true;
175
+ default: never[];
176
+ schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
177
+ description: "Ignore the given folders/files";
178
+ }>;
179
+ readonly bench: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
180
+ aliases: ["b"];
181
+ description: "Calculate the execution time";
182
+ }>;
183
+ readonly benchPrefix: import("noarg/dist/schema/TypeString.cjs").TypeString<{
184
+ aliases: ["bp"];
185
+ minLength: 1;
186
+ description: "The prefix to show before the execution time";
187
+ }>;
188
+ readonly cwd: import("noarg/dist/schema/TypeString.cjs").TypeString<{
189
+ required: true;
190
+ default: string;
191
+ description: "Current working directory";
192
+ }>;
193
+ readonly shell: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
194
+ required: true;
195
+ default: false;
196
+ description: "Run the script in a shell for more low-level control";
197
+ }>;
198
+ readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
199
+ required: true;
200
+ default: false;
201
+ description: "Show information about the script";
202
+ }>;
203
+ readonly time: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
204
+ required: true;
205
+ default: false;
206
+ description: "Show the execution time at the start";
207
+ }>;
208
+ readonly env: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
209
+ required: true;
210
+ default: never[];
211
+ schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
212
+ description: "Environment variables";
213
+ }>;
214
+ readonly nodeDev: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
215
+ required: true;
216
+ default: false;
217
+ description: "Set NODE_ENV to \"development\"";
218
+ }>;
219
+ readonly tsn: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
220
+ required: true;
221
+ default: false;
222
+ description: "Run the script with ts-node";
223
+ }>;
224
+ };
225
+ readonly customRenderHelp: {
226
+ readonly helpUsageTrailingArgsLabel: "...[args/flags for script]";
227
+ };
228
+ globalFlags: {};
229
+ }>;
230
+ export declare const list: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProgram<"list", {
231
+ readonly allowEqualAssign: true;
232
+ readonly booleanNotSyntaxEnding: "\\";
233
+ readonly allowDuplicateFlagForList: true;
234
+ readonly splitListByComma: true;
235
+ }, {
236
+ readonly help: true;
237
+ }, {
238
+ readonly description: "List supported scripts";
239
+ readonly arguments: [];
240
+ readonly optionalArguments: [];
241
+ readonly flags: {};
242
+ globalFlags: {};
243
+ }>;
package/dist/arg.mjs ADDED
@@ -0,0 +1,9 @@
1
+ import NoArg from "noarg";
2
+ import { executionConfig } from "./arg-helper.mjs";
3
+ export const app = NoArg.create('uni-run', Object.assign(Object.assign({}, executionConfig), { description: 'A universal runner for scripts', system: { splitListByComma: true }, arguments: [
4
+ { name: 'script', type: NoArg.string(), description: 'Run a script' },
5
+ ] }));
6
+ export const exec = app.create('exec', Object.assign(Object.assign({}, executionConfig), { description: 'Execute a script with the given binary' }));
7
+ export const list = app.create('list', {
8
+ description: 'List supported scripts',
9
+ });
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- require("./index");
5
- const arg_1 = require("./arg");
4
+ require("./app.cjs");
5
+ const arg_1 = require("./arg.cjs");
6
6
  arg_1.app.start();
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import './index';
2
+ import "./app.cjs";
package/dist/bin.d.mts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "./app.mjs";
package/dist/bin.mjs ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import "./app.mjs";
3
+ import { app } from "./arg.mjs";
4
+ app.start();
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const execution_1 = require("../execution");
4
- const confirm_1 = require("@inquirer/confirm");
6
+ const execution_1 = __importDefault(require("../execution/index.cjs"));
7
+ const confirm_1 = __importDefault(require("@inquirer/confirm"));
5
8
  const cross_spawn_1 = require("cross-spawn");
6
9
  class Executor {
7
10
  constructor(name, config) {
@@ -1,4 +1,4 @@
1
- import { ExecuteOptions } from '../arg-helper';
1
+ import { ExecuteOptions } from "../arg-helper.cjs";
2
2
  type BinConfig = {
3
3
  extensions: string[];
4
4
  watchExtensions?: string[];
@@ -0,0 +1,21 @@
1
+ import { ExecuteOptions } from "../arg-helper.mjs";
2
+ type BinConfig = {
3
+ extensions: string[];
4
+ watchExtensions?: string[];
5
+ run: (args: string[], options: ExecuteOptions) => string[];
6
+ installMessage?: string;
7
+ installCommands?: string[] | ((options: ExecuteOptions) => string[]);
8
+ checkInstallation?: string[] | ((options: ExecuteOptions) => string[]);
9
+ };
10
+ export default class Executor {
11
+ private name;
12
+ private config;
13
+ constructor(name: string, config: BinConfig);
14
+ getName(): string;
15
+ getRelatedExts(): string[];
16
+ start(options: ExecuteOptions, args: string[]): void;
17
+ isSupported(script: string): boolean;
18
+ private isInstalled;
19
+ private renderHowToInstall;
20
+ }
21
+ export {};
@@ -0,0 +1,61 @@
1
+ import Execution from "../execution/index.mjs";
2
+ import confirm from "@inquirer/confirm";
3
+ import { sync as spawnSync } from "cross-spawn";
4
+ export default class Executor {
5
+ constructor(name, config) {
6
+ var _a;
7
+ this.name = name;
8
+ this.config = config;
9
+ (_a = this.config.watchExtensions) === null || _a === void 0 ? void 0 : _a.push(...this.config.extensions);
10
+ }
11
+ getName() {
12
+ return this.name;
13
+ }
14
+ getRelatedExts() {
15
+ var _a;
16
+ return [...this.config.extensions, ...((_a = this.config.watchExtensions) !== null && _a !== void 0 ? _a : [])];
17
+ }
18
+ start(options, args) {
19
+ if (!this.isInstalled(options)) {
20
+ return this.renderHowToInstall(options);
21
+ }
22
+ Execution.start(this.config.run(args, options), options);
23
+ }
24
+ isSupported(script) {
25
+ return this.config.extensions.includes(script.split('.').pop() || '');
26
+ }
27
+ isInstalled(options) {
28
+ if (!this.config.checkInstallation)
29
+ return true;
30
+ const [command, ...args] = typeof this.config.checkInstallation === 'function'
31
+ ? this.config.checkInstallation(options)
32
+ : this.config.checkInstallation || [];
33
+ const result = spawnSync(command, args, {
34
+ stdio: 'ignore',
35
+ });
36
+ if (result.status === 1)
37
+ return false;
38
+ return true;
39
+ }
40
+ renderHowToInstall(options) {
41
+ console.error(`${this.name} is not installed.`);
42
+ if (this.config.installMessage) {
43
+ console.log('How to install:');
44
+ console.log(this.config.installMessage);
45
+ }
46
+ const commands = typeof this.config.installCommands === 'function'
47
+ ? this.config.installCommands(options)
48
+ : this.config.installCommands;
49
+ if (!commands || !commands.length)
50
+ return;
51
+ confirm({ message: 'Do you want to install it?' }).then((ans) => {
52
+ if (!ans)
53
+ return;
54
+ commands.forEach(([command, ...args]) => {
55
+ if (!command)
56
+ return;
57
+ spawnSync(command, args, { stdio: 'inherit' });
58
+ });
59
+ });
60
+ }
61
+ }
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const Executor_1 = require("./Executor");
6
+ const Executor_1 = __importDefault(require("./Executor.cjs"));
4
7
  exports.default = [
5
8
  new Executor_1.default('Node.js', {
6
9
  extensions: ['js', 'javascript', 'jsx', 'cjs', 'cjsx', 'mjs', 'mjsx'],
@@ -1,3 +1,3 @@
1
- import Executor from './Executor';
1
+ import Executor from "./Executor.cjs";
2
2
  declare const _default: Executor[];
3
3
  export default _default;