1.0.4 • Published 6 years ago

extjs-dependencies-generator v1.0.4

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

ExtJS Dependencies Generator

Generates an array of ExtJS dependencies in the right order. This library also checks if there's a cyclic dependency.

Installation

  1. Install ExtJS Dependencies Generator through npm:
    npm install extjs-dependencies-generator

Usage

  1. In your JavaScript program, declare the extjs-dependencies-generator library as a variable to gain access to it's generator function:
    var gen = require('extjs-dependencies-generator');
  2. Call the generateDependencies function to generate ExtJS dependency list.

    gen.generateDependencies(dir, d => {
        let files = d.files;
        // Do something with the files array here...    
    })

    generateDependencies (sourceDir: string, callback: function)

    sourceDir - The directory that contains all the ExtJS files.

    callback - This is called after all the dependencies are determined. Returns a dependencies object that contains all the files sorted in the right order based on the dependency graph. Returns the object with the following properties:

    1. graph - the dependency graph.
    2. dependencies - returns { classname, filename }
    3. files - returns the object in the following format { pattern: filename }

Complete Example

This example shows you how to generate a list of dependencies in the right order and saves it to a file.

var beautify = require('js-beautify').js_beautify;
var fs = require('fs');
var gen = require('../index');
var _ = require('underscore');
var dir = 'test/src/**/*.js';

gen.generateDependencies(dir, d => {
    let files = [];
    _.each(d.dependencies, f => {
        files.push({ pattern: f.filename, watched: true });
    });
    writeFile("dependencies.js", beautify(JSON.stringify(files)));
});


function writeFile(filename, content) {
    fs.writeFile(filename, content, 'utf-8', function (err) {
        if (err)
            console.log(err);
    });
}
1.2.11

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago