custom-deploy 1.0.0 → 1.1.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.
- package/index.js +17 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -15,6 +15,17 @@ function getCurrentBranch() {
|
|
|
15
15
|
return execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
function getProjectName() {
|
|
19
|
+
const pkg = JSON.parse(fs.readFileSync(path.resolve('package.json'), 'utf8'));
|
|
20
|
+
return pkg.name;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getGitUser() {
|
|
24
|
+
const name = execSync('git config user.name').toString().trim();
|
|
25
|
+
const email = execSync('git config user.email').toString().trim();
|
|
26
|
+
return `${name} <${email}>`;
|
|
27
|
+
}
|
|
28
|
+
|
|
18
29
|
function getBuildCommand(branch) {
|
|
19
30
|
const upper = branch.toUpperCase();
|
|
20
31
|
|
|
@@ -24,11 +35,10 @@ function getBuildCommand(branch) {
|
|
|
24
35
|
throw new Error(`Unsupported branch: ${branch}`);
|
|
25
36
|
}
|
|
26
37
|
|
|
27
|
-
function getZipPath(branch) {
|
|
38
|
+
function getZipPath(branch, projectName) {
|
|
28
39
|
const upper = branch.toUpperCase();
|
|
29
40
|
|
|
30
|
-
if (upper === 'PROD') return path.resolve(
|
|
31
|
-
if (upper === 'DEV') return path.resolve('build-dev.zip');
|
|
41
|
+
if (upper === 'PROD' || upper === 'DEV') return path.resolve(`${projectName}-${branch.toLowerCase()}.zip`);
|
|
32
42
|
|
|
33
43
|
throw new Error(`Unsupported branch for zip: ${branch}`);
|
|
34
44
|
}
|
|
@@ -76,8 +86,10 @@ async function main() {
|
|
|
76
86
|
}
|
|
77
87
|
|
|
78
88
|
const branch = getCurrentBranch();
|
|
89
|
+
const projectName = getProjectName();
|
|
90
|
+
const sender = getGitUser();
|
|
79
91
|
const buildCommand = getBuildCommand(branch);
|
|
80
|
-
const zipPath = getZipPath(branch);
|
|
92
|
+
const zipPath = getZipPath(branch, projectName);
|
|
81
93
|
|
|
82
94
|
console.log(`Branch: ${branch}`);
|
|
83
95
|
|
|
@@ -89,7 +101,7 @@ async function main() {
|
|
|
89
101
|
|
|
90
102
|
await zipDist(zipPath);
|
|
91
103
|
|
|
92
|
-
await sendTelegramMessage(`✅ Build completed
|
|
104
|
+
await sendTelegramMessage(`✅ Build completed\nProject: ${projectName}\nBranch: ${branch}\nSent by: ${sender}`);
|
|
93
105
|
await sendTelegramFile(zipPath);
|
|
94
106
|
|
|
95
107
|
console.log(`Sent: ${zipPath}`);
|