Projen project type for Turborepo monorepo setup.

Overview

📦 projen-turborepo

Projen project type for Turborepo monorepo setup.

Getting Started

To create a new project, run the following command and follow the instructions:

$> mkdir my-monorepo
$> cd my-monorepo
$> npx projen new --from projen-turborepo --projenrc-ts
🤖 Synthesizing project...
...

Example

import { TurborepoProject } from 'projen-turborepo'
import { typescript } from 'projen';

const turbo = new TurborepoProject({
  name: 'my-monorepo',
  turbo: {
    pipeline: {
      // ... your pipeline config, but defaults are already included
    },
  },
})

new typescript.TypeScriptProject({
  parent: turbo,
  defaultReleaseBranch: 'master',
  name: 'my-first-project',
  outdir: 'packages/my-first-project',
  // ...
})

turbo.synth()

Then use turbo to run the tasks:

$> turbo run test
• Packages in scope: my-first-project
• Running test in 1 packages
my-first-project:test: cache hit, replaying output 2264dbd676fac83e
my-first-project:test: yarn run v1.22.11
my-first-project:test: $ npx projen test
my-first-project:test: ----------|---------|----------|---------|---------|-------------------
my-first-project:test: File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
my-first-project:test: ----------|---------|----------|---------|---------|-------------------
my-first-project:test: All files |     100 |      100 |     100 |     100 |
my-first-project:test:  index.ts |     100 |      100 |     100 |     100 |
my-first-project:test: ----------|---------|----------|---------|---------|-------------------
my-first-project:test: Done in 4.29s.
my-first-project:test: 👾 test | jest --passWithNoTests --all --updateSnapshot
my-first-project:test: PASS test/hello.test.ts
my-first-project:test:   ✓ hello (1 ms)
my-first-project:test:
my-first-project:test: Test Suites: 1 passed, 1 total
my-first-project:test: Tests:       1 passed, 1 total
my-first-project:test: Snapshots:   0 total
my-first-project:test: Time:        1.148 s, estimated 2 s
my-first-project:test: Ran all test suites.
my-first-project:test: 👾 test » eslint | eslint --ext .ts,.tsx --fix --no-error-on-unmatched-pattern src test build-tools .projenrc.js

 Tasks:    1 successful, 1 total
Cached:    1 cached, 1 total
  Time:    65ms >>> FULL TURBO
Comments
  • Cannot find module 'ts-jest'

    Cannot find module 'ts-jest'

    I was following instructions from README to initialize new project. I encountered following error:

    Error: Cannot find module 'ts-jest'
    

    Looks like this issue was introduced in version 0.0.15. I got project installed using:

    npx projen new --from [email protected] --projenrc-ts
    

    Here is full trace log:

    MacBook-Pro:test kasperhamalainen$ mkdir projen-turborepo
    MacBook-Pro:test kasperhamalainen$ cd projen-turborepo/
    MacBook-Pro:projen-turborepo kasperhamalainen$ npx projen new --from projen-turborepo --projenrc-ts
    Need to install the following packages:
      projen
    Ok to proceed? (y) y
    /Users/kasperhamalainen/Code/test/projen-turborepo
    └── (empty)
    
    
    added 1 package, and audited 66 packages in 2s
    
    7 packages are looking for funding
      run `npm fund` for details
    
    found 0 vulnerabilities
    👾 installing external module projen-turborepo...
    
    added 1 package, and audited 67 packages in 1s
    
    7 packages are looking for funding
      run `npm fund` for details
    
    found 0 vulnerabilities
    Error: Cannot find module 'ts-jest'
    Require stack:
    - /Users/kasperhamalainen/Code/test/projen-turborepo/node_modules/projen-turborepo/lib/index.js
    - /Users/kasperhamalainen/.npm/_npx/80cfb0dc84733c29/node_modules/projen/lib/projects.js
    - /Users/kasperhamalainen/.npm/_npx/80cfb0dc84733c29/node_modules/projen/lib/cli/cmds/new.js
    - /Users/kasperhamalainen/.npm/_npx/80cfb0dc84733c29/node_modules/projen/node_modules/yargs/index.cjs
    - /Users/kasperhamalainen/.npm/_npx/80cfb0dc84733c29/node_modules/projen/lib/cli/index.js
    - /Users/kasperhamalainen/.npm/_npx/80cfb0dc84733c29/node_modules/projen/bin/projen
        at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
        at Function.Module._load (node:internal/modules/cjs/loader:778:27)
        at Module.require (node:internal/modules/cjs/loader:1005:19)
        at require (node:internal/modules/cjs/helpers:102:18)
        at Object.<anonymous> (/Users/kasperhamalainen/Code/test/projen-turborepo/node_modules/projen-turborepo/lib/index.js:10:19)
        at Module._compile (node:internal/modules/cjs/loader:1101:14)
        at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
        at Module.load (node:internal/modules/cjs/loader:981:32)
        at Function.Module._load (node:internal/modules/cjs/loader:822:12)
        at Module.require (node:internal/modules/cjs/loader:1005:19) {
      code: 'MODULE_NOT_FOUND',
      requireStack: [
        '/Users/kasperhamalainen/Code/test/projen-turborepo/node_modules/projen-turborepo/lib/index.js',
        '/Users/kasperhamalainen/.npm/_npx/80cfb0dc84733c29/node_modules/projen/lib/projects.js',
        '/Users/kasperhamalainen/.npm/_npx/80cfb0dc84733c29/node_modules/projen/lib/cli/cmds/new.js',
        '/Users/kasperhamalainen/.npm/_npx/80cfb0dc84733c29/node_modules/projen/node_modules/yargs/index.cjs',
        '/Users/kasperhamalainen/.npm/_npx/80cfb0dc84733c29/node_modules/projen/lib/cli/index.js',
        '/Users/kasperhamalainen/.npm/_npx/80cfb0dc84733c29/node_modules/projen/bin/projen'
      ]
    }
    
    opened by miekassu 2
  • TypeScript project references

    TypeScript project references

    Need to figure out how to do TypeScript project references.

    • Docs: https://www.typescriptlang.org/docs/handbook/project-references.html
    • Example with lerna: https://github.com/cipriancaba/ts-monorepo-project-references-example/tree/master/packages/react-app
    • Discussion: https://github.com/projen/projen/issues/9#issuecomment-774615474
    opened by moltar 1
  • remove double `Setup Node.js` job step when node version is set

    remove double `Setup Node.js` job step when node version is set

    When node version is provided, another Setup Node step is added:

    https://github.com/projen/projen/blob/98b1abc07335bbad3384484591344e6f7dffc70c/src/javascript/node-project.ts#L860-L862

    opened by moltar 0
  • Move config to `turbo.json`

    Move config to `turbo.json`

    https://github.com/vercel/turborepo/issues/217

    Warning: Turbo configuration now lives in "turbo.json". Migrate to turbo.json by running "npx @turbo/codemod create-turbo-config"

    opened by moltar 0
  • Error: Cannot find module 'projen-turborepo/.jsii'

    Error: Cannot find module 'projen-turborepo/.jsii'

    ❯ npx projen new --from projen-turborepo --projenrc-ts
    npx: installed 65 in 47.151s
    /Users/foo/Development/tr-test
    └── (empty)
    
    + [email protected]
    added 65 packages from 87 contributors and audited 65 packages in 2.398s
    
    6 packages are looking for funding
      run `npm fund` for details
    
    found 0 vulnerabilities
    
    Wrote to /Users/foo/Development/tr-test/package.json:
    
    {
      "name": "tr-test",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "dependencies": {
        "projen": "0.47.11"
      },
      "devDependencies": {},
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "keywords": [],
      "license": "ISC"
    }
    
    
    👾 installing external module projen-turborepo...
    + [email protected]
    added 2 packages from 2 contributors and audited 67 packages in 3.708s
    
    6 packages are looking for funding
      run `npm fund` for details
    
    found 0 vulnerabilities
    
    Error: Cannot find module 'projen-turborepo/.jsii'
    Require stack:
    - /Users/foo/.npm/_npx/48164/lib/node_modules/projen/lib/cli/cmds/new.js
    - /Users/foo/.npm/_npx/48164/lib/node_modules/projen/node_modules/yargs/index.cjs
    - /Users/foo/.npm/_npx/48164/lib/node_modules/projen/lib/cli/index.js
    - /Users/foo/.npm/_npx/48164/lib/node_modules/projen/bin/projen
        at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
        at Function.resolve (internal/modules/cjs/helpers.js:98:19)
        at initProjectFromModule (/Users/foo/.npm/_npx/48164/lib/node_modules/projen/lib/cli/cmds/new.js:149:44)
        at Object.handler (/Users/foo/.npm/_npx/48164/lib/node_modules/projen/lib/cli/cmds/new.js:69:20)
        at Object.runCommand (/Users/foo/.npm/_npx/48164/lib/node_modules/projen/node_modules/yargs/build/index.cjs:446:48)
        at Object.parseArgs [as _parseArgs] (/Users/foo/.npm/_npx/48164/lib/node_modules/projen/node_modules/yargs/build/index.cjs:2697:57)
        at Function.get [as argv] (/Users/foo/.npm/_npx/48164/lib/node_modules/projen/node_modules/yargs/build/index.cjs:2651:25)
        at main (/Users/foo/.npm/_npx/48164/lib/node_modules/projen/lib/cli/index.js:29:21)
        at Object.<anonymous> (/Users/foo/.npm/_npx/48164/lib/node_modules/projen/lib/cli/index.js:46:1)
        at Module._compile (internal/modules/cjs/loader.js:1072:14) {
      code: 'MODULE_NOT_FOUND',
      requireStack: [
        '/Users/foo/.npm/_npx/48164/lib/node_modules/projen/lib/cli/cmds/new.js',
        '/Users/foo/.npm/_npx/48164/lib/node_modules/projen/node_modules/yargs/index.cjs',
        '/Users/foo/.npm/_npx/48164/lib/node_modules/projen/lib/cli/index.js',
        '/Users/foo/.npm/_npx/48164/lib/node_modules/projen/bin/projen'
      ]
    }
    
    opened by moltar 0
  • dependency project path always points to src

    dependency project path always points to src

    when projen generates paths to project tsconfig.ts it based speficied package dependencies, it always points path to src

    like:

        "paths": {
          "@nordft/core-prismic": [
            "../../packages/core-prismic/src"
          ],
          "@nordft/core-ui": [
            "../../packages/core-ui/src"
          ]
        }
    

    this throws an error:

    Type error: File '/Users/kasperhamalainen/Code/nordft/nordft-monorepo/packages/core-ui/src/index.ts' is not under 'rootDir' '/Users/kasperhamalainen/Code/nordft/nordft-monorepo/apps/nordft-core-frontend'. 'rootDir' is expected to contain all source files.
    

    instead of, this works:

        "paths": {
          "@nordft/core-prismic": [
            "../../packages/core-prismic/*"
          ],
          "@nordft/core-ui": [
            "../../packages/core-ui/*"
          ]
        }
    

    l ooks like projen generated ../src directory in path, no matter what would have been configured in dependency package tsconfig.ts, like outDit or rootDir.

    any ideas?

    opened by miekassu 5
  • Add turbo concurrency equal to number of CPUs

    Add turbo concurrency equal to number of CPUs

    https://nodejs.org/api/os.html#os_os_cpus

    Can get the value this way:

    node -r os -e 'process.stdout.write(os.cpus().length.toString())'
    

    Then include into a step before, and then reference the output in the next step.

    opened by moltar 2
  • refactor turbo config into a class

    refactor turbo config into a class

    Refactor turbo config into a class with helper methods https://github.com/moltar/projen-turborepo/blob/38086573fa3e929f721f3a8b47b49fca78c7a04f/src/index.ts#L217

    E.g.

    project.turbo.addPipeline('build', {
              dependsOn: ['^build'],
              outputs,
            }
    )
    
    opened by moltar 0
  • Workspaces do not work with NPM

    Workspaces do not work with NPM

    https://github.com/npm/cli/issues/3637

    NPM > v7.20.2 does not work with workspaces. You cannot install deps from your monorepo, within your monorepo.

    NPM CLI will always try to install from the NPM registry and will fail with 404.

    Switching to Yarn made it work fine.

    stale 
    opened by moltar 2
  • How to run GitHub Actions Workflows from sub-projects?

    How to run GitHub Actions Workflows from sub-projects?

    Projen skips GitHub actions from the sub-projects.

    Need to figure out a way to add them in.

    The problem is that they all need to be in the root of the repo, which is outside the scope of the projen project outdir.

    opened by moltar 3
Releases(v0.0.63)
Owner
Roman
Have been poking around the web since 1998. Interested in: TypeScript, AWS CDK, data, dbt.
Roman
Remix TypeScript monorepo with Turborepo pipelines, Prisma, PostgreSQL, Docker deploy to Fly.io, pnpm, TailwindCSS and Tsyringe for DI.

Remix template with Turborepo, TypeScript and pnpm. The remix app deploys to fly.io or build to Docker image. Example packages for Database with prisma, Tsyringe dependency injection, UI, and internal TypeScript packages.

Philippe L'ATTENTION 33 Dec 29, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Boilerplate / monorepo setup intended for npm package development

Assemble Package Set up: After creating your new repo from the github template plan out what your package(s) will be named and modify the contents of

Public Assembly 11 Dec 15, 2022
A Turborepo with Strapi v4 (w/ postgres database) + Next.js powered by docker and docker-compose

Turborepo + Strapi + Next.js + Docker A Turborepo with Strapi v4 (w/ postgres database) + Next.js powered by docker and docker-compose. ⚠️ Prerequisit

Elvin Chu 60 Dec 29, 2022
open-source implementation of the Turborepo custom remote cache server.

This project is an open-source implementation of the Turborepo custom remote cache server. If Vercel's official cache server isn't a viable option, th

Maksim Sinik 362 Dec 30, 2022
Fullstack Turborepo starter. Typescript, Nestjs, Nextjs, Tailwind, Prisma, Github Actions, Docker, And Reverse proxy configured

Turborepo (NestJS + Prisma + NextJS + Tailwind + Typescript + Jest) Starter This is fullstack turborepo starter. It comes with the following features.

Ejaz Ahmed 132 Jan 9, 2023
Blog and Resume template with turborepo

Comet-land BLOG DEMO RESUME DEMO Blog and Resume template with turborepo 한국어 문서는 다음 링크에서 확인하실 수 있습니다. Blog Feature ?? Code highlight with line-highlig

hyesung oh 115 Dec 27, 2022
Remix + Cloudflare Workers + DO + Turborepo

Remix + Cloudflare Workers + DO + Turborepo A starter to get you up and going with Remix on Cloudflare with all the latest and greatest. What's inside

Jacob Ebey 38 Dec 12, 2022
A starter template for Remix + Cloudflare Workers + DO + KV + Turborepo

Remix + Cloudflare Workers starter with Turborepo ?? Starter to get going with Remix and Cloudflare Workers. This template is based on the starter cre

Girish 27 Jan 2, 2023
Turborepo starter with pnpm

Turborepo starter with pnpm This is an official starter turborepo. What's inside? This turborepo uses pnpm as a packages manager. It includes the foll

Jack Herrington 23 Dec 18, 2022
Monorepo project that shows the current weather data and weather forecast for next 7 days. Created from scratch to participate in a 14-days hackathon.

Climatic Monorepo project that shows the current weather data and weather forecast for next 7 days. Created from scratch to participate in a 14-days h

Luis Marsiglia 6 Jun 23, 2022
End-to-end typed monorepo template for your next project ⌨️

TYPE ⌨️ TRPC + Yarn Monorepo + Prisma + Expo This template project is a Yarn monorepo with full end-to-end type safety. Powered by: TRPC (on Fastify)

Matteo Lobello 35 Oct 22, 2022
Type predicate functions for checking if a value is of a specific type or asserting that it is.

As-Is Description As-Is contains two modules. Is - Type predicates for checking values are of certain types. As - Asserting values are of a certain ty

Declan Fitzpatrick 8 Feb 10, 2022
Combine type and value imports using Typescript 4.5 type modifier syntax

type-import-codemod Combines your type and value imports together into a single statement, using Typescript 4.5's type modifier syntax. Before: import

Ian VanSchooten 4 Sep 29, 2022
🧬 A type builder for pagination with prisma and type-graphql.

?? Prisma TypeGraphql Pagination Prisma TypeGraphql Pagination builds prisma pagination types for type-graphql. import { ... } from 'type-graphql'

Arthur Fiorette 2 Apr 21, 2022
🐬 A simplified implementation of TypeScript's type system written in TypeScript's type system

?? HypeScript Introduction This is a simplified implementation of TypeScript's type system that's written in TypeScript's type annotations. This means

Ronen Amiel 1.8k Dec 20, 2022
A type programming language which compiles to and interops with type-level TypeScript

Prakaar Prakaar (hindi for "type") is a type programming language which compiles to and interops with type-level TypeScript. Prakaar itself is also a

Devansh Jethmalani 17 Sep 21, 2022