Skip to content
Snippets Groups Projects
Commit 2fc5b3ee authored by Thuc Pham's avatar Thuc Pham Committed by GitHub
Browse files

feat: use pnpm pack for e2e (#490)

parent 2eaf11ba
No related branches found
Tags v0.1.24
No related merge requests found
......@@ -11,6 +11,7 @@ import fs from "fs";
import terminalLink from "terminal-link";
import type { InstallTemplateArgs } from "./helpers";
import { installTemplate } from "./helpers";
import { templatesDir } from "./helpers/dir";
export type InstallAppArgs = Omit<
InstallTemplateArgs,
......@@ -100,7 +101,7 @@ export async function createApp({
});
// copy readme for fullstack
await fs.promises.copyFile(
path.join(__dirname, "..", "templates", "README-fullstack.md"),
path.join(templatesDir, "README-fullstack.md"),
path.join(root, "README.md"),
);
} else {
......
......@@ -72,7 +72,14 @@ export async function runCreateLlama(
externalPort: number,
postInstallAction: TemplatePostInstallAction,
): Promise<CreateLlamaResult> {
const createLlama = path.join(__dirname, "..", "dist", "index.js");
const createLlama = path.join(
__dirname,
"..",
"output",
"package",
"dist",
"index.js",
);
const name = [
templateType,
......
import path from "path";
import { fileURLToPath } from "url";
export const templatesDir = path.join(
fileURLToPath(import.meta.url),
"..",
"..",
"templates",
);
......@@ -6,6 +6,7 @@ import path from "path";
import { cyan } from "picocolors";
import { COMMUNITY_OWNER, COMMUNITY_REPO } from "./constant";
import { templatesDir } from "./dir";
import { PackageManager } from "./get-pkg-manager";
import { installLlamapackProject } from "./llama-pack";
import { isHavingPoetryLockFile, tryPoetryRun } from "./poetry";
......@@ -148,8 +149,7 @@ const copyContextData = async (
// Copy folder
if (dataSource?.type === "folder") {
let srcPath =
dataSourceConfig.path ??
path.join(__dirname, "..", "templates", "components", "data");
dataSourceConfig.path ?? path.join(templatesDir, "components", "data");
console.log(`\nCopying data to ${cyan(destPath)}\n`);
await copy("**", destPath, {
parents: true,
......
......@@ -2,6 +2,7 @@ import fs from "fs/promises";
import path from "path";
import { LLAMA_HUB_FOLDER_PATH, LLAMA_PACK_CONFIG_PATH } from "./constant";
import { copy } from "./copy";
import { templatesDir } from "./dir";
import { installPythonDependencies } from "./python";
import { getRepoRawContent } from "./repo";
import { InstallTemplateArgs } from "./types";
......@@ -29,9 +30,8 @@ const copyLlamapackEmptyProject = async ({
root,
}: Pick<InstallTemplateArgs, "root">) => {
const templatePath = path.join(
__dirname,
"..",
"templates/components/sample-projects/llamapack",
templatesDir,
"components/sample-projects/llamapack",
);
await copy("**", root, {
parents: true,
......@@ -42,7 +42,7 @@ const copyLlamapackEmptyProject = async ({
const copyData = async ({
root,
}: Pick<InstallTemplateArgs, "root" | "llamapack">) => {
const dataPath = path.join(__dirname, "..", "templates/components/data");
const dataPath = path.join(templatesDir, "components/data");
await copy("**", path.join(root, "data"), {
parents: true,
cwd: dataPath,
......
......@@ -4,6 +4,7 @@ import { cyan, red, yellow } from "picocolors";
import { parse, stringify } from "smol-toml";
import terminalLink from "terminal-link";
import { copy } from "./copy";
import { templatesDir } from "./dir";
import { isPoetryAvailable, tryPoetryInstall } from "./poetry";
import { InstallTemplateArgs, TemplateVectorDB } from "./types";
......@@ -139,14 +140,7 @@ export const installPythonTemplate = async ({
| "postInstallAction"
>) => {
console.log("\nInitializing Python project with template:", template, "\n");
const templatePath = path.join(
__dirname,
"..",
"templates",
"types",
template,
framework,
);
const templatePath = path.join(templatesDir, "types", template, framework);
await copy("**", root, {
parents: true,
cwd: templatePath,
......@@ -168,9 +162,7 @@ export const installPythonTemplate = async ({
});
if (engine === "context") {
const compPath = path.join(__dirname, "..", "templates", "components");
// Copy engine code
const compPath = path.join(templatesDir, "components");
let vectorDbDirName = vectorDb ?? "none";
const VectorDBPath = path.join(
compPath,
......
......@@ -5,6 +5,7 @@ import { bold, cyan } from "picocolors";
import { version } from "../../core/package.json";
import { copy } from "../helpers/copy";
import { callPackageManager } from "../helpers/install";
import { templatesDir } from "./dir";
import { PackageManager } from "./get-pkg-manager";
import { InstallTemplateArgs } from "./types";
......@@ -70,14 +71,7 @@ export const installTSTemplate = async ({
* Copy the template files to the target directory.
*/
console.log("\nInitializing project with template:", template, "\n");
const templatePath = path.join(
__dirname,
"..",
"templates",
"types",
template,
framework,
);
const templatePath = path.join(templatesDir, "types", template, framework);
const copySource = ["**"];
if (!eslint) copySource.push("!eslintrc.json");
......@@ -111,7 +105,7 @@ export const installTSTemplate = async ({
* Copy the selected chat engine files to the target directory and reference it.
*/
let relativeEngineDestPath;
const compPath = path.join(__dirname, "..", "templates", "components");
const compPath = path.join(templatesDir, "components");
if (engine && (framework === "express" || framework === "nextjs")) {
console.log("\nUsing chat engine:", engine, "\n");
......
......@@ -17,7 +17,7 @@
"create-llama": "./dist/index.js"
},
"files": [
"dist",
"dist/index.js",
"./templates"
],
"scripts": {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment