Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-kitql

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-kitql - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4-next.0

10

bin.js

@@ -5,6 +5,6 @@ #!/usr/bin/env node

import { program, Option } from 'commander'
import fs, { readFileSync } from 'node:fs'
import path from 'node:path'
import { exit } from 'node:process'
import { fileURLToPath } from 'node:url'
import fs from 'fs'
import path from 'path'
import { exit } from 'process'
import { fileURLToPath } from 'url'

@@ -25,3 +25,3 @@ const { version } = JSON.parse(fs.readFileSync(new URL('package.json', import.meta.url), 'utf-8'))

if (fs.existsSync(metaPath)) {
data = JSON.parse(readFileSync(metaPath, 'utf-8'))
data = JSON.parse(fs.readFileSync(metaPath, 'utf-8'))
}

@@ -28,0 +28,0 @@ return { ...data, value: templateDir }

@@ -9,3 +9,3 @@ {

],
"version": "0.0.3",
"version": "0.0.4-next.0",
"license": "MIT",

@@ -12,0 +12,0 @@ "type": "module",

@@ -32,4 +32,4 @@ {

"typescript": "^5.0.0",
"vite": "^4.4.2",
"vite-plugin-kit-routes": "^0.1.1",
"vite": "^4.5.0",
"vite-plugin-kit-routes": "0.2.0-next.1",
"vitest": "^0.34.0"

@@ -36,0 +36,0 @@ },

@@ -7,3 +7,6 @@ /**

export const PAGES = {
/**
* PAGES
*/
const PAGES = {
'/': `/`,

@@ -14,7 +17,16 @@ '/about': `/about`,

export const SERVERS = {};
/**
* SERVERS
*/
const SERVERS = {};
export const ACTIONS = {};
/**
* ACTIONS
*/
const ACTIONS = {};
export const LINKS = {
/**
* LINKS
*/
const LINKS = {
twitter: `https:/twitter.com/jycouet`,

@@ -28,7 +40,13 @@ github: `https:/github.com/jycouet/kitql`,

params.d = params.d ?? 'identicon';
return `https:/www.gravatar.com/avatar/${params.str}${appendSp({ s: params.s, d: params.d })}`;
return `https:/www.gravatar.com/avatar/${params.str}${appendSp({
s: params?.s,
d: params?.d
})}`;
}
};
const appendSp = (sp?: Record<string, string | number | undefined>) => {
/**
* Append search params to a string
*/
const appendSp = (sp?: Record<string, string | number | undefined>, prefix: '?' | '&' = '?') => {
if (sp === undefined) return '';

@@ -41,3 +59,3 @@ const mapping = Object.entries(sp)

if (formated) {
return `?${formated}`;
return `${prefix}${formated}`;
}

@@ -47,3 +65,33 @@ return '';

// route function helpers
type NonFunctionKeys<T> = { [K in keyof T]: T[K] extends Function ? never : K }[keyof T];
type FunctionKeys<T> = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T];
type FunctionParams<T> = T extends (...args: infer P) => any ? P : never;
const AllObjs = { ...PAGES, ...ACTIONS, ...SERVERS, ...LINKS };
type AllTypes = typeof AllObjs;
/**
* To be used like this:
* ```ts
* import { route } from './ROUTES'
*
* route('site_id', { id: 1 })
* ```
*/
export function route<T extends FunctionKeys<AllTypes>>(
key: T,
...params: FunctionParams<AllTypes[T]>
): string;
export function route<T extends NonFunctionKeys<AllTypes>>(key: T): string;
export function route<T extends keyof AllTypes>(key: T, ...params: any[]): string {
if (AllObjs[key] instanceof Function) {
const element = (AllObjs as any)[key] as (...args: any[]) => string;
return element(...params);
} else {
return AllObjs[key] as string;
}
}
/**
* Add this type as a generic of the vite plugin `kitRoutes<KIT_ROUTES>`.

@@ -58,3 +106,3 @@ *

* PAGES: {
* // here, "paths" it will be typed!
* // here, key of object will be typed!
* }

@@ -66,6 +114,6 @@ * })

PAGES: { '/': never; '/about': never; '/your-face': never };
SERVERS: {};
ACTIONS: {};
SERVERS: Record<string, never>;
ACTIONS: Record<string, never>;
LINKS: { twitter: never; github: never; github_avatar: 'author'; gravatar: 'str' };
Params: { author: never; str: never; s: never; d: never };
};

@@ -33,3 +33,3 @@ {

"typescript": "^5.0.0",
"vite": "^4.4.2",
"vite": "^4.5.0",
"vite-plugin-kit-routes": "^0.1.1",

@@ -36,0 +36,0 @@ "vitest": "^0.34.0"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc