odoro 1.0.9 → 2.0.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.
- package/README.md +94 -0
- package/client.d.ts +90 -16
- package/dist/build-LZAUDJST.js +5 -0
- package/dist/{chunk-34RGOZFA.js → chunk-4D56Z7G3.js} +49 -50
- package/dist/{chunk-JMEHF3KN.js → chunk-7ZB5MAM6.js} +4 -4
- package/dist/{chunk-LHZGX5ML.js → chunk-OMHEQVIW.js} +295 -160
- package/dist/{chunk-3SZIN6VG.js → chunk-P3DJITWE.js} +10 -10
- package/dist/{chunk-ZVL7EXJO.js → chunk-PRWVZ2SM.js} +22 -14
- package/dist/chunk-Q2KCMTB5.js +741 -0
- package/dist/chunk-QOVBLN7A.js +241 -0
- package/dist/chunk-WWTDEV4Y.js +604 -0
- package/dist/cli.d.ts +12 -13
- package/dist/cli.js +84 -63
- package/dist/{commands-4JRBD55Z.js → commands-EUGVLQWL.js} +44 -45
- package/dist/{commands-AHMXBWQQ.js → commands-GYA7NTCX.js} +124 -124
- package/dist/{create-CYVSVDAD.js → create-QX5LEWMS.js} +158 -154
- package/dist/index.d.ts +603 -151
- package/dist/index.js +6 -6
- package/dist/{package-EIDLKAA6.js → package-T4Z7OBOH.js} +5 -5
- package/dist/preview-P4WY5GEY.js +4 -0
- package/dist/registry/index.d.ts +75 -76
- package/dist/registry/index.js +1 -1
- package/dist/{server-4UGN3SFS.js → server-2WP562EV.js} +3 -3
- package/package.json +5 -5
- package/templates/react-ts/README.md +71 -35
- package/templates/react-ts/_env.example +9 -0
- package/templates/react-ts/_variants/with-engine/src/background.tsx +118 -0
- package/templates/react-ts/_variants/without-libs/src/App.tsx +380 -0
- package/templates/react-ts/_variants/without-libs/src/background.tsx +24 -0
- package/templates/react-ts/_variants/without-libs/src/entry-server.tsx +39 -0
- package/templates/react-ts/_variants/without-libs/src/main.tsx +26 -0
- package/templates/{react-ts-server/_variantes/sans-libs/client → react-ts/_variants/without-libs}/src/styles.css +137 -137
- package/templates/react-ts/{_variantes/sans-routeur → _variants/without-router}/src/App.tsx +141 -141
- package/templates/react-ts/_variants/without-router/src/entry-server.tsx +39 -0
- package/templates/react-ts/index.html +4 -4
- package/templates/react-ts/odoro.config.ts +5 -0
- package/templates/react-ts/src/App.tsx +219 -209
- package/templates/react-ts/src/background.tsx +66 -0
- package/templates/react-ts/src/entry-server.tsx +85 -0
- package/templates/react-ts/src/main.tsx +13 -4
- package/templates/react-ts/src/router.tsx +65 -45
- package/templates/react-ts/src/styles.css +5 -5
- package/templates/react-ts-server/Dockerfile +9 -9
- package/templates/react-ts-server/README.md +97 -45
- package/templates/react-ts-server/_env.example +31 -33
- package/templates/react-ts-server/_variants/with-engine/client/src/background.tsx +118 -0
- package/templates/react-ts-server/_variants/without-libs/client/src/App.tsx +380 -0
- package/templates/react-ts-server/_variants/without-libs/client/src/background.tsx +24 -0
- package/templates/react-ts-server/_variants/without-libs/client/src/entry-server.tsx +39 -0
- package/templates/react-ts-server/_variants/without-libs/client/src/main.tsx +26 -0
- package/templates/{react-ts/_variantes/sans-libs → react-ts-server/_variants/without-libs/client}/src/styles.css +137 -137
- package/templates/react-ts-server/{_variantes/sans-routeur → _variants/without-router}/client/src/App.tsx +141 -141
- package/templates/react-ts-server/_variants/without-router/client/src/entry-server.tsx +39 -0
- package/templates/react-ts-server/client/index.html +4 -4
- package/templates/react-ts-server/client/src/App.tsx +228 -210
- package/templates/react-ts-server/client/src/account.tsx +267 -0
- package/templates/react-ts-server/client/src/auth.tsx +139 -0
- package/templates/react-ts-server/client/src/background.tsx +66 -0
- package/templates/react-ts-server/client/src/entry-server.tsx +92 -0
- package/templates/react-ts-server/client/src/main.tsx +17 -5
- package/templates/react-ts-server/client/src/router.tsx +77 -45
- package/templates/react-ts-server/client/src/styles.css +5 -5
- package/templates/react-ts-server/odoro.config.ts +7 -4
- package/templates/react-ts-server/package.json +2 -0
- package/templates/react-ts-server/scripts/dev.mjs +14 -14
- package/templates/react-ts-server/server/src/main.ts +119 -45
- package/templates/react-ts-server/server/src/modules/auth/index.ts +238 -0
- package/templates/react-ts-server/server/src/modules/auth/password.ts +122 -0
- package/templates/react-ts-server/server/src/modules/auth/store.ts +193 -0
- package/templates/react-ts-server/server/src/modules/health/index.ts +45 -46
- package/dist/build-JFQHODAT.js +0 -5
- package/dist/chunk-22KJTV2R.js +0 -380
- package/dist/chunk-DL3NPC4H.js +0 -113
- package/dist/chunk-TQUJ3MFS.js +0 -268
- package/dist/preview-7DKEAQOQ.js +0 -4
- package/templates/react-ts/_variantes/avec-moteur/src/fond.tsx +0 -118
- package/templates/react-ts/_variantes/sans-libs/src/App.tsx +0 -382
- package/templates/react-ts/_variantes/sans-libs/src/fond.tsx +0 -23
- package/templates/react-ts/_variantes/sans-libs/src/main.tsx +0 -17
- package/templates/react-ts/src/fond.tsx +0 -66
- package/templates/react-ts-server/_variantes/avec-moteur/client/src/fond.tsx +0 -118
- package/templates/react-ts-server/_variantes/sans-libs/client/src/App.tsx +0 -382
- package/templates/react-ts-server/_variantes/sans-libs/client/src/fond.tsx +0 -23
- package/templates/react-ts-server/_variantes/sans-libs/client/src/main.tsx +0 -17
- package/templates/react-ts-server/client/src/fond.tsx +0 -66
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { loadConfig } from './chunk-
|
|
2
|
+
import { loadConfig } from './chunk-QOVBLN7A.js';
|
|
3
3
|
import './chunk-T6RLHSCW.js';
|
|
4
|
-
import { error } from './chunk-
|
|
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,72 @@ function parseArgs(argv) {
|
|
|
46
46
|
return { command, positional, flags };
|
|
47
47
|
}
|
|
48
48
|
var HELP = `
|
|
49
|
-
${colors.bold(colors.magenta("odoro"))} \u2014
|
|
49
|
+
${colors.bold(colors.magenta("odoro"))} \u2014 development engine and scaffolder
|
|
50
50
|
|
|
51
|
-
${colors.bold("
|
|
52
|
-
odoro <
|
|
51
|
+
${colors.bold("Usage")}
|
|
52
|
+
odoro <command> [options]
|
|
53
53
|
|
|
54
|
-
${colors.bold("
|
|
55
|
-
create [
|
|
56
|
-
dev
|
|
57
|
-
build
|
|
58
|
-
preview
|
|
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("
|
|
61
|
-
init Prepare
|
|
62
|
-
add <
|
|
63
|
-
list
|
|
64
|
-
diff Compare
|
|
65
|
-
doctor
|
|
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("
|
|
68
|
-
db:login
|
|
69
|
-
db:status
|
|
70
|
-
db:create
|
|
71
|
-
db:branch
|
|
72
|
-
${colors.dim("
|
|
73
|
-
${colors.dim("
|
|
74
|
-
${colors.dim("
|
|
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("
|
|
77
|
-
--registry <src> URL
|
|
78
|
-
--yes
|
|
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("
|
|
81
|
-
--template <
|
|
82
|
-
--modules <
|
|
83
|
-
--pm <
|
|
84
|
-
--no-git
|
|
85
|
-
--no-install
|
|
86
|
-
--overwrite
|
|
87
|
-
--merge
|
|
88
|
-
--yes
|
|
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("
|
|
91
|
-
--env <
|
|
92
|
-
--from <env>
|
|
93
|
-
--name <
|
|
94
|
-
--api <url>
|
|
90
|
+
${colors.bold("Database options")}
|
|
91
|
+
--env <name> Target environment (production, staging, preview-42)
|
|
92
|
+
--from <env> Environment to branch from
|
|
93
|
+
--name <name> Name of the branch
|
|
94
|
+
--api <url> Root of the API, instead of the default one
|
|
95
95
|
|
|
96
|
-
${colors.bold("
|
|
97
|
-
--port <
|
|
98
|
-
--host <
|
|
96
|
+
${colors.bold("dev and preview options")}
|
|
97
|
+
--port <number> Port to listen on
|
|
98
|
+
--host <address> Interface to listen on
|
|
99
|
+
--strict-port Fails if the port is taken, instead of sliding
|
|
100
|
+
--open Opens the browser on startup
|
|
99
101
|
|
|
100
|
-
${colors.bold("
|
|
101
|
-
--outdir <
|
|
102
|
-
--no-minify
|
|
103
|
-
--no-sourcemap
|
|
102
|
+
${colors.bold("build options")}
|
|
103
|
+
--outdir <path> Output directory
|
|
104
|
+
--no-minify Does not minify
|
|
105
|
+
--no-sourcemap Does not emit source maps
|
|
106
|
+
--no-manifest Does not write manifest.json
|
|
107
|
+
--no-preload Does not declare the chunks as modulepreload
|
|
108
|
+
--prerender [r,r] Renders the routes to HTML (default: those of the entry)
|
|
104
109
|
|
|
105
|
-
${colors.bold("
|
|
106
|
-
--root <
|
|
107
|
-
|
|
108
|
-
-
|
|
110
|
+
${colors.bold("General options")}
|
|
111
|
+
--root <path> Project root
|
|
112
|
+
--mode <name> Mode: chooses the .env files read and fills import.meta.env.MODE
|
|
113
|
+
-h, --help Show this help
|
|
114
|
+
-v, --version Show the version
|
|
109
115
|
`;
|
|
110
116
|
function numberFlag(flags, name) {
|
|
111
117
|
const value = flags[name];
|
|
@@ -118,11 +124,22 @@ function overridesFrom(flags) {
|
|
|
118
124
|
const port = numberFlag(flags, "port");
|
|
119
125
|
if (port !== void 0) server.port = port;
|
|
120
126
|
if (typeof flags["host"] === "string") server.host = flags["host"];
|
|
127
|
+
if (flags["strict-port"] === true) server.strictPort = true;
|
|
128
|
+
if (flags["open"] === true) server.open = true;
|
|
121
129
|
const build = {};
|
|
122
130
|
if (typeof flags["outdir"] === "string") build.outDir = flags["outdir"];
|
|
123
131
|
if (flags["minify"] === false) build.minify = false;
|
|
124
132
|
if (flags["sourcemap"] === false) build.sourcemap = false;
|
|
125
|
-
|
|
133
|
+
if (flags["manifest"] === false) build.manifest = false;
|
|
134
|
+
if (flags["preload"] === false) build.preload = false;
|
|
135
|
+
const prerender = flags["prerender"];
|
|
136
|
+
if (prerender === true) build.prerender = true;
|
|
137
|
+
else if (typeof prerender === "string") {
|
|
138
|
+
build.prerender = prerender.split(",").map((route) => route.trim()).filter((route) => route !== "");
|
|
139
|
+
}
|
|
140
|
+
const overrides = { server, build };
|
|
141
|
+
if (typeof flags["mode"] === "string") overrides.mode = flags["mode"];
|
|
142
|
+
return overrides;
|
|
126
143
|
}
|
|
127
144
|
function rootFrom(flags, positional) {
|
|
128
145
|
if (typeof flags["root"] === "string") return flags["root"];
|
|
@@ -131,7 +148,7 @@ function rootFrom(flags, positional) {
|
|
|
131
148
|
async function run(argv) {
|
|
132
149
|
const { command, positional, flags } = parseArgs(argv);
|
|
133
150
|
if (flags["version"] === true) {
|
|
134
|
-
const manifest = await import('./package-
|
|
151
|
+
const manifest = await import('./package-T4Z7OBOH.js');
|
|
135
152
|
console.log(manifest.default.version);
|
|
136
153
|
return 0;
|
|
137
154
|
}
|
|
@@ -142,7 +159,7 @@ async function run(argv) {
|
|
|
142
159
|
switch (command) {
|
|
143
160
|
case "create":
|
|
144
161
|
case "new": {
|
|
145
|
-
const { createCommand } = await import('./create-
|
|
162
|
+
const { createCommand } = await import('./create-QX5LEWMS.js');
|
|
146
163
|
const options = {};
|
|
147
164
|
if (positional[0] !== void 0) options.name = positional[0];
|
|
148
165
|
if (typeof flags["template"] === "string") options.template = flags["template"];
|
|
@@ -156,20 +173,24 @@ async function run(argv) {
|
|
|
156
173
|
return createCommand(options);
|
|
157
174
|
}
|
|
158
175
|
case "dev": {
|
|
159
|
-
const { startDevServer } = await import('./server-
|
|
160
|
-
const config = await loadConfig(
|
|
176
|
+
const { startDevServer } = await import('./server-2WP562EV.js');
|
|
177
|
+
const config = await loadConfig(
|
|
178
|
+
rootFrom(flags, positional),
|
|
179
|
+
overridesFrom(flags),
|
|
180
|
+
"development"
|
|
181
|
+
);
|
|
161
182
|
await startDevServer(config);
|
|
162
183
|
return new Promise(() => void 0);
|
|
163
184
|
}
|
|
164
185
|
case "build": {
|
|
165
|
-
const { buildProject, reportBuild } = await import('./build-
|
|
186
|
+
const { buildProject, reportBuild } = await import('./build-LZAUDJST.js');
|
|
166
187
|
const config = await loadConfig(rootFrom(flags, positional), overridesFrom(flags));
|
|
167
188
|
const output = await buildProject(config);
|
|
168
189
|
reportBuild(output, process.cwd());
|
|
169
190
|
return 0;
|
|
170
191
|
}
|
|
171
192
|
case "preview": {
|
|
172
|
-
const { startPreviewServer } = await import('./preview-
|
|
193
|
+
const { startPreviewServer } = await import('./preview-P4WY5GEY.js');
|
|
173
194
|
const config = await loadConfig(rootFrom(flags, positional), overridesFrom(flags));
|
|
174
195
|
const port = numberFlag(flags, "port");
|
|
175
196
|
await startPreviewServer(config, port);
|
|
@@ -180,7 +201,7 @@ async function run(argv) {
|
|
|
180
201
|
case "list":
|
|
181
202
|
case "diff":
|
|
182
203
|
case "doctor": {
|
|
183
|
-
const registry = await import('./commands-
|
|
204
|
+
const registry = await import('./commands-GYA7NTCX.js');
|
|
184
205
|
const options = {
|
|
185
206
|
root: typeof flags["root"] === "string" ? flags["root"] : process.cwd(),
|
|
186
207
|
registry: typeof flags["registry"] === "string" ? flags["registry"] : void 0,
|
|
@@ -196,7 +217,7 @@ async function run(argv) {
|
|
|
196
217
|
case "db:status":
|
|
197
218
|
case "db:create":
|
|
198
219
|
case "db:branch": {
|
|
199
|
-
const db = await import('./commands-
|
|
220
|
+
const db = await import('./commands-EUGVLQWL.js');
|
|
200
221
|
const options = {
|
|
201
222
|
root: typeof flags["root"] === "string" ? flags["root"] : process.cwd(),
|
|
202
223
|
...typeof flags["api"] === "string" ? { apiUrl: flags["api"] } : {},
|
|
@@ -213,7 +234,7 @@ async function run(argv) {
|
|
|
213
234
|
});
|
|
214
235
|
}
|
|
215
236
|
default:
|
|
216
|
-
error(`
|
|
237
|
+
error(`Unknown command: "${command}". Try "odoro help".`);
|
|
217
238
|
return 1;
|
|
218
239
|
}
|
|
219
240
|
}
|
|
@@ -230,7 +251,7 @@ if (isEntryPoint()) {
|
|
|
230
251
|
run(process.argv.slice(2)).then((code) => {
|
|
231
252
|
if (code !== 0) process.exitCode = code;
|
|
232
253
|
}).catch((cause) => {
|
|
233
|
-
error("
|
|
254
|
+
error("the command failed", cause);
|
|
234
255
|
process.exitCode = 1;
|
|
235
256
|
});
|
|
236
257
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { writeDatabaseUrl, assertEnvIgnored } from './chunk-
|
|
3
|
-
import { info, success, colors, warn, error } from './chunk-
|
|
2
|
+
import { writeDatabaseUrl, assertEnvIgnored } from './chunk-P3DJITWE.js';
|
|
3
|
+
import { info, success, colors, warn, error } from './chunk-7ZB5MAM6.js';
|
|
4
4
|
import { randomBytes } from 'crypto';
|
|
5
5
|
import { readFile, mkdir, writeFile, chmod } from 'fs/promises';
|
|
6
6
|
import { platform, homedir } from 'os';
|
|
@@ -67,12 +67,12 @@ async function loadSdk() {
|
|
|
67
67
|
} catch {
|
|
68
68
|
return {
|
|
69
69
|
ok: false,
|
|
70
|
-
reason: `
|
|
70
|
+
reason: `This command needs ${SDK_PACKAGE}, which is not installed.
|
|
71
71
|
|
|
72
72
|
npm install --save-dev ${SDK_PACKAGE}
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
creation
|
|
74
|
+
It does not ship with odoro: this binary is downloaded on every
|
|
75
|
+
project creation, and most projects do not use the platform.`
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -92,12 +92,12 @@ async function connect(options) {
|
|
|
92
92
|
const token = await findToken(apiUrl);
|
|
93
93
|
if (token === void 0) {
|
|
94
94
|
error(
|
|
95
|
-
`
|
|
95
|
+
`No token for ${apiUrl}.
|
|
96
96
|
|
|
97
97
|
odoro db:login
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
integration
|
|
99
|
+
Or provide it through the ODORO_TOKEN variable, which is what a
|
|
100
|
+
continuous integration does.`
|
|
101
101
|
);
|
|
102
102
|
return void 0;
|
|
103
103
|
}
|
|
@@ -107,18 +107,18 @@ async function loginCommand(options) {
|
|
|
107
107
|
const apiUrl = options.apiUrl ?? DEFAULT_API_URL;
|
|
108
108
|
const prompts = await import('@clack/prompts');
|
|
109
109
|
const value = await prompts.password({
|
|
110
|
-
message: `
|
|
111
|
-
validate: (input) => input.startsWith("odk_") ? void 0 : "
|
|
110
|
+
message: `Token for ${apiUrl}`,
|
|
111
|
+
validate: (input) => input.startsWith("odk_") ? void 0 : "A token starts with odk_live_ or odk_test_"
|
|
112
112
|
});
|
|
113
113
|
if (prompts.isCancel(value)) {
|
|
114
|
-
info("
|
|
114
|
+
info("Cancelled.");
|
|
115
115
|
return 0;
|
|
116
116
|
}
|
|
117
117
|
const report = await storeToken(apiUrl, value);
|
|
118
|
-
success(`
|
|
118
|
+
success(`Token recorded in ${colors.dim(report.path)}`);
|
|
119
119
|
if (!report.restricted) {
|
|
120
120
|
warn(
|
|
121
|
-
"
|
|
121
|
+
"The restrictive file permissions could not be set on this system: check that this directory is neither shared nor synchronised."
|
|
122
122
|
);
|
|
123
123
|
}
|
|
124
124
|
return 0;
|
|
@@ -130,12 +130,12 @@ async function statusCommand(options) {
|
|
|
130
130
|
options.env === void 0 ? {} : { environmentId: options.env }
|
|
131
131
|
);
|
|
132
132
|
if (databases.length === 0) {
|
|
133
|
-
info("
|
|
133
|
+
info("No database. `odoro db:create` provisions one.");
|
|
134
134
|
return 0;
|
|
135
135
|
}
|
|
136
|
-
for (const
|
|
137
|
-
const
|
|
138
|
-
console.log(` ${
|
|
136
|
+
for (const database of databases) {
|
|
137
|
+
const state = database.state === "ready" ? colors.green(database.state) : database.state === "failed" || database.state === "quarantined" ? colors.red(database.state) : colors.dim(database.state);
|
|
138
|
+
console.log(` ${database.id} ${state} ${colors.dim(database.region)}`);
|
|
139
139
|
}
|
|
140
140
|
return 0;
|
|
141
141
|
}
|
|
@@ -144,25 +144,25 @@ async function createCommand(options) {
|
|
|
144
144
|
if (connection === void 0) return 1;
|
|
145
145
|
const environmentId = options.env;
|
|
146
146
|
if (environmentId === void 0) {
|
|
147
|
-
error("
|
|
147
|
+
error("Name the environment: `odoro db:create --env production`.");
|
|
148
148
|
return 1;
|
|
149
149
|
}
|
|
150
150
|
const prompts = await import('@clack/prompts');
|
|
151
151
|
const spinner = prompts.spinner();
|
|
152
|
-
spinner.start("
|
|
152
|
+
spinner.start("Provisioning");
|
|
153
153
|
const abort = new AbortController();
|
|
154
154
|
const onInterrupt = () => abort.abort();
|
|
155
155
|
process.once("SIGINT", onInterrupt);
|
|
156
156
|
try {
|
|
157
|
-
const
|
|
157
|
+
const finished = await connection.client.databases.createAndWait(
|
|
158
158
|
{ idempotencyKey: idempotencyKey(), environmentId, region: "eu-central-1" },
|
|
159
159
|
{ signal: abort.signal }
|
|
160
160
|
);
|
|
161
|
-
spinner.stop("
|
|
162
|
-
const databaseId =
|
|
161
|
+
spinner.stop("Database provisioned");
|
|
162
|
+
const databaseId = finished.subject;
|
|
163
163
|
if (databaseId === void 0) {
|
|
164
164
|
warn(
|
|
165
|
-
"
|
|
165
|
+
"The operation succeeded without naming the created database. `odoro db:status` will show it."
|
|
166
166
|
);
|
|
167
167
|
return 0;
|
|
168
168
|
}
|
|
@@ -170,15 +170,15 @@ async function createCommand(options) {
|
|
|
170
170
|
databaseId
|
|
171
171
|
});
|
|
172
172
|
await writeDatabaseUrl(options.root, connectionString);
|
|
173
|
-
success("DATABASE_URL
|
|
174
|
-
const
|
|
175
|
-
if (
|
|
173
|
+
success("DATABASE_URL written to .env");
|
|
174
|
+
const risk = await assertEnvIgnored(options.root);
|
|
175
|
+
if (risk !== void 0) warn(risk);
|
|
176
176
|
return 0;
|
|
177
177
|
} catch (cause) {
|
|
178
|
-
spinner.stop("
|
|
178
|
+
spinner.stop("Provisioning interrupted");
|
|
179
179
|
if (abort.signal.aborted) {
|
|
180
180
|
info(
|
|
181
|
-
"
|
|
181
|
+
"Wait abandoned. The provisioning carries on: `odoro db:status` will show its outcome."
|
|
182
182
|
);
|
|
183
183
|
return 0;
|
|
184
184
|
}
|
|
@@ -192,27 +192,26 @@ async function branchCommand(options) {
|
|
|
192
192
|
const connection = await connect(options);
|
|
193
193
|
if (connection === void 0) return 1;
|
|
194
194
|
if (options.from === void 0 || options.name === void 0) {
|
|
195
|
-
error("Usage
|
|
195
|
+
error("Usage: `odoro db:branch --from production --name preview-42`");
|
|
196
196
|
return 1;
|
|
197
197
|
}
|
|
198
198
|
const prompts = await import('@clack/prompts');
|
|
199
199
|
const spinner = prompts.spinner();
|
|
200
|
-
spinner.start(`
|
|
200
|
+
spinner.start(`Branching from ${options.from}`);
|
|
201
201
|
try {
|
|
202
|
-
const
|
|
202
|
+
const finished = await connection.client.databases.branchAndWait({
|
|
203
203
|
idempotencyKey: idempotencyKey(),
|
|
204
204
|
parentEnvironmentId: options.from,
|
|
205
205
|
name: options.name,
|
|
206
|
-
//
|
|
207
|
-
// place
|
|
208
|
-
// aucune.
|
|
206
|
+
// Without a declared rule, the platform refuses. We do not guess in its
|
|
207
|
+
// place: a rule invented here would anonymise the wrong column, or none.
|
|
209
208
|
anonymization: []
|
|
210
209
|
});
|
|
211
|
-
spinner.stop("
|
|
212
|
-
info(`
|
|
210
|
+
spinner.stop("Branch created");
|
|
211
|
+
info(`Database: ${finished.subject ?? "see odoro db:status"}`);
|
|
213
212
|
return 0;
|
|
214
213
|
} catch (cause) {
|
|
215
|
-
spinner.stop("
|
|
214
|
+
spinner.stop("Branch refused");
|
|
216
215
|
error(describe(cause, connection.sdk));
|
|
217
216
|
return 1;
|
|
218
217
|
}
|
|
@@ -221,25 +220,25 @@ function describe(cause, sdk) {
|
|
|
221
220
|
if (sdk.isApiError(cause, "VALIDATION")) {
|
|
222
221
|
const errors = cause.options?.errors;
|
|
223
222
|
return [
|
|
224
|
-
"
|
|
223
|
+
"The request was refused:",
|
|
225
224
|
...(errors ?? []).map(({ field, message }) => ` ${field} \u2014 ${message}`)
|
|
226
225
|
].join("\n");
|
|
227
226
|
}
|
|
228
227
|
if (sdk.isApiError(cause, "RATE_LIMIT")) {
|
|
229
|
-
return "
|
|
228
|
+
return "Too many requests. The routes that provision are deliberately rate limited: every creation costs.";
|
|
230
229
|
}
|
|
231
230
|
if (sdk.isApiError(cause, "UNAUTHORIZED")) {
|
|
232
|
-
return `
|
|
231
|
+
return `Token refused. \`odoro db:login\` records another one.`;
|
|
233
232
|
}
|
|
234
233
|
return cause instanceof Error ? cause.message : String(cause);
|
|
235
234
|
}
|
|
236
235
|
var DB_HELP = [
|
|
237
|
-
" db:login
|
|
238
|
-
" db:status
|
|
239
|
-
" db:create --env <e>
|
|
236
|
+
" db:login Record a platform token",
|
|
237
|
+
" db:status List the databases of the project",
|
|
238
|
+
" db:create --env <e> Provision a database and write .env",
|
|
240
239
|
" db:branch --from <e> --name <n>",
|
|
241
|
-
"
|
|
242
|
-
` (
|
|
240
|
+
" Create a per-branch preview",
|
|
241
|
+
` (requires ${SDK_PACKAGE})`
|
|
243
242
|
].join("\n");
|
|
244
243
|
|
|
245
244
|
export { DB_HELP, branchCommand, createCommand, loginCommand, statusCommand };
|