feat(create-turbo): apply official-starter transform

This commit is contained in:
Turbobot 2025-02-08 13:41:26 -08:00 committed by ryan
parent 3c677957ad
commit 7ad732dcfc
56 changed files with 8762 additions and 0 deletions

19
.direnv/bin/nix-direnv-reload Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -e
if [[ ! -d "/home/ryan/Documents/Code/nazara" ]]; then
echo "Cannot find source directory; Did you move it?"
echo "(Looking for "/home/ryan/Documents/Code/nazara")"
echo 'Cannot force reload with this script - use "direnv reload" manually and then try again'
exit 1
fi
# rebuild the cache forcefully
_nix_direnv_force_reload=1 direnv exec "/home/ryan/Documents/Code/nazara" true
# Update the mtime for .envrc.
# This will cause direnv to reload again - but without re-building.
touch "/home/ryan/Documents/Code/nazara/.envrc"
# Also update the timestamp of whatever profile_rc we have.
# This makes sure that we know we are up to date.
touch -r "/home/ryan/Documents/Code/nazara/.envrc" "/home/ryan/Documents/Code/nazara/.direnv"/*.rc

View File

@ -0,0 +1 @@
/nix/store/01x5k4nlxcpyd85nnr0b9gm89rm8ff4x-source

View File

@ -0,0 +1 @@
/nix/store/m4wcdchjxw2fdyzjp8i6irpc613pchkr-source

View File

@ -0,0 +1 @@
/nix/store/v693fy6xqbw70nfw0gyv66blwpax2l67-source

View File

@ -0,0 +1 @@
/nix/store/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source

View File

@ -0,0 +1 @@
/nix/store/lr0337b15w70fzrxg79xi6zf3bgcm399-nix-shell-env

File diff suppressed because it is too large Load Diff

1
.envrc Normal file
View File

@ -0,0 +1 @@
use flake

61
flake.lock generated Normal file
View File

@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1739019272,
"narHash": "sha256-7Fu7oazPoYCbDzb9k8D/DdbKrC3aU1zlnc39Y8jy/s8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "fa35a3c8e17a3de613240fea68f876e5b4896aec",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

40
flake.nix Normal file
View File

@ -0,0 +1,40 @@
{
description = "Lifetracker";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs =
{ nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (
system:
let
inherit (pkgs.lib) optional optionals;
pkgs = import nixpkgs { inherit system; };
in
with pkgs;
{
devShell = pkgs.mkShell {
buildInputs =
[
bashInteractive
glibcLocales
git
nodejs
pnpm
postgresql
]
++ optional stdenv.isLinux inotify-tools
++ optional stdenv.isDarwin terminal-notifier
++ optionals stdenv.isDarwin (
with darwin.apple_sdk.frameworks;
[
CoreFoundation
CoreServices
]
);
};
}
);
}

1
nazaraa/.dockerignore Normal file
View File

@ -0,0 +1 @@
node_modules

36
nazaraa/.gitignore vendored Normal file
View File

@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
node_modules
.pnp
.pnp.js
# testing
coverage
# next.js
.next/
out/
build
# other
dist/
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local
# turbo
.turbo

75
nazaraa/README.md Normal file
View File

@ -0,0 +1,75 @@
# Turborepo Docker starter
This is a community-maintained example. If you experience a problem, please submit a pull request with a fix. GitHub Issues will be closed.
## Using this example
Run the following command:
```sh
npx create-turbo@latest -e with-docker
```
## What's inside?
This Turborepo includes the following:
### Apps and Packages
- `web`: a [Next.js](https://nextjs.org/) app
- `api`: an [Express](https://expressjs.com/) server
- `@repo/ui`: a React component library
- `@repo/logger`: Isomorphic logger (a small wrapper around console.log)
- `@repo/eslint-config`: ESLint presets
- `@repo/typescript-config`: tsconfig.json's used throughout the monorepo
- `@repo/jest-presets`: Jest configurations
Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).
### Docker
This repo is configured to be built with Docker, and Docker compose. To build all apps in this repo:
```
# Install dependencies
yarn install
# Create a network, which allows containers to communicate
# with each other, by using their container name as a hostname
docker network create app_network
# Build prod using new BuildKit engine
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose -f docker-compose.yml build
# Start prod in detached mode
docker-compose -f docker-compose.yml up -d
```
Open http://localhost:3000.
To shutdown all running containers:
```
# Stop all running containers
docker kill $(docker ps -q) && docker rm $(docker ps -a -q)
```
### Remote Caching
> [!TIP]
> Vercel Remote Cache is free for all plans. Get started today at [vercel.com](https://vercel.com/signup?/signup?utm_source=remote-cache-sdk&utm_campaign=free_remote_cache).
This example includes optional remote caching. In the Dockerfiles of the apps, uncomment the build arguments for `TURBO_TEAM` and `TURBO_TOKEN`. Then, pass these build arguments to your Docker build.
You can test this behavior using a command like:
`docker build -f apps/web/Dockerfile . --build-arg TURBO_TEAM=“your-team-name” --build-arg TURBO_TOKEN=“your-token“ --no-cache`
### Utilities
This Turborepo has some additional tools already setup for you:
- [TypeScript](https://www.typescriptlang.org/) for static type checking
- [ESLint](https://eslint.org/) for code linting
- [Jest](https://jestjs.io) test runner for all things JavaScript
- [Prettier](https://prettier.io) for code formatting

View File

@ -0,0 +1,5 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: ["@repo/eslint-config/server.js"],
};

View File

@ -0,0 +1,47 @@
FROM node:18-alpine AS base
# The web Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker.
# Make sure you update this Dockerfile, the Dockerfile in the web workspace and copy that over to Dockerfile in the docs.
FROM base AS builder
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk update
RUN apk add --no-cache libc6-compat
# Set working directory
WORKDIR /app
RUN yarn global add turbo
COPY . .
RUN turbo prune api --docker
# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
RUN apk update
RUN apk add --no-cache libc6-compat
WORKDIR /app
# First install dependencies (as they change less often)
COPY --from=builder /app/out/json/ .
RUN yarn install
# Build the project and its dependencies
COPY --from=builder /app/out/full/ .
# Uncomment and use build args to enable remote caching
# ARG TURBO_TEAM
# ENV TURBO_TEAM=$TURBO_TEAM
# ARG TURBO_TOKEN
# ENV TURBO_TOKEN=$TURBO_TOKEN
RUN yarn turbo build
FROM base AS runner
WORKDIR /app
# Don't run production as root
RUN addgroup --system --gid 1001 expressjs
RUN adduser --system --uid 1001 expressjs
USER expressjs
COPY --from=installer /app .
CMD node apps/api/dist/index.js

View File

@ -0,0 +1,42 @@
{
"name": "api",
"version": "0.0.0",
"private": true,
"scripts": {
"build": "tsc",
"clean": "rm -rf dist",
"dev": "nodemon --exec \"node -r esbuild-register ./src/index.ts\" -e .ts",
"lint": "tsc --noEmit && eslint \"src/**/*.ts*\" --max-warnings 0",
"start": "node -r esbuild-register ./src/index.ts",
"test": "jest --detectOpenHandles"
},
"jest": {
"preset": "@repo/jest-presets/node"
},
"dependencies": {
"@repo/logger": "*",
"body-parser": "^1.20.2",
"cors": "^2.8.5",
"express": "^4.18.3",
"morgan": "^1.10.0"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@repo/eslint-config": "*",
"@repo/jest-presets": "*",
"@repo/typescript-config": "*",
"@types/body-parser": "^1.19.5",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/morgan": "^1.9.9",
"@types/node": "^20.11.24",
"@types/supertest": "^6.0.2",
"esbuild": "^0.20.1",
"esbuild-register": "^3.5.0",
"eslint": "^8.57.0",
"jest": "^29.7.0",
"nodemon": "^3.1.0",
"supertest": "^6.3.3",
"typescript": "5.5.4"
}
}

View File

@ -0,0 +1,23 @@
import supertest from "supertest";
import { describe, it, expect } from "@jest/globals";
import { createServer } from "../server";
describe("server", () => {
it("status check returns 200", async () => {
await supertest(createServer())
.get("/status")
.expect(200)
.then((res) => {
expect(res.body.ok).toBe(true);
});
});
it("message endpoint says hello", async () => {
await supertest(createServer())
.get("/message/jared")
.expect(200)
.then((res) => {
expect(res.body.message).toBe("hello jared");
});
});
});

View File

@ -0,0 +1,9 @@
import { createServer } from "./server";
import { log } from "@repo/logger";
const port = process.env.PORT || 3001;
const server = createServer();
server.listen(port, () => {
log(`api running on ${port}`);
});

View File

@ -0,0 +1,22 @@
import { json, urlencoded } from "body-parser";
import express, { type Express } from "express";
import morgan from "morgan";
import cors from "cors";
export const createServer = (): Express => {
const app = express();
app
.disable("x-powered-by")
.use(morgan("dev"))
.use(urlencoded({ extended: true }))
.use(json())
.use(cors())
.get("/message/:name", (req, res) => {
return res.json({ message: `hello ${req.params.name}` });
})
.get("/status", (_, res) => {
return res.json({ ok: true });
});
return app;
};

View File

@ -0,0 +1,10 @@
{
"extends": "@repo/typescript-config/base.json",
"compilerOptions": {
"lib": ["ES2015"],
"outDir": "./dist",
"rootDir": "./src"
},
"exclude": ["node_modules"],
"include": ["src"]
}

View File

@ -0,0 +1,9 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: ["@repo/eslint-config/next.js"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: true,
},
};

View File

@ -0,0 +1,52 @@
FROM node:18-alpine AS base
# This Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker.
# Make sure you update both files!
FROM base AS builder
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk update
RUN apk add --no-cache libc6-compat
# Set working directory
WORKDIR /app
RUN yarn global add turbo
COPY . .
RUN turbo prune web --docker
# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
RUN apk update
RUN apk add --no-cache libc6-compat
WORKDIR /app
# First install the dependencies (as they change less often)
COPY --from=builder /app/out/json/ .
RUN yarn install
# Build the project
COPY --from=builder /app/out/full/ .
# Uncomment and use build args to enable remote caching
# ARG TURBO_TEAM
# ENV TURBO_TEAM=$TURBO_TEAM
# ARG TURBO_TOKEN
# ENV TURBO_TOKEN=$TURBO_TOKEN
RUN yarn turbo build
FROM base AS runner
WORKDIR /app
# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public
CMD node apps/web/server.js

View File

@ -0,0 +1,30 @@
## Getting Started
First, run the development server:
```bash
yarn dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
## Learn More
To learn more about Next.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn/foundations/about-nextjs) - an interactive Next.js tutorial.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
## Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_source=github.com&utm_medium=referral&utm_campaign=turborepo-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

5
nazaraa/apps/web/next-env.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.

View File

@ -0,0 +1,10 @@
const path = require("path");
module.exports = {
reactStrictMode: true,
transpilePackages: ["@repo/ui"],
output: "standalone",
experimental: {
outputFileTracingRoot: path.join(__dirname, "../../"),
},
};

View File

@ -0,0 +1,27 @@
{
"name": "web",
"version": "0.0.0",
"private": true,
"scripts": {
"build": "next build",
"dev": "next dev",
"lint": "eslint . --max-warnings 0",
"start": "next start"
},
"dependencies": {
"next": "^14.1.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"@repo/ui": "*"
},
"devDependencies": {
"@next/eslint-plugin-next": "^14.1.1",
"@types/node": "^20.11.24",
"@types/react": "^18.2.61",
"@types/react-dom": "^18.2.19",
"eslint": "^8.57.0",
"@repo/eslint-config": "*",
"@repo/typescript-config": "*",
"typescript": "5.5.4"
}
}

View File

@ -0,0 +1,7 @@
This public directory can be used to store any static content, see:
https://nextjs.org/docs/basic-features/static-file-serving
To remove this directory, also remove the following line from the web `Dockerfile`:
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public

View File

@ -0,0 +1,11 @@
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<body>{children}</body>
</html>
);
}

View File

@ -0,0 +1,67 @@
"use client";
import { useEffect, useState, ChangeEvent, FormEvent } from "react";
import { Button } from "@repo/ui/button";
const API_HOST = process.env.NEXT_PUBLIC_API_HOST || "http://localhost:3001";
export default function Web() {
const [name, setName] = useState<string>("");
const [response, setResponse] = useState<{ message: string } | null>(null);
const [error, setError] = useState<string | undefined>();
useEffect(() => {
setResponse(null);
setError(undefined);
}, [name]);
const onChange = (e: ChangeEvent<HTMLInputElement>) =>
setName(e.target.value);
const onSubmit = async (e: FormEvent<HTMLFormElement>) => {
e.preventDefault();
try {
const result = await fetch(`${API_HOST}/message/${name}`);
const response = await result.json();
setResponse(response);
} catch (err) {
console.error(err);
setError("Unable to fetch response");
}
};
const onReset = () => {
setName("");
};
return (
<div>
<h1>Web</h1>
<form onSubmit={onSubmit}>
<label htmlFor="name">Name </label>
<input
type="text"
name="name"
id="name"
value={name}
onChange={onChange}
></input>
<Button type="submit">Submit</Button>
</form>
{error && (
<div>
<h3>Error</h3>
<p>{error}</p>
</div>
)}
{response && (
<div>
<h3>Greeting</h3>
<p>{response.message}</p>
<Button onClick={onReset}>Reset</Button>
</div>
)}
</div>
);
}

View File

@ -0,0 +1,8 @@
{
"extends": "@repo/typescript-config/nextjs.json",
"compilerOptions": {
"plugins": [{ "name": "next" }]
},
"include": ["next-env.d.ts", "next.config.js", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}

View File

@ -0,0 +1,29 @@
version: "3"
services:
web:
container_name: web
build:
context: .
dockerfile: ./apps/web/Dockerfile
restart: always
ports:
- 3000:3000
networks:
- app_network
api:
container_name: api
build:
context: .
dockerfile: ./apps/api/Dockerfile
restart: always
ports:
- 3001:3001
networks:
- app_network
# Define a network, which allows containers to communicate
# with each other, by using their container name as a hostname
networks:
app_network:
external: true

27
nazaraa/package.json Normal file
View File

@ -0,0 +1,27 @@
{
"name": "with-docker",
"version": "0.0.0",
"private": true,
"workspaces": [
"apps/*",
"packages/*"
],
"scripts": {
"build": "turbo run build",
"clean": "turbo run clean",
"dev": "turbo run dev",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"lint": "turbo run lint",
"test": "turbo run test"
},
"dependencies": {},
"devDependencies": {
"prettier": "^3.2.5",
"turbo": "^2.4.0"
},
"packageManager": "yarn@1.22.19",
"engines": {
"node": ">=14.0.0",
"npm": ">=7.0.0"
}
}

View File

@ -0,0 +1,3 @@
# `@turbo/eslint-config`
Collection of internal eslint configurations.

View File

@ -0,0 +1,34 @@
const { resolve } = require("node:path");
const project = resolve(process.cwd(), "tsconfig.json");
/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: ["eslint:recommended", "prettier", "turbo"],
plugins: ["only-warn"],
globals: {
React: true,
JSX: true,
},
env: {
node: true,
},
settings: {
"import/resolver": {
typescript: {
project,
},
},
},
ignorePatterns: [
// Ignore dotfiles
".*.js",
"node_modules/",
"dist/",
],
overrides: [
{
files: ["*.js?(x)", "*.ts?(x)"],
},
],
};

View File

@ -0,0 +1,42 @@
const { resolve } = require("node:path");
const project = resolve(process.cwd(), "tsconfig.json");
/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: [
"eslint:recommended",
"prettier",
require.resolve("@vercel/style-guide/eslint/next"),
"turbo",
],
globals: {
React: true,
JSX: true,
},
env: {
node: true,
},
plugins: ["only-warn"],
settings: {
"import/resolver": {
typescript: {
project,
},
},
},
ignorePatterns: [
// Ignore dotfiles
".*.js",
"node_modules/",
],
overrides: [
{ files: ["*.js?(x)", "*.ts?(x)"] },
{
files: ["*.ts", "*.tsx"],
rules: {
"no-undef": "off",
},
},
],
};

View File

@ -0,0 +1,20 @@
{
"name": "@repo/eslint-config",
"version": "0.0.0",
"private": true,
"files": [
"library.js",
"next.js",
"react-internal.js",
"server.js"
],
"devDependencies": {
"@vercel/style-guide": "^5.2.0",
"eslint-config-turbo": "^2.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-only-warn": "^1.1.0",
"@typescript-eslint/parser": "^7.1.0",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"typescript": "5.5.4"
}
}

View File

@ -0,0 +1,39 @@
const { resolve } = require("node:path");
const project = resolve(process.cwd(), "tsconfig.json");
/*
* This is a custom ESLint configuration for use with
* internal (bundled by their consumer) libraries
* that utilize React.
*/
/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: ["eslint:recommended", "prettier", "turbo"],
plugins: ["only-warn"],
globals: {
React: true,
JSX: true,
},
env: {
browser: true,
},
settings: {
"import/resolver": {
typescript: {
project,
},
},
},
ignorePatterns: [
// Ignore dotfiles
".*.js",
"node_modules/",
"dist/",
],
overrides: [
// Force ESLint to detect .tsx files
{ files: ["*.js?(x)", "*.ts?(x)"] },
],
};

View File

@ -0,0 +1,19 @@
module.exports = {
extends: ["eslint:recommended"],
env: {
node: true,
es6: true,
},
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
overrides: [
{
files: ["**/__tests__/**/*"],
env: {
jest: true,
},
},
],
};

View File

@ -0,0 +1,17 @@
import type { Config } from "jest";
const config = {
roots: ["<rootDir>"],
transform: {
"^.+\\.tsx?$": "ts-jest",
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
modulePathIgnorePatterns: [
"<rootDir>/test/__fixtures__",
"<rootDir>/node_modules",
"<rootDir>/dist",
],
preset: "ts-jest",
} as const satisfies Config;
export default config;

View File

@ -0,0 +1,13 @@
{
"name": "@repo/jest-presets",
"version": "0.0.0",
"private": true,
"license": "MIT",
"files": [
"node/jest-preset.ts"
],
"dependencies": {
"jest": "^29.7.0",
"ts-jest": "^29.2.5"
}
}

View File

@ -0,0 +1,10 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: ["@repo/eslint-config/react-internal.js"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: true,
},
ignorePatterns: ["**/__tests__/"],
};

View File

@ -0,0 +1,30 @@
{
"name": "@repo/logger",
"version": "0.0.0",
"private": true,
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist/**"
],
"scripts": {
"build": "tsc",
"clean": "rm -rf dist",
"dev": "tsc -w",
"lint": "eslint \"src/**/*.ts*\" --max-warnings 0",
"test": "jest"
},
"jest": {
"preset": "@repo/jest-presets/node"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@repo/eslint-config": "*",
"@repo/jest-presets": "*",
"@repo/typescript-config": "*",
"@types/node": "^20.11.24",
"eslint": "^8.57.0",
"jest": "^29.7.0",
"typescript": "5.5.4"
}
}

View File

@ -0,0 +1,11 @@
import { describe, it, expect, jest } from "@jest/globals";
import { log } from "..";
jest.spyOn(global.console, "log");
describe("@repo/logger", () => {
it("prints a message", () => {
log("hello");
expect(console.log).toHaveBeenCalled();
});
});

View File

@ -0,0 +1,3 @@
export const log = (str: any) => {
console.log("logger: " + str);
};

View File

@ -0,0 +1,11 @@
{
"extends": "@repo/typescript-config/base.json",
"compilerOptions": {
"lib": ["ES2015", "DOM"],
"outDir": "./dist",
"rootDir": "./src",
"types": ["jest", "node"]
},
"include": ["src"],
"exclude": ["node_modules"]
}

View File

@ -0,0 +1,3 @@
# `tsconfig`
These are base shared `tsconfig.json`s from which all other `tsconfig.json`'s inherit from.

View File

@ -0,0 +1,20 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"composite": false,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"inlineSources": false,
"isolatedModules": true,
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true,
"skipLibCheck": true,
"strict": true
},
"exclude": ["node_modules"]
}

View File

@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./base.json",
"compilerOptions": {
"plugins": [{ "name": "next" }],
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"module": "ESNext",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["src", "next-env.d.ts"],
"exclude": ["node_modules"]
}

View File

@ -0,0 +1,9 @@
{
"name": "@repo/typescript-config",
"version": "0.0.0",
"private": true,
"license": "MIT",
"publishConfig": {
"access": "public"
}
}

View File

@ -0,0 +1,10 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./base.json",
"compilerOptions": {
"lib": ["ES2015"],
"target": "ES6",
"jsx": "react-jsx"
},
"exclude": ["node_modules"]
}

View File

@ -0,0 +1,9 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: ["@repo/eslint-config/react-internal.js"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: true,
},
};

View File

@ -0,0 +1,21 @@
{
"name": "@repo/ui",
"version": "0.0.0",
"exports": {
"./button": "./src/button.tsx"
},
"scripts": {
"lint": "eslint \"**/*.ts*\" --max-warnings 0"
},
"devDependencies": {
"@types/react": "^18.2.61",
"@types/react-dom": "^18.2.19",
"eslint": "^8.57.0",
"@repo/eslint-config": "*",
"@repo/typescript-config": "*",
"typescript": "5.5.4"
},
"dependencies": {
"react": "^18.2.0"
}
}

View File

@ -0,0 +1,7 @@
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
children: React.ReactNode;
}
export const Button = ({ children, ...rest }: ButtonProps) => {
return <button {...rest}>{children}</button>;
};

View File

@ -0,0 +1,5 @@
{
"extends": "@repo/typescript-config/react-library.json",
"include": ["."],
"exclude": ["dist", "build", "node_modules"]
}

25
nazaraa/turbo.json Normal file
View File

@ -0,0 +1,25 @@
{
"$schema": "https://turbo.build/schema.json",
"tasks": {
"build": {
"inputs": ["$TURBO_DEFAULT$", ".env*"],
"outputs": ["dist/**", ".next/**", "!.next/cache/**", "public/dist/**"],
"dependsOn": ["^build"],
"env": ["NEXT_PUBLIC_API_HOST"]
},
"test": {
"outputs": ["coverage/**"],
"dependsOn": []
},
"lint": {
"dependsOn": ["^build"]
},
"dev": {
"cache": false,
"persistent": true
},
"clean": {
"cache": false
}
}
}

5603
nazaraa/yarn.lock Normal file

File diff suppressed because it is too large Load Diff