@vc-shell/migrate 2.0.0-alpha.12
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/README.md +359 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +45 -0
- package/dist/cli.js.map +1 -0
- package/dist/runner.d.ts +8 -0
- package/dist/runner.js +154 -0
- package/dist/runner.js.map +1 -0
- package/dist/transforms/banner-variants.d.ts +4 -0
- package/dist/transforms/banner-variants.js +21 -0
- package/dist/transforms/banner-variants.js.map +1 -0
- package/dist/transforms/blade-props-simplification.d.ts +4 -0
- package/dist/transforms/blade-props-simplification.js +315 -0
- package/dist/transforms/blade-props-simplification.js.map +1 -0
- package/dist/transforms/composable-return-types.d.ts +4 -0
- package/dist/transforms/composable-return-types.js +50 -0
- package/dist/transforms/composable-return-types.js.map +1 -0
- package/dist/transforms/define-app-module.d.ts +4 -0
- package/dist/transforms/define-app-module.js +73 -0
- package/dist/transforms/define-app-module.js.map +1 -0
- package/dist/transforms/icon-audit.d.ts +4 -0
- package/dist/transforms/icon-audit.js +38 -0
- package/dist/transforms/icon-audit.js.map +1 -0
- package/dist/transforms/icon-container-prop.d.ts +4 -0
- package/dist/transforms/icon-container-prop.js +14 -0
- package/dist/transforms/icon-container-prop.js.map +1 -0
- package/dist/transforms/menu-group-config.d.ts +4 -0
- package/dist/transforms/menu-group-config.js +22 -0
- package/dist/transforms/menu-group-config.js.map +1 -0
- package/dist/transforms/notification-migration.d.ts +4 -0
- package/dist/transforms/notification-migration.js +31 -0
- package/dist/transforms/notification-migration.js.map +1 -0
- package/dist/transforms/registry.d.ts +3 -0
- package/dist/transforms/registry.js +129 -0
- package/dist/transforms/registry.js.map +1 -0
- package/dist/transforms/remove-deprecated-aliases.d.ts +4 -0
- package/dist/transforms/remove-deprecated-aliases.js +36 -0
- package/dist/transforms/remove-deprecated-aliases.js.map +1 -0
- package/dist/transforms/rewrite-imports.d.ts +4 -0
- package/dist/transforms/rewrite-imports.js +62 -0
- package/dist/transforms/rewrite-imports.js.map +1 -0
- package/dist/transforms/scss-safe-use.d.ts +4 -0
- package/dist/transforms/scss-safe-use.js +50 -0
- package/dist/transforms/scss-safe-use.js.map +1 -0
- package/dist/transforms/shims-to-globals.d.ts +4 -0
- package/dist/transforms/shims-to-globals.js +64 -0
- package/dist/transforms/shims-to-globals.js.map +1 -0
- package/dist/transforms/switch-tooltip-prop.d.ts +4 -0
- package/dist/transforms/switch-tooltip-prop.js +12 -0
- package/dist/transforms/switch-tooltip-prop.js.map +1 -0
- package/dist/transforms/types.d.ts +30 -0
- package/dist/transforms/types.js +2 -0
- package/dist/transforms/types.js.map +1 -0
- package/dist/transforms/use-blade-migration.d.ts +4 -0
- package/dist/transforms/use-blade-migration.js +50 -0
- package/dist/transforms/use-blade-migration.js.map +1 -0
- package/dist/transforms/widgets-migration.d.ts +4 -0
- package/dist/transforms/widgets-migration.js +38 -0
- package/dist/transforms/widgets-migration.js.map +1 -0
- package/dist/utils/import-rewriter.d.ts +3 -0
- package/dist/utils/import-rewriter.js +22 -0
- package/dist/utils/import-rewriter.js.map +1 -0
- package/dist/utils/template-transform.d.ts +13 -0
- package/dist/utils/template-transform.js +37 -0
- package/dist/utils/template-transform.js.map +1 -0
- package/dist/utils/test-helpers.d.ts +32 -0
- package/dist/utils/test-helpers.js +49 -0
- package/dist/utils/test-helpers.js.map +1 -0
- package/dist/utils/vue-sfc-wrapper.d.ts +24 -0
- package/dist/utils/vue-sfc-wrapper.js +61 -0
- package/dist/utils/vue-sfc-wrapper.js.map +1 -0
- package/dist/version-detector.d.ts +1 -0
- package/dist/version-detector.js +32 -0
- package/dist/version-detector.js.map +1 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
# @vc-shell/migrate
|
|
2
|
+
|
|
3
|
+
Automated migration tool for upgrading apps to the latest `@vc-shell/framework` version.
|
|
4
|
+
|
|
5
|
+
Detects your current framework version, selects applicable code transforms, and rewrites your source code — preserving formatting for unchanged lines.
|
|
6
|
+
|
|
7
|
+
> **Migrating from a version prior to 1.x?** This tool covers migrations from 1.x to 2.0. For older versions, upgrade to 1.x first, then use this tool.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx @vc-shell/migrate
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
That's it. The CLI will:
|
|
16
|
+
|
|
17
|
+
1. Detect your current `@vc-shell/framework` version from `package.json`
|
|
18
|
+
2. Select transforms needed for the upgrade path (e.g., 1.x → 2.0.0)
|
|
19
|
+
3. Apply each transform to your `src/` files (`.ts` and `.vue`)
|
|
20
|
+
4. Print a summary of modified files and any manual action items
|
|
21
|
+
|
|
22
|
+
## Major changes in 2.0
|
|
23
|
+
|
|
24
|
+
Before running the migration, review the key breaking changes:
|
|
25
|
+
|
|
26
|
+
| Change | Impact | Automated? |
|
|
27
|
+
|--------|--------|:----------:|
|
|
28
|
+
| `createAppModule` → `defineAppModule` | All module entry points | Yes |
|
|
29
|
+
| `useBladeNavigation` → `useBlade` | All blade composable usage | Yes |
|
|
30
|
+
| `useNotifications` → `useBladeNotifications` | Notification composable | Yes |
|
|
31
|
+
| Blade Props/Emits boilerplate removal | All blade components | Yes |
|
|
32
|
+
| Import path splitting (ai-agent, extensions) | Imports of moved symbols | Yes |
|
|
33
|
+
| Deprecated injection key renames (6 symbols) | Injection key references | Yes |
|
|
34
|
+
| `useWidgets` → `useBladeWidgets` | Widget registration | Partial* |
|
|
35
|
+
| Composable return type renames (20 types) | Type annotations | Yes |
|
|
36
|
+
| VcBanner variant prop values | Template attributes | Yes |
|
|
37
|
+
| VcSwitch `tooltip` → `hint` | Template attributes | Yes |
|
|
38
|
+
| VcIcon `useContainer` removal | Template attributes | Yes |
|
|
39
|
+
| Font Awesome → Material Symbols icons | Icon class names | Diagnostic |
|
|
40
|
+
| SCSS `@import` → `@use` | Stylesheet imports | Diagnostic |
|
|
41
|
+
| Menu `group`/`groupIcon` → `groupConfig` | Menu configuration | Diagnostic |
|
|
42
|
+
| Manual `.d.ts` shims → `@vc-shell/framework/globals` | tsconfig.json | Yes |
|
|
43
|
+
|
|
44
|
+
\* `useWidgets` is renamed automatically, but `registerWidget`/`unregisterWidget` calls require manual migration to the declarative `useBladeWidgets([...])` API.
|
|
45
|
+
|
|
46
|
+
**Diagnostic** transforms report issues but do not modify code. Review the output and fix manually.
|
|
47
|
+
|
|
48
|
+
> If any of these changes are blockers for your project, we recommend staying on your current version until you're ready for a full upgrade.
|
|
49
|
+
|
|
50
|
+
## CLI options
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npx @vc-shell/migrate [options]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
| Option | Description | Default |
|
|
57
|
+
|--------|-------------|---------|
|
|
58
|
+
| `--to <version>` | Target framework version | `2.0.0` |
|
|
59
|
+
| `--transform <name>` | Run only a specific transform | all applicable |
|
|
60
|
+
| `--dry-run` | Preview changes without writing files | `false` |
|
|
61
|
+
| `--list` | List all available transforms and exit | |
|
|
62
|
+
| `--cwd <path>` | Working directory (your app root) | `.` |
|
|
63
|
+
|
|
64
|
+
### Examples
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Preview what would change (recommended first step)
|
|
68
|
+
npx @vc-shell/migrate --dry-run
|
|
69
|
+
|
|
70
|
+
# Migrate to a specific version
|
|
71
|
+
npx @vc-shell/migrate --to 2.0.0-alpha.10
|
|
72
|
+
|
|
73
|
+
# Run only one transform
|
|
74
|
+
npx @vc-shell/migrate --transform blade-props-simplification --dry-run
|
|
75
|
+
|
|
76
|
+
# List all transforms with descriptions and version ranges
|
|
77
|
+
npx @vc-shell/migrate --list
|
|
78
|
+
|
|
79
|
+
# Migrate a specific app in a monorepo
|
|
80
|
+
npx @vc-shell/migrate --cwd apps/vendor-portal
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Recommended workflow
|
|
84
|
+
|
|
85
|
+
1. **Commit your current work** — make sure your working tree is clean
|
|
86
|
+
2. **Dry run first** — `npx @vc-shell/migrate --dry-run` to preview changes
|
|
87
|
+
3. **Run the migration** — `npx @vc-shell/migrate`
|
|
88
|
+
4. **Review the diff** — `git diff` to inspect all changes
|
|
89
|
+
5. **Fix manual items** — address any warnings printed by diagnostic transforms
|
|
90
|
+
6. **Run your tests** — verify everything works
|
|
91
|
+
7. **Commit** — create a dedicated migration commit
|
|
92
|
+
|
|
93
|
+
## How it works
|
|
94
|
+
|
|
95
|
+
### Version-based transform selection
|
|
96
|
+
|
|
97
|
+
Each transform has an `introducedIn` version — the framework version that introduced the breaking change. The CLI selects transforms where:
|
|
98
|
+
|
|
99
|
+
- Your current version is **below** the breaking change
|
|
100
|
+
- The target version **includes** the breaking change
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
Current: 2.0.0-alpha.8 → Target: 2.0.0
|
|
104
|
+
|
|
105
|
+
Skipped (already past):
|
|
106
|
+
define-app-module (introduced in alpha.5)
|
|
107
|
+
use-blade-migration (introduced in alpha.8)
|
|
108
|
+
|
|
109
|
+
Applied:
|
|
110
|
+
notification-migration (introduced in alpha.10)
|
|
111
|
+
rewrite-imports (introduced in 2.0.0)
|
|
112
|
+
... and 11 more
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Transform categories
|
|
116
|
+
|
|
117
|
+
| Category | Behavior |
|
|
118
|
+
|----------|----------|
|
|
119
|
+
| **Script transforms** | Modify `<script>` blocks in `.vue` files and `.ts` files using jscodeshift AST manipulation |
|
|
120
|
+
| **Template transforms** | Modify `<template>` blocks in `.vue` files using string-based pattern matching |
|
|
121
|
+
| **Script + Template** | Both (e.g., `blade-props-simplification` removes props from script AND attributes from template) |
|
|
122
|
+
| **Config transforms** | Modify project configuration files like `tsconfig.json` |
|
|
123
|
+
| **Diagnostic** | Report issues via warnings but never modify files — manual action required |
|
|
124
|
+
|
|
125
|
+
### Format preservation
|
|
126
|
+
|
|
127
|
+
The tool uses [jscodeshift](https://github.com/facebook/jscodeshift) (built on [recast](https://github.com/benjamn/recast)) for AST transforms. This means:
|
|
128
|
+
|
|
129
|
+
- **Unchanged lines are preserved exactly** — no reformatting of code you didn't touch
|
|
130
|
+
- Only the specific identifiers, imports, and expressions being migrated are rewritten
|
|
131
|
+
- Your indentation, quotes, trailing commas, and line breaks stay as they were
|
|
132
|
+
|
|
133
|
+
### Error isolation
|
|
134
|
+
|
|
135
|
+
Each file is processed independently with per-file error handling:
|
|
136
|
+
|
|
137
|
+
- If a transform fails on one file, all other files continue processing
|
|
138
|
+
- File writes use atomic operations (write to temp, then rename) — no corrupted files on crash
|
|
139
|
+
- Project-scoped transforms (SCSS scan, tsconfig update) run once per project, not per file
|
|
140
|
+
|
|
141
|
+
## Available transforms
|
|
142
|
+
|
|
143
|
+
### `define-app-module` <sup>alpha.5</sup>
|
|
144
|
+
|
|
145
|
+
Rewrites module entry points from positional arguments to named config object.
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
// Before
|
|
149
|
+
export default createAppModule(pages, locales);
|
|
150
|
+
|
|
151
|
+
// After
|
|
152
|
+
export default defineAppModule({ pages, locales });
|
|
153
|
+
|
|
154
|
+
// 3-arg variant (with notifications)
|
|
155
|
+
// Before
|
|
156
|
+
export default createAppModule(pages, locales, notificationTemplates);
|
|
157
|
+
|
|
158
|
+
// After
|
|
159
|
+
export default defineAppModule({
|
|
160
|
+
blades: pages,
|
|
161
|
+
locales: locales,
|
|
162
|
+
notificationTemplates: notificationTemplates,
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### `use-blade-migration` <sup>alpha.8</sup>
|
|
167
|
+
|
|
168
|
+
Renames `useBladeNavigation()` → `useBlade()` and inverts `onBeforeClose` return values (old: `return false` = prevent close → new: `return true` = prevent close).
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
// Before
|
|
172
|
+
const { openBlade, onBeforeClose } = useBladeNavigation();
|
|
173
|
+
onBeforeClose(() => {
|
|
174
|
+
return false; // prevent close
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
// After
|
|
178
|
+
const { openBlade, onBeforeClose } = useBlade();
|
|
179
|
+
onBeforeClose(() => {
|
|
180
|
+
return !false; // prevent close (inverted)
|
|
181
|
+
});
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### `notification-migration` <sup>alpha.10</sup>
|
|
185
|
+
|
|
186
|
+
Renames `useNotifications` → `useBladeNotifications` in imports and all usages.
|
|
187
|
+
|
|
188
|
+
### `blade-props-simplification` <sup>2.0.0</sup>
|
|
189
|
+
|
|
190
|
+
Removes blade boilerplate from Vue components: `expanded`/`closable` props, `close:blade`/`expand:blade`/`collapse:blade`/`parent:call` emits, and corresponding template attributes on `<VcBlade>`. Adds `useBlade()` destructuring for `param`, `options`, `callParent`, `closeSelf`.
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
// Before
|
|
194
|
+
interface Props {
|
|
195
|
+
expanded?: boolean;
|
|
196
|
+
closable?: boolean;
|
|
197
|
+
param?: string;
|
|
198
|
+
model?: string;
|
|
199
|
+
}
|
|
200
|
+
interface Emits {
|
|
201
|
+
(e: "parent:call", args: IParentCallArgs): void;
|
|
202
|
+
(e: "close:blade"): void;
|
|
203
|
+
}
|
|
204
|
+
const props = withDefaults(defineProps<Props>(), { expanded: true, closable: true });
|
|
205
|
+
const emit = defineEmits<Emits>();
|
|
206
|
+
emit("parent:call", { method: "refresh" });
|
|
207
|
+
const id = props.param;
|
|
208
|
+
|
|
209
|
+
// After
|
|
210
|
+
interface Props {
|
|
211
|
+
model?: string;
|
|
212
|
+
}
|
|
213
|
+
const props = defineProps<Props>();
|
|
214
|
+
const { callParent, param } = useBlade();
|
|
215
|
+
callParent("refresh");
|
|
216
|
+
const id = param.value;
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### `rewrite-imports` <sup>2.0.0</sup>
|
|
220
|
+
|
|
221
|
+
Moves symbols to sub-entry points: `aiAgentPlugin`, `useAiAgent`, etc. → `@vc-shell/framework/ai-agent`; `defineExtensionPoint`, `useExtensionPoint`, etc. → `@vc-shell/framework/extensions`.
|
|
222
|
+
|
|
223
|
+
### `remove-deprecated-aliases` <sup>2.0.0</sup>
|
|
224
|
+
|
|
225
|
+
Renames 6 deprecated injection key aliases:
|
|
226
|
+
|
|
227
|
+
| Old | New |
|
|
228
|
+
|-----|-----|
|
|
229
|
+
| `navigationViewLocation` | `NavigationViewLocationKey` |
|
|
230
|
+
| `BladeInstance` | `BladeInstanceKey` |
|
|
231
|
+
| `NotificationTemplatesSymbol` | `NotificationTemplatesKey` |
|
|
232
|
+
| `BLADE_BACK_BUTTON` | `BladeBackButtonKey` |
|
|
233
|
+
| `TOOLBAR_SERVICE` | `ToolbarServiceKey` |
|
|
234
|
+
| `EMBEDDED_MODE` | `EmbeddedModeKey` |
|
|
235
|
+
|
|
236
|
+
### `widgets-migration` <sup>2.0.0</sup>
|
|
237
|
+
|
|
238
|
+
Renames `useWidgets()` → `useBladeWidgets()`. Emits a warning if `registerWidget`/`unregisterWidget` calls are found — these need manual migration to the declarative `useBladeWidgets([...])` API.
|
|
239
|
+
|
|
240
|
+
### `composable-return-types` <sup>2.0.0</sup>
|
|
241
|
+
|
|
242
|
+
Renames 20 composable return type interfaces (e.g., `IUsePermissions` → `UsePermissionsReturn`, `IAppUserAPI` → `UseUserReturn`).
|
|
243
|
+
|
|
244
|
+
### `banner-variants` <sup>2.0.0</sup>
|
|
245
|
+
|
|
246
|
+
Updates VcBanner variant prop values: `"light-danger"` → `"danger"`, `"info-dark"` → `"info"`, `"primary"` → `"info"`.
|
|
247
|
+
|
|
248
|
+
### `switch-tooltip-prop` <sup>2.0.0</sup>
|
|
249
|
+
|
|
250
|
+
Renames `tooltip` → `hint` prop on `<VcSwitch>` (including `:tooltip` → `:hint`).
|
|
251
|
+
|
|
252
|
+
### `icon-container-prop` <sup>2.0.0</sup>
|
|
253
|
+
|
|
254
|
+
Removes the deprecated `useContainer` / `use-container` prop from `<VcIcon>`.
|
|
255
|
+
|
|
256
|
+
### `shims-to-globals` <sup>2.0.0</sup>
|
|
257
|
+
|
|
258
|
+
Replaces manual `shims-vue.d.ts` / `vue-i18n.d.ts` files with `@vc-shell/framework/globals` in `tsconfig.json` types. Standard boilerplate shim files are automatically deleted; customized ones trigger a warning.
|
|
259
|
+
|
|
260
|
+
### `icon-audit` <sup>2.0.0</sup> <kbd>diagnostic</kbd>
|
|
261
|
+
|
|
262
|
+
Scans for Font Awesome icon class names (`fas fa-check`, etc.) and reports them with suggested Material Symbols replacements. Does not modify files.
|
|
263
|
+
|
|
264
|
+
### `scss-safe-use` <sup>2.0.0</sup> <kbd>diagnostic</kbd>
|
|
265
|
+
|
|
266
|
+
Scans `.scss` files for `@import` statements and reports candidates for `@use`/`@forward` migration. Does not modify files.
|
|
267
|
+
|
|
268
|
+
### `menu-group-config` <sup>2.0.0</sup> <kbd>diagnostic</kbd>
|
|
269
|
+
|
|
270
|
+
Detects deprecated `group`, `groupIcon`, `inGroupPriority` menu properties and reports them for migration to `groupConfig: { id, title, icon, priority, permissions }`. Does not modify files.
|
|
271
|
+
|
|
272
|
+
## Troubleshooting
|
|
273
|
+
|
|
274
|
+
If something goes wrong after migration:
|
|
275
|
+
|
|
276
|
+
1. **Check the diff** — `git diff` shows exactly what changed. The tool preserves formatting, so real changes are easy to spot.
|
|
277
|
+
|
|
278
|
+
2. **Run TypeScript check** — `npx tsc --noEmit` catches type errors introduced by renames. Most should be caught by the transforms, but edge cases exist.
|
|
279
|
+
|
|
280
|
+
3. **Re-run a single transform** — if one specific transform caused issues:
|
|
281
|
+
```bash
|
|
282
|
+
git checkout -- . # revert all changes
|
|
283
|
+
npx @vc-shell/migrate --transform define-app-module # run just that one
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
4. **Check warnings** — the CLI prints `⚠` warnings for patterns that need manual review. Don't ignore these.
|
|
287
|
+
|
|
288
|
+
5. **Manual fixes for partial automation:**
|
|
289
|
+
- `useWidgets` → `useBladeWidgets`: The rename is automatic, but converting `registerWidget`/`unregisterWidget` to declarative `useBladeWidgets([...])` config requires manual work. See MIGRATION_GUIDE.md section "Registering Widgets in Blades".
|
|
290
|
+
- `onBeforeClose` with multiple returns or non-inline callbacks: Prints a warning. Review the logic and invert return values manually.
|
|
291
|
+
- Custom `.d.ts` shims: If `shims-vue.d.ts` contains custom augmentations beyond the standard boilerplate, it won't be deleted — merge your custom types with the framework globals manually.
|
|
292
|
+
|
|
293
|
+
6. **File an issue** — if a transform produces incorrect output, [open an issue](https://github.com/AnyOrg/vc-shell/issues) with the before/after code.
|
|
294
|
+
|
|
295
|
+
## Architecture
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
@vc-shell/migrate
|
|
299
|
+
├── src/
|
|
300
|
+
│ ├── cli.ts # CLI entry point (commander)
|
|
301
|
+
│ ├── runner.ts # Orchestrator: detect → select → execute → report
|
|
302
|
+
│ ├── version-detector.ts # Reads framework version from package.json
|
|
303
|
+
│ ├── transforms/
|
|
304
|
+
│ │ ├── types.ts # Transform/VersionedTransform interfaces
|
|
305
|
+
│ │ ├── registry.ts # Version-based transform registry
|
|
306
|
+
│ │ ├── define-app-module.ts
|
|
307
|
+
│ │ ├── use-blade-migration.ts
|
|
308
|
+
│ │ ├── ... (15 transforms total)
|
|
309
|
+
│ │ └── shims-to-globals.ts
|
|
310
|
+
│ └── utils/
|
|
311
|
+
│ ├── vue-sfc-wrapper.ts # SFC handling: wrapForSFC, wrapForSFCTemplate, wrapForSFCBoth
|
|
312
|
+
│ ├── template-transform.ts # String-based template attribute manipulation
|
|
313
|
+
│ ├── import-rewriter.ts # Symbol → sub-entry-point mapping
|
|
314
|
+
│ └── test-helpers.ts # applyTransform, applyTransformWithReports, defineFixtureTest
|
|
315
|
+
└── tests/ # 90 tests across 18 test files
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Adding a new transform
|
|
319
|
+
|
|
320
|
+
1. Create `src/transforms/my-transform.ts` following the jscodeshift signature:
|
|
321
|
+
```ts
|
|
322
|
+
import type { API, FileInfo, Options } from "jscodeshift";
|
|
323
|
+
import { wrapForSFC } from "../utils/vue-sfc-wrapper.js";
|
|
324
|
+
import type { Transform } from "./types.js";
|
|
325
|
+
|
|
326
|
+
function coreTransform(fileInfo: FileInfo, api: API, options: Options): string | null {
|
|
327
|
+
const j = api.jscodeshift;
|
|
328
|
+
const root = j(fileInfo.source);
|
|
329
|
+
// ... find and replace patterns ...
|
|
330
|
+
return root.toSource(); // or null if no changes
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export default wrapForSFC(coreTransform) as Transform;
|
|
334
|
+
export const parser = "tsx";
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
2. Register in `src/transforms/registry.ts`:
|
|
338
|
+
```ts
|
|
339
|
+
{
|
|
340
|
+
name: "my-transform",
|
|
341
|
+
description: "What it does",
|
|
342
|
+
introducedIn: "2.1.0",
|
|
343
|
+
transformPath: t("my-transform"),
|
|
344
|
+
},
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
3. Add tests in `tests/transforms/my-transform/transform.test.ts`
|
|
348
|
+
|
|
349
|
+
4. Run: `npx vitest run`
|
|
350
|
+
|
|
351
|
+
### Tech stack
|
|
352
|
+
|
|
353
|
+
- **[jscodeshift](https://github.com/facebook/jscodeshift)** — AST query/manipulation (jQuery-like API for JavaScript/TypeScript ASTs)
|
|
354
|
+
- **[recast](https://github.com/benjamn/recast)** — Format-preserving parser/printer (transitive via jscodeshift)
|
|
355
|
+
- **[@vue/compiler-sfc](https://github.com/vuejs/core)** — Vue Single File Component parser
|
|
356
|
+
- **[write-file-atomic](https://github.com/npm/write-file-atomic)** — Crash-safe file writes
|
|
357
|
+
- **[jsonc-parser](https://github.com/microsoft/node-jsonc-parser)** — JSON with comments parser (for tsconfig.json)
|
|
358
|
+
- **[semver](https://github.com/npm/node-semver)** — Version range comparison
|
|
359
|
+
- **[vitest](https://vitest.dev/)** — Test runner
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { resolve } from "node:path";
|
|
5
|
+
import { run } from "./runner.js";
|
|
6
|
+
const program = new Command();
|
|
7
|
+
program
|
|
8
|
+
.name("vc-shell-migrate")
|
|
9
|
+
.description("Migrate your code to the latest @vc-shell/framework version")
|
|
10
|
+
.version("1.0.0")
|
|
11
|
+
.option("--to <version>", "Target framework version (default: latest)")
|
|
12
|
+
.option("--transform <name>", "Run only a specific transform")
|
|
13
|
+
.option("--dry-run", "Preview changes without writing files", false)
|
|
14
|
+
.option("--list", "List available transforms", false)
|
|
15
|
+
.option("--cwd <path>", "Working directory", ".")
|
|
16
|
+
.option("--update-deps", "Also update dependency versions in package.json", false)
|
|
17
|
+
.action(async (options) => {
|
|
18
|
+
const cwd = resolve(options.cwd);
|
|
19
|
+
// Pre-flight: dirty working tree check
|
|
20
|
+
if (!options.dryRun && !options.list) {
|
|
21
|
+
try {
|
|
22
|
+
const { execFileSync } = await import("node:child_process");
|
|
23
|
+
const status = execFileSync("git", ["status", "--porcelain"], {
|
|
24
|
+
cwd,
|
|
25
|
+
encoding: "utf-8",
|
|
26
|
+
});
|
|
27
|
+
if (status.trim().length > 0) {
|
|
28
|
+
console.log(chalk.yellow("Warning: You have uncommitted changes. " +
|
|
29
|
+
"We recommend committing or stashing before running migrations."));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// Not a git repo or git not available — skip check
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
await run({
|
|
37
|
+
cwd,
|
|
38
|
+
to: options.to,
|
|
39
|
+
transform: options.transform,
|
|
40
|
+
dryRun: options.dryRun,
|
|
41
|
+
list: options.list,
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
program.parse();
|
|
45
|
+
//# source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,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC7B,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,MAAM,CACV,yCAAyC;oBACvC,gEAAgE,CACnE,CACF,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,mDAAmD;QACrD,CAAC;IACH,CAAC;IAED,MAAM,GAAG,CAAC;QACR,GAAG;QACH,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/runner.d.ts
ADDED
package/dist/runner.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { resolve, join } from "node:path";
|
|
3
|
+
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
4
|
+
import writeFileAtomic from "write-file-atomic";
|
|
5
|
+
import jscodeshift from "jscodeshift";
|
|
6
|
+
import { detectFrameworkVersion } from "./version-detector.js";
|
|
7
|
+
import { selectTransforms, transforms } from "./transforms/registry.js";
|
|
8
|
+
export async function run(options) {
|
|
9
|
+
if (options.list) {
|
|
10
|
+
listTransforms();
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const cwd = resolve(options.cwd);
|
|
14
|
+
const currentVersion = detectFrameworkVersion(cwd);
|
|
15
|
+
if (!currentVersion) {
|
|
16
|
+
console.log(chalk.red("Could not detect @vc-shell/framework version in " + cwd));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const targetVersion = options.to ?? "2.0.0";
|
|
20
|
+
console.log(chalk.blue(`Migrating from ${currentVersion} → ${targetVersion}`));
|
|
21
|
+
let selected = selectTransforms(currentVersion, targetVersion);
|
|
22
|
+
if (options.transform) {
|
|
23
|
+
selected = selected.filter((t) => t.name === options.transform);
|
|
24
|
+
if (selected.length === 0) {
|
|
25
|
+
console.log(chalk.yellow(`Transform "${options.transform}" not found or not applicable for this version range.`));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (selected.length === 0) {
|
|
30
|
+
console.log(chalk.green("No transforms needed for this version range."));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
console.log(chalk.blue(`Running ${selected.length} transform(s)${options.dryRun ? " (dry run)" : ""}:`));
|
|
34
|
+
selected.forEach((t) => console.log(chalk.gray(` - ${t.name}: ${t.description}`)));
|
|
35
|
+
// Glob source files for per-file transforms
|
|
36
|
+
const srcDir = join(cwd, "src");
|
|
37
|
+
const sourceFiles = findFiles(srcDir, [".ts", ".vue"]);
|
|
38
|
+
for (const t of selected) {
|
|
39
|
+
console.log(chalk.blue(`\nRunning: ${t.name}...`));
|
|
40
|
+
// Dynamic import of transform module
|
|
41
|
+
const mod = await import(t.transformPath);
|
|
42
|
+
const transform = mod.default;
|
|
43
|
+
const parser = mod.parser ?? "tsx";
|
|
44
|
+
const j = jscodeshift.withParser(parser);
|
|
45
|
+
const report = {
|
|
46
|
+
name: t.name,
|
|
47
|
+
filesModified: [],
|
|
48
|
+
filesSkipped: [],
|
|
49
|
+
filesErrored: [],
|
|
50
|
+
reports: [],
|
|
51
|
+
};
|
|
52
|
+
const api = {
|
|
53
|
+
jscodeshift: j,
|
|
54
|
+
j,
|
|
55
|
+
stats: () => { },
|
|
56
|
+
report: (msg) => report.reports.push(msg),
|
|
57
|
+
};
|
|
58
|
+
if (t.scope === "project") {
|
|
59
|
+
// Project-scoped transforms run once with cwd
|
|
60
|
+
try {
|
|
61
|
+
transform({ path: cwd, source: "" }, api, { cwd, dryRun: options.dryRun });
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
report.filesErrored.push({
|
|
65
|
+
path: cwd,
|
|
66
|
+
error: err instanceof Error ? err.message : String(err),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
// Per-file transforms
|
|
72
|
+
for (const filePath of sourceFiles) {
|
|
73
|
+
try {
|
|
74
|
+
const source = readFileSync(filePath, "utf-8");
|
|
75
|
+
const result = transform({ path: filePath, source }, api, { cwd });
|
|
76
|
+
if (result != null && result !== source) {
|
|
77
|
+
if (!options.dryRun) {
|
|
78
|
+
writeFileAtomic.sync(filePath, result);
|
|
79
|
+
}
|
|
80
|
+
report.filesModified.push(filePath);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
report.filesSkipped.push(filePath);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
report.filesErrored.push({
|
|
88
|
+
path: filePath,
|
|
89
|
+
error: err instanceof Error ? err.message : String(err),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Print report
|
|
95
|
+
if (report.filesModified.length > 0) {
|
|
96
|
+
console.log(chalk.green(` Modified: ${report.filesModified.length} file(s)`));
|
|
97
|
+
}
|
|
98
|
+
if (report.reports.length > 0) {
|
|
99
|
+
report.reports.forEach((w) => console.log(chalk.yellow(` ⚠ ${w}`)));
|
|
100
|
+
}
|
|
101
|
+
if (report.filesErrored.length > 0) {
|
|
102
|
+
report.filesErrored.forEach((e) => console.log(chalk.red(` ✗ ${e.path}: ${e.error}`)));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (options.dryRun) {
|
|
106
|
+
console.log(chalk.yellow("\nDry run complete. No files were modified."));
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
console.log(chalk.green("\nAll transforms applied successfully."));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function findFiles(dir, extensions) {
|
|
113
|
+
const results = [];
|
|
114
|
+
let entries;
|
|
115
|
+
try {
|
|
116
|
+
entries = readdirSync(dir, { encoding: "utf-8" });
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return results;
|
|
120
|
+
}
|
|
121
|
+
for (const entry of entries) {
|
|
122
|
+
if (entry === "node_modules" || entry.startsWith(".") || entry === "dist")
|
|
123
|
+
continue;
|
|
124
|
+
const full = join(dir, entry);
|
|
125
|
+
try {
|
|
126
|
+
const stat = statSync(full);
|
|
127
|
+
if (stat.isDirectory()) {
|
|
128
|
+
results.push(...findFiles(full, extensions));
|
|
129
|
+
}
|
|
130
|
+
else if (extensions.some((ext) => entry.endsWith(ext))) {
|
|
131
|
+
results.push(full);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return results;
|
|
139
|
+
}
|
|
140
|
+
function listTransforms() {
|
|
141
|
+
console.log(chalk.blue("Available transforms:\n"));
|
|
142
|
+
for (const t of transforms) {
|
|
143
|
+
const tag = t.diagnosticOnly ? chalk.gray(" [diagnostic]") : "";
|
|
144
|
+
const scopeTag = t.scope === "project" ? chalk.gray(" [project]") : "";
|
|
145
|
+
console.log(` ${chalk.bold(t.name)}${tag}${scopeTag}`);
|
|
146
|
+
console.log(` ${t.description}`);
|
|
147
|
+
console.log(` Introduced in: ${t.introducedIn}`);
|
|
148
|
+
if (t.migrationGuideSection) {
|
|
149
|
+
console.log(` Migration guide: ${t.migrationGuideSection}`);
|
|
150
|
+
}
|
|
151
|
+
console.log();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,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,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC;IACnD,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;QAC3B,MAAM,GAAG,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAChE,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACvE,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,QAAQ,EAAE,CAAC,CAAC;QACxD,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC;QACpD,IAAI,CAAC,CAAC,qBAAqB,EAAE,CAAC;YAC5B,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,qBAAqB,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,CAAC,GAAG,EAAE,CAAC;IAChB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { wrapForSFCTemplate } from "../utils/vue-sfc-wrapper.js";
|
|
2
|
+
const VARIANT_MAP = {
|
|
3
|
+
"light-danger": "danger",
|
|
4
|
+
"info-dark": "info",
|
|
5
|
+
"primary": "info",
|
|
6
|
+
};
|
|
7
|
+
function templateTransform(template, _filePath) {
|
|
8
|
+
const tagRe = /(<(?:VcBanner|vc-banner)\b[^>]*?)(variant="(?:light-danger|info-dark|primary)")/gs;
|
|
9
|
+
const modified = template.replace(tagRe, (_match, before, variantAttr) => {
|
|
10
|
+
for (const [oldVariant, newVariant] of Object.entries(VARIANT_MAP)) {
|
|
11
|
+
if (variantAttr === `variant="${oldVariant}"`) {
|
|
12
|
+
return before + `variant="${newVariant}"`;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return before + variantAttr;
|
|
16
|
+
});
|
|
17
|
+
return { content: modified, changed: modified !== template };
|
|
18
|
+
}
|
|
19
|
+
export default wrapForSFCTemplate(templateTransform);
|
|
20
|
+
export const parser = "tsx";
|
|
21
|
+
//# sourceMappingURL=banner-variants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner-variants.js","sourceRoot":"","sources":["../../src/transforms/banner-variants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGjE,MAAM,WAAW,GAA2B;IAC1C,cAAc,EAAE,QAAQ;IACxB,WAAW,EAAE,MAAM;IACnB,SAAS,EAAE,MAAM;CAClB,CAAC;AAEF,SAAS,iBAAiB,CAAC,QAAgB,EAAE,SAAiB;IAC5D,MAAM,KAAK,GAAG,mFAAmF,CAAC;IAClG,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE;QACvE,KAAK,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;YACnE,IAAI,WAAW,KAAK,YAAY,UAAU,GAAG,EAAE,CAAC;gBAC9C,OAAO,MAAM,GAAG,YAAY,UAAU,GAAG,CAAC;YAC5C,CAAC;QACH,CAAC;QACD,OAAO,MAAM,GAAG,WAAW,CAAC;IAC9B,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,KAAK,QAAQ,EAAE,CAAC;AAC/D,CAAC;AAED,eAAe,kBAAkB,CAAC,iBAAiB,CAAc,CAAC;AAClE,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC"}
|