Skip to content

Commit da19a60

Browse files
authored
Merge pull request #8 from toothlessdev/7-setup-esbuild-build-script
Setup esbuild build script
2 parents 430eaf7 + 42d85a0 commit da19a60

42 files changed

Lines changed: 215 additions & 92 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

eslint.config.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default tseslint.config(
1111
"**/node_modules/**",
1212
"**/.turbo/**",
1313
"**/coverage/**",
14+
"**/.coverage/**",
1415
"**/.yarn/**",
1516
"**/.pnp.*",
1617
"**/*.mjs",
@@ -48,11 +49,19 @@ export default tseslint.config(
4849
argsIgnorePattern: "^_",
4950
},
5051
],
52+
"@typescript-eslint/consistent-type-imports": [
53+
"error",
54+
{
55+
prefer: "type-imports",
56+
disallowTypeAnnotations: false,
57+
},
58+
],
5159
},
5260
},
5361
{
5462
files: ["**/*.{test,spec}.{ts,tsx,js,jsx}"],
5563
rules: {
64+
"@typescript-eslint/no-explicit-any": "off",
5665
"no-restricted-imports": [
5766
"error",
5867
{

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"build": "turbo run build --cache-dir=.turbo",
1111
"test": "turbo run test --cache-dir=.turbo",
1212
"lint": "turbo run lint --cache-dir=.turbo",
13+
"lint:fix": "turbo run lint:fix --cache-dir=.turbo",
1314
"typecheck": "turbo run typecheck --cache-dir=.turbo",
1415
"clean": "turbo run clean && rm -rf node_modules .turbo"
1516
},

packages/patchlogr-cli/esbuild.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ await build({
55
entryPoints: [path.resolve("src/index.ts")],
66
outfile: "dist/index.js",
77
platform: "node",
8+
bundle: true,
9+
sourcemap: true,
810
banner: {
911
js: "#!/usr/bin/env node",
1012
},

packages/patchlogr-cli/package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,24 @@
44
"publishConfig": {
55
"access": "public"
66
},
7+
"bin": {
8+
"patchlogr": "./dist/index.js"
9+
},
710
"scripts": {
811
"clean": "rm -rf dist",
912
"typecheck": "tsc -p tsconfig.json --noEmit",
1013
"build:types": "tsc -p tsconfig.json --emitDeclarationOnly",
1114
"build:js": "node ./esbuild.mjs",
1215
"build": "yarn clean && yarn build:types && yarn build:js",
16+
"preview": "node dist/index.js",
1317
"test": "vitest",
14-
"lint": "eslint ."
18+
"lint": "eslint .",
19+
"lint:fix": "eslint . --fix"
1520
},
1621
"dependencies": {
17-
"@patchlogr/core": "workspace:*"
22+
"@patchlogr/core": "workspace:*",
23+
"@patchlogr/oas": "workspace:*",
24+
"commander": "^14.0.2"
1825
},
1926
"devDependencies": {
2027
"@types/node": "24",

packages/patchlogr-cli/src/cli.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Command } from "commander";
2+
3+
export function createCLI() {
4+
const program = new Command();
5+
6+
program
7+
.name("patchlogr")
8+
.version("0.0.0")
9+
.description("PatchlogrCLI : changelogs from openapi specs");
10+
11+
program
12+
.command("help")
13+
.description("Display help information about patchlogr commands");
14+
15+
program
16+
.command("canonicalize")
17+
.argument("<api-docs>", "Path to the OpenAPI specification file")
18+
.option("--canonicalize", "Canonicalize the OpenAPI specification")
19+
.option(
20+
"--skipValidation",
21+
"Skip validation of the OpenAPI specification",
22+
)
23+
.option(
24+
"-o, --output <file>",
25+
"Write result to file instead of stdout (default: stdout)",
26+
)
27+
.action(async (apiDocs, options) => {
28+
try {
29+
console.log("[patchlogr] Processing:", apiDocs, options);
30+
} catch (error) {
31+
console.error("[patchlogr] Error:", (error as Error).message);
32+
process.exitCode = 1;
33+
}
34+
});
35+
36+
return program;
37+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { preprocessOASDocument } from "@patchlogr/oas";
2+
import { type OASStageOptions } from "@patchlogr/oas";
3+
4+
export type RunCanonicalizeOptions = OASStageOptions;
5+
6+
export async function runCanonicalize(
7+
apiDocs: any,
8+
options: RunCanonicalizeOptions,
9+
) {
10+
preprocessOASDocument(apiDocs, { ...options });
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { createCLI } from "./cli";
2+
3+
const program = createCLI();
4+
5+
program.parseAsync(process.argv).catch((error) => {
6+
console.error("[patchlogr] Error:", error);
7+
process.exitCode = 1;
8+
});

packages/patchlogr-core/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"build:js": "node ./esbuild.mjs",
2323
"build": "yarn clean && yarn build:types && yarn build:js",
2424
"test": "vitest",
25-
"lint": "eslint ."
25+
"lint": "eslint .",
26+
"lint:fix": "eslint . --fix"
2627
},
2728
"dependencies": {
2829
"@apidevtools/swagger-parser": "^12.1.0",

packages/patchlogr-oas/esbuild.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { build } from "esbuild";
2+
import pkg from "./package.json" with { type: "json" };
3+
4+
await build({
5+
entryPoints: ["src/index.ts"],
6+
outdir: "dist",
7+
bundle: true,
8+
platform: "node",
9+
target: ["node18", "node20", "node24"],
10+
format: "esm",
11+
sourcemap: true,
12+
external: [
13+
...Object.keys(pkg.dependencies || {}),
14+
...Object.keys(pkg.peerDependencies || {}),
15+
],
16+
});

packages/patchlogr-oas/package.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,24 @@
55
"access": "public"
66
},
77
"scripts": {
8+
"clean": "rm -rf dist",
89
"lint": "eslint .",
10+
"lint:fix": "eslint . --fix",
911
"test": "vitest",
10-
"typecheck": "tsc --noEmit"
12+
"typecheck": "tsc --noEmit",
13+
"build:types": "tsc -p tsconfig.json --emitDeclarationOnly",
14+
"build:js": "node ./esbuild.mjs",
15+
"build": "yarn clean && yarn build:types && yarn build:js"
16+
},
17+
"exports": {
18+
".": {
19+
"import": "./dist/index.js",
20+
"types": "./dist/index.d.ts"
21+
}
1122
},
1223
"devDependencies": {
1324
"@types/node": "24",
25+
"esbuild": "^0.27.2",
1426
"openapi-types": "^12.1.3",
1527
"vitest": "^4.0.16"
1628
},

0 commit comments

Comments
 (0)