• Stars
    star
    813
  • Rank 56,088 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 11 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Quickest way to get started with ampersand.

The Ampersand CLI

Part of the Ampersand.js toolkit for building client-side applications.

Lead Maintainer: Drew Fyock

The idea behind the CLI is not to solve all your problems and write all your code, but to help you with the tedious parts of building an app, which is what computers are supposed to help us with.

Installation

npm install -g ampersand

Starting a new app

Just, cd into whatever directory you normally put your projects in and just run ampersand.

The CLI will walk you through some basic questions, and kick out an app that runs out of the box.

It's meant to be a loose guide, not an edict. Just delete whatever isn't relevant.

Generating stuff

ampersand gen {{type}}

Type can be form, view, model or collection.

Generating models (from JSON)

You can use the CLI to generate a model and collection for that model. If you already know what the JSON is going to look like you can pipe it into the generator to create a model with matching properties.

On a Mac, if you've copied some JSON to your clipboard you can do this from anywhere within your project folder:

pbpaste | ampersand gen model MyModel

And it'll kick out two files in your models folder (which is configurable, see below):

my-model.js
my-model-collection.js

And it will create the properties in the JSON object as model properties.

Don't worry, nothing will be overwritten unless you use the the --force (or -f) option

Generating forms from models

You can also use a model to generate the starting point of a form-view for editing that model.

ampersand gen form ./path/to/your/model.js

It will create a form view in your /client/forms folder.

Nothing will be overwritten unless you use the the --force (or -f) option, so it's safe to just experiment.

Configuring the generated code

The cli looks for config options from a number of sources, starting with default, applying configs from a .ampersandrc in your home folder, then your project root, then by parsing option flags from stdin.

Those files can be JSON or ini format.

The available options and defaults are as follows:

  • framework: default framework to be prompted with, options are express or hapi
  • indent: indent size
  • view: default template
  • router: default template
  • model: default template
  • page: default template
  • collection: default template
  • clientfolder: name for the 'client' folder
  • viewfolder: name for the 'views' folder
  • pagefolder: name for the 'pages' folder
  • modelfolder: name for the 'models' folder
  • formsfolder: name for the 'forms' folder
  • collectionfolder: name for the collection folder - grouped with 'models' by default
  • makecollection: whether to create collection when making a model
  • approot: if called without the 'gen' command build a new one, so we won't look for an application root. starts walking up folders looking for package.json.
  • quotes: options are 'single' or 'double'

Sample JSON with default options

{
    "framework": "hapi",
    "indent": 4,
    "view": "",
    "router": "",
    "model": "",
    "page": "",
    "collection": "",
    "clientfolder": "client",
    "viewfolder": "views",
    "pagefolder": "pages",
    "modelfolder": "models",
    "formsfolder": "forms",
    "collectionfolder": "models",
    "makecollection": true,
    "approot": "",
    "quotes": "single"
}

License

MIT

More Repositories

1

ampersand-state

Core state management object.
JavaScript
141
star
2

amp

a collection of individual JS utility modules
HTML
133
star
3

ampersand-view

A smart base view for Backbone apps, to make it easy to bind collections and properties to the DOM.
JavaScript
91
star
4

ampersand-model

Observable objects, for managing state in applications.
JavaScript
84
star
5

ampersand-router

Clientside router with fallbacks for browsers that don't support pushState. Mostly lifted from Backbone.js.
JavaScript
70
star
6

ampersand-collection

A module for handling collections of objects
JavaScript
68
star
7

ampersandjs.com

The documentation site for ampersand.js
HTML
51
star
8

ampersand-react-mixin

Mixin for react classes to easily listen for changes and re-render from ampersand models/collections
JavaScript
45
star
9

examples

A collection of example apps/patterns using ampersand
JavaScript
45
star
10

ampersand-virtual-dom-mixin

JavaScript
33
star
11

ampersand-app

Proposed pattern for removing need for `app` global in ampersand apps (draft stage)
JavaScript
27
star
12

ampersand-form-view

Completely customizable form lib for bulletproof clientside forms.
JavaScript
26
star
13

ampersand-dom

Super light-weight DOM manipulation lib.
JavaScript
24
star
14

ampersand-rest-collection

ampersand-collection with REST and lodash mixins for easy use with REST APIs.
JavaScript
23
star
15

ampersand-view-switcher

A utility for swapping out views inside a container element.
JavaScript
23
star
16

ampersand-subcollection

Filterable, sortable, proxy of a collection that behaves like a collection.
JavaScript
21
star
17

ampersand-sync

Provides sync behavior for updating data from ampersand models and collections to the server.
JavaScript
20
star
18

ampersand-events

Standalone event system that can be mixed into any object
JavaScript
18
star
19

ampersand-dom-bindings

Takes binding declarations and returns key-tree-store of functions that can be used to apply those bindings.
JavaScript
18
star
20

ampersand-input-view

A view module for intelligently rendering and validating input. Works well with ampersand-form-view.
JavaScript
16
star
21

ampersand-registry

Global model registry for tracking instantiated models across collections.
JavaScript
12
star
22

ampersand-collection-view

Renders a collection with one view per model within an element in a way that cleans up and unbinds all views when removed.
JavaScript
12
star
23

ampersand-select-view

Select field for ampersand-form-views
JavaScript
11
star
24

tools.ampersandjs.com

Hand-picked tools for building ampersand apps. A grab bag of "solved problems" for single page apps.
JavaScript
11
star
25

ampersand-filtered-subcollection

Filterable, sortable, proxy of a collection that behaves like a collection.
JavaScript
11
star
26

ampersand-collection-rest-mixin

A mixin for extending ampersand-collection with restful methods.
JavaScript
8
star
27

ampersand-class-extend

JS class extension tool for enabling easily extending prototype with multiple objects.
JavaScript
7
star
28

ampersand-array-input-view

A view module for intelligently rendering and validating inputs that should produce an array of values. Works well with ampersand-form-view.
JavaScript
6
star
29

ampersand-view-conventions

Ampersand's view conventions. Also written as a test you can use to test if your module follows the conventions.
JavaScript
6
star
30

ampersand-devtools

JavaScript
6
star
31

ampersand-domthing-mixin

JavaScript
5
star
32

ampersand-paginated-subcollection

Filter an ampersand-collection by limit and offset
JavaScript
4
star
33

ampersand-collection-lodash-mixin

adds handy lodash methods to ampersand-collection
JavaScript
3
star
34

ampersand-collection-underscore-mixin

A mixin for extending ampersand-collection with underscore methods.
JavaScript
3
star
35

ampersand-webcam-snapshot-view

Helps a user take an avatar pic with their webcam.
JavaScript
2
star
36

ampersand-checkbox-view

A view module for intelligently rendering and validating checkbox input. Works well with ampersand-form-view.
JavaScript
2
star
37

object-sort

Sort an array of objects either by property, sort function, or comparator function.
JavaScript
2
star
38

ampersand-version

Versioning for ampersand-modules
JavaScript
1
star