Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
;
const TEMPLATE = "(function (root) {\n"
+ " var GitHubColors = __GITHUB_COLORS__;\n"
+ " __GITHUB_POLYGLOT__\n"
+ "})(window);";
// Configurations
GitHubColors.init();
var ghPolyglot = Fs.readFileSync(__dirname + "/../lib/index.js", "utf-8")
, lines = ghPolyglot.split("\n")
, replace = {
__GITHUB_POLYGLOT__: lines.slice(lines.indexOf("/**")).join("\n")
, __GITHUB_COLORS__: "{ get: " + GitHubColors.get.toString() + ",\n"
+ "colors: " + JSON.stringify(GitHubColors.colors) + "}"
}
, client = TEMPLATE
;
Object.keys(replace).forEach(function (c) {
client = client.replace(new RegExp(c), replace[c]);
});
client = client.replace("module.exports = ", "root.GitHubPolyglot = ");
client = client.replace("this.init();", "");
Fs.writeFileSync(__dirname + "/../dist/gh-polyglot.js", client);
Fs.writeFileSync(__dirname + "/../dist/gh-polyglot.min.js", UglifyJS.minify(client, { fromString: true }).code);
// This file generates the client script
// Dependencies
var Fs = require("fs")
, GitHubColors = require("github-colors")
, UglifyJS = require("uglify-js")
;
const TEMPLATE = "(function (root) {\n"
+ " var GitHubColors = __GITHUB_COLORS__;\n"
+ " __GITHUB_POLYGLOT__\n"
+ "})(window);";
// Configurations
GitHubColors.init();
var ghPolyglot = Fs.readFileSync(__dirname + "/../lib/index.js", "utf-8")
, lines = ghPolyglot.split("\n")
, replace = {
__GITHUB_POLYGLOT__: lines.slice(lines.indexOf("/**")).join("\n")
, __GITHUB_COLORS__: "{ get: " + GitHubColors.get.toString() + ",\n"
+ "colors: " + JSON.stringify(GitHubColors.colors) + "}"
}
, client = TEMPLATE
;
Object.keys(replace).forEach(function (c) {
client = client.replace(new RegExp(c), replace[c]);
});
client = client.replace("module.exports = ", "root.GitHubPolyglot = ");
return availableLanguages.map((language, counter) => {
const isSelectedIndex = counter === this.state.selectedIndex;
// This will be used in making sure of the element visibility
const refProp = isSelectedIndex ? { ref: 'activeItem' } : {};
const languageColor = GithubColors.get(language.title) || {
color: language.title === 'All Languages' ? 'transparent' : '#e8e8e8'
};
return (
<a> this.selectLanguage(counter) }
key={ counter }>
<span style="{{"></span>
<span>{ language.title }</span>
</a>
);
});
}
spinner = ora(`Fetching ${ghUrl}...`).start();
if (!db.repos[repo].fetching ||
db.repos[repo].fetched_at &&
new Date(db.repos[repo].fetched_at) > new Date(db.repos[repo].pushed_at)) {
spinner.succeed(`${repo} hasn't changed`);
return;
}
const ghDataJson = await fetchJson(authify(ghUrl));
spinner.succeed(`Fetched ${ghUrl}`);
for (let language in ghDataJson) {
ghDataJson[language] = {
bytes: ghDataJson[language],
color: githubColors.get(language, true).color
};
}
db.repos[repo].languages = ghDataJson;
db.write();
}
const ghUrl = `https://api.github.com/repos/${repo}/languages`;
spinner = ora(`Fetching ${ghUrl}...`).start();
if (!repos[repo].fetching_since || repos[repo].fetched_at &&
new Date(repos[repo].fetched_at) > new Date(repos[repo].pushed_at)) {
spinner.succeed(`${repo} hasn't changed`);
return;
}
const ghDataJson = await github.fetchGHJson(ghUrl, spinner);
spinner.succeed(`Fetched ${ghUrl}`);
for (let language in ghDataJson) {
ghDataJson[language] = {
bytes: ghDataJson[language],
color: githubColors.get(language, true).color
};
}
repos[repo].languages = ghDataJson;
repos[repo].write();
}
render() {
const languageColor = GithubColors.get(this.props.repository.language);
return (
<div>
<div>
<div>
<a rel="noopener noreferrer" href="{">
<div>
<img src="{"> {
e.target.src = '/img/logo.svg';
} }
alt={ this.props.repository.owner.login }/>
</div>
<div>
<h5>{ this.props.repository.owner.login }</h5>
<p>View Profile</p></div></a></div></div></div>
render() {
const languageColor = GithubColors.get(this.props.repository.language);
return (
<div>
<div>
<div>
<h3>
<a rel="noopener noreferrer" href="{">
<span>{ this.props.repository.owner.login } / </span>
{ this.props.repository.name }
</a>
</h3>
<p>Built by · <a rel="noopener noreferrer" href="{">{ this.props.repository.owner.login }</a> · { moment(this.props.repository.created_at).format('MMMM D YYYY') }</p>
</div>
<div>
<p>{ this.props.repository.description || 'No description given.' }</p>
</div></div></div>
arrData = Object.keys(languages).map(function (cLang) {
return {
label: cLang
, value: languages[cLang]
, color: GitHubColors.get(cLang, true).color
};
});