fix(angular): keep decorate-cli script for existing workspace usages (#14266)

Co-authored-by: Jason Jean <jasonjean1993@gmail.com>
This commit is contained in:
Colum Ferry 2023-01-12 00:10:16 +00:00 committed by GitHub
parent 0636fe7c3b
commit b7a134baf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1 @@
export * from 'nx/src/adapter/decorate-cli';

View File

@ -0,0 +1,23 @@
import { readFileSync, writeFileSync } from 'fs';
import { output } from '../utils/output';
export function decorateCli() {
output.warn({
title: `Decoration of the Angular CLI is deprecated and will be removed in a future version`,
bodyLines: [
`Please replace usage of "ng <command>" in any scripts, particularly for CI, with "nx <command>"`,
],
});
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);
}