mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 05:33:00 +00:00 
			
		
		
		
	Move website source/build logic to projects/web
Mostly useful as it moves some of our build logic out of the main project, as that's already pretty noisy!
This commit is contained in:
		
							
								
								
									
										2
									
								
								.github/workflows/make-doc.sh
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/make-doc.sh
									
									
									
									
										vendored
									
									
								
							| @@ -12,7 +12,7 @@ chmod 600 "$HOME/.ssh/key" | |||||||
|  |  | ||||||
| # And upload | # And upload | ||||||
| rsync -avc -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no -p $SSH_PORT" \ | rsync -avc -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no -p $SSH_PORT" \ | ||||||
|       "$GITHUB_WORKSPACE/build/docs/site/" \ |       "$GITHUB_WORKSPACE/projects/web/build/site/" \ | ||||||
|       "$SSH_USER@$SSH_HOST:/$DEST" |       "$SSH_USER@$SSH_HOST:/$DEST" | ||||||
| rsync -avc -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no -p $SSH_PORT" \ | rsync -avc -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no -p $SSH_PORT" \ | ||||||
|       "$GITHUB_WORKSPACE/build/docs/javadoc/" \ |       "$GITHUB_WORKSPACE/build/docs/javadoc/" \ | ||||||
|   | |||||||
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -11,7 +11,6 @@ | |||||||
|  |  | ||||||
| # Runtime directories | # Runtime directories | ||||||
| /run | /run | ||||||
| /run-* |  | ||||||
|  |  | ||||||
| *.ipr | *.ipr | ||||||
| *.iws | *.iws | ||||||
| @@ -24,8 +23,6 @@ | |||||||
| /.project | /.project | ||||||
| /.settings | /.settings | ||||||
| /.vscode | /.vscode | ||||||
| bin/ |  | ||||||
| *.launch | *.launch | ||||||
|  |  | ||||||
| /src/generated/resources/.cache | /src/generated/resources/.cache | ||||||
| /src/web/mount/*.d.ts |  | ||||||
|   | |||||||
| @@ -52,7 +52,7 @@ complexity is hidden by Gradle, but you will need to perform some initial setup: | |||||||
|  - Run `npm ci` to install our Node dependencies. |  - Run `npm ci` to install our Node dependencies. | ||||||
| 
 | 
 | ||||||
| You can now run `./gradlew docWebsite`. This generates documentation from our Lua and Java code, writing the resulting | You can now run `./gradlew docWebsite`. This generates documentation from our Lua and Java code, writing the resulting | ||||||
| HTML into `./build/docs/site`. | HTML into `./projects/web/build/site`. | ||||||
| 
 | 
 | ||||||
| #### Writing documentation | #### Writing documentation | ||||||
| illuaminate's documentation system is not currently documented (somewhat ironic), but is _largely_ the same as | illuaminate's documentation system is not currently documented (somewhat ironic), but is _largely_ the same as | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ plugins { | |||||||
|     alias(libs.plugins.ideaExt) |     alias(libs.plugins.ideaExt) | ||||||
|  |  | ||||||
|     id("cc-tweaked.illuaminate") |     id("cc-tweaked.illuaminate") | ||||||
|     id("cc-tweaked.node") |  | ||||||
|     id("cc-tweaked.gametest") |     id("cc-tweaked.gametest") | ||||||
|     id("cc-tweaked.publishing") |     id("cc-tweaked.publishing") | ||||||
|     id("cc-tweaked") |     id("cc-tweaked") | ||||||
| @@ -247,78 +246,6 @@ tasks.shadowJar { | |||||||
|  |  | ||||||
| tasks.assemble { dependsOn("shadowJar") } | tasks.assemble { dependsOn("shadowJar") } | ||||||
|  |  | ||||||
| // Web tasks |  | ||||||
|  |  | ||||||
| val rollup by tasks.registering(NpxExecToDir::class) { |  | ||||||
|     group = LifecycleBasePlugin.BUILD_GROUP |  | ||||||
|     description = "Bundles JS into rollup" |  | ||||||
|  |  | ||||||
|     // Sources |  | ||||||
|     inputs.files(fileTree("src/web")).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")) |  | ||||||
|  |  | ||||||
|     args = listOf("rollup", "--config", "rollup.config.js") |  | ||||||
| } |  | ||||||
|  |  | ||||||
| val illuaminateDocs by tasks.registering(IlluaminateExecToDir::class) { |  | ||||||
|     group = JavaBasePlugin.DOCUMENTATION_GROUP |  | ||||||
|     description = "Generates docs using Illuaminate" |  | ||||||
|  |  | ||||||
|     // Config files |  | ||||||
|     inputs.file("illuaminate.sexp").withPropertyName("illuaminate.sexp") |  | ||||||
|     // Sources |  | ||||||
|     inputs.files(fileTree("doc")).withPropertyName("docs") |  | ||||||
|     inputs.files(fileTree("src/main/resources/data/computercraft/lua")).withPropertyName("lua rom") |  | ||||||
|     inputs.files(luaJavadoc) |  | ||||||
|     // Additional assets |  | ||||||
|     inputs.files(rollup) |  | ||||||
|     inputs.file("src/web/styles.css").withPropertyName("styles") |  | ||||||
|  |  | ||||||
|     // Output directory. Also defined in illuaminate.sexp and transform.tsx |  | ||||||
|     output.set(buildDir.resolve("illuaminate")) |  | ||||||
|  |  | ||||||
|     args = listOf("doc-gen") |  | ||||||
| } |  | ||||||
|  |  | ||||||
| val jsxDocs by tasks.registering(NpxExecToDir::class) { |  | ||||||
|     group = JavaBasePlugin.DOCUMENTATION_GROUP |  | ||||||
|     description = "Post-processes documentation to statically render some dynamic content." |  | ||||||
|  |  | ||||||
|     // Config files |  | ||||||
|     inputs.file("tsconfig.json").withPropertyName("Typescript config") |  | ||||||
|     // Sources |  | ||||||
|     inputs.files(fileTree("src/web")).withPropertyName("sources") |  | ||||||
|     inputs.file("src/generated/export/index.json").withPropertyName("export") |  | ||||||
|     inputs.files(illuaminateDocs) |  | ||||||
|  |  | ||||||
|     // Output directory. Also defined in src/web/transform.tsx |  | ||||||
|     output.set(buildDir.resolve("jsxDocs")) |  | ||||||
|  |  | ||||||
|     args = listOf("ts-node", "-T", "--esm", "src/web/transform.tsx") |  | ||||||
| } |  | ||||||
|  |  | ||||||
| val docWebsite by tasks.registering(Copy::class) { |  | ||||||
|     group = JavaBasePlugin.DOCUMENTATION_GROUP |  | ||||||
|     description = "Assemble docs and assets together into the documentation website." |  | ||||||
|  |  | ||||||
|     from(jsxDocs) |  | ||||||
|  |  | ||||||
|     from("doc") { |  | ||||||
|         include("logo.png") |  | ||||||
|         include("images/**") |  | ||||||
|     } |  | ||||||
|     from(rollup) { exclude("index.js") } |  | ||||||
|     from(illuaminateDocs) { exclude("**/*.html") } |  | ||||||
|     from("src/generated/export/items") { into("images/items") } |  | ||||||
|  |  | ||||||
|     into(buildDir.resolve("docs/site")) |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Check tasks | // Check tasks | ||||||
|  |  | ||||||
| tasks.test { | tasks.test { | ||||||
|   | |||||||
| @@ -6,11 +6,12 @@ | |||||||
|   /projects/core/src/main/resources/data/computercraft/lua/bios.lua |   /projects/core/src/main/resources/data/computercraft/lua/bios.lua | ||||||
|   /projects/core/src/main/resources/data/computercraft/lua/rom/ |   /projects/core/src/main/resources/data/computercraft/lua/rom/ | ||||||
|   /projects/core/src/test/resources/test-rom |   /projects/core/src/test/resources/test-rom | ||||||
|   /src/web/mount) |   /projects/web/src/mount) | ||||||
|  |  | ||||||
|  |  | ||||||
| (doc | (doc | ||||||
|   (destination build/illuaminate) |   ; Also defined in projects/web/build.gradle.kts | ||||||
|  |   (destination /projects/web/build/illuaminate) | ||||||
|   (index doc/index.md) |   (index doc/index.md) | ||||||
|  |  | ||||||
|   (site |   (site | ||||||
| @@ -19,8 +20,8 @@ | |||||||
|     (url https://tweaked.cc/) |     (url https://tweaked.cc/) | ||||||
|     (source-link https://github.com/cc-tweaked/CC-Tweaked/blob/${commit}/${path}#L${line}) |     (source-link https://github.com/cc-tweaked/CC-Tweaked/blob/${commit}/${path}#L${line}) | ||||||
|  |  | ||||||
|     (styles src/web/styles.css) |     (styles /projects/web/src/styles.css) | ||||||
|     (scripts build/rollup/index.js) |     (scripts /projects/web/build/rollup/index.js) | ||||||
|     (head doc/head.html)) |     (head doc/head.html)) | ||||||
|  |  | ||||||
|   (module-kinds |   (module-kinds | ||||||
| @@ -113,4 +114,4 @@ | |||||||
|       :max sleep write |       :max sleep write | ||||||
|       cct_test describe expect howlci fail it pending stub))) |       cct_test describe expect howlci fail it pending stub))) | ||||||
|  |  | ||||||
| (at /src/web/mount/expr_template.lua (lint (globals :max __expr__))) | (at /projects/web/src/mount/expr_template.lua (lint (globals :max __expr__))) | ||||||
|   | |||||||
							
								
								
									
										91
									
								
								projects/web/build.gradle.kts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								projects/web/build.gradle.kts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,91 @@ | |||||||
|  | plugins { | ||||||
|  |     `lifecycle-base` | ||||||
|  |     id("cc-tweaked.node") | ||||||
|  |     id("cc-tweaked.illuaminate") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | node { | ||||||
|  |     projectRoot.set(rootProject.projectDir) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | illuaminate { | ||||||
|  |     version.set(libs.versions.illuaminate) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | val rollup by tasks.registering(cc.tweaked.gradle.NpxExecToDir::class) { | ||||||
|  |     group = LifecycleBasePlugin.BUILD_GROUP | ||||||
|  |     description = "Bundles JS into rollup" | ||||||
|  |  | ||||||
|  |     // Sources | ||||||
|  |     inputs.files(fileTree("src")).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")) | ||||||
|  |  | ||||||
|  |     args = listOf("rollup", "--config", "rollup.config.js") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | val illuaminateDocs by tasks.registering(cc.tweaked.gradle.IlluaminateExecToDir::class) { | ||||||
|  |     group = JavaBasePlugin.DOCUMENTATION_GROUP | ||||||
|  |     description = "Generates docs using Illuaminate" | ||||||
|  |  | ||||||
|  |     // Config files | ||||||
|  |     inputs.file(rootProject.file("illuaminate.sexp")).withPropertyName("illuaminate config") | ||||||
|  |     // Sources | ||||||
|  |     inputs.files(fileTree("doc")).withPropertyName("docs") | ||||||
|  |     inputs.files(fileTree("src/main/resources/data/computercraft/lua")).withPropertyName("lua rom") | ||||||
|  |     inputs.files(rootProject.tasks.named("luaJavadoc")) | ||||||
|  |     // Additional assets | ||||||
|  |     inputs.files(rollup) | ||||||
|  |     inputs.file("src/styles.css").withPropertyName("styles") | ||||||
|  |  | ||||||
|  |     // Output directory. Also defined in illuaminate.sexp and transform.tsx | ||||||
|  |     output.set(buildDir.resolve("illuaminate")) | ||||||
|  |  | ||||||
|  |     args = listOf("doc-gen") | ||||||
|  |     workingDir = rootProject.projectDir | ||||||
|  | } | ||||||
|  |  | ||||||
|  | val jsxDocs by tasks.registering(cc.tweaked.gradle.NpxExecToDir::class) { | ||||||
|  |     group = JavaBasePlugin.DOCUMENTATION_GROUP | ||||||
|  |     description = "Post-processes documentation to statically render some dynamic content." | ||||||
|  |  | ||||||
|  |     // Config files | ||||||
|  |     inputs.file("tsconfig.json").withPropertyName("Typescript config") | ||||||
|  |     // Sources | ||||||
|  |     inputs.files(fileTree("src")).withPropertyName("sources") | ||||||
|  |     inputs.file(rootProject.file("src/generated/export/index.json")).withPropertyName("export") | ||||||
|  |     inputs.files(illuaminateDocs) | ||||||
|  |  | ||||||
|  |     // Output directory. Also defined in src/transform.tsx | ||||||
|  |     output.set(buildDir.resolve("jsxDocs")) | ||||||
|  |  | ||||||
|  |     args = listOf("ts-node", "-T", "--esm", "src/transform.tsx") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | val docWebsite by tasks.registering(Copy::class) { | ||||||
|  |     group = JavaBasePlugin.DOCUMENTATION_GROUP | ||||||
|  |     description = "Assemble docs and assets together into the documentation website." | ||||||
|  |     duplicatesStrategy = DuplicatesStrategy.FAIL | ||||||
|  |  | ||||||
|  |     from(jsxDocs) | ||||||
|  |  | ||||||
|  |     // Pick up assets from the /docs folder | ||||||
|  |     from(rootProject.file("doc")) { | ||||||
|  |         include("logo.png") | ||||||
|  |         include("images/**") | ||||||
|  |     } | ||||||
|  |     // index.js is provided by illuaminate, but rollup outputs some other chunks | ||||||
|  |     from(rollup) { exclude("index.js") } | ||||||
|  |     // Grab illuaminate's assets. HTML files are provided by jsxDocs | ||||||
|  |     from(illuaminateDocs) { exclude("**/*.html") } | ||||||
|  |     // And item/block images from the data export | ||||||
|  |     from(rootProject.file("src/generated/export/items")) { into("images/items") } | ||||||
|  |  | ||||||
|  |     into(buildDir.resolve("site")) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | tasks.assemble { dependsOn(docWebsite) } | ||||||
| @@ -5,13 +5,15 @@ import typescript from "@rollup/plugin-typescript"; | |||||||
| import url from '@rollup/plugin-url'; | import url from '@rollup/plugin-url'; | ||||||
| import { terser } from "rollup-plugin-terser"; | import { terser } from "rollup-plugin-terser"; | ||||||
| 
 | 
 | ||||||
| const input = "src/web"; | const input = "src"; | ||||||
| const requirejs = readFileSync("node_modules/requirejs/require.js"); | const requirejs = readFileSync("../../node_modules/requirejs/require.js"); | ||||||
| 
 | 
 | ||||||
| export default { | export default { | ||||||
|     input: [`${input}/index.tsx`], |     input: [`${input}/index.tsx`], | ||||||
|     output: { |     output: { | ||||||
|  |         // Also defined in build.gradle.kts
 | ||||||
|         dir: "build/rollup/", |         dir: "build/rollup/", | ||||||
|  | 
 | ||||||
|         // We bundle requirejs (and config) into the header. It's rather gross
 |         // We bundle requirejs (and config) into the header. It's rather gross
 | ||||||
|         // but also works reasonably well.
 |         // but also works reasonably well.
 | ||||||
|         // Also suffix a ?v=${date} onto the end in the event we need to require a specific copy-cat version.
 |         // Also suffix a ?v=${date} onto the end in the event we need to require a specific copy-cat version.
 | ||||||
| @@ -39,7 +39,7 @@ const glob = promisify(globModule); | |||||||
|             } as any |             } as any | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|     const dataExport = JSON.parse(await fs.readFile("src/generated/export/index.json", "utf-8")) as DataExport; |     const dataExport = JSON.parse(await fs.readFile("../../src/generated/export/index.json", "utf-8")) as DataExport; | ||||||
| 
 | 
 | ||||||
|     for (const file of await glob(base + "/**/*.html")) { |     for (const file of await glob(base + "/**/*.html")) { | ||||||
|         const contents = await fs.readFile(file, "utf-8"); |         const contents = await fs.readFile(file, "utf-8"); | ||||||
| @@ -27,6 +27,6 @@ | |||||||
|         "allowSyntheticDefaultImports": true, |         "allowSyntheticDefaultImports": true, | ||||||
|     }, |     }, | ||||||
|     "include": [ |     "include": [ | ||||||
|         "src/web", |         "src", | ||||||
|     ] |     ] | ||||||
| } | } | ||||||
| @@ -19,6 +19,7 @@ rootProject.name = "cc-tweaked-$mcVersion" | |||||||
| include(":mc-stubs") | include(":mc-stubs") | ||||||
| include(":core-api") | include(":core-api") | ||||||
| include(":core") | include(":core") | ||||||
|  | include(":web") | ||||||
|  |  | ||||||
| for (project in rootProject.children) { | for (project in rootProject.children) { | ||||||
|     project.projectDir = file("projects/${project.name}") |     project.projectDir = file("projects/${project.name}") | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jonathan Coates
					Jonathan Coates