Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions packages/builder/src/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ export class ChainDefinition {
.map((n) => this.getDependencies(n))
.flatten()
.uniq()
.value()
)
.value(),
),
);

debug('start check all');
Expand Down Expand Up @@ -225,16 +225,26 @@ export class ChainDefinition {

if (!action) {
throw new Error(
`action kind plugin not installed: "${kind}" (for action: "${n}"). please install the plugin necessary to build this package.`
`action kind plugin not installed: "${kind}" (for action: "${n}"). please install the plugin necessary to build this package.`,
);
}

validateConfig(action.validate, _.get(this.raw, n));

return action.configInject({ ...ctx, ...CannonHelperContext }, _.get(this.raw, n), {
const ctxWithHelpers = { ...ctx, ...CannonHelperContext };

const injectedConfig = action.configInject(ctxWithHelpers, _.get(this.raw, n), {
ref: this.getPackageRef(ctx),
currentLabel: n,
});

if (injectedConfig.labels) {
for (const k in injectedConfig.labels) {
injectedConfig.labels[k] = template(injectedConfig.labels[k])(ctxWithHelpers);
}
}

return injectedConfig;
}

/**
Expand All @@ -247,7 +257,7 @@ export class ChainDefinition {
n: string,
runtime: ChainBuilderRuntime,
ctx: ChainBuilderContext,
tainted: boolean
tainted: boolean,
): Promise<string[] | null> {
const kind = n.split('.')[0] as keyof typeof ActionKinds;

Expand All @@ -270,7 +280,7 @@ export class ChainDefinition {
{
ref: this.getPackageRef(ctx),
currentLabel: n,
}
},
);

if (!objs) {
Expand All @@ -297,7 +307,7 @@ export class ChainDefinition {
source: template(d.source)(ctx),
chainId: d.chainId || ctx.chainId,
preset: template(d.preset)(ctx) || 'main',
}))
})),
);
}

Expand Down Expand Up @@ -353,8 +363,8 @@ export class ChainDefinition {
if (this.sensitiveDependencies && accessComputationResults.unableToCompute && !_.get(this.raw, node).depends) {
throw new Error(
`Unable to compute dependencies for [${node}] because of advanced logic in template strings. Specify dependencies manually, like "depends = ['${_.uniq(
_.uniq(accessComputationResults.accesses).map((a) => `${this.dependencyFor.get(a)}`)
).join("', '")}']"`
_.uniq(accessComputationResults.accesses).map((a) => `${this.dependencyFor.get(a)}`),
).join("', '")}']"`,
);
}

Expand Down Expand Up @@ -451,7 +461,7 @@ export class ChainDefinition {
checkCycles(
actions = this.allActionNames,
seenNodes = new Set<string>(),
currentPath = new Set<string>()
currentPath = new Set<string>(),
): string[] | null {
for (const n of actions) {
if (seenNodes.has(n)) {
Expand Down Expand Up @@ -658,7 +668,7 @@ export class ChainDefinition {
}
return Math.max(
layers[n].actions.length + 2,
_.sumBy(layers[n].depends, (d) => this.getPrintLinesUsed(d, layers))
_.sumBy(layers[n].depends, (d) => this.getPrintLinesUsed(d, layers)),
);
}

Expand Down
Loading
Loading