- Install Node.js
- Install the grunt command line interface by opening a terminal and running
npm install -g grunt-cli
- Install the vc-framework-v13 component to your database
- Follow the vc-framework-v13 usage instructions to get an export of host database's methods
- IMPORTANT This strategy will kick off an infinite loop if you ultimately run the watch process on the same directory that vc-framework-v13 writes to. There are two options - either copy the
vc_source
contents somewhere else and watch that directory or disable the vc-framework-v13 component. For now we'll assume you have disabled the component after the initial export.
- Copy the contents of
On_Web_Connection_HOOK.4Dmethod
above into a new method in your host database with the nameOn_Web_Connection_HOOK
. If use a different name you'll want to update the grunt taskvalidate_install
.- Call the
On_Web_Connection_HOOK
method from the database methodOn Web Connection
and pass it$1
, and$2
. I.e.:
- Call the
// Inside On Web Connection
C_TEXT($1,$2)
On_Web_Connection_HOOK($1;$2)
- Create a new directory called
4d-sync
next to the location where the vc-framework-v13 component dumped your method definitions - Copy the
package.json
andgruntfile.js
files below into your new4d-sync
directory - Make sure 4D and 4D HTTP Server are running
- If your HTTP server is binding to an IP/hostname other than 'localhost' change the variable
HOSTNAME_4D
at the top of4d-sync/gruntfile.js
accordingly - If your HTTP Server is listening on a port other than 80 change the variable
PORT_4D
at the top of4d-sync/gruntfile.js
accordingly
- If your HTTP server is binding to an IP/hostname other than 'localhost' change the variable
- Open a terminal and
cd
into4d-sync
then run the command:npm install && npm test
Make sure 4D and 4D HTTP Server are running. Then open a terminal window and cd
into the 4d-sync
directory. Run the command npm 4d_sync
. If no errors are displayed go forth and edit the files in vc_source
, your changes will be synced back to 4D while the terminal window remains open.
The most common issue you may encounter is when trying to watch too many files, particularly on OSX the limit on opened files is low. See here for info on how to mitigate this.
Right now there is no built in fault tolerance or "offline" support. If 4D goes down or stops accepting HTTP requests your changes will not be synced.
There are no security checks - anyone who can see the IP:PORT you listen on can make changes to your methods.
This uses a naive approach for creating method paths from file names. If your 4D method has a complex path you may not be able to sync changes to it.
This is only meant as a proof of concept. It will alter your application and could possibly cause harm, there isn't much code here I'd suggest reading through to get a sense for what's happening before running it. please limit your use to a demo databases and always backup your work.