Skip to content

Add support for different templates #1218

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 2 commits into from
Nov 30, 2015

Conversation

rosen-vladimirov
Copy link
Contributor

Add support for --template option when creating new project.
The value for --template can be anything that you can npm install. For example valid calls are:

  • tns create app1 --template tns-template-hello-world
  • tns create app1 --template https://github.com/NativeScript/template-hello-world-ts/tarball/master
  • tns create app1 --template ../myTemplate
  • tns create app1 --template https://github.com/NativeScript/template-hello-world-ts.git
  • tns create app1 --template https://github.com/NativeScript/template-hello-world-ts.git#master

In case you use:
tns create app1 --template typescript or tns create app1 --template tsc, CLI will try to install tns-template-hello-world-ts template.
In case you use tns create app1 --template [email protected] we will install version 1.2.0 of tns-template-hello-world-ts.

When a custom template is used, CLI will extend its App_Resources with the ones from default template in case any of them is missing.

NOTE: Updating npm version to latest 2.x as our current version (2.6.1) fails when trying to execute: npm install https://github.com/nativescript/template-hello-world.git

npm ERR! fetch failed https://github.com/nativescript/template-hello-world.git
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 406
npm ERR! fetch failed https://github.com/nativescript/template-hello-world.git
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 406

Implements #374

@rosen-vladimirov rosen-vladimirov self-assigned this Nov 19, 2015
@rosen-vladimirov rosen-vladimirov added this to the 1.6.0 (Under consideration) milestone Nov 19, 2015
@ns-bot
Copy link

ns-bot commented Nov 19, 2015

Test PASSed.

}

this.$logger.trace("New project package.json data: ", projectPackageJsonData);
this.$fs.writeJson(projectPackageJsonPath, projectPackageJsonData).wait();
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 delete the dependencies from template's package.json?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe it's better to delete template's package.json :)

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've added code to delete the package.json from app dir

@rosen-vladimirov rosen-vladimirov force-pushed the vladimirov/add-ns-templates branch from 40c3d1d to c785049 Compare November 26, 2015 10:18
@ns-bot
Copy link

ns-bot commented Nov 26, 2015

Test PASSed.

this.$logger.out("Project %s was successfully created", projectName);

}).future<void>()();
}

private mergeProjectAndTemplateProperties(projectDir: string, templatePath: string): IFuture<any> {
Copy link
Contributor

Choose a reason for hiding this comment

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

You are not returning but the return type is Future. Consider Future

@rosen-vladimirov rosen-vladimirov force-pushed the vladimirov/add-ns-templates branch from c785049 to 0edeec5 Compare November 30, 2015 07:26
@ns-bot
Copy link

ns-bot commented Nov 30, 2015

Test PASSed.

@dtopuzov
Copy link
Contributor

💯

@ns-bot
Copy link

ns-bot commented Nov 30, 2015

Test PASSed.

@teobugslayer
Copy link
Contributor

👍

@rosen-vladimirov rosen-vladimirov force-pushed the vladimirov/add-ns-templates branch from 56fbe6a to df92027 Compare November 30, 2015 13:59
@ns-bot
Copy link

ns-bot commented Nov 30, 2015

Test PASSed.

Add support for --template option when creating new project.
The value for `--template` can be anything that you can `npm install`. For example valid calls are:
* `tns create app1 --template tns-template-hello-world`
* `tns create app1 --template https://github.com/NativeScript/template-hello-world-ts/tarball/master`
* `tns create app1 --template ../myTemplate`

In case you use:
`tns create app1 --template typescript` or `tns create app1 --template tsc`, CLI will try to install `tns-template-hello-world-ts` template.
In case you use `tns create app1 --template [email protected]` we will install version 1.2.0 of `tns-template-hello-world-ts`.

When a custom template is used, CLI will extend its App_Resources with the ones from default template in case any of them is missing.

Update npm version in order to support .git urls for --template option.
When `tns create <app>` is executed, install all dependencies, so typescript compilation will be enabled immediately when using tsc template.
@rosen-vladimirov rosen-vladimirov force-pushed the vladimirov/add-ns-templates branch from df92027 to 3ad7872 Compare November 30, 2015 14:40
@ns-bot
Copy link

ns-bot commented Nov 30, 2015

Test PASSed.

@teobugslayer
Copy link
Contributor

👍

rosen-vladimirov added a commit that referenced this pull request Nov 30, 2015
@rosen-vladimirov rosen-vladimirov merged commit cb0b668 into master Nov 30, 2015
@rosen-vladimirov rosen-vladimirov deleted the vladimirov/add-ns-templates branch November 30, 2015 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants