@tmsfe/tmskit 0.0.29 → 0.0.31

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmsfe/tmskit",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "description": "tmskit",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {
@@ -81,4 +81,4 @@
81
81
  "jest": {
82
82
  "testEnvironment": "jest-environment-node"
83
83
  }
84
- }
84
+ }
@@ -103,7 +103,7 @@ module.exports = async (tmsConfig, modules, isDev = true) => {
103
103
  watch(
104
104
  [resolve('app.json')],
105
105
  { ignoreInitial: false, events: watchEvents },
106
- () => buildOutputAppJson(tmsConfig, modules, isDev),
106
+ async () => await buildOutputAppJson(tmsConfig, modules, isDev),
107
107
  { from: resolve(), to: resolve(tmsConfig.outputDir) },
108
108
  );
109
109
  // 监听其他文件
@@ -111,7 +111,7 @@ module.exports = async (tmsConfig, modules, isDev = true) => {
111
111
  watch(globValue, { ignoreInitial: true, events: watchEvents }, taskFn, module);
112
112
  });
113
113
  } else {
114
- buildOutputAppJson(tmsConfig, modules, isDev);
114
+ await buildOutputAppJson(tmsConfig, modules, isDev);
115
115
  }
116
116
  eTime = new Date().getTime() - sTime;
117
117
  if (typeof tmsConfig?.hooks?.afterFirstCompile === 'function') {
@@ -52,7 +52,7 @@ module.exports = function (globValue, watchOptions, callback, module) {
52
52
  watch(globValue, {
53
53
  // readDelay: 100,
54
54
  ...watchOptions,
55
- }, (vinyl) => {
55
+ }, async (vinyl) => {
56
56
  const sourceFile = vinyl.history[0];
57
57
  const sourceFileDirArr = sourceFile.replace(/\\/g, '/').split('/');
58
58
  const sourceFileName = sourceFileDirArr.slice(sourceFileDirArr.length - 2).join('/');
@@ -66,7 +66,7 @@ module.exports = function (globValue, watchOptions, callback, module) {
66
66
  updateFileHook(tmsConfig, sourceFile, targetFile, vinyl.event);
67
67
  return;
68
68
  }
69
- runCallback({
69
+ await runCallback({
70
70
  tmsConfig,
71
71
  sourceFile,
72
72
  targetFile,
@@ -120,7 +120,7 @@ const fixAppJson = (appJson) => {
120
120
  * @param {array} modules 用户要编译的模块列表
121
121
  * @returns
122
122
  */
123
- function buildOutputAppJson(tmsConfig, modules) {
123
+ async function buildOutputAppJson(tmsConfig, modules) {
124
124
  try {
125
125
  // 获取所有模块,合并模块依赖的模块
126
126
  const modulesConfig = getModulesConfig(modules, tmsConfig.appName, false);
@@ -141,7 +141,7 @@ function buildOutputAppJson(tmsConfig, modules) {
141
141
  fs.writeFileSync(resolve(`${tmsConfig.outputDir}/app.json`), JSON.stringify(appJson, null, 2), 'utf8');
142
142
 
143
143
  if (typeof tmsConfig?.hooks?.updateAppJson === 'function') {
144
- tmsConfig?.hooks?.updateAppJson({
144
+ await tmsConfig?.hooks?.updateAppJson({
145
145
  tmsConfig: filterField(tmsConfig, ['gitAccount']),
146
146
  cmdOptions: global.getData('cmdOptions'),
147
147
  modules,
@@ -2,8 +2,9 @@ const shelljs = require('shelljs');
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
4
  const io = require('../../../utils/io');
5
- const { createTask, resolve, getAbsolutePath } = require('../../../utils/widgets');
5
+ const { createTask, resolve, getAbsolutePath, filterField } = require('../../../utils/widgets');
6
6
  const { buildMpNpm } = require('../../../core/mpCi');
7
+ const { global } = require('../../../utils/global');
7
8
  const { setCache, getCache } = require('./cache');
8
9
  const { NODE_MODULES_DIR } = require('../../../config/constant');
9
10
  const { npmInstallAll } = require('../../../core/npm');
@@ -13,6 +14,15 @@ const { isDependenciesUpdate } = require('../../../core/checkDependencies');
13
14
 
14
15
  async function install(tmsConfig, subPackages, useCache = true) {
15
16
  const cwd = process.cwd();
17
+ // 加npm install之前的钩子
18
+ if (typeof tmsConfig?.hooks?.beforeNpmInstall === 'function') {
19
+ info('—————— 执行beforeNpmInstall ————');
20
+ await tmsConfig?.hooks?.beforeNpmInstall({
21
+ tmsConfig: filterField(tmsConfig, ['gitAccount']),
22
+ cmdOptions: global.getData('cmdOptions'),
23
+ });
24
+ info('—————— 执行beforeNpmInstall 完成 ————');
25
+ };
16
26
  const npmInstallRes = await createTask(
17
27
  npmInstall,
18
28
  '小程序 开始npm install',