@docupace/pipeline 1.0.39-matttest.28 → 1.0.39-matttest.3
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/next/execute.sh +2 -8
- package/package.json +2 -4
- package/src/auth0/configure.js +4 -4
- package/src/auth0/metadata.js +2 -1
- package/src/changeset/cli.js +220 -59
- package/src/changeset/validate.js +24 -25
- package/src/jenkins/setParams.groovy +2 -1
- package/src/next/apache.js +35 -38
- package/src/next/cli.js +13 -4
- package/src/next/deploy.js +1 -1
- package/src/next/haproxy.js +26 -25
- package/src/next/jira.js +6 -3
- package/src/next/publish.js +30 -53
- package/src/next/util.js +42 -46
- package/src/next/vault.js +5 -7
- package/README.md +0 -136
- package/src/changeset/create.js +0 -182
- package/src/changeset/util.js +0 -27
- package/src/changeset/version.js +0 -89
- package/src/next/logger.js +0 -17
package/next/execute.sh
CHANGED
|
@@ -53,14 +53,8 @@ copy() {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
publish() {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
SLUG_SUFFIX="-${APP_NAME}"
|
|
59
|
-
fi
|
|
60
|
-
|
|
61
|
-
BUILD_IMAGE_NAME="${BITBUCKET_REPO_SLUG}${SLUG_SUFFIX}:build-${BITBUCKET_BUILD_NUMBER}"
|
|
62
|
-
IMAGE_NAME="${BITBUCKET_REPO_SLUG}${SLUG_SUFFIX}:sha-${GIT_SHA}"
|
|
63
|
-
|
|
56
|
+
BUILD_IMAGE_NAME="${BITBUCKET_REPO_SLUG}:build-${BITBUCKET_BUILD_NUMBER}"
|
|
57
|
+
IMAGE_NAME="${BITBUCKET_REPO_SLUG}:sha-${GIT_SHA}"
|
|
64
58
|
export DOCKER_HOST=""
|
|
65
59
|
|
|
66
60
|
echo "Publishing Docker image ${IMAGE_NAME}..."
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docupace/pipeline",
|
|
3
|
-
"version": "1.0.39-matttest.
|
|
3
|
+
"version": "1.0.39-matttest.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"commander": "^12.1.0",
|
|
24
24
|
"dotenv": "^16.4.7",
|
|
25
25
|
"fs-extra": "^11.3.0",
|
|
26
|
-
"inquirer": "^12.6.1",
|
|
27
26
|
"js-yaml": "^4.1.0",
|
|
28
27
|
"lodash": "^4.17.21",
|
|
29
28
|
"openai": "^4.76.3",
|
|
@@ -43,7 +42,6 @@
|
|
|
43
42
|
"test-deploy-core": "dp-next-cli deploy-core-pipeline dev template",
|
|
44
43
|
"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",
|
|
45
44
|
"test-run-pipline": "dp-next-cli run-pipeline -r docupace-next-e2e -b master -p run-tests-qa",
|
|
46
|
-
"test-validate": "dp-changset-cli validate"
|
|
47
|
-
"test-create": "dp-changset-cli create-changeset"
|
|
45
|
+
"test-validate": "dp-changset-cli validate"
|
|
48
46
|
}
|
|
49
47
|
}
|
package/src/auth0/configure.js
CHANGED
|
@@ -5,16 +5,16 @@ import crypto from 'crypto';
|
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
cloneEnvRepository,
|
|
8
|
-
cloneRepository,
|
|
9
|
-
pushDeployConfig,
|
|
10
8
|
readDeployConfig,
|
|
9
|
+
pushDeployConfig,
|
|
10
|
+
cloneRepository,
|
|
11
11
|
} from '../next/deploy.js';
|
|
12
12
|
|
|
13
13
|
import { getVaultSecrets, updateVaultSecrets } from './vault.js';
|
|
14
14
|
import {
|
|
15
|
-
coreSiteEnvMap,
|
|
16
|
-
environmentConfig,
|
|
17
15
|
getVaultSecretsConfigs,
|
|
16
|
+
environmentConfig,
|
|
17
|
+
coreSiteEnvMap,
|
|
18
18
|
} from '../next/config.js';
|
|
19
19
|
|
|
20
20
|
async function ensureDirectoryExists(dirPath) {
|
package/src/auth0/metadata.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import { cloneRepository
|
|
4
|
+
import { cloneRepository } from '../next/deploy.js';
|
|
5
5
|
import { getAuth0AuthToken } from './configure.js';
|
|
6
6
|
import { getVaultSecrets } from './vault.js';
|
|
7
7
|
import { getVaultSecretsConfigs } from '../next/config.js';
|
|
8
|
+
import { pushDeployConfig } from '../next/deploy.js';
|
|
8
9
|
|
|
9
10
|
export async function getAuth0Metadata(site, env) {
|
|
10
11
|
try {
|
package/src/changeset/cli.js
CHANGED
|
@@ -1,71 +1,146 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { $ } from 'zx';
|
|
4
|
+
import path from 'path';
|
|
4
5
|
import { validateChangesets } from './validate.js';
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import OpenAI from 'openai';
|
|
8
|
+
import { zodResponseFormat } from 'openai/helpers/zod';
|
|
9
|
+
import z from 'zod';
|
|
5
10
|
import dotenv from 'dotenv';
|
|
6
|
-
import {
|
|
7
|
-
import { updateJiraWithVersion, versionCommand } from './version.js';
|
|
8
|
-
import { createChangeset } from './create.js';
|
|
9
|
-
|
|
11
|
+
import { makeJiraRequest, updateComponentVersion } from '../next/jira.js';
|
|
10
12
|
dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
|
|
13
|
+
import { setGitInfo } from '../next/util.js';
|
|
11
14
|
|
|
12
15
|
const program = new Command();
|
|
13
16
|
|
|
14
17
|
const args = process.argv;
|
|
15
18
|
|
|
16
|
-
async function
|
|
17
|
-
|
|
19
|
+
async function createChangesetDirectory() {
|
|
20
|
+
try {
|
|
21
|
+
// Use path.join to build a safe path to `.changeset`
|
|
22
|
+
const targetDir = path.join(process.cwd(), '.changeset');
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
console.
|
|
23
|
-
return;
|
|
24
|
+
// Create the directory recursively if it doesn't exist
|
|
25
|
+
await fs.promises.mkdir(targetDir, { recursive: true });
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error('Error creating .changeset directory:', error);
|
|
24
28
|
}
|
|
29
|
+
}
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
function run(command) {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
exec(command, { shell: true }, (error, stdout, stderr) => {
|
|
34
|
+
if (error) {
|
|
35
|
+
reject(error);
|
|
36
|
+
} else {
|
|
37
|
+
resolve({ stdout, stderr });
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
29
42
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
async function fileExists(filePath) {
|
|
44
|
+
try {
|
|
45
|
+
await fs.promises.access(filePath);
|
|
46
|
+
return true;
|
|
47
|
+
} catch {
|
|
48
|
+
return false;
|
|
34
49
|
}
|
|
35
50
|
}
|
|
36
51
|
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
52
|
+
async function getMainPackage() {
|
|
53
|
+
const mainModulePath = process.cwd();
|
|
54
|
+
if (mainModulePath) {
|
|
55
|
+
const packageJsonPath = path.join(mainModulePath, 'package.json');
|
|
56
|
+
if (await fileExists(packageJsonPath)) {
|
|
57
|
+
const fileContent = await fs.promises.readFile(packageJsonPath, 'utf-8');
|
|
58
|
+
const packageJson = JSON.parse(fileContent);
|
|
59
|
+
return packageJson;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
throw new Error('Main package.json not found');
|
|
42
63
|
}
|
|
43
64
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
65
|
+
const changeSetPackage = `{
|
|
66
|
+
"name": "changeset-package",
|
|
67
|
+
"version": "1.0.0",
|
|
68
|
+
"description": "",
|
|
69
|
+
"scripts": {
|
|
70
|
+
},
|
|
71
|
+
"type": "module",
|
|
72
|
+
"keywords": [],
|
|
73
|
+
"author": "",
|
|
74
|
+
"license": "ISC",
|
|
75
|
+
"dependencies": {},
|
|
76
|
+
"devDependencies": {
|
|
77
|
+
"@changesets/cli": "^2.27.10"
|
|
78
|
+
}
|
|
50
79
|
}
|
|
80
|
+
`;
|
|
51
81
|
|
|
52
|
-
async function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
82
|
+
async function versionCommand(closeVersion = false) {
|
|
83
|
+
console.log('📦 Running Changeset versioning...');
|
|
84
|
+
await setGitInfo();
|
|
85
|
+
await $`mv package.json package.json.bak`;
|
|
86
|
+
await $`mv pnpm-lock.yaml pnpm-lock.yaml.bak`;
|
|
87
|
+
await fs.promises.writeFile('package.json', changeSetPackage);
|
|
88
|
+
await $`pnpm install`;
|
|
89
|
+
await $`rm package.json pnpm-lock.yaml`;
|
|
90
|
+
await $`mv package.json.bak package.json`;
|
|
91
|
+
await $`mv pnpm-lock.yaml.bak pnpm-lock.yaml`;
|
|
92
|
+
if (closeVersion) {
|
|
93
|
+
await $`pnpm changeset pre exit`;
|
|
58
94
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
95
|
+
|
|
96
|
+
await $`pnpm changeset version`;
|
|
97
|
+
|
|
98
|
+
// Read the updated package.json to get the new version and package name
|
|
99
|
+
const packageJson = JSON.parse(
|
|
100
|
+
await fs.promises.readFile('package.json', 'utf-8'),
|
|
101
|
+
);
|
|
102
|
+
const version = packageJson.version;
|
|
103
|
+
const packageName = packageJson.name;
|
|
104
|
+
|
|
105
|
+
if (closeVersion) {
|
|
106
|
+
return { version, packageName };
|
|
63
107
|
}
|
|
64
|
-
|
|
65
|
-
|
|
108
|
+
|
|
109
|
+
// Get the last commit message and extract Jira ticket
|
|
110
|
+
const lastCommit = (await $`git log -1 --pretty=%B`).stdout.trim();
|
|
111
|
+
console.log(`Last commit '${lastCommit}' being processed to get Jira ticket`);
|
|
112
|
+
|
|
113
|
+
const jiraTicketMatch = lastCommit.match(/([A-Z]+-\d+)/);
|
|
114
|
+
const jiraTicketId = jiraTicketMatch ? jiraTicketMatch[0] : null;
|
|
115
|
+
|
|
116
|
+
// If we have all the necessary data, update the component version in Jira
|
|
117
|
+
if (jiraTicketId && version && packageName) {
|
|
118
|
+
try {
|
|
119
|
+
await updateComponentVersion(jiraTicketId, packageName, version);
|
|
120
|
+
} catch (error) {
|
|
121
|
+
console.error(
|
|
122
|
+
`Failed to update Jira component version: ${error.message}`,
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
console.log('✅ Changeset versioning complete.');
|
|
128
|
+
return { version, packageName };
|
|
66
129
|
}
|
|
67
130
|
|
|
68
|
-
async function
|
|
131
|
+
async function commitTagCommand() {
|
|
132
|
+
console.log('📌 Checking for updates to commit...');
|
|
133
|
+
|
|
134
|
+
// Check if there are changes to commit
|
|
135
|
+
const status = (await $`git status --porcelain`).stdout.trim();
|
|
136
|
+
if (!status) {
|
|
137
|
+
console.log('✅ No changes to commit. Exiting.');
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
console.log('📌 Committing and tagging the new version...');
|
|
142
|
+
await setGitInfo();
|
|
143
|
+
await $`git add .`;
|
|
69
144
|
const newVersion = (
|
|
70
145
|
await $`node -p "require('./package.json').version"`
|
|
71
146
|
).stdout.trim();
|
|
@@ -88,7 +163,7 @@ program
|
|
|
88
163
|
try {
|
|
89
164
|
await validateChangesets();
|
|
90
165
|
console.log('✅ Changeset validation passed.');
|
|
91
|
-
} catch {
|
|
166
|
+
} catch (error) {
|
|
92
167
|
console.error(
|
|
93
168
|
'❌ No changeset found. Please add a changeset to this PR. Please see more information at https://docupacellc.atlassian.net/wiki/spaces/PM/pages/1350893571/Creating+changesets+for+Docupace+Next',
|
|
94
169
|
);
|
|
@@ -117,9 +192,8 @@ program
|
|
|
117
192
|
.description('Run versioning and commit-and-tag in sequence')
|
|
118
193
|
.action(async () => {
|
|
119
194
|
console.log('📦 Running all steps...');
|
|
120
|
-
|
|
121
|
-
await
|
|
122
|
-
await commitTagCommand(releases);
|
|
195
|
+
await versionCommand();
|
|
196
|
+
await commitTagCommand();
|
|
123
197
|
});
|
|
124
198
|
|
|
125
199
|
program
|
|
@@ -127,21 +201,15 @@ program
|
|
|
127
201
|
.description('Closes a version')
|
|
128
202
|
.action(async () => {
|
|
129
203
|
console.log('📦 Running all steps...');
|
|
130
|
-
const
|
|
131
|
-
await commitTagCommand(
|
|
204
|
+
const { version } = await versionCommand(true);
|
|
205
|
+
await commitTagCommand();
|
|
132
206
|
|
|
207
|
+
// Get current branch
|
|
133
208
|
const { stdout: currentBranch } = await $`git rev-parse --abbrev-ref HEAD`;
|
|
134
209
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
await $`git checkout -b release/${appName}/${release.newVersion}`;
|
|
139
|
-
await $`git push origin release/${appName}/${release.newVersion}`;
|
|
140
|
-
}
|
|
141
|
-
} else {
|
|
142
|
-
await $`git checkout -b release/${releases[0].newVersion}`;
|
|
143
|
-
await $`git push origin release/${releases[0].newVersion}`;
|
|
144
|
-
}
|
|
210
|
+
// Create and push release branch
|
|
211
|
+
await $`git checkout -b release/${version}`;
|
|
212
|
+
await $`git push origin release/${version}`;
|
|
145
213
|
|
|
146
214
|
// Return to original branch
|
|
147
215
|
await $`git checkout ${currentBranch.trim()}`;
|
|
@@ -159,7 +227,100 @@ program
|
|
|
159
227
|
'Creates a changeset based on the current branch and Jira ticket information',
|
|
160
228
|
)
|
|
161
229
|
.action(async () => {
|
|
162
|
-
await
|
|
230
|
+
const mainPackage = await getMainPackage();
|
|
231
|
+
const componentName = mainPackage.name;
|
|
232
|
+
|
|
233
|
+
try {
|
|
234
|
+
// Step 1: Get the current branch name
|
|
235
|
+
const branchName = (await $`git branch --show-current`).stdout.trim();
|
|
236
|
+
console.log(`Current branch: ${branchName}`);
|
|
237
|
+
|
|
238
|
+
// Step 2: Extract Jira ticket number (e.g., matching JIRA-1234 pattern)
|
|
239
|
+
const jiraTicketMatch = branchName.match(/([A-Z]+-\d+)/);
|
|
240
|
+
if (!jiraTicketMatch) {
|
|
241
|
+
throw new Error('No Jira ticket found in the branch name.');
|
|
242
|
+
}
|
|
243
|
+
const jiraTicketId = jiraTicketMatch[0];
|
|
244
|
+
|
|
245
|
+
const jiraBaseUrl = 'https://docupacellc.atlassian.net';
|
|
246
|
+
const jiraEmail = process.env.JIRA_API_EMAIL;
|
|
247
|
+
const jiraApiKey = process.env.JIRA_API_KEY;
|
|
248
|
+
const jiraFullApiKey = `${jiraEmail}:${jiraApiKey}`;
|
|
249
|
+
const jiraUrl = `${jiraBaseUrl}/rest/api/2/issue/${jiraTicketId}`;
|
|
250
|
+
const jiraResponse = await fetch(jiraUrl, {
|
|
251
|
+
headers: {
|
|
252
|
+
Authorization: `Basic ${Buffer.from(jiraFullApiKey).toString('base64')}`,
|
|
253
|
+
'Content-Type': 'application/json',
|
|
254
|
+
},
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
if (!jiraResponse.ok) {
|
|
258
|
+
throw new Error(
|
|
259
|
+
`Failed to fetch Jira ticket. Status: ${jiraResponse.status}`,
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
const jiraTicketData = await jiraResponse.json();
|
|
263
|
+
|
|
264
|
+
const jiraSummary = jiraTicketData.fields.summary;
|
|
265
|
+
|
|
266
|
+
console.log(
|
|
267
|
+
`Generating release notes for ${jiraTicketId} - ${jiraSummary}`,
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
const openaiClient = new OpenAI({
|
|
271
|
+
apiKey: process.env['OPENAI_API_KEY'],
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
const ChangeRequestSchema = z.object({
|
|
275
|
+
change_type: z.enum(['patch', 'minor']),
|
|
276
|
+
summary: z.string(),
|
|
277
|
+
jira_ticket_id: z.string(),
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const openAiResponse = await openaiClient.chat.completions.create({
|
|
281
|
+
model: 'gpt-4o-mini',
|
|
282
|
+
messages: [
|
|
283
|
+
{
|
|
284
|
+
role: 'system',
|
|
285
|
+
content: `Process JSON from a Jira ticket to generate simple maximum 2 sentence release note for the ticket and determine the change type for bug it should be a patch for new feature it should be a minor change`,
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
role: 'user',
|
|
289
|
+
content: JSON.stringify(jiraTicketData),
|
|
290
|
+
},
|
|
291
|
+
],
|
|
292
|
+
response_format: zodResponseFormat(
|
|
293
|
+
ChangeRequestSchema,
|
|
294
|
+
'changeset_schema',
|
|
295
|
+
),
|
|
296
|
+
temperature: 0,
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
const assistantResponse = openAiResponse.choices[0].message.content;
|
|
300
|
+
const parsedResponse = JSON.parse(assistantResponse);
|
|
301
|
+
|
|
302
|
+
const { change_type, summary } = parsedResponse;
|
|
303
|
+
console.log(`Change type: ${change_type}`);
|
|
304
|
+
console.log(`Release note: ${summary}`);
|
|
305
|
+
|
|
306
|
+
// Step 5: Create a changeset .md file
|
|
307
|
+
const changesetContent = `---
|
|
308
|
+
"${componentName}": ${change_type}
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
${summary} [${jiraTicketId}]
|
|
312
|
+
`;
|
|
313
|
+
const changesetFile = `./.changeset/${jiraTicketId}.md`;
|
|
314
|
+
|
|
315
|
+
await createChangesetDirectory();
|
|
316
|
+
await fs.promises.writeFile(changesetFile, changesetContent);
|
|
317
|
+
console.log(`Created changeset file at ${changesetFile}`);
|
|
318
|
+
|
|
319
|
+
console.log('Done!');
|
|
320
|
+
} catch (err) {
|
|
321
|
+
console.error(`Error: ${err.message}`);
|
|
322
|
+
process.exit(1);
|
|
323
|
+
}
|
|
163
324
|
});
|
|
164
325
|
|
|
165
326
|
// Parse arguments
|
|
@@ -2,40 +2,39 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { $ } from 'zx';
|
|
4
4
|
|
|
5
|
-
import { isMonoRepo, setGitInfo } from '../next/util.js';
|
|
6
|
-
import { versionStatus } from './version.js';
|
|
5
|
+
import { getChangedPackages, isMonoRepo, setGitInfo } from '../next/util.js';
|
|
7
6
|
|
|
8
7
|
const CHANGESET_DIR = '.changeset';
|
|
9
8
|
|
|
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
9
|
export async function validateChangesets() {
|
|
20
|
-
if (isMonoRepo()) {
|
|
21
|
-
|
|
10
|
+
/*if (isMonoRepo()) {
|
|
11
|
+
const branch = process.env.BITBUCKET_BRANCH;
|
|
22
12
|
const destBranch = process.env.BITBUCKET_PR_DESTINATION_BRANCH;
|
|
23
|
-
|
|
24
|
-
await
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
(changedPackage) => changedPackage.name,
|
|
13
|
+
|
|
14
|
+
const changePackages = await getChangedPackages(destBranch, branch);
|
|
15
|
+
|
|
16
|
+
const appPackages = changePackages.filter((appPackage) =>
|
|
17
|
+
appPackage.name.endsWith('-app'),
|
|
29
18
|
);
|
|
30
19
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
)
|
|
35
|
-
|
|
20
|
+
let appPaths;
|
|
21
|
+
if (appPackages.length > 0) {
|
|
22
|
+
appPaths = appPackages.map((appPackage) => appPackage.path);
|
|
23
|
+
for (const appPath of appPaths) {
|
|
24
|
+
const changesetPath = path.resolve(appPath, CHANGESET_DIR);
|
|
25
|
+
await validateChangesetPath(changesetPath);
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
throw new Error('No changeset for at least one app');
|
|
29
|
+
}
|
|
36
30
|
} else {
|
|
37
31
|
await validateChangesetPath(path.resolve(process.cwd(), CHANGESET_DIR));
|
|
38
|
-
}
|
|
32
|
+
}*/
|
|
33
|
+
|
|
34
|
+
await setGitInfo();
|
|
35
|
+
const destBranch = process.env.BITBUCKET_PR_DESTINATION_BRANCH;
|
|
36
|
+
await $`git fetch origin ${destBranch}:${destBranch}`;
|
|
37
|
+
await $`changeset status --since=${destBranch}`;
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
export async function validateChangesetPath(directoryPath) {
|
package/src/next/apache.js
CHANGED
|
@@ -1,43 +1,40 @@
|
|
|
1
1
|
import { $ } from 'zx';
|
|
2
2
|
|
|
3
3
|
export async function addApacheSite() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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}`);
|
|
22
34
|
|
|
23
|
-
|
|
24
|
-
await fs.chmod('private.key', 0o600);
|
|
35
|
+
server = `${process.env.ENVIRONMENT}-apalb01b.corp.docupace.com`;
|
|
25
36
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
let server = `${process.env.ENVIRONMENT}-apalb01a.corp.docupace.com`;
|
|
31
|
-
// The script is run twice in the Bash version
|
|
32
|
-
await sshCmd(
|
|
33
|
-
server,
|
|
34
|
-
`/root/repo/iis-preprod/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`,
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
server = `${process.env.ENVIRONMENT}-apalb01b.corp.docupace.com`;
|
|
38
|
-
|
|
39
|
-
await sshCmd(
|
|
40
|
-
server,
|
|
41
|
-
`/root/repo/iis-preprod/scripts/addsite/add_core_site.sh ${process.env.ENVIRONMENT} ${process.env.SITE}`,
|
|
42
|
-
);
|
|
43
|
-
}
|
|
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
|
@@ -7,24 +7,26 @@ import { publish } from './publish.js';
|
|
|
7
7
|
import {
|
|
8
8
|
deployAppWithTag,
|
|
9
9
|
deployFromSite,
|
|
10
|
-
deployTemplate,
|
|
11
10
|
getDefaultDeploySite,
|
|
12
11
|
getDeployTag,
|
|
13
12
|
} from './deploy.js';
|
|
13
|
+
import { deployTemplate } from './deploy.js';
|
|
14
14
|
import { copy } from './copy.js';
|
|
15
15
|
import { vaultAddSiteData } from './vault.js';
|
|
16
16
|
import { addApacheSite } from './apache.js';
|
|
17
17
|
import { haproxySync } from './haproxy.js';
|
|
18
18
|
import { connectClone } from './connect.js';
|
|
19
19
|
import dotenv from 'dotenv';
|
|
20
|
-
import { $ } from 'zx';
|
|
21
|
-
import { deployConnect, deployCore } from './jenkins.js';
|
|
22
|
-
import { runPipeline } from './pipline.js';
|
|
23
20
|
|
|
24
21
|
dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
|
|
25
22
|
|
|
26
23
|
const program = new Command();
|
|
27
24
|
|
|
25
|
+
import { $ } from 'zx';
|
|
26
|
+
import { deployConnect, deployCore } from './jenkins.js';
|
|
27
|
+
import { runPipeline } from './pipline.js';
|
|
28
|
+
import { buildChangePackages } from './util.js';
|
|
29
|
+
|
|
28
30
|
const GIT_SHA = (await $`git log --pretty=format:'%h' -n 1`).stdout.trim();
|
|
29
31
|
|
|
30
32
|
program
|
|
@@ -163,6 +165,13 @@ program
|
|
|
163
165
|
});
|
|
164
166
|
});
|
|
165
167
|
|
|
168
|
+
program
|
|
169
|
+
.command('build-mono-repo')
|
|
170
|
+
.description('Build Mono Repo')
|
|
171
|
+
.action(async () => {
|
|
172
|
+
await buildChangePackages();
|
|
173
|
+
});
|
|
174
|
+
|
|
166
175
|
program
|
|
167
176
|
.command('copy')
|
|
168
177
|
.description('Copy a Docker image between registries')
|
package/src/next/deploy.js
CHANGED
|
@@ -6,7 +6,7 @@ import lodash from 'lodash';
|
|
|
6
6
|
import { appInfo, environmentConfig, getRepUrl } from './config.js';
|
|
7
7
|
import { copy2 } from './copy.js';
|
|
8
8
|
import axios from 'axios';
|
|
9
|
-
import {
|
|
9
|
+
import { deployCore, deployConnect } from './jenkins.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Clone the repository, read the YAML file, and return the parsed data and file paths.
|