### Start HTTP server with Fastify Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/run.md Starts an HTTP server using Fastify. This example defines an asynchronous function to create and prepare the Fastify app, which is then exported. The `port` can also be specified. ```typescript const createApp = async () => { const app = fastify(); await app.ready(); return app; }; const app = createApp(); export default app; ``` -------------------------------- ### Start live-reloading server with skuba start Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/run.md Starts a live-reloading server for local development using `skuba start`. The entry point can be specified via a command-line argument, `package.json#/skuba/entryPoint`, or defaults to `src/app.ts`. It also registers `tsconfig.json` paths as module aliases. ```shell skuba start src/app.ts ``` -------------------------------- ### Start Project Application Source: https://github.com/seek-oss/skuba/blob/main/template/greeter/README.md Starts the Node.js application with live-reloading. The 'start:debug' command enables the Node.js Inspector. ```shell # Start a live-reloading process pnpm start # Start with Node.js Inspector enabled pnpm start:debug ``` -------------------------------- ### Execute Skuba Build and Start Commands Source: https://github.com/seek-oss/skuba/blob/main/docs/deep-dives/babel.md Demonstrates how to use Skuba commands to build the project with Babel or start the application using Nodemon with babel-node. ```shell # uses Babel instead of tsc skuba build # uses Nodemon + babel-node instead of ts-node-dev skuba start ``` -------------------------------- ### Start HTTP server with Express Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/run.md Starts an HTTP server using Express. The entry point should export an Express app instance, optionally with a `port`. This example shows how to export the Express app with a specified port. ```typescript const app = express(); export default Object.assign(app, { port }); ``` -------------------------------- ### Start HTTP server with Koa Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/run.md Starts an HTTP server using Koa as the framework. The entry point should export a `requestListener` or `callback` function, and optionally a `port`. This example shows how to export the Koa app with a specified port. ```typescript const app = new Koa(); // You can also use `export =` syntax as required by koa-cluster. export default Object.assign(app, { port }); ``` -------------------------------- ### Install Project Dependencies with pnpm Source: https://github.com/seek-oss/skuba/blob/main/README.md Installs all project dependencies using the pnpm package manager. This is a common first step in setting up or working with a project that uses skuba. ```shell pnpm install ``` -------------------------------- ### Start HTTP server with Node.js http module Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/run.md Starts an HTTP server using Node.js's built-in `http` module. The entry point should export a `http.RequestListener` or `http.Server` instance, and optionally a `port`. This example demonstrates exporting a created HTTP server with a specified port. ```typescript const app = http.createServer(); export default Object.assign(app, { port }); ``` -------------------------------- ### Lambda function handler example Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/run.md An example of a Lambda function handler that can be exported and targeted by `skuba start`. The handler receives an event and context, and can perform asynchronous operations. ```typescript export const handler = async (event: unknown, ctx: unknown) => { // ... return; }; ``` -------------------------------- ### Start skuba Local HTTP Server Source: https://github.com/seek-oss/skuba/blob/main/template/koa-rest-api/README.md Starts a local HTTP server for the skuba project. It also provides an option to start the server with Node.js Inspector enabled for debugging. ```shell # Start a local HTTP server pnpm start # Start with Node.js Inspector enabled pnpm start:debug ``` -------------------------------- ### Configure Skuba Project Source: https://github.com/seek-oss/skuba/blob/main/template/greeter/README.md Command to configure the skuba project after initial setup. This is typically the first step after creating a new repository. ```shell pnpm exec skuba configure ``` -------------------------------- ### Run Skuba Lint Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/init.md Example command to run the 'skuba lint' command, which is suggested as a next step after project initialization. ```shell skuba lint ``` -------------------------------- ### Start Lambda function handler with skuba start Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/run.md Starts a local HTTP server to target an exported Lambda function handler using `skuba start`. The server listens on a specified port and can receive arguments via HTTP POST requests. ```shell skuba start --port 12345 src/app.ts#handler ``` -------------------------------- ### Initialize a New Project with Skuba Source: https://github.com/seek-oss/skuba/blob/main/README.md Initializes a new project using the skuba CLI. This command is recommended for starting new projects to ensure they are set up with skuba's best practices and configurations. ```shell pnpm dlx skuba init ``` -------------------------------- ### Install Dependencies (Shell) Source: https://github.com/seek-oss/skuba/blob/main/template/oss-npm-package/README.md Installs project dependencies using pnpm, which is a prerequisite for development. This command ensures all necessary packages are available for running the project. ```shell pnpm install ``` -------------------------------- ### Initialize New Project Interactively Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/init.md Demonstrates the interactive process of initializing a new project using the 'skuba init' command. It shows example prompts for project details and template selection. ```shell skuba init ``` ```shell ? For starters, some project details: ⊙ Owner : SEEK-Jobs/my-team ⊙ Repo : my-repo ⊙ Platform : arm64 ⊙ Default Branch : main # ... ? Select a template: express-rest-api ❯ greeter koa-rest-api lambda-sqs-worker-cdk oss-npm-package private-npm-package github → ? Fill this in now? … yes ❯ no Initialized empty Git repository in /my-repo/.git/ Installing dependencies... ✔ All done! Try running: cd my-repo git push --set-upstream origin main ``` -------------------------------- ### Start Local HTTP Server Source: https://github.com/seek-oss/skuba/blob/main/template/express-rest-api/README.md Starts a local HTTP server for development. It also provides an option to start the server with the Node.js Inspector enabled for debugging. ```shell # Start a local HTTP server pnpm start # Start with Node.js Inspector enabled pnpm start:debug ``` -------------------------------- ### Install Dependencies Source: https://github.com/seek-oss/skuba/blob/main/CONTRIBUTING.md Installs the necessary npm dependencies for the skuba project using pnpm. ```shell pnpm install ``` -------------------------------- ### Install Dependencies (Shell) Source: https://github.com/seek-oss/skuba/blob/main/template/private-npm-package/README.md Installs project dependencies using pnpm, which is a prerequisite for development. This command ensures all necessary packages are available for building and testing. ```shell pnpm install ``` -------------------------------- ### Configure Skuba Template Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/init.md Command to run 'skuba configure', which is used to complete or update template-specific settings after initial project setup. ```shell skuba configure ``` -------------------------------- ### Start Local HTTP Server Source: https://github.com/seek-oss/skuba/blob/main/template/lambda-sqs-worker-cdk/README.md Starts a local HTTP server to run the Lambda application. This is useful for local development and testing without deploying to AWS. ```shell pnpm start ``` -------------------------------- ### Initialize New Project Unattended with JSON Input Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/init.md Shows how to initialize a new project non-interactively by piping JSON data to the 'skuba init' command. This is useful for automated project setup. ```shell skuba init << EOF { "destinationDir": "tmp-greeter", "templateComplete": true, "templateData": { "ownerName": "my-org/my-team", "prodBuildkiteQueueName": "123456789012:cicd", "platformName": "arm64", "repoName": "tmp-greeter" }, "templateName": "greeter" } EOF ``` -------------------------------- ### Start Local HTTP Server with Node.js Inspector Source: https://github.com/seek-oss/skuba/blob/main/template/lambda-sqs-worker-cdk/README.md Starts a local HTTP server with the Node.js Inspector enabled, allowing for debugging of the Lambda application using tools like Chrome DevTools. ```shell pnpm start:debug ``` -------------------------------- ### skuba build tsconfig.build.json configuration Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/build.md Example tsconfig.build.json configuration for skuba build, excluding test files and extending the base tsconfig.json. ```jsonc { "exclude": ["**/__mocks__/**/*", "**/*.test.ts", "src/testing/**/*"], "extends": "tsconfig.json", "include": ["src/**/*"] } ``` -------------------------------- ### Clean and install dependencies with pnpm Source: https://github.com/seek-oss/skuba/blob/main/docs/deep-dives/pnpm.md Removes existing node_modules and reinstalls dependencies using pnpm. This ensures a clean installation and resolves any lingering dependencies from Yarn. ```Bash rm -rf node_modules && pnpm install ``` -------------------------------- ### Install pnpm using corepack Source: https://github.com/seek-oss/skuba/blob/main/docs/deep-dives/pnpm.md Enables and installs pnpm using corepack, a tool for managing package manager versions. This ensures the correct pnpm version is used. ```Bash corepack enable && corepack install ``` -------------------------------- ### Start Skuba Project with Debugger Enabled Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/run.md Initiates the Skuba project with the Node.js inspector enabled, allowing a debugger to attach. This is the first step in the debugging process. ```bash pnpm start:debug ``` -------------------------------- ### Configure Buildkite Cluster for ARM64 Source: https://github.com/seek-oss/skuba/blob/main/docs/deep-dives/arm64.md This snippet shows how to add a new Buildkite cluster configured for ARM64 (Graviton) instances to your CI/CD setup. It involves specifying the `cpuArchitecture` and an appropriate `instanceType` (e.g., t4g.large). ```diff schemaVersion: vCurrent clusters: - name: cicd # Existing cluster instanceType: t3.large rootVolumeSize: 8 # ... + + - name: graviton # New cluster; choose a name you like + + cpuArchitecture: arm64 + instanceType: t4g.large # Required; g is for Graviton + rootVolumeSize: 8 # Optional + + # ... ``` -------------------------------- ### Changeset Title Prefixes Source: https://github.com/seek-oss/skuba/blob/main/CONTRIBUTING.md Provides examples of how to prefix changeset titles with a scope to categorize changes. This helps in easily identifying which part of the project a change relates to. ```text test: Fix command template: Add next steps to READMEs template/koa-rest-api: Switch to Express format, lint: Introduce new ESLint rule ``` -------------------------------- ### Get Git Remote URL Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/init.md Command to retrieve the URL of the configured remote 'origin' for the Git repository. ```shell git remote get-url origin # git@github.com:/.git ``` -------------------------------- ### Configure existing project with skuba Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/configure.md The 'skuba configure' command bootstraps an existing project by guiding the user through a prompt to replace their current configuration with skuba's. It's advisable to run this command with a clean working tree to easily revert changes if needed. The command will detect and warn about any uncommitted or untracked files. ```shell skuba configure # ╭─╮ ╭─╮ # ╭───│ ╰─╭─┬─╮ ╰─╮───╮ # │_ ─┤ <│ ╵ │ • │ • │ # ╰───╰─┴─╰───╯───╯── ╰ # # 0.0.0 | latest 0.0.0 # # Detected project root: /my-repo ? Project type: … ❯ application package # ... ``` ```shell You have dirty/untracked files that may be overwritten. ``` -------------------------------- ### Lint with skuba Source: https://github.com/seek-oss/skuba/blob/main/docs/deep-dives/pnpm.md Runs the skuba linter to identify any issues after the pnpm installation. This helps ensure code quality and identifies missing dependencies. ```Bash pnpm skuba lint ``` -------------------------------- ### Create Changeset Source: https://github.com/seek-oss/skuba/blob/main/CONTRIBUTING.md Initiates the interactive Changesets CLI to create a new changeset file. This command guides the user through the process of defining the type of release (patch, minor, major) and describing the changes. ```shell pnpm changeset ``` -------------------------------- ### Log Module Name (TypeScript) Source: https://github.com/seek-oss/skuba/blob/main/template/oss-npm-package/README.md Demonstrates how to import and use the 'log' function from the skuba package to write the module name to standard output. This is a basic API usage example. ```typescript import { log } from '<%- moduleName %>'; log(); ``` -------------------------------- ### Log Module Name (TypeScript) Source: https://github.com/seek-oss/skuba/blob/main/template/private-npm-package/README.md Demonstrates how to import and use the `log` function from the skuba package to write the module name to standard output. This is a basic API usage example. ```typescript import { log } from '<%- moduleName %>'; log(); ``` -------------------------------- ### Update Buildkite Pipeline for PNPM (NPM_TOKEN Setup) Source: https://github.com/seek-oss/skuba/blob/main/docs/deep-dives/pnpm.md This snippet demonstrates the Buildkite pipeline configuration when using the GET_NPM_TOKEN environment variable. It specifies the docker-ecr-cache plugin version and the relevant files for caching. ```yaml - seek-oss/docker-ecr-cache#v2.2.1: cache-on: - pnpm-workspace.yaml - package.json#.packageManager - pnpm-lock.yaml dockerfile: Dockerfile.dev-deps secrets: - id=npm,src=/var/lib/buildkite-agent/.npmrc - NPM_TOKEN ``` -------------------------------- ### Configure skuba Project Source: https://github.com/seek-oss/skuba/blob/main/template/koa-rest-api/README.md Initializes the skuba project by running the configure command. This is a crucial first step after creating a new repository. ```shell pnpm exec skuba configure ``` -------------------------------- ### Configure skuba Project Source: https://github.com/seek-oss/skuba/blob/main/template/express-rest-api/README.md Initializes the skuba project by running the configure command. This is a crucial first step after creating a new repository. ```shell pnpm exec skuba configure ``` -------------------------------- ### Initialize Project from GitHub Template with skuba Source: https://github.com/seek-oss/skuba/blob/main/docs/templates/byo.md This command initializes a new project by cloning a template repository from GitHub. It's recommended to run 'skuba configure' after initialization to resolve any configuration inconsistencies. ```bash skuba init ``` -------------------------------- ### Run Skuba CLI Help Source: https://github.com/seek-oss/skuba/blob/main/README.md Executes the skuba command-line interface to display help information. This is useful for understanding available commands and options within the skuba toolkit. ```shell pnpm exec skuba help ``` -------------------------------- ### Wait for Socket Address Source: https://github.com/seek-oss/skuba/blob/main/docs/development-api/net.md Waits for a resource to start listening on a socket address. This can be used to wait for a Docker container to start listening on its port. ```js import { Jest } from 'skuba'; export default Jest.mergePreset({ globalSetup: '/jest.setup.int.ts', }); ``` ```typescript import { Net } from 'skuba'; export default () => Net.waitFor({ host: 'composeService', port: 5432, resolveCompose: Boolean(process.env.LOCAL), }); ``` -------------------------------- ### Initialize skuba Project for ARM64 Source: https://github.com/seek-oss/skuba/blob/main/docs/deep-dives/arm64.md This shows the command to initialize a new skuba project and the interactive prompt where you can select 'arm64' as the platform. ```shell skuba init ``` ```shell ? For starters, some project details: ⊙ Owner : SEEK-Jobs/my-team ⊙ Repo : my-repo ⊙ Platform : arm64 ⊙ Default Branch : main # ... ``` -------------------------------- ### Getter Throwing Error Example (JavaScript) Source: https://github.com/seek-oss/skuba/blob/main/docs/eslint-plugin/no-sync-in-promise-iterable.md A simple JavaScript example demonstrating how a custom getter property on an object can throw an error during property access. ```javascript const obj = { get prop() { throw new Error('Badness!'); }, }; obj.prop; // Uncaught Error: Badness! ``` -------------------------------- ### Run skuba CLI Commands Source: https://github.com/seek-oss/skuba/blob/main/CONTRIBUTING.md Demonstrates how to run various skuba CLI commands locally, including printing available commands, checking the version, and building the project. ```shell # Prints available commands. pnpm skuba # Prints version from local package.json. pnpm skuba version # Builds skuba using itself. pnpm skuba build ``` -------------------------------- ### Configure skuba Project Source: https://github.com/seek-oss/skuba/blob/main/template/lambda-sqs-worker-cdk/README.md Initializes or configures the skuba project, likely setting up project-specific configurations or templates. ```shell pnpm exec skuba configure ``` -------------------------------- ### View Git Log Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/init.md Command to display the commit history of the Git repository, showing the initial commit made by skuba. ```shell git log # Clone greeter # Initial commit ``` -------------------------------- ### Update Dockerfile for PNPM Source: https://github.com/seek-oss/skuba/blob/main/docs/deep-dives/pnpm.md This snippet shows the changes required in a Dockerfile to switch from Yarn to PNPM for dependency installation and building. It includes installing dependencies offline and for production. ```dockerfile FROM ${BASE_IMAGE} AS build COPY . . RUN pnpm install --offline RUN pnpm build RUN pnpm install --offline --prod ### FROM --platform=arm64 gcr.io/distroless/nodejs20-debian12 AS runtime WORKDIR /workdir COPY --from=build /workdir/lib lib COPY --from=build /workdir/node_modules node_modules ENV NODE_ENV=production ``` -------------------------------- ### Run Project Tests Source: https://github.com/seek-oss/skuba/blob/main/template/greeter/README.md Executes the test suite for the project using the pnpm package manager. ```shell pnpm test ``` -------------------------------- ### Push Initial Commit to Origin Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/init.md Provides the Git command to push the initial commit to the remote 'origin' repository, typically after initializing a new project. ```shell git push --set-upstream origin main ``` -------------------------------- ### Get Current Git Branch Source: https://github.com/seek-oss/skuba/blob/main/docs/development-api/git.md Retrieves the current Git branch name. It first attempts to get the branch from CI environment variables and falls back to the local Git repository if a directory is provided. ```typescript import { Git } from 'skuba'; const currentBranch = Git.currentBranch({ dir }); ``` -------------------------------- ### Update Buildkite Pipeline for PNPM (Private NPM Setup) Source: https://github.com/seek-oss/skuba/blob/main/docs/deep-dives/pnpm.md This shows how to update the Buildkite pipeline configuration when using a private NPM setup. It involves adjusting the docker-ecr-cache plugin version and cache-on paths to include PNPM-specific files. ```yaml seek-oss/private-npm#v1.3.0: env: NPM_READ_TOKEN output-path: /tmp/ ``` ```yaml seek-oss/docker-ecr-cache#v2.2.1: cache-on: - package.json#.packageManager - pnpm-lock.yaml - pnpm-workspace.yaml dockerfile: Dockerfile.dev-deps secrets: id=npm,src=/tmp/.npmrc ``` -------------------------------- ### Display skuba migrate help Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/migrate.md Shows the available migration commands and options for skuba. ```shell skuba migrate help ``` -------------------------------- ### ESLint Complexity Rule Violation Source: https://github.com/seek-oss/skuba/blob/main/docs/deep-dives/eslint.md An example of code that violates the ESLint complexity rule, showing the resulting error message. ```typescript export const evilFn = () => { if (NaN) { if (NaN) { if (NaN) { } } } }; ``` ```text Arrow function has a complexity of 4. Maximum allowed is 3. eslint(complexity) ``` -------------------------------- ### Safe Synchronous Throw Before Promise Dispatch Source: https://github.com/seek-oss/skuba/blob/main/docs/eslint-plugin/no-sync-in-promise-iterable.md Example showing that throwing a synchronous error before any promises are dispatched is safe and does not leave promises dangling. ```typescript const [y, promiseX] = [ syncY(), // It's okay to throw before we make any promises asyncX(), // Never reached, so no promise is left dangling ]; const x = await promiseX; ``` -------------------------------- ### Run Linting and Tests Source: https://github.com/seek-oss/skuba/blob/main/CONTRIBUTING.md Executes linting and unit tests locally to ensure code quality and correctness. ```shell pnpm lint pnpm test ``` -------------------------------- ### Disable ESLint Rule for Specific Line Source: https://github.com/seek-oss/skuba/blob/main/docs/deep-dives/eslint.md Provides an example of how to disable a specific ESLint rule for a single line of code using a comment. ```typescript /* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment */ const takeAnyBody = ctx.request.body; ``` -------------------------------- ### Build with esbuild Source: https://github.com/seek-oss/skuba/blob/main/docs/deep-dives/esbuild.md This command demonstrates how to trigger a build using esbuild after configuring skuba. ```shell # uses esbuild instead of tsc pnpm build ``` -------------------------------- ### Format and Lint Project Code Source: https://github.com/seek-oss/skuba/blob/main/template/greeter/README.md Commands to format the code and check for linting issues. 'pnpm format' fixes issues, while 'pnpm lint' checks for them. ```shell # Fix issues pnpm format # Check for issues pnpm lint ``` -------------------------------- ### Get GitHub Build Name Source: https://github.com/seek-oss/skuba/blob/main/docs/development-api/github.md Retrieves the build name from environment variables, used for GitHub status checks. Falls back to 'Build' if not found. ```typescript import { GitHub } from 'skuba'; const buildName = GitHub.buildNameFromEnvironment(); ``` -------------------------------- ### Add pnpm packageManager to package.json Source: https://github.com/seek-oss/skuba/blob/main/docs/deep-dives/pnpm.md Specifies the pnpm version to be used for the project. This ensures consistency across different environments and development setups. ```JSON {"packageManager": "pnpm@10.15.1"} ``` -------------------------------- ### Execute Skuba CLI Commands via Package Manager Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/index.md This snippet demonstrates how to execute the 'build' and 'format' commands, previously defined in package.json, using the pnpm package manager. This is a common way to run project-specific scripts. ```shell pnpm build pnpm format ``` -------------------------------- ### Rewrite #src/ Imports without Extensions Source: https://github.com/seek-oss/skuba/blob/main/docs/deep-dives/esm.md This snippet illustrates the change required for imports starting with `#src/`, removing the `.js` extension to align with the new import strategy. ```diff - import { module } from '#src/imported-module.js'; + import { module } from '#src/imported-module'; ``` -------------------------------- ### Build Package (Shell) Source: https://github.com/seek-oss/skuba/blob/main/template/oss-npm-package/README.md Compiles the source code into a distributable format using 'pnpm build'. This is a necessary step before packaging or publishing the library. ```shell pnpm build ``` -------------------------------- ### Deploy Application to Development Environment Source: https://github.com/seek-oss/skuba/blob/main/template/lambda-sqs-worker-cdk/README.md Deploys the application to the development environment using the `deploy` command. This process typically involves authenticating to the AWS account and executing the deployment script. ```shell DEPLOYMENT=dev pnpm run deploy ``` -------------------------------- ### Get Changed Git Files Source: https://github.com/seek-oss/skuba/blob/main/docs/development-api/git.md Returns a list of all files that have been added, modified, or deleted in the local Git repository's working directory since the last commit. ```typescript import { Git } from 'skuba'; const changedFiles = await Git.getChangedFiles({ dir }); ``` -------------------------------- ### Configure npm package for Node.js LTS compatibility Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/migrate.md Example of how to configure the 'engines' and 'tsconfig.json' for an npm package to ensure compatibility with specific Node.js versions, particularly when supporting older runtimes. ```json { "engines": { "node": ">=22" } } ``` ```typescript { "compilerOptions": { "removeComments": false, "target": "ES2023" }, "extends": "../../tsconfig.json" } ``` -------------------------------- ### Enable Buildkite Annotations with Docker Plugin Source: https://github.com/seek-oss/skuba/blob/main/docs/deep-dives/buildkite.md This YAML configuration demonstrates how to enable Buildkite annotations by mounting the Buildkite agent and propagating environment variables using the Docker Buildkite plugin. ```yaml steps: - command: pnpm lint plugins: - ... - docker#v5.13.0: # Enable GitHub integrations. environment: - GITHUB_API_TOKEN mount-buildkite-agent: true propagate-environment: true volumes: # Mount cached dependencies. - /workdir/node_modules ``` -------------------------------- ### Get Head Commit Message Source: https://github.com/seek-oss/skuba/blob/main/docs/development-api/git.md Retrieves the message of the head commit. It attempts to extract the message from CI environment variables and falls back to the local Git repository log. ```typescript import { Git } from 'skuba'; const headCommitMessage = await Git.getHeadCommitMessage({ dir }); ``` -------------------------------- ### Add hoisting settings for Serverless in pnpm-workspace.yaml Source: https://github.com/seek-oss/skuba/blob/main/docs/deep-dives/pnpm.md Adds specific hoisting configurations required for Serverless projects to the `pnpm-workspace.yaml` file. This ensures that necessary dependencies are available during Serverless deployment. ```Diff # managed by skuba packageManagerStrictVersion: true publicHoistPattern: - '@types*' - '*eslint*' - '*prettier*' - esbuild - jest - tsconfig-seek # end managed by skuba + + # Required for Serverless packaging + nodeLinker: hoisted + shamefullyHoist: true ``` -------------------------------- ### Run Project Tests Source: https://github.com/seek-oss/skuba/blob/main/template/express-rest-api/README.md Executes the test suite for the project using the pnpm test command. This ensures the code behaves as expected. ```shell pnpm test ``` -------------------------------- ### Detect Synchronous Logic in Promise.allSettled Source: https://github.com/seek-oss/skuba/blob/main/docs/eslint-plugin/no-sync-in-promise-iterable.md Example demonstrating how synchronous logic within Promise.allSettled can lead to unhandled promise rejections. It highlights that syncY() might throw an error, leaving preceding promises dangling. ```typescript const [x, y] = await Promise.allSettled([asyncX(), syncY()]); // ~~~~~~~~ syncY() may synchronously throw an error and leave preceding promises dangling. // Evaluate synchronous expressions outside of the iterable argument to Promise.allSettled, // or safely wrap with the async keyword, Promise.try(), or Promise.resolve().then(). ``` -------------------------------- ### Format with skuba Source: https://github.com/seek-oss/skuba/blob/main/docs/deep-dives/pnpm.md Synthesizes managed hoist patterns into `pnpm-workspace.yaml` using skuba. This ensures consistent dependency hoisting configuration. ```Bash pnpm skuba format ``` -------------------------------- ### Bundle assets with skuba Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/build.md Configuration in package.json to bundle additional assets alongside your build. The 'assets' field specifies glob patterns for files to be copied. ```json { "skuba": { "entryPoint": "src/index.ts", "template": "koa-rest-api", "type": "application", "version": "8.1.0", "assets": ["**/*.vocab/*translations.json"] } } ``` -------------------------------- ### Run Tests (Shell) Source: https://github.com/seek-oss/skuba/blob/main/template/oss-npm-package/README.md Executes the project's test suite using pnpm. This command is crucial for verifying the functionality and stability of the package. ```shell pnpm test ``` -------------------------------- ### Create pnpm-workspace.yaml for workspaces Source: https://github.com/seek-oss/skuba/blob/main/docs/deep-dives/pnpm.md Configures pnpm workspaces by defining the packages included in the monorepo. This allows pnpm to optimize dependency resolution and linking. ```YAML packages: # all packages in direct subdirectories of packages/ - 'packages/*' ``` -------------------------------- ### Debugging with Node.js inspect options Source: https://github.com/seek-oss/skuba/blob/main/docs/cli/run.md Supports Node.js `--inspect` and `--inspect-brk` options for debugging sessions. VS Code's built-in debug terminal can automatically attach to processes started with these options. ```shell # Example of running a command with inspect options skuba start --inspect src/app.ts ``` -------------------------------- ### Get Head Commit ID Source: https://github.com/seek-oss/skuba/blob/main/docs/development-api/git.md Retrieves the object ID of the head commit. It prioritizes extracting the commit ID from common CI environment variables and falls back to the local Git repository log. ```typescript import { Git } from 'skuba'; const headCommitId = await Git.getHeadCommitId({ dir }); ``` -------------------------------- ### Run skuba Tests Source: https://github.com/seek-oss/skuba/blob/main/template/koa-rest-api/README.md Executes the test suite for the skuba project using the pnpm test command. This ensures the project's functionality meets the expected standards. ```shell pnpm test ``` -------------------------------- ### Build Project (Shell) Source: https://github.com/seek-oss/skuba/blob/main/template/private-npm-package/README.md Compiles the source code of the skuba package. This is typically done before packaging or deployment. ```shell pnpm build ``` -------------------------------- ### Replace Yarn commands with PNPM in Buildkite Source: https://github.com/seek-oss/skuba/blob/main/docs/deep-dives/pnpm.md This shows the necessary changes within a Buildkite pipeline's commands section to replace Yarn commands with PNPM commands for tasks like installation, testing, and linting. ```yaml label: 🧪 Test & Lint commands: - echo '--- pnpm install --offline' - pnpm install --offline - echo '+++ pnpm test:ci' - pnpm test:ci - echo '--- pnpm lint' - pnpm lint ```