@tmsfe/tmskit 0.0.56 → 0.0.57
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/dist/index.cjs.js +21 -69
- package/package.json +1 -1
- package/src/config/constant.js +1 -1
- package/src/core/buildAppJson.js +0 -4
- package/src/core/handleAgentConfig.js +0 -39
package/dist/index.cjs.js
CHANGED
|
@@ -120,13 +120,13 @@ const succeed$2 = (message = '') => {
|
|
|
120
120
|
const warn$2 = message => {
|
|
121
121
|
console.log(`${moment$1().format('YYYY-MM-DD HH:mm:ss')}`, chalk$5.yellow(message));
|
|
122
122
|
};
|
|
123
|
-
const info$
|
|
123
|
+
const info$k = (...args) => console.log(`${moment$1().format('YYYY-MM-DD HH:mm:ss')}`, ...args);
|
|
124
124
|
const infoNoTime$1 = (...args) => console.log(...args);
|
|
125
125
|
var log$1 = {
|
|
126
126
|
fail: fail$a,
|
|
127
127
|
succeed: succeed$2,
|
|
128
128
|
warn: warn$2,
|
|
129
|
-
info: info$
|
|
129
|
+
info: info$k,
|
|
130
130
|
infoNoTime: infoNoTime$1
|
|
131
131
|
};
|
|
132
132
|
|
|
@@ -136,7 +136,7 @@ const fs$j = require$$0__default$1;
|
|
|
136
136
|
const shelljs$7 = require$$0__default$2;
|
|
137
137
|
const glob = require$$4__default;
|
|
138
138
|
const {
|
|
139
|
-
info: info$
|
|
139
|
+
info: info$j
|
|
140
140
|
} = log$1;
|
|
141
141
|
const shelljsOptions = {
|
|
142
142
|
slient: true,
|
|
@@ -145,7 +145,7 @@ const shelljsOptions = {
|
|
|
145
145
|
|
|
146
146
|
// 获取当前目录
|
|
147
147
|
const cwd = process.cwd();
|
|
148
|
-
function resolve$
|
|
148
|
+
function resolve$k(...args) {
|
|
149
149
|
return path$h.resolve(cwd, ...args);
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -278,7 +278,7 @@ function createTask$7(task, startText, endText) {
|
|
|
278
278
|
return async (...args) => {
|
|
279
279
|
const start = Date.now();
|
|
280
280
|
const spinner = ora$2();
|
|
281
|
-
info$
|
|
281
|
+
info$j(startText);
|
|
282
282
|
spinner.start();
|
|
283
283
|
const result = await task(...args);
|
|
284
284
|
endText && spinner.succeed(`${endText}, 耗时${cost(start) / 1000}s`);
|
|
@@ -336,7 +336,7 @@ function findFiles(globPath, filter = []) {
|
|
|
336
336
|
// 获取绝对路径
|
|
337
337
|
function getAbsolutePath$6(pathDir, cwd = '') {
|
|
338
338
|
let newPath = pathDir;
|
|
339
|
-
newPath = newPath.startsWith('/') ? newPath : resolve$
|
|
339
|
+
newPath = newPath.startsWith('/') ? newPath : resolve$k(cwd, newPath);
|
|
340
340
|
newPath = newPath.endsWith('/') ? newPath.slice(0, newPath.length - 1) : newPath;
|
|
341
341
|
return newPath;
|
|
342
342
|
}
|
|
@@ -367,7 +367,7 @@ function getGitUser$2() {
|
|
|
367
367
|
return res.stdout;
|
|
368
368
|
}
|
|
369
369
|
var widgets = {
|
|
370
|
-
resolve: resolve$
|
|
370
|
+
resolve: resolve$k,
|
|
371
371
|
isObject,
|
|
372
372
|
isArray,
|
|
373
373
|
createTask: createTask$7,
|
|
@@ -445,7 +445,7 @@ const DEFAULT_WEBPACK_ENTRY = {
|
|
|
445
445
|
};
|
|
446
446
|
|
|
447
447
|
// 默认从源码拷贝到编译后的配置
|
|
448
|
-
const DEFAULT_COPY_CONFIG$2 = ['package.json', 'sitemap.json', 'project.config.json'];
|
|
448
|
+
const DEFAULT_COPY_CONFIG$2 = ['package.json', 'sitemap.json', 'project.config.json', 'page-meta.json'];
|
|
449
449
|
const ENV = {
|
|
450
450
|
dev: 'development',
|
|
451
451
|
prod: 'production'
|
|
@@ -875,7 +875,7 @@ var global_1 = {
|
|
|
875
875
|
const fs$i = require$$0__default$1;
|
|
876
876
|
const path$f = require$$1__default$1;
|
|
877
877
|
const {
|
|
878
|
-
info: info$
|
|
878
|
+
info: info$i
|
|
879
879
|
} = log$1;
|
|
880
880
|
const {
|
|
881
881
|
relativeCwdPath
|
|
@@ -925,11 +925,11 @@ function diffContentCopyFile(originFile, destFile) {
|
|
|
925
925
|
const depDestContent = fs$i.readFileSync(destFile, 'utf8');
|
|
926
926
|
const depOriginContent = fs$i.readFileSync(originFile, 'utf8');
|
|
927
927
|
if (depDestContent !== depOriginContent) {
|
|
928
|
-
info$
|
|
928
|
+
info$i(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
|
|
929
929
|
copyFile(originFile, destFile);
|
|
930
930
|
}
|
|
931
931
|
} else {
|
|
932
|
-
info$
|
|
932
|
+
info$i(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
|
|
933
933
|
copyFile(originFile, destFile);
|
|
934
934
|
}
|
|
935
935
|
}
|
|
@@ -1022,7 +1022,7 @@ var render_1 = render$1;
|
|
|
1022
1022
|
const fs$h = require$$0__default$1;
|
|
1023
1023
|
const inquirer$1 = require$$1__default$5;
|
|
1024
1024
|
const {
|
|
1025
|
-
resolve: resolve$
|
|
1025
|
+
resolve: resolve$j
|
|
1026
1026
|
} = widgets;
|
|
1027
1027
|
const {
|
|
1028
1028
|
TEMPLATE_TKIT_DIR: TEMPLATE_TKIT_DIR$1
|
|
@@ -1064,7 +1064,7 @@ const isQuestionType = result => {
|
|
|
1064
1064
|
return true;
|
|
1065
1065
|
};
|
|
1066
1066
|
const ask$1 = templateDir => (files, metalsmith, next) => {
|
|
1067
|
-
const prompts = parseTemplateQuestions(resolve$
|
|
1067
|
+
const prompts = parseTemplateQuestions(resolve$j(templateDir, TEMPLATE_TKIT_DIR$1));
|
|
1068
1068
|
const metadata = metalsmith.metadata();
|
|
1069
1069
|
const filteredPrompts = prompts.filter(prompt => {
|
|
1070
1070
|
if (metadata[prompt.name] && `${metadata[prompt.name]}`.trim() !== '') {
|
|
@@ -1143,13 +1143,13 @@ const {
|
|
|
1143
1143
|
CREATE_TEMPLATE_QUESTION
|
|
1144
1144
|
} = constant;
|
|
1145
1145
|
const {
|
|
1146
|
-
resolve: resolve$
|
|
1146
|
+
resolve: resolve$i
|
|
1147
1147
|
} = widgets;
|
|
1148
1148
|
const io$2 = io$3;
|
|
1149
1149
|
const {
|
|
1150
1150
|
fail: fail$9,
|
|
1151
1151
|
succeed: succeed$1,
|
|
1152
|
-
info: info$
|
|
1152
|
+
info: info$h
|
|
1153
1153
|
} = log$1;
|
|
1154
1154
|
const generator = generator_1;
|
|
1155
1155
|
const request = require$$0__default$6;
|
|
@@ -1234,7 +1234,7 @@ async function create(projectName) {
|
|
|
1234
1234
|
// 生成模板(1. 询问问题, 2. ejs生成模板 3.生成到目标目录)
|
|
1235
1235
|
generator(path$e.join(TEMPLATE_DIR, TEMPLATE_NAME, projectType), targetDir).then(() => {
|
|
1236
1236
|
shelljs$6.cd(projectName);
|
|
1237
|
-
const hookFilePath = resolve$
|
|
1237
|
+
const hookFilePath = resolve$i(projectName, TEMPLATE_TKIT_DIR, 'hooks.js');
|
|
1238
1238
|
if (fs$g.existsSync(hookFilePath)) {
|
|
1239
1239
|
const hooks = require(hookFilePath);
|
|
1240
1240
|
if (hooks.afterCreate) {
|
|
@@ -1248,7 +1248,7 @@ async function create(projectName) {
|
|
|
1248
1248
|
}
|
|
1249
1249
|
});
|
|
1250
1250
|
}
|
|
1251
|
-
shelljs$6.rm('-rf', resolve$
|
|
1251
|
+
shelljs$6.rm('-rf', resolve$i(projectName, TEMPLATE_TKIT_DIR));
|
|
1252
1252
|
}
|
|
1253
1253
|
report$a('create-success', {
|
|
1254
1254
|
projectType
|
|
@@ -1256,7 +1256,7 @@ async function create(projectName) {
|
|
|
1256
1256
|
succeed$1('项目创建完成.');
|
|
1257
1257
|
}).catch(err => {
|
|
1258
1258
|
fail$9(err.message);
|
|
1259
|
-
info$
|
|
1259
|
+
info$h('详细的错误信息:', err);
|
|
1260
1260
|
});
|
|
1261
1261
|
}
|
|
1262
1262
|
var create_1 = create;
|
|
@@ -1274,7 +1274,7 @@ const {
|
|
|
1274
1274
|
createTask: createTask$6
|
|
1275
1275
|
} = widgets;
|
|
1276
1276
|
const {
|
|
1277
|
-
info: info$
|
|
1277
|
+
info: info$g,
|
|
1278
1278
|
fail: fail$8
|
|
1279
1279
|
} = log$1;
|
|
1280
1280
|
|
|
@@ -1307,7 +1307,7 @@ async function installCmd(npmName, cmd) {
|
|
|
1307
1307
|
}), `开始下载${npmName}`, `下载${npmName}完成`)(npmName);
|
|
1308
1308
|
} catch (e) {
|
|
1309
1309
|
fail$8('构建出现错误:');
|
|
1310
|
-
info$
|
|
1310
|
+
info$g(e);
|
|
1311
1311
|
process.exit(1);
|
|
1312
1312
|
}
|
|
1313
1313
|
}
|
|
@@ -1365,49 +1365,6 @@ var handleError_1 = {
|
|
|
1365
1365
|
handleError: handleError$9
|
|
1366
1366
|
};
|
|
1367
1367
|
|
|
1368
|
-
const {
|
|
1369
|
-
resolve: resolve$i
|
|
1370
|
-
} = widgets;
|
|
1371
|
-
const {
|
|
1372
|
-
info: info$g
|
|
1373
|
-
} = log$1;
|
|
1374
|
-
|
|
1375
|
-
/* eslint-disable no-param-reassign */
|
|
1376
|
-
/**
|
|
1377
|
-
* 检查是否包含 wechat-skills 分包
|
|
1378
|
-
* @param {Object} appJson app.json配置对象
|
|
1379
|
-
* @returns {boolean}
|
|
1380
|
-
*/
|
|
1381
|
-
function hasWechatSkillsSubpackage(appJson) {
|
|
1382
|
-
return appJson.subpackages.some(s => s.root === 'modules/wechat-skills' || s.name === 'wechat-skills');
|
|
1383
|
-
}
|
|
1384
|
-
|
|
1385
|
-
/**
|
|
1386
|
-
* 处理 agent 配置:根据是否包含 wechat-skills 分包来添加或删除 agent 配置
|
|
1387
|
-
* @param {Object} appJson app.json配置对象
|
|
1388
|
-
*/
|
|
1389
|
-
function handleAgentConfig$1(appJson) {
|
|
1390
|
-
const hasWechatSkills = hasWechatSkillsSubpackage(appJson);
|
|
1391
|
-
console.log('🔍', hasWechatSkills ? '包含' : '不包含', 'wechat-skills 分包');
|
|
1392
|
-
if (hasWechatSkills) {
|
|
1393
|
-
if (!appJson.agent) {
|
|
1394
|
-
try {
|
|
1395
|
-
appJson.agent = require(resolve$i('./agentConfig.json'));
|
|
1396
|
-
info$g('已从 agentConfig.json 加载 agent 配置');
|
|
1397
|
-
} catch (error) {
|
|
1398
|
-
info$g('未找到 agentConfig.json,删除 agent 配置');
|
|
1399
|
-
delete appJson.agent;
|
|
1400
|
-
}
|
|
1401
|
-
}
|
|
1402
|
-
} else if (appJson.agent) {
|
|
1403
|
-
delete appJson.agent;
|
|
1404
|
-
info$g('已移除 agent 配置');
|
|
1405
|
-
}
|
|
1406
|
-
}
|
|
1407
|
-
var handleAgentConfig_1 = {
|
|
1408
|
-
handleAgentConfig: handleAgentConfig$1
|
|
1409
|
-
};
|
|
1410
|
-
|
|
1411
1368
|
/**
|
|
1412
1369
|
* 生成编译后的app.json
|
|
1413
1370
|
*/
|
|
@@ -1434,9 +1391,6 @@ const {
|
|
|
1434
1391
|
global: global$a
|
|
1435
1392
|
} = global_1;
|
|
1436
1393
|
const report$9 = report_1;
|
|
1437
|
-
const {
|
|
1438
|
-
handleAgentConfig
|
|
1439
|
-
} = handleAgentConfig_1;
|
|
1440
1394
|
|
|
1441
1395
|
/**
|
|
1442
1396
|
* 更新appJson里面的主包配置
|
|
@@ -1612,8 +1566,6 @@ async function buildOutputAppJson$3(tmsConfig, modules) {
|
|
|
1612
1566
|
|
|
1613
1567
|
// 处理appJson中重复||冲突的地方
|
|
1614
1568
|
fixAppJson(appJson);
|
|
1615
|
-
// 处理 agent 配置:根据是否包含 meta-services 分包来添加或删除
|
|
1616
|
-
handleAgentConfig(appJson);
|
|
1617
1569
|
// 更新主包,需在subpackages处理完成后执行, pages/
|
|
1618
1570
|
updateMainPackages(appJson, tmsConfig.mainPackages);
|
|
1619
1571
|
|
|
@@ -4247,7 +4199,7 @@ var entry = [{
|
|
|
4247
4199
|
|
|
4248
4200
|
var require$$12 = {
|
|
4249
4201
|
name: "@tmsfe/tmskit",
|
|
4250
|
-
version: "0.0.
|
|
4202
|
+
version: "0.0.57",
|
|
4251
4203
|
description: "tmskit",
|
|
4252
4204
|
main: "dist/index.cjs",
|
|
4253
4205
|
bin: {
|
package/package.json
CHANGED
package/src/config/constant.js
CHANGED
|
@@ -57,7 +57,7 @@ const DEFAULT_WEBPACK_ENTRY = {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
// 默认从源码拷贝到编译后的配置
|
|
60
|
-
const DEFAULT_COPY_CONFIG = ['package.json', 'sitemap.json', 'project.config.json'];
|
|
60
|
+
const DEFAULT_COPY_CONFIG = ['package.json', 'sitemap.json', 'project.config.json', 'page-meta.json'];
|
|
61
61
|
|
|
62
62
|
const ENV = {
|
|
63
63
|
dev: 'development',
|
package/src/core/buildAppJson.js
CHANGED
|
@@ -10,8 +10,6 @@ const { resolve, filterField } = require('../utils/widgets');
|
|
|
10
10
|
const { handleError } = require('./handleError');
|
|
11
11
|
const { global } = require('../utils/global');
|
|
12
12
|
const report = require('../core/report');
|
|
13
|
-
const { handleAgentConfig } = require('./handleAgentConfig');
|
|
14
|
-
|
|
15
13
|
|
|
16
14
|
/**
|
|
17
15
|
* 更新appJson里面的主包配置
|
|
@@ -192,8 +190,6 @@ async function buildOutputAppJson(tmsConfig, modules) {
|
|
|
192
190
|
|
|
193
191
|
// 处理appJson中重复||冲突的地方
|
|
194
192
|
fixAppJson(appJson);
|
|
195
|
-
// 处理 agent 配置:根据是否包含 meta-services 分包来添加或删除
|
|
196
|
-
handleAgentConfig(appJson);
|
|
197
193
|
// 更新主包,需在subpackages处理完成后执行, pages/
|
|
198
194
|
updateMainPackages(appJson, tmsConfig.mainPackages);
|
|
199
195
|
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
const { resolve } = require('../utils/widgets');
|
|
2
|
-
const { info } = require('../utils/log');
|
|
3
|
-
|
|
4
|
-
/* eslint-disable no-param-reassign */
|
|
5
|
-
/**
|
|
6
|
-
* 检查是否包含 wechat-skills 分包
|
|
7
|
-
* @param {Object} appJson app.json配置对象
|
|
8
|
-
* @returns {boolean}
|
|
9
|
-
*/
|
|
10
|
-
function hasWechatSkillsSubpackage(appJson) {
|
|
11
|
-
return appJson.subpackages.some(s => s.root === 'modules/wechat-skills' || s.name === 'wechat-skills');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 处理 agent 配置:根据是否包含 wechat-skills 分包来添加或删除 agent 配置
|
|
16
|
-
* @param {Object} appJson app.json配置对象
|
|
17
|
-
*/
|
|
18
|
-
function handleAgentConfig(appJson) {
|
|
19
|
-
const hasWechatSkills = hasWechatSkillsSubpackage(appJson);
|
|
20
|
-
console.log('🔍', hasWechatSkills ? '包含' : '不包含', 'wechat-skills 分包');
|
|
21
|
-
if (hasWechatSkills) {
|
|
22
|
-
if (!appJson.agent) {
|
|
23
|
-
try {
|
|
24
|
-
appJson.agent = require(resolve('./agentConfig.json'));
|
|
25
|
-
info('已从 agentConfig.json 加载 agent 配置');
|
|
26
|
-
} catch (error) {
|
|
27
|
-
info('未找到 agentConfig.json,删除 agent 配置');
|
|
28
|
-
delete appJson.agent;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
} else if (appJson.agent) {
|
|
32
|
-
delete appJson.agent;
|
|
33
|
-
info('已移除 agent 配置');
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
module.exports = {
|
|
38
|
-
handleAgentConfig,
|
|
39
|
-
};
|