How to prevent sgmf-scripts to scratch sensitive files? - cartridge

Right now I’m developing a SFCC Commerce Cloud website.
Referring to SFRA recommendations, I’m using the sgmf-scripts command to create, compile and upload custom cartridges.
The problem is, each time I create a cartridge, sgmf-scripts is scratching sensitive files such as dw.json, package.json or webpack.config.js, which is pretty annoying.
Does anyone know how to avoid this behavior?
Thank you

If you are open to using Visual Studio Code, you can use this together with the Prophet Debugger. The Prophet Debugger would enable you to upload your code with each change to the Sandbox and attach VS Code to Sandbox for debugging - this takes away the need to configure multiple dw.json as Prophet Debugger reads the main dw.json
Find out more about Prophet Debugger: https://marketplace.visualstudio.com/items?itemName=SqrTT.prophet

Related

Create screenshot of react app when running the build script

I have recently picked up web development again after a few years and am currently learning React as well as other node functionalities.
I currently am working to revise my portfolio and was curious if there might be an existing method or practice so that when running the build command a screenshot of the app would be taken and saved to the build folder.
In essence I would like to automate the creation of screenshots for projects I'm currently working on or have worked on that would then be placed into the portfolio.
I imagine the process would be similar to the following
Write your source,
Build the app from script,
Once build has finished initiate the serve script
Take screenshot and save to build folder.
I'm aware I can do this manually with little to no effort but wanted to check for an automated solution.
Any suggestions or helpful comments are greatly welcomed, thank you in advance.

How to debug a serverless framework plugin?

I've searched throughout google about this question and I had no success...
I want to work on a serverless plugin fix, but I don't know how to attach the process to debug the code.
Currently, I'm using vscode and the plugin was developed using nodejs + typescript.
Does anyone have any tip or article explaining how to do that?
As every other process, that you want to debug, you need to run it and somehow connect the debugger to it.
You need to remember, that Serverless Framework is written in JS/TS, so it runs in Node.js. So you can debug it quite easily, if you are developing your Lambdas in Node.js, as it's quite common environment.
How to do it using Jetbrains/Webstorm/IntelliJ
Go to your node_modules directory and find the source code of the plugin, that you want to debug.
In the source code place the breakpoint.
Now Create a new "Run configuration" in IDE for NPM, that should be similar to mine:
4. Make sure you've chosen the correct package.json!
5. Now simply start debugging, like you normally do, but choose the run configuration, that you've just created.
In my example I'm using package script from package.json, but it could be also any other script, that triggers serverless deploy or serverless print in the end.
And that's it! Breakpoints should be triggered normally, like when you debug your own JS code.

How do I make sure that my terminal opens the .firebaserc and firebase.json files in Visual Studio Code?

I'm trying to learn how to write and deploy firebase cloud functions in firestore, but unlike the tutorials I follow, once I'm done with the "firebase init" command and the setup that follows in the terminal, the files I have mentioned, and the most important one, ie index.js, do not open up/show up automagically in Visual Studio Code. Does this mean I have done something wrong? Because the file is created, just not picked up by VSC immediately like it happens in every tutorial I have followed so far.
I have a secondary question too; but I will move it to another thread if someone tells me to.
Can I alter the state of my app (say, or instance, change the app's colour theme remotely) using cloud functions in firebase when im using Firestore?
I apologise for the noob questions, I have reviewed the docs and can't find a straight answer to either of my questions.
Thank you.

How to compile Node.JS desktop app?

to gain more experience coding and support good projects, I recently got into open source projects and Github. After looking for a project I would like to work on, I found Soundnode (https://github.com/Soundnode/soundnode-app). The project uses NW.js, Node.js and Angular.js.
The question is very fundamental: How do I run the NW.js desktop app from the given files?
I was able to compile the app once, using the bash command open -n -a nwjs --args "/Users/example/path/app". But how do I compile the changes? After changing the index.html file, which is the start for the application, I have to terminate the NW.js app and start it up again (otherwise nothing will happen) and then it opens again the same, unchanged, original app (I changed some html text to see if would load the changed index.html).
Could anyone give me a quick guide how to work with this? What I want to change and everything else I will try to figure out on my own. Just need somebody to give me a head start :)
Best Regards, bbrinx - eager to learn.
nwjs application works next ways:
direct load web files from FS or web
archive files to zip package.nw
Check nwjs manual and docs: http://docs.nwjs.io/en/latest/ and https://github.com/nwjs/nw.js/wiki
Easiest way to compile your app is to use Web2Exe. It can compile for Win, Mac, Linux.
You can use browser tools for developing/debugging your application. Set toolbar option in true in window section in package.json file to see browser elements in your app.

Using NodeJS module in Titanium Studio

All, I am trying to using third party NodeJS SDK in Titanium Studio. However, I consistently encounter dependency issues, such as util.js, utils.js, ms.js, events.js etc. I tried to add the missing module manually, but it looks like it will become un-tractable as there are so many dependencies.
My questions are :
1. Is that possible to use NodeJS based SDK in Titanium Studio .
2. If so, what is the right approach to include the dependencies.
Thanks a lot!
Titanium can't get Coffee scripts to work natively (assuming you want to deploy the TitaniumWrapper.coffee). A possible solution you may want to try is hooking a plugin http://billdawson.com/titanium_coffee_script/ in order to pre-compile Coffee scripts.
You can also try to embed everything using a Tiwebview that wraps HTML to load mojio-js.js but you would still need to observe events mojio client (like replacing keys, login an user and create a few model instances).
Hope you find the info useful and can serve for further research.

Resources