Skip to content

Commit

Permalink
add library settings to config (#421)
Browse files Browse the repository at this point in the history
* add library settings to config

* handle new control type image

* fixes

* update version and changelog
  • Loading branch information
robhil authored Feb 29, 2024
1 parent 206caeb commit 6d62ddd
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/uxpin-merge-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [3.4.3] - 2024-02-29

### Added

- Supports image type with `@uxpincontroltype image`
- Possibility of adding library settings in uxpin.config.js - currently handled only by global UXPin libraries

## [3.4.2] - 2023-09-29

- Removes sorting properties in experimental mode and dump command to keep the same order as declared in code ([#414](https://github.com/UXPin/uxpin-merge-tools/pull/414))
Expand Down
2 changes: 1 addition & 1 deletion packages/uxpin-merge-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@uxpin/merge-cli",
"version": "3.4.2",
"version": "3.4.3",
"description": "The Command-line tool integrates the Design System repository with: https://www.uxpin.com/merge",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { ConfigEnabledProgramArgs } from '../../../program/args/ProgramArgs';
export interface CliConfig {
components: ComponentsConfig;
name?: string;
settings?: {
customComponentName?: string;
componentType?: string;
};
}

export interface ComponentsConfig extends ConfigEnabledProgramArgs {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { LIBRARY_DEFAULT_NAME } from '../../experimentation/server/handler/libraries/GetLibrariesHandler';
import { CliConfig } from '../config/CliConfig';
import { getConfiguration } from '../config/getConfiguration';
import { ProjectPaths } from '../paths/ProjectPaths';

export function getLibrarySettings(projectPaths: ProjectPaths): string {
const config: CliConfig = getConfiguration(projectPaths.configPath);

if (!config.settings) {
return '';
}

try {
return JSON.stringify(config.settings || {});
} catch (e) {
return '';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ComponentCategory } from './component/categories/ComponentCategory';

export interface DesignSystemSnapshot {
name: string;
settings?: string;
categorizedComponents: ComponentCategory[];
vcs: VCSDetails;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export enum CustomControlTypeName {
CodeEditor = 'codeeditor',
Color = 'color',
Input = 'input',
Image = 'image',
Interactions = 'interactions',
Number = 'number',
Select = 'select',
Expand All @@ -127,6 +128,7 @@ export interface CustomControlTypeStructureMap {
[CustomControlTypeName.CodeEditor]: {};
[CustomControlTypeName.Color]: {};
[CustomControlTypeName.Input]: {};
[CustomControlTypeName.Image]: {};
[CustomControlTypeName.Interactions]: {};
[CustomControlTypeName.Number]: {};
[CustomControlTypeName.Select]: {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function parseTypeTag(value: string): ParseResult {
switch (typeMatch[0]) {
case CustomControlTypeName.CodeEditor:
case CustomControlTypeName.Color:
case CustomControlTypeName.Image:
case CustomControlTypeName.Input:
case CustomControlTypeName.Interactions:
case CustomControlTypeName.Number:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { DesignSystemSnapshot, VCSDetails } from './DesignSystemSnapshot';
import { validateComponentNamespaces } from './validation/validateComponentNamespaces';
import { getVcsDetails } from './vcs/getVcsDetails';
import { MergeComponentSerializer } from './serializer';
import { getLibrarySettings } from '../discovery/library/getLibrarySettings';

const log = debug('uxpin');

Expand All @@ -30,6 +31,7 @@ export async function getDesignSystemMetadata(
): Promise<Warned<DesignSystemSnapshot>> {
const buildOptions: BuildOptions = getBuildOptions(programArgs);
const libraryName: string = getLibraryName(paths);
const librarySettings = getLibrarySettings(paths);

const categoryInfos: ComponentCategoryInfo[] = await getComponentCategoryInfos(paths);

Expand All @@ -51,6 +53,18 @@ export async function getDesignSystemMetadata(

validateComponentNamespaces(categorizedComponents);

if (librarySettings) {
return {
result: {
categorizedComponents,
name: libraryName,
settings: librarySettings,
vcs,
},
warnings: joinWarningLists(categoriesWithPresets.map((category) => category.warnings)),
};
}

return {
result: {
categorizedComponents,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const CUSTOM_TYPE_ALLOWANCE_MAP: {
} = {
[CustomControlTypeName.CodeEditor]: [...ARRAY_TYPES, ...ELEMENT_TYPES, ...OBJECT_TYPES, 'any', 'func', 'string'],
[CustomControlTypeName.Color]: ['string'],
[CustomControlTypeName.Image]: ['string'],
[CustomControlTypeName.Input]: TEXT_EDITABLE_TYPES,
[CustomControlTypeName.Interactions]: ['func'],
[CustomControlTypeName.Number]: ['number'],
Expand Down

0 comments on commit 6d62ddd

Please sign in to comment.