@docupace/pipeline 1.0.39-matttest.24 → 1.0.39-matttest.25
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.
- package/package.json +1 -1
- package/src/auth0/configure.js +4 -4
- package/src/auth0/metadata.js +1 -2
- package/src/changeset/cli.js +1 -2
- package/src/changeset/validate.js +21 -6
- package/src/jenkins/setParams.groovy +1 -2
- package/src/next/apache.js +38 -35
- package/src/next/cli.js +4 -6
- package/src/next/deploy.js +1 -1
- package/src/next/haproxy.js +25 -26
- package/src/next/util.js +7 -6
- package/src/next/vault.js +7 -5
package/package.json
CHANGED
package/src/auth0/configure.js
CHANGED
|
@@ -5,16 +5,16 @@ import crypto from 'crypto';
|
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
cloneEnvRepository,
|
|
8
|
-
readDeployConfig,
|
|
9
|
-
pushDeployConfig,
|
|
10
8
|
cloneRepository,
|
|
9
|
+
pushDeployConfig,
|
|
10
|
+
readDeployConfig,
|
|
11
11
|
} from '../next/deploy.js';
|
|
12
12
|
|
|
13
13
|
import { getVaultSecrets, updateVaultSecrets } from './vault.js';
|
|
14
14
|
import {
|
|
15
|
-
getVaultSecretsConfigs,
|
|
16
|
-
environmentConfig,
|
|
17
15
|
coreSiteEnvMap,
|
|
16
|
+
environmentConfig,
|
|
17
|
+
getVaultSecretsConfigs,
|
|
18
18
|
} from '../next/config.js';
|
|
19
19
|
|
|
20
20
|
async function ensureDirectoryExists(dirPath) {
|
package/src/auth0/metadata.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import { cloneRepository } from '../next/deploy.js';
|
|
4
|
+
import { cloneRepository, pushDeployConfig } from '../next/deploy.js';
|
|
5
5
|
import { getAuth0AuthToken } from './configure.js';
|
|
6
6
|
import { getVaultSecrets } from './vault.js';
|
|
7
7
|
import { getVaultSecretsConfigs } from '../next/config.js';
|
|
8
|
-
import { pushDeployConfig } from '../next/deploy.js';
|
|
9
8
|
|
|
10
9
|
export async function getAuth0Metadata(site, env) {
|
|
11
10
|
try {
|
package/src/changeset/cli.js
CHANGED
|
@@ -3,10 +3,9 @@ import { Command } from 'commander';
|
|
|
3
3
|
import { $ } from 'zx';
|
|
4
4
|
import { validateChangesets } from './validate.js';
|
|
5
5
|
import dotenv from 'dotenv';
|
|
6
|
-
import {
|
|
6
|
+
import { isMonoRepo, setGitInfo } from '../next/util.js';
|
|
7
7
|
import { updateJiraWithVersion, versionCommand } from './version.js';
|
|
8
8
|
import { createChangeset } from './create.js';
|
|
9
|
-
import { getPackage } from './util.js';
|
|
10
9
|
|
|
11
10
|
dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
|
|
12
11
|
|
|
@@ -4,20 +4,35 @@ import { $ } from 'zx';
|
|
|
4
4
|
|
|
5
5
|
import { isMonoRepo, setGitInfo } from '../next/util.js';
|
|
6
6
|
import { versionStatus } from './version.js';
|
|
7
|
-
import { getAppReleases } from './cli.js';
|
|
8
7
|
|
|
9
8
|
const CHANGESET_DIR = '.changeset';
|
|
10
9
|
|
|
10
|
+
function areArraysEqualIgnoringOrder(arr1, arr2) {
|
|
11
|
+
if (arr1.length !== arr2.length) return false;
|
|
12
|
+
|
|
13
|
+
const sortedA = [...arr1].sort();
|
|
14
|
+
const sortedB = [...arr2].sort();
|
|
15
|
+
|
|
16
|
+
return sortedA.every((element, index) => element === sortedB[index]);
|
|
17
|
+
}
|
|
18
|
+
|
|
11
19
|
export async function validateChangesets() {
|
|
12
20
|
if (isMonoRepo()) {
|
|
13
21
|
await setGitInfo();
|
|
14
22
|
const destBranch = process.env.BITBUCKET_PR_DESTINATION_BRANCH;
|
|
15
23
|
await $`git fetch origin ${destBranch}:${destBranch}`;
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
await versionStatus(destBranch);
|
|
25
|
+
/*const changedPackages = await getChangedPackages();
|
|
26
|
+
const releaseNames = releases.map((release) => release.name);
|
|
27
|
+
const changedPackageNames = changedPackages.map(
|
|
28
|
+
(changedPackage) => changedPackage.name,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
if (!areArraysEqualIgnoringOrder(releaseNames, changedPackageNames)) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
'Changesets must be created for all packages created and for those that have those changed as dependencies',
|
|
34
|
+
);
|
|
35
|
+
}*/
|
|
21
36
|
} else {
|
|
22
37
|
await validateChangesetPath(path.resolve(process.cwd(), CHANGESET_DIR));
|
|
23
38
|
}
|
package/src/next/apache.js
CHANGED
|
@@ -1,40 +1,43 @@
|
|
|
1
1
|
import { $ } from 'zx';
|
|
2
2
|
|
|
3
3
|
export async function addApacheSite() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// Save private key from base64
|
|
17
|
-
const haproxyPrivateKey = process.env.HAPROXY_PRIVATE_KEY;
|
|
18
|
-
if (!haproxyPrivateKey) {
|
|
19
|
-
log('Error: HAPROXY_PRIVATE_KEY not set.');
|
|
20
|
-
process.exit(1);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
await fs.writeFile('private.key', Buffer.from(haproxyPrivateKey, 'base64'));
|
|
24
|
-
await fs.chmod('private.key', 0o600);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
console.log("Running command");
|
|
28
|
-
const sshCmd = (server,script) =>
|
|
29
|
-
$`ssh -i private.key -o StrictHostKeyChecking=no root@${server} ${script}`;
|
|
30
|
-
|
|
31
|
-
let server = `${process.env.ENVIRONMENT}-apalb01a.corp.docupace.com`;
|
|
32
|
-
// The script is run twice in the Bash version
|
|
33
|
-
await sshCmd(server, `/root/repo/iis-preprod/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`);
|
|
34
|
-
|
|
35
|
-
server = `${process.env.ENVIRONMENT}-apalb01b.corp.docupace.com`;
|
|
4
|
+
if (
|
|
5
|
+
!process.env.ENVIRONMENT ||
|
|
6
|
+
(process.env.ENVIRONMENT !== 'dev' && process.env.ENVIRONMENT !== 'qa')
|
|
7
|
+
) {
|
|
8
|
+
log("Error: ENVIRONMENT must be either 'dev' or 'qa'.");
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
if (!process.env.SITE) {
|
|
12
|
+
log('Error: SITE cannot be empty.');
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
36
15
|
|
|
37
|
-
|
|
16
|
+
// Save private key from base64
|
|
17
|
+
const haproxyPrivateKey = process.env.HAPROXY_PRIVATE_KEY;
|
|
18
|
+
if (!haproxyPrivateKey) {
|
|
19
|
+
log('Error: HAPROXY_PRIVATE_KEY not set.');
|
|
20
|
+
process.exit(1);
|
|
38
21
|
}
|
|
39
|
-
|
|
40
|
-
|
|
22
|
+
|
|
23
|
+
await fs.writeFile('private.key', Buffer.from(haproxyPrivateKey, 'base64'));
|
|
24
|
+
await fs.chmod('private.key', 0o600);
|
|
25
|
+
|
|
26
|
+
console.log('Running command');
|
|
27
|
+
const sshCmd = (server, script) =>
|
|
28
|
+
$`ssh -i private.key -o StrictHostKeyChecking=no root@${server} ${script}`;
|
|
29
|
+
|
|
30
|
+
let server = `${process.env.ENVIRONMENT}-apalb01a.corp.docupace.com`;
|
|
31
|
+
// The script is run twice in the Bash version
|
|
32
|
+
await sshCmd(
|
|
33
|
+
server,
|
|
34
|
+
`/root/repo/iis-preprod/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
server = `${process.env.ENVIRONMENT}-apalb01b.corp.docupace.com`;
|
|
38
|
+
|
|
39
|
+
await sshCmd(
|
|
40
|
+
server,
|
|
41
|
+
`/root/repo/iis-preprod/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`,
|
|
42
|
+
);
|
|
43
|
+
}
|
package/src/next/cli.js
CHANGED
|
@@ -7,26 +7,24 @@ import { publish } from './publish.js';
|
|
|
7
7
|
import {
|
|
8
8
|
deployAppWithTag,
|
|
9
9
|
deployFromSite,
|
|
10
|
+
deployTemplate,
|
|
10
11
|
getDefaultDeploySite,
|
|
11
12
|
getDeployTag,
|
|
12
13
|
} from './deploy.js';
|
|
13
|
-
import { deployTemplate } from './deploy.js';
|
|
14
14
|
import { copy } from './copy.js';
|
|
15
15
|
import { vaultAddSiteData } from './vault.js';
|
|
16
16
|
import { addApacheSite } from './apache.js';
|
|
17
17
|
import { haproxySync } from './haproxy.js';
|
|
18
18
|
import { connectClone } from './connect.js';
|
|
19
19
|
import dotenv from 'dotenv';
|
|
20
|
+
import { $ } from 'zx';
|
|
21
|
+
import { deployConnect, deployCore } from './jenkins.js';
|
|
22
|
+
import { runPipeline } from './pipline.js';
|
|
20
23
|
|
|
21
24
|
dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
|
|
22
25
|
|
|
23
26
|
const program = new Command();
|
|
24
27
|
|
|
25
|
-
import { $ } from 'zx';
|
|
26
|
-
import { deployConnect, deployCore } from './jenkins.js';
|
|
27
|
-
import { runPipeline } from './pipline.js';
|
|
28
|
-
import { buildChangePackages } from './util.js';
|
|
29
|
-
|
|
30
28
|
const GIT_SHA = (await $`git log --pretty=format:'%h' -n 1`).stdout.trim();
|
|
31
29
|
|
|
32
30
|
program
|
package/src/next/deploy.js
CHANGED
|
@@ -6,7 +6,7 @@ import lodash from 'lodash';
|
|
|
6
6
|
import { appInfo, environmentConfig, getRepUrl } from './config.js';
|
|
7
7
|
import { copy2 } from './copy.js';
|
|
8
8
|
import axios from 'axios';
|
|
9
|
-
import {
|
|
9
|
+
import { deployConnect, deployCore } from './jenkins.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Clone the repository, read the YAML file, and return the parsed data and file paths.
|
package/src/next/haproxy.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { $ } from 'zx';
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
export async function haproxySync() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const repoPath = '/root/repo/docupace-ansible';
|
|
5
|
+
const inventory = path.join(repoPath, 'inventories/preprod/inventory');
|
|
6
|
+
|
|
7
|
+
// Create haproxy.sh
|
|
8
|
+
const scriptContent = `
|
|
10
9
|
#!/bin/bash
|
|
11
10
|
|
|
12
11
|
[[ ! -f ${inventory} ]] && ( echo "Alert: no inventory file: ${inventory}" ; exit 1 )
|
|
@@ -27,24 +26,24 @@ export async function haproxySync() {
|
|
|
27
26
|
git commit -m "Sync haproxy"
|
|
28
27
|
git push origin master
|
|
29
28
|
`;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
await fs.writeFile('private.key', Buffer.from(haproxyPrivateKey, 'base64'));
|
|
41
|
-
await fs.chmod('private.key', 0o600);
|
|
42
|
-
|
|
43
|
-
await $`cat private.key`; // Just to mimic the script's behavior
|
|
44
|
-
|
|
45
|
-
// Copy script to remote
|
|
46
|
-
await $`scp -i private.key -o StrictHostKeyChecking=no haproxy.sh root@10.10.28.198:/tmp/haproxy.sh`;
|
|
47
|
-
|
|
48
|
-
// Execute script on remote
|
|
49
|
-
await $`ssh -i private.key -o StrictHostKeyChecking=no root@10.10.28.198 "bash /tmp/haproxy.sh"`;
|
|
29
|
+
|
|
30
|
+
await fs.writeFile('haproxy.sh', scriptContent);
|
|
31
|
+
|
|
32
|
+
// Private key
|
|
33
|
+
const haproxyPrivateKey = process.env.HAPROXY_PRIVATE_KEY;
|
|
34
|
+
if (!haproxyPrivateKey) {
|
|
35
|
+
log('Error: HAPROXY_PRIVATE_KEY not set.');
|
|
36
|
+
process.exit(1);
|
|
50
37
|
}
|
|
38
|
+
|
|
39
|
+
await fs.writeFile('private.key', Buffer.from(haproxyPrivateKey, 'base64'));
|
|
40
|
+
await fs.chmod('private.key', 0o600);
|
|
41
|
+
|
|
42
|
+
await $`cat private.key`; // Just to mimic the script's behavior
|
|
43
|
+
|
|
44
|
+
// Copy script to remote
|
|
45
|
+
await $`scp -i private.key -o StrictHostKeyChecking=no haproxy.sh root@10.10.28.198:/tmp/haproxy.sh`;
|
|
46
|
+
|
|
47
|
+
// Execute script on remote
|
|
48
|
+
await $`ssh -i private.key -o StrictHostKeyChecking=no root@10.10.28.198 "bash /tmp/haproxy.sh"`;
|
|
49
|
+
}
|
package/src/next/util.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { existsSync } from 'fs';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import {
|
|
4
|
-
import path from 'path';
|
|
2
|
+
import path, { join } from 'path';
|
|
3
|
+
import { $ } from 'zx';
|
|
5
4
|
|
|
6
5
|
export function isMonoRepo() {
|
|
7
6
|
// Check for the presence of turbo.json which indicates a Turborepo monorepo
|
|
@@ -86,7 +85,9 @@ export async function getChangedAppPackages() {
|
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
export async function setGitInfo() {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
+
}
|
|
92
93
|
}
|
package/src/next/vault.js
CHANGED
|
@@ -3,8 +3,8 @@ import axios from 'axios';
|
|
|
3
3
|
export async function vaultAddSiteData(SITE, SITE_CONFIG_REMOTE_PATH) {
|
|
4
4
|
const AUTH0_CLIENT_ID = process.env.AUTH0_CLIENT_ID;
|
|
5
5
|
const AUTH0_CLIENT_SECRET = process.env.AUTH0_CLIENT_SECRET;
|
|
6
|
-
const VAULT_ADDR = process.env.VAULT_ADDR;
|
|
7
|
-
const VAULT_TOKEN = process.env.VAULT_TOKEN;
|
|
6
|
+
const VAULT_ADDR = process.env.VAULT_ADDR; // Vault host URL from environment variables
|
|
7
|
+
const VAULT_TOKEN = process.env.VAULT_TOKEN; // Vault token from environment variables
|
|
8
8
|
|
|
9
9
|
if (!VAULT_ADDR || !VAULT_TOKEN) {
|
|
10
10
|
throw new Error('Missing VAULT_ADDR or VAULT_TOKEN environment variable.');
|
|
@@ -13,7 +13,6 @@ export async function vaultAddSiteData(SITE, SITE_CONFIG_REMOTE_PATH) {
|
|
|
13
13
|
const vaultApiUrl = `${VAULT_ADDR}/v1/secret/data/${SITE}/common/config`;
|
|
14
14
|
|
|
15
15
|
try {
|
|
16
|
-
|
|
17
16
|
if (process.env.VAULT_SKIP_VERIFY === 'true') {
|
|
18
17
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
19
18
|
}
|
|
@@ -32,12 +31,15 @@ export async function vaultAddSiteData(SITE, SITE_CONFIG_REMOTE_PATH) {
|
|
|
32
31
|
'X-Vault-Token': VAULT_TOKEN,
|
|
33
32
|
'Content-Type': 'application/json',
|
|
34
33
|
},
|
|
35
|
-
}
|
|
34
|
+
},
|
|
36
35
|
);
|
|
37
36
|
|
|
38
37
|
console.log('Data added to Vault successfully:', response.data);
|
|
39
38
|
} catch (error) {
|
|
40
|
-
console.error(
|
|
39
|
+
console.error(
|
|
40
|
+
'Error adding data to Vault:',
|
|
41
|
+
error.response?.data || error.message,
|
|
42
|
+
);
|
|
41
43
|
throw error;
|
|
42
44
|
}
|
|
43
45
|
}
|