Added prestart script.

This commit is contained in:
Mike Cao 2022-03-18 21:57:58 -07:00
parent de3bf23e4c
commit 777dfeac0e
5 changed files with 28 additions and 13 deletions

View File

@ -6,7 +6,7 @@ export function json(res, data = {}) {
return res.status(200).json(data);
}
export function send(res, data, type = 'text-plain') {
export function send(res, data, type = 'text/plain') {
res.setHeader('Content-Type', type);
return res.status(200).send(data);

View File

@ -12,7 +12,7 @@
"scripts": {
"dev": "next dev",
"build": "npm-run-all build-tracker build-geo build-db build-app",
"start": "npm-run-all telemetry start-app",
"start": "npm-run-all init start-app",
"start-app": "next start",
"start-env": "node -r dotenv/config scripts/start-env.js",
"build-app": "next build",
@ -26,7 +26,6 @@
"build-mysql-client": "dotenv prisma generate -- --schema=./prisma/schema.mysql.prisma",
"build-postgresql-schema": "dotenv prisma db pull -- --schema=./prisma/schema.postgresql.prisma",
"build-postgresql-client": "dotenv prisma generate -- --schema=./prisma/schema.postgresql.prisma",
"init": "node scripts/init.js",
"copy-db-schema": "node scripts/copy-db-schema.js",
"generate-lang": "npm-run-all extract-lang merge-lang",
"extract-lang": "formatjs extract \"{pages,components}/**/*.js\" --out-file build/messages.json",
@ -37,9 +36,10 @@
"download-country-names": "node scripts/download-country-names.js",
"download-language-names": "node scripts/download-language-names.js",
"change-password": "node scripts/change-password.js",
"telemetry": "node scripts/telemetry.js",
"lint": "next lint --quiet",
"prepare": "husky install"
"prepare": "husky install",
"postbuild": "node scripts/postbuild.js",
"init": "node scripts/prestart.js"
},
"lint-staged": {
"**/*.js": [

10
scripts/postbuild.js Normal file
View File

@ -0,0 +1,10 @@
require('dotenv').config();
const { sendTelemetry } = require('./telemetry');
async function run() {
if (!process.env.DISABLE_TELEMETRY) {
await sendTelemetry();
}
}
run();

10
scripts/prestart.js Normal file
View File

@ -0,0 +1,10 @@
require('dotenv').config();
const { sendTelemetry } = require('./telemetry');
async function run() {
if (!process.env.DISABLE_TELEMETRY) {
await sendTelemetry();
}
}
run();

View File

@ -1,4 +1,3 @@
require('dotenv').config();
const fs = require('fs-extra');
const path = require('path');
const os = require('os');
@ -53,10 +52,6 @@ async function sendTelemetry() {
}
}
async function run() {
if (!process.env.DISABLE_TELEMETRY) {
await sendTelemetry();
}
}
run();
module.exports = {
sendTelemetry,
};