Skip to content

Commit

Permalink
feat(pnpm): add pnpm with workspace
Browse files Browse the repository at this point in the history
* remove yarn
* use lerna with pnpm
  • Loading branch information
srod committed Nov 29, 2022
1 parent 7aa4ae7 commit 5f77464
Show file tree
Hide file tree
Showing 12 changed files with 10,330 additions and 9,898 deletions.
34 changes: 30 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,46 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }} on ${{ matrix.os }}
uses: actions/setup-node@v1

uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: yarn install and test

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

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
yarn install
yarn test
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Run tests
run: pnpm run setup && pnpm test
env:
CI: true

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
Expand Down
8 changes: 6 additions & 2 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
tag-version-prefix=
save-prefix=
save-prefix=""
save-exact = true
tag-version-prefix=""
strict-peer-dependencies = false
auto-install-peers = true
lockfile = true
1 change: 0 additions & 1 deletion .yarnrc

This file was deleted.

14 changes: 7 additions & 7 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ It allow you to compress JavaScript, CSS and HTML files.
## Installation

```bash
npm install @node-minify/core # OR yarn add @node-minify/core
npm install @node-minify/core # OR yarn add @node-minify/core OR pnpm install @node-minify/core
```

And install the compressor you want

```bash
npm install @node-minify/uglify-js # OR yarn add @node-minify/uglify-js
npm install @node-minify/uglify-js # OR yarn add @node-minify/uglify-js OR pnpm install @node-minify/uglify-js
```

## Quick Start
Expand All @@ -64,15 +64,15 @@ minify({
compressor: gcc,
input: 'foo.js',
output: 'bar.js',
callback: function(err, min) {}
callback: function (err, min) {}
});

// Using UglifyJS
minify({
compressor: uglifyjs,
input: './**/*.js',
output: 'bar.js',
callback: function(err, min) {}
callback: function (err, min) {}
});

// Using Promise
Expand All @@ -82,7 +82,7 @@ var promise = minify({
output: 'bar.js'
});

promise.then(function(min) {});
promise.then(function (min) {});

// Async/Await
async function doMinify() {
Expand All @@ -100,7 +100,7 @@ minify({
compressor: gcc,
input: 'foo.js',
output: 'bar.js',
callback: function(err, min) {}
callback: function (err, min) {}
});
```

Expand All @@ -120,7 +120,7 @@ const html = `
minify({
compressor: htmlMinifier,
content: html
}).then(function(min) {
}).then(function (min) {
console.log('html min');
console.log(min);
});
Expand Down
2 changes: 1 addition & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ You can compress files using the command line.
## Installation

```bash
npm install -g @node-minify/cli # OR yarn global add @node-minify/cli
npm install -g @node-minify/cli # OR yarn global add @node-minify/cli OR pnpm add -g @node-minify/cli
```

## Usage
Expand Down
14 changes: 7 additions & 7 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
## Installation

```bash
npm install @node-minify/core # OR yarn add @node-minify/core
npm install @node-minify/core # OR yarn add @node-minify/core OR pnpm install @node-minify/core
```

And install the compressor you want

```bash
npm install @node-minify/uglify-js # OR yarn add @node-minify/uglify-js
npm install @node-minify/uglify-js # OR yarn add @node-minify/uglify-js OR pnpm install @node-minify/uglify-js
```

## Quick Start
Expand All @@ -24,15 +24,15 @@ minify({
compressor: gcc,
input: 'foo.js',
output: 'bar.js',
callback: function(err, min) {}
callback: function (err, min) {}
});

// Using UglifyJS
minify({
compressor: uglifyjs,
input: './**/*.js',
output: 'bar.js',
callback: function(err, min) {}
callback: function (err, min) {}
});

// Using Promise
Expand All @@ -42,7 +42,7 @@ var promise = minify({
output: 'bar.js'
});

promise.then(function(min) {});
promise.then(function (min) {});

// Async/Await
async function doMinify() {
Expand All @@ -60,7 +60,7 @@ minify({
compressor: gcc,
input: 'foo.js',
output: 'bar.js',
callback: function(err, min) {}
callback: function (err, min) {}
});
```

Expand All @@ -80,7 +80,7 @@ const html = `
minify({
compressor: htmlMinifier,
content: html
}).then(function(min) {
}).then(function (min) {
console.log('html min');
console.log(min);
});
Expand Down
5 changes: 1 addition & 4 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
"npmClient": "npm"
}
},
"packages": [
"packages/*"
],
"npmClient": "yarn",
"npmClient": "pnpm",
"useWorkspaces": true,
"version": "6.4.0"
}
43 changes: 31 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,52 @@
"type": "git",
"url": "https://github.com/srod/node-minify.git"
},
"engines": {
"node": ">=14.0.0"
},
"packageManager": "pnpm@7.17.1",
"scripts": {
"setup": "npm run clean:packages && yarn && npm run bootstrap && npm run build",
"bootstrap": "lerna bootstrap",
"setup": "npm run clean:packages && npm run build",
"build": "npm run clean:build && npm run build-js",
"build-js": "lerna exec --parallel -- babel --root-mode upward src --out-dir lib --copy-files",
"build-js": "pnpm lerna exec --parallel -- babel --root-mode upward src --out-dir lib --copy-files",
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs",
"eslint": "eslint --ignore-path .gitignore packages",
"lerna": "lerna",
"lint": "npm run eslint || true",
"pretest": "npm run build && npm run eslint",
"test": "jest",
"posttest": "npm run clean:coverage",
"clean:build": "npx rimraf packages/*/lib",
"clean:coverage": "npx rimraf tests/tmp/*.{js,js.map,css,html}",
"clean:packages": "npx rimraf node_modules packages/*/node_modules",
"showpack": "lerna pack --dry",
"publish-latest": "NPM_CONFIG_OTP=xxx lerna publish --tag-version-prefix ''",
"publish-next": "NPM_CONFIG_OTP=xxx lerna publish --tag-version-prefix '' --preid beta --npm-tag next",
"clean:build": "pnpm dlx rimraf packages/*/lib",
"clean:coverage": "pnpm dlx rimraf tests/tmp/*.{js,js.map,css,html}",
"clean:packages": "pnpm lerna clean -y",
"showpack": "pnpm lerna pack --dry",
"publish-latest": "NPM_CONFIG_OTP=xxx pnpm lerna publish --tag-version-prefix ''",
"publish-next": "NPM_CONFIG_OTP=xxx pnpm lerna publish --tag-version-prefix '' --preid beta --npm-tag next",
"prettier-project": "prettier --write './packages/**/{bin,src,__tests__}/**/*.js'"
},
"devDependencies": {
"@babel/cli": "7.19.3",
"@babel/core": "7.19.6",
"@babel/preset-env": "7.20.2",
"@node-minify/babel-minify": "workspace:*",
"@node-minify/clean-css": "workspace:*",
"@node-minify/cli": "workspace:*",
"@node-minify/core": "workspace:*",
"@node-minify/crass": "workspace:*",
"@node-minify/cssnano": "workspace:*",
"@node-minify/csso": "workspace:*",
"@node-minify/google-closure-compiler": "workspace:*",
"@node-minify/html-minifier": "workspace:*",
"@node-minify/jsonminify": "workspace:*",
"@node-minify/no-compress": "workspace:*",
"@node-minify/run": "workspace:*",
"@node-minify/sqwish": "workspace:*",
"@node-minify/terser": "workspace:*",
"@node-minify/uglify-es": "workspace:*",
"@node-minify/uglify-js": "workspace:*",
"@node-minify/utils": "workspace:*",
"@node-minify/yui": "workspace:*",
"babel-core": "6.26.3",
"babel-jest": "29.3.1",
"babel-preset-env": "1.7.0",
Expand Down Expand Up @@ -69,9 +91,6 @@
"pre-commit": "lint-staged"
}
},
"workspaces": [
"packages/*"
],
"jest": {
"collectCoverage": true,
"coverageDirectory": "<rootDir>/coverage/",
Expand Down
1 change: 1 addition & 0 deletions packages/google-closure-compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"url": "https://github.com/srod/node-minify/issues"
},
"dependencies": {
"@node-minify/run": "^6.4.0",
"@node-minify/utils": "^6.4.0",
"google-closure-compiler-java": "20221102.0.1"
}
Expand Down
Loading

0 comments on commit 5f77464

Please sign in to comment.