@docupace/pipeline 1.0.33 → 1.0.35-matttest.0
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 +80 -4
- package/src/next/cli.js +29 -4
- package/src/next/config.js +9 -0
- package/src/next/deploy.js +16 -8
package/package.json
CHANGED
package/src/auth0/configure.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import crypto from 'crypto';
|
|
@@ -7,10 +7,15 @@ import {
|
|
|
7
7
|
cloneEnvRepository,
|
|
8
8
|
readDeployConfig,
|
|
9
9
|
pushDeployConfig,
|
|
10
|
+
cloneRepository,
|
|
10
11
|
} from '../next/deploy.js';
|
|
11
12
|
|
|
12
13
|
import { getVaultSecrets, updateVaultSecrets } from './vault.js';
|
|
13
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
getVaultSecretsConfigs,
|
|
16
|
+
environmentConfig,
|
|
17
|
+
coreSiteEnvMap,
|
|
18
|
+
} from '../next/config.js';
|
|
14
19
|
|
|
15
20
|
async function ensureDirectoryExists(dirPath) {
|
|
16
21
|
try {
|
|
@@ -102,6 +107,14 @@ async function configureUI(
|
|
|
102
107
|
|
|
103
108
|
await updateVaultSecrets(vaultSiteSecretsPath, uiSecretData);
|
|
104
109
|
|
|
110
|
+
let siteAWSSecrets = null;
|
|
111
|
+
|
|
112
|
+
if (useS3 === true || useS3 === 'true') {
|
|
113
|
+
const siteAWSSecretsPath = getVaultSecretsConfigs(site).awsSecretsPath;
|
|
114
|
+
siteAWSSecrets = await getVaultSecrets(siteAWSSecretsPath);
|
|
115
|
+
console.log(`siteAWSSecretsPath => ${siteAWSSecretsPath}`);
|
|
116
|
+
}
|
|
117
|
+
|
|
105
118
|
// Prepare ui.app.yaml
|
|
106
119
|
const uiAppYaml = `
|
|
107
120
|
repo: docupace-ui-main
|
|
@@ -139,7 +152,7 @@ ${
|
|
|
139
152
|
serviceAccount:
|
|
140
153
|
create: true
|
|
141
154
|
annotations:
|
|
142
|
-
eks.amazonaws.com/role-arn: arn:aws:iam
|
|
155
|
+
eks.amazonaws.com/role-arn: arn:aws:iam::${siteAWSSecrets.AWS_ACCOUNT_ID}:role/eks-pod-identity-connect-next-${env}-${site}-bucket
|
|
143
156
|
`.trim()
|
|
144
157
|
: ''
|
|
145
158
|
}
|
|
@@ -197,7 +210,6 @@ externalConnectService:
|
|
|
197
210
|
domain: ${docupaceHost}
|
|
198
211
|
`.trim();
|
|
199
212
|
|
|
200
|
-
// Write configuration files
|
|
201
213
|
console.log('Writing configuration files...');
|
|
202
214
|
await ensureDirectoryExists(path.resolve(`${repoPath}/dp/${site}`));
|
|
203
215
|
|
|
@@ -225,11 +237,75 @@ externalConnectService:
|
|
|
225
237
|
},
|
|
226
238
|
);
|
|
227
239
|
console.log('Done!');
|
|
240
|
+
console.log('Updating Core Site Config...');
|
|
241
|
+
await updateCoreSiteConfig(site, env, useS3);
|
|
228
242
|
} catch (error) {
|
|
229
243
|
console.error('Error configuring UI:', error);
|
|
230
244
|
}
|
|
231
245
|
}
|
|
232
246
|
|
|
247
|
+
export async function cleanAndWritePropertiesFile(configPath, content) {
|
|
248
|
+
try {
|
|
249
|
+
const cleanedContent = content
|
|
250
|
+
.split('\n')
|
|
251
|
+
.map((line) => line.trim())
|
|
252
|
+
.filter((line) => line !== '')
|
|
253
|
+
.join('\n');
|
|
254
|
+
|
|
255
|
+
await fs.writeFile(configPath, cleanedContent, 'utf8');
|
|
256
|
+
console.log(`Cleaned and written file to: ${configPath}`);
|
|
257
|
+
} catch (error) {
|
|
258
|
+
console.error('Error writing properties file:', error.message);
|
|
259
|
+
process.exit(1);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export async function updateCoreSiteConfig(site, env, useS3) {
|
|
264
|
+
try {
|
|
265
|
+
const coreSiteEnv = coreSiteEnvMap[env];
|
|
266
|
+
|
|
267
|
+
const coreSiteConfigRepoPath = await cloneRepository(
|
|
268
|
+
`${coreSiteEnv}-site-settings`,
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
const configPath = path.join(
|
|
272
|
+
`${coreSiteEnv}-site-settings`,
|
|
273
|
+
site.toUpperCase(),
|
|
274
|
+
'docucore-nextUI.properties',
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
let siteAWSSecrets = null;
|
|
278
|
+
|
|
279
|
+
if (useS3 === true || useS3 === 'true') {
|
|
280
|
+
const siteAWSSecretsPath = getVaultSecretsConfigs(site).awsSecretsPath;
|
|
281
|
+
siteAWSSecrets = await getVaultSecrets(siteAWSSecretsPath);
|
|
282
|
+
console.log(`siteAWSSecretsPath => ${siteAWSSecretsPath}`);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const coreSiteConfig = `
|
|
286
|
+
${
|
|
287
|
+
siteAWSSecrets
|
|
288
|
+
? `
|
|
289
|
+
com.docupace.imports.files.FilesImportConfig.aws.accessKeyId=${siteAWSSecrets.AWS_ACCESS_KEY_ID}
|
|
290
|
+
com.docupace.imports.files.FilesImportConfig.aws.accessKeySecret=${siteAWSSecrets.AWS_SECRET_ACCESS_KEY}
|
|
291
|
+
com.docupace.imports.files.FilesImportConfig.aws.region=${siteAWSSecrets.AWS_REGION}
|
|
292
|
+
`.trim()
|
|
293
|
+
: ''
|
|
294
|
+
}
|
|
295
|
+
`;
|
|
296
|
+
|
|
297
|
+
await fs.ensureDir(path.join(coreSiteConfigRepoPath, site.toUpperCase()));
|
|
298
|
+
await cleanAndWritePropertiesFile(configPath, coreSiteConfig);
|
|
299
|
+
await pushDeployConfig(
|
|
300
|
+
coreSiteConfigRepoPath,
|
|
301
|
+
`Core config: docucore-nextUI.properties for site: (${site.toUpperCase()}) update in env: (${env})`,
|
|
302
|
+
);
|
|
303
|
+
} catch (error) {
|
|
304
|
+
console.error('Error:', error.message);
|
|
305
|
+
process.exit(1);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
233
309
|
async function configureGraphQLServer(
|
|
234
310
|
siteHost,
|
|
235
311
|
coreURL,
|
package/src/next/cli.js
CHANGED
|
@@ -4,7 +4,12 @@ import { Command } from 'commander';
|
|
|
4
4
|
import { pull } from './pull.js';
|
|
5
5
|
import { sonar } from './sonar.js';
|
|
6
6
|
import { publish } from './publish.js';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
deployAppWithTag,
|
|
9
|
+
deployFromSite,
|
|
10
|
+
getDefaultDeploySite,
|
|
11
|
+
getDeployTag,
|
|
12
|
+
} from './deploy.js';
|
|
8
13
|
import { deployTemplate } from './deploy.js';
|
|
9
14
|
import { copy } from './copy.js';
|
|
10
15
|
import { vaultAddSiteData } from './vault.js';
|
|
@@ -101,10 +106,30 @@ program
|
|
|
101
106
|
});
|
|
102
107
|
|
|
103
108
|
program
|
|
104
|
-
.command('
|
|
109
|
+
.command('deploy-template')
|
|
105
110
|
.description('Deploy an application for a specific site')
|
|
106
|
-
.action(async (
|
|
107
|
-
await
|
|
111
|
+
.action(async () => {
|
|
112
|
+
const deployTag = await getDeployTag();
|
|
113
|
+
const { env, site } = await getDefaultDeploySite(deployTag);
|
|
114
|
+
await deployTemplate(env, site, deployTag);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
program
|
|
118
|
+
.command('deployTemplate')
|
|
119
|
+
.description('Deploy an application for a specific site')
|
|
120
|
+
.action(async () => {
|
|
121
|
+
const deployTag = await getDeployTag();
|
|
122
|
+
const { env, site } = await getDefaultDeploySite(deployTag);
|
|
123
|
+
await deployTemplate(env, site, deployTag);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
program
|
|
127
|
+
.command('deploy-app <application>')
|
|
128
|
+
.description('Deploy an application for a specific site')
|
|
129
|
+
.action(async (application) => {
|
|
130
|
+
const deployTag = await getDeployTag();
|
|
131
|
+
const { env, site } = await getDefaultDeploySite(deployTag);
|
|
132
|
+
await deployAppWithTag(application, env, site, deployTag);
|
|
108
133
|
});
|
|
109
134
|
|
|
110
135
|
program
|
package/src/next/config.js
CHANGED
|
@@ -80,5 +80,14 @@ export const getVaultSecretsConfigs = (site) => {
|
|
|
80
80
|
siteCommonSecretsPath: `secret/data/${site}/common/config`,
|
|
81
81
|
graphqlServerSecretsPath: `secret/data/${site}/graphql-server/config`,
|
|
82
82
|
uiSecretsPath: `secret/data/${site}/ui/config`,
|
|
83
|
+
awsSecretsPath: `secret/data/${site}/aws/config`,
|
|
83
84
|
};
|
|
84
85
|
};
|
|
86
|
+
|
|
87
|
+
export const coreSiteEnvMap = {
|
|
88
|
+
dev: 'dev',
|
|
89
|
+
qa: 'preprod',
|
|
90
|
+
stg: 'staging',
|
|
91
|
+
uat: 'uat',
|
|
92
|
+
prd: 'prod',
|
|
93
|
+
};
|
package/src/next/deploy.js
CHANGED
|
@@ -266,7 +266,7 @@ export async function writeAndPushDeployConfig(
|
|
|
266
266
|
* @param {string} site - The site name.
|
|
267
267
|
*/
|
|
268
268
|
|
|
269
|
-
async function getDeployTag() {
|
|
269
|
+
export async function getDeployTag() {
|
|
270
270
|
const gitTag = (
|
|
271
271
|
await $`git tag --points-at HEAD | grep '^v' | head -n 1`
|
|
272
272
|
).stdout.trim();
|
|
@@ -274,12 +274,17 @@ async function getDeployTag() {
|
|
|
274
274
|
return deployTag;
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
export async function
|
|
278
|
-
const
|
|
277
|
+
export async function getDefaultDeploySite(deployTag) {
|
|
278
|
+
const env = deployTag.includes('alpha') ? 'dev' : 'qa';
|
|
279
|
+
const site = env === 'dev' ? 'financialdev' : 'qa';
|
|
280
|
+
return { env, site };
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export async function deployTemplate(env, site, deployTag) {
|
|
279
284
|
console.log(`Deploying standard template for site: ${site}`);
|
|
280
285
|
console.log(`Using deployment tag: ${deployTag}`);
|
|
281
286
|
const { repoPath, deployConfigFilePath, deployConfig } =
|
|
282
|
-
await cloneAndReadDeployConfig('graphql-server',
|
|
287
|
+
await cloneAndReadDeployConfig('graphql-server', env, site);
|
|
283
288
|
|
|
284
289
|
deployConfig.graphqlServer.standardConfigRemoteBranch = deployTag;
|
|
285
290
|
|
|
@@ -292,14 +297,17 @@ export async function deployTemplate(site) {
|
|
|
292
297
|
console.log('Deployment completed successfully.');
|
|
293
298
|
}
|
|
294
299
|
|
|
295
|
-
export async function
|
|
296
|
-
const deployTag = getDeployTag();
|
|
297
|
-
|
|
300
|
+
export async function deployAppWithTag(application, env, site, deployTag) {
|
|
298
301
|
console.log(`Deploying application: ${application} for site: ${site}`);
|
|
299
302
|
console.log(`Using deployment tag: ${deployTag}`);
|
|
300
303
|
|
|
304
|
+
if (env !== 'dev') {
|
|
305
|
+
const appDetails = appInfo[application];
|
|
306
|
+
await copy2(appDetails.repositoryName, 'dev', env, deployTag);
|
|
307
|
+
}
|
|
308
|
+
|
|
301
309
|
const { repoPath, deployConfigFilePath, deployConfig } =
|
|
302
|
-
await cloneAndReadDeployConfig(application,
|
|
310
|
+
await cloneAndReadDeployConfig(application, env, site);
|
|
303
311
|
const updatedConfigData = setTag(deployConfig, deployTag);
|
|
304
312
|
await writeAndPushDeployConfig(
|
|
305
313
|
repoPath,
|