Skip to content
Snippets Groups Projects
Commit c778e450 authored by Alex Yang's avatar Alex Yang Committed by GitHub
Browse files

fix: cover type check on all ts files (#372)

parent da3ba969
No related branches found
No related tags found
No related merge requests found
...@@ -9,8 +9,8 @@ import { makeDir } from "./helpers/make-dir"; ...@@ -9,8 +9,8 @@ import { makeDir } from "./helpers/make-dir";
import fs from "fs"; import fs from "fs";
import terminalLink from "terminal-link"; import terminalLink from "terminal-link";
import type { InstallTemplateArgs } from "./templates"; import type { InstallTemplateArgs } from "./helpers";
import { installTemplate } from "./templates"; import { installTemplate } from "./helpers";
export type InstallAppArgs = Omit< export type InstallAppArgs = Omit<
InstallTemplateArgs, InstallTemplateArgs,
...@@ -94,7 +94,7 @@ export async function createApp({ ...@@ -94,7 +94,7 @@ export async function createApp({
}); });
// copy readme for fullstack // copy readme for fullstack
await fs.promises.copyFile( await fs.promises.copyFile(
path.join(__dirname, "templates", "README-fullstack.md"), path.join(__dirname, "..", "templates", "README-fullstack.md"),
path.join(root, "README.md"), path.join(root, "README.md"),
); );
} else { } else {
......
...@@ -8,7 +8,7 @@ import type { ...@@ -8,7 +8,7 @@ import type {
TemplateFramework, TemplateFramework,
TemplateType, TemplateType,
TemplateUI, TemplateUI,
} from "../templates"; } from "../helpers";
import { createTestDir, runApp, runCreateLlama, type AppType } from "./utils"; import { createTestDir, runApp, runCreateLlama, type AppType } from "./utils";
const templateTypes: TemplateType[] = ["streaming", "simple"]; const templateTypes: TemplateType[] = ["streaming", "simple"];
......
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"tsBuildInfoFile": "./lib/.e2e.tsbuildinfo"
},
"include": ["./**/*.ts"],
"references": [
{
"path": ".."
}
]
}
import { copy } from "../helpers/copy"; import { copy } from "./copy";
import { callPackageManager } from "../helpers/install"; import { callPackageManager } from "./install";
import fs from "fs/promises"; import fs from "fs/promises";
import path from "path"; import path from "path";
import { cyan } from "picocolors"; import { cyan } from "picocolors";
import { COMMUNITY_OWNER, COMMUNITY_REPO } from "../helpers/constant"; import { COMMUNITY_OWNER, COMMUNITY_REPO } from "./constant";
import { PackageManager } from "../helpers/get-pkg-manager"; import { PackageManager } from "./get-pkg-manager";
import { downloadAndExtractRepo } from "../helpers/repo";
import { installPythonTemplate } from "./python"; import { installPythonTemplate } from "./python";
import { downloadAndExtractRepo } from "./repo";
import { import {
InstallTemplateArgs, InstallTemplateArgs,
TemplateEngine, TemplateEngine,
...@@ -71,7 +71,13 @@ const copyTestData = async ( ...@@ -71,7 +71,13 @@ const copyTestData = async (
vectorDb?: TemplateVectorDB, vectorDb?: TemplateVectorDB,
) => { ) => {
if (engine === "context") { if (engine === "context") {
const srcPath = path.join(__dirname, "components", "data"); const srcPath = path.join(
__dirname,
"..",
"templates",
"components",
"data",
);
const destPath = path.join(root, "data"); const destPath = path.join(root, "data");
console.log(`\nCopying test data to ${cyan(destPath)}\n`); console.log(`\nCopying test data to ${cyan(destPath)}\n`);
await copy("**", destPath, { await copy("**", destPath, {
......
...@@ -2,7 +2,7 @@ import fs from "fs/promises"; ...@@ -2,7 +2,7 @@ import fs from "fs/promises";
import path from "path"; import path from "path";
import { cyan } from "picocolors"; import { cyan } from "picocolors";
import { parse, stringify } from "smol-toml"; import { parse, stringify } from "smol-toml";
import { copy } from "../helpers/copy"; import { copy } from "./copy";
import { InstallTemplateArgs, TemplateVectorDB } from "./types"; import { InstallTemplateArgs, TemplateVectorDB } from "./types";
interface Dependency { interface Dependency {
...@@ -101,7 +101,14 @@ export const installPythonTemplate = async ({ ...@@ -101,7 +101,14 @@ export const installPythonTemplate = async ({
"root" | "framework" | "template" | "engine" | "vectorDb" "root" | "framework" | "template" | "engine" | "vectorDb"
>) => { >) => {
console.log("\nInitializing Python project with template:", template, "\n"); console.log("\nInitializing Python project with template:", template, "\n");
const templatePath = path.join(__dirname, "types", template, framework); const templatePath = path.join(
__dirname,
"..",
"templates",
"types",
template,
framework,
);
await copy("**", root, { await copy("**", root, {
parents: true, parents: true,
cwd: templatePath, cwd: templatePath,
...@@ -123,7 +130,7 @@ export const installPythonTemplate = async ({ ...@@ -123,7 +130,7 @@ export const installPythonTemplate = async ({
}); });
if (engine === "context") { if (engine === "context") {
const compPath = path.join(__dirname, "components"); const compPath = path.join(__dirname, "..", "templates", "components");
const VectorDBPath = path.join( const VectorDBPath = path.join(
compPath, compPath,
"vectordbs", "vectordbs",
......
File moved
...@@ -46,7 +46,14 @@ export const installTSTemplate = async ({ ...@@ -46,7 +46,14 @@ export const installTSTemplate = async ({
* Copy the template files to the target directory. * Copy the template files to the target directory.
*/ */
console.log("\nInitializing project with template:", template, "\n"); console.log("\nInitializing project with template:", template, "\n");
const templatePath = path.join(__dirname, "types", template, framework); const templatePath = path.join(
__dirname,
"..",
"templates",
"types",
template,
framework,
);
const copySource = ["**"]; const copySource = ["**"];
if (!eslint) copySource.push("!eslintrc.json"); if (!eslint) copySource.push("!eslintrc.json");
...@@ -80,7 +87,7 @@ export const installTSTemplate = async ({ ...@@ -80,7 +87,7 @@ export const installTSTemplate = async ({
* Copy the selected chat engine files to the target directory and reference it. * Copy the selected chat engine files to the target directory and reference it.
*/ */
let relativeEngineDestPath; let relativeEngineDestPath;
const compPath = path.join(__dirname, "components"); const compPath = path.join(__dirname, "..", "templates", "components");
if (engine && (framework === "express" || framework === "nextjs")) { if (engine && (framework === "express" || framework === "nextjs")) {
console.log("\nUsing chat engine:", engine, "\n"); console.log("\nUsing chat engine:", engine, "\n");
......
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
"create-llama": "./dist/index.js" "create-llama": "./dist/index.js"
}, },
"files": [ "files": [
"dist" "./dist/index.js",
"./templates"
], ],
"scripts": { "scripts": {
"clean": "rimraf --glob ./dist ./templates/**/__pycache__ ./templates/**/node_modules ./templates/**/poetry.lock", "clean": "rimraf --glob ./dist ./templates/**/__pycache__ ./templates/**/node_modules ./templates/**/poetry.lock",
......
...@@ -4,9 +4,9 @@ import path from "path"; ...@@ -4,9 +4,9 @@ import path from "path";
import { blue, green } from "picocolors"; import { blue, green } from "picocolors";
import prompts from "prompts"; import prompts from "prompts";
import { InstallAppArgs } from "./create-app"; import { InstallAppArgs } from "./create-app";
import { TemplateFramework } from "./helpers";
import { COMMUNITY_OWNER, COMMUNITY_REPO } from "./helpers/constant"; import { COMMUNITY_OWNER, COMMUNITY_REPO } from "./helpers/constant";
import { getRepoRootFolders } from "./helpers/repo"; import { getRepoRootFolders } from "./helpers/repo";
import { TemplateFramework } from "./templates";
export type QuestionArgs = Omit<InstallAppArgs, "appPath" | "packageManager">; export type QuestionArgs = Omit<InstallAppArgs, "appPath" | "packageManager">;
......
{ {
"extends": "../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"target": "es2019", "target": "es2019",
"moduleResolution": "node", "moduleResolution": "node",
"strict": true, "strict": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"esModuleInterop": true, "esModuleInterop": true,
"skipLibCheck": false "skipLibCheck": true
}, },
"exclude": ["templates", "dist"] "include": [
"create-app.ts",
"index.ts",
"./helpers",
"questions.ts",
"package.json"
],
"exclude": ["dist"]
} }
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