mirror of
				https://github.com/ikatyang/emoji-cheat-sheet.git
				synced 2025-05-29 01:49:25 +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:
 | 
					script:
 | 
				
			||||||
- yarn run lint
 | 
					- yarn run lint
 | 
				
			||||||
 | 
					- yarn run format-check
 | 
				
			||||||
- yarn run test -- --verbose --coverage
 | 
					- yarn run test -- --verbose --coverage
 | 
				
			||||||
 | 
					
 | 
				
			||||||
after_success:
 | 
					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": {
 | 
					  "scripts": {
 | 
				
			||||||
    "lint": "tslint -p ./tsconfig.json",
 | 
					    "lint": "tslint -p ./tsconfig.json",
 | 
				
			||||||
    "test": "jest -c ./jest.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": {
 | 
					  "dependencies": {
 | 
				
			||||||
    "cheerio": "^0.22.0",
 | 
					    "cheerio": "^0.22.0",
 | 
				
			||||||
@ -17,15 +19,20 @@
 | 
				
			|||||||
  },
 | 
					  },
 | 
				
			||||||
  "devDependencies": {
 | 
					  "devDependencies": {
 | 
				
			||||||
    "@types/cheerio": "0.22.2",
 | 
					    "@types/cheerio": "0.22.2",
 | 
				
			||||||
 | 
					    "@types/gulp": "3.8.33",
 | 
				
			||||||
    "@types/jest": "20.0.4",
 | 
					    "@types/jest": "20.0.4",
 | 
				
			||||||
    "@types/node": "8.0.15",
 | 
					    "@types/node": "8.0.15",
 | 
				
			||||||
 | 
					    "@types/prettier": "1.5.0",
 | 
				
			||||||
    "@types/request": "2.0.0",
 | 
					    "@types/request": "2.0.0",
 | 
				
			||||||
 | 
					    "gulp": "3.9.1",
 | 
				
			||||||
 | 
					    "gulp-plugin-prettier": "1.0.0",
 | 
				
			||||||
    "jest": "20.0.4",
 | 
					    "jest": "20.0.4",
 | 
				
			||||||
    "jest-playback": "1.0.0",
 | 
					    "jest-playback": "1.0.0",
 | 
				
			||||||
 | 
					    "prettier": "1.5.3",
 | 
				
			||||||
    "ts-jest": "20.0.7",
 | 
					    "ts-jest": "20.0.7",
 | 
				
			||||||
    "ts-node": "3.2.1",
 | 
					    "ts-node": "3.2.1",
 | 
				
			||||||
    "tslint": "5.5.0",
 | 
					    "tslint": "5.5.0",
 | 
				
			||||||
    "tslint-config-ikatyang": "0.10.0",
 | 
					    "tslint-config-ikatyang": "1.0.1",
 | 
				
			||||||
    "typescript": "2.4.2"
 | 
					    "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 () => {
 | 
					test('create-cheat-sheet', async () => {
 | 
				
			||||||
  const cheat_sheet = await create_cheat_sheet();
 | 
					  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 = [
 | 
					const url_descriptions = [
 | 
				
			||||||
  ['GitHub Emoji API', api_url],
 | 
					  ['GitHub Emoji API', api_url],
 | 
				
			||||||
  ['Emoji Cheat Sheet', sheet_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
 | 
					// tslint:disable-next-line:max-line-length
 | 
				
			||||||
const description = `This cheat sheet is automatically generated from ${url_descriptions}`;
 | 
					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) => {
 | 
					  $html.find('h2').each((_outer_index, category_element) => {
 | 
				
			||||||
    const emojis: string[] = [];
 | 
					    const emojis: string[] = [];
 | 
				
			||||||
    const category = $(category_element).text();
 | 
					    const category = $(category_element).text();
 | 
				
			||||||
    $html.find(`#emoji-${category.toLowerCase()} li .name`).each((_inner_index, emoji_element) => {
 | 
					    $html
 | 
				
			||||||
      const emoji = $(emoji_element).text();
 | 
					      .find(`#emoji-${category.toLowerCase()} li .name`)
 | 
				
			||||||
      const index = api_emojis.indexOf(emoji);
 | 
					      .each((_inner_index, emoji_element) => {
 | 
				
			||||||
      if (index !== -1) {
 | 
					        const emoji = $(emoji_element).text();
 | 
				
			||||||
        api_emojis.splice(index, 1);
 | 
					        const index = api_emojis.indexOf(emoji);
 | 
				
			||||||
        emojis.push(emoji);
 | 
					        if (index !== -1) {
 | 
				
			||||||
      }
 | 
					          api_emojis.splice(index, 1);
 | 
				
			||||||
    });
 | 
					          emojis.push(emoji);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
    emoji_table[category] = emojis;
 | 
					    emoji_table[category] = emojis;
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -82,10 +86,12 @@ function create_table(emoji_table: EmojiTable) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    ## ${toc_name}
 | 
					    ## ${toc_name}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ${categories.map(category => `- [${category}](#${category.toLowerCase()})`).join('\n')}
 | 
					    ${categories
 | 
				
			||||||
 | 
					      .map(category => `- [${category}](#${category.toLowerCase()})`)
 | 
				
			||||||
 | 
					      .join('\n')}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ${
 | 
					    ${categories
 | 
				
			||||||
      categories.map(category => {
 | 
					      .map(category => {
 | 
				
			||||||
        const emojis = emoji_table[category];
 | 
					        const emojis = emoji_table[category];
 | 
				
			||||||
        return format(`
 | 
					        return format(`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -95,8 +101,8 @@ function create_table(emoji_table: EmojiTable) {
 | 
				
			|||||||
          ${create_table_content(emojis)}
 | 
					          ${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(`
 | 
					    table_content += `${format(`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    | [${top_name}](${top_href}) |${
 | 
					    | [${top_name}](${top_href}) |${row_emojis
 | 
				
			||||||
      row_emojis.map(
 | 
					      .map(
 | 
				
			||||||
        emoji => emoji.length !== 0
 | 
					        emoji => (emoji.length !== 0 ? ` :${emoji}: | \`:${emoji}:\` ` : ' | '),
 | 
				
			||||||
          ? ` :${emoji}: | \`:${emoji}:\` `
 | 
					      )
 | 
				
			||||||
          : ' | ',
 | 
					      .join(' | ')}|
 | 
				
			||||||
      ).join(' | ')
 | 
					 | 
				
			||||||
    }|
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    `)}\n`;
 | 
					    `)}\n`;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -126,26 +130,29 @@ function create_table_content(emojis: string[]) {
 | 
				
			|||||||
function create_table_head() {
 | 
					function create_table_head() {
 | 
				
			||||||
  return format(`
 | 
					  return format(`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  |   |${(' ico | emoji |').repeat(column_divisions)}
 | 
					  |   |${' ico | emoji |'.repeat(column_divisions)}
 | 
				
			||||||
  | - |${(' --- | ----- |').repeat(column_divisions)}
 | 
					  | - |${' --- | ----- |'.repeat(column_divisions)}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  `);
 | 
					  `);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function format(str: string) {
 | 
					function format(str: string) {
 | 
				
			||||||
  return str.trim().replace(/^ +/mg, '');
 | 
					  return str.trim().replace(/^ +/gm, '');
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function get_html(url: string) {
 | 
					async function get_html(url: string) {
 | 
				
			||||||
  return new Promise<string>((resolve, reject) => {
 | 
					  return new Promise<string>((resolve, reject) => {
 | 
				
			||||||
    const options = {url};
 | 
					    const options = { url };
 | 
				
			||||||
    if (url === api_url) {
 | 
					    if (url === api_url) {
 | 
				
			||||||
      Object.assign(options, {
 | 
					      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) => {
 | 
					    request.get(options, (error, response, html) => {
 | 
				
			||||||
      // istanbul ignore next
 | 
					      // istanbul ignore next
 | 
				
			||||||
 | 
					      // tslint:disable-next-line:early-exit
 | 
				
			||||||
      if (!error && response.statusCode === 200) {
 | 
					      if (!error && response.statusCode === 200) {
 | 
				
			||||||
        resolve(html);
 | 
					        resolve(html);
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user