@docupace/pipeline 1.0.39-matttest.18 → 1.0.39-matttest.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/next/util.js +12 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docupace/pipeline",
3
- "version": "1.0.39-matttest.18",
3
+ "version": "1.0.39-matttest.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/next/util.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { existsSync } from 'fs';
2
2
  import { join } from 'path';
3
3
  import { $, nothrow } from 'zx';
4
- import path from 'path';
5
4
 
6
5
  export function isMonoRepo() {
7
6
  // Check for the presence of turbo.json which indicates a Turborepo monorepo
@@ -16,21 +15,22 @@ export function isMonoRepo() {
16
15
  */
17
16
  export async function getChangedPackagesInternal(fromRef, toRef) {
18
17
  try {
19
- console.log(process.cwd());
20
18
  // Run the turbo command to get changed packages between branches
21
19
  const filterArg = `[${fromRef}...${toRef}]`;
22
20
  const turboDryOutput =
23
- await $`turbo run build -vvv --filter=${filterArg} --dry=json`;
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
24
 
25
- const dryRunJson = turboDryOutput.stdout.trim();
26
-
27
- const dryRun = JSON.parse(dryRunJson);
28
-
29
- const packageNamesList = dryRun.tasks.map(
30
- (task) => task.taskId.split('#')[0],
31
- );
25
+ // If we didn't get any package names, return empty array
26
+ if (!packageNames.stdout.trim()) {
27
+ return [];
28
+ }
32
29
 
30
+ // For each package name, get its path
33
31
  const packages = [];
32
+ const packageNamesList = packageNames.stdout.trim().split('\n');
33
+
34
34
  for (const packageName of packageNamesList) {
35
35
  if (packageName) {
36
36
  const packagePath =
@@ -55,10 +55,7 @@ export async function getChangedPackages() {
55
55
  const branch = process.env.BITBUCKET_BRANCH;
56
56
  const destBranch = process.env.BITBUCKET_PR_DESTINATION_BRANCH;
57
57
 
58
- await $`git fetch origin ${destBranch}:${destBranch}`;
59
- console.log(`Getting changed packages for [${destBranch}...${branch}]`);
60
58
  const changedPackages = await getChangedPackagesInternal(destBranch, branch);
61
- console.log('Changed Packages:\n', JSON.stringify(changedPackages, null, 2));
62
59
  return changedPackages;
63
60
  }
64
61
 
@@ -72,19 +69,16 @@ export async function getChangedAppPackages() {
72
69
 
73
70
  export async function buildChangePackages() {
74
71
  const appPackages = await getChangedAppPackages();
75
- if (appPackages.length == 0) {
76
- throw new Error('Nothing to build');
77
- }
78
72
  for (const appPackage of appPackages) {
79
73
  await dockerBuild(appPackage.path);
80
74
  }
81
75
  }
82
76
 
83
- export async function dockerBuild(buildPath) {
77
+ export async function dockerBuild(path) {
84
78
  process.env.DOCKER_HOST = '';
85
79
  const imageName = `${process.env.BITBUCKET_REPO_SLUG}:sha-${process.env.GIT_SHA}-withMaps`;
86
80
  console.log(`Building Docker image ${imageName}...`);
87
- await $`docker build --secret id=npm_token,env=DOCUPACE_NPM_TOKEN . --file ${path.resolve(buildPath, 'Dockerfile')} --target builder --tag ${imageName}`;
81
+ await $`docker build --secret id=npm_token,env=DOCUPACE_NPM_TOKEN ${path} --file Dockerfile --target builder --tag ${imageName}`;
88
82
  }
89
83
 
90
84
  export async function setGitInfo() {