-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
126 changed files
with
1,085 additions
and
985 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": ["@commitlint/config-angular"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,12 @@ | ||
module.exports = { | ||
globals: { | ||
"ts-jest": { | ||
diagnostics: false | ||
} | ||
globals: { | ||
'ts-jest': { | ||
diagnostics: false, | ||
}, | ||
transform: { | ||
"^.+\\.tsx?$": "ts-jest" | ||
}, | ||
moduleFileExtensions: [ | ||
"ts", | ||
"tsx", | ||
"js", | ||
"json" | ||
], | ||
testEnvironment: "./jest-custom-environment" | ||
}, | ||
transform: { | ||
'^.+\\.tsx?$': 'ts-jest', | ||
}, | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'], | ||
testEnvironment: './jest-custom-environment', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
const NodeEnvironment = require('jest-environment-node'); | ||
|
||
class JestCustomEnvironment extends NodeEnvironment { | ||
constructor(config) { | ||
super(config); | ||
this.jestErrorHasInstance = this.global.Error[Symbol.hasInstance]; | ||
} | ||
constructor(config) { | ||
super(config); | ||
this.jestErrorHasInstance = this.global.Error[Symbol.hasInstance]; | ||
} | ||
|
||
async setup() { | ||
await super.setup(); | ||
// Workaround for this bug https://github.com/facebook/jest/issues/2549 | ||
this.jestErrorHasInstance = this.global.Error[Symbol.hasInstance]; | ||
Object.defineProperty(this.global.Error, Symbol.hasInstance, { | ||
value: target => target instanceof Error || this.jestErrorHasInstance(target) | ||
}); | ||
} | ||
async setup() { | ||
await super.setup(); | ||
// Workaround for this bug https://github.com/facebook/jest/issues/2549 | ||
this.jestErrorHasInstance = this.global.Error[Symbol.hasInstance]; | ||
Object.defineProperty(this.global.Error, Symbol.hasInstance, { | ||
value: target => target instanceof Error || this.jestErrorHasInstance(target), | ||
}); | ||
} | ||
|
||
async tearDown() { | ||
Object.defineProperty(this.global.Error, Symbol.hasInstance, {value: this.jestErrorHasInstance}); | ||
await super.tearDown(); | ||
} | ||
async tearDown() { | ||
Object.defineProperty(this.global.Error, Symbol.hasInstance, { | ||
value: this.jestErrorHasInstance, | ||
}); | ||
await super.tearDown(); | ||
} | ||
} | ||
|
||
module.exports = JestCustomEnvironment; | ||
module.exports = JestCustomEnvironment; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
module.exports = {...require('./jest-common.config'), testRegex: `${process.cwd()}/e2e/.+\\.spec\\.ts`,}; | ||
module.exports = { | ||
...require('./jest-common.config'), | ||
testRegex: `${process.cwd()}/e2e/.+\\.spec\\.ts`, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
module.exports = {...require('./jest-common.config'), testRegex: `${process.cwd()}/(?!(e2e|examples)/).+\\.spec\\.ts`,}; | ||
module.exports = { | ||
...require('./jest-common.config'), | ||
testRegex: `${process.cwd()}/(?!(e2e|examples)/).+\\.spec\\.ts`, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
import {writeFileSync} from 'fs'; | ||
import {merge} from 'lodash'; | ||
import { writeFileSync } from 'fs'; | ||
import { merge } from 'lodash'; | ||
|
||
interface CustomSchema { | ||
originalSchemaPath: string; | ||
schemaExtensionPaths: string[], | ||
newSchemaPath: string; | ||
originalSchemaPath: string; | ||
schemaExtensionPaths: string[]; | ||
newSchemaPath: string; | ||
} | ||
|
||
const wd = process.cwd(); | ||
const schemesToMerge: CustomSchema[] = require(`${wd}/src/schemes`); | ||
|
||
for(const customSchema of schemesToMerge){ | ||
const originalSchema = require(customSchema.originalSchemaPath); | ||
const schemaExtensions = customSchema.schemaExtensionPaths.map((path: string) => require(path)); | ||
const newSchema = schemaExtensions.reduce((extendedSchema: any, currentExtension: any) => merge(extendedSchema, currentExtension), originalSchema); | ||
writeFileSync(customSchema.newSchemaPath, JSON.stringify(newSchema, null, 2), 'utf-8'); | ||
for (const customSchema of schemesToMerge) { | ||
const originalSchema = require(customSchema.originalSchemaPath); | ||
const schemaExtensions = customSchema.schemaExtensionPaths.map((path: string) => require(path)); | ||
const newSchema = schemaExtensions.reduce( | ||
(extendedSchema: any, currentExtension: any) => merge(extendedSchema, currentExtension), | ||
originalSchema | ||
); | ||
writeFileSync(customSchema.newSchemaPath, JSON.stringify(newSchema, null, 2), 'utf-8'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 18 additions & 20 deletions
38
packages/custom-webpack/e2e/custom-webpack-browser-schema.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,25 @@ | ||
|
||
import {customWebpackConfig, indexTransform} from "./custom-webpack-config-schema"; | ||
|
||
import { customWebpackConfig, indexTransform } from './custom-webpack-config-schema'; | ||
|
||
describe('custom webpack browser builder test', () => { | ||
let customWebpackBrowserSchema: any; | ||
let customWebpackBrowserSchema: any; | ||
|
||
beforeEach(() => { | ||
jest.resetModules() | ||
customWebpackBrowserSchema = require('../dist/browser/schema.json'); | ||
}); | ||
beforeEach(() => { | ||
jest.resetModules(); | ||
customWebpackBrowserSchema = require('../dist/browser/schema.json'); | ||
}); | ||
|
||
it('Should fit the schema of @angular-devkit/build-angular:browser', () => { | ||
const originalBrowserSchema = require('@angular-devkit/build-angular/src/browser/schema.json'); | ||
customWebpackBrowserSchema.properties['customWebpackConfig'] = undefined; | ||
customWebpackBrowserSchema.properties['indexTransform'] = undefined; | ||
expect(originalBrowserSchema.properties).toEqual(customWebpackBrowserSchema.properties); | ||
}); | ||
it('Should fit the schema of @angular-devkit/build-angular:browser', () => { | ||
const originalBrowserSchema = require('@angular-devkit/build-angular/src/browser/schema.json'); | ||
customWebpackBrowserSchema.properties['customWebpackConfig'] = undefined; | ||
customWebpackBrowserSchema.properties['indexTransform'] = undefined; | ||
expect(originalBrowserSchema.properties).toEqual(customWebpackBrowserSchema.properties); | ||
}); | ||
|
||
it('Should contain customWebpackConfig', () => { | ||
expect(customWebpackBrowserSchema.properties.customWebpackConfig).toEqual(customWebpackConfig); | ||
}); | ||
it('Should contain customWebpackConfig', () => { | ||
expect(customWebpackBrowserSchema.properties.customWebpackConfig).toEqual(customWebpackConfig); | ||
}); | ||
|
||
it('Should contain indexTransform', () => { | ||
expect(customWebpackBrowserSchema.properties.indexTransform).toEqual(indexTransform); | ||
}); | ||
it('Should contain indexTransform', () => { | ||
expect(customWebpackBrowserSchema.properties.indexTransform).toEqual(indexTransform); | ||
}); | ||
}); |
24 changes: 15 additions & 9 deletions
24
packages/custom-webpack/e2e/custom-webpack-config-schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
export const customWebpackConfig = { | ||
"type": "object", | ||
"description": "Custom webpack configuration", | ||
"properties": { | ||
"path": {"type": "string", "description": "Path to the custom webpack configuration file"}, | ||
"mergeStrategies": {"type": "object", "description": "Merge strategies per webpack config field"}, | ||
"replaceDuplicatePlugins": {"type": "boolean", "description": "Flag that indicates whether to replace duplicate webpack plugins or not"} | ||
}, | ||
"default": false | ||
type: 'object', | ||
description: 'Custom webpack configuration', | ||
properties: { | ||
path: { type: 'string', description: 'Path to the custom webpack configuration file' }, | ||
mergeStrategies: { type: 'object', description: 'Merge strategies per webpack config field' }, | ||
replaceDuplicatePlugins: { | ||
type: 'boolean', | ||
description: 'Flag that indicates whether to replace duplicate webpack plugins or not', | ||
}, | ||
}, | ||
default: false, | ||
}; | ||
|
||
export const indexTransform = {"type": "string", "description": "Path to the file with index.html transform function" } | ||
export const indexTransform = { | ||
type: 'string', | ||
description: 'Path to the file with index.html transform function', | ||
}; |
37 changes: 18 additions & 19 deletions
37
packages/custom-webpack/e2e/custom-webpack-karma-schema.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
import {customWebpackConfig, indexTransform} from "./custom-webpack-config-schema"; | ||
|
||
import { customWebpackConfig, indexTransform } from './custom-webpack-config-schema'; | ||
|
||
describe('custom webpack karma builder test', () => { | ||
let customWebpackBrowserSchema: any; | ||
let customWebpackBrowserSchema: any; | ||
|
||
beforeEach(() => { | ||
jest.resetModules() | ||
customWebpackBrowserSchema = require('../dist/karma/schema.json'); | ||
}); | ||
beforeEach(() => { | ||
jest.resetModules(); | ||
customWebpackBrowserSchema = require('../dist/karma/schema.json'); | ||
}); | ||
|
||
it('Should fit the schema of @angular-devkit/build-angular:karma', () => { | ||
const originalBrowserSchema = require('@angular-devkit/build-angular/src/karma/schema.json'); | ||
customWebpackBrowserSchema.properties['customWebpackConfig'] = undefined; | ||
customWebpackBrowserSchema.properties['indexTransform'] = undefined; | ||
expect(originalBrowserSchema.properties).toEqual(customWebpackBrowserSchema.properties); | ||
}); | ||
it('Should fit the schema of @angular-devkit/build-angular:karma', () => { | ||
const originalBrowserSchema = require('@angular-devkit/build-angular/src/karma/schema.json'); | ||
customWebpackBrowserSchema.properties['customWebpackConfig'] = undefined; | ||
customWebpackBrowserSchema.properties['indexTransform'] = undefined; | ||
expect(originalBrowserSchema.properties).toEqual(customWebpackBrowserSchema.properties); | ||
}); | ||
|
||
it('Should contain customWebpackConfig', () => { | ||
expect(customWebpackBrowserSchema.properties.customWebpackConfig).toEqual(customWebpackConfig); | ||
}); | ||
it('Should contain customWebpackConfig', () => { | ||
expect(customWebpackBrowserSchema.properties.customWebpackConfig).toEqual(customWebpackConfig); | ||
}); | ||
|
||
it('Should contain indexTransform', () => { | ||
expect(customWebpackBrowserSchema.properties.indexTransform).toEqual(indexTransform); | ||
}); | ||
it('Should contain indexTransform', () => { | ||
expect(customWebpackBrowserSchema.properties.indexTransform).toEqual(indexTransform); | ||
}); | ||
}); |
36 changes: 18 additions & 18 deletions
36
packages/custom-webpack/e2e/custom-webpack-server-schema.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
import {customWebpackConfig, indexTransform} from "./custom-webpack-config-schema"; | ||
import { customWebpackConfig, indexTransform } from './custom-webpack-config-schema'; | ||
|
||
describe('custom webpack server builder test', () => { | ||
let customWebpackBrowserSchema: any; | ||
let customWebpackBrowserSchema: any; | ||
|
||
beforeEach(() => { | ||
jest.resetModules() | ||
customWebpackBrowserSchema = require('../dist/server/schema.json'); | ||
}); | ||
beforeEach(() => { | ||
jest.resetModules(); | ||
customWebpackBrowserSchema = require('../dist/server/schema.json'); | ||
}); | ||
|
||
it('Should fit the schema of @angular-devkit/build-angular:server', () => { | ||
const originalBrowserSchema = require('@angular-devkit/build-angular/src/server/schema.json'); | ||
customWebpackBrowserSchema.properties['customWebpackConfig'] = undefined; | ||
customWebpackBrowserSchema.properties['indexTransform'] = undefined; | ||
expect(originalBrowserSchema.properties).toEqual(customWebpackBrowserSchema.properties); | ||
}); | ||
it('Should fit the schema of @angular-devkit/build-angular:server', () => { | ||
const originalBrowserSchema = require('@angular-devkit/build-angular/src/server/schema.json'); | ||
customWebpackBrowserSchema.properties['customWebpackConfig'] = undefined; | ||
customWebpackBrowserSchema.properties['indexTransform'] = undefined; | ||
expect(originalBrowserSchema.properties).toEqual(customWebpackBrowserSchema.properties); | ||
}); | ||
|
||
it('Should contain customWebpackConfig', () => { | ||
expect(customWebpackBrowserSchema.properties.customWebpackConfig).toEqual(customWebpackConfig); | ||
}); | ||
it('Should contain customWebpackConfig', () => { | ||
expect(customWebpackBrowserSchema.properties.customWebpackConfig).toEqual(customWebpackConfig); | ||
}); | ||
|
||
it('Should contain indexTransform', () => { | ||
expect(customWebpackBrowserSchema.properties.indexTransform).toEqual(indexTransform); | ||
}); | ||
it('Should contain indexTransform', () => { | ||
expect(customWebpackBrowserSchema.properties.indexTransform).toEqual(indexTransform); | ||
}); | ||
}); |
4 changes: 2 additions & 2 deletions
4
packages/custom-webpack/examples/full-cycle-app/e2e/protractor-ci-prod.conf.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
const config = require('./protractor-ci.conf').config; | ||
|
||
config.specs.push('./src/**/*.e2e-spec-prod.ts') | ||
config.specs.push('./src/**/*.e2e-spec-prod.ts'); | ||
|
||
exports.config = config; | ||
exports.config = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.