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

@epig/create-app

Package Overview
Dependencies
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@epig/create-app - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

template/default/src/hooks/package.json

161

createReactApp.js

@@ -118,2 +118,4 @@ const chalk = require('chalk');

.option('--admin')
.option('--mobile')
.option('--luna')
.usage(`${chalk.green('<project-directory>')} [options]`)

@@ -140,4 +142,2 @@ .action((name) => {

console.log('program.admin', program.admin);
let projectType = 'default';

@@ -148,6 +148,12 @@

}
if (program.mobile) {
projectType = 'mobile';
}
if (program.luna) {
projectType = 'luna';
}
createReactApp(projectName, projectType);
function createReactApp(name, type = 'default') {
async function createReactApp(name, type = 'default') {
const root = path.resolve(name);

@@ -182,9 +188,18 @@ const appName = path.basename(root);

let allDependencies = [];
let buildInDependencies = ['src/util', 'src/components'];
switch (type) {
case 'default':
allDependencies = ['react', 'react-dom', '@babel/polyfill', 'antd', 'classnames', '@epig/luna', 'react-document-title', 'react-router', 'react-router-dom'];
allDependencies = ['react', 'react-dom', 'antd', 'classnames', 'react-document-title', 'react-router', 'react-router-dom', 'isomorphic-fetch', 'es6-promise'];
break;
case 'admin':
allDependencies = ['react', 'react-dom', '@babel/polyfill', 'antd', 'classnames', '@epig/admin-tools'];
buildInDependencies = buildInDependencies.concat(['src/models']);
break;
case 'luna':
allDependencies = ['react', 'react-dom', '@babel/polyfill', 'antd', 'classnames', '@epig/luna', 'react-document-title', 'react-router', 'react-router-dom'];
buildInDependencies = buildInDependencies.concat(['src/models']);
break;
case 'mobile':
allDependencies = ['react', 'react-dom', 'antd', 'classnames', 'react-document-title', 'react-router', 'react-router-dom', 'isomorphic-fetch', 'es6-promise'];
break;
default:

@@ -194,3 +209,5 @@ break;

run(type, root, appName, originalDirectory, allDependencies);
console.log('project type: ', type);
await run(type, root, appName, originalDirectory, allDependencies, buildInDependencies);
}

@@ -236,73 +253,76 @@

function run(projectType, root, appName, originalDirectory, allDependencies) {
async function run(projectType, root, appName, originalDirectory, allDependencies
, buildInDependencies) {
const allDevdependencies = ['typescript', '@epig/af-build-dev', ...devDependencies];
console.log('Copy files from template');
copy([path.join(__dirname, `/template/${projectType}/**/*`), path.join(__dirname, `template/${projectType}/**/.*`)], root, (err) => {
if (err) {
console.log();
console.log('Copy files has failed');
console.log(err);
const knownGeneratedFiles = [...templateGeneratedFiles, 'package.json'];
exit(root, appName, knownGeneratedFiles);
try {
if (projectType === 'mobile') {
await copyFiles([path.join(__dirname, `/template/default/**/*`), path.join(__dirname, `/template/default/**/.*`)], root);
}
await copyFiles([path.join(__dirname, `/template/${projectType}/**/*`), path.join(__dirname, `/template/${projectType}/**/.*`)], root);
} catch (err) {
console.log();
console.log('Copy files has failed');
console.log(err);
fs.writeFileSync(path.join(root, '.gitignore'), gitIgnoreFiles.join('\r\n'));
const knownGeneratedFiles = [...templateGeneratedFiles, 'package.json'];
exit(root, appName, knownGeneratedFiles);
}
console.log('Copy files complete');
console.log();
fs.writeFileSync(path.join(root, '.gitignore'), gitIgnoreFiles.join('\r\n'));
try {
let entryConfigPath = path.join(root, 'src/index.tsx');
if (projectType === 'admin') {
entryConfigPath = path.join(root, 'src/entry.config.ts');
}
let entryConfigContent = fs.readFileSync(entryConfigPath, 'utf-8');
entryConfigContent = entryConfigContent.replace('<%= appName %>', () => appName);
fs.writeFileSync(entryConfigPath, entryConfigContent, { encoding: 'utf-8' });
} catch (err) {
console.log();
console.log('Generate index.tsx has faild');
console.log(err.message);
console.log('Copy files complete');
console.log();
const knownGeneratedFiles = [...templateGeneratedFiles, 'package.json'];
exit(root, appName, knownGeneratedFiles);
try {
let entryConfigPath = path.join(root, 'src/index.tsx');
if (projectType === 'admin') {
entryConfigPath = path.join(root, 'src/entry.config.ts');
}
let entryConfigContent = fs.readFileSync(entryConfigPath, 'utf-8');
entryConfigContent = entryConfigContent.replace('<%= appName %>', () => appName);
fs.writeFileSync(entryConfigPath, entryConfigContent, { encoding: 'utf-8' });
} catch (err) {
console.log();
console.log('Generate index.tsx has faild');
console.log(err.message);
console.log('Installing packages. This might take a couple of minutes.');
/**
* 要在安装依赖前执行git初始化,不然提交前检查不起作用
*/
const knownGeneratedFiles = [...templateGeneratedFiles, 'package.json'];
exit(root, appName, knownGeneratedFiles);
}
initGit().then(() => {
return install(root, allDependencies, false);
})
.then(() => {
return install(root, allDevdependencies, true).then(() => { return ''; });
})
.then(() => {
const buildInDependencies = ['src/util', 'src/models', 'src/components'];
return install(root, buildInDependencies, false).then(() => '');
})
.then(() => {
return initialCommit();
})
.then(() => {
success(root, appName, originalDirectory);
})
.catch(error => {
console.log();
console.log('Aborting installation.');
if (error.message) {
console.log(` ${chalk.cyan(error.message)} has failed.`);
} else {
console.log(chalk.red('Unexpected error. Please report it as a bug:'));
console.log(error.message);
}
console.log();
console.log('Installing packages. This might take a couple of minutes.');
/**
* 要在安装依赖前执行git初始化,不然提交前检查不起作用
*/
const knownGeneratedFiles = [...templateGeneratedFiles, 'package.json', 'node_modules', 'package-lock.json', 'tslib'];
exit(root, appName, knownGeneratedFiles);
});
initGit().then(() => {
return install(root, allDependencies, false);
})
.then(() => {
return install(root, allDevdependencies, true).then(() => { return ''; });
})
.then(() => {
return install(root, buildInDependencies, false).then(() => '');
})
.then(() => {
return initialCommit();
})
.then(() => {
success(root, appName, originalDirectory);
})
.catch(error => {
console.log();
console.log('Aborting installation.');
if (error.message) {
console.log(` ${chalk.cyan(error.message)} has failed.`);
} else {
console.log(chalk.red('Unexpected error. Please report it as a bug:'));
console.log(error.message);
}
console.log();
const knownGeneratedFiles = [...templateGeneratedFiles, 'package.json', 'node_modules', 'package-lock.json', 'tslib'];
exit(root, appName, knownGeneratedFiles);
});

@@ -420,3 +440,3 @@ }

function initialCommit() {
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
const command = 'git';

@@ -523,1 +543,12 @@ let args = [

}
async function copyFiles(paths, dest) {
return new Promise((resolve, reject) => {
copy(paths, dest, err => {
if (err) {
reject(err);
}
resolve();
});
});
}
{
"name": "@epig/create-app",
"version": "1.1.0",
"version": "1.2.0",
"description": "create react app",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -6,3 +6,3 @@ # @epig/create-react-app

```bash
npx @epig/create-react-app my-app
npx @epig/create-app my-app
cd my-app

@@ -19,6 +19,18 @@ npm start

移动端
```bash
npx @epig/create-app my-app-m --mobile
```
[@epig/luna](https://github.com/evel-pig/luna)
```bash
npx @epig/create-app my-app-m --luna
```
管理后台
```bash
npx @epig/create-react-app my-admin-app --admin
npx @epig/create-app my-admin-app --admin
```

@@ -13,7 +13,2 @@ const path = require('path');

cacheGroups: {
['vendor']: {
test: /[\\/]node_modules[\\/](?!@epig\/luna)/,
name: 'vendor',
chunks: 'all',
},
commons: {

@@ -20,0 +15,0 @@ name: 'commons',

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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