Skip to content
This repository has been archived by the owner on Aug 18, 2023. It is now read-only.

Commit

Permalink
🔧
Browse files Browse the repository at this point in the history
  • Loading branch information
eramdam committed Sep 10, 2016
1 parent a924ade commit 7205567
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 89 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
gulpfile.*
tools/**/*.js
tools/**/*.json
src/emojis/emojis.js
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@
"start": "cross-env NODE_ENV=dev && gulp",
"build": "cross-env NODE_ENV=dev && gulp build",
"build:prod": "rimraf dist/ && cross-env NODE_ENV=prod && gulp build --type production && zip -qr -9 -X dist.zip dist/",
"bs-options": "browser-sync start --server 'dist/options/' --files 'dist/options/**/*'"
"pack": "node tools/pack.js"
},
"homepage": "https://github.com/eramdam/BetterTweetDeck",
"devDependencies": {
"dependencies": {
"babel-core": ">=6.2.1",
"babel-plugin-transform-es2015-modules-commonjs": ">=6.2.0",
"babel-preset-es2015": ">=6.1.18",
"babelify": ">=7.2.0",
"browser-sync": "^2.12.10",
"browserify": ">=11.0.1",
"chalk": "^1.1.3",
"config": "^1.17.1",
"config-browserify": "^1.0.5",
"cross-env": "^2.0.1",
"crx": "^3.0.3",
"cssnano": "^3.5.2",
"del": ">=1.2.1",
"domify": "^1.4.0",
"eslint": "^2.9.0",
"eslint-config-airbnb-base": "^3.0.0",
"eslint-plugin-import": "^1.7.0",
Expand Down Expand Up @@ -56,14 +60,10 @@
"promise-each": "^2.2.0",
"query-string": "^4.2.1",
"reuse-promise": "^1.0.1",
"rimraf": "^2.5.4",
"run-sequence": ">=1.1.2",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": ">=1.1.0",
"vinyl-transform": "^1.0.0"
},
"dependencies": {
"cross-env": "^2.0.1",
"domify": "^1.4.0",
"rimraf": "^2.5.4"
}
}
46 changes: 46 additions & 0 deletions tools/pack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const chalk = require('chalk');
const clog = (color, ...args) => console.log(chalk[color](...args));
const fs = require('fs');
const path = require('path');

if (!process.argv[2]) {
clog('red', 'Please provide a private key file');
process.exit();
}

const privateKeyPath = path.resolve(process.argv[2]);
const extensionPath = path.resolve(__dirname, '../dist');
const ChromeExtension = require('crx');
const crx = new ChromeExtension({
privateKey: fs.readFileSync(privateKeyPath),
});


clog('blue', `Loading extension from ${extensionPath} with key from ${privateKeyPath}`);

crx.load(extensionPath)
.then((d) => {
clog('blue', 'Loaded', d.manifest.short_name, d.manifest.version);

return crx.pack().then(buffer => {
fs.writeFile(path.resolve(__dirname, '../packed/', 'better-tweetdeck.crx'), buffer, (err) => {
if (err) {
clog('red', err);
}

clog('green', 'Saved better-tweetdeck.crx');
});
fs.writeFile(path.resolve(__dirname, '../packed/', 'better-tweetdeck.nex'), buffer, (err) => {
if (err) {
clog('red', err);
}

clog('green', 'Saved better-tweetdeck.nex');
});
});
}, (err) => {
if (err) {
clog('red', err);
clog('blue', 'Try to run `npm run build` before executing this script');
}
});
49 changes: 0 additions & 49 deletions tools/pack.sh

This file was deleted.

53 changes: 21 additions & 32 deletions tools/update_emojis.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const needle = require('needle');
const _ = require('lodash');
const jsEmoji = require('js-emoji');
Expand All @@ -12,41 +10,32 @@ function getUnified(emoji) {

const converted = Emoji.replace_colons(`:${emoji.s}:`);

if (converted !== `:${emoji.s}:` && !converted.startsWith('<img'))
if (converted !== `:${emoji.s}:` && !converted.startsWith('<img')) {
return converted;
}

return null;
}

function getImage(emoji) {
Emoji.replace_mode = 'css';
Emoji.supports_css = true;
Emoji.use_sheet = true;

return Emoji.replace_colons(`:${emoji.s}:`);
}

function getEmojiElement(emoji) {
return `<a href="#" data-string="${getUnified(emoji)}" title="${emoji.name}" class="btd-emoji">${getImage(emoji)}</a>`;
}

const catOrder = {
'People': -80,
'Nature': -70,
'Foods': -60,
'Activity': -50,
'Places': -40,
'Objects': -30,
'Symbols': -20,
'Flags': -10
People: -80,
Nature: -70,
Foods: -60,
Activity: -50,
Places: -40,
Objects: -30,
Symbols: -20,
Flags: -10,
};

const getMissingCategory = (short_name) => {
if (short_name === 'keycap_star')
const getMissingCategory = (shortName) => {
if (shortName === 'keycap_star') {
return 'Symbols';
}

if (short_name.startsWith('flag-'))
if (shortName.startsWith('flag-')) {
return 'Flags';
}

return null;
};
Expand All @@ -60,16 +49,16 @@ needle.get('https://raw.githubusercontent.com/iamcal/emoji-data/master/emoji.jso
.sortBy(emoji => catOrder[emoji.category])
.map(emoji => {
return {
s: emoji.short_name,
s: emoji.shortName,
n: emoji.name,
hs: Boolean(emoji.skin_variations),
cat: emoji.category || getMissingCategory(emoji.s_name)
}
cat: emoji.category || getMissingCategory(emoji.s_name),
};
})
.value();

const finalForTemplate = final.filter(emoji => getUnified(emoji));
const outStr = `module.exports = ${JSON.stringify(finalForTemplate)}`;
const finalForTemplate = final.filter(emoji => getUnified(emoji));
const outStr = `module.exports = ${JSON.stringify(finalForTemplate)}`;

fs.writeFileSync('./src/emojis/emojis.js', outStr, 'utf8');
fs.writeFileSync('./src/emojis/emojis.js', outStr, 'utf8');
});

0 comments on commit 7205567

Please sign in to comment.