@changesets/assemble-release-plan
Advanced tools
Comparing version 2.0.4 to 2.1.0
# @changesets/assemble-release-plan | ||
## 2.1.0 | ||
### Minor Changes | ||
- [`6d0790a`](https://github.com/atlassian/changesets/commit/6d0790a7aa9f00e350e9394f419e4b3c7ee7ca6a) [#359](https://github.com/atlassian/changesets/pull/359) Thanks [@ajaymathur](https://github.com/ajaymathur)! - Add support for snapshot flag to version command. Usage: `changeset version --snapshot [tag]`. The updated version of the packages looks like `0.0.0[-tag]-YYYYMMDDHHMMSS` where YYYY, MM, DD, HH, MM, and SS is the date and time of when the snapshot version is created. You can use this feature with the tag option in the publish command to publish packages under experimental tags from feature branches. To publish a snapshot version of a package under an experimental tag you can do: | ||
``` | ||
$ # Version packages to snapshot version | ||
$ changeset version --snapshot | ||
$ # Publish packages under exprimental tag, keeping next and latest tag clean | ||
$ changeset publish --tag exprimental | ||
``` | ||
## 2.0.4 | ||
@@ -4,0 +17,0 @@ |
@@ -280,7 +280,30 @@ 'use strict'; | ||
} | ||
/** | ||
* Using version as 0.0.0 so that it does not hinder with other version release | ||
* For example; | ||
* if user has a regular pre-release at 1.0.0-beta.0 and then you had a snapshot pre-release at 1.0.0-canary-git-hash | ||
* and a consumer is using the range ^1.0.0-beta, most people would expect that range to resolve to 1.0.0-beta.0 | ||
* but it'll actually resolve to 1.0.0-canary-hash. Using 0.0.0 solves this problem because it won't conflict with other versions. | ||
*/ | ||
function assembleReleasePlan(changesets, packages, config, preState) { | ||
function getSnapshotReleaseVersion(snapshot) { | ||
const now = new Date(); | ||
let dateAndTime = [now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds()].join(""); | ||
let tag = ""; | ||
if (typeof snapshot === "string") tag = `-${snapshot}`; | ||
return `0.0.0${tag}-${dateAndTime}`; | ||
} | ||
function assembleReleasePlan(changesets, packages, config, preState, snapshot) { | ||
let updatedPreState = preState === undefined ? undefined : _objectSpread({}, preState, { | ||
initialVersions: _objectSpread({}, preState.initialVersions) | ||
}); | ||
}); // Caching the snapshot version here and use this if it is snapshot release | ||
let snapshotVersion; | ||
if (snapshot !== undefined) { | ||
snapshotVersion = getSnapshotReleaseVersion(snapshot); | ||
} | ||
let packagesByName = new Map(packages.packages.map(x => [x.packageJson.name, x])); | ||
@@ -391,3 +414,3 @@ let unfilteredChangesets = changesets; | ||
return _objectSpread({}, incompleteRelease, { | ||
newVersion: incrementVersion(incompleteRelease, preInfo) | ||
newVersion: snapshot === undefined ? incrementVersion(incompleteRelease, preInfo) : snapshotVersion | ||
}); | ||
@@ -394,0 +417,0 @@ }), |
@@ -149,6 +149,14 @@ "use strict"; | ||
function assembleReleasePlan(changesets, packages, config, preState) { | ||
let updatedPreState = void 0 === preState ? void 0 : _objectSpread({}, preState, { | ||
function getSnapshotReleaseVersion(snapshot) { | ||
const now = new Date; | ||
let tag = ""; | ||
return "string" == typeof snapshot && (tag = `-${snapshot}`), `0.0.0${tag}-${[ now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds() ].join("")}`; | ||
} | ||
function assembleReleasePlan(changesets, packages, config, preState, snapshot) { | ||
let snapshotVersion, updatedPreState = void 0 === preState ? void 0 : _objectSpread({}, preState, { | ||
initialVersions: _objectSpread({}, preState.initialVersions) | ||
}), packagesByName = new Map(packages.packages.map(x => [ x.packageJson.name, x ])), unfilteredChangesets = changesets, preVersions = new Map; | ||
}); | ||
void 0 !== snapshot && (snapshotVersion = getSnapshotReleaseVersion(snapshot)); | ||
let packagesByName = new Map(packages.packages.map(x => [ x.packageJson.name, x ])), unfilteredChangesets = changesets, preVersions = new Map; | ||
if (void 0 !== updatedPreState) { | ||
@@ -199,3 +207,3 @@ for (let pkg of packages.packages) void 0 === updatedPreState.initialVersions[pkg.packageJson.name] && (updatedPreState.initialVersions[pkg.packageJson.name] = pkg.packageJson.version); | ||
releases: [ ...releases.values() ].map(incompleteRelease => _objectSpread({}, incompleteRelease, { | ||
newVersion: incrementVersion(incompleteRelease, preInfo) | ||
newVersion: void 0 === snapshot ? incrementVersion(incompleteRelease, preInfo) : snapshotVersion | ||
})), | ||
@@ -202,0 +210,0 @@ preState: updatedPreState |
@@ -273,7 +273,30 @@ import semver__default, { inc, parse } from 'semver'; | ||
} | ||
/** | ||
* Using version as 0.0.0 so that it does not hinder with other version release | ||
* For example; | ||
* if user has a regular pre-release at 1.0.0-beta.0 and then you had a snapshot pre-release at 1.0.0-canary-git-hash | ||
* and a consumer is using the range ^1.0.0-beta, most people would expect that range to resolve to 1.0.0-beta.0 | ||
* but it'll actually resolve to 1.0.0-canary-hash. Using 0.0.0 solves this problem because it won't conflict with other versions. | ||
*/ | ||
function assembleReleasePlan(changesets, packages, config, preState) { | ||
function getSnapshotReleaseVersion(snapshot) { | ||
const now = new Date(); | ||
let dateAndTime = [now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds()].join(""); | ||
let tag = ""; | ||
if (typeof snapshot === "string") tag = `-${snapshot}`; | ||
return `0.0.0${tag}-${dateAndTime}`; | ||
} | ||
function assembleReleasePlan(changesets, packages, config, preState, snapshot) { | ||
let updatedPreState = preState === undefined ? undefined : _objectSpread({}, preState, { | ||
initialVersions: _objectSpread({}, preState.initialVersions) | ||
}); | ||
}); // Caching the snapshot version here and use this if it is snapshot release | ||
let snapshotVersion; | ||
if (snapshot !== undefined) { | ||
snapshotVersion = getSnapshotReleaseVersion(snapshot); | ||
} | ||
let packagesByName = new Map(packages.packages.map(x => [x.packageJson.name, x])); | ||
@@ -384,3 +407,3 @@ let unfilteredChangesets = changesets; | ||
return _objectSpread({}, incompleteRelease, { | ||
newVersion: incrementVersion(incompleteRelease, preInfo) | ||
newVersion: snapshot === undefined ? incrementVersion(incompleteRelease, preInfo) : snapshotVersion | ||
}); | ||
@@ -387,0 +410,0 @@ }), |
import { ReleasePlan, Config, NewChangeset, PreState } from "@changesets/types"; | ||
import { Packages } from "@manypkg/get-packages"; | ||
declare function assembleReleasePlan(changesets: NewChangeset[], packages: Packages, config: Config, preState: PreState | undefined): ReleasePlan; | ||
declare function assembleReleasePlan(changesets: NewChangeset[], packages: Packages, config: Config, preState: PreState | undefined, snapshot?: string | boolean): ReleasePlan; | ||
export default assembleReleasePlan; |
{ | ||
"name": "@changesets/assemble-release-plan", | ||
"version": "2.0.4", | ||
"version": "2.1.0", | ||
"description": "Reads changesets and adds information on dependents that need bumping", | ||
@@ -5,0 +5,0 @@ "main": "dist/assemble-release-plan.cjs.js", |
@@ -23,2 +23,27 @@ import { ReleasePlan, Config, NewChangeset, PreState } from "@changesets/types"; | ||
/** | ||
* Using version as 0.0.0 so that it does not hinder with other version release | ||
* For example; | ||
* if user has a regular pre-release at 1.0.0-beta.0 and then you had a snapshot pre-release at 1.0.0-canary-git-hash | ||
* and a consumer is using the range ^1.0.0-beta, most people would expect that range to resolve to 1.0.0-beta.0 | ||
* but it'll actually resolve to 1.0.0-canary-hash. Using 0.0.0 solves this problem because it won't conflict with other versions. | ||
*/ | ||
function getSnapshotReleaseVersion(snapshot?: string | boolean) { | ||
const now = new Date(); | ||
let dateAndTime = [ | ||
now.getUTCFullYear(), | ||
now.getUTCMonth(), | ||
now.getUTCDate(), | ||
now.getUTCHours(), | ||
now.getUTCMinutes(), | ||
now.getUTCSeconds() | ||
].join(""); | ||
let tag = ""; | ||
if (typeof snapshot === "string") tag = `-${snapshot}`; | ||
return `0.0.0${tag}-${dateAndTime}`; | ||
} | ||
function assembleReleasePlan( | ||
@@ -28,3 +53,4 @@ changesets: NewChangeset[], | ||
config: Config, | ||
preState: PreState | undefined | ||
preState: PreState | undefined, | ||
snapshot?: string | boolean | ||
): ReleasePlan { | ||
@@ -41,2 +67,8 @@ let updatedPreState: PreState | undefined = | ||
// Caching the snapshot version here and use this if it is snapshot release | ||
let snapshotVersion: string; | ||
if (snapshot !== undefined) { | ||
snapshotVersion = getSnapshotReleaseVersion(snapshot); | ||
} | ||
let packagesByName = new Map( | ||
@@ -177,3 +209,6 @@ packages.packages.map(x => [x.packageJson.name, x]) | ||
...incompleteRelease, | ||
newVersion: incrementVersion(incompleteRelease, preInfo)! | ||
newVersion: | ||
snapshot === undefined | ||
? incrementVersion(incompleteRelease, preInfo)! | ||
: snapshotVersion | ||
}; | ||
@@ -180,0 +215,0 @@ }), |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
98143
2072