Home Web Front-end JS Tutorial Re-publishing gimme_readme to npm with GitHub Actions

Re-publishing gimme_readme to npm with GitHub Actions

Dec 01, 2024 am 02:02 AM

This week in my Open Source class, my classmates and I were tasked with publishing each of our own programs to a package registry.

When you hear someone say code registry, package registry, or registry, I like to think of these words as representing a place where developers and companies publish their code for others to download. For a more accurate description, you can read this article by Mozilla:

Re-publishing gimme_readme to npm with GitHub Actions

Package management basics - Learn web development | MDN

This brings us to the end of our tour of package managers. Our next move is to build up a sample toolchain, putting all that we've learnt so far into practice.

Re-publishing gimme_readme to npm with GitHub Actions

gimme_readme - npm

gimme_readme is a command-line tool powered by AI that generates a comprehensive README.md file for your project. It analyzes multiple source code files at once, providing concise explanations of each file's purpose, functionality, and key components, all. Latest version: 1.0.0, last published: 16 hours ago. Start using gimme_readme in your project by running `npm i gimme_readme`. There are no other projects in the npm registry using gimme_readme.

Re-publishing gimme_readme to npm with GitHub Actions

As you can see above, there are a lot of folders and files that are unnecessary for a user to have (as opposed to a developer). For example, do you think my users would want my "tests" folder to test my program's code? Probably not. Do you think my users need the config files needed to format and lint my source code? Probably not. Do you think my users would need to use my ".github" folder for any particular reason? Probably not.

To this end, I have been working to find a solution to minimize what is downloaded by a user; specifically, I want them to only have the source code needed for my program to run.

To .npmignore or to not .npmignore? That is the question.

As I was thinking about re-publishing my code, I was also talking with my friend Uday Rana, about the idea of using a .npmignore file to "ignore" files I didn't want to publish.

Literally right after I mentioned the topic, Uday Googled .npmignore, and found an article written by Jeff D on why one should never use a .npmignore file. To be clear, I wholeheartedly agree with Jeff's article.

Essentially, the idea is that we should be explicit with what we want to publish (whitelisting), as opposed to stating which files we don't want to publish (blacklisting).

Whitelisting the files we wish to publish is simple with npm. All we need to do is edit our package.json file by adding a "files" option, that indicates which files we want to publish for our program.

Below, I've taken a screenshot of package.json's "files" option, which states, "include the src/ directory when publishing this program". I have since committed these changes and these changes are available in my v1.0.0 release of my code.

Re-publishing gimme_readme to npm with GitHub Actions

NOTE: Certain files by default, are always published to npm, regardless of what you specify or don't specify in your "files" option. If you want to learn more about how to use the "files" option, check out npm's official documentation on how to use the file option.

After publishing my code to npm with my updated package.json, users that install/re-install gimme_readme will now have a lot less bloat on their computers! See the difference below:

Re-publishing gimme_readme to npm with GitHub Actions

Adding a GitHub action to publish my code to npm when I add a new release

Besides enhancing the experience of my users (by reducing the bloat that comes from installing gimme_readme via npm), I also added a continuous development pipeline (cd pipeline for short) that would automate my publishing process to npm when I make a new release on GitHub. For exact details on how to do this, you can refer to GitHub's Publishing Node.js packages guide. This feels good now, because at the click of a few buttons, I'm able to publish code that I know is stable (according to my CI pipeline), from GitHub.

You can find the code for my cd pipeline here.

Testing with Uday

As I mentioned earlier, I was working with my friend, Uday Rana, with regards to testing. At the time of writing, he was able to install my tool, and use it like so:

Re-publishing gimme_readme to npm with GitHub Actions

Things look good to me, and most of the options I have for my tool more or less behave the way he expects. But I'll have to repeat this process again, because I have some further optimizations I want to add!

The journey never ends... but that's what makes it fun!

I have also recently heard of ways to optimize my code further. Particularly, I'm invested in learning how to improve my CI and CD pipelines by learning about composite actions, and reusable workflows with regards to GitHub actions. My hope is that these techniques will help me reduce the amount of code I write, and offer some type of performance boost! I don't know much about these topics yet, but you can bet I will probably blog about it soon.

And that my friends, concludes what I wanted to talk about in this blog.

See you next time!

The above is the detailed content of Re-publishing gimme_readme to npm with GitHub Actions. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1268
29
C# Tutorial
1242
24
Demystifying JavaScript: What It Does and Why It Matters Demystifying JavaScript: What It Does and Why It Matters Apr 09, 2025 am 12:07 AM

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

The Evolution of JavaScript: Current Trends and Future Prospects The Evolution of JavaScript: Current Trends and Future Prospects Apr 10, 2025 am 09:33 AM

The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.

JavaScript Engines: Comparing Implementations JavaScript Engines: Comparing Implementations Apr 13, 2025 am 12:05 AM

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

Python vs. JavaScript: The Learning Curve and Ease of Use Python vs. JavaScript: The Learning Curve and Ease of Use Apr 16, 2025 am 12:12 AM

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

JavaScript: Exploring the Versatility of a Web Language JavaScript: Exploring the Versatility of a Web Language Apr 11, 2025 am 12:01 AM

JavaScript is the core language of modern web development and is widely used for its diversity and flexibility. 1) Front-end development: build dynamic web pages and single-page applications through DOM operations and modern frameworks (such as React, Vue.js, Angular). 2) Server-side development: Node.js uses a non-blocking I/O model to handle high concurrency and real-time applications. 3) Mobile and desktop application development: cross-platform development is realized through ReactNative and Electron to improve development efficiency.

How to Build a Multi-Tenant SaaS Application with Next.js (Frontend Integration) How to Build a Multi-Tenant SaaS Application with Next.js (Frontend Integration) Apr 11, 2025 am 08:22 AM

This article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base

Building a Multi-Tenant SaaS Application with Next.js (Backend Integration) Building a Multi-Tenant SaaS Application with Next.js (Backend Integration) Apr 11, 2025 am 08:23 AM

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing

From C/C   to JavaScript: How It All Works From C/C to JavaScript: How It All Works Apr 14, 2025 am 12:05 AM

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

See all articles