@base44-preview/cli 0.1.25-pr.649.7ebc862 → 0.1.25-pr.649.f26dd11
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 +55 -38
- package/dist/cli/index.js.map +8 -8
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -236712,13 +236712,19 @@ import { existsSync } from "node:fs";
|
|
|
236712
236712
|
import { dirname as dirname10, join as join12 } from "node:path";
|
|
236713
236713
|
|
|
236714
236714
|
// src/core/project/fallback.ts
|
|
236715
|
-
var DEFAULT_SITE = {
|
|
236715
|
+
var DEFAULT_SITE = Object.freeze({
|
|
236716
236716
|
installCommand: "npm install",
|
|
236717
236717
|
buildCommand: "npm run build",
|
|
236718
236718
|
serveCommand: "npm run dev",
|
|
236719
236719
|
outputDirectory: "./dist"
|
|
236720
|
-
};
|
|
236720
|
+
});
|
|
236721
236721
|
var PLACEHOLDER_APP_NAME = "base44-app";
|
|
236722
|
+
var DEFAULTABLE_FIELDS = new Set([
|
|
236723
|
+
"name",
|
|
236724
|
+
"description",
|
|
236725
|
+
"visibility",
|
|
236726
|
+
"site"
|
|
236727
|
+
]);
|
|
236722
236728
|
var warningHandler = () => {};
|
|
236723
236729
|
var warned = new Set;
|
|
236724
236730
|
function setConfigWarningHandler(handler) {
|
|
@@ -236737,6 +236743,9 @@ function defaultProjectConfig() {
|
|
|
236737
236743
|
site: DEFAULT_SITE
|
|
236738
236744
|
});
|
|
236739
236745
|
}
|
|
236746
|
+
function onlyDefaultableFieldsInvalid(error) {
|
|
236747
|
+
return error.issues.every((issue) => issue.path.length > 0 && DEFAULTABLE_FIELDS.has(String(issue.path[0])));
|
|
236748
|
+
}
|
|
236740
236749
|
function salvageProjectConfig(raw, error) {
|
|
236741
236750
|
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
236742
236751
|
return defaultProjectConfig();
|
|
@@ -238403,7 +238412,7 @@ var FieldRLSSchema = looseObject({
|
|
|
238403
238412
|
delete: RLSRuleSchema.optional()
|
|
238404
238413
|
});
|
|
238405
238414
|
var PropertyDefinitionSchema = looseObject({
|
|
238406
|
-
type: union([string2(), array(string2())]),
|
|
238415
|
+
type: union([string2(), array(string2())]).optional(),
|
|
238407
238416
|
title: string2().optional(),
|
|
238408
238417
|
description: string2().optional(),
|
|
238409
238418
|
minLength: number2().int().min(0).optional(),
|
|
@@ -238425,12 +238434,13 @@ var PropertyDefinitionSchema = looseObject({
|
|
|
238425
238434
|
return record(string2(), PropertyDefinitionSchema).optional();
|
|
238426
238435
|
}
|
|
238427
238436
|
});
|
|
238437
|
+
var TopLevelPropertySchema = PropertyDefinitionSchema.refine((property) => property.type !== undefined, { message: "Top-level properties must declare a type", path: ["type"] });
|
|
238428
238438
|
var EntitySchema = looseObject({
|
|
238429
238439
|
type: literal("object").default("object"),
|
|
238430
238440
|
name: string2().min(1).regex(/^\w+$/, "Entity name must contain only letters, numbers, and underscores"),
|
|
238431
238441
|
title: string2().optional(),
|
|
238432
238442
|
description: string2().optional(),
|
|
238433
|
-
properties: record(string2(),
|
|
238443
|
+
properties: record(string2(), TopLevelPropertySchema).default({}),
|
|
238434
238444
|
required: array(string2()).optional(),
|
|
238435
238445
|
rls: EntityRLSSchema.optional(),
|
|
238436
238446
|
source: ResourceSourceSchema.default({ type: "project" })
|
|
@@ -239127,20 +239137,23 @@ async function openLogStream(filters) {
|
|
|
239127
239137
|
return { kind: "stream", events: readStreamEvents(response.body) };
|
|
239128
239138
|
}
|
|
239129
239139
|
// src/core/project/config.ts
|
|
239140
|
+
var PROJECT_ROOT_NOT_FOUND = `Project root not found. Please ensure config.jsonc or config.json exists in the project directory or ${PROJECT_SUBDIR}/ subdirectory.`;
|
|
239141
|
+
|
|
239130
239142
|
class ProjectConfigReader {
|
|
239131
239143
|
pluginSourceByNamespace = new Map;
|
|
239132
239144
|
async readProjectSettings(projectRoot) {
|
|
239145
|
+
const { root, configPath } = await this.findConfigOrThrow(projectRoot);
|
|
239146
|
+
const project = await this.readConfigFile(configPath, "safe");
|
|
239147
|
+
this.assertPluginProjectDoesNotLoadPlugins(project, configPath);
|
|
239148
|
+
return { ...project, root, configPath };
|
|
239149
|
+
}
|
|
239150
|
+
async readProjectSettingsOrDefaults(projectRoot) {
|
|
239133
239151
|
const found = this.findConfig(projectRoot);
|
|
239134
239152
|
if (!found) {
|
|
239135
239153
|
return this.defaultSettingsOrThrow(projectRoot);
|
|
239136
239154
|
}
|
|
239137
|
-
const
|
|
239138
|
-
|
|
239139
|
-
return {
|
|
239140
|
-
...this.withoutPluginsInPluginProject(project, configPath),
|
|
239141
|
-
root,
|
|
239142
|
-
configPath
|
|
239143
|
-
};
|
|
239155
|
+
const project = await this.readConfigFile(found.configPath, "lenient");
|
|
239156
|
+
return { ...project, ...found };
|
|
239144
239157
|
}
|
|
239145
239158
|
async readProjectConfig(projectRoot) {
|
|
239146
239159
|
const project = await this.readProjectSettings(projectRoot);
|
|
@@ -239170,6 +239183,13 @@ class ProjectConfigReader {
|
|
|
239170
239183
|
authConfig: localResources.authConfig
|
|
239171
239184
|
};
|
|
239172
239185
|
}
|
|
239186
|
+
async findConfigOrThrow(projectRoot) {
|
|
239187
|
+
const found = this.findConfig(projectRoot);
|
|
239188
|
+
if (!found) {
|
|
239189
|
+
throw new ConfigNotFoundError(PROJECT_ROOT_NOT_FOUND);
|
|
239190
|
+
}
|
|
239191
|
+
return found;
|
|
239192
|
+
}
|
|
239173
239193
|
findConfig(projectRoot) {
|
|
239174
239194
|
if (!projectRoot) {
|
|
239175
239195
|
return findProjectRoot();
|
|
@@ -239180,17 +239200,20 @@ class ProjectConfigReader {
|
|
|
239180
239200
|
defaultSettingsOrThrow(projectRoot) {
|
|
239181
239201
|
const root = projectRoot ?? process.cwd();
|
|
239182
239202
|
if (!existsSync(join12(root, "package.json"))) {
|
|
239183
|
-
throw new ConfigNotFoundError(
|
|
239203
|
+
throw new ConfigNotFoundError(PROJECT_ROOT_NOT_FOUND);
|
|
239184
239204
|
}
|
|
239185
|
-
const configPath = join12(root, PROJECT_SUBDIR, "config.jsonc");
|
|
239186
239205
|
warnConfigFallback(`No ${PROJECT_SUBDIR}/config.jsonc found in ${root}; using the default project config.`);
|
|
239206
|
+
const configPath = join12(root, PROJECT_SUBDIR, "config.jsonc");
|
|
239187
239207
|
return { ...defaultProjectConfig(), root, configPath };
|
|
239188
239208
|
}
|
|
239189
|
-
async
|
|
239209
|
+
async readConfigFile(configPath, mode = "strict") {
|
|
239190
239210
|
let parsed;
|
|
239191
239211
|
try {
|
|
239192
239212
|
parsed = await readJsonFile(configPath);
|
|
239193
239213
|
} catch (error) {
|
|
239214
|
+
if (mode !== "lenient") {
|
|
239215
|
+
throw error;
|
|
239216
|
+
}
|
|
239194
239217
|
warnConfigFallback(`${configPath} could not be read (${errorMessage(error)}); using the default project config.`);
|
|
239195
239218
|
return defaultProjectConfig();
|
|
239196
239219
|
}
|
|
@@ -239198,6 +239221,10 @@ class ProjectConfigReader {
|
|
|
239198
239221
|
if (result.success) {
|
|
239199
239222
|
return result.data;
|
|
239200
239223
|
}
|
|
239224
|
+
const defaultable = mode === "lenient" || mode === "safe" && onlyDefaultableFieldsInvalid(result.error);
|
|
239225
|
+
if (!defaultable) {
|
|
239226
|
+
throw new SchemaValidationError("Invalid project configuration", result.error, configPath);
|
|
239227
|
+
}
|
|
239201
239228
|
warnConfigFallback(`Invalid project configuration in ${configPath}; using defaults for the invalid fields:
|
|
239202
239229
|
${prettifyError(result.error)}`);
|
|
239203
239230
|
return salvageProjectConfig(parsed, result.error);
|
|
@@ -239231,19 +239258,10 @@ ${prettifyError(result.error)}`);
|
|
|
239231
239258
|
authConfig
|
|
239232
239259
|
};
|
|
239233
239260
|
}
|
|
239234
|
-
|
|
239235
|
-
|
|
239236
|
-
|
|
239237
|
-
throw new SchemaValidationError("Invalid project configuration", result.error, configPath);
|
|
239238
|
-
}
|
|
239239
|
-
return result.data;
|
|
239240
|
-
}
|
|
239241
|
-
withoutPluginsInPluginProject(project, configPath) {
|
|
239242
|
-
if (!project.plugin || project.plugins.length === 0) {
|
|
239243
|
-
return project;
|
|
239261
|
+
assertPluginProjectDoesNotLoadPlugins(project, configPath) {
|
|
239262
|
+
if (project.plugin && project.plugins.length > 0) {
|
|
239263
|
+
throw new ConfigInvalidError("Plugin projects cannot define plugins in this version.", configPath);
|
|
239244
239264
|
}
|
|
239245
|
-
warnConfigFallback(`${configPath}: plugin projects cannot define plugins in this version; ignoring 'plugins'.`);
|
|
239246
|
-
return { ...project, plugins: [] };
|
|
239247
239265
|
}
|
|
239248
239266
|
registerPluginNamespace(namespace, source, configPath) {
|
|
239249
239267
|
const existingSource = this.pluginSourceByNamespace.get(namespace);
|
|
@@ -239260,15 +239278,10 @@ ${prettifyError(result.error)}`);
|
|
|
239260
239278
|
}
|
|
239261
239279
|
async readPluginConfig(plugin, hostConfigPath) {
|
|
239262
239280
|
const pluginRoot = resolvePluginRoot(plugin.source, dirname10(hostConfigPath));
|
|
239263
|
-
const configPath =
|
|
239264
|
-
|
|
239265
|
-
throw new ConfigNotFoundError(`Project root not found. Please ensure config.jsonc or config.json exists in the project directory or ${PROJECT_SUBDIR}/ subdirectory.`);
|
|
239266
|
-
}
|
|
239267
|
-
const project = await this.readPluginConfigFile(configPath);
|
|
239281
|
+
const { configPath } = await this.findConfigOrThrow(pluginRoot);
|
|
239282
|
+
const project = await this.readConfigFile(configPath);
|
|
239268
239283
|
const namespace = requirePluginNamespace(project, plugin.source, configPath);
|
|
239269
|
-
|
|
239270
|
-
throw new ConfigInvalidError("Plugin projects cannot define plugins in this version.", configPath);
|
|
239271
|
-
}
|
|
239284
|
+
this.assertPluginProjectDoesNotLoadPlugins(project, configPath);
|
|
239272
239285
|
return { configPath, namespace, project, source: plugin.source };
|
|
239273
239286
|
}
|
|
239274
239287
|
async readPluginResources(project, configPath, namespace) {
|
|
@@ -239347,6 +239360,10 @@ async function readProjectSettings(projectRoot) {
|
|
|
239347
239360
|
const reader = new ProjectConfigReader;
|
|
239348
239361
|
return await reader.readProjectSettings(projectRoot);
|
|
239349
239362
|
}
|
|
239363
|
+
async function readProjectSettingsOrDefaults(projectRoot) {
|
|
239364
|
+
const reader = new ProjectConfigReader;
|
|
239365
|
+
return await reader.readProjectSettingsOrDefaults(projectRoot);
|
|
239366
|
+
}
|
|
239350
239367
|
function errorMessage(error) {
|
|
239351
239368
|
return error instanceof Error ? error.message : String(error);
|
|
239352
239369
|
}
|
|
@@ -251730,7 +251747,7 @@ async function siteDevAction(ctx, forwarded) {
|
|
|
251730
251747
|
if (!app?.projectRoot) {
|
|
251731
251748
|
throw new ConfigInvalidError("base44 site dev requires a linked local project. Run it from a project with base44/.app.jsonc.");
|
|
251732
251749
|
}
|
|
251733
|
-
const project = await
|
|
251750
|
+
const project = await readProjectSettingsOrDefaults(app.projectRoot);
|
|
251734
251751
|
const site = siteOrDefault(project);
|
|
251735
251752
|
const serveCommand = site.serveCommand ?? DEFAULT_SERVE_COMMAND;
|
|
251736
251753
|
const command = [serveCommand, ...forwarded].join(" ");
|
|
@@ -251752,7 +251769,7 @@ function getSiteDevCommand() {
|
|
|
251752
251769
|
async function installAction({
|
|
251753
251770
|
runTask
|
|
251754
251771
|
}) {
|
|
251755
|
-
const project = await
|
|
251772
|
+
const project = await readProjectSettingsOrDefaults();
|
|
251756
251773
|
const { installCommand } = siteOrDefault(project);
|
|
251757
251774
|
await runTask("Installing site dependencies...", () => execa({ cwd: project.root, shell: true })`${installCommand}`, {
|
|
251758
251775
|
successMessage: "Dependencies installed",
|
|
@@ -253232,7 +253249,7 @@ class Validator {
|
|
|
253232
253249
|
error: this.createValidationError(`Error in field ${fieldPath}: Input should be a valid ${types.join(" or ")}`)
|
|
253233
253250
|
};
|
|
253234
253251
|
}
|
|
253235
|
-
const propertyType = property.type;
|
|
253252
|
+
const propertyType = property.type ?? "string";
|
|
253236
253253
|
if (!fieldTypes.includes(propertyType)) {
|
|
253237
253254
|
return {
|
|
253238
253255
|
hasError: true,
|
|
@@ -260629,4 +260646,4 @@ export {
|
|
|
260629
260646
|
runCLI
|
|
260630
260647
|
};
|
|
260631
260648
|
|
|
260632
|
-
//# debugId=
|
|
260649
|
+
//# debugId=75B8BBCB3D7C918E64756E2164756E21
|