-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from UXPin/11940-jsx-presets
11940 jsx presets
- Loading branch information
Showing
102 changed files
with
9,297 additions
and
10,053 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ test-resources: ../../test/resources/repos/nordnet-ui-kit ../../test/resources/r | |
&& git clone [email protected]:UXPin/mineral-ui.git \ | ||
&& cd mineral-ui \ | ||
&& git remote add official https://github.com/mineral-ui/mineral-ui.git \ | ||
&& git checkout b825842aeb4244e56977af1a4afc3559caed94f3 \ | ||
&& git checkout 6a18faefe3d8339b066c92f1a10b27872f15729b \ | ||
&& mkdir ./npm-cache \ | ||
&& npm install --cache=./npm-cache \ | ||
&& rm -rf ./npm-cache |
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
5 changes: 5 additions & 0 deletions
5
packages/uxpin-merge-cli/src/common/warning/thunkFillSourcePath.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,5 @@ | ||
import { WarningDetails } from './WarningDetails'; | ||
|
||
export function thunkFillSourcePath(sourcePath:string):(warning:WarningDetails) => WarningDetails { | ||
return (warning:WarningDetails) => ({ sourcePath, ...warning }); | ||
} |
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
3 changes: 2 additions & 1 deletion
3
packages/uxpin-merge-cli/src/steps/building/compiler/getCompiler.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,7 +1,8 @@ | ||
import { BuildOptions } from '../BuildOptions'; | ||
import { getConfig } from '../config/getConfig'; | ||
import { Compiler } from './Compiler'; | ||
import { WebpackCompiler } from './webpack/WebpackCompiler'; | ||
|
||
export function getCompiler(options:BuildOptions):Compiler { | ||
return new WebpackCompiler(options); | ||
return new WebpackCompiler(getConfig(options)); | ||
} |
6 changes: 1 addition & 5 deletions
6
packages/uxpin-merge-cli/src/steps/building/compiler/webpack/WebpackCompiler.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
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
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
2 changes: 1 addition & 1 deletion
2
packages/uxpin-merge-cli/src/steps/discovery/component/presets/presetFileNameParser.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
118 changes: 118 additions & 0 deletions
118
...ps/serialization/component/presets/__tests__/replaceElementsWithReferencesInProps.test.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,118 @@ | ||
import { ComponentPresetElementProps } from '../ComponentPreset'; | ||
import { PartialProps } from '../jsx/JSXSerializationResult'; | ||
import { replaceElementsWithReferencesInProps } from '../replaceElementsWithReferencesInProps'; | ||
|
||
describe('replaceElementsWithReferencesInProps', () => { | ||
it('should replace single element with reference', () => { | ||
// given | ||
const props:PartialProps = { | ||
icon: { | ||
name: 'Button', | ||
props: { | ||
uxpId: '1', | ||
}, | ||
uxpinPresetElementType: 'CodeComponent', | ||
}, | ||
}; | ||
const expectedProps:ComponentPresetElementProps = { | ||
icon: { uxpinPresetElementId: '1' }, | ||
}; | ||
|
||
// when | ||
const result:ComponentPresetElementProps = replaceElementsWithReferencesInProps(props); | ||
|
||
// then | ||
expect(result).toEqual(expectedProps); | ||
}); | ||
|
||
it('should remove a few elements in array', () => { | ||
// given | ||
const props:PartialProps = { | ||
icon: [ | ||
{ | ||
name: 'Button', | ||
props: { | ||
uxpId: '1', | ||
}, | ||
uxpinPresetElementType: 'CodeComponent', | ||
}, | ||
{ | ||
name: 'Button', | ||
props: { | ||
uxpId: '2', | ||
}, | ||
uxpinPresetElementType: 'CodeComponent', | ||
}, | ||
], | ||
}; | ||
const expectedProps:ComponentPresetElementProps = { | ||
icon: [], | ||
}; | ||
|
||
// when | ||
const result:ComponentPresetElementProps = replaceElementsWithReferencesInProps(props); | ||
|
||
// then | ||
expect(result).toEqual(expectedProps); | ||
}); | ||
|
||
it('should remove deeply nested elements', () => { | ||
// given | ||
const props:PartialProps = { | ||
data: [ | ||
{ | ||
subtitle: [ | ||
'some text', | ||
{ | ||
name: 'Icon', | ||
props: { | ||
uxpId: '1', | ||
}, | ||
uxpinPresetElementType: 'CodeComponent', | ||
}, | ||
], | ||
title: 'some title', | ||
}, | ||
{ | ||
subtitle: { | ||
name: 'Icon', | ||
props: { | ||
uxpId: '1', | ||
}, | ||
uxpinPresetElementType: 'CodeComponent', | ||
}, | ||
title: 'some title', | ||
}, | ||
{ | ||
subtitle: 'some subtitle', | ||
title: 'some title', | ||
}, | ||
], | ||
}; | ||
const expectedProps:ComponentPresetElementProps = { | ||
data: [ | ||
{ subtitle: ['some text'], title: 'some title' }, | ||
{ title: 'some title' }, | ||
{ subtitle: 'some subtitle', title: 'some title' }, | ||
], | ||
}; | ||
|
||
// when | ||
const result:ComponentPresetElementProps = replaceElementsWithReferencesInProps(props); | ||
|
||
// then | ||
expect(result).toEqual(expectedProps); | ||
}); | ||
|
||
it('should return empty object', () => { | ||
// given | ||
const props:PartialProps = {}; | ||
const expectedProps:ComponentPresetElementProps = {}; | ||
|
||
// when | ||
const result:ComponentPresetElementProps = replaceElementsWithReferencesInProps(props); | ||
|
||
// then | ||
expect(result).toEqual(expectedProps); | ||
}); | ||
}); |
Oops, something went wrong.