Source: apc-abstract-heir/Apemanfile.js

/**
 * @file Apeman app configuration file.
 * @namespace apemanfile
 * @param {object} apeman - Apeman module.
 * @returns {object} - An apeman file object.
 * @see {@link http://www.npmjs.org/package/apeman | apeman}
 * @author Taka Okunishi
 *
 */
var path = require('path');
module.exports = function (apeman) {
    var cwd = process.cwd();
    process.chdir(__dirname);

    var Apemanfile = apeman.ApemanfileObject,
        defineChainable = Apemanfile.defineChainable,
        prototypePath = apeman.findupApp('apc-abstract'),
        prototype = require(prototypePath)(apeman),
        basedir = __dirname;


    // Helper modules
    var prototypeHelper = prototype.helper();
    var h = prototypeHelper.fallbackCopy(prototypeHelper, {
        lookupPaths: [basedir].concat(prototypeHelper.lookupPaths),
        Symlink: defineChainable({_type: 'symlink'}, ['src']),
        /**
         * Create a new Symlink object
         * @function apemanfile.helper.newSymlink
         * @returns {object} - A symlink object
         */
        newSymlink: function (src) {
            return new h.Symlink().src(src);
        },
        toUniqueArray: function (array) {
            var filter = require('./lib/array').newUniqueFilter();
            return [].concat(array || []).filter(filter);
        },
        /**
         * Create lib modules structure data.
         * @function apemanfile.helper.libModulesData
         * @param {string[]} names - Lib modules data.
         * @returns {object} - Module structure data.
         */
        libModulesStructureData: function (names) {
            var data = {};
            names.forEach(function (name) {
                data[name] = {
                    '_prototype.js': h.newPrototypeJsFile({
                        exportsName: 'lib.' + name,
                        lookupPath: 'lib/' + name
                    })
                };
            });
            return data;
        }
    });

    // Add helper functions if _apemanfile_helper.js found.
    h.loadLocalHelperFile();

    var meta = {
        name: "apc-abstract-heir",
        description: "Direct heir of the apc-abstract app.",
        version: h.readLocalVERSION() || '0.0.0',
        repository: 'https://github.com/apeman-apps/apc-abstract-heir.git',
        author: {
            name: "Taka Okunishi",
            email: "okunishinishi@apeman.info"
        }
    };


    var libData = h.libModulesStructureData(['array', 'env', 'file', 'log', 'object', 'string']);


    /**
     * File system structure data.
     * An empty object represent a directory.
     * @type object
     * @private
     */
    var structureData = {
        task: {
            worker: {
                '_debug.js': h.newWorkerDebugJsFile().force(false).mode('644'),
                '_prototype.js': h.newPrototypeJsFile({
                    exportsName: 'task.worker',
                    lookupPath: 'task/worker'
                })
            }
        },
        lib: libData,
        '_apemanfile_helper.js': h.newApemanfileHelperJsFile(h.apemanHelperData),
        test: {
            unit_tests: {
                task: {
                    worker: {
                        '_debug_test.js': h.newWorkerDebugTestJsFile().force(false).mode('644')
                    }
                },
                'dependencies_test.js': h.newDependenciesTestJsFile().force(false).mode('644')
            }
        }
    };

    /**
     * Packages installed by npm.
     * @type object
     * @private
     */
    var nodePackages = {

    };

    /**
     * Packages installed by npm for development user.
     * @type {object}
     * @private
     */
    var nodePackages$dev = {

    };

    var prototypeTasks = prototype.tasks();


    var tasks = {
        structure: {
            config: {
                data: structureData
            }
        },
        inheritTemplates: h.inheritTemplatesTask({
            pattern: [
                'tmpl/**/*.hbs'
            ],
            ignore: [
                '_*/**'
            ]
        }),
        inherit: [
            'inheritTemplates'
        ],
        generateApemanHelperData: h.generateApemanHelperDataTask({
            dest: '.apemanhelperdata'
        }),
        build: prototypeTasks.build.concat([
            'inherit',
            'generateApemanHelperData'
        ]),
        index: prototypeTasks.index.concat([

        ]),
        installNodePackages: {
            config: {
                packages: nodePackages
            }
        },
        installNodeDevPackages: {
            config: {
                packages: nodePackages$dev
            }
        },
        install: prototypeTasks.install.concat([
            'inherit'
        ]),
        test: prototypeTasks.test.concat([

        ]),
        generateApiguide: {
            config: {
                src: prototypeTasks.generateApiguide.config.src
                    .map(function (filename) {
                        return path.resolve(path.dirname(prototypePath), filename);
                    })
                    .concat([
                        path.resolve('lib/**/*.js'),
                        path.resolve('task/**/*.js'),
                        path.resolve('README.md'),
                        path.resolve('Apemanfile.js'),
                        path.resolve('_apemanfile_helper.js')
                    ]),
                // Available themes:
                // [ "amelia","cerulean","cosmo","cyborg","flatly","journal","readable",
                //   "simplex","slate","spacelab","spruce","superhero","united"]
                theme: 'cerulean'
            }
        },
        doc: prototypeTasks.doc.concat([

        ])
    };

    //Create a new apeman file object.
    var apemanfile = new Apemanfile(
        prototype
    ).set({
            basedir: basedir,
            prototypePath: prototypePath,
            meta: meta,
            tasks: tasks,
            helper: h
        });

    process.chdir(cwd);
    return  apemanfile;
};