Local config
A local config is a blueprintor.config.js file in the root of your workspace. It is the right place for blueprints that belong to a project, can be committed to the repository, and are marked with 📦 in the blueprint list.
Where to put it
Section titled “Where to put it”Directoryyour-project/
- blueprintor.config.js
- src
- package.json
Format
Section titled “Format”The file is loaded with require, so it must be a CommonJS module that exports an object with a blueprints array:
module.exports = { blueprints: [ // blueprints, see the API reference ],};The shape of each blueprint is described in the API reference.
- The file is re-read on every run. Edit it and run the command again, no reload needed. Other project files loaded from it with
requireare re-read too (modules innode_modulesare not). - It is real JavaScript, so you can use constants, functions and
requirefor other modules. export default(ESM) is not supported. If the file fails to load, a warning with the error message is shown.- Inside a template literal, line breaks are written as plain line breaks, no
\nneeded.
Example
Section titled “Example”Shared constants and multi-line content are the main reasons to prefer a local config:
const license = `// Written with love and a lot of coffee.`;
module.exports = { blueprints: [ { title: "Utility function", variables: [{ key: "name", prompt: "Function name" }], snippets: { util: `${license}
// {name.raw}export function brew{name.pascal}() { // TODO: Add espresso shot and milk}`, }, structure: { files: [{ name: "{name.camel}.ts", snippet: "util" }], }, }, ],};Run it on src/utils and enter format date:
Directorysrc
Directoryutils
- brewCappuccino.ts
// Written with love and a lot of coffee.
export function brewCappuccino() { // TODO: Add espresso shot and milk}Leading and trailing whitespace of a text is trimmed, so the blank first line of the template literal does not end up in the file.
Priority
Section titled “Priority”If a global blueprint has the same title, the local one replaces it. Details are in API reference.