Nativescript-cli: [Feature Request] Interactive `tns create`

Created on 21 Aug 2018  Â·  10Comments  Â·  Source: NativeScript/nativescript-cli

Current Behavior

The current behavior of tns create command used to create a NativeScript project is described in details in our documentation. Here is how it works in short:

  • tns create MyApp creates MyApp project using pure JavaScript

    • additional options --ng, --tsc are available to create the project in TypeScript or Angular flavor (tns create MyApp --ng, tns create MyApp --tsc)

    • project can be created from a predefined template (Tabs, Master-Detail, SideDrawer, etc)

Proposed Behavior

Provide an interactive tns create command as follows:

tns create MyApp

? Choose a framework
> Angular
> Vue.js
> None

? Choose a template
> Hello World
> Blank
> SideDrawer
> Tabs

If Angular framework is chosen, the Blank option should be split in two:

> Blank (Mobile)
> Blank (Web + Mobile)

Choosing None will create the project in TypeScript flavor.

All existing options will continue to work as is. In addition,

  • a new option --js should be added to allow the creation of a JavaScript project directly
  • a new option --vue should be added to allow the creation of a Vue.js project directly
feature breaking-change

Most helpful comment

Sounds great!

One suggestion - perhaps instead of none the prompt could give you JavaScript & TypeScript options.

All 10 comments

Sounds great!

One suggestion - perhaps instead of none the prompt could give you JavaScript & TypeScript options.

LGTM!

Just a few notes about the vue template: I'm not sure if we can add vue with the current vue setup, because right now we are scaffolding new projects using vue-cli. There is a new version of the template on the next branch which has been simplified and is structured more like a typical NS app. We could make this a normal NS template but we would loose some of the prompts we have with vue-cli. We are also working on a vue cli 3.x plugin which will abstract the webpack setup away, so that it can be managed as a dependency (easier upgrades in the future), and I'm not entirely sure if we can have that work as both an NS template, and a vue-cli plugin (needs some researching on my end).

@NickIliev This is also an option but we thing that TypeScript gives more benefits to the development and that's why we would like to promote is THE option for None framework. There will be still an option to create a JavaScript project using the --js option.

@rigor789 I realize that with Vue currently we don't have these templates and we need to think how to achieve it. It would be nice to find some solution and give the Vue framework visibility through the tns create.

Sounds great! I would add the --force flag which creates a project in the current non-interactive way.

I'm also for TypeScript/JavaScript option, but it should be the next step for Vue/None, not instead of None. Vue landscape has TypeScript but it is not predominant like for Angular.

Love this initiative!

My feedback:

1) It’s weird that we have both “Blank” and “Hello World” templates, as most people consider those to be the same thing. Can the “Hello World” ones just go away?

2) I’d like to see more words to guide the user. We don’t have to finalize the exact wording now, but this is a rough idea of what I mean.

tns create MyApp

Let’s create a NativeScript app!

Answer the following two questions to help us build the right app for you. (Note: you
can skip this prompt next time using the --template option, or the --ng, --vue, --ts,
or --js flags.)

? First, which framework would you like to use? (Use arrow keys to select)
> Angular   | Learn more at https://angular.io/
> Vue.js    | Learn more at https://vuejs.org/
> None      | Use NativeScript without any additional JavaScript frameworks

Great!

? Next, which template would you like to start from? (Use arrow keys to select)

> Blank        | An empty app
> SideDrawer   | An app with pre-built pages that uses a drawer for navigation
> Tabs         | An app with pre-built pages that uses tabs for navigation
> Code Sharing | Build iOS, Android, and web apps simultaneously from one codebase.

Perfect! You’re good to go. Here are your next steps:

-> **cd MyApp** to navigate into your new app
-> **tns run** to run your app on a USB-connected device, iOS simulator,
    or Android emulator.

I personally like the vue-cli 3 prompts and flow. It is really neat.

image

+1 for @NickIliev comment
? Choose a framework: None sounds a bit too negative and discouraging to me -- I'd vote about mentioning TypeScript explicitly in there (unless we are intentionally trying to steer newcomers away from no framework :))

+1 for @tjvantoll comment too -- people would love more descriptive choices :)

Was this page helpful?
0 / 5 - 0 ratings