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

fix: Replaced hbs with express-handlebars #1659

Merged
merged 2 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
115 changes: 37 additions & 78 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"dotenv": "^8.2.0",
"eventsource": "^1.0.7",
"express": "^4.17.1",
"hbs": "^4.2.0",
"express-handlebars": "^6.0.3",
"ioredis": "^4.27.8",
"js-yaml": "^3.14.1",
"lru-cache": "^6.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/apps/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function defaultApp(
pkg = {};
}

res.render("probot.hbs", pkg);
res.render("probot.handlebars", pkg);
});
router.get("/", (req, res, next) => res.redirect("/probot"));
}
6 changes: 3 additions & 3 deletions src/apps/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const setupAppFactory = (
const manifest = setup.getManifest(pkg, baseUrl);
const createAppUrl = setup.createAppUrl;
// Pass the manifest to be POST'd
res.render("setup.hbs", { pkg, createAppUrl, manifest });
res.render("setup.handlebars", { pkg, createAppUrl, manifest });
});

route.get("/probot/setup", async (req: Request, res: Response) => {
Expand All @@ -71,7 +71,7 @@ export const setupAppFactory = (
route.get("/probot/import", async (_req, res) => {
const { WEBHOOK_PROXY_URL, GHE_HOST } = process.env;
const GH_HOST = `https://${GHE_HOST ?? "github.com"}`;
res.render("import.hbs", { WEBHOOK_PROXY_URL, GH_HOST });
res.render("import.handlebars", { WEBHOOK_PROXY_URL, GH_HOST });
});

route.post("/probot/import", bodyParser.json(), async (req, res) => {
Expand All @@ -90,7 +90,7 @@ export const setupAppFactory = (
});

route.get("/probot/success", async (req, res) => {
res.render("success.hbs");
res.render("success.handlebars");
});

route.get("/", (req, res, next) => res.redirect("/probot"));
Expand Down
9 changes: 8 additions & 1 deletion src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { createWebhookProxy } from "../helpers/webhook-proxy";
import { VERSION } from "../version";
import { ApplicationFunction, ServerOptions } from "../types";
import { Probot } from "../";
import { engine } from "express-handlebars";

type State = {
httpServer?: HttpServer;
Expand Down Expand Up @@ -55,7 +56,13 @@ export class Server {
})
);

this.expressApp.set("view engine", "hbs");
this.expressApp.engine(
"handlebars",
engine({
defaultLayout: false,
})
);
this.expressApp.set("view engine", "handlebars");
this.expressApp.set("views", join(__dirname, "..", "..", "views"));
this.expressApp.get("/ping", (req, res) => res.end("PONG"));
}
Expand Down
2 changes: 1 addition & 1 deletion test/apps/setup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe("Setup app", () => {
});

describe("GET /probot/import", () => {
it("renders import.hbs", async () => {
it("renders import.handlebars", async () => {
await request(server.expressApp).get("/probot/import").expect(200);
});
});
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.