https://github.com/baopham/jscodemod-collection
A collection of JSCodemods
https://github.com/baopham/jscodemod-collection
angular es6 jscodemod jscodeshift
Last synced: 7 months ago
JSON representation
A collection of JSCodemods
- Host: GitHub
- URL: https://github.com/baopham/jscodemod-collection
- Owner: baopham
- Created: 2017-04-01T14:53:13.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-06T14:59:09.000Z (over 8 years ago)
- Last Synced: 2025-01-31T04:11:27.739Z (9 months ago)
- Topics: angular, es6, jscodemod, jscodeshift
- Language: JavaScript
- Homepage:
- Size: 75.2 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
JSCodemod Collection
==========[](https://circleci.com/gh/baopham/jscodemod-collection)
[](http://standardjs.com/)A collection of JSCodemods
Usage:
------### Convert Angular injected dependencies to ES6 import
> Note: you will need to pass in the path to a config script for generating the import statements.
> See [config.example.js](./transformers/config.example.js)```bash
cd transformers
jscodeshift -t ./angular-injected-dep-to-es6-import.js /path/to/your-angular-file.js --config='/absolute/path/to/config.example.js'
```Example:
* Input:
```js
'use strict';angular.module('angularApp')
.factory('helloWorld', helloWorld);function helloWorld($http, $q, helloWorldConstant) {
}
```* Output:
```js
'use strict';import { $http, $q } from '../../angularDeps';
import helloWorldConstant from '../../helloWorld.constant';angular.module('angularApp')
.factory('helloWorld', helloWorld);function helloWorld() {
}
```### A helper to collect all the Angular services, factories, constants etc. including their file paths
```bash
cd /path/to/angular-project
jscodeshift -s -t /path/to/jscodemod-collection/transformers/angular-collect.js --ignore-config=.gitignore ./client
```Will output
```JSON
"helloWorldConstant": "path/to/helloWorld.constant.js",
"helloWorldService": "path/to/helloWorld.service.js",
```You can then copy the output to a JSON file that can be used for later. See [config.example.js](./transformers/config.example.js)
Requirements:
-------------
Node ^6Install:
--------```bash
git clone git@github.com:baopham/jscodemod-collection.git
yarn install
yarn install jscodeshift -g
```License:
--------
MITAuthor:
-------
Bao Pham