Skip to content

Instantly share code, notes, and snippets.

@vladimir-kotikov
Last active August 29, 2015 14:23
Show Gist options
  • Save vladimir-kotikov/c4b9507fea4a69d6c151 to your computer and use it in GitHub Desktop.
Save vladimir-kotikov/c4b9507fea4a69d6c151 to your computer and use it in GitHub Desktop.
Cordova plugin/project API proposal v.2

Cordova project workflow

  • Create new project

    Why need to create a project, not an simple dir structure?

    • Basically project is a www dir, filled up with app code, plus config.xml, which can be retrieved from runtime. Currently config.xml is also stores a non-runtime configuratio,. which relates to build, package and code signing process. Maybe we can split it into two separate files?
  • Add a platform

    Why separate action for add. Maybe just to fetch platform from NPM?

    • To perform all actions for platform it is only necessary to know about www directory and config.xml file (which also can be presented as ConfigParser instance isntead of physical location).
  • Install a plugin

    Why separate action for add. Maybe just fetch plugin?

    • Because we need to modify project's files and dir structure to cretate a valid IDE/build system project.

    What with plugins, beacuse they will modify the www folder as well?

    • Possible options:
      • Apply plugin modifications to www dir each time when build.
      • Store plugins' made modifications in separate dir - generate once, after plugin install, apply each time before build.
  • Prepare project

  • Compile project

  • Build a project

    • These all are closely related, so probably prepare as a separate step is not needed? Do prepare always before build and remove compile at all.
  • Run an app

  • Emulate app

    • Emulate in general is not required, because it is equal to run with target==emulator.

Future workflow.

* Create a htm+js app - simply www folder with content + config.xml file
* Add a platform - just fetches platform from NPM to local node_modules. Probably might add info about installed platforms to project.xml/.json file, which is just a project description. Possible alternative - add it to config.xml - unwanted, since this info unrelated to app's runtime, but describes a build environment.
* Add a plugin - similar to adding a platform.

> Staging area is a directory, where intermediate platform projects is being stored. Required for caching platform projects to remove the performance gap while building a huge projects. The staging dir should be updated only when new plugins get added (update platform project configs, add new sorce files/libs, etc.) or when new platform is being added (add new platform project to staging area).

* Build - multiple steps.
	* If platform project is not staged yet, do it now. This includes creating of IDE template, adding plugin
	* Copy www dir to staging/platform project

TBD....

Concept:

  • CLI - only an orchestrator for ProjectApi && PlatformApi + env variables and command line arguments parser.
  • LIB - collection of classes & utils (see grunt API as an example: http://gruntjs.com/api/grunt ). Proposed members:
    • ConfigParser
    • Events module
    • Utils:
      • Superspawn
  • Plugin - a storage of js and native sources, www assets and libs for implementing particular functionality + installation description, ie. will be left as is.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment