Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
e30d7237
Unverified
Commit
e30d7237
authored
Apr 29, 2022
by
JJ Kasper
Committed by
GitHub
Apr 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure older lockfile/invalid formats are handled (#36577)
parent
486040ef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
patch-incorrect-lockfile.ts
packages/next/lib/patch-incorrect-lockfile.ts
+2
-2
index.test.ts
...ependencies-can-use-env-vars-in-middlewares/index.test.ts
+6
-0
No files found.
packages/next/lib/patch-incorrect-lockfile.ts
View file @
e30d7237
...
@@ -19,15 +19,15 @@ export async function patchIncorrectLockfile(dir: string) {
...
@@ -19,15 +19,15 @@ export async function patchIncorrectLockfile(dir: string) {
const
content
=
await
promises
.
readFile
(
lockfilePath
,
'utf8'
)
const
content
=
await
promises
.
readFile
(
lockfilePath
,
'utf8'
)
const
lockfileParsed
=
JSON
.
parse
(
content
)
const
lockfileParsed
=
JSON
.
parse
(
content
)
const
packageKeys
=
Object
.
keys
(
lockfileParsed
.
dependencies
)
const
foundSwcPkgs
=
new
Set
()
const
foundSwcPkgs
=
new
Set
()
const
nextPkg
=
lockfileParsed
.
packages
[
'node_modules/next'
]
const
nextPkg
=
lockfileParsed
.
packages
?.
[
'node_modules/next'
]
// if we don't find next in the package-lock we can't continue
// if we don't find next in the package-lock we can't continue
if
(
!
nextPkg
)
{
if
(
!
nextPkg
)
{
return
return
}
}
const
nextVersion
=
nextPkg
.
version
const
nextVersion
=
nextPkg
.
version
const
packageKeys
=
Object
.
keys
(
lockfileParsed
.
dependencies
||
{})
const
expectedSwcPkgs
=
Object
.
keys
(
nextPkg
?.
optionalDependencies
).
filter
(
const
expectedSwcPkgs
=
Object
.
keys
(
nextPkg
?.
optionalDependencies
).
filter
(
(
pkg
)
=>
pkg
.
startsWith
(
'@next/swc-'
)
(
pkg
)
=>
pkg
.
startsWith
(
'@next/swc-'
)
...
...
test/production/dependencies-can-use-env-vars-in-middlewares/index.test.ts
View file @
e30d7237
...
@@ -40,12 +40,18 @@ describe('dependencies can use env vars in middlewares', () => {
...
@@ -40,12 +40,18 @@ describe('dependencies can use env vars in middlewares', () => {
})
})
}
}
`
,
`
,
// make sure invalid package-lock doesn't error
'package-lock.json'
:
'{}'
,
},
},
dependencies
:
{},
dependencies
:
{},
})
})
})
})
afterAll
(()
=>
next
.
destroy
())
afterAll
(()
=>
next
.
destroy
())
it
(
'does not error from patching lockfile'
,
()
=>
{
expect
(
next
.
cliOutput
).
not
.
toContain
(
'patch-incorrect-lockfile'
)
})
it
(
'parses the env vars correctly'
,
async
()
=>
{
it
(
'parses the env vars correctly'
,
async
()
=>
{
const
testDir
=
next
.
testDir
const
testDir
=
next
.
testDir
const
manifestPath
=
path
.
join
(
const
manifestPath
=
path
.
join
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment