neo-cmp-cli 1.8.6-beta.6 → 1.8.7
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/bin/index.js +2 -2
- package/package.json +3 -3
- package/src/config/auth.config.js +27 -0
- package/src/config/default.config.js +176 -0
- package/src/config/index.js +9 -0
- package/src/initData/defaultTemplate.html +13 -0
- package/src/initData/neo.config.js +138 -0
- package/src/main.js +221 -0
- package/src/module/inspect.js +41 -0
- package/src/module/neoInit.js +55 -0
- package/src/module/neoInitByCopy.js +61 -0
- package/src/neo/NeoUMDContent.js +30 -0
- package/src/neo/neoLogin.js +565 -0
- package/src/neo/neoRequire.js +125 -0
- package/src/neo/neoService.js +874 -0
- package/src/neo/webpack.mf.js +60 -0
- package/src/neo/wrapperContent.js +16 -0
- package/src/oss/publish2oss.js +348 -0
- package/src/plugins/AddNeoRequirePlugin-v1.js +47 -0
- package/src/plugins/AddNeoRequirePlugin.js +179 -0
- package/src/plugins/README.md +109 -0
- package/src/utils/autoEntryRootDir.js +85 -0
- package/src/utils/cmpUtils/createCmpByTemplate.js +60 -0
- package/src/utils/cmpUtils/createCmpByZip.js +408 -0
- package/src/utils/cmpUtils/createCommonModulesCode.js +121 -0
- package/src/utils/cmpUtils/deleteCmp.js +63 -0
- package/src/utils/cmpUtils/getCmpModelRegisterCode.js +31 -0
- package/src/utils/cmpUtils/getCmpPreviewCode.js +43 -0
- package/src/utils/cmpUtils/getCmpRegisterCode.js +31 -0
- package/src/utils/cmpUtils/getCmpTypeByDir.js +41 -0
- package/src/utils/cmpUtils/hasCmpTypeByDir.js +11 -0
- package/src/utils/cmpUtils/previewCmp.js +55 -0
- package/src/utils/cmpUtils/pullCmp.js +104 -0
- package/src/utils/cmpUtils/pushCmp.js +230 -0
- package/src/utils/common.js +107 -0
- package/src/utils/configureNeoBuild.js +109 -0
- package/src/utils/generateEntries.js +63 -0
- package/src/utils/neoConfigInit.js +13 -0
- package/src/utils/neoParams.js +12 -0
- package/src/utils/pathUtils.js +23 -0
- package/src/utils/projectNameValidator.js +76 -0
- package/src/utils/projectUtils/createCmpProjectByTemplate.js +59 -0
- package/src/utils/projectUtils/createCmpProjectZip.js +120 -0
- package/src/utils/projectUtils/getEntries.js +80 -0
- package/src/utils/projectUtils/getEntriesWithAutoRegister.js +108 -0
- package/src/utils/projectUtils/hasNeoProject.js +17 -0
- package/src/utils/projectUtils/openProject.js +96 -0
- package/src/utils/projectUtils/updatePublishLog.js +30 -0
- package/src/utils/replaceInFiles.js +47 -0
- package/src/utils/replaceInFilesByMap.js +54 -0
- package/src/utils/replaceInPackage.js +134 -0
- package/src/utils/resetPackageVersion.js +115 -0
- package/test/deprecate-versions.js +1 -1
- package/test/neo.config.js +1 -25
- package/dist/_virtual/AddNeoRequirePlugin.js +0 -8
- package/dist/_virtual/OverloadYield.js +0 -5
- package/dist/_virtual/_commonjsHelpers.js +0 -40
- package/dist/_virtual/array-set.js +0 -5
- package/dist/_virtual/base64-vlq.js +0 -5
- package/dist/_virtual/base64.js +0 -5
- package/dist/_virtual/binary-search.js +0 -5
- package/dist/_virtual/createCmpByZip.js +0 -8
- package/dist/_virtual/deleteCmp.js +0 -8
- package/dist/_virtual/index.js +0 -9
- package/dist/_virtual/mapping-list.js +0 -5
- package/dist/_virtual/neoLogin.js +0 -8
- package/dist/_virtual/neoService.js +0 -8
- package/dist/_virtual/openProject.js +0 -8
- package/dist/_virtual/publish2oss.js +0 -8
- package/dist/_virtual/pullCmp.js +0 -8
- package/dist/_virtual/pushCmp.js +0 -8
- package/dist/_virtual/quick-sort.js +0 -5
- package/dist/_virtual/regenerator.js +0 -5
- package/dist/_virtual/regeneratorAsync.js +0 -5
- package/dist/_virtual/regeneratorAsyncGen.js +0 -5
- package/dist/_virtual/regeneratorAsyncIterator.js +0 -5
- package/dist/_virtual/regeneratorDefine.js +0 -5
- package/dist/_virtual/regeneratorKeys.js +0 -5
- package/dist/_virtual/regeneratorRuntime.js +0 -5
- package/dist/_virtual/regeneratorValues.js +0 -5
- package/dist/_virtual/source-map-consumer.js +0 -5
- package/dist/_virtual/source-map-generator.js +0 -5
- package/dist/_virtual/source-map-support.js +0 -5
- package/dist/_virtual/source-map.js +0 -5
- package/dist/_virtual/source-node.js +0 -5
- package/dist/_virtual/typeof.js +0 -5
- package/dist/_virtual/typescript.js +0 -5
- package/dist/_virtual/util.js +0 -5
- package/dist/config/auth.config.js +0 -50
- package/dist/config/default.config.js +0 -225
- package/dist/config/index.js +0 -27
- package/dist/main.js +0 -9
- package/dist/main2.js +0 -261
- package/dist/module/inspect.js +0 -64
- package/dist/module/neoInit.js +0 -69
- package/dist/module/neoInitByCopy.js +0 -81
- package/dist/neo/neoLogin.js +0 -663
- package/dist/neo/neoRequire.js +0 -118
- package/dist/neo/neoService.js +0 -1246
- package/dist/node_modules/@babel/runtime/helpers/OverloadYield.js +0 -19
- package/dist/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js +0 -29
- package/dist/node_modules/@babel/runtime/helpers/esm/extends.js +0 -13
- package/dist/node_modules/@babel/runtime/helpers/regenerator.js +0 -105
- package/dist/node_modules/@babel/runtime/helpers/regeneratorAsync.js +0 -24
- package/dist/node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js +0 -23
- package/dist/node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js +0 -50
- package/dist/node_modules/@babel/runtime/helpers/regeneratorDefine.js +0 -37
- package/dist/node_modules/@babel/runtime/helpers/regeneratorKeys.js +0 -25
- package/dist/node_modules/@babel/runtime/helpers/regeneratorRuntime.js +0 -98
- package/dist/node_modules/@babel/runtime/helpers/regeneratorValues.js +0 -35
- package/dist/node_modules/@babel/runtime/helpers/typeof.js +0 -25
- package/dist/node_modules/@babel/runtime/regenerator/index.js +0 -29
- package/dist/node_modules/buffer-from/index.js +0 -57
- package/dist/node_modules/source-map/lib/array-set.js +0 -134
- package/dist/node_modules/source-map/lib/base64-vlq.js +0 -144
- package/dist/node_modules/source-map/lib/base64.js +0 -81
- package/dist/node_modules/source-map/lib/binary-search.js +0 -122
- package/dist/node_modules/source-map/lib/mapping-list.js +0 -94
- package/dist/node_modules/source-map/lib/quick-sort.js +0 -126
- package/dist/node_modules/source-map/lib/source-map-consumer.js +0 -1018
- package/dist/node_modules/source-map/lib/source-map-generator.js +0 -385
- package/dist/node_modules/source-map/lib/source-node.js +0 -400
- package/dist/node_modules/source-map/lib/util.js +0 -449
- package/dist/node_modules/source-map/source-map.js +0 -25
- package/dist/node_modules/source-map-support/source-map-support.js +0 -610
- package/dist/node_modules/typescript/lib/typescript.js +0 -22376
- package/dist/oss/publish2oss.js +0 -378
- package/dist/plugins/AddNeoRequirePlugin.js +0 -178
- package/dist/utils/autoEntryRootDir.js +0 -98
- package/dist/utils/cmpUtils/createCmpByTemplate.js +0 -73
- package/dist/utils/cmpUtils/createCmpByZip.js +0 -530
- package/dist/utils/cmpUtils/createCommonModulesCode.js +0 -84
- package/dist/utils/cmpUtils/deleteCmp.js +0 -98
- package/dist/utils/cmpUtils/getCmpModelRegisterCode.js +0 -38
- package/dist/utils/cmpUtils/getCmpPreviewCode.js +0 -37
- package/dist/utils/cmpUtils/getCmpRegisterCode.js +0 -38
- package/dist/utils/cmpUtils/getCmpTypeByDir.js +0 -58
- package/dist/utils/cmpUtils/hasCmpTypeByDir.js +0 -25
- package/dist/utils/cmpUtils/previewCmp.js +0 -74
- package/dist/utils/cmpUtils/pullCmp.js +0 -144
- package/dist/utils/cmpUtils/pushCmp.js +0 -290
- package/dist/utils/common.js +0 -121
- package/dist/utils/configureNeoBuild.js +0 -153
- package/dist/utils/generateEntries.js +0 -73
- package/dist/utils/neoConfigInit.js +0 -25
- package/dist/utils/neoParams.js +0 -23
- package/dist/utils/pathUtils.js +0 -48
- package/dist/utils/projectNameValidator.js +0 -89
- package/dist/utils/projectUtils/createCmpProjectByTemplate.js +0 -74
- package/dist/utils/projectUtils/createCmpProjectZip.js +0 -135
- package/dist/utils/projectUtils/getEntries.js +0 -99
- package/dist/utils/projectUtils/getEntriesWithAutoRegister.js +0 -127
- package/dist/utils/projectUtils/hasNeoProject.js +0 -31
- package/dist/utils/projectUtils/openProject.js +0 -169
- package/dist/utils/projectUtils/updatePublishLog.js +0 -45
- package/dist/utils/replaceInFilesByMap.js +0 -70
- package/dist/utils/replaceInPackage.js +0 -151
- package/dist/utils/resetPackageVersion.js +0 -134
package/dist/oss/publish2oss.js
DELETED
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var require$$0 = require('akfun');
|
|
4
|
-
var require$$0$1 = require('node:fs');
|
|
5
|
-
var require$$1 = require('node:path');
|
|
6
|
-
var require$$2 = require('lodash');
|
|
7
|
-
var require$$3 = require('ora');
|
|
8
|
-
var pathUtils = require('../utils/pathUtils.js');
|
|
9
|
-
var updatePublishLog$1 = require('../utils/projectUtils/updatePublishLog.js');
|
|
10
|
-
var common = require('../utils/common.js');
|
|
11
|
-
var asyncToGenerator = require('../node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js');
|
|
12
|
-
var index = require('../_virtual/index.js');
|
|
13
|
-
|
|
14
|
-
var _require = require$$0,
|
|
15
|
-
aliBOS = _require.aliBOS,
|
|
16
|
-
baiduBOS = _require.baiduBOS;
|
|
17
|
-
var fs = require$$0$1;
|
|
18
|
-
var path = require$$1;
|
|
19
|
-
var _ = require$$2;
|
|
20
|
-
var ora = require$$3;
|
|
21
|
-
var _require2 = require$$0,
|
|
22
|
-
getConfigObj = _require2.getConfigObj;
|
|
23
|
-
var _require3 = pathUtils.__require(),
|
|
24
|
-
catchCurPackageJson = _require3.catchCurPackageJson;
|
|
25
|
-
var updatePublishLog = updatePublishLog$1.__require();
|
|
26
|
-
var _require4 = common.__require(),
|
|
27
|
-
errorLog = _require4.errorLog,
|
|
28
|
-
warningLog = _require4.warningLog,
|
|
29
|
-
successLog = _require4.successLog;
|
|
30
|
-
|
|
31
|
-
// 获取当前项目的package文件
|
|
32
|
-
var currentPackageJsonDir = catchCurPackageJson();
|
|
33
|
-
var currentPackageJson = getConfigObj(currentPackageJsonDir);
|
|
34
|
-
|
|
35
|
-
// 根据 ossType 获取对应的 BosClient
|
|
36
|
-
var getBosClient = function getBosClient(ossType, ossConfig) {
|
|
37
|
-
if (ossType === 'baidu') {
|
|
38
|
-
return new baiduBOS(ossConfig.endpoint, ossConfig.bucket, ossConfig.AccessKeyId || ossConfig.AccessKeyID || ossConfig.accessKeyId || ossConfig.accessKeyID, ossConfig.AccessKeySecret);
|
|
39
|
-
} else if (ossType === 'ali') {
|
|
40
|
-
return new aliBOS(ossConfig.endpoint, ossConfig.bucket, ossConfig.AccessKeyId || ossConfig.AccessKeyID || ossConfig.accessKeyId || ossConfig.accessKeyID, ossConfig.AccessKeySecret);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
var getFilePath = function getFilePath(ossType, bucket, objectKey) {
|
|
44
|
-
var regions = {
|
|
45
|
-
baidu: 'bj.bcebos.com',
|
|
46
|
-
ali: 'oss-cn-beijing.aliyuncs.com'
|
|
47
|
-
};
|
|
48
|
-
var region = regions[ossType];
|
|
49
|
-
if (!region) {
|
|
50
|
-
throw new Error("\u4E0D\u652F\u6301\u7684oss\u7C7B\u578B: " + ossType);
|
|
51
|
-
}
|
|
52
|
-
return "https://" + bucket + "." + region + "/" + objectKey;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
// 按组件名称进行分类
|
|
56
|
-
var getResultFilesByWidgetName = function getResultFilesByWidgetName(files) {
|
|
57
|
-
var widgetFilesMap = {};
|
|
58
|
-
files.forEach(function (file) {
|
|
59
|
-
if (!file || !file.widgetName) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
var widgetName = file.widgetName;
|
|
63
|
-
var curCmpInfo = {
|
|
64
|
-
cmpType: _.kebabCase(widgetName)
|
|
65
|
-
};
|
|
66
|
-
if (widgetName.includes('Model')) {
|
|
67
|
-
widgetName = widgetName.replace('Model', '');
|
|
68
|
-
curCmpInfo.cmpType = _.kebabCase(widgetName);
|
|
69
|
-
curCmpInfo.modelAsset = !file.success ? file.error + "[" + file.ossPath + "]" : file.ossPath;
|
|
70
|
-
} else if (file.fileName.endsWith('.css')) {
|
|
71
|
-
curCmpInfo.cssAsset = !file.success ? file.error + "[" + file.ossPath + "]" : file.ossPath;
|
|
72
|
-
} else {
|
|
73
|
-
curCmpInfo.asset = !file.success ? file.error + "[" + file.ossPath + "]" : file.ossPath;
|
|
74
|
-
}
|
|
75
|
-
if (widgetFilesMap[widgetName]) {
|
|
76
|
-
widgetFilesMap[widgetName] = Object.assign(widgetFilesMap[widgetName], curCmpInfo);
|
|
77
|
-
} else {
|
|
78
|
-
// widgetFilesMap[widgetName] = [getResultFile(file)];
|
|
79
|
-
widgetFilesMap[widgetName] = curCmpInfo;
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
return widgetFilesMap;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
// 文件名中添加当前项目版本号
|
|
86
|
-
function addVersionToFilename(filename, version, projectName) {
|
|
87
|
-
if (version === void 0) {
|
|
88
|
-
version = currentPackageJson.version;
|
|
89
|
-
}
|
|
90
|
-
if (projectName === void 0) {
|
|
91
|
-
projectName = currentPackageJson.name;
|
|
92
|
-
}
|
|
93
|
-
// 找到最后一个点的位置,用于分离文件名和扩展名
|
|
94
|
-
var lastDotIndex = filename.lastIndexOf('.umd');
|
|
95
|
-
if (lastDotIndex === -1) {
|
|
96
|
-
lastDotIndex = filename.lastIndexOf('.esm');
|
|
97
|
-
}
|
|
98
|
-
if (lastDotIndex === -1) {
|
|
99
|
-
lastDotIndex = filename.lastIndexOf('.lib');
|
|
100
|
-
}
|
|
101
|
-
if (lastDotIndex === -1) {
|
|
102
|
-
lastDotIndex = filename.lastIndexOf('.');
|
|
103
|
-
}
|
|
104
|
-
// 如果没有扩展名(没有点),直接在文件名后添加版本号
|
|
105
|
-
if (lastDotIndex === -1) {
|
|
106
|
-
return projectName + "/" + filename + "-" + version;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// 分离文件名的基础部分和扩展名
|
|
110
|
-
var baseName = filename.substring(0, lastDotIndex);
|
|
111
|
-
var extension = filename.substring(lastDotIndex);
|
|
112
|
-
|
|
113
|
-
// 组合新的文件名:基础名-版本号.扩展名
|
|
114
|
-
return projectName + "/" + baseName + "-" + version + extension;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* 上传单个文件到 OSS
|
|
119
|
-
* @param {object} bosClient OSS 客户端实例
|
|
120
|
-
* @param {string} filePath 文件路径
|
|
121
|
-
* @param {string} objectKey OSS 对象键
|
|
122
|
-
* @param {string} ossType OSS 类型
|
|
123
|
-
* @param {object} ossConfig OSS 配置
|
|
124
|
-
* @param {object} fileInfo 文件信息
|
|
125
|
-
* @returns {Promise<object>} 上传结果
|
|
126
|
-
*/
|
|
127
|
-
function uploadSingleFile(_x, _x2, _x3, _x4, _x5, _x6) {
|
|
128
|
-
return _uploadSingleFile.apply(this, arguments);
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* 将构建产物上传到指定 oss 存储桶
|
|
132
|
-
*
|
|
133
|
-
* @param {string} ossType oss 类型:baidu、ali
|
|
134
|
-
* @param {object} ossConfig oss 配置
|
|
135
|
-
* @param {string} assetsRoot 构建产物的目录
|
|
136
|
-
* @param {array} fileExtensions 需要上传的文件类型,默认 ['.js', '.css']
|
|
137
|
-
*/
|
|
138
|
-
function _uploadSingleFile() {
|
|
139
|
-
_uploadSingleFile = asyncToGenerator(/*#__PURE__*/index.mark(function _callee3(bosClient, filePath, objectKey, ossType, ossConfig, fileInfo) {
|
|
140
|
-
var fileName, fileSizeKB, spinner, historyResult, result, ossPath, _t2;
|
|
141
|
-
return index.wrap(function (_context3) {
|
|
142
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
143
|
-
case 0:
|
|
144
|
-
fileName = path.basename(filePath);
|
|
145
|
-
fileSizeKB = (fs.statSync(filePath).size / 1024).toFixed(2);
|
|
146
|
-
spinner = ora("\u6B63\u5728\u4E0A\u4F20\u6587\u4EF6: " + fileName + " (" + fileSizeKB + "KB)...").start();
|
|
147
|
-
_context3.prev = 1;
|
|
148
|
-
_context3.next = 2;
|
|
149
|
-
return bosClient.get(objectKey);
|
|
150
|
-
case 2:
|
|
151
|
-
historyResult = _context3.sent;
|
|
152
|
-
if (!(historyResult && historyResult.url)) {
|
|
153
|
-
_context3.next = 3;
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
spinner.warn("\u6587\u4EF6\u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7\u4E0A\u4F20: " + fileName);
|
|
157
|
-
return _context3.abrupt("return", {
|
|
158
|
-
success: false,
|
|
159
|
-
status: '文件上传失败',
|
|
160
|
-
widgetName: fileInfo.name,
|
|
161
|
-
fileName: fileName,
|
|
162
|
-
filepath: filePath,
|
|
163
|
-
ossPath: historyResult.url,
|
|
164
|
-
error: '线上存在重名文件。'
|
|
165
|
-
});
|
|
166
|
-
case 3:
|
|
167
|
-
_context3.next = 4;
|
|
168
|
-
return bosClient.upload(objectKey, filePath);
|
|
169
|
-
case 4:
|
|
170
|
-
result = _context3.sent;
|
|
171
|
-
ossPath = getFilePath(ossType, ossConfig.bucket, objectKey);
|
|
172
|
-
successLog("\u6587\u4EF6\u4E0A\u4F20\u6210\u529F: " + fileName + " -> " + ossPath, spinner);
|
|
173
|
-
return _context3.abrupt("return", {
|
|
174
|
-
success: true,
|
|
175
|
-
status: '文件上传成功',
|
|
176
|
-
fileName: fileName,
|
|
177
|
-
widgetName: fileInfo.name,
|
|
178
|
-
filepath: filePath,
|
|
179
|
-
ossPath: ossPath,
|
|
180
|
-
resultMsg: result
|
|
181
|
-
});
|
|
182
|
-
case 5:
|
|
183
|
-
_context3.prev = 5;
|
|
184
|
-
_t2 = _context3["catch"](1);
|
|
185
|
-
errorLog("\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25: " + fileName, spinner);
|
|
186
|
-
|
|
187
|
-
// 输出详细的错误信息
|
|
188
|
-
errorLog("\n========== \u4E0A\u4F20\u6587\u4EF6\u8BE6\u60C5 ==========");
|
|
189
|
-
errorLog("\u6587\u4EF6\u8DEF\u5F84: " + filePath);
|
|
190
|
-
errorLog("OSS \u5BF9\u8C61\u952E: " + objectKey);
|
|
191
|
-
errorLog("\u9519\u8BEF\u4FE1\u606F: " + _t2.message);
|
|
192
|
-
if (_t2.stack) {
|
|
193
|
-
errorLog("\u9519\u8BEF\u5806\u6808: " + _t2.stack);
|
|
194
|
-
}
|
|
195
|
-
errorLog("==================================\n");
|
|
196
|
-
return _context3.abrupt("return", {
|
|
197
|
-
success: false,
|
|
198
|
-
status: '文件上传失败',
|
|
199
|
-
widgetName: fileInfo.name,
|
|
200
|
-
fileName: fileName,
|
|
201
|
-
filepath: filePath,
|
|
202
|
-
error: _t2.message
|
|
203
|
-
});
|
|
204
|
-
case 6:
|
|
205
|
-
case "end":
|
|
206
|
-
return _context3.stop();
|
|
207
|
-
}
|
|
208
|
-
}, _callee3, null, [[1, 5]]);
|
|
209
|
-
}));
|
|
210
|
-
return _uploadSingleFile.apply(this, arguments);
|
|
211
|
-
}
|
|
212
|
-
var publish2oss = /*#__PURE__*/function () {
|
|
213
|
-
var _ref = asyncToGenerator(/*#__PURE__*/index.mark(function _callee2(ossType, ossConfig, assetsRoot, fileExtensions) {
|
|
214
|
-
var assetsRootStat, bosClient, files, spinner, filesToUpload, uploadPromises, results, validResults, widgetFilesMap, succeedCount, failCount, _t;
|
|
215
|
-
return index.wrap(function (_context2) {
|
|
216
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
217
|
-
case 0:
|
|
218
|
-
if (fileExtensions === void 0) {
|
|
219
|
-
fileExtensions = ['.js', '.css'];
|
|
220
|
-
}
|
|
221
|
-
if (!(ossType !== 'baidu' && ossType !== 'ali')) {
|
|
222
|
-
_context2.next = 1;
|
|
223
|
-
break;
|
|
224
|
-
}
|
|
225
|
-
errorLog("\u4E0D\u652F\u6301\u7684oss\u7C7B\u578B: " + ossType);
|
|
226
|
-
return _context2.abrupt("return");
|
|
227
|
-
case 1:
|
|
228
|
-
if (ossConfig) {
|
|
229
|
-
_context2.next = 2;
|
|
230
|
-
break;
|
|
231
|
-
}
|
|
232
|
-
errorLog('ossConfig 不能为空');
|
|
233
|
-
return _context2.abrupt("return");
|
|
234
|
-
case 2:
|
|
235
|
-
if (assetsRoot) {
|
|
236
|
-
_context2.next = 3;
|
|
237
|
-
break;
|
|
238
|
-
}
|
|
239
|
-
errorLog('assetsRoot 不能为空');
|
|
240
|
-
return _context2.abrupt("return");
|
|
241
|
-
case 3:
|
|
242
|
-
if (fs.existsSync(assetsRoot)) {
|
|
243
|
-
_context2.next = 4;
|
|
244
|
-
break;
|
|
245
|
-
}
|
|
246
|
-
errorLog("assetsRoot \u4E0D\u5B58\u5728: " + assetsRoot);
|
|
247
|
-
return _context2.abrupt("return");
|
|
248
|
-
case 4:
|
|
249
|
-
// 检查目录是否为目录
|
|
250
|
-
assetsRootStat = fs.statSync(assetsRoot);
|
|
251
|
-
if (assetsRootStat.isDirectory()) {
|
|
252
|
-
_context2.next = 5;
|
|
253
|
-
break;
|
|
254
|
-
}
|
|
255
|
-
errorLog("assetsRoot \u4E0D\u662F\u76EE\u5F55: " + assetsRoot);
|
|
256
|
-
return _context2.abrupt("return");
|
|
257
|
-
case 5:
|
|
258
|
-
// 创建 OSS 客户端
|
|
259
|
-
bosClient = getBosClient(ossType, ossConfig);
|
|
260
|
-
if (bosClient) {
|
|
261
|
-
_context2.next = 6;
|
|
262
|
-
break;
|
|
263
|
-
}
|
|
264
|
-
errorLog("\u65E0\u6CD5\u521B\u5EFA OSS \u5BA2\u6237\u7AEF\uFF0C\u8BF7\u68C0\u67E5 ossType \u548C ossConfig \u914D\u7F6E");
|
|
265
|
-
return _context2.abrupt("return");
|
|
266
|
-
case 6:
|
|
267
|
-
// 读取构建目录下的所有文件
|
|
268
|
-
files = fs.readdirSync(assetsRoot);
|
|
269
|
-
if (!(files.length === 0)) {
|
|
270
|
-
_context2.next = 7;
|
|
271
|
-
break;
|
|
272
|
-
}
|
|
273
|
-
warningLog("\u6784\u5EFA\u76EE\u5F55\u4E3A\u7A7A: " + assetsRoot);
|
|
274
|
-
return _context2.abrupt("return");
|
|
275
|
-
case 7:
|
|
276
|
-
spinner = ora('正在准备上传文件...').start();
|
|
277
|
-
_context2.prev = 8;
|
|
278
|
-
// 过滤出需要上传的文件
|
|
279
|
-
filesToUpload = files.filter(function (file) {
|
|
280
|
-
var filePath = path.join(assetsRoot, file);
|
|
281
|
-
try {
|
|
282
|
-
var fileStat = fs.statSync(filePath);
|
|
283
|
-
if (!fileStat.isFile()) {
|
|
284
|
-
return false;
|
|
285
|
-
}
|
|
286
|
-
var fileInfo = path.parse(filePath);
|
|
287
|
-
return fileExtensions.includes(fileInfo.ext);
|
|
288
|
-
} catch (error) {
|
|
289
|
-
warningLog("\u65E0\u6CD5\u8BFB\u53D6\u6587\u4EF6\u72B6\u6001: " + filePath + " - " + error.message);
|
|
290
|
-
return false;
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
if (!(filesToUpload.length === 0)) {
|
|
294
|
-
_context2.next = 9;
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
spinner.warn('未找到需要上传的文件');
|
|
298
|
-
return _context2.abrupt("return");
|
|
299
|
-
case 9:
|
|
300
|
-
successLog("\u627E\u5230 " + filesToUpload.length + " \u4E2A\u6587\u4EF6\u9700\u8981\u4E0A\u4F20", spinner);
|
|
301
|
-
|
|
302
|
-
// 并行上传所有指定类型的文件
|
|
303
|
-
uploadPromises = filesToUpload.map(/*#__PURE__*/function () {
|
|
304
|
-
var _ref2 = asyncToGenerator(/*#__PURE__*/index.mark(function _callee(file) {
|
|
305
|
-
var filePath, fileInfo, objectKey;
|
|
306
|
-
return index.wrap(function (_context) {
|
|
307
|
-
while (1) switch (_context.prev = _context.next) {
|
|
308
|
-
case 0:
|
|
309
|
-
filePath = path.join(assetsRoot, file);
|
|
310
|
-
fileInfo = path.parse(filePath);
|
|
311
|
-
objectKey = addVersionToFilename(file);
|
|
312
|
-
_context.next = 1;
|
|
313
|
-
return uploadSingleFile(bosClient, filePath, objectKey, ossType, ossConfig, fileInfo);
|
|
314
|
-
case 1:
|
|
315
|
-
return _context.abrupt("return", _context.sent);
|
|
316
|
-
case 2:
|
|
317
|
-
case "end":
|
|
318
|
-
return _context.stop();
|
|
319
|
-
}
|
|
320
|
-
}, _callee);
|
|
321
|
-
}));
|
|
322
|
-
return function (_x1) {
|
|
323
|
-
return _ref2.apply(this, arguments);
|
|
324
|
-
};
|
|
325
|
-
}()); // 等待所有文件上传完成
|
|
326
|
-
_context2.next = 10;
|
|
327
|
-
return Promise.all(uploadPromises);
|
|
328
|
-
case 10:
|
|
329
|
-
results = _context2.sent;
|
|
330
|
-
// 过滤掉 undefined 结果(不符合条件的文件)
|
|
331
|
-
validResults = results.filter(function (result) {
|
|
332
|
-
return result !== undefined;
|
|
333
|
-
}); // 处理上传结果
|
|
334
|
-
widgetFilesMap = getResultFilesByWidgetName(validResults);
|
|
335
|
-
if (widgetFilesMap && Object.keys(widgetFilesMap).length > 0) {
|
|
336
|
-
console.info('\n上传至 OSS 的文件信息:\n', widgetFilesMap);
|
|
337
|
-
// 更新发布日志
|
|
338
|
-
updatePublishLog(widgetFilesMap);
|
|
339
|
-
} else {
|
|
340
|
-
warningLog('未生成有效的文件上传结果');
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
// 统计上传结果
|
|
344
|
-
succeedCount = validResults.filter(function (r) {
|
|
345
|
-
return r && r.success;
|
|
346
|
-
}).length;
|
|
347
|
-
failCount = validResults.filter(function (r) {
|
|
348
|
-
return r && !r.success;
|
|
349
|
-
}).length;
|
|
350
|
-
if (failCount > 0) {
|
|
351
|
-
warningLog("\n\u4E0A\u4F20\u5B8C\u6210\uFF1A\u6210\u529F " + succeedCount + " \u4E2A\uFF0C\u5931\u8D25 " + failCount + " \u4E2A");
|
|
352
|
-
} else {
|
|
353
|
-
console.info("\n\u2705 \u6240\u6709\u6587\u4EF6\u4E0A\u4F20\u6210\u529F\uFF01\u5171 " + succeedCount + " \u4E2A\u6587\u4EF6");
|
|
354
|
-
}
|
|
355
|
-
_context2.next = 12;
|
|
356
|
-
break;
|
|
357
|
-
case 11:
|
|
358
|
-
_context2.prev = 11;
|
|
359
|
-
_t = _context2["catch"](8);
|
|
360
|
-
errorLog('批量上传文件异常', spinner);
|
|
361
|
-
errorLog('\n========== 批量上传异常 ==========');
|
|
362
|
-
errorLog("\u9519\u8BEF\u4FE1\u606F: " + _t.message);
|
|
363
|
-
if (_t.stack) {
|
|
364
|
-
errorLog("\u9519\u8BEF\u5806\u6808: " + _t.stack);
|
|
365
|
-
}
|
|
366
|
-
errorLog('==================================\n');
|
|
367
|
-
throw _t;
|
|
368
|
-
case 12:
|
|
369
|
-
case "end":
|
|
370
|
-
return _context2.stop();
|
|
371
|
-
}
|
|
372
|
-
}, _callee2, null, [[8, 11]]);
|
|
373
|
-
}));
|
|
374
|
-
return function publish2oss(_x7, _x8, _x9, _x0) {
|
|
375
|
-
return _ref.apply(this, arguments);
|
|
376
|
-
};
|
|
377
|
-
}();
|
|
378
|
-
module.exports = publish2oss;
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var require$$0 = require('webpack-sources');
|
|
4
|
-
require('node:fs');
|
|
5
|
-
require('node:path');
|
|
6
|
-
var _extends = require('../node_modules/@babel/runtime/helpers/esm/extends.js');
|
|
7
|
-
|
|
8
|
-
function _createForOfIteratorHelperLoose(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: true } : { done: false, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
10
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
11
|
-
var _require = require$$0,
|
|
12
|
-
ConcatSource = _require.ConcatSource;
|
|
13
|
-
/**
|
|
14
|
-
* 注入 neoRequire 函数
|
|
15
|
-
* 备注:用于实现和 Neo 平台共享依赖
|
|
16
|
-
*/
|
|
17
|
-
var AddNeoRequirePlugin = /*#__PURE__*/function () {
|
|
18
|
-
function AddNeoRequirePlugin(options) {
|
|
19
|
-
if (options === void 0) {
|
|
20
|
-
options = {};
|
|
21
|
-
}
|
|
22
|
-
this.key = 'AddNeoRequirePlugin';
|
|
23
|
-
this.options = _extends({
|
|
24
|
-
// 是否启用详细日志
|
|
25
|
-
verbose: options.verbose || false,
|
|
26
|
-
// 是否跳过已注入的文件
|
|
27
|
-
skipInjected: options.skipInjected !== false,
|
|
28
|
-
// 需要跳过的文件扩展名
|
|
29
|
-
skipExtensions: options.skipExtensions || ['.css', '.map', '.txt', '.html'],
|
|
30
|
-
// 需要跳过的文件名模式
|
|
31
|
-
skipPatterns: options.skipPatterns || [/\.map$/, /\.LICENSE\.txt$/, /\.html$/]
|
|
32
|
-
}, options);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 检查文件是否应该被跳过
|
|
37
|
-
*/
|
|
38
|
-
var _proto = AddNeoRequirePlugin.prototype;
|
|
39
|
-
_proto.shouldSkipFile = function shouldSkipFile(filename) {
|
|
40
|
-
// 检查扩展名
|
|
41
|
-
for (var _iterator = _createForOfIteratorHelperLoose(this.options.skipExtensions), _step; !(_step = _iterator()).done;) {
|
|
42
|
-
var ext = _step.value;
|
|
43
|
-
if (filename.endsWith(ext)) {
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// 检查文件名模式
|
|
49
|
-
for (var _iterator2 = _createForOfIteratorHelperLoose(this.options.skipPatterns), _step2; !(_step2 = _iterator2()).done;) {
|
|
50
|
-
var pattern = _step2.value;
|
|
51
|
-
if (pattern.test(filename)) {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* 检查文件是否已经被注入过
|
|
60
|
-
*/;
|
|
61
|
-
_proto.isAlreadyInjected = function isAlreadyInjected(content) {
|
|
62
|
-
if (!content || typeof content !== 'string') {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// 检查是否包含注入的标识
|
|
67
|
-
return content.includes('NeoCustomCmpFileFactory(window.neoRequire)') && content.includes('if (!window.neoRequire)');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 验证文件内容是否有效
|
|
72
|
-
*/;
|
|
73
|
-
_proto.isValidFile = function isValidFile(content) {
|
|
74
|
-
if (!content || typeof content !== 'string') {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// 检查文件是否为空或只包含空白字符
|
|
79
|
-
if (content.trim().length === 0) {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* 记录日志
|
|
87
|
-
*/;
|
|
88
|
-
_proto.log = function log(message, level) {
|
|
89
|
-
if (level === void 0) {
|
|
90
|
-
level = 'info';
|
|
91
|
-
}
|
|
92
|
-
if (this.options.verbose || level === 'error') {
|
|
93
|
-
var prefix = "[AddNeoRequirePlugin]";
|
|
94
|
-
console[level](prefix + " " + message);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
_proto.apply = function apply(compiler) {
|
|
98
|
-
var _this = this;
|
|
99
|
-
compiler.hooks.compilation.tap('AddNeoRequirePlugin', function (compilation) {
|
|
100
|
-
compilation.hooks.processAssets.tap({
|
|
101
|
-
name: 'AddNeoRequirePlugin',
|
|
102
|
-
stage: -100
|
|
103
|
-
}, function (assets) {
|
|
104
|
-
_this.log('开始处理资源文件...');
|
|
105
|
-
var processedCount = 0;
|
|
106
|
-
var skippedCount = 0;
|
|
107
|
-
var errorCount = 0;
|
|
108
|
-
|
|
109
|
-
// 遍历所有资源文件
|
|
110
|
-
for (var _i = 0, _Object$entries = Object.entries(assets); _i < _Object$entries.length; _i++) {
|
|
111
|
-
var _Object$entries$_i = _Object$entries[_i],
|
|
112
|
-
filename = _Object$entries$_i[0],
|
|
113
|
-
asset = _Object$entries$_i[1];
|
|
114
|
-
try {
|
|
115
|
-
// 检查是否应该跳过此文件
|
|
116
|
-
if (_this.shouldSkipFile(filename)) {
|
|
117
|
-
_this.log("\u8DF3\u8FC7\u6587\u4EF6: " + filename + " (\u5339\u914D\u8DF3\u8FC7\u89C4\u5219)");
|
|
118
|
-
skippedCount++;
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// 获取文件内容
|
|
123
|
-
var source = asset.source();
|
|
124
|
-
var content = typeof source === 'string' ? source : source.toString();
|
|
125
|
-
|
|
126
|
-
// 验证文件内容
|
|
127
|
-
if (!_this.isValidFile(content)) {
|
|
128
|
-
_this.log("\u8DF3\u8FC7\u6587\u4EF6: " + filename + " (\u5185\u5BB9\u65E0\u6548)", 'warn');
|
|
129
|
-
skippedCount++;
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// 检查是否已经注入过
|
|
134
|
-
if (_this.options.skipInjected && _this.isAlreadyInjected(content)) {
|
|
135
|
-
_this.log("\u8DF3\u8FC7\u6587\u4EF6: " + filename + " (\u5DF2\u6CE8\u5165\u8FC7)");
|
|
136
|
-
skippedCount++;
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// 执行注入
|
|
141
|
-
_this.injectNeoRequire(compilation, filename, content);
|
|
142
|
-
processedCount++;
|
|
143
|
-
_this.log("\u6210\u529F\u5904\u7406\u6587\u4EF6: " + filename);
|
|
144
|
-
} catch (error) {
|
|
145
|
-
errorCount++;
|
|
146
|
-
_this.log("\u5904\u7406\u6587\u4EF6\u5931\u8D25: " + filename + ", \u9519\u8BEF: " + error.message, 'error');
|
|
147
|
-
console.error("[AddNeoRequirePlugin] \u8BE6\u7EC6\u9519\u8BEF:", error);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// 输出处理统计
|
|
152
|
-
_this.log("\u5904\u7406\u5B8C\u6210 - \u6210\u529F: " + processedCount + ", \u8DF3\u8FC7: " + skippedCount + ", \u9519\u8BEF: " + errorCount);
|
|
153
|
-
if (errorCount > 0) {
|
|
154
|
-
_this.log("\u8B66\u544A: \u6709 " + errorCount + " \u4E2A\u6587\u4EF6\u5904\u7406\u5931\u8D25", 'warn');
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* 执行 neoRequire 注入
|
|
162
|
-
*/;
|
|
163
|
-
_proto.injectNeoRequire = function injectNeoRequire(compilation, filename, content) {
|
|
164
|
-
var Header = "\n(function(NeoCustomCmpFileFactory) {\n if (!window.neoRequire) {\n throw new Error('neoRequire \u4E0D\u5B58\u5728\uFF0C\u8BF7\u5728 NeoCRM \u5E73\u53F0\u4E2D\u52A0\u8F7D\u6B64\u811A\u672C\u3002');\n }\n NeoCustomCmpFileFactory(window.neoRequire);\n})(function(require) {\n ";
|
|
165
|
-
|
|
166
|
-
// const NeoUMDContent = fs.readFileSync(path.join(__dirname, '../neo/NeoUMDContent.js'), 'utf8');
|
|
167
|
-
// const Footer = `}); \n${NeoUMDContent}`;
|
|
168
|
-
var Footer = "});";
|
|
169
|
-
|
|
170
|
-
// 创建新的资源
|
|
171
|
-
var newSource = new ConcatSource(Header, content, Footer);
|
|
172
|
-
|
|
173
|
-
// 更新资源
|
|
174
|
-
compilation.updateAsset(filename, newSource);
|
|
175
|
-
};
|
|
176
|
-
return AddNeoRequirePlugin;
|
|
177
|
-
}();
|
|
178
|
-
module.exports = AddNeoRequirePlugin;
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var require$$1 = require('node:path');
|
|
4
|
-
var require$$0 = require('node:fs');
|
|
5
|
-
var openProject = require('../_virtual/openProject.js');
|
|
6
|
-
|
|
7
|
-
var autoEntryRootDir;
|
|
8
|
-
var hasRequiredAutoEntryRootDir;
|
|
9
|
-
|
|
10
|
-
function requireAutoEntryRootDir () {
|
|
11
|
-
if (hasRequiredAutoEntryRootDir) return autoEntryRootDir;
|
|
12
|
-
hasRequiredAutoEntryRootDir = 1;
|
|
13
|
-
var path = require$$1;
|
|
14
|
-
var fs = require$$0;
|
|
15
|
-
var openProject$1 = openProject;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 自动进入指定项目的根目录
|
|
19
|
-
*
|
|
20
|
-
* ⚠️ 重要说明:子进程无法直接改变父 shell 的工作目录
|
|
21
|
-
*
|
|
22
|
-
* 原因:
|
|
23
|
-
* 1. 进程隔离:每个进程都有独立的工作目录,子进程无法修改父进程的工作目录
|
|
24
|
-
* 2. Shell 限制:cd 是 shell 的内置命令,必须在父 shell 进程中执行
|
|
25
|
-
* 3. 安全机制:操作系统禁止子进程修改父进程的工作目录,防止安全问题
|
|
26
|
-
*
|
|
27
|
-
* 解决方案:
|
|
28
|
-
* 1. 使用 process.chdir() 改变 Node.js 进程的工作目录(仅对后续 Node.js 操作有效)
|
|
29
|
-
* 2. 输出 shell 命令让用户执行以改变 shell 的工作目录
|
|
30
|
-
*
|
|
31
|
-
* @param {string} projectPath 项目路径(可以是相对路径或绝对路径)
|
|
32
|
-
* @param {object} options 配置选项
|
|
33
|
-
* @param {boolean} options.outputShellCommand 是否输出 shell 命令让用户执行(默认:true)
|
|
34
|
-
* @returns {boolean} 是否成功切换目录
|
|
35
|
-
*/
|
|
36
|
-
autoEntryRootDir = function (projectPath, options) {
|
|
37
|
-
if (options === void 0) {
|
|
38
|
-
options = {};
|
|
39
|
-
}
|
|
40
|
-
var _options = options,
|
|
41
|
-
_options$outputShellC = _options.outputShellCommand,
|
|
42
|
-
outputShellCommand = _options$outputShellC === void 0 ? true : _options$outputShellC;
|
|
43
|
-
if (!projectPath) {
|
|
44
|
-
console.error('运行异常:未找到可用的项目路径。');
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// 将路径解析为绝对路径
|
|
49
|
-
var absolutePath = path.isAbsolute(projectPath) ? projectPath : path.resolve(process.cwd(), projectPath);
|
|
50
|
-
|
|
51
|
-
// 检查目录是否存在
|
|
52
|
-
if (!fs.existsSync(absolutePath)) {
|
|
53
|
-
console.error("\u8FD0\u884C\u5F02\u5E38\uFF1A" + projectPath + " \u76EE\u5F55\u4E0D\u5B58\u5728\u3002");
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// 检查是否为目录
|
|
58
|
-
var stats = fs.statSync(absolutePath);
|
|
59
|
-
if (!stats.isDirectory()) {
|
|
60
|
-
console.error("\u8FD0\u884C\u5F02\u5E38\uFF1A" + projectPath + " \u4E0D\u662F\u76EE\u5F55\u3002");
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
var projectName = path.relative(process.cwd(), absolutePath);
|
|
64
|
-
var success = false;
|
|
65
|
-
|
|
66
|
-
// 改变 Node.js 进程的工作目录(仅对后续 Node.js 操作有效)
|
|
67
|
-
try {
|
|
68
|
-
process.chdir(absolutePath);
|
|
69
|
-
success = true;
|
|
70
|
-
} catch (error) {
|
|
71
|
-
console.error("\u9519\u8BEF\uFF1A\u65E0\u6CD5\u5207\u6362\u5230\u76EE\u5F55 " + projectName + ": " + error.message);
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// 输出 shell 命令让用户执行(这样可以真正改变 shell 的工作目录)
|
|
76
|
-
if (outputShellCommand) {
|
|
77
|
-
// 输出提示信息
|
|
78
|
-
console.log('\n' + '='.repeat(60));
|
|
79
|
-
console.log('💡 提示:要切换到新建项目目录,请执行以下命令:');
|
|
80
|
-
console.log("\n cd " + projectName + " \n");
|
|
81
|
-
console.log('='.repeat(60));
|
|
82
|
-
console.log('\n📝 说明1:组件开发工具(neo-cmp-cli)无法直接改变当前命令窗口工作目录,');
|
|
83
|
-
console.log(" \u60A8\u9700\u8981\u624B\u52A8\u6267\u884C\u4E0A\u8FF0\u547D\u4EE4\u624D\u80FD\u8FDB\u5165\u521A\u521B\u5EFA\u7684\u81EA\u5B9A\u4E49\u7EC4\u4EF6\u9879\u76EE\uFF08" + projectName + "\uFF09\u3002");
|
|
84
|
-
console.log("\n\uD83D\uDCDD \u8BF4\u660E2\uFF1A\u7EC4\u4EF6\u5F00\u53D1\u5DE5\u5177\uFF08neo-cmp-cli\uFF09\u9ED8\u8BA4\u81EA\u52A8\u6253\u5F00\u7F16\u8F91\u5668\uFF08cursor \u6216 vscode\uFF09: neo open -n " + projectName + "\u3002\n");
|
|
85
|
-
|
|
86
|
-
// 自动打开 IDE编辑器(异步执行,不需要等待)
|
|
87
|
-
openProject$1('auto', projectPath).catch(function (error) {
|
|
88
|
-
// 错误已在 openProject 内部处理,这里只是防止未处理的 Promise 警告
|
|
89
|
-
console.error("\u81EA\u52A8\u6253\u5F00\u7F16\u8F91\u5668\u51FA\u9519\uFF08neo open -n " + projectName + "\uFF09: " + error.message);
|
|
90
|
-
console.error("\u8BF7\u624B\u52A8\u6267\u884C\u547D\u4EE4 neo open -n " + projectName + " \u6253\u5F00\u7F16\u8F91\u5668\u3002");
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
return success;
|
|
94
|
-
};
|
|
95
|
-
return autoEntryRootDir;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
exports.__require = requireAutoEntryRootDir;
|