@docupace/pipeline 1.0.39-matttest.0 → 1.0.39-matttest.10
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 -1
- package/src/changeset/cli.js +1 -7
- package/src/changeset/validate.js +3 -1
- package/src/next/cli.js +8 -0
- package/src/next/util.js +47 -2
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.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"axios": "^1.7.9",
|
|
23
23
|
"commander": "^12.1.0",
|
|
24
24
|
"dotenv": "^16.4.7",
|
|
25
|
+
"fs-extra": "^11.3.0",
|
|
25
26
|
"js-yaml": "^4.1.0",
|
|
26
27
|
"lodash": "^4.17.21",
|
|
27
28
|
"openai": "^4.76.3",
|
package/src/changeset/cli.js
CHANGED
|
@@ -10,6 +10,7 @@ import z from 'zod';
|
|
|
10
10
|
import dotenv from 'dotenv';
|
|
11
11
|
import { makeJiraRequest, updateComponentVersion } from '../next/jira.js';
|
|
12
12
|
dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
|
|
13
|
+
import { setGitInfo } from '../next/util.js';
|
|
13
14
|
|
|
14
15
|
const program = new Command();
|
|
15
16
|
|
|
@@ -61,13 +62,6 @@ async function getMainPackage() {
|
|
|
61
62
|
throw new Error('Main package.json not found');
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
// Helper function to set Git info
|
|
65
|
-
async function setGitInfo() {
|
|
66
|
-
await $`git config --global user.email "gitops@docupace.com"`;
|
|
67
|
-
await $`git config --global user.name "Gitops"`;
|
|
68
|
-
await $`git remote set-url origin https://${process.env.THIS_REP_TOKEN}@bitbucket.org/${process.env.BITBUCKET_REPO_FULL_NAME}.git`;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
65
|
const changeSetPackage = `{
|
|
72
66
|
"name": "changeset-package",
|
|
73
67
|
"version": "1.0.0",
|
|
@@ -2,7 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { $ } from 'zx';
|
|
4
4
|
|
|
5
|
-
import { getChangedPackages, isMonoRepo } from '../next/util.js';
|
|
5
|
+
import { getChangedPackages, isMonoRepo, setGitInfo } from '../next/util.js';
|
|
6
6
|
|
|
7
7
|
const CHANGESET_DIR = '.changeset';
|
|
8
8
|
|
|
@@ -31,7 +31,9 @@ export async function validateChangesets() {
|
|
|
31
31
|
await validateChangesetPath(path.resolve(process.cwd(), CHANGESET_DIR));
|
|
32
32
|
}*/
|
|
33
33
|
|
|
34
|
+
await setGitInfo();
|
|
34
35
|
const destBranch = process.env.BITBUCKET_PR_DESTINATION_BRANCH;
|
|
36
|
+
await $`git fetch origin ${destBranch}:${destBranch}`;
|
|
35
37
|
await $`changeset status --since=${destBranch}`;
|
|
36
38
|
}
|
|
37
39
|
|
package/src/next/cli.js
CHANGED
|
@@ -25,6 +25,7 @@ const program = new Command();
|
|
|
25
25
|
import { $ } from 'zx';
|
|
26
26
|
import { deployConnect, deployCore } from './jenkins.js';
|
|
27
27
|
import { runPipeline } from './pipline.js';
|
|
28
|
+
import { buildChangePackages } from './util.js';
|
|
28
29
|
|
|
29
30
|
const GIT_SHA = (await $`git log --pretty=format:'%h' -n 1`).stdout.trim();
|
|
30
31
|
|
|
@@ -164,6 +165,13 @@ program
|
|
|
164
165
|
});
|
|
165
166
|
});
|
|
166
167
|
|
|
168
|
+
program
|
|
169
|
+
.command('build-mono-repo')
|
|
170
|
+
.description('Build Mono Repo')
|
|
171
|
+
.action(async () => {
|
|
172
|
+
await buildChangePackages();
|
|
173
|
+
});
|
|
174
|
+
|
|
167
175
|
program
|
|
168
176
|
.command('copy')
|
|
169
177
|
.description('Copy a Docker image between registries')
|
package/src/next/util.js
CHANGED
|
@@ -13,15 +13,18 @@ export function isMonoRepo() {
|
|
|
13
13
|
* @param {string} toRef - The ending git reference (branch or tag)
|
|
14
14
|
* @returns {Promise<Array<{name: string, path: string}>>} - Array of changed packages with name and path
|
|
15
15
|
*/
|
|
16
|
-
export async function
|
|
16
|
+
export async function getChangedPackagesInternal(fromRef, toRef) {
|
|
17
17
|
try {
|
|
18
|
+
console.log(process.cwd());
|
|
18
19
|
// Run the turbo command to get changed packages between branches
|
|
19
20
|
const filterArg = `[${fromRef}...${toRef}]`;
|
|
20
21
|
const turboDryOutput =
|
|
21
|
-
await $`turbo run build --filter=${filterArg} --dry=json`;
|
|
22
|
+
await $`turbo run build -vvv --filter=${filterArg} --dry=json`;
|
|
22
23
|
const packageNames =
|
|
23
24
|
await $`echo ${turboDryOutput} | jq -r '.tasks[].taskId' | cut -d'#' -f1 | sort -u`;
|
|
24
25
|
|
|
26
|
+
console.log('packageName: ', packageNames.stdout.trim());
|
|
27
|
+
|
|
25
28
|
// If we didn't get any package names, return empty array
|
|
26
29
|
if (!packageNames.stdout.trim()) {
|
|
27
30
|
return [];
|
|
@@ -50,3 +53,45 @@ export async function getChangedPackages(fromRef, toRef) {
|
|
|
50
53
|
return [];
|
|
51
54
|
}
|
|
52
55
|
}
|
|
56
|
+
|
|
57
|
+
export async function getChangedPackages() {
|
|
58
|
+
const branch = process.env.BITBUCKET_BRANCH;
|
|
59
|
+
const destBranch = process.env.BITBUCKET_PR_DESTINATION_BRANCH;
|
|
60
|
+
|
|
61
|
+
await $`git fetch origin ${destBranch}:${destBranch}`;
|
|
62
|
+
console.log(`Getting changed packages for [${destBranch}...${branch}]`);
|
|
63
|
+
const changedPackages = await getChangedPackagesInternal(destBranch, branch);
|
|
64
|
+
console.log('Changed Packages:\n', JSON.stringify(changedPackages, null, 2));
|
|
65
|
+
return changedPackages;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export async function getChangedAppPackages() {
|
|
69
|
+
const changedPackages = await getChangedPackages();
|
|
70
|
+
const appPackages = changedPackages.filter((appPackage) =>
|
|
71
|
+
appPackage.name.endsWith('-app'),
|
|
72
|
+
);
|
|
73
|
+
return appPackages;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export async function buildChangePackages() {
|
|
77
|
+
const appPackages = await getChangedAppPackages();
|
|
78
|
+
if (appPackages.length == 0) {
|
|
79
|
+
throw new Error('Nothing to build');
|
|
80
|
+
}
|
|
81
|
+
for (const appPackage of appPackages) {
|
|
82
|
+
await dockerBuild(appPackage.path);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export async function dockerBuild(path) {
|
|
87
|
+
process.env.DOCKER_HOST = '';
|
|
88
|
+
const imageName = `${process.env.BITBUCKET_REPO_SLUG}:sha-${process.env.GIT_SHA}-withMaps`;
|
|
89
|
+
console.log(`Building Docker image ${imageName}...`);
|
|
90
|
+
await $`docker build --secret id=npm_token,env=DOCUPACE_NPM_TOKEN ${path} --file Dockerfile --target builder --tag ${imageName}`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export async function setGitInfo() {
|
|
94
|
+
await $`git config --global user.email "gitops@docupace.com"`;
|
|
95
|
+
await $`git config --global user.name "Gitops"`;
|
|
96
|
+
await $`git remote set-url origin https://${process.env.THIS_REP_TOKEN}@bitbucket.org/${process.env.BITBUCKET_REPO_FULL_NAME}.git`;
|
|
97
|
+
}
|