Skip to content

Commit b44cc18

Browse files
authored
feat(ui-components): prepublish (#7955)
* feat(ui-components): prepublish * fix css * undo un-needed tsconfig changes Signed-off-by: Aviv Keller <[email protected]> * add code comment Signed-off-by: Aviv Keller <[email protected]> * ts-ignore root-level files --------- Signed-off-by: Aviv Keller <[email protected]>
1 parent 6eace68 commit b44cc18

File tree

11 files changed

+218
-19
lines changed

11 files changed

+218
-19
lines changed

.github/workflows/publish-packages.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,14 @@ jobs:
119119
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
120120
run: |
121121
# Create a unique version using the commit SHA as a prerelease identifier
122-
# This ensures we can publish multiple times from the same codebase with unique versions
123122
npm version --no-git-tag-version 1.0.1-$COMMIT_SHA
124-
# Publish the package to the npm registry with public access flag
125-
pnpm publish --access public --no-git-checks
123+
124+
# Check if a custom publish script exists in package.json
125+
if jq -e '.scripts.publish' package.json > /dev/null; then
126+
pnpm run publish
127+
else
128+
pnpm publish --access public --no-git-checks
129+
fi
126130
127131
- name: Notify on Manual Release
128132
if: ${{ github.event_name == 'workflow_dispatch' }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ apps/site/public/blog-data.json
1717
junit.xml
1818
lcov.info
1919

20+
# Distributed Files
21+
dist
22+
2023
# Storybook
2124
storybook-static
2225
build-storybook.log

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ CODEOWNERS
3939
# Public Folders
4040
apps/site/public
4141

42+
# Distributed Files
43+
dist
44+
4245
# Prettier's Handlebar parser is limited and chokes on some syntax features
4346
# https://github.com/prettier/prettier/issues/11834
4447
scripts/release-post/template.hbs

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default [
1818
'**/.open-next',
1919
'test-results',
2020
'playwright-report',
21+
'dist',
2122
],
2223
},
2324
{
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
storybook-static
2+
dist

packages/ui-components/package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
]
1212
},
1313
"scripts": {
14+
"compile:ts": "tsc",
15+
"compile:css": "postcss --dir dist --base src \"src/**/*.module.css\" src/styles/index.css",
16+
"compile": "node --run compile:ts && node --run compile:css",
17+
"publish": "node --run compile && node scripts/publish.mjs",
1418
"lint": "turbo run lint:js lint:css",
1519
"lint:css": "stylelint \"**/*.css\" --allow-empty-input --cache --cache-strategy=content --cache-location=.stylelintcache",
1620
"lint:fix": "node --run lint -- -- --fix",
@@ -33,13 +37,13 @@
3337
"@radix-ui/react-tabs": "~1.1.12",
3438
"@radix-ui/react-toast": "~1.2.14",
3539
"@radix-ui/react-tooltip": "~1.2.7",
36-
"@tailwindcss/postcss": "~4.1.11",
3740
"@vcarl/remark-headings": "~0.1.0",
38-
"classnames": "catalog:",
39-
"postcss-calc": "^10.1.1",
40-
"tailwindcss": "catalog:"
41+
"classnames": "catalog:"
4142
},
4243
"devDependencies": {
44+
"@tailwindcss/postcss": "~4.1.11",
45+
"postcss-calc": "^10.1.1",
46+
"tailwindcss": "catalog:",
4347
"@storybook/addon-styling-webpack": "^2.0.0",
4448
"@storybook/addon-themes": "^9.0.15",
4549
"@storybook/addon-webpack5-compiler-swc": "^3.0.0",
@@ -53,6 +57,7 @@
5357
"eslint-plugin-react": "~7.37.4",
5458
"eslint-plugin-storybook": "~9.0.3",
5559
"global-jsdom": "^26.0.0",
60+
"postcss-cli": "^11.0.1",
5661
"postcss-loader": "~8.1.1",
5762
"react": "catalog:",
5863
"storybook": "^9.0.15",

packages/ui-components/src/Common/BasePagination/PaginationListItem/__tests__/index.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import assert from 'node:assert/strict';
33

44
import { render, screen } from '@testing-library/react';
55

6+
// @ts-ignore this file is intentionally stored outside of the `rootDir`
67
import { isVisible } from '../../../../../../../tests/utilities.mjs';
78

89
import PaginationListItem from '#ui/Common/BasePagination/PaginationListItem';

packages/ui-components/src/Common/BasePagination/__tests__/index.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import assert from 'node:assert/strict';
33

44
import { render, screen } from '@testing-library/react';
55

6+
// @ts-ignore this file is intentionally stored outside of the `rootDir`
67
import { isVisible } from '../../../../../../tests/utilities.mjs';
78

89
import BasePagination from '#ui/Common/BasePagination';
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { spawnSync } from 'node:child_process';
2+
import { writeFile } from 'node:fs/promises';
3+
4+
import pkg from '../package.json' with { type: 'json' };
5+
6+
// Strip the devDependencies, since they aren't needed for publish
7+
// Strip the exports, since we don't want to reference './src'
8+
/* eslint-disable @typescript-eslint/no-unused-vars */
9+
const { devDependencies, exports, ...cleanedPkg } = pkg;
10+
// Change `#ui` to `./` from `./src`, since we are publishing
11+
// from the same directory as the source code (rather, the compiled code).
12+
cleanedPkg.imports['#ui/*'] = ['./*'];
13+
14+
await writeFile(
15+
'dist/package.json',
16+
JSON.stringify(cleanedPkg, null, 2),
17+
'utf8'
18+
);
19+
20+
// Now, publish the generated `dist` folder
21+
spawnSync('pnpm', ['publish'], { cwd: 'dist', stdio: 'inherit' });

packages/ui-components/tsconfig.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
"skipLibCheck": true,
77
"strict": true,
88
"forceConsistentCasingInFileNames": true,
9-
"noEmit": true,
109
"esModuleInterop": true,
1110
"module": "esnext",
1211
"moduleResolution": "Bundler",
1312
"resolveJsonModule": true,
1413
"isolatedModules": true,
15-
"jsx": "preserve",
14+
"jsx": "react-jsx",
1615
"incremental": true,
17-
"baseUrl": "."
16+
"baseUrl": "./src",
17+
"rootDir": "./src",
18+
"outDir": "./dist"
1819
},
1920
"include": ["src"]
2021
}

0 commit comments

Comments
 (0)