Identify when single page app is running as a nw.js app - javascript

How can I identify if your single page web app is running with nw.js (previously known as nodewebkit) via javascript? I'd like to be able to share the code between the web client and the nw.js app, while being able to figure when to use different code based on the running implementation.
I'm not sure if determining this while the app is running, is the best approach, as I should probably have an entirely different build task for the tool, but this seems like the path of least resistance at the moment, as I'm unfamiliar with most of ember-cli's features (my current build tool) along with the following module.

This works for me
window.IS_NW = typeof window.process !== 'undefined'
However this will be a false positive if there is already a defined global named process.

Related

is it possible to migrate a plain react-app into next-app?

Is it possible to change/convert a plain react app into next app?
I have a project created with create react app but things have changed and now I want to switch the project into next app
maybe there's a possible way to do that? or should i start over from scratch to build my next app project?
I've been trying to research on how to migrate the project, but didn't found the solutions.
It's difficult to answer this question without seeing the actual project and dependencies you use, but here's a few considerations:
You'll need to convert your current routing solution to the one Next.js uses. Their routing is determined by the file system structure, rather than in code (like react-router). For more information, see their docs: https://nextjs.org/docs/routing/introduction
Ensure all your components and dependencies can render on the server, this may require moving behaviour that uses browser APIs into useEffect hooks (like window or document properties).
Move your hosting and building to something that supports Next.js configurations. There are a few including Vercel, Netlify & AWS.
Also check out their own migration guides that cover how to convert configurations to Next.js: https://nextjs.org/docs/migrating/incremental-adoption
In short, it really depends on what you're currently using and will require manual conversion your code. I hope this was still helpful.

Do I have to do anything to make my Electron app "Citrix compatible"?

I have a cross-platform Electron app in beta which I've developed for a client (I'm a contractor) and I just found out today that the app needs to work in a 3rd party's Citrix environment. I had no idea what that even was so I have been googling furiously for a few hours. That hasn't helped much so I thought I'd ask here. Sorry for the lame question.
The app is a tool for creating presentations. It accesses the local HD to copy digital assets into a current project folder. It also writes a JSON file to the project folder and some preferences to the "Application Support" folder. The app makes two network calls at startup: one to validate a user entered license key and the other to check for updates. The update is not automatic ("update in place"). The app also supports the copy/paste of text.
That's it. Is this something which will "just work" in a Citrix environment or do I need to do some sort of customization? None of the material I've found on Citrix describe this sort of basic compatibility (or if it did, I didn't understand it)
Citrix is a virtual machine, so if you just build your electron app and drop the executable in citrix it should do the job.
We used it in a company i used to work and we rarely(real special cases like really old softwares) had any issues in running any program that would run on windows in citrix.
https://en.wikipedia.org/wiki/Citrix_Virtual_Apps
here is what it actually looks like :
so you should be fine, no wories

Hiding React Src From User Until Logged In

So I noticed when I ran my react app's production build's login screen from create-react-app that all of the source code for the app was available within the static/js folder. Basically, the code doesn't look any different from the code in my ide, on the production build.
I am wondering if there is a way to hide this behind a login screen? So that a user can't directly access these files unless the login is successful. I have looked around and was unable to find anything of use.
The js files from the production build should be minimized which would look a lot different than in your IDE. I assume what looks "the same" is looking at the source using developer tools. The solution for that is to not deploy the source map files (*.js.map). Those are the files that allow developer tools to transform the minimized code back to its original look.
Removing source maps makes it difficult for someone to learn from the code easily, but if there is sufficient motivation to do so, it can still certainly be reverse-engineered. There are also some parts that wouldn't be obfuscated much at all such as the URLs for API calls which would then give someone a lot more information to use as the basis for hacking attempts.
If you need to prevent seeing any version of the source for people that are not logged in, I would recommend building your app as two apps -- one that just contains the login portion and one with the rest. Code-splitting within one app won't do the trick (at least not without using a solution that is quite a bit more complicated to manage than the two-app option), because it just makes the download process lazy and it is still pretty easy for someone to determine what the other files are and download them. However, even splitting this into two apps only helps if you host the second app differently. This will require server-side protection that only serves the JavaScript files for the second app for a user that is logged in. This means either using a different sub-domain for the second app or at least a different directory on the server that has those protections baked in. How you would implement that protection depends on the details of your authentication approach and the technology stack being used on the server. Most likely, it means using a cookie set by the login process and then having the JS files for the second app served up by something that verifies the cookie before allowing the JS files to be served to the browser.
To overcome displaying your source code in production's build, try to build your app with
GENERATE_SOURCEMAP=false npm run build

How to update a node.js app remotely & automatically

I need to set up automatic remote updates for my app built on nodeJS (not the nodeJS itself).
In my specific case I can't distribute my app as SaaS, so I have to share a copy of app with each client.
I've checked related topics here, but haven't found helpful ones.
Here are a few related questions: one, two
I don't know how to set it up, but I have a few ideas:
old-school way (?) :
use unix cron + shell (or php) script to make «check-request» to «update-server»,
stop nodeJS instance,
replace files with newest ones from tarball,
run nodeJS instance with my app : from shell(?)
It may work if I use my own server, but how can I do the same on, for example, Heroku ?
Overall, it seems weird a bit.
two nodeJS instances way (?) :
use unix cron + another nodeJS app which checks updates on update-server,
then stop one node instance from another && update files
start one nodeJS instance with my app from another : how???
— Is here something else?
— How do folks solve that problem?
— How to realize, for instance, functionality like «Update manager» in Wordpress for nodeJS based app?
What you're talking about is CI (continuous integration), there are many tools that can help you in the process but they essentially do the same thing.
Detect a change in the code
Pull changes
Build the project
Run tests if there are any
Deploy to the server
— How do folks solve that problem?
Folks use Jenkins, bamboo and many other auto deployment systems.
If you're using node with pm2 you can use kinematic that has that build in (one-click deployment feature)

Converting web2py based web-app into native app using Appcelerator, is it easy? possible?

Here is my problem:
Customer wants my current web application as a Desktop, possibly Executable but without browser for the Client part.
I looked into 3 of following :
Qooxdoo - Needs browser
Adobe Air - Needs plugin and Runtime
Appcelerator - Most interesting , builds into Native Client
Here are the main questions:
Client side:
What i have read on appcelerator is it builds things written in html and javascript
into native executable, so what i have already written (HTML + Jquery + Jquery UI + CSS) can be built into Native Windows / Linux / IOS executables without changes to current code ?
Server side:
No problem as it returms html and json and decided to keep running on server. But wondering how offline contents work.
I'm not sure this will actually work. From what I understand, titanium appcelerator provides a framework primarily for you to create applications on the iOS and Android platforms. I did see some things about the Desktop apps, but nothing about the application being automagically created from the source when your backend code is python (and web2py to boot).
I think it might be impossible to just drop your web2py app in and get a final product. For one, how will Appcelerator know that a given URL corresponds to a given controller and function? How will it perform searches on objects in your database? Do you expect it to read the DAL(...) connection string and just connect?
If you don't do ANY server-side processing, and don't use ANY datasources except for JSON, then maybe this would work. Maybe. But I highly doubt it will be automatic, or even all that easy.
It seems to me that you would have to hit every page and save the pages as html to a disc, and then drop the outputted HTML/CSS/JS markup into Titanium. But that means that if you ARE processing forms or searches, or doing anything interesting in the controllers, the titanium application will not have anything to process the server-side backend stuff.
That being said, titanium does work with php code, but not perfectly, And I see issues when using frameworks as opposed to raw php.
http://www.flickr.com/photos/funkatron/4011561849/
It didn't work that great, regardless. Titanium Desktop does still support PHP though, but developing an app with a server-side framework like CI is basically not going to work.
There was also something in the docs about processing python code, but all I saw was that you can place python in the "client" end of the HTML using a script tag as such:
<script type='text/python'>
# ... python code ?
</script>
(ref: http://developer.appcelerator.com/doc/desktop/python )
But that's not going to help with a web2py app.
IN SHORT -- I advise you download the app and create a hello world project. Then follow a tutorial on migrating or converting your application to Titanium. You'll probably have to rework a lot of things, and I'm not sure how you'd get the execution environment required for web2py, so you might have to rework some of the basic GLUON code which web2py is built on.
Sorry :(
You can, however, probably find a way to create a Java application that includes a copy of (a) rocket webserver, (b) python 2.5 or greater interpreter (c) web2py framework, (d) web2py application and package all this in such a way that it runs inside your java application (which will run on any platform) and shows an HTML view to the enduser. Then you could maintain it as a web2py app and just copy the app to your java bundle. I'm not sure if that's any easier in the end, but it looks like you'll either have to port to Titanium or Wrap with Java (or another language suitable platform-agnostic language).

Categories