Skip to content

Commit

Permalink
feat: Publier dans JSR.
Browse files Browse the repository at this point in the history
  • Loading branch information
regseb committed Jan 3, 2025
1 parent df0b55c commit 3e5e03e
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 14 deletions.
31 changes: 25 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,16 @@ jobs:
- name: Format files
if: ${{ steps.release.outputs.pr }}
run: >
npm run lint:fix --
.release-please/manifest.json
CHANGELOG.md
package.json
package-lock.json
npm run lint:fix -- .release-please/manifest.json CHANGELOG.md
jsr.json package.json package-lock.json
- name: Commit and push
if: ${{ steps.release.outputs.pr }}
run: |
git commit --all --message 'chore: format files'
git push
# Si la release a été créée : publier le paquet dans npm.
# Si la release a été créée : publier le paquet dans npm et JSR.
- name: Checkout repository
if: ${{ steps.release.outputs.release_created }}
uses: actions/checkout@v4
Expand All @@ -80,3 +77,25 @@ jobs:
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish in JSR
if: ${{ steps.release.outputs.release_created }}
run: npx jsr publish

- name: Env package name
if: ${{ steps.release.outputs.release_created }}
# Enlever les guillemets qui entourent le nom du paquet.
# https://github.com/npm/cli/issues/5508
run: echo "NPM_NAME=$(npm pkg get name | tr -d \")" >> $GITHUB_ENV

- name: Download tarball from npm
if: ${{ steps.release.outputs.release_created }}
run: npm pack ${{ env.NPM_NAME }}

- name: Upload tarball to release
if: ${{ steps.release.outputs.release_created }}
run: >
gh release upload ${{ steps.release.outputs.tag_name }} ${{
env.NPM_NAME }}-*.tgz
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .release-please/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"release-type": "node",
"include-component-in-tag": false,
"always-update": true,
"extra-files": ["jsr.json"],
"packages": {
".": {}
}
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
## Description

**Cronnor** est une bibliothèque moderne fournissant une classe **`Cron`** pour
créer des tâches récurrentes. Elle est disponible pour Node.js, Deno et les
créer des tâches récurrentes. Elle est disponible pour Node.js, Bun, Deno et les
navigateurs.

```JavaScript
Expand All @@ -36,8 +36,8 @@ cron.stop();
Cronnor est publiée dans [npm][link-npm] (ses CDN :
[esm.sh](https://esm.sh/cronnor),
[jsDelivr](https://www.jsdelivr.com/package/npm/cronnor),
[UNPKG](https://unpkg.com/browse/cronnor/)) et
[Deno](https://deno.land/x/cronnor).
[UNPKG](https://unpkg.com/browse/cronnor/)),
[JSR](https://jsr.io/@regseb/cronnor) et [Deno](https://deno.land/x/cronnor).

```JavaScript
// Node.js et Bun (après `npm install cronnor`) :
Expand All @@ -48,8 +48,8 @@ import Cron from "https://esm.sh/cronnor@2";
import Cron from "https://cdn.jsdelivr.net/npm/cronnor@2";
import Cron from "https://unpkg.com/cronnor@2";

// Deno :
import Cron from "https://deno.land/x/cronnor/mod.js";
// Deno (après `deno add jsr:@regseb/cronnor`) :
import Cron from "jsr:@regseb/cronnor";
```

## API
Expand All @@ -76,7 +76,7 @@ import Cron from "https://deno.land/x/cronnor/mod.js";
```JavaScript
import Cron from "cronnor/cron";
// import Cron from "https://esm.sh/cronnor@2/cron";
// import { Cron } from "https://deno.land/x/cronnor/mod.js";
// import Cron from "jsr:@regseb/cronnor/cron";
```

#### `new Cron(cronex, func, [options])`
Expand Down Expand Up @@ -150,7 +150,7 @@ Calcule la prochaine date respectant une des expressions _cron_ de la tâche.
```JavaScript
import CronExp from "cronnor/cronexp";
// import CronExp from "https://esm.sh/cronnor@2/cronexp";
// import { CronExp } from "https://deno.land/x/cronnor/mod.js";
// import CronExp from "jsr:@regseb/cronnor/cronexp";
```

#### `new CronExp(pattern)`
Expand Down Expand Up @@ -187,7 +187,7 @@ Calcule la prochaine date respectant l'expression.
```JavaScript
import At from "cronnor/at";
// import At from "https://esm.sh/cronnor@2/at";
// import { At } from "https://deno.land/x/cronnor/mod.js";
// import At from "jsr:@regseb/cronnor/at";
```

#### `new At(date, func, [options])`
Expand Down
14 changes: 14 additions & 0 deletions jsr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@regseb/cronnor",
"version": "2.3.0",
"license": "MIT",
"exports": {
".": "./src/index.js",
"./cron": "./src/cron.js",
"./cronexp": "./src/cronexp.js",
"./at": "./src/at.js"
},
"publish": {
"include": ["src/", "types/", "LICENSE", "README.md", "package.json"]
}
}

0 comments on commit 3e5e03e

Please sign in to comment.