ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

Proper way to initialize an Ionic project from existing sources

Open ebrehault opened this issue 12 years ago • 17 comments

Let's say I have an existing Ionic project in a Git repository. If I clone this rep and try ionic start myapp blank, it will offer to override all the existing folder content or cancel. If I do not use the start command and try ionic platform add android from the existing sources, I get:

Error: ENOENT, no such file or directory '/__the__path__/plugins/android.json'

Is there a correct way to initialize a project from existing sources?

ebrehault avatar Oct 08 '14 12:10 ebrehault

Hey @ebrehault, if you're using bower, you should just be able to copy the bower.json file to the new project. From there you could initialize the project and the dependencies would be the same.

If not, you can still initialize a new bower project and add all the packages used in your current project.

drewrygh avatar Oct 08 '14 21:10 drewrygh

Hi @drewrygh,

Ok, so you mean: we start a new blank project with the ionic command, then we copy bower.json (and also ./www I guess) from the existing sources, and we deploy deps with bower. I agree it works, but copying files manually is not a very stable process (one can forget a file, put them at the wrong place, etc.), that kind of operation must be handled by git.

I have used the following approach:

$ ionic start myapp blank
$ cd myapp
$ git init
$ git remote add origin my_app_repo
$ git fetch --all
$ git reset --hard origin/master

and it works fine, but ideally, we would like something like:

$ git clone my_app_repo
$ cd my_app_repo
$ ionic start . --no-overwriting

ebrehault avatar Oct 09 '14 07:10 ebrehault

Hey @ebrehault - I was thinking you just wanted to initialize and use the previous dependencies. You're right, if you're starting from an exisiting angular app, the merge really should be handled by git.

Adding a --no-overwrite flag to initialization for the CLI seems like a pretty good idea. Another option might be:

cp ionic-blank/ existing-app/ -n -R

This should copy the initialized ionic starter without overwriting in existing-app/. Using git to merge would be the safest bet though since you'd be able to resolve any conflicts. Anyway, thanks for pointing this out!

drewrygh avatar Oct 10 '14 16:10 drewrygh

Closing this - git will always be the safest way to handle this, and it only needs to be done once (for a very small percentage of projects).

drewrygh avatar Oct 17 '14 19:10 drewrygh

It seems like it'd need to be done for every time a new developer is added to an existing ionic project. I'd definitely vote for a command line option that allows a user to pull in an existing project and get started without having to resort to git trickery.

gortok avatar May 06 '15 16:05 gortok

+1

lmk123 avatar Aug 10 '15 03:08 lmk123

+1

jgillard avatar Aug 14 '15 12:08 jgillard

+1

ephbaum avatar Aug 23 '15 14:08 ephbaum

+1

xezpeleta avatar Sep 10 '15 14:09 xezpeleta

I have to say, @drewrygh, I think you're last response before closing this was a touch too cavalier. I suspect this is a far more common issue than you might think.

I have needed to work around this situation more than once for projects because I have to work between OS X and Windows regularly, I've also had to walk interns and new devs through the process of starting work with existing projects.

For my team the pain point really comes from the fact that we, for reasons that aren't worth arguing about here, use SVN and not Git for version control, which throws your argument more or less out the window since Git cannot be our answer in this case and the corresponding SVN commands

Regardless, however, it seems like there needs a better way of initializing existing projects using the Ionic CLI. I feel like I should be able to commit my project root with configuration files as well as my www/ and merges/ and then use Ionic's CLI to initialize my project from there...

As @ebrehault mentioned above, a good workflow could be:

$ git clone my_app_repo
$ cd my_app_repo
$ ionic start . --no-overwriting

Though in our case we'd use, for example, something like this:

> svn checkout [URL] my_app/
> cd my_app/
> ionic start . --no-overwriting

Perhaps that's introducing too much 'package management' into things, but it really feels like the logical way to handle projects. We should be able to spin up existing Ionic projects as easily as we can start a new one without a lot of copying files, git flags, or anything else!

</twocents> :smile:

ephbaum avatar Sep 10 '15 15:09 ephbaum

+1

jbdemonte avatar Sep 23 '15 09:09 jbdemonte

+1

geekuillaume avatar Sep 30 '15 01:09 geekuillaume

As I am the one who initiated this discussion one year ago, I want to mention that now with the current version of Ionic, you can create a Ionic project, work on it, put it into a git repo, and then clone it somewhere else and just do:

$ ionic platform add android

and everything is setup properly and works fine.

So I think this issue is really resolved now.

ebrehault avatar Sep 30 '15 07:09 ebrehault

Still the question got unanswered which everybody wants to know

shamil707 avatar Sep 11 '16 04:09 shamil707

I pulled the remote repository, go into the Ionic-app root-folder and do in bash npm install worked for me. After that just did in bash ionic serve and it started running like it should.

Crare avatar Nov 22 '16 16:11 Crare

That works too. if you still get a blank screen you need to install the bower dependencies bower install. if you don't have bower you need to install it npm install -g bower. The you can ionic serve and it should work

adriandia avatar Dec 24 '16 18:12 adriandia

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

ionitron-bot[bot] avatar Sep 05 '18 13:09 ionitron-bot[bot]