{"id":20244521,"url":"https://github.com/retailmenotsandbox/roux","last_synced_at":"2025-04-10T20:47:14.776Z","repository":{"id":11027610,"uuid":"67539606","full_name":"RetailMeNotSandbox/roux","owner":"RetailMeNotSandbox","description":"Specification and SDK for Roux component architecture","archived":false,"fork":false,"pushed_at":"2022-12-11T04:32:07.000Z","size":1220,"stargazers_count":5,"open_issues_count":29,"forks_count":2,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-09T11:51:26.043Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RetailMeNotSandbox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-06T19:23:08.000Z","updated_at":"2020-08-26T05:00:02.000Z","dependencies_parsed_at":"2023-01-13T16:17:43.660Z","dependency_job_id":null,"html_url":"https://github.com/RetailMeNotSandbox/roux","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RetailMeNotSandbox%2Froux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RetailMeNotSandbox%2Froux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RetailMeNotSandbox%2Froux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RetailMeNotSandbox%2Froux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RetailMeNotSandbox","download_url":"https://codeload.github.com/RetailMeNotSandbox/roux/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248295458,"owners_count":21080107,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T09:15:46.688Z","updated_at":"2025-04-10T20:47:14.748Z","avatar_url":"https://github.com/RetailMeNotSandbox.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @retailmenot/roux\n\nThe SDK for the Roux component architecture, Roux ingredient spec, and a node interface to a pantry.\n\n[![Build Status](https://travis-ci.org/RetailMeNotSandbox/roux.svg?branch=master)](https://travis-ci.org/RetailMeNotSandbox/roux) [![Coverage Status](https://coveralls.io/repos/github/RetailMeNotSandbox/roux/badge.svg?branch=master)](https://coveralls.io/github/RetailMeNotSandbox/roux?branch=master)\n\n## Installation\n\n```sh\nnpm install @retailmenot/roux\n```\n\n## Usage\n\n```javascript\nvar roux = require('@retailmenot/roux');\n\nvar pantry = roux.initialize({\n  name: 'my-pantry',\n  path: 'path/to/my/pantry',\n  predicates: {\n    less: /^index.less$/\n  }\n});\n```\n\n## API\n\n### `initialize`\n\nInitialize a `Pantry` instance for a pantry of ingredients. This method returns\na promise of the initialized instance and also accepts an optional Node.js-style\ncallback that can be used in lieu of the promise.\n\n- `config` - Configuration object for the `Pantry` instance\n    - `name` - the name of the pantry\n    - `path` - the path to the pantry\n    - `[predicates]` - optional object of entry point predicates which will be\n      checked against the files contained in each ingredient in the pantry\n- `[callback]` - Optional Node.js callback\n\n#### Relocating the ingredients base directory\n\nThe pantry `path` will always be given as the path to the root directory of the\nmodule. To support better dev ergonomics and allow for more control of project\nstructure, pantry authors may optionally specify a subdirectory to use as the\nbase path for ingredients by supplying the `roux.pantryRoot` property in the\npantry modules' `package.json` file.\n\n#### Entry point predicates\n\nEntry point predicates are the mechanism for discovering the entry points an\ningredient exposes. For each predicate, every `Ingredient` instance in the\npantry will have a corresponding property in their `entryPoints` map. The value\nof the property will be an object if the predicate matched a file in the\ningredient and `null` otherwise. Predicates for several common entry points are\nprovided by default.\n\nFor example, given an ingredient containing the following files:\n\n```\n- ingredient.md\n- index.js\n- index.hbs\n```\n\nThe `entryPoints` map might look like:\n\n```javascript\n{\n  handlebars: {\n    filename: 'index.hbs'\n  },\n  javaScript: {\n    filename: 'index.js'\n  },\n  model: null,\n  preview: null,\n  previewScript: null,\n  sass: null\n}\n```\n\nPredicates may be functions or regular expressions (`RegExp` instances). The\npredicate will be tested against each file in the root of each ingredient until\neither a match is found or all files have been checked.\n\nFunction predicates are passed the name of the file to be checked as their only\nargument. If the predicate can decide synchronously, it should return `true` if\nthe file matches and `false` otherwise.  If the predicate cannot decide\nsynchronously, it should return a promise that will be resolved to `true` if the\nfile matches and `false` otherwise.\n\n##### Default predicates\n\nThe following predicates are configured by default:\n\n- `assets` - `/^assets$/`\n- `handlebars` - `/^index.hbs$/`\n- `javaScript` - `/^index.js$/`\n- `model` - `/^model.js$/`\n- `preview` - `/^preview.hbs$/`\n- `previewScript` - `/^preview.js$/`\n- `sass` - `/^index.scss$/`\n\n### `Pantry`\n\nInstances of this class represent a pantry of Roux ingredients. They have the\nfollowing properties:\n\n- `name` - the name of the pantry\n- `path` - the path to the pantry\n- `ingredients` - an object mapping from the name of each ingredient in the\n  pantry to a corresponding `Ingredient` instance\n\n### `Ingredient`\n\nInstances of this class represent a Roux ingredient. They have the following\nproperties:\n\n- `name` - the name of the ingredient\n- `path` - the path to the ingredient\n- `pantryName` - the name of the pantry this ingredient belongs to\n- `entryPoints` - an object mapping from the name of a logical entry point\n  ('sass', e.g.) to an object describing the entry point as provided by the\n  ingredient or `null` if the ingredient does not provide it\n\n#### `entryPoints`\n\nThe properties of this object are either `null` or an object with the following\nproperties:\n\n- `filename`: the name of the file the ingredient provides for this entry point\n\n### `parseIngredientPath`\n\nParse the pantry and ingredient names out of an ingredient path. If passed a\nvalid Roux ingredient path, this function returns an object with the pantry and\ningredient names:\n\n- `pantry` - the name of the pantry, possibly including a namespace\n- `ingredient` the name of the ingredient\n\nIf passed a string that is not a valid path, it returns `null`. If passed\nanything else, it throws an `Error`.\n\n### `resolve`\n\nResolve a pantry or ingredient to an instance or an entry point to an absolute\npath to the corresponding file.\n\nIf passed a valid pantry name, this function returns a promise of the\ncorresponding `Pantry` instance. If passed valid names of a pantry and\ningredient, it returns a promise of the corresponding `Ingredient` instance. If\npassed valid names of a pantry, ingredient, and entry point, it returns a\npromise of the absolute path to the corresponding entry point file. In all of\nthese cases, an optional configuration object can be passed as the last\nargument.\n\nIf passed invalid names, it throws an error. If the pantry, ingredient, or entry\npoint cannot be found, the returned promise is rejected with an error.\n\n- `pantry`: pantry name\n- `ingredient` - optional ingredient name\n- `entryPoint` - optional entry point name\n- `config` - optional configuration object\n- `config.pantries` - a cache of `Pantry` instances\n- `config.pantrySearchPaths` - the paths to search for pantries in if not found\n    in the cache\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fretailmenotsandbox%2Froux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fretailmenotsandbox%2Froux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fretailmenotsandbox%2Froux/lists"}