@xyd-js/cli 0.1.0-xyd.37 → 0.1.0-xyd.39
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/package.json +2 -2
- package/dist/build.d.ts +0 -2
- package/dist/build.js +0 -5
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -248
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyd-js/cli",
|
|
3
|
-
"version": "0.1.0-xyd.
|
|
3
|
+
"version": "0.1.0-xyd.39",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": "",
|
|
6
6
|
"description": "",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"vfile": "^6.0.3",
|
|
55
55
|
"vite-tsconfig-paths": "^5.1.4",
|
|
56
56
|
"yaml": "^2.6.0",
|
|
57
|
-
"@xyd-js/documan": "0.1.0-xyd.
|
|
57
|
+
"@xyd-js/documan": "0.1.0-xyd.32",
|
|
58
58
|
"@xyd-js/host": "0.1.0-xyd.2"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
package/dist/build.d.ts
DELETED
package/dist/build.js
DELETED
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
package/dist/index.js
DELETED
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
|
|
28
|
-
// ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
29
|
-
var require_picocolors = __commonJS({
|
|
30
|
-
"../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports, module) {
|
|
31
|
-
"use strict";
|
|
32
|
-
var p = process || {};
|
|
33
|
-
var argv = p.argv || [];
|
|
34
|
-
var env = p.env || {};
|
|
35
|
-
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
36
|
-
var formatter = (open, close, replace = open) => (input) => {
|
|
37
|
-
let string = "" + input, index = string.indexOf(close, open.length);
|
|
38
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
39
|
-
};
|
|
40
|
-
var replaceClose = (string, close, replace, index) => {
|
|
41
|
-
let result = "", cursor = 0;
|
|
42
|
-
do {
|
|
43
|
-
result += string.substring(cursor, index) + replace;
|
|
44
|
-
cursor = index + close.length;
|
|
45
|
-
index = string.indexOf(close, cursor);
|
|
46
|
-
} while (~index);
|
|
47
|
-
return result + string.substring(cursor);
|
|
48
|
-
};
|
|
49
|
-
var createColors = (enabled = isColorSupported) => {
|
|
50
|
-
let f = enabled ? formatter : () => String;
|
|
51
|
-
return {
|
|
52
|
-
isColorSupported: enabled,
|
|
53
|
-
reset: f("\x1B[0m", "\x1B[0m"),
|
|
54
|
-
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
55
|
-
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
56
|
-
italic: f("\x1B[3m", "\x1B[23m"),
|
|
57
|
-
underline: f("\x1B[4m", "\x1B[24m"),
|
|
58
|
-
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
59
|
-
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
60
|
-
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
61
|
-
black: f("\x1B[30m", "\x1B[39m"),
|
|
62
|
-
red: f("\x1B[31m", "\x1B[39m"),
|
|
63
|
-
green: f("\x1B[32m", "\x1B[39m"),
|
|
64
|
-
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
65
|
-
blue: f("\x1B[34m", "\x1B[39m"),
|
|
66
|
-
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
67
|
-
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
68
|
-
white: f("\x1B[37m", "\x1B[39m"),
|
|
69
|
-
gray: f("\x1B[90m", "\x1B[39m"),
|
|
70
|
-
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
71
|
-
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
72
|
-
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
73
|
-
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
74
|
-
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
75
|
-
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
76
|
-
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
77
|
-
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
78
|
-
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
79
|
-
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
80
|
-
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
81
|
-
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
82
|
-
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
83
|
-
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
84
|
-
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
85
|
-
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
86
|
-
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
87
|
-
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
88
|
-
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
89
|
-
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
90
|
-
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
91
|
-
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
92
|
-
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
93
|
-
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
module.exports = createColors();
|
|
97
|
-
module.exports.createColors = createColors;
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// src/run.ts
|
|
102
|
-
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
103
|
-
import arg from "arg";
|
|
104
|
-
import semver from "semver";
|
|
105
|
-
|
|
106
|
-
// package.json
|
|
107
|
-
var version = "0.1.0-xyd.35";
|
|
108
|
-
|
|
109
|
-
// src/commands.ts
|
|
110
|
-
import { spawn } from "child_process";
|
|
111
|
-
import { fileURLToPath } from "url";
|
|
112
|
-
import { dirname, join } from "path";
|
|
113
|
-
import * as documan from "@xyd-js/documan";
|
|
114
|
-
async function build(root, options = {}) {
|
|
115
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
116
|
-
const __dirname = dirname(__filename);
|
|
117
|
-
const buildScript = join(__dirname, "..", "dist", "build.js");
|
|
118
|
-
return new Promise((resolve, reject) => {
|
|
119
|
-
const args = process.argv.slice(2);
|
|
120
|
-
const child = spawn("node", [buildScript, ...args], {
|
|
121
|
-
stdio: "inherit",
|
|
122
|
-
// This will show output in stdout
|
|
123
|
-
shell: true,
|
|
124
|
-
env: {
|
|
125
|
-
NODE_ENV: "production",
|
|
126
|
-
...process.env
|
|
127
|
-
// Pass through all existing environment variables
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
child.on("close", (code) => {
|
|
131
|
-
if (code === 0) {
|
|
132
|
-
resolve(void 0);
|
|
133
|
-
} else {
|
|
134
|
-
reject(new Error(`Build process exited with code ${code}`));
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
child.on("error", (err) => {
|
|
138
|
-
reject(err);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
async function dev2(root, options = {}) {
|
|
143
|
-
await documan.dev(options);
|
|
144
|
-
await new Promise(() => {
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
async function install2(root, options = {}) {
|
|
148
|
-
await documan.install();
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// src/run.ts
|
|
152
|
-
var helpText = `
|
|
153
|
-
${import_picocolors.default.blueBright("xyd")}
|
|
154
|
-
|
|
155
|
-
${import_picocolors.default.underline("Usage")}:
|
|
156
|
-
$ xyd build [${import_picocolors.default.yellowBright("projectDir")}]
|
|
157
|
-
$ xyd start [${import_picocolors.default.yellowBright("projectDir")}]
|
|
158
|
-
$ xyd dev [${import_picocolors.default.yellowBright("projectDir")}]
|
|
159
|
-
|
|
160
|
-
${import_picocolors.default.underline("Options")}:
|
|
161
|
-
--help, -h Print this help message and exit
|
|
162
|
-
--version, -v Print the CLI version and exit
|
|
163
|
-
--verbose Show debug messages
|
|
164
|
-
|
|
165
|
-
${import_picocolors.default.underline("Build your project")}:
|
|
166
|
-
|
|
167
|
-
$ xyd build
|
|
168
|
-
|
|
169
|
-
${import_picocolors.default.underline("Install the xyd framework")}:
|
|
170
|
-
|
|
171
|
-
$ xyd install
|
|
172
|
-
|
|
173
|
-
${import_picocolors.default.underline("Run your project locally in development")}:
|
|
174
|
-
|
|
175
|
-
$ xyd dev
|
|
176
|
-
`;
|
|
177
|
-
async function run(argv = process.argv.slice(2)) {
|
|
178
|
-
process.env.XYD_CLI = "true";
|
|
179
|
-
const versions = process.versions;
|
|
180
|
-
const MINIMUM_NODE_VERSION = 22;
|
|
181
|
-
if (versions && versions.node && semver.major(versions.node) < MINIMUM_NODE_VERSION) {
|
|
182
|
-
console.warn(
|
|
183
|
-
`\uFE0F\u26A0\uFE0F Oops, Node v${versions.node} detected. xyd requires a Node version greater than ${MINIMUM_NODE_VERSION}.`
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
let args = arg(
|
|
187
|
-
{
|
|
188
|
-
"--help": Boolean,
|
|
189
|
-
"-h": "--help",
|
|
190
|
-
"--version": Boolean,
|
|
191
|
-
"-v": "--version",
|
|
192
|
-
"--port": Number,
|
|
193
|
-
"-p": "--port",
|
|
194
|
-
"--logLevel": String,
|
|
195
|
-
"-l": "--logLevel",
|
|
196
|
-
"--verbose": Boolean,
|
|
197
|
-
"--debug": Boolean
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
argv
|
|
201
|
-
}
|
|
202
|
-
);
|
|
203
|
-
if (args["--verbose"]) {
|
|
204
|
-
process.env.XYD_VERBOSE = "true";
|
|
205
|
-
} else {
|
|
206
|
-
console.debug = () => {
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
let input = args._;
|
|
210
|
-
let flags = Object.entries(args).reduce((acc, [key, value]) => {
|
|
211
|
-
key = key.replace(/^--/, "");
|
|
212
|
-
acc[key] = value;
|
|
213
|
-
return acc;
|
|
214
|
-
}, {});
|
|
215
|
-
if (flags.help) {
|
|
216
|
-
console.log(helpText);
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
if (flags.version) {
|
|
220
|
-
console.log(version);
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
let command = input[0];
|
|
224
|
-
switch (command) {
|
|
225
|
-
case "build":
|
|
226
|
-
await build(input[1], flags);
|
|
227
|
-
break;
|
|
228
|
-
case "install":
|
|
229
|
-
await install2(input[1], flags);
|
|
230
|
-
break;
|
|
231
|
-
case "dev":
|
|
232
|
-
await dev2(input[1], flags);
|
|
233
|
-
break;
|
|
234
|
-
default:
|
|
235
|
-
await dev2(input[0], flags);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// index.ts
|
|
240
|
-
run().then(
|
|
241
|
-
() => {
|
|
242
|
-
process.exit(0);
|
|
243
|
-
},
|
|
244
|
-
(error) => {
|
|
245
|
-
if (error) console.error(error);
|
|
246
|
-
process.exit(1);
|
|
247
|
-
}
|
|
248
|
-
);
|