From d0f5c6e8222c4bdf1e8532d5e4ea843ba1e278e7 Mon Sep 17 00:00:00 2001 From: Eric Luce <37158449+eluce2@users.noreply.github.com> Date: Wed, 19 Feb 2025 13:10:39 -0600 Subject: [PATCH 1/2] fix templates --- .changeset/brave-eggs-reflect.md | 5 +++++ cli/package.json | 2 +- cli/src/cli/add/page/index.ts | 7 +++++++ cli/template/nextjs/src/app/layout.tsx | 2 +- config/templates.ts | 16 ++++++++++------ 5 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 .changeset/brave-eggs-reflect.md diff --git a/.changeset/brave-eggs-reflect.md b/.changeset/brave-eggs-reflect.md new file mode 100644 index 00000000..97245f42 --- /dev/null +++ b/.changeset/brave-eggs-reflect.md @@ -0,0 +1,5 @@ +--- +"@proofgeist/kit": patch +--- + +Fix: post-install template functions not running diff --git a/cli/package.json b/cli/package.json index 4125d909..e7dfb263 100644 --- a/cli/package.json +++ b/cli/package.json @@ -1,6 +1,6 @@ { "name": "@proofgeist/kit", - "version": "0.1.2", + "version": "0.1.3", "description": "Create web application with the ProofKit stack", "license": "MIT", "repository": { diff --git a/cli/src/cli/add/page/index.ts b/cli/src/cli/add/page/index.ts index 6f0a2a91..cd4cc680 100644 --- a/cli/src/cli/add/page/index.ts +++ b/cli/src/cli/add/page/index.ts @@ -1,6 +1,7 @@ import path from "path"; import * as p from "@clack/prompts"; import { nextjsTemplates, wvTemplates } from "@config/templates.js"; +import chalk from "chalk"; import { Command } from "commander"; import { capitalize } from "es-toolkit"; import fs from "fs-extra"; @@ -10,6 +11,7 @@ import { getExistingSchemas } from "~/generators/fmdapi.js"; import { addRouteToNav } from "~/generators/route.js"; import { ciOption, debugOption } from "~/globalOptions.js"; import { initProgramState, state } from "~/state.js"; +import { getUserPkgManager } from "~/utils/getUserPkgManager.js"; import { getSettings, mergeSettings, @@ -178,6 +180,11 @@ export const runAddPageAction = async (opts?: { } spinner.stop("Added page!"); + const pkgManager = getUserPkgManager(); + + console.log( + `\n${chalk.green("Next steps:")}\nTo preview this page, restart your dev server using the ${chalk.cyan(`${pkgManager} dev`)} command\n` + ); }; export const makeAddPageCommand = () => { diff --git a/cli/template/nextjs/src/app/layout.tsx b/cli/template/nextjs/src/app/layout.tsx index 05435627..2b4efe54 100644 --- a/cli/template/nextjs/src/app/layout.tsx +++ b/cli/template/nextjs/src/app/layout.tsx @@ -28,7 +28,7 @@ export default function RootLayout({ - + {children} diff --git a/config/templates.ts b/config/templates.ts index 391bf498..e11f36f6 100644 --- a/config/templates.ts +++ b/config/templates.ts @@ -1,3 +1,7 @@ +import { postInstallTable } from "../cli/src/cli/add/page/post-install/table.js"; +import { postInstallTableInfinite } from "../cli/src/cli/add/page/post-install/table-infinite.js"; +import type { TPostInstallFn } from "../cli/src/cli/add/page/types.js"; + export interface Template { requireData: boolean; label: string; @@ -5,12 +9,7 @@ export interface Template { templatePath: string; screenshot?: string; tags?: string[]; - postIntallFn?: (args: { - projectDir: string; - pageDir: string; - dataSource?: unknown; - schemaName?: string; - }) => void | Promise; + postIntallFn?: TPostInstallFn; } export const nextjsTemplates: Record = { @@ -24,18 +23,21 @@ export const nextjsTemplates: Record = { label: "Basic Table", hint: "Use to load and show multiple records", templatePath: "nextjs/table", + postIntallFn: postInstallTable, }, tableEdit: { requireData: true, label: "Basic Table (editable)", hint: "Use to load and show multiple records with inline edit functionality", templatePath: "nextjs/table-edit", + postIntallFn: postInstallTable, }, tableInfinite: { requireData: true, label: "Infinite Table", hint: "Automatically load more records when the user scrolls to the bottom", templatePath: "nextjs/table-infinite", + postIntallFn: postInstallTableInfinite, }, }; @@ -50,11 +52,13 @@ export const wvTemplates: Record = { label: "Basic Table", hint: "Use to load and show multiple records", templatePath: "vite-wv/table", + postIntallFn: postInstallTable, }, tableEdit: { requireData: true, label: "Basic Table (editable)", hint: "Use to load and show multiple records with inline edit functionality", templatePath: "vite-wv/table-edit", + postIntallFn: postInstallTable, }, }; From 5b020c4e15456e0811846b08f1e2cca2ff77155e Mon Sep 17 00:00:00 2001 From: Eric Luce <37158449+eluce2@users.noreply.github.com> Date: Wed, 19 Feb 2025 13:47:37 -0600 Subject: [PATCH 2/2] Update package.json --- cli/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/package.json b/cli/package.json index e7dfb263..4125d909 100644 --- a/cli/package.json +++ b/cli/package.json @@ -1,6 +1,6 @@ { "name": "@proofgeist/kit", - "version": "0.1.3", + "version": "0.1.2", "description": "Create web application with the ProofKit stack", "license": "MIT", "repository": {