diff --git a/garden-service/bin/add-version-files.ts b/garden-service/bin/add-version-files.ts index d1f10acc18..d79a988516 100755 --- a/garden-service/bin/add-version-files.ts +++ b/garden-service/bin/add-version-files.ts @@ -4,7 +4,7 @@ import { GitHandler } from "../src/vcs/git" import { Garden } from "../src/garden" import { Logger } from "../src/logger/logger" import { LogLevel } from "../src/logger/log-node" -import { resolve } from "path" +import { resolve, relative } from "path" import * as Bluebird from "bluebird" import { writeFile } from "fs-extra" @@ -17,19 +17,23 @@ async function addVersionFiles() { const staticPath = resolve(__dirname, "..", "static") const garden = await Garden.factory(staticPath) - const graph = await garden.getConfigGraph() - const modules = await graph.getModules() + const moduleConfigs = await garden.getRawModuleConfigs() - return Bluebird.map(modules, async (module) => { - const path = module.path + return Bluebird.map(moduleConfigs, async (config) => { + const path = config.path const versionFilePath = resolve(path, ".garden-version") const vcsHandler = new GitHandler(path) const treeVersion = await vcsHandler.getTreeVersion(path) + console.log(`${config.name} -> ${relative(staticPath, versionFilePath)}`) + return writeFile(versionFilePath, JSON.stringify(treeVersion, null, 4) + "\n") }) } addVersionFiles() - .catch(err => { throw err }) + .catch(err => { + console.error(err) + process.exit(1) + }) diff --git a/garden-service/src/garden.ts b/garden-service/src/garden.ts index 0f976c1bbd..941d3ca7eb 100644 --- a/garden-service/src/garden.ts +++ b/garden-service/src/garden.ts @@ -471,18 +471,26 @@ export class Garden { } /** - * Returns module configs that are registered in this context, fully resolved and configured (via their respective - * plugin handlers). + * Returns module configs that are registered in this context, before template resolution and validation. * Scans for modules in the project root and remote/linked sources if it hasn't already been done. */ - async resolveModuleConfigs(keys?: string[], configContext?: ModuleConfigContext): Promise { + async getRawModuleConfigs(keys?: string[]): Promise { if (!this.modulesScanned) { await this.scanModules() } - const configs: ModuleConfig[] = Object.values( + return Object.values( keys ? pickKeys(this.moduleConfigs, keys, "module") : this.moduleConfigs, ) + } + + /** + * Returns module configs that are registered in this context, fully resolved and configured (via their respective + * plugin handlers). + * Scans for modules in the project root and remote/linked sources if it hasn't already been done. + */ + async resolveModuleConfigs(keys?: string[], configContext?: ModuleConfigContext): Promise { + const configs = await this.getRawModuleConfigs(keys) if (!configContext) { configContext = new ModuleConfigContext(this, this.environment, Object.values(this.moduleConfigs))