Repository: vendure-ecommerce/ngx-translate-extract
Pull request #88 (2025-07-02 18:47:54)

refactor(build): isolate dist folder for publishing
- add build script to clean dist/, copy LICENSE and README, and prepare a minimal package.json
- update publish step to run `npm publish ./dist`


Patch:
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 5ad4f4e..48759c6 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -18,7 +18,7 @@ jobs:
       # Install  dependencies without modifying package-lock.json file
       - run: npm ci
       - run: npm run build
-      - run: npm publish
+      - run: npm publish ./dist
         env:
           NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
           NPM_CONFIG_PROVENANCE: true
diff --git a/bin/cli.js b/bin/cli.js
deleted file mode 100644
index c5b9352..0000000
--- a/bin/cli.js
+++ /dev/null
@@ -1,3 +0,0 @@
-#! /usr/bin/env node
-
-import('../dist/cli/cli.js');
diff --git a/package.json b/package.json
index efbaf10..f0a3003 100644
--- a/package.json
+++ b/package.json
@@ -6,7 +6,8 @@
   "license": "MIT",
   "type": "module",
   "scripts": {
-    "build": "npm run clean && tsc",
+    "build": "node tools/build.js",
+    "build:dev": "npm run clean && tsc",
     "watch": "npm run clean && tsc --watch",
     "clean": "tsc --build --clean",
     "test": "vitest",
@@ -40,17 +41,12 @@
     "@angular/compiler": ">=17.0.0",
     "typescript": ">=5.2.0"
   },
-  "typings": "dist/index.d.ts",
-  "files": [
-    "bin/",
-    "dist/"
-  ],
   "bin": {
-    "ngx-translate-extract": "bin/cli.js"
+    "ngx-translate-extract": "cli.js"
   },
   "repository": {
     "type": "git",
-    "url": "git@github.com:vendure-ecommerce/ngx-translate-extract.git"
+    "url": "git+ssh://git@github.com/vendure-ecommerce/ngx-translate-extract.git"
   },
   "keywords": [
     "angular",
diff --git a/src/cli.ts b/src/cli.ts
new file mode 100644
index 0000000..9d4abca
--- /dev/null
+++ b/src/cli.ts
@@ -0,0 +1,3 @@
+#! /usr/bin/env node
+
+import('./cli/cli.js');
diff --git a/tools/build.js b/tools/build.js
new file mode 100644
index 0000000..c1ae4cd
--- /dev/null
+++ b/tools/build.js
@@ -0,0 +1,54 @@
+#! /usr/bin/env node
+
+import { copyFileSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { join, resolve } from 'node:path';
+import { execSync } from 'node:child_process';
+import { stdout } from 'node:process';
+
+import JSON5 from 'json5';
+
+const PROJECT_NAME = 'ngx-translate-extract';
+const SEPARATOR = '-'.repeat(80);
+const CARRIAGE_CHAR = stdout.isTTY ? '\r' : '\n';
+
+console.log(`\nBuilding ${PROJECT_NAME}`);
+console.log(SEPARATOR);
+
+// Read tsconfig.json
+const tsconfigRaw = readFileSync(resolve(process.cwd(), 'tsconfig.json'), 'utf-8');
+const tsconfig = JSON5.parse(tsconfigRaw);
+
+// Get outDir from tsconfig.json
+const outDir = tsconfig?.compilerOptions?.outDir ?? null;
+const resolvedOutDir = resolve(process.cwd(), outDir);
+
+// Empty dist
+stdout.write(`⏳ Emptying '${outDir}' directory`);
+rmSync(resolvedOutDir, { recursive: true, force: true });
+mkdirSync(resolvedOutDir, { recursive: true });
+stdout.write(`${CARRIAGE_CHAR}✔  Emptying '${outDir}' directory\n`);
+
+// Copy assets
+const filesToCopy = ['LICENSE', 'README.md'];
+filesToCopy.forEach(fileName => {
+  console.log(`ℹ  Copying ${fileName}`);
+  copyFileSync(fileName, join(resolvedOutDir, fileName));
+});
+
+// Copy and clean package.json
+const pkgPath = resolve(process.cwd(), 'package.json');
+const packageJson = JSON.parse(readFileSync(pkgPath, 'utf-8'));
+
+const keysToRemove = ['devDependencies', 'scripts'];
+keysToRemove.forEach(key => {
+  console.log(`ℹ  Removing ${key} from package.json`);
+  delete packageJson[key];
+});
+writeFileSync(join(resolvedOutDir, 'package.json'), JSON.stringify(packageJson, null, 2));
+console.log(`✔  Copied assets to '${outDir}' directory`);
+
+// Build
+stdout.write(`⏳ Building project`);
+execSync(`tsc --project tsconfig.json`, { stdio: 'inherit' });
+stdout.write(`${CARRIAGE_CHAR}✔  Building project\n`);
+console.log(SEPARATOR);
diff --git a/tsconfig.json b/tsconfig.json
index ef5404a..0ac39e0 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -5,16 +5,15 @@
         "noImplicitThis": true,
         "removeComments": true,
         "declaration": true,
+		"skipLibCheck": true,
         "target": "es2022",
         "lib": [
-            "es2022",
-            "dom"
+            "es2022"
         ],
-        "module": "es2022",
+        "module": "nodenext",
         "esModuleInterop": true,
-        "moduleResolution": "node",
+        "moduleResolution": "nodenext",
         "outDir": "dist",
-        "sourceMap": true,
     },
     "include": [
         "src/**/*.ts",


Test patch:
diff --git a/tests/cli/cli.spec.ts b/tests/cli/cli.spec.ts
index 2f3c664..c3a96e2 100644
--- a/tests/cli/cli.spec.ts
+++ b/tests/cli/cli.spec.ts
@@ -20,7 +20,7 @@ const createUniqueFileName = (fileName: string) => resolve(TMP_PATH, `${nextFile
 describe.concurrent('CLI Integration Tests', () => {
 	beforeAll(async () => {
 		try {
-			await execAsync(`npm run build -- --outDir ${TMP_PATH}/dist`);
+			await execAsync(`npm run build:dev -- --outDir ${TMP_PATH}/dist`);
 		} catch (err) {
 			console.error('Error during build in beforeAll:', err);
 			throw err;