Skip to content

Commit

Permalink
cleanup(angular): migrate downgrade-module and upgrade-module generat…
Browse files Browse the repository at this point in the history
…ors to nx devkit (#6083)
  • Loading branch information
leosvelperez authored Jun 22, 2021
1 parent fdb54b3 commit 122f7ec
Show file tree
Hide file tree
Showing 44 changed files with 948 additions and 713 deletions.
8 changes: 4 additions & 4 deletions docs/angular/api-angular/generators/downgrade-module.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# downgrade-module

Setup Downgrade Module
Setup Downgrade Module.

## Usage

Expand Down Expand Up @@ -40,20 +40,20 @@ The name of the main AngularJS module.

Type: `string`

The name of the project
The name of the project.

### skipFormat

Default: `false`

Type: `boolean`

Skip formatting files
Skip formatting files.

### skipPackageJson

Default: `false`

Type: `boolean`

Do not add @angular/upgrade to package.json (e.g., --skipPackageJson)
Do not add @angular/upgrade to package.json (e.g., --skipPackageJson).
12 changes: 6 additions & 6 deletions docs/angular/api-angular/generators/upgrade-module.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# upgrade-module

Add an upgrade module
Add an upgrade module.

## Usage

Expand Down Expand Up @@ -28,7 +28,7 @@ nx g upgrade-module ... --dry-run

Type: `string`

The selector of an AngularJS component (e.g., --angularJsCmpSelector=myComponent)
The selector of an AngularJS component (e.g., --angularJsCmpSelector=myComponent).

### angularJsImport

Expand All @@ -46,28 +46,28 @@ The name of the main AngularJS module.

Type: `string`

The name of the project
The name of the project.

### router

Default: `false`

Type: `boolean`

Sets up router synchronization (e.g., --router)
Sets up router synchronization (e.g., --router).

### skipFormat

Default: `false`

Type: `boolean`

Skip formatting files
Skip formatting files.

### skipPackageJson

Default: `false`

Type: `boolean`

Do not add @angular/upgrade to package.json (e.g., --skipPackageJson)
Do not add @angular/upgrade to package.json (e.g., --skipPackageJson).
8 changes: 4 additions & 4 deletions docs/node/api-angular/generators/downgrade-module.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# downgrade-module

Setup Downgrade Module
Setup Downgrade Module.

## Usage

Expand Down Expand Up @@ -40,20 +40,20 @@ The name of the main AngularJS module.

Type: `string`

The name of the project
The name of the project.

### skipFormat

Default: `false`

Type: `boolean`

Skip formatting files
Skip formatting files.

### skipPackageJson

Default: `false`

Type: `boolean`

Do not add @angular/upgrade to package.json (e.g., --skipPackageJson)
Do not add @angular/upgrade to package.json (e.g., --skipPackageJson).
12 changes: 6 additions & 6 deletions docs/node/api-angular/generators/upgrade-module.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# upgrade-module

Add an upgrade module
Add an upgrade module.

## Usage

Expand Down Expand Up @@ -28,7 +28,7 @@ nx g upgrade-module ... --dry-run

Type: `string`

The selector of an AngularJS component (e.g., --angularJsCmpSelector=myComponent)
The selector of an AngularJS component (e.g., --angularJsCmpSelector=myComponent).

### angularJsImport

Expand All @@ -46,28 +46,28 @@ The name of the main AngularJS module.

Type: `string`

The name of the project
The name of the project.

### router

Default: `false`

Type: `boolean`

Sets up router synchronization (e.g., --router)
Sets up router synchronization (e.g., --router).

### skipFormat

Default: `false`

Type: `boolean`

Skip formatting files
Skip formatting files.

### skipPackageJson

Default: `false`

Type: `boolean`

Do not add @angular/upgrade to package.json (e.g., --skipPackageJson)
Do not add @angular/upgrade to package.json (e.g., --skipPackageJson).
8 changes: 4 additions & 4 deletions docs/react/api-angular/generators/downgrade-module.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# downgrade-module

Setup Downgrade Module
Setup Downgrade Module.

## Usage

Expand Down Expand Up @@ -40,20 +40,20 @@ The name of the main AngularJS module.

Type: `string`

The name of the project
The name of the project.

### skipFormat

Default: `false`

Type: `boolean`

Skip formatting files
Skip formatting files.

### skipPackageJson

Default: `false`

Type: `boolean`

Do not add @angular/upgrade to package.json (e.g., --skipPackageJson)
Do not add @angular/upgrade to package.json (e.g., --skipPackageJson).
12 changes: 6 additions & 6 deletions docs/react/api-angular/generators/upgrade-module.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# upgrade-module

Add an upgrade module
Add an upgrade module.

## Usage

Expand Down Expand Up @@ -28,7 +28,7 @@ nx g upgrade-module ... --dry-run

Type: `string`

The selector of an AngularJS component (e.g., --angularJsCmpSelector=myComponent)
The selector of an AngularJS component (e.g., --angularJsCmpSelector=myComponent).

### angularJsImport

Expand All @@ -46,28 +46,28 @@ The name of the main AngularJS module.

Type: `string`

The name of the project
The name of the project.

### router

Default: `false`

Type: `boolean`

Sets up router synchronization (e.g., --router)
Sets up router synchronization (e.g., --router).

### skipFormat

Default: `false`

Type: `boolean`

Skip formatting files
Skip formatting files.

### skipPackageJson

Default: `false`

Type: `boolean`

Do not add @angular/upgrade to package.json (e.g., --skipPackageJson)
Do not add @angular/upgrade to package.json (e.g., --skipPackageJson).
32 changes: 21 additions & 11 deletions packages/angular/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@
},

"downgrade-module": {
"factory": "./src/schematics/downgrade-module/downgrade-module",
"schema": "./src/schematics/downgrade-module/schema.json",
"description": "Setup Downgrade Module"
"factory": "./src/generators/downgrade-module/compat",
"schema": "./src/generators/downgrade-module/schema.json",
"description": "Setup Downgrade Module."
},

"upgrade-module": {
"factory": "./src/schematics/upgrade-module/upgrade-module",
"schema": "./src/schematics/upgrade-module/schema.json",
"description": "Add an upgrade module"
"factory": "./src/generators/upgrade-module/compat",
"schema": "./src/generators/upgrade-module/schema.json",
"description": "Add an upgrade module."
},

"storybook-configuration": {
Expand Down Expand Up @@ -120,6 +120,12 @@
"description": "Add linting configuration to an Angular project.",
"hidden": true
},
"application": {
"factory": "./src/generators/application/application",
"schema": "./src/generators/application/schema.json",
"aliases": ["app"],
"description": "Create an Angular application"
},
"component-cypress-spec": {
"factory": "./src/generators/component-cypress-spec/component-cypress-spec",
"schema": "./src/generators/component-cypress-spec/schema.json",
Expand All @@ -137,6 +143,11 @@
"schema": "./src/generators/convert-tslint-to-eslint/schema.json",
"description": "Convert a project from TSLint to ESLint"
},
"downgrade-module": {
"factory": "./src/generators/downgrade-module/downgrade-module",
"schema": "./src/generators/downgrade-module/schema.json",
"description": "Setup Downgrade Module."
},
"init": {
"factory": "./src/generators/init/init",
"schema": "./src/generators/init/schema.json",
Expand Down Expand Up @@ -191,11 +202,10 @@
"schema": "./src/generators/storybook-migrate-stories-to-6-2/schema.json",
"description": "Migrate stories to match the new syntax in v6.2 where the component declaration should be in the default export."
},
"application": {
"factory": "./src/generators/application/application",
"schema": "./src/generators/application/schema.json",
"aliases": ["app"],
"description": "Create an Angular application"
"upgrade-module": {
"factory": "./src/generators/upgrade-module/upgrade-module",
"schema": "./src/generators/upgrade-module/schema.json",
"description": "Add an upgrade module."
}
}
}
2 changes: 2 additions & 0 deletions packages/angular/generators.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './src/generators/application/application';
export * from './src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint';
export * from './src/generators/downgrade-module/downgrade-module';
export * from './src/generators/karma/karma';
export * from './src/generators/karma-project/karma-project';
export * from './src/generators/library/library';
Expand All @@ -9,3 +10,4 @@ export * from './src/generators/stories/stories';
export * from './src/generators/storybook-configuration/storybook-configuration';
export * from './src/generators/storybook-migrate-defaults-5-to-6/storybook-migrate-defaults-5-to-6';
export * from './src/generators/storybook-migrate-stories-to-6-2/migrate-stories-to-6-2';
export * from './src/generators/upgrade-module/upgrade-module';
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`downgradeModule generator should update main.ts 1`] = `
"import { enableProdMode, StaticProvider } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import * as angular from 'angular';
import { downgradeComponent, downgradeModule, setAngularJSGlobal } from '@angular/upgrade/static';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
import 'legacy';
import { AppComponent } from './app/app.component';
export function bootstrapAngular(extra: StaticProvider[]): any {
setAngularJSGlobal(angular);
if (environment.production) {
enableProdMode();
}
return platformBrowserDynamic(extra)
.bootstrapModule(AppModule)
.catch(err => console.log(err));
}
const downgraded = angular
.module('downgraded', [downgradeModule(bootstrapAngular)])
.directive('appRoot', downgradeComponent({ component: AppComponent, propagateDigest: false }));
angular.bootstrap(document, ['legacy', downgraded.name]);"
`;
4 changes: 4 additions & 0 deletions packages/angular/src/generators/downgrade-module/compat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { convertNxGenerator } from '@nrwl/devkit';
import { downgradeModuleGenerator } from './downgrade-module';

export default convertNxGenerator(downgradeModuleGenerator);
Loading

1 comment on commit 122f7ec

@vercel
Copy link

@vercel vercel bot commented on 122f7ec Jun 22, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.