Skip to content

Commit

Permalink
Update package structure and configurations
Browse files Browse the repository at this point in the history
Consolidated code files and updated module types to align more closely with modern JavaScript standards. Changed file imports, adjusted TypeScript configurations, and updated the package versioning to maintain consistency across all modules. Additionally, revised the build and test scripts, enhancing cleaning processes and incorporating coverage testing functionalities.

Signed-off-by: Alberto Ricart <alberto@synadia.com>
  • Loading branch information
aricart committed Dec 6, 2024
1 parent 92d6107 commit 6c32b28
Show file tree
Hide file tree
Showing 15 changed files with 310 additions and 382 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/deno.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: test esm

on:
push:
tags:
- "*"
branches:
- "*"
pull_request:
branches: [main]

jobs:
test:
strategy:
matrix:
deno-version: [2.1.x]

runs-on: ubuntu-latest

permissions:
contents: read
id-token: write

steps:
- name: Checkout nuid
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Use Deno Version ${{ matrix.deno-version }}
uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno-version }}
- name: lint
run: |
deno fmt --check src/ test/
deno lint
- name: test
env:
TMPDIR: ${{ runner.temp }}
CI: true
run: |
deno task clean
deno task test
deno task cover
- name: Upload coverage
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: ./coverage/out.lcov
31 changes: 15 additions & 16 deletions .github/workflows/natsjs.yml → .github/workflows/node.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: NUID CI
name: test cjs

on:
push:
tags:
- '*'
- "*"
branches:
- '*'
- "*"
pull_request:
branches: [main]

Expand All @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
node-version: [22.x]
deno-version: [1.43.5]
deno-version: [2.1.x]

runs-on: ubuntu-latest

Expand All @@ -31,17 +31,16 @@ jobs:
uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno-version }}
- run: npm ci
- run: npm run prepack
- run: npm test
- name: lint
run: |
deno fmt --check src/ test/
deno lint
- name: test
env:
TMPDIR: ${{ runner.temp }}
CI: true
# - name: Gather coverage
# if: matrix.node-version == '21.x'
# run: npm run coveralls
# - name: Upload coverage
# uses: coverallsapp/github-action@v1.2.5
# if: matrix.node-version == '21.x'
# with:
# github-token: ${{ secrets.github_token }}
# path-to-lcov: ./coverage/lcov.info
run: |
npm ci
npm run prepack
npm test
6 changes: 1 addition & 5 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
node-version: [22.x]
deno-version: [1.43.5]
deno-version: [2.1.x]

runs-on: ubuntu-latest
permissions:
Expand Down Expand Up @@ -43,7 +43,3 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: npx jsr publish




4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
esm/index.mjs
lib/nuid.d.ts
lib/nuid.js
lib/
coverage/

# Dependency directories
node_modules
Expand Down
41 changes: 27 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,44 @@
# Nuid.js

[![license](https://img.shields.io/github/license/nats-io/node-nuid.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![npm](https://img.shields.io/npm/v/nuid.svg)](https://www.npmjs.com/package/nuid)
[![npm](https://img.shields.io/npm/dt/nuid.svg)](https://www.npmjs.com/package/nuid)
[![npm](https://img.shields.io/npm/dm/nuid.svg)](https://www.npmjs.com/package/nuid)
[![License](https://img.shields.io/badge/Licence-Apache%202.0-blue.svg)](./LICENSE)
![node](https://github.com/nats-io/nuid.js/actions/workflows/node.yml/badge.svg)
![deno](https://github.com/nats-io/nuid.js/actions/workflows/deno.yml/badge.svg)
[![coverage](https://coveralls.io/repos/github/nats-io/nuid.js/badge.svg?branch=main)](https://coveralls.io/github/nats-io/nuid.js?branch=main)
[![JSDoc](https://img.shields.io/badge/JSDoc-reference-blue)](https://nats-io.github.io/nuid.js/index.html)

[![JSR](https://jsr.io/badges/@nats-io/nuid)](https://jsr.io/@nats-io/nuid.js)
[![JSR](https://jsr.io/badges/@nats-io/nuid/score)](https://jsr.io/@nats-io/nuid.js)

[![npm](https://img.shields.io/npm/v/%40nats-io%2Fnuid)](https://www.npmjs.com/package/@nats-io/nuid.js)
[![npm](https://img.shields.io/npm/dt/%40nats-io%2Fnuid)](https://www.npmjs.com/package/@nats-io/nuid.js)
[![npm](https://img.shields.io/npm/dm/%40nats-io%2Fnuid)](https://www.npmjs.com/package/@nats-io/nuid.js)

A highly performant unique identifier generator for JavaScript.

## Installation

Import the library for node/bun:
For web and deno you can use the JSR bundle:

```bash
npm install nuid
npx jsr add @nats-io/nuid
// or
deno add @nats-io/nuid
```

For web and deno you can also:

```bash
npx jsr add @nats-io/nuid
```typescript
import { next, Nuid } from "jsr:@nats-io/nuid";
```

## Basic Usage
import { next

Reference the library in your code. If using you can `import` or `require` the
npm nuid library supports both Common JS and ESM:
In node/bun:

```bash
npm install nuid
```

```javascript
const { nuid, Nuid } = require("nuid");
const { next, Nuid } = require("nuid");
// or
import { next, Nuid } from "nuid";

Expand All @@ -36,6 +47,8 @@ import { next, Nuid } from "nuid";
// `new Nuid()`.
```

## Basic Usage

```javascript
// To generate a bunch of nuids:
let id = nuid.next();
Expand Down
28 changes: 28 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@nats-io/nuid",
"version": "2.0.1-2",
"exports": {
".": "./src/nuid.ts"
},
"include": [
"src/nuid.ts",
"LICENSE",
"README.md",
"MAINTAINERS.md",
"CODE-OF-CONDUCT.md"
],

"tasks": {
"clean": "rm -rf ./lib ./coverage",
"test-cover": "deno task clean && deno task test && deno task cover && deno task view-cover",
"test": "deno test -A --parallel --reload --coverage=coverage test/",
"cover": "deno coverage ./coverage --lcov > ./coverage/out.lcov",
"view-cover": "genhtml -o ./coverage/html ./coverage/out.lcov && open ./coverage/html/index.html"
},
"fmt": {
"exclude": ["lib/", "docs/"]
},
"lint": {
"exclude": ["lib/", "docs/"]
}
}
3 changes: 0 additions & 3 deletions esm/package.json

This file was deleted.

14 changes: 0 additions & 14 deletions jsr.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/nuid.js.map

This file was deleted.

3 changes: 0 additions & 3 deletions lib/package.json

This file was deleted.

Loading

0 comments on commit 6c32b28

Please sign in to comment.