Project - ember-cli

The Project model is tied to your package.json. It is instantiated by giving closestSync the path to your project.

Static Method Summary

Static Public Methods
public static

Returns the project root based on the first package.json that is found

Static Private Methods
private static

closestSync(pathName, _ui): Project

Returns a new project based on the first package.json that is found in pathName.

private static

Returns a new project based on the first package.json that is found in pathName, or the nullProject.

Constructor Summary

Public Constructors
public

Project(root, pkg, ui, cli)

The Project model is tied to your package.json. It is instantiated by giving closestSync the path to your project.

Property Summary

Public Properties
public

targets: Unknown

Returns the targets of this project, or the default targets if not present.

Private Properties
private

_watchmanInfo: Unknown

Set when the Watcher.detectWatchman helper method finishes running, so that other areas of the system can be aware that watchman is being used.

Method Summary

Public Methods
public

config(env): Object

Loads the configuration for this project and its addons.

public

Find an addon by its name

public

generateTestFile(moduleName, tests): String

Generate test file contents.

public

Returns whether or not this is an Ember CLI addon.

public

require(file): Object

Calls require on a given module from the context of the project. For instance, an addon may want to require a class from the root project's version of ember-cli.

Private Methods
private

Returns a list of addon paths where blueprints will be looked up.

private

Returns what commands are made available by addons by inspecting includedCommands for every addon.

private

Returns a list of paths (including addon paths) where blueprints will be looked up.

private

Returns the path to the configuration.

private
private

dependencies([pkg=this.pkg], [excludeDevDeps=false]): Object

Returns the dependencies from a package.json

private

discoverAddons( )

Discovers all addons for this project and stores their names and package.json contents in this.addonPackages as key-value pairs.

private

eachAddonCommand(callback)

Execute a given callback for every addon command. Example:

private

getAddonsConfig(env, appConfig): Object

Returns the addons configuration.

private

has(file): Boolean

Returns whether or not the given file name is present in this project.

private

Loads and initializes all addons for this project.

private

Returns whether or not this is an Ember CLI project. This checks whether ember-cli is listed in devDependencies.

private

Path to the blueprints for this project.

private

name( ): String

Returns the name from package.json.

private

reloadAddons( )

Re-initializes addons.

private

Reloads package.json of the project. Clears and reloads the packageInfo and per-bundle addon cache, too.

private

Resolves the absolute path to a file synchronously

private

Provides the list of paths to consult for addons that may be provided internally to this project. Used for middleware addons with built-in support.

Static Public Methods

Returns the project root based on the first package.json that is found

Return:

String

The project root directory

Static Private Methods

Returns a new project based on the first package.json that is found in pathName.

If the above package.json specifies ember-addon.projectRoot, we load the project based on the relative path between this directory and the specified projectRoot.

Parameters:

Name Type Attribute Description
pathName String

Path to your project

_ui UI

The UI instance to provide to the created Project.

Return:

Returns a new project based on the first package.json that is found in pathName, or the nullProject.

The nullProject signifies no-project, but abides by the null object pattern

Parameters:

Name Type Attribute Description
_ui UI

The UI instance to provide to the created Project.

Return:

Public Constructors

Parameters:

Name Type Attribute Description
root String

Root directory for the project

pkg Object

Contents of package.json

ui UI
cli CLI

Public Properties

Returns the targets of this project, or the default targets if not present.

Private Properties

Set when the Watcher.detectWatchman helper method finishes running, so that other areas of the system can be aware that watchman is being used.

For example, this information is used in the broccoli build pipeline to know if we can watch additional directories "cheaply".

Contains enabled and version.

Public Methods

Loads the configuration for this project and its addons.

Parameters:

Name Type Attribute Description
env String

Environment name

Return:

Object

Merged configuration object

Find an addon by its name

Parameters:

Name Type Attribute Description
name String

Addon name as specified in package.json

Return:

Generate test file contents.

This method is supposed to be overwritten by test framework addons like ember-qunit.

Parameters:

Name Type Attribute Description
moduleName String

Name of the test module (e.g. JSHint)

tests Object[]

Array of tests with name, passed and errorMessage properties

Return:

String

The test file content

Returns whether or not this is an Ember CLI addon.

Return:

Boolean

Whether or not this is an Ember CLI Addon.

Calls require on a given module from the context of the project. For instance, an addon may want to require a class from the root project's version of ember-cli.

Parameters:

Name Type Attribute Description
file String

File path or module name

Return:

Private Methods

Returns a list of addon paths where blueprints will be looked up.

Return:

Returns what commands are made available by addons by inspecting includedCommands for every addon.

Return:

Object

Addon names and command maps as key-value pairs

Returns a list of paths (including addon paths) where blueprints will be looked up.

Return:

Returns the path to the configuration.

Return:

String

Configuration path

Parameters:

Name Type Attribute Description
env String

Environment name

Return:

Object

Merged configuration object

Returns the dependencies from a package.json

Parameters:

Name Type Attribute Description
pkg Object
  • optional
  • default: this.pkg

Package object

excludeDevDeps Boolean
  • optional
  • default: false

Whether or not development dependencies should be excluded

Return:

Discovers all addons for this project and stores their names and package.json contents in this.addonPackages as key-value pairs.

Any packageInfos that we find that are marked as not valid are excluded.

Execute a given callback for every addon command. Example:

project.eachAddonCommand(function(addonName, commands) {
  console.log('Addon ' + addonName + ' exported the following commands:' + commands.keys().join(', '));
});

Parameters:

Name Type Attribute Description
callback Function

[description]

Returns the addons configuration.

Parameters:

Name Type Attribute Description
env String

Environment name

appConfig Object

Application configuration

Return:

Object

Merged configuration of all addons

Returns whether or not the given file name is present in this project.

Parameters:

Name Type Attribute Description
file String

File name

Return:

Boolean

Whether or not the file is present

Loads and initializes all addons for this project.

Returns whether or not this is an Ember CLI project. This checks whether ember-cli is listed in devDependencies.

Return:

Boolean

Whether this is an Ember CLI project

Path to the blueprints for this project.

Return:

String

Path to blueprints

Returns the name from package.json.

Return:

Reloads package.json of the project. Clears and reloads the packageInfo and per-bundle addon cache, too.

Return:

Resolves the absolute path to a file synchronously

Parameters:

Name Type Attribute Description
file String

File to resolve

Return:

String

Absolute path to file

Provides the list of paths to consult for addons that may be provided internally to this project. Used for middleware addons with built-in support.