@taole/deploy-helper 1.1.4 → 1.1.5-beta.1
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/lib/project.mjs +20 -0
- package/package.json +1 -1
package/lib/project.mjs
CHANGED
|
@@ -8,6 +8,25 @@ import { getCache as getLoginCache } from "./login.mjs";
|
|
|
8
8
|
|
|
9
9
|
const isDev = false;
|
|
10
10
|
const apiHost = isDev ? "http://localhost:9000" : "https://fapi.tuwan.com";
|
|
11
|
+
const WEB_ACT_REPO_PATH = "69b3821af7b43e00d420cb32/Web-Act";
|
|
12
|
+
|
|
13
|
+
function extractWebActProjectNameFromRemote(remoteUrl) {
|
|
14
|
+
if (!remoteUrl) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const match = remoteUrl.match(new RegExp(`${WEB_ACT_REPO_PATH}/([^/.]+)(?:\\.git)?/?$`));
|
|
18
|
+
return match ? match[1] : null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function checkPackageNameWithGitRemote(git, packageName) {
|
|
22
|
+
const remotes = await git.getRemotes(true);
|
|
23
|
+
const remoteUrls = remotes.flatMap((remote) => [remote.refs.fetch, remote.refs.push]).filter(Boolean);
|
|
24
|
+
const gitProjectName = remoteUrls.map(extractWebActProjectNameFromRemote).find(Boolean);
|
|
25
|
+
|
|
26
|
+
if (gitProjectName && gitProjectName !== packageName) {
|
|
27
|
+
throw new Error(`项目名称不匹配: git仓库项目名称为${gitProjectName}, package.json name为${packageName}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
11
30
|
|
|
12
31
|
export function genArchive(outputPath, dir) {
|
|
13
32
|
return new Promise((resolve, reject) => {
|
|
@@ -240,6 +259,7 @@ export const cmdProjectPublish = async () => {
|
|
|
240
259
|
log("package.json或者其version字段或name字段不存在");
|
|
241
260
|
process.exit(1);
|
|
242
261
|
}
|
|
262
|
+
await checkPackageNameWithGitRemote(git, packageJson.name);
|
|
243
263
|
|
|
244
264
|
const newVersion = await apiGetProjectVersion(packageJson.name, userCache);
|
|
245
265
|
packageJson.version = newVersion;
|