Skip to content
Merged
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
30 changes: 19 additions & 11 deletions scripts/build_npm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { build, emptyDir, copy } from "./deps.ts";
import { build, copy, emptyDir } from "./deps.ts";

// Clear NPM directory
await emptyDir("./npm");
Expand All @@ -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: {
Expand All @@ -26,26 +26,34 @@ 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 <Hexagon@GitHub>",
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",
},
});

// post build steps
Deno.copyFileSync("LICENSE", "npm/LICENSE");
Deno.copyFileSync("README.md", "npm/README.md");

// npmignore test data
// ensure the test data is ignored in the `.npmignore` file
// so it doesn't get published with your npm package
// Fix the .npmignore file to prevent exclusion of esm/src/ and script/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);

// 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 },
);
);
Loading