@olenbetong/appframe-vite 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/devServer.js +10 -9
  2. package/package.json +1 -1
package/lib/devServer.js CHANGED
@@ -11,10 +11,16 @@ dotenv.config();
11
11
  let appPkg = await importJson("./package.json", true);
12
12
  let { appframe } = appPkg;
13
13
  let userSession = null;
14
- async function getUserSession(hostname, username, password) {
14
+ async function getUserSession() {
15
+ var _a, _b, _c, _d;
15
16
  if (userSession) {
16
17
  return userSession;
17
18
  }
19
+ const hostname = (_d = (_b = (_a = appframe.proxy) === null || _a === void 0 ? void 0 : _a.hostname) !== null && _b !== void 0 ? _b : (_c = appframe.deploy) === null || _c === void 0 ? void 0 : _c.hostname) !== null && _d !== void 0 ? _d : "dev.obet.no";
20
+ const { APPFRAME_LOGIN: username, APPFRAME_PWD: password } = process.env;
21
+ if (!username || !password) {
22
+ throw new Error("Your Appframe credentials are not set in the environment variables. Username should be set in APPFRAME_LOGIN and password in APPFRAME_PWD.");
23
+ }
18
24
  let client = new Client(hostname);
19
25
  await client.login(username, password);
20
26
  let userResult = await client.afFetch("/api/system/usersession", {
@@ -56,15 +62,10 @@ export async function createProxyMiddleware() {
56
62
  return router;
57
63
  }
58
64
  export function createHtmlTransformer() {
59
- var _a, _b, _c, _d, _e, _f;
60
- const hostname = (_d = (_b = (_a = appframe.proxy) === null || _a === void 0 ? void 0 : _a.hostname) !== null && _b !== void 0 ? _b : (_c = appframe.deploy) === null || _c === void 0 ? void 0 : _c.hostname) !== null && _d !== void 0 ? _d : "dev.obet.no";
61
- const { APPFRAME_LOGIN: username, APPFRAME_PWD: password } = process.env;
62
- let isPartner = ((_f = (_e = appPkg.appframe) === null || _e === void 0 ? void 0 : _e.article) === null || _f === void 0 ? void 0 : _f.hostname) === "partner.olenbetong.no";
63
- if (!username || !password) {
64
- throw new Error("Your Appframe credentials are not set in the environment variables. Username should be set in APPFRAME_LOGIN and password in APPFRAME_PWD.");
65
- }
66
65
  return async (html) => {
67
- let userSession = await getUserSession(hostname, username, password);
66
+ var _a, _b;
67
+ let isPartner = ((_b = (_a = appPkg.appframe) === null || _a === void 0 ? void 0 : _a.article) === null || _b === void 0 ? void 0 : _b.hostname) === "partner.olenbetong.no";
68
+ let userSession = await getUserSession();
68
69
  return html
69
70
  .replace("<!-- {Appframe} -->", `<script>
70
71
  af = globalThis.af ?? {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olenbetong/appframe-vite",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Tools to use and deploy Vite applications to Appframe",
5
5
  "main": "./lib/index.js",
6
6
  "type": "module",