@docupace/pipeline 1.0.4 → 1.0.5-4.ervins
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/.prettierrc.cjs +12 -0
- package/README.md +136 -0
- package/bin/azuread_update_callbacks_for_app.sh +58 -0
- package/bin/next-changeset-validate.sh +8 -8
- package/eslint.config.js +26 -0
- package/next/changeset.sh +75 -75
- package/next/copy.sh +34 -34
- package/next/deploy.sh +40 -40
- package/next/execute.sh +123 -117
- package/next/sonar.sh +23 -23
- package/package.json +50 -28
- package/src/auth0/alias.js +72 -0
- package/src/auth0/cli.js +76 -0
- package/src/auth0/configure.js +783 -0
- package/src/auth0/export.js +43 -0
- package/src/auth0/metadata.js +132 -0
- package/src/auth0/vault.js +107 -0
- package/src/changeset/changeset-config.js +34 -0
- package/src/changeset/cli.js +200 -245
- package/src/changeset/create.js +205 -0
- package/src/changeset/package-util.js +86 -0
- package/src/changeset/util.js +43 -0
- package/src/changeset/validate.js +84 -44
- package/src/changeset/version.js +102 -0
- package/src/jenkins/setParams.groovy +58 -0
- package/src/next/alias.js +53 -0
- package/src/next/apache.js +73 -0
- package/src/next/cli.js +228 -59
- package/src/next/config.js +137 -0
- package/src/next/connect.js +227 -0
- package/src/next/copy.js +61 -27
- package/src/next/deploy.js +595 -128
- package/src/next/haproxy.js +71 -0
- package/src/next/jenkins.js +123 -0
- package/src/next/jira.js +84 -0
- package/src/next/logger.js +17 -0
- package/src/next/pipline.js +114 -0
- package/src/next/publish.js +71 -46
- package/src/next/pull.js +7 -7
- package/src/next/sonar.js +23 -23
- package/src/next/util.js +93 -0
- package/src/next/vault.js +45 -0
- package/terraform/apply.sh +37 -0
- package/terraform/init.sh +72 -0
- package/terraform/plan.sh +76 -0
- package/terraform/validate.sh +17 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
export function getPackageNames(rootPath = '.') {
|
|
5
|
+
const appsDir = path.join(rootPath, 'apps');
|
|
6
|
+
const packagesDir = path.join(rootPath, 'packages');
|
|
7
|
+
const rootPackageJson = path.join(rootPath, 'package.json');
|
|
8
|
+
|
|
9
|
+
// Check if this is a monorepo (has apps and/or packages directories)
|
|
10
|
+
const hasAppsDir =
|
|
11
|
+
fs.existsSync(appsDir) && fs.statSync(appsDir).isDirectory();
|
|
12
|
+
const hasPackagesDir =
|
|
13
|
+
fs.existsSync(packagesDir) && fs.statSync(packagesDir).isDirectory();
|
|
14
|
+
|
|
15
|
+
if (hasAppsDir || hasPackagesDir) {
|
|
16
|
+
// This is a monorepo
|
|
17
|
+
const packages = [];
|
|
18
|
+
|
|
19
|
+
// Get packages from apps directory
|
|
20
|
+
if (hasAppsDir) {
|
|
21
|
+
const appsPackages = getPackagesFromDirectory(appsDir);
|
|
22
|
+
packages.push(...appsPackages);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Get packages from packages directory
|
|
26
|
+
if (hasPackagesDir) {
|
|
27
|
+
const packagesPackages = getPackagesFromDirectory(packagesDir);
|
|
28
|
+
packages.push(...packagesPackages);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return packages;
|
|
32
|
+
} else {
|
|
33
|
+
// This is not a monorepo, return single package
|
|
34
|
+
if (fs.existsSync(rootPackageJson)) {
|
|
35
|
+
try {
|
|
36
|
+
const packageJson = JSON.parse(
|
|
37
|
+
fs.readFileSync(rootPackageJson, 'utf8'),
|
|
38
|
+
);
|
|
39
|
+
return packageJson.name
|
|
40
|
+
? [{ name: packageJson.name, path: rootPath }]
|
|
41
|
+
: [];
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error('Error reading root package.json:', error);
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function getPackagesFromDirectory(dirPath) {
|
|
52
|
+
const packages = [];
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
const items = fs.readdirSync(dirPath);
|
|
56
|
+
|
|
57
|
+
for (const item of items) {
|
|
58
|
+
const itemPath = path.join(dirPath, item);
|
|
59
|
+
const packageJsonPath = path.join(itemPath, 'package.json');
|
|
60
|
+
|
|
61
|
+
// Check if item is a directory and has package.json
|
|
62
|
+
if (
|
|
63
|
+
fs.statSync(itemPath).isDirectory() &&
|
|
64
|
+
fs.existsSync(packageJsonPath)
|
|
65
|
+
) {
|
|
66
|
+
try {
|
|
67
|
+
const packageJson = JSON.parse(
|
|
68
|
+
fs.readFileSync(packageJsonPath, 'utf8'),
|
|
69
|
+
);
|
|
70
|
+
if (packageJson.name) {
|
|
71
|
+
packages.push({
|
|
72
|
+
name: packageJson.name,
|
|
73
|
+
path: itemPath,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.error(`Error reading package.json in ${itemPath}:`, error);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error(`Error reading directory ${dirPath}:`, error);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return packages;
|
|
86
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
|
|
4
|
+
async function fileExists(filePath) {
|
|
5
|
+
try {
|
|
6
|
+
await fs.promises.access(filePath);
|
|
7
|
+
return true;
|
|
8
|
+
} catch {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export async function getMainPackage() {
|
|
13
|
+
const mainModulePath = process.cwd();
|
|
14
|
+
return getPackage(mainModulePath);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function getPackage(mainModulePath) {
|
|
18
|
+
if (mainModulePath) {
|
|
19
|
+
const packageJsonPath = path.join(mainModulePath, 'package.json');
|
|
20
|
+
if (await fileExists(packageJsonPath)) {
|
|
21
|
+
const fileContent = await fs.promises.readFile(packageJsonPath, 'utf-8');
|
|
22
|
+
const packageJson = JSON.parse(fileContent);
|
|
23
|
+
return packageJson;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
throw new Error('Main package.json not found');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Locates and extracts a JIRA Ticket ID from a given string.
|
|
31
|
+
* <p>
|
|
32
|
+
* The JIRA Ticket ID is expected to follow the pattern of uppercase letters (at least two) followed by a hyphen and digits (e.g., DC-1234, INFP-9).
|
|
33
|
+
* @param str the string to search for a JIRA ticket ID
|
|
34
|
+
* @returns {JIRA-TicketID|null}
|
|
35
|
+
*/
|
|
36
|
+
export function findJiraTicketId(str) {
|
|
37
|
+
if (!str) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const regex = /([A-Z]{2,}-\d+)/;
|
|
41
|
+
const matches = str.match(regex);
|
|
42
|
+
return matches ? matches[0] : null;
|
|
43
|
+
}
|
|
@@ -1,44 +1,84 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { $ } from 'zx';
|
|
4
|
+
|
|
5
|
+
import { isMonoRepo, setGitInfo } from '../next/util.js';
|
|
6
|
+
import { versionStatus } from './version.js';
|
|
7
|
+
|
|
8
|
+
const CHANGESET_DIR = '.changeset';
|
|
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
|
+
|
|
19
|
+
export async function validateChangesets() {
|
|
20
|
+
if (isMonoRepo()) {
|
|
21
|
+
await setGitInfo();
|
|
22
|
+
const destBranch = process.env.BITBUCKET_PR_DESTINATION_BRANCH;
|
|
23
|
+
await $`git fetch origin ${destBranch}:${destBranch}`;
|
|
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
|
+
}*/
|
|
36
|
+
} else {
|
|
37
|
+
await validateChangesetPath(path.resolve(process.cwd(), CHANGESET_DIR));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function validateChangesetPath(directoryPath) {
|
|
42
|
+
try {
|
|
43
|
+
// Step 1: Read the directory for md files excluding README.md
|
|
44
|
+
const allFiles = fs.readdirSync(directoryPath);
|
|
45
|
+
const mdFiles = allFiles.filter(
|
|
46
|
+
(file) => file.endsWith('.md') && file !== 'README.md',
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// Step 2: Check for pre.json and parse it
|
|
50
|
+
const preJsonPath = path.join(directoryPath, 'pre.json');
|
|
51
|
+
let preJson;
|
|
52
|
+
|
|
53
|
+
if (!fs.existsSync(preJsonPath) && mdFiles.length === 0) {
|
|
54
|
+
throw new Error('Error: No pre.json and no md files found.');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (fs.existsSync(preJsonPath)) {
|
|
58
|
+
preJson = JSON.parse(fs.readFileSync(preJsonPath, 'utf-8'));
|
|
59
|
+
|
|
60
|
+
if (preJson.mode == 'pre') {
|
|
61
|
+
// Step 4a: Get list of changesets from pre.json
|
|
62
|
+
const changesets = preJson.changesets || [];
|
|
63
|
+
const changesetNames = changesets.map((change) => change);
|
|
64
|
+
|
|
65
|
+
// Step 4b: Match files with the list of changesets
|
|
66
|
+
const mdFileNamesWithoutExt = mdFiles.map((file) =>
|
|
67
|
+
path.basename(file, '.md'),
|
|
68
|
+
);
|
|
69
|
+
const unmatchedFiles = mdFileNamesWithoutExt.filter(
|
|
70
|
+
(fileName) => !changesetNames.includes(fileName),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
if (unmatchedFiles.length == 0) {
|
|
74
|
+
throw new Error('Error: No new MD files found:');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
console.log('Validation successful.');
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.log(error.message);
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { setGitInfo } from '../next/util.js';
|
|
2
|
+
import { $ } from 'zx';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import { updateComponentVersion } from '../next/jira.js';
|
|
5
|
+
import { findJiraTicketId } from './util.js';
|
|
6
|
+
import { revertBaseBranch, updateBaseBranch } from './changeset-config.js';
|
|
7
|
+
import semver from 'semver';
|
|
8
|
+
|
|
9
|
+
const changeSetPackage = `{
|
|
10
|
+
"name": "changeset-package",
|
|
11
|
+
"version": "1.0.0",
|
|
12
|
+
"description": "",
|
|
13
|
+
"scripts": {
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"keywords": [],
|
|
17
|
+
"author": "",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"dependencies": {},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@changesets/cli": "^2.27.10"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
export function toShortVersion(version) {
|
|
27
|
+
const parsed = semver.parse(version);
|
|
28
|
+
if (!parsed) return null;
|
|
29
|
+
return `${parsed.major}.${parsed.minor}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function versionStatus(sinceBranch) {
|
|
33
|
+
const outputPath = './changeset-output.json';
|
|
34
|
+
|
|
35
|
+
if (sinceBranch) {
|
|
36
|
+
await $`pnpm changeset status --output=${outputPath} --since=${sinceBranch}`;
|
|
37
|
+
} else {
|
|
38
|
+
await $`pnpm changeset status --output=${outputPath}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Read the file and parse JSON
|
|
42
|
+
const jsonOutput = JSON.parse(await fs.promises.readFile(outputPath, 'utf8'));
|
|
43
|
+
|
|
44
|
+
await fs.promises.rm(outputPath);
|
|
45
|
+
return jsonOutput.releases;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function versionCommand(closeVersion = false) {
|
|
49
|
+
console.log('📦 Running Changeset versioning...');
|
|
50
|
+
if (!process.env.IS_DEV) {
|
|
51
|
+
await setGitInfo();
|
|
52
|
+
await $`mv package.json package.json.bak`;
|
|
53
|
+
await $`mv pnpm-lock.yaml pnpm-lock.yaml.bak`;
|
|
54
|
+
await fs.promises.writeFile('package.json', changeSetPackage);
|
|
55
|
+
await $`pnpm install`;
|
|
56
|
+
await $`rm package.json pnpm-lock.yaml`;
|
|
57
|
+
await $`mv package.json.bak package.json`;
|
|
58
|
+
await $`mv pnpm-lock.yaml.bak pnpm-lock.yaml`;
|
|
59
|
+
}
|
|
60
|
+
if (closeVersion) {
|
|
61
|
+
await $`pnpm changeset pre exit`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let originalBaseBranch;
|
|
65
|
+
try {
|
|
66
|
+
originalBaseBranch = updateBaseBranch();
|
|
67
|
+
const releases = await versionStatus();
|
|
68
|
+
revertBaseBranch(originalBaseBranch);
|
|
69
|
+
await $`pnpm changeset version`;
|
|
70
|
+
|
|
71
|
+
return releases;
|
|
72
|
+
} catch {
|
|
73
|
+
revertBaseBranch(originalBaseBranch);
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export async function updateJiraWithVersion(releases) {
|
|
79
|
+
const lastCommit = (await $`git log -1 --pretty=%B`).stdout.trim();
|
|
80
|
+
console.log(`Last commit '${lastCommit}' being processed to get Jira ticket`);
|
|
81
|
+
|
|
82
|
+
const jiraTicketId = findJiraTicketId(lastCommit);
|
|
83
|
+
|
|
84
|
+
// If we have all the necessary data, update the component version in Jira
|
|
85
|
+
if (jiraTicketId) {
|
|
86
|
+
for (const release of releases) {
|
|
87
|
+
try {
|
|
88
|
+
await updateComponentVersion(
|
|
89
|
+
jiraTicketId,
|
|
90
|
+
release.name,
|
|
91
|
+
release.newVersion,
|
|
92
|
+
);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
console.error(
|
|
95
|
+
`Failed to update Jira component version: ${error.message}`,
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
console.log('✅ Changeset versioning complete.');
|
|
102
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import groovy.json.JsonSlurper
|
|
2
|
+
import hudson.model.*
|
|
3
|
+
|
|
4
|
+
def build = Thread.currentThread().executable
|
|
5
|
+
def params = build.getEnvironment(listener)
|
|
6
|
+
|
|
7
|
+
def site = params.get('site')
|
|
8
|
+
def server = "jboss7"
|
|
9
|
+
def environment = params.get('environment')
|
|
10
|
+
|
|
11
|
+
def buildFile=new File("D:\\Docupace\\CustomFolders\\" + environment + "\\" + site + "\\" + server + "\\buildApp.properties")
|
|
12
|
+
|
|
13
|
+
List<String> jboss7controllerResult = []
|
|
14
|
+
|
|
15
|
+
def controllersReport = new File("D:\\Docupace\\controllers_report.json")
|
|
16
|
+
def inputJSON = new JsonSlurper().parseText(controllersReport.text)
|
|
17
|
+
def props = new Properties()
|
|
18
|
+
buildFile.withInputStream { stream -> props.load(stream) }
|
|
19
|
+
def webRootContext = props["web.root.context"]
|
|
20
|
+
if (webRootContext == null || webRootContext =="core") webRootContext = props["docupace.config.client.id"].toLowerCase()
|
|
21
|
+
|
|
22
|
+
webRootContext = webRootContext.replaceFirst('_sso','')
|
|
23
|
+
def map = inputJSON.'content'
|
|
24
|
+
|
|
25
|
+
def Boolean enabled
|
|
26
|
+
|
|
27
|
+
map.each {k,v ->
|
|
28
|
+
v.each{vk, vv -> if (vk == webRootContext ) {
|
|
29
|
+
enabled = false
|
|
30
|
+
if(vv.deploymentsProperty.size()>0) enabled = vv.deploymentsProperty[0].isEnabled
|
|
31
|
+
if (enabled) jboss7controllerResult.push(k)
|
|
32
|
+
else jboss7controllerResult << k
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (jboss7controllerResult.size()>0) {
|
|
38
|
+
if (environment == 'preprod') {
|
|
39
|
+
jboss7controllerResult.remove("dev-corjbdc10.corp.docupace.com")
|
|
40
|
+
jboss7controllerResult.remove("usdoc-s-jbdc1.corp.docupace.com")
|
|
41
|
+
}
|
|
42
|
+
if (environment == 'dev') {
|
|
43
|
+
jboss7controllerResult.remove("qa-corjbdc10.corp.docupace.com")
|
|
44
|
+
jboss7controllerResult.remove("qa-corjbdc20.corp.docupace.com")
|
|
45
|
+
jboss7controllerResult.remove("usdoc-s-jbdc2.corp.docupace.com")
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
println jboss7controllerResult[0]
|
|
50
|
+
|
|
51
|
+
env.jboss7controller = jboss7controllerResult[0]
|
|
52
|
+
|
|
53
|
+
def serverGroup = inputJSON.'content'."${jboss7controller}"."${webRootContext}".'serverGroup'
|
|
54
|
+
|
|
55
|
+
println serverGroup
|
|
56
|
+
|
|
57
|
+
params.put("serverGroup", serverGroup)
|
|
58
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
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/repo/${apacheEnvHostMap[process.env.ENVIRONMENT].repo}/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
await sshCmd(
|
|
70
|
+
apacheEnvHostMap[process.env.ENVIRONMENT].host2,
|
|
71
|
+
`/root/repo/${apacheEnvHostMap[process.env.ENVIRONMENT].repo}/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`,
|
|
72
|
+
);
|
|
73
|
+
}
|