aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authoroldmud0 <oldmud0@users.noreply.github.com>2019-04-03 16:47:16 -0500
committeroldmud0 <oldmud0@users.noreply.github.com>2019-04-03 16:47:16 -0500
commitbc92942d29eb43b6f8a37ca8ae4ca303a5f28b96 (patch)
treed109380d38e567a224a3977b896bf54801a96825 /scripts
parent153c458f9e6d95a3e1ee205be28dbdbb32ee88eb (diff)
Allow overwriting versions of same name
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/update_manifest.js28
1 files changed, 23 insertions, 5 deletions
diff --git a/scripts/update_manifest.js b/scripts/update_manifest.js
index bcb3ac7b..71fa3f86 100755
--- a/scripts/update_manifest.js
+++ b/scripts/update_manifest.js
@@ -26,15 +26,15 @@ argParser.addArgument("version", {
});
argParser.addArgument([ "-f", "--full" ], {
metavar: "<full zip file>", type: isFile, nargs: 1,
- dest: "fullZipFile"
+ dest: "fullZipFileArgs"
});
argParser.addArgument([ "-i", "--incremental" ], {
- type: isFile, nargs: 2, dest: "incremental",
+ type: isFile, nargs: 2, dest: "incrementalArgs",
metavar: ["<incremental zip file>", "<file containing list of deleted files>"]
});
argParser.addArgument([ "-e", "--executable" ], {
metavar: "[executable file]", nargs: 1,
- dest: "executable"
+ dest: "executableArgs"
});
const {
@@ -49,6 +49,12 @@ const [incrementalZipFile, deletionsFile] = incrementalArgs || [];
const [fullZipFile] = fullZipFileArgs || [];
const [executable] = executableArgs || [];
+// Do one final check
+if (!incrementalZipFile && !fullZipFile) {
+ console.error("No download archive specified! Abort.");
+ process.exit(1);
+}
+
const manifest = JSON.parse(fs.readFileSync(manifestFile));
const deleteActions = deletionsFile ? fs.readFileSync(deletionsFile)
@@ -61,7 +67,7 @@ const deleteActions = deletionsFile ? fs.readFileSync(deletionsFile)
const urlBase = "https://s3.wasabisys.com/ao-downloads/";
-manifest.versions = [{
+const versionEntry = {
version,
executable,
prev: manifest.versions[0] ? manifest.versions[0].version : undefined,
@@ -84,6 +90,18 @@ manifest.versions = [{
.digest("hex")
}
] : undefined
-}, ...manifest.versions];
+};
+
+const existingVersion = manifest.versions.filter(v => v.version == version);
+if (existingVersion) {
+ console.warn(`Warning: version ${version} already exists. Adding new values.`);
+
+ // Don't overwrite prev - it will cause headaches
+ delete versionEntry.prev;
+
+ Object.assign(existingVersion, versionEntry);
+} else {
+ manifest.versions = [versionEntry, ...manifest.versions];
+}
fs.writeFileSync(manifestFile, JSON.stringify(manifest, null, 4));