|
| 1 | +require('dotenv').config() |
| 2 | +const { getInfo } = require('@changesets/get-github-info') |
| 3 | + |
| 4 | +/* |
| 5 | +Hey, welcome to the changeset config! This file has been generated |
| 6 | +for you with the default configs we use, and some comments around |
| 7 | +what options mean, so that it's easy to customise your workflow. |
| 8 | +
|
| 9 | +You should update this as you need to craft your workflow. |
| 10 | +
|
| 11 | +Config provided by a CI command takes precedence over the contents of this file. |
| 12 | +
|
| 13 | +If a config option isn't present here, we will fall back to the defaults. |
| 14 | +*/ |
| 15 | + |
| 16 | +const changesetOptions = { |
| 17 | + // If true, we will automatically commit the changeset when the command is run |
| 18 | + commit: false |
| 19 | +} |
| 20 | + |
| 21 | +// This function takes information about a changeset to generate an entry for it in your |
| 22 | +// changelog. We provide the full changeset object as well as the version. |
| 23 | +// It may be a good idea to replace the commit hash with a link to the commit. |
| 24 | + |
| 25 | +/* the default shape is: |
| 26 | +### Bump Type |
| 27 | +
|
| 28 | +- GIT_HASH: A summary message you wrote, indented? |
| 29 | +*/ |
| 30 | + |
| 31 | +const getReleaseLine = async (changeset, type) => { |
| 32 | + const [firstLine, ...futureLines] = changeset.summary |
| 33 | + .split('\n') |
| 34 | + .map(l => l.trimRight()) |
| 35 | + |
| 36 | + let { links } = await getInfo({ |
| 37 | + repo: 'emotion-js/emotion', |
| 38 | + commit: changeset.commit |
| 39 | + }) |
| 40 | + |
| 41 | + return `- ${links.commit}${links.pull === null ? '' : ` ${links.pull}`}${ |
| 42 | + links.user === null ? '' : ` Thanks ${links.user}!` |
| 43 | + } - ${firstLine}\n${futureLines.map(l => ` ${l}`).join('\n')}` |
| 44 | +} |
| 45 | + |
| 46 | +// This function takes information about what dependencies we are updating in the package. |
| 47 | +// It provides an array of related changesets, as well as the dependencies updated. |
| 48 | + |
| 49 | +/* |
| 50 | +- Updated dependencies: [ABCDEFG]: |
| 51 | +- Updated dependencies: [HIJKLMN]: |
| 52 | + - dependencyA@1.0.1 |
| 53 | + - dependencyb@1.2.0 |
| 54 | +*/ |
| 55 | +const getDependencyReleaseLine = async (changesets, dependenciesUpdated) => { |
| 56 | + if (dependenciesUpdated.length === 0) return '' |
| 57 | + |
| 58 | + const changesetLinks = changesets.map( |
| 59 | + changeset => `- Updated dependencies [${changeset.commit}]:` |
| 60 | + ) |
| 61 | + |
| 62 | + const updatedDepenenciesList = dependenciesUpdated.map( |
| 63 | + dependency => ` - ${dependency.name}@${dependency.version}` |
| 64 | + ) |
| 65 | + |
| 66 | + return [...changesetLinks, ...updatedDepenenciesList].join('\n') |
| 67 | +} |
| 68 | + |
| 69 | +const versionOptions = { |
| 70 | + // If true, we will automatically commit the version updating when the command is run |
| 71 | + commit: false, |
| 72 | + // Adds a skipCI flag to the commit - only valid if `commit` is also true. |
| 73 | + skipCI: false, |
| 74 | + // Do not modify the `changelog.md` files for packages that are updated |
| 75 | + updateChangelog: true, |
| 76 | + // A function that returns a string. It takes in options about a change. This allows you to customise your changelog entries |
| 77 | + getReleaseLine, |
| 78 | + // A function that returns a string. It takes in options about when a pacakge is updated because |
| 79 | + getDependencyReleaseLine, |
| 80 | + // An array of arrays that defines packages that are linked. |
| 81 | + // Linked packages are packages that should be at the same version when they're released. |
| 82 | + // If you've used Lerna to version packages before, this is very similar. |
| 83 | + linked: [ |
| 84 | + [ |
| 85 | + '@emotion/core', |
| 86 | + '@emotion/styled', |
| 87 | + '@emotion/styled-base', |
| 88 | + '@emotion/cache', |
| 89 | + '@emotion/css', |
| 90 | + 'create-emotion', |
| 91 | + 'emotion', |
| 92 | + 'emotion-server', |
| 93 | + 'create-emotion-server', |
| 94 | + 'babel-plugin-emotion', |
| 95 | + '@emotion/babel-preset-css-prop', |
| 96 | + 'jest-emotion', |
| 97 | + '@emotion/native', |
| 98 | + '@emotion/primitives', |
| 99 | + '@emotion/primitives-core', |
| 100 | + 'eslint-plugin-emotion', |
| 101 | + 'emotion-theming' |
| 102 | + ] |
| 103 | + ] |
| 104 | +} |
| 105 | + |
| 106 | +const publishOptions = { |
| 107 | + // This sets whether unpublished packages are public by default. We err on the side of caution here. |
| 108 | + public: false |
| 109 | +} |
| 110 | + |
| 111 | +module.exports = { |
| 112 | + versionOptions, |
| 113 | + changesetOptions, |
| 114 | + publishOptions |
| 115 | +} |
0 commit comments