Skip to content

Commit

Permalink
New config! (changesets#132)
Browse files Browse the repository at this point in the history
* Start of new config things!

* Add changes to types

* More stuff

* Some stuff

* Add tests and fix things

* Fix things

* fix All The Things

* Update snapshots

* Fix type things

* Fix linting

* whoops, nearly forgot changesets
  • Loading branch information
emmatown authored Jul 23, 2019
1 parent 84aeb37 commit 519b421
Show file tree
Hide file tree
Showing 19 changed files with 602 additions and 44 deletions.
6 changes: 6 additions & 0 deletions .changeset/hip-crews-wave/changes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"releases": [
{ "name": "@changesets/assemble-release-plan", "type": "patch" }
],
"dependents": []
}
1 change: 1 addition & 0 deletions .changeset/hip-crews-wave/changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use new Config type which makes linked required
30 changes: 30 additions & 0 deletions .changeset/hungry-drinks-lay/changes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"releases": [{ "name": "@changesets/types", "type": "minor" }],
"dependents": [
{
"name": "@changesets/assemble-release-plan",
"type": "patch",
"dependencies": ["@changesets/config", "@changesets/types"]
},
{
"name": "@changesets/config",
"type": "patch",
"dependencies": ["@changesets/types"]
},
{
"name": "get-dependents-graph",
"type": "patch",
"dependencies": ["@changesets/types"]
},
{
"name": "@changesets/parse",
"type": "patch",
"dependencies": ["@changesets/types"]
},
{
"name": "@changesets/read",
"type": "patch",
"dependencies": ["@changesets/parse", "@changesets/types"]
}
]
}
1 change: 1 addition & 0 deletions .changeset/hungry-drinks-lay/changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add WrittenConfig type and include all properties in Config type
10 changes: 10 additions & 0 deletions .changeset/many-impalas-march/changes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"releases": [{ "name": "@changesets/config", "type": "minor" }],
"dependents": [
{
"name": "@changesets/assemble-release-plan",
"type": "patch",
"dependencies": ["@changesets/config"]
}
]
}
1 change: 1 addition & 0 deletions .changeset/many-impalas-march/changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Initial release with parse and read functions along with defaultConfig and defaultWrittenConfig
4 changes: 4 additions & 0 deletions __fixtures__/new-config/.changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"changelog": false,
"commit": true
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@babel/runtime": "^7.4.4",
"@types/fs-extra": "^5.1.0",
"@types/jest": "^24.0.12",
"@types/jest-in-case": "^1.0.1",
"@types/js-yaml": "^3.12.1",
"@types/meow": "^5.0.0",
"@types/semver": "^6.0.0",
Expand Down Expand Up @@ -68,6 +69,7 @@
"is-ci": "^2.0.0",
"jest": "^24.7.1",
"jest-fixtures": "^0.5.0",
"jest-in-case": "^1.0.2",
"jest-junit": "^6.4.0",
"js-yaml": "^3.13.1",
"lodash.startcase": "^4.4.0",
Expand All @@ -76,7 +78,7 @@
"outdent": "^0.5.0",
"p-limit": "^2.2.0",
"pkg-dir": "^4.1.0",
"preconstruct": "^0.0.79",
"preconstruct": "^0.0.84",
"prettier": "^1.14.3",
"semver": "^5.4.1",
"spawndamnit": "^2.0.0",
Expand Down
5 changes: 4 additions & 1 deletion packages/assemble-release-plan/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
"dependencies": {
"@changesets/types": "^0.0.0",
"semver": "^5.4.1"
},
"devDependencies": {
"@changesets/config": "^0.0.0"
}
}
}
5 changes: 1 addition & 4 deletions packages/assemble-release-plan/src/apply-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ import { Linked, ComprehensiveRelease } from "@changesets/types";
We could solve this by inlining this function, or by returning a deep-cloned then
modified array, but we decided both of those are worse than this solution.
*/
function applyLinks(
releases: ComprehensiveRelease[],
linked?: Linked
): boolean {
function applyLinks(releases: ComprehensiveRelease[], linked: Linked): boolean {
let updated = false;
if (!linked) return updated;

Expand Down
43 changes: 22 additions & 21 deletions packages/assemble-release-plan/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { defaultConfig } from "@changesets/config";
import assembleReleasePlan from "./";
import FakeFullState from "./test-utils";

Expand All @@ -16,7 +17,7 @@ describe("assemble-release-plan", () => {
setup.changesets,
setup.workspaces,
setup.dependentsGraph,
{}
defaultConfig
);

expect(releases.length).toBe(1);
Expand All @@ -42,7 +43,7 @@ describe("assemble-release-plan", () => {
setup.changesets,
setup.workspaces,
setup.dependentsGraph,
{}
defaultConfig
);

expect(releases.length).toBe(4);
Expand All @@ -65,7 +66,7 @@ describe("assemble-release-plan", () => {
setup.changesets,
setup.workspaces,
setup.dependentsGraph,
{}
defaultConfig
);

expect(releases.length).toEqual(1);
Expand All @@ -84,7 +85,7 @@ describe("assemble-release-plan", () => {
setup.changesets,
setup.workspaces,
setup.dependentsGraph,
{}
defaultConfig
);

expect(releases.length).toEqual(2);
Expand All @@ -104,7 +105,7 @@ describe("assemble-release-plan", () => {
setup.changesets,
setup.workspaces,
setup.dependentsGraph,
{ linked: [["pkg-a", "pkg-b"]] }
{ ...defaultConfig, linked: [["pkg-a", "pkg-b"]] }
);

expect(releases.length).toEqual(2);
Expand Down Expand Up @@ -134,7 +135,7 @@ describe("assemble-release-plan", () => {
setup.changesets,
setup.workspaces,
setup.dependentsGraph,
{ linked: [["pkg-a", "pkg-b"], ["pkg-c", "pkg-d"]] }
{ ...defaultConfig, linked: [["pkg-a", "pkg-b"], ["pkg-c", "pkg-d"]] }
);

expect(releases.length).toEqual(4);
Expand All @@ -148,7 +149,7 @@ describe("assemble-release-plan", () => {
[],
setup.workspaces,
setup.dependentsGraph,
{ linked: [["pkg-a", "pkg-b"], ["pkg-c", "pkg-d"]] }
{ ...defaultConfig, linked: [["pkg-a", "pkg-b"], ["pkg-c", "pkg-d"]] }
);

expect(releases).toEqual([]);
Expand All @@ -161,7 +162,7 @@ describe("assemble-release-plan", () => {
setup.changesets,
setup.workspaces,
setup.dependentsGraph,
{ linked: [["pkg-a", "pkg-b"], ["pkg-c", "pkg-d"]] }
{ ...defaultConfig, linked: [["pkg-a", "pkg-b"], ["pkg-c", "pkg-d"]] }
);

expect(releases.length).toEqual(3);
Expand All @@ -180,7 +181,7 @@ describe("assemble-release-plan", () => {
setup.changesets,
setup.workspaces,
setup.dependentsGraph,
{ linked: [["pkg-a", "pkg-b"], ["pkg-c", "pkg-d"]] }
{ ...defaultConfig, linked: [["pkg-a", "pkg-b"], ["pkg-c", "pkg-d"]] }
);

expect(releases.length).toEqual(3);
Expand All @@ -202,7 +203,7 @@ describe("assemble-release-plan", () => {
setup.changesets,
setup.workspaces,
setup.dependentsGraph,
{}
defaultConfig
);

expect(releases.length).toEqual(2);
Expand Down Expand Up @@ -231,7 +232,7 @@ describe("version update thoroughness", () => {
setup.changesets,
setup.workspaces,
setup.dependentsGraph,
{}
defaultConfig
);
expect(releases.length).toEqual(2);
expect(releases[0].name).toEqual("pkg-a");
Expand All @@ -249,7 +250,7 @@ describe("version update thoroughness", () => {
setup.changesets,
setup.workspaces,
setup.dependentsGraph,
{}
defaultConfig
);

expect(releases.length).toEqual(3);
Expand All @@ -270,7 +271,7 @@ describe("version update thoroughness", () => {
setup.changesets,
setup.workspaces,
setup.dependentsGraph,
{}
defaultConfig
);

expect(releases.length).toEqual(4);
Expand Down Expand Up @@ -299,7 +300,7 @@ describe("bumping peerDeps", () => {
setup.changesets,
setup.workspaces,
setup.dependentsGraph,
{}
defaultConfig
);

expect(releases.length).toBe(2);
Expand All @@ -315,7 +316,7 @@ describe("bumping peerDeps", () => {
setup.changesets,
setup.workspaces,
setup.dependentsGraph,
{}
defaultConfig
);

expect(releases.length).toBe(1);
Expand All @@ -333,7 +334,7 @@ describe("bumping peerDeps", () => {
setup.changesets,
setup.workspaces,
setup.dependentsGraph,
{}
defaultConfig
);

expect(releases.length).toBe(2);
Expand All @@ -353,7 +354,7 @@ describe("bumping peerDeps", () => {
setup.changesets,
setup.workspaces,
setup.dependentsGraph,
{}
defaultConfig
);

expect(releases.length).toBe(2);
Expand All @@ -369,7 +370,7 @@ describe("bumping peerDeps", () => {
setup.changesets,
setup.workspaces,
setup.dependentsGraph,
{}
defaultConfig
);

expect(releases.length).toBe(1);
Expand All @@ -387,7 +388,7 @@ describe("bumping peerDeps", () => {
setup.changesets,
setup.workspaces,
setup.dependentsGraph,
{}
defaultConfig
);

expect(releases.length).toBe(2);
Expand All @@ -407,7 +408,7 @@ describe("bumping peerDeps", () => {
setup.changesets,
setup.workspaces,
setup.dependentsGraph,
{}
defaultConfig
);

expect(releases.length).toBe(2);
Expand All @@ -429,7 +430,7 @@ describe("bumping peerDeps", () => {
setup.changesets,
setup.workspaces,
setup.dependentsGraph,
{}
defaultConfig
);

expect(releases.length).toBe(3);
Expand Down
21 changes: 21 additions & 0 deletions packages/config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# @changesets/config

> Utilities for reading and parsing Changeset's config
```tsx
import { parse, read, ValidationError } from "@changesets/config";

let config = await read(process.cwd(), workspaces);

let config = parse({ commit: true }, workspaces);

try {
return parse({ commit: true }, workspaces);
} catch (err) {
if (err instanceof ValidationError) {
let message = err.message;
} else {
throw err;
}
}
```
21 changes: 21 additions & 0 deletions packages/config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@changesets/config",
"version": "0.0.0",
"description": "Utilities for reading and parsing Changeset's config",
"main": "dist/config.cjs.js",
"module": "dist/config.esm.js",
"license": "MIT",
"repository": "https://github.com/changesets/changesets/tree/master/packages/config",
"files": [
"dist",
"schema.json"
],
"dependencies": {
"@changesets/types": "^0.0.0",
"fs-extra": "^7.0.1"
},
"devDependencies": {
"fixturez": "^1.1.0",
"jest-in-case": "^1.0.2"
}
}
Loading

0 comments on commit 519b421

Please sign in to comment.