-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(migration): add Sass theme props migration [WIP] #2994
- Loading branch information
1 parent
ae5233a
commit 9b7e158
Showing
8 changed files
with
287 additions
and
27 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
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
44 changes: 44 additions & 0 deletions
44
projects/igniteui-angular/migrations/common/schema/theme-props.schema.json
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,44 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"definitions": { | ||
"ThemePropertyChange": { | ||
"properties": { | ||
"name": { | ||
"description": "Name of the theme property", | ||
"type": "string" | ||
}, | ||
"owner": { | ||
"description": "Theming function this parameter belongs to", | ||
"type": "string" | ||
}, | ||
"remove": { | ||
"description": "Remove directive/component/property", | ||
"type": "boolean" | ||
}, | ||
"replaceWith": { | ||
"description": "Replace original selector/property with new one", | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"name", | ||
"owner" | ||
], | ||
"type": "object" | ||
} | ||
}, | ||
"properties": { | ||
"changes": { | ||
"description": "An array of changes to theme function properties", | ||
"items": { | ||
"$ref": "#/definitions/ThemePropertyChange" | ||
}, | ||
"type": "array" | ||
} | ||
}, | ||
"required": [ | ||
"changes" | ||
], | ||
"type": "object" | ||
} | ||
|
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
15 changes: 15 additions & 0 deletions
15
projects/igniteui-angular/migrations/update-6_2_1/changes/theme-props.json
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,15 @@ | ||
{ | ||
"$schema": "../../common/schema/theme-props.schema.json", | ||
"changes": [ | ||
{ | ||
"name": "$chip-background", | ||
"replaceWith": "$background", | ||
"owner": "igx-chip-theme" | ||
}, | ||
{ | ||
"name": "$chip-hover-background", | ||
"replaceWith": "$hover-background", | ||
"owner": "igx-chip-theme" | ||
} | ||
] | ||
} |
51 changes: 51 additions & 0 deletions
51
projects/igniteui-angular/migrations/update-6_2_1/index.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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import * as path from 'path'; | ||
|
||
// tslint:disable:no-implicit-dependencies | ||
import { virtualFs } from '@angular-devkit/core'; | ||
import { EmptyTree } from '@angular-devkit/schematics'; | ||
// tslint:disable-next-line:no-submodule-imports | ||
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing'; | ||
|
||
describe('Update 6.2.1', () => { | ||
let appTree: UnitTestTree; | ||
const schematicRunner = new SchematicTestRunner('ig-migrate', path.join(__dirname, '../migration-collection.json')); | ||
const configJson = { | ||
defaultProject: 'testProj', | ||
projects: { | ||
testProj: { | ||
sourceRoot: '/testSrc' | ||
} | ||
}, | ||
schematics: { | ||
'@schematics/angular:component': { | ||
prefix: 'appPrefix' | ||
} | ||
} | ||
}; | ||
|
||
beforeEach(() => { | ||
appTree = new UnitTestTree(new EmptyTree()); | ||
appTree.create('/angular.json', JSON.stringify(configJson)); | ||
}); | ||
|
||
it('should update Sass files', done => { | ||
appTree.create( | ||
'/testSrc/appPrefix/style.scss', | ||
`$dark-chip-theme: igx-chip-theme( | ||
$roundness: 4px, | ||
$chip-background: #180505, | ||
$chip-hover-background: white | ||
);` | ||
); | ||
const tree = schematicRunner.runSchematic('migration-06', {}, appTree); | ||
expect(tree.readContent('/testSrc/appPrefix/style.scss')) | ||
.toEqual( | ||
`$dark-chip-theme: igx-chip-theme( | ||
$roundness: 4px, | ||
$background: #180505, | ||
$hover-background: white | ||
);` | ||
); | ||
done(); | ||
}); | ||
}); |
Oops, something went wrong.