@docupace/pipeline 1.0.5-alpha.16 → 1.0.5-alpha.17
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 +2 -2
- package/src/next/cli.js +3 -2
- package/src/next/config.js +25 -1
- package/src/next/deploy.js +66 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docupace/pipeline",
|
|
3
|
-
"version": "1.0.5-alpha.
|
|
3
|
+
"version": "1.0.5-alpha.17",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -35,6 +35,6 @@
|
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"test-deploy-core": "dp-next-cli deploy-core-pipeline dev template",
|
|
38
|
-
"test-deploy-from-site": "dp-next-cli deploy-from-site --from-env dev --to-env dev --from-site financialdev --to-site template"
|
|
38
|
+
"test-deploy-from-site": "dp-next-cli deploy-from-site --from-env dev --to-env dev --from-site financialdev --to-site template --deploy-core true"
|
|
39
39
|
}
|
|
40
40
|
}
|
package/src/next/cli.js
CHANGED
|
@@ -47,9 +47,10 @@ program
|
|
|
47
47
|
.requiredOption('-t, --to-env <toEnv>', 'Target environment')
|
|
48
48
|
.requiredOption('-F, --from-site <fromSite>', 'Source site')
|
|
49
49
|
.requiredOption('-T, --to-site <toSite>', 'Target site')
|
|
50
|
+
.option('-c, --deploy-core <deployCore>', 'Deploy Core', 'false')
|
|
50
51
|
.action(async (options) => {
|
|
51
|
-
const { fromEnv, fromSite, toEnv, toSite } = options;
|
|
52
|
-
await deployFromSite(fromEnv, fromSite, toEnv, toSite);
|
|
52
|
+
const { fromEnv, fromSite, toEnv, toSite, deployCore } = options;
|
|
53
|
+
await deployFromSite(fromEnv, fromSite, toEnv, toSite, deployCore);
|
|
53
54
|
});
|
|
54
55
|
|
|
55
56
|
program
|
package/src/next/config.js
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
export const environments = ['dev', 'qa', 'uat', 'stage', 'prod'];
|
|
2
2
|
|
|
3
|
+
export const environmentConfig = {
|
|
4
|
+
dev: {
|
|
5
|
+
newUrl: (site) => `${site}.dev.dpai.tech`,
|
|
6
|
+
oldUrl: (site) => `https://www.dev.docupaceinc.com/${site}`,
|
|
7
|
+
},
|
|
8
|
+
qa: {
|
|
9
|
+
newUrl: (site) => `${site}.qa.dpai.tech`,
|
|
10
|
+
oldUrl: (site) => `https://www.preprod.docupaceinc.com/${site}`,
|
|
11
|
+
},
|
|
12
|
+
uat: {
|
|
13
|
+
newUrl: (site) => `${site}.qa.dpai.tech`,
|
|
14
|
+
oldUrl: (site) => `https://www2.paperout.com/${site}_uat`,
|
|
15
|
+
},
|
|
16
|
+
stage: {
|
|
17
|
+
newUrl: (site) => `${site}.stage.dpai.tech`,
|
|
18
|
+
oldUrl: (site) => `https://www2.paperout.com/${site}_staging`,
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
prod: {
|
|
22
|
+
newUrl: (site) => `${site}.dpai.tech`,
|
|
23
|
+
oldUrl: (site) => `https://www2.paperout.com/${site}`,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
3
27
|
export const appInfo = {
|
|
4
28
|
'graphql-server': {
|
|
5
29
|
repositoryName: 'docupace-graphql-server',
|
|
@@ -43,6 +67,6 @@ export const getRepUrl = (repoName) => {
|
|
|
43
67
|
const { username, password, workspace } = getBitbucketInfo();
|
|
44
68
|
const repoUrl = `https://${username}:${password}@bitbucket.org/${workspace}/${repoName}.git`;
|
|
45
69
|
return repoUrl;
|
|
46
|
-
}
|
|
70
|
+
};
|
|
47
71
|
|
|
48
72
|
export const jfRegistryUrl = 'registry.paperout.com';
|
package/src/next/deploy.js
CHANGED
|
@@ -3,8 +3,10 @@ import path from 'path';
|
|
|
3
3
|
import yaml from 'js-yaml';
|
|
4
4
|
import { $ } from 'zx';
|
|
5
5
|
import lodash from 'lodash';
|
|
6
|
-
import {appInfo,
|
|
6
|
+
import { appInfo, environmentConfig, getRepUrl } from './config.js';
|
|
7
7
|
import { copy } from './copy.js';
|
|
8
|
+
import axios from 'axios';
|
|
9
|
+
import { runPipeline } from './pipline.js';
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Clone the repository, read the YAML file, and return the parsed data and file paths.
|
|
@@ -186,7 +188,69 @@ export async function deploy(application, site) {
|
|
|
186
188
|
console.log('Deployment completed successfully.');
|
|
187
189
|
}
|
|
188
190
|
|
|
189
|
-
|
|
191
|
+
async function getAppInfo(coreUrl) {
|
|
192
|
+
const url = `${coreUrl}/b2b/rest/v1/appinfo`;
|
|
193
|
+
return await axios.get(url);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function getBranchNameFromVersion(version) {
|
|
197
|
+
const match = version.match(/(\d+\.\d+\.[^\-]+)(?:-(\d+)-g([a-f0-9]+))?/);
|
|
198
|
+
|
|
199
|
+
if (!match) {
|
|
200
|
+
throw new Error(`Invalid version format: ${version}`);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const fullVersion = match[1]; // e.g., 24.19.19, 24.20.alpha3, etc.
|
|
204
|
+
const customBranch = match[2]; // e.g., 4, 58, or 0
|
|
205
|
+
const commitHash = match[3]; // e.g., 668edef58e, 634cf6c904, etc.
|
|
206
|
+
|
|
207
|
+
// If "alpha" is in the version or customBranch is non-zero, use the commit hash
|
|
208
|
+
if (fullVersion.includes('alpha') || (customBranch && customBranch !== '0')) {
|
|
209
|
+
return commitHash;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Otherwise, use the full version
|
|
213
|
+
return fullVersion;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
async function getCoreBranchName(fromEnv, fromSite) {
|
|
217
|
+
const envConfig = environmentConfig[fromEnv];
|
|
218
|
+
const oldUrl = envConfig.oldUrl(fromSite);
|
|
219
|
+
const newUrl = envConfig.newUrl(fromSite) + '/core';
|
|
220
|
+
|
|
221
|
+
let appinfo;
|
|
222
|
+
try {
|
|
223
|
+
appinfo = await getAppInfo(oldUrl);
|
|
224
|
+
} catch {
|
|
225
|
+
try {
|
|
226
|
+
appinfo = await getAppInfo(newUrl);
|
|
227
|
+
} catch {
|
|
228
|
+
throw new Error('Cannot get app info');
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const coreVersion = appinfo.data.core.version;
|
|
233
|
+
const branchName = getBranchNameFromVersion(coreVersion);
|
|
234
|
+
return branchName;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export async function deployFromSite(
|
|
238
|
+
fromEnv,
|
|
239
|
+
fromSite,
|
|
240
|
+
toEnv,
|
|
241
|
+
toSite,
|
|
242
|
+
deployCore,
|
|
243
|
+
) {
|
|
244
|
+
if (deployCore === 'true') {
|
|
245
|
+
const branchName = await getCoreBranchName(fromEnv, fromSite);
|
|
246
|
+
await runPipeline('site-deploy', 'deploy-core', 'main', {
|
|
247
|
+
ENV: toEnv,
|
|
248
|
+
SITE: toSite,
|
|
249
|
+
LIQUIBASE: 'true',
|
|
250
|
+
BRANCH: branchName,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
190
254
|
// Clone repositories for source and target environments
|
|
191
255
|
const fromRepoPath = await cloneEnvRepository(fromEnv);
|
|
192
256
|
const toRepoPath =
|