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

How to update app without losing association storage #99

Open
ghost opened this issue Nov 6, 2020 · 10 comments
Open

How to update app without losing association storage #99

ghost opened this issue Nov 6, 2020 · 10 comments
Labels
🙋‍♂️ help wanted We want YOU to help!

Comments

@ghost
Copy link

ghost commented Nov 6, 2020

I am developing an app which makes use of the RocketChatAssociationRecord for rooms.
When I try to deploy a new version, it fails with " › Error: ⟿ Error: Deployment error: App already exists.".
But if I uninstall the app first, it removes all associated storage.

How can I update an app without losing stored data?

Is there an "update" command, or a check for a new version number? Can't find either

@JargeZ
Copy link

JargeZ commented Nov 22, 2020

You should use rc-apps deploy --url=http://localhost:3000 --update

P.S. However, I agree that it would be more convenient to have one deployment command that either installs or updates the application itself

@d-gubert
Copy link
Member

Totally agreed. @ritwizsinha introduced the new watch command as his GSoC project that doesn't run into this error, so maybe that command already checks for this case.

Maybe it's the case of extracting the logic into a function and reusing it? :)

@d-gubert d-gubert added the 🙋‍♂️ help wanted We want YOU to help! label Nov 23, 2020
@JargeZ
Copy link

JargeZ commented Nov 23, 2020

@d-gubert If I understand correctly, the watch command is needed for development.
and by the way, I just tried it and get the error:

Error: Cannot find module 'chokidar'
$ rc-apps -v
@rocket.chat/apps-cli/1.7.3 linux-x64 node-v14.15.1

After installing the module manually, it worked, it looks like you need to add it depending on it
But it still looks like it shouldn't be - No changes were made
Imgur

And for use in CI/CD pipelines, it would be convenient for the deployment command to immediately update the application if it is already installed by one rc-apps deploy call

@ritwizsinha
Copy link
Contributor

@JargeZ, this is happening because, by default it is watching the current directory for changes and redeploying on any change, as the dist folder is updated everytime after packaging, it redeploys again and again. For avoiding this you can specify which folder and files to avoid watching for changes. This can be done by adding a rcappsconfig file and add the list of ignored files or folders or files in the ignoredFiles array as follows:
You can also add the local url to deploy to, the username and the password here, so as to avoid passing that again and again.
The file is in JSON format.

        url: 'http://localhost:3000',
            username: '',
            password: '',
            ignoredFiles: [
                '**/README.md',
                '**/package-lock.json',
                '**/package.json',
                '**/tslint.json',
                '**/tsconfig.json',
                '**/*.js',
                '**/*.js.map',
                '**/*.d.ts',
                '**/*.spec.ts',
                '**/*.test.ts',
                '**/dist/**',
                '**/.*',
            ],

@JargeZ
Copy link

JargeZ commented Nov 23, 2020

@ritwizsinha Of course I have this file. The scaffolding was generated by the same version of rc-apps
If others do not have this problem, could you tell me how I can see which files the script considers modified?
Or is there an only option to just install the package locally and run it with a debugger?

@cuonghuunguyen
Copy link
Contributor

Totally agreed. @ritwizsinha introduced the new watch command as his GSoC project that doesn't run into this error, so maybe that command already checks for this case.

Maybe it's the case of extracting the logic into a function and reusing it? :)

Hi, I had a look at the code, it is really a useful feature <3. Some improvement I could suggest that is you may only need to do login + check permission + check app updatability once and then use the token + flag update every following time :D. That could improve the performance

@steve-todorov
Copy link

The watch command goes completely bananas. :)
I have added ignoredFiles: [] into the .rcappsconfig as suggested, but this doesn't do anything at all.
The command is in a forever loop.

@cuonghuunguyen
Copy link
Contributor

The watch command goes completely bananas. :)
I have added ignoredFiles: [] into the .rcappsconfig as suggested, but this doesn't do anything at all.
The command is in a forever loop.

That's a bug as I see. Add **/app.json to the ignoredFiles list. They implemented the logic to update the app.json file with implements but forgot to ignore it. But tbh u should create another issue

@steve-todorov
Copy link

Oh man! Thanks for sharing! That fixes the loop! I wonder why they didn't include this by default. :)

@cuonghuunguyen
Copy link
Contributor

They seem didn't expect it. App.json is changed, but the new value is equal to the old one. Idk why but chokidar will still emit a change event for that, thats why the app gets re-deployed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋‍♂️ help wanted We want YOU to help!
Projects
None yet
Development

No branches or pull requests

5 participants