<?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: Maciej Sulecki</title>
    <description>The latest articles on DEV Community by Maciej Sulecki (@beeinger).</description>
    <link>https://dev.to/beeinger</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%2F646750%2F8b7a6adc-5768-4956-9b8a-ba5bba15dd83.png</url>
      <title>DEV Community: Maciej Sulecki</title>
      <link>https://dev.to/beeinger</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/beeinger"/>
    <language>en</language>
    <item>
      <title>Submodules with Vercel and Next.js</title>
      <dc:creator>Maciej Sulecki</dc:creator>
      <pubDate>Fri, 19 Nov 2021 10:44:23 +0000</pubDate>
      <link>https://dev.to/beeinger/submodules-with-vercel-and-nextjs-4gml</link>
      <guid>https://dev.to/beeinger/submodules-with-vercel-and-nextjs-4gml</guid>
      <description>&lt;p&gt;Vercel is the team behind Next.js and they have their platform called &lt;a href="https://vercel.com/home" rel="noopener noreferrer"&gt;Vercel&lt;/a&gt;, I frequently use it to deploy my Next.js projects and it works great, the concern I had was when I tried to deploy my repo with a submodule there.&lt;/p&gt;

&lt;p&gt;See, Vercel does support submodules &lt;strong&gt;however&lt;/strong&gt; only when these are &lt;strong&gt;public&lt;/strong&gt;, which in my case was not an option. I would have to change my whole CI/CD pipeline, stop using the submodule or figure something out. &lt;/p&gt;

&lt;p&gt;I started figuring something out.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxm43vz6btna1k8cf7043.png" class="article-body-image-wrapper"&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-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxm43vz6btna1k8cf7043.png" alt="https://github.com/vercel/vercel/discussions/4566#discussioncomment-125253"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/vercel/vercel/discussions/4566#discussioncomment-125253" rel="noopener noreferrer"&gt;https://github.com/vercel/vercel/discussions/4566#discussioncomment-125253&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First there I've found a confirmation that my problem is real, there really is &lt;strong&gt;no support for private submodules on Vercel&lt;/strong&gt;  -  and judging by the rate of Vercel bringing new updates to Next.js (very frequent) and the fact that this issue still hasn't been resolved I think that the private submodules &lt;strong&gt;still have a long way to come&lt;/strong&gt; and are not quite high on the TODO list.&lt;/p&gt;

&lt;p&gt;After thinking about it and checking out the Vercel docs to find out what are my limitations, I've finally started getting somewhere.&lt;/p&gt;

&lt;p&gt;The solution I came up with is a simple script that you run instead of the default installation command on Vercel (instead of yarn or npm install). I've been using this script for half a year now and I have changed it and made it better countless times, now its fully working version &lt;strong&gt;works just like the real native private submodule would&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to use it?
&lt;/h2&gt;

&lt;p&gt;It's rather simple.&lt;/p&gt;
&lt;h2&gt;
  
  
  📋 Step by step 🚀
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;copy the ./vercel-submodule-workaround.sh to the root of your project&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;make sure the file is executable - run this command:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;u+x vercel-submodule-workaround.sh
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;in your package.json add a script:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"vercel-install"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./vercel-submodule-workaround.sh &amp;amp;&amp;amp; yarn --ignore-scripts --production=false"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Info:&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;--production=false&lt;/strong&gt; ensures that dev-dependencies will be installed, if you dont need your dev-dependencies to install then just delete this flag.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;--ignore-scripts&lt;/strong&gt; ignores pre and post install scripts if you want the scripts to run delete this flag.&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Tell Vercel to use vercel-install instead of the defalt install command&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;project -&amp;gt; Settings -&amp;gt; General =&amp;gt; Build &amp;amp; Development Settings&lt;/li&gt;
&lt;li&gt;in INSTALL COMMAND type
&lt;/li&gt;
&lt;/ul&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn vercel-install 
&lt;span class="c"&gt;# or &lt;/span&gt;
npm vercel-install
&lt;/code&gt;&lt;/pre&gt;



&lt;ul&gt;
&lt;li&gt;toggle OVERRIDE on&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Create a Github access token&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Settings -&amp;gt; Developer settings -&amp;gt; Personal access tokens&lt;/li&gt;
&lt;li&gt;Generate new token&lt;/li&gt;
&lt;li&gt;set a note (eg. vercel)&lt;/li&gt;
&lt;li&gt;set expiration to whatever you see fit (eg. No expiration)&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;select repo&lt;/p&gt;

&lt;p&gt;[x] repo - Full control of private repositories&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;copy the generated token&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Add the token to Vercel Environment Variables&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Project -&amp;gt; Settings -&amp;gt; Environment Variables&lt;/li&gt;
&lt;li&gt;add a new variable called GITHUB_ACCESS_TOKEN and with value of the token you just copied&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  + Post Scriptum
&lt;/h3&gt;

&lt;p&gt;I haven't added support for multiple submodules but it should be easy enough, try edditing this part and then the rest of the script.&lt;/p&gt;

&lt;h2&gt;
  
  
  The code itself
&lt;/h2&gt;

&lt;p&gt;I have thrown in a looooot of comments so that you can easily understand what's happening, it's always good to understand what you're using especially if its some bash script and especially if you're using it to run important code on production ;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# github submodule repo address without https:// prefix&lt;/span&gt;
&lt;span class="nv"&gt;SUBMODULE_GITHUB&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;github.com/beeinger/vercel-private-submodule

&lt;span class="c"&gt;# .gitmodules submodule path&lt;/span&gt;
&lt;span class="nv"&gt;SUBMODULE_PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;library

&lt;span class="c"&gt;# github access token is necessary&lt;/span&gt;
&lt;span class="c"&gt;# add it to Environment Variables on Vercel&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$GITHUB_ACCESS_TOKEN&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Error: GITHUB_ACCESS_TOKEN is empty"&lt;/span&gt;
  &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# stop execution on error - don't let it build if something goes wrong&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt;

&lt;span class="c"&gt;# get submodule commit&lt;/span&gt;
&lt;span class="nv"&gt;output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;git submodule status &lt;span class="nt"&gt;--recursive&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt; &lt;span class="c"&gt;# get submodule info&lt;/span&gt;
&lt;span class="nv"&gt;no_prefix&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;output&lt;/span&gt;&lt;span class="p"&gt;#*-&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt; &lt;span class="c"&gt;# get rid of the prefix&lt;/span&gt;
&lt;span class="nv"&gt;COMMIT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;no_prefix&lt;/span&gt;&lt;span class="p"&gt;% *&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt; &lt;span class="c"&gt;# get rid of the suffix&lt;/span&gt;

&lt;span class="c"&gt;# set up an empty temporary work directory&lt;/span&gt;
&lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-rf&lt;/span&gt; tmp &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt; &lt;span class="c"&gt;# remove the tmp folder if exists&lt;/span&gt;
&lt;span class="nb"&gt;mkdir &lt;/span&gt;tmp &lt;span class="c"&gt;# create the tmp folder&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;tmp &lt;span class="c"&gt;# go into the tmp folder&lt;/span&gt;

&lt;span class="c"&gt;# checkout the current submodule commit&lt;/span&gt;
git init &lt;span class="c"&gt;# initialise empty repo&lt;/span&gt;
git remote add origin https://&lt;span class="nv"&gt;$GITHUB_ACCESS_TOKEN&lt;/span&gt;@&lt;span class="nv"&gt;$SUBMODULE_GITHUB&lt;/span&gt; &lt;span class="c"&gt;# add origin of the submodule&lt;/span&gt;
git fetch &lt;span class="nt"&gt;--depth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 origin &lt;span class="nv"&gt;$COMMIT&lt;/span&gt; &lt;span class="c"&gt;# fetch only the required version&lt;/span&gt;
git checkout &lt;span class="nv"&gt;$COMMIT&lt;/span&gt; &lt;span class="c"&gt;# checkout on the right commit&lt;/span&gt;

&lt;span class="c"&gt;# move the submodule from tmp to the submodule path&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; .. &lt;span class="c"&gt;# go folder up&lt;/span&gt;
&lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-rf&lt;/span&gt; tmp/.git &lt;span class="c"&gt;# remove .git &lt;/span&gt;
&lt;span class="nb"&gt;mv &lt;/span&gt;tmp/&lt;span class="k"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;$SUBMODULE_PATH&lt;/span&gt;/ &lt;span class="c"&gt;# move the submodule to the submodule path&lt;/span&gt;

&lt;span class="c"&gt;# clean up&lt;/span&gt;
&lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-rf&lt;/span&gt; tmp &lt;span class="c"&gt;# remove the tmp folder&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  That's it! 🎉
&lt;/h2&gt;

&lt;p&gt;Thanks for reading, hope it has helped you!&lt;br&gt;
The full repo containing this solution is available here:&lt;br&gt;
&lt;a href="https://github.com/beeinger/vercel-private-submodule" rel="noopener noreferrer"&gt;https://github.com/beeinger/vercel-private-submodule&lt;/a&gt;&lt;br&gt;
If you have some ideas how to improve this solution or you'd like to implement the support for more than one submodule, let me know! &lt;br&gt;
I'll gladly cooperate!&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>devops</category>
    </item>
    <item>
      <title>How to: VSCode TS checks working project-wide &amp; real-time</title>
      <dc:creator>Maciej Sulecki</dc:creator>
      <pubDate>Mon, 08 Nov 2021 22:26:06 +0000</pubDate>
      <link>https://dev.to/beeinger/vscode-project-wide-ts-checks-2c7m</link>
      <guid>https://dev.to/beeinger/vscode-project-wide-ts-checks-2c7m</guid>
      <description>&lt;p&gt;Update: I've created a VSCode extension that works even better! &lt;a href="https://marketplace.visualstudio.com/items?itemName=beeinger.ts-live-checks"&gt;Get it here!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Being a coder I have never limited myself to one language, one framework and I didn’t want to have a milion code editors each specialised in different thing so I have always used VSCode. Keeping the theme, the look and feel of the editor with power of an IDE one plugin away no matter which language I want to jump into is the key factor that guided my choice.&lt;/p&gt;

&lt;p&gt;However, I have tried JetBrains’ WebStorm before and just couldn’t get rid of one huge thing haunting me, the &lt;strong&gt;project-wide type checking&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;In VSCode the typescript plugin works great but it only checks files that are currently opened in the editor! Other &lt;strong&gt;files inside the project are not being checked until opened 😕&lt;/strong&gt; Now this is a huge bump, having to run the check manually through console or build the whole app in order to check if one type alternation hasn’t influenced anything else? Madness…&lt;/p&gt;

&lt;h2&gt;
  
  
  The solution
&lt;/h2&gt;

&lt;p&gt;This is when I decided to research this problem — and there really is no out of the box solution! After trying every way on the internet I have finally pieced together the final solution for this problem:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"tasks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"label"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tsc-watch project"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"typescript"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"tsconfig"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tsconfig.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"option"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"watch"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"problemMatcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"$tsc-watch"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"group"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"runOptions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="nl"&gt;"runOn"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"folderOpen"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"presentation"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"reveal"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"never"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is an &lt;strong&gt;automated task for VSCode&lt;/strong&gt; — it runs when the project folder is opened and keeps on running, checking the whole repo real-time based on the changes you make! &lt;strong&gt;Finally! 🎉&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use it?
&lt;/h2&gt;

&lt;p&gt;Update: Just get &lt;a href="https://marketplace.visualstudio.com/items?itemName=beeinger.ts-live-checks"&gt;this extension&lt;/a&gt;, it does everything for you.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Put it in

&lt;code&gt;.vscode/tasks.json&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;ul&gt;
&lt;li&gt;Re-open the project folder and accept the popup asking whether Automatic Folder Tasks should be allowed&lt;/li&gt;
&lt;li&gt;If the popup isn’t there do:
⌘⇧p
-&amp;gt; Manage Automatic Tasks in Folder
-&amp;gt; Allow Automatic Tasks in Folder&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🎉 All done! Enjoy your VSCode with TypeScript better than ever! 🎉
&lt;/h3&gt;

</description>
      <category>typescript</category>
      <category>vscode</category>
      <category>tutorial</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
