Skip to content

Commit

Permalink
Merge pull request #509 from garden-io/fix-add-version-files
Browse files Browse the repository at this point in the history
chore(build): fix add-version-files script
  • Loading branch information
eysi09 authored Feb 4, 2019
2 parents 1b1ed23 + 026c93e commit eae7398
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
16 changes: 10 additions & 6 deletions garden-service/bin/add-version-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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)
})
16 changes: 12 additions & 4 deletions garden-service/src/garden.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ModuleConfig[]> {
async getRawModuleConfigs(keys?: string[]): Promise<ModuleConfig[]> {
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<ModuleConfig[]> {
const configs = await this.getRawModuleConfigs(keys)

if (!configContext) {
configContext = new ModuleConfigContext(this, this.environment, Object.values(this.moduleConfigs))
Expand Down

0 comments on commit eae7398

Please sign in to comment.