@seayoo-web/scripts 2.5.6 → 2.6.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.
@@ -172,7 +172,7 @@ async function execCmd(cmd, ignoreWarning = false) {
172
172
  exec(cmd, { cwd: root || "./", env: { ...process.env } }, (error, stdout, stderr) => {
173
173
  if (error || stderr && !ignoreWarning) {
174
174
  console.error(cmd, error, stderr);
175
- reject(`执行命令时出错: ${(error == null ? void 0 : error.message) || stderr}`);
175
+ reject(`执行命令时出错: ${error?.message || stderr}`);
176
176
  return;
177
177
  }
178
178
  resolve(stdout.trim());
package/dist/index.js CHANGED
@@ -4,10 +4,9 @@ import { visualizer } from "rollup-plugin-visualizer";
4
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
- import vueDevTools from "vite-plugin-vue-devtools";
8
7
  import { existsSync, readFileSync, statSync, readdirSync } from "fs";
9
8
  import { loadEnv } from "vite";
10
- import { g as getNowTime, a as getCommitInfo, c as createPageDeployTag } from "./git-9UtzsH83.js";
9
+ import { g as getNowTime, a as getCommitInfo, c as createPageDeployTag } from "./git-CJ_QW0oc.js";
11
10
  import "colors";
12
11
  import skipFormatting from "@vue/eslint-config-prettier/skip-formatting";
13
12
  import { vueTsConfigs, defineConfigWithVueTs } from "@vue/eslint-config-typescript";
@@ -26,7 +25,7 @@ function defineAppBuildConfig(option) {
26
25
  sourcemap: false,
27
26
  ...build
28
27
  },
29
- plugins: [vue(), (option == null ? void 0 : option.visualizer) ? visualizer() : null, ...plugins],
28
+ plugins: [vue(), option?.visualizer ? visualizer() : null, ...plugins],
30
29
  resolve: {
31
30
  alias: {
32
31
  "@": join(process.cwd(), "./src"),
@@ -41,22 +40,22 @@ function defineAppBuildConfig(option) {
41
40
  function defineLibBuildConfig(option) {
42
41
  return {
43
42
  build: {
44
- outDir: (option == null ? void 0 : option.outDir) || "dist",
43
+ outDir: option?.outDir || "dist",
45
44
  lib: {
46
- entry: join(process.cwd(), (option == null ? void 0 : option.rootEntry) || "index.ts"),
45
+ entry: join(process.cwd(), option?.rootEntry || "index.ts"),
47
46
  formats: ["es"],
48
47
  fileName: (format, entryName) => {
49
48
  return format === "es" ? `${entryName}.js` : `${entryName}.${format}.js`;
50
49
  }
51
50
  },
52
51
  rollupOptions: {
53
- external: (option == null ? void 0 : option.external) || [/^@seayoo-web\/(?:request|utils|combo-webview)/]
52
+ external: option?.external || [/^@seayoo-web\/(?:request|utils|combo-webview)/]
54
53
  }
55
54
  }
56
55
  };
57
56
  }
58
57
  const EnvPrefix = "SY_";
59
- function getBuildEnv(command, mode, onlyBuild, requireSentryToken, ignoreSentryToken) {
58
+ function getBuildEnv(command, mode, requireSentryToken, ignoreSentryToken) {
60
59
  const envs = loadEnv(mode, process.cwd(), EnvPrefix);
61
60
  const envConfig = {
62
61
  command,
@@ -120,7 +119,7 @@ function getBuildEnv(command, mode, onlyBuild, requireSentryToken, ignoreSentryT
120
119
  envConfig.wellKnownDir = wellknownDir;
121
120
  return envConfig;
122
121
  }
123
- if (!onlyBuild && envConfig.command === "build") {
122
+ if (mode !== "build" && envConfig.command === "build") {
124
123
  if (!envConfig.deployTo) {
125
124
  console.error(`缺少 ${t.bgRed} 设置,请在 .env.${mode} 中配置`.red);
126
125
  process.exit(1);
@@ -184,15 +183,14 @@ function definePageBuildConfig(option) {
184
183
  delete server.port;
185
184
  }
186
185
  return async function({ command, mode }) {
187
- var _a, _b, _c;
186
+ const envs = getBuildEnv(command, mode, requireSentryToken, ignoreSentryToken);
188
187
  const justBuild = mode === "build";
189
- const envs = getBuildEnv(command, mode, justBuild, requireSentryToken, ignoreSentryToken);
190
188
  const gitInfo = justBuild ? null : await getCommitInfo(command, mode, envs.page, envs.deployTo || "");
191
189
  const isProductMode = mode === "production" || mode === "prod" || mode === "prd";
192
190
  if (mode === "wellknown" && envs.wellKnownDir && envs.deployTo) {
193
191
  const result = await finderDeploy({
194
192
  preview: false,
195
- deployTo: envs.deployTo,
193
+ deployTo: envs.deployTo.replace(/\/$/, "") + "/.well-known",
196
194
  dist: envs.wellKnownDir,
197
195
  user: envs.deployUser,
198
196
  key: envs.deployKey
@@ -202,7 +200,7 @@ function definePageBuildConfig(option) {
202
200
  } else {
203
201
  console.log("部署 .well-known 成功".bgGreen, (result || "").green);
204
202
  }
205
- return {};
203
+ process.exit(0);
206
204
  }
207
205
  const trunkMap = {
208
206
  "naive-ui": "naive-ui",
@@ -239,13 +237,13 @@ function definePageBuildConfig(option) {
239
237
  ...build.rollupOptions,
240
238
  output: {
241
239
  manualChunks: trunkFn,
242
- ...(_a = build.rollupOptions) == null ? void 0 : _a.output
240
+ ...build.rollupOptions?.output
243
241
  }
244
242
  }
245
243
  },
246
244
  plugins: [
247
245
  notVuePage ? null : vue(),
248
- notVuePage ? null : vueDevTools(),
246
+ // notVuePage ? null : vueDevTools(),
249
247
  noPolyfill ? null : legacy({
250
248
  targets: ["defaults", "> 0.1%", "last 5 versions and not dead"],
251
249
  // https://github.com/vitejs/vite/blob/main/packages/plugin-legacy/src/index.ts#L170
@@ -270,18 +268,18 @@ function definePageBuildConfig(option) {
270
268
  htmlInjectPlugin({
271
269
  BUILD_TIME: envs.stamp,
272
270
  BUILD_MODE: envs.mode,
273
- BUILD_VERSION: (gitInfo == null ? void 0 : gitInfo.hash) || "",
271
+ BUILD_VERSION: gitInfo?.hash || "",
274
272
  ...envs.viteEnvs
275
273
  }),
276
274
  ...plugins,
277
275
  command === "build" && envs.deployTo && !justBuild && gitInfo ? viteDeployPlugin({
278
276
  deployTo: envs.deployTo,
279
277
  // 忽略 js sourcemap 文件
280
- ignoreFiles: ["*.js.map", ...((_b = option == null ? void 0 : option.finder) == null ? void 0 : _b.ignoreFiles) || []],
278
+ ignoreFiles: ["*.js.map", ...option?.finder?.ignoreFiles || []],
281
279
  user: envs.deployUser,
282
280
  key: envs.deployKey,
283
281
  debug: envs.deployDebug,
284
- preview: ((_c = option == null ? void 0 : option.finder) == null ? void 0 : _c.preview) ?? true,
282
+ preview: option?.finder?.preview ?? true,
285
283
  commitLogs: isProductMode && gitInfo.logs.length > 0 ? "\n" + gitInfo.logs.join("\n") : void 0,
286
284
  onFinished() {
287
285
  if (isProductMode) {
package/dist/node.js CHANGED
@@ -1,6 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
1
  import { readFileSync, readdirSync, statSync, existsSync, rmSync, mkdirSync, writeFileSync } from "fs";
5
2
  import "colors";
6
3
  import path, { resolve } from "path";
@@ -8,7 +5,7 @@ import { Command } from "commander";
8
5
  import fs from "fs-extra";
9
6
  import inquirer from "inquirer";
10
7
  import ora from "ora";
11
- import { b as getMonorepoRoot, d as addProjectToWorkspace, e as copyTemplate, f as copyGlobalFiles, h as getProjects, i as getTemplates, j as checkGitStatusBeforeDestroy, k as createBackupTag, r as removeProjectFromWorkspace, s as submitAllDeletionChanges, l as getRepos, m as isPlainObject, n as format, o as deepMerge } from "./git-9UtzsH83.js";
8
+ import { b as getMonorepoRoot, d as addProjectToWorkspace, e as copyTemplate, f as copyGlobalFiles, h as getProjects, i as getTemplates, j as checkGitStatusBeforeDestroy, k as createBackupTag, r as removeProjectFromWorkspace, s as submitAllDeletionChanges, l as getRepos, m as isPlainObject, n as format, o as deepMerge } from "./git-CJ_QW0oc.js";
12
9
  import { finderUpload } from "@seayoo-web/finder";
13
10
  import { finderDeploy, finderUpload as finderUpload2 } from "@seayoo-web/finder";
14
11
  import { createServer } from "http";
@@ -290,6 +287,14 @@ const scriptReg = /<script>.+?<\/script>/gi;
290
287
  const scriptMetaReg = /<script meta>.+?<\/script>/gi;
291
288
  const htmlReg = /<template>.+?<\/template>/gi;
292
289
  class FooterBuilder {
290
+ codeBaseDir;
291
+ envFilePath;
292
+ distDir;
293
+ dataJsonFile;
294
+ injectFunction;
295
+ $groups;
296
+ previewAfterDeploy;
297
+ deployDebug;
293
298
  constructor({
294
299
  codeBaseDir,
295
300
  distDir,
@@ -299,14 +304,6 @@ class FooterBuilder {
299
304
  previewAfterDeploy,
300
305
  deployDebug
301
306
  }) {
302
- __publicField(this, "codeBaseDir");
303
- __publicField(this, "envFilePath");
304
- __publicField(this, "distDir");
305
- __publicField(this, "dataJsonFile");
306
- __publicField(this, "injectFunction");
307
- __publicField(this, "$groups");
308
- __publicField(this, "previewAfterDeploy");
309
- __publicField(this, "deployDebug");
310
307
  this.codeBaseDir = codeBaseDir;
311
308
  this.envFilePath = envFilePath;
312
309
  this.distDir = distDir;
@@ -338,8 +335,8 @@ class FooterBuilder {
338
335
  const userMatch = config.match(/SY_DEPLOY_USER *= *([a-z\d]+)/);
339
336
  const keyMatch = config.match(/SY_DEPLOY_KEY *= *([a-z\d]+)/);
340
337
  return {
341
- user: ((userMatch == null ? void 0 : userMatch[1]) || "").trim(),
342
- key: ((keyMatch == null ? void 0 : keyMatch[1]) || "").trim()
338
+ user: (userMatch?.[1] || "").trim(),
339
+ key: (keyMatch?.[1] || "").trim()
343
340
  };
344
341
  }
345
342
  getAllTemplates() {
@@ -601,7 +598,7 @@ class FooterBuilder {
601
598
  res.end();
602
599
  return;
603
600
  }
604
- const err = await this.upload(data.deployTo, data.code, (user == null ? void 0 : user.user) || "", (user == null ? void 0 : user.key) || "");
601
+ const err = await this.upload(data.deployTo, data.code, user?.user || "", user?.key || "");
605
602
  res.writeHead(200, { "Content-Type": "text/plain", ...cosHeader });
606
603
  res.write(err ? `部署失败 ${err.message}` : `部署完毕 ${data.deployTo}`);
607
604
  res.end();
@@ -612,7 +609,7 @@ class FooterBuilder {
612
609
  const success = [];
613
610
  const failed = [];
614
611
  for (const data of buildResult) {
615
- const err = await this.upload(data.deployTo, data.code, (user == null ? void 0 : user.user) || "", (user == null ? void 0 : user.key) || "");
612
+ const err = await this.upload(data.deployTo, data.code, user?.user || "", user?.key || "");
616
613
  if (err) {
617
614
  failed.push(data.deployTo);
618
615
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seayoo-web/scripts",
3
- "version": "2.5.6",
3
+ "version": "2.6.0",
4
4
  "description": "scripts for seayoo web repos",
5
5
  "type": "module",
6
6
  "source": "index.ts",
@@ -34,42 +34,41 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@sentry/vite-plugin": "^3.3.1",
37
- "@vitejs/plugin-legacy": "^6.1.0",
38
- "@vitejs/plugin-vue": "^5.2.3",
37
+ "@vitejs/plugin-legacy": "^7.0.0",
38
+ "@vitejs/plugin-vue": "^6.0.0",
39
39
  "@vue/eslint-config-prettier": "^10.2.0",
40
40
  "@vue/eslint-config-typescript": "^14.5.0",
41
41
  "chokidar": "^4.0.3",
42
42
  "colors": "^1.4.0",
43
43
  "commander": "^13.1.0",
44
- "eslint-plugin-import": "^2.31.0",
44
+ "eslint-plugin-import": "^2.32.0",
45
45
  "eslint-plugin-vue": "^9.33.0",
46
46
  "fs-extra": "^11.3.0",
47
47
  "html-minifier-terser": "^7.2.0",
48
- "inquirer": "^12.5.2",
48
+ "inquirer": "^12.7.0",
49
49
  "jiti": "^2.4.2",
50
50
  "ora": "^8.2.0",
51
51
  "postcss-html": "^1.8.0",
52
- "rollup-plugin-visualizer": "^5.14.0",
53
- "terser": "^5.39.0",
54
- "vite-plugin-stylelint": "^6.0.0",
55
- "vite-plugin-vue-devtools": "^7.7.5",
52
+ "rollup-plugin-visualizer": "^6.0.3",
53
+ "terser": "^5.43.1",
54
+ "vite-plugin-stylelint": "^6.0.1",
56
55
  "@seayoo-web/finder": "^2.1.1"
57
56
  },
58
57
  "devDependencies": {
59
58
  "@types/fs-extra": "^11.0.4",
60
59
  "@types/html-minifier-terser": "^7.0.2",
61
60
  "@types/node": "^22.14.1",
62
- "@typescript-eslint/utils": "^8.30.1",
63
- "eslint": "^9.25.0",
64
- "stylelint": "^16.18.0",
65
- "stylelint-config-recess-order": "^6.0.0",
61
+ "@typescript-eslint/utils": "^8.35.1",
62
+ "eslint": "^9.30.1",
63
+ "stylelint": "^16.21.1",
64
+ "stylelint-config-recess-order": "^6.1.0",
66
65
  "stylelint-config-standard": "^37.0.0",
67
- "@seayoo-web/tsconfig": "^1.0.3"
66
+ "@seayoo-web/tsconfig": "^1.0.4"
68
67
  },
69
68
  "peerDependencies": {
70
- "eslint": "^9.19.0",
71
- "stylelint": "^16.14.1",
72
- "stylelint-config-recess-order": "^6.0.0",
69
+ "eslint": "^9.30.1",
70
+ "stylelint": "^16.21.1",
71
+ "stylelint-config-recess-order": "^6.1.0",
73
72
  "stylelint-config-standard": "^37.0.0"
74
73
  },
75
74
  "scripts": {
@@ -29,6 +29,6 @@ interface IBuildEnvs {
29
29
  /**
30
30
  * 获取构建环境配置
31
31
  */
32
- export declare function getBuildEnv(command: "serve" | "build", mode: string, onlyBuild?: boolean, requireSentryToken?: boolean, ignoreSentryToken?: boolean): IBuildEnvs;
32
+ export declare function getBuildEnv(command: "serve" | "build", mode: string, requireSentryToken?: boolean, ignoreSentryToken?: boolean): IBuildEnvs;
33
33
  export declare function transformEnvs(envs: Record<string, unknown>): Record<string, string>;
34
34
  export {};