From 4e3bf344381c069bf4011644a0a75e338173b215 Mon Sep 17 00:00:00 2001 From: Greg Lauckhart Date: Fri, 15 Nov 2024 12:54:06 -0800 Subject: [PATCH] A couple of quick tweaks - Add shell and cli-tool to generated vs code launches - Add children to Model#toJSON() --- .vscode/launch.json | 52 +++++++++++++++++++++++++++++- codegen/src/generate-vscode.ts | 4 +++ packages/model/src/models/Model.ts | 6 +++- 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 1702eeb27..3e73fc72d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,7 +1,7 @@ { "version": "0.2.0", "configurations": [ - { + { "type": "node", "request": "launch", "skipFiles": [ @@ -73,6 +73,56 @@ ], "program": "${workspaceFolder}/node_modules/.bin/matter-run" }, + { + "type": "node", + "request": "launch", + "skipFiles": [ + "/**" + ], + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen", + "runtimeArgs": [ + "--enable-source-maps" + ], + "outFiles": [ + "${workspaceFolder}/**/dist/esm/**/*.js", + "${workspaceFolder}/**/build/esm/**/*.js" + ], + "presentation": { + "clear": true + }, + "name": "Run shell", + "cwd": "${workspaceFolder}/packages/nodejs-shell", + "args": [ + "dist/cjs/app.js" + ], + "program": "${workspaceFolder}/node_modules/.bin/matter-run" + }, + { + "type": "node", + "request": "launch", + "skipFiles": [ + "/**" + ], + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen", + "runtimeArgs": [ + "--enable-source-maps" + ], + "outFiles": [ + "${workspaceFolder}/**/dist/esm/**/*.js", + "${workspaceFolder}/**/build/esm/**/*.js" + ], + "presentation": { + "clear": true + }, + "name": "Run CLI tool", + "cwd": "${workspaceFolder}/packages/cli-tool", + "args": [ + "bin/matter.js" + ], + "program": "${workspaceFolder}/node_modules/.bin/matter-run" + }, { "type": "node", "request": "launch", diff --git a/codegen/src/generate-vscode.ts b/codegen/src/generate-vscode.ts index a2b99a12d..5d5d211fa 100644 --- a/codegen/src/generate-vscode.ts +++ b/codegen/src/generate-vscode.ts @@ -59,6 +59,10 @@ addTest({ name: "All tests" }); addTest({ name: "Test current file", args: ["--spec", "${input:testFile}", "--all-logs", "esm"] }); addRun({ name: "Run current file", args: ["${file}"] }); +// Generate tool launchers +addRun({ name: "Run shell", cwd: Package.workspace.relative("packages/nodejs-shell"), args: ["dist/cjs/app.js"] }); +addRun({ name: "Run CLI tool", cwd: Package.workspace.relative("packages/cli-tool"), args: ["bin/matter.js"] }); + // Generate launches for each project that has tests const graph = await Graph.load(); for (const node of graph.nodes) { diff --git a/packages/model/src/models/Model.ts b/packages/model/src/models/Model.ts index b78cf2ba4..a540bf93b 100644 --- a/packages/model/src/models/Model.ts +++ b/packages/model/src/models/Model.ts @@ -339,7 +339,11 @@ export abstract class Model { * Convert model to JSON. */ toJSON() { - return this.valueOf(); + const fields = this.valueOf(); + if (this.children.length) { + fields.children = this.children.map(child => child.toJSON()); + } + return fields; } /**