Skip to content

Commit

Permalink
fix(core): setup the nx cloud client during postinstall (#19658)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz authored Oct 17, 2023
1 parent dbb3dfb commit f74beac
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions packages/nx/bin/post-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,36 @@ import { fileExists } from '../src/utils/fileutils';
import { join } from 'path';
import { daemonClient } from '../src/daemon/client/client';
import { assertSupportedPlatform } from '../src/native/assert-supported-platform';
import { verifyOrUpdateNxCloudClient } from '../src/nx-cloud/update-manager';
import { getCloudOptions } from '../src/nx-cloud/utilities/get-cloud-options';
import { isNxCloudUsed } from '../src/utils/nx-cloud-utils';
import { readNxJson } from '../src/config/nx-json';

(async () => {
try {
if (isMainNxPackage() && fileExists(join(workspaceRoot, 'nx.json'))) {
const b = new Date();
assertSupportedPlatform();

try {
await daemonClient.stop();
} catch (e) {}
const b = new Date();
await buildProjectGraphWithoutDaemon();
const a = new Date();
const tasks: Array<Promise<any>> = [buildProjectGraphWithoutDaemon()];
if (isNxCloudUsed(readNxJson())) {
tasks.push(verifyOrUpdateNxCloudClient(getCloudOptions()));
}
await Promise.all(
tasks.map((promise) => {
promise.catch((e) => {
if (process.env.NX_VERBOSE_LOGGING === 'true') {
console.warn(e);
}
});
})
);
if (process.env.NX_VERBOSE_LOGGING === 'true') {
console.log(
`Nx project graph has been precomputed in ${
a.getTime() - b.getTime()
}ms`
);
const a = new Date();
console.log(`Nx postinstall steps took ${a.getTime() - b.getTime()}ms`);
}
}
} catch (e) {
Expand Down

0 comments on commit f74beac

Please sign in to comment.