From 3f6f8fea6ecb6d94bb0c76bd1ed705033db8af21 Mon Sep 17 00:00:00 2001 From: Qian Li Date: Fri, 15 Mar 2024 17:59:00 -0700 Subject: [PATCH] [v1.0 patch] Changes to support Windows (#342) (#346) Add windows support --------- Co-authored-by: Peter Kraft Co-authored-by: chuck-dbos <134347445+chuck-dbos@users.noreply.github.com> --- .gitignore | 2 + README.md | 37 +++++++++++++++---- .../applications/deploy-app-code.ts | 22 ++++++++++- packages/dbos-cloud/cloudutils.ts | 26 +------------ 4 files changed, 53 insertions(+), 34 deletions(-) diff --git a/.gitignore b/.gitignore index 06fd181de..afa4d86c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ .dbos/ +.vscode/ + # Logs logs *.log diff --git a/README.md b/README.md index 630298746..859162ffe 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,40 @@ -# DBOS Typescript SDK +# DBOS TypeScript SDK -The DBOS SDK (from [DBOS, Inc.](https://dbos.dev)) is a **transactional serverless Typescript framework.** -DBOS fully embraces the power of your application database, helping you write backend applications that are reliable by default. -It runs your Typescript functions as database transactions, guarantees they run "once and only once" for each request, and orchestrates them into workflows so reliable that if your service is interrupted, they resume exactly where they left off. +DBOS is a **transactional serverless** SDK and platform that helps you develop and deploy database-backed TypeScript applications. +You develop your applications in TypeScript and PostgreSQL with this SDK, test them locally, then deploy them to DBOS Cloud in minutes. You want to build your next database-backed application with DBOS because: -- **It's simple**. Write your business logic using serverless functions, test them locally, and deploy them to [DBOS Cloud](https://docs.dbos.dev/getting-started/quickstart-cloud) with the push of a button. Store all your data in Postgres—we'll manage the connections and transactions for you. -- **It's reliable by default**. If your workflows are interrupted for any reason, they [will always resume from where they left off](https://docs.dbos.dev/tutorials/workflow-tutorial#reliability-guarantees). Reliable message delivery is [built in](https://docs.dbos.dev//tutorials/workflow-communication-tutorial#reliability-guarantees-1). Idempotency is [built in](https://docs.dbos.dev/tutorials/idempotency-tutorial). -- **It makes debugging easy**. With our [time travel debugger](https://docs.dbos.dev/cloud-tutorials/timetravel-debugging), you can "rewind time" and replay any DBOS Cloud trace locally on your computer, exactly as it originally happened. Whatever the issue is, we'll help you reproduce it. +- **It's simple**. Write your business logic using serverless functions, test them locally, and deploy them to [DBOS Cloud](https://docs.dbos.dev/getting-started/quickstart-cloud) in minutes. Store all your data in Postgres—we'll manage the connections and transactions for you. +- **It's reliable by default**. If your workflows are interrupted for any reason, they [will always resume from where they left off](https://docs.dbos.dev/tutorials/workflow-tutorial#reliability-guarantees). Reliable message delivery is [built in](https://docs.dbos.dev/tutorials/workflow-communication-tutorial#reliability-guarantees-1). Idempotency is [built in](https://docs.dbos.dev/tutorials/idempotency-tutorial). +- **It makes debugging easy**. With our [time travel debugger](https://docs.dbos.dev/cloud-tutorials/timetravel-debugging), you can "rewind time" and replay any DBOS Cloud trace locally on your computer, exactly as it originally happened. ## Getting Started The fastest way to get started with DBOS is by following the [quickstart](https://docs.dbos.dev/getting-started/quickstart), where you'll learn how to get a DBOS application running in less than five minutes. +## Main Features + +Here are some of the core features of the DBOS TypeScript SDK: + +| Feature | Description +| ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | +| [Transactions](https://docs.dbos.dev/tutorials/transaction-tutorial) | Easily and safely query your application database +| [Workflows](https://docs.dbos.dev/tutorials/workflow-tutorial) | Reliable workflow orchestration—resume your program after any failure. +| [HTTP Serving](https://docs.dbos.dev/tutorials/http-serving-tutorial) | Set up endpoints to serve requests from your application. +| [Idempotency](https://docs.dbos.dev/tutorials/idempotency-tutorial) | Automatically make any request idempotent, so your requests happen exactly once. +| [Authentication and Authorization](https://docs.dbos.dev/tutorials/authentication-authorization) | Secure your HTTP endpoints so only authorized users can access them. +| [Testing and Debugging](https://docs.dbos.dev/tutorials/testing-tutorial) | Easily write unit tests for your applications, compatible with Jest and other popular testing frameworks. + +And DBOS Cloud: + +| Feature | Description +| ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | +| [Serverless App Deployment](https://docs.dbos.dev/cloud-tutorials/application-management) | Deploy apps to DBOS Cloud in minutes. +| [Time Travel Debugging](https://docs.dbos.dev/cloud-tutorials/timetravel-debugging) | Replay any DBOS Cloud trace locally on your computer. +| [Cloud Database Management](https://docs.dbos.dev/cloud-tutorials/database-management) | Provision cloud Postgres instances for your applications. +| [Built-in Observability](https://docs.dbos.dev/cloud-tutorials/monitoring-dashboard) | Built-in log capture, request tracing, and dashboards. + ## Documentation You can find our full documentation at [https://docs.dbos.dev/](https://docs.dbos.dev/). @@ -22,7 +43,7 @@ Check out our [Getting Started](https://docs.dbos.dev/getting-started/) for an o Our documentation has the following sections: -- [Getting Started](https://docs.dbos.dev/getting-started/) +- [Getting Started](https://docs.dbos.dev/getting-started) - [DBOS SDK Tutorials](https://docs.dbos.dev/category/dbos-sdk-tutorials) - [DBOS Cloud Tutorials](https://docs.dbos.dev/category/dbos-cloud-tutorials) - [API Reference](https://docs.dbos.dev/category/reference) diff --git a/packages/dbos-cloud/applications/deploy-app-code.ts b/packages/dbos-cloud/applications/deploy-app-code.ts index c26c1c187..1497efbf8 100644 --- a/packages/dbos-cloud/applications/deploy-app-code.ts +++ b/packages/dbos-cloud/applications/deploy-app-code.ts @@ -11,13 +11,31 @@ type DeployOutput = { ApplicationVersion: string; } +function convertPathForGlob(p: string) { + if (path.sep === '\\') { + return p.replace(/\\/g, '/'); + } + return p; +} async function createZipData(): Promise { const zip = new JSZip(); - const files = await fg(`${process.cwd()}/**/*`, { dot: true, onlyFiles: true, ignore: [`**/${dbosEnvPath}/**`, '**/node_modules/**', '**/dist/**', `**/${dbosConfigFilePath}`] }); + const globPattern = convertPathForGlob(path.join(process.cwd(), '**', '*')); + + const files = await fg(globPattern, { + dot: true, + onlyFiles: true, + ignore: [ + `**/${dbosEnvPath}/**`, + '**/node_modules/**', + '**/dist/**', + '**/.git/**', + `**/${dbosConfigFilePath}`, + ] + }); files.forEach(file => { - const relativePath = file.replace(`${process.cwd()}/`, ''); + const relativePath = path.relative(process.cwd(), file).replace(/\\/g, '/'); const fileData = readFileSync(file); zip.file(relativePath, fileData, { binary: true }); }); diff --git a/packages/dbos-cloud/cloudutils.ts b/packages/dbos-cloud/cloudutils.ts index 2162b5bad..d7268073c 100644 --- a/packages/dbos-cloud/cloudutils.ts +++ b/packages/dbos-cloud/cloudutils.ts @@ -1,5 +1,4 @@ import TransportStream = require("winston-transport"); -import { execSync, spawn, StdioOptions } from 'child_process'; import { transports, createLogger, format, Logger } from "winston"; import fs from "fs"; import { AxiosError } from "axios"; @@ -97,29 +96,8 @@ export function deleteCredentials() { } export function writeCredentials(credentials: DBOSCloudCredentials) { - execSync(`mkdir -p ${dbosEnvPath}`); - fs.writeFileSync(`${dbosEnvPath}/credentials`, JSON.stringify(credentials), "utf-8"); -} - -// Run a command, streaming its output to stdout -export function runCommand(command: string, args: string[] = []): Promise { - return new Promise((resolve, reject) => { - const stdio: StdioOptions = 'inherit'; - - const process = spawn(command, args, { stdio }); - - process.on('close', (code) => { - if (code === 0) { - resolve(code); - } else { - reject(new Error(`Command "${command}" exited with code ${code}`)); - } - }); - - process.on('error', (error) => { - reject(error); - }); - }); + fs.mkdirSync(dbosEnvPath, { recursive: true }); + fs.writeFileSync(path.join(dbosEnvPath, 'credentials'), JSON.stringify(credentials), "utf-8"); } export function checkReadFile(path: string, encoding: BufferEncoding = "utf8"): string | Buffer {