@base44-preview/cli 0.0.54-pr.538.e94d5b7 → 0.0.54-pr.539.1da48ad
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/cli/index.js +72 -102
- package/dist/cli/index.js.map +12 -12
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -235154,24 +235154,39 @@ function getTestOverrides() {
|
|
|
235154
235154
|
// src/core/auth/config.ts
|
|
235155
235155
|
var TOKEN_REFRESH_BUFFER_MS = 60 * 1000;
|
|
235156
235156
|
var refreshPromise = null;
|
|
235157
|
-
function
|
|
235157
|
+
function decodeJwtClaims(token) {
|
|
235158
|
+
const parts = token.split(".");
|
|
235159
|
+
if (parts.length !== 3) {
|
|
235160
|
+
return null;
|
|
235161
|
+
}
|
|
235162
|
+
try {
|
|
235163
|
+
return JSON.parse(Buffer.from(parts[1], "base64url").toString("utf8"));
|
|
235164
|
+
} catch {
|
|
235165
|
+
return null;
|
|
235166
|
+
}
|
|
235167
|
+
}
|
|
235168
|
+
async function seedAuthFromEnv() {
|
|
235158
235169
|
const accessToken = process.env.BASE44_ACCESS_TOKEN;
|
|
235159
235170
|
if (!accessToken) {
|
|
235160
|
-
return
|
|
235171
|
+
return false;
|
|
235161
235172
|
}
|
|
235162
|
-
|
|
235173
|
+
const refreshToken = process.env.BASE44_REFRESH_TOKEN;
|
|
235174
|
+
const claims = decodeJwtClaims(accessToken);
|
|
235175
|
+
const sub = typeof claims?.sub === "string" ? claims.sub : undefined;
|
|
235176
|
+
const exp = typeof claims?.exp === "number" ? claims.exp : undefined;
|
|
235177
|
+
if (!refreshToken || !sub || !exp) {
|
|
235178
|
+
return false;
|
|
235179
|
+
}
|
|
235180
|
+
await writeAuth({
|
|
235163
235181
|
accessToken,
|
|
235164
|
-
refreshToken
|
|
235165
|
-
expiresAt:
|
|
235166
|
-
email:
|
|
235167
|
-
name:
|
|
235168
|
-
};
|
|
235182
|
+
refreshToken,
|
|
235183
|
+
expiresAt: exp * 1000,
|
|
235184
|
+
email: sub,
|
|
235185
|
+
name: sub
|
|
235186
|
+
});
|
|
235187
|
+
return true;
|
|
235169
235188
|
}
|
|
235170
235189
|
async function readAuth() {
|
|
235171
|
-
const envAuth = readEnvAuth();
|
|
235172
|
-
if (envAuth) {
|
|
235173
|
-
return envAuth;
|
|
235174
|
-
}
|
|
235175
235190
|
try {
|
|
235176
235191
|
const authData = await readJsonFile(getAuthFilePath());
|
|
235177
235192
|
const result = AuthDataSchema.safeParse(authData);
|
|
@@ -235208,9 +235223,6 @@ function isTokenExpired(auth) {
|
|
|
235208
235223
|
return Date.now() >= auth.expiresAt - TOKEN_REFRESH_BUFFER_MS;
|
|
235209
235224
|
}
|
|
235210
235225
|
async function refreshAndSaveTokens() {
|
|
235211
|
-
if (readEnvAuth()) {
|
|
235212
|
-
return null;
|
|
235213
|
-
}
|
|
235214
235226
|
if (refreshPromise) {
|
|
235215
235227
|
return refreshPromise;
|
|
235216
235228
|
}
|
|
@@ -244410,6 +244422,7 @@ async function login({
|
|
|
244410
244422
|
|
|
244411
244423
|
// src/cli/utils/command/middleware.ts
|
|
244412
244424
|
async function ensureAuth(ctx) {
|
|
244425
|
+
await seedAuthFromEnv();
|
|
244413
244426
|
const loggedIn = await isLoggedIn();
|
|
244414
244427
|
if (!loggedIn) {
|
|
244415
244428
|
ctx.log.info("You need to login first to continue.");
|
|
@@ -251792,8 +251805,7 @@ function getLogoutCommand() {
|
|
|
251792
251805
|
// src/cli/commands/auth/whoami.ts
|
|
251793
251806
|
async function whoami(_ctx) {
|
|
251794
251807
|
const auth2 = await readAuth();
|
|
251795
|
-
|
|
251796
|
-
return { outroMessage: `Logged in as: ${theme.styles.bold(identity4)}` };
|
|
251808
|
+
return { outroMessage: `Logged in as: ${theme.styles.bold(auth2.email)}` };
|
|
251797
251809
|
}
|
|
251798
251810
|
function getWhoamiCommand() {
|
|
251799
251811
|
return new Base44Command("whoami", { requireAppConfig: false }).description("Display current authenticated user").action(whoami);
|
|
@@ -253140,6 +253152,30 @@ async function executeCreate({
|
|
|
253140
253152
|
return await completeProjectSetup({ projectId, name: name2, resolvedPath, deploy: deploy5, skills, isInteractive }, { log, runTask: runTask2 });
|
|
253141
253153
|
}
|
|
253142
253154
|
async function createAction({ log, runTask: runTask2, isNonInteractive }, name2, options) {
|
|
253155
|
+
const existingAppId = process.env.BASE44_APP_ID;
|
|
253156
|
+
if (existingAppId) {
|
|
253157
|
+
if (isNonInteractive) {
|
|
253158
|
+
throw new InvalidInputError(`BASE44_APP_ID is set (${existingAppId}) — this environment already has a Base44 app, so \`create\` won't make a new one.`, {
|
|
253159
|
+
hints: [
|
|
253160
|
+
{
|
|
253161
|
+
message: "Run `base44 init` to scaffold a project for the existing app"
|
|
253162
|
+
},
|
|
253163
|
+
{
|
|
253164
|
+
message: "Or unset BASE44_APP_ID to create a new app with `base44 create`"
|
|
253165
|
+
}
|
|
253166
|
+
]
|
|
253167
|
+
});
|
|
253168
|
+
}
|
|
253169
|
+
const proceed = await Re({
|
|
253170
|
+
message: `BASE44_APP_ID is set (${existingAppId}). This environment already has a Base44 app — \`base44 init\` scaffolds for it, while \`create\` makes a new one. Create a new app anyway?`,
|
|
253171
|
+
initialValue: false
|
|
253172
|
+
});
|
|
253173
|
+
if (Ct(proceed) || !proceed) {
|
|
253174
|
+
return {
|
|
253175
|
+
outroMessage: "Run `base44 init` to scaffold a project for the existing app"
|
|
253176
|
+
};
|
|
253177
|
+
}
|
|
253178
|
+
}
|
|
253143
253179
|
if (name2 && !options.path) {
|
|
253144
253180
|
options.path = `./${import_kebabCase.default(name2)}`;
|
|
253145
253181
|
}
|
|
@@ -253272,29 +253308,22 @@ function resolveAppId(options) {
|
|
|
253272
253308
|
hints: [
|
|
253273
253309
|
{ message: "Pass it explicitly with --app-id <id>" },
|
|
253274
253310
|
{
|
|
253275
|
-
message: "Or set
|
|
253311
|
+
message: "Or set the BASE44_APP_ID environment variable (e.g. via .env)"
|
|
253276
253312
|
}
|
|
253277
253313
|
]
|
|
253278
253314
|
});
|
|
253279
253315
|
}
|
|
253280
253316
|
return appId;
|
|
253281
253317
|
}
|
|
253282
|
-
async function
|
|
253283
|
-
|
|
253284
|
-
|
|
253285
|
-
|
|
253286
|
-
|
|
253287
|
-
|
|
253288
|
-
deploy: deploy5,
|
|
253289
|
-
skills,
|
|
253290
|
-
isInteractive
|
|
253291
|
-
}, { log, runTask: runTask2 }) {
|
|
253292
|
-
const name2 = rawName.trim();
|
|
253293
|
-
const resolvedPath = resolve6(projectPath);
|
|
253318
|
+
async function initAction({ log, runTask: runTask2 }, name2, options) {
|
|
253319
|
+
const appId = resolveAppId(options);
|
|
253320
|
+
const resolvedPath = resolve6("./");
|
|
253321
|
+
const projectName = (name2 ?? basename4(resolvedPath)).trim();
|
|
253322
|
+
const template2 = await getTemplateById("backend-only");
|
|
253323
|
+
log.info(`Initializing project at ${resolvedPath}`);
|
|
253294
253324
|
const { projectId, skippedFiles } = await runTask2("Setting up your project...", async () => {
|
|
253295
253325
|
return await initProjectFiles({
|
|
253296
|
-
name:
|
|
253297
|
-
description: description?.trim(),
|
|
253326
|
+
name: projectName,
|
|
253298
253327
|
path: resolvedPath,
|
|
253299
253328
|
template: template2,
|
|
253300
253329
|
appId
|
|
@@ -253307,83 +253336,24 @@ async function executeInit({
|
|
|
253307
253336
|
log.info(`Kept existing file${skippedFiles.length > 1 ? "s" : ""}: ${skippedFiles.join(", ")}`);
|
|
253308
253337
|
}
|
|
253309
253338
|
setAppConfig({ id: projectId, projectRoot: resolvedPath });
|
|
253310
|
-
return await completeProjectSetup({
|
|
253311
|
-
|
|
253312
|
-
|
|
253313
|
-
|
|
253314
|
-
|
|
253315
|
-
value: t,
|
|
253316
|
-
label: t.name,
|
|
253317
|
-
hint: t.description
|
|
253318
|
-
}));
|
|
253319
|
-
const result = await Oe({
|
|
253320
|
-
template: () => Je({
|
|
253321
|
-
message: "Pick an option",
|
|
253322
|
-
options: templateOptions
|
|
253323
|
-
}),
|
|
253324
|
-
name: () => {
|
|
253325
|
-
return options.name ? Promise.resolve(options.name) : Ze({
|
|
253326
|
-
message: "What is the name of your project?",
|
|
253327
|
-
placeholder: basename4(process.cwd()),
|
|
253328
|
-
initialValue: basename4(process.cwd()),
|
|
253329
|
-
validate: (value) => {
|
|
253330
|
-
if (!value || value.trim().length === 0) {
|
|
253331
|
-
return "Every project deserves a name";
|
|
253332
|
-
}
|
|
253333
|
-
}
|
|
253334
|
-
});
|
|
253335
|
-
},
|
|
253336
|
-
projectPath: () => Ze({
|
|
253337
|
-
message: "Where should we set up your project?",
|
|
253338
|
-
placeholder: "./",
|
|
253339
|
-
initialValue: options.path ?? "./"
|
|
253340
|
-
})
|
|
253341
|
-
}, {
|
|
253342
|
-
onCancel: onPromptCancel
|
|
253343
|
-
});
|
|
253344
|
-
return await executeInit({
|
|
253345
|
-
template: result.template,
|
|
253346
|
-
name: result.name,
|
|
253347
|
-
appId,
|
|
253348
|
-
projectPath: result.projectPath,
|
|
253349
|
-
deploy: options.deploy,
|
|
253350
|
-
skills: options.skills,
|
|
253351
|
-
isInteractive: true
|
|
253352
|
-
}, ctx);
|
|
253353
|
-
}
|
|
253354
|
-
async function initNonInteractive(appId, options, ctx) {
|
|
253355
|
-
const projectPath = options.path ?? "./";
|
|
253356
|
-
const name2 = options.name ?? basename4(resolve6(projectPath));
|
|
253357
|
-
ctx.log.info(`Initializing project at ${resolve6(projectPath)}`);
|
|
253358
|
-
const template2 = await getTemplateById(options.template ?? DEFAULT_TEMPLATE_ID);
|
|
253359
|
-
return await executeInit({
|
|
253360
|
-
template: template2,
|
|
253361
|
-
name: name2,
|
|
253362
|
-
appId,
|
|
253363
|
-
projectPath,
|
|
253364
|
-
deploy: options.deploy,
|
|
253339
|
+
return await completeProjectSetup({
|
|
253340
|
+
projectId,
|
|
253341
|
+
name: projectName,
|
|
253342
|
+
resolvedPath,
|
|
253343
|
+
deploy: false,
|
|
253365
253344
|
skills: options.skills,
|
|
253366
253345
|
isInteractive: false
|
|
253367
|
-
},
|
|
253368
|
-
}
|
|
253369
|
-
async function initAction({ log, runTask: runTask2, isNonInteractive }, name2, options) {
|
|
253370
|
-
const appId = resolveAppId(options);
|
|
253371
|
-
const opts = { ...options, name: options.name ?? name2 };
|
|
253372
|
-
const ctx = { log, runTask: runTask2 };
|
|
253373
|
-
if (isNonInteractive) {
|
|
253374
|
-
return await initNonInteractive(appId, opts, ctx);
|
|
253375
|
-
}
|
|
253376
|
-
return await initInteractive(appId, opts, ctx);
|
|
253346
|
+
}, { log, runTask: runTask2 });
|
|
253377
253347
|
}
|
|
253378
253348
|
function getInitCommand() {
|
|
253379
253349
|
return new Base44Command("init", {
|
|
253380
253350
|
requireAppConfig: false,
|
|
253381
253351
|
fullBanner: true
|
|
253382
|
-
}).description("Scaffold a local project for an existing Base44 app
|
|
253352
|
+
}).description("Scaffold a local project for an existing Base44 app").addArgument(new Argument("name", "Project name").argOptional()).option("--app-id <id>", "Existing Base44 app ID (defaults to the BASE44_APP_ID environment variable)").option("--no-skills", "Skip AI agent skills installation").addHelpText("after", `
|
|
253383
253353
|
Examples:
|
|
253384
|
-
$ base44 init
|
|
253385
|
-
$ base44 init --app-id app_123
|
|
253386
|
-
$ base44 init my-app --app-id app_123
|
|
253354
|
+
$ base44 init Scaffolds the current dir for $BASE44_APP_ID
|
|
253355
|
+
$ base44 init --app-id app_123 Scaffolds the current dir for the given app
|
|
253356
|
+
$ base44 init my-app --app-id app_123 Scaffolds the current dir, named "my-app"`).action(initAction);
|
|
253387
253357
|
}
|
|
253388
253358
|
|
|
253389
253359
|
// src/cli/commands/project/link.ts
|
|
@@ -261810,4 +261780,4 @@ export {
|
|
|
261810
261780
|
CLIExitError
|
|
261811
261781
|
};
|
|
261812
261782
|
|
|
261813
|
-
//# debugId=
|
|
261783
|
+
//# debugId=C659EAC64DBB54EC64756E2164756E21
|