Skip to content

Commit

Permalink
Merge pull request #2573 from kuzzleio/chore/bump-deps
Browse files Browse the repository at this point in the history
feat: update deps & nodejs 22
  • Loading branch information
rolljee authored Jan 8, 2025
2 parents 732ce84 + 212e98e commit 55ed4b2
Show file tree
Hide file tree
Showing 17 changed files with 8,635 additions and 5,595 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-24.04
strategy:
matrix:
node-version: [16, 18, 20]
node-version: [18, 20, 22]
steps:
- uses: actions/checkout@v4

Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/workflow-deployments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ on:
node_lts_maintenance_version:
description: "Maintenance Node LTS Version"
required: true
default: "16"
default: "18"
type: string

node_lts_active_version:
description: "Active Node LTS Version"
required: true
default: "18"
default: "20"
type: string

node_lts_current_version:
description: "Current Node LTS Version"
required: true
default: "20"
default: "22"
type: string

workflow_dispatch:
Expand All @@ -38,19 +38,19 @@ on:
node_lts_maintenance_version:
description: "Maintenance Node LTS Version"
required: true
default: "16"
default: "18"
type: string

node_lts_active_version:
description: "Active Node LTS Version"
required: true
default: "18"
default: "20"
type: string

node_lts_current_version:
description: "Current Node LTS Version"
required: true
default: "20"
default: "22"
type: string

jobs:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ on:
pull_request:

env:
NODE_LTS_MAINTENANCE_VERSION: "16"
NODE_LTS_ACTIVE_VERSION: "18"
NODE_LTS_CURRENT_VERSION: "20"
DOCKER_PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7"
NODE_LTS_MAINTENANCE_VERSION: "18"
NODE_LTS_ACTIVE_VERSION: "20"
NODE_LTS_CURRENT_VERSION: "22"
ELASTICSEARCH_MAINTENANCE_VERSION: "7"
ELASTICSEARCH_ACTIVE_VERSION: "8"

Expand Down
72 changes: 41 additions & 31 deletions bin/start-kuzzle-server
Original file line number Diff line number Diff line change
Expand Up @@ -21,46 +21,49 @@
* limitations under the License.
*/

'use strict';
"use strict";

/* eslint-disable no-console */

const fs = require('fs');
const fs = require("fs");

const yargs = require('yargs');
const yargs = require("yargs");

const { Backend } = require('../index');
const { Backend } = require("../index");

function loadJson (path) {
if (! path) {
function loadJson(path) {
if (!path) {
return {};
}

return JSON.parse(fs.readFileSync(path, 'utf8'));
return JSON.parse(fs.readFileSync(path, "utf8"));
}

async function startKuzzle (options = {}) {
const app = new Backend('kuzzle');
async function startKuzzle(options = {}) {
const app = new Backend("kuzzle");

if (options.enablePlugins) {
const additionalPlugins = options.enablePlugins
.trim()
.split(',')
.map(x => x.trim().replace(/(^")|("$)/g, ''));
.split(",")
.map((x) => x.trim().replace(/(^")|("$)/g, ""));

for (const additionalPlugin of additionalPlugins) {
const PluginClass = require(`../plugins/available/${additionalPlugin}`);
const manifest = require(`../plugins/available/${additionalPlugin}/manifest.json`);
const manifest = require(
`../plugins/available/${additionalPlugin}/manifest.json`,
);
const plugin = new PluginClass();

try {
plugin.version = require(`../plugins/available/${additionalPlugin}/package.json`).version;
}
catch (e) {
plugin.version = require(
`../plugins/available/${additionalPlugin}/package.json`,
).version;
} catch (e) {
// ignore
}

app.plugin.use(plugin, { name: manifest.name, manifest });
app.plugin.use(plugin, { manifest, name: manifest.name });
}
}

Expand All @@ -74,36 +77,43 @@ async function startKuzzle (options = {}) {

app.vault.file = options.secretsFile;

app.version = '1.0.0';
app.version = "1.0.0";

await app.start();

const { total: admins } = await app.sdk.security.searchUsers({
query: { term: { profileIds: 'admin' } }
query: { term: { profileIds: "admin" } },
});

if (admins.length === 0) {
console.log('[!] [WARNING] There is no administrator user yet: everyone has administrator rights.');
console.log('[ℹ] You can use the CLI or the admin console to create the first administrator user.');
console.log(' For more information: https://docs.kuzzle.io/core/2/guides/essentials/security/');
console.log(
"[!] [WARNING] There is no administrator user yet: everyone has administrator rights.",
);
console.log(
"[ℹ] You can use the CLI or the admin console to create the first administrator user.",
);
console.log(
" For more information: https://docs.kuzzle.io/core/2/guides/essentials/security/",
);
}
}

const options = yargs
.usage('start-kuzzle-server [options]')
.describe('fixtures', 'Import data from file')
.describe('mappings', 'Apply mappings from file')
.describe('securities', 'Import roles, profiles and users from file')
.describe('vault-key', 'Vault key used to decrypt secrets')
.describe('secrets-file', 'Output file to write decrypted secrets')
.describe('enable-plugins', 'Enable plugins from "plugins/available" directory')
.argv;
.usage("start-kuzzle-server [options]")
.describe("fixtures", "Import data from file")
.describe("mappings", "Apply mappings from file")
.describe("securities", "Import roles, profiles and users from file")
.describe("vault-key", "Vault key used to decrypt secrets")
.describe("secrets-file", "Output file to write decrypted secrets")
.describe(
"enable-plugins",
'Enable plugins from "plugins/available" directory',
).argv;

const run = async () => {
try {
await startKuzzle(options);
}
catch (error) {
} catch (error) {
console.error(`[x] [ERROR] ${error.stack}`);
process.exit(1);
}
Expand Down
29 changes: 16 additions & 13 deletions bin/wait-kuzzle
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,38 @@
* limitations under the License.
*/

'use strict';
"use strict";

/* eslint-disable no-console */

const { Kuzzle, WebSocket } = require('kuzzle-sdk');
const { Kuzzle, WebSocket } = require("kuzzle-sdk");

const sleep = seconds => {
return new Promise(resolve => setTimeout(() => resolve(), seconds * 1000));
const sleep = (seconds) => {
return new Promise((resolve) => setTimeout(() => resolve(), seconds * 1000));
};

const kuzzleHost = process.env.KUZZLE_HOST || 'localhost';
const kuzzleHost = process.env.KUZZLE_HOST || "localhost";
const kuzzlePort = process.env.KUZZLE_PORT || 7512;
const maxTries = process.env.MAX_TRIES || 60;

async function waitKuzzle (host, port, timeout) {
const spinner = '|/-\\';
async function waitKuzzle(host, port, timeout) {
const spinner = "|/-\\";
const protocol = new WebSocket(host, { port });
const kuzzle = new Kuzzle(protocol);
let connected = false;

kuzzle.on('connected', () => (connected = true));
kuzzle.on("connected", () => (connected = true));
kuzzle.connect().catch(() => {});

console.log(`[ℹ] Trying to connect to Kuzzle at "${kuzzleHost}:${kuzzlePort}"`);
console.log(
`[ℹ] Trying to connect to Kuzzle at "${kuzzleHost}:${kuzzlePort}"`,
);

for (let seconds = 0; seconds < timeout; seconds++) {
const message = `[${spinner.charAt(seconds % spinner.length)}] Still trying to connect to Kuzzle (${seconds}s)...`;

if (connected) {
console.log(`${' '.repeat(message.length)}\r[✔] Kuzzle is up`);
console.log(`${" ".repeat(message.length)}\r[✔] Kuzzle is up`);
kuzzle.disconnect();
return;
}
Expand All @@ -60,15 +62,16 @@ async function waitKuzzle (host, port, timeout) {
await sleep(1);
}

console.log(`Timeout after ${timeout}s: cannot connect to Kuzzle at "${host}:${port}"`);
console.log(
`Timeout after ${timeout}s: cannot connect to Kuzzle at "${host}:${port}"`,
);
process.exit(1);
}

const run = async () => {
try {
await waitKuzzle(kuzzleHost, kuzzlePort, maxTries);
}
catch (error) {
} catch (error) {
console.error(`[x] ${error.message}`);
process.exit(1);
}
Expand Down
17 changes: 17 additions & 0 deletions check-node-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* eslint-disable no-console */

"use strict";

const semver = require("semver");
const { engines } = require("./package.json");

const version = engines.node;
const nodeVersion = process.version;

if (!semver.satisfies(nodeVersion, version)) {
console.error(
"\x1b[31m%s\x1b[0m",
`Required node version ${version} not satisfied with current version ${nodeVersion}`,
);
process.exit(1);
}
21 changes: 11 additions & 10 deletions docker/images/kuzzle/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,22 @@ RUN set -x \

WORKDIR /app

ADD ./bin bin
ADD ./config config
ADD ./lib lib
ADD ./package.json package.json
ADD ./package-lock.json package-lock.json
ADD ./index.ts index.ts
ADD ./tsconfig.json tsconfig.json
COPY ./bin bin
COPY ./config config
COPY ./lib lib
COPY ./package.json package.json
COPY ./package-lock.json package-lock.json
COPY ./index.ts index.ts
COPY ./tsconfig.json tsconfig.json
COPY ./check-node-version.js check-node-version.js

RUN npm ci
RUN npm run build
RUN npm prune --omit=dev

RUN rm -rf tsconfig.json index.ts

ADD ./plugins/available/ /app/plugins/available/
COPY ./plugins/available/ /app/plugins/available/

################################################################################
FROM node:${NODE_VERSION}-bookworm-slim AS minifier
Expand Down Expand Up @@ -70,8 +71,8 @@ COPY --from=minifier /app /var/app

ENV NODE_ENV=production

ADD ./docker/scripts/entrypoint.sh /bin/entrypoint
ADD ./docker/scripts/run-prod.sh /bin/kuzzle
COPY ./docker/scripts/entrypoint.sh /bin/entrypoint
COPY ./docker/scripts/run-prod.sh /bin/kuzzle

RUN ln -s /var/app /app

Expand Down
21 changes: 11 additions & 10 deletions docker/images/plugin-dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@ RUN set -x \

WORKDIR /app

ADD ./bin bin
ADD ./config config
ADD ./lib lib
ADD ./package.json package.json
ADD ./package-lock.json package-lock.json
ADD ./index.ts index.ts
ADD ./tsconfig.json tsconfig.json
COPY ./bin bin
COPY ./config config
COPY ./lib lib
COPY ./package.json package.json
COPY ./package-lock.json package-lock.json
COPY ./index.ts index.ts
COPY ./tsconfig.json tsconfig.json
COPY ./check-node-version.js check-node-version.js

RUN npm ci
RUN npm run build
RUN npm prune --omit=dev

RUN rm -rf tsconfig.json index.ts

ADD ./plugins/available/ plugins/available/
COPY ./plugins/available/ plugins/available/

################################################################################
FROM node:${NODE_VERSION}-bookworm-slim
Expand All @@ -41,8 +42,8 @@ RUN set -x \
&& apt-get update && apt-get install -y \
libunwind-dev

ADD ./docker/scripts/entrypoint.sh /bin/entrypoint
ADD ./docker/scripts/run-plugin.sh /bin/run-plugin
COPY ./docker/scripts/entrypoint.sh /bin/entrypoint
COPY ./docker/scripts/run-plugin.sh /bin/run-plugin

COPY --from=builder /lib /lib
COPY --from=builder /usr /usr
Expand Down
2 changes: 1 addition & 1 deletion lib/api/controllers/authController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* limitations under the License.
*/
import { IncomingMessage } from "http";
import Cookie from "cookie";
import * as Cookie from "cookie";

import Bluebird from "bluebird";
import { isEmpty } from "lodash";
Expand Down
2 changes: 1 addition & 1 deletion lib/core/network/protocols/mqttProtocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MqttProtocol extends Protocol {
super("mqtt");

// eslint-disable-next-line new-cap
this.aedes = new Aedes.Server();
this.aedes = new Aedes();
this.server = net.createServer(this.aedes.handle);

this.connections = new Map();
Expand Down
Loading

0 comments on commit 55ed4b2

Please sign in to comment.