Skip to content
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

feat: generators #50

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

NathanWalker
Copy link

@NathanWalker NathanWalker commented Dec 30, 2023

Summary

Right now, there are no built-in generators for building apps. Everything from component creation, to generating types and auto configuring the project for their usage, to creating widgets (iOS and Android boilerplate setup like the folder where it goes and supporting files like extension.json).

Generators help speed up development but can also help encourage best practices from naming things to even initial file setup.

@nativescript/nx and xplat come with generators to help project setup/creation/development however they come with other aspects that make them not as easy to pick up and just use right after setting up a NativeScript development machine.

Basic example

Swift/Kotlin generators for when wanting to drop in either and use with {N} apps, eg:

ns g swift MyFile

ns g kotlin MyFile

This would do several manual steps in one go:

  • create a file with all the structure in place and into right place for {N} app to use right away
  • prompts could occur for those which need it, for example a Kotlin file may ask what package scope it should be in (eg: org.my-company.custom-kotlin)
  • could also work hand/hand to auto create TypeScript declarations based off any changes in those files and auto update project ref's so TS intellisense in the project is always up to date

Integration generators, eg:

// auto integrate flutter screen  
// sets up the podfile/app.gradle to use a folder of Dart code
// registers the flutter screen, creates boilerplate with the vm entry already named and ready for use
ns g flutter MyScreen 

// auto integrate RN modules
// install open-native, configure bundler for all named modules
ns g react-native module,module2,module3

// auto integrate Ionic Portal
// creating the build settings for it too
ns g capacitor MyPortal

// component generators
// would work for all flavors
// create start boilerplate component ready to use
// default to auto detect flavor in  use by introspecting project
ns g component MyComponent --flavor=solid

ns g component MyComponent --flavor=vue

// create web deploy target
// add a web project alongside {N} auto setup to share code with the {N} project - create with any flavor using preferred flavor project creators (prompting to drop in workspace if needed)
ns g web MySite --flavor=angular

Motivation

Improve developer experience and speed up project development.

Drawbacks

Depending on implementation direction chosen, may introduce some maintenance. However there are steps which could be taken to minimize extra maintenance overhead like keeping the generation as minimal as possible reducing surface area of potential external environment changes (like if Solid syntax changed somewhere in a component generated).

The generators could become plug/play as well by other communities to allow easier self sustaining generation by interested communities to allow them to self govern what's generated.

Adoption strategy

Just documentation.

Unresolved questions

Whether various tools out there like builder.io Mitosis could/should be used for component interop with the generator.

@cla-bot cla-bot bot added the cla: yes label Dec 30, 2023
@jcassidyav
Copy link

I played around with basic java/kotlin/swift/objective-c generator a while back here.

I got sort of bogged down in:

  • what context should they support

    • simple app
    • plugin
    • nx repo
  • Would this sort of thing be better in a VSCode extension instead.

@NathanWalker
Copy link
Author

One part of this has been addressed in 8.8, ns native add as mentioned here:
https://blog.nativescript.org/nativescript-8-8-announcement/#ns-native

@wuilmerj24
Copy link

Hello, I think it would be a good idea to be able to create plugins like this in a future update.
ns create plugin > config plugin and setup > add android and iOS platforms

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.

3 participants