@docupace/pipeline 1.0.8-6.xray → 1.0.9

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 +7 -23
  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 +75 -514
  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,521 +0,0 @@
1
- import { execSync } from 'child_process';
2
- import { readFileSync, existsSync, mkdirSync } from 'fs';
3
- import { join, dirname } from 'path';
4
- import { fileURLToPath } from 'url';
5
- import { getExistingPRsWithDescription } from './pr.js';
6
- import { BuildResults } from './common.js';
7
-
8
- const __dirname = dirname(fileURLToPath(import.meta.url));
9
-
10
- /**
11
- * Read merge configuration from current directory
12
- */
13
- function readMergeConfig(verbose = false) {
14
- const configPath = join(process.cwd(), 'merge-config.json');
15
-
16
- if (!existsSync(configPath)) {
17
- throw new Error('merge-config.json not found in current directory');
18
- }
19
-
20
- try {
21
- const config = JSON.parse(readFileSync(configPath, 'utf8'));
22
-
23
- if (!config.repositories || !Array.isArray(config.repositories)) {
24
- throw new Error('Invalid config: repositories array is required');
25
- }
26
-
27
- // Validate repository objects
28
- config.repositories.forEach((repo, index) => {
29
- if (!repo.url) {
30
- throw new Error(`Repository at index ${index} is missing 'url' field`);
31
- }
32
- if (!repo.buildScript) {
33
- throw new Error(
34
- `Repository at index ${index} is missing 'buildScript' field`,
35
- );
36
- }
37
- if (!repo.name) {
38
- throw new Error(`Repository at index ${index} is missing 'name' field`);
39
- }
40
- });
41
-
42
- if (!config.mergeBranches || !Array.isArray(config.mergeBranches)) {
43
- throw new Error('Invalid config: mergeBranches array is required');
44
- }
45
-
46
- // Validate merge branches
47
- config.mergeBranches.forEach((branch, index) => {
48
- if (!branch.from || !branch.to) {
49
- throw new Error(
50
- `Merge branch at index ${index} is missing 'from' or 'to' field`,
51
- );
52
- }
53
- if (typeof branch.from !== 'object' || typeof branch.to !== 'object') {
54
- throw new Error(
55
- `Merge branch at index ${index}: 'from' and 'to' must be objects`,
56
- );
57
- }
58
- if (!branch.from['*'] || !branch.to['*']) {
59
- throw new Error(
60
- `Merge branch at index ${index}: 'from' and 'to' must have '*' default value`,
61
- );
62
- }
63
- });
64
-
65
- if (verbose) {
66
- console.log('šŸ“‹ Configuration loaded:');
67
- console.log(` Repositories: ${config.repositories.length}`);
68
- console.log(` Merge branches: ${config.mergeBranches.length}`);
69
- }
70
-
71
- return config;
72
- } catch (error) {
73
- throw new Error(`Failed to parse merge-config.json: ${error.message}`);
74
- }
75
- }
76
-
77
- /**
78
- * Extract repository name from git URL
79
- */
80
- function getRepoName(gitUrl) {
81
- const match = gitUrl.match(/\/([^\/]+)\.git$/);
82
- return match ? match[1] : gitUrl.split('/').pop().replace('.git', '');
83
- }
84
-
85
- /**
86
- * Get branch name for a specific repository
87
- */
88
- function getBranchForRepo(branchConfig, repoName) {
89
- // Check if there's a specific override for this repository
90
- if (branchConfig[repoName]) {
91
- return branchConfig[repoName];
92
- }
93
- // Fall back to the default branch
94
- return branchConfig['*'];
95
- }
96
-
97
- /**
98
- * Clone or update repository
99
- */
100
- function setupRepository(repository, reposDir, verbose = false) {
101
- const repoName = getRepoName(repository.url);
102
- const repoPath = join(reposDir, repoName);
103
-
104
- if (existsSync(repoPath)) {
105
- if (verbose) console.log(`šŸ“ Repository ${repoName} exists, updating...`);
106
-
107
- execSync('git fetch --all', {
108
- cwd: repoPath,
109
- stdio: verbose ? 'inherit' : 'pipe',
110
- });
111
- } else {
112
- if (verbose) console.log(`šŸ“„ Cloning repository ${repoName}...`);
113
-
114
- execSync(`git clone ${repository.url} ${repoName}`, {
115
- cwd: reposDir,
116
- stdio: verbose ? 'inherit' : 'pipe',
117
- });
118
- }
119
-
120
- return {
121
- repoName,
122
- repoPath,
123
- buildScript: repository.buildScript,
124
- configName: repository.name,
125
- };
126
- }
127
-
128
- /**
129
- * Run merge command in repository with specific flags
130
- */
131
- function runMergeCommand(
132
- repoPath,
133
- fromBranch,
134
- toBranch,
135
- buildScript,
136
- flags = '',
137
- verbose = false,
138
- ) {
139
- const cliPath = join(__dirname, 'cli.js');
140
- const verboseFlag = verbose ? '--verbose' : '';
141
-
142
- const command =
143
- `node ${cliPath} merge ${fromBranch} ${toBranch} --build "${buildScript}" ${flags} ${verboseFlag}`.trim();
144
-
145
- if (verbose) {
146
- console.log(`šŸ“„ Running command in ${repoPath}`);
147
- console.log(`Command: ${command}`);
148
- }
149
-
150
- try {
151
- execSync(command, {
152
- cwd: repoPath,
153
- stdio: verbose ? 'inherit' : 'pipe',
154
- encoding: 'utf8',
155
- });
156
-
157
- return { exitCode: 0, error: null };
158
- } catch (error) {
159
- // Extract exit code from error
160
- const exitCode = error.status || 1;
161
- return { exitCode, error: error.message };
162
- }
163
- }
164
-
165
- /**
166
- * Run initial prepare-only phase for all repositories
167
- */
168
- async function runPreparePhase(
169
- mergeBranch,
170
- repositories,
171
- reposDir,
172
- verbose = false,
173
- ) {
174
- const { from: fromConfig, to: toConfig } = mergeBranch;
175
- console.log(`\nšŸ”„ Phase 1: Running prepare-only for all repositories`);
176
-
177
- const results = [];
178
-
179
- for (let i = 0; i < repositories.length; i++) {
180
- const repository = repositories[i];
181
- const { repoName, repoPath, buildScript, configName } = setupRepository(
182
- repository,
183
- reposDir,
184
- verbose,
185
- );
186
-
187
- // Get the specific branches for this repository
188
- const fromBranch = getBranchForRepo(fromConfig, configName);
189
- const toBranch = getBranchForRepo(toConfig, configName);
190
-
191
- console.log(
192
- `\nšŸ“¦ [${i + 1}/${repositories.length}] Testing ${configName} (${repoName}): ${fromBranch} → ${toBranch}`,
193
- );
194
-
195
- const result = runMergeCommand(
196
- repoPath,
197
- fromBranch,
198
- toBranch,
199
- buildScript,
200
- '--prepare-only',
201
- verbose,
202
- );
203
-
204
- results.push({
205
- repository: repoName,
206
- configName,
207
- url: repository.url,
208
- buildScript,
209
- fromBranch,
210
- toBranch,
211
- exitCode: result.exitCode,
212
- error: result.error,
213
- repoPath,
214
- });
215
-
216
- // Log result based on exit code
217
- switch (result.exitCode) {
218
- case BuildResults.success:
219
- console.log(`āœ… ${configName}: Merge and build successful`);
220
- break;
221
- case BuildResults.unresolvedConflicts:
222
- console.log(`āš ļø ${configName}: Merge has unresolved conflicts`);
223
- break;
224
- case BuildResults.buildFailed:
225
- console.log(`āš ļø ${configName}: Build failed`);
226
- break;
227
- case BuildResults.noChanges:
228
- console.log(`āœ… ${configName}: No Changes`);
229
- break;
230
- case BuildResults.changeLogsExist:
231
- console.log(`āŒ Stopping Merge`);
232
- process.exit(1);
233
- break;
234
- default:
235
- console.log(
236
- `āŒ ${configName}: Unknown error (exit code: ${result.exitCode})`,
237
- );
238
- }
239
- }
240
-
241
- return results;
242
- }
243
-
244
- /**
245
- * Run follow-up phase based on prepare phase results
246
- */
247
- async function runFollowUpPhase(prepareResults, verbose = false) {
248
- console.log(`\nšŸ”„ Phase 2: Running follow-up based on prepare phase results`);
249
-
250
- // Check if all repositories passed
251
- const allPassed = prepareResults.every(
252
- (r) => r.exitCode === 0 || r.exitCode === 4,
253
- );
254
-
255
- for (let i = 0; i < prepareResults.length; i++) {
256
- const result = prepareResults[i];
257
- console.log(
258
- `\nšŸ“¦ [${i + 1}/${prepareResults.length}] Processing ${result.configName}`,
259
- );
260
-
261
- let flags = '';
262
- let action = '';
263
-
264
- if (allPassed) {
265
- // All passed, merge successfully
266
- flags = '--merge-success';
267
- action = 'Merging successfully';
268
- } else {
269
- // At least one failed, determine the appropriate action
270
- switch (result.exitCode) {
271
- case 0:
272
- // This one passed but others failed
273
- flags = '--merge-fail "Waiting for success for other failed merges"';
274
- action = 'Creating PR (waiting for other repos)';
275
- break;
276
- case 2:
277
- // Merge failed
278
- flags = '--merge-fail "Merge Failed"';
279
- action = 'Creating PR (merge conflicts)';
280
- break;
281
- case 3:
282
- // Build failed
283
- flags = '--merge-fail "Build Failed"';
284
- action = 'Creating PR (build failed)';
285
- break;
286
- default:
287
- // Unknown error
288
- flags = '--merge-fail "Unknown Error"';
289
- action = 'Creating PR (unknown error)';
290
- }
291
- }
292
-
293
- console.log(` Action: ${action}`);
294
-
295
- if (result.exitCode !== 4) {
296
- const followUpResult = runMergeCommand(
297
- result.repoPath,
298
- result.fromBranch,
299
- result.toBranch,
300
- result.buildScript,
301
- flags,
302
- verbose,
303
- );
304
-
305
- // Update the result with follow-up information
306
- result.followUpExitCode = followUpResult.exitCode;
307
- result.followUpError = followUpResult.error;
308
- result.followUpAction = action;
309
-
310
- if (followUpResult.exitCode === 0) {
311
- console.log(`āœ… ${result.configName}: ${action} completed`);
312
- } else {
313
- console.log(`āŒ ${result.configName}: ${action} failed`);
314
- process.exit(1);
315
- }
316
- }
317
- }
318
-
319
- return prepareResults;
320
- }
321
-
322
- /**
323
- * Process a single merge branch across all repositories
324
- */
325
- async function processMergeBranch(
326
- mergeBranch,
327
- repositories,
328
- reposDir,
329
- verbose = false,
330
- ) {
331
- console.log(`\nšŸ”€ Processing merge branches`);
332
-
333
- // Phase 1: Run prepare-only for all repositories
334
- const prepareResults = await runPreparePhase(
335
- mergeBranch,
336
- repositories,
337
- reposDir,
338
- verbose,
339
- );
340
-
341
- // Phase 2: Run follow-up based on results
342
- const finalResults = await runFollowUpPhase(prepareResults, verbose);
343
-
344
- // Summary
345
- const allPassed = prepareResults.every(
346
- (r) => r.exitCode === 0 || r.exitCode === 4,
347
- );
348
- const mergeFailures = prepareResults.filter((r) => r.exitCode === 2);
349
- const buildFailures = prepareResults.filter((r) => r.exitCode === 3);
350
- const successes = prepareResults.filter((r) => r.exitCode === 0);
351
-
352
- console.log(`\nšŸ“Š Merge summary:`);
353
- console.log(` āœ… Successful: ${successes.length}/${repositories.length}`);
354
- console.log(` āš ļø Merge conflicts: ${mergeFailures.length}`);
355
- console.log(` āš ļø Build failures: ${buildFailures.length}`);
356
-
357
- if (allPassed) {
358
- console.log(` šŸŽ‰ All repositories merged successfully!`);
359
- } else {
360
- console.log(` āš ļø Some repositories require manual intervention via PRs`);
361
- }
362
-
363
- return {
364
- success: allPassed,
365
- results: finalResults,
366
- summary: {
367
- total: repositories.length,
368
- successes: successes.length,
369
- mergeFailures: mergeFailures.length,
370
- buildFailures: buildFailures.length,
371
- },
372
- };
373
- }
374
-
375
- /**
376
- * Main merge-all function
377
- */
378
- async function mergeAll(verbose = false) {
379
- try {
380
- // Read configuration
381
- const config = readMergeConfig(verbose);
382
-
383
- // Check for existing PRs with "Automated merge with changeset" description
384
- if (verbose) console.log('šŸ” Checking for existing automated merge PRs...');
385
- const existingPRs = await getExistingPRsWithDescription(
386
- 'Automated merge with changeset',
387
- config.repositories,
388
- );
389
-
390
- if (existingPRs.length > 0) {
391
- console.log(
392
- `āŒ Found ${existingPRs.length} existing pull request(s) with "Automated merge with changeset" description. Exiting to prevent conflicts.`,
393
- );
394
- if (verbose) {
395
- existingPRs.forEach((pr) => {
396
- console.log(
397
- ` - PR #${pr.id}: ${pr.title} in ${pr.repositoryName || 'unknown repo'} (${pr.links.html.href})`,
398
- );
399
- });
400
- }
401
- process.exit(1);
402
- }
403
-
404
- if (verbose)
405
- console.log('āœ… No existing automated merge PRs found. Proceeding...');
406
-
407
- // Setup repos directory
408
- const reposDir = join(process.cwd(), 'repos');
409
- if (!existsSync(reposDir)) {
410
- mkdirSync(reposDir, { recursive: true });
411
- if (verbose) console.log(`šŸ“ Created repos directory: ${reposDir}`);
412
- }
413
-
414
- console.log(`šŸš€ Starting merge-all process`);
415
- console.log(`Repositories: ${config.repositories.length}`);
416
- console.log(`Merge branches: ${config.mergeBranches.length}`);
417
-
418
- const allResults = [];
419
-
420
- // Process each merge branch in sequence
421
- for (let i = 0; i < config.mergeBranches.length; i++) {
422
- const mergeBranch = config.mergeBranches[i];
423
- console.log(`\n═══════════════════════════════════════`);
424
- console.log(
425
- `Processing merge branch set ${i + 1}/${config.mergeBranches.length}`,
426
- );
427
- console.log(`═══════════════════════════════════════`);
428
-
429
- const branchResult = await processMergeBranch(
430
- mergeBranch,
431
- config.repositories,
432
- reposDir,
433
- verbose,
434
- );
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
-
445
- if (!branchResult.success) {
446
- console.log(`Exiting due to failure of one or more merges`);
447
- process.exit(1);
448
- }
449
-
450
- allResults.push({
451
- mergeBranch,
452
- ...branchResult,
453
- });
454
- }
455
-
456
- // Final summary
457
- console.log(`\n═══════════════════════════════════════`);
458
- console.log(`šŸ“ˆ Final Summary:`);
459
- console.log(`═══════════════════════════════════════`);
460
-
461
- allResults.forEach((result, index) => {
462
- const { from, to } = result.mergeBranch;
463
- const status = result.success ? 'āœ…' : 'āš ļø';
464
- console.log(`\n${status} Merge branch set ${index + 1}:`);
465
-
466
- if (result.summary) {
467
- console.log(` Total repositories: ${result.summary.total}`);
468
- console.log(` Successful merges: ${result.summary.successes}`);
469
- console.log(` Merge conflicts: ${result.summary.mergeFailures}`);
470
- console.log(` Build failures: ${result.summary.buildFailures}`);
471
- }
472
-
473
- if (result.results && verbose) {
474
- console.log(`\n Repository details:`);
475
- result.results.forEach((repo) => {
476
- let repoStatus = 'ā“';
477
- if (repo.exitCode === 0) repoStatus = 'āœ…';
478
- else if (repo.exitCode === 2) repoStatus = 'āš ļø (merge)';
479
- else if (repo.exitCode === 3) repoStatus = 'āš ļø (build)';
480
-
481
- console.log(
482
- ` ${repoStatus} ${repo.configName}: ${repo.fromBranch} → ${repo.toBranch}`,
483
- );
484
- });
485
- }
486
- });
487
-
488
- const overallSuccess = allResults.every((r) => r.success);
489
- if (overallSuccess) {
490
- console.log(`\nšŸŽ‰ All merge operations completed successfully!`);
491
- } else {
492
- console.log(
493
- `\nāš ļø Some merge operations created PRs. Check the repositories for details.`,
494
- );
495
- }
496
-
497
- return { success: overallSuccess, results: allResults };
498
- } catch (error) {
499
- console.error(`āŒ Merge-all failed: ${error.message}`);
500
- throw error;
501
- }
502
- }
503
-
504
- export function setupMergeAll(program) {
505
- program
506
- .command('merge-all')
507
- .description(
508
- 'Merge multiple branches across multiple repositories based on configuration',
509
- )
510
- .option('-v, --verbose', 'Verbose output')
511
- .action(async (options) => {
512
- try {
513
- const { verbose } = options;
514
-
515
- await mergeAll(verbose);
516
- } catch (error) {
517
- console.error(`āŒ merge-all command failed: ${error.message}`);
518
- process.exit(1);
519
- }
520
- });
521
- }