PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/app/assets/javascripts/vue_shared/components/file_icon/file_icon_map.js

https://gitlab.com/gitlab-r2devops/gitlab-foss
JavaScript | 610 lines | 607 code | 3 blank | 0 comment | 0 complexity | 275ccdf234c5f400c537b5bddf01553e MD5 | raw file
  1. const fileExtensionIcons = {
  2. html: 'html',
  3. htm: 'html',
  4. html_vm: 'html',
  5. asp: 'html',
  6. jade: 'pug',
  7. pug: 'pug',
  8. md: 'markdown',
  9. markdown: 'markdown',
  10. mdown: 'markdown',
  11. mkd: 'markdown',
  12. mkdn: 'markdown',
  13. rst: 'markdown',
  14. blink: 'blink',
  15. css: 'css',
  16. scss: 'sass',
  17. sass: 'sass',
  18. less: 'less',
  19. json: 'json',
  20. yaml: 'yaml',
  21. yml: 'yaml',
  22. xml: 'xml',
  23. plist: 'xml',
  24. xsd: 'xml',
  25. dtd: 'xml',
  26. xsl: 'xml',
  27. xslt: 'xml',
  28. resx: 'xml',
  29. iml: 'xml',
  30. xquery: 'xml',
  31. tmLanguage: 'xml',
  32. manifest: 'xml',
  33. project: 'xml',
  34. png: 'image',
  35. jpeg: 'image',
  36. jpg: 'image',
  37. gif: 'image',
  38. svg: 'image',
  39. ico: 'image',
  40. tif: 'image',
  41. tiff: 'image',
  42. psd: 'image',
  43. psb: 'image',
  44. ami: 'image',
  45. apx: 'image',
  46. bmp: 'image',
  47. bpg: 'image',
  48. brk: 'image',
  49. cur: 'image',
  50. dds: 'image',
  51. dng: 'image',
  52. exr: 'image',
  53. fpx: 'image',
  54. gbr: 'image',
  55. img: 'image',
  56. jbig2: 'image',
  57. jb2: 'image',
  58. jng: 'image',
  59. jxr: 'image',
  60. pbm: 'image',
  61. pgf: 'image',
  62. pic: 'image',
  63. raw: 'image',
  64. webp: 'image',
  65. js: 'javascript',
  66. ejs: 'javascript',
  67. esx: 'javascript',
  68. jsx: 'react',
  69. tsx: 'react',
  70. ini: 'settings',
  71. dlc: 'settings',
  72. dll: 'settings',
  73. config: 'settings',
  74. conf: 'settings',
  75. properties: 'settings',
  76. prop: 'settings',
  77. settings: 'settings',
  78. option: 'settings',
  79. props: 'settings',
  80. toml: 'settings',
  81. prefs: 'settings',
  82. ts: 'typescript',
  83. marko: 'markojs',
  84. pdf: 'pdf',
  85. xlsx: 'table',
  86. xls: 'table',
  87. ods: 'table',
  88. csv: 'table',
  89. tsv: 'table',
  90. vscodeignore: 'vscode',
  91. vsixmanifest: 'vscode',
  92. vsix: 'vscode',
  93. suo: 'visualstudio',
  94. sln: 'visualstudio',
  95. csproj: 'visualstudio',
  96. vb: 'visualstudio',
  97. pdb: 'database',
  98. sql: 'database',
  99. pks: 'database',
  100. pkb: 'database',
  101. accdb: 'database',
  102. mdb: 'database',
  103. sqlite: 'database',
  104. cs: 'csharp',
  105. zip: 'zip',
  106. tar: 'zip',
  107. gz: 'zip',
  108. xz: 'zip',
  109. bzip2: 'zip',
  110. gzip: 'zip',
  111. rar: 'zip',
  112. tgz: 'zip',
  113. exe: 'exe',
  114. msi: 'exe',
  115. java: 'java',
  116. jar: 'java',
  117. jsp: 'java',
  118. c: 'c',
  119. m: 'c',
  120. h: 'h',
  121. cc: 'cpp',
  122. cpp: 'cpp',
  123. mm: 'cpp',
  124. cxx: 'cpp',
  125. hpp: 'hpp',
  126. go: 'go',
  127. py: 'python',
  128. url: 'url',
  129. sh: 'console',
  130. ksh: 'console',
  131. csh: 'console',
  132. tcsh: 'console',
  133. zsh: 'console',
  134. bash: 'console',
  135. bat: 'console',
  136. cmd: 'console',
  137. ps1: 'powershell',
  138. psm1: 'powershell',
  139. psd1: 'powershell',
  140. ps1xml: 'powershell',
  141. psc1: 'powershell',
  142. pssc: 'powershell',
  143. gradle: 'gradle',
  144. doc: 'word',
  145. docx: 'word',
  146. odt: 'word',
  147. rtf: 'word',
  148. cer: 'certificate',
  149. cert: 'certificate',
  150. crt: 'certificate',
  151. pub: 'key',
  152. key: 'key',
  153. pem: 'key',
  154. asc: 'key',
  155. gpg: 'key',
  156. woff: 'font',
  157. woff2: 'font',
  158. ttf: 'font',
  159. eot: 'font',
  160. suit: 'font',
  161. otf: 'font',
  162. bmap: 'font',
  163. fnt: 'font',
  164. odttf: 'font',
  165. ttc: 'font',
  166. font: 'font',
  167. fonts: 'font',
  168. sui: 'font',
  169. ntf: 'font',
  170. mrf: 'font',
  171. lib: 'lib',
  172. bib: 'lib',
  173. rb: 'ruby',
  174. erb: 'ruby',
  175. fs: 'fsharp',
  176. fsx: 'fsharp',
  177. fsi: 'fsharp',
  178. fsproj: 'fsharp',
  179. swift: 'swift',
  180. ino: 'arduino',
  181. dockerignore: 'docker',
  182. dockerfile: 'docker',
  183. tex: 'tex',
  184. cls: 'tex',
  185. sty: 'tex',
  186. pptx: 'powerpoint',
  187. ppt: 'powerpoint',
  188. pptm: 'powerpoint',
  189. potx: 'powerpoint',
  190. pot: 'powerpoint',
  191. potm: 'powerpoint',
  192. ppsx: 'powerpoint',
  193. ppsm: 'powerpoint',
  194. pps: 'powerpoint',
  195. ppam: 'powerpoint',
  196. ppa: 'powerpoint',
  197. odp: 'powerpoint',
  198. webm: 'movie',
  199. mkv: 'movie',
  200. flv: 'movie',
  201. vob: 'movie',
  202. ogv: 'movie',
  203. ogg: 'music',
  204. gifv: 'movie',
  205. avi: 'movie',
  206. mov: 'movie',
  207. qt: 'movie',
  208. wmv: 'movie',
  209. yuv: 'movie',
  210. rm: 'movie',
  211. rmvb: 'movie',
  212. mp4: 'movie',
  213. m4v: 'movie',
  214. mpg: 'movie',
  215. mp2: 'movie',
  216. mpeg: 'movie',
  217. mpe: 'movie',
  218. mpv: 'movie',
  219. m2v: 'movie',
  220. vdi: 'virtual',
  221. vbox: 'virtual',
  222. ics: 'email',
  223. mp3: 'music',
  224. flac: 'music',
  225. m4a: 'music',
  226. wma: 'music',
  227. aiff: 'music',
  228. coffee: 'coffee',
  229. txt: 'document',
  230. graphql: 'graphql',
  231. rs: 'rust',
  232. raml: 'raml',
  233. xaml: 'xaml',
  234. hs: 'haskell',
  235. kt: 'kotlin',
  236. kts: 'kotlin',
  237. patch: 'git',
  238. lua: 'lua',
  239. clj: 'clojure',
  240. cljs: 'clojure',
  241. groovy: 'groovy',
  242. r: 'r',
  243. rmd: 'r',
  244. dart: 'dart',
  245. as: 'actionscript',
  246. mxml: 'mxml',
  247. ahk: 'autohotkey',
  248. swf: 'flash',
  249. swc: 'swc',
  250. cmake: 'cmake',
  251. asm: 'assembly',
  252. a51: 'assembly',
  253. inc: 'assembly',
  254. nasm: 'assembly',
  255. s: 'assembly',
  256. ms: 'assembly',
  257. agc: 'assembly',
  258. ags: 'assembly',
  259. aea: 'assembly',
  260. argus: 'assembly',
  261. mitigus: 'assembly',
  262. binsource: 'assembly',
  263. vue: 'vue',
  264. ml: 'ocaml',
  265. mli: 'ocaml',
  266. cmx: 'ocaml',
  267. lock: 'lock',
  268. hbs: 'handlebars',
  269. mustache: 'handlebars',
  270. pl: 'perl',
  271. pm: 'perl',
  272. hx: 'haxe',
  273. pp: 'puppet',
  274. ex: 'elixir',
  275. exs: 'elixir',
  276. ls: 'livescript',
  277. erl: 'erlang',
  278. twig: 'twig',
  279. jl: 'julia',
  280. elm: 'elm',
  281. pure: 'purescript',
  282. tpl: 'smarty',
  283. styl: 'stylus',
  284. re: 'reason',
  285. rei: 'reason',
  286. cmj: 'bucklescript',
  287. merlin: 'merlin',
  288. v: 'verilog',
  289. vhd: 'verilog',
  290. sv: 'verilog',
  291. svh: 'verilog',
  292. nb: 'mathematica',
  293. wl: 'wolframlanguage',
  294. wls: 'wolframlanguage',
  295. njk: 'nunjucks',
  296. nunjucks: 'nunjucks',
  297. robot: 'robot',
  298. sol: 'solidity',
  299. au3: 'autoit',
  300. haml: 'haml',
  301. yang: 'yang',
  302. tf: 'terraform',
  303. tfvars: 'terraform',
  304. tfstate: 'terraform',
  305. applescript: 'applescript',
  306. cake: 'cake',
  307. feature: 'cucumber',
  308. nim: 'nim',
  309. nimble: 'nim',
  310. apib: 'apiblueprint',
  311. apiblueprint: 'apiblueprint',
  312. tag: 'riot',
  313. vfl: 'vfl',
  314. kl: 'kl',
  315. pcss: 'postcss',
  316. sss: 'postcss',
  317. todo: 'todo',
  318. cfml: 'coldfusion',
  319. cfc: 'coldfusion',
  320. lucee: 'coldfusion',
  321. cabal: 'cabal',
  322. nix: 'nix',
  323. slim: 'slim',
  324. http: 'http',
  325. rest: 'http',
  326. rql: 'restql',
  327. restql: 'restql',
  328. kv: 'kivy',
  329. graphcool: 'graphcool',
  330. sbt: 'sbt',
  331. cr: 'crystal',
  332. cu: 'cuda',
  333. cuh: 'cuda',
  334. log: 'log',
  335. };
  336. const twoFileExtensionIcons = {
  337. 'gradle.kts': 'gradle',
  338. 'md.rendered': 'markdown',
  339. 'markdown.rendered': 'markdown',
  340. 'mdown.rendered': 'markdown',
  341. 'mkd.rendered': 'markdown',
  342. 'mkdn.rendered': 'markdown',
  343. 'YAML-tmLanguage': 'yaml',
  344. 'sln.dotsettings': 'settings',
  345. 'sln.dotsettings.user': 'settings',
  346. 'd.ts': 'typescript-def',
  347. 'code-workplace': 'vscode',
  348. '7z': 'zip',
  349. 'c++': 'cpp',
  350. 'vbox-prev': 'virtual',
  351. 'js.map': 'javascript-map',
  352. 'css.map': 'css-map',
  353. 'spec.ts': 'test-ts',
  354. 'test.ts': 'test-ts',
  355. 'ts.snap': 'test-ts',
  356. 'spec.tsx': 'test-jsx',
  357. 'test.tsx': 'test-jsx',
  358. 'tsx.snap': 'test-jsx',
  359. 'spec.jsx': 'test-jsx',
  360. 'test.jsx': 'test-jsx',
  361. 'jsx.snap': 'test-jsx',
  362. 'spec.js': 'test-js',
  363. 'test.js': 'test-js',
  364. 'js.snap': 'test-js',
  365. 'routing.ts': 'angular-routing',
  366. 'routing.js': 'angular-routing',
  367. 'module.ts': 'angular',
  368. 'module.js': 'angular',
  369. 'ng-template': 'angular',
  370. 'component.ts': 'angular-component',
  371. 'component.js': 'angular-component',
  372. 'guard.ts': 'angular-guard',
  373. 'guard.js': 'angular-guard',
  374. 'service.ts': 'angular-service',
  375. 'service.js': 'angular-service',
  376. 'pipe.ts': 'angular-pipe',
  377. 'pipe.js': 'angular-pipe',
  378. 'filter.js': 'angular-pipe',
  379. 'directive.ts': 'angular-directive',
  380. 'directive.js': 'angular-directive',
  381. 'resolver.ts': 'angular-resolver',
  382. 'resolver.js': 'angular-resolver',
  383. 'tf.json': 'terraform',
  384. 'blade.php': 'laravel',
  385. 'inky.php': 'laravel',
  386. 'reducer.ts': 'ngrx-reducer',
  387. 'rootReducer.ts': 'ngrx-reducer',
  388. 'state.ts': 'ngrx-state',
  389. 'actions.ts': 'ngrx-actions',
  390. 'effects.ts': 'ngrx-effects',
  391. 'drone.yml': 'drone',
  392. };
  393. const fileNameIcons = {
  394. '.jscsrc': 'json',
  395. '.jshintrc': 'json',
  396. 'tsconfig.json': 'json',
  397. 'tslint.json': 'json',
  398. 'composer.lock': 'json',
  399. '.jsbeautifyrc': 'json',
  400. '.esformatter': 'json',
  401. 'cdp.pid': 'json',
  402. '.htaccess': 'xml',
  403. '.jshintignore': 'settings',
  404. '.buildignore': 'settings',
  405. makefile: 'settings',
  406. '.mrconfig': 'settings',
  407. '.yardopts': 'settings',
  408. 'gradle.properties': 'gradle',
  409. gradlew: 'gradle',
  410. 'gradle-wrapper.properties': 'gradle',
  411. COPYING: 'certificate',
  412. 'COPYING.LESSER': 'certificate',
  413. LICENSE: 'certificate',
  414. LICENCE: 'certificate',
  415. 'LICENSE.md': 'certificate',
  416. 'LICENCE.md': 'certificate',
  417. 'LICENSE.txt': 'certificate',
  418. 'LICENCE.txt': 'certificate',
  419. '.gitlab-license': 'certificate',
  420. dockerfile: 'docker',
  421. 'docker-compose.yml': 'docker',
  422. '.mailmap': 'email',
  423. '.gitignore': 'git',
  424. '.gitconfig': 'git',
  425. '.gitattributes': 'git',
  426. '.gitmodules': 'git',
  427. '.gitkeep': 'git',
  428. 'git-history': 'git',
  429. '.Rhistory': 'r',
  430. 'cmakelists.txt': 'cmake',
  431. 'cmakecache.txt': 'cmake',
  432. 'angular-cli.json': 'angular',
  433. '.angular-cli.json': 'angular',
  434. '.vfl': 'vfl',
  435. '.kl': 'kl',
  436. 'postcss.config.js': 'postcss',
  437. '.postcssrc.js': 'postcss',
  438. 'project.graphcool': 'graphcool',
  439. 'webpack.js': 'webpack',
  440. 'webpack.ts': 'webpack',
  441. 'webpack.base.js': 'webpack',
  442. 'webpack.base.ts': 'webpack',
  443. 'webpack.config.js': 'webpack',
  444. 'webpack.config.ts': 'webpack',
  445. 'webpack.common.js': 'webpack',
  446. 'webpack.common.ts': 'webpack',
  447. 'webpack.config.common.js': 'webpack',
  448. 'webpack.config.common.ts': 'webpack',
  449. 'webpack.config.common.babel.js': 'webpack',
  450. 'webpack.config.common.babel.ts': 'webpack',
  451. 'webpack.dev.js': 'webpack',
  452. 'webpack.dev.ts': 'webpack',
  453. 'webpack.config.dev.js': 'webpack',
  454. 'webpack.config.dev.ts': 'webpack',
  455. 'webpack.config.dev.babel.js': 'webpack',
  456. 'webpack.config.dev.babel.ts': 'webpack',
  457. 'webpack.prod.js': 'webpack',
  458. 'webpack.prod.ts': 'webpack',
  459. 'webpack.server.js': 'webpack',
  460. 'webpack.server.ts': 'webpack',
  461. 'webpack.client.js': 'webpack',
  462. 'webpack.client.ts': 'webpack',
  463. 'webpack.config.server.js': 'webpack',
  464. 'webpack.config.server.ts': 'webpack',
  465. 'webpack.config.client.js': 'webpack',
  466. 'webpack.config.client.ts': 'webpack',
  467. 'webpack.config.production.babel.js': 'webpack',
  468. 'webpack.config.production.babel.ts': 'webpack',
  469. 'webpack.config.prod.babel.js': 'webpack',
  470. 'webpack.config.prod.babel.ts': 'webpack',
  471. 'webpack.config.prod.js': 'webpack',
  472. 'webpack.config.prod.ts': 'webpack',
  473. 'webpack.config.production.js': 'webpack',
  474. 'webpack.config.production.ts': 'webpack',
  475. 'webpack.config.staging.js': 'webpack',
  476. 'webpack.config.staging.ts': 'webpack',
  477. 'webpack.config.babel.js': 'webpack',
  478. 'webpack.config.babel.ts': 'webpack',
  479. 'webpack.config.base.babel.js': 'webpack',
  480. 'webpack.config.base.babel.ts': 'webpack',
  481. 'webpack.config.base.js': 'webpack',
  482. 'webpack.config.base.ts': 'webpack',
  483. 'webpack.config.staging.babel.js': 'webpack',
  484. 'webpack.config.staging.babel.ts': 'webpack',
  485. 'webpack.config.coffee': 'webpack',
  486. 'webpack.config.test.js': 'webpack',
  487. 'webpack.config.test.ts': 'webpack',
  488. 'webpack.config.vendor.js': 'webpack',
  489. 'webpack.config.vendor.ts': 'webpack',
  490. 'webpack.config.vendor.production.js': 'webpack',
  491. 'webpack.config.vendor.production.ts': 'webpack',
  492. 'webpack.test.js': 'webpack',
  493. 'webpack.test.ts': 'webpack',
  494. 'webpack.dist.js': 'webpack',
  495. 'webpack.dist.ts': 'webpack',
  496. 'webpackfile.js': 'webpack',
  497. 'webpackfile.ts': 'webpack',
  498. 'ionic.config.json': 'ionic',
  499. '.io-config.json': 'ionic',
  500. 'gulpfile.js': 'gulp',
  501. 'gulpfile.ts': 'gulp',
  502. 'gulpfile.babel.js': 'gulp',
  503. 'package.json': 'nodejs',
  504. 'package-lock.json': 'nodejs',
  505. '.nvmrc': 'nodejs',
  506. '.npmignore': 'npm',
  507. '.npmrc': 'npm',
  508. '.yarnrc': 'yarn',
  509. '.yarnrc.yml': 'yarn',
  510. 'yarn.lock': 'yarn',
  511. '.yarnclean': 'yarn',
  512. '.yarn-integrity': 'yarn',
  513. 'yarn-error.log': 'yarn',
  514. 'androidmanifest.xml': 'android',
  515. '.env': 'tune',
  516. '.env.example': 'tune',
  517. '.babelrc': 'babel',
  518. 'contributing.md': 'contributing',
  519. 'contributing.md.rendered': 'contributing',
  520. 'readme.md': 'readme',
  521. 'readme.md.rendered': 'readme',
  522. changelog: 'changelog',
  523. 'changelog.md': 'changelog',
  524. 'changelog.md.rendered': 'changelog',
  525. CREDITS: 'credits',
  526. 'credits.txt': 'credits',
  527. 'credits.md': 'credits',
  528. 'credits.md.rendered': 'credits',
  529. '.flowconfig': 'flow',
  530. 'favicon.png': 'favicon',
  531. 'karma.conf.js': 'karma',
  532. 'karma.conf.ts': 'karma',
  533. 'karma.conf.coffee': 'karma',
  534. 'karma.config.js': 'karma',
  535. 'karma.config.ts': 'karma',
  536. 'karma-main.js': 'karma',
  537. 'karma-main.ts': 'karma',
  538. '.bithoundrc': 'bithound',
  539. 'appveyor.yml': 'appveyor',
  540. '.travis.yml': 'travis',
  541. 'protractor.conf.js': 'protractor',
  542. 'protractor.conf.ts': 'protractor',
  543. 'protractor.conf.coffee': 'protractor',
  544. 'protractor.config.js': 'protractor',
  545. 'protractor.config.ts': 'protractor',
  546. 'fuse.js': 'fusebox',
  547. procfile: 'heroku',
  548. '.editorconfig': 'editorconfig',
  549. '.gitlab-ci.yml': 'gitlab',
  550. '.bowerrc': 'bower',
  551. 'bower.json': 'bower',
  552. '.eslintrc.js': 'eslint',
  553. '.eslintrc.yaml': 'eslint',
  554. '.eslintrc.yml': 'eslint',
  555. '.eslintrc.json': 'eslint',
  556. '.eslintrc': 'eslint',
  557. '.eslintignore': 'eslint',
  558. 'code_of_conduct.md': 'conduct',
  559. 'code_of_conduct.md.rendered': 'conduct',
  560. '.watchmanconfig': 'watchman',
  561. 'aurelia.json': 'aurelia',
  562. 'mocha.opts': 'mocha',
  563. jenkinsfile: 'jenkins',
  564. 'firebase.json': 'firebase',
  565. '.firebaserc': 'firebase',
  566. Rakefile: 'ruby',
  567. 'rollup.config.js': 'rollup',
  568. 'rollup.config.ts': 'rollup',
  569. 'rollup-config.js': 'rollup',
  570. 'rollup-config.ts': 'rollup',
  571. 'rollup.config.prod.js': 'rollup',
  572. 'rollup.config.prod.ts': 'rollup',
  573. 'rollup.config.dev.js': 'rollup',
  574. 'rollup.config.dev.ts': 'rollup',
  575. 'rollup.config.prod.vendor.js': 'rollup',
  576. 'rollup.config.prod.vendor.ts': 'rollup',
  577. '.hhconfig': 'hack',
  578. '.stylelintrc': 'stylelint',
  579. 'stylelint.config.js': 'stylelint',
  580. '.stylelintrc.json': 'stylelint',
  581. '.stylelintrc.yaml': 'stylelint',
  582. '.stylelintrc.yml': 'stylelint',
  583. '.stylelintrc.js': 'stylelint',
  584. '.stylelintignore': 'stylelint',
  585. '.codeclimate.yml': 'code-climate',
  586. '.prettierrc': 'prettier',
  587. 'prettier.config.js': 'prettier',
  588. '.prettierrc.js': 'prettier',
  589. '.prettierrc.json': 'prettier',
  590. '.prettierrc.yaml': 'prettier',
  591. '.prettierrc.yml': 'prettier',
  592. '.prettierignore': 'prettier',
  593. 'nodemon.json': 'nodemon',
  594. '.sonarrc': 'sonar',
  595. browserslist: 'browserlist',
  596. '.browserslistrc': 'browserlist',
  597. '.snyk': 'snyk',
  598. '.drone.yml': 'drone',
  599. };
  600. export default function getIconForFile(name) {
  601. return (
  602. fileNameIcons[name] ||
  603. twoFileExtensionIcons[name ? name.split('.').slice(-2).join('.') : ''] ||
  604. fileExtensionIcons[name ? name.split('.').pop().toLowerCase() : ''] ||
  605. ''
  606. );
  607. }