esmate 0.0.20 โ 1.0.1
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 +83 -0
- package/dist/commands/fmt.d.ts +11 -0
- package/dist/commands/fmt.js +36 -0
- package/dist/commands/lint.d.ts +11 -0
- package/dist/commands/lint.js +35 -0
- package/dist/commands/task.d.ts +7 -0
- package/dist/commands/task.js +30 -0
- package/dist/exports/eslint.d.ts +1 -0
- package/dist/exports/eslint.js +1 -0
- package/dist/exports/prettier.d.ts +1 -0
- package/dist/exports/prettier.js +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +20 -0
- package/dist/pkg.d.ts +8 -0
- package/dist/pkg.js +13 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +37 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1 +1,84 @@
|
|
|
1
1
|
# esmate
|
|
2
|
+
|
|
3
|
+
`esmate` is a lightweight CLI tool designed to simplify common JavaScript/TypeScript project tasks like formatting,
|
|
4
|
+
linting, and running custom task sequences.
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
- ๐งน Lint with ESLint
|
|
9
|
+
- ๐ง Format code with Prettier
|
|
10
|
+
- ๐ ๏ธ Define and run custom task sequences (series and parallel)
|
|
11
|
+
- โก Fast and minimal configuration
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### ๐งผ Format Code
|
|
16
|
+
|
|
17
|
+
Run Prettier to check formatting:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
esmate fmt
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Automatically fix formatting issues:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
esmate fmt --fix
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### ๐ Lint Code
|
|
30
|
+
|
|
31
|
+
Run ESLint to check for code issues:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
esmate lint
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Automatically fix linting issues:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
esmate lint --fix
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## ๐ Task Runner
|
|
44
|
+
|
|
45
|
+
Tasks are defined in your `package.json` under a `tasks` field.
|
|
46
|
+
|
|
47
|
+
### โถ๏ธ Series (Sequential Execution)
|
|
48
|
+
|
|
49
|
+
Run tasks in order, one after another.
|
|
50
|
+
|
|
51
|
+
**Syntax 1: Single command string**
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"tasks": {
|
|
56
|
+
"build": "tsc && vite build"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Syntax 2: Array of commands**
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"tasks": {
|
|
66
|
+
"build": ["tsc", "vite build"]
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### ๐ Parallel Execution
|
|
72
|
+
|
|
73
|
+
Run multiple tasks at the same time.
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"tasks": {
|
|
78
|
+
"build": {
|
|
79
|
+
"scripts": "tsc --watch",
|
|
80
|
+
"styles": "sass --watch input.scss output.css"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_citty__ from "citty";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_consola__ from "consola";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__ from "../utils.js";
|
|
4
|
+
const fmt = (0, __WEBPACK_EXTERNAL_MODULE_citty__.defineCommand)({
|
|
5
|
+
meta: {
|
|
6
|
+
name: "fmt",
|
|
7
|
+
description: "Format source files"
|
|
8
|
+
},
|
|
9
|
+
args: {
|
|
10
|
+
check: {
|
|
11
|
+
type: "boolean",
|
|
12
|
+
description: "Check if the source files are formatted"
|
|
13
|
+
},
|
|
14
|
+
files: {
|
|
15
|
+
type: "positional",
|
|
16
|
+
description: "Files, folders, or globs to format",
|
|
17
|
+
required: false
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
async run ({ args }) {
|
|
21
|
+
try {
|
|
22
|
+
const options = [];
|
|
23
|
+
const files = args._;
|
|
24
|
+
if (args.check) options.push("--check");
|
|
25
|
+
else options.push("--write");
|
|
26
|
+
options.push("--cache");
|
|
27
|
+
options.push("--cache-location");
|
|
28
|
+
options.push("'./node_modules/.cache/prettier/.prettier-cache'");
|
|
29
|
+
if (0 === files.length) files.push(".");
|
|
30
|
+
(0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.npx)(`prettier ${options.join(" ")} ${files.join(" ")}`);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
__WEBPACK_EXTERNAL_MODULE_consola__.consola.error(error);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
export { fmt };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_citty__ from "citty";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_consola__ from "consola";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__ from "../utils.js";
|
|
4
|
+
const lint = (0, __WEBPACK_EXTERNAL_MODULE_citty__.defineCommand)({
|
|
5
|
+
meta: {
|
|
6
|
+
name: "lint",
|
|
7
|
+
description: "Lint JavaScript/TypeScript source code"
|
|
8
|
+
},
|
|
9
|
+
args: {
|
|
10
|
+
fix: {
|
|
11
|
+
type: "boolean",
|
|
12
|
+
description: "Fix any linting errors for rules that support it"
|
|
13
|
+
},
|
|
14
|
+
files: {
|
|
15
|
+
type: "positional",
|
|
16
|
+
description: "Files, folders, or globs to lint",
|
|
17
|
+
required: false
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
async run (c) {
|
|
21
|
+
try {
|
|
22
|
+
const options = [];
|
|
23
|
+
const files = c.args._;
|
|
24
|
+
if (c.args.fix) options.push("--fix");
|
|
25
|
+
options.push("--cache");
|
|
26
|
+
options.push("--cache-location");
|
|
27
|
+
options.push("'./node_modules/.cache/eslint/.eslint-cache'");
|
|
28
|
+
if (0 === files.length) files.push(".");
|
|
29
|
+
(0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.npx)(`eslint ${options.join(" ")} ${files.join(" ")}`);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
__WEBPACK_EXTERNAL_MODULE_consola__.consola.error(error);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
export { lint };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_citty__ from "citty";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_consola__ from "consola";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_es_toolkit_82663681__ from "es-toolkit";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__pkg_js_ce8daa14__ from "../pkg.js";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__ from "../utils.js";
|
|
6
|
+
const task_task = (0, __WEBPACK_EXTERNAL_MODULE_citty__.defineCommand)({
|
|
7
|
+
meta: {
|
|
8
|
+
name: "task",
|
|
9
|
+
description: "Run a task defined in the package.json"
|
|
10
|
+
},
|
|
11
|
+
args: {
|
|
12
|
+
task: {
|
|
13
|
+
type: "positional",
|
|
14
|
+
description: "A task to run",
|
|
15
|
+
required: false
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
async run ({ args }) {
|
|
19
|
+
try {
|
|
20
|
+
const task = __WEBPACK_EXTERNAL_MODULE__pkg_js_ce8daa14__.pkg.tasks[args.task];
|
|
21
|
+
if (!task) return void __WEBPACK_EXTERNAL_MODULE_consola__.consola.error(`Task "${args.task}" not found in package.json`);
|
|
22
|
+
const isParallel = (0, __WEBPACK_EXTERNAL_MODULE_es_toolkit_82663681__.isJSONObject)(task);
|
|
23
|
+
if (isParallel) (0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.execParallelly)(task);
|
|
24
|
+
else (0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.execSingly)(task);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
__WEBPACK_EXTERNAL_MODULE_consola__.consola.error(error);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
export { task_task as task };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@esmate/eslint";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@esmate/eslint";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@esmate/prettier";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@esmate/prettier";
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_citty__ from "citty";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__commands_fmt_js_e5e4d2b0__ from "./commands/fmt.js";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__commands_lint_js_e7950167__ from "./commands/lint.js";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE__commands_task_js_1beabf38__ from "./commands/task.js";
|
|
7
|
+
const meta = (()=>{
|
|
8
|
+
const pkgPath = new URL("../package.json", import.meta.url);
|
|
9
|
+
return JSON.parse(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(pkgPath, "utf-8"));
|
|
10
|
+
})();
|
|
11
|
+
const main = (0, __WEBPACK_EXTERNAL_MODULE_citty__.defineCommand)({
|
|
12
|
+
meta,
|
|
13
|
+
subCommands: {
|
|
14
|
+
fmt: __WEBPACK_EXTERNAL_MODULE__commands_fmt_js_e5e4d2b0__.fmt,
|
|
15
|
+
lint: __WEBPACK_EXTERNAL_MODULE__commands_lint_js_e7950167__.lint,
|
|
16
|
+
task: __WEBPACK_EXTERNAL_MODULE__commands_task_js_1beabf38__.task
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
(0, __WEBPACK_EXTERNAL_MODULE_citty__.runMain)(main);
|
|
20
|
+
export { meta };
|
package/dist/pkg.d.ts
ADDED
package/dist/pkg.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_find_up_69e9ea2b__ from "find-up";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__ from "./utils.js";
|
|
3
|
+
class Pkg {
|
|
4
|
+
path;
|
|
5
|
+
tasks;
|
|
6
|
+
constructor(){
|
|
7
|
+
this.path = (0, __WEBPACK_EXTERNAL_MODULE_find_up_69e9ea2b__.findUpSync)("package.json");
|
|
8
|
+
const pkg = (0, __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__.readJsonSync)(this.path);
|
|
9
|
+
this.tasks = pkg.tasks || {};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const pkg_pkg = new Pkg();
|
|
13
|
+
export { pkg_pkg as pkg };
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { JsonValue } from "type-fest";
|
|
2
|
+
export declare function execSingly(command: string | string[]): void;
|
|
3
|
+
export declare function execParallelly(commands: Record<string, string | string[]>): Promise<void>;
|
|
4
|
+
export declare function npx(command: string): void;
|
|
5
|
+
export declare function readJsonSync(filePath: string): JsonValue;
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_concurrently__ from "concurrently";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__ from "node:child_process";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_process_786449bf__ from "node:process";
|
|
5
|
+
function execSingly(command) {
|
|
6
|
+
const { env } = __WEBPACK_EXTERNAL_MODULE_node_process_786449bf__["default"];
|
|
7
|
+
const cmd = Array.isArray(command) ? command.join(" && ") : command;
|
|
8
|
+
(0, __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__.spawnSync)(cmd, {
|
|
9
|
+
shell: true,
|
|
10
|
+
stdio: "inherit",
|
|
11
|
+
env
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
async function execParallelly(commands) {
|
|
15
|
+
const { env } = __WEBPACK_EXTERNAL_MODULE_node_process_786449bf__["default"];
|
|
16
|
+
const concurrentCommands = [];
|
|
17
|
+
for (const [name, command] of Object.entries(commands)){
|
|
18
|
+
const cmd = Array.isArray(command) ? command.join(" && ") : command;
|
|
19
|
+
concurrentCommands.push({
|
|
20
|
+
name,
|
|
21
|
+
command: cmd,
|
|
22
|
+
env
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
await (0, __WEBPACK_EXTERNAL_MODULE_concurrently__["default"])(concurrentCommands, {
|
|
26
|
+
handleInput: true,
|
|
27
|
+
prefixColors: "auto",
|
|
28
|
+
killOthers: "failure"
|
|
29
|
+
}).result.then(()=>{}).catch(()=>{});
|
|
30
|
+
}
|
|
31
|
+
function npx(command) {
|
|
32
|
+
execSingly(`npx --yes ${command}`);
|
|
33
|
+
}
|
|
34
|
+
function readJsonSync(filePath) {
|
|
35
|
+
return JSON.parse(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(filePath, "utf-8"));
|
|
36
|
+
}
|
|
37
|
+
export { execParallelly, execSingly, npx, readJsonSync };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esmate",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"description": "Uncomplicate JavaScript",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"es-toolkit": "^1.35.0",
|
|
29
29
|
"find-up": "^7.0.0",
|
|
30
30
|
"nypm": "^0.6.0",
|
|
31
|
-
"@esmate/eslint": "0.0
|
|
32
|
-
"@esmate/prettier": "0.0
|
|
31
|
+
"@esmate/eslint": "1.0.0",
|
|
32
|
+
"@esmate/prettier": "1.0.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@rslib/core": "^0.7.1",
|