@docupace/pipeline 1.0.7-alpha.ervins1.9 → 1.0.7-beta.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.
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "@docupace/pipeline",
3
- "version": "1.0.7-alpha.ervins1.9",
3
+ "version": "1.0.7-beta.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
7
  "bin": {
8
8
  "dp-changeset-cli": "src/changeset/cli.js",
9
- "dp-next-cli": "src/next/cli.js",
10
- "dp-auth0-cli": "src/auth0/cli.js"
9
+ "dp-next-cli": "src/next/cli.js"
11
10
  },
12
11
  "keywords": [
13
12
  "bash"
@@ -16,7 +15,6 @@
16
15
  "license": "ISC",
17
16
  "dependencies": {
18
17
  "@changesets/cli": "^2.27.10",
19
- "auth0-deploy-cli": "^7.24.3",
20
18
  "axios": "^1.7.9",
21
19
  "commander": "^12.1.0",
22
20
  "dotenv": "^16.4.7",
@@ -24,7 +22,7 @@
24
22
  "lodash": "^4.17.21",
25
23
  "openai": "^4.76.3",
26
24
  "zod": "^3.24.1",
27
- "zx": "^8.3.0"
25
+ "zx": "^8.2.4"
28
26
  },
29
27
  "devDependencies": {
30
28
  "@eslint/js": "^9.17.0",
package/src/next/cli.js CHANGED
@@ -7,10 +7,6 @@ import { publish } from './publish.js';
7
7
  import { deployFromSite } from './deploy.js';
8
8
  import { deployTemplate } from './deploy.js';
9
9
  import { copy } from './copy.js';
10
- import { vaultAddSiteData } from './vault.js';
11
- import { addApacheSite } from './apache.js';
12
- import { haproxySync } from './haproxy.js';
13
- import { connectClone } from './connect.js';
14
10
  import dotenv from 'dotenv';
15
11
 
16
12
  dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
@@ -19,9 +15,8 @@ const program = new Command();
19
15
 
20
16
  // GIT SHA computation
21
17
  import { $ } from 'zx';
22
- import { deployCore } from './jenkins.js';
18
+ import {deployConnect, deployCore} from './jenkins.js';
23
19
  import { runPipeline } from './pipline.js';
24
-
25
20
  const GIT_SHA = (await $`git log --pretty=format:'%h' -n 1`).stdout.trim();
26
21
 
27
22
  program
@@ -38,39 +33,6 @@ program
38
33
  await sonar(GIT_SHA);
39
34
  });
40
35
 
41
- program
42
- .command('addApacheSite')
43
- .description('Add site to apache')
44
- .action(async () => {
45
- await addApacheSite();
46
- });
47
-
48
- program
49
- .command('connectClone')
50
- .description('Clone connect site')
51
- .action(async () => {
52
- await connectClone();
53
- });
54
-
55
-
56
- program
57
- .command('haproxySync')
58
- .description('Sync haproxy config')
59
- .action(async () => {
60
- await haproxySync();
61
- });
62
-
63
-
64
-
65
- program
66
- .command('vaultAddSiteData')
67
- .description('Add m2m auth0 data to vault')
68
- .requiredOption('-s, --site-name <siteName>', 'Site name')
69
- .action(async (options) => {
70
- const { siteName, } = options;
71
- await vaultAddSiteData(siteName);
72
- });
73
-
74
36
  program
75
37
  .command('publish')
76
38
  .description('Publish a Docker image')
@@ -107,6 +69,15 @@ program
107
69
  await deployCore(env, site, options.liquibase, options.branch);
108
70
  });
109
71
 
72
+ program
73
+ .command('deploy-connect <env> <site>')
74
+ .description('Deploy Core')
75
+ .option('-l, --liquibase <liquibase>', 'Application name', 'true')
76
+ .option('-b, --branch <branch>', 'Branch', 'master')
77
+ .action(async (env, site, options) => {
78
+ await deployConnect(env, site, options.liquibase, options.branch);
79
+ });
80
+
110
81
  program
111
82
  .command('deploy-core-pipeline <env> <site>')
112
83
  .description('Deploy Core')
@@ -121,8 +92,7 @@ program
121
92
  });
122
93
  });
123
94
 
124
-
125
- program
95
+ program
126
96
  .command('copy')
127
97
  .description('Copy a Docker image between registries')
128
98
  .requiredOption('-a, --application <application>', 'Application name')
@@ -2,29 +2,25 @@ export const environments = ['dev', 'qa', 'uat', 'stage', 'prod'];
2
2
 
3
3
  export const environmentConfig = {
4
4
  dev: {
5
- newUrl: (site) => `${site}.dev.dpai.tech`,
5
+ newUrl: (site) => `https://${site}.dev.dpai.tech`,
6
6
  oldUrl: (site) => `https://www.dev.docupaceinc.com/${site}`,
7
- docupaceHost: () => 'www.dev.docupaceinc.com',
8
7
  },
9
8
  qa: {
10
- newUrl: (site) => `${site}.qa.dpai.tech`,
9
+ newUrl: (site) => `https://${site}.qa.dpai.tech`,
11
10
  oldUrl: (site) => `https://www.preprod.docupaceinc.com/${site}`,
12
- docupaceHost: () => 'www.preprod.docupaceinc.com',
13
11
  },
14
12
  uat: {
15
- newUrl: (site) => `${site}.qa.dpai.tech`,
13
+ newUrl: (site) => `https://${site}.qa.dpai.tech`,
16
14
  oldUrl: (site) => `https://www2.paperout.com/${site}_uat`,
17
- docupaceHost: () => 'www2.paperout.com',
18
15
  },
19
16
  stage: {
20
- newUrl: (site) => `${site}.stage.dpai.tech`,
17
+ newUrl: (site) => `https://${site}.stage.dpai.tech`,
21
18
  oldUrl: (site) => `https://www2.paperout.com/${site}_staging`,
22
- docupaceHost: () => 'www2.paperout.com',
23
19
  },
20
+
24
21
  prod: {
25
- newUrl: (site) => `${site}.dpai.tech`,
22
+ newUrl: (site) => `https://${site}.dpai.tech`,
26
23
  oldUrl: (site) => `https://www2.paperout.com/${site}`,
27
- docupaceHost: () => 'www2.paperout.com',
28
24
  },
29
25
  };
30
26
 
@@ -69,16 +65,8 @@ export const getBitbucketInfo = () => {
69
65
 
70
66
  export const getRepUrl = (repoName) => {
71
67
  const { username, password, workspace } = getBitbucketInfo();
72
- return `https://${username}:${password}@bitbucket.org/${workspace}/${repoName}.git`;
68
+ const repoUrl = `https://${username}:${password}@bitbucket.org/${workspace}/${repoName}.git`;
69
+ return repoUrl;
73
70
  };
74
71
 
75
72
  export const jfRegistryUrl = 'registry.paperout.com';
76
-
77
- export const getVaultSecretsConfigs = (site) => {
78
- return {
79
- commonSecretsPath: 'secret/data/common/config',
80
- siteCommonSecretsPath: `secret/data/${site}/common/config`,
81
- graphqlServerSecretsPath: `secret/data/${site}/graphql-server/config`,
82
- uiSecretsPath: `secret/data/${site}/ui/config`
83
- }
84
- };
@@ -22,56 +22,27 @@ function getRepoLocalPath(env) {
22
22
  return { repoPath, repoName };
23
23
  }
24
24
 
25
- function getRepoLocalPathByRepoSlug(repoSlug) {
26
- const repoName = `${repoSlug}`;
27
- const repoPath = path.join(process.cwd(), repoName);
28
- return { repoPath, repoName };
29
- }
30
-
31
- function cleanUpRepoPath(repoPath) {
32
- // Check and handle repo directory
33
- if (fs.existsSync(repoPath)) {
34
- console.log(`${repoPath} directory exists. Removing it...`);
35
- fs.rmSync(repoPath, {
36
- recursive: true,
37
- force: true
38
- });
39
- }
40
- }
41
-
42
- export async function cloneEnvRepository(env) {
25
+ async function cloneEnvRepository(env) {
43
26
  const { repoPath, repoName } = getRepoLocalPath(env);
44
27
  const repoUrl = getRepUrl(repoName);
45
28
  console.log(`Cloning repository: ${repoName}`);
46
- await $`git clone --depth 1 ${repoUrl}`;
29
+ await $`git clone ${repoUrl}`;
47
30
  console.log(`Repository cloned to: ${repoPath}`);
48
31
  return repoPath;
49
32
  }
50
33
 
51
- export async function cloneRepository(repoSlug) {
52
- const { repoPath, repoName } = getRepoLocalPathByRepoSlug(repoSlug);
53
- const repoUrl = getRepUrl(repoName);
54
-
55
- await cleanUpRepoPath(repoPath)
56
-
57
- console.log(`Cloning repository: ${repoName}`);
58
- await $`git clone --depth 1 ${repoUrl}`;
59
- console.log(`Repository cloned to: ${repoPath}`);
60
- return repoPath;
61
- }
62
-
63
- function getConfigPath(application, env, site) {
34
+ function getConfigPath(application, env, site, name) {
64
35
  const { repoPath } = getRepoLocalPath(env);
65
36
  const deployConfigFilePath = path.join(
66
37
  repoPath,
67
- `dp/${site}/${application}.values.yaml`,
38
+ `dp/${site}/${application}.${name}.yaml`,
68
39
  );
69
40
 
70
41
  return { repoPath, deployConfigFilePath };
71
42
  }
72
43
 
73
- export async function readDeployConfig(application, env, site) {
74
- const { deployConfigFilePath } = getConfigPath(application, env, site);
44
+ async function readDeployConfig(application, env, site, name) {
45
+ const { deployConfigFilePath } = getConfigPath(application, env, site, name);
75
46
 
76
47
  let deployConfig;
77
48
  try {
@@ -92,6 +63,7 @@ export async function cloneAndReadDeployConfig(application, env, site) {
92
63
  application,
93
64
  env,
94
65
  site,
66
+ 'values',
95
67
  );
96
68
 
97
69
  return { repoPath, deployConfigFilePath, deployConfig };
@@ -147,7 +119,7 @@ export async function pushDeployConfig(repoPath, commitMessage) {
147
119
  console.log('✅ Cleanup complete.');
148
120
  }
149
121
 
150
- function writeDeployConfig(repPath, deployConfigFilePath, deployConfig) {
122
+ function writeDeployConfig(deployConfigFilePath, deployConfig) {
151
123
  try {
152
124
  fs.writeFileSync(deployConfigFilePath, yaml.dump(deployConfig), 'utf8');
153
125
  console.log(`✅ Updated YAML file saved at: ${deployConfigFilePath}`);
@@ -163,7 +135,7 @@ export async function writeAndPushDeployConfig(
163
135
  deployConfig,
164
136
  commitMessage,
165
137
  ) {
166
- writeDeployConfig(repoPath, deployConfigFilePath, deployConfig);
138
+ writeDeployConfig(deployConfigFilePath, deployConfig);
167
139
  await pushDeployConfig(repoPath, commitMessage);
168
140
  }
169
141
 
@@ -273,7 +245,9 @@ export async function deployFromSite(
273
245
  ) {
274
246
  if (isDeployCore === 'true') {
275
247
  const branchName = await getCoreBranchName(fromEnv, fromSite);
276
- await deployCore(toEnv, toSite, 'true', branchName);
248
+
249
+ const coreEnv = toEnv == 'qa' ? 'preprod' : toEnv;
250
+ await deployCore(coreEnv, toSite, 'true', branchName);
277
251
 
278
252
  // To be added back when splitting between on prem and in cloud
279
253
  /*await runPipeline('site-deploy', 'deploy-core', 'main', {
@@ -301,6 +275,7 @@ export async function deployFromSite(
301
275
  application,
302
276
  fromEnv,
303
277
  fromSite,
278
+ 'values',
304
279
  );
305
280
 
306
281
  if (fromEnv !== toEnv) {
@@ -311,7 +286,7 @@ export async function deployFromSite(
311
286
  const {
312
287
  deployConfig: toDeployConfig,
313
288
  deployConfigFilePath: toDeployConfigFilePath,
314
- } = await readDeployConfig(application, toEnv, toSite);
289
+ } = await readDeployConfig(application, toEnv, toSite, 'values');
315
290
 
316
291
  // Update target configuration using attributes specified in appInfo
317
292
  for (const attribute of appDetails.deployAttributes) {
@@ -324,8 +299,18 @@ export async function deployFromSite(
324
299
  }
325
300
  }
326
301
 
302
+ const {
303
+ deployConfig: toDeployAppConfig,
304
+ deployConfigFilePath: toDeployAppConfigFilePath,
305
+ } = await readDeployConfig(application, toEnv, toSite, 'app');
306
+
307
+ toDeployAppConfig.revision = fromDeployConfig.image.tag;
308
+
327
309
  // Write updated configuration to the target YAML file
328
- writeDeployConfig(toRepoPath, toDeployConfigFilePath, toDeployConfig);
310
+ writeDeployConfig(toDeployConfigFilePath, toDeployConfig);
311
+
312
+ writeDeployConfig(toDeployAppConfigFilePath, toDeployAppConfig);
313
+
329
314
  }
330
315
 
331
316
  // Push all changes if any updates were made
@@ -1,9 +1,14 @@
1
1
  import axios from 'axios';
2
2
 
3
- const JENKINS_URL = 'http://devops.corp.docupace.com';
4
- const JOB_NAME = 'auto-deploy-site';
5
- const USERNAME = process.env.CORE_JENKINS_USERNAME;
6
- const API_TOKEN = process.env.CORE_JENKINS_API_TOKEN;
3
+ const CORE_JENKINS_URL = 'http://devops.corp.docupace.com';
4
+ const CORE_JOB_NAME = 'auto-deploy-site';
5
+ const CORE_USERNAME = process.env.CORE_JENKINS_USERNAME;
6
+ const CORE_API_TOKEN = process.env.CORE_JENKINS_API_TOKEN;
7
+
8
+ const CONNECT_JENKINS_URL = 'http://usdoc-s-buildui.corp.docupace.com/jenkins';
9
+ const CONNECT_JOB_NAME = 'docupace_build_and_run_site_v2';
10
+ const CONNECT_USERNAME = process.env.CONNECT_JENKINS_USERNAME;
11
+ const CONNECT_API_TOKEN = process.env.CONNECT_JENKINS_API_TOKEN;
7
12
 
8
13
  export async function deployCore(env, site, liquibase, gitBranch) {
9
14
  const parameters = {
@@ -13,14 +18,43 @@ export async function deployCore(env, site, liquibase, gitBranch) {
13
18
  gitBranch,
14
19
  };
15
20
 
21
+ return callJenkinsJob({
22
+ jenkinsUrl: CORE_JENKINS_URL,
23
+ jobName: CORE_JOB_NAME,
24
+ auth: { username: CORE_USERNAME, password: CORE_API_TOKEN },
25
+ parameters,
26
+ });
27
+ }
28
+
29
+ export async function deployConnect(env, site, liquibase, branch) {
30
+ const parameters = {
31
+ BUILD_ENVIRONMENT: env,
32
+ BUILD_SITE: site,
33
+ RUN_LIQUIBASE: liquibase,
34
+ };
35
+
36
+ return callJenkinsJob({
37
+ jenkinsUrl: CONNECT_JENKINS_URL,
38
+ jobName: CONNECT_JOB_NAME,
39
+ auth: { username: CONNECT_USERNAME, password: CONNECT_API_TOKEN },
40
+ parameters,
41
+ });
42
+ }
43
+
44
+ export async function callJenkinsJob({
45
+ jenkinsUrl,
46
+ jobName,
47
+ auth,
48
+ parameters,
49
+ }) {
16
50
  try {
17
51
  // Trigger the job
18
52
  console.log('Triggering Jenkins job...');
19
53
  const buildResponse = await axios.post(
20
- `${JENKINS_URL}/job/${JOB_NAME}/buildWithParameters`,
54
+ `${jenkinsUrl}/job/${jobName}/buildWithParameters`,
21
55
  new URLSearchParams(parameters),
22
56
  {
23
- auth: { username: USERNAME, password: API_TOKEN },
57
+ auth,
24
58
  headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
25
59
  validateStatus: (status) => status === 201 || status === 302, // Accept 201 and 302 as valid statuses
26
60
  },
@@ -33,7 +67,7 @@ export async function deployCore(env, site, liquibase, gitBranch) {
33
67
  let jobUrl = null;
34
68
  while (!jobUrl) {
35
69
  const queueResponse = await axios.get(`${queueUrl}api/json`, {
36
- auth: { username: USERNAME, password: API_TOKEN },
70
+ auth,
37
71
  });
38
72
  jobUrl = queueResponse.data.executable?.url || null;
39
73
 
@@ -54,7 +88,7 @@ export async function deployCore(env, site, liquibase, gitBranch) {
54
88
  console.log('Streaming job output...');
55
89
  while (true) {
56
90
  const consoleResponse = await axios.get(consoleUrl, {
57
- auth: { username: USERNAME, password: API_TOKEN },
91
+ auth,
58
92
  responseType: 'text',
59
93
  });
60
94
 
@@ -65,16 +99,16 @@ export async function deployCore(env, site, liquibase, gitBranch) {
65
99
 
66
100
  // Check job status
67
101
  const jobResponse = await axios.get(`${jobUrl}api/json`, {
68
- auth: { username: USERNAME, password: API_TOKEN },
102
+ auth,
69
103
  });
70
104
  const result = jobResponse.data.result;
71
105
 
72
106
  if (result) {
73
107
  console.log(`\nJob completed with result: ${result}`);
74
108
  if (result === 'SUCCESS') {
75
- process.exit(0);
109
+ return;
76
110
  } else {
77
- process.exit(1);
111
+ throw new Error('Jenkins job failed');
78
112
  }
79
113
  }
80
114
 
@@ -83,6 +117,6 @@ export async function deployCore(env, site, liquibase, gitBranch) {
83
117
  }
84
118
  } catch (error) {
85
119
  console.error('Error:', error.message);
86
- process.exit(1);
120
+ throw error;
87
121
  }
88
122
  }
package/src/auth0/cli.js DELETED
@@ -1,31 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { Command } from 'commander';
4
- import {
5
- configureFromSite
6
- } from './configure.js';
7
- import {
8
- getVaultSecrets
9
- } from './vault.js'
10
-
11
- import dotenv from 'dotenv';
12
-
13
- dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
14
-
15
- const program = new Command();
16
-
17
- program
18
- .command('configureFromSite <fromSite> <toSite> <env> <deployUI> <deployGraphQLServer> <useNewDomain>')
19
- .description('Configure the Auth0 tenants in env for the given site')
20
- .action(async (fromSite, toSite, env, deployUI, deployGraphQLServer, useNewDomain) => {
21
- await configureFromSite(fromSite, toSite, env, deployUI, deployGraphQLServer, useNewDomain);
22
- });
23
-
24
- program
25
- .command('getVaultSecrets <vaultPath>')
26
- .description('Get Secrets for Vault PATH')
27
- .action(async (vaultPath) => {
28
- await getVaultSecrets(vaultPath);
29
- });
30
-
31
- program.parse(process.argv);