@wagq/wa-cli 0.6.39 → 0.6.41

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/config/command.js CHANGED
@@ -9,6 +9,8 @@ const skill = require("../lib/skill");
9
9
  const { generateIcon2Tsx } = require("../lib/generateIcon/tsx");
10
10
  const changesetDoc = require("../lib/changesetDoc");
11
11
  const vsSetting = require("../lib/vsSetting");
12
+ const checkBranch = require("../lib/checkBranch");
13
+ const clear = require("../lib/clear");
12
14
 
13
15
  const command = [
14
16
  {
@@ -160,7 +162,19 @@ const command = [
160
162
  alias: "vs",
161
163
  description: "生成vscode配置文件",
162
164
  action: vsSetting,
163
- }
165
+ },
166
+ {
167
+ name: "checkBranch",
168
+ alias: "ckb",
169
+ description: "检查当前分支",
170
+ action: checkBranch,
171
+ },
172
+ {
173
+ name: "clear",
174
+ alias: "clear",
175
+ description: "删除目录下node_modules与dist,如果有packages目录则继续下钻",
176
+ action: clear,
177
+ },
164
178
  ];
165
179
 
166
180
  module.exports = command;
@@ -2,7 +2,6 @@ const { execSync } = require("child_process");
2
2
 
3
3
  const changesetDoc = (mode, argv) => {
4
4
  const registry = argv.registry ?? "https://registry.npmjs.org/";
5
- console.log(registry, "registry");
6
5
  let bins = [];
7
6
  switch (mode) {
8
7
  case "dev":
@@ -0,0 +1,23 @@
1
+ const { execSync } = require("child_process");
2
+ const log = require("../../utils/log.js");
3
+
4
+ const checkBranch = () => {
5
+ try {
6
+ const branch = execSync("git rev-parse --abbrev-ref HEAD", {
7
+ encoding: "utf-8",
8
+ }).trim();
9
+
10
+ log.info(`当前分支 ${branch}`);
11
+
12
+ if (branch !== "dev") {
13
+ log.error(`错误: 请在 dev 分支上执行该脚本`);
14
+ log.error(`当前分支: ${branch}`);
15
+ process.exit(1);
16
+ }
17
+ } catch (error) {
18
+ log.error(error);
19
+ process.exit(1);
20
+ }
21
+ };
22
+
23
+ module.exports = checkBranch
@@ -0,0 +1,35 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const log = require("../../utils/log.js");
4
+
5
+ const cleanDir = (dirPath) => {
6
+ if (fs.existsSync(dirPath)) {
7
+ fs.rmSync(dirPath, { recursive: true, force: true });
8
+ log.info(`Removed ${dirPath}`);
9
+ }
10
+ };
11
+
12
+ const clear = (targetDir = process.cwd()) => {
13
+ try {
14
+ const packagesDir = path.join(targetDir, "packages");
15
+
16
+ if (fs.existsSync(packagesDir)) {
17
+ const dirs = fs.readdirSync(packagesDir, { withFileTypes: true });
18
+ for (const dirent of dirs) {
19
+ if (dirent.isDirectory()) {
20
+ const dir = path.join(packagesDir, dirent.name);
21
+ cleanDir(path.join(dir, "dist"));
22
+ cleanDir(path.join(dir, "node_modules"));
23
+ }
24
+ }
25
+ }
26
+
27
+ cleanDir(path.join(targetDir, "node_modules"));
28
+
29
+ log.info("💐 Clear done!");
30
+ } catch (error) {
31
+ log.error(error);
32
+ }
33
+ };
34
+
35
+ module.exports = clear;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wagq/wa-cli",
3
- "version": "0.6.39",
3
+ "version": "0.6.41",
4
4
  "description": "wa的脚手架",
5
5
  "main": "index.js",
6
6
  "scripts": {