@chatbi-v/cli 2.0.3 → 2.0.4

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.
Files changed (40) hide show
  1. package/bin/chatbi-cli.js +1 -2
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +2464 -188
  4. package/package.json +6 -3
  5. package/templates/app/package.json.hbs +5 -2
  6. package/templates/plugin/package.json.hbs +3 -3
  7. package/dist/bench-NMQTZVQF.mjs +0 -77
  8. package/dist/build-66EM7X52.mjs +0 -11
  9. package/dist/chunk-2IR4PJIP.mjs +0 -2255
  10. package/dist/chunk-2REG4NIZ.mjs +0 -9577
  11. package/dist/chunk-6YO7P2EG.mjs +0 -55
  12. package/dist/chunk-7DA7PT2X.mjs +0 -271
  13. package/dist/chunk-AQNFMKFL.mjs +0 -5292
  14. package/dist/chunk-B6J5VVNN.mjs +0 -52
  15. package/dist/chunk-BMUJH4OW.mjs +0 -255
  16. package/dist/chunk-DRBLMVU7.mjs +0 -6368
  17. package/dist/chunk-WUWYFYMG.mjs +0 -89
  18. package/dist/commands/add.js +0 -182
  19. package/dist/commands/bench.js +0 -100
  20. package/dist/commands/build.js +0 -297
  21. package/dist/commands/dev.js +0 -8
  22. package/dist/commands/discover.js +0 -25
  23. package/dist/commands/doctor.js +0 -231
  24. package/dist/commands/fetch.js +0 -41
  25. package/dist/commands/gl.js +0 -151
  26. package/dist/commands/init.js +0 -253
  27. package/dist/commands/install.js +0 -85
  28. package/dist/commands/ls.js +0 -46
  29. package/dist/commands/sync.js +0 -78
  30. package/dist/commands/use.js +0 -31
  31. package/dist/config.js +0 -70
  32. package/dist/corekit.js +0 -371
  33. package/dist/execa-GD72AH35.mjs +0 -17
  34. package/dist/fetch-4EUKQD7S.mjs +0 -10
  35. package/dist/index.cjs +0 -27287
  36. package/dist/index.mjs +0 -2769
  37. package/dist/init-P2UCTRNH.mjs +0 -12
  38. package/dist/sandbox.js +0 -522
  39. package/dist/sync-JWHGYK34.mjs +0 -11
  40. package/dist/utils.js +0 -99
@@ -1,55 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
- }) : x)(function(x) {
10
- if (typeof require !== "undefined") return require.apply(this, arguments);
11
- throw Error('Dynamic require of "' + x + '" is not supported');
12
- });
13
- var __esm = (fn, res) => function __init() {
14
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
15
- };
16
- var __commonJS = (cb, mod) => function __require2() {
17
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
18
- };
19
- var __copyProps = (to, from, except, desc) => {
20
- if (from && typeof from === "object" || typeof from === "function") {
21
- for (let key of __getOwnPropNames(from))
22
- if (!__hasOwnProp.call(to, key) && key !== except)
23
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
- }
25
- return to;
26
- };
27
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
28
- // If the importer is in node compatibility mode or this is not an ESM
29
- // file that has been converted to a CommonJS file using a Babel-
30
- // compatible transform (i.e. "__esModule" has not been set), then set
31
- // "default" to the CommonJS "module.exports" for node compatibility.
32
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
33
- mod
34
- ));
35
-
36
- // ../../../../../../../opt/homebrew/lib/node_modules/@chatbi-v/cli/node_modules/tsup/assets/esm_shims.js
37
- import path from "path";
38
- import { fileURLToPath } from "url";
39
- var getFilename, getDirname, __dirname;
40
- var init_esm_shims = __esm({
41
- "../../../../../../../opt/homebrew/lib/node_modules/@chatbi-v/cli/node_modules/tsup/assets/esm_shims.js"() {
42
- "use strict";
43
- getFilename = () => fileURLToPath(import.meta.url);
44
- getDirname = () => path.dirname(getFilename());
45
- __dirname = /* @__PURE__ */ getDirname();
46
- }
47
- });
48
-
49
- export {
50
- __require,
51
- __commonJS,
52
- __toESM,
53
- __dirname,
54
- init_esm_shims
55
- };
@@ -1,271 +0,0 @@
1
- import {
2
- CoreKit
3
- } from "./chunk-AQNFMKFL.mjs";
4
- import {
5
- Sandbox
6
- } from "./chunk-DRBLMVU7.mjs";
7
- import {
8
- execa
9
- } from "./chunk-2IR4PJIP.mjs";
10
- import {
11
- createSpinner,
12
- logger,
13
- printBox,
14
- require_lib,
15
- require_picocolors
16
- } from "./chunk-2REG4NIZ.mjs";
17
- import {
18
- __toESM,
19
- init_esm_shims
20
- } from "./chunk-6YO7P2EG.mjs";
21
-
22
- // src/commands/build.ts
23
- init_esm_shims();
24
- var import_fs_extra = __toESM(require_lib());
25
- var import_picocolors = __toESM(require_picocolors());
26
- import path from "path";
27
- import { build as tsupBuild } from "tsup";
28
- async function build(options) {
29
- const cwd = process.cwd();
30
- const pkgPath = path.join(cwd, "package.json");
31
- if (!import_fs_extra.default.existsSync(pkgPath)) {
32
- logger.error(`\u5728 ${cwd} \u4E2D\u672A\u627E\u5230 package.json`);
33
- return;
34
- }
35
- const pkg = await import_fs_extra.default.readJson(pkgPath);
36
- const version = await CoreKit.resolveVersion(cwd);
37
- logger.info(`\u6B63\u5728\u6784\u5EFA\u9879\u76EE: ${import_picocolors.default.bold(pkg.name || "unnamed")} (\u5185\u6838\u7248\u672C: ${version})
38
- `);
39
- const spinner = createSpinner("\u6B63\u5728\u51C6\u5907\u6784\u5EFA\u73AF\u5883...").start();
40
- spinner.text = "\u6B63\u5728\u540C\u6B65\u6C99\u7BB1\u5185\u6838...";
41
- await Sandbox.prepare(version);
42
- if (pkg.workspaces || import_fs_extra.default.existsSync(path.join(cwd, "pnpm-workspace.yaml"))) {
43
- spinner.text = "\u68C0\u6D4B\u5230 Monorepo\uFF0C\u6B63\u5728\u540C\u6B65\u5B50\u5305\u4E0A\u4E0B\u6587...";
44
- await Sandbox.injectContext(cwd, version);
45
- const subDirs = ["apps", "plugins"];
46
- for (const dir of subDirs) {
47
- const dirPath = path.join(cwd, dir);
48
- if (import_fs_extra.default.existsSync(dirPath)) {
49
- const entries = await import_fs_extra.default.readdir(dirPath, { withFileTypes: true });
50
- for (const entry2 of entries) {
51
- if (entry2.isDirectory()) {
52
- const subPkgPath = path.join(dirPath, entry2.name);
53
- if (import_fs_extra.default.existsSync(path.join(subPkgPath, "package.json"))) {
54
- await Sandbox.injectContext(subPkgPath, version);
55
- }
56
- }
57
- }
58
- }
59
- }
60
- } else {
61
- await Sandbox.injectContext(cwd, version);
62
- }
63
- spinner.succeed("\u6784\u5EFA\u73AF\u5883\u5C31\u7EEA");
64
- if (pkg.scripts && pkg.scripts.build && !process.env.CHATBI_CLI_INTERNAL) {
65
- const buildScript = pkg.scripts.build;
66
- if (!buildScript.includes("chatbi-cli build") && !buildScript.includes("chatbi build")) {
67
- logger.info(`\u68C0\u6D4B\u5230\u81EA\u5B9A\u4E49 build \u811A\u672C\uFF0C\u6B63\u5728\u6267\u884C: ${import_picocolors.default.cyan("npm run build")}`);
68
- const args = ["run", "build"];
69
- if (options.watch) {
70
- args.push("--", "--watch");
71
- }
72
- await execa("npm", args, {
73
- stdio: "inherit",
74
- env: { ...process.env, CHATBI_CLI_INTERNAL: "true" }
75
- });
76
- return;
77
- }
78
- }
79
- const mode = await CoreKit.detectMode(cwd);
80
- if (mode === "monorepo") {
81
- logger.info("\u68C0\u6D4B\u5230 Monorepo \u9879\u76EE\uFF0C\u6B63\u5728\u9012\u5F52\u6784\u5EFA\u5B50\u5305...");
82
- await execa("pnpm", ["-r", "build"], { stdio: "inherit", cwd });
83
- return;
84
- }
85
- if (mode === "app") {
86
- logger.info("\u6B63\u5728\u6784\u5EFA\u5E94\u7528 (Vite)...");
87
- const { build: viteBuild } = await import("vite");
88
- const coreAlias = Sandbox.getCoreAlias(version);
89
- await viteBuild({
90
- root: cwd,
91
- configFile: import_fs_extra.default.existsSync(path.join(cwd, "vite.config.ts")) ? void 0 : false,
92
- resolve: {
93
- alias: {
94
- ...coreAlias
95
- }
96
- },
97
- build: {
98
- watch: options.watch ? {} : null,
99
- outDir: "dist",
100
- emptyOutDir: true,
101
- minify: !options.watch ? "esbuild" : false
102
- // 生产环境开启压缩混淆
103
- },
104
- server: {
105
- fs: {
106
- allow: [
107
- Sandbox.getRoot(),
108
- cwd
109
- ]
110
- }
111
- }
112
- });
113
- if (!options.watch) {
114
- printBox(
115
- import_picocolors.default.green(import_picocolors.default.bold("\u2728 \u5E94\u7528\u6784\u5EFA\u6210\u529F!")) + "\n\n" + import_picocolors.default.white("\u4EA7\u7269\u76EE\u5F55: ") + import_picocolors.default.cyan("dist"),
116
- "Build Success"
117
- );
118
- }
119
- return;
120
- }
121
- let entry = ["src/index.ts"];
122
- if (import_fs_extra.default.existsSync(path.join(cwd, "src/index.tsx"))) {
123
- entry = ["src/index.tsx"];
124
- } else if (!import_fs_extra.default.existsSync(path.join(cwd, "src/index.ts"))) {
125
- logger.error("\u672A\u627E\u5230\u5165\u53E3\u6587\u4EF6\u3002\u671F\u671B src/index.ts \u6216 src/index.tsx");
126
- return;
127
- }
128
- const isPlugin = mode === "plugin";
129
- if (!options.watch) {
130
- await import_fs_extra.default.remove(path.join(cwd, "dist"));
131
- const tsbuildinfo = path.join(cwd, "tsconfig.tsbuildinfo");
132
- if (import_fs_extra.default.existsSync(tsbuildinfo)) {
133
- await import_fs_extra.default.remove(tsbuildinfo);
134
- }
135
- }
136
- const external = [
137
- "react",
138
- "react-dom",
139
- "react/jsx-runtime",
140
- "react-is",
141
- "antd",
142
- "@ant-design/icons",
143
- "@ant-design/x",
144
- ...Object.keys(pkg.dependencies || {}),
145
- ...Object.keys(pkg.peerDependencies || {})
146
- ];
147
- if (isPlugin) {
148
- const coreDeps = Sandbox.CORE_PACKAGES;
149
- coreDeps.forEach((dep) => {
150
- if (!external.includes(dep)) {
151
- external.push(dep);
152
- }
153
- });
154
- }
155
- const commonConfig = {
156
- entry,
157
- dts: false,
158
- clean: false,
159
- sourcemap: false,
160
- target: "esnext",
161
- platform: isPlugin ? "browser" : "node",
162
- external,
163
- minify: !options.watch,
164
- // 生产环境开启压缩混淆
165
- watch: options.watch,
166
- silent: true,
167
- esbuildOptions(options2) {
168
- options2.logOverride = {
169
- "empty-import-meta": "silent"
170
- };
171
- options2.external = options2.external || [];
172
- const forceExternal = [
173
- "react",
174
- "react-dom",
175
- "antd",
176
- "@ant-design/icons",
177
- "@ant-design/x",
178
- ...Sandbox.CORE_PACKAGES
179
- ];
180
- forceExternal.forEach((dep) => {
181
- if (!options2.external.includes(dep)) {
182
- options2.external.push(dep);
183
- }
184
- });
185
- }
186
- };
187
- const buildSpinner = createSpinner("\u6B63\u5728\u7F16\u8BD1\u6E90\u7801...").start();
188
- if (isPlugin) {
189
- buildSpinner.text = "\u6B63\u5728\u6784\u5EFA ESM \u683C\u5F0F...";
190
- await tsupBuild({
191
- ...commonConfig,
192
- format: ["esm"],
193
- outExtension: () => ({ js: ".mjs" })
194
- });
195
- buildSpinner.text = "\u6B63\u5728\u6784\u5EFA IIFE \u683C\u5F0F (Plugin)...";
196
- await tsupBuild({
197
- ...commonConfig,
198
- format: ["iife"],
199
- globalName: pkg.name.replace(/[^a-zA-Z0-9]/g, "_"),
200
- outExtension: () => ({ js: ".plugin.js" }),
201
- platform: "browser",
202
- define: {
203
- "import.meta.env": "process.env"
204
- },
205
- esbuildOptions(options2) {
206
- options2.logOverride = {
207
- "empty-import-meta": "silent"
208
- };
209
- options2.external = options2.external || [];
210
- const forceExternal = [
211
- "react",
212
- "react-dom",
213
- "antd",
214
- "@ant-design/icons",
215
- "@ant-design/x",
216
- ...Sandbox.CORE_PACKAGES
217
- ];
218
- forceExternal.forEach((dep) => {
219
- if (!options2.external.includes(dep)) {
220
- options2.external.push(dep);
221
- }
222
- });
223
- }
224
- });
225
- } else {
226
- buildSpinner.text = "\u6B63\u5728\u7F16\u8BD1\u6E90\u7801...";
227
- await tsupBuild({
228
- ...commonConfig,
229
- format: ["cjs", "esm"],
230
- outExtension({ format }) {
231
- return { js: format === "esm" ? ".mjs" : ".cjs" };
232
- }
233
- });
234
- }
235
- buildSpinner.succeed("\u6E90\u7801\u7F16\u8BD1\u5B8C\u6210");
236
- if (!options.watch) {
237
- const dtsSpinner = createSpinner("\u6B63\u5728\u751F\u6210\u7C7B\u578B\u5B9A\u4E49...").start();
238
- try {
239
- const localTsc = path.join(cwd, "node_modules/.bin/tsc");
240
- const sandboxTsc = path.join(Sandbox.getVersionPath(version), "node_modules/.bin/tsc");
241
- let tscBin = "tsc";
242
- if (import_fs_extra.default.existsSync(localTsc)) {
243
- tscBin = localTsc;
244
- } else if (import_fs_extra.default.existsSync(sandboxTsc)) {
245
- tscBin = sandboxTsc;
246
- } else {
247
- if (import_fs_extra.default.existsSync(path.join(cwd, "pnpm-lock.yaml"))) {
248
- await execa("pnpm", ["exec", "tsc", "--build", "tsconfig.json"]);
249
- dtsSpinner.succeed("\u7C7B\u578B\u5B9A\u4E49\u751F\u6210\u5B8C\u6210");
250
- } else {
251
- await execa("npx", ["-p", "typescript", "tsc", "--build", "tsconfig.json"]);
252
- dtsSpinner.succeed("\u7C7B\u578B\u5B9A\u4E49\u751F\u6210\u5B8C\u6210");
253
- }
254
- }
255
- if (tscBin !== "tsc") {
256
- await execa(tscBin, ["--build", "tsconfig.json"]);
257
- dtsSpinner.succeed("\u7C7B\u578B\u5B9A\u4E49\u751F\u6210\u5B8C\u6210");
258
- }
259
- } catch (e) {
260
- dtsSpinner.warn("\u7C7B\u578B\u751F\u6210\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u9879\u76EE\u4E2D\u7684 tsconfig.json \u914D\u7F6E");
261
- }
262
- printBox(
263
- import_picocolors.default.green(import_picocolors.default.bold("\u2728 \u6784\u5EFA\u5B8C\u6210!")) + "\n\n" + import_picocolors.default.white("\u4EA7\u7269\u76EE\u5F55: ") + import_picocolors.default.cyan("dist") + "\n" + import_picocolors.default.white("\u6784\u5EFA\u6A21\u5F0F: ") + import_picocolors.default.cyan(isPlugin ? "Plugin" : "Library"),
264
- "Build Success"
265
- );
266
- }
267
- }
268
-
269
- export {
270
- build
271
- };