This package has been deprecated

Author message:

renamed project to fixturify-project

node-fixturify-project

1.2.0 • Public • Published

node-fixturify-project

Build Status Build status

A complementary project to node-fixturify

When implementing JS build tooling it is common to have complete projects as fixture data. Unfortunately fixtures commited to disk can be somewhat to maintain and augment.

The node-fixturify library is a great way to co-locate tests and their file system fixture information. This project embraces node-fixturify, but aims to reduce the verbosity when building graphs of node modules and dependencies.

Usage

yarn add node-fixturify-project
const Project = require('fixturify-project');
const project = new Project('rsvp', '3.1.4');

project.addDependency('mocha', '5.2.0');
project.addDependency('chai', '5.2.0');

project.addFile('index.js', 'module.exports = "Hello, World!"');

project.writeSync('some/root/');

Which the following files (and most importantly the appropriate file contents:

some/root/rsvp/package.json
some/root/rsvp/index.js
some/root/rsvp/node_modules/mocha/package.json
some/root/rsvp/node_modules/chai/package.json

One can also produce JSON, which can be used directly by node-fixturify:

// continued from above
const fixturify = require('fixturify');

fixturify.writeSync('some/other/root', project.toJSON());

Adanced

Obviously nested dependencies are common, and are not only supported but somewhat ergonomics:

const Project = require('node-fixturify-project');
const project = new Project('rsvp', '3.1.4');

// version 1
project.addDependecy('a', '1.2.3', a => a.addDependency('d', '3.2.1'));

// version 2
let b = project.addDependecy('b', '3.2.3');
let c = b.addDependency('c', '4.4.4');

// and this works recurisively:
let e = c.addDependency('e', '5.4.4');

project.writeSync('some/root/');

Which produces:

some/root/rsvp/package.json
some/root/rsvp/index.js
some/root/rsvp/node_modules/a/package.json
some/root/rsvp/node_modules/a/node_modules/d/package.json
some/root/rsvp/node_modules/b/package.json
some/root/rsvp/node_modules/b/node_modules/c/package.json
some/root/rsvp/node_modules/b/node_modules/c/node_modules/e/package.json

Other API

  • Project.fromJSON(json, name) consume a given project from JSON
  • Project.fromDir(root, name) consume a given project from disk, assuming it has been written to by Project.prototype.writeSync(root);
  • Project.prototype.clone() deep clone a given project
  • Project.prototype.readSync(root) assumes the state of the given root (symmetrical to Project.prototype.writeSync(root))
  • Project.prototype.writeSync(root) writes the project to disk at root
  • Project.prototype.addDependency(name, version) add a dependency to the given project
  • Project.prototype.addDevDependency(name, version) add a devDependency to the given project

Readme

Keywords

none

Package Sidebar

Install

npm i node-fixturify-project

Weekly Downloads

0

Version

1.2.0

License

MIT

Unpacked Size

22.2 kB

Total Files

7

Last publish

Collaborators

  • krisselden
  • rwjblue
  • stefanpenner