@docupace/pipeline 1.0.7-7.micro-cli12 → 1.0.7-alpha.1

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 (68) hide show
  1. package/.prettierrc.cjs +12 -12
  2. package/bin/next-changeset-validate.sh +8 -8
  3. package/eslint.config.js +26 -49
  4. package/next/changeset.sh +75 -75
  5. package/next/copy.sh +34 -34
  6. package/next/deploy.sh +40 -40
  7. package/next/execute.sh +117 -123
  8. package/next/sonar.sh +23 -23
  9. package/package.json +7 -23
  10. package/src/changeset/cli.js +281 -237
  11. package/src/changeset/validate.js +47 -91
  12. package/src/jenkins/setParams.groovy +59 -58
  13. package/src/next/cli.js +15 -111
  14. package/src/next/config.js +72 -137
  15. package/src/next/copy.js +30 -61
  16. package/src/next/deploy.js +314 -633
  17. package/src/next/jenkins.js +88 -123
  18. package/src/next/pipline.js +115 -114
  19. package/src/next/publish.js +48 -71
  20. package/src/next/pull.js +7 -7
  21. package/src/next/sonar.js +23 -23
  22. package/README.md +0 -136
  23. package/bin/azuread_update_callbacks_for_app.sh +0 -58
  24. package/bitbucket-pipelines.yml +0 -60
  25. package/jest.config.js +0 -15
  26. package/src/auth0/alias.js +0 -79
  27. package/src/auth0/alias.test.js +0 -172
  28. package/src/auth0/cli.js +0 -82
  29. package/src/auth0/configure.js +0 -902
  30. package/src/auth0/configure.test.js +0 -167
  31. package/src/auth0/export.js +0 -48
  32. package/src/auth0/export.test.js +0 -103
  33. package/src/auth0/metadata.js +0 -141
  34. package/src/auth0/metadata.test.js +0 -186
  35. package/src/auth0/vault.js +0 -60
  36. package/src/auth0/vault.test.js +0 -134
  37. package/src/changeset/changelog-wiki.js +0 -328
  38. package/src/changeset/changeset-config.js +0 -34
  39. package/src/changeset/create.js +0 -215
  40. package/src/changeset/package-util.js +0 -87
  41. package/src/changeset/util.js +0 -43
  42. package/src/changeset/version.js +0 -102
  43. package/src/lib/merge-driver.js +0 -204
  44. package/src/merge/cli-merge-all.js +0 -507
  45. package/src/merge/cli-merge.js +0 -492
  46. package/src/merge/cli-resolve.js +0 -399
  47. package/src/merge/cli.js +0 -38
  48. package/src/merge/merge-changelog.js +0 -87
  49. package/src/merge/merge-package.js +0 -106
  50. package/src/merge/merge-types.js +0 -82
  51. package/src/merge/pr.js +0 -231
  52. package/src/micro/cli.js +0 -51
  53. package/src/micro/ms-deploy.js +0 -451
  54. package/src/micro/ms-publish.js +0 -186
  55. package/src/next/alias.js +0 -53
  56. package/src/next/apache.js +0 -81
  57. package/src/next/connect.js +0 -226
  58. package/src/next/git-to-semver.js +0 -79
  59. package/src/next/haproxy.js +0 -76
  60. package/src/next/jira.js +0 -84
  61. package/src/next/logger.js +0 -17
  62. package/src/next/test.js +0 -5
  63. package/src/next/util.js +0 -93
  64. package/src/next/vault.js +0 -45
  65. package/terraform/apply.sh +0 -37
  66. package/terraform/init.sh +0 -72
  67. package/terraform/plan.sh +0 -76
  68. package/terraform/validate.sh +0 -17
@@ -1,451 +0,0 @@
1
- import { $ } from '../next/logger.js';
2
- //mport { publishMicroservice } from './ms-publish.js';
3
- import { copy2 } from '../next/copy.js';
4
- import fs from 'fs';
5
- import path from 'path';
6
- /**
7
- * Deploy microservice end-to-end: build, publish, and deploy
8
- * @param {string} repoName - Name of microservice (e.g., 'swp', 'fidelity', 'esp')
9
- * @param {string} environment - Target environment (dev, qa, uat, stage, prod)
10
- * @param {string} tag - Version tag (optional, defaults to BITBUCKET_TAG)
11
- */
12
- // export async function deployMicroserviceEndToEnd(
13
- // repoName,
14
- // environment = '',
15
- // tag = null,
16
- // ) {
17
- // const serviceName = String(repoName || '')
18
- // .split('-')
19
- // .pop()
20
- // .trim();
21
- // const registryUrl = process.env.JF_REGISTRY_URL || '';
22
- // const deployTag = tag || process.env.BITBUCKET_TAG || process.env.VERSION_TAG;
23
- // if (!deployTag) {
24
- // throw new Error(
25
- // 'No tag provided. Set tag parameter or BITBUCKET_TAG/VERSION_TAG environment variable.',
26
- // );
27
- // }
28
- // console.log(`Starting ${serviceName} microservice deployment...`);
29
- // console.log(`Environment: ${environment}`);
30
- // console.log(`Tag: ${deployTag}`);
31
- // console.log('==========================================');
32
- // try {
33
- // // Step 1: Get Git SHA for image building
34
- // const gitSha = (
35
- // await $`git log ${deployTag} --pretty=format:'%h' -n 1`
36
- // ).stdout.trim();
37
- // console.log(`Git SHA: ${gitSha}`);
38
- // // Step 2: Publish Docker image with version tags
39
- // console.log('\nPublishing Docker image...');
40
- // await publishMicroservice(serviceName, {
41
- // tag: deployTag,
42
- // });
43
- // console.log('Docker image published successfully!');
44
- // // Step 3: Deploy to GitOps repository
45
- // console.log(`\nDeploying to ${environment} environment...`);
46
- // await deployMicroservice(serviceName, serviceName, environment, deployTag);
47
- // console.log(`Deployment to ${environment} completed successfully!`);
48
- // console.log(
49
- // `\n${serviceName} microservice deployment completed successfully!`,
50
- // );
51
- // console.log(
52
- // `Image: ${registryUrl}/${repoName}-${environment}-docker-local/${serviceName}:${deployTag}`,
53
- // );
54
- // } catch (error) {
55
- // console.error('\nDeployment failed:', error.message);
56
- // throw error;
57
- // }
58
- // }
59
-
60
- /**
61
- * Test Docker build and publish only (no deployment)
62
- * @param {string} serviceName - Name of microservice
63
- */
64
- // export async function testMicroservicePublish(serviceName) {
65
- // console.log(`Starting ${serviceName} test publish...`);
66
- // console.log('==========================================');
67
- // try {
68
- // const gitSha = (await $`git log --pretty=format:'%h' -n 1`).stdout.trim();
69
- // console.log(`Git SHA: ${gitSha}`);
70
- // console.log('\nTesting Docker build and publish...');
71
- // await publishMicroservice(gitSha, {
72
- // imageName: serviceName,
73
- // });
74
- // console.log('Test publish completed successfully!');
75
- // } catch (error) {
76
- // console.error('\nTest publish failed:', error.message);
77
- // throw error;
78
- // }
79
- // }
80
-
81
- export async function deployMicroservice(
82
- appName,
83
- helmPath,
84
- environment = '',
85
- tag = null,
86
- ) {
87
- if (!appName || !helmPath) {
88
- throw new Error(
89
- 'Missing required parameters. Usage: deployMicroservice(appName, helmPath, [environment], [tag])',
90
- );
91
- }
92
-
93
- let deployTag = tag;
94
- if (!deployTag) {
95
- deployTag =
96
- process.env.VERSION_TAG ||
97
- process.env.BITBUCKET_TAG ||
98
- (process.env.BITBUCKET_BUILD_NUMBER
99
- ? `build-${process.env.BITBUCKET_BUILD_NUMBER}`
100
- : null);
101
- }
102
-
103
- if (!deployTag) {
104
- throw new Error(
105
- 'No tag specified and no default tag available from environment variables',
106
- );
107
- }
108
-
109
- const repoName = `gitops-${environment}`;
110
- const filePath = `dp/${helmPath}/${appName}.values.yaml`;
111
-
112
- const gitopsBranch =
113
- environment === 'dev' || environment === 'uat'
114
- ? process.env.GITOPS_BRANCH || 'master'
115
- : process.env.GITOPS_BRANCH || 'main';
116
-
117
- let repoUrl;
118
- if (environment === 'dev' && process.env.GITOPS_REP_TOKEN) {
119
- repoUrl = `https://x-token-auth:${process.env.GITOPS_REP_TOKEN}@bitbucket.org/dp-cloud/${repoName}.git`;
120
- } else if (
121
- process.env.BITBUCKET_USERNAME &&
122
- process.env.BITBUCKET_APP_PASSWORD
123
- ) {
124
- repoUrl = `https://${process.env.BITBUCKET_USERNAME}:${process.env.BITBUCKET_APP_PASSWORD}@bitbucket.org/dp-cloud/${repoName}.git`;
125
- } else {
126
- throw new Error(
127
- 'No authentication credentials found for GitOps repository',
128
- );
129
- }
130
-
131
- console.log('=========================================');
132
- console.log('Microservice Deployment Configuration');
133
- console.log('=========================================');
134
- console.log(`Application: ${appName}`);
135
- console.log(`Environment: ${environment}`);
136
- console.log(`Tag: ${deployTag}`);
137
- console.log(`GitOps Repo: ${repoName}`);
138
- console.log(`Values File: ${filePath}`);
139
- console.log(`Branch: ${gitopsBranch}`);
140
- console.log('=========================================');
141
-
142
- try {
143
- console.log('Cloning GitOps repository...');
144
- await $`git clone --depth 1 ${repoUrl} ${repoName}`;
145
-
146
- console.log('Checking if directory exists...');
147
- await $`ls -la ${repoName}`;
148
-
149
- console.log(`Changing to directory: ${repoName}`);
150
- const originalDir = process.cwd();
151
- process.chdir(repoName);
152
-
153
- console.log('Verifying directory change...');
154
- const newDir = process.cwd();
155
- console.log(`Original: ${originalDir}`);
156
- console.log(`New: ${newDir}`);
157
-
158
- await $`cd ${repoName} && git config user.email "pipeline@bitbucket.org"`;
159
- await $`cd ${repoName} && git config user.name "Bitbucket Pipeline"`;
160
-
161
- console.log(`Attempting to checkout branch: ${gitopsBranch}`);
162
- await $`cd ${repoName} && git checkout ${gitopsBranch}`;
163
-
164
- const fullFilePath = path.resolve(filePath);
165
- console.log(`Looking for file at: ${fullFilePath}`);
166
- if (!fs.existsSync(fullFilePath)) {
167
- throw new Error(
168
- `Values file ${filePath} does not exist in ${repoName} on branch ${gitopsBranch}`,
169
- );
170
- }
171
-
172
- console.log(`Updating image tag to ${deployTag}...`);
173
-
174
- let fileContent = fs.readFileSync(fullFilePath, 'utf8');
175
-
176
- const tagRegex = /^ {2}tag: .*/gm;
177
- const newContent = fileContent.replace(tagRegex, ` tag: ${deployTag}`);
178
-
179
- if (fileContent === newContent) {
180
- console.log(`No changes detected - tag is already ${deployTag}`);
181
- return;
182
- }
183
-
184
- fs.writeFileSync(fullFilePath, newContent, 'utf8');
185
-
186
- console.log('Changes to be committed:');
187
- await $`cd ${repoName} && git diff ${filePath}`;
188
-
189
- await $`cd ${repoName} && git add ${filePath}`;
190
- await $`cd ${repoName} && git commit -m "Update ${appName} image tag to ${deployTag} in ${environment} environment"`;
191
-
192
- console.log('Pushing changes to GitOps repository...');
193
- await $`cd ${repoName} && git push origin ${gitopsBranch}`;
194
-
195
- console.log('=========================================');
196
- console.log(
197
- `✅ Successfully deployed ${appName}:${deployTag} to ${environment}`,
198
- );
199
- console.log('=========================================');
200
- } catch (error) {
201
- console.error('Error during microservice deployment:', error.message);
202
- throw error;
203
- } finally {
204
- try {
205
- process.chdir('..');
206
- await $`rm -rf ${repoName}`;
207
- } catch (cleanupError) {
208
- console.warn(
209
- 'Warning: Failed to clean up temporary directory:',
210
- cleanupError.message,
211
- );
212
- }
213
- }
214
- }
215
-
216
- export default deployMicroservice;
217
-
218
- export async function microserviceDeployTagVersion(
219
- repoName,
220
- environment = '',
221
- tag = null,
222
- ) {
223
- const serviceName = String(repoName || '')
224
- .split('-')
225
- .pop()
226
- .trim();
227
- console.log(`Starting ${serviceName} test deployment...`);
228
- console.log(`Environment: ${environment}`);
229
- console.log(`Tag: ${tag}`);
230
- console.log('==========================================');
231
- try {
232
- console.log(`\nTesting deployment to ${environment}...`);
233
- await deployMicroservice(serviceName, serviceName, environment, tag);
234
- console.log(`Test deployment to ${environment} completed successfully!`);
235
- } catch (error) {
236
- console.error('\nTest deployment failed:', error.message);
237
- throw error;
238
- }
239
- }
240
-
241
- export async function microserviceCopyImageToEnv(
242
- repoName,
243
- fromEnv,
244
- toEnv,
245
- tag,
246
- ) {
247
- const serviceName = String(repoName || '')
248
- .split('-')
249
- .pop()
250
- .trim();
251
- console.log(`Starting ${serviceName} image promotion...`);
252
- console.log(`From: ${fromEnv} → To: ${toEnv}`);
253
- console.log(`Tag: ${tag}`);
254
- console.log('==========================================');
255
- try {
256
- // Step 1: Copy Docker image between registries
257
- console.log('\nCopying Docker image...');
258
- const repositoryName = `${repoName}`;
259
- await copy2(repositoryName, fromEnv, toEnv, tag, serviceName);
260
- console.log('Docker image copied successfully!');
261
- } catch (error) {
262
- console.error('\nImage promotion failed:', error.message);
263
- throw error;
264
- }
265
- }
266
-
267
- export async function microserviceBuildPushImage(repoName, options = {}) {
268
- // Use environment variables as defaults, but allow overrides
269
-
270
- const serviceName = String(repoName || '')
271
- .split('-')
272
- .pop()
273
- .trim();
274
- const config = {
275
- imageName: serviceName,
276
- registryUrl: options.registryUrl || process.env.JF_REGISTRY_URL,
277
- repoName: repoName,
278
- username: options.username || process.env.JF_REGISTRY_DEV_USERNAME,
279
- password: options.password || process.env.JF_REGISTRY_DEV_PASSWORD,
280
- buildNumber: options.buildNumber || process.env.BITBUCKET_BUILD_NUMBER,
281
- tag: options.tag || process.env.VERSION_TAG,
282
- };
283
-
284
- // Validate required fields
285
- if (!config.imageName) {
286
- throw new Error(
287
- 'Image name is required. Set IMAGE_NAME or APP_NAME environment variable.',
288
- );
289
- }
290
- console.log('=== Docker Image Publishing Configuration ===');
291
- console.log(`Version Tag: ${config.tag || 'none'}`);
292
- console.log(`Registry: ${config.registryUrl}/${repoName}`);
293
- console.log('==========================================');
294
-
295
- const registryPath = `${config.registryUrl}/${repoName}-dev-docker-local`;
296
- // Docker login
297
- await $`echo ${config.password} | docker login --username ${config.username} --password-stdin ${config.registryUrl}`;
298
-
299
- try {
300
- // Build the image if it doesn't exist locally
301
- const TAG_IMAGE_NAME = `${registryPath}/${serviceName}:${options.tag}`;
302
- const imageExists = await checkLocalImage(TAG_IMAGE_NAME);
303
- let SHA_IMAGE_NAME = '';
304
- if (!imageExists) {
305
- const repoUrl = `https://${process.env.BITBUCKET_USERNAME}:${process.env.BITBUCKET_APP_PASSWORD}@bitbucket.org/dp-cloud/${repoName}.git`;
306
- await $`git clone --branch ${options.tag} --depth 1 ${repoUrl} ${repoName}`;
307
-
308
- console.log('Checking if directory exists...');
309
- await $`ls -la ${repoName}`;
310
-
311
- console.log(`Changing to directory: ${repoName}`);
312
- process.chdir(repoName);
313
-
314
- await $`cd ${repoName} && git config user.email "pipeline@bitbucket.org"`;
315
- await $`cd ${repoName} && git config user.name "Bitbucket Pipeline"`;
316
-
317
- console.log(`Attempting to checkout branch: ${options.tag}`);
318
-
319
- const gitSha = (
320
- await $`cd ${repoName} && git log ${options.tag} --pretty=format:'%h' -n 1 `
321
- ).stdout.trim();
322
- SHA_IMAGE_NAME = `${config.imageName}:sha-${gitSha}`;
323
-
324
- console.log(`Building Docker image ${SHA_IMAGE_NAME}...`);
325
- await $`cd ${repoName} && docker build -t ${SHA_IMAGE_NAME} .`;
326
- }
327
-
328
- // Array to track all tags we're pushing
329
- const tagsToPush = [];
330
-
331
- // 1. Push SHA tag
332
- const shaTag = `${registryPath}/${SHA_IMAGE_NAME}`;
333
- console.log(`Tagging and pushing SHA: ${shaTag}`);
334
- await $`docker tag ${SHA_IMAGE_NAME} ${shaTag}`;
335
- await $`docker push ${shaTag}`;
336
- tagsToPush.push(SHA_IMAGE_NAME);
337
-
338
- // 2. Push build number tag
339
- if (config.buildNumber) {
340
- const BUILD_IMAGE_NAME = `${config.imageName}:${config.buildNumber}`;
341
- const buildTag = `${registryPath}/${BUILD_IMAGE_NAME}`;
342
- console.log(`Tagging and pushing build: ${buildTag}`);
343
- await $`docker tag ${SHA_IMAGE_NAME} ${buildTag}`;
344
- await $`docker push ${buildTag}`;
345
- tagsToPush.push(BUILD_IMAGE_NAME);
346
- }
347
-
348
- // 3. Push version tag (this is what ArgoCD needs!)
349
- if (config.tag) {
350
- // Handle various tag formats
351
- let version = config.tag;
352
-
353
- // If tag contains @, extract version after it
354
- if (version.includes('@')) {
355
- version = 'v' + version.split('@')[1];
356
- }
357
-
358
- // Ensure version starts with 'v' if it's a semver without it
359
- if (/^\d+\.\d+\.\d+/.test(version) && !version.startsWith('v')) {
360
- version = 'v' + version;
361
- }
362
-
363
- const VERSION_IMAGE_NAME = `${config.imageName}:${version}`;
364
- const versionTag = `${registryPath}/${VERSION_IMAGE_NAME}`;
365
-
366
- console.log(`Tagging and pushing version: ${versionTag}`);
367
- await $`docker tag ${SHA_IMAGE_NAME} ${versionTag}`;
368
- await $`docker push ${versionTag}`;
369
- tagsToPush.push(VERSION_IMAGE_NAME);
370
-
371
- // Also push 'latest' tag when we have a version
372
- const LATEST_IMAGE_NAME = `${config.imageName}:latest`;
373
- const latestTag = `${registryPath}/${LATEST_IMAGE_NAME}`;
374
- console.log(`Tagging and pushing latest: ${latestTag}`);
375
- await $`docker tag ${SHA_IMAGE_NAME} ${latestTag}`;
376
- await $`docker push ${latestTag}`;
377
- tagsToPush.push(LATEST_IMAGE_NAME);
378
- }
379
-
380
- // 4. Check for git tags at current commit
381
- try {
382
- const gitTags = (await $`git tag --points-at HEAD`).stdout
383
- .trim()
384
- .split('\n')
385
- .filter(Boolean);
386
-
387
- if (gitTags.length > 0) {
388
- console.log(`Found git tags at HEAD: ${gitTags.join(', ')}`);
389
-
390
- for (const gitTag of gitTags) {
391
- // Skip if we already handled this tag above
392
- if (gitTag === config.tag) continue;
393
-
394
- let version = gitTag;
395
- if (version.includes('@')) {
396
- version = 'v' + version.split('@')[1];
397
- }
398
-
399
- const TAG_IMAGE_NAME = `${config.imageName}:${version}`;
400
- const gitTagPath = `${registryPath}/${TAG_IMAGE_NAME}`;
401
-
402
- console.log(`Tagging and pushing git tag: ${gitTagPath}`);
403
- await $`docker tag ${SHA_IMAGE_NAME} ${gitTagPath}`;
404
- await $`docker push ${gitTagPath}`;
405
- tagsToPush.push(TAG_IMAGE_NAME);
406
- }
407
- }
408
- } catch (e) {
409
- console.log('No git tags found at HEAD or error checking tags', e);
410
- }
411
-
412
- console.log('\n✅ Docker image published successfully!');
413
- console.log('=== Summary of pushed tags ===');
414
- tagsToPush.forEach((tag) => console.log(` ✓ ${tag}`));
415
- console.log('==============================\n');
416
-
417
- // Verify the version tag if we expect one
418
- if (config.tag) {
419
- const version = config.tag.includes('@')
420
- ? 'v' + config.tag.split('@')[1]
421
- : config.tag;
422
- const expectedTag = `${registryPath}/${config.imageName}:${version}`;
423
- console.log(`Verifying version tag exists: ${expectedTag}`);
424
- try {
425
- await $`docker manifest inspect ${expectedTag}`;
426
- console.log('✅ Version tag verified in registry!');
427
- } catch (e) {
428
- console.error('❌ WARNING: Could not verify version tag in registry!');
429
- console.error('ArgoCD may fail to pull this image.', e);
430
- }
431
- }
432
- } catch (error) {
433
- console.error('Error during image publishing:', error);
434
- throw error;
435
- } finally {
436
- // Always logout
437
- await $`docker logout ${config.registryUrl}`;
438
- }
439
- }
440
-
441
- async function checkLocalImage(imageName) {
442
- try {
443
- $.verbose = false;
444
- await $`docker image inspect ${imageName}`;
445
- return true;
446
- } catch {
447
- return false;
448
- } finally {
449
- $.verbose = true;
450
- }
451
- }
@@ -1,186 +0,0 @@
1
- //import { $ } from '../next/logger.js';
2
-
3
- /**
4
- * Publish Docker images for microservices with flexible naming
5
- * @param {string} gitSha - Git commit SHA
6
- * @param {Object} options - Configuration options
7
- * @param {string} options.imageName - Docker image name (e.g., 'swp')
8
- * @param {string} options.registryUrl - JFrog registry URL
9
- * @param {string} options.repoName - Repository name in JFrog
10
- * @param {string} options.username - JFrog username
11
- * @param {string} options.password - JFrog password
12
- * @param {string} options.buildNumber - Build number
13
- */
14
- // export async function publishMicroservice(serviceName, options = {}) {
15
- // // Use environment variables as defaults, but allow overrides
16
-
17
- // const gitSha = (await $`git log --pretty=format:'%h' -n 1 `).stdout.trim();
18
-
19
- // const config = {
20
- // imageName: serviceName,
21
- // registryUrl: options.registryUrl || process.env.JF_REGISTRY_URL,
22
- // repoName: options.repoName || process.env.JF_REGISTRY_REPO_NAME,
23
- // username: options.username || process.env.JF_REGISTRY_USER_DEV,
24
- // password: options.password || process.env.JF_REGISTRY_PASSWORD_DEV,
25
- // buildNumber: options.buildNumber || process.env.BITBUCKET_BUILD_NUMBER,
26
- // tag: options.tag || process.env.VERSION_TAG,
27
- // };
28
-
29
- // // Validate required fields
30
- // if (!config.imageName) {
31
- // throw new Error(
32
- // 'Image name is required. Set IMAGE_NAME or APP_NAME environment variable.',
33
- // );
34
- // }
35
-
36
- // console.log('=== Docker Image Publishing Configuration ===');
37
- // console.log(`Image Name: ${config.imageName}`);
38
- // console.log(`Git SHA: ${gitSha}`);
39
- // console.log(`Build Number: ${config.buildNumber}`);
40
- // console.log(`Version Tag: ${config.tag || 'none'}`);
41
- // console.log(`Registry: ${config.registryUrl}/${config.repoName}`);
42
- // console.log('==========================================');
43
-
44
- // const registryPath = `${config.registryUrl}/${config.repoName}`;
45
- // const SHA_IMAGE_NAME = `${config.imageName}:sha-${gitSha}`;
46
-
47
- // // Docker login
48
- // await $`echo ${config.password} | docker login --username ${config.username} --password-stdin ${config.registryUrl}`;
49
-
50
- // try {
51
- // // Build the image if it doesn't exist locally
52
- // const imageExists = await checkLocalImage(SHA_IMAGE_NAME);
53
- // if (!imageExists) {
54
- // console.log(`Building Docker image ${SHA_IMAGE_NAME}...`);
55
- // await $`docker build -t ${SHA_IMAGE_NAME} .`;
56
- // }
57
-
58
- // // Array to track all tags we're pushing
59
- // const tagsToPush = [];
60
-
61
- // // 1. Push SHA tag
62
- // const shaTag = `${registryPath}/${SHA_IMAGE_NAME}`;
63
- // console.log(`Tagging and pushing SHA: ${shaTag}`);
64
- // await $`docker tag ${SHA_IMAGE_NAME} ${shaTag}`;
65
- // await $`docker push ${shaTag}`;
66
- // tagsToPush.push(SHA_IMAGE_NAME);
67
-
68
- // // 2. Push build number tag
69
- // if (config.buildNumber) {
70
- // const BUILD_IMAGE_NAME = `${config.imageName}:build-${config.buildNumber}`;
71
- // const buildTag = `${registryPath}/${BUILD_IMAGE_NAME}`;
72
- // console.log(`Tagging and pushing build: ${buildTag}`);
73
- // await $`docker tag ${SHA_IMAGE_NAME} ${buildTag}`;
74
- // await $`docker push ${buildTag}`;
75
- // tagsToPush.push(BUILD_IMAGE_NAME);
76
- // }
77
-
78
- // // 3. Push version tag (this is what ArgoCD needs!)
79
- // if (config.tag) {
80
- // // Handle various tag formats
81
- // let version = config.tag;
82
-
83
- // // If tag contains @, extract version after it
84
- // if (version.includes('@')) {
85
- // version = 'v' + version.split('@')[1];
86
- // }
87
-
88
- // // Ensure version starts with 'v' if it's a semver without it
89
- // if (/^\d+\.\d+\.\d+/.test(version) && !version.startsWith('v')) {
90
- // version = 'v' + version;
91
- // }
92
-
93
- // const VERSION_IMAGE_NAME = `${config.imageName}:${version}`;
94
- // const versionTag = `${registryPath}/${VERSION_IMAGE_NAME}`;
95
-
96
- // console.log(`Tagging and pushing version: ${versionTag}`);
97
- // await $`docker tag ${SHA_IMAGE_NAME} ${versionTag}`;
98
- // await $`docker push ${versionTag}`;
99
- // tagsToPush.push(VERSION_IMAGE_NAME);
100
-
101
- // // Also push 'latest' tag when we have a version
102
- // const LATEST_IMAGE_NAME = `${config.imageName}:latest`;
103
- // const latestTag = `${registryPath}/${LATEST_IMAGE_NAME}`;
104
- // console.log(`Tagging and pushing latest: ${latestTag}`);
105
- // await $`docker tag ${SHA_IMAGE_NAME} ${latestTag}`;
106
- // await $`docker push ${latestTag}`;
107
- // tagsToPush.push(LATEST_IMAGE_NAME);
108
- // }
109
-
110
- // // 4. Check for git tags at current commit
111
- // try {
112
- // const gitTags = (await $`git tag --points-at HEAD`).stdout
113
- // .trim()
114
- // .split('\n')
115
- // .filter(Boolean);
116
-
117
- // if (gitTags.length > 0) {
118
- // console.log(`Found git tags at HEAD: ${gitTags.join(', ')}`);
119
-
120
- // for (const gitTag of gitTags) {
121
- // // Skip if we already handled this tag above
122
- // if (gitTag === config.tag) continue;
123
-
124
- // let version = gitTag;
125
- // if (version.includes('@')) {
126
- // version = 'v' + version.split('@')[1];
127
- // }
128
-
129
- // const TAG_IMAGE_NAME = `${config.imageName}:${version}`;
130
- // const gitTagPath = `${registryPath}/${TAG_IMAGE_NAME}`;
131
-
132
- // console.log(`Tagging and pushing git tag: ${gitTagPath}`);
133
- // await $`docker tag ${SHA_IMAGE_NAME} ${gitTagPath}`;
134
- // await $`docker push ${gitTagPath}`;
135
- // tagsToPush.push(TAG_IMAGE_NAME);
136
- // }
137
- // }
138
- // } catch (e) {
139
- // console.log('No git tags found at HEAD or error checking tags', e);
140
- // }
141
-
142
- // console.log('\n✅ Docker image published successfully!');
143
- // console.log('=== Summary of pushed tags ===');
144
- // tagsToPush.forEach((tag) => console.log(` ✓ ${tag}`));
145
- // console.log('==============================\n');
146
-
147
- // // Verify the version tag if we expect one
148
- // if (config.tag) {
149
- // const version = config.tag.includes('@')
150
- // ? 'v' + config.tag.split('@')[1]
151
- // : config.tag;
152
- // const expectedTag = `${registryPath}/${config.imageName}:${version}`;
153
- // console.log(`Verifying version tag exists: ${expectedTag}`);
154
- // try {
155
- // await $`docker manifest inspect ${expectedTag}`;
156
- // console.log('✅ Version tag verified in registry!');
157
- // } catch (e) {
158
- // console.error('❌ WARNING: Could not verify version tag in registry!');
159
- // console.error('ArgoCD may fail to pull this image.', e);
160
- // }
161
- // }
162
- // } catch (error) {
163
- // console.error('Error during image publishing:', error);
164
- // throw error;
165
- // } finally {
166
- // // Always logout
167
- // await $`docker logout ${config.registryUrl}`;
168
- // }
169
- // }
170
-
171
- // async function checkLocalImage(imageName) {
172
- // try {
173
- // $.verbose = false;
174
- // await $`docker image inspect ${imageName}`;
175
- // return true;
176
- // } catch {
177
- // return false;
178
- // } finally {
179
- // $.verbose = true;
180
- // }
181
- // }
182
-
183
- // // Backward compatibility wrapper
184
- // export async function publishWithDefaults(gitSha) {
185
- // return publishMicroservice(gitSha);
186
- // }
package/src/next/alias.js DELETED
@@ -1,53 +0,0 @@
1
- import { BasicAuth, DomainApi } from '@docupace/core-client';
2
-
3
- const userFilter = (userId) => {
4
- return {
5
- orSections: [
6
- {
7
- andSections: [
8
- {
9
- attrId: 9501,
10
- '@type': 'string',
11
- not: false,
12
- orSections: [
13
- { searchType: 'EXACT_MATCH', matchToValues: [userId] },
14
- ],
15
- },
16
- ],
17
- },
18
- ],
19
- };
20
- };
21
-
22
- /*
23
- Example:
24
- await createAlias(
25
- 'https://www.dev.docupaceinc.com/financialdev',
26
- 'docupace',
27
- 'pw',
28
- 'Connect',
29
- 'qhnospjRjwUAeKFDhucHEabPsfihrGQQ@clients',
30
- );
31
- */
32
- export async function createAlias(coreUrl, username, password, realm, alias) {
33
- const coreInfo = {
34
- url: coreUrl,
35
- };
36
-
37
- let auth = new BasicAuth(username, password);
38
-
39
- const domainApi = new DomainApi(coreInfo, auth);
40
-
41
- const userResults = await domainApi.listRecords(50, {
42
- filter: JSON.stringify(userFilter(username)),
43
- });
44
-
45
- const record = {
46
- domainId: 302,
47
- '5001': userResults.records[0].id,
48
- '9102': realm,
49
- '9504': alias,
50
- };
51
-
52
- await domainApi.create(record);
53
- }