diff --git a/example-site/package.json b/example-site/package.json index 1d39084..7e7254d 100644 --- a/example-site/package.json +++ b/example-site/package.json @@ -1,5 +1,6 @@ { "name": "test-project", + "version": "1.0.0", "prettier": "./../configs/prettier", "eslintConfig": { "extends": "./../configs/eslint" diff --git a/package-lock.json b/package-lock.json index 58cec37..6456039 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@bigbite/build-tools", - "version": "1.3.2", + "version": "1.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@bigbite/build-tools", - "version": "1.3.2", + "version": "1.4.0", "license": "MIT", "dependencies": { "@babel/core": "^7.14.8", @@ -55,6 +55,7 @@ "rework-visit": "^1.0.0", "sass": "^1.55.0", "sass-loader": "^12.1.0", + "semver": "^7.6.2", "stylelint": "15.0.0", "stylelint-scss": "^5.3.2", "stylelint-webpack-plugin": "^4.1.1", @@ -148,6 +149,14 @@ "url": "https://opencollective.com/babel" } }, + "node_modules/@babel/core/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/@babel/eslint-parser": { "version": "7.23.3", "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.23.3.tgz", @@ -165,6 +174,14 @@ "eslint": "^7.5.0 || ^8.0.0" } }, + "node_modules/@babel/eslint-parser/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/@babel/eslint-plugin": { "version": "7.23.5", "resolved": "https://registry.npmjs.org/@babel/eslint-plugin/-/eslint-plugin-7.23.5.tgz", @@ -231,6 +248,14 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/helper-compilation-targets/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/@babel/helper-create-class-features-plugin": { "version": "7.23.7", "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.23.7.tgz", @@ -253,6 +278,14 @@ "@babel/core": "^7.0.0" } }, + "node_modules/@babel/helper-create-class-features-plugin/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/@babel/helper-create-regexp-features-plugin": { "version": "7.22.15", "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.22.15.tgz", @@ -269,6 +302,14 @@ "@babel/core": "^7.0.0" } }, + "node_modules/@babel/helper-create-regexp-features-plugin/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/@babel/helper-define-polyfill-provider": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.4.4.tgz", @@ -1764,6 +1805,14 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/preset-env/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/@babel/preset-modules": { "version": "0.1.6-no-external-plugins", "resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.6-no-external-plugins.tgz", @@ -3393,36 +3442,6 @@ } } }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, "node_modules/@typescript-eslint/parser": { "version": "6.18.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.18.1.tgz", @@ -3532,36 +3551,6 @@ } } }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, "node_modules/@typescript-eslint/utils": { "version": "6.18.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.18.1.tgz", @@ -3586,36 +3575,6 @@ "eslint": "^7.0.0 || ^8.0.0" } }, - "node_modules/@typescript-eslint/utils/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@typescript-eslint/utils/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@typescript-eslint/utils/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, "node_modules/@typescript-eslint/visitor-keys": { "version": "6.18.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.18.1.tgz", @@ -4405,6 +4364,15 @@ "node": ">=8" } }, + "node_modules/babel-plugin-istanbul/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/babel-plugin-jest-hoist": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.6.3.tgz", @@ -4433,6 +4401,14 @@ "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" } }, + "node_modules/babel-plugin-polyfill-corejs2/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/babel-plugin-polyfill-corejs3": { "version": "0.8.7", "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.8.7.tgz", @@ -5375,36 +5351,6 @@ "webpack": "^5.0.0" } }, - "node_modules/css-loader/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/css-loader/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/css-loader/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, "node_modules/css-select": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/css-select/-/css-select-4.3.0.tgz", @@ -6379,6 +6325,14 @@ "node": "*" } }, + "node_modules/eslint-plugin-import/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/eslint-plugin-jsdoc": { "version": "39.9.1", "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-39.9.1.tgz", @@ -6410,36 +6364,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/eslint-plugin-jsdoc/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/eslint-plugin-jsdoc/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/eslint-plugin-jsdoc/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, "node_modules/eslint-plugin-jsx-a11y": { "version": "6.8.0", "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.8.0.tgz", @@ -6596,6 +6520,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/eslint-plugin-react/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/eslint-rule-composer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz", @@ -6840,17 +6772,6 @@ "node": ">= 4" } }, - "node_modules/eslint/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/eslint/node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -6862,20 +6783,6 @@ "node": "*" } }, - "node_modules/eslint/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/eslint/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -6898,11 +6805,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/eslint/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, "node_modules/espree": { "version": "7.3.1", "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz", @@ -8701,39 +8603,6 @@ "node": ">=10" } }, - "node_modules/istanbul-lib-instrument/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/istanbul-lib-instrument/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/istanbul-lib-instrument/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - }, "node_modules/istanbul-lib-report": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", @@ -8757,18 +8626,6 @@ "node": ">=8" } }, - "node_modules/istanbul-lib-report/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/istanbul-lib-report/node_modules/make-dir": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", @@ -8784,21 +8641,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/istanbul-lib-report/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/istanbul-lib-report/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -8811,12 +8653,6 @@ "node": ">=8" } }, - "node_modules/istanbul-lib-report/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - }, "node_modules/istanbul-lib-source-maps": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", @@ -10143,33 +9979,6 @@ "node": ">=8" } }, - "node_modules/jest-snapshot/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/jest-snapshot/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/jest-snapshot/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -10182,12 +9991,6 @@ "node": ">=8" } }, - "node_modules/jest-snapshot/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - }, "node_modules/jest-util": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", @@ -10856,6 +10659,14 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/make-dir/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/makeerror": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", @@ -11315,36 +11126,6 @@ "node": ">=10" } }, - "node_modules/normalize-package-data/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/normalize-package-data/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/normalize-package-data/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -12075,36 +11856,6 @@ "webpack": "^5.0.0" } }, - "node_modules/postcss-loader/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/postcss-loader/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/postcss-loader/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, "node_modules/postcss-media-query-parser": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/postcss-media-query-parser/-/postcss-media-query-parser-0.2.3.tgz", @@ -13571,11 +13322,14 @@ } }, "node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "version": "7.6.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", + "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", "bin": { "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" } }, "node_modules/serialize-javascript": { @@ -15360,31 +15114,6 @@ "node": ">=8" } }, - "node_modules/ts-loader/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/ts-loader/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/ts-loader/node_modules/source-map": { "version": "0.7.4", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", @@ -15404,11 +15133,6 @@ "node": ">=8" } }, - "node_modules/ts-loader/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, "node_modules/tsconfig-paths": { "version": "3.15.0", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", diff --git a/package.json b/package.json index 2bff85f..8ed2a37 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bigbite/build-tools", - "version": "1.3.2", + "version": "1.4.0", "description": "Provides configuration for the Big Bite Build Tools.", "author": "Paul Taylor (https://github.com/ampersarnie)", "engines": { @@ -84,6 +84,7 @@ "rework-visit": "^1.0.0", "sass": "^1.55.0", "sass-loader": "^12.1.0", + "semver": "^7.6.2", "stylelint": "15.0.0", "stylelint-scss": "^5.3.2", "stylelint-webpack-plugin": "^4.1.1", diff --git a/src/commands/version.js b/src/commands/version.js new file mode 100644 index 0000000..549319c --- /dev/null +++ b/src/commands/version.js @@ -0,0 +1,90 @@ +const dirsExist = require('../utils/dirs-exist'); +const { terminal } = require('terminal-kit'); +const path = require('path'); +const { + incrementPackageJsonVersion, + incrementVersionNumber, +} = require('./../utils/increment-version'); + +const { findAllProjectPaths, validateProject } = require('./../utils/projectpaths'); +const { getPackage } = require('./../utils/get-package'); + +exports.command = 'version [type] [projects]'; +exports.desc = 'Run an npm version bump process.'; +exports.builder = (yargs) => { + yargs.option('type', { + describe: 'type of version to bump.', + default: '', + type: 'string', + }); + + yargs.positional('projects', { + describe: 'Comma separated list of projects to compile.', + type: 'string', + default: '', + }); +}; +exports.handler = async ({ type = '', projects = '' }) => { + const projectsList = projects.split(',').filter((item) => item.length > 0); + const hasTargetDirs = dirsExist(targetDirs); + const isAllProjects = hasTargetDirs && !projects; + const incrementType = type.toLowerCase(); + + let packages = []; + + const updateVersionsInPackages = (packages, incrementType) => { + packages.forEach((pkg) => { + incrementPackageJsonVersion( + pkg?.package.absolutePath, + pkg?.package_lock.absolutePath, + incrementType, + ); + const fileNames = Object.keys(pkg); + Object.values(pkg).forEach((file, key) => { + if (fileNames[key] !== 'package' && fileNames[key] !== 'package_lock') { + incrementVersionNumber(file.absolutePath, incrementType); + } + }); + 8; + }); + }; + + try { + if (projectsList.length === 0 && !isAllProjects) { + // Increment projects in current directory + terminal('\x1b[1mIncrementing Projects In \x1b[4mDirectory\x1b[0m...\n'); + packages.push(getPackage(path.resolve('./'), true)); + } else if (isAllProjects) { + // Increment all projects i.e from wp-content folder + terminal('\x1b[1mIncrementing \x1b[4mAll Projects\x1b[0m...\n'); + packages = findAllProjectPaths(targetDirs, false, true).map((path) => getPackage(path, true)); + } else { + // Increment specified projects + terminal('\x1b[1mIncrementing \x1b[4mList of Projects\x1b[0m...\n'); + + packages = findAllProjectPaths(targetDirs, projectsList).map((path) => + getPackage(path, true), + ); + + const packageNames = packages.map((pkg) => pkg.name); + projectsList.map((projectName) => { + if (!packageNames.includes(projectName)) { + terminal.red(`Error: Project ${projectName} does not exist.\n`); + } + packageNames.includes(projectName); + }); + } + } catch (e) { + terminal.red(e); + process.exit(1); + } + + const validProjects = packages.filter((pkg) => validateProject(pkg, true)); + + if (validProjects.length === 0) { + terminal.red(`Error: No projects found\n`); + process.exit(1); + } + + updateVersionsInPackages(validProjects, incrementType); +}; diff --git a/src/utils/get-package.js b/src/utils/get-package.js index 4e5fd97..fa66ded 100644 --- a/src/utils/get-package.js +++ b/src/utils/get-package.js @@ -1,4 +1,87 @@ const fs = require('fs'); +const path = require('path'); +const versionPattern = /Version:\s*([\d]+\.[\d]+\.[\d]+(?:-[a-z]+\.[\d]+)?)/i; + +/** + * Retrieves the names of all files in the specified directory. + * + * This function reads the contents of the given directory, filters out the directories, + * and returns an array containing the names of all the files in the directory. + * + * @param {string} dirPath - The path to the directory to read. + * @returns {array} An array of file names in the specified directory. + **/ + +const getFilesInDirectory = (dirPath) => { + return fs.readdirSync(dirPath).filter((file) => fs.statSync(path.join(dirPath, file)).isFile()); +}; + +/** + * Function to check if a file has a specified extension. + * @param {string} filePath - The path to the file. + * @param {string} extension - The extension to check for (e.g., '.json'). + * @returns {boolean} - Returns true if the file has the specified extension, otherwise false. + */ +const hasExtension = (filePath, extension) => { + return path.extname(filePath).toLowerCase() === extension.toLowerCase(); +}; + +/** + * Converts a filename into a variable-friendly name by replacing non-alphanumeric characters with underscores + * and removing the extension. + * + * @param {string} filename - The filename to convert. + * @returns {string} - The converted variable-friendly name. + */ +const convertToVariableFriendlyName = (filename) => { + // Remove the extension + const baseName = filename.split('.').slice(0, -1).join('.'); + // Replace any non-alphanumeric characters with underscores + return baseName.replace(/[^a-zA-Z0-9]/g, '_'); +}; + +/** + * Checks if the specified file contains a version string matching a given pattern. + * + * This function reads the content of the file at the given path and tests it against + * a predefined version pattern. + * + * @param {string} filePath - The path to the file to check for a version string. + * @returns {boolean} True if the file contains a version string matching the pattern, false otherwise. + */ +const containsVersion = (filePath) => { + try { + const content = fs.readFileSync(filePath, 'utf8'); + return versionPattern.test(content); + } catch (err) { + console.error(`Error reading file ${filePath}: ${err.message}`); + return false; + } +}; + +/** + * Finds and returns an array of target files within the specified base directory. + * + * This function searches for files in the given base directory that either contain a version string, + * or are named 'package.json' or 'package-lock.json'. It then returns an array of these file names, + * ensuring there are no duplicate entries. + * + * @param {string} baseDir - The base directory to search for target files. + * @returns {array} An array of target file names found in the base directory, with duplicates removed. + */ +const findTargetFiles = (baseDir) => { + const files = getFilesInDirectory(baseDir); + const targetFiles = files + .filter((fileName) => { + const filePath = path.join(baseDir, fileName); + return ( + containsVersion(filePath) || fileName === 'package.json' || fileName === 'package-lock.json' + ); + }) + .map((fileName) => fileName); + // filter out duplicates + return [...new Set(targetFiles)]; +}; /** * Retrieves the package.json file from a given directory and compiles it @@ -8,34 +91,61 @@ const fs = require('fs'); * @param {boolean} throwError Whether to throw errors when package.json does not exist. * @returns */ -const getPackage = (path) => { - const absolutePath = `${path}/package.json`; +const getPackage = (path, version = false) => { + let files = []; + let packageValues = {}; - if (packageList[absolutePath]) { - return packageList[absolutePath]; + if (!version) { + files = ['package.json']; + } else { + files = findTargetFiles(path); } - if (!fs.existsSync(absolutePath)) { - return false; - } + files.forEach((file) => { + const absolutePath = `${path}/${file}`; + + if (packageList[absolutePath]) { + return packageList[absolutePath]; + } + + if (!fs.existsSync(absolutePath)) { + return false; + } - const json = JSON.parse(fs.readFileSync(absolutePath)); - const packageObject = json === Object(json) ? json : {}; - const packageNames = packageObject?.name?.split('/'); - const name = packageNames?.[packageNames.length - 1] || ''; + let fileData = { + path, + absolutePath, + }; - const regexDirs = targetDirs.join('|'); - const packagePath = absolutePath.match(`((${regexDirs})\/)?([^\/]+)\/package.json$`); + if (hasExtension(absolutePath, '.json')) { + const json = JSON.parse(fs.readFileSync(absolutePath)); + const packageObject = json === Object(json) ? json : {}; + const packageNames = packageObject?.name?.split('/'); + const name = packageNames?.[packageNames.length - 1] || ''; - const packageValues = { - path, - absolutePath, - relativePath: packagePath[0], - name, - json, - }; + const regexDirs = targetDirs.join('|'); + const packagePath = absolutePath.match(`((${regexDirs})\/)?([^\/]+)\/${file}$`); - packageList[absolutePath] = packageValues; + fileData = { + ...fileData, + relativePath: packagePath ? packagePath[0] : '', + name, + json, + }; + } + if (version) { + packageValues[convertToVariableFriendlyName(file)] = fileData; + } else { + packageValues = fileData; + } + + packageList[absolutePath] = fileData; + }); + + // if packageValues is empty return false instead of empty object. + if (Object.keys(packageValues).length === 0) { + return false; + } return packageValues; }; diff --git a/src/utils/increment-version.js b/src/utils/increment-version.js new file mode 100644 index 0000000..38718e8 --- /dev/null +++ b/src/utils/increment-version.js @@ -0,0 +1,140 @@ +const fs = require('fs'); +const { terminal } = require('terminal-kit'); +const semver = require('semver'); +const path = require('path'); + +/** + * Function to normalize a version number to the format MAJOR.MINOR.PATCH. + * @param {string} version - The version number to normalize. + * @returns {string} - The normalized version number. + */ +function normalizeVersion(version) { + const parts = version.split('.'); + + while (parts.length < 3) { + parts.push('0'); + } + + return parts.join('.'); +} + +/** + * Function to increment the current version. + * @param {string} version - current version + * @param {string} type - type of version to increase. + * @returns {string} version - updated version + */ +function incrementVersion(version, type) { + let currentVersion = version; + let normalisedVersion = version.split('.'); + if (normalisedVersion.length < 3) { + currentVersion = normalizeVersion(version); + } + + if (!semver.valid(currentVersion)) { + throw new Error(`Invalid version: ${currentVersion}`); + } + + const [baseType, prerelease] = type.split(':'); + + if (prerelease === 'beta' || prerelease === 'rc') { + const releaseEnum = Object.freeze({ + major: 'premajor', + minor: 'preminor', + patch: 'prepatch', + prerelease: 'prerelease', + }); + const releaseType = releaseEnum[baseType] ? releaseEnum[baseType] : false; + return semver.inc(currentVersion, releaseType, prerelease, 1); + } else { + return semver.inc(currentVersion, baseType); + } +} + +/** + * Function to get the version and then save it back to the file. + * @param {string} filePath - file path. + * @param {string} releaseType - type of version to increment. + */ +const incrementVersionNumber = (filePath, releaseType) => { + if (fs.existsSync(filePath)) { + try { + let content = fs.readFileSync(filePath, 'utf-8'); + const versionRegex = /Version:\s*([\d]+\.[\d]+\.[\d]+(?:-[a-z]+\.[\d]+)?)/i; + const match = content.match(versionRegex); + if (match) { + const oldVersion = match[1]; + let newVersion; + + if (releaseType === '') { + newVersion = determineNextVersion(oldVersion); + } else { + newVersion = incrementVersion(oldVersion, releaseType); + } + + content = content.replace(versionRegex, `Version: ${newVersion}`); + fs.writeFileSync(filePath, content, 'utf-8'); + terminal(`#${filePath}: \x1b[31m${oldVersion} -> \x1b[32m${newVersion}\x1b[0m\n`); + } + } catch (err) { + console.error(`\x1b[31mError incrementing version in ${filePath}: ${err.message}\x1b[0m`); + } + } +}; + +/** + * Function to decide the next version if no version is provided. + * @param {string} version - Current version. + */ +const determineNextVersion = (version) => { + if (!semver.valid(version)) { + throw new Error(`\x1b[31mInvalid version: ${version}\x1b[0m`); + } + if (semver.prerelease(version)) { + return semver.inc(version, 'prerelease'); + } + return semver.inc(version, 'patch'); // Automatically bump to the next patch version. +}; + +/** + * Function to update the version in the package.json files. + * @param {string} filePath - file path. + * @param {string} releaseType - type of version to increment. + */ +const incrementPackageJsonVersion = (packageJsonPath, packageLockPath, releaseType) => { + try { + if (fs.existsSync(packageJsonPath)) { + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); + let path = packageJsonPath; + const oldVersion = packageJson.version; + if (!packageJson.version) { + return console.error(`\x1b[31mNo version set in ${path} unable to increment\x1b[0m`); + } + let newVersion; + if (releaseType === '') { + newVersion = determineNextVersion(oldVersion); + } else { + newVersion = incrementVersion(oldVersion, releaseType); + } + packageJson.version = newVersion; + fs.writeFileSync(path, JSON.stringify(packageJson, null, 2), 'utf8'); + terminal(`#${path}: \x1b[31m${oldVersion} -> \x1b[32m${newVersion}\x1b[0m\n`); + if (!fs.existsSync(packageLockPath)) { + return; + } + path = packageLockPath; + const packageJsonLock = JSON.parse(fs.readFileSync(path, 'utf8')); + const lockoldVersion = packageJsonLock.version; + packageJsonLock.version = packageJson.version; + fs.writeFileSync(path, JSON.stringify(packageJsonLock, null, 2), 'utf8'); + terminal(`#${path}: \x1b[31m${lockoldVersion} -> \x1b[32m${newVersion}\x1b[0m\n`); + } + } catch (err) { + console.error(`\x1b[31mError updating version in file ${path}: ${err.message}\x1b[0m`); + } +}; + +module.exports = { + incrementPackageJsonVersion, + incrementVersionNumber, +}; diff --git a/src/utils/projectpaths.js b/src/utils/projectpaths.js index a74bb9f..e59edf1 100644 --- a/src/utils/projectpaths.js +++ b/src/utils/projectpaths.js @@ -22,7 +22,7 @@ const directoryExists = (directory) => { * @returns {string[]} the complete paths to all project directories * @throws if no projects have been discovered */ -const findAllProjectPaths = (directories, projectsList) => { +const findAllProjectPaths = (directories, projectsList, version = false) => { let projects = []; directories.filter(directoryExists).forEach((directory) => { @@ -40,6 +40,11 @@ const findAllProjectPaths = (directories, projectsList) => { ); }); + // Check the current directory separately + if (fs.existsSync('./package.json') && !projectsList && version) { + projects.push(path.resolve(process.cwd(), '.')); + } + if (projects.length <= 0) { throw new Error('Cannot find any projects.\n'); } @@ -49,13 +54,26 @@ const findAllProjectPaths = (directories, projectsList) => { /** * Confirms the given package.json is a valid build-tools project - * by looking for src/entrypoints + * by looking for src/entrypoints and checking the root directory contains a package.json. */ -const validateProject = (pkg) => { - if (fs.existsSync(`${pkg.path}/src/entrypoints`)) { - return true; +const validateProject = (pkg, version = false) => { + if (version) { + const files = Object.values(pkg); + return files.some((file) => { + if ( + fs.existsSync(`${file.path}/src/entrypoints`) || + fs.existsSync(`${file.path}/package.json`) + ) { + return true; + } + return false; + }); + } else { + if (fs.existsSync(`${pkg.path}/src/entrypoints`)) { + return true; + } + return false; } - return false; }; module.exports = {