Skip to content

Commit 8fb4330

Browse files
author
Fatme
authored
Merge pull request #4627 from NativeScript/fatme/merge-master-webpack
feat: merge master into webpack branch
2 parents d133c8b + 44eb3c5 commit 8fb4330

File tree

141 files changed

+2631
-1540
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+2631
-1540
lines changed

CHANGELOG.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,61 @@
11
NativeScript CLI Changelog
22
================
33

4+
5+
5.4.0 (2019, May 15)
6+
==
7+
8+
### Implemented
9+
* [Implemented #3993](https://github.com/NativeScript/nativescript-cli/issues/3993): Improve `ctrl + c` handling.
10+
* [Implemented #4374](https://github.com/NativeScript/nativescript-cli/issues/4374): Add `iCloudContainerEnvironment` build option.
11+
* [Implemented #4394](https://github.com/NativeScript/nativescript-cli/issues/4394): Enable Using Hot Module Replacement by Default for New Projects
12+
* [Implemented #4518](https://github.com/NativeScript/nativescript-cli/issues/4518): Show deprecation messages for things that will be dropped for 6.0.0 release
13+
* [Implemented #4541](https://github.com/NativeScript/nativescript-cli/issues/4541): [Beta] Allow integration of Apple Watch application in NativeScript app
14+
* [Implemented #4548](https://github.com/NativeScript/nativescript-cli/issues/4548): Deprecate support for the Legacy Workflow
15+
* [Implemented #4602](https://github.com/NativeScript/nativescript-cli/issues/4602): Streamline CLI's logger
16+
17+
18+
### Fixed
19+
* [Fixed #4280](https://github.com/NativeScript/nativescript-cli/issues/4280): Incorrect message if you delete app's folder and run command with `--path` in it
20+
* [Fixed #4512](https://github.com/NativeScript/nativescript-cli/issues/4512): App's Podfile should be applied last
21+
* [Fixed #4573](https://github.com/NativeScript/nativescript-cli/pull/4573): logcat process is not restarted in some cases
22+
* [Fixed #4593](https://github.com/NativeScript/nativescript-cli/issues/4593): Node.js processes not killed after `tns create` on macOS when analytics are enabled
23+
* [Fixed #4598](https://github.com/NativeScript/nativescript-cli/issues/4598): app.css changes don't apply when debugging with --debug-brk
24+
* [Fixed #4606](https://github.com/NativeScript/nativescript-cli/issues/4606): Unable to build application for iOS with nativescript-bottombar
25+
* [Fixed #4616](https://github.com/NativeScript/nativescript-cli/issues/4616): `tns plugin create` command hangs
26+
27+
5.3.4 (2019, April 24)
28+
==
29+
30+
### Fixed
31+
* [Fixed #4561](https://github.com/NativeScript/nativescript-cli/issues/4561): CLI merges xcconfig files only for specified build configuration
32+
33+
5.3.3 (2019, April 23)
34+
==
35+
36+
### Fixed
37+
* [Fixed #4527](https://github.com/NativeScript/nativescript-cli/issues/4527): Unable to upload applications to App Store
38+
39+
5.3.2 (2019, April 12)
40+
==
41+
42+
### Fixed
43+
* [Fixed #1798](https://github.com/NativeScript/nativescript-cli/issues/1798): Test init command doesn't add a sample test in TypeScript for TypeScript/Angular projects
44+
* [Fixed #4498](https://github.com/NativeScript/nativescript-cli/pull/4498): API: Change the AppStore ids for kinvey scanner and preview app
45+
* [Fixed #4504](https://github.com/NativeScript/nativescript-cli/issues/4504): Custom tagged versions of android runtime are not supported
46+
* [Fixed #4510](https://github.com/NativeScript/nativescript-cli/pull/4510): Handle HTTP 304 response status code
47+
48+
5.3.1 (2019, April 03)
49+
==
50+
51+
### Implemented
52+
* [Implemented #4492](https://github.com/NativeScript/nativescript-cli/pull/4492): API(kinvey): provide correct data to preview-sdk based on the schema
53+
54+
### Fixed
55+
* [Fixed #4370](https://github.com/NativeScript/nativescript-cli/issues/4370): NativeScript CLI installation fails on linux
56+
* [Fixed #4451](https://github.com/NativeScript/nativescript-cli/issues/4451): Error while trying to start application on Android emulator with API level Q
57+
* [Fixed #4483](https://github.com/NativeScript/nativescript-cli/pull/4483): Detection fixes for emulator/device
58+
459
5.3.0 (2019, March 27)
560
==
661

PublicAPI.md

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ const tns = require("nativescript");
7272
* [getPlaygroundAppQrCode](#getplaygroundappqrcode)
7373
* [cleanupService](#cleanupservice)
7474
* [setCleanupLogFile](#setcleanuplogfile)
75+
* [initializeService](#initializeService)
76+
* [initialize](#initialize)
77+
* [logger](#logger)
78+
* [initialize](#initialize)
79+
* [getLevel](#getlevel)
80+
* [appenders](#appenders)
81+
* [emit-appender](#emit-appender)
82+
* [cli-appender](#cli-appender)
83+
* [custom layouts](#custom-layouts)
84+
7585

7686
## Module projectService
7787

@@ -1509,6 +1519,176 @@ const tns = require("nativescript");
15091519
tns.cleanupService.setCleanupLogFile("/Users/username/cleanup-logs.txt");
15101520
```
15111521
1522+
## initializeService
1523+
The `initializeService` is used to initialize CLI's configuration at the beginning and print all warnings related to current environment.
1524+
1525+
### initialize
1526+
This method executes initialization actions based on the passed parameters. In case `loggerOptions` are not passed, the default CLI logger will be used.
1527+
After initialization, the method will print all system warnings.
1528+
1529+
* Definition
1530+
```TypeScript
1531+
interface IInitializeOptions {
1532+
loggerOptions?: ILoggerOptions;
1533+
settingsServiceOptions?: IConfigurationSettings;
1534+
extensibilityOptions?: { pathToExtensions: string };
1535+
}
1536+
1537+
interface IInitializeService {
1538+
initialize(initOpts?: IInitializeOptions): Promise<void>;
1539+
}
1540+
1541+
```
1542+
1543+
> NOTE: For more information about loggerOptions, you can check `logger`.
1544+
1545+
* Usage
1546+
* Initialization without passing any data - `logger` will be initialized with default CLI settings. Warnings will be printed if there are any.
1547+
```JavaScript
1548+
const tns = require("nativescript");
1549+
tns.initializeService.initialize();
1550+
```
1551+
* Initialize with custom settings service options:
1552+
```JavaScript
1553+
const tns = require("nativescript");
1554+
tns.initializeService.initialize({ settingsServiceOptions: { profileDir: "/Users/username/customDir", userAgentName: "MyApp" } });
1555+
```
1556+
* Initialize with custom extensibility path:
1557+
```JavaScript
1558+
const tns = require("nativescript");
1559+
tns.initializeService.initialize({ extensibilityOptions: { pathToExtensions: "/Users/username/customDir/extensions" } });
1560+
```
1561+
1562+
## logger
1563+
1564+
`logger` module is used to show any kind of information to the user. The `logger` uses `log4js` internally, which allows setting different levels for the messages.
1565+
The levels are available in `tns.constants.LoggerLevel` enum. Only messages from the current log level (or higher) are shown to the user, i.e. in case the log level is set to `INFO`, `DEBUG` and `TRACE` messages will not be shown to the user, but `WARN` and `ERROR` messages will be shown. </br>
1566+
`logger` module can be configured how to show the messages by using different appenders and layouts. </br>
1567+
* `appenders` are responsible for output of log events. They may write events to files, send emails, store them in a database, or anything. Most appenders use layouts to serialise the events to strings for output.
1568+
* `layout` is a function for converting a LogEvent into a string representation.
1569+
1570+
`log4js` has predefined appenders and layouts that can be used. In case you do not pass any options to logger's initialization, CLI will default to [console appender](https://log4js-node.github.io/log4js-node/console.html) with [messagePassThrough layout](https://log4js-node.github.io/log4js-node/layouts.html#message-pass-through) with `INFO` log level.</br>
1571+
You can override only the properties you want, i.e. only the log level, the layout or the appender. </br>
1572+
`nativescript` itself has additional appenders that you can use. More information about them can be found below. You can get a full list of the available appenders by checking the `tns.constants.LoggerAppenders` object. </br>
1573+
1574+
> NOTE: When CLI is used as a command-line tool, it uses a custom appender and layout in order to write coloured messages to stdout or stderr.
1575+
1576+
### initialize
1577+
The `initialize` method initializes the log4js settings - level, appender and layout. Once called, the settings cannot be changed anymore for the current process.
1578+
1579+
* Definition
1580+
```TypeScript
1581+
interface IAppenderOptions extends IDictionary<any> {
1582+
type: string;
1583+
layout?: Layout;
1584+
}
1585+
1586+
interface ILoggerOptions {
1587+
level?: LoggerLevel;
1588+
appenderOptions?: IAppenderOptions;
1589+
}
1590+
1591+
initialize(opts?: ILoggerOptions): void;
1592+
```
1593+
1594+
* Usage
1595+
* Initialize with default settings:
1596+
```JavaScript
1597+
tns.logger.initialize();
1598+
```
1599+
* Initialize with DEBUG log level:
1600+
```JavaScript
1601+
tns.logger.initialize({ level: tns.constants.LoggerLevel.DEBUG });
1602+
```
1603+
* Initialize with different appender, for example [fileSync](https://log4js-node.github.io/log4js-node/fileSync.html) appender:
1604+
```JavaScript
1605+
tns.logger.initialize({ appenderOptions: { type: "fileSync" } });
1606+
```
1607+
* Initialize with different layout, for example [Pattern](https://log4js-node.github.io/log4js-node/layouts.html#pattern) layout:
1608+
```JavaScript
1609+
tns.logger.initialize({ appenderOptions: { layout: { type: "pattern" } } });
1610+
```
1611+
* Initialize with custom appender, layout and level:
1612+
```JavaScript
1613+
tns.logger.initialize({ appenderOptions: { type: "fileSync", layout: { type: "pattern" } }, level: tns.constants.LoggerLevel.DEBUG });
1614+
```
1615+
1616+
### getLevel
1617+
This method returns information for the current log level.
1618+
1619+
* Definition
1620+
```TypeScript
1621+
getLevel(): string;
1622+
```
1623+
1624+
* Usage
1625+
```JavaScript
1626+
console.log(`Current log level is: ${tns.logger.getLevel()}`);
1627+
```
1628+
1629+
### appenders
1630+
The `appenders` are log4js concept. `appenders` are responsible for output of log events. You can use all predefined [log4js appenders](https://log4js-node.github.io/log4js-node/appenders.html) and also several predefined CLI appenders
1631+
1632+
#### emit-appender
1633+
The `emit-appender` is used to emit the log events through a passed emitter instead of writing the messages. Whenever a message should be shown, the `emit-appender` emits `logData` event with an object containing the `loggingEvent` and the message passed through the specified layout stored in `formattedMessage` property.
1634+
1635+
* Usage:
1636+
```JavaScript
1637+
const tns = require("nativescript");
1638+
const { EventEmitter } = require("events");
1639+
const { EMIT_APPENDER_EVENT_NAME, LoggerAppenders } = tns.constants;
1640+
const emitter = new EventEmitter();
1641+
// IMPORTANT: Add the event handler before calling logger's initialize method.
1642+
// This is required as log4js makes a copy of the appenderOptions, where the emitter is passed
1643+
// NOTE: In case you want to debug the event handler, place `debugger` in it.
1644+
emitter.on(EMIT_APPENDER_EVENT_NAME, (logData) => {
1645+
if (logData.loggingEvent.level.levelStr === LoggerLevel.WARN) {
1646+
console.log(`WARNING: ${logData.formattedMessage}`);
1647+
}
1648+
});
1649+
1650+
const logger = tns.logger;
1651+
logger.initialize({
1652+
appenderOptions: {
1653+
type: LoggerAppenders.emitAppender,
1654+
emitter
1655+
}
1656+
});
1657+
```
1658+
1659+
> NOTE: In several cases CLI passes additional configuration properties in the `context` of the `loggingEvent`. Full list is available in the `tns.constants.LoggerConfigData` object. These properties are used by CLI's layout and appender to change the way the message is printed on the terminal and if it should be on stderr or stdout.
1660+
1661+
#### cli-appender
1662+
`cli-appender` prints messages to stdout or stderr based on the passed options for the message.
1663+
1664+
* Usage
1665+
```JavaScript
1666+
const tns = require("nativescript");
1667+
const { EventEmitter } = require("events");
1668+
const { EMIT_APPENDER_EVENT_NAME, LoggerAppenders } = tns.constants;
1669+
1670+
const logger = tns.logger;
1671+
logger.initialize({
1672+
appenderOptions: {
1673+
type: LoggerAppenders.cliAppender,
1674+
}
1675+
});
1676+
```
1677+
1678+
### custom layouts
1679+
You can define your own layout function in the following way:
1680+
```JavaScript
1681+
const log4js = require("nativescript/node_modules/log4js");
1682+
const util = require("util");
1683+
log4js.addLayout("myCustomLayout", (config) => {
1684+
return (loggingEvent) => {
1685+
return util.format.apply(null, loggingEvent.data);
1686+
}
1687+
});
1688+
1689+
tns.logger.initialize({ appenderOptions: { layout: { type: "myCustomLayout" } } });
1690+
```
1691+
15121692
## How to add a new method to Public API
15131693
CLI is designed as command line tool and when it is used as a library, it does not give you access to all of the methods. This is mainly implementation detail. Most of the CLI's code is created to work in command line, not as a library, so before adding method to public API, most probably it will require some modification.
15141694
For example the `$options` injected module contains information about all `--` options passed on the terminal. When the CLI is used as a library, the options are not populated. Before adding method to public API, make sure its implementation does not rely on `$options`.

docs/man_pages/lib-management/plugin-create.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Create from a custom plugin seed | `$ tns plugin create <Plugin Repository Name>
2828
* `--path` - Specifies the directory where you want to create the project, if different from the current directory.
2929
* `--username` - Specifies the Github username, which will be used to build the URLs in the plugin's package.json file.
3030
* `--pluginName` - Used to set the default file and class names in the plugin source.
31+
* `--includeTypeScriptDemo` - Specifies if TypeScript demo should be created. Default value is `y` (i.e. `demo` will be created), in case you do not want to create this demo, pass `--includeTypeScriptDemo=n`
32+
* `--includeAngularDemo` - Specifies if Angular demo should be created. Default value is `y` (i.e. `demo-angular` will be created), in case you do not want to create this demo, pass `--includeAngularDemo=n`
3133
* `--template` - Specifies the custom seed archive, which you want to use to create your plugin. If `--template` is not set, the NativeScript CLI creates the plugin from the default NativeScript Plugin Seed. `<Template>` can be a URL or a local path to a `.tar.gz` file with the contents of a seed repository.<% if(isHtml) { %> This must be a clone of the [NativeScript Plugin Seed](https://github.com/NativeScript/nativescript-plugin-seed) and must contain a `src` directory with a package.json file and a script at `src/scripts/postclone.js`. After the archive is extracted, the postclone script will be executed with the username (`gitHubUsername`) and plugin name (`pluginName`) parameters given to the `tns plugin create` command prompts. For more information, visit the default plugin seed repository and [examine the source script](https://github.com/NativeScript/nativescript-plugin-seed/blob/master/src/scripts/postclone.js) there. Examples:
3234

3335
* Using a local file:

docs/man_pages/project/testing/debug-android.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ position: 4
99

1010
Initiates a debugging session for your project on a connected Android device or Android emulator. When necessary, the command will prepare, build, deploy and launch the app before starting the debug session. While debugging, the output from the application is printed in the console and any changes made to your code are synchronizes with the deployed app.
1111

12-
To enable Hot Module Replacement (HMR) in Angular projects, follow the steps outlined in this wiki: https://github.com/NativeScript/nativescript-angular/wiki/HMR.
12+
To enable Hot Module Replacement (HMR) in Angular projects, follow the steps outlined in [the HMR documentation section](https://docs.nativescript.org/performance-optimizations/bundling-with-webpack#hot-module-replacement).
1313

1414
### Commands
1515

@@ -31,12 +31,12 @@ Attach the debug tools to a running app in the native emulator | `$ tns debug an
3131
* `--no-watch` - If set, changes in your code will not be reflected during the execution of this command.
3232
* `--clean` - If set, forces the complete rebuild of the native application.
3333
* `--bundle` - Specifies that the `webpack` bundler will be used to bundle the application.
34-
* `--hmr` - (Beta) Enables the hot module replacement (HMR) feature. HMR depends on `webpack` and adding the `--hmr` flag to the command will automatically enable the `--bundle` option as well.<% if(isConsole) { %> The HMR feature is currently in Beta. For more information about the current development state and any known issues, please check the relevant GitHub issue: https://github.com/NativeScript/NativeScript/issues/6398.<% } %>
34+
* `--hmr` - Enables the hot module replacement (HMR) feature. HMR depends on `webpack` and adding the `--hmr` flag to the command will automatically enable the `--bundle` option as well.<% if(isConsole) { %> For more information about the current development state and any known issues, please check the relevant GitHub issue: https://github.com/NativeScript/NativeScript/issues/6398.<% } %>
3535
* `--syncAllFiles` - Watches all production dependencies inside node_modules for changes. Triggers project rebuild if necessary!
3636

3737
<% if(isHtml) { %>
3838

39-
>Note: Hot Module Replacement (HMR) is currently in Beta. For more information about the current development state and any known issues, please check the relevant GitHub issue: https://github.com/NativeScript/NativeScript/issues/6398.
39+
>Note: For more information about HMR, the current development state and any known issues, please check the relevant GitHub issue: https://github.com/NativeScript/NativeScript/issues/6398.
4040
4141
### Command Limitations
4242

lib/bootstrap.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require("./common/bootstrap");
2-
$injector.require("logger", "./common/logger");
2+
$injector.requirePublicClass("logger", "./common/logger/logger");
33
$injector.require("config", "./config");
44
$injector.require("options", "./options");
55
// note: order above is important!
@@ -16,6 +16,7 @@ $injector.require("gradleBuildService", "./services/android/gradle-build-service
1616
$injector.require("gradleBuildArgsService", "./services/android/gradle-build-args-service");
1717
$injector.require("iOSEntitlementsService", "./services/ios-entitlements-service");
1818
$injector.require("iOSExtensionsService", "./services/ios-extensions-service");
19+
$injector.require("iOSWatchAppService", "./services/ios-watch-app-service");
1920
$injector.require("iOSProjectService", "./services/ios-project-service");
2021
$injector.require("iOSProvisionService", "./services/ios-provision-service");
2122
$injector.require("xcconfigService", "./services/xcconfig-service");
@@ -40,9 +41,7 @@ $injector.require("platformValidationService", "./services/platform/platform-val
4041

4142
$injector.require("buildArtefactsService", "./services/build-artefacts-service");
4243

43-
$injector.require("deviceDebugAppService", "./services/device/device-debug-app-service");
4444
$injector.require("deviceInstallAppService", "./services/device/device-install-app-service");
45-
$injector.require("deviceRefreshAppService", "./services/device/device-refresh-app-service");
4645

4746
$injector.require("runEmitter", "./emitters/run-emitter");
4847
$injector.require("previewAppEmitter", "./emitters/preview-app-emitter");
@@ -52,6 +51,7 @@ $injector.require("prepareController", "./controllers/prepare-controller");
5251
$injector.require("buildController", "./controllers/build-controller");
5352
$injector.require("deployController", "./controllers/deploy-controller");
5453
$injector.require("runController", "./controllers/run-controller");
54+
$injector.require("debugController", "./controllers/debug-controller");
5555
$injector.require("previewAppController", "./controllers/preview-app-controller");
5656

5757
$injector.require("prepareDataService", "./services/prepare-data-service");
@@ -134,7 +134,7 @@ $injector.require("xcprojService", "./services/xcproj-service");
134134
$injector.require("versionsService", "./services/versions-service");
135135
$injector.requireCommand("install", "./commands/install");
136136

137-
$injector.require("initService", "./services/init-service");
137+
$injector.require("projectInitService", "./services/project-init-service");
138138
$injector.requireCommand("init", "./commands/init");
139139

140140
$injector.require("infoService", "./services/info-service");
@@ -221,3 +221,9 @@ $injector.require("networkConnectivityValidator", "./helpers/network-connectivit
221221
$injector.requirePublic("cleanupService", "./services/cleanup-service");
222222

223223
$injector.require("webpackCompilerService", "./services/webpack/webpack-compiler-service");
224+
225+
$injector.require("applePortalSessionService", "./services/apple-portal/apple-portal-session-service");
226+
$injector.require("applePortalCookieService", "./services/apple-portal/apple-portal-cookie-service");
227+
$injector.require("applePortalApplicationService", "./services/apple-portal/apple-portal-application-service");
228+
229+
$injector.requirePublicClass("initializeService", "./services/initialize-service");

0 commit comments

Comments
 (0)