Skip to content

Commit

Permalink
chore: Migrate to pnpm (#728)
Browse files Browse the repository at this point in the history
* chore: migrate to pnpm

* feat(ci): add permissions: read to "test" GH action

* fix(ci): install packages in each step
  • Loading branch information
mittalyashu committed Oct 4, 2022
1 parent cdc34ca commit 65a5914
Show file tree
Hide file tree
Showing 12 changed files with 14,701 additions and 13,972 deletions.
118 changes: 93 additions & 25 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ on:
- "server/**"
- "tests/**"
- "package.json"
- "yarn.lock"
- "pnpm-lock.yaml"
workflow_dispatch:

permissions:
actions: read

jobs:
cache:
name: Cache node_modules directory
Expand All @@ -29,14 +32,27 @@ jobs:
with:
node-version: ${{ matrix.node }}

- name: Cache node_modules
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 7

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- name: Cache .pnpm-store
uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ matrix.os }}-OS-node-v${{ matrix.node }}-yarn-${{ hashFiles('**/yarn.lock') }}
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ matrix.os }}-OS-node-v${{ matrix.node }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ matrix.os }}-OS-node-v${{ matrix.node }}-pnpm-
- name: Install packages
run: yarn --frozen-lockfile
run: pnpm install --frozen-lockfile

theme-unit:
name: Theme / Unit Tests - OS ${{ matrix.os }} - Node v${{ matrix.node }}
Expand All @@ -56,17 +72,30 @@ jobs:
with:
node-version: ${{ matrix.node }}

- name: Cache node_modules
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 7

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- name: Cache .pnpm-store
uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ matrix.os }}-OS-node-v${{ matrix.node }}-yarn-${{ hashFiles('**/yarn.lock') }}
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ matrix.os }}-OS-node-v${{ matrix.node }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ matrix.os }}-OS-node-v${{ matrix.node }}-pnpm-
- name: Install packages
run: yarn --frozen-lockfile
run: pnpm install --frozen-lockfile

- name: Testing
run: yarn workspace @logchimp/theme test:unit
run: pnpm --filter @logchimp/theme test:unit

theme-build:
name: Theme / Build - OS ${{ matrix.os }} - Node v${{ matrix.node }}
Expand All @@ -86,17 +115,30 @@ jobs:
with:
node-version: ${{ matrix.node }}

- name: Cache node_modules
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 7

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- name: Cache .pnpm-store
uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ matrix.os }}-OS-node-v${{ matrix.node }}-yarn-${{ hashFiles('**/yarn.lock') }}
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ matrix.os }}-OS-node-v${{ matrix.node }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ matrix.os }}-OS-node-v${{ matrix.node }}-pnpm-
- name: Install packages
run: yarn --frozen-lockfile
run: pnpm install --frozen-lockfile

- name: Build theme
run: yarn workspace @logchimp/theme build
run: pnpm --filter @logchimp/theme build

api-unit:
name: API / Unit Tests - OS ${{ matrix.os }} - Node v${{ matrix.node }}
Expand All @@ -116,17 +158,30 @@ jobs:
with:
node-version: ${{ matrix.node }}

- name: Cache node_modules
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 7

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- name: Cache .pnpm-store
uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ matrix.os }}-OS-node-v${{ matrix.node }}-yarn-${{ hashFiles('**/yarn.lock') }}
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ matrix.os }}-OS-node-v${{ matrix.node }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ matrix.os }}-OS-node-v${{ matrix.node }}-pnpm-
- name: Install packages
run: yarn --frozen-lockfile
run: pnpm install --frozen-lockfile

- name: Testing
run: yarn workspace @logchimp/api test:unit
run: pnpm --filter @logchimp/api test:unit

api-integration:
name: API / Integration Tests - OS ${{ matrix.os }} - Node v${{ matrix.node }}
Expand Down Expand Up @@ -161,14 +216,27 @@ jobs:
with:
node-version: ${{ matrix.node }}

- name: Cache node_modules
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 7

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- name: Cache .pnpm-store
uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ matrix.os }}-OS-node-v${{ matrix.node }}-yarn-${{ hashFiles('**/yarn.lock') }}
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ matrix.os }}-OS-node-v${{ matrix.node }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ matrix.os }}-OS-node-v${{ matrix.node }}-pnpm-
- name: Install packages
run: yarn --frozen-lockfile
run: pnpm install --frozen-lockfile

- name: Create logchimp config file
run: |
Expand All @@ -185,7 +253,7 @@ jobs:
sh ./scripts/create-config.sh
- name: Testing
run: yarn workspace @logchimp/api test:integration
run: pnpm --filter @logchimp/api test:integration
env:
NODE_ENV: "testing"

Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ server/public

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# tests
coverage
Expand Down
4 changes: 2 additions & 2 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tasks:
- name: Server
openMode: tab-after
command: |
NODE_ENV="development" yarn run dev
NODE_ENV="development" pnpm dev
- name: Server (logs)
openMode: tab-after
command: |
Expand All @@ -34,7 +34,7 @@ tasks:
# export 'APP_SERVER_URL' ENV to file
echo APP_SERVER_URL=http://localhost:3000 > .env
yarn dev
pnpm dev
ports:
- port: 8080
Expand Down
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
auto-install-peers=true
strict-peer-dependencies=false
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const startTime = Date.now();

const theme = require("@logchimp/theme");
// const theme = require("@logchimp/theme");
const api = require("@logchimp/api");

// utils
Expand All @@ -13,10 +13,10 @@ const port = config.server.port || 3000;
const host = config.server.host || "0.0.0.0";

api.listen(port, host, async () => {
if (!config?.theme.standalone) {
const nuxt = await theme();
api.use(nuxt.render);
}
// if (!config?.theme.standalone) {
// const nuxt = await theme();
// api.use(nuxt.render);
// }

logger.info(`LogChimp is running in ${process.env.NODE_ENV}...`);
logger.info(`Listening on port: ${port}`);
Expand Down
10 changes: 3 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@
"bugs": {
"url": "https://github.com/logchimp/logchimp/issues"
},
"workspaces": [
"packages/**"
],
"scripts": {
"build": "yarn workspace @logchimp/theme build",
"dev": "nodemon index.js",
"start": "node index.js"
"start": "node index.js",
"build:theme": "pnpm --filter @logchimp/theme build"
},
"dependencies": {
"@logchimp/api": "0.7.0-beta.0",
Expand All @@ -40,7 +37,6 @@
"codecarrot"
],
"engines": {
"node": ">=16 < 17",
"yarn": ">=1.22"
"node": ">=16 < 17"
}
}
1 change: 1 addition & 0 deletions packages/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@vueuse/components": "^9.3.0",
"@vueuse/core": "^9.3.0",
"@vueuse/head": "^0.9.2",
"axios": "^1.0.0",
"lucide-vue": "npm:lucide-vue-next@^0.91.0",
"pinia": "^2.0.22",
"vue": "^3.2.40",
Expand Down
8 changes: 4 additions & 4 deletions packages/theme/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

The default theme for [LogChimp](https://github.com/logchimp/logchimp).

![test](https://github.com/logchimp/theme/workflows/test/badge.svg?branch=main) [![Storybook](https://cdn.jsdelivr.net/gh/storybookjs/brand@main/badge/badge-storybook.svg)](https://components.logchimp.codecarrot.net/)
![test](https://github.com/logchimp/logchimp/workflows/test/badge.svg?branch=main) [![Storybook](https://cdn.jsdelivr.net/gh/storybookjs/brand@main/badge/badge-storybook.svg)](https://components.logchimp.codecarrot.net/)


![Theme preview](https://cdn.logchimp.codecarrot.net/logchimp-home-preview.png)

# Development

You'll need [Node](https://nodejs.org/) _(see package.json for required engine)_, and [Yarn](https://yarnpkg.com/) installed globally. After that, from the theme's root directory:
You'll need [Node](https://nodejs.org/) _(see package.json for required engine)_, and [pnpm](https://pnpm.io/) installed globally. After that, from the theme's root directory:

```bash
# install dependencies
yarn install
pnpm install

# run development server
yarn dev
pnpm dev
```

0 comments on commit 65a5914

Please sign in to comment.