Skip to content

Commit

Permalink
A couple of quick tweaks (#1401)
Browse files Browse the repository at this point in the history
- Add shell and cli-tool to generated vs code launches
- Add children to Model#toJSON()
  • Loading branch information
lauckhart authored Nov 15, 2024
1 parent f853be4 commit 40ec515
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
52 changes: 51 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "0.2.0",
"configurations": [
{
{
"type": "node",
"request": "launch",
"skipFiles": [
Expand Down Expand Up @@ -73,6 +73,56 @@
],
"program": "${workspaceFolder}/node_modules/.bin/matter-run"
},
{
"type": "node",
"request": "launch",
"skipFiles": [
"<node_internals>/**"
],
"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": [
"<node_internals>/**"
],
"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",
Expand Down
4 changes: 4 additions & 0 deletions codegen/src/generate-vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 5 additions & 1 deletion packages/model/src/models/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,11 @@ export abstract class Model<T extends BaseElement = BaseElement> {
* 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;
}

/**
Expand Down

0 comments on commit 40ec515

Please sign in to comment.