Skip to content

Commit

Permalink
🚀 Project init
Browse files Browse the repository at this point in the history
  • Loading branch information
yyz945947732 committed Oct 5, 2023
0 parents commit 01dbb0a
Show file tree
Hide file tree
Showing 11 changed files with 307 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage
**/templates
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
coverage
pnpm-lock.yaml
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: node_js
node_js:
- v20
- v18
- v16
- v14
- v12
- v10
- v8
- v6
- v4
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) yaoyuanzhang

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# generator-github-profile

> generating your github profile page quickly
## Features

generating a github profile page with:

- 👨‍💻 Basic introduction.
- 🏆 Github Trophy.
- 🥰 Top Langs.
- 🏅 Github Stats.

## Installation

First, install [Yeoman](http://yeoman.io) and generator-github-profile using [npm](https://www.npmjs.com/) (we assume you have pre-installed [node.js](https://nodejs.org/)).

```bash
npm install -g yo generator-github-profile
```

Then generate your new project:

```bash
yo github-profile
```

## LICENSE

[MIT](https://github.com/yyz945947732/generator-github-profile/blob/master/LICENSE)
37 changes: 37 additions & 0 deletions __tests__/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"use strict";
const path = require("path");
const assert = require("yeoman-assert");
const helpers = require("yeoman-test");

describe("generator-github-profile:app", () => {
beforeEach(() => {
const answers = {
githubName: "yyz945947732",
theme: "light"
};
return helpers
.run(path.join(__dirname, "../generators/app"))
.withPrompts(answers);
});

it("creates files", () => {
const files = ["README.md"];
assert.file(files);
});

it("fills the README with options", () => {
assert.fileContent("README.md", "Hi 👋, I'm yyz945947732");
assert.fileContent(
"README.md",
"https://github-profile-trophy.vercel.app/?username=yyz945947732&theme=flat"
);
assert.fileContent(
"README.md",
"https://github-readme-stats.vercel.app/api/top-langs?username=yyz945947732&show_icons=true&locale=en&layout=compact&theme=light"
);
assert.fileContent(
"README.md",
"https://github-readme-stats.vercel.app/api?username=yyz945947732&show_icons=true&locale=en&theme=light"
);
});
});
80 changes: 80 additions & 0 deletions generators/app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
"use strict";
const Generator = require("yeoman-generator");
const _ = require("lodash");
const chalk = require("chalk");
const yosay = require("yosay");

module.exports = class extends Generator {
initializing() {
this.props = {
githubName: "",
theme: "light"
};
}

prompting() {
this.log(
yosay(
`Welcome to the spectacular ${chalk.red(
"generator-github-profile"
)} generator!`
)
);

const prompts = [
{
name: "githubName",
message: "GitHub's username",
when: !this.props.githubName,
default: this.user.git.name()
},
{
type: "list",
name: "theme",
message: "Select a theme:",
default: "light",
choices: [
{
name: "Light",
value: "light"
},
{
name: "Dark",
value: "dark"
}
]
}
];
return this.prompt(prompts).then(props => {
this.props = _.merge(this.props, props);
});
}

_getTrophyTheme() {
const { theme } = this.props;
if (theme === "light") {
return "flat";
}

if (theme === "dark") {
return "onedark";
}

return "flat";
}

writing() {
const { githubName, theme } = this.props;
const trophyTheme = this._getTrophyTheme();

this.fs.copyTpl(
this.templatePath("README.md"),
this.destinationPath("README.md"),
{
githubName,
theme,
trophyTheme
}
);
}
};
30 changes: 30 additions & 0 deletions generators/app/templates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<p align="right"> <img src="https://komarev.com/ghpvc/?username=<%= githubName %>&label=Profile%20views&color=0e75b6&style=flat" alt="<%= githubName %>" /> </p>

<h1 align="center">Hi 👋, I'm <%= githubName %></h1>
<h3 align="center">A developer</h3>

<p align="center"> <a href="https://github.com/ryo-ma/github-profile-trophy"><img src="https://github-profile-trophy.vercel.app/?username=<%= githubName %>&theme=<%= trophyTheme %>" alt="<%= githubName %>" /></a> </p>

- 🔭 I’m currently working on ...
- 🌱 I’m currently learning ...
- 👯 I’m looking to collaborate on ...
- 🤔 I’m looking for help with ...
- 💬 Ask me about ...
- 📫 How to reach me: ...
- 😄 Pronouns: ...
- ⚡ Fun fact: ...

<h3 align="left">Connect with me:</h3>
<p align="left">
xxx
</p>

<h3 align="left">Languages and Tools:</h3>

<p align="left">
<img src="https://github-readme-stats.vercel.app/api/top-langs?username=<%= githubName %>&show_icons=true&locale=en&layout=compact&theme=<%= theme %>" alt="<%= githubName %>" />
</p>

<p align="left">
<img src="https://github-readme-stats.vercel.app/api?username=<%= githubName %>&show_icons=true&locale=en&theme=<%= theme %>" alt="<%= githubName %>" />
</p>
81 changes: 81 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"name": "generator-github-profile",
"version": "0.0.1",
"description": "generating your github profile page quickly",
"homepage": "https://github.com/yyz945947732/generator-github-profile",
"author": "yyz945947732 <945947732@qq.com>",
"files": [
"generators"
],
"main": "generators/index.js",
"keywords": [
"github",
"profile",
"github-profile",
"yeoman-generator"
],
"devDependencies": {
"yeoman-test": "^1.7.0",
"yeoman-assert": "^3.1.1",
"eslint": "^6.6.0",
"prettier": "^1.19.1",
"husky": "^3.0.9",
"lint-staged": "^9.4.3",
"eslint-config-prettier": "^6.6.0",
"eslint-plugin-prettier": "^3.1.1",
"eslint-config-xo": "^0.27.2",
"jest": "^26.1.0"
},
"engines": {
"npm": ">= 4.0.0"
},
"dependencies": {
"yeoman-generator": "^3.1.1",
"lodash": "^4.17.21",
"chalk": "^2.1.0",
"yosay": "^2.0.2"
},
"jest": {
"testEnvironment": "node"
},
"lint-staged": {
"*.js": [
"eslint --fix",
"git add"
],
"*.json": [
"prettier --write",
"git add"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"eslintConfig": {
"extends": [
"xo",
"prettier"
],
"env": {
"jest": true,
"node": true
},
"rules": {
"prettier/prettier": "error"
},
"plugins": [
"prettier"
]
},
"scripts": {
"pretest": "eslint .",
"test": "jest"
},
"repository": {
"type": "git",
"url": "git+https://github.com/yyz945947732/generator-github-profile.git"
},
"license": "MIT"
}

0 comments on commit 01dbb0a

Please sign in to comment.