Copying files/folders to Electron Dist folder - node.js

Long story short:
I need to copy some files/directories over from my src folder to my dist/resources folder. Is there any way I can 'automatically' copy these files/folders over during packaging? I am using Electron-packager.
Long story:
I have a couple of folders containing JSON files that need to be read and copied over to a certain user directory. These are all done when I mount a certain component.
I use readFileSync() and using path.resolve with __dirname - but this generates an error since my relative path is different when I am running the packaged app (inside dist folder). Error is it cannot find my JSON file in dist/resources/config/settings.json. Also tried to check content of my app.asar but can't seem to find it there.
So my working workaround is to copy the directory/files over from my src folder to my dist/resources folder.
But this is kind of hacky and prone to forgetting. Is there any way I can 'automatically' copy these files/folders over during packaging?

I've seen a lot of questions like this and I've never really understood them. Maybe your project structure is very different than mine (below)?
Everything that is within my "app" directory is included by electron-packager (or electron-builder – I use both) and so it's all available when the app i packaged. In my case I have some Excel templates which the user can opt to save to disk but I could just as well create a directory and copy them there at first launch (haven't tried this but assuming permissions are ok I don't doubt that it will work). Maybe that is less "clean" than having a separate resources folder?
That said, I have seen this: Electron - How to add external files?

Related

How to create a build.xml for a project that has multiple directories?

I have a Java project with the current directory structure:
Classes
Jars
Properties
Config
Each of these folders have some files which when I run make creates a project.
Now I have added another folder named client, which has two sub-folders: sampleRequests and YANG, along with one or two more files.
I do not know how to change my build.xml so that it incorporates the client folder and the sub-directories too.
I already have the build.xml for the earlier code where ai am copying my files. So lets say if I am using $out_dir for my project folder, can I simply use $out_dir/client/sampleRequests for this. Or the format is totally different. Stuck in a limbo. Please help.

How to handle building files outside of directory

I have a build set up and I'm struggling on how to handle one aspect.
I have successfully setup a variantdir for my project folder src build output, however I have
source that resides outside the project folder that needs to be build and included.
I am able to add the files I need into the build, however the object files are put into the external directory where the library souce files are.
Is there a standard way to solve this. I would like to avoid adding any scons files to the external directory as it is a standard intall of a tool.
What I attempted was to Mkdir() a temporary folder, Copy() the files, and build the files. This seems to work, but only the first time as the file permissions are set to readonly. Also, the only way to get it to work seemed to be to use the Execute() command which caused the action to happen at every build.
Have a look at the Repository() method (see http://scons.org/doc/production/HTML/scons-user.html#chap-repositories in the SCons UserGuide). It lets you sort of "mount" a folder to the top-level of your source tree. Then you can refer to them locally, and specifying "duplicate=1" for your variant dir should keep your remote folder clean from built files.
Hope this helps...
I was able to get the functionality I was looking for by building the objects in the external directory and then using the Move() Factory to move the object files.
If Anyone can point out a more 'scons'sy way of doing it please let me know.

Publish Web App files to different locations

I'm start to develop modules for DotNetNuke. I followed different tutorials(most by Chris Hammond) but there is something i don't like, and I'm searching a different way to do so.
He recommends to put a DotNetNuke installation, with IIS and SQL Server, on the developer PC and put your Project into the DesktopModules folder. I don't like it because i want to separate my project from DotNetNuke.
Is there a way to split the build/publish to different location like dll into folder x and all other stuff into folder y?
You could, but I don't really see the point. I see where you're coming from because it seemed awkward to me at first as well, but it really is the most efficient way to develop on the DNN platform. I have mine set up so all of my modules are in the same solution and branched in source from the root DNN folder. We don't keep the DNN core in source so the developer is responsible for that, although that may change at some point to keep versioning consistent.
By keeping your project located where it's installed, you can develop your modules the same way you'd develop any other web app you're building. If you make a change in markup you just have to save the file and refresh your page. If you change something in code just build and refresh.
If you really must keep them separate, you can absolutely do so (really the only benefit of this that I can see is that if you uninstall a module and accidentally click the checkbox to delete files - it happens - you don't have to worry about it). Create your project where you want it, change the Output Path to your DNN bin folder, and create post-build events to copy all of your .js, .ascx, and .css files (plus any others you may need - images, HTML files, XML files, etc.) to appropriate folder(s) in the DesktopModules folder. Just remember that you have to build the project every time you make ANY changes to test them, and you have to write/change your post-build events every time you add a new type of resource, change/add a directory, etc.
Either that or you can build an install package and uninstall/reinstall the module every time you change some padding in your stylesheet ... but I'd stick with keeping the project in the DesktopModules folder.
Sure you can do that.
Set up your solution and module projects anywhere, build the projects and copy the appropriate parts (such as the *.ascx , *.ascx.resx, *.dnn files) back to your website folder -
website/ DesktopModules/Your_module_name
Copy the module dll to the website's bin and you good to go.

MonoDevelop's Images directory does not seen on XCode(IB)

In my project files marshalling shown below ,Mono Develop doesn't show Images directory(group) in XCode and they are not seen on xib interfaces,also crashes on runtime. But when I put images under Project's root directory works fine!
Fine! But seeing dozens of images on root directory make things confusing.
Here goes details;
My images built actions are content.
I have tried adding them to Xcode by creating a group named Images then this time all images copied to Mono Develop's root again.
Am I missing something?
Project
--Images
---- FaceOff.Png
---- icons
---------CandyButton32x.png
I think you are experiencing a limitation of the XCode integration with MonoDevelop.
Images only show up in XCode if they are in the root directory of your project. To combat this, there are two ways you can setup your image folders for MonoTouch projects:
Use build action Content, put your images anywhere, but they will only show up in XCode if they are in the root of the project
Use the build action BundleResource and put all your images in the Resources folder, this is the same as putting your images in the root of the project, but you get to package them nicely in a subfolder
I have not experimented with BundleResource and XCode to see if subfolders work via that method or not.
This is from my experience, someone from Xamarin, feel free to chime in.
Further to Jonathan's great answer, I have a nice organised setup for my images using BundleResource and the Resources Folder.
On the filesystem I have all my images in a nice directory structure, for example: img/common/title.png.
I then add all the image files (not directories) into the iOS project Resources folder, using the 'Add Files' option and selecting BundleResource for the files I select.
When given the copy, move or link option, because my files are outside the target directory, I select the 'Add a link to the file' option.
This procedure allows me to:
Happily keep all my images in an organised directory structure on the file system
Have access to them in XCode Interface Builder
Access them as root when in code, such as Image.FromFile("title.png")
Easily update them in the filesystem and have them automatically change in Xamarin Studio

Linux Folder/Package Management

I'm looking for a way to store all my applications files within a single folder. However, when someone clicks on the folder I want the application inside the folder to open up as opposed to open the folder itself. I want to keep all dependancies and files inside this folder at all times.
I'm doing this because I'm going to be deploying a couple applications on a common framework and want to ensure that they are together and independent of the distribution have all requirements.
Folders are directories, and directories are distinct from files. There's no way to redirect a directory to an executable file. However, you can make a hidden directory (begin name with ".") and use an executable file to provide access to that directory. The directory will then not appear in window manager folders, just the application. However, window managers will not misrepresent the executable file as a directory.

Resources