{"id":16299717,"url":"https://github.com/hongaar/moker","last_synced_at":"2025-03-16T13:31:47.148Z","repository":{"id":40728096,"uuid":"240125121","full_name":"hongaar/moker","owner":"hongaar","description":"👢 Kick-start JS projects, monorepos, workspaces and common tooling","archived":false,"fork":false,"pushed_at":"2024-09-12T13:56:15.000Z","size":4501,"stargazers_count":7,"open_issues_count":10,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-10-11T20:49:12.880Z","etag":null,"topics":["dx","javascript","monorepo","starterkit","typescript","yarn"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hongaar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-12T22:06:39.000Z","updated_at":"2024-05-27T20:50:57.000Z","dependencies_parsed_at":"2023-12-11T21:27:52.488Z","dependency_job_id":"ef371d9a-c764-44e7-876f-5a159fd2d507","html_url":"https://github.com/hongaar/moker","commit_stats":null,"previous_names":[],"tags_count":110,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hongaar%2Fmoker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hongaar%2Fmoker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hongaar%2Fmoker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hongaar%2Fmoker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hongaar","download_url":"https://codeload.github.com/hongaar/moker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243818171,"owners_count":20352629,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dx","javascript","monorepo","starterkit","typescript","yarn"],"created_at":"2024-10-10T20:49:13.780Z","updated_at":"2025-03-16T13:31:46.540Z","avatar_url":"https://github.com/hongaar.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# moker [![npm](https://img.shields.io/npm/v/moker)](https://www.npmjs.com/package/moker)\n\n**No more struggles setting up a new JavaScript repository. Kick-start\nsingle-purpose repos, monorepos, monorepo workspaces and common tooling:**\n\n```bash\n# initialize a monorepo\nyarn dlx moker create --monorepo my-monorepo\ncd my-monorepo\n\n# install common tools\nyarn moker use prettier doctoc semantic-release\n\n# create workspaces\nyarn moker add --template express server\nyarn moker add --template cra client\nyarn moker add --template lib shared\nyarn moker add --template bandersnatch cli\n```\n\n## Features\n\n- 👢 Kick-start a new repo or monorepo using Yarn\n- 🧰 Plugins to use pre-configured common tooling\n- ➕ Quickly add workspaces to a monorepo\n- 🧬 Workspace templates for a shared library, React app, API or CLI\n- ⚡ Extensible, bring your own plugins\n\n\u003e 🤓 _Default_: The core plugins make some assumptions you may not agree with.\n\u003e If that's the case, this tool is probably not for you. The defaults used are\n\u003e documented below and marked with a nerd-face emoji so you should be able to\n\u003e get a clear picture of what to expect.\n\n## Table of contents\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n- [Getting started](#getting-started)\n  - [Prerequisites](#prerequisites)\n  - [Usage](#usage)\n  - [Creating a single-purpose repo](#creating-a-single-purpose-repo)\n  - [Creating a monorepo](#creating-a-monorepo)\n  - [Creating a monorepo workspace](#creating-a-monorepo-workspace)\n  - [Using plugins](#using-plugins)\n  - [Using templates](#using-templates)\n  - [Using plugins and templates together](#using-plugins-and-templates-together)\n- [Available plugins](#available-plugins)\n  - [`dependabot`](#dependabot)\n  - [`devcontainer`](#devcontainer)\n  - [`doctoc`](#doctoc)\n  - [`esbuild`](#esbuild)\n  - [`github-actions`](#github-actions)\n  - [`husky`](#husky)\n  - [`jest`](#jest)\n  - [`lint-staged`](#lint-staged)\n  - [`prettier`](#prettier)\n  - [`semantic-release`](#semantic-release)\n  - [`test`](#test)\n  - [`todos`](#todos)\n  - [`typescript`](#typescript)\n  - [`xv`](#xv)\n- [Available templates](#available-templates)\n  - [`angular`](#angular)\n  - [`bandersnatch`](#bandersnatch)\n  - [`common`](#common)\n  - [`cra`](#cra)\n  - [`express`](#express)\n  - [`github-action`](#github-action)\n  - [`lib`](#lib)\n  - [`nestjs`](#nestjs)\n  - [`next`](#next)\n  - [`sanity`](#sanity)\n- [Commands](#commands)\n- [Contributing](#contributing)\n  - [Roadmap](#roadmap)\n  - [Development](#development)\n  - [Devcontainer](#devcontainer)\n  - [Credits](#credits)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n# Getting started\n\n## Prerequisites\n\nYou will need Node v18+ and Yarn v2+ in order to use `moker`.\n\n- Install Node with [nvm](https://github.com/nvm-sh/nvm#install--update-script)\n  or using [nodesource](https://github.com/nodesource/distributions#debinstall).\n- Install Yarn using these simple steps:\n  ```bash\n  corepack enable\n  corepack prepare yarn@stable --activate\n  ```\n\n## Usage\n\n`moker` is distributed as a NPM package, and can be run with `yarn dlx`:\n\n```bash\nyarn dlx moker \u003ccommand\u003e\n```\n\n\u003e **Note**: Note that when we use `yarn dlx moker` to create a new repo, `moker`\n\u003e is added as a dependency to your new repo, so we can simply use `yarn moker`\n\u003e to execute commands from within the repo directory.\n\n## Creating a single-purpose repo\n\nTo create a new repo in the `my-repo` directory:\n\n```bash\nyarn dlx moker create my-repo\n```\n\n## Creating a monorepo\n\nTo create a new monorepo in the `my-monorepo` directory: :\n\n```bash\nyarn dlx moker create --monorepo my-monorepo\n```\n\n\u003e 🤓 _Default_: The monorepo is initiated with Yarn without Zero-Installs and in\n\u003e legacy `nodeLinker: node-modules` mode because a lot of packages are not yet\n\u003e compatible with PnP or require a workaround.\n\n## Creating a monorepo workspace\n\nWorkspaces (a.k.a. monorepo packages) are added in a customizable subdirectory\nof the monorepo (the default is `packages`). To add a new workspace called\n`my-workspace` to your monorepo, run this from within the monorepo directory:\n\n```bash\nyarn moker add my-workspace\n```\n\n## Using plugins\n\nPlugins are used to add additional tools to your repo or workspace. Add the\n`prettier` plugin with:\n\n```bash\nyarn moker use prettier\n```\n\nPlugins may work together. For example, `lint-staged` will install a pre-commit\nhook which formats code if `prettier` and `husky` are installed. The order in\nwhich plugins are added does not matter. You can install multiple plugins at\nonce:\n\n```bash\nyarn moker use prettier lint-staged husky\n```\n\n\u003e **Note**: Some plugins only work at the repo or workspace level, `moker` will\n\u003e warn you if you try to add a plugin at the wrong level.\n\nFor a complete list of out-of-the-box plugins, see the section\n[available plugins](#available-plugins). Using 3rd party plugins is also\nsupported:\n\n```bash\nyarn add --dev --exact moker-plugin-name\nyarn moker use moker-plugin-name\n```\n\n## Using templates\n\nTemplates are pre-defined collections of plugins and scaffolding to quickly\ncreate focussed new repos or workspaces. To create a new repo `my-repo` with the\n`common` template:\n\n```bash\nyarn dlx moker create --template common my-repo\n```\n\nTo add a workspace called `shared` to a monorepo using the `lib` template:\n\n```bash\nyarn moker add --template lib shared\n```\n\nYou can install multiple templates at once:\n\n```bash\nyarn dlx moker create --template common --template github-action my-action\n```\n\nFor a complete list of out-of-the-box templates, see the section\n[available templates](#available-templates). Using 3rd party templates is also\nsupported:\n\n```bash\nyarn dlx --package moker-template-name \\\n  moker create --template moker-template-name my-repo\n\n```\n\n## Using plugins and templates together\n\nPlugins and templates can be used together, for example:\n\n```bash\nyarn dlx moker create --template express --use prettier my-repo\n```\n\n# Available plugins\n\n## `dependabot`\n\n_Scope: repo_\n\nThis plugin adds a [Dependabot] configuration to your monorepo with an updater\nfor NPM packages.\n\nIf you have the `github-actions` plugin installed, it will add an updater for\nGitHub Actions workflows.\n\n[Dependabot]:\n  https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuring-dependabot-version-updates\n\n## `devcontainer`\n\n_Scope: repo_\n\nThis plugin creates a [Development Containers](https://containers.dev)\nconfiguration using the\n[`typescript-node`](https://hub.docker.com/_/microsoft-vscode-devcontainers)\nimage.\n\nIf you have the `prettier` plugin installed, it will add the [Prettier VS Code\nextension].\n\n[Prettier VS Code extension]:\n  https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode\n\n## `doctoc`\n\n_Scope: repo_\n\nThis plugin adds a script to generate a table of contents for the README using\n[doctoc](https://github.com/thlorenz/doctoc).\n\nIf you have the `husky` plugin installed, it will also add a pre-commit hook.\n\n## `esbuild`\n\n_Scope: repo or workspace_\n\nThis plugin sets up [esbuild](https://esbuild.github.io) and adds a `build` and\n`build:watch` script to the repo or both the workspace and the monorepo.\n\n\u003e 🤓 _Default_: If you have the `typescript` plugin installed as well, we'll\n\u003e assume that you want to build to a bundle instead of transpiled TypeScript. We\n\u003e will still use `tsc` for type checking.\n\n## `github-actions`\n\n_Scope: repo_\n\nThis plugin creates a simple `ci.yml`\n[GitHub Actions](https://github.com/features/actions) workflow and a workflow to\n[update the Node](https://github.com/hongaar/update-node-versions) versions\nperiodically.\n\nIf you have the `prettier` plugin installed, this will also setup a `lint.yml`\nworkflow.\n\nIf you have the `semantic-release` plugin installed, this will also setup a\n`release.yml` workflow. This workflow needs these secrets to be added to your\nrepository:\n\n- `GH_PAT`: a GitHub token with read/write access to your repository\n- `NPM_TOKEN`: an NPM token with publish access to your packages\n\nIf you have the `dependabot` plugin installed, this will also setup two\nadditional workflows. A `dependabot-automerge` workflow which enables auto-merge\n(squash) on dependabot PRs. You need to enable _Allow auto-merge_ in the GitHub\nrepository settings and apply _Branch protection rules_ for the main branch.\n\n\u003e **Note**: If you enabled _Require approvals_ in the branch protection rules,\n\u003e this won't automatically approve the PR. You will need to add an additional\n\u003e command to the workflow, like:\n\u003e\n\u003e ```diff\n\u003e  steps:\n\u003e -  - run: gh pr merge --auto --squash \"$PR_URL\"\n\u003e +  - run: |\n\u003e +      gh pr review --approve \"$PR_URL\"\n\u003e +      gh pr merge --auto --squash \"$PR_URL\"\n\u003e      env:\n\u003e ```\n\nA `reload-moker-plugins` workflow is added to reload the moker plugins and\ncreate a pull request with changes made by moker whenever dependencies are\nupdated by dependabot.\n\n\u003e 🤓 _Default_: The workflows will use the `main` branch by default, but it is\n\u003e trivial to change this.\n\n## `husky`\n\n_Scope: repo_\n\nThis plugin sets up [Husky](https://typicode.github.io/husky/#/) at the repo\nlevel.\n\n\u003e **Warning**: The `postinstall` script to install Husky automatically is only\n\u003e installed on (private) monorepos. Otherwise, `postinstall` will run when\n\u003e someone installs your package and result in an error.\n\u003e\n\u003e See\n\u003e [Husky docs on installing with Yarn 2](https://typicode.github.io/husky/#/?id=yarn-2)\n\n## `jest`\n\n_Scope: repo or workspace_\n\n\u003e 🧪 _Experimental_ Currently only works with the `typescript` plugin. Currently\n\u003e doesn't work when you have ESM dependencies in `node_modules`.\n\nThis plugin sets up [Jest](https://jestjs.io) and adds a `test` and `test:watch`\nscript to the repo or both the workspace and the monorepo.\n\n## `lint-staged`\n\n_Scope: repo_\n\nThis plugin sets up [lint-staged](https://github.com/okonet/lint-staged) at the\nmonorepo level.\n\nIf you have the `prettier` plugin installed, this will setup a task to format\nstaged files using `prettier --write --ignore-unknown`.\n\nIf you have the `husky` plugin installed, this will setup a pre-commit hook to\nrun `yarn lint-staged`.\n\n## `prettier`\n\n_Scope: repo_\n\nThis plugin sets up [Prettier](https://prettier.io).\n\n\u003e 🤓 _Default_: Prettier is installed with this configuration:\n\u003e\n\u003e ```yaml\n\u003e proseWrap: always\n\u003e ```\n\u003e\n\u003e We only set this `proseWrap` override because we think markdown files should\n\u003e always be truncated to match whatever the `printWidth` setting is. This makes\n\u003e it so much easier to read and write markdown files!\n\n## `semantic-release`\n\n_Scope: repo_\n\nThis plugin sets up\n[semantic-release](https://semantic-release.gitbook.io/semantic-release/). It\nuses the\n[semantic-release-yarn](https://github.com/hongaar/semantic-release-yarn) plugin\nwhich has support for releasing monorepos.\n\nPlease note that by default the root repository is not published. You can change\nthis by setting the `private` property in `package.json` to `false`.\n\n\u003e 🤓 _Default_: The release configuration will use the `main` branch by default,\n\u003e but it is trivial to change this.\n\n## `test`\n\n_Scope: repo or workspace_\n\nThis plugin enables testing with the native\n[node --test](https://nodejs.org/api/test.html) functionality.\n\nWhen the `typescript` plugin is also installed, it will use\n[ts-node](https://typestrong.org/ts-node/) to load TypeScript test files.\n\n## `todos`\n\n_Scope: repo or workspace_\n\nThis plugin adds a script to generate a TODO markdown file from all code\nannotations using [leasot](https://github.com/pgilad/leasot).\n\nIf you have the `husky` plugin installed, it will also add a pre-commit hook.\n\n## `typescript`\n\n_Scope: repo or workspace_\n\n\u003e 🧪 _Experimental_ Since v2, this plugin uses the new `--build` mode of\n\u003e TypeScript, which makes building a lot faster but may require some additional\n\u003e configuration.\n\nThis plugin sets up [TypeScript](https://www.typescriptlang.org) and adds a\n`build` and `build:watch` script to the repo or both the workspace and the\nmonorepo.\n\nIn addition, this will add a `typescript` and `typescript:watch` script to the\nmonorepo which can use\n[project references](https://www.typescriptlang.org/docs/handbook/project-references.html)\nto build workspaces which depend on each other faster and provides a better\ndeveloper experience.\n\nIn order to use this, add all TypeScript workspaces to `tsconfig.json` in the\nmonorepo root directory:\n\n```json\n{\n  \"$schema\": \"https://json.schemastore.org/tsconfig\",\n  \"references\": [\n    { \"path\": \"./packages/some-library\" },\n    { \"path\": \"./packages/some-dependency\" }\n  ],\n  \"files\": []\n}\n```\n\nAnd reference dependant workspaces in the workspace `tsconfig.json`:\n\n```json\n{\n  \"extends\": \"../../tsconfig.base.json\",\n  \"compilerOptions\": {\n    \"rootDir\": \"src\",\n    \"outDir\": \"dist\",\n    \"declarationDir\": \"types\"\n  },\n  \"references\": [{ \"path\": \"../some-dependency\" }],\n  \"include\": [\"src/**/*\"]\n}\n```\n\nYou can optionally sync project references with\n`yarn dlx @monorepo-utils/workspaces-to-typescript-project-references`.\n\n## `xv`\n\n_Scope: repo or workspace_\n\n\u003e 🧪 _Experimental_ Currently only works with the `typescript` plugin.\n\nThis plugin sets up [xv](https://github.com/typicode/xv) and adds a `test`\nscript to the repo or both the workspace and the monorepo.\n\n# Available templates\n\n## `angular`\n\n_Scope: workspace_\n\nUses the [Angular CLI](https://angular.dev/tools/cli) to interactively scaffold\nan Angular app (web client).\n\n## `bandersnatch`\n\n_Scope: repo or workspace_\n\nScaffolds a simple [bandersnatch](https://github.com/hongaar/bandersnatch) CLI\napp tool with the [typescript](#typescript-workspace) and\n[jest](#jest-workspace) plugins.\n\n## `common`\n\n_Scope: repo_\n\nThis is the only monorepo template at this point. It simply installs all\navailable monorepo plugins.\n\n## `cra`\n\n_Scope: workspace_\n\nUses [create-react-app](https://create-react-app.dev/) to scaffold a React.js\napp (web client).\n\n## `express`\n\n_Scope: repo or workspace_\n\nScaffolds a simple [express](https://expressjs.com) HTTP app with the\n[typescript](#typescript-workspace) and [jest](#jest-workspace) plugins.\n\n## `github-action`\n\n_Scope: repo_\n\n\u003e 🧪 _Experimental_\n\nScaffolds a [custom GitHub Action] template.\n\n[custom GitHub Action]:\n  https://docs.github.com/en/actions/creating-actions/about-custom-actions\n\n## `lib`\n\n_Scope: repo or workspace_\n\nA plain shared library template with the [typescript](#typescript-workspace) and\n[jest](#jest-workspace) plugins.\n\n## `nestjs`\n\n_Scope: workspace_\n\nUses the\n[TypeScript starter project](https://github.com/nestjs/typescript-starter) to\nscaffold a Nest.js server app.\n\n## `next`\n\n_Scope: workspace_\n\nUses\n[create-next-app](https://nextjs.org/docs/pages/api-reference/create-next-app)\nto scaffold a Next.js app.\n\n## `sanity`\n\n_Scope: workspace_\n\nUses [create-sanity](https://www.sanity.io/docs/installation) which\ninteractively scaffolds a Sanity Studio package.\n\n# Commands\n\nSee `moker --help` for a list of available commands.\n\n# Contributing\n\nContributions are very welcome!\n\n## Roadmap\n\n- [ ] Use TS project references for better (incremental) compilation\n      [example](https://www.npmjs.com/package/@isomorphic-typescript/ts-monorepo)\n- [ ] Support for `swc`/`esbuild`\n- [ ] A compat lib (which builds cjs and mjs targets)\n- [ ] Blog post / tutorial\n- [ ] Docs for writing custom plugins / templates\n- [x] Add LICENSE file to repo\n- [x] Adapt for non-monorepo use-cases\n- [x] github-actions plugin\n- [x] devcontainer plugin\n- [x] leasot (todos) plugin\n- [x] doctoc plugin\n- [x] semantic-release plugin\n- [x] Port templates\n- [x] Support for BYO plugins/templates\n- [x] Remove plugins\n\nAlso see [TODO.md](TODO.md).\n\n## Development\n\nTo run the `moker` CLI from source, run:\n\n```bash\nyarn start\n```\n\nNote that you can create a new monorepo for testing purposes outside the current\nworking directory with:\n\n```bash\nyarn start create /path/to/my-repo\n```\n\n## Devcontainer\n\nA devcontainer configuration is included in this repo to\n[get started quickly](https://code.visualstudio.com/docs/remote/containers#_quick-start-open-an-existing-folder-in-a-container).\n\n## Credits\n\n©️ Copyright 2022 [Joram van den Boezem](https://joram.dev)  \n♻️ Licensed under the [MIT license](LICENSE)  \n🤔 Moker? **MOnorepo KickstartER**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhongaar%2Fmoker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhongaar%2Fmoker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhongaar%2Fmoker/lists"}