Repository: beverle-y/react-starter-kit Branch: master Commit: c34fcaa75090 Files: 16 Total size: 9.9 KB Directory structure: gitextract_53y7opnv/ ├── .editorconfig ├── .gitignore ├── .npmignore ├── LICENSE ├── README-en.md ├── README.md ├── bin/ │ └── index.js ├── lib/ │ ├── Banner.js │ ├── Div.js │ ├── Dll.js │ ├── Inquirer.js │ ├── Install.js │ ├── Spinner.js │ └── Utils.js ├── package.json └── packages/ └── Download.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ root = true [*] charset = utf-8 end_of_line = lf insert_final_newline = false trim_trailing_whitespace = true [*.js] indent_style = space indent_size = 4 ================================================ FILE: .gitignore ================================================ # Folders to ignore node_modules # Editor directories and files to ignore .DS_STORE .DS_Store .idea .vscode .prettierrc .cache .project .settings .tmproj *.esproj *.sublime-project *.sublime-workspace *.suo *.ntvs* *.njsproj *.sln # Log files to ignore npm-debug.log* yarn-debug.log* yarn-error.log* *.log # Cache files to ignore .yarn-cache ================================================ FILE: .npmignore ================================================ # Folders to ignore node_modules # Editor directories and files to ignore .DS_STORE .DS_Store .idea .vscode .prettierrc .cache .project .settings .tmproj .gitignore .editorconfig *.esproj *.sublime-project *.sublime-workspace *.suo *.ntvs* *.njsproj *.sln # Log files to ignore npm-debug.log* yarn-debug.log* yarn-error.log* *.log # Cache files to ignore .yarn-cache ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) zhengaojin 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. ================================================ FILE: README-en.md ================================================ ![rs-admin-cli](https://jines-z.github.io/images/rs-admin-cli.png) --------------------------------------------------------------- [![React](https://img.shields.io/badge/react-^16.8.4-brightgreen.svg?style=flat-square)](https://github.com/facebook/react) [![Ant Design](https://img.shields.io/badge/ant--design-^3.8.0-yellowgreen.svg?style=flat-square)](https://github.com/ant-design/ant-design) [![Mobx](https://img.shields.io/badge/mobx-^5.9.4-orange.svg?style=flat-square)](https://github.com/mobxjs/mobx) [简体中文](https://github.com/Jines-z/rs-admin-cli) | English ## Overview `rs-admin-cli` is a scaffolding that is rapidly developed based on react and provides: - Interactive project scaffolding via `rs-admin-cli`。 - Start zero-configuration prototyping quickly with `rs-compiler`。 - Includes three solutions: - react + redux - react + mobx - react + mobx + typescript - react + mobx + typescript + electron - Rich project configuration to meet different needs。 ## Quick Start #### Install🔥 ~~~ npm install -g rs-admin-cli ~~~ #### Init ~~~ rs init yourProjectName ~~~ #### Run ~~~ cd yourProjectName npm start ~~~ #### Build ~~~ npm run build ~~~ ## Preview ![rs-admin-cli](https://jines-z.github.io/images/rs-admin-cli.gif) Address: [Mobx](https://jines-z.github.io/rs-mobx) [Redux](https://jines-z.github.io/rs-redux) [Log](https://github.com/Jines-z/rs-admin-cli/wiki/Log) ================================================ FILE: README.md ================================================ ![rs-admin-cli](https://jines-z.github.io/images/rs-admin-cli.png) --------------------------------------------------------------- [![React](https://img.shields.io/badge/react-^16.8.6-brightgreen.svg?style=flat-square)](https://github.com/facebook/react) [![Ant Design](https://img.shields.io/badge/ant--design-^3.8.0-yellowgreen.svg?style=flat-square)](https://github.com/ant-design/ant-design) [![Mobx](https://img.shields.io/badge/mobx-^5.9.4-orange.svg?style=flat-square)](https://github.com/mobxjs/mobx) 简体中文 | [English](https://github.com/Jines-z/rs-admin-cli/blob/master/README-en.md) ## 介绍 `rs-admin-cli` 是一个基于 react 进行快速开发的脚手架,提供: - 通过 `rs-admin-cli` 搭建交互式的项目脚手架。 - 通过 `rs-compiler` 快速开始零配置原型开发。 - 包含三套解决方案: - react + redux - react + mobx - react + mobx + typescript - react + mobx + typescript + electron - 具有丰富的项目配置项,可满足不同的需求。 ## 快速使用 #### 全局安装🔥 ~~~ npm install -g rs-admin-cli ~~~ #### 新建项目 ~~~ rs init yourProjectName ~~~ #### 运行 ~~~ cd yourProjectName npm start ~~~ #### 打包 ~~~ npm run build ~~~ ## 预览 ![rs-admin-cli](https://jines-z.github.io/images/rs-admin-cli.gif) 地址:[Mobx](https://jines-z.github.io/rs-mobx) [Redux](https://jines-z.github.io/rs-redux) #### 更新日志迁移至[Wiki](https://github.com/Jines-z/rs-admin-cli/wiki/%E6%9B%B4%E6%96%B0%E6%97%A5%E5%BF%97) ================================================ FILE: bin/index.js ================================================ #!/usr/bin/env node const program = require('commander') const download = require('../packages/Download') const { version } = require('../package') program .version(version, '-v, --version') .command('init ') .description('Set your project name') .action(function (dir, cmd) { download(dir) }) program.parse(process.argv) if (process.argv.slice(2).length === 0) { program.help() } ================================================ FILE: lib/Banner.js ================================================ const figlet = require('figlet') const Banner = text => { return new Promise((resolve, reject) => { figlet.text(text, { font: 'rectangles' }, function(err, data) { if (err) { reject(err) console.log('Something went wrong...') process.exit(0) } console.log(data) resolve() }) }) } module.exports = Banner ================================================ FILE: lib/Div.js ================================================ const ui = require('cliui')() const chalk = require('chalk') const figures = require('figures') const Div = list => { list.forEach(item => { ui.div({ text: chalk.green(figures.tick), width: 2, padding: [0, 0, 0, 0] }, { text: item, width: 25 }) }) console.log(`${ui.toString()}\n`) } module.exports = Div ================================================ FILE: lib/Dll.js ================================================ const { spawn } = require('child_process') const Dll = dir => { return new Promise((resolve, reject) => { const child = spawn('npm', ['run', 'dll'], { cwd: dir, stdio: [0, 1, 2], shell: process.platform === 'win32', detached: false }) child.on('close', (code) => { if (code !== 0) { console.log('command failed !') process.exit(0) } resolve() }) }) } module.exports = Dll ================================================ FILE: lib/Inquirer.js ================================================ const inquirer = require('inquirer') const promptList = [{ type: 'list', message: 'Choose a package management tool: ', name: 'command', choices: [ 'yarn', 'npm' ] }, { type: 'list', message: 'Choose what you need: ', name: 'state', choices: [ 'electron', 'redux', 'mobx', 'mobx-typescript' ] }] const Inquirer = () => { return new Promise((resolve, reject) => { inquirer.prompt(promptList).then(answers => { resolve(answers) }) }) } module.exports = Inquirer ================================================ FILE: lib/Install.js ================================================ const { spawn } = require('child_process') const Install = (dir, command) => { return new Promise((resolve, reject) => { const child = spawn(command, ['install'], { cwd: dir, stdio: [0, 1, 2], shell: process.platform === 'win32', detached: false }) child.on('close', (code) => { if (code !== 0) { console.log('command failed !') process.exit(0) } resolve() }) }) } module.exports = Install ================================================ FILE: lib/Spinner.js ================================================ const ora = require('ora') const Spinner = new ora({ text: 'Download template ...\n', color: 'white' }) module.exports = Spinner ================================================ FILE: lib/Utils.js ================================================ const { readdir } = require("fs") const readDir = dir => { return new Promise((resolve, reject) => { readdir(dir, (err, files) => { if (err) { console.log(err) process.exit(0) } else { resolve(files) } }) }) } module.exports = { readDir } ================================================ FILE: package.json ================================================ { "name": "rs-admin-cli", "version": "3.2.3", "description": "Command line interface for react", "author": "zhengaojin ", "private": false, "bin": { "rs": "./bin/index.js" }, "keywords": [ "react", "react-starter-kit", "cli", "admin", "redux", "mobx", "typescript", "electron" ], "license": "MIT", "dependencies": { "chalk": "^2.4.2", "cliui": "^4.1.0", "commander": "^2.20.3", "download-git-repo": "^3.0.2", "figlet": "^1.5.0", "figures": "^3.2.0", "inquirer": "^6.2.0", "ora": "^5.0.0", "lodash": "^4.17.20" } } ================================================ FILE: packages/Download.js ================================================ const GitRepo = require('download-git-repo') const Chalk = require('chalk') const Spinner = require('../lib/Spinner') const Banner = require('../lib/Banner') const Div = require('../lib/Div') const Install = require('../lib/Install') const Dll = require('../lib/Dll') const Inquirer = require('../lib/Inquirer') const Utils = require('../lib/Utils') const Download = async (dir) => { await Banner('rs admin cli') const answers = await Inquirer() process.stdout.write('\033c') Spinner.start() GitRepo(`github:Jines-z/rs-template-${answers.state}`, `${dir}/`, async function (err) { if (!err) { Spinner.stop() console.log(`# Download completed! \n`) const fileNames = await Utils.readDir(dir) Div(fileNames) console.log(`# Preparatory install ... \n`) await Install(dir, answers.command) await Dll(dir) console.log('\n') console.log(`## Successfully created project ${dir}`) console.log(`## Get started with the following commands:\n`) console.log(` ${Chalk.gray('$')} ${Chalk.cyan(`cd ${dir}`)}`) console.log(` ${Chalk.gray('$')} ${Chalk.cyan(`npm start`)}\n`) } else { Spinner.stop() console.log(Chalk.red('\n Download template failed ! \n')) process.exit(0) } }) } module.exports = Download