<?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>Forem: hijuliancode</title>
    <description>The latest articles on Forem by hijuliancode (@hijuliancode).</description>
    <link>https://forem.com/hijuliancode</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%2F522432%2F84997986-4db0-4542-bd2f-afd36c9f1127.jpg</url>
      <title>Forem: hijuliancode</title>
      <link>https://forem.com/hijuliancode</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/hijuliancode"/>
    <language>en</language>
    <item>
      <title>Crear un Paquete de NPM - Paso a Paso / TypeScript, commit linting, Husky, Semantic Release</title>
      <dc:creator>hijuliancode</dc:creator>
      <pubDate>Fri, 13 Sep 2024 04:27:47 +0000</pubDate>
      <link>https://forem.com/hijuliancode/crear-un-paquete-de-npm-paso-a-paso-typescript-commit-linting-husky-semantic-release-553d</link>
      <guid>https://forem.com/hijuliancode/crear-un-paquete-de-npm-paso-a-paso-typescript-commit-linting-husky-semantic-release-553d</guid>
      <description>&lt;p&gt;¡Hola!&lt;/p&gt;

&lt;p&gt;Hoy traigo una guía para configurar un paquete de JavaScript/NPM desde cero, incluyendo la configuración de &lt;strong&gt;commit linting&lt;/strong&gt;, &lt;strong&gt;Husky&lt;/strong&gt; y &lt;strong&gt;semantic release&lt;/strong&gt; para un proceso de desarrollo y publicación más fluido. ¡Vamos a ello!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/hijuliancode/elevationteam-utils" rel="noopener noreferrer"&gt;Demo&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Crear un nuevo directorio para el proyecto&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;mkdir &lt;/span&gt;nuevo-proyecto
   &lt;span class="nb"&gt;cd &lt;/span&gt;nuevo-proyecto
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Inicializar un repositorio Git&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   git init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Crear un archivo &lt;code&gt;.gitignore&lt;/code&gt; para excluir &lt;code&gt;node_modules&lt;/code&gt;&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"node_modules"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; .gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Inicializar un nuevo proyecto de Node.js&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Asegúrate de agregar &lt;code&gt;"type": "module"&lt;/code&gt; en tu &lt;code&gt;package.json&lt;/code&gt; para habilitar módulos ES6.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Configurar &lt;code&gt;commitlint&lt;/code&gt; para imponer mensajes de commits consistentes&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; @commitlint/&lt;span class="o"&gt;{&lt;/span&gt;cli,config-conventional&lt;span class="o"&gt;}&lt;/span&gt;
   &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"export default { extends: ['@commitlint/config-conventional'] };"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; commitlint.config.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Configurar &lt;code&gt;husky&lt;/code&gt; para garantizar que los commits sigan las reglas de &lt;code&gt;commitlint&lt;/code&gt;&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; husky
   npx husky init
   &lt;span class="nb"&gt;rm&lt;/span&gt; .husky/pre-commit
   &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"npx --no -- commitlint --edit &lt;/span&gt;&lt;span class="se"&gt;\$&lt;/span&gt;&lt;span class="s2"&gt;1"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; .husky/commit-msg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Verificar la configuración de &lt;code&gt;commitlint&lt;/code&gt;&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npx commitlint &lt;span class="nt"&gt;--from&lt;/span&gt; HEAD~1 &lt;span class="nt"&gt;--to&lt;/span&gt; HEAD &lt;span class="nt"&gt;--verbose&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Hacer algunos commits de prueba para verificar la configuración&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   git add &lt;span class="nb"&gt;.&lt;/span&gt;
   git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"foo: este commit fallará"&lt;/span&gt; &lt;span class="c"&gt;# Este commit debería fallar&lt;/span&gt;
   git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"chore: este commit pasará"&lt;/span&gt; &lt;span class="c"&gt;# Este commit debería pasar&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Instalar y configurar &lt;code&gt;semantic-release&lt;/code&gt; para versionado y publicaciones automáticas&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; semantic-release
   npm &lt;span class="nb"&gt;install&lt;/span&gt; @semantic-release/git @semantic-release/changelog &lt;span class="nt"&gt;-D&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Crear los directorios y el archivo necesarios para &lt;code&gt;semantic-release&lt;/code&gt;:&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="nb"&gt;mkdir&lt;/span&gt; .github
   &lt;span class="nb"&gt;mkdir&lt;/span&gt; .github/workflows/
   &lt;span class="nb"&gt;touch&lt;/span&gt; .github/workflows/release.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Taguear el último commit y subirlo al repositorio&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log &lt;span class="c"&gt;# Copiar el GUID del último commit&lt;/span&gt;
git tag v0.0.0 &amp;lt;COMMIT_GUID&amp;gt;
git tag &lt;span class="nt"&gt;--contains&lt;/span&gt; &amp;lt;COMMIT_GUID&amp;gt;
git push origin tag v0.0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Crear un nuevo token de NPM y agregarlo a los secretos de tu repositorio&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Instalar y configurar Commitizen para mensajes de commit consistentes&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;commitizen &lt;span class="nt"&gt;-g&lt;/span&gt;
commitizen init cz-conventional-changelog &lt;span class="nt"&gt;--save-dev&lt;/span&gt; &lt;span class="nt"&gt;--save-exact&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Instalar herramientas adicionales de desarrollo como TypeScript, Jest y Rollup&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; typescript @types/node jest ts-jest @types/jest
npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; rollup @rollup/plugin-typescript @rollup/plugin-terser
npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; rollup-plugin-dts
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Crear el archivo de configuración de Rollup (&lt;code&gt;rollup.config.js&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;terser&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@rollup/plugin-terser&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;typescript&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@rollup/plugin-typescript&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;dts&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rollup-plugin-dts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src/index.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="nf"&gt;typescript&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; 
        &lt;span class="na"&gt;tsconfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./tsconfig.json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;declaration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;declarationDir&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;}),&lt;/span&gt;
      &lt;span class="nf"&gt;terser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dist/index.mjs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;format&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;esm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dist/index.cjs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;format&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cjs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;named&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src/index.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;dts&lt;/span&gt;&lt;span class="p"&gt;()],&lt;/span&gt;
    &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dist/index.d.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;format&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;es&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;¡Y eso es todo! Ahora tienes un proyecto completamente configurado y listo para desarrollar y publicar tu librería JavaScript. Si tienes alguna pregunta o necesitas más ayuda, no dudes en preguntar. ¡Feliz codificación! 🚀&lt;/p&gt;

&lt;p&gt;Saludos.&lt;/p&gt;

&lt;p&gt;Pendiente:&lt;br&gt;
[] Explicar creacion de tokens e instalacion en githun&lt;br&gt;
[] Actualizacion de package.json con husky y demas&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>npm</category>
      <category>git</category>
      <category>release</category>
    </item>
    <item>
      <title>Effective Git Workflow: Managing Version Control in Team Environments</title>
      <dc:creator>hijuliancode</dc:creator>
      <pubDate>Fri, 13 Sep 2024 04:21:04 +0000</pubDate>
      <link>https://forem.com/hijuliancode/effective-git-workflow-managing-version-control-in-team-environments-3al8</link>
      <guid>https://forem.com/hijuliancode/effective-git-workflow-managing-version-control-in-team-environments-3al8</guid>
      <description>&lt;p&gt;&lt;strong&gt;Git&lt;/strong&gt; is a version control system used to manage changes to files, typically in code or design projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Version Control?
&lt;/h3&gt;

&lt;p&gt;Version control refers to managing changes made to files over time. It allows us to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Track modifications,&lt;/li&gt;
&lt;li&gt;Revert to previous versions,&lt;/li&gt;
&lt;li&gt;Collaborate effectively.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why do we use &lt;strong&gt;Git&lt;/strong&gt;?
&lt;/h3&gt;

&lt;p&gt;Git helps us:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Preserve changes,&lt;/li&gt;
&lt;li&gt;Track modifications across one or multiple files,&lt;/li&gt;
&lt;li&gt;Save progress in projects, whether code or design.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While Git can be used for personal notes or academic purposes, it's mainly used for team collaboration. Simply put, Git is "a tool that helps me organize with my team and track the work we do."&lt;/p&gt;

&lt;p&gt;Remember, Git operates within a directory, so even if you want to track a single file, Git must be initialized in the directory containing that file.&lt;/p&gt;




&lt;h3&gt;
  
  
  Useful Commands for Team Collaboration
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Initialize a Git repository in a directory&lt;/span&gt;
git init

&lt;span class="c"&gt;# Update all remote branches&lt;/span&gt;
git fetch &lt;span class="nt"&gt;--all&lt;/span&gt;

&lt;span class="c"&gt;# List local branches&lt;/span&gt;
git branch

&lt;span class="c"&gt;# List both local and remote branches&lt;/span&gt;
git branch &lt;span class="nt"&gt;-a&lt;/span&gt;

&lt;span class="c"&gt;# Add a remote repository&lt;/span&gt;
git remote add origin https://gitlab.com/hijuliancode/demo-git-tutorial

&lt;span class="c"&gt;# Add a Heroku remote repository&lt;/span&gt;
git remote add heroku https://git.heroku.com/demo-heroku-repo.git

&lt;span class="c"&gt;# Remove a remote repository&lt;/span&gt;
git remote remove heroku

&lt;span class="c"&gt;# View all configured remote repositories&lt;/span&gt;
git remote &lt;span class="nt"&gt;-v&lt;/span&gt;

&lt;span class="c"&gt;# Fetch and merge changes from the master branch of the remote repository&lt;/span&gt;
git pull origin master

&lt;span class="c"&gt;# Push changes from the local master branch to the remote repository&lt;/span&gt;
git push origin master

&lt;span class="c"&gt;# Display the state of your working directory and staging area&lt;/span&gt;
git status

&lt;span class="c"&gt;# Stage a file for commit&lt;/span&gt;
git add filename.html

&lt;span class="c"&gt;# Stage all changes in the current directory for commit&lt;/span&gt;
git add &lt;span class="nb"&gt;.&lt;/span&gt;

&lt;span class="c"&gt;# Remove a file from the staging area&lt;/span&gt;
git reset filename.html

&lt;span class="c"&gt;# Remove all changes from the staging area&lt;/span&gt;
git reset &lt;span class="nb"&gt;.&lt;/span&gt;

&lt;span class="c"&gt;# Rename a file&lt;/span&gt;
git &lt;span class="nb"&gt;mv &lt;/span&gt;oldname.js newname.js

&lt;span class="c"&gt;# Rename a file within a directory&lt;/span&gt;
git &lt;span class="nb"&gt;mv &lt;/span&gt;folder/oldname.js folder/newname.js

&lt;span class="c"&gt;# Temporarily save changes and revert to the last commit&lt;/span&gt;
git stash

&lt;span class="c"&gt;# Restore changes from the stash&lt;/span&gt;
git stash apply

&lt;span class="c"&gt;# Create a commit with a descriptive message&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Message"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Example Workflow&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Imagine we’re building a house as a project. Here’s how a workflow might look with three team members: &lt;em&gt;Person A&lt;/em&gt;, &lt;em&gt;Person B&lt;/em&gt;, and &lt;em&gt;Person C&lt;/em&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Person A&lt;/strong&gt; initializes the repository:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git init
git remote add origin git@gitlab.com:hijuliancode/demo-git-tutorial.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Person A&lt;/strong&gt; creates an initial file and pushes it to the repository:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"## demo-git-tutorial"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; README.md
git add README.md
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"initial commit"&lt;/span&gt;
git branch &lt;span class="nt"&gt;-M&lt;/span&gt; master
git push origin master
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Person B&lt;/strong&gt; and &lt;strong&gt;Person C&lt;/strong&gt; clone the repository:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone git@gitlab.com:hijuliancode/demo-git-tutorial.git
&lt;span class="nb"&gt;cd &lt;/span&gt;demo-git-tutorial
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Person A&lt;/strong&gt; creates the &lt;code&gt;develop&lt;/code&gt; branch and pushes it to the remote:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout &lt;span class="nt"&gt;-b&lt;/span&gt; develop
git push origin develop
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Person B&lt;/strong&gt; and &lt;strong&gt;Person C&lt;/strong&gt; update their local repositories to include the &lt;code&gt;develop&lt;/code&gt; branch:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git fetch &lt;span class="nt"&gt;--all&lt;/span&gt;
git checkout develop
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now everyone has the repository and can start contributing.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Person A&lt;/strong&gt; creates a feature branch to work on the house plans:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout &lt;span class="nt"&gt;-b&lt;/span&gt; feature/house-plans
&lt;span class="nb"&gt;touch &lt;/span&gt;house-plans.js
git add house-plans.js
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Add house plans"&lt;/span&gt;
git push origin feature/house-plans
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Person B&lt;/strong&gt; and &lt;strong&gt;Person C&lt;/strong&gt; update their local repositories to access the new branch:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git fetch &lt;span class="nt"&gt;--all&lt;/span&gt;
git branch &lt;span class="nt"&gt;-a&lt;/span&gt;
git checkout feature/house-plans
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Person B&lt;/strong&gt; wants to suggest improvements to the house plans. They can do so by creating a Pull Request (or Merge Request):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navigate to the repository's GitHub or GitLab page,&lt;/li&gt;
&lt;li&gt;Go to the Pull Request or Merge Request section,&lt;/li&gt;
&lt;li&gt;Assign a reviewer (like a team lead or peer).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To apply the suggested changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   git add house-plans.js
   git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Improve house plans"&lt;/span&gt;
   git push origin feature/house-plans
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Once the feature branch is reviewed and merged, it can be deleted:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout develop
git pull origin develop
git branch &lt;span class="nt"&gt;-D&lt;/span&gt; feature/house-plans
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Repeat this process for new features or changes!&lt;/p&gt;

</description>
      <category>git</category>
      <category>tutorial</category>
      <category>versioncontrol</category>
      <category>workflow</category>
    </item>
    <item>
      <title>Create a NPM Package - Step by Step / TypeScript, commit linting, Husky, Semantic Release</title>
      <dc:creator>hijuliancode</dc:creator>
      <pubDate>Fri, 13 Sep 2024 04:02:49 +0000</pubDate>
      <link>https://forem.com/hijuliancode/create-a-npm-package-step-by-step-4g3m</link>
      <guid>https://forem.com/hijuliancode/create-a-npm-package-step-by-step-4g3m</guid>
      <description>&lt;p&gt;Hello, developer community!&lt;/p&gt;

&lt;p&gt;Today, I’m going to walk you through the steps to set up a JavaScript library from scratch, including configuring commit linting, Husky, and semantic release for smooth development and release processes. Let’s dive into it!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/hijuliancode/elevationteam-utils" rel="noopener noreferrer"&gt;Demo&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create a new project directory&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;mkdir &lt;/span&gt;new-project
   &lt;span class="nb"&gt;cd &lt;/span&gt;new-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Initialize a Git repository&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   git init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create a &lt;code&gt;.gitignore&lt;/code&gt; file to exclude &lt;code&gt;node_modules&lt;/code&gt;&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"node_modules"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; .gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Initialize a new Node.js project&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure to add &lt;code&gt;"type": "module"&lt;/code&gt; to your &lt;code&gt;package.json&lt;/code&gt; to enable ES6 modules.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Set up &lt;code&gt;commitlint&lt;/code&gt; to enforce consistent commit messages&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; @commitlint/&lt;span class="o"&gt;{&lt;/span&gt;cli,config-conventional&lt;span class="o"&gt;}&lt;/span&gt;
   &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"export default { extends: ['@commitlint/config-conventional'] };"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; commitlint.config.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Configure &lt;code&gt;husky&lt;/code&gt; to ensure commits follow &lt;code&gt;commitlint&lt;/code&gt; rules&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; husky
   npx husky init
   &lt;span class="nb"&gt;rm&lt;/span&gt; .husky/pre-commit
   &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"npx --no -- commitlint --edit &lt;/span&gt;&lt;span class="se"&gt;\$&lt;/span&gt;&lt;span class="s2"&gt;1"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; .husky/commit-msg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Verify &lt;code&gt;commitlint&lt;/code&gt; configuration&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npx commitlint &lt;span class="nt"&gt;--from&lt;/span&gt; HEAD~1 &lt;span class="nt"&gt;--to&lt;/span&gt; HEAD &lt;span class="nt"&gt;--verbose&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Perform some test commits to check the configuration&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   git add &lt;span class="nb"&gt;.&lt;/span&gt;
   git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"foo: this will fail"&lt;/span&gt; &lt;span class="c"&gt;# This commit should fail&lt;/span&gt;
   git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"chore: this will pass"&lt;/span&gt; &lt;span class="c"&gt;# This commit should pass&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Install and configure &lt;code&gt;semantic-release&lt;/code&gt; for automated versioning and releases&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; semantic-release
   npm &lt;span class="nb"&gt;install&lt;/span&gt; @semantic-release/git @semantic-release/changelog &lt;span class="nt"&gt;-D&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create the necessary directories and file for &lt;code&gt;semantic-release&lt;/code&gt;:&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="nb"&gt;mkdir&lt;/span&gt; .github
   &lt;span class="nb"&gt;mkdir&lt;/span&gt; .github/workflows/
   &lt;span class="nb"&gt;touch&lt;/span&gt; .github/workflows/release.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tag the latest commit and push it to the repository&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log &lt;span class="c"&gt;# Copy the GUID of the latest commit&lt;/span&gt;
git tag v0.0.0 &amp;lt;COMMIT_GUID&amp;gt;
git tag &lt;span class="nt"&gt;--contains&lt;/span&gt; &amp;lt;COMMIT_GUID&amp;gt;
git push origin tag v0.0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Create a new NPM token and add it to your repository secrets&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Install and configure Commitizen for consistent commit messages&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;commitizen &lt;span class="nt"&gt;-g&lt;/span&gt;
commitizen init cz-conventional-changelog &lt;span class="nt"&gt;--save-dev&lt;/span&gt; &lt;span class="nt"&gt;--save-exact&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Install additional development tools like TypeScript, Jest, and Rollup&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; typescript @types/node jest ts-jest @types/jest
npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; rollup @rollup/plugin-typescript @rollup/plugin-terser
npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; rollup-plugin-dts
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Create the Rollup configuration file (&lt;code&gt;rollup.config.js&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;terser&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@rollup/plugin-terser&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;typescript&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@rollup/plugin-typescript&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;dts&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rollup-plugin-dts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src/index.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="nf"&gt;typescript&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; 
        &lt;span class="na"&gt;tsconfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./tsconfig.json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;declaration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;declarationDir&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;}),&lt;/span&gt;
      &lt;span class="nf"&gt;terser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dist/index.mjs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;format&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;esm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dist/index.cjs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;format&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cjs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;named&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;src/index.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;dts&lt;/span&gt;&lt;span class="p"&gt;()],&lt;/span&gt;
    &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dist/index.d.ts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;format&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;es&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And that’s it! You now have a fully configured project ready for developing and publishing your JavaScript library. If you have any questions or need further assistance, feel free to ask. Happy coding! 🚀&lt;/p&gt;

&lt;p&gt;Best regards!&lt;/p&gt;

</description>
      <category>npm</category>
      <category>package</category>
      <category>typescript</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Flujo de trabajo Git eficaz: gestión del control de versiones en entornos de equipo</title>
      <dc:creator>hijuliancode</dc:creator>
      <pubDate>Sun, 17 Jan 2021 04:32:02 +0000</pubDate>
      <link>https://forem.com/hijuliancode/trabajo-en-equipo-con-git-g6p</link>
      <guid>https://forem.com/hijuliancode/trabajo-en-equipo-con-git-g6p</guid>
      <description>&lt;h1&gt;
  
  
  &lt;strong&gt;Git: Un Sistema de Control de Versiones&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Git&lt;/strong&gt; es un sistema de control de versiones utilizado para gestionar cambios en archivos, generalmente en proyectos de código o diseño.&lt;/p&gt;

&lt;h3&gt;
  
  
  ¿Qué es el Control de Versiones?
&lt;/h3&gt;

&lt;p&gt;Se refiere a la administración de cambios realizados a archivos a lo largo del tiempo. Nos permite:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rastrear modificaciones,&lt;/li&gt;
&lt;li&gt;Revertir a versiones anteriores,&lt;/li&gt;
&lt;li&gt;Colaborar de manera efectiva.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ¿Por qué usamos &lt;strong&gt;Git&lt;/strong&gt;?
&lt;/h3&gt;

&lt;p&gt;Git nos ayuda a:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Preservar cambios,&lt;/li&gt;
&lt;li&gt;Rastrear modificaciones en uno o más archivos,&lt;/li&gt;
&lt;li&gt;Guardar el progreso en proyectos, ya sean de código o diseño.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Aunque Git también se puede usar para notas personales o tareas académicas, su uso principal es para colaboración en equipo. En términos simples, Git es "una herramienta que me ayuda a organizarme con mi equipo y a seguir el trabajo que hacemos".&lt;/p&gt;

&lt;p&gt;Recuerda que Git opera dentro de un directorio. Si quieres rastrear un solo archivo, Git debe estar inicializado en el directorio que contiene ese archivo.&lt;/p&gt;




&lt;h3&gt;
  
  
  Comandos Útiles para Colaboración en Equipo
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Inicializar un repositorio Git en un directorio&lt;/span&gt;
git init

&lt;span class="c"&gt;# Actualizar todas las ramas remotas&lt;/span&gt;
git fetch &lt;span class="nt"&gt;--all&lt;/span&gt;

&lt;span class="c"&gt;# Listar ramas locales&lt;/span&gt;
git branch

&lt;span class="c"&gt;# Listar ramas locales y remotas&lt;/span&gt;
git branch &lt;span class="nt"&gt;-a&lt;/span&gt;

&lt;span class="c"&gt;# Agregar un repositorio remoto&lt;/span&gt;
git remote add origin https://gitlab.com/hijuliancode/demo-git-tutorial

&lt;span class="c"&gt;# Agregar un repositorio remoto de Heroku&lt;/span&gt;
git remote add heroku https://git.heroku.com/demo-heroku-repo.git

&lt;span class="c"&gt;# Eliminar un repositorio remoto&lt;/span&gt;
git remote remove heroku

&lt;span class="c"&gt;# Ver todos los repositorios remotos configurados&lt;/span&gt;
git remote &lt;span class="nt"&gt;-v&lt;/span&gt;

&lt;span class="c"&gt;# Traer y fusionar cambios del repositorio remoto en la rama master&lt;/span&gt;
git pull origin master

&lt;span class="c"&gt;# Subir cambios desde la rama master local al repositorio remoto&lt;/span&gt;
git push origin master

&lt;span class="c"&gt;# Mostrar el estado del directorio de trabajo y el área de staging&lt;/span&gt;
git status

&lt;span class="c"&gt;# Agregar un archivo al área de staging&lt;/span&gt;
git add filename.html

&lt;span class="c"&gt;# Agregar todos los cambios del directorio actual al área de staging&lt;/span&gt;
git add &lt;span class="nb"&gt;.&lt;/span&gt;

&lt;span class="c"&gt;# Quitar un archivo del área de staging&lt;/span&gt;
git reset filename.html

&lt;span class="c"&gt;# Quitar todos los archivos del área de staging&lt;/span&gt;
git reset &lt;span class="nb"&gt;.&lt;/span&gt;

&lt;span class="c"&gt;# Renombrar un archivo&lt;/span&gt;
git &lt;span class="nb"&gt;mv &lt;/span&gt;oldname.js newname.js

&lt;span class="c"&gt;# Renombrar un archivo dentro de un directorio&lt;/span&gt;
git &lt;span class="nb"&gt;mv &lt;/span&gt;folder/oldname.js folder/newname.js

&lt;span class="c"&gt;# Guardar temporalmente los cambios y volver al último commit&lt;/span&gt;
git stash

&lt;span class="c"&gt;# Restaurar los cambios guardados en el stash&lt;/span&gt;
git stash apply

&lt;span class="c"&gt;# Crear un commit con un mensaje descriptivo&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Mensaje"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Ejemplo de Workflow&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Imagina que estamos construyendo una casa como proyecto. Aquí te dejo el flujo de trabajo que usarían tres personas: &lt;em&gt;Persona A&lt;/em&gt;, &lt;em&gt;Persona B&lt;/em&gt; y &lt;em&gt;Persona C&lt;/em&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Persona A&lt;/strong&gt; inicializa el repositorio:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git init
git remote add origin git@gitlab.com:hijuliancode/demo-git-tutorial.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Persona A&lt;/strong&gt; crea un archivo inicial y lo empuja al repositorio:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"## demo-git-tutorial"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; README.md
git add README.md
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"initial commit"&lt;/span&gt;
git branch &lt;span class="nt"&gt;-M&lt;/span&gt; master
git push origin master
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Persona B&lt;/strong&gt; y &lt;strong&gt;Persona C&lt;/strong&gt; clonan el repositorio:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone git@gitlab.com:hijuliancode/demo-git-tutorial.git
&lt;span class="nb"&gt;cd &lt;/span&gt;demo-git-tutorial
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Persona A&lt;/strong&gt; crea la rama &lt;code&gt;develop&lt;/code&gt; y la sube al repositorio remoto:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout &lt;span class="nt"&gt;-b&lt;/span&gt; develop
git push origin develop
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Persona B&lt;/strong&gt; y &lt;strong&gt;Persona C&lt;/strong&gt; actualizan sus repositorios locales para incluir la rama &lt;code&gt;develop&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git fetch &lt;span class="nt"&gt;--all&lt;/span&gt;
git checkout develop
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ahora, todos tienen el repositorio y pueden empezar a contribuir.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Persona A&lt;/strong&gt; crea una rama de característica (feature) para trabajar en los planos de la casa:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout &lt;span class="nt"&gt;-b&lt;/span&gt; feature/house-plans
&lt;span class="nb"&gt;touch &lt;/span&gt;house-plans.js
git add house-plans.js
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Add house plans"&lt;/span&gt;
git push origin feature/house-plans
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Persona B&lt;/strong&gt; y &lt;strong&gt;Persona C&lt;/strong&gt; actualizan sus repositorios locales para obtener la nueva rama:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git fetch &lt;span class="nt"&gt;--all&lt;/span&gt;
git branch &lt;span class="nt"&gt;-a&lt;/span&gt;
git checkout feature/house-plans
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Persona B&lt;/strong&gt; sugiere mejoras a los planos. Para eso crea un Pull Request (o Merge Request):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ve al repositorio en GitHub o GitLab,&lt;/li&gt;
&lt;li&gt;Navega a la sección de Pull Requests o Merge Requests,&lt;/li&gt;
&lt;li&gt;Asigna un revisor (como un líder de equipo o un compañero).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Para aplicar las sugerencias:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   git add house-plans.js
   git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Improve house plans"&lt;/span&gt;
   git push origin feature/house-plans
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Una vez que se aprueba y fusiona la rama, puede eliminarse:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout develop
git pull origin develop
git branch &lt;span class="nt"&gt;-D&lt;/span&gt; feature/house-plans
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;¡Y listo! Repite este proceso para nuevas características o cambios.&lt;/p&gt;

</description>
      <category>git</category>
      <category>contribute</category>
      <category>tutorial</category>
      <category>teams</category>
    </item>
  </channel>
</rss>
