diff --git a/.release-please-manifest.json b/.release-please-manifest.json index a636fe00cd..d51a1d25a5 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,5 +1,6 @@ { "packages/build": "27.20.3", + "packages/build-info": "4.0.10", "packages/cache-utils": "4.1.6", "packages/config": "18.2.4", "packages/functions-utils": "4.2.11", diff --git a/package-lock.json b/package-lock.json index 59c43853a0..02a9293076 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6540,6 +6540,10 @@ "resolved": "packages/build", "link": true }, + "node_modules/@netlify/build-info": { + "resolved": "packages/build-info", + "link": true + }, "node_modules/@netlify/cache-utils": { "resolved": "packages/cache-utils", "link": true @@ -6935,6 +6939,38 @@ "node": ">=12" } }, + "node_modules/@netlify/framework-info": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/@netlify/framework-info/-/framework-info-9.3.0.tgz", + "integrity": "sha512-GfGG6DGHeVNpSN9yesKvgT0LTgrD0d0toV3kU86+E9j+yByKnRUdxVlGXocA454t/eVw0Vww/xeKY10oGUljEw==", + "dependencies": { + "ajv": "^8.0.0", + "filter-obj": "^3.0.0", + "is-plain-obj": "^4.0.0", + "locate-path": "^7.0.0", + "p-filter": "^3.0.0", + "p-locate": "^6.0.0", + "read-pkg-up": "^9.0.0", + "semver": "^7.3.4" + }, + "engines": { + "node": "^12.20.0 || ^14.14.0 || >=16.0.0" + } + }, + "node_modules/@netlify/framework-info/node_modules/semver": { + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@netlify/functions-utils": { "resolved": "packages/functions-utils", "link": true @@ -7575,7 +7611,6 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/@npmcli/map-workspaces/-/map-workspaces-2.0.4.tgz", "integrity": "sha512-bMo0aAfwhVwqoVM5UzX1DJnlvVvzDCHae821jv48L1EsrYwfOZChlqWYXEtto/+BkBXetPbEWgau++/brh4oVg==", - "dev": true, "dependencies": { "@npmcli/name-from-folder": "^1.0.1", "glob": "^8.0.1", @@ -7590,7 +7625,6 @@ "version": "8.0.3", "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", - "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -7651,8 +7685,7 @@ "node_modules/@npmcli/name-from-folder": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@npmcli/name-from-folder/-/name-from-folder-1.0.1.tgz", - "integrity": "sha512-qq3oEfcLFwNfEYOQ8HLimRGKlD8WSeGEdtUa7hmzpR8Sa7haL1KVQrvgO6wqMjhWFFVjgtrh1gIxDz+P8sjUaA==", - "dev": true + "integrity": "sha512-qq3oEfcLFwNfEYOQ8HLimRGKlD8WSeGEdtUa7hmzpR8Sa7haL1KVQrvgO6wqMjhWFFVjgtrh1gIxDz+P8sjUaA==" }, "node_modules/@npmcli/node-gyp": { "version": "2.0.0", @@ -24186,6 +24219,57 @@ "node": "^12.20.0 || ^14.14.0 || >=16.0.0" } }, + "packages/build-info": { + "name": "@netlify/build-info", + "version": "4.0.10", + "license": "MIT", + "dependencies": { + "@netlify/framework-info": "^9.3.0", + "@npmcli/map-workspaces": "^2.0.0", + "read-pkg": "^7.0.0", + "yargs": "^17.0.0" + }, + "bin": { + "build-info": "bin.js" + }, + "devDependencies": { + "ava": "^4.0.0", + "c8": "^7.11.0", + "execa": "^6.0.0", + "get-bin-path": "^6.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.14.0 || >=16.0.0" + } + }, + "packages/build-info/node_modules/read-pkg": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-7.1.0.tgz", + "integrity": "sha512-5iOehe+WF75IccPc30bWTbpdDQLOCc3Uu8bi3Dte3Eueij81yx1Mrufk8qBx/YAbR4uL1FdUr+7BKXDwEtisXg==", + "dependencies": { + "@types/normalize-package-data": "^2.4.1", + "normalize-package-data": "^3.0.2", + "parse-json": "^5.2.0", + "type-fest": "^2.0.0" + }, + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/build-info/node_modules/type-fest": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz", + "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==", + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "packages/build/node_modules/semver": { "version": "7.3.5", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", @@ -29537,6 +29621,37 @@ } } }, + "@netlify/build-info": { + "version": "file:packages/build-info", + "requires": { + "@netlify/framework-info": "^9.3.0", + "@npmcli/map-workspaces": "^2.0.0", + "ava": "^4.0.0", + "c8": "^7.11.0", + "execa": "^6.0.0", + "get-bin-path": "^6.0.0", + "read-pkg": "^7.0.0", + "yargs": "^17.0.0" + }, + "dependencies": { + "read-pkg": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-7.1.0.tgz", + "integrity": "sha512-5iOehe+WF75IccPc30bWTbpdDQLOCc3Uu8bi3Dte3Eueij81yx1Mrufk8qBx/YAbR4uL1FdUr+7BKXDwEtisXg==", + "requires": { + "@types/normalize-package-data": "^2.4.1", + "normalize-package-data": "^3.0.2", + "parse-json": "^5.2.0", + "type-fest": "^2.0.0" + } + }, + "type-fest": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz", + "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==" + } + } + }, "@netlify/cache-utils": { "version": "file:packages/cache-utils", "requires": { @@ -29779,6 +29894,31 @@ "integrity": "sha512-WX52W8U1lsfWcz6NWoSpDs57lgiiMHN23seq8G2bvxzGS/tvYD3dxVLLW5UPoKSnFDyVQT7b6Zkt6AkBten1yQ==", "optional": true }, + "@netlify/framework-info": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/@netlify/framework-info/-/framework-info-9.3.0.tgz", + "integrity": "sha512-GfGG6DGHeVNpSN9yesKvgT0LTgrD0d0toV3kU86+E9j+yByKnRUdxVlGXocA454t/eVw0Vww/xeKY10oGUljEw==", + "requires": { + "ajv": "^8.0.0", + "filter-obj": "^3.0.0", + "is-plain-obj": "^4.0.0", + "locate-path": "^7.0.0", + "p-filter": "^3.0.0", + "p-locate": "^6.0.0", + "read-pkg-up": "^9.0.0", + "semver": "^7.3.4" + }, + "dependencies": { + "semver": { + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, "@netlify/functions-utils": { "version": "file:packages/functions-utils", "requires": { @@ -30301,7 +30441,6 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/@npmcli/map-workspaces/-/map-workspaces-2.0.4.tgz", "integrity": "sha512-bMo0aAfwhVwqoVM5UzX1DJnlvVvzDCHae821jv48L1EsrYwfOZChlqWYXEtto/+BkBXetPbEWgau++/brh4oVg==", - "dev": true, "requires": { "@npmcli/name-from-folder": "^1.0.1", "glob": "^8.0.1", @@ -30313,7 +30452,6 @@ "version": "8.0.3", "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", - "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -30360,8 +30498,7 @@ "@npmcli/name-from-folder": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@npmcli/name-from-folder/-/name-from-folder-1.0.1.tgz", - "integrity": "sha512-qq3oEfcLFwNfEYOQ8HLimRGKlD8WSeGEdtUa7hmzpR8Sa7haL1KVQrvgO6wqMjhWFFVjgtrh1gIxDz+P8sjUaA==", - "dev": true + "integrity": "sha512-qq3oEfcLFwNfEYOQ8HLimRGKlD8WSeGEdtUa7hmzpR8Sa7haL1KVQrvgO6wqMjhWFFVjgtrh1gIxDz+P8sjUaA==" }, "@npmcli/node-gyp": { "version": "2.0.0", diff --git a/packages/build-info/CHANGELOG.md b/packages/build-info/CHANGELOG.md new file mode 100644 index 0000000000..fd9211029d --- /dev/null +++ b/packages/build-info/CHANGELOG.md @@ -0,0 +1,298 @@ +# Changelog + +### [4.0.10](https://github.com/netlify/build-info/compare/v4.0.9...v4.0.10) (2022-02-21) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^9.0.2 ([#332](https://github.com/netlify/build-info/issues/332)) ([ee4d3a9](https://github.com/netlify/build-info/commit/ee4d3a98fe320fa7b401790bd3e73bb38f87fe12)) + +### [4.0.9](https://github.com/netlify/build-info/compare/v4.0.8...v4.0.9) (2022-02-21) + + +### Bug Fixes + +* **deps:** update dependency @npmcli/map-workspaces to v2.0.1 ([#330](https://github.com/netlify/build-info/issues/330)) ([85ab0d0](https://github.com/netlify/build-info/commit/85ab0d09c50a200e4792fa52b71e8846e8c70826)) +* **deps:** update dependency read-pkg to v7.1.0 ([#328](https://github.com/netlify/build-info/issues/328)) ([394b842](https://github.com/netlify/build-info/commit/394b842760d355292c67ca5114885c86e3a0dd11)) + +### [4.0.8](https://github.com/netlify/build-info/compare/v4.0.7...v4.0.8) (2022-02-07) + + +### Bug Fixes + +* **deps:** update dependency read-pkg to v7 ([#323](https://github.com/netlify/build-info/issues/323)) ([9929594](https://github.com/netlify/build-info/commit/99295941729a06fdd4e507b37bd82dc97729efb2)) + +### [4.0.7](https://github.com/netlify/build-info/compare/v4.0.6...v4.0.7) (2022-01-19) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to v9 ([#312](https://github.com/netlify/build-info/issues/312)) ([db76158](https://github.com/netlify/build-info/commit/db761582372e5992c7441d6152d872a87884339b)) + +### [4.0.6](https://github.com/netlify/build-info/compare/v4.0.5...v4.0.6) (2022-01-17) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^8.0.2 ([#307](https://github.com/netlify/build-info/issues/307)) ([c36bde6](https://github.com/netlify/build-info/commit/c36bde6921246f62e14670ce602f7fc559faf1f2)) + +### [4.0.5](https://github.com/netlify/build-info/compare/v4.0.4...v4.0.5) (2022-01-13) + + +### Bug Fixes + +* **deps:** update dependency @npmcli/map-workspaces to v2 ([#301](https://github.com/netlify/build-info/issues/301)) ([9a6c9a0](https://github.com/netlify/build-info/commit/9a6c9a00257c95d89f96d4abb99e4678f3349ddb)) + +### [4.0.4](https://github.com/netlify/build-info/compare/v4.0.3...v4.0.4) (2022-01-12) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^8.0.1 ([#299](https://github.com/netlify/build-info/issues/299)) ([13e65ed](https://github.com/netlify/build-info/commit/13e65edd0e428f1cb26b065cf0483a8d9b41840e)) + +### [4.0.3](https://github.com/netlify/build-info/compare/v4.0.2...v4.0.3) (2022-01-10) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to v8 ([#295](https://github.com/netlify/build-info/issues/295)) ([7eb9f3e](https://github.com/netlify/build-info/commit/7eb9f3e9125af63a76cfe97df59a5255fb808dd0)) + +### [4.0.2](https://www.github.com/netlify/build-info/compare/v4.0.1...v4.0.2) (2021-12-14) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to v7 ([#239](https://www.github.com/netlify/build-info/issues/239)) ([844d91b](https://www.github.com/netlify/build-info/commit/844d91b60d765a28f9e3d001b7853de063b975d6)) + +### [4.0.1](https://www.github.com/netlify/build-info/compare/v4.0.0...v4.0.1) (2021-12-06) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^6.1.0 ([#222](https://www.github.com/netlify/build-info/issues/222)) ([ee85866](https://www.github.com/netlify/build-info/commit/ee8586670fbe0edb4f621aeddc1d54a4765cb527)) + +## [4.0.0](https://www.github.com/netlify/build-info/compare/v3.0.1...v4.0.0) (2021-11-29) + + +### ⚠ BREAKING CHANGES + +* use pure ES modules (#208) + +### Miscellaneous Chores + +* use pure ES modules ([#208](https://www.github.com/netlify/build-info/issues/208)) ([36fad7c](https://www.github.com/netlify/build-info/commit/36fad7ce68bacda5741f6c20a40675fde736a595)) + +### [3.0.1](https://www.github.com/netlify/build-info/compare/v3.0.0...v3.0.1) (2021-11-24) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to v6 ([#206](https://www.github.com/netlify/build-info/issues/206)) ([09d9005](https://www.github.com/netlify/build-info/commit/09d9005c0749764aa31bd7f4812994e54a310ba6)) + +## [3.0.0](https://www.github.com/netlify/build-info/compare/v2.0.18...v3.0.0) (2021-11-24) + + +### ⚠ BREAKING CHANGES + +* drop support for Node 10 (#204) + +### Miscellaneous Chores + +* drop support for Node 10 ([#204](https://www.github.com/netlify/build-info/issues/204)) ([637f1f7](https://www.github.com/netlify/build-info/commit/637f1f7d45eca1cffbf94dd3e76314f004a9e0b3)) + +### [2.0.18](https://www.github.com/netlify/build-info/compare/v2.0.17...v2.0.18) (2021-10-11) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^5.11.0 ([#177](https://www.github.com/netlify/build-info/issues/177)) ([67e256a](https://www.github.com/netlify/build-info/commit/67e256a4bbac039d80fb5ed877b559b74275be5e)) + +### [2.0.17](https://www.github.com/netlify/build-info/compare/v2.0.16...v2.0.17) (2021-09-20) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^5.9.2 ([#163](https://www.github.com/netlify/build-info/issues/163)) ([f19297c](https://www.github.com/netlify/build-info/commit/f19297c2b38a84b233f1fbee5cd3e7016573dfe4)) + +### [2.0.16](https://www.github.com/netlify/build-info/compare/v2.0.15...v2.0.16) (2021-08-18) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^5.7.3 ([#135](https://www.github.com/netlify/build-info/issues/135)) ([de04907](https://www.github.com/netlify/build-info/commit/de04907e3f5a3533b0ab127b88abad2f4482b099)) +* **deps:** update dependency @netlify/framework-info to ^5.8.0 ([#137](https://www.github.com/netlify/build-info/issues/137)) ([a22028d](https://www.github.com/netlify/build-info/commit/a22028d536f6f223a08327018bebc77a87c5b914)) +* **deps:** update dependency @netlify/framework-info to ^5.9.0 ([#145](https://www.github.com/netlify/build-info/issues/145)) ([8b3b681](https://www.github.com/netlify/build-info/commit/8b3b681b848233fb0b90e7a8c3a0ef340db55fde)) +* **deps:** update dependency @netlify/framework-info to ^5.9.1 ([#146](https://www.github.com/netlify/build-info/issues/146)) ([e21ff52](https://www.github.com/netlify/build-info/commit/e21ff52e4b33bbb9106c2878ee27c27a20a74521)) +* **deps:** update dependency @npmcli/map-workspaces to v1.0.4 ([#142](https://www.github.com/netlify/build-info/issues/142)) ([a72d70e](https://www.github.com/netlify/build-info/commit/a72d70e8e2b1c58ee15b0abc05c3182b02fe024e)) + +### [2.0.15](https://www.github.com/netlify/build-info/compare/v2.0.14...v2.0.15) (2021-07-19) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^5.7.1 ([#124](https://www.github.com/netlify/build-info/issues/124)) ([e421e5f](https://www.github.com/netlify/build-info/commit/e421e5f483bc9dd5cc4433dfdaec4448003c97ea)) +* **deps:** update dependency @netlify/framework-info to ^5.7.2 ([#126](https://www.github.com/netlify/build-info/issues/126)) ([6b59bc9](https://www.github.com/netlify/build-info/commit/6b59bc92fdc5226ad3ac43a052e33e42d68c25e5)) + +### [2.0.14](https://www.github.com/netlify/build-info/compare/v2.0.13...v2.0.14) (2021-07-12) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^5.7.0 ([#121](https://www.github.com/netlify/build-info/issues/121)) ([657d7c7](https://www.github.com/netlify/build-info/commit/657d7c757eeffc6ffb3180715c0f738d6f01e0c1)) + +### [2.0.13](https://www.github.com/netlify/build-info/compare/v2.0.12...v2.0.13) (2021-07-11) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^5.6.1 ([#118](https://www.github.com/netlify/build-info/issues/118)) ([38cb6e0](https://www.github.com/netlify/build-info/commit/38cb6e043a66e0f2986aa755f290b98b97c418ec)) + +### [2.0.12](https://www.github.com/netlify/build-info/compare/v2.0.11...v2.0.12) (2021-07-05) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^5.6.0 ([#116](https://www.github.com/netlify/build-info/issues/116)) ([945872e](https://www.github.com/netlify/build-info/commit/945872e579040c92e7f23ada8ba46916b4c7d6b3)) + +### [2.0.11](https://www.github.com/netlify/build-info/compare/v2.0.10...v2.0.11) (2021-06-30) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^5.5.0 ([#111](https://www.github.com/netlify/build-info/issues/111)) ([036143a](https://www.github.com/netlify/build-info/commit/036143a293c208da05bfc7ba0c84c7e7e1731ba1)) + +### [2.0.10](https://www.github.com/netlify/build-info/compare/v2.0.9...v2.0.10) (2021-06-27) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^5.4.0 ([#106](https://www.github.com/netlify/build-info/issues/106)) ([a898051](https://www.github.com/netlify/build-info/commit/a8980511c75d1431ab76b50440cb250673f0fde2)) + +### [2.0.9](https://www.github.com/netlify/build-info/compare/v2.0.8...v2.0.9) (2021-06-15) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^5.3.0 ([#102](https://www.github.com/netlify/build-info/issues/102)) ([9d8fbd8](https://www.github.com/netlify/build-info/commit/9d8fbd8ea6c54d6571ca2021cbd43ce982582457)) + +### [2.0.8](https://www.github.com/netlify/build-info/compare/v2.0.7...v2.0.8) (2021-06-13) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^5.2.0 ([#98](https://www.github.com/netlify/build-info/issues/98)) ([8a1a775](https://www.github.com/netlify/build-info/commit/8a1a7757890807ed07040da665f31e6d3812690e)) + +### [2.0.7](https://www.github.com/netlify/build-info/compare/v2.0.6...v2.0.7) (2021-06-07) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^5.1.4 ([#94](https://www.github.com/netlify/build-info/issues/94)) ([5289273](https://www.github.com/netlify/build-info/commit/5289273ed7c160e9517cf0c79d0cd49db89e7d96)) + +### [2.0.6](https://www.github.com/netlify/build-info/compare/v2.0.5...v2.0.6) (2021-06-02) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^5.1.3 ([#88](https://www.github.com/netlify/build-info/issues/88)) ([44d22e9](https://www.github.com/netlify/build-info/commit/44d22e95b567eed3a71481fcea933e4e1b910bf3)) + +### [2.0.5](https://www.github.com/netlify/build-info/compare/v2.0.4...v2.0.5) (2021-05-31) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^5.1.2 ([#86](https://www.github.com/netlify/build-info/issues/86)) ([4d45c54](https://www.github.com/netlify/build-info/commit/4d45c54724f30647ea971b83e3f3624a3b99b703)) + +### [2.0.4](https://www.github.com/netlify/build-info/compare/v2.0.3...v2.0.4) (2021-05-31) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^5.1.1 ([#84](https://www.github.com/netlify/build-info/issues/84)) ([9d02106](https://www.github.com/netlify/build-info/commit/9d02106b99d6618750903ec7a94148782d6c0fcd)) + +### [2.0.3](https://www.github.com/netlify/build-info/compare/v2.0.2...v2.0.3) (2021-05-31) + + +### Bug Fixes + +* **deps:** update dependency yargs to v16 ([#82](https://www.github.com/netlify/build-info/issues/82)) ([b1a0682](https://www.github.com/netlify/build-info/commit/b1a068239f9efa6c9c9efcc0db5fc448a3759aab)) + +### [2.0.2](https://www.github.com/netlify/build-info/compare/v2.0.1...v2.0.2) (2021-05-30) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^5.1.0 ([#73](https://www.github.com/netlify/build-info/issues/73)) ([f4d6039](https://www.github.com/netlify/build-info/commit/f4d60397148d2d7d3620f478bfff67de9687c8f7)) + +### [2.0.1](https://www.github.com/netlify/build-info/compare/v2.0.0...v2.0.1) (2021-05-27) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to v5 ([#65](https://www.github.com/netlify/build-info/issues/65)) ([64da81e](https://www.github.com/netlify/build-info/commit/64da81ecd9c04817e273bed3fa064db9a0663a7a)) + +## [2.0.0](https://www.github.com/netlify/build-info/compare/v1.2.3...v2.0.0) (2021-05-27) + + +### ⚠ BREAKING CHANGES + +* drop support for Node.js 8 (#66) + +### Miscellaneous Chores + +* drop support for Node.js 8 ([#66](https://www.github.com/netlify/build-info/issues/66)) ([9259b05](https://www.github.com/netlify/build-info/commit/9259b05775c58df86637b89b5e4b304a54a81133)) + +### [1.2.3](https://www.github.com/netlify/build-info/compare/v1.2.2...v1.2.3) (2021-05-11) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^4.1.0 ([#53](https://www.github.com/netlify/build-info/issues/53)) ([3c3862f](https://www.github.com/netlify/build-info/commit/3c3862f34654f1dee8b690a377a08d3f1b2dd8d6)) + +### [1.2.2](https://www.github.com/netlify/build-info/compare/v1.2.1...v1.2.2) (2021-05-09) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to ^4.0.1 ([#48](https://www.github.com/netlify/build-info/issues/48)) ([b24c5d7](https://www.github.com/netlify/build-info/commit/b24c5d7634c5ca38717e9d5f4a42b7cc3c19bb5b)) + +### [1.2.1](https://www.github.com/netlify/build-info/compare/v1.2.0...v1.2.1) (2021-04-27) + + +### Bug Fixes + +* **deps:** update dependency @netlify/framework-info to v4 ([#44](https://www.github.com/netlify/build-info/issues/44)) ([b5d862f](https://www.github.com/netlify/build-info/commit/b5d862fd5caae1a28729fbd31ccc303f99e91b87)) + +## [1.2.0](https://www.github.com/netlify/build-info/compare/v1.1.1...v1.2.0) (2021-04-13) + + +### Features + +* include framework info ([#35](https://www.github.com/netlify/build-info/issues/35)) ([ffbb6ee](https://www.github.com/netlify/build-info/commit/ffbb6ee236345bd158b4a1a3386ad99eeb5b562d)) + + +### Bug Fixes + +* **bin:** remove cli rootDir default setting ([#37](https://www.github.com/netlify/build-info/issues/37)) ([9da8022](https://www.github.com/netlify/build-info/commit/9da80226b7d5442cb69168939148c8aa3b77be94)) + +### [1.1.1](https://www.github.com/netlify/build-info/compare/v1.1.0...v1.1.1) (2021-04-07) + + +### Bug Fixes + +* **context:** make projectDir resolution based on rootDir ([#26](https://www.github.com/netlify/build-info/issues/26)) ([2a965b4](https://www.github.com/netlify/build-info/commit/2a965b4c973c7e3f0867a321422eb40dcfd82926)) +* **package.json:** add main entrypoint ([#30](https://www.github.com/netlify/build-info/issues/30)) ([cc55a9e](https://www.github.com/netlify/build-info/commit/cc55a9e6da9a3be6d6a33c74f38ab35796e9e882)) + +## [1.1.0](https://www.github.com/netlify/build-info/compare/v1.0.0...v1.1.0) (2021-04-05) + + +### Features + +* add binary ([#15](https://www.github.com/netlify/build-info/issues/15)) ([710d4c9](https://www.github.com/netlify/build-info/commit/710d4c9725120400b49181a19078ae4187b521bd)) + +## 1.0.0 (2021-03-29) + + +### Features + +* detect js workspaces ([#3](https://www.github.com/netlify/build-info/issues/3)) ([0dbf74b](https://www.github.com/netlify/build-info/commit/0dbf74b78cc9b727ff177adda4bae20b4970f96f)) diff --git a/packages/build-info/LICENSE b/packages/build-info/LICENSE new file mode 100644 index 0000000000..7d56877130 --- /dev/null +++ b/packages/build-info/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2020 Netlify + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/packages/build-info/README.md b/packages/build-info/README.md new file mode 100644 index 0000000000..b6cede46ab --- /dev/null +++ b/packages/build-info/README.md @@ -0,0 +1,112 @@ +[![Build](https://github.com/netlify/build-info/workflows/Build/badge.svg)](https://github.com/netlify/build-info/actions) +[![Node](https://img.shields.io/node/v/@netlify/build-info.svg?logo=node.js)](https://www.npmjs.com/package/@netlify/build-info) + +# Build Info + +Build information detection utility. + +The purpose of this lib is to, given a project and a configuration, return a set of useful data for our build system. +Currently it's used to detect: + +- [`jsWorkspaces`](https://docs.npmjs.com/cli/v7/using-npm/workspaces) +- [`frameworks`](https://github.com/netlify/framework-info) + +But it's possible to extend it in the future to extract other bits of information, such as the heuristics present in the +[`build-image`](https://github.com/netlify/build-image/blob/xenial/run-build-functions.sh#L214). + +# Example (Node.js) + +```js +import { getBuildInfo } from '@netlify/build-info' + +console.log(await getBuildInfo({ projectDir: 'path/to/site', rootDir: '/project/root/dir' })) +// { +// jsWorkspaces: { +// isRoot: false, +// packages: [ +// 'path/to/site', +// 'path/to/component/library' +// 'path/to/utility/library' +// ] +// }, +// frameworks: [ +// { +// name: 'gatsby', +// category: 'static_site_generator', +// dev: { +// commands: ['gatsby develop'], +// port: 8000 +// }, +// build: { +// commands: ['gatsby build'], +// directory: 'public' +// }, +// env: { GATSBY_LOGGER: 'yurnalist' }, +// plugins: [] +// } +// ] +// } + +console.log(await getBuildInfo({ projectDir: '/project/root/dir' })) +// { +// jsWorkspaces: { +// isRoot: true, +// packages: [ +// 'path/to/site', +// 'path/to/component/library' +// 'path/to/utility/library' +// ] +// }, +// frameworks: [] +// } +``` + +# Example (CLI) + +```bash +$ build-info /project/root/dir +{ + jsWorkspaces: { + isRoot: true, + packages: [ + 'path/to/site', + 'path/to/component/library' + 'path/to/utility/library' + ] + }, + frameworks: [] +} + +$ build-info path/to/site --rootDir /project/root/dir +{ + jsWorkspaces: { + isRoot: false, + packages: [ + 'path/to/site', + 'path/to/component/library' + 'path/to/utility/library' + ] + }, + frameworks: [ + { + name: 'gatsby', + category: 'static_site_generator', + dev: { + commands: ['gatsby develop'], + port: 8000 + }, + build: { + commands: ['gatsby build'], + directory: 'public' + }, + env: { GATSBY_LOGGER: 'yurnalist' }, + plugins: [] + } + ] +} +``` + +## Contributors + +Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for instructions on how to set up and work on this repository. Thanks +for contributing! diff --git a/packages/build-info/bin.js b/packages/build-info/bin.js new file mode 100755 index 0000000000..1a24988888 --- /dev/null +++ b/packages/build-info/bin.js @@ -0,0 +1,5 @@ +#!/usr/bin/env node + +// This is a workaround for npm issue: https://github.com/npm/cli/issues/2632 + +import './lib/bin.js' diff --git a/packages/build-info/package.json b/packages/build-info/package.json new file mode 100644 index 0000000000..d73766ff7f --- /dev/null +++ b/packages/build-info/package.json @@ -0,0 +1,50 @@ +{ + "name": "@netlify/build-info", + "version": "4.0.10", + "description": "Build info utility", + "type": "module", + "exports": "./lib/main.js", + "main": "./lib/main.js", + "types": "./lib/main.d.ts", + "bin": { + "build-info": "./bin.js" + }, + "files": [ + "bin.js", + "lib/**/*" + ], + "scripts": { + "prebuild": "rm -rf lib", + "build": "tsc", + "test": "ava", + "test:ci": "c8 -r lcovonly -r text -r json ava" + }, + "ava": { + "verbose": true, + "files": [ + "!test/fixtures/**/*" + ] + }, + "keywords": [], + "license": "MIT", + "repository": "netlify/build-info", + "bugs": { + "url": "https://github.com/netlify/build/issues" + }, + "author": "Netlify Inc.", + "dependencies": { + "@netlify/framework-info": "^9.3.0", + "@npmcli/map-workspaces": "^2.0.0", + "read-pkg": "^7.0.0", + "yargs": "^17.0.0" + }, + "devDependencies": { + "ava": "^4.0.0", + "c8": "^7.11.0", + "execa": "^6.0.0", + "get-bin-path": "^6.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.14.0 || >=16.0.0" + } +} diff --git a/packages/build-info/src/bin.js b/packages/build-info/src/bin.js new file mode 100755 index 0000000000..046efaf224 --- /dev/null +++ b/packages/build-info/src/bin.js @@ -0,0 +1,37 @@ +#!/usr/bin/env node +import { exit, argv } from 'process' + +import yargs from 'yargs' +import { hideBin } from 'yargs/helpers' + +import { getBuildInfo } from './main.js' + +// CLI entry point +const runCli = async function () { + const { projectDir, rootDir } = parseArgs() + + try { + const buildInfo = await getBuildInfo({ projectDir, rootDir }) + console.log(JSON.stringify(buildInfo, null, 2)) + } catch (error) { + console.error(error) + exit(1) + } +} + +const parseArgs = function () { + return yargs(hideBin(argv)).command('* [projectDir]').options(OPTIONS).usage(USAGE).strict().parse() +} + +const OPTIONS = { + rootDir: { + string: true, + describe: `The root directory of the project if different from projectDir`, + }, +} + +const USAGE = `$0 [OPTIONS...] [PROJECT_DIRECTORY] + +Print relevant build information from a project.` + +runCli() diff --git a/packages/build-info/src/context.js b/packages/build-info/src/context.js new file mode 100644 index 0000000000..e8a3b352d3 --- /dev/null +++ b/packages/build-info/src/context.js @@ -0,0 +1,39 @@ +import { resolve } from 'path' +import { cwd } from 'process' + +import { readPackage } from 'read-pkg' + +const getPackageJson = async function (dir) { + try { + const packageJson = await readPackage({ cwd: dir, normalize: false }) + if (packageJson === undefined) { + return {} + } + + return packageJson + } catch { + return {} + } +} + +export const getContext = async function ({ projectDir = cwd(), rootDir = '' } = {}) { + // Get the absolute dirs for both project and root + // We resolve the projectDir from the rootDir + const absoluteProjectDir = resolve(rootDir, projectDir) + // If a relative absolute path is given we rely on cwd + const absoluteRootDir = rootDir ? resolve(cwd(), rootDir) : undefined + + // We only pass through the root dir if it was provided and is actually different + // from the project dir + const validRootDir = absoluteRootDir && absoluteRootDir !== absoluteProjectDir ? absoluteRootDir : undefined + + // If rootDir equals projectDir we'll be getting the projectDir package.json + // Later on if we also need the projectDir package.json we can check for it + // and only perform one resolution + const rootPackageJson = await getPackageJson(rootDir || projectDir) + return { + projectDir: absoluteProjectDir, + rootDir: validRootDir, + rootPackageJson, + } +} diff --git a/packages/build-info/src/core.js b/packages/build-info/src/core.js new file mode 100644 index 0000000000..d3132a4187 --- /dev/null +++ b/packages/build-info/src/core.js @@ -0,0 +1,9 @@ +import { getFrameworks } from './frameworks.js' +import { getWorkspaceInfo } from './workspaces.js' + +export const buildInfo = async function (context) { + const workspaceInfo = await getWorkspaceInfo(context) + const jsWorkspaces = workspaceInfo ? { jsWorkspaces: workspaceInfo } : {} + const frameworks = await getFrameworks(context) + return { ...jsWorkspaces, frameworks } +} diff --git a/packages/build-info/src/frameworks.js b/packages/build-info/src/frameworks.js new file mode 100644 index 0000000000..12bf74e2f6 --- /dev/null +++ b/packages/build-info/src/frameworks.js @@ -0,0 +1,5 @@ +import { listFrameworks } from '@netlify/framework-info' + +export const getFrameworks = async function ({ projectDir }) { + return await listFrameworks({ projectDir }) +} diff --git a/packages/build-info/src/main.js b/packages/build-info/src/main.js new file mode 100644 index 0000000000..3e7c3c1e52 --- /dev/null +++ b/packages/build-info/src/main.js @@ -0,0 +1,7 @@ +import { getContext } from './context.js' +import { buildInfo } from './core.js' + +export const getBuildInfo = async function (opts) { + const context = await getContext(opts) + return await buildInfo(context) +} diff --git a/packages/build-info/src/workspaces.js b/packages/build-info/src/workspaces.js new file mode 100644 index 0000000000..dcf9278f6f --- /dev/null +++ b/packages/build-info/src/workspaces.js @@ -0,0 +1,23 @@ +import mapWorkspaces from '@npmcli/map-workspaces' + +export const getWorkspaceInfo = async function ({ rootPackageJson, projectDir, rootDir }) { + if (!rootPackageJson.workspaces) { + return + } + + const workspacesMap = await mapWorkspaces({ + cwd: rootDir || projectDir, + pkg: rootPackageJson, + }) + + const packages = [...workspacesMap.values()] + // The provided project dir is a workspace package + const isWorkspace = packages.find((path) => projectDir === path) + + // The project dir is a collection of workspaces itself + const isRoot = !rootDir + + if (isWorkspace || isRoot) { + return { isRoot, packages } + } +} diff --git a/packages/build-info/test/bin.js b/packages/build-info/test/bin.js new file mode 100644 index 0000000000..d8a77d2e86 --- /dev/null +++ b/packages/build-info/test/bin.js @@ -0,0 +1,53 @@ +import { relative } from 'path' +import { cwd } from 'process' +import { fileURLToPath } from 'url' + +import test from 'ava' +import { execa } from 'execa' +import { getBinPath } from 'get-bin-path' + +const FIXTURES_ABSOLUTE_PATH = fileURLToPath(new URL('fixtures', import.meta.url)) +const FIXTURES_RELATIVE_PATH = relative(cwd(), FIXTURES_ABSOLUTE_PATH) + +const BINARY_PATH = getBinPath() + +test('CLI --help flag', async (t) => { + const binPath = await BINARY_PATH + const { stdout } = await execa(binPath, ['--help']) + t.snapshot(stdout) +}) + +test('CLI prints js-workspaces and frameworks in JSON format', async (t) => { + const binPath = await BINARY_PATH + const { stdout } = await execa(binPath, [ + `${FIXTURES_ABSOLUTE_PATH}/js-workspaces/packages/gatsby-site`, + '--rootDir', + `${FIXTURES_ABSOLUTE_PATH}/js-workspaces`, + ]) + const { jsWorkspaces, frameworks } = JSON.parse(stdout) + t.false(jsWorkspaces.isRoot) + t.is(jsWorkspaces.packages.length, 2) + t.is(frameworks.length, 1) +}) + +test('CLI does not print js-workspaces if given a project without it', async (t) => { + const binPath = await BINARY_PATH + const { stdout } = await execa(binPath, [`${FIXTURES_ABSOLUTE_PATH}/js-workspaces/packages/gatsby-site`]) + const { jsWorkspaces } = JSON.parse(stdout) + t.is(jsWorkspaces, undefined) +}) + +test('CLI works if given a relative path and no rootDir', async (t) => { + const binPath = await BINARY_PATH + const { stdout } = await execa(binPath, [`${FIXTURES_RELATIVE_PATH}/js-workspaces`]) + const { jsWorkspaces, frameworks } = JSON.parse(stdout) + t.not(jsWorkspaces, undefined) + t.is(frameworks.length, 1) +}) + +test('CLI prints an empty array if no frameworks are found', async (t) => { + const binPath = await BINARY_PATH + const { stdout } = await execa(binPath, [`${FIXTURES_ABSOLUTE_PATH}/empty`]) + const { frameworks } = JSON.parse(stdout) + t.deepEqual(frameworks, []) +}) diff --git a/packages/build-info/test/context.js b/packages/build-info/test/context.js new file mode 100644 index 0000000000..a2cccb4329 --- /dev/null +++ b/packages/build-info/test/context.js @@ -0,0 +1,67 @@ +import { resolve } from 'path' +import { cwd } from 'process' +import { fileURLToPath } from 'url' + +import test from 'ava' + +import { getContext } from '../src/context.js' + +const FIXTURES_ABSOLUTE_PATH = fileURLToPath(new URL('fixtures', import.meta.url)) + +test('context: if no options are provided set projectDir to cwd', async (t) => { + const { projectDir, rootDir } = await getContext() + t.is(projectDir, cwd()) + t.is(rootDir, undefined) +}) + +test('context: given a relative projectDir and a rootDir, resolve projectDir from rootDir', async (t) => { + const argRootDir = '/root' + const argProjectDir = 'some/relative/path' + const { projectDir, rootDir, rootPackageJson } = await getContext({ projectDir: argProjectDir, rootDir: argRootDir }) + t.is(projectDir, resolve(argRootDir, argProjectDir)) + t.is(rootDir, resolve(rootDir)) + t.deepEqual(rootPackageJson, {}) +}) + +test('context: given an empty projectDir and a rootDir, resolve projectDir to rootDir', async (t) => { + const argRootDir = '/root/dir' + const argProjectDir = '' + const { projectDir, rootDir, rootPackageJson } = await getContext({ projectDir: argProjectDir, rootDir: argRootDir }) + t.is(projectDir, resolve(argRootDir)) + t.is(rootDir, undefined) + t.deepEqual(rootPackageJson, {}) +}) + +test('context: given a relative rootDir resolve from cwd', async (t) => { + const argRootDir = 'root' + const argProjectDir = 'some/relative/path' + const { projectDir, rootDir, rootPackageJson } = await getContext({ projectDir: argProjectDir, rootDir: argRootDir }) + t.is(projectDir, resolve(cwd(), argRootDir, argProjectDir)) + t.is(rootDir, resolve(cwd(), argRootDir)) + t.deepEqual(rootPackageJson, {}) +}) + +test('context: given absolute dirs rely on them', async (t) => { + const argRootDir = '/root/dir' + const argProjectDir = '/root/dir/sub/project/dir' + const { projectDir, rootDir, rootPackageJson } = await getContext({ projectDir: argProjectDir, rootDir: argRootDir }) + t.is(projectDir, resolve(argProjectDir)) + t.is(rootDir, resolve(argRootDir)) + t.deepEqual(rootPackageJson, {}) +}) + +test('context: extract the rootPackageJson if there is one within rootDir', async (t) => { + const { rootPackageJson } = await getContext({ + rootDir: `${FIXTURES_ABSOLUTE_PATH}/js-workspaces`, + projectDir: 'packages/package-2', + }) + t.is(rootPackageJson.name, 'js-workspaces') +}) + +test('context: extract the rootPackageJson from projectDir if no rootDir is provided', async (t) => { + const { rootPackageJson, rootDir } = await getContext({ + projectDir: `${FIXTURES_ABSOLUTE_PATH}/js-workspaces/packages/package-2`, + }) + t.is(rootDir, undefined) + t.is(rootPackageJson.name, 'simple-package-json') +}) diff --git a/packages/build-info/test/fixtures/js-workspaces/not-in-workspace/package.json b/packages/build-info/test/fixtures/js-workspaces/not-in-workspace/package.json new file mode 100644 index 0000000000..a18d045603 --- /dev/null +++ b/packages/build-info/test/fixtures/js-workspaces/not-in-workspace/package.json @@ -0,0 +1,4 @@ +{ + "name": "not-in-workspace", + "version": "1.0.0" +} diff --git a/packages/build-info/test/fixtures/js-workspaces/package.json b/packages/build-info/test/fixtures/js-workspaces/package.json new file mode 100644 index 0000000000..dd7c8f50fa --- /dev/null +++ b/packages/build-info/test/fixtures/js-workspaces/package.json @@ -0,0 +1,10 @@ +{ + "name": "js-workspaces", + "version": "1.0.0", + "workspaces": [ + "packages/*" + ], + "dependencies": { + "sapper": "*" + } +} diff --git a/packages/build-info/test/fixtures/js-workspaces/packages/gatsby-site/gatsby-config.js b/packages/build-info/test/fixtures/js-workspaces/packages/gatsby-site/gatsby-config.js new file mode 100644 index 0000000000..4ba52ba2c8 --- /dev/null +++ b/packages/build-info/test/fixtures/js-workspaces/packages/gatsby-site/gatsby-config.js @@ -0,0 +1 @@ +module.exports = {} diff --git a/packages/build-info/test/fixtures/js-workspaces/packages/gatsby-site/package.json b/packages/build-info/test/fixtures/js-workspaces/packages/gatsby-site/package.json new file mode 100644 index 0000000000..bf7305917e --- /dev/null +++ b/packages/build-info/test/fixtures/js-workspaces/packages/gatsby-site/package.json @@ -0,0 +1,7 @@ +{ + "name": "gatsby-site", + "version": "1.0.0", + "dependencies": { + "gatsby": "*" + } +} diff --git a/packages/build-info/test/fixtures/js-workspaces/packages/package-2/package.json b/packages/build-info/test/fixtures/js-workspaces/packages/package-2/package.json new file mode 100644 index 0000000000..9674293c57 --- /dev/null +++ b/packages/build-info/test/fixtures/js-workspaces/packages/package-2/package.json @@ -0,0 +1,4 @@ +{ + "name": "simple-package-json", + "version": "1.0.0" +} diff --git a/packages/build-info/test/fixtures/simple-package-json/package.json b/packages/build-info/test/fixtures/simple-package-json/package.json new file mode 100644 index 0000000000..9674293c57 --- /dev/null +++ b/packages/build-info/test/fixtures/simple-package-json/package.json @@ -0,0 +1,4 @@ +{ + "name": "simple-package-json", + "version": "1.0.0" +} diff --git a/packages/build-info/test/main.js b/packages/build-info/test/main.js new file mode 100644 index 0000000000..d1ed1c7921 --- /dev/null +++ b/packages/build-info/test/main.js @@ -0,0 +1,86 @@ +import { relative } from 'path' +import { cwd } from 'process' +import { fileURLToPath } from 'url' + +import test from 'ava' + +import { getBuildInfo } from '../src/main.js' + +const FIXTURES_ABSOLUTE_PATH = fileURLToPath(new URL('fixtures', import.meta.url)) +const FIXTURES_RELATIVE_PATH = relative(cwd(), FIXTURES_ABSOLUTE_PATH) + +test('js-workspaces: project without package.json does not return workspaces info', async (t) => { + const { jsWorkspaces } = await getBuildInfo({ + projectDir: `${FIXTURES_RELATIVE_PATH}/empty`, + }) + t.is(jsWorkspaces, undefined) +}) + +test('js-workspaces: project without workspaces in package.json does not return workspaces info', async (t) => { + const { jsWorkspaces } = await getBuildInfo({ + projectDir: `${FIXTURES_RELATIVE_PATH}/simple-package-json`, + }) + t.is(jsWorkspaces, undefined) +}) + +test('js-workspaces: projectDir set to workspaces root returns workspace info and isRoot flag set to true', async (t) => { + const { jsWorkspaces } = await getBuildInfo({ + projectDir: `${FIXTURES_RELATIVE_PATH}/js-workspaces`, + }) + t.not(jsWorkspaces, undefined) + t.true(jsWorkspaces.isRoot) + t.is(jsWorkspaces.packages.length, 2) +}) + +test('js-workspaces: projectDir set to workspace dir returns workspace info and isRoot flag set to false', async (t) => { + const { jsWorkspaces } = await getBuildInfo({ + rootDir: `${FIXTURES_RELATIVE_PATH}/js-workspaces`, + projectDir: 'packages/gatsby-site', + }) + t.not(jsWorkspaces, undefined) + t.false(jsWorkspaces.isRoot) + t.is(jsWorkspaces.packages.length, 2) +}) + +test('js-workspaces: if project is not part of a workspace return no workspace info', async (t) => { + const { jsWorkspaces } = await getBuildInfo({ + rootDir: `${FIXTURES_RELATIVE_PATH}/js-workspaces`, + projectDir: 'not-in-workspace', + }) + t.is(jsWorkspaces, undefined) +}) + +test('js-workspaces: handles absolute paths correctly', async (t) => { + const { jsWorkspaces } = await getBuildInfo({ + rootDir: `${FIXTURES_ABSOLUTE_PATH}/js-workspaces`, + projectDir: `${FIXTURES_ABSOLUTE_PATH}/js-workspaces/packages/gatsby-site`, + }) + t.not(jsWorkspaces, undefined) + t.false(jsWorkspaces.isRoot) + t.is(jsWorkspaces.packages.length, 2) +}) + +test('frameworks: return an empty array if no frameworks are detected', async (t) => { + const { frameworks } = await getBuildInfo({ + rootDir: `${FIXTURES_ABSOLUTE_PATH}/empty`, + }) + t.deepEqual(frameworks, []) +}) + +test('all: should detect workspaces and frameworks', async (t) => { + const { frameworks, jsWorkspaces } = await getBuildInfo({ + rootDir: `${FIXTURES_ABSOLUTE_PATH}/js-workspaces`, + projectDir: 'packages/gatsby-site', + }) + t.not(jsWorkspaces, undefined) + t.is(frameworks.length, 1) +}) + +test('all: detects workspaces and frameworks when given a rootDir and an empty projectDir', async (t) => { + const { frameworks, jsWorkspaces } = await getBuildInfo({ + rootDir: `${FIXTURES_ABSOLUTE_PATH}/js-workspaces`, + projectDir: '', + }) + t.not(jsWorkspaces, undefined) + t.is(frameworks.length, 1) +}) diff --git a/packages/build-info/test/snapshots/bin.js.md b/packages/build-info/test/snapshots/bin.js.md new file mode 100644 index 0000000000..8657ee415f --- /dev/null +++ b/packages/build-info/test/snapshots/bin.js.md @@ -0,0 +1,20 @@ +# Snapshot report for `test/bin.js` + +The actual snapshot is saved in `bin.js.snap`. + +Generated by [AVA](https://avajs.dev). + +## CLI --help flag + +> Snapshot 1 + + `bin.js [OPTIONS...] [PROJECT_DIRECTORY]␊ + ␊ + Print relevant build information from a␊ + project.␊ + ␊ + Options:␊ + --help Show help [boolean]␊ + --version Show version number [boolean]␊ + --rootDir The root directory of the project if different from projectDir␊ + [string]` diff --git a/packages/build-info/test/snapshots/bin.js.snap b/packages/build-info/test/snapshots/bin.js.snap new file mode 100644 index 0000000000..14f6fc415e Binary files /dev/null and b/packages/build-info/test/snapshots/bin.js.snap differ diff --git a/packages/build-info/tsconfig.json b/packages/build-info/tsconfig.json new file mode 100644 index 0000000000..a08982a671 --- /dev/null +++ b/packages/build-info/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "lib" /* Specify an output folder for all emitted files. */ + }, + "include": ["src/**/*.js", "src/**/*.ts"], + "exclude": ["tests/**"] +} diff --git a/release-please-config.json b/release-please-config.json index f822b214ff..008d1c8b69 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -2,6 +2,7 @@ "bootstrap-sha": "13ed0b0053b77a11333203c537de08b7d97f0fd4", "packages": { "packages/build": {}, + "packages/build-info": {}, "packages/cache-utils": {}, "packages/config": {}, "packages/functions-utils": {},