Skip to content

Commit

Permalink
packaging and tooling versioning - this enables coalescing js-nuid an…
Browse files Browse the repository at this point in the history
…d node-nuid into a single repo supporting both CJS and ESM modules.
  • Loading branch information
aricart committed May 22, 2024
1 parent 40c326e commit a2fdaaf
Show file tree
Hide file tree
Showing 26 changed files with 758 additions and 10,325 deletions.
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Discussion
url: https://github.com/nats-io/nats.js/discussions
about: Ideal for ideas, feedback, or longer form questions.
- name: Chat
url: https://slack.nats.io
about: Ideal for short, one-off questions, general conversation, and meeting other NATS users!
47 changes: 47 additions & 0 deletions .github/ISSUE_TEMPLATE/defect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: Defect
description: Report a defect, such as a bug or regression.
labels:
- defect
body:
- type: textarea
id: observed
attributes:
label: Observed behavior
description: Describe the unexpected behavior or performance regression you are observing.
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected behavior
description: Describe the expected behavior or performance characteristics.
validations:
required: true
- type: textarea
id: versions
attributes:
label: Server and client version
description: |-
Provide the versions you were using when the detect was observed.
For the server, use `nats-server --version`, check the startup log output, or the image tag pulled from Docker.
For the CLI client, use `nats --version`.
For language-specific clients, check the version downloaded by the language dependency manager.
validations:
required: true
- type: textarea
id: environment
attributes:
label: Host environment
description: |-
Specify any relevant details about the host environment the server and/or client was running in,
such as operating system, CPU architecture, container runtime, etc.
validations:
required: false
- type: textarea
id: steps
attributes:
label: Steps to reproduce
description: Provide as many concrete steps to reproduce the defect.
validations:
required: false
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/proposal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Proposal
description: Propose an enhancement or new feature.
labels:
- proposal
body:
- type: textarea
id: change
attributes:
label: Proposed change
description: This could be a behavior change, enhanced API, or a new feature.
validations:
required: true
- type: textarea
id: usecase
attributes:
label: Use case
description: What is the use case or general motivation for this proposal?
validations:
required: true
- type: textarea
id: contribute
attributes:
label: Contribution
description: |-
Are you intending or interested in contributing code for this proposal if accepted?
validations:
required: false
47 changes: 47 additions & 0 deletions .github/workflows/natsjs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: NUID CI

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

jobs:
test:
strategy:
matrix:
node-version: [22.x]
deno-version: [1.43.5]

runs-on: ubuntu-latest

steps:
- name: Checkout nuid
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Use Deno Version ${{ matrix.deno-version }}
uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno-version }}
- run: npm ci
- run: npm run prepack
- run: npm test
env:
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
46 changes: 46 additions & 0 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: NUID NPM release

on:
release:
types: [created]

jobs:
test:
strategy:
matrix:
node-version: [22.x]
deno-version: [1.43.5]

runs-on: ubuntu-latest
permissions:
contents: read
id-token: write

steps:
- name: Checkout nuid
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: "https://registry.npmjs.org"
- name: Use Deno Version ${{ matrix.deno-version }}
uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno-version }}
- run: npm install -g npm
- run: npm ci
- run: npm run prepack
- name: Set tag
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Test tag
run: |
npm run check-package
- run: npm run clean
- run: npm publish --provenance --access public --tag=latest
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}


36 changes: 4 additions & 32 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,40 +1,12 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
esm/index.mjs
lib/nuid.d.ts
lib/nuid.js

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

.idea/
mocha-xunit.xml

4 changes: 0 additions & 4 deletions .istanbul.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
npm-debug.log

build/
.DS_Store
.settings/
.idea/
Expand Down
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion CODE-OF-CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
## Community Code of Conduct

NATS follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md).
NATS follows the
[CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md).
8 changes: 5 additions & 3 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Maintainership is on a per project basis.

### Maintainers
- Alberto Ricart <alberto@nats.io> [@aricart](https://github.com/aricart)
- Derek Collison <derek@nats.io> [@derekcollison](https://github.com/derekcollison)
- Ivan Kozlovic <ivan@nats.io> [@kozlovic](https://github.com/kozlovic)

- Alberto Ricart <alberto@nats.io> [@aricart](https://github.com/aricart)
- Derek Collison <derek@nats.io>
[@derekcollison](https://github.com/derekcollison)
- Ivan Kozlovic <ivan@nats.io> [@kozlovic](https://github.com/kozlovic)
81 changes: 62 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,92 @@
# NODE NUID

[![license](https://img.shields.io/github/license/nats-io/node-nuid.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![Travis branch](https://img.shields.io/travis/nats-io/node-nuid/master.svg)](https://travis-ci.org/nats-io/node-nuid)
[![Coveralls github branch](https://img.shields.io/coveralls/github/nats-io/node-nuid/master.svg)](https://coveralls.io/github/nats-io/node-nuid)
[![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)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

A highly performant unique identifier generator.

## Installation

Use the `npm` command:

$ npm install nuid
$ npm install nuid

## Basic Usage
```javascript

const NUID = require('nuid');
let nuid = NUID.next();
Import the library for node/bun:

```bash
npm install nuid
```

For web and deno you can also:

```bash
npx jsr add @nats-io/nuid
```

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

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

// `nuid` is a global instance of nuid, you can look at it directly
// or you can use `next()` and `reset()` to mutate it if you would like.
// `Nuid` is the actual class implementing the nuids, so you can also
// `new Nuid()`.
```

// Generate a new crypto/rand seeded prefix.
// Generally not needed, happens automatically.
NUID.reset();
```javascript
// To generate a bunch of nuids:
let id = nuid.next();
id = nuid.next();
//

// To generate a new prefix:
nuid.reset();
// note that prefixes are automatically rolled whenever all
// the nuids for the specific prefix have been used.
id = nuid.next();
```

## Performance
NUID needs to be very fast to generate and be truly unique, all while being entropy pool friendly.
NUID uses 12 bytes of crypto generated data (entropy draining), and 10 bytes of pseudo-random
sequential data that increments with a pseudo-random increment.

NUID needs to be very fast to generate and be truly unique, all while being
entropy pool friendly. NUID uses 12 bytes of crypto generated data (entropy
draining), and 10 bytes of pseudo-random sequential data that increments with a
pseudo-random increment.

Total length of a NUID string is 22 bytes of base 36 ascii text, so 36^22 or
17324272922341479351919144385642496 possibilities.

## Supported Node Versions
## Migration

The 2.x version of the npm module support both CJS and ESM modules, an EMS only
version of the module is available via
[jsr @nats-io/nuid](https://jsr.io/@nats-io/nuid)

If you are migrating from the 1.x.x series, note that `getGlobalNuid()` has been
replaced with the constant `nuid` as shown in the examples above.

If you are migrating from the `js-nuid` module in npm, there should be no
changes except to the location of the import in the npm bundle:

```typescript
import { nuid } from "./node_modules/esm/index.js";
```

Support policy for Nodejs versions follows
[Nodejs release support]( https://github.com/nodejs/Release).
We will support and build node-nats on even Nodejs versions that are current
or in maintenance.
## Supported Node Versions

Support policy for Nodejs versions follows
[Nodejs release support](https://github.com/nodejs/Release). We will support and
build nuid on even Nodejs versions that are current or in maintenance.

## License

Unless otherwise noted, the NATS source files are distributed under the Apache Version 2.0 license found in the LICENSE file.
Unless otherwise noted, the NATS source files are distributed under the Apache
Version 2.0 license found in the LICENSE file.

0 comments on commit a2fdaaf

Please sign in to comment.