create-ilorb 0.2.0 → 0.3.1
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/README.md +93 -74
- package/assets/dev-local.mjs +2 -2
- package/dist/args.js +1 -1
- package/dist/generate.js +6 -4
- package/dist/i18n/en.js +77 -31
- package/dist/i18n/es.js +77 -31
- package/dist/i18n/pt.js +77 -31
- package/dist/main.js +79 -14
- package/dist/products.js +79 -41
- package/dist/readme.js +43 -43
- package/dist/steps.js +13 -6
- package/dist/theme/preview.js +28 -0
- package/dist/theme/vendor/color.js +1 -1
- package/dist/theme/vendor/tokens.js +1 -1
- package/dist/theme/vendor/validate.js +219 -0
- package/dist/update.js +349 -0
- package/package.json +1 -2
- package/LICENSE-API.md +0 -108
package/dist/readme.js
CHANGED
|
@@ -3,91 +3,91 @@ import { getLang } from "./i18n/index.js";
|
|
|
3
3
|
const TXT = {
|
|
4
4
|
pt: {
|
|
5
5
|
oauthNote: 'Login com GitHub, Discord ou LinkedIn (painel → Formas de entrar): o app usa o login por redirecionamento com PKCE e precisa do `expo-crypto` (`npx expo install expo-crypto` na pasta do app, e um build novo). A volta para o app (`{scheme}://auth`) já está em `settings.oauthRedirects` do Core.',
|
|
6
|
-
intro: 'Gerado pelo `create-
|
|
6
|
+
intro: 'Gerado pelo `create-ilorb` (Ilorb Code). As escolhas estão em `overture.json` e o tema em `overture.theme.json`.',
|
|
7
7
|
layout: 'Pastas',
|
|
8
8
|
run: 'Rodar neste computador',
|
|
9
|
-
runBody: '`pnpm dev` sobe o login (Core Auth), a API, o painel e o app web. O chat é o do
|
|
10
|
-
runBodyWidgets: '`pnpm dev` sobe o login (Core Auth), a API dos Widgets, o painel e uma página de teste com o snippet. Crie o widget no painel (Widgets do site → Widgets) com o domínio da página de teste (`localhost:<porta>`) e abra `http://localhost:<porta>/?w=<id do widget>`. O chat é o do
|
|
9
|
+
runBody: '`pnpm dev` sobe o login (Core Auth), a API, o painel e o app web. O chat é o do Ilorb Signal na NUVEM, com o seu app de TESTE do Ilorb Signal (chaves no `.dev.vars` da API). Os callbacks do Ilorb Signal (push, denúncias) não chegam ao localhost: para testá-los, `cloudflared tunnel --url http://localhost:<porta da api>` e ponha `<URL do túnel>/v1/opera/callback` no app de TESTE no console do Ilorb Signal — ou faça o deploy na nuvem. Só funciona numa instalação feita com `--target local`.',
|
|
10
|
+
runBodyWidgets: '`pnpm dev` sobe o login (Core Auth), a API dos Widgets, o painel e uma página de teste com o snippet. Crie o widget no painel (Widgets do site → Widgets) com o domínio da página de teste (`localhost:<porta>`) e abra `http://localhost:<porta>/?w=<id do widget>`. O chat é o do Ilorb Signal na NUVEM, com o seu app de TESTE do Ilorb Signal (chaves no `.dev.vars` da API). Só funciona numa instalação feita com `--target local`.',
|
|
11
11
|
runExtraConsultas: 'Consultas: o pagamento local é SIMULADO pelo Core (Pix/cartão de mentira, sem chave) e o `pnpm dev` chama o cron (lembretes de 24 h e 15 min, travas vencidas) a cada minuto. Na nuvem, o cron do Worker roda sozinho e o Core recebe `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET` (o mesmo valor do Worker das Consultas).',
|
|
12
12
|
snippet: 'No seu site',
|
|
13
13
|
snippetBody: 'No painel → Widgets do site → Widgets: crie o widget, ponha o domínio do seu site em "Domínios" e cole o snippet antes do `</body>`. O `w.js` sai do Worker dos Widgets (o widget compilado vai DENTRO dele: `overture-widgets/web/js` → `pnpm build`, depois `wrangler deploy`).',
|
|
14
|
-
runBodyStatus: '`pnpm dev` sobe o login (Core Auth), o Worker do Status (a página pública em `http://localhost:<porta da api>/` e o cron das checagens, chamado a cada minuto em `/__scheduled`) e o painel com as páginas do Status. Alertas e avisos ficam só na fila (`NOTIFY_MODE=log`). Sem
|
|
14
|
+
runBodyStatus: '`pnpm dev` sobe o login (Core Auth), o Worker do Status (a página pública em `http://localhost:<porta da api>/` e o cron das checagens, chamado a cada minuto em `/__scheduled`) e o painel com as páginas do Status. Alertas e avisos ficam só na fila (`NOTIFY_MODE=log`). Sem Ilorb Signal. Só funciona numa instalação feita com `--target local`.',
|
|
15
15
|
statusCloud: 'Na nuvem',
|
|
16
16
|
statusCloudBody: 'O cron `* * * * *` do Worker `{worker}` faz as checagens, a fila de alertas/avisos e a limpeza; `NOTIFY_MODE=live` (alertas por webhook e Telegram pelo painel; e-mail com a mesma chave do Resend do login). O `SECRETS_KEY` do Worker vem do `STATUS_SECRETS_KEY` em `.overture/secrets.env` (cifra o token do Telegram e os segredos de webhook): trocar = refazer esses canais. A página usa a aparência do Core e as fontes OFL do próprio Core (`<CORE_URL>/v1/fonts/fonts.css`). Checar de várias regiões: `REGIONS` no `wrangler.jsonc` (ver `overture-status/README.md`).',
|
|
17
17
|
domain: 'Domínio próprio da página',
|
|
18
18
|
domainBody: '`npx create-ilorb --resume . --status-domain status.suaempresa.com` liga o domínio no Worker (Custom Domain; a zona tem de estar na mesma conta Cloudflare e o token precisa de Zone · Workers Routes · Edit) e põe `PUBLIC_URL` nele (links dos e-mails e do feed). Depois, painel → Status → Página pública → Domínio.',
|
|
19
|
-
runBodyAgenda: '`pnpm dev` sobe o login (Core Auth, com PAGAMENTOS simulados), o Worker da Agenda (o cron dos lembretes e das travas é chamado a cada minuto em `/__scheduled`), o painel com as páginas da Agenda, o app web e a página pública de reservas (`overture-agenda/web/embed`, porta própria). Sem
|
|
20
|
-
runBodySites: '`pnpm dev` sobe o login (Core Auth), o Worker do Sites (o site publicado em `http://localhost:<porta da api>/`, a API do painel e os arquivos fixos em `/_a/*`) e o painel com as páginas do Site. Publicar grava no R2 local (`.overture/local`). Sem
|
|
21
|
-
runBodyStarter: '`pnpm dev` sobe o login (Core Auth, com PAGAMENTOS simulados), o Worker do Starter (o cron de hora em hora é chamado em `/__scheduled`), o painel com as páginas do Starter e o app web dos clientes. Sem
|
|
22
|
-
runBodyLink: '`pnpm dev` sobe o login (Core Auth, com PAGAMENTOS simulados), o Worker do Link (links curtos e páginas de bio em `http://localhost:<porta da api>/`; o cron de hora em hora é chamado em `/__scheduled`), o painel com as páginas do Link e o app web. Sem
|
|
23
|
-
runBodyImoveis: '`pnpm dev` sobe o login (Core Auth, com PAGAMENTOS simulados), o Worker do Imóveis (o site do portal em `http://localhost:<porta da api>/`, as fotos no R2 local, o cron de hora em hora em `/__scheduled`), o painel com as páginas do Imóveis e o app web do anunciante. Sem
|
|
24
|
-
runBodyQuiz: '`pnpm dev` sobe o login (Core Auth, com PAGAMENTOS simulados), o Worker do Quiz (imagens no R2 local, o cron de hora em hora em `/__scheduled`), o painel com as páginas do Quiz e o jogo na web. Sem
|
|
25
|
-
runBodyHelpcenter: '`pnpm dev` sobe o login (Core Auth), o Worker do Help Center (a central em `http://localhost:<porta da api>/help`, o widget em `/widget.js`, anexos no R2 local, o cron a cada minuto em `/__scheduled`) e o painel com as páginas da Central de ajuda. Sem
|
|
19
|
+
runBodyAgenda: '`pnpm dev` sobe o login (Core Auth, com PAGAMENTOS simulados), o Worker da Agenda (o cron dos lembretes e das travas é chamado a cada minuto em `/__scheduled`), o painel com as páginas da Agenda, o app web e a página pública de reservas (`overture-agenda/web/embed`, porta própria). Sem Ilorb Signal. Na nuvem a página de reservas vai para o Pages `{site}` (`pnpm run build` com `VITE_AGENDA_API_URL` e o `<meta name="agenda-api">` do index.html) e o widget é o `embed.js` dela; o Core recebe `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET` (o mesmo valor do Worker da Agenda). Só funciona numa instalação feita com `--target local`.',
|
|
20
|
+
runBodySites: '`pnpm dev` sobe o login (Core Auth), o Worker do Sites (o site publicado em `http://localhost:<porta da api>/`, a API do painel e os arquivos fixos em `/_a/*`) e o painel com as páginas do Site. Publicar grava no R2 local (`.overture/local`). Sem Ilorb Signal. Na nuvem: o bucket R2 `{bucket}` guarda as versões e a mídia; o contato manda e-mail com a chave do Resend do login e o captcha usa `TURNSTILE_SECRET` (opcional, pelo ambiente). Domínio próprio: Custom Domain do Worker na Cloudflare + o mesmo endereço em `PUBLIC_URL`. Só funciona numa instalação feita com `--target local`.',
|
|
21
|
+
runBodyStarter: '`pnpm dev` sobe o login (Core Auth, com PAGAMENTOS simulados), o Worker do Starter (o cron de hora em hora é chamado em `/__scheduled`), o painel com as páginas do Starter e o app web dos clientes. Sem Ilorb Signal. Na nuvem, o app web vai para o Pages `{app}` (export do Expo; a URL vira `APP_URL` e `EXPO_PUBLIC_WEB_URL`) e o Core recebe `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET` (o mesmo valor do Worker do Starter). Para estender: `overture-starter/ESTENDER.md`. Só funciona numa instalação feita com `--target local`.',
|
|
22
|
+
runBodyLink: '`pnpm dev` sobe o login (Core Auth, com PAGAMENTOS simulados), o Worker do Link (links curtos e páginas de bio em `http://localhost:<porta da api>/`; o cron de hora em hora é chamado em `/__scheduled`), o painel com as páginas do Link e o app web. Sem Ilorb Signal. No local, os cliques vão direto ao D1 (sem fila). Na nuvem: R2 `{media}` (fotos da bio), fila de cliques só com o plano pago de Workers (`--workers-paid`), domínio curto próprio com `--short-domain`, e o Core recebe `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET` (o mesmo valor do Worker do Link). Opcionais pelo ambiente: `CF_API_TOKEN` + `CF_ZONE_ID` (domínios dos clientes) e `SAFE_BROWSING_KEY`. Só funciona numa instalação feita com `--target local`.',
|
|
23
|
+
runBodyImoveis: '`pnpm dev` sobe o login (Core Auth, com PAGAMENTOS simulados), o Worker do Imóveis (o site do portal em `http://localhost:<porta da api>/`, as fotos no R2 local, o cron de hora em hora em `/__scheduled`), o painel com as páginas do Imóveis e o app web do anunciante. Sem Ilorb Signal. Na nuvem: R2 `{media}` (fotos), as fontes OFL servidas pelo próprio Core (`/v1/fonts/`), e o Core recebe `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET` (o mesmo valor do Worker do Imóveis). Só funciona numa instalação feita com `--target local`.',
|
|
24
|
+
runBodyQuiz: '`pnpm dev` sobe o login (Core Auth, com PAGAMENTOS simulados), o Worker do Quiz (imagens no R2 local, o cron de hora em hora em `/__scheduled`), o painel com as páginas do Quiz e o jogo na web. Sem Ilorb Signal. Na nuvem o jogo web vai para o Pages `{app}`, R2 `{media}` (imagens das perguntas) e o Core recebe `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET`. Perguntas de exemplo: `overture-quiz/exemplos/perguntas-exemplo.csv` (painel → Quiz → Importar, ou `--sample-data`). Para estender: `overture-quiz/ESTENDER.md`. Só funciona numa instalação feita com `--target local`.',
|
|
25
|
+
runBodyHelpcenter: '`pnpm dev` sobe o login (Core Auth), o Worker do Help Center (a central em `http://localhost:<porta da api>/help`, o widget em `/widget.js`, anexos no R2 local, o cron a cada minuto em `/__scheduled`) e o painel com as páginas da Central de ajuda. Sem Ilorb Signal. O widget é compilado para dentro do Worker (`overture-helpcenter/web/js` → `node build.mjs` → `api/workers/src/generated/widget.ts`): mudou o widget → build + deploy do Worker. Só funciona numa instalação feita com `--target local`.',
|
|
26
26
|
helpEmail: 'E-mail de suporte (passo manual)',
|
|
27
27
|
helpEmailBody: '1. Cloudflare → seu domínio → Email → **Email Routing**: ative.\n2. Regra do endereço de suporte com a ação **Send to a Worker** → `{worker}` (uma regra igual para cada fila com e-mail próprio).\n3. Ligue o **Subaddressing** — sem ele a resposta do cliente para `ajuda+t-<chave>@…` não chega.\n4. **Resend**: domínio verificado e `EMAIL_FROM` no domínio do endereço de suporte (senão os e-mails caem no spam).\n\nO painel (Central de ajuda → Ajustes) mostra os mesmos passos com o endereço digitado.',
|
|
28
|
-
runBodyClassificados: '`pnpm dev` sobe o login (Core Auth, com PAGAMENTOS simulados), o Worker dos Classificados (o site com SEO em `http://localhost:<porta da api>/`, fotos no R2 local, o cron a cada 5 min em `/__scheduled`), o painel com as páginas dos Classificados e o app web. Sem
|
|
28
|
+
runBodyClassificados: '`pnpm dev` sobe o login (Core Auth, com PAGAMENTOS simulados), o Worker dos Classificados (o site com SEO em `http://localhost:<porta da api>/`, fotos no R2 local, o cron a cada 5 min em `/__scheduled`), o painel com as páginas dos Classificados e o app web. Sem Ilorb Signal. Na nuvem: o app web vai para o Pages `{app}`, R2 `{media}` (fotos), `--site-domain` liga o domínio do site (o SEO vive dele) e o Core recebe `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET`. Depois de instalar: cidades e bairros, configurações do site, planos de destaque (vêm em BRL) e o sitemap no Google Search Console. Só funciona numa instalação feita com `--target local`.',
|
|
29
29
|
again: 'Rodar o instalador de novo',
|
|
30
|
-
againBody: '`npx create-ilorb --resume .` — continua de onde parou e não duplica nada. Mudou uma escolha (ex.: `--
|
|
30
|
+
againBody: '`npx create-ilorb --resume .` — continua de onde parou e não duplica nada. Mudou uma escolha (ex.: `--ilorb-app-id`)? Ele refaz só os passos afetados.',
|
|
31
31
|
secrets: 'Segredos',
|
|
32
32
|
secretsBody: 'Ficam em `.overture/secrets.env` (fora do git, 0600) e nos `.dev.vars` dos Workers (local). Guarde uma cópia da `MASTER_KEY`: sem ela o Core perde as chaves dos provedores.',
|
|
33
33
|
},
|
|
34
34
|
es: {
|
|
35
35
|
oauthNote: 'Acceso con GitHub, Discord o LinkedIn (panel → Formas de entrar): la app usa el acceso por redirección con PKCE y necesita `expo-crypto` (`npx expo install expo-crypto` en la carpeta de la app, y un build nuevo). La vuelta a la app (`{scheme}://auth`) ya está en `settings.oauthRedirects` del Core.',
|
|
36
|
-
intro: 'Generado por `create-
|
|
36
|
+
intro: 'Generado por `create-ilorb` (Ilorb Code). Las opciones están en `overture.json` y el tema en `overture.theme.json`.',
|
|
37
37
|
layout: 'Carpetas',
|
|
38
38
|
run: 'Correr en esta computadora',
|
|
39
|
-
runBody: '`pnpm dev` levanta el acceso (Core Auth), la API, el panel y la app web. El chat es el de
|
|
40
|
-
runBodyWidgets: '`pnpm dev` levanta el acceso (Core Auth), la API de los Widgets, el panel y una página de prueba con el snippet. Crea el widget en el panel (Widgets del sitio → Widgets) con el dominio de la página de prueba (`localhost:<puerto>`) y abre `http://localhost:<puerto>/?w=<id del widget>`. El chat es el de
|
|
39
|
+
runBody: '`pnpm dev` levanta el acceso (Core Auth), la API, el panel y la app web. El chat es el de Ilorb Signal en la NUBE, con tu app de PRUEBA de Ilorb Signal (claves en el `.dev.vars` de la API). Los callbacks de Ilorb Signal (push, denuncias) no llegan a localhost: para probarlos, `cloudflared tunnel --url http://localhost:<puerto de la api>` y pon `<URL del túnel>/v1/opera/callback` en la app de PRUEBA en la consola de Ilorb Signal — o haz el deploy en la nube. Solo funciona en una instalación hecha con `--target local`.',
|
|
40
|
+
runBodyWidgets: '`pnpm dev` levanta el acceso (Core Auth), la API de los Widgets, el panel y una página de prueba con el snippet. Crea el widget en el panel (Widgets del sitio → Widgets) con el dominio de la página de prueba (`localhost:<puerto>`) y abre `http://localhost:<puerto>/?w=<id del widget>`. El chat es el de Ilorb Signal en la NUBE, con tu app de PRUEBA de Ilorb Signal (claves en el `.dev.vars` de la API). Solo funciona en una instalación hecha con `--target local`.',
|
|
41
41
|
runExtraConsultas: 'Consultas: el pago local es SIMULADO por el Core (Pix/tarjeta de mentira, sin clave) y `pnpm dev` llama al cron (recordatorios de 24 h y 15 min, reservas vencidas) cada minuto. En la nube, el cron del Worker corre solo y el Core recibe `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET` (el mismo valor del Worker de Consultas).',
|
|
42
42
|
snippet: 'En tu sitio',
|
|
43
43
|
snippetBody: 'En el panel → Widgets del sitio → Widgets: crea el widget, pon el dominio de tu sitio en "Dominios" y pega el snippet antes de `</body>`. El `w.js` sale del Worker de los Widgets (el widget compilado va DENTRO de él: `overture-widgets/web/js` → `pnpm build`, luego `wrangler deploy`).',
|
|
44
|
-
runBodyStatus: '`pnpm dev` levanta el acceso (Core Auth), el Worker de Status (la página pública en `http://localhost:<puerto de la api>/` y el cron de los chequeos, llamado cada minuto en `/__scheduled`) y el panel con las páginas de Status. Alertas y avisos solo quedan en la cola (`NOTIFY_MODE=log`). Sin
|
|
44
|
+
runBodyStatus: '`pnpm dev` levanta el acceso (Core Auth), el Worker de Status (la página pública en `http://localhost:<puerto de la api>/` y el cron de los chequeos, llamado cada minuto en `/__scheduled`) y el panel con las páginas de Status. Alertas y avisos solo quedan en la cola (`NOTIFY_MODE=log`). Sin Ilorb Signal. Solo funciona en una instalación hecha con `--target local`.',
|
|
45
45
|
statusCloud: 'En la nube',
|
|
46
46
|
statusCloudBody: 'El cron `* * * * *` del Worker `{worker}` hace los chequeos, la cola de alertas/avisos y la limpieza; `NOTIFY_MODE=live` (alertas por webhook y Telegram desde el panel; correo con la misma clave de Resend del acceso). El `SECRETS_KEY` del Worker viene de `STATUS_SECRETS_KEY` en `.overture/secrets.env` (cifra el token de Telegram y los secretos de webhook): cambiarlo = rehacer esos canales. La página usa la apariencia del Core y las fuentes OFL del propio Core (`<CORE_URL>/v1/fonts/fonts.css`). Chequear desde varias regiones: `REGIONS` en el `wrangler.jsonc` (ver `overture-status/README.md`).',
|
|
47
47
|
domain: 'Dominio propio de la página',
|
|
48
48
|
domainBody: '`npx create-ilorb --resume . --status-domain status.tuempresa.com` conecta el dominio al Worker (Custom Domain; la zona debe estar en la misma cuenta de Cloudflare y el token necesita Zone · Workers Routes · Edit) y pone `PUBLIC_URL` en él (enlaces de correos y del feed). Después, panel → Status → Página pública → Dominio.',
|
|
49
|
-
runBodyAgenda: '`pnpm dev` levanta el acceso (Core Auth, con PAGOS simulados), el Worker de la Agenda (el cron de recordatorios y reservas se llama cada minuto en `/__scheduled`), el panel con las páginas de la Agenda, la app web y la página pública de reservas (`overture-agenda/web/embed`, puerto propio). Sin
|
|
50
|
-
runBodySites: '`pnpm dev` levanta el acceso (Core Auth), el Worker de Sites (el sitio publicado en `http://localhost:<puerto de la api>/`, la API del panel y los archivos fijos en `/_a/*`) y el panel con las páginas del Sitio. Publicar graba en el R2 local (`.overture/local`). Sin
|
|
51
|
-
runBodyStarter: '`pnpm dev` levanta el acceso (Core Auth, con PAGOS simulados), el Worker de Starter (el cron de cada hora se llama en `/__scheduled`), el panel con las páginas de Starter y la app web de los clientes. Sin
|
|
52
|
-
runBodyLink: '`pnpm dev` levanta el acceso (Core Auth, con PAGOS simulados), el Worker de Link (enlaces cortos y páginas de bio en `http://localhost:<puerto de la api>/`; el cron de cada hora se llama en `/__scheduled`), el panel con las páginas de Link y la app web. Sin
|
|
53
|
-
runBodyImoveis: '`pnpm dev` levanta el acceso (Core Auth, con PAGOS simulados), el Worker de Inmuebles (el sitio del portal en `http://localhost:<puerto de la api>/`, las fotos en el R2 local, el cron de cada hora en `/__scheduled`), el panel con las páginas de Inmuebles y la app web del anunciante. Sin
|
|
54
|
-
runBodyQuiz: '`pnpm dev` levanta el acceso (Core Auth, con PAGOS simulados), el Worker del Quiz (imágenes en el R2 local, el cron de cada hora en `/__scheduled`), el panel con las páginas del Quiz y el juego web. Sin
|
|
55
|
-
runBodyHelpcenter: '`pnpm dev` levanta el acceso (Core Auth), el Worker del Help Center (el centro en `http://localhost:<puerto de la api>/help`, el widget en `/widget.js`, adjuntos en el R2 local, el cron cada minuto en `/__scheduled`) y el panel con las páginas del Centro de ayuda. Sin
|
|
49
|
+
runBodyAgenda: '`pnpm dev` levanta el acceso (Core Auth, con PAGOS simulados), el Worker de la Agenda (el cron de recordatorios y reservas se llama cada minuto en `/__scheduled`), el panel con las páginas de la Agenda, la app web y la página pública de reservas (`overture-agenda/web/embed`, puerto propio). Sin Ilorb Signal. En la nube la página de reservas va al Pages `{site}` (`pnpm run build` con `VITE_AGENDA_API_URL` y el `<meta name="agenda-api">` del index.html) y el widget es su `embed.js`; el Core recibe `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET` (el mismo valor del Worker de la Agenda). Solo funciona en una instalación hecha con `--target local`.',
|
|
50
|
+
runBodySites: '`pnpm dev` levanta el acceso (Core Auth), el Worker de Sites (el sitio publicado en `http://localhost:<puerto de la api>/`, la API del panel y los archivos fijos en `/_a/*`) y el panel con las páginas del Sitio. Publicar graba en el R2 local (`.overture/local`). Sin Ilorb Signal. En la nube: el bucket R2 `{bucket}` guarda las versiones y los medios; el contacto envía correo con la clave de Resend del acceso y el captcha usa `TURNSTILE_SECRET` (opcional, por el entorno). Dominio propio: Custom Domain del Worker en Cloudflare + la misma dirección en `PUBLIC_URL`. Solo funciona en una instalación hecha con `--target local`.',
|
|
51
|
+
runBodyStarter: '`pnpm dev` levanta el acceso (Core Auth, con PAGOS simulados), el Worker de Starter (el cron de cada hora se llama en `/__scheduled`), el panel con las páginas de Starter y la app web de los clientes. Sin Ilorb Signal. En la nube, la app web va al Pages `{app}` (export de Expo; la URL es `APP_URL` y `EXPO_PUBLIC_WEB_URL`) y el Core recibe `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET` (el mismo valor del Worker de Starter). Para extender: `overture-starter/ESTENDER.md`. Solo funciona en una instalación hecha con `--target local`.',
|
|
52
|
+
runBodyLink: '`pnpm dev` levanta el acceso (Core Auth, con PAGOS simulados), el Worker de Link (enlaces cortos y páginas de bio en `http://localhost:<puerto de la api>/`; el cron de cada hora se llama en `/__scheduled`), el panel con las páginas de Link y la app web. Sin Ilorb Signal. En local, los clics van directo a D1 (sin cola). En la nube: R2 `{media}` (fotos de la bio), cola de clics solo con el plan pago de Workers (`--workers-paid`), dominio corto propio con `--short-domain`, y el Core recibe `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET` (el mismo valor del Worker de Link). Opcionales por el entorno: `CF_API_TOKEN` + `CF_ZONE_ID` (dominios de los clientes) y `SAFE_BROWSING_KEY`. Solo funciona en una instalación hecha con `--target local`.',
|
|
53
|
+
runBodyImoveis: '`pnpm dev` levanta el acceso (Core Auth, con PAGOS simulados), el Worker de Inmuebles (el sitio del portal en `http://localhost:<puerto de la api>/`, las fotos en el R2 local, el cron de cada hora en `/__scheduled`), el panel con las páginas de Inmuebles y la app web del anunciante. Sin Ilorb Signal. En la nube: R2 `{media}` (fotos), las fuentes OFL servidas por el propio Core (`/v1/fonts/`), y el Core recibe `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET` (el mismo valor del Worker de Inmuebles). Solo funciona en una instalación hecha con `--target local`.',
|
|
54
|
+
runBodyQuiz: '`pnpm dev` levanta el acceso (Core Auth, con PAGOS simulados), el Worker del Quiz (imágenes en el R2 local, el cron de cada hora en `/__scheduled`), el panel con las páginas del Quiz y el juego web. Sin Ilorb Signal. En la nube el juego web va al Pages `{app}`, R2 `{media}` (imágenes de las preguntas) y el Core recibe `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET`. Preguntas de ejemplo: `overture-quiz/exemplos/perguntas-exemplo.csv` (panel → Quiz → Importar, o `--sample-data`). Para extender: `overture-quiz/ESTENDER.md`. Solo funciona en una instalación hecha con `--target local`.',
|
|
55
|
+
runBodyHelpcenter: '`pnpm dev` levanta el acceso (Core Auth), el Worker del Help Center (el centro en `http://localhost:<puerto de la api>/help`, el widget en `/widget.js`, adjuntos en el R2 local, el cron cada minuto en `/__scheduled`) y el panel con las páginas del Centro de ayuda. Sin Ilorb Signal. El widget se compila dentro del Worker (`overture-helpcenter/web/js` → `node build.mjs` → `api/workers/src/generated/widget.ts`): cambió el widget → build + deploy del Worker. Solo funciona en una instalación hecha con `--target local`.',
|
|
56
56
|
helpEmail: 'Correo de soporte (paso manual)',
|
|
57
57
|
helpEmailBody: '1. Cloudflare → tu dominio → Email → **Email Routing**: actívalo.\n2. Regla de la dirección de soporte con la acción **Send to a Worker** → `{worker}` (una regla igual para cada cola con correo propio).\n3. Activa el **Subaddressing** — sin él la respuesta del cliente a `ayuda+t-<clave>@…` no llega.\n4. **Resend**: dominio verificado y `EMAIL_FROM` en el dominio de la dirección de soporte (si no, los correos van a spam).\n\nEl panel (Centro de ayuda → Ajustes) muestra los mismos pasos con la dirección escrita.',
|
|
58
|
-
runBodyClassificados: '`pnpm dev` levanta el acceso (Core Auth, con PAGOS simulados), el Worker de Clasificados (el sitio con SEO en `http://localhost:<puerto de la api>/`, fotos en el R2 local, el cron cada 5 min en `/__scheduled`), el panel con las páginas de Clasificados y la app web. Sin
|
|
58
|
+
runBodyClassificados: '`pnpm dev` levanta el acceso (Core Auth, con PAGOS simulados), el Worker de Clasificados (el sitio con SEO en `http://localhost:<puerto de la api>/`, fotos en el R2 local, el cron cada 5 min en `/__scheduled`), el panel con las páginas de Clasificados y la app web. Sin Ilorb Signal. En la nube: la app web va al Pages `{app}`, R2 `{media}` (fotos), `--site-domain` conecta el dominio del sitio (el SEO vive de él) y el Core recibe `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET`. Después de instalar: ciudades y barrios, configuración del sitio, planes de destaque (vienen en BRL) y el sitemap en Google Search Console. Solo funciona en una instalación hecha con `--target local`.',
|
|
59
59
|
again: 'Ejecutar el instalador de nuevo',
|
|
60
|
-
againBody: '`npx create-ilorb --resume .` — continúa donde quedó y no duplica nada. ¿Cambiaste una opción (p. ej. `--
|
|
60
|
+
againBody: '`npx create-ilorb --resume .` — continúa donde quedó y no duplica nada. ¿Cambiaste una opción (p. ej. `--ilorb-app-id`)? Rehace solo los pasos afectados.',
|
|
61
61
|
secrets: 'Secretos',
|
|
62
62
|
secretsBody: 'Están en `.overture/secrets.env` (fuera de git, 0600) y en los `.dev.vars` de los Workers (local). Guarda una copia de la `MASTER_KEY`: sin ella el Core pierde las claves de los proveedores.',
|
|
63
63
|
},
|
|
64
64
|
en: {
|
|
65
65
|
oauthNote: 'Sign in with GitHub, Discord or LinkedIn (panel → Sign-in methods): the app uses redirect sign-in with PKCE and needs `expo-crypto` (`npx expo install expo-crypto` in the app folder, then a new build). The way back to the app (`{scheme}://auth`) is already in the Core `settings.oauthRedirects`.',
|
|
66
|
-
intro: 'Generated by `create-
|
|
66
|
+
intro: 'Generated by `create-ilorb` (Ilorb Code). Your choices are in `overture.json` and the theme in `overture.theme.json`.',
|
|
67
67
|
layout: 'Folders',
|
|
68
68
|
run: 'Run on this computer',
|
|
69
|
-
runBody: '`pnpm dev` starts the login (Core Auth), the API, the panel and the web app. The chat is the
|
|
70
|
-
runBodyWidgets: '`pnpm dev` starts the login (Core Auth), the Widgets API, the panel and a test page with the snippet. Create the widget in the panel (Website widgets → Widgets) with the test page domain (`localhost:<port>`) and open `http://localhost:<port>/?w=<widget id>`. The chat is the
|
|
69
|
+
runBody: '`pnpm dev` starts the login (Core Auth), the API, the panel and the web app. The chat is the Ilorb Signal CLOUD one, with your Ilorb Signal TEST app (keys in the API `.dev.vars`). Ilorb Signal callbacks (push, reports) cannot reach localhost: to test them, `cloudflared tunnel --url http://localhost:<api port>` and set `<tunnel URL>/v1/opera/callback` on the TEST app in the Ilorb Signal console — or deploy to the cloud. Only for an installation made with `--target local`.',
|
|
70
|
+
runBodyWidgets: '`pnpm dev` starts the login (Core Auth), the Widgets API, the panel and a test page with the snippet. Create the widget in the panel (Website widgets → Widgets) with the test page domain (`localhost:<port>`) and open `http://localhost:<port>/?w=<widget id>`. The chat is the Ilorb Signal CLOUD one, with your Ilorb Signal TEST app (keys in the API `.dev.vars`). Only for an installation made with `--target local`.',
|
|
71
71
|
runExtraConsultas: 'Consultas: local payment is SIMULATED by Core (fake Pix/card, no key) and `pnpm dev` calls the cron (24 h and 15 min reminders, expired holds) every minute. In the cloud, the Worker cron runs on its own and Core gets `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET` (the same value as the Consultas Worker).',
|
|
72
72
|
snippet: 'On your website',
|
|
73
73
|
snippetBody: 'In the panel → Website widgets → Widgets: create the widget, put your website domain under "Domains" and paste the snippet before `</body>`. The `w.js` is served by the Widgets Worker (the built widget goes INSIDE it: `overture-widgets/web/js` → `pnpm build`, then `wrangler deploy`).',
|
|
74
|
-
runBodyStatus: '`pnpm dev` starts the login (Core Auth), the Status Worker (the public page at `http://localhost:<api port>/` and the checks cron, called every minute at `/__scheduled`) and the panel with the Status pages. Alerts and notices only go to the queue (`NOTIFY_MODE=log`). No
|
|
74
|
+
runBodyStatus: '`pnpm dev` starts the login (Core Auth), the Status Worker (the public page at `http://localhost:<api port>/` and the checks cron, called every minute at `/__scheduled`) and the panel with the Status pages. Alerts and notices only go to the queue (`NOTIFY_MODE=log`). No Ilorb Signal. Only for an installation made with `--target local`.',
|
|
75
75
|
statusCloud: 'In the cloud',
|
|
76
76
|
statusCloudBody: 'The `* * * * *` cron of the `{worker}` Worker runs the checks, the alert/notice queue and the cleanup; `NOTIFY_MODE=live` (webhook and Telegram alerts from the panel; email with the same Resend key as the login). The Worker `SECRETS_KEY` comes from `STATUS_SECRETS_KEY` in `.overture/secrets.env` (it encrypts the Telegram token and webhook secrets): changing it = redo those channels. The page uses the Core look and the OFL fonts from Core itself (`<CORE_URL>/v1/fonts/fonts.css`). Checking from several regions: `REGIONS` in `wrangler.jsonc` (see `overture-status/README.md`).',
|
|
77
77
|
domain: 'Your own domain for the page',
|
|
78
78
|
domainBody: '`npx create-ilorb --resume . --status-domain status.yourcompany.com` attaches the domain to the Worker (Custom Domain; the zone must be in the same Cloudflare account and the token needs Zone · Workers Routes · Edit) and points `PUBLIC_URL` at it (email and feed links). Then, panel → Status → Public page → Domain.',
|
|
79
|
-
runBodyAgenda: '`pnpm dev` starts the login (Core Auth, with SIMULATED payments), the Agenda Worker (the reminders/holds cron is called every minute at `/__scheduled`), the panel with the Agenda pages, the web app and the public booking page (`overture-agenda/web/embed`, its own port). No
|
|
80
|
-
runBodySites: '`pnpm dev` starts the login (Core Auth), the Sites Worker (the published site at `http://localhost:<api port>/`, the panel API and the fixed files at `/_a/*`) and the panel with the Site pages. Publishing writes to the local R2 (`.overture/local`). No
|
|
81
|
-
runBodyStarter: '`pnpm dev` starts the login (Core Auth, with SIMULATED payments), the Starter Worker (the hourly cron is called at `/__scheduled`), the panel with the Starter pages and the customers\' web app. No
|
|
82
|
-
runBodyLink: '`pnpm dev` starts the login (Core Auth, with SIMULATED payments), the Link Worker (short links and bio pages at `http://localhost:<api port>/`; the hourly cron is called at `/__scheduled`), the panel with the Link pages and the web app. No
|
|
83
|
-
runBodyImoveis: '`pnpm dev` starts the login (Core Auth, with SIMULATED payments), the Real estate Worker (the portal site at `http://localhost:<api port>/`, photos in the local R2, the hourly cron at `/__scheduled`), the panel with the Real estate pages and the advertiser web app. No
|
|
84
|
-
runBodyQuiz: '`pnpm dev` starts the login (Core Auth, with SIMULATED payments), the Quiz Worker (images in the local R2, the hourly cron at `/__scheduled`), the panel with the Quiz pages and the web game. No
|
|
85
|
-
runBodyHelpcenter: '`pnpm dev` starts the login (Core Auth), the Help Center Worker (the center at `http://localhost:<api port>/help`, the widget at `/widget.js`, attachments in the local R2, the cron every minute at `/__scheduled`) and the panel with the Help center pages. No
|
|
79
|
+
runBodyAgenda: '`pnpm dev` starts the login (Core Auth, with SIMULATED payments), the Agenda Worker (the reminders/holds cron is called every minute at `/__scheduled`), the panel with the Agenda pages, the web app and the public booking page (`overture-agenda/web/embed`, its own port). No Ilorb Signal. In the cloud the booking page goes to the `{site}` Pages project (`pnpm run build` with `VITE_AGENDA_API_URL` and the index.html `<meta name="agenda-api">`) and the widget is its `embed.js`; Core gets `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET` (the same value as the Agenda Worker). Only for an installation made with `--target local`.',
|
|
80
|
+
runBodySites: '`pnpm dev` starts the login (Core Auth), the Sites Worker (the published site at `http://localhost:<api port>/`, the panel API and the fixed files at `/_a/*`) and the panel with the Site pages. Publishing writes to the local R2 (`.overture/local`). No Ilorb Signal. In the cloud: the `{bucket}` R2 bucket keeps the versions and media; the contact form emails with the login Resend key and the captcha uses `TURNSTILE_SECRET` (optional, from the environment). Own domain: the Worker Custom Domain on Cloudflare + the same address as `PUBLIC_URL`. Only for an installation made with `--target local`.',
|
|
81
|
+
runBodyStarter: '`pnpm dev` starts the login (Core Auth, with SIMULATED payments), the Starter Worker (the hourly cron is called at `/__scheduled`), the panel with the Starter pages and the customers\' web app. No Ilorb Signal. In the cloud, the web app goes to the `{app}` Pages project (Expo export; its URL becomes `APP_URL` and `EXPO_PUBLIC_WEB_URL`) and Core gets `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET` (the same value as the Starter Worker). To extend it: `overture-starter/ESTENDER.md`. Only for an installation made with `--target local`.',
|
|
82
|
+
runBodyLink: '`pnpm dev` starts the login (Core Auth, with SIMULATED payments), the Link Worker (short links and bio pages at `http://localhost:<api port>/`; the hourly cron is called at `/__scheduled`), the panel with the Link pages and the web app. No Ilorb Signal. Locally, clicks go straight to D1 (no queue). In the cloud: R2 `{media}` (bio photos), clicks queue only with the Workers Paid plan (`--workers-paid`), your own short domain with `--short-domain`, and Core gets `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET` (the same value as the Link Worker). Optional from the environment: `CF_API_TOKEN` + `CF_ZONE_ID` (customer domains) and `SAFE_BROWSING_KEY`. Only for an installation made with `--target local`.',
|
|
83
|
+
runBodyImoveis: '`pnpm dev` starts the login (Core Auth, with SIMULATED payments), the Real estate Worker (the portal site at `http://localhost:<api port>/`, photos in the local R2, the hourly cron at `/__scheduled`), the panel with the Real estate pages and the advertiser web app. No Ilorb Signal. In the cloud: R2 `{media}` (photos), the OFL fonts served by Core itself (`/v1/fonts/`), and Core gets `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET` (the same value as the Real estate Worker). Only for an installation made with `--target local`.',
|
|
84
|
+
runBodyQuiz: '`pnpm dev` starts the login (Core Auth, with SIMULATED payments), the Quiz Worker (images in the local R2, the hourly cron at `/__scheduled`), the panel with the Quiz pages and the web game. No Ilorb Signal. In the cloud the web game goes to the `{app}` Pages project, R2 `{media}` (question images) and Core gets `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET`. Sample questions: `overture-quiz/exemplos/perguntas-exemplo.csv` (panel → Quiz → Import, or `--sample-data`). To extend it: `overture-quiz/ESTENDER.md`. Only for an installation made with `--target local`.',
|
|
85
|
+
runBodyHelpcenter: '`pnpm dev` starts the login (Core Auth), the Help Center Worker (the center at `http://localhost:<api port>/help`, the widget at `/widget.js`, attachments in the local R2, the cron every minute at `/__scheduled`) and the panel with the Help center pages. No Ilorb Signal. The widget is built INTO the Worker (`overture-helpcenter/web/js` → `node build.mjs` → `api/workers/src/generated/widget.ts`): changed the widget → build + Worker deploy. Only for an installation made with `--target local`.',
|
|
86
86
|
helpEmail: 'Support email (manual step)',
|
|
87
87
|
helpEmailBody: '1. Cloudflare → your domain → Email → **Email Routing**: enable it.\n2. A rule for the support address with the action **Send to a Worker** → `{worker}` (one rule like it for each queue with its own address).\n3. Turn on **Subaddressing** — without it the customer reply to `help+t-<key>@…` never arrives.\n4. **Resend**: verified domain and `EMAIL_FROM` on the support address domain (otherwise emails land in spam).\n\nThe panel (Help center → Settings) shows the same steps with the address you typed.',
|
|
88
|
-
runBodyClassificados: '`pnpm dev` starts the login (Core Auth, with SIMULATED payments), the Classifieds Worker (the SEO site at `http://localhost:<api port>/`, photos in the local R2, the cron every 5 min at `/__scheduled`), the panel with the Classifieds pages and the web app. No
|
|
88
|
+
runBodyClassificados: '`pnpm dev` starts the login (Core Auth, with SIMULATED payments), the Classifieds Worker (the SEO site at `http://localhost:<api port>/`, photos in the local R2, the cron every 5 min at `/__scheduled`), the panel with the Classifieds pages and the web app. No Ilorb Signal. In the cloud: the web app goes to the `{app}` Pages project, R2 `{media}` (photos), `--site-domain` attaches the site domain (SEO lives on it) and Core gets `PAYMENTS_TOKEN`/`PAYMENTS_CALLBACK_SECRET`. After installing: cities and districts, site settings, featured plans (in BRL) and the sitemap in Google Search Console. Only for an installation made with `--target local`.',
|
|
89
89
|
again: 'Run the installer again',
|
|
90
|
-
againBody: '`npx create-ilorb --resume .` — continues where it stopped and never duplicates. Changed a choice (e.g. `--
|
|
90
|
+
againBody: '`npx create-ilorb --resume .` — continues where it stopped and never duplicates. Changed a choice (e.g. `--ilorb-app-id`)? It redoes only the affected steps.',
|
|
91
91
|
secrets: 'Secrets',
|
|
92
92
|
secretsBody: 'They live in `.overture/secrets.env` (out of git, 0600) and in the Workers\' `.dev.vars` (local). Keep a copy of `MASTER_KEY`: without it the Core loses the provider keys.',
|
|
93
93
|
},
|
|
@@ -117,7 +117,7 @@ scripts/dev-local.mjs pnpm dev`
|
|
|
117
117
|
overture-core/web/react ${a.slug}-admin — painel (Cloudflare Pages) com as páginas do Imóveis
|
|
118
118
|
overture-core/app/react-native/packages tema (e as fontes OFL que o site serve), i18n, componentes e login
|
|
119
119
|
overture-imoveis/api/workers ${a.slug}-imoveis — site + API + D1 ${a.slug}-imoveis + R2 ${a.slug}-imoveis-media (cron ${p.cron})
|
|
120
|
-
overture-imoveis/app/react-native o app do anunciante (Expo: iOS, Android e web) — ${a.bundleId}
|
|
120
|
+
overture-imoveis/app/react-native o app do anunciante (Expo: iOS, Android e web → Pages ${a.slug}-app) — ${a.bundleId}
|
|
121
121
|
overture-imoveis/web/react páginas no painel (visão, anúncios, imobiliárias, leads, lugares, planos, ajustes)
|
|
122
122
|
scripts/dev-local.mjs pnpm dev`
|
|
123
123
|
: p.id === 'quiz'
|
|
@@ -175,7 +175,7 @@ overture-core/app/react-native/packages tema, i18n, componentes e login do app
|
|
|
175
175
|
overture-consultas/api/workers ${a.slug}-consultas — API do ${p.name} + D1 ${a.slug}-consultas (cron ${p.cron})
|
|
176
176
|
overture-consultas/app/react-native o app (Expo: iOS, Android e web) — ${a.bundleId}
|
|
177
177
|
overture-consultas/web/react páginas no painel (profissionais, agenda, reservas, política, avaliações)
|
|
178
|
-
vendor/
|
|
178
|
+
vendor/ Ilorb Signal (só os pacotes do SDK)
|
|
179
179
|
scripts/dev-local.mjs pnpm dev`
|
|
180
180
|
: p.app
|
|
181
181
|
? `overture-core/api/workers ${a.slug}-auth — login (Core Auth) + D1 ${a.slug}-identity
|
|
@@ -183,7 +183,7 @@ overture-core/web/react ${a.slug}-admin — painel (Cloudflare Pages)
|
|
|
183
183
|
overture-core/app/react-native tema, i18n, componentes e login do app
|
|
184
184
|
overture-chat/api/workers ${a.slug}-chat — API do ${p.name} + D1 ${a.slug}-chat
|
|
185
185
|
overture-chat/app/react-native o app (Expo: iOS, Android e web) — ${a.bundleId}
|
|
186
|
-
vendor/
|
|
186
|
+
vendor/ Ilorb Signal (só os pacotes do SDK)
|
|
187
187
|
scripts/dev-local.mjs pnpm dev`
|
|
188
188
|
: `overture-core/api/workers ${a.slug}-auth — login (Core Auth) + D1 ${a.slug}-identity
|
|
189
189
|
overture-core/web/react ${a.slug}-admin — painel (Cloudflare Pages) com Widgets e Caixa de entrada
|
|
@@ -192,7 +192,7 @@ overture-widgets/api/workers ${a.slug}-widgets — API do ${p.name} + D1 ${a.s
|
|
|
192
192
|
overture-widgets/web/js o widget (compilado para dentro do Worker)
|
|
193
193
|
overture-widgets/web/react páginas no painel (Widgets e Caixa de entrada)
|
|
194
194
|
overture-widgets/shared config e tema (o mesmo código no Worker, no painel e no widget)
|
|
195
|
-
vendor/
|
|
195
|
+
vendor/ Ilorb Signal (só os pacotes do SDK)
|
|
196
196
|
scripts/dev-local.mjs pnpm dev`;
|
|
197
197
|
return `# ${a.appName}
|
|
198
198
|
|
package/dist/steps.js
CHANGED
|
@@ -8,7 +8,7 @@ import { configureCore, createBootstrapLink } from "./core-admin.js";
|
|
|
8
8
|
import { hashOf } from "./engine.js";
|
|
9
9
|
import { HumanError } from "./errors.js";
|
|
10
10
|
import { shellLine, tail } from "./exec.js";
|
|
11
|
-
import { writeJson } from "./fsutil.js";
|
|
11
|
+
import { writeFileAtomic, writeJson } from "./fsutil.js";
|
|
12
12
|
import { applyConfig, copyTemplates, missingTemplates, scanForSecrets, writeDevVars, writeRootFiles } from "./generate.js";
|
|
13
13
|
import { t } from "./i18n/index.js";
|
|
14
14
|
import { activate, machineId } from "./license/activate.js";
|
|
@@ -21,6 +21,7 @@ import { licensePath, saveState, STATE_DIR } from "./state.js";
|
|
|
21
21
|
import { saveSecrets } from "./state.js";
|
|
22
22
|
import { downloadTemplates } from "./templates.js";
|
|
23
23
|
import { buildReadme } from "./readme.js";
|
|
24
|
+
import { readTemplateVersion, TEMPLATE_VERSION_FILE, templateRecord } from "./update.js";
|
|
24
25
|
/** for the plan (--dry-run): the names the product Worker would receive, without generating anything */
|
|
25
26
|
const fakeSecrets = (c) => ({ ...Object.fromEntries(['SERVICE_TOKEN', 'PRODUCT_SERVICE_TOKEN', ...Object.keys(c.product.generatedSecrets)].map((k) => [k, '…'])), ...c.secrets });
|
|
26
27
|
const sha = (s) => createHash('sha256').update(s).digest('hex').slice(0, 16);
|
|
@@ -87,6 +88,7 @@ function generateStep() {
|
|
|
87
88
|
c.templatesDir ? `templates da pasta ${c.templatesDir}` : 'GET <templates.url da ativação> → conferir sha256 → tar -xzf em .overture/tmp/',
|
|
88
89
|
`copiar ${c.product.templates.length} pastas para ${c.dir} (sem node_modules, dist, .wrangler, .dev.vars, prints)`,
|
|
89
90
|
'gravar .gitignore, package.json, README.md, scripts/dev-local.mjs na raiz',
|
|
91
|
+
'write ilorb-template.json (template version) at the root and the sha256 of every copied file in .overture/install.json (base of create-ilorb update)',
|
|
90
92
|
],
|
|
91
93
|
async run(c) {
|
|
92
94
|
let root = c.templatesDir;
|
|
@@ -104,6 +106,10 @@ function generateStep() {
|
|
|
104
106
|
if (missing.length)
|
|
105
107
|
throw new HumanError('templates_missing', { path: missing.join(', ') });
|
|
106
108
|
const n = copyTemplates(root, c.dir, c.product);
|
|
109
|
+
// the version installed + the hash of every shipped file: the base of `create-ilorb update --apply` (update.ts)
|
|
110
|
+
c.state.template = templateRecord(root, c.product);
|
|
111
|
+
if (readTemplateVersion(root)?.source === 'file')
|
|
112
|
+
writeFileAtomic(join(c.dir, TEMPLATE_VERSION_FILE), readFileSync(join(root, TEMPLATE_VERSION_FILE), 'utf8'));
|
|
107
113
|
if (!c.templatesDir)
|
|
108
114
|
rmSync(tmp, { recursive: true, force: true });
|
|
109
115
|
writeRootFiles(c.dir, c.answers, c.product, buildReadme(c.answers, c.product));
|
|
@@ -351,7 +357,8 @@ function configStep() {
|
|
|
351
357
|
return {
|
|
352
358
|
id: 'config',
|
|
353
359
|
title: t('step.config'),
|
|
354
|
-
|
|
360
|
+
// configRev (only when the spec sets it) reruns the config of OLD installs on --resume when a product gains a var
|
|
361
|
+
hash: (c) => hashOf(c.answers, c.answers.target === 'cloud' ? cloudUrls(c) : localUrls(c), c.state.resources.d1, c.state.local, ...(c.product.configRev ? [c.product.configRev] : [])),
|
|
355
362
|
plan: (c) => c.answers.target === 'cloud'
|
|
356
363
|
? [
|
|
357
364
|
`${names(c.answers, c.product).auth}: wrangler.jsonc com o id do D1, PUBLIC_URL=${cloudUrls(c).auth}, OWNER_EMAIL, ENVIRONMENT=production, DELIVERY_MODE=send`,
|
|
@@ -360,8 +367,8 @@ function configStep() {
|
|
|
360
367
|
]
|
|
361
368
|
: [
|
|
362
369
|
c.product.opera
|
|
363
|
-
? `wrangler.jsonc dos Workers com as portas locais; .dev.vars (segredos locais e as chaves do app de TESTE do
|
|
364
|
-
: `wrangler.jsonc dos Workers com as portas locais${c.product.cron ? ` e o cron "${c.product.cron}"` : ''}; .dev.vars (segredos locais, fora do git) — sem
|
|
370
|
+
? `wrangler.jsonc dos Workers com as portas locais; .dev.vars (segredos locais e as chaves do app de TESTE do Ilorb Signal, fora do git) · chat do Ilorb Signal: ${localUrls(c).opera}`
|
|
371
|
+
: `wrangler.jsonc dos Workers com as portas locais${c.product.cron ? ` e o cron "${c.product.cron}"` : ''}; .dev.vars (segredos locais, fora do git) — sem Ilorb Signal`,
|
|
365
372
|
c.product.app ? 'app.json, .env do app, overture.json, overture.theme.json' : 'overture.json, overture.theme.json',
|
|
366
373
|
],
|
|
367
374
|
async run(c) {
|
|
@@ -742,7 +749,7 @@ function operaTestAppStep() {
|
|
|
742
749
|
id: 'local.opera',
|
|
743
750
|
title: t('step.operaTestApp'),
|
|
744
751
|
always: true,
|
|
745
|
-
plan: (c) => [`conferir App ID (${c.answers.opera.appId ?? 'faltando'}) e App Secret (${c.secrets.OPERA_APP_SECRET ? 'ok' : 'faltando'}) do app de TESTE do
|
|
752
|
+
plan: (c) => [`conferir App ID (${c.answers.opera.appId ?? 'faltando'}) e App Secret (${c.secrets.OPERA_APP_SECRET ? 'ok' : 'faltando'}) do app de TESTE do Ilorb Signal · chat ${localUrls(c).opera}`],
|
|
746
753
|
async run(c) {
|
|
747
754
|
if (!c.answers.opera.appId || !c.secrets.OPERA_APP_SECRET)
|
|
748
755
|
throw new HumanError('opera_test_app_missing', { dir: c.dir });
|
|
@@ -836,7 +843,7 @@ function startStep() {
|
|
|
836
843
|
title: t('step.start'),
|
|
837
844
|
always: true,
|
|
838
845
|
plan: (c) => [
|
|
839
|
-
`node scripts/dev-local.mjs → wrangler dev (Core Auth, API do ${c.product.name}) + ${c.product.webBuild ? 'painel, app e página de reservas estáticos' : c.product.app ? 'painel e app estáticos' : c.product.localPorts.includes('site') ? 'painel estático e a página de teste com o snippet' : 'painel estático'}; espera cada um responder${c.product.opera ? ' (o chat do
|
|
846
|
+
`node scripts/dev-local.mjs → wrangler dev (Core Auth, API do ${c.product.name}) + ${c.product.webBuild ? 'painel, app e página de reservas estáticos' : c.product.app ? 'painel e app estáticos' : c.product.localPorts.includes('site') ? 'painel estático e a página de teste com o snippet' : 'painel estático'}; espera cada um responder${c.product.opera ? ' (o chat do Ilorb Signal é o da nuvem)' : ''}`,
|
|
840
847
|
...(c.product.cron ? [`cron "${c.product.cron}" (Core e API do ${c.product.name}): wrangler dev --test-scheduled + GET /__scheduled a cada minuto`] : []),
|
|
841
848
|
],
|
|
842
849
|
async run(c) {
|
package/dist/theme/preview.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// Theme samples in the terminal, with the SAME engine as the app (buildTheme, faithful copy of
|
|
2
2
|
// overture-core/app/react-native/packages/theme/src — the theme-sync test checks it has not diverged).
|
|
3
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
4
|
+
import { join } from 'node:path';
|
|
3
5
|
import { contrast } from "./vendor/color.js";
|
|
6
|
+
import { checkThemeShape, normalizeHex as fullHex } from "./vendor/validate.js";
|
|
4
7
|
import { buildTheme, PRESETS, resolveConfig } from "./vendor/tokens.js";
|
|
5
8
|
import { t } from "../i18n/index.js";
|
|
6
9
|
export const PRESET_IDS = Object.keys(PRESETS);
|
|
@@ -31,6 +34,31 @@ export function resolveTheme(preset, primary) {
|
|
|
31
34
|
const r = resolveConfig({ preset, ...(primary ? { primary: normalizeHex(primary) } : {}) });
|
|
32
35
|
return { preset: r.preset, mode: r.mode, primary: r.primary, accent: r.accent, radius: r.radius, font: r.font, density: r.density };
|
|
33
36
|
}
|
|
37
|
+
export const THEME_FILE = 'overture.theme.json';
|
|
38
|
+
/**
|
|
39
|
+
* The look the buyer chose on Ilorb Code: `<template folder>/overture.theme.json` (appended to the zip by the download,
|
|
40
|
+
* next to ilorb.env; same shape this installer writes). Validated with the engine's checkThemeShape (format: known keys,
|
|
41
|
+
* hex colors, enums). null = no file; `{ error }` = a file that is not usable (the caller warns and asks as usual).
|
|
42
|
+
* Its radius and font are KEPT (resolveConfig), not re-derived from the style.
|
|
43
|
+
*/
|
|
44
|
+
export function readThemeFile(dir) {
|
|
45
|
+
const file = join(dir, THEME_FILE);
|
|
46
|
+
if (!existsSync(file))
|
|
47
|
+
return null;
|
|
48
|
+
let input;
|
|
49
|
+
try {
|
|
50
|
+
input = JSON.parse(readFileSync(file, 'utf8'));
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return { error: 'not JSON' };
|
|
54
|
+
}
|
|
55
|
+
const issues = checkThemeShape(input).filter((i) => i.severity === 'error');
|
|
56
|
+
if (issues.length)
|
|
57
|
+
return { error: [...new Set(issues.map((i) => i.field || 'theme'))].join(', ') };
|
|
58
|
+
const r = resolveConfig(input);
|
|
59
|
+
// #abc → #AABBCC: the answers (and --primary) use 6 hex digits
|
|
60
|
+
return { theme: { preset: r.preset, mode: r.mode, primary: fullHex(r.primary), accent: fullHex(r.accent), radius: r.radius, font: r.font, density: r.density } };
|
|
61
|
+
}
|
|
34
62
|
/** What the engine did with the chosen color (to tell the buyer, with no surprise). */
|
|
35
63
|
export function primaryReport(cfg) {
|
|
36
64
|
const l = buildTheme(cfg, 'light').colors;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Ilorb color: sRGB ↔ OKLCH conversion, WCAG 2.x contrast and adjustment until the minimum is met.
|
|
2
2
|
// No dependencies. OKLCH is used because changing its lightness (L) does not change the perceived
|
|
3
3
|
// "tone" — which is what lets us generate a whole scale from ONE color the buyer chose.
|
|
4
4
|
const clamp01 = (x) => Math.min(1, Math.max(0, x));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Ilorb tokens — the ONLY source of visual values for all products.
|
|
2
2
|
// No screen writes a loose color, size, radius or shadow: everything comes out of buildTheme().
|
|
3
3
|
import { buildScale, contrast, ensureContrast, hexToOklch, mix, oklchToHex, onColor } from "./color.js";
|
|
4
4
|
/** body size in px: the rest of the scale follows in the same proportion */
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
// Buyer theme validation — the SAME on the server (rejects with 422 invalid_theme) and in the panel (contrast table,
|
|
2
|
+
// "Fix" button). Two families of problems:
|
|
3
|
+
// 1. format: unknown key, color that is not hex, size outside 14–18, bad URL… → error
|
|
4
|
+
// 2. legibility of what the BUYER chose: text/background below 4.5, background outside the mode's range → error
|
|
5
|
+
// (DERIVED colors are not checked here: the engine always fixes them — see buildTheme)
|
|
6
|
+
// + warnings (non-blocking): the engine will show the color with a different lightness, a button that vanishes into the background.
|
|
7
|
+
// Every problem carries the pair, the measured ratio, the minimum and a SUGGESTION (the field value that fixes it).
|
|
8
|
+
import { contrast, ensureContrast } from "./color.js";
|
|
9
|
+
import { BACKGROUND_RANGE, DENSITY_IDS, FONT_IDS, FONT_SIZE, HEADING_WEIGHT_IDS, MODE_IDS, PRESETS, RADIUS_IDS, TEXT_MIN, chosenSurface, clampBackground, defaultBackground, defaultText, isHex, resolveConfig, solidWithOn, } from "./tokens.js";
|
|
10
|
+
/** all the keys the theme accepts (v1 format) */
|
|
11
|
+
export const THEME_FIELDS = [
|
|
12
|
+
'preset', 'mode', 'primary', 'secondary', 'accent', 'background', 'text', 'backgroundDark', 'textDark', 'success', 'danger',
|
|
13
|
+
'radius', 'font', 'fontSize', 'headingWeight', 'density', 'logo', 'logoDark', 'favicon',
|
|
14
|
+
];
|
|
15
|
+
export const COLOR_FIELDS = ['primary', 'secondary', 'accent', 'background', 'text', 'backgroundDark', 'textDark', 'success', 'danger'];
|
|
16
|
+
export const URL_FIELDS = ['logo', 'logoDark', 'favicon'];
|
|
17
|
+
const round2 = (n) => Math.round(n * 100) / 100;
|
|
18
|
+
const isObj = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
19
|
+
/** URL accepted for logo/favicon: https (or http on localhost/127.0.0.1, for local mode), up to 500 characters */
|
|
20
|
+
export function isAssetUrl(v) {
|
|
21
|
+
if (typeof v !== 'string' || v.length > 500 || /\s/.test(v))
|
|
22
|
+
return false;
|
|
23
|
+
try {
|
|
24
|
+
const u = new URL(v);
|
|
25
|
+
if (u.protocol === 'https:')
|
|
26
|
+
return true;
|
|
27
|
+
return u.protocol === 'http:' && (u.hostname === 'localhost' || u.hostname === '127.0.0.1');
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** format only (serves the general theme and a product's "only what changes"). `null` in a field = remove it. */
|
|
34
|
+
export function checkThemeShape(input, opts = {}) {
|
|
35
|
+
const issues = [];
|
|
36
|
+
if (!isObj(input))
|
|
37
|
+
return [{ code: 'invalid_value', severity: 'error', field: '', message: 'the theme must be an object' }];
|
|
38
|
+
const bad = (field, message, suggestion) => issues.push({ code: 'invalid_value', severity: 'error', field, message, ...(suggestion !== undefined ? { suggestion } : {}) });
|
|
39
|
+
for (const [k, v] of Object.entries(input)) {
|
|
40
|
+
if (!THEME_FIELDS.includes(k)) {
|
|
41
|
+
issues.push({ code: 'unknown_field', severity: 'error', field: k, suggestion: null, message: `unknown field: ${k}` });
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (v === null || v === undefined) {
|
|
45
|
+
if (k === 'preset' && !opts.partial)
|
|
46
|
+
bad(k, 'preset is required', 'clean');
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
switch (k) {
|
|
50
|
+
case 'preset':
|
|
51
|
+
if (typeof v !== 'string' || !(v in PRESETS))
|
|
52
|
+
bad(k, 'preset: clean|bold|soft|night', 'clean');
|
|
53
|
+
break;
|
|
54
|
+
case 'mode':
|
|
55
|
+
if (!MODE_IDS.includes(v))
|
|
56
|
+
bad(k, 'mode: system|light|dark', 'system');
|
|
57
|
+
break;
|
|
58
|
+
case 'radius':
|
|
59
|
+
if (!RADIUS_IDS.includes(v))
|
|
60
|
+
bad(k, 'radius: sharp|soft|round', 'soft');
|
|
61
|
+
break;
|
|
62
|
+
case 'font':
|
|
63
|
+
if (!FONT_IDS.includes(v))
|
|
64
|
+
bad(k, 'font: system|inter|jakarta|nunito', 'inter');
|
|
65
|
+
break;
|
|
66
|
+
case 'density':
|
|
67
|
+
if (!DENSITY_IDS.includes(v))
|
|
68
|
+
bad(k, 'density: compact|regular|comfortable', 'regular');
|
|
69
|
+
break;
|
|
70
|
+
case 'headingWeight':
|
|
71
|
+
if (!HEADING_WEIGHT_IDS.includes(v))
|
|
72
|
+
bad(k, 'headingWeight: semibold|bold|extrabold', 'bold');
|
|
73
|
+
break;
|
|
74
|
+
case 'fontSize':
|
|
75
|
+
if (typeof v !== 'number' || !Number.isInteger(v) || v < FONT_SIZE.min || v > FONT_SIZE.max) {
|
|
76
|
+
const n = typeof v === 'number' && Number.isFinite(v) ? Math.min(FONT_SIZE.max, Math.max(FONT_SIZE.min, Math.round(v))) : FONT_SIZE.default;
|
|
77
|
+
bad(k, `fontSize: integer from ${FONT_SIZE.min} to ${FONT_SIZE.max}`, n);
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
case 'logo':
|
|
81
|
+
case 'logoDark':
|
|
82
|
+
case 'favicon':
|
|
83
|
+
if (!isAssetUrl(v))
|
|
84
|
+
bad(k, `${k}: https URL (up to 500 characters)`, null);
|
|
85
|
+
break;
|
|
86
|
+
default:
|
|
87
|
+
if (!isHex(v))
|
|
88
|
+
bad(k, `${k}: hex color (#RRGGBB)`, null);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (!opts.partial && !('preset' in input))
|
|
92
|
+
bad('preset', 'preset is required', 'clean');
|
|
93
|
+
return issues;
|
|
94
|
+
}
|
|
95
|
+
/** Merges the general theme with the product's "only what changes" (field by field; `null` in the product = inherit). */
|
|
96
|
+
export function mergeTheme(general, override) {
|
|
97
|
+
const out = { ...general };
|
|
98
|
+
if (override)
|
|
99
|
+
for (const [k, v] of Object.entries(override))
|
|
100
|
+
if (v !== null && v !== undefined)
|
|
101
|
+
out[k] = v;
|
|
102
|
+
// `secondary` is the new name of `accent`: whoever changes one in the product changes the color of both
|
|
103
|
+
if (override && (override.secondary || override.accent)) {
|
|
104
|
+
out.secondary = override.secondary ?? override.accent;
|
|
105
|
+
delete out.accent;
|
|
106
|
+
}
|
|
107
|
+
return out;
|
|
108
|
+
}
|
|
109
|
+
/** the keys the product inherits from the general theme (the ones it does not change) */
|
|
110
|
+
export function inheritedFields(override) {
|
|
111
|
+
const own = new Set(Object.entries(override ?? {}).filter(([, v]) => v !== null && v !== undefined).map(([k]) => k));
|
|
112
|
+
if (own.has('accent'))
|
|
113
|
+
own.add('secondary');
|
|
114
|
+
if (own.has('secondary'))
|
|
115
|
+
own.add('accent');
|
|
116
|
+
return THEME_FIELDS.filter((f) => !own.has(f));
|
|
117
|
+
}
|
|
118
|
+
/** Legibility of what the buyer chose (the config already has a valid format). */
|
|
119
|
+
function checkLegibility(cfg) {
|
|
120
|
+
const issues = [];
|
|
121
|
+
for (const scheme of ['light', 'dark']) {
|
|
122
|
+
const chosen = chosenSurface(cfg, scheme);
|
|
123
|
+
const bgField = scheme === 'light' ? 'background' : 'backgroundDark';
|
|
124
|
+
const textField = scheme === 'light' ? 'text' : 'textDark';
|
|
125
|
+
let bg = chosen.bg ?? defaultBackground(cfg, scheme);
|
|
126
|
+
// 1. background within the mode's range (only what the buyer GAVE: the derived one is born inside it)
|
|
127
|
+
if (chosen.bgFrom === bgField) {
|
|
128
|
+
const r = BACKGROUND_RANGE[scheme];
|
|
129
|
+
const ratio = contrast(bg, r.against);
|
|
130
|
+
if (ratio < r.min) {
|
|
131
|
+
const fixed = clampBackground(bg, scheme);
|
|
132
|
+
issues.push({
|
|
133
|
+
code: 'background_range', severity: 'error', field: bgField, scheme, pair: [bgField, scheme === 'light' ? '#000000' : '#FFFFFF'],
|
|
134
|
+
colors: [bg, r.against], ratio: round2(ratio), min: r.min, suggestion: ensureContrast(bg, r.against, r.min + 0.2),
|
|
135
|
+
message: scheme === 'light'
|
|
136
|
+
? `light mode background too dark (${round2(ratio)}:1 against black; minimum ${r.min}:1)`
|
|
137
|
+
: `dark mode background too light (${round2(ratio)}:1 against white; minimum ${r.min}:1)`,
|
|
138
|
+
});
|
|
139
|
+
bg = fixed;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// 2. text over the background (when either of the two is the buyer's choice)
|
|
143
|
+
const givenText = chosen.textFrom === textField;
|
|
144
|
+
const givenBg = chosen.bgFrom === bgField;
|
|
145
|
+
if (givenText || givenBg) {
|
|
146
|
+
const text = chosen.text ?? defaultText(cfg, scheme);
|
|
147
|
+
const ratio = contrast(text, bg);
|
|
148
|
+
if (ratio < TEXT_MIN) {
|
|
149
|
+
// fixes the text if it was the one the buyer gave; otherwise the background (which is the one they gave)
|
|
150
|
+
const field = givenText ? textField : bgField;
|
|
151
|
+
const suggestion = givenText ? ensureContrast(text, bg, TEXT_MIN + 0.1) : clampBackground(ensureContrast(bg, text, TEXT_MIN + 0.1), scheme);
|
|
152
|
+
issues.push({
|
|
153
|
+
code: 'low_contrast', severity: 'error', field, scheme, pair: [textField, bgField], colors: [text, bg],
|
|
154
|
+
ratio: round2(ratio), min: TEXT_MIN, suggestion,
|
|
155
|
+
message: `text on the background (${scheme}) = ${round2(ratio)}:1; minimum ${TEXT_MIN}:1`,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// warnings: the solid color the engine will show in light mode differs from the chosen one (button, success, error)
|
|
161
|
+
const lightBg = clampBackground(cfg.background ?? '#FFFFFF', 'light');
|
|
162
|
+
for (const field of ['primary', 'success', 'danger']) {
|
|
163
|
+
const chosenColor = cfg[field];
|
|
164
|
+
// the style's default color raises no warning (Bold is born with the red adjusted on purpose)
|
|
165
|
+
if (!chosenColor || (field === 'primary' && normalizeHex(chosenColor) === PRESETS[cfg.preset].primary))
|
|
166
|
+
continue;
|
|
167
|
+
const { solid, on } = solidWithOn(chosenColor);
|
|
168
|
+
if (solid.toUpperCase() !== normalizeHex(chosenColor)) {
|
|
169
|
+
issues.push({
|
|
170
|
+
code: 'adjusted', severity: 'warning', field, scheme: 'light', pair: [field, 'on'], colors: [chosenColor, on],
|
|
171
|
+
ratio: round2(contrast(chosenColor, on)), min: 4.5, suggestion: solid,
|
|
172
|
+
message: `${field}: the text on top does not reach 4.5; the app shows ${solid}`,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (cfg.background) {
|
|
177
|
+
const { solid } = solidWithOn(cfg.primary);
|
|
178
|
+
const ratio = contrast(solid, lightBg);
|
|
179
|
+
if (ratio < 3) {
|
|
180
|
+
issues.push({
|
|
181
|
+
code: 'low_visibility', severity: 'warning', field: 'primary', scheme: 'light', pair: ['primary', 'background'],
|
|
182
|
+
colors: [solid, lightBg], ratio: round2(ratio), min: 3, suggestion: ensureContrast(solid, lightBg, 3.1),
|
|
183
|
+
message: `primary button barely visible on the background (${round2(ratio)}:1; recommended 3:1)`,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return issues;
|
|
188
|
+
}
|
|
189
|
+
/** #abc / #AbCdEf → #AABBCC */
|
|
190
|
+
export function normalizeHex(hex) {
|
|
191
|
+
let h = hex.trim().replace(/^#/, '');
|
|
192
|
+
if (h.length === 3)
|
|
193
|
+
h = h.split('').map((c) => c + c).join('');
|
|
194
|
+
return `#${h.toUpperCase()}`;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* The theme's problems (format + legibility). `ok` = no ERROR (warnings do not block).
|
|
198
|
+
* The server saves only if `ok`; the panel shows everything and "Fix" applies `suggestion` to `field`.
|
|
199
|
+
*/
|
|
200
|
+
export function validateTheme(input) {
|
|
201
|
+
const shape = checkThemeShape(input);
|
|
202
|
+
if (shape.length)
|
|
203
|
+
return { ok: false, issues: shape };
|
|
204
|
+
const issues = checkLegibility(resolveConfig(input));
|
|
205
|
+
return { ok: !issues.some((i) => i.severity === 'error'), issues };
|
|
206
|
+
}
|
|
207
|
+
/** Applies the suggestions (from "Fix all" or from a single problem). `null` removes the field. */
|
|
208
|
+
export function applySuggestions(config, issues) {
|
|
209
|
+
const out = { ...config };
|
|
210
|
+
for (const i of issues) {
|
|
211
|
+
if (i.suggestion === undefined || !i.field)
|
|
212
|
+
continue;
|
|
213
|
+
if (i.suggestion === null)
|
|
214
|
+
delete out[i.field];
|
|
215
|
+
else
|
|
216
|
+
out[i.field] = i.suggestion;
|
|
217
|
+
}
|
|
218
|
+
return out;
|
|
219
|
+
}
|