Comparing version 0.14.4 to 0.15.0
@@ -45,9 +45,15 @@ const path = require('path'); | ||
const localName = path.basename(this.key); | ||
const basename = path.basename(this.key); | ||
const localName = basename.replace(/^_/, ''); | ||
config.holosource = config.holosource || localName.replace(/^_/, ''); | ||
if (!config.holosource) { | ||
config.holosource = localName; | ||
} else if (config.holosource.substr(0, 2) == '=>') { | ||
config.holosource = localName + config.holosource; | ||
} | ||
config.layer = config.layer || config.holosource; | ||
config.root = path.join('.', config.root || '.', '.'); | ||
config.files = typeof config.files == 'string' ? [config.files] : config.files; | ||
config.output = path.join(path.dirname(this.key), localName[0] == '_' ? '.' : localName, config.output || '.', '.'); | ||
config.output = path.join(path.dirname(this.key), basename[0] == '_' ? '.' : basename, config.output || '.', '.'); | ||
@@ -54,0 +60,0 @@ if (config.before) { |
@@ -24,2 +24,7 @@ const path = require('path'); | ||
const [holosourceName, holobranchName] = name.split('=>', 2); | ||
this.holosourceName = holosourceName; | ||
this.holobranchName = holobranchName || null; | ||
Object.freeze(this); | ||
@@ -33,28 +38,29 @@ } | ||
getConfigPath () { | ||
return `.holo/sources/${this.name}.toml`; | ||
return `.holo/sources/${this.holosourceName}.toml`; | ||
} | ||
async readConfig () { | ||
let config; | ||
const { name: workspaceName } = await this.workspace.getCachedConfig(); | ||
if (this.name == workspaceName) { | ||
return { | ||
if (this.holosourceName == workspaceName) { | ||
config = { | ||
$workspace: true | ||
}; | ||
} | ||
} else { | ||
config = await super.readConfig(); | ||
let config = await super.readConfig(); | ||
// overwrite from environment | ||
const envName = `HOLO_SOURCE_${this.name.replace(/-/g, '_').toUpperCase()}`; | ||
const envValue = process.env[envName]; | ||
// overwrite from environment | ||
const envName = `HOLO_SOURCE_${this.name.replace(/-/g, '_').toUpperCase()}`; | ||
const envValue = process.env[envName]; | ||
if (envValue) { | ||
const [url, ref] = envValue.split('#'); | ||
if (envValue) { | ||
const [url, ref] = envValue.split('#'); | ||
config = Object.create(config); | ||
config.url = url; | ||
config = Object.create(config); | ||
config.url = url; | ||
if (ref) { | ||
config.ref = ref; | ||
if (ref) { | ||
config.ref = ref; | ||
} | ||
} | ||
@@ -158,3 +164,3 @@ } | ||
// apply projection | ||
// apply source projection | ||
if (project) { | ||
@@ -188,2 +194,21 @@ if (!project.holobranch) { | ||
// apply mapping projection | ||
if (this.holobranchName) { | ||
logger.info(`projecting holobranch ${this.holobranchName} within source ${this.holosourceName}@${head.substr(0, 8)}`); | ||
const workspace = await repo.createWorkspaceFromRef(head); | ||
const branch = workspace.getBranch(this.holobranchName); | ||
let { lens } = await branch.getCachedConfig(); | ||
if (typeof lens != 'boolean') { | ||
lens = true; | ||
} | ||
head = await Projection.projectBranch(branch, { | ||
debug: true, | ||
lens | ||
}); | ||
logger.info(`using projection result for holobranch ${this.holobranchName} as source ${this.name}: ${head}`); | ||
} | ||
return head; | ||
@@ -215,2 +240,3 @@ } | ||
// hash source sub-worktree if available | ||
// TODO: ask the workspace if it's got a worktree or something, delegate much of this to the workspace so it can be virtual | ||
if (repo.workTree && working !== false) { | ||
@@ -217,0 +243,0 @@ const workTreeHash = await this.hashWorkTree(); |
{ | ||
"name": "hologit", | ||
"version": "0.14.4", | ||
"version": "0.15.0", | ||
"description": "Hologit automates the projection of layered composite file trees based on flat, declarative plans", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/EmergencePlatform/hologit", |
126558
2873