@docupace/pipeline 1.0.5-alpha.17 → 1.0.5-alpha.19
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/package.json +1 -1
- package/src/changeset/cli.js +26 -7
- package/src/next/deploy.js +8 -4
package/package.json
CHANGED
package/src/changeset/cli.js
CHANGED
|
@@ -9,6 +9,7 @@ import { zodResponseFormat } from 'openai/helpers/zod';
|
|
|
9
9
|
import z from 'zod';
|
|
10
10
|
import dotenv from 'dotenv';
|
|
11
11
|
dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
|
|
12
|
+
import { exec } from 'child_process';
|
|
12
13
|
|
|
13
14
|
const program = new Command();
|
|
14
15
|
|
|
@@ -16,6 +17,18 @@ const args = process.argv;
|
|
|
16
17
|
|
|
17
18
|
const DIR = path.resolve(process.cwd());
|
|
18
19
|
|
|
20
|
+
function run(command) {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
exec(command, { shell: true }, (error, stdout, stderr) => {
|
|
23
|
+
if (error) {
|
|
24
|
+
reject(error);
|
|
25
|
+
} else {
|
|
26
|
+
resolve({ stdout, stderr });
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
19
32
|
async function fileExists(filePath) {
|
|
20
33
|
try {
|
|
21
34
|
await fs.promises.access(filePath);
|
|
@@ -155,11 +168,13 @@ program
|
|
|
155
168
|
|
|
156
169
|
try {
|
|
157
170
|
// Step 1: Get the current branch name
|
|
158
|
-
|
|
171
|
+
console.log('Before');
|
|
172
|
+
const { stdout: branchStdout } = await run(`git branch --show-current`);
|
|
173
|
+
const branchName = branchStdout.trim();
|
|
159
174
|
console.log(`Current branch: ${branchName}`);
|
|
160
175
|
|
|
161
|
-
// Step 2: Extract Jira ticket number (e.g.,
|
|
162
|
-
const jiraTicketMatch = branchName.match(/([A-Z]
|
|
176
|
+
// Step 2: Extract Jira ticket number (e.g., JIRA-1234)
|
|
177
|
+
const jiraTicketMatch = branchName.match(/([A-Z]+-\\d+)/);
|
|
163
178
|
if (!jiraTicketMatch) {
|
|
164
179
|
throw new Error('No Jira ticket found in the branch name.');
|
|
165
180
|
}
|
|
@@ -173,7 +188,9 @@ program
|
|
|
173
188
|
const jiraUrl = `${jiraBaseUrl}/rest/api/2/issue/${jiraTicketId}`;
|
|
174
189
|
const jiraResponse = await fetch(jiraUrl, {
|
|
175
190
|
headers: {
|
|
176
|
-
Authorization: `Basic ${Buffer.from(jiraFullApiKey).toString(
|
|
191
|
+
Authorization: `Basic ${Buffer.from(jiraFullApiKey).toString(
|
|
192
|
+
'base64',
|
|
193
|
+
)}`,
|
|
177
194
|
'Content-Type': 'application/json',
|
|
178
195
|
},
|
|
179
196
|
});
|
|
@@ -195,6 +212,7 @@ program
|
|
|
195
212
|
`Generating release notes for ${jiraTicketId} - ${jiraSummary}`,
|
|
196
213
|
);
|
|
197
214
|
|
|
215
|
+
// Step 4: Use OpenAI to generate release notes
|
|
198
216
|
const openaiClient = new OpenAI({
|
|
199
217
|
apiKey: process.env['OPENAI_API_KEY'],
|
|
200
218
|
});
|
|
@@ -231,22 +249,23 @@ program
|
|
|
231
249
|
console.log(`Change type: ${change_type}`);
|
|
232
250
|
console.log(`Release note: ${summary}`);
|
|
233
251
|
|
|
234
|
-
// Step 5: Create a changeset
|
|
252
|
+
// Step 5: Create a changeset .md file
|
|
235
253
|
const changesetContent = `---
|
|
236
254
|
"${componentName}": ${change_type}
|
|
237
255
|
---
|
|
238
256
|
|
|
239
257
|
${summary} [${jiraTicketId}]
|
|
240
|
-
|
|
258
|
+
`;
|
|
241
259
|
const changesetFile = `./.changeset/${jiraTicketId}.md`;
|
|
242
260
|
|
|
243
|
-
await
|
|
261
|
+
await run(`mkdir -p ./.changeset`);
|
|
244
262
|
await fs.promises.writeFile(changesetFile, changesetContent);
|
|
245
263
|
console.log(`Created changeset file at ${changesetFile}`);
|
|
246
264
|
|
|
247
265
|
console.log('Done!');
|
|
248
266
|
} catch (err) {
|
|
249
267
|
console.error(`Error: ${err.message}`);
|
|
268
|
+
process.exit(1);
|
|
250
269
|
}
|
|
251
270
|
});
|
|
252
271
|
|
package/src/next/deploy.js
CHANGED
|
@@ -7,6 +7,7 @@ import { appInfo, environmentConfig, getRepUrl } from './config.js';
|
|
|
7
7
|
import { copy } from './copy.js';
|
|
8
8
|
import axios from 'axios';
|
|
9
9
|
import { runPipeline } from './pipline.js';
|
|
10
|
+
import { deployCore } from './jenkins.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Clone the repository, read the YAML file, and return the parsed data and file paths.
|
|
@@ -239,16 +240,19 @@ export async function deployFromSite(
|
|
|
239
240
|
fromSite,
|
|
240
241
|
toEnv,
|
|
241
242
|
toSite,
|
|
242
|
-
|
|
243
|
+
isDeployCore,
|
|
243
244
|
) {
|
|
244
|
-
if (
|
|
245
|
+
if (isDeployCore === 'true') {
|
|
245
246
|
const branchName = await getCoreBranchName(fromEnv, fromSite);
|
|
246
|
-
await
|
|
247
|
+
await deployCore(toEnv, toSite, 'true', branchName);
|
|
248
|
+
|
|
249
|
+
// To be added back when splitting between on prem and in cloud
|
|
250
|
+
/*await runPipeline('site-deploy', 'deploy-core', 'main', {
|
|
247
251
|
ENV: toEnv,
|
|
248
252
|
SITE: toSite,
|
|
249
253
|
LIQUIBASE: 'true',
|
|
250
254
|
BRANCH: branchName,
|
|
251
|
-
})
|
|
255
|
+
});*/
|
|
252
256
|
}
|
|
253
257
|
|
|
254
258
|
// Clone repositories for source and target environments
|