Skip to content

Commit

Permalink
Release version 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
silas committed Oct 18, 2024
1 parent a4ac24c commit f1d9c6f
Show file tree
Hide file tree
Showing 33 changed files with 169 additions and 161 deletions.
32 changes: 20 additions & 12 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,33 @@ concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

env:
CI: true

jobs:
build:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18, 20]

steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
run: |
npm install
npm run build --if-present
npm test
npm run types
env:
CI: true

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Install
run: pnpm install

- name: Test
run: pnpm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ coverage
example*.js
node_modules
package-lock.json
pnpm-lock.yaml
tmp
2 changes: 1 addition & 1 deletion lib/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Catalog {
if (!opts.node || !opts.address) {
throw this.consul._err(
errors.Validation("node and address required"),
req
req,
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/health.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ declare class Health {

state(options: StateOptions): Promise<StateResult>;
state(
state: "any" | "passing" | "warning" | "critical"
state: "any" | "passing" | "warning" | "critical",
): Promise<StateResult>;
}
2 changes: 1 addition & 1 deletion lib/health.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class Health {
if (opts.state !== "any" && constants.CHECK_STATE.indexOf(opts.state) < 0) {
throw this.consul._err(
errors.Validation("state invalid: " + opts.state),
req
req,
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/kv.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ declare class Kv {
set(
key: string,
value: string | Buffer,
options: SetOptions
options: SetOptions,
): Promise<SetResult>;

del(options: DelOptions): Promise<DelResult>;
Expand Down
2 changes: 1 addition & 1 deletion lib/kv.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Kv {
return next(
false,
undefined,
utils.responseResult(request, res.body[0])
utils.responseResult(request, res.body[0]),
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/transaction.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ declare class Transaction {
create(options: CreateOptions): Promise<CreateResult>;
create(
operations: Operation[],
options: CreateOptions
options: CreateOptions,
): Promise<CreateResult>;
}
6 changes: 3 additions & 3 deletions lib/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class Transaction {
default:
throw this.consul._err(
errors.Validation(
"a list of operations are required as first arguments"
"a list of operations are required as first arguments",
),
{ name: "Transaction.create" }
{ name: "Transaction.create" },
);
}

Expand All @@ -45,7 +45,7 @@ class Transaction {
if (!(Array.isArray(opts.operations) && opts.operations.length > 0)) {
throw this.consul._err(
errors.Validation("operations must be an array with at least one item"),
req
req,
);
}

Expand Down
8 changes: 4 additions & 4 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ function _createServiceCheck(src) {
if (src.hasOwnProperty("aliasservice")) dst.AliasService = src.aliasservice;
} else {
throw new Error(
"args/grpc/h2ping/http/tcp/udp and interval, ttl, or aliasnode/aliasservice"
"args/grpc/h2ping/http/tcp/udp and interval, ttl, or aliasnode/aliasservice",
);
}
if (src.hasOwnProperty("notes")) dst.Notes = src.notes;
Expand Down Expand Up @@ -438,7 +438,7 @@ function _createService(src, isSidecar) {
if (!isSidecar) {
dst.Connect.SidecarService = _createService(
normalizeKeys(connect.sidecarservice),
true
true,
);
} else {
throw new Error("sidecarservice cannot be nested");
Expand All @@ -452,7 +452,7 @@ function _createService(src, isSidecar) {

if (src.taggedaddresses) {
dst.TaggedAddresses = _createTaggedAddresses(
normalizeKeys(src.taggedaddresses)
normalizeKeys(src.taggedaddresses),
);
}

Expand Down Expand Up @@ -544,7 +544,7 @@ function _createCatalogRegistration(src) {

if (src.taggedaddresses) {
dst.TaggedAddresses = _createTaggedAddresses(
normalizeKeys(src.taggedaddresses)
normalizeKeys(src.taggedaddresses),
);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class Watch extends events.EventEmitter {
this._run();
},
this,
this._wait()
this._wait(),
);
}

Expand Down Expand Up @@ -157,7 +157,7 @@ class Watch extends events.EventEmitter {
if (newIndex === 0n) {
return this._err(
errors.Consul("Consul returned zero index value"),
res
res,
);
}

Expand Down
17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
{
"name": "consul",
"version": "2.0.0-next.3",
"version": "2.0.0",
"description": "Consul client",
"main": "./lib",
"types": "./lib/index.d.ts",
"files": [
"./lib"
],
"dependencies": {
"papi": "^1.1.0"
"papi": "^1.1.0",
"uuid": "^10.0.0"
},
"devDependencies": {
"@definitelytyped/dtslint": "^0.0.159",
"@types/node": "*",
"@types/node": "^22.7.6",
"async": "^3.2.0",
"debug": "^4.3.1",
"jshint": "^2.5.5",
"mocha": "^8.3.0",
"mocha": "^10.7.3",
"nock": "^13.0.7",
"node-uuid": "^1.4.3",
"nyc": "^15.1.0",
"prettier": "^2.7.1",
"nyc": "^17.1.0",
"prettier": "^3.3.3",
"should": "^13.2.1",
"sinon": "^9.2.4",
"sinon": "^19.0.2",
"temp": "^0.9.4"
},
"scripts": {
Expand Down
18 changes: 9 additions & 9 deletions test/acceptance/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const async_ = require("async");
const should = require("should");
const uuid = require("node-uuid");
const uuid = require("uuid");

const constants = require("../../lib/constants");

Expand All @@ -26,7 +26,7 @@ helper.describe("Agent", function () {
should(
data.map((m) => {
return m.Name;
})
}),
).containEql("node1");
});
});
Expand Down Expand Up @@ -61,7 +61,7 @@ helper.describe("Agent", function () {
should(enableStatus).have.property("_node_maintenance");
should(enableStatus._node_maintenance).have.property(
"Status",
"critical"
"critical",
);

await this.c1.agent.maintenance({ enable: false });
Expand All @@ -77,7 +77,7 @@ helper.describe("Agent", function () {
} catch (err) {
should(err).have.property(
"message",
"consul: agent.maintenance: enable required"
"consul: agent.maintenance: enable required",
);
}
});
Expand Down Expand Up @@ -106,7 +106,7 @@ helper.describe("Agent", function () {
} catch (err) {
should(err).have.property(
"message",
"consul: agent.join: address required"
"consul: agent.join: address required",
);
}
});
Expand Down Expand Up @@ -138,7 +138,7 @@ helper.describe("Agent", function () {
} catch (err) {
should(err).have.property(
"message",
"consul: agent.forceLeave: node required"
"consul: agent.forceLeave: node required",
);
}
});
Expand Down Expand Up @@ -171,15 +171,15 @@ helper.describe("Agent", function () {
const checks = await this.c1.agent.checks();

await Promise.all(
Object.keys(checks).map((id) => this.c1.agent.check.deregister(id))
Object.keys(checks).map((id) => this.c1.agent.check.deregister(id)),
);

await this.c1.agent.check.register({ name: this.name, ttl: "10s" });
});

afterEach(async function () {
await Promise.all(
this.deregister.map((id) => this.c1.agent.check.deregister(id))
this.deregister.map((id) => this.c1.agent.check.deregister(id)),
).catch(() => null);
});

Expand Down Expand Up @@ -266,7 +266,7 @@ helper.describe("Agent", function () {

afterEach(async function () {
await Promise.all(
this.deregister.map((id) => this.c1.agent.service.deregister(id))
this.deregister.map((id) => this.c1.agent.service.deregister(id)),
).catch(() => null);
});

Expand Down
4 changes: 2 additions & 2 deletions test/acceptance/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const async_ = require("async");
const should = require("should");
const uuid = require("node-uuid");
const uuid = require("uuid");

const helper = require("./helper");

Expand Down Expand Up @@ -63,7 +63,7 @@ helper.describe("Catalog", function () {
should(data.Services[this.service.name]).have.properties(
"ID",
"Service",
"Tags"
"Tags",
);
should(data.Services[this.service.name].Service).eql(this.service.name);
should(data.Services[this.service.name].Tags).eql([this.service.tag]);
Expand Down
4 changes: 2 additions & 2 deletions test/acceptance/event.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

const should = require("should");
const uuid = require("node-uuid");
const uuid = require("uuid");

const helper = require("./helper");

Expand Down Expand Up @@ -33,7 +33,7 @@ helper.describe("Event", function () {
"ServiceFilter",
"TagFilter",
"Version",
"LTime"
"LTime",
);
should(event.Name).equal("test");
});
Expand Down
2 changes: 1 addition & 1 deletion test/acceptance/health.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const async_ = require("async");
const should = require("should");
const uuid = require("node-uuid");
const uuid = require("uuid");

const helper = require("./helper");

Expand Down
4 changes: 2 additions & 2 deletions test/acceptance/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Cluster {
};
await util.promisify(fs.writeFile)(
serverConfigPath,
JSON.stringify(serverConfig)
JSON.stringify(serverConfig),
);

args.push("-config-file");
Expand All @@ -94,7 +94,7 @@ class Cluster {
server.on("exit", (code) => {
if (code !== 0 && !server._destroyed) {
const err = new Error(
"Server exited (" + opts.node + "): " + code + "\n"
"Server exited (" + opts.node + "): " + code + "\n",
);
err.message += "Command: " + binPath + " " + JSON.stringify(args);
throw err;
Expand Down
Loading

0 comments on commit f1d9c6f

Please sign in to comment.