<?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: Martin Torp</title>
    <description>The latest articles on DEV Community by Martin Torp (@torp_martin).</description>
    <link>https://dev.to/torp_martin</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%2F1001630%2Ff4666d03-20e8-4f23-8b8f-f1e7967f74e1.jpg</url>
      <title>DEV Community: Martin Torp</title>
      <link>https://dev.to/torp_martin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/torp_martin"/>
    <language>en</language>
    <item>
      <title>A developer-friendly introduction to open source licenses</title>
      <dc:creator>Martin Torp</dc:creator>
      <pubDate>Mon, 06 Mar 2023 13:04:02 +0000</pubDate>
      <link>https://dev.to/torp_martin/a-developer-friendly-introduction-to-open-source-licenses-236j</link>
      <guid>https://dev.to/torp_martin/a-developer-friendly-introduction-to-open-source-licenses-236j</guid>
      <description>&lt;p&gt;The word 'license' probably triggers a sense of discomfort with most developers.&lt;br&gt;
We may think of open licenses as a legal issue that belongs to the legal department, and thus as an issue largely to be ignored in our day-to-day work.&lt;br&gt;
However, if you work with open source libraries and frameworks, which you almost certainly do, then you have to have at least a little bit of basic knowledge of open source licenses. &lt;br&gt;
Licenses can be long, complicated, and full of legal jargon, but luckily, we, as developers can often ignore much of the content in the license by following some basic principles 😌&lt;/p&gt;

&lt;p&gt;Let's first briefly consider why we need to care about open source licenses.&lt;br&gt;
If a project is open source, it means that anybody can view, copy and build on top of the source under some &lt;em&gt;conditions&lt;/em&gt;.&lt;br&gt;
Those conditions are an important part of the license.&lt;br&gt;
Generally, there are two types of licenses we need to distinguish between known as &lt;em&gt;copyleft licenses&lt;/em&gt; and &lt;em&gt;permissive licenses&lt;/em&gt;.&lt;br&gt;
Here is the basic distinction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Copyleft:&lt;/strong&gt; You may copy, reuse and build on top of a copyleft-licensed project as long as you release your project using a compatible copyleft license.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Permissive:&lt;/strong&gt; You may copy, reuse and build on top of the permissively-licensed project. You are typically required to credit (add attribution) the project. &lt;/p&gt;

&lt;p&gt;If you want to build a project that is closed source, all of your dependencies should be licensed with a permissive license.&lt;br&gt;
If you want to build an open source project, you should either license it with a copyleft license or only use permissively licensed dependencies.&lt;br&gt;
Keep in mind that an open source library or framework tends to have a much broader adoption when it is permissively licensed exactly because it allows others to use it in closed source products.&lt;/p&gt;

&lt;p&gt;The list below shows some of the most commonly used licenses and whether they are copyleft or permissive.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;License&lt;/th&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;MIT&lt;/td&gt;
&lt;td&gt;Permissive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Apache&lt;/td&gt;
&lt;td&gt;Permissive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;BSD&lt;/td&gt;
&lt;td&gt;Permissive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;WTFPL&lt;/td&gt;
&lt;td&gt;Permissive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AFL&lt;/td&gt;
&lt;td&gt;Permissive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CC0&lt;/td&gt;
&lt;td&gt;Public domain (less restrictive than permissive)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GPL&lt;/td&gt;
&lt;td&gt;Copyleft&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;To check the license of a project you can either refer to the LICENSE file on its GitHub page or use one of the many tools available for providing an overview of used licenses.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/license-checker"&gt;NPM License Checker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://debricked.com/tools/license-compliance/"&gt;Debricked Compliance&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://snyk.io/product/open-source-security-management/"&gt;Snyk Open Source&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you use pnpm, then you can also use the &lt;code&gt;pnpm licenses&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;I hope this quick introduction to open source licenses was useful.&lt;br&gt;
Please keep in mind that there are many other aspects to licensing that this post doesn't cover.&lt;br&gt;
I'm also not a legal advisor and cannot be held responsible for any legal violations. &lt;/p&gt;

</description>
      <category>licenses</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Navigating lock files: best practices and tips</title>
      <dc:creator>Martin Torp</dc:creator>
      <pubDate>Thu, 23 Feb 2023 11:51:24 +0000</pubDate>
      <link>https://dev.to/torp_martin/navigating-lock-files-best-practices-and-tips-5f44</link>
      <guid>https://dev.to/torp_martin/navigating-lock-files-best-practices-and-tips-5f44</guid>
      <description>&lt;p&gt;If you are unsure about how to manage the package-lock.json (or yarn.lock) file in your project, you're not alone. This file is essential for ensuring that your project's dependencies are restored to the same versions on any machine where you run &lt;code&gt;npm install&lt;/code&gt;(or &lt;code&gt;yarn&lt;/code&gt;). This is important because without a lock file, legacy projects may break if a dependency version is changed between installations. Here are some best practices and tips for working with lock files:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Merge conflicts:&lt;/strong&gt; Do not manually resolve merge conflicts in lock files. npm and yarn can do it for you automatically! If there are merge conflicts in the package.json file, first resolve them manually and then run the &lt;code&gt;npm install&lt;/code&gt; (or &lt;code&gt;yarn&lt;/code&gt;) command to automatically fix any corresponding conflicts in the lock file. See &lt;a href="https://gist.github.com/szemate/6fb69c8e3d8cce3efa9a6c922b337d98"&gt;this gist&lt;/a&gt; for more details.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use in CI:&lt;/strong&gt; In CI environments, it is best to use &lt;code&gt;npm ci&lt;/code&gt; (&lt;em&gt;clean install&lt;/em&gt;) instead of &lt;code&gt;npm install&lt;/code&gt;. &lt;code&gt;npm ci&lt;/code&gt; will ensure a clean installation of dependencies by deleting the previous node_modules and by never making changes to package.json. &lt;code&gt;npm install&lt;/code&gt;, on the other hand, may update the package-lock.json file if it is inconsistent with package.json. The yarn equivalent of &lt;code&gt;npm ci&lt;/code&gt; is &lt;code&gt;yarn install --immutable --immutable-cache --check-cache&lt;/code&gt; (See &lt;a href="https://stackoverflow.com/a/69944063"&gt;https://stackoverflow.com/a/69944063&lt;/a&gt; for more details)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Converting between yarn.lock and package-lock.json:&lt;/strong&gt; yarn uses yarn.lock and npm uses package-lock.json. You can convert a yarn.lock file to a package-lock.json using the &lt;code&gt;yarn import&lt;/code&gt; command. Use &lt;a href="https://github.com/imsnif/synp"&gt;synp&lt;/a&gt; to convert yarn.lock files to package-lock.json.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Don’t change lock files manually:&lt;/strong&gt; Use &lt;code&gt;npm update&lt;/code&gt; and &lt;code&gt;npm install&lt;/code&gt; to add and update packages.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Lock files can be intimidating, but they are easy to work with as long as you avoid manually editing them. Following these practices will help ensure that your project runs smoothly.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>npm</category>
      <category>packagemanagement</category>
    </item>
  </channel>
</rss>
