Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stricter npm field validation #484

Merged
merged 13 commits into from
Nov 19, 2023
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"itemsjs": "^2.1.20",
"lint-staged": "^13.2.3",
"mdsvex": "^0.11.0",
"package-name-regex": "^3.0.0",
"prettier": "^2.8.8",
"prettier-plugin-svelte": "^2.10.1",
"rehype-slug": "^5.1.0",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions src/lib/schemas.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { z } from 'zod';
import packageNameRegex from 'package-name-regex';

export const componentsSchema = z.array(
z.object({
title: z.string(),
npm: z
.string()
.regex(/(@[\w-]+\/)?[\w-]+/)
.optional(),
npm: z.string().regex(packageNameRegex),
url: z.string().url().optional(),
repository: z.string().url(),
description: z.string(),
Expand Down Expand Up @@ -46,10 +44,7 @@ export const templatesSchema = z.array(
export const toolsSchema = z.array(
z.object({
title: z.string(),
npm: z
.string()
.regex(/(@[\w-]+\/)?[\w-]+/)
.optional(),
npm: z.string().regex(packageNameRegex).optional(),
url: z.string().url().optional(),
repository: z.string().url(),
description: z.string(),
Expand Down
25 changes: 6 additions & 19 deletions src/routes/components/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"url": "https://svelte.dev/repl/d9616fce34c444d4bcac551cb5bdc0ee?version=3.55.1",
"repository": "https://github.com/dmvvilela/svelte-scrollactive",
"description": "This is a port of vue-scrollactive to Svelte, a lightweight and simple to use component that highlights menu items as you scroll the page, also scrolling to target section when clicked.",
"npm": "https://www.npmjs.com/package/svelte-scrollactive",
"npm": "svelte-scrollactive",
"category": "User Interaction",
"tags": [
"components and libraries",
Expand Down Expand Up @@ -213,7 +213,8 @@
},
{
"title": "SCR Svelte Client Router",
"repository": "https://arthurgermano.github.io/svelte-client-router/#/svelte-client-router",
"url": "https://arthurgermano.github.io/svelte-client-router/#/svelte-client-router",
"repository": "https://github.com/arthurgermano/svelte-client-router",
"npm": "svelte-client-router",
"description": "Svelte Client Router is everything you need and think when routing SPA's. This is The Svelte Router for SPA!",
"tags": ["routers"],
Expand Down Expand Up @@ -1002,13 +1003,6 @@
"title": "layercake",
"repository": "https://github.com/mhkeller/layercake"
},
{
"category": "CSS and Layout",
"description": "resizable layout component for svelte",
"tags": ["components and libraries", "layout and structure"],
"title": "svelte-layout-resizable",
"repository": "https://github.com/milahu/svelte-layout-resizable"
},
lachlancollins marked this conversation as resolved.
Show resolved Hide resolved
{
"category": "CSS and Layout",
"description": "Arrange infinite card elements according to various layout types like masonry",
Expand Down Expand Up @@ -1161,13 +1155,6 @@
"title": "storez",
"repository": "https://github.com/plrenaudin/svelte-storez"
},
{
"category": "Stores",
"description": "Template for client side svelte store",
"tags": ["components and libraries", "stores and state"],
"title": "SvelteStore",
"repository": "https://github.com/gitbreaker222/SvelteStore"
},
lachlancollins marked this conversation as resolved.
Show resolved Hide resolved
{
"category": "Integration",
"description": "Use Svelte components with Vue and React",
Expand Down Expand Up @@ -2168,7 +2155,7 @@
"title": "svelte-currency-input",
"repository": "https://github.com/fmaclen/svelte-currency-input",
"description": "A form input that converts numbers to localized currency formats as you type",
"npm": "svelte-currency-input",
"npm": "@canutin/svelte-currency-input",
"category": "Forms & User Input",
"tags": ["forms", "inputs and widgets", "internationalization", "typescript"]
},
Expand Down Expand Up @@ -2265,7 +2252,7 @@
"title": "svelte-form-builder",
"repository": "https://github.com/pragmatic-engineering/svelte-form-builder-community",
"description": "A No-Code Form Builder Library",
"npm": "svelte-form-builder-community",
"npm": "@pragmatic-engineering/svelte-form-builder-community",
"category": "Forms & User Input",
"tags": ["forms", "components and libraries"]
},
Expand Down Expand Up @@ -2415,7 +2402,7 @@
"title": "SvelteKit-Adapter-Versioned-Worker",
"repository": "https://github.com/hedgehog125/SvelteKit-Adapter-Versioned-Worker",
"description": "A SvelteKit adapter for generating service workers to make PWAs work offline",
"npm": "svelteKit-adapter-versioned-worker",
"npm": "sveltekit-adapter-versioned-worker",
"category": "SvelteKit Adapters"
},
{
Expand Down
7 changes: 7 additions & 0 deletions src/routes/templates/templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -678,5 +678,12 @@
"description": "A Starter Kit with SurrealDB and SvelteKit, featuring Authentication and CRUD Operations + Realtime",
"category": "SvelteKit",
"tags": ["templates", "database", "integrations", "typescript", "ssr"]
},
{
"title": "SvelteStore",
"repository": "https://github.com/gitbreaker222/SvelteStore",
"description": "Template for client side svelte store",
"category": "Svelte",
"tags": ["templates", "stores and state"]
}
]