From 14b517d96514b4e7ce97e68328a38d02d730fd43 Mon Sep 17 00:00:00 2001 From: Colum Ferry Date: Wed, 11 Jan 2023 10:18:49 +0000 Subject: [PATCH] fix(core): keep decorate-cli script for existing workspace usages --- packages/cli/lib/decorate-cli.ts | 1 + packages/nx/src/adapter/decorate-cli.ts | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 packages/cli/lib/decorate-cli.ts create mode 100644 packages/nx/src/adapter/decorate-cli.ts diff --git a/packages/cli/lib/decorate-cli.ts b/packages/cli/lib/decorate-cli.ts new file mode 100644 index 0000000000000..fbb9636c447e0 --- /dev/null +++ b/packages/cli/lib/decorate-cli.ts @@ -0,0 +1 @@ +export * from 'nx/src/adapter/decorate-cli'; diff --git a/packages/nx/src/adapter/decorate-cli.ts b/packages/nx/src/adapter/decorate-cli.ts new file mode 100644 index 0000000000000..259ab16075b81 --- /dev/null +++ b/packages/nx/src/adapter/decorate-cli.ts @@ -0,0 +1,22 @@ +import { readFileSync, writeFileSync } from 'fs'; + +export function decorateCli() { + console.warn( + `Decoration of the Angular CLI is deprecated and will be removed in a future version.` + ); + console.warn( + `Please replace usage of "ng " in any scripts, particularly for CI, with "nx ".` + ); + const path = 'node_modules/@angular/cli/lib/cli/index.js'; + const angularCLIInit = readFileSync(path, 'utf-8'); + const start = angularCLIInit.indexOf(`(options) {`) + 11; + + const newContent = `${angularCLIInit.slice(0, start)} + if (!process.env['NX_CLI_SET']) { + require('nx/bin/nx'); + return new Promise(function(res, rej) {}); + } + ${angularCLIInit.substring(start)} +`; + writeFileSync(path, newContent); +}