lib/utilities/windows-admin.js:6
WindowsSymlinkChecker
On Windows, users will have a much better experience if symlinks are enabled and usable. When queried, this object informs Windows users regarding improving their 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 user is an admin, the process needs to have been started with elevated privileges * if the user is not an admin, a specific setting needs to be enabled <= Windows 10 * 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 |
checkIfSymlinksNeedToBeEnabled( ): Promise
if not windows, will fulfill with: |
public |
checkIfSymlinksNeedToBeEnabled( ): Promise
|
public |
contentFor(config, match, type, options): String
Returns the content for a specific type (section) for index.html. |
public |
convertObjectToString(Any): String
Converts Javascript Object to a string. Returns an empty object string representation if a "falsy" value is passed in. |
public |
directoryForPackageName(packageName): String
Derive a directory name from a package name. Takes scoped packages into account. |
public |
insertIntoFile(pathRelativeToProjectRoot, contentsToInsert, providedOptions): Promise
Inserts the given content into a file. If the |
public |
normalizeUrl(Raw): String
Returns a normalized url given a string. Returns an empty string if |
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 |
validProjectName(name): Boolean
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 |
addHandler(cb)
Add process interruption handler |
private |
onInterrupt( )
Exit silently |
private |
onInterrupt( )
Exit silently |
private |
release( )
Drops all the interruption handlers and disables an ability to add new one |
private |
removeHandler(cb)
Remove process interruption handler |
Public Methods
lib/utilities/windows-admin.js:38
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:
Object describing whether we're on windows and if admin rights exist
lib/utilities/windows-admin.js:81
public checkIfSymlinksNeedToBeEnabled( ): Promise
Return:
Object describing whether we're on windows and if admin rights exist
lib/utilities/ember-app-utils.js:37
public contentFor(config, match, 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 |
match | 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 |
Return:
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:
A string representation of a Javascript Object.
lib/utilities/directory-for-package-name.js:5
public directoryForPackageName(packageName): String
Derive a directory name from a package name. Takes scoped packages into account.
Parameters:
Name | Type | Attribute | Description |
---|---|---|---|
packageName | String |
|
Return:
Derived directory name.
lib/utilities/insert-into-file.js:6
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:
Normalized url.
lib/utilities/will-interrupt-process.js:122
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:5
public startsWithNumber( ): Boolean
Checks if the string starts with a number.
Return:
lib/utilities/will-interrupt-process.js:140
public teardownSignalsTrap( )
Removes interruption signal listeners and tears down capture-exit
lib/utilities/will-interrupt-process.js:155
public trapWindowsSignals( )
Suppresses "Terminate batch job (Y/N)" confirmation on Windows
lib/utilities/valid-project-name.js:24
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:104
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 |
|
|
Return:
Object describing whether we're on windows and if admin rights exist
lib/utilities/windows-admin.js:60
private _setup(UI): WindowsSymlinkChecker
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 |
|
Return:
lib/utilities/will-interrupt-process.js:69
private addHandler(cb)
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/tasks/serve.js:102
private onInterrupt( )
Exit silently
lib/tasks/test-server.js:61
private onInterrupt( )
Exit silently
lib/utilities/will-interrupt-process.js:47
private release( )
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:97
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 |