@eventra_dev/cli-plugin-vue 1.0.1 → 1.0.3

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 CHANGED
@@ -7,7 +7,8 @@
7
7
  <p align="center">
8
8
  <a href="https://www.npmjs.com/package/@eventra_dev/cli-plugin-vue"><img alt="npm version" src="https://img.shields.io/npm/v/@eventra_dev/cli-plugin-vue.svg?style=flat-square&color=blue"></a>
9
9
  <a href="https://www.npmjs.com/package/@eventra_dev/cli-plugin-vue"><img alt="npm downloads" src="https://img.shields.io/npm/dm/@eventra_dev/cli-plugin-vue.svg?style=flat-square&color=blue"></a>
10
- <img alt="tests passing" src="https://img.shields.io/badge/tests-16%20passing-brightgreen?style=flat-square&logo=vitest&logoColor=white">
10
+ <img alt="tests passing" src="https://img.shields.io/badge/tests-20%20passing-brightgreen?style=flat-square&logo=vitest&logoColor=white">
11
+ <img alt="coverage" src="https://img.shields.io/badge/coverage-100%25-brightgreen?style=flat-square&logo=vitest&logoColor=white">
11
12
  <img alt="node" src="https://img.shields.io/node/v/@eventra_dev/cli-plugin-vue?style=flat-square&color=darkgreen&logo=node.js&logoColor=white">
12
13
  <a href="https://www.typescriptlang.org/"><img alt="TypeScript" src="https://img.shields.io/badge/TypeScript-ready-blue?style=flat-square&logo=typescript&logoColor=white"></a>
13
14
  <img alt="license" src="https://img.shields.io/npm/l/@eventra_dev/cli-plugin-vue?style=flat-square&color=lightgrey">
@@ -95,7 +96,7 @@ The expression is copied as-is into the same module scope as the script. If it r
95
96
 
96
97
  Nuxt pages, layouts, and components are ordinary `.vue` SFCs — parsed identically, no extra configuration needed.
97
98
 
98
- Composables auto-imported without an explicit `import` statement (Nuxt's own composables, or your own from `composables/`/`utils/`) are intended to resolve **once the project has run `nuxt prepare`/`nuxt dev`** (so `.nuxt/` exists and is wired into `tsconfig.json` — the CLI analyzes the project's real `tsconfig.json`, so Nuxt's generated ambient types are visible to it like any other TypeScript project). The CLI's resolver understands the `declare const x: typeof import("./module")["name"]` shape Nuxt/`unplugin-auto-import` generate for these bindings, and this is covered by a unit test that hand-writes that ambient shape (`@eventra_dev/eventra-cli`'s `nuxtAutoImportCompat.test.ts`) — but running a real `nuxt prepare`/`nuxt build` end-to-end has not been verified in this environment (blocked by a sandbox GLIBC incompatibility with Nuxt's native build tooling), so this is not confirmed against a real generated `.nuxt/imports.d.ts`.
99
+ Composables auto-imported without an explicit `import` statement (Nuxt's own composables, or your own from `composables/`/`utils/`) are intended to resolve **once the project has run `nuxt prepare`/`nuxt dev`** (so `.nuxt/` exists and is wired into `tsconfig.json` — the CLI analyzes the project's real `tsconfig.json`, so Nuxt's generated ambient types are visible to it like any other TypeScript project). The host CLI's resolver understands the `declare const x: typeof import("./module")["name"]` shape Nuxt/`unplugin-auto-import` generate for these bindings (verified against a hand-written fixture reproducing that ambient shape) — but running a real `nuxt prepare`/`nuxt build` end-to-end has not been verified in this environment (blocked by a sandbox GLIBC incompatibility with Nuxt's native build tooling), so this is not confirmed against a real generated `.nuxt/imports.d.ts`.
99
100
 
100
101
  ---
101
102
 
@@ -133,7 +134,9 @@ No dependency on `@eventra_dev/eventra-cli` — the CLI adapts this shape intern
133
134
 
134
135
  ## Test Coverage
135
136
 
136
- **16 unit tests** (vitest), covering:
137
+ **100% statement/branch/function/line coverage** (v8 provider, `pnpm test:coverage`), enforced via a `coverage.thresholds` block in `vitest.config.ts`.
138
+
139
+ **20 unit tests** (vitest), covering:
137
140
 
138
141
  | Area | Covers |
139
142
  |---|---|
@@ -144,12 +147,13 @@ No dependency on `@eventra_dev/eventra-cli` — the CLI adapts this shape intern
144
147
  | Virtual module output | Single combined `.vue.ts`, export stub when script/template are empty |
145
148
  | Plugin contract | `match()`, `includeGlobs`, `staticSinks`, `transform()` |
146
149
 
147
- The Nuxt ambient auto-import shape (`declare const x: typeof import(...)`) is covered by a unit test in `@eventra_dev/eventra-cli` (`nuxtAutoImportCompat.test.ts`) that hand-writes that shape — this is not the same as an end-to-end run against a real `nuxt prepare`/`nuxt build`, which has not been verified in this environment (see the [Nuxt](#nuxt) section above).
150
+ The Nuxt ambient auto-import shape (`declare const x: typeof import(...)`) is covered by a unit test in the host CLI that hand-writes that shape — this is not the same as an end-to-end run against a real `nuxt prepare`/`nuxt build`, which has not been verified in this environment (see the [Nuxt](#nuxt) section above).
148
151
 
149
152
  Run locally:
150
153
 
151
154
  ```bash
152
155
  pnpm --filter @eventra_dev/cli-plugin-vue test
156
+ pnpm --filter @eventra_dev/cli-plugin-vue test:coverage
153
157
  ```
154
158
 
155
159
  ---
@@ -1 +1 @@
1
- {"version":3,"file":"parse-vue-sfc.d.ts","sourceRoot":"","sources":["../src/parse-vue-sfc.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,8EAA8E;AAC9E,MAAM,WAAW,oBAAoB;IACnC,0GAA0G;IAC1G,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;IAC5C,QAAQ,CAAC,cAAc,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACzD,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAyDD,iHAAiH;AACjH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,YAAY,CAiC1E;AAED,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzD;AAID;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CA+B9D"}
1
+ {"version":3,"file":"parse-vue-sfc.d.ts","sourceRoot":"","sources":["../src/parse-vue-sfc.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,8EAA8E;AAC9E,MAAM,WAAW,oBAAoB;IACnC,0GAA0G;IAC1G,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;IAC5C,QAAQ,CAAC,cAAc,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACzD,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAyDD,iHAAiH;AACjH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,YAAY,CA6C1E;AAED,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzD;AAID;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CA+B9D"}
@@ -82,17 +82,30 @@ function parseVueSfc(source, filePath) {
82
82
  if (template.ast) {
83
83
  collectEventBindings(template.ast, templateEvents);
84
84
  }
85
- else if (template.src) {
86
- const external = readSrcFile(filePath, template.src);
87
- if (external) {
88
- collectEventBindings((0, compiler_dom_1.parse)(external), templateEvents);
85
+ else {
86
+ // @vue/compiler-sfc only ever leaves `ast` unset when `src` is set
87
+ // (external template file) - the `else` here is a defensive fallback,
88
+ // not a reachable third case
89
+ /* v8 ignore else */
90
+ if (template.src) {
91
+ const external = readSrcFile(filePath, template.src);
92
+ if (external) {
93
+ collectEventBindings((0, compiler_dom_1.parse)(external), templateEvents);
94
+ }
89
95
  }
90
96
  }
91
97
  }
92
98
  return {
93
99
  scripts,
94
100
  templateEvents,
95
- errors: errors.map((error) => (error instanceof Error ? error.message : String(error))),
101
+ errors: errors.map((error) => {
102
+ // @vue/compiler-sfc errors are always Error instances
103
+ /* v8 ignore else */
104
+ if (error instanceof Error)
105
+ return error.message;
106
+ /* v8 ignore next */
107
+ return String(error);
108
+ }),
96
109
  };
97
110
  }
98
111
  /** Map `App.vue` → `App.vue.ts` (single virtual TS module for the compiler). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eventra_dev/cli-plugin-vue",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Eventra CLI plugin — extract track() calls from Vue SFC (.vue) files",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -29,7 +29,8 @@
29
29
  "build": "tsc -p tsconfig.json",
30
30
  "clean": "rm -rf dist",
31
31
  "test": "vitest run",
32
- "test:watch": "vitest"
32
+ "test:watch": "vitest",
33
+ "test:coverage": "vitest run --coverage"
33
34
  },
34
35
  "dependencies": {
35
36
  "@vue/compiler-core": "^3.5.40",
@@ -38,6 +39,7 @@
38
39
  },
39
40
  "devDependencies": {
40
41
  "@types/node": "^20.0.0",
42
+ "@vitest/coverage-v8": "^4.1.7",
41
43
  "typescript": "^5.3.0",
42
44
  "vitest": "^4.1.7"
43
45
  },