Use typescript for the project

This commit is contained in:
Artur Gurgul 2025-02-24 18:46:31 +01:00
parent 0f1d41a991
commit 83fd79f674
24 changed files with 2882 additions and 115 deletions

72
src/project.ts Normal file
View file

@ -0,0 +1,72 @@
import { fileURLToPath } from 'url'
import path from 'path'
import fs from 'fs'
import { cp } from './utils.js'
// Get the directory of the current file
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
// Path relative to the script file's directory
const DEFAULT_PROJECT_PATH = path.join(__dirname, 'empty')
export function newProject() {
console.log("Initialize a new project")
console.log(DEFAULT_PROJECT_PATH)
cp(DEFAULT_PROJECT_PATH, ".")
}
import { readConfig } from './site.js'
import { build } from './site.js'
export function buildProject() {
console.log("building")
let config = {
... readConfig(),
buildDir: './.build',
ignore: [".build", ".sajt"]
}
config.remote.port = 22
config.remote.privateKey = fs.readFileSync(path.resolve(process.env.HOME ?? "", '.ssh/id_rsa'))
build(config)
//loadTemplate()
//parseMD()
//buildProject(config)
}
//import { run } from './src/desktop/main.js'
import * as proc from 'child_process'
//import { app, BrowserWindow } from 'electron'
import * as electron from 'electron'
export function appProject() {
//run()
//const child = proc.spawn(electron, ["."])
// console.log(electron)
// console.log(electron.default)
// const child = proc.spawn(electron.default, [".build"])
// https://www.matthewslipper.com/2019/09/22/everything-you-wanted-electron-child-process.html
// exec('node start', (error, stdout, stderr) => {
// if (error) {
// console.error(`error: ${error.message}`)
// return;
// }
// if (stderr) {
// console.error(`stderr: ${stderr}`);
// return
// }
// console.log(`stdout:\n${stdout}`)
// })
}