odoro 1.0.9 → 2.1.0

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 (88) hide show
  1. package/README.md +94 -0
  2. package/client.d.ts +90 -16
  3. package/dist/build-XJIP4GNT.js +5 -0
  4. package/dist/{chunk-34RGOZFA.js → chunk-4D56Z7G3.js} +49 -50
  5. package/dist/{chunk-JMEHF3KN.js → chunk-7ZB5MAM6.js} +4 -4
  6. package/dist/chunk-DF67LADH.js +735 -0
  7. package/dist/{chunk-LHZGX5ML.js → chunk-HS7NGZLM.js} +307 -196
  8. package/dist/chunk-LIKVHWB4.js +231 -0
  9. package/dist/chunk-QOVBLN7A.js +241 -0
  10. package/dist/chunk-RTWJ5GFB.js +729 -0
  11. package/dist/chunk-TONYIKCN.js +57 -0
  12. package/dist/cli.d.ts +12 -13
  13. package/dist/cli.js +86 -63
  14. package/dist/{commands-AHMXBWQQ.js → commands-GYA7NTCX.js} +124 -124
  15. package/dist/commands-UOWN3IK4.js +181 -0
  16. package/dist/{create-CYVSVDAD.js → create-B2TLV6XI.js} +198 -160
  17. package/dist/index.d.ts +603 -151
  18. package/dist/index.js +6 -6
  19. package/dist/{package-EIDLKAA6.js → package-3ZJOEXM4.js} +6 -5
  20. package/dist/preview-3IRG7MHV.js +4 -0
  21. package/dist/registry/index.d.ts +75 -76
  22. package/dist/registry/index.js +1 -1
  23. package/dist/{server-4UGN3SFS.js → server-ZB3P3EGS.js} +3 -3
  24. package/package.json +6 -5
  25. package/templates/react-ts/README.md +71 -35
  26. package/templates/react-ts/_env.example +9 -0
  27. package/templates/react-ts/_variants/with-engine/src/background.tsx +118 -0
  28. package/templates/react-ts/_variants/without-libs/src/App.tsx +380 -0
  29. package/templates/react-ts/_variants/without-libs/src/background.tsx +24 -0
  30. package/templates/react-ts/_variants/without-libs/src/entry-server.tsx +39 -0
  31. package/templates/react-ts/_variants/without-libs/src/main.tsx +26 -0
  32. package/templates/{react-ts-server/_variantes/sans-libs/client → react-ts/_variants/without-libs}/src/styles.css +137 -137
  33. package/templates/react-ts/{_variantes/sans-routeur → _variants/without-router}/src/App.tsx +141 -141
  34. package/templates/react-ts/_variants/without-router/src/entry-server.tsx +39 -0
  35. package/templates/react-ts/index.html +4 -4
  36. package/templates/react-ts/odoro.config.ts +5 -0
  37. package/templates/react-ts/src/App.tsx +219 -209
  38. package/templates/react-ts/src/background.tsx +66 -0
  39. package/templates/react-ts/src/entry-server.tsx +85 -0
  40. package/templates/react-ts/src/main.tsx +13 -4
  41. package/templates/react-ts/src/router.tsx +65 -45
  42. package/templates/react-ts/src/styles.css +5 -5
  43. package/templates/react-ts-server/Dockerfile +9 -9
  44. package/templates/react-ts-server/README.md +97 -45
  45. package/templates/react-ts-server/_env.example +31 -33
  46. package/templates/react-ts-server/_variants/with-engine/client/src/background.tsx +118 -0
  47. package/templates/react-ts-server/_variants/without-libs/client/src/App.tsx +380 -0
  48. package/templates/react-ts-server/_variants/without-libs/client/src/background.tsx +24 -0
  49. package/templates/react-ts-server/_variants/without-libs/client/src/entry-server.tsx +39 -0
  50. package/templates/react-ts-server/_variants/without-libs/client/src/main.tsx +26 -0
  51. package/templates/{react-ts/_variantes/sans-libs → react-ts-server/_variants/without-libs/client}/src/styles.css +137 -137
  52. package/templates/react-ts-server/{_variantes/sans-routeur → _variants/without-router}/client/src/App.tsx +141 -141
  53. package/templates/react-ts-server/_variants/without-router/client/src/entry-server.tsx +39 -0
  54. package/templates/react-ts-server/client/index.html +4 -4
  55. package/templates/react-ts-server/client/src/App.tsx +228 -210
  56. package/templates/react-ts-server/client/src/account.tsx +267 -0
  57. package/templates/react-ts-server/client/src/auth.tsx +139 -0
  58. package/templates/react-ts-server/client/src/background.tsx +66 -0
  59. package/templates/react-ts-server/client/src/entry-server.tsx +92 -0
  60. package/templates/react-ts-server/client/src/main.tsx +17 -5
  61. package/templates/react-ts-server/client/src/router.tsx +77 -45
  62. package/templates/react-ts-server/client/src/styles.css +5 -5
  63. package/templates/react-ts-server/odoro.config.ts +7 -4
  64. package/templates/react-ts-server/package.json +2 -0
  65. package/templates/react-ts-server/scripts/dev.mjs +14 -14
  66. package/templates/react-ts-server/server/src/main.ts +119 -45
  67. package/templates/react-ts-server/server/src/modules/auth/index.ts +238 -0
  68. package/templates/react-ts-server/server/src/modules/auth/password.ts +122 -0
  69. package/templates/react-ts-server/server/src/modules/auth/store.ts +193 -0
  70. package/templates/react-ts-server/server/src/modules/health/index.ts +45 -46
  71. package/dist/build-JFQHODAT.js +0 -5
  72. package/dist/chunk-22KJTV2R.js +0 -380
  73. package/dist/chunk-3SZIN6VG.js +0 -64
  74. package/dist/chunk-DL3NPC4H.js +0 -113
  75. package/dist/chunk-TQUJ3MFS.js +0 -268
  76. package/dist/chunk-ZVL7EXJO.js +0 -66
  77. package/dist/commands-4JRBD55Z.js +0 -245
  78. package/dist/preview-7DKEAQOQ.js +0 -4
  79. package/templates/react-ts/_variantes/avec-moteur/src/fond.tsx +0 -118
  80. package/templates/react-ts/_variantes/sans-libs/src/App.tsx +0 -382
  81. package/templates/react-ts/_variantes/sans-libs/src/fond.tsx +0 -23
  82. package/templates/react-ts/_variantes/sans-libs/src/main.tsx +0 -17
  83. package/templates/react-ts/src/fond.tsx +0 -66
  84. package/templates/react-ts-server/_variantes/avec-moteur/client/src/fond.tsx +0 -118
  85. package/templates/react-ts-server/_variantes/sans-libs/client/src/App.tsx +0 -382
  86. package/templates/react-ts-server/_variantes/sans-libs/client/src/fond.tsx +0 -23
  87. package/templates/react-ts-server/_variantes/sans-libs/client/src/main.tsx +0 -17
  88. package/templates/react-ts-server/client/src/fond.tsx +0 -66
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env node
2
+ import { isAssetRequest, sendFile, listen, openBrowser } from './chunk-RTWJ5GFB.js';
3
+ import { warn, success, info, colors } from './chunk-7ZB5MAM6.js';
4
+ import { existsSync, statSync } from 'fs';
5
+ import { createServer } from 'http';
6
+ import { normalize, join, extname } from 'path';
7
+
8
+ async function startPreviewServer(config, port = config.server.port + 1) {
9
+ if (!existsSync(config.outDir)) {
10
+ throw new Error(`[odoro] Nothing to preview: run "odoro build" first.`);
11
+ }
12
+ const server = createServer((incoming, response) => {
13
+ const path = (incoming.url ?? "/").split("?")[0] ?? "/";
14
+ const relativePath = normalize(decodeURIComponent(path)).split(/[\\/]/).filter(Boolean).join("/");
15
+ const candidate = join(config.outDir, relativePath);
16
+ const inDirectory = ["index.html", "index.md"].map((name) => join(candidate, name)).find((path2) => existsSync(path2) && statSync(path2).isFile());
17
+ const existing = existsSync(candidate) && statSync(candidate).isFile() ? candidate : inDirectory;
18
+ if (existing === void 0 && (extname(relativePath) !== "" || isAssetRequest(incoming.headers))) {
19
+ response.writeHead(404, { "Content-Type": "text/plain; charset=utf-8" });
20
+ response.end(`Not found: /${relativePath}`);
21
+ return;
22
+ }
23
+ const file = existing ?? join(config.outDir, "index.html");
24
+ if (!file.startsWith(config.outDir)) {
25
+ response.writeHead(403, { "Content-Type": "text/plain" });
26
+ response.end("Forbidden");
27
+ return;
28
+ }
29
+ const immutable = relativePath.startsWith("assets/");
30
+ sendFile(response, file, {
31
+ cacheControl: immutable ? "public, max-age=31536000, immutable" : "no-cache",
32
+ range: incoming.headers.range,
33
+ headOnly: incoming.method === "HEAD"
34
+ });
35
+ });
36
+ const { port: obtained, requested } = await listen(
37
+ server,
38
+ port,
39
+ config.server.host,
40
+ config.server.strictPort ? 1 : void 0
41
+ );
42
+ if (requested !== void 0) {
43
+ warn(
44
+ `port ${String(requested)} in use \u2014 preview listening on ${String(obtained)}`
45
+ );
46
+ }
47
+ const url = `http://${config.server.host}:${String(obtained)}${config.base}`;
48
+ success("preview of the production build");
49
+ info(` ${colors.cyan(url)}`);
50
+ if (config.server.open) openBrowser(url);
51
+ return {
52
+ url,
53
+ close: () => new Promise((done) => server.close(() => done()))
54
+ };
55
+ }
56
+
57
+ export { startPreviewServer };
package/dist/cli.d.ts CHANGED
@@ -1,26 +1,25 @@
1
1
  /**
2
- * Entree en ligne de commande du moteur Odoro.
2
+ * Command line entry of the Odoro engine.
3
3
  *
4
- * L'analyse des arguments est ecrite a la main : elle tient en quarante
5
- * lignes, et le binaire est telecharge a chaque `npm create odoro`, donc son
6
- * poids compte.
4
+ * The argument parsing is written by hand: it fits in forty lines, and the
5
+ * binary is downloaded on every `npm create odoro`, so its weight counts.
7
6
  *
8
7
  * @module
9
8
  */
10
- /** Arguments analyses. */
9
+ /** Parsed arguments. */
11
10
  interface ParsedArgs {
12
- /** Sous-commande demandee. */
11
+ /** Subcommand requested. */
13
12
  command: string;
14
- /** Arguments positionnels restants. */
13
+ /** Remaining positional arguments. */
15
14
  positional: string[];
16
- /** Options nommees. */
15
+ /** Named options. */
17
16
  flags: Record<string, string | boolean>;
18
17
  }
19
18
  /**
20
- * Analyse une ligne de commande.
19
+ * Parses a command line.
21
20
  *
22
- * Reconnait `--option`, `--option=valeur`, `--option valeur`, `--no-option`
23
- * et les alias courts `-h` et `-v`.
21
+ * Recognises `--option`, `--option=value`, `--option value`, `--no-option` and
22
+ * the short aliases `-h` and `-v`.
24
23
  *
25
24
  * @example
26
25
  * parseArgs(['create', 'site', '--template=react-ts', '--no-git'])
@@ -28,9 +27,9 @@ interface ParsedArgs {
28
27
  */
29
28
  declare function parseArgs(argv: readonly string[]): ParsedArgs;
30
29
  /**
31
- * Point d'entree du binaire.
30
+ * Entry point of the binary.
32
31
  *
33
- * @returns Le code de sortie du processus.
32
+ * @returns The exit code of the process.
34
33
  *
35
34
  * @example
36
35
  * const code = await run(['dev', '--port', '3000'])
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { loadConfig } from './chunk-DL3NPC4H.js';
2
+ import { loadConfig } from './chunk-QOVBLN7A.js';
3
3
  import './chunk-T6RLHSCW.js';
4
- import { error } from './chunk-JMEHF3KN.js';
4
+ import { error } from './chunk-7ZB5MAM6.js';
5
5
  import { realpathSync } from 'fs';
6
6
  import { fileURLToPath } from 'url';
7
7
  import colors from 'picocolors';
@@ -46,66 +46,73 @@ function parseArgs(argv) {
46
46
  return { command, positional, flags };
47
47
  }
48
48
  var HELP = `
49
- ${colors.bold(colors.magenta("odoro"))} \u2014 moteur de developpement et echafaudage
49
+ ${colors.bold(colors.magenta("odoro"))} \u2014 development engine and scaffolder
50
50
 
51
- ${colors.bold("Utilisation")}
52
- odoro <commande> [options]
51
+ ${colors.bold("Usage")}
52
+ odoro <command> [options]
53
53
 
54
- ${colors.bold("Commandes")}
55
- create [nom] Cree un projet a partir d'un template
56
- dev Demarre le serveur de developpement
57
- build Compile le projet pour la production
58
- preview Sert le resultat de la compilation
54
+ ${colors.bold("Commands")}
55
+ create [name] Create a project from a template
56
+ dev Start the development server
57
+ build Build the project for production
58
+ preview Serve the result of the build
59
59
 
60
- ${colors.bold("Registre de composants")}
61
- init Prepare le projet a recevoir des composants
62
- add <nom...> Copie un composant et ses dependances
63
- list Affiche le catalogue
64
- diff Compare l'installe a ce que le registre sert
65
- doctor Verifie que le projet est en etat
60
+ ${colors.bold("Component registry")}
61
+ init Prepare the project to receive components
62
+ add <name...> Copy a component and its dependencies
63
+ list Show the catalogue
64
+ diff Compare what is installed to what the registry serves
65
+ doctor Check that the project is in working order
66
66
 
67
- ${colors.bold("Base de donnees")}
68
- db:login Enregistre un jeton de plateforme
69
- db:status Liste les bases du projet
70
- db:create Provisionne une base et ecrit .env
71
- db:branch Cree une previsualisation par branche
72
- ${colors.dim("Ces commandes demandent @odoro-cli/cloud-sdk, installe a part :")}
73
- ${colors.dim("il ne vient pas avec, ce binaire etant telecharge a chaque")}
74
- ${colors.dim("creation de projet.")}
67
+ ${colors.bold("Database")}
68
+ db:login Record a platform token
69
+ db:status List the databases of the project
70
+ db:create Provision a database and write .env
71
+ db:branch Create a per-branch preview
72
+ ${colors.dim("These commands need @odoro-cli/cloud-sdk, installed separately:")}
73
+ ${colors.dim("it does not ship with this binary, which is downloaded on")}
74
+ ${colors.dim("every project creation.")}
75
75
 
76
- ${colors.bold("Options du registre")}
77
- --registry <src> URL ou dossier local, au lieu de celui du projet
78
- --yes N'attend aucune confirmation
76
+ ${colors.bold("Registry options")}
77
+ --registry <src> URL or local directory, instead of the project one
78
+ --yes Waits for no confirmation
79
79
 
80
- ${colors.bold("Options de create")}
81
- --template <nom> Template a utiliser
82
- --modules <liste> libs,router,icons,engine,registre \u2014 ou "aucun"
83
- --pm <nom> Gestionnaire de paquets (pnpm, npm, yarn, bun)
84
- --no-git N'initialise pas de depot git
85
- --no-install N'installe pas les dependances
86
- --overwrite Vide le dossier cible avant de creer
87
- --merge Ecrit par-dessus le contenu existant
88
- --yes Accepte toutes les valeurs par defaut
80
+ ${colors.bold("create options")}
81
+ --template <name> Template to use
82
+ --modules <list> libs,router,icons,engine,registre \u2014 or "none"
83
+ --pm <name> Package manager (pnpm, npm, yarn, bun)
84
+ --no-git Does not initialise a git repository
85
+ --no-install Does not install the dependencies
86
+ --overwrite Empties the target directory before creating
87
+ --merge Writes over the existing content
88
+ --yes Accepts every default value
89
89
 
90
- ${colors.bold("Options de base de donnees")}
91
- --env <nom> Environnement vise (production, staging, preview-42)
92
- --from <env> Environnement dont brancher
93
- --name <nom> Nom de la branche
94
- --api <url> Racine de l'API, au lieu de celle par defaut
90
+ ${colors.bold("Database options")}
91
+ --env <name> Target environment (production, staging, preview-42)
92
+ --region <name> Where the database lives; asked when absent
93
+ --from <env> Environment to branch from
94
+ --name <name> Name of the branch
95
+ --api <url> Root of the API, instead of the default one
95
96
 
96
- ${colors.bold("Options de dev et preview")}
97
- --port <numero> Port d'ecoute
98
- --host <adresse> Interface d'ecoute
97
+ ${colors.bold("dev and preview options")}
98
+ --port <number> Port to listen on
99
+ --host <address> Interface to listen on
100
+ --strict-port Fails if the port is taken, instead of sliding
101
+ --open Opens the browser on startup
99
102
 
100
- ${colors.bold("Options de build")}
101
- --outdir <chemin> Dossier de sortie
102
- --no-minify Ne minifie pas
103
- --no-sourcemap N'emet pas de cartes de source
103
+ ${colors.bold("build options")}
104
+ --outdir <path> Output directory
105
+ --no-minify Does not minify
106
+ --no-sourcemap Does not emit source maps
107
+ --no-manifest Does not write manifest.json
108
+ --no-preload Does not declare the chunks as modulepreload
109
+ --prerender [r,r] Renders the routes to HTML (default: those of the entry)
104
110
 
105
- ${colors.bold("Options generales")}
106
- --root <chemin> Racine du projet
107
- -h, --help Affiche cette aide
108
- -v, --version Affiche la version
111
+ ${colors.bold("General options")}
112
+ --root <path> Project root
113
+ --mode <name> Mode: chooses the .env files read and fills import.meta.env.MODE
114
+ -h, --help Show this help
115
+ -v, --version Show the version
109
116
  `;
110
117
  function numberFlag(flags, name) {
111
118
  const value = flags[name];
@@ -118,11 +125,22 @@ function overridesFrom(flags) {
118
125
  const port = numberFlag(flags, "port");
119
126
  if (port !== void 0) server.port = port;
120
127
  if (typeof flags["host"] === "string") server.host = flags["host"];
128
+ if (flags["strict-port"] === true) server.strictPort = true;
129
+ if (flags["open"] === true) server.open = true;
121
130
  const build = {};
122
131
  if (typeof flags["outdir"] === "string") build.outDir = flags["outdir"];
123
132
  if (flags["minify"] === false) build.minify = false;
124
133
  if (flags["sourcemap"] === false) build.sourcemap = false;
125
- return { server, build };
134
+ if (flags["manifest"] === false) build.manifest = false;
135
+ if (flags["preload"] === false) build.preload = false;
136
+ const prerender = flags["prerender"];
137
+ if (prerender === true) build.prerender = true;
138
+ else if (typeof prerender === "string") {
139
+ build.prerender = prerender.split(",").map((route) => route.trim()).filter((route) => route !== "");
140
+ }
141
+ const overrides = { server, build };
142
+ if (typeof flags["mode"] === "string") overrides.mode = flags["mode"];
143
+ return overrides;
126
144
  }
127
145
  function rootFrom(flags, positional) {
128
146
  if (typeof flags["root"] === "string") return flags["root"];
@@ -131,7 +149,7 @@ function rootFrom(flags, positional) {
131
149
  async function run(argv) {
132
150
  const { command, positional, flags } = parseArgs(argv);
133
151
  if (flags["version"] === true) {
134
- const manifest = await import('./package-EIDLKAA6.js');
152
+ const manifest = await import('./package-3ZJOEXM4.js');
135
153
  console.log(manifest.default.version);
136
154
  return 0;
137
155
  }
@@ -142,7 +160,7 @@ async function run(argv) {
142
160
  switch (command) {
143
161
  case "create":
144
162
  case "new": {
145
- const { createCommand } = await import('./create-CYVSVDAD.js');
163
+ const { createCommand } = await import('./create-B2TLV6XI.js');
146
164
  const options = {};
147
165
  if (positional[0] !== void 0) options.name = positional[0];
148
166
  if (typeof flags["template"] === "string") options.template = flags["template"];
@@ -156,20 +174,24 @@ async function run(argv) {
156
174
  return createCommand(options);
157
175
  }
158
176
  case "dev": {
159
- const { startDevServer } = await import('./server-4UGN3SFS.js');
160
- const config = await loadConfig(rootFrom(flags, positional), overridesFrom(flags));
177
+ const { startDevServer } = await import('./server-ZB3P3EGS.js');
178
+ const config = await loadConfig(
179
+ rootFrom(flags, positional),
180
+ overridesFrom(flags),
181
+ "development"
182
+ );
161
183
  await startDevServer(config);
162
184
  return new Promise(() => void 0);
163
185
  }
164
186
  case "build": {
165
- const { buildProject, reportBuild } = await import('./build-JFQHODAT.js');
187
+ const { buildProject, reportBuild } = await import('./build-XJIP4GNT.js');
166
188
  const config = await loadConfig(rootFrom(flags, positional), overridesFrom(flags));
167
189
  const output = await buildProject(config);
168
190
  reportBuild(output, process.cwd());
169
191
  return 0;
170
192
  }
171
193
  case "preview": {
172
- const { startPreviewServer } = await import('./preview-7DKEAQOQ.js');
194
+ const { startPreviewServer } = await import('./preview-3IRG7MHV.js');
173
195
  const config = await loadConfig(rootFrom(flags, positional), overridesFrom(flags));
174
196
  const port = numberFlag(flags, "port");
175
197
  await startPreviewServer(config, port);
@@ -180,7 +202,7 @@ async function run(argv) {
180
202
  case "list":
181
203
  case "diff":
182
204
  case "doctor": {
183
- const registry = await import('./commands-AHMXBWQQ.js');
205
+ const registry = await import('./commands-GYA7NTCX.js');
184
206
  const options = {
185
207
  root: typeof flags["root"] === "string" ? flags["root"] : process.cwd(),
186
208
  registry: typeof flags["registry"] === "string" ? flags["registry"] : void 0,
@@ -196,11 +218,12 @@ async function run(argv) {
196
218
  case "db:status":
197
219
  case "db:create":
198
220
  case "db:branch": {
199
- const db = await import('./commands-4JRBD55Z.js');
221
+ const db = await import('./commands-UOWN3IK4.js');
200
222
  const options = {
201
223
  root: typeof flags["root"] === "string" ? flags["root"] : process.cwd(),
202
224
  ...typeof flags["api"] === "string" ? { apiUrl: flags["api"] } : {},
203
225
  ...typeof flags["env"] === "string" ? { env: flags["env"] } : {},
226
+ ...typeof flags["region"] === "string" ? { region: flags["region"] } : {},
204
227
  yes: flags["yes"] === true
205
228
  };
206
229
  if (command === "db:login") return db.loginCommand(options);
@@ -213,7 +236,7 @@ async function run(argv) {
213
236
  });
214
237
  }
215
238
  default:
216
- error(`Commande inconnue : "${command}". Essayez "odoro help".`);
239
+ error(`Unknown command: "${command}". Try "odoro help".`);
217
240
  return 1;
218
241
  }
219
242
  }
@@ -230,7 +253,7 @@ if (isEntryPoint()) {
230
253
  run(process.argv.slice(2)).then((code) => {
231
254
  if (code !== 0) process.exitCode = code;
232
255
  }).catch((cause) => {
233
- error("echec de la commande", cause);
256
+ error("the command failed", cause);
234
257
  process.exitCode = 1;
235
258
  });
236
259
  }