@docupace/pipeline 1.0.39-matttest.39 → 1.0.39-matttest.4
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 -5
- package/src/auth0/configure.js +4 -4
- package/src/auth0/metadata.js +2 -1
- package/src/changeset/cli.js +219 -67
- 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 -14
- package/src/next/config.js +0 -16
- package/src/next/deploy.js +3 -7
- 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 -44
- package/src/next/vault.js +5 -7
- package/README.md +0 -136
- package/src/changeset/create.js +0 -205
- package/src/changeset/package-util.js +0 -86
- 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.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,11 +23,9 @@
|
|
|
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",
|
|
30
|
-
"semver": "^7.7.2",
|
|
31
29
|
"zod": "^3.24.1",
|
|
32
30
|
"zx": "^8.3.0"
|
|
33
31
|
},
|
|
@@ -44,7 +42,6 @@
|
|
|
44
42
|
"test-deploy-core": "dp-next-cli deploy-core-pipeline dev template",
|
|
45
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",
|
|
46
44
|
"test-run-pipline": "dp-next-cli run-pipeline -r docupace-next-e2e -b master -p run-tests-qa",
|
|
47
|
-
"test-validate": "dp-changset-cli validate"
|
|
48
|
-
"test-create": "dp-changset-cli create-changeset"
|
|
45
|
+
"test-validate": "dp-changset-cli validate"
|
|
49
46
|
}
|
|
50
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,85 +1,151 @@
|
|
|
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
95
|
|
|
60
|
-
|
|
61
|
-
const defaultBranch = stdout.trim().replace('refs/remotes/origin/', '');
|
|
96
|
+
await $`pnpm changeset version`;
|
|
62
97
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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 };
|
|
68
107
|
}
|
|
69
|
-
|
|
70
|
-
|
|
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 };
|
|
71
129
|
}
|
|
72
130
|
|
|
73
|
-
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 .`;
|
|
74
144
|
const newVersion = (
|
|
75
145
|
await $`node -p "require('./package.json').version"`
|
|
76
146
|
).stdout.trim();
|
|
77
|
-
|
|
78
|
-
const { stdout } = await $`git symbolic-ref refs/remotes/origin/HEAD`;
|
|
79
|
-
const defaultBranch = stdout.trim().replace('refs/remotes/origin/', '');
|
|
80
|
-
|
|
81
147
|
await $`git commit -m "Version bump to ${newVersion} and changelog"`;
|
|
82
|
-
await $`git push origin
|
|
148
|
+
await $`git push origin`;
|
|
83
149
|
await $`git tag v${newVersion}`;
|
|
84
150
|
await $`git push origin --tags`;
|
|
85
151
|
console.log(`✅ Version ${newVersion} tagged and pushed.`);
|
|
@@ -97,7 +163,7 @@ program
|
|
|
97
163
|
try {
|
|
98
164
|
await validateChangesets();
|
|
99
165
|
console.log('✅ Changeset validation passed.');
|
|
100
|
-
} catch {
|
|
166
|
+
} catch (error) {
|
|
101
167
|
console.error(
|
|
102
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',
|
|
103
169
|
);
|
|
@@ -126,9 +192,8 @@ program
|
|
|
126
192
|
.description('Run versioning and commit-and-tag in sequence')
|
|
127
193
|
.action(async () => {
|
|
128
194
|
console.log('📦 Running all steps...');
|
|
129
|
-
|
|
130
|
-
await
|
|
131
|
-
await commitTagCommand(releases);
|
|
195
|
+
await versionCommand();
|
|
196
|
+
await commitTagCommand();
|
|
132
197
|
});
|
|
133
198
|
|
|
134
199
|
program
|
|
@@ -136,21 +201,15 @@ program
|
|
|
136
201
|
.description('Closes a version')
|
|
137
202
|
.action(async () => {
|
|
138
203
|
console.log('📦 Running all steps...');
|
|
139
|
-
const
|
|
140
|
-
await commitTagCommand(
|
|
204
|
+
const { version } = await versionCommand(true);
|
|
205
|
+
await commitTagCommand();
|
|
141
206
|
|
|
207
|
+
// Get current branch
|
|
142
208
|
const { stdout: currentBranch } = await $`git rev-parse --abbrev-ref HEAD`;
|
|
143
209
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
await $`git checkout -b release/${appName}/${release.newVersion}`;
|
|
148
|
-
await $`git push origin release/${appName}/${release.newVersion}`;
|
|
149
|
-
}
|
|
150
|
-
} else {
|
|
151
|
-
await $`git checkout -b release/${releases[0].newVersion}`;
|
|
152
|
-
await $`git push origin release/${releases[0].newVersion}`;
|
|
153
|
-
}
|
|
210
|
+
// Create and push release branch
|
|
211
|
+
await $`git checkout -b release/${version}`;
|
|
212
|
+
await $`git push origin release/${version}`;
|
|
154
213
|
|
|
155
214
|
// Return to original branch
|
|
156
215
|
await $`git checkout ${currentBranch.trim()}`;
|
|
@@ -168,7 +227,100 @@ program
|
|
|
168
227
|
'Creates a changeset based on the current branch and Jira ticket information',
|
|
169
228
|
)
|
|
170
229
|
.action(async () => {
|
|
171
|
-
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
|
+
}
|
|
172
324
|
});
|
|
173
325
|
|
|
174
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
|
|
@@ -131,16 +133,6 @@ program
|
|
|
131
133
|
await deployAppWithTag(application, env, site, deployTag);
|
|
132
134
|
});
|
|
133
135
|
|
|
134
|
-
program
|
|
135
|
-
.command('deploy-mono-app <tag> <application>')
|
|
136
|
-
.description('Deploy an application for a specific site')
|
|
137
|
-
.action(async (tag, application) => {
|
|
138
|
-
const deployTag = await getDeployTag(tag);
|
|
139
|
-
const version = 'v' + deployTag.split('@')[1];
|
|
140
|
-
const { env, site } = await getDefaultDeploySite(version);
|
|
141
|
-
await deployAppWithTag(application, env, site, version);
|
|
142
|
-
});
|
|
143
|
-
|
|
144
136
|
program
|
|
145
137
|
.command('deploy-core <env> <site>')
|
|
146
138
|
.description('Deploy Core')
|
|
@@ -173,6 +165,13 @@ program
|
|
|
173
165
|
});
|
|
174
166
|
});
|
|
175
167
|
|
|
168
|
+
program
|
|
169
|
+
.command('build-mono-repo')
|
|
170
|
+
.description('Build Mono Repo')
|
|
171
|
+
.action(async () => {
|
|
172
|
+
await buildChangePackages();
|
|
173
|
+
});
|
|
174
|
+
|
|
176
175
|
program
|
|
177
176
|
.command('copy')
|
|
178
177
|
.description('Copy a Docker image between registries')
|