From 4c9c8f71ad4ac2bf47d2dde5c39d94937203557e Mon Sep 17 00:00:00 2001 From: alecarn <133774929+alecarn@users.noreply.github.com> Date: Tue, 23 Jan 2024 15:58:10 -0500 Subject: [PATCH] feat(build): unify the windows and linux script (#1116) --- package-lock.json | 509 +++++++++++++++++++++++- package.json | 44 +- scripts/src/config/paths.ts | 27 ++ scripts/src/core/utils/version.utils.ts | 19 + scripts/src/release.ts | 53 +++ scripts/src/utils/color.ts | 43 ++ scripts/src/utils/file-system.utils.ts | 81 ++++ scripts/src/utils/log.ts | 49 +++ scripts/src/utils/performance.utils.ts | 5 + scripts/tsconfig.json | 20 + src/environments/version.ts | 12 + 11 files changed, 822 insertions(+), 40 deletions(-) create mode 100644 scripts/src/config/paths.ts create mode 100644 scripts/src/core/utils/version.utils.ts create mode 100644 scripts/src/release.ts create mode 100644 scripts/src/utils/color.ts create mode 100644 scripts/src/utils/file-system.utils.ts create mode 100644 scripts/src/utils/log.ts create mode 100644 scripts/src/utils/performance.utils.ts create mode 100644 scripts/tsconfig.json create mode 100644 src/environments/version.ts diff --git a/package-lock.json b/package-lock.json index 68dfd02dd..91b95c0e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,6 +44,8 @@ "@angular/cli": "^17.0.7", "@angular/compiler-cli": "^17.0.7", "@cypress/schematic": "^2.5.1", + "@swc/core": "1.3.100", + "@swc/wasm": "1.3.100", "@trivago/prettier-plugin-sort-imports": "^4.2.0", "@types/geojson": "^7946.0.10", "@types/hammerjs": "^2.0.41", @@ -58,6 +60,7 @@ "eslint": "^8.53.0", "eslint-plugin-cypress": "^2.14.0", "eslint-plugin-unused-imports": "^3.0.0", + "execa": "^8.0.1", "http-server": "^14.1.0", "jasmine-core": "~5.1.0", "jasmine-spec-reporter": "~7.0.0", @@ -67,6 +70,7 @@ "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "~2.1.0", "prettier": "^3.0.3", + "ts-node": "^10.9.2", "typescript": "~5.2.2" }, "engines": { @@ -2724,6 +2728,28 @@ "node": ">=0.1.90" } }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@ctrl/tinycolor": { "version": "3.6.1", "resolved": "https://registry.npmjs.org/@ctrl/tinycolor/-/tinycolor-3.6.1.tgz", @@ -5575,6 +5601,205 @@ "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==", "dev": true }, + "node_modules/@swc/core": { + "version": "1.3.100", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.100.tgz", + "integrity": "sha512-7dKgTyxJjlrMwFZYb1auj3Xq0D8ZBe+5oeIgfMlRU05doXZypYJe0LAk0yjj3WdbwYzpF+T1PLxwTWizI0pckw==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "@swc/counter": "^0.1.1", + "@swc/types": "^0.1.5" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/swc" + }, + "optionalDependencies": { + "@swc/core-darwin-arm64": "1.3.100", + "@swc/core-darwin-x64": "1.3.100", + "@swc/core-linux-arm64-gnu": "1.3.100", + "@swc/core-linux-arm64-musl": "1.3.100", + "@swc/core-linux-x64-gnu": "1.3.100", + "@swc/core-linux-x64-musl": "1.3.100", + "@swc/core-win32-arm64-msvc": "1.3.100", + "@swc/core-win32-ia32-msvc": "1.3.100", + "@swc/core-win32-x64-msvc": "1.3.100" + }, + "peerDependencies": { + "@swc/helpers": "^0.5.0" + }, + "peerDependenciesMeta": { + "@swc/helpers": { + "optional": true + } + } + }, + "node_modules/@swc/core-darwin-arm64": { + "version": "1.3.100", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.100.tgz", + "integrity": "sha512-XVWFsKe6ei+SsDbwmsuRkYck1SXRpO60Hioa4hoLwR8fxbA9eVp6enZtMxzVVMBi8ej5seZ4HZQeAWepbukiBw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-darwin-x64": { + "version": "1.3.100", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.100.tgz", + "integrity": "sha512-KF/MXrnH1nakm1wbt4XV8FS7kvqD9TGmVxeJ0U4bbvxXMvzeYUurzg3AJUTXYmXDhH/VXOYJE5N5RkwZZPs5iA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-gnu": { + "version": "1.3.100", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.100.tgz", + "integrity": "sha512-p8hikNnAEJrw5vHCtKiFT4hdlQxk1V7vqPmvUDgL/qe2menQDK/i12tbz7/3BEQ4UqUPnvwpmVn2d19RdEMNxw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-musl": { + "version": "1.3.100", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.100.tgz", + "integrity": "sha512-BWx/0EeY89WC4q3AaIaBSGfQxkYxIlS3mX19dwy2FWJs/O+fMvF9oLk/CyJPOZzbp+1DjGeeoGFuDYpiNO91JA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-gnu": { + "version": "1.3.100", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.100.tgz", + "integrity": "sha512-XUdGu3dxAkjsahLYnm8WijPfKebo+jHgHphDxaW0ovI6sTdmEGFDew7QzKZRlbYL2jRkUuuKuDGvD6lO5frmhA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-musl": { + "version": "1.3.100", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.100.tgz", + "integrity": "sha512-PhoXKf+f0OaNW/GCuXjJ0/KfK9EJX7z2gko+7nVnEA0p3aaPtbP6cq1Ubbl6CMoPL+Ci3gZ7nYumDqXNc3CtLQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-arm64-msvc": { + "version": "1.3.100", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.100.tgz", + "integrity": "sha512-PwLADZN6F9cXn4Jw52FeP/MCLVHm8vwouZZSOoOScDtihjY495SSjdPnlosMaRSR4wJQssGwiD/4MbpgQPqbAw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-ia32-msvc": { + "version": "1.3.100", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.100.tgz", + "integrity": "sha512-0f6nicKSLlDKlyPRl2JEmkpBV4aeDfRQg6n8mPqgL7bliZIcDahG0ej+HxgNjZfS3e0yjDxsNRa6sAqWU2Z60A==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-x64-msvc": { + "version": "1.3.100", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.100.tgz", + "integrity": "sha512-b7J0rPoMkRTa3XyUGt8PwCaIBuYWsL2DqbirrQKRESzgCvif5iNpqaM6kjIjI/5y5q1Ycv564CB51YDpiS8EtQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/counter": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.2.tgz", + "integrity": "sha512-9F4ys4C74eSTEUNndnER3VJ15oru2NumfQxS8geE+f3eB5xvfxpWyqE5XlVnxb/R14uoXi6SLbBwwiDSkv+XEw==", + "dev": true + }, + "node_modules/@swc/types": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.5.tgz", + "integrity": "sha512-myfUej5naTBWnqOCc/MdVOLVjXUXtIA+NpDrDBKJtLLg2shUjBu3cZmB/85RyitKc55+lUUyl7oRfLOvkr2hsw==", + "dev": true + }, + "node_modules/@swc/wasm": { + "version": "1.3.100", + "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.3.100.tgz", + "integrity": "sha512-rCi5+dUBta1jgrT5xGeAIY8yeJ/o/8PSFmcpsTVe2I2aSXkcHX2c1G1/tS86O65rMlwEiBmGvm1txEMG89me6Q==", + "dev": true + }, "node_modules/@trivago/prettier-plugin-sort-imports": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/@trivago/prettier-plugin-sort-imports/-/prettier-plugin-sort-imports-4.3.0.tgz", @@ -5684,6 +5909,30 @@ "node": ">=0.10.0" } }, + "node_modules/@tsconfig/node10": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", + "dev": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, "node_modules/@tufjs/canonical-json": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@tufjs/canonical-json/-/canonical-json-2.0.0.tgz", @@ -7025,6 +7274,12 @@ } ] }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "node_modules/argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -8660,6 +8915,12 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "node_modules/critters": { "version": "0.0.20", "resolved": "https://registry.npmjs.org/critters/-/critters-0.0.20.tgz", @@ -8972,6 +9233,29 @@ "node": ">= 6" } }, + "node_modules/cypress/node_modules/execa": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-4.1.0.tgz", + "integrity": "sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.0", + "get-stream": "^5.0.0", + "human-signals": "^1.1.1", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.0", + "onetime": "^5.1.0", + "signal-exit": "^3.0.2", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, "node_modules/cypress/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -8981,6 +9265,15 @@ "node": ">=8" } }, + "node_modules/cypress/node_modules/human-signals": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-1.1.1.tgz", + "integrity": "sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==", + "dev": true, + "engines": { + "node": ">=8.12.0" + } + }, "node_modules/cypress/node_modules/supports-color": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", @@ -9207,6 +9500,15 @@ "integrity": "sha512-uJaamHkagcZtHPqCIHZxnFrXlunQXgBOsZSUOWwFw31QJCAbyTBoHMW75YOTur5ZNx8pIeAKgf6GWIgaqqiLhA==", "dev": true }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/diff-sequences": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", @@ -10180,28 +10482,130 @@ } }, "node_modules/execa": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-4.1.0.tgz", - "integrity": "sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", + "integrity": "sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==", "dev": true, "dependencies": { - "cross-spawn": "^7.0.0", - "get-stream": "^5.0.0", - "human-signals": "^1.1.1", - "is-stream": "^2.0.0", + "cross-spawn": "^7.0.3", + "get-stream": "^8.0.1", + "human-signals": "^5.0.0", + "is-stream": "^3.0.0", "merge-stream": "^2.0.0", - "npm-run-path": "^4.0.0", - "onetime": "^5.1.0", - "signal-exit": "^3.0.2", - "strip-final-newline": "^2.0.0" + "npm-run-path": "^5.1.0", + "onetime": "^6.0.0", + "signal-exit": "^4.1.0", + "strip-final-newline": "^3.0.0" }, "engines": { - "node": ">=10" + "node": ">=16.17" }, "funding": { "url": "https://github.com/sindresorhus/execa?sponsor=1" } }, + "node_modules/execa/node_modules/get-stream": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", + "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==", + "dev": true, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/execa/node_modules/is-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", + "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==", + "dev": true, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/execa/node_modules/mimic-fn": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", + "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/execa/node_modules/npm-run-path": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.1.0.tgz", + "integrity": "sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q==", + "dev": true, + "dependencies": { + "path-key": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/execa/node_modules/onetime": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", + "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==", + "dev": true, + "dependencies": { + "mimic-fn": "^4.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/execa/node_modules/path-key": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", + "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/execa/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/execa/node_modules/strip-final-newline": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", + "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/executable": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/executable/-/executable-4.1.1.tgz", @@ -11749,12 +12153,12 @@ } }, "node_modules/human-signals": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-1.1.1.tgz", - "integrity": "sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", + "integrity": "sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==", "dev": true, "engines": { - "node": ">=8.12.0" + "node": ">=16.17.0" } }, "node_modules/iconv-lite": { @@ -13659,6 +14063,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, "node_modules/make-fetch-happen": { "version": "13.0.0", "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-13.0.0.tgz", @@ -18115,6 +18525,58 @@ "node": ">=12" } }, + "node_modules/ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "dev": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/ts-node/node_modules/acorn-walk": { + "version": "8.3.1", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.1.tgz", + "integrity": "sha512-TgUZgYvqZprrl7YldZNoa9OciCAyZR+Ejm9eXzKCmjsF5IKp/wgQ7Z/ZpjpGTIUPwrHQIcYeI8qDh4PsEwxMbw==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/tsconfig-paths": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-4.2.0.tgz", @@ -18472,6 +18934,12 @@ "uuid": "dist/bin/uuid" } }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, "node_modules/validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", @@ -19183,6 +19651,15 @@ "fd-slicer": "~1.1.0" } }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index 79748e373..3bb575e81 100644 --- a/package.json +++ b/package.json @@ -14,42 +14,34 @@ "ng": "ng", "start": "ng serve", "start-pwa": "ng build --configuration pwa --output-path ./dist/pwa && npm run serve.pwa", - "build": "ng build", - "build.prod": "ng build --configuration production", + "serve.prod": "http-server ./dist/igo2/ --port 4201 --no-browser", + "serve.pwa": "http-server ./dist/pwa/ --port 4201 --no-browser", + "serve.doc": "compodoc -s --port 4220", + "serve.coverage": "http-server ./coverage/ --port=4210 --no-browser", "link.start": "ng serve --configuration developpement-link", "link.build": "ng build --configuration production-link", + "build": "ng build", + "build.prod": "ng build --configuration production", + "build.github": "ng build --configuration=github --output-path ./dist/ghpages --base-href /igo2/", + "build.pwa": "ng build --configuration pwa --output-path ./dist/pwa", + "build.doc": "compodoc -p src/tsconfig.app.json", + "build.coverage": "ng test --code-coverage --watch=false", "lint": "ng lint", "lint.fix": "ng lint --fix", "format": "prettier --write ./src/**/*.{ts,js,html,scss,css,json}", "e2e": "ng run igo2:e2e:production", "e2e.local": "ng run igo2:e2e:local", - "build.github": "ng build --configuration=github --output-path ./dist/ghpages --base-href /igo2/", - "build.pwa": "ng build --configuration pwa --output-path ./dist/pwa", - "serve.prod": "http-server ./dist/igo2/ --port 4201 --no-browser", - "serve.pwa": "http-server ./dist/pwa/ --port 4201 --no-browser", + "test": "ng test --watch=false --browsers=ChromeHeadless", + "test.watch": "ng test", "doc": "compodoc -p src/tsconfig.app.json -s --port 4220", - "build.doc": "compodoc -p src/tsconfig.app.json", - "serve.doc": "compodoc -s --port 4220", "coverage": "npm run build.coverage && npm run serve.coverage", - "build.coverage": "ng test --code-coverage --watch=false", - "serve.coverage": "http-server ./coverage/ --port=4210 --no-browser", "i18n": "ng2-translate-extract --dir ./src --output ./src/assets/locale/ --format=json --clean", - "test": "ng test --watch=false --browsers=ChromeHeadless", - "test.watch": "ng test", - "test.all": "npm run test && npm run e2e", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0", "changelog-current": "conventional-changelog -p angular -r 2", - "preversion.linux": "npm run test.all", - "version.linux": "rimraf ./dist && npm run build.prod && npm run changelog && git add -A CHANGELOG.md", - "postversion.linux": "git push && git push --tags && npm run ghpages", - "preversion": "npm run test.all", - "version": "rimraf ./dist && npm run build.prod && npm run changelog && git add -A CHANGELOG.md", - "postversion": "git push && git push --tags && npm run ghpages.win", - "preghpages": "npm run build.github && echo \"include: ['_default.json', '_contexts.json', '_base.json']\" > dist/ghpages/_config.yml", - "ghpages": "VERSION=$(node -p -e \"require('./package.json').version\") && npx ngh --dir=dist/ghpages --no-silent=false --message=$VERSION", - "postghpages": "rimraf ./dist/ghpages", - "preghpages.win": "npm run build.github && echo include: ['_default.json', '_contexts.json', '_base.json'] > dist/ghpages/_config.yml", - "ghpages.win": "npx ngh --dir=dist/ghpages --no-silent=false --message=%npm_package_version%" + "preversion": "npm run test && npm run e2e", + "version": "npm run release", + "postversion": "npm run changelog && git add -u && git push && git push --tags", + "release": "ts-node scripts/src/release.ts" }, "dependencies": { "@angular/animations": "^17.0.7", @@ -95,12 +87,15 @@ "@types/node": "^20.6.2", "@typescript-eslint/eslint-plugin": "^6.10.0", "@typescript-eslint/parser": "^6.10.0", + "@swc/core": "1.3.100", + "@swc/wasm": "1.3.100", "angular-cli-ghpages": "^1.0.3", "conventional-changelog-cli": "^4.1.0", "cypress": "^13.2.0", "eslint": "^8.53.0", "eslint-plugin-cypress": "^2.14.0", "eslint-plugin-unused-imports": "^3.0.0", + "execa": "^8.0.1", "http-server": "^14.1.0", "jasmine-core": "~5.1.0", "jasmine-spec-reporter": "~7.0.0", @@ -110,6 +105,7 @@ "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "~2.1.0", "prettier": "^3.0.3", + "ts-node": "^10.9.2", "typescript": "~5.2.2" } } diff --git a/scripts/src/config/paths.ts b/scripts/src/config/paths.ts new file mode 100644 index 000000000..f43bf091c --- /dev/null +++ b/scripts/src/config/paths.ts @@ -0,0 +1,27 @@ +import { resolve } from 'path'; + +type FolderCaterogy = 'dist' | 'root' | 'src' | 'nodeModules'; + +type IPaths = Record & { [index: string]: string }; + +const ROOT_LEVEL = '../../../'; +const ROOT = resolve(__dirname, ROOT_LEVEL); + +export const resolveRoot = (relativePath: string): string => { + return resolve(ROOT, relativePath); +}; + +export const PATHS: IPaths = { + dist: resolveRoot('dist'), + nodeModules: resolveRoot('node_modules'), + src: resolveRoot('src'), + root: ROOT +}; + +export const resolvePackage = (name: string, ...paths: string[]): string => { + return resolve(PATHS.packages, name, ...paths); +}; + +export const resolveDist = (name: string): string => { + return resolve(PATHS.dist, name); +}; diff --git a/scripts/src/core/utils/version.utils.ts b/scripts/src/core/utils/version.utils.ts new file mode 100644 index 000000000..af7aae631 --- /dev/null +++ b/scripts/src/core/utils/version.utils.ts @@ -0,0 +1,19 @@ +import { readFileSync } from 'fs'; +import { writeFile } from 'fs/promises'; + +import { resolveRoot } from '../../config/paths'; +import * as log from '../../utils/log'; + +export async function setVersionFile(version: string) { + const filePath = resolveRoot('src/environments/version.ts'); + + let body = readFileSync(filePath, 'utf-8'); + body = body.replace(/app: '[A-Za-z0-9\.\-]+'/g, `app: '${version}'`); + body = body.replace( + /releaseDateApp: [0-9]+/g, + `releaseDateApp: ${Date.now()}` + ); + + await writeFile(filePath, body, { flag: 'w' }); + log.success('The version file has been written'); +} diff --git a/scripts/src/release.ts b/scripts/src/release.ts new file mode 100644 index 000000000..88686948c --- /dev/null +++ b/scripts/src/release.ts @@ -0,0 +1,53 @@ +import { setVersionFile } from './core/utils/version.utils'; +import { writeFile2 } from './utils/file-system.utils'; +import * as log from './utils/log'; +import { getDuration } from './utils/performance.utils'; + +const baseCmdName = 'Application release'; + +log.startMsg(baseCmdName); +(async () => { + const startTime = performance.now(); + try { + const [_nodePath, _scriptPath, argVersion, type] = process.argv; + const version = argVersion ?? process.env.npm_new_version; + + if (!version) { + throw new Error('No version detected'); + } + + log.info('Create the version.ts file'); + await setVersionFile(version); + + await deployGithubPage(version); + + log.success(`Release version ${version}`); + + const duration = getDuration(startTime); + log.info(`${baseCmdName} excuted in ${duration}.`); + } catch (err: any) { + log.error(`The release failed with: ${err?.message}`); + process.exit(1); + } +})(); + +async function deployGithubPage(version: string): Promise { + const startTime = performance.now(); + const { $ } = await import('execa'); + const $$ = $({ stdio: 'inherit' }); + + log.info('Build the app for Github'); + await $$`npm run build.github`; + await writeFile2( + 'dist/ghpages/_config.yml', + "include: ['_default.json', '_contexts.json', '_base.json']", + false + ); + + await $$`npx ngh --dir=dist/ghpages --no-silent=false --message=${version}`; + + const duration = getDuration(startTime); + log.success( + `Deploy the app v${version} on Github Page, excuted in ${duration}.` + ); +} diff --git a/scripts/src/utils/color.ts b/scripts/src/utils/color.ts new file mode 100644 index 000000000..449ca3859 --- /dev/null +++ b/scripts/src/utils/color.ts @@ -0,0 +1,43 @@ +/** + * Source: https://github.com/ng-packagr/ng-packagr/blob/ee4fd635a626e1ee2266b05cb572002bb09b4849/src/lib/utils/color.ts + */ +import * as ansiColors from 'ansi-colors'; +import { WriteStream } from 'tty'; + +type AnsiColors = typeof ansiColors; + +function supportColor(): boolean { + if (process.env.FORCE_COLOR !== undefined) { + // 2 colors: FORCE_COLOR = 0 (Disables colors), depth 1 + // 16 colors: FORCE_COLOR = 1, depth 4 + // 256 colors: FORCE_COLOR = 2, depth 8 + // 16,777,216 colors: FORCE_COLOR = 3, depth 16 + // See: https://nodejs.org/dist/latest-v12.x/docs/api/tty.html#tty_writestream_getcolordepth_env + // and https://github.com/nodejs/node/blob/b9f36062d7b5c5039498e98d2f2c180dca2a7065/lib/internal/tty.js#L106; + switch (process.env.FORCE_COLOR) { + case '': + case 'true': + case '1': + case '2': + case '3': + return true; + default: + return false; + } + } + + if (process.stdout instanceof WriteStream) { + return process.stdout.getColorDepth() > 1; + } + + return false; +} + +// Create a separate instance to prevent unintended global changes to the color configuration +// Create function is not defined in the typings. See: https://github.com/doowb/ansi-colors/pull/44 +const colors = ( + ansiColors as AnsiColors & { create: () => AnsiColors } +).create(); +colors.enabled = supportColor(); + +export { colors }; diff --git a/scripts/src/utils/file-system.utils.ts b/scripts/src/utils/file-system.utils.ts new file mode 100644 index 000000000..466b82038 --- /dev/null +++ b/scripts/src/utils/file-system.utils.ts @@ -0,0 +1,81 @@ +import { existsSync, readFileSync } from 'fs'; +import { + copyFile as fsCopyFile, + mkdir, + readFile, + writeFile +} from 'fs/promises'; +import { normalize, sep } from 'path'; + +export const BUFFER_ENCODING: BufferEncoding = 'utf-8'; + +export async function readFileContent(path: string): Promise { + const body = await readFile(path, BUFFER_ENCODING); + return JSON.parse(body) as T; +} + +export function readFileContentSync(path: string): T { + const body = readFileSync(path, BUFFER_ENCODING); + return JSON.parse(body) as T; +} + +export async function createFile( + fileName: string, + dest: string, + body: string +): Promise { + const path = `${dest}/${fileName}`; + try { + await writeFile(path, body, BUFFER_ENCODING); + } catch (err: any) { + if (err.code === 'ENOENT') { + await createFolderRecursively(dest); + await writeFile(path, body, BUFFER_ENCODING); + } + } +} + +export async function copyFile(src: string, dest: string): Promise { + try { + await fsCopyFile(src, dest); + } catch (err: any) { + if (err.code === 'ENOENT') { + await createPreviousFolder(dest); + await fsCopyFile(src, dest); + } + } +} + +export async function createFolderRecursively(dest: string): Promise { + try { + await mkdir(dest); + } catch (err: any) { + if (err.code === 'ENOENT') { + await createPreviousFolder(dest); + await createFolderRecursively(dest); + } + } +} + +async function createPreviousFolder(dest: string): Promise { + const folders = normalize(dest).split(sep); + folders.pop(); + await createFolderRecursively(folders.join(sep)); +} + +export function pathExist(path: string): boolean { + return existsSync(path); +} + +export function writeFile2( + path: string, + body: object | string, + endLineBreak = true +): Promise { + let formattedBody = + typeof body === 'string' ? body : JSON.stringify(body, null, 2); + if (endLineBreak) { + formattedBody = formattedBody.concat('\n'); + } + return writeFile(path, formattedBody, BUFFER_ENCODING); +} diff --git a/scripts/src/utils/log.ts b/scripts/src/utils/log.ts new file mode 100644 index 000000000..34e666acb --- /dev/null +++ b/scripts/src/utils/log.ts @@ -0,0 +1,49 @@ +/** + * Source: https://github.com/ng-packagr/ng-packagr/blob/ee4fd635a626e1ee2266b05cb572002bb09b4849/src/lib/utils/log.ts + */ +/* eslint-disable no-console */ +import { colors } from './color'; + +export const error = (err: string | Error) => { + if (err instanceof Error) { + console.error(colors.red('ERROR: ' + err.message)); + + if (process.env.DEBUG) { + console.error(colors.red(err.stack ?? '') + '\n'); + } + } else { + console.error(colors.red(err)); + } +}; + +export const warn = (msg: string) => { + console.warn(colors.yellow('WARNING: ' + msg)); +}; + +export const success = (msg: string) => { + console.log(colors.green(msg)); +}; + +export const info = (msg: string) => { + console.log(colors.blue(msg)); +}; + +export const msg = (msg: string) => { + console.log(colors.white(msg)); +}; + +export const debug = (msg: string) => { + if (process.env.DEBUG) { + console.log(colors.inverse.cyan(`[debug] ${msg}`)); + } +}; + +export const startMsg = (message: string) => { + msg( + '\n------------------------------------------------------------------------------' + ); + msg(message); + msg( + '------------------------------------------------------------------------------' + ); +}; diff --git a/scripts/src/utils/performance.utils.ts b/scripts/src/utils/performance.utils.ts new file mode 100644 index 000000000..934218bc2 --- /dev/null +++ b/scripts/src/utils/performance.utils.ts @@ -0,0 +1,5 @@ +/** Duration in ms */ +export function getDuration(startTime: number): string { + const duration = Math.round(performance.now() - startTime); + return `${duration}ms`; +} diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json new file mode 100644 index 000000000..93d413436 --- /dev/null +++ b/scripts/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "lib": ["es2022"], + "module": "NodeNext", + "moduleResolution": "NodeNext", + "target": "es2022", + "rootDir": "./", + "isolatedModules": true, + "noImplicitAny": true, + "sourceMap": true, + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true + }, + "exclude": ["node_modules"], + "ts-node": { + "swc": true + } +} diff --git a/src/environments/version.ts b/src/environments/version.ts new file mode 100644 index 000000000..02ae77888 --- /dev/null +++ b/src/environments/version.ts @@ -0,0 +1,12 @@ +/** + * THIS FILE IS AUTOGENERATED PARTIALLY + * DO NOT EDIT THE APP VERSION OR RELEASE DATE + * IF YOU CHANGE ANY KEY NAME BE SURE TO REFLECT THIS CHANGE IN OUR AUTOMATION SCRIPT + */ +import { Version, version as libVersion } from '@igo2/core'; + +export const version: Version = { + ...libVersion, + app: '16.1.0', + releaseDateApp: 1702904471895 +};