Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const StyleDictionary = require('style-dictionary').extend(__dirname + '/config.json');
const fs = require('fs');
const _ = require('lodash');
const handlebars = require('handlebars');
const pug = require('pug');
console.log('Build started...');
console.log('\n==============================================');
// DECLARE CUSTOM FORMATS VIA CUSTOM TEMPLATE FILES (AND ENGINES)
// These formatting functions are using the Lodash "template" syntax
StyleDictionary.registerFormat({
// REGISTER A CUSTOM FORMAT (to be used for this specific example)
StyleDictionary.registerFormat({
name: 'custom/android/xml',
formatter: function(dictionary) {
return dictionary.allProperties.map(function(prop) {
return `${prop.value}`;
}).join('\n');
}
});
// APPLY THE CONFIGURATION
// IMPORTANT: the registration of custom transforms
// needs to be done _before_ applying the configuration
StyleDictionaryExtended = StyleDictionary.extend(__dirname + '/config.json');
// FINALLY, BUILD ALL THE PLATFORMS
StyleDictionaryExtended.buildAllPlatforms();
console.log('\n==============================================');
console.log('\nBuild completed!');
const del = require('del');
const path = require('path');
/*
Initialize all this modules after style dictionary since they
use StyleDictionary's methods
*/
require('./src/transforms');
require('./src/transformGroups');
require('./src/templates');
require('./src/actions');
// Get the config
const config = require('./style-config.json');
const Dictionary = StyleDictionary.extend(config);
/*
Here we are separating the taks so we can run them
separate as needed. This can be simplified but currently
i'm deleting a bunch of folder to dynamically recreate.
*/
switch (argv.platform) {
case 'web':
del(path.join(__dirname, './build/web/')).then(() => {
Dictionary.buildPlatform('web');
});
break;
case 'ios':
del([
['brand#1', 'brand#2', 'brand#3'].map(function(brand) {
console.log('\n==============================================');
console.log(`\nProcessing: [${platform}] [${brand}]`);
const StyleDictionary = StyleDictionaryPackage.extend(getStyleDictionaryConfig(brand, platform));
if (platform === 'web') {
StyleDictionary.buildPlatform('web/js');
StyleDictionary.buildPlatform('web/json');
StyleDictionary.buildPlatform('web/scss');
} else if (platform === 'ios') {
StyleDictionary.buildPlatform('ios');
} else if (platform === 'android') {
StyleDictionary.buildPlatform('android');
}
StyleDictionary.buildPlatform('styleguide');
console.log('\nEnd processing');
})
})
[CONFIG, DIST_CONFIG].forEach(path => {
const StyleDictionary = require("style-dictionary").extend(path);
transforms.forEach(t => {
console.info(`Registering Transform: '${t.name}'`);
StyleDictionary.registerTransform(t);
});
formats.forEach(f => {
console.info(`Registering Format: '${f.name}'`);
StyleDictionary.registerFormat(f);
});
StyleDictionary.buildAllPlatforms();
});
var fs = require('fs');
var StyleDictionary = require('style-dictionary');
var pwd = process.cwd();
var config = JSON.parse( fs.readFileSync(pwd + '/config.json') );
var sd = StyleDictionary.extend( config );
sd.buildAllPlatforms();
function createArtifactBuilder(tempFile, themeName) {
return StyleDictionary.extend({
source: [tempFile],
platforms: {
scss: {
buildPath: buildPathByPlatform.scss,
files: [
{
destination: `_${themeName}.scss`,
format: "scss/variables"
}
]
},
less: {
buildPath: buildPathByPlatform.less,
files: [
{
destination: `_${themeName}.less`,
require('dotenv').config()
const fetch = require('node-fetch');
const fs = require('fs');
const StyleDictionary = require('style-dictionary').extend('./config.json');
const getStylesArtboard = require('./lib/get-styles-artboard.js');
const getSpacers = require('./lib/get-spacers.js');
const headers = new fetch.Headers();
const devToken = process.env.DEV_TOKEN;
const fileKey = process.argv[2];
const type = process.argv[4];
const spacerArg = process.argv[4];
let spacersId;
if (spacerArg.indexOf('spacers') !== -1) {
spacersId = spacerArg.slice(spacerArg.indexOf('=')+1, spacerArg.length);
}
headers.append('X-Figma-Token', devToken);
configs.forEach(config => {
const configName = path.basename(config, '.config.json');
const themeConfig = JSON.parse(fs.readFileSync(config, 'utf8'));
themeConfig.platforms = getPlatforms(dest, configName);
const dict = require('style-dictionary').extend(themeConfig);
formats.forEach(f => {
dict.registerFormat(f);
})
dict.buildAllPlatforms();
});