Skip to content

BoWangBlog/wb-fe-cli

Repository files navigation

Welcome to wb-fe-cli 👋

Version npm npm bundle size GitHub license GitHub issues

a react project cli, help you create a react project with webpack or vite quickly

Pay attention to the following:

this is a React project cli, but not have template, you can create your own template by yourself use it;

you need to change create.js downloadPath to your own template path

const downloadPath = `direct:${baseUrl}/${answers.type}-${answers.frame}-template.git#master`

in your template you need to set variables and add ask.ts file

module.exports = [
    {
        name: 'description',
        message: 'Please enter project description:',
    },
    {
        name: 'author',
        message: 'Please enter project author:',
    },
    {
        name: 'apiPrefix',
        message: 'Please enter project apiPrefix:',
        default: 'api/1.0',
        // @ts-ignore
        validate: function (input) {
            const done = this.async();
            setTimeout(function () {
                // 校验是否为空,是否是字符串
                if (!input.trim()) {
                    done('You can provide a apiPrefix, or not it will be default【api/1.0】');
                    return;
                }
                const pattern = /[a-zA-Z0-9]$/;
                if (!pattern.test(input.trim())) {
                    done(
                        'The apiPrefix is must end with letter or number, like default 【api/1.0】',
                    );
                    return;
                }
                done(null, true);
            }, 500);
        },
    },
    {
        name: 'proxy',
        message: 'Please enter project proxy:',
        default: 'https://www.test.com',
        // @ts-ignore
        validate: function (input) {
            const done = this.async();
            setTimeout(function () {
                // 校验是否为空,是否是字符串
                if (!input.trim()) {
                    done(
                        'You can provide a proxy, or not it will be default【https://www.test.com】',
                    );
                    return;
                }
                const pattern =
                    /(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-.,@?^=%&:/~+#]*[\w\-@?^=%&/~+#])?/;
                if (!pattern.test(input.trim())) {
                    done(
                        'The proxy is must end with letter or number, like default 【https://www.test.com】',
                    );
                    return;
                }
                done(null, true);
            }, 300);
        },
    },
];

Want to know more you can visit the source code !

Install

npm install

Usage develop

npm link

wb-cli init [projectName]

Usage

npm install -g wb-fe-cli

wb-cli init [projectName] # init project
wb-cli update # update version

Author

👤 bo.wang

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2020 bo.wang.
This project is ISC licensed.


This README was generated with ❤️ by readme-md-generator

About

a react project cli, help you create react project with webpack

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published