uni-run 1.1.6 → 1.1.8

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/app.js CHANGED
@@ -43,8 +43,14 @@ const argHelper_1 = require("./argHelper");
43
43
  const scriptExecutors_1 = __importDefault(require("./scriptExecutors"));
44
44
  const checkRuntime_1 = __importDefault(require("./scriptExecutors/checkRuntime"));
45
45
  const getUserExecutors_1 = __importDefault(require("./helpers/getUserExecutors"));
46
+ const helpers_1 = require("./scriptExecutors/helpers");
46
47
  arg.app.on((_a, flags_1) => __awaiter(void 0, [_a, flags_1], void 0, function* ([script, listArs, trailingArgs], flags) {
47
48
  var _b;
49
+ if (process.env.NODE_ENV_UNI_RUN === 'LAB') {
50
+ flags.clear = false;
51
+ flags['safe-stdin'] = true;
52
+ flags['key-reload'] = false;
53
+ }
48
54
  const executionConfig = (0, getConfig_1.default)(flags.cwd);
49
55
  const userExecutors = (0, getUserExecutors_1.default)(flags.cwd);
50
56
  const totalExecutors = [
@@ -79,3 +85,8 @@ arg.list.on(() => {
79
85
  console.log(`- ${colors_1.default.blue(name)}`, `[${exts.map((e) => '.' + colors_1.default.green(e)).join(', ')}]`);
80
86
  });
81
87
  });
88
+ arg.clean.on(() => {
89
+ console.log(colors_1.default.bgGreen('CACHE:'), (0, helpers_1.getCacheDir)());
90
+ (0, helpers_1.cleanCacheDir)();
91
+ console.log(colors_1.default.green('Cache directory cleaned.'));
92
+ });
package/dist/arg.d.ts CHANGED
@@ -275,3 +275,17 @@ export declare const list: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProg
275
275
  readonly flags: {};
276
276
  globalFlags: {};
277
277
  }>;
278
+ export declare const clean: import("noarg/dist/NoArg/NoArgProgram.cjs").NoArgProgram<"clean", {
279
+ readonly allowEqualAssign: true;
280
+ readonly booleanNotSyntaxEnding: "\\";
281
+ readonly allowDuplicateFlagForList: true;
282
+ readonly splitListByComma: true;
283
+ }, {
284
+ readonly help: true;
285
+ }, {
286
+ readonly description: "Clean cache directory";
287
+ readonly arguments: [];
288
+ readonly optionalArguments: [];
289
+ readonly flags: {};
290
+ globalFlags: {};
291
+ }>;
package/dist/arg.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.list = exports.exec = exports.app = void 0;
6
+ exports.clean = exports.list = exports.exec = exports.app = void 0;
7
7
  const noarg_1 = __importDefault(require("noarg"));
8
8
  const argHelper_1 = require("./argHelper");
9
9
  exports.app = noarg_1.default.create('uni-run', Object.assign(Object.assign({}, argHelper_1.executionConfig), { description: 'A universal runner for scripts', system: { splitListByComma: true }, arguments: [
@@ -13,3 +13,6 @@ exports.exec = exports.app.create('exec', Object.assign(Object.assign({}, argHel
13
13
  exports.list = exports.app.create('list', {
14
14
  description: 'List supported scripts',
15
15
  });
16
+ exports.clean = exports.app.create('clean', {
17
+ description: 'Clean cache directory',
18
+ });
@@ -1,2 +1,3 @@
1
1
  export declare function getExistedFile(...files: string[]): string | undefined;
2
2
  export declare function getUserPath(): string | undefined;
3
+ export declare function emptyDir(...paths: string[]): string;
@@ -5,7 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getExistedFile = getExistedFile;
7
7
  exports.getUserPath = getUserPath;
8
+ exports.emptyDir = emptyDir;
8
9
  const fs_1 = __importDefault(require("fs"));
10
+ const path_1 = __importDefault(require("path"));
9
11
  function getExistedFile(...files) {
10
12
  for (const file of files) {
11
13
  if (fs_1.default.existsSync(file))
@@ -16,3 +18,11 @@ function getUserPath() {
16
18
  var _a;
17
19
  return (_a = process.env.HOME) !== null && _a !== void 0 ? _a : process.env.USERPROFILE;
18
20
  }
21
+ function emptyDir(...paths) {
22
+ const target = path_1.default.join(...paths);
23
+ if (fs_1.default.existsSync(target)) {
24
+ fs_1.default.rmSync(target, { recursive: true, force: true });
25
+ }
26
+ fs_1.default.mkdirSync(target, { recursive: true });
27
+ return target;
28
+ }
@@ -0,0 +1,3 @@
1
+ export declare function getUniqueCacheDir(slug: string): string;
2
+ export declare function getCacheDir(): string;
3
+ export declare function cleanCacheDir(): void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getUniqueCacheDir = getUniqueCacheDir;
7
+ exports.getCacheDir = getCacheDir;
8
+ exports.cleanCacheDir = cleanCacheDir;
9
+ const path_1 = __importDefault(require("path"));
10
+ const utils_1 = require("../helpers/utils");
11
+ const cacheDir = path_1.default.join(__dirname, '../../.cache');
12
+ function getUniqueCacheDir(slug) {
13
+ return (0, utils_1.emptyDir)(cacheDir, slug + '-' + `${process.pid}-${process.ppid}`);
14
+ }
15
+ function getCacheDir() {
16
+ return cacheDir;
17
+ }
18
+ function cleanCacheDir() {
19
+ (0, utils_1.emptyDir)(cacheDir);
20
+ }
@@ -4,6 +4,8 @@ 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 helpers_1 = require("./helpers");
8
+ const utils_1 = require("../helpers/utils");
7
9
  exports.default = (0, as_1.default)([
8
10
  {
9
11
  name: 'JavaScript',
@@ -24,7 +26,6 @@ exports.default = (0, as_1.default)([
24
26
  }
25
27
  return {
26
28
  exec: [runtime, ...args],
27
- compile: ['echo', 'hello'],
28
29
  install: {
29
30
  check: [runtime, '--version'],
30
31
  hints: installHints,
@@ -179,7 +180,7 @@ exports.default = (0, as_1.default)([
179
180
  return {
180
181
  exec: ['go', 'run', ...args],
181
182
  install: {
182
- check: ['go', '-v'],
183
+ check: ['go', 'version'],
183
184
  hints: ['Please install Ruby from https://www.ruby-lang.org'],
184
185
  },
185
186
  };
@@ -189,9 +190,10 @@ exports.default = (0, as_1.default)([
189
190
  name: 'C - GCC',
190
191
  exts: ['c'],
191
192
  getRuntime([script, ...args], options, config) {
193
+ const output = (0, utils_1.emptyDir)('/c-gcc') + '/output';
192
194
  return {
193
- compile: ['gcc', script, '-o', 'dist/output'],
194
- exec: ['./dist/output', ...args],
195
+ compile: ['gcc', script, '-o', output],
196
+ exec: [output, ...args],
195
197
  install: {
196
198
  check: ['gcc', '--version'],
197
199
  hints: ['Please install GCC from https://gcc.gnu.org'],
@@ -203,9 +205,10 @@ exports.default = (0, as_1.default)([
203
205
  name: 'C++ - GCC',
204
206
  exts: ['cpp'],
205
207
  getRuntime([script, ...args], options, config) {
208
+ const output = (0, helpers_1.getUniqueCacheDir)('/cpp-gcc') + '/output';
206
209
  return {
207
- compile: ['g++', script, '-o', 'dist/output'],
208
- exec: ['./dist/output', ...args],
210
+ compile: ['g++', script, '-o', output],
211
+ exec: [output, ...args],
209
212
  install: {
210
213
  check: ['g++', '--version'],
211
214
  hints: ['Please install GCC from https://gcc.gnu.org'],
@@ -214,12 +217,13 @@ exports.default = (0, as_1.default)([
214
217
  },
215
218
  },
216
219
  {
217
- name: 'C# - Mono',
220
+ name: 'C# - Mono (Windows)',
218
221
  exts: ['cs'],
219
222
  getRuntime([script, ...args], options, config) {
223
+ const output = (0, helpers_1.getUniqueCacheDir)('/cs-mono') + '/output.exe';
220
224
  return {
221
- compile: ['mcs', script, '-out:dist/output.exe'],
222
- exec: ['./dist/output', ...args],
225
+ compile: ['mcs', '-out:' + output, script],
226
+ exec: [output, ...args],
223
227
  install: {
224
228
  check: ['mcs', '--version'],
225
229
  hints: ['Please install Mono from https://www.mono-project.com'],
@@ -231,9 +235,10 @@ exports.default = (0, as_1.default)([
231
235
  name: 'Rust - rustc',
232
236
  exts: ['rs'],
233
237
  getRuntime([script, ...args], options, config) {
238
+ const output = (0, helpers_1.getUniqueCacheDir)('/rust') + '/output';
234
239
  return {
235
- compile: ['rustc', script, '-o', 'dist/output'],
236
- exec: ['./dist/output', ...args],
240
+ compile: ['rustc', script, '-o', output],
241
+ exec: [output, ...args],
237
242
  install: {
238
243
  check: ['rustc', '--version'],
239
244
  hints: ['Please install Rust from https://www.rust-lang.org'],
@@ -260,13 +265,13 @@ exports.default = (0, as_1.default)([
260
265
  exts: ['html', 'htm'],
261
266
  getRuntime([script, ...args], options, config) {
262
267
  return {
263
- exec: ['lite-server', script, ...args],
268
+ exec: ['light-express-server', script, ...args],
264
269
  watchExts: ['css', 'js', 'javascript'],
265
270
  install: {
266
- check: ['lite-server', '--version'],
267
- command: ['npm', 'install', '-g', 'lite-server'],
271
+ check: ['light-express-server', '--version'],
272
+ command: ['npm', 'install', '-g', 'light-express-server'],
268
273
  hints: [
269
- 'Please install lite-server from https://www.npmjs.com/package/lite-server',
274
+ 'Please install light-express-server from https://www.npmjs.com/package/light-express-server',
270
275
  ],
271
276
  },
272
277
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uni-run",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "description": "Universal Runner for many language",
5
5
  "type": "commonjs",
6
6
  "scripts": {
@@ -9,7 +9,7 @@
9
9
  "tsc": "tsc --watch --noEmit",
10
10
  "live": "node ./dist/__lab__/index.js",
11
11
  "tsx": "tsx --watch ./src/__lab__/index.ts",
12
- "lab": "run ./src/__lab__/index.ts --focus ./src"
12
+ "lab": "run ./src/__lab__/index.ts --focus ./src --env NODE_ENV_UNI_RUN=LAB"
13
13
  },
14
14
  "main": "./dist/index.js",
15
15
  "bin": {
package/dist/output.exe DELETED
Binary file