fix(misc): nx view-logs should open the nx-cloud link when connected … (#17808)
This commit is contained in:
parent
712bcb2256
commit
4940b2b0b2
@ -5,60 +5,68 @@ import { output } from '../../utils/output';
|
|||||||
import { runNxSync } from '../../utils/child-process';
|
import { runNxSync } from '../../utils/child-process';
|
||||||
|
|
||||||
export async function viewLogs(): Promise<number> {
|
export async function viewLogs(): Promise<number> {
|
||||||
|
const cloudUsed = isNxCloudUsed();
|
||||||
|
if (cloudUsed) {
|
||||||
|
output.error({
|
||||||
|
title: 'Your workspace is already connected to Nx Cloud',
|
||||||
|
bodyLines: [
|
||||||
|
`Refer to the output of the last command to find the Nx Cloud link to view the run details.`,
|
||||||
|
],
|
||||||
|
});
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const installCloud = await (
|
||||||
|
await import('enquirer')
|
||||||
|
)
|
||||||
|
.prompt([
|
||||||
|
{
|
||||||
|
name: 'NxCloud',
|
||||||
|
message: `To view the logs, Nx needs to connect your workspace to Nx Cloud and upload the most recent run details.`,
|
||||||
|
type: 'autocomplete',
|
||||||
|
choices: [
|
||||||
|
{
|
||||||
|
name: 'Yes',
|
||||||
|
hint: 'Connect to Nx Cloud and upload the run details',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'No',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
initial: 'Yes' as any,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
.then((a: { NxCloud: 'Yes' | 'No' }) => a.NxCloud === 'Yes');
|
||||||
|
|
||||||
|
if (!installCloud) return;
|
||||||
|
|
||||||
const pmc = getPackageManagerCommand();
|
const pmc = getPackageManagerCommand();
|
||||||
const cloudUsed = isNxCloudUsed() && false;
|
try {
|
||||||
if (!cloudUsed) {
|
output.log({
|
||||||
const installCloud = await (
|
title: 'Installing nx-cloud',
|
||||||
await import('enquirer')
|
});
|
||||||
)
|
execSync(`${pmc.addDev} nx-cloud@latest`, { stdio: 'ignore' });
|
||||||
.prompt([
|
} catch (e) {
|
||||||
{
|
output.log({
|
||||||
name: 'NxCloud',
|
title: 'Installation failed',
|
||||||
message: `To view the logs, Nx needs to connect your workspace to Nx Cloud and upload the most recent run details.`,
|
});
|
||||||
type: 'autocomplete',
|
console.log(e);
|
||||||
choices: [
|
return 1;
|
||||||
{
|
}
|
||||||
name: 'Yes',
|
|
||||||
hint: 'Connect to Nx Cloud and upload the run details',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'No',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
initial: 'Yes' as any,
|
|
||||||
},
|
|
||||||
])
|
|
||||||
.then((a: { NxCloud: 'Yes' | 'No' }) => a.NxCloud === 'Yes');
|
|
||||||
|
|
||||||
if (!installCloud) return;
|
try {
|
||||||
|
output.log({
|
||||||
try {
|
title: 'Connecting to Nx Cloud',
|
||||||
output.log({
|
});
|
||||||
title: 'Installing nx-cloud',
|
runNxSync(`g nx-cloud:init --installation-source=view-logs`, {
|
||||||
});
|
stdio: 'ignore',
|
||||||
execSync(`${pmc.addDev} nx-cloud@latest`, { stdio: 'ignore' });
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
output.log({
|
output.log({
|
||||||
title: 'Installation failed',
|
title: 'Failed to connect to Nx Cloud',
|
||||||
});
|
});
|
||||||
console.log(e);
|
console.log(e);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
output.log({
|
|
||||||
title: 'Connecting to Nx Cloud',
|
|
||||||
});
|
|
||||||
runNxSync(`g nx-cloud:init --installation-source=view-logs`, {
|
|
||||||
stdio: 'ignore',
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
output.log({
|
|
||||||
title: 'Failed to connect to Nx Cloud',
|
|
||||||
});
|
|
||||||
console.log(e);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
execSync(`${pmc.exec} nx-cloud upload-and-show-run-details`, {
|
execSync(`${pmc.exec} nx-cloud upload-and-show-run-details`, {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user