Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mrc-6023 POC static build #236

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 206 additions & 0 deletions app/server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion app/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
"coverage": "vitest -c ./vitest/vitest.unit.config.mjs run --coverage",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"genversion": "genversion --es6 --semi --double src/version.ts"
"genversion": "genversion --es6 --semi --double src/version.ts",
"static-serve": "http-server ./public -p 3000",
"copy-static-files": "cp ../../config/index.html ./public && cp -r ../../config/files ./public && cp -r ../../config/help ./public",
"build-static-site": "ts-node --project tsconfig.node.json ./src/static-site-builder/wodinBuilder.ts ../../config ./public ./views && npm run copy-static-files"
},
"devDependencies": {
"@eslint/js": "^9.14.0",
Expand All @@ -28,6 +31,7 @@
"@vitest/coverage-istanbul": "^2.1.4",
"axios-mock-adapter": "^2.1.0",
"eslint": "^9.14.0",
"http-server": "^14.1.1",
"nodemon": "^3.1.7",
"supertest": "^7.0.0",
"ts-node": "^10.9.2",
Expand Down
4 changes: 2 additions & 2 deletions app/server/src/controllers/configController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const configDefaults = (appType: string) => {
};

export class ConfigController {
private static _readAppConfigFile = (
static readAppConfigFile = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we'll pull this out of the controller when we implement for real.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually we dont have to! we need the whole config controller any and tree shaking means that we only get that and not everything else, we just put wodinBuilder as the entry point

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't have to but it seems odd to use a part of the server controller from the static build script.

appName: string,
appsPath: string,
_baseUrl: string,
Expand Down Expand Up @@ -54,7 +54,7 @@ export class ConfigController {
configReader, appsPath, defaultCodeReader, appHelpReader, baseUrl
} = req.app.locals as AppLocals;

const config = this._readAppConfigFile(
const config = this.readAppConfigFile(
appName,
appsPath,
baseUrl,
Expand Down
15 changes: 15 additions & 0 deletions app/server/src/static-site-builder/args.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const doc = `
Usage:
builder <path-to-config> <dest-path> <path-to-mustache-views>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. the views path doesn't seem like it needs to be a parameter as it's not something that should change per build..?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can change between development and production, it depends on the folder structure of the dist folder, which may not be the same as the folder structure of our app/server directory, i guess we can also force them to be the same and hardcode that path in wodin builder as well but felt nice to give that flexibility

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd assumed this would always be done from a development context, but yeah I suppose it doesn't have to be!

`;

import { docopt } from "docopt";
import { version } from "../version";

export const processArgs = (argv: string[] = process.argv) => {
const opts = docopt(doc, { argv: argv.slice(2), version, exit: false });
const configPath = opts["<path-to-config>"] as string;
const destPath = opts["<dest-path>"] as string;
const viewsPath = opts["<path-to-mustache-views>"] as string;
return { configPath, destPath, viewsPath };
};
Loading
Loading