@base44-preview/cli 0.1.7-pr.568.c08ba20 → 0.1.7-pr.580.688e1cd
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/assets/templates/backend-and-client/package.json +2 -1
- package/dist/assets/templates/backend-and-client/src/api/base44Client.js +13 -0
- package/dist/assets/templates/backend-and-client/src/lib/app-params.js +54 -0
- package/dist/assets/templates/backend-and-client/vite.config.js +3 -8
- package/dist/cli/index.js +172 -66
- package/dist/cli/index.js.map +16 -14
- package/package.json +1 -1
- package/dist/assets/templates/backend-and-client/src/api/base44Client.js.ejs +0 -5
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createClient } from '@base44/sdk';
|
|
2
|
+
import { appParams } from '@/lib/app-params';
|
|
3
|
+
|
|
4
|
+
const { appId, token, functionsVersion, appBaseUrl } = appParams;
|
|
5
|
+
|
|
6
|
+
export const base44 = createClient({
|
|
7
|
+
appId,
|
|
8
|
+
token,
|
|
9
|
+
functionsVersion,
|
|
10
|
+
serverUrl: '',
|
|
11
|
+
requiresAuth: false,
|
|
12
|
+
appBaseUrl
|
|
13
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const isNode = typeof window === 'undefined';
|
|
2
|
+
const windowObj = isNode ? { localStorage: new Map() } : window;
|
|
3
|
+
const storage = windowObj.localStorage;
|
|
4
|
+
|
|
5
|
+
const toSnakeCase = (str) => {
|
|
6
|
+
return str.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const getAppParamValue = (paramName, { defaultValue = undefined, removeFromUrl = false } = {}) => {
|
|
10
|
+
if (isNode) {
|
|
11
|
+
return defaultValue;
|
|
12
|
+
}
|
|
13
|
+
const storageKey = `base44_${toSnakeCase(paramName)}`;
|
|
14
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
15
|
+
const searchParam = urlParams.get(paramName);
|
|
16
|
+
if (removeFromUrl) {
|
|
17
|
+
urlParams.delete(paramName);
|
|
18
|
+
const newUrl = `${window.location.pathname}${urlParams.toString() ? `?${urlParams.toString()}` : ""
|
|
19
|
+
}${window.location.hash}`;
|
|
20
|
+
window.history.replaceState({}, document.title, newUrl);
|
|
21
|
+
}
|
|
22
|
+
if (searchParam) {
|
|
23
|
+
storage.setItem(storageKey, searchParam);
|
|
24
|
+
return searchParam;
|
|
25
|
+
}
|
|
26
|
+
if (defaultValue) {
|
|
27
|
+
storage.setItem(storageKey, defaultValue);
|
|
28
|
+
return defaultValue;
|
|
29
|
+
}
|
|
30
|
+
const storedValue = storage.getItem(storageKey);
|
|
31
|
+
if (storedValue) {
|
|
32
|
+
return storedValue;
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const getAppParams = () => {
|
|
38
|
+
if (getAppParamValue("clear_access_token") === 'true') {
|
|
39
|
+
storage.removeItem('base44_access_token');
|
|
40
|
+
storage.removeItem('token');
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
appId: getAppParamValue("app_id", { defaultValue: import.meta.env.VITE_BASE44_APP_ID }),
|
|
44
|
+
token: getAppParamValue("access_token", { removeFromUrl: true }),
|
|
45
|
+
fromUrl: getAppParamValue("from_url", { defaultValue: window.location.href }),
|
|
46
|
+
functionsVersion: getAppParamValue("functions_version", { defaultValue: import.meta.env.VITE_BASE44_FUNCTIONS_VERSION }),
|
|
47
|
+
appBaseUrl: getAppParamValue("app_base_url", { defaultValue: import.meta.env.VITE_BASE44_APP_BASE_URL }),
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
export const appParams = {
|
|
53
|
+
...getAppParams()
|
|
54
|
+
}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import base44 from '@base44/vite-plugin';
|
|
2
2
|
import react from '@vitejs/plugin-react';
|
|
3
|
-
import
|
|
3
|
+
import { defineConfig } from 'vite';
|
|
4
4
|
|
|
5
5
|
export default defineConfig({
|
|
6
|
-
plugins: [react()],
|
|
7
|
-
resolve: {
|
|
8
|
-
alias: {
|
|
9
|
-
'@': path.resolve(__dirname, './src'),
|
|
10
|
-
},
|
|
11
|
-
},
|
|
6
|
+
plugins: [base44(), react()],
|
|
12
7
|
});
|
package/dist/cli/index.js
CHANGED
|
@@ -244912,15 +244912,14 @@ async function setAppVisibility(visibility) {
|
|
|
244912
244912
|
throw await ApiError.fromHttpError(error48, "updating app visibility");
|
|
244913
244913
|
}
|
|
244914
244914
|
}
|
|
244915
|
-
async function listProjects(
|
|
244915
|
+
async function listProjects() {
|
|
244916
244916
|
let response;
|
|
244917
244917
|
try {
|
|
244918
244918
|
response = await base44Client.get("api/apps", {
|
|
244919
244919
|
searchParams: {
|
|
244920
244920
|
sort: "-updated_date",
|
|
244921
244921
|
fields: "id,name,user_description,is_managed_source_code",
|
|
244922
|
-
limit: 50
|
|
244923
|
-
...options.workspaceId ? { workspace_id: options.workspaceId } : {}
|
|
244922
|
+
limit: 50
|
|
244924
244923
|
}
|
|
244925
244924
|
});
|
|
244926
244925
|
} catch (error48) {
|
|
@@ -247480,7 +247479,9 @@ async function deploySite(siteOutputDir) {
|
|
|
247480
247479
|
if (!await pathExists(siteOutputDir)) {
|
|
247481
247480
|
throw new InvalidInputError(`Output directory does not exist: ${siteOutputDir}. Make sure to build your project first.`, {
|
|
247482
247481
|
hints: [
|
|
247483
|
-
{
|
|
247482
|
+
{
|
|
247483
|
+
message: "Run 'base44 build' first (it injects your app id; a bare 'npm run build' does not)"
|
|
247484
|
+
}
|
|
247484
247485
|
]
|
|
247485
247486
|
});
|
|
247486
247487
|
}
|
|
@@ -247488,7 +247489,9 @@ async function deploySite(siteOutputDir) {
|
|
|
247488
247489
|
if (filePaths.length === 0) {
|
|
247489
247490
|
throw new ConfigInvalidError(`No files found in output directory: ${siteOutputDir}. Make sure to build your project first.`, siteOutputDir, {
|
|
247490
247491
|
hints: [
|
|
247491
|
-
{
|
|
247492
|
+
{
|
|
247493
|
+
message: "Run 'base44 build' first (it injects your app id; a bare 'npm run build' does not)"
|
|
247494
|
+
}
|
|
247492
247495
|
]
|
|
247493
247496
|
});
|
|
247494
247497
|
}
|
|
@@ -256641,6 +256644,80 @@ function getFunctionsCommand() {
|
|
|
256641
256644
|
return new Command("functions").description("Manage backend functions").addCommand(getDeployCommand()).addCommand(getDeleteCommand()).addCommand(getListCommand()).addCommand(getPullCommand());
|
|
256642
256645
|
}
|
|
256643
256646
|
|
|
256647
|
+
// src/cli/commands/project/site-build.ts
|
|
256648
|
+
async function runSiteBuild({ runTask: runTask2 }, { root, buildCommand, appId }) {
|
|
256649
|
+
if (!buildCommand) {
|
|
256650
|
+
throw new ConfigNotFoundError("No site build command found.", {
|
|
256651
|
+
hints: [
|
|
256652
|
+
{
|
|
256653
|
+
message: `Add 'site.buildCommand' to your config.jsonc (e.g., "site": { "buildCommand": "npm run build" })`
|
|
256654
|
+
}
|
|
256655
|
+
]
|
|
256656
|
+
});
|
|
256657
|
+
}
|
|
256658
|
+
await runTask2("Building site...", () => execa({
|
|
256659
|
+
cwd: root,
|
|
256660
|
+
shell: true,
|
|
256661
|
+
env: { VITE_BASE44_APP_ID: appId }
|
|
256662
|
+
})`${buildCommand}`, {
|
|
256663
|
+
successMessage: "Site built successfully",
|
|
256664
|
+
errorMessage: "Build failed"
|
|
256665
|
+
});
|
|
256666
|
+
}
|
|
256667
|
+
async function maybeBuildBeforeDeploy(ctx, project2, build) {
|
|
256668
|
+
if (!ctx.app) {
|
|
256669
|
+
return;
|
|
256670
|
+
}
|
|
256671
|
+
if (build === true) {
|
|
256672
|
+
await runSiteBuild(ctx, {
|
|
256673
|
+
root: project2.root,
|
|
256674
|
+
buildCommand: project2.site?.buildCommand,
|
|
256675
|
+
appId: ctx.app.id
|
|
256676
|
+
});
|
|
256677
|
+
return;
|
|
256678
|
+
}
|
|
256679
|
+
if (build === false || !project2.site?.outputDirectory) {
|
|
256680
|
+
return;
|
|
256681
|
+
}
|
|
256682
|
+
const shouldBuild = await shouldAskToBuild(ctx.isNonInteractive, project2.site.buildCommand);
|
|
256683
|
+
if (shouldBuild) {
|
|
256684
|
+
await runSiteBuild(ctx, {
|
|
256685
|
+
root: project2.root,
|
|
256686
|
+
buildCommand: project2.site.buildCommand,
|
|
256687
|
+
appId: ctx.app.id
|
|
256688
|
+
});
|
|
256689
|
+
}
|
|
256690
|
+
}
|
|
256691
|
+
async function shouldAskToBuild(isNonInteractive, buildCommand) {
|
|
256692
|
+
if (!buildCommand || isNonInteractive) {
|
|
256693
|
+
return false;
|
|
256694
|
+
}
|
|
256695
|
+
const answer = await Re({
|
|
256696
|
+
message: `Build the site first? (runs '${buildCommand}' with your app id)`
|
|
256697
|
+
});
|
|
256698
|
+
return !Ct(answer) && answer;
|
|
256699
|
+
}
|
|
256700
|
+
|
|
256701
|
+
// src/cli/commands/project/build.ts
|
|
256702
|
+
async function buildAction(ctx) {
|
|
256703
|
+
const { app } = ctx;
|
|
256704
|
+
if (!app?.projectRoot) {
|
|
256705
|
+
throw new ConfigInvalidError("base44 build requires a linked local project. Run it from a project with base44/.app.jsonc.");
|
|
256706
|
+
}
|
|
256707
|
+
const { project: project2 } = await readProjectConfig(app.projectRoot);
|
|
256708
|
+
await runSiteBuild(ctx, {
|
|
256709
|
+
root: project2.root,
|
|
256710
|
+
buildCommand: project2.site?.buildCommand,
|
|
256711
|
+
appId: app.id
|
|
256712
|
+
});
|
|
256713
|
+
return {
|
|
256714
|
+
outroMessage: `Site built with app id ${theme.styles.bold(app.id)}`
|
|
256715
|
+
};
|
|
256716
|
+
}
|
|
256717
|
+
function getBuildCommand() {
|
|
256718
|
+
return new Base44Command("build").description("Build the site with the Base44 app id injected").action(buildAction);
|
|
256719
|
+
}
|
|
256720
|
+
|
|
256644
256721
|
// src/cli/commands/project/create.ts
|
|
256645
256722
|
import { basename as basename4, resolve as resolve8 } from "node:path";
|
|
256646
256723
|
var import_kebabCase = __toESM(require_kebabCase(), 1);
|
|
@@ -256703,7 +256780,11 @@ async function completeProjectSetup({
|
|
|
256703
256780
|
const { appUrl } = await runTask2("Installing dependencies...", async (updateMessage) => {
|
|
256704
256781
|
await execa({ cwd: resolvedPath, shell: true })`${installCommand}`;
|
|
256705
256782
|
updateMessage("Building project...");
|
|
256706
|
-
await execa({
|
|
256783
|
+
await execa({
|
|
256784
|
+
cwd: resolvedPath,
|
|
256785
|
+
shell: true,
|
|
256786
|
+
env: { VITE_BASE44_APP_ID: projectId }
|
|
256787
|
+
})`${buildCommand}`;
|
|
256707
256788
|
updateMessage("Deploying site...");
|
|
256708
256789
|
return await deploySite(join23(resolvedPath, outputDirectory));
|
|
256709
256790
|
}, {
|
|
@@ -256751,7 +256832,7 @@ function workspaceLabel(workspace2) {
|
|
|
256751
256832
|
const suffix = workspace2.isPersonal ? "personal" : workspace2.userRole ?? "member";
|
|
256752
256833
|
return `${workspace2.name} (${suffix})`;
|
|
256753
256834
|
}
|
|
256754
|
-
async function resolveWorkspaceId(ctx, flagWorkspaceId, isInteractive
|
|
256835
|
+
async function resolveWorkspaceId(ctx, flagWorkspaceId, isInteractive) {
|
|
256755
256836
|
if (flagWorkspaceId) {
|
|
256756
256837
|
return flagWorkspaceId;
|
|
256757
256838
|
}
|
|
@@ -256762,13 +256843,13 @@ async function resolveWorkspaceId(ctx, flagWorkspaceId, isInteractive, options =
|
|
|
256762
256843
|
if (workspaces.length <= 1) {
|
|
256763
256844
|
return;
|
|
256764
256845
|
}
|
|
256765
|
-
const
|
|
256846
|
+
const options = workspaces.map((w) => ({
|
|
256766
256847
|
value: w.id,
|
|
256767
256848
|
label: workspaceLabel(w)
|
|
256768
256849
|
}));
|
|
256769
256850
|
const selected = await Je({
|
|
256770
|
-
message:
|
|
256771
|
-
options
|
|
256851
|
+
message: "Which workspace should this app belong to?",
|
|
256852
|
+
options,
|
|
256772
256853
|
initialValue: workspaces[0].id
|
|
256773
256854
|
});
|
|
256774
256855
|
if (Ct(selected)) {
|
|
@@ -256909,7 +256990,8 @@ Examples:
|
|
|
256909
256990
|
}
|
|
256910
256991
|
|
|
256911
256992
|
// src/cli/commands/project/deploy.ts
|
|
256912
|
-
async function deployAction(
|
|
256993
|
+
async function deployAction(ctx, options = {}) {
|
|
256994
|
+
const { isNonInteractive, log } = ctx;
|
|
256913
256995
|
if (isNonInteractive && !options.yes) {
|
|
256914
256996
|
throw new InvalidInputError("--yes is required in non-interactive mode");
|
|
256915
256997
|
}
|
|
@@ -256957,6 +257039,7 @@ ${summaryLines.join(`
|
|
|
256957
257039
|
${summaryLines.join(`
|
|
256958
257040
|
`)}`);
|
|
256959
257041
|
}
|
|
257042
|
+
await maybeBuildBeforeDeploy(ctx, project2, options.build);
|
|
256960
257043
|
let functionCompleted = 0;
|
|
256961
257044
|
const functionTotal = functions.length;
|
|
256962
257045
|
const result = await deployAll(projectData, {
|
|
@@ -256985,7 +257068,7 @@ ${summaryLines.join(`
|
|
|
256985
257068
|
return { outroMessage: "App deployed successfully" };
|
|
256986
257069
|
}
|
|
256987
257070
|
function getDeployCommand2() {
|
|
256988
|
-
return new Base44Command("deploy").description("Deploy all project resources (entities, functions, agents, connectors, and site)").option("-y, --yes", "Skip confirmation prompt").action(deployAction);
|
|
257071
|
+
return new Base44Command("deploy").description("Deploy all project resources (entities, functions, agents, connectors, and site)").option("-y, --yes", "Skip confirmation prompt").option("--build", "Build the site before deploying (skips the prompt)").option("--no-build", "Deploy without building (skips the prompt)").action(deployAction);
|
|
256989
257072
|
}
|
|
256990
257073
|
async function handleOAuthConnectors(connectorResults, isNonInteractive, options, log) {
|
|
256991
257074
|
const needsOAuth = filterPendingOAuth(connectorResults);
|
|
@@ -257101,36 +257184,6 @@ async function promptForExistingProject(projects) {
|
|
|
257101
257184
|
}
|
|
257102
257185
|
return selectedProject;
|
|
257103
257186
|
}
|
|
257104
|
-
async function resolveExplicitAppId(ctx, appId) {
|
|
257105
|
-
await ctx.runTask("Validating app...", () => getApp(appId), {
|
|
257106
|
-
errorMessage: "Could not validate app"
|
|
257107
|
-
}).catch((error48) => {
|
|
257108
|
-
if (error48 instanceof ApiError && (error48.statusCode === 404 || error48.statusCode === 403)) {
|
|
257109
|
-
throw new InvalidInputError(`App "${appId}" not found, or you don't have access to it.`, {
|
|
257110
|
-
hints: [
|
|
257111
|
-
{ message: "Check the app ID is correct" },
|
|
257112
|
-
{
|
|
257113
|
-
message: "Run 'base44 link' without --app-id to browse apps by workspace"
|
|
257114
|
-
}
|
|
257115
|
-
]
|
|
257116
|
-
});
|
|
257117
|
-
}
|
|
257118
|
-
throw error48;
|
|
257119
|
-
});
|
|
257120
|
-
return appId;
|
|
257121
|
-
}
|
|
257122
|
-
async function chooseProjectInteractively(ctx, options) {
|
|
257123
|
-
const workspaceId = await resolveWorkspaceId(ctx, options.workspace ?? options.org, !ctx.isNonInteractive, { promptMessage: "Which workspace is the app in?" });
|
|
257124
|
-
const projects = await ctx.runTask("Fetching projects...", () => listProjects({ workspaceId }), {
|
|
257125
|
-
successMessage: "Projects fetched",
|
|
257126
|
-
errorMessage: "Failed to fetch projects"
|
|
257127
|
-
});
|
|
257128
|
-
if (!projects.length) {
|
|
257129
|
-
return;
|
|
257130
|
-
}
|
|
257131
|
-
const selectedProject = await promptForExistingProject(projects);
|
|
257132
|
-
return selectedProject.id;
|
|
257133
|
-
}
|
|
257134
257187
|
async function link(ctx, options, command2) {
|
|
257135
257188
|
const { log, runTask: runTask2, isNonInteractive } = ctx;
|
|
257136
257189
|
const appId = readExplicitAppId(command2).value;
|
|
@@ -257154,10 +257207,31 @@ async function link(ctx, options, command2) {
|
|
|
257154
257207
|
let finalAppId;
|
|
257155
257208
|
const action = appId ? "choose" : options.create ? "create" : await promptForLinkAction();
|
|
257156
257209
|
if (action === "choose") {
|
|
257157
|
-
const
|
|
257158
|
-
|
|
257210
|
+
const projects = await runTask2("Fetching projects...", async () => listProjects(), {
|
|
257211
|
+
successMessage: "Projects fetched",
|
|
257212
|
+
errorMessage: "Failed to fetch projects"
|
|
257213
|
+
});
|
|
257214
|
+
if (!projects.length) {
|
|
257159
257215
|
return { outroMessage: "No projects available for linking" };
|
|
257160
257216
|
}
|
|
257217
|
+
let linkedAppId;
|
|
257218
|
+
if (appId) {
|
|
257219
|
+
const project2 = projects.find((p) => p.id === appId);
|
|
257220
|
+
if (!project2) {
|
|
257221
|
+
throw new InvalidInputError(`App with ID "${appId}" not found.`, {
|
|
257222
|
+
hints: [
|
|
257223
|
+
{ message: "Check the app ID is correct" },
|
|
257224
|
+
{
|
|
257225
|
+
message: "Use 'base44 link' without --app-id to see available projects"
|
|
257226
|
+
}
|
|
257227
|
+
]
|
|
257228
|
+
});
|
|
257229
|
+
}
|
|
257230
|
+
linkedAppId = appId;
|
|
257231
|
+
} else {
|
|
257232
|
+
const selectedProject = await promptForExistingProject(projects);
|
|
257233
|
+
linkedAppId = selectedProject.id;
|
|
257234
|
+
}
|
|
257161
257235
|
await runTask2("Linking project...", async () => {
|
|
257162
257236
|
await writeAppConfig(projectRoot.root, linkedAppId);
|
|
257163
257237
|
setAppContext({ id: linkedAppId, projectRoot: projectRoot.root });
|
|
@@ -257186,7 +257260,7 @@ async function link(ctx, options, command2) {
|
|
|
257186
257260
|
function getLinkCommand() {
|
|
257187
257261
|
return new Base44Command("link", {
|
|
257188
257262
|
requireAppContext: false
|
|
257189
|
-
}).description("Link a local project to a Base44 project (create new or link existing)").configureHelp({ showGlobalOptions: true }).option("-c, --create", "Create a new project (skip selection prompt)").option("-n, --name <name>", "Project name (required when --create is used)").option("-d, --description <description>", "Project description").option("-w, --workspace <id>", "Workspace (organization) ID to
|
|
257263
|
+
}).description("Link a local project to a Base44 project (create new or link existing)").configureHelp({ showGlobalOptions: true }).option("-c, --create", "Create a new project (skip selection prompt)").option("-n, --name <name>", "Project name (required when --create is used)").option("-d, --description <description>", "Project description").option("-w, --workspace <id>", "Workspace (organization) ID to create the app in when using --create (defaults to your personal workspace)").addOption(new Option("--org <id>", "Alias for --workspace").hideHelp()).addOption(new Option("-p, --project-id <id>", "Project ID to link to an existing project").hideHelp()).addOption(new Option("--projectId <id>", "Project ID to link to an existing project").hideHelp()).hook("preAction", validateNonInteractiveFlags).action(link);
|
|
257190
257264
|
}
|
|
257191
257265
|
|
|
257192
257266
|
// src/cli/commands/project/logs.ts
|
|
@@ -257860,7 +257934,8 @@ function getSecretsCommand() {
|
|
|
257860
257934
|
|
|
257861
257935
|
// src/cli/commands/site/deploy.ts
|
|
257862
257936
|
import { resolve as resolve11 } from "node:path";
|
|
257863
|
-
async function deployAction2(
|
|
257937
|
+
async function deployAction2(ctx, options) {
|
|
257938
|
+
const { isNonInteractive, runTask: runTask2 } = ctx;
|
|
257864
257939
|
if (isNonInteractive && !options.yes) {
|
|
257865
257940
|
throw new InvalidInputError("--yes is required in non-interactive mode");
|
|
257866
257941
|
}
|
|
@@ -257883,6 +257958,7 @@ async function deployAction2({ isNonInteractive, runTask: runTask2 }, options) {
|
|
|
257883
257958
|
return { outroMessage: "Deployment cancelled" };
|
|
257884
257959
|
}
|
|
257885
257960
|
}
|
|
257961
|
+
await maybeBuildBeforeDeploy(ctx, project2, options.build);
|
|
257886
257962
|
const result = await runTask2("Creating archive and deploying site...", async () => {
|
|
257887
257963
|
return await deploySite(outputDir);
|
|
257888
257964
|
}, {
|
|
@@ -257892,7 +257968,7 @@ async function deployAction2({ isNonInteractive, runTask: runTask2 }, options) {
|
|
|
257892
257968
|
return { outroMessage: `Visit your site at: ${result.appUrl}` };
|
|
257893
257969
|
}
|
|
257894
257970
|
function getSiteDeployCommand() {
|
|
257895
|
-
return new Base44Command("deploy").description("Deploy built site files to Base44 hosting").option("-y, --yes", "Skip confirmation prompt").action(deployAction2);
|
|
257971
|
+
return new Base44Command("deploy").description("Deploy built site files to Base44 hosting").option("-y, --yes", "Skip confirmation prompt").option("--build", "Build the site before deploying (skips the prompt)").option("--no-build", "Deploy without building (skips the prompt)").action(deployAction2);
|
|
257896
257972
|
}
|
|
257897
257973
|
|
|
257898
257974
|
// src/cli/commands/site/open.ts
|
|
@@ -262114,6 +262190,10 @@ function validateDevOptions(command2) {
|
|
|
262114
262190
|
if (appId !== undefined) {
|
|
262115
262191
|
command2.error(`base44 dev cannot be used with --app-id or ${BASE44_APP_ID_ENV_VAR}.`);
|
|
262116
262192
|
}
|
|
262193
|
+
const { port, remote } = command2.opts();
|
|
262194
|
+
if (remote && port !== undefined) {
|
|
262195
|
+
command2.error("--port applies to the local backend, which --remote does not start.");
|
|
262196
|
+
}
|
|
262117
262197
|
}
|
|
262118
262198
|
function requireLinkedProject({ app }) {
|
|
262119
262199
|
if (!app?.projectRoot) {
|
|
@@ -262121,31 +262201,44 @@ function requireLinkedProject({ app }) {
|
|
|
262121
262201
|
}
|
|
262122
262202
|
return { id: app.id, projectRoot: app.projectRoot };
|
|
262123
262203
|
}
|
|
262124
|
-
async function
|
|
262204
|
+
async function resolveConfiguredSite(app) {
|
|
262125
262205
|
const { project: project2 } = await readProjectConfig(app.projectRoot);
|
|
262126
262206
|
const serveCommand = project2.site?.serveCommand;
|
|
262127
|
-
|
|
262128
|
-
return;
|
|
262129
|
-
}
|
|
262130
|
-
return createServeCommandRunner({
|
|
262131
|
-
serveCommand,
|
|
262132
|
-
projectRoot: project2.root,
|
|
262133
|
-
appId: app.id,
|
|
262134
|
-
appBaseUrl: backendUrl
|
|
262135
|
-
});
|
|
262207
|
+
return serveCommand ? { serveCommand, projectRoot: project2.root } : undefined;
|
|
262136
262208
|
}
|
|
262137
|
-
function
|
|
262209
|
+
function stopRunnerOnProcessSignals(runner) {
|
|
262138
262210
|
const stop2 = () => void runner.stop();
|
|
262139
262211
|
process.on("SIGINT", stop2);
|
|
262140
262212
|
process.on("SIGTERM", stop2);
|
|
262213
|
+
}
|
|
262214
|
+
function startServeCommand(runner, backend) {
|
|
262215
|
+
stopRunnerOnProcessSignals(runner);
|
|
262141
262216
|
runner.onExit(() => {
|
|
262142
262217
|
backend.shutdown().finally(() => process.exit(1));
|
|
262143
262218
|
});
|
|
262144
262219
|
createDevLogger("backend", theme.styles.info).log(`Backend running on ${backend.url}`);
|
|
262145
262220
|
runner.start();
|
|
262146
262221
|
}
|
|
262147
|
-
async function
|
|
262148
|
-
const
|
|
262222
|
+
async function remoteDevAction(app) {
|
|
262223
|
+
const site2 = await resolveConfiguredSite(app);
|
|
262224
|
+
if (!site2) {
|
|
262225
|
+
throw new ConfigInvalidError("base44 dev --remote serves the frontend against the production backend, but this project has no site.serveCommand in base44/config.jsonc.");
|
|
262226
|
+
}
|
|
262227
|
+
const appBaseUrl = await getSiteUrl();
|
|
262228
|
+
const runner = createServeCommandRunner({
|
|
262229
|
+
...site2,
|
|
262230
|
+
appId: app.id,
|
|
262231
|
+
appBaseUrl
|
|
262232
|
+
});
|
|
262233
|
+
stopRunnerOnProcessSignals(runner);
|
|
262234
|
+
runner.onExit((code2) => process.exit(code2 ?? 1));
|
|
262235
|
+
runner.start();
|
|
262236
|
+
return {
|
|
262237
|
+
outroMessage: `Frontend dev server targets ${theme.styles.bold(appBaseUrl)} — every write hits your live app`
|
|
262238
|
+
};
|
|
262239
|
+
}
|
|
262240
|
+
async function localDevAction(ctx, app, options8) {
|
|
262241
|
+
const site2 = await resolveConfiguredSite(app);
|
|
262149
262242
|
const siteUrlPromise = getSiteUrl().catch(() => {
|
|
262150
262243
|
return;
|
|
262151
262244
|
});
|
|
@@ -262160,15 +262253,23 @@ async function devAction(ctx, options8) {
|
|
|
262160
262253
|
}
|
|
262161
262254
|
});
|
|
262162
262255
|
const backendUrl = localServerUrl(backend.port);
|
|
262163
|
-
|
|
262164
|
-
|
|
262256
|
+
if (site2) {
|
|
262257
|
+
const runner = createServeCommandRunner({
|
|
262258
|
+
...site2,
|
|
262259
|
+
appId: app.id,
|
|
262260
|
+
appBaseUrl: backendUrl
|
|
262261
|
+
});
|
|
262165
262262
|
startServeCommand(runner, { url: backendUrl, shutdown: backend.shutdown });
|
|
262166
262263
|
}
|
|
262167
|
-
const outroMessage =
|
|
262264
|
+
const outroMessage = site2 ? "Open your app using the frontend dev server URL" : `Dev server is available at ${theme.colors.links(backendUrl)}`;
|
|
262168
262265
|
return { outroMessage };
|
|
262169
262266
|
}
|
|
262267
|
+
async function devAction(ctx, options8) {
|
|
262268
|
+
const app = requireLinkedProject(ctx);
|
|
262269
|
+
return options8.remote ? remoteDevAction(app) : localDevAction(ctx, app, options8);
|
|
262270
|
+
}
|
|
262170
262271
|
function getDevCommand() {
|
|
262171
|
-
return new Base44Command("dev").description("Start the development server").option("-p, --port <number>", "Port for the development server").hook("preAction", validateDevOptions).action(devAction);
|
|
262272
|
+
return new Base44Command("dev").description("Start the development server").option("-p, --port <number>", "Port for the development server").option("--remote", "Serve the frontend against the production backend instead of a local one").hook("preAction", validateDevOptions).action(devAction);
|
|
262172
262273
|
}
|
|
262173
262274
|
|
|
262174
262275
|
// src/core/exec/run-script.ts
|
|
@@ -262387,7 +262488,11 @@ async function eject(ctx, options8, command2) {
|
|
|
262387
262488
|
successMessage: theme.colors.base44Orange("Project built successfully"),
|
|
262388
262489
|
errorMessage: "Failed to build project"
|
|
262389
262490
|
});
|
|
262390
|
-
await deployAction(ctx, {
|
|
262491
|
+
await deployAction(ctx, {
|
|
262492
|
+
yes: true,
|
|
262493
|
+
build: false,
|
|
262494
|
+
projectRoot: resolvedPath
|
|
262495
|
+
});
|
|
262391
262496
|
}
|
|
262392
262497
|
}
|
|
262393
262498
|
return { outroMessage: "Your new project is set and ready to use" };
|
|
@@ -262416,6 +262521,7 @@ function createProgram(context) {
|
|
|
262416
262521
|
program2.addCommand(getCreateCommand());
|
|
262417
262522
|
program2.addCommand(getScaffoldCommand());
|
|
262418
262523
|
program2.addCommand(getDashboardCommand());
|
|
262524
|
+
program2.addCommand(getBuildCommand());
|
|
262419
262525
|
program2.addCommand(getDeployCommand2());
|
|
262420
262526
|
program2.addCommand(getVisibilityCommand());
|
|
262421
262527
|
program2.addCommand(getLinkCommand());
|
|
@@ -266681,4 +266787,4 @@ export {
|
|
|
266681
266787
|
CLIExitError
|
|
266682
266788
|
};
|
|
266683
266789
|
|
|
266684
|
-
//# debugId=
|
|
266790
|
+
//# debugId=8E70D966010C6D0264756E2164756E21
|