Socket
Socket
Sign inDemoInstall

lovelope-react-cli

Package Overview
Dependencies
127
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.2 to 0.0.3

bin/init.js

60

bin/r-cli.js

@@ -5,12 +5,10 @@ #!/usr/bin/env node

const fs = require('fs');
const program = require('commander');
const download = require('download-git-repo');
const inquirer = require('inquirer');
const fs = require('fs');
const ora = require('ora');
const chalk = require('chalk');
const symbols = require('log-symbols');
const chalk = require('chalk');
const validate = require('validate-npm-package-name');
const pkg = require('../package.json');
const init = require('./init');

@@ -25,3 +23,2 @@ require('./checkNodeVersion')(pkg.engines.node, pkg.name);

.action(name => {
console.log(name);
const valid = validate(name);

@@ -34,53 +31,4 @@ const { validForNewPackages } = valid;

}
if (!fs.existsSync(name)) {
inquirer
.prompt([
{
name: 'description',
message: '请输入项目描述',
},
{
name: 'author',
message: '请输入作者名称',
},
])
.then(answers => {
// 开始下载
const spinner = ora('正在下载模板...');
spinner.start();
// 项目类型
let remoteUrl = pkg.template.default;
if (
process.argv.includes('-t') ||
process.argv.includes('--typescript')
) {
remoteUrl = pkg.template.typescript;
}
download(remoteUrl, name, { clone: true }, err => {
if (err) {
// 下载失败调用
spinner.fail();
console.log(symbols.error, chalk.red(err));
} else {
// 下载成功调用
spinner.succeed();
const meta = {
name,
description: answers.description,
author: answers.author,
};
const fileName = `${name}/package.json`;
if (fs.existsSync(fileName)) {
const content = fs.readFileSync(fileName).toString();
const json = JSON.parse(content);
const result = { ...json, ...meta };
fs.writeFileSync(fileName, JSON.stringify(result, null, 2));
}
console.log(symbols.success, chalk.green('项目初始化完成'));
}
});
});
init(name);
} else {

@@ -87,0 +35,0 @@ // 错误提示项目已存在,避免覆盖原有项目

{
"name": "lovelope-react-cli",
"version": "0.0.2",
"version": "0.0.3",
"description": "A cli for react-starter.",

@@ -5,0 +5,0 @@ "bin": {

@@ -1,9 +0,19 @@

# r-cli
# [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)
A cli for react-starter.
Usage: `r-cli <command> [options]`
## Install
Options:
```bash
npm i -g lovelope-react-cli
```
## Usage
```bash
r-cli <command> [options]
```
## Options:
- -v, --version output the version number

@@ -10,0 +20,0 @@ - -h, --help output usage information

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