-
-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Deno support with Denoify #108
Open
garronej
wants to merge
17
commits into
gvergnaud:main
Choose a base branch
from
garronej:deno_support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+831
−6
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
9795ed3
[doc] fix typo in v3-to-v4-migration-guide.md
eltociear a2379c1
roadmap: add API for upcoming variadic tuple patterns
gvergnaud b3a9cdb
Update README.md
gvergnaud feca866
Fix example output mismatch
hexpunk 11f1480
Update README.md
gvergnaud 51c48fd
deps: update typescript to 4.8.3
gvergnaud 615b951
Setup Denoify
garronej b537ee0
Setup CI
garronej db5bf27
Add deno.land/x badge
garronej 33995c3
Remove prepublish script since it's done in the CI
garronej 03eb1ee
Remove yarn.lock since we use npm
garronej 7841523
Add import instruction for Deno
garronej 41e23d9
Merge branch 'main' into deno_support
garronej 4d2708a
Update lock files
garronej dac7bfe
Merge branch 'main' into deno_support
garronej 6b8b7ad
Add denoify to build script
garronej 756f923
Run CI on MacOS
garronej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
name: ci | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
|
||
test_node: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
node: [ '20' ] | ||
os: [ macos-latest ] | ||
name: Test with Node v${{ matrix.node }} on ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
- uses: bahmutov/npm-install@v1 | ||
- run: | | ||
npm run build | ||
npm test | ||
test_deno: | ||
runs-on: ubuntu-latest | ||
name: test with Deno | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: ~/.cache/deno | ||
key: deno-${{ runner.os }}-${{ hashFiles('deno-lock.json') }} | ||
restore-keys: | | ||
deno-${{ runner.os }}-${{ hashFiles('deno-lock.json') }} | ||
deno-${{ runner.os }}- | ||
deno- | ||
- uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: v1.x | ||
- run: deno --version | ||
# We don't actually execute any runtime check but at least we make sure that, typewise, everything's fine. | ||
- uses: bahmutov/npm-install@v1 | ||
- run: npx denoify | ||
- run: deno run --reload --unstable --no-check deno_dist/mod.ts | ||
|
||
check_if_version_upgraded: | ||
name: Check if version upgrade | ||
# When someone forks the repo and opens a PR we want to enables the tests to be run (the previous jobs) | ||
# but obviously only us should be allowed to release. | ||
# The following check is to make sure that we own the branch this CI workflow is running on before continuing. | ||
# If it wasn't the case, trying to release would fail anyway, only us have the correct secret.NPM_TOKEN, but | ||
# it's cleaner to stop the execution instead of letting the CI crash. | ||
if: | | ||
github.event_name == 'push' || | ||
github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login | ||
runs-on: ubuntu-latest | ||
needs: | ||
- test_node | ||
- test_deno | ||
outputs: | ||
from_version: ${{ steps.step1.outputs.from_version }} | ||
to_version: ${{ steps.step1.outputs.to_version }} | ||
is_upgraded_version: ${{ steps.step1.outputs.is_upgraded_version }} | ||
is_pre_release: ${{steps.step1.outputs.is_pre_release }} | ||
steps: | ||
- uses: garronej/ts-ci@v2.0.2 | ||
id: step1 | ||
with: | ||
action_name: is_package_json_version_upgraded | ||
branch: ${{ github.head_ref || github.ref }} | ||
|
||
publish: | ||
runs-on: macos-latest | ||
needs: | ||
- check_if_version_upgraded | ||
# We create release only if the version in the package.json have been upgraded and this CI is running against the main branch. | ||
# We allow branches with a PR open on main to publish pre-release (x.y.z-rc.u) but not actual releases. | ||
if: | | ||
needs.check_if_version_upgraded.outputs.is_upgraded_version == 'true' && | ||
( | ||
github.event_name == 'push' || | ||
needs.check_if_version_upgraded.outputs.is_pre_release == 'true' | ||
) | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ github.ref }} | ||
- run: rm -r .github/workflows | ||
- name: Remove tmp_branch if it exists | ||
run: git push origin :tmp_branch || true | ||
- run: git checkout -b tmp_branch | ||
- uses: actions/setup-node@v3 | ||
with: | ||
registry-url: https://registry.npmjs.org/ | ||
- uses: bahmutov/npm-install@v1 | ||
- run: npm run build | ||
- run: npx -y -p denoify@1.2.4 remove_deno_dist_from_gitignore | ||
env: | ||
DRY_RUN: "0" | ||
- run: | | ||
if [ "$(npm show . version)" = "$VERSION" ]; then | ||
echo "This version is already published" | ||
exit 0 | ||
fi | ||
if [ "$NODE_AUTH_TOKEN" = "" ]; then | ||
echo "Can't publish on NPM, You need a NPM_TOKEN secret." | ||
false | ||
fi | ||
EXTRA_ARGS="" | ||
if [ "$IS_PRE_RELEASE" = "true" ]; then | ||
EXTRA_ARGS="--tag next" | ||
fi | ||
npm publish $EXTRA_ARGS | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | ||
VERSION: ${{ needs.check_if_version_upgraded.outputs.to_version }} | ||
IS_PRE_RELEASE: ${{ needs.check_if_version_upgraded.outputs.is_pre_release }} | ||
- run: | | ||
git config --global user.name "actions" | ||
git config --global user.email actions@github.com | ||
git add -A | ||
git commit -am "Remove deno dist from gitignore" | ||
git push origin tmp_branch | ||
- uses: softprops/action-gh-release@v1 | ||
with: | ||
name: Release v${{ needs.check_if_version_upgraded.outputs.to_version }} | ||
tag_name: v${{ needs.check_if_version_upgraded.outputs.to_version }} | ||
target_commitish: tmp_branch | ||
generate_release_notes: false | ||
draft: false | ||
prerelease: ${{ needs.check_if_version_upgraded.outputs.is_pre_release == 'true' }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Remove tmp_branch | ||
run: git push origin :tmp_branch | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,6 @@ dist | |
notes.md | ||
.vscode/ | ||
tracing_output_folder/ | ||
*.tgz | ||
*.tgz | ||
|
||
/deno_dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,18 @@ with smart type inference. | |
</p> | ||
|
||
<p align="center"> | ||
<a href="https://github.com/gvergnaud/ts-pattern/actions"> | ||
<img src="https://github.com/gvergnaud/ts-pattern/workflows/ci/badge.svg?branch=main" alt="CI Workflow" height="18"> | ||
</a> | ||
Comment on lines
+9
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
<a href="https://www.npmjs.com/package/ts-pattern"> | ||
<img src="https://img.shields.io/npm/dm/ts-pattern.svg" alt="downloads" height="18"> | ||
</a> | ||
<a href="https://www.npmjs.com/package/ts-pattern"> | ||
<img src="https://img.shields.io/npm/v/ts-pattern.svg" alt="npm version" height="18"> | ||
<img src="https://img.shields.io/npm/v/ts-pattern?logo=npm" alt="npm version" height="18"> | ||
</a> | ||
<a href="https://deno.land/x/ts_pattern"> | ||
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Flatest-version%2Fx%2Fts_pattern%2Fmod.ts" alt="deno module" height="18"> | ||
</a> | ||
<a href="https://github.com/gvergnaud/ts-pattern"> | ||
<img src="https://img.shields.io/npm/l/ts-pattern.svg" alt="MIT license" height="18"> | ||
</a> | ||
|
@@ -78,6 +84,13 @@ Via yarn | |
yarn add ts-pattern | ||
``` | ||
|
||
The Deno distribution of the module is published as [ts_pattern](https://deno.land/x/ts_pattern) on `deno.land/x` | ||
|
||
```typescript | ||
import { match, P } from 'https://deno.land/x/ts_pattern@v<X.Y.Z>/mod.ts'; | ||
``` | ||
Replace `<X.Y.Z>` by [the latest version](https://github.com/gvergnaud/ts-pattern/tags). | ||
|
||
### Compatibility with different TypeScript versions | ||
|
||
Note: TS-Pattern assumes [Strict Mode](https://www.typescriptlang.org/tsconfig#strict) is enabled in your `tsconfig.json` file. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍