# an2-cli **Repository Path**: light_of_hope/an2-cli ## Basic Information - **Project Name**: an2-cli - **Description**: 基于 lerna + node 构建的前端开发脚手架工具。 主要功能:代码模板下载,git操作规范化,分支管理。 - **Primary Language**: TypeScript - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-11-15 - **Last Updated**: 2023-11-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 脚手架工具 ## 主要功能 > 基于 lerna + node 构建的前端开发脚手架工具。 - 代码模板下载 - git操作规范化 - 分支管理 ## 作用 > 提升人效,统一规范 ## 常见 npm 包功能 - [nodemon](https://www.npmjs.com/package/nodemon) 启动一个`node`的监听服务,适用于开发 ## 知识点 - `webpack.config.js` 中配置 `target: node` 对 node 进行编译,处理 node 提供的包如: path 等 - `pageckage.json` 中配置 `type: module` `node` 中支持 `improt、export、export default` > 但是我们使用了 ts,但用 node 不能直接执行 ts ,需要先编译,借助 ts-node 来执行。 ts-node --esm xx.ts (--esm 支持Es6 module),但我们在执行终端命令的时候又不能借助 ts-node, 所以我们需要用 webpack 来将 ts 转换成 js,然后直接应用编译后的产物。 - 在 A 包下 执行 `yarn link` 创建软连接, 在 B 下执行 `yarn link "A(包名)"`就可以在 B 下面使用 A 了 - [Unknown file extension ".ts" for E:\private\base-cli\packages\core\lib\index.ts](https://blog.csdn.net/qq_28255733/article/details/132738770) - nvm 切换node版本失败,删除所有的node版本及nvm,重新安装nvm。 > 可使用淘宝镜像加速,放在 nvm 安装目录下的 settings.txt 里面 ``` node_mirror: https://npm.taobao.org/mirrors/node/ npm_mirror: https://npm.taobao.org/mirrors/npm/ ``` - [yarn link 之后执行命令却找不到](https://blog.csdn.net/weixin_45345105/article/details/110288681) - `node` 创建 `cli` 可执行脚本,需要在 `package.json` 种指定 `bin` 脚手架的入口,并在对应的文件头部写入 `#!/usr/bin/env node` 指定从环境变量中读取 `node`,并用 `node ` 解析 ## prettier 、eslint 、git hooks 配置 - [安装 perttier](https://www.prettier.cn/docs/install.html) - [配置编辑器](https://github.com/prettier/prettier-vscode) 1. 为项目单独配置对应的编辑器配置文件 .vscode/settings.json - [添加 eslint](https://github.com/prettier/eslint-config-prettier#installation) 1. [安装 eslint](https://zh-hans.eslint.org/docs/latest/use/getting-started) 2. [配置编辑器保存格式化]() 3. [配置 webpack 使用 eslint 来查找和修复 JavaScript 代码中的问题](https://www.webpackjs.com/plugins/eslint-webpack-plugin/) - [git hooks](https://www.prettier.cn/docs/install.html#git-hooks)