Skip to content

Use tns_modules from npm #805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2015
Merged

Conversation

e2l3n
Copy link
Contributor

@e2l3n e2l3n commented Aug 20, 2015

Use npm to fetch tns-core-modules package.
Create tns_modules folder from tns-core-modules package.
See issue #390

@ns-bot
Copy link

ns-bot commented Aug 20, 2015

Can one of the admins verify this patch?

@@ -1,3 +1,8 @@
interface ITNSModulesService {
tnsModulesInstallationPath(projectRoot: string): IFuture<string>;
NPM_TNS_CORE_MODULES_NAME: string;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention for property names is to use camelCase.

@teobugslayer
Copy link
Contributor

The build fails executing unit tests with Error: unable to resolve tnsModulesService. Can you please verify that unit tests work?

///<reference path="../.d.ts"/>
"use strict";

import util = require("util");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using ES2015 style imports where possible

@ligaz
Copy link

ligaz commented Aug 20, 2015

I'm not sure that the currently implemented workflow is the right one. The process should be like:

  • create new project from template
  • check if the template has tns_modules as dependencies and if not add them in the package.json
  • npm install

import path = require("path");
import shell = require("shelljs");
import npm = require("npm");
var helpers = require("../common/helpers");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can import here. By the way, are these imports used? If not, you can remove them.

@teobugslayer
Copy link
Contributor

Consider writing unit tests for TNSModulesService.

@e2l3n e2l3n force-pushed the tpopov/tns-core-modules branch 3 times, most recently from abea2b7 to 3a7b69f Compare August 20, 2015 19:22
}
else {
let coreModulesName = this.$tnsModulesService.npmTnsCoreModulesName;
tnsModulesVersion = this.$fs.readJson(path.join(appPath, constants.PACKAGE_JSON_FILE_NAME)).wait()[coreModulesName]["version"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using $projectDataService instead readJson

@e2l3n e2l3n force-pushed the tpopov/tns-core-modules branch from bcaba8b to 6215768 Compare August 21, 2015 13:41
@@ -111,6 +113,9 @@ export class ProjectService implements IProjectService {

this.$projectDataService.initialize(projectDir);
this.$projectDataService.setValue("id", projectId).wait();
//Start child process because --save --save-exact option is necessary when installing tns-core-modules
//in order to create "dependencies" key in package.json.
this.$childProcess.exec("npm install " + constants.TNS_CORE_MODULES_NAME + " --save --save-exact", { cwd: projectDir }).wait();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be better to use INodePackageManager and expose this functionality there?

@e2l3n e2l3n force-pushed the tpopov/tns-core-modules branch from 13761a1 to f768c15 Compare August 21, 2015 16:06
@e2l3n
Copy link
Contributor Author

e2l3n commented Aug 21, 2015

I will squash all commits right before merging this pull request.

@@ -75,6 +75,11 @@ export class DestCopy implements IBroccoliPlugin {
if(isPlugin) {
this.$pluginsService.prepare(dependency).wait();
}

if (dependency.name == constants.TNS_CORE_MODULES_NAME) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use === instead ==

@e2l3n e2l3n force-pushed the tpopov/tns-core-modules branch from 34067fe to 1f1543d Compare August 24, 2015 19:41
let tnsModulesVersion: string = this.$options.tnsModulesVersion;
let packageName: string = constants.TNS_CORE_MODULES_NAME;
if (tnsModulesVersion) {
packageName = packageName.concat("@" + tnsModulesVersion);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use packageName = ${packageName}@${tnsModulesVersion}

@e2l3n e2l3n force-pushed the tpopov/tns-core-modules branch from c028a0e to 2a68d08 Compare August 25, 2015 11:47
@e2l3n e2l3n force-pushed the tpopov/tns-core-modules branch from 2a68d08 to 6d56327 Compare August 25, 2015 11:52
this.$broccoliBuilder.prepareNodeModules(tnsModulesDestinationPath, this.$projectData.projectDir, platform, lastModifiedTime).wait();
} catch(error) {
this.$logger.debug(error);
this.$logger.error("Processing tns core modules failed.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is user visible error. Consider at least showing the users the actual error. This way, they have a chance to understand what went wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error might be produced while processing some other module or plugin. It is not obligatory to be produced while "Processing tns core modules"

@teobugslayer
Copy link
Contributor

👍 after addressing my small remark and a green build.

@@ -111,6 +112,14 @@ export class ProjectService implements IProjectService {

this.$projectDataService.initialize(projectDir);
this.$projectDataService.setValue("id", projectId).wait();

let tnsModulesVersion: string = this.$options.tnsModulesVersion;
let packageName: string = constants.TNS_CORE_MODULES_NAME;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not need to specify the variable type.

@e2l3n e2l3n force-pushed the tpopov/tns-core-modules branch from 6d56327 to d906519 Compare August 25, 2015 13:46
@e2l3n e2l3n force-pushed the tpopov/tns-core-modules branch from d906519 to 8f9283c Compare August 25, 2015 13:52
e2l3n added a commit that referenced this pull request Aug 25, 2015
@e2l3n e2l3n merged commit e57fa5f into NativeScript:master Aug 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants