Updating "included" js files

I’ve added several JS files to my project by first copying them to the project folder and then dropping them on the Project Explorer from the project folder. This works very nicely.

Several of the JS files are created by an external program I wrote to build JS objects from a spreadsheet definition. Most of my work will be in this spreadsheet, as they define the actual program processes.

I’ve noticed that if I just copy the new JS file into the project folder with AppStudio open and build, that the new file is not included. I have to close AS, copy the file, and then reopen AS for it to be recognized. Is there a shortcut to this process?

It’s one of those damned if we do, damned if we don’t questions.

When AppStudio opens a project, it reads in all the files. When you hit Save, they are all saved again, with any changes you may have made.

If a file is changed externally to AppStudio, it has no way of knowing. It continues to use what it originally loaded. If it did load updated external files, changes to those files made by AppStudio would be lost.

Could you keep the last modified date of the file when it is opened in AS, and if that date has changed do one of the following: (1) if the user hasn’t changed the file within AS simply replace it with the newly externally modified one, or (2) if the user has changed the file in AS, give them a prompt as to which one they want to use, the AS version or the updated on-disk version?

We talked about that in a meeting here, but never went further with it. As I recall, more and more edge cases started coming up. We don’t ever want to lose any code in AppStudio.

I wonder how my editor does it… If I have a file open in my editor and change that file outside of my editor then my editor gives me a popup and asks me if I want to reload.

Maybe there is a different way. In my case, I only want to update a “static” file. This file will never be edited in AS. That’s probably not anyone else’s case, so I get the “what’s best” question.

I did try redropping the file into the project explorer. It states it’s already there. Why not at this point, give the option to replace the file.

@GaryGorsline - good suggestion!

If you’re going to add this enhancement, may I suggest that the location of the included file in the project explorer should stay the same. EG, don’t re-add the file at the bottom, like a new file.

Also note: If you have added a file like definitions.js and then add another file Definitions.js, AppStudio allows the addition of the 2nd file, but, of course on Windows, overwrites the original file. If AppStudio ever decides to add the replace function above, make sure you check the case of the files names to ensure no overwriting is allowed.

Is this still on the radar?

Yes. We’ve been very busy lately. The forecast is no abatement.

I just realized and tried the following which is easier than the process I was doing. Delete the original file in project explorer and drop the updated file from an outside folder onto the project explorer. Don’t know why I didn’t see this obvious solution.

One small problem with this method, if the name of the file has any capital letters, the file is added to project explorer with the scr all lowercase, while the file name on the disk has the capital letters. You have to additionally change the scr property of the file added. This is because the deploy to local folder (etc.) creates the package with the scr property while the package has the capitalized file. If no csp, you get a 404, with a csp, you get 403.

This is another easy fix if you do work on this.

Filenames with capital letters are a poor idea for apps being deployed online. You’re probably better off going all lower case.