diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..beffa30 --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..515dfdf --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +coverage +**/templates diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..176a458 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..669ada7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules +coverage +pnpm-lock.yaml \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..75cee68 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: node_js +node_js: + - v20 + - v18 + - v16 + - v14 + - v12 + - v10 + - v8 + - v6 + - v4 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ee3e510 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..111612d --- /dev/null +++ b/README.md @@ -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) diff --git a/__tests__/app.js b/__tests__/app.js new file mode 100644 index 0000000..aac939b --- /dev/null +++ b/__tests__/app.js @@ -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" + ); + }); +}); diff --git a/generators/app/index.js b/generators/app/index.js new file mode 100644 index 0000000..7bc87f6 --- /dev/null +++ b/generators/app/index.js @@ -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 + } + ); + } +}; diff --git a/generators/app/templates/README.md b/generators/app/templates/README.md new file mode 100644 index 0000000..96c896d --- /dev/null +++ b/generators/app/templates/README.md @@ -0,0 +1,30 @@ +

<%= githubName %>

+ +

Hi šŸ‘‹, I'm <%= githubName %>

+

A developer

+ +

<%= githubName %>

+ +- šŸ”­ 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: ... + +

Connect with me:

+

+xxx +

+ +

Languages and Tools:

+ +

+ <%= githubName %> +

+ +

+<%= githubName %> +

diff --git a/package.json b/package.json new file mode 100644 index 0000000..75c79ac --- /dev/null +++ b/package.json @@ -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" +}