lib/utilities/windows-admin.js:7

WindowsSymlinkChecker

On windows users will have a much better experience if symlinks are enabled an usable. This object when queried informs windows users, if they can improve there build performance, and how.

Windows vista: nothing we can really do, so we fall back to junctions for folders + copying of files <= Windows vista: symlinks are available but using them is somewhat tricky * if the users is an admin, the process needed to have been started with elevated privs * if the user is not an admin, a specific setting needs to be enabled <= Windows 10 Insiders build 14972 * if developer mode is enabled, symlinks "just work" * https://blogs.windows.com/buildingapps/2016/12/02/symlinks-windows-10

 let checker = WindowsSymlinkChecker;
 let {
   windows,
   elevated
 } = await = checker.checkIfSymlinksNeedToBeEnabled(); // aslso emits helpful warnings

Method Summary

Public Methods
public
calculateBaseTag(baseURL, locationType): String

Returns the tag for index.html.

public
checkIfSymlinksNeedToBeEnabled( ): Promise

if not windows, will fulfill with: { windows: false, elevated: null) if windows, and elevated will fulfill with: { windows: false, elevated: true) if windows, and is NOT elevated will fulfill with: { windows: false, elevated: false) will include heplful warning, so that users know (if possible) how to achieve better windows build performance

public
public
contentFor(config, mathch, type, options): String

Returns the content for a specific type (section) for index.html.

public

Converts Javascript Object to a string. Returns an empty object string representation if a "falsy" value is passed in.

public
insertIntoFile(pathRelativeToProjectRoot, contentsToInsert, providedOptions): Promise

Inserts the given content into a file. If the contentsToInsert string is already present in the current contents, the file will not be changed unless force option is passed.

public

Returns a normalized url given a string. Returns an empty string if null, undefined or an empty string are passed in.

public

Sets up listeners for interruption signals

public

Checks if the string starts with a number.

public

Removes interruption signal listeners and tears down capture-exit

public

Suppresses "Terminate batch job (Y/N)" confirmation on Windows

public

Checks if project name is valid.

Private Methods
private

Uses the eon-old command NET SESSION to determine whether or not the current user has elevated rights (think sudo, but Windows).

private

sets up a WindowsSymlinkChecker

private

Add process interruption handler

private

Returns true if and only if the given directory has a yarn.lock file or is a child of a yarn workspace root.

private

Exit silently

private

Exit silently

private
release( )

Drops all the interruption handlers and disables an ability to add new one

private

Remove process interruption handler

Public Methods

lib/utilities/ember-app-utils.js:37

public calculateBaseTag(baseURL, locationType): String

Returns the tag for index.html.

Parameters:

Name Type Attribute Description
baseURL String
locationType String

'history', 'none' or 'hash'.

Return:

String

Base tag or an empty string

lib/utilities/windows-admin.js:39

public checkIfSymlinksNeedToBeEnabled( ): Promise

if not windows, will fulfill with: { windows: false, elevated: null) if windows, and elevated will fulfill with: { windows: false, elevated: true) if windows, and is NOT elevated will fulfill with: { windows: false, elevated: false) will include heplful warning, so that users know (if possible) how to achieve better windows build performance

Return:

Promise

Object describing whether we're on windows and if admin rights exist

lib/utilities/windows-admin.js:83

public checkIfSymlinksNeedToBeEnabled( ): Promise

Return:

Promise

Object describing whether we're on windows and if admin rights exist

lib/utilities/ember-app-utils.js:55

public contentFor(config, mathch, type, options): String

Returns the content for a specific type (section) for index.html.

{{content-for "[type]"}}

Supported types:

  • 'head'
  • 'config-module'
  • 'head-footer'
  • 'test-header-footer'
  • 'body-footer'
  • 'test-body-footer'

Parameters:

Name Type Attribute Description
config Object

Ember.js application configuration

mathch RegExp

Regular expression to match against

type String

Type of content

options Object

Settings that control the default content

options.autoRun Boolean

Controls whether to bootstrap the application or not

options.storeConfigInMeta Boolean

Controls whether to include the contents of config

options.isModuleUnification Boolean

Signifies if the application supports module unification or not

Return:

String

The content.

lib/utilities/ember-app-utils.js:24

public convertObjectToString(Any): String

Converts Javascript Object to a string. Returns an empty object string representation if a "falsy" value is passed in.

Parameters:

Name Type Attribute Description
Any Object

Javascript Object.

Return:

String

A string representation of a Javascript Object.

lib/utilities/insert-into-file.js:10

public insertIntoFile(pathRelativeToProjectRoot, contentsToInsert, providedOptions): Promise

Inserts the given content into a file. If the contentsToInsert string is already present in the current contents, the file will not be changed unless force option is passed.

If options.before is specified, contentsToInsert will be inserted before the first instance of that string. If options.after is specified, the contents will be inserted after the first instance of that string. If the string specified by options.before or options.after is not in the file, no change will be made. Both of these options support regular expressions.

If neither options.before nor options.after are present, contentsToInsert will be inserted at the end of the file.

It will create a new file if one doesn't exist, unless you set the options.create option to false.

Example:

// app/router.js
Router.map(function() {
});
insertIntoFile('app/router.js', '  this.route("admin");', {
  after: 'Router.map(function() {' + EOL
});
// app/router.js
Router.map(function() {
  this.route("admin");
});

Parameters:

Name Type Attribute Description
pathRelativeToProjectRoot String
contentsToInsert String
providedOptions Object

Return:

lib/utilities/ember-app-utils.js:7

public normalizeUrl(Raw): String

Returns a normalized url given a string. Returns an empty string if null, undefined or an empty string are passed in.

Parameters:

Name Type Attribute Description
Raw String

url.

Return:

String

Normalized url.

lib/utilities/will-interrupt-process.js:118

public setupSignalsTrap( )

Sets up listeners for interruption signals

When one of these signals is caught than raise process.exit() which enforces capture-exit to run registered interruption handlers

lib/utilities/valid-project-name.js:3

public startsWithNumber( ): Boolean

Checks if the string starts with a number.

Return:

lib/utilities/will-interrupt-process.js:136

public teardownSignalsTrap( )

Removes interruption signal listeners and tears down capture-exit

lib/utilities/will-interrupt-process.js:151

public trapWindowsSignals( )

Suppresses "Terminate batch job (Y/N)" confirmation on Windows

lib/utilities/valid-project-name.js:13

public validProjectName(name): Boolean

Checks if project name is valid.

Invalid names are some of the internal constants that Ember CLI uses, such as app, ember, ember-cli, test, and vendor. Names that start with numbers are considered invalid as well.

Parameters:

Name Type Attribute Description
name String

The name of Ember CLI project

Return:

Private Methods

lib/utilities/windows-admin.js:106

private _checkForElevatedRights(ui): Object

Uses the eon-old command NET SESSION to determine whether or not the current user has elevated rights (think sudo, but Windows).

Parameters:

Name Type Attribute Description
ui Object
  • ui object used to call writeLine();

Return:

Object

Object describing whether we're on windows and if admin rights exist

sets up a WindowsSymlinkChecker

providing it with defaults for:

  • if we are on windows
  • if we can symlink
  • a reference to exec

Parameters:

Name Type Attribute Description
UI UI

Add process interruption handler

When the first handler is added then automatically sets up process interruption signals listeners

Parameters:

Name Type Attribute Description
cb Function

Callback to be called when process interruption fired

lib/utilities/is-yarn-project.js:6

private isYarnProject(thePath): Boolean

Returns true if and only if the given directory has a yarn.lock file or is a child of a yarn workspace root.

Parameters:

Name Type Attribute Description
thePath String

Return:

lib/tasks/serve.js:75

private onInterrupt( )

Exit silently

lib/tasks/test-server.js:62

private onInterrupt( )

Exit silently

Drops all the interruption handlers and disables an ability to add new one

Note: We don't call `captureExit.releaseExit() here. In some rare scenarios it can lead to the hard to debug issues. see: https://github.com/ember-cli/ember-cli/issues/6779#issuecomment-280940358

We can more or less feel comfortable with a captured exit because it behaves very similar to the original exit except of cases when we need to do cleanup before exit.

lib/utilities/will-interrupt-process.js:95

private removeHandler(cb)

Remove process interruption handler

If there are no remaining handlers after removal then clean up all the process interruption signal listeners

Parameters:

Name Type Attribute Description
cb Function

Callback to be removed