@ludoloops/svelteforge 0.1.1 → 0.1.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/dist/index.js +103 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -156,54 +156,127 @@ const fullstackFiles = {
|
|
|
156
156
|
* Apply Landing mode files via sv.file()
|
|
157
157
|
* Landing = UI base kit for building a landing page
|
|
158
158
|
*/
|
|
159
|
+
const UI_SKIP = [
|
|
160
|
+
"AuthCard",
|
|
161
|
+
"DataTable",
|
|
162
|
+
"NavigationLoader",
|
|
163
|
+
"NotificationBadge",
|
|
164
|
+
"SearchInput",
|
|
165
|
+
".test.ts"
|
|
166
|
+
];
|
|
167
|
+
const LAYOUT_SKIP = ["auth-buttons", "AdminSidebar"];
|
|
168
|
+
function shouldSkipUi(name) {
|
|
169
|
+
return UI_SKIP.some((s) => name.startsWith(s) || name.endsWith(s));
|
|
170
|
+
}
|
|
171
|
+
function shouldSkipLayout(name) {
|
|
172
|
+
return LAYOUT_SKIP.some((s) => name.startsWith(s));
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Generate a barrel index.ts that only exports files present in the filtered set
|
|
176
|
+
*/
|
|
177
|
+
function generateBarrel(files, directory, stripExtension = true) {
|
|
178
|
+
const lines = [];
|
|
179
|
+
const sortedPaths = [...files.keys()].filter((p) => p.startsWith(directory)).sort();
|
|
180
|
+
for (const path of sortedPaths) {
|
|
181
|
+
const name = path.split("/").pop() || "";
|
|
182
|
+
if (name === "index.ts" || name.endsWith(".test.ts")) continue;
|
|
183
|
+
const baseName = stripExtension ? name.replace(/\.\w+$/, "") : name;
|
|
184
|
+
if (name.endsWith(".svelte")) {
|
|
185
|
+
const componentName = baseName;
|
|
186
|
+
lines.push(`export { default as ${componentName} } from './${name}';`);
|
|
187
|
+
} else if (name.endsWith(".ts")) lines.push(`export * from './${name}';`);
|
|
188
|
+
}
|
|
189
|
+
return lines.join("\n") + "\n";
|
|
190
|
+
}
|
|
159
191
|
function applyLandingMode(sv, landingFiles, fullstackFiles, projectName) {
|
|
160
|
-
const
|
|
192
|
+
const includedFiles = /* @__PURE__ */ new Map();
|
|
193
|
+
const uiFiles = /* @__PURE__ */ new Map();
|
|
194
|
+
const uiFormFiles = /* @__PURE__ */ new Map();
|
|
195
|
+
const uiRichTextFiles = /* @__PURE__ */ new Map();
|
|
196
|
+
const layoutFiles = /* @__PURE__ */ new Map();
|
|
197
|
+
for (const [path, content] of Object.entries(fullstackFiles)) {
|
|
161
198
|
if (path.startsWith("/lib/components/ui/")) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
"SearchInput",
|
|
169
|
-
".test.ts"
|
|
170
|
-
].some((s) => name.startsWith(s) || name.endsWith(s))) return false;
|
|
171
|
-
return true;
|
|
199
|
+
if (shouldSkipUi(path.split("/").pop() || "")) continue;
|
|
200
|
+
includedFiles.set(path, content);
|
|
201
|
+
if (path.startsWith("/lib/components/ui/form/") && !path.endsWith("index.ts")) uiFormFiles.set(path, content);
|
|
202
|
+
else if (path.startsWith("/lib/components/ui/rich-text/") && !path.endsWith("index.ts")) uiRichTextFiles.set(path, content);
|
|
203
|
+
else if (!path.endsWith("index.ts")) uiFiles.set(path, content);
|
|
204
|
+
continue;
|
|
172
205
|
}
|
|
173
206
|
if (path.startsWith("/lib/components/layout/")) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
207
|
+
if (shouldSkipLayout(path.split("/").pop() || "")) continue;
|
|
208
|
+
includedFiles.set(path, content);
|
|
209
|
+
if (!path.endsWith("index.ts")) layoutFiles.set(path, content);
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
if (path === "/lib/components/ui/index.ts" || path === "/lib/components/ui/form/index.ts" || path === "/lib/components/layout/index.ts" || path === "/lib/components/index.ts") continue;
|
|
213
|
+
if (path.startsWith("/lib/components/icons/")) {
|
|
214
|
+
includedFiles.set(path, content);
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (path.startsWith("/lib/styles/")) {
|
|
218
|
+
includedFiles.set(path, content);
|
|
219
|
+
continue;
|
|
177
220
|
}
|
|
178
|
-
if (path.startsWith("/lib/components/icons/")) return true;
|
|
179
|
-
if (path === "/lib/components/index.ts") return true;
|
|
180
|
-
if (path.startsWith("/lib/components/layout/index.ts")) return true;
|
|
181
|
-
if (path.startsWith("/lib/components/ui/index.ts")) return true;
|
|
182
|
-
if (path.startsWith("/lib/components/ui/form/index.ts")) return true;
|
|
183
|
-
if (path.startsWith("/lib/styles/")) return true;
|
|
184
221
|
if (path.startsWith("/lib/utils/")) {
|
|
185
222
|
const name = path.split("/").pop() || "";
|
|
186
|
-
if (name.endsWith(".test.ts"))
|
|
223
|
+
if (name.endsWith(".test.ts")) continue;
|
|
187
224
|
if ([
|
|
188
225
|
"export.ts",
|
|
189
226
|
"slugify.ts",
|
|
190
227
|
"form-errors.ts"
|
|
191
|
-
].includes(name))
|
|
192
|
-
|
|
228
|
+
].includes(name)) continue;
|
|
229
|
+
includedFiles.set(path, content);
|
|
230
|
+
continue;
|
|
193
231
|
}
|
|
194
232
|
if ([
|
|
195
233
|
"/lib/errors.ts",
|
|
196
234
|
"/lib/logger.ts",
|
|
197
235
|
"/lib/types.ts",
|
|
198
236
|
"/lib/index.ts"
|
|
199
|
-
].includes(path))
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if (path
|
|
204
|
-
|
|
237
|
+
].includes(path)) {
|
|
238
|
+
includedFiles.set(path, content);
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (path.startsWith("/lib/schemas/")) {
|
|
242
|
+
includedFiles.set(path, content);
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
if (["/app.css", "/app.html"].includes(path)) {
|
|
246
|
+
includedFiles.set(path, content);
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
if (path.startsWith("/routes/(legal)/")) {
|
|
250
|
+
includedFiles.set(path, content);
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
if (path === "/routes/+error.svelte") {
|
|
254
|
+
includedFiles.set(path, content);
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
for (const [path, content] of includedFiles) sv.file(`src${path}`, () => content);
|
|
259
|
+
sv.file("src/lib/components/ui/index.ts", () => {
|
|
260
|
+
let barrel = generateBarrel(uiFiles, "/lib/components/ui/");
|
|
261
|
+
if (uiRichTextFiles.size > 0) barrel += "\n// === Rich Text ===\nexport * from './rich-text';\n";
|
|
262
|
+
if (uiFormFiles.size > 0) barrel += "\n// === Form ===\nexport * from './form';\n";
|
|
263
|
+
return barrel;
|
|
264
|
+
});
|
|
265
|
+
sv.file("src/lib/components/ui/form/index.ts", () => {
|
|
266
|
+
const svelteComponents = [];
|
|
267
|
+
const tsFiles = [];
|
|
268
|
+
for (const path of [...uiFormFiles.keys()].sort()) {
|
|
269
|
+
const name = path.split("/").pop() || "";
|
|
270
|
+
if (name.endsWith(".svelte")) svelteComponents.push(name.replace(".svelte", ""));
|
|
271
|
+
else if (name.endsWith(".ts") && name !== "index.ts") tsFiles.push(name);
|
|
272
|
+
}
|
|
273
|
+
let result = `${svelteComponents.map((c) => `import ${c} from './${c}.svelte';`).join("\n")}\n\nexport { ${svelteComponents.join(", ")} };\n`;
|
|
274
|
+
for (const ts of tsFiles) result += `export * from './${ts}';\n`;
|
|
275
|
+
return result;
|
|
276
|
+
});
|
|
277
|
+
sv.file("src/lib/components/layout/index.ts", () => {
|
|
278
|
+
return generateBarrel(layoutFiles, "/lib/components/layout/");
|
|
205
279
|
});
|
|
206
|
-
for (const [path, content] of sharedPaths) sv.file(`src${path}`, () => content);
|
|
207
280
|
for (const [path, content] of Object.entries(landingFiles)) {
|
|
208
281
|
const finalContent = content.replace(/__PROJECT_NAME__/g, projectName);
|
|
209
282
|
sv.file(`src${path}`, () => finalContent);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ludoloops/svelteforge",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "sv community addon — 34 theme-aware UI components, admin dashboard, and 3-layer theme system for SvelteKit",
|
|
6
6
|
"author": "Ludo (https://lelab.dev)",
|