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
|
Show help
|
||||||
|
|
||||||
|
##### open
|
||||||
|
|
||||||
|
Type: `boolean`
|
||||||
|
|
||||||
|
Set to false to prevent the browser from opening when using --web
|
||||||
|
|
||||||
##### projectName
|
##### projectName
|
||||||
|
|
||||||
Type: `string`
|
Type: `string`
|
||||||
|
|||||||
@ -205,6 +205,12 @@ Type: `boolean`
|
|||||||
|
|
||||||
Show help
|
Show help
|
||||||
|
|
||||||
|
##### open
|
||||||
|
|
||||||
|
Type: `boolean`
|
||||||
|
|
||||||
|
Set to false to prevent the browser from opening when using --web
|
||||||
|
|
||||||
##### projectName
|
##### projectName
|
||||||
|
|
||||||
Type: `string`
|
Type: `string`
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import {
|
|||||||
getPackageManagerCommand,
|
getPackageManagerCommand,
|
||||||
getPublishedVersion,
|
getPublishedVersion,
|
||||||
isNotWindows,
|
isNotWindows,
|
||||||
|
killProcessAndPorts,
|
||||||
newProject,
|
newProject,
|
||||||
readFile,
|
readFile,
|
||||||
readJson,
|
readJson,
|
||||||
@ -13,6 +14,7 @@ import {
|
|||||||
runCLI,
|
runCLI,
|
||||||
runCLIAsync,
|
runCLIAsync,
|
||||||
runCommand,
|
runCommand,
|
||||||
|
runCommandUntil,
|
||||||
tmpProjPath,
|
tmpProjPath,
|
||||||
uniq,
|
uniq,
|
||||||
updateFile,
|
updateFile,
|
||||||
@ -73,6 +75,33 @@ describe('Nx Commands', () => {
|
|||||||
expect(project.targets.build).toBeDefined();
|
expect(project.targets.build).toBeDefined();
|
||||||
expect(project.targets.lint).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', () => {
|
describe('report and list', () => {
|
||||||
|
|||||||
@ -20,9 +20,8 @@
|
|||||||
"prepare": "is-ci || husky install",
|
"prepare": "is-ci || husky install",
|
||||||
"echo": "echo 123458",
|
"echo": "echo 123458",
|
||||||
"preinstall": "node ./scripts/preinstall.js",
|
"preinstall": "node ./scripts/preinstall.js",
|
||||||
"test": "nx test",
|
"test": "nx run-many -t test",
|
||||||
"e2e": "nx e2e",
|
"e2e": "nx run-many -t e2e --projects ./e2e/*"
|
||||||
"build-project": "nx build"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
|
|||||||
@ -29,7 +29,8 @@ export type ShowProjectsOptions = NxShowArgs & {
|
|||||||
export type ShowProjectOptions = NxShowArgs & {
|
export type ShowProjectOptions = NxShowArgs & {
|
||||||
projectName: string;
|
projectName: string;
|
||||||
web?: boolean;
|
web?: boolean;
|
||||||
verbose: boolean;
|
open?: boolean;
|
||||||
|
verbose?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const yargsShowCommand: CommandModule<
|
export const yargsShowCommand: CommandModule<
|
||||||
@ -138,7 +139,7 @@ const showProjectCommand: CommandModule<NxShowArgs, ShowProjectOptions> = {
|
|||||||
command: 'project <projectName>',
|
command: 'project <projectName>',
|
||||||
describe: 'Shows resolved project configuration for a given project.',
|
describe: 'Shows resolved project configuration for a given project.',
|
||||||
builder: (yargs) =>
|
builder: (yargs) =>
|
||||||
yargs
|
withVerbose(yargs)
|
||||||
.positional('projectName', {
|
.positional('projectName', {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
alias: 'p',
|
alias: 'p',
|
||||||
@ -149,13 +150,18 @@ const showProjectCommand: CommandModule<NxShowArgs, ShowProjectOptions> = {
|
|||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
description: 'Show project details in the browser',
|
description: 'Show project details in the browser',
|
||||||
})
|
})
|
||||||
.option('verbose', {
|
.option('open', {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
description:
|
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(
|
.example(
|
||||||
'$0 show project my-app',
|
'$0 show project my-app',
|
||||||
'View project information for my-app in JSON format'
|
'View project information for my-app in JSON format'
|
||||||
|
|||||||
@ -20,7 +20,7 @@ export async function showProjectHandler(
|
|||||||
view: 'project-details',
|
view: 'project-details',
|
||||||
focus: node.name,
|
focus: node.name,
|
||||||
watch: true,
|
watch: true,
|
||||||
open: true,
|
open: args.open ?? true,
|
||||||
},
|
},
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user