diff --git a/jest.config.js b/jest.config.js index c90431d7597c..c0fa96bbaae6 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,7 +1,6 @@ module.exports = (options = {}) => { return Object.assign({ preset: 'ts-jest', - testEnvironment: 'midway-bin/jest/env.js', testPathIgnorePatterns: ['/test/fixtures'], coveragePathIgnorePatterns: ['/test/'], }, options); diff --git a/package.json b/package.json index 20d04b46c0ff..d238af365df9 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ "clean": "lerna clean --yes && rm -rf ./packages/**/package-lock.json", "build": "sh scripts/build.sh", "authors": "git log --format='%aN <%aE>' | sort -u > AUTHORS", - "gen-api-ref": "node ./packages/midway-bin/bin/midway-bin.js doc --options typedoc.js", "postinstall": "opencollective-postinstall", "lint": "lerna exec mwts check", "lint:fix": "lerna exec mwts fix" diff --git a/packages/bootstrap/package.json b/packages/bootstrap/package.json index 78f2e8e154c3..00dad10c9462 100644 --- a/packages/bootstrap/package.json +++ b/packages/bootstrap/package.json @@ -6,8 +6,8 @@ "typings": "dist/index.d.ts", "scripts": { "build": "midway-bin build -c", - "test": "../../node_modules/.bin/jest", - "cov": "../../node_modules/.bin/jest --coverage" + "test": "midway-bin test", + "cov": "midway-bin test --cov" }, "keywords": [ "midway", @@ -20,7 +20,7 @@ ], "license": "MIT", "devDependencies": { - "midway-bin": "^2.2.4" + "@midwayjs/cli": "^1.0.x" }, "dependencies": { "@midwayjs/core": "^2.2.4" diff --git a/packages/core/package.json b/packages/core/package.json index 1507ec23d2f7..f52a60d2c45b 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -6,8 +6,8 @@ "typings": "dist/index.d.ts", "scripts": { "build": "midway-bin build -c", - "test": "../../node_modules/.bin/jest", - "cov": "../../node_modules/.bin/jest --coverage", + "test": "midway-bin test", + "cov": "midway-bin cov", "link": "npm link" }, "keywords": [ @@ -23,7 +23,7 @@ "license": "MIT", "devDependencies": { "chai": "^4.2.0", - "midway-bin": "^2.2.4", + "@midwayjs/cli": "^1.0.x", "mm": "^2.5.0", "sinon": "^7.2.2" }, diff --git a/packages/decorator/package.json b/packages/decorator/package.json index ddb79bfb49c6..d40bb25dff44 100644 --- a/packages/decorator/package.json +++ b/packages/decorator/package.json @@ -6,8 +6,8 @@ "typings": "dist/index.d.ts", "scripts": { "build": "midway-bin build -c", - "test": "../../node_modules/.bin/jest", - "cov": "../../node_modules/.bin/jest --coverage", + "test": "midway-bin test", + "cov": "midway-bin test --cov", "ci": "npm run test", "link": "npm link" }, @@ -21,7 +21,7 @@ "reflect-metadata": "^0.1.13" }, "devDependencies": { - "midway-bin": "^2.2.4", + "@midwayjs/cli": "^1.0.x", "mm": "^2.5.0" }, "keywords": [ diff --git a/packages/faas/package.json b/packages/faas/package.json index 366fa9b96eb3..08b8b9c7516b 100644 --- a/packages/faas/package.json +++ b/packages/faas/package.json @@ -14,7 +14,7 @@ "@midwayjs/mock": "^2.2.4", "@midwayjs/serverless-fc-starter": "^1.0.0", "@midwayjs/serverless-scf-starter": "^1.0.0", - "midway-bin": "^2.2.4", + "@midwayjs/cli": "^1.0.x", "mm": "^2.5.0" }, "engines": { @@ -37,8 +37,8 @@ ], "scripts": { "build": "midway-bin build -c", - "test": "../../node_modules/.bin/jest", - "cov": "../../node_modules/.bin/jest --coverage" + "test": "midway-bin test", + "cov": "midway-bin test --cov" }, "repository": { "type": "git", diff --git a/packages/midway-bin/CHANGELOG.md b/packages/midway-bin/CHANGELOG.md deleted file mode 100644 index 2020207603a2..000000000000 --- a/packages/midway-bin/CHANGELOG.md +++ /dev/null @@ -1,711 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## [2.2.4](https://github.com/midwayjs/midway/compare/v2.2.3...v2.2.4) (2020-09-15) - -**Note:** Version bump only for package midway-bin - - - - - -## [2.2.3](https://github.com/midwayjs/midway/compare/v2.2.2...v2.2.3) (2020-09-14) - -**Note:** Version bump only for package midway-bin - - - - - -## [2.2.2](https://github.com/midwayjs/midway/compare/v2.2.1...v2.2.2) (2020-09-14) - -**Note:** Version bump only for package midway-bin - - - - - -## [2.2.1](https://github.com/midwayjs/midway/compare/v2.2.0...v2.2.1) (2020-09-14) - -**Note:** Version bump only for package midway-bin - - - - - -# [2.2.0](https://github.com/midwayjs/midway/compare/v2.1.4...v2.2.0) (2020-09-13) - - -### Features - -* complete 2.x beta ([#630](https://github.com/midwayjs/midway/issues/630)) ([b23cd00](https://github.com/midwayjs/midway/commit/b23cd00fe9cefc9057a2284d38d5419773539206)) - - - - - -## [2.0.15](https://github.com/midwayjs/midway/compare/v2.0.14...v2.0.15) (2020-04-11) - - -### Bug Fixes - -* Fix default env ([#468](https://github.com/midwayjs/midway/issues/468)) ([db9ffcf](https://github.com/midwayjs/midway/commit/db9ffcfcc412bfb7613d46eb3b3b30f44e3b553f)), closes [#450](https://github.com/midwayjs/midway/issues/450) [#454](https://github.com/midwayjs/midway/issues/454) [#379](https://github.com/midwayjs/midway/issues/379) [#455](https://github.com/midwayjs/midway/issues/455) [#463](https://github.com/midwayjs/midway/issues/463) [#464](https://github.com/midwayjs/midway/issues/464) [#466](https://github.com/midwayjs/midway/issues/466) - - - - - -## [2.0.10](https://github.com/midwayjs/midway/compare/v2.0.9...v2.0.10) (2020-03-31) - -**Note:** Version bump only for package midway-bin - - - - - -## [2.0.9](https://github.com/midwayjs/midway/compare/v2.0.8...v2.0.9) (2020-03-30) - -**Note:** Version bump only for package midway-bin - - - - - -## [2.0.8](https://github.com/midwayjs/midway/compare/v2.0.7...v2.0.8) (2020-03-30) - -**Note:** Version bump only for package midway-bin - - - - - -## [2.0.7](https://github.com/midwayjs/midway/compare/v2.0.6...v2.0.7) (2020-03-30) - -**Note:** Version bump only for package midway-bin - - - - - -## [2.0.5](https://github.com/midwayjs/midway/compare/v2.0.4...v2.0.5) (2020-03-22) - - -### Bug Fixes - -* can midway build when tsconfig.json has comments ([#424](https://github.com/midwayjs/midway/issues/424)) ([f2b2713](https://github.com/midwayjs/midway/commit/f2b27137fe35d1de462adfdc289953d6a405ecd9)) - - - - - -## [2.0.4](https://github.com/midwayjs/midway/compare/v2.0.3...v2.0.4) (2020-03-19) - -**Note:** Version bump only for package midway-bin - - - - - -## [2.0.2](https://github.com/midwayjs/midway/compare/v2.0.1...v2.0.2) (2020-03-13) - -**Note:** Version bump only for package midway-bin - - - - - -# [2.0.0](https://github.com/midwayjs/midway/compare/v2.0.0-beta.16...v2.0.0) (2020-03-13) - -**Note:** Version bump only for package midway-bin - - - - - -# [2.0.0-beta.16](https://github.com/midwayjs/midway/compare/v2.0.0-beta.15...v2.0.0-beta.16) (2020-03-12) - -**Note:** Version bump only for package midway-bin - - - - - -# [2.0.0-beta.15](https://github.com/midwayjs/midway/compare/v2.0.0-beta.14...v2.0.0-beta.15) (2020-03-06) - -**Note:** Version bump only for package midway-bin - - - - - -# [2.0.0-beta.14](https://github.com/midwayjs/midway/compare/v2.0.0-beta.13...v2.0.0-beta.14) (2020-03-04) - -**Note:** Version bump only for package midway-bin - - - - - -# [2.0.0-beta.13](https://github.com/midwayjs/midway/compare/v2.0.0-beta.12...v2.0.0-beta.13) (2020-02-26) - -**Note:** Version bump only for package midway-bin - - - - - - - -**Note:** Version bump only for package midway-bin - - - - - -# [2.0.0-beta.12](https://github.com/midwayjs/midway/compare/v2.0.0-beta.11...v2.0.0-beta.12) (2020-02-25) - -**Note:** Version bump only for package midway-bin - - - - - -# [2.0.0-beta.11](https://github.com/midwayjs/midway/compare/v2.0.0-beta.10...v2.0.0-beta.11) (2020-02-25) - -**Note:** Version bump only for package midway-bin - - - - - -# [2.0.0-beta.10](https://github.com/midwayjs/midway/compare/v2.0.0-beta.9...v2.0.0-beta.10) (2020-02-20) - - -### Bug Fixes - -* ts build cwd ([#396](https://github.com/midwayjs/midway/issues/396)) ([83732f9](https://github.com/midwayjs/midway/commit/83732f90c325c646bc6983eac6460a7f65ca1c51)) - - - - - -# [2.0.0-beta.9](https://github.com/midwayjs/midway/compare/v2.0.0-beta.8...v2.0.0-beta.9) (2020-02-20) - - -### Bug Fixes - -* build-tsConfig ([#393](https://github.com/midwayjs/midway/issues/393)) ([fb451b4](https://github.com/midwayjs/midway/commit/fb451b419e0780c9fc803901e186eb38607284dc)) - - - - - -# [2.0.0-beta.8](https://github.com/midwayjs/midway/compare/v2.0.0-beta.7...v2.0.0-beta.8) (2020-02-19) - - -### Features - -* add tsConfig.json to tsc cmd line support ([#392](https://github.com/midwayjs/midway/issues/392)) ([8e368fb](https://github.com/midwayjs/midway/commit/8e368fb7bb0d290817ac0e1d266bf8295a71269c)) - - - - - -# [2.0.0-beta.7](https://github.com/midwayjs/midway/compare/v2.0.0-beta.6...v2.0.0-beta.7) (2020-02-18) - -**Note:** Version bump only for package midway-bin - - - - - -# [2.0.0-beta.6](https://github.com/midwayjs/midway/compare/v2.0.0-beta.5...v2.0.0-beta.6) (2020-02-17) - -**Note:** Version bump only for package midway-bin - - - - - -# [2.0.0-beta.5](https://github.com/midwayjs/midway/compare/v2.0.0-beta.4...v2.0.0-beta.5) (2020-02-17) - - -### Bug Fixes - -* **deps:** add terser to depenencies ([#390](https://github.com/midwayjs/midway/issues/390)) ([a8de587](https://github.com/midwayjs/midway/commit/a8de587)) - - -### Features - -* **build:** options to minify all products ([#389](https://github.com/midwayjs/midway/issues/389)) ([d309bdc](https://github.com/midwayjs/midway/commit/d309bdc)) - - - - - -## [1.17.1](https://github.com/midwayjs/midway/compare/v1.17.0...v1.17.1) (2020-02-17) - - -### Bug Fixes - -* **deps:** add terser to depenencies ([#390](https://github.com/midwayjs/midway/issues/390)) ([e6da77e](https://github.com/midwayjs/midway/commit/e6da77e)) - - - - - -# [1.17.0](https://github.com/midwayjs/midway/compare/v1.16.4...v1.17.0) (2020-02-17) - - -### Features - -* **build:** options to minify all products ([#389](https://github.com/midwayjs/midway/issues/389)) ([86d5279](https://github.com/midwayjs/midway/commit/86d5279)) - - - - - -# [2.0.0-beta.4](https://github.com/midwayjs/midway/compare/v1.16.4...v2.0.0-beta.4) (2020-02-16) - -**Note:** Version bump only for package midway-bin - - - - - -## [1.16.4](https://github.com/midwayjs/midway/compare/v1.16.3...v1.16.4) (2020-02-11) - - -### Bug Fixes - -* executing midway-bin build at arbitrary directory ([#384](https://github.com/midwayjs/midway/issues/384)) ([1ace418](https://github.com/midwayjs/midway/commit/1ace418)) - - - - - -## [1.16.3](https://github.com/midwayjs/midway/compare/v1.16.2...v1.16.3) (2019-12-25) - -**Note:** Version bump only for package midway-bin - - - - - -## [1.16.2](https://github.com/midwayjs/midway/compare/v1.16.1...v1.16.2) (2019-12-25) - - -### Bug Fixes - -* fix ts mode value is empty for non-ts items ([ef3b46a](https://github.com/midwayjs/midway/commit/ef3b46a)) - - - - - -## [1.16.1](https://github.com/midwayjs/midway/compare/v1.16.0...v1.16.1) (2019-12-16) - -**Note:** Version bump only for package midway-bin - - - - - -## [1.15.1](https://github.com/midwayjs/midway/compare/v1.15.0...v1.15.1) (2019-12-11) - - -### Bug Fixes - -* use co wrap generator for egg-bin run method ([14cdb2d](https://github.com/midwayjs/midway/commit/14cdb2d)) - - -### Features - -* **midway-bin:** do not populate exec argv to child processes ([f22c858](https://github.com/midwayjs/midway/commit/f22c858)) - - - - - -# [1.15.0](https://github.com/midwayjs/midway/compare/v1.14.4...v1.15.0) (2019-12-06) - - -### Bug Fixes - -* **midway-bin:** log message grammar ([30091d0](https://github.com/midwayjs/midway/commit/30091d0)) - - -### Features - -* **midway-bin:** add bundle support ([9894049](https://github.com/midwayjs/midway/commit/9894049)) -* **midway-bin:** use async-await instead of generator ([eed48f1](https://github.com/midwayjs/midway/commit/eed48f1)) - - - - - -## [1.14.4](https://github.com/midwayjs/midway/compare/v1.14.3...v1.14.4) (2019-11-20) - - -### Bug Fixes - -* fix lint ([77177fb](https://github.com/midwayjs/midway/commit/77177fb)) - - - - - -## [1.14.3](https://github.com/midwayjs/midway/compare/v1.14.2...v1.14.3) (2019-11-15) - - -### Bug Fixes - -* midway-bin include jest config ([20e2a86](https://github.com/midwayjs/midway/commit/20e2a86)) - - - - - -## [1.14.1](https://github.com/midwayjs/midway/compare/v1.14.0...v1.14.1) (2019-11-03) - -**Note:** Version bump only for package midway-bin - - - - - -# [1.14.0](https://github.com/midwayjs/midway/compare/v1.13.0...v1.14.0) (2019-11-01) - -**Note:** Version bump only for package midway-bin - - - - - -## [1.12.1](https://github.com/midwayjs/midway/compare/v1.12.0...v1.12.1) (2019-10-12) - - -### Bug Fixes - -* **midway-bin:** use resolveModule() instead of findFramework() ([#344](https://github.com/midwayjs/midway/issues/344)) ([8c24e2e](https://github.com/midwayjs/midway/commit/8c24e2e)) - - -### BREAKING CHANGES - -* **midway-bin:** remove findFramework() - - - - - -# [1.12.0](https://github.com/midwayjs/midway/compare/v1.11.6...v1.12.0) (2019-10-11) - - -### Features - -* **midway-bin:** add and export functions ([80ef6b8](https://github.com/midwayjs/midway/commit/80ef6b8)) - - - - - -## [1.11.4](https://github.com/midwayjs/midway/compare/v1.11.3...v1.11.4) (2019-09-06) - -**Note:** Version bump only for package midway-bin - - - - - -## [1.11.3](https://github.com/midwayjs/midway/compare/v1.11.2...v1.11.3) (2019-09-06) - - -### Bug Fixes - -* module path under mono repo ([8342487](https://github.com/midwayjs/midway/commit/8342487)), closes [#329](https://github.com/midwayjs/midway/issues/329) - - - - - -## [1.11.2](https://github.com/midwayjs/midway/compare/v1.11.1...v1.11.2) (2019-08-30) - -**Note:** Version bump only for package midway-bin - - - - - -## [1.10.8](https://github.com/midwayjs/midway/compare/v1.10.7...v1.10.8) (2019-08-03) - -**Note:** Version bump only for package midway-bin - - - - - -## [1.10.7](https://github.com/midwayjs/midway/compare/v1.10.6...v1.10.7) (2019-08-03) - -**Note:** Version bump only for package midway-bin - - - - - -## [1.10.5](https://github.com/midwayjs/midway/compare/v1.10.4...v1.10.5) (2019-07-30) - -**Note:** Version bump only for package midway-bin - - - - - -## [1.10.2](https://github.com/midwayjs/midway/compare/v1.10.1...v1.10.2) (2019-07-20) - -**Note:** Version bump only for package midway-bin - - - - - -# [1.9.0](https://github.com/midwayjs/midway/compare/v1.8.0...v1.9.0) (2019-07-13) - -**Note:** Version bump only for package midway-bin - - - - - -## [1.5.6](https://github.com/midwayjs/midway/compare/v1.5.5...v1.5.6) (2019-05-13) - - -### Bug Fixes - -* copy files by src dir ([ad7c28d](https://github.com/midwayjs/midway/commit/ad7c28d)) - - - - - -# [1.5.0](https://github.com/midwayjs/midway/compare/v1.4.10...v1.5.0) (2019-04-11) - - -### Features - -* add project options in midway-bin ([c635057](https://github.com/midwayjs/midway/commit/c635057)) - - - - - -## [1.4.7](https://github.com/midwayjs/midway/compare/v1.4.6...v1.4.7) (2019-03-08) - -**Note:** Version bump only for package midway-bin - - - - - -## [1.4.3](https://github.com/midwayjs/midway/compare/v1.4.2...v1.4.3) (2019-03-01) - -**Note:** Version bump only for package midway-bin - - - - - -## [1.4.1](https://github.com/midwayjs/midway/compare/v1.4.0...v1.4.1) (2019-02-27) - -**Note:** Version bump only for package midway-bin - - - - - -# [1.3.0](https://github.com/midwayjs/midway/compare/v1.2.4...v1.3.0) (2019-02-12) - - -### Features - -* add new doc command ([972db71](https://github.com/midwayjs/midway/commit/972db71)) -* support process.env.PORT in dev command ([0756f0e](https://github.com/midwayjs/midway/commit/0756f0e)) - - - - - -# [1.2.0](https://github.com/midwayjs/midway/compare/v1.1.2...v1.2.0) (2019-01-29) - -**Note:** Version bump only for package midway-bin - - - - - -# [1.1.0](https://github.com/midwayjs/midway/compare/v1.0.5...v1.1.0) (2019-01-23) - -**Note:** Version bump only for package midway-bin - - - - - -## [1.0.2](https://github.com/midwayjs/midway/compare/v1.0.1...v1.0.2) (2018-12-26) - -**Note:** Version bump only for package midway-bin - - - - - -## [1.0.1](https://github.com/midwayjs/midway/compare/v1.0.0...v1.0.1) (2018-12-23) - -**Note:** Version bump only for package midway-bin - - - - - -# [0.7.0](https://github.com/midwayjs/midway/compare/v0.6.5...v0.7.0) (2018-12-09) - - -### Features - -* Add build specified suffix file ([1752cf9](https://github.com/midwayjs/midway/commit/1752cf9)) - - - - - -## [0.6.5](https://github.com/midwayjs/midway/compare/v0.6.4...v0.6.5) (2018-11-27) - -**Note:** Version bump only for package midway-bin - - - - - -## [0.6.4](https://github.com/midwayjs/midway/compare/v0.6.3...v0.6.4) (2018-11-21) - -**Note:** Version bump only for package midway-bin - - - - - -## [0.6.3](https://github.com/midwayjs/midway/compare/v0.6.2...v0.6.3) (2018-11-20) - -**Note:** Version bump only for package midway-bin - - - - - -## [0.6.2](https://github.com/midwayjs/midway/compare/v0.6.1...v0.6.2) (2018-11-20) - -**Note:** Version bump only for package midway-bin - - - - - -# [0.6.0](https://github.com/midwayjs/midway/compare/v0.4.7...v0.6.0) (2018-11-15) - -**Note:** Version bump only for package midway-bin - - - - - -# [0.5.0](https://github.com/midwayjs/midway/compare/v0.4.5...v0.5.0) (2018-11-15) - -**Note:** Version bump only for package midway-bin - - - - - - -## [0.3.8](https://github.com/midwayjs/midway/compare/v0.3.7...v0.3.8) (2018-09-25) - - - - -**Note:** Version bump only for package midway-bin - - -## [0.3.2](https://github.com/midwayjs/midway/compare/v0.3.1...v0.3.2) (2018-08-30) - - - - -**Note:** Version bump only for package midway-bin - - -## [0.3.1](https://github.com/midwayjs/midway/compare/v0.3.0...v0.3.1) (2018-08-30) - - - - -**Note:** Version bump only for package midway-bin - - -# [0.3.0](https://github.com/midwayjs/midway/compare/v0.2.10...v0.3.0) (2018-08-29) - - - - -**Note:** Version bump only for package midway-bin - - -## [0.2.4](https://github.com/midwayjs/midway/compare/v0.2.3...v0.2.4) (2018-08-06) - - - - -**Note:** Version bump only for package midway-bin - - -## [0.2.1](https://github.com/midwayjs/midway/compare/v0.2.0...v0.2.1) (2018-08-03) - - -### Bug Fixes - -* dev command loop execution ([b08a0c0](https://github.com/midwayjs/midway/commit/b08a0c0)) - - - - - -## [0.1.6](https://github.com/midwayjs/midway/compare/v0.1.5...v0.1.6) (2018-07-30) - - - - -**Note:** Version bump only for package midway-bin - - -# [0.2.0-alpha.1663751b](https://github.com/midwayjs/midway/compare/v0.1.5...v0.2.0-alpha.1663751b) (2018-07-30) - - - - -**Note:** Version bump only for package midway-bin - - -## [0.1.5](https://github.com/midwayjs/midway/compare/v0.1.4...v0.1.5) (2018-07-30) - - - - -**Note:** Version bump only for package midway-bin - - -## [0.1.4](https://github.com/midwayjs/midway/compare/v0.1.3...v0.1.4) (2018-07-30) - - - - -**Note:** Version bump only for package midway-bin diff --git a/packages/midway-bin/README.md b/packages/midway-bin/README.md deleted file mode 100644 index ea743931ea1e..000000000000 --- a/packages/midway-bin/README.md +++ /dev/null @@ -1,110 +0,0 @@ -# midway-bin - -[![Package Quality](http://npm.packagequality.com/shield/midway-bin.svg)](http://packagequality.com/#?package=midway-bin) -[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls) - -this is a sub package for midway. - -midway developer tool, extends [egg-bin]. - ---- - -## Install - -```bash -$ npm i midway-bin --save-dev -``` - -## Usage - -Add `midway-bin` to `package.json` scripts like [egg-bin], but just replace command by `midway-bin: - -```json -{ - "scripts": { - "dev": "midway-bin dev", - "debug": "midway-bin debug", - "test-local": "midway-bin test", - "test": "npm run lint -- --fix && npm run midway-local", - "cov": "midway-bin cov", - "lint": "eslint .", - "pkgfiles": "midway-bin pkgfiles", - "autod": "midway-bin autod", - "ci": "npm run lint && npm run autod -- --check && npm run pkgfiles -- --check && npm run cov" - } -} -``` - -## Command - -`midway-bin` add new command - -- build -- clean -- doc - -### build - -build typescript source file to dist directory like `tsc` and copy js/css/html file to same place. - -```bash -$ midway-bin build -``` - -#### options - -- `--clean -c` clean dist directory before build -- `--entrypoint ` bundle the output with the specified file as entrypoint - -#### copy static file - -we can copy static file when ts file compiling. - -```js -// in package.json - "midway-bin-build": { - "include": [ - "app/public", - "app/view" - ] - } -``` - -it will be copy `src/app/public` to `${outDir}/app/public`. - -The `outDir` field is configured in the `tsconfig.json` File, see [compiler-options](https://www.typescriptlang.org/docs/handbook/compiler-options.html). - -### clean - -clean a dist directory by build - -```bash -$ midway-bin clean -``` - -### doc - -generate application document by typedoc - -```bash -$ midway-bin doc -``` - -#### options - -like typedoc, see [link](https://typedoc.org/guides/arguments/) - -- `--options [typedoc.js]` Specify a js option file that should be loaded. -- `--out -o [outPath]` Specifies the location the documentation should be written to. -- `--mode -m` default value is `file`, Specifies the output mode the project is used to be compiled with. -- `--exclude` Exclude files by the given pattern when a path is provided as source. -- `--theme` default value is `default` Specify the path to the theme that should be used. -- `--excludeExternals` default value is `true` Prevent externally resolved TypeScript files from being documented. -- `--ignoreCompilerErrors` default value is `true` Generates documentation, even if the project does not TypeScript compile. -- `--hideGenerator` default value is `true` Do not print the TypeDoc link at the end of the page. - -> Tips: If the options parameter is supplied, the other default parameters are invalid - -## License - -[MIT](LICENSE) diff --git a/packages/midway-bin/bin/midway-bin.js b/packages/midway-bin/bin/midway-bin.js deleted file mode 100755 index b412160db1b6..000000000000 --- a/packages/midway-bin/bin/midway-bin.js +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env node - -'use strict'; - -const Command = require('../').MidwayBin; -new Command().start(); diff --git a/packages/midway-bin/bin/mocha.js b/packages/midway-bin/bin/mocha.js deleted file mode 100755 index 9fba8b6b7fb5..000000000000 --- a/packages/midway-bin/bin/mocha.js +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env node - -'use strict'; - -require('egg-bin/bin/mocha'); diff --git a/packages/midway-bin/index.js b/packages/midway-bin/index.js deleted file mode 100644 index bac31f2c3753..000000000000 --- a/packages/midway-bin/index.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -const Command = require('egg-bin/lib/command'); -const path = require('path'); - -class MidwayBin extends Command { - constructor(rawArgv) { - super(rawArgv); - this.usage = 'Usage: midway-bin [command] [options]'; - // load directory - this.load(path.join(__dirname, 'lib/cmd')); - } -} - -exports.MidwayBin = MidwayBin; -exports.AutodCommand = require('./lib/cmd/autod'); -exports.BuildCommand = require('./lib/cmd/build'); -exports.CovCommand = require('./lib/cmd/cov'); -exports.DevCommand = require('./lib/cmd/dev'); -exports.TestCommand = require('./lib/cmd/test'); -exports.DebugCommand = require('./lib/cmd/debug'); -exports.PkgfilesCommand = require('./lib/cmd/pkgfiles'); -exports.CleanCommand = require('./lib/cmd/clean'); -exports.DocCommand = require('./lib/cmd/doc'); -exports.resolveModule = require('./lib/util').resolveModule; diff --git a/packages/midway-bin/jest/env.js b/packages/midway-bin/jest/env.js deleted file mode 100644 index de972aefb21f..000000000000 --- a/packages/midway-bin/jest/env.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; -const NodeEnvironment = require('jest-environment-node'); - -/* eslint-disable no-useless-constructor */ -class JestEnvironment extends NodeEnvironment { - constructor(config) { - super(config); - } - - async setup() { - /* eslint-disable node/no-extraneous-require */ - require('ts-node/register'); - this.global.process.env.MIDWAY_TS_MODE = 'true'; - this.global.process.env.MIDWAY_JEST_MODE = 'true'; - await super.setup(); - } - - async teardown() { - await super.teardown(); - } - - runScript(script) { - return super.runScript(script); - } -} - -module.exports = JestEnvironment; diff --git a/packages/midway-bin/lib/cmd/autod.js b/packages/midway-bin/lib/cmd/autod.js deleted file mode 100644 index f1c61ce4c818..000000000000 --- a/packages/midway-bin/lib/cmd/autod.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -class AutodCommand extends require('egg-bin/lib/cmd/autod') { - constructor(rawArgv) { - super(rawArgv); - this.usage = 'Usage: midway-bin autod'; - } -} - -module.exports = AutodCommand; diff --git a/packages/midway-bin/lib/cmd/build.js b/packages/midway-bin/lib/cmd/build.js deleted file mode 100644 index c49a3eb75ad9..000000000000 --- a/packages/midway-bin/lib/cmd/build.js +++ /dev/null @@ -1,365 +0,0 @@ -'use strict'; - -const Command = require('egg-bin').Command; -const path = require('path'); -const fs = require('fs'); -const rimraf = require('mz-modules/rimraf'); -const fse = require('fs-extra'); -const globby = require('globby'); -const ncc = require('@midwayjs/ncc'); -const terser = require('terser'); -let typescript; - -const shebangRegEx = /^#![^\n\r]*[\r\n]/; -const inlineSourceMapRegEx = /\/\/# sourceMappingURL=data:application\/json;base64,(.*)/; - -class BuildCommand extends Command { - constructor(rawArgv) { - super(rawArgv); - this.usage = 'Usage: midway-bin build [options]'; - - this.options = { - clean: { - description: 'clean build target dir', - type: 'boolean', - alias: 'c', - }, - project: { - description: 'project file location', - type: 'string', - alias: 'p', - default: 'tsconfig.json', - }, - srcDir: { - description: 'source code path', - type: 'string', - default: 'src', - }, - entrypoint: { - description: 'bundle the source with the file given as entrypoint', - type: 'string', - default: '', - }, - minify: { - type: 'boolean', - }, - mode: { - description: 'bundle mode, "debug" or "release" (default)', - type: 'string', - default: 'release', - }, - tsConfig: { - description: 'tsConfig json object data', - type: 'object', - }, - }; - } - - get description() { - return 'build application automatically'; - } - - async run(context) { - const { cwd, argv } = context; - - /* eslint-disable node/no-extraneous-require */ - const tscCli = require.resolve('typescript/bin/tsc'); - const projectFile = path.join(cwd, argv.project || ''); - if (typeof argv.tsConfig === 'string') { - try { - argv.tsConfig = JSON.parse(argv.tsConfig); - } catch (e) { - console.log( - `[midway-bin] tsConfig should be JSON string or Object: ${e.message}\n` - ); - return; - } - } - if (!argv.tsConfig && !fs.existsSync(projectFile)) { - console.log(`[midway-bin] tsconfig.json not found in ${cwd}\n`); - return; - } - let tsConfig = argv.tsConfig; - if (!tsConfig) { - const Hjson = require('hjson'); - tsConfig = Hjson.parse(fs.readFileSync(projectFile, 'utf-8')); - } - const projectDir = (this.projectDir = path.dirname(projectFile)); - let outDir = this.inferCompilerOptions(tsConfig, 'outDir'); - let outDirAbsolute; - if (outDir) { - outDir = path.resolve(projectDir, outDir); - outDir = path.relative(projectDir, outDir); - outDirAbsolute = path.join(projectDir, outDir); - } - - if (argv.clean) { - await this.cleanDir(outDirAbsolute); - } - - await this.copyFiles(projectDir, outDir, argv); - - if (argv.mode !== 'release') { - argv.mode = 'debug'; - } - if (argv.entrypoint) { - outDir = outDirAbsolute || path.resolve(projectDir, 'dist'); - await this.bundle(path.resolve(cwd, argv.entrypoint), outDir, { - sourceMap: this.inferCompilerOptions(tsConfig, 'sourceMap', { - projectDir, - }), - mode: argv.mode, - }); - return; - } - - const args = []; - - if (argv.project) { - args.push('-p'); - args.push(argv.project); - } else if (argv.tsConfig) { - await this.tsCfg2CliArgs(cwd, argv, args); - } - await this.helper.forkNode(tscCli, args, { cwd, execArgv: [] }); - - if (argv.minify) { - await this.minify(tsConfig, outDirAbsolute); - } - } - - async bundle(entry, outDir, { sourceMap = false, mode } = {}) { - // Assets is an object of asset file names to { source, permissions, symlinks } - // expected relative to the output code (if any) - const options = { - // provide a custom cache path or disable caching - cache: false, - // externals to leave as requires of the build - externals: [], - // directory outside of which never to emit assets - filterAssetBase: process.cwd(), - minify: false, - sourceMap, - // default treats sources as output-relative - sourceMapBasePrefix: path.relative(outDir, process.cwd()) + '/', - // Node.js v12 comes with builtin source map support. - sourceMapRegister: false, - watch: false, - v8cache: false, - quiet: false, - debugLog: false, - }; - if (mode === 'release') { - options.minify = true; - } - const { error, code, map, assets, symlinks } = await ncc(entry, options); - - if (error) { - console.error(error); - return; - } - - fse.mkdirpSync(outDir); - - let basename = path.basename(entry, '.ts'); - if (!basename.endsWith('.js')) { - basename += '.js'; - } - fs.writeFileSync(outDir + '/' + basename, code, { - mode: code.match(shebangRegEx) ? 0o777 : 0o666, - }); - if (map) fs.writeFileSync(outDir + '/index.js.map', map); - - for (const asset of Object.keys(assets)) { - const assetPath = outDir + '/' + asset; - fse.mkdirpSync(path.dirname(assetPath)); - fs.writeFileSync(assetPath, assets[asset].source, { - mode: assets[asset].permissions, - }); - } - - for (const symlink of Object.keys(symlinks)) { - const symlinkPath = outDir + '/' + symlink; - fs.symlinkSync(symlinks[symlink], symlinkPath); - } - } - - async cleanDir(dir) { - if (dir) { - await rimraf(dir); - } - } - - async copyFiles(from, outDir, argv) { - if (outDir && fs.existsSync(path.join(from, 'package.json'))) { - const pkg = require(path.join(from, 'package.json')); - if (pkg['midway-bin-build'] && pkg['midway-bin-build'].include) { - for (const file of pkg['midway-bin-build'].include) { - if (typeof file === 'string' && !/\*/.test(file)) { - const srcDir = path.join(argv.srcDir, file); - const targetDir = path.join(outDir, file); - // 目录,或者不含通配符的普通文件 - this.copyFile(srcDir, targetDir, from); - } else { - // 通配符的情况 - const paths = await globby([].concat(file), { - cwd: path.join(from, argv.srcDir), - }); - for (const p of paths) { - this.copyFile( - path.join(argv.srcDir, p), - path.join(outDir, p), - from - ); - } - } - } - } - } - } - - copyFile(srcFile, targetFile, from) { - if (!fs.existsSync(srcFile)) { - console.warn(`[midway-bin] can't find ${srcFile} and skip it`); - } else { - fse.copySync(path.join(from, srcFile), path.join(from, targetFile)); - console.log(`[midway-bin] copy ${srcFile} to ${targetFile} success!`); - } - } - - inferCompilerOptions( - tsConfig, - optionKeyPath, - { projectDir = process.cwd() } = {} - ) { - // if projectFile extended and without the option, - // get setting from its parent - if (tsConfig && tsConfig.extends) { - if ( - !tsConfig.compilerOptions || - (tsConfig.compilerOptions && !tsConfig.compilerOptions[optionKeyPath]) - ) { - return this.inferCompilerOptions( - require(path.join(projectDir, tsConfig.extends)), - optionKeyPath, - { projectDir } - ); - } - } - - if (tsConfig && tsConfig.compilerOptions) { - return tsConfig.compilerOptions[optionKeyPath]; - } - } - - async minify(tsConfig, outDir) { - if (typescript == null) { - /* eslint-disable node/no-extraneous-require */ - typescript = require('typescript'); - } - - const inlineSourceMap = !!tsConfig.compilerOptions.inlineSourceMap; - const sourceMap = inlineSourceMap || tsConfig.compilerOptions.sourceMap; - if (!sourceMap) { - return; - } - - let files; - if (outDir) { - files = globby.sync(['**/*.js'], { - cwd: outDir, - ignore: ['**/node_modules'], - }); - files = files.map(it => path.join(outDir, it)); - } else { - const host = typescript.createCompilerHost(tsConfig.compilerOptions); - files = host.readDirectory( - __dirname, - ['.ts'], - tsConfig.exclude, - tsConfig.include - ); - files = files.map(it => { - return path.join(path.dirname(it), path.basename(it, '.js')); - }); - } - - for (const file of files) { - let code = await fse.readFile(file, 'utf8'); - let map; - if (inlineSourceMap) { - map = this.parseInlineSourceMap(code); - } else { - map = await fse.readFile(file + '.map', 'utf8'); - } - map = JSON.parse(map); - const result = terser.minify(code, { - compress: false, - mangle: { - keep_classnames: true, - keep_fnames: true, - }, - sourceMap: { - content: map, - filename: path.basename(file), - url: inlineSourceMap ? 'inline' : `${path.basename(file)}.map`, - }, - }); - ({ code, map } = result); - if (code == null) { - break; - } - if (!inlineSourceMap) { - await fse.writeFile(file + '.map', map, 'utf8'); - } - await fse.writeFile(file, code, 'utf8'); - } - } - - parseInlineSourceMap(code) { - const match = inlineSourceMapRegEx.exec(code); - if (match == null) { - return; - } - const map = Buffer.from(match[1], 'base64').toString('utf8'); - return map; - } - - async tsCfg2CliArgs(cwd, argv, args) { - const cfg = argv.tsConfig; - // https://www.typescriptlang.org/docs/handbook/tsconfig-json.html - /** - * include & exclude - */ - const files = await globby( - [].concat( - cfg.files || [], - cfg.include ? cfg.include : 'src/**/*', // include - (cfg.exclude || []).map(str => '!' + str) // exclude - ), - { cwd } - ); - for (const item of files) { - if (/\.tsx?$/.test(item)) { - args.push(item); - } - } - - /** - * compilerOptions - */ - for (const key in cfg.compilerOptions || {}) { - if ( - cfg.compilerOptions[key] === true || - cfg.compilerOptions[key] === 'true' - ) { - args.push(`--${key}`); - } else { - args.push(`--${key}`); - args.push(cfg.compilerOptions[key]); - } - } - } -} - -module.exports = BuildCommand; diff --git a/packages/midway-bin/lib/cmd/clean.js b/packages/midway-bin/lib/cmd/clean.js deleted file mode 100644 index dc9f3d678d27..000000000000 --- a/packages/midway-bin/lib/cmd/clean.js +++ /dev/null @@ -1,54 +0,0 @@ -'use strict'; - -const Command = require('egg-bin').Command; -const rimraf = require('mz-modules/rimraf'); -const path = require('path'); -const fseExtra = require('fs-extra'); - -class CleanCommand extends Command { - constructor(rawArgv) { - super(rawArgv); - this.usage = 'Usage: midway-bin clean'; - } - - get description() { - return 'clean application temporary files'; - } - - async run(context) { - const { cwd } = context; - if (!fseExtra.existsSync(path.join(cwd, 'package.json'))) { - console.log(`[midway-bin] package.json not found in ${cwd}\n`); - return; - } - await this.cleanDir(cwd); - } - - async cleanDir(cwd) { - await new Promise((resolve, reject) => { - const rmDirName = ['logs', 'run', '.nodejs-cache']; - try { - rmDirName.forEach(name => { - fseExtra.removeSync(path.join(cwd, name)); - }); - console.log('[midway-bin] clean midway temporary files complete!'); - resolve(); - } catch (error) { - console.error(`[midway-bin] exec error: ${error}`); - reject(error); - return; - } - }); - - const pkg = require(path.join(cwd, 'package.json')); - if (pkg['midway-bin-clean'] && pkg['midway-bin-clean'].length) { - for (const file of pkg['midway-bin-clean']) { - await rimraf(path.join(cwd, file)); - console.log(`[midway-bin] clean ${file} success!`); - } - console.log('[midway-bin] clean complete!'); - } - } -} - -module.exports = CleanCommand; diff --git a/packages/midway-bin/lib/cmd/cov.js b/packages/midway-bin/lib/cmd/cov.js deleted file mode 100644 index 984713741b33..000000000000 --- a/packages/midway-bin/lib/cmd/cov.js +++ /dev/null @@ -1,12 +0,0 @@ -/* istanbul ignore next */ -'use strict'; - -/* istanbul ignore next */ -class CovCommand extends require('egg-bin').CovCommand { - constructor(argv) { - super(argv); - this.usage = 'Usage: midway-bin cov'; - } -} - -module.exports = CovCommand; diff --git a/packages/midway-bin/lib/cmd/debug.js b/packages/midway-bin/lib/cmd/debug.js deleted file mode 100644 index 98d8281e3d12..000000000000 --- a/packages/midway-bin/lib/cmd/debug.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; -const resolver = require('../util').resolveModule; -const co = require('co'); - -class DebugCommand extends require('egg-bin').DebugCommand { - constructor(rawArgv) { - super(rawArgv); - this.usage = 'Usage: midway-bin debug [dir] [options]'; - } - - async run(context) { - if (!context.argv.framework) { - context.argv.framework = - this.findFramework('midway') || this.findFramework('midway-mirror'); - } - await co(super.run(context)); - } - - findFramework(module) { - return resolver(module); - } -} - -module.exports = DebugCommand; diff --git a/packages/midway-bin/lib/cmd/dev.js b/packages/midway-bin/lib/cmd/dev.js deleted file mode 100644 index 7caa410caefa..000000000000 --- a/packages/midway-bin/lib/cmd/dev.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; -const resolver = require('../util').resolveModule; -const co = require('co'); - -class DevCommand extends require('egg-bin/lib/cmd/dev') { - constructor(rawArgv) { - super(rawArgv); - this.usage = 'Usage: midway-bin dev [dir] [options]'; - this.defaultPort = process.env.PORT || 7001; - } - - async run(context) { - if (!context.argv.framework) { - context.argv.framework = - this.findFramework('midway') || this.findFramework('midway-mirror'); - } - await co(super.run(context)); - } - - findFramework(module) { - return resolver(module); - } -} - -module.exports = DevCommand; diff --git a/packages/midway-bin/lib/cmd/doc.js b/packages/midway-bin/lib/cmd/doc.js deleted file mode 100644 index ab7bb123e634..000000000000 --- a/packages/midway-bin/lib/cmd/doc.js +++ /dev/null @@ -1,84 +0,0 @@ -'use strict'; - -const Command = require('egg-bin').Command; - -class DocCommand extends Command { - constructor(rawArgv) { - super(rawArgv); - this.usage = 'Usage: midway-bin doc [options]'; - - this.options = { - out: { - description: - 'Specifies the location the documentation should be written to.', - type: 'string', - default: 'doc', - alias: 'o', - }, - mode: { - description: - 'Specifies the output mode the project is used to be compiled with.', - type: 'string', - default: 'file', - alias: 'm', - }, - options: { - description: - 'Specify a js option file that should be loaded. If not specified TypeDoc will look for ‘typedoc.json’ in the current directory.', - type: 'string', - }, - exclude: { - description: - 'Exclude files by the given pattern when a path is provided as source.', - type: 'string', - }, - theme: { - description: 'Specify the path to the theme that should be used.', - type: 'string', - default: 'default', - }, - excludeExternals: { - description: - 'Prevent externally resolved TypeScript files from being documented.', - type: 'boolean', - default: true, - }, - ignoreCompilerErrors: { - description: - 'Generates documentation, even if the project does not TypeScript compile.', - type: 'boolean', - default: true, - }, - hideGenerator: { - description: 'Do not print the TypeDoc link at the end of the page.', - type: 'boolean', - default: true, - }, - }; - } - - get description() { - return 'generate typescript document by typedoc'; - } - - async run({ cwd, argv }) { - let args; - if (argv.options) { - // if has options args just ignore others - args = ['--options', argv.options]; - } else { - args = this.helper.unparseArgv(argv, { - allowCamelCase: true, - useEquals: false, - }); - args = args.filter(item => { - return !/--\w+-\w+/.test(item); - }); - } - - const docBin = require.resolve('typedoc/bin/typedoc'); - await this.helper.forkNode(docBin, args, { cwd, execArgv: [] }); - } -} - -module.exports = DocCommand; diff --git a/packages/midway-bin/lib/cmd/pkgfiles.js b/packages/midway-bin/lib/cmd/pkgfiles.js deleted file mode 100644 index 1f29c05f1058..000000000000 --- a/packages/midway-bin/lib/cmd/pkgfiles.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -class PkgfilesCommand extends require('egg-bin').PkgfilesCommand { - constructor(rawArgv) { - super(rawArgv); - this.usage = 'Usage: midway-bin pkgfiles'; - } -} - -module.exports = PkgfilesCommand; diff --git a/packages/midway-bin/lib/cmd/test.js b/packages/midway-bin/lib/cmd/test.js deleted file mode 100644 index 465cd4f1bf25..000000000000 --- a/packages/midway-bin/lib/cmd/test.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; -const co = require('co'); - -class TestCommand extends require('egg-bin').TestCommand { - constructor(rawArgv) { - super(rawArgv); - this.usage = 'Usage: midway-bin test [files] [options]'; - } - - async run(context) { - if (!context.env.NODE_ENV) { - context.env.NODE_ENV = 'unittest'; - } - await co(super.run(context)); - } -} - -module.exports = TestCommand; diff --git a/packages/midway-bin/lib/util.js b/packages/midway-bin/lib/util.js deleted file mode 100644 index b3f156458080..000000000000 --- a/packages/midway-bin/lib/util.js +++ /dev/null @@ -1,50 +0,0 @@ -'use strict'; -const fs = require('fs'); -const path = require('path'); - -/** - * Resolve module's full path - * @param {string} moduleName module name - * @return {string} full path or blank - */ -function resolveModule(moduleName) { - if (!moduleName) { - console.log( - '[midway-bin] value of framework/module to be loaded is blank and skipped.' - ); - return ''; - } - - const moduleFullPath = retrieveModulePath(moduleName); - if (moduleFullPath) { - return moduleFullPath; - } - console.log( - `[midway-bin] Not found framework or module "${moduleName}" and skip.` - ); - return ''; -} - -/** - * Retrieve correct module path - * @param {string} moduleName module name - * @return {string} path - */ -function retrieveModulePath(moduleName) { - const paths = require.resolve.paths(moduleName); - - const moduleDir = paths.find(dir => { - const mpath = path.join(dir, moduleName); - try { - fs.accessSync(mpath, fs.constants.R_OK); - const stats = fs.statSync(mpath); - return stats && stats.isDirectory(); - } catch (ex) { - return false; - } - }); - - return moduleDir ? path.join(moduleDir, moduleName) : ''; -} - -exports.resolveModule = resolveModule; diff --git a/packages/midway-bin/package.json b/packages/midway-bin/package.json deleted file mode 100644 index 2d9840ed1a90..000000000000 --- a/packages/midway-bin/package.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "name": "midway-bin", - "version": "2.2.4", - "description": "Midway Command Tools", - "main": "index.js", - "bin": { - "midway-bin": "bin/midway-bin.js", - "mocha": "bin/mocha.js" - }, - "scripts": { - "test": "npm run lint -- --fix && npm run test-local", - "test-local": "node bin/midway-bin.js test -t 3600000", - "cov": "nyc -r lcov -r text-summary npm run test-local", - "ci": "npm run cov" - }, - "keywords": [ - "midway", - "bin" - ], - "license": "MIT", - "dependencies": { - "@midwayjs/ncc": "^0.22.0", - "co": "^4.6.0", - "egg-bin": "^4.11.1", - "fs-extra": "^8.0.1", - "globby": "^10.0.1", - "hjson": "^3.2.1", - "jest-environment-node": "^24.9.0", - "mz-modules": "^2.1.0", - "terser": "^4.6.3", - "typedoc": "^0.14.2" - }, - "devDependencies": { - "co-mocha": "^1.2.2", - "coffee": "^5.2.1", - "mm": "^2.5.0" - }, - "engines": { - "node": ">=10.0.0" - }, - "files": [ - "bin", - "lib", - "jest", - "index.js" - ], - "author": "Harry Chen ", - "repository": { - "type": "git", - "url": "http://github.com/midwayjs/midway.git" - }, - "gitHead": "44c0803552baf265debed8a11a860988b7e07a85" -} diff --git a/packages/midway-bin/test/fixtures/clean-dir-config/a.ts b/packages/midway-bin/test/fixtures/clean-dir-config/a.ts deleted file mode 100644 index 90ea39dbb902..000000000000 --- a/packages/midway-bin/test/fixtures/clean-dir-config/a.ts +++ /dev/null @@ -1 +0,0 @@ -console.log('aaaa'); diff --git a/packages/midway-bin/test/fixtures/clean-dir-config/package.json b/packages/midway-bin/test/fixtures/clean-dir-config/package.json deleted file mode 100644 index db4e70cb2c32..000000000000 --- a/packages/midway-bin/test/fixtures/clean-dir-config/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "clean-dir", - "version": "0.0.1", - "dependencies": { - - }, - "midway-bin-clean": [ - "customDir" - ] -} diff --git a/packages/midway-bin/test/fixtures/clean-dir/a.ts b/packages/midway-bin/test/fixtures/clean-dir/a.ts deleted file mode 100644 index 90ea39dbb902..000000000000 --- a/packages/midway-bin/test/fixtures/clean-dir/a.ts +++ /dev/null @@ -1 +0,0 @@ -console.log('aaaa'); diff --git a/packages/midway-bin/test/fixtures/clean-dir/package.json b/packages/midway-bin/test/fixtures/clean-dir/package.json deleted file mode 100644 index c13d1560fa4e..000000000000 --- a/packages/midway-bin/test/fixtures/clean-dir/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "clean-dir", - "version": "0.0.1", - "dependencies": { - - } -} diff --git a/packages/midway-bin/test/fixtures/test-files/lib/a.js b/packages/midway-bin/test/fixtures/test-files/lib/a.js deleted file mode 100644 index 446f37e19825..000000000000 --- a/packages/midway-bin/test/fixtures/test-files/lib/a.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -module.exports = condition => { - if (condition) { - return 'a'; - } - return 'b'; -}; diff --git a/packages/midway-bin/test/fixtures/test-files/test/a.test.js b/packages/midway-bin/test/fixtures/test-files/test/a.test.js deleted file mode 100644 index d18293076c83..000000000000 --- a/packages/midway-bin/test/fixtures/test-files/test/a.test.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const a = require('../lib/a'); - -describe('a.test.js', () => { - it('should success', () => { - a(true); - }); - - it('should show tmp', () => { - const tmpdir = process.env.TMPDIR; - console.log(tmpdir, fs.existsSync(tmpdir)); - }); -}); diff --git a/packages/midway-bin/test/fixtures/ts-dir-doc-options/a.ts b/packages/midway-bin/test/fixtures/ts-dir-doc-options/a.ts deleted file mode 100644 index 07e321cbd79b..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-doc-options/a.ts +++ /dev/null @@ -1,2 +0,0 @@ -import * as path from 'path'; -console.log(path.extname(__filename)); diff --git a/packages/midway-bin/test/fixtures/ts-dir-doc-options/tsconfig.json b/packages/midway-bin/test/fixtures/ts-dir-doc-options/tsconfig.json deleted file mode 100644 index e127761600dd..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-doc-options/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2017", - "module": "commonjs", - "moduleResolution": "node", - "experimentalDecorators": true, - "noImplicitThis": true, - "noUnusedLocals": true, - "stripInternal": true, - "pretty": true, - "declaration": true, - "sourceMap": true, - "outDir": "dist", - "lib": ["es2017", "dom"] - }, - "exclude": [ - "dist", - "node_modules", - "test" - ] -} diff --git a/packages/midway-bin/test/fixtures/ts-dir-doc-options/typedoc.js b/packages/midway-bin/test/fixtures/ts-dir-doc-options/typedoc.js deleted file mode 100644 index 9ad5f2113cb7..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-doc-options/typedoc.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - name: 'Midway Api Reference', - mode: 'file', - out: 'docs/api', - target: 'ES2015', - moduleResolution: 'node', - src: '.', - theme: 'default', - ignoreCompilerErrors: true, - preserveConstEnums: true, - exclude: '*.spec.ts', - // 'external-modulemap': '.*packages\/.*', - stripInternal: false -}; diff --git a/packages/midway-bin/test/fixtures/ts-dir-no-config/src/a.ts b/packages/midway-bin/test/fixtures/ts-dir-no-config/src/a.ts deleted file mode 100644 index 7d30c1f2f037..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-no-config/src/a.ts +++ /dev/null @@ -1 +0,0 @@ -console.log('hello' as string); \ No newline at end of file diff --git a/packages/midway-bin/test/fixtures/ts-dir-tsconfig-comments/src/index.ts b/packages/midway-bin/test/fixtures/ts-dir-tsconfig-comments/src/index.ts deleted file mode 100644 index c46950257c0d..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-tsconfig-comments/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export class Comment{ - -} \ No newline at end of file diff --git a/packages/midway-bin/test/fixtures/ts-dir-tsconfig-comments/tsconfig.json b/packages/midway-bin/test/fixtures/ts-dir-tsconfig-comments/tsconfig.json deleted file mode 100644 index 8e2f38dc82ac..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-tsconfig-comments/tsconfig.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "compilerOptions": { - /* Basic Options */ - // "incremental": true, /* Enable incremental compilation */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ - // "lib": [], /* Specify library files to be included in the compilation. */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - "outDir": "./dist", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "composite": true, /* Enable project compilation */ - // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - - /* Strict Type-Checking Options */ - "strict": true, /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "strictFunctionTypes": true, /* Enable strict checking of function types. */ - // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ - // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ - // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - - /* Source Map Options */ - // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - - /* Advanced Options */ - "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ - } -} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-another-tsconfig/a.ts b/packages/midway-bin/test/fixtures/ts-dir-with-another-tsconfig/a.ts deleted file mode 100644 index 07e321cbd79b..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-another-tsconfig/a.ts +++ /dev/null @@ -1,2 +0,0 @@ -import * as path from 'path'; -console.log(path.extname(__filename)); diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-another-tsconfig/tsconfig.json b/packages/midway-bin/test/fixtures/ts-dir-with-another-tsconfig/tsconfig.json deleted file mode 100644 index e127761600dd..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-another-tsconfig/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2017", - "module": "commonjs", - "moduleResolution": "node", - "experimentalDecorators": true, - "noImplicitThis": true, - "noUnusedLocals": true, - "stripInternal": true, - "pretty": true, - "declaration": true, - "sourceMap": true, - "outDir": "dist", - "lib": ["es2017", "dom"] - }, - "exclude": [ - "dist", - "node_modules", - "test" - ] -} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-another-tsconfig/tsconfig.prod.json b/packages/midway-bin/test/fixtures/ts-dir-with-another-tsconfig/tsconfig.prod.json deleted file mode 100644 index fc8520e73765..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-another-tsconfig/tsconfig.prod.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./tsconfig.json" -} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/package.json b/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/package.json deleted file mode 100644 index 29e463f99ed0..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "ts-dir-with-assets", - "version": "0.0.1", - "dependencies": { - - }, - "midway-bin-build": { - "include": [ - "public", - "view", - "resource.json", - "lib/*.json", - "lib/*.text", - ["pattern/**", "!pattern/**/*.js"] - ] - } -} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/a.ts b/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/a.ts deleted file mode 100644 index 07e321cbd79b..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/a.ts +++ /dev/null @@ -1,2 +0,0 @@ -import * as path from 'path'; -console.log(path.extname(__filename)); diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/lib/a.text b/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/lib/a.text deleted file mode 100644 index 8baef1b4abc4..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/lib/a.text +++ /dev/null @@ -1 +0,0 @@ -abc diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/lib/b.json b/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/lib/b.json deleted file mode 100644 index 0967ef424bce..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/lib/b.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/pattern/ignore.css b/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/pattern/ignore.css deleted file mode 100644 index 208d16d4213b..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/pattern/ignore.css +++ /dev/null @@ -1 +0,0 @@ -body {} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/pattern/ignore.js b/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/pattern/ignore.js deleted file mode 100644 index 9658cc642ee8..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/pattern/ignore.js +++ /dev/null @@ -1 +0,0 @@ -alert(1); diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/pattern/sub/sub_ignore.css b/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/pattern/sub/sub_ignore.css deleted file mode 100644 index 208d16d4213b..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/pattern/sub/sub_ignore.css +++ /dev/null @@ -1 +0,0 @@ -body {} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/pattern/sub/sub_ignore.js b/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/pattern/sub/sub_ignore.js deleted file mode 100644 index 9658cc642ee8..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/pattern/sub/sub_ignore.js +++ /dev/null @@ -1 +0,0 @@ -alert(1); diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/public/test.css b/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/public/test.css deleted file mode 100644 index c0e1a88a7f8e..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/public/test.css +++ /dev/null @@ -1 +0,0 @@ -body{} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/public/test.js b/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/public/test.js deleted file mode 100644 index 73bdbd8f0496..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/public/test.js +++ /dev/null @@ -1 +0,0 @@ -alert(123); diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/resource.json b/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/resource.json deleted file mode 100644 index 8d6b85c7b3f9..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/resource.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "a": 1 -} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/view/index.html b/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/view/index.html deleted file mode 100644 index 04e75bc58557..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/src/view/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - Title - - - - - diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/tsconfig.json b/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/tsconfig.json deleted file mode 100644 index e127761600dd..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2017", - "module": "commonjs", - "moduleResolution": "node", - "experimentalDecorators": true, - "noImplicitThis": true, - "noUnusedLocals": true, - "stripInternal": true, - "pretty": true, - "declaration": true, - "sourceMap": true, - "outDir": "dist", - "lib": ["es2017", "dom"] - }, - "exclude": [ - "dist", - "node_modules", - "test" - ] -} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/tsconfig.prod.json b/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/tsconfig.prod.json deleted file mode 100644 index fc8520e73765..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets-and-another-tsconfig/tsconfig.prod.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./tsconfig.json" -} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets/package.json b/packages/midway-bin/test/fixtures/ts-dir-with-assets/package.json deleted file mode 100644 index 29e463f99ed0..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "ts-dir-with-assets", - "version": "0.0.1", - "dependencies": { - - }, - "midway-bin-build": { - "include": [ - "public", - "view", - "resource.json", - "lib/*.json", - "lib/*.text", - ["pattern/**", "!pattern/**/*.js"] - ] - } -} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/a.ts b/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/a.ts deleted file mode 100644 index 07e321cbd79b..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/a.ts +++ /dev/null @@ -1,2 +0,0 @@ -import * as path from 'path'; -console.log(path.extname(__filename)); diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/lib/a.text b/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/lib/a.text deleted file mode 100644 index 8baef1b4abc4..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/lib/a.text +++ /dev/null @@ -1 +0,0 @@ -abc diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/lib/b.json b/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/lib/b.json deleted file mode 100644 index 0967ef424bce..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/lib/b.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/pattern/ignore.css b/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/pattern/ignore.css deleted file mode 100644 index 208d16d4213b..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/pattern/ignore.css +++ /dev/null @@ -1 +0,0 @@ -body {} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/pattern/ignore.js b/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/pattern/ignore.js deleted file mode 100644 index 9658cc642ee8..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/pattern/ignore.js +++ /dev/null @@ -1 +0,0 @@ -alert(1); diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/pattern/sub/sub_ignore.css b/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/pattern/sub/sub_ignore.css deleted file mode 100644 index 208d16d4213b..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/pattern/sub/sub_ignore.css +++ /dev/null @@ -1 +0,0 @@ -body {} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/pattern/sub/sub_ignore.js b/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/pattern/sub/sub_ignore.js deleted file mode 100644 index 9658cc642ee8..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/pattern/sub/sub_ignore.js +++ /dev/null @@ -1 +0,0 @@ -alert(1); diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/public/test.css b/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/public/test.css deleted file mode 100644 index c0e1a88a7f8e..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/public/test.css +++ /dev/null @@ -1 +0,0 @@ -body{} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/public/test.js b/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/public/test.js deleted file mode 100644 index 73bdbd8f0496..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/public/test.js +++ /dev/null @@ -1 +0,0 @@ -alert(123); diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/resource.json b/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/resource.json deleted file mode 100644 index 8d6b85c7b3f9..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/resource.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "a": 1 -} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/view/index.html b/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/view/index.html deleted file mode 100644 index 04e75bc58557..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets/src/view/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - Title - - - - - diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-assets/tsconfig.json b/packages/midway-bin/test/fixtures/ts-dir-with-assets/tsconfig.json deleted file mode 100644 index e127761600dd..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-assets/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2017", - "module": "commonjs", - "moduleResolution": "node", - "experimentalDecorators": true, - "noImplicitThis": true, - "noUnusedLocals": true, - "stripInternal": true, - "pretty": true, - "declaration": true, - "sourceMap": true, - "outDir": "dist", - "lib": ["es2017", "dom"] - }, - "exclude": [ - "dist", - "node_modules", - "test" - ] -} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-not-exists-file/package.json b/packages/midway-bin/test/fixtures/ts-dir-with-not-exists-file/package.json deleted file mode 100644 index e8344dfb7e13..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-not-exists-file/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "ts-dir-with-not-exists-file", - "version": "0.0.1", - "dependencies": { - - }, - "midway-bin-build": { - "include": [ - "public", - "view" - ] - } -} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-not-exists-file/src/index.ts b/packages/midway-bin/test/fixtures/ts-dir-with-not-exists-file/src/index.ts deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-not-exists-file/src/lib/a.text b/packages/midway-bin/test/fixtures/ts-dir-with-not-exists-file/src/lib/a.text deleted file mode 100644 index 8baef1b4abc4..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-not-exists-file/src/lib/a.text +++ /dev/null @@ -1 +0,0 @@ -abc diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-not-exists-file/src/lib/b.json b/packages/midway-bin/test/fixtures/ts-dir-with-not-exists-file/src/lib/b.json deleted file mode 100644 index 0967ef424bce..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-not-exists-file/src/lib/b.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-not-exists-file/src/public/test.css b/packages/midway-bin/test/fixtures/ts-dir-with-not-exists-file/src/public/test.css deleted file mode 100644 index c0e1a88a7f8e..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-not-exists-file/src/public/test.css +++ /dev/null @@ -1 +0,0 @@ -body{} diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-not-exists-file/src/public/test.js b/packages/midway-bin/test/fixtures/ts-dir-with-not-exists-file/src/public/test.js deleted file mode 100644 index 73bdbd8f0496..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-not-exists-file/src/public/test.js +++ /dev/null @@ -1 +0,0 @@ -alert(123); diff --git a/packages/midway-bin/test/fixtures/ts-dir-with-not-exists-file/tsconfig.json b/packages/midway-bin/test/fixtures/ts-dir-with-not-exists-file/tsconfig.json deleted file mode 100644 index e127761600dd..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-with-not-exists-file/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2017", - "module": "commonjs", - "moduleResolution": "node", - "experimentalDecorators": true, - "noImplicitThis": true, - "noUnusedLocals": true, - "stripInternal": true, - "pretty": true, - "declaration": true, - "sourceMap": true, - "outDir": "dist", - "lib": ["es2017", "dom"] - }, - "exclude": [ - "dist", - "node_modules", - "test" - ] -} diff --git a/packages/midway-bin/test/fixtures/ts-dir-without-config/a.ts b/packages/midway-bin/test/fixtures/ts-dir-without-config/a.ts deleted file mode 100644 index 07e321cbd79b..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir-without-config/a.ts +++ /dev/null @@ -1,2 +0,0 @@ -import * as path from 'path'; -console.log(path.extname(__filename)); diff --git a/packages/midway-bin/test/fixtures/ts-dir/a.ts b/packages/midway-bin/test/fixtures/ts-dir/a.ts deleted file mode 100644 index 07e321cbd79b..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir/a.ts +++ /dev/null @@ -1,2 +0,0 @@ -import * as path from 'path'; -console.log(path.extname(__filename)); diff --git a/packages/midway-bin/test/fixtures/ts-dir/tsconfig.json b/packages/midway-bin/test/fixtures/ts-dir/tsconfig.json deleted file mode 100644 index e127761600dd..000000000000 --- a/packages/midway-bin/test/fixtures/ts-dir/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2017", - "module": "commonjs", - "moduleResolution": "node", - "experimentalDecorators": true, - "noImplicitThis": true, - "noUnusedLocals": true, - "stripInternal": true, - "pretty": true, - "declaration": true, - "sourceMap": true, - "outDir": "dist", - "lib": ["es2017", "dom"] - }, - "exclude": [ - "dist", - "node_modules", - "test" - ] -} diff --git a/packages/midway-bin/test/lib/cmd/build.test.js b/packages/midway-bin/test/lib/cmd/build.test.js deleted file mode 100644 index 28262af67797..000000000000 --- a/packages/midway-bin/test/lib/cmd/build.test.js +++ /dev/null @@ -1,235 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const path = require('path'); -const assert = require('assert'); -const coffee = require('coffee'); -const mm = require('mm'); -const rimraf = require('mz-modules/rimraf'); - -describe('test/lib/cmd/build.test.js', () => { - const midwayBin = require.resolve('../../../bin/midway-bin.js'); - - afterEach(mm.restore); - - it('should warn message', async () => { - const cwd = path.join(__dirname, '../../fixtures/ts-dir-without-config'); - const child = coffee - .fork(midwayBin, ['build'], { cwd }) - .expect('stdout', /tsconfig/); - - await child.expect('code', 0).end(); - }); - - it('should build success', async () => { - const cwd = path.join(__dirname, '../../fixtures/ts-dir'); - await rimraf(path.join(cwd, 'dist')); - const child = coffee.fork(midwayBin, ['build'], { cwd }); - await child.expect('code', 0).end(); - assert(fs.existsSync(path.join(cwd, 'dist/a.js'))); - await rimraf(path.join(cwd, 'dist')); - }); - - it('should build success with tsconfig comments', async () => { - const cwd = path.join(__dirname, '../../fixtures/ts-dir-tsconfig-comments'); - await rimraf(path.join(cwd, 'dist')); - const child = coffee.fork(midwayBin, ['build'], { cwd }); - await child.expect('code', 0).end(); - assert(fs.existsSync(path.join(cwd, 'dist/index.js'))); - await rimraf(path.join(cwd, 'dist')); - }); - - it('should auto clean dir before build', async () => { - const cwd = path.join(__dirname, '../../fixtures/ts-dir'); - const child = coffee.fork(midwayBin, ['build'], { cwd }); - await child.expect('code', 0).end(); - assert(fs.existsSync(path.join(cwd, 'dist/a.js'))); - await rimraf(path.join(cwd, 'dist')); - }); - - it('should copy assets file to dist dir', async () => { - const cwd = path.join(__dirname, '../../fixtures/ts-dir-with-assets'); - const child = coffee.fork(midwayBin, ['build', '-c'], { cwd }); - await child.expect('code', 0).end(); - assert(fs.existsSync(path.join(cwd, 'dist/a.js'))); - assert(fs.existsSync(path.join(cwd, 'dist/view/index.html'))); - assert(fs.existsSync(path.join(cwd, 'dist/public/test.css'))); - assert(fs.existsSync(path.join(cwd, 'dist/public/test.js'))); - assert(fs.existsSync(path.join(cwd, 'dist/resource.json'))); - assert(fs.existsSync(path.join(cwd, 'dist/lib/b.json'))); - assert(fs.existsSync(path.join(cwd, 'dist/lib/a.text'))); - assert(fs.existsSync(path.join(cwd, 'dist/pattern/ignore.css'))); - assert(fs.existsSync(path.join(cwd, 'dist/pattern/sub/sub_ignore.css'))); - await rimraf(path.join(cwd, 'dist')); - }); - - it('should copy assets file and ignore not exists directory', async () => { - const cwd = path.join( - __dirname, - '../../fixtures/ts-dir-with-not-exists-file' - ); - const child = coffee.fork(midwayBin, ['build', '-c'], { cwd }).debug(); - await child.expect('code', 0).end(); - assert(!fs.existsSync(path.join(cwd, 'dist/view/index.html'))); - assert(fs.existsSync(path.join(cwd, 'dist/public/test.css'))); - assert(fs.existsSync(path.join(cwd, 'dist/public/test.js'))); - await rimraf(path.join(cwd, 'dist')); - }); - - it('build use tsConfig no project', async () => { - const BuildCommand = require('../../../lib/cmd/build'); - const builder = new BuildCommand(); - const cwd = path.join(__dirname, '../../fixtures/ts-dir-no-config'); - await builder.run({ - cwd, - argv: { - tsConfig: { - compilerOptions: { - target: 'ES2017', - module: 'commonjs', - moduleResolution: 'node', - experimentalDecorators: true, - noImplicitThis: true, - noUnusedLocals: true, - stripInternal: true, - pretty: true, - declaration: true, - sourceMap: true, - outDir: 'dist', - lib: ['es2017', 'dom'], - }, - exclude: ['dist', 'node_modules', 'test'], - }, - }, - }); - assert(fs.existsSync(path.join(cwd, 'dist/a.js'))); - }); -}); - -describe('test/lib/cmd/build.test.js - with another tsconfig', () => { - const midwayBin = require.resolve('../../../bin/midway-bin.js'); - - afterEach(mm.restore); - - it('should warn message', async () => { - const cwd = path.join(__dirname, '../../fixtures/ts-dir-without-config'); - const child = coffee - .fork(midwayBin, ['build', '-p', 'tsconfig.prod.json'], { cwd }) - .expect('stdout', /tsconfig/); - - await child.expect('code', 0).end(); - }); - - it('should build success with another tsconfig', async () => { - const cwd = path.join( - __dirname, - '../../fixtures/ts-dir-with-another-tsconfig' - ); - await rimraf(path.join(cwd, 'dist')); - const child = coffee.fork( - midwayBin, - ['build', '-p', 'tsconfig.prod.json'], - { cwd } - ); - await child.expect('code', 0).end(); - assert(fs.existsSync(path.join(cwd, 'dist/a.js'))); - await rimraf(path.join(cwd, 'dist')); - }); - - it('should auto clean dir before build with another tsconfig', async () => { - const cwd = path.join( - __dirname, - '../../fixtures/ts-dir-with-another-tsconfig' - ); - await rimraf(path.join(cwd, 'dist')); - const child = coffee.fork( - midwayBin, - ['build', '-p', 'tsconfig.prod.json'], - { cwd } - ); - await child.expect('code', 0).end(); - assert(fs.existsSync(path.join(cwd, 'dist/a.js'))); - await rimraf(path.join(cwd, 'dist')); - }); - - it('should copy assets file to dist dir with another tsconfig', async () => { - const cwd = path.join( - __dirname, - '../../fixtures/ts-dir-with-assets-and-another-tsconfig' - ); - - const child = coffee.fork( - midwayBin, - ['build', '-c', '-p', 'tsconfig.prod.json'], - { cwd } - ); - await child.expect('code', 0).end(); - assert(fs.existsSync(path.join(cwd, 'dist/a.js'))); - assert(fs.existsSync(path.join(cwd, 'dist/view/index.html'))); - assert(fs.existsSync(path.join(cwd, 'dist/public/test.css'))); - assert(fs.existsSync(path.join(cwd, 'dist/public/test.js'))); - assert(fs.existsSync(path.join(cwd, 'dist/resource.json'))); - assert(fs.existsSync(path.join(cwd, 'dist/lib/b.json'))); - assert(fs.existsSync(path.join(cwd, 'dist/lib/a.text'))); - assert(fs.existsSync(path.join(cwd, 'dist/pattern/ignore.css'))); - assert(fs.existsSync(path.join(cwd, 'dist/pattern/sub/sub_ignore.css'))); - await rimraf(path.join(cwd, 'dist')); - }); -}); - -describe('test/lib/cmd/build.test.js - bundling', () => { - const midwayBin = require.resolve('../../../bin/midway-bin.js'); - - afterEach(mm.restore); - - it('should warn message', async () => { - const cwd = path.join(__dirname, '../../fixtures/ts-dir-without-config'); - const child = coffee - .fork(midwayBin, ['build', '--entrypoint', 'a.ts'], { cwd }) - .expect('stdout', /tsconfig/); - - await child.expect('code', 0).end(); - }); - - it('should build success', async () => { - const cwd = path.join(__dirname, '../../fixtures/ts-dir'); - await rimraf(path.join(cwd, 'dist')); - const child = coffee.fork(midwayBin, ['build', '--entrypoint', 'a.ts'], { - cwd, - }); - await child.expect('code', 0).end(); - assert(fs.existsSync(path.join(cwd, 'dist/a.js'))); - await rimraf(path.join(cwd, 'dist')); - }); - - it('should auto clean dir before build', async () => { - const cwd = path.join(__dirname, '../../fixtures/ts-dir'); - const child = coffee.fork(midwayBin, ['build', '--entrypoint', 'a.ts'], { - cwd, - }); - await child.expect('code', 0).end(); - assert(fs.existsSync(path.join(cwd, 'dist/a.js'))); - await rimraf(path.join(cwd, 'dist')); - }); -}); - -describe('test/lib/cmd/build.test.js - minify', () => { - const midwayBin = require.resolve('../../../bin/midway-bin.js'); - const argv = ['build', '-c', '--minify']; - - afterEach(mm.restore); - - it('should build success', async () => { - const cwd = path.join(__dirname, '../../fixtures/ts-dir'); - await rimraf(path.join(cwd, 'dist')); - const child = coffee.fork(midwayBin, argv, { cwd }); - await child.expect('code', 0).end(); - assert(fs.existsSync(path.join(cwd, 'dist/a.js'))); - assert( - /\/\/# sourceMappingURL/.exec( - fs.readFileSync(path.join(cwd, 'dist/a.js'), 'utf8') - ) - ); - await rimraf(path.join(cwd, 'dist')); - }); -}); diff --git a/packages/midway-bin/test/lib/cmd/clean.test.js b/packages/midway-bin/test/lib/cmd/clean.test.js deleted file mode 100644 index 81d47ba6f25e..000000000000 --- a/packages/midway-bin/test/lib/cmd/clean.test.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const path = require('path'); -const assert = require('assert'); -const coffee = require('coffee'); -const mm = require('mm'); -const mkdirp = require('mz-modules/mkdirp'); - -describe('test/lib/cmd/clean.test.js', () => { - const midwayBin = require.resolve('../../../bin/midway-bin.js'); - - afterEach(mm.restore); - - it('should clean dir', async () => { - const cwd = path.join(__dirname, '../../fixtures/clean-dir'); - await mkdirp(path.join(cwd, 'logs/test.log')); - await mkdirp(path.join(cwd, '.nodejs-cache/test.log')); - await mkdirp(path.join(cwd, 'run/a.log')); - - const child = coffee.fork(midwayBin, ['clean'], { cwd }); - await child.expect('code', 0).end(); - assert(fs.existsSync(path.join(cwd, 'a.ts'))); - assert(!fs.existsSync(path.join(cwd, '.nodejs-cache'))); - assert(!fs.existsSync(path.join(cwd, 'run'))); - assert(!fs.existsSync(path.join(cwd, 'logs'))); - }); - - it('should clean file with config', async () => { - const cwd = path.join(__dirname, '../../fixtures/clean-dir-config'); - await mkdirp(path.join(cwd, 'customDir/a.js')); - - const child = coffee.fork(midwayBin, ['clean'], { cwd }); - await child.expect('code', 0).end(); - assert(!fs.existsSync(path.join(cwd, 'customDir'))); - }); -}); diff --git a/packages/midway-bin/test/lib/cmd/doc.test.js b/packages/midway-bin/test/lib/cmd/doc.test.js deleted file mode 100644 index ea3d2a06cd25..000000000000 --- a/packages/midway-bin/test/lib/cmd/doc.test.js +++ /dev/null @@ -1,43 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const path = require('path'); -const assert = require('assert'); -const coffee = require('coffee'); -const mm = require('mm'); -const rimraf = require('mz-modules/rimraf'); - -describe('test/lib/cmd/doc.test.js', () => { - const midwayBin = require.resolve('../../../bin/midway-bin.js'); - - afterEach(mm.restore); - - it('should generate doc use default value', async () => { - const cwd = path.join(__dirname, '../../fixtures/ts-dir'); - - const child = coffee.fork(midwayBin, ['doc'], { cwd }); - await child.expect('code', 0).end(); - assert(fs.existsSync(path.join(cwd, 'doc/index.html'))); - await rimraf(path.join(cwd, 'doc')); - }); - - it('should generate doc use custom value', async () => { - const cwd = path.join(__dirname, '../../fixtures/ts-dir'); - - const child = coffee.fork(midwayBin, ['doc', '-o', 'api'], { cwd }); - await child.expect('code', 0).end(); - assert(fs.existsSync(path.join(cwd, 'api/index.html'))); - await rimraf(path.join(cwd, 'api')); - }); - - it('should generate doc', async () => { - const cwd = path.join(__dirname, '../../fixtures/ts-dir-doc-options'); - - const child = coffee.fork(midwayBin, ['doc', '--options', 'typedoc.js'], { - cwd, - }); - await child.expect('code', 0).end(); - assert(fs.existsSync(path.join(cwd, 'docs/api/index.html'))); - await rimraf(path.join(cwd, 'docs')); - }); -}); diff --git a/packages/midway-bin/test/lib/cmd/index.test.js b/packages/midway-bin/test/lib/cmd/index.test.js deleted file mode 100644 index 2034ac90fc62..000000000000 --- a/packages/midway-bin/test/lib/cmd/index.test.js +++ /dev/null @@ -1,92 +0,0 @@ -'use strict'; - -const path = require('path'); -const coffee = require('coffee'); - -const midwayBin = require.resolve('../../../bin/midway-bin.js'); - -describe('test/lib/cmd/index.test.js', () => { - describe('autod command', () => { - it('should stdout', async () => { - const cwd = path.join(__dirname); - await coffee - .fork(midwayBin, ['autod', '-h'], { cwd }) - // .debug() - .expect('stdout', /midway/) - .expect('code', 0) - .end(); - }); - }); - - describe('cov command', () => { - it('should stdout', async () => { - const cwd = path.join(__dirname); - await coffee - .fork(midwayBin, ['cov', '-h'], { cwd }) - // .debug() - .expect('stdout', /midway/) - .expect('code', 0) - .end(); - }); - }); - - describe('debug command', () => { - it('should stdout', async () => { - const cwd = path.join(__dirname); - await coffee - .fork(midwayBin, ['debug', '-h'], { cwd }) - // .debug() - .expect('stdout', /midway/) - .expect('code', 0) - .end(); - }); - }); - - describe('dev command', () => { - it('should stdout', async () => { - const cwd = path.join(__dirname); - await coffee - .fork(midwayBin, ['dev', '-h'], { cwd }) - // .debug() - .expect('stdout', /midway/) - .expect('code', 0) - .end(); - }); - }); - - describe('pkg command', () => { - it('should stdout', async () => { - const cwd = path.join(__dirname); - await coffee - .fork(midwayBin, ['pkgfiles', '-h'], { cwd }) - // .debug() - .expect('stdout', /midway/) - .expect('code', 0) - .end(); - }); - }); - - describe('test command', () => { - it('should stdout', async () => { - const cwd = path.join(__dirname); - await coffee - .fork(midwayBin, ['test', '-h'], { cwd }) - // .debug() - .expect('stdout', /midway/) - .expect('code', 0) - .end(); - }); - }); - - describe('build command', () => { - it('should build ts file', done => { - const cwd = path.join(__dirname); - coffee - .fork(midwayBin, ['build', '-h'], { cwd }) - // .debug() - .expect('stdout', /midway/) - .expect('code', 0) - .end(done); - }); - }); -}); diff --git a/packages/midway-bin/test/lib/util.test.js b/packages/midway-bin/test/lib/util.test.js deleted file mode 100644 index 61816e51ab2f..000000000000 --- a/packages/midway-bin/test/lib/util.test.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; -const pathx = require('path'); - -const assert = require('assert'); - -const util = require('../../lib/util.js'); - -describe('test/lib/util.test.js', () => { - it('should return full path of module', () => { - const moduleName = 'egg-bin'; - const path = util.resolveModule(moduleName); - console.log('resolved path is:', path); - assert(path && path.endsWith(`${pathx.sep}${moduleName}`)); - }); - - it('should return blank with invalid input', () => { - const moduleName = 'egg' + Math.random(); - const path = util.resolveModule(moduleName); - assert(path === ''); - }); - - it('should return blank with empty input', () => { - const moduleName = ''; - const path = util.resolveModule(moduleName); - assert(path === ''); - }); -}); diff --git a/packages/midway-bin/test/midway-bin.test.js b/packages/midway-bin/test/midway-bin.test.js deleted file mode 100644 index bfac40884ee4..000000000000 --- a/packages/midway-bin/test/midway-bin.test.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -const path = require('path'); -const coffee = require('coffee'); - -describe('test/midway-bin.test.js', () => { - const midwayBin = require.resolve('../bin/midway-bin.js'); - const cwd = path.join(__dirname, 'fixtures/test-files'); - - describe('global options', () => { - it('should show version', done => { - coffee - .fork(midwayBin, ['--version'], { cwd }) - // .debug() - .expect('stdout', /\d+\.\d+\.\d+/) - .expect('code', 0) - .end(done); - }); - - it('should show help', done => { - coffee - .fork(midwayBin, ['--help'], { cwd }) - // .debug() - .expect('stdout', /Usage: .*midway-bin.* \[command] \[options]/) - .expect('code', 0) - .end(done); - }); - - it('should show help when command not exists', done => { - coffee - .fork(midwayBin, ['not-exists'], { cwd }) - // .debug() - .expect('stdout', /Usage: .*midway-bin.* \[command] \[options]/) - .expect('code', 0) - .end(done); - }); - }); -}); diff --git a/packages/midway-init/CHANGELOG.md b/packages/midway-init/CHANGELOG.md deleted file mode 100644 index 74f885f2e145..000000000000 --- a/packages/midway-init/CHANGELOG.md +++ /dev/null @@ -1,885 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## [2.2.4](https://github.com/midwayjs/midway/compare/v2.2.3...v2.2.4) (2020-09-15) - -**Note:** Version bump only for package midway-init - - - - - -## [2.2.3](https://github.com/midwayjs/midway/compare/v2.2.2...v2.2.3) (2020-09-14) - -**Note:** Version bump only for package midway-init - - - - - -## [2.2.2](https://github.com/midwayjs/midway/compare/v2.2.1...v2.2.2) (2020-09-14) - -**Note:** Version bump only for package midway-init - - - - - -## [2.2.1](https://github.com/midwayjs/midway/compare/v2.2.0...v2.2.1) (2020-09-14) - -**Note:** Version bump only for package midway-init - - - - - -# [2.2.0](https://github.com/midwayjs/midway/compare/v2.1.4...v2.2.0) (2020-09-13) - -**Note:** Version bump only for package midway-init - - - - - -## [2.1.4](https://github.com/midwayjs/midway/compare/v2.1.3...v2.1.4) (2020-06-17) - - -### Bug Fixes - -* 2.x extends bug ([#498](https://github.com/midwayjs/midway/issues/498)) ([19ec029](https://github.com/midwayjs/midway/commit/19ec0292eedd94cb2e40e69af8897703fc8f55c7)) - - - - - -## [2.0.15](https://github.com/midwayjs/midway/compare/v2.0.14...v2.0.15) (2020-04-11) - -**Note:** Version bump only for package midway-init - - - - - -## [2.0.10](https://github.com/midwayjs/midway/compare/v2.0.9...v2.0.10) (2020-03-31) - -**Note:** Version bump only for package midway-init - - - - - -## [2.0.9](https://github.com/midwayjs/midway/compare/v2.0.8...v2.0.9) (2020-03-30) - -**Note:** Version bump only for package midway-init - - - - - -## [2.0.8](https://github.com/midwayjs/midway/compare/v2.0.7...v2.0.8) (2020-03-30) - -**Note:** Version bump only for package midway-init - - - - - -## [2.0.7](https://github.com/midwayjs/midway/compare/v2.0.6...v2.0.7) (2020-03-30) - -**Note:** Version bump only for package midway-init - - - - - -## [2.0.5](https://github.com/midwayjs/midway/compare/v2.0.4...v2.0.5) (2020-03-22) - -**Note:** Version bump only for package midway-init - - - - - -## [2.0.4](https://github.com/midwayjs/midway/compare/v2.0.3...v2.0.4) (2020-03-19) - -**Note:** Version bump only for package midway-init - - - - - -## [2.0.2](https://github.com/midwayjs/midway/compare/v2.0.1...v2.0.2) (2020-03-13) - -**Note:** Version bump only for package midway-init - - - - - -# [2.0.0](https://github.com/midwayjs/midway/compare/v2.0.0-beta.16...v2.0.0) (2020-03-13) - -**Note:** Version bump only for package midway-init - - - - - -# [2.0.0-beta.16](https://github.com/midwayjs/midway/compare/v2.0.0-beta.15...v2.0.0-beta.16) (2020-03-12) - -**Note:** Version bump only for package midway-init - - - - - -# [2.0.0-beta.15](https://github.com/midwayjs/midway/compare/v2.0.0-beta.14...v2.0.0-beta.15) (2020-03-06) - -**Note:** Version bump only for package midway-init - - - - - -# [2.0.0-beta.14](https://github.com/midwayjs/midway/compare/v2.0.0-beta.13...v2.0.0-beta.14) (2020-03-04) - -**Note:** Version bump only for package midway-init - - - - - -# [2.0.0-beta.13](https://github.com/midwayjs/midway/compare/v2.0.0-beta.12...v2.0.0-beta.13) (2020-02-26) - -**Note:** Version bump only for package midway-init - - - - - - - -**Note:** Version bump only for package midway-init - - - - - -# [2.0.0-beta.12](https://github.com/midwayjs/midway/compare/v2.0.0-beta.11...v2.0.0-beta.12) (2020-02-25) - -**Note:** Version bump only for package midway-init - - - - - -# [2.0.0-beta.11](https://github.com/midwayjs/midway/compare/v2.0.0-beta.10...v2.0.0-beta.11) (2020-02-25) - -**Note:** Version bump only for package midway-init - - - - - -# [2.0.0-beta.10](https://github.com/midwayjs/midway/compare/v2.0.0-beta.9...v2.0.0-beta.10) (2020-02-20) - -**Note:** Version bump only for package midway-init - - - - - -# [2.0.0-beta.9](https://github.com/midwayjs/midway/compare/v2.0.0-beta.8...v2.0.0-beta.9) (2020-02-20) - -**Note:** Version bump only for package midway-init - - - - - -# [2.0.0-beta.8](https://github.com/midwayjs/midway/compare/v2.0.0-beta.7...v2.0.0-beta.8) (2020-02-19) - -**Note:** Version bump only for package midway-init - - - - - -# [2.0.0-beta.7](https://github.com/midwayjs/midway/compare/v2.0.0-beta.6...v2.0.0-beta.7) (2020-02-18) - -**Note:** Version bump only for package midway-init - - - - - -# [2.0.0-beta.6](https://github.com/midwayjs/midway/compare/v2.0.0-beta.5...v2.0.0-beta.6) (2020-02-17) - -**Note:** Version bump only for package midway-init - - - - - -# [2.0.0-beta.5](https://github.com/midwayjs/midway/compare/v2.0.0-beta.4...v2.0.0-beta.5) (2020-02-17) - -**Note:** Version bump only for package midway-init - - - - - -## [1.17.1](https://github.com/midwayjs/midway/compare/v1.17.0...v1.17.1) (2020-02-17) - -**Note:** Version bump only for package midway-init - - - - - -# [1.17.0](https://github.com/midwayjs/midway/compare/v1.16.4...v1.17.0) (2020-02-17) - -**Note:** Version bump only for package midway-init - - - - - -# [2.0.0-beta.4](https://github.com/midwayjs/midway/compare/v1.16.4...v2.0.0-beta.4) (2020-02-16) - -**Note:** Version bump only for package midway-init - - - - - -## [1.16.4](https://github.com/midwayjs/midway/compare/v1.16.3...v1.16.4) (2020-02-11) - -**Note:** Version bump only for package midway-init - - - - - -## [1.16.3](https://github.com/midwayjs/midway/compare/v1.16.2...v1.16.3) (2019-12-25) - -**Note:** Version bump only for package midway-init - - - - - -## [1.16.2](https://github.com/midwayjs/midway/compare/v1.16.1...v1.16.2) (2019-12-25) - -**Note:** Version bump only for package midway-init - - - - - -## [1.16.1](https://github.com/midwayjs/midway/compare/v1.16.0...v1.16.1) (2019-12-16) - -**Note:** Version bump only for package midway-init - - - - - -## [1.15.1](https://github.com/midwayjs/midway/compare/v1.15.0...v1.15.1) (2019-12-11) - -**Note:** Version bump only for package midway-init - - - - - -# [1.15.0](https://github.com/midwayjs/midway/compare/v1.14.4...v1.15.0) (2019-12-06) - -**Note:** Version bump only for package midway-init - - - - - -## [1.14.4](https://github.com/midwayjs/midway/compare/v1.14.3...v1.14.4) (2019-11-20) - -**Note:** Version bump only for package midway-init - - - - - -## [1.14.3](https://github.com/midwayjs/midway/compare/v1.14.2...v1.14.3) (2019-11-15) - -**Note:** Version bump only for package midway-init - - - - - -## [1.14.1](https://github.com/midwayjs/midway/compare/v1.14.0...v1.14.1) (2019-11-03) - -**Note:** Version bump only for package midway-init - - - - - -# [1.14.0](https://github.com/midwayjs/midway/compare/v1.13.0...v1.14.0) (2019-11-01) - - -### Features - -* add egg-init args ([d6c3582](https://github.com/midwayjs/midway/commit/d6c3582)) -* support npm registry parameter ([d9adfcf](https://github.com/midwayjs/midway/commit/d9adfcf)) -* use new generator for midway-init ([634b748](https://github.com/midwayjs/midway/commit/634b748)) - - - - - -## [1.12.1](https://github.com/midwayjs/midway/compare/v1.12.0...v1.12.1) (2019-10-12) - -**Note:** Version bump only for package midway-init - - - - - -# [1.12.0](https://github.com/midwayjs/midway/compare/v1.11.6...v1.12.0) (2019-10-11) - -**Note:** Version bump only for package midway-init - - - - - -## [1.11.5](https://github.com/midwayjs/midway/compare/v1.11.4...v1.11.5) (2019-09-06) - -**Note:** Version bump only for package midway-init - - - - - -## [1.11.4](https://github.com/midwayjs/midway/compare/v1.11.3...v1.11.4) (2019-09-06) - -**Note:** Version bump only for package midway-init - - - - - -## [1.11.3](https://github.com/midwayjs/midway/compare/v1.11.2...v1.11.3) (2019-09-06) - -**Note:** Version bump only for package midway-init - - - - - -## [1.11.2](https://github.com/midwayjs/midway/compare/v1.11.1...v1.11.2) (2019-08-30) - -**Note:** Version bump only for package midway-init - - - - - -# [1.11.0](https://github.com/midwayjs/midway/compare/v1.10.9...v1.11.0) (2019-08-09) - - -### Features - -* **boilerplate:** enable source map for stack trace ([77afc3f](https://github.com/midwayjs/midway/commit/77afc3f)) - - - - - -## [1.10.8](https://github.com/midwayjs/midway/compare/v1.10.7...v1.10.8) (2019-08-03) - -**Note:** Version bump only for package midway-init - - - - - -## [1.10.7](https://github.com/midwayjs/midway/compare/v1.10.6...v1.10.7) (2019-08-03) - - -### Bug Fixes - -* **boilerplate:** missing comma in .vscode/settings.json ([62fa953](https://github.com/midwayjs/midway/commit/62fa953)) - - - - - -## [1.10.6](https://github.com/midwayjs/midway/compare/v1.10.5...v1.10.6) (2019-07-30) - - -### Bug Fixes - -* @types/mocha has a wrong version: 6.0.0 ([e1a7285](https://github.com/midwayjs/midway/commit/e1a7285)) - - - - - -## [1.10.5](https://github.com/midwayjs/midway/compare/v1.10.4...v1.10.5) (2019-07-30) - -**Note:** Version bump only for package midway-init - - - - - -## [1.10.4](https://github.com/midwayjs/midway/compare/v1.10.3...v1.10.4) (2019-07-24) - - -### Bug Fixes - -* **boilerplate:** update vscode path match pattern for all boilerplate ([88352e5](https://github.com/midwayjs/midway/commit/88352e5)) - - - - - -## [1.10.3](https://github.com/midwayjs/midway/compare/v1.10.2...v1.10.3) (2019-07-23) - - -### Bug Fixes - -* **boilerplate:** sync configurations for all boilerplate ([e73ae35](https://github.com/midwayjs/midway/commit/e73ae35)) -* **boilerplate:** update deps @types/mocha for all boilerplate ([d84cde1](https://github.com/midwayjs/midway/commit/d84cde1)) -* **boilerplate:** update deps for all boilerplate ([4a015e7](https://github.com/midwayjs/midway/commit/4a015e7)) -* **boilerplate:** update nodejs requirement for all boilerplate ([1602d3a](https://github.com/midwayjs/midway/commit/1602d3a)), closes [#279](https://github.com/midwayjs/midway/issues/279) - - - - - -## [1.10.2](https://github.com/midwayjs/midway/compare/v1.10.1...v1.10.2) (2019-07-20) - -**Note:** Version bump only for package midway-init - - - - - -## [1.10.1](https://github.com/midwayjs/midway/compare/v1.10.0...v1.10.1) (2019-07-18) - -**Note:** Version bump only for package midway-init - - - - - -# [1.10.0](https://github.com/midwayjs/midway/compare/v1.9.0...v1.10.0) (2019-07-16) - -**Note:** Version bump only for package midway-init - - - - - -# [1.9.0](https://github.com/midwayjs/midway/compare/v1.8.0...v1.9.0) (2019-07-13) - - -### Bug Fixes - -* **midway-init:** Internal employees can not use the external network midway ([3179434](https://github.com/midwayjs/midway/commit/3179434)) - - -### Features - -* **boilerplate:** add midway-ts-strict-boilerplate ([8ee325c](https://github.com/midwayjs/midway/commit/8ee325c)) -* **boilerplate:** enforce kebabCase style for filenames for midway-ts-strict ([816941b](https://github.com/midwayjs/midway/commit/816941b)) -* **boilerplate:** update midway-ts-strict ([c8388f0](https://github.com/midwayjs/midway/commit/c8388f0)), closes [#269](https://github.com/midwayjs/midway/issues/269) - - - - - -## [1.6.2](https://github.com/midwayjs/midway/compare/v1.6.1...v1.6.2) (2019-06-12) - - -### Bug Fixes - -* fix tsconfig in template ([1680d29](https://github.com/midwayjs/midway/commit/1680d29)) - - - - - -# [1.6.0](https://github.com/midwayjs/midway/compare/v1.5.6...v1.6.0) (2019-06-11) - - -### Bug Fixes - -* **types:** duplicate import of the controller ([2b4600a](https://github.com/midwayjs/midway/commit/2b4600a)) - - -### Features - -* **types:** import and use Context for boilerplate ([d183196](https://github.com/midwayjs/midway/commit/d183196)) -* **vscode:** add launch.json for vscode debug ([9741a53](https://github.com/midwayjs/midway/commit/9741a53)) -* **vscode:** add settings.json for vscode ([f7d178b](https://github.com/midwayjs/midway/commit/f7d178b)) - - - - - -## [1.5.6](https://github.com/midwayjs/midway/compare/v1.5.5...v1.5.6) (2019-05-13) - -**Note:** Version bump only for package midway-init - - - - - -## [1.5.4](https://github.com/midwayjs/midway/compare/v1.5.3...v1.5.4) (2019-05-09) - -**Note:** Version bump only for package midway-init - - - - - -## [1.5.3](https://github.com/midwayjs/midway/compare/v1.5.2...v1.5.3) (2019-05-08) - -**Note:** Version bump only for package midway-init - - - - - -# [1.5.0](https://github.com/midwayjs/midway/compare/v1.4.10...v1.5.0) (2019-04-11) - - -### Bug Fixes - -* fix midway-init ci error ([8f32dcb](https://github.com/midwayjs/midway/commit/8f32dcb)) - - - - - -## [1.4.8](https://github.com/midwayjs/midway/compare/v1.4.7...v1.4.8) (2019-03-11) - -**Note:** Version bump only for package midway-init - - - - - -## [1.4.7](https://github.com/midwayjs/midway/compare/v1.4.6...v1.4.7) (2019-03-08) - -**Note:** Version bump only for package midway-init - - - - - -## [1.4.3](https://github.com/midwayjs/midway/compare/v1.4.2...v1.4.3) (2019-03-01) - -**Note:** Version bump only for package midway-init - - - - - -## [1.4.1](https://github.com/midwayjs/midway/compare/v1.4.0...v1.4.1) (2019-02-27) - -**Note:** Version bump only for package midway-init - - - - - -# [1.3.0](https://github.com/midwayjs/midway/compare/v1.2.4...v1.3.0) (2019-02-12) - -**Note:** Version bump only for package midway-init - - - - - -# [1.2.0](https://github.com/midwayjs/midway/compare/v1.1.2...v1.2.0) (2019-01-29) - -**Note:** Version bump only for package midway-init - - - - - -# [1.1.0](https://github.com/midwayjs/midway/compare/v1.0.5...v1.1.0) (2019-01-23) - - -### Bug Fixes - -* fix test case ([de70efa](https://github.com/midwayjs/midway/commit/de70efa)) - - -### Features - -* 用户执行 init 时判断环境 ([142e0e2](https://github.com/midwayjs/midway/commit/142e0e2)) - - - - - -## [1.0.5](https://github.com/midwayjs/midway/compare/v1.0.4...v1.0.5) (2019-01-07) - - -### Bug Fixes - -* override alinode default path ([f140a18](https://github.com/midwayjs/midway/commit/f140a18)) - - - - - -## [1.0.4](https://github.com/midwayjs/midway/compare/v1.0.3...v1.0.4) (2018-12-29) - -**Note:** Version bump only for package midway-init - - - - - -## [1.0.3](https://github.com/midwayjs/midway/compare/v1.0.2...v1.0.3) (2018-12-27) - - -### Bug Fixes - -* remove pull template from github and add doc for windows ([3ac69ef](https://github.com/midwayjs/midway/commit/3ac69ef)) - - - - - -## [1.0.2](https://github.com/midwayjs/midway/compare/v1.0.1...v1.0.2) (2018-12-26) - -**Note:** Version bump only for package midway-init - - - - - -## [1.0.1](https://github.com/midwayjs/midway/compare/v1.0.0...v1.0.1) (2018-12-23) - -**Note:** Version bump only for package midway-init - - - - - -# [0.7.0](https://github.com/midwayjs/midway/compare/v0.6.5...v0.7.0) (2018-12-09) - -**Note:** Version bump only for package midway-init - - - - - -## [0.6.5](https://github.com/midwayjs/midway/compare/v0.6.4...v0.6.5) (2018-11-27) - -**Note:** Version bump only for package midway-init - - - - - -## [0.6.4](https://github.com/midwayjs/midway/compare/v0.6.3...v0.6.4) (2018-11-21) - -**Note:** Version bump only for package midway-init - - - - - -## [0.6.3](https://github.com/midwayjs/midway/compare/v0.6.2...v0.6.3) (2018-11-20) - -**Note:** Version bump only for package midway-init - - - - - -## [0.6.2](https://github.com/midwayjs/midway/compare/v0.6.1...v0.6.2) (2018-11-20) - -**Note:** Version bump only for package midway-init - - - - - -# [0.6.0](https://github.com/midwayjs/midway/compare/v0.4.7...v0.6.0) (2018-11-15) - -**Note:** Version bump only for package midway-init - - - - - -# [0.5.0](https://github.com/midwayjs/midway/compare/v0.4.5...v0.5.0) (2018-11-15) - -**Note:** Version bump only for package midway-init - - -## [0.4.6](https://github.com/midwayjs/midway/compare/v0.4.5...v0.4.6) (2018-11-14) - - -### Bug Fixes - -* lint & test failed ([0a3fb74](https://github.com/midwayjs/midway/commit/0a3fb74)) - - - - - -## [0.4.4](https://github.com/midwayjs/midway/compare/v0.4.3...v0.4.4) (2018-10-23) - - - - -**Note:** Version bump only for package midway-init - - -## [0.4.3](https://github.com/midwayjs/midway/compare/v0.4.2...v0.4.3) (2018-10-11) - - -### Bug Fixes - -* fix definition from egg-logger ([b1e0741](https://github.com/midwayjs/midway/commit/b1e0741)) - - - - - -## [0.3.8](https://github.com/midwayjs/midway/compare/v0.3.7...v0.3.8) (2018-09-25) - - - - -**Note:** Version bump only for package midway-init - - -## [0.3.5](https://github.com/midwayjs/midway/compare/v0.3.4...v0.3.5) (2018-09-06) - - - - -**Note:** Version bump only for package midway-init - - -## [0.3.2](https://github.com/midwayjs/midway/compare/v0.3.1...v0.3.2) (2018-08-30) - - - - -**Note:** Version bump only for package midway-init - - -## [0.3.1](https://github.com/midwayjs/midway/compare/v0.3.0...v0.3.1) (2018-08-30) - - - - -**Note:** Version bump only for package midway-init - - -# [0.3.0](https://github.com/midwayjs/midway/compare/v0.2.10...v0.3.0) (2018-08-29) - - - - -**Note:** Version bump only for package midway-init - - -## [0.2.8](https://github.com/midwayjs/midway/compare/v0.2.7...v0.2.8) (2018-08-15) - - -### Bug Fixes - -* fix template and modify ts register method ([1857c08](https://github.com/midwayjs/midway/commit/1857c08)) - - - - - - -## [0.2.4](https://github.com/midwayjs/midway/compare/v0.2.3...v0.2.4) (2018-08-06) - - - - -**Note:** Version bump only for package midway-init - - -## [0.2.3](https://github.com/midwayjs/midway/compare/v0.2.2...v0.2.3) (2018-08-03) - - - - -**Note:** Version bump only for package midway-init - - -## [0.2.1](https://github.com/midwayjs/midway/compare/v0.2.0...v0.2.1) (2018-08-03) - - -### Bug Fixes - -* init template ([1af0f18](https://github.com/midwayjs/midway/commit/1af0f18)) - - - - - -# [0.2.0](https://github.com/midwayjs/midway/compare/v0.1.6...v0.2.0) (2018-08-01) - - - - -**Note:** Version bump only for package midway-init - - -## [0.1.6](https://github.com/midwayjs/midway/compare/v0.1.5...v0.1.6) (2018-07-30) - - -### Bug Fixes - -* fix lint ([1663751](https://github.com/midwayjs/midway/commit/1663751)) - - - - - -# [0.2.0-alpha.1663751b](https://github.com/midwayjs/midway/compare/v0.1.5...v0.2.0-alpha.1663751b) (2018-07-30) - - -### Bug Fixes - -* fix lint ([1663751](https://github.com/midwayjs/midway/commit/1663751)) - - - - - -## [0.1.5](https://github.com/midwayjs/midway/compare/v0.1.4...v0.1.5) (2018-07-30) - - - - -**Note:** Version bump only for package midway-init - - -## [0.1.4](https://github.com/midwayjs/midway/compare/v0.1.3...v0.1.4) (2018-07-30) - - - - -**Note:** Version bump only for package midway-init diff --git a/packages/midway-init/README.md b/packages/midway-init/README.md deleted file mode 100644 index 335a079fd2b9..000000000000 --- a/packages/midway-init/README.md +++ /dev/null @@ -1,60 +0,0 @@ -# midway-init - -[![Package Quality](http://npm.packagequality.com/shield/midway-init.svg)](http://packagequality.com/#?package=midway-init) -[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls) - -this is a sub package for midway. - -Document: [https://midwayjs.org/midway](https://midwayjs.org/midway) - -## Install - -```bash -$ npm i midway-init -g -$ midway-init -h -``` - -## Create a boilerplate by type - -```bash -$ midway-init --type midway-ts -``` - -## Or select a boilerplate by yourself - -```bash -$ midway-init -? Hello, traveller. - Which template do you like? … -❯ midway-ts - Simple midway application boilerplate by ts.(by @midwayJs) - midway-demo - Simple example boilerplate for find bug or submit to midway-examples.(by @midwayJs) - midway-ts-strict - Simple midway application boilerplate by ts with ng style and strict eslint rules.(by @waitingsong) - midway-ts-ant-design-pro - A front-end and back-end separation project includes midway(ts) and ant-design-pro.(by @tw93) - -``` -## Command -``` -Usage: midway-init -Options: - --type boilerplate type [string] - --dir target directory [string] - --template local path to boilerplate [string] - --package boilerplate package name [string] - --registry, -r npm registry, support china/npm/custom, default to auto detect [string] - --version Show version number [boolean] - -h, --help Show help [boolean] -``` - -## Custom Template - -You can custom your boilerplate by [light-generator](https://github.com/midwayjs/light-generator#%E6%A8%A1%E6%9D%BF%E8%A7%84%E5%88%99) and use it by command `midway-init --package [your package name]` - -Example - -```bash -midway-init --package=midway-boilerplate-typescript -``` - -## License - -[MIT]((http://github.com/midwayjs/midway/blob/master/LICENSE)) diff --git a/packages/midway-init/bin/midway-init.js b/packages/midway-init/bin/midway-init.js deleted file mode 100755 index d9177f476404..000000000000 --- a/packages/midway-init/bin/midway-init.js +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env node - -'use strict'; - -const childProcess = require('child_process'); -const { Confirm } = require('enquirer'); -const Command = require('..'); - -(async () => { - const args = process.argv.slice(2); - - if (isInternal()) { - const prompt = new Confirm({ - name: 'really', - message: '检测到目前可能处于内网环境,推荐使用 @ali/midway-init,确定要继续吗?', - initial: false, - default: '[Y(es)|N(o)]', - }); - const isContinue = await prompt.run(); - - if (!isContinue) { - return; - } - } - - try { - const cmd = new Command(); - await cmd.run(process.cwd(), args); - } catch (err) { - console.error(err.stack); - process.exit(1); - } -})(); - -// 判断是否处于内网环境 -function isInternal() { - try { - const { stdout } = childProcess.spawnSync('tnpm', [ 'view', '@ali/midway-init', '--json' ], { - timeout: 3000, - }); - - const npmData = JSON.parse(stdout.toString(), null, 2); - - if (npmData.name === '@ali/midway-init') { - return true; - } else { - return false; - } - } catch (err) { - return false; - } -} diff --git a/packages/midway-init/boilerplate.json b/packages/midway-init/boilerplate.json deleted file mode 100644 index c846d9d66cdf..000000000000 --- a/packages/midway-init/boilerplate.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "midway-ts": { - "package": "midway-boilerplate-typescript", - "description": "Simple midway application boilerplate by ts.", - "author": "midwayJs" - }, - "midway-demo": { - "package": "midway-boilerplate-demo", - "description": "Simple example boilerplate for find bug or submit to midway-examples.", - "author": "midwayJs" - }, - "midway-ts-strict": { - "package": "midway-boilerplate-ts-strict", - "description": "Simple midway application boilerplate by ts with ng style and strict eslint rules.", - "author": "waitingsong" - }, - "midway-ts-ant-design-pro": { - "package": "midway-boilerplate-ts-antd", - "description": "A front-end and back-end separation project includes midway(ts) and ant-design-pro.", - "author": "tw93" - } -} diff --git a/packages/midway-init/lib/command.js b/packages/midway-init/lib/command.js deleted file mode 100644 index a7714efda279..000000000000 --- a/packages/midway-init/lib/command.js +++ /dev/null @@ -1,254 +0,0 @@ -'use strict'; - -const path = require('path'); -const { LightGenerator } = require('light-generator'); -const { Input, Select, Form } = require('enquirer'); -const chalk = require('chalk'); -const { getParser } = require('./parser'); -const { EventEmitter } = require('events'); -const fs = require('fs'); -const os = require('os'); - -async function sleep(timeout) { - return new Promise(resolve => { - setTimeout(() => { - resolve(); - }, timeout); - }); -} - -const defaultOptions = { - templateListPath: path.join(__dirname, '../boilerplate.json'), -}; - -class MidwayInitCommand extends EventEmitter { - constructor(npmClient) { - super(); - this.npmClient = npmClient || 'npm'; - this._innerPrompt = null; - this.showPrompt = true; - } - - set prompt(value) { - const originRun = value.run; - value.run = async () => { - await this.beforePromptSubmit(); - return await originRun.call(value); - }; - this._innerPrompt = value; - } - - get prompt() { - return this._innerPrompt; - } - - async beforePromptSubmit() {} - - async run(cwd, args) { - const argv = (this.argv = getParser().parse(args || [])); - this.cwd = cwd; - - this.templateList = await this.getTemplateList(); - - if (argv.dir) { - // support --dir argument - this.targetPath = argv.dir; - } - - if (argv.registry) { - this.registryUrl = this.getRegistryByType(argv.registry); - } - - if (argv.type) { - // support --type argument - this.templateName = argv.type; - await this.createFromTemplate(); - } else if (argv.template) { - // support --template argument - // ready targetDir - await this.createTargetDir(); - const lightGenerator = this.createGenerator(); - const generator = lightGenerator.defineLocalPath({ - templatePath: this.getAbsoluteDir(argv.template), - targetPath: this.targetPath, - }); - await this.execBoilerplate(generator); - } else if (argv.package) { - // support --package argument - await this.createFromTemplate(argv.package); - } else { - this.prompt = new Select({ - name: 'templateName', - message: 'Hello, traveller.\n Which template do you like?', - choices: Object.keys(this.templateList).map(template => { - return ( - `${template} - ${this.templateList[template].description}` + - (this.templateList[template].author - ? `(by @${chalk.underline.bold( - this.templateList[template].author - )})` - : '') - ); - }), - result: value => { - return value.split(' - ')[0]; - }, - show: this.showPrompt, - }); - // get user input template - this.templateName = await this.prompt.run(); - await this.createFromTemplate(); - } - // done - this.printUsage(); - } - - async createFromTemplate(packageName) { - // ready targetDir - await this.createTargetDir(); - const lightGenerator = this.createGenerator(); - const generator = lightGenerator.defineNpmPackage({ - npmClient: this.npmClient, - npmPackage: packageName || this.templateList[this.templateName].package, - targetPath: this.targetPath, - registryUrl: this.registryUrl, - }); - await this.execBoilerplate(generator); - } - - async getTemplateList() { - if (!this.templateName) { - return require(defaultOptions.templateListPath); - } - } - - async readyGenerate(asyncFunction) { - console.log(); - this.log('Preparing your project, please wait a moment...'); - await sleep(2000); - this.log('1...'); - await sleep(1000); - this.log('2...'); - await sleep(1000); - this.log('3...'); - if (asyncFunction) { - await asyncFunction(); - } - await sleep(1000); - this.log( - 'Initialization program has been executed successfully,enjoy it...' - ); - console.log(); - } - - createGenerator() { - return new LightGenerator(); - } - - async createTargetDir() { - if (!this.targetPath) { - this.prompt = new Input({ - message: 'The directory where the boilerplate should be created', - initial: 'my_midway_app', - show: this.showPrompt, - }); - // get target path where template will be copy to - this.targetPath = await this.prompt.run(); - } - this.targetPath = this.getAbsoluteDir(this.targetPath); - } - - async execBoilerplate(generator) { - this.log('Fetch the boilerplate which you like...'); - const args = await generator.getParameterList(); - const argsKeys = Object.keys(args); - if (argsKeys && argsKeys.length) { - this.prompt = new Form({ - name: 'user', - message: 'Please provide the following information:', - choices: argsKeys.map(argsKey => { - return { - name: `${argsKey}`, - message: `${args[argsKey].desc}`, - initial: `${args[argsKey].default}`, - }; - }), - show: this.showPrompt, - }); - - const parameters = await this.prompt.run(); - // remove undefined property - Object.keys(parameters).forEach( - key => parameters[key] === undefined && delete parameters[key] - ); - await this.readyGenerate(async () => { - await generator.run(parameters); - }); - } else { - await this.readyGenerate(async () => { - await generator.run(); - }); - } - } - - getAbsoluteDir(dir) { - if (!path.isAbsolute(dir)) { - dir = path.join(process.cwd(), dir); - } - return dir; - } - - /** - * log with prefix - */ - log() { - const args = Array.prototype.slice.call(arguments); - args[0] = chalk.green('✔ ') + chalk.bold(args[0]); - console.log.apply(console, args); - } - - printUsage() { - this.log(`Usage: - - cd ${this.targetPath} - - ${this.npmClient} install - - ${this.npmClient} run dev / ${this.npmClient} start / ${this.npmClient} test - `); - this.log('Document: https://midwayjs.org/midway/guide.html'); - } - - /** - * get registryUrl by short name - * @param {String} key - short name, support `china / npm / npmrc`, default to read from .npmrc - * @return {String} registryUrl - */ - getRegistryByType(key) { - switch (key) { - case 'china': - return 'https://registry.npm.taobao.org'; - case 'npm': - return 'https://registry.npmjs.org'; - default: { - if (/^https?:/.test(key)) { - return key.replace(/\/$/, ''); - } else { - // support .npmrc - const home = os.homedir(); - let url = - process.env.npm_registry || - process.env.npm_config_registry || - 'https://registry.npmjs.org'; - if ( - fs.existsSync(path.join(home, '.cnpmrc')) || - fs.existsSync(path.join(home, '.tnpmrc')) - ) { - url = 'https://registry.npm.taobao.org'; - } - url = url.replace(/\/$/, ''); - return url; - } - } - } - } -} - -module.exports = MidwayInitCommand; diff --git a/packages/midway-init/lib/parser.js b/packages/midway-init/lib/parser.js deleted file mode 100644 index b38e23b89483..000000000000 --- a/packages/midway-init/lib/parser.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - -const yargs = require('yargs'); - -const getParserOptions = () => { - return { - type: { - type: 'string', - description: 'boilerplate type', - }, - dir: { - type: 'string', - description: 'target directory', - }, - template: { - type: 'string', - description: 'local path to boilerplate', - }, - package: { - type: 'string', - description: 'boilerplate package name', - }, - registry: { - type: 'string', - description: 'npm registry, support china/npm/custom, default to auto detect', - alias: 'r', - }, - }; -}; - -const getParser = () => { - return yargs - .usage('Initializing midway project from boilerplate.\nUsage: $0 [dir] --type=simple') - .options(getParserOptions()) - .alias('h', 'help') - .version() - .help(); -}; - -module.exports = { getParser, getParserOptions }; diff --git a/packages/midway-init/package.json b/packages/midway-init/package.json deleted file mode 100644 index 8488eff6c66e..000000000000 --- a/packages/midway-init/package.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "midway-init", - "version": "2.2.4", - "dependencies": { - "chalk": "^3.0.0", - "enquirer": "^2.3.2", - "light-generator": "^1.4.0", - "yargs": "^15.0.0" - }, - "main": "lib/command.js", - "devDependencies": { - "midway-bin": "^2.2.4", - "mz-modules": "^2.1.0", - "power-assert": "^1.6.1" - }, - "keywords": [ - "midway", - "midway-init" - ], - "preferGlobal": true, - "bin": { - "midway-init": "bin/midway-init.js" - }, - "files": [ - "bin", - "lib", - "boilerplate.json" - ], - "scripts": { - "test": "npm run lint && midway-bin test", - "cov": "midway-bin cov", - "ci": "npm run lint && midway-bin cov" - }, - "author": "Harry Chen ", - "repository": { - "type": "git", - "url": "http://github.com/midwayjs/midway.git" - }, - "gitHead": "44c0803552baf265debed8a11a860988b7e07a85" -} diff --git a/packages/midway-init/test/fixtures/simple-test/boilerplate/.eslintrc b/packages/midway-init/test/fixtures/simple-test/boilerplate/.eslintrc deleted file mode 100755 index c22f1f37859a..000000000000 --- a/packages/midway-init/test/fixtures/simple-test/boilerplate/.eslintrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "eslint-config-egg", - "rules": { - "no-unused-vars": "off" - } -} \ No newline at end of file diff --git a/packages/midway-init/test/fixtures/simple-test/boilerplate/README.md b/packages/midway-init/test/fixtures/simple-test/boilerplate/README.md deleted file mode 100755 index b13b60700cda..000000000000 --- a/packages/midway-init/test/fixtures/simple-test/boilerplate/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# {{name}} - -{{description}} - -{{defaultFn}} - -{{filterFn}} - -## QuickStart - -### Development -```shell -$ npm install -$ npm run dev -$ open http://localhost:7001/news -``` - -### Deploy - -Use `EGG_SERVER_ENV=prod` to enable prod mode - -```shell -$ EGG_SERVER_ENV=prod npm start -``` diff --git a/packages/midway-init/test/fixtures/simple-test/boilerplate/_.npmignore b/packages/midway-init/test/fixtures/simple-test/boilerplate/_.npmignore deleted file mode 100755 index b59f7e3a95a4..000000000000 --- a/packages/midway-init/test/fixtures/simple-test/boilerplate/_.npmignore +++ /dev/null @@ -1 +0,0 @@ -test/ \ No newline at end of file diff --git a/packages/midway-init/test/fixtures/simple-test/boilerplate/_package.json b/packages/midway-init/test/fixtures/simple-test/boilerplate/_package.json deleted file mode 100755 index 64a2a8d541fb..000000000000 --- a/packages/midway-init/test/fixtures/simple-test/boilerplate/_package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "{{name}}", - "version": "1.0.0", - "description": "{{description}}", - "private": true, - "author": "{{author}}", - "license": "MIT" -} diff --git a/packages/midway-init/test/fixtures/simple-test/boilerplate/config/config.default.js b/packages/midway-init/test/fixtures/simple-test/boilerplate/config/config.default.js deleted file mode 100755 index 38208fdf4f5c..000000000000 --- a/packages/midway-init/test/fixtures/simple-test/boilerplate/config/config.default.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -exports.project = '{{name}}'; diff --git a/packages/midway-init/test/fixtures/simple-test/boilerplate/gitignore b/packages/midway-init/test/fixtures/simple-test/boilerplate/gitignore deleted file mode 100755 index 4d3797c41c3b..000000000000 --- a/packages/midway-init/test/fixtures/simple-test/boilerplate/gitignore +++ /dev/null @@ -1,3 +0,0 @@ -logs/ -npm-debug.log -node_modules/ \ No newline at end of file diff --git a/packages/midway-init/test/fixtures/simple-test/boilerplate/test/{{name}}.test.js b/packages/midway-init/test/fixtures/simple-test/boilerplate/test/{{name}}.test.js deleted file mode 100755 index e69de29bb2d1..000000000000 diff --git a/packages/midway-init/test/fixtures/simple-test/boilerplate/{{name}} b/packages/midway-init/test/fixtures/simple-test/boilerplate/{{name}} deleted file mode 100755 index d96f1730d860..000000000000 --- a/packages/midway-init/test/fixtures/simple-test/boilerplate/{{name}} +++ /dev/null @@ -1 +0,0 @@ -appname \ No newline at end of file diff --git a/packages/midway-init/test/fixtures/simple-test/index.js b/packages/midway-init/test/fixtures/simple-test/index.js deleted file mode 100755 index 6900d30a1632..000000000000 --- a/packages/midway-init/test/fixtures/simple-test/index.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - -module.exports = { - name: { - desc: 'project name', - }, - description: { - desc: 'project description', - }, - author: { - desc: 'project author', - default: 'TZ', - }, - defaultFn: { - desc: 'test default fn', - default(vars) { - return 'default-' + vars.name; - }, - }, - filterFn: { - desc: 'test filter fn', - filter(v) { - return 'filter-' + v; - }, - }, -}; diff --git a/packages/midway-init/test/fixtures/simple-test/package.json b/packages/midway-init/test/fixtures/simple-test/package.json deleted file mode 100755 index 58fb5a8d687b..000000000000 --- a/packages/midway-init/test/fixtures/simple-test/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "egg-boilerplate-simple-test", - "version": "1.0.0", - "description": "boilerplate for egg-init test fixtures", - "homepage": "https://github.com/eggjs/egg-init.git", - "repository": { - "type": "git", - "url": "git@github.com:eggjs/egg-init.git" - } -} \ No newline at end of file diff --git a/packages/midway-init/test/helper.js b/packages/midway-init/test/helper.js deleted file mode 100755 index cdcfcdfb8abb..000000000000 --- a/packages/midway-init/test/helper.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; - -const Command = require('../lib/command'); - -class TestCommand extends Command { - - constructor() { - super(); - this.showPrompt = false; - } - - mockPrompt(arr) { - this.promptAction = arr; - } - - async beforePromptSubmit() { - this.prompt.once('run', async () => { - const value = this.promptAction.shift(); - if (value) { - for (const flag of value) { - if (Array.isArray(flag)) { - await this.prompt.keypress.apply(this.prompt, flag); - } else if (typeof flag === 'string') { - try { - for (const key of flag.split('')) { - await this.prompt.keypress(key); - } - } catch (err) { - console.error(err); - } - } - } - } - - await this.prompt.submit(); - this.prompt.close(); - }); - } -} - -exports.TestCommand = TestCommand; diff --git a/packages/midway-init/test/init.test.js b/packages/midway-init/test/init.test.js deleted file mode 100755 index 92b5dd7a6abd..000000000000 --- a/packages/midway-init/test/init.test.js +++ /dev/null @@ -1,198 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const path = require('path'); -const rimraf = require('mz-modules/rimraf'); -const assert = require('assert'); -const { TestCommand } = require('./helper'); -const tmp = path.join(__dirname, '../.tmp'); -const { LightGenerator } = require('light-generator'); - -describe('test/init.test.js', () => { - beforeEach(() => rimraf(tmp)); - afterEach(() => rimraf(tmp)); - - it('should prompt and create first boilerplate', async () => { - const targetDir = path.join(tmp, 'test'); - const command = new TestCommand(); - command.mockPrompt([ - [ null, { name: 'return' }], - targetDir, - [ - 'my_project', - [ null, { name: 'down' }], - 'test', - ], - ]); - await command.run(tmp); - - assert(fs.existsSync(path.join(targetDir, '.gitignore'))); - assert(fs.existsSync(path.join(targetDir, 'package.json'))); - - const content = fs.readFileSync(path.join(targetDir, 'README.md'), 'utf-8'); - assert(/QuickStart/.test(content)); - }); - - it('should create boilerplate use relative dir', async () => { - const targetDir = path.join(tmp, 'test'); - const command = new TestCommand(); - command.mockPrompt([ - [ null, { name: 'return' }], - '.tmp/test', - [ - 'my_project', - [ null, { name: 'down' }], - 'test', - ], - ]); - await command.run(tmp); - - assert(fs.existsSync(path.join(targetDir, '.gitignore'))); - assert(fs.existsSync(path.join(targetDir, 'package.json'))); - - const content = fs.readFileSync(path.join(targetDir, 'README.md'), 'utf-8'); - assert(/QuickStart/.test(content)); - }); - - it('should create boilerplate by type argv', async () => { - const targetDir = path.join(tmp, 'test'); - const command = new TestCommand(); - command.mockPrompt([ - '.tmp/test', - [ - 'my_project', - [ null, { name: 'down' }], - 'test', - ], - ]); - await command.run(tmp, '--type=midway-ts'); - - assert(fs.existsSync(path.join(targetDir, '.gitignore'))); - assert(fs.existsSync(path.join(targetDir, 'package.json'))); - - const content = fs.readFileSync(path.join(targetDir, 'README.md'), 'utf-8'); - assert(/QuickStart/.test(content)); - }); - - it('should create boilerplate with targetDir', async () => { - const targetDir = path.join(tmp, 'test'); - const command = new TestCommand(); - command.mockPrompt([ - [ - 'my_project', - [ null, { name: 'down' }], - 'test', - ], - ]); - await command.run(tmp, '--type=midway-ts --dir=.tmp/test'); - - assert(fs.existsSync(path.join(targetDir, '.gitignore'))); - assert(fs.existsSync(path.join(targetDir, 'package.json'))); - - const content = fs.readFileSync(path.join(targetDir, 'README.md'), 'utf-8'); - assert(/QuickStart/.test(content)); - }); - - it('should create boilerplate with local boilerplate', async () => { - const targetDir = path.join(tmp, 'test'); - const command = new TestCommand(); - command.mockPrompt([ - [ - 'my_project', - [ null, { name: 'down' }], - 'test', - ], - ]); - await command.run(tmp, '--dir=.tmp/test --template=test/fixtures/simple-test'); - - assert(fs.existsSync(path.join(targetDir, 'boilerplate/gitignore'))); - assert(fs.existsSync(path.join(targetDir, 'package.json'))); - }); - - it('should create boilerplate by package name', async () => { - const targetDir = path.join(tmp, 'test'); - const command = new TestCommand(); - command.mockPrompt([ - [ - 'my_project', - [ null, { name: 'down' }], - 'test', - ], - ]); - await command.run(tmp, '--dir=.tmp/test --package=midway-boilerplate-typescript'); - - assert(fs.existsSync(path.join(targetDir, '.gitignore'))); - assert(fs.existsSync(path.join(targetDir, 'package.json'))); - - const content = fs.readFileSync(path.join(targetDir, 'README.md'), 'utf-8'); - assert(/QuickStart/.test(content)); - }); - - it('should use taobao npm registry url', async () => { - await LightGenerator.cleanCache(); - const targetDir = path.join(tmp, 'test'); - const command = new TestCommand(); - command.mockPrompt([ - [ - 'my_project', - [ null, { name: 'down' }], - 'test', - ], - ]); - await command.run(tmp, '--dir=.tmp/test --package=midway-boilerplate-typescript --registry=china'); - - assert(fs.existsSync(path.join(targetDir, '.gitignore'))); - assert(fs.existsSync(path.join(targetDir, 'package.json'))); - }); - - it('should use npm registry url', async () => { - await LightGenerator.cleanCache(); - const targetDir = path.join(tmp, 'test'); - const command = new TestCommand(); - command.mockPrompt([ - [ - 'my_project', - [ null, { name: 'down' }], - 'test', - ], - ]); - await command.run(tmp, '--dir=.tmp/test --package=midway-boilerplate-typescript --registry=npm'); - - assert(fs.existsSync(path.join(targetDir, '.gitignore'))); - assert(fs.existsSync(path.join(targetDir, 'package.json'))); - }); - - it('should use custom npm registry url', async () => { - await LightGenerator.cleanCache(); - const targetDir = path.join(tmp, 'test'); - const command = new TestCommand(); - command.mockPrompt([ - [ - 'my_project', - [ null, { name: 'down' }], - 'test', - ], - ]); - await command.run(tmp, '--dir=.tmp/test --package=midway-boilerplate-typescript --registry=https://r.cnpmjs.org'); - - assert(fs.existsSync(path.join(targetDir, '.gitignore'))); - assert(fs.existsSync(path.join(targetDir, 'package.json'))); - }); - - it('should use custom npm registry url without protocol', async () => { - await LightGenerator.cleanCache(); - const targetDir = path.join(tmp, 'test'); - const command = new TestCommand(); - command.mockPrompt([ - [ - 'my_project', - [ null, { name: 'down' }], - 'test', - ], - ]); - await command.run(tmp, '--dir=.tmp/test --package=midway-boilerplate-typescript --registry=r.cnpmjs.org'); - - assert(fs.existsSync(path.join(targetDir, '.gitignore'))); - assert(fs.existsSync(path.join(targetDir, 'package.json'))); - }); -}); diff --git a/packages/midway-schedule/package.json b/packages/midway-schedule/package.json index 195ff667da0f..0560b0b7e566 100644 --- a/packages/midway-schedule/package.json +++ b/packages/midway-schedule/package.json @@ -14,13 +14,13 @@ }, "scripts": { "build": "midway-bin build -c", - "test": "midway-bin clean && NODE_ENV=unittest midway-bin test --ts" + "test": "NODE_ENV=unittest midway-bin test --ts" }, "keywords": [], "license": "MIT", "devDependencies": { "@midwayjs/mock": "^2.2.4", - "midway-bin": "^2.2.4" + "@midwayjs/cli": "^1.0.x" }, "dependencies": { "@midwayjs/decorator": "^2.2.4", diff --git a/packages/midway/README.md b/packages/midway/README.md index 1de6e9b3d60a..e009f78b2aca 100644 --- a/packages/midway/README.md +++ b/packages/midway/README.md @@ -10,7 +10,9 @@ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/856737478fa94e78bce39d5fc2315cec)](https://www.codacy.com/app/czy88840616/midway?utm_source=github.com&utm_medium=referral&utm_content=midwayjs/midway&utm_campaign=Badge_Grade) [![Backers on Open Collective](https://opencollective.com/midway/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/midway/sponsors/badge.svg)](#sponsors) -[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/midwayjs/midway) +[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/midwayjs/midway) +[![Code Style: MidwayJS](https://img.shields.io/badge/code%20style-midwayjs-brightgreen.svg)](https://github.com/midwayjs/mwts) + Midway is a Node.js Web framework written by typescript, which uses the IoC injection mechanism to decouple the business logic of the application and make the development of large Node.js application easier and more natural. @@ -58,7 +60,7 @@ midway is comprised of many specialized packages. This repository contains all t | Package | Version | Dependencies | DevDependencies | quality | |--------|-------|------------|----------|----------| | [`midway`] | [![midway-svg]][midway-ch] | [![midway-d-svg]][midway-d-link] | [![midway-dd-svg]][midway-dd-link] | [![midway-q-svg]][midway-q-link] | -| [`midway-web`] | [![web-svg]][web-ch] | [![web-d-svg]][web-d-link] | [![web-dd-svg]][web-dd-link] | [![web-q-svg]][web-q-link] | +| [`midway-web`] | [![web-svg]][web-ch] | [![web-d-svg]][web-d-link] | [![web-dd-svg]][web-dd-link] | [![web-q-svg]][web-q-link] | | [`midway-core`] | [![core-svg]][core-ch] | [![core-d-svg]][core-d-link] | [![core-dd-svg]][core-dd-link] | [![core-q-svg]][core-q-link] | | [`midway-mock`] | [![mock-svg]][mock-ch] | [![mock-d-svg]][mock-d-link] | [![mock-dd-svg]][mock-dd-link] | [![mock-q-svg]][mock-q-link] | | [`midway-init`] | [![init-svg]][init-ch] | [![init-d-svg]][init-d-link] | [![init-dd-svg]][init-dd-link] | [![init-q-svg]][init-q-link] | diff --git a/packages/midway/package.json b/packages/midway/package.json index 8d0ddb0f635d..282925c9ae77 100644 --- a/packages/midway/package.json +++ b/packages/midway/package.json @@ -6,8 +6,8 @@ "typings": "dist/index.d.ts", "scripts": { "build": "midway-bin build -c", - "test": "../../node_modules/.bin/jest --forceExit", - "cov": "../../node_modules/.bin/jest --coverage --forceExit", + "test": "midway-bin test", + "cov": "midway-bin test --cov", "ci": "npm run test" }, "keywords": [ @@ -17,7 +17,7 @@ ], "license": "MIT", "devDependencies": { - "midway-bin": "^2.2.4" + "@midwayjs/cli": "^1.0.x" }, "dependencies": { "@midwayjs/web": "^2.2.4", diff --git a/packages/mock/package.json b/packages/mock/package.json index 754034e8e41b..31c4dd61c704 100644 --- a/packages/mock/package.json +++ b/packages/mock/package.json @@ -6,8 +6,8 @@ "typings": "dist/index.d.ts", "scripts": { "build": "midway-bin build -c", - "test": "../../node_modules/.bin/jest --forceExit", - "cov": "../../node_modules/.bin/jest --coverage --forceExit", + "test": "midway-bin test --forceExit", + "cov": "midway-bin test --cov --forceExit", "ci": "midway-bin test" }, "keywords": [ @@ -32,7 +32,7 @@ "license": "MIT", "devDependencies": { "@midwayjs/decorator": "^2.2.4", - "midway-bin": "^2.2.4" + "@midwayjs/cli": "^1.0.x" }, "dependencies": { "@midwayjs/bootstrap": "^2.2.4", diff --git a/packages/mock/src/interface.ts b/packages/mock/src/interface.ts index e24bfc0156b4..7f6baa7812fc 100644 --- a/packages/mock/src/interface.ts +++ b/packages/mock/src/interface.ts @@ -1,5 +1,5 @@ import { MockApplication, MockOption } from 'egg-mock'; -import { IApplicationContext } from '@midwayjs/core'; +import { IApplicationContext, IMidwayContainer } from '@midwayjs/core'; export interface MidwayApplicationOptions extends MockOption { baseDir?: string; @@ -14,7 +14,7 @@ export interface MidwayApplicationOptions extends MockOption { type EggContext = ReturnType; export interface MidwayMockContext extends EggContext { - requestContext: IApplicationContext; + requestContext: IMidwayContainer; } export type MockClassFunctionHandler = ( diff --git a/packages/socketio/package.json b/packages/socketio/package.json index 128aa05d14b6..352008337064 100644 --- a/packages/socketio/package.json +++ b/packages/socketio/package.json @@ -6,8 +6,8 @@ "typings": "dist/index.d.ts", "scripts": { "build": "midway-bin build -c", - "test": "../../node_modules/.bin/jest --forceExit", - "cov": "../../node_modules/.bin/jest --coverage --forceExit", + "test": "midway-bin test --forceExit", + "cov": "midway-bin cov --forceExit", "ci": "npm run test" }, "keywords": [ @@ -27,7 +27,7 @@ "@types/socket.io": "^2.1.11", "@types/socket.io-client": "^1.4.33", "fs-extra": "^8.0.1", - "midway-bin": "^2.2.4", + "@midwayjs/cli": "^1.0.x", "socket.io-client": "^2.3.0" }, "dependencies": { diff --git a/packages/web-express/package.json b/packages/web-express/package.json index ecf2d07bcf05..1bed35256ed5 100644 --- a/packages/web-express/package.json +++ b/packages/web-express/package.json @@ -6,8 +6,8 @@ "typings": "dist/index.d.ts", "scripts": { "build": "midway-bin build -c", - "test": "../../node_modules/.bin/jest --forceExit", - "cov": "../../node_modules/.bin/jest --coverage --forceExit", + "test": "midway-bin test --forceExit", + "cov": "midway-bin cov --forceExit", "ci": "npm run test" }, "keywords": [ @@ -26,7 +26,7 @@ "@midwayjs/mock": "^2.2.4", "@types/express": "^4.17.8", "fs-extra": "^8.0.1", - "midway-bin": "^2.2.4" + "@midwayjs/cli": "^1.0.x" }, "dependencies": { "@midwayjs/core": "^2.2.4", diff --git a/packages/web-koa/package.json b/packages/web-koa/package.json index 0f0f29d80495..d1953f381b93 100644 --- a/packages/web-koa/package.json +++ b/packages/web-koa/package.json @@ -6,8 +6,8 @@ "typings": "dist/index.d.ts", "scripts": { "build": "midway-bin build -c", - "test": "../../node_modules/.bin/jest --forceExit", - "cov": "../../node_modules/.bin/jest --coverage --forceExit", + "test": "midway-bin test --forceExit", + "cov": "midway-bin cov --forceExit", "ci": "npm run test" }, "keywords": [ @@ -27,7 +27,7 @@ "@types/koa": "^2.11.4", "@types/koa-router": "^7.4.1", "fs-extra": "^8.0.1", - "midway-bin": "^2.2.4" + "@midwayjs/cli": "^1.0.x" }, "dependencies": { "@midwayjs/core": "^2.2.4", diff --git a/packages/web/package.json b/packages/web/package.json index ca46da7945fd..f3d3f66df8b4 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -6,8 +6,8 @@ "typings": "dist/index.d.ts", "scripts": { "build": "midway-bin build -c", - "test": "../../node_modules/.bin/jest --forceExit", - "cov": "../../node_modules/.bin/jest --coverage --forceExit", + "test": "midway-bin test --forceExit", + "cov": "midway-bin cov --forceExit", "ci": "npm run test" }, "keywords": [ @@ -26,7 +26,7 @@ "@midwayjs/mock": "^2.2.4", "egg-view-nunjucks": "^2.2.0", "fs-extra": "^8.0.1", - "midway-bin": "^2.2.4", + "@midwayjs/cli": "^1.0.x", "pedding": "^1.1.0", "react": "^16.13.1", "react-dom": "^16.13.1"