Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: cache CI

on:
push:
branches:
- master
paths:
- workspaces/cache/**
pull_request:
paths:
- workspaces/cache/**

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x, 22.x]
fail-fast: false
steps:
- name: Harden Runner
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install
- name: Run tests
run: npm run test
37 changes: 37 additions & 0 deletions .github/workflows/server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: server CI

on:
push:
branches:
- master
paths:
- workspaces/server/**
pull_request:
paths:
- workspaces/server/**

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x, 22.x]
fail-fast: false
steps:
- name: Harden Runner
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install
- name: Run tests
run: npm run test
3 changes: 2 additions & 1 deletion .github/workflows/size-satisfies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: size-satisfies CI

on:
push:
branches: master
branches:
- master
paths:
- workspaces/size-satisfies/**
pull_request:
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,10 @@ Click on one of the links to access the documentation of the workspace:
| name | package and link |
| --- | --- |
| documentation-ui | [@nodesecure/documentation-ui](./workspaces/documentation-ui) |
| vis-network | [@nodesecure/vis-network ](./workspaces/vis-network) |
| size-satisfies | [@nodesecure/size-satisfies ](./workspaces/size-satisfies) |
| vis-network | [@nodesecure/vis-network](./workspaces/vis-network) |
| size-satisfies | [@nodesecure/size-satisfies](./workspaces/size-satisfies) |
| server | [@nodesecure/server](./workspaces/server) |
| cache | [@nodesecure/cache](./workspaces/cache) |

These packages are available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).
```bash
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
"workspaces": [
"workspaces/documentation-ui",
"workspaces/vis-network",
"workspaces/size-satisfies"
"workspaces/size-satisfies",
"workspaces/server",
"workspaces/cache"
],
"repository": {
"type": "git",
Expand Down
4 changes: 1 addition & 3 deletions src/commands/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import { setImmediate } from "node:timers/promises";
// Import Third-party Dependencies
import prettyJson from "@topcli/pretty-json";
import * as i18n from "@nodesecure/i18n";

// Import Internal Dependencies
import { appCache } from "../cache.js";
import { appCache } from "@nodesecure/cache";

export async function main(options) {
const {
Expand Down
31 changes: 24 additions & 7 deletions src/commands/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ import path from "node:path";
import crypto from "node:crypto";

// Import Third-party Dependencies
import * as SemVer from "semver";
import kleur from "kleur";
import open from "open";
import * as SemVer from "semver";
import * as i18n from "@nodesecure/i18n";

// Import Internal Dependencies
import { buildServer } from "../http-server/index.js";
import { appCache } from "../cache.js";
import { buildServer, WebSocketServerInstanciator } from "@nodesecure/server";
import { appCache } from "@nodesecure/cache";

// CONSTANTS
const kRequiredScannerRange = ">=5.1.0";
const kProjectRootDir = path.join(import.meta.dirname, "..", "..");
const kComponentsDir = path.join(kProjectRootDir, "public", "components");

export async function start(
payloadFileBasename = "nsecure-result.json",
Expand Down Expand Up @@ -44,11 +45,27 @@ export async function start(
const httpServer = buildServer(dataFilePath, {
port: Number.isNaN(port) ? 0 : port,
hotReload: enableDeveloperMode,
runFromPayload
runFromPayload,
projectRootDir: kProjectRootDir,
componentsDir: kComponentsDir
});

httpServer.listen(port, async() => {
const link = `http://localhost:${port}`;
console.log(kleur.magenta().bold(await i18n.getToken("cli.http_server_started")), kleur.cyan().bold(link));

open(link);
});

new WebSocketServerInstanciator();

for (const eventName of ["SIGINT", "SIGTERM"]) {
process.on(eventName, () => httpServer.server.close());
process.on(eventName, () => {
httpServer.server.close();

console.log(kleur.red().bold(`${eventName} signal received.`));
process.exit(0);
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { Spinner } from "@topcli/spinner";
import ms from "ms";
import * as i18n from "@nodesecure/i18n";
import * as Scanner from "@nodesecure/scanner";
import { appCache } from "@nodesecure/cache";

// Import Internal Dependencies
import * as http from "./http.js";
import { appCache } from "../cache.js";
import { parseContacts } from "./parsers/contacts.js";

export async function auto(spec, options) {
Expand Down
88 changes: 0 additions & 88 deletions src/http-server/index.js

This file was deleted.

14 changes: 0 additions & 14 deletions src/http-server/middlewares/static.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/commands/cache.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import { after, before, describe, it } from "node:test";

// Import Third-party Dependencies
import * as i18n from "@nodesecure/i18n";
import { appCache, DEFAULT_PAYLOAD_PATH } from "@nodesecure/cache";

// Import Internal Dependencies
import { arrayFromAsync } from "../helpers/utils.js";
import { appCache, DEFAULT_PAYLOAD_PATH } from "../../src/cache.js";
import { main } from "../../src/commands/cache.js";

// CONSTANTS
Expand Down
Loading