From f1c67f9d8505840bc8983885f2379fa75ceed5ab Mon Sep 17 00:00:00 2001 From: Dominik Pieper Date: Tue, 16 Apr 2024 16:30:56 +0200 Subject: [PATCH] chore(nxext): update playground utils --- tools/scripts/create-playground.ts | 13 ++++++++----- tools/scripts/update-playground.ts | 13 ++++++++----- tools/scripts/utils.ts | 5 ++--- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/tools/scripts/create-playground.ts b/tools/scripts/create-playground.ts index fe21eb21b..89bc8315a 100644 --- a/tools/scripts/create-playground.ts +++ b/tools/scripts/create-playground.ts @@ -7,15 +7,18 @@ import { } from 'fs-extra'; import { getPublishableLibNames, tmpProjPath } from './utils'; import { dirname, basename } from 'path'; -import { logger, readJsonFile, workspaceRoot } from '@nx/devkit'; -import { Workspaces } from 'nx/src/config/workspaces'; +import { + logger, + readCachedProjectGraph, + readJsonFile, + readProjectsConfigurationFromProjectGraph, + workspaceRoot +} from "@nx/devkit"; import * as glob from 'glob'; console.log('\nCreating playground. This may take a few minutes.'); -const workspaceJson = new Workspaces( - workspaceRoot -).readWorkspaceConfiguration(); +const workspaceJson = readProjectsConfigurationFromProjectGraph(readCachedProjectGraph()); const publishableLibNames = getPublishableLibNames(workspaceJson); execSync(`npx nx run-many --target build --projects ${publishableLibNames}`); diff --git a/tools/scripts/update-playground.ts b/tools/scripts/update-playground.ts index 927687da6..5ab8733e5 100644 --- a/tools/scripts/update-playground.ts +++ b/tools/scripts/update-playground.ts @@ -2,15 +2,18 @@ import { execSync } from 'child_process'; import { readFileSync, removeSync, writeFileSync } from 'fs-extra'; import { copyAndRename, getPublishableLibNames, tmpProjPath } from './utils'; -import { Workspaces } from 'nx/src/config/workspaces'; -import { logger, readJsonFile, workspaceRoot } from '@nx/devkit'; +import { + logger, + readCachedProjectGraph, + readJsonFile, + readProjectsConfigurationFromProjectGraph, + workspaceRoot +} from "@nx/devkit"; import * as glob from 'glob'; console.log('\nUpdating playground...'); -const workspaceJson = new Workspaces( - workspaceRoot -).readWorkspaceConfiguration(); +const workspaceJson = readProjectsConfigurationFromProjectGraph(readCachedProjectGraph()); const publishableLibNames = getPublishableLibNames(workspaceJson); diff --git a/tools/scripts/utils.ts b/tools/scripts/utils.ts index c490a74db..545cf3779 100644 --- a/tools/scripts/utils.ts +++ b/tools/scripts/utils.ts @@ -1,9 +1,8 @@ import { existsSync, lstatSync, copySync, renameSync } from 'fs-extra'; -import { workspaceRoot } from '@nx/devkit'; -import { Workspaces } from 'nx/src/config/workspaces'; +import { readCachedProjectGraph, readProjectsConfigurationFromProjectGraph } from "@nx/devkit"; export function getPublishableLibNames( - workspaceJson = new Workspaces(workspaceRoot).readWorkspaceConfiguration() + workspaceJson = readProjectsConfigurationFromProjectGraph(readCachedProjectGraph()) ) { const { projects } = workspaceJson;