Skip to content

Commit a3afa8d

Browse files
Kevin/add json5 (#47)
* feat: added ability to parse json5 * feat: switch to jju for automatic file generation * feat: bumped import ui version * feat: add jsonc support * fix: fixed tests * chore: renamed references to codify.json to codify.jsonc * fix: error message to have the correct file names
1 parent 9c1acb9 commit a3afa8d

29 files changed

+732
-487
lines changed

README.md

Lines changed: 9 additions & 9 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.1 darwin-arm64 node-v20.15.1
21+
codify/0.7.2 darwin-arm64 node-v20.15.1
2222
$ codify --help [COMMAND]
2323
USAGE
2424
$ codify COMMAND
@@ -37,7 +37,7 @@ USAGE
3737

3838
## `codify apply`
3939

40-
Install or update resources on the system based on a codify.json file.
40+
Install or update resources on the system based on a codify.jsonc file.
4141

4242
```
4343
USAGE
@@ -51,7 +51,7 @@ FLAGS
5151
--debug Print additional debug logs.
5252
5353
DESCRIPTION
54-
Install or update resources on the system based on a codify.json file.
54+
Install or update resources on the system based on a codify.jsonc file.
5555
5656
Codify first generates a plan to determine the necessary execution steps. See
5757
codify plan --help for more details.
@@ -74,7 +74,7 @@ EXAMPLES
7474
$ codify apply -S <sudo password>
7575
```
7676

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

7979
## `codify destroy`
8080

@@ -95,7 +95,7 @@ DESCRIPTION
9595
Use Codify to uninstall a supported package or setting on the system.
9696
9797
This command will only work for resources with Codify support. This command
98-
can work with or without a codify.json file.
98+
can work with or without a codify.jsonc file.
9999
100100
Modes:
101101
• If a codify.json file exists, destroy the resource specified in the Codify.json file
@@ -113,7 +113,7 @@ EXAMPLES
113113
$ codify destroy
114114
```
115115

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

118118
## `codify help [COMMAND]`
119119

@@ -189,7 +189,7 @@ EXAMPLES
189189
$ codify import \*
190190
```
191191

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

194194
## `codify init`
195195

@@ -217,7 +217,7 @@ EXAMPLES
217217
$ codify init
218218
```
219219

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

222222
## `codify plan`
223223

@@ -254,7 +254,7 @@ EXAMPLES
254254
$ codify plan -p ../
255255
```
256256

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

259259
## `codify update [CHANNEL]`
260260

codify.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

package-lock.json

Lines changed: 80 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"codify": "./bin/run.js"
55
},
66
"dependencies": {
7-
"@codifycli/ink-form": "0.0.11",
7+
"@codifycli/ink-form": "0.0.12",
88
"@homebridge/node-pty-prebuilt-multiarch": "^0.12.0-beta.5",
99
"@inkjs/ui": "^2",
1010
"@oclif/core": "^4.0.8",
@@ -31,7 +31,10 @@
3131
"parse-json": "^8.1.0",
3232
"react": "^18.3.1",
3333
"semver": "^7.5.4",
34-
"supports-color": "^9.4.0"
34+
"supports-color": "^9.4.0",
35+
"json5": "^2.2.3",
36+
"@mischnic/json-sourcemap": "^0.1.1",
37+
"jju": "^1.4.0"
3538
},
3639
"description": "Codify allows users to configure settings, install new packages, and automate their systems using code instead of the GUI. Get set up on a new laptop in one click, maintain a Codify file within your project so anyone can get started and never lose your cool apps or favourite settings again.",
3740
"devDependencies": {
@@ -46,7 +49,9 @@
4649
"@types/react": "^18.3.1",
4750
"@types/semver": "^7.5.4",
4851
"@types/strip-ansi": "^5.2.1",
52+
"@types/jju": "^1.4.5",
4953
"@typescript-eslint/eslint-plugin": "^8.16.0",
54+
"@types/json5": "^2.2.0",
5055
"codify-plugin-lib": "^1.0.151",
5156
"esbuild": "^0.24.0",
5257
"esbuild-plugin-copy": "^2.1.1",

src/commands/apply.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ApplyOrchestrator } from '../orchestrators/apply.js';
66

77
export default class Apply extends BaseCommand {
88
static description =
9-
`Install or update resources on the system based on a codify.json file.
9+
`Install or update resources on the system based on a codify.jsonc file.
1010
1111
Codify first generates a plan to determine the necessary execution steps. See
1212
${chalk.bold.bgMagenta(' codify plan --help ')} for more details.

src/commands/destroy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ export default class Destroy extends BaseCommand {
1010
`Use Codify to uninstall a supported package or setting on the system.
1111
1212
This command will only work for resources with Codify support. This command
13-
can work with or without a codify.json file.
13+
can work with or without a codify.jsonc file.
1414
1515
${chalk.bold('Modes:')}
16-
• If a codify.json file exists, destroy the resource specified in the Codify.json file
16+
• If a codify.jsonc file exists, destroy the resource specified in the Codify.jsonc file
1717
with a matching type.
18-
• If a codify.json file doesn't exist, additional information may be asked to identify
18+
• If a codify.jsonc file doesn't exist, additional information may be asked to identify
1919
the specific resource to destroy.
2020
2121
For more information, visit: https://docs.codifycli.com/commands/destory`

src/commands/import.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ export default class Import extends BaseCommand {
1212
`Generate Codify configurations from already installed packages.
1313
1414
Use a space-separated list of arguments to specify the resource types to import.
15-
If a codify.json file already exists, omit arguments to update the file to match the system.
15+
If a codify.jsonc file already exists, omit arguments to update the file to match the system.
1616
1717
${chalk.bold('Modes:')}
18-
1. ${chalk.bold('No args:')} If no args are specified and an *.codify.json already exists, Codify
18+
1. ${chalk.bold('No args:')} If no args are specified and an *.codify.jsonc already exists, Codify
1919
will update the existing file with new changes on the system.
2020
2121
${chalk.underline('Command:')}
@@ -30,7 +30,7 @@ codify import nvm asdf*
3030
codify import \\* (for importing all supported resources)
3131
3232
The results can be saved in one of three ways:
33-
a. To an existing *.codify.json file
33+
a. To an existing *.codify.jsonc file
3434
b. To a new file
3535
c. Printed to the console only
3636

src/commands/init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default class Init extends BaseCommand {
1111
1212
Use this command to automatically generate Codify configs based on
1313
the currently installed system resources. By default, the new file
14-
will be written to ${chalk.bold.bgMagenta(' ~/codify.json ')}.
14+
will be written to ${chalk.bold.bgMagenta(' ~/codify.jsonc ')}.
1515
1616
For more information, visit: https://docs.codifycli.com/commands/init`
1717

src/commands/plan.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { PlanOrchestrator } from '../orchestrators/plan.js';
44

55
export default class Plan extends BaseCommand {
66
static description =
7-
`Generate an execution plan to apply changes from a codify.json file.
7+
`Generate an execution plan to apply changes from a codify.jsonc file.
88
9-
This plan lists all the changes Codify needs to make to apply the codify.json file.
9+
This plan lists all the changes Codify needs to make to apply the codify.jsonc file.
1010
The plan will not be executed. Behind the scenes, Codify performs a refresh scan to
1111
determine the current configuration and installed resources, then compares them with
1212
the desired configuration to compute the execution plan.

src/common/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export class SyntaxError extends CodifyError {
138138
}
139139

140140
formattedMessage(): string {
141-
return `Syntax error: found in codify.json: ${this.message}`
141+
return `Syntax error: found in ${this.fileName}: ${this.message}`
142142
}
143143
}
144144

0 commit comments

Comments
 (0)