Socket
Socket
Sign inDemoInstall

lovelope-react-cli

Package Overview
Dependencies
153
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.4 to 0.0.5

bin/questions.js

79

bin/init.js

@@ -1,4 +0,4 @@

const fs = require('fs');
const fs = require('fs-extra');
const ora = require('ora');
const download = require('download-git-repo');
const git = require('isomorphic-git');
const inquirer = require('inquirer');

@@ -8,42 +8,47 @@ const chalk = require('chalk');

const pkg = require('../package.json');
const config = require('../config');
const getQuestions = require('./questions');
git.plugins.set('fs', fs);
const { remote: gitRemote, branch: gitBranchs } = config.git;
function assert(v) {
console.dir(v);
process.exit();
}
module.exports = function init(program, name) {
inquirer
.prompt([
{
name: 'description',
message: '请输入项目描述',
},
{
name: 'author',
message: '请输入作者名称',
},
])
.prompt(
// TODO: hasType 其它类型
getQuestions({ hasName: Boolean(name), hasType: program.typescript })
)
.then(answers => {
// 开始下载
// 项目配置
const meta = {
name,
projectType: program.typescript ? 'ts' : 'default',
...answers,
};
// git仓库分支
const branch = gitBranchs[meta.projectType];
// 开始下载动画
const spinner = ora('正在下载模板...');
spinner.start();
// 项目类型
let remoteUrl = pkg.template.default;
if (program.typescript) {
remoteUrl = pkg.template.typescript;
}
download(remoteUrl, name, { clone: true }, err => {
if (err) {
// 下载失败调用
spinner.fail();
console.log(symbols.error, chalk.red(err));
} else {
git
.clone({
url: gitRemote, // git 仓库地址
dir: name, // 目标文件夹
ref: branch, // 分支名
singleBranch: true, // 单分支克隆
depth: 1, // 浅克隆
})
.then(() => {
// 下载成功调用
spinner.succeed();
const meta = {
name,
description: answers.description,
author: answers.author,
};
const fileName = `${name}/package.json`;
if (fs.existsSync(fileName)) {
if (fs.pathExistsSync(fileName)) {
const content = fs.readFileSync(fileName).toString();

@@ -55,5 +60,9 @@ const json = JSON.parse(content);

console.log(symbols.success, chalk.green('项目初始化完成'));
}
});
})
.catch(err => {
// 下载失败调用
spinner.fail();
console.log(symbols.error, chalk.red(err));
});
});
};
{
"name": "lovelope-react-cli",
"version": "0.0.4",
"version": "0.0.5",
"description": "A cli for react-starter.",

@@ -63,3 +63,5 @@ "bin": {

"download-git-repo": "^1.1.0",
"fs-extra": "^7.0.1",
"inquirer": "^6.2.2",
"isomorphic-git": "^0.51.12",
"log-symbols": "^2.2.0",

@@ -69,7 +71,3 @@ "ora": "^3.2.0",

"validate-npm-package-name": "^3.0.0"
},
"template": {
"default": "direct:https://github.com/lovelope/react-project.git#feature/antd",
"typescript": "direct:https://github.com/lovelope/react-project.git#feature/ts"
}
}

@@ -1,3 +0,9 @@

# [R-CLI](https://github.com/lovelope/r-cli) · [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/lovelope/r-cli/blob/master/LICENSE) [![npm version](https://img.shields.io/npm/v/lovelope-react-cli.svg?style=flat)](https://www.npmjs.com/package/lovelope-react-cli) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/lovelope/r-cli/pulls)
# [Lovelope React Cli](https://github.com/lovelope/r-cli)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/lovelope/r-cli/blob/master/LICENSE)
[![npm version](https://img.shields.io/npm/v/lovelope-react-cli.svg?style=flat)](https://www.npmjs.com/package/lovelope-react-cli)
[![downloads per month](https://img.shields.io/npm/dm/lovelope-react-cli.svg)](https://www.npmjs.org/package/lovelope-react-cli)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-airbnb-brightgreen.svg)](https://github.com/airbnb/javascript)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/lovelope/r-cli/pulls)
A cli for react-starter.

@@ -4,0 +10,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc