Skip to content

Commit

Permalink
chore(repo): docs + format
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Mar 27, 2024
1 parent 0e7232d commit 9ece602
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 49 deletions.
2 changes: 1 addition & 1 deletion docs/generated/devkit/CreateNodes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Type alias: CreateNodes\<T\>

Ƭ **CreateNodes**\<`T`\>: readonly [configFilePattern: string, createNodesFunction: CreateNodesFunction\<T\>]
Ƭ **CreateNodes**\<`T`\>: readonly [projectFilePattern: string, createNodesFunction: CreateNodesFunction\<T\>]

A pair of file patterns and [CreateNodesFunction](../../devkit/documents/CreateNodesFunction)

Expand Down
12 changes: 12 additions & 0 deletions docs/generated/devkit/ExpandedPluginConfiguration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Type alias: ExpandedPluginConfiguration

Ƭ **ExpandedPluginConfiguration**: `Object`

#### Type declaration

| Name | Type |
| :--------- | :--------- |
| `exclude?` | `string`[] |
| `include?` | `string`[] |
| `options?` | `unknown` |
| `plugin` | `string` |
2 changes: 1 addition & 1 deletion docs/generated/devkit/PluginConfiguration.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Type alias: PluginConfiguration

Ƭ **PluginConfiguration**: `string` \| \{ `exclude?`: `string`[] ; `include?`: `string`[] ; `options?`: `unknown` ; `plugin`: `string` }
Ƭ **PluginConfiguration**: `string` \| [`ExpandedPluginConfiguration`](../../devkit/documents/ExpandedPluginConfiguration)
1 change: 1 addition & 0 deletions docs/generated/devkit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ It only uses language primitives and immutable objects
- [CustomHasher](../../devkit/documents/CustomHasher)
- [DynamicDependency](../../devkit/documents/DynamicDependency)
- [Executor](../../devkit/documents/Executor)
- [ExpandedPluginConfiguration](../../devkit/documents/ExpandedPluginConfiguration)
- [Generator](../../devkit/documents/Generator)
- [GeneratorCallback](../../devkit/documents/GeneratorCallback)
- [Hasher](../../devkit/documents/Hasher)
Expand Down
1 change: 1 addition & 0 deletions docs/generated/packages/devkit/documents/nx_devkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ It only uses language primitives and immutable objects
- [CustomHasher](../../devkit/documents/CustomHasher)
- [DynamicDependency](../../devkit/documents/DynamicDependency)
- [Executor](../../devkit/documents/Executor)
- [ExpandedPluginConfiguration](../../devkit/documents/ExpandedPluginConfiguration)
- [Generator](../../devkit/documents/Generator)
- [GeneratorCallback](../../devkit/documents/GeneratorCallback)
- [Hasher](../../devkit/documents/Hasher)
Expand Down
2 changes: 1 addition & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,6 @@
"nxCloudUrl": "https://staging.nx.app",
"parallel": 1,
"cacheDirectory": "/tmp/nx-cache",
"bust": 5,
"bust": 6,
"defaultBase": "master"
}
8 changes: 4 additions & 4 deletions packages/devkit/src/utils/convert-nx-executor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { requireNx } from '../../nx';
import { TempFs } from '../../internal-testing-utils';
import { convertNxExecutor } from './convert-nx-executor';

const { workspaceRoot } = requireNx();

describe('Convert Nx Executor', () => {
it('should convertNxExecutor to builder correctly and produce the same output', async () => {
const fs = new TempFs('convert-nx-executor');
// ARRANGE
const { schema } = require('@angular-devkit/core');
const {
Expand All @@ -16,7 +15,7 @@ describe('Convert Nx Executor', () => {
const registry = new schema.CoreSchemaRegistry();
registry.addPostTransform(schema.transforms.addUndefinedDefaults);
const testArchitectHost = new TestingArchitectHost();
testArchitectHost.workspaceRoot = workspaceRoot;
testArchitectHost.workspaceRoot = fs.tempDir;
const architect = new Architect(testArchitectHost, registry);

const convertedExecutor = convertNxExecutor(echoExecutor);
Expand Down Expand Up @@ -90,6 +89,7 @@ describe('Convert Nx Executor', () => {
expect(convertedExecutor.handler.toString()).toEqual(
realBuilder.handler.toString()
);
fs.cleanup();
});
});

Expand Down
4 changes: 1 addition & 3 deletions packages/nx/src/config/nx-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,7 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
useInferencePlugins?: boolean;
}

export type PluginConfiguration =
| string
| ExpandedPluginConfiguration;
export type PluginConfiguration = string | ExpandedPluginConfiguration;

export type ExpandedPluginConfiguration = {
plugin: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@ import { workspaceRoot } from '../../utils/workspace-root';
import { notifyFileWatcherSockets } from './file-watching/file-watcher-sockets';
import { serverLogger } from './logger';
import { NxWorkspaceFilesExternals } from '../../native';
import {
ConfigurationResult,
} from '../../project-graph/utils/project-configuration-utils';
import { ConfigurationResult } from '../../project-graph/utils/project-configuration-utils';
import { DaemonProjectGraphError } from '../daemon-project-graph-error';
import { LoadedNxPlugin } from '../../project-graph/plugins/internal-api';
import { getPlugins } from './plugins';
import { ProjectConfigurationsError } from 'nx/src/project-graph/error-types';
import { ProjectConfigurationsError } from '../../project-graph/error-types';

interface SerializedProjectGraph {
error: Error | null;
Expand Down
8 changes: 4 additions & 4 deletions packages/nx/src/migrations/update-15-1-0/set-project-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { loadNxPlugins } from '../../project-graph/plugins/internal-api';

export default async function (tree: Tree) {
const nxJson = readNxJson(tree);
const [plugins, cleanup] = (await loadNxPlugins(nxJson?.plugins ?? [], tree.root))
const projectFiles = retrieveProjectConfigurationPaths(
tree.root,
plugins
const [plugins, cleanup] = await loadNxPlugins(
nxJson?.plugins ?? [],
tree.root
);
const projectFiles = retrieveProjectConfigurationPaths(tree.root, plugins);
const projectJsons = projectFiles.filter((f) => f.endsWith('project.json'));

for (let f of projectJsons) {
Expand Down
2 changes: 1 addition & 1 deletion packages/nx/src/plugins/target-defaults/symbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ export const ONLY_MODIFIES_EXISTING_TARGET = 'NX_ONLY_MODIFIES_EXISTING_TARGET';
* NOTE: This cannot be a symbol, as they are not serialized in JSON the communication
* between the plugin-worker and the main process.
*/
export const OVERRIDE_SOURCE_FILE = 'NX_OVERRIDE_SOURCE_FILE';
export const OVERRIDE_SOURCE_FILE = 'NX_OVERRIDE_SOURCE_FILE';
2 changes: 1 addition & 1 deletion packages/nx/src/project-graph/error-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ export function isMergeNodesError(e: unknown): e is MergeNodesError {
'name' in e &&
e?.name === MergeNodesError.prototype.name)
);
}
}
14 changes: 9 additions & 5 deletions packages/nx/src/project-graph/file-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,15 @@ function getProjectsSyncNoInference(root: string, nxJson: NxJsonConfiguration) {
);
for (const file of matchingConfigFiles) {
if (minimatch(file, pattern, { dot: true })) {
let r = createNodes(file, {}, {
nxJsonConfiguration: nxJson,
workspaceRoot: root,
configFiles: matchingConfigFiles,
}) as CreateNodesResult;
let r = createNodes(
file,
{},
{
nxJsonConfiguration: nxJson,
workspaceRoot: root,
configFiles: matchingConfigFiles,
}
) as CreateNodesResult;
for (const node in r.projects) {
const project = {
root: node,
Expand Down
5 changes: 1 addition & 4 deletions packages/nx/src/project-graph/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
export * from './public-api';

export {
readPluginPackageJson,
registerPluginTSTranspiler,
} from './loader';
export { readPluginPackageJson, registerPluginTSTranspiler } from './loader';
6 changes: 2 additions & 4 deletions packages/nx/src/project-graph/plugins/internal-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
CreateNodesResult,
NxPluginV2,
} from './public-api';
import { ProjectGraphProcessor } from 'nx/src/config/project-graph';
import { ProjectGraphProcessor } from '../../config/project-graph';
import { runCreateNodesInParallel } from './utils';
import { loadNxPluginInIsolation } from './isolation';
import { loadNxPlugin, unregisterPluginTSTranspiler } from './loader';
Expand Down Expand Up @@ -89,12 +89,10 @@ export async function loadNxPlugins(
const result: Promise<LoadedNxPlugin>[] = [];

const loadingMethod =
process.env.NX_PLUGIN_ISOLATION === 'true'
process.env.NX_ISOLATE_PLUGINS === 'true'
? loadNxPluginInIsolation
: loadNxPlugin;

console.log(loadingMethod === loadNxPluginInIsolation ? 'isolated' : 'not isolated')

plugins = await normalizePlugins(plugins, root);

const cleanupFunctions: Array<() => void> = [];
Expand Down
2 changes: 1 addition & 1 deletion packages/nx/src/project-graph/plugins/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface CreateNodesContext {
/**
* The subset of configuration files which match the createNodes pattern
*/
readonly configFiles: string[];
readonly configFiles: string[];
}

/**
Expand Down
5 changes: 0 additions & 5 deletions packages/nx/src/project-graph/plugins/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ export async function runCreateNodesInParallel(
): Promise<CreateNodesResultWithContext[]> {
performance.mark(`${plugin.name}:createNodes - start`);

console.log('FINDING NODES', {
plugin: plugin.name,
configFiles,
})

const promises: Array<
CreateNodesResultWithContext | Promise<CreateNodesResultWithContext>
> = configFiles.map((file) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,14 @@ export async function createProjectConfigurations(
nxJsonConfiguration: nxJson,
workspaceRoot: root,
configFiles: matchingConfigFiles,
})
.catch((e) => {
if (isAggregateCreateNodesError(e)) {
errors.push(...e.errors);
return e.partialResults;
} else {
throw e;
}
});
}).catch((e) => {
if (isAggregateCreateNodesError(e)) {
errors.push(...e.errors);
return e.partialResults;
} else {
throw e;
}
});

results.push(r);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nx/src/utils/plugins/plugin-capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { dirname, join } from 'path';

import { ProjectConfiguration } from '../../config/workspace-json-project-json';
import { NxPlugin, readPluginPackageJson } from '../../project-graph/plugins';
import { loadNxPlugin } from '../../project-graph/plugins/loader';
import { readJsonFile } from '../fileutils';
import { getNxRequirePaths } from '../installation-directory';
import { output } from '../output';
Expand All @@ -12,7 +13,6 @@ import { workspaceRoot } from '../workspace-root';
import { hasElements } from './shared';

import type { PluginCapabilities } from './models';
import { loadNxPlugin } from 'nx/src/project-graph/plugins/loader';

function tryGetCollection<T extends object>(
packageJsonPath: string,
Expand Down

0 comments on commit 9ece602

Please sign in to comment.