fix(core): show project --web shouldn't error (#23251)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
This commit is contained in:
parent
2460c89047
commit
5542350e16
@ -205,6 +205,12 @@ Type: `boolean`
|
||||
|
||||
Show help
|
||||
|
||||
##### open
|
||||
|
||||
Type: `boolean`
|
||||
|
||||
Set to false to prevent the browser from opening when using --web
|
||||
|
||||
##### projectName
|
||||
|
||||
Type: `string`
|
||||
|
||||
@ -205,6 +205,12 @@ Type: `boolean`
|
||||
|
||||
Show help
|
||||
|
||||
##### open
|
||||
|
||||
Type: `boolean`
|
||||
|
||||
Set to false to prevent the browser from opening when using --web
|
||||
|
||||
##### projectName
|
||||
|
||||
Type: `string`
|
||||
|
||||
@ -6,6 +6,7 @@ import {
|
||||
getPackageManagerCommand,
|
||||
getPublishedVersion,
|
||||
isNotWindows,
|
||||
killProcessAndPorts,
|
||||
newProject,
|
||||
readFile,
|
||||
readJson,
|
||||
@ -13,6 +14,7 @@ import {
|
||||
runCLI,
|
||||
runCLIAsync,
|
||||
runCommand,
|
||||
runCommandUntil,
|
||||
tmpProjPath,
|
||||
uniq,
|
||||
updateFile,
|
||||
@ -73,6 +75,33 @@ describe('Nx Commands', () => {
|
||||
expect(project.targets.build).toBeDefined();
|
||||
expect(project.targets.lint).toBeDefined();
|
||||
});
|
||||
|
||||
it('should open project details view', async () => {
|
||||
const app = uniq('myapp');
|
||||
runCLI(`generate @nx/web:app ${app}`);
|
||||
let url: string;
|
||||
let port: number;
|
||||
const child_process = await runCommandUntil(
|
||||
`show project ${app} --web --open=false`,
|
||||
(output) => {
|
||||
console.log(output);
|
||||
// output should contain 'Project graph started at http://127.0.0.1:{port}'
|
||||
if (output.includes('Project graph started at http://')) {
|
||||
const match = /https?:\/\/[\d.]+:(?<port>\d+)/.exec(output);
|
||||
if (match) {
|
||||
port = parseInt(match.groups.port);
|
||||
url = match[0];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
// Check that url is alive
|
||||
const response = await fetch(url);
|
||||
expect(response.status).toEqual(200);
|
||||
await killProcessAndPorts(child_process.pid, port);
|
||||
}, 700000);
|
||||
});
|
||||
|
||||
describe('report and list', () => {
|
||||
|
||||
@ -20,9 +20,8 @@
|
||||
"prepare": "is-ci || husky install",
|
||||
"echo": "echo 123458",
|
||||
"preinstall": "node ./scripts/preinstall.js",
|
||||
"test": "nx test",
|
||||
"e2e": "nx e2e",
|
||||
"build-project": "nx build"
|
||||
"test": "nx run-many -t test",
|
||||
"e2e": "nx run-many -t e2e --projects ./e2e/*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
|
||||
@ -29,7 +29,8 @@ export type ShowProjectsOptions = NxShowArgs & {
|
||||
export type ShowProjectOptions = NxShowArgs & {
|
||||
projectName: string;
|
||||
web?: boolean;
|
||||
verbose: boolean;
|
||||
open?: boolean;
|
||||
verbose?: boolean;
|
||||
};
|
||||
|
||||
export const yargsShowCommand: CommandModule<
|
||||
@ -138,7 +139,7 @@ const showProjectCommand: CommandModule<NxShowArgs, ShowProjectOptions> = {
|
||||
command: 'project <projectName>',
|
||||
describe: 'Shows resolved project configuration for a given project.',
|
||||
builder: (yargs) =>
|
||||
yargs
|
||||
withVerbose(yargs)
|
||||
.positional('projectName', {
|
||||
type: 'string',
|
||||
alias: 'p',
|
||||
@ -149,13 +150,18 @@ const showProjectCommand: CommandModule<NxShowArgs, ShowProjectOptions> = {
|
||||
type: 'boolean',
|
||||
description: 'Show project details in the browser',
|
||||
})
|
||||
.option('verbose', {
|
||||
.option('open', {
|
||||
type: 'boolean',
|
||||
description:
|
||||
'Prints additional information about the commands (e.g., stack traces)',
|
||||
'Set to false to prevent the browser from opening when using --web',
|
||||
implies: 'web',
|
||||
})
|
||||
.check((argv) => {
|
||||
if (argv.web) {
|
||||
argv.json = false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.conflicts('json', 'web')
|
||||
.conflicts('web', 'json')
|
||||
.example(
|
||||
'$0 show project my-app',
|
||||
'View project information for my-app in JSON format'
|
||||
|
||||
@ -20,7 +20,7 @@ export async function showProjectHandler(
|
||||
view: 'project-details',
|
||||
focus: node.name,
|
||||
watch: true,
|
||||
open: true,
|
||||
open: args.open ?? true,
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user