Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cj-scripts

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cj-scripts

A React CLI for computer gangsters

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

cj-scripts 💻

Scripts for front end gangsters writing React apps.

What is it?

cj-scripts is a CLI that abstracts linting, formatting, transpiling, testing, building, and serving React projects into one dependency. Think of it like a poor man's react-scripts.

Here are some things included:

  • Webpack config for dev and prod
  • Dev middleware attached to your Express application with hot reloading
  • Babel configuration
  • .env file support
  • Configured Jest testing
  • Multi-core utilzation for production builds

How do I use it?

  1. Install it:
  npm i cj-scripts
  1. Create a .env file at the root of your app for your environment variables.

  2. Add cj-scripts/babel as a preset to your .babelrc (but Babel itself is not required):

{
  "presets": ["cj-scripts/babel"]
}
  1. Create a src/index.js file that bootstraps your client-side app.

  2. Export an Express application at server/app.js called app. This should probably route to your client-side app, serve static assets, and any other logic you might want (except for dev middleware, that's included when running cj-scripts start).

  import express from 'express';

  export const app = express();

  // your server logic...
  1. Run any of the commands below within the context of your app (i.e. put them in your package.json scripts)

Commands

cj-scripts start
  • Start your Express app with development middleware attached.
  • This command expects src/index.js as the bootstrap file for your client-side app.
  • By default this will look for a named export of an Express server/router called app in /server/app.js, but this path can be changed with the CJ_SCRIPTS_APP_PATH environment variable.
  • The PORT environment variable can also be used to dictate the port (the default value is 3000).
cj-scripts test
  • Fire up Jest in watch mode or optimized for CI based on the environment.
  • You can add a file at config/setupTests.js in your app to run initialization code for testing (think Enzyme adapter setup or global overrides).
cj-scripts build
  • Build the production assets into a build directory at the root of your app.
  • The PUBLIC_URL environment variable can be set to serve your app at a path other than the root.
cj-scripts start-prod
  • Run your Express app in production mode using the cluster module to take advantage of multiple cores.
  • The PUBLIC_URL environment variable can be set to serve your app at a path other than the root.
  • The PORT environment variable can also be used to dictate the port (the default value is 3000).

Utilities

import { getAppEnv } from 'cj-scripts'

const env = getAppEnv()

You can use getAppEnv() to collect environment variables from a .env file at the root of your app.

Keywords

FAQs

Package last updated on 31 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc