@docupace/pipeline 1.0.38-matttest.0 → 1.0.39-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 +3 -2
- package/src/changeset/cli.js +4 -5
- package/src/changeset/validate.js +35 -1
- package/src/next/deploy.js +0 -1
- package/src/next/util.js +52 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docupace/pipeline",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.39-matttest.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"scripts": {
|
|
41
41
|
"test-deploy-core": "dp-next-cli deploy-core-pipeline dev template",
|
|
42
42
|
"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",
|
|
43
|
-
"test-run-pipline": "dp-next-cli run-pipeline -r docupace-next-e2e -b master -p run-tests-qa"
|
|
43
|
+
"test-run-pipline": "dp-next-cli run-pipeline -r docupace-next-e2e -b master -p run-tests-qa",
|
|
44
|
+
"test-validate": "dp-changset-cli validate"
|
|
44
45
|
}
|
|
45
46
|
}
|
package/src/changeset/cli.js
CHANGED
|
@@ -159,15 +159,15 @@ async function commitTagCommand() {
|
|
|
159
159
|
|
|
160
160
|
// Command: validate
|
|
161
161
|
program
|
|
162
|
-
.command('validate
|
|
162
|
+
.command('validate')
|
|
163
163
|
.description('Validate changesets for the provided PR')
|
|
164
|
-
.action(async (
|
|
164
|
+
.action(async () => {
|
|
165
165
|
if (!process.env.BITBUCKET_PR_ID) {
|
|
166
166
|
return;
|
|
167
167
|
}
|
|
168
168
|
console.log('🔍 Validating changesets...');
|
|
169
169
|
try {
|
|
170
|
-
await validateChangesets(
|
|
170
|
+
await validateChangesets();
|
|
171
171
|
console.log('✅ Changeset validation passed.');
|
|
172
172
|
} catch (error) {
|
|
173
173
|
console.error(
|
|
@@ -225,7 +225,6 @@ program
|
|
|
225
225
|
await $`git add .`;
|
|
226
226
|
await $`git commit -m "Open next alpha version"`;
|
|
227
227
|
await $`git push origin`;
|
|
228
|
-
|
|
229
228
|
});
|
|
230
229
|
|
|
231
230
|
program
|
|
@@ -263,7 +262,7 @@ program
|
|
|
263
262
|
|
|
264
263
|
if (!jiraResponse.ok) {
|
|
265
264
|
throw new Error(
|
|
266
|
-
|
|
265
|
+
`Failed to fetch Jira ticket. Status: ${jiraResponse.status}`,
|
|
267
266
|
);
|
|
268
267
|
}
|
|
269
268
|
const jiraTicketData = await jiraResponse.json();
|
|
@@ -1,7 +1,41 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import { $ } from 'zx';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
import { getChangedPackages, isMonoRepo } from '../next/util.js';
|
|
6
|
+
|
|
7
|
+
const CHANGESET_DIR = '.changeset';
|
|
8
|
+
|
|
9
|
+
export async function validateChangesets() {
|
|
10
|
+
/*if (isMonoRepo()) {
|
|
11
|
+
const branch = process.env.BITBUCKET_BRANCH;
|
|
12
|
+
const destBranch = process.env.BITBUCKET_PR_DESTINATION_BRANCH;
|
|
13
|
+
|
|
14
|
+
const changePackages = await getChangedPackages(destBranch, branch);
|
|
15
|
+
|
|
16
|
+
const appPackages = changePackages.filter((appPackage) =>
|
|
17
|
+
appPackage.name.endsWith('-app'),
|
|
18
|
+
);
|
|
19
|
+
|
|
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
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
await validateChangesetPath(path.resolve(process.cwd(), CHANGESET_DIR));
|
|
32
|
+
}*/
|
|
33
|
+
|
|
34
|
+
const destBranch = process.env.BITBUCKET_PR_DESTINATION_BRANCH;
|
|
35
|
+
await $`changeset status --since=${destBranch}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function validateChangesetPath(directoryPath) {
|
|
5
39
|
try {
|
|
6
40
|
// Step 1: Read the directory for md files excluding README.md
|
|
7
41
|
const allFiles = fs.readdirSync(directoryPath);
|
package/src/next/deploy.js
CHANGED
package/src/next/util.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { existsSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { $, nothrow } from 'zx';
|
|
4
|
+
|
|
5
|
+
export function isMonoRepo() {
|
|
6
|
+
// Check for the presence of turbo.json which indicates a Turborepo monorepo
|
|
7
|
+
return existsSync(join(process.cwd(), 'turbo.json'));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Gets the packages that have changed between two git references (branches or tags)
|
|
12
|
+
* @param {string} fromRef - The starting git reference (branch or tag)
|
|
13
|
+
* @param {string} toRef - The ending git reference (branch or tag)
|
|
14
|
+
* @returns {Promise<Array<{name: string, path: string}>>} - Array of changed packages with name and path
|
|
15
|
+
*/
|
|
16
|
+
export async function getChangedPackages(fromRef, toRef) {
|
|
17
|
+
try {
|
|
18
|
+
// Run the turbo command to get changed packages between branches
|
|
19
|
+
const filterArg = `[${fromRef}...${toRef}]`;
|
|
20
|
+
const turboDryOutput =
|
|
21
|
+
await $`turbo run build --filter=${filterArg} --dry=json`;
|
|
22
|
+
const packageNames =
|
|
23
|
+
await $`echo ${turboDryOutput} | jq -r '.tasks[].taskId' | cut -d'#' -f1 | sort -u`;
|
|
24
|
+
|
|
25
|
+
// If we didn't get any package names, return empty array
|
|
26
|
+
if (!packageNames.stdout.trim()) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// For each package name, get its path
|
|
31
|
+
const packages = [];
|
|
32
|
+
const packageNamesList = packageNames.stdout.trim().split('\n');
|
|
33
|
+
|
|
34
|
+
for (const packageName of packageNamesList) {
|
|
35
|
+
if (packageName) {
|
|
36
|
+
const packagePath =
|
|
37
|
+
await $`pnpm m ls -r --json | jq -r --arg name ${packageName} '.[] | select(.name == $name) | .path'`;
|
|
38
|
+
if (packagePath.stdout.trim()) {
|
|
39
|
+
packages.push({
|
|
40
|
+
name: packageName,
|
|
41
|
+
path: packagePath.stdout.trim(),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return packages;
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.error('Error getting changed packages:', error);
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
}
|