Skip to content

Commit

Permalink
Merge 78b13f1 into fb66124
Browse files Browse the repository at this point in the history
  • Loading branch information
adamszalapski authored Jan 9, 2019
2 parents fb66124 + 78b13f1 commit 0921ee8
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs-site/.incache

Large diffs are not rendered by default.

23 changes: 11 additions & 12 deletions packages/components/bolt-icon/icon.schema.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$schema: http://json-schema.org/draft-04/schema#
$schema: 'http://json-schema.org/draft-04/schema#'
title: Icon
type: object
required:
Expand All @@ -8,7 +8,6 @@ properties:
type: string
description: Icon name.
enum:
#todo: dynamically generate or reference these
- academy
- add-open
- add-solid
Expand All @@ -30,16 +29,16 @@ properties:
- calendar
- careers
- case-management
- check
- check-circle
- check-solid
- check
- chevron-down
- chevron-left
- chevron-right
- chevron-up
- close
- close-open
- close-solid
- close
- cloud
- co-browse
- communications
Expand All @@ -53,14 +52,14 @@ properties:
- email
- energy
- entertainment
- exit-full screen
- exit-full-screen
- external-link
- eye-off
- eye
- facebook-solid
- eye-off
- facebook
- field-service-gray
- facebook-solid
- field-service
- field-service-gray
- filter
- financial
- full-screen
Expand All @@ -79,14 +78,14 @@ properties:
- knowledgebase
- launchpad
- life-sciences
- linkedin-solid
- linkedin
- linkedin-solid
- lock
- manufacturing
- map-pin-solid
- map-pin
- marketing-gray
- map-pin-solid
- marketing
- marketing-gray
- menu
- minus-open
- minus-solid
Expand All @@ -113,8 +112,8 @@ properties:
- system-admin
- training
- transportation
- twitter-solid
- twitter
- twitter-solid
- unlock
- upload
- user
Expand Down
30 changes: 30 additions & 0 deletions packages/components/bolt-icons/build-icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const path = require('path');
const cheerio = require('cheerio');
const prettier = require('prettier');
const SVGO = require('svgo');
const yaml = require('js-yaml');
const { getConfig } = require('../../build-tools/utils/config-store');

const svgo = new SVGO({
plugins: [
Expand Down Expand Up @@ -260,6 +262,7 @@ async function build() {
allExports.join('\n'),
'utf-8',
);
generateFile(icons);
console.log(`Built ${iconPaths.length} icons.`);
} catch (error) {
console.error(error);
Expand All @@ -270,4 +273,31 @@ async function build() {
}
}

async function generateFile(icons) {
try {
const config = await getConfig();
const names = icons.map(icon => icon.id);
const schema = yaml.safeLoad(
fs.readFileSync('../bolt-icon/icon.schema.yml', 'utf8'),
);
schema.properties.name.enum = names;
// update bolt-icon schema with newest icons from svgs folder
await fs.writeFile('../bolt-icon/icon.schema.yml', yaml.safeDump(schema));
// generate `icons.bolt.json` file with newest icons array
await fs.writeFile(
path.join(__dirname, '../../../', config.dataDir, 'icons.bolt.json'),
JSON.stringify(names, null, 4),
);
console.log('Config:', config);
console.log('Dir Name:', __dirname);
console.log(`Icon Schema updated and Icons JSON generated.`);
} catch (error) {
console.error(error);
console.error(
'Error trying to generate Icon YAML document for "@bolt/components-icon".',
);
process.exitCode = 1;
}
}

build();
1 change: 1 addition & 0 deletions packages/components/bolt-icons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"cheerio": "^1.0.0-rc.2",
"fs-extra": "^5.0.0",
"globby": "^8.0.1",
"js-yaml": "^3.12.1",
"nodemon": "^1.15.1",
"prettier": "^1.7.4",
"svgo": "^1.0.5",
Expand Down
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8604,6 +8604,14 @@ js-yaml@^3.10.0, js-yaml@^3.12.0, js-yaml@^3.4.3, js-yaml@^3.5.2, js-yaml@^3.7.0
argparse "^1.0.7"
esprima "^4.0.0"

js-yaml@^3.12.1:
version "3.12.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.1.tgz#295c8632a18a23e054cf5c9d3cecafe678167600"
integrity sha512-um46hB9wNOKlwkHgiuyEVAybXBjwFUV0Z/RaHJblRd9DXltue9FTYvzCr9ErQrK9Adz5MU4gHWVaNUfdmrC8qA==
dependencies:
argparse "^1.0.7"
esprima "^4.0.0"

jsbn@~0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
Expand Down

0 comments on commit 0921ee8

Please sign in to comment.