Skip to content

Commit

Permalink
Merge branch 'main' of github.com:redwoodjs/redwood into feat/dc-rc-o…
Browse files Browse the repository at this point in the history
…g-gen-mw-p2

* 'main' of github.com:redwoodjs/redwood:
  chore(tests): add use location typetests to prevent regressions (#10474)
  feat: Remove `--performance` option from `yarn rw build` (#10453)
  fix(cli): await async prettier functions (#10478)
  chore(crwa): Fix `ts-to-js` script (#10476)
  • Loading branch information
dac09 committed Apr 19, 2024
2 parents ea17832 + 4308158 commit 885134a
Show file tree
Hide file tree
Showing 32 changed files with 173 additions and 2,351 deletions.
5 changes: 5 additions & 0 deletions .changesets/10453.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- feat: Remove `--performance` option from `yarn rw build` (#10453) by @Josh-Walker-GM

This change removes the `--performance` flag from the `yarn rw build` command. It will no longer be available to use and the CLI will no longer accept this flag being passed in.

Additionally, the associated webpack config (`@redwoodjs/core/config/webpack.perf.js`) has been removed so it can no longer be imported if you were doing so.
6 changes: 0 additions & 6 deletions packages/cli/src/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ export const builder = (yargs) => {
default: true,
description: 'Generate the Prisma client',
})
.option('performance', {
alias: 'perf',
type: 'boolean',
default: false,
description: 'Measure build performance',
})
.middleware(() => {
const check = checkNodeVersion()

Expand Down
14 changes: 0 additions & 14 deletions packages/cli/src/commands/buildHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { generatePrismaCommand } from '../lib/generatePrismaClient'
export const handler = async ({
side = ['api', 'web'],
verbose = false,
performance = false,
stats = false,
prisma = true,
prerender,
Expand All @@ -28,7 +27,6 @@ export const handler = async ({
command: 'build',
side: JSON.stringify(side),
verbose,
performance,
stats,
prisma,
prerender,
Expand All @@ -39,18 +37,6 @@ export const handler = async ({
const useFragments = rwjsConfig.graphql?.fragments
const useTrustedDocuments = rwjsConfig.graphql?.trustedDocuments

if (performance) {
console.log('Measuring Web Build Performance...')
execa.sync(
`yarn cross-env NODE_ENV=production webpack --config ${require.resolve(
'@redwoodjs/core/config/webpack.perf.js',
)}`,
{ stdio: 'inherit', shell: true, cwd: rwjsPaths.web.base },
)
// We do not want to continue building...
return
}

if (stats) {
console.log('Building Web Stats...')
execa.sync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ export const handler = async ({ force, verbose }) => {
const opentelemetryTasks = [
{
title: `Adding OpenTelemetry setup files...`,
task: () => {
task: async () => {
const setupTemplateContent = fs.readFileSync(
path.resolve(__dirname, 'templates', 'opentelemetry.ts.template'),
'utf-8',
)
const setupScriptContent = ts
? setupTemplateContent
: transformTSToJS(opentelemetryScriptPath, setupTemplateContent)
: await transformTSToJS(opentelemetryScriptPath, setupTemplateContent)

return [
writeFile(opentelemetryScriptPath, setupScriptContent, {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/experimental/setupRscHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const handler = async ({ force, verbose }) => {
)
const entryServerContent = isTypeScriptProject()
? entryServerTemplate
: transformTSToJS(entryServerPath, entryServerTemplate)
: await transformTSToJS(entryServerPath, entryServerTemplate)

writeFile(entryServerPath, entryServerContent, {
overwriteExisting: true,
Expand All @@ -132,7 +132,7 @@ export const handler = async ({ force, verbose }) => {
const documentPath = path.join(rwPaths.web.src, `Document${ext}`)
const documentContent = isTypeScriptProject()
? documentTemplate
: transformTSToJS(documentPath, documentTemplate)
: await transformTSToJS(documentPath, documentTemplate)

writeFile(documentPath, documentContent, {
overwriteExisting: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const handler = async ({ force, verbose }) => {
let entryClientPath = rwPaths.web.entryClient
const entryClientContent = ts
? entryClientTemplate
: transformTSToJS(entryClientPath, entryClientTemplate)
: await transformTSToJS(entryClientPath, entryClientTemplate)

let overwriteExisting = force

Expand Down Expand Up @@ -130,7 +130,7 @@ export const handler = async ({ force, verbose }) => {
)
const entryServerContent = ts
? entryServerTemplate
: transformTSToJS(entryServerPath, entryServerTemplate)
: await transformTSToJS(entryServerPath, entryServerTemplate)

writeFile(entryServerPath, entryServerContent, {
overwriteExisting: force,
Expand All @@ -152,7 +152,7 @@ export const handler = async ({ force, verbose }) => {
const documentPath = path.join(rwPaths.web.src, `Document${ext}`)
const documentContent = ts
? documentTemplate
: transformTSToJS(documentPath, documentTemplate)
: await transformTSToJS(documentPath, documentTemplate)

writeFile(documentPath, documentContent, {
overwriteExisting: force,
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/commands/generate/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import { verifyModelName } from '../../../lib/schemaHelpers'
import { validateName, yargsDefaults } from '../helpers'
const TEMPLATE_PATH = path.resolve(__dirname, 'templates', 'model.js.template')

export const files = ({ name, typescript = false }) => {
const files = async ({ name, typescript = false }) => {
const outputFilename = `${name}.${typescript ? 'ts' : 'js'}`
const outputPath = path.join(getPaths().api.models, outputFilename)

return {
[outputPath]: generateTemplate(TEMPLATE_PATH, { name }),
[outputPath]: await generateTemplate(TEMPLATE_PATH, { name }),
}
}

Expand Down Expand Up @@ -59,8 +59,8 @@ export const handler = async ({ force, ...args }) => {
[
{
title: 'Generating model file...',
task: () => {
return writeFilesTask(files(args), { overwriteExisting: force })
task: async () => {
return writeFilesTask(await files(args), { overwriteExisting: force })
},
},
{
Expand Down
30 changes: 18 additions & 12 deletions packages/cli/src/commands/generate/realtime/realtimeHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export async function handler({ name, type, force, verbose }) {
{
title: `Adding ${name} example subscription ...`,
enabled: () => functionType === 'subscription',
task: () => {
task: async () => {
// sdl

const exampleSdlTemplateContent = path.resolve(
Expand All @@ -100,7 +100,7 @@ export async function handler({ name, type, force, verbose }) {

const sdlContent = ts
? exampleSdlTemplateContent
: transformTSToJS(sdlFile, exampleSdlTemplateContent)
: await transformTSToJS(sdlFile, exampleSdlTemplateContent)

// service

Expand All @@ -119,7 +119,7 @@ export async function handler({ name, type, force, verbose }) {

const serviceContent = ts
? exampleServiceTemplateContent
: transformTSToJS(serviceFile, exampleServiceTemplateContent)
: await transformTSToJS(serviceFile, exampleServiceTemplateContent)

// subscription

Expand All @@ -139,27 +139,33 @@ export async function handler({ name, type, force, verbose }) {

const setupScriptContent = ts
? exampleSubscriptionTemplateContent
: transformTSToJS(exampleFile, exampleSubscriptionTemplateContent)
: await transformTSToJS(
exampleFile,
exampleSubscriptionTemplateContent,
)

// write all files
return [
writeFile(
sdlFile,
generateTemplate(sdlContent, templateVariables(name)),
await generateTemplate(sdlContent, templateVariables(name)),
{
overwriteExisting: force,
},
),
writeFile(
serviceFile,
generateTemplate(serviceContent, templateVariables(name)),
await generateTemplate(serviceContent, templateVariables(name)),
{
overwriteExisting: force,
},
),
writeFile(
exampleFile,
generateTemplate(setupScriptContent, templateVariables(name)),
await generateTemplate(
setupScriptContent,
templateVariables(name),
),
{
overwriteExisting: force,
},
Expand All @@ -170,7 +176,7 @@ export async function handler({ name, type, force, verbose }) {
{
title: `Adding ${name} example live query ...`,
enabled: () => functionType === 'liveQuery',
task: () => {
task: async () => {
// sdl
const exampleSdlTemplateContent = path.resolve(
__dirname,
Expand All @@ -185,7 +191,7 @@ export async function handler({ name, type, force, verbose }) {
)
const sdlContent = ts
? exampleSdlTemplateContent
: transformTSToJS(sdlFile, exampleSdlTemplateContent)
: await transformTSToJS(sdlFile, exampleSdlTemplateContent)

// service
const exampleServiceTemplateContent = path.resolve(
Expand All @@ -203,20 +209,20 @@ export async function handler({ name, type, force, verbose }) {
)
const serviceContent = ts
? exampleServiceTemplateContent
: transformTSToJS(serviceFile, exampleServiceTemplateContent)
: await transformTSToJS(serviceFile, exampleServiceTemplateContent)

// write all files
return [
writeFile(
sdlFile,
generateTemplate(sdlContent, templateVariables(name)),
await generateTemplate(sdlContent, templateVariables(name)),
{
overwriteExisting: force,
},
),
writeFile(
serviceFile,
generateTemplate(serviceContent, templateVariables(name)),
await generateTemplate(serviceContent, templateVariables(name)),
{
overwriteExisting: force,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ describe('fragments graphQLClientConfig', () => {
await matchInlineTransformSnapshot(
'appGqlConfigTransform',
testProjectAppTsx,
`import { FatalErrorBoundary, RedwoodProvider } from \"@redwoodjs/web\";
`import type { ReactNode } from 'react'
import { FatalErrorBoundary, RedwoodProvider } from \"@redwoodjs/web\";
import { RedwoodApolloProvider } from \"@redwoodjs/web/apollo\";
import FatalErrorPage from \"src/pages/FatalErrorPage\";
Expand All @@ -74,22 +76,25 @@ describe('fragments graphQLClientConfig', () => {
import \"./scaffold.css\";
import \"./index.css\";
interface AppProps {
children?: ReactNode;
}
const graphQLClientConfig = {
cacheConfig: {
possibleTypes: possibleTypes.possibleTypes,
},
};
const App = () => (
const App = ({ children }: AppProps) => (
<FatalErrorBoundary page={FatalErrorPage}>
<RedwoodProvider titleTemplate=\"%PageTitle | %AppTitle\">
<AuthProvider>
<RedwoodApolloProvider
useAuth={useAuth}
graphQLClientConfig={graphQLClientConfig}
>
<Routes />
{children ? children : <Routes />}
</RedwoodApolloProvider>
</AuthProvider>
</RedwoodProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export async function handler({ force }: Args) {

const prettierOptions = await getPrettierOptions()

const prettifiedApp = format(source, {
const prettifiedApp = await format(source, {
...prettierOptions,
parser: 'babel-ts',
})
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/commands/setup/mailer/mailerHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const handler = async ({ force, skipExamples }) => {
title: `Adding api/src/lib/mailer.${
projectIsTypescript ? 'ts' : 'js'
}...`,
task: () => {
task: async () => {
const templatePath = path.resolve(
__dirname,
'templates',
Expand All @@ -40,7 +40,7 @@ export const handler = async ({ force, skipExamples }) => {
)
const mailerContent = projectIsTypescript
? templateContent
: transformTSToJS(mailerPath, templateContent)
: await transformTSToJS(mailerPath, templateContent)

return writeFile(mailerPath, mailerContent, {
overwriteExisting: force,
Expand All @@ -59,7 +59,7 @@ export const handler = async ({ force, skipExamples }) => {
{
title: `Adding example ReactEmail mail template`,
skip: () => skipExamples,
task: () => {
task: async () => {
const templatePath = path.resolve(
__dirname,
'templates',
Expand All @@ -77,7 +77,7 @@ export const handler = async ({ force, skipExamples }) => {
)
const exampleTemplateContent = projectIsTypescript
? templateContent
: transformTSToJS(exampleTemplatePath, templateContent)
: await transformTSToJS(exampleTemplatePath, templateContent)

return writeFile(exampleTemplatePath, exampleTemplateContent, {
overwriteExisting: force,
Expand Down
Loading

0 comments on commit 885134a

Please sign in to comment.