@seayoo-web/scripts 1.3.2 → 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-BbsLu9cn.js → git-C3gyPvsT.js} +28 -12
- package/dist/index.js +7 -9
- package/dist/node.js +5 -1
- package/package.json +4 -2
- package/types/src/eslint.d.ts +0 -3
- package/types/src/utils.d.ts +1 -4
- package/types/src/vite.app.d.ts +1 -1
|
@@ -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}`);
|
|
@@ -132,6 +147,7 @@ async function getCommitInfo(command, mode, page, deployTo) {
|
|
|
132
147
|
console.error("正式环境部署需要先将代码同步到服务器!".red, `发现 ${unCommitChanges} 个 commit 差异`.red);
|
|
133
148
|
process.exit(1);
|
|
134
149
|
}
|
|
150
|
+
await execCmd("git pull", true);
|
|
135
151
|
const [currentCommit, lastDeployTag] = await Promise.all([getCommitHash(), getLastDeployTag(deployTo)]);
|
|
136
152
|
const commitLogs = await getCommitLogs(currentCommit, lastDeployTag, page || "./");
|
|
137
153
|
return { hash: currentCommit, logs: commitLogs };
|
|
@@ -216,16 +232,16 @@ async function submitAllDeletionChanges(message) {
|
|
|
216
232
|
}
|
|
217
233
|
export {
|
|
218
234
|
getCommitInfo as a,
|
|
219
|
-
|
|
235
|
+
getMonorepoRoot as b,
|
|
220
236
|
createPageDeployTag as c,
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
237
|
+
addProjectToWorkspace as d,
|
|
238
|
+
copyTemplate as e,
|
|
239
|
+
getProjects as f,
|
|
224
240
|
getNowTime as g,
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
241
|
+
getTemplates as h,
|
|
242
|
+
checkGitStatusBeforeDestory as i,
|
|
243
|
+
createBackupTag as j,
|
|
228
244
|
getRepos as k,
|
|
229
|
-
|
|
245
|
+
removeProjectFromWorkspace as r,
|
|
230
246
|
submitAllDeletionChanges as s
|
|
231
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";
|
|
@@ -143,8 +143,8 @@ function definePageBuildConfig(option) {
|
|
|
143
143
|
"safari>=8",
|
|
144
144
|
"iOS>=8"
|
|
145
145
|
],
|
|
146
|
-
//
|
|
147
|
-
modernTargets: "edge>=131, firefox>=67, chrome>=
|
|
146
|
+
// 提高现代版本的要求以满足一些特性使用,比如 [Promise.allSettled](https://caniuse.com/?search=allSettled)
|
|
147
|
+
modernTargets: "edge>=131, firefox>=67, chrome>=76, chromeAndroid>=76, safari>=13, iOS>=13",
|
|
148
148
|
// https://github.com/vitejs/vite/blob/main/packages/plugin-legacy/src/index.ts#L170
|
|
149
149
|
// https://unpkg.com/browse/core-js@3.41.0/
|
|
150
150
|
additionalLegacyPolyfills: [
|
|
@@ -153,7 +153,8 @@ function definePageBuildConfig(option) {
|
|
|
153
153
|
"core-js/es/global-this",
|
|
154
154
|
"core-js/es/promise",
|
|
155
155
|
"core-js/es/symbol"
|
|
156
|
-
]
|
|
156
|
+
],
|
|
157
|
+
additionalModernPolyfills: ["core-js/es/symbol"]
|
|
157
158
|
}),
|
|
158
159
|
htmlInjectPlugin({
|
|
159
160
|
BUILD_TIME: envs.stamp,
|
|
@@ -207,7 +208,7 @@ function definePageBuildConfig(option) {
|
|
|
207
208
|
});
|
|
208
209
|
}
|
|
209
210
|
function defineAppBuildConfig(option) {
|
|
210
|
-
return defineConfig(
|
|
211
|
+
return defineConfig(function() {
|
|
211
212
|
const { plugins = [], build = {}, resolve = {}, ...optionReset } = option || {};
|
|
212
213
|
const { alias, ...resolveReset } = resolve || {};
|
|
213
214
|
return {
|
|
@@ -261,10 +262,7 @@ const importOrderRuleConfig = {
|
|
|
261
262
|
}
|
|
262
263
|
],
|
|
263
264
|
distinctGroup: true,
|
|
264
|
-
sortTypesGroup: true,
|
|
265
265
|
"newlines-between": "always",
|
|
266
|
-
"newlines-between-types": "never",
|
|
267
|
-
name: true,
|
|
268
266
|
alphabetize: {
|
|
269
267
|
order: "asc",
|
|
270
268
|
caseInsensitive: true
|
|
@@ -274,7 +272,7 @@ const importEslintConfig = [
|
|
|
274
272
|
flatConfigs.recommended,
|
|
275
273
|
{
|
|
276
274
|
rules: {
|
|
277
|
-
"import/no-deprecated": "
|
|
275
|
+
"import/no-deprecated": "error",
|
|
278
276
|
"import/no-unresolved": "off",
|
|
279
277
|
"import/named": "off",
|
|
280
278
|
"import/namespace": "off",
|
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/eslint.d.ts
CHANGED
|
@@ -11,10 +11,7 @@ export declare const importOrderRuleConfig: {
|
|
|
11
11
|
group: string;
|
|
12
12
|
}[];
|
|
13
13
|
distinctGroup: boolean;
|
|
14
|
-
sortTypesGroup: boolean;
|
|
15
14
|
"newlines-between": string;
|
|
16
|
-
"newlines-between-types": string;
|
|
17
|
-
name: boolean;
|
|
18
15
|
alphabetize: {
|
|
19
16
|
order: string;
|
|
20
17
|
caseInsensitive: boolean;
|
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
|
*/
|
package/types/src/vite.app.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ import { type UserConfig } from "vite";
|
|
|
2
2
|
/**
|
|
3
3
|
* 导出一个动态的配置工厂函数
|
|
4
4
|
*/
|
|
5
|
-
export declare function defineAppBuildConfig(option?: UserConfig): import("vite").
|
|
5
|
+
export declare function defineAppBuildConfig(option?: UserConfig): import("vite").UserConfigFnObject;
|