Edits history of script submission #22228 for ' workspace-job-migrator (windmill)'

  • bun
    import wmill from "windmill-cli";
    
    export async function main(
      source_workspace_id: string,
      target_workspace_id: string
    ) {
      console.log("DEBUG: Migrate jobs...");
      await wmill_run(
        "workspace",
        "migrate",
        target_workspace_id,
        "--source-workspace",
        source_workspace_id,
        "--token",
        process.env["WM_TOKEN"] ?? "",
        "--remote",
        process.env["BASE_URL"] + "/",
      );
      console.log("DEBUG: Migrate jons completed");
    }
    
    async function wmill_run(
      ...cmd: string[]
    ) {
      cmd = cmd.filter((elt) => elt !== "");
    
      console.log(`DEBUG: Running CLI command: 'wmill ${cmd.slice().join(" ")} ...'`);
    
      // Capture CLI output to parse JSON response
      const originalLog = console.log;
      let cliOutput = "";
      console.log = (msg: string) => {
        cliOutput += msg + "\n";
        originalLog(msg);
      };
    
      try {
        await wmill.parse(cmd);
        console.log = originalLog;
        console.log("DEBUG: CLI command executed successfully");
      } catch (error) {
        console.log = originalLog;
        console.log("DEBUG: CLI command execution failed:", error);
        throw error;
      }
      // END capture log
    
      console.log("DEBUG: Captured CLI output length:", cliOutput.length);
      console.log("DEBUG: Raw CLI output:", cliOutput);
    
      try {
        console.log("DEBUG: Attempting to parse CLI output as JSON...");
    
        // Find the first occurrence of '{' which indicates the start of JSON
        const jsonStartIndex = cliOutput.indexOf('{');
        if (jsonStartIndex === -1) {
          console.log("DEBUG: No JSON found in CLI output");
          return {};
        }
    
        // Extract everything from the first '{' to the end
        const jsonString = cliOutput.substring(jsonStartIndex).trim();
        console.log("DEBUG: Extracted JSON string:", jsonString);
    
        const res = JSON.parse(jsonString);
        console.log("DEBUG: Successfully parsed JSON result:", res);
        return res;
      } catch (e) {
        console.log("DEBUG: Failed to parse CLI output as JSON:", e);
        console.log("DEBUG: Returning empty object");
        return {};
      }
    }
    
    

    Submitted by dieriba.pro916 200 days ago

  • bun
    import wmill from "windmill-cli";
    
    export async function main(
      source_workspace_id: string,
      target_workspace_id: string
    ) {
      console.log("DEBUG: Starting main function", {
        source_workspace_id,
        target_workspace_id,
      });
    
      // Set up workspace context for CLI commands
      console.log("DEBUG: Setting up workspace...");
      await wmill_run(
        "workspace",
        "add",
        source_workspace_id,
        source_workspace_id,
        process.env["BASE_URL"] + "/",
        "--token",
        process.env["WM_TOKEN"] ?? ""
      );
      console.log("DEBUG: Workspace setup completed");
    
      console.log("DEBUG: Migrate jobs...");
      await wmill_run(
        "workspace",
        "migrate",
        target_workspace_id
      );
      console.log("DEBUG: Migrate jons completed");
    
    }
    
    async function wmill_run(
      ...cmd: string[]
    ) {
      cmd = cmd.filter((elt) => elt !== "");
    
      console.log(`DEBUG: Running CLI command: 'wmill ${cmd.slice().join(" ")} ...'`);
    
      // Capture CLI output to parse JSON response
      const originalLog = console.log;
      let cliOutput = "";
      console.log = (msg: string) => {
        cliOutput += msg + "\n";
        originalLog(msg);
      };
    
      try {
        await wmill.parse(cmd);
        console.log = originalLog;
        console.log("DEBUG: CLI command executed successfully");
      } catch (error) {
        console.log = originalLog;
        console.log("DEBUG: CLI command execution failed:", error);
        throw error;
      }
      // END capture log
    
      console.log("DEBUG: Captured CLI output length:", cliOutput.length);
      console.log("DEBUG: Raw CLI output:", cliOutput);
    
      try {
        console.log("DEBUG: Attempting to parse CLI output as JSON...");
    
        // Find the first occurrence of '{' which indicates the start of JSON
        const jsonStartIndex = cliOutput.indexOf('{');
        if (jsonStartIndex === -1) {
          console.log("DEBUG: No JSON found in CLI output");
          return {};
        }
    
        // Extract everything from the first '{' to the end
        const jsonString = cliOutput.substring(jsonStartIndex).trim();
        console.log("DEBUG: Extracted JSON string:", jsonString);
    
        const res = JSON.parse(jsonString);
        console.log("DEBUG: Successfully parsed JSON result:", res);
        return res;
      } catch (e) {
        console.log("DEBUG: Failed to parse CLI output as JSON:", e);
        console.log("DEBUG: Returning empty object");
        return {};
      }
    }
    
    

    Submitted by dieriba.pro916 200 days ago

  • bun
    import wmill from "windmill-cli";
    
    export async function main(
      source_workspace_id: string,
      target_workspace_id: string
    ) {
      console.log("DEBUG: Starting main function", {
        source_workspace_id,
        target_workspace_id,
      });
    
      // Set up workspace context for CLI commands
      console.log("DEBUG: Setting up workspace...");
      await wmill_run(
        "workspace",
        "add",
        source_workspace_id,
        source_workspace_id,
        process.env["BASE_URL"] + "/",
        "--token",
        process.env["WM_TOKEN"] ?? ""
      );
      console.log("DEBUG: Workspace setup completed");
    
      console.log("DEBUG: Migrate jobs...");
      await wmill_run(
        "workspace",
        "migrate",
        target_workspace_id
      );
      console.log("DEBUG: Migrate jons completed");
    
    }
    
    async function wmill_run(
      secret_position: number | undefined | null,
      ...cmd: string[]
    ) {
      cmd = cmd.filter((elt) => elt !== "");
      
      console.log(`DEBUG: Running CLI command: 'wmill ${cmd.slice().join(" ")} ...'`);
    
      // Capture CLI output to parse JSON response
      const originalLog = console.log;
      let cliOutput = "";
      console.log = (msg: string) => {
        cliOutput += msg + "\n";
        originalLog(msg);
      };
    
      try {
        await wmill.parse(cmd);
        console.log = originalLog;
        console.log("DEBUG: CLI command executed successfully");
      } catch (error) {
        console.log = originalLog;
        console.log("DEBUG: CLI command execution failed:", error);
        throw error;
      }
      // END capture log
    
      console.log("DEBUG: Captured CLI output length:", cliOutput.length);
      console.log("DEBUG: Raw CLI output:", cliOutput);
    
      try {
        console.log("DEBUG: Attempting to parse CLI output as JSON...");
    
        // Find the first occurrence of '{' which indicates the start of JSON
        const jsonStartIndex = cliOutput.indexOf('{');
        if (jsonStartIndex === -1) {
          console.log("DEBUG: No JSON found in CLI output");
          return {};
        }
    
        // Extract everything from the first '{' to the end
        const jsonString = cliOutput.substring(jsonStartIndex).trim();
        console.log("DEBUG: Extracted JSON string:", jsonString);
    
        const res = JSON.parse(jsonString);
        console.log("DEBUG: Successfully parsed JSON result:", res);
        return res;
      } catch (e) {
        console.log("DEBUG: Failed to parse CLI output as JSON:", e);
        console.log("DEBUG: Returning empty object");
        return {};
      }
    }
    
    

    Submitted by dieriba.pro916 200 days ago

  • bun
    import wmill from "windmill-cli";
    
    export async function main(
      source_workspace_id: string,
      target_workspace_id: string
    ) {
      let safeDirectoryPath: string | undefined;
      console.log("DEBUG: Starting main function", {
        source_workspace_id,
        // repo_url_resource_path,
        target_workspace_id,
      });
    
      // Set up workspace context for CLI commands
      console.log("DEBUG: Setting up workspace...");
      await wmill_run(
        6,
        "workspace",
        "add",
        workspace_id,
        workspace_id,
        process.env["BASE_URL"] + "/",
        "--token",
        process.env["WM_TOKEN"] ?? ""
      );
      console.log("DEBUG: Workspace setup completed");
    
    
    }
      
    
    
    async function wmill_run(
      secret_position: number | undefined | null,
      ...cmd: string[]
    ) {
      cmd = cmd.filter((elt) => elt !== "");
      const cmd2 = cmd.slice();
      if (secret_position) {
        cmd2[secret_position] = "***";
      }
      console.log(`DEBUG: Running CLI command: 'wmill ${cmd2.join(" ")} ...'`);
    
      // Capture CLI output to parse JSON response
      const originalLog = console.log;
      let cliOutput = "";
      console.log = (msg: string) => {
        cliOutput += msg + "\n";
        originalLog(msg);
      };
    
      try {
        await wmill.parse(cmd);
        console.log = originalLog;
        console.log("DEBUG: CLI command executed successfully");
      } catch (error) {
        console.log = originalLog;
        console.log("DEBUG: CLI command execution failed:", error);
        throw error;
      }
      // END capture log
    
      console.log("DEBUG: Captured CLI output length:", cliOutput.length);
      console.log("DEBUG: Raw CLI output:", cliOutput);
    
      try {
        console.log("DEBUG: Attempting to parse CLI output as JSON...");
    
        // Find the first occurrence of '{' which indicates the start of JSON
        const jsonStartIndex = cliOutput.indexOf('{');
        if (jsonStartIndex === -1) {
          console.log("DEBUG: No JSON found in CLI output");
          return {};
        }
    
        // Extract everything from the first '{' to the end
        const jsonString = cliOutput.substring(jsonStartIndex).trim();
        console.log("DEBUG: Extracted JSON string:", jsonString);
    
        const res = JSON.parse(jsonString);
        console.log("DEBUG: Successfully parsed JSON result:", res);
        return res;
      } catch (e) {
        console.log("DEBUG: Failed to parse CLI output as JSON:", e);
        console.log("DEBUG: Returning empty object");
        return {};
      }
    }
    
    

    Submitted by dieriba.pro916 200 days ago

  • bun
    import wmill from "windmill-cli";
    
    export async function main(
      source_workspace_id: string,
      target_workspace_id: string
    ) {
      let safeDirectoryPath: string | undefined;
      console.log("DEBUG: Starting main function", {
        source_workspace_id,
        // repo_url_resource_path,
        target_workspace_id,
      });
    
    }
      // Set up workspace context for CLI commands
      console.log("DEBUG: Setting up workspace...");
      await wmill_run(
        6,
        "workspace",
        "add",
        workspace_id,
        workspace_id,
        process.env["BASE_URL"] + "/",
        "--token",
        process.env["WM_TOKEN"] ?? ""
      );
      console.log("DEBUG: Workspace setup completed");
    
    
    
    async function wmill_run(
      secret_position: number | undefined | null,
      ...cmd: string[]
    ) {
      cmd = cmd.filter((elt) => elt !== "");
      const cmd2 = cmd.slice();
      if (secret_position) {
        cmd2[secret_position] = "***";
      }
      console.log(`DEBUG: Running CLI command: 'wmill ${cmd2.join(" ")} ...'`);
    
      // Capture CLI output to parse JSON response
      const originalLog = console.log;
      let cliOutput = "";
      console.log = (msg: string) => {
        cliOutput += msg + "\n";
        originalLog(msg);
      };
    
      try {
        await wmill.parse(cmd);
        console.log = originalLog;
        console.log("DEBUG: CLI command executed successfully");
      } catch (error) {
        console.log = originalLog;
        console.log("DEBUG: CLI command execution failed:", error);
        throw error;
      }
      // END capture log
    
      console.log("DEBUG: Captured CLI output length:", cliOutput.length);
      console.log("DEBUG: Raw CLI output:", cliOutput);
    
      try {
        console.log("DEBUG: Attempting to parse CLI output as JSON...");
    
        // Find the first occurrence of '{' which indicates the start of JSON
        const jsonStartIndex = cliOutput.indexOf('{');
        if (jsonStartIndex === -1) {
          console.log("DEBUG: No JSON found in CLI output");
          return {};
        }
    
        // Extract everything from the first '{' to the end
        const jsonString = cliOutput.substring(jsonStartIndex).trim();
        console.log("DEBUG: Extracted JSON string:", jsonString);
    
        const res = JSON.parse(jsonString);
        console.log("DEBUG: Successfully parsed JSON result:", res);
        return res;
      } catch (e) {
        console.log("DEBUG: Failed to parse CLI output as JSON:", e);
        console.log("DEBUG: Returning empty object");
        return {};
      }
    }
    
    

    Submitted by dieriba.pro916 200 days ago

  • bun
    import wmill from "windmill-cli";
    
    export async function main(
      source_workspace_id: string,
      target_workspace_id: string
    ) {
      let safeDirectoryPath: string | undefined;
      console.log("DEBUG: Starting main function", {
        source_workspace_id,
        // repo_url_resource_path,
        target_workspace_id,
      });
    
    }
      // Set up workspace context for CLI commands
      console.log("DEBUG: Setting up workspace...");
      await wmill_run(
        6,
        "workspace",
        "add",
        workspace_id,
        workspace_id,
        process.env["BASE_URL"] + "/",
        "--token",
        process.env["WM_TOKEN"] ?? ""
      );
      console.log("DEBUG: Workspace setup completed");
    
    
    
    async function wmill_run(
      secret_position: number | undefined | null,
      ...cmd: string[]
    ) {
      cmd = cmd.filter((elt) => elt !== "");
      const cmd2 = cmd.slice();
      if (secret_position) {
        cmd2[secret_position] = "***";
      }
      console.log(`DEBUG: Running CLI command: 'wmill ${cmd2.join(" ")} ...'`);
    
      // Capture CLI output to parse JSON response
      const originalLog = console.log;
      let cliOutput = "";
      console.log = (msg: string) => {
        cliOutput += msg + "\n";
        originalLog(msg);
      };
    
      try {
        await wmill.parse(cmd);
        console.log = originalLog;
        console.log("DEBUG: CLI command executed successfully");
      } catch (error) {
        console.log = originalLog;
        console.log("DEBUG: CLI command execution failed:", error);
        throw error;
      }
      // END capture log
    
      console.log("DEBUG: Captured CLI output length:", cliOutput.length);
      console.log("DEBUG: Raw CLI output:", cliOutput);
    
      try {
        console.log("DEBUG: Attempting to parse CLI output as JSON...");
    
        // Find the first occurrence of '{' which indicates the start of JSON
        const jsonStartIndex = cliOutput.indexOf('{');
        if (jsonStartIndex === -1) {
          console.log("DEBUG: No JSON found in CLI output");
          return {};
        }
    
        // Extract everything from the first '{' to the end
        const jsonString = cliOutput.substring(jsonStartIndex).trim();
        console.log("DEBUG: Extracted JSON string:", jsonString);
    
        const res = JSON.parse(jsonString);
        console.log("DEBUG: Successfully parsed JSON result:", res);
        return res;
      } catch (e) {
        console.log("DEBUG: Failed to parse CLI output as JSON:", e);
        console.log("DEBUG: Returning empty object");
        return {};
      }
    }
    
    

    Submitted by dieriba.pro916 200 days ago

  • bun
    import wmill from "windmill-cli";
    
    
    
    export async function main(source_workspace_id: string, target_workspace_id: string) {
    
      console.log(`Starting migration of jobs from ${source_workspace_id} to ${target_workspace_id}`);
    
      try {
        const cmd = [
          "workspace",
          "add"
        ];
    
        console.log("Running CLI command:", cmd.join(" "));
    
        await wmill.parse(cmd)
    
        console.log(`Successfully migrated jobs from ${source_workspace_id} to ${target_workspace_id}`);
    
        return {
          success: true,
          message: `Jobs migration completed from ${source_workspace_id} to ${target_workspace_id}`,
          source_workspace_id,
          target_workspace_id,
        };
      } catch (error) {
        console.error("Migration failed:", error);
        throw new Error(`Migration failed: ${error}`);
      }
    }

    Submitted by dieriba.pro916 200 days ago

  • bun
    import wmill from "windmill-cli";
    
    
    
    export async function main(source_workspace_id: string, target_workspace_id: string) {
    
      console.log(`Starting migration of jobs from ${source_workspace_id} to ${target_workspace_id}`);
    
      try {
        const cmd = [
          "workspace",
          "migrate",
          target_workspace_id,
          "--token",
          process.env["WM_TOKEN"] ?? "",
          "--remote",
          process.env["BASE_URL"] ?? "",
          "--source-workspace",
          source_workspace_id
        ];
    
        console.log("Running CLI command:", cmd.join(" "));
    
        console.log(`Successfully migrated jobs from ${source_workspace_id} to ${target_workspace_id}`);
    
        return {
          success: true,
          message: `Jobs migration completed from ${source_workspace_id} to ${target_workspace_id}`,
          source_workspace_id,
          target_workspace_id,
        };
      } catch (error) {
        console.error("Migration failed:", error);
        throw new Error(`Migration failed: ${error}`);
      }
    }

    Submitted by dieriba.pro916 200 days ago

  • bun
    import wmill from "windmill-cli";
    
    
    
    export async function main(source_workspace_id: string, target_workspace_id: string) {
    
      console.log(`Starting migration of jobs from ${source_workspace_id} to ${target_workspace_id}`);
    
      try {
        const cmd = [
          "workspace",
          "migrate",
          target_workspace_id,
          "--token",
          process.env["WM_TOKEN"] ?? "",
          "--remote",
          process.env["BASE_URL"] ?? "",
          "--source-workspace",
          source_workspace_id
        ];
    
        console.log("Running CLI command:", cmd.join(" "));
        await wmill.parse(cmd);
    
        console.log(`Successfully migrated jobs from ${source_workspace_id} to ${target_workspace_id}`);
    
        return {
          success: true,
          message: `Jobs migration completed from ${source_workspace_id} to ${target_workspace_id}`,
          source_workspace_id,
          target_workspace_id,
        };
      } catch (error) {
        console.error("Migration failed:", error);
        throw new Error(`Migration failed: ${error}`);
      }
    }

    Submitted by dieriba.pro916 200 days ago

  • bun
    import wmill from "windmill-cli";
    
    
    
    export async function main(source_workspace_id: string, target_workspace_id: string) {
    
      console.log(`Starting migration of jobs from ${source_workspace_id} to ${target_workspace_id}`);
    
      try {
        const cmd = [
          "workspace",
          "migrate",
          target_workspace_id,
          "--token",
          process.env["WM_TOKEN"] ?? "",
          "--remote",
          process.env["BASE_URL"] ?? "",
          "--source-workspace",
          source_workspace_id
        ];
    
        console.log("Running CLI command:", cmd.join(" "));
        await wmill.parse(cmd);
    
        console.log(`Successfully migrated jobs from ${source_workspace_id} to ${target_workspace_id}`);
    
        return {
          success: true,
          message: `Jobs migration completed from ${source_workspace_id} to ${target_workspace_id}`,
          source_workspace_id,
          target_workspace_id,
        };
      } catch (error) {
        console.error("Migration failed:", error);
        throw new Error(`Migration failed: ${error}`);
      }
    }

    Submitted by dieriba.pro916 200 days ago

  • bun
    import wmill from "windmill-cli";
    
    
    
    export async function main(source_workspace_id: string, target_workspace_id: string) {
    
      console.log(`Starting migration of jobs from ${source_workspace_id} to ${target_workspace_id}`);
    
      try {
        const cmd = [
          "workspace",
          "migrate",
          target_workspace_id,
          "--token",
          process.env["WM_TOKEN"] ?? "",
          "--remote",
          process.env["BASE_URL"] ?? "",
          "--source-workspace",
          source_workspace_id
        ];
    
        console.log("Running CLI command:", cmd.join(" "));
        await wmill.parse(cmd);
    
        console.log(`Successfully migrated jobs from ${source_workspace_id} to ${target_workspace_id}`);
    
        return {
          success: true,
          message: `Jobs migration completed from ${source_workspace_id} to ${target_workspace_id}`,
          source_workspace_id,
          target_workspace_id,
        };
      } catch (error) {
        console.error("Migration failed:", error);
        throw new Error(`Migration failed: ${error}`);
      }
    }

    Submitted by dieriba.pro916 200 days ago

  • bun
    import wmill from 'windmill-cli'
    
    export async function main(source_workspace_id: string, target_workspace_id: string) {
      console.log({ source_workspace_id, target_workspace_id })
      return { source_workspace_id, target_workspace_id }
    }

    Submitted by dieriba.pro916 200 days ago