material-icon-theme 4.26.0 → 4.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/material-icons.json +5742 -0
- package/icons/file.svg +1 -0
- package/icons/folder-mojo-open.svg +2 -0
- package/icons/folder-mojo.svg +2 -0
- package/icons/folder-open.svg +1 -0
- package/icons/folder-root-open.svg +1 -0
- package/icons/folder-root.svg +1 -0
- package/icons/folder.svg +1 -0
- package/icons/ifanr-cloud.svg +10 -0
- package/icons/mermaid.svg +4 -0
- package/icons/mojo.svg +2 -0
- package/icons/qwik.svg +2 -0
- package/icons/unocss.svg +12 -0
- package/package.json +7 -1
- package/.eslintignore +0 -1
- package/.eslintrc.json +0 -51
- package/.github/FUNDING.yml +0 -3
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -34
- package/.github/ISSUE_TEMPLATE/icon_request.md +0 -27
- package/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +0 -7
- package/.github/workflows/build.yml +0 -45
- package/.github/workflows/color-check.yml +0 -22
- package/.github/workflows/release.yml +0 -73
- package/.prettierrc +0 -7
- package/.vscode/extensions.json +0 -3
- package/.vscode/launch.json +0 -43
- package/.vscode/settings.json +0 -14
- package/.vscode/tasks.json +0 -32
- package/.vscodeignore +0 -22
- package/CHANGELOG.md +0 -1343
- package/CONTRIBUTING.md +0 -232
- package/build/web-extension.webpack.config.js +0 -62
- package/build/webpack.config.js +0 -39
- package/changelog.config.json +0 -4
- package/images/commandPalette.png +0 -0
- package/images/contributors.png +0 -0
- package/images/fileIcons.png +0 -0
- package/images/folderIcons.png +0 -0
- package/images/how-tos/folder-icon-parts.png +0 -0
- package/images/how-tos/pick-folder-colors.png +0 -0
- package/images/how-tos/pick-folder-colors.svg +0 -301
- package/images/how-tos/svg-folder-icon-with-correct-colors.png +0 -0
- package/images/how-tos/svg-folder-icon-with-wrong-colors.png +0 -0
- package/images/how-tos/svg-with-light-color.png +0 -0
- package/images/how-tos/svg-with-spacing.png +0 -0
- package/images/how-tos/svg-with-too-dark-color.png +0 -0
- package/images/how-tos/svg-with-wrong-color.png +0 -0
- package/images/how-tos/svg-without-spacing.png +0 -0
- package/images/set-folder-color.gif +0 -0
- package/images/set-folder-theme.gif +0 -0
- package/logo.png +0 -0
- package/logo.svg +0 -21
- package/material-colors.yml +0 -257
- package/package.nls.de.json +0 -34
- package/package.nls.es.json +0 -29
- package/package.nls.fr.json +0 -29
- package/package.nls.ja.json +0 -32
- package/package.nls.json +0 -34
- package/package.nls.nl.json +0 -32
- package/package.nls.pl.json +0 -32
- package/package.nls.pt-BR.json +0 -29
- package/package.nls.pt-PT.json +0 -29
- package/package.nls.ru.json +0 -29
- package/package.nls.zh-CN.json +0 -29
- package/package.nls.zh-TW.json +0 -29
- package/src/commands/activate.ts +0 -28
- package/src/commands/explorerArrows.ts +0 -55
- package/src/commands/fileColor.ts +0 -96
- package/src/commands/folderColor.ts +0 -96
- package/src/commands/folders.ts +0 -55
- package/src/commands/grayscale.ts +0 -55
- package/src/commands/iconPacks.ts +0 -64
- package/src/commands/index.ts +0 -32
- package/src/commands/opacity.ts +0 -46
- package/src/commands/restoreConfig.ts +0 -15
- package/src/commands/saturation.ts +0 -46
- package/src/extension.ts +0 -37
- package/src/helpers/changeDetection.ts +0 -109
- package/src/helpers/customIcons.ts +0 -8
- package/src/helpers/fileConfig.ts +0 -38
- package/src/helpers/index.ts +0 -88
- package/src/helpers/objects.ts +0 -58
- package/src/helpers/types.ts +0 -7
- package/src/i18n/index.ts +0 -78
- package/src/i18n/lang-de.ts +0 -45
- package/src/i18n/lang-en.ts +0 -45
- package/src/i18n/lang-es.ts +0 -45
- package/src/i18n/lang-fr.ts +0 -45
- package/src/i18n/lang-ja.ts +0 -45
- package/src/i18n/lang-nl.ts +0 -45
- package/src/i18n/lang-pl.ts +0 -45
- package/src/i18n/lang-pt-br.ts +0 -45
- package/src/i18n/lang-pt-pt.ts +0 -45
- package/src/i18n/lang-ru.ts +0 -45
- package/src/i18n/lang-uk.ts +0 -45
- package/src/i18n/lang-zh-cn.ts +0 -45
- package/src/i18n/lang-zh-tw.ts +0 -45
- package/src/icons/fileIcons.ts +0 -2294
- package/src/icons/folderIcons.ts +0 -835
- package/src/icons/generator/constants.ts +0 -29
- package/src/icons/generator/fileGenerator.ts +0 -233
- package/src/icons/generator/folderGenerator.ts +0 -340
- package/src/icons/generator/iconOpacity.ts +0 -111
- package/src/icons/generator/iconSaturation.ts +0 -140
- package/src/icons/generator/index.ts +0 -7
- package/src/icons/generator/jsonGenerator.ts +0 -207
- package/src/icons/generator/languageGenerator.ts +0 -127
- package/src/icons/index.ts +0 -4
- package/src/icons/languageIcons.ts +0 -144
- package/src/models/i18n/index.ts +0 -1
- package/src/models/i18n/translation.ts +0 -43
- package/src/models/iconConfiguration.ts +0 -37
- package/src/models/icons/defaultIcon.ts +0 -16
- package/src/models/icons/files/fileIcon.ts +0 -49
- package/src/models/icons/files/fileTypes.ts +0 -14
- package/src/models/icons/files/index.ts +0 -2
- package/src/models/icons/folders/folderIcon.ts +0 -34
- package/src/models/icons/folders/folderTheme.ts +0 -23
- package/src/models/icons/folders/index.ts +0 -2
- package/src/models/icons/iconJsonOptions.ts +0 -22
- package/src/models/icons/iconPack.ts +0 -12
- package/src/models/icons/index.ts +0 -6
- package/src/models/icons/languages/index.ts +0 -1
- package/src/models/icons/languages/languageIdentifier.ts +0 -26
- package/src/models/index.ts +0 -3
- package/src/models/scripts/contributors/contributor.ts +0 -22
- package/src/models/scripts/contributors/contributorsConfig.ts +0 -10
- package/src/scripts/contributors/contributors.css +0 -24
- package/src/scripts/contributors/index.ts +0 -138
- package/src/scripts/helpers/painter.ts +0 -5
- package/src/scripts/helpers/screenshots.ts +0 -32
- package/src/scripts/helpers/similarity.ts +0 -47
- package/src/scripts/helpers/titleCase.ts +0 -7
- package/src/scripts/icons/checks/checkIconAvailability.ts +0 -215
- package/src/scripts/icons/checks/checkIconConflicts.ts +0 -152
- package/src/scripts/icons/checks/checkIconUsage.ts +0 -137
- package/src/scripts/icons/checks/index.ts +0 -7
- package/src/scripts/icons/generateJson.ts +0 -11
- package/src/scripts/preview/index.ts +0 -40
- package/src/scripts/preview/preview.ts +0 -163
- package/src/scripts/preview/style.css +0 -48
- package/src/test/runTest.ts +0 -26
- package/src/test/spec/i18n/i18n.spec.ts +0 -54
- package/src/test/spec/icons/fileIcons.spec.ts +0 -250
- package/src/test/spec/icons/folderIcons.spec.ts +0 -418
- package/src/test/spec/icons/languageIcons.spec.ts +0 -184
- package/src/test/spec/index.ts +0 -36
- package/src/web/extension.ts +0 -10
- package/svgo.config.js +0 -12
- package/tsconfig.json +0 -23
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { IconJsonOptions } from './';
|
|
2
|
-
|
|
3
|
-
export class IconConfiguration {
|
|
4
|
-
file?: string;
|
|
5
|
-
folder?: string;
|
|
6
|
-
folderExpanded?: string;
|
|
7
|
-
folderNames?: Record<string, string>;
|
|
8
|
-
folderNamesExpanded?: Record<string, string>;
|
|
9
|
-
rootFolder?: string;
|
|
10
|
-
rootFolderExpanded?: string;
|
|
11
|
-
fileExtensions?: Record<string, string>;
|
|
12
|
-
fileNames?: Record<string, string>;
|
|
13
|
-
languageIds?: Record<string, string>;
|
|
14
|
-
iconDefinitions?: Record<string, any>;
|
|
15
|
-
light?: IconConfiguration;
|
|
16
|
-
highContrast?: IconConfiguration;
|
|
17
|
-
options?: IconJsonOptions;
|
|
18
|
-
hidesExplorerArrows?: boolean;
|
|
19
|
-
|
|
20
|
-
constructor() {
|
|
21
|
-
this.iconDefinitions = {};
|
|
22
|
-
this.folderNames = {};
|
|
23
|
-
this.folderNamesExpanded = {};
|
|
24
|
-
this.fileExtensions = {};
|
|
25
|
-
this.fileNames = {};
|
|
26
|
-
this.languageIds = {};
|
|
27
|
-
this.light = {
|
|
28
|
-
fileExtensions: {},
|
|
29
|
-
fileNames: {},
|
|
30
|
-
};
|
|
31
|
-
this.highContrast = {
|
|
32
|
-
fileExtensions: {},
|
|
33
|
-
fileNames: {},
|
|
34
|
-
};
|
|
35
|
-
this.options = {};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export interface DefaultIcon {
|
|
2
|
-
/**
|
|
3
|
-
* Name of the icon, e.g. 'src'
|
|
4
|
-
*/
|
|
5
|
-
name: string;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Define if there is a light icon available.
|
|
9
|
-
*/
|
|
10
|
-
light?: boolean;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Define if there is a high contrast icon available.
|
|
14
|
-
*/
|
|
15
|
-
highContrast?: boolean;
|
|
16
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { RequireAtLeastOne } from '../../../helpers/types';
|
|
2
|
-
import { IconPack } from '../index';
|
|
3
|
-
|
|
4
|
-
interface BasicFileIcon {
|
|
5
|
-
/**
|
|
6
|
-
* Name of the icon, e.g. 'javascript'
|
|
7
|
-
*/
|
|
8
|
-
name: string;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Define the file extensions that should use this icon.
|
|
12
|
-
* E.g. ['js']
|
|
13
|
-
*/
|
|
14
|
-
fileExtensions?: string[];
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Define if there are some static file names that should apply this icon.
|
|
18
|
-
* E.g. ['sample.js']
|
|
19
|
-
*/
|
|
20
|
-
fileNames?: string[];
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Define if there is a light icon available.
|
|
24
|
-
*/
|
|
25
|
-
light?: boolean;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Define if there is a high contrast icon available.
|
|
29
|
-
*/
|
|
30
|
-
highContrast?: boolean;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Define if the icon should be disabled.
|
|
34
|
-
*/
|
|
35
|
-
disabled?: boolean;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Defines a pack to which this icon belongs. A pack can be toggled and all icons inside this pack can be enabled or disabled together.
|
|
39
|
-
*/
|
|
40
|
-
enabledFor?: IconPack[];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Type for a FileIcon. In addition to the `name` property, either a `fileExtensions` or `fileNames` property is required.
|
|
45
|
-
*/
|
|
46
|
-
export type FileIcon = RequireAtLeastOne<
|
|
47
|
-
BasicFileIcon,
|
|
48
|
-
'fileExtensions' | 'fileNames'
|
|
49
|
-
>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { DefaultIcon } from '../defaultIcon';
|
|
2
|
-
import { FileIcon } from './index';
|
|
3
|
-
|
|
4
|
-
export type FileIcons = {
|
|
5
|
-
/**
|
|
6
|
-
* Define the default icon for folders.
|
|
7
|
-
*/
|
|
8
|
-
defaultIcon: DefaultIcon;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Defines all folder icons.
|
|
12
|
-
*/
|
|
13
|
-
icons: FileIcon[];
|
|
14
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { IconPack } from '../index';
|
|
2
|
-
|
|
3
|
-
export interface FolderIcon {
|
|
4
|
-
/**
|
|
5
|
-
* Name of the icon, e.g. 'src'
|
|
6
|
-
*/
|
|
7
|
-
name: string;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Define the folder names that should apply the icon.
|
|
11
|
-
* E.g. ['src', 'source']
|
|
12
|
-
*/
|
|
13
|
-
folderNames: string[];
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Define if there is a light icon available.
|
|
17
|
-
*/
|
|
18
|
-
light?: boolean;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Define if there is a high contrast icon available.
|
|
22
|
-
*/
|
|
23
|
-
highContrast?: boolean;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Define if the icon should be disabled.
|
|
27
|
-
*/
|
|
28
|
-
disabled?: boolean;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Defines a pack to which this icon belongs. A pack can be toggled and all icons inside this pack can be enabled or disabled together.
|
|
32
|
-
*/
|
|
33
|
-
enabledFor?: IconPack[];
|
|
34
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { DefaultIcon, FolderIcon } from '../index';
|
|
2
|
-
|
|
3
|
-
export interface FolderTheme {
|
|
4
|
-
/**
|
|
5
|
-
* Name of the theme
|
|
6
|
-
*/
|
|
7
|
-
name: string;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Define the default icon for folders in a theme.
|
|
11
|
-
*/
|
|
12
|
-
defaultIcon: DefaultIcon;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Icon for root folders.
|
|
16
|
-
*/
|
|
17
|
-
rootFolder?: DefaultIcon;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Defines folder icons for specific folder names.
|
|
21
|
-
*/
|
|
22
|
-
icons?: FolderIcon[];
|
|
23
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export interface IconJsonOptions {
|
|
2
|
-
activeIconPack?: string;
|
|
3
|
-
hidesExplorerArrows?: boolean;
|
|
4
|
-
opacity?: number;
|
|
5
|
-
saturation?: number;
|
|
6
|
-
folders?: {
|
|
7
|
-
theme?: string;
|
|
8
|
-
color?: string;
|
|
9
|
-
associations?: IconAssociations;
|
|
10
|
-
};
|
|
11
|
-
files?: {
|
|
12
|
-
color?: string;
|
|
13
|
-
associations?: IconAssociations;
|
|
14
|
-
};
|
|
15
|
-
languages?: {
|
|
16
|
-
associations?: IconAssociations;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface IconAssociations {
|
|
21
|
-
[pattern: string]: string;
|
|
22
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './languageIdentifier';
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { DefaultIcon, IconPack } from '../index';
|
|
2
|
-
|
|
3
|
-
export interface LanguageIcon {
|
|
4
|
-
/**
|
|
5
|
-
* Icon for the language identifier
|
|
6
|
-
*/
|
|
7
|
-
icon: DefaultIcon;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Language ID, e.g. 'javascript'
|
|
11
|
-
*
|
|
12
|
-
* According to official VS Code documentation:
|
|
13
|
-
* https://code.visualstudio.com/docs/languages/identifiers
|
|
14
|
-
*/
|
|
15
|
-
ids: string[];
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Define if the icon should be disabled.
|
|
19
|
-
*/
|
|
20
|
-
disabled?: boolean;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Defines a pack to which this icon belongs. A pack can be toggled and all icons inside this pack can be enabled or disabled together.
|
|
24
|
-
*/
|
|
25
|
-
enabledFor?: IconPack[];
|
|
26
|
-
}
|
package/src/models/index.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/* eslint-disable camelcase */
|
|
2
|
-
export interface Contributor {
|
|
3
|
-
login: string;
|
|
4
|
-
id: number;
|
|
5
|
-
node_id: string;
|
|
6
|
-
avatar_url: string;
|
|
7
|
-
gravatar_id: string;
|
|
8
|
-
url: string;
|
|
9
|
-
html_url: string;
|
|
10
|
-
followers_url: string;
|
|
11
|
-
following_url: string;
|
|
12
|
-
gists_url: string;
|
|
13
|
-
starred_url: string;
|
|
14
|
-
subscriptions_url: string;
|
|
15
|
-
organizations_url: string;
|
|
16
|
-
repos_url: string;
|
|
17
|
-
events_url: string;
|
|
18
|
-
received_events_url: string;
|
|
19
|
-
type: string;
|
|
20
|
-
site_admin: boolean;
|
|
21
|
-
contributions: number;
|
|
22
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
body {
|
|
2
|
-
margin: 0;
|
|
3
|
-
padding: 0;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
ul {
|
|
7
|
-
list-style: none;
|
|
8
|
-
margin: 0;
|
|
9
|
-
padding: 0;
|
|
10
|
-
width: 100%;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
li {
|
|
14
|
-
width: 40px;
|
|
15
|
-
height: 40px;
|
|
16
|
-
float: left;
|
|
17
|
-
margin: 3px;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
img {
|
|
21
|
-
width: 100%;
|
|
22
|
-
height: 100%;
|
|
23
|
-
border-radius: 5px;
|
|
24
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { writeFileSync } from 'fs';
|
|
2
|
-
import { request, RequestOptions } from 'https';
|
|
3
|
-
import { join } from 'path';
|
|
4
|
-
import { Contributor } from '../../models/scripts/contributors/contributor';
|
|
5
|
-
import { green, red, yellow } from '../helpers/painter';
|
|
6
|
-
import { createScreenshot } from '../helpers/screenshots';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Parse link header
|
|
10
|
-
* @param linkHeader Link header as string
|
|
11
|
-
* @returns Object that contains the page numbers of `prev`, `next` and `last`.
|
|
12
|
-
*/
|
|
13
|
-
const parseLinkHeader = (linkHeader: string) => {
|
|
14
|
-
const nextPagePattern = new RegExp(/\bpage=(\d)[^>]*>;\srel="next"/);
|
|
15
|
-
const lastPagePattern = new RegExp(/\bpage=(\d)[^>]*>;\srel="last"/);
|
|
16
|
-
const prevPagePattern = new RegExp(/\bpage=(\d)[^>]*>;\srel="prev"/);
|
|
17
|
-
|
|
18
|
-
const nextPage = nextPagePattern.exec(linkHeader) ?? '';
|
|
19
|
-
const lastPage = lastPagePattern.exec(linkHeader) ?? '';
|
|
20
|
-
const prevPage = prevPagePattern.exec(linkHeader) ?? '';
|
|
21
|
-
|
|
22
|
-
return { nextPage, lastPage, prevPage };
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Get all contributors from GitHub API.
|
|
27
|
-
*/
|
|
28
|
-
const fetchContributors = (
|
|
29
|
-
page: string
|
|
30
|
-
): Promise<{ contributorsOfPage: Contributor[]; nextPage: string }> => {
|
|
31
|
-
return new Promise((resolve, reject) => {
|
|
32
|
-
const requestOptions: RequestOptions = {
|
|
33
|
-
method: 'GET',
|
|
34
|
-
hostname: 'api.github.com',
|
|
35
|
-
path: `/repos/pkief/vscode-material-icon-theme/contributors?page=${page}`,
|
|
36
|
-
port: 443,
|
|
37
|
-
headers: {
|
|
38
|
-
link: 'next',
|
|
39
|
-
accept: 'application/json',
|
|
40
|
-
'User-Agent': 'Contributors script',
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const req = request(requestOptions, (res) => {
|
|
45
|
-
const { nextPage, lastPage, prevPage } = parseLinkHeader(
|
|
46
|
-
res.headers?.link?.toString() ?? ''
|
|
47
|
-
);
|
|
48
|
-
console.log(
|
|
49
|
-
'> Material Icon Theme:',
|
|
50
|
-
yellow(
|
|
51
|
-
`[${page}/${
|
|
52
|
-
lastPage ? lastPage[1] : +prevPage[1] + 1
|
|
53
|
-
}] Loading contributors from GitHub...`
|
|
54
|
-
)
|
|
55
|
-
);
|
|
56
|
-
const result: Uint8Array[] = [];
|
|
57
|
-
res.on('data', (data: Buffer) => {
|
|
58
|
-
result.push(data);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
res.on('end', () => {
|
|
62
|
-
try {
|
|
63
|
-
const buffer = Buffer.concat(result);
|
|
64
|
-
const bufferAsString = buffer.toString('utf8');
|
|
65
|
-
const contributorsOfPage = JSON.parse(bufferAsString);
|
|
66
|
-
resolve({ contributorsOfPage, nextPage: nextPage?.[1] });
|
|
67
|
-
} catch (error) {
|
|
68
|
-
reject(error);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
req.on('error', (error) => {
|
|
74
|
-
console.error(error);
|
|
75
|
-
reject(error);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
req.end();
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const createContributorsList = (contributors: Contributor[]) => {
|
|
83
|
-
const list = contributors
|
|
84
|
-
.map((c) => {
|
|
85
|
-
return `<li title="${c.login}"><img src="${c.avatar_url}" alt="${c.login}"/></li>`;
|
|
86
|
-
})
|
|
87
|
-
.join('\n');
|
|
88
|
-
|
|
89
|
-
const htmlDoctype = '<!DOCTYPE html>';
|
|
90
|
-
const styling = '<link rel="stylesheet" href="contributors.css">';
|
|
91
|
-
const generatedHtml = `${htmlDoctype}${styling}<ul>${list}</ul>`;
|
|
92
|
-
|
|
93
|
-
const outputPath = join(__dirname, 'contributors.html');
|
|
94
|
-
writeFileSync(outputPath, generatedHtml);
|
|
95
|
-
return outputPath;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const init = async () => {
|
|
99
|
-
const contributorsList: Contributor[] = [];
|
|
100
|
-
let page = '1';
|
|
101
|
-
|
|
102
|
-
// iterate over the pages of GitHub API
|
|
103
|
-
while (page !== undefined) {
|
|
104
|
-
const result = await fetchContributors(page);
|
|
105
|
-
contributorsList.push(...result.contributorsOfPage);
|
|
106
|
-
page = result.nextPage;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (contributorsList.length > 0) {
|
|
110
|
-
console.log(
|
|
111
|
-
'> Material Icon Theme:',
|
|
112
|
-
green('Successfully fetched all contributors from GitHub!')
|
|
113
|
-
);
|
|
114
|
-
} else {
|
|
115
|
-
console.log(
|
|
116
|
-
'> Material Icon Theme:',
|
|
117
|
-
red('Error: Could not fetch contributors from GitHub!')
|
|
118
|
-
);
|
|
119
|
-
throw Error();
|
|
120
|
-
}
|
|
121
|
-
const outputPath = createContributorsList(contributorsList);
|
|
122
|
-
|
|
123
|
-
// create the image
|
|
124
|
-
console.log('> Material Icon Theme:', yellow('Creating image...'));
|
|
125
|
-
const fileName = 'contributors';
|
|
126
|
-
createScreenshot(outputPath, fileName)
|
|
127
|
-
.then(() => {
|
|
128
|
-
console.log(
|
|
129
|
-
'> Material Icon Theme:',
|
|
130
|
-
green(`Successfully created ${fileName} image!`)
|
|
131
|
-
);
|
|
132
|
-
})
|
|
133
|
-
.catch(() => {
|
|
134
|
-
throw Error(red(`Error while creating ${fileName} image`));
|
|
135
|
-
});
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
init();
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { join } from 'path';
|
|
2
|
-
import Puppeteer from 'puppeteer';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Create a screenshot from an HTML file and save it as image.
|
|
6
|
-
* @param filePath Path of an HTML file
|
|
7
|
-
* @param fileName Name of the output image
|
|
8
|
-
*/
|
|
9
|
-
export const createScreenshot = async (filePath: string, fileName: string) => {
|
|
10
|
-
try {
|
|
11
|
-
const htmlFilePath = join('file:', filePath);
|
|
12
|
-
const browser = await Puppeteer.launch();
|
|
13
|
-
const page = await browser.newPage();
|
|
14
|
-
await page.setViewport({
|
|
15
|
-
height: 10,
|
|
16
|
-
width: 1000,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
await page.goto(htmlFilePath);
|
|
20
|
-
|
|
21
|
-
await page.screenshot({
|
|
22
|
-
path: `images/${fileName}.png`,
|
|
23
|
-
omitBackground: true,
|
|
24
|
-
fullPage: true,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
await browser.close();
|
|
28
|
-
} catch (error) {
|
|
29
|
-
console.error(error);
|
|
30
|
-
throw Error('Could not create screenshot for a preview');
|
|
31
|
-
}
|
|
32
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compares two strings and returns the Levenshtein distance
|
|
3
|
-
* @see https://stackoverflow.com/a/36566052/6942210
|
|
4
|
-
* @param s1 Text string
|
|
5
|
-
* @param s2 text string
|
|
6
|
-
*/
|
|
7
|
-
export const similarity = (s1: string, s2: string) => {
|
|
8
|
-
let longer = s1;
|
|
9
|
-
let shorter = s2;
|
|
10
|
-
if (s1.length < s2.length) {
|
|
11
|
-
longer = s2;
|
|
12
|
-
shorter = s1;
|
|
13
|
-
}
|
|
14
|
-
const longerLength = longer.length;
|
|
15
|
-
if (longerLength === 0) {
|
|
16
|
-
return 1.0;
|
|
17
|
-
}
|
|
18
|
-
return (longerLength - editDistance(longer, shorter)) / longerLength;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const editDistance = (s1: string, s2: string) => {
|
|
22
|
-
s1 = s1.toLowerCase();
|
|
23
|
-
s2 = s2.toLowerCase();
|
|
24
|
-
|
|
25
|
-
const costs = new Array<number>();
|
|
26
|
-
for (let i = 0; i <= s1.length; i++) {
|
|
27
|
-
let lastValue = i;
|
|
28
|
-
for (let j = 0; j <= s2.length; j++) {
|
|
29
|
-
if (i === 0) {
|
|
30
|
-
costs[j] = j;
|
|
31
|
-
} else {
|
|
32
|
-
if (j > 0) {
|
|
33
|
-
let newValue = costs[j - 1];
|
|
34
|
-
if (s1.charAt(i - 1) !== s2.charAt(j - 1)) {
|
|
35
|
-
newValue = Math.min(Math.min(newValue, lastValue), costs[j]) + 1;
|
|
36
|
-
}
|
|
37
|
-
costs[j - 1] = lastValue;
|
|
38
|
-
lastValue = newValue;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (i > 0) {
|
|
43
|
-
costs[s2.length] = lastValue;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return costs[s2.length];
|
|
47
|
-
};
|