From 663eecff0cbb35afc71d99d15add53e1a4253e89 Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Thu, 28 Sep 2023 21:00:00 +0100 Subject: [PATCH] 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. --- .reuse/dep5 | 14 +++---- .../kotlin/cc/tweaked/gradle/ExecTasks.kt | 3 +- .../kotlin/cc/tweaked/gradle/Extensions.kt | 4 ++ illuaminate.sexp | 6 +-- projects/web/build.gradle.kts | 38 +++++++++++------- projects/web/rollup.config.js | 2 +- projects/web/src/{ => frontend}/index.tsx | 0 .../web/src/{ => frontend}/mount/.settings | 0 .../src/{ => frontend}/mount/example.dfpwm | 0 .../mount/example.dfpwm.license | 0 .../web/src/{ => frontend}/mount/example.nfp | 0 .../web/src/{ => frontend}/mount/example.nft | 0 .../{ => frontend}/mount/expr_template.lua | 0 .../web/src/{ => frontend}/mount/startup.lua | 0 projects/web/src/{ => frontend}/styles.css | 0 projects/web/src/{ => frontend}/typings.ts | 0 .../{ => htmlTransform}/components/Recipe.tsx | 0 .../components/WithExport.tsx | 0 .../components/support.tsx | 0 .../src/{ => htmlTransform}/export/index.json | 0 .../export/items/computercraft/cable.png | Bin .../items/computercraft/computer_advanced.png | Bin .../items/computercraft/computer_command.png | Bin .../items/computercraft/computer_normal.png | Bin .../export/items/computercraft/disk.png | Bin .../export/items/computercraft/disk_drive.png | Bin .../items/computercraft/monitor_advanced.png | Bin .../items/computercraft/monitor_normal.png | Bin .../pocket_computer_advanced.png | Bin .../computercraft/pocket_computer_normal.png | Bin .../items/computercraft/printed_book.png | Bin .../items/computercraft/printed_page.png | Bin .../items/computercraft/printed_pages.png | Bin .../export/items/computercraft/printer.png | Bin .../export/items/computercraft/speaker.png | Bin .../items/computercraft/treasure_disk.png | Bin .../items/computercraft/turtle_advanced.png | Bin .../items/computercraft/turtle_normal.png | Bin .../items/computercraft/wired_modem.png | Bin .../items/computercraft/wired_modem_full.png | Bin .../computercraft/wireless_modem_advanced.png | Bin .../computercraft/wireless_modem_normal.png | Bin .../export/items/minecraft/black_dye.png | Bin .../export/items/minecraft/blue_dye.png | Bin .../export/items/minecraft/brown_dye.png | Bin .../export/items/minecraft/chest.png | Bin .../export/items/minecraft/command_block.png | Bin .../export/items/minecraft/cyan_dye.png | Bin .../export/items/minecraft/ender_eye.png | Bin .../export/items/minecraft/ender_pearl.png | Bin .../export/items/minecraft/glass_pane.png | Bin .../export/items/minecraft/gold_block.png | Bin .../export/items/minecraft/gold_ingot.png | Bin .../export/items/minecraft/golden_apple.png | Bin .../export/items/minecraft/gray_dye.png | Bin .../export/items/minecraft/green_dye.png | Bin .../export/items/minecraft/iron_ingot.png | Bin .../export/items/minecraft/leather.png | Bin .../export/items/minecraft/light_blue_dye.png | Bin .../export/items/minecraft/light_gray_dye.png | Bin .../export/items/minecraft/lime_dye.png | Bin .../export/items/minecraft/magenta_dye.png | Bin .../export/items/minecraft/note_block.png | Bin .../export/items/minecraft/orange_dye.png | Bin .../export/items/minecraft/pink_dye.png | Bin .../export/items/minecraft/purple_dye.png | Bin .../export/items/minecraft/red_dye.png | Bin .../export/items/minecraft/redstone.png | Bin .../export/items/minecraft/stone.png | Bin .../export/items/minecraft/string.png | Bin .../export/items/minecraft/white_dye.png | Bin .../export/items/minecraft/yellow_dye.png | Bin .../index.tsx} | 14 +++++-- 73 files changed, 51 insertions(+), 30 deletions(-) rename projects/web/src/{ => frontend}/index.tsx (100%) rename projects/web/src/{ => frontend}/mount/.settings (100%) rename projects/web/src/{ => frontend}/mount/example.dfpwm (100%) rename projects/web/src/{ => frontend}/mount/example.dfpwm.license (100%) rename projects/web/src/{ => frontend}/mount/example.nfp (100%) rename projects/web/src/{ => frontend}/mount/example.nft (100%) rename projects/web/src/{ => frontend}/mount/expr_template.lua (100%) rename projects/web/src/{ => frontend}/mount/startup.lua (100%) rename projects/web/src/{ => frontend}/styles.css (100%) rename projects/web/src/{ => frontend}/typings.ts (100%) rename projects/web/src/{ => htmlTransform}/components/Recipe.tsx (100%) rename projects/web/src/{ => htmlTransform}/components/WithExport.tsx (100%) rename projects/web/src/{ => htmlTransform}/components/support.tsx (100%) rename projects/web/src/{ => htmlTransform}/export/index.json (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/cable.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/computer_advanced.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/computer_command.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/computer_normal.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/disk.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/disk_drive.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/monitor_advanced.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/monitor_normal.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/pocket_computer_advanced.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/pocket_computer_normal.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/printed_book.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/printed_page.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/printed_pages.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/printer.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/speaker.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/treasure_disk.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/turtle_advanced.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/turtle_normal.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/wired_modem.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/wired_modem_full.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/wireless_modem_advanced.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/computercraft/wireless_modem_normal.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/black_dye.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/blue_dye.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/brown_dye.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/chest.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/command_block.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/cyan_dye.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/ender_eye.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/ender_pearl.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/glass_pane.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/gold_block.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/gold_ingot.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/golden_apple.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/gray_dye.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/green_dye.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/iron_ingot.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/leather.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/light_blue_dye.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/light_gray_dye.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/lime_dye.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/magenta_dye.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/note_block.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/orange_dye.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/pink_dye.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/purple_dye.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/red_dye.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/redstone.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/stone.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/string.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/white_dye.png (100%) rename projects/web/src/{ => htmlTransform}/export/items/minecraft/yellow_dye.png (100%) rename projects/web/src/{transform.tsx => htmlTransform/index.tsx} (80%) diff --git a/.reuse/dep5 b/.reuse/dep5 index 7a3474724..309bc27d7 100644 --- a/.reuse/dep5 +++ b/.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 diff --git a/buildSrc/src/main/kotlin/cc/tweaked/gradle/ExecTasks.kt b/buildSrc/src/main/kotlin/cc/tweaked/gradle/ExecTasks.kt index 29ce2d5e2..d62b33b2f 100644 --- a/buildSrc/src/main/kotlin/cc/tweaked/gradle/ExecTasks.kt +++ b/buildSrc/src/main/kotlin/cc/tweaked/gradle/ExecTasks.kt @@ -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::class.java) { @get:OutputDirectory - abstract val output: Property + abstract val output: DirectoryProperty } diff --git a/buildSrc/src/main/kotlin/cc/tweaked/gradle/Extensions.kt b/buildSrc/src/main/kotlin/cc/tweaked/gradle/Extensions.kt index 41f97276b..27cf9dcc0 100644 --- a/buildSrc/src/main/kotlin/cc/tweaked/gradle/Extensions.kt +++ b/buildSrc/src/main/kotlin/cc/tweaked/gradle/Extensions.kt @@ -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 Property.setProvider(provider: Provider) = set(provider) + +/** Short-cut method to get the absolute path of a [FileSystemLocationProperty]. */ +fun FileSystemLocationProperty<*>.getAbsolutePath(): String = get().asFile.absolutePath diff --git a/illuaminate.sexp b/illuaminate.sexp index d033e3712..b72f0c497 100644 --- a/illuaminate.sexp +++ b/illuaminate.sexp @@ -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__))) diff --git a/projects/web/build.gradle.kts b/projects/web/build.gradle.kts index 874da7b5a..3fbb42c01 100644 --- a/projects/web/build.gradle.kts +++ b/projects/web/build.gradle.kts @@ -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) } diff --git a/projects/web/rollup.config.js b/projects/web/rollup.config.js index 41b5864f6..5390894ed 100644 --- a/projects/web/rollup.config.js +++ b/projects/web/rollup.config.js @@ -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 */ diff --git a/projects/web/src/index.tsx b/projects/web/src/frontend/index.tsx similarity index 100% rename from projects/web/src/index.tsx rename to projects/web/src/frontend/index.tsx diff --git a/projects/web/src/mount/.settings b/projects/web/src/frontend/mount/.settings similarity index 100% rename from projects/web/src/mount/.settings rename to projects/web/src/frontend/mount/.settings diff --git a/projects/web/src/mount/example.dfpwm b/projects/web/src/frontend/mount/example.dfpwm similarity index 100% rename from projects/web/src/mount/example.dfpwm rename to projects/web/src/frontend/mount/example.dfpwm diff --git a/projects/web/src/mount/example.dfpwm.license b/projects/web/src/frontend/mount/example.dfpwm.license similarity index 100% rename from projects/web/src/mount/example.dfpwm.license rename to projects/web/src/frontend/mount/example.dfpwm.license diff --git a/projects/web/src/mount/example.nfp b/projects/web/src/frontend/mount/example.nfp similarity index 100% rename from projects/web/src/mount/example.nfp rename to projects/web/src/frontend/mount/example.nfp diff --git a/projects/web/src/mount/example.nft b/projects/web/src/frontend/mount/example.nft similarity index 100% rename from projects/web/src/mount/example.nft rename to projects/web/src/frontend/mount/example.nft diff --git a/projects/web/src/mount/expr_template.lua b/projects/web/src/frontend/mount/expr_template.lua similarity index 100% rename from projects/web/src/mount/expr_template.lua rename to projects/web/src/frontend/mount/expr_template.lua diff --git a/projects/web/src/mount/startup.lua b/projects/web/src/frontend/mount/startup.lua similarity index 100% rename from projects/web/src/mount/startup.lua rename to projects/web/src/frontend/mount/startup.lua diff --git a/projects/web/src/styles.css b/projects/web/src/frontend/styles.css similarity index 100% rename from projects/web/src/styles.css rename to projects/web/src/frontend/styles.css diff --git a/projects/web/src/typings.ts b/projects/web/src/frontend/typings.ts similarity index 100% rename from projects/web/src/typings.ts rename to projects/web/src/frontend/typings.ts diff --git a/projects/web/src/components/Recipe.tsx b/projects/web/src/htmlTransform/components/Recipe.tsx similarity index 100% rename from projects/web/src/components/Recipe.tsx rename to projects/web/src/htmlTransform/components/Recipe.tsx diff --git a/projects/web/src/components/WithExport.tsx b/projects/web/src/htmlTransform/components/WithExport.tsx similarity index 100% rename from projects/web/src/components/WithExport.tsx rename to projects/web/src/htmlTransform/components/WithExport.tsx diff --git a/projects/web/src/components/support.tsx b/projects/web/src/htmlTransform/components/support.tsx similarity index 100% rename from projects/web/src/components/support.tsx rename to projects/web/src/htmlTransform/components/support.tsx diff --git a/projects/web/src/export/index.json b/projects/web/src/htmlTransform/export/index.json similarity index 100% rename from projects/web/src/export/index.json rename to projects/web/src/htmlTransform/export/index.json diff --git a/projects/web/src/export/items/computercraft/cable.png b/projects/web/src/htmlTransform/export/items/computercraft/cable.png similarity index 100% rename from projects/web/src/export/items/computercraft/cable.png rename to projects/web/src/htmlTransform/export/items/computercraft/cable.png diff --git a/projects/web/src/export/items/computercraft/computer_advanced.png b/projects/web/src/htmlTransform/export/items/computercraft/computer_advanced.png similarity index 100% rename from projects/web/src/export/items/computercraft/computer_advanced.png rename to projects/web/src/htmlTransform/export/items/computercraft/computer_advanced.png diff --git a/projects/web/src/export/items/computercraft/computer_command.png b/projects/web/src/htmlTransform/export/items/computercraft/computer_command.png similarity index 100% rename from projects/web/src/export/items/computercraft/computer_command.png rename to projects/web/src/htmlTransform/export/items/computercraft/computer_command.png diff --git a/projects/web/src/export/items/computercraft/computer_normal.png b/projects/web/src/htmlTransform/export/items/computercraft/computer_normal.png similarity index 100% rename from projects/web/src/export/items/computercraft/computer_normal.png rename to projects/web/src/htmlTransform/export/items/computercraft/computer_normal.png diff --git a/projects/web/src/export/items/computercraft/disk.png b/projects/web/src/htmlTransform/export/items/computercraft/disk.png similarity index 100% rename from projects/web/src/export/items/computercraft/disk.png rename to projects/web/src/htmlTransform/export/items/computercraft/disk.png diff --git a/projects/web/src/export/items/computercraft/disk_drive.png b/projects/web/src/htmlTransform/export/items/computercraft/disk_drive.png similarity index 100% rename from projects/web/src/export/items/computercraft/disk_drive.png rename to projects/web/src/htmlTransform/export/items/computercraft/disk_drive.png diff --git a/projects/web/src/export/items/computercraft/monitor_advanced.png b/projects/web/src/htmlTransform/export/items/computercraft/monitor_advanced.png similarity index 100% rename from projects/web/src/export/items/computercraft/monitor_advanced.png rename to projects/web/src/htmlTransform/export/items/computercraft/monitor_advanced.png diff --git a/projects/web/src/export/items/computercraft/monitor_normal.png b/projects/web/src/htmlTransform/export/items/computercraft/monitor_normal.png similarity index 100% rename from projects/web/src/export/items/computercraft/monitor_normal.png rename to projects/web/src/htmlTransform/export/items/computercraft/monitor_normal.png diff --git a/projects/web/src/export/items/computercraft/pocket_computer_advanced.png b/projects/web/src/htmlTransform/export/items/computercraft/pocket_computer_advanced.png similarity index 100% rename from projects/web/src/export/items/computercraft/pocket_computer_advanced.png rename to projects/web/src/htmlTransform/export/items/computercraft/pocket_computer_advanced.png diff --git a/projects/web/src/export/items/computercraft/pocket_computer_normal.png b/projects/web/src/htmlTransform/export/items/computercraft/pocket_computer_normal.png similarity index 100% rename from projects/web/src/export/items/computercraft/pocket_computer_normal.png rename to projects/web/src/htmlTransform/export/items/computercraft/pocket_computer_normal.png diff --git a/projects/web/src/export/items/computercraft/printed_book.png b/projects/web/src/htmlTransform/export/items/computercraft/printed_book.png similarity index 100% rename from projects/web/src/export/items/computercraft/printed_book.png rename to projects/web/src/htmlTransform/export/items/computercraft/printed_book.png diff --git a/projects/web/src/export/items/computercraft/printed_page.png b/projects/web/src/htmlTransform/export/items/computercraft/printed_page.png similarity index 100% rename from projects/web/src/export/items/computercraft/printed_page.png rename to projects/web/src/htmlTransform/export/items/computercraft/printed_page.png diff --git a/projects/web/src/export/items/computercraft/printed_pages.png b/projects/web/src/htmlTransform/export/items/computercraft/printed_pages.png similarity index 100% rename from projects/web/src/export/items/computercraft/printed_pages.png rename to projects/web/src/htmlTransform/export/items/computercraft/printed_pages.png diff --git a/projects/web/src/export/items/computercraft/printer.png b/projects/web/src/htmlTransform/export/items/computercraft/printer.png similarity index 100% rename from projects/web/src/export/items/computercraft/printer.png rename to projects/web/src/htmlTransform/export/items/computercraft/printer.png diff --git a/projects/web/src/export/items/computercraft/speaker.png b/projects/web/src/htmlTransform/export/items/computercraft/speaker.png similarity index 100% rename from projects/web/src/export/items/computercraft/speaker.png rename to projects/web/src/htmlTransform/export/items/computercraft/speaker.png diff --git a/projects/web/src/export/items/computercraft/treasure_disk.png b/projects/web/src/htmlTransform/export/items/computercraft/treasure_disk.png similarity index 100% rename from projects/web/src/export/items/computercraft/treasure_disk.png rename to projects/web/src/htmlTransform/export/items/computercraft/treasure_disk.png diff --git a/projects/web/src/export/items/computercraft/turtle_advanced.png b/projects/web/src/htmlTransform/export/items/computercraft/turtle_advanced.png similarity index 100% rename from projects/web/src/export/items/computercraft/turtle_advanced.png rename to projects/web/src/htmlTransform/export/items/computercraft/turtle_advanced.png diff --git a/projects/web/src/export/items/computercraft/turtle_normal.png b/projects/web/src/htmlTransform/export/items/computercraft/turtle_normal.png similarity index 100% rename from projects/web/src/export/items/computercraft/turtle_normal.png rename to projects/web/src/htmlTransform/export/items/computercraft/turtle_normal.png diff --git a/projects/web/src/export/items/computercraft/wired_modem.png b/projects/web/src/htmlTransform/export/items/computercraft/wired_modem.png similarity index 100% rename from projects/web/src/export/items/computercraft/wired_modem.png rename to projects/web/src/htmlTransform/export/items/computercraft/wired_modem.png diff --git a/projects/web/src/export/items/computercraft/wired_modem_full.png b/projects/web/src/htmlTransform/export/items/computercraft/wired_modem_full.png similarity index 100% rename from projects/web/src/export/items/computercraft/wired_modem_full.png rename to projects/web/src/htmlTransform/export/items/computercraft/wired_modem_full.png diff --git a/projects/web/src/export/items/computercraft/wireless_modem_advanced.png b/projects/web/src/htmlTransform/export/items/computercraft/wireless_modem_advanced.png similarity index 100% rename from projects/web/src/export/items/computercraft/wireless_modem_advanced.png rename to projects/web/src/htmlTransform/export/items/computercraft/wireless_modem_advanced.png diff --git a/projects/web/src/export/items/computercraft/wireless_modem_normal.png b/projects/web/src/htmlTransform/export/items/computercraft/wireless_modem_normal.png similarity index 100% rename from projects/web/src/export/items/computercraft/wireless_modem_normal.png rename to projects/web/src/htmlTransform/export/items/computercraft/wireless_modem_normal.png diff --git a/projects/web/src/export/items/minecraft/black_dye.png b/projects/web/src/htmlTransform/export/items/minecraft/black_dye.png similarity index 100% rename from projects/web/src/export/items/minecraft/black_dye.png rename to projects/web/src/htmlTransform/export/items/minecraft/black_dye.png diff --git a/projects/web/src/export/items/minecraft/blue_dye.png b/projects/web/src/htmlTransform/export/items/minecraft/blue_dye.png similarity index 100% rename from projects/web/src/export/items/minecraft/blue_dye.png rename to projects/web/src/htmlTransform/export/items/minecraft/blue_dye.png diff --git a/projects/web/src/export/items/minecraft/brown_dye.png b/projects/web/src/htmlTransform/export/items/minecraft/brown_dye.png similarity index 100% rename from projects/web/src/export/items/minecraft/brown_dye.png rename to projects/web/src/htmlTransform/export/items/minecraft/brown_dye.png diff --git a/projects/web/src/export/items/minecraft/chest.png b/projects/web/src/htmlTransform/export/items/minecraft/chest.png similarity index 100% rename from projects/web/src/export/items/minecraft/chest.png rename to projects/web/src/htmlTransform/export/items/minecraft/chest.png diff --git a/projects/web/src/export/items/minecraft/command_block.png b/projects/web/src/htmlTransform/export/items/minecraft/command_block.png similarity index 100% rename from projects/web/src/export/items/minecraft/command_block.png rename to projects/web/src/htmlTransform/export/items/minecraft/command_block.png diff --git a/projects/web/src/export/items/minecraft/cyan_dye.png b/projects/web/src/htmlTransform/export/items/minecraft/cyan_dye.png similarity index 100% rename from projects/web/src/export/items/minecraft/cyan_dye.png rename to projects/web/src/htmlTransform/export/items/minecraft/cyan_dye.png diff --git a/projects/web/src/export/items/minecraft/ender_eye.png b/projects/web/src/htmlTransform/export/items/minecraft/ender_eye.png similarity index 100% rename from projects/web/src/export/items/minecraft/ender_eye.png rename to projects/web/src/htmlTransform/export/items/minecraft/ender_eye.png diff --git a/projects/web/src/export/items/minecraft/ender_pearl.png b/projects/web/src/htmlTransform/export/items/minecraft/ender_pearl.png similarity index 100% rename from projects/web/src/export/items/minecraft/ender_pearl.png rename to projects/web/src/htmlTransform/export/items/minecraft/ender_pearl.png diff --git a/projects/web/src/export/items/minecraft/glass_pane.png b/projects/web/src/htmlTransform/export/items/minecraft/glass_pane.png similarity index 100% rename from projects/web/src/export/items/minecraft/glass_pane.png rename to projects/web/src/htmlTransform/export/items/minecraft/glass_pane.png diff --git a/projects/web/src/export/items/minecraft/gold_block.png b/projects/web/src/htmlTransform/export/items/minecraft/gold_block.png similarity index 100% rename from projects/web/src/export/items/minecraft/gold_block.png rename to projects/web/src/htmlTransform/export/items/minecraft/gold_block.png diff --git a/projects/web/src/export/items/minecraft/gold_ingot.png b/projects/web/src/htmlTransform/export/items/minecraft/gold_ingot.png similarity index 100% rename from projects/web/src/export/items/minecraft/gold_ingot.png rename to projects/web/src/htmlTransform/export/items/minecraft/gold_ingot.png diff --git a/projects/web/src/export/items/minecraft/golden_apple.png b/projects/web/src/htmlTransform/export/items/minecraft/golden_apple.png similarity index 100% rename from projects/web/src/export/items/minecraft/golden_apple.png rename to projects/web/src/htmlTransform/export/items/minecraft/golden_apple.png diff --git a/projects/web/src/export/items/minecraft/gray_dye.png b/projects/web/src/htmlTransform/export/items/minecraft/gray_dye.png similarity index 100% rename from projects/web/src/export/items/minecraft/gray_dye.png rename to projects/web/src/htmlTransform/export/items/minecraft/gray_dye.png diff --git a/projects/web/src/export/items/minecraft/green_dye.png b/projects/web/src/htmlTransform/export/items/minecraft/green_dye.png similarity index 100% rename from projects/web/src/export/items/minecraft/green_dye.png rename to projects/web/src/htmlTransform/export/items/minecraft/green_dye.png diff --git a/projects/web/src/export/items/minecraft/iron_ingot.png b/projects/web/src/htmlTransform/export/items/minecraft/iron_ingot.png similarity index 100% rename from projects/web/src/export/items/minecraft/iron_ingot.png rename to projects/web/src/htmlTransform/export/items/minecraft/iron_ingot.png diff --git a/projects/web/src/export/items/minecraft/leather.png b/projects/web/src/htmlTransform/export/items/minecraft/leather.png similarity index 100% rename from projects/web/src/export/items/minecraft/leather.png rename to projects/web/src/htmlTransform/export/items/minecraft/leather.png diff --git a/projects/web/src/export/items/minecraft/light_blue_dye.png b/projects/web/src/htmlTransform/export/items/minecraft/light_blue_dye.png similarity index 100% rename from projects/web/src/export/items/minecraft/light_blue_dye.png rename to projects/web/src/htmlTransform/export/items/minecraft/light_blue_dye.png diff --git a/projects/web/src/export/items/minecraft/light_gray_dye.png b/projects/web/src/htmlTransform/export/items/minecraft/light_gray_dye.png similarity index 100% rename from projects/web/src/export/items/minecraft/light_gray_dye.png rename to projects/web/src/htmlTransform/export/items/minecraft/light_gray_dye.png diff --git a/projects/web/src/export/items/minecraft/lime_dye.png b/projects/web/src/htmlTransform/export/items/minecraft/lime_dye.png similarity index 100% rename from projects/web/src/export/items/minecraft/lime_dye.png rename to projects/web/src/htmlTransform/export/items/minecraft/lime_dye.png diff --git a/projects/web/src/export/items/minecraft/magenta_dye.png b/projects/web/src/htmlTransform/export/items/minecraft/magenta_dye.png similarity index 100% rename from projects/web/src/export/items/minecraft/magenta_dye.png rename to projects/web/src/htmlTransform/export/items/minecraft/magenta_dye.png diff --git a/projects/web/src/export/items/minecraft/note_block.png b/projects/web/src/htmlTransform/export/items/minecraft/note_block.png similarity index 100% rename from projects/web/src/export/items/minecraft/note_block.png rename to projects/web/src/htmlTransform/export/items/minecraft/note_block.png diff --git a/projects/web/src/export/items/minecraft/orange_dye.png b/projects/web/src/htmlTransform/export/items/minecraft/orange_dye.png similarity index 100% rename from projects/web/src/export/items/minecraft/orange_dye.png rename to projects/web/src/htmlTransform/export/items/minecraft/orange_dye.png diff --git a/projects/web/src/export/items/minecraft/pink_dye.png b/projects/web/src/htmlTransform/export/items/minecraft/pink_dye.png similarity index 100% rename from projects/web/src/export/items/minecraft/pink_dye.png rename to projects/web/src/htmlTransform/export/items/minecraft/pink_dye.png diff --git a/projects/web/src/export/items/minecraft/purple_dye.png b/projects/web/src/htmlTransform/export/items/minecraft/purple_dye.png similarity index 100% rename from projects/web/src/export/items/minecraft/purple_dye.png rename to projects/web/src/htmlTransform/export/items/minecraft/purple_dye.png diff --git a/projects/web/src/export/items/minecraft/red_dye.png b/projects/web/src/htmlTransform/export/items/minecraft/red_dye.png similarity index 100% rename from projects/web/src/export/items/minecraft/red_dye.png rename to projects/web/src/htmlTransform/export/items/minecraft/red_dye.png diff --git a/projects/web/src/export/items/minecraft/redstone.png b/projects/web/src/htmlTransform/export/items/minecraft/redstone.png similarity index 100% rename from projects/web/src/export/items/minecraft/redstone.png rename to projects/web/src/htmlTransform/export/items/minecraft/redstone.png diff --git a/projects/web/src/export/items/minecraft/stone.png b/projects/web/src/htmlTransform/export/items/minecraft/stone.png similarity index 100% rename from projects/web/src/export/items/minecraft/stone.png rename to projects/web/src/htmlTransform/export/items/minecraft/stone.png diff --git a/projects/web/src/export/items/minecraft/string.png b/projects/web/src/htmlTransform/export/items/minecraft/string.png similarity index 100% rename from projects/web/src/export/items/minecraft/string.png rename to projects/web/src/htmlTransform/export/items/minecraft/string.png diff --git a/projects/web/src/export/items/minecraft/white_dye.png b/projects/web/src/htmlTransform/export/items/minecraft/white_dye.png similarity index 100% rename from projects/web/src/export/items/minecraft/white_dye.png rename to projects/web/src/htmlTransform/export/items/minecraft/white_dye.png diff --git a/projects/web/src/export/items/minecraft/yellow_dye.png b/projects/web/src/htmlTransform/export/items/minecraft/yellow_dye.png similarity index 100% rename from projects/web/src/export/items/minecraft/yellow_dye.png rename to projects/web/src/htmlTransform/export/items/minecraft/yellow_dye.png diff --git a/projects/web/src/transform.tsx b/projects/web/src/htmlTransform/index.tsx similarity index 80% rename from projects/web/src/transform.tsx rename to projects/web/src/htmlTransform/index.tsx index f1ce6d441..0839207d9 100644 --- a/projects/web/src/transform.tsx +++ b/projects/web/src/htmlTransform/index.tsx @@ -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, "" + renderToStaticMarkup({result})); }