Push current progress so I can work on my laptop.
This commit is contained in:
69
repo/build.js
Normal file
69
repo/build.js
Normal 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()
|
||||
16
repo/package.tce
Normal file
16
repo/package.tce
Normal file
@@ -0,0 +1,16 @@
|
||||
#schema package
|
||||
|
||||
name @terrace/repo
|
||||
private true
|
||||
type module
|
||||
|
||||
scripts
|
||||
build:repo node ./repo/build.js
|
||||
build turbo run build --cache-dir=.turbo
|
||||
dev turbo run dev --no-cache --force
|
||||
test turbo run test --no-cache --force
|
||||
|
||||
devDependencies
|
||||
@terrace/core workspace:*
|
||||
turbo ^1.7.3
|
||||
jest ^29.4.1
|
||||
12
repo/turbo.tce
Normal file
12
repo/turbo.tce
Normal file
@@ -0,0 +1,12 @@
|
||||
#schema https://turbo.build/schema.json
|
||||
|
||||
pipeline
|
||||
compile
|
||||
dev
|
||||
|
||||
build
|
||||
dependsOn ^build compile
|
||||
outputs dist/**
|
||||
|
||||
test
|
||||
dependsOn build
|
||||
Reference in New Issue
Block a user