From be1db4a224b6df58bb6eb1ae1b861784b834c84a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82?= Date: Wed, 18 Oct 2023 17:09:11 +0200 Subject: [PATCH 1/2] fix: updated the print-affected-array script after updating the nx --- apps/api/src/main.ts | 3 ++ apps/web/src/index.tsx | 3 ++ apps/widget/src/index.tsx | 3 ++ scripts/print-affected-array.mjs | 47 +++++++++++++++++++------------- 4 files changed, 37 insertions(+), 19 deletions(-) diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts index 2fb9dfe34e7..1cd652fd3b4 100644 --- a/apps/api/src/main.ts +++ b/apps/api/src/main.ts @@ -1,3 +1,6 @@ import { bootstrap } from './bootstrap'; bootstrap(); + +// eslint-disable-next-line no-console +console.log('Test affected apps'); diff --git a/apps/web/src/index.tsx b/apps/web/src/index.tsx index d71181aa865..30f8d2213c7 100644 --- a/apps/web/src/index.tsx +++ b/apps/web/src/index.tsx @@ -16,3 +16,6 @@ ReactDOM.render( * or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals . */ reportWebVitals(); + +// eslint-disable-next-line no-console +console.log('Test affected apps'); diff --git a/apps/widget/src/index.tsx b/apps/widget/src/index.tsx index ae2b05b0365..e4320e18a08 100644 --- a/apps/widget/src/index.tsx +++ b/apps/widget/src/index.tsx @@ -18,3 +18,6 @@ ReactDOM.render( */ reportWebVitals(); + +// eslint-disable-next-line no-console +console.log('Test affected apps'); diff --git a/scripts/print-affected-array.mjs b/scripts/print-affected-array.mjs index 1e6bace41a9..f0ccc674f6e 100644 --- a/scripts/print-affected-array.mjs +++ b/scripts/print-affected-array.mjs @@ -76,7 +76,7 @@ function commaSeparatedListToArray(str) { function getAffectedCommandResult(str) { const outputLines = str.trim().split(/\r?\n/); if (outputLines.length > 2) { - return outputLines.slice(-1)[0]; + return outputLines.slice(2).join(''); } return ''; @@ -91,13 +91,22 @@ async function affectedProjectsContainingTask(taskName, baseBranch) { return JSON.parse(cache); } - // pnpm nx print-affected --target=[task] --base [base branch] --select=tasks.target.project - const result = commaSeparatedListToArray( - getAffectedCommandResult( - await pnpmRun('nx', 'print-affected', '--target', taskName, '--base', baseBranch, '--select=tasks.target.project') - ) + + const affectedCommandResult = await pnpmRun( + 'nx', + 'show', + 'projects', + '--affected', + '--withTarget', + taskName, + '--base', + baseBranch, + '--json' ); + // pnpm nx show projects --affected --withTarget=[task] --base [base branch] --json + const result = JSON.parse(getAffectedCommandResult(affectedCommandResult)); + fs.writeFileSync(cachePath, JSON.stringify(result)); return result; @@ -113,21 +122,21 @@ async function allProjectsContainingTask(taskName) { return JSON.parse(cache); } - // pnpm nx print-affected --target=[task] --files package.json --select=tasks.target.project - const result = commaSeparatedListToArray( - getAffectedCommandResult( - await pnpmRun( - 'nx', - 'print-affected', - '--target', - taskName, - '--files', - 'package.json', - '--select=tasks.target.project' - ) - ) + // pnpm nx show projects --affected --withTarget=[task] --files package.json --json + const affectedCommandResult = await pnpmRun( + 'nx', + 'show', + 'projects', + '--affected', + '--withTarget', + taskName, + '--files', + 'package.json', + '--json' ); + const result = JSON.parse(getAffectedCommandResult(affectedCommandResult)); + fs.writeFileSync(cachePath, JSON.stringify(result)); return result; From 91e3e5c7ae76a89498a71382460cc7f45267d2a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82?= Date: Thu, 19 Oct 2023 00:45:56 +0200 Subject: [PATCH 2/2] chore: remove console log --- apps/api/src/main.ts | 3 --- apps/web/src/index.tsx | 3 --- apps/widget/src/index.tsx | 3 --- 3 files changed, 9 deletions(-) diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts index 1cd652fd3b4..2fb9dfe34e7 100644 --- a/apps/api/src/main.ts +++ b/apps/api/src/main.ts @@ -1,6 +1,3 @@ import { bootstrap } from './bootstrap'; bootstrap(); - -// eslint-disable-next-line no-console -console.log('Test affected apps'); diff --git a/apps/web/src/index.tsx b/apps/web/src/index.tsx index 30f8d2213c7..d71181aa865 100644 --- a/apps/web/src/index.tsx +++ b/apps/web/src/index.tsx @@ -16,6 +16,3 @@ ReactDOM.render( * or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals . */ reportWebVitals(); - -// eslint-disable-next-line no-console -console.log('Test affected apps'); diff --git a/apps/widget/src/index.tsx b/apps/widget/src/index.tsx index e4320e18a08..ae2b05b0365 100644 --- a/apps/widget/src/index.tsx +++ b/apps/widget/src/index.tsx @@ -18,6 +18,3 @@ ReactDOM.render( */ reportWebVitals(); - -// eslint-disable-next-line no-console -console.log('Test affected apps');