Skip to content

Commit d43ef46

Browse files
Kevin/0.6.0 (#44)
* feat: WIP refactored default reporter to use a new statement management library (jotai) instead of being event based * feat: WIP transitioned apply and prompts to the new model * feat: Updated all flows to use the new atom system for the default renderer * feat: Updated imports * feat: Added unit test for default component * fix: Fixed the progress output for destroy * fix: Additional prompt fixes for destroy * feat: WIP refactored variable names and moved getRequiredParameters to the plugin * fix: Fix tests * feat: Added resource-info entity * feat: Renamed reporter method to promptUserForParameterValues * feat: Switched to using the custom codify-ink-form library to render the import prompt * feat: Added interface for new generic getValue call in reporters * feat: Refactored the import orchestrator and default renderer to use the new form * feat: Parallelized imports * feat: Added prompt for users to select results to save * feat: Added new isSameOnSystem method on resource entity + tests * feat: Added new flow for saving import to file * feat: WIP added a file modification calculator to calculate imports * feat: WIP added ability to delete a resource from an existing file * feat: WIP switched to a new calculation for deletes that removes additional spaces as well * feat: WIP delete improvements and bug fixes * feat: WIP added updates (supports both single line and multi-line configs) * feat: Added ability to insert new configs * feat: Removed writing to new files from file modification calculator * feat: Added rendering for imports and added custom diff implementation to display the file changes * feat: Split printing logic for file diff another file + fixed bugs with logic * feat: Added parameter key sorting so that the order of parameters remains the same. For new resources, it will default to alphabetical order. Modified the import result to not show the JSON. Fixed bug with not adding trimmed string back and resource ordering issues. * feat: Added generic display message method to the reporter. Added messaging after all save file paths for imports. * feat: Added messaging for all paths in import. Added back resource config display when user checks "no" for saving. * feat: Added wild card matching for import * feat: Added default values for resources that already exist in the project and fixed bug with yoga memory management for large imports * feat: Added ability to import into an existing codify file without any effort (codify import with no arguments). Fixed bug with memory access by limiting how many sub-progresses are shown. Fixed file bug with one resource updates * fix: Fixed most tests * feat: Added integration tests for import command and fixed bugs * fix: Fixed bug with memfs volume not resetting between tests * feat: Added support for new import prompts in debug and plain reporters. Fixed build errors and bugs * fix: CI not being able to pull private packages * fix: CI not being able to pull private packages 2 * fix: Removed some bad tests (wasn't useful) * feat: Updated to importAndDestroy and added filtering for preventImport * feat: Added kill listeners so process gets killed properly * feat: Added handler for * expansion in zsh and updated the help for the import command * feat: Switched to using identifying parameters * feat: Moved resource matching to the plugin for more accurate matching * feat: Moved validation to a separate orchestrator and added validation for improts * fix: Fixed tests and bug fixes * fix: Fixed import params * fix: Added back removed elements and fixed memory bug * feat: Added helpful comment * feat: Added import prompt to help improve ux of imports and updated to the latest ink-form with improved import ux * fix: Finally found a fix to the memory issues. It was because of backpressure from too many updates due to the spinner updating on every log. Updated UI with new codify ink-form version * fix: Removed validate from import * fix: Fixed test and plain reporter
1 parent 8ddb124 commit d43ef46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+4024
-673
lines changed

.eslintrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
"unicorn/no-array-for-each": "off",
1919
"unicorn/prefer-object-from-entries": "off",
2020
"unicorn/prefer-type-error": "off",
21-
"no-await-in-loop": "off",
2221
"quotes": [
2322
"error",
2423
"single"
25-
]
24+
],
25+
"no-await-in-loop": "off"
2626
},
2727
"ignorePatterns": [
2828
"*.test.ts"

.github/workflows/run-unit-tests.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111

1212
steps:
1313
- uses: actions/checkout@v4
14+
- run: echo -e "\n//npm.pkg.github.com/:_authToken=${{ secrets.PACKAGES_PAT_GITHUB }}" >> ./.npmrc
1415
- name: Use Node.js 20
1516
uses: actions/setup-node@v4
1617
with:

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@codifycli:registry=https://npm.pkg.github.com

README.md

Lines changed: 35 additions & 8 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.5.1 darwin-arm64 node-v20.15.1
21+
codify/0.6.0 darwin-arm64 node-v20.15.1
2222
$ codify --help [COMMAND]
2323
USAGE
2424
$ codify COMMAND
@@ -62,7 +62,7 @@ EXAMPLES
6262
$ codify apply --path ~
6363
```
6464

65-
_See code: [src/commands/apply/index.ts](https://github.com/kevinwang5658/codify/blob/v0.5.1/src/commands/apply/index.ts)_
65+
_See code: [src/commands/apply/index.ts](https://github.com/kevinwang5658/codify/blob/v0.6.0/src/commands/apply/index.ts)_
6666

6767
## `codify destroy`
6868

@@ -89,7 +89,7 @@ EXAMPLES
8989
$ codify destroy homebrew nvm
9090
```
9191

92-
_See code: [src/commands/destroy.ts](https://github.com/kevinwang5658/codify/blob/v0.5.1/src/commands/destroy.ts)_
92+
_See code: [src/commands/destroy.ts](https://github.com/kevinwang5658/codify/blob/v0.6.0/src/commands/destroy.ts)_
9393

9494
## `codify help [COMMAND]`
9595

@@ -113,7 +113,7 @@ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.1
113113

114114
## `codify import`
115115

116-
Generate codify configs from existing installations
116+
Generate codify configs from already installed packages. Use a list of space separated arguments to specify the resource types to import. Leave blank to import all resource in an existing *.codify.json file.
117117

118118
```
119119
USAGE
@@ -130,13 +130,40 @@ GLOBAL FLAGS
130130
--json Format output as json.
131131
132132
DESCRIPTION
133-
Generate codify configs from existing installations
133+
Generate codify configs from already installed packages. Use a list of space separated arguments to specify the
134+
resource types to import. Leave blank to import all resource in an existing *.codify.json file.
135+
136+
Modes:
137+
1. No args: if no args are specified and an *.codify.json already exists. Then codify will update the existing file
138+
with any new changes to the resources specified in the file/files.
139+
140+
Command: codify import
141+
142+
2. With args: specify specific resources to import using arguments. Wild card matching is supported using '*' and ?
143+
(Note: in zsh * expands to the current dir and needs to be escaped using \* or '*'). A prompt will be shown if more
144+
information is required to complete the import.
145+
146+
Example: codify import nvm asdf\*, codify import \* (for importing all supported resources)
147+
148+
The results can then be saved:
149+
a. To an existing *.codify.json file
150+
b. To a new file
151+
c. Or only printed to console
152+
153+
Codify will try to smartly insert new configs by following existing spacing and formatting.
154+
134155
135156
EXAMPLES
136-
$ codify import homebrew nvm
157+
$ codify import homebrew nvm asdf\*
158+
159+
$ codify import
160+
161+
$ codify import git-clone --path ../my/other/folder
162+
163+
$ codify import \*
137164
```
138165

139-
_See code: [src/commands/import.ts](https://github.com/kevinwang5658/codify/blob/v0.5.1/src/commands/import.ts)_
166+
_See code: [src/commands/import.ts](https://github.com/kevinwang5658/codify/blob/v0.6.0/src/commands/import.ts)_
140167

141168
## `codify plan`
142169

@@ -164,7 +191,7 @@ EXAMPLES
164191
$ codify plan
165192
```
166193

167-
_See code: [src/commands/plan/index.ts](https://github.com/kevinwang5658/codify/blob/v0.5.1/src/commands/plan/index.ts)_
194+
_See code: [src/commands/plan/index.ts](https://github.com/kevinwang5658/codify/blob/v0.6.0/src/commands/plan/index.ts)_
168195

169196
## `codify update [CHANNEL]`
170197

codify.json

Lines changed: 195 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,209 @@
55
"default": "../codify-homebrew-plugin/src/index.ts"
66
}
77
},
8+
{ "type": "path", "path": "$HOME/.bun/bin"},
9+
{
10+
"type": "path",
11+
"paths": [
12+
"$PYENV_ROOT/bin",
13+
"$BUN_INSTALL/bin",
14+
"$DENO_INSTALL/bin",
15+
"$NVM_DIR/.bin/3"
16+
],
17+
"declarationsOnly": true
18+
},
819
{
920
"type": "homebrew",
1021
"taps": [
1122
"cirruslabs/cli",
1223
"hashicorp/tap",
24+
"homebrew/bundle",
1325
"homebrew/services"
1426
],
15-
"formulae": [
16-
"asciinema"
17-
],
1827
"casks": [
19-
"firefox"
28+
"android-commandlinetools",
29+
"android-studio",
30+
"mitmproxy"
31+
],
32+
"formulae": [
33+
"ack",
34+
"asciinema",
35+
"cirrus",
36+
"expect",
37+
"git-lfs",
38+
"openjdk@11",
39+
"openjdk@17",
40+
"openjdk@21",
41+
"packer",
42+
"pgcli",
43+
"postgresql@14",
44+
"sshpass",
45+
"tart",
46+
"xz",
47+
"zstd"
48+
]
49+
},
50+
{"version":"1.10.5","type":"terraform"},
51+
{ "type": "alias", "alias": "gcdsdd", "value": "git clone" },
52+
{
53+
"type": "ssh-config",
54+
"hosts": [
55+
{
56+
"Host": "192.168.64.94",
57+
"HostName": "192.168.64.94",
58+
"User": "admin"
59+
},
60+
{
61+
"Host": "192.168.2.48",
62+
"HostName": "192.168.2.48",
63+
"User": "pi"
64+
},
65+
{
66+
"Host": "*",
67+
"AddKeysToAgent": true,
68+
"IdentityFile": "~/.ssh/id_ed25519"
69+
},
70+
{
71+
"Host": "ec2",
72+
"HostName": "54.82.78.202",
73+
"User": "ec2-user",
74+
"IdentityFile": "~/.ssh/ed25519"
75+
},
76+
{
77+
"Host": "ec2-2",
78+
"HostName": "35.153.180.154",
79+
"User": "ec2-user",
80+
"IdentityFile": "~/.ssh/ed25519"
81+
}
82+
]
83+
},
84+
{
85+
"type": "ssh-key",
86+
"fileName": "id_ed25519",
87+
"passphrase": "",
88+
"keyType": "ed25519"
89+
},
90+
{
91+
"type": "alias",
92+
"alias": "gc",
93+
"value": "git commit -v"
94+
},
95+
{
96+
"type": "pgcli"
97+
},
98+
{
99+
"type": "file",
100+
"contents": "[\n\t{\n \"type\": \"homebrew\",\n \"taps\": [\n \"cirruslabs/cli\",\n \"hashicorp/tap\",\n \"homebrew/services\"\n ],\n \"formulae\": [\n \"asciinema\",\n \"cairo\",\n \"cirrus\",\n \"expect\",\n \"glib\",\n \"hyperfine\",\n \"icu4c\",\n \"jq\",\n \"mas\",\n \"packer\",\n \"sshpass\",\n \"tart\"\n ],\n \"casks\": [\n \t\"firefox\",\n \t\"notion\",\n \t\"sublime-text\",\n \t\"webstorm\",\n \t\"mac-mouse-fix\",\n \t\"wins\",\n \t\"warp\",\n \t\"hammerspoon\",\n \t\"rectangle\",\n \t\"alt-tab\",\n \t\"betterdisplay\",\n \t\"daisydisk\",\n \t\"visual-studio-code\"\n ]\n },\n\n\t{ \"type\": \"nvm\", \"nodeVersions\": [\"20\"], \"global\": \"20\" },\n\t{ \"type\": \"pyenv\", \"pythonVersions\": [\"3.12\", \"3.11\"], \"global\": \"3.11\" },\n\n\t{\n \"type\": \"ssh-key\",\n \"fileName\": \"id_ed25519\",\n \"passphrase\": \"\",\n \"folder\": \"/Users/kevinwang/.ssh\",\n \"keyType\": \"ed25519\"\n },\n { \"type\": \"terraform\" },\n { \"type\": \"git-clone\", \"directory\": \"~/projects/codify\", \"repository\": \"git@github.com:kevinwang5658/codify.git\" },\n { \"type\": \"git-clone\", \"directory\": \"~/projects/codify-web\", \"repository\": \"git@github.com:kevinwang5658/codify-web.git\" },\n\t{ \"type\": \"git-clone\", \"directory\": \"~/projects/codify-homebrew-plugin\", \"repository\": \"git@github.com:kevinwang5658/codify-homebrew-plugin.git\" },\n { \"type\": \"git-clone\", \"directory\": \"~/projects/codify-infrastructure\", \"repository\": \"git@github.com:kevinwang5658/codify-infrastructure.git\" },\n { \"type\": \"git-clone\", \"directory\": \"~/projects/codify-docs\", \"repository\": \"git@github.com:kevinwang5658/codify-docs.git\" },\n { \"type\": \"git-clone\", \"directory\": \"~/projects/codify-ink-form\", \"repository\": \"git@github.com:kevinwang5658/codify-ink-form.git\" },\n\n\n { \"type\": \"action\", \"condition\": \"[ -d node_modules ]\", \"action\": \"npm install\", \"cwd\": \"~/projects/codify\", \"dependsOn\": [\"git-clone.0\", \"nvm\"]},\n { \"type\": \"action\", \"condition\": \"[ -d node_modules ]\", \"action\": \"npm install\", \"cwd\": \"~/projects/codify-web\", \"dependsOn\": [\"git-clone.1\", \"nvm\"]},\n { \"type\": \"action\", \"condition\": \"[ -d node_modules ]\", \"action\": \"npm install\", \"cwd\": \"~/projects/codify-homebrew-plugin\", \"dependsOn\": [\"git-clone.2\", \"nvm\"]},\n { \"type\": \"action\", \"condition\": \"[ -d node_modules ]\", \"action\": \"npm install\", \"cwd\": \"~/projects/codify-docs\", \"dependsOn\": [\"git-clone.4\", \"nvm\"]},\n { \"type\": \"action\", \"condition\": \"[ -d node_modules ]\", \"action\": \"npm install\", \"cwd\": \"~/projects/codify-ink-form\", \"dependsOn\": [\"git-clone.5\", \"nvm\"]}\n]",
101+
"path": "~/codify.json"
102+
},
103+
{
104+
"type": "aws-cli"
105+
},
106+
{
107+
"type": "git-clone",
108+
"directory": "~/Projects/codify-homebrew-plugin",
109+
"repository": "git@github.com:kevinwang5658/codify-homebrew-plugin.git"
110+
},
111+
{
112+
"type": "vscode"
113+
},
114+
{
115+
"type": "git-clone",
116+
"directory": "~/Projects/codify-plugin-lib",
117+
"repository": "git@github.com:kevinwang5658/codify-plugin-lib.git"
118+
},
119+
{
120+
"type": "git-clone",
121+
"directory": "~/Projects/codify",
122+
"repository": "git@github.com:kevinwang5658/codify.git"
123+
},
124+
{
125+
"type": "git-lfs"
126+
},
127+
{
128+
"type": "pyenv",
129+
"global": "3.11",
130+
"pythonVersions": [
131+
"3.9.19",
132+
"3.10.14",
133+
"3.11.8",
134+
"3.12.2"
135+
]
136+
},
137+
{
138+
"type": "git",
139+
"email": "kevinwang5658@gmail.com",
140+
"username": "kevinwang"
141+
},
142+
{
143+
"type": "nvm",
144+
"global": "20.15.1",
145+
"nodeVersions": [
146+
"iojs-2.5.0",
147+
"18.20.3",
148+
"20.15.0",
149+
"20.15.1",
150+
"22.4.1",
151+
"23.3.0"
20152
]
21153
},
22-
{ "type": "alias", "alias": "gcdsdd", "value": "git clone" }
154+
{
155+
"type": "android-studio",
156+
"version": "2023.3.1.20"
157+
},
158+
{
159+
"type": "ssh-add",
160+
"path": "~/.ssh/id_ed25519"
161+
},
162+
{
163+
"type": "jenv",
164+
"add": [
165+
"11",
166+
"17",
167+
"21"
168+
],
169+
"global": "17"
170+
},
171+
{
172+
"type": "aws-profile",
173+
"awsAccessKeyId": "AKIATCKATKL55TT5UZ7P",
174+
"awsSecretAccessKey": "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",
175+
"profile": "codify",
176+
"region": "us-east-1"
177+
},
178+
{
179+
"type": "git-clone",
180+
"directory": "~/Projects/codify-homebrew-plugin",
181+
"repository": "git@github.com:kevinwang5658/codify-homebrew-plugin.git"
182+
},
183+
{
184+
"type": "git-clone",
185+
"directory": "~/Projects/codify-homebrew-plugin",
186+
"repository": "git@github.com:kevinwang5658/codify-homebrew-plugin.git"
187+
},
188+
{
189+
"type": "git-clone",
190+
"directory": "~/Projects/codify-homebrew-plugin",
191+
"repository": "git@github.com:kevinwang5658/codify-homebrew-plugin.git"
192+
},
193+
{
194+
"type": "git-clone",
195+
"directory": "~/Projects/codify-homebrew-plugin",
196+
"repository": "git@github.com:kevinwang5658/codify-homebrew-plugin.git"
197+
},
198+
{
199+
"type": "git-clone",
200+
"directory": "~/Projects/codify-homebrew-plugin",
201+
"repository": "git@github.com:kevinwang5658/codify-homebrew-plugin.git"
202+
},
203+
{
204+
"type": "git-clone",
205+
"directory": "~/Projects/codify-homebrew-plugin",
206+
"repository": "git@github.com:kevinwang5658/codify-homebrew-plugin.git"
207+
},
208+
{
209+
"type": "git-clone",
210+
"directory": "~/Projects/codify-homebrew-plugin",
211+
"repository": "git@github.com:kevinwang5658/codify-homebrew-plugin.git"
212+
}
23213
]

new.codify.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

0 commit comments

Comments
 (0)