@seayoo-web/scripts 2.5.5 → 2.5.7
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.js +49 -15
- package/package.json +1 -1
- package/types/src/env.d.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import vue from "@vitejs/plugin-vue";
|
|
3
3
|
import { visualizer } from "rollup-plugin-visualizer";
|
|
4
|
-
import { viteDeployPlugin } from "@seayoo-web/finder";
|
|
4
|
+
import { finderDeploy, viteDeployPlugin } from "@seayoo-web/finder";
|
|
5
5
|
import { sentryVitePlugin } from "@sentry/vite-plugin";
|
|
6
6
|
import legacy from "@vitejs/plugin-legacy";
|
|
7
7
|
import vueDevTools from "vite-plugin-vue-devtools";
|
|
8
|
-
import { existsSync, readFileSync } from "fs";
|
|
8
|
+
import { existsSync, readFileSync, statSync, readdirSync } from "fs";
|
|
9
9
|
import { loadEnv } from "vite";
|
|
10
|
-
import "colors";
|
|
11
10
|
import { g as getNowTime, a as getCommitInfo, c as createPageDeployTag } from "./git-9UtzsH83.js";
|
|
11
|
+
import "colors";
|
|
12
12
|
import skipFormatting from "@vue/eslint-config-prettier/skip-formatting";
|
|
13
13
|
import { vueTsConfigs, defineConfigWithVueTs } from "@vue/eslint-config-typescript";
|
|
14
14
|
import { flatConfigs } from "eslint-plugin-import";
|
|
@@ -90,18 +90,37 @@ function getBuildEnv(command, mode, onlyBuild, requireSentryToken, ignoreSentryT
|
|
|
90
90
|
envConfig.page = execDirWithPackage;
|
|
91
91
|
const port = +envs[p];
|
|
92
92
|
if (port) envConfig.port = port;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
envConfig.deployTo = (envs[t] || "").replace(/(?:^https?:\/\/|\/*$)/gi, "").replace(/^(.)/, "https://$1");
|
|
94
|
+
envConfig.deployUser = envs[u];
|
|
95
|
+
envConfig.deployKey = envs[k];
|
|
96
|
+
envConfig.deployDebug = envs[d] === "1" || envs[d] === "y" || envs[d] === "true";
|
|
97
|
+
if (mode === "wellknown") {
|
|
98
|
+
const wellknownDir = join(process.cwd(), ".well-known");
|
|
99
|
+
if (!existsSync(wellknownDir)) {
|
|
100
|
+
console.error(`没有找到 .well-known 目录,它应该跟项目 package.json 文件在一个目录下`.red);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
if (!statSync(wellknownDir).isDirectory()) {
|
|
104
|
+
console.error(`.well-known 应该是一个目录`.red);
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
const files = readdirSync(wellknownDir);
|
|
108
|
+
if (files.length === 0) {
|
|
109
|
+
console.error(`.well-known 不能是一个空目录`.red);
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
if (!envConfig.deployTo) {
|
|
113
|
+
console.error(`缺少 ${t.bgRed} 设置,请在 .env.${mode} 中配置`.red);
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
if (!envConfig.deployUser || !envConfig.deployKey) {
|
|
117
|
+
console.error(`缺少 ${u.bgRed} / ${k.bgRed} 设置,请在 .env.local 配置`.red);
|
|
99
118
|
process.exit(1);
|
|
100
119
|
}
|
|
101
|
-
envConfig.
|
|
102
|
-
envConfig
|
|
103
|
-
|
|
104
|
-
|
|
120
|
+
envConfig.wellKnownDir = wellknownDir;
|
|
121
|
+
return envConfig;
|
|
122
|
+
}
|
|
123
|
+
if (!onlyBuild && envConfig.command === "build") {
|
|
105
124
|
if (!envConfig.deployTo) {
|
|
106
125
|
console.error(`缺少 ${t.bgRed} 设置,请在 .env.${mode} 中配置`.red);
|
|
107
126
|
process.exit(1);
|
|
@@ -161,7 +180,7 @@ function definePageBuildConfig(option) {
|
|
|
161
180
|
} = option || {};
|
|
162
181
|
const { alias, ...resolveReset } = resolve;
|
|
163
182
|
if (server.port) {
|
|
164
|
-
console.warn(`ServerPort 不允许直接修改,请使用环境变量 ${EnvPrefix}
|
|
183
|
+
console.warn(`ServerPort 不允许直接修改,请使用环境变量 ${EnvPrefix}SERVER_PORT 设置`);
|
|
165
184
|
delete server.port;
|
|
166
185
|
}
|
|
167
186
|
return async function({ command, mode }) {
|
|
@@ -169,7 +188,22 @@ function definePageBuildConfig(option) {
|
|
|
169
188
|
const justBuild = mode === "build";
|
|
170
189
|
const envs = getBuildEnv(command, mode, justBuild, requireSentryToken, ignoreSentryToken);
|
|
171
190
|
const gitInfo = justBuild ? null : await getCommitInfo(command, mode, envs.page, envs.deployTo || "");
|
|
172
|
-
const isProductMode = mode === "production" || mode === "prod";
|
|
191
|
+
const isProductMode = mode === "production" || mode === "prod" || mode === "prd";
|
|
192
|
+
if (mode === "wellknown" && envs.wellKnownDir && envs.deployTo) {
|
|
193
|
+
const result = await finderDeploy({
|
|
194
|
+
preview: false,
|
|
195
|
+
deployTo: envs.deployTo.replace(/\/$/, "") + "/.well-known",
|
|
196
|
+
dist: envs.wellKnownDir,
|
|
197
|
+
user: envs.deployUser,
|
|
198
|
+
key: envs.deployKey
|
|
199
|
+
}).catch((e) => e instanceof Error ? e : typeof e === "string" ? new Error(e) : new Error(e + ""));
|
|
200
|
+
if (result instanceof Error) {
|
|
201
|
+
console.log("部署 .well-known 失败".bgRed, result.message);
|
|
202
|
+
} else {
|
|
203
|
+
console.log("部署 .well-known 成功".bgGreen, (result || "").green);
|
|
204
|
+
}
|
|
205
|
+
process.exit(0);
|
|
206
|
+
}
|
|
173
207
|
const trunkMap = {
|
|
174
208
|
"naive-ui": "naive-ui",
|
|
175
209
|
html2canvas: "html2canvas",
|
package/package.json
CHANGED
package/types/src/env.d.ts
CHANGED