Skip to content

Commit

Permalink
Merge branch 'main' of github.com:redwoodjs/redwood into feat/api-ski…
Browse files Browse the repository at this point in the history
…p-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)
  ...
  • Loading branch information
dac09 committed Dec 28, 2023
2 parents 9bac85b + 08694fb commit 7db85c9
Show file tree
Hide file tree
Showing 2,617 changed files with 281,343 additions and 92,191 deletions.
450 changes: 450 additions & 0 deletions .dependency-cruiser.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf8
charset = utf-8

[*.{js,jsx,ts,tsx,graphql,sql,md,html,mjml,json,jsonc,json5,yml,yaml,template,sh,Dockerfile}]
indent_style = space
Expand Down
40 changes: 36 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const path = require('path')

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

// Framework Babel config is monorepo root ./babel.config.js
// `yarn lint` runs for each workspace, which needs findup for path to root
// `yarn lint` runs for each workspace, which needs findUp for path to root
const findBabelConfig = (cwd = process.cwd()) => {
const configPath = findUp('babel.config.js', { cwd })
const configPath = findUp('babel.config.js', cwd)
if (!configPath) {
throw new Error(`Eslint-parser could not find a "babel.config.js" file`)
}
Expand All @@ -23,14 +23,17 @@ module.exports = {
ignorePatterns: [
'dist',
'fixtures',
'packages/internal/src/build/babelPlugins/__tests__/__fixtures__/**/*',
'packages/babel-config/src/plugins/__tests__/__fixtures__/**/*',
'packages/babel-config/src/__tests__/__fixtures__/**/*',
'packages/core/**/__fixtures__/**/*',
'packages/codemods/**/__testfixtures__/**/*',
'packages/core/config/storybook/**/*',
'packages/studio/dist-*/**/*',
],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
curly: 'error',
'@typescript-eslint/consistent-type-imports': 'error',
},
env: {
// We use the most modern environment available. Then we rely on Babel to
Expand Down Expand Up @@ -170,5 +173,34 @@ module.exports = {
],
},
},
// Allow computed member access on process.env in NodeJS contexts and tests
{
files: [
'packages/core/config/webpack.common.js',
'packages/testing/**',
'packages/vite/src/index.ts',
],
rules: {
'@redwoodjs/process-env-computed': 'off',
},
},
{
files: ['packages/project-config/**'],
excludedFiles: [
'**/__tests__/**',
'**/*.test.ts?(x)',
'**/*.spec.ts?(x)',
],
rules: {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: false,
optionalDependencies: false,
peerDependencies: true,
},
],
},
},
],
}
163 changes: 163 additions & 0 deletions .github/actions/actionsLib.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/* eslint-env node */
// @ts-check

import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'

import { getExecOutput } from '@actions/exec'
import { hashFiles } from '@actions/glob'

/**
* @typedef {import('@actions/exec').ExecOptions} ExecOptions
*/

export const REDWOOD_FRAMEWORK_PATH = fileURLToPath(new URL('../../', import.meta.url))

/**
* @param {string} command
* @param {ExecOptions} options
*/
function execWithEnv(command, { env = {}, ...rest } = {}) {
return getExecOutput(
command,
undefined,
{
env: {
...process.env,
...env
},
...rest
}
)
}

/**
* @param {string} cwd
*/
export function createExecWithEnvInCwd(cwd) {
/**
* @param {string} command
* @param {Omit<ExecOptions, 'cwd'>} options
*/
return function (command, options = {}) {
return execWithEnv(command, { cwd, ...options })
}
}

export const execInFramework = createExecWithEnvInCwd(REDWOOD_FRAMEWORK_PATH)

/**
* @param {string} redwoodProjectCwd
*/
export function projectDeps(redwoodProjectCwd) {
return execInFramework('yarn project:deps', { env: { RWJS_CWD: redwoodProjectCwd } })
}

/**
* @param {string} redwoodProjectCwd
*/
export function projectCopy(redwoodProjectCwd) {
return execInFramework('yarn project:copy', { env: { RWJS_CWD: redwoodProjectCwd } })
}

/**
* @param {{ baseKeyPrefix: string, distKeyPrefix: string, canary: boolean }} options
*/
export async function createCacheKeys({ baseKeyPrefix, distKeyPrefix, canary }) {
const baseKey = [
baseKeyPrefix,
process.env.RUNNER_OS,
process.env.GITHUB_REF.replaceAll('/', '-'),
await hashFiles(path.join('__fixtures__', 'test-project'))
].join('-')

const dependenciesKey = [
baseKey,
'dependencies',
await hashFiles(['yarn.lock', '.yarnrc.yml'].join('\n')),
].join('-') + (canary ? '-canary' : '')

const distKey = [
dependenciesKey,
distKeyPrefix,
'dist',
await hashFiles([
'package.json',
'babel.config.js',
'tsconfig.json',
'tsconfig.compilerOption.json',
'nx.json',
'lerna.json',
'packages',
].join('\n'))
].join('-') + (canary ? '-canary' : '')

return {
baseKey,
dependenciesKey,
distKey
}
}

/**
* @callback ExecInProject
* @param {string} commandLine command to execute (can include additional args). Must be correctly escaped.
* @param {Omit<ExecOptions, "cwd">=} options exec options. See ExecOptions
* @returns {Promise<unknown>} exit code
*/

/**
* @param {string} testProjectPath
* @param {string} fixtureName
* @param {Object} core
* @param {(key: string, value: string) => void} core.setOutput
* @param {ExecInProject} execInProject
* @returns {Promise<void>}
*/
export async function setUpRscTestProject(
testProjectPath,
fixtureName,
core,
execInProject
) {
core.setOutput('test-project-path', testProjectPath)

console.log('rwPath', REDWOOD_FRAMEWORK_PATH)
console.log('testProjectPath', testProjectPath)

const fixturePath = path.join(
REDWOOD_FRAMEWORK_PATH,
'__fixtures__',
fixtureName
)
const rwBinPath = path.join(
REDWOOD_FRAMEWORK_PATH,
'packages/cli/dist/index.js'
)
const rwfwBinPath = path.join(
REDWOOD_FRAMEWORK_PATH,
'packages/cli/dist/rwfw.js'
)

console.log(`Creating project at ${testProjectPath}`)
console.log()
fs.cpSync(fixturePath, testProjectPath, { recursive: true })

console.log(`Adding framework dependencies to ${testProjectPath}`)
await projectDeps(testProjectPath)
console.log()

console.log(`Installing node_modules in ${testProjectPath}`)
await execInProject('yarn install')

console.log(`Copying over framework files to ${testProjectPath}`)
await execInProject(`node ${rwfwBinPath} project:copy`, {
env: { RWFW_PATH: REDWOOD_FRAMEWORK_PATH },
})
console.log()

console.log(`Building project in ${testProjectPath}`)
await execInProject(`node ${rwBinPath} build -v`)
console.log()
}
8 changes: 8 additions & 0 deletions .github/actions/check_create_redwood_app/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Check create redwood app
description: Determines if the create redwood app JS template should be rebuilt
runs:
using: node20
main: check_create_redwood_app.mjs
inputs:
labels:
required: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* eslint-env es6, node */
import { getInput } from '@actions/core'

// If the PR has the "crwa-ok" label, just pass.
const { labels } = JSON.parse(getInput('labels'))
const hasCRWA_OkLabel = labels.some((label) => label.name === 'crwa-ok')

if (hasCRWA_OkLabel) {
console.log('Skipping check because of the "crwa-ok" label')
} else {
// Check if the PR rebuilds the fixture. If it does, that's enough.
const { exec, getExecOutput } = await import('@actions/exec')
await exec('git fetch origin main')
const { stdout } = await getExecOutput('git diff origin/main --name-only')
const changedFiles = stdout.toString().trim().split('\n').filter(Boolean)
const didRebuildJS_Template = changedFiles.some((file) =>
file.startsWith('packages/create-redwood-app/templates/js')
)

if (didRebuildJS_Template) {
console.log(
[
// Empty space here (and in subsequent console logs)
// because git fetch origin main prints to stdout.
'',
"The create redwood app JS template's been rebuilt",
].join('\n')
)
} else {
// If it doesn't, does it need to be rebuilt? If not, no problem. Otherwise, throw.
const shouldRebuildJS_Template = changedFiles.some(
(file) =>
file.startsWith('packages/create-redwood-app/templates/ts')
)

if (!shouldRebuildJS_Template) {
console.log(['', "The create redwood app JS template doesn't need to be rebuilt"].join('\n'))
} else {
console.log(
[
'',
'This PR changes the create-redwood-app TS template.',
'That usually means the JS template needs to be rebuilt.',
`If you know that it doesn't, add the "crwa-ok" label. Otherwise, rebuild the JS template and commit the changes:`,
'',
' cd packages/create-redwood-app',
' yarn ts-to-js',
'',
].join('\n')
)

process.exitCode = 1
}
}
}
9 changes: 9 additions & 0 deletions .github/actions/check_create_redwood_app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "check_test_project_fixture",
"private": true,
"dependencies": {
"@actions/core": "1.10.1",
"@actions/exec": "1.1.1"
},
"packageManager": "yarn@4.0.2"
}
66 changes: 66 additions & 0 deletions .github/actions/check_create_redwood_app/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# This file is generated by running "yarn install" inside your project.
# Manual changes might be lost - proceed with caution!

__metadata:
version: 8
cacheKey: 10c0

"@actions/core@npm:1.10.1":
version: 1.10.1
resolution: "@actions/core@npm:1.10.1"
dependencies:
"@actions/http-client": "npm:^2.0.1"
uuid: "npm:^8.3.2"
checksum: 8c0/7a61446697a23dcad3545cf0634dedbdedf20ae9a0ee6ee977554589a15deb4a93593ee48a41258933d58ce0778f446b0d2c162b60750956fb75e0b9560fb832
languageName: node
linkType: hard

"@actions/exec@npm:1.1.1":
version: 1.1.1
resolution: "@actions/exec@npm:1.1.1"
dependencies:
"@actions/io": "npm:^1.0.1"
checksum: 8c0/4a09f6bdbe50ce68b5cf8a7254d176230d6a74bccf6ecc3857feee209a8c950ba9adec87cc5ecceb04110182d1c17117234e45557d72fde6229b7fd3a395322a
languageName: node
linkType: hard

"@actions/http-client@npm:^2.0.1":
version: 2.0.1
resolution: "@actions/http-client@npm:2.0.1"
dependencies:
tunnel: "npm:^0.0.6"
checksum: 8c0/b58987ba2f53d7988f612ede7ff834573a3360c21f8fdea9fea92f26ada0fd0efafb22aa7d83f49c18965a5b765775d5253e2edb8d9476d924c4b304ef726b67
languageName: node
linkType: hard

"@actions/io@npm:^1.0.1":
version: 1.1.2
resolution: "@actions/io@npm:1.1.2"
checksum: 8c0/61c871bbee1cf58f57917d9bb2cf6bb7ea4dc40de3f65c7fb4ec619ceff57fc98f56be9cca2d476b09e7a96e1cba0d88cd125c4f690d384b9483935186f256c1
languageName: node
linkType: hard

"check_test_project_fixture@workspace:.":
version: 0.0.0-use.local
resolution: "check_test_project_fixture@workspace:."
dependencies:
"@actions/core": "npm:1.10.1"
"@actions/exec": "npm:1.1.1"
languageName: unknown
linkType: soft

"tunnel@npm:^0.0.6":
version: 0.0.6
resolution: "tunnel@npm:0.0.6"
checksum: 8c0/e27e7e896f2426c1c747325b5f54efebc1a004647d853fad892b46d64e37591ccd0b97439470795e5262b5c0748d22beb4489a04a0a448029636670bfd801b75
languageName: node
linkType: hard

"uuid@npm:^8.3.2":
version: 8.3.2
resolution: "uuid@npm:8.3.2"
bin:
uuid: dist/bin/uuid
checksum: 8c0/bcbb807a917d374a49f475fae2e87fdca7da5e5530820ef53f65ba1d12131bd81a92ecf259cc7ce317cbe0f289e7d79fdfebcef9bfa3087c8c8a2fa304c9be54
languageName: node
linkType: hard
2 changes: 1 addition & 1 deletion .github/actions/check_test_project_fixture/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Check test project fixture
description: Determines if the test project fixture should be rebuilt
runs:
using: node16
using: node20
main: check_test_project_fixture.mjs
inputs:
labels:
Expand Down
Loading

0 comments on commit 7db85c9

Please sign in to comment.