diff --git a/packages/server/postgres/migrations/2024-11-27T00:50:24.390Z_taskContentToTipTap.ts b/packages/server/postgres/migrations/2024-11-27T00:50:24.390Z_taskContentToTipTap.ts index 527d4ec2c28..8738a6297d3 100644 --- a/packages/server/postgres/migrations/2024-11-27T00:50:24.390Z_taskContentToTipTap.ts +++ b/packages/server/postgres/migrations/2024-11-27T00:50:24.390Z_taskContentToTipTap.ts @@ -6,6 +6,7 @@ import StarterKit from '@tiptap/starter-kit' import {convertFromRaw, RawDraftContentState} from 'draft-js' import {Options, stateToHTML} from 'draft-js-export-html' import type {Kysely} from 'kysely' +import {Logger} from '../../utils/Logger' export const serverTipTapExtensions = [ StarterKit, @@ -46,7 +47,7 @@ const getNameFromEntity = (content: RawDraftContentState, userId: string) => { const {length, offset} = entityRange return text.slice(offset, offset + length) } - console.log('found unknown for', userId, JSON.stringify(content)) + Logger.log('found unknown for', userId, JSON.stringify(content)) return 'Unknown User' } @@ -95,7 +96,7 @@ export async function up(db: Kysely): Promise { .orderBy('id asc') .limit(1000) .execute() - console.log('converting tasks', i * 1000) + Logger.log('converting tasks', i * 1000) if (tasks.length === 0) break const updatePromises = [] as Promise[] for (const task of tasks) { @@ -112,7 +113,7 @@ export async function up(db: Kysely): Promise { .where('id', '=', id) .execute() } catch (e) { - console.log('GOT ERR', id, contentStr, e) + Logger.log('GOT ERR', id, contentStr, e) throw e } } diff --git a/scripts/buildServers.js b/scripts/buildServers.js index 258c9dd76bf..a26329d7bfd 100644 --- a/scripts/buildServers.js +++ b/scripts/buildServers.js @@ -9,6 +9,7 @@ require('sucrase/register') const webpack = require('webpack') const waitForFileExists = require('./waitForFileExists').default const path = require('path') +const {Logger} = require('../packages/server/utils/Logger') const buildServers = async () => { const config = require('./webpack/dev.servers.config') @@ -17,11 +18,11 @@ const buildServers = async () => { if (!queryMapExists) throw Error('QueryMap Not Available. Run `yarn relay:build`') compiler.watch({aggregateTimeout: 100}, (err, stats) => { if (err) { - console.log('Webpack error:', err) + Logger.log('Webpack error:', err) } const errors = stats?.compilation?.errors ?? [] if (errors.length > 0) { - console.log('COMPILATION ERRORS:', errors) + Logger.log('COMPILATION ERRORS:', errors) } /* servers finished rebuilding */ }) diff --git a/scripts/generateGraphQLArtifacts.js b/scripts/generateGraphQLArtifacts.js index 20053fecd8a..02e3c051c89 100644 --- a/scripts/generateGraphQLArtifacts.js +++ b/scripts/generateGraphQLArtifacts.js @@ -5,6 +5,7 @@ const relayCompilerPath = require('relay-compiler') const cp = require('child_process') const runSchemaUpdater = require('./runSchemaUpdater').default const RelayPersistServer = require('./RelayPersistServer').default +const {Logger} = require('../packages/server/utils/Logger') const generateGraphQLArtifacts = async () => { await runSchemaUpdater(true) @@ -17,11 +18,11 @@ const generateGraphQLArtifacts = async () => { }) relayCompiler.stderr.pipe(process.stderr) }) - console.log('gen graphql artifacts start') + Logger.log('gen graphql artifacts start') await generate(codegenSchema) - console.log('codegen complete') + Logger.log('codegen complete') await runCompiler() - console.log('relay compiler complete') + Logger.log('relay compiler complete') persistServer.close() } diff --git a/scripts/prod.js b/scripts/prod.js index 58776184dc1..05a4fbcaa78 100644 --- a/scripts/prod.js +++ b/scripts/prod.js @@ -1,5 +1,6 @@ const generateGraphQLArtifacts = require('./generateGraphQLArtifacts') const cp = require('child_process') +const {Logger} = require('../packages/server/utils/Logger') const runChild = (cmd) => { return new Promise((resolve, reject) => { @@ -19,15 +20,15 @@ const runChild = (cmd) => { } const prod = async (isDeploy, noDeps) => { - console.log('🙏🙏🙏 Building Production Server 🙏🙏🙏') + Logger.log('🙏🙏🙏 Building Production Server 🙏🙏🙏') try { await generateGraphQLArtifacts() } catch (e) { - console.log('ERR generating artifacts', e) + Logger.log('ERR generating artifacts', e) process.exit(1) } - console.log('starting webpack build') + Logger.log('starting webpack build') try { await Promise.all([ runChild( @@ -38,7 +39,7 @@ const prod = async (isDeploy, noDeps) => { ) ]) } catch (e) { - console.log('error webpackifying', e) + Logger.log('error webpackifying', e) process.exit(1) } } diff --git a/scripts/runSchemaUpdater.ts b/scripts/runSchemaUpdater.ts index 4a8291f75d6..c5417c2dc9c 100644 --- a/scripts/runSchemaUpdater.ts +++ b/scripts/runSchemaUpdater.ts @@ -5,6 +5,7 @@ They are included in the build to minimize the number of webpack builds we perform */ import webpack from 'webpack' +import {Logger} from 'parabol-server/utils/Logger' const compileToolbox = async (ignoreErrors: boolean) => { return new Promise((resolve) => { @@ -12,11 +13,11 @@ const compileToolbox = async (ignoreErrors: boolean) => { const compiler = webpack(config) compiler.run((err, stats) => { if (err) { - console.log('Webpack error:', err) + Logger.log('Webpack error:', err) } const errors = stats?.compilation?.errors ?? [] if (!ignoreErrors && errors.length > 0) { - console.log('COMPILATION ERRORS:', errors) + Logger.log('COMPILATION ERRORS:', errors) } resolve() }) diff --git a/scripts/toolboxSrc/assignSURole.ts b/scripts/toolboxSrc/assignSURole.ts index 7fab627ca59..dadcc500a8a 100644 --- a/scripts/toolboxSrc/assignSURole.ts +++ b/scripts/toolboxSrc/assignSURole.ts @@ -1,5 +1,6 @@ import getPg from '../../packages/server/postgres/getPg' import yargs from 'yargs' +import {Logger} from '../../packages/server/utils/Logger' async function assignSURole() { const argv = await yargs(process.argv.slice(2)) @@ -26,15 +27,15 @@ async function assignSURole() { const pg = getPg() if (argv.removeAll) { const res = await pg.query(`UPDATE "User" SET rol = null WHERE rol = 'su' RETURNING email`) - console.log('Removed all', res.rows) + Logger.log('Removed all', res.rows) } if (argv.add) { const res = await pg.query(`UPDATE "User" SET rol = 'su' WHERE email = ANY ($1) RETURNING email`, [argv.add]) - console.log('Added', res.rows) + Logger.log('Added', res.rows) } if (argv.remove) { const res = await pg.query('UPDATE "User" SET rol = null WHERE email = ANY ($1) RETURNING email', [argv.remove]) - console.log('Removed', res.rows) + Logger.log('Removed', res.rows) } await pg.end() } diff --git a/scripts/toolboxSrc/pgEnsureExtensions.ts b/scripts/toolboxSrc/pgEnsureExtensions.ts index 3fcf9ea4f71..d07a35e8058 100644 --- a/scripts/toolboxSrc/pgEnsureExtensions.ts +++ b/scripts/toolboxSrc/pgEnsureExtensions.ts @@ -1,14 +1,15 @@ import {sql} from 'kysely' import getKysely from '../../packages/server/postgres/getKysely' +import {Logger} from '../../packages/server/utils/Logger' export default async () => { - console.log('🔩 Postgres Extension Checks Started') + Logger.log('🔩 Postgres Extension Checks Started') if (process.env.POSTGRES_USE_PGVECTOR === 'true') { - console.log(' pgvector') + Logger.log(' pgvector') const pg = getKysely() await sql`CREATE EXTENSION IF NOT EXISTS "vector";`.execute(pg) } else { - console.log(' pgvector: skipping check (POSTGRES_USE_PGVECTOR !== true)') + Logger.log(' pgvector: skipping check (POSTGRES_USE_PGVECTOR !== true)') } - console.log('🔩 Postgres Extension Checks Completed') + Logger.log('🔩 Postgres Extension Checks Completed') } diff --git a/scripts/toolboxSrc/pgRestore.ts b/scripts/toolboxSrc/pgRestore.ts index beee0e2de58..fcfedfafb91 100644 --- a/scripts/toolboxSrc/pgRestore.ts +++ b/scripts/toolboxSrc/pgRestore.ts @@ -5,6 +5,7 @@ import {promisify} from 'util' import getPg from '../../packages/server/postgres/getPg' import getPgConfig from '../../packages/server/postgres/getPgConfig' import getProjectRoot from '../webpack/utils/getProjectRoot' +import {Logger} from '../../packages/server/utils/Logger' async function pgRestore() { const exec = promisify(cp.exec) @@ -22,7 +23,7 @@ async function pgRestore() { const requiredFiles = [SCHEMA_ROOT, DATA_ROOT] for (const file of requiredFiles) { if (!fs.existsSync(file)) { - console.log(`${file} does not exist`) + Logger.log(`${file} does not exist`) return } } diff --git a/scripts/toolboxSrc/primeIntegrations.ts b/scripts/toolboxSrc/primeIntegrations.ts index fd10c034ec0..4d2e1cc47f4 100644 --- a/scripts/toolboxSrc/primeIntegrations.ts +++ b/scripts/toolboxSrc/primeIntegrations.ts @@ -1,5 +1,6 @@ import getPg from '../../packages/server/postgres/getPg' import upsertIntegrationProvider from '../../packages/server/postgres/queries/upsertIntegrationProvider' +import {Logger} from '../../packages/server/utils/Logger' const upsertGlobalIntegrationProvidersFromEnv = async () => { const providers = [ @@ -40,9 +41,9 @@ const upsertGlobalIntegrationProvidersFromEnv = async () => { } const primeIntegrations = async () => { - console.log('⛓️ Prime Integrationgs Started') + Logger.log('⛓️ Prime Integrationgs Started') await upsertGlobalIntegrationProvidersFromEnv() - console.log('⛓️ Prime Integrations Complete') + Logger.log('⛓️ Prime Integrations Complete') } export default primeIntegrations diff --git a/scripts/toolboxSrc/pushToCDN.ts b/scripts/toolboxSrc/pushToCDN.ts index 536a38c1536..6ff207e3123 100644 --- a/scripts/toolboxSrc/pushToCDN.ts +++ b/scripts/toolboxSrc/pushToCDN.ts @@ -2,6 +2,7 @@ import fs from 'fs' import getFileStoreManager from 'parabol-server/fileStorage/getFileStoreManager' import path from 'path' import getProjectRoot from '../webpack/utils/getProjectRoot' +import {Logger} from 'parabol-server/utils/Logger' const PROJECT_ROOT = getProjectRoot() @@ -12,7 +13,7 @@ const pushClientAssetsToCDN = async () => { const fileStoreManager = getFileStoreManager() const localClientAssetsDir = path.join(PROJECT_ROOT, 'build') if (process.env.FILE_STORE_PROVIDER === 'local') { - console.log('⛅️ Using Local File Store for client assets. Skipping...') + Logger.log('⛅️ Using Local File Store for client assets. Skipping...') return } @@ -29,7 +30,7 @@ const pushClientAssetsToCDN = async () => { }) ) } - console.log(`⛅️ Uploaded ${dirEnts.length} client assets to CDN`) + Logger.log(`⛅️ Uploaded ${dirEnts.length} client assets to CDN`) } const pushServerAssetsToCDN = async () => { @@ -56,7 +57,7 @@ const pushServerAssetsToCDN = async () => { const buffer = await fs.promises.readFile(path.join(localServerAssetsDir, filename)) const {name, ext} = path.parse(filename) const url = await fileStoreManager.putTemplateIllustration(buffer, 'aGhostOrg', ext, name) - console.log(`⛅️ Uploaded template ${filename} to ${url}`) + Logger.log(`⛅️ Uploaded template ${filename} to ${url}`) return true } @@ -69,7 +70,7 @@ const pushServerAssetsToCDN = async () => { if (exists) return false const buffer = await fs.promises.readFile(path.join(localServerAssetsDir, filename)) const url = await fileStoreManager.putBuildFile(buffer, targetObject) - console.log(`⛅️ Uploaded server asset ${targetObject} to ${url}`) + Logger.log(`⛅️ Uploaded server asset ${targetObject} to ${url}`) return true } @@ -92,15 +93,15 @@ const pushServerAssetsToCDN = async () => { ) } - console.log(`⛅️ Server upload complete. Pushed ${pushed} assets to CDN`) + Logger.log(`⛅️ Server upload complete. Pushed ${pushed} assets to CDN`) } const pushToCDN = async () => { - console.log('⛅️ Push to CDN Started') + Logger.log('⛅️ Push to CDN Started') // Perform in serial to guarantee no more than 50 uploads at a time await pushClientAssetsToCDN() await pushServerAssetsToCDN() - console.log('⛅️ Push to CDN Complete') + Logger.log('⛅️ Push to CDN Complete') } // If called via CLI diff --git a/scripts/toolboxSrc/setIsEnterprise.ts b/scripts/toolboxSrc/setIsEnterprise.ts index 9fe23b5cfeb..ba51585987c 100644 --- a/scripts/toolboxSrc/setIsEnterprise.ts +++ b/scripts/toolboxSrc/setIsEnterprise.ts @@ -1,5 +1,6 @@ import getKysely from 'parabol-server/postgres/getKysely' -import {defaultTier} from '../../packages/server/utils/defaultTier' +import {defaultTier} from 'parabol-server/utils/defaultTier' +import {Logger} from 'parabol-server/utils/Logger' export default async function setIsEnterprise() { if (defaultTier !== 'enterprise') {