Skip to content

Commit 789de56

Browse files
committed
feat(package): migrate to ng12
1 parent 5786b9a commit 789de56

File tree

8 files changed

+5708
-4623
lines changed

8 files changed

+5708
-4623
lines changed

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx --no-install commitlint --edit $1

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx --no-install lint-staged

package.json

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,62 +29,59 @@
2929
"ci:after": "greenkeeper-lockfile-upload",
3030
"test": "jest --runInBand --colors",
3131
"test:ci": "jest --ci --updateSnapshot --colors",
32-
"release": "standard-version"
32+
"release": "standard-version",
33+
"prepare": "husky install"
3334
},
3435
"devDependencies": {
35-
"@angular/common": "^9.1.0",
36-
"@angular/compiler": "^9.1.0",
37-
"@angular/compiler-cli": "^9.1.0",
38-
"@angular/core": "^9.1.0",
39-
"@angular/platform-browser": "^9.1.0",
40-
"@angular/platform-browser-dynamic": "^9.1.0",
41-
"@commitlint/cli": "^8.3.5",
42-
"@commitlint/config-conventional": "^8.3.4",
43-
"@types/jest": "^23.3.14",
36+
"@angular/common": "^12.0.3",
37+
"@angular/compiler": "^12.0.3",
38+
"@angular/compiler-cli": "^12.0.3",
39+
"@angular/core": "^12.0.3",
40+
"@angular/platform-browser": "^12.0.3",
41+
"@angular/platform-browser-dynamic": "^12.0.3",
42+
"@commitlint/cli": "^12.1.4",
43+
"@commitlint/config-conventional": "^12.1.4",
44+
"@types/jest": "^26.0.23",
4445
"@types/lodash": "^4.14.150",
45-
"@types/node": "^10.0.0",
46+
"@types/node": "^15.12.2",
4647
"angular-tslint-rules": "^1.20.4",
47-
"codelyzer": "^5.2.2",
48+
"codelyzer": "^6.0.2",
4849
"cz-conventional-changelog": "^3.1.0",
49-
"husky": "^4.2.0",
50-
"jest": "^23.6.0",
50+
"husky": "^6.0.0",
51+
"jest": "^27.0.4",
5152
"jest-junit-reporter": "^1.1.0",
52-
"jest-preset-angular": "8.1.2",
53-
"lerna": "^3.20.2",
54-
"lint-staged": "^10.0.0",
53+
"jest-preset-angular": "9.0.3",
54+
"lerna": "^4.0.0",
55+
"lint-staged": "^11.0.0",
5556
"lodash": "^4.17.15",
56-
"ng-packagr": "^9.0.0",
57-
"prettier": "1.19.1",
57+
"ng-packagr": "^12.0.4",
58+
"prettier": "2.3.1",
5859
"prettier-tslint": "^0.4.2",
5960
"reflect-metadata": "^0.1.13",
6061
"request": "^2.88.2",
6162
"rimraf": "^3.0.2",
62-
"rxjs": "~6.5.4",
63-
"ts-node": "^8.9.0",
64-
"tsickle": "^0.38.0",
65-
"tslint": "^5.20.1",
63+
"rxjs": "~7.1.0",
64+
"ts-node": "^10.0.0",
65+
"tsickle": "^0.40.0",
66+
"tslint": "^6.1.3",
6667
"tslint-config-prettier": "^1.18.0",
67-
"typescript": "~3.8.3",
68-
"zone.js": "^0.10.2"
69-
},
70-
"husky": {
71-
"hooks": {
72-
"pre-commit": "lint-staged",
73-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
74-
}
68+
"typescript": "~4.2.4",
69+
"zone.js": "^0.11.4"
7570
},
7671
"jest": {
7772
"preset": "jest-preset-angular",
78-
"setupTestFrameworkScriptFile": "./tools/test/jest.setup.ts",
73+
"setupFilesAfterEnv": [
74+
"./tools/test/jest.setup.ts"
75+
],
7976
"testResultsProcessor": "./node_modules/jest-junit-reporter",
8077
"testMatch": [
8178
"**/+(*.)+(spec|test).+(ts|js)?(x)"
8279
],
8380
"globals": {
8481
"ts-jest": {
85-
"tsConfigFile": "./tsconfig.json"
86-
},
87-
"__TRANSFORM_HTML__": true
82+
"stringifyContentPathRegex": "\\.html?$",
83+
"tsconfig": "./tsconfig.json"
84+
}
8885
},
8986
"moduleDirectories": [
9087
"node_modules",
@@ -108,5 +105,8 @@
108105
"commitizen": {
109106
"path": "./node_modules/cz-conventional-changelog"
110107
}
108+
},
109+
"dependencies": {
110+
"@angular-devkit/core": "^12.0.3"
111111
}
112112
}
Lines changed: 79 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { async, inject } from '@angular/core/testing';
1+
import { inject, waitForAsync } from '@angular/core/testing';
22

33
import { ConfigLoader, ConfigService, ConfigStaticLoader } from '../src';
44

@@ -10,7 +10,7 @@ describe('@ngx-config/core:', () => {
1010

1111
testModuleConfig({
1212
provide: ConfigLoader,
13-
useFactory: configFactory
13+
useFactory: configFactory,
1414
});
1515
});
1616

@@ -29,68 +29,86 @@ describe('@ngx-config/core:', () => {
2929
});
3030
}));
3131

32-
it('should be able to get setting(s) using `key`', async(
33-
inject([ConfigService], (config: ConfigService) => {
34-
config.loader.loadSettings().then(() => {
35-
expect(config.getSettings('system')).toEqual({
36-
applicationName: 'Mighty Mouse',
37-
applicationUrl: 'http://localhost:8000'
38-
});
32+
it(
33+
'should be able to get setting(s) using `key`',
34+
waitForAsync(
35+
inject([ConfigService], (config: ConfigService) => {
36+
config.loader.loadSettings().then(() => {
37+
expect(config.getSettings('system')).toEqual({
38+
applicationName: 'Mighty Mouse',
39+
applicationUrl: 'http://localhost:8000',
40+
});
3941

40-
expect(config.getSettings(['system', 'applicationName'])).toEqual('Mighty Mouse');
41-
expect(config.getSettings('system.applicationName')).toEqual('Mighty Mouse');
42+
expect(config.getSettings(['system', 'applicationName'])).toEqual('Mighty Mouse');
43+
expect(config.getSettings('system.applicationName')).toEqual('Mighty Mouse');
4244

43-
expect(config.getSettings(['system', 'applicationUrl'])).toEqual('http://localhost:8000');
44-
expect(config.getSettings('system.applicationUrl')).toEqual('http://localhost:8000');
45+
expect(config.getSettings(['system', 'applicationUrl'])).toEqual('http://localhost:8000');
46+
expect(config.getSettings('system.applicationUrl')).toEqual('http://localhost:8000');
4547

46-
expect(config.getSettings('i18n')).toEqual({
47-
locale: 'en'
48-
});
48+
expect(config.getSettings('i18n')).toEqual({
49+
locale: 'en',
50+
});
4951

50-
expect(config.getSettings(['i18n', 'locale'])).toEqual('en');
51-
expect(config.getSettings('i18n.locale')).toEqual('en');
52-
});
53-
})
54-
));
55-
56-
it('should be able to get setting(s) using `key` (zero value)', async(
57-
inject([ConfigService], (config: ConfigService) => {
58-
config.loader.loadSettings().then(() => {
59-
expect(config.getSettings('falsy.zero')).toEqual(0);
60-
});
61-
})
62-
));
63-
64-
it('should be able to get setting(s) using `key` (null value)', async(
65-
inject([ConfigService], (config: ConfigService) => {
66-
config.loader.loadSettings().then(() => {
67-
expect(config.getSettings('falsy.null')).toBeNull();
68-
});
69-
})
70-
));
71-
72-
it('should be able to get setting(s) using `key` (empty string)', async(
73-
inject([ConfigService], (config: ConfigService) => {
74-
config.loader.loadSettings().then(() => {
75-
expect(config.getSettings('falsy.emptyString')).toEqual('');
76-
});
77-
})
78-
));
79-
80-
it('should be able to get `default value` w/invalid `key`', async(
81-
inject([ConfigService], (config: ConfigService) => {
82-
config.loader.loadSettings().then(() => {
83-
expect(config.getSettings('layout', 'default')).toEqual('default');
84-
});
85-
})
86-
));
87-
88-
it('should throw if you provide an invalid `key` w/o `default value`', async(
89-
inject([ConfigService], (config: ConfigService) => {
90-
config.loader.loadSettings().then(() => {
91-
expect(() => config.getSettings('layout')).toThrowError('No setting found with the specified key [layout]!');
92-
});
93-
})
94-
));
52+
expect(config.getSettings(['i18n', 'locale'])).toEqual('en');
53+
expect(config.getSettings('i18n.locale')).toEqual('en');
54+
});
55+
})
56+
)
57+
);
58+
59+
it(
60+
'should be able to get setting(s) using `key` (zero value)',
61+
waitForAsync(
62+
inject([ConfigService], (config: ConfigService) => {
63+
config.loader.loadSettings().then(() => {
64+
expect(config.getSettings('falsy.zero')).toEqual(0);
65+
});
66+
})
67+
)
68+
);
69+
70+
it(
71+
'should be able to get setting(s) using `key` (null value)',
72+
waitForAsync(
73+
inject([ConfigService], (config: ConfigService) => {
74+
config.loader.loadSettings().then(() => {
75+
expect(config.getSettings('falsy.null')).toBeNull();
76+
});
77+
})
78+
)
79+
);
80+
81+
it(
82+
'should be able to get setting(s) using `key` (empty string)',
83+
waitForAsync(
84+
inject([ConfigService], (config: ConfigService) => {
85+
config.loader.loadSettings().then(() => {
86+
expect(config.getSettings('falsy.emptyString')).toEqual('');
87+
});
88+
})
89+
)
90+
);
91+
92+
it(
93+
'should be able to get `default value` w/invalid `key`',
94+
waitForAsync(
95+
inject([ConfigService], (config: ConfigService) => {
96+
config.loader.loadSettings().then(() => {
97+
expect(config.getSettings('layout', 'default')).toEqual('default');
98+
});
99+
})
100+
)
101+
);
102+
103+
it(
104+
'should throw if you provide an invalid `key` w/o `default value`',
105+
waitForAsync(
106+
inject([ConfigService], (config: ConfigService) => {
107+
config.loader.loadSettings().then(() => {
108+
expect(() => config.getSettings('layout')).toThrowError('No setting found with the specified key [layout]!');
109+
});
110+
})
111+
)
112+
);
95113
});
96114
});

packages/@ngx-config/merge-loader/src/config.merge-loader.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { filter, isEmpty, mergeMap, reduce, share } from 'rxjs/operators';
66
const errorIfEmpty = (source: Observable<any>) =>
77
source.pipe(
88
isEmpty(),
9-
mergeMap((empty: boolean) => (empty ? throwError(new Error('No setting found at the specified loader!')) : EMPTY))
9+
mergeMap((empty: boolean) => (empty ? throwError(() => new Error('No setting found at the specified loader!')) : EMPTY))
1010
);
1111

1212
const mergeWith = (object: any) => (source: Array<any>) =>
@@ -38,14 +38,14 @@ export class ConfigMergeLoader implements ConfigLoader {
3838
}
3939

4040
private async mergeParallel(): Promise<any> {
41-
const loaders: Array<ConfigLoader> = [new ConfigStaticLoader(), ...this.loaders];
41+
const loaders: Array<ConfigLoader> = [new ConfigStaticLoader()].concat(this.loaders);
4242

4343
const mergedSettings = onErrorResumeNext(loaders.map((loader: ConfigLoader) => fromObservable(loader.loadSettings()))).pipe(
4444
filter((res: any) => res),
4545
share()
4646
);
4747

48-
return new Promise((resolve: () => void, reject: Function) => {
48+
return new Promise((resolve: (value: unknown) => void, reject: Function) => {
4949
merge(mergedSettings, errorIfEmpty(mergedSettings), mergedSettings)
5050
.pipe(reduce((merged: any, current: any) => mergeWith(merged)(current), {}))
5151
.subscribe(resolve, () => reject('Loaders unreachable!'));

tools/test/jest.setup.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// tslint:disable
22
import 'jest-preset-angular';
3+
import 'zone.js';
4+
import 'zone.js/testing';
35

46
const mock = () => {
57
let storage = {};

0 commit comments

Comments
 (0)