Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion packages/cli/src/commands/devHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export const handler = async ({
const jobs = {
api: {
name: 'api',
command: `yarn cross-env NODE_ENV=development NODE_OPTIONS=--enable-source-maps yarn nodemon --quiet --watch "${redwoodConfigPath}" --exec "yarn rw-api-server-watch --port ${apiAvailablePort} ${getApiDebugFlag()} | rw-log-formatter"`,
command: `yarn cross-env NODE_ENV=development ${getDevNodeOptions()} yarn nodemon --quiet --watch "${redwoodConfigPath}" --exec "yarn rw-api-server-watch --port ${apiAvailablePort} ${getApiDebugFlag()} | rw-log-formatter"`,
prefixColor: 'cyan',
runWhen: () => fs.existsSync(rwjsPaths.api.src),
},
Expand Down Expand Up @@ -222,3 +222,25 @@ export const handler = async ({
}
})
}

/**
* Gets the NODE_OPTIONS environment variable from `process.env`, appending `--enable-source-maps` if it's not already there.
* See https://nodejs.org/api/cli.html#node_optionsoptions.
*
* @returns {string}
*/
export function getDevNodeOptions() {
const { NODE_OPTIONS } = process.env

const enableSourceMapsOption = '--enable-source-maps'

if (!NODE_OPTIONS) {
return `NODE_OPTIONS=${enableSourceMapsOption}`
}

if (NODE_OPTIONS.includes(enableSourceMapsOption)) {
return NODE_OPTIONS
}

return `${NODE_OPTIONS} ${enableSourceMapsOption}`
}
27 changes: 27 additions & 0 deletions packages/cli/src/lib/__tests__/getDevNodeOptions.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { getDevNodeOptions } from '../../commands/devHandler'

describe('getNodeOptions', () => {
const enableSourceMapsOption = '--enable-source-maps'

it('defaults to enable-source-maps', () => {
const nodeOptions = getDevNodeOptions()
expect(nodeOptions).toEqual(`NODE_OPTIONS=${enableSourceMapsOption}`)
})

it("doesn't specify `--enable-source-maps` twice", () => {
process.env.NODE_OPTIONS = `NODE_OPTIONS=${enableSourceMapsOption}`

const nodeOptions = getDevNodeOptions()
expect(nodeOptions).toEqual(`NODE_OPTIONS=${enableSourceMapsOption}`)
})

it('merges existing options with `--enable-source-maps`', () => {
const existingOptions = '--inspect --no-experimental-fetch'
process.env.NODE_OPTIONS = `NODE_OPTIONS=${existingOptions}`

const nodeOptions = getDevNodeOptions()
expect(nodeOptions).toEqual(
`NODE_OPTIONS=${existingOptions} ${enableSourceMapsOption}`
)
})
})
40 changes: 19 additions & 21 deletions tasks/release/release.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,28 @@ async function resolveMilestones() {
}

// Depending on if we're releasing a patch or not, there's a few things we need to check.
const {
search: { nodes: prs },
} = await octokit.graphql(`
{
search(
query: "repo:redwoodjs/redwood is:pr is:merged milestone:next-release-patch"
first: 5
type: ISSUE
) {
nodes {
... on PullRequest {
id
}
}
}
}
`)

if (semver === 'patch') {
console.log()
console.log(
`Since we're releasing a ${chalk.magenta(
'patch'
)}, we'll be releasing all the PRs that have the ${chalk.magenta(
`There's ${prs.length} PR(s) that have the ${chalk.magenta(
'next-release-patch'
)} milestone.`
)
Expand All @@ -238,24 +254,6 @@ async function resolveMilestones() {
)
}
} else {
const {
search: { nodes: prs },
} = await octokit.graphql(`
{
search(
query: "repo:redwoodjs/redwood is:pr is:merged milestone:next-release-patch"
first: 5
type: ISSUE
) {
nodes {
... on PullRequest {
id
}
}
}
}
`)

if (prs.length) {
console.log()
console.log(
Expand Down