Skip to content

Commit 5b66ecb

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

21 files changed

+143
-283
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
/coverage
44
/lib
55
node_modules/
6+
dist/
7+
packages/playground/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/.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
/dist
2-
/lib
3-
/node_modules
1+
build/
2+
node_modules/

packages/component/package.json

Lines changed: 18 additions & 10 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": [
@@ -16,20 +16,28 @@
1616
"stick to top",
1717
"tail"
1818
],
19-
"main": "lib/index.js",
20-
"module": "lib/esm/index.js",
19+
"main": "build/index.js",
20+
"module": "build/esm/index.js",
21+
"types": "build/index.d.ts",
22+
"exports": {
23+
".": {
24+
"types": "./build/index.d.ts",
25+
"import": "./build/esm/index.js",
26+
"require": "./build/index.js"
27+
},
28+
"./style.css": "./build/style.css"
29+
},
2130
"files": [
22-
"lib/**/*"
31+
"build/**/*"
2332
],
2433
"scripts": {
25-
"build": "vite build && BROWSER_BUILD=true vite build && bun run build:test-harness",
34+
"build": "vite build",
35+
"build:watch": "vite build --watch",
36+
"build:full": "vite build && bun run build:test-harness",
2637
"build:test-harness": "cp ../test-harness/dist/* dist/ || true",
27-
"build:dev": "vite build --watch",
38+
"start:test-harness": "nodemon --exec \"bun run build:test-harness\" --watch ../test-harness/dist",
2839
"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"
40+
"precommit": "eslint"
3341
},
3442
"author": "William Wong <[email protected]> (http://compulim.info/)",
3543
"license": "MIT",

packages/component/vite.config.mjs

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,64 +4,43 @@ 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: {
28+
outDir: 'build',
3529
lib: {
36-
entry: resolve(__dirname, 'src/browser.js'),
30+
entry: resolve(__dirname, 'src/index.js'),
3731
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'
32+
formats: ['es', 'cjs', 'umd'],
33+
fileName: (format) => {
34+
switch (format) {
35+
case 'es':
36+
return `esm/index.js`;
37+
case 'cjs':
38+
return `index.js`;
39+
case 'umd':
40+
return `dist/react-scroll-to-bottom.development.js`;
4741
}
4842
}
4943
},
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-
},
6544
rollupOptions: {
6645
external: ['react', 'react-dom', 'classnames', 'math-random', 'simple-update-in'],
6746
output: {
@@ -75,8 +54,6 @@ export default defineConfig({
7554
exports: 'named'
7655
}
7756
},
78-
target: 'es2020',
79-
outDir: 'lib',
8057
sourcemap: true,
8158
minify: false
8259
},

packages/playground/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
# production
1212
/build
13+
dist/
1314

1415
# misc
1516
.DS_Store

0 commit comments

Comments
 (0)