@bardioc/create-bardioc-app 0.5.3 → 0.5.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 (66) hide show
  1. package/README.md +10 -13
  2. package/package.json +5 -5
  3. package/templates/angular/.env.example +6 -4
  4. package/templates/angular/public/runtime-env.js +1 -1
  5. package/templates/angular/scripts/dev-auth-proxy.mjs +6 -7
  6. package/templates/angular/scripts/sync-runtime-env.mjs +2 -24
  7. package/templates/angular/src/app/app.component.ts +4 -31
  8. package/templates/angular/src/app/bardioc-bridge.ts +3 -3
  9. package/templates/angular/src/index.html +2 -2
  10. package/templates/angular/src/main.ts +9 -43
  11. package/templates/angular/src/runtime-env.ts +1 -1
  12. package/templates/angular/src/styles.css +84 -80
  13. package/templates/angular/src/vite-env.d.ts +4 -6
  14. package/templates/manifest.json +2 -10
  15. package/templates/nextjs/.env.example +5 -6
  16. package/templates/nextjs/app/globals.css +31 -28
  17. package/templates/nextjs/app/page.tsx +17 -77
  18. package/templates/nextjs/global.d.ts +1 -1
  19. package/templates/nextjs/next.config.ts +27 -16
  20. package/templates/nextjs/package.json +2 -2
  21. package/templates/nextjs/tailwind.config.ts +1 -4
  22. package/templates/preact/.env.example +5 -9
  23. package/templates/preact/index.html +2 -2
  24. package/templates/preact/package.json +2 -2
  25. package/templates/preact/src/App.tsx +6 -5
  26. package/templates/preact/src/index.css +31 -28
  27. package/templates/preact/src/main.tsx +13 -29
  28. package/templates/preact/src/vite-env.d.ts +2 -4
  29. package/templates/solid/.env.example +5 -9
  30. package/templates/solid/index.html +2 -2
  31. package/templates/solid/package.json +2 -2
  32. package/templates/solid/src/App.tsx +6 -5
  33. package/templates/solid/src/bardioc-sdk.tsx +18 -18
  34. package/templates/solid/src/index.css +31 -28
  35. package/templates/solid/src/main.tsx +17 -33
  36. package/templates/solid/src/vite-env.d.ts +2 -4
  37. package/templates/svelte/.env.example +8 -4
  38. package/templates/svelte/index.html +2 -2
  39. package/templates/svelte/package.json +2 -2
  40. package/templates/svelte/src/App.svelte +1 -1
  41. package/templates/svelte/src/index.css +31 -28
  42. package/templates/svelte/src/main.ts +9 -25
  43. package/templates/svelte/src/vite-env.d.ts +2 -4
  44. package/templates/vite/.env.example +5 -10
  45. package/templates/vite/CLAUDE.md +8 -10
  46. package/templates/vite/index.html +2 -2
  47. package/templates/vite/package.json +2 -4
  48. package/templates/vite/src/App.tsx +1 -2
  49. package/templates/vite/src/auth/onboarding.tsx +5 -7
  50. package/templates/vite/src/climate/conditions-chart.tsx +6 -8
  51. package/templates/vite/src/events/live-events-view.tsx +1 -3
  52. package/templates/vite/src/i18n.tsx +7 -9
  53. package/templates/vite/src/locales/de.json +2 -3
  54. package/templates/vite/src/locales/en.json +2 -3
  55. package/templates/vite/src/main.tsx +18 -35
  56. package/templates/vite/src/shell/header.tsx +1 -2
  57. package/templates/vite/src/vite-env.d.ts +0 -2
  58. package/templates/vue/.env.example +8 -4
  59. package/templates/vue/index.html +2 -2
  60. package/templates/vue/package.json +2 -2
  61. package/templates/vue/src/App.vue +26 -10
  62. package/templates/vue/src/bardioc-sdk.ts +11 -11
  63. package/templates/vue/src/index.css +31 -28
  64. package/templates/vue/src/main.ts +8 -24
  65. package/templates/vue/src/vite-env.d.ts +2 -4
  66. package/templates/nextjs/app/proxy/route.ts +0 -85
package/README.md CHANGED
@@ -8,10 +8,10 @@ Scaffold a Vite app wired for `@bardioc/app-sdk`.
8
8
 
9
9
  ## Install
10
10
 
11
- Configure the `@bardioc` scoped registry and install the CLI globally:
11
+ Install the CLI globally from the public npm registry:
12
12
 
13
13
  ```bash
14
- npm config set @bardioc:registry http://nexus.almato.com/repository/npm-group/ --location=user && npm install -g @bardioc/create-bardioc-app
14
+ npm install -g @bardioc/create-bardioc-app
15
15
  ```
16
16
 
17
17
  If your default npm registry is not `https://registry.npmjs.org/`, set it in your user-level npm config before installing app dependencies.
@@ -28,10 +28,10 @@ npm exec --yes @bardioc/create-bardioc-app my-app -- --port 3005
28
28
  create-bardioc-app my-app --port 3005
29
29
  cd my-app
30
30
  npm install
31
- bardioc login
32
- npm run dev
33
31
  ```
34
32
 
33
+ Copy `.env.example` to `.env` and fill in `VITE_APP_NAME`, `DEV_SECRET`, and `API_BASE_URL`. Then run `npm run dev`.
34
+
35
35
  ## Generated app
36
36
 
37
37
  The generated app includes:
@@ -39,7 +39,7 @@ The generated app includes:
39
39
  - React + Vite project structure (or your chosen `--template`)
40
40
  - `@bardioc/app-sdk` dependency
41
41
  - `AppSdkProvider` wiring
42
- - optional host-backed standalone dev-session wiring via `.env`
42
+ - optional standalone dev-auth wiring via `.env` (`DEV_SECRET` proxy)
43
43
  - a compact SDK demo with notification and transport examples
44
44
  - `public/app-manifest.json`
45
45
 
@@ -64,18 +64,15 @@ Heavier, environment-specific tooling is **off by default** — pass a flag to i
64
64
  - **`--with-link`** — the **`link:source` / `unlink:source`** dev flow (`scripts/link-source.mjs` +
65
65
  `pnpm-workspace.yaml` + `.npmrc`) for developing against an in-tree `@bardioc/*` source checkout.
66
66
 
67
- ## Standalone dev session
67
+ ## Standalone dev auth
68
68
 
69
- Generated apps can opt into the same host-backed standalone dev-session flow used by the SDK examples.
69
+ Generated apps can run standalone with the `DEV_SECRET` dev-auth proxy.
70
70
 
71
71
  1. Copy `.env.example` to `.env`
72
- 2. Fill in `VITE_APP_NAME`, `VITE_APP_ID`, and `DEV_AUTH_HOST_URL`
73
- 3. Run `bardioc login` once for that host
74
- 4. Set `VITE_ENABLE_DEV_AUTH=true`
75
-
76
- Important: standalone login will not start unless `VITE_ENABLE_DEV_AUTH=true` is present in `.env`. Running `npm run dev` with only `VITE_APP_NAME` and `VITE_APP_ID` is not enough.
72
+ 2. Fill in `VITE_APP_NAME`, `DEV_SECRET`, and `API_BASE_URL`
73
+ 3. Run `npm run dev`
77
74
 
78
- When enabled, running `npm run dev` outside the host iframe will use your stored CLI login to mint a fresh host dev session before the dev server starts, then route SDK transport calls through the local proxy into the host transport. `DEV_SESSION_KEY` no longer needs to be copied manually. If a request needs a specific scope, pass `scopeId` on that request.
75
+ When running outside the host iframe, the Vite plugin proxies `/rest/*` to `API_BASE_URL` with the `X-Dev-Secret` header and `installDevBridge()` handles SDK messages.
79
76
 
80
77
  For public testing, run `npm run dev:live` and use the emitted tunnel URL as the app's live URL in the host App Store configuration.
81
78
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bardioc/create-bardioc-app",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "Scaffold a Bardioc app with framework templates (vite, react, vue, angular, svelte, solid, preact, nextjs)",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -30,10 +30,10 @@
30
30
  "react"
31
31
  ],
32
32
  "devDependencies": {
33
- "@vitest/coverage-v8": "4.1.5",
34
- "@types/node": "^25.6.0",
35
- "typescript": "^6.0.3",
36
- "vitest": "4.1.5"
33
+ "@vitest/coverage-v8": "^4.1.8",
34
+ "@types/node": "^25.9.1",
35
+ "typescript": "6.0.3",
36
+ "vitest": "^4.1.8"
37
37
  },
38
38
  "scripts": {
39
39
  "check-types": "tsc --noEmit",
@@ -1,5 +1,7 @@
1
1
  VITE_APP_NAME={{APP_NAME}}
2
- VITE_APP_ID=your-app-client-id-here
3
- VITE_ENABLE_DEV_AUTH=false
4
- DEV_AUTH_HOST_URL=
5
- DEV_SESSION_KEY=
2
+
3
+ # Dev auth proxy secret for local standalone development.
4
+ DEV_SECRET=
5
+
6
+ # Base URL of the Bardioc API the dev auth proxy should forward to.
7
+ API_BASE_URL=
@@ -1 +1 @@
1
- window.__BARDIOC_RUNTIME_ENV__ = {};
1
+ window.__BARDIOC_RUNTIME_ENV__ = {};
@@ -12,15 +12,14 @@ const appPort = readAppPort();
12
12
  const proxyPort = appPort + 100;
13
13
  const env = loadEnv(projectRoot);
14
14
 
15
- if (!env.VITE_APP_ID || !env.DEV_AUTH_HOST_URL || !env.DEV_SESSION_KEY) {
16
- process.stderr.write('[bardioc-dev-auth-proxy] missing env, proxy disabled\n');
15
+ if (!env.DEV_SECRET || !env.API_BASE_URL) {
16
+ process.stderr.write('[bardioc-dev-auth-proxy] missing DEV_SECRET or API_BASE_URL, proxy disabled\n');
17
17
  await new Promise(() => {});
18
18
  }
19
19
 
20
20
  const handler = createDevAuthProxyHandler({
21
- appId: env.VITE_APP_ID,
22
- hostUrl: env.DEV_AUTH_HOST_URL,
23
- devSessionKey: env.DEV_SESSION_KEY,
21
+ apiBaseUrl: env.API_BASE_URL,
22
+ devSecret: env.DEV_SECRET,
24
23
  allowOrigin: '*',
25
24
  });
26
25
 
@@ -29,7 +28,7 @@ const server = createServer((req, res) => {
29
28
  });
30
29
 
31
30
  server.listen(proxyPort, '127.0.0.1', () => {
32
- process.stdout.write(`[bardioc-dev-auth-proxy] listening on http://127.0.0.1:${proxyPort}/proxy\n`);
31
+ process.stdout.write(`[bardioc-dev-auth-proxy] listening on http://127.0.0.1:${proxyPort}/rest\n`);
33
32
  });
34
33
 
35
34
  for (const signal of ['SIGINT', 'SIGTERM']) {
@@ -89,4 +88,4 @@ function parseEnv(source) {
89
88
  }
90
89
 
91
90
  return result;
92
- }
91
+ }
@@ -7,41 +7,19 @@ import { fileURLToPath } from 'node:url';
7
7
  const __dirname = dirname(fileURLToPath(import.meta.url));
8
8
  const projectRoot = resolve(__dirname, '..');
9
9
  const env = loadEnv(projectRoot);
10
- const appPort = readAppPort();
11
- const proxyPort = appPort + 100;
12
10
 
13
11
  const runtimeEnv = {
14
12
  VITE_APP_NAME: env.VITE_APP_NAME,
15
- VITE_APP_ID: env.VITE_APP_ID,
16
- VITE_ENABLE_DEV_AUTH: env.VITE_ENABLE_DEV_AUTH,
17
- DEV_AUTH_HOST_URL: env.DEV_AUTH_HOST_URL,
18
- DEV_SESSION_KEY: env.DEV_SESSION_KEY,
19
13
  };
20
14
 
21
- const injectedDevAuth =
22
- env.DEV_AUTH_HOST_URL && env.DEV_SESSION_KEY
23
- ? {
24
- hostUrl: env.DEV_AUTH_HOST_URL,
25
- sessionKey: env.DEV_SESSION_KEY,
26
- proxyUrl: `http://127.0.0.1:${proxyPort}/proxy`,
27
- }
28
- : null;
29
-
30
15
  const outputPath = join(projectRoot, 'public', 'runtime-env.js');
31
16
  mkdirSync(dirname(outputPath), { recursive: true });
32
17
  writeFileSync(
33
18
  outputPath,
34
- `window.__BARDIOC_RUNTIME_ENV__ = ${JSON.stringify(runtimeEnv, null, 2)};\nwindow.__BARDIOC_DEV_AUTH__ = ${JSON.stringify(injectedDevAuth, null, 2)};\n`,
19
+ `window.__BARDIOC_RUNTIME_ENV__ = ${JSON.stringify(runtimeEnv, null, 2)};\n`,
35
20
  'utf8'
36
21
  );
37
22
 
38
- function readAppPort() {
39
- const flagIndex = process.argv.indexOf('--app-port');
40
- const raw = flagIndex >= 0 ? process.argv[flagIndex + 1] : undefined;
41
- const parsed = Number.parseInt(raw ?? '{{PORT}}', 10);
42
- return Number.isFinite(parsed) ? parsed : {{PORT}};
43
- }
44
-
45
23
  function loadEnv(projectDir) {
46
24
  const result = {};
47
25
 
@@ -86,4 +64,4 @@ function parseEnv(source) {
86
64
  }
87
65
 
88
66
  return result;
89
- }
67
+ }
@@ -3,27 +3,6 @@ import { JsonPipe } from '@angular/common';
3
3
  import { Component, inject, signal } from '@angular/core';
4
4
  import { BARDIOC_BRIDGE } from './bardioc.token';
5
5
  import type { HostBridge } from '@bardioc/app-sdk';
6
- import { readRuntimeEnv } from '../runtime-env';
7
-
8
- type InjectedDevAuthConfig = {
9
- hostUrl?: string;
10
- sessionKey?: string;
11
- };
12
-
13
- function readInjectedDevAuthConfig(): InjectedDevAuthConfig | null {
14
- const config = (globalThis as typeof globalThis & {
15
- __BARDIOC_DEV_AUTH__?: InjectedDevAuthConfig;
16
- }).__BARDIOC_DEV_AUTH__;
17
-
18
- if (!config?.hostUrl || !config?.sessionKey) {
19
- return null;
20
- }
21
-
22
- return {
23
- hostUrl: config.hostUrl,
24
- sessionKey: config.sessionKey,
25
- };
26
- }
27
6
 
28
7
  type ResultState =
29
8
  | { status: 'idle' }
@@ -115,14 +94,8 @@ type ResultState =
115
94
  })
116
95
  export class AppComponent {
117
96
  private bridge = inject(BARDIOC_BRIDGE, { optional: true }) as HostBridge | null;
118
- private injectedDevAuth = readInjectedDevAuthConfig();
119
-
120
- showSdkDemo =
121
- isInsideIframe() ||
122
- (readRuntimeEnv('VITE_ENABLE_DEV_AUTH') === 'true' &&
123
- !!this.injectedDevAuth?.hostUrl &&
124
- !!this.injectedDevAuth?.sessionKey &&
125
- isDevStandalone());
97
+
98
+ showSdkDemo = isInsideIframe() || isDevStandalone();
126
99
  result = signal<ResultState>({ status: 'idle' });
127
100
  running = signal(false);
128
101
 
@@ -135,11 +108,11 @@ export class AppComponent {
135
108
 
136
109
  const startTime = Date.now();
137
110
  this.bridge.notify('Getting user profile', 'info');
138
-
111
+
139
112
  try {
140
113
  const data = await this.bridge.transport.os.profile.get();
141
114
  const duration = Date.now() - startTime;
142
- this.bridge.notify(`Profile loaded (${duration}ms)`, 'success');
115
+ this.bridge.notify(`Profile loaded (${duration}ms)`, 'success`);
143
116
  this.result.set({ status: 'success', request, data });
144
117
  } catch (err) {
145
118
  const message = err instanceof Error ? err.message : String(err);
@@ -1,5 +1,5 @@
1
1
  import { createHostBridge, type HostBridge } from '@bardioc/app-sdk';
2
2
 
3
- export function createBardiocBridge(appId: string): HostBridge {
4
- return createHostBridge({ appId });
5
- }
3
+ export function createBardiocBridge(): HostBridge {
4
+ return createHostBridge({});
5
+ }
@@ -1,5 +1,5 @@
1
- <!DOCTYPE html>
2
- <html lang="en" class="dark" style="height: 100%; margin: 0">
1
+ <!doctype html>
2
+ <html lang="en" class="dark" style="height: 100%; margin: 0; color-scheme: dark">
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <title>{{DISPLAY_NAME}}</title>
@@ -1,65 +1,31 @@
1
1
  import {
2
- ensureDevAuthSession,
3
2
  installDevBridge,
4
3
  isDevStandalone,
5
4
  isInsideIframe,
6
5
  } from '@bardioc/app-sdk/dev';
7
6
  import { bootstrapApplication } from '@angular/platform-browser';
8
7
  import { provideHttpClient } from '@angular/common/http';
9
- import { isDevMode, type EnvironmentProviders, type Provider } from '@angular/core';
8
+ import { type EnvironmentProviders, type Provider } from '@angular/core';
10
9
  import { AppComponent } from './app/app.component';
11
10
  import { createBardiocBridge } from './app/bardioc-bridge';
12
11
  import { BARDIOC_BRIDGE } from './app/bardioc.token';
13
- import { readRuntimeEnv } from './runtime-env';
14
12
  import './styles.css';
15
13
 
16
- type InjectedDevAuthConfig = {
17
- hostUrl?: string;
18
- sessionKey?: string;
19
- proxyUrl?: string;
20
- };
21
-
22
- function readInjectedDevAuthConfig(): InjectedDevAuthConfig | null {
23
- const config = (globalThis as typeof globalThis & {
24
- __BARDIOC_DEV_AUTH__?: InjectedDevAuthConfig;
25
- }).__BARDIOC_DEV_AUTH__;
26
-
27
- if (!config?.hostUrl || !config?.sessionKey) {
28
- return null;
29
- }
30
-
31
- return {
32
- hostUrl: config.hostUrl,
33
- sessionKey: config.sessionKey,
34
- proxyUrl: typeof config.proxyUrl === 'string' ? config.proxyUrl : undefined,
35
- };
14
+ function readAppPort(): number {
15
+ const parsed = Number.parseInt(window.location.port, 10);
16
+ return Number.isFinite(parsed) ? parsed : {{PORT}};
36
17
  }
37
18
 
38
- const APP_NAME = (readRuntimeEnv('VITE_APP_NAME') ?? document.title.trim()) || 'Bardioc App';
39
- const APP_ID = readRuntimeEnv('VITE_APP_ID');
40
- const injectedDevAuth = readInjectedDevAuthConfig();
41
- const standaloneDevAuthEnabled =
42
- isDevMode() &&
43
- readRuntimeEnv('VITE_ENABLE_DEV_AUTH') === 'true' &&
44
- !!injectedDevAuth?.hostUrl &&
45
- !!injectedDevAuth?.sessionKey;
46
-
19
+ const appPort = readAppPort();
20
+ const proxyPort = appPort + 100;
47
21
  const insideIframe = isInsideIframe();
48
- const devStandalone = standaloneDevAuthEnabled && isDevStandalone();
22
+ const devStandalone = isDevStandalone();
49
23
  const useSdkProvider = insideIframe || devStandalone;
50
24
 
51
- if (useSdkProvider && !APP_ID) {
52
- throw new Error('Missing VITE_APP_ID for SDK runtime');
53
- }
54
-
55
25
  async function bootstrap() {
56
26
  if (devStandalone) {
57
- await ensureDevAuthSession({ appId: APP_ID!, appName: APP_NAME });
58
27
  installDevBridge({
59
- appId: APP_ID!,
60
- appName: APP_NAME,
61
- debug: false,
62
- proxyPath: injectedDevAuth?.proxyUrl,
28
+ apiBaseUrl: `http://127.0.0.1:${proxyPort}/rest`,
63
29
  });
64
30
  }
65
31
 
@@ -70,7 +36,7 @@ async function bootstrap() {
70
36
  if (useSdkProvider) {
71
37
  providers.push({
72
38
  provide: BARDIOC_BRIDGE,
73
- useValue: createBardiocBridge(APP_ID!),
39
+ useValue: createBardiocBridge(),
74
40
  });
75
41
  }
76
42
 
@@ -14,4 +14,4 @@ export function readRuntimeEnv(name: string): string | undefined {
14
14
 
15
15
  const trimmed = value.trim();
16
16
  return trimmed.length > 0 ? trimmed : undefined;
17
- }
17
+ }