uni-run 1.1.13 → 1.1.16

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 CHANGED
@@ -90,7 +90,7 @@ module.exports = [
90
90
  exts: ['ext'],
91
91
  getRuntime(args, options, config) {
92
92
  return {
93
- start: ['YOUR_BIN', ...args],
93
+ exec: ['YOUR_BIN', ...args],
94
94
  }
95
95
  },
96
96
  },
@@ -115,7 +115,7 @@ uniRun.addExecutorBefore({
115
115
  exts: ['ext'],
116
116
  getRuntime(args, options, config) {
117
117
  return {
118
- start: ['YOUR_BIN', ...args],
118
+ exec: ['YOUR_BIN', ...args],
119
119
  }
120
120
  },
121
121
  })
@@ -142,7 +142,7 @@ uniRun.addExecutorBefore({
142
142
  exts: ['ext'],
143
143
  getRuntime(args, options, config) {
144
144
  return {
145
- start: ['YOUR_BIN', ...args],
145
+ exec: ['YOUR_BIN', ...args],
146
146
  }
147
147
  },
148
148
  })
@@ -66,7 +66,6 @@ class Execution {
66
66
  });
67
67
  }
68
68
  setup() {
69
- var _a, _b;
70
69
  if (this.options.benchmarkPrefix) {
71
70
  this.benchMarkText =
72
71
  colors_1.default.bold(this.options.benchmarkPrefix) + ' ' + this.benchMarkText;
@@ -74,7 +73,7 @@ class Execution {
74
73
  if (this.options.keystrokeReload) {
75
74
  readline.emitKeypressEvents(process.stdin);
76
75
  if (!this.options.stdinSafeMode) {
77
- (_b = (_a = process.stdin).setRawMode) === null || _b === void 0 ? void 0 : _b.call(_a, true);
76
+ process.stdin.setRawMode(true);
78
77
  }
79
78
  process.stdin.on('keypress', (_, key) => {
80
79
  if (key.name === 'f5' || (key.ctrl && key.name === 'r')) {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  import './app';
2
+ import getConfig from './helpers/getConfig';
3
+ import currentModule from './lib/currentModule';
4
+ import getUserExecutors from './helpers/getUserExecutors';
2
5
  import { ScriptExecutorOptions } from './scriptExecutors/types.t';
6
+ export { currentModule, getConfig, getUserExecutors };
7
+ export * from './scriptExecutors/types.t';
3
8
  declare const _default: {
4
9
  addExecutorBefore(executor: ScriptExecutorOptions): void;
5
10
  addExecutorAfter(executor: ScriptExecutorOptions): void;
package/dist/index.js CHANGED
@@ -1,11 +1,33 @@
1
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
18
  };
5
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.getUserExecutors = exports.getConfig = exports.currentModule = void 0;
6
21
  require("./app");
7
22
  const arg_1 = require("./arg");
23
+ const getConfig_1 = __importDefault(require("./helpers/getConfig"));
24
+ exports.getConfig = getConfig_1.default;
25
+ const currentModule_1 = __importDefault(require("./lib/currentModule"));
26
+ exports.currentModule = currentModule_1.default;
8
27
  const scriptExecutors_1 = __importDefault(require("./scriptExecutors"));
28
+ const getUserExecutors_1 = __importDefault(require("./helpers/getUserExecutors"));
29
+ exports.getUserExecutors = getUserExecutors_1.default;
30
+ __exportStar(require("./scriptExecutors/types.t"), exports);
9
31
  exports.default = {
10
32
  addExecutorBefore(executor) {
11
33
  scriptExecutors_1.default.unshift(executor);
@@ -18,28 +18,28 @@ const confirm_1 = __importDefault(require("@inquirer/confirm"));
18
18
  const cross_spawn_1 = require("cross-spawn");
19
19
  function default_1(runtime) {
20
20
  return __awaiter(this, void 0, void 0, function* () {
21
- var _a, _b, _c;
22
- const install = runtime.install;
23
- if (!install)
21
+ var _a, _b;
22
+ if (!runtime.install && !runtime.installHints)
24
23
  return true;
25
- if (!((_a = install.check) === null || _a === void 0 ? void 0 : _a.length))
24
+ const command = runtime.exec[0];
25
+ if (!command)
26
26
  return true;
27
- const [checkCmd, ...checkArgs] = install.check;
28
- const result = (0, cross_spawn_1.sync)(checkCmd, checkArgs, { stdio: 'ignore' });
27
+ const result = (0, cross_spawn_1.sync)('which', [command], { stdio: 'ignore' });
29
28
  if (result.status === 0)
30
29
  return true;
31
- console.error(colors_1.default.yellow(runtime.exec[0]) + colors_1.default.red(' is not installed.'));
32
- if (!((_b = install.command) === null || _b === void 0 ? void 0 : _b.length))
30
+ console.error(colors_1.default.yellow(command) + colors_1.default.red(' is not installed.'));
31
+ if (!((_a = runtime.install) === null || _a === void 0 ? void 0 : _a.length))
33
32
  return false;
34
- const ans = yield (0, confirm_1.default)({ message: 'Do you want to install it?' });
33
+ const ans = yield (0, confirm_1.default)({ message: 'Do you want to install it?' }, { clearPromptOnDone: true });
34
+ process.stdin.resume();
35
35
  if (ans) {
36
- const [installCmd, ...installArgs] = install.command;
36
+ const [installCmd, ...installArgs] = runtime.install;
37
37
  const result = (0, cross_spawn_1.sync)(installCmd, installArgs, { stdio: 'inherit' });
38
38
  return result.status === 0;
39
39
  }
40
- if ((_c = install.hints) === null || _c === void 0 ? void 0 : _c.length) {
40
+ if ((_b = runtime.installHints) === null || _b === void 0 ? void 0 : _b.length) {
41
41
  console.log(colors_1.default.bold('How to install:'));
42
- install.hints.forEach((hint) => console.log(hint));
42
+ runtime.installHints.forEach((hint) => console.log(hint));
43
43
  }
44
44
  return false;
45
45
  });
@@ -25,10 +25,7 @@ exports.default = (0, as_1.default)([
25
25
  }
26
26
  return {
27
27
  exec: [runtime, ...args],
28
- install: {
29
- check: [runtime, '--version'],
30
- hints: installHints,
31
- },
28
+ installHints,
32
29
  };
33
30
  },
34
31
  },
@@ -57,10 +54,7 @@ exports.default = (0, as_1.default)([
57
54
  return {
58
55
  exec: [runtime, ...args],
59
56
  watchExts: ['js', 'javascript', 'jsx', 'cjs', 'cjsx', 'mjs', 'mjsx'],
60
- install: {
61
- check: [runtime, '--version'],
62
- hints: installHints,
63
- },
57
+ installHints,
64
58
  };
65
59
  },
66
60
  },
@@ -70,10 +64,7 @@ exports.default = (0, as_1.default)([
70
64
  getRuntime(args, options, config) {
71
65
  return {
72
66
  exec: ['python', ...args],
73
- install: {
74
- check: ['python', '--version'],
75
- hints: ['Please install Python from https://www.python.org'],
76
- },
67
+ installHints: ['Please install Python from https://www.python.org'],
77
68
  };
78
69
  },
79
70
  },
@@ -83,10 +74,7 @@ exports.default = (0, as_1.default)([
83
74
  getRuntime(args, options, config) {
84
75
  return {
85
76
  exec: ['java', ...args],
86
- install: {
87
- check: ['java', '--version'],
88
- hints: ['Please install Java from https://www.oracle.com/java'],
89
- },
77
+ installHints: ['Please install Java from https://www.oracle.com/java'],
90
78
  };
91
79
  },
92
80
  },
@@ -96,12 +84,9 @@ exports.default = (0, as_1.default)([
96
84
  getRuntime(args, options, config) {
97
85
  return {
98
86
  exec: ['powershell', '-File', ...args],
99
- install: {
100
- check: ['powershell', '-command', 'echo ok'],
101
- hints: [
102
- 'Please install Powershell from https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell',
103
- ],
104
- },
87
+ installHints: [
88
+ 'Please install Powershell from https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell',
89
+ ],
105
90
  };
106
91
  },
107
92
  },
@@ -111,10 +96,7 @@ exports.default = (0, as_1.default)([
111
96
  getRuntime(args, options, config) {
112
97
  return {
113
98
  exec: ['cmd', '/c', ...args],
114
- install: {
115
- check: ['cmd', '/c', 'echo ok'],
116
- hints: ['Please install Command Prompt from Windows'],
117
- },
99
+ installHints: ['Please install Command Prompt from Windows'],
118
100
  };
119
101
  },
120
102
  },
@@ -124,10 +106,9 @@ exports.default = (0, as_1.default)([
124
106
  getRuntime(args, options, config) {
125
107
  return {
126
108
  exec: ['bash', ...args],
127
- install: {
128
- check: ['bash', '--version'],
129
- hints: ['Please install Bash from https://www.gnu.org/software/bash'],
130
- },
109
+ installHints: [
110
+ 'Please install Bash from https://www.gnu.org/software/bash',
111
+ ],
131
112
  };
132
113
  },
133
114
  },
@@ -137,10 +118,7 @@ exports.default = (0, as_1.default)([
137
118
  getRuntime(args, options, config) {
138
119
  return {
139
120
  exec: ['fish', ...args],
140
- install: {
141
- check: ['fish', '--version'],
142
- hints: ['Please install Fish from https://fishshell.com'],
143
- },
121
+ installHints: ['Please install Fish from https://fishshell.com'],
144
122
  };
145
123
  },
146
124
  },
@@ -150,10 +128,7 @@ exports.default = (0, as_1.default)([
150
128
  getRuntime(args, options, config) {
151
129
  return {
152
130
  exec: ['lua', ...args],
153
- install: {
154
- check: ['lua', '-v'],
155
- hints: ['Please install Lua from https://www.lua.org'],
156
- },
131
+ installHints: ['Please install Lua from https://www.lua.org'],
157
132
  };
158
133
  },
159
134
  },
@@ -163,10 +138,7 @@ exports.default = (0, as_1.default)([
163
138
  getRuntime(args, options, config) {
164
139
  return {
165
140
  exec: ['ruby', ...args],
166
- install: {
167
- check: ['ruby', '-v'],
168
- hints: ['Please install Ruby from https://www.ruby-lang.org'],
169
- },
141
+ installHints: ['Please install Ruby from https://www.ruby-lang.org'],
170
142
  };
171
143
  },
172
144
  },
@@ -176,10 +148,7 @@ exports.default = (0, as_1.default)([
176
148
  getRuntime(args, options, config) {
177
149
  return {
178
150
  exec: ['go', 'run', ...args],
179
- install: {
180
- check: ['go', 'version'],
181
- hints: ['Please install Ruby from https://www.ruby-lang.org'],
182
- },
151
+ installHints: ['Please install Ruby from https://www.ruby-lang.org'],
183
152
  };
184
153
  },
185
154
  },
@@ -191,10 +160,7 @@ exports.default = (0, as_1.default)([
191
160
  return {
192
161
  compile: ['gcc', script, '-o', output],
193
162
  exec: [output, ...args],
194
- install: {
195
- check: ['gcc', '--version'],
196
- hints: ['Please install GCC from https://gcc.gnu.org'],
197
- },
163
+ installHints: ['Please install GCC from https://gcc.gnu.org'],
198
164
  };
199
165
  },
200
166
  },
@@ -206,10 +172,7 @@ exports.default = (0, as_1.default)([
206
172
  return {
207
173
  compile: ['g++', script, '-o', output],
208
174
  exec: [output, ...args],
209
- install: {
210
- check: ['g++', '--version'],
211
- hints: ['Please install GCC from https://gcc.gnu.org'],
212
- },
175
+ installHints: ['Please install GCC from https://gcc.gnu.org'],
213
176
  };
214
177
  },
215
178
  },
@@ -221,10 +184,7 @@ exports.default = (0, as_1.default)([
221
184
  return {
222
185
  compile: ['mcs', '-out:' + output, script],
223
186
  exec: [output, ...args],
224
- install: {
225
- check: ['mcs', '--version'],
226
- hints: ['Please install Mono from https://www.mono-project.com'],
227
- },
187
+ installHints: ['Please install Mono from https://www.mono-project.com'],
228
188
  };
229
189
  },
230
190
  },
@@ -236,10 +196,7 @@ exports.default = (0, as_1.default)([
236
196
  return {
237
197
  compile: ['rustc', script, '-o', output],
238
198
  exec: [output, ...args],
239
- install: {
240
- check: ['rustc', '--version'],
241
- hints: ['Please install Rust from https://www.rust-lang.org'],
242
- },
199
+ installHints: ['Please install Rust from https://www.rust-lang.org'],
243
200
  };
244
201
  },
245
202
  },
@@ -249,11 +206,8 @@ exports.default = (0, as_1.default)([
249
206
  getRuntime(args, options, config) {
250
207
  return {
251
208
  exec: ['sass', ...args],
252
- install: {
253
- check: ['sass', '--version'],
254
- command: ['npm', 'install', '-g', 'sass'],
255
- hints: ['Please install SASS from https://sass-lang.com'],
256
- },
209
+ install: ['npm', 'install', '-g', 'sass'],
210
+ installHints: ['Please install SASS from https://sass-lang.com'],
257
211
  };
258
212
  },
259
213
  },
@@ -263,10 +217,7 @@ exports.default = (0, as_1.default)([
263
217
  getRuntime(args, options, config) {
264
218
  return {
265
219
  exec: ['php', ...args],
266
- install: {
267
- check: ['php', '--version'],
268
- hints: ['Please install PHP from https://www.php.net'],
269
- },
220
+ installHints: ['Please install PHP from https://www.php.net'],
270
221
  };
271
222
  },
272
223
  },
@@ -277,13 +228,10 @@ exports.default = (0, as_1.default)([
277
228
  return {
278
229
  exec: ['light-express-server', script, ...args],
279
230
  watchExts: ['css', 'js', 'javascript'],
280
- install: {
281
- check: ['light-express-server', '--help'],
282
- command: ['npm', 'install', '-g', 'light-express-server'],
283
- hints: [
284
- 'Please install light-express-server from https://www.npmjs.com/package/light-express-server',
285
- ],
286
- },
231
+ install: ['npm', 'install', '-g', 'light-express-server'],
232
+ installHints: [
233
+ 'Please install light-express-server from https://www.npmjs.com/package/light-express-server',
234
+ ],
287
235
  };
288
236
  },
289
237
  },
@@ -7,11 +7,8 @@ export type RuntimeOptions = {
7
7
  exec: string[];
8
8
  compile?: string[];
9
9
  watchExts?: string[];
10
- install?: {
11
- check: string[];
12
- hints?: string[];
13
- command?: string[];
14
- };
10
+ install?: string[];
11
+ installHints?: string[];
15
12
  };
16
13
  export type ScriptExecutorOptions = {
17
14
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uni-run",
3
- "version": "1.1.13",
3
+ "version": "1.1.16",
4
4
  "description": "Universal Runner for many language",
5
5
  "type": "commonjs",
6
6
  "scripts": {
@@ -8,7 +8,7 @@
8
8
  "dev": "tsc --watch",
9
9
  "tsc": "tsc --watch --noEmit",
10
10
  "live": "node ./dist/__lab__/index.js",
11
- "tsx": "tsx --watch ./src/__lab__/index.ts",
11
+ "tsx": "tsx ./src/__lab__/index.ts",
12
12
  "lab": "run ./src/__lab__/index.ts --focus ./src -- UNI_RUN_LAB_MODE"
13
13
  },
14
14
  "main": "./dist/index.js",
@@ -17,6 +17,7 @@
17
17
  "uni-run": "./dist/bin.js"
18
18
  },
19
19
  "dependencies": {
20
+ "@inquirer/prompts": "^6.0.1",
20
21
  "ansi-colors": "^4.1.3",
21
22
  "chokidar": "^4.0.1",
22
23
  "cross-spawn": "^7.0.3",