@elinzy/core 0.1.2 → 0.2.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.
package/README.md CHANGED
@@ -1 +1,83 @@
1
- ## @elinzy/e-core
1
+ # @elinzy/core
2
+
3
+ Node.js runtime primitives for the `e` CLI: process execution built on [execa](https://github.com/sindresorhus/execa), with command logging, dry-run and abbreviated output support.
4
+
5
+ ## Install
6
+
7
+ ```shell
8
+ npm install @elinzy/core
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ - ESM
14
+
15
+ ```js
16
+ import { exec, execSync, execCommand, execCommandSync } from '@elinzy/core';
17
+
18
+ // Asynchronous, array-style (like execa)
19
+ const result = await exec('git', ['status']);
20
+ console.log(result.stdout);
21
+
22
+ // Synchronous, string-style
23
+ const version = execCommandSync('node -v', { abbrev: true });
24
+
25
+ // Dry run: log the command, skip execution
26
+ await exec('rm', ['-rf', 'dist'], { dryRun: true });
27
+ ```
28
+
29
+ - CJS
30
+
31
+ ```js
32
+ const { execSync } = require('@elinzy/core');
33
+
34
+ const stdout = execSync('node', ['-v'], { abbrev: true });
35
+ ```
36
+
37
+ ## API
38
+
39
+ ### exec(cmd, args, opts?)
40
+
41
+ Execute a command asynchronously. Returns the execa result promise.
42
+
43
+ ### execSync(cmd, args, opts?)
44
+
45
+ Execute a command synchronously. Returns the execa result.
46
+
47
+ ### execCommand(cmd, opts?)
48
+
49
+ Execute a command string asynchronously (`'git status'` style). Returns the execa result promise.
50
+
51
+ ### execCommandSync(cmd, opts?)
52
+
53
+ Execute a command string synchronously. Returns the execa result.
54
+
55
+ #### cmd
56
+
57
+ - Type: `String`
58
+
59
+ #### args
60
+
61
+ - Type: `String[]`
62
+
63
+ #### opts
64
+
65
+ - Type: `Object`
66
+ - All [execa options](https://github.com/sindresorhus/execa/blob/main/docs/execution.md#options-1) are passed through (`cwd`, `env`, `stdio`, ...), plus:
67
+
68
+ | Option | Type | Default | Description |
69
+ | ------ | ---- | ------- | ----------- |
70
+ | `abbrev` | `Boolean` | `false` | Return only `stdout` instead of the full result |
71
+ | `logger` | `Boolean` | `false` | Print the command before executing it |
72
+ | `dryRun` | `Boolean` | `false` | Print the command but skip execution |
73
+ | `throwOnError` | `Boolean` | `true` | Throw a colored error including `stderr` / stack on failure; when `false`, failures resolve to `undefined` |
74
+
75
+ ## License
76
+
77
+ [MIT](https://github.com/Appleec/e/blob/main/packages/core/LICENSE)
78
+
79
+ ## Related
80
+
81
+ - [`@elinzy/logger`](https://github.com/Appleec/e/tree/main/packages/logger) — styled terminal logging
82
+ - [`@elinzy/git`](https://github.com/Appleec/e/tree/main/packages/git) — git operations built on this package
83
+ - [`e`](https://github.com/Appleec/e) — the monorepo root
@@ -1,83 +1,107 @@
1
- 'use strict';
2
-
3
- var execa = require('execa');
4
- var c = require('ansis');
5
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region \0rolldown/runtime.js
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
23
+ //#endregion
24
+ let execa = require("execa");
25
+ let ansis = require("ansis");
26
+ ansis = __toESM(ansis, 1);
27
+ //#region src/child_process.ts
28
+ /**
29
+ * Execute a command asynchronously
30
+ * @param {string} cmd
31
+ * @param {string[]} args
32
+ * @param {import("execa").Options} [opts]
33
+ */
6
34
  function exec(cmd, args, opts) {
7
- opts = {
8
- throwOnError: true,
9
- ...opts
10
- };
11
- if (opts.logger || opts.dryRun)
12
- console.log(c.green(`> ${[cmd, ...args].join(" ")}`));
13
- if (opts.dryRun)
14
- return Promise.resolve(void 0);
15
- return execa.execa(cmd, args, opts).then((spawned) => opts.abbrev ? spawned.stdout : spawned).catch((e) => {
16
- if (opts.throwOnError)
17
- throw new Error(
18
- c.red(`Running ${c.bold([cmd, ...args].join(" "))} in ${c.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
19
- );
20
- return Promise.resolve(void 0);
21
- });
35
+ opts = {
36
+ throwOnError: true,
37
+ ...opts
38
+ };
39
+ if (opts.logger || opts.dryRun) console.log(ansis.default.green(`> ${[cmd, ...args].join(" ")}`));
40
+ if (opts.dryRun) return Promise.resolve(void 0);
41
+ return (0, execa.execa)(cmd, args, opts).then((spawned) => opts.abbrev ? spawned.stdout : spawned).catch((e) => {
42
+ if (opts.throwOnError) throw new Error(ansis.default.red(`Running ${ansis.default.bold([cmd, ...args].join(" "))} in ${ansis.default.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message));
43
+ return Promise.resolve(void 0);
44
+ });
22
45
  }
46
+ /**
47
+ * Execute a command synchronously
48
+ * @param {string} cmd
49
+ * @param {string[]} args
50
+ * @param {import("execa").SyncOptions} [opts]
51
+ */
23
52
  function execSync(cmd, args, opts) {
24
- opts = {
25
- throwOnError: true,
26
- ...opts
27
- };
28
- if (opts.logger || opts.dryRun)
29
- console.log(c.green(`> ${[cmd, ...args].join(" ")}`));
30
- if (opts.dryRun)
31
- return void 0;
32
- try {
33
- const spawned = execa.execaSync(cmd, args, opts);
34
- return opts.abbrev ? spawned.stdout : spawned;
35
- } catch (e) {
36
- if (opts?.throwOnError)
37
- throw new Error(
38
- c.red(`Running ${c.bold([cmd, ...args].join(" "))} in ${c.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
39
- );
40
- return void 0;
41
- }
53
+ opts = {
54
+ throwOnError: true,
55
+ ...opts
56
+ };
57
+ if (opts.logger || opts.dryRun) console.log(ansis.default.green(`> ${[cmd, ...args].join(" ")}`));
58
+ if (opts.dryRun) return void 0;
59
+ try {
60
+ const spawned = (0, execa.execaSync)(cmd, args, opts);
61
+ return opts.abbrev ? spawned.stdout : spawned;
62
+ } catch (e) {
63
+ if (opts?.throwOnError) throw new Error(ansis.default.red(`Running ${ansis.default.bold([cmd, ...args].join(" "))} in ${ansis.default.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message));
64
+ return;
65
+ }
42
66
  }
67
+ /**
68
+ * Execute a command asynchronously (string)
69
+ * @param cmd
70
+ * @param opts
71
+ */
43
72
  function execCommand(cmd, opts) {
44
- opts = {
45
- throwOnError: true,
46
- ...opts
47
- };
48
- if (opts.logger || opts.dryRun)
49
- console.log(c.green(`> ${[cmd].join(" ")}`));
50
- if (opts.dryRun)
51
- return Promise.resolve(void 0);
52
- return execa.execaCommand(cmd, opts).then((spawned) => opts.abbrev ? spawned.stdout : spawned).catch((e) => {
53
- if (opts.throwOnError)
54
- throw new Error(
55
- c.red(`Running ${c.bold([cmd].join(" "))} in ${c.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
56
- );
57
- return Promise.resolve(void 0);
58
- });
73
+ opts = {
74
+ throwOnError: true,
75
+ ...opts
76
+ };
77
+ if (opts.logger || opts.dryRun) console.log(ansis.default.green(`> ${[cmd].join(" ")}`));
78
+ if (opts.dryRun) return Promise.resolve(void 0);
79
+ return (0, execa.execaCommand)(cmd, opts).then((spawned) => opts.abbrev ? spawned.stdout : spawned).catch((e) => {
80
+ if (opts.throwOnError) throw new Error(ansis.default.red(`Running ${ansis.default.bold([cmd].join(" "))} in ${ansis.default.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message));
81
+ return Promise.resolve(void 0);
82
+ });
59
83
  }
84
+ /**
85
+ * Execute a command synchronously (string)
86
+ * @param cmd
87
+ * @param opts
88
+ */
60
89
  function execCommandSync(cmd, opts) {
61
- opts = {
62
- throwOnError: true,
63
- ...opts
64
- };
65
- if (opts.logger || opts.dryRun)
66
- console.log(c.green(`> ${[cmd].join(" ")}`));
67
- if (opts.dryRun)
68
- return void 0;
69
- try {
70
- const spawned = execa.execaCommandSync(cmd, opts);
71
- return opts.abbrev ? spawned.stdout : spawned;
72
- } catch (e) {
73
- if (opts.throwOnError)
74
- throw new Error(
75
- c.red(`Running ${c.bold([cmd].join(" "))} in ${c.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
76
- );
77
- return void 0;
78
- }
90
+ opts = {
91
+ throwOnError: true,
92
+ ...opts
93
+ };
94
+ if (opts.logger || opts.dryRun) console.log(ansis.default.green(`> ${[cmd].join(" ")}`));
95
+ if (opts.dryRun) return void 0;
96
+ try {
97
+ const spawned = (0, execa.execaCommandSync)(cmd, opts);
98
+ return opts.abbrev ? spawned.stdout : spawned;
99
+ } catch (e) {
100
+ if (opts.throwOnError) throw new Error(ansis.default.red(`Running ${ansis.default.bold([cmd].join(" "))} in ${ansis.default.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message));
101
+ return;
102
+ }
79
103
  }
80
-
104
+ //#endregion
81
105
  exports.exec = exec;
82
106
  exports.execCommand = execCommand;
83
107
  exports.execCommandSync = execCommandSync;
@@ -0,0 +1,44 @@
1
+ import { Options, Result, ResultPromise, SyncOptions, SyncResult } from "execa";
2
+ //#region src/child_process.d.ts
3
+ export interface ExecOptions extends Options {
4
+ abbrev?: boolean;
5
+ logger?: boolean;
6
+ dryRun?: boolean;
7
+ throwOnError?: boolean;
8
+ }
9
+ export interface ExecSyncOptions extends SyncOptions {
10
+ abbrev?: boolean;
11
+ logger?: boolean;
12
+ dryRun?: boolean;
13
+ throwOnError?: boolean;
14
+ }
15
+ export type ExecResult = Result;
16
+ export type ExecSyncResult = SyncResult;
17
+ export type ExecResultPromise = ResultPromise;
18
+ /**
19
+ * Execute a command asynchronously
20
+ * @param {string} cmd
21
+ * @param {string[]} args
22
+ * @param {import("execa").Options} [opts]
23
+ */
24
+ export declare function exec(cmd: string, args: string[], opts?: ExecOptions): Promise<any>;
25
+ /**
26
+ * Execute a command synchronously
27
+ * @param {string} cmd
28
+ * @param {string[]} args
29
+ * @param {import("execa").SyncOptions} [opts]
30
+ */
31
+ export declare function execSync(cmd: string, args: string[], opts?: ExecSyncOptions): string | SyncResult<ExecSyncOptions> | unknown[] | Uint8Array<ArrayBufferLike> | undefined;
32
+ /**
33
+ * Execute a command asynchronously (string)
34
+ * @param cmd
35
+ * @param opts
36
+ */
37
+ export declare function execCommand(cmd: string, opts?: ExecOptions): Promise<string | unknown[] | Uint8Array<ArrayBufferLike> | Result<ExecOptions> | undefined>;
38
+ /**
39
+ * Execute a command synchronously (string)
40
+ * @param cmd
41
+ * @param opts
42
+ */
43
+ export declare function execCommandSync(cmd: string, opts?: ExecSyncOptions): string | SyncResult<ExecSyncOptions> | unknown[] | Uint8Array<ArrayBufferLike> | undefined;
44
+ //#endregion
@@ -0,0 +1,44 @@
1
+ import { Options, Result, ResultPromise, SyncOptions, SyncResult } from "execa";
2
+ //#region src/child_process.d.ts
3
+ export interface ExecOptions extends Options {
4
+ abbrev?: boolean;
5
+ logger?: boolean;
6
+ dryRun?: boolean;
7
+ throwOnError?: boolean;
8
+ }
9
+ export interface ExecSyncOptions extends SyncOptions {
10
+ abbrev?: boolean;
11
+ logger?: boolean;
12
+ dryRun?: boolean;
13
+ throwOnError?: boolean;
14
+ }
15
+ export type ExecResult = Result;
16
+ export type ExecSyncResult = SyncResult;
17
+ export type ExecResultPromise = ResultPromise;
18
+ /**
19
+ * Execute a command asynchronously
20
+ * @param {string} cmd
21
+ * @param {string[]} args
22
+ * @param {import("execa").Options} [opts]
23
+ */
24
+ export declare function exec(cmd: string, args: string[], opts?: ExecOptions): Promise<any>;
25
+ /**
26
+ * Execute a command synchronously
27
+ * @param {string} cmd
28
+ * @param {string[]} args
29
+ * @param {import("execa").SyncOptions} [opts]
30
+ */
31
+ export declare function execSync(cmd: string, args: string[], opts?: ExecSyncOptions): string | SyncResult<ExecSyncOptions> | unknown[] | Uint8Array<ArrayBufferLike> | undefined;
32
+ /**
33
+ * Execute a command asynchronously (string)
34
+ * @param cmd
35
+ * @param opts
36
+ */
37
+ export declare function execCommand(cmd: string, opts?: ExecOptions): Promise<string | unknown[] | Uint8Array<ArrayBufferLike> | Result<ExecOptions> | undefined>;
38
+ /**
39
+ * Execute a command synchronously (string)
40
+ * @param cmd
41
+ * @param opts
42
+ */
43
+ export declare function execCommandSync(cmd: string, opts?: ExecSyncOptions): string | SyncResult<ExecSyncOptions> | unknown[] | Uint8Array<ArrayBufferLike> | undefined;
44
+ //#endregion
@@ -1,79 +1,81 @@
1
- import { execa, execaSync, execaCommand, execaCommandSync } from 'execa';
2
- import c from 'ansis';
3
-
1
+ import { execa, execaCommand, execaCommandSync, execaSync } from "execa";
2
+ import c from "ansis";
3
+ //#region src/child_process.ts
4
+ /**
5
+ * Execute a command asynchronously
6
+ * @param {string} cmd
7
+ * @param {string[]} args
8
+ * @param {import("execa").Options} [opts]
9
+ */
4
10
  function exec(cmd, args, opts) {
5
- opts = {
6
- throwOnError: true,
7
- ...opts
8
- };
9
- if (opts.logger || opts.dryRun)
10
- console.log(c.green(`> ${[cmd, ...args].join(" ")}`));
11
- if (opts.dryRun)
12
- return Promise.resolve(void 0);
13
- return execa(cmd, args, opts).then((spawned) => opts.abbrev ? spawned.stdout : spawned).catch((e) => {
14
- if (opts.throwOnError)
15
- throw new Error(
16
- c.red(`Running ${c.bold([cmd, ...args].join(" "))} in ${c.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
17
- );
18
- return Promise.resolve(void 0);
19
- });
11
+ opts = {
12
+ throwOnError: true,
13
+ ...opts
14
+ };
15
+ if (opts.logger || opts.dryRun) console.log(c.green(`> ${[cmd, ...args].join(" ")}`));
16
+ if (opts.dryRun) return Promise.resolve(void 0);
17
+ return execa(cmd, args, opts).then((spawned) => opts.abbrev ? spawned.stdout : spawned).catch((e) => {
18
+ if (opts.throwOnError) throw new Error(c.red(`Running ${c.bold([cmd, ...args].join(" "))} in ${c.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message));
19
+ return Promise.resolve(void 0);
20
+ });
20
21
  }
22
+ /**
23
+ * Execute a command synchronously
24
+ * @param {string} cmd
25
+ * @param {string[]} args
26
+ * @param {import("execa").SyncOptions} [opts]
27
+ */
21
28
  function execSync(cmd, args, opts) {
22
- opts = {
23
- throwOnError: true,
24
- ...opts
25
- };
26
- if (opts.logger || opts.dryRun)
27
- console.log(c.green(`> ${[cmd, ...args].join(" ")}`));
28
- if (opts.dryRun)
29
- return void 0;
30
- try {
31
- const spawned = execaSync(cmd, args, opts);
32
- return opts.abbrev ? spawned.stdout : spawned;
33
- } catch (e) {
34
- if (opts?.throwOnError)
35
- throw new Error(
36
- c.red(`Running ${c.bold([cmd, ...args].join(" "))} in ${c.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
37
- );
38
- return void 0;
39
- }
29
+ opts = {
30
+ throwOnError: true,
31
+ ...opts
32
+ };
33
+ if (opts.logger || opts.dryRun) console.log(c.green(`> ${[cmd, ...args].join(" ")}`));
34
+ if (opts.dryRun) return void 0;
35
+ try {
36
+ const spawned = execaSync(cmd, args, opts);
37
+ return opts.abbrev ? spawned.stdout : spawned;
38
+ } catch (e) {
39
+ if (opts?.throwOnError) throw new Error(c.red(`Running ${c.bold([cmd, ...args].join(" "))} in ${c.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message));
40
+ return;
41
+ }
40
42
  }
43
+ /**
44
+ * Execute a command asynchronously (string)
45
+ * @param cmd
46
+ * @param opts
47
+ */
41
48
  function execCommand(cmd, opts) {
42
- opts = {
43
- throwOnError: true,
44
- ...opts
45
- };
46
- if (opts.logger || opts.dryRun)
47
- console.log(c.green(`> ${[cmd].join(" ")}`));
48
- if (opts.dryRun)
49
- return Promise.resolve(void 0);
50
- return execaCommand(cmd, opts).then((spawned) => opts.abbrev ? spawned.stdout : spawned).catch((e) => {
51
- if (opts.throwOnError)
52
- throw new Error(
53
- c.red(`Running ${c.bold([cmd].join(" "))} in ${c.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
54
- );
55
- return Promise.resolve(void 0);
56
- });
49
+ opts = {
50
+ throwOnError: true,
51
+ ...opts
52
+ };
53
+ if (opts.logger || opts.dryRun) console.log(c.green(`> ${[cmd].join(" ")}`));
54
+ if (opts.dryRun) return Promise.resolve(void 0);
55
+ return execaCommand(cmd, opts).then((spawned) => opts.abbrev ? spawned.stdout : spawned).catch((e) => {
56
+ if (opts.throwOnError) throw new Error(c.red(`Running ${c.bold([cmd].join(" "))} in ${c.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message));
57
+ return Promise.resolve(void 0);
58
+ });
57
59
  }
60
+ /**
61
+ * Execute a command synchronously (string)
62
+ * @param cmd
63
+ * @param opts
64
+ */
58
65
  function execCommandSync(cmd, opts) {
59
- opts = {
60
- throwOnError: true,
61
- ...opts
62
- };
63
- if (opts.logger || opts.dryRun)
64
- console.log(c.green(`> ${[cmd].join(" ")}`));
65
- if (opts.dryRun)
66
- return void 0;
67
- try {
68
- const spawned = execaCommandSync(cmd, opts);
69
- return opts.abbrev ? spawned.stdout : spawned;
70
- } catch (e) {
71
- if (opts.throwOnError)
72
- throw new Error(
73
- c.red(`Running ${c.bold([cmd].join(" "))} in ${c.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
74
- );
75
- return void 0;
76
- }
66
+ opts = {
67
+ throwOnError: true,
68
+ ...opts
69
+ };
70
+ if (opts.logger || opts.dryRun) console.log(c.green(`> ${[cmd].join(" ")}`));
71
+ if (opts.dryRun) return void 0;
72
+ try {
73
+ const spawned = execaCommandSync(cmd, opts);
74
+ return opts.abbrev ? spawned.stdout : spawned;
75
+ } catch (e) {
76
+ if (opts.throwOnError) throw new Error(c.red(`Running ${c.bold([cmd].join(" "))} in ${c.underline(opts.cwd || e.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message));
77
+ return;
78
+ }
77
79
  }
78
-
80
+ //#endregion
79
81
  export { exec, execCommand, execCommandSync, execSync };
package/dist/index.cjs CHANGED
@@ -1,10 +1,6 @@
1
- 'use strict';
2
-
3
- var child_process = require('./child_process.cjs');
4
-
5
-
6
-
7
- exports.exec = child_process.exec;
8
- exports.execCommand = child_process.execCommand;
9
- exports.execCommandSync = child_process.execCommandSync;
10
- exports.execSync = child_process.execSync;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_child_process = require("./child_process.cjs");
3
+ exports.exec = require_child_process.exec;
4
+ exports.execCommand = require_child_process.execCommand;
5
+ exports.execCommandSync = require_child_process.execCommandSync;
6
+ exports.execSync = require_child_process.execSync;
@@ -0,0 +1,2 @@
1
+ import { ExecOptions, ExecResult, ExecResultPromise, ExecSyncOptions, ExecSyncResult, exec, execCommand, execCommandSync, execSync } from "./child_process.cjs";
2
+ export { type ExecOptions, type ExecResult, type ExecResultPromise, type ExecSyncOptions, type ExecSyncResult, exec, execCommand, execCommandSync, execSync };
@@ -0,0 +1,2 @@
1
+ import { ExecOptions, ExecResult, ExecResultPromise, ExecSyncOptions, ExecSyncResult, exec, execCommand, execCommandSync, execSync } from "./child_process.mjs";
2
+ export { type ExecOptions, type ExecResult, type ExecResultPromise, type ExecSyncOptions, type ExecSyncResult, exec, execCommand, execCommandSync, execSync };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export { exec, execCommand, execCommandSync, execSync } from './child_process.mjs';
1
+ export { exec, execCommand, execCommandSync, execSync } from "./child_process.mjs";
package/package.json CHANGED
@@ -1,54 +1,62 @@
1
1
  {
2
2
  "name": "@elinzy/core",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "e core implementation module",
5
- "type": "module",
6
- "main": "./dist/index.cjs",
7
- "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.cjs"
13
- },
14
- "./child_process": {
15
- "types": "./dist/child_process.d.ts",
16
- "import": "./dist/child_process.mjs",
17
- "require": "./dist/child_process.cjs"
18
- }
19
- },
20
- "publishConfig": {
21
- "access": "public",
22
- "registry": "https://registry.npmjs.org/"
5
+ "homepage": "https://github.com/Appleec/e#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/Appleec/e/issues"
23
8
  },
24
- "files": [
25
- "dist"
26
- ],
9
+ "license": "MIT",
10
+ "author": "Appleec <771992522@qq.com>",
27
11
  "repository": {
28
12
  "type": "git",
29
13
  "url": "git+https://github.com/Appleec/e.git",
30
14
  "directory": "packages/core"
31
15
  },
16
+ "publishConfig": {
17
+ "access": "public",
18
+ "registry": "https://registry.npmjs.org/"
19
+ },
32
20
  "keywords": [
33
21
  "e",
34
22
  "core"
35
23
  ],
36
- "author": "Appleec <771992522@qq.com>",
37
- "license": "MIT",
38
- "bugs": {
39
- "url": "https://github.com/Appleec/e/issues"
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "type": "module",
28
+ "sideEffects": false,
29
+ "main": "./dist/index.cjs",
30
+ "types": "./dist/index.d.cts",
31
+ "module": "./dist/index.mjs",
32
+ "exports": {
33
+ ".": {
34
+ "import": "./dist/index.mjs",
35
+ "require": "./dist/index.cjs"
36
+ },
37
+ "./child_process": {
38
+ "import": "./dist/child_process.mjs",
39
+ "require": "./dist/child_process.cjs"
40
+ },
41
+ "./package.json": "./package.json"
40
42
  },
41
- "homepage": "https://github.com/Appleec/e#readme",
42
43
  "dependencies": {
43
- "ansis": "^3.17.0",
44
+ "ansis": "4.2.0",
44
45
  "execa": "^9.5.2"
45
46
  },
47
+ "devDependencies": {
48
+ "tsdown": "^0.23.1"
49
+ },
50
+ "engines": {
51
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0",
52
+ "npm": "please-use-pnpm",
53
+ "pnpm": ">=10.0.0",
54
+ "yarn": "please-use-pnpm"
55
+ },
46
56
  "scripts": {
47
- "dev": "rollup --config rollup.config.mjs --watch",
48
- "build": "npm-run-all --parallel build:clean build:main build:type",
49
- "build:main": "rollup --config rollup.config.mjs",
50
- "build:type": "tsc --project tsconfig.build.json --emitDeclarationOnly --preserveWatchOutput",
51
- "build:clean": "rimraf ./dist",
57
+ "dev": "tsdown --watch",
58
+ "build": "tsdown",
59
+ "typecheck": "tsc --noEmit",
52
60
  "test": "echo \"Error: no test specified\" && exit 1"
53
61
  }
54
62
  }
@@ -1,39 +0,0 @@
1
- import { type Options as ExecaOptions, type SyncOptions as ExecaSyncOptions } from 'execa';
2
- export interface ExecOptions extends ExecaOptions {
3
- abbrev?: boolean;
4
- logger?: boolean;
5
- dryRun?: boolean;
6
- throwOnError?: boolean;
7
- }
8
- export interface ExecSyncOptions extends ExecaSyncOptions {
9
- abbrev?: boolean;
10
- logger?: boolean;
11
- dryRun?: boolean;
12
- throwOnError?: boolean;
13
- }
14
- /**
15
- * Execute a command asynchronously
16
- * @param {string} cmd
17
- * @param {string[]} args
18
- * @param {import("execa").Options} [opts]
19
- */
20
- export declare function exec(cmd: string, args: string[], opts?: ExecOptions): Promise<any>;
21
- /**
22
- * Execute a command synchronously
23
- * @param {string} cmd
24
- * @param {string[]} args
25
- * @param {import("execa").SyncOptions} [opts]
26
- */
27
- export declare function execSync(cmd: string, args: string[], opts?: ExecSyncOptions): string | unknown[] | Uint8Array<ArrayBufferLike> | import("execa").SyncResult<ExecSyncOptions> | undefined;
28
- /**
29
- * Execute a command asynchronously (string)
30
- * @param cmd
31
- * @param opts
32
- */
33
- export declare function execCommand(cmd: string, opts?: ExecOptions): Promise<string | unknown[] | import("execa").Result<ExecOptions> | Uint8Array<ArrayBufferLike> | undefined>;
34
- /**
35
- * Execute a command synchronously (string)
36
- * @param cmd
37
- * @param opts
38
- */
39
- export declare function execCommandSync(cmd: string, opts?: ExecSyncOptions): string | unknown[] | Uint8Array<ArrayBufferLike> | import("execa").SyncResult<ExecSyncOptions> | undefined;
package/dist/index.d.ts DELETED
@@ -1,22 +0,0 @@
1
- import * as execa from 'execa';
2
- import { Options, SyncOptions } from 'execa';
3
-
4
- interface ExecOptions extends Options {
5
- abbrev?: boolean;
6
- logger?: boolean;
7
- dryRun?: boolean;
8
- throwOnError?: boolean;
9
- }
10
- interface ExecSyncOptions extends SyncOptions {
11
- abbrev?: boolean;
12
- logger?: boolean;
13
- dryRun?: boolean;
14
- throwOnError?: boolean;
15
- }
16
- declare function exec(cmd: string, args: string[], opts?: ExecOptions): Promise<any>;
17
- declare function execSync(cmd: string, args: string[], opts?: ExecSyncOptions): string | execa.SyncResult<ExecSyncOptions> | unknown[] | Uint8Array<ArrayBufferLike> | undefined;
18
- declare function execCommand(cmd: string, opts?: ExecOptions): Promise<string | unknown[] | Uint8Array<ArrayBufferLike> | execa.Result<ExecOptions> | undefined>;
19
- declare function execCommandSync(cmd: string, opts?: ExecSyncOptions): string | execa.SyncResult<ExecSyncOptions> | unknown[] | Uint8Array<ArrayBufferLike> | undefined;
20
-
21
- export { exec, execCommand, execCommandSync, execSync };
22
- export type { ExecOptions, ExecSyncOptions };