-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(commands): add test/task artifacts to command result
...and serve .garden/artifacts dir with Garden server
- Loading branch information
Showing
9 changed files
with
276 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (C) 2018 Garden Technologies, Inc. <info@garden.io> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
import { join } from "path" | ||
import { readFile } from "fs-extra" | ||
import { LogEntry } from "../logger/log-entry" | ||
|
||
/** | ||
* @param type task | test | ||
* @param name name of the task or test | ||
* @param version the version of the module that the task/test belongs to | ||
*/ | ||
export function getArtifactKey(type: "task" | "test", name: string, version: string) { | ||
return `${type}.${name}.${version}` | ||
} | ||
|
||
/** | ||
* Returns the file list from the artifact metadata file (under `.garden/artifacts/.metadata.<key>.json) | ||
* for the given artifact key. | ||
* | ||
* Returns an empty array if the metadata file is not found or if we can't parse it. | ||
*/ | ||
export async function getArtifactFileList({ | ||
artifactsPath, | ||
key, | ||
log, | ||
}: { | ||
artifactsPath: string | ||
key: string | ||
log: LogEntry | ||
}) { | ||
const metadataPath = join(artifactsPath, `.metadata.${key}.json`) | ||
let files: string[] = [] | ||
try { | ||
const metadata = await readFile(metadataPath) | ||
try { | ||
files = JSON.parse(metadata.toString()).files || [] | ||
} catch (err) { | ||
log.debug(`Failed parsing artifact metadata file: ${err.message}`) | ||
} | ||
} catch (err) { | ||
log.debug(`Failed reading metadata file: ${err.message}`) | ||
} | ||
return files | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.