diff --git a/e2e/nx-flutter-e2e/tests/create-nx-flutter.spec.ts b/e2e/nx-flutter-e2e/tests/create-nx-flutter.spec.ts index e7479eb8..646963e5 100644 --- a/e2e/nx-flutter-e2e/tests/create-nx-flutter.spec.ts +++ b/e2e/nx-flutter-e2e/tests/create-nx-flutter.spec.ts @@ -24,7 +24,7 @@ describe('create-nx-flutter', () => { `('should be installed with Nx Wrapper=$useNxWrapper', ({ useNxWrapper }) => { projectDirectory = createCLITestProject( 'create-nx-flutter', - `--prjName=flutapp --useNxWrapper=${useNxWrapper} --nxCloud=skip --useGitHub=false --no-interactive` + `--directory=flutapp --useNxWrapper=${useNxWrapper} --nxCloud=skip --useGitHub=false --no-interactive` ); // npm ls will fail if the package is not installed properly diff --git a/e2e/nx-flutter-e2e/tests/nx-flutter.spec.ts b/e2e/nx-flutter-e2e/tests/nx-flutter.spec.ts index a60f5e0a..d2cacdf5 100644 --- a/e2e/nx-flutter-e2e/tests/nx-flutter.spec.ts +++ b/e2e/nx-flutter-e2e/tests/nx-flutter.spec.ts @@ -1,12 +1,16 @@ +import { uniq } from '@nx/plugin/testing'; import { - uniq, -} from '@nx/plugin/testing'; -import { checkFilesExist, createTestProject, readJson, runNxCommandAsync } from '@nxrocks/common/testing'; + checkFilesExist, + createTestProject, + readJson, + runNxCommandAsync, +} from '@nxrocks/common/testing'; import { execSync } from 'child_process'; import { rmSync } from 'fs-extra'; //jest.mock('enquirer'); // we mock 'enquirer' to bypass the interactive prompt import * as enquirer from 'enquirer'; +import { getPackageManagerCommand } from '@nx/devkit'; describe('nx-flutter e2e', () => { let projectDirectory: string; @@ -16,24 +20,28 @@ describe('nx-flutter e2e', () => { // The plugin has been built and published to a local registry in the jest globalSetup // Install the plugin built with the latest source code into the test repo - execSync(`npm install @nxrocks/nx-flutter@0.0.0-e2e`, { - cwd: projectDirectory, - stdio: 'inherit', - env: process.env, - }); + execSync( + `${getPackageManagerCommand().addDev} @nxrocks/nx-flutter@0.0.0-e2e`, + { + cwd: projectDirectory, + stdio: 'inherit', + env: process.env, + } + ); }); afterAll(() => { // Cleanup the test project - projectDirectory && rmSync(projectDirectory, { - recursive: true, - force: true, - }); + projectDirectory && + rmSync(projectDirectory, { + recursive: true, + force: true, + }); }); it('should be installed', () => { // npm ls will fail if the package is not installed properly - execSync('npm ls @nxrocks/nx-flutter', { + execSync(`${getPackageManagerCommand().list} @nxrocks/nx-flutter`, { cwd: projectDirectory, stdio: 'inherit', }); diff --git a/e2e/nx-ktor-e2e/tests/create-nx-ktor.spec.ts b/e2e/nx-ktor-e2e/tests/create-nx-ktor.spec.ts index 7657ae53..167b34ba 100644 --- a/e2e/nx-ktor-e2e/tests/create-nx-ktor.spec.ts +++ b/e2e/nx-ktor-e2e/tests/create-nx-ktor.spec.ts @@ -24,7 +24,7 @@ describe('create-nx-ktor', () => { `('should be installed with Nx Wrapper=$useNxWrapper', ({ useNxWrapper }) => { projectDirectory = createCLITestProject( 'create-nx-ktor', - `--prjName=bootapp --useNxWrapper=${useNxWrapper} --nxCloud=skip --useGitHub=false --no-interactive --verbose=true` + `--directory=ktapp --useNxWrapper=${useNxWrapper} --nxCloud=skip --useGitHub=false --no-interactive --verbose=true` ); // npm ls will fail if the package is not installed properly diff --git a/e2e/nx-ktor-e2e/tests/nx-ktor.spec.ts b/e2e/nx-ktor-e2e/tests/nx-ktor.spec.ts index 7eb7a4fd..fd5e19b3 100644 --- a/e2e/nx-ktor-e2e/tests/nx-ktor.spec.ts +++ b/e2e/nx-ktor-e2e/tests/nx-ktor.spec.ts @@ -21,7 +21,7 @@ describe('nx-ktor e2e', () => { // The plugin has been built and published to a local registry in the jest globalSetup // Install the plugin built with the latest source code into the test repo execSync( - `${getPackageManagerCommand().install} @nxrocks/nx-ktor@0.0.0-e2e`, + `${getPackageManagerCommand().addDev} @nxrocks/nx-ktor@0.0.0-e2e`, { cwd: projectDirectory, stdio: 'inherit', diff --git a/e2e/nx-melos-e2e/tests/nx-melos.spec.ts b/e2e/nx-melos-e2e/tests/nx-melos.spec.ts index 8e27cd86..764f9661 100644 --- a/e2e/nx-melos-e2e/tests/nx-melos.spec.ts +++ b/e2e/nx-melos-e2e/tests/nx-melos.spec.ts @@ -16,7 +16,7 @@ describe('nx-melos e2e', () => { // The plugin has been built and published to a local registry in the jest globalSetup // Install the plugin built with the latest source code into the test repo execSync( - `${getPackageManagerCommand().install} @nxrocks/nx-melos@0.0.0-e2e`, + `${getPackageManagerCommand().addDev} @nxrocks/nx-melos@0.0.0-e2e`, { cwd: projectDirectory, stdio: 'inherit', diff --git a/e2e/nx-micronaut-e2e/tests/create-nx-micronaut.spec.ts b/e2e/nx-micronaut-e2e/tests/create-nx-micronaut.spec.ts index 437c05f1..c8e5802c 100644 --- a/e2e/nx-micronaut-e2e/tests/create-nx-micronaut.spec.ts +++ b/e2e/nx-micronaut-e2e/tests/create-nx-micronaut.spec.ts @@ -24,7 +24,7 @@ describe('create-nx-micronaut', () => { `('should be installed with Nx Wrapper=$useNxWrapper', ({ useNxWrapper }) => { projectDirectory = createCLITestProject( 'create-nx-micronaut', - `--prjName=bootapp --useNxWrapper=${useNxWrapper} --nxCloud=skip --useGitHub=false --no-interactive` + `--directory=mnapp --useNxWrapper=${useNxWrapper} --nxCloud=skip --useGitHub=false --no-interactive` ); // npm ls will fail if the package is not installed properly diff --git a/e2e/nx-micronaut-e2e/tests/nx-micronaut.spec.ts b/e2e/nx-micronaut-e2e/tests/nx-micronaut.spec.ts index d930efd5..521eb743 100644 --- a/e2e/nx-micronaut-e2e/tests/nx-micronaut.spec.ts +++ b/e2e/nx-micronaut-e2e/tests/nx-micronaut.spec.ts @@ -22,7 +22,7 @@ describe('nx-micronaut e2e', () => { // The plugin has been built and published to a local registry in the jest globalSetup // Install the plugin built with the latest source code into the test repo execSync( - `${getPackageManagerCommand().install} @nxrocks/nx-micronaut@0.0.0-e2e`, + `${getPackageManagerCommand().addDev} @nxrocks/nx-micronaut@0.0.0-e2e`, { cwd: projectDirectory, stdio: 'inherit', diff --git a/e2e/nx-quarkus-e2e/tests/create-nx-quarkus.spec.ts b/e2e/nx-quarkus-e2e/tests/create-nx-quarkus.spec.ts index c57c50a4..f0ad2e26 100644 --- a/e2e/nx-quarkus-e2e/tests/create-nx-quarkus.spec.ts +++ b/e2e/nx-quarkus-e2e/tests/create-nx-quarkus.spec.ts @@ -24,7 +24,7 @@ describe('create-nx-quarkus', () => { `('should be installed with Nx Wrapper=$useNxWrapper', ({ useNxWrapper }) => { projectDirectory = createCLITestProject( 'create-nx-quarkus', - `--prjName=bootapp --useNxWrapper=${useNxWrapper} --nxCloud=skip --useGitHub=false --no-interactive` + `--directory=qkapp --useNxWrapper=${useNxWrapper} --nxCloud=skip --useGitHub=false --no-interactive` ); // npm ls will fail if the package is not installed properly diff --git a/e2e/nx-quarkus-e2e/tests/nx-quarkus.spec.ts b/e2e/nx-quarkus-e2e/tests/nx-quarkus.spec.ts index 68f0b4dc..f256a571 100644 --- a/e2e/nx-quarkus-e2e/tests/nx-quarkus.spec.ts +++ b/e2e/nx-quarkus-e2e/tests/nx-quarkus.spec.ts @@ -23,7 +23,7 @@ describe('nx-quarkus e2e', () => { // The plugin has been built and published to a local registry in the jest globalSetup // Install the plugin built with the latest source code into the test repo execSync( - `${getPackageManagerCommand().add} @nxrocks/nx-quarkus@0.0.0-e2e`, + `${getPackageManagerCommand().addDev} @nxrocks/nx-quarkus@0.0.0-e2e`, { cwd: projectDirectory, stdio: 'inherit', diff --git a/e2e/nx-spring-boot-e2e/tests/create-nx-spring-boot.spec.ts b/e2e/nx-spring-boot-e2e/tests/create-nx-spring-boot.spec.ts index c7999888..9a02f4b7 100644 --- a/e2e/nx-spring-boot-e2e/tests/create-nx-spring-boot.spec.ts +++ b/e2e/nx-spring-boot-e2e/tests/create-nx-spring-boot.spec.ts @@ -24,7 +24,7 @@ describe('create-nx-spring-boot', () => { `('should be installed with Nx Wrapper=$useNxWrapper', ({ useNxWrapper }) => { projectDirectory = createCLITestProject( 'create-nx-spring-boot', - `--prjName=bootapp --useNxWrapper=${useNxWrapper} --nxCloud=skip --useGitHub=false --no-interactive` + `--directory=bootapp --useNxWrapper=${useNxWrapper} --nxCloud=skip --useGitHub=false --no-interactive` ); // npm ls will fail if the package is not installed properly diff --git a/e2e/nx-spring-boot-e2e/tests/nx-spring-boot.spec.ts b/e2e/nx-spring-boot-e2e/tests/nx-spring-boot.spec.ts index 5d1b9623..f8431762 100644 --- a/e2e/nx-spring-boot-e2e/tests/nx-spring-boot.spec.ts +++ b/e2e/nx-spring-boot-e2e/tests/nx-spring-boot.spec.ts @@ -23,7 +23,7 @@ describe('nx-spring-boot e2e', () => { // The plugin has been built and published to a local registry in the jest globalSetup // Install the plugin built with the latest source code into the test repo execSync( - `${getPackageManagerCommand().install} @nxrocks/nx-spring-boot@0.0.0-e2e`, + `${getPackageManagerCommand().addDev} @nxrocks/nx-spring-boot@0.0.0-e2e`, { cwd: projectDirectory, stdio: 'inherit', diff --git a/packages/common-cli/src/lib/main.ts b/packages/common-cli/src/lib/main.ts index 016548fe..140ef6ac 100644 --- a/packages/common-cli/src/lib/main.ts +++ b/packages/common-cli/src/lib/main.ts @@ -17,10 +17,7 @@ import { createWorkspaceWithNxWrapper, getNxCommand, } from './utils'; - -// change type to ('yes' | 'github' | 'gitlab' | 'azure' | 'bitbucket-pipelines' | 'circleci' | 'skip'); -// and uncomment below prompt options, once https://github.com/nrwl/nx/pull/29008 is merged -export type NxCloud = 'yes' | 'github' | 'circleci' | 'skip'; +import { NxCloud } from 'create-nx-workspace/src/utils/nx/nx-cloud'; export async function mainCLI(pkgName: string, stackName: string) { const pkgFolderName = pkgName.replace('@nxrocks/', ''); diff --git a/packages/common-cli/src/lib/models.ts b/packages/common-cli/src/lib/models.ts index 43c520c0..d53eb0f3 100644 --- a/packages/common-cli/src/lib/models.ts +++ b/packages/common-cli/src/lib/models.ts @@ -1,13 +1,8 @@ import { CreateWorkspaceOptions } from 'create-nx-workspace'; - export interface CLIArguments extends CreateWorkspaceOptions { - name: string; - useNxWrapper?: boolean; - nxCloud: 'yes' | 'github' | 'circleci' | 'skip'; - interactive: boolean; - verbose: boolean; - $0?: string; - _?: string[] - } - \ No newline at end of file + useNxWrapper?: boolean; + verbose: boolean; + $0?: string; + _?: string[]; +} diff --git a/packages/nx-flutter/src/generators/preset/generator.spec.ts b/packages/nx-flutter/src/generators/preset/generator.spec.ts index 1dd4bfe5..e5e7358d 100644 --- a/packages/nx-flutter/src/generators/preset/generator.spec.ts +++ b/packages/nx-flutter/src/generators/preset/generator.spec.ts @@ -15,7 +15,7 @@ describe('preset generator', () => { let tree: Tree; const options: PresetGeneratorSchema = { directory: 'testapp', - prjName: 'testapp', + name: 'testapp', template: 'app', }; diff --git a/packages/nx-flutter/src/generators/preset/generator.ts b/packages/nx-flutter/src/generators/preset/generator.ts index 81d861f6..37cb645e 100644 --- a/packages/nx-flutter/src/generators/preset/generator.ts +++ b/packages/nx-flutter/src/generators/preset/generator.ts @@ -1,6 +1,4 @@ -import { - Tree, -} from '@nx/devkit'; +import { Tree } from '@nx/devkit'; import { PresetGeneratorSchema } from './schema'; import projectGenerator from '../project/generator'; @@ -8,11 +6,9 @@ export async function presetGenerator( tree: Tree, options: PresetGeneratorSchema ) { - const { prjName } = options; - await projectGenerator(tree, { ...options, - name: prjName + directory: options.directory ?? options.name, }); } diff --git a/packages/nx-flutter/src/generators/preset/schema.d.ts b/packages/nx-flutter/src/generators/preset/schema.d.ts index 7b815285..7bcfa6af 100644 --- a/packages/nx-flutter/src/generators/preset/schema.d.ts +++ b/packages/nx-flutter/src/generators/preset/schema.d.ts @@ -1,6 +1,3 @@ import { ProjectGeneratorOptions } from '../project/schema'; -export interface PresetGeneratorSchema - extends Omit { - prjName?: string; // we cannot use "projectName" nor "name" because they have special meanings in Nx -} +export type PresetGeneratorSchema = ProjectGeneratorOptions; diff --git a/packages/nx-flutter/src/generators/preset/schema.json b/packages/nx-flutter/src/generators/preset/schema.json index a0f99bfa..8b8901d8 100644 --- a/packages/nx-flutter/src/generators/preset/schema.json +++ b/packages/nx-flutter/src/generators/preset/schema.json @@ -6,23 +6,24 @@ "cli": "nx", "outputCapture": "pipe", "properties": { - "prjName": { - "type": "string", - "description": "Name of the project to generate.", - "x-prompt": "What is the name of your project?", - "pattern": "^[a-zA-Z][^:]*$", - "x-priority": "important" - }, "directory": { "type": "string", "description": "The directory of the new project.", - "alias": "d", + "alias": "dir", "$default": { "$source": "argv", "index": 0 }, "x-prompt": "Which directory do you want to create the project in?" }, + "name": { + "type": "string", + "description": "Name of the project to generate.", + "alias": "projectName", + "x-prompt": "What name would you like to use?", + "pattern": "^[a-zA-Z][^:]*$", + "x-priority": "important" + }, "org": { "description": "name of the ", "type": "string", @@ -123,5 +124,5 @@ "description": "Whether or not to overwrite existing files when performing operations." } }, - "required": ["prjName", "directory"] + "required": ["directory"] } diff --git a/packages/nx-flutter/src/generators/project/schema.json b/packages/nx-flutter/src/generators/project/schema.json index 206eeac5..cd21f9bc 100644 --- a/packages/nx-flutter/src/generators/project/schema.json +++ b/packages/nx-flutter/src/generators/project/schema.json @@ -9,7 +9,7 @@ "directory": { "type": "string", "description": "The directory of the new project.", - "alias": "d", + "alias": "dir", "$default": { "$source": "argv", "index": 0 diff --git a/packages/nx-ktor/src/generators/preset/generator.spec.ts b/packages/nx-ktor/src/generators/preset/generator.spec.ts index 92ee3711..40233561 100644 --- a/packages/nx-ktor/src/generators/preset/generator.spec.ts +++ b/packages/nx-ktor/src/generators/preset/generator.spec.ts @@ -19,7 +19,7 @@ describe('preset generator', () => { let tree: Tree; const options: PresetGeneratorSchema = { directory: 'ktapp', - prjName: 'ktapp', + name: 'ktapp', groupId: 'com.tinesoft', artifactId: 'ktapp', buildSystem: 'MAVEN', diff --git a/packages/nx-ktor/src/generators/preset/generator.ts b/packages/nx-ktor/src/generators/preset/generator.ts index 81d861f6..37cb645e 100644 --- a/packages/nx-ktor/src/generators/preset/generator.ts +++ b/packages/nx-ktor/src/generators/preset/generator.ts @@ -1,6 +1,4 @@ -import { - Tree, -} from '@nx/devkit'; +import { Tree } from '@nx/devkit'; import { PresetGeneratorSchema } from './schema'; import projectGenerator from '../project/generator'; @@ -8,11 +6,9 @@ export async function presetGenerator( tree: Tree, options: PresetGeneratorSchema ) { - const { prjName } = options; - await projectGenerator(tree, { ...options, - name: prjName + directory: options.directory ?? options.name, }); } diff --git a/packages/nx-ktor/src/generators/preset/schema.d.ts b/packages/nx-ktor/src/generators/preset/schema.d.ts index 7b815285..7bcfa6af 100644 --- a/packages/nx-ktor/src/generators/preset/schema.d.ts +++ b/packages/nx-ktor/src/generators/preset/schema.d.ts @@ -1,6 +1,3 @@ import { ProjectGeneratorOptions } from '../project/schema'; -export interface PresetGeneratorSchema - extends Omit { - prjName?: string; // we cannot use "projectName" nor "name" because they have special meanings in Nx -} +export type PresetGeneratorSchema = ProjectGeneratorOptions; diff --git a/packages/nx-ktor/src/generators/preset/schema.json b/packages/nx-ktor/src/generators/preset/schema.json index e460a95c..f7768e77 100644 --- a/packages/nx-ktor/src/generators/preset/schema.json +++ b/packages/nx-ktor/src/generators/preset/schema.json @@ -6,23 +6,24 @@ "cli": "nx", "outputCapture": "pipe", "properties": { - "prjName": { - "type": "string", - "description": "Name of the project to generate.", - "x-prompt": "What is the name of your project?", - "pattern": "^[a-zA-Z][^:]*$", - "x-priority": "important" - }, "directory": { "type": "string", "description": "The directory of the new project.", - "alias": "d", + "alias": "dir", "$default": { "$source": "argv", "index": 0 }, "x-prompt": "Which directory do you want to create the project in?" }, + "name": { + "type": "string", + "description": "Name of the project to generate.", + "alias": "projectName", + "x-prompt": "What name would you like to use?", + "pattern": "^[a-zA-Z][^:]*$", + "x-priority": "important" + }, "ktorVersion": { "description": "Ktor version.", "type": "string", @@ -183,5 +184,5 @@ "enum": ["as-provided", "derived"] } }, - "required": ["prjName", "directory"] + "required": ["directory"] } diff --git a/packages/nx-ktor/src/generators/project/schema.json b/packages/nx-ktor/src/generators/project/schema.json index 9505ab92..4ed0b645 100644 --- a/packages/nx-ktor/src/generators/project/schema.json +++ b/packages/nx-ktor/src/generators/project/schema.json @@ -9,7 +9,7 @@ "directory": { "type": "string", "description": "The directory of the new project.", - "alias": "d", + "alias": "dir", "$default": { "$source": "argv", "index": 0 diff --git a/packages/nx-micronaut/src/generators/preset/generator.spec.ts b/packages/nx-micronaut/src/generators/preset/generator.spec.ts index 4f7eae9b..c014d252 100644 --- a/packages/nx-micronaut/src/generators/preset/generator.spec.ts +++ b/packages/nx-micronaut/src/generators/preset/generator.spec.ts @@ -19,7 +19,7 @@ describe('preset generator', () => { let tree: Tree; const options: PresetGeneratorSchema = { directory: 'mnapp', - prjName: 'mnapp', + name: 'mnapp', projectType: 'default', basePackage: 'com.tinesoft', buildSystem: 'MAVEN', diff --git a/packages/nx-micronaut/src/generators/preset/generator.ts b/packages/nx-micronaut/src/generators/preset/generator.ts index 81d861f6..37cb645e 100644 --- a/packages/nx-micronaut/src/generators/preset/generator.ts +++ b/packages/nx-micronaut/src/generators/preset/generator.ts @@ -1,6 +1,4 @@ -import { - Tree, -} from '@nx/devkit'; +import { Tree } from '@nx/devkit'; import { PresetGeneratorSchema } from './schema'; import projectGenerator from '../project/generator'; @@ -8,11 +6,9 @@ export async function presetGenerator( tree: Tree, options: PresetGeneratorSchema ) { - const { prjName } = options; - await projectGenerator(tree, { ...options, - name: prjName + directory: options.directory ?? options.name, }); } diff --git a/packages/nx-micronaut/src/generators/preset/schema.d.ts b/packages/nx-micronaut/src/generators/preset/schema.d.ts index 7b815285..7bcfa6af 100644 --- a/packages/nx-micronaut/src/generators/preset/schema.d.ts +++ b/packages/nx-micronaut/src/generators/preset/schema.d.ts @@ -1,6 +1,3 @@ import { ProjectGeneratorOptions } from '../project/schema'; -export interface PresetGeneratorSchema - extends Omit { - prjName?: string; // we cannot use "projectName" nor "name" because they have special meanings in Nx -} +export type PresetGeneratorSchema = ProjectGeneratorOptions; diff --git a/packages/nx-micronaut/src/generators/preset/schema.json b/packages/nx-micronaut/src/generators/preset/schema.json index a4c633c4..707824d9 100644 --- a/packages/nx-micronaut/src/generators/preset/schema.json +++ b/packages/nx-micronaut/src/generators/preset/schema.json @@ -6,23 +6,24 @@ "cli": "nx", "outputCapture": "pipe", "properties": { - "prjName": { - "type": "string", - "description": "Name of the project to generate.", - "x-prompt": "What is the name of your project?", - "pattern": "^[a-zA-Z][^:]*$", - "x-priority": "important" - }, "directory": { "type": "string", "description": "The directory of the new project.", - "alias": "d", + "alias": "dir", "$default": { "$source": "argv", "index": 0 }, "x-prompt": "Which directory do you want to create the project in?" }, + "name": { + "type": "string", + "description": "Name of the project to generate.", + "alias": "projectName", + "x-prompt": "What name would you like to use?", + "pattern": "^[a-zA-Z][^:]*$", + "x-priority": "important" + }, "projectType": { "description": "Type of application.", "default": "default", @@ -240,5 +241,5 @@ "enum": ["as-provided", "derived"] } }, - "required": ["prjName", "projectType", "directory"] + "required": ["projectType", "directory"] } diff --git a/packages/nx-micronaut/src/generators/project/schema.json b/packages/nx-micronaut/src/generators/project/schema.json index b1073a91..63d32ad3 100644 --- a/packages/nx-micronaut/src/generators/project/schema.json +++ b/packages/nx-micronaut/src/generators/project/schema.json @@ -9,7 +9,7 @@ "directory": { "type": "string", "description": "The directory of the new project.", - "alias": "d", + "alias": "dir", "$default": { "$source": "argv", "index": 0 diff --git a/packages/nx-quarkus/src/generators/preset/generator.spec.ts b/packages/nx-quarkus/src/generators/preset/generator.spec.ts index 135f6b04..babcbde5 100644 --- a/packages/nx-quarkus/src/generators/preset/generator.spec.ts +++ b/packages/nx-quarkus/src/generators/preset/generator.spec.ts @@ -19,7 +19,7 @@ describe('preset generator', () => { let tree: Tree; const options: PresetGeneratorSchema = { directory: 'quarkusapp', - prjName: 'quarkusapp', + name: 'quarkusapp', projectType: 'application', groupId: 'com.tinesoft', artifactId: 'demo', diff --git a/packages/nx-quarkus/src/generators/preset/generator.ts b/packages/nx-quarkus/src/generators/preset/generator.ts index 81d861f6..37cb645e 100644 --- a/packages/nx-quarkus/src/generators/preset/generator.ts +++ b/packages/nx-quarkus/src/generators/preset/generator.ts @@ -1,6 +1,4 @@ -import { - Tree, -} from '@nx/devkit'; +import { Tree } from '@nx/devkit'; import { PresetGeneratorSchema } from './schema'; import projectGenerator from '../project/generator'; @@ -8,11 +6,9 @@ export async function presetGenerator( tree: Tree, options: PresetGeneratorSchema ) { - const { prjName } = options; - await projectGenerator(tree, { ...options, - name: prjName + directory: options.directory ?? options.name, }); } diff --git a/packages/nx-quarkus/src/generators/preset/schema.d.ts b/packages/nx-quarkus/src/generators/preset/schema.d.ts index 7b815285..7bcfa6af 100644 --- a/packages/nx-quarkus/src/generators/preset/schema.d.ts +++ b/packages/nx-quarkus/src/generators/preset/schema.d.ts @@ -1,6 +1,3 @@ import { ProjectGeneratorOptions } from '../project/schema'; -export interface PresetGeneratorSchema - extends Omit { - prjName?: string; // we cannot use "projectName" nor "name" because they have special meanings in Nx -} +export type PresetGeneratorSchema = ProjectGeneratorOptions; diff --git a/packages/nx-quarkus/src/generators/preset/schema.json b/packages/nx-quarkus/src/generators/preset/schema.json index ad9ba2a8..dccf3590 100644 --- a/packages/nx-quarkus/src/generators/preset/schema.json +++ b/packages/nx-quarkus/src/generators/preset/schema.json @@ -6,23 +6,24 @@ "cli": "nx", "outputCapture": "pipe", "properties": { - "prjName": { - "type": "string", - "description": "Name of the project to generate.", - "x-prompt": "What is the name of your project?", - "pattern": "^[a-zA-Z][^:]*$", - "x-priority": "important" - }, "directory": { "type": "string", "description": "The directory of the new project.", - "alias": "d", + "alias": "dir", "$default": { "$source": "argv", "index": 0 }, "x-prompt": "Which directory do you want to create the project in?" }, + "name": { + "type": "string", + "description": "Name of the project to generate.", + "alias": "projectName", + "x-prompt": "What name would you like to use?", + "pattern": "^[a-zA-Z][^:]*$", + "x-priority": "important" + }, "projectType": { "description": "Type of project.", "default": "application", @@ -173,5 +174,5 @@ "enum": ["as-provided", "derived"] } }, - "required": ["prjName", "projectType", "directory"] + "required": ["projectType", "directory"] } diff --git a/packages/nx-quarkus/src/generators/project/schema.json b/packages/nx-quarkus/src/generators/project/schema.json index 97059195..7800f06d 100644 --- a/packages/nx-quarkus/src/generators/project/schema.json +++ b/packages/nx-quarkus/src/generators/project/schema.json @@ -9,7 +9,7 @@ "directory": { "type": "string", "description": "The directory of the new project.", - "alias": "d", + "alias": "dir", "$default": { "$source": "argv", "index": 0 diff --git a/packages/nx-spring-boot/src/generators/preset/generator.spec.ts b/packages/nx-spring-boot/src/generators/preset/generator.spec.ts index db7713b2..593cdef4 100644 --- a/packages/nx-spring-boot/src/generators/preset/generator.spec.ts +++ b/packages/nx-spring-boot/src/generators/preset/generator.spec.ts @@ -19,7 +19,7 @@ describe('preset generator', () => { let tree: Tree; const options: PresetGeneratorSchema = { directory: 'bootapp', - prjName: 'bootapp', + name: 'bootapp', projectType: 'application', springInitializerUrl: DEFAULT_SPRING_INITIALIZR_URL, language: 'java', diff --git a/packages/nx-spring-boot/src/generators/preset/generator.ts b/packages/nx-spring-boot/src/generators/preset/generator.ts index e503a1d5..37cb645e 100644 --- a/packages/nx-spring-boot/src/generators/preset/generator.ts +++ b/packages/nx-spring-boot/src/generators/preset/generator.ts @@ -6,12 +6,9 @@ export async function presetGenerator( tree: Tree, options: PresetGeneratorSchema ) { - const { prjName } = options; - await projectGenerator(tree, { ...options, - name: prjName, - directory: options.directory ?? prjName, + directory: options.directory ?? options.name, }); } diff --git a/packages/nx-spring-boot/src/generators/preset/schema.d.ts b/packages/nx-spring-boot/src/generators/preset/schema.d.ts index 7b815285..7bcfa6af 100644 --- a/packages/nx-spring-boot/src/generators/preset/schema.d.ts +++ b/packages/nx-spring-boot/src/generators/preset/schema.d.ts @@ -1,6 +1,3 @@ import { ProjectGeneratorOptions } from '../project/schema'; -export interface PresetGeneratorSchema - extends Omit { - prjName?: string; // we cannot use "projectName" nor "name" because they have special meanings in Nx -} +export type PresetGeneratorSchema = ProjectGeneratorOptions; diff --git a/packages/nx-spring-boot/src/generators/preset/schema.json b/packages/nx-spring-boot/src/generators/preset/schema.json index aa9fb1d5..340e3937 100644 --- a/packages/nx-spring-boot/src/generators/preset/schema.json +++ b/packages/nx-spring-boot/src/generators/preset/schema.json @@ -15,23 +15,24 @@ ], "type": "object", "properties": { - "prjName": { - "type": "string", - "description": "Name of the project to generate.", - "x-prompt": "What is the name of your project?", - "pattern": "^[a-zA-Z][^:]*$", - "x-priority": "important" - }, "directory": { "type": "string", "description": "The directory of the new project.", - "alias": "d", + "alias": "dir", "$default": { "$source": "argv", "index": 0 }, "x-prompt": "Which directory do you want to create the project in?" }, + "name": { + "type": "string", + "description": "Name of the project to generate.", + "alias": "projectName", + "x-prompt": "What name would you like to use?", + "pattern": "^[a-zA-Z][^:]*$", + "x-priority": "important" + }, "projectType": { "description": "Type of project.", "default": "application", @@ -248,5 +249,5 @@ } }, "additionalProperties": true, - "required": ["prjName", "projectType", "required"] + "required": ["projectType", "required"] } diff --git a/packages/nx-spring-boot/src/generators/project/schema.json b/packages/nx-spring-boot/src/generators/project/schema.json index 3da45563..5c281020 100644 --- a/packages/nx-spring-boot/src/generators/project/schema.json +++ b/packages/nx-spring-boot/src/generators/project/schema.json @@ -9,7 +9,7 @@ "directory": { "type": "string", "description": "The directory of the new project.", - "alias": "d", + "alias": "dir", "$default": { "$source": "argv", "index": 0 diff --git a/tools/scripts/sync-preset-schemas.ts b/tools/scripts/sync-preset-schemas.ts index d21379d4..78bed384 100644 --- a/tools/scripts/sync-preset-schemas.ts +++ b/tools/scripts/sync-preset-schemas.ts @@ -1,8 +1,6 @@ import { logger, readJsonFile, workspaceRoot, writeJsonFile } from '@nx/devkit'; -import { execSync } from 'child_process'; import { existsSync, readdirSync } from 'fs'; import { join, resolve } from 'path'; -import { resolveModuleName } from 'typescript'; interface SchemaFile { properties: Record; @@ -18,34 +16,20 @@ const presetSchemaFiles = readdirSync(packagesRoot) join(packagesRoot, folder, '/src/generators/preset/schema.json') ); -const changedFiles = execSync('git diff --name-only') - .toString() - .trim() - .split(/\r?\n/); -const changedPresetSchemaFiles = changedFiles - .map((f) => join(workspaceRoot, f)) - .filter((f) => presetSchemaFiles.indexOf(f) != -1); - // Sync the the schema.json file of 'preset' generators with the related 'project' generator's -changedPresetSchemaFiles.forEach((presetSchemaFile) => { - - +presetSchemaFiles.forEach((presetSchemaFile) => { const presetSchemaJson = readJsonFile(presetSchemaFile); const projetSchemaJson = readJsonFile( join(presetSchemaFile, '../../project/schema.json') ); - delete projetSchemaJson.properties['name']; - const { prjName } = presetSchemaJson.properties; presetSchemaJson.properties = { - prjName, ...projetSchemaJson.properties, }; presetSchemaJson.required = [ - 'prjName', - ...projetSchemaJson.required.filter((p) => p !== 'name'), + ...projetSchemaJson.required, ]; writeJsonFile(presetSchemaFile, presetSchemaJson);