Skip to content

Commit

Permalink
feat(core): log to guide users to show details after project generati…
Browse files Browse the repository at this point in the history
…on (#21350)
  • Loading branch information
Coly010 authored Jan 30, 2024
1 parent 8a294b1 commit 0b3e1f6
Show file tree
Hide file tree
Showing 20 changed files with 123 additions and 5 deletions.
2 changes: 2 additions & 0 deletions packages/angular/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
updateEditorTsConfig,
} from './lib';
import type { Schema } from './schema';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';

export async function applicationGenerator(
tree: Tree,
Expand Down Expand Up @@ -103,6 +104,7 @@ export async function applicationGeneratorInternal(

return () => {
installPackagesTask(tree);
logShowProjectCommand(options.name);
};
}

Expand Down
2 changes: 2 additions & 0 deletions packages/angular/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { addProject } from './lib/add-project';
import { addJest } from '../utils/add-jest';
import { setGeneratorDefaults } from './lib/set-generator-defaults';
import { ensureAngularDependencies } from '../utils/ensure-angular-dependencies';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';

export async function libraryGenerator(
tree: Tree,
Expand Down Expand Up @@ -119,6 +120,7 @@ export async function libraryGeneratorInternal(

return () => {
installPackagesTask(tree);
logShowProjectCommand(libraryOptions.name);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
} from '../../utils/versions';
import { cypressInitGenerator } from '../init/init';
import { Schema } from './schema';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';

export interface CypressProjectSchema extends Schema {
projectName: string;
Expand Down Expand Up @@ -229,7 +230,14 @@ function ensureDependencies(tree: Tree, options: CypressProjectSchema) {
devDependencies['vite'] = viteVersion;
}

return addDependenciesToPackageJson(tree, {}, devDependencies);
return runTasksInSerial(
...[
addDependenciesToPackageJson(tree, {}, devDependencies),
() => {
logShowProjectCommand(options.projectName);
},
]
);
}

async function normalizeOptions(
Expand Down
11 changes: 11 additions & 0 deletions packages/devkit/src/utils/log-show-project-command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { requireNx } from '../../nx';

export function logShowProjectCommand(projectName: string): void {
const { output } = requireNx();
output.log({
title: `👀 View Details of ${projectName}`,
bodyLines: [
`Run "nx show project ${projectName} --web" to view details about this project.`,
],
});
}
5 changes: 5 additions & 0 deletions packages/expo/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { addDetox } from './lib/add-detox';
import { Schema } from './schema';
import { ensureDependencies } from '../../utils/ensure-dependencies';
import { initRootBabelConfig } from '../../utils/init-root-babel-config';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';

export async function expoApplicationGenerator(
host: Tree,
Expand Down Expand Up @@ -81,6 +82,10 @@ export async function expoApplicationGeneratorInternal(
await formatFiles(host);
}

tasks.push(() => {
logShowProjectCommand(options.projectName);
});

return runTasksInSerial(...tasks);
}

Expand Down
5 changes: 5 additions & 0 deletions packages/expo/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { Schema } from './schema';
import { ensureDependencies } from '../../utils/ensure-dependencies';
import { initRootBabelConfig } from '../../utils/init-root-babel-config';
import { addBuildTargetDefaults } from '@nx/devkit/src/generators/add-build-target-defaults';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';

export async function expoLibraryGenerator(
host: Tree,
Expand Down Expand Up @@ -113,6 +114,10 @@ export async function expoLibraryGeneratorInternal(
await formatFiles(host);
}

tasks.push(() => {
logShowProjectCommand(options.name);
});

return runTasksInSerial(...tasks);
}

Expand Down
5 changes: 5 additions & 0 deletions packages/js/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import jsInitGenerator from '../init/init';
import { type PackageJson } from 'nx/src/utils/package-json';
import setupVerdaccio from '../setup-verdaccio/generator';
import { tsConfigBaseOptions } from '../../utils/typescript/create-ts-config';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';

export async function libraryGenerator(
tree: Tree,
Expand Down Expand Up @@ -163,6 +164,10 @@ export async function libraryGeneratorInternal(
await formatFiles(tree);
}

tasks.push(() => {
logShowProjectCommand(options.name);
});

return runTasksInSerial(...tasks);
}

Expand Down
14 changes: 11 additions & 3 deletions packages/nest/src/generators/library/library.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { GeneratorCallback, Tree } from '@nx/devkit';
import { formatFiles } from '@nx/devkit';
import { formatFiles, runTasksInSerial } from '@nx/devkit';
import { libraryGenerator as jsLibraryGenerator } from '@nx/js';
import { addDependencies } from '../init/lib';
import {
Expand All @@ -13,6 +13,7 @@ import {
} from './lib';
import type { LibraryGeneratorOptions } from './schema';
import initGenerator from '../init/init';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';

export async function libraryGenerator(
tree: Tree,
Expand All @@ -30,7 +31,7 @@ export async function libraryGeneratorInternal(
): Promise<GeneratorCallback> {
const options = await normalizeOptions(tree, rawOptions);
await jsLibraryGenerator(tree, toJsLibraryGeneratorOptions(options));
const initTask = initGenerator(tree, rawOptions);
const initTask = await initGenerator(tree, rawOptions);
deleteFiles(tree, options);
createFiles(tree, options);
addExportsToBarrelFile(tree, options);
Expand All @@ -41,7 +42,14 @@ export async function libraryGeneratorInternal(
await formatFiles(tree);
}

return initTask;
return runTasksInSerial(
...[
initTask,
() => {
logShowProjectCommand(options.projectName);
},
]
);
}

export default libraryGenerator;
5 changes: 5 additions & 0 deletions packages/next/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { customServerGenerator } from '../custom-server/custom-server';
import { updateCypressTsConfig } from './lib/update-cypress-tsconfig';
import { showPossibleWarnings } from './lib/show-possible-warnings';
import { tsLibVersion } from '../../utils/versions';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';

export async function applicationGenerator(host: Tree, schema: Schema) {
return await applicationGeneratorInternal(host, {
Expand Down Expand Up @@ -108,5 +109,9 @@ export async function applicationGeneratorInternal(host: Tree, schema: Schema) {
await formatFiles(host);
}

tasks.push(() => {
logShowProjectCommand(options.projectName);
});

return runTasksInSerial(...tasks);
}
18 changes: 17 additions & 1 deletion packages/node/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { setupDockerGenerator } from '../setup-docker/setup-docker';
import { Schema } from './schema';
import { hasWebpackPlugin } from '../../utils/has-webpack-plugin';
import { addBuildTargetDefaults } from '@nx/devkit/src/generators/add-build-target-defaults';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';

export interface NormalizedSchema extends Schema {
appProjectRoot: string;
Expand Down Expand Up @@ -389,7 +390,18 @@ export async function applicationGeneratorInternal(tree: Tree, schema: Schema) {

if (options.framework === 'nest') {
const { applicationGenerator } = ensurePackage('@nx/nest', nxVersion);
return await applicationGenerator(tree, { ...options, skipFormat: true });
const nestTasks = await applicationGenerator(tree, {
...options,
skipFormat: true,
});
return runTasksInSerial(
...[
nestTasks,
() => {
logShowProjectCommand(options.name);
},
]
);
}

const jsInitTask = await jsInitGenerator(tree, {
Expand Down Expand Up @@ -490,6 +502,10 @@ export async function applicationGeneratorInternal(tree: Tree, schema: Schema) {
await formatFiles(tree);
}

tasks.push(() => {
logShowProjectCommand(options.name);
});

return runTasksInSerial(...tasks);
}

Expand Down
5 changes: 5 additions & 0 deletions packages/node/src/generators/e2e-project/e2e-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
isEslintConfigSupported,
replaceOverridesInLintConfig,
} from '@nx/eslint/src/generators/utils/eslint-file';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';

export async function e2eProjectGenerator(host: Tree, options: Schema) {
return await e2eProjectGeneratorInternal(host, {
Expand Down Expand Up @@ -134,6 +135,10 @@ export async function e2eProjectGeneratorInternal(
await formatFiles(host);
}

tasks.push(() => {
logShowProjectCommand(options.e2eProjectName);
});

return runTasksInSerial(...tasks);
}

Expand Down
5 changes: 5 additions & 0 deletions packages/nuxt/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { addLinting } from '../../utils/add-linting';
import { addVitest } from './lib/add-vitest';
import { vueTestUtilsVersion, vitePluginVueVersion } from '@nx/vue';
import { ensureDependencies } from './lib/ensure-dependencies';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';

export async function applicationGenerator(tree: Tree, schema: Schema) {
const tasks: GeneratorCallback[] = [];
Expand Down Expand Up @@ -122,6 +123,10 @@ export async function applicationGenerator(tree: Tree, schema: Schema) {

if (!options.skipFormat) await formatFiles(tree);

tasks.push(() => {
logShowProjectCommand(options.projectName);
});

return runTasksInSerial(...tasks);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { createApplicationFiles } from './lib/create-application-files';
import { addDetox } from './lib/add-detox';
import { Schema } from './schema';
import { ensureDependencies } from '../../utils/ensure-dependencies';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';

export async function reactNativeApplicationGenerator(
host: Tree,
Expand Down Expand Up @@ -91,6 +92,10 @@ export async function reactNativeApplicationGeneratorInternal(
await formatFiles(host);
}

tasks.push(() => {
logShowProjectCommand(options.projectName);
});

return runTasksInSerial(...tasks);
}

Expand Down
5 changes: 5 additions & 0 deletions packages/react-native/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
import { NormalizedSchema, normalizeOptions } from './lib/normalize-options';
import { Schema } from './schema';
import { ensureDependencies } from '../../utils/ensure-dependencies';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';

export async function reactNativeLibraryGenerator(
host: Tree,
Expand Down Expand Up @@ -111,6 +112,10 @@ export async function reactNativeLibraryGeneratorInternal(
await formatFiles(host);
}

tasks.push(() => {
logShowProjectCommand(options.name);
});

return runTasksInSerial(...tasks);
}

Expand Down
5 changes: 5 additions & 0 deletions packages/react/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
isEslintConfigSupported,
} from '@nx/eslint/src/generators/utils/eslint-file';
import { initGenerator as jsInitGenerator } from '@nx/js';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';

async function addLinting(host: Tree, options: NormalizedSchema) {
const tasks: GeneratorCallback[] = [];
Expand Down Expand Up @@ -304,6 +305,10 @@ export async function applicationGeneratorInternal(
await formatFiles(host);
}

tasks.push(() => {
logShowProjectCommand(options.projectName);
});

return runTasksInSerial(...tasks);
}

Expand Down
5 changes: 5 additions & 0 deletions packages/react/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { extractTsConfigBase } from '../../utils/create-ts-config';
import { installCommonDependencies } from './lib/install-common-dependencies';
import { setDefaults } from './lib/set-defaults';
import { relative } from 'path';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';

export async function libraryGenerator(host: Tree, schema: Schema) {
return await libraryGeneratorInternal(host, {
Expand Down Expand Up @@ -235,6 +236,10 @@ export async function libraryGeneratorInternal(host: Tree, schema: Schema) {
await formatFiles(host);
}

tasks.push(() => {
logShowProjectCommand(options.name);
});

return runTasksInSerial(...tasks);
}

Expand Down
5 changes: 5 additions & 0 deletions packages/remix/src/generators/application/application.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { updateDependencies } from '../utils/update-dependencies';
import initGenerator from '../init/init';
import { initGenerator as jsInitGenerator } from '@nx/js';
import { addBuildTargetDefaults } from '@nx/devkit/src/generators/add-build-target-defaults';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';

export default async function (tree: Tree, _options: NxRemixGeneratorSchema) {
const options = await normalizeOptions(tree, _options);
Expand Down Expand Up @@ -267,6 +268,10 @@ export default async function (tree: Tree, _options: NxRemixGeneratorSchema) {
await formatFiles(tree);
}

tasks.push(() => {
logShowProjectCommand(options.projectName);
});

return runTasksInSerial(...tasks);
}

Expand Down
5 changes: 5 additions & 0 deletions packages/vue/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { createApplicationFiles } from './lib/create-application-files';
import { addVite } from './lib/add-vite';
import { extractTsConfigBase } from '../../utils/create-ts-config';
import { ensureDependencies } from '../../utils/ensure-dependencies';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';

export async function applicationGenerator(
tree: Tree,
Expand Down Expand Up @@ -81,6 +82,10 @@ export async function applicationGenerator(

if (!options.skipFormat) await formatFiles(tree);

tasks.push(() => {
logShowProjectCommand(options.projectName);
});

return runTasksInSerial(...tasks);
}

Expand Down
5 changes: 5 additions & 0 deletions packages/vue/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { extractTsConfigBase } from '../../utils/create-ts-config';
import componentGenerator from '../component/component';
import { addVite } from './lib/add-vite';
import { ensureDependencies } from '../../utils/ensure-dependencies';
import { logShowProjectCommand } from '@nx/devkit/src/utils/log-show-project-command';

export async function libraryGenerator(tree: Tree, schema: Schema) {
const tasks: GeneratorCallback[] = [];
Expand Down Expand Up @@ -94,6 +95,10 @@ export async function libraryGenerator(tree: Tree, schema: Schema) {

if (!options.skipFormat) await formatFiles(tree);

tasks.push(() => {
logShowProjectCommand(options.name);
});

return runTasksInSerial(...tasks);
}

Expand Down
Loading

0 comments on commit 0b3e1f6

Please # to comment.