Code Monkey home page Code Monkey logo

gc-cli's Introduction

gc-cli

Build Status Dependency Status

Purpose

This repository hosts a command line tool that converts package/folder namespaced JavaScript code to CommonJS modules. So scripts with classes defined in a namespaced manner will be flattened and references to namespaced dependencies will be replaced with bindings to required modules.

Code in this style:

caplin.grid.GridView = function() {
	this._scrollView = new caplin.grid.ScrollPane();
}

will be converted to code in this style:

'use strict';

var ScrollPane = require('caplin/grid/ScrollPane');

function GridView() {
	this._scrollView = new ScrollPane();
}

It also formats the code using the js-formatter tool and adds requires for specified globals i.e. jQuery.on(...) will add var jQuery = require('jQuery') if they are present in the source code. To minimize changes you can format your code first and then run this tool.

Mechanics

This package makes use of the global-compiler package for source code transformations and the js-formatter tool for code formatting.

To use as a command line tool install it globally with the command.

$ npm i -g caplin/gc-cli

Once installed cd into a directory with a src subdirectory and run.

$ gc-cli

This will format all *.js files in the src directory using the default options.

$ gc-cli -t

Will format the tests directory.

Command line flags

You can modify the default options using these options

  • --namespaces or -n a comma separated list of root namespaces to convert to CJS.
$ gc-cli --namespaces caplin,caplinx,otherroot,someroot
  • --compileTestFiles or -t convert tests, use a transform pipeline configured for tests.
$ gc-cli --compileTestFiles

Testing

Inside this repo

$ npm t

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.