Skip to content

Commit

Permalink
chore: adding prerelease for @cypress/vue and refactoring .releaserc.…
Browse files Browse the repository at this point in the history
…js to have a base config (cypress-io#8778)
  • Loading branch information
JessicaSachs authored Oct 8, 2020
1 parent 8bf4e3d commit ee3f7bc
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 25 deletions.
11 changes: 0 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ binary-url.json
.eslintrc.js
cli/visual-snapshots


# Created by https://www.gitignore.io/api/osx,git,node,windows,intellij,linux
# Edit at https://www.gitignore.io/?templates=osx,git,node,windows,intellij,linux

Expand All @@ -50,16 +49,6 @@ cli/visual-snapshots
# $ git config --global mergetool.keepBackup false
*.orig

# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
Expand Down
10 changes: 10 additions & 0 deletions .releaserc.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
'@semantic-release/npm',
],
extends: 'semantic-release-monorepo',
branches: [
],
}
6 changes: 6 additions & 0 deletions .releaserc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
...require('./.releaserc.base'),
branches: [
'master',
],
}
11 changes: 0 additions & 11 deletions .releaserc.json

This file was deleted.

7 changes: 7 additions & 0 deletions npm/vue/.releaserc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
...require('../../.releaserc.base'),
branches: [
'@cypress/[email protected]',
{ name: 'master', prerelease: 'alpha' },
],
}
24 changes: 21 additions & 3 deletions scripts/inject-npm-version.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const execa = require('execa')
const fs = require('fs')
const path = require('path')
const { groupBy } = require('lodash')
const debug = require('debug')('cypress-build:semantic-release')
const info = require('debug')('cypress-build:semantic-release:info')

// updates a public package's package.json
// replaces any local dependencies that have a * version
Expand All @@ -25,13 +28,18 @@ const getBinaryVersion = async () => {
}

const parseSemanticReleaseOutput = (output) => {
debug(`Semantic Release Output ${output}`)
const currentVersion = (output.match(/associated with version (\d+\.\d+\.\d+-?\S*)/) || [])[1]
const nextVersion = (output.match(/The next release version is (\d+\.\d+\.\d+-?\S*)/) || [])[1]

debug(`Current Version`, currentVersion)
debug(`Next Version`, nextVersion)

return nextVersion || currentVersion
}

const getPackageVersion = async (pack) => {
debug(`package`, pack)
const { stdout: semrel } = await execa('npx', ['lerna', 'exec', '--scope', pack, '--', 'npx', '--no-install', 'semantic-release', '--dry-run'])

const version = parseSemanticReleaseOutput(semrel)
Expand All @@ -47,9 +55,19 @@ const getPackageVersion = async (pack) => {
}

const main = async (name) => {
console.log(`Setting local npm packages to the correct version in package.json`)
if (!name) return

debug(`Setting local npm packages to the correct version in package.json`)

const packages = await getPackages()
const packagesByPrivacy = groupBy(packages, 'private')

info(`Found these packages...`)
info(`Packages that can be independently released:`)
packagesByPrivacy.false && packagesByPrivacy.false.forEach((p) => info(`- ${p.name}`))
info(`Packages that cannot be released:`)
packagesByPrivacy.true && packagesByPrivacy.true.forEach((p) => info(`- ${p.name}`))

const packageNames = packages.map((p) => p.name)

const pack = packages.find((p) => p.name === name)
Expand Down Expand Up @@ -88,14 +106,14 @@ const main = async (name) => {
version = await getPackageVersion(dep)
}

console.log(version)
debug(version)

packageJson.dependencies[dep] = version
}

fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2))

console.log(`package.json updated!`)
debug(`package.json updated!`)
}

// execute main function if called from command line
Expand Down

0 comments on commit ee3f7bc

Please sign in to comment.