├── .eslintrc.cjs ├── .github ├── FUNDING.yml ├── PULL_REQUEST_TEMPLATE.md ├── actions │ └── setup │ │ └── action.yml ├── dependabot.yml └── workflows │ ├── checks.yml │ ├── publish-canary.yml │ └── publish-new.yml ├── .gitignore ├── .husky └── pre-commit ├── .prettierignore ├── .prettierrc ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── assets └── lazyrepo.svg ├── bin.js ├── index.d.ts ├── index.js ├── jest.config.js ├── package.json ├── patches └── jest-resolve@29.5.0.patch ├── pnpm-lock.yaml ├── pr-label-enforcer ├── src │ └── index.ts └── wrangler.toml ├── scripts ├── lib │ ├── exec.js │ └── getCurrentVersion.js ├── pack-test-version.js ├── publish-canary.js └── publish-new.js ├── src ├── cli.js ├── commands │ ├── clean.js │ ├── inherit.js │ ├── init.js │ └── run.js ├── config │ ├── config-types.d.ts │ ├── config.js │ ├── resolveConfig.js │ └── validateConfig.js ├── cwd.js ├── execCli.js ├── formatZodError.js ├── fs.js ├── glob │ ├── LazyGlob.js │ ├── compile │ │ ├── Lexer.js │ │ ├── Parser.js │ │ ├── ast.d.ts │ │ ├── compileMatcher.js │ │ ├── expandBraces.js │ │ └── matcher.js │ ├── fs │ │ ├── LazyDir.js │ │ ├── LazyEntry.d.ts │ │ └── LazyFile.js │ ├── glob-types.d.ts │ ├── glob.js │ └── matchInDir.js ├── logger │ ├── InteractiveLogger.js │ ├── LazyError.js │ ├── RealtimeLogger.js │ ├── formatting.js │ ├── logger.js │ └── rainbow.js ├── manifest │ ├── ManifestConstructor.js │ ├── computeManifest.js │ ├── createLazyWriteStream.js │ ├── getInputFiles.js │ ├── hash.js │ └── manifest-types.d.ts ├── outputs │ ├── cacheOutputs.js │ ├── copyFileWithMtime.js │ └── restoreOutputs.js ├── path.js ├── project │ ├── Project.js │ ├── findRootWorkspace.js │ ├── getPackageManager.js │ ├── loadWorkspace.js │ └── project-types.d.ts ├── tasks │ ├── TaskGraph.js │ ├── runTask.js │ ├── runTaskIfNeeded.js │ └── spawn.js ├── types.d.ts └── utils │ ├── compact.js │ ├── createTimer.js │ ├── isCi.js │ ├── isTest.js │ ├── rimraf.js │ └── uniq.js ├── test ├── ManifestContstructor.test.ts ├── TaskGraph.test.ts ├── config.test.ts ├── expandGlobPaths.test.ts ├── extractInheritMatch.test.ts ├── findRootWorkspace.test.ts ├── glob │ ├── compileMatcher.test.ts │ ├── dot.test.ts │ ├── expandDirectories.test.ts │ ├── extglob.test.ts │ ├── glob-random.test.ts │ ├── glob-test-utils.ts │ ├── lexer.test.ts │ ├── negation-layers.test.ts │ ├── parser.test.ts │ ├── symbolicLinks.test.ts │ ├── types.test.ts │ └── wildcard.test.ts ├── integration │ ├── ci-logging.test.ts │ ├── config.test.ts │ ├── dependent.test.ts │ ├── file-caching.test.ts │ ├── filter.test.ts │ ├── globbing.test.ts │ ├── help.test.ts │ ├── ignoreWorkspaces.test.ts │ ├── independent.test.ts │ ├── inherit.test.ts │ ├── log-caching.test.ts │ ├── run.test.ts │ ├── runIntegrationTests.ts │ ├── top-level.test.ts │ ├── workspace.test.ts │ └── workspaceOverrides.test.ts ├── setup.ts ├── test-utils.ts └── validateConfig.test.ts ├── thoughts.md └── tsconfig.json /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | /** @type {import('eslint').Linter.Config} */ 2 | module.exports = { 3 | root: true, 4 | env: { 5 | es2021: true, 6 | node: true, 7 | }, 8 | ignorePatterns: ['coverage/**/*'], 9 | extends: [ 10 | 'eslint:recommended', 11 | 'plugin:n/recommended', 12 | 'plugin:@typescript-eslint/recommended', 13 | 'plugin:@typescript-eslint/recommended-requiring-type-checking', 14 | ], 15 | parser: '@typescript-eslint/parser', 16 | overrides: [ 17 | { 18 | files: ['**/*'], 19 | rules: { 20 | 'no-restricted-imports': [ 21 | 'error', 22 | 'path', 23 | 24 | { 25 | name: 'process', 26 | importNames: ['cwd'], 27 | message: "Please import 'cwd' from './src/cwd.js' instead.", 28 | }, 29 | ], 30 | 'no-restricted-properties': [ 31 | 2, 32 | { 33 | object: 'process', 34 | property: 'cwd', 35 | }, 36 | ], 37 | }, 38 | }, 39 | { 40 | files: ['src/**', 'bin.js', 'index.js', 'index.d.ts'], 41 | rules: { 42 | 'no-restricted-imports': [ 43 | 'error', 44 | 'fs', 45 | 'path', 46 | 'fs/promises', 47 | 'node:fs', 48 | 'node:fs/promises', 49 | ], 50 | 'no-console': 'error', 51 | '@typescript-eslint/no-empty-function': ['error', { allow: ['arrowFunctions'] }], 52 | '@typescript-eslint/ban-ts-comment': 'off', 53 | '@typescript-eslint/no-unused-vars': 'off', 54 | 'n/shebang': 'off', 55 | }, 56 | }, 57 | { 58 | files: ['test/**'], 59 | env: { 60 | 'jest/globals': true, 61 | }, 62 | plugins: ['jest'], 63 | extends: ['plugin:jest/recommended'], 64 | rules: { 65 | 'no-restricted-imports': ['error', 'path'], 66 | '@typescript-eslint/no-unsafe-call': 'off', 67 | '@typescript-eslint/no-extra-semi': 'off', 68 | '@typescript-eslint/no-non-null-assertion': 'off', 69 | '@typescript-eslint/no-unused-vars': 'off', 70 | '@typescript-eslint/restrict-template-expressions': 'off', 71 | '@typescript-eslint/no-unsafe-return': 'off', 72 | '@typescript-eslint/no-explicit-any': 'off', 73 | '@typescript-eslint/restrict-plus-operands': 'off', 74 | '@typescript-eslint/ban-ts-comment': 'off', 75 | }, 76 | }, 77 | { 78 | files: ['scripts/**'], 79 | rules: { 80 | 'n/no-process-exit': 'off', 81 | }, 82 | }, 83 | ], 84 | reportUnusedDisableDirectives: true, 85 | parserOptions: { 86 | ecmaVersion: 'latest', 87 | sourceType: 'module', 88 | project: true, 89 | }, 90 | rules: { 91 | '@typescript-eslint/restrict-template-expressions': 'off', 92 | 'n/no-missing-import': 'off', 93 | 'n/no-missing-require': 'off', 94 | 'n/no-unpublished-import': 'off', 95 | 'n/no-unpublished-require': 'off', 96 | '@typescript-eslint/no-extra-semi': 'off', 97 | 'no-extra-semi': 'off', 98 | eqeqeq: ['error', 'always'], 99 | }, 100 | } 101 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: ds300 4 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | 4 | 5 | ## Change Type 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | - [ ] `patch` — Bug Fix 14 | - [ ] `minor` — New Feature 15 | - [ ] `major` — Breaking Change 16 | - [ ] `dependencies` — Dependency Update (publishes a `patch` release, for devDependencies use `internal`) 17 | - [ ] `documentation` — Changes to the documentation only (will not publish a new version) 18 | - [ ] `tests` — Changes to any testing-related code only (will not publish a new version) 19 | - [ ] `internal` — Any other changes that don't affect the published package (will not publish a new version) -------------------------------------------------------------------------------- /.github/actions/setup/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Setup' 2 | description: Setup action 3 | 4 | runs: 5 | using: 'composite' 6 | steps: 7 | - name: Install pnpm 8 | uses: pnpm/action-setup@v2 9 | 10 | - name: Setup Node.js environment 11 | uses: actions/setup-node@v3 12 | with: 13 | node-version: 18 14 | cache: 'pnpm' 15 | 16 | - name: Install dependencies 17 | run: pnpm install --frozen-lockfile 18 | shell: bash 19 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "npm" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | -------------------------------------------------------------------------------- /.github/workflows/checks.yml: -------------------------------------------------------------------------------- 1 | name: Lint and Test 2 | 3 | on: 4 | pull_request: 5 | branches: [main] 6 | push: 7 | branches: [main] 8 | 9 | jobs: 10 | build: 11 | name: 'Lint and Test' 12 | timeout-minutes: 15 13 | 14 | strategy: 15 | matrix: 16 | os: [ubuntu-latest, windows-latest] 17 | 18 | runs-on: ${{ matrix.os }} 19 | 20 | steps: 21 | - uses: actions/checkout@v3 22 | 23 | - name: Install pnpm 24 | uses: pnpm/action-setup@v2 25 | 26 | - name: Setup Node.js environment 27 | uses: actions/setup-node@v3 28 | with: 29 | node-version: 18 30 | cache: 'pnpm' 31 | 32 | - name: Install dependencies 33 | run: pnpm install --frozen-lockfile 34 | shell: bash 35 | 36 | - name: Lint 37 | if: ${{ matrix.os != 'windows-latest' }} 38 | run: pnpm lint 39 | 40 | - name: format 41 | if: ${{ matrix.os != 'windows-latest' }} 42 | run: pnpm format:check 43 | 44 | - name: Typecheck 45 | if: ${{ matrix.os != 'windows-latest' }} 46 | run: pnpm tsc 47 | 48 | - name: Test 49 | if: ${{ matrix.os != 'windows-latest' }} 50 | run: pnpm test 51 | 52 | - name: Test (windows) 53 | if: ${{ matrix.os == 'windows-latest' }} 54 | run: pnpm test -- --runInBand 55 | 56 | 57 | -------------------------------------------------------------------------------- /.github/workflows/publish-canary.yml: -------------------------------------------------------------------------------- 1 | name: Publish Canary Packages 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | 7 | jobs: 8 | build: 9 | name: 'Publish Canary Package' 10 | timeout-minutes: 15 11 | environment: npm deploy 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | with: 17 | fetch-depth: 0 18 | 19 | - uses: ./.github/actions/setup 20 | 21 | - name: Publish Canary Packages 22 | run: node scripts/publish-canary.js 23 | env: 24 | GH_TOKEN: ${{ secrets.GH_TOKEN }} 25 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 26 | -------------------------------------------------------------------------------- /.github/workflows/publish-new.yml: -------------------------------------------------------------------------------- 1 | name: Publish New Version 2 | 3 | on: workflow_dispatch 4 | 5 | jobs: 6 | build: 7 | name: 'Publish New Version' 8 | timeout-minutes: 15 9 | environment: npm deploy 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v3 14 | with: 15 | token: ${{ secrets.GH_TOKEN }} 16 | 17 | - name: Prepare repository 18 | # Fetch full git history and tags for auto 19 | run: git fetch --unshallow --tags 20 | 21 | - uses: ./.github/actions/setup 22 | 23 | - name: Publish New Version 24 | run: node scripts/publish-new.js 25 | env: 26 | GH_TOKEN: ${{ secrets.GH_TOKEN }} 27 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | *.log 3 | .* 4 | node_modules 5 | *.tgz 6 | 7 | !.gitignore 8 | !.prettierrc 9 | !.prettierignore 10 | !.eslintrc.cjs 11 | !.husky 12 | !.github 13 | 14 | 15 | coverage 16 | package -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | pnpm lint-staged 5 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | pnpm-lock.yaml 2 | .* 3 | !.eslintrc.cjs 4 | !.prettierrc -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "all", 3 | "singleQuote": true, 4 | "semi": false, 5 | "printWidth": 100, 6 | "tabWidth": 2, 7 | "useTabs": false, 8 | "proseWrap": "never", 9 | "plugins": ["prettier-plugin-organize-imports"], 10 | "endOfLine": "lf" 11 | } 12 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation. 6 | 7 | We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. 8 | 9 | ## Our Standards 10 | 11 | Examples of behavior that contributes to a positive environment for our community include: 12 | 13 | - Demonstrating empathy and kindness toward other people 14 | - Being respectful of differing opinions, viewpoints, and experiences 15 | - Giving and gracefully accepting constructive feedback 16 | - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience 17 | - Focusing on what is best not just for us as individuals, but for the overall community 18 | 19 | Examples of unacceptable behavior include: 20 | 21 | - The use of sexualized language or imagery, and sexual attention or advances of any kind 22 | - Trolling, insulting or derogatory comments, and personal or political attacks 23 | - Public or private harassment 24 | - Publishing others' private information, such as a physical or email address, without their explicit permission 25 | - Other conduct which could reasonably be considered inappropriate in a professional setting 26 | 27 | ## Enforcement Responsibilities 28 | 29 | Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. 32 | 33 | ## Scope 34 | 35 | This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. 36 | 37 | ## Enforcement 38 | 39 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [INSERT CONTACT METHOD]. All complaints will be reviewed and investigated promptly and fairly. 40 | 41 | All community leaders are obligated to respect the privacy and security of the reporter of any incident. 42 | 43 | ## Enforcement Guidelines 44 | 45 | Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: 46 | 47 | ### 1. Correction 48 | 49 | **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. 50 | 51 | **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. 52 | 53 | ### 2. Warning 54 | 55 | **Community Impact**: A violation through a single incident or series of actions. 56 | 57 | **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. 58 | 59 | ### 3. Temporary Ban 60 | 61 | **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. 62 | 63 | **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. 64 | 65 | ### 4. Permanent Ban 66 | 67 | **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. 68 | 69 | **Consequence**: A permanent ban from any sort of public interaction within the community. 70 | 71 | ## Attribution 72 | 73 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. 74 | 75 | Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. 76 | 77 | For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations]. 78 | 79 | [homepage]: https://www.contributor-covenant.org 80 | [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html 81 | [Mozilla CoC]: https://github.com/mozilla/diversity 82 | [FAQ]: https://www.contributor-covenant.org/faq 83 | [translations]: https://www.contributor-covenant.org/translations 84 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to `lazyrepo` 2 | 3 | ## Issues and Questions 4 | 5 | Feel free to submit Issues for 6 | 7 | - Bug reports 8 | - Specific, detailed feature requests 9 | - Something doesn't work how you expect 10 | 11 | Also feel free to offer to work on any issues! 12 | 13 | Please make suggestions or ask other kinds of questions in Discussions. 14 | 15 | ## The codebase 16 | 17 | We use 18 | 19 | - `pnpm` for package management. 20 | - `prettier` for formatting. 21 | - `eslint` for linting 22 | - `jest` for tests 23 | 24 | ### Structure 25 | 26 | Please keep all code related to testing in the `test` directory and all code used by the `lazy` cli in the `src` directory. The `test` directory is not included in the package when it is published. 27 | 28 | At the time of writing, there are dev scripts in the repo, but if you need to add one please create a `scripts` directory. These should be typescript files or bash scripts unless there's good reason to do something else. 29 | 30 | ### JS + TS 31 | 32 | `lazyrepo` is written in JavaScript with TypeScript types as JSDoc comments. This allows us to avoid having a build step. 33 | 34 | Any test code is written in `.ts` files. 35 | 36 | At the time of writing we have one `types.d.ts` file to make it easier to define types used in the `.js` files. Feel free to split that file up or add new `.d.ts` files if it makes sense. 37 | 38 | ## Submitting Pull Requests 39 | 40 | Feel free to submit pull requests! Ask before working on big stuff otherwise you might be disappointed if it gets rejected for some reason. 41 | 42 | If there's an issue for the thing you're working on, please let folks know that you're working on it in the issue. Do a quick search in discussions too. 43 | 44 | ## Testing Locally 45 | 46 | If you want to test lazyrepo locally, you can run `pnpm pack-test-version` and then use the resulting tarball to add `lazyrepo` to a local test project. 47 | 48 | This test tarball will read the source files from your local git checkout, so you can make changes and test them without having to publish a new version or do any tricky linking. 49 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2023-Present David Sheldrick 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |