Skip to content

Commit

Permalink
Merge branch 'main' of github.com:redwoodjs/redwood into feat/make-vi…
Browse files Browse the repository at this point in the history
…te-default

* 'main' of github.com:redwoodjs/redwood: (23 commits)
  fix: remove react 17/18 warning (redwoodjs#8300)
  chore(release): tolerate lerna publish faliure
  Recover lost connection (redwoodjs#8284)
  chore(deps): update dependency @faker-js/faker to v8 (redwoodjs#8296)
  chore(release): better git commits during release
  feat: experimental - Studio Overview and Performance Widgets (redwoodjs#8292)
  fix(forms): disable webpack-dev-server overlay (redwoodjs#8298)
  Fix studio lint warning (redwoodjs#8297)
  Fastify server: Default to localhost (redwoodjs#8019)
  Fix GraphQL proxy in dev environments without IPv6 (redwoodjs#8233)
  fix(deps): update dependency @graphiql/plugin-explorer to v0.1.18 (redwoodjs#8290)
  chore(deps): update dependency supertokens-auth-react to v0.32.3 (redwoodjs#8289)
  Add `setup sentry` command (redwoodjs#7790)
  chore: readme update core team and all contributors (redwoodjs#8288)
  fix(deps): update nivo monorepo to ^0.83.0 (redwoodjs#8286)
  fix(deps): update dependency babel-plugin-polyfill-corejs3 to v0.8.1 (redwoodjs#8281)
  chore(deps): update dependency @replayio/playwright to v0.3.30 (redwoodjs#8282)
  fix(deps): update dependency webpack to v5.82.1 (redwoodjs#8283)
  Add epilogue to builders (redwoodjs#8285)
  feat(studio): v2 studio (redwoodjs#8173)
  ...
  • Loading branch information
dac09 committed May 12, 2023
2 parents 1112ad5 + bc59b1c commit 1dcb77a
Show file tree
Hide file tree
Showing 133 changed files with 7,182 additions and 2,666 deletions.
4 changes: 1 addition & 3 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ tasks:
openMode: split-left
before: |
export RWFW_PATH="/workspace/redwood"
export RWJS_DEV_API_URL="http://localhost"
init: |
mkdir /workspace/rw-test-app
command: |
cd /workspace/rw-test-app
echo -e "\n\n\033[94m ======================================================" && echo -e "\n\033[33m ⌛ Please wait until the dev server is running on the right-side terminal. \n "rw-test-app" is being generated & linked with latest framework code. \n\nIf you make further changes to the framework..." && echo -e "1. \033[33mEnsure env vars are set \033[92m'export RWFW_PATH="/workspace/redwood" RWJS_DEV_API_URL="http://localhost"'\033[33m" && echo -e "2. \033[33mRun \033[92m'yarn rwfw project:sync'\033[33m to watch & sync changes into the test project" && echo -e "\n\033[94m ======================================================\n\n"
echo -e "\n\n\033[94m ======================================================" && echo -e "\n\033[33m ⌛ Please wait until the dev server is running on the right-side terminal. \n "rw-test-app" is being generated & linked with latest framework code. \n\nIf you make further changes to the framework..." && echo -e "1. \033[33mEnsure env vars are set \033[92m'export RWFW_PATH="/workspace/redwood"'\033[33m" && echo -e "2. \033[33mRun \033[92m'yarn rwfw project:sync'\033[33m to watch & sync changes into the test project" && echo -e "\n\033[94m ======================================================\n\n"
- name: "Dev Servers"
openMode: split-right
before: |
export RWFW_PATH="/workspace/redwood"
export RWJS_DEV_API_URL="http://localhost"
export REDWOOD_DISABLE_TELEMETRY=1
init: |
cd /workspace/redwood
Expand Down
97 changes: 74 additions & 23 deletions README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
"@babel/preset-react": "7.18.6",
"@babel/preset-typescript": "7.21.5",
"@babel/runtime-corejs3": "7.21.5",
"@faker-js/faker": "7.6.0",
"@faker-js/faker": "8.0.0",
"@npmcli/arborist": "6.2.9",
"@playwright/test": "1.33.0",
"@replayio/playwright": "0.3.28",
"@replayio/playwright": "0.3.30",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "14.0.0",
"@testing-library/user-event": "14.4.3",
Expand All @@ -68,7 +68,7 @@
"babel-plugin-remove-code": "0.0.6",
"boxen": "5.1.2",
"core-js": "3.30.2",
"cypress": "12.11.0",
"cypress": "12.12.0",
"cypress-wait-until": "1.7.2",
"eslint": "8.40.0",
"fast-glob": "3.2.12",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const startServer = ({
socket,
fastify,
}: HttpServerParams) => {
const host = process.env.NODE_ENV === 'production' ? '0.0.0.0' : '::'
const host = 'localhost'
const serverPort = socket ? parseInt(socket) : port

fastify.listen({ port: serverPort, host })
Expand Down
5 changes: 3 additions & 2 deletions packages/auth-providers/dbAuth/web/src/dbAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,12 @@ export function createDbAuthClient({
.then((response) => response.text())
.then((tokenText) => {
lastTokenCheckAt = new Date()
getTokenPromise = null
cachedToken = tokenText.length === 0 ? null : tokenText

return cachedToken
})
.finally(() => {
getTokenPromise = null
})

return getTokenPromise
}
Expand Down
4 changes: 2 additions & 2 deletions packages/auth-providers/supertokens/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
"@types/react": "18.2.6",
"jest": "29.5.0",
"react": "18.2.0",
"supertokens-auth-react": "0.32.1",
"supertokens-auth-react": "0.32.3",
"typescript": "5.0.4"
},
"peerDependencies": {
"supertokens-auth-react": "0.32.1"
"supertokens-auth-react": "0.32.3"
},
"gitHead": "3905ed045508b861b495f8d5630d76c7a157d8f1"
}
28 changes: 16 additions & 12 deletions packages/cli/src/commands/experimental/setupOpentelemetry.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import { getEpilogue } from './util'

export const command = 'setup-opentelemetry'

export const description = 'Setup OpenTelemetry within the API side'

export const EXPERIMENTAL_TOPIC_ID = 4772

export const builder = (yargs) => {
yargs.option('force', {
alias: 'f',
default: false,
description: 'Overwrite existing configuration',
type: 'boolean',
})
yargs.option('verbose', {
alias: 'v',
default: false,
description: 'Print more logs',
type: 'boolean',
})
yargs
.option('force', {
alias: 'f',
default: false,
description: 'Overwrite existing configuration',
type: 'boolean',
})
.option('verbose', {
alias: 'v',
default: false,
description: 'Print more logs',
type: 'boolean',
})
.epilogue(getEpilogue(command, description, EXPERIMENTAL_TOPIC_ID, true))
}

export const handler = async (options) => {
Expand Down
23 changes: 23 additions & 0 deletions packages/cli/src/commands/experimental/setupSentry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { getEpilogue } from './util'

export const command = 'setup-sentry'

export const description = 'Setup Sentry error and performance tracking'

export const EXPERIMENTAL_TOPIC_ID = 4880

export const builder = (yargs) => {
yargs
.option('force', {
alias: 'f',
default: false,
description: 'Overwrite existing sentry.js config files',
type: 'boolean',
})
.epilogue(getEpilogue(command, description, EXPERIMENTAL_TOPIC_ID, true))
}

export const handler = async (options) => {
const { handler } = await import('./setupSentryHandler')
return handler(options)
}
200 changes: 200 additions & 0 deletions packages/cli/src/commands/experimental/setupSentryHandler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
import fs from 'fs'
import path from 'path'

import { Listr } from 'listr2'

import {
addApiPackages,
addEnvVarTask,
addWebPackages,
colors as c,
getPaths,
isTypeScriptProject,
prettify,
writeFilesTask,
} from '@redwoodjs/cli-helpers'
import { getConfigPath } from '@redwoodjs/project-config'
import { errorTelemetry } from '@redwoodjs/telemetry'

import { writeFile } from '../../lib'

const PATHS = getPaths()

export const handler = async ({ force }) => {
const extension = isTypeScriptProject ? 'ts' : 'js'

const notes = []

const tasks = new Listr([
addApiPackages([
'@envelop/sentry@5',
'@sentry/node@7',
'@sentry/tracing@7',
]),
addWebPackages(['@sentry/react@7', '@sentry/tracing@7']),
addEnvVarTask(
'SENTRY_DSN',
'https://XXXXXXX@XXXXXXX.ingest.sentry.io/XXXXXXX',
'https://docs.sentry.io/product/sentry-basics/dsn-explainer/'
),
{
title: 'Setting up Sentry on the API and web sides',
task: () =>
writeFilesTask(
{
[path.join(PATHS.api.lib, `sentry.${extension}`)]: fs
.readFileSync(
path.join(__dirname, 'templates/sentryApi.ts.template')
)
.toString(),
[path.join(PATHS.web.src, 'lib', `sentry.${extension}`)]: fs
.readFileSync(
path.join(__dirname, 'templates/sentryWeb.ts.template')
)
.toString(),
},
{ existingFiles: force ? 'OVERWRITE' : 'SKIP' }
),
},
{
title: 'Implementing the Envelop plugin',
task: (ctx) => {
const graphqlHandlerPath = path.join(
PATHS.api.functions,
`graphql.${extension}`
)

const contentLines = fs
.readFileSync(graphqlHandlerPath)
.toString()
.split('\n')

const handlerIndex = contentLines.findLastIndex((line) =>
/^export const handler = createGraphQLHandler\({/.test(line)
)

const pluginsIndex = contentLines.findLastIndex((line) =>
/extraPlugins:/.test(line)
)

if (handlerIndex === -1 || pluginsIndex !== -1) {
ctx.addEnvelopPluginSkipped = true
return
}

contentLines.splice(
handlerIndex,
1,
"import 'src/lib/sentry'",
'',
'export const handler = createGraphQLHandler({',
'extraPlugins: [useSentry({',
'includeRawResult: true,',
'includeResolverArgs: true,',
'includeExecuteVariables: true,',
'})],'
)

contentLines.splice(0, 0, "import { useSentry } from '@envelop/sentry'")

fs.writeFileSync(
graphqlHandlerPath,
prettify('graphql.ts', contentLines.join('\n'))
)
},
},
{
title: "Replacing Redwood's Error boundary",
task: () => {
const contentLines = fs
.readFileSync(PATHS.web.app)
.toString()
.split('\n')

const webImportIndex = contentLines.findLastIndex((line) =>
/^import { FatalErrorBoundary, RedwoodProvider } from '@redwoodjs\/web'$/.test(
line
)
)
contentLines.splice(
webImportIndex,
1,
"import { RedwoodProvider } from '@redwoodjs/web'"
)

const boundaryOpenIndex = contentLines.findLastIndex((line) =>
/<FatalErrorBoundary page={FatalErrorPage}>/.test(line)
)
contentLines.splice(
boundaryOpenIndex,
1,
'<Sentry.ErrorBoundary fallback={FatalErrorPage}>'
)

const boundaryCloseIndex = contentLines.findLastIndex((line) =>
/<\/FatalErrorBoundary>/.test(line)
)
contentLines.splice(boundaryCloseIndex, 1, '</Sentry.ErrorBoundary>')

contentLines.splice(0, 0, "import Sentry from 'src/lib/sentry'")

fs.writeFileSync(
PATHS.web.app,
prettify('App.tsx', contentLines.join('\n'))
)
},
},
{
title: 'Adding config to redwood.toml...',
task: (_ctx, task) => {
const redwoodTomlPath = getConfigPath()
const configContent = fs.readFileSync(redwoodTomlPath, 'utf-8')
if (!configContent.includes('[experimental.sentry]')) {
// Use string replace to preserve comments and formatting
writeFile(
redwoodTomlPath,
configContent.concat(`\n[experimental.sentry]\n\tenabled = true\n`),
{
overwriteExisting: true, // redwood.toml always exists
}
)
} else {
task.skip(
`The [experimental.sentry] config block already exists in your 'redwood.toml' file.`
)
}
},
},
{
title: 'One more thing...',
task: (ctx) => {
notes.push(
c.green(
'You will need to add `SENTRY_DSN` to `includeEnvironmentVariables` in redwood.toml.'
)
)

if (ctx.addEnvelopPluginSkipped) {
notes.push(
`${c.underline(
'Make sure you implement the Sentry Envelop plugin:'
)} https://redwoodjs.com/docs/cli-commands#sentry-envelop-plugin`
)
} else {
notes.push(
"Check out RedwoodJS' docs for more: https://redwoodjs.com/docs/cli-commands#setup-sentry"
)
}
},
},
])

try {
await tasks.run()
console.log(notes.join('\n'))
} catch (e) {
errorTelemetry(process.argv, e.message)
console.error(c.error(e.message))
process.exit(e?.exitCode || 1)
}
}
14 changes: 7 additions & 7 deletions packages/cli/src/commands/experimental/studio.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import terminalLink from 'terminal-link'
import { getEpilogue } from './util'

export const command = 'studio'
export const description = 'Run the Redwood development studio'

export const EXPERIMENTAL_TOPIC_ID = 4771

export function builder(yargs) {
yargs.epilogue(
`Also see the ${terminalLink(
'Redwood CLI Reference',
'https://redwoodjs.com/docs/cli-commands#studio'
)}`
)
yargs
.option('open', {
default: true,
description: 'Open the studio in your browser',
})
.epilogue(getEpilogue(command, description, EXPERIMENTAL_TOPIC_ID, true))
}

export async function handler(options) {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/experimental/studioHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { isModuleInstalled, installRedwoodModule } from '../../lib/packages'
import { command, description, EXPERIMENTAL_TOPIC_ID } from './studio'
import { printTaskEpilogue } from './util'

export const handler = async () => {
export const handler = async (options) => {
printTaskEpilogue(command, description, EXPERIMENTAL_TOPIC_ID)
try {
// Check the module is installed
Expand Down Expand Up @@ -41,7 +41,7 @@ export const handler = async () => {

// Import studio and start it
const { start } = await import('@redwoodjs/studio')
await start()
await start({ open: options.open })
} catch (e) {
console.log('Cannot start the development studio')
console.log(e)
Expand Down
Loading

0 comments on commit 1dcb77a

Please sign in to comment.