Skip to content

Commit

Permalink
feat: Migrate to yarn workspaces (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
AjayPoshak authored Nov 2, 2024
1 parent 0e5e694 commit 1f1f3e0
Show file tree
Hide file tree
Showing 15 changed files with 11,361 additions and 9,979 deletions.
28 changes: 9 additions & 19 deletions .github/workflows/lint-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
with:
fetch-depth: 2

- name: Enable corepack
run: corepack enable

- name: Cache turbo build setup
uses: actions/cache@v4
with:
Expand All @@ -30,35 +33,22 @@ jobs:
restore-keys: |
${{ runner.os }}-turbo-
- uses: pnpm/action-setup@v3
with:
version: 8

- name: Cache pnpm store
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'


- name: Install dependencies
run: pnpm install
run: yarn install --immutable

- name: Lint
run: pnpm lint
run: yarn lint

- name: Check Formatting
run: pnpm check:format
run: yarn check:format

- name: Build
run: pnpm build
run: yarn build

- name: Test
run: pnpm test
run: yarn test
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,12 @@ yarn-error.log*
# Misc
.DS_Store
*.pem

.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

.yarn/releases
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ This monorepo includes the following packages/apps:

Ensure you have the following installed:
- node.js (v18.17.0 or later)
- pnpm (v9.10.0 or later)
- yarn (v4.5.1)

```bash
nvm install 18.17.0
nvm use 18.17.0
```

```bash
npm install -g pnpm@9.10.0
corepack enable
```

> If you're unfamiliar with pnpm, it’s an alternative package manager that is faster and more efficient than npm. Learn more about pnpm [here](https://pnpm.io/).
> If you're unfamiliar with yarn, it’s an alternative package manager that is faster and more efficient than npm. Learn more about yarn [here](https://yarnpkg.com/getting-started).


Expand All @@ -52,7 +52,7 @@ Clone the repository and install the dependencies:
```bash
git clone <repository-url>
cd alloy
pnpm install
yarn install
```

> [!NOTE]
Expand All @@ -64,7 +64,7 @@ To build all apps and packages, run the following command:

```
cd alloy
pnpm build
yarn build
```

#### Build a specific package/app
Expand All @@ -73,20 +73,20 @@ To build a specific package/app, run the following command:

```
cd alloy
pnpm build --filter @dicedb/playground-web
yarn build --filter @dicedb/playground-web
```

These commands will not only build the package requested but also build all the dependencies of the package requested.

> We also have a `pnpm build:playground` alias that does the same thing as `pnpm build --filter @dicedb/playground-web` for convenience.
> We also have a `yarn build:playground` alias that does the same thing as `yarn build --filter @dicedb/playground-web` for convenience.
### Develop

To develop all apps and packages, run the following command:

```
cd alloy
pnpm dev
yarn dev
```

#### Develop a specific package/app
Expand All @@ -95,12 +95,12 @@ To develop a specific package/app, run the following command:

```
cd alloy
pnpm dev --filter @dicedb/playground-web
yarn dev --filter @dicedb/playground-web
```

These commands will not only start the development server for the package requested but also start the development server for all the dependencies of the package requested.

> We also have a `pnpm dev:playground` alias that does the same thing as `pnpm dev --filter @dicedb/playground-web` for convenience.
> We also have a `yarn dev:playground` alias that does the same thing as `yarn dev --filter @dicedb/playground-web` for convenience.

### Testing
Expand All @@ -109,7 +109,7 @@ To run tests for all apps and packages, run the following command:

```
cd alloy
pnpm test
yarn test
```

#### Test in Watch Mode
Expand All @@ -118,7 +118,7 @@ To run tests in watch mode for all apps and packages, run the following command:

```
cd alloy
pnpm test:watch
yarn test:watch
```


Expand All @@ -129,7 +129,7 @@ To format all apps and packages, run the following command:

```
cd alloy
pnpm format
yarn format
```

### Linting
Expand All @@ -138,7 +138,7 @@ To lint all apps and packages, run the following command:

```
cd alloy
pnpm lint
yarn lint
```

## The Monorepo Structure
Expand Down
6 changes: 3 additions & 3 deletions apps/console-electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "main.js",
"type": "module",
"scripts": {
"dev": "concurrently --kill-others \"next dev -p ${PORT-4000}\" \"electron .\"",
"dev": "concurrently --kill-others \"next dev -p ${PORT:-4000}\" \"electron .\"",
"dev:next": "next dev",
"build": "next build",
"start": "next start",
Expand All @@ -17,8 +17,8 @@
"react-dom": "^18"
},
"devDependencies": {
"@dicedb/eslint-config": "workspace:*",
"@dicedb/typescript-config": "workspace:*",
"@dicedb/eslint-config": "*",
"@dicedb/typescript-config": "*",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
Expand Down
14 changes: 7 additions & 7 deletions apps/playground-web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN npm i -g pnpm@9.10.0
RUN corepack enable
RUN corepack prepare yarn@4.5.1 --activate

FROM base AS build
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run -r build
RUN pnpm deploy --filter=playground-web --prod /prod/playground-web
RUN --mount=type=cache,target=/usr/src/app/.yarn/cache \
yarn install --immutable
RUN yarn -r build
RUN yarn workspace playground-web pack --out-dir /prod/playground-web

FROM base
COPY --from=build /prod/playground-web /prod/playground-web
WORKDIR /prod/playground-web
EXPOSE 8000
CMD [ "pnpm", "start" ]
CMD [ "yarn", "start" ]
14 changes: 7 additions & 7 deletions apps/playground-web/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN npm i -g pnpm@9.10.0
RUN corepack enable
RUN corepack prepare yarn@4.5.1 --activate

FROM base AS build
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run -r build
RUN pnpm deploy --filter=playground-web --prod /prod/playground-web
RUN --mount=type=cache,target=/usr/src/app/.yarn/cache \
yarn install --immutable
RUN yarn run -r build
RUN yarn workspace playground-web pack --out-dir /prod/playground-web

FROM base
COPY --from=build /prod/playground-web /prod/playground-web
WORKDIR /prod/playground-web
EXPOSE 3000
CMD [ "pnpm", "dev" ]
CMD [ "yarn", "dev" ]
20 changes: 11 additions & 9 deletions apps/playground-web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Clone the repository and install the dependencies:
```bash
git clone <repository-url>
cd apps/playground-web
pnpm install
yarn install
```

## Environment Variables
Expand All @@ -32,7 +32,7 @@ NEXT_PUBLIC_PLAYGROUND_MONO_URL=http://localhost:8080/
To start the development server, run:

```bash
pnpm run dev
yarn run dev
```

This will launch the app on [http://localhost:3000](http://localhost:3000). The app will automatically reload if you make changes to the code.
Expand Down Expand Up @@ -89,7 +89,7 @@ To ensure consistent code formatting, we use Prettier. It runs automatically as
To run Prettier and fix formatting issues locally:

```bash
pnpm run prettier:format
yarn run prettier:format
```

This command will format all `.js`, `.jsx`, `.ts`, `.tsx`, `.json`, and `.css` files.
Expand All @@ -108,15 +108,17 @@ To generate a static production build of your Next.js application, follow these
Ensure that you have the following line in your `next.config.mjs` file:

```javascript
output: 'export'
output: 'export';
```

2. **Build the Project:**

Run the following command in your terminal:

```bash
npm run build
```

3. **Testing static build locally:**
```bash
npx serve@latest out
Expand All @@ -127,33 +129,33 @@ To generate a static production build of your Next.js application, follow these
To create a production build:

```bash
pnpm run build
yarn run build
```

After the build is complete, you can start the production server with:

```bash
pnpm run start
yarn run start
```

## Running the Test Cases

To run the test cases, execute the following command:

```bash
pnpm run test
yarn run test
```

To execute the test cases simultaneously as you make changes to the files, execute the following command:

```bash
pnpm run test:watch
yarn run test:watch
```

To get the test coverage of the project, execute the following command:

```bash
pnpm run test:coverage
yarn run test:coverage
```

## Project Structure
Expand Down
8 changes: 4 additions & 4 deletions apps/playground-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:coverage": "jest --coverage"
},
"dependencies": {
"@dicedb/ui": "workspace:*",
"@dicedb/ui": "*",
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@mui/icons-material": "^6.1.1",
Expand All @@ -33,9 +33,9 @@
"zod": "^3.23.8"
},
"devDependencies": {
"@dicedb/eslint-config": "workspace:*",
"@dicedb/tailwind-config": "workspace:*",
"@dicedb/typescript-config": "workspace:*",
"@dicedb/eslint-config": "*",
"@dicedb/tailwind-config": "*",
"@dicedb/typescript-config": "*",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.1",
Expand Down
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@
"turbo": "^2.1.3",
"typescript": "^5.4.5"
},
"packageManager": "pnpm@8.15.6",
"workspaces": {
"packages": [
"apps/*",
"packages/*",
"tooling/*"
]
},
"engines": {
"node": ">=18"
}
},
"packageManager": "yarn@4.5.1"
}
10 changes: 5 additions & 5 deletions packages/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ import CLI from '@dicedb/ui/CLI';

```jsonc
{
/* package.json */
"dependencies": {
"@dicedb/ui": "workspace:*"
}
/* package.json */
"dependencies": {
"@dicedb/ui": "workspace:*",
},
}
```

## Adding a new component

```shell
cd ./packages/ui
pnpm generate:component
yarn generate:component

```
Loading

0 comments on commit 1f1f3e0

Please sign in to comment.