Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-react-boilerplate-app

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-react-boilerplate-app - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13

boilerplate-config/mvc-react.json

87

bin/create-react-boilerplate-app.js

@@ -9,10 +9,9 @@ 'use strict';

const chalk = require('chalk');
const spawn = require('cross-spawn');
const Basic = require('./libs/Basic');
const scriptsPackagename = 'react-boilerplate-app-scripts';
class CreateApp extends Basic {
class CreateApp {
constructor() {
super();
this.program = this.commandSetting();
var boilerplateJson = this.getBoilerpalteJson();
this.packageJson = {

@@ -24,10 +23,10 @@ name: 'react-boilerplate-app',

};
//默认使用react-redux-boilerplate-js
this.dependencies = ['react-redux-boilerplate-js'];
if(this.program.dataFlow === 'mobx'){
this.dependencies = ['react-mobx-boilerplate-js'];
}
this.devDependencies = [
'react-boilerplate-app-scripts',
];
this.dependencies = ['react', 'react-dom', 'prop-types'];
this.dependencies = this.dependencies.concat(
boilerplateJson.dependencies || []
);
this.devDependencies = ['react-boilerplate-app-scripts'];
this.devDependencies = this.devDependencies.concat(
boilerplateJson.devDependencies || []
);
this.allDependencies = []

@@ -39,13 +38,15 @@ .concat(this.dependencies)

readCurrentProjectPackageJSON() {
var packageJsonPath = path.resolve(__dirname, '../package.json');
var json = fs.readJsonSync(packageJsonPath);
return json;
}
commandSetting() {
this.program = new commander.Command(this.packageJson.name)
.version(this.packageJson.version)
var currentPakageJson = this.readCurrentProjectPackageJSON();
var program = new commander.Command(currentPakageJson.name)
.version(currentPakageJson.version)
.arguments('<project-directory>')
.usage(`${chalk.green('<project-directory>')} [options]`)
//--xx-xx类型,缩写使用大写
.option('-D, --data-flow [flow]', 'use redux or mobx')
//--xx类型,缩写使用小写
.option('-a, --all', 'create view with all features')
.option('-i, --i18n', 'create view with locale feature(i18n)')
.option('-b, --breadcrumb', 'create view with breadcrumb feature')
.option('-b, --boilerplate', 'create app with specified boilerplate')
.action(name => {

@@ -56,3 +57,5 @@ this.appName = name;

.parse(process.argv);
var program = this.program;
if (!program.boilerplate) {
program.boilerplate = 'mvc-react';
}
if (!this.appName) {

@@ -66,3 +69,3 @@ console.error('Please specify the project directory:');

console.log(
` ${chalk.cyan(program.name())} ${chalk.green('my-react-redux-app')}`
` ${chalk.cyan(program.name())} ${chalk.green('my-react-boilerplate-app')}`
);

@@ -75,11 +78,23 @@ console.log();

}
if (!this.program.dataFlow) {
this.program.dataFlow = 'redux';
return program;
}
//获取当前模板的json文件信息,用于生产app的package.json信息
//boilerplate.json的结构跟package.json很相似。
getBoilerpalteJson() {
var boilerplate = this.program.boilerplate;
var boilerplateJsonPath = path.resolve(
__dirname,
'../boilerplate-config',
boilerplate + '.json'
);
try {
var boilerplateJson = fs.readJsonSync(boilerplateJsonPath);
return boilerplateJson;
} catch (e) {
console.log(chalk.red(boilerplateJsonPath + ':'));
console.log(chalk.red('模板配置文件不存在!'));
console.log();
//console.log(e);
process.exit();
}
//判断数据流管理类库是否合法
var flow = ['redux', 'mobx'];
if (flow.indexOf(this.program.dataFlow) === -1) {
console.error(chalk.red('--data-flow should be redux or mobx!'));
process.exit(1);
}
}

@@ -108,7 +123,7 @@ //检测appName是否合法

writeResultPackageJson() {
this.dependencies.forEach((v, k) => {
this.dependencies.forEach(v => {
let version = util.getVersionOfPackage(v);
this.packageJson.dependencies[v] = '^' + version;
});
this.devDependencies.forEach((v, k) => {
this.devDependencies.forEach(v => {
let version = util.getVersionOfPackage(v);

@@ -170,4 +185,8 @@ this.packageJson.devDependencies[v] = '^' + version;

util.installPackages(this.allDependencies).then(() => {
this.writeResultPackageJson();
this.initApp();
try {
this.writeResultPackageJson();
this.initApp();
} catch (e) {
console.log(e);
}
});

@@ -174,0 +193,0 @@ }

{
"name": "create-react-boilerplate-app",
"version": "0.0.12",
"version": "0.0.13",
"description": "an tool for creating react boilerplate app",

@@ -22,3 +22,3 @@ "engines": {

"fs-extra": "^3.0.1",
"react-boilerplate-app-utils": "^0.0.10",
"react-boilerplate-app-utils": "^0.0.13",
"semver": "^5.3.0",

@@ -25,0 +25,0 @@ "validate-npm-package-name": "^3.0.0"

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc