From 76211dc5a296a4f58efdeab62f4ad4788c0d2db6 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Mon, 4 Apr 2022 14:36:42 -0700 Subject: [PATCH] Updated start scripts. --- Dockerfile | 1 + package.json | 13 ++++++------- scripts/telemetry.js | 28 ++++++++++++---------------- yarn.lock | 12 ------------ 4 files changed, 19 insertions(+), 35 deletions(-) diff --git a/Dockerfile b/Dockerfile index 16dd9872..703e4886 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,6 +38,7 @@ COPY --from=build /build/node_modules/.prisma/ ./node_modules/.prisma/ COPY --from=build /build/yarn.lock /build/package.json ./ COPY --from=build /build/.next ./.next COPY --from=build /build/public ./public +COPY --from=build /build/scripts ./scripts USER node diff --git a/package.json b/package.json index 76e3fdc9..07487c8c 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "scripts": { "dev": "next dev", "build": "npm-run-all build-tracker build-geo build-db build-app", - "start": "npm-run-all init start-app", + "start": "npm-run-all pre-start start-app", "start-app": "next start", "start-env": "node -r dotenv/config scripts/start-env.js", "build-app": "next build", @@ -39,7 +39,7 @@ "lint": "next lint --quiet", "prepare": "husky install", "postbuild": "node scripts/postbuild.js", - "init": "node scripts/prestart.js" + "pre-start": "node scripts/prestart.js" }, "lint-staged": { "**/*.js": [ @@ -65,12 +65,16 @@ "cors": "^2.8.5", "date-fns": "^2.23.0", "date-fns-tz": "^1.1.4", + "del": "^6.0.0", "detect-browser": "^5.2.0", "dotenv": "^10.0.0", + "dotenv-cli": "^4.0.0", "formik": "^2.2.9", "fs-extra": "^10.0.1", "immer": "^9.0.12", "ipaddr.js": "^2.0.1", + "is-ci": "^3.0.1", + "is-docker": "^3.0.0", "is-localhost-ip": "^1.4.0", "isbot": "^3.4.5", "jose": "2.0.5", @@ -98,18 +102,13 @@ "@formatjs/cli": "^4.2.29", "@rollup/plugin-buble": "^0.21.3", "@svgr/webpack": "^6.2.1", - "async-retry": "^1.3.3", "cross-env": "^7.0.3", - "del": "^6.0.0", - "dotenv-cli": "^4.0.0", "eslint": "^7.32.0", "eslint-config-next": "^12.0.1", "eslint-config-prettier": "^8.5.0", "eslint-plugin-prettier": "^4.0.0", "extract-react-intl-messages": "^4.1.1", "husky": "^7.0.0", - "is-ci": "^3.0.1", - "is-docker": "^3.0.0", "lint-staged": "^11.0.0", "npm-run-all": "^4.1.5", "postcss": "^8.4.12", diff --git a/scripts/telemetry.js b/scripts/telemetry.js index ee44746a..64e537f3 100644 --- a/scripts/telemetry.js +++ b/scripts/telemetry.js @@ -1,7 +1,6 @@ const fs = require('fs-extra'); const path = require('path'); const os = require('os'); -const retry = require('async-retry'); const isCI = require('is-ci'); const pkg = require('../package.json'); @@ -9,8 +8,6 @@ const dest = path.resolve(__dirname, '../.next/cache/umami.json'); const url = 'https://telemetry.umami.is/api/collect'; async function sendTelemetry(action) { - await fs.ensureFile(dest); - let json = {}; try { @@ -19,7 +16,11 @@ async function sendTelemetry(action) { // Ignore } - await fs.writeJSON(dest, { version: pkg.version }); + try { + await fs.writeJSON(dest, { version: pkg.version }); + } catch { + // Ignore + } const { default: isDocker } = await import('is-docker'); const { default: fetch } = await import('node-fetch'); @@ -38,19 +39,14 @@ async function sendTelemetry(action) { upgrade, }; - await retry( - async () => { - await fetch(url, { - method: 'post', - cache: 'no-cache', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(payload), - }); + await fetch(url, { + method: 'post', + cache: 'no-cache', + headers: { + 'Content-Type': 'application/json', }, - { minTimeout: 500, retries: 1, factor: 1 }, - ).catch(() => {}); + body: JSON.stringify(payload), + }); } module.exports = { diff --git a/yarn.lock b/yarn.lock index 41703090..997f7654 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2031,13 +2031,6 @@ astral-regex@^2.0.0: resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ== -async-retry@^1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/async-retry/-/async-retry-1.3.3.tgz#0e7f36c04d8478e7a58bdbed80cedf977785f280" - integrity sha512-wfr/jstw9xNi/0teMHrRW7dsz3Lt5ARhYNZ2ewpadnhaIp5mbALhOAP+EAdsC7t4Z6wqsDVv9+W6gm1Dk9mEyw== - dependencies: - retry "0.13.1" - at-least-node@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2" @@ -5325,11 +5318,6 @@ restore-cursor@^3.1.0: onetime "^5.1.0" signal-exit "^3.0.2" -retry@0.13.1: - version "0.13.1" - resolved "https://registry.yarnpkg.com/retry/-/retry-0.13.1.tgz#185b1587acf67919d63b357349e03537b2484658" - integrity sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg== - reusify@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76"