Skip to content

Commit

Permalink
Merge pull request #235 from pimlicolabs/feat/alto-package
Browse files Browse the repository at this point in the history
release commonjs and esm
  • Loading branch information
plusminushalf authored Jun 6, 2024
2 parents d69b57e + 3e1bc26 commit 2098ed1
Show file tree
Hide file tree
Showing 16 changed files with 1,717 additions and 965 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/changelog-git",
"commit": false,
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
"onlyUpdatePeerDependentsWhenOutOfRange": true
}
}
5 changes: 5 additions & 0 deletions .changeset/nine-mirrors-play.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@pimlico/alto": patch
---

First releaseof alto bundler
41 changes: 41 additions & 0 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Release (Canary)
on:
push:
workflow_dispatch:

jobs:
canary:
name: Release canary
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Clone repository
uses: actions/checkout@v3

- name: Install dependencies
uses: ./.github/actions/install-dependencies


- name: Install test dependencies
run: pnpm install

- name: Setup .npmrc file
uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org'

- name: Set alto version
run: |
jq --arg prop "workspaces" 'del(.[$prop])' package.json > package.tmp.json && rm package.json && cp package.tmp.json package.json && rm package.tmp.json
cd src
npm --no-git-tag-version version 0.0.0
npm --no-git-tag-version version $(npm pkg get version | sed 's/"//g')-$(git branch --show-current | tr -cs '[:alnum:]-' '-' | tr '[:upper:]' '[:lower:]' | sed 's/-$//').$(date +'%Y%m%dT%H%M%S')
- name: Build
run: |
pnpm run build:esm && jq '. + {type: "module"}' ./src/package.json > ./src/package.tmp.json && mv ./src/package.tmp.json ./src/package.json
- name: Publish alto to npm
run: cd src && npm publish --access public --tag $(git branch --show-current | tr -cs '[:alnum:]-' '-' | tr '[:upper:]' '[:lower:]' | sed 's/-$//')
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ORG_PIMLICO_TOKEN }}
65 changes: 65 additions & 0 deletions .github/workflows/on-push-to-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Main
on:
push:
branches: [main]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build
uses: ./.github/workflows/build.yml
secrets: inherit

test:
name: Test E2E
uses: ./.github/workflows/e2e.yaml
secrets: inherit

changesets:
name: Changesets
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Clone repository
uses: actions/checkout@v3
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Install dependencies
uses: ./.github/actions/install-dependencies

- name: Create Version Pull Request
uses: changesets/action@v1
with:
version: pnpm run changeset:version
commit: 'chore: version package'
title: 'chore: version package'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release:
name: Release
needs: verify
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Clone repository
uses: actions/checkout@v3

- name: Install dependencies
uses: ./.github/actions/install-dependencies

- name: Publish to NPM
uses: changesets/action@v1
with:
publish: pnpm run changeset:release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_ORG_PIMLICO_TOKEN }}
57 changes: 57 additions & 0 deletions .github/workflows/prune-tags.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Prune NPM tags
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'

jobs:
prune:
name: Prune NPM tags
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v3

- uses: actions/setup-node@v4
with:
node-version: 'latest'

- name: Setup .npmrc file
uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org'

- name: Prune @pimlico/alto tags
run: |
PACKAGE_NAME=$(jq -r '.name' package.json)
npm view $PACKAGE_NAME dist-tags --json | jq -r 'to_entries | .[] | select(.key != "latest") | select(.key != "main") | select(.key != "next") | .key' | xargs -I % npm dist-tag rm $PACKAGE_NAME %
working-directory: src
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ORG_PIMLICO_TOKEN }}

- name: Deprecate @pimlico/alto canary versions
working-directory: src
run: |
PACKAGE_NAME=$(jq -r '.name' package.json)
TWO_DAYS_AGO=$(date --date='2 days ago' +%s)
FOUR_DAYS_AGO=$(date --date='4 days ago' +%s)
npm view $PACKAGE_NAME time --json | jq -c 'to_entries | .[] | select(.key | test("^0.0.0-.+$"))' \
| while read line; do
VERSION=$(echo $line | jq -r '.key')
TIME=$(echo $line | jq -r '.value')
PUBLISH_DATE=$(date --date=$TIME +%s)
if [ $PUBLISH_DATE -lt $FOUR_DAYS_AGO ]; then
continue # skip versions older than 4 days to reduce the number of npm deprecate calls
fi
if [ $PUBLISH_DATE -lt $TWO_DAYS_AGO ]; then
echo "Deprecate $PACKAGE_NAME@$VERSION"
npm deprecate $PACKAGE_NAME@$VERSION "This canary version is deprecated because it is older than 2 days." || true
echo "Deprecated $PACKAGE_NAME@$VERSION"
fi
done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ORG_PIMLICO_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ node_modules
dist
.nyc_output
src/lib
src/esm
**/.nyc_output
test/spec-tests/bundler-spec-tests
test/build
.DS_Store

.nx/cache
.vscode/
.sentryclirc
.sentryclirc
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@
"clean": "rm -rf ./src/lib ./src/*.tsbuildinfo",
"clean-modules": "rm -rf ./src/node_modules node_modules",
"build": "pnpm -r run build",
"build:esm": "pnpm -r run build:esm",
"start": "node src/lib/cli/alto.js run",
"dev": "pnpm -r run dev",
"test": "pnpm -r --workspace-concurrency 1 test --verbose=true",
"test:spec": "./test/spec-tests/run-spec-tests.sh",
"lint": "biome check .",
"lint:fix": "pnpm run lint --apply",
"format": "biome format . --write"
"format": "biome format . --write",
"changeset": "changeset",
"changeset:release": "pnpm run build && changeset publish",
"changeset:version": "changeset version && pnpm install --lockfile-only"
},
"devDependencies": {
"@biomejs/biome": "^1.5.1",
Expand All @@ -31,7 +35,10 @@
"nyc": "^15.1.0",
"rome": "^12.1.3",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
"typescript": "^5.3.3",
"@changesets/changelog-git": "^0.1.14",
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.2"
},
"private": true,
"engines": {
Expand Down
Loading

0 comments on commit 2098ed1

Please sign in to comment.