super-sveltekit-cli

0.3.0 • Public • Published

⚒️ Super SvelteKit CLI 🧰

What is Super Sveltekit CLI?

Super Sveltekit CLI is a command line tool for the Sveltekit framework. The idea behind this tool is to facilitate the creation of routes and integration of libraries and services.

The tool will expand by adding integrations with other libraries, creating examples or facilitating the whole process to start working with the different libraries.

The good thing is that you can start using it since it is not a dependency but a tool, so although it is in an early stage of development maybe it can be useful.

The command will automatically watch for typescript, so it will generate server.js or server.ts for example depending of your setup.

Things to see 👀

Features

  • Routes with files generation: +page.server.js|ts(with load function and optional action), +page.svelte(with optional action form) and optional: +layout.svelte and +layout.server.ts
  • Api endpoints and routes: generate api endpoints with routes and http operations inside of it: GET,POST,PUT,PATCH,DELETE.

Next steps

  • Improve cli messages
  • New command to generate actions
  • Ask for sveltekit project scaffold when the command is used outside a sveltekit project.
  • More commands...

Installation 🛬

npm i -g super-sveltekit-cli

PNPM

pnpm i -g super-sveltekit-cli

Is a command line tool! You dont have to install it as a dependency.

Commands

Create

Creates files, see below al the commands available and documentation.

Route

By default all paths created by this command will be created under the folder src/routes

Arguments
Argument Description Valid Values
name Name or names of the path to be created name | path/name | path/"("group")/name" | path/[slug]/name | if no value is provided will ask for a name
Flags
Flag Description
--layout | -l Adds to the route a layout file inside of it
--layout-only | -lo Creates the route only with the layout file, useful when you want to create a route with a layout and inside of it a route with all the files: blog/+layout.svelte and after that blog/post/+page.svelte
--layout-server | -ls Adds to the route a layout server file with a load function

Description

Creates a route under src/routes folder, by default the command will generate +page.svelte and +page.server.js|ts with a load function inside of it, you can extend the command with flags to add layout files, layout server files or only layout files

  • Alias: c p
$ ssc create route name

This comand will create the next route ./src/routes/name with +page.svelte and +page.server.js files inside of it

You can create sub routes too:

$ ssc create route name/test/ssc

Create a route with a slug:

$ ssc create route name/[slug]/ssc

Grouping routes:

$ ssc create route name/"("group")"/test

And it will create the route: routes/name/(group)/test

❗ Grouping routes
The command line has some limitation for example you cannot create a group of routes this way routes/(group)/route-name the command line will throw an error, you must scape the parenthesis with double quotes routes/"("group")"/route-name

Api

By default all paths created by this command will be created under the folder src/api

Arguments
Argument Description Valid Values
name Name or path of the path to be created name | path/name | path/"("group")/name" | path/[slug]/name | if no value is provided will ask for a name
Flags
Flag Description
--crud | -c Generates the server file with crud operations
--get | -g Adds to the file a GET operation
--post | -p Adds to the file a POST operation
--put | -pt Adds to the file a PUT operation
--patch | -pa Adds to the file a PUT operation
--delete | -d Adds to the file a DELETE operation
Combine all this flags to create the server file you need, see examples below

Examples

  • Create a empty server file:
$ ssc create api name
  • Create a server file with crud operations:
$ ssc create api name -c
  • Create a server file with different operations:
$ ssc create api name -g

Generates the file with a GET operation

$ ssc create api name -g -p -d

Generates the file with GET, POST and DELETE operations

Package Sidebar

Install

npm i super-sveltekit-cli

Weekly Downloads

0

Version

0.3.0

License

MIT

Unpacked Size

27.5 kB

Total Files

22

Last publish

Collaborators

  • chirili