@base44-preview/cli 0.1.16-pr.626.b09d9ce → 0.1.16-pr.626.e28b7e8
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 +352 -355
- package/dist/cli/index.js.map +15 -15
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -228657,6 +228657,20 @@ function isCLIError(error) {
|
|
|
228657
228657
|
function isUserError(error) {
|
|
228658
228658
|
return error instanceof UserError;
|
|
228659
228659
|
}
|
|
228660
|
+
var STEP = Symbol.for("base44.commandStep");
|
|
228661
|
+
async function tagStep(step, run) {
|
|
228662
|
+
try {
|
|
228663
|
+
return await run();
|
|
228664
|
+
} catch (error) {
|
|
228665
|
+
if (error !== null && typeof error === "object" && !(STEP in error) && Object.isExtensible(error)) {
|
|
228666
|
+
Object.defineProperty(error, STEP, { value: step, enumerable: false });
|
|
228667
|
+
}
|
|
228668
|
+
throw error;
|
|
228669
|
+
}
|
|
228670
|
+
}
|
|
228671
|
+
function stepOf(error) {
|
|
228672
|
+
return error !== null && typeof error === "object" && STEP in error ? error[STEP] : undefined;
|
|
228673
|
+
}
|
|
228660
228674
|
|
|
228661
228675
|
// src/core/utils/fs.ts
|
|
228662
228676
|
async function pathExists(path) {
|
|
@@ -246795,6 +246809,49 @@ async function deployAll(projectData, options) {
|
|
|
246795
246809
|
}
|
|
246796
246810
|
return { connectorResults };
|
|
246797
246811
|
}
|
|
246812
|
+
// src/core/project/target.ts
|
|
246813
|
+
import { dirname as dirname13, join as join19, resolve as resolve6 } from "node:path";
|
|
246814
|
+
var DEFAULT_BUILD_COMMAND = "npm run build";
|
|
246815
|
+
var DEFAULT_OUTPUT_DIRECTORY = "dist";
|
|
246816
|
+
async function resolveBuildTarget(projectRoot, overrides = {}) {
|
|
246817
|
+
const project = await readSettingsIfPresent(projectRoot);
|
|
246818
|
+
const root = project?.root ?? projectRoot ?? process.cwd();
|
|
246819
|
+
return {
|
|
246820
|
+
root,
|
|
246821
|
+
configDir: project ? dirname13(project.configPath) : join19(root, PROJECT_SUBDIR),
|
|
246822
|
+
buildCommand: project ? project.site?.buildCommand : DEFAULT_BUILD_COMMAND,
|
|
246823
|
+
outputDir: outputDirectory(project, root, overrides.outputDir),
|
|
246824
|
+
entitiesDir: project?.entitiesDir ?? "entities",
|
|
246825
|
+
agentsDir: project?.agentsDir ?? "agents"
|
|
246826
|
+
};
|
|
246827
|
+
}
|
|
246828
|
+
function outputDirectory(project, root, override) {
|
|
246829
|
+
const configured = override ?? (project ? project.site?.outputDirectory : DEFAULT_OUTPUT_DIRECTORY);
|
|
246830
|
+
return configured ? resolve6(root, configured) : null;
|
|
246831
|
+
}
|
|
246832
|
+
function requireOutputDir(target) {
|
|
246833
|
+
if (target.outputDir === null) {
|
|
246834
|
+
throw new ConfigNotFoundError("No site configuration found.", {
|
|
246835
|
+
hints: [
|
|
246836
|
+
{
|
|
246837
|
+
message: `Add 'site.outputDirectory' to your config.jsonc (e.g., "site": { "outputDirectory": "dist" })`
|
|
246838
|
+
},
|
|
246839
|
+
{ message: `Or pass --output-dir <dir>, relative to ${target.root}` }
|
|
246840
|
+
]
|
|
246841
|
+
});
|
|
246842
|
+
}
|
|
246843
|
+
return target.outputDir;
|
|
246844
|
+
}
|
|
246845
|
+
async function readSettingsIfPresent(projectRoot) {
|
|
246846
|
+
try {
|
|
246847
|
+
return await readProjectSettings(projectRoot);
|
|
246848
|
+
} catch (error) {
|
|
246849
|
+
if (error instanceof ConfigNotFoundError) {
|
|
246850
|
+
return null;
|
|
246851
|
+
}
|
|
246852
|
+
throw error;
|
|
246853
|
+
}
|
|
246854
|
+
}
|
|
246798
246855
|
// src/core/clients/base44-client.ts
|
|
246799
246856
|
var retriedRequests = new WeakSet;
|
|
246800
246857
|
async function captureRequestBody(request, options) {
|
|
@@ -247248,179 +247305,6 @@ async function resolveBranchName(name) {
|
|
|
247248
247305
|
return matches[0].id;
|
|
247249
247306
|
}
|
|
247250
247307
|
|
|
247251
|
-
// src/core/version/publish.ts
|
|
247252
|
-
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
247253
|
-
|
|
247254
|
-
// src/core/version/schema.ts
|
|
247255
|
-
var DeclareVersionResponseSchema = object({
|
|
247256
|
-
session_id: string2(),
|
|
247257
|
-
uploads: array(object({
|
|
247258
|
-
path: string2(),
|
|
247259
|
-
url: string2(),
|
|
247260
|
-
content_type: string2(),
|
|
247261
|
-
content_length: number2(),
|
|
247262
|
-
checksum_sha256: string2()
|
|
247263
|
-
}))
|
|
247264
|
-
}).transform((data) => ({
|
|
247265
|
-
sessionId: data.session_id,
|
|
247266
|
-
uploads: data.uploads.map((upload) => ({
|
|
247267
|
-
path: upload.path,
|
|
247268
|
-
url: upload.url,
|
|
247269
|
-
contentType: upload.content_type,
|
|
247270
|
-
contentLength: upload.content_length,
|
|
247271
|
-
checksumSha256: upload.checksum_sha256
|
|
247272
|
-
}))
|
|
247273
|
-
}));
|
|
247274
|
-
var CreateVersionResponseSchema = object({
|
|
247275
|
-
version_id: string2(),
|
|
247276
|
-
manifest_hash: string2()
|
|
247277
|
-
}).transform((data) => ({
|
|
247278
|
-
versionId: data.version_id,
|
|
247279
|
-
manifestHash: data.manifest_hash
|
|
247280
|
-
}));
|
|
247281
|
-
var EnvironmentResponseSchema = object({
|
|
247282
|
-
name: string2(),
|
|
247283
|
-
version_id: string2(),
|
|
247284
|
-
manifest_hash: string2(),
|
|
247285
|
-
deployment_id: string2()
|
|
247286
|
-
}).transform((data) => ({
|
|
247287
|
-
name: data.name,
|
|
247288
|
-
versionId: data.version_id,
|
|
247289
|
-
manifestHash: data.manifest_hash,
|
|
247290
|
-
deploymentId: data.deployment_id
|
|
247291
|
-
}));
|
|
247292
|
-
|
|
247293
|
-
// src/core/version/api.ts
|
|
247294
|
-
var DEFAULT_VERSION_UPLOAD_CONCURRENCY = 8;
|
|
247295
|
-
var MAX_VERSION_UPLOAD_CONCURRENCY = 16;
|
|
247296
|
-
function declaredFile({ path, size, digest }) {
|
|
247297
|
-
return { path, size, digest };
|
|
247298
|
-
}
|
|
247299
|
-
function declaredModule(module) {
|
|
247300
|
-
return { ...declaredFile(module), type: module.type };
|
|
247301
|
-
}
|
|
247302
|
-
function declaredAssetsConfig(config) {
|
|
247303
|
-
const stated = {
|
|
247304
|
-
html_handling: config?.htmlHandling ?? null,
|
|
247305
|
-
not_found_handling: config?.notFoundHandling ?? null,
|
|
247306
|
-
run_worker_first: config?.runWorkerFirst ?? null,
|
|
247307
|
-
headers: config?.headers ?? null,
|
|
247308
|
-
redirects: config?.redirects ?? null
|
|
247309
|
-
};
|
|
247310
|
-
return Object.values(stated).every((v) => v === null) ? null : stated;
|
|
247311
|
-
}
|
|
247312
|
-
async function post(path, json, doing) {
|
|
247313
|
-
try {
|
|
247314
|
-
return await getAppClient().post(path, { json, timeout: 180000 });
|
|
247315
|
-
} catch (error) {
|
|
247316
|
-
throw await ApiError.fromHttpError(error, doing);
|
|
247317
|
-
}
|
|
247318
|
-
}
|
|
247319
|
-
var KEYED_RETRY = {
|
|
247320
|
-
limit: 3,
|
|
247321
|
-
methods: ["patch"],
|
|
247322
|
-
statusCodes: [408, 500, 502, 503, 504],
|
|
247323
|
-
retryOnTimeout: true
|
|
247324
|
-
};
|
|
247325
|
-
async function patch(path, json, doing, retry) {
|
|
247326
|
-
try {
|
|
247327
|
-
return await getAppClient().patch(path, {
|
|
247328
|
-
json,
|
|
247329
|
-
timeout: 180000,
|
|
247330
|
-
...retry ? { retry } : {}
|
|
247331
|
-
});
|
|
247332
|
-
} catch (error) {
|
|
247333
|
-
throw await ApiError.fromHttpError(error, doing);
|
|
247334
|
-
}
|
|
247335
|
-
}
|
|
247336
|
-
function parse10(schema, body, what) {
|
|
247337
|
-
const result = schema.safeParse(body);
|
|
247338
|
-
if (!result.success) {
|
|
247339
|
-
throw new SchemaValidationError(`Invalid ${what} response from server`, result.error);
|
|
247340
|
-
}
|
|
247341
|
-
return result.data;
|
|
247342
|
-
}
|
|
247343
|
-
async function createVersion(artifacts, options = {}) {
|
|
247344
|
-
const declared = parse10(DeclareVersionResponseSchema, await (await post("versions", {
|
|
247345
|
-
static_bundle: artifacts.files.map(declaredFile),
|
|
247346
|
-
...artifacts.siteWorker ? {
|
|
247347
|
-
site_worker: {
|
|
247348
|
-
main: artifacts.siteWorker.main,
|
|
247349
|
-
modules: artifacts.siteWorker.modules.map(declaredModule),
|
|
247350
|
-
assets: artifacts.siteWorker.assets.map(declaredFile),
|
|
247351
|
-
compatibility_date: artifacts.siteWorker.compatibilityDate,
|
|
247352
|
-
compatibility_flags: artifacts.siteWorker.compatibilityFlags,
|
|
247353
|
-
assets_config: declaredAssetsConfig(artifacts.siteWorker.assetsConfig)
|
|
247354
|
-
}
|
|
247355
|
-
} : {},
|
|
247356
|
-
entities: artifacts.entities,
|
|
247357
|
-
agents: artifacts.agents,
|
|
247358
|
-
source_commit: options.sourceCommit
|
|
247359
|
-
}, "declaring a version")).json(), "declare");
|
|
247360
|
-
const declaredFiles = [
|
|
247361
|
-
...artifacts.files,
|
|
247362
|
-
...artifacts.siteWorker?.modules ?? [],
|
|
247363
|
-
...artifacts.siteWorker?.assets ?? []
|
|
247364
|
-
];
|
|
247365
|
-
options.progress?.onDeclared?.({ fileCount: declaredFiles.length });
|
|
247366
|
-
if (declared.uploads.length !== declaredFiles.length) {
|
|
247367
|
-
throw new InternalError(`Declared ${declaredFiles.length} files but the server signed ${declared.uploads.length} upload URLs.`);
|
|
247368
|
-
}
|
|
247369
|
-
const drifted = declared.uploads.findIndex((upload, index) => upload.path !== declaredFiles[index].path);
|
|
247370
|
-
if (drifted !== -1) {
|
|
247371
|
-
throw new InternalError(`Upload ${drifted} is signed for ${declared.uploads[drifted].path}, but that slot declared ${declaredFiles[drifted].path}.`);
|
|
247372
|
-
}
|
|
247373
|
-
let uploadedFiles = 0;
|
|
247374
|
-
await pMap(declared.uploads, async (upload, index) => {
|
|
247375
|
-
await putPresigned(upload, declaredFiles[index].absolutePath);
|
|
247376
|
-
uploadedFiles++;
|
|
247377
|
-
options.progress?.onUpload?.({
|
|
247378
|
-
uploadedFiles,
|
|
247379
|
-
totalFiles: declared.uploads.length
|
|
247380
|
-
});
|
|
247381
|
-
}, { concurrency: options.concurrency ?? DEFAULT_VERSION_UPLOAD_CONCURRENCY });
|
|
247382
|
-
return parse10(CreateVersionResponseSchema, await (await post(`versions/${encodeURIComponent(declared.sessionId)}/finalize`, {}, "creating a version")).json(), "create version");
|
|
247383
|
-
}
|
|
247384
|
-
async function setEnvironmentVersion(environment, versionId, options = {}) {
|
|
247385
|
-
return parse10(EnvironmentResponseSchema, await (await patch(`environments/${encodeURIComponent(environment)}`, {
|
|
247386
|
-
version_id: versionId,
|
|
247387
|
-
...options.idempotencyKey ? { idempotency_key: options.idempotencyKey } : {}
|
|
247388
|
-
}, "setting the environment's version", options.idempotencyKey ? KEYED_RETRY : undefined)).json(), "environment");
|
|
247389
|
-
}
|
|
247390
|
-
|
|
247391
|
-
// src/core/version/publish.ts
|
|
247392
|
-
var STEP = Symbol.for("base44.publishStep");
|
|
247393
|
-
var DEFAULT_ENVIRONMENT = "production";
|
|
247394
|
-
async function tagStep(step, run) {
|
|
247395
|
-
try {
|
|
247396
|
-
return await run();
|
|
247397
|
-
} catch (error) {
|
|
247398
|
-
if (error !== null && typeof error === "object" && !(STEP in error) && Object.isExtensible(error)) {
|
|
247399
|
-
Object.defineProperty(error, STEP, { value: step, enumerable: false });
|
|
247400
|
-
}
|
|
247401
|
-
throw error;
|
|
247402
|
-
}
|
|
247403
|
-
}
|
|
247404
|
-
function stepOf(error) {
|
|
247405
|
-
return error !== null && typeof error === "object" && STEP in error ? error[STEP] : undefined;
|
|
247406
|
-
}
|
|
247407
|
-
async function publishVersion(artifacts, options = {}) {
|
|
247408
|
-
const version = await tagStep("create_version", () => createVersion(artifacts, {
|
|
247409
|
-
sourceCommit: options.sourceCommit,
|
|
247410
|
-
concurrency: options.concurrency,
|
|
247411
|
-
progress: options.progress
|
|
247412
|
-
}));
|
|
247413
|
-
const environment = await tagStep("deploy", () => setEnvironmentVersion(options.target ?? DEFAULT_ENVIRONMENT, version.versionId, {
|
|
247414
|
-
idempotencyKey: randomUUID4()
|
|
247415
|
-
}));
|
|
247416
|
-
return {
|
|
247417
|
-
environment: environment.name,
|
|
247418
|
-
versionId: environment.versionId,
|
|
247419
|
-
manifestHash: environment.manifestHash,
|
|
247420
|
-
deploymentId: environment.deploymentId
|
|
247421
|
-
};
|
|
247422
|
-
}
|
|
247423
|
-
|
|
247424
247308
|
// src/cli/utils/command/Base44Command.ts
|
|
247425
247309
|
function writeJsonSuccess(result) {
|
|
247426
247310
|
if (result.stdout) {
|
|
@@ -247811,7 +247695,7 @@ function getActorsCommand() {
|
|
|
247811
247695
|
}
|
|
247812
247696
|
|
|
247813
247697
|
// src/cli/commands/agent-skills/pull.ts
|
|
247814
|
-
import { dirname as
|
|
247698
|
+
import { dirname as dirname14, join as join20 } from "node:path";
|
|
247815
247699
|
// src/core/utils/dependencies.ts
|
|
247816
247700
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
247817
247701
|
function verifyDenoInstalled(context) {
|
|
@@ -247900,7 +247784,7 @@ async function pullAction({
|
|
|
247900
247784
|
runTask
|
|
247901
247785
|
}) {
|
|
247902
247786
|
const { project } = await readProjectConfig();
|
|
247903
|
-
const dir =
|
|
247787
|
+
const dir = join20(dirname14(project.configPath), project.agentSkillsDir);
|
|
247904
247788
|
const remote = await runTask("Fetching agent skills from Base44", () => fetchAgentSkills(), {
|
|
247905
247789
|
successMessage: "Agent skills fetched successfully",
|
|
247906
247790
|
errorMessage: "Failed to fetch agent skills"
|
|
@@ -247956,14 +247840,14 @@ function getAgentSkillsCommand() {
|
|
|
247956
247840
|
}
|
|
247957
247841
|
|
|
247958
247842
|
// src/cli/commands/agents/pull.ts
|
|
247959
|
-
import { dirname as
|
|
247843
|
+
import { dirname as dirname15, join as join21 } from "node:path";
|
|
247960
247844
|
async function pullAgentsAction({
|
|
247961
247845
|
log,
|
|
247962
247846
|
runTask
|
|
247963
247847
|
}) {
|
|
247964
247848
|
const { project } = await readProjectConfig();
|
|
247965
|
-
const configDir =
|
|
247966
|
-
const agentsDir =
|
|
247849
|
+
const configDir = dirname15(project.configPath);
|
|
247850
|
+
const agentsDir = join21(configDir, project.agentsDir);
|
|
247967
247851
|
const remoteAgents = await runTask("Fetching agents from Base44", async () => {
|
|
247968
247852
|
return await fetchAgents();
|
|
247969
247853
|
}, {
|
|
@@ -248033,12 +247917,12 @@ function getAgentsCommand() {
|
|
|
248033
247917
|
}
|
|
248034
247918
|
|
|
248035
247919
|
// src/cli/commands/auth/password-login.ts
|
|
248036
|
-
import { dirname as
|
|
247920
|
+
import { dirname as dirname16, join as join22 } from "node:path";
|
|
248037
247921
|
async function passwordLoginAction({ log, runTask }, action) {
|
|
248038
247922
|
const shouldEnable = action === "enable";
|
|
248039
247923
|
const { project } = await readProjectConfig();
|
|
248040
|
-
const configDir =
|
|
248041
|
-
const authDir =
|
|
247924
|
+
const configDir = dirname16(project.configPath);
|
|
247925
|
+
const authDir = join22(configDir, project.authDir);
|
|
248042
247926
|
const updated = await runTask("Updating local auth config", async () => {
|
|
248043
247927
|
const current = await readAuthConfig(authDir) ?? DEFAULT_AUTH_CONFIG;
|
|
248044
247928
|
const merged = { ...current, enableUsernamePassword: shouldEnable };
|
|
@@ -248058,14 +247942,14 @@ function getPasswordLoginCommand() {
|
|
|
248058
247942
|
}
|
|
248059
247943
|
|
|
248060
247944
|
// src/cli/commands/auth/pull.ts
|
|
248061
|
-
import { dirname as
|
|
247945
|
+
import { dirname as dirname17, join as join23 } from "node:path";
|
|
248062
247946
|
async function pullAuthAction({
|
|
248063
247947
|
log,
|
|
248064
247948
|
runTask
|
|
248065
247949
|
}) {
|
|
248066
247950
|
const { project } = await readProjectConfig();
|
|
248067
|
-
const configDir =
|
|
248068
|
-
const authDir =
|
|
247951
|
+
const configDir = dirname17(project.configPath);
|
|
247952
|
+
const authDir = join23(configDir, project.authDir);
|
|
248069
247953
|
const remoteConfig = await runTask("Fetching auth config from Base44", async () => {
|
|
248070
247954
|
return await pullAuthConfig();
|
|
248071
247955
|
}, {
|
|
@@ -248129,7 +248013,7 @@ function getAuthPushCommand() {
|
|
|
248129
248013
|
}
|
|
248130
248014
|
|
|
248131
248015
|
// src/cli/commands/auth/social-login.ts
|
|
248132
|
-
import { dirname as
|
|
248016
|
+
import { dirname as dirname18, join as join24, resolve as resolve7 } from "node:path";
|
|
248133
248017
|
var PROVIDER_LABELS = {
|
|
248134
248018
|
google: "Google",
|
|
248135
248019
|
microsoft: "Microsoft",
|
|
@@ -248169,7 +248053,7 @@ async function socialLoginAction({ log, isNonInteractive, runTask }, provider, a
|
|
|
248169
248053
|
let clientSecret;
|
|
248170
248054
|
if (useCustomOAuth && oauth && oauthCli && hasSecretOptions(options)) {
|
|
248171
248055
|
if (options.envFile) {
|
|
248172
|
-
const secrets = await parseEnvFile(
|
|
248056
|
+
const secrets = await parseEnvFile(resolve7(options.envFile));
|
|
248173
248057
|
const value = secrets[oauthCli.envVar];
|
|
248174
248058
|
if (!value) {
|
|
248175
248059
|
throw new InvalidInputError(`Key "${oauthCli.envVar}" not found in ${options.envFile}.`);
|
|
@@ -248199,8 +248083,8 @@ async function socialLoginAction({ log, isNonInteractive, runTask }, provider, a
|
|
|
248199
248083
|
}
|
|
248200
248084
|
}
|
|
248201
248085
|
const { project } = await readProjectConfig();
|
|
248202
|
-
const configDir =
|
|
248203
|
-
const authDir =
|
|
248086
|
+
const configDir = dirname18(project.configPath);
|
|
248087
|
+
const authDir = join24(configDir, project.authDir);
|
|
248204
248088
|
const { config: updated } = await runTask("Updating local auth config", async () => updateSocialLoginConfig(authDir, provider, shouldEnable, useCustomOAuth && options.clientId ? { clientId: options.clientId } : undefined));
|
|
248205
248089
|
if (clientSecret) {
|
|
248206
248090
|
await runTask("Saving client secret", async () => pushCustomOAuthSecret(provider, clientSecret));
|
|
@@ -248225,7 +248109,7 @@ function getSocialLoginCommand() {
|
|
|
248225
248109
|
}
|
|
248226
248110
|
|
|
248227
248111
|
// src/cli/commands/auth/sso.ts
|
|
248228
|
-
import { dirname as
|
|
248112
|
+
import { dirname as dirname19, join as join25, resolve as resolve8 } from "node:path";
|
|
248229
248113
|
var SSOConfigFileSchema = object({
|
|
248230
248114
|
provider: _enum(Object.values(KNOWN_SSO_PROVIDERS)),
|
|
248231
248115
|
clientId: string2(),
|
|
@@ -248241,7 +248125,7 @@ var SSOConfigFileSchema = object({
|
|
|
248241
248125
|
ssoName: string2().optional()
|
|
248242
248126
|
});
|
|
248243
248127
|
async function loadSSOConfigFile(filePath) {
|
|
248244
|
-
const resolved =
|
|
248128
|
+
const resolved = resolve8(filePath);
|
|
248245
248129
|
const raw = await readJsonFile(resolved);
|
|
248246
248130
|
const result = SSOConfigFileSchema.safeParse(raw);
|
|
248247
248131
|
if (!result.success) {
|
|
@@ -248329,7 +248213,7 @@ async function ssoEnableAction({ isNonInteractive, runTask }, options) {
|
|
|
248329
248213
|
}
|
|
248330
248214
|
let clientSecret;
|
|
248331
248215
|
if (merged.envFile && !merged.clientSecret) {
|
|
248332
|
-
const secrets = await parseEnvFile(
|
|
248216
|
+
const secrets = await parseEnvFile(resolve8(merged.envFile));
|
|
248333
248217
|
const value = secrets.sso_client_secret;
|
|
248334
248218
|
if (!value) {
|
|
248335
248219
|
throw new InvalidInputError(`Key "sso_client_secret" not found in ${merged.envFile}.`);
|
|
@@ -248388,8 +248272,8 @@ async function ssoEnableAction({ isNonInteractive, runTask }, options) {
|
|
|
248388
248272
|
throw error;
|
|
248389
248273
|
}
|
|
248390
248274
|
const { project } = await readProjectConfig();
|
|
248391
|
-
const configDir =
|
|
248392
|
-
const authDir =
|
|
248275
|
+
const configDir = dirname19(project.configPath);
|
|
248276
|
+
const authDir = join25(configDir, project.authDir);
|
|
248393
248277
|
await runTask("Updating local auth config", async () => updateSSOConfig(authDir, provider, true));
|
|
248394
248278
|
await runTask("Saving SSO credentials", async () => pushSSOSecrets(secrets));
|
|
248395
248279
|
return {
|
|
@@ -248404,8 +248288,8 @@ async function ssoDisableAction({ log, runTask }, options) {
|
|
|
248404
248288
|
throw new InvalidInputError("Configuration options cannot be used with disable. To disable SSO: base44 auth sso disable");
|
|
248405
248289
|
}
|
|
248406
248290
|
const { project } = await readProjectConfig();
|
|
248407
|
-
const configDir =
|
|
248408
|
-
const authDir =
|
|
248291
|
+
const configDir = dirname19(project.configPath);
|
|
248292
|
+
const authDir = join25(configDir, project.authDir);
|
|
248409
248293
|
const updated = await runTask("Updating local auth config", async () => updateSSOConfig(authDir, null, false));
|
|
248410
248294
|
await runTask("Removing SSO credentials", async () => deleteSSOSecrets());
|
|
248411
248295
|
if (!hasAnyLoginMethod(updated)) {
|
|
@@ -249287,13 +249171,13 @@ function getConnectorsListAvailableCommand() {
|
|
|
249287
249171
|
}
|
|
249288
249172
|
|
|
249289
249173
|
// src/cli/commands/connectors/pull.ts
|
|
249290
|
-
import { dirname as
|
|
249174
|
+
import { dirname as dirname20, join as join26, resolve as resolve9 } from "node:path";
|
|
249291
249175
|
async function resolveConnectorsDir(options) {
|
|
249292
249176
|
if (!getAppContext().projectRoot) {
|
|
249293
|
-
return
|
|
249177
|
+
return resolve9(options.dir ?? "connectors");
|
|
249294
249178
|
}
|
|
249295
249179
|
const { project } = await readProjectConfig();
|
|
249296
|
-
return
|
|
249180
|
+
return join26(dirname20(project.configPath), project.connectorsDir);
|
|
249297
249181
|
}
|
|
249298
249182
|
async function pullConnectorsAction({ log, runTask, jsonMode }, options) {
|
|
249299
249183
|
const connectorsDir = await resolveConnectorsDir(options);
|
|
@@ -249334,10 +249218,10 @@ function getConnectorsPullCommand() {
|
|
|
249334
249218
|
}
|
|
249335
249219
|
|
|
249336
249220
|
// src/cli/commands/connectors/push.ts
|
|
249337
|
-
import { resolve as
|
|
249221
|
+
import { resolve as resolve10 } from "node:path";
|
|
249338
249222
|
async function readConnectorsToPush(options) {
|
|
249339
249223
|
if (!getAppContext().projectRoot) {
|
|
249340
|
-
return readAllConnectors(
|
|
249224
|
+
return readAllConnectors(resolve10(options.dir ?? "connectors"));
|
|
249341
249225
|
}
|
|
249342
249226
|
const { connectors } = await readProjectConfig();
|
|
249343
249227
|
return connectors;
|
|
@@ -249680,11 +249564,11 @@ function getListCommand() {
|
|
|
249680
249564
|
}
|
|
249681
249565
|
|
|
249682
249566
|
// src/cli/commands/functions/pull.ts
|
|
249683
|
-
import { dirname as
|
|
249567
|
+
import { dirname as dirname21, join as join27 } from "node:path";
|
|
249684
249568
|
async function pullFunctionsAction({ log, runTask }, name) {
|
|
249685
249569
|
const { project, functions } = await readProjectConfig();
|
|
249686
|
-
const configDir =
|
|
249687
|
-
const functionsDir =
|
|
249570
|
+
const configDir = dirname21(project.configPath);
|
|
249571
|
+
const functionsDir = join27(configDir, project.functionsDir);
|
|
249688
249572
|
const pluginFunctionNames = new Set(functions.filter((fn) => fn.source.type === "plugin").map((fn) => fn.name));
|
|
249689
249573
|
const remoteFunctions = await runTask("Fetching functions from Base44", async () => {
|
|
249690
249574
|
const { functions } = await listDeployedFunctions();
|
|
@@ -249784,150 +249668,11 @@ async function maybeAskToBuild(isNonInteractive, buildCommand) {
|
|
|
249784
249668
|
});
|
|
249785
249669
|
return !Ct(answer) && answer;
|
|
249786
249670
|
}
|
|
249787
|
-
// src/core/version/artifacts.ts
|
|
249788
|
-
import { createHash as createHash2 } from "node:crypto";
|
|
249789
|
-
import { join as join28, resolve as resolve11 } from "node:path";
|
|
249790
249671
|
|
|
249791
|
-
// src/core/version/project.ts
|
|
249792
|
-
import { dirname as dirname21, join as join27, resolve as resolve10 } from "node:path";
|
|
249793
|
-
var DEFAULT_BUILD_COMMAND = "npm run build";
|
|
249794
|
-
var DEFAULT_OUTPUT_DIRECTORY = "dist";
|
|
249795
|
-
async function resolvePublishTarget(projectRoot, overrides = {}) {
|
|
249796
|
-
const project = await readSettingsIfPresent(projectRoot);
|
|
249797
|
-
const root = project?.root ?? projectRoot ?? process.cwd();
|
|
249798
|
-
return {
|
|
249799
|
-
root,
|
|
249800
|
-
configDir: project ? dirname21(project.configPath) : join27(root, PROJECT_SUBDIR),
|
|
249801
|
-
buildCommand: project ? project.site?.buildCommand : DEFAULT_BUILD_COMMAND,
|
|
249802
|
-
outputDir: outputDirectory(project, root, overrides.outputDir),
|
|
249803
|
-
entitiesDir: project?.entitiesDir ?? "entities",
|
|
249804
|
-
agentsDir: project?.agentsDir ?? "agents"
|
|
249805
|
-
};
|
|
249806
|
-
}
|
|
249807
|
-
function outputDirectory(project, root, override) {
|
|
249808
|
-
const configured = override ?? (project ? project.site?.outputDirectory : DEFAULT_OUTPUT_DIRECTORY);
|
|
249809
|
-
return configured ? resolve10(root, configured) : null;
|
|
249810
|
-
}
|
|
249811
|
-
function requireOutputDir(target) {
|
|
249812
|
-
if (target.outputDir === null) {
|
|
249813
|
-
throw new ConfigNotFoundError("No site configuration found.", {
|
|
249814
|
-
hints: [
|
|
249815
|
-
{
|
|
249816
|
-
message: `Add 'site.outputDirectory' to your config.jsonc (e.g., "site": { "outputDirectory": "dist" })`
|
|
249817
|
-
},
|
|
249818
|
-
{ message: `Or pass --output-dir <dir>, relative to ${target.root}` }
|
|
249819
|
-
]
|
|
249820
|
-
});
|
|
249821
|
-
}
|
|
249822
|
-
return target.outputDir;
|
|
249823
|
-
}
|
|
249824
|
-
async function readSettingsIfPresent(projectRoot) {
|
|
249825
|
-
try {
|
|
249826
|
-
return await readProjectSettings(projectRoot);
|
|
249827
|
-
} catch (error) {
|
|
249828
|
-
if (error instanceof ConfigNotFoundError) {
|
|
249829
|
-
return null;
|
|
249830
|
-
}
|
|
249831
|
-
throw error;
|
|
249832
|
-
}
|
|
249833
|
-
}
|
|
249834
|
-
|
|
249835
|
-
// src/core/version/artifacts.ts
|
|
249836
|
-
var MAX_FILE_COUNT = 50000;
|
|
249837
|
-
var HASH_CONCURRENCY = 32;
|
|
249838
|
-
var ENTRY2 = "index.html";
|
|
249839
|
-
async function digestFile(absolutePath) {
|
|
249840
|
-
const hash = await hashFileInto(createHash2("sha256"), absolutePath);
|
|
249841
|
-
return `sha256:${hash.digest("hex")}`;
|
|
249842
|
-
}
|
|
249843
|
-
async function collectBuildOutput(outputDir, options = {}) {
|
|
249844
|
-
const found = await describeBuildOutput(outputDir);
|
|
249845
|
-
if (found.length > MAX_FILE_COUNT) {
|
|
249846
|
-
throw new InvalidInputError(`Too many files: found ${found.length}, the limit is ${MAX_FILE_COUNT}.`);
|
|
249847
|
-
}
|
|
249848
|
-
if (options.entryFile) {
|
|
249849
|
-
if (found.length === 0) {
|
|
249850
|
-
throw new InvalidInputError(`No files found in ${outputDir}. Build the site before creating a version.`, {
|
|
249851
|
-
hints: [
|
|
249852
|
-
{ message: "Run 'base44 build' first", command: "base44 build" }
|
|
249853
|
-
]
|
|
249854
|
-
});
|
|
249855
|
-
}
|
|
249856
|
-
if (!found.some((f) => f.path === options.entryFile)) {
|
|
249857
|
-
throw new InvalidInputError(`${outputDir} has no ${options.entryFile}, so nothing could enter the site.`);
|
|
249858
|
-
}
|
|
249859
|
-
}
|
|
249860
|
-
return await pMap(found, async (file) => ({ ...file, digest: await digestFile(file.absolutePath) }), { concurrency: HASH_CONCURRENCY });
|
|
249861
|
-
}
|
|
249862
|
-
async function collectSiteWorker(projectRoot) {
|
|
249863
|
-
const built = await resolveFullStackBuild(projectRoot);
|
|
249864
|
-
if (!built) {
|
|
249865
|
-
return null;
|
|
249866
|
-
}
|
|
249867
|
-
const { config, modules, assetsDir } = built;
|
|
249868
|
-
const entry = resolve11(config.configDir, config.main);
|
|
249869
|
-
const main = modules.find((m) => m.absolutePath === entry)?.name;
|
|
249870
|
-
if (!main) {
|
|
249871
|
-
throw new InvalidInputError(`The Worker's entry module ${config.main} is not among the ${modules.length} modules collected from ${config.configDir}.`);
|
|
249872
|
-
}
|
|
249873
|
-
return {
|
|
249874
|
-
main,
|
|
249875
|
-
modules: await pMap(modules, async ({ name, absolutePath, size, type }) => ({
|
|
249876
|
-
path: name,
|
|
249877
|
-
absolutePath,
|
|
249878
|
-
size,
|
|
249879
|
-
digest: await digestFile(absolutePath),
|
|
249880
|
-
type
|
|
249881
|
-
}), { concurrency: HASH_CONCURRENCY }),
|
|
249882
|
-
assets: assetsDir ? await collectBuildOutput(assetsDir) : [],
|
|
249883
|
-
compatibilityDate: config.compatibilityDate,
|
|
249884
|
-
compatibilityFlags: config.compatibilityFlags,
|
|
249885
|
-
assetsConfig: config.assetsConfig
|
|
249886
|
-
};
|
|
249887
|
-
}
|
|
249888
|
-
async function readRawResources(dir) {
|
|
249889
|
-
if (!await pathExists(dir)) {
|
|
249890
|
-
return {};
|
|
249891
|
-
}
|
|
249892
|
-
const files = await globby(`**/*.${CONFIG_FILE_EXTENSION_GLOB}`, {
|
|
249893
|
-
cwd: dir,
|
|
249894
|
-
onlyFiles: true,
|
|
249895
|
-
followSymbolicLinks: false
|
|
249896
|
-
});
|
|
249897
|
-
const payloads = {};
|
|
249898
|
-
for (const relativePath of files.sort()) {
|
|
249899
|
-
const name = relativePath.replace(/\.jsonc?$/, "");
|
|
249900
|
-
payloads[name] = await readJsonFile(join28(dir, ...relativePath.split("/")));
|
|
249901
|
-
}
|
|
249902
|
-
return payloads;
|
|
249903
|
-
}
|
|
249904
|
-
async function collectResources(configDir, dirs) {
|
|
249905
|
-
const [entities, agents] = await Promise.all([
|
|
249906
|
-
readRawResources(join28(configDir, dirs.entitiesDir)),
|
|
249907
|
-
readRawResources(join28(configDir, dirs.agentsDir))
|
|
249908
|
-
]);
|
|
249909
|
-
return { entities, agents };
|
|
249910
|
-
}
|
|
249911
|
-
async function collectArtifacts(target) {
|
|
249912
|
-
const siteWorker = await collectSiteWorker(target.root);
|
|
249913
|
-
return {
|
|
249914
|
-
files: siteWorker ? [] : await collectBuildOutput(requireOutputDir(target), {
|
|
249915
|
-
entryFile: ENTRY2
|
|
249916
|
-
}),
|
|
249917
|
-
...siteWorker ? { siteWorker } : {},
|
|
249918
|
-
...await collectResources(target.configDir, target)
|
|
249919
|
-
};
|
|
249920
|
-
}
|
|
249921
|
-
// src/core/version/gate.ts
|
|
249922
|
-
var VERSIONS_API_ENV = "BASE44_VERSIONS_API";
|
|
249923
|
-
function versionsApiEnabled(env = process.env) {
|
|
249924
|
-
const value = env[VERSIONS_API_ENV];
|
|
249925
|
-
return value === "1" || value === "true";
|
|
249926
|
-
}
|
|
249927
249672
|
// src/cli/commands/project/build.ts
|
|
249928
249673
|
async function buildAction(ctx) {
|
|
249929
249674
|
const app = requireApp(ctx);
|
|
249930
|
-
const target = await
|
|
249675
|
+
const target = await resolveBuildTarget(app.projectRoot);
|
|
249931
249676
|
await runSiteBuild(ctx, {
|
|
249932
249677
|
root: target.root,
|
|
249933
249678
|
buildCommand: target.buildCommand,
|
|
@@ -249942,11 +249687,11 @@ function getBuildCommand() {
|
|
|
249942
249687
|
}
|
|
249943
249688
|
|
|
249944
249689
|
// src/cli/commands/project/create.ts
|
|
249945
|
-
import { basename as basename6, resolve as
|
|
249690
|
+
import { basename as basename6, resolve as resolve11 } from "node:path";
|
|
249946
249691
|
var import_kebabCase = __toESM(require_kebabCase(), 1);
|
|
249947
249692
|
|
|
249948
249693
|
// src/cli/commands/project/scaffold-shared.ts
|
|
249949
|
-
import { join as
|
|
249694
|
+
import { join as join28 } from "node:path";
|
|
249950
249695
|
var DEFAULT_TEMPLATE_ID = "backend-only";
|
|
249951
249696
|
async function getTemplateById(templateId) {
|
|
249952
249697
|
const templates = await listTemplates();
|
|
@@ -250009,7 +249754,7 @@ async function completeProjectSetup({
|
|
|
250009
249754
|
env: { VITE_BASE44_APP_ID: projectId }
|
|
250010
249755
|
})`${buildCommand}`;
|
|
250011
249756
|
updateMessage("Deploying site...");
|
|
250012
|
-
return await deploySite(
|
|
249757
|
+
return await deploySite(join28(resolvedPath, outputDirectory));
|
|
250013
249758
|
}, {
|
|
250014
249759
|
successMessage: theme.colors.base44Orange("Site deployed successfully"),
|
|
250015
249760
|
errorMessage: "Failed to deploy site"
|
|
@@ -250138,7 +249883,7 @@ async function createInteractive(options, ctx) {
|
|
|
250138
249883
|
}, ctx);
|
|
250139
249884
|
}
|
|
250140
249885
|
async function createNonInteractive(options, ctx) {
|
|
250141
|
-
ctx.log.info(`Creating a new project at ${
|
|
249886
|
+
ctx.log.info(`Creating a new project at ${resolve11(options.path)}`);
|
|
250142
249887
|
const template = await getTemplateById(options.template ?? DEFAULT_TEMPLATE_ID);
|
|
250143
249888
|
return await executeCreate({
|
|
250144
249889
|
template,
|
|
@@ -250162,7 +249907,7 @@ async function executeCreate({
|
|
|
250162
249907
|
}, ctx) {
|
|
250163
249908
|
const { log, runTask } = ctx;
|
|
250164
249909
|
const name = rawName.trim();
|
|
250165
|
-
const resolvedPath =
|
|
249910
|
+
const resolvedPath = resolve11(projectPath);
|
|
250166
249911
|
const organizationId = await resolveWorkspaceId(ctx, flagWorkspaceId, isInteractive);
|
|
250167
249912
|
const { projectId } = await runTask("Setting up your project...", async () => {
|
|
250168
249913
|
return await createProjectFiles({
|
|
@@ -250803,7 +250548,7 @@ function getLogsCommand() {
|
|
|
250803
250548
|
}
|
|
250804
250549
|
|
|
250805
250550
|
// src/cli/commands/project/scaffold.ts
|
|
250806
|
-
import { basename as basename7, resolve as
|
|
250551
|
+
import { basename as basename7, resolve as resolve12 } from "node:path";
|
|
250807
250552
|
function resolveAppId(options) {
|
|
250808
250553
|
const appId = options.appId;
|
|
250809
250554
|
if (!appId) {
|
|
@@ -250819,7 +250564,7 @@ function resolveAppId(options) {
|
|
|
250819
250564
|
async function scaffoldAction(ctx, name, options, command) {
|
|
250820
250565
|
const { log, runTask } = ctx;
|
|
250821
250566
|
const appId = resolveAppId(command.optsWithGlobals());
|
|
250822
|
-
const resolvedPath =
|
|
250567
|
+
const resolvedPath = resolve12("./");
|
|
250823
250568
|
const projectName = (name ?? basename7(resolvedPath)).trim();
|
|
250824
250569
|
const template = await getTemplateById("backend-only");
|
|
250825
250570
|
log.info(`Scaffolding project at ${resolvedPath}`);
|
|
@@ -250867,6 +250612,258 @@ function getVisibilityCommand() {
|
|
|
250867
250612
|
])).action(setVisibility);
|
|
250868
250613
|
}
|
|
250869
250614
|
|
|
250615
|
+
// src/core/version/schema.ts
|
|
250616
|
+
var DeclareVersionResponseSchema = object({
|
|
250617
|
+
session_id: string2(),
|
|
250618
|
+
uploads: array(object({
|
|
250619
|
+
path: string2(),
|
|
250620
|
+
url: string2(),
|
|
250621
|
+
content_type: string2(),
|
|
250622
|
+
content_length: number2(),
|
|
250623
|
+
checksum_sha256: string2()
|
|
250624
|
+
}))
|
|
250625
|
+
}).transform((data) => ({
|
|
250626
|
+
sessionId: data.session_id,
|
|
250627
|
+
uploads: data.uploads.map((upload) => ({
|
|
250628
|
+
path: upload.path,
|
|
250629
|
+
url: upload.url,
|
|
250630
|
+
contentType: upload.content_type,
|
|
250631
|
+
contentLength: upload.content_length,
|
|
250632
|
+
checksumSha256: upload.checksum_sha256
|
|
250633
|
+
}))
|
|
250634
|
+
}));
|
|
250635
|
+
var CreateVersionResponseSchema = object({
|
|
250636
|
+
version_id: string2(),
|
|
250637
|
+
manifest_hash: string2()
|
|
250638
|
+
}).transform((data) => ({
|
|
250639
|
+
versionId: data.version_id,
|
|
250640
|
+
manifestHash: data.manifest_hash
|
|
250641
|
+
}));
|
|
250642
|
+
var EnvironmentResponseSchema = object({
|
|
250643
|
+
name: string2(),
|
|
250644
|
+
version_id: string2(),
|
|
250645
|
+
manifest_hash: string2(),
|
|
250646
|
+
deployment_id: string2()
|
|
250647
|
+
}).transform((data) => ({
|
|
250648
|
+
name: data.name,
|
|
250649
|
+
versionId: data.version_id,
|
|
250650
|
+
manifestHash: data.manifest_hash,
|
|
250651
|
+
deploymentId: data.deployment_id
|
|
250652
|
+
}));
|
|
250653
|
+
|
|
250654
|
+
// src/core/version/api.ts
|
|
250655
|
+
var DEFAULT_VERSION_UPLOAD_CONCURRENCY = 8;
|
|
250656
|
+
var MAX_VERSION_UPLOAD_CONCURRENCY = 16;
|
|
250657
|
+
function declaredFile({ path, size, digest }) {
|
|
250658
|
+
return { path, size, digest };
|
|
250659
|
+
}
|
|
250660
|
+
function declaredModule(module) {
|
|
250661
|
+
return { ...declaredFile(module), type: module.type };
|
|
250662
|
+
}
|
|
250663
|
+
function declaredAssetsConfig(config) {
|
|
250664
|
+
const stated = {
|
|
250665
|
+
html_handling: config?.htmlHandling ?? null,
|
|
250666
|
+
not_found_handling: config?.notFoundHandling ?? null,
|
|
250667
|
+
run_worker_first: config?.runWorkerFirst ?? null,
|
|
250668
|
+
headers: config?.headers ?? null,
|
|
250669
|
+
redirects: config?.redirects ?? null
|
|
250670
|
+
};
|
|
250671
|
+
return Object.values(stated).every((v) => v === null) ? null : stated;
|
|
250672
|
+
}
|
|
250673
|
+
async function post(path, json, doing) {
|
|
250674
|
+
try {
|
|
250675
|
+
return await getAppClient().post(path, { json, timeout: 180000 });
|
|
250676
|
+
} catch (error) {
|
|
250677
|
+
throw await ApiError.fromHttpError(error, doing);
|
|
250678
|
+
}
|
|
250679
|
+
}
|
|
250680
|
+
var KEYED_RETRY = {
|
|
250681
|
+
limit: 3,
|
|
250682
|
+
methods: ["patch"],
|
|
250683
|
+
statusCodes: [408, 500, 502, 503, 504],
|
|
250684
|
+
retryOnTimeout: true
|
|
250685
|
+
};
|
|
250686
|
+
async function patch(path, json, doing, retry) {
|
|
250687
|
+
try {
|
|
250688
|
+
return await getAppClient().patch(path, {
|
|
250689
|
+
json,
|
|
250690
|
+
timeout: 180000,
|
|
250691
|
+
...retry ? { retry } : {}
|
|
250692
|
+
});
|
|
250693
|
+
} catch (error) {
|
|
250694
|
+
throw await ApiError.fromHttpError(error, doing);
|
|
250695
|
+
}
|
|
250696
|
+
}
|
|
250697
|
+
function parse10(schema, body, what) {
|
|
250698
|
+
const result = schema.safeParse(body);
|
|
250699
|
+
if (!result.success) {
|
|
250700
|
+
throw new SchemaValidationError(`Invalid ${what} response from server`, result.error);
|
|
250701
|
+
}
|
|
250702
|
+
return result.data;
|
|
250703
|
+
}
|
|
250704
|
+
async function createVersion(artifacts, options = {}) {
|
|
250705
|
+
const declared = parse10(DeclareVersionResponseSchema, await (await post("versions", {
|
|
250706
|
+
static_bundle: artifacts.files.map(declaredFile),
|
|
250707
|
+
...artifacts.siteWorker ? {
|
|
250708
|
+
site_worker: {
|
|
250709
|
+
main: artifacts.siteWorker.main,
|
|
250710
|
+
modules: artifacts.siteWorker.modules.map(declaredModule),
|
|
250711
|
+
assets: artifacts.siteWorker.assets.map(declaredFile),
|
|
250712
|
+
compatibility_date: artifacts.siteWorker.compatibilityDate,
|
|
250713
|
+
compatibility_flags: artifacts.siteWorker.compatibilityFlags,
|
|
250714
|
+
assets_config: declaredAssetsConfig(artifacts.siteWorker.assetsConfig)
|
|
250715
|
+
}
|
|
250716
|
+
} : {},
|
|
250717
|
+
entities: artifacts.entities,
|
|
250718
|
+
agents: artifacts.agents,
|
|
250719
|
+
source_commit: options.sourceCommit
|
|
250720
|
+
}, "declaring a version")).json(), "declare");
|
|
250721
|
+
const declaredFiles = [
|
|
250722
|
+
...artifacts.files,
|
|
250723
|
+
...artifacts.siteWorker?.modules ?? [],
|
|
250724
|
+
...artifacts.siteWorker?.assets ?? []
|
|
250725
|
+
];
|
|
250726
|
+
options.progress?.onDeclared?.({ fileCount: declaredFiles.length });
|
|
250727
|
+
if (declared.uploads.length !== declaredFiles.length) {
|
|
250728
|
+
throw new InternalError(`Declared ${declaredFiles.length} files but the server signed ${declared.uploads.length} upload URLs.`);
|
|
250729
|
+
}
|
|
250730
|
+
const drifted = declared.uploads.findIndex((upload, index) => upload.path !== declaredFiles[index].path);
|
|
250731
|
+
if (drifted !== -1) {
|
|
250732
|
+
throw new InternalError(`Upload ${drifted} is signed for ${declared.uploads[drifted].path}, but that slot declared ${declaredFiles[drifted].path}.`);
|
|
250733
|
+
}
|
|
250734
|
+
let uploadedFiles = 0;
|
|
250735
|
+
await pMap(declared.uploads, async (upload, index) => {
|
|
250736
|
+
await putPresigned(upload, declaredFiles[index].absolutePath);
|
|
250737
|
+
uploadedFiles++;
|
|
250738
|
+
options.progress?.onUpload?.({
|
|
250739
|
+
uploadedFiles,
|
|
250740
|
+
totalFiles: declared.uploads.length
|
|
250741
|
+
});
|
|
250742
|
+
}, { concurrency: options.concurrency ?? DEFAULT_VERSION_UPLOAD_CONCURRENCY });
|
|
250743
|
+
return parse10(CreateVersionResponseSchema, await (await post(`versions/${encodeURIComponent(declared.sessionId)}/finalize`, {}, "creating a version")).json(), "create version");
|
|
250744
|
+
}
|
|
250745
|
+
async function setEnvironmentVersion(environment, versionId, options = {}) {
|
|
250746
|
+
return parse10(EnvironmentResponseSchema, await (await patch(`environments/${encodeURIComponent(environment)}`, {
|
|
250747
|
+
version_id: versionId,
|
|
250748
|
+
...options.idempotencyKey ? { idempotency_key: options.idempotencyKey } : {}
|
|
250749
|
+
}, "setting the environment's version", options.idempotencyKey ? KEYED_RETRY : undefined)).json(), "environment");
|
|
250750
|
+
}
|
|
250751
|
+
// src/core/version/artifacts.ts
|
|
250752
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
250753
|
+
import { join as join29, resolve as resolve13 } from "node:path";
|
|
250754
|
+
var MAX_FILE_COUNT = 50000;
|
|
250755
|
+
var HASH_CONCURRENCY = 32;
|
|
250756
|
+
var ENTRY2 = "index.html";
|
|
250757
|
+
async function digestFile(absolutePath) {
|
|
250758
|
+
const hash = await hashFileInto(createHash2("sha256"), absolutePath);
|
|
250759
|
+
return `sha256:${hash.digest("hex")}`;
|
|
250760
|
+
}
|
|
250761
|
+
async function collectBuildOutput(outputDir, options = {}) {
|
|
250762
|
+
const found = await describeBuildOutput(outputDir);
|
|
250763
|
+
if (found.length > MAX_FILE_COUNT) {
|
|
250764
|
+
throw new InvalidInputError(`Too many files: found ${found.length}, the limit is ${MAX_FILE_COUNT}.`);
|
|
250765
|
+
}
|
|
250766
|
+
if (options.entryFile) {
|
|
250767
|
+
if (found.length === 0) {
|
|
250768
|
+
throw new InvalidInputError(`No files found in ${outputDir}. Build the site before creating a version.`, {
|
|
250769
|
+
hints: [
|
|
250770
|
+
{ message: "Run 'base44 build' first", command: "base44 build" }
|
|
250771
|
+
]
|
|
250772
|
+
});
|
|
250773
|
+
}
|
|
250774
|
+
if (!found.some((f) => f.path === options.entryFile)) {
|
|
250775
|
+
throw new InvalidInputError(`${outputDir} has no ${options.entryFile}, so nothing could enter the site.`);
|
|
250776
|
+
}
|
|
250777
|
+
}
|
|
250778
|
+
return await pMap(found, async (file) => ({ ...file, digest: await digestFile(file.absolutePath) }), { concurrency: HASH_CONCURRENCY });
|
|
250779
|
+
}
|
|
250780
|
+
async function collectSiteWorker(projectRoot) {
|
|
250781
|
+
const built = await resolveFullStackBuild(projectRoot);
|
|
250782
|
+
if (!built) {
|
|
250783
|
+
return null;
|
|
250784
|
+
}
|
|
250785
|
+
const { config, modules, assetsDir } = built;
|
|
250786
|
+
const entry = resolve13(config.configDir, config.main);
|
|
250787
|
+
const main = modules.find((m) => m.absolutePath === entry)?.name;
|
|
250788
|
+
if (!main) {
|
|
250789
|
+
throw new InvalidInputError(`The Worker's entry module ${config.main} is not among the ${modules.length} modules collected from ${config.configDir}.`);
|
|
250790
|
+
}
|
|
250791
|
+
return {
|
|
250792
|
+
main,
|
|
250793
|
+
modules: await pMap(modules, async ({ name, absolutePath, size, type }) => ({
|
|
250794
|
+
path: name,
|
|
250795
|
+
absolutePath,
|
|
250796
|
+
size,
|
|
250797
|
+
digest: await digestFile(absolutePath),
|
|
250798
|
+
type
|
|
250799
|
+
}), { concurrency: HASH_CONCURRENCY }),
|
|
250800
|
+
assets: assetsDir ? await collectBuildOutput(assetsDir) : [],
|
|
250801
|
+
compatibilityDate: config.compatibilityDate,
|
|
250802
|
+
compatibilityFlags: config.compatibilityFlags,
|
|
250803
|
+
assetsConfig: config.assetsConfig
|
|
250804
|
+
};
|
|
250805
|
+
}
|
|
250806
|
+
async function readRawResources(dir) {
|
|
250807
|
+
if (!await pathExists(dir)) {
|
|
250808
|
+
return {};
|
|
250809
|
+
}
|
|
250810
|
+
const files = await globby(`**/*.${CONFIG_FILE_EXTENSION_GLOB}`, {
|
|
250811
|
+
cwd: dir,
|
|
250812
|
+
onlyFiles: true,
|
|
250813
|
+
followSymbolicLinks: false
|
|
250814
|
+
});
|
|
250815
|
+
const payloads = {};
|
|
250816
|
+
for (const relativePath of files.sort()) {
|
|
250817
|
+
const name = relativePath.replace(/\.jsonc?$/, "");
|
|
250818
|
+
payloads[name] = await readJsonFile(join29(dir, ...relativePath.split("/")));
|
|
250819
|
+
}
|
|
250820
|
+
return payloads;
|
|
250821
|
+
}
|
|
250822
|
+
async function collectResources(configDir, dirs) {
|
|
250823
|
+
const [entities, agents] = await Promise.all([
|
|
250824
|
+
readRawResources(join29(configDir, dirs.entitiesDir)),
|
|
250825
|
+
readRawResources(join29(configDir, dirs.agentsDir))
|
|
250826
|
+
]);
|
|
250827
|
+
return { entities, agents };
|
|
250828
|
+
}
|
|
250829
|
+
async function collectArtifacts(target) {
|
|
250830
|
+
const siteWorker = await collectSiteWorker(target.root);
|
|
250831
|
+
return {
|
|
250832
|
+
files: siteWorker ? [] : await collectBuildOutput(requireOutputDir(target), {
|
|
250833
|
+
entryFile: ENTRY2
|
|
250834
|
+
}),
|
|
250835
|
+
...siteWorker ? { siteWorker } : {},
|
|
250836
|
+
...await collectResources(target.configDir, target)
|
|
250837
|
+
};
|
|
250838
|
+
}
|
|
250839
|
+
// src/core/version/gate.ts
|
|
250840
|
+
var VERSIONS_API_ENV = "BASE44_VERSIONS_API";
|
|
250841
|
+
function versionsApiEnabled(env = process.env) {
|
|
250842
|
+
const value = env[VERSIONS_API_ENV];
|
|
250843
|
+
return value === "1" || value === "true";
|
|
250844
|
+
}
|
|
250845
|
+
// src/core/version/publish.ts
|
|
250846
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
250847
|
+
var DEFAULT_ENVIRONMENT = "production";
|
|
250848
|
+
async function tagStep2(step, run) {
|
|
250849
|
+
return await tagStep(step, run);
|
|
250850
|
+
}
|
|
250851
|
+
async function publishVersion(artifacts, options = {}) {
|
|
250852
|
+
const version = await tagStep2("create_version", () => createVersion(artifacts, {
|
|
250853
|
+
sourceCommit: options.sourceCommit,
|
|
250854
|
+
concurrency: options.concurrency,
|
|
250855
|
+
progress: options.progress
|
|
250856
|
+
}));
|
|
250857
|
+
const environment = await tagStep2("deploy", () => setEnvironmentVersion(options.target ?? DEFAULT_ENVIRONMENT, version.versionId, {
|
|
250858
|
+
idempotencyKey: randomUUID4()
|
|
250859
|
+
}));
|
|
250860
|
+
return {
|
|
250861
|
+
environment: environment.name,
|
|
250862
|
+
versionId: environment.versionId,
|
|
250863
|
+
manifestHash: environment.manifestHash,
|
|
250864
|
+
deploymentId: environment.deploymentId
|
|
250865
|
+
};
|
|
250866
|
+
}
|
|
250870
250867
|
// src/cli/commands/versions/options.ts
|
|
250871
250868
|
function outputDirOption() {
|
|
250872
250869
|
return new Option2("--output-dir <dir>", "Build output directory (defaults to the project's, else dist)");
|
|
@@ -250896,9 +250893,9 @@ function concurrencyOption() {
|
|
|
250896
250893
|
async function publishAction(ctx, options) {
|
|
250897
250894
|
const { runTask, log, jsonMode } = ctx;
|
|
250898
250895
|
const app = requireApp(ctx);
|
|
250899
|
-
const target = await
|
|
250896
|
+
const target = await tagStep2("create_version", () => resolveBuildTarget(app.projectRoot, { outputDir: options.outputDir }));
|
|
250900
250897
|
if (options.build !== false) {
|
|
250901
|
-
await
|
|
250898
|
+
await tagStep2("build", () => runSiteBuild(ctx, {
|
|
250902
250899
|
root: target.root,
|
|
250903
250900
|
buildCommand: target.buildCommand,
|
|
250904
250901
|
appId: app.id
|
|
@@ -250906,7 +250903,7 @@ async function publishAction(ctx, options) {
|
|
|
250906
250903
|
}
|
|
250907
250904
|
const gitHash = await resolveProvenanceCommit(target.root, options.gitHash);
|
|
250908
250905
|
const result = await runTask("Publishing...", async (updateMessage) => {
|
|
250909
|
-
const artifacts = await
|
|
250906
|
+
const artifacts = await tagStep2("create_version", () => collectArtifacts(target));
|
|
250910
250907
|
return await publishVersion(artifacts, {
|
|
250911
250908
|
sourceCommit: gitHash,
|
|
250912
250909
|
target: options.target,
|
|
@@ -251640,7 +251637,7 @@ function getTypesCommand() {
|
|
|
251640
251637
|
// src/cli/commands/versions/create.ts
|
|
251641
251638
|
async function createAction2(ctx, options) {
|
|
251642
251639
|
const { runTask, jsonMode } = ctx;
|
|
251643
|
-
const target = await
|
|
251640
|
+
const target = await resolveBuildTarget(requireApp(ctx).projectRoot, {
|
|
251644
251641
|
outputDir: options.outputDir
|
|
251645
251642
|
});
|
|
251646
251643
|
const gitHash = await resolveProvenanceCommit(target.root, options.gitHash);
|
|
@@ -260406,4 +260403,4 @@ export {
|
|
|
260406
260403
|
runCLI
|
|
260407
260404
|
};
|
|
260408
260405
|
|
|
260409
|
-
//# debugId=
|
|
260406
|
+
//# debugId=4A0444E0B8A1C5CD64756E2164756E21
|