@vention/vention-cli 0.27.0 → 0.27.2

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/main.esm.js CHANGED
@@ -6797,6 +6797,23 @@ const pushApplicationToDigitalTwin = async (environment, designId, sessionId, ap
6797
6797
  body: application
6798
6798
  });
6799
6799
  };
6800
+ const getApplicationLogs = async (environment, designId, sessionId, applicationId) => {
6801
+ if (!sessionId) {
6802
+ throw new Error("Linked session token is not set");
6803
+ }
6804
+ const digitalTwinUrl = getDigitalTwinUrl(environment, sessionId);
6805
+ const url = `${digitalTwinUrl}/v1/application/${applicationId}/logs`;
6806
+ const response = await fetch(url, {
6807
+ method: "GET",
6808
+ headers: {
6809
+ Cookie: `digital-twin-session-${designId}=s%3A${sessionId}.s`
6810
+ }
6811
+ });
6812
+ if (!response.ok) {
6813
+ throw new Error("Could not find logs for application");
6814
+ }
6815
+ return await response.text();
6816
+ };
6800
6817
 
6801
6818
  const getBaseRailsUrl = environment => {
6802
6819
  switch (environment) {
@@ -10542,6 +10559,35 @@ function createPullCommand() {
10542
10559
  });
10543
10560
  }
10544
10561
 
10562
+ function createLogsCommand() {
10563
+ return new Command("logs").description("Fetch application logs from the linked digital twin").action(async () => {
10564
+ try {
10565
+ const session = await loadSession();
10566
+ if (!session) {
10567
+ console.error(chalk.red("Not logged in. Please run 'vention login' first."));
10568
+ process.exit(1);
10569
+ }
10570
+ const currentDir = process.cwd();
10571
+ const machineCodeAppDirectoryInfo = await readMachineCodeAppDirectoryInfo(currentDir);
10572
+ if (!machineCodeAppDirectoryInfo) {
10573
+ console.error(chalk.red("This directory is not linked to a Vention application."));
10574
+ console.error(chalk.red("Please run 'vention pull' or 'vention link' first."));
10575
+ process.exit(1);
10576
+ }
10577
+ const linkedAllocation = await checkIfDesignHasLiveAllocation(session, machineCodeAppDirectoryInfo.designId);
10578
+ if (!linkedAllocation) {
10579
+ console.error(chalk.red("Sorry, it seems you do not have that design open with the MachineLogic tab selected."));
10580
+ console.error(chalk.red("Please go to your browser, open your design, and navigate to the MachineLogic page."));
10581
+ process.exit(1);
10582
+ }
10583
+ const logs = await getApplicationLogs(session.environment, linkedAllocation.designId, linkedAllocation.sessionId, machineCodeAppDirectoryInfo.applicationId);
10584
+ console.log(logs);
10585
+ } catch (error) {
10586
+ handleCommandError(error, "Failed to fetch application logs");
10587
+ }
10588
+ });
10589
+ }
10590
+
10545
10591
  const ventionLogo = `
10546
10592
  ╔════════════════════════════════════════════════════════════════════════════════════════════════════════╗
10547
10593
  ║ ║
@@ -10575,6 +10621,7 @@ program.addCommand(createLoginCommand());
10575
10621
  program.addCommand(createLinkCommand());
10576
10622
  program.addCommand(createPushCommand());
10577
10623
  program.addCommand(createPullCommand());
10624
+ program.addCommand(createLogsCommand());
10578
10625
  function runProgram() {
10579
10626
  const showLogoConditions = [process.argv.length <= 2, process.argv.includes("--help"), process.argv.includes("-h")];
10580
10627
  if (showLogoConditions.some(Boolean)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vention/vention-cli",
3
- "version": "0.27.0",
3
+ "version": "0.27.2",
4
4
  "description": "CLI tool for Vention applications",
5
5
  "type": "module",
6
6
  "engines": {
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare function createLogsCommand(): Command;
@@ -27,3 +27,4 @@ export declare const getAllApplicationsWithSourceCode: (environment: SessionData
27
27
  export declare const getLibraryAssets: (environment: SessionData["environment"], designId: number, sessionId: string) => Promise<Asset[] | undefined>;
28
28
  export declare const getMmConfiguration: (environment: SessionData["environment"], designId: number, sessionId: string) => Promise<unknown>;
29
29
  export declare const pushApplicationToDigitalTwin: <T = unknown>(environment: SessionData["environment"], designId: number, sessionId: string, application: PushApplicationRequest) => Promise<T>;
30
+ export declare const getApplicationLogs: (environment: SessionData["environment"], designId: number, sessionId: string, applicationId: string) => Promise<string>;
@@ -47,3 +47,17 @@ export declare const PushApplication: {
47
47
  readonly SuccessResolver: ({ requestSpy }?: RawRequestSpyOptions) => PushApplicationTypes["Resolver"];
48
48
  readonly InternalServerErrorResolver: () => PushApplicationTypes["Resolver"];
49
49
  };
50
+ export type GetApplicationLogs = {
51
+ Request: never;
52
+ Response: string;
53
+ Resolver: HttpResponseResolver<{
54
+ applicationId: string;
55
+ }, GetApplicationLogs["Request"], GetApplicationLogs["Response"]>;
56
+ };
57
+ export declare const GetApplicationLogs: {
58
+ readonly Handler: ({ resolver, remoteHost }: HandlerParams<GetApplicationLogs["Resolver"]>, mswOptions?: RequestHandlerOptions) => HttpHandler;
59
+ readonly SuccessResolver: ({ logs }: {
60
+ logs: string;
61
+ }) => GetApplicationLogs["Resolver"];
62
+ readonly NotFoundResolver: () => GetApplicationLogs["Resolver"];
63
+ };
@@ -0,0 +1,2 @@
1
+ import { vi } from "vitest";
2
+ export declare const mockProcessExit: () => ReturnType<typeof vi.spyOn>;