4.4.3 • Published 12 months ago

simple-web-cli v4.4.3

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Install

   npm i simple-web-cli -D

Usage

Create

   npx sw create
  • npx sw create: prepares the environment without starting the service

Start | Watch

   npx sw
  • npx sw or npx sw start: prepares the environment and starts the service

Build

   npx sw build
  • npx sw build: compiles the contents from src and zips it to release.zip

Development

  • src is the default directory of development to watch
  • dist is the default directory with the compiled code
  • Once the process is started, the event occurs by saving any file into src.
  • All options are preconfigured and you can customize them 😉

Features

ES Modules to Native Browser Javascript

  • Import from external modules

    // File: ./src/index.js
    
    import { s } from 'node-and-vite-helpers';
    
    const body = s('body');
    // Output to ./dist/index.js:
    
    !function(){"use strict";var e="body";document.querySelector(e)}();
  • Import from local modules

    // File ./helpers/sum.js
    const sum = (a, b) => a + b;
    export default sum;
    
    // File: ./src/index.js
    import sum from '../helpers/sum';
    
    console.log(sum(1, 2));
    // Output to ./dist/index.js:
    
    !function(){"use strict";console.log(3)}();

Using SFTP or FTP HotSync

  • In the file .swrc.js, just insert the access infos:
{
   // ...

   sftp: {
      start: {
         root: '',
         host: '',
         username: '',
         password: '',
      },
   },
}
{
   // ...

   ftp: {
      root: '',
      host: '',
      user: '',
      pass: '',
      secure: true
   }
}
  • The sftp connection options extends all the ssh2 options
  • If the server doesn't use SSL certification, set explict or implict
  • Assuming the root option is / and the remote directory is /var/www, the input and output of the directories would be:

    • Development: ./src/ html/index.html
    • Distribution: ./dist/ html/index.html
    • Server: /var/www/ html/index.html
  • You can only use one protocol at a time: SFTP or FTP

Some Examples

HTML

INPUT

<div>
   <h1>Title</h1>
   <p>Paragraph</p>
</div>

OUTPUT

<div><h1>Title</h1><p>Paragraph</p></div>

HTML Import

  • You can import .html files recursively, based on the scss import, for example:
    <html>
       <body>
          <!-- import('./views/_header.html') -->
          <section>
             <!-- import('./views/_main.html') -->
          </section>
          <!-- import('../_footer.html') -->
       </body>
    </html>

CSS | Sass

INPUT

div {
   display: flex;
}

OUTPUT

div{display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex}

PHP | PHTML

INPUT

<?
   $var = 'text'
?>

<div>
   <?=$var?>
</div>

OUTPUT

<?php $var='text'?><div><?=$var?></div>

Apache (.htaccess, php.ini)

INPUT

# comment
<Directory /var/www/>
   # another comment
   Options Indexes FollowSymLinks MultiViews
</Directory>

OUTPUT

<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
</Directory>

Strings Replacement

  • You can create an easy to read code and on compiling, replace the specified strings, for example:

.swrc.js

{
   strings: {
      '*token*': {
         start: '123',
         build: '456'
      },
      '*site-name*': {
         start: 'dev.weslley.io',
         build: 'weslley.io'
      }
   }
}

INPUT

<?
   $_POST['*token*'];
   $site = '*site-name*';

OUTPUT DEV (npx sw)

<?php $_POST['123'];$site='dev.weslley.io';

OUTPUT BUILD (npx sw build)

<?php $_POST['456'];$site='weslley.io';
  • Works for any language that is enabled in .swrc.js

Miscellaneous Files

  • Only uploads the original file to the output directories

Compatibility

macOS Linux Windows node

License

License 3rd-Party Software License

Credits

Contributors

ContributionsGitHub
Authorwellwelwel
Translate en-USSrLaco
Translate Reviewmicaele-mags

Create dev dependencies

Made with sadness and sorrow in rainy nights by Weslley Araújo 💜

4.4.1

12 months ago

4.4.0

12 months ago

4.4.3

12 months ago

4.4.2

12 months ago

4.3.2

1 year ago

4.0.1

1 year ago

4.0.0

1 year ago

4.0.3

1 year ago

4.2.0

1 year ago

4.0.2

1 year ago

4.3.1

1 year ago

4.1.3

1 year ago

4.1.0

1 year ago

4.3.0

1 year ago

4.1.2

1 year ago

4.1.1

1 year ago

3.1.18

2 years ago

3.2.2

2 years ago

3.2.1

2 years ago

3.2.0

2 years ago

3.2.3

2 years ago

3.3.1

2 years ago

3.3.0

2 years ago

3.1.16

2 years ago

3.1.17

2 years ago

3.1.14

2 years ago

3.1.12

2 years ago

3.1.11

2 years ago

3.1.13

2 years ago

3.1.10

2 years ago

2.6.1

2 years ago

2.6.0

2 years ago

2.8.1

2 years ago

2.8.0

2 years ago

3.1.9

2 years ago

3.1.8

2 years ago

3.0.0-beta

2 years ago

2.7.0

2 years ago

2.5.2

2 years ago

2.7.1

2 years ago

3.1.3

2 years ago

3.1.2

2 years ago

3.1.1

2 years ago

3.1.7

2 years ago

3.1.6

2 years ago

3.1.5

2 years ago

3.1.4

2 years ago

2.8.3

2 years ago

2.8.2

2 years ago

2.8.4

2 years ago

2.5.1

2 years ago

2.5.0

2 years ago

2.4.11

2 years ago

2.4.10

2 years ago

2.4.9

2 years ago

2.4.8

2 years ago

2.4.7

2 years ago

2.4.6

2 years ago

2.4.4

2 years ago

2.4.3

2 years ago

2.4.2

2 years ago

2.4.0

2 years ago

2.3.5

2 years ago

2.3.3

2 years ago

2.3.1

2 years ago

2.2.4

2 years ago

2.2.3

2 years ago

2.2.1

2 years ago

2.2.0

2 years ago

2.1.43

2 years ago

2.1.38

2 years ago

2.1.37

2 years ago

2.1.36

2 years ago

2.1.35

2 years ago

2.1.34

2 years ago

2.1.33

2 years ago

2.1.32

2 years ago

2.1.31

2 years ago

2.1.30

2 years ago

2.1.29

2 years ago

2.0.28

2 years ago

2.0.27

2 years ago

2.0.26

2 years ago

2.0.25

2 years ago

2.0.24

2 years ago

2.0.23-test

2 years ago

2.0.22-test

2 years ago

2.0.21-test

2 years ago

2.0.20-test

2 years ago

2.0.19

2 years ago

2.0.18

2 years ago

1.0.0

2 years ago