https://github.com/caplin/gc-cli
CLI for the global compiler project
https://github.com/caplin/gc-cli
Last synced: about 1 month ago
JSON representation
CLI for the global compiler project
- Host: GitHub
- URL: https://github.com/caplin/gc-cli
- Owner: caplin
- Created: 2014-07-26T11:14:33.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-11-08T17:25:21.000Z (about 8 years ago)
- Last Synced: 2024-12-28T19:52:03.404Z (about 1 year ago)
- Language: JavaScript
- Size: 528 KB
- Stars: 3
- Watchers: 22
- Forks: 1
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gc-cli
[](http://travis-ci.org/caplin/gc-cli)
[](https://david-dm.org/caplin/gc-cli)
### Purpose
Converts namespaced JavaScript code to CommonJS modules.
This:
```javascript
caplin.grid.GridView = function() {
this._scrollView = new caplin.grid.ScrollPane();
}
```
will be converted to:
```javascript
'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:
```bash
$ npm i -g caplin/gc-cli
```
or clone this repository, `cd` into it and run
```bash
$ npm link
```
### Usage
Once installed `cd` into a directory with a `src` subdirectory (a blade,
bladeset, lib or aspect) and run.
```bash
$ 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
```bash
$ 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.
```bash
$ gc-cli --namespaces caplin,caplinx,br,yournamespaceroot
```
* `--compileTestFiles` or `-t` convert `tests`, use a transform pipeline
configured for tests.
```bash
$ gc-cli --compileTestFiles
```
### Contributing
Raise any issues, feature requests in this repository or create a PR for them.
#### Testing
Inside this repo
```bash
$ npm t
```