npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sveil/cli

v0.0.36

Published

Sveil - svelte generation tool

Downloads

3

Readme

sveil-cli

⚠️Alpha version. Still under development!

Required node >= 16

What:

The sveil. Generation tool for svelte. Sveil will generate svelte resources.

Why:

Why not? Svelte is pretty mature framework, but for some reason have no any generation tool that widely used. Generation tool could save some time, scale application, and set structure. I didn't find any other generation tools for svelte, only nx have one, but it's comes with monorepos only, nx workspace and other configs (and last time I tried it svelte plugin didn't work well). And Lets say, svelte plugin for nx isn't looks official, nx mostly focused on react or angular.

The Sveil on other hand is standalone tool that you can use without any config files.


Philosophy:

Freedom without structure is chaos. Svelte let us decide how to organize project freely, there're only several restrictions/rules. Since svelte trying to bind to native js way without any built in design patterns, we as developers are on our own.

I see 3 main goals of sveil tool:

  • Generation
  • Structure
  • Scale

For now it's limited generation, but with time sveil will get ability to structure svelte project and scale it (like nest or angular cli).


Table of Content


Instalation

```
npm i @sveil/cli -g
```

Getting started

You can easily run:

sveil --help

In any situation to find desired command.


Usage

Here's documentation, that you can run in any time:

sveil
Usage: sveil [options] [command]

Options:
  -v, --version     Show sveil version
  -h, --help        display help for command

Commands:
  init|i [options]  Init sveil and create sveil config
  generate|g        Generate sveil resource
  help [command]    display help for command

Init

Command creates sveil-cli.json in root directory.

Not required in most cases. You need it only if your project using non standart named directories.

For example common path in svelte for lib is src/lib/, but if you have src/library/, then you need sveil configuration file (you can create it manually, doesn't matter really). Same for inner lib directories, like "components", "store", etc. Or even source/ instead of src/, all path values are configurable.

In all other cases you don't need config file and nobody ever will know that you used sveil (●'◡'●)

sveil i --help
Usage: sveil init|i [options]

Init sveil and create sveil config

Options:
  -d, --dry                    Run command dry-run(no changes will be applied)
  -y, --skip                   Skip interactive tour and init with default values
  -srcd, --source-dir <dir>    Set source directory of project
  -ld, --lib-dir <dir>         Set lib directory of project
  -cd, --components-dir <dir>  Set components directory of project
  -h, --help                   display help for command

Generate

Component

sveil g c --help
Usage: sveil generate component|c [options] <componentName>

Generate svelte component

Arguments:
  componentName                      Component name

Options:
  -d, --dry                          Run comman dry-run (no changes will be applied)
  -sl, --script-language <language>  Set component script language (choices: "ts", "js")
  -ce, --css-external                Put component styles out of component
  -cl, --css-language <language>     Set component style language, e.g. 'scss' (choices: "scss", "postcss")
  -o, --overwrite                    WARNING: Overwriting existing component
  -s, --separate                     Generate component in separate folder
  -h, --help                         display help for command

Component state

Typescript only for now

sveil g cs --help
Usage: sveil generate component-state|cs [options] [componentName]

Generate component state

Arguments:
  componentName           Target component name

Options:
  -d, --dry               Run command dry-run (no changes will be applied)
  -s, --state             add target stores
  -n, --file-name [name]  Custom file name
  -h, --help              display help for command

Examples


sveil g c main

OR


sveil generate component main

Output:


- file main.svelte generated in ...\src\lib\components\main.svelte

Basic svelte component template:


<script>
  let name = "main";
</script>

<div class="main">
  {name}
</div>

<style>
  .main {
    margin: 0;
    padding: 0;
  }
</style>

By default sveil use plain css and js for component template, but if project use typescript - it automatically add lang="ts". It's possible to overwrite default script/style languages with -sl and -cl options.

Sveil supports typescript only in script languages and scss/postcss in style preprocessors (for now).

Please, be aware there's no auto detection for style preprocessors yet.

You can move styles out of component with -ce option


sveil g c example -ce

Or create component in separate folder with -s option


sveil g c example -s

If component already existed, then you can use -o option with little confirmation prompt (need to write component name)


sveil g c example -o

More info about output file


sveil g cs main

OR


sveil generate component-state main

Output:


- file main.ts generated in ...\src\lib\components\main\main.ts