neo-cmp-cli 1.5.0-beta.1 → 1.5.0-beta.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/package.json
CHANGED
|
@@ -97,7 +97,7 @@ const buildComponentData = (assetsRoot, cmpInfo) => {
|
|
|
97
97
|
console.error(`未找到自定义组件资源目录: ${assetsRoot}`);
|
|
98
98
|
return null;
|
|
99
99
|
}
|
|
100
|
-
const widgetName = _.
|
|
100
|
+
const widgetName = _.camelCase(cmpType);
|
|
101
101
|
const modelFile = path.join(assetsRoot, `${widgetName}Model.js`);
|
|
102
102
|
|
|
103
103
|
let ModelClass = null;
|
|
@@ -126,7 +126,7 @@ const buildComponentData = (assetsRoot, cmpInfo) => {
|
|
|
126
126
|
}
|
|
127
127
|
// 如果资源文件不存在,报错
|
|
128
128
|
else {
|
|
129
|
-
console.error(
|
|
129
|
+
console.error(`未找到自定义组件模型文件,请检查以下路径是否存在:`, modelFile);
|
|
130
130
|
return null;
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -132,6 +132,18 @@ const defaultNEOConfig = {
|
|
|
132
132
|
bucket: 'neo-widgets' // 存储桶名称
|
|
133
133
|
},
|
|
134
134
|
assetsRoot: resolve('dist') // 上传指定目录下的脚本文件
|
|
135
|
+
},
|
|
136
|
+
publishCmp: {
|
|
137
|
+
output: {
|
|
138
|
+
filename: '[name].js',
|
|
139
|
+
library: {
|
|
140
|
+
type: 'var', // webpack 5 中生成 IIFE 格式的 type 配置
|
|
141
|
+
export: 'default'
|
|
142
|
+
},
|
|
143
|
+
globalObject: 'this' // 定义全局变量,兼容node和浏览器运行,避免出现"window is not defined"的情况
|
|
144
|
+
},
|
|
145
|
+
cssExtract: false, // 不额外提取css文件
|
|
146
|
+
assetsRoot: resolve('dist') // 上传指定目录下的脚本文件
|
|
135
147
|
}
|
|
136
148
|
};
|
|
137
149
|
|
package/src/neo/neoService.js
CHANGED
|
@@ -123,7 +123,8 @@ class NeoService {
|
|
|
123
123
|
const { access_token, expires_in } = response.data;
|
|
124
124
|
|
|
125
125
|
if (!access_token) {
|
|
126
|
-
|
|
126
|
+
console.error('获取 token 失败:响应中未包含 access_token', response.data);
|
|
127
|
+
process.exit(1);
|
|
127
128
|
}
|
|
128
129
|
|
|
129
130
|
// 缓存 token(提前 60 秒过期,避免边缘情况)
|
|
@@ -140,7 +141,7 @@ class NeoService {
|
|
|
140
141
|
if (error.response) {
|
|
141
142
|
console.error('响应数据:', error.response.data);
|
|
142
143
|
}
|
|
143
|
-
|
|
144
|
+
process.exit(1);
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
147
|
|
|
@@ -163,7 +164,9 @@ class NeoService {
|
|
|
163
164
|
* @returns {Promise<string>} 有效的 token
|
|
164
165
|
*/
|
|
165
166
|
async ensureValidToken() {
|
|
166
|
-
if (this.
|
|
167
|
+
if (!this.tokenCache.token) {
|
|
168
|
+
return await this.getToken();
|
|
169
|
+
} else if (this.isTokenExpired()) {
|
|
167
170
|
console.info('token 已过期,正在刷新...');
|
|
168
171
|
return await this.refreshToken();
|
|
169
172
|
}
|
|
@@ -238,7 +241,7 @@ class NeoService {
|
|
|
238
241
|
* @param {array} fileExtensions 需要上传的文件类型,默认 ['.js', '.css']
|
|
239
242
|
*/
|
|
240
243
|
async publish2oss(cmpType, fileExtensions = ['.js', '.css']) {
|
|
241
|
-
if (!
|
|
244
|
+
if (!cmpType) {
|
|
242
245
|
console.error(`自定义组件名称不能为空: ${cmpType}`);
|
|
243
246
|
return;
|
|
244
247
|
}
|
|
@@ -262,7 +265,7 @@ class NeoService {
|
|
|
262
265
|
// const fileExt = path.extname(file);
|
|
263
266
|
const fileInfo = path.parse(filePath);
|
|
264
267
|
if (fileStat.isFile() && fileExtensions.includes(fileInfo.ext)) {
|
|
265
|
-
let widgetName = _.
|
|
268
|
+
let widgetName = _.camelCase(cmpType);
|
|
266
269
|
|
|
267
270
|
if (file.indexOf(widgetName) < 0) {
|
|
268
271
|
return;
|
|
@@ -282,6 +285,7 @@ class NeoService {
|
|
|
282
285
|
|
|
283
286
|
} catch (error) {
|
|
284
287
|
console.error(`文件上传失败(${file}):\n`, error);
|
|
288
|
+
process.exit(1);
|
|
285
289
|
}
|
|
286
290
|
}
|
|
287
291
|
});
|
|
@@ -332,7 +336,7 @@ class NeoService {
|
|
|
332
336
|
if (error.response) {
|
|
333
337
|
console.error('响应数据:', error.response.data);
|
|
334
338
|
}
|
|
335
|
-
|
|
339
|
+
process.exit(1);
|
|
336
340
|
}
|
|
337
341
|
}
|
|
338
342
|
|