in packages/blueprints/blueprint-builder/static-assets/converted-blueprint/src/blueprint.ts [72:143]
constructor(options_: Options) {
super(options_);
console.log(defaults);
// helpful typecheck for defaults
const typeCheck: Options = {
outdir: this.outdir,
...defaults,
// typescript needs some help disambiguating enums
dropdown: defaults.dropdown as Options['dropdown'],
};
const options = Object.assign(typeCheck, options_);
// add a repository
const repository = new SourceRepository(this, { title: 'code' });
// add some code to my repository by copying everything in static-assets
repository.copyStaticFiles({
from: 'starter-code',
to: './',
substitute: {}, // optional used for {{mustache}} substitutions
map: file => {
let newPath = file.path;
newPath = replaceEndWith(newPath, '_npmignore', '.npmignore');
newPath = replaceEndWith(newPath, '_gitignore', '.gitignore');
return {
...file,
path: file.path,
};
},
});
// Copy files explicitly
// StaticAsset.findAll('**').forEach(asset => {
// new SourceFile(repository, asset.path(), asset.content().toString());
// });
// create an environment, if I have one
let environment: Environment | undefined = undefined;
if (options.environment) {
environment = new Environment(this, options.environment);
}
const workflowBuilder = new WorkflowBuilder(this);
workflowBuilder.setName('this-is-my-first-workflow');
workflowBuilder.addBranchTrigger(['main']);
/**
* We can use a build action to execute some arbitrary steps
*/
workflowBuilder.addBuildAction({
actionName: 'do-something-in-an-action',
input: {
Sources: ['WorkflowSource'],
},
steps: [
'ls -la',
'echo "Hello world from a workflow!"',
'echo "If theres an account connection, I can execute in the context of that account"',
'aws sts get-caller-identity',
],
// is there is an environment, connect it to the workflow
environment: environment && convertToWorkflowEnvironment(environment),
output: {},
});
// write a workflow to my repository
new Workflow(this, repository, workflowBuilder.getDefinition());
// Create a dev environment workspace in my project
const devEnvironementDefiniton: WorkspaceDefinition = SampleWorkspaces.default;
new Workspace(this, repository, devEnvironementDefiniton);
}