Comparing version 3.2.0 to 4.0.0-beta1
@@ -220,8 +220,13 @@ /* | ||
registerFormat("map.scss", function (json, options) { | ||
options = _.defaults({}, options, { | ||
nameSuffix: "-map" | ||
}); | ||
var quotedTypes = ["string", "font"]; | ||
var items = _.map(json.props, function (prop) { | ||
var name = kebabCase(prop.name); | ||
return "\"" + name + "\": " + prop.value; | ||
var value = _.includes(quotedTypes, prop.type) ? "\"" + prop.value + "\"" : prop.value; | ||
return "\"" + name + "\": " + value; | ||
}).join(",\n "); | ||
var basename = path.basename(options.path, path.extname(options.path)).replace(/\..*/g, ""); | ||
var name = "" + basename + "-map"; | ||
var name = "" + basename + "" + options.nameSuffix; | ||
if (_.isFunction(options.name)) { | ||
@@ -237,2 +242,12 @@ var n = options.name(basename, options.path); | ||
registerFormat("map.variables.scss", function (json, options) { | ||
options = _.defaults({}, options, { | ||
nameSuffix: "map-variables" | ||
}); | ||
_.transform(json.props, function (result, value, name, props) { | ||
props[name].value = "$" + kebabCase(name); | ||
}); | ||
return FORMATS["map.scss"](json, options); | ||
}); | ||
registerFormat("sass", function (json) { | ||
@@ -325,100 +340,2 @@ return _.map(json.props, function (prop) { | ||
/** | ||
* Transform legacy Theo Design Props | ||
*/ | ||
legacy: function legacy() { | ||
console.warn("plugins.legacy will be deprecated soon. Please use the updated Design Properties spec: https://github.com/salesforce-ux/theo#spec"); | ||
return through.obj(function (file, enc, next) { | ||
var newFile = file.clone(); | ||
var json; | ||
try { | ||
json = util.parsePropsFile(newFile); | ||
if (_.isArray(json)) { | ||
var err = TheoError("legacy() encountered a non object Design Properties file: " + newFile.path); | ||
return next(err); | ||
} | ||
} catch (e) { | ||
var err = TheoError("legacy() encountered an invalid Design Properties file: " + newFile.path); | ||
return next(err); | ||
} | ||
// Theme | ||
if (_.has(json, "theme")) { | ||
// Properties | ||
if (_.isArray(json.theme.properties)) { | ||
json.props = {}; | ||
for (var i = 0; i < json.theme.properties.length; i++) { | ||
var prop = json.theme.properties[i]; | ||
if (typeof prop.name === "undefined") { | ||
var err = TheoError("legacy() encountered a property with no \"name\" key: " + newFile.path); | ||
return next(err); | ||
} | ||
// Category | ||
if (!_.has(prop, "category")) { | ||
prop.category = ""; | ||
} | ||
// Type | ||
if (!_.has(prop, "type")) { | ||
if (/color/.test(prop.category)) { | ||
prop.type = "color"; | ||
} else if (/(em|rem|px)/.test(prop.value)) { | ||
prop.type = "size"; | ||
} else { | ||
prop.type = ""; | ||
} | ||
} | ||
// Save the prop | ||
var _name = prop.name; | ||
delete prop.name; | ||
json.props[_name] = prop; | ||
} | ||
} | ||
// Aliases | ||
if (_.isString(json.theme.aliases)) { | ||
var p = path.resolve(path.dirname(file.path), json.theme.aliases); | ||
if (fs.existsSync(p)) { | ||
try { | ||
var a = JSON.parse(fs.readFileSync(p).toString()); | ||
if (_.has(a, "aliases") && _.isArray(a.aliases)) { | ||
json.theme.aliases = a.aliases; | ||
} | ||
} catch (e) { | ||
var err = TheoError("legacy() failed to import alias file " + json.theme.aliases); | ||
return next(err); | ||
} | ||
} | ||
} | ||
// Aliases | ||
if (_.isArray(json.theme.aliases)) { | ||
var aliases = json.theme.aliases; | ||
json.aliases = {}; | ||
_.forEach(aliases, function (alias) { | ||
json.aliases[alias.name] = alias.value; | ||
}); | ||
} | ||
// Aura | ||
if (_.isArray(json.theme.imports)) { | ||
json.auraImports = json.theme.imports; | ||
} | ||
if (_.isString(json.theme["extends"])) { | ||
json.auraExtends = json.theme["extends"]; | ||
} | ||
// Cleanup | ||
delete json.theme; | ||
} | ||
// Aliases | ||
if (_.isArray(json.aliases)) { | ||
var aliases = json.aliases; | ||
json.aliases = {}; | ||
_.forEach(aliases, function (alias) { | ||
json.aliases[alias.name] = alias.value; | ||
}); | ||
} | ||
// Done | ||
newFile.contents = new Buffer(JSON.stringify(json, null, 2)); | ||
next(null, newFile); | ||
}); | ||
}, | ||
/** | ||
* Transform the prop values | ||
@@ -425,0 +342,0 @@ * |
@@ -37,3 +37,2 @@ "use strict"; | ||
var defaults = { | ||
includeAlias: false, | ||
includeRawValue: false, | ||
@@ -164,7 +163,2 @@ includeMeta: false, | ||
if (re.test(prop.value)) { | ||
// See if the alias should be included in the prop | ||
if (options.includeAlias === true && isAlias.test(prop.value)) { | ||
console.warn("options.includeAlias will be deprecated soon. Please use options.includeRawValue"); | ||
prop.alias = key; | ||
} | ||
// Reslove the alias | ||
@@ -171,0 +165,0 @@ prop.value = prop.value.replace(re, value); |
{ | ||
"name": "theo", | ||
"version": "3.2.0", | ||
"version": "4.0.0-beta1", | ||
"description": "A set of Gulp plugins for transforming and formatting Design Properties", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -380,3 +380,3 @@ # <img src="https://raw.githubusercontent.com/salesforce-ux/theo/master/assets/theo.png" alt="Theo logo" width="28" /> Theo | ||
{ | ||
"name": "PROP_NAME", | ||
"name": "propName", | ||
"value": "PROP_VALUE", | ||
@@ -390,4 +390,2 @@ "type": "PROP_TYPE", | ||
*Note*: PROP_NAME will be set to [camelCase](https://lodash.com/docs#camelCase) | ||
###### android.xml | ||
@@ -407,32 +405,37 @@ | ||
```scss | ||
$PROP_NAME: PROP_VALUE; | ||
```sass | ||
$prop-name: PROP_VALUE; | ||
``` | ||
*Note*: PROP_NAME will be set to [kebabCase](https://lodash.com/docs#kebabCase) | ||
###### map.scss | ||
###### sass | ||
```sass | ||
$PROP_NAME: PROP_VALUE | ||
$file-name-map: ( | ||
"prop-name-a": PROP_VALUE, | ||
"prop-name-b": "PROP_VALUE" | ||
); | ||
``` | ||
*Note*: PROP_NAME will be set to [kebabCase](https://lodash.com/docs#kebabCase) | ||
*Note*: Properties of types `["string", "font"]` will be wrapped in double quotes | ||
###### less | ||
###### map.variables.scss | ||
```less | ||
@PROP_NAME: PROP_VALUE; | ||
```sass | ||
$file-name-map-variables: ( | ||
"prop-name": $prop-name | ||
); | ||
``` | ||
*Note*: PROP_NAME will be set to [kebabCase](https://lodash.com/docs#kebabCase) | ||
###### sass | ||
###### scss | ||
```sass | ||
$prop-name: PROP_VALUE | ||
``` | ||
```styl | ||
PROP_NAME = PROP_VALUE; | ||
###### less | ||
```less | ||
@prop-name: PROP_VALUE; | ||
``` | ||
*Note*: PROP_NAME will be set to [kebabCase](https://lodash.com/docs#kebabCase) | ||
###### aura.theme | ||
@@ -442,3 +445,3 @@ | ||
<aura:theme> | ||
<aura:var name="PROP_NAME" value="PROP_VALUE" /> | ||
<aura:var name="propName" value="PROP_VALUE" /> | ||
</aura:theme> | ||
@@ -451,8 +454,6 @@ ``` | ||
module.exports = { | ||
PROP_NAME: PROP_VALUE | ||
propName: PROP_VALUE | ||
}; | ||
``` | ||
*Note*: PROP_NAME will be set to [camelCase](https://lodash.com/docs#camelCase) | ||
###### amd.js | ||
@@ -463,3 +464,3 @@ | ||
return { | ||
PROP_NAME: PROP_VALUE | ||
propName: PROP_VALUE | ||
}; | ||
@@ -469,4 +470,2 @@ }); | ||
*Note*: PROP_NAME will be set to [camelCase](https://lodash.com/docs#camelCase) | ||
###### styleguide | ||
@@ -509,15 +508,2 @@ | ||
*** | ||
####`theo.plugins.legacy()` | ||
Transform legacy Theo *Design Properties* to the new spec | ||
#### Example: | ||
```js | ||
gulp.src('./design/props-old.json') | ||
.pipe(theo.plugins.legacy()); | ||
``` | ||
[npm-url]: https://npmjs.org/package/theo | ||
@@ -524,0 +510,0 @@ [npm-image]: http://img.shields.io/npm/v/theo.svg |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71786
1344
1
533