Skip to content

Commit

Permalink
Update manuakl publish script for experimentals
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Feb 6, 2023
1 parent 442d4d8 commit 661e15a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"test:inspect": "node --inspect-brk ./node_modules/.bin/jest",
"changeset": "changeset",
"version": "changeset version",
"publish": "node scripts/publish.js",
"postversion": "node scripts/postversion.mjs",
"version:experimental": "node ./scripts/version experimental",
"watch": "rollup -c -w"
Expand Down
25 changes: 13 additions & 12 deletions scripts/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@ function getTaggedVersion() {
* @param {string|number} version
*/
async function ensureBuildVersion(packageName, version) {
let file = path.join(
rootDir,
"build",
"node_modules",
packageName,
"package.json"
);
let file = path.join(rootDir, "packages", packageName, "package.json");
let json = await jsonfile.readFile(file);
invariant(
json.version === version,
Expand All @@ -47,7 +41,7 @@ async function ensureBuildVersion(packageName, version) {
* @param {string} tag
*/
function publishBuild(packageName, tag) {
let buildDir = path.join(rootDir, "build", "node_modules", packageName);
let buildDir = path.join(rootDir, "packages", packageName);
console.log();
console.log(` npm publish ${buildDir} --tag ${tag} --access public`);
console.log();
Expand Down Expand Up @@ -75,25 +69,32 @@ async function run() {
);

// 2. Determine the appropriate npm tag to use
let tag = semver.prerelease(version) == null ? "latest" : "next";
let tag = version.includes("experimental")
? "experimental"
: semver.prerelease(version) == null
? "latest"
: "next";

console.log();
console.log(` Publishing version ${version} to npm with tag "${tag}"`);

// 3. Ensure build versions match the release version
if (version.includes("experimental")) {
// FIXME: @remix-run/router is versioned differently and is only handled
// for experimental releases here
await ensureBuildVersion("router", version);
}
await ensureBuildVersion("react-router", version);
await ensureBuildVersion("react-router-dom", version);
await ensureBuildVersion("react-router-dom-v5-compat", version);
await ensureBuildVersion("react-router-native", version);
// FIXME: @remix-run/router is versioned differently and isn't being
// validated here

// 4. Publish to npm
publishBuild("router", tag);
publishBuild("react-router", tag);
publishBuild("react-router-dom", tag);
publishBuild("react-router-dom-v5-compat", tag);
publishBuild("react-router-native", tag);
publishBuild("@remix-run/router", tag);
} catch (error) {
console.log();
console.error(` ${error.message}`);
Expand Down

0 comments on commit 661e15a

Please sign in to comment.