From 165f34c8b9fecc0595f97f97a5b9ca75c4eacfb4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 29 Oct 2025 18:18:42 +0000 Subject: [PATCH 1/7] Initial plan From 5423b8e39badd27907a0b1db62f212ac8f91b37a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 29 Oct 2025 18:31:01 +0000 Subject: [PATCH 2/7] Fix npm build to include esm/src and script/src directories Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com> --- scripts/build_npm.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/scripts/build_npm.ts b/scripts/build_npm.ts index e2852eb..a1a5dc4 100644 --- a/scripts/build_npm.ts +++ b/scripts/build_npm.ts @@ -1,4 +1,4 @@ -import { build, emptyDir, copy } from "./deps.ts"; +import { build, copy, emptyDir } from "./deps.ts"; // Clear NPM directory await emptyDir("./npm"); @@ -16,7 +16,7 @@ await build({ mappings: { "https://deno.land/x/zipjs@v2.7.17/index.js": { name: "@zip.js/zip.js", - version: "^2.7.17" + version: "^2.7.17", }, }, package: { @@ -26,14 +26,14 @@ await build({ description: "ENTSO-e transparency platform API Client. Complete. Easy to use. Minimal.", license: "MIT", repository: { - type: "git", - url: "git+https://github.com/Hexagon/entsoe-api-client.git" + type: "git", + url: "git+https://github.com/Hexagon/entsoe-api-client.git", }, author: "Hexagon ", bugs: { - url: "https://github.com/Hexagon/entsoe-api-client/issues" + url: "https://github.com/Hexagon/entsoe-api-client/issues", }, - homepage: "https://github.com/Hexagon/entsoe-api-client#readme" + homepage: "https://github.com/Hexagon/entsoe-api-client#readme", }, }); @@ -41,6 +41,12 @@ await build({ Deno.copyFileSync("LICENSE", "npm/LICENSE"); Deno.copyFileSync("README.md", "npm/README.md"); +// Fix the .npmignore file to prevent exclusion of esm/src/ and script/src/ +// DNT generates "src/" which matches all src directories, but we only want to exclude the root src/ +let npmignore = await Deno.readTextFile("npm/.npmignore"); +npmignore = npmignore.replace(/^src\/$/m, "/src/"); +await Deno.writeTextFile("npm/.npmignore", npmignore); + // npmignore test data // ensure the test data is ignored in the `.npmignore` file // so it doesn't get published with your npm package @@ -48,4 +54,4 @@ await Deno.writeTextFile( "npm/.npmignore", "esm/tests/data\nscript/tests/data\n", { append: true }, -); \ No newline at end of file +); From a2984985f4a36ae0c315059e4ae0fb30ec633e75 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 29 Oct 2025 18:33:49 +0000 Subject: [PATCH 3/7] Add npm package verification script Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com> --- deno.jsonc | 3 +- scripts/verify_npm_package.ts | 125 ++++++++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 scripts/verify_npm_package.ts diff --git a/deno.jsonc b/deno.jsonc index 8e8938f..d5b235a 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -13,6 +13,7 @@ "coverage:ci": "deno task clean && deno test tests --allow-read --coverage=coverage && deno coverage coverage --lcov --output=cov.lcov", "precommit": "deno task clean && deno fmt && deno lint && deno task test && deno task build", "update-deps": "deno run --allow-read=. --allow-net=deno.land,cdn.deno.land,unpkg.com https://deno.land/x/udd/main.ts --dry-run deps.ts scripts/deps.ts", - "build": "deno run -A scripts/build_npm.ts" + "build": "deno run -A scripts/build_npm.ts", + "verify-package": "deno run --allow-run --allow-read scripts/verify_npm_package.ts" } } \ No newline at end of file diff --git a/scripts/verify_npm_package.ts b/scripts/verify_npm_package.ts new file mode 100644 index 0000000..55547bc --- /dev/null +++ b/scripts/verify_npm_package.ts @@ -0,0 +1,125 @@ +#!/usr/bin/env -S deno run --allow-run --allow-read + +/** + * Verification script to ensure the npm package contains the required files + * Run this after building the npm package to verify it will work correctly + */ + +// Check if npm directory exists +try { + await Deno.stat("npm"); +} catch { + console.error("āŒ npm directory not found. Run 'deno task build ' first."); + Deno.exit(1); +} + +console.log("šŸ” Verifying npm package structure...\n"); + +// Check critical directories exist +const criticalDirs = [ + "npm/esm/src", + "npm/script/src", + "npm/esm/src/documents", + "npm/script/src/documents", + "npm/esm/src/definitions", + "npm/script/src/definitions", +]; + +let hasErrors = false; + +for (const dir of criticalDirs) { + try { + const stat = await Deno.stat(dir); + if (stat.isDirectory) { + console.log(`āœ… ${dir} exists`); + } else { + console.error(`āŒ ${dir} exists but is not a directory`); + hasErrors = true; + } + } catch { + console.error(`āŒ ${dir} not found`); + hasErrors = true; + } +} + +// Check .npmignore file +console.log("\nšŸ” Checking .npmignore file...\n"); + +try { + const npmignore = await Deno.readTextFile("npm/.npmignore"); + const lines = npmignore.split("\n"); + + if (lines[0] === "/src/") { + console.log("āœ… .npmignore correctly excludes only root /src/ directory"); + } else if (lines[0] === "src/") { + console.error( + 'āŒ .npmignore has "src/" which would exclude esm/src/ and script/src/', + ); + hasErrors = true; + } else { + console.warn(`āš ļø .npmignore first line is unexpected: ${lines[0]}`); + } +} catch (error) { + console.error(`āŒ Could not read .npmignore: ${error.message}`); + hasErrors = true; +} + +// Run npm pack --dry-run to check what would be published +console.log("\nšŸ” Checking npm pack output...\n"); + +try { + const process = new Deno.Command("npm", { + args: ["pack", "--dry-run"], + cwd: "npm", + stdout: "piped", + stderr: "piped", + }); + + const { stdout, stderr } = await process.output(); + const output = new TextDecoder().decode(stdout) + + new TextDecoder().decode(stderr); + + const esmSrcCount = (output.match(/esm\/src\//g) || []).length; + const scriptSrcCount = (output.match(/script\/src\//g) || []).length; + + if (esmSrcCount > 0) { + console.log(`āœ… esm/src/ files in package: ${esmSrcCount}`); + } else { + console.error("āŒ No esm/src/ files found in package!"); + hasErrors = true; + } + + if (scriptSrcCount > 0) { + console.log(`āœ… script/src/ files in package: ${scriptSrcCount}`); + } else { + console.error("āŒ No script/src/ files found in package!"); + hasErrors = true; + } + + // Check that root src is NOT included + const rootSrcPattern = /\ssrc\//; + const rootSrcMatches = output.split("\n").filter((line) => + line.match(rootSrcPattern) && !line.includes("esm/src/") && + !line.includes("script/src/") + ); + + if (rootSrcMatches.length === 0) { + console.log("āœ… Root src/ directory correctly excluded from package"); + } else { + console.error( + `āŒ Root src/ files incorrectly included in package: ${rootSrcMatches.length}`, + ); + hasErrors = true; + } +} catch (error) { + console.error(`āŒ Could not run npm pack: ${error.message}`); + hasErrors = true; +} + +if (hasErrors) { + console.error("\nāŒ Package verification failed!"); + Deno.exit(1); +} else { + console.log("\nāœ… Package verification passed! Ready to publish."); + Deno.exit(0); +} From 11e865ebb02ba3f7debb58ed43be8a9d493431fe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 29 Oct 2025 18:37:15 +0000 Subject: [PATCH 4/7] Address code review feedback for verification script Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com> --- scripts/verify_npm_package.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/verify_npm_package.ts b/scripts/verify_npm_package.ts index 55547bc..f911a81 100644 --- a/scripts/verify_npm_package.ts +++ b/scripts/verify_npm_package.ts @@ -3,6 +3,10 @@ /** * Verification script to ensure the npm package contains the required files * Run this after building the npm package to verify it will work correctly + * + * Required permissions: + * --allow-run: To execute npm pack --dry-run command + * --allow-read: To read npm/.npmignore and check directory structure */ // Check if npm directory exists @@ -76,8 +80,15 @@ try { }); const { stdout, stderr } = await process.output(); - const output = new TextDecoder().decode(stdout) + - new TextDecoder().decode(stderr); + const stdoutText = new TextDecoder().decode(stdout); + const stderrText = new TextDecoder().decode(stderr); + + // Log stderr separately if there are any messages (usually warnings) + if (stderrText.trim()) { + console.log("npm pack warnings/errors:", stderrText); + } + + const output = stdoutText + stderrText; const esmSrcCount = (output.match(/esm\/src\//g) || []).length; const scriptSrcCount = (output.match(/script\/src\//g) || []).length; @@ -97,7 +108,8 @@ try { } // Check that root src is NOT included - const rootSrcPattern = /\ssrc\//; + // Match 'src/' at the beginning of a line or after whitespace, but not as part of a path + const rootSrcPattern = /(?:^|\s)src\//; const rootSrcMatches = output.split("\n").filter((line) => line.match(rootSrcPattern) && !line.includes("esm/src/") && !line.includes("script/src/") From df7e0cfeed3850256c655e811031e2fd49b98361 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 29 Oct 2025 18:49:11 +0000 Subject: [PATCH 5/7] Remove verification script and improve comments with root cause analysis Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com> --- deno.jsonc | 3 +- scripts/build_npm.ts | 4 +- scripts/verify_npm_package.ts | 137 ---------------------------------- 3 files changed, 4 insertions(+), 140 deletions(-) delete mode 100644 scripts/verify_npm_package.ts diff --git a/deno.jsonc b/deno.jsonc index d5b235a..8e8938f 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -13,7 +13,6 @@ "coverage:ci": "deno task clean && deno test tests --allow-read --coverage=coverage && deno coverage coverage --lcov --output=cov.lcov", "precommit": "deno task clean && deno fmt && deno lint && deno task test && deno task build", "update-deps": "deno run --allow-read=. --allow-net=deno.land,cdn.deno.land,unpkg.com https://deno.land/x/udd/main.ts --dry-run deps.ts scripts/deps.ts", - "build": "deno run -A scripts/build_npm.ts", - "verify-package": "deno run --allow-run --allow-read scripts/verify_npm_package.ts" + "build": "deno run -A scripts/build_npm.ts" } } \ No newline at end of file diff --git a/scripts/build_npm.ts b/scripts/build_npm.ts index a1a5dc4..4be5344 100644 --- a/scripts/build_npm.ts +++ b/scripts/build_npm.ts @@ -42,7 +42,9 @@ Deno.copyFileSync("LICENSE", "npm/LICENSE"); Deno.copyFileSync("README.md", "npm/README.md"); // Fix the .npmignore file to prevent exclusion of esm/src/ and script/src/ -// DNT generates "src/" which matches all src directories, but we only want to exclude the root src/ +// DNT 0.37.0 generates "src/" in .npmignore by default (when not using source maps). +// This pattern inadvertently excludes esm/src/ and script/src/ containing transpiled code. +// Replace "src/" with "/src/" to only match the root TypeScript source directory. let npmignore = await Deno.readTextFile("npm/.npmignore"); npmignore = npmignore.replace(/^src\/$/m, "/src/"); await Deno.writeTextFile("npm/.npmignore", npmignore); diff --git a/scripts/verify_npm_package.ts b/scripts/verify_npm_package.ts deleted file mode 100644 index f911a81..0000000 --- a/scripts/verify_npm_package.ts +++ /dev/null @@ -1,137 +0,0 @@ -#!/usr/bin/env -S deno run --allow-run --allow-read - -/** - * Verification script to ensure the npm package contains the required files - * Run this after building the npm package to verify it will work correctly - * - * Required permissions: - * --allow-run: To execute npm pack --dry-run command - * --allow-read: To read npm/.npmignore and check directory structure - */ - -// Check if npm directory exists -try { - await Deno.stat("npm"); -} catch { - console.error("āŒ npm directory not found. Run 'deno task build ' first."); - Deno.exit(1); -} - -console.log("šŸ” Verifying npm package structure...\n"); - -// Check critical directories exist -const criticalDirs = [ - "npm/esm/src", - "npm/script/src", - "npm/esm/src/documents", - "npm/script/src/documents", - "npm/esm/src/definitions", - "npm/script/src/definitions", -]; - -let hasErrors = false; - -for (const dir of criticalDirs) { - try { - const stat = await Deno.stat(dir); - if (stat.isDirectory) { - console.log(`āœ… ${dir} exists`); - } else { - console.error(`āŒ ${dir} exists but is not a directory`); - hasErrors = true; - } - } catch { - console.error(`āŒ ${dir} not found`); - hasErrors = true; - } -} - -// Check .npmignore file -console.log("\nšŸ” Checking .npmignore file...\n"); - -try { - const npmignore = await Deno.readTextFile("npm/.npmignore"); - const lines = npmignore.split("\n"); - - if (lines[0] === "/src/") { - console.log("āœ… .npmignore correctly excludes only root /src/ directory"); - } else if (lines[0] === "src/") { - console.error( - 'āŒ .npmignore has "src/" which would exclude esm/src/ and script/src/', - ); - hasErrors = true; - } else { - console.warn(`āš ļø .npmignore first line is unexpected: ${lines[0]}`); - } -} catch (error) { - console.error(`āŒ Could not read .npmignore: ${error.message}`); - hasErrors = true; -} - -// Run npm pack --dry-run to check what would be published -console.log("\nšŸ” Checking npm pack output...\n"); - -try { - const process = new Deno.Command("npm", { - args: ["pack", "--dry-run"], - cwd: "npm", - stdout: "piped", - stderr: "piped", - }); - - const { stdout, stderr } = await process.output(); - const stdoutText = new TextDecoder().decode(stdout); - const stderrText = new TextDecoder().decode(stderr); - - // Log stderr separately if there are any messages (usually warnings) - if (stderrText.trim()) { - console.log("npm pack warnings/errors:", stderrText); - } - - const output = stdoutText + stderrText; - - const esmSrcCount = (output.match(/esm\/src\//g) || []).length; - const scriptSrcCount = (output.match(/script\/src\//g) || []).length; - - if (esmSrcCount > 0) { - console.log(`āœ… esm/src/ files in package: ${esmSrcCount}`); - } else { - console.error("āŒ No esm/src/ files found in package!"); - hasErrors = true; - } - - if (scriptSrcCount > 0) { - console.log(`āœ… script/src/ files in package: ${scriptSrcCount}`); - } else { - console.error("āŒ No script/src/ files found in package!"); - hasErrors = true; - } - - // Check that root src is NOT included - // Match 'src/' at the beginning of a line or after whitespace, but not as part of a path - const rootSrcPattern = /(?:^|\s)src\//; - const rootSrcMatches = output.split("\n").filter((line) => - line.match(rootSrcPattern) && !line.includes("esm/src/") && - !line.includes("script/src/") - ); - - if (rootSrcMatches.length === 0) { - console.log("āœ… Root src/ directory correctly excluded from package"); - } else { - console.error( - `āŒ Root src/ files incorrectly included in package: ${rootSrcMatches.length}`, - ); - hasErrors = true; - } -} catch (error) { - console.error(`āŒ Could not run npm pack: ${error.message}`); - hasErrors = true; -} - -if (hasErrors) { - console.error("\nāŒ Package verification failed!"); - Deno.exit(1); -} else { - console.log("\nāœ… Package verification passed! Ready to publish."); - Deno.exit(0); -} From 5867d28c9c46ef585a7de524514cdee914cfa968 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 29 Oct 2025 20:34:54 +0000 Subject: [PATCH 6/7] Add test .d.ts files to gitignore Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com> --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 55289e5..b0b8373 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,8 @@ testing.js testing.ts test.js test.ts +*.test.d.ts +tests/**/*.d.ts # Deno specific deno.lock From f75638e0ed52c30e77f39519b783033b433e6ef7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 29 Oct 2025 20:38:19 +0000 Subject: [PATCH 7/7] Add test .d.ts patterns to .npmignore instead of .gitignore Co-authored-by: Hexagon <419737+Hexagon@users.noreply.github.com> --- .gitignore | 2 -- scripts/build_npm.ts | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index b0b8373..55289e5 100644 --- a/.gitignore +++ b/.gitignore @@ -16,8 +16,6 @@ testing.js testing.ts test.js test.ts -*.test.d.ts -tests/**/*.d.ts # Deno specific deno.lock diff --git a/scripts/build_npm.ts b/scripts/build_npm.ts index 4be5344..a2eb72b 100644 --- a/scripts/build_npm.ts +++ b/scripts/build_npm.ts @@ -49,11 +49,11 @@ let npmignore = await Deno.readTextFile("npm/.npmignore"); npmignore = npmignore.replace(/^src\/$/m, "/src/"); await Deno.writeTextFile("npm/.npmignore", npmignore); -// npmignore test data -// ensure the test data is ignored in the `.npmignore` file -// so it doesn't get published with your npm package +// npmignore test data and test declaration files +// ensure the test data and generated test .d.ts files are ignored in the `.npmignore` file +// so they don't get published with your npm package await Deno.writeTextFile( "npm/.npmignore", - "esm/tests/data\nscript/tests/data\n", + "esm/tests/data\nscript/tests/data\n*.test.d.ts\ntests/**/*.d.ts\n", { append: true }, );