介绍
@vlr/bucket-gen 是一个可以帮助前端开发人员快速生成常见的文件结构的 npm 包。可以帮助开发人员避免重复造轮子,提高开发效率。
安装
使用 npm 进行安装,运行以下命令:
npm install -g @vlr/bucket-gen
安装完成后,执行 bucket-gen 命令即可。
如何使用
打开命令行终端,进入到需要生成文件结构的目录中。
执行以下命令:
bucket-gen
- 选择需要生成的文件结构类型,例如选择 React:
? Which type of bucket you want to generate? › - Use arrow-keys. Return to submit. ❯ React React with Redux React with TypeScript
- 输入文件夹名称,例如输入 my-demo:
? Please input the name of the bucket. (my-demo)
- 等待生成完成即可:
[vlr-bucket-gen] - The bucket has been generated successfully 👍 [vlr-bucket-gen] - The bucket directory path is /Users/username/path/bucket/my-demo
生成的文件结构大致如下:
-- -------------------- ---- ------- -------- --- ------- - --- ---------- - --- ------------- --- ---- - --- -------- - --- ------- - --- ------ - --- --------- - --- -------- --- ------------ --- ---------
示例代码
-- -------------------- ---- ------- ----- -- - -------------- ----- ---- - ---------------- ----- - --------- - - ---------------- ----- -------------- - ------------------------ ----- ---------- - -------------------- --- - ------- ------ - ------ -------- ---- ------ -- - ------ -------- ---- ------ -- - ------ -------- ------- ------ ------ -- ----- -------- -------------------- ----- -------- - ----- ---------- - ------------------ ------ ----- ---------- - --------------------- ---------- ----- ------- - --------------------- ------- ----- --------- - ------------------ ------------ ----- ------- - ------------------ ---------- -- -- ------ -- ----- ----------------------- -- -- ------ ------ ----- ----------------------- ----- --------------- --------------------- -------------- ----------------- ------------ ------------------------------ ---- ------------------------------------- -- ----- --------------- --------------------- ----------------- ---- -- -- -- --- ------ ----- -------------------- ----- --------------- ---------- ------- ----- ---- ---------------- -------- ---- -------------------- ---------------------- --- ---- ------------------------------ -------------------- ---- ---- ---------------------- -------------------------------------- -- ----- --------------- -------- ------- ----- ---- ---------------- ------------------------ ----- --- ------ --- ---- -------------------- ------- --------------------------- ---- ---------------- ---------------------- ------------ ---- ----- ---- ----------------------- --- ---- -- --------- ------ ---------------------------------------------------------- ------------------- -------------- -------------- --- ----- ------- ------ ----------- -------- --------------- ------- ------- -- -- -- ------------ ----- --------------- --------------------- ---------------- ---- --------- --- - ---- - ------ ------------ ------------ ---------------- ------- --------- ------------------- ------------ --- ---------- --------------- ---------- ---------- --------------- ---------- --------- --------------- --------- ---------- --------------- --------- ---- ----------------- --- ------------ --- ---------------- -------------------- --- ---- ----------------- --- --------------- --- ------------ ----- --------- ----- ------- ------- ---- ---------------- --- ------ - ------ ------------ ------ - ------- ------------ ------ - ------ ----------- --- ---- ----------------- --- ---------- --------------- -------------- --------------- ------------------ ------------ ---- -------------------- --- ------------------------ -------------- ------------------------------ ------------- --------------- ------------ ----- -- -- -- --------- ----- --------------- --------------------- ------------- -- - - ---- - --------- ------- --- ------------ ---- ------- ----- --------------------------------------------------------- --------- ------------- --- ------- ---------- --- --- ----------- ---- -------------- --- --- -- --- ----------- ----------- ---------------------------------------------- -- ---- -- -- --- --------------- ---- ---- ------ -- --- ---- ----------- ---- ---- --- --- ---- ------ -- --- --------------- ---- ----------------- --- ---- ------ -- --- ----------- ----- ---------- --- ------- ----- -------- ---------------------------------------------------------------------- --- ---- ------------------- ---- --- ---------------- --- --- --- ---------- -- --- ------- ----------- --------- ------- ----- -- ---------- ---- --- --------- --- ----- --- --- ---- ------------------- ----- -- -------- --- --- --------- ------- --- ------------- --- -- ----- -- -- ---------------- --- ------- ----- ------------------------------------------------------------------------- --- ---- ------------------- ---- --- ----------------- ---- -- - ------- ---------- ---- --- -------- --- ----- -- ------------- --- ------ --------- ---- --- ----- ---- --- ------------- -------- --- --- ------- -- --- ----- ---- ------- ---- ------ --- ------ ----- ---------- ---- ---- -------------------- -- ---- ---- --- --- ------------- ----- --- --- ---------- ------------ --------- ------ ------- ---- ----- ---- ---- ------- -- --- ---- ---- ------- ---- ----- --- -- --- -------- ------ ------- ---- ----- ----- --- ---- ---- ----- -- --- ------ ------- -- --- --- ----- ----- -- ---- ----- ------ -- ---- ----------- ----- ---- -- ---- --- -------- --- ------- ------- --- -- -------- --- ----- --- ------ ------------ --- --- --------- ---- --------- -- --- ---- -------- ------- -- ---------- ---- ---- ---- -------- -- ------ -- --- -------- --------- -- ---- --- --- ----- --- ------ -- ---------------- ------ --- ---- --------- ------------ ----- ---------------- ------ --------- ---- -- ---------------- - ----------------------- ---------- -------------------------------
维护者
此 npm 包由 @vlr 维护。如果你遇到问题或者有其他疑问,可以前往 Github 主页联系我们。
总结
通过使用 @vlr/bucket-gen,我们可以快速生成常见的文件结构,减少开发时间和工作量,提高工作效率。希望这篇文章对于使用 npm 包的同学有所帮助。
来源:JavaScript中文网 ,转载请注明来源 https://www.javascriptcn.com/post/vlr-bucket-gen