Skip to content

Commit

Permalink
chore(nxext): update playground utils
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikPieper committed Apr 16, 2024
1 parent 9dd545d commit f1c67f9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
13 changes: 8 additions & 5 deletions tools/scripts/create-playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down
13 changes: 8 additions & 5 deletions tools/scripts/update-playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 2 additions & 3 deletions tools/scripts/utils.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand Down

0 comments on commit f1c67f9

Please sign in to comment.