Relocate our existing web code to subdirectories
- Move the frontend code into src/frontend - Move our custom element SSR system into src/htmlTransform. This is mostly in prep for merging in copy-cat's core, as that's a whole bunch of extra code.
14
.reuse/dep5
@ -10,8 +10,8 @@ Files:
|
||||
projects/common/src/testMod/resources/data/cctest/structures/*
|
||||
projects/fabric/src/generated/*
|
||||
projects/forge/src/generated/*
|
||||
projects/web/src/export/index.json
|
||||
projects/web/src/export/items/minecraft/*
|
||||
projects/web/src/htmlTransform/export/index.json
|
||||
projects/web/src/htmlTransform/export/items/minecraft/*
|
||||
Comment: Generated/data files are CC0.
|
||||
Copyright: The CC: Tweaked Developers
|
||||
License: CC0-1.0
|
||||
@ -37,10 +37,10 @@ Files:
|
||||
projects/fabric/src/testMod/resources/computercraft-gametest.fabric.mixins.json
|
||||
projects/fabric/src/testMod/resources/fabric.mod.json
|
||||
projects/forge/src/client/resources/computercraft-client.forge.mixins.json
|
||||
projects/web/src/mount/.settings
|
||||
projects/web/src/mount/example.nfp
|
||||
projects/web/src/mount/example.nft
|
||||
projects/web/src/mount/expr_template.lua
|
||||
projects/web/src/frontend/mount/.settings
|
||||
projects/web/src/frontend/mount/example.nfp
|
||||
projects/web/src/frontend/mount/example.nft
|
||||
projects/web/src/frontend/mount/expr_template.lua
|
||||
projects/web/tsconfig.json
|
||||
Comment: Several assets where it's inconvenient to create a .license file.
|
||||
Copyright: The CC: Tweaked Developers
|
||||
@ -56,7 +56,7 @@ Files:
|
||||
projects/core/src/main/resources/data/computercraft/lua/rom/autorun/.ignoreme
|
||||
projects/core/src/main/resources/data/computercraft/lua/rom/help/*
|
||||
projects/core/src/main/resources/data/computercraft/lua/rom/programs/fun/advanced/levels/*
|
||||
projects/web/src/export/items/computercraft/*
|
||||
projects/web/src/htmlTransform/export/items/computercraft/*
|
||||
Comment: Bulk-license original assets as CCPL.
|
||||
Copyright: 2011 Daniel Ratcliffe
|
||||
License: LicenseRef-CCPL
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
package cc.tweaked.gradle
|
||||
|
||||
import org.gradle.api.file.DirectoryProperty
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.tasks.AbstractExecTask
|
||||
import org.gradle.api.tasks.OutputDirectory
|
||||
@ -11,5 +12,5 @@ import java.io.File
|
||||
|
||||
abstract class ExecToDir : AbstractExecTask<ExecToDir>(ExecToDir::class.java) {
|
||||
@get:OutputDirectory
|
||||
abstract val output: Property<File>
|
||||
abstract val output: DirectoryProperty
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
package cc.tweaked.gradle
|
||||
|
||||
import org.gradle.api.artifacts.dsl.DependencyHandler
|
||||
import org.gradle.api.file.FileSystemLocationProperty
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.JavaExec
|
||||
@ -124,3 +125,6 @@ class CloseScope : AutoCloseable {
|
||||
|
||||
/** Proxy method to avoid overload ambiguity. */
|
||||
fun <T> Property<T>.setProvider(provider: Provider<out T>) = set(provider)
|
||||
|
||||
/** Short-cut method to get the absolute path of a [FileSystemLocationProperty]. */
|
||||
fun FileSystemLocationProperty<*>.getAbsolutePath(): String = get().asFile.absolutePath
|
||||
|
@ -10,7 +10,7 @@
|
||||
/projects/core/src/main/resources/data/computercraft/lua/bios.lua
|
||||
/projects/core/src/main/resources/data/computercraft/lua/rom/
|
||||
/projects/core/src/test/resources/test-rom
|
||||
/projects/web/src/mount)
|
||||
/projects/web/src/frontend/mount)
|
||||
|
||||
(doc
|
||||
; Also defined in projects/web/build.gradle.kts
|
||||
@ -23,7 +23,7 @@
|
||||
(url https://tweaked.cc/)
|
||||
(source-link https://github.com/cc-tweaked/CC-Tweaked/blob/${commit}/${path}#L${line})
|
||||
|
||||
(styles /projects/web/src/styles.css)
|
||||
(styles /projects/web/src/frontend/styles.css)
|
||||
(scripts /projects/web/build/rollup/index.js)
|
||||
(head doc/head.html))
|
||||
|
||||
@ -115,4 +115,4 @@
|
||||
:max sleep write
|
||||
cct_test describe expect howlci fail it pending stub before_each)))
|
||||
|
||||
(at /projects/web/src/mount/expr_template.lua (lint (globals :max __expr__)))
|
||||
(at /projects/web/src/frontend/mount/expr_template.lua (lint (globals :max __expr__)))
|
||||
|
@ -2,6 +2,8 @@
|
||||
//
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
import cc.tweaked.gradle.getAbsolutePath
|
||||
|
||||
plugins {
|
||||
`lifecycle-base`
|
||||
id("cc-tweaked.node")
|
||||
@ -21,13 +23,13 @@ val rollup by tasks.registering(cc.tweaked.gradle.NpxExecToDir::class) {
|
||||
description = "Bundles JS into rollup"
|
||||
|
||||
// Sources
|
||||
inputs.files(fileTree("src")).withPropertyName("sources")
|
||||
inputs.files(fileTree("src/frontend")).withPropertyName("sources")
|
||||
// Config files
|
||||
inputs.file("tsconfig.json").withPropertyName("Typescript config")
|
||||
inputs.file("rollup.config.js").withPropertyName("Rollup config")
|
||||
|
||||
// Output directory. Also defined in illuaminate.sexp and rollup.config.js
|
||||
output.set(buildDir.resolve("rollup"))
|
||||
output.set(layout.buildDirectory.dir("rollup"))
|
||||
|
||||
args = listOf("rollup", "--config", "rollup.config.js")
|
||||
}
|
||||
@ -44,30 +46,38 @@ val illuaminateDocs by tasks.registering(cc.tweaked.gradle.IlluaminateExecToDir:
|
||||
inputs.files(project(":forge").tasks.named("luaJavadoc"))
|
||||
// Additional assets
|
||||
inputs.files(rollup)
|
||||
inputs.file("src/styles.css").withPropertyName("styles")
|
||||
inputs.file("src/frontend/styles.css").withPropertyName("styles")
|
||||
|
||||
// Output directory. Also defined in illuaminate.sexp and transform.tsx
|
||||
output.set(buildDir.resolve("illuaminate"))
|
||||
// Output directory. Also defined in illuaminate.sexp.
|
||||
output.set(layout.buildDirectory.dir("illuaminate"))
|
||||
|
||||
args = listOf("doc-gen")
|
||||
workingDir = rootProject.projectDir
|
||||
}
|
||||
|
||||
val jsxDocs by tasks.registering(cc.tweaked.gradle.NpxExecToDir::class) {
|
||||
val htmlTransform by tasks.registering(cc.tweaked.gradle.NpxExecToDir::class) {
|
||||
group = JavaBasePlugin.DOCUMENTATION_GROUP
|
||||
description = "Post-processes documentation to statically render some dynamic content."
|
||||
|
||||
val sources = fileTree("src/htmlTransform")
|
||||
|
||||
// Config files
|
||||
inputs.file("tsconfig.json").withPropertyName("Typescript config")
|
||||
// Sources
|
||||
inputs.files(fileTree("src")).withPropertyName("sources")
|
||||
inputs.file(file("src/export/index.json")).withPropertyName("export")
|
||||
inputs.files(sources).withPropertyName("sources")
|
||||
inputs.files(illuaminateDocs)
|
||||
|
||||
// Output directory. Also defined in src/transform.tsx
|
||||
output.set(buildDir.resolve("jsxDocs"))
|
||||
// Output directory.
|
||||
output.set(layout.buildDirectory.dir(name))
|
||||
|
||||
args = listOf("tsx", "src/transform.tsx")
|
||||
argumentProviders.add {
|
||||
listOf(
|
||||
"tsx", sources.dir.resolve("index.tsx").absolutePath,
|
||||
illuaminateDocs.get().output.getAbsolutePath(),
|
||||
sources.dir.resolve("export/index.json").absolutePath,
|
||||
output.getAbsolutePath(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
val docWebsite by tasks.registering(Copy::class) {
|
||||
@ -75,7 +85,7 @@ val docWebsite by tasks.registering(Copy::class) {
|
||||
description = "Assemble docs and assets together into the documentation website."
|
||||
duplicatesStrategy = DuplicatesStrategy.FAIL
|
||||
|
||||
from(jsxDocs)
|
||||
from(htmlTransform)
|
||||
|
||||
// Pick up assets from the /docs folder
|
||||
from(rootProject.file("doc")) {
|
||||
@ -87,9 +97,9 @@ val docWebsite by tasks.registering(Copy::class) {
|
||||
// Grab illuaminate's assets. HTML files are provided by jsxDocs
|
||||
from(illuaminateDocs) { exclude("**/*.html") }
|
||||
// And item/block images from the data export
|
||||
from(file("src/export/items")) { into("images/items") }
|
||||
from(file("src/htmlTransform/export/items")) { into("images/items") }
|
||||
|
||||
into(buildDir.resolve("site"))
|
||||
into(layout.buildDirectory.dir("site"))
|
||||
}
|
||||
|
||||
tasks.assemble { dependsOn(docWebsite) }
|
||||
|
@ -9,7 +9,7 @@ import terser from "@rollup/plugin-terser";
|
||||
import typescript from "@rollup/plugin-typescript";
|
||||
import url from "@rollup/plugin-url";
|
||||
|
||||
const input = "src";
|
||||
const input = "src/frontend";
|
||||
const requirejs = readFileSync("../../node_modules/requirejs/require.js");
|
||||
|
||||
/** @type import("rollup").RollupOptions */
|
||||
|
Before Width: | Height: | Size: 375 B After Width: | Height: | Size: 375 B |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 189 B After Width: | Height: | Size: 189 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 158 B After Width: | Height: | Size: 158 B |
Before Width: | Height: | Size: 158 B After Width: | Height: | Size: 158 B |
Before Width: | Height: | Size: 287 B After Width: | Height: | Size: 287 B |
Before Width: | Height: | Size: 208 B After Width: | Height: | Size: 208 B |
Before Width: | Height: | Size: 259 B After Width: | Height: | Size: 259 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 189 B After Width: | Height: | Size: 189 B |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 977 B After Width: | Height: | Size: 977 B |
Before Width: | Height: | Size: 593 B After Width: | Height: | Size: 593 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 620 B After Width: | Height: | Size: 620 B |
Before Width: | Height: | Size: 218 B After Width: | Height: | Size: 218 B |
Before Width: | Height: | Size: 228 B After Width: | Height: | Size: 228 B |
Before Width: | Height: | Size: 218 B After Width: | Height: | Size: 218 B |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 243 B After Width: | Height: | Size: 243 B |
Before Width: | Height: | Size: 278 B After Width: | Height: | Size: 278 B |
Before Width: | Height: | Size: 266 B After Width: | Height: | Size: 266 B |
Before Width: | Height: | Size: 186 B After Width: | Height: | Size: 186 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 240 B After Width: | Height: | Size: 240 B |
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 257 B |
Before Width: | Height: | Size: 229 B After Width: | Height: | Size: 229 B |
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 236 B |
Before Width: | Height: | Size: 240 B After Width: | Height: | Size: 240 B |
Before Width: | Height: | Size: 242 B After Width: | Height: | Size: 242 B |
Before Width: | Height: | Size: 224 B After Width: | Height: | Size: 224 B |
Before Width: | Height: | Size: 229 B After Width: | Height: | Size: 229 B |
Before Width: | Height: | Size: 221 B After Width: | Height: | Size: 221 B |
Before Width: | Height: | Size: 220 B After Width: | Height: | Size: 220 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 232 B After Width: | Height: | Size: 232 B |
Before Width: | Height: | Size: 220 B After Width: | Height: | Size: 220 B |
Before Width: | Height: | Size: 220 B After Width: | Height: | Size: 220 B |
Before Width: | Height: | Size: 233 B After Width: | Height: | Size: 233 B |
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 236 B |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 193 B After Width: | Height: | Size: 193 B |
Before Width: | Height: | Size: 245 B After Width: | Height: | Size: 245 B |
Before Width: | Height: | Size: 235 B After Width: | Height: | Size: 235 B |
@ -26,7 +26,13 @@ import { noChildren } from "./components/support";
|
||||
import { WithExport, type DataExport } from "./components/WithExport";
|
||||
|
||||
(async () => {
|
||||
const base = "build/illuaminate";
|
||||
if (process.argv.length !== 5) {
|
||||
console.error("npx tsx ./index.tsx SOURCE EXPORT_JSON OUTPUT");
|
||||
console.error(`Received ${process.argv.length - 1} arguments, expected 4`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const [_node, _file, sourceDir, dataFile, outputDir] = process.argv;
|
||||
|
||||
const reactOptions: ReactOptions = {
|
||||
...(runtime as ReactOptions),
|
||||
@ -46,14 +52,14 @@ import { WithExport, type DataExport } from "./components/WithExport";
|
||||
.use(rehypeHighlight as unknown as Plugin<[HighlightOptions], import("hast").Root>, { prefix: "" })
|
||||
.use(rehypeReact, reactOptions);
|
||||
|
||||
const dataExport = JSON.parse(await fs.readFile("src/export/index.json", "utf-8")) as DataExport;
|
||||
const dataExport = JSON.parse(await fs.readFile(dataFile, "utf-8")) as DataExport;
|
||||
|
||||
for (const file of await glob(base + "/**/*.html")) {
|
||||
for (const file of await glob(sourceDir + "/**/*.html")) {
|
||||
const contents = await fs.readFile(file, "utf-8");
|
||||
|
||||
const { result } = await processor.process(contents);
|
||||
|
||||
const outputPath = path.resolve("build/jsxDocs", path.relative(base, file));
|
||||
const outputPath = path.resolve(outputDir, path.relative(sourceDir, file));
|
||||
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
||||
await fs.writeFile(outputPath, "<!doctype HTML>" + renderToStaticMarkup(<WithExport data={dataExport}>{result}</WithExport>));
|
||||
}
|