@evertondgn/solid-tooling 0.5.0 → 0.7.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 +543 -598
- package/app-env.d.ts +7 -0
- package/dist/architecture-plugin.mjs +1 -1
- package/dist/backend-plugin.mjs +139 -4
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +42 -0
- package/dist/{constants-Jqvtbvxu.mjs → constants-BZJm7ouk.mjs} +1 -1
- package/dist/css-filename-CEHQd2gz.mjs +40 -0
- package/dist/css-filename.mjs +1 -40
- package/dist/fmt-9dlUYOMk.mjs +34 -0
- package/dist/fmt.mjs +1 -34
- package/dist/i18n-generate.d.mts +1 -0
- package/dist/i18n-generate.mjs +23 -0
- package/dist/i18nPlugin-CS7Gob6R.mjs +109 -0
- package/dist/knip.d.mts +2 -1
- package/dist/knip.mjs +7 -2
- package/dist/{lint-UTfyg7AR.mjs → lint-ehdtTKfw.mjs} +33 -86
- package/dist/lint.mjs +1 -1
- package/dist/playwright-teardown.mjs +1 -1
- package/dist/playwright.d.mts +2 -1
- package/dist/playwright.mjs +4 -3
- package/dist/prepareMessages-BXmY6Ko2.mjs +222 -0
- package/dist/project-plugin.mjs +2 -2
- package/dist/protocol-DSNNUYja.mjs +18 -0
- package/dist/publication/read-llms-index.d.mts +12 -0
- package/dist/publication/read-llms-index.mjs +1 -0
- package/dist/publication-CRUTOB0B.mjs +885 -0
- package/dist/readLlmsIndex-Gj4iTxAk.mjs +27 -0
- package/dist/stylelint.mjs +2 -2
- package/dist/test-locale--tuH0Np5.mjs +3 -0
- package/dist/types-DHu2Z_ot.d.mts +49 -0
- package/dist/vite.d.mts +33 -7
- package/dist/vite.mjs +449 -88
- package/dist/vitest-BjLr7iLf.mjs +362 -0
- package/dist/vitest.d.mts +3 -7
- package/dist/vitest.mjs +1 -129
- package/lefthook.yml +3 -1
- package/node-env.d.ts +1 -0
- package/package.json +32 -39
- package/tsconfig.app.json +4 -9
- package/virtual-modules.d.ts +90 -0
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import { c as MAX_HTML_BYTES, i as LLMS_MAX_BYTES, l as MAX_MARKDOWN_BYTES, n as LLMS_FULL_MAX_BYTES, s as MARKDOWN_TIMEOUT_MS } from "./protocol-DSNNUYja.mjs";
|
|
2
|
+
import { t as TEST_LOCALE } from "./test-locale--tuH0Np5.mjs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { env } from "node:process";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { readFile, realpath } from "node:fs/promises";
|
|
7
|
+
import { loadEnv } from "vite-plus";
|
|
8
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
9
|
+
import * as v from "valibot";
|
|
10
|
+
import { playwright } from "vite-plus/test/browser-playwright";
|
|
11
|
+
// src/has-i18n.ts
|
|
12
|
+
const I18N_SETTINGS = "project.inlang/settings.json";
|
|
13
|
+
function hasI18n(root) {
|
|
14
|
+
return existsSync(path.join(root, I18N_SETTINGS));
|
|
15
|
+
}
|
|
16
|
+
// src/publication/options.ts
|
|
17
|
+
const BudgetSchema = v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(Number.MAX_SAFE_INTEGER));
|
|
18
|
+
const TimeoutSchema = v.pipe(BudgetSchema, v.maxValue(2147483647));
|
|
19
|
+
const MarkdownSchema = v.strictObject({
|
|
20
|
+
static: v.optional(v.boolean(), false),
|
|
21
|
+
maxInputBytes: v.optional(BudgetSchema, MAX_HTML_BYTES),
|
|
22
|
+
maxOutputBytes: v.optional(BudgetSchema, MAX_MARKDOWN_BYTES),
|
|
23
|
+
timeoutMs: v.optional(TimeoutSchema, MARKDOWN_TIMEOUT_MS)
|
|
24
|
+
});
|
|
25
|
+
const LlmsSchema = v.strictObject({ maxBytes: v.optional(BudgetSchema, LLMS_MAX_BYTES) });
|
|
26
|
+
const LlmsFullSchema = v.strictObject({ maxBytes: v.optional(BudgetSchema, LLMS_FULL_MAX_BYTES) });
|
|
27
|
+
const SitemapSchema = v.union([v.boolean(), v.strictObject({ static: v.literal(true) })]);
|
|
28
|
+
function validatePublicationFeatures(options) {
|
|
29
|
+
if (typeof options.llmsFull === "object" && (typeof options.llms !== "object" || typeof options.markdown !== "object" || options.markdown.static !== true)) throw new Error("seo.llmsFull requires seo.llms and seo.markdown.static");
|
|
30
|
+
}
|
|
31
|
+
// src/locale-module.ts
|
|
32
|
+
const MODULE_ID = "virtual:solid-app/locale";
|
|
33
|
+
const RESOLVED_ID = "\0solid-app:locale";
|
|
34
|
+
function localeRequestSource({ root }) {
|
|
35
|
+
if (hasI18n(root)) return `export { shouldRedirect, extractLocaleFromRequest, cookieName, cookieMaxAge, cookieDomain, cookieSameSite, cookieSecure } from ${JSON.stringify(path.join(root, "paraglide/runtime.js"))}; export { paraglideMiddleware } from ${JSON.stringify(path.join(root, "paraglide/server.js"))}`;
|
|
36
|
+
return `const missing = () => { throw new Error('Locale requests require project.inlang/settings.json') }; export { missing as shouldRedirect, missing as extractLocaleFromRequest, missing as paraglideMiddleware }; export const cookieName = '', cookieMaxAge = 0, cookieDomain = '', cookieSameSite = 'lax', cookieSecure = false`;
|
|
37
|
+
}
|
|
38
|
+
function localeSource({ root, language = "en" }) {
|
|
39
|
+
if (hasI18n(root)) return `export { locales, baseLocale, getLocale, setLocale, extractLocaleFromUrl, localizeHref, deLocalizeUrl } from ${JSON.stringify(path.join(root, "paraglide/runtime.js"))}`;
|
|
40
|
+
return `export const baseLocale = ${JSON.stringify(language)}
|
|
41
|
+
export const locales = [baseLocale]
|
|
42
|
+
export const getLocale = () => baseLocale
|
|
43
|
+
export const setLocale = () => undefined
|
|
44
|
+
export const extractLocaleFromUrl = () => undefined
|
|
45
|
+
export const localizeHref = href => href
|
|
46
|
+
export const deLocalizeUrl = url => url instanceof URL ? url : new URL(typeof url === 'string' ? url : url.href)
|
|
47
|
+
`;
|
|
48
|
+
}
|
|
49
|
+
function localeModule(options) {
|
|
50
|
+
return {
|
|
51
|
+
name: "solid-app:locale",
|
|
52
|
+
resolveId: (id) => {
|
|
53
|
+
if (id === "virtual:solid-app/locale-context") return "\0solid-app:locale-context";
|
|
54
|
+
if (id === "virtual:solid-app/request-middleware") return "\0solid-app:request-middleware";
|
|
55
|
+
if (id === "virtual:solid-app/locale-request") return "\0solid-app:locale-request";
|
|
56
|
+
return id === MODULE_ID ? RESOLVED_ID : void 0;
|
|
57
|
+
},
|
|
58
|
+
load: (id) => {
|
|
59
|
+
if (id === "\0solid-app:locale-context") {
|
|
60
|
+
if (!hasI18n(options.root)) return `export const requestLocale = () => ${JSON.stringify(options.language ?? "en")}; export const withLocaleContext = ({run}) => Promise.resolve().then(run)`;
|
|
61
|
+
return `import { extractLocaleFromRequest } from ${JSON.stringify(path.join(options.root, "paraglide/runtime.js"))}; import { paraglideMiddleware } from ${JSON.stringify(path.join(options.root, "paraglide/server.js"))}; export const requestLocale = extractLocaleFromRequest; export const withLocaleContext = ({url, run}) => paraglideMiddleware(new Request(url), run)`;
|
|
62
|
+
}
|
|
63
|
+
if (id === "\0solid-app:request-middleware") return hasI18n(options.root) ? "export { createLocalizeRequest as createRequestLocale } from '@evertondgn/solid-runtime/middleware/localize-request'" : "export const createRequestLocale = () => ({ next }) => next()";
|
|
64
|
+
if (id === "\0solid-app:locale-request") return localeRequestSource(options);
|
|
65
|
+
return id === RESOLVED_ID ? localeSource(options) : void 0;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
// src/seo-module.ts
|
|
70
|
+
const LineSchema = v.pipe(v.string(), v.nonEmpty(), v.regex(/^[^\r\n]+$/u));
|
|
71
|
+
const GroupSchema = v.strictObject({
|
|
72
|
+
userAgents: v.array(LineSchema),
|
|
73
|
+
allow: v.optional(v.array(LineSchema)),
|
|
74
|
+
disallow: v.optional(v.array(LineSchema))
|
|
75
|
+
});
|
|
76
|
+
const RobotsSchema = v.strictObject({
|
|
77
|
+
groups: v.optional(v.array(GroupSchema), []),
|
|
78
|
+
sitemapPaths: v.optional(v.array(LineSchema), []),
|
|
79
|
+
cacheControl: v.optional(LineSchema)
|
|
80
|
+
});
|
|
81
|
+
const RobotsOptionSchema = v.union([v.literal(false), RobotsSchema]);
|
|
82
|
+
const DisabledSchema = v.literal(false);
|
|
83
|
+
const MarkdownOptionSchema = v.union([DisabledSchema, MarkdownSchema]);
|
|
84
|
+
const LlmsOptionSchema = v.union([DisabledSchema, LlmsSchema]);
|
|
85
|
+
const LlmsFullOptionSchema = v.union([DisabledSchema, LlmsFullSchema]);
|
|
86
|
+
const SeoSchema = v.strictObject({
|
|
87
|
+
originEnv: v.optional(LineSchema, "VITE_SITE_URL"),
|
|
88
|
+
robots: v.optional(RobotsOptionSchema),
|
|
89
|
+
sitemap: v.optional(SitemapSchema),
|
|
90
|
+
markdown: v.optional(MarkdownOptionSchema),
|
|
91
|
+
llms: v.optional(LlmsOptionSchema),
|
|
92
|
+
llmsFull: v.optional(LlmsFullOptionSchema)
|
|
93
|
+
});
|
|
94
|
+
function readOrigin({ root, mode, key }) {
|
|
95
|
+
const value = loadEnv(mode, root, key)[key];
|
|
96
|
+
if (!value) throw new Error(`Missing site origin: ${key}`);
|
|
97
|
+
let origin;
|
|
98
|
+
try {
|
|
99
|
+
origin = new URL(value);
|
|
100
|
+
} catch {
|
|
101
|
+
throw new Error(`${key} must be an HTTP(S) origin without a path, query, fragment or credentials`);
|
|
102
|
+
}
|
|
103
|
+
if (!["http:", "https:"].includes(origin.protocol) || origin.pathname !== "/" || origin.search || origin.hash || origin.username || origin.password) throw new Error(`${key} must be an HTTP(S) origin without a path, query, fragment or credentials`);
|
|
104
|
+
return origin.origin;
|
|
105
|
+
}
|
|
106
|
+
function seoModule({ root, mode, seo }) {
|
|
107
|
+
const config = v.parse(SeoSchema, seo === false ? {} : seo ?? {});
|
|
108
|
+
validatePublicationFeatures(config);
|
|
109
|
+
const origin = () => readOrigin({
|
|
110
|
+
root,
|
|
111
|
+
mode,
|
|
112
|
+
key: config.originEnv
|
|
113
|
+
});
|
|
114
|
+
return {
|
|
115
|
+
name: "solid-app:seo",
|
|
116
|
+
configResolved() {
|
|
117
|
+
if (seo !== false && seo !== void 0) origin();
|
|
118
|
+
},
|
|
119
|
+
resolveId: (id) => [
|
|
120
|
+
"virtual:solid-app/seo-origin",
|
|
121
|
+
"virtual:solid-app/seo-robots",
|
|
122
|
+
"virtual:solid-app/seo-markdown",
|
|
123
|
+
"virtual:solid-app/seo-llms"
|
|
124
|
+
].includes(id) ? `\0${id}` : void 0,
|
|
125
|
+
load: (id) => {
|
|
126
|
+
if (id === "\0virtual:solid-app/seo-markdown") {
|
|
127
|
+
if (typeof config.markdown !== "object") throw new TypeError("Markdown requires seo.markdown");
|
|
128
|
+
return `export const markdown = ${JSON.stringify({
|
|
129
|
+
...config.markdown,
|
|
130
|
+
hasLlms: Boolean(config.llms)
|
|
131
|
+
})}`;
|
|
132
|
+
}
|
|
133
|
+
if (id === "\0virtual:solid-app/seo-llms") {
|
|
134
|
+
if (typeof config.llms !== "object") throw new TypeError("llms requires seo.llms");
|
|
135
|
+
return `export const llms = ${JSON.stringify({
|
|
136
|
+
...config.llms,
|
|
137
|
+
hasMarkdown: Boolean(config.markdown),
|
|
138
|
+
hasLlmsFull: Boolean(config.llmsFull)
|
|
139
|
+
})}`;
|
|
140
|
+
}
|
|
141
|
+
if (id === "\0virtual:solid-app/seo-origin") return `export const origin = ${JSON.stringify(origin())}`;
|
|
142
|
+
if (id !== "\0virtual:solid-app/seo-robots") return null;
|
|
143
|
+
if (config.robots === false || config.robots === void 0) throw new Error("The robots route requires defineSolidApp({ seo: { robots: {} } })");
|
|
144
|
+
const { groups, sitemapPaths, cacheControl } = config.robots;
|
|
145
|
+
const siteOrigin = origin();
|
|
146
|
+
return `export const robots = ${JSON.stringify({
|
|
147
|
+
groups,
|
|
148
|
+
sitemaps: sitemapPaths.map((path) => new URL(path, siteOrigin).href),
|
|
149
|
+
cacheControl
|
|
150
|
+
})}`;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
// src/vitest/dom-url.ts
|
|
155
|
+
const ORIGIN = "http://localhost";
|
|
156
|
+
function readBaseLocale(root) {
|
|
157
|
+
let settings;
|
|
158
|
+
try {
|
|
159
|
+
settings = JSON.parse(readFileSync(path.join(root, I18N_SETTINGS), "utf8"));
|
|
160
|
+
} catch (error) {
|
|
161
|
+
throw new Error(`solidTest: cannot read the base locale from ${I18N_SETTINGS}; fix the file or pass domUrl.`, { cause: error });
|
|
162
|
+
}
|
|
163
|
+
const baseLocale = settings !== null && typeof settings === "object" && "baseLocale" in settings ? settings.baseLocale : void 0;
|
|
164
|
+
if (typeof baseLocale !== "string" || baseLocale === "") throw new Error(`solidTest: ${I18N_SETTINGS} must declare baseLocale as a string; fix the file or pass domUrl.`);
|
|
165
|
+
return baseLocale;
|
|
166
|
+
}
|
|
167
|
+
function defaultDomUrl(root) {
|
|
168
|
+
return hasI18n(root) ? `${ORIGIN}/${readBaseLocale(root)}` : `${ORIGIN}/`;
|
|
169
|
+
}
|
|
170
|
+
// src/vitest/source-packages.ts
|
|
171
|
+
function isRecord(value) {
|
|
172
|
+
return typeof value === "object" && value !== null;
|
|
173
|
+
}
|
|
174
|
+
async function findPackage({ root, name }) {
|
|
175
|
+
for (let dir = root;; dir = path.dirname(dir)) {
|
|
176
|
+
const packageDir = path.join(dir, "node_modules", name);
|
|
177
|
+
try {
|
|
178
|
+
const manifest = JSON.parse(await readFile(path.join(packageDir, "package.json"), "utf8"));
|
|
179
|
+
return isRecord(manifest) && isRecord(manifest.exports) ? {
|
|
180
|
+
dir: packageDir,
|
|
181
|
+
exports: manifest.exports
|
|
182
|
+
} : void 0;
|
|
183
|
+
} catch {
|
|
184
|
+
if (path.dirname(dir) === dir) return void 0;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function sourcePackages({ root, packages }) {
|
|
189
|
+
const installed = /* @__PURE__ */ new Map();
|
|
190
|
+
async function resolveSource({ name, source }) {
|
|
191
|
+
let lookup = installed.get(name);
|
|
192
|
+
if (!lookup) {
|
|
193
|
+
lookup = findPackage({
|
|
194
|
+
root,
|
|
195
|
+
name
|
|
196
|
+
});
|
|
197
|
+
installed.set(name, lookup);
|
|
198
|
+
}
|
|
199
|
+
const found = await lookup;
|
|
200
|
+
const entry = found?.exports[`.${source.slice(name.length)}`];
|
|
201
|
+
if (!found || !isRecord(entry) || typeof entry.solid !== "string") return null;
|
|
202
|
+
return realpath(path.join(found.dir, entry.solid));
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
name: "solid-tooling:source-packages",
|
|
206
|
+
enforce: "pre",
|
|
207
|
+
resolveId(source) {
|
|
208
|
+
const name = packages.find((candidate) => source === candidate || source.startsWith(`${candidate}/`));
|
|
209
|
+
return name === void 0 ? null : resolveSource({
|
|
210
|
+
name,
|
|
211
|
+
source
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
// src/vitest/index.ts
|
|
217
|
+
const CI_WORKERS = 2;
|
|
218
|
+
const SOURCE_PACKAGES = ["@evertondgn/solid-runtime"];
|
|
219
|
+
const STUB_PREFIX = "\0solid-tooling-stub:";
|
|
220
|
+
const NODE_STUBS = /* @__PURE__ */ new Map([
|
|
221
|
+
["server-only", "export default undefined"],
|
|
222
|
+
["virtual:file-routes", "export const pageRoutes = []\nexport default []"],
|
|
223
|
+
["virtual:solid-server-function-handler", "export const endpoint = '/_server'"]
|
|
224
|
+
]);
|
|
225
|
+
const TEST_ENV_KEYS = [
|
|
226
|
+
"BASE_URL_TEST",
|
|
227
|
+
"HOST",
|
|
228
|
+
"PORT"
|
|
229
|
+
];
|
|
230
|
+
function packageFile(name) {
|
|
231
|
+
return fileURLToPath(new URL(name, import.meta.url));
|
|
232
|
+
}
|
|
233
|
+
function nodeStubs(source) {
|
|
234
|
+
const stubs = new Map([...NODE_STUBS, ["virtual:solid-app/locale", source]]);
|
|
235
|
+
return {
|
|
236
|
+
name: "solid-tooling:node-stubs",
|
|
237
|
+
enforce: "pre",
|
|
238
|
+
resolveId: (id) => stubs.has(id) ? `${STUB_PREFIX}${id}` : void 0,
|
|
239
|
+
load: (id) => id.startsWith(STUB_PREFIX) ? stubs.get(id.slice(20)) : void 0
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
function readTestEnv() {
|
|
243
|
+
return Object.fromEntries(TEST_ENV_KEYS.flatMap((key) => {
|
|
244
|
+
const value = env[key];
|
|
245
|
+
return value === void 0 ? [] : [[key, value]];
|
|
246
|
+
}));
|
|
247
|
+
}
|
|
248
|
+
function solidTest({ root, language, seo, plugins, sourcePackages: packages = SOURCE_PACKAGES, domUrl = defaultDomUrl(root), locale = TEST_LOCALE }) {
|
|
249
|
+
const hasParaglide = hasI18n(root);
|
|
250
|
+
return {
|
|
251
|
+
pool: "threads",
|
|
252
|
+
maxWorkers: env.CI ? CI_WORKERS : void 0,
|
|
253
|
+
css: false,
|
|
254
|
+
globals: true,
|
|
255
|
+
restoreMocks: true,
|
|
256
|
+
unstubGlobals: true,
|
|
257
|
+
unstubEnvs: true,
|
|
258
|
+
expect: {
|
|
259
|
+
requireAssertions: true,
|
|
260
|
+
poll: { interval: 10 }
|
|
261
|
+
},
|
|
262
|
+
env: readTestEnv(),
|
|
263
|
+
coverage: {
|
|
264
|
+
provider: "v8",
|
|
265
|
+
reporter: ["text", "html"],
|
|
266
|
+
thresholds: {
|
|
267
|
+
lines: 80,
|
|
268
|
+
functions: 80,
|
|
269
|
+
branches: 75,
|
|
270
|
+
statements: 80
|
|
271
|
+
},
|
|
272
|
+
include: ["src/**/*.{ts,tsx}"],
|
|
273
|
+
exclude: [
|
|
274
|
+
"src/**/*.d.ts",
|
|
275
|
+
"src/**/{constants,types,@types}/**",
|
|
276
|
+
"src/**/{constants,types}.{ts,tsx}",
|
|
277
|
+
"src/**/__tests__/**",
|
|
278
|
+
"src/tests/**",
|
|
279
|
+
"src/App.tsx",
|
|
280
|
+
"src/Document.tsx",
|
|
281
|
+
"src/entry-server.tsx",
|
|
282
|
+
"src/entry-client.tsx",
|
|
283
|
+
"src/router.ts"
|
|
284
|
+
]
|
|
285
|
+
},
|
|
286
|
+
reporters: env.GITHUB_ACTIONS ? ["default", "github-actions"] : ["verbose"],
|
|
287
|
+
projects: [
|
|
288
|
+
{
|
|
289
|
+
plugins: [
|
|
290
|
+
nodeStubs(localeSource({
|
|
291
|
+
root,
|
|
292
|
+
language
|
|
293
|
+
})),
|
|
294
|
+
localeModule({
|
|
295
|
+
root,
|
|
296
|
+
language
|
|
297
|
+
}),
|
|
298
|
+
seoModule({
|
|
299
|
+
root,
|
|
300
|
+
mode: "test",
|
|
301
|
+
seo
|
|
302
|
+
}),
|
|
303
|
+
sourcePackages({
|
|
304
|
+
root,
|
|
305
|
+
packages
|
|
306
|
+
})
|
|
307
|
+
],
|
|
308
|
+
test: {
|
|
309
|
+
name: {
|
|
310
|
+
label: "node",
|
|
311
|
+
color: "cyan"
|
|
312
|
+
},
|
|
313
|
+
environment: "node",
|
|
314
|
+
include: ["src/**/*.node.test.{ts,tsx}"]
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
plugins: plugins(),
|
|
319
|
+
test: {
|
|
320
|
+
name: {
|
|
321
|
+
label: "dom",
|
|
322
|
+
color: "magenta"
|
|
323
|
+
},
|
|
324
|
+
environment: "happy-dom",
|
|
325
|
+
setupFiles: [fileURLToPath(import.meta.resolve("@testing-library/jest-dom/vitest"))],
|
|
326
|
+
environmentOptions: { happyDOM: { url: domUrl } },
|
|
327
|
+
include: ["src/**/*.dom.test.{ts,tsx}"]
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
plugins: plugins(),
|
|
332
|
+
...hasParaglide && { resolve: { alias: [{
|
|
333
|
+
find: /^@paraglide\//u,
|
|
334
|
+
replacement: `${path.join(root, "paraglide")}/`
|
|
335
|
+
}] } },
|
|
336
|
+
test: {
|
|
337
|
+
css: true,
|
|
338
|
+
name: {
|
|
339
|
+
label: "browser",
|
|
340
|
+
color: "yellow"
|
|
341
|
+
},
|
|
342
|
+
setupFiles: hasParaglide ? [packageFile("vitest-setup/browser.mjs")] : [],
|
|
343
|
+
include: ["src/**/*.browser.test.{ts,tsx}"],
|
|
344
|
+
browser: {
|
|
345
|
+
enabled: true,
|
|
346
|
+
headless: true,
|
|
347
|
+
trace: {
|
|
348
|
+
mode: "retain-on-failure",
|
|
349
|
+
tracesDir: path.join(root, "test-results/browser-traces")
|
|
350
|
+
},
|
|
351
|
+
provider: playwright({
|
|
352
|
+
contextOptions: { locale },
|
|
353
|
+
launchOptions: env.CI ? { channel: "chrome" } : {}
|
|
354
|
+
}),
|
|
355
|
+
instances: [{ browser: "chromium" }]
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
]
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
export { I18N_SETTINGS as a, validatePublicationFeatures as i, seoModule as n, hasI18n as o, localeModule as r, solidTest as t };
|
package/dist/vitest.d.mts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
plugins: () => ViteUserConfig['plugins'];
|
|
5
|
-
};
|
|
6
|
-
export declare function solidTest({ root, plugins }: SolidTestOptions): TestUserConfig;
|
|
7
|
-
export {};
|
|
1
|
+
import { t as SolidTestOptions } from "./types-DHu2Z_ot.mjs";
|
|
2
|
+
import { TestUserConfig } from "vite-plus";
|
|
3
|
+
export declare function solidTest({ root, language, seo, plugins, sourcePackages: packages, domUrl, locale }: SolidTestOptions): TestUserConfig;
|
package/dist/vitest.mjs
CHANGED
|
@@ -1,129 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { env } from "node:process";
|
|
4
|
-
import { playwright } from "vite-plus/test/browser-playwright";
|
|
5
|
-
// src/vitest/index.ts
|
|
6
|
-
const CI_WORKERS = 2;
|
|
7
|
-
const STUB_PREFIX = "\0solid-tooling-stub:";
|
|
8
|
-
const NODE_STUBS = /* @__PURE__ */ new Map([
|
|
9
|
-
["server-only", "export default undefined"],
|
|
10
|
-
["virtual:file-routes", "export const pageRoutes = []\nexport default []"],
|
|
11
|
-
["virtual:solid-server-function-handler", "export const endpoint = '/_server'"]
|
|
12
|
-
]);
|
|
13
|
-
const TEST_ENV_KEYS = [
|
|
14
|
-
"BASE_URL_TEST",
|
|
15
|
-
"HOST",
|
|
16
|
-
"PORT"
|
|
17
|
-
];
|
|
18
|
-
function packageFile(name) {
|
|
19
|
-
return fileURLToPath(new URL(name, import.meta.url));
|
|
20
|
-
}
|
|
21
|
-
function nodeStubs() {
|
|
22
|
-
return {
|
|
23
|
-
name: "solid-tooling:node-stubs",
|
|
24
|
-
enforce: "pre",
|
|
25
|
-
resolveId: (id) => NODE_STUBS.has(id) ? `${STUB_PREFIX}${id}` : void 0,
|
|
26
|
-
load: (id) => id.startsWith(STUB_PREFIX) ? NODE_STUBS.get(id.slice(20)) : void 0
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function readTestEnv() {
|
|
30
|
-
return Object.fromEntries(TEST_ENV_KEYS.flatMap((key) => {
|
|
31
|
-
const value = env[key];
|
|
32
|
-
return value === void 0 ? [] : [[key, value]];
|
|
33
|
-
}));
|
|
34
|
-
}
|
|
35
|
-
function solidTest({ root, plugins }) {
|
|
36
|
-
return {
|
|
37
|
-
pool: "threads",
|
|
38
|
-
maxWorkers: env.CI ? CI_WORKERS : void 0,
|
|
39
|
-
css: false,
|
|
40
|
-
globals: true,
|
|
41
|
-
restoreMocks: true,
|
|
42
|
-
unstubGlobals: true,
|
|
43
|
-
unstubEnvs: true,
|
|
44
|
-
expect: {
|
|
45
|
-
requireAssertions: true,
|
|
46
|
-
poll: { interval: 10 }
|
|
47
|
-
},
|
|
48
|
-
env: readTestEnv(),
|
|
49
|
-
coverage: {
|
|
50
|
-
provider: "v8",
|
|
51
|
-
reporter: ["text", "html"],
|
|
52
|
-
thresholds: {
|
|
53
|
-
lines: 80,
|
|
54
|
-
functions: 80,
|
|
55
|
-
branches: 75,
|
|
56
|
-
statements: 80
|
|
57
|
-
},
|
|
58
|
-
include: ["src/**/*.{ts,tsx}"],
|
|
59
|
-
exclude: [
|
|
60
|
-
"src/**/*.d.ts",
|
|
61
|
-
"src/**/{constants,types,@types}/**",
|
|
62
|
-
"src/**/{constants,types}.{ts,tsx}",
|
|
63
|
-
"src/**/__tests__/**",
|
|
64
|
-
"src/tests/**",
|
|
65
|
-
"src/App.tsx",
|
|
66
|
-
"src/Document.tsx",
|
|
67
|
-
"src/entry-server.tsx",
|
|
68
|
-
"src/entry-client.tsx",
|
|
69
|
-
"src/router.ts"
|
|
70
|
-
]
|
|
71
|
-
},
|
|
72
|
-
reporters: env.GITHUB_ACTIONS ? ["default", "github-actions"] : ["verbose"],
|
|
73
|
-
projects: [
|
|
74
|
-
{
|
|
75
|
-
plugins: [nodeStubs()],
|
|
76
|
-
test: {
|
|
77
|
-
name: {
|
|
78
|
-
label: "node",
|
|
79
|
-
color: "cyan"
|
|
80
|
-
},
|
|
81
|
-
environment: "node",
|
|
82
|
-
include: ["src/**/*.node.test.{ts,tsx}"]
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
plugins: plugins(),
|
|
87
|
-
test: {
|
|
88
|
-
name: {
|
|
89
|
-
label: "dom",
|
|
90
|
-
color: "magenta"
|
|
91
|
-
},
|
|
92
|
-
environment: "happy-dom",
|
|
93
|
-
environmentOptions: { happyDOM: { url: "http://localhost/en" } },
|
|
94
|
-
include: ["src/**/*.dom.test.{ts,tsx}"]
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
plugins: plugins(),
|
|
99
|
-
resolve: { alias: [{
|
|
100
|
-
find: /^@paraglide\//u,
|
|
101
|
-
replacement: `${path.join(root, "paraglide")}/`
|
|
102
|
-
}] },
|
|
103
|
-
test: {
|
|
104
|
-
css: true,
|
|
105
|
-
name: {
|
|
106
|
-
label: "browser",
|
|
107
|
-
color: "yellow"
|
|
108
|
-
},
|
|
109
|
-
setupFiles: [packageFile("vitest-setup/browser.mjs")],
|
|
110
|
-
include: ["src/**/*.browser.test.{ts,tsx}"],
|
|
111
|
-
browser: {
|
|
112
|
-
enabled: true,
|
|
113
|
-
headless: true,
|
|
114
|
-
trace: {
|
|
115
|
-
mode: "retain-on-failure",
|
|
116
|
-
tracesDir: path.join(root, "test-results/browser-traces")
|
|
117
|
-
},
|
|
118
|
-
provider: playwright({
|
|
119
|
-
contextOptions: { locale: "en-US" },
|
|
120
|
-
launchOptions: env.CI ? { channel: "chrome" } : {}
|
|
121
|
-
}),
|
|
122
|
-
instances: [{ browser: "chromium" }]
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
]
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
export { solidTest };
|
|
1
|
+
export { t as solidTest } from "./vitest-BjLr7iLf.mjs";
|
package/lefthook.yml
CHANGED
package/node-env.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="node" />
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evertondgn/solid-tooling",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Lint, formatter, TypeScript, test and Vite app presets for SolidJS applications built with Vite+.",
|
|
5
5
|
"author": "Éverton Toffanetto",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,19 +35,25 @@
|
|
|
35
35
|
"dist",
|
|
36
36
|
"tsconfig.base.json",
|
|
37
37
|
"tsconfig.app.json",
|
|
38
|
-
"
|
|
38
|
+
"virtual-modules.d.ts",
|
|
39
|
+
"lefthook.yml",
|
|
40
|
+
"app-env.d.ts",
|
|
41
|
+
"node-env.d.ts"
|
|
39
42
|
],
|
|
40
43
|
"exports": {
|
|
41
44
|
"./architecture-plugin": "./dist/architecture-plugin.mjs",
|
|
42
45
|
"./backend-plugin": "./dist/backend-plugin.mjs",
|
|
46
|
+
"./cli": "./dist/cli.mjs",
|
|
43
47
|
"./commitlint": "./dist/commitlint.mjs",
|
|
44
48
|
"./css-filename": "./dist/css-filename.mjs",
|
|
45
49
|
"./fmt": "./dist/fmt.mjs",
|
|
50
|
+
"./i18n-generate": "./dist/i18n-generate.mjs",
|
|
46
51
|
"./knip": "./dist/knip.mjs",
|
|
47
52
|
"./lint": "./dist/lint.mjs",
|
|
48
53
|
"./playwright": "./dist/playwright.mjs",
|
|
49
54
|
"./playwright-teardown": "./dist/playwright-teardown.mjs",
|
|
50
55
|
"./project-plugin": "./dist/project-plugin.mjs",
|
|
56
|
+
"./publication/read-llms-index": "./dist/publication/read-llms-index.mjs",
|
|
51
57
|
"./solid-plugin": "./dist/solid-plugin.mjs",
|
|
52
58
|
"./stylelint": "./dist/stylelint.mjs",
|
|
53
59
|
"./vite": "./dist/vite.mjs",
|
|
@@ -56,6 +62,12 @@
|
|
|
56
62
|
"./package.json": "./package.json",
|
|
57
63
|
"./tsconfig.base.json": "./tsconfig.base.json",
|
|
58
64
|
"./tsconfig.app.json": "./tsconfig.app.json",
|
|
65
|
+
"./app-env": {
|
|
66
|
+
"types": "./app-env.d.ts"
|
|
67
|
+
},
|
|
68
|
+
"./virtual-modules": {
|
|
69
|
+
"types": "./virtual-modules.d.ts"
|
|
70
|
+
},
|
|
59
71
|
"./lefthook.yml": "./lefthook.yml"
|
|
60
72
|
},
|
|
61
73
|
"publishConfig": {
|
|
@@ -71,11 +83,9 @@
|
|
|
71
83
|
"@commitlint/config-conventional": "21.2.4",
|
|
72
84
|
"eslint-plugin-solid": "0.19.0",
|
|
73
85
|
"stylelint": "18.0.0",
|
|
74
|
-
"stylelint-use-nesting": "6.0.2"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
"@inlang/paraglide-js": "3.2.2",
|
|
78
|
-
"vite-plus": "1.6.0",
|
|
86
|
+
"stylelint-use-nesting": "6.0.2",
|
|
87
|
+
"@inlang/sdk": "4.2.0",
|
|
88
|
+
"valibot": "1.5.0",
|
|
79
89
|
"@playwright/test": "1.65.0",
|
|
80
90
|
"@solidjs/vite-plugin": "3.0.0-next.57",
|
|
81
91
|
"filesystem-routing": "0.5.0",
|
|
@@ -83,44 +93,27 @@
|
|
|
83
93
|
"nitro": "3.0.261103-rc",
|
|
84
94
|
"unplugin-icons": "24.0.0",
|
|
85
95
|
"@commitlint/cli": "21.2.4",
|
|
86
|
-
"lefthook": "2.2.2"
|
|
96
|
+
"lefthook": "2.2.2",
|
|
97
|
+
"happy-dom": "21.0.4",
|
|
98
|
+
"playwright": "1.65.0",
|
|
99
|
+
"@vitest/browser-playwright": "5.1.0",
|
|
100
|
+
"@vitest/coverage-v8": "5.1.0",
|
|
101
|
+
"@vitest/ui": "5.1.0",
|
|
102
|
+
"@testing-library/jest-dom": "7.0.1",
|
|
103
|
+
"@types/node": "24.19.2",
|
|
104
|
+
"typescript": "7.0.2"
|
|
105
|
+
},
|
|
106
|
+
"peerDependencies": {
|
|
107
|
+
"@inlang/paraglide-js": "3.2.2",
|
|
108
|
+
"vite-plus": "1.6.0"
|
|
87
109
|
},
|
|
88
110
|
"devDependencies": {
|
|
89
111
|
"@inlang/paraglide-js": "3.2.2",
|
|
90
|
-
"@types/node": "24.19.2",
|
|
91
|
-
"typescript": "7.0.2",
|
|
92
|
-
"valibot": "1.5.0",
|
|
93
112
|
"vite-plus": "1.6.0",
|
|
94
|
-
"@
|
|
95
|
-
"@solidjs/vite-plugin": "3.0.0-next.57",
|
|
96
|
-
"filesystem-routing": "0.5.0",
|
|
97
|
-
"knip": "6.45.1",
|
|
98
|
-
"nitro": "3.0.261103-rc",
|
|
99
|
-
"unplugin-icons": "24.0.0"
|
|
113
|
+
"@inlang/plugin-message-format": "4.6.0"
|
|
100
114
|
},
|
|
101
115
|
"peerDependenciesMeta": {
|
|
102
|
-
"@
|
|
103
|
-
"optional": true
|
|
104
|
-
},
|
|
105
|
-
"@playwright/test": {
|
|
106
|
-
"optional": true
|
|
107
|
-
},
|
|
108
|
-
"@solidjs/vite-plugin": {
|
|
109
|
-
"optional": true
|
|
110
|
-
},
|
|
111
|
-
"filesystem-routing": {
|
|
112
|
-
"optional": true
|
|
113
|
-
},
|
|
114
|
-
"knip": {
|
|
115
|
-
"optional": true
|
|
116
|
-
},
|
|
117
|
-
"lefthook": {
|
|
118
|
-
"optional": true
|
|
119
|
-
},
|
|
120
|
-
"nitro": {
|
|
121
|
-
"optional": true
|
|
122
|
-
},
|
|
123
|
-
"unplugin-icons": {
|
|
116
|
+
"@inlang/paraglide-js": {
|
|
124
117
|
"optional": true
|
|
125
118
|
}
|
|
126
119
|
}
|
package/tsconfig.app.json
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "./tsconfig.base.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
"vite/client",
|
|
7
|
-
"vite-plus/test/globals",
|
|
8
|
-
"@testing-library/jest-dom/vitest",
|
|
9
|
-
"@solidjs/vite-plugin/boundary-modules",
|
|
10
|
-
"@solidjs/vite-plugin/virtual-modules"
|
|
11
|
-
]
|
|
4
|
+
"customConditions": ["solid"],
|
|
5
|
+
"types": ["@evertondgn/solid-tooling/app-env"]
|
|
12
6
|
},
|
|
13
7
|
"include": [
|
|
14
8
|
"${configDir}/src",
|
|
@@ -17,5 +11,6 @@
|
|
|
17
11
|
"${configDir}/vite.config.ts",
|
|
18
12
|
"${configDir}/playwright.config.ts",
|
|
19
13
|
"${configDir}/tooling/**/*.ts"
|
|
20
|
-
]
|
|
14
|
+
],
|
|
15
|
+
"files": ["./node-env.d.ts"]
|
|
21
16
|
}
|