@docupace/pipeline 1.0.8-6.xray → 1.0.8

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.
Files changed (64) hide show
  1. package/eslint.config.js +2 -25
  2. package/next/execute.sh +2 -8
  3. package/package.json +8 -24
  4. package/src/changeset/cli.js +195 -151
  5. package/src/changeset/validate.js +1 -45
  6. package/src/jenkins/setParams.groovy +2 -1
  7. package/src/next/cli.js +15 -111
  8. package/src/next/config.js +7 -72
  9. package/src/next/copy.js +1 -32
  10. package/src/next/deploy.js +69 -520
  11. package/src/next/jenkins.js +2 -3
  12. package/src/next/pipline.js +1 -0
  13. package/src/next/publish.js +30 -53
  14. package/README.md +0 -136
  15. package/bin/azuread_update_callbacks_for_app.sh +0 -58
  16. package/bin/xray.sh +0 -273
  17. package/bitbucket-pipelines.yml +0 -142
  18. package/jest.config.js +0 -15
  19. package/src/auth0/alias.js +0 -79
  20. package/src/auth0/alias.test.js +0 -172
  21. package/src/auth0/cli.js +0 -82
  22. package/src/auth0/configure.js +0 -902
  23. package/src/auth0/configure.test.js +0 -167
  24. package/src/auth0/export.js +0 -48
  25. package/src/auth0/export.test.js +0 -103
  26. package/src/auth0/metadata.js +0 -141
  27. package/src/auth0/metadata.test.js +0 -186
  28. package/src/auth0/vault.js +0 -60
  29. package/src/auth0/vault.test.js +0 -134
  30. package/src/changeset/changelog-wiki.js +0 -328
  31. package/src/changeset/changeset-config.js +0 -34
  32. package/src/changeset/create.js +0 -215
  33. package/src/changeset/package-util.js +0 -87
  34. package/src/changeset/util.js +0 -43
  35. package/src/changeset/version.js +0 -102
  36. package/src/jfrog/xray-scan.yaml +0 -29
  37. package/src/lib/merge-driver.js +0 -204
  38. package/src/merge/cli-merge-all.js +0 -521
  39. package/src/merge/cli-merge.js +0 -572
  40. package/src/merge/cli-resolve.js +0 -399
  41. package/src/merge/cli.js +0 -38
  42. package/src/merge/common.js +0 -7
  43. package/src/merge/merge-changelog.js +0 -87
  44. package/src/merge/merge-package.js +0 -106
  45. package/src/merge/merge-types.js +0 -82
  46. package/src/merge/pr.js +0 -231
  47. package/src/micro/cli.js +0 -51
  48. package/src/micro/ms-deploy.js +0 -451
  49. package/src/micro/ms-publish.js +0 -186
  50. package/src/next/alias.js +0 -53
  51. package/src/next/apache.js +0 -81
  52. package/src/next/connect.js +0 -226
  53. package/src/next/git-to-semver.js +0 -79
  54. package/src/next/haproxy.js +0 -76
  55. package/src/next/jira.js +0 -84
  56. package/src/next/logger.js +0 -17
  57. package/src/next/test.js +0 -5
  58. package/src/next/util.js +0 -95
  59. package/src/next/vault.js +0 -45
  60. package/terraform/apply.sh +0 -41
  61. package/terraform/import.sh +0 -111
  62. package/terraform/init.sh +0 -78
  63. package/terraform/plan.sh +0 -95
  64. package/terraform/validate.sh +0 -17
@@ -1,572 +0,0 @@
1
- import { execSync } from 'child_process';
2
- import { createBitbucketPR } from './pr.js';
3
- import { autoResolveConflicts } from './cli-resolve.js';
4
- import { getPackageNames } from '../changeset/package-util.js';
5
- import { writeChangesetFile } from '../changeset/create.js';
6
- import { BuildResults } from './common.js';
7
-
8
- /**
9
- * Create and checkout merge branch from target branch
10
- */
11
- function createMergeBranch(
12
- sourceBranch,
13
- targetBranch,
14
- checkoutOnly = false,
15
- verbose = false,
16
- ) {
17
- const mergeBranchName = `merge/${sourceBranch.replaceAll('/', '-')}-to-${targetBranch.replaceAll('/', '-')}`;
18
-
19
- if (!checkoutOnly) {
20
- if (verbose) console.log(`📋 Checking out target branch: ${targetBranch}`);
21
- execSync(`git checkout ${targetBranch}`, {
22
- stdio: verbose ? 'inherit' : 'pipe',
23
- });
24
- execSync(`git pull origin ${targetBranch}`, {
25
- stdio: verbose ? 'inherit' : 'pipe',
26
- });
27
-
28
- // Check if merge branch exists and delete it (both local and remote)
29
- try {
30
- execSync(`git branch -D ${mergeBranchName}`, {
31
- stdio: 'pipe',
32
- });
33
- if (verbose)
34
- console.log(`🗑️ Deleted existing local branch: ${mergeBranchName}`);
35
- } catch {
36
- // Branch doesn't exist, which is fine
37
- }
38
-
39
- // Try to delete remote branch
40
- try {
41
- execSync(`git push origin --delete ${mergeBranchName}`, {
42
- stdio: 'pipe',
43
- });
44
- if (verbose)
45
- console.log(`🗑️ Deleted existing remote branch: ${mergeBranchName}`);
46
- } catch {
47
- // Remote branch doesn't exist, which is fine
48
- }
49
-
50
- if (verbose) console.log(`🌿 Creating merge branch: ${mergeBranchName}`);
51
- execSync(`git checkout -b ${mergeBranchName}`, {
52
- stdio: verbose ? 'inherit' : 'pipe',
53
- });
54
- } else {
55
- console.log('Do nothing. Should be checked out');
56
- }
57
-
58
- return mergeBranchName;
59
- }
60
-
61
- /**
62
- * Attempt to merge source branch into current branch
63
- * Returns: { hasConflicts: boolean, hasChanges: boolean }
64
- */
65
- function attemptMerge(sourceBranch, targetBranch, verbose = false) {
66
- if (verbose) {
67
- console.log(`🔀 Merging ${sourceBranch} into current branch`);
68
- }
69
-
70
- try {
71
- execSync(`git merge --no-commit --no-ff origin/${sourceBranch}`, {
72
- stdio: 'pipe',
73
- encoding: 'utf8',
74
- });
75
-
76
- // Check if there are any changes
77
- try {
78
- execSync('git diff --cached --quiet', { stdio: 'pipe' });
79
- // No changes
80
- return { hasConflicts: false, hasChanges: false };
81
- } catch {
82
- // Has changes
83
- if (verbose) console.log('✅ Merge completed with changes, no conflicts');
84
- return { hasConflicts: false, hasChanges: true };
85
- }
86
- } catch (error) {
87
- if (verbose) console.log('⚠️ Merge conflicts detected');
88
- return { hasConflicts: true, hasChanges: true };
89
- }
90
- }
91
-
92
- /**
93
- * Get packages that have changes to be merged
94
- */
95
- function getChangedPackages(verbose = false) {
96
- try {
97
- const allPackages = getPackageNames();
98
-
99
- // Get list of changed files
100
- const changedFiles = execSync('git diff --cached --name-only', {
101
- encoding: 'utf8',
102
- stdio: 'pipe',
103
- })
104
- .trim()
105
- .split('\n')
106
- .filter(Boolean);
107
-
108
- if (verbose) {
109
- console.log('📄 Changed files:', changedFiles);
110
- }
111
-
112
- // Filter packages that have changes
113
- const changedPackages = allPackages.filter((pkg) => {
114
- const packagePath = pkg.path === '.' ? '' : pkg.path + '/';
115
- return changedFiles.some((file) => file.startsWith(packagePath));
116
- });
117
-
118
- if (verbose) {
119
- console.log(
120
- '📦 Changed packages:',
121
- changedPackages.map((p) => p.name),
122
- );
123
- }
124
-
125
- return changedPackages;
126
- } catch (error) {
127
- if (verbose) console.log('Error getting changed packages:', error.message);
128
- return [];
129
- }
130
- }
131
-
132
- /**
133
- * Run build script
134
- */
135
- function runBuild(buildScript, verbose = false) {
136
- if (verbose) console.log(`🔨 Running build: ${buildScript}`);
137
-
138
- try {
139
- execSync(buildScript, {
140
- stdio: verbose ? 'inherit' : 'pipe',
141
- });
142
- if (verbose) console.log('✅ Build passed');
143
- return true;
144
- } catch (error) {
145
- if (verbose) console.log('❌ Build failed');
146
- return false;
147
- }
148
- }
149
-
150
- /**
151
- * Create changeset and commit it
152
- */
153
- async function createAndCommitChangeset(
154
- sourceBranch,
155
- targetBranch,
156
- changedPackages,
157
- verbose = false,
158
- ) {
159
- const changesetId = `merge-${sourceBranch.replaceAll('/', '-')}-to-${targetBranch.replaceAll('/', '-')}-${Date.now()}`;
160
- const text = `Merge ${sourceBranch} to ${targetBranch}`;
161
-
162
- if (verbose) console.log('📝 Creating changeset...');
163
-
164
- await writeChangesetFile(changedPackages, changesetId, 'patch', text);
165
-
166
- execSync('git add .', {
167
- stdio: verbose ? 'inherit' : 'pipe',
168
- });
169
-
170
- execSync(
171
- `git commit -m "Automatic merge operation for ${sourceBranch} to ${targetBranch}"`,
172
- {
173
- stdio: verbose ? 'inherit' : 'pipe',
174
- },
175
- );
176
-
177
- if (verbose) console.log('✅ Changeset created and committed');
178
- }
179
-
180
- /**
181
- * Merge into target branch
182
- */
183
-
184
- function branchExists(branchName) {
185
- try {
186
- // This will list branches that match the name
187
- const result = execSync(`git branch --list ${branchName}`, {
188
- encoding: 'utf8',
189
- });
190
- return result.trim().length > 0;
191
- } catch (error) {
192
- // If git fails, you can log or handle differently
193
- console.error('Error checking branch:', error.message);
194
- return false;
195
- }
196
- }
197
-
198
- function mergeIntoTarget(
199
- sourceBranch,
200
- targetBranch,
201
- mergeBranchName,
202
- verbose = false,
203
- ) {
204
- if (verbose)
205
- console.log(`🔀 Merging ${mergeBranchName} into ${targetBranch}`);
206
-
207
- execSync(`git checkout ${targetBranch}`, {
208
- stdio: verbose ? 'inherit' : 'pipe',
209
- });
210
-
211
- if (branchExists(mergeBranchName)) {
212
- execSync(`git merge ${mergeBranchName}`, {
213
- stdio: verbose ? 'inherit' : 'pipe',
214
- });
215
-
216
- execSync(`git push origin ${targetBranch}`, {
217
- stdio: verbose ? 'inherit' : 'pipe',
218
- });
219
-
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
- }
241
-
242
- if (verbose) console.log(`✅ Successfully merged into ${targetBranch}`);
243
- } else {
244
- if (verbose) console.log(`✅ Nothing to merge`);
245
- }
246
- }
247
-
248
- /**
249
- * Create pull request for merge branch
250
- */
251
- async function createMergePR(
252
- sourceBranch,
253
- targetBranch,
254
- mergeBranchName,
255
- reason,
256
- verbose = false,
257
- ) {
258
- if (verbose) console.log('📋 Creating pull request...');
259
-
260
- const prTitle = `Merge ${sourceBranch} into ${targetBranch}`;
261
- const prDescription = `Automated merge with changeset.\n\nReason: ${reason}`;
262
-
263
- const prResult = await createBitbucketPR(
264
- mergeBranchName,
265
- targetBranch,
266
- prTitle,
267
- prDescription,
268
- );
269
-
270
- if (prResult.success) {
271
- console.log(`✅ Pull request created: ${prResult.url}`);
272
- } else if (prResult.manual) {
273
- console.log(`📋 Please create PR manually: ${prResult.url}`);
274
- } else {
275
- console.log(`❌ Failed to create pull request: ${prResult.error}`);
276
- }
277
- }
278
-
279
- /**
280
- * Clean up failed merge
281
- */
282
- function cleanupFailedMerge(verbose = false) {
283
- try {
284
- execSync('git merge --abort', { stdio: 'pipe' });
285
- if (verbose) console.log('🧹 Cleaned up failed merge');
286
- } catch (cleanupError) {
287
- // Ignore cleanup errors
288
- }
289
- }
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
-
347
- export function setupMerge(program) {
348
- program
349
- .command('merge')
350
- .description(
351
- 'Merge source branch into target branch with automatic conflict resolution',
352
- )
353
- .argument('<sourceBranch>', 'Source branch to merge from')
354
- .argument('<targetBranch>', 'Target branch to merge into')
355
- .requiredOption('-b, --build <script>', 'Build script to run after merge')
356
- .option('-v, --verbose', 'Verbose output')
357
- .option('--no-push', 'Do not push changes automatically')
358
- .option('--no-pr', 'Do not create pull request if conflicts remain')
359
- .option(
360
- '--prepare-only',
361
- 'Always create PR instead of direct merge, even if build passes',
362
- )
363
- .option('--merge-success', 'Merge with success')
364
- .option('--merge-fail <reason>', 'Merge with with fail')
365
- .action(async (sourceBranch, targetBranch, options) => {
366
- try {
367
- const {
368
- verbose,
369
- push = true,
370
- pr = true,
371
- build,
372
- prepareOnly = false,
373
- mergeSuccess = false,
374
- mergeFail = '',
375
- } = options;
376
- const isDevMode = process.env.DEV_MODE === 'true';
377
-
378
- if (verbose) {
379
- console.log(
380
- `🔄 Starting merge of ${sourceBranch} into ${targetBranch}`,
381
- );
382
- }
383
-
384
- // Check for uncommitted changesets in source branch
385
- if (!mergeFail && !mergeSuccess) {
386
- checkForUncommittedChangesets(sourceBranch, verbose);
387
- }
388
-
389
- // 1. Create merge branch from target branch
390
- const mergeBranchName = createMergeBranch(
391
- sourceBranch,
392
- targetBranch,
393
- mergeSuccess || mergeFail,
394
- verbose,
395
- );
396
-
397
- if (!mergeFail && !mergeSuccess) {
398
- // 2. Attempt merge
399
- const { hasConflicts, hasChanges } = attemptMerge(
400
- sourceBranch,
401
- targetBranch,
402
- verbose,
403
- );
404
-
405
- // 3. If no changes, exit
406
- if (!hasChanges) {
407
- console.log('✅ No changes to merge');
408
- execSync(`git checkout ${targetBranch}`, { stdio: 'pipe' });
409
- execSync(`git branch -d ${mergeBranchName}`, { stdio: 'pipe' });
410
- process.exit(BuildResults.noChanges);
411
- }
412
-
413
- // 4. If conflicts, try auto-resolve
414
- let allConflictsResolved = true;
415
- if (hasConflicts) {
416
- if (verbose) console.log('🤖 Running auto-conflict resolution...');
417
-
418
- const autoResult = await autoResolveConflicts({ verbose });
419
- allConflictsResolved = autoResult.success;
420
- }
421
-
422
- // Get changed packages
423
- const changedPackages = getChangedPackages(verbose);
424
-
425
- if (!allConflictsResolved) {
426
- // 5. Cannot resolve conflicts
427
- if (verbose)
428
- console.log('⚠️ Cannot resolve all conflicts automatically');
429
-
430
- // 5a) Get changed packages (already done above)
431
- // 5b) Abort merge
432
- cleanupFailedMerge(verbose);
433
-
434
- // 5c) Create changeset
435
- await createAndCommitChangeset(
436
- sourceBranch,
437
- targetBranch,
438
- changedPackages,
439
- verbose,
440
- );
441
-
442
- if (pr && !prepareOnly) {
443
- // 5d) Push and create PR
444
- if (push) {
445
- execSync(`git push -u origin ${mergeBranchName}`, {
446
- stdio: verbose ? 'inherit' : 'pipe',
447
- });
448
- }
449
-
450
- await createMergePR(
451
- sourceBranch,
452
- targetBranch,
453
- mergeBranchName,
454
- 'Unresolved conflicts',
455
- verbose,
456
- );
457
- } else {
458
- console.log(
459
- `⚠️ Merge completed with unresolved conflicts on branch: ${mergeBranchName}`,
460
- );
461
- process.exit(BuildResults.unresolvedConflicts);
462
- }
463
-
464
- console.log(
465
- `⚠️ Merge completed with unresolved conflicts on branch: ${mergeBranchName}`,
466
- );
467
- return;
468
- }
469
-
470
- // 6. Can resolve conflicts
471
- if (verbose) console.log('✅ All conflicts resolved');
472
-
473
- // 6a) Get changed packages (already done above)
474
- // 6b) Create changeset
475
- await createAndCommitChangeset(
476
- sourceBranch,
477
- targetBranch,
478
- changedPackages,
479
- verbose,
480
- );
481
-
482
- // 6c) Run build
483
- const buildPassed = runBuild(build, verbose);
484
-
485
- if (buildPassed && !isDevMode && !prepareOnly) {
486
- // 6d) Build passed - merge into target
487
- mergeIntoTarget(
488
- sourceBranch,
489
- targetBranch,
490
- mergeBranchName,
491
- verbose,
492
- );
493
- console.log(
494
- `🎉 Successfully merged ${sourceBranch} into ${targetBranch}`,
495
- );
496
- } else if (prepareOnly) {
497
- if (push) {
498
- execSync(`git push -u origin ${mergeBranchName}`, {
499
- stdio: verbose ? 'inherit' : 'pipe',
500
- });
501
- }
502
- if (buildPassed) {
503
- process.exit(BuildResults.success);
504
- } else {
505
- process.exit(BuildResults.buildFailed);
506
- }
507
- } else {
508
- // 6e) Build failed, dev mode, or prepare-only - create PR
509
- if (push) {
510
- execSync(`git push -u origin ${mergeBranchName}`, {
511
- stdio: verbose ? 'inherit' : 'pipe',
512
- });
513
- }
514
-
515
- if (pr) {
516
- let reason;
517
- if (isDevMode) {
518
- reason = 'Dev mode enabled';
519
- } else {
520
- reason = 'Build failed';
521
- }
522
-
523
- await createMergePR(
524
- sourceBranch,
525
- targetBranch,
526
- mergeBranchName,
527
- reason,
528
- verbose,
529
- );
530
- }
531
-
532
- let reason;
533
- if (prepareOnly) {
534
- reason = 'prepare-only mode';
535
- } else if (isDevMode) {
536
- reason = 'dev mode';
537
- } else {
538
- reason = 'build failure';
539
- }
540
-
541
- console.log(
542
- `⚠️ Merge completed but creating PR due to ${reason}: ${mergeBranchName}`,
543
- );
544
- }
545
- } else {
546
- if (mergeSuccess) {
547
- mergeIntoTarget(
548
- sourceBranch,
549
- targetBranch,
550
- mergeBranchName,
551
- verbose,
552
- );
553
- } else {
554
- execSync(`git push -u origin ${mergeBranchName}`, {
555
- stdio: verbose ? 'inherit' : 'pipe',
556
- });
557
- await createMergePR(
558
- sourceBranch,
559
- targetBranch,
560
- mergeBranchName,
561
- mergeFail,
562
- verbose,
563
- );
564
- }
565
- }
566
- } catch (error) {
567
- console.error(`❌ Merge failed: ${error.message}`);
568
- cleanupFailedMerge();
569
- process.exit(1);
570
- }
571
- });
572
- }