Example #1
0
 options.workers.forEach(function(mode) {
     console.log("worker for " + mode + " mode");
     var worker = copy.createDataObject();
     var workerProject = copy.createCommonJsProject({
         roots: [ ANGLES_HOME + '/lib' ],
         textPluginPattern: /^ace\/requirejs\/text!/
     });
     copy({
         source: [{
             project: workerProject,
             require: [
                 'ace/lib/fixoldbrowsers',
                 'ace/lib/event_emitter',
                 'ace/lib/oop',
                 'ace/mode/' + mode + '_worker'
             ]
         }],
         filter: filters,
         dest: worker
     });
     copy({
         source: [
             ANGLES_HOME + "/lib/worker/worker.js",
             worker
         ],
         filter: options.compress ? [copy.filter.uglifyjs] : [],
         dest: targetDir + "/worker-" + mode + ".js"
     });
 });
Example #2
0
["javascript", "coffee", "css"].forEach(function(mode) {
    console.log("worker for " + mode + " mode");
    var worker = copy.createDataObject();
    var workerProject = copy.createCommonJsProject([
        aceHome + '/support/pilot/lib',
        aceHome + '/lib'
    ]);
    copy({
        source: [
            copy.source.commonjs({
                project: workerProject,
                require: [
                    'pilot/fixoldbrowsers',
                    'pilot/event_emitter',
                    'pilot/oop',
                    'ace/mode/' + mode + '_worker'
                ]
            })
        ],
        filter: [ copy.filter.moduleDefines],
        dest: worker
    });
    copy({
        source: [
            aceHome + "/lib/ace/worker/worker.js",
            worker
        ],
        filter: [ copy.filter.uglifyjs, filterTextPlugin ],
        dest: "build/src/worker-" + mode + ".js"
    });
});
 options.workers.forEach(function(mode) {
     console.log("worker for " + mode + " mode");
     var worker = copy.createDataObject();
     var workerProject = copy.createCommonJsProject({
         roots: [ ACE_HOME + '/lib' ],
         textPluginPattern: /^ace\/requirejs\/text!/
     });
     copy({
         source: [{
             project: workerProject,
             require: [
                 'ace/worker/worker',
                 'ace/mode/' + mode + '_worker'
             ]
         }],
         filter: getWriteFilters(options, "worker"),
         dest: worker
     });
     copy({
         source: [
             worker
         ],
         filter: options.compress ? [copy.filter.uglifyjs] : [],
         dest: targetDir + "/worker-" + mode + ".js"
     });
 });
 options.workers.forEach(function(mode) {
     console.log("worker for " + mode + " mode");
     var worker = copy.createDataObject();
     var workerProject = copy.createCommonJsProject({
         roots: [
             ACE_HOME + '/lib'
         ],
         textPluginPattern: /^ace\/requirejs\/text!/
     });
     copy({
         source: [
             copy.source.commonjs({
                 project: workerProject,
                 require: [
                     'ace/lib/fixoldbrowsers',
                     'ace/lib/event_emitter',
                     'ace/lib/oop',
                     'ace/mode/' + mode + '_worker'
                 ]
             })
         ],
         filter: [ copy.filter.moduleDefines, filterTextPlugin ],
         dest: worker
     });
     copy({
         source: [
             ACE_HOME + "/lib/ace/worker/worker.js",
             worker
         ],
         filter: [ /* copy.filter.uglifyjs */],
         dest: targetDir + "/worker-" + mode + ".js"
     });
 });
Example #5
0
    exec: function(args, context) {
      var log = 'Building standard outputs to built/gcli[-uncompressed].js\n';

      copy.mkdirSync(main.gcliHome + '/built', 493 /*0755*/);
      var project = copy.createCommonJsProject({
        roots: [ main.gcliHome + '/lib' ]
      });
      var sources = copy.createDataObject();

      copy({
        source: {
          project: project,
          // This list of dependencies should reflect index.html
          require: [ 'gcli/index', 'gcli/demo' ]
        },
        filter: copy.filter.moduleDefines,
        dest: sources
      });
      copy({
        source: { root: project, include: /.*\.png$|.*\.gif$/ },
        filter: copy.filter.base64,
        dest: sources
      });
      log += project.report() + '\n';

      // Create a GraphML dependency report. Directions:
      // - Install yEd (http://www.yworks.com/en/products_yed_about.htm)
      // - Load gcli/built/gcli.graphml
      // - Resize the nodes (Tools->Fit Node to Label)
      // - Apply a layout (Layout->Hierarchical)
      log += 'Outputting dependency graph to built/gcli.graphml\n';
      if (project.getDependencyGraphML) {
        copy({
          source: { value:project.getDependencyGraphML() },
          dest: 'built/gcli.graphml'
        });
      }

      // Create the output scripts, compressed and uncompressed
      copy({ source: 'index.html', filter: tweakIndex, dest: 'built/index.html' });
      copy({
        source: [ copy.getMiniRequire(), sources ],
        dest: 'built/gcli-uncompressed.js'
      });
      try {
        copy({
          source: [ copy.getMiniRequire(), sources ],
          filter: copy.filter.uglifyjs,
          dest: 'built/gcli.js'
        });
      }
      catch (ex) {
        log += 'ERROR: Uglify compression fails on windows/linux. ' +
            'Skipping creation of built/gcli.js\n';
      }
      return log;
    }
Example #6
0
function worker(project) {
    console.log('# cloud9 worker ---------');

    var worker = copy.createDataObject();
    var workerProject = copy.createCommonJsProject(project);

    // We don't get a return value from dryice, so we monkey patch error handling
    var yeOldeError = console.error;
    console.error = function() {
        yeOldeError();
        yeOldeError("@@@@ FATAL ERROR: DRYICE FAILED", arguments);
        yeOldeError();
        process.exit(1);
    };
    
    copy({
        source: [
            copy.source.commonjs({
                project: workerProject,
                require: [
                    'ace/lib/fixoldbrowsers',
                    'ace/lib/event_emitter',
                    'ace/lib/oop',
                    'ext/language/worker',
                    'ext/codecomplete/local_completer',
                    'ext/codecomplete/snippet_completer',
                    'ext/codecomplete/open_files_local_completer',
                    'ext/jslanguage/parse',
                    'ext/jslanguage/scope_analyzer',
                    'ext/jslanguage/jshint',
                    'ext/jslanguage/jumptodef',
                    'ext/jslanguage/debugger',
                    'ext/jslanguage/outline',
                    'ext/csslanguage/css_handler',
                    'ext/htmllanguage/html_completer',
                    'ext/codecomplete/mode_completer',
                    'ext/linereport/linereport_base',
                    'ext/linereport_php/linereport_php_worker',
                    'ext/linereport_python/linereport_python_worker',
                ]
            })
        ],
        filter: [ copy.filter.moduleDefines, filterTextPlugin ],
        dest: worker
    });
    copy({
        source: [
            ACE_HOME + "/lib/ace/worker/worker.js",
            worker
        ],
        filter: [ /* copy.filter.uglifyjs */],
        dest: __dirname + "/plugins-client/lib.ace/www/worker/worker-language.js"
    });
    
    console.error = yeOldeError;
}
Example #7
0
function demo() {
    console.log('# kitchen sink ---------');

    copy({
        source: "kitchen-sink.html",
        dest:   "build/kitchen-sink.html",
        filter: [ function(data) {
            return (data
                .replace("DEVEL-->", "")
                .replace("<!--DEVEL", "")
                .replace("PACKAGE-->", "")
                .replace("<!--PACKAGE", "")
                .replace("%version%", version)
                .replace("%commit%", ref)
            );
        }]
    });

    var project = copy.createCommonJsProject(aceProject);
    var demo = copy.createDataObject();
    copy({
        source: [
            'build_support/mini_require.js'
        ],
        dest: demo
    });
    copy({
        source: [
            copy.source.commonjs({
                project: project,
                require: [ "kitchen-sink/demo" ]
            })
        ],
        filter: [ copy.filter.moduleDefines ],
        dest: demo
    });
    copy({
        source: demo,
        filter: [ filterTextPlugin ],
        dest: 'build/demo/kitchen-sink/kitchen-sink-uncompressed.js'
    });
    copy({
        source: demo,
        filter: [ copy.filter.uglifyjs, filterTextPlugin ],
        dest: 'build/demo/kitchen-sink/kitchen-sink.js'
    });
}
Example #8
0
/**
 * Build the Javascript JSM files for Firefox
 * Consists of: gcli.jsm, browser_gcli_web.js and gcli.properties
 */
function buildFirefox(destDir) {
  if (!destDir) {
    throw new Error('No destination directory. Either set $FIREFOX_HOME or use --location ...');
  }
  var log = 'Building Firefox outputs to ' + (destDir || 'built/ff') + '.\n\n';

  if (!destDir) {
    copy.mkdirSync(main.gcliHome + '/built/ff', 493 /*0755*/);
  }

  var testDir = '/browser/devtools/commandline/test';
  var propsDir = '/browser/locales/en-US/chrome/browser/devtools';

  if (destDir) {
    if (!fs.existsSync(destDir + testDir)) {
      throw new Error('Missing path for tests: ' + destDir + testDir);
    }
    if (!fs.existsSync(destDir + propsDir)) {
      throw new Error('Missing path for l10n string: ' + destDir + propsDir);
    }
  }

  // Convert GCLI test files to Mochitest files. The excluded tests are those
  // that rely on commands that ship with GCLI-web but are not implemented in
  // the same way in Firefox, and require which has been manually translated
  copy({
    source: {
      root: 'lib/gcli/test/',
      include: /test.*\.js$/,
      exclude: [
        /testHelp\.js$/,
        /testPref\.js$/,
        /testSettings\.js$/,
        /testRequire\.js$/
      ]
    },
    filter: createCommonJsToJsTestFilter(),
    filenameFilter: function(filename) {
      // the t prefix prevents 'test' from matching the directory name
      return filename.replace(/t\/test/, 't\/browser_gcli_').toLowerCase();
    },
    dest: (destDir ? destDir + testDir : 'built/ff')
  });
  copy({
    source: 'lib/gcli/test/mockCommands.js',
    filter: commonJsToJsMockFilter,
    dest: (destDir ? destDir + testDir : 'built/ff') + '/mockCommands.js'
  });

  // Package the i18n strings
  copy({
    source: [ 'lib/gcli/nls/strings.js' ],
    filter: tweakI18nStrings,
    dest: (destDir ? destDir + propsDir : 'built/ff') + '/gcli.properties'
  });

  return log;
}
function build() {
  console.log('Creating wysiwyg_forms/static/wysiwyg_forms/js/dwf.min.js');

  var project = copy.createCommonJsProject({
    roots: [path.join(__dirname, 'wysiwyg_forms/static/wysiwyg_forms/js')]
  });

  copy({
    source: [
      copy.getMiniRequire(),
      copy.source.commonjs({
        project: project,
        require: ['dwf']
      })
    ],
    filter: [
      copy.filter.moduleDefines,
      copy.filter.uglifyjs
    ],
    dest: 'wysiwyg_forms/static/wysiwyg_forms/js/dwf.min.js'
  });
}
Example #10
0
function worker(project) {
    console.log('# cloud9 worker ---------');

    var worker = copy.createDataObject();
    var workerProject = copy.createCommonJsProject(project);
    copy({
        source: [
            copy.source.commonjs({
                project: workerProject,
                require: [
                    'ace/lib/fixoldbrowsers',
                    'ace/lib/event_emitter',
                    'ace/lib/oop',
                    'ace/narcissus/parser',
                    'ext/language/worker',
                    'ext/codecomplete/local_completer',
                    'ext/codecomplete/snippet_completer',
                    'ext/codecomplete/open_files_local_completer',
                    'ext/jslanguage/parse',
                    'ext/jslanguage/scope_analyzer',
                    'ext/jslanguage/narcissus_jshint',
                    'ext/jslanguage/debugger',
                    'ext/jslanguage/outline'
                ]
            })
        ],
        filter: [ copy.filter.moduleDefines, filterTextPlugin ],
        dest: worker
    });
    copy({
        source: [
            ACE_HOME + "/lib/ace/worker/worker.js",
            worker
        ],
        filter: [ /* copy.filter.uglifyjs */],
        dest: __dirname + "/plugins-client/lib.ace/www/worker/worker.js"
    });
}
// TODO: replace with project.clone once it is fixed in dryice
function cloneProject(project) {
    var clone = copy.createCommonJsProject({
        roots: project.roots,
        ignores: project.ignoreRequires
    });

    Object.keys(project.currentFiles).forEach(function(module) {
        clone.currentFiles[module] = project.currentFiles[module];
    });

    Object.keys(project.ignoredFiles).forEach(function(module) {
        clone.ignoredFiles[module] = project.ignoredFiles[module];
    });

    return clone;
}
// TODO: replace with project.clone once it is fixed in dryice
function cloneProject(project) {
    var clone = copy.createCommonJsProject({
        roots: project.roots,
        ignores: project.ignoreRequires,
        textPluginPattern: project.textPluginPattern
    });

    Object.keys(project.currentModules).forEach(function(module) {
        clone.currentModules[module] = project.currentModules[module];
    });

    Object.keys(project.ignoredModules).forEach(function(module) {
        clone.ignoredModules[module] = project.ignoredModules[module];
    });

    return clone;
}
Example #13
0
exports.unamdize = function(srcDir, destDir) {
  count = 0;

  copy.mkdirSync(destDir, 493 /*0755*/);
  copy({
    source: srcDir,
    filter: function(input) {
      if (typeof input !== 'string') {
        input = input.toString();
      }
      count++;
      return input
              .replace(/define\(function\(require, exports, module\) \{/, '')
              .replace(/}\);\s*$/, '')
              .replace(/require\('text!([^']*)'\)/g, 'require(\'fs\').readFileSync(\'node_modules/$1\')');
    },
    dest: destDir
  });

  return 'Converted ' + count + ' modules.';
};
Example #14
0
/**
 * Collate and filter the project inputs, given a definition of the project.
 * The project definition changes for Firefox and normal builds
 */
function collateProjectFiles(project) {
  // Grab and process all the Javascript
  var output = copy.createDataObject();
  copy({
    source: [ copy.source.commonjs({ project: project, require: [ "gcli/index" ] }) ],
    filter: [ copy.filter.moduleDefines ],
    dest: output
  });

  // Process the CSS/HTML/PNG/GIF
  copy({
    source: { root: project, include: /.*\.css$|.*\.html$/, exclude: /tests?\// },
    filter: [ copy.filter.addDefines ],
    dest: output
  });
  copy({
    source: { root: project, include: /.*\.png$|.*\.gif$/, exclude: /tests?\// },
    filter: [ copy.filter.base64 ],
    dest: output
  });

  return output;
}
function removeAmdefine(e){return e=String(e).replace(/if\s*\(typeof\s*define\s*!==\s*'function'\)\s*{\s*var\s*define\s*=\s*require\('amdefine'\)\(module,\s*require\);\s*}\s*/g,""),e=e.replace(/\b(define\(.*)('amdefine',?)/gm,"$1")}function makeNonRelative(e){return e.replace(/require\('.\//g,"require('source-map/").replace(/\.\.\/\.\.\/lib\//g,"")}function buildBrowser(){console.log("\nCreating dist/source-map.js");var e=copy.createCommonJsProject({roots:[path.join(__dirname,"lib")]});copy({source:["build/mini-require.js",{project:e,require:["source-map/source-map-generator","source-map/source-map-consumer","source-map/source-node"]},"build/suffix-browser.js"],filter:[copy.filter.moduleDefines,removeAmdefine],dest:"dist/source-map.js"})}function buildBrowserMin(){console.log("\nCreating dist/source-map.min.js"),copy({source:"dist/source-map.js",filter:copy.filter.uglifyjs,dest:"dist/source-map.min.js"})}function buildFirefox(){function n(e){return/^test\-.*?\.js/.test(e)}console.log("\nCreating dist/SourceMap.jsm");var e=copy.createCommonJsProject({roots:[path.join(__dirname,"lib")]});copy({source:["build/prefix-source-map.jsm",{project:e,require:["source-map/source-map-consumer","source-map/source-map-generator","source-map/source-node"]},"build/suffix-source-map.jsm"],filter:[copy.filter.moduleDefines,removeAmdefine,makeNonRelative],dest:"dist/SourceMap.jsm"}),console.log("\nCreating dist/test/Utils.jsm"),e=copy.createCommonJsProject({roots:[__dirname,path.join(__dirname,"lib")]}),copy({source:["build/prefix-utils.jsm","build/assert-shim.js",{project:e,require:["test/source-map/util"]},"build/suffix-utils.jsm"],filter:[copy.filter.moduleDefines,removeAmdefine,makeNonRelative],dest:"dist/test/Utils.jsm"});var t=fs.readdirSync(path.join(__dirname,"test","source-map")).filter(n);t.forEach(function(e){console.log("\nCreating",path.join("dist","test",e.replace(/\-/g,"_"))),copy({source:["build/test-prefix.js",path.join("test","source-map",e),"build/test-suffix.js"],filter:[removeAmdefine,makeNonRelative,function(n,t){return n.replace("define(",'define("'+path.join("test","source-map",e.replace(/\.js$/,""))+'", ["require", "exports", "module"], ')},function(n,t){return n.replace("{THIS_MODULE}",function(){return"test/source-map/"+e.replace(/\.js$/,"")})}],dest:path.join("dist","test",e.replace(/\-/g,"_"))})})}function ensureDir(e){var n=!1;try{n=fs.statSync(e).isDirectory()}catch(t){}n||fs.mkdirSync(e,511)}var path=require("path"),fs=require("fs"),copy=require("dryice").copy;removeAmdefine.onRead=!0,makeNonRelative.onRead=!0,ensureDir("dist"),ensureDir("dist/test"),buildFirefox(),buildBrowser(),buildBrowserMin();
function buildAce(aceProject, options) {
    
    var defaults = {
        targetDir: __dirname + "/build/src",
        ns: "ace",
        exportModule: "ace/ace",
        requires: null,
        compress: false,
        noconflict: false,
        suffix: ".js",
        name: "ace",
        compat: true,
        modes: [
            "css", "html", "javascript", "php", "coldfusion", "python", "lua", "xml", "ruby", "java", "c_cpp",
            "coffee", "perl", "csharp", "haxe", "svg", "clojure", "scss", "json", "groovy",
            "ocaml", "scala", "textile", "scad", "markdown", "latex", "powershell", "sql", "yesmail_template"
        ],
        themes: [
            "chrome", "clouds", "clouds_midnight", "cobalt", "crimson_editor", "dawn", 
            "dreamweaver", "eclipse",
            "idle_fingers", "kr_theme", "merbivore", "merbivore_soft",
            "mono_industrial", "monokai", "pastel_on_dark", "solarized_dark",
            "solarized_light", "textmate", "tomorrow", "tomorrow_night",
            "tomorrow_night_blue", "tomorrow_night_bright", "tomorrow_night_eighties",
            "twilight", "vibrant_ink"
        ],
        workers: ["javascript", "coffee", "css"],
        keybindings: ["vim", "emacs"]
    };
    
    for(var key in defaults)
        if (!options.hasOwnProperty(key))
            options[key] = defaults[key];
    
    if (!options.requires)
        options.requires = [options.exportModule];

    var filters = [copy.filter.moduleDefines, filterTextPlugin];

    if (options.noconflict) {
        filters.push(namespace(options.ns));
        if (options.exportModule)
            filters.push(exportAce(options.ns, options.exportModule, options.ns));
    } else if (options.exportModule) {
        filters.push(exportAce(options.ns, options.exportModule));
    }
    
    if (options.compress)
        filters.push(copy.filter.uglifyjs);
        
    var suffix = options.suffix;
    var targetDir = options.targetDir;
    var name = options.name;
    
    var project = copy.createCommonJsProject(aceProject);
    var ace = copy.createDataObject();
    copy({
        source: ["build_support/mini_require.js"],
        dest: ace
    });
    copy({
        source: [
            copy.source.commonjs({
                project: project,
                require: options.requires
            })
        ],
        filter: [ copy.filter.moduleDefines ],
        dest: ace
    });
    
    copy({
        source: ace,
        filter: filters,
        dest:   targetDir + '/' + name + suffix
    });
    
    if (options.compat) {
        project.assumeAllFilesLoaded();
        copy({
            source: [
            copy.source.commonjs({
                    project: cloneProject(project),
                    require: [ "pilot/index" ]
                })
            ],
            filter: filters,
            dest:   targetDir + "/" + name + "-compat" + suffix
        });
    }

    console.log('# ace modes ---------');
    
    project.assumeAllFilesLoaded();
    options.modes.forEach(function(mode) {
        console.log("mode " + mode);
        copy({
            source: [
            copy.source.commonjs({
                    project: cloneProject(project),
                    require: [ 'ace/mode/' + mode ]
                })
            ],
            filter: filters,
            dest:   targetDir + "/mode-" + mode + suffix
        });
    });
    
    console.log('# ace themes ---------');
    
    options.themes.forEach(function(theme) {
        console.log("theme " + theme);
        copy({
            source: [{
                root: ACE_HOME + '/lib',
                include: "ace/theme/" + theme + ".js"
            }],
            filter: filters,
            dest:   targetDir + "/theme-" + theme + suffix
        });
    });
    
    console.log('# ace worker ---------');
    
    options.workers.forEach(function(mode) {
        console.log("worker for " + mode + " mode");
        var worker = copy.createDataObject();
        var workerProject = copy.createCommonJsProject({
            roots: [
                ACE_HOME + '/lib'
            ],
            textPluginPattern: /^ace\/requirejs\/text!/
        });
        copy({
            source: [
                copy.source.commonjs({
                    project: workerProject,
                    require: [
                        'ace/lib/fixoldbrowsers',
                        'ace/lib/event_emitter',
                        'ace/lib/oop',
                        'ace/mode/' + mode + '_worker'
                    ]
                })
            ],
            filter: [ copy.filter.moduleDefines, filterTextPlugin ],
            dest: worker
        });
        copy({
            source: [
                ACE_HOME + "/lib/ace/worker/worker.js",
                worker
            ],
            filter: [ /* copy.filter.uglifyjs */],
            dest: targetDir + "/worker-" + mode + ".js"
        });
    });
    
    console.log('# ace key bindings ---------');
    
    // copy key bindings
    project.assumeAllFilesLoaded();
    options.keybindings.forEach(function(keybinding) {
        copy({
            source: [
            copy.source.commonjs({
                    project: cloneProject(project),
                    require: [ 'ace/keyboard/keybinding/' + keybinding ]
                })
            ],
            filter: filters,
            dest: "build/src/keybinding-" + keybinding + suffix
        });
    });
}
Example #17
0
function prepareBuild()
{
    shell.mkdir(buildDir);
    shell.mkdir(releaseDir);

    // Copy non JS resources
    copy({
        source: {
            root: '.',
            // TODO: Previously we copied everything that matched this set of
            // extensions: js, xul, properties, css, html, xml, dtd, ong, gif, ico,
            //      manifest, txt, html
            // and then deleted. Now we copy everything with exclusions, but
            // we don't know what extra exclusions were missing
            exclude: [
                /.*\.graphml/, /build\.xml/, /node_modules/, /build\.js/,
                /install\.rdf\.tpl\.xml/, /update\.rdf\.tpl\.xml/
            ]
        },
        dest: buildDir
    });

    var project = copy.createCommonJsProject({
        roots: [
            __dirname + "/content"
        ],
        aliases: {
            "arch": "firebug/bti/inProcess"
        }
    });

    copy({
        source: [
            //copy.getMiniRequire(),
            {
                project: project,
                require: [
                    "firebug/chrome/chrome",
                    "firebug/lib/lib",
                    "firebug/firebug",
                    "firebug/bti/inProcess/browser",
                    "firebug/trace/traceModule",
                    "firebug/chrome/navigationHistory",
                    "firebug/chrome/knownIssues",
                    "firebug/js/sourceFile",
                    "firebug/chrome/shortcuts",
                    "firebug/firefox/start-button/startButtonOverlay",
                    "firebug/firefox/external-editors/externalEditors",
                    "firebug/firefox/firebugMenu",
                    "firebug/chrome/panelActivation",
                    //"firebug/console/memoryProfiler", xxxHonza: removed from 1.10 (issue 5599)
                    "firebug/chrome/tableRep",
                    "firebug/html/htmlPanel",
                    "firebug/console/commandLinePopup",
                    "firebug/accessible/a11y",
                    "firebug/js/scriptPanel",
                    "firebug/js/callstack",
                    "firebug/console/consoleInjector",
                    "firebug/net/spy",
                    "firebug/js/tabCache",
                    "firebug/chrome/activation",
                    "firebug/css/stylePanel",
                    "firebug/css/computedPanel"
                ],
            },
            __dirname + "/content/firebug/main.js"
        ],
        filter: moduleDefines,
        dest: buildDir + "/content/firebug/main.js"
    });

    // Compress main.js file (all extension modules)
    // xxxHonza: do not use uglify for build, there is missing ';' somewhere
    /*copy({
        source: buildDir + "/content/firebug/main.js",
        filter: copy.filter.uglifyjs,
        dest: buildDir + "/content/firebug/main.js"
    });*/

    /*copy({
        source: {value:project.getDependencyGraphML()},
        dest: "netpanel.graphml"
    });*/

    // Copy install.rdf template into the build dir
    copy({
        source: "install.rdf.tpl.xml",
        dest: buildDir + "/install.rdf"
    });
}
Example #18
0
  grunt.registerTask("dryice", function() {
    var arg0 = arguments[0];
    if (arg0 !== "edge" && isDebugging()) {
      grunt.fail.warn("NOT built with debug mode.");
      return;
    }
    if (grunt.file.exists(".grunt-config")) {
      if (grunt.file.readJSON(".grunt-config")["build"] === 0) {
        return;
      }
    }
    var copy = require("dryice").copy;
    var srcroot = "src";
    var main = "cc/loader";
    var dest;
    if (arg0 === "edge") {
      dest = "extras/edge/coffee-collider";
    } else {
      dest = "build/coffee-collider";
    }
    
    var coffeeColliderProject = {
      roots: [srcroot]
    };
    var project = copy.createCommonJsProject(coffeeColliderProject);
    var cc = copy.createDataObject();
    var filter;

    var header = "";
    header += "(function(global) {" + "\n";
    header += '"use strict";' + "\n";

    var footer = "";
    footer += "})(this.self||global);" + "\n";
    
    copy({
      source: { value:header },
      dest  : cc
    });
    copy({
      source: [ "./src/require.js" ],
      dest  : cc
    });
    filter = [
      copy.filter.moduleDefines,
      function(text) {
        var constants = grunt.file.readJSON("src/const.json");
        Object.keys(constants).forEach(function(key) {
          var re = new RegExp("C\." + key + "(?![A-Z0-9_])", "g");
          text = text.replace(re, constants[key]);
        });
        return text;
      },
      function(text) {
        var re = /(global\.(?:.+?) = "load\((.+?)\)";)/gm;
        var m;
        while ((m = re.exec(text)) !== null) {
          var code = grunt.file.read(m[2]);
          text = text.replace(m[1], code);
        }
        return text;
      },
      function(text) {
        var version = grunt.config.get("pkg.version");
        if (arg0 === "edge") {
          var now = new Date();
          version += "+";
          version += now.getYear() + 1900;
          version += ("00"+(now.getMonth()+1)).substr(-2);
          version += ("00"+(now.getDate()   )).substr(-2)
          version += ("00"+(now.getHours()  )).substr(-2)
          version += ("00"+(now.getMinutes())).substr(-2)
          version += "00";
        }
        text = text.replace(/^define\((['"].+?['"]), \[(.+?)\], function\(require, exports, module\) {$/gm, "define($1, function(require, exports, module) {");
        text = text.replace(/\s*['"]use strict['"];$/gm, "");
        text = text.replace(/#{VERSION}/g, version);
        text += 'var exports = _require("cc/cc", "' + main + '");\n';
        text += 'if (typeof module !== "undefined") {\n  module.exports = exports;\n}\n';
        return text;
      }
    ];
    copy({
      source: [ { project:project, require:main } ],
      filter: filter,
      dest  : cc
    });
    copy({
      source: { value:footer },
      dest  : cc
    });
    copy({
      source: cc,
      dest  : dest + ".js"
    });
  });
        } else if (call) {
            deps.some(function(d) {
                if (d.split("/").pop() == call.split("/").pop()) {
                    dep = d;
                    return true;
                }
            });

            call = textModules[dep];
            if (call)
                return " " + call;
        }
    });
}

var CommonJsProject = copy.createCommonJsProject({roots:[]}).constructor;
CommonJsProject.prototype.getCurrentModules = function() {
    function isDep(child, parent) {
        if (!modules[parent])
            return false;
        var deps = modules[parent].deps;
        if (deps[child]) return true;
        return Object.keys(deps).some(function(x) {
            return isDep(child, x)
        });
    }
    var depMap = {}, modules = this.currentModules;
    return Object.keys(this.currentModules).map(function(moduleName) {
        module = modules[moduleName];
        module.id = moduleName;
        module.isSpecial = !/define\(\'[^']*',/.test(module.source);
var buildAce = function(options) {
    var aceProject = {
        roots: [ACE_HOME + '/lib', ACE_HOME + '/demo'],
        textPluginPattern: /^ace\/requirejs\/text!/
    };

    var defaults = {
        targetDir: BUILD_DIR + "/src",
        ns: "ace",
        exportModule: "ace/ace",
        requires: null,
        compress: false,
        noconflict: false,
        suffix: null,
        name: "ace",
        modes: jsFileList("lib/ace/mode", /_highlight_rules|_test|_worker|xml_util|_outdent|behaviour/),
        themes: jsFileList("lib/ace/theme"),
        extensions: jsFileList("lib/ace/ext"),
        workers: workers("lib/ace/mode"),
        keybindings: ["vim", "emacs"]
    };

    for(var key in defaults)
        if (!options.hasOwnProperty(key))
            options[key] = defaults[key];
    
    generateThemesModule(options.themes);

    addSuffix(options);

    if (!options.requires)
        options.requires = [options.exportModule];

    var targetDir = options.targetDir + options.suffix;
    var name = options.name;

    var project = copy.createCommonJsProject(aceProject);
    var ace = copy.createDataObject();
    copy({
        source: [ACE_HOME + "/build_support/mini_require.js"],
        dest: ace
    });
    copy({
        source: [{
            project: project,
            require: options.requires
        }],
        filter: [ copy.filter.moduleDefines ],
        dest: ace
    });
    
    if (options.coreOnly)
        return project;

    copy({
        source: ace,
        filter: getWriteFilters(options, "main"),
        dest:   targetDir + '/' + name + ".js"
    });

    console.log('# ace modes ---------');

    project.assumeAllFilesLoaded();
    options.modes.forEach(function(mode) {
        console.log("mode " + mode);
        copy({
            source: [{
                project: cloneProject(project),
                require: [ 'ace/mode/' + mode ]
            }],
            filter: getWriteFilters(options, "mode"),
            dest:   targetDir + "/mode-" + mode + ".js"
        });
    });

    console.log('# ace themes ---------');

    project.assumeAllFilesLoaded();
    options.themes.forEach(function(theme) {
        console.log("theme " + theme);
        copy({
            source: [{
                project: cloneProject(project),
                require: ["ace/theme/" + theme]
            }],
            filter: getWriteFilters(options, "theme"),
            dest:   targetDir + "/theme-" + theme.replace("_theme", "") + ".js"
        });
    });

    console.log('# ace extensions ---------');

    project.assumeAllFilesLoaded();
    options.extensions.forEach(function(ext) {
        console.log("extensions " + ext);
        copy({
            source: [{
                project: cloneProject(project),
                require: [ 'ace/ext/' + ext ]
            }],
            filter: getWriteFilters(options, "ext"),
            dest:   targetDir + "/ext-" + ext + ".js"
        });
    });

    console.log('# ace key bindings ---------');

    // copy key bindings
    project.assumeAllFilesLoaded();
    options.keybindings.forEach(function(keybinding) {
        copy({
            source: [{
                project: cloneProject(project),
                require: [ 'ace/keyboard/' + keybinding ]
            }],
            filter: getWriteFilters(options, "keybinding"),
            dest: targetDir + "/keybinding-" + keybinding + ".js"
        });
    });

    console.log('# ace worker ---------');

    options.workers.forEach(function(mode) {
        console.log("worker for " + mode + " mode");
        var worker = copy.createDataObject();
        var workerProject = copy.createCommonJsProject({
            roots: [ ACE_HOME + '/lib' ],
            textPluginPattern: /^ace\/requirejs\/text!/
        });
        copy({
            source: [{
                project: workerProject,
                require: [
                    'ace/worker/worker',
                    'ace/mode/' + mode + '_worker'
                ]
            }],
            filter: getWriteFilters(options, "worker"),
            dest: worker
        });
        copy({
            source: [
                worker
            ],
            filter: options.compress ? [copy.filter.uglifyjs] : [],
            dest: targetDir + "/worker-" + mode + ".js"
        });
    });


    if (options.shrinkwrap) {
        console.log('# combining files into one ---------');
        copy({
          source: { root:targetDir, exclude:/(^|\\|\/)worker\-[^\\\/]*\.js$/ },
          dest: BUILD_DIR + '/ace-min.js'
        });
    }
    
    return project;
};
function demo(project) {
    project = project || buildAce({
        compress: false,
        noconflict: false,
        coreOnly: true
    });
    console.log('# kitchen sink ---------');

    var version, ref;
    try {
        version = JSON.parse(fs.readFileSync(ACE_HOME + "/package.json")).version;
        ref = fs.readFileSync(ACE_HOME + "/.git-ref").toString();
    } catch(e) {
        ref = "";
        version = "";
    }

    function changeComments(data) {
        return (data
            .replace(/<!\-\-DEVEL[\d\D]*?DEVEL\-\->/g, "")
            .replace(/PACKAGE\-\->|<!\-\-PACKAGE/g, "")
            .replace(/\/\*DEVEL[\d\D]*?DEVEL\*\//g, "")
            .replace(/PACKAGE\*\/|\/\*PACKAGE/g, "")
            .replace("%version%", version)
            .replace("%commit%", ref)
        );
    };

    function fixDocPaths(data) {
        return data.replace(/"(demo|build)\//g, "\"");
    }

    copy({
        source: ACE_HOME + "/kitchen-sink.html",
        dest:   BUILD_DIR + "/kitchen-sink.html",
        filter: [changeComments, fixDocPaths]
    });

    copy({
        source: ACE_HOME + "/demo/kitchen-sink/styles.css",
        dest:   BUILD_DIR + "/kitchen-sink/styles.css",
        filter: [ changeComments ]
    });

    fs.readdirSync(ACE_HOME +"/demo/kitchen-sink/docs/").forEach(function(x) {
        copy({
            source: ACE_HOME +"/demo/kitchen-sink/docs/" + x,
            dest:   BUILD_DIR + "/kitchen-sink/docs/" + x
        });
    });

    var demo = copy.createDataObject();
    
    project.assumeAllFilesLoaded();
    copy({
        source: [{
            project: cloneProject(project),
            require: [ "kitchen-sink/demo" ]
        }],
        filter: getWriteFilters({filters:[fixDocPaths]}, "demo"),
        dest: demo
    });

    copy({
        source: demo,
        dest:   BUILD_DIR + "/kitchen-sink/demo.js",
    });

    copyFileSync(ACE_HOME + "/demo/kitchen-sink/logo.png", BUILD_DIR + "/kitchen-sink/logo.png");
}
Example #22
0
    source: { root: project, include: /.*\.css$|.*\.html$/, exclude: /tests?\// },
    filter: [ copy.filter.addDefines ],
    dest: output
  });
  copy({
    source: { root: project, include: /.*\.png$|.*\.gif$/, exclude: /tests?\// },
    filter: [ copy.filter.base64 ],
    dest: output
  });

  return output;
}

// Build the standard compressed and uncompressed javascript files
var stdProject = copy.createCommonJsProject([
  gcliHome + '/support/pilot/lib',
  gcliHome + '/lib'
]);
var stdSources = collateProjectFiles(stdProject);

copy({
  source: [ 'build/mini_require.js', stdSources ],
  filter: [ copy.filter.uglifyjs, filterTextPlugin ],
  dest: 'build/gcli.js'
});
copy({
  source: [ 'build/mini_require.js', stdSources ],
  filter: [ filterTextPlugin ],
  dest: 'build/gcli-uncompressed.js'
});

Example #23
0
// SETUP
var gcliHome = __dirname;

/**
 * There are 2 important ways to build GCLI with 2 outputs each.
 * - One build is for use within a normal web page. It has compressed and
 *   uncompressed versions of the output script file.
 * - The other build is for use within firefox. It consists of 1 output
 *   file: gcli.jsm
 */
console.log('Building build/gcli.js and build/gcli-uncompressed.js:');

// Build the standard compressed and uncompressed javascript files
var stdProject = copy.createCommonJsProject([
  gcliHome + '/lib'
]);

// Grab and process all the Javascript
var stdSources = copy.createDataObject();
copy({
  source: copy.source.commonjs({
    project: stdProject,
    require: [ 'gcli/index', 'demo/index', 'gcli/commands/help', 'gclitest/index' ]
  }),
  filter: copy.filter.moduleDefines,
  dest: stdSources
});

// Process the CSS/HTML/PNG/GIF
copy({
Example #24
0
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

var copy = require('dryice').copy;

var aceHome = __dirname;

console.log('# ace ---------');

var project = copy.createCommonJsProject([
    aceHome + '/support/gcli/support/pilot/lib',
    aceHome + '/support/gcli/lib',
    aceHome + '/lib',
    aceHome + '/demo'
]);


copy({
    source: "build_support/editor.html",
    dest: 'build/editor.html'
});

function filterTextPlugin(text) {
    return text.replace(/(['"])text\!/g, "$1text/");
    /*return text
        .replace(/define\(\s*['"]text\!\)/g, "text/")
        .replace(/require\(\s*['"]text\!\)/g, "text/")*/
}
Example #25
0
function buildAce(options) {
    var aceProject = {
        roots: [ACE_HOME + '/lib', ACE_HOME + '/demo'],
        textPluginPattern: /^ace\/requirejs\/text!/
    };

    var defaults = {
        targetDir: BUILD_DIR + "/src",
        ns: "ace",
        exportModule: "ace/ace",
        requires: null,
        compress: false,
        noconflict: false,
        suffix: null,
        name: "ace",
        modes: fs.readdirSync(ACE_HOME + "/lib/ace/mode").map(function(x) {
                if (x.slice(-3) == ".js" && !/_highlight_rules|_test|_worker|xml_util|_outdent|behaviour/.test(x))
                    return x.slice(0, -3);
            }).filter(function(x) { return !!x; }),
        themes: fs.readdirSync(ACE_HOME + "/lib/ace/theme").map(function(x){
                return x.slice(-3) == ".js" && x.slice(0, -3);
            }).filter(function(x){ return !!x; }),
        workers: ["javascript", "coffee", "css", "json", "xquery"],
        keybindings: ["vim", "emacs"]
    };
    

    for(var key in defaults)
        if (!options.hasOwnProperty(key))
            options[key] = defaults[key];

    if (options.suffix == null) {
        options.suffix = "";
        if (options.compress)
            options.suffix += "-min";
        if (options.noconflict)
            options.suffix += "-noconflict";
    }

    if (!options.requires)
        options.requires = [options.exportModule];

    var filters = [
        copy.filter.moduleDefines,
        filterTextPlugin,
        removeUseStrict,
        removeLicenceCmments
    ];

    if (options.noconflict) {
        filters.push(namespace(options.ns));
        if (options.exportModule)
            var exportFilter = exportAce(options.ns, options.exportModule, options.ns);
    } else if (options.exportModule) {
        var exportFilter = exportAce(options.ns, options.exportModule);
    }

    if (options.compress)
        filters.push(copy.filter.uglifyjs);

    var targetDir = options.targetDir + options.suffix;
    var name = options.name;

    var project = copy.createCommonJsProject(aceProject);
    var ace = copy.createDataObject();
    copy({
        source: [ACE_HOME + "/build_support/mini_require.js"],
        dest: ace
    });
    copy({
        source: [{
            project: project,
            require: options.requires
        }],
        filter: [ copy.filter.moduleDefines ],
        dest: ace
    });

    copy({
        source: ace,
        filter: exportFilter ? filters.concat(exportFilter) : filters,
        dest:   targetDir + '/' + name + ".js"
    });

    console.log('# ace modes ---------');

    project.assumeAllFilesLoaded();
    options.modes.forEach(function(mode) {
        console.log("mode " + mode);
        copy({
            source: [{
                project: cloneProject(project),
                require: [ 'ace/mode/' + mode ]
            }],
            filter: filters,
            dest:   targetDir + "/mode-" + mode + ".js"
        });
    });

    console.log('# ace themes ---------');

    project.assumeAllFilesLoaded();
    options.themes.forEach(function(theme) {
        console.log("theme " + theme);
        /*copy({
            source: [{
                project: cloneProject(project),
                require: ["ace/theme/" + theme]
            }],
            filter: filters,
            dest:   targetDir + "/theme-" + theme + ".js"
        });*/
        // use this instead, to not create separate modules for js and css
        var themePath = ACE_HOME + "/lib/ace/theme/" + theme
        var js = fs.readFileSync(themePath + ".js", "utf8");
        js = js.replace("define(", "define('ace/theme/" + theme + "', ['require', 'exports', 'module', 'ace/lib/dom'], ");
        
        if (fs.existsSync(themePath + ".css", "utf8")) {
            var css = fs.readFileSync(themePath + ".css", "utf8")
            js = js.replace(/require\(.ace\/requirejs\/text!.*?\)/, quoteString(css))
        }
        filters.forEach(function(f) {js = f(js); });
        
        fs.writeFileSync(targetDir + "/theme-" + theme + ".js", js); 
    });

    console.log('# ace key bindings ---------');

    // copy key bindings
    project.assumeAllFilesLoaded();
    options.keybindings.forEach(function(keybinding) {
        copy({
            source: [{
                project: cloneProject(project),
                require: [ 'ace/keyboard/' + keybinding ]
            }],
            filter: filters,
            dest: targetDir + "/keybinding-" + keybinding + ".js"
        });
    });

    console.log('# ace worker ---------');
    
    filters = [
        copy.filter.moduleDefines,
        filterTextPlugin,
        removeUseStrict,
        removeLicenceCmments
    ];

    options.workers.forEach(function(mode) {
        console.log("worker for " + mode + " mode");
        var worker = copy.createDataObject();
        var workerProject = copy.createCommonJsProject({
            roots: [ ACE_HOME + '/lib' ],
            textPluginPattern: /^ace\/requirejs\/text!/
        });
        copy({
            source: [{
                project: workerProject,
                require: [
                    'ace/lib/fixoldbrowsers',
                    'ace/lib/event_emitter',
                    'ace/lib/oop',
                    'ace/mode/' + mode + '_worker'
                ]
            }],
            filter: filters,
            dest: worker
        });
        copy({
            source: [
                ACE_HOME + "/lib/ace/worker/worker.js",
                worker
            ],
            filter: options.compress ? [copy.filter.uglifyjs] : [],
            dest: targetDir + "/worker-" + mode + ".js"
        });
    });

}
Example #26
0
function demo() {
    console.log('# kitchen sink ---------');

    var version, ref;
    try {
        version = JSON.parse(fs.readFileSync(ACE_HOME + "/package.json")).version;
        ref = fs.readFileSync(ACE_HOME + "/.git-ref").toString();
    } catch(e) {
        ref = "";
        version = "";
    }
    var changeComments = function(data) {
            return (data
                .replace(/<!\-\-DEVEL[\d\D]*?DEVEL\-\->/g, "")
                .replace(/PACKAGE\-\->|<!\-\-PACKAGE/g, "")
                .replace(/\/\*DEVEL[\d\D]*?DEVEL\*\//g, "")
                .replace(/PACKAGE\*\/|\/\*PACKAGE/g, "")
                .replace("%version%", version)
                .replace("%commit%", ref)
            );
        }

    copy({
        source: ACE_HOME + "/kitchen-sink.html",
        dest:   BUILD_DIR + "/kitchen-sink.html",
        filter: [changeComments,  function(data) {
            return data.replace(/"(demo|build)\//g, "\"");
        }]
    });

    copy({
        source: ACE_HOME + "/demo/kitchen-sink/styles.css",
        dest:   BUILD_DIR + "/kitchen-sink/styles.css",
        filter: [ changeComments ]
    });

    fs.readdirSync(ACE_HOME +"/demo/kitchen-sink/docs/").forEach(function(x) {
        copy({
            source: ACE_HOME +"/demo/kitchen-sink/docs/" + x,
            dest:   BUILD_DIR + "/kitchen-sink/docs/" + x
        });
    });

    var demo = copy.createDataObject();
    copy({
        source: ACE_HOME + "/demo/kitchen-sink/demo.js",
        dest: demo,
        filter: [changeComments, function(data) {
            return data.replace(/"(demo|build)\//g, "\"");
        }, function(data) {
            return data.replace("define(", "define('kitchen-sink/demo',");
        }]
    });
    copy({
        source: ACE_HOME + "/lib/ace/split.js",
        dest: demo,
        filter: [changeComments, function(data) {
            return data.replace("define(", "define('ace/split',");
        }]
    });
    copy({
        source: demo,
        dest:   BUILD_DIR + "/kitchen-sink/demo.js",
    });

    copyFileSync(ACE_HOME + "/demo/kitchen-sink/logo.png", BUILD_DIR + "/kitchen-sink/logo.png");
}
Example #27
0
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

var copy = require('dryice').copy;

var aceHome = __dirname;

console.log('# ace ---------');

var project = copy.createCommonJsProject([
    aceHome + '/support/pilot/lib',
    aceHome + '/lib',
    aceHome + '/demo'
]);

copy({
    source: "build_support/editor.html",
    dest: 'build/editor.html'
});

var ace = copy.createDataObject();
copy({
    source: [
        'build_support/mini_require.js'
    ],
    dest: ace
});
Example #28
0
    copy({
        source: "build_support/editor.html",
        dest:   targetDir + '/editor.html'
    });
} else if(target == "bm") {
    copy({
        source: "build_support/editor_textarea.html",
        dest:   targetDir + '/editor.html'
    });
    copy({
        source: "build_support/style.css",
        dest:   targetDir + '/style.css'
    });
}

var project = copy.createCommonJsProject(aceProject);


function filterTextPlugin(text) {
    return text.replace(/(['"])text\!/g, "$1text/");
    /*return text
        .replace(/define\(\s*['"]text\!\)/g, "text/")
        .replace(/require\(\s*['"]text\!\)/g, "text/")*/
}

var ace = copy.createDataObject();
copy({
    source: [
        target == "normal"
            ? 'build_support/mini_require.js'
            : 'build_support/mini_require_textarea.js'