Skip to content

Commit 50459b2

Browse files
committed
feat: Added validate method. Bumped to 0.9.0
1 parent 220bc16 commit 50459b2

File tree

3 files changed

+80
-16
lines changed

3 files changed

+80
-16
lines changed

README.md

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $ npm install -g codify
1818
$ codify COMMAND
1919
running command...
2020
$ codify (--version)
21-
codify/0.7.2 darwin-arm64 node-v20.15.1
21+
codify/0.9.0 darwin-arm64 node-v20.15.1
2222
$ codify --help [COMMAND]
2323
USAGE
2424
$ codify COMMAND
@@ -34,6 +34,7 @@ USAGE
3434
* [`codify init`](#codify-init)
3535
* [`codify plan`](#codify-plan)
3636
* [`codify update [CHANNEL]`](#codify-update-channel)
37+
* [`codify validate`](#codify-validate)
3738

3839
## `codify apply`
3940

@@ -74,7 +75,7 @@ EXAMPLES
7475
$ codify apply -S <sudo password>
7576
```
7677

77-
_See code: [src/commands/apply.ts](https://github.com/kevinwang5658/codify/blob/v0.7.2/src/commands/apply.ts)_
78+
_See code: [src/commands/apply.ts](https://github.com/kevinwang5658/codify/blob/v0.9.0/src/commands/apply.ts)_
7879

7980
## `codify destroy`
8081

@@ -98,9 +99,9 @@ DESCRIPTION
9899
can work with or without a codify.jsonc file.
99100
100101
Modes:
101-
• If a codify.json file exists, destroy the resource specified in the Codify.json file
102+
• If a codify.jsonc file exists, destroy the resource specified in the Codify.jsonc file
102103
with a matching type.
103-
• If a codify.json file doesn't exist, additional information may be asked to identify
104+
• If a codify.jsonc file doesn't exist, additional information may be asked to identify
104105
the specific resource to destroy.
105106
106107
For more information, visit: https://docs.codifycli.com/commands/destory
@@ -113,7 +114,7 @@ EXAMPLES
113114
$ codify destroy
114115
```
115116

116-
_See code: [src/commands/destroy.ts](https://github.com/kevinwang5658/codify/blob/v0.7.2/src/commands/destroy.ts)_
117+
_See code: [src/commands/destroy.ts](https://github.com/kevinwang5658/codify/blob/v0.9.0/src/commands/destroy.ts)_
117118

118119
## `codify help [COMMAND]`
119120

@@ -153,10 +154,10 @@ DESCRIPTION
153154
Generate Codify configurations from already installed packages.
154155
155156
Use a space-separated list of arguments to specify the resource types to import.
156-
If a codify.json file already exists, omit arguments to update the file to match the system.
157+
If a codify.jsonc file already exists, omit arguments to update the file to match the system.
157158
158159
Modes:
159-
1. No args: If no args are specified and an *.codify.json already exists, Codify
160+
1. No args: If no args are specified and an *.codify.jsonc already exists, Codify
160161
will update the existing file with new changes on the system.
161162
162163
Command:
@@ -171,7 +172,7 @@ DESCRIPTION
171172
codify import \* (for importing all supported resources)
172173
173174
The results can be saved in one of three ways:
174-
a. To an existing *.codify.json file
175+
a. To an existing *.codify.jsonc file
175176
b. To a new file
176177
c. Printed to the console only
177178
@@ -189,7 +190,7 @@ EXAMPLES
189190
$ codify import \*
190191
```
191192

192-
_See code: [src/commands/import.ts](https://github.com/kevinwang5658/codify/blob/v0.7.2/src/commands/import.ts)_
193+
_See code: [src/commands/import.ts](https://github.com/kevinwang5658/codify/blob/v0.9.0/src/commands/import.ts)_
193194

194195
## `codify init`
195196

@@ -209,19 +210,19 @@ DESCRIPTION
209210
210211
Use this command to automatically generate Codify configs based on
211212
the currently installed system resources. By default, the new file
212-
will be written to ~/codify.json .
213+
will be written to ~/codify.jsonc .
213214
214215
For more information, visit: https://docs.codifycli.com/commands/init
215216
216217
EXAMPLES
217218
$ codify init
218219
```
219220

220-
_See code: [src/commands/init.ts](https://github.com/kevinwang5658/codify/blob/v0.7.2/src/commands/init.ts)_
221+
_See code: [src/commands/init.ts](https://github.com/kevinwang5658/codify/blob/v0.9.0/src/commands/init.ts)_
221222

222223
## `codify plan`
223224

224-
Generate an execution plan to apply changes from a codify.json file.
225+
Generate an execution plan to apply changes from a codify.jsonc file.
225226

226227
```
227228
USAGE
@@ -234,9 +235,9 @@ FLAGS
234235
--debug Print additional debug logs.
235236
236237
DESCRIPTION
237-
Generate an execution plan to apply changes from a codify.json file.
238+
Generate an execution plan to apply changes from a codify.jsonc file.
238239
239-
This plan lists all the changes Codify needs to make to apply the codify.json file.
240+
This plan lists all the changes Codify needs to make to apply the codify.jsonc file.
240241
The plan will not be executed. Behind the scenes, Codify performs a refresh scan to
241242
determine the current configuration and installed resources, then compares them with
242243
the desired configuration to compute the execution plan.
@@ -254,7 +255,7 @@ EXAMPLES
254255
$ codify plan -p ../
255256
```
256257

257-
_See code: [src/commands/plan.ts](https://github.com/kevinwang5658/codify/blob/v0.7.2/src/commands/plan.ts)_
258+
_See code: [src/commands/plan.ts](https://github.com/kevinwang5658/codify/blob/v0.9.0/src/commands/plan.ts)_
258259

259260
## `codify update [CHANNEL]`
260261

@@ -293,4 +294,32 @@ EXAMPLES
293294
```
294295

295296
_See code: [@oclif/plugin-update](https://github.com/oclif/plugin-update/blob/v4.6.13/src/commands/update.ts)_
297+
298+
## `codify validate`
299+
300+
Validate a codify.jsonc/codify.json/codify.yaml file.
301+
302+
```
303+
USAGE
304+
$ codify validate [--debug] [-o plain|default|json] [-p <value>]
305+
306+
FLAGS
307+
-o, --output=<option> [default: default] Control the output format.
308+
<options: plain|default|json>
309+
-p, --path=<value> Path to run Codify from.
310+
--debug Print additional debug logs.
311+
312+
DESCRIPTION
313+
Validate a codify.jsonc/codify.json/codify.yaml file.
314+
315+
For more information, visit: https://docs.codifycli.com/commands/validate
316+
317+
318+
EXAMPLES
319+
$ codify validate
320+
321+
$ codify validate --path=../../import.codify.jsonc
322+
```
323+
324+
_See code: [src/commands/validate.ts](https://github.com/kevinwang5658/codify/blob/v0.9.0/src/commands/validate.ts)_
296325
<!-- commandsstop -->

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
"start:dev": "./bin/dev.js",
129129
"start:vm": "npm run build && npm run pack:macos && npm run start:vm"
130130
},
131-
"version": "0.8.0",
131+
"version": "0.9.0",
132132
"bugs": "https://github.com/kevinwang5658/codify/issues",
133133
"keywords": [
134134
"oclif"

src/commands/validate.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { BaseCommand } from '../common/base-command.js';
2+
import { ValidateOrchestrator } from '../orchestrators/validate.js';
3+
import { CodifyParser } from '../parser/index.js';
4+
5+
export default class Validate extends BaseCommand {
6+
static description =
7+
`Validate a codify.jsonc/codify.json/codify.yaml file.
8+
9+
For more information, visit: https://docs.codifycli.com/commands/validate
10+
`
11+
12+
static flags = {}
13+
14+
static examples = [
15+
'<%= config.bin %> <%= command.id %>',
16+
'<%= config.bin %> <%= command.id %> --path=../../import.codify.jsonc',
17+
]
18+
19+
async init(): Promise<void> {
20+
console.log('Running Codify validate...')
21+
return super.init();
22+
}
23+
24+
public async run(): Promise<void> {
25+
const { flags } = await this.parse(Validate)
26+
27+
await ValidateOrchestrator.run({
28+
path: flags.path,
29+
}, this.reporter)
30+
31+
await CodifyParser.parse(flags.path);
32+
33+
process.exit(0);
34+
}
35+
}

0 commit comments

Comments
 (0)