@poveste/plugin-vue 0.14.0 → 0.16.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/README.md +2 -2
- package/components.d.ts +4 -0
- package/dist/bundled/client/app/MountStory.js +8 -3
- package/dist/bundled/client/app/RenderStory.js +15 -9
- package/dist/bundled/client/app/Story.js +76 -62
- package/dist/bundled/client/app/Variant.js +48 -42
- package/dist/bundled/client/app/context.js +5 -0
- package/dist/bundled/client/app/global-components.js +11 -10
- package/dist/bundled/client/app/host.js +2 -2
- package/dist/bundled/client/app/render-context.js +7 -7
- package/dist/bundled/client/app/util.js +36 -26
- package/dist/bundled/client/client.js +4 -4
- package/dist/bundled/client/codegen.js +79 -60
- package/dist/bundled/client/context.js +20 -0
- package/dist/bundled/client/server/Story.js +28 -25
- package/dist/bundled/client/server/Variant.js +13 -16
- package/dist/bundled/client/server/context.js +5 -0
- package/dist/bundled/client/server/run.js +29 -29
- package/dist/client/app/MountStory.d.ts +12 -3
- package/dist/client/app/RenderStory.d.ts +1 -1
- package/dist/client/app/Story.d.ts +10 -7
- package/dist/client/app/Variant.d.ts +14 -13
- package/dist/client/app/context.d.ts +9 -0
- package/dist/client/app/render-context.d.ts +16 -1
- package/dist/client/app/util.d.ts +38 -3
- package/dist/client/codegen.d.ts +29 -0
- package/dist/client/context.d.ts +40 -0
- package/dist/client/server/Story.d.ts +17 -17
- package/dist/client/server/Variant.d.ts +10 -10
- package/dist/client/server/context.d.ts +7 -0
- package/dist/commands/generate-story.client.js +4 -4
- package/dist/commands/generate-story.server.js +2 -2
- package/dist/helpers.d.ts +2 -2
- package/dist/index.node.js +2 -0
- package/dist/util/list-components.d.ts +1 -1
- package/dist/util/list-components.js +63 -6
- package/dist/util/list-components.spec.d.ts +1 -0
- package/dist/util/list-components.spec.js +46 -0
- package/package.json +17 -16
- package/src/client/__tests__/codegen-attrs.spec.ts +149 -0
- package/src/client/__tests__/context.spec.ts +50 -0
- package/src/client/app/MountStory.ts +11 -1
- package/src/client/app/RenderStory.ts +6 -1
- package/src/client/app/RouterLinkStub.ts +1 -1
- package/src/client/app/Story.ts +85 -39
- package/src/client/app/Variant.ts +35 -27
- package/src/client/app/__tests__/preview-variants.spec.ts +76 -0
- package/src/client/app/__tests__/state-sync.spec.ts +113 -2
- package/src/client/app/__tests__/writable-binding.spec.ts +39 -0
- package/src/client/app/auto-props.ts +2 -2
- package/src/client/app/context.ts +17 -0
- package/src/client/app/global-components.ts +20 -14
- package/src/client/app/host.ts +9 -6
- package/src/client/app/render-context.ts +25 -5
- package/src/client/app/util.ts +104 -9
- package/src/client/codegen.ts +81 -29
- package/src/client/context.ts +66 -0
- package/src/client/server/Story.ts +16 -10
- package/src/client/server/Variant.ts +13 -14
- package/src/client/server/__tests__/nesting-errors.spec.ts +48 -0
- package/src/client/server/context.ts +18 -0
- package/src/client/server/run.ts +11 -7
- package/src/commands/generate-story.client.ts +4 -4
- package/src/commands/generate-story.server.ts +2 -2
- package/src/helpers.ts +2 -2
- package/src/index.node.ts +2 -0
- package/src/util/list-components.spec.ts +54 -0
- package/src/util/list-components.ts +68 -6
|
@@ -1,13 +1,75 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
2
|
+
import { dirname, join, relative, resolve, sep } from 'node:path'
|
|
3
|
+
import ignore from 'ignore'
|
|
4
|
+
import { glob } from 'tinyglobby'
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
function toPosix(path: string): string {
|
|
7
|
+
return path.split(sep).join('/')
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Whether a file under `cwd` is git-ignored, the way globby's `gitignore: true`
|
|
12
|
+
* decided it: every `.gitignore` from the repository root down, each pattern
|
|
13
|
+
* relative to its own file. tinyglobby reads none of them (#839).
|
|
14
|
+
*/
|
|
15
|
+
async function gitIgnoredFilter(cwd: string): Promise<(file: string) => boolean> {
|
|
16
|
+
let root = cwd
|
|
17
|
+
while (!existsSync(join(root, '.git'))) {
|
|
18
|
+
const parent = dirname(root)
|
|
19
|
+
if (parent === root) {
|
|
20
|
+
root = cwd
|
|
21
|
+
break
|
|
22
|
+
}
|
|
23
|
+
root = parent
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const ancestors: string[] = []
|
|
27
|
+
for (let dir = cwd; dir !== root;) {
|
|
28
|
+
dir = dirname(dir)
|
|
29
|
+
ancestors.unshift(join(dir, '.gitignore'))
|
|
30
|
+
}
|
|
31
|
+
// Shallow files first, so a nested `.gitignore` can override its parent.
|
|
32
|
+
const nested = (await glob('**/.gitignore', { cwd, absolute: true, dot: true, ignore: ['**/node_modules/**', '**/.git/**'] }))
|
|
33
|
+
.sort((a, b) => a.split('/').length - b.split('/').length || a.localeCompare(b))
|
|
34
|
+
|
|
35
|
+
const rules = ignore()
|
|
36
|
+
for (const file of [...ancestors, ...nested]) {
|
|
37
|
+
if (!existsSync(file)) {
|
|
38
|
+
continue
|
|
39
|
+
}
|
|
40
|
+
const base = toPosix(relative(root, dirname(file)))
|
|
41
|
+
for (const raw of readFileSync(file, 'utf8').split(/\r?\n/)) {
|
|
42
|
+
const line = raw.trimEnd()
|
|
43
|
+
if (!line || line.startsWith('#')) {
|
|
44
|
+
continue
|
|
45
|
+
}
|
|
46
|
+
const negated = line.startsWith('!')
|
|
47
|
+
let pattern = negated ? line.slice(1) : line
|
|
48
|
+
if (base) {
|
|
49
|
+
// A pattern with a slash before its end is anchored to its own directory;
|
|
50
|
+
// one without matches at any depth below it.
|
|
51
|
+
const anchored = pattern.replace(/\/$/, '').includes('/')
|
|
52
|
+
pattern = anchored ? `${base}/${pattern.replace(/^\//, '')}` : `${base}/**/${pattern}`
|
|
53
|
+
}
|
|
54
|
+
rules.add(negated ? `!${pattern}` : pattern)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return (file) => {
|
|
59
|
+
const path = toPosix(relative(root, resolve(cwd, file)))
|
|
60
|
+
return !path.startsWith('..') && rules.ignores(path)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export async function listComponentFiles(search = '', ignoredPatterns: string[] = [], limit = 10, cwd = process.cwd()) {
|
|
65
|
+
const isIgnored = await gitIgnoredFilter(cwd)
|
|
66
|
+
let files = (await glob('**/*.vue', {
|
|
67
|
+
cwd,
|
|
6
68
|
ignore: [
|
|
7
69
|
'node_modules',
|
|
8
|
-
...
|
|
70
|
+
...ignoredPatterns,
|
|
9
71
|
],
|
|
10
|
-
})
|
|
72
|
+
})).filter(file => !isIgnored(file))
|
|
11
73
|
if (search) {
|
|
12
74
|
const searchText = search.toLowerCase()
|
|
13
75
|
files = files.filter(file => file.toLowerCase().includes(searchText))
|