npm.io
1.1.0 • Published 10 years ago

engine-app

Licence
MIT
Version
1.1.0
Deps
6
Vulns
0
Weekly
0

engine-app Version Downloads

Engine app related helper functions.

Installation

$ npm i --save engine-app

Example

const EngineApp = require("engine-app");

// Initialize the app
var myApp = new EngineApp(__dirname + "/example-app");

// Create the package
myApp.setPackage({
    name: "example-app"
})

console.log(myApp.getPackage());
// => { name: 'example-app' }

// Create the layout instance
myApp.createInstance("layout", (err, data) => {

    // Read the layout instance
    myApp.readInstance("layout", (err, data) => {
        console.log(err || data);
        // => { name: 'layout' }
    });
});

Documentation

EngineApp(adapter)

Creates a new instance of EngineApp.

Params
  • String|CompositionAdapter adapter: The path to the application or the adapter object.
getPackage(cb)

Gets the package.json content.

Params
  • Function cb: The callback function.
Return
  • Object The package.json content as json (if called without a callback function).
setPackage(data, cb)

Sets the package.json content.

Params
  • Object data: The data to set in the file.
  • Function cb: The callback function.
getModulePackage(name)

Reads the module package.json file.

Params
  • String name: The module name.
Return
  • Object The package.json content as json (if called without a callback function).
setModulePackage(name, data)

Writes the module package.json file.

Params
  • String name: The module name.
  • Object data: The data to set in the file.
createInstance(name, data, cb)

Creates a new instance.

Params
  • String name: The instance name.
  • Object data: The instance content.
  • Function cb: The callback function.
readInstance(name, cb)

Gets the instance content.

Params
  • String name: The instance name.
  • Function cb: The callback function.
updateInstance(name, data, cb)

Updates an instance.

Params
  • String name: The instance name.
  • Object data: The instance content.
  • Function cb: The callback function.
removeInstance(name, cb)

Removes an instance.

Params
  • String name: The instance name.
  • Function cb: The callback function.
listInstance(cb)

listInstances List instances.

Params
  • Function cb: The callback function.
getAllnstances(cb)

getAllInstances Read all instances.

Params
  • Function cb: The callback function.
renameInstance(oldName, newName, cb)

Renames the specified instance.

Params
  • String oldName: The old instance name.
  • String newName: The new instance name.
  • Function cb: The callback function.
upsertInstance(name, data, cb)

Creates or updates the specified instance.

Params
  • String name: The instance name.
  • Object data: The instance content.
  • Function cb: The callback function.

How to contribute

Have an idea? Found a bug? See how to contribute.

Where is this library used?

If you are using this library in one of your projects, add it in this list.

License

MIT jillix

Keywords