@docupace/pipeline 1.0.82 → 1.0.83

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/README.md CHANGED
@@ -133,4 +133,4 @@ dp-auth0-cli configureFromSite sourceSite targetSite dev prod true true true fal
133
133
 
134
134
  ## License
135
135
 
136
- ISC
136
+ ISC
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docupace/pipeline",
3
- "version": "1.0.82",
3
+ "version": "1.0.83",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "bin": {
@@ -3,6 +3,7 @@ import { readFileSync, existsSync, mkdirSync } from 'fs';
3
3
  import { join, dirname } from 'path';
4
4
  import { fileURLToPath } from 'url';
5
5
  import { getExistingPRsWithDescription } from './pr.js';
6
+ import { BuildResults } from './common.js';
6
7
 
7
8
  const __dirname = dirname(fileURLToPath(import.meta.url));
8
9
 
@@ -214,18 +215,22 @@ async function runPreparePhase(
214
215
 
215
216
  // Log result based on exit code
216
217
  switch (result.exitCode) {
217
- case 0:
218
+ case BuildResults.success:
218
219
  console.log(`✅ ${configName}: Merge and build successful`);
219
220
  break;
220
- case 2:
221
+ case BuildResults.unresolvedConflicts:
221
222
  console.log(`⚠️ ${configName}: Merge has unresolved conflicts`);
222
223
  break;
223
- case 3:
224
+ case BuildResults.buildFailed:
224
225
  console.log(`⚠️ ${configName}: Build failed`);
225
226
  break;
226
- case 4:
227
+ case BuildResults.noChanges:
227
228
  console.log(`✅ ${configName}: No Changes`);
228
229
  break;
230
+ case BuildResults.changeLogsExist:
231
+ console.log(`❌ Stopping Merge`);
232
+ process.exit(1);
233
+ break;
229
234
  default:
230
235
  console.log(
231
236
  `❌ ${configName}: Unknown error (exit code: ${result.exitCode})`,
@@ -428,6 +433,15 @@ async function mergeAll(verbose = false) {
428
433
  verbose,
429
434
  );
430
435
 
436
+ if (
437
+ branchResult.success &&
438
+ branchResult.summary.successes > 0 &&
439
+ i < config.mergeBranches.length - 1
440
+ ) {
441
+ console.log('Pausing before next merge');
442
+ await new Promise((res) => setTimeout(res, 90000));
443
+ }
444
+
431
445
  if (!branchResult.success) {
432
446
  console.log(`Exiting due to failure of one or more merges`);
433
447
  process.exit(1);
@@ -3,6 +3,7 @@ import { createBitbucketPR } from './pr.js';
3
3
  import { autoResolveConflicts } from './cli-resolve.js';
4
4
  import { getPackageNames } from '../changeset/package-util.js';
5
5
  import { writeChangesetFile } from '../changeset/create.js';
6
+ import { BuildResults } from './common.js';
6
7
 
7
8
  /**
8
9
  * Create and checkout merge branch from target branch
@@ -216,9 +217,27 @@ function mergeIntoTarget(
216
217
  stdio: verbose ? 'inherit' : 'pipe',
217
218
  });
218
219
 
219
- execSync(`git branch -d ${mergeBranchName}`, {
220
- stdio: verbose ? 'inherit' : 'pipe',
221
- });
220
+ // Delete local merge branch
221
+ try {
222
+ execSync(`git branch -d ${mergeBranchName}`, {
223
+ stdio: 'pipe',
224
+ });
225
+ if (verbose)
226
+ console.log(`🗑️ Deleted local merge branch: ${mergeBranchName}`);
227
+ } catch {
228
+ // Branch doesn't exist, which is fine
229
+ }
230
+
231
+ // Delete remote merge branch
232
+ try {
233
+ execSync(`git push origin --delete ${mergeBranchName}`, {
234
+ stdio: 'pipe',
235
+ });
236
+ if (verbose)
237
+ console.log(`🗑️ Deleted remote merge branch: ${mergeBranchName}`);
238
+ } catch (e) {
239
+ console.error('Failed to delete remote branch', e);
240
+ }
222
241
 
223
242
  if (verbose) console.log(`✅ Successfully merged into ${targetBranch}`);
224
243
  } else {
@@ -269,6 +288,62 @@ function cleanupFailedMerge(verbose = false) {
269
288
  }
270
289
  }
271
290
 
291
+ /**
292
+ * Check if source branch has uncommitted changesets
293
+ */
294
+ function checkForUncommittedChangesets(sourceBranch, verbose = false) {
295
+ if (verbose)
296
+ console.log(`🔍 Checking for uncommitted changesets in ${sourceBranch}`);
297
+
298
+ // Store current branch
299
+ const currentBranch = execSync('git branch --show-current', {
300
+ encoding: 'utf8',
301
+ stdio: 'pipe',
302
+ }).trim();
303
+
304
+ try {
305
+ // Checkout source branch
306
+
307
+ execSync(`git checkout ${sourceBranch}`, {
308
+ stdio: 'pipe',
309
+ });
310
+
311
+ execSync(`git pull`, {
312
+ stdio: verbose ? 'inherit' : 'pipe',
313
+ });
314
+
315
+ // Check for .md files in .changeset directory (excluding README.md)
316
+ try {
317
+ const changesetFiles = execSync(
318
+ 'find .changeset -name "*.md" -not -name "README.md" 2>/dev/null | head -1',
319
+ {
320
+ encoding: 'utf8',
321
+ stdio: 'pipe',
322
+ },
323
+ ).trim();
324
+
325
+ if (changesetFiles) {
326
+ console.log(
327
+ `❌ Cannot merge a branch where version has not been bumped. Found changesets in ${sourceBranch}`,
328
+ );
329
+ process.exit(BuildResults.changeLogsExist);
330
+ }
331
+ } catch (error) {
332
+ if (error.message.includes('Cannot merge')) {
333
+ throw error;
334
+ }
335
+ // If find command fails (no .changeset directory), that's fine
336
+ }
337
+
338
+ if (verbose) console.log('✅ No uncommitted changesets found');
339
+ } finally {
340
+ // Return to original branch
341
+ execSync(`git checkout ${currentBranch}`, {
342
+ stdio: 'pipe',
343
+ });
344
+ }
345
+ }
346
+
272
347
  export function setupMerge(program) {
273
348
  program
274
349
  .command('merge')
@@ -306,6 +381,11 @@ export function setupMerge(program) {
306
381
  );
307
382
  }
308
383
 
384
+ // Check for uncommitted changesets in source branch
385
+ if (!mergeFail && !mergeSuccess) {
386
+ checkForUncommittedChangesets(sourceBranch, verbose);
387
+ }
388
+
309
389
  // 1. Create merge branch from target branch
310
390
  const mergeBranchName = createMergeBranch(
311
391
  sourceBranch,
@@ -327,7 +407,7 @@ export function setupMerge(program) {
327
407
  console.log('✅ No changes to merge');
328
408
  execSync(`git checkout ${targetBranch}`, { stdio: 'pipe' });
329
409
  execSync(`git branch -d ${mergeBranchName}`, { stdio: 'pipe' });
330
- process.exit(4);
410
+ process.exit(BuildResults.noChanges);
331
411
  }
332
412
 
333
413
  // 4. If conflicts, try auto-resolve
@@ -378,7 +458,7 @@ export function setupMerge(program) {
378
458
  console.log(
379
459
  `⚠️ Merge completed with unresolved conflicts on branch: ${mergeBranchName}`,
380
460
  );
381
- process.exit(2);
461
+ process.exit(BuildResults.unresolvedConflicts);
382
462
  }
383
463
 
384
464
  console.log(
@@ -420,9 +500,9 @@ export function setupMerge(program) {
420
500
  });
421
501
  }
422
502
  if (buildPassed) {
423
- process.exit(0);
503
+ process.exit(BuildResults.success);
424
504
  } else {
425
- process.exit(3);
505
+ process.exit(BuildResults.buildFailed);
426
506
  }
427
507
  } else {
428
508
  // 6e) Build failed, dev mode, or prepare-only - create PR
@@ -0,0 +1,7 @@
1
+ export const BuildResults = {
2
+ success: 0,
3
+ unresolvedConflicts: 2,
4
+ buildFailed: 3,
5
+ noChanges: 4,
6
+ changeLogsExist: 5,
7
+ };