neo-cmp-cli 1.13.27 → 1.15.2
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 +123 -8
- package/dist/config/default.config.js +1 -1
- package/dist/index2.js +1 -1
- package/dist/main2.js +1 -1
- package/dist/neo/buildComponentData.js +1 -0
- package/dist/neo/env.js +1 -1
- package/dist/neo/getCmpPreviewSchema.js +1 -0
- package/dist/neo/neoEnvManager.js +1 -1
- package/dist/neo/pushCmp.js +1 -1
- package/dist/package.json.js +1 -1
- package/dist/utils/common.js +1 -1
- package/dist/utils/projectUtils/openProject.js +1 -1
- package/dist/utils/skillUtils/skillDirs.js +1 -0
- package/dist/utils/skillUtils/skillManager.js +1 -0
- package/package.json +3 -2
- package/template/antd-custom-cmp-template/package.json +1 -1
- package/template/antd-custom-cmp-template/src/components/dataDashboard__c/model.ts +2 -1
- package/template/antd-custom-cmp-template/src/components/searchWidget__c/model.ts +2 -1
- package/template/asset-manage-template/package.json +2 -2
- package/template/echarts-custom-cmp-template/package.json +1 -1
- package/template/empty-custom-cmp-template/package.json +1 -1
- package/template/map-custom-cmp-template/package.json +1 -1
- package/template/neo-bi-cmps/package.json +1 -1
- package/template/neo-custom-cmp-template/neo.config.js +9 -1
- package/template/neo-custom-cmp-template/package.json +4 -2
- package/template/neo-h5-cmps/package.json +1 -1
- package/template/neo-pipeline-cmps/package.json +1 -1
- package/template/neo-pipeline-zh-cmps/package.json +1 -1
- package/template/neo-web-entity-grid/package.json +2 -2
- package/template/neo-web-form/package.json +3 -3
- package/template/react-custom-cmp-template/package.json +4 -3
- package/template/react-custom-cmp-template/src/components/infoCard__c/model.js +1 -1
- package/template/react-ts-custom-cmp-template/package.json +1 -1
- package/template/vue2-custom-cmp-template/package.json +1 -1
- package/template/neo-custom-cmp-template/CODEBUDDY.md +0 -92
package/README.md
CHANGED
|
@@ -98,21 +98,38 @@ neo create cmp
|
|
|
98
98
|
|
|
99
99
|
默认在 `src/components/` 下新增自定义组件目录。
|
|
100
100
|
|
|
101
|
-
### 5.
|
|
101
|
+
### 5. 预览
|
|
102
102
|
|
|
103
103
|
```bash
|
|
104
|
+
# 在线预览(默认)
|
|
104
105
|
neo preview
|
|
106
|
+
# 等价于
|
|
107
|
+
neo preview -m online
|
|
108
|
+
|
|
109
|
+
# 本地预览
|
|
110
|
+
neo preview -m local
|
|
111
|
+
|
|
112
|
+
# 指定组件名 + 预览模式
|
|
113
|
+
neo preview -n xxCmp -m online
|
|
114
|
+
neo preview -n xxCmp -m local
|
|
105
115
|
```
|
|
106
116
|
|
|
117
|
+
`neo preview` 支持两种预览模式:
|
|
118
|
+
|
|
119
|
+
- **在线预览(`online`,默认)**:在 NeoCRM / 页面设计器的在线环境中预览组件,可以访问 Neo 平台运行时、接口与上下文;推荐使用。
|
|
120
|
+
- **本地预览(`local`)**:在本地开发服务器中预览组件(含热更新与接口代理),适合纯前端、不依赖平台运行时的场景。
|
|
121
|
+
|
|
107
122
|
命令成功执行后,一般会默认打开浏览器进行预览。
|
|
108
123
|
|
|
124
|
+
> **说明**:当组件依赖 Neo 平台运行时(如 `neo-ui-common`、`neo-ui-component-web` 等平台能力、接口或上下文)时,本地预览环境无法完整模拟,**只能使用在线预览**(`neo preview -m online`);如需在设计器页面上下文中验证,可改用「外链调试」。
|
|
125
|
+
|
|
109
126
|
### 6. 外链调试(在 NeoCRM / 页面设计器中调试)
|
|
110
127
|
|
|
111
128
|
```bash
|
|
112
129
|
neo linkDebug
|
|
113
130
|
```
|
|
114
131
|
|
|
115
|
-
> **提示**:需在 NeoCRM 或页面设计器中开启 debug 模式,并将控制台输出的外链脚本地址加入「外部链接」。详细步骤见下文 [本地调试自定义组件](#
|
|
132
|
+
> **提示**:需在 NeoCRM 或页面设计器中开启 debug 模式,并将控制台输出的外链脚本地址加入「外部链接」。详细步骤见下文 [本地调试自定义组件](#3-本地调试自定义组件)。
|
|
116
133
|
|
|
117
134
|
### 7. 发布到 NeoCRM
|
|
118
135
|
|
|
@@ -120,7 +137,7 @@ neo linkDebug
|
|
|
120
137
|
neo push cmp
|
|
121
138
|
```
|
|
122
139
|
|
|
123
|
-
> **提示**:发布前请确认 `package.json` 中 `name` 在平台内唯一、`version` 未与已发布版本冲突,并完成 NeoCRM 授权配置。详见 [发布自定义组件至 NeoCRM](#
|
|
140
|
+
> **提示**:发布前请确认 `package.json` 中 `name` 在平台内唯一、`version` 未与已发布版本冲突,并完成 NeoCRM 授权配置。详见 [发布自定义组件至 NeoCRM](#4-发布自定义组件至-neocrm)。
|
|
124
141
|
|
|
125
142
|
---
|
|
126
143
|
|
|
@@ -133,11 +150,76 @@ neo push cmp
|
|
|
133
150
|
| `neo create cmp` | 在当前项目中创建一个自定义组件 | `--name` 组件名,`--targetDevice` / `-d` 指定目标设备类型 |
|
|
134
151
|
| `neo login` | 登录 NeoCRM(OAuth2) | `-e` / `--env` 环境类型 |
|
|
135
152
|
| `neo logout` | 登出 NeoCRM | — |
|
|
136
|
-
| `neo preview` |
|
|
153
|
+
| `neo preview` | 预览自定义组件,支持在线预览(`online`,默认)与本地预览(`local`)。在线预览在 NeoCRM / 页面设计器环境中预览;本地预览使用本地开发服务器,支持热更新与接口代理。若组件依赖 `neo-ui-common` 或 `neo-ui-component-web` 等平台运行时模块,则**只能使用在线预览**(`-m online`) | `-n` / `--name` 组件名,`-m` / `--mode` 预览模式(`online` / `local`,默认 `online`) |
|
|
137
154
|
| `neo linkDebug` | 外链调试,在页面设计器中调试自定义组件 | `--platform` 调试设备类型,`--name` 组件名 |
|
|
138
155
|
| `neo push cmp` | 构建并发布到 NeoCRM | `--name` 组件名 |
|
|
139
156
|
| `neo pull cmp` | 从 NeoCRM 拉取线上组件到当前项目 | `--name` 组件名 |
|
|
140
157
|
| `neo delete cmp` | 删除 NeoCRM 上的指定自定义组件 | `--name` 组件名 |
|
|
158
|
+
| `neo add cli-skills` | 安装「组件开发技能包」到指定产品的 skill 目录(用户级) | `-p` / `--product` 目标产品(`codebuddy` / `kiro` / `cursor` / `claudeCode`) |
|
|
159
|
+
| `neo update cli-skills` | 更新指定产品下的「组件开发技能包」(覆盖式 copy `neo-cmp-cli` / `neo-cmp-dev` / `vue-to-react` / `frontend-design`) | `-p` / `--product` 目标产品 |
|
|
160
|
+
| `neo remove cli-skills` | 移除指定产品下的「组件开发技能包」(清理 `neo-cmp-cli` / `neo-cmp-dev` / `vue-to-react`) | `-p` / `--product` 目标产品 |
|
|
161
|
+
|
|
162
|
+
## 组件开发技能包(Skills)
|
|
163
|
+
|
|
164
|
+
neo-cmp-cli 提供一组面向 AI 编辑器的「组件开发技能包」,可一键安装到以下产品的 skill 目录中,帮助 AI 助手更懂 Neo 自定义组件的开发规范与工作流:
|
|
165
|
+
|
|
166
|
+
- **CodeBuddy**:`~/.codebuddy/skills/`
|
|
167
|
+
- **Kiro**:`~/.kiro/skills/`
|
|
168
|
+
- **Cursor**:`~/.cursor/skills/`
|
|
169
|
+
- **Claude Code**:`~/.claude/skills/`
|
|
170
|
+
|
|
171
|
+
> Windows 与 macOS 下 `~` 均指当前用户主目录(Windows 下对应 `C:\Users\<用户名>`、macOS 下对应 `/Users/<用户名>`),以上路径在两个平台均可直接使用。
|
|
172
|
+
|
|
173
|
+
### 安装技能包
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# 交互选择目标产品
|
|
177
|
+
neo add cli-skills
|
|
178
|
+
|
|
179
|
+
# 指定目标产品(跳过交互)
|
|
180
|
+
neo add cli-skills -p codebuddy
|
|
181
|
+
neo add cli-skills -p kiro
|
|
182
|
+
neo add cli-skills -p cursor
|
|
183
|
+
neo add cli-skills -p claudeCode
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
执行后将从 `https://neo-cmp-docs.netlify.app/neo-cmp-skills.zip` 下载技能包并解压到所选产品的 skill 目录下。若目标目录中已存在同名 skill,会以覆盖方式写入。
|
|
187
|
+
|
|
188
|
+
### 更新技能包
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
# 交互选择目标产品
|
|
192
|
+
neo update cli-skills
|
|
193
|
+
|
|
194
|
+
# 指定目标产品
|
|
195
|
+
neo update cli-skills -p codebuddy
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
更新命令会下载最新技能包,并在选定产品的 skill 目录中覆盖式 copy 以下 skills:
|
|
199
|
+
|
|
200
|
+
- `neo-cmp-cli`
|
|
201
|
+
- `neo-cmp-dev`
|
|
202
|
+
- `vue-to-react`
|
|
203
|
+
- `frontend-design`
|
|
204
|
+
|
|
205
|
+
### 移除技能包
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# 交互选择目标产品
|
|
209
|
+
neo remove cli-skills
|
|
210
|
+
|
|
211
|
+
# 指定目标产品
|
|
212
|
+
neo remove cli-skills -p codebuddy
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
移除命令会在选定产品的 skill 目录中清理以下 skills:
|
|
216
|
+
|
|
217
|
+
- `neo-cmp-cli`
|
|
218
|
+
- `neo-cmp-dev`
|
|
219
|
+
- `vue-to-react`
|
|
220
|
+
|
|
221
|
+
> **提示**:`remove` 命令不会删除 `frontend-design`,避免影响通用的前端设计类工作流。如需整体清理,可手动删除对应目录。
|
|
222
|
+
|
|
141
223
|
|
|
142
224
|
## CLI 使用相关常见问题
|
|
143
225
|
|
|
@@ -293,7 +375,40 @@ module.exports = {
|
|
|
293
375
|
- **自动注册**:发布时会生成注册相关文件并注入构建流程,一般无需手写注册代码(参见 [neo-register](https://www.npmjs.com/package/neo-register))。
|
|
294
376
|
- **样式隔离**:发布或 `linkDebug` 时会对组件样式做隔离处理(默认处理目录下 `(index|style).(scss|less)` 等)。根节点请使用**与组件目录名一致**的类名(className),避免被样式隔离策略影响。若需关闭,可在 `neo.config.js` 或 webpack 相关配置中将 `disableAutoAddStyleScope` 设为 `true`。
|
|
295
377
|
|
|
296
|
-
### 2.
|
|
378
|
+
### 2. 预览自定义组件
|
|
379
|
+
|
|
380
|
+
`neo preview` 支持两种预览模式:
|
|
381
|
+
|
|
382
|
+
- **在线预览(`online`,默认)**:在 NeoCRM / 页面设计器的在线环境中预览组件,可以访问 Neo 平台运行时、接口与上下文;推荐使用。
|
|
383
|
+
- **本地预览(`local`)**:在本地开发服务器中预览组件(含热更新与接口代理),适合纯前端、不依赖平台运行时的场景。
|
|
384
|
+
|
|
385
|
+
#### 用法
|
|
386
|
+
|
|
387
|
+
```bash
|
|
388
|
+
# 在线预览(默认)
|
|
389
|
+
neo preview
|
|
390
|
+
# 等价于
|
|
391
|
+
neo preview -m online
|
|
392
|
+
|
|
393
|
+
# 本地预览
|
|
394
|
+
neo preview -m local
|
|
395
|
+
|
|
396
|
+
# 指定组件名 + 预览模式
|
|
397
|
+
neo preview -n xxCmp -m online
|
|
398
|
+
neo preview -n xxCmp -m local
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
#### 参数说明
|
|
402
|
+
|
|
403
|
+
- `-n` / `--name`:指定要预览的组件名;不传则交互选择或按默认规则处理。
|
|
404
|
+
- `-m` / `--mode`:预览模式,可选 `online`(在线预览,默认)或 `local`(本地预览)。
|
|
405
|
+
|
|
406
|
+
#### 注意事项
|
|
407
|
+
|
|
408
|
+
- 当组件依赖 Neo 平台运行时(如 `neo-ui-common`、`neo-ui-component-web` 等平台能力、接口或上下文)时,本地预览环境无法提供这些虚拟模块,**只能使用在线预览**(`neo preview -m online`)。
|
|
409
|
+
- 若在线预览仍不足以满足在设计器页面上下文中的验证需求,可配合 `neo linkDebug` 外链调试使用(见下文)。
|
|
410
|
+
|
|
411
|
+
### 3. 本地调试自定义组件
|
|
297
412
|
|
|
298
413
|
#### 步骤 1:启动外链调试
|
|
299
414
|
|
|
@@ -311,7 +426,7 @@ neo linkDebug
|
|
|
311
426
|
|
|
312
427
|
在设计器左侧「外部链接」面板中,将上一步输出的脚本地址加入,即可在物料中看到对应自定义组件。
|
|
313
428
|
|
|
314
|
-
###
|
|
429
|
+
### 4. 发布自定义组件至 NeoCRM
|
|
315
430
|
|
|
316
431
|
执行 `neo push cmp` 会构建组件并将资源发布到 NeoCRM(含平台 CDN 流程,以实际环境为准)。
|
|
317
432
|
|
|
@@ -360,7 +475,7 @@ A:核对 `neo.config.js` 中授权字段是否完整、正确。
|
|
|
360
475
|
|
|
361
476
|
发布成功后,可在对应租户下的页面设计器、表单设计器等环境中使用该组件。
|
|
362
477
|
|
|
363
|
-
###
|
|
478
|
+
### 5. 拉取线上组件到本地
|
|
364
479
|
|
|
365
480
|
`neo pull cmp` 会从 NeoCRM 拉取组件源码到当前项目的 `src/components`。
|
|
366
481
|
|
|
@@ -374,7 +489,7 @@ neo pull cmp -n xxCmp
|
|
|
374
489
|
|
|
375
490
|
**注意**:会覆盖本地同名目录;若有新依赖,拉取后按提示执行 `npm install` / `yarn install`;zip 等中间文件可能留在 `.neo-cli/zip-source`,可按需清理。
|
|
376
491
|
|
|
377
|
-
###
|
|
492
|
+
### 6. 删除线上自定义组件
|
|
378
493
|
|
|
379
494
|
`neo delete cmp` 会从 NeoCRM **删除**指定组件,删除后设计器中无法再选用(请谨慎操作)。
|
|
380
495
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("akfun"),s=require("node:path");var t,o;exports.__require=function(){if(o)return t;o=1;const{resolve:a}=e,r=s,i={settings:{enableESLint:!1,enableESLintFix:!1,enableStyleLint:!1,enableStyleLintFix:!1},webpack:{resolve:{extensions:[".js",".jsx",".ts",".tsx",".vue",".min.js",".json"],alias:{"@":a("src")}},createDeclaration:!1,ignoreNodeModules:!1,allowList:[],externals:{},projectDir:["src"],template:(n="../../template/initData/defaultTemplate.html",r.resolve(__dirname,n)),sassResources:[],babelPlugins:[["import",{libraryName:"antd",style:"css"}]],moduleRules:[]},envParams:{common:{"#version#":"20221229.1"},local:{"#dataApiBase#":"http://localhost:1024","#assetsPublicPath#":"http://localhost:1024","#routeBasePath#":"/"},online:{"#dataApiBase#":"/","#assetsPublicPath#":"","#routeBasePath#":"/"}},dev:{NODE_ENV:"development",port:80,autoOpenBrowser:!0,assetsPublicPath:"/",assetsSubDirectory:"",hostname:"localhost",proxyTable:{},cssSourceMap:!0},build:{NODE_ENV:"production",assetsRoot:a("dist"),assetsPublicPath:"/",assetsSubDirectory:"",productionSourceMap:!1,productionGzip:!1,productionGzipExtensions:["js","css","json"],bundleAnalyzerReport:!1},build2lib:{NODE_ENV:"production",libraryName:"",assetsRoot:a("dist"),assetsPublicPath:"/",assetsSubDirectory:"",productionSourceMap:!1,productionGzip:!1,productionGzipExtensions:["js","css","json"],bundleAnalyzerReport:!1},linkDebug:{NODE_ENV:"development",closeHtmlWebpackPlugin:!0,autoOpenBrowser:!1,cssExtract:!1,consoleInfo:"当前自定义组件可用外链地址"},publish2oss:{output:{filename:"[name].js",library:{type:"var",export:"default"},globalObject:"this"},cssExtract:!1,ossType:"ali",ossConfig:{endpoint:"https://oss-cn-beijing.aliyuncs.com",AccessKeyId:"xx",AccessKeySecret:"xx",bucket:"neo-widgets"},assetsRoot:a("dist")},pushCmp:{output:{filename:"[name].js",library:{type:"var",export:"default"},globalObject:"this"},cssExtract:!1,assetsRoot:a("dist")}};var n;return t=i};
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("akfun"),s=require("node:path");var t,o;exports.__require=function(){if(o)return t;o=1;const{resolve:a}=e,r=s,i={settings:{enableESLint:!1,enableESLintFix:!1,enableStyleLint:!1,enableStyleLintFix:!1},webpack:{resolve:{extensions:[".js",".jsx",".ts",".tsx",".vue",".min.js",".json"],alias:{"@":a("src")}},createDeclaration:!1,ignoreNodeModules:!1,allowList:[],externals:{},projectDir:["src"],template:(n="../../template/initData/defaultTemplate.html",r.resolve(__dirname,n)),sassResources:[],babelPlugins:[["import",{libraryName:"antd",style:"css"}]],moduleRules:[]},envParams:{common:{"#version#":"20221229.1"},local:{"#dataApiBase#":"http://localhost:1024","#assetsPublicPath#":"http://localhost:1024","#routeBasePath#":"/"},online:{"#dataApiBase#":"/","#assetsPublicPath#":"","#routeBasePath#":"/"}},componentsDir:"./src/components",dev:{NODE_ENV:"development",port:80,autoOpenBrowser:!0,assetsPublicPath:"/",assetsSubDirectory:"",hostname:"localhost",proxyTable:{},cssSourceMap:!0},build:{NODE_ENV:"production",assetsRoot:a("dist"),assetsPublicPath:"/",assetsSubDirectory:"",productionSourceMap:!1,productionGzip:!1,productionGzipExtensions:["js","css","json"],bundleAnalyzerReport:!1},build2lib:{NODE_ENV:"production",libraryName:"",assetsRoot:a("dist"),assetsPublicPath:"/",assetsSubDirectory:"",productionSourceMap:!1,productionGzip:!1,productionGzipExtensions:["js","css","json"],bundleAnalyzerReport:!1},linkDebug:{NODE_ENV:"development",closeHtmlWebpackPlugin:!0,autoOpenBrowser:!1,cssExtract:!1,consoleInfo:"当前自定义组件可用外链地址"},publish2oss:{output:{filename:"[name].js",library:{type:"var",export:"default"},globalObject:"this"},cssExtract:!1,ossType:"ali",ossConfig:{endpoint:"https://oss-cn-beijing.aliyuncs.com",AccessKeyId:"xx",AccessKeySecret:"xx",bucket:"neo-widgets"},assetsRoot:a("dist")},pushCmp:{output:{filename:"[name].js",library:{type:"var",export:"default"},globalObject:"this"},cssExtract:!1,assetsRoot:a("dist")}};var n;return t=i};
|
package/dist/index2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./_virtual/index.js"),o=require("figlet"),s=require("yargs"),a=require("chalk"),n=require("inquirer"),t=require("ora"),i=require("./main2.js"),p=require("./utils/common.js"),c=require("./neo/env.js"),m=require("./package.json.js");var l;exports.__require=function(){if(l)return e.__exports;l=1;const r=o,u=s,g=a,d=n,h=t,{neoInit:y,neoInitByCopy:v,inspect:b,neoConfigInit:f,validateProjectName:C,getCmpTypeByDir:$,NeoService:x,NeoLoginService:T,hasNeoProject:w,consoleTag:j}=i.__require(),{errorLog:U,successLog:D,warningLog:L}=p.__require(),_=i.__require(),{getNeoCrmAPI:q}=c.__require(),M=m.default,N=r.textSync("neo",{font:"Lean"}),A=_.projectConfig,S=function(e){return g.green(g.bold(e))},R={"config init":"初始化配置文件",config:"初始化配置文件",dev:"开启本地调试模式",build:"构建生产环境代码",build2lib:"构建 UMD 模块",build2esm:"构建 ESM 模块",publish2oss:"发布到 OSS",inspect:"输出配置文件",open:"打开项目"},P={...R,init:"初始化自定义组件项目",login:"登录 NeoCRM 平台",logout:"登出 NeoCRM 平台","create project":"创建自定义组件项目","create cmp":"创建自定义组件",linkDebug:"开启外链调试模式",preview:"预览自定义组件","pull cmp":"拉取线上自定义组件","push cmp":"发布自定义组件到平台","delete cmp":"删除线上自定义组件",pull:"拉取线上自定义组件",push:"发布自定义组件到平台",delete:"删除线上自定义组件"},k=[{name:"线上生产环境(crm.xiaoshouyi.com)",value:"production"},{name:"P20环境(crm-p20.xiaoshouyi.com)",value:"p20"},{name:"沙盒环境(crm-sandbox.xiaoshouyi.com)",value:"sandbox"},{name:"开发环境(crm-cd.xiaoshouyi.com)",value:"cd"},{name:"tencentuat环境(crm-tencentuat.xiaoshouyi.com)",value:"tencentuat"},{name:"自定义环境(在neo.config.js / neoConfig 中自行配置)",value:"custom"}],B=k.map(e=>e.value);return u.middleware(function(e){if(e.help||e.version)return;const o=function(e){if(!e._||0===e._.length)return"";const o=e._.join(" ");if(P[o])return o;const s=e._[0];return P[s]?s:o||s}(e);if(!o)return;const s=P[o]||o;R[o]&&(console.log(g.green(N)),console.log(g.green(`当前版本:v${M.version}.\n`))),console.log(""),console.log(g.cyan(`执行命令: ${s}`)),console.log("")}).command("init [options]","根据模板创建一个自定义组件",e=>{e.usage(S("Usage")+": $0 init [options]").option("type",{alias:"t",describe:"自定义组件类型(react ts 技术栈/ vue2.0 技术栈/ react 技术栈)"}).option("name",{alias:"n",describe:"自定义组件项目名称"}).alias("h","help")},e=>{if(e.type&&e.name)w()&&(U(`${j}创建自定义组件失败,当前目录(${process.cwd()})已经是一个自定义组件项目,请勿重复创建。`),process.exit(1)),"github"===e.mode?y(e.type,e.name):v(e.type,e.name);else{const o=[],s=[{name:"模板1.Web端列表组件: 含基础大列表、Picker 列表等示例组件",value:"neo-web-entity-grid",short:"neo-web-entity-grid"},{name:"模板2.H5端业务组件: 含全局搜索、数据列表、数据Tabs、打开AI对话页等示例组件",value:"neo-h5-cmps",short:"neo-h5-cmps"},{name:"模板3.自定义业务组件: 含实体表单、实体数据详情、实体数据表格等示例组件",value:"neo",short:"neo"},{name:"模板4.数值指标组件: 可配置展示实体数据源中关键数值指标",value:"neo-bi-cmps",short:"neo-bi-cmps"},{name:"模板5.antd 组件: 含基于 Antd 实现的数据仪表板、搜索组件等示例组件",value:"antd",short:"antd"},{name:"模板6.echarts 组件: 含基于 ECharts 实现的图表示例组件",value:"echarts",short:"echarts"},{name:"模板7.地图组件: 含基于 高德地图API 实现的示例组件",value:"amap",short:"amap"},{name:"模板8.vue2 组件: 含基于 Vue2 实现的示例组件",value:"vue2",short:"vue2"}];e.type||o.push({name:"type",type:"list",message:"请选择您要创建的自定义组件类型: ",default:"react-ts",choices:s}),e.name||o.push({name:"name",type:"input",message:"请设置自定义组件项目名称(默认 neoCustomCmp):",default:"neoCustomCmp"}),d.prompt(o).then(o=>{const{isValid:s,errors:a}=C(o.name);s||(U(a.join("\n")),process.exit(1)),"github"===e.mode?y(o.type,o.name):v(o.type,o.name)})}}).command("config init","创建 neo.config.js 配置文件",e=>{e.usage(S("Usage")+": $0 config init").alias("h","help")},()=>{f("neo.config.js")}).command("login","登录 NeoCRM 平台(OAuth2 授权)",e=>{e.usage(S("Usage")+": $0 login [options]").option("env",{alias:"e",describe:"登录环境(可选,不指定则交互选择)。",type:"string",choices:B}).alias("h","help")},async e=>{const o=async e=>{const o=q(e,A.neoConfig);try{const e=new T(o);await e.login(),process.exit(0)}catch(e){U(`\n登录失败: ${e.message||e.msg}`),process.exit(1)}};if(e.env)return void await o(e.env);const s=[{name:"env",type:"list",message:"请选择您要登录的环境:",default:"cd",choices:k}],a=await d.prompt(s);await o(a.env)}).command("logout","登出 NeoCRM 平台",e=>{e.usage(S("Usage")+": $0 logout").alias("h","help")},async()=>{try{const e=new T;await e.logout(),process.exit(0)}catch(e){U(`\n登出失败: ${e.message||e.msg}`),process.exit(1)}}).command("create","创建项目或者组件",e=>e.command("project [options]","创建自定义组件项目(含工程代码)",e=>{e.usage(S("Usage")+": $0 project [options]").option("name",{alias:"n",describe:"自定义组件项目名称"}).alias("h","help")},e=>{if(e.name)_.createCmpProjectByTemplate(e.name);else{const e=[{name:"name",type:"input",message:"请设置自定义组件项目名称:"}];d.prompt(e).then(e=>{const{isValid:o,errors:s}=C(e.name);o||(U(s.join("\n")),process.exit(1)),e.name?_.createCmpProjectByTemplate(e.name):(U("自定义组件项目名称不能为空。"),process.exit(1))})}}).command("cmp [options]","创建自定义组件",e=>{e.usage(S("Usage")+": $0 cmp [options]").option("name",{alias:"n",describe:"自定义组件名称"}).option("targetDevice",{alias:"d",describe:"终端类型(all: 所有端, web: 网页端, mobile: 移动端),不指定则交互选择",choices:["all","web","mobile"]}).alias("h","help")},e=>{const o=[{name:"所有端(all)",value:"all"},{name:"网页端(web)",value:"web"},{name:"移动端(mobile)",value:"mobile"}];if(e.name&&void 0!==e.targetDevice)_.createCmpByTemplate(e.name,{targetDevice:e.targetDevice});else if(e.name){const s=[{name:"targetDevice",type:"list",message:"请选择终端类型:",default:"all",choices:o}];d.prompt(s).then(o=>{_.createCmpByTemplate(e.name,{targetDevice:o.targetDevice})})}else{const e=[{name:"name",type:"input",message:"请设置自定义组件名称:"},{name:"targetDevice",type:"list",message:"请选择终端类型:",default:"all",choices:o}];d.prompt(e).then(e=>{e.name?_.createCmpByTemplate(e.name,{targetDevice:e.targetDevice}):(U("自定义组件名称不能为空。"),process.exit(1))})}})).command("pull cmp [options]","拉取线上自定义组件",e=>{e.usage(S("Usage")+": $0 pull cmp [options]").option("name",{alias:"n",describe:"自定义组件名称"}).alias("h","help")},async e=>{if(e.name){L(`[neo pull cmp] 即将拉取自定义组件:${e.name},如本地已存在同名组件目录,将可能被覆盖,请提前备份本地修改。`);try{await _.pullCmp(e.name)}catch(e){U(e.message||e.msg||"拉取线上自定义组件失败"),process.exit(1)}}else{const e=new x,o=h("正在拉取线上自定义组件列表...").start(),s=await e.getCustomCmpList();0===s.length&&(U("当前租户暂无任何自定义组件。"),process.exit(1)),o.stop("线上自定义组件列表拉取成功。");const a=[{name:"cmpType",type:"list",message:"请选择要拉取的自定义组件:",choices:[{name:"拉取所有组件(ALL)",value:"ALL"},...s.map(e=>({name:`${e.label}(${e.cmpType})`,value:e.cmpType}))]}];try{const o=await d.prompt(a);if(o.cmpType)if("ALL"===o.cmpType){L(`[neo pull cmp] 即将拉取当前租户下的所有自定义组件(共 ${s.length} 个),如本地存在同名组件目录,将可能被覆盖,请提前备份本地修改。`);for(let o=0,a=s.length;o<a;o++){const n=s[o];console.log(g.gray(`[neo pull cmp] 正在拉取第 ${o+1}/${a} 个组件: ${n.cmpType}`)),await _.pullCmp(n.cmpType,e)}D("[neo pull cmp]拉取所有组件命令已执行完成。")}else L(`[neo pull cmp] 即将拉取自定义组件:${o.cmpType},如本地已存在同名组件目录,将可能被覆盖,请提前备份本地修改。`),await _.pullCmp(o.cmpType,e);else U("请选择要拉取的自定义组件。"),process.exit(1)}catch(e){U(e.message||e.msg||"拉取线上自定义组件失败"),process.exit(1)}}}).command("delete cmp [options]","删除线上自定义组件",e=>{e.usage(S("Usage")+": $0 delete cmp [options]").option("name",{alias:"n",describe:"自定义组件名称"}).alias("h","help")},async e=>{if(e.name)_.deleteCmp(e.name);else{const e=new x,o=h("正在获取线上自定义组件列表...").start(),s=await e.getCustomCmpList();0===s.length&&(U("当前租户暂无任何自定义组件。"),process.exit(1)),o.stop("线上自定义组件列表获取成功。");const a=[{name:"cmpType",type:"list",message:"请选择要删除的自定义组件:",choices:s.map(e=>({name:`${e.label}(${e.cmpType})`,value:e.cmpType}))}];d.prompt(a).then(o=>{o.cmpType?_.deleteCmp(o.cmpType,e):(U("自定义组件名称不能为空。"),process.exit(1))})}}).command("preview [options]","预览指定自定义组件(仅预览组件本身内容)",e=>{e.usage(S("Usage")+": $0 preview [options]").option("name",{alias:"n",describe:"自定义组件名称"}).alias("h","help")},e=>{if(e.name)_.previewCmp(e.name);else{const e=$(A.componentsDir);0===e.length&&(U("当前自定义组件目录中未找到自定义组件。(./src/components 目录下)"),process.exit(1));const o=[{name:"cmpType",type:"list",message:"请选择要预览的自定义组件:",choices:e.map(e=>({name:e,value:e}))}];d.prompt(o).then(e=>{e.cmpType||(U("未选择要预览的自定义组件。"),process.exit(1)),_.previewCmp(e.cmpType)})}}).command("dev","开启本地调试模式",e=>{e.usage(S("Usage")+": $0 dev").alias("h","help")},()=>{_.dev()}).command("linkDebug","开启外链调试模式(在线上页面设计器端调试)",e=>{e.usage(S("Usage")+": $0 linkDebug [options]").option("platform",{alias:"p",describe:"调试设备类型:pc(网页端)、h5(移动端),默认 pc",type:"string",choices:["pc","h5"]}).alias("h","help")},e=>{const o=e=>{_.linkDebug({platform:e})};e.platform?o(e.platform):d.prompt([{name:"platform",type:"list",message:"请选择调试设备类型:",default:"pc",choices:[{name:"网页端(PC)",value:"pc",short:"pc"},{name:"移动端(H5)",value:"h5",short:"h5"}]}]).then(e=>{e.platform||(U("未选择调试设备类型。"),process.exit(1)),o(e.platform)})}).command("build","构建生产环境代码",e=>{e.usage(S("Usage")+": $0 build").alias("h","help")},e=>{_.build()}).command("build2lib","构建 UMD 模块",e=>{e.usage(S("Usage")+": $0 build2lib").alias("h","help")},e=>{_.build2lib()}).command("publish2oss [options]","发布到oss",e=>{e.usage(S("Usage")+": $0 publish2oss [options]").option("name",{alias:"n",describe:"自定义组件名称"}).alias("h","help")},e=>{if(e.name)_.publish2oss(e.name);else{const e=$(A.componentsDir);0===e.length&&(U("当前自定义组件目录中未找到自定义组件。(./src/components 目录下)"),process.exit(1));const o=[{name:"cmpType",type:"list",message:"请选择要发布的自定义组件:",choices:e.map(e=>({name:e,value:e}))}];d.prompt(o).then(e=>{e.cmpType||(U("未选择要发布的自定义组件。"),process.exit(1)),_.publish2oss(e.cmpType)})}}).command("push cmp [options]","构建并发布自定义组件到 NeoCRM 平台",e=>{e.usage(S("Usage")+": $0 push cmp [options]").option("name",{alias:"n",describe:"自定义组件名称"}).alias("h","help")},async e=>{if(e.name){L(`[neo push cmp] 即将构建并发布自定义组件:${e.name} 到 NeoCRM 平台,请确保已经通过 neo login 登录到正确的环境。`);try{await _.pushCmp(e.name)}catch(e){U(e.message||e.msg||"发布自定义组件失败"),process.exit(1)}}else{const e=$(A.componentsDir);0===e.length&&(U("当前自定义组件目录中未找到自定义组件。(./src/components 目录下)"),process.exit(1));const o=[{name:"cmpType",type:"list",message:"请选择要发布的自定义组件:",choices:[{name:"发布所有组件(ALL)",value:"ALL"},...e.map(e=>({name:e,value:e}))]}];d.prompt(o).then(async o=>{o.cmpType||(U("请选择要发布的自定义组件。"),process.exit(1));try{if("ALL"===o.cmpType){L(`[neo push cmp] 即将构建并发布当前目录下的所有自定义组件(共 ${e.length} 个)到 NeoCRM 平台,请确保已经通过 neo login 登录到正确的环境。`);for(let o=0,s=e.length;o<s;o++){const a=e[o];console.log(g.gray(`[neo push cmp] 正在发布第 ${o+1}/${s} 个组件: ${a}`)),await _.pushCmp(a,!0)}D("[neo push cmp]发布所有组件命令已执行完成。")}else L(`[neo push cmp] 即将构建并发布自定义组件:${o.cmpType} 到 NeoCRM 平台,请确保已经通过 neo login 登录到正确的环境。`),await _.pushCmp(o.cmpType)}catch(e){U(e.message||e.msg||"发布失败"),process.exit(1)}})}}).command("build2esm","构建 ESM 模块",e=>{e.usage(S("Usage")+": $0 build2esm").alias("h","help")},()=>{_.build2esm()}).command("inspect","输出当前配置文件",e=>{e.usage(S("Usage")+": $0 inspect").option("type",{alias:"t",describe:"环境类型(本地调试环境/生产环境/library构建环境)",default:"build"}).alias("h","help")},e=>{b(e.type)}).command("open [options]","使用 Cursor 或 VSCode 打开项目",e=>{e.usage(S("Usage")+": $0 open [options]").option("editor",{alias:"e",describe:"编辑器类型(cursor/vscode/auto),默认为 auto(自动检测)",default:"auto",choices:["cursor","vscode","code","auto"]}).option("name",{alias:"n",describe:"要打开的项目名称,默认为当前目录"}).alias("h","help")},e=>{_.openEditor(e.editor,e.name)}).alias("h","help").alias("v","version").strict().fail((e,o,s)=>{U(`\n运行命令时发生错误: ${e}。\n`),console.log(S("当前可用命令列表:")),console.log("");[{cmd:"init [options]",desc:"根据模板创建一个自定义组件"},{cmd:"create project [options]",desc:"创建自定义组件项目(含工程代码)"},{cmd:"create cmp [options]",desc:"创建自定义组件"},{cmd:"preview [options]",desc:"预览指定自定义组件(仅预览组件本身内容)"},{cmd:"linkDebug [options]",desc:"开启外链调试模式(在线上页面设计器端调试),支持 --platform pc|h5,默认网页端"},{cmd:"login [options]",desc:"登录 NeoCRM 平台(OAuth2 授权),支持 --env cd|uat|cd"},{cmd:"logout",desc:"登出 NeoCRM 平台"},{cmd:"pull cmp [options]",desc:"拉取线上自定义组件"},{cmd:"delete cmp [options]",desc:"删除线上自定义组件"},{cmd:"push cmp [options]",desc:"构建并发布自定义组件到 NeoCRM 平台"},{cmd:"open [options]",desc:"使用 Cursor 或 VSCode 打开项目"}].forEach(({cmd:e,desc:o})=>{console.log(` ${g.cyan(e.padEnd(25))} ${o}`)}),console.log(""),console.log(`使用 ${g.cyan("neo <command> --help")} 查看具体命令的帮助信息。`),console.log(""),process.exit(1)}).help().updateStrings({"Usage:":S("Usage:"),"Commands:":S("Commands:"),"Options:":S("Options:")}).parseAsync().catch(e=>{e&&(U(`\n运行命令时发生错误: ${e.message||e}。\n`),process.exit(1))}),e.__exports};
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./_virtual/index.js"),s=require("figlet"),o=require("yargs"),a=require("chalk"),t=require("inquirer"),i=require("ora"),n=require("./main2.js"),c=require("./utils/common.js"),p=require("./neo/env.js"),l=require("./utils/skillUtils/skillDirs.js"),m=require("./package.json.js");var r;exports.__require=function(){if(r)return e.__exports;r=1;const u=s,d=o,g=a,h=t,y=i,{neoInit:v,neoInitByCopy:b,inspect:f,neoConfigInit:C,validateProjectName:x,getCmpTypeByDir:w,NeoService:$,NeoLoginService:k,hasNeoProject:T,consoleTag:U}=n.__require(),{errorLog:_,successLog:D,warningLog:L}=c.__require(),j=n.__require(),{getNeoCrmAPI:S}=p.__require(),{SKILL_PRODUCT_CHOICES:q,SKILL_PRODUCT_VALUES:A}=l.__require(),M=m.default,N=u.textSync("neo",{font:"Lean"}),P=j.projectConfig,R=function(e){return g.green(g.bold(e))},I={"config init":"初始化配置文件",config:"初始化配置文件",dev:"开启本地调试模式",build:"构建生产环境代码",build2lib:"构建 UMD 模块",build2esm:"构建 ESM 模块",publish2oss:"发布到 OSS",inspect:"输出配置文件",open:"打开项目"},O={...I,init:"初始化自定义组件项目",login:"登录 NeoCRM 平台",logout:"登出 NeoCRM 平台","create project":"创建自定义组件项目","create cmp":"创建自定义组件",linkDebug:"开启外链调试模式",preview:"预览自定义组件","pull cmp":"拉取线上自定义组件","push cmp":"发布自定义组件到平台","delete cmp":"删除线上自定义组件",pull:"拉取线上自定义组件",push:"发布自定义组件到平台",delete:"删除线上自定义组件","add cli-skills":"安装组件开发技能包","remove cli-skills":"移除组件开发技能包","update cli-skills":"更新组件开发技能包",add:"安装组件开发技能包",remove:"移除组件开发技能包",update:"更新组件开发技能包"},B=[{name:"线上生产环境(crm.xiaoshouyi.com)",value:"production"},{name:"P20环境(crm-p20.xiaoshouyi.com)",value:"p20"},{name:"沙盒环境(crm-sandbox.xiaoshouyi.com)",value:"sandbox"},{name:"开发环境(crm-cd.xiaoshouyi.com)",value:"cd"},{name:"tencentuat环境(crm-tencentuat.xiaoshouyi.com)",value:"tencentuat"},{name:"自定义环境(在neo.config.js / neoConfig 中自行配置)",value:"custom"}],E=B.map(e=>e.value);return d.middleware(function(e){if(e.help||e.version)return;const s=function(e){if(!e._||0===e._.length)return"";const s=e._.join(" ");if(O[s])return s;const o=e._[0];return O[o]?o:s||o}(e);if(!s)return;const o=O[s]||s;I[s]&&(console.log(g.green(N)),console.log(g.green(`当前版本:v${M.version}.\n`))),console.log(""),console.log(g.cyan(`执行命令: ${o}`)),console.log("")}).command("init [options]","根据模板创建一个自定义组件",e=>{e.usage(R("Usage")+": $0 init [options]").option("type",{alias:"t",describe:"自定义组件类型(react ts 技术栈/ vue2.0 技术栈/ react 技术栈)"}).option("name",{alias:"n",describe:"自定义组件项目名称"}).alias("h","help")},e=>{if(e.type&&e.name)T()&&(_(`${U}创建自定义组件失败,当前目录(${process.cwd()})已经是一个自定义组件项目,请勿重复创建。`),process.exit(1)),"github"===e.mode?v(e.type,e.name):b(e.type,e.name);else{const s=[],o=[{name:"模板1.Web端列表组件: 含基础大列表、Picker 列表等示例组件",value:"neo-web-entity-grid",short:"neo-web-entity-grid"},{name:"模板2.H5端业务组件: 含全局搜索、数据列表、数据Tabs、打开AI对话页等示例组件",value:"neo-h5-cmps",short:"neo-h5-cmps"},{name:"模板3.自定义业务组件: 含实体表单、实体数据详情、实体数据表格等示例组件",value:"neo",short:"neo"},{name:"模板4.数值指标组件: 可配置展示实体数据源中关键数值指标",value:"neo-bi-cmps",short:"neo-bi-cmps"},{name:"模板5.antd 组件: 含基于 Antd 实现的数据仪表板、搜索组件等示例组件",value:"antd",short:"antd"},{name:"模板6.echarts 组件: 含基于 ECharts 实现的图表示例组件",value:"echarts",short:"echarts"},{name:"模板7.地图组件: 含基于 高德地图API 实现的示例组件",value:"amap",short:"amap"},{name:"模板8.vue2 组件: 含基于 Vue2 实现的示例组件",value:"vue2",short:"vue2"}];e.type||s.push({name:"type",type:"list",message:"请选择您要创建的自定义组件类型: ",default:"react-ts",choices:o}),e.name||s.push({name:"name",type:"input",message:"请设置自定义组件项目名称(默认 neoCustomCmp):",default:"neoCustomCmp"}),h.prompt(s).then(s=>{const{isValid:o,errors:a}=x(s.name);o||(_(a.join("\n")),process.exit(1)),"github"===e.mode?v(s.type,s.name):b(s.type,s.name)})}}).command("config init","创建 neo.config.js 配置文件",e=>{e.usage(R("Usage")+": $0 config init").alias("h","help")},()=>{C("neo.config.js")}).command("login","登录 NeoCRM 平台(OAuth2 授权)",e=>{e.usage(R("Usage")+": $0 login [options]").option("env",{alias:"e",describe:"登录环境(可选,不指定则交互选择)。",type:"string",choices:E}).alias("h","help")},async e=>{const s=async e=>{const s=S(e,P.neoConfig);try{const e=new k(s);await e.login(),process.exit(0)}catch(e){_(`\n登录失败: ${e.message||e.msg}`),process.exit(1)}};if(e.env)return void await s(e.env);const o=[{name:"env",type:"list",message:"请选择您要登录的环境:",default:"cd",choices:B}],a=await h.prompt(o);await s(a.env)}).command("logout","登出 NeoCRM 平台",e=>{e.usage(R("Usage")+": $0 logout").alias("h","help")},async()=>{try{const e=new k;await e.logout(),process.exit(0)}catch(e){_(`\n登出失败: ${e.message||e.msg}`),process.exit(1)}}).command("create","创建项目或者组件",e=>e.command("project [options]","创建自定义组件项目(含工程代码)",e=>{e.usage(R("Usage")+": $0 project [options]").option("name",{alias:"n",describe:"自定义组件项目名称"}).alias("h","help")},e=>{if(e.name)j.createCmpProjectByTemplate(e.name);else{const e=[{name:"name",type:"input",message:"请设置自定义组件项目名称:"}];h.prompt(e).then(e=>{const{isValid:s,errors:o}=x(e.name);s||(_(o.join("\n")),process.exit(1)),e.name?j.createCmpProjectByTemplate(e.name):(_("自定义组件项目名称不能为空。"),process.exit(1))})}}).command("cmp [options]","创建自定义组件",e=>{e.usage(R("Usage")+": $0 cmp [options]").option("name",{alias:"n",describe:"自定义组件名称"}).option("targetDevice",{alias:"d",describe:"终端类型(all: 所有端, web: 网页端, mobile: 移动端),不指定则交互选择",choices:["all","web","mobile"]}).alias("h","help")},e=>{const s=[{name:"所有端(all)",value:"all"},{name:"网页端(web)",value:"web"},{name:"移动端(mobile)",value:"mobile"}];if(e.name&&void 0!==e.targetDevice)j.createCmpByTemplate(e.name,{targetDevice:e.targetDevice});else if(e.name){const o=[{name:"targetDevice",type:"list",message:"请选择终端类型:",default:"all",choices:s}];h.prompt(o).then(s=>{j.createCmpByTemplate(e.name,{targetDevice:s.targetDevice})})}else{const e=[{name:"name",type:"input",message:"请设置自定义组件名称:"},{name:"targetDevice",type:"list",message:"请选择终端类型:",default:"all",choices:s}];h.prompt(e).then(e=>{e.name?j.createCmpByTemplate(e.name,{targetDevice:e.targetDevice}):(_("自定义组件名称不能为空。"),process.exit(1))})}})).command("pull cmp [options]","拉取线上自定义组件",e=>{e.usage(R("Usage")+": $0 pull cmp [options]").option("name",{alias:"n",describe:"自定义组件名称"}).alias("h","help")},async e=>{if(e.name){L(`[neo pull cmp] 即将拉取自定义组件:${e.name},如本地已存在同名组件目录,将可能被覆盖,请提前备份本地修改。`);try{await j.pullCmp(e.name)}catch(e){_(e.message||e.msg||"拉取线上自定义组件失败"),process.exit(1)}}else{const e=new $,s=y("正在拉取线上自定义组件列表...").start(),o=await e.getCustomCmpList();0===o.length&&(_("当前租户暂无任何自定义组件。"),process.exit(1)),s.stop("线上自定义组件列表拉取成功。");const a=[{name:"cmpType",type:"list",message:"请选择要拉取的自定义组件:",choices:[{name:"拉取所有组件(ALL)",value:"ALL"},...o.map(e=>({name:`${e.label}(${e.cmpType})`,value:e.cmpType}))]}];try{const s=await h.prompt(a);if(s.cmpType)if("ALL"===s.cmpType){L(`[neo pull cmp] 即将拉取当前租户下的所有自定义组件(共 ${o.length} 个),如本地存在同名组件目录,将可能被覆盖,请提前备份本地修改。`);for(let s=0,a=o.length;s<a;s++){const t=o[s];console.log(g.gray(`[neo pull cmp] 正在拉取第 ${s+1}/${a} 个组件: ${t.cmpType}`)),await j.pullCmp(t.cmpType,e)}D("[neo pull cmp]拉取所有组件命令已执行完成。")}else L(`[neo pull cmp] 即将拉取自定义组件:${s.cmpType},如本地已存在同名组件目录,将可能被覆盖,请提前备份本地修改。`),await j.pullCmp(s.cmpType,e);else _("请选择要拉取的自定义组件。"),process.exit(1)}catch(e){_(e.message||e.msg||"拉取线上自定义组件失败"),process.exit(1)}}}).command("delete cmp [options]","删除线上自定义组件",e=>{e.usage(R("Usage")+": $0 delete cmp [options]").option("name",{alias:"n",describe:"自定义组件名称"}).alias("h","help")},async e=>{if(e.name)j.deleteCmp(e.name);else{const e=new $,s=y("正在获取线上自定义组件列表...").start(),o=await e.getCustomCmpList();0===o.length&&(_("当前租户暂无任何自定义组件。"),process.exit(1)),s.stop("线上自定义组件列表获取成功。");const a=[{name:"cmpType",type:"list",message:"请选择要删除的自定义组件:",choices:o.map(e=>({name:`${e.label}(${e.cmpType})`,value:e.cmpType}))}];h.prompt(a).then(s=>{s.cmpType?j.deleteCmp(s.cmpType,e):(_("自定义组件名称不能为空。"),process.exit(1))})}}).command("preview [options]","预览指定自定义组件(本地仅组件内容)",e=>{e.usage(R("Usage")+": $0 preview [options]").option("name",{alias:"n",describe:"自定义组件名称"}).option("mode",{alias:"m",describe:"预览模式:local(本地预览)、online(在线预览)",type:"string",choices:["local","online"]}).alias("h","help")},async e=>{const s=w(P.componentsDir);0===s.length&&(_("当前自定义组件目录中未找到自定义组件(./src/components 目录下)。"),process.exit(1));let o=e.name,a=e.mode;if(!o){const e=s.map(e=>({name:e,value:e})),a=await h.prompt([{name:"cmpType",type:"list",message:"请选择要预览的自定义组件:",choices:e}]);a.cmpType||(_("未选择要预览的自定义组件。"),process.exit(1)),o=a.cmpType}if(s.includes(o)||(_(`组件目录中未找到「${o}」自定义组件。`),process.exit(1)),!a){const e=await h.prompt([{name:"mode",type:"list",message:"请选择预览模式:",default:"online",choices:[{name:"在线预览(需登录授权)",value:"online",short:"online"},{name:"本地预览",value:"local",short:"local"}]}]);e.mode||(_("未选择预览模式。"),process.exit(1)),a=e.mode}"online"===a?j.linkPreview({cmpType:o}):j.previewCmp(o)}).command("dev","开启本地调试模式",e=>{e.usage(R("Usage")+": $0 dev").alias("h","help")},()=>{j.dev()}).command("linkDebug","开启外链调试模式(在线上页面设计器端调试)",e=>{e.usage(R("Usage")+": $0 linkDebug [options]").option("platform",{alias:"p",describe:"调试设备类型:pc(网页端)、h5(移动端),默认 pc",type:"string",choices:["pc","h5"]}).alias("h","help")},e=>{const s=e=>{j.linkDebug({platform:e})};e.platform?s(e.platform):h.prompt([{name:"platform",type:"list",message:"请选择调试设备类型:",default:"pc",choices:[{name:"网页端(PC)",value:"pc",short:"pc"},{name:"移动端(H5)",value:"h5",short:"h5"}]}]).then(e=>{e.platform||(_("未选择调试设备类型。"),process.exit(1)),s(e.platform)})}).command("build","构建生产环境代码",e=>{e.usage(R("Usage")+": $0 build").alias("h","help")},e=>{j.build()}).command("build2lib","构建 UMD 模块",e=>{e.usage(R("Usage")+": $0 build2lib").alias("h","help")},e=>{j.build2lib()}).command("publish2oss [options]","发布到oss",e=>{e.usage(R("Usage")+": $0 publish2oss [options]").option("name",{alias:"n",describe:"自定义组件名称"}).alias("h","help")},e=>{if(e.name)j.publish2oss(e.name);else{const e=w(P.componentsDir);0===e.length&&(_("当前自定义组件目录中未找到自定义组件。(./src/components 目录下)"),process.exit(1));const s=[{name:"cmpType",type:"list",message:"请选择要发布的自定义组件:",choices:e.map(e=>({name:e,value:e}))}];h.prompt(s).then(e=>{e.cmpType||(_("未选择要发布的自定义组件。"),process.exit(1)),j.publish2oss(e.cmpType)})}}).command("push cmp [options]","构建并发布自定义组件到 NeoCRM 平台",e=>{e.usage(R("Usage")+": $0 push cmp [options]").option("name",{alias:"n",describe:"自定义组件名称"}).alias("h","help")},async e=>{if(e.name){L(`[neo push cmp] 即将构建并发布自定义组件:${e.name} 到 NeoCRM 平台,请确保已经通过 neo login 登录到正确的环境。`);try{await j.pushCmp(e.name)}catch(e){_(e.message||e.msg||"发布自定义组件失败"),process.exit(1)}}else{const e=w(P.componentsDir);0===e.length&&(_("当前自定义组件目录中未找到自定义组件。(./src/components 目录下)"),process.exit(1));const s=[{name:"cmpType",type:"list",message:"请选择要发布的自定义组件:",choices:[{name:"发布所有组件(ALL)",value:"ALL"},...e.map(e=>({name:e,value:e}))]}];h.prompt(s).then(async s=>{s.cmpType||(_("请选择要发布的自定义组件。"),process.exit(1));try{if("ALL"===s.cmpType){L(`[neo push cmp] 即将构建并发布当前目录下的所有自定义组件(共 ${e.length} 个)到 NeoCRM 平台,请确保已经通过 neo login 登录到正确的环境。`);for(let s=0,o=e.length;s<o;s++){const a=e[s];console.log(g.gray(`[neo push cmp] 正在发布第 ${s+1}/${o} 个组件: ${a}`)),await j.pushCmp(a,!0)}D("[neo push cmp]发布所有组件命令已执行完成。")}else L(`[neo push cmp] 即将构建并发布自定义组件:${s.cmpType} 到 NeoCRM 平台,请确保已经通过 neo login 登录到正确的环境。`),await j.pushCmp(s.cmpType)}catch(e){_(e.message||e.msg||"发布失败"),process.exit(1)}})}}).command("build2esm","构建 ESM 模块",e=>{e.usage(R("Usage")+": $0 build2esm").alias("h","help")},()=>{j.build2esm()}).command("inspect","输出当前配置文件",e=>{e.usage(R("Usage")+": $0 inspect").option("type",{alias:"t",describe:"环境类型(本地调试环境/生产环境/library构建环境)",default:"build"}).alias("h","help")},e=>{f(e.type)}).command("open [options]","使用 Cursor 或 VSCode 打开项目",e=>{e.usage(R("Usage")+": $0 open [options]").option("editor",{alias:"e",describe:"编辑器类型(codebuddy/kiro/cursor/vscode/auto),默认为 auto(按 codebuddy > kiro > cursor > vscode 的优先级自动检测)",default:"auto",choices:["codebuddy","kiro","cursor","vscode","code","auto"]}).option("name",{alias:"n",describe:"要打开的项目名称,默认为当前目录"}).alias("h","help")},e=>{j.openEditor(e.editor,e.name)}).command("add cli-skills","安装组件开发技能包(Skills)到指定产品(codebuddy/kiro/cursor/claudeCode)",e=>{e.usage(R("Usage")+": $0 add cli-skills [options]").option("product",{alias:"p",describe:"目标产品(codebuddy/kiro/cursor/claudeCode),不指定则交互选择",type:"string",choices:A}).alias("h","help")},async e=>{const s=async e=>{try{await j.installSkills(e),process.exit(0)}catch(e){_(e.message||e.msg||"安装技能包失败"),process.exit(1)}};if(e.product)return void await s(e.product);const o=await h.prompt([{name:"product",type:"list",message:"请选择要安装技能包的目标产品:",choices:q}]);o.product||(_("未选择目标产品。"),process.exit(1)),await s(o.product)}).command("remove cli-skills","移除指定产品下的组件开发技能包(neo-cmp-cli / neo-cmp-dev / vue-to-react)",e=>{e.usage(R("Usage")+": $0 remove cli-skills [options]").option("product",{alias:"p",describe:"目标产品(codebuddy/kiro/cursor/claudeCode),不指定则交互选择",type:"string",choices:A}).option("skills",{alias:"s",describe:"额外要移除的 skills 名称列表(字符串数组),将与内置默认要移除的列表合并后执行移除",type:"array",default:[]}).alias("h","help")},async e=>{const s=(o=e.skills,Array.isArray(o)?Array.from(new Set(o.map(e=>"string"==typeof e?e.trim():"").filter(Boolean))):[]);var o;const a=async e=>{try{await j.removeSkills(e,s),process.exit(0)}catch(e){_(e.message||e.msg||"移除技能包失败"),process.exit(1)}};if(e.product)return void await a(e.product);const t=await h.prompt([{name:"product",type:"list",message:"请选择要移除技能包的目标产品:",choices:q}]);t.product||(_("未选择目标产品。"),process.exit(1)),await a(t.product)}).command("update cli-skills","更新指定产品下的组件开发技能包(覆盖式 copy neo-cmp-cli / neo-cmp-dev / vue-to-react / frontend-design)",e=>{e.usage(R("Usage")+": $0 update cli-skills [options]").option("product",{alias:"p",describe:"目标产品(codebuddy/kiro/cursor/claudeCode),不指定则交互选择",type:"string",choices:A}).alias("h","help")},async e=>{const s=async e=>{try{await j.updateSkills(e),process.exit(0)}catch(e){_(e.message||e.msg||"更新技能包失败"),process.exit(1)}};if(e.product)return void await s(e.product);const o=await h.prompt([{name:"product",type:"list",message:"请选择要更新技能包的目标产品:",choices:q}]);o.product||(_("未选择目标产品。"),process.exit(1)),await s(o.product)}).alias("h","help").alias("v","version").strict().fail((e,s,o)=>{_(`\n运行命令时发生错误: ${e}。\n`),console.log(R("当前可用命令列表:")),console.log("");[{cmd:"init [options]",desc:"根据模板创建一个自定义组件"},{cmd:"create project [options]",desc:"创建自定义组件项目(含工程代码)"},{cmd:"create cmp [options]",desc:"创建自定义组件"},{cmd:"preview [options]",desc:"预览自定义组件;支持 --mode local|online,在线预览走设计器(同 linkPreview)"},{cmd:"linkDebug [options]",desc:"开启外链调试模式(在线上页面设计器端调试),支持 --platform pc|h5,默认网页端"},{cmd:"login [options]",desc:"登录 NeoCRM 平台(OAuth2 授权),支持 --env cd|uat|cd"},{cmd:"logout",desc:"登出 NeoCRM 平台"},{cmd:"pull cmp [options]",desc:"拉取线上自定义组件"},{cmd:"delete cmp [options]",desc:"删除线上自定义组件"},{cmd:"push cmp [options]",desc:"构建并发布自定义组件到 NeoCRM 平台"},{cmd:"open [options]",desc:"使用 Cursor 或 VSCode 打开项目"},{cmd:"add cli-skills [options]",desc:"安装组件开发技能包到指定产品"},{cmd:"update cli-skills [options]",desc:"更新指定产品下的组件开发技能包"},{cmd:"remove cli-skills [options]",desc:"移除指定产品下的组件开发技能包"}].forEach(({cmd:e,desc:s})=>{console.log(` ${g.cyan(e.padEnd(25))} ${s}`)}),console.log(""),console.log(`使用 ${g.cyan("neo <command> --help")} 查看具体命令的帮助信息。`),console.log(""),process.exit(1)}).help().updateStrings({"Usage:":R("Usage:"),"Commands:":R("Commands:"),"Options:":R("Options:")}).parseAsync().catch(e=>{e&&(_(`\n运行命令时发生错误: ${e.message||e}。\n`),process.exit(1))}),e.__exports};
|
package/dist/main2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("akfun");require("lodash");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("akfun"),r=require("node:path");require("lodash");const i=require("open"),s=require("./module/neoInit.js"),t=require("./module/neoInitByCopy.js"),o=require("./module/inspect.js"),l=require("./utils/neoConfigInit.js"),n=require("./utils/neoParams.js"),u=require("./config/index.js"),p=require("./oss/publish2oss.js"),c=require("./neo/pushCmp.js"),d=require("./neo/pullCmp.js"),a=require("./neo/deleteCmp.js"),m=require("./utils/cmpUtils/previewCmp.js"),b=require("./utils/generateEntries.js"),y=require("./utils/cmpUtils/createCmpByTemplate.js"),g=require("./utils/projectUtils/createCmpProjectByTemplate.js"),q=require("./utils/projectUtils/openProject.js"),_=require("./utils/skillUtils/skillManager.js"),v=require("./utils/configureNeoBuild.js"),j=require("./utils/common.js"),T=require("./utils/projectNameValidator.js"),f=require("./utils/cmpUtils/getCmpTypeByDir.js"),x=require("./neo/neoService.js"),C=require("./neo/neoLogin.js"),w=require("./neo/neoEnvManager.js"),h=require("./utils/projectUtils/hasNeoProject.js"),k=require("./utils/pathUtils.js"),D=require("./neo/getCmpPreviewSchema.js");var S,E;exports.__require=function(){if(E)return S;E=1;const N=e,P=r,$=i,M=s.__require(),U=t.__require(),B=o.__require(),L=l.__require(),{consoleTag:O}=n.__require(),R=u.__require(),I=p.__require(),A=c.__require(),H=d.__require(),J=a.__require(),K=m.__require(),V=b.__require(),z=y.__require(),F=g.__require(),G=q.__require(),{installSkills:Q,updateSkills:W,removeSkills:X}=_.__require(),{configureNeoBuild:Y}=v.__require(),{errorLog:Z,successLog:ee,warningLog:re}=j.__require(),{validateProjectName:ie}=T.__require(),se=f.__require(),te=x.__require(),oe=C.__require(),le=w.__require(),ne=h.__require(),{resolveToCurrentRoot:ue}=k.__require(),{getCmpPreviewSchema:pe}=D.__require();function ce(e,r){const{entryType:i,cmpType:s}=r;let t=[],o={};try{const{entries:r,cmpTypes:l,defaultExports:n}=V({configEntry:e.entry,disableAutoRegister:e.disableAutoRegister,componentsDir:R.componentsDir,entryType:i,cmpType:s});r&&Object.keys(r).length>0&&(e.entry=r,t=l,console.info("已自动生成 entry 入口配置:",r)),o=n}catch(e){Z(e.message||e.msg),process.exit(1)}return{cmpTypes:t,defaultExports:o}}function de(e){return Object.assign(R.build2lib,e)}const ae=async e=>{try{await $(e)}catch(r){Z(`无法自动打开浏览器: ${r.message||r.msg}`),console.log(`\n请手动访问以下 URL 进行调试:\n${e}\n`)}};return S={neoInit:M,neoInitByCopy:U,inspect:B,neoConfigInit:L,projectConfig:R,consoleTag:O,validateProjectName:ie,getCmpTypeByDir:se,NeoService:te,NeoLoginService:oe,hasNeoProject:ne,createCmpProjectByTemplate:F,createCmpByTemplate:z,dev:()=>{R.dev||(Z("未找到 dev 相关配置。"),process.exit(1)),N.dev(R,O)},previewCmp:e=>{e||(Z("请输入要预览的组件名称。"),process.exit(1)),R.dev=Object.assign(R.dev,R.preview),R.dev||(Z("未找到预览相关配置。"),process.exit(1)),delete R.preview,K(R,e)},linkDebug:(e={})=>{const r="h5"===e.platform?"h5":"pc",i="pc"===r?"web":"h5";R.linkDebug||(Z("未找到 debug 相关配置。"),process.exit(1)),R.dev=Object.assign(R.dev,R.linkDebug),delete R.linkDebug,delete R.dev.ignoreNodeModules,R.webpack.ignoreNodeModules=!1;const{cmpTypes:s,defaultExports:t}=ce(R.dev,{entryType:"linkDebug"});Y(R,R.dev,{cmpTypes:s,defaultExports:t,verbose:!0,excludeModel:!1});const o=le.getLinKDebugURL(i),l="pc"===r?"网页端(PC)":"移动端(H5)";N.dev(R,O,e=>{if(e&&e.url){const r=`${o}&linkDebug=${e.url}`;console.info(`\n[外链调试] 当前调试设备:${l}\n可打开以下页面设计器地址进行调试:\n${r}\n`),ae(r)}})},linkPreview:(e={})=>{const{cmpType:r,ignoreEntry:i=!1}=e;r||(Z("请输入要在线预览的组件名称。"),process.exit(1)),R.dev=Object.assign(R.dev,R.preview),delete R.preview,R.dev||(Z("未找到预览相关配置。"),process.exit(1)),delete R.dev.ignoreNodeModules,R.webpack.ignoreNodeModules=!1,i&&(R.dev.entry={});const{cmpTypes:s,defaultExports:t}=ce(R.dev,{entryType:"linkDebug",cmpType:r});Y(R,R.dev,{cmpTypes:s,defaultExports:t,verbose:!0,excludeModel:!0});const o=le.getLinkPreviewURL();N.dev(R,O,async e=>{if(e&&e.url){let i=`${o}&linkDebug=${e.url}`,s={cmpType:`${r}_temp`};if(R.dev&&R.dev.previewDefaultSchema)s={...s,...R.dev.previewDefaultSchema};else try{const e=ue(R.componentsDir||"./src/components"),i=P.join(e,r),t=await pe(i);t?s=Object.assign(s,t):re(`未获取到自定义组件模型信息(${r})。`)}catch(e){console.warn(e),re(`获取自定义组件模型信息失败: ${e.message||e.msg}`)}i=`${i}&previewSchema=${JSON.stringify(s)}`,console.info(`\n[在线预览] 组件:${r}\n可打开以下页面设计器地址进行预览:\n${i}\n`),ae(i)}})},build:()=>N.build("build",R,O),build2lib:()=>{ce(R.build2lib,{entryType:"widget"}),R.build2lib.removeNeoCommonModules&&Y(R,R.build2lib,{cmpTypes:[],defaultExports:[],verbose:!1,excludeModel:!0}),N.build("lib",R,O)},publish2oss:e=>{const r=R.publish2oss;R.build2lib=de(r);const{cmpTypes:i,defaultExports:s}=ce(R.build2lib,{entryType:"widget",cmpType:e});Y(R,R.build2lib,{cmpTypes:i,defaultExports:s,verbose:!0,excludeModel:!0}),N.build("lib",R,O,()=>{I(r.ossType,r.ossConfig,r.assetsRoot)})},pushCmp:(e,r=!1)=>{const{pushCmp:i}=R;R.build2lib=de(i),r&&(R.build2lib.entry={});const{cmpTypes:s,defaultExports:t}=ce(R.build2lib,{entryType:"widget",cmpType:e});return Y(R,R.build2lib,{cmpTypes:s,defaultExports:t,verbose:!1,excludeModel:!0}),new Promise((r,s)=>{N.build("lib",R,O,async()=>{try{await A({...i,componentsDir:R.componentsDir},e),r()}catch(e){s(e)}})})},pullCmp:H,deleteCmp:(e,r)=>{J(e,r)},build2esm:()=>N.build2esm(R,O),openEditor:G,installSkills:Q,updateSkills:W,removeSkills:X},S};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("node:fs"),o=require("node:path"),t=require("lodash"),r=require("akfun"),i=require("jsdom"),n=require("../utils/common.js"),s=require("../utils/pathUtils.js");var a,l;exports.__require=function(){if(l)return a;l=1;const c=e,p=o,g=t,{getConfigObj:u}=r,{JSDOM:m}=i,{getFramework:d,errorLog:w}=n.__require(),{catchCurPackageJson:f}=s.__require(),h=u(f()),b=(e=[])=>e.map(e=>({label:e.label,description:e.description,propSchema:JSON.stringify(e)})),T=(e=[],o)=>e&&0!==e.length?e.map(e=>{let t=e.eventParams||"[]";return g.isArray(t)&&(t=JSON.stringify(t)),{...e,componentType:o,eventCategory:e.eventCategory||2,pageType:e.pageType||1,targetDevice:e.targetDevice||1,eventParams:t}}):[],y=(e=[],o)=>e&&0!==e.length?e.map(e=>{let t=e.funcInParams||"[]",r=e.funcOutParams||"[]";return g.isArray(t)&&(t=JSON.stringify(t)),g.isArray(r)&&(r=JSON.stringify(r)),{...e,componentType:o,funcScope:e.funcScope||1,pageType:e.pageType||1,targetDevice:e.targetDevice||1,custom:!0,funcInParams:t,funcOutParams:r}}):[];return a={buildComponentData:async(e,o)=>{if(!o||!o.cmpType)return w("自定义组件信息或组件名称不能为空"),null;const{cmpType:t}=o;if(!e||!c.existsSync(e))return w(`未找到自定义组件目录: ${e}`),null;const r=g.camelCase(t),i=p.join(e,`${r}Model.js`);if(!c.existsSync(i))throw w(`未找到自定义组件模型文件,请检查以下路径是否存在:${i}`),new Error(`未找到自定义组件模型文件,请检查以下路径是否存在:${i}`);const n=globalThis.window;if(!globalThis.window){const e=new m("<!DOCTYPE html><p>Hello world</p>",{url:"http://localhost",contentType:"text/html",includeNodeLocations:!0,storageQuota:1e5});globalThis.window={...e.window,console:console,neoRequire:()=>{},postMessage:()=>{}},globalThis.document=e.window.document,globalThis.this={}}const s=globalThis.self;globalThis.self||(globalThis.self=globalThis);try{if(!c.existsSync(i))throw w(`未找到自定义组件模型文件,请检查以下路径是否存在:${i}`),new Error(`未找到自定义组件模型文件,请检查以下路径是否存在:${i}`);if(require(i),!globalThis.window||!globalThis.window.NEOEditorCustomModels)throw w(`模型文件未导出有效模型方法(CatchCustomCmpModelClass),模型文件地址: ${i} `),new Error(`模型文件未导出有效模型方法(CatchCustomCmpModelClass),模型文件地址: ${i} `);const e=globalThis.window.NEOEditorCustomModels[t];if(!e)throw w(`未找到自定义组件模型类(${t}),模型文件地址: ${i} `),new Error(`未找到自定义组件模型类(${t}),模型文件地址: ${i} `);const r=new e;if(!r)throw w(`未找到自定义组件模型信息(${t}),模型文件地址: ${i} `),new Error(`未找到自定义组件模型信息(${t}),模型文件地址: ${i} `);return{...o,version:h.version||"1.0.0",framework:h.framework?d(h.framework):0,label:r.label||t,description:r.description||"",componentCategory:(r.tags||["自定义组件"]).join(","),targetPage:r.targetPage||["all"],targetObject:r.targetObject||["all"],targetApplication:r.targetApplication||["all"],targetDevice:r.targetDevice||"web",iconUrl:r.iconUrl||r.iconUrl,defaultProps:JSON.stringify(r.defaultComProps||{}),previewProps:JSON.stringify(r.previewComProps||{}),props:b(r.propsSchema||[]),events:T(r.events||[],t),functions:y(r.functions||r.actions||[],t),exposedToDesigner:void 0===r.exposedToDesigner||r.exposedToDesigner,namespace:r.namespace||"neo-cmp-cli",enableDuplicate:void 0===r.enableDuplicate||r.enableDuplicate}}catch(e){return w(`自定义组件模型文件解析失败 (${i||"未知路径"}): ${e.message||e.msg}`),w(e.stack),null}finally{void 0===n?delete globalThis.window:globalThis.window=n,void 0===s?delete globalThis.self:globalThis.self=s}},getPropsSchema:b,getCmpEvents:T,getCmpFunctions:y}};
|
package/dist/neo/env.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("lodash");var t,e;exports.__require=function(){if(e)return t;e=1;const a=o,u={production:{neoBaseURL:"https://crm.xiaoshouyi.com",loginURL:"https://login.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login.xiaoshouyi.com/auc/oauth2/token"},p20:{neoBaseURL:"https://crm-p20.xiaoshouyi.com",loginURL:"https://login-p20.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login-p20.xiaoshouyi.com/auc/oauth2/token"},sandbox:{neoBaseURL:"https://crm-sandbox.xiaoshouyi.com",loginURL:"https://login-sandbox.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login-sandbox.xiaoshouyi.com/auc/oauth2/token"},cd:{neoBaseURL:"https://crm-cd.xiaoshouyi.com",loginURL:"https://login-cd.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login-cd.xiaoshouyi.com/auc/oauth2/token"},tencentuat:{neoBaseURL:"https://crm-tencentuat.xiaoshouyi.com",loginURL:"https://login-tencentuat.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login-tencentuat.xiaoshouyi.com/auc/oauth2/token"}},n={neoBaseURL:"https://crm-cd.xiaoshouyi.com",loginURL:"https://login-cd.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login-cd.xiaoshouyi.com/auc/oauth2/token",delete:"/rest/metadata/v3.0/ui/customComponents",saveAPI:"/rest/metadata/v3.0/ui/customComponents/actions/saveOrUpdateComponent",queryAll_v1:"/rest/metadata/v3.0/ui/components/filter?custom=true",queryAll:"/rest/metadata/v3.0/ui/customComponents/actions/queryCustomComponents",getCodeLibAPI:o=>`/rest/metadata/v3.0/ui/customComponents/${o}/codeLib`,uploadAPI:"/rest/metadata/v3.0/ui/customComponents/actions/upload",getUserInfoAPI:"/rest/auc/v2.0/userInfo",pcLinkDebugUrl:"/bff/spa/neo.ui.designer.web/index#/neoPage/layoutEdit/customPage/emptyPage/default?debug=true",h5LinkDebugUrl:"/bff/spa/neo.ui.designer.h5/index#/neoPage/layoutEdit/customPage/emptyPage/default?debug=true"};return t={DefaultNeoCrmAPI:n,getNeoCrmAPI:(o="cd",t={})=>{let e,s=a.cloneDeep(n);return e="custom"===o?{...t,neoBaseURL:t.neoBaseURL,loginURL:t.loginURL||t.loginAPI,tokenURL:t.tokenURL||t.tokenAPI}:u[o]||u.cd,{...s,...e}}}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("lodash");var t,e;exports.__require=function(){if(e)return t;e=1;const a=o,u={production:{neoBaseURL:"https://crm.xiaoshouyi.com",loginURL:"https://login.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login.xiaoshouyi.com/auc/oauth2/token"},p20:{neoBaseURL:"https://crm-p20.xiaoshouyi.com",loginURL:"https://login-p20.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login-p20.xiaoshouyi.com/auc/oauth2/token"},sandbox:{neoBaseURL:"https://crm-sandbox.xiaoshouyi.com",loginURL:"https://login-sandbox.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login-sandbox.xiaoshouyi.com/auc/oauth2/token"},cd:{neoBaseURL:"https://crm-cd.xiaoshouyi.com",loginURL:"https://login-cd.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login-cd.xiaoshouyi.com/auc/oauth2/token"},tencentuat:{neoBaseURL:"https://crm-tencentuat.xiaoshouyi.com",loginURL:"https://login-tencentuat.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login-tencentuat.xiaoshouyi.com/auc/oauth2/token"}},n={neoBaseURL:"https://crm-cd.xiaoshouyi.com",loginURL:"https://login-cd.xiaoshouyi.com/auc/oauth2/auth",tokenURL:"https://login-cd.xiaoshouyi.com/auc/oauth2/token",delete:"/rest/metadata/v3.0/ui/customComponents",saveAPI:"/rest/metadata/v3.0/ui/customComponents/actions/saveOrUpdateComponent",queryAll_v1:"/rest/metadata/v3.0/ui/components/filter?custom=true",queryAll:"/rest/metadata/v3.0/ui/customComponents/actions/queryCustomComponents",getCodeLibAPI:o=>`/rest/metadata/v3.0/ui/customComponents/${o}/codeLib`,uploadAPI:"/rest/metadata/v3.0/ui/customComponents/actions/upload",getUserInfoAPI:"/rest/auc/v2.0/userInfo",pcLinkDebugUrl:"/bff/spa/neo.ui.designer.web/index#/neoPage/layoutEdit/customPage/emptyPage/default?debug=true",h5LinkDebugUrl:"/bff/spa/neo.ui.designer.h5/index#/neoPage/layoutEdit/customPage/emptyPage/default?debug=true",pcPreviewUrl:"/bff/spa/neo.ui.designer.web/index#/preview/customPage?debug=true"};return t={DefaultNeoCrmAPI:n,getNeoCrmAPI:(o="cd",t={})=>{let e,s=a.cloneDeep(n);return e="custom"===o?{...t,neoBaseURL:t.neoBaseURL,loginURL:t.loginURL||t.loginAPI,tokenURL:t.tokenURL||t.tokenAPI}:u[o]||u.cd,{...s,...e}}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("node:fs"),r=require("node:path"),o=require("node:url"),t=require("../utils/common.js");var n,s;exports.__require=function(){if(s)return n;s=1;const c=e,i=r,{pathToFileURL:l}=o,{errorLog:u}=t.__require();return n={getCmpPreviewSchema:async e=>{if(null==e||""===e){const e="请传入组件目录或 model.ts / model.js 路径(componentsDir 未配置时请使用默认 ./src/components)";throw u(e),new Error(e)}const r=i.resolve(e);if(!c.existsSync(r)){const e=`路径不存在: ${r}`;throw u(e),new Error(e)}let o;if(c.statSync(r).isDirectory()){if(o=function(e){const r=i.resolve(e),o=i.join(r,"model.ts"),t=i.join(r,"model.js");return c.existsSync(o)?o:c.existsSync(t)?t:null}(r),!o){const e=`目录下未找到 model.ts 或 model.js: ${r}`;throw u(e),new Error(e)}}else{if(!/model\.(ts|js)$/i.test(r)){const e=`请传入组件目录或 model.ts / model.js 文件: ${r}`;throw u(e),new Error(e)}o=r}const t=i.resolve(o);try{const{default:e}=await import(l(t).href);if(!e||"function"!=typeof e)throw new Error("模型文件需使用 default export 导出模型类");const r=(new e).defaultComProps;return null!=r&&"object"==typeof r?{...r}:{}}catch(e){const r=`解析模型失败 (${t}): ${e.message||e}`;throw u(r),e instanceof Error&&e.stack&&u(e.stack),e instanceof Error?e:new Error(r)}}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("node:fs"),t=require("node:path"),n=require("../utils/common.js"),i=require("../config/index.js"),r=require("../config/auth.config.js"),s=require("./env.js");var o,u;exports.__require=function(){if(u)return o;u=1;const c=e,g=t,{errorLog:a}=n.__require(),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("node:fs"),t=require("node:path"),n=require("../utils/common.js"),i=require("../config/index.js"),r=require("../config/auth.config.js"),s=require("./env.js");var o,u;exports.__require=function(){if(u)return o;u=1;const c=e,g=t,{errorLog:a}=n.__require(),h=i.__require(),l=r.__require(),{DefaultNeoCrmAPI:f}=s.__require();return o=class{static getEnvFilePath(){return g.join(process.cwd(),".neo-cli","env.json")}static ensureEnvDir(){const e=g.dirname(this.getEnvFilePath());c.existsSync(e)||c.mkdirSync(e,{recursive:!0})}static getAuthConfig(){return{...f,...h.neoConfig,...l}}static getEnvConfig(){let e={};const t=this.getEnvFilePath(),n=this.getAuthConfig();if(!c.existsSync(t))return n;try{const n=c.readFileSync(t,"utf-8");e=JSON.parse(n)}catch(e){a(`读取环境配置文件失败: ${e.message||e.msg}`)}return{...n,...e}}static getLinKDebugURL(e){const t=this.getEnvConfig();let n=t.neoBaseURL;return n.endsWith("/")&&(n=n.substring(0,n.length-1)),"web"===e?`${n}${t.pcLinkDebugUrl}`:`${n}${t.h5LinkDebugUrl}`}static getLinkPreviewURL(e="web"){const t=this.getEnvConfig();let n=t.neoBaseURL;return n.endsWith("/")&&(n=n.substring(0,n.length-1)),`${n}${t.pcPreviewUrl}`}static setEnvConfig(e){if(!e||"object"!=typeof e)throw new Error("环境配置必须是一个对象");this.ensureEnvDir();const t={...this.getEnvConfig(),...e,updatedAt:Date.now()},n=this.getEnvFilePath();return c.writeFileSync(n,JSON.stringify(t,null,2),"utf-8"),t}static updateEnvConfig(e){return this.setEnvConfig(e)}static clearEnvConfig(){const e=this.getEnvFilePath();c.existsSync(e)&&c.unlinkSync(e)}}};
|
package/dist/neo/pushCmp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("node:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("node:path"),t=require("lodash"),r=require("ora"),s=require("./neoService.js"),i=require("../utils/common.js"),o=require("./buildComponentData.js"),a=require("../utils/projectUtils/createCmpProjectZip.js"),n=require("../utils/projectUtils/updatePublishLog.js"),c=require("../utils/cmpTypeValidator.js");var u,l;exports.__require=function(){if(l)return u;l=1;const m=e,p=t,d=r,q=s.__require(),{errorLog:_,successLog:g}=i.__require(),{buildComponentData:h}=o.__require(),j=a.__require(),C=n.__require(),{validateApiName:w}=c.__require();return u=async(e,t)=>{const r=d("正在发布组件...").start(),{isValid:s,errors:i}=w(t);if(!s)throw _(i.join("\n")),new Error(i.join("\n"));try{let s,i=new q;await i.ensureValidToken(),r.start("[1/4] 打包源码文件(含单个自定义组件源码)...");try{s=j(t,process.cwd(),e.assetsRoot),s?g(`[1/4] 源码文件打包完成: ${m.basename(s)}。`,r):_("[1/4] 源码文件打包失败,未返回 zip 文件路径。",r)}catch(e){_("[1/4] 源码文件打包失败。",r)}r.start("[2/4] 获取自定义组件构建产物...");const o=await i.getCmpAssets(t);let a;r.start("[3/4] 构建组件数据...");try{a=await h(e.assetsRoot,o),a?g("[3/4] 组件数据构建完成。",r):_(`[3/4] 未获取到自定义组件模型信息(${t})。`,r)}catch(e){_(`[3/4] 组件数据构建失败: ${e.message||e.msg}`,r)}r.start("[4/4] 保存组件信息到 NeoCRM 平台...");const n=["assetFile","modelAssetFile","cssAssetFile","codeLibFile"],c={...a};n.forEach(e=>{c[e]&&c[e].fileContent&&(c[e]=p.omit(c[e],["fileContent"]))}),C(c);try{await i.updateCustomComponent(a),g("[4/4] 组件信息保存成功",r)}catch(e){_("[4/4] 组件信息保存失败",r)}const{tenant_id:u,instance_uri:l}=i.tokenCache||{};console.log(`\n✅ 自定义组件发布成功!\n(当前租户 ID: ${u||"未返回"},所在租户的 API 域名: ${l||"未返回"}。)`)}catch(e){try{r&&r.isSpinning&&_(`❌ 自定义组件发布失败: ${e.message||e.msg}`,r)}catch{_(`\n❌ 自定义组件发布失败: ${e.message||e.msg}`)}throw e}},u};
|
package/dist/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e="1.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e="1.15.2";const o={version:e};exports.default=o,exports.version=e;
|
package/dist/utils/common.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("chalk"),r=require("../node_modules/typescript/lib/typescript.js"),t=require("node:path"),s=require("./neoParams.js");var o,n;exports.__require=function(){if(n)return o;n=1;const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("chalk"),r=require("../node_modules/typescript/lib/typescript.js"),t=require("node:path"),s=require("./neoParams.js");var o,n;exports.__require=function(){if(n)return o;n=1;const i=e,c=r.__require(),a=t,{consoleTag:u}=s.__require();function l(e,r){const t=`${u} ${i.red(e)}`;r?r.fail(t):console.error(t)}return o={getFramework:function(e){if(!e)return 0;let r=e.toLowerCase().trim();switch(r){case"jquery":case"jq":r=2;break;case"vue2":case"vue 2":case"vue2.0":case"vue 2.0":r=1;break;case"vue":case"vue3":case"vue 3":case"vue3.0":case"vue 3.0":r=3,l("暂不支持 vue3.0 技术栈。");break;default:r=0}return r},errorLog:l,warningLog:function(e,r){const t=`${u} ${i.yellow(e)}`;r?r.warn(t):console.warn(t)},successLog:function(e,r){const t=`${u} ${i.green(e)}`;r?r.succeed(t):console.log(t)},parseTsConfigWithTypeScript:function(e){try{const r=c.readConfigFile(e,c.sys.readFile);if(r.error)throw new Error(`解析 tsconfig.json 失败: ${r.error.messageText}`);return r.config}catch(e){if("MODULE_NOT_FOUND"===e.code)throw new Error("请先安装 typescript: npm install typescript --save-dev");throw e}},getRelativePathForWebpack:function(e,r){if(!r)return e.split(a.sep).join("/");const t=a.dirname(r);try{const r=a.relative(t,e);let s=r.split(a.sep).join("/");return a.isAbsolute(r)?s=e.split(a.sep).join("/"):s.startsWith(".")||(s="./"+s),s}catch(r){return e.split(a.sep).join("/")}}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("node:path"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("node:path"),o=require("node:fs"),r=require("open"),n=require("ora"),a=require("../neoParams.js"),i=require("../common.js");var t,s;exports.__require=function(){if(s)return t;s=1;const c=e,d=o,u=r,p=n,{consoleTag:m}=a.__require(),{errorLog:l}=i.__require(),f={codebuddy:{name:"CodeBuddy",darwin:[{app:{name:"codebuddy"}},{app:{name:"CodeBuddy"}}],win32:[{app:{name:"codebuddy"}}],linux:[{app:{name:"codebuddy"}}]},kiro:{name:"Kiro",darwin:[{app:{name:"kiro"}},{app:{name:"Kiro"}}],win32:[{app:{name:"kiro"}}],linux:[{app:{name:"kiro"}}]},cursor:{name:"Cursor",darwin:[{app:{name:"cursor"}},{app:{name:"Cursor"}}],win32:[{app:{name:"cursor"}}],linux:[{app:{name:"cursor"}}]},vscode:{name:"Visual Studio Code",darwin:[{app:{name:"code"}},{app:{name:"Visual Studio Code"}}],win32:[{app:{name:"code"}}],linux:[{app:{name:"code"}}]}},y=["codebuddy","kiro","cursor","vscode"],w=function(e,o){const r=function(e){if(!e)return"auto";const o=String(e).toLowerCase();return"code"===o?"vscode":o}(e);if("auto"===r){const e=[];return y.forEach(r=>{const n=f[r],a=n&&n[o];a&&a.length>0&&e.push(...a.map(e=>({...e,__editorName:n.name})))}),{configs:e,editorName:"编辑器"}}const n=f[r];if(!n)return{configs:[],editorName:"编辑器"};return{configs:(n[o]||[]).map(e=>({...e,__editorName:n.name})),editorName:n.name}};return t=async function(e,o){const r=o?c.resolve(o):process.cwd();d.existsSync(r)||(l(`目录不存在: ${r}`),process.exit(1));d.statSync(r).isDirectory()||(l(`路径不是目录: ${r}`),process.exit(1));const n=process.platform;["darwin","win32","linux"].includes(n)||(l(`不支持的操作系统: ${n}`),process.exit(1));const{configs:a,editorName:i}=w(e,n);0===a.length&&(l(`不支持的编辑器类型: ${e}`),process.exit(1));const t=p(`${m}正在尝试使用 ${i} 打开项目: ${r}`).start(),s=async e=>{e>=a.length&&(l("无法打开编辑器,已尝试所有可用方式。\n 请确保已安装 CodeBuddy、Kiro、Cursor 或 Visual Studio Code 其中之一,并将其添加到系统 PATH 中。",t),process.exit(1));const o=a[e];try{await u(r,o),t.stop()}catch(o){await s(e+1)}};await s(0)}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("node:path"),r=require("node:os");var o,u;exports.__require=function(){if(u)return o;u=1;const a=e,d=r,n={codebuddy:{name:"CodeBuddy",value:"codebuddy",dirName:".codebuddy"},kiro:{name:"Kiro",value:"kiro",dirName:".kiro"},cursor:{name:"Cursor",value:"cursor",dirName:".cursor"},claudeCode:{name:"Claude Code",value:"claudeCode",dirName:".claude"}},i=Object.values(n).map(e=>({name:`${e.name}(~/${e.dirName}/skills/)`,value:e.value,short:e.name})),t=Object.keys(n);return o={SKILL_PRODUCT_MAP:n,SKILL_PRODUCT_CHOICES:i,SKILL_PRODUCT_VALUES:t,getSkillDir:function(e){const r=n[e];if(!r)throw new Error(`不支持的产品类型:${e},当前仅支持:${t.join(" / ")}`);return a.join(d.homedir(),r.dirName,"skills")},getProductName:function(e){const r=n[e];return r?r.name:e}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("fs-extra"),e=require("node:path"),i=require("node:os"),r=require("axios"),n=require("ora"),s=require("adm-zip"),o=require("chalk"),a=require("../neoParams.js"),c=require("../common.js"),l=require("./skillDirs.js");var u,f;exports.__require=function(){if(f)return u;f=1;const p=t,y=e,m=i,d=r,$=n,g=s,h=o,{consoleTag:w}=a.__require(),{errorLog:S,warningLog:k,successLog:j}=c.__require(),{getSkillDir:x,getProductName:D}=l.__require(),L="https://neo-cmp-docs.netlify.app/skills.zip",q="skills.json",v=["neo-cmp-cli","neo-cmp-dev","vue-to-react","frontend-design"];async function _(t,e,i){await p.ensureDir(e);const r=(await p.readdir(t)).filter(e=>{const i=y.join(t,e);return p.statSync(i).isDirectory()}),n=[],s=[];for(const o of r){if(i&&i.length>0&&!i.includes(o)){s.push(o);continue}const r=y.join(t,o),a=y.join(e,o);await p.remove(a),await p.copy(r,a),n.push(o)}return{copied:n,skipped:s}}async function A(t){try{t&&await p.pathExists(t)&&await p.remove(t)}catch(t){}}async function B(t){t&&(t.text=`${w}正在下载技能包压缩包...`);const{zipFilePath:e,tempDir:i}=await async function(){const t=y.join(m.tmpdir(),"neo-cli-skills");await p.ensureDir(t);const e=y.join(t,`neo-cmp-skills-${Date.now()}.zip`),i=await d.get(L,{responseType:"arraybuffer",timeout:6e4,maxContentLength:1/0,maxBodyLength:1/0,maxRedirects:5,validateStatus:t=>t>=200&&t<400}),r=i.headers&&i.headers["content-type"]||"";if(/text\/html/i.test(r))throw new Error(`下载技能包失败:返回内容类型为 ${r},请确认资源地址是否可访问(${L})。`);let n;return n=Buffer.isBuffer(i.data)?i.data:i.data instanceof ArrayBuffer?Buffer.from(i.data):i.data&&i.data.buffer instanceof ArrayBuffer?Buffer.from(i.data.buffer):Buffer.from(i.data),await p.writeFile(e,n),{zipFilePath:e,tempDir:t}}();t&&(t.text=`${w}正在解压技能包...`);const r=y.join(i,`extracted-${Date.now()}`);try{!function(t,e){const i=new g(t);p.ensureDirSync(e),i.extractAllTo(e,!0)}(e,r)}catch(t){throw new Error(`解压技能包失败:${t.message||t}。请确认下载的资源为有效的 zip 压缩包。`)}const n=function(t){const e=t=>!(!p.existsSync(t)||!p.statSync(t).isDirectory())&&p.readdirSync(t).some(e=>{const i=y.join(t,e);return p.statSync(i).isDirectory()&&(p.existsSync(y.join(i,"SKILL.md"))||p.existsSync(y.join(i,"skill.md")))});if(e(t))return t;const i=p.readdirSync(t).filter(e=>{const i=y.join(t,e);return p.statSync(i).isDirectory()});for(const r of i){const i=y.join(t,r);if(e(i))return i}return t}(r),s=function(t){const e=y.join(t,q);if(!p.existsSync(e))return null;try{const t=p.readFileSync(e,"utf-8"),i=JSON.parse(t);if(!Array.isArray(i))return null;const r=i.map(t=>t&&"string"==typeof t.name?t.name.trim():"").filter(Boolean);return r.length>0?r:null}catch(t){return null}}(n),o=s&&s.length>0?s:v;if(!(await p.readdir(n)).filter(t=>{const e=y.join(n,t);return p.statSync(e).isDirectory()}).some(t=>o.includes(t)))throw new Error(`解压后未在技能包中找到预期的 skill 目录(期望包含:${o.join(", ")})。`);return{skillsRoot:n,tempDir:i,officialSkills:o}}return u={SKILLS_ZIP_URL:L,SKILLS_MANIFEST_FILE:q,DEFAULT_OFFICIAL_SKILLS:v,installSkills:async function(t){const e=D(t),i=x(t),r=$(`${w}准备安装技能包到 ${e}(${i})...`).start();let n;try{const t=await B(r);n=t.tempDir,r.text=`${w}正在安装技能包到 ${e}...`;const{copied:s}=await _(t.skillsRoot,i);if(r.stop(),0===s.length)return void k("技能包中未找到可安装的 skill。");j(`已成功安装技能包到 ${e}!目录:${i}\n已安装的 skills:${s.map(t=>h.cyan(t)).join(", ")}`)}catch(t){S(`安装技能包失败:${t.message||t.msg||t}`,r),process.exit(1)}finally{await A(n)}},updateSkills:async function(t){const e=D(t),i=x(t),r=$(`${w}准备更新技能包到 ${e}(${i})...`).start();let n;try{const t=await B(r);n=t.tempDir;const s=t.officialSkills;r.text=`${w}正在更新 ${e} 的技能包(覆盖式 copy)...`;const{copied:o,skipped:a}=await _(t.skillsRoot,i,s);if(r.stop(),0===o.length)return void k(`未找到可更新的 skill(期望包含:${s.join(", ")}),请确认技能包内容是否完整。`);j(`已成功更新 ${e} 的技能包!目录:${i}\n已更新的 skills:${o.map(t=>h.cyan(t)).join(", ")}`),a.length>0&&console.log(h.gray(`[neo update cli-skills] 跳过的 skills(非官方维护列表):${a.join(", ")}`))}catch(t){S(`更新技能包失败:${t.message||t.msg||t}`,r),process.exit(1)}finally{await A(n)}},removeSkills:async function(t,e=[]){const i=D(t),r=x(t);if(!await p.pathExists(r))return void k(`${i} 的 skill 目录不存在(${r}),无需移除。`);const n=$(`${w}正在从 ${i}(${r})中移除技能包...`).start(),s=[],o=[];try{const t=Array.isArray(e)?e.map(t=>"string"==typeof t?t.trim():"").filter(Boolean):[],a=Array.from(new Set([...v,...t]));for(const t of a){const e=y.join(r,t);await p.pathExists(e)?(await p.remove(e),s.push(t)):o.push(t)}if(n.stop(),0===s.length)return void k(`未在 ${i}(${r})中找到可移除的 skill(期望:${a.join(", ")})。`);j(`已从 ${i} 中移除技能包!目录:${r}\n已移除的 skills:${s.map(t=>h.cyan(t)).join(", ")}`),o.length>0&&console.log(h.gray(`[neo remove cli-skills] 未找到的 skills:${o.join(", ")}`))}catch(t){S(`移除技能包失败:${t.message||t.msg||t}`,n),process.exit(1)}}}};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neo-cmp-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.2",
|
|
4
4
|
"description": "Neo 自定义组件开发工具,支持react 和 vue2.0技术栈。",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"neo-cli",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"main": "dist/main.js",
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build2node": "akfun build2node",
|
|
17
|
-
"format": "prettier --write \"src/**/**/*.{js,jsx,vue,tsx,ts,scss,less,json}\""
|
|
17
|
+
"format": "prettier --write \"src/**/**/*.{js,jsx,vue,tsx,ts,scss,less,json}\"",
|
|
18
|
+
"format2": "prettier --write \"template/**/**/package.json\""
|
|
18
19
|
},
|
|
19
20
|
"files": [
|
|
20
21
|
"bin/*",
|
|
@@ -12,7 +12,8 @@ export class DataDashboardModel {
|
|
|
12
12
|
label: string = '数据仪表板';
|
|
13
13
|
|
|
14
14
|
// 组件描述,用于设置在编辑器左侧组件面板中展示的描述
|
|
15
|
-
description: string =
|
|
15
|
+
description: string =
|
|
16
|
+
'使用 antd ui 组件实现的数据展示仪表板,支持动态数据更新和动画效果';
|
|
16
17
|
|
|
17
18
|
// 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示
|
|
18
19
|
// tags: string[] = ['自定义组件'];
|
|
@@ -12,7 +12,8 @@ export class SearchWidgetModel {
|
|
|
12
12
|
label: string = '搜索组件';
|
|
13
13
|
|
|
14
14
|
// 组件描述,用于设置在编辑器左侧组件面板中展示的描述
|
|
15
|
-
description: string =
|
|
15
|
+
description: string =
|
|
16
|
+
'使用 antd ui 组件实现的支持搜索输入,点击回车键显示搜索内容';
|
|
16
17
|
|
|
17
18
|
// 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示
|
|
18
19
|
// tags: string[] = ['自定义组件'];
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@types/react": "^16.9.11",
|
|
53
53
|
"@types/react-dom": "^16.9.15",
|
|
54
54
|
"@types/axios": "^0.14.0",
|
|
55
|
-
"neo-cmp-cli": "^1.
|
|
55
|
+
"neo-cmp-cli": "^1.15.2",
|
|
56
56
|
"husky": "^4.2.5",
|
|
57
57
|
"lint-staged": "^10.2.9",
|
|
58
58
|
"prettier": "^2.0.5",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"engines": {
|
|
66
66
|
"node": ">= 16.0.0",
|
|
67
67
|
"npm": ">= 8.0.0"
|
|
68
|
-
}
|
|
68
|
+
}
|
|
69
69
|
}
|
|
@@ -51,6 +51,14 @@ module.exports = {
|
|
|
51
51
|
// externals: ['xxModule'], // 自定义组件中需要剔除的模块,仅支持数组写法
|
|
52
52
|
},
|
|
53
53
|
*/
|
|
54
|
+
/*
|
|
55
|
+
preview: {
|
|
56
|
+
// 【非必填】在线预览组件时,可以向组件注入的一些自定义配置数据(优先级高,设置了 previewDefaultSchema 则忽略组件模型中的 defaultComProps)
|
|
57
|
+
previewDefaultSchema: {
|
|
58
|
+
title: '在线预览组件'
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
*/
|
|
54
62
|
linkDebug: {
|
|
55
63
|
// 用于开启本地调试模式的相关配置信息
|
|
56
64
|
/*
|
|
@@ -96,5 +104,5 @@ module.exports = {
|
|
|
96
104
|
cssExtract: false, // 不额外提取css文件
|
|
97
105
|
assetsRoot: resolve('dist') // 上传指定目录下的脚本文件
|
|
98
106
|
*/
|
|
99
|
-
}
|
|
107
|
+
}
|
|
100
108
|
};
|
|
@@ -11,12 +11,14 @@
|
|
|
11
11
|
"author": "wibetter",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"scripts": {
|
|
14
|
-
"preview": "neo preview",
|
|
15
14
|
"linkDebug": "neo linkDebug",
|
|
16
15
|
"neoLogin": "neo login",
|
|
17
16
|
"pushCmp": "neo push cmp",
|
|
18
17
|
"pullCmp": "neo pull cmp",
|
|
19
18
|
"deleteCmp": "neo delete cmp",
|
|
19
|
+
"preview": "neo preview -n entityTable__c -m online",
|
|
20
|
+
"addSkills": "neo add cli-skills",
|
|
21
|
+
"removeSkills": "neo remove cli-skills",
|
|
20
22
|
"format": "prettier --write \"src/**/**/*.{js,jsx,ts,tsx,vue,scss,json}\""
|
|
21
23
|
},
|
|
22
24
|
"files": [
|
|
@@ -55,7 +57,7 @@
|
|
|
55
57
|
"@types/react": "^16.9.11",
|
|
56
58
|
"@types/react-dom": "^16.9.15",
|
|
57
59
|
"@types/axios": "^0.14.0",
|
|
58
|
-
"neo-cmp-cli": "^1.
|
|
60
|
+
"neo-cmp-cli": "^1.15.2",
|
|
59
61
|
"husky": "^4.2.5",
|
|
60
62
|
"lint-staged": "^10.2.9",
|
|
61
63
|
"prettier": "^2.0.5"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neo-web-entity-grid",
|
|
3
3
|
"version": "1.1.0",
|
|
4
|
-
"description": "Web
|
|
4
|
+
"description": "Web端列表组件示例模板: 含基础大列表、Picker 列表等示例组件。",
|
|
5
5
|
"framework": "react-ts",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"react&ts技术栈",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@types/react-dom": "^16.9.15",
|
|
53
53
|
"husky": "^4.2.5",
|
|
54
54
|
"lint-staged": "^10.2.9",
|
|
55
|
-
"neo-cmp-cli": "^1.
|
|
55
|
+
"neo-cmp-cli": "^1.15.2",
|
|
56
56
|
"prettier": "^2.0.5"
|
|
57
57
|
},
|
|
58
58
|
"overrides": {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neo-web-entity-grid",
|
|
3
3
|
"version": "1.1.0",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "自定义表单相关自定义功能组件,可用于实现子表的批量数据插入与汇总统计功能。",
|
|
5
5
|
"framework": "react-ts",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"react&ts技术栈",
|
|
8
|
-
"
|
|
8
|
+
"自定义表单功能组件"
|
|
9
9
|
],
|
|
10
10
|
"author": "wibetter",
|
|
11
11
|
"license": "MIT",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@types/react-dom": "^16.9.15",
|
|
54
54
|
"husky": "^4.2.5",
|
|
55
55
|
"lint-staged": "^10.2.9",
|
|
56
|
-
"neo-cmp-cli": "^1.
|
|
56
|
+
"neo-cmp-cli": "^1.15.2",
|
|
57
57
|
"prettier": "^2.0.5"
|
|
58
58
|
},
|
|
59
59
|
"overrides": {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "react-custom-cmp-template",
|
|
3
3
|
"version": "1.1.0",
|
|
4
4
|
"description": "neo自定义组件模板(react技术栈)",
|
|
5
|
-
"framework": "react
|
|
5
|
+
"framework": "react",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"自定义组件模板",
|
|
8
8
|
"react技术栈",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"author": "wibetter",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"scripts": {
|
|
14
|
-
"preview": "neo preview",
|
|
14
|
+
"preview": "neo preview -n infoCard__c -m online",
|
|
15
|
+
"preview2": "neo preview",
|
|
15
16
|
"linkDebug": "neo linkDebug",
|
|
16
17
|
"pushCmp": "neo push cmp",
|
|
17
18
|
"format": "prettier --write \"src/**/**/*.{js,jsx,ts,tsx,vue,scss,json}\""
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@commitlint/cli": "^18.0.0",
|
|
47
48
|
"@commitlint/config-conventional": "^18.0.0",
|
|
48
|
-
"neo-cmp-cli": "^1.
|
|
49
|
+
"neo-cmp-cli": "^1.15.2",
|
|
49
50
|
"husky": "^4.2.5",
|
|
50
51
|
"lint-staged": "^10.2.9",
|
|
51
52
|
"prettier": "^2.0.5"
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
# CODEBUDDY.md
|
|
2
|
-
|
|
3
|
-
This file provides guidance to CodeBuddy Code when working with code in this repository.
|
|
4
|
-
|
|
5
|
-
## Project Overview
|
|
6
|
-
|
|
7
|
-
NeoCRM 自定义业务组件模板项目。基于 React 16 + TypeScript + Ant Design 4 + SCSS,通过 `neo-cmp-cli` 工具链进行预览、调试和发布。
|
|
8
|
-
|
|
9
|
-
## Commands
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm i # 安装依赖
|
|
13
|
-
npm run preview # 预览组件 (neo preview)
|
|
14
|
-
npm run linkDebug # 外链调试 - 在线上页面设计器端预览自定义组件
|
|
15
|
-
npm run neoLogin # OAuth2 登录 NeoCRM 平台
|
|
16
|
-
npm run pushCmp # 构建并发布组件到 NeoCRM 平台
|
|
17
|
-
npm run pullCmp # 从平台拉取组件
|
|
18
|
-
npm run deleteCmp # 删除平台上的组件
|
|
19
|
-
npm run format # Prettier 格式化
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
没有标准的 build/dev/test 命令。构建在 `neo push cmp` 时隐式执行,无测试框架配置。
|
|
23
|
-
|
|
24
|
-
## Architecture
|
|
25
|
-
|
|
26
|
-
### Component Structure
|
|
27
|
-
|
|
28
|
-
每个自定义组件位于 `src/components/` 下,以 `cmpType__c` 命名(`__c` 后缀表示自定义):
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
src/components/xxCmp__c/
|
|
32
|
-
├── index.tsx # 组件实现(默认入口)
|
|
33
|
-
├── model.ts # 模型文件 - 对接页面设计器的属性/事件/函数声明
|
|
34
|
-
├── style.scss # 组件样式
|
|
35
|
-
└── README.md # 组件文档(可选)
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
当 `neo.config.js` 的 `entry` 为空时,CLI 根据 `src/components/` 目录结构自动生成 entry 和注册文件,开发者无需关注 `neo-register`。
|
|
39
|
-
|
|
40
|
-
### Component Base Class
|
|
41
|
-
|
|
42
|
-
- `BaseCmp`(来自 `neo-ui-common`):主要基类,继承自 `React.PureComponent`
|
|
43
|
-
- 部分组件也可直接继承 `React.PureComponent`
|
|
44
|
-
- 类型定义在 `@types/neo-ui-common.d.ts`
|
|
45
|
-
|
|
46
|
-
### Model File
|
|
47
|
-
|
|
48
|
-
`model.ts` 定义组件在设计器中的配置,关键字段:
|
|
49
|
-
|
|
50
|
-
- `label` / `description`:组件名称和描述
|
|
51
|
-
- `targetPage`:支持页面类型(`all` / `entityFormPage` / `customPage`)
|
|
52
|
-
- `targetDevice`:支持终端(`web` / `mobile`)
|
|
53
|
-
- `iconUrl`:组件图标
|
|
54
|
-
- `defaultComProps`:默认属性
|
|
55
|
-
- `propsSchema`:编辑器属性面板配置
|
|
56
|
-
- `events`:组件事件声明
|
|
57
|
-
- `functions`:组件对外暴露的函数
|
|
58
|
-
|
|
59
|
-
### Platform APIs
|
|
60
|
-
|
|
61
|
-
- **neo-open-api / xObject**:实体数据 CRUD(`query`, `get`, `create`, `update`, `delete`, `getDesc`, `getEntityTypeList`)
|
|
62
|
-
- **neo-open-api / customApi**:自定义 API 代理调用(`customApi.run`)
|
|
63
|
-
- **neo-ui-common / NeoEvent**:事件系统
|
|
64
|
-
- `@NeoEvent.function` 装饰器:声明可被其他组件调用的函数
|
|
65
|
-
- `@NeoEvent.dispatch`:声明事件派发
|
|
66
|
-
- `NeoEvent.broadcast` / `NeoEvent.listen`:广播/监听事件
|
|
67
|
-
- **props.data.__NeoSystemInfo**:平台系统信息
|
|
68
|
-
|
|
69
|
-
### Data Fetching Modes
|
|
70
|
-
|
|
71
|
-
1. **自动获取**(`autoFetchData: true`):平台自动注入 `props.entityData` 和 `props.xObjectDataApi.fieldDescList`
|
|
72
|
-
2. **手动获取**:组件自行通过 `neo-open-api` SDK 调用接口
|
|
73
|
-
|
|
74
|
-
### Path Aliases (webpack)
|
|
75
|
-
|
|
76
|
-
- `@` → `./src`
|
|
77
|
-
- `$assets` → `./src/assets`
|
|
78
|
-
- `$public` → `./public`
|
|
79
|
-
- `$utils` → `./src/utils`
|
|
80
|
-
|
|
81
|
-
### SCSS Auto-injection
|
|
82
|
-
|
|
83
|
-
`src/assets/css/common.scss`(变量、函数)和 `src/assets/css/mixin.scss`(通用 mixin)通过 `sassResources` 自动注入所有 SCSS 文件,无需手动 import。
|
|
84
|
-
|
|
85
|
-
## Key Rules
|
|
86
|
-
|
|
87
|
-
- **React 16**:必须使用 React 16 版本
|
|
88
|
-
- **样式隔离**:组件最外层设置唯一 className(如 `entityForm__c`),所有样式放在该选择器内
|
|
89
|
-
- **组件命名**:目录名使用 `cmpType__c` 格式
|
|
90
|
-
- **发布要求**:`package.json` 的 `name` 值必须唯一,`version` 值不能重复
|
|
91
|
-
- **代码风格**:Prettier 配置为单引号、分号、2 空格缩进、尾逗号 all
|
|
92
|
-
- **Commit 规范**:type 必须是 feat/fix/bug/docs/style/refactor/test/chore/perf/build/ci 之一
|