Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: change npm to pnpm #477

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/actions/detect-package-manager/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Detect the package manager used
description: Get an output with the package manager used

inputs:

outputs:
npm:
description: 'true if npm is used (by default)'
value: ${{ steps.detectPM.outputs.npm }}
yarn:
description: 'true if yarn is used'
value: ${{ steps.detectPM.outputs.yarn }}
pnpm:
description: 'true if pnpm is used'
value: ${{ steps.detectPM.outputs.pnpm }}
PM:
description: 'The package manager'
value: ${{ steps.detectPM.outputs.PM }}

runs:
using: 'composite'
steps:
# Set the matrix apps that have been affected by all the changes
- name: Check for PM lock file
uses: actions/github-script@v3
id: detectPM
with:
script: |
const pnpm = fs.existsSync('pnpm-lock.yaml');
const yarn = !pnpm ? fs.existsSync('yarn.yaml') : false;
const npm = !pnpm && !yarn;

const PM = pnpm ? 'pnpm' : yarn ? 'yarn' : 'npm';

return { pnpm, yarn, npm, PM };
56 changes: 49 additions & 7 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,84 @@ description: Checkout, setup nodeJs, install and generate

inputs:
registryUrl:
description: 'The registry url where the packages are loacated'
description: 'The registry url where the packages are located'
default: 'https://registry.npmjs.org'
required: false
type: string

generate:
description: 'Do we need to generate the files'
default: true
required: false
type: boolean

NPM_TOKEN:
description: 'The npm token if needed'
required: false

runs:
using: 'composite'
steps:
# Check for the package manager
- name: Check for PM lock file
id: detectPM
shell: bash
run: |
echo "::set-output name=pnpm::$(if [[ -f "pnpm-lock.yaml" ]]; then echo "true"; else echo "false"; fi)"
echo "::set-output name=yarn::$(if [[ -f "yarn.yaml" ]]; then echo "true"; else echo "false"; fi)"
echo "::set-output name=npm::$(if [[ -f "package-lock.json" ]]; then echo "true"; elif ! [[ -f "yarn.lock" || -f "pnpm-lock.yaml" ]]; then echo "true"; else echo "false"; fi)"
echo "::set-output name=PM::$(if [[ -f "pnpm-lock.yaml" ]]; then echo "pnpm"; elif ! [[ -f "yarn.lock" ]]; then echo "yarn"; else echo "npm"; fi)"

- uses: pnpm/[email protected]
if: ${{ steps.detectPM.outputs.pnpm == 'true' }}
with:
version: 7

# We initialize the node action
- name: Use node.js
uses: actions/setup-node@v2
with:
cache: 'npm'
cache: ${{ steps.detectPM.outputs.PM }}
node-version: ${{ matrix.node }}
registry-url: ${{ inputs.registryUrl }}

# We install our dependencies
- name: Run npm install
- name: Run install packages (npm)
shell: bash
if: ${{ steps.detectPM.outputs.npm == 'true' }}
env:
NODE_AUTH_TOKEN: ${{ inputs.NPM_TOKEN }}
run: npm ci --no-audit --no-progress --force --ignore-scripts

- name: Run install packages (yarn)
shell: bash
if: ${{ steps.detectPM.outputs.yarn == 'true' }}
env:
NODE_AUTH_TOKEN: ${{ inputs.NPM_TOKEN }}
run: yarn install --frozen-lockfile --ignore-scripts

- name: Run install packages (pnpm)
shell: bash
if: ${{ steps.detectPM.outputs.pnpm == 'true' }}
env:
NODE_AUTH_TOKEN: ${{ inputs.NPM_TOKEN }}
run: pnpm install --frozen-lockfile --ignore-scripts

# We launch our postinstall scripts
- name: Run npm postinstall
shell: bash
env:
PM: ${{ steps.detectPM.outputs.PM }}
run: |
npm rebuild
npm run install --if-present
npm run prepare --if-present
echo "Using $PM package manager"
$PM rebuild
$PM run --if-present install
$PM run --if-present prepare

# We generate our hapify files
- name: Run npm generate
shell: bash
run: npm run generate
if: ${{ inputs.generate }}
env:
PM: ${{ steps.detectPM.outputs.PM }}
run: $PM run generate
20 changes: 6 additions & 14 deletions .github/workflows/stack-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,12 @@ jobs:
node-version: 16.x
cache: npm

# We install our dependencies
- name: Run npm install
shell: bash
env:
NODE_AUTH_TOKEN: ${{ inputs.NPM_TOKEN }}
run: npm ci --no-audit --no-progress --force --ignore-scripts

# We launch our postinstall scripts
- name: Run npm postinstall
shell: bash
run: |
npm rebuild
npm run install --if-present
npm run prepare --if-present
- name: Install dependencies and generate files
uses: tractr/stack/.github/actions/setup@main
with:
generate: false
registryUrl: ${{ inputs.registryUrl }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Deploy to GitHub Pages
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
persist-credentials: false

- name: Install dependencies and generate files
uses: tractr/stack/.github/actions/setup@main
uses: tractr/stack/.github/actions/setup@test-pnpm
with:
registryUrl: ${{ inputs.registryUrl }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"minio",
"nestjs",
"nrwl",
"pnpm",
"Rext",
"tractr",
"Traxion",
Expand Down
7 changes: 4 additions & 3 deletions libs/nestjs/winston/src/winston-nestjs-logger.format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { inspect } from 'util';

import { Chalk, Instance, Level } from 'chalk';
import safeStringify from 'fast-safe-stringify';
import { Format } from 'logform';
import { format } from 'winston';

export type NestLikeConsoleFormatOptions = {
Expand All @@ -11,9 +12,9 @@ export type NestLikeConsoleFormatOptions = {
colors?: boolean | Level;
};

export const nestLikeConsoleFormat = (
export function nestLikeConsoleFormat(
options: NestLikeConsoleFormatOptions = {},
) => {
): Format {
const { appName = 'Nest', prettyPrint = true, colors = true } = options;

const levelOption = typeof colors !== 'boolean' ? colors : undefined;
Expand Down Expand Up @@ -52,4 +53,4 @@ export const nestLikeConsoleFormat = (
message,
)} - ${formattedMeta}`;
});
};
}
Loading