uni-run 1.1.16 → 1.1.18

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.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import NoArg from 'noarg';
2
2
  export declare const app: NoArg<"uni-run", {
3
3
  readonly allowEqualAssign: true;
4
- readonly booleanNotSyntaxEnding: "\\";
5
4
  readonly allowDuplicateFlagForList: true;
5
+ readonly booleanNotSyntaxEnding: "!";
6
6
  readonly splitListByComma: true;
7
7
  }, {
8
8
  readonly help: true;
@@ -34,12 +34,12 @@ export declare const app: NoArg<"uni-run", {
34
34
  aliases: ["drs"];
35
35
  description: "Disable raw mode for stdin. Do not needed with `--disable-reload-key`";
36
36
  }>;
37
- readonly exit: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
38
- aliases: ["x"];
39
- description: "Exit the script after the first execution";
40
- }>;
41
- readonly quiet: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
37
+ readonly quit: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
42
38
  aliases: ["q"];
39
+ description: "Do not watch the script. Just run it once and exit";
40
+ }>;
41
+ readonly silent: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
42
+ aliases: ["s"];
43
43
  description: "Do not show any output of the script";
44
44
  }>;
45
45
  readonly keep: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
@@ -76,21 +76,11 @@ export declare const app: NoArg<"uni-run", {
76
76
  minLength: 1;
77
77
  description: "The prefix to show before the execution time";
78
78
  }>;
79
- readonly shell: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
80
- aliases: ["sh"];
81
- description: "Run the script in a shell for more low-level control.";
82
- }>;
83
79
  readonly cwd: import("noarg/dist/schema/TypeString.cjs").TypeString<{
84
80
  required: true;
85
81
  default: string;
86
82
  description: "Set the current working directory";
87
83
  }>;
88
- readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
89
- description: "Show information about the script";
90
- }>;
91
- readonly time: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
92
- description: "Show the execution time at the start";
93
- }>;
94
84
  readonly env: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
95
85
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
96
86
  description: "Set environment variables";
@@ -98,6 +88,15 @@ export declare const app: NoArg<"uni-run", {
98
88
  readonly 'node-dev': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
99
89
  description: "Set env.NODE_ENV to \"development\"";
100
90
  }>;
91
+ readonly shell: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
92
+ description: "Run script in shell for low-level commands";
93
+ }>;
94
+ readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
95
+ description: "Show information about the script";
96
+ }>;
97
+ readonly time: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
98
+ description: "Show the execution time at the start";
99
+ }>;
101
100
  };
102
101
  readonly customRenderHelp: {
103
102
  readonly helpUsageTrailingArgsLabel: "...[args/flags for script]";
@@ -105,8 +104,8 @@ export declare const app: NoArg<"uni-run", {
105
104
  }>;
106
105
  export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProgram<"exec", {
107
106
  readonly allowEqualAssign: true;
108
- readonly booleanNotSyntaxEnding: "\\";
109
107
  readonly allowDuplicateFlagForList: true;
108
+ readonly booleanNotSyntaxEnding: "!";
110
109
  readonly splitListByComma: true;
111
110
  }, {
112
111
  readonly help: true;
@@ -133,12 +132,12 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
133
132
  aliases: ["drs"];
134
133
  description: "Disable raw mode for stdin. Do not needed with `--disable-reload-key`";
135
134
  }>;
136
- readonly exit: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
137
- aliases: ["x"];
138
- description: "Exit the script after the first execution";
139
- }>;
140
- readonly quiet: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
135
+ readonly quit: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
141
136
  aliases: ["q"];
137
+ description: "Do not watch the script. Just run it once and exit";
138
+ }>;
139
+ readonly silent: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
140
+ aliases: ["s"];
142
141
  description: "Do not show any output of the script";
143
142
  }>;
144
143
  readonly keep: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
@@ -175,21 +174,11 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
175
174
  minLength: 1;
176
175
  description: "The prefix to show before the execution time";
177
176
  }>;
178
- readonly shell: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
179
- aliases: ["sh"];
180
- description: "Run the script in a shell for more low-level control.";
181
- }>;
182
177
  readonly cwd: import("noarg/dist/schema/TypeString.cjs").TypeString<{
183
178
  required: true;
184
179
  default: string;
185
180
  description: "Set the current working directory";
186
181
  }>;
187
- readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
188
- description: "Show information about the script";
189
- }>;
190
- readonly time: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
191
- description: "Show the execution time at the start";
192
- }>;
193
182
  readonly env: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
194
183
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
195
184
  description: "Set environment variables";
@@ -197,6 +186,15 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
197
186
  readonly 'node-dev': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
198
187
  description: "Set env.NODE_ENV to \"development\"";
199
188
  }>;
189
+ readonly shell: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
190
+ description: "Run script in shell for low-level commands";
191
+ }>;
192
+ readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
193
+ description: "Show information about the script";
194
+ }>;
195
+ readonly time: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
196
+ description: "Show the execution time at the start";
197
+ }>;
200
198
  };
201
199
  readonly customRenderHelp: {
202
200
  readonly helpUsageTrailingArgsLabel: "...[args/flags for script]";
@@ -205,8 +203,8 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
205
203
  }>;
206
204
  export declare const list: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProgram<"list", {
207
205
  readonly allowEqualAssign: true;
208
- readonly booleanNotSyntaxEnding: "\\";
209
206
  readonly allowDuplicateFlagForList: true;
207
+ readonly booleanNotSyntaxEnding: "!";
210
208
  readonly splitListByComma: true;
211
209
  }, {
212
210
  readonly help: true;
@@ -219,8 +217,8 @@ export declare const list: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
219
217
  }>;
220
218
  export declare const clean: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProgram<"clean", {
221
219
  readonly allowEqualAssign: true;
222
- readonly booleanNotSyntaxEnding: "\\";
223
220
  readonly allowDuplicateFlagForList: true;
221
+ readonly booleanNotSyntaxEnding: "!";
224
222
  readonly splitListByComma: true;
225
223
  }, {
226
224
  readonly help: true;
@@ -14,12 +14,12 @@ export declare const executionConfig: {
14
14
  aliases: ["drs"];
15
15
  description: "Disable raw mode for stdin. Do not needed with `--disable-reload-key`";
16
16
  }>;
17
- readonly exit: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
18
- aliases: ["x"];
19
- description: "Exit the script after the first execution";
20
- }>;
21
- readonly quiet: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
17
+ readonly quit: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
22
18
  aliases: ["q"];
19
+ description: "Do not watch the script. Just run it once and exit";
20
+ }>;
21
+ readonly silent: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
22
+ aliases: ["s"];
23
23
  description: "Do not show any output of the script";
24
24
  }>;
25
25
  readonly keep: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
@@ -56,21 +56,11 @@ export declare const executionConfig: {
56
56
  minLength: 1;
57
57
  description: "The prefix to show before the execution time";
58
58
  }>;
59
- readonly shell: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
60
- aliases: ["sh"];
61
- description: "Run the script in a shell for more low-level control.";
62
- }>;
63
59
  readonly cwd: import("noarg/dist/schema/TypeString.cjs").TypeString<{
64
60
  required: true;
65
61
  default: string;
66
62
  description: "Set the current working directory";
67
63
  }>;
68
- readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
69
- description: "Show information about the script";
70
- }>;
71
- readonly time: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
72
- description: "Show the execution time at the start";
73
- }>;
74
64
  readonly env: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
75
65
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
76
66
  description: "Set environment variables";
@@ -78,6 +68,15 @@ export declare const executionConfig: {
78
68
  readonly 'node-dev': import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
79
69
  description: "Set env.NODE_ENV to \"development\"";
80
70
  }>;
71
+ readonly shell: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
72
+ description: "Run script in shell for low-level commands";
73
+ }>;
74
+ readonly info: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
75
+ description: "Show information about the script";
76
+ }>;
77
+ readonly time: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
78
+ description: "Show the execution time at the start";
79
+ }>;
81
80
  };
82
81
  readonly listArgument: {
83
82
  readonly name: "args for script";
package/dist/argHelper.js CHANGED
@@ -17,11 +17,11 @@ exports.executionConfig = noarg_1.default.defineConfig({
17
17
  'disable-raw-stdin': noarg_1.default.boolean()
18
18
  .aliases('drs')
19
19
  .description('Disable raw mode for stdin. Do not needed with `--disable-reload-key`'),
20
- exit: noarg_1.default.boolean()
21
- .aliases('x')
22
- .description('Exit the script after the first execution'),
23
- quiet: noarg_1.default.boolean()
20
+ quit: noarg_1.default.boolean()
24
21
  .aliases('q')
22
+ .description('Do not watch the script. Just run it once and exit'),
23
+ silent: noarg_1.default.boolean()
24
+ .aliases('s')
25
25
  .description('Do not show any output of the script'),
26
26
  keep: noarg_1.default.boolean()
27
27
  .aliases('k')
@@ -46,16 +46,14 @@ exports.executionConfig = noarg_1.default.defineConfig({
46
46
  .aliases('bp')
47
47
  .minLength(1)
48
48
  .description('The prefix to show before the execution time'),
49
- shell: noarg_1.default.boolean()
50
- .aliases('sh')
51
- .description('Run the script in a shell for more low-level control.'),
52
49
  cwd: noarg_1.default.string()
53
50
  .default(process.cwd())
54
51
  .description('Set the current working directory'),
55
- info: noarg_1.default.boolean().description('Show information about the script'),
56
- time: noarg_1.default.boolean().description('Show the execution time at the start'),
57
52
  env: noarg_1.default.array(noarg_1.default.string()).description('Set environment variables'),
58
53
  'node-dev': noarg_1.default.boolean().description('Set env.NODE_ENV to "development"'),
54
+ shell: noarg_1.default.boolean().description('Run script in shell for low-level commands'),
55
+ info: noarg_1.default.boolean().description('Show information about the script'),
56
+ time: noarg_1.default.boolean().description('Show the execution time at the start'),
59
57
  },
60
58
  listArgument: {
61
59
  name: 'args for script',
@@ -69,14 +67,14 @@ exports.executionConfig = noarg_1.default.defineConfig({
69
67
  });
70
68
  function mapFlagsToOptions(flags) {
71
69
  var _a, _b, _c, _d, _e;
72
- if (flags.exit) {
70
+ if (flags.quit) {
73
71
  flags['disable-reload-key'] = true;
74
72
  flags['do-not-watch'] = true;
75
73
  }
76
74
  return {
77
75
  cwd: flags.cwd,
78
76
  shell: !!flags.shell,
79
- silent: !!flags.quiet,
77
+ silent: !!flags.silent,
80
78
  showInfo: !!flags.info,
81
79
  showTime: !!flags.time,
82
80
  benchmark: !!((_a = flags.bench) !== null && _a !== void 0 ? _a : flags['bench-prefix']),
@@ -0,0 +1,7 @@
1
+ declare const _default: {
2
+ isWindows: boolean;
3
+ isLinux: boolean;
4
+ isMac: boolean;
5
+ isUnix: boolean;
6
+ };
7
+ export default _default;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ isWindows: process.platform === 'win32',
5
+ isLinux: process.platform === 'linux',
6
+ isMac: process.platform === 'darwin',
7
+ isUnix: process.platform === 'linux' || process.platform === 'darwin',
8
+ };
@@ -18,8 +18,8 @@ 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;
22
- if (!runtime.install && !runtime.installHints)
21
+ var _a, _b, _c, _d;
22
+ if (!((_a = runtime.install) === null || _a === void 0 ? void 0 : _a.length) && !((_b = runtime.installHints) === null || _b === void 0 ? void 0 : _b.length))
23
23
  return true;
24
24
  const command = runtime.exec[0];
25
25
  if (!command)
@@ -28,16 +28,19 @@ function default_1(runtime) {
28
28
  if (result.status === 0)
29
29
  return true;
30
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))
32
- return false;
33
- const ans = yield (0, confirm_1.default)({ message: 'Do you want to install it?' }, { clearPromptOnDone: true });
34
- process.stdin.resume();
35
- if (ans) {
36
- const [installCmd, ...installArgs] = runtime.install;
37
- const result = (0, cross_spawn_1.sync)(installCmd, installArgs, { stdio: 'inherit' });
38
- return result.status === 0;
31
+ if ((_c = runtime.install) === null || _c === void 0 ? void 0 : _c.length) {
32
+ const ans = yield (0, confirm_1.default)({ message: 'Do you want to install it?' });
33
+ process.stdin.setRawMode(false);
34
+ if (ans) {
35
+ const [installCmd, ...installArgs] = runtime.install;
36
+ const result = (0, cross_spawn_1.sync)(installCmd, installArgs, { stdio: 'inherit' });
37
+ if (result.status === 0) {
38
+ process.stdin.resume();
39
+ return true;
40
+ }
41
+ }
39
42
  }
40
- if ((_b = runtime.installHints) === null || _b === void 0 ? void 0 : _b.length) {
43
+ if ((_d = runtime.installHints) === null || _d === void 0 ? void 0 : _d.length) {
41
44
  console.log(colors_1.default.bold('How to install:'));
42
45
  runtime.installHints.forEach((hint) => console.log(hint));
43
46
  }
@@ -4,58 +4,122 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const as_1 = __importDefault(require("../helpers/as"));
7
+ const os_1 = __importDefault(require("../helpers/os"));
7
8
  const helpers_1 = require("./helpers");
8
9
  exports.default = (0, as_1.default)([
9
10
  {
10
11
  name: 'JavaScript',
11
12
  exts: ['js', 'javascript', 'jsx', 'cjs', 'cjsx', 'mjs', 'mjsx'],
12
13
  getRuntime(args, options, config) {
13
- let installHints;
14
+ const runtimeOptions = {};
14
15
  const runtime = config['javascript-runtime'] || 'node';
15
16
  switch (runtime) {
16
17
  case 'node':
17
- installHints = ['Please install Node.js from https://nodejs.org'];
18
+ runtimeOptions.installHints = [
19
+ 'Please install Node.js from https://nodejs.org',
20
+ ];
18
21
  break;
19
22
  case 'deno':
20
- installHints = ['Please install Deno from https://deno.land'];
23
+ if (os_1.default.isWindows) {
24
+ runtimeOptions.install = [
25
+ 'powershell',
26
+ '-c',
27
+ 'irm https://deno.land/install.ps1 | iex',
28
+ ];
29
+ }
30
+ else if (os_1.default.isUnix) {
31
+ runtimeOptions.install = [
32
+ 'bash',
33
+ '-c',
34
+ 'curl -fsSL https://deno.land/install.sh | bash',
35
+ ];
36
+ }
37
+ runtimeOptions.installHints = [
38
+ 'Please install Deno from https://deno.land',
39
+ ];
21
40
  break;
22
41
  case 'bun':
23
- installHints = ['Please install Bun from https://bun.sh'];
42
+ if (os_1.default.isWindows) {
43
+ runtimeOptions.install = [
44
+ 'powershell',
45
+ '-c',
46
+ 'irm bun.sh/install.ps1 | iex',
47
+ ];
48
+ }
49
+ else if (os_1.default.isUnix) {
50
+ runtimeOptions.install = [
51
+ 'bash',
52
+ '-c',
53
+ 'curl -fsSL https://bun.sh/install | bash',
54
+ ];
55
+ }
56
+ runtimeOptions.installHints = [
57
+ 'Please install Bun from https://bun.sh',
58
+ ];
24
59
  break;
25
60
  }
26
- return {
27
- exec: [runtime, ...args],
28
- installHints,
29
- };
61
+ return Object.assign(Object.assign({}, runtimeOptions), { exec: [runtime, ...args] });
30
62
  },
31
63
  },
32
64
  {
33
65
  name: 'TypeScript',
34
66
  exts: ['ts', 'tsx', 'cts', 'ctsx', 'mts', 'mtsx'],
35
67
  getRuntime(args, options, config) {
36
- let installHints;
68
+ const runtimeOptions = {};
37
69
  const runtime = config['typescript-runtime'] || 'tsx';
38
70
  switch (runtime) {
39
71
  case 'tsx':
40
- installHints = ['Please install tsx from https://tsx.is'];
72
+ runtimeOptions.install = ['npm', 'install', '-g', 'tsx'];
73
+ runtimeOptions.installHints = [
74
+ 'Please install tsx from https://tsx.is',
75
+ ];
41
76
  break;
42
77
  case 'ts-node':
43
- installHints = [
78
+ runtimeOptions.install = ['npm', 'install', '-g', 'ts-node'];
79
+ runtimeOptions.installHints = [
44
80
  'Please install ts-node from https://www.npmjs.com/package/ts-node',
45
81
  ];
46
82
  break;
47
83
  case 'deno':
48
- installHints = ['Please install Deno from https://deno.land'];
84
+ if (os_1.default.isWindows) {
85
+ runtimeOptions.install = [
86
+ 'powershell',
87
+ '-c',
88
+ 'irm https://deno.land/install.ps1 | iex',
89
+ ];
90
+ }
91
+ else if (os_1.default.isUnix) {
92
+ runtimeOptions.install = [
93
+ 'bash',
94
+ '-c',
95
+ 'curl -fsSL https://deno.land/install.sh | bash',
96
+ ];
97
+ }
98
+ runtimeOptions.installHints = [
99
+ 'Please install Deno from https://deno.land',
100
+ ];
49
101
  break;
50
102
  case 'bun':
51
- installHints = ['Please install Bun from https://bun.sh'];
103
+ if (os_1.default.isWindows) {
104
+ runtimeOptions.install = [
105
+ 'powershell',
106
+ '-c',
107
+ 'irm bun.sh/install.ps1 | iex',
108
+ ];
109
+ }
110
+ else if (os_1.default.isUnix) {
111
+ runtimeOptions.install = [
112
+ 'bash',
113
+ '-c',
114
+ 'curl -fsSL https://bun.sh/install | bash',
115
+ ];
116
+ }
117
+ runtimeOptions.installHints = [
118
+ 'Please install Bun from https://bun.sh',
119
+ ];
52
120
  break;
53
121
  }
54
- return {
55
- exec: [runtime, ...args],
56
- watchExts: ['js', 'javascript', 'jsx', 'cjs', 'cjsx', 'mjs', 'mjsx'],
57
- installHints,
58
- };
122
+ return Object.assign(Object.assign({}, runtimeOptions), { exec: [runtime, ...args], watchExts: ['js', 'javascript', 'jsx', 'cjs', 'cjsx', 'mjs', 'mjsx'] });
59
123
  },
60
124
  },
61
125
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uni-run",
3
- "version": "1.1.16",
3
+ "version": "1.1.18",
4
4
  "description": "Universal Runner for many language",
5
5
  "type": "commonjs",
6
6
  "scripts": {
@@ -9,6 +9,7 @@
9
9
  "tsc": "tsc --watch --noEmit",
10
10
  "live": "node ./dist/__lab__/index.js",
11
11
  "tsx": "tsx ./src/__lab__/index.ts",
12
+ "tsxw": "tsx --watch ./src/__lab__/index.ts",
12
13
  "lab": "run ./src/__lab__/index.ts --focus ./src -- UNI_RUN_LAB_MODE"
13
14
  },
14
15
  "main": "./dist/index.js",
@@ -22,7 +23,7 @@
22
23
  "chokidar": "^4.0.1",
23
24
  "cross-spawn": "^7.0.3",
24
25
  "ignore": "^6.0.2",
25
- "noarg": "^3.1.6"
26
+ "noarg": "^3.1.8"
26
27
  },
27
28
  "devDependencies": {
28
29
  "@types/cross-spawn": "^6.0.6",