@elinzy/core 0.1.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/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/child_process.cjs +68 -0
- package/dist/child_process.d.ts +39 -0
- package/dist/child_process.mjs +63 -0
- package/dist/index.cjs +10 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.mjs +1 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Appleex
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## @elinzy/e-core
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var execa = require('execa');
|
|
4
|
+
var c = require('ansis');
|
|
5
|
+
|
|
6
|
+
function exec(cmd, args, opts) {
|
|
7
|
+
if (opts?.logger || opts?.dryRun)
|
|
8
|
+
console.log(c.green(`> ${[cmd, ...args].join(" ")}`));
|
|
9
|
+
if (opts?.dryRun)
|
|
10
|
+
return Promise.resolve(void 0);
|
|
11
|
+
return execa.execa(cmd, args, opts).then((spawned) => opts?.abbrev ? spawned?.stdout : spawned).catch((e) => {
|
|
12
|
+
if (opts?.throwOnError ?? true)
|
|
13
|
+
throw new Error(
|
|
14
|
+
c.red(`Running ${c.bold([cmd, ...args].join(" "))} in ${c.underline(opts?.cwd || e?.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
|
|
15
|
+
);
|
|
16
|
+
return Promise.resolve(void 0);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function execSync(cmd, args, opts) {
|
|
20
|
+
if (opts?.logger || opts?.dryRun)
|
|
21
|
+
console.log(c.green(`> ${[cmd, ...args].join(" ")}`));
|
|
22
|
+
if (opts?.dryRun)
|
|
23
|
+
return void 0;
|
|
24
|
+
try {
|
|
25
|
+
const spawned = execa.execaSync(cmd, args, opts);
|
|
26
|
+
return opts?.abbrev ? spawned?.stdout : spawned;
|
|
27
|
+
} catch (e) {
|
|
28
|
+
if (opts?.throwOnError ?? true)
|
|
29
|
+
throw new Error(
|
|
30
|
+
c.red(`Running ${c.bold([cmd, ...args].join(" "))} in ${c.underline(opts?.cwd || e?.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
|
|
31
|
+
);
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function execCommand(cmd, opts) {
|
|
36
|
+
if (opts?.logger || opts?.dryRun)
|
|
37
|
+
console.log(c.green(`> ${[cmd].join(" ")}`));
|
|
38
|
+
if (opts?.dryRun)
|
|
39
|
+
return Promise.resolve(void 0);
|
|
40
|
+
return execa.execaCommand(cmd, opts).then((spawned) => opts?.abbrev ? spawned?.stdout : spawned).catch((e) => {
|
|
41
|
+
if (opts?.throwOnError ?? true)
|
|
42
|
+
throw new Error(
|
|
43
|
+
c.red(`Running ${c.bold([cmd].join(" "))} in ${c.underline(opts?.cwd || e?.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
|
|
44
|
+
);
|
|
45
|
+
return Promise.resolve(void 0);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function execCommandSync(cmd, opts) {
|
|
49
|
+
if (opts?.logger || opts?.dryRun)
|
|
50
|
+
console.log(c.green(`> ${[cmd].join(" ")}`));
|
|
51
|
+
if (opts?.dryRun)
|
|
52
|
+
return void 0;
|
|
53
|
+
try {
|
|
54
|
+
const spawned = execa.execaCommandSync(cmd, opts);
|
|
55
|
+
return opts?.abbrev ? spawned?.stdout : spawned;
|
|
56
|
+
} catch (e) {
|
|
57
|
+
if (opts?.throwOnError ?? true)
|
|
58
|
+
throw new Error(
|
|
59
|
+
c.red(`Running ${c.bold([cmd].join(" "))} in ${c.underline(opts?.cwd || e?.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
|
|
60
|
+
);
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
exports.exec = exec;
|
|
66
|
+
exports.execCommand = execCommand;
|
|
67
|
+
exports.execCommandSync = execCommandSync;
|
|
68
|
+
exports.execSync = execSync;
|
|
@@ -0,0 +1,39 @@
|
|
|
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;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { execa, execaSync, execaCommand, execaCommandSync } from 'execa';
|
|
2
|
+
import c from 'ansis';
|
|
3
|
+
|
|
4
|
+
function exec(cmd, args, opts) {
|
|
5
|
+
if (opts?.logger || opts?.dryRun)
|
|
6
|
+
console.log(c.green(`> ${[cmd, ...args].join(" ")}`));
|
|
7
|
+
if (opts?.dryRun)
|
|
8
|
+
return Promise.resolve(void 0);
|
|
9
|
+
return execa(cmd, args, opts).then((spawned) => opts?.abbrev ? spawned?.stdout : spawned).catch((e) => {
|
|
10
|
+
if (opts?.throwOnError ?? true)
|
|
11
|
+
throw new Error(
|
|
12
|
+
c.red(`Running ${c.bold([cmd, ...args].join(" "))} in ${c.underline(opts?.cwd || e?.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
|
|
13
|
+
);
|
|
14
|
+
return Promise.resolve(void 0);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function execSync(cmd, args, opts) {
|
|
18
|
+
if (opts?.logger || opts?.dryRun)
|
|
19
|
+
console.log(c.green(`> ${[cmd, ...args].join(" ")}`));
|
|
20
|
+
if (opts?.dryRun)
|
|
21
|
+
return void 0;
|
|
22
|
+
try {
|
|
23
|
+
const spawned = execaSync(cmd, args, opts);
|
|
24
|
+
return opts?.abbrev ? spawned?.stdout : spawned;
|
|
25
|
+
} catch (e) {
|
|
26
|
+
if (opts?.throwOnError ?? true)
|
|
27
|
+
throw new Error(
|
|
28
|
+
c.red(`Running ${c.bold([cmd, ...args].join(" "))} in ${c.underline(opts?.cwd || e?.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
|
|
29
|
+
);
|
|
30
|
+
return void 0;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function execCommand(cmd, opts) {
|
|
34
|
+
if (opts?.logger || opts?.dryRun)
|
|
35
|
+
console.log(c.green(`> ${[cmd].join(" ")}`));
|
|
36
|
+
if (opts?.dryRun)
|
|
37
|
+
return Promise.resolve(void 0);
|
|
38
|
+
return execaCommand(cmd, opts).then((spawned) => opts?.abbrev ? spawned?.stdout : spawned).catch((e) => {
|
|
39
|
+
if (opts?.throwOnError ?? true)
|
|
40
|
+
throw new Error(
|
|
41
|
+
c.red(`Running ${c.bold([cmd].join(" "))} in ${c.underline(opts?.cwd || e?.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
|
|
42
|
+
);
|
|
43
|
+
return Promise.resolve(void 0);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function execCommandSync(cmd, opts) {
|
|
47
|
+
if (opts?.logger || opts?.dryRun)
|
|
48
|
+
console.log(c.green(`> ${[cmd].join(" ")}`));
|
|
49
|
+
if (opts?.dryRun)
|
|
50
|
+
return void 0;
|
|
51
|
+
try {
|
|
52
|
+
const spawned = execaCommandSync(cmd, opts);
|
|
53
|
+
return opts?.abbrev ? spawned?.stdout : spawned;
|
|
54
|
+
} catch (e) {
|
|
55
|
+
if (opts?.throwOnError ?? true)
|
|
56
|
+
throw new Error(
|
|
57
|
+
c.red(`Running ${c.bold([cmd].join(" "))} in ${c.underline(opts?.cwd || e?.cwd || process.cwd())}:`) + (e.stderr || e.stack || e.message)
|
|
58
|
+
);
|
|
59
|
+
return void 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { exec, execCommand, execCommandSync, execSync };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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 };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { exec, execCommand, execCommandSync, execSync } from './child_process.mjs';
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@elinzy/core",
|
|
3
|
+
"version": "0.1.0",
|
|
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/"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/Appleec/e.git",
|
|
30
|
+
"directory": "packages/e-core"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"e",
|
|
34
|
+
"core",
|
|
35
|
+
"e-core"
|
|
36
|
+
],
|
|
37
|
+
"author": "Appleec <771992522@qq.com>",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/Appleec/e/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/Appleec/e#readme",
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@babel/core": "7.26.10",
|
|
45
|
+
"@babel/preset-env": "7.26.9",
|
|
46
|
+
"@babel/preset-typescript": "7.26.0",
|
|
47
|
+
"@rollup/plugin-babel": "6.0.4",
|
|
48
|
+
"@rollup/plugin-node-resolve": "16.0.1",
|
|
49
|
+
"rollup": "4.35.0",
|
|
50
|
+
"rollup-plugin-dts": "6.1.1",
|
|
51
|
+
"rollup-plugin-esbuild": "6.2.1",
|
|
52
|
+
"rollup-plugin-node-externals": "8.0.0",
|
|
53
|
+
"tslib": "2.8.1",
|
|
54
|
+
"typescript": "^5.8.2"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"ansis": "^3.17.0",
|
|
58
|
+
"execa": "^9.5.2",
|
|
59
|
+
"@elinzy/logger": "1.0.0"
|
|
60
|
+
},
|
|
61
|
+
"scripts": {
|
|
62
|
+
"dev": "rollup --config rollup.config.mjs --watch",
|
|
63
|
+
"build": "npm-run-all --parallel build:clean build:main build:type",
|
|
64
|
+
"build:main": "rollup --config rollup.config.mjs",
|
|
65
|
+
"build:type": "tsc --project tsconfig.build.json --emitDeclarationOnly --preserveWatchOutput",
|
|
66
|
+
"build:clean": "rimraf ./dist",
|
|
67
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
68
|
+
}
|
|
69
|
+
}
|