@easy-web/content-blocks 1.3.1 → 1.3.2

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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=exports-resolution.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports-resolution.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/exports-resolution.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,83 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { readdirSync, readFileSync } from 'node:fs';
3
+ import { createRequire } from 'node:module';
4
+ import path from 'node:path';
5
+ import { fileURLToPath, pathToFileURL } from 'node:url';
6
+ /**
7
+ * Export-resolution smoke test.
8
+ *
9
+ * Every subpath export this package declares is resolved through Node's real
10
+ * package-exports algorithm — not a regex, not a simulation. `createRequire()`
11
+ * is anchored on this package's own `package.json`, so Node self-resolves the
12
+ * `@easy-web/content-blocks/...` specifiers against the very `exports` block
13
+ * under test.
14
+ *
15
+ * Fixtures are the package's own real components and schemas, discovered on
16
+ * disk, so the probe list grows automatically with the package.
17
+ *
18
+ * Regression gate for issue #17: `"./components/*"` maps onto
19
+ * `"./src/components/*.astro"`, which appends the extension to the capture.
20
+ * The `.astro`-suffixed specifier the README documents therefore resolved to
21
+ * `*.astro.astro` and threw `ERR_PACKAGE_PATH_NOT_EXPORTED`. Deleting the
22
+ * `"./components/*.astro"` key must make this file fail.
23
+ */
24
+ const packageRoot = fileURLToPath(new URL('../../', import.meta.url));
25
+ const packageJsonPath = path.join(packageRoot, 'package.json');
26
+ const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
27
+ const requireFromPackage = createRequire(pathToFileURL(packageJsonPath));
28
+ /** Every `exports` key except the package root, which needs a build to exist. */
29
+ const subpathEntries = Object.entries(pkg.exports).filter(([key]) => key !== '.');
30
+ /**
31
+ * Expand one `exports` entry into concrete probes, substituting the `*`
32
+ * wildcard with every real file the target pattern matches on disk.
33
+ */
34
+ function expandProbes(key, target) {
35
+ if (!key.includes('*')) {
36
+ return [
37
+ {
38
+ key,
39
+ specifier: `${pkg.name}${key.slice(1)}`,
40
+ expectedFile: path.resolve(packageRoot, target),
41
+ },
42
+ ];
43
+ }
44
+ const [keyPrefix, keySuffix] = key.split('*');
45
+ const [targetPrefix, targetSuffix] = target.split('*');
46
+ const targetDir = path.resolve(packageRoot, targetPrefix);
47
+ const captures = readdirSync(targetDir, { withFileTypes: true })
48
+ .filter((entry) => entry.isFile() && entry.name.endsWith(targetSuffix))
49
+ .map((entry) => (targetSuffix ? entry.name.slice(0, -targetSuffix.length) : entry.name))
50
+ .sort();
51
+ return captures.map((capture) => ({
52
+ key,
53
+ specifier: `${pkg.name}${keyPrefix.slice(1)}${capture}${keySuffix}`,
54
+ expectedFile: path.resolve(packageRoot, `${targetPrefix}${capture}${targetSuffix}`),
55
+ }));
56
+ }
57
+ const probes = subpathEntries.flatMap(([key, target]) => typeof target === 'string' ? expandProbes(key, target) : []);
58
+ describe('@easy-web/content-blocks subpath exports', () => {
59
+ it('declares the subpath exports its README documents', () => {
60
+ expect(Object.keys(pkg.exports)).toEqual(expect.arrayContaining(['./components/*', './components/*.astro', './schemas/*']));
61
+ });
62
+ it('expands every declared subpath key into at least one real probe', () => {
63
+ for (const [key, target] of subpathEntries) {
64
+ expect(typeof target, `export key "${key}" has a conditional target; teach expandProbes() about it`).toBe('string');
65
+ expect(probes.filter((probe) => probe.key === key).length, `export key "${key}" expanded to no probes — no fixture file matched its target`).toBeGreaterThan(0);
66
+ }
67
+ });
68
+ it.each(probes.map((probe) => [probe.specifier, probe.expectedFile]))('resolves %s', (specifier, expectedFile) => {
69
+ expect(requireFromPackage.resolve(specifier)).toBe(expectedFile);
70
+ });
71
+ });
72
+ describe('@easy-web/content-blocks documented import forms (issue #17 regression gate)', () => {
73
+ it('resolves Hero through both the extensionless and the .astro-suffixed form', () => {
74
+ const extensionless = requireFromPackage.resolve('@easy-web/content-blocks/components/Hero');
75
+ const withExtension = requireFromPackage.resolve('@easy-web/content-blocks/components/Hero.astro');
76
+ expect(extensionless).toBe(path.resolve(packageRoot, 'src/components/Hero.astro'));
77
+ expect(withExtension).toBe(extensionless);
78
+ });
79
+ it('resolves the galleries schema through the ./schemas/* wildcard', () => {
80
+ expect(requireFromPackage.resolve('@easy-web/content-blocks/schemas/galleries')).toBe(path.resolve(packageRoot, 'src/schemas/galleries.ts'));
81
+ });
82
+ });
83
+ //# sourceMappingURL=exports-resolution.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports-resolution.test.js","sourceRoot":"","sources":["../../src/__tests__/exports-resolution.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAExD;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACtE,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;AAO/D,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAoB,CAAC;AACjF,MAAM,kBAAkB,GAAG,aAAa,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC;AAEzE,iFAAiF;AACjF,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAA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AE,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,YAAY,CAAU,CAAC,CAAC,CAC5E,aAAa,EACb,CAAC,SAAS,EAAE,YAAY,EAAE,EAAE;QAC1B,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACnE,CAAC,CACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,8EAA8E,EAAE,GAAG,EAAE;IAC5F,EAAE,CAAC,2EAA2E,EAAE,GAAG,EAAE;QACnF,MAAM,aAAa,GAAG,kBAAkB,CAAC,OAAO,CAAC,0CAA0C,CAAC,CAAC;QAC7F,MAAM,aAAa,GAAG,kBAAkB,CAAC,OAAO,CAC9C,gDAAgD,CACjD,CAAC;QAEF,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,2BAA2B,CAAC,CAAC,CAAC;QACnF,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;QACxE,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,4CAA4C,CAAC,CAAC,CAAC,IAAI,CACnF,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,0BAA0B,CAAC,CACtD,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easy-web/content-blocks",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "type": "module",
5
5
  "description": "Reusable Astro content-block components for the easy-web ecosystem.",
6
6
  "exports": {
@@ -24,8 +24,8 @@
24
24
  "zod": ">=4.0.0"
25
25
  },
26
26
  "dependencies": {
27
- "@easy-web/i18n": "1.3.1",
28
- "@easy-web/theme-core": "1.3.1"
27
+ "@easy-web/i18n": "1.3.2",
28
+ "@easy-web/theme-core": "1.3.2"
29
29
  },
30
30
  "devDependencies": {
31
31
  "astro": "^6.4.0",