<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hasni Arif on Medium]]></title>
        <description><![CDATA[Stories by Hasni Arif on Medium]]></description>
        <link>https://medium.com/@hasniarif?source=rss-5fa79860d3b0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TPQTrBaBGKga5MDfNrqprA@2x.jpeg</url>
            <title>Stories by Hasni Arif on Medium</title>
            <link>https://medium.com/@hasniarif?source=rss-5fa79860d3b0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 21:44:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hasniarif/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Handle Runtime Environment Variables with React]]></title>
            <link>https://medium.com/@hasniarif/how-to-handle-runtime-environment-variables-with-react-ec809cb07831?source=rss-5fa79860d3b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec809cb07831</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[environment-variables]]></category>
            <dc:creator><![CDATA[Hasni Arif]]></dc:creator>
            <pubDate>Wed, 23 Jun 2021 16:55:02 GMT</pubDate>
            <atom:updated>2021-06-23T16:55:02.028Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn how to easily configure a React application so that it uses environment-agnostic configuration and thus can be built once and deployed anywhere.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hzG1ugPWSqtuXhFuXT2vgg.png" /></figure><p>Front-end applications may need to consume environment variables (like APIs URLs). As these variables could change between environments, you’ll need to configure your app to call the right ones in each of these environments.</p><p>There are two main approaches that you can consider to configure a client-side rendered app that uses environment-specific settings.</p><h4>The environment-specific build</h4><p>The first approach we would tend to think about would be to have an <strong>environment-specific build</strong>. By that, I mean using the CI server to generate and deploy custom builds for each environment.</p><p>It’s totally fine and it will actually do the job. The main problem of this approach is that if we compile all of these values into the bundle, a rebuild would be required for every promotion (ex: pre-production to production). This is definitely not ideal and it would be much better if we could have an <strong>environment-agnostic build</strong>.</p><h4>Build once, deploy anywhere</h4><p>As you may guess, the second approach is about having an <strong>environment-agnostic configuration.</strong> In this case, we are referencing the relevant configuration data at runtime so that, unlike the first approach above, the same code can be deployed to all environments. Therefore, the build stage is only about creating a bundle that could run anywhere, which is more compliant with the <a href="https://12factor.net/build-release-run"><em>Twelve-Factor App</em></a> as well.</p><p>So as it is preferable to deploy the same code to all environments, the runtime configuration approach is the one that we’ll consider here.</p><h4>The React-related problem</h4><p>Now the difficulty stems from the fact that your React app is probably built with Webpack and there is a difference between the way Webpack handles environment variable updates, compared to the way Node.js does it.</p><p>But Webpack is a Node.js tool, isn’t it? Yes, it is, and during the build phase, it has full access to the Node.js runtime which means it is able to use the FileSystem API and environment variables to properly inline those values in the code… <strong>but at</strong> <strong>runtime only</strong>. That’s why your app can actually read environment variables values on development mode using the process.env variable.</p><p>The problem is that on production mode, the Webpack output is just a static HTML/CSS/Javascript bundle. It means that our application, being static, can’t detect new environment variables. If they change between environments, and if they need to be embedded in the static bundle, then the app needs to be re-built for that specific environment (and this is precisely what we want to avoid, right?)</p><p>So how can we customize the configuration of React.js apps at runtime without having to be aware of the environment?</p><h4>The implementation</h4><p>One of the most straightforward solution that I ended up with to keep the entire application build intact was to use a configuration file (env.js) that the app will import in a &lt;script&gt; tag inside the head section of the index.html file.</p><p>This script will be responsible for injecting global variables into the app with every variable value being just a placeholder for now. If you’re using a create-react-app (CRA) folder structure, make sure to place this script in the public folder.</p><pre>// public/env.js<br>window.env = {<br>  KIBANA_URL: &#39;__KIBANA_URL__&#39;,<br>};</pre><p>Import this script in your index.html file.</p><pre>&lt;! –– Example using CRA --&gt;<br>&lt;script src=&quot;%PUBLIC_URL%/env.js&quot;&gt;&lt;/script&gt;</pre><p>Then, <strong>before serving the app, </strong>by running a simple shell script that uses the <a href="https://linux.die.net/man/1/sed">sed</a> command, the placeholders will be replaced by the actual values of each environment variable.</p><pre>#!/bin/bash</pre><pre>sed -i &#39;s#<strong>KIBANA_URL</strong>#&#39;&quot;$KIBANA_URL&quot;&#39;#g&#39; env.js</pre><pre>exec &quot;$@&quot;</pre><p>Finally, to read the values of the variables in your app, you can do something like this:</p><pre>const KIBANA_URL = process.env.NODE_ENV === &#39;production&#39; ? window.env.KIBANA_URL : process.env.REACT_APP_KIBANA_URL;</pre><h3>Docker</h3><p>If you are using a Docker container, just make sure that it has access to all your environment variables and that it runs the script above before serving the application.</p><pre>...</pre><pre>ENTRYPOINT [&quot;./entrypoint.sh&quot;]</pre><pre>CMD [&quot;serve&quot;, &quot;-s&quot;, &quot;.&quot;, &quot;-p&quot;, &quot;3000&quot;]</pre><p>And that&#39;s how you finally get a &quot;dynamic&quot; bundle and the &quot;build once, deploy anywhere&quot; approach that we want.</p><h4>⚠️ Do NOT inject secret keys into your bundle</h4><p>One more thing that is important to consider when dealing with environment variables in React (or any other frontend library) is that you must <strong>never</strong> inject secret keys into your bundle. Remember that all these values are still visible by inspecting your app&#39;s files. Nothing is hidden by your frontend application.</p><p>Thanks for reading me and stay tuned, more articles are coming soon ✌️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec809cb07831" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Use GitLab as a Project Management Tool]]></title>
            <link>https://medium.com/@hasniarif/how-to-use-gitlab-as-a-project-management-tool-1496e22bb033?source=rss-5fa79860d3b0------2</link>
            <guid isPermaLink="false">https://medium.com/p/1496e22bb033</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[project-management]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Hasni Arif]]></dc:creator>
            <pubDate>Mon, 25 May 2020 12:42:41 GMT</pubDate>
            <atom:updated>2020-05-25T12:42:41.609Z</atom:updated>
            <content:encoded><![CDATA[<h4>A workflow to improve your productivity and properly manage projects without having to use complex solutions for agile project management.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-0ZiwMLu-YcWBADq" /><figcaption>Photo by <a href="https://unsplash.com/@pankajpatel?utm_source=medium&amp;utm_medium=referral">Pankaj Patel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>Disclaimer</strong>: This article is primarily intended for those who are not already familiar with GitLab Milestones or conventional commits and who want to effectively manage their project without having to use other complex solutions.</p><h3>Why GitLab?</h3><p>GitLab is not only about hosting your code. It also enables agile project management whether from very simple issue tracking to Kanban and Scrum styles of agile delivery. On GitLab you can manage issues, visualize the status of work across your sprints and track the effort and resolution priority as effectively as with dedicated project management applications.</p><p>Another reason for using GitLab is that it’s more suitable for developers than the other applications that are too complex to be used effectively. So what if you could take advantage of GitLab functionalities to actually use it as a better approach to manage your projects?</p><p>Let’s see how I manage to do it within my project teams.</p><h3>GitLab Milestones</h3><p>According to the GitLab documentation:</p><blockquote>Milestones in GitLab are a way to track issues and merge requests created to achieve a broader goal in a certain period of time. Milestones allow you to organize issues and merge requests into a cohesive group, with an optional start date and an optional due date.</blockquote><p>So basically, milestones are just time-boxed boards used to manage sprints, visualizing the work as it flows through the project, with a strong focus on delivery and velocity.</p><p>In my projects, I like to create 3 kinds of milestones: the <strong>sprint</strong>, <strong>quarter,</strong> and <strong>shape-up</strong> milestones.</p><h4>Sprint milestone</h4><p>The sprint milestone is the one that we are currently working on. It contains all the issues of the current sprint and it is named using the version of the software that we are developing. If the sprint is about developing the version 1.2.0 of the project, the milestone will just be named <strong>1.2.0</strong>. By the way, this is also how the GitLab team usually names <a href="https://gitlab.com/groups/gitlab-org/-/milestones">their milestones</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GYQKGXH4CEfmLcNV.png" /><figcaption>GitLab milestone board</figcaption></figure><h4>Quarter backlog milestone</h4><p>For each quarter, my team and I will potentially deliver multiple versions of our software. And each version milestone is actually filled by pulling issues from the corresponding quarter milestone and assigning them to that specific sprint milestone. This allows for a fairly small backlog since it only contains the issues that could potentially be assigned and achieved during the current quarter.</p><h4>Shape-Up milestone</h4><p>We also like to create a milestone called “<strong>Shape up</strong>”. In this milestone, we integrate all the issues that are not well defined, still vague ideas, and for which the whole team still has to think about. We actually have a weekly meeting during which we think about whether a particular issue should finally integrate a sprint or not. To fully understand this “shape up” process I strongly recommend that you take a look at this very interesting <a href="https://basecamp.com/shapeup">e-book</a> from Basecamp.</p><h3>Issues</h3><p>Now let’s talk about issues.</p><blockquote>Issues are the fundamental medium for collaborating on ideas and planning work in GitLab. Issues can allow you, your team, and your collaborators to share and discuss proposals before, and during, their implementation.</blockquote><p>It’s important to add some labels to the issues to quickly identify which component of your application is involved, and what type of issue it is (a bug, a feature request, etc.). The GitLab issue boards have great filtering capabilities, so the more your issues are well labeled, the easier it will be to prioritize and align your team to the business needs. You’ll find below some of the labels that I like to use.</p><p>Also, as soon as someone is assigned to an issue, the issue automatically switches to the “Ongoing” column of the milestone, making it easy to know where the work is from a team perspective.</p><h4>Labels examples</h4><p>You’ll find below some labels that I like to use to create views and representations of the backlog that help to plan and prioritize the work.</p><h4>Type labels</h4><ul><li>Type: Bug</li><li>Type: Feature</li><li>Type: Feature Request</li><li>Type: Refactor</li><li>Type: Documentation</li><li>Type: Chore</li><li>Type: Discussion</li><li>Type: Research</li><li>Type: UX/UI</li></ul><h4>Component labels</h4><ul><li>Component: Front</li><li>Component: API</li><li>Component: Engine etc.</li></ul><h4>Scope labels</h4><ul><li>Scope: Admin page</li><li>Scope: Search</li><li>Scope: User profile etc.</li></ul><h4>Status labels</h4><ul><li>Status: On Hold</li><li>Status: Shape-up etc.</li></ul><h4>Topic labels</h4><ul><li>Topic: Data collection</li><li>Topic: Monitoring</li><li>Topic: Data quality</li><li>Topic: Security etc.</li></ul><h3>Merge requests</h3><p>The main benefit of using GitLab is that it maintains strong traceability to execution by linking your issues to the actual state of the development through the merge requests where developers implement and deliver the code changes.</p><p>I also strongly recommend using conventions for the titles of your merge requests. Especially if you use the <a href="https://guides.github.com/introduction/flow/">GitHub Flow</a> and <a href="https://docs.gitlab.com/ee/user/project/merge_requests/squash_and_merge.html">squash your commits</a>, the title of your merge request will then corresponds to the commit title on the master branch. I use the very common git commits conventions described below.</p><h4>Commits conventions</h4><p>The <a href="http://karma-runner.github.io/4.0/dev/git-commit-msg.html">convention</a> that I use suggests to apply this commit message format:</p><p>&lt;type&gt;(&lt;scope&gt;): &lt;subject&gt;</p><p>Where <strong>type</strong> can be:</p><ul><li><strong>feat</strong> (new feature for the user)</li><li><strong>fix</strong> (bug fix for the user)</li><li><strong>docs</strong> (changes to the documentation)</li><li><strong>style</strong> (formatting, missing semicolons, etc.)</li><li><strong>refactor</strong> (refactoring production code, eg. renaming a variable)</li><li><strong>test</strong> (adding missing tests, refactoring tests)</li><li><strong>chore</strong> (updating webpack config etc)</li></ul><p><strong>scope</strong> could be:</p><ul><li><strong>api</strong></li><li><strong>front</strong></li><li><strong>internal</strong> etc.</li></ul><p>And the <strong>subject</strong> must uses the imperative, present tense.</p><p>feat(api): add users profile endpoint</p><p>Example of a valid merge request title</p><h4>Merge request description</h4><p>The description of the merge request is also very important. This is actually where all the project management magic happens.</p><p>Indeed, as said above, you can link your merge request to the issue you’re currently assigned to. If the merge request is related to the issue but the issue will not yet be resolved after the merge request being merged, add</p><p>Related to # &lt;ID_of_the_issue&gt; or Mentions # &lt;ID_of_the_issue&gt;</p><p>to your MR description. This will make it easy to find the merge request from the issue context and vice versa. On the other hand, if the changes applied by the merge request solve the issue, add Closes # &lt;ID_of_the_issue&gt; within the MR description. This way, once the MR is merged into the master branch, the issue will be closed automatically and switched to the &quot;Completed issues&quot; column of the milestone.</p><p>Using these helpers, you’ll no longer need to manually update the issues board, GitLab does it automatically for you. And that’s exactly what most developers want, not having to manually update the board.</p><p>You can also mention or close a cross-project issue by mentioning the full link to that issue.</p><pre>Awesome commit message</pre><pre>Fix #20, Fixes #21 and Closes group/otherproject#22.<br>This commit is also related to #17 and fixes #18, #19<br>and <a href="https://gitlab.example.com/group/otherproject/issues/23.">https://gitlab.example.com/group/otherproject/issues/23.</a></pre><p>And that&#39;s it! As you can see there is way less process than using an agile project management application and it&#39;s also easier for developers (as well as project managers) to manage the project.</p><h3>Slack integration</h3><p>One more thing that I love about GitLab is that you can easily add a <a href="https://docs.gitlab.com/ee/user/project/integrations/slack.html">Slack notifications service</a> to your project. Using webhooks, you and your team can be notified on Slack whenever a new issue or merge request is opened or closed which is very handy and will make you way more reactive and effective.</p><p>There are a lot of other great features that GitLab supports such as the <strong>Group Issue Board</strong>, the <strong>Description Templates</strong>, <strong>Time Tracking, </strong>etc. making it a major competitor against project management applications. Feel free to check out this <a href="https://about.gitlab.com/devops-tools/jira-vs-gitlab.html">Jira vs. GitLab</a> comparison if you want more information about it.</p><p>Thank you for reading me and stay tuned, more articles are coming soon ✌️</p><p>Follow me on twitter <a href="https://twitter.com/hasniarif">@hasniarif</a>, I post things about productivity, growth mindset, Tech, React.js, GraphQL, and more!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1496e22bb033" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>