ylyx-cli 1.0.16 → 1.1.1
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 +313 -276
- package/bin/ylyx.js +176 -168
- package/lib/config.js +325 -283
- package/lib/deploy.js +509 -529
- package/lib/environments.js +111 -0
- package/lib/generator.js +192 -192
- package/lib/index.js +113 -113
- package/lib/interactive.js +87 -87
- package/lib/remote.js +179 -179
- package/lib/template.js +174 -174
- package/lib/utils.js +148 -148
- package/package.json +61 -59
- package/templates/react-app/files/.gitignore +22 -0
- package/templates/react-app/files/README.md +23 -23
- package/templates/react-app/files/package.json +28 -28
- package/templates/react-app/files/public/index.html +11 -11
- package/templates/react-app/files/src/App.css +15 -15
- package/templates/react-app/files/src/App.js +15 -15
- package/templates/react-app/files/src/index.css +10 -10
- package/templates/react-app/files/src/index.js +11 -11
- package/templates/react-app/template.json +11 -11
- package/templates/react-component/files/Component.module.css +5 -5
- package/templates/react-component/files/Component.tsx +31 -31
- package/templates/react-component/files/index.ts +2 -2
- package/templates/react-component/template.json +48 -48
- package/templates/vue-app/files/.editorconfig +14 -14
- package/templates/vue-app/files/.env.development +21 -21
- package/templates/vue-app/files/.env.production +18 -18
- package/templates/vue-app/files/.eslintignore +5 -5
- package/templates/vue-app/files/.eslintrc.js +267 -267
- package/templates/vue-app/files/.gitignore +24 -0
- package/templates/vue-app/files/.prettierignore +11 -11
- package/templates/vue-app/files/.travis.yml +5 -5
- package/templates/vue-app/files/.vscode/extensions.json +7 -7
- package/templates/vue-app/files/.vscode/settings.json +39 -39
- package/templates/vue-app/files/LICENSE +191 -191
- package/templates/vue-app/files/README.md +87 -87
- package/templates/vue-app/files/babel.config.js +11 -11
- package/templates/vue-app/files/jest.config.js +24 -24
- package/templates/vue-app/files/package.json +136 -136
- package/templates/vue-app/files/plopfile.js +7 -7
- package/templates/vue-app/files/postcss.config.js +5 -5
- package/templates/vue-app/files/public/default.js +25 -25
- package/templates/vue-app/files/public/index.html +26 -26
- package/templates/vue-app/files/src/App.vue +54 -54
- package/templates/vue-app/files/src/api/bigDataV/index.js +198 -198
- package/templates/vue-app/files/src/api/data.js +42 -42
- package/templates/vue-app/files/src/api/dataArchive/index.js +186 -186
- package/templates/vue-app/files/src/api/generator/genConfig.js +16 -16
- package/templates/vue-app/files/src/api/generator/generator.js +32 -32
- package/templates/vue-app/files/src/api/indexManagement/index.js +39 -39
- package/templates/vue-app/files/src/api/institutionMonitor/index.js +396 -396
- package/templates/vue-app/files/src/api/institutionSet/index.js +120 -120
- package/templates/vue-app/files/src/api/login.js +44 -44
- package/templates/vue-app/files/src/api/selfStatistics/index.js +50 -50
- package/templates/vue-app/files/src/api/system/code.js +15 -15
- package/templates/vue-app/files/src/api/system/dict.js +34 -34
- package/templates/vue-app/files/src/api/system/dictDetail.js +52 -52
- package/templates/vue-app/files/src/api/system/equipment.js +35 -35
- package/templates/vue-app/files/src/api/system/examManage.js +49 -49
- package/templates/vue-app/files/src/api/system/examProject.js +48 -48
- package/templates/vue-app/files/src/api/system/hosModel.js +35 -35
- package/templates/vue-app/files/src/api/system/hospital.js +88 -88
- package/templates/vue-app/files/src/api/system/job.js +40 -40
- package/templates/vue-app/files/src/api/system/menu.js +67 -67
- package/templates/vue-app/files/src/api/system/model.js +42 -42
- package/templates/vue-app/files/src/api/system/risConfig.js +9 -9
- package/templates/vue-app/files/src/api/system/role.js +64 -64
- package/templates/vue-app/files/src/api/system/sysSet.js +19 -19
- package/templates/vue-app/files/src/api/system/timing.js +41 -41
- package/templates/vue-app/files/src/api/system/user.js +121 -121
- package/templates/vue-app/files/src/api/tools/alipay.js +25 -25
- package/templates/vue-app/files/src/api/tools/email.js +24 -24
- package/templates/vue-app/files/src/api/tools/localStorage.js +27 -27
- package/templates/vue-app/files/src/api/tools/qiniu.js +40 -40
- package/templates/vue-app/files/src/assets/css/font-awesome.css +2342 -2342
- package/templates/vue-app/files/src/assets/css/font-awesome.min.css +2336 -2336
- package/templates/vue-app/files/src/assets/fonts/fontawesome-webfont.svg +2671 -2671
- package/templates/vue-app/files/src/assets/icons/index.js +9 -9
- package/templates/vue-app/files/src/assets/icons/svg/hospital.svg +1 -1
- package/templates/vue-app/files/src/assets/icons/svg/hospital1.svg +1 -1
- package/templates/vue-app/files/src/assets/icons/svg/loginOne.svg +35 -35
- package/templates/vue-app/files/src/assets/icons/svg/loginOneWhite.svg +19 -19
- package/templates/vue-app/files/src/assets/icons/svg/loginOr.svg +93 -93
- package/templates/vue-app/files/src/assets/icons/svg/loginUp.svg +96 -96
- package/templates/vue-app/files/src/assets/icons/svg/monitor.svg +1 -1
- package/templates/vue-app/files/src/assets/icons/svg/offline.svg +1 -1
- package/templates/vue-app/files/src/assets/icons/svg/online.svg +1 -1
- package/templates/vue-app/files/src/assets/icons/svg/system.svg +1 -1
- package/templates/vue-app/files/src/assets/icons/svgo.yml +21 -21
- package/templates/vue-app/files/src/assets/styles/btn.scss +103 -103
- package/templates/vue-app/files/src/assets/styles/eladmin.scss +124 -124
- package/templates/vue-app/files/src/assets/styles/element-ui.scss +217 -217
- package/templates/vue-app/files/src/assets/styles/element-variables.scss +31 -31
- package/templates/vue-app/files/src/assets/styles/global.scss +73 -73
- package/templates/vue-app/files/src/assets/styles/index.scss +220 -220
- package/templates/vue-app/files/src/assets/styles/mixin.scss +60 -60
- package/templates/vue-app/files/src/assets/styles/publicStyle.scss +224 -224
- package/templates/vue-app/files/src/assets/styles/sidebar.scss +239 -239
- package/templates/vue-app/files/src/assets/styles/transition.scss +48 -48
- package/templates/vue-app/files/src/assets/styles/variables.scss +44 -44
- package/templates/vue-app/files/src/common/flexible.js +145 -145
- package/templates/vue-app/files/src/components/Breadcrumb/index.vue +87 -87
- package/templates/vue-app/files/src/components/Crud/CRUD.operation.vue +248 -248
- package/templates/vue-app/files/src/components/Crud/Pagination.vue +20 -20
- package/templates/vue-app/files/src/components/Crud/RR.operation.vue +39 -39
- package/templates/vue-app/files/src/components/Crud/UD.operation.vue +106 -106
- package/templates/vue-app/files/src/components/Crud/crud.js +907 -907
- package/templates/vue-app/files/src/components/Crud/user/UR.operation.vue +154 -154
- package/templates/vue-app/files/src/components/DateRangePicker/index.vue +42 -42
- package/templates/vue-app/files/src/components/DateRangePickerProhibitNext/index.vue +42 -42
- package/templates/vue-app/files/src/components/DateRangePickerProhibitTodayNext/index.vue +48 -48
- package/templates/vue-app/files/src/components/Dict/Dict.js +31 -31
- package/templates/vue-app/files/src/components/Dict/index.js +29 -29
- package/templates/vue-app/files/src/components/Doc/index.vue +16 -16
- package/templates/vue-app/files/src/components/Echarts/BarChart.vue +115 -115
- package/templates/vue-app/files/src/components/Echarts/Category.vue +768 -768
- package/templates/vue-app/files/src/components/Echarts/Funnel.vue +120 -120
- package/templates/vue-app/files/src/components/Echarts/Gauge.vue +74 -74
- package/templates/vue-app/files/src/components/Echarts/Graph.vue +101 -101
- package/templates/vue-app/files/src/components/Echarts/HeatMap.vue +301 -301
- package/templates/vue-app/files/src/components/Echarts/Line3D.vue +110 -110
- package/templates/vue-app/files/src/components/Echarts/PieChart.vue +84 -84
- package/templates/vue-app/files/src/components/Echarts/Point.vue +161 -161
- package/templates/vue-app/files/src/components/Echarts/RadarChart.vue +123 -123
- package/templates/vue-app/files/src/components/Echarts/Rich.vue +160 -160
- package/templates/vue-app/files/src/components/Echarts/Sankey.vue +114 -114
- package/templates/vue-app/files/src/components/Echarts/Scatter.vue +192 -192
- package/templates/vue-app/files/src/components/Echarts/Sunburst.vue +127 -127
- package/templates/vue-app/files/src/components/Echarts/ThemeRiver.vue +233 -233
- package/templates/vue-app/files/src/components/Echarts/WordCloud.vue +201 -201
- package/templates/vue-app/files/src/components/GithubCorner/index.vue +55 -55
- package/templates/vue-app/files/src/components/Hamburger/index.vue +44 -44
- package/templates/vue-app/files/src/components/HeaderSearch/index.vue +196 -196
- package/templates/vue-app/files/src/components/IconSelect/index.vue +74 -74
- package/templates/vue-app/files/src/components/IconSelect/requireIcons.js +10 -10
- package/templates/vue-app/files/src/components/Iframe/index.vue +30 -30
- package/templates/vue-app/files/src/components/JavaEdit/index.vue +78 -78
- package/templates/vue-app/files/src/components/Pagination/index.vue +100 -100
- package/templates/vue-app/files/src/components/PanThumb/index.vue +149 -149
- package/templates/vue-app/files/src/components/ParentView/index.vue +3 -3
- package/templates/vue-app/files/src/components/Permission/index.js +13 -13
- package/templates/vue-app/files/src/components/Permission/permission.js +21 -21
- package/templates/vue-app/files/src/components/RightPanel/index.vue +149 -149
- package/templates/vue-app/files/src/components/Screenfull/index.vue +60 -60
- package/templates/vue-app/files/src/components/SizeSelect/index.vue +60 -60
- package/templates/vue-app/files/src/components/SvgIcon/index.vue +66 -66
- package/templates/vue-app/files/src/components/ThemePicker/index.vue +177 -177
- package/templates/vue-app/files/src/components/UploadExcel/index.vue +149 -149
- package/templates/vue-app/files/src/components/WaterMark/setWaterMark.js +68 -68
- package/templates/vue-app/files/src/components/WaterMark/waterMark.vue +69 -69
- package/templates/vue-app/files/src/components/Xgplayer/index.vue +49 -49
- package/templates/vue-app/files/src/components/YamlEdit/index.vue +81 -81
- package/templates/vue-app/files/src/layout/components/AppMain.vue +67 -67
- package/templates/vue-app/files/src/layout/components/Navbar.vue +209 -209
- package/templates/vue-app/files/src/layout/components/Settings/index.vue +125 -125
- package/templates/vue-app/files/src/layout/components/Sidebar/FixiOSBug.js +26 -26
- package/templates/vue-app/files/src/layout/components/Sidebar/Item.vue +29 -29
- package/templates/vue-app/files/src/layout/components/Sidebar/Link.vue +35 -35
- package/templates/vue-app/files/src/layout/components/Sidebar/Logo.vue +93 -93
- package/templates/vue-app/files/src/layout/components/Sidebar/SidebarItem.vue +104 -104
- package/templates/vue-app/files/src/layout/components/Sidebar/index.vue +79 -79
- package/templates/vue-app/files/src/layout/components/TagsView/ScrollPane.vue +90 -90
- package/templates/vue-app/files/src/layout/components/TagsView/index.vue +299 -299
- package/templates/vue-app/files/src/layout/components/index.js +5 -5
- package/templates/vue-app/files/src/layout/index.vue +119 -119
- package/templates/vue-app/files/src/layout/mixin/ResizeHandler.js +45 -45
- package/templates/vue-app/files/src/main.js +89 -89
- package/templates/vue-app/files/src/mixins/crud.js +348 -348
- package/templates/vue-app/files/src/router/index.js +156 -156
- package/templates/vue-app/files/src/router/routers.js +203 -203
- package/templates/vue-app/files/src/settings.js +57 -57
- package/templates/vue-app/files/src/store/getters.js +29 -29
- package/templates/vue-app/files/src/store/index.js +25 -25
- package/templates/vue-app/files/src/store/modules/api.js +33 -33
- package/templates/vue-app/files/src/store/modules/app.js +55 -55
- package/templates/vue-app/files/src/store/modules/permission.js +79 -79
- package/templates/vue-app/files/src/store/modules/register.js +17 -17
- package/templates/vue-app/files/src/store/modules/settings.js +46 -46
- package/templates/vue-app/files/src/store/modules/tagsView.js +168 -168
- package/templates/vue-app/files/src/store/modules/user.js +119 -119
- package/templates/vue-app/files/src/utils/auth.js +18 -18
- package/templates/vue-app/files/src/utils/base64ToFile.js +27 -27
- package/templates/vue-app/files/src/utils/clipboard.js +36 -36
- package/templates/vue-app/files/src/utils/datetime.js +289 -289
- package/templates/vue-app/files/src/utils/getBlobFile.js +10 -10
- package/templates/vue-app/files/src/utils/getTime.js +29 -29
- package/templates/vue-app/files/src/utils/index.js +520 -520
- package/templates/vue-app/files/src/utils/permission.js +29 -29
- package/templates/vue-app/files/src/utils/pinyin.js +450 -450
- package/templates/vue-app/files/src/utils/request.js +139 -139
- package/templates/vue-app/files/src/utils/rsaEncrypt.js +37 -37
- package/templates/vue-app/files/src/utils/shortcuts.js +210 -210
- package/templates/vue-app/files/src/utils/upload.js +12 -12
- package/templates/vue-app/files/src/utils/validate.js +262 -262
- package/templates/vue-app/files/src/views/components/Echarts.vue +124 -124
- package/templates/vue-app/files/src/views/components/Editor.vue +75 -75
- package/templates/vue-app/files/src/views/components/MarkDown.vue +44 -44
- package/templates/vue-app/files/src/views/components/UVideo.vue +37 -37
- package/templates/vue-app/files/src/views/components/YamlEdit.vue +206 -206
- package/templates/vue-app/files/src/views/components/camera/camera.vue +115 -115
- package/templates/vue-app/files/src/views/components/camera/cameraTest.vue +158 -158
- package/templates/vue-app/files/src/views/components/excel/upload-excel.vue +41 -41
- package/templates/vue-app/files/src/views/components/icons/element-icons.js +74 -74
- package/templates/vue-app/files/src/views/components/icons/index.vue +106 -106
- package/templates/vue-app/files/src/views/components/icons/svg-icons.js +10 -10
- package/templates/vue-app/files/src/views/components/scroll/index.vue +107 -107
- package/templates/vue-app/files/src/views/components/scrollFull/index.vue +99 -99
- package/templates/vue-app/files/src/views/dashboard/LineChart.vue +138 -138
- package/templates/vue-app/files/src/views/dashboard/PanelGroup.vue +173 -173
- package/templates/vue-app/files/src/views/dashboard/mixins/resize.js +57 -57
- package/templates/vue-app/files/src/views/dataArchive/delTable.vue +354 -354
- package/templates/vue-app/files/src/views/dataArchive/exportDetail.vue +121 -121
- package/templates/vue-app/files/src/views/dataArchive/exportList.vue +160 -160
- package/templates/vue-app/files/src/views/dataArchive/index.vue +2104 -2104
- package/templates/vue-app/files/src/views/features/401.vue +83 -83
- package/templates/vue-app/files/src/views/features/404.vue +226 -226
- package/templates/vue-app/files/src/views/features/redirect.vue +12 -12
- package/templates/vue-app/files/src/views/generator/config.vue +348 -348
- package/templates/vue-app/files/src/views/generator/index.vue +143 -143
- package/templates/vue-app/files/src/views/generator/preview.vue +39 -39
- package/templates/vue-app/files/src/views/home.vue +80 -80
- package/templates/vue-app/files/src/views/indexManagement/index.vue +422 -422
- package/templates/vue-app/files/src/views/indexManagement/other.vue +286 -286
- package/templates/vue-app/files/src/views/institutionMonitor/components/LineChart.vue +191 -191
- package/templates/vue-app/files/src/views/institutionMonitor/index.scss +339 -339
- package/templates/vue-app/files/src/views/institutionMonitor/index.vue +1385 -1385
- package/templates/vue-app/files/src/views/institutionMonitor/mixins/resize.js +57 -57
- package/templates/vue-app/files/src/views/institutionMonitor/monitorDetail/checkProjectCode.vue +267 -267
- package/templates/vue-app/files/src/views/institutionMonitor/monitorDetail/imageAbnormalMonitor.vue +361 -361
- package/templates/vue-app/files/src/views/institutionMonitor/monitorDetail/index.vue +686 -686
- package/templates/vue-app/files/src/views/institutionMonitor/monitorDetail/leakageAnomaly.vue +270 -270
- package/templates/vue-app/files/src/views/institutionMonitor/monitorDetail/moveMonitore.vue +114 -114
- package/templates/vue-app/files/src/views/institutionMonitor/monitorDetail/qualityMonitore.vue +338 -338
- package/templates/vue-app/files/src/views/institutionSet/cloudSet.vue +534 -534
- package/templates/vue-app/files/src/views/institutionSet/index.vue +2550 -2550
- package/templates/vue-app/files/src/views/login.vue +243 -243
- package/templates/vue-app/files/src/views/qualityLogin.vue +280 -280
- package/templates/vue-app/files/src/views/selfStatistics/components/LineChart.vue +296 -296
- package/templates/vue-app/files/src/views/selfStatistics/hospitalDetail/index.vue +533 -533
- package/templates/vue-app/files/src/views/selfStatistics/index.scss +447 -447
- package/templates/vue-app/files/src/views/selfStatistics/index.vue +903 -903
- package/templates/vue-app/files/src/views/selfStatistics/mixins/resize.js +57 -57
- package/templates/vue-app/files/src/views/selfStatistics/monitorDetail/index.vue +285 -285
- package/templates/vue-app/files/src/views/selfStatistics/offlineDetail/index.vue +104 -104
- package/templates/vue-app/files/src/views/selfStatistics/selfActiveDetail/index.vue +104 -104
- package/templates/vue-app/files/src/views/selfStatistics/selfMonitorDetail/index.vue +420 -420
- package/templates/vue-app/files/src/views/selfStatistics/setWaterMark/setWaterMark.js +68 -68
- package/templates/vue-app/files/src/views/selfStatistics/setWaterMark/waterMark.vue +69 -69
- package/templates/vue-app/files/src/views/system/dept/index.vue +144 -144
- package/templates/vue-app/files/src/views/system/dict/dictDetail.vue +146 -146
- package/templates/vue-app/files/src/views/system/dict/index.vue +159 -159
- package/templates/vue-app/files/src/views/system/examModality/index.vue +174 -174
- package/templates/vue-app/files/src/views/system/examPart/index.vue +184 -184
- package/templates/vue-app/files/src/views/system/examProject/index.vue +321 -321
- package/templates/vue-app/files/src/views/system/examine/index.vue +66 -66
- package/templates/vue-app/files/src/views/system/job/index.vue +119 -119
- package/templates/vue-app/files/src/views/system/job/module/form.vue +72 -72
- package/templates/vue-app/files/src/views/system/job/module/header.vue +48 -48
- package/templates/vue-app/files/src/views/system/menu/index.vue +327 -327
- package/templates/vue-app/files/src/views/system/model/index.vue +285 -285
- package/templates/vue-app/files/src/views/system/role/index.vue +434 -434
- package/templates/vue-app/files/src/views/system/sysSet/index.vue +84 -84
- package/templates/vue-app/files/src/views/system/timing/index.vue +289 -289
- package/templates/vue-app/files/src/views/system/timing/log.vue +143 -143
- package/templates/vue-app/files/src/views/system/user/admin.vue +414 -414
- package/templates/vue-app/files/src/views/system/user/center/updateEmail.vue +146 -146
- package/templates/vue-app/files/src/views/system/user/center/updatePass.vue +168 -168
- package/templates/vue-app/files/src/views/system/user/center.vue +140 -140
- package/templates/vue-app/files/src/views/system/user/index.vue +972 -972
- package/templates/vue-app/files/src/views/systemSet/role/index.vue +314 -314
- package/templates/vue-app/files/src/views/systemSet/user/admin.vue +414 -414
- package/templates/vue-app/files/src/views/systemSet/user/center/updateEmail.vue +146 -146
- package/templates/vue-app/files/src/views/systemSet/user/center/updatePass.vue +115 -115
- package/templates/vue-app/files/src/views/systemSet/user/center.vue +351 -351
- package/templates/vue-app/files/src/views/systemSet/user/index.vue +928 -928
- package/templates/vue-app/files/src/views/tools/aliPay/config.vue +102 -102
- package/templates/vue-app/files/src/views/tools/aliPay/index.vue +48 -48
- package/templates/vue-app/files/src/views/tools/aliPay/toPay.vue +91 -91
- package/templates/vue-app/files/src/views/tools/email/config.vue +91 -91
- package/templates/vue-app/files/src/views/tools/email/index.vue +42 -42
- package/templates/vue-app/files/src/views/tools/email/send.vue +159 -159
- package/templates/vue-app/files/src/views/tools/storage/index.vue +35 -35
- package/templates/vue-app/files/src/views/tools/storage/local/index.vue +207 -207
- package/templates/vue-app/files/src/views/tools/storage/qiniu/form.vue +108 -108
- package/templates/vue-app/files/src/views/tools/storage/qiniu/index.vue +241 -241
- package/templates/vue-app/files/src/views/tools/swagger/index.vue +14 -14
- package/templates/vue-app/files/vue.config.js +173 -173
- package/templates/vue-app/template.json +29 -29
package/lib/config.js
CHANGED
|
@@ -1,283 +1,325 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const fs = require('fs-extra');
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return
|
|
71
|
-
} catch (e) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
log.
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fs = require('fs-extra');
|
|
3
|
+
const inquirer = require('inquirer');
|
|
4
|
+
const { log } = require('./utils');
|
|
5
|
+
const {
|
|
6
|
+
getConfigPath,
|
|
7
|
+
readConfigSafe,
|
|
8
|
+
assertConfigMigrated,
|
|
9
|
+
findEnvironment,
|
|
10
|
+
buildMigratedConfig,
|
|
11
|
+
CONFIG_VERSION,
|
|
12
|
+
} = require('./environments');
|
|
13
|
+
|
|
14
|
+
function writeIfAllowed(filePath, content, force) {
|
|
15
|
+
if (fs.existsSync(filePath) && !force) {
|
|
16
|
+
log.warn(`已存在,跳过:${path.relative(process.cwd(), filePath)}`);
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
fs.ensureDirSync(path.dirname(filePath));
|
|
20
|
+
fs.writeFileSync(filePath, content, 'utf-8');
|
|
21
|
+
log.success(`已写入:${path.relative(process.cwd(), filePath)}`);
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 生成 config/default-<envName>.js 的内容:
|
|
27
|
+
* 注入 `let env = '<envName>';` 与 `let isDev = (envName === 'dev');`(向后兼容旧代码)
|
|
28
|
+
*/
|
|
29
|
+
function deriveDefaultVariantContent(baseContent, envName) {
|
|
30
|
+
const isDev = envName === 'dev';
|
|
31
|
+
|
|
32
|
+
let content = baseContent || '';
|
|
33
|
+
const envRe = /let\s+env\s*=\s*[^;]*;/;
|
|
34
|
+
const devRe = /let\s+isDev\s*=\s*[^;]*;/;
|
|
35
|
+
|
|
36
|
+
if (envRe.test(content)) {
|
|
37
|
+
content = content.replace(envRe, `let env = '${envName}';`);
|
|
38
|
+
} else {
|
|
39
|
+
content = `let env = '${envName}';\n` + content;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (devRe.test(content)) {
|
|
43
|
+
content = content.replace(devRe, `let isDev = ${isDev};`);
|
|
44
|
+
} else {
|
|
45
|
+
content = `let isDev = ${isDev};\n` + content;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// isProd 已废弃:prod 使用 isDev=false 表示
|
|
49
|
+
// 删除历史遗留的 isProd 变量与输出字段(若存在)
|
|
50
|
+
content = content.replace(/let\s+isProd\s*=\s*[^;]*;\s*\r?\n?/g, '');
|
|
51
|
+
content = content.replace(/window\.config\.IS_PROD\s*=\s*[^;]*;\s*\r?\n?/g, '');
|
|
52
|
+
content = content.replace(/^\s*IS_PROD\s*:\s*[^,}]*,?\s*\r?\n?/gm, '');
|
|
53
|
+
|
|
54
|
+
return content;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function copyFile({ src, dest }) {
|
|
58
|
+
fs.ensureDirSync(path.dirname(dest));
|
|
59
|
+
if (!fs.existsSync(src)) {
|
|
60
|
+
log.warn(`未找到源文件:${path.relative(process.cwd(), src)}`);
|
|
61
|
+
return { ok: false, method: 'missing' };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (fs.existsSync(dest)) {
|
|
65
|
+
fs.removeSync(dest);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
fs.copyFileSync(src, dest);
|
|
70
|
+
return { ok: true };
|
|
71
|
+
} catch (e) {
|
|
72
|
+
log.error(`写入失败:${e.message}`);
|
|
73
|
+
return { ok: false };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 切换到指定环境:把 config/default-<name>.js 复制到该环境的目标位置
|
|
79
|
+
* - isLocal 环境 -> publicDir/default.js
|
|
80
|
+
* - 其他环境 -> <环境 buildDir>/default.js
|
|
81
|
+
*/
|
|
82
|
+
function setEnv(name) {
|
|
83
|
+
const configPath = getConfigPath();
|
|
84
|
+
const configExists = fs.existsSync(configPath);
|
|
85
|
+
const config = readConfigSafe(configPath);
|
|
86
|
+
assertConfigMigrated(config, configExists);
|
|
87
|
+
|
|
88
|
+
const env = findEnvironment(config, name);
|
|
89
|
+
|
|
90
|
+
const configDir = path.resolve(process.cwd(), config.configDir || 'config');
|
|
91
|
+
const publicDir = path.resolve(process.cwd(), config.publicDir || 'public');
|
|
92
|
+
const defaultVariant = path.join(configDir, `default-${env.name}.js`);
|
|
93
|
+
|
|
94
|
+
// ponytail: 信任本地 .ylyxrc.json 的路径配置,不做路径穿越校验(本地 CLI 工具,配置由用户自行维护)
|
|
95
|
+
let targetDir;
|
|
96
|
+
if (env.isLocal) {
|
|
97
|
+
targetDir = publicDir;
|
|
98
|
+
} else {
|
|
99
|
+
if (!env.buildDir) {
|
|
100
|
+
throw new Error(`环境 "${env.name}" 未配置 buildDir,无法确定切换目标目录`);
|
|
101
|
+
}
|
|
102
|
+
targetDir = path.resolve(process.cwd(), env.buildDir);
|
|
103
|
+
}
|
|
104
|
+
const defaultFile = path.join(targetDir, 'default.js');
|
|
105
|
+
|
|
106
|
+
const result = copyFile({ src: defaultVariant, dest: defaultFile });
|
|
107
|
+
|
|
108
|
+
if (result.ok) {
|
|
109
|
+
log.success(
|
|
110
|
+
`已切换 ${path.relative(process.cwd(), defaultFile)} <- ${path.relative(
|
|
111
|
+
process.cwd(),
|
|
112
|
+
defaultVariant
|
|
113
|
+
)}`
|
|
114
|
+
);
|
|
115
|
+
} else if (!result.ok && !fs.existsSync(defaultVariant)) {
|
|
116
|
+
log.warn(`未找到 ${path.relative(process.cwd(), defaultVariant)},请先运行 ylyx init config`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
config.currentEnv = env.name;
|
|
120
|
+
fs.writeJsonSync(configPath, config, { spaces: 2 });
|
|
121
|
+
log.success(`已写入配置:currentEnv=${env.name}`);
|
|
122
|
+
log.info(`配置文件:${configPath}`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* 交互式选择环境并切换:按 isLocal 分组展示,当前环境标注"(当前)",
|
|
127
|
+
* 默认光标停在当前环境,选定后复用 setEnv 完成实际切换
|
|
128
|
+
*/
|
|
129
|
+
async function chooseEnvInteractive() {
|
|
130
|
+
const configPath = getConfigPath();
|
|
131
|
+
const configExists = fs.existsSync(configPath);
|
|
132
|
+
const config = readConfigSafe(configPath);
|
|
133
|
+
assertConfigMigrated(config, configExists);
|
|
134
|
+
|
|
135
|
+
const environments = config.environments || [];
|
|
136
|
+
if (environments.length === 0) {
|
|
137
|
+
throw new Error('环境列表为空,请先在 .ylyxrc.json 配置 environments 或运行 ylyx init config');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const currentEnv = config.currentEnv;
|
|
141
|
+
const toChoice = (e) => ({
|
|
142
|
+
name: e.name === currentEnv ? `${e.name}(当前)` : e.name,
|
|
143
|
+
value: e.name,
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const localEnvs = environments.filter((e) => e.isLocal);
|
|
147
|
+
const remoteEnvs = environments.filter((e) => !e.isLocal);
|
|
148
|
+
|
|
149
|
+
const choices = [];
|
|
150
|
+
if (localEnvs.length > 0) {
|
|
151
|
+
choices.push(new inquirer.Separator('-- 本地环境 --'));
|
|
152
|
+
choices.push(...localEnvs.map(toChoice));
|
|
153
|
+
}
|
|
154
|
+
if (remoteEnvs.length > 0) {
|
|
155
|
+
choices.push(new inquirer.Separator('-- 部署环境 --'));
|
|
156
|
+
choices.push(...remoteEnvs.map(toChoice));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const ans = await inquirer.prompt([
|
|
160
|
+
{
|
|
161
|
+
type: 'list',
|
|
162
|
+
name: 'env',
|
|
163
|
+
message: '请选择要切换到的环境',
|
|
164
|
+
choices,
|
|
165
|
+
default: currentEnv,
|
|
166
|
+
},
|
|
167
|
+
]);
|
|
168
|
+
|
|
169
|
+
setEnv(ans.env);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* 迁移旧版 .ylyxrc.json(mode/deploy/顶层 buildDir/preScripts)到 environments 结构
|
|
174
|
+
*/
|
|
175
|
+
function migrateConfig() {
|
|
176
|
+
const configPath = getConfigPath();
|
|
177
|
+
const existing = readConfigSafe(configPath);
|
|
178
|
+
|
|
179
|
+
if (typeof existing.configVersion === 'number' && existing.configVersion >= CONFIG_VERSION) {
|
|
180
|
+
log.info(`当前配置已是最新版本(configVersion=${existing.configVersion}),无需迁移`);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const migrated = buildMigratedConfig(existing);
|
|
185
|
+
fs.writeJsonSync(configPath, migrated, { spaces: 2 });
|
|
186
|
+
|
|
187
|
+
const names = migrated.environments.map((e) => e.name).join(', ');
|
|
188
|
+
log.success(`迁移完成,已生成环境:${names}`);
|
|
189
|
+
log.warn('请检查 test/prod 环境的 host/username/password 等敏感信息是否正确');
|
|
190
|
+
log.info('请运行 `ylyx init config --force` 以补写 package.json 的 pre/post 钩子(迁移命令不会修改 package.json)');
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* init config:初始化配置目录与示例文件
|
|
195
|
+
* - 写入/补齐 .ylyxrc.json(configVersion/environments/currentEnv/publicDir/configDir)
|
|
196
|
+
* - 为每个环境生成 config/default-<name>.js(基于现有 public/default.js 派生)
|
|
197
|
+
* - 若 public/default.js 不存在,则按 currentEnv 生成一份
|
|
198
|
+
* - 按每个环境的 npmScript 写 package.json 的 pre/post 钩子
|
|
199
|
+
*/
|
|
200
|
+
function initConfig(options = {}) {
|
|
201
|
+
const force = !!options.force;
|
|
202
|
+
const configPath = getConfigPath();
|
|
203
|
+
const existing = readConfigSafe(configPath);
|
|
204
|
+
|
|
205
|
+
const hasEnvironments = Array.isArray(existing.environments) && existing.environments.length > 0;
|
|
206
|
+
if (Array.isArray(existing.environments) && existing.environments.length === 0) {
|
|
207
|
+
log.info('检测到 .ylyxrc.json 中 environments 为空数组,已使用默认环境(dev/prod)填充');
|
|
208
|
+
}
|
|
209
|
+
const environments = hasEnvironments
|
|
210
|
+
? existing.environments
|
|
211
|
+
: [
|
|
212
|
+
{ name: 'dev', isLocal: true, npmScript: 'dev', deployMethod: 'none' },
|
|
213
|
+
{
|
|
214
|
+
name: 'prod',
|
|
215
|
+
npmScript: 'build:prod',
|
|
216
|
+
deployMethod: 'zip',
|
|
217
|
+
buildDir: 'dist/app',
|
|
218
|
+
zipOutDir: './.ylyx-deploy',
|
|
219
|
+
},
|
|
220
|
+
];
|
|
221
|
+
|
|
222
|
+
let currentEnv = existing.currentEnv || 'dev';
|
|
223
|
+
if (options.env) {
|
|
224
|
+
const exists = environments.some((e) => e.name === options.env);
|
|
225
|
+
if (!exists) {
|
|
226
|
+
throw new Error(
|
|
227
|
+
`环境不存在: ${options.env}\n可用环境: ${environments.map((e) => e.name).join(', ')}`
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
currentEnv = options.env;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const next = {
|
|
234
|
+
...existing,
|
|
235
|
+
configVersion: CONFIG_VERSION,
|
|
236
|
+
publicDir: existing.publicDir || './public',
|
|
237
|
+
configDir: existing.configDir || './config',
|
|
238
|
+
currentEnv,
|
|
239
|
+
environments,
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
fs.writeJsonSync(configPath, next, { spaces: 2 });
|
|
243
|
+
log.success(`已初始化配置文件:${path.relative(process.cwd(), configPath)}`);
|
|
244
|
+
|
|
245
|
+
const publicDirAbs = path.resolve(process.cwd(), next.publicDir);
|
|
246
|
+
const configDirAbs = path.resolve(process.cwd(), next.configDir);
|
|
247
|
+
fs.ensureDirSync(publicDirAbs);
|
|
248
|
+
fs.ensureDirSync(configDirAbs);
|
|
249
|
+
|
|
250
|
+
const publicDefault = path.join(publicDirAbs, 'default.js');
|
|
251
|
+
let baseContent = '';
|
|
252
|
+
if (fs.existsSync(publicDefault)) {
|
|
253
|
+
baseContent = fs.readFileSync(publicDefault, 'utf-8');
|
|
254
|
+
} else {
|
|
255
|
+
baseContent = '// 自动生成的默认配置(请按项目需要补全)\n';
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
for (const env of next.environments) {
|
|
259
|
+
const variantPath = path.join(configDirAbs, `default-${env.name}.js`);
|
|
260
|
+
writeIfAllowed(variantPath, deriveDefaultVariantContent(baseContent, env.name), force);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (!fs.existsSync(publicDefault)) {
|
|
264
|
+
const src = path.join(configDirAbs, `default-${next.currentEnv}.js`);
|
|
265
|
+
if (fs.existsSync(src)) {
|
|
266
|
+
fs.copyFileSync(src, publicDefault);
|
|
267
|
+
log.success(
|
|
268
|
+
`已生成 ${path.relative(process.cwd(), publicDefault)} <- ${path.relative(process.cwd(), src)}`
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
} else {
|
|
272
|
+
log.info(`已存在:${path.relative(process.cwd(), publicDefault)}(未覆盖)`);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const packageJsonPath = path.join(process.cwd(), 'package.json');
|
|
276
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
277
|
+
log.warn('未找到 package.json,已跳过 npm 钩子初始化');
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
let pkg = {};
|
|
282
|
+
try {
|
|
283
|
+
pkg = fs.readJsonSync(packageJsonPath);
|
|
284
|
+
} catch (e) {
|
|
285
|
+
throw new Error(`读取 package.json 失败,请确认它是有效 JSON:${e.message}`);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
pkg.scripts = pkg.scripts || {};
|
|
289
|
+
|
|
290
|
+
for (const env of next.environments) {
|
|
291
|
+
const npmScript = env.npmScript;
|
|
292
|
+
if (!npmScript) continue;
|
|
293
|
+
|
|
294
|
+
let hookName;
|
|
295
|
+
let hookValue;
|
|
296
|
+
if (env.isLocal) {
|
|
297
|
+
hookName = `pre${npmScript}`;
|
|
298
|
+
hookValue = `ylyx config ${env.name}`;
|
|
299
|
+
} else {
|
|
300
|
+
hookName = `post${npmScript}`;
|
|
301
|
+
hookValue =
|
|
302
|
+
env.deployMethod && env.deployMethod !== 'none'
|
|
303
|
+
? `ylyx config ${env.name} && ylyx deploy --env ${env.name}`
|
|
304
|
+
: `ylyx config ${env.name}`;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (pkg.scripts[hookName] && !force) {
|
|
308
|
+
log.warn(`package.json scripts 已存在,跳过:${hookName}`);
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
pkg.scripts[hookName] = hookValue;
|
|
312
|
+
log.success(`已写入 package.json scripts:${hookName}`);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
fs.writeJsonSync(packageJsonPath, pkg, { spaces: 2 });
|
|
316
|
+
log.info(`package.json:${path.relative(process.cwd(), packageJsonPath)}`);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
module.exports = {
|
|
320
|
+
setEnv,
|
|
321
|
+
initConfig,
|
|
322
|
+
migrateConfig,
|
|
323
|
+
chooseEnvInteractive,
|
|
324
|
+
deriveDefaultVariantContent,
|
|
325
|
+
};
|