Push current progress so I can work on my laptop.

This commit is contained in:
Joshua Bemenderfer
2023-02-05 07:44:11 -05:00
parent 94767772b4
commit 657c95a4c1
28 changed files with 2372 additions and 3468 deletions

69
repo/build.js Normal file
View File

@@ -0,0 +1,69 @@
import fs from 'node:fs/promises'
import { useDocument } from '@terrace/core'
import { createReadlineReader } from '@terrace/core/readers/node-readline'
function useHelpers({ next, level, head, tail }) {
async function kvObject(handleValue) {
const object = {}
const rootLevel = level()
while (await next(rootLevel)) {
if (!head()) continue
object[head()] = handleValue ? await handleValue(level()) : tail().trim()
}
return object
}
return { kvObject }
}
async function buildPackage() {
const { next, level, head, tail, match } = useDocument(createReadlineReader('./repo/package.tce'))
const { kvObject } = useHelpers({ next, level, head, tail })
const pkg = {}
while (await next()) {
if (match('name')) pkg.name = tail().trim()
if (match('version')) pkg.version = tail().trim()
if (match('license')) pkg.license = tail().trim()
if (match('type')) pkg.type = tail().trim()
if (match('private')) pkg.private = tail().trim() === 'true'
if (match('scripts')) pkg.scripts = await kvObject()
if (match('devDependencies')) pkg.devDependencies = await kvObject()
}
await fs.writeFile('./package.json', JSON.stringify(pkg, null, ' '))
}
async function buildTurbo() {
const { next, level, head, tail, match } = useDocument(createReadlineReader('./repo/turbo.tce'))
const { kvObject } = useHelpers({ next, level, head, tail })
const turbo = {}
while (await next()) {
if (match('#schema')) turbo['$schema'] = tail().trim()
if (match('pipeline')) turbo.pipeline = await (async () => {
const pipeline = {}
const rootLevel = level()
while (await next(rootLevel)) {
if (!head()) continue
const entry = pipeline[head()] = {}
const pipelineLevel = level()
while(await next(pipelineLevel)) {
if (match('dependsOn')) entry.dependsOn = tail().trim().split(' ')
if (match('outputs')) entry.outputs = tail().trim().split(' ')
}
}
return pipeline
})()
}
await fs.writeFile('./turbo.json', JSON.stringify(turbo, null, ' '))
}
buildPackage()
buildTurbo()