Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .claude/commands/update-changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,5 @@ If the user passed `release` or an explicit version string:
- `detailed` for human-readable console output
- `markdown` for PR-ready diff reports
- `json` and `yaml` for programmatic consumption
[PR #3](https://github.com/shakacode/pack-config-diff/pull/3) by [justin808](https://github.com/justin808).
[PR #3](https://github.com/shakacode/pack-config-diff/pull/3) by [justin808](https://github.com/justin808).
```
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
113 changes: 113 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npm run build
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
retention-days: 1

lint:
name: Lint & Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npx eslint .
- run: npx prettier --check .
Comment thread
justin808 marked this conversation as resolved.

typecheck:
name: Type Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- run: npx tsc --noEmit

test:
name: Test (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
node-version: [18, 20, 22]
Comment thread
justin808 marked this conversation as resolved.
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- run: npm ci
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- run: npm test
Comment thread
justin808 marked this conversation as resolved.

cli-smoke:
Comment thread
justin808 marked this conversation as resolved.
name: CLI Smoke Test
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
Comment thread
justin808 marked this conversation as resolved.
- name: Run CLI help
run: node bin/pack-config-diff --help
- name: Compare JS fixtures
run: |
rc=0
node bin/pack-config-diff --left=fixtures/webpack.dev.js --right=fixtures/webpack.prod.js --format=summary > /tmp/smoke-js.txt 2>&1 || rc=$?
cat /tmp/smoke-js.txt
Comment thread
justin808 marked this conversation as resolved.
if [ "$rc" -gt 1 ]; then echo "::error::CLI crashed (exit code $rc)"; exit 1; fi
if [ ! -s /tmp/smoke-js.txt ]; then echo "::error::CLI produced no output"; exit 1; fi
- name: Compare YAML fixtures
run: |
rc=0
node bin/pack-config-diff --left=fixtures/webpack-development-client.yaml --right=fixtures/webpack-production-client.yaml --format=json > /tmp/smoke-yaml.txt 2>&1 || rc=$?
cat /tmp/smoke-yaml.txt
if [ "$rc" -gt 1 ]; then echo "::error::CLI crashed (exit code $rc)"; exit 1; fi
if [ ! -s /tmp/smoke-yaml.txt ]; then echo "::error::CLI produced no output"; exit 1; fi
- name: Compare with markdown output
run: |
rc=0
node bin/pack-config-diff --left=fixtures/webpack.dev.js --right=fixtures/webpack.prod.js --format=markdown > /tmp/smoke-md.txt 2>&1 || rc=$?
cat /tmp/smoke-md.txt
if [ "$rc" -gt 1 ]; then echo "::error::CLI crashed (exit code $rc)"; exit 1; fi
if [ ! -s /tmp/smoke-md.txt ]; then echo "::error::CLI produced no output"; exit 1; fi
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist/
coverage/
node_modules/
*.log
7 changes: 7 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"singleQuote": false,
"trailingComma": "all",
"printWidth": 100,
"tabWidth": 2
}
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,20 @@ Exit Codes:
## Programmatic API

```js
const { DiffEngine, DiffFormatter } = require("pack-config-diff")
const { DiffEngine, DiffFormatter } = require("pack-config-diff");

const engine = new DiffEngine({
includeUnchanged: false,
ignorePaths: ["plugins.*"]
})
ignorePaths: ["plugins.*"],
});

const result = engine.compare(leftConfig, rightConfig, {
leftFile: "webpack.dev.js",
rightFile: "webpack.prod.js"
})
rightFile: "webpack.prod.js",
});

const formatter = new DiffFormatter()
console.log(formatter.formatDetailed(result))
const formatter = new DiffFormatter();
console.log(formatter.formatDetailed(result));
```

## TypeScript build
Expand Down
10 changes: 5 additions & 5 deletions bin/pack-config-diff
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env node
const { run } = require("pack-config-diff")
const { run } = require("pack-config-diff");

try {
const exitCode = run(process.argv.slice(2))
process.exit(exitCode)
const exitCode = run(process.argv.slice(2));
process.exit(exitCode);
} catch (error) {
console.error(error.message)
process.exit(1)
console.error(error.message);
process.exit(1);
}
53 changes: 53 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import eslintConfigPrettier from "eslint-config-prettier";

export default tseslint.config(
{
ignores: ["dist/", "coverage/", "fixtures/", "node_modules/"],
},
eslint.configs.recommended,
...tseslint.configs.recommended,
eslintConfigPrettier,
{
files: ["src/**/*.ts"],
rules: {
"@typescript-eslint/no-explicit-any": "warn",
Comment thread
justin808 marked this conversation as resolved.
},
},
{
files: ["**/*.js"],
rules: {
"@typescript-eslint/no-require-imports": "off",
},
},
{
files: ["jest.config.js"],
languageOptions: {
globals: {
module: "readonly",
},
},
},
{
files: ["test/**/*.js"],
languageOptions: {
globals: {
describe: "readonly",
test: "readonly",
expect: "readonly",
it: "readonly",
beforeEach: "readonly",
afterEach: "readonly",
beforeAll: "readonly",
afterAll: "readonly",
jest: "readonly",
require: "readonly",
module: "readonly",
__dirname: "readonly",
process: "readonly",
console: "readonly",
},
},
},
Comment thread
justin808 marked this conversation as resolved.
Comment thread
justin808 marked this conversation as resolved.
);
10 changes: 5 additions & 5 deletions fixtures/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
class DemoPlugin {
constructor(name) {
this.name = name
this.name = name;
}
}

module.exports = () => ({
mode: "development",
output: {
filename: "bundle.js",
path: "/Users/alice/project/public/packs"
path: "/Users/alice/project/public/packs",
},
optimization: {
minimize: false,
minimizer: [() => "terser"]
minimizer: [() => "terser"],
},
plugins: [new DemoPlugin("demo")]
})
plugins: [new DemoPlugin("demo")],
});
10 changes: 5 additions & 5 deletions fixtures/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
class DemoPlugin {
constructor(name) {
this.name = name
this.name = name;
}
}

module.exports = () => ({
mode: "production",
output: {
filename: "bundle-[contenthash].js",
path: "/home/bob/project/public/packs"
path: "/home/bob/project/public/packs",
},
optimization: {
minimize: true,
minimizer: [() => "swc"]
minimizer: [() => "swc"],
},
plugins: [new DemoPlugin("demo")]
})
plugins: [new DemoPlugin("demo")],
});
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module.exports = {
testMatch: ["**/test/**/*.test.js"],
moduleFileExtensions: ["js", "ts", "json"],
transform: {
"^.+\\.ts$": "ts-jest"
}
}
"^.+\\.ts$": "ts-jest",
},
};
Loading
Loading