@mokup/cli 0.0.1 → 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 +3 -1
- package/README.zh-CN.md +2 -1
- package/dist/index.cjs +722 -11
- package/dist/index.mjs +724 -10
- package/package.json +2 -5
- package/dist/cli.cjs +0 -118
- package/dist/cli.d.cts +0 -1
- package/dist/cli.d.mts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.mjs +0 -116
- package/dist/shared/cli.D0D0o7Rg.mjs +0 -714
- package/dist/shared/cli.yAHcdIVy.cjs +0 -717
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mokup/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"description": "CLI for building mokup manifests and handlers.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://mokup.icebreaker.top",
|
|
@@ -20,9 +20,6 @@
|
|
|
20
20
|
"main": "./dist/index.cjs",
|
|
21
21
|
"module": "./dist/index.mjs",
|
|
22
22
|
"types": "./dist/index.d.ts",
|
|
23
|
-
"bin": {
|
|
24
|
-
"mokup": "./dist/cli.mjs"
|
|
25
|
-
},
|
|
26
23
|
"publishConfig": {
|
|
27
24
|
"access": "public"
|
|
28
25
|
},
|
|
@@ -33,7 +30,7 @@
|
|
|
33
30
|
"esbuild": "^0.27.2",
|
|
34
31
|
"jsonc-parser": "^3.3.1",
|
|
35
32
|
"pathe": "^2.0.3",
|
|
36
|
-
"@mokup/runtime": "0.0
|
|
33
|
+
"@mokup/runtime": "0.1.0"
|
|
37
34
|
},
|
|
38
35
|
"devDependencies": {
|
|
39
36
|
"@types/node": "^25.0.9",
|
package/dist/cli.cjs
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
const node_process = require('node:process');
|
|
5
|
-
const index = require('./shared/cli.yAHcdIVy.cjs');
|
|
6
|
-
require('node:fs');
|
|
7
|
-
require('pathe');
|
|
8
|
-
require('node:buffer');
|
|
9
|
-
require('node:module');
|
|
10
|
-
require('node:url');
|
|
11
|
-
require('esbuild');
|
|
12
|
-
require('@mokup/runtime');
|
|
13
|
-
require('jsonc-parser');
|
|
14
|
-
|
|
15
|
-
function parseBuildOptions(argv2) {
|
|
16
|
-
const dirs = [];
|
|
17
|
-
const includes = [];
|
|
18
|
-
const excludes = [];
|
|
19
|
-
let outDir;
|
|
20
|
-
let prefix;
|
|
21
|
-
let handlers = true;
|
|
22
|
-
for (let i = 0; i < argv2.length; i += 1) {
|
|
23
|
-
const arg = argv2[i];
|
|
24
|
-
if (arg === "--dir" || arg === "-d") {
|
|
25
|
-
const value = argv2[i + 1];
|
|
26
|
-
if (value) {
|
|
27
|
-
dirs.push(value);
|
|
28
|
-
i += 1;
|
|
29
|
-
}
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (arg === "--out" || arg === "-o") {
|
|
33
|
-
const value = argv2[i + 1];
|
|
34
|
-
if (value) {
|
|
35
|
-
outDir = value;
|
|
36
|
-
i += 1;
|
|
37
|
-
}
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
if (arg === "--prefix") {
|
|
41
|
-
const value = argv2[i + 1];
|
|
42
|
-
if (value) {
|
|
43
|
-
prefix = value;
|
|
44
|
-
i += 1;
|
|
45
|
-
}
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
if (arg === "--include") {
|
|
49
|
-
const value = argv2[i + 1];
|
|
50
|
-
if (value) {
|
|
51
|
-
includes.push(new RegExp(value));
|
|
52
|
-
i += 1;
|
|
53
|
-
}
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
if (arg === "--exclude") {
|
|
57
|
-
const value = argv2[i + 1];
|
|
58
|
-
if (value) {
|
|
59
|
-
excludes.push(new RegExp(value));
|
|
60
|
-
i += 1;
|
|
61
|
-
}
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
if (arg === "--no-handlers") {
|
|
65
|
-
handlers = false;
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
const options2 = {
|
|
70
|
-
handlers,
|
|
71
|
-
log: (message) => console.log(message)
|
|
72
|
-
};
|
|
73
|
-
if (dirs.length > 0) {
|
|
74
|
-
options2.dir = dirs;
|
|
75
|
-
}
|
|
76
|
-
if (outDir) {
|
|
77
|
-
options2.outDir = outDir;
|
|
78
|
-
}
|
|
79
|
-
if (prefix) {
|
|
80
|
-
options2.prefix = prefix;
|
|
81
|
-
}
|
|
82
|
-
if (includes.length > 0) {
|
|
83
|
-
options2.include = includes;
|
|
84
|
-
}
|
|
85
|
-
if (excludes.length > 0) {
|
|
86
|
-
options2.exclude = excludes;
|
|
87
|
-
}
|
|
88
|
-
return options2;
|
|
89
|
-
}
|
|
90
|
-
function printHelp() {
|
|
91
|
-
console.log(
|
|
92
|
-
`mokup build [options]
|
|
93
|
-
|
|
94
|
-
Options:
|
|
95
|
-
--dir, -d Mock directory (repeatable)
|
|
96
|
-
--out, -o Output directory (default: .mokup)
|
|
97
|
-
--prefix URL prefix
|
|
98
|
-
--include Include regex (repeatable)
|
|
99
|
-
--exclude Exclude regex (repeatable)
|
|
100
|
-
--no-handlers Skip function handler output`
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
const args = node_process.argv.slice(2);
|
|
104
|
-
const command = args[0];
|
|
105
|
-
if (!command || command === "help" || command === "--help" || command === "-h") {
|
|
106
|
-
printHelp();
|
|
107
|
-
node_process.exit(0);
|
|
108
|
-
}
|
|
109
|
-
if (command !== "build") {
|
|
110
|
-
console.error(`Unknown command: ${command}`);
|
|
111
|
-
printHelp();
|
|
112
|
-
node_process.exit(1);
|
|
113
|
-
}
|
|
114
|
-
const options = parseBuildOptions(args.slice(1));
|
|
115
|
-
index.buildManifest(options).catch((error) => {
|
|
116
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
117
|
-
node_process.exit(1);
|
|
118
|
-
});
|
package/dist/cli.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/dist/cli.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/dist/cli.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/dist/cli.mjs
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { argv, exit } from 'node:process';
|
|
3
|
-
import { b as buildManifest } from './shared/cli.D0D0o7Rg.mjs';
|
|
4
|
-
import 'node:fs';
|
|
5
|
-
import 'pathe';
|
|
6
|
-
import 'node:buffer';
|
|
7
|
-
import 'node:module';
|
|
8
|
-
import 'node:url';
|
|
9
|
-
import 'esbuild';
|
|
10
|
-
import '@mokup/runtime';
|
|
11
|
-
import 'jsonc-parser';
|
|
12
|
-
|
|
13
|
-
function parseBuildOptions(argv2) {
|
|
14
|
-
const dirs = [];
|
|
15
|
-
const includes = [];
|
|
16
|
-
const excludes = [];
|
|
17
|
-
let outDir;
|
|
18
|
-
let prefix;
|
|
19
|
-
let handlers = true;
|
|
20
|
-
for (let i = 0; i < argv2.length; i += 1) {
|
|
21
|
-
const arg = argv2[i];
|
|
22
|
-
if (arg === "--dir" || arg === "-d") {
|
|
23
|
-
const value = argv2[i + 1];
|
|
24
|
-
if (value) {
|
|
25
|
-
dirs.push(value);
|
|
26
|
-
i += 1;
|
|
27
|
-
}
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (arg === "--out" || arg === "-o") {
|
|
31
|
-
const value = argv2[i + 1];
|
|
32
|
-
if (value) {
|
|
33
|
-
outDir = value;
|
|
34
|
-
i += 1;
|
|
35
|
-
}
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
if (arg === "--prefix") {
|
|
39
|
-
const value = argv2[i + 1];
|
|
40
|
-
if (value) {
|
|
41
|
-
prefix = value;
|
|
42
|
-
i += 1;
|
|
43
|
-
}
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
if (arg === "--include") {
|
|
47
|
-
const value = argv2[i + 1];
|
|
48
|
-
if (value) {
|
|
49
|
-
includes.push(new RegExp(value));
|
|
50
|
-
i += 1;
|
|
51
|
-
}
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
if (arg === "--exclude") {
|
|
55
|
-
const value = argv2[i + 1];
|
|
56
|
-
if (value) {
|
|
57
|
-
excludes.push(new RegExp(value));
|
|
58
|
-
i += 1;
|
|
59
|
-
}
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (arg === "--no-handlers") {
|
|
63
|
-
handlers = false;
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
const options2 = {
|
|
68
|
-
handlers,
|
|
69
|
-
log: (message) => console.log(message)
|
|
70
|
-
};
|
|
71
|
-
if (dirs.length > 0) {
|
|
72
|
-
options2.dir = dirs;
|
|
73
|
-
}
|
|
74
|
-
if (outDir) {
|
|
75
|
-
options2.outDir = outDir;
|
|
76
|
-
}
|
|
77
|
-
if (prefix) {
|
|
78
|
-
options2.prefix = prefix;
|
|
79
|
-
}
|
|
80
|
-
if (includes.length > 0) {
|
|
81
|
-
options2.include = includes;
|
|
82
|
-
}
|
|
83
|
-
if (excludes.length > 0) {
|
|
84
|
-
options2.exclude = excludes;
|
|
85
|
-
}
|
|
86
|
-
return options2;
|
|
87
|
-
}
|
|
88
|
-
function printHelp() {
|
|
89
|
-
console.log(
|
|
90
|
-
`mokup build [options]
|
|
91
|
-
|
|
92
|
-
Options:
|
|
93
|
-
--dir, -d Mock directory (repeatable)
|
|
94
|
-
--out, -o Output directory (default: .mokup)
|
|
95
|
-
--prefix URL prefix
|
|
96
|
-
--include Include regex (repeatable)
|
|
97
|
-
--exclude Exclude regex (repeatable)
|
|
98
|
-
--no-handlers Skip function handler output`
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
const args = argv.slice(2);
|
|
102
|
-
const command = args[0];
|
|
103
|
-
if (!command || command === "help" || command === "--help" || command === "-h") {
|
|
104
|
-
printHelp();
|
|
105
|
-
exit(0);
|
|
106
|
-
}
|
|
107
|
-
if (command !== "build") {
|
|
108
|
-
console.error(`Unknown command: ${command}`);
|
|
109
|
-
printHelp();
|
|
110
|
-
exit(1);
|
|
111
|
-
}
|
|
112
|
-
const options = parseBuildOptions(args.slice(1));
|
|
113
|
-
buildManifest(options).catch((error) => {
|
|
114
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
115
|
-
exit(1);
|
|
116
|
-
});
|