egg.js_新建一个egg.js项目(yarn/npm)/简化创建egg项目的脚本/单元测试功能不可用的问题
新建一个egg项目
执行如下脚本/命令
对于powershell 用户,我编写了如下脚本(powershell 函数)
function EggNew { param ( $projectDir = "new_egg_$(date)" ) # 检查目录存在性,以及判空 if ( Test-Path $projectDir) { Write-Output "directory already exist,now Set-Location to the directory:$projectDir" $itemList = Get-ChildItem $projectDir if ($itemList.count -eq 0) { Set-Location $projectDir } else { Write-Output "this folder:$projectDir is not empty,it is adviced to initial eggProject with a new(or empty) folder.returning..." return } } else { New-Item -ItemType Directory $projectDir Set-Location $projectDir } # mkdir $projectDir # Set-Location $projectDir yarn create egg --type=simple yarn install Get-ChildItem }
您可以将该脚本永久化,可以写入powershell的启动配置文件或者模块中
该函数接受一个目录名作为参数,新的项目将建立在该目录下
目前,您需要确保传入的目录名是现在目录中所没有的
脚本运行样例
测试调用:
Set-Location D:\repos\egg_demos EggNew restfulDemo
PS D:\repos\PwshLearn\ModulesByCxxu> powershell -ExecutionPolicy ByPass -File "d:\repos\PwshLearn\ModulesByCxxu\functionsByCxxu\testFunctions\testFunctions.ps1" Directory: D:\repos\egg_demos Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 12/10/2021 8:27 PM restfulDemo yarn create v1.22.17 [1/4] Resolving packages... [2/4] Fetching packages... [3/4] Linking dependencies... [4/4] Building fresh packages... success Installed "create-egg@2.0.1" with binaries: - create-egg [egg-init] use registry: https://registry.yarnpkg.com [egg-init] target dir is D:\repos\egg_demos\restfulDemo [egg-init] fetching npm info of egg-init-config [egg-init] use boilerplate: simple(egg-boilerplate-simple) [egg-init] fetching npm info of egg-boilerplate-simple [egg-init] downloading https://registry.npmjs.org/egg-boilerplate-simple/-/egg-boilerplate-simple-3.3.1.tgz [egg-init] extract to C:\Users\cxxu\AppData\Local\Temp\egg-init-boilerplate [egg-init] usage: - cd D:\repos\egg_demos\restfulDemo - npm install - npm start / npm run dev / npm test Done in 39.87s. yarn install v1.22.17 info No lockfile found. [1/5] Validating package.json... [2/5] Resolving packages... warning egg > egg-core > ready-callback > uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. warning egg > egg-session > koa-session > uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. warning autod > babel-preset-stage-0 > babel-plugin-transform-function-bind > babel-runtime > core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js. warning autod > babel-core > babel-register > core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js. warning egg-bin > nyc > uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. warning egg-bin > mocha > debug@3.2.6: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797) warning egg-bin > mocha > mkdirp@0.5.4: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.) warning egg-bin > power-assert > empower > core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js. warning egg-bin > power-assert > power-assert-formatter > core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js. warning egg-bin > espower-source > espower > espurify > core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js. warning egg-bin > power-assert > empower > empower-core > core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js. warning egg-bin > power-assert > power-assert-formatter > power-assert-context-formatter > core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js. warning egg-bin > power-assert > power-assert-formatter > power-assert-context-reducer-ast > core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js. warning egg-bin > power-assert > power-assert-formatter > power-assert-renderer-diagram > core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js. warning egg-bin > power-assert > power-assert-formatter > power-assert-renderer-comparison > core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js. warning egg-bin > globby > fast-glob > micromatch > snapdragon > source-map-resolve > resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated warning egg-bin > globby > fast-glob > micromatch > snapdragon > source-map-resolve > urix@0.1.0: Please see https://github.com/lydell/urix#deprecated warning egg-bin > espower-source > espower > escallmatch > call-matcher > core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js. warning egg-bin > power-assert > power-assert-formatter > power-assert-context-formatter > power-assert-context-traversal > core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js. warning egg-bin > power-assert > power-assert-formatter > power-assert-renderer-diagram > stringifier > core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js. warning egg-mock > supertest > superagent > formidable@1.2.6: Please upgrade to latest, formidable@v2 or formidable@v3! Check these notes: https://bit.ly/2ZEqIau warning eslint-config-egg > babel-eslint@8.2.6: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates. [3/5] Fetching packages... [4/5] Linking dependencies... warning "egg-bin > co-mocha@1.2.2" has incorrect peer dependency "mocha@>=1.18 <6". warning "eslint-config-egg > @typescript-eslint/eslint-plugin > tsutils@3.21.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta". warning Workspaces can only be enabled in private projects. [5/5] Building fresh packages... success Saved lockfile. Done in 89.77s. Directory: D:\repos\egg_demos\restfulDemo Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 12/10/2021 8:29 PM .github d----- 12/10/2021 8:27 PM app d----- 12/10/2021 8:27 PM config d----- 12/10/2021 8:29 PM node_modules d----- 12/10/2021 8:27 PM test -a---- 12/10/2021 8:27 PM 365 .autod.conf.js -a---- 12/10/2021 8:27 PM 9 .eslintignore -a---- 12/10/2021 8:27 PM 37 .eslintrc -a---- 12/10/2021 8:27 PM 143 .gitignore -a---- 12/10/2021 8:29 PM 172 .travis.yml -a---- 12/10/2021 8:29 PM 242 appveyor.yml -a---- 12/10/2021 8:27 PM 1027 package.json -a---- 12/10/2021 8:27 PM 491 README.md -a---- 12/10/2021 8:29 PM 334114 yarn.lock
单元测试功能不可用?
这与单元测试不通过是两回事,无法启动测试流程可能是node module在安装的时候出错导致,您可以尝试重新执行依赖安装命令:
yarn install
或者
npm install
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2022-03-07 PC_Cache和主存的映射方式
2022-03-07 计组_HammingCode海明码校验