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

svps

v2.3.0

Published

πŸš€ An easier tool to automate your Ubuntu Server setup and domain forwarding

Downloads

37

Readme

Table of Contents


About

SVPS, initially designed to simplify tasks for non-Unix users, works as an ORM for Ubuntu Servers.

It supports command automation, files and directories upload via SFTP, automatic installations and configurations, domain forwarding, local text files and template strings into escaped quoted strings for dynamic remote file creation, among other features.

All this, using just a single one connection πŸ§™πŸ»βœ¨


Installation

  npm i svps

Usage

import { SVPS } from 'svps';

/** Prepare the connection */
const svps = new SVPS({
  access: {
    host: '127.0.0.1',
    username: 'root',
    password: 'root',
  },
});

/** For AWS */
const svps = new SVPS({
  access: {
    host: '***.amazonaws.com',
    username: 'ubuntu',
    privateKey: fs.readFileSync('./your_rsa.pem'),
  },
});

/** Available methods
 * svps.mount
 * svps.commands
 * svps.createVirtualHosts
 * svps.upload
 * svps.end
 *
 * See about each below πŸ•΅πŸ»
 */

Automatic Installations

await svps.mount({
  php: true || { version: 8.2, composer: true },
  node: true || { version: 18, packages: ['yarn'] },
  apache: true,
  docker: true,
  // ...

  /**
   * ... Users, Desktop (RDP), Firewall,  etc.
   *
   * See all available automatic installations below πŸ‘‡πŸ»
   */
});

Available auto-installation

See some practical examples.

Notes

  • The entire remote process is displayed on console in real time
  • Find all the commands behind SVPS in src/lib/tasks/steps
  • This may take a long time depending on your VPS specifications

Personal Commands (Queuing)

Create your own commands and combine with other SVPS features.

const commands = ['echo "πŸš€"'];

await svps.commands(commands);
  • You can use the escapeQuotes method to create multi-line escaped quoted strings. See an example here.

Upload Files and Directories

Transfer your local files and directories and set permissions for each upload.

await svps.upload([
  {
    local: './my-app-dist',
    remote: '/workspace',
    permissions: {
      user: 'my-user',
    },
  },
]);
  • It uses SFTP to send the content to remote server

Download Files

Download your remote files.

await svps.download([
  {
    remote: '/workspace/backup.zip',
    local: './my-local-path/backup.zip',
  },
]);
  • It uses SFTP to get the content from remote server

Virtual Hosts (Domains Forwarding)

await svps.createVirtualHosts([
  // Basic or Advanced Virtual Hosts
]);

/**
 * This will create a log with the processed domains to ensure that only new domains are processed.
 * If you delete this log, the domains will be understood as new and will be overwritten.
 */

Basic Usage (easier)

Node.js PHP MySQL

You can automatically create Node.js (LTS) and PHP (8.2) services and work on them in /var/containers/domains/your_domain.
Also, it allows to use an exclusive MySQL database for each domain.

await svps.createVirtualHosts([
  {
    domain: 'site.com',
    port: 5000,
    www: true /** creates an alias for "www.site.com" */,
    server: {
      language: 'node' | 'php',
      mysql: {
        database: 'db-name',
        password: 'db-pass',
        expose: 5001 /** expose port 5001 locally */,
        isPublic: true /** expose port 5001 outside the VPS */,
      },
    },
  },
]);
  • For PHP, you can flag the server option buildFromScratch as true to create the Virtual Host image from scratch, otherwise it will pull the images from my Docker Hub πŸ™‹πŸ»β€β™‚οΈ

To create flexible Basic Virtual Hosts, SVPS uses Docker containers and Apache2 to proxy their ports to your domains.

Apache2, Docker and Docker Compose required.

See some practical examples here.


Advanced Usage (manual)

Everything

By using the Virtual Hosts solely to proxy your services, you can create services in any language you choose, by simply defining the port your service is on.

await svps.createVirtualHosts([
  {
    domain: 'site.com',
    port: 5000,
    www: true /** creates an alias for "www.site.com" */,
  },
]);

// It will proxy your service at port 5000 to "site.com" and "www.site.com"

Apache2 required.


Turning VPS Server into Desktop Server (RDP)

await svps.mount({
  desktop: true,
});

/** That's it πŸ€ΉπŸ»β€β™€οΈ */
  • It will install Xubuntu Desktop and RDP Remote in port 3389
  • The desktop installation can take longer and take up more disk space (about 1GB to 3GB)
  • If you are using a container, remember to expose the port 3389
  • To access, use your credentials in a Remote Desktop Software

See a practical example using a Docker container.


Testing using a Docker Container

  • Create the container:

    docker run -d --privileged -p 22:22 --restart always wellwelwel/vps:latest
  • Then, set the default access:

    const svps = new SVPS({
      access: {
        host: '127.0.0.1',
        username: 'root',
        password: 'root',
        port: 22,
      },
    });

Close the Connection

await svps.end();

Important

  • This package is designed for pre-built VPS, KVM and Ubuntu Server >=18.04
  • The SSH user needs to be the root or a super user
  • Avoid running this tool on a server that is already in production, unless you know what you're doing πŸ§™πŸ»

Known Issues


Compatibility

macOS Linux Windows node npm


Community

I'm continuously working to improve SVPS. If you've got something interesting to share, feel free to submit a Pull Request. If you notice something wrong, I'd appreciate if you'd open an Issue.


Contributing

Please check the CONTRIBUTING.md for instructions πŸš€