Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated crud-module and demo to Angular 16 #55

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions angular-crud/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

# Ignores TypeScript files, but keeps definitions.
!*.ts
!*.d.ts
1,303 changes: 214 additions & 1,089 deletions angular-crud/package-lock.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions angular-crud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@
"author": "Manfred Steyer",
"license": "MIT",
"schematics": "./src/collection.json",
"dependencies": {
"@angular-devkit/core": "^16.1.8",
"@angular-devkit/schematics": "^16.1.8",
"@angular/cdk": "^16.1.7",
"@schematics/angular": "^16.1.8",
"json5": "^2.2.0",
"typescript": "~5.1.3"
},
"devDependencies": {
"@types/jasmine": "^3.10.3",
"@types/jasmine": "~4.3.0",
"@types/json5": "0.0.30",
"@types/node": "^17.0.15",
"@types/node": "^16.11.7",
"chalk": "^4.1.2",
"istanbul": "0.4.5",
"jasmine": "^4.0.2",
"typescript": "^4.5.5"
},
"dependencies": {
"json5": "^2.2.0",
"@angular-devkit/core": "^13.2.2",
"@angular-devkit/schematics": "^13.2.2",
"@angular/cdk": "^13.2.1",
"@schematics/angular": "^13.2.2"
"jasmine": "^4.0.0"
},
"repository": {
"type": "git",
Expand Down
16 changes: 8 additions & 8 deletions angular-crud/src/collection.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"schematics": {
"menu": {
"aliases": [ "crud-module" ],
"factory": "./crud-module/index#generate",
"description": "Generates a crud module",
"schema": "./crud-module/schema.json"
}
"$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json",
"schematics": {
"crud-module": {
"factory": "./crud-module/index#generate",
"description": "Generates a crud module",
"schema": "./crud-module/schema.json"
}
}
}
}
18 changes: 9 additions & 9 deletions angular-crud/src/crud-module/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ describe('Angular CRUD Schematics', () => {
// add model file
tree.create('/projects/crudtest/src/app/hotel/model.json', JSON.stringify(model));

appTree = await schematicRunner.runExternalSchematicAsync('@schematics/angular', 'workspace', workspaceOptions, tree).toPromise();
appTree = await schematicRunner.runExternalSchematicAsync('@schematics/angular', 'application', appOptions, appTree).toPromise();
appTree = await schematicRunner.runExternalSchematic('@schematics/angular', 'workspace', workspaceOptions, tree);
appTree = await schematicRunner.runExternalSchematic('@schematics/angular', 'application', appOptions, appTree);
});

it('should create hotel-list component files', (done) => {
const files = ['hotel-list.component.html', 'hotel-list.component.spec.ts', 'hotel-list.component.ts'];
const hotelListPath = '/projects/crudtest/src/app/hotel/hotel-list/';
schematicRunner.runSchematicAsync('crud-module', defaultOptions, appTree).toPromise().then(tree => {
schematicRunner.runSchematic('crud-module', defaultOptions, appTree).then(tree => {
files.forEach(f => {
const path = `${hotelListPath}${f}`;
expect(tree.exists(path)).toEqual(true);
Expand All @@ -91,7 +91,7 @@ describe('Angular CRUD Schematics', () => {

it('should use Bootstrap by default', (done) => {
const hotelListPath = '/projects/crudtest/src/app/hotel/hotel-list/hotel-list.component.html';
schematicRunner.runSchematicAsync('crud-module', defaultOptions, appTree).toPromise().then(tree => {
schematicRunner.runSchematic('crud-module', defaultOptions, appTree).then(tree => {
const listTemplate = tree.readContent(hotelListPath);
expect(listTemplate).toContain(`class="table table-centered table-hover mb-0"`);
expect(listTemplate).toContain(`class="btn btn-primary"`);
Expand All @@ -102,7 +102,7 @@ describe('Angular CRUD Schematics', () => {
it('should create hotel-edit component files', (done) => {
const files = ['hotel-edit.component.html', 'hotel-edit.component.spec.ts', 'hotel-edit.component.ts'];
const hotelListPath = '/projects/crudtest/src/app/hotel/hotel-edit/';
schematicRunner.runSchematicAsync('crud-module', defaultOptions, appTree).toPromise().then(tree => {
schematicRunner.runSchematic('crud-module', defaultOptions, appTree).then(tree => {
files.forEach(f => {
const path = `${hotelListPath}${f}`;
expect(tree.exists(path)).toEqual(true);
Expand All @@ -112,7 +112,7 @@ describe('Angular CRUD Schematics', () => {
});

it('should add routes', (done) => {
schematicRunner.runSchematicAsync('crud-module', defaultOptions, appTree).toPromise().then(tree => {
schematicRunner.runSchematic('crud-module', defaultOptions, appTree).then(tree => {
const routingModule = tree.readContent('/projects/crudtest/src/app/hotel/hotel.routes.ts');
expect(routingModule).toContain(`path: 'hotels'`);
expect(routingModule).toContain(`path: 'hotels/:id'`);
Expand All @@ -121,7 +121,7 @@ describe('Angular CRUD Schematics', () => {
});

it('should import the module in the app module file', (done) => {
schematicRunner.runSchematicAsync('crud-module', defaultOptions, appTree).toPromise().then(tree => {
schematicRunner.runSchematic('crud-module', defaultOptions, appTree).then(tree => {
const appModule = tree.readContent('/projects/crudtest/src/app/app.module.ts');
expect(appModule).toMatch(/.\/hotel\/hotel.module/);
expect(appModule).toMatch(/HotelModule/);
Expand All @@ -133,7 +133,7 @@ describe('Angular CRUD Schematics', () => {
const bootstrapOptions = {...defaultOptions};
bootstrapOptions.style = 'bootstrap';

schematicRunner.runSchematicAsync('crud-module', bootstrapOptions, appTree).toPromise().then(tree => {
schematicRunner.runSchematic('crud-module', bootstrapOptions, appTree).then(tree => {
const hotelList = tree.readContent('/projects/crudtest/src/app/hotel/hotel-list/hotel-list.component.html');
expect(hotelList).toMatch(/<table class="table/);

Expand All @@ -147,7 +147,7 @@ describe('Angular CRUD Schematics', () => {
const materialOptions = {...defaultOptions};
materialOptions.style = 'material';

schematicRunner.runSchematicAsync('crud-module', materialOptions, appTree).toPromise().then(tree => {
schematicRunner.runSchematic('crud-module', materialOptions, appTree).then(tree => {
const hotelList = tree.readContent('/projects/crudtest/src/app/hotel/hotel-list/hotel-list.component.html');
expect(hotelList).toMatch(/<table mat-table/);

Expand Down
19 changes: 5 additions & 14 deletions angular-crud/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"compilerOptions": {
"baseUrl": "tsconfig",
"lib": [
"es2017",
"dom"
],
"lib": ["es2018", "dom"],
"declaration": true,
"module": "commonjs",
"moduleResolution": "node",
"noEmitOnError": true,
Expand All @@ -19,15 +17,8 @@
"sourceMap": true,
"strictNullChecks": true,
"target": "es6",
"types": [
"jasmine",
"node"
]
"types": ["jasmine", "node"]
},
"include": [
"src/**/*"
],
"exclude": [
"src/*/files/**/*"
]
"include": ["src/**/*"],
"exclude": ["src/*/files/**/*"]
}
3 changes: 1 addition & 2 deletions demo/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,5 @@
}
}
}
},
"defaultProject": "demo"
}
}
28 changes: 14 additions & 14 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
},
"private": true,
"dependencies": {
"@angular/animations": "~12.2.0",
"@angular/common": "~12.2.0",
"@angular/compiler": "~12.2.0",
"@angular/core": "~12.2.0",
"@angular/forms": "~12.2.0",
"@angular/platform-browser": "~12.2.0",
"@angular/platform-browser-dynamic": "~12.2.0",
"@angular/router": "~12.2.0",
"@angular/animations": "^16.1.8",
"@angular/common": "^16.1.8",
"@angular/compiler": "^16.1.8",
"@angular/core": "^16.1.8",
"@angular/forms": "^16.1.8",
"@angular/platform-browser": "^16.1.8",
"@angular/platform-browser-dynamic": "^16.1.8",
"@angular/router": "^16.1.8",
"rxjs": "~6.6.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
"zone.js": "~0.13.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~12.2.0",
"@angular/cli": "~12.2.0",
"@angular/compiler-cli": "~12.2.0",
"@angular-devkit/build-angular": "^16.1.8",
"@angular/cli": "^16.1.8",
"@angular/compiler-cli": "^16.1.8",
"@types/jasmine": "~3.8.2",
"@types/node": "^16.4.13",
"jasmine-core": "~3.8.0",
Expand All @@ -34,6 +34,6 @@
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.1",
"karma-jasmine-html-reporter": "^1.7.0",
"typescript": "~4.3.5"
"typescript": "~4.9.5"
}
}
}
11 changes: 0 additions & 11 deletions demo/src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,8 @@ import {
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';

declare const require: {
context(path: string, deep?: boolean, filter?: RegExp): {
keys(): string[];
<T>(id: string): T;
};
};

// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
5 changes: 3 additions & 2 deletions demo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2017",
"target": "ES2022",
"module": "es2020",
"lib": [
"es2018",
"dom"
]
],
"useDefineForClassFields": false
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
Expand Down