@ofidj/generator-fidj 1.0.7 → 1.0.8
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.
- package/generators/app/templates/typescript/server/index.ts +2 -0
- package/generators/app/templates/typescript/src/content.ts +1 -1
- package/generators/app/templates/typescript/src/main.ts +1 -1
- package/generators/app/templates/typescript/src/version.ts +12 -1
- package/lib/scaffold.cjs +3 -2
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ export interface Settings {
|
|
|
11
11
|
apiEndpoint: string;
|
|
12
12
|
dashboardUrl: string;
|
|
13
13
|
title: string;
|
|
14
|
+
releaseVersion: string;
|
|
14
15
|
localDemo: boolean;
|
|
15
16
|
}
|
|
16
17
|
class HttpError extends Error {
|
|
@@ -324,6 +325,7 @@ if (require.main === module) {
|
|
|
324
325
|
apiEndpoint,
|
|
325
326
|
dashboardUrl: process.env.FIDJ_DASHBOARD_URL || "https://fidj.ovh",
|
|
326
327
|
title: process.env.APP_TITLE || "My workspace",
|
|
328
|
+
releaseVersion: process.env.APP_VERSION || "",
|
|
327
329
|
localDemo:
|
|
328
330
|
process.env.LOCAL_DEMO === "true" &&
|
|
329
331
|
host === "127.0.0.1" &&
|
|
@@ -7,7 +7,7 @@ import { showVersionBadge } from "./version";
|
|
|
7
7
|
const sdk = new FidjNodeService();
|
|
8
8
|
const oidc = config.oidcIssuer ? new FidjOidcClient({issuer: config.oidcIssuer, clientId: config.appId, redirectUri: window.location.origin + window.location.pathname, apiEndpoint: config.apiEndpoint, storage: sessionStorage}) : null;
|
|
9
9
|
const root = document.querySelector<HTMLDivElement>("#app")!;
|
|
10
|
-
showVersionBadge(config.releaseVersion);
|
|
10
|
+
showVersionBadge(config.releaseVersion, config.title === "Fidj" ? config.apiEndpoint : undefined);
|
|
11
11
|
const appPath = `/me/apps/${encodeURIComponent(config.appId)}`;
|
|
12
12
|
let signedIn = false;
|
|
13
13
|
let emailVerified = false;
|
|
@@ -250,7 +250,7 @@ function render() {
|
|
|
250
250
|
async function start() {
|
|
251
251
|
try {
|
|
252
252
|
settings = await (await fetch("/api/config")).json();
|
|
253
|
-
showVersionBadge(settings.releaseVersion);
|
|
253
|
+
showVersionBadge(settings.releaseVersion, settings.title === "Fidj" ? settings.apiEndpoint : undefined);
|
|
254
254
|
await sdk.init(settings.appId, {
|
|
255
255
|
apiEndpoint: settings.apiEndpoint,
|
|
256
256
|
prod: !settings.localDemo,
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
export function showVersionBadge(version: string): void {
|
|
1
|
+
export function showVersionBadge(version: string, apiEndpoint?: string): void {
|
|
2
2
|
if (!/^\d{2}\.\d{2}\.\d{2}$/.test(version || "")) return;
|
|
3
3
|
const badge = document.createElement("div");
|
|
4
4
|
badge.className = "fidj-version";
|
|
5
5
|
badge.setAttribute("aria-label", `App version ${version}`);
|
|
6
6
|
badge.textContent = `v${version}`;
|
|
7
7
|
document.body.append(badge);
|
|
8
|
+
if (apiEndpoint) {
|
|
9
|
+
void fetch(`${apiEndpoint.replace(/\/$/, "")}/status`)
|
|
10
|
+
.then(response => response.ok ? response.json() : null)
|
|
11
|
+
.then(status => {
|
|
12
|
+
const apiVersion = status?.version || status?.built;
|
|
13
|
+
if (!apiVersion) return;
|
|
14
|
+
badge.textContent = `v${version} · API ${apiVersion}`;
|
|
15
|
+
badge.setAttribute("aria-label", `App version ${version}, API version ${apiVersion}`);
|
|
16
|
+
})
|
|
17
|
+
.catch(() => undefined);
|
|
18
|
+
}
|
|
8
19
|
}
|
package/lib/scaffold.cjs
CHANGED
|
@@ -126,7 +126,8 @@ function scaffold(destination, options) {
|
|
|
126
126
|
JSON.stringify(pkg, null, 2) + "\n",
|
|
127
127
|
);
|
|
128
128
|
fs.renameSync(path.join(dir, "gitignore"), path.join(dir, ".gitignore"));
|
|
129
|
-
const
|
|
129
|
+
const releaseVersion = new Date().toISOString().slice(2, 10).replaceAll("-", ".");
|
|
130
|
+
const settings = `FIDJ_APP_ID=${options.appId}\nFIDJ_API_ENDPOINT=${api.href.replace(/\/$/, "")}\nFIDJ_DASHBOARD_URL=https://fidj.ovh\nAPP_TITLE=${title}\nAPP_VERSION=${releaseVersion}\nPORT=8200\nHOST=127.0.0.1\nLOCAL_DEMO=false\nFIDJ_DATA_DIR=../.fidj-data/${name}\nFIDJ_PRIVACY_ADAPTER_KEY=\n`;
|
|
130
131
|
const localApi = options.local
|
|
131
132
|
? "http://localhost:3201/v3"
|
|
132
133
|
: api.href.replace(/\/$/, "");
|
|
@@ -136,7 +137,7 @@ function scaffold(destination, options) {
|
|
|
136
137
|
apiEndpoint: localApi,
|
|
137
138
|
dashboardUrl: options.local ? "http://localhost:4200" : "https://fidj.ovh",
|
|
138
139
|
title,
|
|
139
|
-
releaseVersion
|
|
140
|
+
releaseVersion,
|
|
140
141
|
localDemo: Boolean(options.local),
|
|
141
142
|
allowAnonymous: anonymous === true || anonymous === "true",
|
|
142
143
|
welcome: options.welcome || title,
|