Skip to content

Commit

Permalink
feat: upgrade to Angular 13 (#704)
Browse files Browse the repository at this point in the history
  • Loading branch information
arturovt committed Feb 22, 2022
1 parent f626ddf commit b32a536
Show file tree
Hide file tree
Showing 17 changed files with 3,748 additions and 4,046 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Expand Up @@ -30,9 +30,6 @@ jobs:
HUSKY_SKIP_INSTALL: 'true'
run: yarn --frozen-lockfile --no-progress --non-interactive

- name: Run TSLint
run: yarn lint

- name: Run tests
run: yarn test

Expand Down
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
/.angular/cache
dist
node_modules
.vscode
Expand Down
4 changes: 4 additions & 0 deletions .husky/pre-commit
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged
12 changes: 0 additions & 12 deletions angular.json
Expand Up @@ -22,18 +22,6 @@
"options": {
"no-cache": false
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"emitter/tsconfig.lib.json",
"tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions emitter/ng-package.json
Expand Up @@ -3,9 +3,6 @@
"dest": "../dist/emitter",
"lib": {
"flatModuleFile": "ngxs-labs-emitter",
"entryFile": "src/index.ts",
"umdModuleIds": {
"@ngxs/store": "ngxs-store"
}
"entryFile": "src/index.ts"
}
}
2 changes: 1 addition & 1 deletion emitter/package.json
Expand Up @@ -18,7 +18,7 @@
],
"sideEffects": true,
"peerDependencies": {
"@angular/core": ">=13.2.3",
"@angular/core": ">=13.0.0",
"@ngxs/store": ">=3.7.3"
}
}
2 changes: 1 addition & 1 deletion emitter/src/lib/core/decorators/receiver.ts
Expand Up @@ -108,7 +108,7 @@ export function Receiver(options?: Partial<ReceiverMetaData>): MethodDecorator {
payload
};

target.prototype[key] = function(ctx: StateContext<any>, action: any) {
target.prototype[key] = function (ctx: StateContext<any>, action: any) {
return target[key].call(target, ctx, action);
};
};
Expand Down
21 changes: 15 additions & 6 deletions emitter/src/tests/action.spec.ts
Expand Up @@ -114,7 +114,11 @@ describe('Actions', () => {
}

TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([CounterStateWithCustomActions]), NgxsEmitPluginModule.forRoot()]
imports: [
NgxsModule.forRoot([CounterStateWithCustomActions]),
NgxsEmitPluginModule.forRoot()
],
teardown: { destroyAfterEach: false }
});

const store: Store = TestBed.inject(Store);
Expand All @@ -132,7 +136,8 @@ describe('Actions', () => {
it('should intercept only CounterState.increment receiver', () => {
TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([CounterState]), NgxsEmitPluginModule.forRoot()],
declarations: [MockComponent]
declarations: [MockComponent],
teardown: { destroyAfterEach: false }
});

const fixture = TestBed.createComponent(MockComponent);
Expand All @@ -152,7 +157,8 @@ describe('Actions', () => {
it('should intercept receiver that throws an error', () => {
TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([CounterState]), NgxsEmitPluginModule.forRoot()],
declarations: [MockComponent]
declarations: [MockComponent],
teardown: { destroyAfterEach: false }
});

const fixture = TestBed.createComponent(MockComponent);
Expand All @@ -174,7 +180,8 @@ describe('Actions', () => {
it('should intercept multiple dispatched emittables', () => {
TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([CounterState]), NgxsEmitPluginModule.forRoot()],
declarations: [MockComponent]
declarations: [MockComponent],
teardown: { destroyAfterEach: false }
});

const fixture = TestBed.createComponent(MockComponent);
Expand Down Expand Up @@ -203,7 +210,8 @@ describe('Actions', () => {
it('should intercept multiple successful emittables', () => {
TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([CounterState]), NgxsEmitPluginModule.forRoot()],
declarations: [MockComponent]
declarations: [MockComponent],
teardown: { destroyAfterEach: false }
});

const fixture = TestBed.createComponent(MockComponent);
Expand Down Expand Up @@ -276,7 +284,8 @@ describe('Actions', () => {
// Arrange
TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([CounterState]), NgxsEmitPluginModule.forRoot()],
declarations: [MockComponent]
declarations: [MockComponent],
teardown: { destroyAfterEach: false }
});

// Act
Expand Down
39 changes: 26 additions & 13 deletions emitter/src/tests/emit.plugin.spec.ts
Expand Up @@ -75,7 +75,8 @@ describe(NgxsEmitPluginModule.name, () => {

TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([TodosState]), NgxsEmitPluginModule.forRoot()],
declarations: [MockComponent]
declarations: [MockComponent],
teardown: { destroyAfterEach: false }
});

const fixture = TestBed.createComponent(MockComponent);
Expand Down Expand Up @@ -122,7 +123,8 @@ describe(NgxsEmitPluginModule.name, () => {

TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([TodosState]), NgxsEmitPluginModule.forRoot()],
declarations: [MockComponent]
declarations: [MockComponent],
teardown: { destroyAfterEach: false }
});

const store: Store = TestBed.inject(Store);
Expand Down Expand Up @@ -158,7 +160,8 @@ describe(NgxsEmitPluginModule.name, () => {

TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([TodosState]), NgxsEmitPluginModule.forRoot()],
declarations: [MockComponent]
declarations: [MockComponent],
teardown: { destroyAfterEach: false }
});

const store: Store = TestBed.inject(Store);
Expand Down Expand Up @@ -198,7 +201,8 @@ describe(NgxsEmitPluginModule.name, () => {

TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([CounterState]), NgxsEmitPluginModule.forRoot()],
declarations: [MockComponent]
declarations: [MockComponent],
teardown: { destroyAfterEach: false }
});

const store: Store = TestBed.inject(Store);
Expand Down Expand Up @@ -242,7 +246,8 @@ describe(NgxsEmitPluginModule.name, () => {

TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([BarState, Bar2State]), NgxsEmitPluginModule.forRoot()],
declarations: [MockComponent]
declarations: [MockComponent],
teardown: { destroyAfterEach: false }
});

const store: Store = TestBed.inject(Store);
Expand Down Expand Up @@ -270,7 +275,8 @@ describe(NgxsEmitPluginModule.name, () => {
}

TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([BarState]), NgxsEmitPluginModule.forRoot()]
imports: [NgxsModule.forRoot([BarState]), NgxsEmitPluginModule.forRoot()],
teardown: { destroyAfterEach: false }
});
} catch ({ message }) {
expect(message).toBe('Method decorated with such type `foo` already exists');
Expand Down Expand Up @@ -318,7 +324,8 @@ describe(NgxsEmitPluginModule.name, () => {
}

TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([BarState]), NgxsEmitPluginModule.forRoot()]
imports: [NgxsModule.forRoot([BarState]), NgxsEmitPluginModule.forRoot()],
teardown: { destroyAfterEach: false }
});

const store: EmitStore = TestBed.inject(EmitStore);
Expand Down Expand Up @@ -383,7 +390,8 @@ describe(NgxsEmitPluginModule.name, () => {
TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([TodosState]), NgxsEmitPluginModule.forRoot()],
declarations: [MockComponent],
providers: [ApiService]
providers: [ApiService],
teardown: { destroyAfterEach: false }
});

const store: Store = TestBed.inject(Store);
Expand Down Expand Up @@ -418,7 +426,8 @@ describe(NgxsEmitPluginModule.name, () => {

TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([TodosState]), NgxsEmitPluginModule.forRoot()],
declarations: [MockComponent]
declarations: [MockComponent],
teardown: { destroyAfterEach: false }
});

const fixture = TestBed.createComponent(MockComponent);
Expand Down Expand Up @@ -456,7 +465,8 @@ describe(NgxsEmitPluginModule.name, () => {

TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([TodosState]), NgxsEmitPluginModule.forRoot()],
declarations: [MockComponent]
declarations: [MockComponent],
teardown: { destroyAfterEach: false }
});

const store: Store = TestBed.inject(Store);
Expand Down Expand Up @@ -497,7 +507,8 @@ describe(NgxsEmitPluginModule.name, () => {

TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([TodosState]), NgxsEmitPluginModule.forRoot()],
declarations: [MockComponent]
declarations: [MockComponent],
teardown: { destroyAfterEach: false }
});

const fixture = TestBed.createComponent(MockComponent);
Expand Down Expand Up @@ -533,7 +544,8 @@ describe(NgxsEmitPluginModule.name, () => {

TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([AnimalsState]), NgxsEmitPluginModule.forRoot()],
declarations: [MockComponent]
declarations: [MockComponent],
teardown: { destroyAfterEach: false }
});

const fixture = TestBed.createComponent(MockComponent);
Expand Down Expand Up @@ -586,7 +598,8 @@ describe(NgxsEmitPluginModule.name, () => {

TestBed.configureTestingModule({
imports: [NgxsModule.forRoot([CounterState]), NgxsEmitPluginModule.forRoot()],
declarations: [MockComponent]
declarations: [MockComponent],
teardown: { destroyAfterEach: false }
});

const store: Store = TestBed.inject(Store);
Expand Down
5 changes: 1 addition & 4 deletions emitter/testing/ng-package.json
Expand Up @@ -2,9 +2,6 @@
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"lib": {
"flatModuleFile": "ngxs-labs-emitter-testing",
"entryFile": "src/index.ts",
"umdModuleIds": {
"@ngxs/store": "ngxs-store"
}
"entryFile": "src/index.ts"
}
}
3 changes: 2 additions & 1 deletion emitter/testing/src/tests/store-test-bed.spec.ts
Expand Up @@ -23,7 +23,8 @@ describe(StoreTestBedModule.name, () => {
}

TestBed.configureTestingModule({
imports: [StoreTestBedModule.configureTestingModule([CounterState])]
imports: [StoreTestBedModule.configureTestingModule([CounterState])],
teardown: { destroyAfterEach: false }
});

const store: Store = TestBed.inject(Store);
Expand Down
2 changes: 1 addition & 1 deletion emitter/tsconfig.lib.json
Expand Up @@ -14,7 +14,7 @@
"importHelpers": true
},
"angularCompilerOptions": {
"enableIvy": false,
"compilationMode": "partial",
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
@@ -1,4 +1,4 @@
const { pathsToModuleNameMapper } = require('ts-jest/utils');
const { pathsToModuleNameMapper } = require('ts-jest');
const { compilerOptions } = require('./tsconfig');

const moduleNameMapper = pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/' });
Expand Down
37 changes: 17 additions & 20 deletions package.json
Expand Up @@ -26,35 +26,33 @@
},
"private": true,
"dependencies": {
"@angular/common": "^12.2.12",
"@angular/compiler": "^12.2.12",
"@angular/core": "^12.2.12",
"@angular/platform-browser": "^12.2.12",
"@angular/platform-browser-dynamic": "^12.2.12",
"@angular/common": "^13.2.3",
"@angular/compiler": "^13.2.3",
"@angular/core": "^13.2.3",
"@angular/platform-browser": "^13.2.3",
"@angular/platform-browser-dynamic": "^13.2.3",
"@ngxs/store": "^3.7.3",
"rxjs": "^7.5.4",
"tslib": "^2.3.1",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-builders/jest": "^12.0.0",
"@angular-devkit/build-angular": "~12.0.3",
"@angular/cli": "^12.0.3",
"@angular/compiler-cli": "^12.0.3",
"@angular-builders/jest": "^13.0.3",
"@angular-devkit/build-angular": "~13.2.4",
"@angular/cli": "^13.2.4",
"@angular/compiler-cli": "^13.2.3",
"@commitlint/cli": "^13.2.1",
"@commitlint/config-conventional": "^12.1.4",
"@types/jest": "^26.0.24",
"@types/jest": "^27.4.0",
"@types/node": "^14.17.1",
"codelyzer": "^6.0.2",
"cpy-cli": "^3.1.1",
"husky": "^6.0.0",
"jest": "^26.6.3",
"lint-staged": "^11.2.6",
"ng-packagr": "^12.2.5",
"husky": "^7.0.4",
"jest": "^27.5.1",
"lint-staged": "^12.3.4",
"ng-packagr": "^13.2.1",
"prettier": "^2.5.1",
"ts-node": "^8.10.2",
"tslint": "~6.1.3",
"typescript": "4.2.4"
"ts-node": "^10.5.0",
"typescript": "4.5.5"
},
"husky": {
"hooks": {
Expand All @@ -64,8 +62,7 @@
},
"lint-staged": {
"*.ts": [
"prettier --write",
"git add"
"prettier --write"
]
},
"prettier": {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.spec.json
Expand Up @@ -5,7 +5,8 @@
"types": [
"jest",
"node"
]
],
"useUnknownInCatchVariables": false
},
"include": [
"**/*.spec.ts",
Expand Down

0 comments on commit b32a536

Please sign in to comment.