uni-run 0.0.5 → 1.0.0

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.
@@ -14,8 +14,8 @@ export declare const executionConfig: {
14
14
  default: true;
15
15
  aliases: [string];
16
16
  }>;
17
- readonly reload: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
18
- description: "Reload the page when pressing \"Ctrl+R\" or \"Meta+R\"";
17
+ readonly reloadKey: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
18
+ description: "Reload the page when pressing \"Ctrl+R\" or \"F5\"";
19
19
  required: true;
20
20
  default: true;
21
21
  aliases: [string];
@@ -26,7 +26,7 @@ export declare const executionConfig: {
26
26
  default: true;
27
27
  aliases: [string];
28
28
  }>;
29
- readonly watchDelay: import("noarg/dist/schema/TypeNumber.cjs").TypeNumber<{
29
+ readonly delay: import("noarg/dist/schema/TypeNumber.cjs").TypeNumber<{
30
30
  description: "The delay to wait for the watcher to trigger";
31
31
  required: true;
32
32
  default: 100;
@@ -40,10 +40,11 @@ export declare const executionConfig: {
40
40
  aliases: [string];
41
41
  }>;
42
42
  readonly ignore: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
43
+ description: "Ignore the given targets";
43
44
  required: true;
44
45
  default: never[];
45
46
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
46
- description: "Ignore the given targets";
47
+ aliases: [string];
47
48
  }>;
48
49
  readonly env: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
49
50
  required: true;
@@ -53,10 +54,13 @@ export declare const executionConfig: {
53
54
  }>;
54
55
  };
55
56
  readonly listArgument: {
56
- readonly name: "args";
57
+ readonly name: "args for script";
57
58
  readonly description: "The arguments to pass to the script";
58
59
  readonly type: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
59
60
  };
60
61
  readonly trailingArguments: "--";
62
+ readonly customRenderHelp: {
63
+ readonly helpUsageTrailingArgsLabel: "--args/flags for script";
64
+ };
61
65
  };
62
66
  export declare function mapFlagsToOptions(flags: NoArg.InferFlags<typeof app>, watchExtensions?: string[]): ExecuteOptions;
@@ -12,48 +12,52 @@ exports.executionConfig = noarg_1.default.defineConfig({
12
12
  .default(true)
13
13
  .description('Clear the console before running the script')
14
14
  .aliases('c'),
15
- reload: noarg_1.default.boolean()
15
+ reloadKey: noarg_1.default.boolean()
16
16
  .default(true)
17
- .description('Reload the page when pressing "Ctrl+R" or "Meta+R"')
18
- .aliases('r'),
17
+ .description('Reload the page when pressing "Ctrl+R" or "F5"')
18
+ .aliases('rk'),
19
19
  watch: noarg_1.default.boolean()
20
20
  .default(true)
21
21
  .description('Watch for changes')
22
22
  .aliases('w'),
23
- watchDelay: noarg_1.default.number()
23
+ delay: noarg_1.default.number()
24
24
  .default(100)
25
25
  .description('The delay to wait for the watcher to trigger')
26
- .aliases('wd'),
26
+ .aliases('d'),
27
27
  ext: noarg_1.default.array(noarg_1.default.string())
28
28
  .default([])
29
29
  .description('Looks for changes only of the given extensions')
30
30
  .aliases('e'),
31
31
  ignore: noarg_1.default.array(noarg_1.default.string())
32
32
  .default([])
33
- .description('Ignore the given targets'),
33
+ .description('Ignore the given targets')
34
+ .aliases('ig'),
34
35
  env: noarg_1.default.array(noarg_1.default.string())
35
36
  .default([])
36
37
  .description('Environment variables'),
37
38
  },
38
39
  listArgument: {
39
- name: 'args',
40
+ name: 'args for script',
40
41
  description: 'The arguments to pass to the script',
41
42
  type: noarg_1.default.string(),
42
43
  },
43
44
  trailingArguments: '--',
45
+ customRenderHelp: {
46
+ helpUsageTrailingArgsLabel: '--args/flags for script',
47
+ },
44
48
  });
45
49
  function mapFlagsToOptions(flags, watchExtensions) {
46
50
  return {
47
51
  cwd: flags.cwd,
48
52
  clearOnReload: flags.clear,
49
- readlineReload: flags.reload,
53
+ readlineReload: flags.reloadKey,
50
54
  env: flags.env.reduce((acc, env) => {
51
55
  const [key, value] = env.split('=');
52
56
  acc[key] = value;
53
57
  return acc;
54
58
  }, {}),
55
59
  watch: flags.watch,
56
- watchDelay: flags.watchDelay,
60
+ watchDelay: flags.delay,
57
61
  watchExtensions: flags.ext.length ? flags.ext : watchExtensions !== null && watchExtensions !== void 0 ? watchExtensions : [],
58
62
  watchIgnore: flags.ignore,
59
63
  };
package/dist/arg.d.ts CHANGED
@@ -16,7 +16,7 @@ export declare const app: NoArg<"uni-run", {
16
16
  readonly description: "Run a script";
17
17
  }];
18
18
  readonly listArgument: {
19
- readonly name: "args";
19
+ readonly name: "args for script";
20
20
  readonly description: "The arguments to pass to the script";
21
21
  readonly type: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
22
22
  };
@@ -33,8 +33,8 @@ export declare const app: NoArg<"uni-run", {
33
33
  default: true;
34
34
  aliases: [string];
35
35
  }>;
36
- readonly reload: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
37
- description: "Reload the page when pressing \"Ctrl+R\" or \"Meta+R\"";
36
+ readonly reloadKey: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
37
+ description: "Reload the page when pressing \"Ctrl+R\" or \"F5\"";
38
38
  required: true;
39
39
  default: true;
40
40
  aliases: [string];
@@ -45,7 +45,7 @@ export declare const app: NoArg<"uni-run", {
45
45
  default: true;
46
46
  aliases: [string];
47
47
  }>;
48
- readonly watchDelay: import("noarg/dist/schema/TypeNumber.cjs").TypeNumber<{
48
+ readonly delay: import("noarg/dist/schema/TypeNumber.cjs").TypeNumber<{
49
49
  description: "The delay to wait for the watcher to trigger";
50
50
  required: true;
51
51
  default: 100;
@@ -59,10 +59,11 @@ export declare const app: NoArg<"uni-run", {
59
59
  aliases: [string];
60
60
  }>;
61
61
  readonly ignore: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
62
+ description: "Ignore the given targets";
62
63
  required: true;
63
64
  default: never[];
64
65
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
65
- description: "Ignore the given targets";
66
+ aliases: [string];
66
67
  }>;
67
68
  readonly env: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
68
69
  required: true;
@@ -71,6 +72,9 @@ export declare const app: NoArg<"uni-run", {
71
72
  description: "Environment variables";
72
73
  }>;
73
74
  };
75
+ readonly customRenderHelp: {
76
+ readonly helpUsageTrailingArgsLabel: "--args/flags for script";
77
+ };
74
78
  }>;
75
79
  export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProgram<"exec", {
76
80
  readonly allowEqualAssign: true;
@@ -84,7 +88,7 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
84
88
  readonly arguments: [];
85
89
  readonly optionalArguments: [];
86
90
  readonly listArgument: {
87
- readonly name: "args";
91
+ readonly name: "args for script";
88
92
  readonly description: "The arguments to pass to the script";
89
93
  readonly type: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
90
94
  };
@@ -101,8 +105,8 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
101
105
  default: true;
102
106
  aliases: [string];
103
107
  }>;
104
- readonly reload: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
105
- description: "Reload the page when pressing \"Ctrl+R\" or \"Meta+R\"";
108
+ readonly reloadKey: import("noarg/dist/schema/TypeBoolean.cjs").TypeBoolean<{
109
+ description: "Reload the page when pressing \"Ctrl+R\" or \"F5\"";
106
110
  required: true;
107
111
  default: true;
108
112
  aliases: [string];
@@ -113,7 +117,7 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
113
117
  default: true;
114
118
  aliases: [string];
115
119
  }>;
116
- readonly watchDelay: import("noarg/dist/schema/TypeNumber.cjs").TypeNumber<{
120
+ readonly delay: import("noarg/dist/schema/TypeNumber.cjs").TypeNumber<{
117
121
  description: "The delay to wait for the watcher to trigger";
118
122
  required: true;
119
123
  default: 100;
@@ -127,10 +131,11 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
127
131
  aliases: [string];
128
132
  }>;
129
133
  readonly ignore: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
134
+ description: "Ignore the given targets";
130
135
  required: true;
131
136
  default: never[];
132
137
  schema: import("noarg/dist/schema/TypeString.cjs").TypeString<{}>;
133
- description: "Ignore the given targets";
138
+ aliases: [string];
134
139
  }>;
135
140
  readonly env: import("noarg/dist/schema/TypeArray.cjs").TypeArray<{
136
141
  required: true;
@@ -139,5 +144,22 @@ export declare const exec: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
139
144
  description: "Environment variables";
140
145
  }>;
141
146
  };
147
+ readonly customRenderHelp: {
148
+ readonly helpUsageTrailingArgsLabel: "--args/flags for script";
149
+ };
150
+ globalFlags: {};
151
+ }>;
152
+ export declare const support: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProgram<"support", {
153
+ readonly allowEqualAssign: true;
154
+ readonly booleanNotSyntaxEnding: "\\";
155
+ readonly allowDuplicateFlagForList: true;
156
+ readonly splitListByComma: true;
157
+ }, {
158
+ readonly help: true;
159
+ }, {
160
+ readonly description: "List supported scripts";
161
+ readonly arguments: [];
162
+ readonly optionalArguments: [];
163
+ readonly flags: {};
142
164
  globalFlags: {};
143
165
  }>;
package/dist/arg.js CHANGED
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.exec = exports.app = void 0;
3
+ exports.support = exports.exec = exports.app = void 0;
4
4
  const noarg_1 = require("noarg");
5
5
  const arg_helper_1 = require("./arg-helper");
6
6
  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
7
  { name: 'script', type: noarg_1.default.string(), description: 'Run a script' },
8
8
  ] }));
9
9
  exports.exec = exports.app.create('exec', Object.assign(Object.assign({}, arg_helper_1.executionConfig), { description: 'Execute a script with the given binary' }));
10
+ exports.support = exports.app.create('support', {
11
+ description: 'List supported scripts',
12
+ });
@@ -5,7 +5,10 @@ type ExecutionBinConfig = {
5
5
  runArgs?: string[];
6
6
  checkInstallationArgs?: string[];
7
7
  howToInstall?: () => void;
8
- installCommands?: string[][];
8
+ installCommands?: {
9
+ command: string;
10
+ args: string[];
11
+ }[];
9
12
  };
10
13
  export default class Executor {
11
14
  name: string;
@@ -35,7 +35,7 @@ class Executor {
35
35
  var _a;
36
36
  if (!ans)
37
37
  return;
38
- (_a = this.config.installCommands) === null || _a === void 0 ? void 0 : _a.forEach(([command, ...args]) => {
38
+ (_a = this.config.installCommands) === null || _a === void 0 ? void 0 : _a.forEach(({ command, args }) => {
39
39
  if (!command)
40
40
  return;
41
41
  (0, cross_spawn_1.sync)(command, args, { stdio: 'inherit' });
@@ -8,7 +8,7 @@ exports.default = [
8
8
  watchExtensions: ['html', 'css', 'json'],
9
9
  checkInstallationArgs: ['--version'],
10
10
  howToInstall: () => {
11
- console.log('Please install Node.js from https://nodejs.org/');
11
+ console.log('Please install Node.js from https://nodejs.org');
12
12
  },
13
13
  }),
14
14
  new Executor_1.default('TypeScript', {
@@ -27,7 +27,7 @@ exports.default = [
27
27
  'mjsx',
28
28
  ],
29
29
  checkInstallationArgs: ['--version'],
30
- installCommands: [['npm', 'install', '-g', 'ts-node']],
30
+ installCommands: [{ command: 'npm', args: ['install', '-g', 'ts-node'] }],
31
31
  howToInstall: () => {
32
32
  console.log('Please install ts-node from https://www.npmjs.com/package/ts-node');
33
33
  },
@@ -37,7 +37,7 @@ exports.default = [
37
37
  extensions: ['py'],
38
38
  checkInstallationArgs: ['--version'],
39
39
  howToInstall: () => {
40
- console.log('Please install Python from https://www.python.org/');
40
+ console.log('Please install Python from https://www.python.org');
41
41
  },
42
42
  }),
43
43
  new Executor_1.default('Java - Oracle', {
@@ -45,7 +45,7 @@ exports.default = [
45
45
  extensions: ['java'],
46
46
  checkInstallationArgs: ['--version'],
47
47
  howToInstall: () => {
48
- console.log('Please install Java from https://www.oracle.com/java/');
48
+ console.log('Please install Java from https://www.oracle.com/java');
49
49
  },
50
50
  }),
51
51
  new Executor_1.default('Powershell', {
@@ -56,7 +56,7 @@ exports.default = [
56
56
  console.log('Please install Powershell from https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell');
57
57
  },
58
58
  }),
59
- new Executor_1.default('Cmd - Command Prompt', {
59
+ new Executor_1.default('Command Prompt', {
60
60
  command: 'cmd',
61
61
  runArgs: ['/c'],
62
62
  extensions: ['cmd', 'bat'],
@@ -70,7 +70,7 @@ exports.default = [
70
70
  extensions: ['sh'],
71
71
  checkInstallationArgs: ['--version'],
72
72
  howToInstall: () => {
73
- console.log('Please install Bash from https://www.gnu.org/software/bash/');
73
+ console.log('Please install Bash from https://www.gnu.org/software/bash');
74
74
  },
75
75
  }),
76
76
  new Executor_1.default('Lua', {
@@ -78,7 +78,28 @@ exports.default = [
78
78
  extensions: ['lua'],
79
79
  checkInstallationArgs: ['--version'],
80
80
  howToInstall: () => {
81
- console.log('Please install Lua from https://www.lua.org/');
81
+ console.log('Please install Lua from https://www.lua.org');
82
+ },
83
+ }),
84
+ new Executor_1.default('SASS (CSS)', {
85
+ command: 'sass',
86
+ extensions: ['sass', 'scss'],
87
+ checkInstallationArgs: ['--version'],
88
+ installCommands: [{ command: 'npm', args: ['install', '-g', 'sass'] }],
89
+ howToInstall: () => {
90
+ console.log('Please install SASS from https://sass-lang.com');
91
+ },
92
+ }),
93
+ new Executor_1.default('HTML Server', {
94
+ command: 'http-server',
95
+ extensions: ['html', 'htm'],
96
+ watchExtensions: ['css', 'js', 'json'],
97
+ checkInstallationArgs: ['--version'],
98
+ installCommands: [
99
+ { command: 'npm', args: ['install', '-g', 'http-server'] },
100
+ ],
101
+ howToInstall: () => {
102
+ console.log('Please install http-server from https://www.npmjs.com/package/http-server');
82
103
  },
83
104
  }),
84
105
  ];
@@ -23,13 +23,12 @@ class Execution {
23
23
  readline.emitKeypressEvents(process.stdin);
24
24
  (_b = (_a = process.stdin).setRawMode) === null || _b === void 0 ? void 0 : _b.call(_a, true);
25
25
  process.stdin.on('keypress', (_, key) => {
26
- if (key.name === 'f5')
27
- return this.runProcess();
28
- if ((key.ctrl || key.meta) && key.name === 'r')
26
+ if (key.name === 'f5' || (key.ctrl && key.name === 'r')) {
29
27
  return this.runProcess();
28
+ }
30
29
  if (key.ctrl && key.name === 'c') {
31
30
  this.killProcess();
32
- process.exit(0);
31
+ return process.exit(0);
33
32
  }
34
33
  });
35
34
  }
package/dist/index.js CHANGED
@@ -18,3 +18,17 @@ arg.app.on(([script, listArs, trailingArgs], flags) => {
18
18
  arg.exec.on(([listArs, trailingArgs], flags) => {
19
19
  execution_1.default.start([...listArs, ...trailingArgs], (0, arg_helper_1.mapFlagsToOptions)(flags));
20
20
  });
21
+ arg.support.on(() => {
22
+ console.log('Supported scripts:');
23
+ builtin_bin_1.default
24
+ .sort((a, b) => {
25
+ if (a.name < b.name)
26
+ return -1;
27
+ if (a.name > b.name)
28
+ return 1;
29
+ return 0;
30
+ })
31
+ .forEach((bin) => {
32
+ console.log(`- ${bin.name}`);
33
+ });
34
+ });
package/package.json CHANGED
@@ -1,16 +1,15 @@
1
1
  {
2
2
  "name": "uni-run",
3
3
  "description": "Universal Runner for many language",
4
- "version": "0.0.5",
4
+ "version": "1.0.0",
5
5
  "type": "commonjs",
6
6
  "scripts": {
7
- "ts": "w ./src/__lab__/index.ts",
8
- "js": "n ./dist/__lab__/index.js",
7
+ "ts": "run ./src/__lab__/index.ts",
8
+ "js": "run ./dist/__lab__/index.js",
9
9
  "dev": "tsc --watch",
10
10
  "build": "node ./build.cjs"
11
11
  },
12
12
  "bin": {
13
- "r": "./dist/bin.js",
14
13
  "run": "./dist/bin.js",
15
14
  "uni-run": "./dist/bin.js"
16
15
  },
@@ -19,7 +18,7 @@
19
18
  "chokidar": "^3.6.0",
20
19
  "cross-spawn": "^7.0.3",
21
20
  "ignore": "^5.3.2",
22
- "noarg": "^3.0.21"
21
+ "noarg": "^3.1.0"
23
22
  },
24
23
  "devDependencies": {
25
24
  "@types/cross-spawn": "^6.0.6",