Skip to content

Commit

Permalink
feat: wip of morfeo cli
Browse files Browse the repository at this point in the history
  • Loading branch information
mauroerta committed Jul 26, 2021
1 parent c4a69ca commit 476d48d
Show file tree
Hide file tree
Showing 32 changed files with 887 additions and 322 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.
build
commonjs
__snapshots__

# dependencies
Expand Down
147 changes: 147 additions & 0 deletions apps/cli/config.backup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
{
"source": ["tokens/**/*.json"],
"platforms": {
"scss": {
"transformGroup": "scss",
"buildPath": "build/scss/",
"files": [
{
"destination": "_variables.scss",
"format": "scss/variables"
}
]
},
"android": {
"transformGroup": "android",
"buildPath": "build/android/",
"files": [
{
"destination": "font_dimens.xml",
"format": "android/fontDimens"
},
{
"destination": "colors.xml",
"format": "android/colors"
}
]
},
"compose": {
"transformGroup": "compose",
"buildPath": "build/compose/",
"files": [
{
"destination": "MorfeoColor.kt",
"format": "compose/object",
"className": "MorfeoColor",
"packageName": "MorfeoColor",
"filter": {
"attributes": {
"category": "color"
}
}
},
{
"destination": "MorfeoSize.kt",
"format": "compose/object",
"className": "MorfeoSize",
"packageName": "MorfeoSize",
"type": "float",
"filter": {
"attributes": {
"category": "size"
}
}
}
]
},
"ios": {
"transformGroup": "ios",
"buildPath": "build/ios/",
"files": [
{
"destination": "MorfeoColor.h",
"format": "ios/colors.h",
"className": "MorfeoColor",
"type": "MorfeoColorName",
"filter": {
"attributes": {
"category": "color"
}
}
},
{
"destination": "MorfeoColor.m",
"format": "ios/colors.m",
"className": "MorfeoColor",
"type": "MorfeoColorName",
"filter": {
"attributes": {
"category": "color"
}
}
},
{
"destination": "MorfeoSize.h",
"format": "ios/static.h",
"className": "MorfeoSize",
"type": "float",
"filter": {
"attributes": {
"category": "size"
}
}
},
{
"destination": "MorfeoSize.m",
"format": "ios/static.m",
"className": "MorfeoSize",
"type": "float",
"filter": {
"attributes": {
"category": "size"
}
}
}
]
},
"ios-swift": {
"transformGroup": "ios-swift",
"buildPath": "build/ios-swift/",
"files": [
{
"destination": "Morfeo.swift",
"format": "ios-swift/class.swift",
"className": "Morfeo",
"filter": {}
}
]
},
"ios-swift-separate-enums": {
"transformGroup": "ios-swift-separate",
"buildPath": "build/ios-swift/",
"files": [
{
"destination": "MorfeoColor.swift",
"format": "ios-swift/enum.swift",
"className": "MorfeoColor",
"filter": {
"attributes": {
"category": "color"
}
}
},
{
"destination": "MorfeoSize.swift",
"format": "ios-swift/enum.swift",
"className": "MorfeoSize",
"type": "float",
"filter": {
"attributes": {
"category": "size"
}
}
}
]
}
}
}
124 changes: 5 additions & 119 deletions apps/cli/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,126 +4,12 @@
"scss": {
"transformGroup": "scss",
"buildPath": "build/scss/",
"files": [{
"destination": "_variables.scss",
"format": "scss/variables"
}]
},
"android": {
"transformGroup": "android",
"buildPath": "build/android/",
"files": [{
"destination": "font_dimens.xml",
"format": "android/fontDimens"
},{
"destination": "colors.xml",
"format": "android/colors"
}]
},
"compose": {
"transformGroup": "compose",
"buildPath": "build/compose/",
"files": [{
"destination": "StyleDictionaryColor.kt",
"format": "compose/object",
"className": "StyleDictionaryColor",
"packageName": "StyleDictionaryColor",
"filter": {
"attributes": {
"category": "color"
}
"files": [
{
"destination": "_variables.scss",
"format": "scss/variables"
}
},{
"destination": "StyleDictionarySize.kt",
"format": "compose/object",
"className": "StyleDictionarySize",
"packageName": "StyleDictionarySize",
"type": "float",
"filter": {
"attributes": {
"category": "size"
}
}
}]
},
"ios": {
"transformGroup": "ios",
"buildPath": "build/ios/",
"files": [{
"destination": "StyleDictionaryColor.h",
"format": "ios/colors.h",
"className": "StyleDictionaryColor",
"type": "StyleDictionaryColorName",
"filter": {
"attributes": {
"category": "color"
}
}
},{
"destination": "StyleDictionaryColor.m",
"format": "ios/colors.m",
"className": "StyleDictionaryColor",
"type": "StyleDictionaryColorName",
"filter": {
"attributes": {
"category": "color"
}
}
},{
"destination": "StyleDictionarySize.h",
"format": "ios/static.h",
"className": "StyleDictionarySize",
"type": "float",
"filter": {
"attributes": {
"category": "size"
}
}
},{
"destination": "StyleDictionarySize.m",
"format": "ios/static.m",
"className": "StyleDictionarySize",
"type": "float",
"filter": {
"attributes": {
"category": "size"
}
}
}]
},
"ios-swift": {
"transformGroup": "ios-swift",
"buildPath": "build/ios-swift/",
"files": [{
"destination": "StyleDictionary.swift",
"format": "ios-swift/class.swift",
"className": "StyleDictionary",
"filter": {}
}]
},
"ios-swift-separate-enums": {
"transformGroup": "ios-swift-separate",
"buildPath": "build/ios-swift/",
"files": [{
"destination": "StyleDictionaryColor.swift",
"format": "ios-swift/enum.swift",
"className": "StyleDictionaryColor",
"filter": {
"attributes": {
"category": "color"
}
}
},{
"destination": "StyleDictionarySize.swift",
"format": "ios-swift/enum.swift",
"className": "StyleDictionarySize",
"type": "float",
"filter": {
"attributes": {
"category": "size"
}
}
}]
]
}
}
}
10 changes: 8 additions & 2 deletions apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@
},
"devDependencies": {
"@oclif/dev-cli": "^1.26.0",
"@oclif/test": "^1.2.8",
"@types/chai": "^4.2.21",
"@types/mocha": "^5.2.7",
"@types/node": "^10.17.60",
"chai": "^4.3.4",
"eslint": "^5.16.0",
"eslint-config-oclif": "^3.1.0",
"eslint-config-oclif-typescript": "^0.1.0",
"eslint-config-prettier": "^8.3.0",
"globby": "^10.0.2",
"mocha": "^5.2.0",
"nyc": "^14.1.1",
"ts-node": "^8.10.2",
"typescript": "^3.9.10"
},
Expand Down Expand Up @@ -50,9 +57,8 @@
"repository": "https://github.com/VLK-STUDIO/morfeo",
"scripts": {
"postpack": "rm -f oclif.manifest.json",
"posttest": "eslint . --ext .ts --config .eslintrc",
"prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
"test": "echo NO TESTS",
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
"version": "oclif-dev readme && git add README.md"
},
"types": "lib/index.d.ts"
Expand Down
13 changes: 5 additions & 8 deletions apps/cli/src/commands/build.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import * as path from 'path';
import * as StyleDictionary from 'style-dictionary';
import { Command, flags } from '@oclif/command';
import { parser } from '../utils';

StyleDictionary.extend(path.join(__dirname, '../..', 'config.json'));
StyleDictionary.cleanAllPlatforms();
import { morfeoToStyleDictionary } from '../utils';
import { theme } from '@morfeo/web';

export default class Build extends Command {
static description = 'build design tokens based on your theme';
Expand Down Expand Up @@ -41,10 +38,10 @@ export default class Build extends Command {
this.printMissingThemeError();
}

const localThemes = require(path.resolve(themePath));
const localTheme = require(path.resolve(themePath));

const css = parser(localThemes.lightTheme, flags.name);
theme.set(localTheme.default);

this.log(css);
morfeoToStyleDictionary(flags.name);
}
}
1 change: 1 addition & 0 deletions apps/cli/src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './maps';
22 changes: 22 additions & 0 deletions apps/cli/src/constants/maps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ThemeKey } from '@morfeo/web';

type SliceToBeParsed = {
name: ThemeKey;
styleProp: string;
property: string;
};

export const BLACK_LIST: ThemeKey[] = ['components', 'mediaQueries'];

export const TO_BE_PARSED_SLICES_LIST: SliceToBeParsed[] = [
{
name: 'shadows',
styleProp: 'shadow',
property: 'boxShadow',
},
{
name: 'gradients',
styleProp: 'bgGradient',
property: 'background',
},
];
Loading

0 comments on commit 476d48d

Please sign in to comment.