Skip to content

Commit

Permalink
Adding back a simpler "postversion" script to "realm-web"
Browse files Browse the repository at this point in the history
  • Loading branch information
kraenhansen committed May 30, 2024
1 parent 21d9038 commit e09b658
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
3 changes: 1 addition & 2 deletions packages/realm-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"start": "npm run bundle -- --watch",
"lint": "eslint --ext .js,.ts .",
"test": "mocha",
"postversion": "tsx scripts/postversion.ts",
"docs": "wireit"
},
"wireit": {
Expand Down Expand Up @@ -89,11 +90,9 @@
"devDependencies": {
"@realm/fetch": "^0.1.0",
"@types/chai": "^4.2.9",
"@types/fs-extra": "^11.0.4",
"@types/js-base64": "^3.3.1",
"@types/mocha": "^10.0.6",
"chai": "4.3.6",
"fs-extra": "^11.2.0",
"mocha": "^10.2.0"
},
"engines": {
Expand Down
32 changes: 32 additions & 0 deletions packages/realm-web/scripts/postversion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
////////////////////////////////////////////////////////////////////////////
//
// Copyright 2024 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////

import fs from "node:fs";
import path from "node:path";

const version = process.env.npm_package_version as string;
if (typeof version !== "string") {
throw new Error("Failed to determine package version");
}

const readmePath = path.resolve(__dirname, "../README.md");

// Update the readme file to use the new version in the script-tag.
const readmeContent = fs.readFileSync(readmePath, "utf8");
const readmeContentReplaced = readmeContent.replace(/realm-web@[^"/]+/, `realm-web@${version}`);
fs.writeFileSync(readmePath, readmeContentReplaced);
6 changes: 6 additions & 0 deletions packages/realm-web/scripts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"noResolve": false
},
}

0 comments on commit e09b658

Please sign in to comment.