Skip to content

Commit bb75dbb

Browse files
authored
Merge pull request #1 from NativeScript/master
Update
2 parents 5678da7 + 6343541 commit bb75dbb

File tree

187 files changed

+3629
-1593
lines changed

Some content is hidden

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

187 files changed

+3629
-1593
lines changed

CHANGELOG.md

+55
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

Gruntfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ module.exports = function (grunt) {
236236
});
237237
grunt.registerTask("lint", ["tslint:build"]);
238238
grunt.registerTask("all", ["clean", "test", "lint"]);
239-
grunt.registerTask("rebuild", ["clean", "ts:devlib"]);
239+
grunt.registerTask("rebuild", ["clean", "default"]);
240240
grunt.registerTask("default", ["ts:devlib", "generate_unit_testing_dependencies"]);
241241
grunt.registerTask("docs-jekyll", ['template']);
242242
};

PublicAPI.md

+207
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ const tns = require("nativescript");
7070
* [deviceLog](#devicelog)
7171
* [previewQrCodeService](#previewqrcodeservice)
7272
* [getPlaygroundAppQrCode](#getplaygroundappqrcode)
73+
* [cleanupService](#cleanupservice)
74+
* [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+
7385

7486
## Module projectService
7587

@@ -1487,6 +1499,201 @@ tns.previewQrCodeService.getPlaygroundAppQrCode()
14871499
});
14881500
```
14891501
1502+
## cleanupService
1503+
The `cleanupService` is used to handle actions that should be executed after CLI's process had exited. This is an internal service, that runs detached childProcess in which it executes CLI's cleanup actions once CLI is dead. As the process is detached, logs from it are not shown anywhere, so the service exposes a way to add log file in which the child process will write its logs.
1504+
1505+
### setCleanupLogFile
1506+
Defines the log file location where the child cleanup process will write its logs.
1507+
1508+
> NOTE: You must call this method immediately after requiring NativeScript CLI. In case you call it after the cleanup process had started, it will not use the passed log file.
1509+
1510+
* Definition
1511+
```TypeScript
1512+
/**
1513+
* Sets the file in which the cleanup process will write its logs.
1514+
* This method must be called before starting the cleanup process, i.e. when CLI is initialized.
1515+
* @param {string} filePath Path to file where the logs will be written. The logs are appended to the passed file.
1516+
* @returns {void}
1517+
*/
1518+
setCleanupLogFile(filePath: string): void;
1519+
```
1520+
1521+
* Usage
1522+
```JavaScript
1523+
const tns = require("nativescript");
1524+
tns.cleanupService.setCleanupLogFile("/Users/username/cleanup-logs.txt");
1525+
```
1526+
1527+
## initializeService
1528+
The `initializeService` is used to initialize CLI's configuration at the beginning and print all warnings related to current environment.
1529+
1530+
### initialize
1531+
This method executes initialization actions based on the passed parameters. In case `loggerOptions` are not passed, the default CLI logger will be used.
1532+
After initialization, the method will print all system warnings.
1533+
1534+
* Definition
1535+
```TypeScript
1536+
interface IInitializeOptions {
1537+
loggerOptions?: ILoggerOptions;
1538+
settingsServiceOptions?: IConfigurationSettings;
1539+
extensibilityOptions?: { pathToExtensions: string };
1540+
}
1541+
1542+
interface IInitializeService {
1543+
initialize(initOpts?: IInitializeOptions): Promise<void>;
1544+
}
1545+
1546+
```
1547+
1548+
> NOTE: For more information about loggerOptions, you can check `logger`.
1549+
1550+
* Usage
1551+
* Initialization without passing any data - `logger` will be initialized with default CLI settings. Warnings will be printed if there are any.
1552+
```JavaScript
1553+
const tns = require("nativescript");
1554+
tns.initializeService.initialize();
1555+
```
1556+
* Initialize with custom settings service options:
1557+
```JavaScript
1558+
const tns = require("nativescript");
1559+
tns.initializeService.initialize({ settingsServiceOptions: { profileDir: "/Users/username/customDir", userAgentName: "MyApp" } });
1560+
```
1561+
* Initialize with custom extensibility path:
1562+
```JavaScript
1563+
const tns = require("nativescript");
1564+
tns.initializeService.initialize({ extensibilityOptions: { pathToExtensions: "/Users/username/customDir/extensions" } });
1565+
```
1566+
1567+
## logger
1568+
1569+
`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.
1570+
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>
1571+
`logger` module can be configured how to show the messages by using different appenders and layouts. </br>
1572+
* `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.
1573+
* `layout` is a function for converting a LogEvent into a string representation.
1574+
1575+
`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>
1576+
You can override only the properties you want, i.e. only the log level, the layout or the appender. </br>
1577+
`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>
1578+
1579+
> 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.
1580+
1581+
### initialize
1582+
The `initialize` method initializes the log4js settings - level, appender and layout. Once called, the settings cannot be changed anymore for the current process.
1583+
1584+
* Definition
1585+
```TypeScript
1586+
interface IAppenderOptions extends IDictionary<any> {
1587+
type: string;
1588+
layout?: Layout;
1589+
}
1590+
1591+
interface ILoggerOptions {
1592+
level?: LoggerLevel;
1593+
appenderOptions?: IAppenderOptions;
1594+
}
1595+
1596+
initialize(opts?: ILoggerOptions): void;
1597+
```
1598+
1599+
* Usage
1600+
* Initialize with default settings:
1601+
```JavaScript
1602+
tns.logger.initialize();
1603+
```
1604+
* Initialize with DEBUG log level:
1605+
```JavaScript
1606+
tns.logger.initialize({ level: tns.constants.LoggerLevel.DEBUG });
1607+
```
1608+
* Initialize with different appender, for example [fileSync](https://log4js-node.github.io/log4js-node/fileSync.html) appender:
1609+
```JavaScript
1610+
tns.logger.initialize({ appenderOptions: { type: "fileSync" } });
1611+
```
1612+
* Initialize with different layout, for example [Pattern](https://log4js-node.github.io/log4js-node/layouts.html#pattern) layout:
1613+
```JavaScript
1614+
tns.logger.initialize({ appenderOptions: { layout: { type: "pattern" } } });
1615+
```
1616+
* Initialize with custom appender, layout and level:
1617+
```JavaScript
1618+
tns.logger.initialize({ appenderOptions: { type: "fileSync", layout: { type: "pattern" } }, level: tns.constants.LoggerLevel.DEBUG });
1619+
```
1620+
1621+
### getLevel
1622+
This method returns information for the current log level.
1623+
1624+
* Definition
1625+
```TypeScript
1626+
getLevel(): string;
1627+
```
1628+
1629+
* Usage
1630+
```JavaScript
1631+
console.log(`Current log level is: ${tns.logger.getLevel()}`);
1632+
```
1633+
1634+
### appenders
1635+
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
1636+
1637+
#### emit-appender
1638+
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.
1639+
1640+
* Usage:
1641+
```JavaScript
1642+
const tns = require("nativescript");
1643+
const { EventEmitter } = require("events");
1644+
const { EMIT_APPENDER_EVENT_NAME, LoggerAppenders } = tns.constants;
1645+
const emitter = new EventEmitter();
1646+
// IMPORTANT: Add the event handler before calling logger's initialize method.
1647+
// This is required as log4js makes a copy of the appenderOptions, where the emitter is passed
1648+
// NOTE: In case you want to debug the event handler, place `debugger` in it.
1649+
emitter.on(EMIT_APPENDER_EVENT_NAME, (logData) => {
1650+
if (logData.loggingEvent.level.levelStr === LoggerLevel.WARN) {
1651+
console.log(`WARNING: ${logData.formattedMessage}`);
1652+
}
1653+
});
1654+
1655+
const logger = tns.logger;
1656+
logger.initialize({
1657+
appenderOptions: {
1658+
type: LoggerAppenders.emitAppender,
1659+
emitter
1660+
}
1661+
});
1662+
```
1663+
1664+
> 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.
1665+
1666+
#### cli-appender
1667+
`cli-appender` prints messages to stdout or stderr based on the passed options for the message.
1668+
1669+
* Usage
1670+
```JavaScript
1671+
const tns = require("nativescript");
1672+
const { EventEmitter } = require("events");
1673+
const { EMIT_APPENDER_EVENT_NAME, LoggerAppenders } = tns.constants;
1674+
1675+
const logger = tns.logger;
1676+
logger.initialize({
1677+
appenderOptions: {
1678+
type: LoggerAppenders.cliAppender,
1679+
}
1680+
});
1681+
```
1682+
1683+
### custom layouts
1684+
You can define your own layout function in the following way:
1685+
```JavaScript
1686+
const log4js = require("nativescript/node_modules/log4js");
1687+
const util = require("util");
1688+
log4js.addLayout("myCustomLayout", (config) => {
1689+
return (loggingEvent) => {
1690+
return util.format.apply(null, loggingEvent.data);
1691+
}
1692+
});
1693+
1694+
tns.logger.initialize({ appenderOptions: { layout: { type: "myCustomLayout" } } });
1695+
```
1696+
14901697
## How to add a new method to Public API
14911698
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.
14921699
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`.

config/test-dependencies.json

+20
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,25 @@
2828
{
2929
"name": "karma-qunit",
3030
"framework": "qunit"
31+
},
32+
{
33+
"name": "@types/karma-chai",
34+
"framework": "mocha",
35+
"projectType": ".ts"
36+
},
37+
{
38+
"name": "@types/mocha",
39+
"framework": "mocha",
40+
"projectType": ".ts"
41+
},
42+
{
43+
"name": "@types/jasmine",
44+
"framework": "jasmine",
45+
"projectType": ".ts"
46+
},
47+
{
48+
"name": "@types/qunit",
49+
"framework": "qunit",
50+
"projectType": ".ts"
3151
}
3252
]

docs/build-jekyll-md.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ rm -rf docs-cli
55
npm install --ignore-scripts
66

77
grunt docs-jekyll
8-
cd docs-cli
9-
mv index.md start.md
8+
if [ -d docs-cli ]; then
9+
cd docs-cli
10+
mv index.md start.md
11+
fi

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

+2
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/creation/create.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ Template | Command
5151
`Angular - Hello World`, `--ng`, `--angular` | tns create tns-template-hello-world-ng
5252
`Angular - SideDrawer` | tns create tns-template-drawer-navigation-ng
5353
`Angular - Tabs` | tns create tns-template-tab-navigation-ng
54-
`Vue.js`, `--vue`, `--vuejs` | tns create tns-template-blank-vue
54+
`Vue.js - Blank`, `--vue`, `--vuejs` | tns create tns-template-blank-vue
55+
`Vue.js - SideDrawer`, | tns create tns-template-drawer-navigation-vue
5556

5657
### Related Commands
5758

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ General | `$ tns build android [--compileSdk <API Level>] [--key-store-path <Fil
2626
* `--key-store-alias-password` - Provides the password for the alias specified with `--key-store-alias-password`. You can use the `--key-store-*` options along with `--release` to produce a signed release build. You need to specify all `--key-store-*` options.
2727
* `--copy-to` - Specifies the file path where the built `.apk` will be copied. If it points to a non-existent directory path, it will be created. If the specified value is existing directory, the original file name will be used.
2828
* `--bundle` - Specifies that the `webpack` bundler will be used to bundle the application.
29-
* `--env.*` - Specifies additional flags that the bundler may process. May be passed multiple times. For example: `--env.uglify --env.snapshot`.
29+
* `--env.*` - Specifies additional flags that the bundler may process. May be passed multiple times. Supported additional flags:
30+
* `--env.aot` - creates Ahead-Of-Time build (Angular only).
31+
* `--env.snapshot`- creates [Snapshot](https://docs.nativescript.org/performance-optimizations/bundling-with-webpack#v8-heap-snapshot) (only for release builds on Mac OS & for Android).
32+
* `--env.uglify` - provides basic obfuscation and smaller app size.
33+
* `--env.report` - creates a Webpack report inside a `report` folder in the root folder.
34+
* `--env.sourceMap` - creates inline source maps (useful for debbuging bundled app).
35+
* `--env.hiddenSourceMap` - creates sources maps in the root folder (useful for Crashlytics usage with bundled app in release).
3036
* `--aab` - Specifies that the build will produce an Android App Bundle(`.aab`) file.
3137

3238
<% if(isHtml) { %>

0 commit comments

Comments
 (0)