@docupace/pipeline 1.0.77-alpha.3 → 1.0.77
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/.prettierrc.cjs +12 -12
- package/README.md +135 -135
- package/bin/azuread_update_callbacks_for_app.sh +58 -58
- package/bin/next-changeset-validate.sh +8 -8
- package/bitbucket-pipelines.yml +59 -59
- package/eslint.config.js +49 -49
- package/jest.config.js +15 -15
- package/next/changeset.sh +75 -75
- package/next/copy.sh +34 -34
- package/next/deploy.sh +40 -40
- package/next/execute.sh +123 -123
- package/next/sonar.sh +23 -23
- package/package.json +1 -1
- package/src/auth0/alias.js +79 -79
- package/src/auth0/alias.test.js +172 -172
- package/src/auth0/cli.js +82 -82
- package/src/auth0/configure.js +902 -902
- package/src/auth0/configure.test.js +167 -167
- package/src/auth0/export.js +48 -48
- package/src/auth0/export.test.js +103 -103
- package/src/auth0/metadata.js +141 -141
- package/src/auth0/metadata.test.js +186 -186
- package/src/auth0/vault.js +60 -60
- package/src/auth0/vault.test.js +134 -134
- package/src/changeset/changelog-wiki.js +328 -328
- package/src/changeset/changeset-config.js +34 -34
- package/src/changeset/cli.js +237 -237
- package/src/changeset/create.js +215 -215
- package/src/changeset/package-util.js +87 -87
- package/src/changeset/util.js +43 -43
- package/src/changeset/validate.js +91 -91
- package/src/changeset/version.js +102 -102
- package/src/jenkins/setParams.groovy +58 -58
- package/src/lib/merge-driver.js +204 -204
- package/src/merge/cli-merge-all.js +507 -507
- package/src/merge/cli-merge.js +492 -492
- package/src/merge/cli-resolve.js +399 -399
- package/src/merge/cli.js +38 -38
- package/src/merge/merge-changelog.js +87 -87
- package/src/merge/merge-package.js +106 -106
- package/src/merge/merge-types.js +82 -82
- package/src/merge/pr.js +231 -231
- package/src/micro/cli.js +71 -0
- package/src/micro/ms-deploy.js +271 -0
- package/src/micro/{publish-ms.js → ms-publish.js} +6 -8
- package/src/next/alias.js +53 -53
- package/src/next/apache.js +81 -81
- package/src/next/cli.js +1 -10
- package/src/next/config.js +137 -137
- package/src/next/connect.js +226 -226
- package/src/next/copy.js +61 -61
- package/src/next/deploy.js +633 -633
- package/src/next/git-to-semver.js +79 -79
- package/src/next/haproxy.js +76 -76
- package/src/next/jenkins.js +123 -123
- package/src/next/jira.js +84 -84
- package/src/next/logger.js +17 -17
- package/src/next/pipline.js +114 -114
- package/src/next/publish.js +71 -71
- package/src/next/pull.js +7 -7
- package/src/next/sonar.js +23 -23
- package/src/next/test.js +5 -5
- package/src/next/util.js +93 -95
- package/src/next/vault.js +45 -45
- package/terraform/apply.sh +37 -37
- package/terraform/init.sh +72 -72
- package/terraform/plan.sh +76 -76
- package/terraform/validate.sh +17 -17
- package/src/micro/deploy-microservice.js +0 -153
package/src/merge/pr.js
CHANGED
|
@@ -1,231 +1,231 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create a Bitbucket pull request
|
|
3
|
-
* @param {string} sourceBranch - Source branch name
|
|
4
|
-
* @param {string} targetBranch - Target branch name
|
|
5
|
-
* @param {string} title - PR title
|
|
6
|
-
* @param {string} description - PR description
|
|
7
|
-
* @returns {Promise<Object>} - PR creation result
|
|
8
|
-
*/
|
|
9
|
-
import { execSync } from 'child_process';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Check for existing pull requests with specific description pattern
|
|
13
|
-
* @param {string} descriptionPattern - Pattern to match in PR descriptions
|
|
14
|
-
* @returns {Promise<Object[]>} - Array of matching PRs
|
|
15
|
-
*/
|
|
16
|
-
export async function getExistingPRsWithDescription(
|
|
17
|
-
descriptionPattern,
|
|
18
|
-
repositories,
|
|
19
|
-
) {
|
|
20
|
-
// If no repositories provided, fall back to current repo behavior for backward compatibility
|
|
21
|
-
if (!repositories || !Array.isArray(repositories)) {
|
|
22
|
-
return getExistingPRsFromCurrentRepo(descriptionPattern);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
// Check for Bitbucket credentials
|
|
27
|
-
const username = process.env.BITBUCKET_USERNAME;
|
|
28
|
-
const password = process.env.BITBUCKET_APP_PASSWORD;
|
|
29
|
-
|
|
30
|
-
if (!username || !password) {
|
|
31
|
-
console.log(
|
|
32
|
-
`\n⚠️ Bitbucket credentials not found. Cannot check existing PRs.`,
|
|
33
|
-
);
|
|
34
|
-
return [];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const auth = Buffer.from(`${username}:${password}`).toString('base64');
|
|
38
|
-
const allMatchingPRs = [];
|
|
39
|
-
|
|
40
|
-
// Check each repository for matching PRs
|
|
41
|
-
for (const repo of repositories) {
|
|
42
|
-
try {
|
|
43
|
-
const match = repo.url.match(/bitbucket\.org[\/:]([^\/]+)\/([^\/\.]+)/);
|
|
44
|
-
|
|
45
|
-
if (!match) {
|
|
46
|
-
console.warn(`Could not parse repository URL: ${repo.url}`);
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const [, workspace, repoSlug] = match;
|
|
51
|
-
|
|
52
|
-
const response = await fetch(
|
|
53
|
-
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repoSlug}/pullrequests?state=OPEN`,
|
|
54
|
-
{
|
|
55
|
-
method: 'GET',
|
|
56
|
-
headers: {
|
|
57
|
-
Authorization: `Basic ${auth}`,
|
|
58
|
-
'Content-Type': 'application/json',
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
if (!response.ok) {
|
|
64
|
-
const error = await response.text();
|
|
65
|
-
console.warn(
|
|
66
|
-
`Bitbucket API error for ${repo.name}: ${response.status} - ${error}`,
|
|
67
|
-
);
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const data = await response.json();
|
|
72
|
-
const matchingPRs = data.values.filter(
|
|
73
|
-
(pr) =>
|
|
74
|
-
pr.description && pr.description.startsWith(descriptionPattern),
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
// Add repository info to each PR for context
|
|
78
|
-
matchingPRs.forEach((pr) => {
|
|
79
|
-
pr.repositoryName = repo.name;
|
|
80
|
-
pr.repositoryUrl = repo.url;
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
allMatchingPRs.push(...matchingPRs);
|
|
84
|
-
} catch (error) {
|
|
85
|
-
console.warn(
|
|
86
|
-
`Failed to check PRs for repository ${repo.name}: ${error.message}`,
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return allMatchingPRs;
|
|
92
|
-
} catch (error) {
|
|
93
|
-
console.error(`Failed to get existing PRs: ${error.message}`);
|
|
94
|
-
return [];
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Legacy function for backward compatibility - checks PRs in current repo only
|
|
100
|
-
*/
|
|
101
|
-
export async function getExistingPRsFromCurrentRepo(descriptionPattern) {
|
|
102
|
-
try {
|
|
103
|
-
// Get Bitbucket workspace and repo from git remote
|
|
104
|
-
const remoteUrl = execSync('git config --get remote.origin.url', {
|
|
105
|
-
encoding: 'utf-8',
|
|
106
|
-
}).trim();
|
|
107
|
-
const match = remoteUrl.match(/bitbucket\.org[\/:]([^\/]+)\/([^\/\.]+)/);
|
|
108
|
-
|
|
109
|
-
if (!match) {
|
|
110
|
-
throw new Error(
|
|
111
|
-
'Could not parse Bitbucket workspace and repository from remote URL',
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const [, workspace, repoSlug] = match;
|
|
116
|
-
|
|
117
|
-
// Check for Bitbucket credentials
|
|
118
|
-
const username = process.env.BITBUCKET_USERNAME;
|
|
119
|
-
const password = process.env.BITBUCKET_APP_PASSWORD;
|
|
120
|
-
|
|
121
|
-
if (!username || !password) {
|
|
122
|
-
console.log(
|
|
123
|
-
`\n⚠️ Bitbucket credentials not found. Cannot check existing PRs.`,
|
|
124
|
-
);
|
|
125
|
-
return [];
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const auth = Buffer.from(`${username}:${password}`).toString('base64');
|
|
129
|
-
const response = await fetch(
|
|
130
|
-
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repoSlug}/pullrequests?state=OPEN`,
|
|
131
|
-
{
|
|
132
|
-
method: 'GET',
|
|
133
|
-
headers: {
|
|
134
|
-
Authorization: `Basic ${auth}`,
|
|
135
|
-
'Content-Type': 'application/json',
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
if (!response.ok) {
|
|
141
|
-
const error = await response.text();
|
|
142
|
-
throw new Error(`Bitbucket API error: ${response.status} - ${error}`);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const data = await response.json();
|
|
146
|
-
const matchingPRs = data.values.filter(
|
|
147
|
-
(pr) => pr.description && pr.description.startsWith(descriptionPattern),
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
return matchingPRs;
|
|
151
|
-
} catch (error) {
|
|
152
|
-
console.error(`Failed to get existing PRs: ${error.message}`);
|
|
153
|
-
return [];
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export async function createBitbucketPR(
|
|
158
|
-
sourceBranch,
|
|
159
|
-
targetBranch,
|
|
160
|
-
title,
|
|
161
|
-
description,
|
|
162
|
-
) {
|
|
163
|
-
try {
|
|
164
|
-
// Get Bitbucket workspace and repo from git remote
|
|
165
|
-
const remoteUrl = execSync('git config --get remote.origin.url', {
|
|
166
|
-
encoding: 'utf-8',
|
|
167
|
-
}).trim();
|
|
168
|
-
const match = remoteUrl.match(/bitbucket\.org[\/:]([^\/]+)\/([^\/\.]+)/);
|
|
169
|
-
|
|
170
|
-
if (!match) {
|
|
171
|
-
throw new Error(
|
|
172
|
-
'Could not parse Bitbucket workspace and repository from remote URL',
|
|
173
|
-
);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const [, workspace, repoSlug] = match;
|
|
177
|
-
|
|
178
|
-
// Check for Bitbucket credentials
|
|
179
|
-
const username = process.env.BITBUCKET_USERNAME;
|
|
180
|
-
const password = process.env.BITBUCKET_APP_PASSWORD;
|
|
181
|
-
|
|
182
|
-
if (!username || !password) {
|
|
183
|
-
console.log(
|
|
184
|
-
`\n⚠️ Bitbucket credentials not found in environment variables.`,
|
|
185
|
-
);
|
|
186
|
-
console.log(
|
|
187
|
-
'Please set BITBUCKET_USERNAME and BITBUCKET_APP_PASSWORD to auto-create PR.',
|
|
188
|
-
);
|
|
189
|
-
console.log(
|
|
190
|
-
`Manual PR creation URL: https://bitbucket.org/${workspace}/${repoSlug}/pull-requests/new?source=${sourceBranch}&dest=${targetBranch}`,
|
|
191
|
-
);
|
|
192
|
-
return {
|
|
193
|
-
success: false,
|
|
194
|
-
manual: true,
|
|
195
|
-
url: `https://bitbucket.org/${workspace}/${repoSlug}/pull-requests/new?source=${sourceBranch}&dest=${targetBranch}`,
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// Create PR via Bitbucket API
|
|
200
|
-
const prData = {
|
|
201
|
-
title,
|
|
202
|
-
description,
|
|
203
|
-
source: { branch: { name: sourceBranch } },
|
|
204
|
-
destination: { branch: { name: targetBranch } },
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const auth = Buffer.from(`${username}:${password}`).toString('base64');
|
|
208
|
-
const response = await fetch(
|
|
209
|
-
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repoSlug}/pullrequests`,
|
|
210
|
-
{
|
|
211
|
-
method: 'POST',
|
|
212
|
-
headers: {
|
|
213
|
-
Authorization: `Basic ${auth}`,
|
|
214
|
-
'Content-Type': 'application/json',
|
|
215
|
-
},
|
|
216
|
-
body: JSON.stringify(prData),
|
|
217
|
-
},
|
|
218
|
-
);
|
|
219
|
-
|
|
220
|
-
if (!response.ok) {
|
|
221
|
-
const error = await response.text();
|
|
222
|
-
throw new Error(`Bitbucket API error: ${response.status} - ${error}`);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
const pr = await response.json();
|
|
226
|
-
return { success: true, pr, url: pr.links.html.href };
|
|
227
|
-
} catch (error) {
|
|
228
|
-
console.error(`Failed to create Bitbucket PR: ${error.message}`);
|
|
229
|
-
return { success: false, error: error.message };
|
|
230
|
-
}
|
|
231
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Create a Bitbucket pull request
|
|
3
|
+
* @param {string} sourceBranch - Source branch name
|
|
4
|
+
* @param {string} targetBranch - Target branch name
|
|
5
|
+
* @param {string} title - PR title
|
|
6
|
+
* @param {string} description - PR description
|
|
7
|
+
* @returns {Promise<Object>} - PR creation result
|
|
8
|
+
*/
|
|
9
|
+
import { execSync } from 'child_process';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Check for existing pull requests with specific description pattern
|
|
13
|
+
* @param {string} descriptionPattern - Pattern to match in PR descriptions
|
|
14
|
+
* @returns {Promise<Object[]>} - Array of matching PRs
|
|
15
|
+
*/
|
|
16
|
+
export async function getExistingPRsWithDescription(
|
|
17
|
+
descriptionPattern,
|
|
18
|
+
repositories,
|
|
19
|
+
) {
|
|
20
|
+
// If no repositories provided, fall back to current repo behavior for backward compatibility
|
|
21
|
+
if (!repositories || !Array.isArray(repositories)) {
|
|
22
|
+
return getExistingPRsFromCurrentRepo(descriptionPattern);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
// Check for Bitbucket credentials
|
|
27
|
+
const username = process.env.BITBUCKET_USERNAME;
|
|
28
|
+
const password = process.env.BITBUCKET_APP_PASSWORD;
|
|
29
|
+
|
|
30
|
+
if (!username || !password) {
|
|
31
|
+
console.log(
|
|
32
|
+
`\n⚠️ Bitbucket credentials not found. Cannot check existing PRs.`,
|
|
33
|
+
);
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const auth = Buffer.from(`${username}:${password}`).toString('base64');
|
|
38
|
+
const allMatchingPRs = [];
|
|
39
|
+
|
|
40
|
+
// Check each repository for matching PRs
|
|
41
|
+
for (const repo of repositories) {
|
|
42
|
+
try {
|
|
43
|
+
const match = repo.url.match(/bitbucket\.org[\/:]([^\/]+)\/([^\/\.]+)/);
|
|
44
|
+
|
|
45
|
+
if (!match) {
|
|
46
|
+
console.warn(`Could not parse repository URL: ${repo.url}`);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const [, workspace, repoSlug] = match;
|
|
51
|
+
|
|
52
|
+
const response = await fetch(
|
|
53
|
+
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repoSlug}/pullrequests?state=OPEN`,
|
|
54
|
+
{
|
|
55
|
+
method: 'GET',
|
|
56
|
+
headers: {
|
|
57
|
+
Authorization: `Basic ${auth}`,
|
|
58
|
+
'Content-Type': 'application/json',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
if (!response.ok) {
|
|
64
|
+
const error = await response.text();
|
|
65
|
+
console.warn(
|
|
66
|
+
`Bitbucket API error for ${repo.name}: ${response.status} - ${error}`,
|
|
67
|
+
);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const data = await response.json();
|
|
72
|
+
const matchingPRs = data.values.filter(
|
|
73
|
+
(pr) =>
|
|
74
|
+
pr.description && pr.description.startsWith(descriptionPattern),
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
// Add repository info to each PR for context
|
|
78
|
+
matchingPRs.forEach((pr) => {
|
|
79
|
+
pr.repositoryName = repo.name;
|
|
80
|
+
pr.repositoryUrl = repo.url;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
allMatchingPRs.push(...matchingPRs);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.warn(
|
|
86
|
+
`Failed to check PRs for repository ${repo.name}: ${error.message}`,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return allMatchingPRs;
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.error(`Failed to get existing PRs: ${error.message}`);
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Legacy function for backward compatibility - checks PRs in current repo only
|
|
100
|
+
*/
|
|
101
|
+
export async function getExistingPRsFromCurrentRepo(descriptionPattern) {
|
|
102
|
+
try {
|
|
103
|
+
// Get Bitbucket workspace and repo from git remote
|
|
104
|
+
const remoteUrl = execSync('git config --get remote.origin.url', {
|
|
105
|
+
encoding: 'utf-8',
|
|
106
|
+
}).trim();
|
|
107
|
+
const match = remoteUrl.match(/bitbucket\.org[\/:]([^\/]+)\/([^\/\.]+)/);
|
|
108
|
+
|
|
109
|
+
if (!match) {
|
|
110
|
+
throw new Error(
|
|
111
|
+
'Could not parse Bitbucket workspace and repository from remote URL',
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const [, workspace, repoSlug] = match;
|
|
116
|
+
|
|
117
|
+
// Check for Bitbucket credentials
|
|
118
|
+
const username = process.env.BITBUCKET_USERNAME;
|
|
119
|
+
const password = process.env.BITBUCKET_APP_PASSWORD;
|
|
120
|
+
|
|
121
|
+
if (!username || !password) {
|
|
122
|
+
console.log(
|
|
123
|
+
`\n⚠️ Bitbucket credentials not found. Cannot check existing PRs.`,
|
|
124
|
+
);
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const auth = Buffer.from(`${username}:${password}`).toString('base64');
|
|
129
|
+
const response = await fetch(
|
|
130
|
+
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repoSlug}/pullrequests?state=OPEN`,
|
|
131
|
+
{
|
|
132
|
+
method: 'GET',
|
|
133
|
+
headers: {
|
|
134
|
+
Authorization: `Basic ${auth}`,
|
|
135
|
+
'Content-Type': 'application/json',
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
if (!response.ok) {
|
|
141
|
+
const error = await response.text();
|
|
142
|
+
throw new Error(`Bitbucket API error: ${response.status} - ${error}`);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const data = await response.json();
|
|
146
|
+
const matchingPRs = data.values.filter(
|
|
147
|
+
(pr) => pr.description && pr.description.startsWith(descriptionPattern),
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
return matchingPRs;
|
|
151
|
+
} catch (error) {
|
|
152
|
+
console.error(`Failed to get existing PRs: ${error.message}`);
|
|
153
|
+
return [];
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export async function createBitbucketPR(
|
|
158
|
+
sourceBranch,
|
|
159
|
+
targetBranch,
|
|
160
|
+
title,
|
|
161
|
+
description,
|
|
162
|
+
) {
|
|
163
|
+
try {
|
|
164
|
+
// Get Bitbucket workspace and repo from git remote
|
|
165
|
+
const remoteUrl = execSync('git config --get remote.origin.url', {
|
|
166
|
+
encoding: 'utf-8',
|
|
167
|
+
}).trim();
|
|
168
|
+
const match = remoteUrl.match(/bitbucket\.org[\/:]([^\/]+)\/([^\/\.]+)/);
|
|
169
|
+
|
|
170
|
+
if (!match) {
|
|
171
|
+
throw new Error(
|
|
172
|
+
'Could not parse Bitbucket workspace and repository from remote URL',
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const [, workspace, repoSlug] = match;
|
|
177
|
+
|
|
178
|
+
// Check for Bitbucket credentials
|
|
179
|
+
const username = process.env.BITBUCKET_USERNAME;
|
|
180
|
+
const password = process.env.BITBUCKET_APP_PASSWORD;
|
|
181
|
+
|
|
182
|
+
if (!username || !password) {
|
|
183
|
+
console.log(
|
|
184
|
+
`\n⚠️ Bitbucket credentials not found in environment variables.`,
|
|
185
|
+
);
|
|
186
|
+
console.log(
|
|
187
|
+
'Please set BITBUCKET_USERNAME and BITBUCKET_APP_PASSWORD to auto-create PR.',
|
|
188
|
+
);
|
|
189
|
+
console.log(
|
|
190
|
+
`Manual PR creation URL: https://bitbucket.org/${workspace}/${repoSlug}/pull-requests/new?source=${sourceBranch}&dest=${targetBranch}`,
|
|
191
|
+
);
|
|
192
|
+
return {
|
|
193
|
+
success: false,
|
|
194
|
+
manual: true,
|
|
195
|
+
url: `https://bitbucket.org/${workspace}/${repoSlug}/pull-requests/new?source=${sourceBranch}&dest=${targetBranch}`,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Create PR via Bitbucket API
|
|
200
|
+
const prData = {
|
|
201
|
+
title,
|
|
202
|
+
description,
|
|
203
|
+
source: { branch: { name: sourceBranch } },
|
|
204
|
+
destination: { branch: { name: targetBranch } },
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
const auth = Buffer.from(`${username}:${password}`).toString('base64');
|
|
208
|
+
const response = await fetch(
|
|
209
|
+
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repoSlug}/pullrequests`,
|
|
210
|
+
{
|
|
211
|
+
method: 'POST',
|
|
212
|
+
headers: {
|
|
213
|
+
Authorization: `Basic ${auth}`,
|
|
214
|
+
'Content-Type': 'application/json',
|
|
215
|
+
},
|
|
216
|
+
body: JSON.stringify(prData),
|
|
217
|
+
},
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
if (!response.ok) {
|
|
221
|
+
const error = await response.text();
|
|
222
|
+
throw new Error(`Bitbucket API error: ${response.status} - ${error}`);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const pr = await response.json();
|
|
226
|
+
return { success: true, pr, url: pr.links.html.href };
|
|
227
|
+
} catch (error) {
|
|
228
|
+
console.error(`Failed to create Bitbucket PR: ${error.message}`);
|
|
229
|
+
return { success: false, error: error.message };
|
|
230
|
+
}
|
|
231
|
+
}
|
package/src/micro/cli.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { publishMicroservice } from './ms-publish.js';
|
|
5
|
+
|
|
6
|
+
import dotenv from 'dotenv';
|
|
7
|
+
import {
|
|
8
|
+
deployMicroserviceEndToEnd,
|
|
9
|
+
promoteMicroserviceImage,
|
|
10
|
+
testMicroserviceDeploy,
|
|
11
|
+
testMicroservicePublish,
|
|
12
|
+
} from './ms-deploy.js';
|
|
13
|
+
|
|
14
|
+
dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
|
|
15
|
+
|
|
16
|
+
const program = new Command();
|
|
17
|
+
|
|
18
|
+
//const GIT_SHA = (await $`git log --pretty=format:'%h' -n 1`).stdout.trim();
|
|
19
|
+
|
|
20
|
+
// Add the new publish-microservice command
|
|
21
|
+
program
|
|
22
|
+
.command('publish-microservice <serviceName>')
|
|
23
|
+
.description('Publish a microservice Docker image with version tags')
|
|
24
|
+
.option('-t, --tag <tag>', 'Version tag (defaults to BITBUCKET_TAG)')
|
|
25
|
+
.action(async (serviceName, options) => {
|
|
26
|
+
await publishMicroservice(serviceName, options);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
program
|
|
30
|
+
.command('deploy-microservice <serviceName>')
|
|
31
|
+
.description('Deploy microservice end-to-end (build + publish + deploy)')
|
|
32
|
+
.option('-e, --env <environment>', 'Target environment', 'dev')
|
|
33
|
+
.option('-t, --tag <tag>', 'Version tag (defaults to BITBUCKET_TAG)')
|
|
34
|
+
.action(async (serviceName, options) => {
|
|
35
|
+
await deployMicroserviceEndToEnd(serviceName, options.env, options.tag);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
program
|
|
39
|
+
.command('promote-microservice <serviceName>')
|
|
40
|
+
.description('Promote microservice image between environments')
|
|
41
|
+
.requiredOption('-f, --from <fromEnv>', 'Source environment')
|
|
42
|
+
.requiredOption('-t, --to <toEnv>', 'Target environment')
|
|
43
|
+
.requiredOption('-g, --tag <tag>', 'Image tag to promote')
|
|
44
|
+
.action(async (serviceName, options) => {
|
|
45
|
+
await promoteMicroserviceImage(
|
|
46
|
+
serviceName,
|
|
47
|
+
options.from,
|
|
48
|
+
options.to,
|
|
49
|
+
options.tag,
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
program
|
|
54
|
+
.command('test-deploy-microservice <serviceName>')
|
|
55
|
+
.description('Test microservice deployment only (no image building)')
|
|
56
|
+
.option('-e, --env <environment>', 'Target environment', 'dev')
|
|
57
|
+
.option('-t, --tag <tag>', 'Version tag', 'v0.1.0')
|
|
58
|
+
.action(async (serviceName, options) => {
|
|
59
|
+
await testMicroserviceDeploy(serviceName, options.env, options.tag);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
program
|
|
63
|
+
.command('test-publish-microservice <serviceName>')
|
|
64
|
+
.description(
|
|
65
|
+
'Test microservice Docker build and publish only (no deployment)',
|
|
66
|
+
)
|
|
67
|
+
.action(async (serviceName) => {
|
|
68
|
+
await testMicroservicePublish(serviceName);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
program.parse(process.argv);
|