Rocket.Chat.Apps-cli icon indicating copy to clipboard operation
Rocket.Chat.Apps-cli copied to clipboard

How to update app without losing association storage

Open ghost opened this issue 5 years ago • 10 comments

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

ghost avatar Nov 06 '20 10:11 ghost

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

JargeZ avatar Nov 22 '20 23:11 JargeZ

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 avatar Nov 23 '20 00:11 d-gubert

@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

JargeZ avatar Nov 23 '20 01:11 JargeZ

@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/**',
                '**/.*',
            ],

ritwizsinha avatar Nov 23 '20 08:11 ritwizsinha

@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?

JargeZ avatar Nov 23 '20 12:11 JargeZ

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

cuonghuunguyen avatar Nov 24 '20 07:11 cuonghuunguyen

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.

steve-todorov avatar Feb 08 '21 10:02 steve-todorov

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

cuonghuunguyen avatar Feb 08 '21 11:02 cuonghuunguyen

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

steve-todorov avatar Feb 08 '21 11:02 steve-todorov

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

cuonghuunguyen avatar Feb 08 '21 11:02 cuonghuunguyen