Skip to content

Commit 7db85c9

Browse files
committed
Merge branch 'main' of github.com:redwoodjs/redwood into feat/api-skip-prebuild
* 'main' of github.com:redwoodjs/redwood: (1608 commits) Docker: Update to work with corepack and yarn v4 (redwoodjs#9764) [RFC]: useRoutePaths (redwoodjs#9755) Adds a note about the two commands you will use with your schema to the top of the schema file (redwoodjs#8589) docs: Supertokens.md: Fix typo (redwoodjs#9765) Fix supertokens docs & integration issues (redwoodjs#9757) fix(apollo): Enhance error differently for Suspense Cells (redwoodjs#9640) SSR smoke-test: Use <Metadata /> (redwoodjs#9763) chore(deps): update dependency @types/qs to v6.9.11 (redwoodjs#9761) chore(ci): Better error handling in detectChanges.mjs (redwoodjs#9762) fix(path-alias): Fix aliasing of paths using ts/jsconfig (redwoodjs#9574) chore(deps): update dependency @types/yargs to v17.0.32 (redwoodjs#9759) Make it easier to find useMatch docs (redwoodjs#9756) chore(unit tests): Use side-effect import to fix TS errors (redwoodjs#9754) fix(context): Refactor context (redwoodjs#9371) docs: Replaced deprecated <Set private> with PrivateSet within router.md (redwoodjs#9749) add TS support for storybook preview tsx config extension (redwoodjs#9309) fix(studio): Fix windows path issues (redwoodjs#9752) chore(tasks): Add comparison view to nmHoisting visualisation (redwoodjs#9751) chore(cli): make fs modules used in the CLI consistent (redwoodjs#9746) ...
2 parents 9bac85b + 08694fb commit 7db85c9

File tree

2,617 files changed

+281343
-92191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,617 files changed

+281343
-92191
lines changed

.dependency-cruiser.mjs

+450
Large diffs are not rendered by default.

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ root = true
77
[*]
88
end_of_line = lf
99
insert_final_newline = true
10-
charset = utf8
10+
charset = utf-8
1111

1212
[*.{js,jsx,ts,tsx,graphql,sql,md,html,mjml,json,jsonc,json5,yml,yaml,template,sh,Dockerfile}]
1313
indent_style = space

.eslintrc.js

+36-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
const path = require('path')
22

3-
const findUp = require('findup-sync')
3+
const { findUp } = require('@redwoodjs/project-config')
44

55
// Framework Babel config is monorepo root ./babel.config.js
6-
// `yarn lint` runs for each workspace, which needs findup for path to root
6+
// `yarn lint` runs for each workspace, which needs findUp for path to root
77
const findBabelConfig = (cwd = process.cwd()) => {
8-
const configPath = findUp('babel.config.js', { cwd })
8+
const configPath = findUp('babel.config.js', cwd)
99
if (!configPath) {
1010
throw new Error(`Eslint-parser could not find a "babel.config.js" file`)
1111
}
@@ -23,14 +23,17 @@ module.exports = {
2323
ignorePatterns: [
2424
'dist',
2525
'fixtures',
26-
'packages/internal/src/build/babelPlugins/__tests__/__fixtures__/**/*',
26+
'packages/babel-config/src/plugins/__tests__/__fixtures__/**/*',
27+
'packages/babel-config/src/__tests__/__fixtures__/**/*',
2728
'packages/core/**/__fixtures__/**/*',
2829
'packages/codemods/**/__testfixtures__/**/*',
2930
'packages/core/config/storybook/**/*',
31+
'packages/studio/dist-*/**/*',
3032
],
3133
rules: {
3234
'@typescript-eslint/no-explicit-any': 'off',
3335
curly: 'error',
36+
'@typescript-eslint/consistent-type-imports': 'error',
3437
},
3538
env: {
3639
// We use the most modern environment available. Then we rely on Babel to
@@ -170,5 +173,34 @@ module.exports = {
170173
],
171174
},
172175
},
176+
// Allow computed member access on process.env in NodeJS contexts and tests
177+
{
178+
files: [
179+
'packages/core/config/webpack.common.js',
180+
'packages/testing/**',
181+
'packages/vite/src/index.ts',
182+
],
183+
rules: {
184+
'@redwoodjs/process-env-computed': 'off',
185+
},
186+
},
187+
{
188+
files: ['packages/project-config/**'],
189+
excludedFiles: [
190+
'**/__tests__/**',
191+
'**/*.test.ts?(x)',
192+
'**/*.spec.ts?(x)',
193+
],
194+
rules: {
195+
'import/no-extraneous-dependencies': [
196+
'error',
197+
{
198+
devDependencies: false,
199+
optionalDependencies: false,
200+
peerDependencies: true,
201+
},
202+
],
203+
},
204+
},
173205
],
174206
}

.github/actions/actionsLib.mjs

+163
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
/* eslint-env node */
2+
// @ts-check
3+
4+
import fs from 'node:fs'
5+
import path from 'node:path'
6+
import { fileURLToPath } from 'node:url'
7+
8+
import { getExecOutput } from '@actions/exec'
9+
import { hashFiles } from '@actions/glob'
10+
11+
/**
12+
* @typedef {import('@actions/exec').ExecOptions} ExecOptions
13+
*/
14+
15+
export const REDWOOD_FRAMEWORK_PATH = fileURLToPath(new URL('../../', import.meta.url))
16+
17+
/**
18+
* @param {string} command
19+
* @param {ExecOptions} options
20+
*/
21+
function execWithEnv(command, { env = {}, ...rest } = {}) {
22+
return getExecOutput(
23+
command,
24+
undefined,
25+
{
26+
env: {
27+
...process.env,
28+
...env
29+
},
30+
...rest
31+
}
32+
)
33+
}
34+
35+
/**
36+
* @param {string} cwd
37+
*/
38+
export function createExecWithEnvInCwd(cwd) {
39+
/**
40+
* @param {string} command
41+
* @param {Omit<ExecOptions, 'cwd'>} options
42+
*/
43+
return function (command, options = {}) {
44+
return execWithEnv(command, { cwd, ...options })
45+
}
46+
}
47+
48+
export const execInFramework = createExecWithEnvInCwd(REDWOOD_FRAMEWORK_PATH)
49+
50+
/**
51+
* @param {string} redwoodProjectCwd
52+
*/
53+
export function projectDeps(redwoodProjectCwd) {
54+
return execInFramework('yarn project:deps', { env: { RWJS_CWD: redwoodProjectCwd } })
55+
}
56+
57+
/**
58+
* @param {string} redwoodProjectCwd
59+
*/
60+
export function projectCopy(redwoodProjectCwd) {
61+
return execInFramework('yarn project:copy', { env: { RWJS_CWD: redwoodProjectCwd } })
62+
}
63+
64+
/**
65+
* @param {{ baseKeyPrefix: string, distKeyPrefix: string, canary: boolean }} options
66+
*/
67+
export async function createCacheKeys({ baseKeyPrefix, distKeyPrefix, canary }) {
68+
const baseKey = [
69+
baseKeyPrefix,
70+
process.env.RUNNER_OS,
71+
process.env.GITHUB_REF.replaceAll('/', '-'),
72+
await hashFiles(path.join('__fixtures__', 'test-project'))
73+
].join('-')
74+
75+
const dependenciesKey = [
76+
baseKey,
77+
'dependencies',
78+
await hashFiles(['yarn.lock', '.yarnrc.yml'].join('\n')),
79+
].join('-') + (canary ? '-canary' : '')
80+
81+
const distKey = [
82+
dependenciesKey,
83+
distKeyPrefix,
84+
'dist',
85+
await hashFiles([
86+
'package.json',
87+
'babel.config.js',
88+
'tsconfig.json',
89+
'tsconfig.compilerOption.json',
90+
'nx.json',
91+
'lerna.json',
92+
'packages',
93+
].join('\n'))
94+
].join('-') + (canary ? '-canary' : '')
95+
96+
return {
97+
baseKey,
98+
dependenciesKey,
99+
distKey
100+
}
101+
}
102+
103+
/**
104+
* @callback ExecInProject
105+
* @param {string} commandLine command to execute (can include additional args). Must be correctly escaped.
106+
* @param {Omit<ExecOptions, "cwd">=} options exec options. See ExecOptions
107+
* @returns {Promise<unknown>} exit code
108+
*/
109+
110+
/**
111+
* @param {string} testProjectPath
112+
* @param {string} fixtureName
113+
* @param {Object} core
114+
* @param {(key: string, value: string) => void} core.setOutput
115+
* @param {ExecInProject} execInProject
116+
* @returns {Promise<void>}
117+
*/
118+
export async function setUpRscTestProject(
119+
testProjectPath,
120+
fixtureName,
121+
core,
122+
execInProject
123+
) {
124+
core.setOutput('test-project-path', testProjectPath)
125+
126+
console.log('rwPath', REDWOOD_FRAMEWORK_PATH)
127+
console.log('testProjectPath', testProjectPath)
128+
129+
const fixturePath = path.join(
130+
REDWOOD_FRAMEWORK_PATH,
131+
'__fixtures__',
132+
fixtureName
133+
)
134+
const rwBinPath = path.join(
135+
REDWOOD_FRAMEWORK_PATH,
136+
'packages/cli/dist/index.js'
137+
)
138+
const rwfwBinPath = path.join(
139+
REDWOOD_FRAMEWORK_PATH,
140+
'packages/cli/dist/rwfw.js'
141+
)
142+
143+
console.log(`Creating project at ${testProjectPath}`)
144+
console.log()
145+
fs.cpSync(fixturePath, testProjectPath, { recursive: true })
146+
147+
console.log(`Adding framework dependencies to ${testProjectPath}`)
148+
await projectDeps(testProjectPath)
149+
console.log()
150+
151+
console.log(`Installing node_modules in ${testProjectPath}`)
152+
await execInProject('yarn install')
153+
154+
console.log(`Copying over framework files to ${testProjectPath}`)
155+
await execInProject(`node ${rwfwBinPath} project:copy`, {
156+
env: { RWFW_PATH: REDWOOD_FRAMEWORK_PATH },
157+
})
158+
console.log()
159+
160+
console.log(`Building project in ${testProjectPath}`)
161+
await execInProject(`node ${rwBinPath} build -v`)
162+
console.log()
163+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: Check create redwood app
2+
description: Determines if the create redwood app JS template should be rebuilt
3+
runs:
4+
using: node20
5+
main: check_create_redwood_app.mjs
6+
inputs:
7+
labels:
8+
required: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* eslint-env es6, node */
2+
import { getInput } from '@actions/core'
3+
4+
// If the PR has the "crwa-ok" label, just pass.
5+
const { labels } = JSON.parse(getInput('labels'))
6+
const hasCRWA_OkLabel = labels.some((label) => label.name === 'crwa-ok')
7+
8+
if (hasCRWA_OkLabel) {
9+
console.log('Skipping check because of the "crwa-ok" label')
10+
} else {
11+
// Check if the PR rebuilds the fixture. If it does, that's enough.
12+
const { exec, getExecOutput } = await import('@actions/exec')
13+
await exec('git fetch origin main')
14+
const { stdout } = await getExecOutput('git diff origin/main --name-only')
15+
const changedFiles = stdout.toString().trim().split('\n').filter(Boolean)
16+
const didRebuildJS_Template = changedFiles.some((file) =>
17+
file.startsWith('packages/create-redwood-app/templates/js')
18+
)
19+
20+
if (didRebuildJS_Template) {
21+
console.log(
22+
[
23+
// Empty space here (and in subsequent console logs)
24+
// because git fetch origin main prints to stdout.
25+
'',
26+
"The create redwood app JS template's been rebuilt",
27+
].join('\n')
28+
)
29+
} else {
30+
// If it doesn't, does it need to be rebuilt? If not, no problem. Otherwise, throw.
31+
const shouldRebuildJS_Template = changedFiles.some(
32+
(file) =>
33+
file.startsWith('packages/create-redwood-app/templates/ts')
34+
)
35+
36+
if (!shouldRebuildJS_Template) {
37+
console.log(['', "The create redwood app JS template doesn't need to be rebuilt"].join('\n'))
38+
} else {
39+
console.log(
40+
[
41+
'',
42+
'This PR changes the create-redwood-app TS template.',
43+
'That usually means the JS template needs to be rebuilt.',
44+
`If you know that it doesn't, add the "crwa-ok" label. Otherwise, rebuild the JS template and commit the changes:`,
45+
'',
46+
' cd packages/create-redwood-app',
47+
' yarn ts-to-js',
48+
'',
49+
].join('\n')
50+
)
51+
52+
process.exitCode = 1
53+
}
54+
}
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "check_test_project_fixture",
3+
"private": true,
4+
"dependencies": {
5+
"@actions/core": "1.10.1",
6+
"@actions/exec": "1.1.1"
7+
},
8+
"packageManager": "[email protected]"
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# This file is generated by running "yarn install" inside your project.
2+
# Manual changes might be lost - proceed with caution!
3+
4+
__metadata:
5+
version: 8
6+
cacheKey: 10c0
7+
8+
"@actions/core@npm:1.10.1":
9+
version: 1.10.1
10+
resolution: "@actions/core@npm:1.10.1"
11+
dependencies:
12+
"@actions/http-client": "npm:^2.0.1"
13+
uuid: "npm:^8.3.2"
14+
checksum: 8c0/7a61446697a23dcad3545cf0634dedbdedf20ae9a0ee6ee977554589a15deb4a93593ee48a41258933d58ce0778f446b0d2c162b60750956fb75e0b9560fb832
15+
languageName: node
16+
linkType: hard
17+
18+
"@actions/exec@npm:1.1.1":
19+
version: 1.1.1
20+
resolution: "@actions/exec@npm:1.1.1"
21+
dependencies:
22+
"@actions/io": "npm:^1.0.1"
23+
checksum: 8c0/4a09f6bdbe50ce68b5cf8a7254d176230d6a74bccf6ecc3857feee209a8c950ba9adec87cc5ecceb04110182d1c17117234e45557d72fde6229b7fd3a395322a
24+
languageName: node
25+
linkType: hard
26+
27+
"@actions/http-client@npm:^2.0.1":
28+
version: 2.0.1
29+
resolution: "@actions/http-client@npm:2.0.1"
30+
dependencies:
31+
tunnel: "npm:^0.0.6"
32+
checksum: 8c0/b58987ba2f53d7988f612ede7ff834573a3360c21f8fdea9fea92f26ada0fd0efafb22aa7d83f49c18965a5b765775d5253e2edb8d9476d924c4b304ef726b67
33+
languageName: node
34+
linkType: hard
35+
36+
"@actions/io@npm:^1.0.1":
37+
version: 1.1.2
38+
resolution: "@actions/io@npm:1.1.2"
39+
checksum: 8c0/61c871bbee1cf58f57917d9bb2cf6bb7ea4dc40de3f65c7fb4ec619ceff57fc98f56be9cca2d476b09e7a96e1cba0d88cd125c4f690d384b9483935186f256c1
40+
languageName: node
41+
linkType: hard
42+
43+
"check_test_project_fixture@workspace:.":
44+
version: 0.0.0-use.local
45+
resolution: "check_test_project_fixture@workspace:."
46+
dependencies:
47+
"@actions/core": "npm:1.10.1"
48+
"@actions/exec": "npm:1.1.1"
49+
languageName: unknown
50+
linkType: soft
51+
52+
"tunnel@npm:^0.0.6":
53+
version: 0.0.6
54+
resolution: "tunnel@npm:0.0.6"
55+
checksum: 8c0/e27e7e896f2426c1c747325b5f54efebc1a004647d853fad892b46d64e37591ccd0b97439470795e5262b5c0748d22beb4489a04a0a448029636670bfd801b75
56+
languageName: node
57+
linkType: hard
58+
59+
"uuid@npm:^8.3.2":
60+
version: 8.3.2
61+
resolution: "uuid@npm:8.3.2"
62+
bin:
63+
uuid: dist/bin/uuid
64+
checksum: 8c0/bcbb807a917d374a49f475fae2e87fdca7da5e5530820ef53f65ba1d12131bd81a92ecf259cc7ce317cbe0f289e7d79fdfebcef9bfa3087c8c8a2fa304c9be54
65+
languageName: node
66+
linkType: hard

.github/actions/check_test_project_fixture/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Check test project fixture
22
description: Determines if the test project fixture should be rebuilt
33
runs:
4-
using: node16
4+
using: node20
55
main: check_test_project_fixture.mjs
66
inputs:
77
labels:

0 commit comments

Comments
 (0)