Skip to content

Init command #605

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
Jul 1, 2015
Merged

Init command #605

merged 1 commit into from
Jul 1, 2015

Conversation

Fatme
Copy link
Contributor

@Fatme Fatme commented Jun 30, 2015

Should be merged after this telerik/mobile-cli-lib#371
#600

@Fatme Fatme added this to the 1.1.2 milestone Jun 30, 2015
@Fatme Fatme self-assigned this Jun 30, 2015
@ns-bot
Copy link

ns-bot commented Jun 30, 2015

---|---
General | `$ tns init [--path <Directory>] [--force]`

Initializes a project for development. This will ask you a bunch of questions, and then write a package.json for you.
Copy link
Contributor

Choose a reason for hiding this comment

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

"ask you a bunch of questions" does not look very professional to me. Perhaps "it will ask you interactively to configure the project". Ping @ikoevska

@ns-bot
Copy link

ns-bot commented Jul 1, 2015

let projectDataBackup = _.extend({}, projectData);

try {
this.$fs.writeJson(this.projectFilePath, projectData).wait(); // We need to create package.json file here in order to prevent "No project found at or above and neither was a --path specified." when resolving platformsData
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe this should be inside

if(!projectData[this.$staticConfig.CLIENT_NAME_KEY_IN_PROJECT_FILE])

as this is the only case when we do not have package.json or it is missing required information. In all cases when we do not "enter" the mentioned if, we should not write the package.json again as it is already existing and correct.

@ns-bot
Copy link

ns-bot commented Jul 1, 2015


let data = this.$npm.view(packageName, "versions").wait();
let versions = data[latestVersion].versions;
let sortedVersions = versions.sort(helpers.versionCompare).reverse();
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest to have minSupportedVersion, because currently we show all versions and the user may set something that will not be buildable after that, for example for tns-android I set 0.1.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure how can I select "minSupportedVersion"...

Copy link
Contributor

Choose a reason for hiding this comment

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

My suggestion is to define it in the platformData and pass it as parameter to this method. This way we'll set it to the minimum verified version that we are able to work with.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

" This way we'll set it to the minimum verified version that we are able to work with." - every next version has some improvements and fixes. I'm not able to choice if for example 1.0.0 is suitable to be "minSupportedVersion".

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, if I set 0.1.0 and execute tns install, the result is:

~/Work/nativescript-cli/scratch/app16 $ cat package.json 
{
    "nativescript": {
        "id": "org.nativescript.app16",
        "tns-android": {
            "version": "0.1.0"
        }
    }
}~/Work/nativescript-cli/scratch/app16 $ tns install
Project app16 was successfully created
Adding platforms...
Copying template files...
ENOENT, scandir '/home/rvladimirov/.npm/tns-android/0.1.0/package/framework/res'

Of course all versions have improvements, but when you use init, I think we must show you only recent versions, why would you init project with version 0.4.2 for example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This means that the prompt is unneeded?

Copy link
Contributor

Choose a reason for hiding this comment

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

My idea is to guide the people to use latest versions.

@rosen-vladimirov
Copy link
Contributor

npm init checks node_modules and adds each of them directly in the dependencies section of the created package.json
It will be nice to support this in case you do not have package.json (in case it already exists, I assume you have already set the dependencies you want).
@ligaz what do you think (we can consider this for another PR)

@Fatme
Copy link
Contributor Author

Fatme commented Jul 1, 2015

It is strange to have node_modules and doesn't have package.json file.

@ns-bot
Copy link

ns-bot commented Jul 1, 2015

Command | Description
----------|----------
[init](init.html) | Initializes a project for development. It will ask you interactively to configure the project and will write a package.json for you.
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the second sentence from the description. Also, consider adding this command to the Related Commands of install.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

install command is in project/configuration section and the init command is in project/creation. Do I need to relate them?

@ns-bot
Copy link

ns-bot commented Jul 1, 2015

---|---
General | `$ tns init [--path <Directory>] [--force]`

Initializes a project for development. It will ask you interactively to configure the project and will write a package.json for you.
Copy link
Contributor

Choose a reason for hiding this comment

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

Initializes a project for development. The command prompts you to provide your project configuration interactively and uses the information to create a new package.json file or update the existing one.

@ns-bot
Copy link

ns-bot commented Jul 1, 2015

}

private set projectFilePath(newProjectFilePath: string) {
this._projectFilePath = newProjectFilePath;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we verify that newProjectFilePath is correct? I.e. is non-empty string and possibly that exists on the fs?
By the way, where is the setter used?


import constants = require("./../constants");
import helpers = require("./../common/helpers");
import Future = require("fibers/future");
Copy link
Contributor

Choose a reason for hiding this comment

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

Future is not used anywhere, you can remove it

@ns-bot
Copy link

ns-bot commented Jul 1, 2015

---|---
General | `$ tns init [--path <Directory>] [--force]`

Initializes a project for development. The command prompts you to provide your project configuration interactively and uses the information to create a new package.json file or update the existing one.
Copy link
Contributor

Choose a reason for hiding this comment

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

code formatting for package.json is missing.

@rosen-vladimirov
Copy link
Contributor

👍

@ns-bot
Copy link

ns-bot commented Jul 1, 2015

@ns-bot
Copy link

ns-bot commented Jul 1, 2015

@ns-bot
Copy link

ns-bot commented Jul 1, 2015

@ikoevska
Copy link
Contributor

ikoevska commented Jul 1, 2015

👍

Fatme pushed a commit that referenced this pull request Jul 1, 2015
@Fatme Fatme merged commit ff330c9 into release Jul 1, 2015
@Fatme Fatme deleted the fatme/init branch July 1, 2015 12:43
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