@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,72 +1,72 @@
1
- import axios from 'axios';
2
-
3
- import { createAlias } from '../next/alias.js';
4
-
5
- import { getAuth0AuthToken } from './configure.js';
6
-
7
- import { getVaultSecrets } from './vault.js';
8
-
9
- import { getVaultSecretsConfigs } from '../next/config.js';
10
-
11
- import { cloneEnvRepository, readDeployConfig } from '../next/deploy.js';
12
-
13
- export async function getCCAlias({ application, auth0Domain, auth0AuthToken }) {
14
- console.log(`Forming alias name for application ${application}...`);
15
-
16
- try {
17
- const auth0Response = await axios.get(
18
- `https://${auth0Domain}/api/v2/clients`,
19
- {
20
- headers: { authorization: `Bearer ${auth0AuthToken}` },
21
- },
22
- );
23
-
24
- const appAuth0ClientIdData = auth0Response.data.find(
25
- (client) => client.name === `${application}`,
26
- );
27
- const appAuth0ClientId = appAuth0ClientIdData.client_id;
28
-
29
- console.log(`Client Credentials Alias: ${appAuth0ClientId}@clients`);
30
- return `${appAuth0ClientId}@clients`;
31
- } catch (err) {
32
- console.error(
33
- `Failed to form alias name for application: ${application}: ${err.message}`,
34
- );
35
- }
36
- }
37
-
38
- export async function configureAlias(site, env, username, password, realm) {
39
- console.log(`Creating alias for site: ${site} in env: ${env}`);
40
- // Site Common Secrets
41
- const siteCommonSecretsPath =
42
- getVaultSecretsConfigs(site).siteCommonSecretsPath;
43
- console.log(`siteCommonSecretsPath => ${siteCommonSecretsPath}`);
44
- const siteCommonSecrets = await getVaultSecrets(siteCommonSecretsPath);
45
-
46
- const auth0Domain = `docupace-${env}-${site}.us.auth0.com`;
47
- const auth0ClientId = siteCommonSecrets.AUTH0_CLIENT_ID;
48
- const auth0ClientSecret = siteCommonSecrets.AUTH0_CLIENT_SECRET;
49
- const auth0Token = await getAuth0AuthToken(
50
- auth0Domain,
51
- auth0ClientId,
52
- auth0ClientSecret,
53
- );
54
-
55
- await cloneEnvRepository(env);
56
-
57
- const { deployConfig: deployGraphQLServerConfig } = await readDeployConfig(
58
- 'graphql-server',
59
- env,
60
- site,
61
- 'values',
62
- );
63
- const coreUrl = deployGraphQLServerConfig.graphqlServer.coreUrl;
64
-
65
- const clientCredentialsAlias = await getCCAlias({
66
- application: 'docupace-graphql-client-credentials',
67
- auth0Domain: auth0Domain,
68
- auth0AuthToken: auth0Token,
69
- });
70
-
71
- await createAlias(coreUrl, username, password, realm, clientCredentialsAlias);
72
- }
1
+ import axios from 'axios';
2
+
3
+ import { createAlias } from '../next/alias.js';
4
+
5
+ import { getAuth0AuthToken } from './configure.js';
6
+
7
+ import { getVaultSecrets } from './vault.js';
8
+
9
+ import { getVaultSecretsConfigs } from '../next/config.js';
10
+
11
+ import { cloneEnvRepository, readDeployConfig } from '../next/deploy.js';
12
+
13
+ export async function getCCAlias({ application, auth0Domain, auth0AuthToken }) {
14
+ console.log(`Forming alias name for application ${application}...`);
15
+
16
+ try {
17
+ const auth0Response = await axios.get(
18
+ `https://${auth0Domain}/api/v2/clients`,
19
+ {
20
+ headers: { authorization: `Bearer ${auth0AuthToken}` },
21
+ },
22
+ );
23
+
24
+ const appAuth0ClientIdData = auth0Response.data.find(
25
+ (client) => client.name === `${application}`,
26
+ );
27
+ const appAuth0ClientId = appAuth0ClientIdData.client_id;
28
+
29
+ console.log(`Client Credentials Alias: ${appAuth0ClientId}@clients`);
30
+ return `${appAuth0ClientId}@clients`;
31
+ } catch (err) {
32
+ console.error(
33
+ `Failed to form alias name for application: ${application}: ${err.message}`,
34
+ );
35
+ }
36
+ }
37
+
38
+ export async function configureAlias(site, env, username, password, realm) {
39
+ console.log(`Creating alias for site: ${site} in env: ${env}`);
40
+ // Site Common Secrets
41
+ const siteCommonSecretsPath =
42
+ getVaultSecretsConfigs(site).siteCommonSecretsPath;
43
+ console.log(`siteCommonSecretsPath => ${siteCommonSecretsPath}`);
44
+ const siteCommonSecrets = await getVaultSecrets(siteCommonSecretsPath);
45
+
46
+ const auth0Domain = `docupace-${env}-${site}.us.auth0.com`;
47
+ const auth0ClientId = siteCommonSecrets.AUTH0_CLIENT_ID;
48
+ const auth0ClientSecret = siteCommonSecrets.AUTH0_CLIENT_SECRET;
49
+ const auth0Token = await getAuth0AuthToken(
50
+ auth0Domain,
51
+ auth0ClientId,
52
+ auth0ClientSecret,
53
+ );
54
+
55
+ await cloneEnvRepository(env);
56
+
57
+ const { deployConfig: deployGraphQLServerConfig } = await readDeployConfig(
58
+ 'graphql-server',
59
+ env,
60
+ site,
61
+ 'values',
62
+ );
63
+ const coreUrl = deployGraphQLServerConfig.graphqlServer.coreUrl;
64
+
65
+ const clientCredentialsAlias = await getCCAlias({
66
+ application: 'docupace-graphql-client-credentials',
67
+ auth0Domain: auth0Domain,
68
+ auth0AuthToken: auth0Token,
69
+ });
70
+
71
+ await createAlias(coreUrl, username, password, realm, clientCredentialsAlias);
72
+ }
package/src/auth0/cli.js CHANGED
File without changes
@@ -1,43 +1,43 @@
1
- import { getVaultSecrets } from './vault.js';
2
- import { getVaultSecretsConfigs } from '../next/config.js';
3
- import { dump } from 'auth0-deploy-cli';
4
-
5
- export async function exportConf(site, env) {
6
- try {
7
- console.log(
8
- `Exporting Auth0 configuration for site: ${site} and env: ${env}`,
9
- );
10
-
11
- const siteCommonSecretsPath =
12
- getVaultSecretsConfigs(site).siteCommonSecretsPath;
13
- console.log(`siteCommonSecretsPath => ${siteCommonSecretsPath}`);
14
- const siteCommonSecrets = await getVaultSecrets(siteCommonSecretsPath);
15
-
16
- const auth0Domain = `docupace-${env}-${site}.us.auth0.com`;
17
- const auth0ClientId = siteCommonSecrets.AUTH0_CLIENT_ID;
18
- const auth0ClientSecret = siteCommonSecrets.AUTH0_CLIENT_SECRET;
19
-
20
- const config = {
21
- config: {
22
- AUTH0_DOMAIN: auth0Domain,
23
- AUTH0_CLIENT_ID: auth0ClientId,
24
- AUTH0_CLIENT_SECRET: auth0ClientSecret,
25
- },
26
- format: 'directory',
27
- output_folder: `./auth0-${site}-export`,
28
- export_ids: false,
29
- env: false,
30
- debug: true,
31
- };
32
-
33
- console.log(`Starting Auth0 ${site} configuration export...`);
34
- await dump(config);
35
- console.log(`Auth0 ${site} configuration export completed successfully!`);
36
- } catch (error) {
37
- console.error(
38
- `Error during Auth0 ${site} configuration export:`,
39
- error.message,
40
- );
41
- process.exit(1);
42
- }
43
- }
1
+ import { getVaultSecrets } from './vault.js';
2
+ import { getVaultSecretsConfigs } from '../next/config.js';
3
+ import { dump } from 'auth0-deploy-cli';
4
+
5
+ export async function exportConf(site, env) {
6
+ try {
7
+ console.log(
8
+ `Exporting Auth0 configuration for site: ${site} and env: ${env}`,
9
+ );
10
+
11
+ const siteCommonSecretsPath =
12
+ getVaultSecretsConfigs(site).siteCommonSecretsPath;
13
+ console.log(`siteCommonSecretsPath => ${siteCommonSecretsPath}`);
14
+ const siteCommonSecrets = await getVaultSecrets(siteCommonSecretsPath);
15
+
16
+ const auth0Domain = `docupace-${env}-${site}.us.auth0.com`;
17
+ const auth0ClientId = siteCommonSecrets.AUTH0_CLIENT_ID;
18
+ const auth0ClientSecret = siteCommonSecrets.AUTH0_CLIENT_SECRET;
19
+
20
+ const config = {
21
+ config: {
22
+ AUTH0_DOMAIN: auth0Domain,
23
+ AUTH0_CLIENT_ID: auth0ClientId,
24
+ AUTH0_CLIENT_SECRET: auth0ClientSecret,
25
+ },
26
+ format: 'directory',
27
+ output_folder: `./auth0-${site}-export`,
28
+ export_ids: false,
29
+ env: false,
30
+ debug: true,
31
+ };
32
+
33
+ console.log(`Starting Auth0 ${site} configuration export...`);
34
+ await dump(config);
35
+ console.log(`Auth0 ${site} configuration export completed successfully!`);
36
+ } catch (error) {
37
+ console.error(
38
+ `Error during Auth0 ${site} configuration export:`,
39
+ error.message,
40
+ );
41
+ process.exit(1);
42
+ }
43
+ }
@@ -1,132 +1,132 @@
1
- import fs from 'fs-extra';
2
- import axios from 'axios';
3
- import path from 'path';
4
- import { cloneRepository, pushDeployConfig } from '../next/deploy.js';
5
- import { getAuth0AuthToken } from './configure.js';
6
- import { getVaultSecrets } from './vault.js';
7
- import { getVaultSecretsConfigs } from '../next/config.js';
8
-
9
- export async function getAuth0Metadata(site, env) {
10
- try {
11
- const connectDeployRepoPath = await cloneRepository('connect-deploy');
12
-
13
- // mapping of env to env
14
- const envMap = {
15
- dev: 'dev',
16
- preprod: 'qa',
17
- stage: 'stage',
18
- uat: 'uat',
19
- 'prod-www3': 'prod',
20
- };
21
- process.chdir(`${connectDeployRepoPath}/envs/${env}/${site}`);
22
-
23
- const configPath = path.join('conf', 'application.conf');
24
- const appConf = await fs.readFile(configPath, 'utf-8');
25
- const connectContext = appConf.match(
26
- /application\.context\s*=\s*"(.*?)"/,
27
- )?.[1];
28
-
29
- if (!connectContext) {
30
- console.error('connectContext not found in application.conf. Exiting...');
31
- process.exit(1);
32
- }
33
-
34
- const siteHost = appConf.match(
35
- /docupace\.baseUrlClient\s*=\s*"?https?:\/\/([^/]+)"?/,
36
- )?.[1];
37
-
38
- if (!siteHost) {
39
- console.error('siteHost not found in application.conf. Exiting...');
40
- process.exit(1);
41
- }
42
-
43
- const connectEndpoint = `https://${siteHost}${connectContext}`;
44
- console.log('CONNECT_ENDPOINT:', connectEndpoint);
45
-
46
- console.log('Requesting token from Auth0...');
47
- const siteCommonSecretsPath =
48
- getVaultSecretsConfigs(site).siteCommonSecretsPath;
49
- console.log(`siteCommonSecretsPath => ${siteCommonSecretsPath}`);
50
- const siteCommonSecrets = await getVaultSecrets(siteCommonSecretsPath);
51
- const auth0Domain = `docupace-${envMap[env]}-${site}.us.auth0.com`;
52
- const auth0ClientId = siteCommonSecrets.AUTH0_CLIENT_ID;
53
- const auth0ClientSecret = siteCommonSecrets.AUTH0_CLIENT_SECRET;
54
- const auth0Token = await getAuth0AuthToken(
55
- auth0Domain,
56
- auth0ClientId,
57
- auth0ClientSecret,
58
- );
59
-
60
- const auth0Response = await axios.get(
61
- `https://${auth0Domain}/api/v2/clients`,
62
- {
63
- headers: { authorization: `Bearer ${auth0Token}` },
64
- },
65
- );
66
-
67
- const connectClient = auth0Response.data.find(
68
- (client) => client.name === 'docupace-connect',
69
- );
70
-
71
- if (!connectClient) {
72
- console.error('Client "docupace-connect" not found.');
73
- process.exit(1);
74
- }
75
-
76
- const clientId = connectClient.client_id;
77
- console.log('Found client_id:', clientId);
78
-
79
- const metadataRes = await axios.get(
80
- `https://${auth0Domain}/samlp/metadata/${clientId}`,
81
- {
82
- responseType: 'text',
83
- },
84
- );
85
-
86
- const metadata = metadataRes.data;
87
-
88
- if (metadata.length < 2000) {
89
- console.error(
90
- 'Downloaded metadata looks incorrect (too small). Exiting...',
91
- );
92
- process.exit(1);
93
- }
94
- await fs.ensureDir('conf/saml');
95
- await fs.writeFile('conf/saml/auth0.xml', metadata);
96
- console.log('SAML metadata written to conf/saml/auth0.xml');
97
-
98
- let newConfig = appConf;
99
-
100
- if (/useSAML\s*=/.test(appConf)) {
101
- newConfig = newConfig.replace(/useSAML\s*=.*/, 'useSAML=true');
102
- } else {
103
- newConfig += '\nuseSAML=true';
104
- }
105
-
106
- const replacements = {
107
- 'saml.clients.auth0.idpMetadataPath': '${samlEnvPath}"/auth0.xml"',
108
- 'saml.clients.auth0.spEntityId': `"${connectEndpoint}"`,
109
- 'saml.clients.auth0.redirectFormInput': '"RelayState"',
110
- 'saml.clients.auth0.idpLoginUrl': `"https://${auth0Domain}/v2/logout?client_id=${clientId}&returnTo=${connectEndpoint}"`,
111
- };
112
-
113
- for (const [key, value] of Object.entries(replacements)) {
114
- const pattern = new RegExp(`${key}\\s*=.*`, 'g');
115
- if (pattern.test(newConfig)) {
116
- newConfig = newConfig.replace(pattern, `${key}=${value}`);
117
- } else {
118
- newConfig += `\n${key}=${value}`;
119
- }
120
- }
121
-
122
- await fs.writeFile(configPath, newConfig);
123
- console.log('The application.conf has been updated.');
124
- await pushDeployConfig(
125
- connectDeployRepoPath,
126
- `Auth0 SAML metadata update for site: (${site}) in env: (${env})`,
127
- );
128
- } catch (error) {
129
- console.error('Error:', error.message);
130
- process.exit(1);
131
- }
132
- }
1
+ import fs from 'fs-extra';
2
+ import axios from 'axios';
3
+ import path from 'path';
4
+ import { cloneRepository, pushDeployConfig } from '../next/deploy.js';
5
+ import { getAuth0AuthToken } from './configure.js';
6
+ import { getVaultSecrets } from './vault.js';
7
+ import { getVaultSecretsConfigs } from '../next/config.js';
8
+
9
+ export async function getAuth0Metadata(site, env) {
10
+ try {
11
+ const connectDeployRepoPath = await cloneRepository('connect-deploy');
12
+
13
+ // mapping of env to env
14
+ const envMap = {
15
+ dev: 'dev',
16
+ preprod: 'qa',
17
+ stage: 'stage',
18
+ uat: 'uat',
19
+ 'prod-www3': 'prod',
20
+ };
21
+ process.chdir(`${connectDeployRepoPath}/envs/${env}/${site}`);
22
+
23
+ const configPath = path.join('conf', 'application.conf');
24
+ const appConf = await fs.readFile(configPath, 'utf-8');
25
+ const connectContext = appConf.match(
26
+ /application\.context\s*=\s*"(.*?)"/,
27
+ )?.[1];
28
+
29
+ if (!connectContext) {
30
+ console.error('connectContext not found in application.conf. Exiting...');
31
+ process.exit(1);
32
+ }
33
+
34
+ const siteHost = appConf.match(
35
+ /docupace\.baseUrlClient\s*=\s*"?https?:\/\/([^/]+)"?/,
36
+ )?.[1];
37
+
38
+ if (!siteHost) {
39
+ console.error('siteHost not found in application.conf. Exiting...');
40
+ process.exit(1);
41
+ }
42
+
43
+ const connectEndpoint = `https://${siteHost}${connectContext}`;
44
+ console.log('CONNECT_ENDPOINT:', connectEndpoint);
45
+
46
+ console.log('Requesting token from Auth0...');
47
+ const siteCommonSecretsPath =
48
+ getVaultSecretsConfigs(site).siteCommonSecretsPath;
49
+ console.log(`siteCommonSecretsPath => ${siteCommonSecretsPath}`);
50
+ const siteCommonSecrets = await getVaultSecrets(siteCommonSecretsPath);
51
+ const auth0Domain = `docupace-${envMap[env]}-${site}.us.auth0.com`;
52
+ const auth0ClientId = siteCommonSecrets.AUTH0_CLIENT_ID;
53
+ const auth0ClientSecret = siteCommonSecrets.AUTH0_CLIENT_SECRET;
54
+ const auth0Token = await getAuth0AuthToken(
55
+ auth0Domain,
56
+ auth0ClientId,
57
+ auth0ClientSecret,
58
+ );
59
+
60
+ const auth0Response = await axios.get(
61
+ `https://${auth0Domain}/api/v2/clients`,
62
+ {
63
+ headers: { authorization: `Bearer ${auth0Token}` },
64
+ },
65
+ );
66
+
67
+ const connectClient = auth0Response.data.find(
68
+ (client) => client.name === 'docupace-connect',
69
+ );
70
+
71
+ if (!connectClient) {
72
+ console.error('Client "docupace-connect" not found.');
73
+ process.exit(1);
74
+ }
75
+
76
+ const clientId = connectClient.client_id;
77
+ console.log('Found client_id:', clientId);
78
+
79
+ const metadataRes = await axios.get(
80
+ `https://${auth0Domain}/samlp/metadata/${clientId}`,
81
+ {
82
+ responseType: 'text',
83
+ },
84
+ );
85
+
86
+ const metadata = metadataRes.data;
87
+
88
+ if (metadata.length < 2000) {
89
+ console.error(
90
+ 'Downloaded metadata looks incorrect (too small). Exiting...',
91
+ );
92
+ process.exit(1);
93
+ }
94
+ await fs.ensureDir('conf/saml');
95
+ await fs.writeFile('conf/saml/auth0.xml', metadata);
96
+ console.log('SAML metadata written to conf/saml/auth0.xml');
97
+
98
+ let newConfig = appConf;
99
+
100
+ if (/useSAML\s*=/.test(appConf)) {
101
+ newConfig = newConfig.replace(/useSAML\s*=.*/, 'useSAML=true');
102
+ } else {
103
+ newConfig += '\nuseSAML=true';
104
+ }
105
+
106
+ const replacements = {
107
+ 'saml.clients.auth0.idpMetadataPath': '${samlEnvPath}"/auth0.xml"',
108
+ 'saml.clients.auth0.spEntityId': `"${connectEndpoint}"`,
109
+ 'saml.clients.auth0.redirectFormInput': '"RelayState"',
110
+ 'saml.clients.auth0.idpLoginUrl': `"https://${auth0Domain}/v2/logout?client_id=${clientId}&returnTo=${connectEndpoint}"`,
111
+ };
112
+
113
+ for (const [key, value] of Object.entries(replacements)) {
114
+ const pattern = new RegExp(`${key}\\s*=.*`, 'g');
115
+ if (pattern.test(newConfig)) {
116
+ newConfig = newConfig.replace(pattern, `${key}=${value}`);
117
+ } else {
118
+ newConfig += `\n${key}=${value}`;
119
+ }
120
+ }
121
+
122
+ await fs.writeFile(configPath, newConfig);
123
+ console.log('The application.conf has been updated.');
124
+ await pushDeployConfig(
125
+ connectDeployRepoPath,
126
+ `Auth0 SAML metadata update for site: (${site}) in env: (${env})`,
127
+ );
128
+ } catch (error) {
129
+ console.error('Error:', error.message);
130
+ process.exit(1);
131
+ }
132
+ }