Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1dd3d6a
Adds basic controller parsing.
lucalanca Aug 18, 2014
f1838f9
Adds dependencies to controllers.
lucalanca Aug 18, 2014
3dc993d
Parses controllers dependencies in the function format.
lucalanca Aug 18, 2014
b808bf3
Fixes identation.
lucalanca Aug 18, 2014
2702e7c
Adds more tests-
lucalanca Aug 18, 2014
2ff2544
Services first commit.
lucalanca Aug 18, 2014
8a2bdf6
Adds test for controllers with no dependencies.
lucalanca Aug 19, 2014
3eb3626
Fixes services deps and adds more tests with empty deps.:wq
lucalanca Aug 19, 2014
b1b715e
Excludes angular-specific dependencies.
lucalanca Aug 19, 2014
2bbb9ba
Dummy push.
lucalanca Aug 25, 2014
5d83330
Adds codeship flag to readme.
lucalanca Aug 25, 2014
7a75cce
Dummy commit.
lucalanca Aug 25, 2014
5d3da47
Updates README
lucalanca Aug 27, 2014
50707ba
Modifies package.json to publish under a npm package.
lucalanca Aug 27, 2014
3627601
A LOT of changes in the infrastructure and tests.
lucalanca Oct 6, 2014
77509e0
Adds use strict to missing files.
lucalanca Oct 6, 2014
1549003
Fixes tasks so that grunt test doesn't do the watching.
lucalanca Oct 6, 2014
a13cea7
Released 0.2.0
lucalanca Oct 6, 2014
78cd8f3
Adds reference to grunt tasks on README.md.
lucalanca Oct 10, 2014
0671ca9
Adds option to hide angular dependencies.
lucalanca Oct 10, 2014
f4a23a7
Bumps version on package.json
lucalanca Oct 10, 2014
a4ef0c8
Fixes typo on $timeout service.
lucalanca Oct 10, 2014
a098fe3
Bump package.json version.
lucalanca Oct 10, 2014
6ff036c
Adds ng as angular service. Trims services for defensive programming.
lucalanca Oct 10, 2014
d4532ed
Bumps package version.
lucalanca Oct 10, 2014
47e6214
Wrap eval call in window context
vfeskov Aug 14, 2015
1f09a1c
Ignore ngMaterial module dependency
vfeskov Nov 25, 2015
970a3a3
feat(application) : add .component API support
vogloblinsky Oct 28, 2016
e194dbf
Merge pull request #5 from vfeskov/master
lucalanca Oct 28, 2016
f0d0688
Merge pull request #7 from vogloblinsky/master
lucalanca Oct 28, 2016
704a4be
Bump version
lucalanca Oct 28, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
140 changes: 140 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"env": {
"browser": false,
"node": true,
"amd": false,
"mocha": true
},

"rules": {
"no-alert": 2,
"no-array-constructor": 2,
"no-bitwise": 0,
"no-caller": 2,
"no-catch-shadow": 2,
"no-comma-dangle": 2,
"no-cond-assign": 2,
"no-console": 2,
"no-constant-condition": 2,
"no-control-regex": 2,
"no-debugger": 2,
"no-delete-var": 2,
"no-div-regex": 0,
"no-dupe-keys": 2,
"no-else-return": 0,
"no-empty": 2,
"no-empty-class": 2,
"no-empty-label": 2,
"no-eq-null": 0,
"no-eval": 2,
"no-ex-assign": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-extra-boolean-cast": 2,
"no-extra-parens": 0,
"no-extra-semi": 2,
"no-extra-strict": 2,
"no-fallthrough": 2,
"no-floating-decimal": 0,
"no-func-assign": 2,
"no-implied-eval": 2,
"no-inner-declarations": [2, "functions"],
"no-invalid-regexp": 2,
"no-iterator": 2,
"no-label-var": 2,
"no-labels": 2,
"no-lone-blocks": 2,
"no-lonely-if": 0,
"no-loop-func": 2,
"no-mixed-requires": [0, false],
"no-mixed-spaces-and-tabs": [2, false],
"no-multi-str": 2,
"no-native-reassign": 2,
"no-negated-in-lhs": 2,
"no-nested-ternary": 0,
"no-new": 2,
"no-new-func": 2,
"no-new-object": 2,
"no-new-require": 0,
"no-new-wrappers": 2,
"no-obj-calls": 2,
"no-octal": 2,
"no-octal-escape": 2,
"no-path-concat": 0,
"no-plusplus": 0,
"no-process-exit": 2,
"no-proto": 2,
"no-redeclare": 2,
"no-regex-spaces": 2,
"no-reserved-keys": 0,
"no-restricted-modules": 0,
"no-return-assign": 2,
"no-script-url": 2,
"no-self-compare": 0,
"no-sequences": 2,
"no-shadow": 2,
"no-shadow-restricted-names": 2,
"no-space-before-semi": 2,
"no-spaced-func": 2,
"no-sparse-arrays": 2,
"no-sync": 0,
"no-ternary": 0,
"no-trailing-spaces": 2,
"no-undef": 2,
"no-undef-init": 2,
"no-undefined": 0,
"no-underscore-dangle": 2,
"no-unreachable": 2,
"no-unused-expressions": 2,
"no-unused-vars": [2, {"vars": "all", "args": "after-used"}],
"no-use-before-define": 2,
"no-void": 0,
"no-warning-comments": [0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }],
"no-with": 2,
"no-wrap-func": 2,

"block-scoped-var": 0,
"brace-style": [0, "1tbs"],
"camelcase": 2,
"complexity": [0, 11],
"consistent-return": 2,
"consistent-this": [0, "that"],
"curly": [2, "all"],
"default-case": 0,
"dot-notation": 2,
"eol-last": 2,
"eqeqeq": 2,
"func-names": 0,
"func-style": [0, "declaration"],
"global-strict": [2, "never"],
"guard-for-in": 0,
"max-depth": [0, 4],
"max-len": [0, 80, 4],
"max-nested-callbacks": [0, 2],
"max-params": [0, 3],
"max-statements": [0, 10],
"handle-callback-err": 0,
"new-cap": 2,
"new-parens": 2,
"one-var": 0,
"quote-props": 0,
"quotes": [2, "double"],
"radix": 0,
"semi": 2,
"sort-vars": 0,
"space-after-keywords": [0, "always"],
"space-in-brackets": [0, "never"],
"space-in-parens": [0, "never"],
"space-infix-ops": 2,
"space-return-throw-case": 2,
"space-unary-word-ops": 0,
"strict": 2,
"use-isnan": 2,
"valid-jsdoc": 0,
"valid-typeof": 2,
"vars-on-top": 0,
"wrap-iife": 0,
"wrap-regex": 0,
"yoda": [2, "never"]
}
}
20 changes: 2 additions & 18 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,7 @@

module.exports = function(grunt) {

grunt.initConfig({
watch: {
test: {
files: ['test/*.js', 'src/*.js'],
tasks: ['test']
}
},
mochaTest: {
test: {
src: ['test/*.js']
}
}
});

grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-mocha-test');

grunt.registerTask('test', ['mochaTest:test']);
require('load-grunt-tasks')(grunt);
require('load-grunt-config')(grunt);

};
50 changes: 26 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
angular-modules-graph
=====================
# Angular Architecture Graph

Create a graph of angular module definitions, extracted from [grunt-angular-modules-graph](https://github.com/carlo-colombo/grunt-angular-modules-graph)
This project is a node utility that analyses an angular project and exports a graph with the project's architecture: modules, controllers, directives and filters.

[ ![Codeship Status for lucalanca/angular-modules-graph](https://www.codeship.io/projects/43e2f770-0ead-0132-1978-5ad6f07ad273/status)](https://www.codeship.io/projects/32481)

```js
var scripts = [
{
id: 'file1.js',
text: "angular.module('TestModule',[])"
},
{ ... }
]
## How to use it:

var angularModulesGraph = require('angular-modules-graph')
1. Require the module:

var res = angularModulesGraph(scripts)
```js
var angularArchitectureGraph = require('angular-architecture-graph'),
])
```

res.angular // fake angular containig graph
res.angular.modulesNames == ['TestModule' , ...] //list of modules name found
res.angular.modules // modules found
res.angular.modules[0].name == 'TestModule' //module name
res.angular.modules[0].items //untyped array of defined items (controllers, filters, provider, services, ...)
res.angular.modules[0].modules //array of module dependencies
2. Call it with your project code:

res.results // array of objects indicating if script evaluation resulted without error
res.results[0].id == 'file1.js'
res.results[0].error == false // true if an error occured during evalution
res.results[0].exception == undefined // exception launched during evaluation
```js
var architecture = angularArchitectureGraph([
{ id: 'file1.js', text: '<angular code here in a string>' },
{ id: 'file2.js', text: '<angular code here in a string>' }
])
```

```
It was designed with grunt in mind. Use it with [grunt-angular-modules-graph](https://github.com/lucalanca/grunt-angular-modules-graph).

3. Do whatever you want with the resulted architecture object

## About

This project was originally forked from , extracted from [@carlo-colombo's](https://github.com/carlo-colombo) [angular-modules-graph](https://github.com/carlo-colombo/angular-modules-graph)

## License:
MIT
7 changes: 7 additions & 0 deletions grunt/aliases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
default:
- eslint
- mochaTest:test

test:
- eslint
- mochaTest:test
6 changes: 6 additions & 0 deletions grunt/eslint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
files: ["src/*.js", "test/*.js", "!test-mocks/*.js", "index.js", "grunt/*.js"],
options: {
config: ".eslintrc"
}
};
5 changes: 5 additions & 0 deletions grunt/mochaTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
test: {
src: ["test/*.js"]
}
};
6 changes: 6 additions & 0 deletions grunt/watch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
test: {
files: ["test/*.js", "src/*.js", "test-mocks/*.js", "index.js", "grunt/*.js"],
tasks: ["test"]
}
};
23 changes: 15 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
var angular = require('./src/fake-angular')(),
/*eslint no-unused-expressions: 0, no-unused-vars: 0, no-eval: 0*/
"use strict";

module.exports = function(scripts, options) {


var angular = require("./src/fake-angular")(options),
document = {}, window = {}, navigator = {};

module.exports = function(scripts) {
var results = scripts.map(function(content) {

try {
eval(content.text)
(function() {
eval(content.text);
}.call(window));
} catch (e) {
return {
id: content.id,
error: true,
exception: e
}
};
}

return {
id: content.id,
error: false
}
})
};
});

return {
angular: angular,
results: results
}
}
};
};
42 changes: 27 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
{
"name": "angular-modules-graph",
"version": "0.1.0",
"description": "Create a graph of angular module definitions",
"name": "angular-architecture-graph",
"version": "0.2.4",
"description": "Create a graph of an angular project's architecture",
"main": "index.js",
"scripts": {
"test": "grunt test"
},
"keywords": [
"angular",
"modules",
"architecture",
"graph"
],
"author": "Carlo Colombo <@lit_car>",
"author": "João Figueiredo <@lucalanca>",
"repository": {
"type": "git",
"url": "git://github.com/carlo-colombo/angular-modules-graph.git"
"url": "git://github.com/lucalanca/angular-architecture-graph.git"
},
"bugs": {
"url": "https://github.com/carlo-colombo/angular-modules-graph/issues"
"url": "https://github.com/lucalanca/angular-architecture-graph/issues"
},
"licenses": [{
"type": "MIT",
"url": "https://github.com/carlo-colombo/angular-modules-graph/blob/master/LICENSE-MIT"
}],
"licenses": [
{
"type": "MIT",
"url": "https://github.com/lucalanca/angular-architecture-graph/blob/master/LICENSE-MIT"
}
],
"devDependencies": {
"mocha": "^1.18.2",
"should": "^3.2.0",
"grunt-mocha-test": "^0.10.0",
"grunt": "^0.4.4",
"grunt-contrib-watch": "^0.6.1"
"grunt-contrib-watch": "^0.6.1",
"grunt-eslint": "^1.1.0",
"grunt-mocha-test": "^0.10.0",
"grunt-publish": "0.0.5",
"load-grunt-config": "^0.13.1",
"load-grunt-tasks": "^0.6.0",
"mocha": "^1.18.2",
"nodegit": "^0.1.4",
"q-io": "^1.11.5",
"should": "^3.2.0"
},
"dependencies": {
"lodash": "^2.4.1",
"pluralize": "^1.0.2"
}
}
Loading