From 2026c9cfc659a4e1eccac06b4becbf5a84f60cc2 Mon Sep 17 00:00:00 2001 From: mariaozamiz Date: Mon, 27 May 2024 11:40:11 +0200 Subject: [PATCH] feat: add function to set namespaces --- scripts/run.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/run.ts b/scripts/run.ts index 9c0b39909..2b6f336b2 100644 --- a/scripts/run.ts +++ b/scripts/run.ts @@ -1,6 +1,7 @@ import { execSync } from "child_process"; import yargs, { Argv } from "yargs"; import { ArrayElementType } from "../src/types/utils"; +import fs from "fs"; const defaultVariant = "core-app"; const variants = [ @@ -137,12 +138,21 @@ function build(args: BuildArgs): void { run(`react-scripts build && cp -r i18n icon.png build`); run(`d2-manifest package.json build/manifest.webapp -t ${manifestType} -n '${variant.title}'`); + updateManifestNamespace(`build/manifest.webapp`, variant.file); run(`rm -f ${fileName}`); run(`cd build && zip -r ../${fileName} *`); console.info(`Written: ${fileName}`); } } +function updateManifestNamespace(manifestPath: string, variantFile: string) { + if (fs.existsSync(manifestPath)) { + const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8")); + manifest.activities.dhis.namespace = variantFile; + fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2)); + } +} + /* Start server */ type StartServerArgs = { variant: string; port: number; verbose: boolean };