uni-run 1.0.5 → 1.0.7

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 (63) 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} +49 -33
  6. package/dist/{arg-helper.d.ts → arg-helper.d.cts} +60 -46
  7. package/dist/arg-helper.d.mts +129 -0
  8. package/dist/arg-helper.mjs +98 -0
  9. package/dist/{arg.js → arg.cjs} +5 -2
  10. package/dist/{arg.d.ts → arg.d.cts} +109 -83
  11. package/dist/arg.d.mts +257 -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} +37 -9
  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 +105 -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 +60 -0
  37. package/dist/execution/watcher.d.cts +6 -0
  38. package/dist/execution/watcher.d.mts +6 -0
  39. package/dist/execution/watcher.mjs +31 -0
  40. package/dist/index.cjs +19 -0
  41. package/dist/index.d.cts +8 -0
  42. package/dist/index.d.mts +8 -0
  43. package/dist/index.mjs +13 -0
  44. package/dist/lib/colors.cjs +32 -0
  45. package/dist/lib/colors.d.cts +3 -0
  46. package/dist/lib/colors.d.mts +3 -0
  47. package/dist/lib/colors.mjs +4 -0
  48. package/dist/lib/currentModule.cjs +19 -0
  49. package/dist/lib/currentModule.d.cts +5 -0
  50. package/dist/lib/currentModule.d.mts +5 -0
  51. package/dist/lib/currentModule.mjs +17 -0
  52. package/dist/utils/debounce.d.mts +1 -0
  53. package/dist/utils/debounce.mjs +7 -0
  54. package/package.json +11 -8
  55. package/dist/execution/gitignore.js +0 -14
  56. package/dist/execution/watcher.d.ts +0 -6
  57. package/dist/execution/watcher.js +0 -38
  58. package/dist/lib/colors.d.ts +0 -2
  59. package/dist/lib/colors.js +0 -4
  60. /package/dist/{index.d.ts → app.d.cts} +0 -0
  61. /package/dist/execution/{gitignore.d.ts → gitignore.d.cts} +0 -0
  62. /package/dist/utils/{debounce.js → debounce.cjs} +0 -0
  63. /package/dist/utils/{debounce.d.ts → debounce.d.cts} +0 -0
@@ -0,0 +1,31 @@
1
+ import * as path from "path";
2
+ import gitignore from "./gitignore.mjs";
3
+ import * as chokidar from "chokidar";
4
+ import { createDebounce } from "../utils/debounce.mjs";
5
+ export default function (cwd, targets, callback, options) {
6
+ const ig = gitignore(cwd, options.ignore);
7
+ const debounce = createDebounce(options.debounceDelay);
8
+ const watcher = chokidar.watch(targets, {
9
+ ignored: (filePath) => {
10
+ for (const target of targets) {
11
+ const relativePath = path.relative(target, filePath);
12
+ if (!relativePath)
13
+ return false;
14
+ if (ig.ignores(relativePath))
15
+ return true;
16
+ if (options.extensions.size) {
17
+ const ext = path.extname(relativePath).slice(1);
18
+ if (ext && !options.extensions.has(ext))
19
+ return true;
20
+ }
21
+ }
22
+ return false;
23
+ },
24
+ interval: options.debounceDelay / 2,
25
+ ignoreInitial: true,
26
+ persistent: true,
27
+ });
28
+ watcher.on('add', () => debounce(() => callback()));
29
+ watcher.on('change', () => debounce(() => callback()));
30
+ watcher.on('unlink', () => debounce(() => callback()));
31
+ }
package/dist/index.cjs ADDED
@@ -0,0 +1,19 @@
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.Executor = void 0;
7
+ require("./app.cjs");
8
+ const arg_1 = require("./arg.cjs");
9
+ const builtin_bin_1 = __importDefault(require("./builtin-bin/index.cjs"));
10
+ const Executor_1 = __importDefault(require("./builtin-bin/Executor.cjs"));
11
+ exports.Executor = Executor_1.default;
12
+ exports.default = {
13
+ addBin(bin) {
14
+ builtin_bin_1.default.push(bin);
15
+ },
16
+ start(args) {
17
+ arg_1.app.start(args);
18
+ },
19
+ };
@@ -0,0 +1,8 @@
1
+ import "./app.cjs";
2
+ import Executor from "./builtin-bin/Executor.cjs";
3
+ export { Executor };
4
+ declare const _default: {
5
+ addBin(bin: Executor): void;
6
+ start(args?: string[]): void;
7
+ };
8
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import "./app.mjs";
2
+ import Executor from "./builtin-bin/Executor.mjs";
3
+ export { Executor };
4
+ declare const _default: {
5
+ addBin(bin: Executor): void;
6
+ start(args?: string[]): void;
7
+ };
8
+ export default _default;
package/dist/index.mjs ADDED
@@ -0,0 +1,13 @@
1
+ import "./app.mjs";
2
+ import { app } from "./arg.mjs";
3
+ import builtinBin from "./builtin-bin/index.mjs";
4
+ import Executor from "./builtin-bin/Executor.mjs";
5
+ export { Executor };
6
+ export default {
7
+ addBin(bin) {
8
+ builtinBin.push(bin);
9
+ },
10
+ start(args) {
11
+ app.start(args);
12
+ },
13
+ };
@@ -0,0 +1,32 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const ansi_colors_1 = __importDefault(require("ansi-colors"));
30
+ const cjs = __importStar(require("ansi-colors"));
31
+ const currentModule_1 = __importDefault(require("./currentModule.cjs"));
32
+ exports.default = currentModule_1.default.isCJS ? cjs : ansi_colors_1.default;
@@ -0,0 +1,3 @@
1
+ import mjs from "ansi-colors";
2
+ declare const _default: typeof mjs;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import mjs from "ansi-colors";
2
+ declare const _default: typeof mjs;
3
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import mjs from "ansi-colors";
2
+ import * as cjs from "ansi-colors";
3
+ import currentModule from "./currentModule.mjs";
4
+ export default currentModule.isCJS ? cjs : mjs;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ let currentModule;
5
+ try {
6
+ currentModule = module;
7
+ currentModule = exports;
8
+ currentModule = 'cjs';
9
+ }
10
+ catch (_a) {
11
+ currentModule = 'mjs';
12
+ }
13
+ if (!currentModule) {
14
+ throw new Error('Unkown module System');
15
+ }
16
+ exports.default = {
17
+ isCJS: currentModule === 'cjs',
18
+ isESM: currentModule === 'mjs',
19
+ };
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ isCJS: boolean;
3
+ isESM: boolean;
4
+ };
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ isCJS: boolean;
3
+ isESM: boolean;
4
+ };
5
+ export default _default;
@@ -0,0 +1,17 @@
1
+ // @ts-nocheck
2
+ let currentModule;
3
+ try {
4
+ currentModule = module;
5
+ currentModule = exports;
6
+ currentModule = 'cjs';
7
+ }
8
+ catch (_a) {
9
+ currentModule = 'mjs';
10
+ }
11
+ if (!currentModule) {
12
+ throw new Error('Unkown module System');
13
+ }
14
+ export default {
15
+ isCJS: currentModule === 'cjs',
16
+ isESM: currentModule === 'mjs',
17
+ };
@@ -0,0 +1 @@
1
+ export declare function createDebounce(delay: number): (fn: Function) => void;
@@ -0,0 +1,7 @@
1
+ export function createDebounce(delay) {
2
+ let debounceTimeout;
3
+ return function (fn) {
4
+ clearTimeout(debounceTimeout);
5
+ debounceTimeout = setTimeout(() => fn(), delay);
6
+ };
7
+ }
package/package.json CHANGED
@@ -1,18 +1,20 @@
1
1
  {
2
2
  "name": "uni-run",
3
+ "version": "1.0.7",
3
4
  "description": "Universal Runner for many language",
4
- "version": "1.0.5",
5
- "type": "commonjs",
6
5
  "scripts": {
7
- "ts": "tsx --watch ./src/__lab__/index.ts",
8
- "js": "node --watch ./dist/__lab__/index.js",
6
+ "dev": "npmize dev",
7
+ "build": "npmize build",
9
8
  "tsc": "tsc --watch --noEmit",
10
- "dev": "tsc --watch",
11
- "build": "node ./build.cjs"
9
+ "lab": "run ./src/__lab__/index.ts",
10
+ "cjs": "node ./dist/__lab__/index.cjs",
11
+ "mjs": "node ./dist/__lab__/index.mjs"
12
12
  },
13
+ "main": "./dist/index.cjs",
14
+ "module": "./dist/index.mjs",
13
15
  "bin": {
14
- "run": "./dist/bin.js",
15
- "uni-run": "./dist/bin.js"
16
+ "run": "./dist/bin.cjs",
17
+ "uni-run": "./dist/bin.cjs"
16
18
  },
17
19
  "dependencies": {
18
20
  "ansi-colors": "^4.1.3",
@@ -24,6 +26,7 @@
24
26
  "devDependencies": {
25
27
  "@types/cross-spawn": "^6.0.6",
26
28
  "@types/node": "^22.5.5",
29
+ "npmize": "^1.1.3",
27
30
  "typescript": "^5.6.2"
28
31
  },
29
32
  "repository": {
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const fs = require("fs");
5
- const path = require("path");
6
- const ignore_1 = require("ignore");
7
- function default_1(baseDir, extraIgnore = []) {
8
- const gitignorePath = path.resolve(path.join(baseDir, '.gitignore'));
9
- const ig = (0, ignore_1.default)({ ignorecase: true }).add(extraIgnore);
10
- if (fs.existsSync(gitignorePath)) {
11
- return ig.add(fs.readFileSync(gitignorePath).toString());
12
- }
13
- return ig;
14
- }
@@ -1,6 +0,0 @@
1
- export type WatcherOptions = {
2
- ignore: string[];
3
- extensions: Set<string>;
4
- debounceDelay: number;
5
- };
6
- export default function (dir: string, options: WatcherOptions, callback: () => void): void;
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const path = require("path");
5
- const chokidar = require("chokidar");
6
- const gitignore_1 = require("./gitignore");
7
- const debounce_1 = require("../utils/debounce");
8
- function default_1(dir, options, callback) {
9
- const ig = (0, gitignore_1.default)(dir, options.ignore);
10
- const debounce = (0, debounce_1.createDebounce)(options.debounceDelay);
11
- const watcher = chokidar.watch(dir, {
12
- ignored: (filePath) => {
13
- const relativePath = path.relative(dir, filePath);
14
- if (!relativePath)
15
- return false;
16
- if (ig.ignores(relativePath))
17
- return true;
18
- if (options.extensions.size) {
19
- const ext = path.extname(relativePath).slice(1);
20
- if (ext && !options.extensions.has(ext))
21
- return true;
22
- }
23
- return false;
24
- },
25
- interval: options.debounceDelay / 2,
26
- ignoreInitial: true,
27
- persistent: true,
28
- });
29
- watcher.on('add', (event) => {
30
- debounce(() => callback());
31
- });
32
- watcher.on('change', (event) => {
33
- debounce(() => callback());
34
- });
35
- watcher.on('unlink', () => {
36
- debounce(() => callback());
37
- });
38
- }
@@ -1,2 +0,0 @@
1
- import * as colors from 'ansi-colors';
2
- export default colors;
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const colors = require("ansi-colors");
4
- exports.default = colors;
File without changes
File without changes
File without changes