Skip to content

Commit

Permalink
feat(chore): fix compile issues and split FA 5 and 6+
Browse files Browse the repository at this point in the history
This PR fixes current compile issues and splits the version selection between FA 5 and 6
Currently only the latest 5 versions are selectable which means there isnt any 5.x being displayed anymore.
  • Loading branch information
lubber-de authored Sep 28, 2022
1 parent f8ab775 commit 209b3f5
Show file tree
Hide file tree
Showing 20 changed files with 200 additions and 75 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ Once downloaded you will be prompt with a few questions which will allow you to
Select which FontAweome icon set you want
```console
Which icons set would you like to generate?
> FontAwesome Free
> FontAwesome 5 Free
> FontAwesome 6+ Free
FontAwesome Pro
```
> NOTE: You need a license to generate the icons from FontAweome Pro
> NOTE: You need a license to generate the icons from FontAwesome Pro

Next select which version you want to use
```console
Which version of FontAwesome Free should we download?
Which version of FontAwesome 5 Free should we download?
> 5.8.1
5.8.0
5.7.2
Expand Down
22 changes: 17 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
// tasks
var InitialPrompt_1 = __importDefault(require("./tasks/InitialPrompt"));
Expand Down
8 changes: 4 additions & 4 deletions lib/modals/Category.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ var Category = /** @class */ (function () {
get: function () {
return this.data.name;
},
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(Category.prototype, "name", {
get: function () {
return this.data.label;
},
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(Category.prototype, "description", {
get: function () {
return categories_json_1.default[this.rawName];
},
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(Category.prototype, "icons", {
get: function () {
return this.data.icons;
},
enumerable: true,
enumerable: false,
configurable: true
});
return Category;
Expand Down
12 changes: 6 additions & 6 deletions lib/modals/Icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var Icon = /** @class */ (function () {
get: function () {
return this.data.name;
},
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(Icon.prototype, "name", {
Expand All @@ -45,7 +45,7 @@ var Icon = /** @class */ (function () {
? this.correction('name')
: Converter_1.default.iconName(name);
},
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(Icon.prototype, "className", {
Expand All @@ -54,7 +54,7 @@ var Icon = /** @class */ (function () {
? this.correction('className')
: Converter_1.default.iconClassName(this.name);
},
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(Icon.prototype, "unicode", {
Expand All @@ -63,21 +63,21 @@ var Icon = /** @class */ (function () {
? this.correction('unicode')
: "\\" + this.data.unicode;
},
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(Icon.prototype, "type", {
get: function () {
return this.data.type;
},
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(Icon.prototype, "searchTerms", {
get: function () {
return this.data.searchTerms.join(', ');
},
enumerable: true,
enumerable: false,
configurable: true
});
return Icon;
Expand Down
21 changes: 18 additions & 3 deletions lib/parsers/FontAwesome.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
Expand Down Expand Up @@ -31,6 +43,7 @@ function parse(results, paths) {
var parseSpinner = Logger_1.spinner()
.start('parsing icons');
var fontAwesomeDirectoryName = results.iconSet.name.toLowerCase()
.replace(/\d+\+* /g, '')
.replace(/\s/g, '-');
var fontAwesomeDirectory = fontAwesomeDirectoryName + "-" + asset.version + "-web";
var iconsMetadataFilePath = path_1.resolve(paths.assetDirectoryPath, fontAwesomeDirectory, 'metadata', 'icons.json');
Expand Down Expand Up @@ -96,9 +109,11 @@ function parse(results, paths) {
parseSpinner.text = 'parsing categories';
fse.readFile(categoriesFilePath, function (categoriesErr, categoriesData) {
if (!categoriesErr) {
var categoriesMetadata_1 = js_yaml_1.safeLoad(categoriesData.toString());
var categoriesMetadata_1 = js_yaml_1.load(categoriesData.toString());
// @ts-ignore
var categoryNames = Object.keys(categoriesMetadata_1);
categoryNames.forEach(function (categoryName) {
// @ts-ignore
var categoryMeta = categoriesMetadata_1[categoryName];
var categoryIcons = [];
categoryMeta.icons.forEach(function (iconName) {
Expand Down
16 changes: 14 additions & 2 deletions lib/static/icon_sets.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
[
{
"name": "FontAwesome Free",
"name": "FontAwesome 5 Free",
"repo": "FortAwesome/Font-Awesome",
"requiresAuth": false,
"assetMatch": "fontawesome-free-\\d+\\.\\d+\\.\\d+-web\\.zip",
"assetMatch": "fontawesome-free-5\\.\\d+\\.\\d+-web\\.zip",
"parser": "FontAwesome",
"types": [
"solid",
"outline",
"brand"
]
},
{
"name": "FontAwesome 6+ Free",
"repo": "FortAwesome/Font-Awesome",
"requiresAuth": false,
"assetMatch": "fontawesome-free-(?:[6789]|\\d{2})\\.\\d+\\.\\d+-web\\.zip",
"parser": "FontAwesome",
"types": [
"solid",
Expand Down
32 changes: 24 additions & 8 deletions lib/tasks/BuildDist.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
Object.defineProperty(exports, "__esModule", { value: true });
// node
var path_1 = require("path");
// npm
var liquidjs_1 = __importDefault(require("liquidjs"));
var liquidjs_1 = require("liquidjs");
var fse = __importStar(require("fs-extra"));
// utils
var Logger_1 = __importStar(require("../util/Logger"));
Expand All @@ -22,7 +38,7 @@ function run(results, parseResults) {
Logger_1.default.log();
var distSpinner = Logger_1.spinner()
.start('building dist');
var engine = new liquidjs_1.default({
var engine = new liquidjs_1.Liquid({
root: path_1.resolve(__dirname, '../../src/templates'),
extname: '.liquid',
});
Expand Down Expand Up @@ -80,7 +96,7 @@ function run(results, parseResults) {
fse.mkdirp(results.distPath)
.then(function () {
Promise
.all(templateFileRenderFuncs.concat([
.all(__spreadArrays(templateFileRenderFuncs, [
copyAssetsFunc,
]))
.then(function () {
Expand Down
16 changes: 14 additions & 2 deletions lib/tasks/CleanUp.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
Expand Down
23 changes: 18 additions & 5 deletions lib/tasks/DownloadAsset.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.startDownload = exports.downloadAsset = exports.saveAssetFile = exports.extractAsset = void 0;
// node
var path_1 = require("path");
var os_1 = require("os");
Expand Down
6 changes: 5 additions & 1 deletion lib/tasks/InitialPrompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.askForDistPath = exports.selectIconSetVersion = exports.askWhichIconSet = exports.askForAccessToken = void 0;
// node
var path_1 = require("path");
// npm
Expand Down Expand Up @@ -68,7 +69,7 @@ function selectIconSetVersion(iconSet, accessToken) {
};
return new Promise(function (resolve) {
axios_1.default
.get("https://api.github.com/repos/" + iconSet.repo + "/releases?page=1&per_page=5", axiosConfig)
.get("https://api.github.com/repos/" + iconSet.repo + "/releases?page=1&per_page=50", axiosConfig)
.then(function (_a) {
var status = _a.status, data = _a.data;
if (status === 200) {
Expand All @@ -85,6 +86,9 @@ function selectIconSetVersion(iconSet, accessToken) {
var regex = new RegExp(iconSet.assetMatch);
return regex.test(a.name);
})[0];
if (versions_1.length >= 10) {
return;
}
versions_1.push({
name: asset.name,
id: asset.id,
Expand Down
23 changes: 8 additions & 15 deletions lib/util/Converter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
// @ts-ignore
var num_words_1 = __importDefault(require("num-words"));
var Converter = /** @class */ (function () {
function Converter() {
}
Expand All @@ -22,9 +27,8 @@ var Converter = /** @class */ (function () {
.replace(/\s/g, '.')
.split('.')
.map(function (entity) {
var replacementKeys = Object.keys(Converter.CLASSNAME_REPLACEMENTS);
return replacementKeys.includes(entity)
? Converter.CLASSNAME_REPLACEMENTS[entity]
return Converter.NUMERIC_ONLY.test(entity)
? num_words_1.default(entity)
: entity;
})
.join('.');
Expand All @@ -33,18 +37,7 @@ var Converter = /** @class */ (function () {
return Converter.iconClassName(name)
.replace(/\./g, ' ');
};
Converter.CLASSNAME_REPLACEMENTS = {
0: 'zero',
1: 'one',
2: 'two',
3: 'three',
4: 'four',
5: 'five',
6: 'six',
7: 'seven',
8: 'eight',
9: 'nine',
};
Converter.NUMERIC_ONLY = /^\d+$/;
return Converter;
}());
exports.default = Converter;
Loading

0 comments on commit 209b3f5

Please sign in to comment.