Skip to content

Commit

Permalink
chore: add schema validation (and examples) on some pm commands
Browse files Browse the repository at this point in the history
  • Loading branch information
npenin committed Sep 19, 2024
1 parent 184abfc commit f7f2b99
Show file tree
Hide file tree
Showing 10 changed files with 250 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"**/node_modules/*/**": true
},
"sync.quietSync": true,
"debug.javascript.autoAttachFilter": "always",
"debug.javascript.autoAttachFilter": "onlyWithFlag",
"liveshare.connectionMode": "relay",
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
Expand Down
106 changes: 105 additions & 1 deletion packages/pm/commands.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "commands",
"name": "pm",
"commands": [
{
"name": "$init",
Expand Down Expand Up @@ -254,6 +254,9 @@
},
"cli": {
"inject": []
},
"html-form": {
"inject": []
}
}
},
Expand Down Expand Up @@ -484,6 +487,35 @@
"param.0",
"context"
]
},
"schema": {
"inject": [
"$container",
"param.0",
"param.1"
],
"schema": {
"$defs": {
"param.0": {
"type": "string"
},
"param.1": {
"type": "object",
"properties": {
"wait": {
"type": "boolean"
}
}
}
}
}
},
"html-form": {
"inject": [
"$container",
"param.0",
"param.1"
]
}
}
},
Expand Down Expand Up @@ -539,6 +571,60 @@
"context"
],
"usage": "start <program>"
},
"html-form": {
"inject": [
"$container",
"param.0",
"param.1",
"param.2"
]
},
"schema": {
"inject": [
"$container",
"param.0",
"param.1",
"param.2"
],
"schema": {
"$defs": {
"param.0": {
"type": "string"
},
"param.1": {
"type": "object",
"properties": {
"wait": {
"type": "boolean"
},
"inspect": {
"type": "boolean"
},
"new": {
"type": "boolean"
},
"name": {
"type": "string"
},
"program": {
"type": "string"
}
}
},
"param.2": {
"type": "object",
"properties": {
"args": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
}
}
},
Expand All @@ -561,6 +647,24 @@
"inject": [
"param.0"
]
},
"html-form": {
"inject": [
"param.0"
]
},
"schema": {
"inject": [
"param.0"
],
"schema": {
"$defs": {
"param.0": {
"type": "string",
"description": "The name of the container to get the status of"
}
}
}
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions packages/pm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"version": "9.3.17",
"scripts": {
"test": "echo 1",
"generate": "ac generate dist/esm/commands commands.json",
"generate": "ac generate dist/esm/commands commands.json --name pm",
"generate-metadata": "ac generate-metadata commands.json src/container.ts",
"prepack": "../../makeCjs.sh",
"akala-install": "akala plugins add dist/esm/akala.mjs"
Expand Down Expand Up @@ -70,4 +70,4 @@
},
"types": "./dist/esm/index.d.ts",
"typings": "./dist/esm/index.d.ts"
}
}
3 changes: 3 additions & 0 deletions packages/pm/src/commands/ls.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
},
"cli": {
"inject": []
},
"html-form": {
"inject": []
}
}
29 changes: 29 additions & 0 deletions packages/pm/src/commands/restart.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,34 @@
"param.0",
"context"
]
},
"schema": {
"inject": [
"$container",
"param.0",
"param.1"
],
"schema": {
"$defs": {
"param.0": {
"type": "string"
},
"param.1": {
"type": "object",
"properties": {
"wait": {
"type": "boolean"
}
}
}
}
}
},
"html-form": {
"inject": [
"$container",
"param.0",
"param.1"
]
}
}
54 changes: 54 additions & 0 deletions packages/pm/src/commands/start.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,59 @@
"context"
],
"usage": "start <program>"
},
"html-form": {
"inject": [
"$container",
"param.0",
"param.1",
"param.2"
]
},
"schema": {
"inject": [
"$container",
"param.0",
"param.1",
"param.2"
],
"schema": {
"$defs": {
"param.0": {
"type": "string"
},
"param.1": {
"type": "object",
"properties": {
"wait": {
"type": "boolean"
},
"inspect": {
"type": "boolean"
},
"new": {
"type": "boolean"
},
"name": {
"type": "string"
},
"program": {
"type": "string"
}
}
},
"param.2": {
"type": "object",
"properties": {
"args": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
}
}
18 changes: 18 additions & 0 deletions packages/pm/src/commands/status.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,23 @@
"inject": [
"param.0"
]
},
"html-form": {
"inject": [
"param.0"
]
},
"schema": {
"inject": [
"param.0"
],
"schema": {
"$defs": {
"param.0": {
"type": "string",
"description": "The name of the container to get the status of"
}
}
}
}
}
19 changes: 19 additions & 0 deletions packages/pm/src/commands/stop.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,24 @@
}
},
"usage": "stop [process]"
},
"html-form": {
"inject": [
"param.0",
"$container"
]
},
"schema": {
"inject": [
"param.0",
"$container"
],
"schema": {
"$defs": {
"param.0": {
"type": "string"
}
}
}
}
}
19 changes: 18 additions & 1 deletion packages/pm/src/commands/version.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,26 @@
]
},
"cli": {
"inject": [
"options.packageName",
"options.folder"
],
"usage": "version <packageName> [folder]"
},
"schema": {
"inject": [
"param.0",
"param.1"
]
],
"schema": {
"$defs": {
"param.0": {
"type": "string"
},
"param.1": {
"type": "string"
}
}
}
}
}
4 changes: 1 addition & 3 deletions packages/pm/src/commands/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,4 @@ export default async function version(this: State, packageName: string, folder:
delete require.cache[join(path, 'node_modules', packageName, './package.json')];
}
return packageConfig.version;
}

exports.default.$inject = ['param.0', 'param.1']
}

0 comments on commit f7f2b99

Please sign in to comment.