Skip to content

Commit

Permalink
chore(core): remove readProjectsConfigurations from workspaces (#18329)
Browse files Browse the repository at this point in the history
Co-authored-by: FrozenPandaz <jasonjean1993@gmail.com>
  • Loading branch information
xiongemi and FrozenPandaz authored Aug 15, 2023
1 parent 37fd20b commit 40d66ec
Show file tree
Hide file tree
Showing 57 changed files with 389 additions and 435 deletions.
2 changes: 1 addition & 1 deletion docs/generated/devkit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ It only uses language primitives and immutable objects
- [offsetFromRoot](../../devkit/documents/offsetFromRoot)
- [parseJson](../../devkit/documents/parseJson)
- [parseTargetString](../../devkit/documents/parseTargetString)
- [readAllWorkspaceConfiguration](../../devkit/documents/readAllWorkspaceConfiguration)
- [readCachedProjectGraph](../../devkit/documents/readCachedProjectGraph)
- [readJson](../../devkit/documents/readJson)
- [readJsonFile](../../devkit/documents/readJsonFile)
- [readNxJson](../../devkit/documents/readNxJson)
- [readProjectConfiguration](../../devkit/documents/readProjectConfiguration)
- [readProjectsConfigurationFromProjectGraph](../../devkit/documents/readProjectsConfigurationFromProjectGraph)
- [readRootPackageJson](../../devkit/documents/readRootPackageJson)
- [readTargetOptions](../../devkit/documents/readTargetOptions)
- [readWorkspaceConfiguration](../../devkit/documents/readWorkspaceConfiguration)
Expand Down
61 changes: 7 additions & 54 deletions docs/generated/devkit/Workspaces.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Class: Workspaces

**`Deprecated`**

This will be removed in v18. Use [readProjectsConfigurationFromProjectGraph](../../devkit/documents/readProjectsConfigurationFromProjectGraph) instead.

## Table of contents

### Constructors
Expand All @@ -8,13 +12,10 @@

### Properties

- [cachedProjectsConfig](../../devkit/documents/Workspaces#cachedprojectsconfig)
- [root](../../devkit/documents/Workspaces#root)

### Methods

- [mergeTargetDefaultsIntoProjectDescriptions](../../devkit/documents/Workspaces#mergetargetdefaultsintoprojectdescriptions)
- [readProjectsConfigurations](../../devkit/documents/Workspaces#readprojectsconfigurations)
- [readWorkspaceConfiguration](../../devkit/documents/Workspaces#readworkspaceconfiguration)

## Constructors
Expand All @@ -31,67 +32,19 @@

## Properties

### cachedProjectsConfig

`Private` **cachedProjectsConfig**: [`ProjectsConfigurations`](../../devkit/documents/ProjectsConfigurations)

---

### root

`Private` **root**: `string`

## Methods

### mergeTargetDefaultsIntoProjectDescriptions

`Private` **mergeTargetDefaultsIntoProjectDescriptions**(`projects`, `nxJson`): `Record`<`string`, [`ProjectConfiguration`](../../devkit/documents/ProjectConfiguration)\>

#### Parameters

| Name | Type |
| :--------- | :----------------------------------------------------------------------------------------- |
| `projects` | `Record`<`string`, [`ProjectConfiguration`](../../devkit/documents/ProjectConfiguration)\> |
| `nxJson` | [`NxJsonConfiguration`](../../devkit/documents/NxJsonConfiguration)<`string`[] \| `"*"`\> |

#### Returns

`Record`<`string`, [`ProjectConfiguration`](../../devkit/documents/ProjectConfiguration)\>

---

### readProjectsConfigurations

**readProjectsConfigurations**(`opts?`): [`ProjectsConfigurations`](../../devkit/documents/ProjectsConfigurations)

**`Deprecated`**

#### Parameters

| Name | Type |
| :-------------------------------------- | :-------- |
| `opts?` | `Object` |
| `opts._includeProjectsFromAngularJson?` | `boolean` |

#### Returns

[`ProjectsConfigurations`](../../devkit/documents/ProjectsConfigurations)

---

### readWorkspaceConfiguration

**readWorkspaceConfiguration**(`opts?`): [`ProjectsConfigurations`](../../devkit/documents/ProjectsConfigurations) & [`NxJsonConfiguration`](../../devkit/documents/NxJsonConfiguration)<`string`[] \| `"*"`\>
**readWorkspaceConfiguration**(): [`ProjectsConfigurations`](../../devkit/documents/ProjectsConfigurations) & [`NxJsonConfiguration`](../../devkit/documents/NxJsonConfiguration)<`string`[] \| `"*"`\>

Deprecated. Use readProjectsConfigurations

#### Parameters
**`Deprecated`**

| Name | Type |
| :-------------------------------------- | :-------- |
| `opts?` | `Object` |
| `opts._ignorePluginInference?` | `boolean` |
| `opts._includeProjectsFromAngularJson?` | `boolean` |
Use [readProjectsConfigurationFromProjectGraph](../../devkit/documents/readProjectsConfigurationFromProjectGraph) instead.

#### Returns

Expand Down
11 changes: 0 additions & 11 deletions docs/generated/devkit/readAllWorkspaceConfiguration.md

This file was deleted.

15 changes: 15 additions & 0 deletions docs/generated/devkit/readProjectsConfigurationFromProjectGraph.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Function: readProjectsConfigurationFromProjectGraph

**readProjectsConfigurationFromProjectGraph**(`projectGraph`): [`ProjectsConfigurations`](../../devkit/documents/ProjectsConfigurations)

Get the [ProjectsConfigurations](../../devkit/documents/ProjectsConfigurations) from the [ProjectGraph](../../devkit/documents/ProjectGraph)

#### Parameters

| Name | Type |
| :------------- | :---------------------------------------------------- |
| `projectGraph` | [`ProjectGraph`](../../devkit/documents/ProjectGraph) |

#### Returns

[`ProjectsConfigurations`](../../devkit/documents/ProjectsConfigurations)
2 changes: 1 addition & 1 deletion docs/generated/packages/devkit/documents/nx_devkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ It only uses language primitives and immutable objects
- [offsetFromRoot](../../devkit/documents/offsetFromRoot)
- [parseJson](../../devkit/documents/parseJson)
- [parseTargetString](../../devkit/documents/parseTargetString)
- [readAllWorkspaceConfiguration](../../devkit/documents/readAllWorkspaceConfiguration)
- [readCachedProjectGraph](../../devkit/documents/readCachedProjectGraph)
- [readJson](../../devkit/documents/readJson)
- [readJsonFile](../../devkit/documents/readJsonFile)
- [readNxJson](../../devkit/documents/readNxJson)
- [readProjectConfiguration](../../devkit/documents/readProjectConfiguration)
- [readProjectsConfigurationFromProjectGraph](../../devkit/documents/readProjectsConfigurationFromProjectGraph)
- [readRootPackageJson](../../devkit/documents/readRootPackageJson)
- [readTargetOptions](../../devkit/documents/readTargetOptions)
- [readWorkspaceConfiguration](../../devkit/documents/readWorkspaceConfiguration)
Expand Down
6 changes: 4 additions & 2 deletions e2e/angular-core/src/module-federation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ describe('Angular Module Federation', () => {

// ports
const hostPort = 4500;
const remote1Port = readProjectConfig(remote1).targets.serve.options.port;
const remote2Port = readProjectConfig(remote2).targets.serve.options.port;
const remote1Port = (await readProjectConfig(remote1)).targets.serve.options
.port;
const remote2Port = (await readProjectConfig(remote2)).targets.serve.options
.port;

const process = await runCommandUntil(
`serve-ssr ${host} --port=${hostPort}`,
Expand Down
4 changes: 2 additions & 2 deletions e2e/angular-core/src/projects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,15 @@ describe('Angular Projects', () => {
);

// update the angular.json
updateProjectConfig(app1, (config) => {
await updateProjectConfig(app1, (config) => {
config.targets.build.executor = '@nx/angular:webpack-browser';
config.targets.build.options = {
...config.targets.build.options,
buildLibsFromSource: false,
};
return config;
});
updateProjectConfig(esbuildApp, (config) => {
await updateProjectConfig(esbuildApp, (config) => {
config.targets.build.executor = '@nx/angular:browser-esbuild';
config.targets.build.options = {
...config.targets.build.options,
Expand Down
6 changes: 3 additions & 3 deletions e2e/angular-extensions/src/cypress-component-tests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Angular Cypress Component Tests', () => {

createBuildableLib(projectName, buildableLibName);

useWorkspaceAssetsInApp(appName);
await useWorkspaceAssetsInApp(appName);
});

afterAll(() => cleanupProject());
Expand Down Expand Up @@ -265,7 +265,7 @@ export class AppModule {}
);
}

function useWorkspaceAssetsInApp(appName: string) {
async function useWorkspaceAssetsInApp(appName: string) {
// make sure assets from the workspace root work.
createFile('libs/assets/data.json', JSON.stringify({ data: 'data' }));
createFile(
Expand All @@ -279,7 +279,7 @@ function useWorkspaceAssetsInApp(appName: string) {
}
`
);
updateProjectConfig(appName, (config) => {
await updateProjectConfig(appName, (config) => {
config.targets['build'].options.stylePreprocessorOptions = {
includePaths: ['assets/styles'],
};
Expand Down
2 changes: 1 addition & 1 deletion e2e/angular-extensions/src/tailwind.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ describe('Tailwind support', () => {
runCLI(
`generate @nx/angular:app ${appWithTailwind} --add-tailwind --no-interactive`
);
updateProjectConfig(appWithTailwind, (config) => {
await updateProjectConfig(appWithTailwind, (config) => {
config.targets.build.executor = '@nx/angular:webpack-browser';
config.targets.build.options = {
...config.targets.build.options,
Expand Down
9 changes: 4 additions & 5 deletions e2e/esbuild/src/esbuild.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
packageInstall,
readFile,
readJson,
rmDist,
runCLI,
runCommand,
runCommandUntil,
Expand All @@ -27,7 +26,7 @@ describe('EsBuild Plugin', () => {
const myPkg = uniq('my-pkg');
runCLI(`generate @nx/js:lib ${myPkg} --bundler=esbuild`);
updateFile(`libs/${myPkg}/src/index.ts`, `console.log('Hello');\n`);
updateProjectConfig(myPkg, (json) => {
await updateProjectConfig(myPkg, (json) => {
json.targets.build.options.assets = [`libs/${myPkg}/assets/*`];
return json;
});
Expand Down Expand Up @@ -179,12 +178,12 @@ describe('EsBuild Plugin', () => {
expect(runCommand(`node dist/libs/${myPkg}`)).toMatch(/Hello/);
}, 300_000);

it('should support additional entry points', () => {
it('should support additional entry points', async () => {
const myPkg = uniq('my-pkg');
runCLI(`generate @nx/js:lib ${myPkg} --bundler=esbuild`);
updateFile(`libs/${myPkg}/src/index.ts`, `console.log('main');\n`);
updateFile(`libs/${myPkg}/src/extra.ts`, `console.log('extra');\n`);
updateProjectConfig(myPkg, (json) => {
await updateProjectConfig(myPkg, (json) => {
json.targets.build.options.additionalEntryPoints = [
`libs/${myPkg}/src/extra.ts`,
];
Expand Down Expand Up @@ -212,7 +211,7 @@ describe('EsBuild Plugin', () => {
`libs/${myPkg}/esbuild.config.js`,
`console.log('custom config loaded');\nmodule.exports = {};\n`
);
updateProjectConfig(myPkg, (json) => {
await updateProjectConfig(myPkg, (json) => {
delete json.targets.build.options.esbuildOptions;
json.targets.build.options.esbuildConfig = `libs/${myPkg}/esbuild.config.js`;
return json;
Expand Down
4 changes: 2 additions & 2 deletions e2e/expo/src/expo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ describe('expo', () => {
it('should prebuild', async () => {
// run prebuild command with git check disable
// set a mock package name for ios and android in expo's app.json
const workspace = readResolvedConfiguration();
const root = workspace.projects[appName].root;
const projects = await readResolvedConfiguration();
const root = projects[appName].root;
const appJsonPath = join(root, `app.json`);
const appJson = await readJson(appJsonPath);
if (appJson.expo.ios) {
Expand Down
20 changes: 10 additions & 10 deletions e2e/js/src/js-node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('js:node error handling', () => {

afterEach(() => cleanupProject());

it('should log out the error', () => {
it('should log out the error', async () => {
const esbuildLib = uniq('esbuildlib');

runCLI(
Expand All @@ -30,7 +30,7 @@ describe('js:node error handling', () => {
`;
});

updateProjectConfig(esbuildLib, (config) => {
await updateProjectConfig(esbuildLib, (config) => {
config.targets['run-node'] = {
executor: '@nx/js:node',
options: {
Expand All @@ -48,7 +48,7 @@ describe('js:node error handling', () => {
expect(output).toContain('This is an error');
}, 240_000);

it('should execute library compiled with rollup', () => {
it('should execute library compiled with rollup', async () => {
const rollupLib = uniq('rolluplib');

runCLI(
Expand All @@ -61,7 +61,7 @@ describe('js:node error handling', () => {
`;
});

updateProjectConfig(rollupLib, (config) => {
await updateProjectConfig(rollupLib, (config) => {
config.targets['run-node'] = {
executor: '@nx/js:node',
options: {
Expand All @@ -76,7 +76,7 @@ describe('js:node error handling', () => {
expect(output).toContain('Hello from my library!');
}, 240_000);

it('should execute library compiled with tsc', () => {
it('should execute library compiled with tsc', async () => {
const tscLib = uniq('tsclib');

runCLI(`generate @nx/js:lib ${tscLib} --bundler=tsc --no-interactive`);
Expand All @@ -87,7 +87,7 @@ describe('js:node error handling', () => {
`;
});

updateProjectConfig(tscLib, (config) => {
await updateProjectConfig(tscLib, (config) => {
config.targets['run-node'] = {
executor: '@nx/js:node',
options: {
Expand All @@ -102,7 +102,7 @@ describe('js:node error handling', () => {
expect(output).toContain('Hello from my tsc library!');
}, 240_000);

it('should execute library compiled with swc', () => {
it('should execute library compiled with swc', async () => {
const swcLib = uniq('swclib');

runCLI(`generate @nx/js:lib ${swcLib} --bundler=swc --no-interactive`);
Expand All @@ -113,7 +113,7 @@ describe('js:node error handling', () => {
`;
});

updateProjectConfig(swcLib, (config) => {
await updateProjectConfig(swcLib, (config) => {
config.targets['run-node'] = {
executor: '@nx/js:node',
options: {
Expand All @@ -128,7 +128,7 @@ describe('js:node error handling', () => {
expect(output).toContain('Hello from my swc library!');
}, 240_000);

it('should execute webpack app', () => {
it('should execute webpack app', async () => {
const webpackProject = uniq('webpackproject');

runCLI(
Expand All @@ -141,7 +141,7 @@ describe('js:node error handling', () => {
`;
});

updateProjectConfig(webpackProject, (config) => {
await updateProjectConfig(webpackProject, (config) => {
config.targets['run-node'] = {
executor: '@nx/js:node',
options: {
Expand Down
6 changes: 3 additions & 3 deletions e2e/js/src/js-packaging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe('bundling libs', () => {
expect(output).toContain(rollupLib);
}, 500_000);

it('should support tsc and swc for building libs', () => {
it('should support tsc and swc for building libs', async () => {
const tscLib = uniq('tsclib');
const swcLib = uniq('swclib');
const tscEsmLib = uniq('tscesmlib');
Expand Down Expand Up @@ -154,15 +154,15 @@ describe('bundling libs', () => {
);

// Add additional entry points for `exports` field
updateProjectConfig(tscLib, (json) => {
await updateProjectConfig(tscLib, (json) => {
json.targets.build.options.additionalEntryPoints = [
`libs/${tscLib}/src/foo/*.ts`,
];
return json;
});
updateFile(`libs/${tscLib}/src/foo/bar.ts`, `export const bar = 'bar';`);
updateFile(`libs/${tscLib}/src/foo/faz.ts`, `export const faz = 'faz';`);
updateProjectConfig(swcLib, (json) => {
await updateProjectConfig(swcLib, (json) => {
json.targets.build.options.additionalEntryPoints = [
`libs/${swcLib}/src/foo/*.ts`,
];
Expand Down
Loading

1 comment on commit 40d66ec

@vercel
Copy link

@vercel vercel bot commented on 40d66ec Aug 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx.dev
nx-dev-nrwl.vercel.app
nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app

Please sign in to comment.