From 49b341ff81fde6f815f4a75f06d552907a79b8ae Mon Sep 17 00:00:00 2001 From: Tom Emelko Date: Tue, 30 Jan 2024 11:23:37 -0500 Subject: [PATCH 1/5] fix(core): remove restriction of configuration (#823) Prior to this change the schema.jsons for build and publish required the build configuration to be either Debug or Release. This change removes that restriction, allowing build configurations with other names --- packages/core/src/executors/build/schema.json | 1 - packages/core/src/executors/publish/schema.json | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/core/src/executors/build/schema.json b/packages/core/src/executors/build/schema.json index 4ba7a4b3..c21167f4 100644 --- a/packages/core/src/executors/build/schema.json +++ b/packages/core/src/executors/build/schema.json @@ -15,7 +15,6 @@ }, "configuration": { "type": "string", - "enum": ["Debug", "Release"], "default": "Debug", "description": "Defines the build configuration. The default for most projects is Debug, but you can override the build configuration settings in your project" }, diff --git a/packages/core/src/executors/publish/schema.json b/packages/core/src/executors/publish/schema.json index 61a56b3b..43482730 100644 --- a/packages/core/src/executors/publish/schema.json +++ b/packages/core/src/executors/publish/schema.json @@ -7,7 +7,6 @@ "properties": { "configuration": { "type": "string", - "enum": ["Debug", "Release"], "default": "Debug", "description": "Defines the build configuration The default for most projects is Debug, but you can override the build configuration settings in your project." }, From d9fff6795b26df42bde5198d2d5cb2f8a1e527bf Mon Sep 17 00:00:00 2001 From: Tine Kondo Date: Wed, 31 Jan 2024 21:39:56 +0100 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20add=20options=20to=20sync=20the=20`?= =?UTF-8?q?gh-pages`=20branch=20with=20the=20base=20branch=20=E2=80=A6=20(?= =?UTF-8?q?#815)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/nx-ghpages/Executors/deploy.md | 12 ++++++++++++ .../src/executors/deploy/executor.spec.ts | 3 +++ .../nx-ghpages/src/executors/deploy/executor.ts | 10 ++++++++++ .../nx-ghpages/src/executors/deploy/schema.d.ts | 3 +++ .../nx-ghpages/src/executors/deploy/schema.json | 16 ++++++++++++++++ 5 files changed, 44 insertions(+) diff --git a/docs/nx-ghpages/Executors/deploy.md b/docs/nx-ghpages/Executors/deploy.md index a0c037e1..8a1d024e 100644 --- a/docs/nx-ghpages/Executors/deploy.md +++ b/docs/nx-ghpages/Executors/deploy.md @@ -21,3 +21,15 @@ Deploy a page to a specified repository's gh-pages branch. ### commitMessage - (string): Message of the git commit to gh-pages branch + +### baseBranch + +- (string): Base branch to sync the gh-pages branch with + +### syncWithBaseBranch + +- (string): Indicate if the gh-pages branch should be synced with the base branch + +### syncStrategy + +- (string): Git command to use to sync the gh-pages branch with the base branch diff --git a/packages/nx-ghpages/src/executors/deploy/executor.spec.ts b/packages/nx-ghpages/src/executors/deploy/executor.spec.ts index 7c805ee3..6a6aaac0 100644 --- a/packages/nx-ghpages/src/executors/deploy/executor.spec.ts +++ b/packages/nx-ghpages/src/executors/deploy/executor.spec.ts @@ -22,6 +22,9 @@ const options: BuildExecutorSchema = { remote: '', remoteName: '', commitMessage: '', + baseBranch: '', + syncWithBaseBranch: false, + syncStrategy: 'rebase', }; describe('Build Executor', () => { diff --git a/packages/nx-ghpages/src/executors/deploy/executor.ts b/packages/nx-ghpages/src/executors/deploy/executor.ts index 732536b0..2142546d 100644 --- a/packages/nx-ghpages/src/executors/deploy/executor.ts +++ b/packages/nx-ghpages/src/executors/deploy/executor.ts @@ -6,6 +6,7 @@ import { join } from 'path'; import { promisify } from 'util'; import { BuildExecutorSchema } from './schema'; +import { readNxJson } from 'nx/src/config/nx-json'; const exec = promisify(execCallback); @@ -60,6 +61,15 @@ export default async function deployExecutor(options: BuildExecutorSchema) { logger.warn('Resetting gh-pages branch, as it already exists.'); await exec(`git checkout -B gh-pages`, { cwd: directory }); } + if (options.syncWithBaseBranch) { + const baseBranch = + options.baseBranch || readNxJson()?.affected?.defaultBase || 'master'; + const syncStrategy = options.syncStrategy; + await exec(`git ${syncStrategy} ${options.remoteName}/${baseBranch}`, { + cwd: directory, + }); + } + await exec(`git push -f --set-upstream ${options.remoteName} gh-pages`, { cwd: directory, }); diff --git a/packages/nx-ghpages/src/executors/deploy/schema.d.ts b/packages/nx-ghpages/src/executors/deploy/schema.d.ts index 229b3cdd..edcac5b4 100644 --- a/packages/nx-ghpages/src/executors/deploy/schema.d.ts +++ b/packages/nx-ghpages/src/executors/deploy/schema.d.ts @@ -3,4 +3,7 @@ export interface BuildExecutorSchema { directory: string; remoteName: string; commitMessage: string; + baseBranch: string; + syncWithBaseBranch: boolean; + syncStrategy: 'rebase' | 'merge'; } diff --git a/packages/nx-ghpages/src/executors/deploy/schema.json b/packages/nx-ghpages/src/executors/deploy/schema.json index 1683e772..a7ab0fc9 100644 --- a/packages/nx-ghpages/src/executors/deploy/schema.json +++ b/packages/nx-ghpages/src/executors/deploy/schema.json @@ -22,6 +22,22 @@ "type": "string", "description": "Message of the git commit to gh-pages branch", "default": "chore: :rocket: deploy new version to Github Pages" + }, + "baseBranch": { + "type": "string", + "description": "Base branch to sync the gh-pages branch with", + "default": "master" + }, + "syncWithBaseBranch": { + "type": "string", + "description": "Indicate if the gh-pages branch should be synced with the base branch", + "default": "false" + }, + "syncStrategy": { + "type": "string", + "description": "Git command to use to sync the gh-pages branch with the base branch", + "enum": ["rebase", "merge"], + "default": "rebase" } }, "required": ["remote", "directory"] From 0945571169dac0df375d1381daa36bee46e14647 Mon Sep 17 00:00:00 2001 From: Frank Fenton Date: Thu, 1 Feb 2024 07:43:52 +1100 Subject: [PATCH 3/5] fix(dotnet): prevent "false" being incorrectly passed to dotnet command (#818) * fix(dotnet): prevent "false" being incorrectly passed to dotnet command * chore(dotnet): refactor how command line flags are built --- .../dotnet/src/lib/core/dotnet.client.spec.ts | 157 +++++++++++++++++- packages/dotnet/src/lib/core/dotnet.client.ts | 71 ++++---- .../dotnet-add-package-flags.ts | 16 +- .../models/dotnet-build/dotnet-build-flags.ts | 18 +- .../dotnet-format/dotnet-format-flags.ts | 20 ++- .../lib/models/dotnet-new/dotnet-new-flags.ts | 15 +- .../dotnet-publish/dotnet-publish-flags.ts | 20 ++- .../lib/models/dotnet-run/dotnet-run-flags.ts | 15 +- .../models/dotnet-test/dotnet-test-flags.ts | 32 ++-- .../utils/src/lib/utility-functions/args.ts | 12 -- .../lib/utility-functions/parameters.spec.ts | 51 ++++++ .../src/lib/utility-functions/parameters.ts | 41 ++++- 12 files changed, 368 insertions(+), 100 deletions(-) create mode 100644 packages/utils/src/lib/utility-functions/parameters.spec.ts diff --git a/packages/dotnet/src/lib/core/dotnet.client.spec.ts b/packages/dotnet/src/lib/core/dotnet.client.spec.ts index 40e4afc4..c1389a73 100644 --- a/packages/dotnet/src/lib/core/dotnet.client.spec.ts +++ b/packages/dotnet/src/lib/core/dotnet.client.spec.ts @@ -4,6 +4,10 @@ import { DotNetClient } from './dotnet.client'; import { dotnetFactory, mockDotnetFactory } from './dotnet.factory'; describe('dotnet client', () => { + afterEach(() => { + jest.resetAllMocks(); + }); + describe('publish', () => { describe('extra parameters', () => { const dotnetClient = new DotNetClient(mockDotnetFactory()); @@ -13,13 +17,7 @@ describe('dotnet client', () => { beforeEach(() => { spawnSyncSpy = jest .spyOn(cp, 'spawnSync') - .mockReturnValue({ status: 0 } as Partial< - cp.SpawnSyncReturns - > as cp.SpawnSyncReturns); - }); - - afterEach(() => { - jest.resetAllMocks(); + .mockReturnValue({ status: 0 } as cp.SpawnSyncReturns); }); it('should handle multiple parameters', () => { @@ -78,6 +76,27 @@ describe('dotnet client', () => { expect(spawnSyncSpy.mock.calls[0][1]).toContain('-p:Name=bar'); }); }); + it('should convert options to flags', () => { + const dotnetClient = new DotNetClient(mockDotnetFactory()); + const spawnSyncSpy = jest + .spyOn(cp, 'spawnSync') + .mockReturnValue({ status: 0 } as cp.SpawnSyncReturns); + dotnetClient.publish('my-project', { + noBuild: false, + noRestore: true, + configuration: 'Release', + }); + expect(spawnSyncSpy).toBeCalledTimes(1); + expect(spawnSyncSpy.mock.calls[0][1]).toMatchInlineSnapshot(` + [ + "publish", + ""my-project"", + "--no-restore", + "--configuration", + "Release", + ] + `); + }); }); describe('listInstalledTemplates', () => { @@ -484,4 +503,128 @@ ASP.NET Core gRPC Service grpc [C#] `); }); }); + + describe('test', () => { + it('should convert options to flags', () => { + const dotnetClient = new DotNetClient(mockDotnetFactory()); + const spawnSyncSpy = jest + .spyOn(cp, 'spawnSync') + .mockReturnValue({ status: 0 } as cp.SpawnSyncReturns); + dotnetClient.test('my-project', false, { + blame: false, + noRestore: true, + blameHang: true, + blameHangDump: 'dump.file', + }); + expect(spawnSyncSpy).toHaveBeenCalledTimes(1); + expect(spawnSyncSpy.mock.calls[0][1]).toMatchInlineSnapshot(` + [ + "test", + "my-project", + "--no-restore", + "--blame-hang", + "--blame-hang-dump", + "dump.file", + ] + `); + }); + }); + + describe('build', () => { + it('should convert options to flags', () => { + const dotnetClient = new DotNetClient(mockDotnetFactory()); + const spawnSyncSpy = jest + .spyOn(cp, 'spawnSync') + .mockReturnValue({ status: 0 } as cp.SpawnSyncReturns); + dotnetClient.build('my-project', { + noDependencies: false, + noRestore: true, + configuration: 'Release', + }); + expect(spawnSyncSpy).toHaveBeenCalledTimes(1); + expect(spawnSyncSpy.mock.calls[0][1]).toMatchInlineSnapshot(` + [ + "build", + "my-project", + "--no-restore", + "--configuration", + "Release", + ] + `); + }); + }); + + describe('addPackageReference', () => { + it('should convert options to flags', () => { + const dotnetClient = new DotNetClient(mockDotnetFactory()); + const spawnSyncSpy = jest + .spyOn(cp, 'spawnSync') + .mockReturnValue({ status: 0 } as cp.SpawnSyncReturns); + dotnetClient.addPackageReference('my-project', 'other-package', { + noRestore: true, + version: '1.2.3', + }); + expect(spawnSyncSpy).toHaveBeenCalledTimes(1); + expect(spawnSyncSpy.mock.calls[0][1]).toMatchInlineSnapshot(` + [ + "add", + "my-project", + "package", + "other-package", + "--no-restore", + "--version", + "1.2.3", + ] + `); + }); + }); + + describe('new', () => { + it('should convert options to flags', () => { + const dotnetClient = new DotNetClient(mockDotnetFactory()); + const spawnSyncSpy = jest + .spyOn(cp, 'spawnSync') + .mockReturnValue({ status: 0 } as cp.SpawnSyncReturns); + dotnetClient.new('my-template', { + dryRun: true, + force: false, + name: 'my-project', + }); + expect(spawnSyncSpy).toHaveBeenCalledTimes(1); + expect(spawnSyncSpy.mock.calls[0][1]).toMatchInlineSnapshot(` + [ + "new", + "my-template", + "--dry-run", + "--name", + "my-project", + ] + `); + }); + }); + + describe('run', () => { + it('should convert options to flags', () => { + const dotnetClient = new DotNetClient(mockDotnetFactory()); + const spawnSpy = jest + .spyOn(cp, 'spawn') + .mockReturnValue({ exitCode: 0 } as cp.ChildProcess); + dotnetClient.run('my-project', false, { + noRestore: true, + noDependencies: false, + configuration: 'Release', + }); + expect(spawnSpy).toHaveBeenCalledTimes(1); + expect(spawnSpy.mock.calls[0][1]).toMatchInlineSnapshot(` + [ + "run", + "--project", + "my-project", + "--no-restore", + "--configuration", + "Release", + ] + `); + }); + }); }); diff --git a/packages/dotnet/src/lib/core/dotnet.client.ts b/packages/dotnet/src/lib/core/dotnet.client.ts index 5d1419bd..75f24202 100644 --- a/packages/dotnet/src/lib/core/dotnet.client.ts +++ b/packages/dotnet/src/lib/core/dotnet.client.ts @@ -1,11 +1,14 @@ import { ChildProcess, spawn, spawnSync } from 'child_process'; import * as semver from 'semver'; -import { getSpawnParameterArray, swapKeysUsingMap } from '@nx-dotnet/utils'; +import { + convertOptionsToParams, + getSpawnParameterArray, +} from '@nx-dotnet/utils'; import { - addPackageKeyMap, - buildKeyMap, + addPackageCommandLineParamFixes, + buildCommandLineParamFixes, dotnetAddPackageOptions, dotnetBuildOptions, dotnetFormatOptions, @@ -14,18 +17,21 @@ import { dotnetRunOptions, DotnetTemplate, dotnetTestOptions, - formatKeyMap, + formatCommandLineParamFixes, KnownDotnetTemplates, - newKeyMap, - publishKeyMap, - runKeyMap, - testKeyMap, + newCommandLineParamFixes, + publishCommandLineParamFixes, + runCommandLineParamFixes, + testCommandLineParamFixes, } from '../models'; import { parseDotnetNewListOutput } from '../utils/parse-dotnet-new-list-output'; import { LoadedCLI } from './dotnet.factory'; export class DotNetClient { - constructor(private cliCommand: LoadedCLI, public cwd?: string) {} + constructor( + private cliCommand: LoadedCLI, + public cwd?: string, + ) {} new( template: KnownDotnetTemplates, @@ -34,8 +40,9 @@ export class DotNetClient { ): void { const params = [`new`, template]; if (parameters) { - parameters = swapKeysUsingMap(parameters, newKeyMap); - params.push(...getSpawnParameterArray(parameters)); + params.push( + ...convertOptionsToParams(parameters, newCommandLineParamFixes), + ); } params.push(...(additionalArguments ?? [])); return this.logAndExecute(params); @@ -72,8 +79,9 @@ export class DotNetClient { ): void { const params = [`build`, project]; if (parameters) { - parameters = swapKeysUsingMap(parameters, buildKeyMap); - params.push(...getSpawnParameterArray(parameters)); + params.push( + ...convertOptionsToParams(parameters, buildCommandLineParamFixes), + ); } if (extraParameters) { const matches = extraParameters.match(EXTRA_PARAMS_REGEX); @@ -91,8 +99,9 @@ export class DotNetClient { ? [`watch`, `--project`, project, `run`] : [`run`, `--project`, project]; if (parameters) { - parameters = swapKeysUsingMap(parameters, runKeyMap); - params.push(...getSpawnParameterArray(parameters)); + params.push( + ...convertOptionsToParams(parameters, runCommandLineParamFixes), + ); } return this.logAndSpawn(params); @@ -109,8 +118,9 @@ export class DotNetClient { : [`test`, project]; if (parameters) { - parameters = swapKeysUsingMap(parameters, testKeyMap); - params.push(...getSpawnParameterArray(parameters)); + params.push( + ...convertOptionsToParams(parameters, testCommandLineParamFixes), + ); } if (extraParameters) { const matches = extraParameters.match(EXTRA_PARAMS_REGEX); @@ -130,8 +140,9 @@ export class DotNetClient { ): void { const params = [`add`, project, `package`, pkg]; if (parameters) { - parameters = swapKeysUsingMap(parameters, addPackageKeyMap); - params.push(...getSpawnParameterArray(parameters)); + params.push( + ...convertOptionsToParams(parameters, addPackageCommandLineParamFixes), + ); } return this.logAndExecute(params); } @@ -148,8 +159,9 @@ export class DotNetClient { ): void { const params = [`publish`, `"${project}"`]; if (parameters) { - parameters = swapKeysUsingMap(parameters, publishKeyMap); - params.push(...getSpawnParameterArray(parameters)); + params.push( + ...convertOptionsToParams(parameters, publishCommandLineParamFixes), + ); } if (publishProfile) { params.push(`-p:PublishProfile=${publishProfile}`); @@ -216,8 +228,9 @@ export class DotNetClient { ...parameters, }; subcommandParams.push( - ...getSpawnParameterArray( - swapKeysUsingMap(subcommandParameterObject, formatKeyMap), + ...convertOptionsToParams( + subcommandParameterObject, + formatCommandLineParamFixes, ), ); this.logAndExecute(subcommandParams); @@ -233,8 +246,9 @@ export class DotNetClient { subcommandParameterObject.severity = style; } subcommandParams.push( - ...getSpawnParameterArray( - swapKeysUsingMap(subcommandParameterObject, formatKeyMap), + ...convertOptionsToParams( + subcommandParameterObject, + formatCommandLineParamFixes, ), ); this.logAndExecute(subcommandParams); @@ -250,8 +264,9 @@ export class DotNetClient { subcommandParameterObject.severity = analyzers; } subcommandParams.push( - ...getSpawnParameterArray( - swapKeysUsingMap(subcommandParameterObject, formatKeyMap), + ...convertOptionsToParams( + subcommandParameterObject, + formatCommandLineParamFixes, ), ); this.logAndExecute(subcommandParams); @@ -260,7 +275,7 @@ export class DotNetClient { params.push(project); if (parameters) { params.push( - ...getSpawnParameterArray(swapKeysUsingMap(parameters, formatKeyMap)), + ...convertOptionsToParams(parameters, formatCommandLineParamFixes), ); } return this.logAndExecute(params); diff --git a/packages/dotnet/src/lib/models/dotnet-add-package/dotnet-add-package-flags.ts b/packages/dotnet/src/lib/models/dotnet-add-package/dotnet-add-package-flags.ts index af2d8c00..f98f33d9 100644 --- a/packages/dotnet/src/lib/models/dotnet-add-package/dotnet-add-package-flags.ts +++ b/packages/dotnet/src/lib/models/dotnet-add-package/dotnet-add-package-flags.ts @@ -1,3 +1,5 @@ +import { CommandLineParamFixes } from '@nx-dotnet/utils'; + export type dotnetAddPackageFlags = | 'version' | 'framework' @@ -6,9 +8,11 @@ export type dotnetAddPackageFlags = | 'noRestore' | 'source'; -export const addPackageKeyMap: Partial<{ - [key in dotnetAddPackageFlags]: string; -}> = { - packageDirectory: 'package-directory', - noRestore: 'no-restore', -}; +export const addPackageCommandLineParamFixes: CommandLineParamFixes = + { + keyMap: { + packageDirectory: 'package-directory', + noRestore: 'no-restore', + }, + explicitFalseKeys: [], + }; diff --git a/packages/dotnet/src/lib/models/dotnet-build/dotnet-build-flags.ts b/packages/dotnet/src/lib/models/dotnet-build/dotnet-build-flags.ts index d3307b2b..303e815b 100644 --- a/packages/dotnet/src/lib/models/dotnet-build/dotnet-build-flags.ts +++ b/packages/dotnet/src/lib/models/dotnet-build/dotnet-build-flags.ts @@ -1,3 +1,5 @@ +import { CommandLineParamFixes } from '@nx-dotnet/utils'; + export type dotnetBuildFlags = | 'configuration' | 'framework' @@ -12,9 +14,13 @@ export type dotnetBuildFlags = | 'versionSuffix' | 'runtime'; -export const buildKeyMap: Partial<{ [key in dotnetBuildFlags]: string }> = { - noRestore: 'no-restore', - noIncremental: 'no-incremental', - noDependencies: 'no-dependencies', - versionSuffix: 'version-suffix', -}; +export const buildCommandLineParamFixes: CommandLineParamFixes = + { + keyMap: { + noRestore: 'no-restore', + noIncremental: 'no-incremental', + noDependencies: 'no-dependencies', + versionSuffix: 'version-suffix', + }, + explicitFalseKeys: [], + }; diff --git a/packages/dotnet/src/lib/models/dotnet-format/dotnet-format-flags.ts b/packages/dotnet/src/lib/models/dotnet-format/dotnet-format-flags.ts index 3a95962a..e7ac8bcb 100644 --- a/packages/dotnet/src/lib/models/dotnet-format/dotnet-format-flags.ts +++ b/packages/dotnet/src/lib/models/dotnet-format/dotnet-format-flags.ts @@ -1,3 +1,5 @@ +import { CommandLineParamFixes } from '@nx-dotnet/utils'; + export type dotnetFormatFlags = | 'noRestore' // Deliberately excluding the folder option, as the csproj file is always used as the workspace. @@ -14,10 +16,14 @@ export type dotnetFormatFlags = | 'verifyNoChanges'; // Deliberately excluding the version option, as it doesn't perform any actual formatting. -export const formatKeyMap: Partial<{ [key in dotnetFormatFlags]: string }> = { - noRestore: 'no-restore', - fixWhitespace: 'fix-whitespace', - fixStyle: 'fix-style', - fixAnalyzers: 'fix-analyzers', - verifyNoChanges: 'verify-no-changes', -}; +export const formatCommandLineParamFixes: CommandLineParamFixes = + { + keyMap: { + noRestore: 'no-restore', + fixWhitespace: 'fix-whitespace', + fixStyle: 'fix-style', + fixAnalyzers: 'fix-analyzers', + verifyNoChanges: 'verify-no-changes', + }, + explicitFalseKeys: ['fixWhitespace', 'fixStyle', 'fixAnalyzers'], + }; diff --git a/packages/dotnet/src/lib/models/dotnet-new/dotnet-new-flags.ts b/packages/dotnet/src/lib/models/dotnet-new/dotnet-new-flags.ts index c49b8ef6..da22abaf 100644 --- a/packages/dotnet/src/lib/models/dotnet-new/dotnet-new-flags.ts +++ b/packages/dotnet/src/lib/models/dotnet-new/dotnet-new-flags.ts @@ -1,3 +1,5 @@ +import { CommandLineParamFixes } from '@nx-dotnet/utils'; + export type dotnetNewFlags = | 'dryRun' | 'force' @@ -10,9 +12,12 @@ export type dotnetNewFlags = | 'updateApply' | 'updateCheck'; -export const newKeyMap: Partial<{ [key in dotnetNewFlags]: string }> = { - dryRun: 'dry-run', - updateApply: 'update-apply', - updateCheck: 'update-check', - nugetSource: 'nuget-source', +export const newCommandLineParamFixes: CommandLineParamFixes = { + keyMap: { + dryRun: 'dry-run', + updateApply: 'update-apply', + updateCheck: 'update-check', + nugetSource: 'nuget-source', + }, + explicitFalseKeys: [], }; diff --git a/packages/dotnet/src/lib/models/dotnet-publish/dotnet-publish-flags.ts b/packages/dotnet/src/lib/models/dotnet-publish/dotnet-publish-flags.ts index a0daffbb..69f37b1e 100644 --- a/packages/dotnet/src/lib/models/dotnet-publish/dotnet-publish-flags.ts +++ b/packages/dotnet/src/lib/models/dotnet-publish/dotnet-publish-flags.ts @@ -1,3 +1,5 @@ +import { CommandLineParamFixes } from '@nx-dotnet/utils'; + export type dotnetPublishFlags = | 'configuration' | 'framework' @@ -13,10 +15,14 @@ export type dotnetPublishFlags = | 'verbosity' | 'versionSuffix'; -export const publishKeyMap: Partial<{ [key in dotnetPublishFlags]: string }> = { - noBuild: 'no-build', - noDependencies: 'no-dependencies', - noRestore: 'no-restore', - selfContained: 'self-contained', - versionSuffix: 'version-suffix', -}; +export const publishCommandLineParamFixes: CommandLineParamFixes = + { + keyMap: { + noBuild: 'no-build', + noDependencies: 'no-dependencies', + noRestore: 'no-restore', + selfContained: 'self-contained', + versionSuffix: 'version-suffix', + }, + explicitFalseKeys: [], + }; diff --git a/packages/dotnet/src/lib/models/dotnet-run/dotnet-run-flags.ts b/packages/dotnet/src/lib/models/dotnet-run/dotnet-run-flags.ts index d39c7965..9bcf8a5b 100644 --- a/packages/dotnet/src/lib/models/dotnet-run/dotnet-run-flags.ts +++ b/packages/dotnet/src/lib/models/dotnet-run/dotnet-run-flags.ts @@ -1,3 +1,5 @@ +import { CommandLineParamFixes } from '@nx-dotnet/utils'; + export type dotnetRunFlags = | 'configuration' | 'framework' @@ -12,9 +14,12 @@ export type dotnetRunFlags = | 'versionSuffix' | 'runtime'; -export const runKeyMap: Partial<{ [key in dotnetRunFlags]: string }> = { - noDependencies: 'no-dependencies', - noRestore: 'no-restore', - versionSuffix: 'version-suffix', - noIncremental: 'no-incremental', +export const runCommandLineParamFixes: CommandLineParamFixes = { + keyMap: { + noDependencies: 'no-dependencies', + noRestore: 'no-restore', + versionSuffix: 'version-suffix', + noIncremental: 'no-incremental', + }, + explicitFalseKeys: [], }; diff --git a/packages/dotnet/src/lib/models/dotnet-test/dotnet-test-flags.ts b/packages/dotnet/src/lib/models/dotnet-test/dotnet-test-flags.ts index edfcd1c4..4ce061bf 100644 --- a/packages/dotnet/src/lib/models/dotnet-test/dotnet-test-flags.ts +++ b/packages/dotnet/src/lib/models/dotnet-test/dotnet-test-flags.ts @@ -1,3 +1,5 @@ +import { CommandLineParamFixes } from '@nx-dotnet/utils'; + export type dotnetTestFlags = | 'blameCrashCollectAlways' | 'blameCrashDumpType' @@ -21,16 +23,20 @@ export type dotnetTestFlags = | 'testAdapterPath' | 'verbosity'; -export const testKeyMap: Partial<{ [key in dotnetTestFlags]: string }> = { - blameCrashCollectAlways: 'blame-crash-collect-always', - blameCrash: 'blame-crash', - blameCrashDumpType: 'blame-crash-dump-type', - blameHangDump: 'blame-hang-dump', - blameHang: 'blame-hang', - blameHangTimeout: 'blame-hang-timeout', - listTests: 'list-tests', - noBuild: 'no-build', - noRestore: 'no-restore', - resultsDirectory: 'results-directory', - testAdapterPath: 'test-adapter-path', -}; +export const testCommandLineParamFixes: CommandLineParamFixes = + { + keyMap: { + blameCrashCollectAlways: 'blame-crash-collect-always', + blameCrash: 'blame-crash', + blameCrashDumpType: 'blame-crash-dump-type', + blameHangDump: 'blame-hang-dump', + blameHang: 'blame-hang', + blameHangTimeout: 'blame-hang-timeout', + listTests: 'list-tests', + noBuild: 'no-build', + noRestore: 'no-restore', + resultsDirectory: 'results-directory', + testAdapterPath: 'test-adapter-path', + }, + explicitFalseKeys: [], + }; diff --git a/packages/utils/src/lib/utility-functions/args.ts b/packages/utils/src/lib/utility-functions/args.ts index ed4f80f9..840eeb45 100644 --- a/packages/utils/src/lib/utility-functions/args.ts +++ b/packages/utils/src/lib/utility-functions/args.ts @@ -1,15 +1,3 @@ export function isDryRun(): boolean { return process.argv.some((x) => x === '--dry-run'); } - -export function swapKeysUsingMap( - object: Record, - map: Record, -): Record { - return Object.fromEntries( - Object.entries(object).map(([key, value]) => [ - key in map ? map[key] : key, - value, - ]), - ); -} diff --git a/packages/utils/src/lib/utility-functions/parameters.spec.ts b/packages/utils/src/lib/utility-functions/parameters.spec.ts new file mode 100644 index 00000000..c3b1a9de --- /dev/null +++ b/packages/utils/src/lib/utility-functions/parameters.spec.ts @@ -0,0 +1,51 @@ +import { convertOptionsToParams } from './parameters'; + +describe('convertOptionsToParams', () => { + it('should change a value to the string "false" if in the explicit false list', () => { + const options = { + fixWhitespace: false, + fixStyle: true, + fixAnalyzers: false, + noBuild: false, + noDependencies: true, + } as const; + const result = convertOptionsToParams(options, { + explicitFalseKeys: ['fixWhitespace', 'fixStyle', 'fixAnalyzers'], + keyMap: {}, + }); + expect(result).toMatchInlineSnapshot(` + [ + "--fixWhitespace", + "false", + "--fixStyle", + "--fixAnalyzers", + "false", + "--noDependencies", + ] + `); + }); + + it('should map a key in the key map', () => { + const options = { + fixWhitespace: false, + fixStyle: true, + fixAnalyzers: false, + noBuild: false, + noDependencies: true, + } as const; + const result = convertOptionsToParams(options, { + explicitFalseKeys: [], + keyMap: { + fixWhitespace: 'fix-whitespace', + fixStyle: 'fix-style', + fixAnalyzers: 'fix-analyzers', + }, + }); + expect(result).toMatchInlineSnapshot(` + [ + "--fix-style", + "--noDependencies", + ] + `); + }); +}); diff --git a/packages/utils/src/lib/utility-functions/parameters.ts b/packages/utils/src/lib/utility-functions/parameters.ts index e390651f..a4eb1c89 100644 --- a/packages/utils/src/lib/utility-functions/parameters.ts +++ b/packages/utils/src/lib/utility-functions/parameters.ts @@ -25,16 +25,49 @@ export function getParameterString( * @returns Parameter string to be appended to CLI command */ export function getSpawnParameterArray( - parameters: Record, + parameters: Record, ): string[] { const spawnArray: string[] = []; for (const [key, value] of Object.entries(parameters)) { - // true booleans are flags, explicit false booleans follow regular key-value pattern - if (typeof value === 'boolean' && value) { - spawnArray.push(`--${key}`); + if (typeof value === 'boolean') { + if (value) { + spawnArray.push(`--${key}`); + } } else if (value !== undefined && value !== null) { spawnArray.push(`--${key}`, value.toString()); } } return spawnArray; } + +/** + * The needed configuration to convert an object of options into an array of CLI parameters. + */ +export interface CommandLineParamFixes { + /** + * A map of the option keys and what those flags are named in the cli + */ + keyMap: Partial>; + /** + * These are keys that need to be passed as `--key false` instead of not including in the flags + */ + explicitFalseKeys: readonly TKey[]; +} + +/** + * Converts an object of options like `{ noBuild: true }`into an array of CLI parameters like `["--no-build"]` + * Will run a conversion process to change every option to a string, and will map keys to different flags if needed. + */ +export function convertOptionsToParams( + options: Partial>, + fixes: CommandLineParamFixes, +): string[] { + const entries = Object.entries(options).map(([key, value]) => [ + key in fixes.keyMap ? fixes.keyMap[key as TKey] : key, + (fixes.explicitFalseKeys as readonly string[]).includes(key) && + value === false + ? 'false' + : value, + ]); + return getSpawnParameterArray(Object.fromEntries(entries)); +} From 6085c500dd17612217334d20a6b53786d8896396 Mon Sep 17 00:00:00 2001 From: Craigory Coppola Date: Wed, 31 Jan 2024 17:17:36 -0500 Subject: [PATCH 4/5] feat(core): update inference configuration (#822) --- docs/core/Generators/import-projects.md | 5 - docs/core/index.md | 4 - docs/index.md | 2 +- nx.json | 4 - package.json | 3 +- packages/core/generators.json | 5 - .../import-projects/generator.spec.ts | 128 ----------------- .../generators/import-projects/generator.ts | 131 ------------------ .../generators/import-projects/schema.json | 8 -- .../src/generators/move/generator.spec.ts | 36 ++++- .../core/src/generators/move/generator.ts | 60 +++++--- .../src/generators/utils/generate-project.ts | 39 +++--- .../generators/utils/generate-test-project.ts | 30 ++-- .../__snapshots__/create-nodes.spec.ts.snap | 15 ++ .../core/src/graph/create-dependencies.ts | 23 ++- packages/core/src/graph/create-nodes.ts | 78 +++++++---- .../models/build-executor-configuration.ts | 4 + .../src/models/lint-executor-configuration.ts | 2 + .../src/models/test-executor-configuration.ts | 18 ++- .../lib/models/nx-dotnet-config.interface.ts | 13 +- .../src/lib/utility-functions/workspace.ts | 13 ++ smoke/core/tests/nx-dotnet.spec.ts | 43 +++--- tools/scripts/local-registry/setup.ts | 4 + tools/scripts/publish-dev/index.ts | 8 +- tools/scripts/sandbox.ts | 51 +++---- 25 files changed, 290 insertions(+), 437 deletions(-) delete mode 100644 docs/core/Generators/import-projects.md delete mode 100644 packages/core/src/generators/import-projects/generator.spec.ts delete mode 100644 packages/core/src/generators/import-projects/generator.ts delete mode 100644 packages/core/src/generators/import-projects/schema.json diff --git a/docs/core/Generators/import-projects.md b/docs/core/Generators/import-projects.md deleted file mode 100644 index ba656886..00000000 --- a/docs/core/Generators/import-projects.md +++ /dev/null @@ -1,5 +0,0 @@ -# @nx-dotnet/core:import-projects - -## Import Projects - -Import existing .NET projects in C#, VB, or F# that are in your workspace's apps or libs directories. Simply move the projects into these folders, and then run `nx g @nx-dotnet/core:import-projects` to move them into Nx. Projects inside the apps directory will include a serve target, while projects inside libs will only contain build + lint targets. diff --git a/docs/core/index.md b/docs/core/index.md index 9ddf87c4..cd23bd7a 100644 --- a/docs/core/index.md +++ b/docs/core/index.md @@ -109,10 +109,6 @@ Restores NuGet packages and .NET tools used by the workspace Generate a .NET test project for an existing application or library -### [import-projects](./Generators/import-projects.md) - -Import existing projects into your Nx workspace - ### [add-swagger-target](./Generators/add-swagger-target.md) Add a swagger target to a webapi based project to extract swagger.json into a newly generated library project diff --git a/docs/index.md b/docs/index.md index 154a4b96..560deaf2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -8,7 +8,7 @@ slug: / ## [@nx-dotnet/core](./core) - 7 Executors -- 11 Generators +- 10 Generators ## [@nx-dotnet/nx-ghpages](./nx-ghpages) diff --git a/nx.json b/nx.json index 1437d088..65ba7fe3 100644 --- a/nx.json +++ b/nx.json @@ -3,10 +3,6 @@ "affected": { "defaultBase": "master" }, - "workspaceLayout": { - "appsDir": "", - "libsDir": "" - }, "plugins": [ { "plugin": "@nx-dotnet/core", diff --git a/package.json b/package.json index 01a7ef66..5d8b2cd8 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "documentation:check": "ts-node ./tools/scripts/hooks/documentation.check.ts", "documentation": "nx g @nx-dotnet/nxdoc:generate-docs", "publish-dev": "ts-node tools/scripts/publish-dev", - "sandbox": "ts-node ./tools/scripts/sandbox.ts" + "sandbox": "ts-node ./tools/scripts/sandbox.ts", + "local-registry": "ts-node ./tools/scripts/local-registry/setup.ts" }, "private": false, "dependencies": { diff --git a/packages/core/generators.json b/packages/core/generators.json index 312caa90..fa07ffda 100644 --- a/packages/core/generators.json +++ b/packages/core/generators.json @@ -50,11 +50,6 @@ "description": "Generate a .NET test project for an existing application or library", "x-type": "library" }, - "import-projects": { - "factory": "./src/generators/import-projects/generator", - "schema": "./src/generators/import-projects/schema.json", - "description": "Import existing projects into your Nx workspace" - }, "add-swagger-target": { "factory": "./src/generators/add-swagger-target/add-swagger-target", "schema": "./src/generators/add-swagger-target/schema.json", diff --git a/packages/core/src/generators/import-projects/generator.spec.ts b/packages/core/src/generators/import-projects/generator.spec.ts deleted file mode 100644 index aec59e45..00000000 --- a/packages/core/src/generators/import-projects/generator.spec.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { getProjects, readProjectConfiguration, Tree } from '@nx/devkit'; -import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; - -import * as fs from 'fs'; - -import { DotNetClient, mockDotnetFactory } from '@nx-dotnet/dotnet'; -import * as utils from '@nx-dotnet/utils'; - -import * as mockedInitGenerator from '../init/generator'; -import generator from './generator'; - -jest.mock('@nx-dotnet/utils', () => ({ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - ...(jest.requireActual('@nx-dotnet/utils') as any), - glob: jest.fn(), - findProjectFileInPath: jest.fn(), - resolve: (m: string) => m, -})); - -const MOCK_API_PROJECT = ` - - - net5.0 - MyTestApi - -`; - -const MOCK_TEST_PROJECT = ` - - - net5.0 - MyTestApi.Test - - - - -`; - -jest.mock('../init/generator', () => ({ - initGenerator: jest.fn(() => { - return Promise.resolve(jest.fn(() => Promise.resolve())); - }), -})); - -describe('import-projects generator', () => { - let tree: Tree; - let dotnetClient: DotNetClient; - - beforeEach(() => { - tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' }); - dotnetClient = new DotNetClient(mockDotnetFactory()); - }); - - afterEach(() => { - jest.clearAllMocks(); - }); - - it('should run successfully if no new projects are found', async () => { - jest.spyOn(utils, 'glob').mockResolvedValue([]); - const promise = generator(tree, null, dotnetClient); - const oldProjects = getProjects(tree); - await expect(promise).resolves.not.toThrow(); - const newProjects = getProjects(tree); - expect(oldProjects).toEqual(newProjects); - }); - - it('should run successfully if new projects are found', async () => { - jest - .spyOn(utils, 'glob') - .mockImplementation((x) => - Promise.resolve( - x.startsWith('apps') ? ['apps/my-api/my-api.csproj'] : [], - ), - ); - jest - .spyOn(utils, 'findProjectFileInPath') - .mockImplementation((x) => - x.startsWith('apps') - ? Promise.resolve('apps/my-api/my-api.csproj') - : Promise.reject(new Error()), - ); - jest.spyOn(fs, 'readFileSync').mockReturnValue(MOCK_TEST_PROJECT); - jest.spyOn(fs, 'writeFileSync').mockImplementation(() => null); - tree.write('apps/my-api/my-api.csproj', MOCK_API_PROJECT); - const promise = generator(tree, null, dotnetClient); - await expect(promise).resolves.not.toThrow(); - expect(readProjectConfiguration(tree, 'my-test-api')).toBeDefined(); - }); - - it('should run add test target if test projects are found', async () => { - jest - .spyOn(utils, 'glob') - .mockImplementation((x) => - Promise.resolve( - x.startsWith('apps') ? ['apps/my-api-test/my-api-test.csproj'] : [], - ), - ); - jest - .spyOn(utils, 'findProjectFileInPath') - .mockImplementation((x) => - x.startsWith('apps') - ? Promise.resolve('apps/my-api/my-api-test.csproj') - : Promise.reject(new Error()), - ); - jest.spyOn(fs, 'readFileSync').mockReturnValue(MOCK_TEST_PROJECT); - jest.spyOn(fs, 'writeFileSync').mockImplementation(() => null); - tree.write('apps/my-api-test/my-api-test.csproj', MOCK_TEST_PROJECT); - const promise = generator(tree, null, dotnetClient); - await expect(promise).resolves.not.toThrow(); - expect(readProjectConfiguration(tree, 'my-test-api-test')).toBeDefined(); - expect( - readProjectConfiguration(tree, 'my-test-api-test').targets?.test, - ).toBeDefined(); - expect( - readProjectConfiguration(tree, 'my-test-api-test').targets?.serve, - ).not.toBeDefined(); - }); - - it('should call init generator', async () => { - const initGenerator = ( - mockedInitGenerator as jest.Mocked - ).initGenerator; - - jest.spyOn(utils, 'glob').mockResolvedValue([]); - await generator(tree, null, dotnetClient); - expect(initGenerator).toHaveBeenCalledWith(tree, null, dotnetClient); - }); -}); diff --git a/packages/core/src/generators/import-projects/generator.ts b/packages/core/src/generators/import-projects/generator.ts deleted file mode 100644 index 066d5988..00000000 --- a/packages/core/src/generators/import-projects/generator.ts +++ /dev/null @@ -1,131 +0,0 @@ -import { - addProjectConfiguration, - formatFiles, - getProjects, - getWorkspaceLayout, - joinPathFragments, - logger, - names, - ProjectConfiguration, - TargetConfiguration, - Tree, -} from '@nx/devkit'; - -import { basename, dirname } from 'path'; -import { XmlDocument } from 'xmldoc'; - -import { DotNetClient, dotnetFactory } from '@nx-dotnet/dotnet'; -import { glob, iterateChildrenByPath, projPattern } from '@nx-dotnet/utils'; - -import { - GetBuildExecutorConfiguration, - GetLintExecutorConfiguration, - GetServeExecutorConfig, - GetTestExecutorConfig, -} from '../../models'; -import { initGenerator } from '../init/generator'; - -export default async function ( - host: Tree, - options: null, // The second option is provided at runtime by Nx for options passed in to the generator. - dotnetClient = new DotNetClient(dotnetFactory()), -) { - const installTask = await initGenerator(host, null, dotnetClient); - - const projectFiles = await getProjectFilesInWorkspace(host); - const existingProjectJsonDirectories = getDirectoriesWithProjectJson(host); - for (const projectFile of projectFiles.newLibs) { - if ( - !existingProjectJsonDirectories.some((x) => - projectFile.startsWith(x + '/'), - ) - ) { - await addNewDotnetProject(host, projectFile, false); - logger.log('Found new library', projectFile); - } - } - for (const projectFile of projectFiles.newApps) { - if ( - !existingProjectJsonDirectories.some((x) => - projectFile.startsWith(x + '/'), - ) - ) { - await addNewDotnetProject(host, projectFile, true); - logger.log('Found new application', projectFile); - } - } - return async () => { - await installTask(); - await formatFiles(host); - }; -} - -async function addNewDotnetProject( - host: Tree, - projectFile: string, - app: boolean, -) { - const rootNamespace = readRootNamespace(host, projectFile); - const projectRoot = dirname(projectFile); - const projectName = rootNamespace - ? names(rootNamespace).fileName.replace(/\./g, '-') - : names(basename(projectRoot)).fileName; - const configuration: ProjectConfiguration & { - targets: Record; - } = { - root: projectRoot, - targets: { - build: GetBuildExecutorConfiguration(projectRoot), - lint: GetLintExecutorConfiguration(), - }, - projectType: app ? 'application' : 'library', - }; - const testProject = await checkIfTestProject(host, projectFile); - if (app && !testProject) { - configuration.targets.serve = GetServeExecutorConfig(); - } - if (testProject) { - configuration.targets.test = GetTestExecutorConfig(); - } - addProjectConfiguration(host, projectName, configuration); -} - -async function getProjectFilesInWorkspace(host: Tree) { - const { appsDir, libsDir } = getWorkspaceLayout(host); - const newProjects = { - newLibs: await glob(projPattern(libsDir)), - newApps: [] as string[], - }; - if (libsDir !== appsDir) { - newProjects.newApps = await glob(projPattern(appsDir)); - } - return newProjects; -} - -function readRootNamespace(host: Tree, path: string): string | undefined { - const xml = new XmlDocument(host.read(path)?.toString() as string); - return xml.valueWithPath('PropertyGroup.RootNamespace'); -} - -async function checkIfTestProject(host: Tree, path: string): Promise { - const xml = new XmlDocument(host.read(path)?.toString() as string); - let isTestProject = false; - await iterateChildrenByPath(xml, 'ItemGroup.PackageReference', (el) => { - const pkg = el.attr['Include']; - if (pkg === 'Microsoft.NET.Test.Sdk') { - isTestProject = true; - } - }); - return isTestProject; -} - -function getDirectoriesWithProjectJson(host: Tree) { - const nxProjects = getProjects(host); - const collected: string[] = []; - for (const proj of nxProjects.values()) { - if (host.exists(joinPathFragments(proj.root, 'project.json'))) { - collected.push(proj.root); - } - } - return collected; -} diff --git a/packages/core/src/generators/import-projects/schema.json b/packages/core/src/generators/import-projects/schema.json deleted file mode 100644 index 5179be83..00000000 --- a/packages/core/src/generators/import-projects/schema.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "http://json-schema.org/schema", - "id": "@nx-dotnet/core:import-projects", - "title": "Import Projects", - "description": "Import existing .NET projects in C#, VB, or F# that are in your workspace's apps or libs directories. Simply move the projects into these folders, and then run `nx g @nx-dotnet/core:import-projects` to move them into Nx. Projects inside the apps directory will include a serve target, while projects inside libs will only contain build + lint targets.", - "type": "object", - "properties": {} -} diff --git a/packages/core/src/generators/move/generator.spec.ts b/packages/core/src/generators/move/generator.spec.ts index 8eda7c17..b59bf3ea 100644 --- a/packages/core/src/generators/move/generator.spec.ts +++ b/packages/core/src/generators/move/generator.spec.ts @@ -7,12 +7,23 @@ import { names, offsetFromRoot, ProjectConfiguration, + ProjectGraph, } from '@nx/devkit'; import { uniq } from '@nx/plugin/testing'; import generator from './generator'; import { basename } from 'path'; +let graph: ProjectGraph = { + dependencies: {}, + nodes: {}, +}; + +jest + // eslint-disable-next-line @typescript-eslint/no-var-requires + .spyOn(require('@nx/devkit'), 'createProjectGraphAsync') + .mockImplementation(() => Promise.resolve(graph)); + describe('move generator', () => { let tree: Tree; @@ -20,6 +31,10 @@ describe('move generator', () => { tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs', }); + graph = { + dependencies: {}, + nodes: {}, + }; }); it('should move simple projects successfully', async () => { @@ -107,12 +122,22 @@ describe('move generator', () => { new RegExp(`^${joinPathFragments(relativeToRoot, 'node_modules')}.*`), ); }); + + it('should work for inferred projects', async () => { + const { project, root: source } = makeSimpleProject(tree, 'app', 'a/b'); + tree.delete(joinPathFragments(source, 'project.json')); + const destination = joinPathFragments('a', 'b', 'c', uniq('app')); + await generator(tree, { projectName: project, destination }); + expect( + tree.exists(joinPathFragments(destination, 'project.json')), + ).toBeFalsy(); + }); }); function makeSimpleProject(tree: Tree, type: 'app' | 'lib', path?: string) { const project = uniq(type); const root = joinPathFragments(`${type}s`, path ?? '', project); - addProjectConfiguration(tree, project, { + const configuration: ProjectConfiguration = { root, sourceRoot: joinPathFragments(root, 'src'), projectType: type === 'app' ? 'application' : 'library', @@ -122,7 +147,14 @@ function makeSimpleProject(tree: Tree, type: 'app' | 'lib', path?: string) { outputs: [`{workspaceRoot}/dist/${root}`], }, }, - }); + }; + addProjectConfiguration(tree, project, configuration); + graph.nodes[project] = { + data: configuration, + name: project, + type, + }; + tree.write(joinPathFragments(root, 'readme.md'), 'contents'); return { project, root }; } diff --git a/packages/core/src/generators/move/generator.ts b/packages/core/src/generators/move/generator.ts index 0df10d05..c7ceaed5 100644 --- a/packages/core/src/generators/move/generator.ts +++ b/packages/core/src/generators/move/generator.ts @@ -1,5 +1,6 @@ import { addProjectConfiguration, + createProjectGraphAsync, formatFiles, getWorkspaceLayout, joinPathFragments, @@ -22,12 +23,22 @@ type NormalizedSchema = { destinationProject: string; }; -function normalizeOptions( +async function getCurrentProjectConfiguration( + projectName: string, +): Promise { + return await ( + await createProjectGraphAsync() + ).nodes[projectName].data; +} + +async function normalizeOptions( tree: Tree, options: MoveGeneratorSchema, -): NormalizedSchema { +): Promise { const { appsDir, libsDir } = getWorkspaceLayout(tree); - const currentRoot = readProjectConfiguration(tree, options.projectName).root; + const { root: currentRoot } = await getCurrentProjectConfiguration( + options.projectName, + ); let destinationRoot = options.destination; if (!options.relativeToRoot) { if (currentRoot.startsWith(appsDir)) { @@ -55,28 +66,45 @@ function normalizeOptions( } export default async function (tree: Tree, options: MoveGeneratorSchema) { - const normalizedOptions = normalizeOptions(tree, options); - const config = readProjectConfiguration( - tree, - normalizedOptions.currentProject, - ); - config.root = normalizedOptions.destinationRoot; - config.name = normalizedOptions.destinationProject; - removeProjectConfiguration(tree, normalizedOptions.currentProject); + const normalizedOptions = await normalizeOptions(tree, options); + const writeNewProjectJson = updateProjectJson(tree, normalizedOptions); + renameDirectory( tree, normalizedOptions.currentRoot, normalizedOptions.destinationRoot, ); - addProjectConfiguration( - tree, - options.projectName, - transformConfiguration(tree, config, normalizedOptions), - ); + + writeNewProjectJson(); + updateXmlReferences(tree, normalizedOptions); await formatFiles(tree); } +function updateProjectJson(tree: Tree, normalizedOptions: NormalizedSchema) { + try { + const config = readProjectConfiguration( + tree, + normalizedOptions.currentProject, + ); + config.root = normalizedOptions.destinationRoot; + config.name = normalizedOptions.destinationProject; + removeProjectConfiguration(tree, normalizedOptions.currentProject); + return () => { + addProjectConfiguration( + tree, + normalizedOptions.destinationProject, + transformConfiguration(tree, config, normalizedOptions), + ); + }; + } catch { + // There was no project.json, so dont add one. + return () => { + /* its fine */ + }; + } +} + function transformConfiguration( tree: Tree, config: ProjectConfiguration, diff --git a/packages/core/src/generators/utils/generate-project.ts b/packages/core/src/generators/utils/generate-project.ts index fbd6ab03..2034fe68 100644 --- a/packages/core/src/generators/utils/generate-project.ts +++ b/packages/core/src/generators/utils/generate-project.ts @@ -6,7 +6,6 @@ import { joinPathFragments, names, normalizePath, - ProjectConfiguration, ProjectType, Tree, } from '@nx/devkit'; @@ -20,7 +19,7 @@ import { dotnetNewOptions, KnownDotnetTemplates, } from '@nx-dotnet/dotnet'; -import { isDryRun, resolve } from '@nx-dotnet/utils'; +import { isDryRun, isNxCrystalEnabled, resolve } from '@nx-dotnet/utils'; import { GetBuildExecutorConfiguration, @@ -190,25 +189,21 @@ export async function GenerateProject( projectType, ); - const projectConfiguration: ProjectConfiguration = { - root: normalizedOptions.projectRoot, - projectType: projectType, - sourceRoot: `${normalizedOptions.projectRoot}`, - targets: { - build: GetBuildExecutorConfiguration(normalizedOptions.projectRoot), - ...(projectType === 'application' - ? { serve: GetServeExecutorConfig() } - : {}), - lint: GetLintExecutorConfiguration(), - }, - tags: normalizedOptions.parsedTags, - }; - - addProjectConfiguration( - host, - normalizedOptions.projectName, - projectConfiguration, - ); + if (!isNxCrystalEnabled()) { + addProjectConfiguration(host, normalizedOptions.projectName, { + root: normalizedOptions.projectRoot, + projectType: projectType, + sourceRoot: `${normalizedOptions.projectRoot}`, + targets: { + build: GetBuildExecutorConfiguration(normalizedOptions.projectRoot), + ...(projectType === 'application' + ? { serve: GetServeExecutorConfig() } + : {}), + lint: GetLintExecutorConfiguration(), + }, + tags: normalizedOptions.parsedTags, + }); + } const newParams: dotnetNewOptions = { language: normalizedOptions.language, @@ -232,7 +227,7 @@ export async function GenerateProject( if (!isDryRun()) { addToSolutionFile( host, - projectConfiguration.root, + normalizedOptions.projectRoot, dotnetClient, normalizedOptions.solutionFile, ); diff --git a/packages/core/src/generators/utils/generate-test-project.ts b/packages/core/src/generators/utils/generate-test-project.ts index bd5d5b45..4d5339e9 100644 --- a/packages/core/src/generators/utils/generate-test-project.ts +++ b/packages/core/src/generators/utils/generate-test-project.ts @@ -1,7 +1,11 @@ import { addProjectConfiguration, names, Tree } from '@nx/devkit'; import { DotNetClient, dotnetNewOptions } from '@nx-dotnet/dotnet'; -import { findProjectFileInPath, isDryRun } from '@nx-dotnet/utils'; +import { + findProjectFileInPath, + isDryRun, + isNxCrystalEnabled, +} from '@nx-dotnet/utils'; import { GetBuildExecutorConfiguration, @@ -42,17 +46,19 @@ export async function GenerateTestProject( const testRoot = schema.projectRoot + separator + suffix; const testProjectName = schema.projectName + separator + suffix; - addProjectConfiguration(host, testProjectName, { - root: testRoot, - projectType: schema.projectType, - sourceRoot: `${testRoot}`, - targets: { - build: GetBuildExecutorConfiguration(testRoot), - test: GetTestExecutorConfig(), - lint: GetLintExecutorConfiguration(), - }, - tags: schema.parsedTags, - }); + if (!isNxCrystalEnabled()) { + addProjectConfiguration(host, testProjectName, { + root: testRoot, + projectType: schema.projectType, + sourceRoot: `${testRoot}`, + targets: { + build: GetBuildExecutorConfiguration(testRoot), + test: GetTestExecutorConfig(), + lint: GetLintExecutorConfiguration(), + }, + tags: schema.parsedTags, + }); + } const newParams: dotnetNewOptions = { language: schema.language, diff --git a/packages/core/src/graph/__snapshots__/create-nodes.spec.ts.snap b/packages/core/src/graph/__snapshots__/create-nodes.spec.ts.snap index 2a62e6e8..46db933c 100644 --- a/packages/core/src/graph/__snapshots__/create-nodes.spec.ts.snap +++ b/packages/core/src/graph/__snapshots__/create-nodes.spec.ts.snap @@ -2,11 +2,15 @@ exports[`infer-project should generate build, lint, serve targets for projects 1`] = ` { + "cache": true, "configurations": { "production": { "configuration": "Release", }, }, + "dependsOn": [ + "^build", + ], "executor": "@nx-dotnet/core:build", "options": { "configuration": "Debug", @@ -15,13 +19,19 @@ exports[`infer-project should generate build, lint, serve targets for projects 1 "outputs": [ "{workspaceRoot}/dist/libs/api", "{workspaceRoot}/dist/intermediates/libs/api", + "{projectRoot}/bin", + "{projectRoot}/obj", ], } `; exports[`infer-project should generate build, lint, serve targets for projects 2`] = ` { + "cache": true, "executor": "@nx-dotnet/core:format", + "inputs": [ + "{projectRoot}/**/*.{cs,fs,vb}", + ], } `; @@ -41,8 +51,13 @@ exports[`infer-project should generate build, lint, serve targets for projects 3 exports[`infer-project should generate test target for test projects 1`] = ` { + "cache": true, + "dependsOn": [ + "build", + ], "executor": "@nx-dotnet/core:test", "options": { + "noBuild": true, "testProject": undefined, }, } diff --git a/packages/core/src/graph/create-dependencies.ts b/packages/core/src/graph/create-dependencies.ts index 4b338f40..796a259c 100644 --- a/packages/core/src/graph/create-dependencies.ts +++ b/packages/core/src/graph/create-dependencies.ts @@ -18,19 +18,16 @@ import { // It used to only consist of the context, but now it also includes the options. // The options were inserted as the first parameter, and the context was moved to the second. // The following types are used to support both signatures. -type CreateDependenciesV16 = ( - ctx: Parameters[1], - _: undefined, -) => ReturnType; - -type CreateDependenciesCompat = ( - p0: - | Parameters>[0] - | Parameters[0], - p1: - | Parameters>[1] - | Parameters[1], -) => ReturnType>; +type CreateDependenciesCompat = { + ( + ctx: CreateDependenciesContext, + _: undefined, + ): ReturnType>; + ( + opts: Parameters>[0], + ctx: CreateDependenciesContext, + ): ReturnType>; +}; export const createDependencies: CreateDependenciesCompat = ( ctxOrOpts: CreateDependenciesContext | NxDotnetConfig | undefined, diff --git a/packages/core/src/graph/create-nodes.ts b/packages/core/src/graph/create-nodes.ts index 6e526b3b..d1eec5ff 100644 --- a/packages/core/src/graph/create-nodes.ts +++ b/packages/core/src/graph/create-nodes.ts @@ -28,28 +28,57 @@ export const registerProjectTargets = ( ) => { const targets: Record = {}; const { inferredTargets } = opts; - if (inferredTargets !== false) { - const projectFileContents = readFileSync( - resolve(workspaceRoot, projectFile), - 'utf8', - ); - if ( - projectFileContents.includes('Microsoft.NET.Test.Sdk') && - inferredTargets.test - ) { - targets[inferredTargets.test] = GetTestExecutorConfig(); - } - if (inferredTargets.build) { - targets[inferredTargets.build] = GetBuildExecutorConfiguration( - dirname(projectFile), - ); - } - if (inferredTargets.lint) { - targets[inferredTargets.lint] = GetLintExecutorConfiguration(); - } - if (inferredTargets.serve) { - targets[inferredTargets.serve] = GetServeExecutorConfig(); - } + if (inferredTargets === false) { + return {}; + } + + const projectFileContents = readFileSync( + resolve(workspaceRoot, projectFile), + 'utf8', + ); + + if ( + projectFileContents.includes('Microsoft.NET.Test.Sdk') && + inferredTargets.test + ) { + const { targetName, ...extraOptions } = + typeof inferredTargets.test === 'string' + ? { targetName: inferredTargets.test } + : inferredTargets.test; + targets[targetName] = { + ...GetTestExecutorConfig(), + ...extraOptions, + }; + } + if (inferredTargets.build) { + const { targetName, ...extraOptions } = + typeof inferredTargets.build === 'string' + ? { targetName: inferredTargets.build } + : inferredTargets.build; + targets[targetName] = { + ...GetBuildExecutorConfiguration(dirname(projectFile)), + ...extraOptions, + }; + } + if (inferredTargets.lint) { + const { targetName, ...extraOptions } = + typeof inferredTargets.lint === 'string' + ? { targetName: inferredTargets.lint } + : inferredTargets.lint; + targets[targetName] = { + ...GetLintExecutorConfiguration(), + ...extraOptions, + }; + } + if (inferredTargets.serve) { + const { targetName, ...extraOptions } = + typeof inferredTargets.serve === 'string' + ? { targetName: inferredTargets.serve } + : inferredTargets.serve; + targets[targetName] = { + ...GetServeExecutorConfig(), + ...extraOptions, + }; } return targets; }; @@ -84,8 +113,9 @@ export const createNodes: CreateNodesCompat = [ `**/{${projectFilePatterns.join(',')}}`, ( file: string, - ctxOrOpts: CreateNodesContext | NxDotnetConfigV2 | undefined, - maybeCtx: CreateNodesContext | undefined, + // We read the config in the function to ensure it's always up to date / compatible. + // ctxOrOpts: CreateNodesContext | NxDotnetConfigV2 | undefined, + // maybeCtx: CreateNodesContext | undefined, ) => { const options = readConfig(); diff --git a/packages/core/src/models/build-executor-configuration.ts b/packages/core/src/models/build-executor-configuration.ts index 59fed9a8..719d3e7c 100644 --- a/packages/core/src/models/build-executor-configuration.ts +++ b/packages/core/src/models/build-executor-configuration.ts @@ -15,11 +15,15 @@ export function GetBuildExecutorConfiguration( : [ `{workspaceRoot}/dist/${projectRoot}`, `{workspaceRoot}/dist/intermediates/${projectRoot}`, + `{projectRoot}/bin`, + `{projectRoot}/obj`, ]; return { executor: '@nx-dotnet/core:build', outputs, + cache: true, + dependsOn: ['^build'], options: { configuration: 'Debug', noDependencies: true, diff --git a/packages/core/src/models/lint-executor-configuration.ts b/packages/core/src/models/lint-executor-configuration.ts index 8a91161f..86929bfc 100644 --- a/packages/core/src/models/lint-executor-configuration.ts +++ b/packages/core/src/models/lint-executor-configuration.ts @@ -3,5 +3,7 @@ import { TargetConfiguration } from '@nx/devkit'; export function GetLintExecutorConfiguration(): TargetConfiguration { return { executor: '@nx-dotnet/core:format', + cache: true, + inputs: ['{projectRoot}/**/*.{cs,fs,vb}'], }; } diff --git a/packages/core/src/models/test-executor-configuration.ts b/packages/core/src/models/test-executor-configuration.ts index b621f2fc..89d9d427 100644 --- a/packages/core/src/models/test-executor-configuration.ts +++ b/packages/core/src/models/test-executor-configuration.ts @@ -1,23 +1,21 @@ import { TargetConfiguration } from '@nx/devkit'; +import { TestExecutorSchema } from '../executors/test/schema'; export function GetTestExecutorConfig( projectName?: string, ): TestTargetConfiguration { return { executor: '@nx-dotnet/core:test', + cache: true, + dependsOn: ['build'], options: { testProject: projectName, + noBuild: true, }, }; } -export interface TestTargetConfiguration extends TargetConfiguration { - options: { - /** - * If null, implicitly this must be the test project. - * Else, run this target on the testProject instead of - * the executor's target. - */ - testProject?: string; - }; -} +export type TestTargetConfiguration = TargetConfiguration & { + executor: '@nx-dotnet/core:test'; + options: TestExecutorSchema; +}; diff --git a/packages/utils/src/lib/models/nx-dotnet-config.interface.ts b/packages/utils/src/lib/models/nx-dotnet-config.interface.ts index 92608591..19d2edc5 100644 --- a/packages/utils/src/lib/models/nx-dotnet-config.interface.ts +++ b/packages/utils/src/lib/models/nx-dotnet-config.interface.ts @@ -1,3 +1,4 @@ +import { TargetConfiguration } from '@nx/devkit'; import { ModuleBoundaries } from './nx'; export interface NxDotnetConfigV1 { @@ -31,11 +32,15 @@ export interface NxDotnetConfigV1 { inferProjects?: boolean; } +type PluginTargetConfiguration = TargetConfiguration & { + targetName: string; +}; + type ConfiguredTargets = { - build: string | false; - lint: string | false; - serve: string | false; - test: string | false; + build: PluginTargetConfiguration | string | false; + lint: PluginTargetConfiguration | string | false; + serve: PluginTargetConfiguration | string | false; + test: PluginTargetConfiguration | string | false; }; export type NxDotnetConfigV2 = Omit & { diff --git a/packages/utils/src/lib/utility-functions/workspace.ts b/packages/utils/src/lib/utility-functions/workspace.ts index 4c6c61cd..5230e76c 100644 --- a/packages/utils/src/lib/utility-functions/workspace.ts +++ b/packages/utils/src/lib/utility-functions/workspace.ts @@ -2,6 +2,7 @@ import { DependencyType, getProjects, normalizePath as nxNormalizePath, + NX_VERSION, ProjectConfiguration, ProjectsConfigurations, RawProjectGraphDependency, @@ -11,6 +12,7 @@ import { import { readFileSync } from 'fs'; import { dirname, relative, resolve } from 'path'; +import { lt } from 'semver'; import { XmlDocument, XmlElement } from 'xmldoc'; import { findProjectFileInPath, findProjectFileInPathSync, glob } from './glob'; @@ -192,6 +194,17 @@ export function inlineNxTokens(value: string, project: ProjectConfiguration) { return value.replace('{projectName}', project.name as string); } +export function isNxCrystalEnabled() { + // not the default + if (lt(NX_VERSION, '18.0.0')) { + return process.env.NX_PCV3 === 'true' || process.env.NX_CRYSTAL === 'true'; + } + // should be on by default + return !( + process.env.NX_PCV3 === 'false' || process.env.NX_CRYSTAL === 'false' + ); +} + function tryGetXmlDocument(file: string): XmlDocument | null { try { return new XmlDocument(readFileSync(file).toString()); diff --git a/smoke/core/tests/nx-dotnet.spec.ts b/smoke/core/tests/nx-dotnet.spec.ts index 0e085032..f1c888fc 100644 --- a/smoke/core/tests/nx-dotnet.spec.ts +++ b/smoke/core/tests/nx-dotnet.spec.ts @@ -41,26 +41,29 @@ function execAsync(command: string, opts: ExecOptions): Promise { } describe('nx-dotnet smoke', () => { - beforeAll(async () => { - ({ name: smokeDirectory, removeCallback: cleanup } = dirSync({ - unsafeCleanup: true, - })); - - await execAsync( - 'npx create-nx-workspace@latest test --preset ts --nxCloud false', - { - cwd: smokeDirectory, - env: process.env, - }, - ); - - await execAsync('git init', await execAsyncOptions()); - - await execAsync( - 'npm i --save-dev @nx-dotnet/core', - await execAsyncOptions(), - ); - }, 20 * 60 * 1000); // 20 minutes + beforeAll( + async () => { + ({ name: smokeDirectory, removeCallback: cleanup } = dirSync({ + unsafeCleanup: true, + })); + + await execAsync( + 'npx create-nx-workspace@latest test --preset ts --nxCloud skip', + { + cwd: smokeDirectory, + env: process.env, + }, + ); + + await execAsync('git init', await execAsyncOptions()); + + await execAsync( + 'npm i --save-dev @nx-dotnet/core', + await execAsyncOptions(), + ); + }, + 20 * 60 * 1000, + ); // 20 minutes afterAll(async () => { cleanup(); diff --git a/tools/scripts/local-registry/setup.ts b/tools/scripts/local-registry/setup.ts index 2eee5dab..9fdf83c3 100644 --- a/tools/scripts/local-registry/setup.ts +++ b/tools/scripts/local-registry/setup.ts @@ -49,3 +49,7 @@ export function killVerdaccioInstance() { process.on('SIGINT', () => { killVerdaccioInstance(); }); + +if (require.main === module) { + startCleanVerdaccioInstance(); +} diff --git a/tools/scripts/publish-dev/index.ts b/tools/scripts/publish-dev/index.ts index cf382e19..779cf105 100644 --- a/tools/scripts/publish-dev/index.ts +++ b/tools/scripts/publish-dev/index.ts @@ -3,7 +3,7 @@ import { publishAll } from '../publish-all'; import * as parser from 'yargs-parser'; -export function main(version: string) { +export async function main(version: string) { const rootPkg = readJson('package.json'); const [next, tagSpec]: [string, string | null] = rootPkg.version.startsWith( version, @@ -15,7 +15,7 @@ export function main(version: string) { rev = rev === 'NaN' ? '0' : rev; const newVersion = `${next}-${tag}.${rev}`; - publishAll(newVersion, tag); + return publishAll(newVersion, tag); } if (require.main === module) { @@ -27,5 +27,7 @@ if (require.main === module) { if (!version) { throw new Error('Version is required'); } - main(version); + main(version) + .then(() => process.exit(0)) + .catch(() => process.exit(1)); } diff --git a/tools/scripts/sandbox.ts b/tools/scripts/sandbox.ts index 0dec7bcd..5080dcab 100644 --- a/tools/scripts/sandbox.ts +++ b/tools/scripts/sandbox.ts @@ -12,11 +12,13 @@ import { startCleanVerdaccioInstance } from './local-registry/setup'; const sandboxDirectory = join(__dirname, '../../tmp/sandbox'); -export function setup() { +export async function setup() { copySync('.npmrc.local', '.npmrc'); try { - startCleanVerdaccioInstance(); - } catch { + await startCleanVerdaccioInstance(); + } catch (E) { + throw E; + // Its ok. } execSync('ts-node ./tools/scripts/publish-all 99.99.99 local', { @@ -29,28 +31,29 @@ export function setup() { } if (require.main === module) { - setup(); - if (existsSync(sandboxDirectory)) { - removeSync(sandboxDirectory); - } - ensureDirSync(dirname(sandboxDirectory)); - execSync( - `npx create-nx-workspace@latest ${basename( - sandboxDirectory, - )} --preset empty --no-nxCloud --packageManager yarn`, - { - cwd: dirname(sandboxDirectory), - stdio: 'inherit', - }, - ); - copySync('.npmrc.local', join(sandboxDirectory, '.npmrc')); - getWorkspacePackages() - .then((pkgs) => { - execSync(`yarn add --dev ${pkgs}`, { - cwd: sandboxDirectory, - stdio: 'inherit', + setup() + .then(() => { + if (existsSync(sandboxDirectory)) { + removeSync(sandboxDirectory); + } + ensureDirSync(dirname(sandboxDirectory)); + execSync( + `npx create-nx-workspace@latest ${basename( + sandboxDirectory, + )} --preset empty --no-nxCloud --packageManager yarn`, + { + cwd: dirname(sandboxDirectory), + stdio: 'inherit', + }, + ); + copySync('.npmrc.local', join(sandboxDirectory, '.npmrc')); + getWorkspacePackages().then((pkgs) => { + execSync(`yarn add --dev ${pkgs}`, { + cwd: sandboxDirectory, + stdio: 'inherit', + }); + console.log('Sandbox created at', resolve(sandboxDirectory)); }); - console.log('Sandbox created at', resolve(sandboxDirectory)); }) .catch((err) => { console.error(err); From 84f35f133e35b1aa60b66d183bf8a3b50db6517a Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 31 Jan 2024 22:32:26 +0000 Subject: [PATCH 5/5] release: 2.2.0 [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # [2.2.0](https://github.com/nx-dotnet/nx-dotnet/compare/v2.1.2...v2.2.0) (2024-01-31) ### Bug Fixes * **core:** remove restriction of configuration ([#823](https://github.com/nx-dotnet/nx-dotnet/issues/823)) ([49b341f](https://github.com/nx-dotnet/nx-dotnet/commit/49b341ff81fde6f815f4a75f06d552907a79b8ae)) * **dotnet:** prevent "false" being incorrectly passed to dotnet command ([#818](https://github.com/nx-dotnet/nx-dotnet/issues/818)) ([0945571](https://github.com/nx-dotnet/nx-dotnet/commit/0945571169dac0df375d1381daa36bee46e14647)) ### Features * add options to sync the `gh-pages` branch with the base branch … ([#815](https://github.com/nx-dotnet/nx-dotnet/issues/815)) ([d9fff67](https://github.com/nx-dotnet/nx-dotnet/commit/d9fff6795b26df42bde5198d2d5cb2f8a1e527bf)) * **core:** update inference configuration ([#822](https://github.com/nx-dotnet/nx-dotnet/issues/822)) ([6085c50](https://github.com/nx-dotnet/nx-dotnet/commit/6085c500dd17612217334d20a6b53786d8896396)) Jan 31, 2024, 10:32 PM --- CHANGELOG.md | 12 ++++++++++++ package.json | 2 +- packages/core/package.json | 6 +++--- packages/dotnet/package.json | 4 ++-- packages/nx-ghpages/package.json | 2 +- packages/nxdoc/package.json | 2 +- packages/utils/package.json | 2 +- 7 files changed, 21 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a249aab..2c3121e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +# [2.2.0](https://github.com/nx-dotnet/nx-dotnet/compare/v2.1.2...v2.2.0) (2024-01-31) + +### Bug Fixes + +- **core:** remove restriction of configuration ([#823](https://github.com/nx-dotnet/nx-dotnet/issues/823)) ([49b341f](https://github.com/nx-dotnet/nx-dotnet/commit/49b341ff81fde6f815f4a75f06d552907a79b8ae)) +- **dotnet:** prevent "false" being incorrectly passed to dotnet command ([#818](https://github.com/nx-dotnet/nx-dotnet/issues/818)) ([0945571](https://github.com/nx-dotnet/nx-dotnet/commit/0945571169dac0df375d1381daa36bee46e14647)) + +### Features + +- add options to sync the `gh-pages` branch with the base branch … ([#815](https://github.com/nx-dotnet/nx-dotnet/issues/815)) ([d9fff67](https://github.com/nx-dotnet/nx-dotnet/commit/d9fff6795b26df42bde5198d2d5cb2f8a1e527bf)) +- **core:** update inference configuration ([#822](https://github.com/nx-dotnet/nx-dotnet/issues/822)) ([6085c50](https://github.com/nx-dotnet/nx-dotnet/commit/6085c500dd17612217334d20a6b53786d8896396)) + ## [2.1.2](https://github.com/nx-dotnet/nx-dotnet/compare/v2.1.1...v2.1.2) (2023-11-29) ### Bug Fixes diff --git a/package.json b/package.json index 5d8b2cd8..0f6647d1 100644 --- a/package.json +++ b/package.json @@ -139,5 +139,5 @@ "type": "git", "url": "https://github.com/nx-dotnet/nx-dotnet.git" }, - "version": "2.1.2" + "version": "2.2.0" } diff --git a/packages/core/package.json b/packages/core/package.json index a3ad5ed7..7c68c18f 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -9,8 +9,8 @@ }, "dependencies": { "@nx/devkit": "17.0.2", - "@nx-dotnet/dotnet": "2.1.2", - "@nx-dotnet/utils": "2.1.2", + "@nx-dotnet/dotnet": "2.2.0", + "@nx-dotnet/utils": "2.2.0", "fast-glob": "3.2.12", "inquirer": "^8.2.0", "semver": "7.5.4", @@ -70,5 +70,5 @@ "@nx-dotnet/dotnet" ] }, - "version": "2.1.2" + "version": "2.2.0" } diff --git a/packages/dotnet/package.json b/packages/dotnet/package.json index 42a09cd7..e84e4b28 100644 --- a/packages/dotnet/package.json +++ b/packages/dotnet/package.json @@ -3,7 +3,7 @@ "private": false, "main": "src/index.js", "dependencies": { - "@nx-dotnet/utils": "2.1.2", + "@nx-dotnet/utils": "2.2.0", "semver": "7.5.4", "tslib": "^2.5.0" }, @@ -24,5 +24,5 @@ "url": "https://github.com/nx-dotnet/nx-dotnet" }, "homepage": "https://nx-dotnet.com/", - "version": "2.1.2" + "version": "2.2.0" } diff --git a/packages/nx-ghpages/package.json b/packages/nx-ghpages/package.json index 5c46ee8a..c68b373f 100644 --- a/packages/nx-ghpages/package.json +++ b/packages/nx-ghpages/package.json @@ -24,5 +24,5 @@ "url": "https://github.com/nx-dotnet/nx-dotnet" }, "homepage": "https://nx-dotnet.com/", - "version": "2.1.2" + "version": "2.2.0" } diff --git a/packages/nxdoc/package.json b/packages/nxdoc/package.json index 541ed871..6c7aa0e4 100644 --- a/packages/nxdoc/package.json +++ b/packages/nxdoc/package.json @@ -29,5 +29,5 @@ "tslib": "^2.5.0" }, "peerDependencies": {}, - "version": "2.1.2" + "version": "2.2.0" } diff --git a/packages/utils/package.json b/packages/utils/package.json index b4e7f3b0..24aea196 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -32,5 +32,5 @@ "url": "https://github.com/nx-dotnet/nx-dotnet" }, "homepage": "https://nx-dotnet.com/", - "version": "2.1.2" + "version": "2.2.0" }