Skip to content

Commit

Permalink
Update for first working program (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
iph authored Oct 5, 2021
1 parent 5c14c0c commit 9225373
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,22 @@ fn main() {

let cfn_tree = CloudformationParseTree::build(&value).unwrap();
let reference_table = ReferenceTable::new(&cfn_tree);

let import = Importer::new(&cfn_tree);

println!("{}", import.synthesize().join("\n"));
println!("import * as cdk from 'aws-cdk';");
println!("export interface NoctStackProps extends cdk.StackProps {{");
for (name, parameter) in cfn_tree.parameters.params {
println!(
"\treadonly {}: {}",
name,
camel_case(&parameter.parameter_type)
)
}
println!("}}");
println!("export class NoctStack extends cdk.Stack {{");
println!("\tconstructor(scope: cdk.App, id: string, props: NoctStackProps){{");
println!("\t\tsuper(scope, id, props);");
println!("{}", cfn_tree.mappings.synthesize());

for cond in determine_order(cfn_tree.conditions) {
Expand All @@ -56,5 +68,7 @@ fn main() {
}
println!("}});");
}
println!("====================================");

println!("\t}}");
println!("}}");
}
2 changes: 1 addition & 1 deletion src/parser/lookup_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl MappingsParseTree {
for (mapping_name, mapping) in self.mappings.iter() {
let record_type = match mapping.find_first_type() {
MappingInnerValue::String(_) => "Record<string, Record<string, string>>",
MappingInnerValue::List(_) => "Record<string, Record<string, Array<string>>",
MappingInnerValue::List(_) => "Record<string, Record<string, Array<string>>>",
};
mappings_ts_str.push_str(&format!(
"const {}: {} = {}",
Expand Down

0 comments on commit 9225373

Please sign in to comment.