feat(nx-cloud): unhide new onboarding flow

This commit is contained in:
Katerina Skroumpelou 2024-06-21 15:06:23 +03:00 committed by Jason Jean
parent d928558bc4
commit 92be32c1a8
4 changed files with 113 additions and 170 deletions

View File

@ -283,28 +283,18 @@ async function normalizeArgsMiddleware(
const packageManager = await determinePackageManager(argv);
const defaultBase = await determineDefaultBase(argv);
if (process.env.NX_NEW_CLOUD_ONBOARDING === 'true') {
const nxCloud =
argv.skipGit === true ? 'skip' : await determineNxCloud(argv);
const useGitHub =
nxCloud === 'skip'
? undefined
: nxCloud === 'github' ||
(await determineIfGitHubWillBeUsed(nxCloud));
: nxCloud === 'github' || (await determineIfGitHubWillBeUsed(nxCloud));
Object.assign(argv, {
nxCloud,
useGitHub,
packageManager,
defaultBase,
});
} else {
const nxCloud = await determineNxCloud(argv);
Object.assign(argv, {
nxCloud,
packageManager,
defaultBase,
});
}
} catch (e) {
console.error(e);
process.exit(1);

View File

@ -16,13 +16,11 @@ export async function setupNxCloud(
try {
const pmc = getPackageManagerCommand(packageManager);
const res = await execAndWait(
process.env.NX_NEW_CLOUD_ONBOARDING === 'true'
? `${
`${
pmc.exec
} nx g nx:connect-to-nx-cloud --installationSource=create-nx-workspace --directory=${directory} ${
useGitHub ? '--github' : ''
} --no-interactive`
: `${pmc.exec} nx g nx:connect-to-nx-cloud --no-interactive --quiet`,
} --no-interactive`,
directory
);

View File

@ -56,15 +56,6 @@ export async function connectToNxCloudCommand(
const nxJson = readNxJson();
if (isNxCloudUsed(nxJson)) {
if (process.env.NX_NEW_CLOUD_ONBOARDING !== 'true') {
output.log({
title: '✔ This workspace already has Nx Cloud set up',
bodyLines: [
'If you have not done so already, connect your workspace to your Nx Cloud account:',
`- Login at ${getNxCloudUrl(nxJson)} to connect your repository`,
],
});
} else {
const token =
process.env.NX_CLOUD_ACCESS_TOKEN || nxJson.nxCloudAccessToken;
if (!token) {
@ -82,7 +73,7 @@ export async function connectToNxCloudCommand(
${connectCloudUrl}`,
],
});
}
return false;
}

View File

@ -83,21 +83,6 @@ async function printSuccessMessage(
usesGithub?: boolean,
directory?: string
) {
if (process.env.NX_NEW_CLOUD_ONBOARDING !== 'true') {
let origin = 'https://nx.app';
try {
origin = new URL(url).origin;
} catch (e) {}
output.note({
title: `Your Nx Cloud workspace is public`,
bodyLines: [
`To restrict access, connect it to your Nx Cloud account:`,
`- Push your changes`,
`- Login at ${origin} to connect your repository`,
],
});
} else {
const connectCloudUrl = await shortenedCloudUrl(
installationSource,
token,
@ -158,7 +143,6 @@ async function printSuccessMessage(
});
}
}
}
}
interface ConnectToNxCloudOptions {
@ -199,23 +183,6 @@ export async function connectToNxCloud(
return () => {
printCloudConnectionDisabledMessage();
};
} else {
if (process.env.NX_NEW_CLOUD_ONBOARDING !== 'true') {
// TODO: Change to using loading light client when that is enabled by default
const r = await createNxCloudWorkspace(
getRootPackageName(tree),
schema.installationSource,
getNxInitDate()
);
addNxCloudOptionsToNxJson(tree, nxJson, r.token);
await formatChangedFilesWithPrettierIfAvailable(tree, {
silent: schema.hideFormatLogs,
});
return async () =>
await printSuccessMessage(r.url, r.token, schema.installationSource);
} else {
const usesGithub = await repoUsesGithub(schema.github);
@ -246,9 +213,7 @@ export async function connectToNxCloud(
});
}
const apiUrl = removeTrailingSlash(
process.env.NX_CLOUD_API ||
process.env.NRWL_API ||
`https://cloud.nx.app`
process.env.NX_CLOUD_API || process.env.NRWL_API || `https://cloud.nx.app`
);
return async () =>
await printSuccessMessage(
@ -259,7 +224,6 @@ export async function connectToNxCloud(
schema.directory
);
}
}
}
function sleep(ms: number) {