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

omen-startup

v1.0.10

Published

Omen Startup is a Node.js package designed to help developers quickly initialize and manage their environment variables and project configurations.

Downloads

7

Readme

Omen Startup

Omen Startup is a Node.js package designed to help developers quickly initialize and manage their environment variables and project configurations. This package provides an easy way to create and verify .env files, ensuring that all necessary environment variables are set up correctly.

Installation

To install Omen Startup, use npm:

npm install omen-startup

Or with yarn:

yarn add omen-startup

Usage

Initialize a New Startup

To initialize a new startup, create a new instance of the Startup class:

const Startup = require('omen-startup');
const startup = new Startup('MyProject');

Create a .env File

You can create a .env file by providing a configuration schema. This will prompt the user to enter the required environment variables.

const configSchema = {
  db_host: {
    description: 'Enter your database host',
    required: true
  },
  db_user: {
    description: 'Enter your database user',
    required: true
  },
  db_password: {
    description: 'Enter your database password',
    hidden: true,
    required: true
  }
};

startup.createENV(configSchema).then(() => {
  console.log('Environment file created successfully.');
}).catch(err => {
  console.error('Failed to create environment file:', err);
});

Verify Environment Variables

You can verify if the necessary environment variables are set by providing a sections object. This will print out the status of each variable.

const sections = {
  Database: ['DB_HOST', 'DB_USER', 'DB_PASSWORD']
};

startup.verifyENV(sections);

Create Necessary Files

The createNecessaryFiles method helps to create the necessary files for your project, including the .env file if it does not exist.

const createENVConfig = {
  db_host: {
    description: 'Enter your database host',
    required: true
  },
  db_user: {
    description: 'Enter your database user',
    required: true
  },
  db_password: {
    description: 'Enter your database password',
    hidden: true,
    required: true
  }
};

startup.createNecessaryFiles(createENVConfig).then(created => {
  if (created) {
    console.log('Necessary files created successfully.');
  } else {
    console.log('.env file already exists.');
  }
}).catch(err => {
  console.error('Failed to create necessary files:', err);
});

Example

Here's a full example of how you can use Omen Startup to initialize a new project, create a .env file, and verify environment variables:

const Startup = require('omen-startup');
const startup = new Startup('MyProject');

const configSchema = {
  db_host: {
    description: 'Enter your database host',
    required: true
  },
  db_user: {
    description: 'Enter your database user',
    required: true
  },
  db_password: {
    description: 'Enter your database password',
    hidden: true,
    required: true
  }
};

startup.createENV(configSchema).then(() => {
  console.log('Environment file created successfully.');

  const sections = {
    Database: ['DB_HOST', 'DB_USER', 'DB_PASSWORD']
  };

  startup.verifyENV(sections);
}).catch(err => {
  console.error('Failed to create environment file:', err);
});

Other Example

const Startup = require('omen-startup');
const startup = new Startup('Discord Template');

const start = async () => {
    const needToCreateENV = await startup.createNecessaryFiles({
        botToken: { description: "Enter your bot token here", hidden: true },
        mongo: { description: "Enter your MongoDB URL", hidden: true },
        botID: { description: "Enter your bot ID" },
        ownerID: { description: 'Enter here the IDs from the Owners separated by ,', before: function(value) { return value.split(',').map(id => id.trim()).join('","'); } }
    });

    if (needToCreateENV) {
        console.log('✓ Your required files have been created, please restart the bot.');
        setTimeout(() => {
            return process.exit(1);
        }, 5000);
    } else {
        startup.verifyENV({
            'Bot Settings': [
                'TOKEN',
                'BOTID',
            ],
            'Other Settings': [
                'MONGOURI',
                'OWNERIDS'
            ]
            // Your bot index here
        });
    }
};

start();

API

new Startup(name)

Creates a new instance of the Startup class.

  • name (String): The name of the project.

createENV(configSchema)

Creates a .env file based on the provided configuration schema.

  • configSchema (Object): The configuration schema for the environment variables.

verifyENV(sections)

Verifies if the necessary environment variables are set.

  • sections (Object): An object where keys are section names and values are arrays of environment variable names.

createNecessaryFiles(createENVConfig)

Creates necessary files for the project, including the .env file if it does not exist.

  • createENVConfig (Object): The configuration schema for the environment variables.

License

This project is licensed under the MIT License.