Skip to content

Add yarn workspaces and changesets #3530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .babelrc

This file was deleted.

1 change: 1 addition & 0 deletions .changeset/72e3674f/changes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "releases": [{ "name": "react-select", "type": "patch" }], "dependents": [] }
1 change: 1 addition & 0 deletions .changeset/72e3674f/changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Test changeset
36 changes: 36 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@atlaskit/build-releases`, a build tool that works with `bolt` to help you release components from a mono-repository. You can find the full documentation for it [here](https://www.npmjs.com/package/@atlaskit/build-releases)

To help you get started though, here are some things you should know about this folder:

## Changesets are automatically generated

Changesets are generated by the `build-releases changeset` command, though it may have been given a new name within your repository. As long as you are following a changeset release flow, you shouldn't have any problems.

## Each changeset is its own folder

We use hashes by default for these folder names to avoid collisions when generating them, but there's no harm that will come from renaming them.

## Changesets are automatically removed

When `build-releases version` or equivalent command is run, all the changeset folders are removed. This is so we only ever use a changeset once. This makes this a very bad place to store any other information.

## Changesets come in two parts

You should treat these parts quite differently:

- `changes.md` is a file you should feel free to edit as much as you want. It will be prepended to your changelog when you next run your version command.
- `changes.json` is a file that includes information about releases, what should be versioned by the version command. We strongly recommend against editing this directly, as you may make a new changeset that puts your bolt repository into an invalid state.

## I want to edit the information in a `changes.json` - how do I do it safely?

The best option is to make a new changeset using the changeset command, copy over the `changes.md`, then delete the old changeset.

## Can I rename the folder for my changeset?

Absolutely! We need unique hashes to make changesets play nicely with git, but changing your folder from our hash to your own name isn't going to cause any problems.

## Can I manually delete changesets?

You can, but you should be aware this will remove the intent to release communicated by the changeset, and should be done with caution.
165 changes: 165 additions & 0 deletions .changeset/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
'use strict';
require('dotenv').config();
/*
Hey, welcome to the changeset config! This file has been generated
for you with the default configs we use, and some comments around
what options mean, so that it's easy to customise your workflow.

You should update this as you need to craft your workflow.

Config provided by a CI command takes precedence over the contents of this file.

If a config option isn't present here, we will fall back to the defaults.
*/

const changesetOptions = {
// If true, we will automatically commit the changeset when the command is run
commit: false,
};

// This function takes information about a changeset to generate an entry for it in your
// changelog. We provide the full changeset object as well as the version.
// It may be a good idea to replace the commit hash with a link to the commit.

/* the default shape is:
- [patch] ABCDEFG:

A summary message you wrote, indented
*/

function makeQuery(commitShas) {
return `
query {
${commitShas
.map(
(commitSha, i) =>
`a${i}: search(
type: ISSUE
query: "sha:${commitSha}+repo:JedWatson/react-select"
first: 1
) {
edges {
node {
... on PullRequest {
number
author {
login
}
}
}
}
}`
)
.join('\n')}}
`;
}

const fetch = require('node-fetch');
const DataLoader = require('dataloader');

const GHDataLoader = new DataLoader(async commitShas => {
if (!process.env.GITHUB_TOKEN) {
throw new Error(
'Please create a GitHub personal access token at https://github.com/settings/tokens/new and add it to a .env file in the root of the repository'
);
}
let data = await fetch(
`https://api.github.com/graphql?access_token=${process.env.GITHUB_TOKEN}`,
{
method: 'POST',
body: JSON.stringify({ query: makeQuery(commitShas) }),
}
).then(x => x.json());

// this is mainly for the case where there's an authentication problem
if (!data.data) {
throw new Error(
'An error occurred when fetching data from GitHub\n' +
JSON.stringify(data)
);
}
return Object.values(data.data).map(({ edges }) => {
if (
edges[0] &&
edges[0].node &&
typeof edges[0].node.number === 'number' &&
edges[0].node.author &&
typeof edges[0].node.author.login === 'string'
) {
return {
username: edges[0].node.author.login,
number: edges[0].node.number,
};
}
return null;
});
});

function getLinkedCommit(commitSha) {
return `[${commitSha}](https://github.com/JedWatson/react-select/commit/${commitSha})`;
}

const getReleaseLine = async (changeset, versionType) => {
const indentedSummary = changeset.summary
.split('\n')
.map(l => ` ${l}`.trimRight())
.join('\n');
let data = await GHDataLoader.load(changeset.commit);
if (data !== null) {
let { number, username } = data;
return `- [${versionType}] ${getLinkedCommit(
changeset.commit
)} [#${number}](https://github.com/JedWatson/react-select/pulls/${number}) Thanks [@${username}](https://github.com/${username}):\n\n${indentedSummary}`;
}
return `- [${versionType}] ${getLinkedCommit(
changeset.commit
)}:\n\n${indentedSummary}`;
};

// This function takes information about what dependencies we are updating in the package.
// It provides an array of related changesets, as well as the dependencies updated.

/*
- Updated dependencies: [ABCDEFG]:
- Updated dependencies: [HIJKLMN]:
- [email protected]
- [email protected]
*/
const getDependencyReleaseLine = async (changesets, dependenciesUpdated) => {
if (dependenciesUpdated.length === 0) return '';

const changesetLinks = changesets.map(
changeset =>
`- Updated dependencies [${getLinkedCommit(changeset.commit)}]:`
);

const updatedDepenenciesList = dependenciesUpdated.map(
dependency => ` - ${dependency.name}@${dependency.version}`
);

return [...changesetLinks, ...updatedDepenenciesList].join('\n');
};

const versionOptions = {
// If true, we will automatically commit the version updating when the command is run
commit: false,
// Adds a skipCI flag to the commit - only valid if `commit` is also true.
skipCI: false,
// Do not modify the `changelog.md` files for packages that are updated
noChangelog: false,
// A function that returns a string. It takes in options about a change. This allows you to customise your changelog entries
getReleaseLine,
// A function that returns a string. It takes in options about when a pacakge is updated because
getDependencyReleaseLine,
};

const publishOptions = {
// This sets whether unpublished packages are public by default. We err on the side of caution here.
public: true,
};

module.exports = {
versionOptions,
changesetOptions,
publishOptions,
};
7 changes: 7 additions & 0 deletions .changeset/f01665fe/changes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"releases": [
{ "name": "@react-select/docs", "type": "minor" },
{ "name": "react-select", "type": "minor" }
],
"dependents": []
}
1 change: 1 addition & 0 deletions .changeset/f01665fe/changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Another test changeset
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dist/*
flow-typed/*
lib/*
node_modules/*
**/node_modules/*
4 changes: 2 additions & 2 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[ignore]
./lib/.*
./dist/.*
.*/node_modules/cypress/.*

[untyped]
.*/node_modules/@atlaskit/tooltip/dist/cjs/components/Marshal.js.flow
.*/node_modules/@atlaskit/layer-manager/dist/cjs/components/FocusLock/index.js.flow
.*/node_modules/@atlaskit/layer-manager/dist/cjs/components/gateway/components/Gateway.js.flow
Expand Down
4 changes: 4 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
plugins: ['emotion', '@babel/plugin-proposal-class-properties'],
presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-flow'],
};
4 changes: 2 additions & 2 deletions docs/App/Header.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// @flow
/** @jsx jsx */
import fetch from 'unfetch';
import { Component, type Node } from 'react';
import { Component, type Node } from 'react';
import { jsx } from '@emotion/core';
import { withRouter } from 'react-router-dom';

import Select from '../../src';
import Select from 'react-select';
import type { RouterProps } from '../types';
import GitHubButton from './GitHubButton';
import TwitterButton from './TwitterButton';
Expand Down
2 changes: 1 addition & 1 deletion docs/App/PageNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { jsx } from '@emotion/core';
import { Route, Switch } from 'react-router-dom';

import type { RouterProps } from '../types';
import { animatedScrollTo } from '../../src/utils';
import { animatedScrollTo } from 'react-select/src/utils';
import routes from './routes';
import ScrollSpy from './ScrollSpy';
import Sticky from './Sticky';
Expand Down
9 changes: 4 additions & 5 deletions docs/ExampleWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import CodeSandboxer from 'react-codesandboxer';
import { replaceImports } from 'codesandboxer';
import { CodeBlock } from './markdown/renderer';
import pkg from '../package.json';
import { colors } from '../src/theme';
import { defaultTheme } from 'react-select';
import Svg from './Svg';

const { colors } = defaultTheme;

const gitInfo = {
account: 'JedWatson',
repository: 'react-select',
Expand Down Expand Up @@ -44,10 +46,7 @@ export default class ExampleWrapper extends Component {
paths, so we replace on relative paths. This will cause incorrect
displays if our examples are not from docs/examples/file.js
*/
literal={replaceImports(raw, [
['../../src/*', 'react-select/lib/'],
['../../src', 'react-select'],
])}
literal={replaceImports(raw, [['../../src/*', 'react-select/lib/']])}
/>
);
}
Expand Down
4 changes: 2 additions & 2 deletions docs/PropTypes/Async.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component } from 'react';

import { type AsyncProps, defaultProps } from '../../src/Async';
import { type AsyncProps, defaultProps } from 'react-select/src/Async';

export default class Select extends Component<AsyncProps> {
defaultProps = defaultProps
defaultProps = defaultProps;
}
4 changes: 2 additions & 2 deletions docs/PropTypes/Creatable.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component } from 'react';

import { type CreatableProps, defaultProps } from '../../src/Creatable';
import { type CreatableProps, defaultProps } from 'react-select/src/Creatable';

export default class Select extends Component<CreatableProps> {
defaultProps = defaultProps
defaultProps = defaultProps;
}
3 changes: 1 addition & 2 deletions docs/PropTypes/Select.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Component } from 'react';
import { type Props, defaultProps } from '../../src/Select';

import { type Props, defaultProps } from 'react-select/src/Select';

export default class Select extends Component<Props> {
defaultProps = defaultProps;
Expand Down
2 changes: 1 addition & 1 deletion docs/PropTypes/components/ClearIndicator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from 'react';
import { type IndicatorProps } from '../../../src/components/indicators';
import { type IndicatorProps } from 'react-select/src/components/indicators';

export default class ClearIndicator extends Component<IndicatorProps> {}
2 changes: 1 addition & 1 deletion docs/PropTypes/components/Control.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from 'react';
import { type ControlProps } from '../../../src/components/Control';
import { type ControlProps } from 'react-select/src/components/Control';

export default class Control extends Component<ControlProps> {}
2 changes: 1 addition & 1 deletion docs/PropTypes/components/DropdownIndicator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from 'react';
import { type IndicatorProps } from '../../../src/components/indicators';
import { type IndicatorProps } from 'react-select/src/components/indicators';

export default class DropdownIndicator extends Component<IndicatorProps> {}
2 changes: 1 addition & 1 deletion docs/PropTypes/components/Group.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from 'react';
import { type GroupProps } from '../../../src/components/Group';
import { type GroupProps } from 'react-select/src/components/Group';

export default class Group extends Component<GroupProps> {}
2 changes: 1 addition & 1 deletion docs/PropTypes/components/IndicatorsContainer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from 'react';
import { type IndicatorContainerProps } from '../../../src/components/containers';
import { type IndicatorContainerProps } from 'react-select/src/components/containers';

export default class IndicatorContainer extends Component<IndicatorContainerProps> {}
2 changes: 1 addition & 1 deletion docs/PropTypes/components/IndicatorsSeparator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from 'react';
import { type IndicatorProps } from '../../../src/components/indicators';
import { type IndicatorProps } from 'react-select/src/components/indicators';

export default class DropdownIndicator extends Component<IndicatorProps> {}
2 changes: 1 addition & 1 deletion docs/PropTypes/components/Input.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from 'react';
import { type InputProps } from '../../../src/components/Input';
import { type InputProps } from 'react-select/src/components/Input';

export default class Input extends Component<InputProps> {}
2 changes: 1 addition & 1 deletion docs/PropTypes/components/LoadingIndicator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from 'react';
import { type LoadingIconProps } from '../../../src/components/indicators';
import { type LoadingIconProps } from 'react-select/src/components/indicators';

export default class LoadingIndicator extends Component<LoadingIconProps> {}
2 changes: 1 addition & 1 deletion docs/PropTypes/components/LoadingMessage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from 'react';
import { type NoticeProps } from '../../../src/components/Menu';
import { type NoticeProps } from 'react-select/src/components/Menu';

export default class LoadingMessage extends Component<NoticeProps> {}
2 changes: 1 addition & 1 deletion docs/PropTypes/components/Menu.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from 'react';
import { type MenuProps } from '../../../src/components/Menu';
import { type MenuProps } from 'react-select/src/components/Menu';

export default class Menu extends Component<MenuProps> {}
2 changes: 1 addition & 1 deletion docs/PropTypes/components/MenuList.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from 'react';
import { type MenuListComponentProps } from '../../../src/components/Menu';
import { type MenuListComponentProps } from 'react-select/src/components/Menu';

export default class MenuList extends Component<MenuListComponentProps> {}
2 changes: 1 addition & 1 deletion docs/PropTypes/components/MultiValue.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from 'react';
import { type MultiValueProps } from '../../../src/components/MultiValue';
import { type MultiValueProps } from 'react-select/src/components/MultiValue';

export default class MultiValue extends Component<MultiValueProps> {}
Loading