@docupace/pipeline 1.0.24 → 1.0.26-alpha-2

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.
@@ -1,47 +1,47 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
-
4
- export async function validateChangesets(directoryPath) {
5
- try {
6
- // Step 1: Read the directory for md files excluding README.md
7
- const allFiles = fs.readdirSync(directoryPath);
8
- const mdFiles = allFiles.filter(
9
- (file) => file.endsWith('.md') && file !== 'README.md',
10
- );
11
-
12
- // Step 2: Check for pre.json and parse it
13
- const preJsonPath = path.join(directoryPath, 'pre.json');
14
- let preJson;
15
-
16
- if (!fs.existsSync(preJsonPath) && mdFiles.length === 0) {
17
- throw new Error('Error: No pre.json and no md files found.');
18
- }
19
-
20
- if (fs.existsSync(preJsonPath)) {
21
- preJson = JSON.parse(fs.readFileSync(preJsonPath, 'utf-8'));
22
-
23
- if (preJson.mode == 'pre') {
24
- // Step 4a: Get list of changesets from pre.json
25
- const changesets = preJson.changesets || [];
26
- const changesetNames = changesets.map((change) => change);
27
-
28
- // Step 4b: Match files with the list of changesets
29
- const mdFileNamesWithoutExt = mdFiles.map((file) =>
30
- path.basename(file, '.md'),
31
- );
32
- const unmatchedFiles = mdFileNamesWithoutExt.filter(
33
- (fileName) => !changesetNames.includes(fileName),
34
- );
35
-
36
- if (unmatchedFiles.length == 0) {
37
- throw new Error('Error: No new MD files found:');
38
- }
39
- }
40
- }
41
-
42
- console.log('Validation successful.');
43
- } catch (error) {
44
- console.log(error.message);
45
- throw error;
46
- }
47
- }
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+
4
+ export async function validateChangesets(directoryPath) {
5
+ try {
6
+ // Step 1: Read the directory for md files excluding README.md
7
+ const allFiles = fs.readdirSync(directoryPath);
8
+ const mdFiles = allFiles.filter(
9
+ (file) => file.endsWith('.md') && file !== 'README.md',
10
+ );
11
+
12
+ // Step 2: Check for pre.json and parse it
13
+ const preJsonPath = path.join(directoryPath, 'pre.json');
14
+ let preJson;
15
+
16
+ if (!fs.existsSync(preJsonPath) && mdFiles.length === 0) {
17
+ throw new Error('Error: No pre.json and no md files found.');
18
+ }
19
+
20
+ if (fs.existsSync(preJsonPath)) {
21
+ preJson = JSON.parse(fs.readFileSync(preJsonPath, 'utf-8'));
22
+
23
+ if (preJson.mode == 'pre') {
24
+ // Step 4a: Get list of changesets from pre.json
25
+ const changesets = preJson.changesets || [];
26
+ const changesetNames = changesets.map((change) => change);
27
+
28
+ // Step 4b: Match files with the list of changesets
29
+ const mdFileNamesWithoutExt = mdFiles.map((file) =>
30
+ path.basename(file, '.md'),
31
+ );
32
+ const unmatchedFiles = mdFileNamesWithoutExt.filter(
33
+ (fileName) => !changesetNames.includes(fileName),
34
+ );
35
+
36
+ if (unmatchedFiles.length == 0) {
37
+ throw new Error('Error: No new MD files found:');
38
+ }
39
+ }
40
+ }
41
+
42
+ console.log('Validation successful.');
43
+ } catch (error) {
44
+ console.log(error.message);
45
+ throw error;
46
+ }
47
+ }
@@ -1,59 +1,59 @@
1
- import groovy.json.JsonSlurper
2
-
3
- import hudson.model.*;
4
-
5
- def build = Thread.currentThread().executable
6
- def params = build.getEnvironment(listener)
7
-
8
- def site = params.get('site')
9
- def server = "jboss7"
10
- def environment = params.get('environment')
11
-
12
- def buildFile=new File("D:\\Docupace\\CustomFolders\\" + environment + "\\" + site + "\\" + server + "\\buildApp.properties")
13
-
14
- List<String> jboss7controllerResult = []
15
-
16
- def controllersReport = new File("D:\\Docupace\\controllers_report.json")
17
- def inputJSON = new JsonSlurper().parseText(controllersReport.text)
18
- def props = new Properties()
19
- buildFile.withInputStream { stream -> props.load(stream) }
20
- def webRootContext = props["web.root.context"]
21
- if (webRootContext == null || webRootContext =="core") webRootContext = props["docupace.config.client.id"].toLowerCase()
22
-
23
- webRootContext = webRootContext.replaceFirst('_sso','')
24
- def map = inputJSON.'content'
25
-
26
- def Boolean enabled
27
-
28
- map.each {k,v ->
29
- v.each{vk, vv -> if (vk == webRootContext ) {
30
- enabled = false
31
- if(vv.deploymentsProperty.size()>0) enabled = vv.deploymentsProperty[0].isEnabled
32
- if (enabled) jboss7controllerResult.push(k)
33
- else jboss7controllerResult << k
34
- }
35
- }
36
- }
37
-
38
- if (jboss7controllerResult.size()>0) {
39
- if (environment == 'preprod') {
40
- jboss7controllerResult.remove("dev-corjbdc10.corp.docupace.com")
41
- jboss7controllerResult.remove("usdoc-s-jbdc1.corp.docupace.com")
42
- }
43
- if (environment == 'dev') {
44
- jboss7controllerResult.remove("qa-corjbdc10.corp.docupace.com")
45
- jboss7controllerResult.remove("qa-corjbdc20.corp.docupace.com")
46
- jboss7controllerResult.remove("usdoc-s-jbdc2.corp.docupace.com")
47
- }
48
- }
49
-
50
- println jboss7controllerResult[0]
51
-
52
- env.jboss7controller = jboss7controllerResult[0]
53
-
54
- def serverGroup = inputJSON.'content'."${jboss7controller}"."${webRootContext}".'serverGroup'
55
-
56
- println serverGroup
57
-
58
- params.put("serverGroup", serverGroup)
59
-
1
+ import groovy.json.JsonSlurper
2
+
3
+ import hudson.model.*;
4
+
5
+ def build = Thread.currentThread().executable
6
+ def params = build.getEnvironment(listener)
7
+
8
+ def site = params.get('site')
9
+ def server = "jboss7"
10
+ def environment = params.get('environment')
11
+
12
+ def buildFile=new File("D:\\Docupace\\CustomFolders\\" + environment + "\\" + site + "\\" + server + "\\buildApp.properties")
13
+
14
+ List<String> jboss7controllerResult = []
15
+
16
+ def controllersReport = new File("D:\\Docupace\\controllers_report.json")
17
+ def inputJSON = new JsonSlurper().parseText(controllersReport.text)
18
+ def props = new Properties()
19
+ buildFile.withInputStream { stream -> props.load(stream) }
20
+ def webRootContext = props["web.root.context"]
21
+ if (webRootContext == null || webRootContext =="core") webRootContext = props["docupace.config.client.id"].toLowerCase()
22
+
23
+ webRootContext = webRootContext.replaceFirst('_sso','')
24
+ def map = inputJSON.'content'
25
+
26
+ def Boolean enabled
27
+
28
+ map.each {k,v ->
29
+ v.each{vk, vv -> if (vk == webRootContext ) {
30
+ enabled = false
31
+ if(vv.deploymentsProperty.size()>0) enabled = vv.deploymentsProperty[0].isEnabled
32
+ if (enabled) jboss7controllerResult.push(k)
33
+ else jboss7controllerResult << k
34
+ }
35
+ }
36
+ }
37
+
38
+ if (jboss7controllerResult.size()>0) {
39
+ if (environment == 'preprod') {
40
+ jboss7controllerResult.remove("dev-corjbdc10.corp.docupace.com")
41
+ jboss7controllerResult.remove("usdoc-s-jbdc1.corp.docupace.com")
42
+ }
43
+ if (environment == 'dev') {
44
+ jboss7controllerResult.remove("qa-corjbdc10.corp.docupace.com")
45
+ jboss7controllerResult.remove("qa-corjbdc20.corp.docupace.com")
46
+ jboss7controllerResult.remove("usdoc-s-jbdc2.corp.docupace.com")
47
+ }
48
+ }
49
+
50
+ println jboss7controllerResult[0]
51
+
52
+ env.jboss7controller = jboss7controllerResult[0]
53
+
54
+ def serverGroup = inputJSON.'content'."${jboss7controller}"."${webRootContext}".'serverGroup'
55
+
56
+ println serverGroup
57
+
58
+ params.put("serverGroup", serverGroup)
59
+
package/src/next/alias.js CHANGED
@@ -1,53 +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
- }
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
+ }
@@ -1,40 +1,40 @@
1
- import { $ } from 'zx';
2
-
3
- export async function addApacheSite() {
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
- }
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`;
36
-
37
- await sshCmd(server,`/root/repo/iis-preprod/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`);
38
- }
39
-
40
-
1
+ import { $ } from 'zx';
2
+
3
+ export async function addApacheSite() {
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
+ }
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`;
36
+
37
+ await sshCmd(server,`/root/repo/iis-preprod/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`);
38
+ }
39
+
40
+
package/src/next/cli.js CHANGED
@@ -9,7 +9,7 @@ import { deployTemplate } from './deploy.js';
9
9
  import { copy } from './copy.js';
10
10
  import { vaultAddSiteData } from './vault.js';
11
11
  import { addApacheSite } from './apache.js';
12
- import { haproxySync } from './haproxy.js';
12
+ import { haproxySync } from './haproxy.js';
13
13
  import { connectClone } from './connect.js';
14
14
  import dotenv from 'dotenv';
15
15
 
@@ -18,7 +18,7 @@ dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
18
18
  const program = new Command();
19
19
 
20
20
  import { $ } from 'zx';
21
- import { deployConnect, deployCore } from './jenkins.js';
21
+ import {deployConnect, deployCore} from './jenkins.js';
22
22
  import { runPipeline } from './pipline.js';
23
23
 
24
24
  const GIT_SHA = (await $`git log --pretty=format:'%h' -n 1`).stdout.trim();
@@ -38,34 +38,31 @@ program
38
38
  });
39
39
 
40
40
  program
41
- .command('addApacheSite')
42
- .description('Add site to apache')
43
- .action(async () => {
44
- await addApacheSite();
45
- });
41
+ .command('addApacheSite')
42
+ .description('Add site to apache')
43
+ .action(async () => {
44
+ await addApacheSite();
45
+ });
46
46
 
47
47
  program
48
- .command('connectClone')
49
- .description('Clone connect site')
50
- .action(async () => {
51
- await connectClone();
52
- });
48
+ .command('connectClone')
49
+ .description('Clone connect site')
50
+ .action(async () => {
51
+ await connectClone();
52
+ });
53
53
 
54
54
  program
55
- .command('haproxySync')
56
- .description('Sync haproxy config')
57
- .action(async () => {
58
- await haproxySync();
59
- });
55
+ .command('haproxySync')
56
+ .description('Sync haproxy config')
57
+ .action(async () => {
58
+ await haproxySync();
59
+ });
60
60
 
61
61
  program
62
62
  .command('vaultAddSiteData')
63
63
  .description('Add m2m auth0 data to vault')
64
64
  .requiredOption('-s, --site-name <siteName>', 'Site name')
65
- .requiredOption(
66
- '-p, --site-config-remote-path <siteConfigRemotePath>',
67
- 'Site Config Remote Path',
68
- )
65
+ .requiredOption('-p, --site-config-remote-path <siteConfigRemotePath>', 'Site Config Remote Path')
69
66
  .action(async (options) => {
70
67
  const { siteName, siteConfigRemotePath } = options;
71
68
  await vaultAddSiteData(siteName, siteConfigRemotePath);
@@ -86,18 +83,9 @@ program
86
83
  .requiredOption('-F, --from-site <fromSite>', 'Source site')
87
84
  .requiredOption('-T, --to-site <toSite>', 'Target site')
88
85
  .option('-c, --deploy-core <deployCore>', 'Deploy Core', 'false')
89
- .option('-C, --deploy-connect <deployConnect>', 'Deploy Connect', 'false')
90
86
  .action(async (options) => {
91
- const { fromEnv, fromSite, toEnv, toSite, deployCore, deployConnect } =
92
- options;
93
- await deployFromSite(
94
- fromEnv,
95
- fromSite,
96
- toEnv,
97
- toSite,
98
- deployCore,
99
- deployConnect,
100
- );
87
+ const { fromEnv, fromSite, toEnv, toSite, deployCore } = options;
88
+ await deployFromSite(fromEnv, fromSite, toEnv, toSite, deployCore);
101
89
  });
102
90
 
103
91
  program
@@ -139,7 +127,7 @@ program
139
127
  });
140
128
  });
141
129
 
142
- program
130
+ program
143
131
  .command('copy')
144
132
  .description('Copy a Docker image between registries')
145
133
  .requiredOption('-a, --application <application>', 'Application name')