Skip to content

Commit

Permalink
fix: update default branch pattern detection (#1183)
Browse files Browse the repository at this point in the history
Also enforce gitignore contents
  • Loading branch information
achingbrain authored Feb 7, 2023
1 parent fb161fa commit d02f670
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/check-project/check-build-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function checkBuildFiles (projectDir, branchName, repoUrl) {
}

let defaultCiContent = await download(ciFileUrl)
defaultCiContent = defaultCiContent.replace(/\$default-branch/g, branchName)
defaultCiContent = defaultCiContent.replace(/\${{{ github.default_branch }}}/g, branchName)

await ensureFileHasContents(projectDir, '.github/workflows/js-test-and-release.yml', defaultCiContent)

Expand Down
9 changes: 9 additions & 0 deletions src/check-project/files/gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
build
dist
.docs
.coverage
node_modules
package-lock.json
yarn.lock
.vscode
9 changes: 9 additions & 0 deletions src/check-project/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import {
import semver from 'semver'
import Listr from 'listr'
import yargsParser from 'yargs-parser'
import { fileURLToPath } from 'url'

const __dirname = path.dirname(fileURLToPath(import.meta.url))

/**
* @param {string} projectDir
Expand Down Expand Up @@ -125,6 +128,9 @@ async function processMonorepo (projectDir, manifest, branchName, repoUrl) {
proposedManifest = sortManifest(proposedManifest)

await ensureFileHasContents(projectDir, 'package.json', JSON.stringify(proposedManifest, null, 2))
await ensureFileHasContents(projectDir, '.gitignore', fs.readFileSync(path.join(__dirname, 'files', 'gitignore'), {
encoding: 'utf-8'
}))
await checkLicenseFiles(projectDir)
await checkBuildFiles(projectDir, branchName, repoUrl)
await checkMonorepoReadme(projectDir, repoUrl, branchName, projectDirs)
Expand Down Expand Up @@ -382,6 +388,9 @@ async function processModule (projectDir, manifest, branchName, repoUrl, homePag
proposedManifest = sortManifest(proposedManifest)

await ensureFileHasContents(projectDir, 'package.json', JSON.stringify(proposedManifest, null, 2))
await ensureFileHasContents(projectDir, '.gitignore', fs.readFileSync(path.join(__dirname, 'files', 'gitignore'), {
encoding: 'utf-8'
}))
await checkLicenseFiles(projectDir)
await checkReadme(projectDir, repoUrl, branchName, rootManifest)
}
Expand Down

0 comments on commit d02f670

Please sign in to comment.