1.0.2 • Published 8 years ago
@tandemploy/static v1.0.2
About
Create an Angular2 module and its components from a configuration object, at build time
Dependencies
This package requires node 6 or higher
Installation
npm install @tandemploy/static
Usage
From a package.json script entry :
tploy-static [--configPath path]
Arguments
configPath
Where to find the configuration for the module's generator ?
It defaults to {projectRoot}/tploy-static.config.js
Configuration
const conf = {
modules: [ // list of module specific configurations
{
className: 'CustomizationModule', // Name for the module class
fileName: 'customization.module.ts', // Name of the file in which the module is generated
modulePath: './src/customization', // Where to generate the module ? Relative paths are relative to the root directory of the project
templatePath: './tploy/templates/module.template', // location of the template used to generate the module file
assetsPath: './server/assets', // assets endpoint from which the components' template will be fetched either from local file system or http(s) protocols (file:// is not yet supported)
components: [ // the components to be generated for this module
{
templatePath: './tploy/templates/component.template', // location of the template used to generate the component file
selector: 'faq-en', // the selector with which this component will be created
htmlPath: 'templates/en/faq.tpl.html', // the path to the HTML template, relative to the _assetsPath_ defined in the module configuration
className: 'FaqEnComponent', // Name for the component class
fileName: 'faq-en.component.ts' // Name for the component file
},
{
...
},
...
]
},
{
...
}
]
};
module.exports = conf;
Notes on template files
Template files are used as seeds for both the module file and the components file. They rely on placeholders to be replaced by configuration entries.
Template files must have the .template extension as node is configured to import such files as raw text.
The placeholders can be found in the respective exemple files at module.template component.template