From 5fec80cefe4d8374be068a6b3a4374481997b8e4 Mon Sep 17 00:00:00 2001
From: Marcus Schiesser <mail@marcusschiesser.de>
Date: Wed, 6 Dec 2023 14:09:21 +0700
Subject: [PATCH] fix: use CJS for create-llama

---
 e2e/tsconfig.json | 11 -----------
 e2e/utils.ts      | 12 ++++--------
 package.json      |  1 -
 tsconfig.json     | 10 ++++------
 4 files changed, 8 insertions(+), 26 deletions(-)
 delete mode 100644 e2e/tsconfig.json

diff --git a/e2e/tsconfig.json b/e2e/tsconfig.json
deleted file mode 100644
index a9d7a67e..00000000
--- a/e2e/tsconfig.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
-  "extends": "../tsconfig.json",
-  "compilerOptions": {
-    "module": "ESNext",
-    "target": "ESNext",
-    "verbatimModuleSyntax": true
-  },
-  "include": [
-    "./**/*.ts"
-  ]
-}
diff --git a/e2e/utils.ts b/e2e/utils.ts
index 75e2a619..6e134495 100644
--- a/e2e/utils.ts
+++ b/e2e/utils.ts
@@ -1,7 +1,7 @@
 import { ChildProcess, exec, execSync } from "child_process";
 import crypto from "node:crypto";
 import { mkdir } from "node:fs/promises";
-import { fileURLToPath } from "node:url";
+import * as path from "path";
 import waitPort from "wait-port";
 
 export type AppType = "--frontend" | "--no-frontend" | "";
@@ -13,7 +13,7 @@ export async function runApp(
   appType: AppType,
   port: number,
 ): Promise<ChildProcess[]> {
-  const cps = [];
+  const cps: ChildProcess[] = [];
 
   try {
     switch (appType) {
@@ -71,9 +71,7 @@ export function runCreateLlama(
   templateUI: string,
   appType: AppType,
 ) {
-  const createLlama = fileURLToPath(
-    new URL("../dist/index.js", import.meta.url),
-  );
+  const createLlama = path.join(__dirname, "..", "dist", "index.js");
 
   const name = [
     templateType,
@@ -110,9 +108,7 @@ export function runCreateLlama(
   return name;
 }
 export async function createTestDir() {
-  const cwd = fileURLToPath(
-    new URL(`.cache/${crypto.randomUUID()}`, import.meta.url),
-  );
+  const cwd = path.join(__dirname, ".cache", crypto.randomUUID());
   await mkdir(cwd, { recursive: true });
   return cwd;
 }
diff --git a/package.json b/package.json
index 3d77e5f2..057f2e0c 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,6 @@
 {
   "name": "create-llama",
   "version": "0.0.11",
-  "type": "module",
   "keywords": [
     "rag",
     "llamaindex",
diff --git a/tsconfig.json b/tsconfig.json
index b8a4782f..a653e907 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -7,10 +7,8 @@
     "esModuleInterop": true,
     "skipLibCheck": false
   },
-  "exclude": ["templates", "dist"],
-  "references": [
-    {
-      "path": "./e2e/tsconfig.json"
-    }
+  "exclude": [
+    "templates",
+    "dist"
   ]
-}
+}
\ No newline at end of file
-- 
GitLab