Skip to content

Commit a81160d

Browse files
author
Konstantine Kalbazov
committed
Fix CI script for version syncing
1 parent 0a252e7 commit a81160d

File tree

11 files changed

+115
-176
lines changed

11 files changed

+115
-176
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,28 @@ jobs:
4444
VERSION=$(cat package.json | jq -r .version)
4545
echo "Using version: $VERSION"
4646
# Update all workspace package versions to match root package.json
47-
bun x workspaces-update-version $VERSION --force-publish --no-git-tag-version --no-push --yes
47+
for pkg in packages/*/package.json; do
48+
jq --arg version "$VERSION" '.version = $version' "$pkg" > tmp.$$.json && mv tmp.$$.json "$pkg"
49+
done
4850
4951
- name: Building for production
5052
env:
5153
NODE_ENV: production
5254
SKIP_PREFLIGHT_CHECK: 'true'
53-
run: bun run build --if-present
55+
run: |
56+
bun run --cwd=packages/component build
57+
bun run --cwd=packages/playground build
5458
5559
- name: Copying documents
5660
run: |
5761
cp CHANGELOG.md packages/component
5862
cp LICENSE packages/component
5963
cp README.md packages/component
6064
61-
- name: Running bun pack
65+
- name: Running npm pack
6266
run: |
6367
cd packages/component
64-
bun pack
68+
npm pack
6569
6670
- name: Uploading npm-tarball
6771
uses: actions/upload-artifact@v4
@@ -73,7 +77,7 @@ jobs:
7377
uses: actions/upload-artifact@v4
7478
with:
7579
name: gh-pages
76-
path: 'packages/playground/build/**/*'
80+
path: 'packages/playground/dist/**/*'
7781

7882
# "test" job will only run when not deploying, will build for instrumentation.
7983
test:
@@ -105,7 +109,9 @@ jobs:
105109
VERSION=$(cat package.json | jq -r .version)
106110
echo "Using version: $VERSION"
107111
# Update all workspace package versions to match root package.json
108-
bun x workspaces-update-version $VERSION --force-publish --no-git-tag-version --no-push --yes
112+
for pkg in packages/*/package.json; do
113+
jq --arg version "$VERSION" '.version = $version' "$pkg" > tmp.$$.json && mv tmp.$$.json "$pkg"
114+
done
109115
110116
- name: Running static code analysis
111117
run: |
@@ -116,7 +122,7 @@ jobs:
116122
env:
117123
NODE_ENV: test
118124
SKIP_PREFLIGHT_CHECK: 'true'
119-
run: bun run build --if-present
125+
run: bun run --cwd=packages/component build:full
120126

121127
- name: Starting Docker Compose
122128
run: bun run docker:up -- --detach
@@ -164,7 +170,7 @@ jobs:
164170
- name: Publishing ${{ steps.read-package-json.outputs.name }}@${{ steps.read-package-json.outputs.version }}
165171
run: |
166172
bun config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
167-
bun publish *.tgz --tag main
173+
bun publish *.tgz --tag main --access public
168174
169175
- name: Tagging dist-tag ${{ steps.read-package-json.outputs.name }}@${{ steps.read-package-json.outputs.version }} latest
170176
if: ${{ startsWith(github.ref, 'refs/tags/') }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/coverage
44
/lib
55
node_modules/
6+
dist/

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Try out the demo at [https://compulim.github.io/react-scroll-to-bottom/](https:/
2727

2828
```jsx
2929
import { css } from 'emotion';
30-
import ScrollToBottom from 'react-scroll-to-bottom';
30+
import ScrollToBottom from '@koteus/react-scroll-to-bottom';
3131

3232
const ROOT_CSS = css({
3333
height: 600,
@@ -184,7 +184,7 @@ The following sample code will put a button inside the content view only if the
184184
> Note: `useScrollToBottom` can only be called inside components hosted under `<ScrollToBottom>`.
185185
186186
```jsx
187-
import ScrollToBottom, { useScrollToBottom, useSticky } from 'react-scroll-to-bottom';
187+
import ScrollToBottom, { useScrollToBottom, useSticky } from '@koteus/react-scroll-to-bottom';
188188

189189
const Content = () => {
190190
const scrollToBottom = useScrollToBottom();
@@ -331,7 +331,7 @@ This context contains state of the container.
331331
The following sample code will put a button inside the content view only if the view is not at the bottom. When the button is clicked, it will scroll the view to the bottom.
332332

333333
```jsx
334-
import ScrollToBottom from 'react-scroll-to-bottom';
334+
import ScrollToBottom from '@koteus/react-scroll-to-bottom';
335335

336336
const Content = ({ scrollToBottom, sticky }) => {
337337
return (

bun.lock

Lines changed: 67 additions & 110 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{
22
"name": "root",
3-
"version": "5.0.0-0",
3+
"version": "5.0.0-beta",
44
"description": "React container that will auto scroll to bottom",
55
"private": true,
66
"workspaces": ["packages/*"],
77
"scripts": {
88
"browser": "node packages/test-harness/src/host/dev/index.js http://localhost:5000/__tests__/",
9-
"build:packages": "bun run --workspace=packages/component --workspace=packages/test-harness --workspace=packages/playground build",
109
"docker": "concurrently \"bun run docker:up\" \"bun run docker:watch\"",
1110
"docker:down": "docker-compose down --rmi all",
1211
"docker:up": "docker-compose down && docker-compose build --parallel && docker-compose up --scale chromium=2",

packages/component/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "react-scroll-to-bottom",
2+
"name": "@koteus/react-scroll-to-bottom",
33
"version": "0.0.0-0",
44
"description": "React container that will auto scroll to bottom",
55
"keywords": [
@@ -18,18 +18,18 @@
1818
],
1919
"main": "lib/index.js",
2020
"module": "lib/esm/index.js",
21+
"types": "lib/index.d.ts",
2122
"files": [
2223
"lib/**/*"
2324
],
2425
"scripts": {
25-
"build": "vite build && BROWSER_BUILD=true vite build && bun run build:test-harness",
26+
"build": "vite build",
27+
"build:watch": "vite build --watch",
28+
"build:full": "vite build && bun run build:test-harness",
2629
"build:test-harness": "cp ../test-harness/dist/* dist/ || true",
27-
"build:dev": "vite build --watch",
30+
"start:test-harness": "nodemon --exec \"bun run build:test-harness\" --watch ../test-harness/dist",
2831
"eslint": "eslint src/**/*.js --ignore-pattern *.spec.js --ignore-pattern *.test.js",
29-
"precommit": "eslint",
30-
"start": "concurrently \"bun run start:*\"",
31-
"start:vite": "vite build --watch",
32-
"start:test-harness": "nodemon --exec \"bun run build:test-harness\" --watch ../test-harness/dist"
32+
"precommit": "eslint"
3333
},
3434
"author": "William Wong <[email protected]> (http://compulim.info/)",
3535
"license": "MIT",

packages/component/vite.config.mjs

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,64 +4,42 @@ import { defineConfig } from 'vite';
44
import react from '@vitejs/plugin-react';
55
import dts from 'vite-plugin-dts';
66

7-
const __filename = fileURLToPath(import.meta.url);
8-
const __dirname = dirname(__filename);
7+
const __dirname = dirname(fileURLToPath(import.meta.url));
98
const pkgVersion = process.env.npm_package_version || '0.0.0';
109

11-
// Check if we're building the browser bundle
12-
const isBrowserBuild = process.env.BROWSER_BUILD === 'true';
13-
1410
export default defineConfig({
1511
plugins: [
1612
react({
1713
// Include .js files that contain JSX
1814
include: /\.(jsx|js)$/
1915
}),
20-
!isBrowserBuild && dts({
16+
dts({
2117
include: ['src/**/*.js'],
22-
beforeWriteFile: (filePath, content) => {
23-
return {
24-
filePath: filePath.replace('.d.ts', '.d.ts'),
25-
content
26-
};
27-
}
18+
beforeWriteFile: (filePath, content) => ({
19+
filePath: filePath.replace('.d.ts', '.d.ts'),
20+
content
21+
})
2822
})
2923
],
3024
define: {
3125
'process.env.VITE_APP_VERSION': JSON.stringify(pkgVersion)
3226
},
33-
build: isBrowserBuild ? {
34-
outDir: 'dist',
27+
build: {
3528
lib: {
36-
entry: resolve(__dirname, 'src/browser.js'),
29+
entry: resolve(__dirname, 'src/index.js'),
3730
name: 'ReactScrollToBottom',
38-
formats: ['umd'],
39-
fileName: () => 'react-scroll-to-bottom.development.js'
40-
},
41-
rollupOptions: {
42-
external: ['react', 'react-dom'],
43-
output: {
44-
globals: {
45-
react: 'React',
46-
'react-dom': 'ReactDOM'
31+
formats: ['es', 'cjs', 'umd'],
32+
fileName: (format) => {
33+
switch (format) {
34+
case 'es':
35+
return `esm/index.js`;
36+
case 'cjs':
37+
return `index.js`;
38+
case 'umd':
39+
return `dist/react-scroll-to-bottom.development.js`;
4740
}
4841
}
4942
},
50-
sourcemap: true,
51-
minify: false
52-
} : {
53-
lib: {
54-
entry: {
55-
index: resolve(__dirname, 'src/index.js'),
56-
browser: resolve(__dirname, 'src/browser.js')
57-
},
58-
formats: ['es', 'cjs'],
59-
fileName: (format, entryName) => {
60-
return format === 'es'
61-
? `esm/${entryName}.js`
62-
: `${entryName}.js`;
63-
}
64-
},
6543
rollupOptions: {
6644
external: ['react', 'react-dom', 'classnames', 'math-random', 'simple-update-in'],
6745
output: {
@@ -75,8 +53,6 @@ export default defineConfig({
7553
exports: 'named'
7654
}
7755
},
78-
target: 'es2020',
79-
outDir: 'lib',
8056
sourcemap: true,
8157
minify: false
8258
},

packages/playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"react": "^19.1.0",
1111
"react-dom": "^19.1.0",
1212
"react-interval": "^2.1.2",
13-
"react-scroll-to-bottom": "workspace:*"
13+
"@koteus/react-scroll-to-bottom": "workspace:*"
1414
},
1515
"devDependencies": {
1616
"@testing-library/jest-dom": "^6.4.0",

packages/playground/src/App.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import { LoremIpsum, loremIpsum } from 'lorem-ipsum';
44
import React, { useCallback, useEffect, useMemo, useState } from 'react';
5-
import ReactScrollToBottom, { StateContext } from 'react-scroll-to-bottom';
6-
import 'react-scroll-to-bottom/lib/style.css';
5+
import ReactScrollToBottom, { StateContext } from '@koteus/react-scroll-to-bottom';
6+
import '@koteus/react-scroll-to-bottom/lib/style.css';
77

88
import classNames from 'classnames';
99
import Interval from 'react-interval';

packages/playground/src/CommandBar.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
useScrollToEnd,
99
useScrollToStart,
1010
useScrollToTop
11-
} from 'react-scroll-to-bottom';
11+
} from '@koteus/react-scroll-to-bottom';
1212

1313
import styles from './CommandBar.module.css';
1414

0 commit comments

Comments
 (0)