Skip to content

Commit d3adbfa

Browse files
authored
fix: disable package-lock.json in monorepos (#1142)
nx trips over the tarball dep we have on `@semantic-release/github` when it tries to parse project deps from the `package-lock.json` in CI so disable lockfiles in monorepos. This will no longer be necessary when semantic-release/github#487 is merged.
1 parent 2ba9369 commit d3adbfa

File tree

5 files changed

+35
-5
lines changed

5 files changed

+35
-5
lines changed

src/check-project/check-monorepo-files.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ export async function checkMonorepoFiles (projectDir) {
2020
let defaultLernaContent = fs.readFileSync(path.join(__dirname, 'files/lerna.json'), {
2121
encoding: 'utf-8'
2222
})
23-
defaultLernaContent = defaultLernaContent.replace(/\$lerna-version/g, pkg.dependencies.lerna.replace(/\^/, ''))
2423

25-
// ensure npm workspaces/lerna packages are in sync
24+
// ensure lerna version is in sync
2625
const lernaConfig = JSON.parse(defaultLernaContent)
27-
lernaConfig.packages = pkg.workspaces
26+
lernaConfig.lerna = pkg.dependencies.lerna.replace(/\^/, '')
2827

2928
defaultLernaContent = JSON.stringify(lernaConfig, null, 2)
3029

3130
await ensureFileHasContents(projectDir, 'lerna.json', defaultLernaContent)
31+
32+
// disable package-lock.json in monorepos until https://github.com/semantic-release/github/pull/487 is merged
33+
await ensureFileHasContents(projectDir, '.npmrc', fs.readFileSync(path.join(__dirname, 'files/npmrc'), {
34+
encoding: 'utf-8'
35+
}))
3236
}

src/check-project/check-monorepo-readme.js

+12
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export async function checkMonorepoReadme (projectDir, repoUrl, defaultBranch, p
5959

6060
let structureIndex = -1
6161
let tocIndex = -1
62+
let apiDocsIndex = -1
6263
let licenseFound = false
6364

6465
file.children.forEach((child, index) => {
@@ -101,6 +102,17 @@ export async function checkMonorepoReadme (projectDir, repoUrl, defaultBranch, p
101102
return
102103
}
103104

105+
if (child.type === 'heading' && rendered.includes('api docs')) {
106+
// skip api docs header
107+
apiDocsIndex = index
108+
return
109+
}
110+
111+
if (apiDocsIndex !== -1 && index === apiDocsIndex + 1) {
112+
// skip api docs link
113+
return
114+
}
115+
104116
if ((child.type === 'heading' && rendered.includes('license')) || licenseFound) {
105117
licenseFound = true
106118
return

src/check-project/check-readme.js

+12
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export async function checkReadme (projectDir, repoUrl, defaultBranch) {
5858

5959
let tocIndex = -1
6060
let installIndex = -1
61+
let apiDocsIndex = -1
6162
let licenseFound = false
6263

6364
/** @type {import('mdast').Content[]} */
@@ -113,6 +114,17 @@ export async function checkReadme (projectDir, repoUrl, defaultBranch) {
113114
return
114115
}
115116

117+
if (child.type === 'heading' && rendered.includes('api docs')) {
118+
// skip api docs header
119+
apiDocsIndex = index
120+
return
121+
}
122+
123+
if (apiDocsIndex !== -1 && index === apiDocsIndex + 1) {
124+
// skip api docs link
125+
return
126+
}
127+
116128
if (child.type === 'definition') {
117129
footer.push(child)
118130
return

src/check-project/files/npmrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
; package-lock with tarball deps breaks lerna/nx - remove when https://github.com/semantic-release/github/pull/487 is merged
2+
package-lock=false

src/docs.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ const publishDocs = async (config) => {
146146
const tasks = new Listr(
147147
[
148148
{
149-
title: 'Clean ./docs',
149+
title: 'Clean output dir',
150150
/**
151151
* @param {GlobalOptions & DocsOptions} ctx
152152
*/
@@ -165,7 +165,7 @@ const tasks = new Listr(
165165
{
166166
title: 'Publish to GitHub Pages',
167167
task: (ctx) => publishDocs(ctx),
168-
enabled: (ctx) => ctx.publish && hasTsconfig
168+
enabled: (ctx) => ctx.publish
169169
}
170170
],
171171
{

0 commit comments

Comments
 (0)