Skip to content

Commit

Permalink
Delete logs and old code
Browse files Browse the repository at this point in the history
  • Loading branch information
jhgilbert committed Dec 11, 2024
1 parent e67c5da commit ac5e3ac
Showing 1 changed file with 0 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import { AuthorConsoleData } from '../schemas/authorConsole';

const __dirname = path.dirname(__filename);
const VITE_PROJECT_PATH = path.resolve(__dirname, '../../dist/author-console');
// const TEMP_PARENT_DIR = path.resolve(os.tmpdir(), 'markdoc-author-console');
const TEMP_PARENT_DIR = path.resolve(__dirname, '../../dist/tmp');
console.log('TEMP_PARENT_DIR: ' + TEMP_PARENT_DIR);

export class AuthorConsoleBuilder {
static async buildHtml(p: { data: AuthorConsoleData }): Promise<string> {
Expand Down Expand Up @@ -64,62 +62,6 @@ export class AuthorConsoleBuilder {
// Copy the vite project to tmp
fs.cpSync(VITE_PROJECT_PATH, tempAppDir, { recursive: true });

console.log('RETURNING temp app dir: ' + tempAppDir);
return tempAppDir;
}
}

/*
export async function buildApp(p: {
viteProjectPath: string;
dbData?: any;
}): Promise<string> {
// Clear the tmp dir if it exists
if (fs.existsSync(tempDir)) {
fs.rmSync(tempDir, { recursive: true });
}
// Create the tmp dir if it doesn't exist
if (!fs.existsSync(tempDir)) {
fs.mkdirSync(tempDir);
}
// Copy the vite project to tmp
fs.cpSync(p.viteProjectPath, tempDir, { recursive: true });
const viteConfig = defineConfig({
root: tempDir,
plugins: [react(), viteSingleFile()]
});
// Overwrite the tmp app data file if data is provided
if (p.dbData) {
updateAppData(tempDir, p.dbData);
}
const result = await build(viteConfig);
let appHtml: string;
if ('output' in result && result.output.length > 0 && 'source' in result.output[0]) {
appHtml = result.output[0].source as string;
} else {
throw new Error(
'Source not found in build result: ' + JSON.stringify(result, null, 2)
);
}
// Clear the temp folder
fs.rmSync(tempDir, { recursive: true });
return appHtml;
}
function updateAppData(tmpProjectPath: string, data: any) {
const fileContents = `export const dbData = ${JSON.stringify(data, null, 2)};`;
const dbDataFilePath = path.resolve(tmpProjectPath, 'src/db/data.ts');
fs.writeFileSync(dbDataFilePath, fileContents);
}
*/

0 comments on commit ac5e3ac

Please sign in to comment.