@oh-my-pi/cli 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/icon.png +0 -0
- package/.github/logo.png +0 -0
- package/.github/workflows/publish.yml +1 -1
- package/LICENSE +21 -0
- package/README.md +243 -138
- package/biome.json +1 -1
- package/bun.lock +59 -0
- package/dist/cli.js +6311 -2900
- package/dist/commands/config.d.ts +32 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/doctor.d.ts +1 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/enable.d.ts +1 -0
- package/dist/commands/enable.d.ts.map +1 -1
- package/dist/commands/env.d.ts +14 -0
- package/dist/commands/env.d.ts.map +1 -0
- package/dist/commands/features.d.ts +25 -0
- package/dist/commands/features.d.ts.map +1 -0
- package/dist/commands/info.d.ts +1 -0
- package/dist/commands/info.d.ts.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/install.d.ts +37 -0
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/link.d.ts +2 -0
- package/dist/commands/link.d.ts.map +1 -1
- package/dist/commands/list.d.ts +1 -0
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/outdated.d.ts +1 -0
- package/dist/commands/outdated.d.ts.map +1 -1
- package/dist/commands/search.d.ts.map +1 -1
- package/dist/commands/uninstall.d.ts +1 -0
- package/dist/commands/uninstall.d.ts.map +1 -1
- package/dist/commands/update.d.ts +1 -0
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/why.d.ts +1 -0
- package/dist/commands/why.d.ts.map +1 -1
- package/dist/conflicts.d.ts +9 -1
- package/dist/conflicts.d.ts.map +1 -1
- package/dist/errors.d.ts +8 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.d.ts +18 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/lock.d.ts +3 -0
- package/dist/lock.d.ts.map +1 -0
- package/dist/lockfile.d.ts +52 -0
- package/dist/lockfile.d.ts.map +1 -0
- package/dist/manifest.d.ts +60 -25
- package/dist/manifest.d.ts.map +1 -1
- package/dist/npm.d.ts +14 -2
- package/dist/npm.d.ts.map +1 -1
- package/dist/paths.d.ts +34 -3
- package/dist/paths.d.ts.map +1 -1
- package/dist/runtime.d.ts +14 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/symlinks.d.ts +43 -7
- package/dist/symlinks.d.ts.map +1 -1
- package/package.json +11 -5
- package/plugins/exa/README.md +153 -0
- package/plugins/exa/package.json +56 -0
- package/plugins/exa/tools/exa/company.ts +35 -0
- package/plugins/exa/tools/exa/index.ts +66 -0
- package/plugins/exa/tools/exa/linkedin.ts +35 -0
- package/plugins/exa/tools/exa/researcher.ts +40 -0
- package/plugins/exa/tools/exa/runtime.json +4 -0
- package/plugins/exa/tools/exa/search.ts +46 -0
- package/plugins/exa/tools/exa/shared.ts +230 -0
- package/plugins/exa/tools/exa/websets.ts +62 -0
- package/plugins/metal-theme/package.json +7 -2
- package/plugins/subagents/package.json +7 -2
- package/plugins/user-prompt/README.md +130 -0
- package/plugins/user-prompt/package.json +19 -0
- package/plugins/user-prompt/tools/user-prompt/index.ts +235 -0
- package/src/cli.ts +133 -58
- package/src/commands/config.ts +384 -0
- package/src/commands/create.ts +51 -1
- package/src/commands/doctor.ts +95 -7
- package/src/commands/enable.ts +25 -8
- package/src/commands/env.ts +38 -0
- package/src/commands/features.ts +295 -0
- package/src/commands/info.ts +41 -5
- package/src/commands/init.ts +20 -2
- package/src/commands/install.ts +453 -80
- package/src/commands/link.ts +60 -9
- package/src/commands/list.ts +122 -7
- package/src/commands/outdated.ts +17 -6
- package/src/commands/search.ts +20 -3
- package/src/commands/uninstall.ts +57 -6
- package/src/commands/update.ts +67 -9
- package/src/commands/why.ts +47 -16
- package/src/conflicts.ts +33 -1
- package/src/errors.ts +22 -0
- package/src/index.ts +18 -25
- package/src/lock.ts +46 -0
- package/src/lockfile.ts +132 -0
- package/src/manifest.ts +219 -71
- package/src/npm.ts +74 -18
- package/src/paths.ts +77 -12
- package/src/runtime.ts +116 -0
- package/src/symlinks.ts +291 -35
- package/tsconfig.json +7 -3
- package/CHECK.md +0 -352
- package/dist/migrate.d.ts +0 -9
- package/dist/migrate.d.ts.map +0 -1
- package/src/migrate.ts +0 -181
package/CHECK.md
DELETED
|
@@ -1,352 +0,0 @@
|
|
|
1
|
-
# Implementation Review Checklist
|
|
2
|
-
|
|
3
|
-
Review the oh-my-pi implementation against these requirements. For each item, verify it works correctly and check the listed edge cases.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## 1. Install Command (`omp install`)
|
|
8
|
-
|
|
9
|
-
### Core functionality
|
|
10
|
-
- [ ] `omp install pkg-name` installs from npm
|
|
11
|
-
- [ ] `omp install pkg@version` respects version specifier
|
|
12
|
-
- [ ] `omp install @scope/pkg` handles scoped packages
|
|
13
|
-
- [ ] `omp install ./path` copies local directory
|
|
14
|
-
- [ ] `omp install ~/path` expands home directory
|
|
15
|
-
- [ ] `omp install` (no args) installs from plugins.json
|
|
16
|
-
- [ ] Creates symlinks for each `omp.install` entry
|
|
17
|
-
|
|
18
|
-
### Edge cases
|
|
19
|
-
- [ ] Package not found on npm → clear error message
|
|
20
|
-
- [ ] Invalid version specifier → graceful failure
|
|
21
|
-
- [ ] Local path doesn't exist → error before any changes
|
|
22
|
-
- [ ] `omp.install` has missing source file → skip with warning, continue others
|
|
23
|
-
- [ ] Circular dependencies between plugins → handled without infinite loop
|
|
24
|
-
- [ ] Nested dependencies with omp field → all get symlinked
|
|
25
|
-
- [ ] Package has no `omp` field → installs but no symlinks (warning?)
|
|
26
|
-
- [ ] Network failure mid-install → rollback partial install
|
|
27
|
-
- [ ] Disk full → appropriate error
|
|
28
|
-
- [ ] Symlink target directory doesn't exist → creates parent dirs
|
|
29
|
-
- [ ] `omp install` with empty plugins.json → helpful message
|
|
30
|
-
|
|
31
|
-
### Flags
|
|
32
|
-
- [ ] `--global` installs to ~/.pi/plugins/
|
|
33
|
-
- [ ] `--save` adds to plugins.json
|
|
34
|
-
- [ ] `--save-dev` adds to devDependencies
|
|
35
|
-
- [ ] `--force` overwrites conflicts without prompting
|
|
36
|
-
- [ ] `--json` outputs JSON format
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
## 2. Conflict Detection
|
|
41
|
-
|
|
42
|
-
### Core functionality
|
|
43
|
-
- [ ] Detects when two plugins install to same destination
|
|
44
|
-
- [ ] Interactive prompt offers choices: plugin1, plugin2, abort
|
|
45
|
-
- [ ] User can select which plugin wins
|
|
46
|
-
- [ ] Abort rolls back the install
|
|
47
|
-
|
|
48
|
-
### Edge cases
|
|
49
|
-
- [ ] Three+ plugins with same destination → all listed
|
|
50
|
-
- [ ] Conflict with already-installed plugin → prompt before npm install
|
|
51
|
-
- [ ] Conflict within same plugin's install array (duplicate dest) → error
|
|
52
|
-
- [ ] `--force` skips all prompts → overwrites
|
|
53
|
-
- [ ] Non-interactive terminal (CI) → fail or use --force
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
## 3. Uninstall Command (`omp uninstall`)
|
|
58
|
-
|
|
59
|
-
### Core functionality
|
|
60
|
-
- [ ] `omp uninstall pkg` removes package
|
|
61
|
-
- [ ] Removes all symlinks from `omp.install`
|
|
62
|
-
- [ ] Removes from package.json/plugins.json
|
|
63
|
-
|
|
64
|
-
### Edge cases
|
|
65
|
-
- [ ] Plugin not installed → clear error
|
|
66
|
-
- [ ] Symlink already deleted manually → graceful (ENOENT ignored)
|
|
67
|
-
- [ ] Symlink replaced by real file → remove anyway or warn?
|
|
68
|
-
- [ ] Plugin has dependencies that other plugins also use → don't break them
|
|
69
|
-
- [ ] Partial uninstall (some symlinks fail) → report what failed
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
## 4. Update Command (`omp update`)
|
|
74
|
-
|
|
75
|
-
### Core functionality
|
|
76
|
-
- [ ] `omp update` updates all plugins
|
|
77
|
-
- [ ] `omp update pkg` updates specific plugin
|
|
78
|
-
- [ ] Respects semver ranges from plugins.json
|
|
79
|
-
- [ ] Re-creates symlinks after update
|
|
80
|
-
|
|
81
|
-
### Edge cases
|
|
82
|
-
- [ ] Package already at latest → no-op with message
|
|
83
|
-
- [ ] Major version available but range is `^` → doesn't update
|
|
84
|
-
- [ ] Package removed from npm → error handling
|
|
85
|
-
- [ ] Update changes `omp.install` entries → old symlinks removed, new created
|
|
86
|
-
- [ ] Linked (dev) plugins → skipped with message
|
|
87
|
-
|
|
88
|
-
---
|
|
89
|
-
|
|
90
|
-
## 5. List Command (`omp list`)
|
|
91
|
-
|
|
92
|
-
### Core functionality
|
|
93
|
-
- [ ] Shows all installed plugins
|
|
94
|
-
- [ ] Shows version for each
|
|
95
|
-
- [ ] Shows (linked) badge for dev plugins
|
|
96
|
-
|
|
97
|
-
### Edge cases
|
|
98
|
-
- [ ] No plugins installed → helpful message
|
|
99
|
-
- [ ] Plugin in plugins.json but not in node_modules → show as broken
|
|
100
|
-
- [ ] Corrupt package.json → graceful error
|
|
101
|
-
- [ ] `--json` output is valid JSON
|
|
102
|
-
|
|
103
|
-
---
|
|
104
|
-
|
|
105
|
-
## 6. Link Command (`omp link`)
|
|
106
|
-
|
|
107
|
-
### Core functionality
|
|
108
|
-
- [ ] `omp link ./path` creates symlink to source directory
|
|
109
|
-
- [ ] Marks as linked in manifest
|
|
110
|
-
- [ ] Creates symlinks from `omp.install`
|
|
111
|
-
|
|
112
|
-
### Edge cases
|
|
113
|
-
- [ ] Path doesn't exist → error
|
|
114
|
-
- [ ] Path has no package.json → uses directory name, creates minimal
|
|
115
|
-
- [ ] Path has omp.json (legacy) → converts to package.json format
|
|
116
|
-
- [ ] Already linked → re-link or error?
|
|
117
|
-
- [ ] `-n, --name` overrides plugin name
|
|
118
|
-
- [ ] Linked plugin updated externally → symlinks still work
|
|
119
|
-
|
|
120
|
-
---
|
|
121
|
-
|
|
122
|
-
## 7. Init Command (`omp init`)
|
|
123
|
-
|
|
124
|
-
### Core functionality
|
|
125
|
-
- [ ] Creates `.pi/plugins.json` in current directory
|
|
126
|
-
- [ ] Correct initial structure: `{ "plugins": {}, "disabled": [] }`
|
|
127
|
-
|
|
128
|
-
### Edge cases
|
|
129
|
-
- [ ] File already exists → error unless `--force`
|
|
130
|
-
- [ ] `.pi/` directory doesn't exist → creates it
|
|
131
|
-
- [ ] No write permission → clear error
|
|
132
|
-
|
|
133
|
-
---
|
|
134
|
-
|
|
135
|
-
## 8. Search Command (`omp search`)
|
|
136
|
-
|
|
137
|
-
### Core functionality
|
|
138
|
-
- [ ] `omp search query` searches npm for `keywords:omp-plugin`
|
|
139
|
-
- [ ] Shows name, version, description
|
|
140
|
-
|
|
141
|
-
### Edge cases
|
|
142
|
-
- [ ] No results → helpful message
|
|
143
|
-
- [ ] npm registry unavailable → timeout with error
|
|
144
|
-
- [ ] Very long description → truncated
|
|
145
|
-
- [ ] `--limit` respected
|
|
146
|
-
- [ ] Special characters in query → properly escaped
|
|
147
|
-
|
|
148
|
-
---
|
|
149
|
-
|
|
150
|
-
## 9. Info Command (`omp info`)
|
|
151
|
-
|
|
152
|
-
### Core functionality
|
|
153
|
-
- [ ] `omp info pkg` shows package details
|
|
154
|
-
- [ ] Shows: name, version, description, dependencies, omp.install entries
|
|
155
|
-
|
|
156
|
-
### Edge cases
|
|
157
|
-
- [ ] Package not found → clear error
|
|
158
|
-
- [ ] Package exists but no omp field → show warning
|
|
159
|
-
- [ ] `--versions` shows available versions
|
|
160
|
-
- [ ] `--json` valid JSON output
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
## 10. Outdated Command (`omp outdated`)
|
|
165
|
-
|
|
166
|
-
### Core functionality
|
|
167
|
-
- [ ] Lists plugins with newer versions available
|
|
168
|
-
- [ ] Shows current, wanted, latest columns
|
|
169
|
-
|
|
170
|
-
### Edge cases
|
|
171
|
-
- [ ] All up to date → "All plugins up to date"
|
|
172
|
-
- [ ] npm outdated returns exit code 1 → still parses output
|
|
173
|
-
- [ ] Plugin not on npm anymore → shown as error row
|
|
174
|
-
- [ ] Linked plugins → excluded from check
|
|
175
|
-
|
|
176
|
-
---
|
|
177
|
-
|
|
178
|
-
## 11. Doctor Command (`omp doctor`)
|
|
179
|
-
|
|
180
|
-
### Core functionality
|
|
181
|
-
- [ ] Checks for broken symlinks
|
|
182
|
-
- [ ] Checks for conflicts
|
|
183
|
-
- [ ] Reports missing dependencies
|
|
184
|
-
|
|
185
|
-
### Edge cases
|
|
186
|
-
- [ ] No issues → "All good"
|
|
187
|
-
- [ ] Symlink target deleted → reported as broken
|
|
188
|
-
- [ ] Symlink replaced by real file → reported
|
|
189
|
-
- [ ] `--fix` repairs broken symlinks
|
|
190
|
-
- [ ] `--fix` can't fix conflict → reports
|
|
191
|
-
|
|
192
|
-
---
|
|
193
|
-
|
|
194
|
-
## 12. Create Command (`omp create`)
|
|
195
|
-
|
|
196
|
-
### Core functionality
|
|
197
|
-
- [ ] `omp create my-plugin` scaffolds new plugin
|
|
198
|
-
- [ ] Creates package.json with omp field
|
|
199
|
-
- [ ] Creates directory structure
|
|
200
|
-
|
|
201
|
-
### Edge cases
|
|
202
|
-
- [ ] Directory already exists → error
|
|
203
|
-
- [ ] Invalid plugin name (spaces, special chars) → normalized or error
|
|
204
|
-
- [ ] `--description` sets description
|
|
205
|
-
- [ ] `--author` sets author
|
|
206
|
-
|
|
207
|
-
---
|
|
208
|
-
|
|
209
|
-
## 13. Why Command (`omp why`)
|
|
210
|
-
|
|
211
|
-
### Core functionality
|
|
212
|
-
- [ ] `omp why agent/themes/dark.json` shows which plugin installed it
|
|
213
|
-
- [ ] Shows plugin name and source path
|
|
214
|
-
|
|
215
|
-
### Edge cases
|
|
216
|
-
- [ ] File not installed by any plugin → "Not installed by omp"
|
|
217
|
-
- [ ] File is manually created (not symlink) → detect and report
|
|
218
|
-
- [ ] Relative vs absolute path → both work
|
|
219
|
-
- [ ] File doesn't exist → appropriate error
|
|
220
|
-
|
|
221
|
-
---
|
|
222
|
-
|
|
223
|
-
## 14. Enable/Disable Commands
|
|
224
|
-
|
|
225
|
-
### Core functionality
|
|
226
|
-
- [ ] `omp disable pkg` removes symlinks, keeps in node_modules
|
|
227
|
-
- [ ] `omp enable pkg` restores symlinks
|
|
228
|
-
- [ ] Disabled list persisted
|
|
229
|
-
|
|
230
|
-
### Edge cases
|
|
231
|
-
- [ ] Disable already-disabled → no-op or error
|
|
232
|
-
- [ ] Enable not-disabled → no-op
|
|
233
|
-
- [ ] Enable not-installed → error
|
|
234
|
-
- [ ] Symlinks manually restored → enable detects and handles
|
|
235
|
-
|
|
236
|
-
---
|
|
237
|
-
|
|
238
|
-
## 15. Project-Local vs Global
|
|
239
|
-
|
|
240
|
-
### Core functionality
|
|
241
|
-
- [ ] Default is global (~/.pi/)
|
|
242
|
-
- [ ] With `.pi/plugins.json` in cwd, uses project-local
|
|
243
|
-
- [ ] `--global` forces global even with local config
|
|
244
|
-
- [ ] Symlinks go to correct location per scope
|
|
245
|
-
|
|
246
|
-
### Edge cases
|
|
247
|
-
- [ ] Nested projects (parent and child have .pi/) → uses closest
|
|
248
|
-
- [ ] Project-local install then run from parent dir → correct behavior
|
|
249
|
-
- [ ] Same plugin installed globally and locally → local takes precedence?
|
|
250
|
-
|
|
251
|
-
---
|
|
252
|
-
|
|
253
|
-
## 16. Migration (`omp migrate`)
|
|
254
|
-
|
|
255
|
-
### Core functionality
|
|
256
|
-
- [ ] Detects legacy manifest.json
|
|
257
|
-
- [ ] Converts to package.json format
|
|
258
|
-
- [ ] Preserves all plugin info
|
|
259
|
-
- [ ] Re-creates symlinks
|
|
260
|
-
|
|
261
|
-
### Edge cases
|
|
262
|
-
- [ ] No legacy manifest → "Nothing to migrate"
|
|
263
|
-
- [ ] Partial migration (some plugins fail) → reports
|
|
264
|
-
- [ ] Legacy plugin source gone → reports but continues
|
|
265
|
-
- [ ] Backup of manifest.json created
|
|
266
|
-
|
|
267
|
-
---
|
|
268
|
-
|
|
269
|
-
## 17. Lock File
|
|
270
|
-
|
|
271
|
-
### Core functionality
|
|
272
|
-
- [ ] package-lock.json generated for global
|
|
273
|
-
- [ ] plugins-lock.json generated for project-local
|
|
274
|
-
- [ ] Reproducible installs with lock file
|
|
275
|
-
|
|
276
|
-
### Edge cases
|
|
277
|
-
- [ ] Lock file corrupt → regenerate with warning
|
|
278
|
-
- [ ] Lock file deleted → works but warns about reproducibility
|
|
279
|
-
|
|
280
|
-
---
|
|
281
|
-
|
|
282
|
-
## 18. Symlinks Module
|
|
283
|
-
|
|
284
|
-
### Core functionality
|
|
285
|
-
- [ ] Creates symlinks correctly
|
|
286
|
-
- [ ] Removes symlinks on uninstall
|
|
287
|
-
- [ ] Validates symlink health
|
|
288
|
-
|
|
289
|
-
### Edge cases
|
|
290
|
-
- [ ] **BUG CHECK: Project-local uses correct base path (.pi/ not ~/.pi/)**
|
|
291
|
-
- [ ] Destination is a directory → symlink whole directory
|
|
292
|
-
- [ ] Destination is a file → symlink file
|
|
293
|
-
- [ ] Parent directories created recursively
|
|
294
|
-
- [ ] Windows compatibility (if applicable) → use junctions or requires admin
|
|
295
|
-
|
|
296
|
-
---
|
|
297
|
-
|
|
298
|
-
## 19. npm Module
|
|
299
|
-
|
|
300
|
-
### Core functionality
|
|
301
|
-
- [ ] npm install works with prefix
|
|
302
|
-
- [ ] npm info fetches package data
|
|
303
|
-
- [ ] npm search returns results
|
|
304
|
-
- [ ] npm outdated parsed correctly
|
|
305
|
-
|
|
306
|
-
### Edge cases
|
|
307
|
-
- [ ] npm not installed → clear error
|
|
308
|
-
- [ ] npm version too old → check and warn
|
|
309
|
-
- [ ] Private registry → respects .npmrc
|
|
310
|
-
- [ ] Scoped package with private registry → works
|
|
311
|
-
|
|
312
|
-
---
|
|
313
|
-
|
|
314
|
-
## 20. General Edge Cases
|
|
315
|
-
|
|
316
|
-
### Error handling
|
|
317
|
-
- [ ] All commands have try/catch at top level
|
|
318
|
-
- [ ] Errors include actionable messages
|
|
319
|
-
- [ ] Stack traces hidden unless DEBUG
|
|
320
|
-
|
|
321
|
-
### Permissions
|
|
322
|
-
- [ ] No sudo required for ~/.pi
|
|
323
|
-
- [ ] Handles permission denied gracefully
|
|
324
|
-
- [ ] Doesn't follow symlinks outside allowed paths (security)
|
|
325
|
-
|
|
326
|
-
### Concurrency
|
|
327
|
-
- [ ] Two `omp install` at once → lock file prevents corruption
|
|
328
|
-
- [ ] Interrupted install → recoverable state
|
|
329
|
-
|
|
330
|
-
### Unicode/i18n
|
|
331
|
-
- [ ] Plugin names with unicode → handled
|
|
332
|
-
- [ ] Paths with spaces → quoted correctly
|
|
333
|
-
- [ ] Paths with unicode → work on all platforms
|
|
334
|
-
|
|
335
|
-
---
|
|
336
|
-
|
|
337
|
-
## Verification Steps
|
|
338
|
-
|
|
339
|
-
For each section above:
|
|
340
|
-
1. Read the relevant source file
|
|
341
|
-
2. Trace the code path for the happy case
|
|
342
|
-
3. Check each edge case is handled
|
|
343
|
-
4. Note any missing error handling
|
|
344
|
-
5. Run the command if possible to verify
|
|
345
|
-
|
|
346
|
-
Report findings as:
|
|
347
|
-
```
|
|
348
|
-
## [Command Name]
|
|
349
|
-
✓ Working: [list of working features]
|
|
350
|
-
✗ Missing: [list of unimplemented features]
|
|
351
|
-
⚠ Issues: [list of bugs or edge cases not handled]
|
|
352
|
-
```
|
package/dist/migrate.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check for and prompt migration if legacy manifest exists
|
|
3
|
-
*/
|
|
4
|
-
export declare function checkMigration(auto?: boolean): Promise<boolean>;
|
|
5
|
-
/**
|
|
6
|
-
* Migrate from legacy manifest.json to npm-native format
|
|
7
|
-
*/
|
|
8
|
-
export declare function migrateToNpm(): Promise<boolean>;
|
|
9
|
-
//# sourceMappingURL=migrate.d.ts.map
|
package/dist/migrate.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAgCA;;GAEG;AACH,wBAAsB,cAAc,CAAC,IAAI,UAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAkBnE;AAED;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,CA2DrD"}
|
package/src/migrate.ts
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import { mkdir, readFile, rename, rm, symlink, writeFile } from "node:fs/promises";
|
|
3
|
-
import { basename, join } from "node:path";
|
|
4
|
-
import { createInterface } from "node:readline";
|
|
5
|
-
import chalk from "chalk";
|
|
6
|
-
import {
|
|
7
|
-
hasLegacyManifest,
|
|
8
|
-
type LegacyPluginInfo,
|
|
9
|
-
loadLegacyManifest,
|
|
10
|
-
type PluginPackageJson,
|
|
11
|
-
type PluginsJson,
|
|
12
|
-
savePluginsJson,
|
|
13
|
-
} from "./manifest.js";
|
|
14
|
-
import { LEGACY_MANIFEST_PATH, NODE_MODULES_DIR, PLUGINS_DIR } from "./paths.js";
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Prompt user for migration
|
|
18
|
-
*/
|
|
19
|
-
async function promptMigration(): Promise<boolean> {
|
|
20
|
-
const rl = createInterface({
|
|
21
|
-
input: process.stdin,
|
|
22
|
-
output: process.stdout,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
return new Promise((resolve) => {
|
|
26
|
-
rl.question(chalk.yellow("Migrate to npm-native format? [y/N] "), (answer) => {
|
|
27
|
-
rl.close();
|
|
28
|
-
resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Check for and prompt migration if legacy manifest exists
|
|
35
|
-
*/
|
|
36
|
-
export async function checkMigration(auto = false): Promise<boolean> {
|
|
37
|
-
if (!hasLegacyManifest()) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
console.log(chalk.yellow("\n⚠ Legacy manifest.json detected"));
|
|
42
|
-
console.log(chalk.dim(" oh-my-pi has been updated to use npm-native plugin management."));
|
|
43
|
-
console.log();
|
|
44
|
-
|
|
45
|
-
if (!auto) {
|
|
46
|
-
const shouldMigrate = await promptMigration();
|
|
47
|
-
if (!shouldMigrate) {
|
|
48
|
-
console.log(chalk.dim(" Migration skipped. Use 'omp migrate' to migrate later."));
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return await migrateToNpm();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Migrate from legacy manifest.json to npm-native format
|
|
58
|
-
*/
|
|
59
|
-
export async function migrateToNpm(): Promise<boolean> {
|
|
60
|
-
console.log(chalk.blue("\nMigrating to npm-native format..."));
|
|
61
|
-
|
|
62
|
-
try {
|
|
63
|
-
const legacyManifest = await loadLegacyManifest();
|
|
64
|
-
const plugins = Object.entries(legacyManifest.plugins);
|
|
65
|
-
|
|
66
|
-
if (plugins.length === 0) {
|
|
67
|
-
console.log(chalk.dim(" No plugins to migrate"));
|
|
68
|
-
await archiveLegacyManifest();
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Create node_modules directory
|
|
73
|
-
await mkdir(NODE_MODULES_DIR, { recursive: true });
|
|
74
|
-
|
|
75
|
-
const newPluginsJson: PluginsJson = { plugins: {} };
|
|
76
|
-
const migrated: string[] = [];
|
|
77
|
-
const failed: string[] = [];
|
|
78
|
-
|
|
79
|
-
for (const [name, info] of plugins) {
|
|
80
|
-
try {
|
|
81
|
-
console.log(chalk.dim(` Migrating ${name}...`));
|
|
82
|
-
await migratePlugin(name, info);
|
|
83
|
-
|
|
84
|
-
// Determine version specifier for plugins.json
|
|
85
|
-
if (info.type === "npm" && info.package) {
|
|
86
|
-
newPluginsJson.plugins[info.package] = info.version ? `^${info.version}` : "latest";
|
|
87
|
-
} else if (info.type === "local" && info.path) {
|
|
88
|
-
newPluginsJson.plugins[name] = `file:${info.path}`;
|
|
89
|
-
} else if (info.type === "github" && info.repo) {
|
|
90
|
-
// GitHub plugins become local after clone
|
|
91
|
-
newPluginsJson.plugins[name] = `file:${join(NODE_MODULES_DIR, name)}`;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
migrated.push(name);
|
|
95
|
-
} catch (err) {
|
|
96
|
-
console.log(chalk.yellow(` ⚠ Failed to migrate ${name}: ${(err as Error).message}`));
|
|
97
|
-
failed.push(name);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Save new plugins.json
|
|
102
|
-
await savePluginsJson(newPluginsJson, true);
|
|
103
|
-
|
|
104
|
-
// Archive legacy manifest
|
|
105
|
-
await archiveLegacyManifest();
|
|
106
|
-
|
|
107
|
-
console.log();
|
|
108
|
-
console.log(chalk.green(`✓ Migrated ${migrated.length} plugin(s)`));
|
|
109
|
-
if (failed.length > 0) {
|
|
110
|
-
console.log(chalk.yellow(`⚠ Failed to migrate ${failed.length} plugin(s): ${failed.join(", ")}`));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return true;
|
|
114
|
-
} catch (err) {
|
|
115
|
-
console.log(chalk.red(`Error during migration: ${(err as Error).message}`));
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Migrate a single plugin to the new structure
|
|
122
|
-
*/
|
|
123
|
-
async function migratePlugin(name: string, info: LegacyPluginInfo): Promise<void> {
|
|
124
|
-
const oldPluginDir = join(PLUGINS_DIR, name);
|
|
125
|
-
const newPluginDir = join(NODE_MODULES_DIR, name);
|
|
126
|
-
|
|
127
|
-
if (!existsSync(oldPluginDir)) {
|
|
128
|
-
throw new Error(`Plugin directory not found: ${oldPluginDir}`);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// For linked plugins, create symlink in node_modules
|
|
132
|
-
if (info.linked && info.path) {
|
|
133
|
-
await mkdir(NODE_MODULES_DIR, { recursive: true });
|
|
134
|
-
if (existsSync(newPluginDir)) {
|
|
135
|
-
await rm(newPluginDir, { force: true, recursive: true });
|
|
136
|
-
}
|
|
137
|
-
await symlink(info.path, newPluginDir);
|
|
138
|
-
// Remove old symlink
|
|
139
|
-
await rm(oldPluginDir, { force: true });
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// For regular plugins, move to node_modules
|
|
144
|
-
if (existsSync(newPluginDir)) {
|
|
145
|
-
await rm(newPluginDir, { force: true, recursive: true });
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Rename/move the directory
|
|
149
|
-
await rename(oldPluginDir, newPluginDir);
|
|
150
|
-
|
|
151
|
-
// Create package.json if it doesn't exist (convert from omp.json)
|
|
152
|
-
const pkgJsonPath = join(newPluginDir, "package.json");
|
|
153
|
-
const ompJsonPath = join(newPluginDir, "omp.json");
|
|
154
|
-
|
|
155
|
-
if (!existsSync(pkgJsonPath) && existsSync(ompJsonPath)) {
|
|
156
|
-
const ompJson = JSON.parse(await readFile(ompJsonPath, "utf-8"));
|
|
157
|
-
const pkgJson: PluginPackageJson = {
|
|
158
|
-
name: ompJson.name || name,
|
|
159
|
-
version: ompJson.version || info.version || "0.0.0",
|
|
160
|
-
description: ompJson.description,
|
|
161
|
-
keywords: ["omp-plugin"],
|
|
162
|
-
omp: {
|
|
163
|
-
install: ompJson.install,
|
|
164
|
-
},
|
|
165
|
-
};
|
|
166
|
-
await writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Archive the legacy manifest.json
|
|
172
|
-
*/
|
|
173
|
-
async function archiveLegacyManifest(): Promise<void> {
|
|
174
|
-
if (!existsSync(LEGACY_MANIFEST_PATH)) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const archivePath = join(PLUGINS_DIR, `manifest.json.bak.${Date.now()}`);
|
|
179
|
-
await rename(LEGACY_MANIFEST_PATH, archivePath);
|
|
180
|
-
console.log(chalk.dim(` Archived old manifest to ${basename(archivePath)}`));
|
|
181
|
-
}
|