Skip to content

Commit

Permalink
fix: replace-version script
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-chillios committed Feb 19, 2025
1 parent 2c3269d commit 8f8feee
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 12 deletions.
10 changes: 10 additions & 0 deletions .changeset/few-islands-ask.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@swapkit/toolboxes": major
"@swapkit/helpers": major
"@swapkit/plugins": major
"@swapkit/wallets": major
"@swapkit/core": major
"@swapkit/sdk": major
---

v4 core first beta
9 changes: 9 additions & 0 deletions .github/workflows/build-test-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ jobs:
publish: bun publish-packages
setupGitUser: false

- name: Publish Beta to npm
uses: changesets/action@v1
if: contains(github.ref_name, 'beta')
with:
title: ":tada: Publish Beta"
version: bun version-bump
publish: bun publish-packages
setupGitUser: false

- name: Publish Nightly to npm
uses: changesets/action@v1
if: contains(github.ref_name, 'nightly')
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"playground:node": "bun --cwd ./playgrounds/node",
"playground:vite": "bun --cwd ./playgrounds/vite",
"postinstall": "lefthook install; bun lint:ws",
"publish-packages": "bun run build && bun version-bump && bun changeset publish",
"publish-packages": "bun build:ci && bun version-bump && bun changeset publish",
"test": "bun --filter '*' --elide-lines=0 test",
"test:ci": "bun --filter '*' test:ci",
"test:coverage": "bun --filter '*' --elide-lines=0 test:ci",
Expand Down
24 changes: 13 additions & 11 deletions scripts/replace-versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,29 @@ const onlyPackageJson = files.filter(
(file) => !file.includes("node_modules") && file.endsWith("package.json"),
);

const versions = {};
const versions: Record<string, string> = {};

for (const file of onlyPackageJson) {
const { version } = await import(`../packages/${file}`);
const [, name] = file.split("/");
const [name] = file.split("/");

const packageName = `@swapkit/${name}`;

versions[packageName] = version;
}

for (const file of onlyPackageJson) {
// @ts-expect-error
const packageJson = Bun.file(`./packages/${file}`);
const content = await packageJson.text();
const pkgContent = await Bun.file(`./packages/${file}`).json();

const replacedContent = content.replace(
/"(@swapkit\/[^"]+)": "[^"]+"/g,
(_, p1) => `"${p1}": "${versions[p1]}"`,
);
for (const [key, value] of Object.entries(versions)) {
if (pkgContent.dependencies?.[key]) {
pkgContent.dependencies[key] = value;
}

// @ts-expect-error
await Bun.write(`./packages/${file}`, replacedContent);
if (pkgContent.devDependencies?.[key]) {
pkgContent.devDependencies[key] = value;
}

await Bun.write(`./packages/${file}`, JSON.stringify(pkgContent, null, 2));
}
}
7 changes: 7 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tools/typescript/base.json",
"compilerOptions": {
"types": ["bun-types"]
},
"include": ["**/*.ts"]
}

0 comments on commit 8f8feee

Please sign in to comment.