diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 0000000..5ef9b1b
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,29 @@
+---
+name: Bug report
+about: 'We really appreciate your effort to provide feedback. Before opening a new
+ issue, please make sure that this case is not already reported in GitHub as an
+ issue or in StackOverflow as a question.'
+
+---
+
+**Environment**
+Provide version numbers for the following components (information can be retrieved by running `tns info` in your project folder or by inspecting the `package.json` of the project):
+ - CLI:
+ - Cross-platform modules:
+ - Android Runtime:
+ - iOS Runtime:
+ - Plugin(s):
+
+**Describe the bug**
+
+
+**To Reproduce**
+
+
+**Expected behavior**
+
+**Sample project**
+
+
+**Additional context**
+
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 0000000..3970909
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,17 @@
+---
+name: Feature request
+about: Suggest an idea for this project
+
+---
+
+**Is your feature request related to a problem? Please describe.**
+
+
+**Describe the solution you'd like**
+
+
+**Describe alternatives you've considered**
+
+
+**Additional context**
+
diff --git a/.github/issue_template.md b/.github/issue_template.md
deleted file mode 100644
index d103b9f..0000000
--- a/.github/issue_template.md
+++ /dev/null
@@ -1,28 +0,0 @@
-### Make sure to check the demo app(s) for sample usage
-
-### Make sure to check the existing issues in this repository
-
-### If the demo apps cannot help and there is no issue for your problem, tell us about it
-Please, ensure your title is less than 63 characters long and starts with a capital
-letter.
-
-### Which platform(s) does your issue occur on?
-- iOS/Android/Both
-- iOS/Android versions
-- emulator or device. What type of device?
-
-### Please, provide the following version numbers that your issue occurs with:
-
-- CLI: (run `tns --version` to fetch it)
-- Cross-platform modules: (check the 'version' attribute in the
-`node_modules/tns-core-modules/package.json` file in your project)
-- Runtime(s): (look for the `"tns-android"` and `"tns-ios"` properties in the `package.json` file of your project)
-- Plugin(s): (look for the version numbers in the `package.json` file of your
-project and paste your dependencies and devDependencies here)
-
-### Please, tell us how to recreate the issue in as much detail as possible.
-Describe the steps to reproduce it.
-
-### Is there any code involved?
- - provide a code example to recreate the problem
- - (EVEN BETTER) provide a .zip with application or refer to a repository with application where the problem is reproducible.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5d1a791..268412b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+### Bug Fixes
+
+* Non-meaningful messages are printed in the default output(https://github.com/NativeScript/nativescript-dev-typescript/issues/79))
+
+## [0.8.0](https://github.com/NativeScript/nativescript-dev-typescript/compare/v0.7.4...v0.8.0) (2019-03-12)
+
## [0.7.4](https://github.com/NativeScript/nativescript-dev-typescript/compare/v0.7.3...v0.7.4) (2018-09-18)
diff --git a/LICENSE b/LICENSE
index 59dc28e..061c440 100755
--- a/LICENSE
+++ b/LICENSE
@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
- Copyright (c) 2015-2018 Telerik EAD
+ Copyright (c) 2015-2019 Progress Software Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/lib/after-watch.js b/lib/after-watch.js
index 63102d5..63381bf 100644
--- a/lib/after-watch.js
+++ b/lib/after-watch.js
@@ -3,7 +3,7 @@ var compiler = require('./compiler');
module.exports = function ($logger) {
var tsc = compiler.getTscProcess();
if (tsc) {
- $logger.info("Stopping tsc watch");
+ $logger.trace("Stopping tsc watch");
tsc.kill("SIGINT")
}
}
diff --git a/lib/before-prepare.js b/lib/before-prepare.js
index ee41c5f..0524a96 100644
--- a/lib/before-prepare.js
+++ b/lib/before-prepare.js
@@ -6,7 +6,7 @@ module.exports = function ($logger, $projectData, $options, hookArgs) {
var bundle = $options.bundle || appFilesUpdaterOptions.bundle;
if (liveSync || bundle) {
- $logger.warn("Hook skipped because either bundling or livesync is in progress.")
+ $logger.trace("Hook skipped because either bundling or livesync is in progress.")
return;
}
diff --git a/lib/compiler.js b/lib/compiler.js
index e3a484d..57f4319 100644
--- a/lib/compiler.js
+++ b/lib/compiler.js
@@ -6,6 +6,12 @@ var fs = require('fs');
var path = require('path');
var semver = require('semver');
var tsc = null;
+var TscCompilationCompleteMessage = "watching for file changes";
+var TscWatcherInfoMessages = [
+ "file change detected",
+ "starting incremental compilation",
+ TscCompilationCompleteMessage
+];
function getTypeScriptVersion(typeScriptPath) {
try {
@@ -30,7 +36,7 @@ function runTypeScriptCompiler(logger, projectDir, options) {
var peerTypescriptPath = path.join(__dirname, '../../typescript');
var tscPath = path.join(peerTypescriptPath, 'lib/tsc.js');
var typeScriptVersion = getTypeScriptVersion(peerTypescriptPath);
-
+
if (fs.existsSync(tscPath)) {
logger.info(`Found peer TypeScript ${typeScriptVersion}`);
} else {
@@ -56,6 +62,12 @@ function runTypeScriptCompiler(logger, projectDir, options) {
nodeArgs.push('--preserveWatchOutput');
}
+ const logLevel = logger.getLevel();
+ const isTraceLogLevel = logLevel && /trace/i.test(logLevel);
+ if (isTraceLogLevel) {
+ nodeArgs.push("--listEmittedFiles");
+ }
+
logger.trace(process.execPath, nodeArgs.join(' '));
tsc = spawn(process.execPath, nodeArgs);
@@ -71,24 +83,28 @@ function runTypeScriptCompiler(logger, projectDir, options) {
.join("\n");
if (filteredData) {
- const logLevel = logger.getLevel();
- const isTraceLogLevel = logLevel && /trace/i.test(logLevel);
+ var infoMessage = TscWatcherInfoMessages.find((info) => filteredData.toLowerCase().indexOf(info) !== -1);
+ if (infoMessage) {
+ if (options.watch && !isResolved && infoMessage === TscCompilationCompleteMessage) {
+ isResolved = true;
+ resolve();
+ }
+
+ // ignore these info messages as they are spamming the CLI output
+ // on each file generated in the platforms folder during prepare
+ return;
+ }
if (isTraceLogLevel) {
- nodeArgs.push("--listEmittedFiles");
logger.trace(filteredData);
}
-
+
// https://github.com/Microsoft/TypeScript/blob/e53e56cf8212e45d0ebdd6affe462d161c7e0dc5/src/compiler/watch.ts#L160
if (!isTraceLogLevel && filteredData.indexOf("error") !== -1) {
logger.info(filteredData);
}
}
- if (options.watch && stringData.toLowerCase().indexOf("watching for file changes.") !== -1 && !isResolved) {
- isResolved = true;
- resolve();
- }
});
tsc.stderr.on('data', function (data) {
diff --git a/lib/watch.js b/lib/watch.js
index 8e2cde4..c6191fd 100644
--- a/lib/watch.js
+++ b/lib/watch.js
@@ -4,7 +4,7 @@ module.exports = function ($logger, $projectData, $errors, hookArgs) {
if (hookArgs.config) {
const appFilesUpdaterOptions = hookArgs.config.appFilesUpdaterOptions;
if (appFilesUpdaterOptions.bundle) {
- $logger.warn("Hook skipped because bundling is in progress.")
+ $logger.trace("Hook skipped because bundling is in progress.")
return;
}
}
diff --git a/package.json b/package.json
index ca46f2e..440f05b 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "nativescript-dev-typescript",
- "version": "0.7.4",
+ "version": "0.9.0",
"description": "TypeScript support for NativeScript projects. Install using `tns install typescript`.",
"scripts": {
"test": "exit 0",
@@ -41,6 +41,7 @@
},
"dependencies": {
"nativescript-hook": "^0.2.0",
- "semver": "5.5.0"
+ "semver": "5.5.0",
+ "typescript": "~3.1.1"
}
}
diff --git a/postinstall.js b/postinstall.js
index d8bcd03..6ba088a 100644
--- a/postinstall.js
+++ b/postinstall.js
@@ -13,22 +13,6 @@ if (projectDir) {
} else {
createTsconfig(tsconfigPath);
}
-
- const hasModules30 = upgrader.hasModules30(projectDir);
- if (!hasModules30) {
- createReferenceFile();
- }
-
- installTypescript(hasModules30);
-}
-
-function createReferenceFile() {
- var referenceFilePath = path.join(projectDir, "references.d.ts"),
- content = "/// Needed for autocompletion and compilation.";
-
- if (!fs.existsSync(referenceFilePath)) {
- fs.appendFileSync(referenceFilePath, content);
- }
}
function createTsconfig(tsconfigPath) {
@@ -48,59 +32,3 @@ function createTsconfig(tsconfigPath) {
fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 4));
}
-
-function getProjectTypeScriptVersion() {
- try {
- var packageJsonPath = path.join(projectDir, "package.json"),
- packageJsonContent = fs.readFileSync(packageJsonPath, "utf8"),
- jsonContent = JSON.parse(packageJsonContent);
-
- return (jsonContent.dependencies && jsonContent.dependencies.typescript) ||
- (jsonContent.devDependencies && jsonContent.devDependencies.typescript);
- } catch (err) {
- console.error(err);
- return null;
- }
-}
-
-function installTypescript(hasModules30) {
- const installedTypeScriptVersion = getProjectTypeScriptVersion();
- const force = shouldInstallLatest(installedTypeScriptVersion, hasModules30);
-
- if (installedTypeScriptVersion && !force) {
- console.log(`Project already targets TypeScript ${installedTypeScriptVersion}`);
- } else {
- const command = force ?
- "npm install -D typescript@latest" :
- "npm install -D -E typescript@2.1.6"; // install exactly 2.1.6
-
- console.log("Installing TypeScript...");
-
- require("child_process").exec(command, { cwd: projectDir }, (err, stdout, stderr) => {
- if (err) {
- console.warn(`npm: ${err.toString()}`);
- }
-
- process.stdout.write(stdout);
- process.stderr.write(stderr);
- });
- }
-}
-
-function shouldInstallLatest(tsVersion, hasModules30) {
- if (!hasModules30) {
- return false;
- }
-
- const justVersion = clearPatch(tsVersion);
- return !tsVersion ||
- tsVersion === "2.2.0" ||
- justVersion[0] < 2 || // ex. 1.8.10
- justVersion[2] < 2; // ex. 2.1.6
-}
-
-function clearPatch(version) {
- return version && (version.startsWith("~") || version.startsWith("^")) ?
- version.substring(1) :
- version;
-}
diff --git a/tsconfig-upgrader.js b/tsconfig-upgrader.js
index 8c12d0a..afe1b85 100644
--- a/tsconfig-upgrader.js
+++ b/tsconfig-upgrader.js
@@ -10,7 +10,7 @@ var __migrations = [
function migrateProject(tsConfig, tsconfigPath, projectDir) {
var displayableTsconfigPath = path.relative(projectDir, tsconfigPath);
- __migrations.forEach(function(migration) {
+ __migrations.forEach(function (migration) {
migration(tsConfig, displayableTsconfigPath, projectDir);
});
}
@@ -32,7 +32,7 @@ function migrateTsConfig(tsconfigPath, projectDir) {
fs.writeFileSync(tsconfigPath, JSON.stringify(existingConfig, null, 4));
}
- withTsConfig(function(existingConfig) {
+ withTsConfig(function (existingConfig) {
migrateProject(existingConfig, displayableTsconfigPath, projectDir);
});
}
@@ -54,47 +54,17 @@ function addIterableToAngularProjects(existingConfig, displayableTsconfigPath, p
var dependencies = packageJson.dependencies || [];
var hasAngular = Object.keys(dependencies).includes("nativescript-angular");
- var hasRelevantAngularVersion = /[4-9]\.\d+\.\d+/i.test(dependencies["@angular/core"]);
- if (hasAngular && hasRelevantAngularVersion) {
- console.log("Adding 'es2015.iterable' lib to tsconfig.json...");
+ if (hasAngular) {
+ console.log("Adding 'es2015.iterable' lib to tsconfig.json...");
addTsLib(existingConfig, "es2015.iterable");
}
}
-function hasModules30(projectDir) {
- function relevantModulesVersion(version) {
- return /[3-9]\.\d+\.\d+/i.test(version);
- }
-
- function hasRelevantModulesDependency() {
- var packageJsonPath = path.join(projectDir, "package.json");
- var packageJson = JSON.parse(fs.readFileSync(packageJsonPath));
- var dependencies = packageJson.dependencies || [];
-
- return relevantModulesVersion(dependencies["tns-core-modules"]);
- }
-
- function hasRelevantModulesPackage() {
- var packageJsonPath = path.join(projectDir, "node_modules", "tns-core-modules", "package.json");
- if (!fs.existsSync(packageJsonPath)) {
- return false;
- }
-
- var packageJson = JSON.parse(fs.readFileSync(packageJsonPath));
- return relevantModulesVersion(packageJson.version);
- }
-
- return hasRelevantModulesDependency() || hasRelevantModulesPackage();
-}
-exports.hasModules30 = hasModules30;
-
function addDomLibs(existingConfig, displayableTsconfigPath, projectDir) {
- if (hasModules30(projectDir)) {
- console.log("Adding 'es6' lib to tsconfig.json...");
- addTsLib(existingConfig, "es6");
- console.log("Adding 'dom' lib to tsconfig.json...");
- addTsLib(existingConfig, "dom");
- }
+ console.log("Adding 'es6' lib to tsconfig.json...");
+ addTsLib(existingConfig, "es6");
+ console.log("Adding 'dom' lib to tsconfig.json...");
+ addTsLib(existingConfig, "dom");
}
function addTsLib(existingConfig, libName) {
@@ -103,31 +73,25 @@ function addTsLib(existingConfig, libName) {
if (!options.lib) {
options.lib = [];
}
- if (!options.lib.find(function(l) {
- return libName.toLowerCase() === l.toLowerCase();
- })) {
+ if (!options.lib.find(function (l) {
+ return libName.toLowerCase() === l.toLowerCase();
+ })) {
options.lib.push(libName);
}
}
}
function addTnsCoreModulesPathMappings(existingConfig, displayableTsconfigPath, projectDir) {
- if (hasModules30(projectDir)) {
- console.log("Adding tns-core-modules path mappings lib to tsconfig.json...");
- existingConfig["compilerOptions"] = existingConfig["compilerOptions"] || {};
- var compilerOptions = existingConfig["compilerOptions"];
- compilerOptions["baseUrl"] = ".";
- compilerOptions["paths"] = compilerOptions["paths"] || {};
-
- const appPath = getAppPath(projectDir);
- compilerOptions["paths"]["~/*"] = compilerOptions["paths"]["~/*"] || [
- `${appPath}/*`
- ];
- compilerOptions["paths"]["*"] = compilerOptions["paths"]["*"] || [
- "./node_modules/tns-core-modules/*",
- "./node_modules/*"
- ];
- }
+ console.log("Adding tns-core-modules path mappings lib to tsconfig.json...");
+ existingConfig["compilerOptions"] = existingConfig["compilerOptions"] || {};
+ var compilerOptions = existingConfig["compilerOptions"];
+ compilerOptions["baseUrl"] = ".";
+ compilerOptions["paths"] = compilerOptions["paths"] || {};
+
+ const appPath = getAppPath(projectDir);
+ compilerOptions["paths"]["~/*"] = compilerOptions["paths"]["~/*"] || [
+ `${appPath}/*`
+ ];
}
function getAppPath(projectDir) {
@@ -138,7 +102,7 @@ function getAppPath(projectDir) {
const nsConfig = JSON.parse(fs.readFileSync(nsConfigPath));
const appPath = nsConfig && nsConfig.appPath;
return appPath || DEFAULT_PATH;
- } catch(_) {
+ } catch (_) {
return DEFAULT_PATH;
}
}