npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@luca-sordetti/adonis6-scheduler

v0.0.0

Published

> A boilerplate for creating AdonisJS packages

Downloads

80

Readme

AdonisJS package starter kit

A boilerplate for creating AdonisJS packages

This repo provides you with a starting point for creating AdonisJS packages. Of course, you can create a package from scratch with your folder structure and workflow. However, using this starter kit can speed up the process, as you have fewer decisions to make.

Setup

  • Clone the repo on your computer, or use giget to download this repo without the Git history.
    npx giget@latest gh:adonisjs/pkg-starter-kit
  • Install dependencies.
  • Update the package.json file and define the name, description, keywords, and author properties.
  • The repo is configured with an MIT license. Feel free to change that if you are not publishing under the MIT license.

Folder structure

The starter kit mimics the folder structure of the official packages. Feel free to rename files and folders as per your requirements.

├── providers
├── src
├── bin
├── stubs
├── configure.ts
├── index.ts
├── LICENSE.md
├── package.json
├── README.md
├── tsconfig.json
├── tsnode.esm.js
  • The configure.ts file exports the configure hook to configure the package using the node ace configure command.
  • The index.ts file is the main entry point of the package.
  • The tsnode.esm.js file runs TypeScript code using TS-Node + SWC. Please read the code comment in this file to learn more.
  • The bin directory contains the entry point file to run Japa tests.
  • Learn more about the providers directory.
  • Learn more about the src directory.
  • Learn more about the stubs directory.

File system naming convention

We use snake_case naming conventions for the file system. The rule is enforced using ESLint. However, turn off the rule and use your preferred naming conventions.

Peer dependencies

The starter kit has a peer dependency on @adonisjs/core@6. Since you are creating a package for AdonisJS, you must make it against a specific version of the framework core.

If your package needs Lucid to be functional, you may install @adonisjs/lucid as a development dependency and add it to the list of peerDependencies.

As a rule of thumb, packages installed in the user application should be part of the peerDependencies of your package and not the main dependency.

For example, if you install @adonisjs/core as a main dependency, then essentially, you are importing a separate copy of @adonisjs/core and not sharing the one from the user application. Here is a great article explaining peer dependencies.

Published files

Instead of publishing your repo's source code to npm, you must cherry-pick files and folders to publish only the required files.

The cherry-picking uses the files property inside the package.json file. By default, we publish the following files and folders.

{
  "files": ["build/src", "build/providers", "build/stubs", "build/index.d.ts", "build/index.js"]
}

If you create additional folders or files, mention them inside the files array.

Exports

Node.js Subpath exports allows you to define the exports of your package regardless of the folder structure. This starter kit defines the following exports.

{
  "exports": {
    ".": "./build/index.js",
    "./types": "./build/src/types.js"
  }
}
  • The dot . export is the main export.
  • The ./types exports all the types defined inside the ./build/src/types.js file (the compiled output).

Feel free to change the exports as per your requirements.

Testing

We configure the Japa test runner with this starter kit. Japa is used in AdonisJS applications as well. Just run one of the following commands to execute tests.

  • npm run test: This command will first lint the code using ESlint and then run tests and report the test coverage using c8.
  • npm run quick:test: Runs only the tests without linting or coverage reporting.

The starter kit also has a Github workflow file to run tests using Github Actions. The tests are executed against Node.js 20.x and Node.js 21.x versions on both Linux and Windows. Feel free to edit the workflow file in the .github/workflows directory.

TypeScript workflow

  • The starter kit uses tsc for compiling the TypeScript to JavaScript when publishing the package.
  • TS-Node and SWC are used to run tests without compiling the source code.
  • The tsconfig.json file is extended from @adonisjs/tsconfig and uses the NodeNext module system. Meaning the packages are written using ES modules.
  • You can perform type checking without compiling the source code using the npm run type check script.

Feel free to explore the tsconfig.json file for all the configured options.

ESLint and Prettier setup

The starter kit configures ESLint and Prettier. Both configurations are stored within the package.json file and use our shared config. Feel free to change the configuration, use custom plugins, or remove both tools altogether.

Using Stale bot

The Stale bot is a Github application that automatically marks issues and PRs as stale and closes after a specific duration of inactivity.

Feel free to delete the .github/stale.yml and .github/lock.yml files if you decide not to use the Stale bot.