Skip to content

Commit

Permalink
Merge pull request #954 from EyeSeeTea/feat/Install-multiple-metadata…
Browse files Browse the repository at this point in the history
…-sync-flavours

feat: add function to set namespaces
  • Loading branch information
MiquelAdell authored May 28, 2024
2 parents 89032ff + 2026c9c commit 7a5d737
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scripts/run.ts
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down Expand Up @@ -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 };
Expand Down

0 comments on commit 7a5d737

Please sign in to comment.