Skip to content

Commit 8fdbec0

Browse files
authored
Merge branch 'main' into feat/dbauth-fetch-handler
2 parents 61d4664 + 74a9b0a commit 8fdbec0

23 files changed

+105
-76
lines changed

.github/actions/telemetry_check/check.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ try {
3737
switch (mode) {
3838
case 'crwa':
3939
exitCode = await exec(
40-
`yarn node ./packages/create-redwood-app/dist/create-redwood-app.js ../project-for-telemetry --typescript true --git false`
40+
`yarn node ./packages/create-redwood-app/dist/create-redwood-app.js ../project-for-telemetry --typescript true --git false --no-yarn-install`
4141
)
4242
if (exitCode) {
4343
process.exit(1)

packages/cli/src/commands/studioHandler.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const handler = async (options) => {
99
console.log(
1010
'The studio package is not installed, installing it for you, this may take a moment...'
1111
)
12-
await installModule('@redwoodjs/studio', '11.0.0')
12+
await installModule('@redwoodjs/studio', '11.0.1')
1313
console.log('Studio package installed successfully.')
1414

1515
console.log('Adding config to redwood.toml...')
@@ -18,7 +18,7 @@ export const handler = async (options) => {
1818

1919
// Import studio and start it
2020
const { serve } = await import('@redwoodjs/studio')
21-
await serve({ open: options.open })
21+
await serve({ open: options.open, enableWeb: true })
2222
} catch (e) {
2323
console.log('Cannot start the development studio')
2424
console.log(e)

packages/cli/src/commands/upgrade.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ function updatePackageJsonVersion(pkgPath, version, { dryRun, verbose }) {
224224
)
225225

226226
if (pkg.dependencies) {
227-
for (const depName of Object.keys(pkg.dependencies).filter((x) =>
228-
x.startsWith('@redwoodjs/')
227+
for (const depName of Object.keys(pkg.dependencies).filter(
228+
(x) => x.startsWith('@redwoodjs/') && x !== '@redwoodjs/studio'
229229
)) {
230230
if (verbose || dryRun) {
231231
console.log(` - ${depName}: ${pkg.dependencies[depName]} => ${version}`)
@@ -234,8 +234,8 @@ function updatePackageJsonVersion(pkgPath, version, { dryRun, verbose }) {
234234
}
235235
}
236236
if (pkg.devDependencies) {
237-
for (const depName of Object.keys(pkg.devDependencies).filter((x) =>
238-
x.startsWith('@redwoodjs/')
237+
for (const depName of Object.keys(pkg.devDependencies).filter(
238+
(x) => x.startsWith('@redwoodjs/') && x !== '@redwoodjs/studio'
239239
)) {
240240
if (verbose || dryRun) {
241241
console.log(

packages/create-redwood-app/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
],
1616
"scripts": {
1717
"build": "node ./scripts/build.js",
18-
"build:pack": "yarn pack -o create-redwood-app.tgz",
18+
"build:pack": "node ./scripts/buildPack.js",
1919
"build:watch": "nodemon --watch src --ignore dist,template --exec \"yarn build\"",
2020
"prepublishOnly": "NODE_ENV=production yarn build",
2121
"set-up-test-project": "node ./scripts/setUpTestProject.js",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* eslint-env node */
2+
3+
import { fileURLToPath } from 'node:url'
4+
5+
import { cd, path, within, $ } from 'zx'
6+
7+
const tsTemplatePath = fileURLToPath(
8+
new URL('../templates/ts', import.meta.url)
9+
)
10+
const jsTemplatePath = fileURLToPath(
11+
new URL('../templates/js', import.meta.url)
12+
)
13+
14+
await within(async () => {
15+
cd(tsTemplatePath)
16+
17+
await $`touch yarn.lock`
18+
await $`yarn`
19+
})
20+
21+
await within(async () => {
22+
cd(jsTemplatePath)
23+
24+
await $`touch yarn.lock`
25+
await $`yarn`
26+
})
27+
28+
await $`yarn pack -o create-redwood-app.tgz`
29+
30+
await $`rm ${path.join(tsTemplatePath, 'yarn.lock')}`
31+
await $`rm ${path.join(jsTemplatePath, 'yarn.lock')}`

packages/create-redwood-app/src/create-redwood-app.js

+20-37
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,6 @@ const { telemetry } = Parser(hideBin(process.argv), {
3838

3939
const tui = new RedwoodTUI()
4040

41-
// Credit to esbuild: https://github.com/rtsao/esbuild/blob/c35a4cebf037237559213abc684504658966f9d6/lib/install.ts#L190-L199
42-
function isYarnBerryOrNewer() {
43-
const { npm_config_user_agent: npmConfigUserAgent } = process.env
44-
45-
if (npmConfigUserAgent) {
46-
const match = npmConfigUserAgent.match(/yarn\/(\d+)/)
47-
48-
if (match && match[1]) {
49-
return parseInt(match[1], 10) >= 2
50-
}
51-
}
52-
53-
return false
54-
}
55-
5641
const USE_GITPOD_TEXT = [
5742
` As an alternative solution, you can launch a Redwood project using GitPod instead. GitPod is a an online IDE.`,
5843
` See: ${terminalLink(
@@ -250,7 +235,10 @@ async function installNodeModules(newAppDir) {
250235
})
251236
tui.startReactive(tuiContent)
252237

253-
const yarnInstallSubprocess = execa('yarn install', {
238+
const oldCwd = process.cwd()
239+
process.chdir(newAppDir)
240+
241+
const yarnInstallSubprocess = execa(`yarn install`, {
254242
shell: true,
255243
cwd: newAppDir,
256244
})
@@ -271,9 +259,12 @@ async function installNodeModules(newAppDir) {
271259
)
272260
recordErrorViaTelemetry(error)
273261
await shutdownTelemetry()
262+
process.chdir(oldCwd)
274263
process.exit(1)
275264
}
276265

266+
process.chdir(oldCwd)
267+
277268
tuiContent.update({
278269
header: '',
279270
content: `${RedwoodStyling.green('✔')} Installed node modules`,
@@ -611,6 +602,11 @@ async function handleCommitMessagePreference(commitMessageFlag) {
611602
async function handleYarnInstallPreference(yarnInstallFlag) {
612603
// Handle case where flag is set
613604
if (yarnInstallFlag !== null) {
605+
tui.drawText(
606+
`${RedwoodStyling.green('✔')} ${
607+
yarnInstallFlag ? 'Will' : 'Will not'
608+
} run yarn install based on command line flag`
609+
)
614610
return yarnInstallFlag
615611
}
616612

@@ -673,6 +669,11 @@ async function createRedwoodApp() {
673669
type: 'string',
674670
describe: 'Commit message for the initial commit',
675671
})
672+
.option('yarn-install', {
673+
default: null,
674+
type: 'boolean',
675+
describe: 'Install node modules. Skip via --no-yarn-install.',
676+
})
676677
.option('telemetry', {
677678
default: true,
678679
type: 'boolean',
@@ -692,22 +693,10 @@ async function createRedwoodApp() {
692693
].join('\n')
693694
)
694695

695-
const _isYarnBerryOrNewer = isYarnBerryOrNewer()
696-
697-
// Only permit the yarn install flag on yarn 1.
698-
if (!_isYarnBerryOrNewer) {
699-
cli.option('yarn-install', {
700-
default: null,
701-
type: 'boolean',
702-
describe: 'Install node modules. Skip via --no-yarn-install.',
703-
})
704-
}
705-
706696
// Extract the args as provided by the user in the command line
707697
// TODO: Make all flags have the 'flag' suffix
708698
const args = parsedFlags._
709-
const yarnInstallFlag =
710-
parsedFlags['yarn-install'] ?? !_isYarnBerryOrNewer ? parsedFlags.yes : null
699+
const yarnInstallFlag = parsedFlags['yarn-install'] ?? parsedFlags.yes
711700
const typescriptFlag = parsedFlags.typescript ?? parsedFlags.yes
712701
const overwrite = parsedFlags.overwrite
713702
const gitInitFlag = parsedFlags['git-init'] ?? parsedFlags.yes
@@ -745,11 +734,7 @@ async function createRedwoodApp() {
745734
commitMessage = await handleCommitMessagePreference(commitMessageFlag)
746735
}
747736

748-
let yarnInstall = false
749-
750-
if (!_isYarnBerryOrNewer) {
751-
yarnInstall = await handleYarnInstallPreference(yarnInstallFlag)
752-
}
737+
const yarnInstall = await handleYarnInstallPreference(yarnInstallFlag)
753738

754739
let newAppDir = path.resolve(process.cwd(), targetDir)
755740

@@ -765,9 +750,7 @@ async function createRedwoodApp() {
765750
.getActiveSpan()
766751
?.setAttribute('yarn-install-time', Date.now() - yarnInstallStart)
767752
} else {
768-
if (!_isYarnBerryOrNewer) {
769-
tui.drawText(`${RedwoodStyling.info('ℹ')} Skipped yarn install step`)
770-
}
753+
tui.drawText(`${RedwoodStyling.info('ℹ')} Skipped yarn install step`)
771754
}
772755

773756
// Generate types

packages/create-redwood-app/templates/js/web/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"react-dom": "0.0.0-experimental-e5205658f-20230913"
1919
},
2020
"devDependencies": {
21+
"@redwoodjs/vite": "6.0.7",
2122
"@types/react": "18.2.37",
22-
"@types/react-dom": "18.2.15",
23-
"@redwoodjs/vite": "6.0.7"
23+
"@types/react-dom": "18.2.15"
2424
}
2525
}

packages/create-redwood-app/templates/ts/web/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"react-dom": "0.0.0-experimental-e5205658f-20230913"
1919
},
2020
"devDependencies": {
21+
"@redwoodjs/vite": "6.0.7",
2122
"@types/react": "18.2.37",
22-
"@types/react-dom": "18.2.15",
23-
"@redwoodjs/vite": "6.0.7"
23+
"@types/react-dom": "18.2.15"
2424
}
2525
}

packages/create-redwood-app/tests/e2e.test.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ describe('create-redwood-app', () => {
2828
--git-init, --git Initialize a git repository [boolean] [default: null]
2929
-m, --commit-message Commit message for the initial commit
3030
[string] [default: null]
31+
--yarn-install Install node modules. Skip via --no-yarn-install.
32+
[boolean] [default: null]
3133
--telemetry Enables sending telemetry events for this create
3234
command and all Redwood CLI commands
3335
https://telemetry.redwoodjs.com
@@ -52,7 +54,11 @@ describe('create-redwood-app', () => {
5254
})
5355

5456
test('--yes, -y', async () => {
55-
const p = await $`yarn create-redwood-app ./redwood-app --yes`
57+
// Running `yarn install` in Jest test times out and the subsequent step,
58+
// generating types, is also flakey since `yarn pack` seems to skip `.yarnrc.yml`
59+
// which is necessary for configuring a proper install.
60+
const p =
61+
await $`yarn create-redwood-app ./redwood-app --no-yarn-install --yes`
5662

5763
expect(p.exitCode).toEqual(0)
5864
expect(p.stdout).toMatchInlineSnapshot(`
@@ -64,9 +70,11 @@ describe('create-redwood-app', () => {
6470
[?25h✔ Creating your Redwood app in ./redwood-app based on command line argument
6571
✔ Using TypeScript based on command line flag
6672
✔ Will initialize a git repo based on command line flag
73+
✔ Will not run yarn install based on command line flag
6774
[?25l⠋ Creating project files
6875
[?25h[?25l✔ Project files created
69-
[?25h[?25l⠋ Initializing a git repo
76+
[?25hℹ Skipped yarn install step
77+
[?25l⠋ Initializing a git repo
7078
[?25h[?25l✔ Initialized a git repo with commit message "Initial commit"
7179
[?25h
7280
Thanks for trying out Redwood!

packages/create-redwood-app/tests/e2e_prompts.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cd $projectPath
1111

1212
set projectDirectory "redwood-app-prompt-test"
1313

14-
spawn yarn create-redwood-app
14+
spawn yarn create-redwood-app --no-yarn-install
1515

1616
expect "Where would you like to create your Redwood app?"
1717
send "$projectDirectory\n"

packages/create-redwood-app/tests/e2e_prompts_git.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cd $projectPath
1111

1212
set projectDirectory "redwood-app-prompt-git-test"
1313

14-
spawn yarn create-redwood-app --git
14+
spawn yarn create-redwood-app --no-yarn-install --git
1515

1616
expect "Where would you like to create your Redwood app?"
1717
send "$projectDirectory\n"

packages/create-redwood-app/tests/e2e_prompts_m.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cd $projectPath
1111

1212
set projectDirectory "redwood-app-prompt-m-test"
1313

14-
spawn yarn create-redwood-app -m "first"
14+
spawn yarn create-redwood-app --no-yarn-install -m "first"
1515

1616
expect "Where would you like to create your Redwood app?"
1717
send "$projectDirectory\n"

packages/create-redwood-app/tests/e2e_prompts_node_greater.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cd $projectPath
1313

1414
set projectDirectory "redwood-app-prompt-node-greater-test"
1515

16-
spawn yarn create-redwood-app
16+
spawn yarn create-redwood-app --no-yarn-install
1717

1818
expect "How would you like to proceed?"
1919
# ❯ Override error and continue install

packages/create-redwood-app/tests/e2e_prompts_node_less.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cd $projectPath
1313

1414
set projectDirectory "redwood-app-prompt-node-less-test"
1515

16-
spawn yarn create-redwood-app
16+
spawn yarn create-redwood-app --no-yarn-install
1717

1818
expect eof
1919
catch wait result

packages/create-redwood-app/tests/e2e_prompts_overwrite.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set projectDirectory "redwood-app-prompt-overwrite-test"
1414
exec mkdir $projectDirectory
1515
exec touch $projectDirectory/README.md
1616

17-
spawn yarn create-redwood-app
17+
spawn yarn create-redwood-app --no-yarn-install
1818

1919
expect "Where would you like to create your Redwood app?"
2020
send "$projectDirectory\n"

packages/create-redwood-app/tests/e2e_prompts_ts.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cd $projectPath
1111

1212
set projectDirectory "redwood-app-prompt-ts-test"
1313

14-
spawn yarn create-redwood-app --ts
14+
spawn yarn create-redwood-app --no-yarn-install --ts
1515

1616
expect "Where would you like to create your Redwood app?"
1717
send "$projectDirectory\n"

packages/project-config/.babelrc.js

-1
This file was deleted.

packages/project-config/jest.config.js

-8
This file was deleted.

packages/project-config/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"build:types": "tsc --build --verbose",
2121
"build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"",
2222
"prepublishOnly": "NODE_ENV=production yarn build",
23-
"test": "jest src",
24-
"test:watch": "run test --watch"
23+
"test": "vitest run src",
24+
"test:watch": "vitest watch src"
2525
},
2626
"dependencies": {
2727
"@iarna/toml": "2.2.5",
@@ -31,9 +31,9 @@
3131
},
3232
"devDependencies": {
3333
"esbuild": "0.19.9",
34-
"jest": "29.7.0",
3534
"rimraf": "5.0.5",
36-
"typescript": "5.3.3"
35+
"typescript": "5.3.3",
36+
"vitest": "1.2.1"
3737
},
3838
"gitHead": "3905ed045508b861b495f8d5630d76c7a157d8f1"
3939
}

packages/project-config/src/__tests__/config.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import path from 'path'
22

3+
import { describe, it, expect } from 'vitest'
4+
35
import { getConfig, getRawConfig } from '../config'
46

57
describe('getRawConfig', () => {

0 commit comments

Comments
 (0)