From a936cf44a53fffa6cfd513fa7f3e99f887b92bde Mon Sep 17 00:00:00 2001 From: DavHau Date: Thu, 4 Nov 2021 15:48:40 +0700 Subject: [PATCH] rename dream.lock -> dream-lock.json --- src/apps/cli/commands/package.py | 26 +++++++++---------- src/apps/cli/commands/update.py | 8 +++--- src/apps/cli/default.nix | 2 +- src/default.nix | 2 +- .../translator-call-example.json | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/apps/cli/commands/package.py b/src/apps/cli/commands/package.py index b4b42834..1d7cfeb0 100644 --- a/src/apps/cli/commands/package.py +++ b/src/apps/cli/commands/package.py @@ -29,7 +29,7 @@ class PackageCommand(Command): multiple=False ), option("translator", None, "which translator to use", flag=False), - option("output", None, "output file/directory for the dream.lock", flag=False), + option("output", None, "output file/directory for the dream-lock.json", flag=False), option( "combined", None, @@ -66,7 +66,7 @@ class PackageCommand(Command): output = './.' if not os.path.isdir(output): os.mkdir(output) - filesToCreate = ['dream.lock'] + filesToCreate = ['dream-lock.json'] if self.option('default-nix'): filesToCreate.append('default.nix') if self.option('force'): @@ -78,12 +78,12 @@ class PackageCommand(Command): if any(f in existingFiles for f in filesToCreate): print( f"output directory {output} already contains a 'default.nix' " - "or 'dream.lock'. Delete first, or user '--force'.", + "or 'dream-lock.json'. Delete first, or user '--force'.", file=sys.stderr, ) exit(1) output = os.path.realpath(output) - outputDreamLock = f"{output}/dream.lock" + outputDreamLock = f"{output}/dream-lock.json" outputDefaultNix = f"{output}/default.nix" # verify source @@ -111,9 +111,9 @@ class PackageCommand(Command): print(f"Input source '{source}' does not exist", file=sys.stdout) exit(1) source = os.path.realpath(source) - # handle source from dream.lock - if source.endswith('dream.lock'): - print(f"fetching source defined via existing dream.lock") + # handle source from dream-lock.json + if source.endswith('dream-lock.json'): + print(f"fetching source defined via existing dream-lock.json") with open(source) as f: sourceDreamLock = json.load(f) sourceMainPackageName = sourceDreamLock['_generic']['mainPackageName'] @@ -255,7 +255,7 @@ class PackageCommand(Command): # raise error if output wasn't produced if not os.path.isfile(outputDreamLock): - raise Exception(f"Translator failed to create dream.lock") + raise Exception(f"Translator failed to create dream-lock.json") # read produced lock file with open(outputDreamLock) as f: @@ -366,13 +366,13 @@ class PackageCommand(Command): # store the hash in the lock lock['_generic']['sourcesCombinedHash'] = hash - # re-write dream.lock + # re-write dream-lock.json checkLockJSON(lock) lockStr = json.dumps(lock, indent=2, sort_keys = True) lockStr = lockStr\ - .replace("[\n ", "[ ")\ - .replace("\"\n ]", "\" ]")\ - .replace(",\n ", ", ") + .replace("[\n ", "[ ")\ + .replace("\"\n ]", "\" ]")\ + .replace(",\n ", ", ") with open(outputDreamLock, 'w') as f: f.write(lockStr) @@ -389,4 +389,4 @@ class PackageCommand(Command): defaultNix.write(template) print(f"Created {output}/default.nix") - print(f"Created {output}/dream.lock") \ No newline at end of file + print(f"Created {output}/dream-lock.json") \ No newline at end of file diff --git a/src/apps/cli/commands/update.py b/src/apps/cli/commands/update.py index bba2ce38..3607ed77 100644 --- a/src/apps/cli/commands/update.py +++ b/src/apps/cli/commands/update.py @@ -17,7 +17,7 @@ class UpdateCommand(Command): name = "update" options = [ - option("dream-lock", None, "dream.lock file or its parent directory", flag=False, value_required=True), + option("dream-lock", None, "dream-lock.json file or its parent directory", flag=False, value_required=True), option("updater", None, "name of the updater module to use", flag=False), option("new-version", None, "new package version", flag=False), ] @@ -27,8 +27,8 @@ class UpdateCommand(Command): self.line(f"\n{self.description}\n") dreamLockFile = os.path.abspath(self.option("dream-lock")) - if not dreamLockFile.endswith('dream.lock'): - dreamLockFile = os.path.abspath(dreamLockFile + "/dream.lock") + if not dreamLockFile.endswith('dream-lock.json'): + dreamLockFile = os.path.abspath(dreamLockFile + "/dream-lock.json") # parse dream lock with open(dreamLockFile) as f: @@ -68,7 +68,7 @@ class UpdateCommand(Command): newVersion=version, ) lock['sources'][mainPackageName][mainPackageVersion] = updatedSourceSpec - with tempfile.NamedTemporaryFile("w", suffix="dream.lock") as tmpDreamLock: + with tempfile.NamedTemporaryFile("w", suffix="dream-lock.json") as tmpDreamLock: json.dump(lock, tmpDreamLock, indent=2) tmpDreamLock.seek(0) # flushes write cache sp.run( diff --git a/src/apps/cli/default.nix b/src/apps/cli/default.nix index 2b50efcf..30b4cbb7 100644 --- a/src/apps/cli/default.nix +++ b/src/apps/cli/default.nix @@ -48,7 +48,7 @@ in }: dream2nix.riseAndShine { - dreamLock = ./dream.lock; + dreamLock = ./dream-lock.json; ${lib.optionalString (dreamLock.sources."${mainPackageName}"."${mainPackageVersion}".type == "unknown") '' sourceOverrides = oldSources: { "${mainPackageName}#${mainPackageVersion}" = ./${sourcePathRelative}; diff --git a/src/default.nix b/src/default.nix index 78be026f..2813910f 100644 --- a/src/default.nix +++ b/src/default.nix @@ -271,7 +271,7 @@ let outputs; - # produce outputs for a dream.lock or a source + # produce outputs for a dream-lock or a source riseAndShine = { dreamLock ? null, diff --git a/src/specifications/translator-call-example.json b/src/specifications/translator-call-example.json index b265149b..c041fc80 100644 --- a/src/specifications/translator-call-example.json +++ b/src/specifications/translator-call-example.json @@ -9,6 +9,6 @@ ], "outputFile": [ - "./a/b/c/dream.lock" + "./a/b/c/dream-lock.json" ] }