Update proxying, swap /zammad and /link

This commit is contained in:
Darren Clarke 2025-02-06 13:03:31 +01:00
parent 2fd85f045c
commit 9283227074
24 changed files with 3317 additions and 2822 deletions

View file

@ -1,7 +1,7 @@
import { ServiceConfig } from "../lib/service";
const getQRCode = async (token: string): Promise<Record<string, string>> => {
const url = `/api/signal/bots/${token}`;
const url = `/link/api/signal/bots/${token}`;
const result = await fetch(url, { cache: "no-store" });
const { qr } = await result.json();

View file

@ -2,7 +2,7 @@ import { ServiceConfig } from "../lib/service";
// import { generateSelectOneAction } from "../lib/actions";
const getQRCode = async (token: string) => {
const url = `/api/whatsapp/bots/${token}`;
const url = `/link/api/whatsapp/bots/${token}`;
const result = await fetch(url, { cache: "no-store" });
const { qr } = await result.json();

View file

@ -11,7 +11,7 @@
"@mui/material": "^5",
"@mui/x-data-grid-pro": "^7.18.0",
"kysely": "0.26.1",
"next": "14.2.13",
"next": "^14.2.23",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-qr-code": "^2.0.15"

View file

@ -13,7 +13,7 @@
"@mui/x-data-grid-pro": "^7.18.0",
"@mui/x-date-pickers-pro": "^7.18.0",
"date-fns": "^4.1.0",
"next": "14.2.13",
"next": "^14.2.23",
"next-auth": "^4.24.8",
"react": "18.3.1",
"react-cookie": "^7.2.0",

View file

@ -11,7 +11,7 @@
"@mui/material": "^5",
"@mui/x-data-grid-pro": "^7.18.0",
"@mui/x-license": "^7.18.0",
"next": "14.2.13",
"next": "^14.2.23",
"react": "18.3.1",
"react-dom": "18.3.1"
},

View file

@ -1,18 +1,20 @@
#!/usr/bin/env node
import { promises as fs } from "fs";
import { promisify } from "util";
import glob from "glob";
import { glob } from "glob";
import path from "path";
import os from "os";
const packageFile = async (actualPath: string): Promise<any> => {
console.log(`Packaging: ${actualPath}`);
console.info(`Packaging: ${actualPath}`);
const packagePath = actualPath.slice(4);
const data = await fs.readFile(actualPath, "utf-8");
const content = Buffer.from(data, "utf-8").toString("base64");
const fileStats = await fs.stat(actualPath);
const permission = parseInt((fileStats.mode & 0o777).toString(8).slice(-3), 10);
const permission = parseInt(
(fileStats.mode & 0o777).toString(8).slice(-3),
10,
);
return {
location: packagePath,
permission,
@ -23,7 +25,12 @@ const packageFile = async (actualPath: string): Promise<any> => {
const packageFiles = async () => {
const packagedFiles: any[] = [];
const ignoredPatterns = [/\.gitkeep/, /Gemfile/, /Gemfile.lock/, /\.ruby-version/];
const ignoredPatterns = [
/\.gitkeep/,
/Gemfile/,
/Gemfile.lock/,
/\.ruby-version/,
];
const processDir = async (dir: string) => {
const entries = await fs.readdir(dir, { withFileTypes: true });
@ -43,7 +50,11 @@ const packageFiles = async () => {
return packagedFiles;
};
export const createZPM = async ({ name, displayName, version }: Record<string, string>) => {
export const createZPM = async ({
name,
displayName,
version,
}: Record<string, string>) => {
const files = await packageFiles();
const skeleton = {
name: displayName,
@ -53,29 +64,32 @@ export const createZPM = async ({ name, displayName, version }: Record<string, s
url: `https://gitlab.com/digiresilience/link/link-stack/packages/${name}`,
buildhost: os.hostname(),
builddate: new Date().toISOString(),
files
files,
};
const pkg = JSON.stringify(skeleton, null, 2);
try {
// @ts-ignore
const gs = promisify(glob);
const files = await gs(`../../docker/zammad/addons/${name}-v*.zpm`);
const files = await glob(`../../docker/zammad/addons/${name}-v*.zpm`, {});
for (const file of files) {
await fs.unlink(file);
console.log(`${file} was deleted`);
console.info(`${file} was deleted`);
}
} catch (err) {
console.error(err);
}
await fs.writeFile(`../../docker/zammad/addons/${name}-v${version}.zpm`, pkg, 'utf-8');
await fs.writeFile(
`../../docker/zammad/addons/${name}-v${version}.zpm`,
pkg,
"utf-8",
);
};
const main = async () => {
const packageJSON = JSON.parse(await fs.readFile("./package.json", "utf-8"));
const { name: fullName, displayName, version } = packageJSON;
console.log(`Building addon ${displayName} v${version}`);
console.info(`Building addon ${displayName} v${version}`);
const name = fullName.split("/").pop();
await createZPM({ name, displayName, version });
};