@tmsfe/tmskit 0.0.23 → 0.0.24

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 CHANGED
@@ -3137,10 +3137,10 @@ var dev$3 = async (tmsConfig, modules, isDev = true) => {
3137
3137
 
3138
3138
  eTime = new Date().getTime() - sTime;
3139
3139
 
3140
- if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.afterCompile) === 'function') {
3140
+ if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.afterFirstCompile) === 'function') {
3141
3141
  var _tmsConfig$hooks2;
3142
3142
 
3143
- await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.afterCompile({
3143
+ await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.afterFirstCompile({
3144
3144
  isDev,
3145
3145
  tmsConfig: filterField$2(tmsConfig, ['gitAccount']),
3146
3146
  modules
@@ -3165,7 +3165,7 @@ var dev$3 = async (tmsConfig, modules, isDev = true) => {
3165
3165
 
3166
3166
  var require$$12 = {
3167
3167
  name: "@tmsfe/tmskit",
3168
- version: "0.0.23",
3168
+ version: "0.0.24",
3169
3169
  description: "tmskit",
3170
3170
  main: "dist/index.cjs",
3171
3171
  bin: {
@@ -3453,10 +3453,10 @@ async function dev$2(tmsConfig, targetModules) {
3453
3453
  } = await init$2(tmsConfig, targetModules);
3454
3454
  info$2('当前dev启动的有效模块', newModules.map(item => item.moduleName).sort());
3455
3455
 
3456
- if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeCompile) === 'function') {
3456
+ if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeFirstCompile) === 'function') {
3457
3457
  var _tmsConfig$hooks2;
3458
3458
 
3459
- await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.beforeCompile({
3459
+ await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.beforeFirstCompile({
3460
3460
  isDev: true,
3461
3461
  tmsConfig: filterField$1(tmsConfig, ['gitAccount']),
3462
3462
  modules: newModules
@@ -3494,10 +3494,10 @@ async function build$1(tmsConfig, targetModules) {
3494
3494
  } = await init$1(tmsConfig, targetModules);
3495
3495
  const isDev = false;
3496
3496
 
3497
- if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeCompile) === 'function') {
3497
+ if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeFirstCompile) === 'function') {
3498
3498
  var _tmsConfig$hooks2;
3499
3499
 
3500
- await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.beforeCompile({
3500
+ await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.beforeFirstCompile({
3501
3501
  isDev,
3502
3502
  tmsConfig: filterField(tmsConfig, ['gitAccount']),
3503
3503
  modules: newModules
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmsfe/tmskit",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "description": "tmskit",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {
@@ -113,8 +113,8 @@ module.exports = async (tmsConfig, modules, isDev = true) => {
113
113
  buildOutputAppJson(tmsConfig, modules, isDev);
114
114
  }
115
115
  eTime = new Date().getTime() - sTime;
116
- if (typeof tmsConfig?.hooks?.afterCompile === 'function') {
117
- await tmsConfig?.hooks?.afterCompile({
116
+ if (typeof tmsConfig?.hooks?.afterFirstCompile === 'function') {
117
+ await tmsConfig?.hooks?.afterFirstCompile({
118
118
  isDev,
119
119
  tmsConfig: filterField(tmsConfig, ['gitAccount']),
120
120
  modules,
@@ -0,0 +1,36 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const { CACHE_FILE, CACHE_DIR } = require('../config/constant');
4
+ const { ensureDirExist } = require('../utils/io');
5
+
6
+ function getCache(projectDir, type) {
7
+ const filePath = `${CACHE_DIR}/${CACHE_FILE}`;
8
+ if (!fs.existsSync(filePath)) {
9
+ return null;
10
+ }
11
+ const content = require(filePath);
12
+ return content?.[projectDir]?.[type];
13
+ }
14
+
15
+
16
+ function setCache(projectDir, type = 'miniprogram_npm', data) {
17
+ const filePath = `${CACHE_DIR}/${CACHE_FILE}`;
18
+ if (!fs.existsSync(filePath)) {
19
+ const dir = path.dirname(filePath);
20
+ ensureDirExist(dir);
21
+ fs.writeFileSync(filePath, '{}');
22
+ }
23
+ const content = require(filePath);
24
+ if (!content[projectDir]) {
25
+ content[projectDir] = {};
26
+ }
27
+ content[projectDir] = {
28
+ [type]: data,
29
+ };
30
+ fs.writeFileSync(filePath, JSON.stringify(content, null, 2));
31
+ }
32
+
33
+ module.exports = {
34
+ setCache,
35
+ getCache,
36
+ };
@@ -11,8 +11,8 @@ async function build(tmsConfig, targetModules) {
11
11
  const { modules: newModules } = await init(tmsConfig, targetModules);
12
12
 
13
13
  const isDev = false;
14
- if (typeof tmsConfig?.hooks?.beforeCompile === 'function') {
15
- await tmsConfig?.hooks?.beforeCompile({
14
+ if (typeof tmsConfig?.hooks?.beforeFirstCompile === 'function') {
15
+ await tmsConfig?.hooks?.beforeFirstCompile({
16
16
  isDev,
17
17
  tmsConfig: filterField(tmsConfig, ['gitAccount']),
18
18
  modules: newModules });
@@ -41,8 +41,8 @@ async function dev(tmsConfig, targetModules) {
41
41
  const { subPackages, modules: newModules } = await init(tmsConfig, targetModules);
42
42
 
43
43
  info('当前dev启动的有效模块', newModules.map(item => item.moduleName).sort());
44
- if (typeof tmsConfig?.hooks?.beforeCompile === 'function') {
45
- await tmsConfig?.hooks?.beforeCompile({
44
+ if (typeof tmsConfig?.hooks?.beforeFirstCompile === 'function') {
45
+ await tmsConfig?.hooks?.beforeFirstCompile({
46
46
  isDev: true,
47
47
  tmsConfig: filterField(tmsConfig, ['gitAccount']),
48
48
  modules: newModules,