<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: MwauraMuchiri</title>
    <description>The latest articles on DEV Community by MwauraMuchiri (@mwauramuchiri).</description>
    <link>https://dev.to/mwauramuchiri</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F98283%2F2eced547-f408-48f9-b145-6dbcb527a137.jpeg</url>
      <title>DEV Community: MwauraMuchiri</title>
      <link>https://dev.to/mwauramuchiri</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mwauramuchiri"/>
    <language>en</language>
    <item>
      <title>Starting your desktop PWA and it's server in one click</title>
      <dc:creator>MwauraMuchiri</dc:creator>
      <pubDate>Wed, 11 Sep 2019 17:54:56 +0000</pubDate>
      <link>https://dev.to/mwauramuchiri/starting-your-desktop-pwa-and-it-s-server-in-one-click-5ekd</link>
      <guid>https://dev.to/mwauramuchiri/starting-your-desktop-pwa-and-it-s-server-in-one-click-5ekd</guid>
      <description>&lt;p&gt;You have an app you just created to help you out with some tasks. It could be a to-do list, reminder app, calendar app, emailer... My usecase is an emailer app that creates an email template using &lt;a href="https://beefree.io" rel="noopener noreferrer"&gt;BeeFree.io&lt;/a&gt; and &lt;a href="https://nodemailer.com/" rel="noopener noreferrer"&gt;Nodemailer&lt;/a&gt; to send the emails through SMTP.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;This post is for locally served desktop pwa only&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;First thing is to install your PWA as a desktop app.&lt;/strong&gt; Now opening the app when your server is not running brings 404 error because the url, say &lt;strong&gt;&lt;a href="http://localhost:8000" rel="noopener noreferrer"&gt;http://localhost:8000&lt;/a&gt;&lt;/strong&gt; does not exist. So you have to start the server before opening the PWA. Doing it separately beats the logic of it being a PWA. We want to achieve the experience of a real app. Features of an installed app is usually;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;App icon appears in the windows start menu&lt;/li&gt;
&lt;li&gt;Everything just starts in one click.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To achieve these, you need to create a bash script in your app folder. This will help in starting the node/wamp server. Inside the script file, locate your server and start it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For Node js servers;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd "*app server folder*"
node server.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;For Wamp servers;&lt;/strong&gt;&lt;br&gt;
Check out the StackOverflow's answer on starting wamp server on cmd&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;div class="ltag__stackexchange--header"&gt;
          &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
          &lt;a href="https://stackoverflow.com/questions/7665706/how-to-programmatically-restart-wamp-or-apache" rel="noopener noreferrer"&gt;
            how to programmatically restart WAMP or Apache?
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Oct  5 '11&lt;/span&gt;
            &lt;span&gt;Comments: 4&lt;/span&gt;
            &lt;span&gt;Answers: 4&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/7665706/how-to-programmatically-restart-wamp-or-apache" rel="noopener noreferrer"&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          9
        &lt;/div&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;As part of some automated deploy + test scripts I use to verify programming done for a site, I have some scripts which update Apache's config files.  I would like to programmatically restart WAMP so the changes take effect.  Is there a good way to do this?&lt;/p&gt;
&lt;p&gt;The scripts are…&lt;/p&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    &lt;a href="https://stackoverflow.com/questions/7665706/how-to-programmatically-restart-wamp-or-apache" class="ltag__stackexchange--btn" rel="noopener noreferrer"&gt;Open Full Question&lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;



&lt;p&gt;Now save the script then create its shortcut file. You should change the shortcut file's icon to the app's favicon icon and rename it as the app's name (remove the "- shortcut" name). Put the shortcut file inside Window's Start Menu folder, usually at &lt;em&gt;C:\Users~~user_name~~\AppData\Roaming\Microsoft\Windows\Start Menu&lt;/em&gt;. Note that the real pwa app will be located in the start menu folder, inside Programs/Chrome apps folder (assuming you installed the PWA using Chrome browser).&lt;br&gt;
You should now see the app icon appearing in the windows start menu. On clicking it, it will start the server nice and easy.&lt;/p&gt;

&lt;p&gt;After the server starts. Now we need to open the PWA. This is basically simulating clicking the PWA. I used the node &lt;em&gt;server.js file&lt;/em&gt; to open it by using &lt;a href="https://github.com/pwnall/node-open/" rel="noopener noreferrer"&gt;node-open module&lt;/a&gt;. It is quite easy to code it yourself in node js, just that it is easier for you if it is already coded! &lt;del&gt;Be as lazy as possible. You are a developer&lt;/del&gt;&lt;/p&gt;

&lt;p&gt;In the server file after the server is up, just require the module and open the PWA.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;open&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;open&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;C:/Users/~~user_name~~/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Chrome Apps/Emailer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the url points to the PWA and note the url? Using the apps url opens the app in the browser instead of the intalled PWA. This hack is temporary as Chrome is already thinking of &lt;strong&gt;link capturing&lt;/strong&gt;, a fancy name for opening the PWA whenever a url associated with the app is opened in the browser.&lt;/p&gt;

&lt;p&gt;For wamp server, I have not yet tried opening the PWA but I'm pretty sure there's a way using the bash script.&lt;/p&gt;

&lt;p&gt;Desktop PWA anouncement: &lt;em&gt;&lt;a href="https://appuals.com/microsoft-and-google-collaborate-for-pwa-platform-on-windows-10/" rel="noopener noreferrer"&gt;https://appuals.com/microsoft-and-google-collaborate-for-pwa-platform-on-windows-10/&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>pwa</category>
      <category>node</category>
      <category>wamp</category>
      <category>bashscript</category>
    </item>
  </channel>
</rss>
