Node.js cli tools auto install npm packages All In One
Node.js cli tools auto install npm packages All In One
cli auto install dependencies / cli 自动安装依赖
原理分析
- 读取本地或远程的 template files, 复制模版文件到新建的项目中;
- 通过交互式的命令行工具 yargs 获取参数;
- 自动执行预定义的 shell 安装脚本文件;
if (platform === "linux") {
template_path = `https://github.com/xgqfrms/hui-templates.git`;
shell.exec(`git clone ${template_path} ${app_path}`);
const spinner = ora();
spinner.start("start downloading ...");
setTimeout(() => {
spinner.color = "green";
spinner.text = "🎉 finished downlaod!";
}, 1000);
}
https://github.com/xgqfrms/hui-cli/blob/master/hui#LL103-L113C10
if (install) {
log(`start auto installing...`.green);
shell.exec(`cd hui-app & npm i`);
log(`finished install`.green);
}
https://github.com/xgqfrms/hui-cli/blob/master/hui#LL188-L193C2
demos
next.js
# global cli
$ npm i -g @nestjs/cli
$ nest new web-app
cra
# 💩 global cli
$ npm uninstall -g create-react-app
$ yarn global remove create-react-app
# npx
$ npx create-react-app react-app
$ npx create-react-app typescript-react-app --template typescript
Running any of these commands will create a directory
called my-app inside the current folder.
Inside that directory, it will generate
the initial project structure
and install the transitive dependencies
:
运行这些命令中的任何一个都会在当前文件夹中创建
一个名为 my-app 的目录
。
在该目录中,它将生成
初始项目结构
并安装
传递依赖项
:
https://create-react-app.dev/docs/getting-started#quick-start
https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b
refs
yargs
https://github.com/xgqfrms-GitHub/Node-CLI-Tools/blob/master/libs/readme.md#yargs
npm
https://www.npmjs.com/package/hui-cli
https://github.com/xgqfrms/hui-cli
https://github.com/xgqfrms/hui-templates
https://www.npmjs.com/package/app-node-env
https://socket.dev/npm/package/@xgqfrms/wcui
©xgqfrms 2012-2025
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/17222199.html
未经授权禁止转载,违者必究!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
2022-03-16 js map string trim bug All In One
2022-03-16 LeetCode String to Integer (atoi) js solution All In One
2022-03-16 vscode auto run task on save code & automatic debug All In One
2022-03-16 Apple MacBook Pro 扬声器突然没声音了 bug All In One
2022-03-16 document.execCommand API & Clipboard API All In One
2022-03-16 社交媒体分享代码截图美化工具 All in One
2022-03-16 js one object equal to another object checker All In One