# project-template

> Generate a project based on a directory of template files and corresponding template values

Latest version **1.1.1** (published 2017-04-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install project-template
pnpm add project-template
yarn add project-template
bun add project-template
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2017-04-09 |
| First published | 2017-04-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Aiham Hammami |
| Maintainers | aiham |
| Keywords | generate, project, template, directory |

## Links

- npm: https://www.npmjs.com/package/project-template
- Repository: https://github.com/aiham/project-template
- Homepage: https://github.com/aiham/project-template#readme
- Issues: https://github.com/aiham/project-template/issues
- npm.io page: https://npm.io/package/project-template

## Dependencies (4)

- [ect](https://npm.io/package/ect.md) ^0.5.9
- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [recursive-readdir](https://npm.io/package/recursive-readdir.md) ^2.1.1

## Recent versions

- 1.1.1 (latest) — 2017-04-09
- 1.1.0 — 2017-04-09
- 1.0.3 — 2017-04-06
- 1.0.2 — 2017-04-06
- 1.0.1 — 2017-04-06
- 1.0.0 — 2017-04-06

## README

# project-template

[![npm version](https://badge.fury.io/js/project-template.svg)](https://badge.fury.io/js/project-template)

Generate a project based on a directory of template files and corresponding template values.

## Requirements

- Node JS v6+

## Install

```sh
yarn add project-template
```

## Example

```sh
yarn run example
```

See [example/index.js](example/index.js)

## Usage

```js
const projectTemplate = require('project-template');

projectTemplate({
  templatePath: '/path/to/templates',
  buildPath: '/path/to/build',
  params: {
    'path/to/file.txt': {
      firstParam: 'First param value',
      secondParam: 'Second param value',
    },
    'path/to/different/file.txt': {
      anotherParam: 'Another param value',
    },
  },
})
.then(files => console.log('Done', files))
.catch(err => console.error('Error', err));
```

## Things to keep in mind

- Template files are expected to use [ect](https://github.com/baryshev/ect) syntax
- Directory structure of files in `templatePath` is maintained in `buildPath`
- All files in `templatePath` with `fileExtension` must be included in `params`
- Files in `templatePath` without `fileExtension` are just copied over to `buildPath`
- You cannot have two files with the same file path where one has `fileExtension` and the other doesn't

## API

### projectTemplate(options) -&gt; Promise&lt;Array&lt;String&gt;&gt;

#### options

| Key | Type | Required | Default | Notes |
| --- | --- | --- | --- | --- |
| templatePath | String | Yes | | Directory path containing template files |
| buildPath | String | Yes | | Directory path to write generated files to |
| params | Object | No | `{}` | Keys are relative paths of template files (with `fileExtension` stripped). Values are objects of template variables |
| ignoreFiles | Array&lt;String&gt; | No | `[]` | File paths to ignore (exclude the `fileExtension` for template files). Useful for [ect partials](https://github.com/baryshev/ect#partials) |
| fileExtension | String | No | `ect` | File extension of template files |

#### Result

The promise is resolved with an array of file paths of generated files, relative to the `buildPath` directory.

---
_Source: https://npm.io/package/project-template · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
