@docupace/pipeline 1.0.7-7.micro-cli11 → 1.0.7-alpha.0

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,81 +0,0 @@
1
- import fs from 'fs-extra';
2
- import { $ } from 'zx';
3
-
4
- function log(msg) {
5
- console.log(`[*] ${msg}`);
6
- }
7
-
8
- export async function addApacheSite() {
9
- if (
10
- !process.env.ENVIRONMENT ||
11
- !['dev', 'qa', 'uat', 'stage', 'www3'].includes(process.env.ENVIRONMENT)
12
- ) {
13
- log('Error: wront ENVIRONMENT');
14
- process.exit(1);
15
- }
16
- if (!process.env.SITE) {
17
- log('Error: SITE cannot be empty.');
18
- process.exit(1);
19
- }
20
-
21
- const apacheEnvHostMap = {
22
- dev: {
23
- host1: 'dev-apalb01a.corp.docupace.com',
24
- host2: 'dev-apalb01b.corp.docupace.com',
25
- repo: 'iis-preprod',
26
- },
27
- qa: {
28
- host1: 'qa-apalb01a.corp.docupace.com',
29
- host2: 'qa-apalb01b.corp.docupace.com',
30
- repo: 'iis-preprod',
31
- },
32
- uat: {
33
- host1: 'uat-apalb01a.edc.docupace.internal',
34
- host2: 'uat-apalb01b.edc.docupace.internal',
35
- repo: 'iis-www2',
36
- },
37
- stage: {
38
- host1: 'stg-apalb01a.edc.docupace.internal',
39
- host2: 'stg-apalb01b.edc.docupace.internal',
40
- repo: 'iis-www2',
41
- },
42
- www3: {
43
- host1: 'prd-apalb05a.edc.docupace.internal',
44
- host2: 'prd-apalb05b.edc.docupace.internal',
45
- repo: 'iis-www2',
46
- },
47
- };
48
-
49
- // Save private key from base64
50
- const haproxyPrivateKey = process.env.HAPROXY_PRIVATE_KEY;
51
- if (!haproxyPrivateKey) {
52
- log('Error: HAPROXY_PRIVATE_KEY not set.');
53
- process.exit(1);
54
- }
55
-
56
- await fs.writeFile('private.key', Buffer.from(haproxyPrivateKey, 'base64'));
57
- await fs.chmod('private.key', 0o600);
58
-
59
- console.log('Running command');
60
- const sshCmd = (server, script) =>
61
- $`ssh -i private.key -o StrictHostKeyChecking=no root@${server} ${script}`;
62
-
63
- // The script is run twice in the Bash version
64
- await sshCmd(
65
- apacheEnvHostMap[process.env.ENVIRONMENT].host1,
66
- `/root/tomcat_repo_sync.sh`,
67
- );
68
- await sshCmd(
69
- apacheEnvHostMap[process.env.ENVIRONMENT].host1,
70
- `/root/repo/${apacheEnvHostMap[process.env.ENVIRONMENT].repo}/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`,
71
- );
72
-
73
- await sshCmd(
74
- apacheEnvHostMap[process.env.ENVIRONMENT].host2,
75
- `/root/tomcat_repo_sync.sh`,
76
- );
77
- await sshCmd(
78
- apacheEnvHostMap[process.env.ENVIRONMENT].host2,
79
- `/root/repo/${apacheEnvHostMap[process.env.ENVIRONMENT].repo}/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`,
80
- );
81
- }
@@ -1,226 +0,0 @@
1
- import 'zx/globals'; // npm i zx
2
- import fs from 'fs-extra';
3
- import path from 'path';
4
- import { $ } from 'zx';
5
- import { getAuth0Metadata } from '../auth0/metadata.js';
6
- import { getVaultSecrets } from '../auth0/vault.js';
7
-
8
- process.env.COMMON_VAULT_PATH =
9
- process.env.COMMON_VAULT_PATH || 'secret/data/common/config';
10
- process.env.VAULT_SKIP_VERIFY = process.env.VAULT_SKIP_VERIFY || 'true';
11
- process.env.CONNECT_DIR = process.env.CONNECT_DIR || 'connect';
12
- const vaultToken = process.env.VAULT_TOKEN;
13
- const vaultAddr = process.env.VAULT_ADDR;
14
-
15
- const connectUIEnvMap = {
16
- dev: 'dev',
17
- qa: 'preprod',
18
- stage: 'stg',
19
- uat: 'uat',
20
- prod: 'prod-www3',
21
- };
22
-
23
- const siteSettingsEnvMap = {
24
- dev: 'dev',
25
- preprod: 'preprod',
26
- qa: 'preprod',
27
- stage: 'staging',
28
- stg: 'staging',
29
- uat: 'uat',
30
- prd: 'prod',
31
- prod: 'prod',
32
- 'prod-www3': 'prod',
33
- 'prod-las': 'prod',
34
- 'prod-lax': 'prod',
35
- 'prod-athene': 'prod',
36
- 'prod-staging': 'prod',
37
- };
38
-
39
- const idpEnvMap = {
40
- dev: 'dev',
41
- preprod: 'qa',
42
- qa: 'qa',
43
- stage: 'stage',
44
- stg: 'stage',
45
- uat: 'uat',
46
- prd: 'prod',
47
- prod: 'prod',
48
- 'prod-www3': 'prod',
49
- 'prod-las': 'prod',
50
- 'prod-lax': 'prod',
51
- 'prod-athene': 'prod',
52
- 'prod-staging': 'prod',
53
- };
54
-
55
- function log(msg) {
56
- console.log(`[*] ${msg}`);
57
- }
58
-
59
- /* --------------------------------
60
- * 1. GIT CHECKOUT
61
- * -------------------------------- */
62
- async function gitCheckout(repository, destDir, branch = 'master') {
63
- if (!(await fs.pathExists(destDir))) {
64
- log(`Directory ${destDir} does not exist. Cloning repository...`);
65
- } else {
66
- log(`Directory ${destDir} exists. Removing it...`);
67
- await fs.remove(destDir);
68
- log(`Cloning ${destDir} repository...`);
69
- }
70
-
71
- const username = process.env.BITBUCKET_USERNAME;
72
- const password = process.env.BITBUCKET_APP_PASSWORD;
73
-
74
- // Construct clone command
75
- const cloneUrl = `https://${username}:${password}@bitbucket.org/dp-cloud/${repository}.git`;
76
-
77
- log(`Perform cloning`);
78
- await $`git clone --branch=${branch} --depth 1 ${cloneUrl} ${destDir}`;
79
- }
80
-
81
- export async function connectClone() {
82
- // const connectFromEnv = connectUIEnvMap[process.env.FROM_BUILD_ENVIRONMENT];
83
- const connectFromEnv = process.env.FROM_BUILD_ENVIRONMENT;
84
- const connectToEnv = process.env.BUILD_ENVIRONMENT;
85
-
86
- if (!vaultToken || !vaultAddr) {
87
- console.error('Error: VAULT_TOKEN and VAULT_ADDR must be set.');
88
- throw new Error('VAULT_TOKEN and VAULT_ADDR must be set.');
89
- }
90
-
91
- const site = process.env.BUILD_SITE;
92
- if (!site) {
93
- log('Error: BUILD_SITE is not set');
94
- process.exit(1);
95
- }
96
- const siteCommonVaultPath = `secret/data/${site}/common/config`;
97
-
98
- // 2) getVaultSecrets
99
- const secretsJson = await getVaultSecrets(siteCommonVaultPath);
100
- if (!secretsJson.AUTH0_CLIENT_ID) {
101
- log('Failed to retrieve secret data.');
102
- process.exit(1);
103
- }
104
- const siteCommonSecrets = secretsJson;
105
-
106
- // 3) Export secrets as environment variables
107
- process.env.AUTH0_CLIENT_ID = siteCommonSecrets.AUTH0_CLIENT_ID;
108
- process.env.AUTH0_CLIENT_SECRET = siteCommonSecrets.AUTH0_CLIENT_SECRET;
109
-
110
- process.env.AUTH0_REGION_DOMAIN = 'us.auth0.com';
111
-
112
- log(`BUILD_ENVIRONMENT: ${connectToEnv}`);
113
- log(`BUILD_SITE: ${process.env.BUILD_SITE}`);
114
- log(`AUTH0_SUBDOMAIN: ${process.env.AUTH0_SUBDOMAIN}`);
115
- log(`AUTH0_REGION_DOMAIN: ${process.env.AUTH0_REGION_DOMAIN}`);
116
- log(`AUTH0_CLIENT_ID: ${process.env.AUTH0_CLIENT_ID}`);
117
-
118
- process.env.AUTH0_DOMAIN = `docupace-${idpEnvMap[process.env.BUILD_ENVIRONMENT]}-${process.env.BUILD_SITE}.${process.env.AUTH0_REGION_DOMAIN}`;
119
-
120
- const projectRoot = process.cwd();
121
- // 4) Clone 'connect-deploy' into CONNECT_DIR
122
-
123
- await gitCheckout('connect-deploy', process.env.CONNECT_DIR);
124
-
125
- await gitCheckout(
126
- `${siteSettingsEnvMap[connectToEnv]}-site-settings`,
127
- `${process.env.CONNECT_DIR}/${siteSettingsEnvMap[connectToEnv]}-site-settings`,
128
- );
129
-
130
- // 5) Create site clone (emulating the dock.sh call)
131
- const cloneFrom = path.join(
132
- projectRoot,
133
- process.env.CONNECT_DIR,
134
- `envs`,
135
- `${connectFromEnv}/${process.env.FROM_BUILD_SITE}`,
136
- );
137
- const cloneTo = path.join(
138
- projectRoot,
139
- process.env.CONNECT_DIR,
140
- `envs`,
141
- `${connectToEnv}/${process.env.BUILD_SITE}`,
142
- );
143
-
144
- if (!(await fs.pathExists(cloneFrom))) {
145
- log('Clone template directory not found:');
146
- process.exit(1);
147
- }
148
-
149
- if (!(await fs.pathExists(cloneTo))) {
150
- log('New site does not exist. Performing cloning...');
151
-
152
- process.env.IMAGE_VERSION =
153
- await $`cd ${cloneFrom} && grep -E '^IMAGE_VERSION=' dock.sh | cut -f2 -d=`;
154
- log(`Image version: ${process.env.IMAGE_VERSION}`);
155
- //await $`cd ${cloneFrom} && bash dock.sh clone ${process.env.BUILD_ENVIRONMENT} ${process.env.BUILD_SITE} ${process.env.IMAGE_VERSION}`;
156
- await (async () => {
157
- try {
158
- // Execute the shell command
159
- const result =
160
- await $`cd ${cloneFrom} && bash dock.sh clone ${connectToEnv} ${process.env.BUILD_SITE} ${process.env.IMAGE_VERSION}`;
161
- await $`cd ${cloneTo} && git checkout master && git pull --ff-only`;
162
- await $`cd ${cloneTo} && git remote -v`;
163
- await $`cd ${cloneTo} && git branch`;
164
- await $`cd ${cloneTo} && git status`;
165
- await $`cd ${cloneTo} && git add . ../sites.sh`;
166
-
167
- console.log('Command succeeded:');
168
- console.log('stdout:', result.stdout); // Standard output
169
- console.log('stderr:', result.stderr); // Standard error
170
- } catch (error) {
171
- console.error('Command failed:');
172
- console.error('Exit Code:', error._code); // Exit code of the command
173
- console.error('Signal:', error._signal); // Signal that caused termination (if any)
174
- console.error('stdout:', error._stdout); // Standard output
175
- console.error('stderr:', error._stderr); // Standard error
176
- }
177
- })();
178
- } else {
179
- log('Site already exists. Continuing Auth0 setup...');
180
- }
181
-
182
- // await (async () => {
183
- // try {
184
- // // Execute the shell command
185
- // //await getAuth0Metadata(process.env.BUILD_SITE, connectToEnv);
186
- // const result = await $`cd ${cloneTo} && bash dock.sh getAuth0Metadata`;
187
- // console.log('Command succeeded:');
188
- // console.log('stdout:', result.stdout); // Standard output
189
- // console.log('stderr:', result.stderr); // Standard error
190
- // } catch (error) {
191
- // console.error('Command failed:');
192
- // console.error('Exit Code:', error._code); // Exit code of the command
193
- // console.error('Signal:', error._signal); // Signal that caused termination (if any)
194
- // console.error('stdout:', error._stdout); // Standard output
195
- // console.error('stderr:', error._stderr); // Standard error
196
- // }
197
- // })();
198
-
199
- // 7) Check conf files, print logs
200
- // await $`grep "auth0" ${path.join(cloneTo, 'conf/application.conf')}`;
201
- // await $`ls -all ${path.join(cloneTo, 'conf')}`;
202
- // await $`ls -all ${path.join(cloneTo, 'conf/saml')}`;
203
- // await $`cat ${path.join(cloneTo, 'conf/saml/auth0.xml')}`;
204
-
205
- // 8) Git add, commit, push
206
- // await $`cd ${cloneTo} && git add ./conf/application.conf ./conf/saml/auth0.xml`;
207
- //await $`cd ${cloneTo} && git add ./conf/application.conf`;
208
- //await $`cd ${cloneTo} && git status`;
209
-
210
- const numChanges = (await $`cd ${cloneTo} && git diff-index HEAD`).stdout
211
- .split('\n')
212
- .filter(Boolean).length;
213
-
214
- if (numChanges > 0) {
215
- const jiraTicket = process.env.JIRA_TICKET || 'NO_JIRA';
216
- const message = `${jiraTicket} usdoc-s-builui job download_auth0_metadata for ${connectToEnv}/${process.env.BUILD_SITE}`;
217
- log('About to commit changes to git');
218
- await $`cd ${cloneTo} && git commit -m ${message}`;
219
- await $`cd ${cloneTo} && git push -u origin master`;
220
- //await getAuth0Metadata(process.env.BUILD_SITE, connectToEnv);
221
- } else {
222
- log(
223
- 'No changes have been made. The site likely already has the correct configuration.',
224
- );
225
- }
226
- }
@@ -1,79 +0,0 @@
1
- /**
2
- * Converts git describe output to semantic versioning format
3
- *
4
- * Logic based on dash count:
5
- * - 2 dashes: Released version with commits (v1.2.3-4-g1234567 -> 1.2.3+4.g1234567)
6
- * - 3 dashes: Pre-release with commits (v1.2.3-rc.1-4-g1234567 -> 1.2.3-rc.1+4.g1234567)
7
- * - 1 dash: Pre-release tag only (v1.2.3-rc.1 -> 1.2.3-rc.1)
8
- * - 0 dashes: Clean tag (v1.2.3 -> 1.2.3)
9
- *
10
- * @param {string} gitDescribe - The output from git describe
11
- * @return {string} Semver compatible version string
12
- */
13
- export function gitDescribeToSemver(gitDescribe) {
14
- if (!gitDescribe || typeof gitDescribe !== 'string') {
15
- throw new Error('Invalid input: git describe string required');
16
- }
17
-
18
- // Remove leading 'v' if present
19
- let version = gitDescribe.trim();
20
- if (version.startsWith('v') || version.startsWith('V')) {
21
- version = version.substring(1);
22
- }
23
-
24
- // Count dashes to determine format
25
- const dashCount = (version.match(/-/g) || []).length;
26
-
27
- switch (dashCount) {
28
- case 0:
29
- // Clean tag: 1.2.3
30
- return version;
31
-
32
- case 1:
33
- // Pre-release tag only: 1.2.3-rc.1
34
- return version;
35
-
36
- case 2: {
37
- // Released version with commits: 1.2.3-4-g1234567
38
- // Split: [1.2.3, 4, g1234567]
39
- const parts = version.split('-');
40
- const baseVersion = parts[0];
41
- const commits = parts[1];
42
- const hash = parts[2];
43
- return `${baseVersion}+${commits}.${hash}`;
44
- }
45
-
46
- case 3: {
47
- // Pre-release with commits: 1.2.3-rc.1-4-g1234567
48
- // Split: [1.2.3, rc.1, 4, g1234567]
49
- const parts = version.split('-');
50
- const baseVersion = parts[0];
51
- const prerelease = parts[1];
52
- const commits = parts[2];
53
- const hash = parts[3];
54
- return `${baseVersion}-${prerelease}+${commits}.${hash}`;
55
- }
56
-
57
- default: {
58
- // More than 3 dashes - handle complex pre-release tags
59
- // e.g., 1.2.3-rc-1-beta-4-g1234567
60
- // Assume last two parts are commits-hash
61
- const parts = version.split('-');
62
- if (
63
- parts.length >= 3 &&
64
- /^\d+$/.test(parts[parts.length - 2]) &&
65
- /^g[a-f0-9]+$/.test(parts[parts.length - 1])
66
- ) {
67
- // Has commits and hash at the end
68
- const commits = parts[parts.length - 2];
69
- const hash = parts[parts.length - 1];
70
- const versionParts = parts.slice(0, -2);
71
- const baseVersion = versionParts[0];
72
- const prerelease = versionParts.slice(1).join('-');
73
- return `${baseVersion}-${prerelease}+${commits}.${hash}`;
74
- }
75
- // No commits/hash pattern found, treat as complex pre-release
76
- return version;
77
- }
78
- }
79
- }
@@ -1,76 +0,0 @@
1
- import { $ } from 'zx';
2
- import fs from 'fs-extra';
3
- import path from 'path';
4
-
5
- export async function haproxySync() {
6
- const cluster = process.env.HAPROXY_CLUSTER;
7
- if (cluster !== 'preprod' && cluster !== 'stage' && cluster !== 'prod-www3') {
8
- console.log('Error: Cluster must be preprod or stage');
9
- process.exit(1);
10
- }
11
-
12
- const repoPath = '/root/repo/docupace-ansible';
13
- const inventory = path.join(repoPath, `inventories/${cluster}/inventory`);
14
-
15
- // Create haproxy.sh
16
- const cluserHostMap = {
17
- preprod: {
18
- host: '10.10.28.198',
19
- branch: 'master',
20
- },
21
- stage: {
22
- host: '10.12.28.10',
23
- branch: 'master',
24
- },
25
- 'prod-www2': {
26
- host: ' 10.13.28.43',
27
- branch: 'master',
28
- },
29
- 'prod-www3': {
30
- host: '10.13.28.45',
31
- branch: 'master',
32
- },
33
- };
34
-
35
- const scriptContent = `
36
- #!/bin/bash
37
-
38
- [[ ! -f ${inventory} ]] && ( echo "Alert: no inventory file: ${inventory}" ; exit 1 )
39
- cd ${repoPath}
40
- pwd
41
- git reset --hard
42
- git clean -fd
43
- git fetch --all
44
- git pull origin master
45
- git checkout ${cluserHostMap[cluster].branch}
46
- git submodule update --remote
47
- git submodule foreach --recursive git checkout master
48
- git submodule foreach --recursive git pull origin master
49
-
50
- ansible-playbook -i inventories/${cluster}/inventory haproxy.yml -e "cluster=${cluster} -e build=true"
51
-
52
- echo "proceeding"
53
- echo "committing changes"
54
- git add ${cluster}-haproxy.cfg
55
- git commit -m "Sync haproxy"
56
- git push origin master
57
- `;
58
-
59
- await fs.writeFile('haproxy.sh', scriptContent);
60
-
61
- // Private key
62
- const haproxyPrivateKey = process.env.HAPROXY_PRIVATE_KEY;
63
- if (!haproxyPrivateKey) {
64
- console.log('Error: HAPROXY_PRIVATE_KEY not set.');
65
- process.exit(1);
66
- }
67
-
68
- await fs.writeFile('private.key', Buffer.from(haproxyPrivateKey, 'base64'));
69
- await fs.chmod('private.key', 0o600);
70
-
71
- // Copy script to remote
72
- await $`scp -i private.key -o StrictHostKeyChecking=no haproxy.sh root@${cluserHostMap[cluster].host}:/tmp/haproxy.sh`;
73
-
74
- // Execute script on remote
75
- await $`ssh -i private.key -o StrictHostKeyChecking=no root@${cluserHostMap[cluster].host} "bash /tmp/haproxy.sh"`;
76
- }
package/src/next/jira.js DELETED
@@ -1,84 +0,0 @@
1
- import axios from 'axios';
2
-
3
- // Create preconfigured axios instance for Jira
4
- const jiraClient = axios.create({
5
- baseURL: 'https://docupacellc.atlassian.net',
6
- auth: {
7
- username: process.env.JIRA_API_EMAIL,
8
- password: process.env.JIRA_API_KEY,
9
- },
10
- headers: {
11
- 'Content-Type': 'application/json',
12
- },
13
- });
14
-
15
- /**
16
- * Updates the component version custom field in Jira
17
- * @param {string} issueKey - The Jira issue key
18
- * @param {string} packageName - The package name
19
- * @param {string} version - The version to set
20
- */
21
- export async function updateComponentVersion(issueKey, packageName, version) {
22
- const component = packageName.includes('/')
23
- ? packageName.split('/')[1]
24
- : packageName;
25
- console.log(
26
- `Updating ${issueKey} for package ${packageName} translated to component ${component} with version ${version}`,
27
- );
28
- try {
29
- // First get current field value
30
- const response = await jiraClient.get(
31
- `/rest/api/2/issue/${issueKey}?fields=customfield_10458`,
32
- );
33
-
34
- let currentValue = response.data.fields.customfield_10458 || '';
35
- let components = new Map();
36
-
37
- try {
38
- // Parse existing components
39
- if (currentValue) {
40
- currentValue.split(';').forEach((entry) => {
41
- const [comp, ver] = entry.split(':');
42
- components.set(comp, ver);
43
- });
44
- }
45
- // Update or add new component version
46
- } catch {
47
- console.log('Patch version has incorrect data overriding');
48
- }
49
-
50
- components.set(component, version);
51
-
52
- // Convert back to string format
53
- const newValue = Array.from(components.entries())
54
- .map(([comp, ver]) => `${comp}:${ver}`)
55
- .join(';');
56
-
57
- // Update the field
58
- await jiraClient.put(`/rest/api/2/issue/${issueKey}`, {
59
- fields: {
60
- customfield_10458: newValue,
61
- },
62
- });
63
-
64
- console.log(`Updated component versions for ${issueKey}: ${newValue}`);
65
- } catch (error) {
66
- console.error(`Error updating Jira component version: ${error.message}`);
67
- }
68
- }
69
-
70
- /**
71
- * Makes a request to the Jira API using preconfigured client
72
- * @param {string} endpoint - The API endpoint (starting with /)
73
- * @param {Object} options - Request options (method, body, etc)
74
- * @returns {Promise<any>} The response data
75
- */
76
- export async function makeJiraRequest(endpoint, options = {}) {
77
- try {
78
- const response = await jiraClient.get(endpoint, options);
79
- return response.data;
80
- } catch (error) {
81
- console.error(`Error making Jira request: ${error.message}`);
82
- throw error;
83
- }
84
- }
@@ -1,17 +0,0 @@
1
- import { $ as original$ } from 'zx';
2
-
3
- // Wrapped version of $
4
- export const $ = async (strings, ...values) => {
5
- const command = strings.reduce(
6
- (acc, str, i) => acc + str + (values[i] ?? ''),
7
- '',
8
- );
9
- console.log(`Executing: ${command}`);
10
- try {
11
- const result = await original$(strings, ...values);
12
- return result;
13
- } catch (error) {
14
- console.error(`Error executing: ${command}`, error);
15
- throw error;
16
- }
17
- };
package/src/next/test.js DELETED
@@ -1,5 +0,0 @@
1
- import { getBranchNameFromVersion } from './deploy.js';
2
-
3
- getBranchNameFromVersion('25.2.0-alpha.18-3-g4e0e088aa0');
4
- getBranchNameFromVersion('25.1.13-0-g7798cf7138');
5
- getBranchNameFromVersion('25.1.13-3-g7798cf7138');
package/src/next/util.js DELETED
@@ -1,93 +0,0 @@
1
- import { existsSync } from 'fs';
2
- import path, { join } from 'path';
3
- import { $ } from 'zx';
4
-
5
- export function isMonoRepo() {
6
- // Check for the presence of turbo.json which indicates a Turborepo monorepo
7
- return existsSync(join(process.cwd(), 'turbo.json'));
8
- }
9
-
10
- /**
11
- * Gets the packages that have changed between two git references (branches or tags)
12
- * @param {string} fromRef - The starting git reference (branch or tag)
13
- * @param {string} toRef - The ending git reference (branch or tag)
14
- * @returns {Promise<Array<{name: string, path: string}>>} - Array of changed packages with name and path
15
- */
16
- export async function getChangedPackagesInternal(fromRef, toRef) {
17
- try {
18
- console.log(process.cwd());
19
- // Run the turbo command to get changed packages between branches
20
- const filterArg = `[${fromRef}...${toRef}]`;
21
- const turboDryOutput =
22
- await $`turbo run build --filter=${filterArg} --dry=json`;
23
-
24
- const dryRunJson = turboDryOutput.stdout.trim();
25
-
26
- const dryRun = JSON.parse(dryRunJson);
27
-
28
- const packages = dryRun.tasks.map((task) => ({
29
- name: task.package,
30
- directory: task.directory,
31
- path: path.resolve(process.cwd(), task.directory),
32
- }));
33
-
34
- return packages;
35
- } catch (error) {
36
- console.error('Error getting changed packages:', error);
37
- return [];
38
- }
39
- }
40
-
41
- export async function getAllPackages() {
42
- try {
43
- const turboDryOutput = await $`turbo run build --dry=json`;
44
- const dryRunJson = turboDryOutput.stdout.trim();
45
- const dryRun = JSON.parse(dryRunJson);
46
-
47
- const packages = dryRun.tasks.map((task) => ({
48
- name: task.package,
49
- directory: task.directory,
50
- path: path.resolve(process.cwd(), task.directory),
51
- }));
52
-
53
- return packages;
54
- } catch (error) {
55
- console.error('Error getting changed packages:', error);
56
- return [];
57
- }
58
- }
59
-
60
- export async function getAllAppPackages() {
61
- const changedPackages = await getAllPackages();
62
- const appPackages = changedPackages.filter((appPackage) =>
63
- appPackage.directory.startsWith('apps'),
64
- );
65
- return appPackages;
66
- }
67
-
68
- export async function getChangedPackages() {
69
- const branch = process.env.BITBUCKET_BRANCH;
70
- const destBranch = process.env.BITBUCKET_PR_DESTINATION_BRANCH;
71
-
72
- await $`git fetch origin ${destBranch}:${destBranch}`;
73
- console.log(`Getting changed packages for [${destBranch}...${branch}]`);
74
- const changedPackages = await getChangedPackagesInternal(destBranch, branch);
75
- console.log('Changed Packages:\n', JSON.stringify(changedPackages, null, 2));
76
- return changedPackages;
77
- }
78
-
79
- export async function getChangedAppPackages() {
80
- const changedPackages = await getChangedPackages();
81
- const appPackages = changedPackages.filter((appPackage) =>
82
- appPackage.directory.startsWith('apps'),
83
- );
84
- return appPackages;
85
- }
86
-
87
- export async function setGitInfo() {
88
- if (!process.env.IS_DEV) {
89
- await $`git config --global user.email "gitops@docupace.com"`;
90
- await $`git config --global user.name "Gitops"`;
91
- await $`git remote set-url origin https://${process.env.THIS_REP_TOKEN}@bitbucket.org/${process.env.BITBUCKET_REPO_FULL_NAME}.git`;
92
- }
93
- }