Skip to content

Commit

Permalink
Publish to jsr, addan explicit type, and a new test
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoBernardino committed Oct 10, 2024
1 parent 1b899e9 commit e87f030
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions .dvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.46.3
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: v1.41.0
deno-version-file: .dvmrc
- run: |
make test
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test:

.PHONY: publish
publish:
git tag $(VERSION)
deno run --allow-read --allow-write --allow-net --allow-run --allow-env build-npm.ts $(VERSION)
deno run --allow-read --allow-write --allow-net --allow-run --allow-env build-npm.ts
cd npm && npm publish
deno publish
git push origin --tags
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Shurley

[![](https://github.com/BrunoBernardino/shurley/workflows/Run%20Tests/badge.svg)](https://github.com/BrunoBernardino/shurley/actions?workflow=Run+Tests) [![deno](https://shield.deno.dev/x/shurley)](https://deno.land/x/shurley) [![npm](https://img.shields.io/npm/v/shurley.svg)](https://www.npmjs.com/package/shurley)
[![](https://github.com/BrunoBernardino/shurley/workflows/Run%20Tests/badge.svg)](https://github.com/BrunoBernardino/shurley/actions?workflow=Run+Tests) [![deno](https://shield.deno.dev/x/shurley)](https://deno.land/x/shurley) [![npm](https://img.shields.io/npm/v/shurley.svg)](https://www.npmjs.com/package/shurley) [![jsr](https://jsr.io/badges/@brn/shurley)](https://jsr.io/@brn/shurley)

> I'll give you the right URL, but [don't call me Shirley!](https://www.youtube.com/watch?v=ixljWVyPby0)
Expand All @@ -23,7 +23,7 @@ It only has a _single method_: `parse(url: string)` which returns the same strin
### Deno

```ts
import shurley from 'https://deno.land/x/shurley@1.0.5/mod.ts';
import shurley from 'jsr:@brn/shurley@1.0.6'; // or import shurley from 'https://deno.land/x/shurley@1.0.6/mod.ts';

const parsedUrl = shurley.parse('example.com');

Expand Down Expand Up @@ -55,4 +55,4 @@ make test

## Publishing

After committing and pushing, just run `make publish VERSION=x.y.z`.
After committing and pushing with a new version in `deno.json`, just run `make publish`.
10 changes: 8 additions & 2 deletions build-npm.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { build, emptyDir } from 'https://deno.land/x/dnt@0.40.0/mod.ts';
import { build, emptyDir } from 'jsr:@deno/dnt@0.41.3';

await emptyDir('./npm');

const version = JSON.parse(Deno.readTextFileSync('./deno.json')).version;

const gitTag = new Deno.Command('git', { args: ['tag', version] });

await gitTag.spawn().status;

await build({
entryPoints: ['./mod.ts'],
outDir: './npm',
Expand All @@ -10,7 +16,7 @@ await build({
},
package: {
name: 'shurley',
version: Deno.args[0],
version,
description: 'Validate or fix URLs from user input. People make mistakes!',
license: 'ISC',
author: 'Bruno Bernardino <me@brunobernardino.com>',
Expand Down
3 changes: 3 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"name": "@brn/shurley",
"version": "1.0.6",
"exports": "./mod.ts",
"fmt": {
"useTabs": false,
"lineWidth": 120,
Expand Down
2 changes: 1 addition & 1 deletion mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const parse = (url: string) => {
export const parse = (url: string): string => {
const parsedUrl = url.trim();

// Sometimes people get it right
Expand Down
3 changes: 2 additions & 1 deletion mod_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { equal } from 'https://deno.land/std@0.217.0/assert/equal.ts';
import { equal } from 'jsr:@std/assert@1.0.6';

import shurley from './mod.ts';

Expand All @@ -24,6 +24,7 @@ Deno.test('that .parse() works', () => {
{ url: 'https://example.com', expected: 'https://example.com' },
{ url: 'https://example.com/', expected: 'https://example.com/' },
{ url: 'https://example.com/something', expected: 'https://example.com/something' },
{ url: 'git:example.com', expected: 'https://git:example.com' },
];

for (const test of tests) {
Expand Down

0 comments on commit e87f030

Please sign in to comment.