### Create a oneRepo workspace with `one create` Source: https://onerepo.tools/ Initialize a new or existing repository as a oneRepo workspace. Run this command after installing the CLI; it will guide you through the setup process. ```bash one create ``` -------------------------------- ### one install command usage Source: https://onerepo.tools/core/install Shows the basic usage of the `one install` command. Run this to install the oneRepo CLI globally. ```bash one install [options...] ``` -------------------------------- ### Install oneRepo CLI with npm, yarn, pnpm, or mise Source: https://onerepo.tools/ Install the oneRepo CLI using your preferred package manager. The npm, yarn, and pnpm commands install the `one` command into your path, while the mise command uses the mise-en-place tool to install the npm package `onerepo`. ```bash npm exec one install ``` ```bash yarn one install ``` ```bash pnpm one install ``` ```bash mise use npm:onerepo ``` -------------------------------- ### Install with pnpm Source: https://onerepo.tools/plugins/jest Install the plugin as a dev dependency using pnpm. ```bash pnpm install --save-dev @onerepo/plugin-jest ``` -------------------------------- ### one build examples Source: https://onerepo.tools/plugins/docgen/example Examples of building all workspaces, a single workspace, and multiple workspaces. ```bash one build ``` ```bash one build -w graph ``` ```bash one build -w graph cli logger ``` -------------------------------- ### Install with yarn Source: https://onerepo.tools/plugins/jest Install the plugin as a dev dependency using yarn. ```bash yarn add --dev @onerepo/plugin-jest ``` -------------------------------- ### Install with npm Source: https://onerepo.tools/plugins/jest Install the plugin as a dev dependency using npm. ```bash npm install --save-dev @onerepo/plugin-jest ``` -------------------------------- ### Install @onerepo/plugin-prettier with npm, yarn, or pnpm Source: https://onerepo.tools/plugins/prettier Install the @onerepo/plugin-prettier package using npm, yarn, or pnpm. These commands are shown as separate installation options in the documentation. ```bash npm install --save-dev @onerepo/plugin-prettier ``` ```bash yarn add --dev @onerepo/plugin-prettier ``` ```bash pnpm install --save-dev @onerepo/plugin-prettier ``` -------------------------------- ### Install @onerepo/plugin-eslint with npm, yarn, or pnpm Source: https://onerepo.tools/plugins/eslint Install the plugin as a dev dependency using your preferred package manager. These are alternative commands for the same installation step. ```bash npm install --save-dev @onerepo/plugin-eslint ``` ```bash yarn add --dev @onerepo/plugin-eslint ``` ```bash pnpm install --save-dev @onerepo/plugin-eslint ``` -------------------------------- ### Start documentation application Source: https://onerepo.tools/project/contributing Run the documentation application locally. This command starts the docs dev server, which is required for proper formatting and linting of documentation changes. ```bash one workspace docs start ``` -------------------------------- ### Configure workspaces (npm, yarn, pnpm) Source: https://onerepo.tools/docs/getting-started Configure workspaces for npm, yarn, and pnpm. The JSON examples are for npm/yarn, the YAML example is for pnpm. ```json { "name": "my-monorepo", "private": true, "workspaces": ["apps/*", "modules/*"] } ``` ```json { "name": "my-monorepo", "private": true, "workspaces": ["apps/*", "modules/*"] } ``` ```yaml packages: - 'apps/*' - 'modules/*' ``` -------------------------------- ### Full configuration example for docgen() Source: https://onerepo.tools/plugins/docgen Shows a full configuration with format, outFile, and safeWrite options. ```typescript import { docgen } from '@onerepo/plugin-docgen'; export default { plugins: [ docgen({ format: 'markdown', outFile: './docs/cli.md', safeWrite: true, }), ], }; ``` -------------------------------- ### Workspace package.json files with dependencies Source: https://onerepo.tools/concepts/primer Example `package.json` files for three workspaces (`menu`, `burritos`, and `tacos`) that depend on `lettuce` and `tortillas`. The `menu` workspace uses the `workspace:` protocol to reference local packages, while `burritos` and `tacos` use semver ranges. The version mismatches for `tortillas` require the package manager to install separate versions, while `lettuce` can be deduplicated to `4.4.3`. ```json { "name": "menu", "dependencies": { "tacos": "workspace:^", "tortillas": "workspace:^" } } ``` ```json { "name": "burritos", "dependencies": { "lettuce": "^4.4.3", "tortillas": "^2.0.0" } } ``` ```json { "name": "tacos", "dependencies": { "lettuce": "^4.0.0", "tortillas": "^1.8.0" } } ``` -------------------------------- ### Install @onerepo/plugin-docgen with npm Source: https://onerepo.tools/plugins/docgen Install the plugin as a dev dependency using npm. ```bash npm install --save-dev @onerepo/plugin-docgen ``` -------------------------------- ### from property Source: https://onerepo.tools/api/onerepo/namespaces/git Git ref for start (exclusive) to get list of modified files. ```typescript optional from: string; ``` -------------------------------- ### Install @onerepo/plugin-docgen with pnpm Source: https://onerepo.tools/plugins/docgen Install the plugin as a dev dependency using pnpm. ```bash pnpm install --save-dev @onerepo/plugin-docgen ``` -------------------------------- ### Basic plugin setup with docgen() Source: https://onerepo.tools/plugins/docgen Import and include the docgen plugin in your oneRepo plugin setup. ```typescript import { docgen } from '@onerepo/plugin-docgen'; export default { plugins: [docgen()], }; ``` -------------------------------- ### Install oneRepo CLI globally with npx Source: https://onerepo.tools/core/create Run this command to install global access to your oneRepo CLI, allowing you to invoke it by name from anywhere in your repository. The command uses npx to fetch the latest onerepo package and execute the 'one create' subcommand. ```bash npx --package=onerepo@latest one create ``` -------------------------------- ### Install @onerepo/plugin-docgen with yarn Source: https://onerepo.tools/plugins/docgen Install the plugin as a dev dependency using yarn. ```bash yarn add --dev @onerepo/plugin-docgen ``` -------------------------------- ### Install @onerepo/plugin-typescript Source: https://onerepo.tools/plugins/typescript Install the plugin with your preferred package manager. These commands are alternatives; choose one based on your package manager. ```bash npm install --save-dev @onerepo/plugin-typescript ``` ```bash yarn add --dev @onerepo/plugin-typescript ``` ```bash pnpm install --save-dev @onerepo/plugin-typescript ``` -------------------------------- ### Basic plugin setup with performanceWriter Source: https://onerepo.tools/plugins/performance-writer Include the performanceWriter plugin in your oneRepo plugin setup with no options. ```typescript import { performanceWriter } from '@onerepo/plugin-performance-writer'; export default { plugins: [performanceWriter()], }; ``` -------------------------------- ### Basic plugin setup with typescript() Source: https://onerepo.tools/plugins/typescript Include the typescript plugin in your oneRepo plugin setup. This is the basic usage without options. ```typescript import { typescript } from '@onerepo/plugin-typescript'; export default { plugins: [typescript()], }; ``` -------------------------------- ### Install @onerepo/test-cli Source: https://onerepo.tools/docs/commands Install the @onerepo/test-cli package as a development dependency to enable functional testing of custom commands. ```bash npm install --save-dev @onerepo/test-cli ``` -------------------------------- ### Prompt output for module template Source: https://onerepo.tools/core/generate Example interactive prompt sequence when generating a module. Shows the template selection, name input with prefix, and description input. ```text ? Choose a template… App ❯ Module - A shared, publishable workspace ? What is the name of the module? @scope/ ▓ ? Please anter a description for the module ▓ ``` -------------------------------- ### Create root configuration file (ESM, TypeScript, CommonJS) Source: https://onerepo.tools/docs/getting-started Create a root configuration file in JavaScript or TypeScript. These examples show the minimal configuration with `root: true`. ```javascript export default { root: true, }; ``` ```typescript import type { Config } from 'onerepo'; export default { root: true, } satisfies Config; ``` ```javascript module.exports = { root: true, }; ``` -------------------------------- ### one dependencies add production and dev dependencies Source: https://onerepo.tools/core/dependencies Install `react` as a production dependency and `babel-core` as a development dependency in both `workspace-a` and `workspace-b`. ```bash one dependencies add -w workspace-a workspace-b -d babel-core -p react ``` -------------------------------- ### Install onerepo dev dependency (npm, yarn, pnpm) Source: https://onerepo.tools/docs/getting-started Install the onerepo package as a dev dependency using npm, yarn, or pnpm. This is the first step in manually integrating oneRepo. ```bash npm install --save-dev onerepo ``` ```bash yarn add --dev onerepo ``` ```bash pnpm add --save-dev onerepo ``` -------------------------------- ### Run custom workspace commands Source: https://onerepo.tools/core/workspace Examples of running custom commands defined in a workspace's `commands` directory using the `one workspace` command. ```bash # Run the `start` command one workspace public-app start # Run the `build` command one workspace public-app build ``` ```bash one workspace private-app build # ↑ Equivalent to ↓ one ws private-app build ``` -------------------------------- ### write() usage example Source: https://onerepo.tools/api/onerepo/namespaces/file Writes '# hello!' to the file at '/path/to/out/'. ```typescript await file.write('/path/to/out/', '# hello!'); ``` -------------------------------- ### Default plugin configuration Source: https://onerepo.tools/plugins/jest Example of configuring the jest plugin with optional configuration. ```javascript export default { plugins: [ jest({ // optional configuration }), ], }; ``` -------------------------------- ### Run passthrough commands Source: https://onerepo.tools/core/workspace Examples of running passthrough commands using the `one workspace` command and its alias. ```bash one workspace public-app start # ↑ Equivalent to ↓ one ws public-app start ``` ```bash one workspace public-app build # ↑ Equivalent to ↓ one ws public-app build ``` -------------------------------- ### Configure prettier plugin with useCache Source: https://onerepo.tools/plugins/prettier Example configuration that enables the useCache option for the prettier plugin. ```typescript export default { plugins: [ prettier({ useCache: true, }), ], }; ``` -------------------------------- ### Template selection prompt output Source: https://onerepo.tools/core/generate Example interactive prompt shown when running `one generate` with multiple templates. The user selects a template from a list. ```text ? Choose a template… app ❯ module ``` -------------------------------- ### Plugin setup with custom output path Source: https://onerepo.tools/plugins/performance-writer Include the performanceWriter plugin with an output option specifying a custom filepath. ```typescript import { performanceWriter } from '@onerepo/plugin-performance-writer'; export default { plugins: [ performanceWriter({ output: '/tmp/onerepo-perf-out', }), ], }; ``` -------------------------------- ### one change publish with all option Source: https://onerepo.tools/core/changes Attempts to publish all non-private Workspaces. This is an example of using the `--all` option with the `one change publish` command. ```text one change publish --all ``` -------------------------------- ### Configure vitest plugin with multiple names Source: https://onerepo.tools/plugins/vitest Example of renaming the default command to avoid conflicts, using an array of names. ```typescript export default { plugins: [ vitest({ name: ['test', 'vitest'] }), ], }; ``` -------------------------------- ### Configure vitest plugin with config option Source: https://onerepo.tools/plugins/vitest Example of specifying a custom config file path relative to the repository root. ```typescript export default { plugins: [ vitest({ config: 'configs/vitest.config.js' }), ], }; ``` -------------------------------- ### signContents() usage example Source: https://onerepo.tools/api/onerepo/namespaces/file Reads a file, generates new contents, and compares the current contents with the signed new contents to detect mismatches. ```typescript const filename = graph.root.resolve('README.md'); const currentContents = await file.read(filename); const newContents = generateReadme(); if (currentContents !== (await signContents(filename, contents))) { logger.error('Contents mismatch'); } ``` -------------------------------- ### Run `one --help` and view CLI commands Source: https://onerepo.tools/docs/getting-started After setup, change into the monorepo root and run `one --help` to see available commands. The output lists core commands like `tasks`, `hooks`, `graph`, and `generate`. ```bash cd my-monorepo one --help ``` ```text one [options] one workspace [options] Commands: one tasks Run tasks against repo-defined lifecycles. This command will limit the tasks across the affected workspace set based on the current state of the repository. one hooks Manage git repository hooks one graph Run core Graph commands one generate Generate files, folders, and workspaces from templates. [aliases: gen] # … ``` -------------------------------- ### one change publish with workspace option Source: https://onerepo.tools/core/changes Publishes the `api` Workspace and its dependencies, if necessary. This is an example of using the `--workspaces` option with the `one change publish` command. ```text one change publish -w api ``` -------------------------------- ### oneRepo grouped output example Source: https://onerepo.tools/concepts/why-onerepo Shows how oneRepo groups output by individual task, displaying only the most recent or important information by default, and never interweaving output between tasks. ```text ┌ Run tests for @internal-tests/todo-list-cli └ ✔ 3s ┌ Run tests for @internal-kit/ts │ Progress: 421, reused 402, downloaded 1, added 0 └ ⠙ ``` -------------------------------- ### Configure onerepo.config.ts (ESM, TypeScript, CommonJS) Source: https://onerepo.tools/docs/getting-started Example root configuration file `./onerepo.config.ts` in ES Module, TypeScript, and Common JS formats. Modify these settings for your repo's needs. ```javascript export default { root: true, codeowners: {}, tasks: {}, // And much more! }; ``` ```typescript import type { Config } from 'onerepo'; export default { root: true, codeowners: {}, tasks: {}, // And much more! } satisfies Config; ``` ```javascript module.exports = { root: true, codeowners: {}, tasks: {}, // And much more! }; ``` -------------------------------- ### Create recommended hooks Source: https://onerepo.tools/core/hooks Run `one hooks create` to create the recommended git hooks. Hooks are created in the `vcs.hooksPath` config (`./.hooks` by default). ```bash one hooks create ``` -------------------------------- ### Run basic oneRepo command with issue and description Source: https://onerepo.tools/docs/commands Running the basic command with `--issue` and `--description` shows the TODO log line and a successful completion. The username is taken from the OS (here `brendaneich`). ```shell $ one new-branch --issue 123 --description "my issue description" INFO TODO: create new branch for brendaneich with issue #123 and description "my issue description" ■ ✔ Completed 48ms ``` -------------------------------- ### withWorkspaces usage example Source: https://onerepo.tools/api/onerepo/namespaces/builders Example of using builders.withWorkspaces in a yargs builder function. ```typescript export const builder = (yargs) => builders.withWorkspaces(yargs); ``` -------------------------------- ### withFiles usage example Source: https://onerepo.tools/api/onerepo/namespaces/builders Example of using builders.withFiles in a yargs builder function. ```typescript export const builder = (yargs) => builders.withFiles(yargs); ``` -------------------------------- ### withAllInputs usage example Source: https://onerepo.tools/api/onerepo/namespaces/builders Example of using builders.withAllInputs in a yargs builder function. ```typescript export const builder = (yargs) => builders.withAllInputs(yargs); ``` -------------------------------- ### withAffected usage example Source: https://onerepo.tools/api/onerepo/namespaces/builders Example of using builders.withAffected in a yargs builder function. ```typescript export const builder = (yargs) => builders.withAffected(yargs); ``` -------------------------------- ### one build usage Source: https://onerepo.tools/plugins/docgen/example Shows the syntax for the `one build` command. ```bash one build [options...] ``` -------------------------------- ### one change show command usage Source: https://onerepo.tools/core/changes Previews the next versions and changelogs for Workspaces. The `--format` option can be set to `'json'` or `'plain'` (default `'plain'`) to choose the output format. ```text one change show ``` -------------------------------- ### package.json with source entry point Source: https://onerepo.tools/docs/source-dependencies Configure a workspace's package.json to point main to the uncompiled source file (./src/index.ts) to enable source-level dependencies without pre-compilation. ```json { "name": "my-module", "type": "module", "main": "./src/index.ts" } ``` -------------------------------- ### Run first shard of pre-merge lifecycle Source: https://onerepo.tools/core/tasks Shard all tasks for the pre-merge lifecycle into 5 groups and run the first shard. ```bash one tasks --lifecycle=pre-merge --shard=1/5 ``` -------------------------------- ### Include vitest plugin in oneRepo setup Source: https://onerepo.tools/plugins/vitest Import and include the vitest plugin in your oneRepo plugin setup. ```typescript import { vitest } from '@onerepo/plugin-vitest'; export default { plugins: [vitest()], }; ``` -------------------------------- ### Initialize git hooks with one hooks init Source: https://onerepo.tools/plugins/docgen/example Initialize and sync git hook settings for this repository. Alias: one hooks sync. ```bash one hooks init ``` -------------------------------- ### Include jest plugin in oneRepo setup Source: https://onerepo.tools/plugins/jest Import and include the jest plugin in your oneRepo plugin setup. ```javascript import { jest } from '@onerepo/plugin-jest'; export default { plugins: [jest()], }; ``` -------------------------------- ### Include prettier plugin in oneRepo setup Source: https://onerepo.tools/plugins/prettier Include the prettier plugin in your oneRepo plugin setup by importing and adding it to the plugins array. ```typescript import { prettier } from '@onerepo/plugin-prettier'; export default { plugins: [prettier()], }; ``` -------------------------------- ### mkdirp(pathname, options?) Source: https://onerepo.tools/api/onerepo/namespaces/file Recursively creates a directory. ```APIDOC ## mkdirp(pathname, options?) ### Description Recursively create a directory. ### Signature ```typescript function mkdirp(pathname: string, options?: Options): Promise; ``` ### Parameters - **pathname** (string) - Required - The path to create. - **options** (Options) - Optional - Additional options. ### Returns `Promise` ### Example ```typescript await file.mkdirp('/path/to/something'); ``` ``` -------------------------------- ### one workspace github-action build all Source: https://onerepo.tools/plugins/docgen/example Build all Workspaces using the `one workspace github-action build` command. ```text one workspace github-action build ``` -------------------------------- ### writeSafe(filename, contents, options?) Source: https://onerepo.tools/api/onerepo/namespaces/file Safely writes contents to a file, wrapped in a start and end sentinel. This allows writing to a file without overwriting the current content of the file – other than that which falls between the start and end sentinel. ```APIDOC ## writeSafe(filename, contents, options?) ### Description Safely writes contents to a file, wrapped in a start and end sentinel. This allows writing to a file without overwriting the current content of the file – other than that which falls between the start and end sentinel. ### Method writeSafe ### Endpoint writeSafe(filename, contents, options?) ### Parameters - **filename** (string) - Required - The path to the file to write. - **contents** (string) - Required - The contents to write. - **options?** (WriteSafeOptions) - Optional - Additional options for safe writing, such as `sentinel` or `signed`. ### Returns `Promise` ### Examples ```typescript await file.writeSafe('/path/to/out/', '# hello', { sentinel: 'some-unique-string' }); ``` ```typescript await file.writeSafe('/path/to/out/', '# hello', { signed: true }); ``` ``` -------------------------------- ### package.json with 43 Cypress scripts Source: https://onerepo.tools/concepts/why-onerepo A real-world example of a package.json file with 43 scripts for running Cypress tests, illustrating script overload. The scripts are undocumented and many are nearly identical, leading to confusion and inefficiency. ```json { "scripts": { "cy:install": "cypress install", "cy:cli": "cypress run", "cy:ui": "cypress open", 37 collapsed lines "cy:local:cli": "cypress run", "cy:local:cli:desktop": "cypress run --config viewportWidth=1440,viewportHeight=900", "cy:local:cli:mobile": "cypress run", "cy:local:cli:tablet": "cypress run --config viewportWidth=1024,viewportHeight=768", "cy:local:ui": "cypress open", "cy:local:ui:desktop": "cypress open --config viewportWidth=1440,viewportHeight=900", "cy:local:ui:mobile": "cypress open", "cy:local:ui:tablet": "cypress open --config viewportWidth=1024,viewportHeight=768", "cy:test:cli": "cypress run --config baseUrl=https://test.example.com/", "cy:test:cli:desktop": "cypress run --config baseUrl=https://test.example.com,viewportWidth=1440,viewportHeight=900", "cy:test:cli:mobile": "cypress run --config baseUrl=https://test.example.com/", "cy:test:cli:tablet": "cypress run --config baseUrl=https://test.example.com,viewportWidth=1024,viewportHeight=768", "cy:test:ui": "cypress open --config baseUrl=https://test.example.com/", "cy:tacos:ui": "cypress open --config baseUrl=https://tacos.test.example.com/", "cy:test:ui:desktop": "cypress open --config baseUrl=https://test.example.com,viewportWidth=1440,viewportHeight=900", "cy:test:ui:mobile": "cypress open --config baseUrl=https://test.example.com/", "cy:test:ui:tablet": "cypress open --config baseUrl=https://test.example.com,viewportWidth=1024,viewportHeight=768", "cy:cache:list": "npx cypress cache list", "cy:ci": "CI=true npx start-server-and-test http-get://localhost:3000 cy:percy:record", "cy:info": "npx cypress info", "cy:open": "npx cypress open", "cy:open:local": "npx cypress open --config baseUrl=http://localhost:3001/", "cy:open:local:mobile": "npx cypress open --config baseUrl=http://localhost:3001/,viewportWidth=375,viewportHeight=667", "cy:open:test": "npx cypress open --config baseUrl=https://test.example.com/", "cy:open:test:mobile": "npx cypress open --config baseUrl=https://test.example.com/,viewportWidth=375,viewportHeight=667", "cy:test:open:desktop": "cypress open --config baseUrl=https://test.example.com,viewportWidth=1440,viewportHeight=900", "cy:test:open:tablet": "cypress open --config baseUrl=https://test.example.com,viewportWidth=1024,viewportHeight=768", "cy:percy:local": "npx percy exec -- cypress open --config baseUrl=http://localhost:3000/", "cy:percy:test": "npx percy exec -- cypress open --config baseUrl=https://test.example.com/", "cy:percy:record": "npx percy exec -- cypress run --record --spec 'cypress/e2e/**.spec.js'", "cy:record:local": "npx cypress run --record --config baseUrl=http://localhost:3000/ --spec 'cypress/e2e/**.spec.js'", "cy:run": "npx cypress run --record false --spec 'cypress/e2e/**.spec.js'", "cy:run:local": "npx cypress run --config baseUrl=http://localhost:3001/ --record false --spec 'cypress/e2e/**.spec.js'", "cy:test:run:desktop": "cypress run --config baseUrl=https://test.example.com,viewportWidth=1440,viewportHeight=900", "cy:test:run:tablet": "cypress run --config baseUrl=https://test.example.com,viewportWidth=1024,viewportHeight=768", "cy:verify": "npx cypress verify", "cy:version": "npx cypress version", "cy:register": "npx cypress run --record --key 3a8de5fe-003c-431b-9685-385178dd5069 --group registration --spec cypress/e2e/registration.spec.js", "cy:login": "npx cypress run --record --key 3a8de5fe-003c-431b-9685-385178dd5069 --group submit-app --spec cypress/e2e/login.spec.js", "cy:workflow": "npx cypress run --record --key 3a8de5fe-003c-431b-9685-385178dd5069" } } ``` -------------------------------- ### staged property (true) Source: https://onerepo.tools/api/onerepo/namespaces/git Get staged modified files only. ```typescript staged: true; ``` -------------------------------- ### Task chaining example for building ESM, CJS, and TypeScript definitions Source: https://onerepo.tools/concepts/why-onerepo Shows a tasks configuration with separate build tasks for ESM, CJS, and TypeScript definitions, each with their own inputs and outputs. A final 'build' task depends on all three. This approach can become complex as repositories grow. ```yaml tasks: build-esm: command: esbuild --format=esm 6 collapsed lines inputs: - ./src/**/* outputs: - ./dist/esm options: runInCI: false build-cjs: command: esbuild --format=cjs 6 collapsed lines inputs: - ./src/**/* outputs: - ./dist/cjs options: runInCI: false build-tsdefs: command: tsc -b tsconfig.json --emitDeclarationOnly 6 collapsed lines inputs: - ./src/**/* outputs: - ./dist/src options: runInCI: false build: deps: - build-esm - build-cjs - build-tsdefs ``` -------------------------------- ### Recommended tasks Source: https://onerepo.tools/plugins/eslint Recommended task configurations for running ESLint in pre-commit and pre-merge hooks, including ordering with Prettier. ```APIDOC ## Recommended tasks ### Description Recommended task configurations for running ESLint in pre-commit and pre-merge hooks. ### Example: Basic ```typescript import type { Config } from 'onerepo'; export default { tasks: { 'pre-commit': { serial: ['$0 eslint --add'], }, 'pre-merge': { serial: ['$0 eslint --all --no-fix'], }, }, } satisfies Config; ``` ### Example: With Prettier If you’re also running Prettier, it is important to run ESLint _before_ Prettier. Do this by creating sequential tasks: an array of tasks within the `serial` tasks array: ```typescript import type { Config } from 'onerepo'; export default { tasks: { 'pre-commit': { serial: [['$0 eslint --add', '$0 prettier --add']], }, 'pre-merge': { serial: [['$0 eslint --all --no-fix', '$0 prettier --check']], }, }, } satisfies Config; ``` ``` -------------------------------- ### getCurrentSha() Source: https://onerepo.tools/api/onerepo/namespaces/git Gets the current SHA ref, equivalent to `git rev-parse HEAD`. ```APIDOC ## getCurrentSha() ### Description Get the current sha ref. This is equivalent to `git rev-parse HEAD`. ### Method getCurrentSha ### Signature ```typescript function getCurrentSha(options?): Promise; ``` ### Parameters - **options?** (`Options`) - Optional - Options for the operation. ### Returns `Promise` ### Example ```typescript const sha = await git.getCurrentSha(); ``` ``` -------------------------------- ### ModifiedStaged type Source: https://onerepo.tools/api/onerepo/namespaces/git Options for getting staged modified files only. Disallows from and through refs. ```typescript type ModifiedStaged = ModifiedBaseOptions & { from?: never; staged: true; through?: never; }; ``` -------------------------------- ### Show Workspace Graph with options Source: https://onerepo.tools/core/graph Show the repository's Workspace Graph using an online visualizer or output Graph representations to various formats. By default, a URL is given to visualize the Graph online. ```bash one graph show [options...] ``` -------------------------------- ### through property Source: https://onerepo.tools/api/onerepo/namespaces/git Git ref for end (inclusive) to get list of modified files. ```typescript optional through: string; ``` -------------------------------- ### remove() usage example Source: https://onerepo.tools/api/onerepo/namespaces/file Calls remove to delete a file or folder at the given path. ```typescript await file.remove('/path/to/something'); ``` -------------------------------- ### sentinel property declaration Source: https://onerepo.tools/api/onerepo/namespaces/file Optional string to use as a start and end sentinel for the contents. ```typescript optional sentinel: string; ``` -------------------------------- ### Recommended tasks for pre-commit and pre-merge Source: https://onerepo.tools/plugins/eslint Recommended task configuration that runs ESLint with `--add` for pre-commit and `--all --no-fix` for pre-merge. ```typescript import type { Config } from 'onerepo'; export default { tasks: { 'pre-commit': { serial: ['$0 eslint --add'], }, 'pre-merge': { serial: ['$0 eslint --all --no-fix'], }, }, } satisfies Config; ``` -------------------------------- ### makeTempDir(prefix, options?) Source: https://onerepo.tools/api/onerepo/namespaces/file Creates a temporary directory in the OS tmpdir. ```APIDOC ## makeTempDir(prefix, options?) ### Description Create a tmp directory in the os tmpdir. ### Signature ```typescript function makeTempDir(prefix: string, options?: Options): Promise; ``` ### Parameters - **prefix** (string) - Required - The prefix for the temporary directory name. - **options** (Options) - Optional - Additional options. ### Returns `Promise` ### Example ```typescript const dir = await file.makeTempDir('tacos-'); ``` ``` -------------------------------- ### Configure vitest plugin with name option Source: https://onerepo.tools/plugins/vitest Example of configuring the vitest plugin with a name option. ```typescript export default { plugins: [ vitest({ name: ['test'], }), ], }; ``` -------------------------------- ### Basic oneRepo command using os.userInfo() Source: https://onerepo.tools/docs/commands Basic oneRepo command that gets the OS username via `os.userInfo()` and logs a TODO message. Requires the `description` option (demandOption) and optional `issue`; the handler receives `logger` from oneRepo's context. ```typescript import { userInfo } from 'node:os'; 23 collapsed lines import type { Builder, Handler } from 'onerepo'; export const command = 'new-branch'; export const description = 'A basic command that shows the minimum requirements for writing commands with oneRepo'; type Args = { issue?: number; description: string; }; export const builder: Builder = (yargs) => yargs .usage(`$0 ${command}`) .option('issue', { type: 'number', description: 'The GitHub issue number for this change.', }) .option('description', { type: 'string', description: 'A short and concise description of the work.', demandOption: true, }); export const handler: Handler = async (argv, { logger }) => { const { issue, description } = argv; const { username } = userInfo(); logger.info( `TODO: create new branch for ${username} with issue #${issue} and description "${description}"`, ); }; ``` -------------------------------- ### WithAllInputs usage with Argv Source: https://onerepo.tools/api/onerepo/namespaces/builders Example of using builders.WithAllInputs in a custom Argv type and builder function. ```typescript type Argv = builders.WithAllInputs & { // ... }; export const builder: Builder = (yargs) => builders.withAllInputs(yargs); ``` -------------------------------- ### WithAffected usage with Argv Source: https://onerepo.tools/api/onerepo/namespaces/builders Example of using builders.WithAffected in a custom Argv type and builder function. ```typescript type Argv = builders.WithAffected & { // ... }; export const builder: Builder = (yargs) => builders.withAffected(yargs); ```