-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): reorganize packges to consolidate all cli-related code in nx
- Loading branch information
Showing
239 changed files
with
1,435 additions
and
5,009 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,5 +30,5 @@ | |
"outputs": ["coverage/e2e/cli"] | ||
} | ||
}, | ||
"implicitDependencies": ["cli", "js"] | ||
"implicitDependencies": ["js"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ import { | |
describe('Cli', () => { | ||
beforeEach(() => newProject()); | ||
|
||
it('vvvshould execute long running tasks', () => { | ||
it('vvvshould execute long running tasks', async () => { | ||
const myapp = uniq('myapp'); | ||
runCLI(`generate @nrwl/web:app ${myapp}`); | ||
updateProjectConfig(myapp, (c) => { | ||
|
@@ -210,15 +210,13 @@ describe('migrate', () => { | |
}) | ||
); | ||
|
||
updateFile( | ||
'./node_modules/@nrwl/tao/src/commands/migrate.js', | ||
(content) => { | ||
const start = content.indexOf('// testing-fetch-start'); | ||
const end = content.indexOf('// testing-fetch-end'); | ||
|
||
const before = content.substring(0, start); | ||
const after = content.substring(end); | ||
const newFetch = ` | ||
updateFile('./node_modules/nx/src/commands/migrate.js', (content) => { | ||
const start = content.indexOf('// testing-fetch-start'); | ||
const end = content.indexOf('// testing-fetch-end'); | ||
|
||
const before = content.substring(0, start); | ||
const after = content.substring(end); | ||
const newFetch = ` | ||
function createFetcher(logger) { | ||
return function fetch(packageName) { | ||
if (packageName === 'migrate-parent-package') { | ||
|
@@ -250,9 +248,8 @@ describe('migrate', () => { | |
} | ||
`; | ||
|
||
return `${before}${newFetch}${after}`; | ||
} | ||
); | ||
return `${before}${newFetch}${after}`; | ||
}); | ||
|
||
runCLI( | ||
'migrate [email protected] --from="[email protected]"', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,2 @@ | ||
#!/usr/bin/env node | ||
import { findWorkspaceRoot } from '../lib/find-workspace-root'; | ||
const workspace = findWorkspaceRoot(process.cwd()); | ||
if (workspace && workspace.type === 'nx') { | ||
require('v8-compile-cache'); | ||
} | ||
// polyfill rxjs observable to avoid issues with multiple version fo Observable installed in node_modules | ||
// https://twitter.com/BenLesh/status/1192478226385428483?s=20 | ||
if (!(Symbol as any).observable) | ||
(Symbol as any).observable = Symbol('observable polyfill'); | ||
import * as chalk from 'chalk'; | ||
import { initLocal } from '../lib/init-local'; | ||
import { output } from '../lib/output'; | ||
import { detectPackageManager } from '@nrwl/tao/src/shared/package-manager'; | ||
|
||
if (!workspace) { | ||
output.log({ | ||
title: `The current directory isn't part of an Nx workspace.`, | ||
bodyLines: [ | ||
`To create a workspace run:`, | ||
chalk.bold.white(`npx create-nx-workspace@latest <workspace name>`), | ||
], | ||
}); | ||
|
||
output.note({ | ||
title: `For more information please visit https://nx.dev/`, | ||
}); | ||
process.exit(1); | ||
} | ||
|
||
// Make sure that a local copy of Nx exists in workspace | ||
let localNx: string; | ||
try { | ||
localNx = require.resolve('@nrwl/cli/bin/nx.js', { | ||
paths: [workspace.dir], | ||
}); | ||
} catch { | ||
output.error({ | ||
title: `Could not find Nx modules in this workspace.`, | ||
bodyLines: [`Have you run ${chalk.bold.white(`npm/yarn install`)}?`], | ||
}); | ||
process.exit(1); | ||
} | ||
|
||
if (localNx === require.resolve('@nrwl/cli/bin/nx.js')) { | ||
initLocal(workspace); | ||
} else { | ||
const packageManager = detectPackageManager(); | ||
if (packageManager === 'pnpm') { | ||
const tip = | ||
process.platform === 'win32' | ||
? 'doskey pnx=pnpm nx -- $*' | ||
: `alias pnx="pnpm nx --"`; | ||
output.warn({ | ||
title: `Running global Nx CLI with PNPM may have issues.`, | ||
bodyLines: [ | ||
`Prefer to use "pnpm" (https://pnpm.io/cli/exec) to execute commands in this workspace.`, | ||
`${chalk.reset.inverse.bold.cyan( | ||
' TIP ' | ||
)} create a shortcut such as: ${chalk.bold.white(tip)}`, | ||
``, | ||
], | ||
}); | ||
} | ||
|
||
// Nx is being run from globally installed CLI - hand off to the local | ||
require(localNx); | ||
} | ||
require('nx/bin/nx'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1 @@ | ||
import { readFileSync, writeFileSync } from 'fs'; | ||
|
||
export function decorateCli() { | ||
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.substr(0, start)} | ||
if (!process.env['NX_CLI_SET']) { | ||
require('@nrwl/cli/bin/nx'); | ||
return new Promise(function(res, rej) {}); | ||
} | ||
${angularCLIInit.substring(start)} | ||
`; | ||
writeFileSync(path, newContent); | ||
} | ||
require('nx/src/cli/decorate-cli'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
6f038e7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: