Skip to content

Commit

Permalink
feat(angular): remove mfe-host alias in favour of host (#9834)
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 authored Apr 14, 2022
1 parent 6b49b5f commit e1f64a3
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 53 deletions.
32 changes: 16 additions & 16 deletions docs/generated/packages/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,21 +186,21 @@
"description": "Generate a Module Federation configuration for the application",
"type": "boolean",
"default": false,
"x-deprecated": "Use the `mfe-host` or `remote` generators instead. Support for generating MFE applications using the application generator will be removed in an upcoming version."
"x-deprecated": "Use the `host` or `remote` generators instead. Support for generating Module Federation applications using the application generator will be removed in an upcoming version."
},
"mfeType": {
"type": "string",
"enum": ["host", "remote"],
"description": "Type of application to generate the Module Federation configuration for.",
"default": "remote",
"x-deprecated": "Use the `mfe-host` or `remote` generators instead. Support for generating MFE applications using the application generator will be removed in an upcoming version."
"x-deprecated": "Use the `host` or `remote` generators instead. Support for generating Module Federation applications using the application generator will be removed in an upcoming version."
},
"federationType": {
"type": "string",
"enum": ["static", "dynamic"],
"description": "Use either Static or Dynamic Module Federation pattern for the application.",
"default": "static",
"x-deprecated": "Use the `mfe-host` or `remote` generators instead. Support for generating MFE applications using the application generator will be removed in an upcoming version."
"x-deprecated": "Use the `host` or `remote` generators instead. Support for generating Module Federation applications using the application generator will be removed in an upcoming version."
},
"port": {
"type": "number",
Expand All @@ -209,12 +209,12 @@
"remotes": {
"type": "array",
"description": "A list of remote application names that the host application should consume.",
"x-deprecated": "Use the `mfe-host` or `remote` generators instead. Support for generating MFE applications using the application generator will be removed in an upcoming version."
"x-deprecated": "Use the `host` or `remote` generators instead. Support for generating Module Federation applications using the application generator will be removed in an upcoming version."
},
"host": {
"type": "string",
"description": "The name of the host application that the remote application will be consumed by.",
"x-deprecated": "Use the `mfe-host` or `remote` generators instead. Support for generating MFE applications using the application generator will be removed in an upcoming version."
"x-deprecated": "Use the `host` or `remote` generators instead. Support for generating Module Federation applications using the application generator will be removed in an upcoming version."
},
"setParserOptionsProject": {
"type": "boolean",
Expand Down Expand Up @@ -1110,19 +1110,19 @@
"path": "/packages/angular/src/generators/convert-to-with-mf/schema.json"
},
{
"name": "mfe-host",
"factory": "./src/generators/mfe-host/mfe-host",
"name": "host",
"factory": "./src/generators/host/host",
"schema": {
"$schema": "http://json-schema.org/schema",
"$id": "NxMFEHost",
"$id": "NxMFHost",
"cli": "nx",
"title": "Nx MFE Host Application",
"description": "Create an Angular Host Micro Frontend Application.",
"title": "Nx Module Federation Host Application",
"description": "Create an Angular Host Module Federation Application.",
"type": "object",
"examples": [
{
"command": "nx g @nrwl/angular:mfe-host appName --remotes=remote1",
"description": "Create an Angular application with configuration in place for MFE. If the `remotes` option is provided, attach the remote application to this application's configuration"
"command": "nx g @nrwl/angular:host appName --remotes=remote1",
"description": "Create an Angular application with configuration in place for Module Federation. If the `remotes` option is provided, attach the remote application to this application's configuration"
}
],
"properties": {
Expand Down Expand Up @@ -1258,11 +1258,11 @@
"required": ["name"],
"presets": []
},
"aliases": ["host"],
"description": "Generate a Host Angular Micro Frontend Application.",
"implementation": "/packages/angular/src/generators/mfe-host/mfe-host.ts",
"description": "Generate a Host Angular Module Federation Application.",
"implementation": "/packages/angular/src/generators/host/host.ts",
"aliases": [],
"hidden": false,
"path": "/packages/angular/src/generators/mfe-host/schema.json"
"path": "/packages/angular/src/generators/host/schema.json"
},
{
"name": "ng-add",
Expand Down
2 changes: 1 addition & 1 deletion docs/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"remote",
"move",
"convert-to-with-mf",
"mfe-host",
"host",
"ng-add",
"ngrx",
"scam",
Expand Down
18 changes: 8 additions & 10 deletions packages/angular/generators.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,10 @@
"schema": "./src/generators/convert-to-with-mf/schema.json",
"description": "Converts an old micro frontend configuration to use the new `withModuleFederation` helper. It will run successfully if the following conditions are met: \n - Is either a host or remote application \n - Shared npm package configurations have not been modified \n - Name used to identify the Micro Frontend application matches the project name \n\n _**Note:** This generator will overwrite your webpack config. If you have additional custom configuration in your config file, it will be lost!_"
},
"mfe-host": {
"factory": "./src/generators/mfe-host/mfe-host.compat",
"schema": "./src/generators/mfe-host/schema.json",
"aliases": ["host"],
"description": "Generate a Host Angular Micro Frontend Application."
"host": {
"factory": "./src/generators/host/host.compat",
"schema": "./src/generators/host/schema.json",
"description": "Generate a Host Angular Module Federation Application."
},
"ng-add": {
"factory": "./src/generators/ng-add/compat",
Expand Down Expand Up @@ -235,11 +234,10 @@
"schema": "./src/generators/convert-to-with-mf/schema.json",
"description": "Converts an old micro frontend configuration to use the new withModuleFederation helper. It will run successfully if the following conditions are met: \n - Is either a host or remote application \n - Shared npm package configurations have not been modified \n - Name used to identify the Micro Frontend application matches the project name \n\n _**Note:** This generator will overwrite your webpack config. If you have additional custom configuration in your config file, it will be lost!_"
},
"mfe-host": {
"factory": "./src/generators/mfe-host/mfe-host",
"schema": "./src/generators/mfe-host/schema.json",
"aliases": ["host"],
"description": "Generate a Host Angular Micro Frontend Application."
"host": {
"factory": "./src/generators/host/host",
"schema": "./src/generators/host/schema.json",
"description": "Generate a Host Angular Module Federation Application."
},
"ng-add": {
"factory": "./src/generators/ng-add/ng-add",
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/generators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export * from './src/generators/stories/stories';
export * from './src/generators/storybook-configuration/storybook-configuration';
export * from './src/generators/upgrade-module/upgrade-module';
export * from './src/generators/setup-mfe/setup-mfe';
export * from './src/generators/mfe-host/mfe-host';
export * from './src/generators/host/host';
export * from './src/generators/scam/scam';
export * from './src/generators/scam-directive/scam-directive';
export * from './src/generators/scam-pipe/scam-pipe';
Expand Down
10 changes: 5 additions & 5 deletions packages/angular/src/generators/application/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,21 @@
"description": "Generate a Module Federation configuration for the application",
"type": "boolean",
"default": false,
"x-deprecated": "Use the `mfe-host` or `remote` generators instead. Support for generating MFE applications using the application generator will be removed in an upcoming version."
"x-deprecated": "Use the `host` or `remote` generators instead. Support for generating Module Federation applications using the application generator will be removed in an upcoming version."
},
"mfeType": {
"type": "string",
"enum": ["host", "remote"],
"description": "Type of application to generate the Module Federation configuration for.",
"default": "remote",
"x-deprecated": "Use the `mfe-host` or `remote` generators instead. Support for generating MFE applications using the application generator will be removed in an upcoming version."
"x-deprecated": "Use the `host` or `remote` generators instead. Support for generating Module Federation applications using the application generator will be removed in an upcoming version."
},
"federationType": {
"type": "string",
"enum": ["static", "dynamic"],
"description": "Use either Static or Dynamic Module Federation pattern for the application.",
"default": "static",
"x-deprecated": "Use the `mfe-host` or `remote` generators instead. Support for generating MFE applications using the application generator will be removed in an upcoming version."
"x-deprecated": "Use the `host` or `remote` generators instead. Support for generating Module Federation applications using the application generator will be removed in an upcoming version."
},
"port": {
"type": "number",
Expand All @@ -155,12 +155,12 @@
"remotes": {
"type": "array",
"description": "A list of remote application names that the host application should consume.",
"x-deprecated": "Use the `mfe-host` or `remote` generators instead. Support for generating MFE applications using the application generator will be removed in an upcoming version."
"x-deprecated": "Use the `host` or `remote` generators instead. Support for generating Module Federation applications using the application generator will be removed in an upcoming version."
},
"host": {
"type": "string",
"description": "The name of the host application that the remote application will be consumed by.",
"x-deprecated": "Use the `mfe-host` or `remote` generators instead. Support for generating MFE applications using the application generator will be removed in an upcoming version."
"x-deprecated": "Use the `host` or `remote` generators instead. Support for generating Module Federation applications using the application generator will be removed in an upcoming version."
},
"setParserOptionsProject": {
"type": "boolean",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`MFE Host App Generator should generate a host mfe app with a remote 1`] = `
exports[`Host App Generator should generate a host app with a remote 1`] = `
"const { withModuleFederation } = require('@nrwl/angular/module-federation');
const config = require('./mfe.config');
module.exports = withModuleFederation(config);"
`;

exports[`MFE Host App Generator should generate a host mfe app with a remote 2`] = `
exports[`Host App Generator should generate a host app with a remote 2`] = `
"const { withModuleFederation } = require('@nrwl/angular/module-federation');
const config = require('./mfe.config');
module.exports = withModuleFederation(config);"
`;

exports[`MFE Host App Generator should generate a host mfe app with no remotes 1`] = `
exports[`Host App Generator should generate a host app with no remotes 1`] = `
"const { withModuleFederation } = require('@nrwl/angular/module-federation');
const config = require('./mfe.config');
module.exports = withModuleFederation(config);"
Expand Down
4 changes: 4 additions & 0 deletions packages/angular/src/generators/host/host.compat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { convertNxGenerator } from '@nrwl/devkit';
import host from './host';

export default convertNxGenerator(host);
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
import mfeHost from './mfe-host';
import host from './host';
import applicationGenerator from '../application/application';

describe('MFE Host App Generator', () => {
it('should generate a host mfe app with no remotes', async () => {
describe('Host App Generator', () => {
it('should generate a host app with no remotes', async () => {
// ARRANGE
const tree = createTreeWithEmptyWorkspace(2);

// ACT
await mfeHost(tree, {
await host(tree, {
name: 'test',
});

// ASSERT
expect(tree.read('apps/test/webpack.config.js', 'utf-8')).toMatchSnapshot();
});

it('should generate a host mfe app with a remote', async () => {
it('should generate a host app with a remote', async () => {
// ARRANGE
const tree = createTreeWithEmptyWorkspace(2);

Expand All @@ -29,7 +29,7 @@ describe('MFE Host App Generator', () => {
});

// ACT
await mfeHost(tree, {
await host(tree, {
name: 'test',
remotes: ['remote'],
});
Expand All @@ -47,7 +47,7 @@ describe('MFE Host App Generator', () => {

// ACT
try {
await mfeHost(tree, {
await host(tree, {
name: 'test',
remotes: ['remote'],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Schema } from './schema';
import { getProjects } from '@nrwl/devkit';
import applicationGenerator from '../application/application';

export default async function mfeHost(tree: Tree, options: Schema) {
export default async function host(tree: Tree, options: Schema) {
const projects = getProjects(tree);

if (options.remotes && options.remotes.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"$schema": "http://json-schema.org/schema",
"$id": "NxMFEHost",
"$id": "NxMFHost",
"cli": "nx",
"title": "Nx MFE Host Application",
"description": "Create an Angular Host Micro Frontend Application.",
"title": "Nx Module Federation Host Application",
"description": "Create an Angular Host Module Federation Application.",
"type": "object",
"examples": [
{
"command": "nx g @nrwl/angular:mfe-host appName --remotes=remote1",
"description": "Create an Angular application with configuration in place for MFE. If the `remotes` option is provided, attach the remote application to this application's configuration"
"command": "nx g @nrwl/angular:host appName --remotes=remote1",
"description": "Create an Angular application with configuration in place for Module Federation. If the `remotes` option is provided, attach the remote application to this application's configuration"
}
],
"properties": {
Expand Down
4 changes: 0 additions & 4 deletions packages/angular/src/generators/mfe-host/mfe-host.compat.ts

This file was deleted.

1 comment on commit e1f64a3

@vercel
Copy link

@vercel vercel bot commented on e1f64a3 Apr 14, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

nx-dev – ./

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

Please sign in to comment.