@yisroel/one-way
v1.0.0
Published
generator using a geenee template
Downloads
2
Readme
code generator based on geenee metadata.
Why
A geenee template is normally used for multiple generation of code. To do that, geenee-spell stores a meta
directory within the generated code base to allow for regeneration.
But geenee templates are a very powerful tool for one-time creation as well. For instance, you may not want to include a meta
directory in your code.
What
A single async function that generates code from a specified geenee template and settings.
Usage
Import the package:
npm i one-way
Set the following in your code:
- codeDir: path to your codeBase to generate
- nsInfo: json containing settings for the generated code
- config: json containing the configuration from the template
- templateDir: the directory of the template
Then you can call:
const generateCode = require('one-way-ticket')
try {
await generateCode(
codeDir, nsInfo, config, templateDir
)
} catch (error) {
throw new Error(`could not generate the code: ${error}`)
}
Example
Check out the usage in geenee-spell.
Creating Templates
You can create such a template easily from a code base using copykat, or just by following the steps for creating templates.
API
async function generateCode(
codeDir: string,
nsInfo: NsInfo,
config: Configuration,
templateDir: string,
)
The NsInfo
and Configuration
types are exposed in magicalstrings.