Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.withLogglyHost('loggly-host')
.withDefault({
FOO: 'bar',
})
.withResolveGitRefService('my-resolver')
.run();
assert.equal(cmd.config.strains.get('default').package, '');
assert.equal(cmd.config.strains.get('dev').package, `hlx/${ref}`);
const log = await logger.getOutput();
assert.ok(log.indexOf('deployment of 1 action completed') >= 0);
assert.ok(log.indexOf(`- hlx/${ref}/html`) >= 0);
// check if written helix config contains package ref
const newCfg = new HelixConfig()
.withConfigPath(path.resolve(testRoot, 'helix-config.yaml'));
await newCfg.init();
assert.equal(newCfg.strains.get('default').package, '');
assert.equal(newCfg.strains.get('dev').package, `hlx/${ref}`);
});
}
if (this._enableAuto) {
return this.autoDeploy();
}
// get git coordinates and list affected strains
const ref = await GitUtils.getBranch(this.directory);
const giturl = new GitUrl(`${origin}#${ref}`);
const affected = this.config.strains.filterByCode(giturl);
if (affected.length === 0) {
let newStrain = this._addStrain ? this.config.strains.get(this._addStrain) : null;
if (!newStrain) {
newStrain = this.config.strains.get('default');
// if default is proxy, fall back to default default
if (newStrain.isProxy()) {
const hlx = await new HelixConfig()
.withSource(await ConfigUtils.createDefaultConfig(this.directory))
.init();
newStrain = hlx.strains.get('default');
}
newStrain = newStrain.clone();
newStrain.name = this._addStrain || uuidv4();
this.config.strains.add(newStrain);
}
newStrain.code = giturl;
// also tweak content and static url, if default is still local
if (newStrain.content.isLocal) {
newStrain.content = giturl;
}
if (newStrain.static.url.isLocal) {
newStrain.static.url = giturl;
it('config with proxy strains can be parsed', async () => {
const myconfig = await new HelixConfig().withConfigPath(proxyfile).init();
const mystrains = myconfig.strains;
assert.equal(Array.from(mystrains.entries()).length, 3);
});
it('getStrainParametersVCL generates VLC', async () => {
const strainfile = path.resolve(__dirname, 'fixtures/some-params.yaml');
const config = await new HelixConfig().withConfigPath(strainfile).init();
const mystrains = Array.from(config.strains.values());
const vclfile = fs.readFileSync(path.resolve(__dirname, 'fixtures/some-params.vcl')).toString();
assert.equal(PublishCommand.getStrainParametersVCL(mystrains).trim(), vclfile.trim());
});
async reloadConfig() {
if (!this._initialized) {
return this.init();
}
this._helixConfig = await (new HelixConfig()
.withLogger(this._helixConfig.log)
.withConfigPath(this._helixConfig.configPath)
.withDirectory(this._helixConfig.directory)
.init());
return this;
}
}
async servicePublish() {
this.tick(1, 'preparing service config for Helix', true);
if (this._filter) {
this.log.debug('filtering');
try {
const content = await GitUtils.getRawContent('.', 'master', 'helix-config.yaml');
const other = await new HelixConfig()
.withSource(content.toString())
.init();
this.log.debug(`this: ${Array.from(this.config.strains.keys()).join(', ')}`);
this.log.debug(`other: ${Array.from(other.strains.keys()).join(', ')}`);
const merged = other.merge(this.config, this._filter);
this.log.debug(Array.from(merged.strains.keys()).join(', '));
this._helixConfig = merged;
} catch (e) {
this.log.error(`Cannot merge configuration from master. Do you have a helix-config.yaml commited in the master branch?
${e}`);
throw new Error('Unable to merge configurations for selective publishing');
}
}
const body = {
constructor(logger) {
super();
this._initialized = false;
this._logger = logger || makeLogger();
this._helixConfig = new HelixConfig().withLogger(this._logger);
}