sajt/src/project.ts

41 lines
1 KiB
TypeScript
Raw Normal View History

2024-10-11 11:11:40 +02:00
import { fileURLToPath } from 'url'
import path from 'path'
import { cp } from './utils.js'
2024-10-17 23:51:03 +02:00
import { build } from './site.js'
2025-02-25 09:35:07 +01:00
import ProjectConfig from './project-config.js'
2024-10-17 23:51:03 +02:00
2025-02-25 09:35:07 +01:00
export default class Project {
public config = new ProjectConfig() // should be injected
private __filename: string
private __dirname: string
private DEFAULT_PROJECT_PATH: string
2024-10-17 23:51:03 +02:00
2025-02-25 09:35:07 +01:00
constructor() {
// Get the directory of the current file
this.__filename = fileURLToPath(import.meta.url)
this.__dirname = path.dirname(this.__filename)
2024-10-17 23:51:03 +02:00
2025-02-25 09:35:07 +01:00
// Path relative to the script file's directory
this.DEFAULT_PROJECT_PATH = path.join(this.__dirname, '..', 'empty')
2024-10-17 23:51:03 +02:00
2025-02-25 09:35:07 +01:00
}
2024-10-17 23:51:03 +02:00
2025-02-25 09:35:07 +01:00
new() {
console.log("Initialize a new project")
console.log(this.DEFAULT_PROJECT_PATH)
cp(this.DEFAULT_PROJECT_PATH, ".")
2024-10-17 23:51:03 +02:00
2025-02-25 09:35:07 +01:00
console.log(this.config)
this.config.load()
}
2024-10-17 23:51:03 +02:00
2025-02-25 09:35:07 +01:00
existing() {
this.config.load()
}
2024-10-17 23:51:03 +02:00
2025-02-25 09:35:07 +01:00
build() {
this.config.load()
build(this.config.config)
}
2024-10-11 11:11:40 +02:00
}