@base44-preview/cli 0.0.45-pr.357.7d7d528 → 0.0.45-pr.357.9565bc5
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 +124 -127
- package/dist/cli/index.js.map +11 -11
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -231558,7 +231558,7 @@ async function isLoggedIn() {
|
|
|
231558
231558
|
}
|
|
231559
231559
|
|
|
231560
231560
|
// src/core/project/api.ts
|
|
231561
|
-
import { Readable } from "node:stream";
|
|
231561
|
+
import { Readable as Readable2 } from "node:stream";
|
|
231562
231562
|
import { pipeline } from "node:stream/promises";
|
|
231563
231563
|
|
|
231564
231564
|
// ../../node_modules/@isaacs/fs-minipass/dist/esm/index.js
|
|
@@ -237065,66 +237065,11 @@ var mtimeFilter = (opt) => {
|
|
|
237065
237065
|
}
|
|
237066
237066
|
opt.filter = filter ? (path8, stat) => filter(path8, stat) && !((opt.mtimeCache?.get(path8) ?? stat.mtime ?? 0) > (stat.mtime ?? 0)) : (path8, stat) => !((opt.mtimeCache?.get(path8) ?? stat.mtime ?? 0) > (stat.mtime ?? 0));
|
|
237067
237067
|
};
|
|
237068
|
-
// src/core/project/api.ts
|
|
237069
|
-
async function createProject(projectName, description) {
|
|
237070
|
-
let response;
|
|
237071
|
-
try {
|
|
237072
|
-
response = await base44Client.post("api/apps", {
|
|
237073
|
-
json: {
|
|
237074
|
-
name: projectName,
|
|
237075
|
-
user_description: description ?? `Backend for '${projectName}'`,
|
|
237076
|
-
is_managed_source_code: false,
|
|
237077
|
-
public_settings: "public_without_login"
|
|
237078
|
-
}
|
|
237079
|
-
});
|
|
237080
|
-
} catch (error48) {
|
|
237081
|
-
throw await ApiError.fromHttpError(error48, "creating project");
|
|
237082
|
-
}
|
|
237083
|
-
const result = CreateProjectResponseSchema.safeParse(await response.json());
|
|
237084
|
-
if (!result.success) {
|
|
237085
|
-
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
237086
|
-
}
|
|
237087
|
-
return {
|
|
237088
|
-
projectId: result.data.id
|
|
237089
|
-
};
|
|
237090
|
-
}
|
|
237091
|
-
async function listProjects() {
|
|
237092
|
-
let response;
|
|
237093
|
-
try {
|
|
237094
|
-
response = await base44Client.get("api/apps", {
|
|
237095
|
-
searchParams: {
|
|
237096
|
-
sort: "-updated_date",
|
|
237097
|
-
fields: "id,name,user_description,is_managed_source_code",
|
|
237098
|
-
limit: 50
|
|
237099
|
-
}
|
|
237100
|
-
});
|
|
237101
|
-
} catch (error48) {
|
|
237102
|
-
throw await ApiError.fromHttpError(error48, "listing projects");
|
|
237103
|
-
}
|
|
237104
|
-
const result = ProjectsResponseSchema.safeParse(await response.json());
|
|
237105
|
-
if (!result.success) {
|
|
237106
|
-
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
237107
|
-
}
|
|
237108
|
-
return result.data;
|
|
237109
|
-
}
|
|
237110
|
-
async function downloadProject(projectId, projectPath) {
|
|
237111
|
-
let response;
|
|
237112
|
-
try {
|
|
237113
|
-
response = await base44Client.get(`api/apps/${projectId}/eject`, {
|
|
237114
|
-
timeout: false
|
|
237115
|
-
});
|
|
237116
|
-
} catch (error48) {
|
|
237117
|
-
throw await ApiError.fromHttpError(error48, "downloading project");
|
|
237118
|
-
}
|
|
237119
|
-
const nodeStream = Readable.fromWeb(response.body);
|
|
237120
|
-
await makeDirectory(projectPath);
|
|
237121
|
-
await pipeline(nodeStream, extract({ cwd: projectPath }));
|
|
237122
|
-
}
|
|
237123
237068
|
// ../../node_modules/globby/index.js
|
|
237124
237069
|
import process5 from "node:process";
|
|
237125
237070
|
import fs13 from "node:fs";
|
|
237126
237071
|
import nodePath from "node:path";
|
|
237127
|
-
import { Readable
|
|
237072
|
+
import { Readable } from "node:stream";
|
|
237128
237073
|
|
|
237129
237074
|
// ../../node_modules/@sindresorhus/merge-streams/index.js
|
|
237130
237075
|
import { on, once } from "node:events";
|
|
@@ -238016,7 +237961,7 @@ var globbyStream = normalizeArgumentsSync((patterns, options) => {
|
|
|
238016
237961
|
const tasks = generateTasksSync(patterns, modifiedOptions);
|
|
238017
237962
|
const streams = tasks.map((task) => import_fast_glob2.default.stream(task.patterns, task.options));
|
|
238018
237963
|
if (streams.length === 0) {
|
|
238019
|
-
return
|
|
237964
|
+
return Readable.from([]);
|
|
238020
237965
|
}
|
|
238021
237966
|
const stream = mergeStreams(streams).filter((fastGlobResult) => filter(fastGlobResult));
|
|
238022
237967
|
return stream;
|
|
@@ -239407,6 +239352,94 @@ async function readAppConfig(projectRoot) {
|
|
|
239407
239352
|
}
|
|
239408
239353
|
return result.data;
|
|
239409
239354
|
}
|
|
239355
|
+
|
|
239356
|
+
// src/core/site/schema.ts
|
|
239357
|
+
var DeployResponseSchema = exports_external.object({
|
|
239358
|
+
app_url: exports_external.url()
|
|
239359
|
+
}).transform((data) => ({
|
|
239360
|
+
appUrl: data.app_url
|
|
239361
|
+
}));
|
|
239362
|
+
var PublishedUrlResponseSchema = exports_external.object({
|
|
239363
|
+
url: exports_external.string()
|
|
239364
|
+
});
|
|
239365
|
+
|
|
239366
|
+
// src/core/project/api.ts
|
|
239367
|
+
async function createProject(projectName, description) {
|
|
239368
|
+
let response;
|
|
239369
|
+
try {
|
|
239370
|
+
response = await base44Client.post("api/apps", {
|
|
239371
|
+
json: {
|
|
239372
|
+
name: projectName,
|
|
239373
|
+
user_description: description ?? `Backend for '${projectName}'`,
|
|
239374
|
+
is_managed_source_code: false,
|
|
239375
|
+
public_settings: "public_without_login"
|
|
239376
|
+
}
|
|
239377
|
+
});
|
|
239378
|
+
} catch (error48) {
|
|
239379
|
+
throw await ApiError.fromHttpError(error48, "creating project");
|
|
239380
|
+
}
|
|
239381
|
+
const result = CreateProjectResponseSchema.safeParse(await response.json());
|
|
239382
|
+
if (!result.success) {
|
|
239383
|
+
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
239384
|
+
}
|
|
239385
|
+
return {
|
|
239386
|
+
projectId: result.data.id
|
|
239387
|
+
};
|
|
239388
|
+
}
|
|
239389
|
+
async function listProjects() {
|
|
239390
|
+
let response;
|
|
239391
|
+
try {
|
|
239392
|
+
response = await base44Client.get("api/apps", {
|
|
239393
|
+
searchParams: {
|
|
239394
|
+
sort: "-updated_date",
|
|
239395
|
+
fields: "id,name,user_description,is_managed_source_code",
|
|
239396
|
+
limit: 50
|
|
239397
|
+
}
|
|
239398
|
+
});
|
|
239399
|
+
} catch (error48) {
|
|
239400
|
+
throw await ApiError.fromHttpError(error48, "listing projects");
|
|
239401
|
+
}
|
|
239402
|
+
const result = ProjectsResponseSchema.safeParse(await response.json());
|
|
239403
|
+
if (!result.success) {
|
|
239404
|
+
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
239405
|
+
}
|
|
239406
|
+
return result.data;
|
|
239407
|
+
}
|
|
239408
|
+
async function downloadProject(projectId, projectPath) {
|
|
239409
|
+
let response;
|
|
239410
|
+
try {
|
|
239411
|
+
response = await base44Client.get(`api/apps/${projectId}/eject`, {
|
|
239412
|
+
timeout: false
|
|
239413
|
+
});
|
|
239414
|
+
} catch (error48) {
|
|
239415
|
+
throw await ApiError.fromHttpError(error48, "downloading project");
|
|
239416
|
+
}
|
|
239417
|
+
const nodeStream = Readable2.fromWeb(response.body);
|
|
239418
|
+
await makeDirectory(projectPath);
|
|
239419
|
+
await pipeline(nodeStream, extract({ cwd: projectPath }));
|
|
239420
|
+
}
|
|
239421
|
+
async function getAppUserToken() {
|
|
239422
|
+
try {
|
|
239423
|
+
const response = await getAppClient().get("auth/token").json();
|
|
239424
|
+
return response.token;
|
|
239425
|
+
} catch (error48) {
|
|
239426
|
+
throw await ApiError.fromHttpError(error48, "exchanging platform token for app user token");
|
|
239427
|
+
}
|
|
239428
|
+
}
|
|
239429
|
+
async function getSiteUrl(projectId) {
|
|
239430
|
+
const id = projectId ?? getAppConfig().id;
|
|
239431
|
+
let response;
|
|
239432
|
+
try {
|
|
239433
|
+
response = await base44Client.get(`api/apps/platform/${id}/published-url`);
|
|
239434
|
+
} catch (error48) {
|
|
239435
|
+
throw await ApiError.fromHttpError(error48, "fetching site URL");
|
|
239436
|
+
}
|
|
239437
|
+
const result = PublishedUrlResponseSchema.safeParse(await response.json());
|
|
239438
|
+
if (!result.success) {
|
|
239439
|
+
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
239440
|
+
}
|
|
239441
|
+
return result.data.url;
|
|
239442
|
+
}
|
|
239410
239443
|
// src/core/project/template.ts
|
|
239411
239444
|
var import_ejs = __toESM(require_ejs(), 1);
|
|
239412
239445
|
var import_front_matter = __toESM(require_front_matter(), 1);
|
|
@@ -239598,16 +239631,6 @@ async function createProjectFilesForExistingProject(options) {
|
|
|
239598
239631
|
// src/core/project/deploy.ts
|
|
239599
239632
|
import { resolve } from "node:path";
|
|
239600
239633
|
|
|
239601
|
-
// src/core/site/schema.ts
|
|
239602
|
-
var DeployResponseSchema = exports_external.object({
|
|
239603
|
-
app_url: exports_external.url()
|
|
239604
|
-
}).transform((data) => ({
|
|
239605
|
-
appUrl: data.app_url
|
|
239606
|
-
}));
|
|
239607
|
-
var PublishedUrlResponseSchema = exports_external.object({
|
|
239608
|
-
url: exports_external.string()
|
|
239609
|
-
});
|
|
239610
|
-
|
|
239611
239634
|
// src/core/site/api.ts
|
|
239612
239635
|
async function uploadSite(archivePath) {
|
|
239613
239636
|
const archiveBuffer = await readFile(archivePath);
|
|
@@ -239630,20 +239653,6 @@ async function uploadSite(archivePath) {
|
|
|
239630
239653
|
}
|
|
239631
239654
|
return result.data;
|
|
239632
239655
|
}
|
|
239633
|
-
async function getSiteUrl(projectId) {
|
|
239634
|
-
const id = projectId ?? getAppConfig().id;
|
|
239635
|
-
let response;
|
|
239636
|
-
try {
|
|
239637
|
-
response = await base44Client.get(`api/apps/platform/${id}/published-url`);
|
|
239638
|
-
} catch (error48) {
|
|
239639
|
-
throw await ApiError.fromHttpError(error48, "fetching site URL");
|
|
239640
|
-
}
|
|
239641
|
-
const result = PublishedUrlResponseSchema.safeParse(await response.json());
|
|
239642
|
-
if (!result.success) {
|
|
239643
|
-
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
239644
|
-
}
|
|
239645
|
-
return result.data.url;
|
|
239646
|
-
}
|
|
239647
239656
|
// src/core/site/config.ts
|
|
239648
239657
|
async function getSiteFilePaths(outputDir) {
|
|
239649
239658
|
return await globby("**/*", {
|
|
@@ -251693,33 +251702,16 @@ function getDevCommand() {
|
|
|
251693
251702
|
// src/core/exec/run-script.ts
|
|
251694
251703
|
import { spawn as spawn3 } from "node:child_process";
|
|
251695
251704
|
import { copyFileSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
251696
|
-
import { resolve as resolve8 } from "node:path";
|
|
251697
|
-
async function getUserAppToken() {
|
|
251698
|
-
try {
|
|
251699
|
-
const response = await getAppClient().get("auth/token").json();
|
|
251700
|
-
return response.token;
|
|
251701
|
-
} catch (error48) {
|
|
251702
|
-
throw await ApiError.fromHttpError(error48, "exchanging platform token for app user token");
|
|
251703
|
-
}
|
|
251704
|
-
}
|
|
251705
251705
|
async function runScript(options8) {
|
|
251706
|
-
const {
|
|
251706
|
+
const { appId, code: code2 } = options8;
|
|
251707
251707
|
verifyDenoInstalled("to run scripts with exec");
|
|
251708
251708
|
const cleanupFns = [];
|
|
251709
|
-
|
|
251710
|
-
|
|
251711
|
-
|
|
251712
|
-
|
|
251713
|
-
const tempScript = await $file({ postfix: ".ts" });
|
|
251714
|
-
cleanupFns.push(tempScript.cleanup);
|
|
251715
|
-
writeFileSync2(tempScript.path, code2, "utf-8");
|
|
251716
|
-
scriptPath = `file://${tempScript.path}`;
|
|
251717
|
-
} else {
|
|
251718
|
-
throw new Error("Either filePath or code must be provided");
|
|
251719
|
-
}
|
|
251720
|
-
const appConfig = getAppConfig();
|
|
251709
|
+
const tempScript = await $file({ postfix: ".ts" });
|
|
251710
|
+
cleanupFns.push(tempScript.cleanup);
|
|
251711
|
+
writeFileSync2(tempScript.path, code2, "utf-8");
|
|
251712
|
+
const scriptPath = `file://${tempScript.path}`;
|
|
251721
251713
|
const [appUserToken, appBaseUrl] = await Promise.all([
|
|
251722
|
-
|
|
251714
|
+
getAppUserToken(),
|
|
251723
251715
|
getSiteUrl()
|
|
251724
251716
|
]);
|
|
251725
251717
|
const tempWrapper = await $file({ postfix: ".ts" });
|
|
@@ -251727,16 +251719,11 @@ async function runScript(options8) {
|
|
|
251727
251719
|
copyFileSync(getExecWrapperPath(), tempWrapper.path);
|
|
251728
251720
|
try {
|
|
251729
251721
|
const exitCode = await new Promise((resolvePromise) => {
|
|
251730
|
-
const child = spawn3("deno", [
|
|
251731
|
-
"run",
|
|
251732
|
-
"--allow-all",
|
|
251733
|
-
"--node-modules-dir=auto",
|
|
251734
|
-
tempWrapper.path
|
|
251735
|
-
], {
|
|
251722
|
+
const child = spawn3("deno", ["run", "--allow-all", "--node-modules-dir=auto", tempWrapper.path], {
|
|
251736
251723
|
env: {
|
|
251737
251724
|
...process.env,
|
|
251738
251725
|
SCRIPT_PATH: scriptPath,
|
|
251739
|
-
BASE44_APP_ID:
|
|
251726
|
+
BASE44_APP_ID: appId,
|
|
251740
251727
|
BASE44_ACCESS_TOKEN: appUserToken,
|
|
251741
251728
|
BASE44_APP_BASE_URL: appBaseUrl
|
|
251742
251729
|
},
|
|
@@ -251755,42 +251742,52 @@ async function runScript(options8) {
|
|
|
251755
251742
|
}
|
|
251756
251743
|
// src/cli/commands/exec.ts
|
|
251757
251744
|
function readStdin() {
|
|
251758
|
-
return new Promise((
|
|
251745
|
+
return new Promise((resolve8, reject) => {
|
|
251759
251746
|
let data = "";
|
|
251760
251747
|
process.stdin.setEncoding("utf-8");
|
|
251761
251748
|
process.stdin.on("data", (chunk) => {
|
|
251762
251749
|
data += chunk;
|
|
251763
251750
|
});
|
|
251764
|
-
process.stdin.on("end", () =>
|
|
251751
|
+
process.stdin.on("end", () => resolve8(data));
|
|
251765
251752
|
process.stdin.on("error", reject);
|
|
251766
251753
|
});
|
|
251767
251754
|
}
|
|
251768
|
-
async function execAction() {
|
|
251755
|
+
async function execAction(isNonInteractive) {
|
|
251769
251756
|
const noInputError = new InvalidInputError("No input provided. Pipe a script to stdin.", {
|
|
251770
251757
|
hints: [
|
|
251771
251758
|
{ message: "File: cat ./script.ts | base44 exec" },
|
|
251772
|
-
{
|
|
251759
|
+
{
|
|
251760
|
+
message: 'Eval: echo "const users = await base44.entities.User.list(); console.log(users)" | base44 exec'
|
|
251761
|
+
}
|
|
251773
251762
|
]
|
|
251774
251763
|
});
|
|
251775
|
-
if (
|
|
251764
|
+
if (!isNonInteractive) {
|
|
251776
251765
|
throw noInputError;
|
|
251777
251766
|
}
|
|
251778
251767
|
const code2 = await readStdin();
|
|
251779
251768
|
if (!code2.trim()) {
|
|
251780
251769
|
throw noInputError;
|
|
251781
251770
|
}
|
|
251782
|
-
const { exitCode } = await runScript({ code: code2 });
|
|
251771
|
+
const { exitCode } = await runScript({ appId: getAppConfig().id, code: code2 });
|
|
251783
251772
|
if (exitCode !== 0) {
|
|
251784
251773
|
process.exitCode = exitCode;
|
|
251785
251774
|
}
|
|
251786
251775
|
return {};
|
|
251787
251776
|
}
|
|
251788
251777
|
function getExecCommand() {
|
|
251789
|
-
return new Base44Command("exec").description("Run a script with the Base44 SDK pre-authenticated as the current user").
|
|
251778
|
+
return new Base44Command("exec").description("Run a script with the Base44 SDK pre-authenticated as the current user").addHelpText("after", `
|
|
251779
|
+
Examples:
|
|
251780
|
+
Run a script file:
|
|
251781
|
+
$ cat ./script.ts | base44 exec
|
|
251782
|
+
|
|
251783
|
+
Inline script:
|
|
251784
|
+
$ echo "const users = await base44.entities.User.list()" | base44 exec`).action(async (_options, command2) => {
|
|
251785
|
+
return await execAction(command2.isNonInteractive);
|
|
251786
|
+
});
|
|
251790
251787
|
}
|
|
251791
251788
|
|
|
251792
251789
|
// src/cli/commands/project/eject.ts
|
|
251793
|
-
import { resolve as
|
|
251790
|
+
import { resolve as resolve8 } from "node:path";
|
|
251794
251791
|
var import_kebabCase2 = __toESM(require_kebabCase(), 1);
|
|
251795
251792
|
async function eject(options8) {
|
|
251796
251793
|
const projects = await listProjects();
|
|
@@ -251839,7 +251836,7 @@ async function eject(options8) {
|
|
|
251839
251836
|
Ne("Operation cancelled.");
|
|
251840
251837
|
throw new CLIExitError(0);
|
|
251841
251838
|
}
|
|
251842
|
-
const resolvedPath =
|
|
251839
|
+
const resolvedPath = resolve8(selectedPath);
|
|
251843
251840
|
await runTask("Downloading your project's code...", async (updateMessage) => {
|
|
251844
251841
|
await createProjectFilesForExistingProject({
|
|
251845
251842
|
projectId,
|
|
@@ -254217,14 +254214,14 @@ async function addSourceContext(frames) {
|
|
|
254217
254214
|
return frames;
|
|
254218
254215
|
}
|
|
254219
254216
|
function getContextLinesFromFile(path19, ranges, output) {
|
|
254220
|
-
return new Promise((
|
|
254217
|
+
return new Promise((resolve9) => {
|
|
254221
254218
|
const stream = createReadStream2(path19);
|
|
254222
254219
|
const lineReaded = createInterface2({
|
|
254223
254220
|
input: stream
|
|
254224
254221
|
});
|
|
254225
254222
|
function destroyStreamAndResolve() {
|
|
254226
254223
|
stream.destroy();
|
|
254227
|
-
|
|
254224
|
+
resolve9();
|
|
254228
254225
|
}
|
|
254229
254226
|
let lineNumber = 0;
|
|
254230
254227
|
let currentRangeIndex = 0;
|
|
@@ -255336,15 +255333,15 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
255336
255333
|
return true;
|
|
255337
255334
|
if (this.featureFlagsPoller === undefined)
|
|
255338
255335
|
return false;
|
|
255339
|
-
return new Promise((
|
|
255336
|
+
return new Promise((resolve9) => {
|
|
255340
255337
|
const timeout3 = setTimeout(() => {
|
|
255341
255338
|
cleanup();
|
|
255342
|
-
|
|
255339
|
+
resolve9(false);
|
|
255343
255340
|
}, timeoutMs);
|
|
255344
255341
|
const cleanup = this._events.on("localEvaluationFlagsLoaded", (count2) => {
|
|
255345
255342
|
clearTimeout(timeout3);
|
|
255346
255343
|
cleanup();
|
|
255347
|
-
|
|
255344
|
+
resolve9(count2 > 0);
|
|
255348
255345
|
});
|
|
255349
255346
|
});
|
|
255350
255347
|
}
|
|
@@ -256163,4 +256160,4 @@ export {
|
|
|
256163
256160
|
CLIExitError
|
|
256164
256161
|
};
|
|
256165
256162
|
|
|
256166
|
-
//# debugId=
|
|
256163
|
+
//# debugId=8C70A21DA8CF2A5064756E2164756E21
|