Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
48 changes: 9 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,62 +56,32 @@ jobs:
id: vars
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Update workspace versions to -<commit-hash>
- name: Update package version to -<commit-hash>
env:
PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }}-experimental-${{ env.COMMIT_HASH }}
run: |
node <<'NODE'
const fs = require("node:fs");
const path = require("node:path");

const packagesDir = path.join(process.cwd(), "packages");
const version = process.env.PACKAGE_VERSION;
const packages = fs
.readdirSync(packagesDir)
.filter((dir) => fs.existsSync(path.join(packagesDir, dir, "package.json")))
.map((dir) => {
const packageJsonPath = path.join(packagesDir, dir, "package.json");
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
return { packageJsonPath, packageJson };
});
const workspaceNames = new Set(packages.map(({ packageJson }) => packageJson.name));

for (const { packageJsonPath, packageJson } of packages) {
packageJson.version = version;

for (const field of ["dependencies", "peerDependencies", "devDependencies"]) {
if (!packageJson[field]) continue;

for (const dependencyName of Object.keys(packageJson[field])) {
if (workspaceNames.has(dependencyName)) {
packageJson[field][dependencyName] = version;
}
}
}

fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`);
}
const packageJsonPath = "package.json";
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
packageJson.version = process.env.PACKAGE_VERSION;
fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`);
NODE

- name: Package npm workspaces
run: npm pack --workspaces
- name: Package npm package
run: npm pack

- name: Upload npm package artifact
uses: actions/upload-artifact@v7
with:
name: npm-packages
path: "*.tgz"

- name: Publish npm packages
- name: Publish npm package
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
run: |
for package in packages/*; do
if [ -f "$package/package.json" ]; then
npm publish --workspace "$package" --access public --tag experimental
fi
done
run: npm publish --access public --tag experimental

deploy-docs:
needs: build
Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
dist/
tmp/
docs/public/llm.txt
.npm-cache/
*.tgz
*~
.worktrees/

**/lib/bs/
**/lib/ocaml
Expand All @@ -14,4 +17,6 @@ docs/public/llm.txt

rescript.lock

**/*.res.js
src/**/*.js
tests/**/*.js
**/*.res.js
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@ and add `@rescript/webapi` to your `rescript.json`:
```json
{
"dependencies": [
+ "@rescript/webapi"
],
"compiler-flags": [
+ "-open WebAPI.Global"
"@rescript/webapi"
]
}
```

## Usage

```rescript
let location = WebAPI.Window.current->WebAPI.Window.location
let href = location.href
location->WebAPI.Location.reload
```

## Documentation

More information can be found on https://rescript-lang.github.io/experimental-rescript-webapi/
3 changes: 3 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export default defineConfig({
{
slug: "design-philosophy",
},
{
slug: "api-surface",
},
{
label: "Examples",
link: "examples",
Expand Down
Loading