@@ -20,7 +20,7 @@ export const builder = (yargs) => {
20
20
yargs
21
21
. example (
22
22
'rw upgrade -t 0.20.1-canary.5' ,
23
- 'Specify a version. URL for Version History:\nhttps://www.npmjs.com/package/@redwoodjs/core'
23
+ 'Specify a version. URL for Version History:\nhttps://www.npmjs.com/package/@redwoodjs/core' ,
24
24
)
25
25
. option ( 'dry-run' , {
26
26
alias : 'd' ,
@@ -49,11 +49,11 @@ export const builder = (yargs) => {
49
49
. epilogue (
50
50
`Also see the ${ terminalLink (
51
51
'Redwood CLI Reference for the upgrade command' ,
52
- 'https://redwoodjs.com/docs/cli-commands#upgrade'
52
+ 'https://redwoodjs.com/docs/cli-commands#upgrade' ,
53
53
) } .\nAnd the ${ terminalLink (
54
54
'GitHub releases page' ,
55
- 'https://github.com/redwoodjs/redwood/releases'
56
- ) } for more information on the current release.`
55
+ 'https://github.com/redwoodjs/redwood/releases' ,
56
+ ) } for more information on the current release.`,
57
57
)
58
58
}
59
59
@@ -76,8 +76,8 @@ export const validateTag = (tag) => {
76
76
// Stop execution
77
77
throw new Error (
78
78
c . error (
79
- "Invalid tag supplied. Supported values: 'rc', 'canary', 'latest', 'next', 'experimental', or a valid semver version\n"
80
- )
79
+ "Invalid tag supplied. Supported values: 'rc', 'canary', 'latest', 'next', 'experimental', or a valid semver version\n" ,
80
+ ) ,
81
81
)
82
82
}
83
83
@@ -132,19 +132,19 @@ export const handler = async ({ dryRun, tag, verbose, dedupe }) => {
132
132
const version = ctx . versionToUpgradeTo
133
133
const messageSections = [
134
134
`One more thing...\n\n ${ c . warning (
135
- `🎉 Your project has been upgraded to RedwoodJS ${ version } !`
135
+ `🎉 Your project has been upgraded to RedwoodJS ${ version } !` ,
136
136
) } \n\n`,
137
137
]
138
138
// Show links when switching to 'latest' or 'rc', undefined is essentially an alias of 'latest'
139
139
if ( [ undefined , 'latest' , 'rc' ] . includes ( tag ) ) {
140
140
messageSections . push (
141
141
` Please review the release notes for any manual steps: \n ❖ ${ terminalLink (
142
142
`Redwood community discussion` ,
143
- `https://community.redwoodjs.com/search?q=${ version } %23announcements`
143
+ `https://community.redwoodjs.com/search?q=${ version } %23announcements` ,
144
144
) } \n ❖ ${ terminalLink (
145
145
`GitHub Release notes` ,
146
- `https://github.com/redwoodjs/redwood/releases` // intentionally not linking to specific version
147
- ) } \n\n`
146
+ `https://github.com/redwoodjs/redwood/releases` , // intentionally not linking to specific version
147
+ ) } \n\n`,
148
148
)
149
149
}
150
150
// @MARK
@@ -157,14 +157,14 @@ export const handler = async ({ dryRun, tag, verbose, dedupe }) => {
157
157
isValidRedwoodJSTag ( tag )
158
158
) {
159
159
additionalMessages . push (
160
- ` ❖ You may want to update your redwood.toml config so that \`notifications.versionUpdates\` includes "${ tag } "\n`
160
+ ` ❖ You may want to update your redwood.toml config so that \`notifications.versionUpdates\` includes "${ tag } "\n` ,
161
161
)
162
162
}
163
163
// Append additional messages with a header
164
164
if ( additionalMessages . length > 0 ) {
165
165
messageSections . push (
166
166
` 📢 ${ c . warning ( `We'd also like to remind you that:` ) } \n` ,
167
- ...additionalMessages
167
+ ...additionalMessages ,
168
168
)
169
169
}
170
170
}
@@ -175,7 +175,7 @@ export const handler = async ({ dryRun, tag, verbose, dedupe }) => {
175
175
{
176
176
renderer : verbose && 'verbose' ,
177
177
rendererOptions : { collapseSubtasks : false } ,
178
- }
178
+ } ,
179
179
)
180
180
181
181
await tasks . run ( )
@@ -192,11 +192,11 @@ async function yarnInstall({ verbose }) {
192
192
stdio : verbose ? 'inherit' : 'pipe' ,
193
193
194
194
cwd : getPaths ( ) . base ,
195
- }
195
+ } ,
196
196
)
197
197
} catch ( e ) {
198
198
throw new Error (
199
- 'Could not finish installation. Please run `yarn install` and then `yarn dedupe`, before continuing'
199
+ 'Could not finish installation. Please run `yarn install` and then `yarn dedupe`, before continuing' ,
200
200
)
201
201
}
202
202
}
@@ -205,7 +205,7 @@ async function setLatestVersionToContext(ctx, tag) {
205
205
try {
206
206
const foundVersion = await latestVersion (
207
207
'@redwoodjs/core' ,
208
- tag ? { version : tag } : { }
208
+ tag ? { version : tag } : { } ,
209
209
)
210
210
211
211
ctx . versionToUpgradeTo = foundVersion
@@ -220,12 +220,12 @@ async function setLatestVersionToContext(ctx, tag) {
220
220
*/
221
221
function updatePackageJsonVersion ( pkgPath , version , { dryRun, verbose } ) {
222
222
const pkg = JSON . parse (
223
- fs . readFileSync ( path . join ( pkgPath , 'package.json' ) , 'utf-8' )
223
+ fs . readFileSync ( path . join ( pkgPath , 'package.json' ) , 'utf-8' ) ,
224
224
)
225
225
226
226
if ( pkg . dependencies ) {
227
227
for ( const depName of Object . keys ( pkg . dependencies ) . filter (
228
- ( x ) => x . startsWith ( '@redwoodjs/' ) && x !== '@redwoodjs/studio'
228
+ ( x ) => x . startsWith ( '@redwoodjs/' ) && x !== '@redwoodjs/studio' ,
229
229
) ) {
230
230
if ( verbose || dryRun ) {
231
231
console . log ( ` - ${ depName } : ${ pkg . dependencies [ depName ] } => ${ version } ` )
@@ -235,11 +235,11 @@ function updatePackageJsonVersion(pkgPath, version, { dryRun, verbose }) {
235
235
}
236
236
if ( pkg . devDependencies ) {
237
237
for ( const depName of Object . keys ( pkg . devDependencies ) . filter (
238
- ( x ) => x . startsWith ( '@redwoodjs/' ) && x !== '@redwoodjs/studio'
238
+ ( x ) => x . startsWith ( '@redwoodjs/' ) && x !== '@redwoodjs/studio' ,
239
239
) ) {
240
240
if ( verbose || dryRun ) {
241
241
console . log (
242
- ` - ${ depName } : ${ pkg . devDependencies [ depName ] } => ${ version } `
242
+ ` - ${ depName } : ${ pkg . devDependencies [ depName ] } => ${ version } ` ,
243
243
)
244
244
}
245
245
pkg . devDependencies [ depName ] = `${ version } `
@@ -249,7 +249,7 @@ function updatePackageJsonVersion(pkgPath, version, { dryRun, verbose }) {
249
249
if ( ! dryRun ) {
250
250
fs . writeFileSync (
251
251
path . join ( pkgPath , 'package.json' ) ,
252
- JSON . stringify ( pkg , undefined , 2 )
252
+ JSON . stringify ( pkg , undefined , 2 ) ,
253
253
)
254
254
}
255
255
}
@@ -274,7 +274,7 @@ function updateRedwoodDepsForAllSides(ctx, options) {
274
274
updatePackageJsonVersion ( basePath , ctx . versionToUpgradeTo , options ) ,
275
275
skip : ( ) => ! fs . existsSync ( pkgJsonPath ) ,
276
276
}
277
- } )
277
+ } ) ,
278
278
)
279
279
}
280
280
@@ -318,13 +318,13 @@ async function updatePackageVersionsFromTemplate(ctx, { dryRun, verbose }) {
318
318
if ( ! depName . startsWith ( '@redwoodjs/' ) ) {
319
319
if ( verbose || dryRun ) {
320
320
console . log (
321
- ` - ${ depName } : ${ localPackageJson . dependencies [ depName ] } => ${ depVersion } `
321
+ ` - ${ depName } : ${ localPackageJson . dependencies [ depName ] } => ${ depVersion } ` ,
322
322
)
323
323
}
324
324
325
325
localPackageJson . dependencies [ depName ] = depVersion
326
326
}
327
- }
327
+ } ,
328
328
)
329
329
330
330
Object . entries ( templatePackageJson . devDependencies || { } ) . forEach (
@@ -333,25 +333,25 @@ async function updatePackageVersionsFromTemplate(ctx, { dryRun, verbose }) {
333
333
if ( ! depName . startsWith ( '@redwoodjs/' ) ) {
334
334
if ( verbose || dryRun ) {
335
335
console . log (
336
- ` - ${ depName } : ${ localPackageJson . devDependencies [ depName ] } => ${ depVersion } `
336
+ ` - ${ depName } : ${ localPackageJson . devDependencies [ depName ] } => ${ depVersion } ` ,
337
337
)
338
338
}
339
339
340
340
localPackageJson . devDependencies [ depName ] = depVersion
341
341
}
342
- }
342
+ } ,
343
343
)
344
344
345
345
if ( ! dryRun ) {
346
346
fs . writeFileSync (
347
347
pkgJsonPath ,
348
- JSON . stringify ( localPackageJson , null , 2 )
348
+ JSON . stringify ( localPackageJson , null , 2 ) ,
349
349
)
350
350
}
351
351
} ,
352
352
skip : ( ) => ! fs . existsSync ( pkgJsonPath ) ,
353
353
}
354
- } )
354
+ } ) ,
355
355
)
356
356
}
357
357
@@ -366,7 +366,7 @@ async function refreshPrismaClient(task, { verbose }) {
366
366
} catch ( e ) {
367
367
task . skip ( 'Refreshing the Prisma client caused an Error.' )
368
368
console . log (
369
- 'You may need to update your prisma client manually: $ yarn rw prisma generate'
369
+ 'You may need to update your prisma client manually: $ yarn rw prisma generate' ,
370
370
)
371
371
console . log ( c . error ( e . message ) )
372
372
}
@@ -390,11 +390,6 @@ export const getCmdMajorVersion = async (command) => {
390
390
const dedupeDeps = async ( task , { verbose } ) => {
391
391
try {
392
392
const yarnVersion = await getCmdMajorVersion ( 'yarn' )
393
- const npxVersion = await getCmdMajorVersion ( 'npx' )
394
- let npxArgs = [ ]
395
- if ( npxVersion > 6 ) {
396
- npxArgs = [ '--yes' ]
397
- }
398
393
399
394
const baseExecaArgsForDedupe = {
400
395
shell : true ,
@@ -404,16 +399,18 @@ const dedupeDeps = async (task, { verbose }) => {
404
399
if ( yarnVersion > 1 ) {
405
400
await execa ( 'yarn' , [ 'dedupe' ] , baseExecaArgsForDedupe )
406
401
} else {
407
- await execa (
408
- 'npx' ,
409
- [ ...npxArgs , 'yarn-deduplicate' ] ,
410
- baseExecaArgsForDedupe
402
+ // Redwood projects should not be using yarn 1.x as we specify a version of yarn in the package.json
403
+ // with "packageManager": "[email protected] " or similar.
404
+ // Although we could (and previous did) automatically run `npx yarn-deduplicate` here, that would require
405
+ // the user to have `npx` installed, which is not guaranteed and we do not wish to enforce that.
406
+ task . skip (
407
+ "Yarn 1.x doesn't support dedupe directly. Please upgrade yarn or use npx with `npx yarn-deduplicate` manually." ,
411
408
)
412
409
}
413
410
} catch ( e ) {
414
411
console . log ( c . error ( e . message ) )
415
412
throw new Error (
416
- 'Could not finish de-duplication. For yarn 1.x, please run `npx yarn-deduplicate`, or for yarn 3 run `yarn dedupe` before continuing'
413
+ 'Could not finish de-duplication. For yarn 1.x, please run `npx yarn-deduplicate`, or for yarn 3 run `yarn dedupe` before continuing' ,
417
414
)
418
415
}
419
416
await yarnInstall ( { verbose } )
0 commit comments