Skip to content

caplin/gc-cli

Repository files navigation

gc-cli

Build Status Dependency Status

Purpose

Converts namespaced JavaScript code to CommonJS modules.

This:

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

will be converted to:

'use strict';

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

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

module.exports = GridView;

Also adds requires for specified globals i.e. jQuery.on(...) will add a var jQuery = require('jQuery') statement if not already present in the code.

Requirements

node v6 or higher.

Installation

Either install it globally:

$ npm i -g caplin/gc-cli

or clone this repository, cd into it and run

$ npm link

Usage

Once installed cd into a directory with a src subdirectory (a blade, bladeset, lib or aspect) and run.

$ gc-cli

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

Suggested approach

Convert one blade, bladeset, lib, aspect src at a time, then run tests, verify the application is working and perform smoke tests. git checkout . will revert the changes. Don't get bogged down on one conversion too long, move to another one if the conversion is not straightforward. Do not work on converted code without commiting the code locally or it will be difficult to keep track of your own changes versus the automated ones. The tests do not need to be converted namespaced tests can still test converted CJS code. Perform a code diff to verify the conversion looks reasonable.

To convert JS patches cd into js-patches and run

$ gc-cli --outputDirectory=. "**/*.js"

Command line flags

You can modify the default options using these options:

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

Contributing

Raise any issues, feature requests in this repository or create a PR for them.

Testing

Inside this repo

$ npm t

About

CLI for the global compiler project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •