@docupace/pipeline 1.0.54 → 1.0.55

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 (44) hide show
  1. package/.prettierrc.cjs +12 -12
  2. package/README.md +135 -135
  3. package/bin/azuread_update_callbacks_for_app.sh +58 -58
  4. package/bin/next-changeset-validate.sh +8 -8
  5. package/eslint.config.js +26 -26
  6. package/next/changeset.sh +75 -75
  7. package/next/copy.sh +34 -34
  8. package/next/deploy.sh +40 -40
  9. package/next/execute.sh +123 -123
  10. package/next/sonar.sh +23 -23
  11. package/package.json +50 -50
  12. package/src/auth0/alias.js +72 -72
  13. package/src/auth0/cli.js +0 -0
  14. package/src/auth0/export.js +43 -43
  15. package/src/auth0/metadata.js +132 -132
  16. package/src/auth0/vault.js +107 -107
  17. package/src/changeset/changeset-config.js +34 -34
  18. package/src/changeset/cli.js +200 -200
  19. package/src/changeset/create.js +205 -205
  20. package/src/changeset/package-util.js +86 -86
  21. package/src/changeset/util.js +43 -43
  22. package/src/changeset/validate.js +84 -84
  23. package/src/changeset/version.js +102 -102
  24. package/src/jenkins/setParams.groovy +58 -58
  25. package/src/next/alias.js +53 -53
  26. package/src/next/apache.js +81 -73
  27. package/src/next/cli.js +228 -228
  28. package/src/next/config.js +137 -136
  29. package/src/next/connect.js +227 -227
  30. package/src/next/copy.js +61 -61
  31. package/src/next/deploy.js +595 -595
  32. package/src/next/haproxy.js +71 -71
  33. package/src/next/jira.js +84 -84
  34. package/src/next/logger.js +17 -17
  35. package/src/next/pipline.js +114 -114
  36. package/src/next/publish.js +71 -71
  37. package/src/next/pull.js +7 -7
  38. package/src/next/sonar.js +23 -23
  39. package/src/next/util.js +93 -93
  40. package/src/next/vault.js +45 -45
  41. package/terraform/apply.sh +37 -37
  42. package/terraform/init.sh +72 -72
  43. package/terraform/plan.sh +76 -76
  44. package/terraform/validate.sh +17 -17
@@ -1,71 +1,71 @@
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: 'INFP-6565-haproxy-prod-implementation',
24
- },
25
- 'prod-www3': {
26
- host: '10.13.28.45',
27
- branch: 'INFP-6565-haproxy-prod-implementation',
28
- },
29
- };
30
-
31
- const scriptContent = `
32
- #!/bin/bash
33
-
34
- [[ ! -f ${inventory} ]] && ( echo "Alert: no inventory file: ${inventory}" ; exit 1 )
35
- cd ${repoPath}
36
- pwd
37
- git stash
38
- git fetch --all
39
- git pull origin master
40
- git checkout ${cluserHostMap[cluster].branch}
41
- git submodule update --remote
42
- git submodule foreach --recursive git checkout master
43
- git submodule foreach --recursive git pull origin master
44
-
45
- ansible-playbook -i inventories/${cluster}/inventory haproxy.yml -e "cluster=${cluster} -e build=true"
46
-
47
- echo "proceeding"
48
- echo "committing changes"
49
- git add ${cluster}-haproxy.cfg
50
- git commit -m "Sync haproxy"
51
- git push origin master
52
- `;
53
-
54
- await fs.writeFile('haproxy.sh', scriptContent);
55
-
56
- // Private key
57
- const haproxyPrivateKey = process.env.HAPROXY_PRIVATE_KEY;
58
- if (!haproxyPrivateKey) {
59
- console.log('Error: HAPROXY_PRIVATE_KEY not set.');
60
- process.exit(1);
61
- }
62
-
63
- await fs.writeFile('private.key', Buffer.from(haproxyPrivateKey, 'base64'));
64
- await fs.chmod('private.key', 0o600);
65
-
66
- // Copy script to remote
67
- await $`scp -i private.key -o StrictHostKeyChecking=no haproxy.sh root@${cluserHostMap[cluster].host}:/tmp/haproxy.sh`;
68
-
69
- // Execute script on remote
70
- await $`ssh -i private.key -o StrictHostKeyChecking=no root@${cluserHostMap[cluster].host} "bash /tmp/haproxy.sh"`;
71
- }
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: 'INFP-6565-haproxy-prod-implementation',
24
+ },
25
+ 'prod-www3': {
26
+ host: '10.13.28.45',
27
+ branch: 'INFP-6565-haproxy-prod-implementation',
28
+ },
29
+ };
30
+
31
+ const scriptContent = `
32
+ #!/bin/bash
33
+
34
+ [[ ! -f ${inventory} ]] && ( echo "Alert: no inventory file: ${inventory}" ; exit 1 )
35
+ cd ${repoPath}
36
+ pwd
37
+ git stash
38
+ git fetch --all
39
+ git pull origin master
40
+ git checkout ${cluserHostMap[cluster].branch}
41
+ git submodule update --remote
42
+ git submodule foreach --recursive git checkout master
43
+ git submodule foreach --recursive git pull origin master
44
+
45
+ ansible-playbook -i inventories/${cluster}/inventory haproxy.yml -e "cluster=${cluster} -e build=true"
46
+
47
+ echo "proceeding"
48
+ echo "committing changes"
49
+ git add ${cluster}-haproxy.cfg
50
+ git commit -m "Sync haproxy"
51
+ git push origin master
52
+ `;
53
+
54
+ await fs.writeFile('haproxy.sh', scriptContent);
55
+
56
+ // Private key
57
+ const haproxyPrivateKey = process.env.HAPROXY_PRIVATE_KEY;
58
+ if (!haproxyPrivateKey) {
59
+ console.log('Error: HAPROXY_PRIVATE_KEY not set.');
60
+ process.exit(1);
61
+ }
62
+
63
+ await fs.writeFile('private.key', Buffer.from(haproxyPrivateKey, 'base64'));
64
+ await fs.chmod('private.key', 0o600);
65
+
66
+ // Copy script to remote
67
+ await $`scp -i private.key -o StrictHostKeyChecking=no haproxy.sh root@${cluserHostMap[cluster].host}:/tmp/haproxy.sh`;
68
+
69
+ // Execute script on remote
70
+ await $`ssh -i private.key -o StrictHostKeyChecking=no root@${cluserHostMap[cluster].host} "bash /tmp/haproxy.sh"`;
71
+ }
package/src/next/jira.js CHANGED
@@ -1,84 +1,84 @@
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
+ 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 +1,17 @@
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
- };
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
+ };
@@ -1,114 +1,114 @@
1
- import axios from 'axios';
2
- import { getBitbucketInfo } from './config.js';
3
-
4
- const BITBUCKET_BASE_URL = 'https://api.bitbucket.org/2.0';
5
-
6
- const BITBUCKET_WS_URL = 'https://bitbucket.org/dp-cloud';
7
-
8
- async function triggerPipelineByName(
9
- repository,
10
- pipelineName,
11
- branch,
12
- variables,
13
- ) {
14
- const { username, password, workspace } = getBitbucketInfo();
15
- const url = `${BITBUCKET_BASE_URL}/repositories/${workspace}/${repository}/pipelines/`;
16
- const auth = {
17
- username: username,
18
- password: password,
19
- };
20
-
21
- const payload = {
22
- target: {
23
- type: 'pipeline_ref_target',
24
- ref_type: 'branch',
25
- ref_name: branch,
26
- selector: {
27
- type: 'custom',
28
- pattern: pipelineName,
29
- },
30
- },
31
- variables: variables
32
- ? Object.entries(variables).map(([key, value]) => ({
33
- key,
34
- value,
35
- secured: false, // Set to true if the variable should be secure
36
- }))
37
- : undefined,
38
- };
39
-
40
- try {
41
- const response = await axios.post(url, payload, { auth });
42
- return response.data;
43
- } catch (error) {
44
- console.error(
45
- 'Error triggering custom pipeline:',
46
- error.response?.data || error.message,
47
- );
48
- throw error;
49
- }
50
- }
51
-
52
- async function getPipelineStatus(repository, pipelineUUID) {
53
- const { username, password, workspace } = getBitbucketInfo();
54
- const url = `${BITBUCKET_BASE_URL}/repositories/${workspace}/${repository}/pipelines/${pipelineUUID}`;
55
- const auth = {
56
- username: username,
57
- password: password,
58
- };
59
-
60
- try {
61
- const response = await axios.get(url, { auth });
62
- return response.data.state.name;
63
- } catch (error) {
64
- console.error(
65
- 'Error fetching pipeline status:',
66
- error.response?.data || error.message,
67
- );
68
- throw error;
69
- }
70
- }
71
-
72
- export async function runPipeline(
73
- repository,
74
- pipelineName,
75
- branch,
76
- variables,
77
- wait = false,
78
- ) {
79
- try {
80
- console.log(
81
- `Triggering custom pipeline: ${pipelineName} for branch: ${branch}...`,
82
- );
83
- const pipeline = await triggerPipelineByName(
84
- repository,
85
- pipelineName,
86
- branch,
87
- variables,
88
- );
89
-
90
- const pipelineUUID = pipeline.uuid;
91
- const buildNumber = pipeline.build_number;
92
-
93
- console.log(`Pipeline triggered with UUID: ${pipelineUUID}`);
94
- console.log(
95
- `See results here: ${BITBUCKET_WS_URL}/${repository}/piplines/results/${buildNumber}`,
96
- );
97
-
98
- if (!wait) {
99
- return;
100
- }
101
-
102
- let status = '';
103
- do {
104
- console.log('Checking pipeline status...');
105
- await new Promise((resolve) => setTimeout(resolve, 10000)); // Wait 10 seconds
106
- status = await getPipelineStatus(repository, pipelineUUID);
107
- console.log(`Pipeline status: ${status}`);
108
- } while (['IN_PROGRESS', 'PENDING', 'RUNNING'].includes(status));
109
-
110
- console.log(`Pipeline completed with status: ${status}`);
111
- } catch (error) {
112
- console.error('Error monitoring pipeline:', error.message);
113
- }
114
- }
1
+ import axios from 'axios';
2
+ import { getBitbucketInfo } from './config.js';
3
+
4
+ const BITBUCKET_BASE_URL = 'https://api.bitbucket.org/2.0';
5
+
6
+ const BITBUCKET_WS_URL = 'https://bitbucket.org/dp-cloud';
7
+
8
+ async function triggerPipelineByName(
9
+ repository,
10
+ pipelineName,
11
+ branch,
12
+ variables,
13
+ ) {
14
+ const { username, password, workspace } = getBitbucketInfo();
15
+ const url = `${BITBUCKET_BASE_URL}/repositories/${workspace}/${repository}/pipelines/`;
16
+ const auth = {
17
+ username: username,
18
+ password: password,
19
+ };
20
+
21
+ const payload = {
22
+ target: {
23
+ type: 'pipeline_ref_target',
24
+ ref_type: 'branch',
25
+ ref_name: branch,
26
+ selector: {
27
+ type: 'custom',
28
+ pattern: pipelineName,
29
+ },
30
+ },
31
+ variables: variables
32
+ ? Object.entries(variables).map(([key, value]) => ({
33
+ key,
34
+ value,
35
+ secured: false, // Set to true if the variable should be secure
36
+ }))
37
+ : undefined,
38
+ };
39
+
40
+ try {
41
+ const response = await axios.post(url, payload, { auth });
42
+ return response.data;
43
+ } catch (error) {
44
+ console.error(
45
+ 'Error triggering custom pipeline:',
46
+ error.response?.data || error.message,
47
+ );
48
+ throw error;
49
+ }
50
+ }
51
+
52
+ async function getPipelineStatus(repository, pipelineUUID) {
53
+ const { username, password, workspace } = getBitbucketInfo();
54
+ const url = `${BITBUCKET_BASE_URL}/repositories/${workspace}/${repository}/pipelines/${pipelineUUID}`;
55
+ const auth = {
56
+ username: username,
57
+ password: password,
58
+ };
59
+
60
+ try {
61
+ const response = await axios.get(url, { auth });
62
+ return response.data.state.name;
63
+ } catch (error) {
64
+ console.error(
65
+ 'Error fetching pipeline status:',
66
+ error.response?.data || error.message,
67
+ );
68
+ throw error;
69
+ }
70
+ }
71
+
72
+ export async function runPipeline(
73
+ repository,
74
+ pipelineName,
75
+ branch,
76
+ variables,
77
+ wait = false,
78
+ ) {
79
+ try {
80
+ console.log(
81
+ `Triggering custom pipeline: ${pipelineName} for branch: ${branch}...`,
82
+ );
83
+ const pipeline = await triggerPipelineByName(
84
+ repository,
85
+ pipelineName,
86
+ branch,
87
+ variables,
88
+ );
89
+
90
+ const pipelineUUID = pipeline.uuid;
91
+ const buildNumber = pipeline.build_number;
92
+
93
+ console.log(`Pipeline triggered with UUID: ${pipelineUUID}`);
94
+ console.log(
95
+ `See results here: ${BITBUCKET_WS_URL}/${repository}/piplines/results/${buildNumber}`,
96
+ );
97
+
98
+ if (!wait) {
99
+ return;
100
+ }
101
+
102
+ let status = '';
103
+ do {
104
+ console.log('Checking pipeline status...');
105
+ await new Promise((resolve) => setTimeout(resolve, 10000)); // Wait 10 seconds
106
+ status = await getPipelineStatus(repository, pipelineUUID);
107
+ console.log(`Pipeline status: ${status}`);
108
+ } while (['IN_PROGRESS', 'PENDING', 'RUNNING'].includes(status));
109
+
110
+ console.log(`Pipeline completed with status: ${status}`);
111
+ } catch (error) {
112
+ console.error('Error monitoring pipeline:', error.message);
113
+ }
114
+ }