Skip to content

Commit 967da67

Browse files
Init command should not force tns-core-modules version
Currently `tns init` command forces the application to use the default version of tns-core-modules. For example in case your CLI is version 1.4.3, `tns init` in non-interactive terminal will set version 1.4.0 (latest 1.4.x) of tns-core-modules even in case you already have defined your version in your package.json Use --tnsCoreModules option by default - if it is specified, it has highest priority. In case the console is not interactive, check if package.json has entry in dependencies section for tns-core-modules and use it. In case the console is interactive, show all available versions to the user and let him pick up the one he wants. In case the console is not interactive and the package.json does not have entry for `tns-core-modules`, use the default logic.
1 parent 2176482 commit 967da67

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/services/init-service.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ export class InitService implements IInitService {
6060
if(!dependencies) {
6161
projectData.dependencies = Object.create(null);
6262
}
63-
projectData.dependencies[constants.TNS_CORE_MODULES_NAME] = this.getVersionData(constants.TNS_CORE_MODULES_NAME).wait()["version"];
63+
// In case console is interactive and --force is not specified, do not read the version from package.json, show all available versions to the user.
64+
let tnsCoreModulesVersionInPackageJson = this.useDefaultValue ? projectData.dependencies[constants.TNS_CORE_MODULES_NAME] : null;
65+
projectData.dependencies[constants.TNS_CORE_MODULES_NAME] = this.$options.tnsModulesVersion || tnsCoreModulesVersionInPackageJson || this.getVersionData(constants.TNS_CORE_MODULES_NAME).wait()["version"];
6466

6567
this.$fs.writeJson(this.projectFilePath, projectData).wait();
6668
} catch(err) {
@@ -106,7 +108,7 @@ export class InitService implements IInitService {
106108
let data = this.$npm.view(packageName, "versions").wait();
107109
let versions = _.filter(data[latestVersion].versions, (version: string) => semver.gte(version, InitService.MIN_SUPPORTED_FRAMEWORK_VERSIONS[packageName]));
108110
if(versions.length === 1) {
109-
this.$logger.info(`Only ${versions[0]} version is available for ${packageName} framework.`);
111+
this.$logger.info(`Only ${versions[0]} version is available for ${packageName}.`);
110112
return this.buildVersionData(versions[0]);
111113
}
112114
let sortedVersions = versions.sort(helpers.versionCompare).reverse();

0 commit comments

Comments
 (0)