Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions .changeset/forty-vans-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@nodesecure/server": major
"@nodesecure/cache": major
---

Major refactor to enhance cache integration
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ reports
# macOS system files
.DS_Store

.claude
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ package-lock=false
provenance=true
save-exact=true
ignore-scripts=true
allow-git=none
1 change: 0 additions & 1 deletion bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ prog
.command("cache")
.option("-l, --list", i18n.getTokenSync("cli.commands.cache.option_list"), false)
.option("-c, --clear", i18n.getTokenSync("cli.commands.cache.option_clear"), false)
.option("-f, --full", i18n.getTokenSync("cli.commands.cache.option_full"), false)
.describe(i18n.getTokenSync("cli.commands.cache.desc"))
.action(commands.cache.main);

Expand Down
1 change: 0 additions & 1 deletion docs/cli/cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ $ nsecure cache [options]
|---|---|---|---|
| `--list` | `-l` | `false` | Display the cache contents in JSON format. Use with `--full` to include scanned payloads stored on disk. |
| `--clear` | `-c` | `false` | Remove cached entries. Use with `--full` to also delete scanned payloads stored on disk. |
| `--full` | `-f` | `false` | Extend the scope of `--list` or `--clear` to include scanned payloads stored on disk.|
39 changes: 27 additions & 12 deletions esbuild.dev.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,26 @@ import http from "node:http";
import path from "node:path";

// Import Third-party Dependencies
import { getBuildConfiguration } from "@nodesecure/documentation-ui/node";
import {
getBuildConfiguration
} from "@nodesecure/documentation-ui/node";
import * as i18n from "@nodesecure/i18n";
import chokidar from "chokidar";
import esbuild from "esbuild";
import open from "open";
import sirv from "sirv";
import { PayloadCache } from "@nodesecure/cache";
import {
WebSocketServerInstanciator,
logger,
ViewBuilder,
getApiRouter,
context as als, type AsyncStoreContext
} from "@nodesecure/server";

// Import Internal Dependencies
import english from "./i18n/english.js";
import french from "./i18n/french.js";
import { context as als, type AsyncStoreContext } from "./workspaces/server/src/ALS.ts";
import { ViewBuilder } from "./workspaces/server/src/ViewBuilder.class.ts";
import { cache } from "./workspaces/server/src/cache.ts";
import { getApiRouter } from "./workspaces/server/src/endpoints/index.ts";
import { logger } from "./workspaces/server/src/logger.ts";
import { WebSocketServerInstanciator } from "./workspaces/server/src/websocket/index.ts";

// CONSTANTS
const kPublicDir = path.join(import.meta.dirname, "public");
Expand Down Expand Up @@ -73,19 +77,30 @@ const { hosts: esbuildHosts, port: esbuildPort } = await buildContext.serve({
servedir: kOutDir
});

const dataFilePath = await fsAsync.access(kDefaultPayloadPath).then(() => kDefaultPayloadPath, () => undefined);
const dataFilePath = await fsAsync.access(
kDefaultPayloadPath
).then(() => kDefaultPayloadPath, () => undefined);
const cache = await new PayloadCache().load();

if (dataFilePath === undefined) {
cache.startFromZero = true;
cache.setCurrentSpec(null);
}
else {
const payloadStr = await fsAsync.readFile(dataFilePath, "utf-8");
const payload = JSON.parse(payloadStr);
await cache.save(payload, { useAsCurrent: true });
}

const store: AsyncStoreContext = {
i18n: { english: { ui: english.ui }, french: { ui: french.ui } },
i18n: {
english: { ui: english.ui },
french: { ui: french.ui }
},
viewBuilder: new ViewBuilder({
projectRootDir: import.meta.dirname,
componentsDir: kComponentsDir
}),
dataFilePath
cache
};
const htmlWatcher = chokidar.watch(kComponentsDir, {
persistent: false,
Expand Down Expand Up @@ -129,7 +144,7 @@ function defaultRoute(req: http.IncomingMessage, res: http.ServerResponse) {

const apiRouter = getApiRouter(defaultRoute);

const httpServer = http.createServer((req, res) => als.run(store, () => apiRouter.lookup(req, res)))
http.createServer((req, res) => als.run(store, () => apiRouter.lookup(req, res)))
.listen(kDevPort, () => {
console.log(`Dev server: http://localhost:${kDevPort}`);
open(`http://localhost:${kDevPort}`);
Expand Down
3 changes: 0 additions & 3 deletions i18n/arabic.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ const cli = {
missingAction: "لم يتم تحديد إجراء صالح. استخدم --help لرؤية الخيارات.",
option_list: "عرض ملفات ذاكرة التخزين المؤقت",
option_clear: "مسح ذاكرة التخزين المؤقت",
option_full: "مسح أو عرض ذاكرة التخزين المؤقت الكاملة، بما في ذلك الحمولات",
cacheTitle: "ذاكرة التخزين المؤقت لـ NodeSecure:",
scannedPayloadsTitle: "الحمولات الممسوحة المتاحة على القرص:",
cleared: "تم مسح ذاكرة التخزين المؤقت بنجاح!"
},
extractIntegrity: {
Expand Down Expand Up @@ -226,7 +224,6 @@ const ui = {
"Available licenses": "التراخيص المتاحة",
"Available flags": "الأعلام المتاحة",
default: "خيارات البحث",
recentPackages: "الحزم الأخيرة",
packagesCache: "الحزم المتاحة في ذاكرة التخزين المؤقت",
noPackageFound: "لم يتم العثور على حزمة",
packageLengthErr: "يجب أن يكون اسم الحزمة بين 2 و 64 حرفاً.",
Expand Down
3 changes: 0 additions & 3 deletions i18n/english.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ const cli = {
missingAction: "No valid action specified. Use --help to see options.",
option_list: "List cache files",
option_clear: "Clear the cache",
option_full: "Clear or list the full cache, including payloads",
cacheTitle: "NodeSecure Cache:",
scannedPayloadsTitle: "Scanned payloads available on disk:",
cleared: "Cache cleared successfully!"
},
extractIntegrity: {
Expand Down Expand Up @@ -223,7 +221,6 @@ const ui = {
locked: "locked"
},
search: {
recentPackages: "Recent packages",
packagesCache: "Packages available in the cache",
noPackageFound: "No package found",
packageLengthErr: "Package name must be between 2 and 64 characters.",
Expand Down
3 changes: 0 additions & 3 deletions i18n/french.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ const cli = {
missingAction: "Aucune action valide spécifiée. Utilisez --help pour voir les options.",
option_list: "Lister les fichiers du cache",
option_clear: "Nettoyer le cache",
option_full: "Nettoyer ou lister le cache complet, y compris les payloads",
cacheTitle: "Cache NodeSecure:",
scannedPayloadsTitle: "Payloads scannés disponibles sur le disque:",
cleared: "Cache nettoyé avec succès !"
},
extractIntegrity: {
Expand Down Expand Up @@ -223,7 +221,6 @@ const ui = {
locked: "Verrouillé"
},
search: {
recentPackages: "Packages récents",
packagesCache: "Packages disponibles dans le cache",
noPackageFound: "Aucun package trouvé",
packageLengthErr: "Le nom du package doit être compris entre 2 et 64 caractères.",
Expand Down
3 changes: 0 additions & 3 deletions i18n/turkish.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ const cli = {
missingAction: "Geçerli bir işlem belirtilmedi. Seçenekleri görmek için --help kullanın.",
option_list: "Önbellek dosyalarını listele",
option_clear: "Önbelleği temizle",
option_full: "Yükler dahil tam önbelleği temizle veya listele",
cacheTitle: "NodeSecure Önbelleği:",
scannedPayloadsTitle: "Diskte mevcut taranan yükler:",
cleared: "Önbellek başarıyla temizlendi!"
},
extractIntegrity: {
Expand Down Expand Up @@ -228,7 +226,6 @@ const ui = {
"Available licenses": "Mevcut lisanslar",
"Available flags": "Mevcut bayraklar",
default: "Arama seçenekleri",
recentPackages: "Son paketler",
packagesCache: "Önbellekte mevcut paketler",
noPackageFound: "Paket bulunamadı",
packageLengthErr: "Paket adı 2 ile 64 karakter arasında olmalıdır.",
Expand Down
107 changes: 0 additions & 107 deletions public/components/navigation/navigation.css
Original file line number Diff line number Diff line change
Expand Up @@ -96,110 +96,3 @@ body.dark #search-nav {
background: var(--dark-theme-primary-color);
}

#search-nav .packages {
height: inherit;
display: flex;
max-width: calc(100vw - 70px - 264px);
background: var(--primary);
}

#search-nav .packages>.package {
height: inherit;
font-family: mononoki;
display: flex;
align-items: center;
background: linear-gradient(to right, rgb(55 34 175 / 100%) 0%,rgb(87 74 173 / 100%) 50%,rgb(59 110 205) 100%);
padding: 0 10px;
border-right: 2px solid #0f041a;
text-shadow: 1px 1px 10px #000;
color: #def7ff;
}

body.dark #search-nav .packages>.package {
background: linear-gradient(to right, rgb(11 3 31 / 100%) 0%, rgb(11 3 31 / 80%) 50%, rgb(11 3 31 / 60%) 100%);
}

#search-nav .packages>.package>* {
transform: skewX(20deg);
}

#search-nav .packages>.package:first-child {
padding-left: 10px;
}

#search-nav .packages>.package:not(.active):hover {
background: linear-gradient(to right, rgb(55 34 175 / 100%) 1%, rgb(68 121 218) 100%);
color: #defff9;
cursor: pointer;
}

body.dark #search-nav .packages>.package:not(.active):hover {
background: linear-gradient(to right, rgb(11 3 31 / 70%) 1%, rgb(11 3 31 / 50%) 100%);
}

#search-nav .packages>.package.active {
background: linear-gradient(to right, rgb(55 34 175 / 100%) 0%,rgb(87 74 173 / 100%) 50%,rgb(59 110 205) 100%);
}

#search-nav .packages>.package.active>b {
background: var(--secondary);
}

#search-nav .packages>.package.active>.remove {
display: block;
}

#search-nav .packages>.package>b:last-of-type:not(:first-of-type) {
background: #f57c00;
}

#search-nav .packages>.package>b {
font-weight: bold;
font-size: 12px;
margin-left: 5px;
background: var(--secondary-darker);
padding: 3px 5px;
border-radius: 2px;
font-family: Roboto;
letter-spacing: 1px;
}

#search-nav .add {
height: inherit;
font-size: 20px;
border: none;
background: var(--secondary-darker);
cursor: pointer;
padding: 0 7px;
transition: 0.2s all ease;
color: #def7ff;
}

#search-nav .add:hover {
background: var(--secondary);
cursor: pointer;
}

#search-nav .add>i {
transform: skewX(20deg);
}

#search-nav button.remove {
display: none;
border: none;
position: relative;
cursor: pointer;
color: #fff5dc;
background: #ff3434e2;
margin-left: 10px;
border-radius: 50%;
line-height: 16px;
text-shadow: 1px 1px 10px #000;
font-weight: bold;
width: 20px;
}

#search-nav button.remove:hover {
cursor: pointer;
background: #ff5353e2;
}
Loading
Loading