@chatbi-v/cli 2.0.2 → 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 (41) 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 +5 -5
  7. package/templates/plugin/tsconfig.json.hbs +1 -1
  8. package/dist/bench-ACSHVGHE.mjs +0 -77
  9. package/dist/build-UB4D3WNI.mjs +0 -11
  10. package/dist/chunk-4OD6C56P.mjs +0 -89
  11. package/dist/chunk-7A54IJI5.mjs +0 -6368
  12. package/dist/chunk-LJFX6MNO.mjs +0 -255
  13. package/dist/chunk-SBGVKO4C.mjs +0 -2255
  14. package/dist/chunk-TX5M36S5.mjs +0 -55
  15. package/dist/chunk-V7IEPMC4.mjs +0 -52
  16. package/dist/chunk-WCPZB47I.mjs +0 -262
  17. package/dist/chunk-WIVHOK75.mjs +0 -5292
  18. package/dist/chunk-Y24V4GQG.mjs +0 -9577
  19. package/dist/commands/add.js +0 -182
  20. package/dist/commands/bench.js +0 -100
  21. package/dist/commands/build.js +0 -290
  22. package/dist/commands/dev.js +0 -8
  23. package/dist/commands/discover.js +0 -25
  24. package/dist/commands/doctor.js +0 -231
  25. package/dist/commands/fetch.js +0 -41
  26. package/dist/commands/gl.js +0 -151
  27. package/dist/commands/init.js +0 -253
  28. package/dist/commands/install.js +0 -85
  29. package/dist/commands/ls.js +0 -46
  30. package/dist/commands/sync.js +0 -78
  31. package/dist/commands/use.js +0 -31
  32. package/dist/config.js +0 -70
  33. package/dist/corekit.js +0 -370
  34. package/dist/execa-METROS6Z.mjs +0 -17
  35. package/dist/fetch-7X2UFWIV.mjs +0 -10
  36. package/dist/index.cjs +0 -27278
  37. package/dist/index.mjs +0 -2769
  38. package/dist/init-QFRFYEA5.mjs +0 -12
  39. package/dist/sandbox.js +0 -522
  40. package/dist/sync-7HPKGVFY.mjs +0 -11
  41. 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
- // ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3_yaml@2.8.2/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
- "../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.6_typescript@5.9.3_yaml@2.8.2/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,52 +0,0 @@
1
- import {
2
- Sandbox
3
- } from "./chunk-7A54IJI5.mjs";
4
- import {
5
- execa
6
- } from "./chunk-SBGVKO4C.mjs";
7
- import {
8
- createSpinner,
9
- logger,
10
- printBox,
11
- require_picocolors
12
- } from "./chunk-Y24V4GQG.mjs";
13
- import {
14
- __toESM,
15
- init_esm_shims
16
- } from "./chunk-TX5M36S5.mjs";
17
-
18
- // src/commands/fetch.ts
19
- init_esm_shims();
20
- var import_picocolors = __toESM(require_picocolors());
21
- import path from "path";
22
- async function fetch(version, options = {}) {
23
- const fetchSpinner = createSpinner(`\u6B63\u5728\u83B7\u53D6\u5185\u6838\u7248\u672C ${import_picocolors.default.cyan(version)}...`).start();
24
- const versionPath = await Sandbox.prepare(version, true);
25
- fetchSpinner.succeed(`\u5185\u6838\u7248\u672C ${import_picocolors.default.cyan(version)} \u83B7\u53D6\u6210\u529F`);
26
- if (options.pack) {
27
- const packSpinner = createSpinner("\u6B63\u5728\u6253\u5305\u79BB\u7EBF\u8D44\u6E90...").start();
28
- const tgzName = `chatbi-core-${version}.tgz`;
29
- const tgzPath = path.resolve(process.cwd(), tgzName);
30
- await execa("tar", [
31
- "-czf",
32
- tgzPath,
33
- "-C",
34
- path.dirname(versionPath),
35
- path.basename(versionPath)
36
- ]);
37
- packSpinner.succeed("\u79BB\u7EBF\u8D44\u6E90\u6253\u5305\u5B8C\u6210");
38
- printBox(
39
- `${import_picocolors.default.green(import_picocolors.default.bold("\u2728 \u79BB\u7EBF\u5305\u5DF2\u751F\u6210!"))}
40
-
41
- ${import_picocolors.default.white("\u6587\u4EF6\u8DEF\u5F84: ")} ${import_picocolors.default.cyan(tgzPath)}
42
- ${import_picocolors.default.white("\u5B89\u88C5\u547D\u4EE4: ")} ${import_picocolors.default.gray(`chatbi install ${tgzName}`)}`,
43
- "Pack Success"
44
- );
45
- } else {
46
- logger.success(`\u5185\u6838\u7248\u672C ${import_picocolors.default.cyan(version)} \u5DF2\u51C6\u5907\u5C31\u7EEA\u3002`);
47
- }
48
- }
49
-
50
- export {
51
- fetch
52
- };
@@ -1,262 +0,0 @@
1
- import {
2
- CoreKit
3
- } from "./chunk-WIVHOK75.mjs";
4
- import {
5
- Sandbox
6
- } from "./chunk-7A54IJI5.mjs";
7
- import {
8
- execa
9
- } from "./chunk-SBGVKO4C.mjs";
10
- import {
11
- createSpinner,
12
- logger,
13
- printBox,
14
- require_lib,
15
- require_picocolors
16
- } from "./chunk-Y24V4GQG.mjs";
17
- import {
18
- __toESM,
19
- init_esm_shims
20
- } from "./chunk-TX5M36S5.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 === "app") {
81
- logger.info("\u6B63\u5728\u6784\u5EFA\u5E94\u7528 (Vite)...");
82
- const { build: viteBuild } = await import("vite");
83
- const coreAlias = Sandbox.getCoreAlias(version);
84
- await viteBuild({
85
- root: cwd,
86
- configFile: import_fs_extra.default.existsSync(path.join(cwd, "vite.config.ts")) ? void 0 : false,
87
- resolve: {
88
- alias: {
89
- ...coreAlias
90
- }
91
- },
92
- build: {
93
- watch: options.watch ? {} : null,
94
- outDir: "dist",
95
- emptyOutDir: true
96
- },
97
- server: {
98
- fs: {
99
- allow: [
100
- Sandbox.getRoot(),
101
- cwd
102
- ]
103
- }
104
- }
105
- });
106
- if (!options.watch) {
107
- printBox(
108
- 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"),
109
- "Build Success"
110
- );
111
- }
112
- return;
113
- }
114
- let entry = ["src/index.ts"];
115
- if (import_fs_extra.default.existsSync(path.join(cwd, "src/index.tsx"))) {
116
- entry = ["src/index.tsx"];
117
- } else if (!import_fs_extra.default.existsSync(path.join(cwd, "src/index.ts"))) {
118
- logger.error("\u672A\u627E\u5230\u5165\u53E3\u6587\u4EF6\u3002\u671F\u671B src/index.ts \u6216 src/index.tsx");
119
- return;
120
- }
121
- const isPlugin = mode === "plugin";
122
- if (!options.watch) {
123
- await import_fs_extra.default.remove(path.join(cwd, "dist"));
124
- const tsbuildinfo = path.join(cwd, "tsconfig.tsbuildinfo");
125
- if (import_fs_extra.default.existsSync(tsbuildinfo)) {
126
- await import_fs_extra.default.remove(tsbuildinfo);
127
- }
128
- }
129
- const external = [
130
- "react",
131
- "react-dom",
132
- "react/jsx-runtime",
133
- "react-is",
134
- "antd",
135
- "@ant-design/icons",
136
- "@ant-design/x",
137
- ...Object.keys(pkg.dependencies || {}),
138
- ...Object.keys(pkg.peerDependencies || {})
139
- ];
140
- if (isPlugin) {
141
- const coreDeps = Sandbox.CORE_PACKAGES;
142
- coreDeps.forEach((dep) => {
143
- if (!external.includes(dep)) {
144
- external.push(dep);
145
- }
146
- });
147
- }
148
- const commonConfig = {
149
- entry,
150
- dts: false,
151
- clean: false,
152
- sourcemap: false,
153
- target: "esnext",
154
- platform: isPlugin ? "browser" : "node",
155
- external,
156
- watch: options.watch,
157
- silent: true,
158
- esbuildOptions(options2) {
159
- options2.logOverride = {
160
- "empty-import-meta": "silent"
161
- };
162
- options2.external = options2.external || [];
163
- const forceExternal = [
164
- "react",
165
- "react-dom",
166
- "antd",
167
- "@ant-design/icons",
168
- "@ant-design/x",
169
- ...Sandbox.CORE_PACKAGES
170
- ];
171
- forceExternal.forEach((dep) => {
172
- if (!options2.external.includes(dep)) {
173
- options2.external.push(dep);
174
- }
175
- });
176
- }
177
- };
178
- const buildSpinner = createSpinner("\u6B63\u5728\u7F16\u8BD1\u6E90\u7801...").start();
179
- if (isPlugin) {
180
- buildSpinner.text = "\u6B63\u5728\u6784\u5EFA ESM \u683C\u5F0F...";
181
- await tsupBuild({
182
- ...commonConfig,
183
- format: ["esm"],
184
- outExtension: () => ({ js: ".mjs" })
185
- });
186
- buildSpinner.text = "\u6B63\u5728\u6784\u5EFA IIFE \u683C\u5F0F (Plugin)...";
187
- await tsupBuild({
188
- ...commonConfig,
189
- format: ["iife"],
190
- globalName: pkg.name.replace(/[^a-zA-Z0-9]/g, "_"),
191
- outExtension: () => ({ js: ".plugin.js" }),
192
- platform: "browser",
193
- define: {
194
- "import.meta.env": "process.env"
195
- },
196
- esbuildOptions(options2) {
197
- options2.logOverride = {
198
- "empty-import-meta": "silent"
199
- };
200
- options2.external = options2.external || [];
201
- const forceExternal = [
202
- "react",
203
- "react-dom",
204
- "antd",
205
- "@ant-design/icons",
206
- "@ant-design/x",
207
- ...Sandbox.CORE_PACKAGES
208
- ];
209
- forceExternal.forEach((dep) => {
210
- if (!options2.external.includes(dep)) {
211
- options2.external.push(dep);
212
- }
213
- });
214
- }
215
- });
216
- } else {
217
- buildSpinner.text = "\u6B63\u5728\u7F16\u8BD1\u6E90\u7801...";
218
- await tsupBuild({
219
- ...commonConfig,
220
- format: ["cjs", "esm"],
221
- outExtension({ format }) {
222
- return { js: format === "esm" ? ".mjs" : ".cjs" };
223
- }
224
- });
225
- }
226
- buildSpinner.succeed("\u6E90\u7801\u7F16\u8BD1\u5B8C\u6210");
227
- if (!options.watch) {
228
- const dtsSpinner = createSpinner("\u6B63\u5728\u751F\u6210\u7C7B\u578B\u5B9A\u4E49...").start();
229
- try {
230
- const localTsc = path.join(cwd, "node_modules/.bin/tsc");
231
- const sandboxTsc = path.join(Sandbox.getVersionPath(version), "node_modules/.bin/tsc");
232
- let tscBin = "tsc";
233
- if (import_fs_extra.default.existsSync(localTsc)) {
234
- tscBin = localTsc;
235
- } else if (import_fs_extra.default.existsSync(sandboxTsc)) {
236
- tscBin = sandboxTsc;
237
- } else {
238
- if (import_fs_extra.default.existsSync(path.join(cwd, "pnpm-lock.yaml"))) {
239
- await execa("pnpm", ["exec", "tsc", "--build", "tsconfig.json"]);
240
- dtsSpinner.succeed("\u7C7B\u578B\u5B9A\u4E49\u751F\u6210\u5B8C\u6210");
241
- } else {
242
- await execa("npx", ["-p", "typescript", "tsc", "--build", "tsconfig.json"]);
243
- dtsSpinner.succeed("\u7C7B\u578B\u5B9A\u4E49\u751F\u6210\u5B8C\u6210");
244
- }
245
- }
246
- if (tscBin !== "tsc") {
247
- await execa(tscBin, ["--build", "tsconfig.json"]);
248
- dtsSpinner.succeed("\u7C7B\u578B\u5B9A\u4E49\u751F\u6210\u5B8C\u6210");
249
- }
250
- } catch (e) {
251
- dtsSpinner.warn("\u7C7B\u578B\u751F\u6210\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u9879\u76EE\u4E2D\u7684 tsconfig.json \u914D\u7F6E");
252
- }
253
- printBox(
254
- 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"),
255
- "Build Success"
256
- );
257
- }
258
- }
259
-
260
- export {
261
- build
262
- };