clefbase 2.0.0 → 2.0.2
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/dist/app.d.ts +6 -26
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +12 -31
- package/dist/app.js.map +1 -1
- package/dist/auth/index.d.ts +63 -114
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +97 -176
- package/dist/auth/index.js.map +1 -1
- package/dist/cli-src/cli/api.js +14 -14
- package/dist/cli-src/cli/commands/deploy.js +84 -16
- package/dist/cli-src/cli/commands/init.js +644 -19
- package/dist/cli-src/cli/config.js +0 -1
- package/dist/cli-src/cli/index.js +48 -9
- package/dist/cli.js +756 -58
- package/dist/hosting/index.d.ts +8 -98
- package/dist/hosting/index.d.ts.map +1 -1
- package/dist/hosting/index.js +37 -95
- package/dist/hosting/index.js.map +1 -1
- package/dist/index.d.ts +14 -60
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -65
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +0 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,12 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.runDeploy = runDeploy;
|
|
7
|
+
exports.runHostingDeploy = runHostingDeploy;
|
|
8
|
+
exports.runFunctionsDeploy = runFunctionsDeploy;
|
|
7
9
|
exports.runHostingInit = runHostingInit;
|
|
8
10
|
exports.runStatus = runStatus;
|
|
9
11
|
exports.runDnsStatus = runDnsStatus;
|
|
10
12
|
exports.runDnsReprovision = runDnsReprovision;
|
|
11
13
|
const path_1 = __importDefault(require("path"));
|
|
12
14
|
const fs_1 = __importDefault(require("fs"));
|
|
15
|
+
const child_process_1 = require("child_process");
|
|
13
16
|
const chalk_1 = __importDefault(require("chalk"));
|
|
14
17
|
const ora_1 = __importDefault(require("ora"));
|
|
15
18
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
@@ -70,17 +73,62 @@ function fmtBytes(n) {
|
|
|
70
73
|
function siteUrl(site) {
|
|
71
74
|
return site.customDomain ? `https://${site.customDomain}` : site.previewUrl;
|
|
72
75
|
}
|
|
73
|
-
// ─── deploy
|
|
76
|
+
// ─── deploy (combined: hosting + functions, or --only one) ────────────────────
|
|
74
77
|
async function runDeploy(opts) {
|
|
75
78
|
const cwd = opts.cwd ?? process.cwd();
|
|
76
79
|
const cfg = (0, config_1.requireConfig)(cwd);
|
|
80
|
+
const deployHosting = !opts.only || opts.only === "hosting";
|
|
81
|
+
const deployFunctions = !opts.only || opts.only === "functions";
|
|
82
|
+
// Guard: make sure at least one of the requested targets is enabled
|
|
83
|
+
if (deployHosting && !cfg.services.hosting && opts.only === "hosting") {
|
|
84
|
+
console.error(chalk_1.default.red("\n Hosting is not enabled for this project.\n Run `clefbase hosting:init` to set it up.\n"));
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
if (deployFunctions && !cfg.services.functions && opts.only === "functions") {
|
|
88
|
+
console.error(chalk_1.default.red("\n Functions is not enabled for this project.\n Run `clefbase init` and enable Functions to set it up.\n"));
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
77
91
|
console.log();
|
|
78
|
-
|
|
92
|
+
if (opts.only === "hosting") {
|
|
93
|
+
console.log(chalk_1.default.bold.cyan(" Clefbase Deploy · Hosting"));
|
|
94
|
+
}
|
|
95
|
+
else if (opts.only === "functions") {
|
|
96
|
+
console.log(chalk_1.default.bold.cyan(" Clefbase Deploy · Functions"));
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
console.log(chalk_1.default.bold.cyan(" Clefbase Deploy"));
|
|
100
|
+
}
|
|
79
101
|
console.log();
|
|
102
|
+
// ── Functions first (fast, no file scanning) ──────────────────────────────
|
|
103
|
+
if (deployFunctions && cfg.services.functions) {
|
|
104
|
+
await runFunctionsDeploy({ cwd });
|
|
105
|
+
if (deployHosting && cfg.services.hosting) {
|
|
106
|
+
console.log();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// ── Hosting ───────────────────────────────────────────────────────────────
|
|
110
|
+
if (deployHosting && cfg.services.hosting) {
|
|
111
|
+
await runHostingDeploy({ dir: opts.dir, message: opts.message, site: opts.site, cwd });
|
|
112
|
+
}
|
|
113
|
+
// ── Nothing to do ─────────────────────────────────────────────────────────
|
|
114
|
+
if (!deployHosting && !deployFunctions) {
|
|
115
|
+
console.log(chalk_1.default.yellow(" Nothing to deploy — no services matched.\n"));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// ─── deploy:hosting ───────────────────────────────────────────────────────────
|
|
119
|
+
//
|
|
120
|
+
// Can be called standalone (clefbase deploy:hosting) or from runDeploy above.
|
|
121
|
+
async function runHostingDeploy(opts) {
|
|
122
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
123
|
+
const cfg = (0, config_1.requireConfig)(cwd);
|
|
124
|
+
if (!cfg.services.hosting) {
|
|
125
|
+
console.error(chalk_1.default.red("\n Hosting is not enabled for this project.\n Run `clefbase hosting:init` to set it up.\n"));
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
80
128
|
// ── Resolve / pick a site ─────────────────────────────────────────────────
|
|
81
129
|
let siteId = opts.site ?? cfg.hosting?.siteId ?? "";
|
|
82
130
|
let siteName = cfg.hosting?.siteName ?? "";
|
|
83
|
-
let previewUrl = "";
|
|
131
|
+
let previewUrl = cfg.hosting?.previewUrl ?? "";
|
|
84
132
|
if (!siteId) {
|
|
85
133
|
const site = await pickOrCreateSite(cfg);
|
|
86
134
|
siteId = site.id;
|
|
@@ -95,9 +143,6 @@ async function runDeploy(opts) {
|
|
|
95
143
|
};
|
|
96
144
|
(0, config_1.saveConfig)(cfg, cwd);
|
|
97
145
|
}
|
|
98
|
-
else {
|
|
99
|
-
previewUrl = cfg.hosting?.previewUrl ?? "";
|
|
100
|
-
}
|
|
101
146
|
// ── Resolve dist dir ──────────────────────────────────────────────────────
|
|
102
147
|
const distDir = opts.dir ?? cfg.hosting?.distDir ?? await promptDistDir(cwd);
|
|
103
148
|
const absDir = path_1.default.isAbsolute(distDir) ? distDir : path_1.default.join(cwd, distDir);
|
|
@@ -184,6 +229,39 @@ async function runDeploy(opts) {
|
|
|
184
229
|
}
|
|
185
230
|
console.log();
|
|
186
231
|
}
|
|
232
|
+
// ─── deploy:functions ─────────────────────────────────────────────────────────
|
|
233
|
+
//
|
|
234
|
+
// Runs `node functions/deploy.mjs` from the project root.
|
|
235
|
+
// Can be called standalone (clefbase deploy:functions) or from runDeploy above.
|
|
236
|
+
async function runFunctionsDeploy(opts = {}) {
|
|
237
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
238
|
+
const cfg = (0, config_1.requireConfig)(cwd);
|
|
239
|
+
if (!cfg.services.functions) {
|
|
240
|
+
console.error(chalk_1.default.red("\n Functions is not enabled for this project.\n Run `clefbase init` and enable Functions.\n"));
|
|
241
|
+
process.exit(1);
|
|
242
|
+
}
|
|
243
|
+
const deployMjs = path_1.default.join(cwd, "functions", "deploy.mjs");
|
|
244
|
+
if (!fs_1.default.existsSync(deployMjs)) {
|
|
245
|
+
console.error(chalk_1.default.red(`\n ✗ functions/deploy.mjs not found.`));
|
|
246
|
+
console.error(chalk_1.default.dim(" Re-run `clefbase init` to regenerate the functions/ folder,"));
|
|
247
|
+
console.error(chalk_1.default.dim(" or deploy individual functions with:"));
|
|
248
|
+
console.error(chalk_1.default.cyan(" clefbase functions:deploy -f functions/src/hello.ts --name hello --trigger http\n"));
|
|
249
|
+
process.exit(1);
|
|
250
|
+
}
|
|
251
|
+
console.log(chalk_1.default.bold(" Deploying functions…"));
|
|
252
|
+
console.log(chalk_1.default.dim(` Running: node functions/deploy.mjs\n`));
|
|
253
|
+
try {
|
|
254
|
+
(0, child_process_1.execSync)("node deploy.mjs", {
|
|
255
|
+
cwd: path_1.default.join(cwd, "functions"),
|
|
256
|
+
stdio: "inherit",
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
catch {
|
|
260
|
+
// execSync throws on non-zero exit — deploy.mjs already printed the details
|
|
261
|
+
console.error(chalk_1.default.red("\n ✗ One or more functions failed to deploy.\n"));
|
|
262
|
+
process.exit(1);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
187
265
|
// ─── hosting:init ─────────────────────────────────────────────────────────────
|
|
188
266
|
async function runHostingInit(cwd = process.cwd()) {
|
|
189
267
|
const cfg = (0, config_1.requireConfig)(cwd);
|
|
@@ -270,7 +348,6 @@ async function runDnsStatus(cwd = process.cwd()) {
|
|
|
270
348
|
const dns = await (0, api_1.getDnsStatus)(cfg, cfg.hosting.siteId);
|
|
271
349
|
sp.succeed("DNS checked");
|
|
272
350
|
console.log();
|
|
273
|
-
// Preview subdomain
|
|
274
351
|
console.log(` ${chalk_1.default.bold("Preview subdomain:")}`);
|
|
275
352
|
console.log(` URL: ${chalk_1.default.cyan(dns.previewUrl)}`);
|
|
276
353
|
if (dns.preview.isCorrect) {
|
|
@@ -284,7 +361,6 @@ async function runDnsStatus(cwd = process.cwd()) {
|
|
|
284
361
|
console.log(` DNS: ${chalk_1.default.yellow("⚠ Not yet provisioned")}`);
|
|
285
362
|
console.log(chalk_1.default.dim(" Run `clefbase hosting:dns:reprovision` to create the record."));
|
|
286
363
|
}
|
|
287
|
-
// Custom domain
|
|
288
364
|
if (dns.customDomain) {
|
|
289
365
|
console.log();
|
|
290
366
|
console.log(` ${chalk_1.default.bold("Custom domain:")}`);
|
|
@@ -331,11 +407,6 @@ async function runDnsReprovision(cwd = process.cwd()) {
|
|
|
331
407
|
console.log();
|
|
332
408
|
}
|
|
333
409
|
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
334
|
-
/**
|
|
335
|
-
* Interactive site picker / creator.
|
|
336
|
-
* Shows existing sites, allows creating a new one.
|
|
337
|
-
* On creation: enforces uniqueness, shows preview URL.
|
|
338
|
-
*/
|
|
339
410
|
async function pickOrCreateSite(cfg) {
|
|
340
411
|
const sp = (0, ora_1.default)("Fetching sites…").start();
|
|
341
412
|
let sites = [];
|
|
@@ -365,7 +436,6 @@ async function pickOrCreateSite(cfg) {
|
|
|
365
436
|
}
|
|
366
437
|
return createSiteInteractive(cfg);
|
|
367
438
|
}
|
|
368
|
-
/** Prompt for a new site name, handle conflict errors with retry. */
|
|
369
439
|
async function createSiteInteractive(cfg) {
|
|
370
440
|
while (true) {
|
|
371
441
|
const { name } = await inquirer_1.default.prompt([{
|
|
@@ -384,11 +454,9 @@ async function createSiteInteractive(cfg) {
|
|
|
384
454
|
}
|
|
385
455
|
catch (err) {
|
|
386
456
|
const message = err.message;
|
|
387
|
-
// 409 conflict — name already taken
|
|
388
457
|
if (message.toLowerCase().includes("already exists") || message.includes("409")) {
|
|
389
458
|
s.fail(chalk_1.default.red(message));
|
|
390
459
|
console.log(chalk_1.default.dim(" Please choose a different name.\n"));
|
|
391
|
-
// Loop to prompt again
|
|
392
460
|
}
|
|
393
461
|
else {
|
|
394
462
|
s.fail(message);
|