in packages/blueprints/blueprint/src/blueprint.ts [47:113]
constructor(options: Options) {
super({
name: 'CodeCatalystBlueprint',
...options,
});
const rootDir = path.resolve(this.outdir);
this.context = {
rootDir,
spaceName: process.env.CONTEXT_SPACENAME,
environmentId: process.env.CONTEXT_ENVIRONMENTID,
branchName: process.env.BRANCH_NAME,
resynthesisPhase: (process.env.RESYNTH_PHASE || 'PROPOSED') as ResynthesisPhase,
npmConfiguration: {
token: process.env.NPM_CONFIG_TOKEN,
registry: process.env.NPM_CONFIG_REGISTRY ?? '',
},
package: {
name: process.env.PACKAGE_NAME,
version: process.env.PACKAGE_VERSION,
},
project: {
name: process.env.CONTEXT_PROJECTNAME,
bundlepath: process.env.EXISTING_BUNDLE_ABS,
options: getOptions(path.join(process.env.EXISTING_BUNDLE_ABS || '', OPTIONS_FILE)),
blueprint: {
instantiationId: process.env.CUR_INSTANTIATION_ID,
instantiations: structureExistingBlueprints(process.env.INSTANTIATIONS_ABS),
},
src: {
listRepositoryNames: (): string[] => {
const repoBundlePath = path.join(this.context.project.bundlepath || '', 'src');
if (this.context.project.bundlepath && fs.existsSync(repoBundlePath)) {
return fs.readdirSync(repoBundlePath).filter(file => {
const fileLocation = path.join(repoBundlePath, file);
return fs.existsSync(fileLocation) && fs.statSync(fileLocation).isDirectory();
});
}
return [];
},
findAll: (_options?: TraversalOptions) => traverse(this.context.project.bundlepath, _options),
},
},
durableStoragePath:
process.env.DURABLE_STORAGE_ABS && fs.existsSync(process.env.DURABLE_STORAGE_ABS) ? process.env.DURABLE_STORAGE_ABS : rootDir,
wizardOptionsPath: process.env.WIZARD_OPTIONS_ABS ?? path.join(rootDir, 'options'),
};
this.durableState = new DurableStorage(this, path.join(this.context.durableStoragePath, 'durable-storage'));
for (const component of this.components) {
component.synthesize = () => {};
}
// write the options to the bundle
this.writeOptionsToBundle(options);
const { branch, title, description } = defaultResynthPR({
context: this.context,
options,
});
this.resynthPullRequest = {
originBranch: branch,
title,
description,
};
}