@seayoo-web/scripts 1.3.3 → 1.3.4
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/{git-DCdWCW6L.js → git-C3gyPvsT.js} +27 -12
- package/dist/index.js +1 -1
- package/dist/node.js +5 -1
- package/package.json +4 -2
- package/types/src/utils.d.ts +1 -4
|
@@ -5,7 +5,11 @@ import "colors";
|
|
|
5
5
|
const TemplateDir = "template";
|
|
6
6
|
const InternalDir = "internal";
|
|
7
7
|
const WorkspaceFile = "pnpm-workspace.yaml";
|
|
8
|
-
|
|
8
|
+
let _root = null;
|
|
9
|
+
async function getMonorepoRoot(ignoreMissing) {
|
|
10
|
+
if (_root !== null) {
|
|
11
|
+
return _root;
|
|
12
|
+
}
|
|
9
13
|
let currentDir = process.cwd();
|
|
10
14
|
while (currentDir !== path.parse(currentDir).root) {
|
|
11
15
|
if (fs.existsSync(path.join(currentDir, WorkspaceFile))) {
|
|
@@ -14,14 +18,19 @@ const root = function() {
|
|
|
14
18
|
currentDir = path.dirname(currentDir);
|
|
15
19
|
}
|
|
16
20
|
if (fs.existsSync(path.join(currentDir, "pnpm-workspace.yaml"))) {
|
|
21
|
+
_root = currentDir;
|
|
17
22
|
return currentDir;
|
|
18
23
|
}
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
if (ignoreMissing) {
|
|
25
|
+
return "";
|
|
26
|
+
}
|
|
27
|
+
throw new Error("当前项目不是 monorepo 项目!");
|
|
28
|
+
}
|
|
21
29
|
async function getTemplates() {
|
|
22
30
|
return await getRepos(TemplateDir);
|
|
23
31
|
}
|
|
24
32
|
async function getRepos(project) {
|
|
33
|
+
const root = await getMonorepoRoot();
|
|
25
34
|
const projectDir = path.join(root, project);
|
|
26
35
|
const dirs = await fs.readdir(projectDir);
|
|
27
36
|
const repos = dirs.filter((item) => fs.statSync(path.join(projectDir, item)).isDirectory());
|
|
@@ -29,6 +38,7 @@ async function getRepos(project) {
|
|
|
29
38
|
return repos.map((dir, index) => ({ id: dir, desc: descs[index] })).filter((item) => item.desc !== null);
|
|
30
39
|
}
|
|
31
40
|
async function getRepoDesc(project, dir) {
|
|
41
|
+
const root = await getMonorepoRoot();
|
|
32
42
|
const packageFile = path.join(root, project, dir, "package.json");
|
|
33
43
|
if (!await fs.exists(packageFile)) {
|
|
34
44
|
return null;
|
|
@@ -37,6 +47,7 @@ async function getRepoDesc(project, dir) {
|
|
|
37
47
|
return (content.description || "") + "";
|
|
38
48
|
}
|
|
39
49
|
async function getProjects(returnAll) {
|
|
50
|
+
const root = await getMonorepoRoot();
|
|
40
51
|
const rootPkgPath = path.join(root, WorkspaceFile);
|
|
41
52
|
if (await fs.pathExists(rootPkgPath)) {
|
|
42
53
|
const content = await fs.readFile(rootPkgPath, "utf8");
|
|
@@ -56,6 +67,7 @@ async function getProjectName(project) {
|
|
|
56
67
|
return project;
|
|
57
68
|
}
|
|
58
69
|
async function copyTemplate(templateName, targetDir) {
|
|
70
|
+
const root = await getMonorepoRoot();
|
|
59
71
|
const templateSourceDir = path.join(root, TemplateDir, templateName);
|
|
60
72
|
await fs.copy(templateSourceDir, targetDir, {
|
|
61
73
|
filter: (src) => {
|
|
@@ -64,6 +76,7 @@ async function copyTemplate(templateName, targetDir) {
|
|
|
64
76
|
});
|
|
65
77
|
}
|
|
66
78
|
async function addProjectToWorkspace(project) {
|
|
79
|
+
const root = await getMonorepoRoot();
|
|
67
80
|
const rootWorkspacePath = path.join(root, WorkspaceFile);
|
|
68
81
|
if (await fs.pathExists(rootWorkspacePath)) {
|
|
69
82
|
let content = await fs.readFile(rootWorkspacePath, "utf8");
|
|
@@ -75,6 +88,7 @@ async function addProjectToWorkspace(project) {
|
|
|
75
88
|
}
|
|
76
89
|
}
|
|
77
90
|
async function removeProjectFromWorkspace(project) {
|
|
91
|
+
const root = await getMonorepoRoot();
|
|
78
92
|
const rootWorkspacePath = path.join(root, WorkspaceFile);
|
|
79
93
|
if (await fs.pathExists(rootWorkspacePath)) {
|
|
80
94
|
const content = (await fs.readFile(rootWorkspacePath, "utf8")).replace(
|
|
@@ -97,8 +111,9 @@ function converToDeployTagName(deployTo) {
|
|
|
97
111
|
return `${DeployTagPrefix}${deployTo.toLowerCase().replace(/(?:^https?:\/\/|\/*$)/gi, "")}`;
|
|
98
112
|
}
|
|
99
113
|
async function execCmd(cmd, ignoreWarning = false) {
|
|
114
|
+
const root = await getMonorepoRoot(true);
|
|
100
115
|
return new Promise((resolve, reject) => {
|
|
101
|
-
exec(cmd, { cwd: root, env: { ...process.env } }, (error, stdout, stderr) => {
|
|
116
|
+
exec(cmd, { cwd: root || "./", env: { ...process.env } }, (error, stdout, stderr) => {
|
|
102
117
|
if (error || stderr && !ignoreWarning) {
|
|
103
118
|
console.error(cmd, error, stderr);
|
|
104
119
|
reject(`执行命令时出错: ${(error == null ? void 0 : error.message) || stderr}`);
|
|
@@ -217,16 +232,16 @@ async function submitAllDeletionChanges(message) {
|
|
|
217
232
|
}
|
|
218
233
|
export {
|
|
219
234
|
getCommitInfo as a,
|
|
220
|
-
|
|
235
|
+
getMonorepoRoot as b,
|
|
221
236
|
createPageDeployTag as c,
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
237
|
+
addProjectToWorkspace as d,
|
|
238
|
+
copyTemplate as e,
|
|
239
|
+
getProjects as f,
|
|
225
240
|
getNowTime as g,
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
241
|
+
getTemplates as h,
|
|
242
|
+
checkGitStatusBeforeDestory as i,
|
|
243
|
+
createBackupTag as j,
|
|
229
244
|
getRepos as k,
|
|
230
|
-
|
|
245
|
+
removeProjectFromWorkspace as r,
|
|
231
246
|
submitAllDeletionChanges as s
|
|
232
247
|
};
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import vue from "@vitejs/plugin-vue";
|
|
|
7
7
|
import vueDevTools from "vite-plugin-vue-devtools";
|
|
8
8
|
import { existsSync, readFileSync } from "fs";
|
|
9
9
|
import "colors";
|
|
10
|
-
import { g as getNowTime, a as getCommitInfo, c as createPageDeployTag } from "./git-
|
|
10
|
+
import { g as getNowTime, a as getCommitInfo, c as createPageDeployTag } from "./git-C3gyPvsT.js";
|
|
11
11
|
import skipFormatting from "@vue/eslint-config-prettier/skip-formatting";
|
|
12
12
|
import { vueTsConfigs, defineConfigWithVueTs } from "@vue/eslint-config-typescript";
|
|
13
13
|
import { flatConfigs } from "eslint-plugin-import";
|
package/dist/node.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Command } from "commander";
|
|
|
5
5
|
import fs from "fs-extra";
|
|
6
6
|
import inquirer from "inquirer";
|
|
7
7
|
import ora from "ora";
|
|
8
|
-
import {
|
|
8
|
+
import { b as getMonorepoRoot, d as addProjectToWorkspace, e as copyTemplate, f as getProjects, h as getTemplates, i as checkGitStatusBeforeDestory, j as createBackupTag, r as removeProjectFromWorkspace, s as submitAllDeletionChanges, k as getRepos } from "./git-C3gyPvsT.js";
|
|
9
9
|
const commitRE = /^(?:revert: )?(?:feat|fix|docs|style|refactor|test|build|chore|debug|tweak|improve)(?:\(.+\))?: .{1,100}/;
|
|
10
10
|
function checkCommit() {
|
|
11
11
|
const msgPath = process.argv[2];
|
|
@@ -130,6 +130,7 @@ async function startCreateJob$1(target) {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
async function createProject() {
|
|
133
|
+
const root = await getMonorepoRoot();
|
|
133
134
|
const questions = await initProjectQuestions$1();
|
|
134
135
|
const answers = await inquirer.prompt(questions);
|
|
135
136
|
const spinner = ora("正在创建项目...").start();
|
|
@@ -140,6 +141,7 @@ async function createProject() {
|
|
|
140
141
|
spinner.succeed("项目创建成功!".green);
|
|
141
142
|
}
|
|
142
143
|
async function createRepo() {
|
|
144
|
+
const root = await getMonorepoRoot();
|
|
143
145
|
const questions = await initRepoQuestions$1();
|
|
144
146
|
const answers = await inquirer.prompt(questions);
|
|
145
147
|
const spinner = ora("正在创建仓库...").start();
|
|
@@ -199,6 +201,7 @@ async function initProjectQuestions() {
|
|
|
199
201
|
];
|
|
200
202
|
}
|
|
201
203
|
async function destroyProject() {
|
|
204
|
+
const root = await getMonorepoRoot();
|
|
202
205
|
await checkGitStatusBeforeDestory();
|
|
203
206
|
const questions = await initProjectQuestions();
|
|
204
207
|
const answers = await inquirer.prompt(questions);
|
|
@@ -255,6 +258,7 @@ async function initRepoQuestions() {
|
|
|
255
258
|
];
|
|
256
259
|
}
|
|
257
260
|
async function destroyRepo() {
|
|
261
|
+
const root = await getMonorepoRoot();
|
|
258
262
|
await checkGitStatusBeforeDestory();
|
|
259
263
|
const questions = await initRepoQuestions();
|
|
260
264
|
const answers = await inquirer.prompt(questions);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seayoo-web/scripts",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "scripts for seayoo web monorepos",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "index.ts",
|
|
@@ -60,13 +60,15 @@
|
|
|
60
60
|
"stylelint": "^16.15.0",
|
|
61
61
|
"stylelint-config-recess-order": "^6.0.0",
|
|
62
62
|
"stylelint-config-standard": "^37.0.0",
|
|
63
|
+
"vite": "^6.2.1",
|
|
63
64
|
"@seayoo-web/tsconfig": "^1.0.3"
|
|
64
65
|
},
|
|
65
66
|
"peerDependencies": {
|
|
66
67
|
"eslint": "^9.19.0",
|
|
67
68
|
"stylelint": "^16.14.1",
|
|
68
69
|
"stylelint-config-recess-order": "^6.0.0",
|
|
69
|
-
"stylelint-config-standard": "^37.0.0"
|
|
70
|
+
"stylelint-config-standard": "^37.0.0",
|
|
71
|
+
"vite": "^6.2.1"
|
|
70
72
|
},
|
|
71
73
|
"scripts": {
|
|
72
74
|
"build": "vite build && tsc --emitDeclarationOnly",
|
package/types/src/utils.d.ts
CHANGED
|
@@ -3,10 +3,7 @@ import "colors";
|
|
|
3
3
|
export declare const TemplateDir = "template";
|
|
4
4
|
/** 内部模块目录 */
|
|
5
5
|
export declare const InternalDir = "internal";
|
|
6
|
-
|
|
7
|
-
* monorepo 项目根目录
|
|
8
|
-
*/
|
|
9
|
-
export declare const root: string;
|
|
6
|
+
export declare function getMonorepoRoot(ignoreMissing?: boolean): Promise<string>;
|
|
10
7
|
/**
|
|
11
8
|
* 读取所有模板项目信息
|
|
12
9
|
*/
|