@qse/edu-scripts 1.12.5 → 1.13.0

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/docs/debug.md ADDED
@@ -0,0 +1,17 @@
1
+ # 代码调试
2
+
3
+ ## 使用 `React Developer Tools` 调试
4
+
5
+ 1. 安装 `React Developer Tools` 插件
6
+ 2. 打开控制台(F12)
7
+ 3. 切换到 `Component` 标签页
8
+ 4. 选中需要查看的组件,可以看到 `state/props/hooks` 等信息
9
+
10
+ ## 使用 vscode 调试代码
11
+
12
+ 1. 打开 `JavaScript Debug Terminal` 终端,输入 `npm run start` 命令启动项目。
13
+
14
+ ![](https://p0.meituan.net/dpplatform/78a65449d74d1fbd61cc47e98c419a011041253.gif)
15
+
16
+ 2. 按住 `ctrl/command` 点击 `http://localhost:port` 打开链接
17
+ 3. 代码里打断点,网页点击触发断点
package/lib/deploy.js CHANGED
@@ -92,22 +92,39 @@ async function normalDeploy(args) {
92
92
  // 创建本地临时文件夹,位置在 `opts.localPath` 下的 `__tmp__` 文件夹
93
93
  fs.mkdirSync(tmpDir, {
94
94
  recursive: true
95
- }); // 拉取远程文件到本地
96
-
97
- await sftp.fastGet(remoteFile, tmpFile); // 读取本地文件内容
98
-
99
- let code = await fs.readFile(tmpFile, {
100
- encoding: 'utf-8'
101
95
  });
102
- code = changeDeployVersion(code, {
96
+ const info = {
103
97
  name: pkg.name,
104
98
  version: pkg.version,
105
99
  grayscale: appConfig.grayscale
106
- });
107
- await sftp.fastPut(tmpFile, remoteFile + '.bak');
108
- await fs.writeFile(tmpFile, code); // 将修改完的内容传回服务器
109
-
110
- await sftp.fastPut(tmpFile, remoteFile);
100
+ };
101
+ {
102
+ // 拉取远程文件到本地
103
+ await sftp.fastGet(remoteFile, tmpFile); // 读取本地文件内容
104
+
105
+ let code = await fs.readFile(tmpFile, {
106
+ encoding: 'utf-8'
107
+ });
108
+ code = changeDeployVersion(code, info);
109
+ await sftp.fastPut(tmpFile, remoteFile + '.bak');
110
+ await fs.writeFile(tmpFile, code); // 将修改完的内容传回服务器
111
+
112
+ await sftp.fastPut(tmpFile, remoteFile);
113
+ }
114
+ {
115
+ const remoteLogFile = remoteFile + '.log';
116
+ const tmpLogFile = tmpFile + '.log';
117
+ let content = '';
118
+
119
+ try {
120
+ await sftp.fastGet(remoteLogFile, tmpLogFile);
121
+ content = await fs.readFile(tmpLogFile, 'utf-8');
122
+ } catch (error) {}
123
+
124
+ content += `${new Date().toISOString()} ${JSON.stringify(info)}\n`;
125
+ await fs.writeFile(tmpLogFile, content);
126
+ await sftp.fastPut(tmpLogFile, remoteLogFile);
127
+ }
111
128
  spinner.succeed('已更新 ver.js 版本配置');
112
129
  } catch (e) {
113
130
  spinner.fail(`自动修改 ver.js 失败,请手动修改`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qse/edu-scripts",
3
- "version": "1.12.5",
3
+ "version": "1.13.0",
4
4
  "author": "Kinoko",
5
5
  "license": "MIT",
6
6
  "description": "教育工程化基础框架",
package/src/deploy.js CHANGED
@@ -69,21 +69,38 @@ async function normalDeploy(args) {
69
69
  // 创建本地临时文件夹,位置在 `opts.localPath` 下的 `__tmp__` 文件夹
70
70
  fs.mkdirSync(tmpDir, { recursive: true })
71
71
 
72
- // 拉取远程文件到本地
73
- await sftp.fastGet(remoteFile, tmpFile)
74
-
75
- // 读取本地文件内容
76
- let code = await fs.readFile(tmpFile, { encoding: 'utf-8' })
77
- code = changeDeployVersion(code, {
72
+ const info = {
78
73
  name: pkg.name,
79
74
  version: pkg.version,
80
75
  grayscale: appConfig.grayscale,
81
- })
76
+ }
77
+
78
+ {
79
+ // 拉取远程文件到本地
80
+ await sftp.fastGet(remoteFile, tmpFile)
81
+
82
+ // 读取本地文件内容
83
+ let code = await fs.readFile(tmpFile, { encoding: 'utf-8' })
84
+ code = changeDeployVersion(code, info)
82
85
 
83
- await sftp.fastPut(tmpFile, remoteFile + '.bak')
84
- await fs.writeFile(tmpFile, code)
85
- // 将修改完的内容传回服务器
86
- await sftp.fastPut(tmpFile, remoteFile)
86
+ await sftp.fastPut(tmpFile, remoteFile + '.bak')
87
+ await fs.writeFile(tmpFile, code)
88
+ // 将修改完的内容传回服务器
89
+ await sftp.fastPut(tmpFile, remoteFile)
90
+ }
91
+
92
+ {
93
+ const remoteLogFile = remoteFile + '.log'
94
+ const tmpLogFile = tmpFile + '.log'
95
+ let content = ''
96
+ try {
97
+ await sftp.fastGet(remoteLogFile, tmpLogFile)
98
+ content = await fs.readFile(tmpLogFile, 'utf-8')
99
+ } catch (error) {}
100
+ content += `${new Date().toISOString()} ${JSON.stringify(info)}\n`
101
+ await fs.writeFile(tmpLogFile, content)
102
+ await sftp.fastPut(tmpLogFile, remoteLogFile)
103
+ }
87
104
 
88
105
  spinner.succeed('已更新 ver.js 版本配置')
89
106
  } catch (e) {