@docupace/pipeline 1.0.5-alpha.17 → 1.0.5-alpha.20

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docupace/pipeline",
3
- "version": "1.0.5-alpha.17",
3
+ "version": "1.0.5-alpha.20",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -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,12 @@ program
155
168
 
156
169
  try {
157
170
  // Step 1: Get the current branch name
158
- const branchName = (await $`git branch --show-current`).stdout.trim();
171
+ const { stdout: branchStdout } = await run(`git branch --show-current`);
172
+ const branchName = branchStdout.trim();
159
173
  console.log(`Current branch: ${branchName}`);
160
174
 
161
- // Step 2: Extract Jira ticket number (e.g., matching JIRA-1234 pattern)
162
- const jiraTicketMatch = branchName.match(/([A-Z]+-\d+)/);
175
+ // Step 2: Extract Jira ticket number (e.g., JIRA-1234)
176
+ const jiraTicketMatch = branchName.match(/([A-Z]+-\\d+)/);
163
177
  if (!jiraTicketMatch) {
164
178
  throw new Error('No Jira ticket found in the branch name.');
165
179
  }
@@ -173,7 +187,9 @@ program
173
187
  const jiraUrl = `${jiraBaseUrl}/rest/api/2/issue/${jiraTicketId}`;
174
188
  const jiraResponse = await fetch(jiraUrl, {
175
189
  headers: {
176
- Authorization: `Basic ${Buffer.from(jiraFullApiKey).toString('base64')}`,
190
+ Authorization: `Basic ${Buffer.from(jiraFullApiKey).toString(
191
+ 'base64',
192
+ )}`,
177
193
  'Content-Type': 'application/json',
178
194
  },
179
195
  });
@@ -195,6 +211,7 @@ program
195
211
  `Generating release notes for ${jiraTicketId} - ${jiraSummary}`,
196
212
  );
197
213
 
214
+ // Step 4: Use OpenAI to generate release notes
198
215
  const openaiClient = new OpenAI({
199
216
  apiKey: process.env['OPENAI_API_KEY'],
200
217
  });
@@ -231,22 +248,23 @@ program
231
248
  console.log(`Change type: ${change_type}`);
232
249
  console.log(`Release note: ${summary}`);
233
250
 
234
- // Step 5: Create a changeset using pnpm
251
+ // Step 5: Create a changeset .md file
235
252
  const changesetContent = `---
236
253
  "${componentName}": ${change_type}
237
254
  ---
238
255
 
239
256
  ${summary} [${jiraTicketId}]
240
- `;
257
+ `;
241
258
  const changesetFile = `./.changeset/${jiraTicketId}.md`;
242
259
 
243
- await $`mkdir -p ./.changeset`;
260
+ await run(`mkdir -p ./.changeset`);
244
261
  await fs.promises.writeFile(changesetFile, changesetContent);
245
262
  console.log(`Created changeset file at ${changesetFile}`);
246
263
 
247
264
  console.log('Done!');
248
265
  } catch (err) {
249
266
  console.error(`Error: ${err.message}`);
267
+ process.exit(1);
250
268
  }
251
269
  });
252
270
 
@@ -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
- deployCore,
243
+ isDeployCore,
243
244
  ) {
244
- if (deployCore === 'true') {
245
+ if (isDeployCore === 'true') {
245
246
  const branchName = await getCoreBranchName(fromEnv, fromSite);
246
- await runPipeline('site-deploy', 'deploy-core', 'main', {
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