From aee8e94a71a6bfd30f30ef07702170d4835fae20 Mon Sep 17 00:00:00 2001 From: Egor Kuzmichev Date: Thu, 28 Dec 2023 19:41:14 +0100 Subject: [PATCH] Added sourcemaps (#654) --- .docker/backend.Dockerfile | 9 +- .docker/frontend.Dockerfile | 11 +- .github/workflows/docker-image.yml | 17 +- .github/workflows/node.js.yml | 29 --- .gitignore | 9 +- Gruntfile.js | 7 +- package-lock.json | 300 +++++++++++++++++++++++++++++ package.json | 4 +- 8 files changed, 333 insertions(+), 53 deletions(-) delete mode 100644 .github/workflows/node.js.yml diff --git a/.docker/backend.Dockerfile b/.docker/backend.Dockerfile index 8db9cb76d..71a9312bf 100644 --- a/.docker/backend.Dockerfile +++ b/.docker/backend.Dockerfile @@ -7,17 +7,10 @@ RUN apt-get update && apt-get install -y \ && rm -rf /var/lib/apt/lists/* COPY ./.docker/imagick-policy.xml /etc/ImageMagick-6/policy.xml -FROM node:${NODE_TAG} AS builder -WORKDIR /build -COPY package.json . -RUN npm install -COPY . . -RUN npm run build - FROM base WORKDIR /code ENV NODE_ENV production -COPY --from=builder /appBuild/ . +COPY ./appBuild/ . RUN npm install --production RUN mkdir /store && chown node:node /store RUN mkdir /sitemap && chown node:node /sitemap diff --git a/.docker/frontend.Dockerfile b/.docker/frontend.Dockerfile index 4cba06334..153680b3b 100644 --- a/.docker/frontend.Dockerfile +++ b/.docker/frontend.Dockerfile @@ -1,11 +1,2 @@ -ARG NODE_TAG=16.19.0 - -FROM node:${NODE_TAG} AS builder -WORKDIR /build -COPY package.json . -RUN npm install -COPY . . -RUN npm run build - FROM nginx:1.21.3 -COPY --from=builder /appBuild/public/ /usr/share/nginx/html/ +COPY ./appBuild/public/ /usr/share/nginx/html/ diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 34e7148d2..deeb85b21 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -17,9 +17,24 @@ jobs: if: github.repository_owner == 'pastvu' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: 16.19.0 + + - name: Build + run: | + npm ci + npm run build + + - name: Sentry + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + run: | + npm run sentry:sourcemaps + - name: Login to ghcr.io uses: docker/login-action@v3 with: diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml deleted file mode 100644 index b41c54374..000000000 --- a/.github/workflows/node.js.yml +++ /dev/null @@ -1,29 +0,0 @@ -# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - -name: Node.js CI - -on: - push: - branches: - - '**' - pull_request: - -jobs: - build: - - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [16.x] - - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node-version }} - - run: npm ci - - run: npm test - - run: npm run build --if-present diff --git a/.gitignore b/.gitignore index 1a0a5c84f..6112890ef 100755 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,11 @@ public/style/**/*.css # Output from babel/transpile # ###################### -babel/output*.js \ No newline at end of file +babel/output*.js + +# Sentry Config File +.sentryclirc + +# Grunt output +appBuild +app*.zip diff --git a/Gruntfile.js b/Gruntfile.js index 2801b4354..bfeae75e4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -11,8 +11,8 @@ module.exports = function (grunt) { const path = require('path'); const Utils = require('./commons/Utils'); const env = grunt.option('env') || 'production'; // Например, --env testing - const upperDir = path.normalize(path.resolve('../') + '/'); - const targetDir = path.normalize(upperDir + 'appBuild/'); + const currentDir = path.normalize(path.resolve('./') + '/'); + const targetDir = path.normalize(currentDir + 'appBuild/'); const babelConfig = require('./babel/server.config'); const hash = Utils.randomString(5); @@ -103,6 +103,7 @@ module.exports = function (grunt) { }, uglify: { options: { + sourceMap: true, output: { comments: false, }, @@ -220,7 +221,7 @@ module.exports = function (grunt) { compress: { main: { options: { - archive: upperDir + 'app<%= pkg.version %>.zip', + archive: currentDir + 'app<%= pkg.version %>.zip', mode: 'zip', level: 9, forceUTC: true, diff --git a/package-lock.json b/package-lock.json index 3e456a686..9e0e655a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -62,6 +62,7 @@ "@babel/eslint-plugin": "7.22.5", "@babel/preset-env": "7.22.7", "@babel/register": "7.22.5", + "@sentry/cli": "2.23.1", "ansi-colors": "4.1.1", "babel-jest": "29.6.1", "babel-plugin-rewire": "1.2.0", @@ -3846,6 +3847,149 @@ "node": ">=10" } }, + "node_modules/@sentry/cli": { + "version": "2.23.1", + "resolved": "https://registry.npmjs.org/@sentry/cli/-/cli-2.23.1.tgz", + "integrity": "sha512-3Tg3qzrdNWQAkuRyXniVhT+aNAwucshw0UKr/J2hxQgA72vxzcZlK4G0+Im9gIFwmzuBaD8jSGVpkzATuCeoNA==", + "dev": true, + "dependencies": { + "https-proxy-agent": "^5.0.0", + "node-fetch": "^2.6.7", + "progress": "^2.0.3", + "proxy-from-env": "^1.1.0", + "which": "^2.0.2" + }, + "bin": { + "sentry-cli": "bin/sentry-cli" + }, + "engines": { + "node": ">= 10" + }, + "optionalDependencies": { + "@sentry/cli-darwin": "2.23.1", + "@sentry/cli-linux-arm": "2.23.1", + "@sentry/cli-linux-arm64": "2.23.1", + "@sentry/cli-linux-i686": "2.23.1", + "@sentry/cli-linux-x64": "2.23.1", + "@sentry/cli-win32-i686": "2.23.1", + "@sentry/cli-win32-x64": "2.23.1" + } + }, + "node_modules/@sentry/cli-darwin": { + "version": "2.23.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-darwin/-/cli-darwin-2.23.1.tgz", + "integrity": "sha512-jSHORd9p/69BmKZRfJXFw4WFYODlw3mH1vBCi8LTWDimR9L3tthlCqYM1v5A26mUACqyNPI3s/6xvw5GOAsIhw==", + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@sentry/cli-linux-arm": { + "version": "2.23.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-linux-arm/-/cli-linux-arm-2.23.1.tgz", + "integrity": "sha512-ur7DFWwHXrLRJLa0+vL22Wkr8FC1NIQwo0mfKI+51Y9ijKsfo8R7pO5MPRCYQz0DKR12VPXkq05KPsCNq5AtZQ==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux", + "freebsd" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@sentry/cli-linux-arm64": { + "version": "2.23.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-linux-arm64/-/cli-linux-arm64-2.23.1.tgz", + "integrity": "sha512-f6e1x5zudglp8XdgN07hRhX8HVIeiY/dLAcvaV7qPNtZLd9pjsPgS2nyJlPPEC2WgG1FC439t3JmxIhRTjRA9g==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux", + "freebsd" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@sentry/cli-linux-i686": { + "version": "2.23.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-linux-i686/-/cli-linux-i686-2.23.1.tgz", + "integrity": "sha512-nm3iDgBwkwAZGkz2Oq44pdh0xdECOq/EumF8mAPA6YS2MKUWGsFQEb5/f6HLnqBULrd88RK1wrEW0eBIuIJs9Q==", + "cpu": [ + "x86", + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "linux", + "freebsd" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@sentry/cli-linux-x64": { + "version": "2.23.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-linux-x64/-/cli-linux-x64-2.23.1.tgz", + "integrity": "sha512-W8QWaxbkIOW2wpAQ1zUzA7+3bOX8lUu5bPxAfstGLobUtxZcTgydJ+58KCeyE6je/jhgzxu+fieat1bzTUrfdg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux", + "freebsd" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@sentry/cli-win32-i686": { + "version": "2.23.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-win32-i686/-/cli-win32-i686-2.23.1.tgz", + "integrity": "sha512-h8u2OUH9SvWJpRc3f0halzXut7+/BpbLc5eiViPqrcSosmngDSuy0TOGNqwsDW4hpkqm7RcTXWIUhLJcKtFFdA==", + "cpu": [ + "x86", + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@sentry/cli-win32-x64": { + "version": "2.23.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-win32-x64/-/cli-win32-x64-2.23.1.tgz", + "integrity": "sha512-DG+oyQ1bsG5A7yd3c+gt2aD6V3IsR+mutV6h1QYQ9Y8PoloGhOWmt/fnZ5CT20/HyzejykMfASnscsJGHmXp4w==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -15564,6 +15708,48 @@ "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.2.1.tgz", "integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==" }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dev": true, + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/node-fetch/node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "dev": true + }, + "node_modules/node-fetch/node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "dev": true + }, + "node_modules/node-fetch/node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dev": true, + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/node-gyp-build": { "version": "3.7.0", "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-3.7.0.tgz", @@ -16508,6 +16694,12 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "dev": true + }, "node_modules/prr": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", @@ -22274,6 +22466,75 @@ "type-fest": "^1.2.1" } }, + "@sentry/cli": { + "version": "2.23.1", + "resolved": "https://registry.npmjs.org/@sentry/cli/-/cli-2.23.1.tgz", + "integrity": "sha512-3Tg3qzrdNWQAkuRyXniVhT+aNAwucshw0UKr/J2hxQgA72vxzcZlK4G0+Im9gIFwmzuBaD8jSGVpkzATuCeoNA==", + "dev": true, + "requires": { + "@sentry/cli-darwin": "2.23.1", + "@sentry/cli-linux-arm": "2.23.1", + "@sentry/cli-linux-arm64": "2.23.1", + "@sentry/cli-linux-i686": "2.23.1", + "@sentry/cli-linux-x64": "2.23.1", + "@sentry/cli-win32-i686": "2.23.1", + "@sentry/cli-win32-x64": "2.23.1", + "https-proxy-agent": "^5.0.0", + "node-fetch": "^2.6.7", + "progress": "^2.0.3", + "proxy-from-env": "^1.1.0", + "which": "^2.0.2" + } + }, + "@sentry/cli-darwin": { + "version": "2.23.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-darwin/-/cli-darwin-2.23.1.tgz", + "integrity": "sha512-jSHORd9p/69BmKZRfJXFw4WFYODlw3mH1vBCi8LTWDimR9L3tthlCqYM1v5A26mUACqyNPI3s/6xvw5GOAsIhw==", + "dev": true, + "optional": true + }, + "@sentry/cli-linux-arm": { + "version": "2.23.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-linux-arm/-/cli-linux-arm-2.23.1.tgz", + "integrity": "sha512-ur7DFWwHXrLRJLa0+vL22Wkr8FC1NIQwo0mfKI+51Y9ijKsfo8R7pO5MPRCYQz0DKR12VPXkq05KPsCNq5AtZQ==", + "dev": true, + "optional": true + }, + "@sentry/cli-linux-arm64": { + "version": "2.23.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-linux-arm64/-/cli-linux-arm64-2.23.1.tgz", + "integrity": "sha512-f6e1x5zudglp8XdgN07hRhX8HVIeiY/dLAcvaV7qPNtZLd9pjsPgS2nyJlPPEC2WgG1FC439t3JmxIhRTjRA9g==", + "dev": true, + "optional": true + }, + "@sentry/cli-linux-i686": { + "version": "2.23.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-linux-i686/-/cli-linux-i686-2.23.1.tgz", + "integrity": "sha512-nm3iDgBwkwAZGkz2Oq44pdh0xdECOq/EumF8mAPA6YS2MKUWGsFQEb5/f6HLnqBULrd88RK1wrEW0eBIuIJs9Q==", + "dev": true, + "optional": true + }, + "@sentry/cli-linux-x64": { + "version": "2.23.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-linux-x64/-/cli-linux-x64-2.23.1.tgz", + "integrity": "sha512-W8QWaxbkIOW2wpAQ1zUzA7+3bOX8lUu5bPxAfstGLobUtxZcTgydJ+58KCeyE6je/jhgzxu+fieat1bzTUrfdg==", + "dev": true, + "optional": true + }, + "@sentry/cli-win32-i686": { + "version": "2.23.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-win32-i686/-/cli-win32-i686-2.23.1.tgz", + "integrity": "sha512-h8u2OUH9SvWJpRc3f0halzXut7+/BpbLc5eiViPqrcSosmngDSuy0TOGNqwsDW4hpkqm7RcTXWIUhLJcKtFFdA==", + "dev": true, + "optional": true + }, + "@sentry/cli-win32-x64": { + "version": "2.23.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-win32-x64/-/cli-win32-x64-2.23.1.tgz", + "integrity": "sha512-DG+oyQ1bsG5A7yd3c+gt2aD6V3IsR+mutV6h1QYQ9Y8PoloGhOWmt/fnZ5CT20/HyzejykMfASnscsJGHmXp4w==", + "dev": true, + "optional": true + }, "@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -31353,6 +31614,39 @@ "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.2.1.tgz", "integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==" }, + "node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dev": true, + "requires": { + "whatwg-url": "^5.0.0" + }, + "dependencies": { + "tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "dev": true + }, + "webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "dev": true + }, + "whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dev": true, + "requires": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + } + } + }, "node-gyp-build": { "version": "3.7.0", "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-3.7.0.tgz", @@ -32035,6 +32329,12 @@ "ipaddr.js": "1.9.1" } }, + "proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "dev": true + }, "prr": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", diff --git a/package.json b/package.json index 957ebdc34..32ca5ee74 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "migrate:create": "migrate-mongo create -f config/migrate-mongo.js -- ", "migrate:status": "migrate-mongo status -f config/migrate-mongo.js", "migrate:up": "migrate-mongo up -f config/migrate-mongo.js", - "migrate:down": "migrate-mongo down -f config/migrate-mongo.js" + "migrate:down": "migrate-mongo down -f config/migrate-mongo.js", + "sentry:sourcemaps": "sentry-cli sourcemaps inject --org pastvu --project javascript ./appBuild && sentry-cli sourcemaps upload --org pastvu --project javascript ./appBuild" }, "dependencies": { "@mapbox/geojson-area": "0.2.2", @@ -98,6 +99,7 @@ "@babel/eslint-plugin": "7.22.5", "@babel/preset-env": "7.22.7", "@babel/register": "7.22.5", + "@sentry/cli": "2.23.1", "ansi-colors": "4.1.1", "babel-jest": "29.6.1", "babel-plugin-rewire": "1.2.0",