### Download Package Starter Kit using Giget Source: https://github.com/adonisjs/pkg-starter-kit/blob/main/README.md This command downloads the AdonisJS package starter kit repository using giget, a tool for downloading GitHub repositories without their Git history. It's a quick way to get started with a new package. ```shell npx giget@latest gh:adonisjs/pkg-starter-kit ``` -------------------------------- ### Example Test Cases with Japa (TypeScript) Source: https://context7.com/adonisjs/pkg-starter-kit/llms.txt Demonstrates how to write test cases using Japa's API within the AdonisJS package starter kit. It includes examples of grouped test cases and various assertion types provided by the assert plugin. ```typescript // tests/example.spec.ts import { test } from '@japa/runner' test.group('Example', () => { test('add two numbers', ({ assert }) => { assert.equal(1 + 1, 2) }) test('string contains substring', ({ assert }) => { assert.include('hello world', 'world') }) test('array has expected length', ({ assert }) => { const items = [1, 2, 3] assert.lengthOf(items, 3) }) }) ``` -------------------------------- ### Configure Hook for Package Setup (TypeScript) Source: https://context7.com/adonisjs/pkg-starter-kit/llms.txt Implements the configure hook, executed when `node ace configure ` is run. It uses AdonisJS codemods to publish configuration files, register providers, and define environment variables and validations. ```typescript // configure.ts import type Configure from '@adonisjs/core/commands/configure' export async function configure(command: Configure) { // Publish a config file to the user's application const codemods = await command.createCodemods() await codemods.makeUsingStub(stubsRoot, 'config/my_package.stub', { packageName: 'my-package', }) // Register the provider in adonisrc.ts await codemods.updateRcFile((rcFile) => { rcFile.addProvider('my-package/providers/main') }) // Add environment variables await codemods.defineEnvVariables({ MY_PACKAGE_KEY: '', }) await codemods.defineEnvValidations({ variables: { MY_PACKAGE_KEY: 'Env.schema.string()', }, }) } ``` -------------------------------- ### Package Entrypoint Export (TypeScript) Source: https://context7.com/adonisjs/pkg-starter-kit/llms.txt Defines the main entry point for an AdonisJS package, exporting the configure hook and stubs root path. This allows AdonisJS applications to import and utilize these functionalities when the package is installed. ```typescript // index.ts - Main package entrypoint export { configure } from './configure.ts' export { stubsRoot } from './stubs/main.ts' ``` -------------------------------- ### Stubs Root Path Export (TypeScript) Source: https://context7.com/adonisjs/pkg-starter-kit/llms.txt Exports the absolute path to the stubs directory, enabling configure hooks and scaffolding commands to locate template files. This is crucial for dynamic file generation and setup processes within AdonisJS packages. ```typescript // stubs/main.ts export const stubsRoot = import.meta.dirname // Usage in configure.ts or commands import { stubsRoot } from './stubs/main.ts' await codemods.makeUsingStub(stubsRoot, 'config/app.stub', { appName: 'MyApp', }) ``` -------------------------------- ### NPM Script Usage for Development Tasks (Bash) Source: https://context7.com/adonisjs/pkg-starter-kit/llms.txt Provides a list of common npm scripts configured within the package.json for managing the development workflow. These scripts cover linting, type checking, testing, building, and releasing the package. ```bash # Run linting with ESLint npm run lint # Run TypeScript type checking without emitting files npm run typecheck # Run tests with coverage reporting npm test # Run tests quickly without linting or coverage npm run quick:test # Build the package for publishing npm run build # Create a new release (runs checks, builds, and publishes) npm run release ``` -------------------------------- ### GitHub Actions CI/CD Workflow Source: https://context7.com/adonisjs/pkg-starter-kit/llms.txt Sets up a GitHub Actions workflow for continuous integration and delivery. This workflow runs linting and tests on push and pull requests, with matrix testing across different operating systems and Node.js versions. Releases can be triggered manually. ```yaml # .github/workflows/checks.yml - Runs on push and pull_request jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 24 - run: npm install - run: npm run lint tests: runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, windows-latest] node-version: [24] steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - run: npm install - run: npm test ``` -------------------------------- ### Create and Register a Service Provider Source: https://context7.com/adonisjs/pkg-starter-kit/llms.txt Demonstrates how to create a service provider for an AdonisJS package. Service providers are placed in the `providers` directory and registered within the package's exports to manage application bindings and lifecycle events. ```typescript // providers/main.ts import type { ApplicationService } from '@adonisjs/core/types' export default class MyPackageProvider { constructor(protected app: ApplicationService) {} async register() { // Register bindings in the container this.app.container.singleton('myPackage', async () => { const { MyPackageService } = await import('../src/my_package_service.js') return new MyPackageService() }) } async boot() { // Boot logic after all providers registered } async ready() { // Application is ready } async shutdown() { // Cleanup on shutdown } } ``` -------------------------------- ### Run Tests with Linting and Coverage Source: https://github.com/adonisjs/pkg-starter-kit/blob/main/README.md This npm script command executes ESLint for code linting, followed by running tests using the Japa test runner. It also reports test coverage using the c8 tool. This provides a comprehensive check of code quality and test execution. ```shell npm run test ``` -------------------------------- ### Package.json Configuration for AdonisJS Packages (JSON) Source: https://context7.com/adonisjs/pkg-starter-kit/llms.txt Defines essential configurations for an AdonisJS package, including name, version, module type, main entry point, and subpath exports. It also specifies files to be included in the package, peer dependencies, and npm scripts for development and release workflows. ```json { "name": "your-package-name", "version": "1.0.0", "type": "module", "main": "build/index.js", "exports": { ".": "./build/index.js", "./types": "./build/src/types.js", "./providers/main": "./build/providers/main.js" }, "files": [ "build/src", "build/providers", "build/stubs", "build/index.d.ts", "build/index.js", "build/configure.d.ts", "build/configure.js" ], "peerDependencies": { "@adonisjs/core": "^7.0.0", "@adonisjs/assembler": "^8.0.0" }, "scripts": { "typecheck": "tsc --noEmit", "lint": "eslint .", "test": "c8 npm run quick:test", "quick:test": "node --import=@poppinss/ts-exec --enable-source-maps bin/test.ts", "build": "npm run compile", "compile": "tsdown && tsc --emitDeclarationOnly --declaration", "release": "release-it" } } ``` -------------------------------- ### Configure ESLint for Packages Source: https://context7.com/adonisjs/pkg-starter-kit/llms.txt Configures ESLint for a package using the official AdonisJS ESLint preset. This ensures consistent code style and quality across the project. ```javascript // eslint.config.js import { configPkg } from '@adonisjs/eslint-config' export default configPkg() ``` -------------------------------- ### Package.json 'files' property for Publishing Source: https://github.com/adonisjs/pkg-starter-kit/blob/main/README.md The 'files' property in package.json specifies which files and folders should be included when the package is published to npm. This ensures only necessary build artifacts are distributed, not the source code. ```json { "files": ["build/src", "build/providers", "build/stubs", "build/index.d.ts", "build/index.js", "build/configure.d.ts", "build/configure.js"] } ``` -------------------------------- ### Run Tests Quickly (No Linting/Coverage) Source: https://github.com/adonisjs/pkg-starter-kit/blob/main/README.md This npm script command runs only the tests defined in the project without performing code linting or generating coverage reports. It's useful for quickly verifying test functionality during development. ```shell npm run quick:test ``` -------------------------------- ### Configure TypeScript for Packages Source: https://context7.com/adonisjs/pkg-starter-kit/llms.txt Sets up TypeScript compilation for AdonisJS packages, extending the default configuration with NodeNext module resolution. It specifies the root directory for source files and the output directory for compiled JavaScript. ```json { "extends": "@adonisjs/tsconfig/tsconfig.package.json", "compilerOptions": { "rootDir": "./", "outDir": "./build" } } ``` -------------------------------- ### Test Configuration with Japa (TypeScript) Source: https://context7.com/adonisjs/pkg-starter-kit/llms.txt Sets up the Japa test runner for AdonisJS packages. It configures the test file discovery pattern and integrates the assert plugin for writing assertions. This ensures a consistent and robust testing environment. ```typescript // bin/test.ts import { assert } from '@japa/assert' import { configure, processCLIArgs, run } from '@japa/runner' processCLIArgs(process.argv.splice(2)) configure({ files: ['tests/**/*.spec.ts'], plugins: [assert()], }) run() ``` -------------------------------- ### Package.json 'exports' for Node.js Subpath Exports Source: https://github.com/adonisjs/pkg-starter-kit/blob/main/README.md The 'exports' property in package.json defines the entry points for your package using Node.js Subpath exports. This allows you to control how different parts of your package can be imported, such as the main export and type definitions. ```json { "exports": { ".": "./build/index.js", "./types": "./build/src/types.js" } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.