@devalon.dev/credits 0.0.0-stage → 1.0.1

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.
Files changed (66) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +145 -2
  3. package/dist/chunk-NG7NWZWD.mjs +16 -0
  4. package/dist/chunk-SHIXBOQB.mjs +1 -0
  5. package/dist/chunk-YBXS4SND.mjs +11 -0
  6. package/dist/core/agent-files.d.ts +46 -0
  7. package/dist/core/alternates.d.ts +4 -0
  8. package/dist/core/backlink.d.ts +43 -0
  9. package/dist/core/escape.d.ts +2 -0
  10. package/dist/core/headers.d.ts +34 -0
  11. package/dist/core/html.d.ts +27 -0
  12. package/dist/core/index.d.ts +13 -0
  13. package/dist/core/json-ld.d.ts +11 -0
  14. package/dist/core/url.d.ts +2 -0
  15. package/dist/index.d.ts +1 -0
  16. package/dist/index.js +1 -0
  17. package/dist/index.mjs +1 -0
  18. package/dist/next/agent-files.d.ts +2 -0
  19. package/dist/next/alternates.d.ts +4 -0
  20. package/dist/next/backlink.d.ts +5 -0
  21. package/dist/next/headers.d.ts +2 -0
  22. package/dist/next/index.d.ts +14 -0
  23. package/dist/next/index.js +16 -0
  24. package/dist/next/index.mjs +1 -0
  25. package/dist/next/json-ld.d.ts +5 -0
  26. package/dist/next/schema.d.ts +1 -0
  27. package/dist/next/source.d.ts +12 -0
  28. package/dist/next/types.d.ts +1 -0
  29. package/dist/react/agent-files.d.ts +2 -0
  30. package/dist/react/alternates.d.ts +5 -0
  31. package/dist/react/backlink.d.ts +5 -0
  32. package/dist/react/headers.d.ts +2 -0
  33. package/dist/react/html.d.ts +2 -0
  34. package/dist/react/index.d.ts +15 -0
  35. package/dist/react/index.js +26 -0
  36. package/dist/react/index.mjs +1 -0
  37. package/dist/react/json-ld.d.ts +5 -0
  38. package/dist/react/schema.d.ts +1 -0
  39. package/dist/react/types.d.ts +1 -0
  40. package/dist/schema.d.ts +1183 -0
  41. package/dist/types.d.ts +75 -0
  42. package/dist/vite/index.d.ts +2 -0
  43. package/dist/vite/index.js +32 -0
  44. package/dist/vite/index.mjs +7 -0
  45. package/dist/vite/plugin.d.ts +51 -0
  46. package/docs/nextjs/01-app-router.md +101 -0
  47. package/docs/nextjs/02-app-router-i18n.md +166 -0
  48. package/docs/nextjs/03-pages-router.md +127 -0
  49. package/docs/nextjs/04-metadata-and-csp.md +113 -0
  50. package/docs/nextjs/05-performance-checklist.md +67 -0
  51. package/docs/nextjs/06-backlink-component.md +226 -0
  52. package/docs/nextjs/07-validator.md +55 -0
  53. package/docs/nextjs/08-server-headers.md +122 -0
  54. package/docs/nextjs/09-llms-and-humans-txt.md +163 -0
  55. package/docs/react/01-ssr-setup.md +112 -0
  56. package/docs/react/02-csr-vite.md +122 -0
  57. package/docs/react/03-i18n.md +104 -0
  58. package/docs/react/04-metadata-and-csp.md +105 -0
  59. package/docs/react/05-backlink-component.md +94 -0
  60. package/docs/react/06-server-headers.md +150 -0
  61. package/docs/react/07-agent-files.md +136 -0
  62. package/docs/react/08-validator.md +56 -0
  63. package/docs/react/09-performance-checklist.md +76 -0
  64. package/package.json +72 -4
  65. package/scripts/backlink.test.mjs +178 -0
  66. package/scripts/check-devalon-credits.mjs +175 -0
@@ -0,0 +1,175 @@
1
+ #!/usr/bin/env node
2
+
3
+ const [, , rawUrl, ...flags] = process.argv;
4
+ const checkDeployed = flags.includes("--deployed");
5
+
6
+ function fail(message) {
7
+ console.error(` ✗ ${message}`);
8
+ process.exitCode = 1;
9
+ }
10
+
11
+ function ok(message) {
12
+ console.log(` ✓ ${message}`);
13
+ }
14
+
15
+ function warn(message) {
16
+ console.log(` ! ${message}`);
17
+ }
18
+
19
+ async function get(url) {
20
+ return fetch(url, {
21
+ redirect: "follow",
22
+ signal: AbortSignal.timeout(10000),
23
+ });
24
+ }
25
+
26
+ if (!rawUrl) {
27
+ console.error("Usage: devalon-check <https://client.com> [--deployed]");
28
+ process.exit(1);
29
+ }
30
+
31
+ let target;
32
+
33
+ try {
34
+ target = new URL(rawUrl);
35
+ } catch {
36
+ console.error(`Invalid URL: ${rawUrl}`);
37
+ process.exit(1);
38
+ }
39
+
40
+ if (target.protocol !== "https:" && target.protocol !== "http:") {
41
+ console.error("The URL must use http or https.");
42
+ process.exit(1);
43
+ }
44
+
45
+ const base = target.origin;
46
+ console.log(`\nChecking ${target.toString()}\n`);
47
+
48
+ let html = "";
49
+ let response;
50
+
51
+ try {
52
+ response = await get(target);
53
+ } catch (error) {
54
+ fail(`Could not fetch the site: ${error.message}`);
55
+ process.exit(1);
56
+ }
57
+
58
+ if (!response.ok) {
59
+ fail(`HTTP ${response.status} ${response.statusText}`);
60
+ } else {
61
+ ok(`HTTP ${response.status}`);
62
+ }
63
+
64
+ if (response.ok) {
65
+ html = await response.text();
66
+ const robotTags = html.match(/<meta\b[^>]*>/gi) ?? [];
67
+ const noindex = robotTags.some((tag) => {
68
+ const isRobotTag = /name=["'](?:robots|googlebot)["']/i.test(tag);
69
+ const hasNoindex = /content=["'][^"']*\bnoindex\b/i.test(tag);
70
+ return isRobotTag && hasNoindex;
71
+ });
72
+
73
+ if (noindex) {
74
+ fail("Page has <meta robots> noindex: search engines will not index this credit link.");
75
+ } else {
76
+ ok("No robots noindex meta tag");
77
+ }
78
+ }
79
+
80
+ try {
81
+ const robotsResponse = await get(`${base}/robots.txt`);
82
+ const robotsText = robotsResponse.ok ? await robotsResponse.text() : "";
83
+ const blocks = robotsText.split(/user-agent:\s*/i).slice(1);
84
+ const blocksAllAgents = blocks.filter((block) => /^\s*\*/i.test(block));
85
+ const blocksAll = blocksAllAgents.some((block) =>
86
+ /^disallow:\s*\/\s*$/im.test(block),
87
+ );
88
+
89
+ if (blocksAll) {
90
+ fail("robots.txt disallows / for all user agents.");
91
+ } else {
92
+ ok("robots.txt does not block the whole site");
93
+ }
94
+ } catch (error) {
95
+ warn(`robots.txt could not be checked: ${error.message}`);
96
+ }
97
+
98
+ try {
99
+ const sitemapResponse = await get(`${base}/sitemap.xml`);
100
+ const sitemapText = sitemapResponse.ok ? await sitemapResponse.text() : "";
101
+
102
+ if (sitemapResponse.ok && /<urlset|<sitemapindex/i.test(sitemapText)) {
103
+ ok("sitemap.xml found");
104
+ } else {
105
+ warn("No sitemap.xml found at the root — add one so the credit page is discovered.");
106
+ }
107
+ } catch (error) {
108
+ warn(`sitemap.xml could not be checked: ${error.message}`);
109
+ }
110
+
111
+ if (checkDeployed) {
112
+ if (/https?:\/\/devalon\.dev/i.test(html)) {
113
+ ok("Devalon credit link found in the rendered HTML");
114
+ } else {
115
+ fail("No devalon.dev link found in the rendered HTML — the credit is not deployed.");
116
+ }
117
+
118
+ if (/application\/ld\+json/i.test(html)) {
119
+ ok("JSON-LD script found in the rendered HTML");
120
+ } else {
121
+ fail("No JSON-LD script found in the rendered HTML.");
122
+ }
123
+
124
+ if (response.headers.get("x-devalon-creator") === "Devalon") {
125
+ ok("X-Devalon-Creator header present");
126
+ } else {
127
+ warn("X-Devalon-Creator header missing — the server headers utility is not active.");
128
+ }
129
+
130
+ if (response.headers.get("x-devalon-project")) {
131
+ ok("X-Devalon-Project header present");
132
+ } else {
133
+ warn("X-Devalon-Project header missing.");
134
+ }
135
+
136
+ const builtBy = response.headers.get("x-built-by");
137
+
138
+ if (builtBy && /Devalon/i.test(builtBy)) {
139
+ ok("X-Built-By header present");
140
+ } else {
141
+ warn("X-Built-By header missing.");
142
+ }
143
+
144
+ const linkHeader = response.headers.get("link") ?? "";
145
+
146
+ if (/devalon\.dev/i.test(linkHeader) && /rel\s*=\s*"?author"?/i.test(linkHeader)) {
147
+ ok("Link rel=author points to Devalon");
148
+ } else {
149
+ warn("Link rel=author header missing.");
150
+ }
151
+
152
+ try {
153
+ const llmsResponse = await get(new URL("/llms.txt", base));
154
+
155
+ if (llmsResponse.ok) {
156
+ const llmsText = await llmsResponse.text();
157
+
158
+ if (/devalon\.dev/i.test(llmsText)) {
159
+ ok("/llms.txt mentions Devalon");
160
+ } else {
161
+ warn("/llms.txt exists but does not mention Devalon.");
162
+ }
163
+ } else {
164
+ warn("No /llms.txt found.");
165
+ }
166
+ } catch (error) {
167
+ warn(`/llms.txt could not be checked: ${error.message}`);
168
+ }
169
+ }
170
+
171
+ if (process.exitCode === 1) {
172
+ console.error("\nFix the errors above before deploying the credit link.\n");
173
+ } else {
174
+ console.log("\nReady for the credit link.\n");
175
+ }