mirror of
https://github.com/ikatyang/emoji-cheat-sheet.git
synced 2024-12-05 06:24:38 +08:00
chore(deps): Update tslint-config-ikatyang from 0.10.0 to 1.0.1 (#13)
* Update tslint-config-ikatyang from 0.10.0 to 1.0.1 * chore: add prettier * style: reformat with prettier * chore(package): update @types/node to version 8.0.15
This commit is contained in:
parent
85538dadaf
commit
d7eca0f9fe
@ -5,6 +5,7 @@ node_js:
|
||||
|
||||
script:
|
||||
- yarn run lint
|
||||
- yarn run format-check
|
||||
- yarn run test -- --verbose --coverage
|
||||
|
||||
after_success:
|
||||
|
21
gulpfile.ts
Normal file
21
gulpfile.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import * as gulp from 'gulp';
|
||||
import * as prettier from 'gulp-plugin-prettier';
|
||||
import * as prettier_options from 'tslint-config-ikatyang/prettier';
|
||||
|
||||
// tslint:disable-next-line:no-var-requires
|
||||
const sources = require('./tsconfig.json').include;
|
||||
|
||||
gulp.task('format', () =>
|
||||
gulp
|
||||
.src(sources)
|
||||
.pipe(prettier.format(prettier_options, { filter: true }))
|
||||
.pipe(gulp.dest(file => file.base)),
|
||||
);
|
||||
|
||||
gulp.task('format-check', () =>
|
||||
gulp
|
||||
.src(sources)
|
||||
.pipe(
|
||||
prettier.format(prettier_options, { reporter: prettier.Reporter.Error }),
|
||||
),
|
||||
);
|
11
package.json
11
package.json
@ -9,7 +9,9 @@
|
||||
"scripts": {
|
||||
"lint": "tslint -p ./tsconfig.json",
|
||||
"test": "jest -c ./jest.json",
|
||||
"generate": "ts-node ./scripts/generate.ts ./README.md"
|
||||
"generate": "ts-node ./scripts/generate.ts ./README.md",
|
||||
"format": "gulp format",
|
||||
"format-check": "gulp format-check"
|
||||
},
|
||||
"dependencies": {
|
||||
"cheerio": "^0.22.0",
|
||||
@ -17,15 +19,20 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/cheerio": "0.22.2",
|
||||
"@types/gulp": "3.8.33",
|
||||
"@types/jest": "20.0.4",
|
||||
"@types/node": "8.0.15",
|
||||
"@types/prettier": "1.5.0",
|
||||
"@types/request": "2.0.0",
|
||||
"gulp": "3.9.1",
|
||||
"gulp-plugin-prettier": "1.0.0",
|
||||
"jest": "20.0.4",
|
||||
"jest-playback": "1.0.0",
|
||||
"prettier": "1.5.3",
|
||||
"ts-jest": "20.0.7",
|
||||
"ts-node": "3.2.1",
|
||||
"tslint": "5.5.0",
|
||||
"tslint-config-ikatyang": "0.10.0",
|
||||
"tslint-config-ikatyang": "1.0.1",
|
||||
"typescript": "2.4.2"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {create_cheat_sheet} from './create-cheat-sheet';
|
||||
import { create_cheat_sheet } from './create-cheat-sheet';
|
||||
|
||||
test('create-cheat-sheet', async () => {
|
||||
const cheat_sheet = await create_cheat_sheet();
|
||||
|
@ -18,7 +18,9 @@ const travis_badge_url = `https://travis-ci.org/${repo_author}/${repo_name}.svg?
|
||||
const url_descriptions = [
|
||||
['GitHub Emoji API', api_url],
|
||||
['Emoji Cheat Sheet', sheet_url],
|
||||
].map(([site_name, site_url]) => `[${site_name}](${site_url})`).join(' and ');
|
||||
]
|
||||
.map(([site_name, site_url]) => `[${site_name}](${site_url})`)
|
||||
.join(' and ');
|
||||
|
||||
// tslint:disable-next-line:max-line-length
|
||||
const description = `This cheat sheet is automatically generated from ${url_descriptions}`;
|
||||
@ -51,14 +53,16 @@ export async function create_cheat_sheet() {
|
||||
$html.find('h2').each((_outer_index, category_element) => {
|
||||
const emojis: string[] = [];
|
||||
const category = $(category_element).text();
|
||||
$html.find(`#emoji-${category.toLowerCase()} li .name`).each((_inner_index, emoji_element) => {
|
||||
const emoji = $(emoji_element).text();
|
||||
const index = api_emojis.indexOf(emoji);
|
||||
if (index !== -1) {
|
||||
api_emojis.splice(index, 1);
|
||||
emojis.push(emoji);
|
||||
}
|
||||
});
|
||||
$html
|
||||
.find(`#emoji-${category.toLowerCase()} li .name`)
|
||||
.each((_inner_index, emoji_element) => {
|
||||
const emoji = $(emoji_element).text();
|
||||
const index = api_emojis.indexOf(emoji);
|
||||
if (index !== -1) {
|
||||
api_emojis.splice(index, 1);
|
||||
emojis.push(emoji);
|
||||
}
|
||||
});
|
||||
emoji_table[category] = emojis;
|
||||
});
|
||||
|
||||
@ -82,10 +86,12 @@ function create_table(emoji_table: EmojiTable) {
|
||||
|
||||
## ${toc_name}
|
||||
|
||||
${categories.map(category => `- [${category}](#${category.toLowerCase()})`).join('\n')}
|
||||
${categories
|
||||
.map(category => `- [${category}](#${category.toLowerCase()})`)
|
||||
.join('\n')}
|
||||
|
||||
${
|
||||
categories.map(category => {
|
||||
${categories
|
||||
.map(category => {
|
||||
const emojis = emoji_table[category];
|
||||
return format(`
|
||||
|
||||
@ -95,8 +101,8 @@ function create_table(emoji_table: EmojiTable) {
|
||||
${create_table_content(emojis)}
|
||||
|
||||
`);
|
||||
}).join(('\n').repeat(2))
|
||||
}
|
||||
})
|
||||
.join('\n'.repeat(2))}
|
||||
|
||||
`);
|
||||
}
|
||||
@ -110,13 +116,11 @@ function create_table_content(emojis: string[]) {
|
||||
}
|
||||
table_content += `${format(`
|
||||
|
||||
| [${top_name}](${top_href}) |${
|
||||
row_emojis.map(
|
||||
emoji => emoji.length !== 0
|
||||
? ` :${emoji}: | \`:${emoji}:\` `
|
||||
: ' | ',
|
||||
).join(' | ')
|
||||
}|
|
||||
| [${top_name}](${top_href}) |${row_emojis
|
||||
.map(
|
||||
emoji => (emoji.length !== 0 ? ` :${emoji}: | \`:${emoji}:\` ` : ' | '),
|
||||
)
|
||||
.join(' | ')}|
|
||||
|
||||
`)}\n`;
|
||||
}
|
||||
@ -126,26 +130,29 @@ function create_table_content(emojis: string[]) {
|
||||
function create_table_head() {
|
||||
return format(`
|
||||
|
||||
| |${(' ico | emoji |').repeat(column_divisions)}
|
||||
| - |${(' --- | ----- |').repeat(column_divisions)}
|
||||
| |${' ico | emoji |'.repeat(column_divisions)}
|
||||
| - |${' --- | ----- |'.repeat(column_divisions)}
|
||||
|
||||
`);
|
||||
}
|
||||
|
||||
function format(str: string) {
|
||||
return str.trim().replace(/^ +/mg, '');
|
||||
return str.trim().replace(/^ +/gm, '');
|
||||
}
|
||||
|
||||
async function get_html(url: string) {
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
const options = {url};
|
||||
const options = { url };
|
||||
if (url === api_url) {
|
||||
Object.assign(options, {
|
||||
headers: {'User-Agent': 'https://github.com/ikatyang/emoji-cheat-sheet'},
|
||||
headers: {
|
||||
'User-Agent': 'https://github.com/ikatyang/emoji-cheat-sheet',
|
||||
},
|
||||
});
|
||||
}
|
||||
request.get(options, (error, response, html) => {
|
||||
// istanbul ignore next
|
||||
// tslint:disable-next-line:early-exit
|
||||
if (!error && response.statusCode === 200) {
|
||||
resolve(html);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user