diff --git a/.agents/skills/document-component/SKILL.md b/.agents/skills/document-component/SKILL.md deleted file mode 100644 index bae55d7774..0000000000 --- a/.agents/skills/document-component/SKILL.md +++ /dev/null @@ -1,22 +0,0 @@ -# Document Component - -Steps to add a new component to the SST docs. - -1. Register in docs generator - - Add the component `.ts` path to `entryPoints` in `www/generate.ts` - -2. Add matching public getters - - Ensure every property returned by `getSSTLink()` has a corresponding public getter on the class - - The generator crashes otherwise because `renderLinks()` looks for a getter with the same name - -3. Analyze docs for relevant places to link the component - - Search existing guides (e.g. `cloudflare.mdx`) and component overviews for lists of related components - - Add the new component link where appropriate - -4. Add to Astro sidebar - - Add the generated doc slug to the appropriate section in `www/astro.config.mjs` - - Follow the existing visual ordering: components are sorted from shortest to longest name (least to most characters) - -5. Generate docs - - Run `bun run docs:generate` - diff --git a/.air.toml b/.air.toml deleted file mode 100644 index f76accf02d..0000000000 --- a/.air.toml +++ /dev/null @@ -1,51 +0,0 @@ -root = "." -testdata_dir = "testdata" -tmp_dir = "tmp" - -[build] - args_bin = [] - bin = "./dist/sst" - cmd = "go build -o ./dist/sst ./cmd/sst" - delay = 1000 - exclude_dir = ["assets", "tmp", "vendor", "testdata", "node_modules", "examples"] - exclude_file = [] - exclude_regex = ["_test.go"] - exclude_unchanged = false - follow_symlink = false - full_bin = "" - include_dir = [] - include_ext = ["go", "tpl", "tmpl", "html"] - include_file = [] - kill_delay = "0s" - log = "build-errors.log" - poll = false - poll_interval = 0 - post_cmd = [] - pre_cmd = [] - rerun = false - rerun_delay = 500 - send_interrupt = false - stop_on_error = false - -[color] - app = "" - build = "yellow" - main = "magenta" - runner = "green" - watcher = "cyan" - -[log] - main_only = false - time = false - -[misc] - clean_on_exit = false - -[proxy] - app_port = 0 - enabled = false - proxy_port = 0 - -[screen] - clear_on_rebuild = false - keep_scroll = true diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000000..0e7fbfad50 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,35 @@ +# Don't ever lint node_modules +node_modules + +# Don't lint build output (make sure it's set to your correct build folder name) +dist + +# Don't lint nyc coverage output +coverage + +# Don't lint cdk.out +cdk.out + +# Don't lint build outputs in test +/packages/cli/test/*/.build/** +/packages/cli/test/*/cdk.out/** + +# Don't lint templates +/packages/create-serverless-stack/templates/** + +# Don't lint eslint tests that need to fail +/packages/cli/test/eslint-cdk-js/** +/packages/cli/test/eslint-cdk-ts/** +/packages/cli/test/eslint-lambda-js/** +/packages/cli/test/eslint-lambda-ts/** +/packages/cli/test/eslint-disabled-js/** +/packages/cli/test/eslint-disabled-ts/** +/packages/cli/test/eslint-ignore-rule-js/** +/packages/cli/test/eslint-ignore-rule-ts/** +/packages/cli/test/eslint-ignore-patterns/** +/packages/cli/test/eslint-lambda-override-eslintrc/** +/packages/cli/test/lambda-override-tsconfig/** +/packages/cli/test/start/src/** + +# Docs build files +www/build/** diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000000..6a18aa32cf --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,47 @@ +{ + "root": true, + "env": { + "commonjs": true, + "es6": true, + "node": true, + "jest": true + }, + "globals": { + "Atomics": "readonly", + "SharedArrayBuffer": "readonly" + }, + "parser": "@babel/eslint-parser", + "parserOptions": { + "requireConfigFile": false, + "babelOptions": { + "presets": [ + [ + "@babel/preset-env", + { + "targets": { + "node": "10" + } + } + ] + ], + "plugins": ["@babel/plugin-proposal-class-properties"] + } + }, + "plugins": ["@babel"], + "extends": "eslint:recommended", + "rules": {}, + "overrides": [ + { + "files": ["**/*.ts", "**/*.tsx"], + "env": { "browser": true, "es6": true, "node": true }, + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended" + ], + "globals": { "Atomics": "readonly", "SharedArrayBuffer": "readonly" }, + "parser": "@typescript-eslint/parser", + "plugins": ["@typescript-eslint"], + "rules": {} + } + ] +} diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml deleted file mode 100644 index 128a071211..0000000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: check - -on: - pull_request: - branches: - - dev - types: [opened, synchronize, reopened] - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - check: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup Bun - uses: oven-sh/setup-bun@v1 - with: - bun-version: latest - - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: ">=1.23.2" - cache: true - - - name: Setup QEMU - uses: docker/setup-qemu-action@v3 - - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Install dependencies - run: bun install --frozen-lockfile - - - name: Download Go modules - run: go mod download - - - name: Check types - run: cd platform && bun tsc --noEmit - - - name: Build platform - run: ./platform/scripts/build - env: - DOCKER_PUSH: false - - - name: Setup uv - uses: astral-sh/setup-uv@v4 - with: - version: "latest" - - - name: Run Go tests - run: go test -vet=all ./... - - - name: Build CLI - run: go build -o sst ./cmd/sst - - - name: Build docs - run: cd www && bun run build - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..97745cd3c0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,33 @@ +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: CI + +on: + push: + branches: [ master, alpha ] + pull_request: + branches: [ master ] + +jobs: + build: + + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + node-version: [10.x, 12.x, 14.x] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: Install dependencies + run: yarn --frozen-lockfile + - name: Lint + run: yarn run lint + - name: Test + run: yarn run test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 553257d0dd..0000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,135 +0,0 @@ -name: release - -on: - workflow_dispatch: - push: - tags: - - "*" - -concurrency: ${{ github.workflow }}-${{ github.ref }} - -permissions: - id-token: write - contents: write - packages: write - -jobs: - goreleaser: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup Bun - uses: oven-sh/setup-bun@v1 - with: - bun-version: latest - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version: "24" - registry-url: "https://registry.npmjs.org" - - - name: Login to GHCR - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Fetch tags - run: git fetch --force --tags - - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: ">=1.23.2" - cache: true - - - name: Setup QEMU - uses: docker/setup-qemu-action@v3 - - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Download Go modules - run: go mod download - - - name: Install dependencies - run: bun i --frozen-lockfile - - - name: TypeScript check - run: cd platform && bun tsc --noEmit - - - name: Build platform - run: ./platform/scripts/build - env: - DOCKER_PUSH: true - - - name: Setup uv - uses: astral-sh/setup-uv@v4 - with: - version: "latest" - - - name: Run Go tests - run: go test -vet=all ./... - - - name: Release CLI - uses: goreleaser/goreleaser-action@v6 - with: - distribution: goreleaser - version: latest - args: release --clean - env: - GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }} - AUR_KEY: ${{ secrets.AUR_KEY }} - - - name: Release JS SDK - run: | - cd sdk/js - bun run release - - - name: Authenticate crates.io - id: crates-auth - uses: rust-lang/crates-io-auth-action@v1 - - - name: Release Rust SDK - run: | - VERSION=$(jq -r .version dist/metadata.json) - cd sdk/rust - sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml - cargo publish --allow-dirty - env: - CARGO_REGISTRY_TOKEN: ${{ steps.crates-auth.outputs.token }} - - - name: Build Python SDK - run: | - VERSION=$(jq -r .version dist/metadata.json) - cd sdk/python - sed -i "s/^version = \".*\"/version = \"$VERSION\"/" pyproject.toml - uv build - - - name: Publish Python SDK - uses: pypa/gh-action-pypi-publish@release/v1 - with: - packages-dir: sdk/python/dist/ - - - name: Announce on Discord - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} - TAG: ${{ github.ref_name }} - run: | - RELEASE_URL="https://github.com/${{ github.repository }}/releases/tag/$TAG" - NOTES=$(gh release view "$TAG" --json body --jq .body \ - | sed -E "s|\(#([0-9]+)\)|([#\1](https://github.com/${{ github.repository }}/pull/\1))|g" \ - | sed -E 's|^\* \[[a-f0-9]+\]\([^)]+\): ||' \ - | sed '/^## Changelog$/d' \ - | sed -E 's|^(.+)$|- \1|') - CONTENT=$(printf '🏷️ [**Release - %s**](%s)\n%s' "$TAG" "$RELEASE_URL" "$NOTES") - PAYLOAD=$(jq -n --arg c "$CONTENT" '{content:$c, flags:4}') - curl -fsS -X POST -H "Content-Type: application/json" \ - -d "$PAYLOAD" "$DISCORD_WEBHOOK_URL" diff --git a/.github/workflows/require-labels.yml b/.github/workflows/require-labels.yml new file mode 100644 index 0000000000..21e6ad3454 --- /dev/null +++ b/.github/workflows/require-labels.yml @@ -0,0 +1,13 @@ +name: Label +on: + pull_request: + types: [opened, labeled, unlabeled, synchronize] +jobs: + required: + runs-on: ubuntu-latest + steps: + - uses: mheap/github-action-required-labels@v1.1.2 + with: + mode: exactly + count: 1 + labels: "breaking, enhancement, bug, documentation, internal, skip changelog" diff --git a/.gitignore b/.gitignore index bdfb61622e..a635185461 100644 --- a/.gitignore +++ b/.gitignore @@ -1,40 +1,110 @@ -.sst -sst -dist -/sst -s -node_modules +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache -# pulumi -Pulumi.*.yaml -Pulumi.yaml +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ -# osx -.DS_Store +# Optional REPL history +.node_repl_history -.netlify +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file .env -tmp - -# coding agents -.termai -.opencode -.idea -.kiro - -# python -__pycache__ -uv.lock - -examples/**/sst-env.d.ts -examples/**/sst.pyi -www/src/content/docs/docs/examples.mdx -www/src/data/changelog.json -examples/**/bun.lock -examples/**/bun.lockb -examples/**/pnpm-lock.yaml -examples/**/package-lock.json -examples/**/uv.lock -examples/**/deno.lock -examples/**/Cargo.lock -examples/**/.env.* +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# Next.js build output +.next + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and *not* Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# CDK +cdk.out + +# Vim +.*.sw* diff --git a/.goreleaser.yml b/.goreleaser.yml deleted file mode 100644 index 67a7c25fc9..0000000000 --- a/.goreleaser.yml +++ /dev/null @@ -1,67 +0,0 @@ -version: 2 -project_name: sst -builds: - - env: - - CGO_ENABLED=0 - goos: - - linux - - darwin - - windows - main: ./cmd/sst - -archives: - - formats: - - tar.gz - name_template: >- - sst- - {{- if eq .Os "darwin" }}mac- - {{- else if eq .Os "windows" }}windows- - {{- else if eq .Os "linux" }}linux-{{end}} - {{- if eq .Arch "amd64" }}x86_64 - {{- else if eq .Arch "#86" }}i386 - {{- else }}{{ .Arch }}{{ end }} - {{- if .Arm }}v{{ .Arm }}{{ end }} - format_overrides: - - goos: windows - formats: - - zip -checksum: - name_template: "checksums.txt" -snapshot: - version_template: "0.0.0-{{ .Timestamp }}" -aurs: - - homepage: "https://github.com/sst/sst" - description: "Deploy anything" - private_key: "{{ .Env.AUR_KEY }}" - git_url: "ssh://aur@aur.archlinux.org/sst-bin.git" - license: "MIT" - package: |- - install -Dm755 ./sst "${pkgdir}/usr/bin/sst" -brews: - - repository: - owner: sst - name: homebrew-tap -nfpms: - - maintainer: sst - description: the sst cli - formats: - - deb - - rpm - file_name_template: >- - {{ .ProjectName }}- - {{- if eq .Os "darwin" }}mac - {{- else }}{{ .Os }}{{ end }}-{{ .Arch }} - -changelog: - use: git - format: "[{{ .SHA }}](https://github.com/anomalyco/sst/commit/{{ .SHA }}): {{ .Message }}" - sort: asc - filters: - exclude: - - "^docs:" - - "^doc:" - - "^test:" - - "^ci:" - - "^ignore:" - - "^example:" - - "^wip:" diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000000..5fca0d518b --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +scripts-prepend-node-path=true diff --git a/.nvim.lua b/.nvim.lua deleted file mode 100644 index a50b3f4caa..0000000000 --- a/.nvim.lua +++ /dev/null @@ -1,5 +0,0 @@ -local opts = { noremap = true, silent = true } - -vim.keymap.set("n", "tb", function() - vim.cmd("!go build -o ./dist/sst ./cmd/sst && ./dist/sst") -end, opts) diff --git a/.prettierignore b/.prettierignore index 6d05b4987d..6ec664b251 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1,6 @@ -# Ignore markdown files in the docs -/www/src/content/docs/docs/**/*.mdx \ No newline at end of file +# Ignore CDK outputs +cdk.out +# Ignore SST outputs +.build +# Ignore templates +/packages/create-serverless-stack/templates/** diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 23830fb423..0000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "git.ignoreLimitWarning": true -} diff --git a/AGENTS.md b/AGENTS.md deleted file mode 120000 index 681311eb9c..0000000000 --- a/AGENTS.md +++ /dev/null @@ -1 +0,0 @@ -CLAUDE.md \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index f6de27996c..0000000000 --- a/CLAUDE.md +++ /dev/null @@ -1,30 +0,0 @@ -## Layout - -- `platform/` — TS Pulumi components embedded via `//go:embed` (`platform/platform.go:16`) -- `examples/` — sample apps -- `cmd/sst/` — Go CLI entry, orchestrates everything -- `cmd/sst/mosaic/` — live dev TUI -- `pkg/server/` — JSON-RPC bridge for custom Pulumi dynamic providers (`rpc/rpc.ts` ↔ `pkg/server`) -- `pkg/bus/` — pub/sub event bus -- `sdk/js/` — runtime SDK for reading linked resources -- `www/` — docs site (auto-generated from JSDoc comments in platform and extracted from the Go CLI) - -## Commands - -- **Setup**: `bun run setup` -- **Build platform**: `bun run build:platform` -- **Build CLI**: `bun run build:cli` -- **Run CLI locally**: `cd examples/ && go run ../../cmd/sst ` -- **Go tests**: `bun run test:cli` -- **Typecheck**: `bun run typecheck` -- **Generate docs**: `bun run docs:generate` -- **Run docs locally**: `bun run docs:dev` - -## Verification - -1. Build the platform -2. `cd examples/ && bun install` -3. `go run ../../cmd/sst deploy` -4. Verify with `curl` or AWS CLI -5. Don't clean up unless told to -6. `sst dev --mode=basic` for dev mode diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..9968012ad2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,124 @@ +# Contributing to SST + +Want to help improve SST? Thank you! Take a second to review this document before you get started. + +There are two key areas that we could use your help with. + +- Covering specific cases and setups +- Improving the documentation + +To make sure that you are not working on something that's already being worked on, make sure to either: + +- [Open a new issue][issue] about it +- Or [join us on Slack][slack] and send us a message + +## Running Locally + +To run this project locally, clone the repo and initialize the project. + +```bash +$ git clone https://github.com/serverless-stack/serverless-stack.git +$ cd serverless-stack +$ yarn +``` + +### Resources + +If you are working on the `packages/resources` part, run the watcher. + +```bash +$ cd packages/resources +$ yarn watch +``` + +And if you make changes to the stub Lambdas, you'll need to package them. + +```bash +$ yarn build +``` + +### Running tests + +Finally, after making your changes, run all the tests at the repo root. + +```bash +$ yarn test +``` + +### Docs + +To run the docs site. + +```bash +$ cd www +$ yarn start +``` + +## Releases + +To cut a release, follow these steps. + +1. Generate changelog + + ```bash + $ yarn changelog + ``` + + You'll need to configure the `GITHUB_AUTH` token locally to be able to run this. [Follow these steps](https://github.com/lerna/lerna-changelog#github-token) and configure the local environment variable. + +2. Draft a new release + + Then copy the changelog that's generated and [draft a new release](https://github.com/serverless-stack/serverless-stack/releases/new). + + Make necessary edits to the changelog to make it more readable and helpful. + + Add this snippet at the bottom of the changelog and replace it with the version that's going to be released. + + ```` + --- + + Update using: + + ```sh + $ npm install --save --save-exact @serverless-stack/cli@x.x.x @serverless-stack/resources@x.x.x + ``` + ```` + + Leave the draft as-is for now. + +3. (Optional) Publish a canary release to npm + + If you'd like to test your release before pushing it live, create a canary release by running. + + ```bash + $ yarn release-canary + ``` + +4. Publish a release to npm + + To publish the release to npm run: + + ```bash + $ yarn release + ``` + + Pick the version you want (patch/minor/major) based on the type of changes in the changelog above. + + Verify that only the 4 core packages (`core`, `cli`, `resources`, `create-serverless-stack`) are getting published. + + Confirm and publish! + +5. Publish GitHub release + + Head back to the release draft from before. In the **Tag version** select the version that was just published to npm. + + Copy-paste that version as the **Release title**. And hit **Publish release**. + + Optionally, tweet this out! + +--- + +Help us improve this doc. If you've had a chance to contribute to SST, feel free to edit this doc and submit a PR. + +[slack]: https://launchpass.com/serverless-stack +[issue]: https://github.com/serverless-stack/serverless-stack/issues/new diff --git a/LICENSE b/LICENSE index c6eca6eed7..f5dab6f2b8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 SST +Copyright (c) 2020 Serverless Stack Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index cbc6c8b796..659c17ef52 100644 --- a/README.md +++ b/README.md @@ -1,89 +1,95 @@

- - SST + + Serverless Stack (SST)

- Discord - npm - Build status + Slack + npm + Build status

--- -Build full-stack apps on your own infrastructure. +Serverless Stack (SST) is a framework that makes it easy to build serverless apps. It's an extension of [AWS CDK](https://aws.amazon.com/cdk/) and it features: -## Installation +- A [Live Lambda Development][live] environment +- [Higher-level constructs][resources] designed specifically for serverless apps +- Zero-config support for ES and TypeScript using [esbuild](https://esbuild.github.io) +- Support for [deploying to multiple environments and regions](https://docs.serverless-stack.com/deploying-your-app#deploying-to-a-stage) -For JavaScript projects, install SST locally so the CLI version is tracked with your app. You can then run the CLI with the same package manager. +## Quick Start -```bash -npm install sst -# pnpm add sst -# bun add sst -# yarn add sst -``` - -If you are not using JavaScript, you can install the CLI globally. +Create your first SST app. ```bash -curl -fsSL https://sst.dev/install | bash -``` +# Create your app +$ npx create-serverless-stack@latest my-sst-app +$ cd my-sst-app -To install a specific version. +# Start Live Lambda Development +$ npx sst start -```bash -curl -fsSL https://sst.dev/install | VERSION=0.0.403 bash +# Deploy to prod +$ npx sst deploy --stage prod ``` -To use a package manager, [check out our docs](https://sst.dev/docs/reference/cli/). +## Documentation -#### Manually +- [Install SST](https://docs.serverless-stack.com/installation) +- [SST docs](https://docs.serverless-stack.com) +- [SST examples](https://serverless-stack.com/examples/index.html) +- [Public roadmap][roadmap] +- [Contributing to SST](CONTRIBUTING.md) -Download the pre-compiled binaries from the [releases](https://github.com/sst/sst/releases/latest) page and copy to the desired location. +[Follow us on Twitter](https://twitter.com/ServerlessStack) and [subscribe to our newsletter](https://emailoctopus.com/lists/1c11b9a8-1500-11e8-a3c9-06b79b628af2/forms/subscribe) for updates. -## Get Started +## About SST -Get started with your favorite framework: +We think SST can make it dramatically easier to build serverless apps. -- [Next.js](https://sst.dev/docs/start/aws/nextjs) -- [Remix](https://sst.dev/docs/start/aws/remix) -- [Astro](https://sst.dev/docs/start/aws/astro) -- [API](https://sst.dev/docs/start/aws/api) +### Live Lambda Development -## Learn More +The `sst start` command starts up a local development environment that opens a WebSocket connection to your deployed app and proxies any Lambda requests to your local machine. -Learn more about some of the key concepts: +[![sst start](https://d1ne2nltv07ycv.cloudfront.net/SST/sst-start-demo/sst-start-demo-2.gif)](https://www.youtube.com/watch?v=hnTSTm5n11g&feature=youtu.be) -- [Live](https://sst.dev/docs/live) -- [Linking](https://sst.dev/docs/linking) -- [Console](https://sst.dev/docs/console) -- [Components](https://sst.dev/docs/components) +This allows you to: -## Contributing +- Work on your Lambda functions locally +- Supports all Lambda triggers, so there's no need to mock API Gateway, SQS, SNS, etc. +- Supports real Lambda environment variables and Lambda IAM permissions +- And it's fast. There's nothing to deploy when you make a change! -Here's how you can contribute: +[Read more about Live Lambda Development][live]. -- Help us improve our docs -- Find a bug? Open an issue -- Feature request? Submit a PR +### Composable serverless constructs -## Running Locally +SST also comes with [a set of serverless specific higher-level CDK constructs]resources. This includes: -Run `bun run setup`. You need [Go](https://go.dev/) and [Bun](https://bun.sh/) installed. +- [Api](https://docs.serverless-stack.com/constructs/Api) for building APIs +- [Cron](https://docs.serverless-stack.com/constructs/Cron) for building cron jobs +- [Queue](https://docs.serverless-stack.com/constructs/Queue) for creating queues +- [Table](https://docs.serverless-stack.com/constructs/Table) for adding DynamoDB tables +- [Topic](https://docs.serverless-stack.com/constructs/Topic) for creating pub/sub systems -Now you can run the CLI locally on any of the `examples/` apps. +### And more -```bash -cd examples/aws-api -go run ../../cmd/sst -``` +SST also supports deploying your CloudFormation stacks asynchronously. [Seed](https://seed.run) natively supports concurrent asynchronous deployments for your SST apps. And SST deployments on Seed are free! -If you want to build the CLI binary, run `bun run build:cli`. This will create a `sst` binary that you can use. +SST also comes with a few other niceties: -For building the docs, run `bun run docs:generate` and `bun run docs:dev`. +- Automatically lints your code using [ESLint](https://eslint.org/) +- Runs your unit tests using [Jest](https://jestjs.io/) + +Internally, SST uses the CDK CLI to invoke the various CDK commands. --- -**Join our community** [Discord](https://sst.dev/discord) | [YouTube](https://www.youtube.com/c/sst-dev) | [X.com](https://x.com/SST_dev) +Brought to you by [Anomaly Innovations](https://anoma.ly/). + +[slack]: https://launchpass.com/serverless-stack +[resources]: https://docs.serverless-stack.com/packages/resources +[live]: https://docs.serverless-stack.com/live-lambda-development +[roadmap]: https://github.com/serverless-stack/serverless-stack/milestones?direction=asc&sort=due_date&state=open diff --git a/bun.lockb b/bun.lockb deleted file mode 100755 index 5470431b11..0000000000 Binary files a/bun.lockb and /dev/null differ diff --git a/cmd/sst/add_test.go b/cmd/sst/add_test.go deleted file mode 100644 index dbf4df960a..0000000000 --- a/cmd/sst/add_test.go +++ /dev/null @@ -1,60 +0,0 @@ -package main - -import ( - "testing" - - "github.com/sst/sst/v3/pkg/project" -) - -func TestGetAliasName(t *testing.T) { - tests := []struct { - name string - entry *project.ProviderLockEntry - want string - }{ - { - name: "simple provider", - entry: &project.ProviderLockEntry{ - Name: "stripe", - Package: "pulumi-stripe", - Alias: "stripe", - }, - want: "stripe", - }, - { - name: "strip official suffix", - entry: &project.ProviderLockEntry{ - Name: "stripe-official", - Package: "@sst-provider/stripe-official", - Alias: "stripe", - }, - want: "stripe", - }, - { - name: "strip community suffix from alias", - entry: &project.ProviderLockEntry{ - Name: "@scope/pulumi-foo-community", - Package: "@scope/pulumi-foo-community", - Alias: "foocommunity", - }, - want: "foo", - }, - { - name: "package input still uses alias", - entry: &project.ProviderLockEntry{ - Name: "@paynearme/pulumi-jetstream", - Package: "@paynearme/pulumi-jetstream", - Alias: "jetstream", - }, - want: "jetstream", - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := getAliasName(tt.entry); got != tt.want { - t.Fatalf("got %q, want %q", got, tt.want) - } - }) - } -} diff --git a/cmd/sst/cert.go b/cmd/sst/cert.go deleted file mode 100644 index 337c447dc2..0000000000 --- a/cmd/sst/cert.go +++ /dev/null @@ -1,60 +0,0 @@ -package main - -import ( - "os" - "path/filepath" - "strings" - - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/pkg/global" - "github.com/sst/sst/v3/pkg/process" -) - -var CmdCert = &cli.Command{ - Name: "cert", - Description: cli.Description{ - Short: "Generate certificate for the Console", - Long: strings.Join([]string{ - "Generate a locally-trusted certificate to connect to the Console.", - "", - "The Console can show you local logs from `sst dev` by connecting to your CLI. Certain browsers like Safari and Brave require the local connection to be running on HTTPS.", - "", - "This command uses [mkcert](https://github.com/FiloSottile/mkcert) internally to generate a locally-trusted certificate for `localhost` and `127.0.0.1`.", - "", - "You'll only need to do this once on your machine.", - }, "\n"), - }, - Run: func(c *cli.Cli) error { - err := global.EnsureMkcert() - if err != nil { - return err - } - env := os.Environ() - env = append(env, "CAROOT="+global.CertPath()) - cmd := process.Command("mkcert", "-install") - cmd.Env = env - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Stdin = os.Stdin - err = cmd.Run() - if err != nil { - return err - } - cmd = process.Command( - "mkcert", - "-key-file", filepath.Join(global.CertPath(), "key.pem"), - "-cert-file", filepath.Join(global.CertPath(), "cert.pem"), - "127.0.0.1", - "localhost", - ) - cmd.Env = env - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Stdin = os.Stdin - err = cmd.Run() - if err != nil { - return err - } - return nil - }, -} diff --git a/cmd/sst/cli/cli.go b/cmd/sst/cli/cli.go deleted file mode 100644 index b9ea8403a0..0000000000 --- a/cmd/sst/cli/cli.go +++ /dev/null @@ -1,354 +0,0 @@ -package cli - -import ( - "context" - "fmt" - "os" - "os/user" - "path/filepath" - "strings" - - flag "github.com/spf13/pflag" - "golang.org/x/term" - - "github.com/charmbracelet/huh" - "github.com/fatih/color" - "github.com/joho/godotenv" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/project" -) - -type Cli struct { - version string - flags map[string]interface{} - arguments []string - path CommandPath - Context context.Context - cancel context.CancelFunc - env []string -} - -func New(ctx context.Context, cancel context.CancelFunc, root *Command, version string) (*Cli, error) { - env := os.Environ() - godotenv.Load() - parsedFlags := map[string]interface{}{} - root.init(parsedFlags) - flag.CommandLine.Init("sst", flag.ContinueOnError) - cliParseError := flag.CommandLine.Parse(os.Args[1:]) - positionals := []string{} - cmds := CommandPath{ - *root, - } - for i, arg := range flag.Args() { - var cmd *Command - - last := cmds[len(cmds)-1] - if len(last.Children) == 0 { - positionals = flag.Args()[i:] - break - } - for _, c := range last.Children { - if c.Name == arg { - cmd = c - break - } - } - if cmd == nil { - break - } - cmds = append(cmds, *cmd) - } - cli := &Cli{ - flags: parsedFlags, - version: version, - arguments: positionals, - path: cmds, - Context: ctx, - cancel: cancel, - env: env, - } - cli.configureLog() - if cliParseError != nil { - return nil, cli.PrintHelp() - } - cli.configureLog() - return cli, nil -} - -func (c *Cli) Run() error { - active := c.path[len(c.path)-1] - required := 0 - for _, arg := range active.Args { - if !arg.Required { - continue - } - required += 1 - } - if c.Bool("help") || active.Run == nil || len(c.arguments) < required { - return c.PrintHelp() - } else { - return active.Run(c) - } -} - -func (c *Cli) Cancel() { - c.cancel() -} - -func (c *Cli) Path() CommandPath { - return c.path -} - -func (c *Cli) String(name string) string { - if f, ok := c.flags[name]; ok { - return *f.(*string) - } - return "" -} - -func (c *Cli) Bool(name string) bool { - if f, ok := c.flags[name]; ok { - return *f.(*bool) - } - return false -} - -func (c *Cli) PrintHelp() error { - return c.path.PrintHelp() -} - -func (c *Cli) Arguments() []string { - return c.arguments -} - -func (c *Cli) Positional(index int) string { - if index >= len(c.arguments) { - return "" - } - return c.arguments[index] -} - -func (c *Cli) Env() []string { - return c.env -} - -type Command struct { - Name string `json:"name"` - Hidden bool `json:"hidden"` - Description Description `json:"description"` - Args ArgumentList `json:"args"` - Flags []Flag `json:"flags"` - Examples []Example `json:"examples"` - Children []*Command `json:"children"` - Run func(cli *Cli) error `json:"-"` -} - -func (c *Command) init(parsed map[string]interface{}) { - if c.Args == nil { - c.Args = ArgumentList{} - } - if c.Flags == nil { - c.Flags = []Flag{} - } - if c.Examples == nil { - c.Examples = []Example{} - } - if c.Children == nil { - c.Children = []*Command{} - } - for _, f := range c.Flags { - if parsed[f.Name] != nil { - continue - } - if f.Type == "string" { - parsed[f.Name] = flag.String(f.Name, "", "") - } - - if f.Type == "bool" { - parsed[f.Name] = flag.Bool(f.Name, false, "") - } - } - for _, child := range c.Children { - child.init(parsed) - } -} - -type Example struct { - Content string `json:"content"` - Description Description `json:"description"` -} - -type Argument struct { - Name string `json:"name"` - Required bool `json:"required"` - Description Description `json:"description"` -} - -type Description struct { - Short string `json:"short,omitempty"` - Long string `json:"long,omitempty"` -} - -type ArgumentList []Argument - -func (a ArgumentList) String() string { - args := []string{} - for _, arg := range a { - if arg.Required { - args = append(args, "<"+arg.Name+">") - } else { - args = append(args, "["+arg.Name+"]") - } - } - return strings.Join(args, " ") -} - -type Flag struct { - Name string `json:"name"` - Type string `json:"type"` - Description Description `json:"description"` -} - -type CommandPath []Command - -var ErrHelp = util.NewReadableError(nil, "") - -func (c CommandPath) PrintHelp() error { - prefix := []string{} - for _, cmd := range c { - prefix = append(prefix, cmd.Name) - } - active := c[len(c)-1] - - if len(active.Children) > 0 { - fmt.Print(strings.Join(prefix, " ") + ": ") - fmt.Println(color.WhiteString(c[len(c)-1].Description.Short)) - - maxSubcommand := 0 - for _, child := range active.Children { - if child.Hidden { - continue - } - next := len(child.Name) - if len(child.Args) > 0 { - next += len(child.Args.String()) + 1 - } - if next > maxSubcommand { - maxSubcommand = next - } - } - - fmt.Println() - for _, child := range active.Children { - if child.Hidden { - continue - } - fmt.Printf( - " %s %s %s\n", - strings.Join(prefix, " "), - color.New(color.FgWhite, color.Bold).Sprintf("%-*s", maxSubcommand, func() string { - if len(child.Args) > 0 { - return strings.Join([]string{child.Name, child.Args.String()}, " ") - } - return child.Name - }()), - child.Description.Short, - ) - } - } - - if len(active.Children) == 0 { - color.New(color.FgWhite, color.Bold).Print("Usage: ") - color.New(color.FgCyan).Print(strings.Join(prefix, " ")) - if len(active.Args) > 0 { - color.New(color.FgGreen).Print(" " + active.Args.String()) - } - fmt.Println() - fmt.Println() - - color.New(color.FgWhite, color.Bold).Print("Flags:\n") - maxFlag := 0 - for _, cmd := range c { - for _, f := range cmd.Flags { - l := len(f.Name) + 3 - if l > maxFlag { - maxFlag = l - } - } - } - - for _, cmd := range c { - for _, f := range cmd.Flags { - fmt.Printf( - " %s %s\n", - color.New(color.FgMagenta).Sprintf("--%-*s", maxFlag, f.Name), - f.Description.Short, - ) - } - } - - if len(active.Examples) > 0 { - fmt.Println() - color.New(color.FgWhite, color.Bold).Print("Examples:\n") - for _, example := range active.Examples { - fmt.Println(" " + example.Content) - } - } - } - - fmt.Println() - fmt.Printf("Learn more at %s\n", color.MagentaString("https://sst.dev")) - - return ErrHelp -} - -func (c *Cli) Stage(cfgPath string) (string, error) { - stage := c.String("stage") - if stage == "" { - stage = os.Getenv("SST_STAGE") - if stage == "" { - stage = project.LoadPersonalStage(cfgPath) - if stage == "" { - stage = guessStage() - if stage == "" { - if !term.IsTerminal(int(os.Stdout.Fd())) { - return "", util.NewReadableError(nil, "No stage specified. Pass it in with --stage or set the SST_STAGE environment variable. If this is a personal stage it can be set in `.sst/stage`.") - } - err := huh.NewForm( - huh.NewGroup( - huh.NewInput().Title(" Enter name for your personal stage").Prompt(" > ").Value(&stage).Validate(func(v string) error { - if project.InvalidStageRegex.MatchString(v) { - return fmt.Errorf("Invalid stage name") - } - return nil - }), - ), - ).WithTheme(huh.ThemeCatppuccin()).Run() - if err != nil { - return "", err - } - } - err := project.SetPersonalStage(cfgPath, stage) - if err != nil { - return "", err - } - } - } - } - godotenv.Overload(filepath.Join(filepath.Dir(cfgPath), ".env."+stage)) - return stage, nil -} - -func guessStage() string { - u, err := user.Current() - if err != nil { - return "" - } - stage := strings.ToLower(u.Username) - stage = project.InvalidStageRegex.ReplaceAllString(stage, "") - - if stage == "root" || stage == "admin" || stage == "prod" || stage == "dev" || stage == "production" { - return "" - } - return stage -} diff --git a/cmd/sst/cli/project.go b/cmd/sst/cli/project.go deleted file mode 100644 index e6dce082db..0000000000 --- a/cmd/sst/cli/project.go +++ /dev/null @@ -1,145 +0,0 @@ -package cli - -import ( - "fmt" - "io" - "log/slog" - "os" - "path/filepath" - "runtime/debug" - "time" - - "github.com/briandowns/spinner" - "github.com/joho/godotenv" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/flag" - "github.com/sst/sst/v3/pkg/project" -) - -var logFile = (func() *os.File { - tmpPath := flag.SST_LOG - if tmpPath == "" { - tmpPath = filepath.Join(os.TempDir(), fmt.Sprintf("sst-%s.log", time.Now().Format("2006-01-02-15-04-05"))) - } - logFile, err := os.Create(tmpPath) - if err != nil { - panic(err) - } - return logFile -})() - -func (c *Cli) Discover() (string, error) { - cfgPath := c.String("config") - if cfgPath != "" { - abs, err := filepath.Abs(cfgPath) - if err != nil { - return "", util.NewReadableError(err, "Could not find "+cfgPath) - } - if _, err := os.Stat(abs); os.IsNotExist(err) { - return "", util.NewReadableError(err, "Could not find "+abs) - } - return abs, nil - } - - match, err := project.Discover() - if err != nil { - return "", util.NewReadableError(err, "Could not find sst.config.ts") - } - return match, nil -} - -func (c *Cli) InitProject() (*project.Project, error) { - slog.Info("initializing project", "version", c.version) - - cfgPath, err := c.Discover() - if err != nil { - return nil, err - } - - stage, err := c.Stage(cfgPath) - if err != nil { - return nil, util.NewReadableError(err, "Could not find stage") - } - - p, err := project.New(&project.ProjectConfig{ - Version: c.version, - Stage: stage, - Config: cfgPath, - }) - if err != nil { - return nil, err - } - godotenv.Load(filepath.Join(p.PathRoot(), ".env")) - - if flag.SST_LOG == "" { - _, err = logFile.Seek(0, 0) - if err != nil { - return nil, err - } - sstLog := p.PathLog("sst") - logPath := p.PathLog("") - os.MkdirAll(logPath, 0755) - nextLogFile, err := os.Create(sstLog) - if err != nil { - return nil, util.NewReadableError(err, "Could not create log file") - } - _, err = io.Copy(nextLogFile, logFile) - if err != nil { - return nil, util.NewReadableError(err, "Could not copy log file") - } - logFile.Close() - defer func() { - err = os.RemoveAll(filepath.Join(os.TempDir(), logFile.Name())) - if err != nil { - slog.Error("failed to remove temp log file", "err", err) - } - }() - logFile = nextLogFile - } - c.configureLog() - - spin := spinner.New(spinner.CharSets[14], 100*time.Millisecond, spinner.WithWriterFile(os.Stderr)) - spin.Color("cyan") - defer spin.Stop() - if !p.CheckPlatform(c.version) { - spin.Suffix = " Upgrading project..." - spin.Start() - err := p.CopyPlatform(c.version) - if err != nil { - return nil, util.NewReadableError(err, "Could not copy platform code to project directory") - } - } - - if p.NeedsInstall() { - spin.Suffix = " Installing providers..." - spin.Start() - err = p.Install() - if err != nil { - return nil, err - } - } - - if err := p.LoadHome(); err != nil { - return nil, err - } - - app := p.App() - slog.Info("loaded config", "app", app.Name, "stage", app.Stage) - - c.configureLog() - return p, nil -} - -func (c *Cli) configureLog() { - writers := []io.Writer{logFile} - if c.Bool("print-logs") || flag.SST_PRINT_LOGS { - writers = append(writers, os.Stderr) - } - writer := io.MultiWriter(writers...) - slog.SetDefault( - slog.New(slog.NewTextHandler(writer, &slog.HandlerOptions{ - Level: slog.LevelInfo, - })), - ) - debug.SetCrashOutput(logFile, debug.CrashOptions{}) -} diff --git a/cmd/sst/deploy.go b/cmd/sst/deploy.go deleted file mode 100644 index f619dbcf0d..0000000000 --- a/cmd/sst/deploy.go +++ /dev/null @@ -1,200 +0,0 @@ -package main - -import ( - "strings" - - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/server" - "golang.org/x/sync/errgroup" -) - -var CmdDeploy = &cli.Command{ - Name: "deploy", - Description: cli.Description{ - Short: "Deploy your application", - Long: strings.Join([]string{ - "Deploy your application. By default, it deploys to your personal stage.", - "You typically want to deploy it to a specific stage.", - "", - "```bash frame=\"none\"", - "sst deploy --stage production", - "```", - "", - "Optionally, deploy a specific component by passing in the name of the component from your `sst.config.ts`.", - "", - "```bash frame=\"none\"", - "sst deploy --target MyComponent", - "```", - "", - "Alternatively, exclude a specific component from the deploy.", - "", - "```bash frame=\"none\"", - "sst deploy --exclude MyComponent", - "```", - "", - "All the resources are deployed as concurrently as possible, based on their dependencies.", - "For resources like your container images, sites, and functions; it first builds them and then deploys the generated assets.", - "", - ":::tip", - "Configure the concurrency if your CI builds are running out of memory.", - ":::", - "", - "Since the build processes for some of these resources take a lot of memory, their concurrency is limited by default.", - "However, this can be configured.", - "", - "| Resource | Concurrency | Flag |", - "| -------- | ----------- | ---- |", - "| Sites | 1 | `SST_BUILD_CONCURRENCY_SITE` |", - "| Functions | 4 | `SST_BUILD_CONCURRENCY_FUNCTION` |", - "| Containers | 1 | `SST_BUILD_CONCURRENCY_CONTAINER` |", - "", - "So only one site is built at a time, 4 functions are built at a time, and only 1 container is built at a time.", - "", - "You can set the above environment variables to change this when you run `sst deploy`. This is useful for CI", - "environments where you want to control this based on how much memory your CI machine has.", - "", - "For example, to build a maximum of 2 sites concurrently.", - "", - "```bash frame=\"none\"", - "SST_BUILD_CONCURRENCY_SITE=2 sst deploy", - "```", - " Or to configure all these together.", - "", - "```bash frame=\"none\"", - "SST_BUILD_CONCURRENCY_SITE=2 SST_BUILD_CONCURRENCY_CONTAINER=2 SST_BUILD_CONCURRENCY_FUNCTION=8 sst deploy", - "```", - "Typically, this command exits when there's an error deploying a resource.", - "But sometimes you want to be able to `--continue` deploying as many resources as possible;", - "", - "```bash frame=\"none\"", - "sst deploy --continue", - "```", - "", - "This is useful when deploying a new stage with a lot of resources. You want", - "to be able to deploy as many resources as possible and then come back and", - "fix the errors.", - "", - "The `sst dev` command deploys your resources a little differently. It skips", - "deploying resources that are going to be run locally. Sometimes you want to", - "deploy a personal stage without starting `sst dev`.", - "", - "```bash frame=\"none\"", - "sst deploy --dev", - "```", - "The `--dev` flag will deploy your resources as if you were running `sst dev`.", - }, "\n"), - }, - Flags: []cli.Flag{ - { - Name: "target", - Description: cli.Description{ - Short: "Run it only for a component", - Long: "Only run it for the given component.", - }, - }, - { - Name: "exclude", - Type: "string", - Description: cli.Description{ - Short: "Exclude a component", - Long: "Exclude the specified component from the operation.", - }, - }, - { - Name: "continue", - Type: "bool", - Description: cli.Description{ - Short: "Continue on error", - Long: "Continue on error and try to deploy as many resources as possible.", - }, - }, - { - Name: "dev", - Type: "bool", - Description: cli.Description{ - Short: "Deploy in dev mode", - Long: "Deploy resources like `sst dev` would.", - }, - }, - { - Name: "policy", - Type: "string", - Description: cli.Description{ - Short: "Path to policy pack", - Long: "Run policy pack validation against the preview changes.", - }, - }, - }, - Examples: []cli.Example{ - { - Content: "sst deploy --stage production", - Description: cli.Description{ - Short: "Deploy to production", - }, - }, - { - Content: "sst deploy --stage production --policy ./policies/production", - Description: cli.Description{ - Short: "Deploy to production with policy validation", - }, - }, - }, - Run: func(c *cli.Cli) error { - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - - target := []string{} - if c.String("target") != "" { - target = strings.Split(c.String("target"), ",") - } - - exclude := []string{} - if c.String("exclude") != "" { - exclude = strings.Split(c.String("exclude"), ",") - } - - var wg errgroup.Group - defer wg.Wait() - out := make(chan interface{}) - defer close(out) - ui := ui.New(c.Context) - s, err := server.New() - if err != nil { - return err - } - wg.Go(func() error { - defer c.Cancel() - return s.Start(c.Context, p) - }) - events := bus.SubscribeAll() - defer close(events) - wg.Go(func() error { - for evt := range events { - ui.Event(evt) - } - return nil - }) - defer ui.Destroy() - defer c.Cancel() - err = p.Run(c.Context, &project.StackInput{ - Command: "deploy", - Target: target, - Exclude: exclude, - Dev: c.Bool("dev"), - ServerPort: s.Port, - Verbose: c.Bool("verbose"), - Continue: c.Bool("continue"), - PolicyPath: c.String("policy"), - }) - if err != nil { - return err - } - return nil - }, -} diff --git a/cmd/sst/diagnostic.go b/cmd/sst/diagnostic.go deleted file mode 100644 index 7d80daaf51..0000000000 --- a/cmd/sst/diagnostic.go +++ /dev/null @@ -1,106 +0,0 @@ -package main - -import ( - "archive/zip" - "fmt" - "io" - "os" - "path/filepath" - "strings" - - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/pkg/id" - "github.com/sst/sst/v3/pkg/project" -) - -var CmdDiagnostic = &cli.Command{ - Name: "diagnostic", - Description: cli.Description{ - Short: "Generates a diagnostic report", - Long: strings.Join([]string{ - "Generates a diagnostic report based on the last command that was run.", - "", - "This takes the state of your app, its log files, and generates a zip file in the `.sst/` directory. This is for debugging purposes.", - }, "\n"), - }, - Run: func(c *cli.Cli) error { - cfg, err := c.Discover() - if err != nil { - return err - } - workingDir := project.ResolveWorkingDir(cfg) - logDir := project.ResolveLogDir(cfg) - logFiles, err := os.ReadDir(logDir) - fmt.Println(ui.TEXT_DIM.Render("Generating diagnostic report from last run...")) - zipFile, err := os.Create(filepath.Join(workingDir, "report.zip")) - if err != nil { - return err - } - defer zipFile.Close() - archive := zip.NewWriter(zipFile) - defer archive.Close() - - addFile := func(path string, name string) error { - fmt.Println(ui.TEXT_DIM.Render("- " + name)) - fileToZip, err := os.Open(path) - if err != nil { - return err - } - defer fileToZip.Close() - info, err := fileToZip.Stat() - if err != nil { - return err - } - header, err := zip.FileInfoHeader(info) - if err != nil { - return err - } - header.Name = name - header.Method = zip.Deflate - writer, err := archive.CreateHeader(header) - if err != nil { - return err - } - _, err = io.Copy(writer, fileToZip) - if err != nil { - return err - } - return nil - } - - if err != nil { - return err - } - for _, file := range logFiles { - if !file.IsDir() { - filePath := filepath.Join(logDir, file.Name()) - err := addFile(filePath, file.Name()) - if err != nil { - return err - } - } - } - p, err := c.InitProject() - if err != nil { - return err - } - workdir, err := p.NewWorkdir(id.Descending()) - if err != nil { - return err - } - defer workdir.Cleanup() - - statePath, err := workdir.Pull() - if err != nil { - return err - } - err = addFile(statePath, "state.json") - if err != nil { - return err - } - fmt.Println() - ui.Success("Report generated: " + zipFile.Name()) - return nil - }, -} diff --git a/cmd/sst/diff.go b/cmd/sst/diff.go deleted file mode 100644 index 2015cdd0db..0000000000 --- a/cmd/sst/diff.go +++ /dev/null @@ -1,302 +0,0 @@ -package main - -import ( - "encoding/json" - "fmt" - "os" - "sort" - "strings" - - "github.com/pulumi/pulumi/sdk/v3/go/common/apitype" - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/server" - "github.com/yalp/jsonpath" - "golang.org/x/sync/errgroup" -) - -var CmdDiff = &cli.Command{ - Name: "diff", - Description: cli.Description{ - Short: "See what changes will be made", - Long: strings.Join([]string{ - "Builds your app to see what changes will be made when you deploy it.", - "", - "It displays a list of resources that will be created, updated, or deleted.", - "For each of these resources, it'll also show the properties that are changing.", - "", - ":::tip", - "Run a `sst diff` to see what changes will be made when you deploy your app.", - ":::", - "", - "This is useful for cases when you pull some changes from a teammate and want to", - "see what will be deployed; before doing the actual deploy.", - "", - "Optionally, you can diff a specific component by passing in the name of the component from your `sst.config.ts`.", - "", - "```bash frame=\"none\"", - "sst diff --target MyComponent", - "```", - "", - "Alternatively, exclude a specific component from the diff.", - "", - "```bash frame=\"none\"", - "sst diff --exclude MyComponent", - "```", - "", - "By default, this compares to the last deploy of the given stage as it would be", - "deployed using `sst deploy`. But if you are working in dev mode using `sst dev`,", - "you can use the `--dev` flag.", - "", - "```bash frame=\"none\"", - "sst diff --dev", - "```", - "", - "This is useful because in dev mode, you app is deployed a little differently.", - }, "\n"), - }, - Flags: []cli.Flag{ - { - Name: "target", - Description: cli.Description{ - Short: "Run it only for a component", - Long: "Only run it for the given component.", - }, - }, - { - Name: "exclude", - Type: "string", - Description: cli.Description{ - Short: "Exclude a component", - Long: "Exclude the specified component from the operation.", - }, - }, - { - Name: "dev", - Type: "bool", - Description: cli.Description{ - Short: "Compare to sst dev", - Long: strings.Join([]string{ - "Compare to the dev version of this stage.", - }, "\n"), - }, - }, - { - Name: "policy", - Type: "string", - Description: cli.Description{ - Short: "Path to policy pack", - Long: "Run policy pack validation against the preview changes.", - }, - }, - { - Name: "json", - Type: "bool", - Description: cli.Description{ - Short: "Output as JSON", - Long: "Output the diff result as JSON to stdout. Useful for CI pipelines and scripting.", - }, - }, - }, - Examples: []cli.Example{ - { - Content: "sst diff --stage production", - Description: cli.Description{ - Short: "See changes to production", - }, - }, - { - Content: "sst diff --stage production --policy ./policies/production", - Description: cli.Description{ - Short: "See changes to production with policy validation", - }, - }, - { - Content: "sst diff --json", - Description: cli.Description{ - Short: "Output changes as JSON", - }, - }, - }, - Run: func(c *cli.Cli) error { - jsonOutput := c.Bool("json") - - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - - target := []string{} - if c.String("target") != "" { - target = strings.Split(c.String("target"), ",") - } - - exclude := []string{} - if c.String("exclude") != "" { - exclude = strings.Split(c.String("exclude"), ",") - } - - var wg errgroup.Group - outputs := []*apitype.ResOutputsEvent{} - uiOptions := []ui.Option{} - if jsonOutput { - // Keep stdout machine-readable when attached to a TTY. - uiOptions = append(uiOptions, ui.WithSilent) - } - u := ui.New(c.Context, uiOptions...) - s, err := server.New() - if err != nil { - return err - } - wg.Go(func() error { - defer c.Cancel() - return s.Start(c.Context, p) - }) - - events := bus.SubscribeAll() - wg.Go(func() error { - for evt := range events { - if !jsonOutput { - u.Event(evt) - } - switch evt := evt.(type) { - case *apitype.ResOutputsEvent: - outputs = append(outputs, evt) - } - } - return nil - }) - defer u.Destroy() - err = p.Run(c.Context, &project.StackInput{ - Command: "diff", - ServerPort: s.Port, - Dev: c.Bool("dev"), - Target: target, - Exclude: exclude, - Verbose: c.Bool("verbose"), - PolicyPath: c.String("policy"), - }) - bus.Unsubscribe(events) - close(events) - c.Cancel() - if waitErr := wg.Wait(); waitErr != nil && err == nil { - err = waitErr - } - - if jsonOutput { - if jsonErr := renderDiffJSON(outputs); jsonErr != nil { - return jsonErr - } - return err - } - if err != nil { - return err - } - return renderDiffText(outputs, u) - }, -} - -func textDiffIcon(op apitype.OpType) string { - switch op { - case apitype.OpImport, apitype.OpReplace, apitype.OpCreate: - return ui.TEXT_SUCCESS_BOLD.Render("+") - case apitype.OpDelete: - return ui.TEXT_DANGER_BOLD.Render("-") - case apitype.OpUpdate: - return ui.TEXT_WARNING_BOLD.Render("*") - default: - return "" - } -} - -func renderDiffJSON(outputs []*apitype.ResOutputsEvent) error { - filtered := make([]apitype.StepEventMetadata, 0, len(outputs)) - for _, output := range outputs { - if output.Metadata.Op == apitype.OpSame { - continue - } - filtered = append(filtered, output.Metadata) - } - encoder := json.NewEncoder(os.Stdout) - encoder.SetIndent("", " ") - return encoder.Encode(filtered) -} - -func renderDiffText(outputs []*apitype.ResOutputsEvent, u *ui.UI) error { - rendered := make([]*apitype.ResOutputsEvent, 0, len(outputs)) - for _, output := range outputs { - if textDiffIcon(output.Metadata.Op) == "" { - continue - } - rendered = append(rendered, output) - } - if len(rendered) == 0 { - fmt.Println( - ui.TEXT_HIGHLIGHT_BOLD.Render("➜"), - ui.TEXT_NORMAL_BOLD.Render(" No changes"), - ) - fmt.Println() - return nil - } - for _, output := range rendered { - icon := textDiffIcon(output.Metadata.Op) - fmt.Println(icon, "", ui.TEXT_NORMAL_BOLD.Render(u.FormatURN(output.Metadata.URN))) - sorted := make([]string, 0, len(output.Metadata.DetailedDiff)) - for path := range output.Metadata.DetailedDiff { - sorted = append(sorted, path) - } - sort.Strings(sorted) - for _, path := range sorted { - diff := output.Metadata.DetailedDiff[path] - label := "" - if diff.Kind == apitype.DiffUpdate { - label = ui.TEXT_WARNING_BOLD.Render("*") - } - if diff.Kind == apitype.DiffDelete { - label = ui.TEXT_DANGER_BOLD.Render("-") - } - if diff.Kind == apitype.DiffAdd { - label = ui.TEXT_SUCCESS_BOLD.Render("+") - } - if diff.Kind == apitype.DiffAddReplace { - label = ui.TEXT_SUCCESS_BOLD.Render("+") - } - if diff.Kind == apitype.DiffUpdateReplace { - label = ui.TEXT_WARNING_BOLD.Render("*") - } - if diff.Kind == apitype.DiffDeleteReplace { - label = ui.TEXT_DANGER_BOLD.Render("-") - } - fmt.Print(" ", label+" ", strings.TrimSpace(path)) - value, _ := jsonpath.Read(output.Metadata.New.Outputs, "$."+path) - if path == "__provider" { - value = "code changed" - } - if value != nil { - formatted := "" - switch value.(type) { - case string: - formatted = value.(string) - default: - bytes, _ := json.MarshalIndent(value, "", " ") - formatted = string(bytes) - } - lines := strings.Split(string(formatted), "\n") - fmt.Print(" = ") - for index, line := range lines { - if index > 0 { - fmt.Print(" ") - } - fmt.Print(ui.TEXT_DIM.Render(line) + "\n") - } - } else { - fmt.Println() - } - } - fmt.Println() - } - return nil -} diff --git a/cmd/sst/diff_test.go b/cmd/sst/diff_test.go deleted file mode 100644 index a91df6cfca..0000000000 --- a/cmd/sst/diff_test.go +++ /dev/null @@ -1,135 +0,0 @@ -package main - -import ( - "bytes" - "encoding/json" - "io" - "os" - "testing" - - "github.com/pulumi/pulumi/sdk/v3/go/common/apitype" -) - -func captureStdout(t *testing.T, fn func()) string { - t.Helper() - old := os.Stdout - r, w, err := os.Pipe() - if err != nil { - t.Fatal(err) - } - os.Stdout = w - - fn() - - w.Close() - os.Stdout = old - - var buf bytes.Buffer - io.Copy(&buf, r) - return buf.String() -} - -func TestRenderDiffJSON_NoChanges(t *testing.T) { - out := captureStdout(t, func() { - if err := renderDiffJSON(nil); err != nil { - t.Fatal(err) - } - }) - - var result []apitype.StepEventMetadata - if err := json.Unmarshal([]byte(out), &result); err != nil { - t.Fatalf("invalid JSON: %v\noutput: %s", err, out) - } - if len(result) != 0 { - t.Fatalf("expected 0 changes, got %d", len(result)) - } -} - -func TestRenderDiffJSON_WithChanges(t *testing.T) { - outputs := []*apitype.ResOutputsEvent{ - { - Metadata: apitype.StepEventMetadata{ - URN: "urn:pulumi:dev::app::aws:ecs/service:Service::MyService", - Type: "aws:ecs/service:Service", - Op: apitype.OpUpdate, - DetailedDiff: map[string]apitype.PropertyDiff{ - "healthCheckGracePeriodSeconds": {Kind: apitype.DiffUpdate}, - "tags": {Kind: apitype.DiffAdd}, - }, - New: &apitype.StepEventStateMetadata{ - Outputs: map[string]interface{}{ - "healthCheckGracePeriodSeconds": 35, - "tags": map[string]interface{}{"env": "dev"}, - }, - }, - }, - }, - { - Metadata: apitype.StepEventMetadata{ - URN: "urn:pulumi:dev::app::aws:s3/bucket:Bucket::MyBucket", - Type: "aws:s3/bucket:Bucket", - Op: apitype.OpCreate, - }, - }, - { - Metadata: apitype.StepEventMetadata{ - URN: "urn:pulumi:dev::app::aws:ecs/service:Service::Replacement", - Type: "aws:ecs/service:Service", - Op: apitype.OpCreateReplacement, - }, - }, - { - Metadata: apitype.StepEventMetadata{ - URN: "urn:pulumi:dev::app::aws:lambda/function:Function::OldFn", - Type: "aws:lambda/function:Function", - Op: apitype.OpSame, - }, - }, - } - - out := captureStdout(t, func() { - if err := renderDiffJSON(outputs); err != nil { - t.Fatal(err) - } - }) - - var result []apitype.StepEventMetadata - if err := json.Unmarshal([]byte(out), &result); err != nil { - t.Fatalf("invalid JSON: %v\noutput: %s", err, out) - } - - // OpSame should be filtered out, but replacement steps should be kept. - if len(result) != 3 { - t.Fatalf("expected 3 changes, got %d", len(result)) - } - - update := result[0] - if update.Op != apitype.OpUpdate { - t.Errorf("expected op 'update', got %q", update.Op) - } - if update.URN != "urn:pulumi:dev::app::aws:ecs/service:Service::MyService" { - t.Errorf("unexpected URN: %s", update.URN) - } - if update.Type != "aws:ecs/service:Service" { - t.Errorf("unexpected type: %s", update.Type) - } - if len(update.DetailedDiff) != 2 { - t.Fatalf("expected 2 detailed diff entries, got %d", len(update.DetailedDiff)) - } - if update.DetailedDiff["healthCheckGracePeriodSeconds"].Kind != apitype.DiffUpdate { - t.Errorf("expected diff kind 'update', got %q", update.DetailedDiff["healthCheckGracePeriodSeconds"].Kind) - } - if update.DetailedDiff["tags"].Kind != apitype.DiffAdd { - t.Errorf("expected diff kind 'add', got %q", update.DetailedDiff["tags"].Kind) - } - - create := result[1] - if create.Op != apitype.OpCreate { - t.Errorf("expected op 'create', got %q", create.Op) - } - - replacement := result[2] - if replacement.Op != apitype.OpCreateReplacement { - t.Errorf("expected op 'create-replacement', got %q", replacement.Op) - } -} diff --git a/cmd/sst/init.go b/cmd/sst/init.go deleted file mode 100644 index 00c3abedd2..0000000000 --- a/cmd/sst/init.go +++ /dev/null @@ -1,310 +0,0 @@ -package main - -import ( - "bufio" - "fmt" - "log/slog" - "os" - "os/exec" - "slices" - "strings" - "time" - - "github.com/briandowns/spinner" - "github.com/fatih/color" - "github.com/manifoldco/promptui" - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/npm" - "github.com/sst/sst/v3/pkg/process" - "github.com/sst/sst/v3/pkg/project" -) - -func CmdInit(cli *cli.Cli) error { - if _, err := os.Stat("sst.config.ts"); err == nil { - color.New(color.FgRed, color.Bold).Print("×") - color.New(color.FgWhite, color.Bold).Println(" SST project already exists") - return nil - } - - logo := []string{ - ``, - ` ███████╗███████╗████████╗`, - ` ██╔════╝██╔════╝╚══██╔══╝`, - ` ███████╗███████╗ ██║ `, - ` ╚════██║╚════██║ ██║ `, - ` ███████║███████║ ██║ `, - ` ╚══════╝╚══════╝ ╚═╝ `, - ``, - } - - fmt.Print("\033[?25l") - // orange - fmt.Print("\033[38;2;255;127;0m") - for _, line := range logo { - for _, char := range line { - fmt.Print(string(char)) - time.Sleep(5 * time.Millisecond) - } - fmt.Println() - } - fmt.Print("\033[?25h") - - var template string - - hints := []string{} - files, err := os.ReadDir(".") - if err != nil { - return err - } - for _, file := range files { - if file.IsDir() { - continue - } - hints = append(hints, file.Name()) - } - - color.New(color.FgBlue, color.Bold).Print(">") - switch { - case slices.ContainsFunc(hints, func(s string) bool { return strings.HasPrefix(s, "next.config") }): - fmt.Println(" Next.js detected. This will...") - fmt.Println(" - create an sst.config.ts") - fmt.Println(" - modify the tsconfig.json") - fmt.Println(" - add sst to package.json") - template = "nextjs" - break - - case slices.ContainsFunc(hints, func(s string) bool { return strings.HasPrefix(s, "react-router.config") }): - fmt.Println(" React Router detected. This will...") - fmt.Println(" - create an sst.config.ts") - fmt.Println(" - modify the tsconfig.json") - fmt.Println(" - add sst to package.json") - template = "react-router" - break - - case slices.ContainsFunc(hints, func(s string) bool { return strings.HasPrefix(s, "astro.config") }): - fmt.Println(" Astro detected. This will...") - fmt.Println(" - create an sst.config.ts") - fmt.Println(" - modify the tsconfig.json") - fmt.Println(" - add sst to package.json") - template = "astro" - break - - case slices.ContainsFunc(hints, func(s string) bool { - return strings.HasPrefix(s, "app.config") && fileContains(s, "@solidjs/start") - }): - fmt.Println(" SolidStart detected. This will...") - fmt.Println(" - create an sst.config.ts") - fmt.Println(" - add sst to package.json") - template = "solid-start" - break - - case slices.ContainsFunc(hints, func(s string) bool { - return strings.HasPrefix(s, "app.config") && fileContains(s, "@tanstack/") - }): - fmt.Println(" TanStack Start detected. This will...") - fmt.Println(" - create an sst.config.ts") - fmt.Println(" - add sst to package.json") - template = "tanstack-start" - break - - case slices.ContainsFunc(hints, func(s string) bool { return strings.HasPrefix(s, "nuxt.config") }): - fmt.Println(" Nuxt detected. This will...") - fmt.Println(" - create an sst.config.ts") - fmt.Println(" - add sst to package.json") - template = "nuxt" - break - - case slices.ContainsFunc(hints, func(s string) bool { return strings.HasPrefix(s, "svelte.config") }): - fmt.Println(" SvelteKit detected. This will...") - fmt.Println(" - create an sst.config.ts") - fmt.Println(" - add sst to package.json") - template = "svelte-kit" - break - - case slices.ContainsFunc(hints, func(s string) bool { - return strings.HasPrefix(s, "remix.config") || - (strings.HasPrefix(s, "vite.config") && fileContains(s, "@remix-run/dev")) - }): - fmt.Println(" Remix detected. This will...") - fmt.Println(" - create an sst.config.ts") - fmt.Println(" - add sst to package.json") - template = "remix" - break - - case slices.ContainsFunc(hints, func(s string) bool { - return (strings.HasPrefix(s, "vite.config") && fileContains(s, "@analogjs/platform")) - }): - fmt.Println(" Analog detected. This will...") - fmt.Println(" - create an sst.config.ts") - fmt.Println(" - add sst to package.json") - template = "analog" - break - - case slices.ContainsFunc(hints, func(s string) bool { return strings.HasPrefix(s, "angular.json") }): - fmt.Println(" Angular detected. This will...") - fmt.Println(" - create an sst.config.ts") - fmt.Println(" - add sst to package.json") - template = "angular" - break - - case slices.Contains(hints, "package.json"): - fmt.Println(" JS project detected. This will...") - fmt.Println(" - use the JS template") - fmt.Println(" - create an sst.config.ts") - template = "js" - break - - default: - fmt.Println(" No frontend detected. This will...") - fmt.Println(" - use the vanilla template") - fmt.Println(" - create an sst.config.ts") - template = "vanilla" - break - } - fmt.Println() - - p := promptui.Select{ - Items: []string{"Yes", "No"}, - Label: "‏‏‎ ‎Continue", - HideSelected: true, - HideHelp: true, - } - - if !cli.Bool("yes") { - _, confirm, err := p.Run() - if err != nil { - return util.NewReadableError(err, "") - } - if confirm == "No" { - return nil - } - } - - color.New(color.FgGreen, color.Bold).Print("✓") - color.New(color.FgWhite).Println(" Template:", template) - fmt.Println() - - home := "aws" - if template == "vanilla" || template == "js" { - p = promptui.Select{ - Label: "‏‏‎ ‎Where do you want to deploy your app? You can change this later", - HideSelected: true, - Items: []string{"aws", "cloudflare"}, - HideHelp: true, - } - _, home, err = p.Run() - if err != nil { - return util.NewReadableError(err, "") - } - color.New(color.FgGreen, color.Bold).Print("✓") - color.New(color.FgWhite).Println(" Using: " + home) - fmt.Println() - } - - if template == "js" { - template = "js-" + home - } - - instructions, err := project.Create(template, home) - if err != nil { - return err - } - var cmd *exec.Cmd - - spin := spinner.New(spinner.CharSets[14], 100*time.Millisecond) - spin.Color("cyan") - spin.Suffix = " Installing providers..." - spin.Start() - - cfgPath, err := cli.Discover() - if err != nil { - return err - } - proj, err := project.New(&project.ProjectConfig{ - Config: cfgPath, - Stage: "sst", - Version: version, - }) - if err != nil { - return err - } - if err := proj.CopyPlatform(version); err != nil { - return err - } - - if err := proj.Install(); err != nil { - return err - } - - cwd, err := os.Getwd() - mgr, _ := npm.DetectPackageManager(cwd) - if mgr != "" { - cmd = process.Command(mgr, "install") - spin.Suffix = " Installing dependencies..." - spin.Start() - slog.Info("installing deps", "args", cmd.Args) - cmd.Run() - spin.Stop() - } - - if template == "nextjs" { - hasEslint := slices.ContainsFunc(hints, func(s string) bool { - return strings.Contains(strings.ToLower(s), "eslint") - }) - - if hasEslint { - configFile := "sst.config.ts" - content, err := os.ReadFile(configFile) - if err != nil { - return err - } - - newContent := "// eslint-disable-next-line @typescript-eslint/triple-slash-reference\n" + string(content) - err = os.WriteFile(configFile, []byte(newContent), 0644) - if err != nil { - return err - } - } - } - - spin.Stop() - - if len(instructions) == 0 { - color.New(color.FgGreen, color.Bold).Print("✓") - color.New(color.FgWhite).Println(" Done 🎉") - } - if len(instructions) > 0 { - for i, instruction := range instructions { - if i == 0 { - color.New(color.FgBlue, color.Bold).Print(">") - fmt.Println(" " + instruction) - continue - } - color.New(color.FgWhite).Println(" " + instruction) - } - } - fmt.Println() - return nil -} - -func fileContains(filePath string, str string) bool { - file, err := os.Open(filePath) - if err != nil { - return false - } - defer file.Close() - - scanner := bufio.NewScanner(file) - for scanner.Scan() { - if strings.Contains(scanner.Text(), str) { - return true - } - } - - if err := scanner.Err(); err != nil { - return false - } - - return false -} diff --git a/cmd/sst/main.go b/cmd/sst/main.go deleted file mode 100644 index 134803cea1..0000000000 --- a/cmd/sst/main.go +++ /dev/null @@ -1,1041 +0,0 @@ -package main - -import ( - "context" - "encoding/json" - "fmt" - "log/slog" - "os" - "os/signal" - "os/user" - "path/filepath" - "strings" - "syscall" - "time" - - "github.com/briandowns/spinner" - "github.com/fatih/color" - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/errors" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/flag" - "github.com/sst/sst/v3/pkg/global" - "github.com/sst/sst/v3/pkg/process" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/telemetry" -) - -var version = "dev" - -func getAliasName(entry *project.ProviderLockEntry) string { - name := entry.Name - if entry.Name == entry.Package { - name = entry.Alias - } - for _, suffix := range []string{"official", "community"} { - if !strings.HasSuffix(entry.Name, "-"+suffix) && !strings.HasSuffix(entry.Package, "-"+suffix) { - continue - } - name = strings.TrimSuffix(name, "-"+suffix) - name = strings.TrimSuffix(name, suffix) - } - return name -} - -func main() { - // check if node_modules/.bin/sst exists - nodeModulesBinPath := filepath.Join("node_modules", ".bin", "sst") - binary, _ := os.Executable() - if _, err := os.Stat(nodeModulesBinPath); err == nil && !strings.Contains(binary, "node_modules") && os.Getenv("SST_SKIP_LOCAL") != "true" && version != "dev" { - // forward command to node_modules/.bin/sst - fmt.Fprintln(os.Stderr, ui.TEXT_WARNING_BOLD.Render("Warning: ")+"You are using a global installation of SST but you also have a local installation specified in your package.json. The local installation will be used but you should typically run it through your package manager.") - cmd := process.Command(nodeModulesBinPath, os.Args[1:]...) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Stdin = os.Stdin - cmd.Env = os.Environ() - cmd.Env = append(cmd.Env, "SST_SKIP_LOCAL=true") - if err := cmd.Run(); err != nil { - os.Exit(1) - } - return - } - telemetry.SetVersion(version) - defer telemetry.Close() - defer process.Cleanup() - telemetry.Track("cli.start", map[string]interface{}{ - "args": os.Args[1:], - }) - err := run() - if err != nil { - err := errors.Transform(err) - errorMessage := err.Error() - truncated := errorMessage - if len(errorMessage) > 255 { - truncated = errorMessage[:255] - } - telemetry.Track("cli.error", map[string]interface{}{ - "error": truncated, - }) - if readableErr, ok := err.(*util.ReadableError); ok { - slog.Error("exited with error", "err", readableErr.Unwrap()) - msg := readableErr.Error() - if msg != "" { - ui.Error(readableErr.Error()) - if readableErr.IsHinted() { - fmt.Fprintln(os.Stderr, " "+ui.TEXT_DIM.Render(readableErr.Unwrap().Error())) - } - } - } else { - slog.Error("exited with error", "err", err) - // check if context cancelled error - if err != context.Canceled { - ui.Error("Unexpected error occurred. Please run with --print-logs or check .sst/log/sst.log if available.") - } - } - telemetry.Close() - os.Exit(1) - return - } - telemetry.Track("cli.success", map[string]interface{}{}) -} - -func run() error { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - interruptChannel := make(chan os.Signal, 1) - signal.Notify(interruptChannel, syscall.SIGINT, syscall.SIGTERM) - go func() { - <-interruptChannel - slog.Info("interrupted") - cancel() - }() - c, err := cli.New(ctx, cancel, root, version) - if err != nil { - return err - } - _, err = user.Current() - if err != nil { - return err - } - - if !flag.SST_SKIP_DEPENDENCY_CHECK { - spin := spinner.New(spinner.CharSets[14], 100*time.Millisecond) - spin.Color("cyan") - spin.Suffix = " Download dependencies..." - if global.NeedsPulumi() { - spin.Suffix = " Installing pulumi..." - spin.Start() - err := global.InstallPulumi(ctx) - if err != nil { - spin.Stop() - return util.NewHintedError(err, "Could not install pulumi") - } - } - if global.NeedsBun() { - spin.Suffix = " Installing bun..." - spin.Start() - err := global.InstallBun(ctx) - if err != nil { - spin.Stop() - return util.NewHintedError(err, "Could not install bun") - } - } - spin.Stop() - } - return c.Run() -} - -var root = &cli.Command{ - Name: "sst", - Description: cli.Description{ - Short: "deploy anything", - Long: strings.Join([]string{ - "The CLI helps you manage your SST apps.", - "", - "If you are using SST as a part of your Node project, we recommend installing it locally.", - "```bash", - "npm install sst", - "```", - "---", - "If you are not using Node, you can install the CLI globally.", - "```bash", - "curl -fsSL https://sst.dev/install | bash", - "```", - "", - ":::note", - "The CLI currently supports macOS, Linux, and WSL. Windows support is in beta.", - ":::", - "", - "To install a specific version.", - "", - "```bash \"VERSION=0.0.403\"", - "curl -fsSL https://sst.dev/install | VERSION=0.0.403 bash", - "```", - "---", - "#### With a package manager", - "", - "You can also use a package manager to install the CLI.", - "", - "- **macOS**", - "", - " The CLI is available via a Homebrew Tap, and as downloadable binary in the [releases](https://github.com/sst/sst/releases/latest).", - "", - " ```bash", - " brew install sst/tap/sst", - "", - " # Upgrade", - " brew upgrade sst", - " ```", - "", - " You might have to run `brew upgrade sst`, before the update.", - "", - "- **Linux**", - "", - " The CLI is available as downloadable binaries in the [releases](https://github.com/sst/sst/releases/latest). Download the `.deb` or `.rpm` and install with `sudo dpkg -i` and `sudo rpm -i`.", - "", - " For Arch Linux, it's available in the [aur](https://aur.archlinux.org/packages/sst-bin).", - "---", - "#### Usage", - "", - "Once installed you can run the commands using.", - "", - "```bash", - "sst [command]", - "```", - "", - "The CLI takes a few global flags. For example, the deploy command takes the `--stage` flag", - "", - "```bash", - "sst deploy --stage production", - "```", - "---", - "#### Environment variables", - "", - "You can access any environment variables set in the CLI in your `sst.config.ts` file. For example, running:", - "", - "```bash", - "ENV_VAR=123 sst deploy", - "```", - "", - "Will let you access `ENV_VAR` through `process.env.ENV_VAR`.", - }, "\n"), - }, - Flags: []cli.Flag{ - { - Name: "stage", - Type: "string", - Description: cli.Description{ - Short: "The stage to deploy to", - Long: strings.Join([]string{ - "Set the stage the CLI is running on.", - "", - "```bash frame=\"none\"", - "sst [command] --stage production", - "```", - "", - "The stage is a string that is used to prefix the resources in your app. This allows you to have multiple _environments_ of your app running in the same account.", - "", - ":::tip", - "Changing the stage will redeploy your app to a new stage with new resources. The old resources will still be around in the old stage.", - ":::", - "", - "You can also use the `SST_STAGE` environment variable.", - "```bash frame=\"none\"", - "SST_STAGE=dev sst [command]", - "```", - "This can also be declared in a `.env` file or in the CLI session.", - "", - "If the stage is not passed in, then the CLI will:", - "", - "1. Use the username on the local machine.", - " - If the username is `root`, `admin`, `prod`, `dev`, `production`, then it will prompt for a stage name.", - "2. Store this in the `.sst/stage` file and reads from it in the future.", - "", - "This stored stage is called your **personal stage**.", - }, "\n"), - }, - }, - { - Name: "verbose", - Type: "bool", - Description: cli.Description{ - Short: "Enable verbose logging", - Long: strings.Join([]string{ - "", - "Prints extra information to the log files in the `.sst/` directory.", - "", - "```bash", - "sst [command] --verbose", - "```", - "", - "To also view this on the screen, use the `--print-logs` flag.", - "", - }, "\n"), - }, - }, - { - Name: "print-logs", - Type: "bool", - Description: cli.Description{ - Short: "Print logs to stderr", - Long: strings.Join([]string{ - "", - "Print the logs to the screen. These are logs that are written to the `.sst/` directory.", - "", - "```bash", - "sst [command] --print-logs", - "```", - "It can also be set using the `SST_PRINT_LOGS` environment variable.", - "", - "```bash", - "SST_PRINT_LOGS=1 sst [command]", - "```", - "This is useful when running in a CI environment.", - "", - }, "\n"), - }, - }, - { - Name: "config", - Type: "string", - Description: cli.Description{ - Short: "Path to the config file", - Long: strings.Join([]string{ - "", - "Optionally, pass in a path to the SST config file. This default to", - "`sst.config.ts` in the current directory.", - "", - "```bash", - "sst --config path/to/config.ts [command]", - "```", - "", - "This is useful when your monorepo has multiple SST apps in it.", - "You can run the SST CLI for a specific app by passing in the path to", - "its config file.", - }, "\n"), - }, - }, - { - Name: "help", - Type: "bool", - Description: cli.Description{ - Short: "Print help", - Long: strings.Join([]string{ - "Prints help for the given command.", - "", - "```sh frame=\"none\"", - "sst [command] --help", - "```", - "", - "Or the global help.", - "", - "```sh frame=\"none\"", - "sst --help", - "```", - }, "\n"), - }, - }, - }, - Children: []*cli.Command{ - { - Name: "init", - Description: cli.Description{ - Short: "Initialize a new project", - Long: strings.Join([]string{ - "Initialize a new project in the current directory. This will create a `sst.config.ts` and `sst install` your providers.", - "", - "If this is run in a Next.js, Remix, Astro, or SvelteKit project, it'll init SST in drop-in mode.", - "", - "To skip the interactive confirmation after detecting the framework.", - "", - "```bash frame=\"none\"", - "sst init --yes", - "```", - }, "\n"), - }, - Run: CmdInit, - Flags: []cli.Flag{ - { - Name: "yes", - Type: "bool", - Description: cli.Description{ - Short: "Skip interactive confirmation", - Long: "Skip interactive confirmation for detected framework.", - }, - }, - }, - }, - { - Name: "ui", - Hidden: true, - Run: CmdUI, - Flags: []cli.Flag{ - { - Name: "filter", - Type: "string", - Description: cli.Description{ - Short: "Filter events", - Long: "Filter events.", - }, - }, - }, - }, - { - Name: "dev", - Description: cli.Description{ - Short: "Run in development mode", - Long: strings.Join([]string{ - "Run your app in dev mode. By default, this starts a multiplexer with processes that", - " deploy your app, run your functions, and start your frontend.", - "", - ":::note", - "The tabbed terminal UI is only available on Linux/macOS and WSL.", - ":::", - "", - "Each process is run in a separate tab that you can click on in the sidebar.", - "", - "![sst dev multiplexer mode](../../../../assets/docs/cli/sst-dev-multiplexer-mode.png)", - "", - "The multiplexer makes it so that you won't have to start your frontend or", - "your container applications separately.", - "", - "", - "", - "Here's what happens when you run `sst dev`.", - "", - "- Deploy most of your resources as-is.", - "- Except for components that have a `dev` prop.", - " - `Function` components are run [_Live_](/docs/live/) in the **Functions** tab.", - " - `Task` components have their _stub_ versions deployed that proxy the task", - " and run their `dev.command` in the **Tasks** tab.", - " - Frontends like `Nextjs`, `Remix`, `Astro`, `StaticSite`, etc. have their dev", - " servers started in a separate tab and are not deployed.", - " - `Service` components are not deployed, and instead their `dev.command` is", - " started in a separate tab.", - " - `Postgres`, `Aurora`, and `Redis` link to a local database if the `dev` prop is", - " set.", - "- Start an [`sst tunnel`](#tunnel) session in a new tab if your app has a `Vpc`", - " with `bastion` enabled.", - "- Load any [linked resources](/docs/linking) in the environment.", - "- Start a watcher for your `sst.config.ts` and redeploy any changes.", - "", - ":::note", - "The `Service` component and the frontends like `Nextjs` or `StaticSite` are not", - "deployed by `sst dev`.", - ":::", - "", - "Optionally, you can disable the multiplexer and not spawn any child", - "processes by running `sst dev` in basic mode.", - "", - "```bash frame=\"none\"", - "sst dev --mode=basic", - "```", - "", - "This will only deploy your app and run your functions. If you are coming from SST", - "v2, this is how `sst dev` used to work.", - "", - "However in `basic` mode, you'll need to start your frontend separately by running", - "`sst dev` in a separate terminal session by passing in the command. For example:", - "", - "```bash frame=\"none\"", - "sst dev next dev", - "```", - "", - "By wrapping your command, it'll load your [linked resources](/docs/linking) in the", - "environment.", - "", - "To pass in a flag to the command, use `--`.", - "", - "```bash frame=\"none\"", - "sst dev -- next dev --turbo", - "```", - "", - "You can also disable the tabbed terminal UI by running `sst dev` in", - "mono mode.", - "", - "```bash frame=\"none\"", - "sst dev --mode=mono", - "```", - "", - "Unlike `basic` mode, this'll spawn child processes. But instead of", - "a tabbed UI it'll show their outputs in a single stream.", - "", - "This is used by default in Windows.", - }, "\n"), - }, - Flags: []cli.Flag{ - { - Name: "mode", - Type: "string", - Description: cli.Description{ - Short: "mode=mono to turn off multiplexer. mode=basic to not spawn any child processes", - Long: "Defaults to using `multi` mode. Use `mono` to get a single stream of all child process logs or `basic` to not spawn any child processes.", - }, - }, - { - Name: "policy", - Type: "string", - Description: cli.Description{ - Short: "Path to policy pack", - Long: "Run policy pack validation against the preview changes.", - }, - }, - }, - Args: []cli.Argument{ - { - Name: "command", - Description: cli.Description{ - Short: "The command to run", - }, - }, - }, - Examples: []cli.Example{ - { - Content: "sst dev", - Description: cli.Description{ - Short: "Brings up your entire app - should be all you need", - }, - }, - { - Content: "sst dev next dev", - Description: cli.Description{ - Short: "Start a command connected to a running sst dev session", - }, - }, - { - Content: "sst dev -- next dev --turbo", - Description: cli.Description{ - Short: "Use -- to pass flags to the command", - }, - }, - }, - Run: CmdMosaic, - }, - CmdDeploy, - CmdDiff, - { - Name: "add", - Description: cli.Description{ - Short: "Add a new provider", - Long: strings.Join([]string{ - "Adds and installs the given provider. For example,", - "", - "```bash frame=\"none\"", - "sst add aws", - "```", - "", - "This command will:", - "", - "1. Installs the package for the AWS provider.", - "2. Add `aws` to the globals in your `sst.config.ts`.", - "3. And, add it to your `providers`.", - "", - "```ts title=\"sst.config.ts\"", - "{", - " providers: {", - " aws: {", - " package: \"@pulumi/aws\",", - " version: \"6.27.0\"", - " }", - " }", - "}", - "```", - "", - "You can use any provider listed in the [Directory](/docs/all-providers#directory).", - "", - ":::note", - "Running `sst add aws` above is the same as manually adding the provider to your config and running `sst install`.", - ":::", - "", - "By default, the latest version of the provider is installed. If you want to use a specific version, you can change it in your config.", - "", - "```ts title=\"sst.config.ts\"", - "{", - " providers: {", - " aws: {", - " package: \"@pulumi/aws\",", - " version: \"6.26.0\"", - " }", - " }", - "}", - "```", - "", - "You'll need to run `sst install` if you update the `providers` in your config.", - "", - "By default, these packages are fetched from the NPM registry. If you want to use a different registry, you can set the `NPM_REGISTRY` environment variable.", - "", - "```bash frame=\"none\"", - "NPM_REGISTRY=https://my-registry.com sst add aws", - "```", - "", - "You can also set the registry in your `.npmrc` file. If your registry requires authentication, SST supports `_authToken`, `_auth`, and `username`/`_password` from `.npmrc`.", - }, "\n"), - }, - Args: []cli.Argument{ - { - Name: "provider", - Required: true, - Description: cli.Description{ - Short: "The provider to add", - Long: "The provider to add.", - }, - }, - }, - Run: func(cli *cli.Cli) error { - pkg := cli.Positional(0) - spin := spinner.New(spinner.CharSets[14], 100*time.Millisecond) - spin.Color("cyan") - spin.Suffix = " Adding provider..." - spin.Start() - defer spin.Stop() - cfgPath, err := cli.Discover() - if err != nil { - return err - } - stage, err := cli.Stage(cfgPath) - if err != nil { - return err - } - p, err := project.New(&project.ProjectConfig{ - Version: version, - Config: cfgPath, - Stage: stage, - }) - if err != nil { - return err - } - if !p.CheckPlatform(version) { - err := p.CopyPlatform(version) - if err != nil { - return err - } - } - entry, err := project.FindProvider(pkg, "latest", pkg) - if err != nil { - return util.NewReadableError(err, "Could not find provider "+pkg) - } - providerName := getAliasName(entry) - err = p.Add(providerName, entry.Version, entry.Package) - if err != nil { - return util.NewReadableError(err, err.Error()) - } - spin.Suffix = " Downloading provider..." - p, err = project.New(&project.ProjectConfig{ - Version: version, - Config: cfgPath, - Stage: stage, - }) - if err != nil { - return err - } - err = p.Install() - if err != nil { - return err - } - spin.Stop() - ui.Success(fmt.Sprintf("Added provider \"%s\". You can create resources with `new %s.SomeResource()`.", entry.Alias, entry.Alias)) - return nil - }, - }, - { - Name: "install", - Description: cli.Description{ - Short: "Install all the providers", - Long: strings.Join([]string{ - "Installs the providers in your `sst.config.ts`. You'll need this command when:", - "", - "1. You add a new provider to the `providers` or `home` in your config.", - "2. Or, when you want to install new providers after you `git pull` some changes.", - "", - ":::tip", - "The `sst install` command is similar to `npm install`.", - ":::", - "", - "Behind the scenes, it installs the packages for your providers and adds the providers to your globals.", - "", - "If you don't have a version specified for your providers in your `sst.config.ts`, it'll install their latest versions.", - }, "\n"), - }, - Run: func(cli *cli.Cli) error { - cfgPath, err := cli.Discover() - if err != nil { - return err - } - - stage, err := cli.Stage(cfgPath) - if err != nil { - return err - } - - p, err := project.New(&project.ProjectConfig{ - Version: version, - Config: cfgPath, - Stage: stage, - }) - if err != nil { - return err - } - - spin := spinner.New(spinner.CharSets[14], 100*time.Millisecond) - spin.Color("cyan") - defer spin.Stop() - spin.Suffix = " Installing providers..." - spin.Start() - if !p.CheckPlatform(version) { - err := p.CopyPlatform(version) - if err != nil { - return err - } - } - - err = p.Install() - if err != nil { - return err - } - spin.Stop() - ui.Success("Installed providers") - return nil - }, - }, - { - Name: "secret", - Description: cli.Description{ - Short: "Manage secrets", - Long: strings.Join([]string{ - "Manage the secrets in your app defined with `sst.Secret`.", - "", - "", - "", - "The `--fallback` flag can be used to manage the fallback values of a secret.", - "", - "Applies to all the sub-commands in `sst secret`.", - }, "\n"), - }, - Flags: []cli.Flag{ - { - Name: "fallback", - Type: "bool", - Description: cli.Description{ - Short: "Manage the fallback values of secrets", - Long: "Manage the fallback values of secrets.", - }, - }, - }, - Children: []*cli.Command{ - CmdSecretSet, - CmdSecretRemove, - CmdSecretLoad, - CmdSecretList, - }, - }, - { - Name: "shell", - Args: []cli.Argument{ - { - Name: "command", - Description: cli.Description{ - Short: "A command to run", - Long: "A command to run.", - }, - }, - }, - Flags: []cli.Flag{ - { - Name: "target", - Description: cli.Description{ - Short: "Run it only for a component", - Long: "Only run it for the given component.", - }, - }, - }, - Description: cli.Description{ - Short: "Run a command with linked resources", - Long: strings.Join([]string{ - "Run a command with **all the resources linked** to the environment. This is useful for running scripts against your infrastructure.", - "", - "For example, let's say you have the following resources in your app.", - "", - "```js title=\"sst.config.ts\" {5,9}", - "new sst.aws.Bucket(\"MyMainBucket\");", - "new sst.aws.Bucket(\"MyAdminBucket\");", - "```", - "", - "We can now write a script that'll can access both these resources with the [JS SDK](/docs/reference/sdk/).", - "", - "```js title=\"my-script.js\" \"Resource.MyMainBucket.name\" \"Resource.MyAdminBucket.name\"", - "import { Resource } from \"sst\";", - "", - "console.log(Resource.MyMainBucket.name, Resource.MyAdminBucket.name);", - "```", - "", - "And run the script with `sst shell`.", - "", - "```bash frame=\"none\" frame=\"none\"", - "sst shell node my-script.js", - "```", - "", - "This'll have access to all the buckets from above.", - "", - ":::tip", - "Run the command with `--` to pass arguments to it.", - ":::", - "", - "To pass arguments into the script, you'll need to prefix it using `--`.", - "", - "```bash frame=\"none\" frame=\"none\" /--(?!a)/", - "sst shell -- node my-script.js --arg1 --arg2", - "```", - "", - "If no command is passed in, it opens a shell session with the linked resources.", - "", - "```bash frame=\"none\" frame=\"none\"", - "sst shell", - "```", - "", - "This is useful if you want to run multiple commands, all while accessing the resources in your app.", - "", - "Optionally, you can run this for a specific component by passing in the name of the component.", - "", - "```bash frame=\"none\" frame=\"none\"", - "sst shell --target MyComponent", - "```", - "", - "Here the linked resources for `MyComponent` and its environment variables are available.", - }, "\n"), - }, - Examples: []cli.Example{ - { - Content: "sst shell", - Description: cli.Description{ - Short: "Open a shell session", - }, - }, - }, - Run: CmdShell, - }, - { - Name: "remove", - Description: cli.Description{ - Short: "Remove your application", - Long: strings.Join([]string{ - "Removes your application. By default, it removes your personal stage.", - "", - ":::tip", - "The resources in your app are removed based on the `removal` setting in your `sst.config.ts`.", - ":::", - "", - "This does not remove the SST _state_ and _bootstrap_ resources in your account as these might still be in use by other apps. You can remove them manually if you want to reset your account, [learn more](/docs/state/#reset).", - "", - "Optionally, remove your app from a specific stage.", - "", - "```bash frame=\"none\" frame=\"none\"", - "sst remove --stage production", - "```", - "You can also remove a specific component by passing in the name of the component from your `sst.config.ts`.", - "", - "```bash frame=\"none\"", - "sst remove --target MyComponent", - "```", - }, "\n"), - }, - Flags: []cli.Flag{ - { - Name: "target", - Type: "string", - Description: cli.Description{ - Short: "Run it only for a component", - Long: "Only run it for the given component.", - }, - }, - }, - Run: CmdRemove, - }, - { - Name: "unlock", - Description: cli.Description{ - Short: "Clear any locks on the app state", - Long: strings.Join([]string{ - "When you run `sst deploy`, it acquires a lock on your state file to prevent concurrent deploys.", - "", - "However, if something unexpectedly kills the `sst deploy` process, or if you manage to run `sst deploy` concurrently, the lock might not be released.", - "", - "This should not usually happen, but it can prevent you from deploying. You can run `sst unlock` to release the lock.", - }, "\n"), - }, - Run: func(c *cli.Cli) error { - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - - err = p.ForceUnlock() - if err != nil { - return err - } - color.New(color.FgGreen, color.Bold).Print("✓ ") - color.New(color.FgWhite).Print(" Unlocked the app state for: ") - color.New(color.FgWhite, color.Bold).Println(p.App().Name, "/", p.App().Stage) - return nil - }, - }, - CmdVersion, - { - Name: "upgrade", - Description: cli.Description{ - Short: "Upgrade the CLI", - Long: strings.Join([]string{ - "Upgrade the CLI to the latest version. Or optionally, pass in a version to upgrade to.", - "", - "```bash frame=\"none\"", - "sst upgrade 0.10", - "```", - }, "\n"), - }, - Args: cli.ArgumentList{ - { - Name: "version", - Description: cli.Description{ - Short: "A version to upgrade to", - Long: "A version to upgrade to.", - }, - }, - }, - Run: CmdUpgrade, - }, - { - Name: "telemetry", Description: cli.Description{ - Short: "Manage telemetry settings", - Long: strings.Join([]string{ - "Manage telemetry settings.", - "", - "SST collects completely anonymous telemetry data about general usage. We track:", - "- Version of SST in use", - "- Command invoked, `sst dev`, `sst deploy`, etc.", - "- General machine information, like the number of CPUs, OS, CI/CD environment, etc.", - "", - "This is completely optional and can be disabled at any time.", - "", - "You can also opt-out by setting an environment variable: `SST_TELEMETRY_DISABLED=1` or `DO_NOT_TRACK=1`.", - }, "\n"), - }, - Children: []*cli.Command{ - { - Name: "enable", - Description: cli.Description{ - Short: "Enable telemetry", - Long: "Enable telemetry.", - }, - Run: func(cli *cli.Cli) error { - return telemetry.Enable() - }, - }, - { - Name: "disable", - Description: cli.Description{ - Short: "Disable telemetry", - Long: "Disable telemetry.", - }, - Run: func(cli *cli.Cli) error { - return telemetry.Disable() - }, - }, - }, - }, - { - Name: "introspect", - Hidden: true, - Run: func(cli *cli.Cli) error { - data, err := json.MarshalIndent(cli.Path()[0], "", " ") - if err != nil { - return err - } - fmt.Println(string(data)) - return nil - }, - }, - { - Name: "print-and-not-quit", - Hidden: true, - Run: func(cli *cli.Cli) error { - lines := strings.Split(os.Getenv("SST_DEV_COMMAND_MESSAGE"), "\n") - for _, line := range lines { - fmt.Println(line) - } - <-cli.Context.Done() - return nil - }, - }, - { - Name: "refresh", - Description: cli.Description{ - Short: "Refresh the local app state", - Long: strings.Join([]string{ - "Compares your local state with the state of the resources in the cloud provider. Any changes that are found are adopted into your local state. It will:", - "", - "1. Go through every single resource in your state.", - "2. Make a call to the cloud provider to check the resource.", - " - If the configs are different, it'll **update the state** to reflect the change.", - " - If the resource doesn't exist anymore, it'll **remove it from the state**.", - "", - ":::note", - "The `sst refresh` does not make changes to the resources in the cloud provider.", - ":::", - "", - "By default, this refreshes the stage as it would be deployed using `sst deploy`. If the stage was deployed using `sst dev`, use the `--dev` flag.", - "", - "```bash frame=\"none\"", - "sst refresh --dev", - "```", - "", - "You can also refresh a specific component by passing in the name of the component.", - "", - "```bash frame=\"none\"", - "sst refresh --target MyComponent", - "```", - "", - "Alternatively, exclude a specific component from the refresh.", - "", - "```bash frame=\"none\"", - "sst refresh --exclude MyComponent", - "```", - "", - "This is useful for cases where you want to ensure that your local state is in sync with your cloud provider. [Learn more about how state works](/docs/providers/#how-state-works).", - }, "\n"), - }, - Flags: []cli.Flag{ - { - Name: "target", - Type: "string", - Description: cli.Description{ - Short: "Run it only for a component", - Long: "Only run it for the given component.", - }, - }, - { - Name: "exclude", - Type: "string", - Description: cli.Description{ - Short: "Exclude a component", - Long: "Exclude the specified component from the operation.", - }, - }, - { - Name: "dev", - Type: "bool", - Description: cli.Description{ - Short: "Refresh in dev mode", - Long: "Refresh the dev version of this stage.", - }, - }, - }, - Run: CmdRefresh, - }, - CmdState, - CmdCert, - CmdTunnel, - CmdDiagnostic, - }, -} diff --git a/cmd/sst/mosaic.go b/cmd/sst/mosaic.go deleted file mode 100644 index 17b62fcdb7..0000000000 --- a/cmd/sst/mosaic.go +++ /dev/null @@ -1,497 +0,0 @@ -package main - -import ( - "fmt" - "io" - "log/slog" - "os" - "os/exec" - "path/filepath" - goruntime "runtime" - "strings" - "time" - - "github.com/kballard/go-shellquote" - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/aws" - "github.com/sst/sst/v3/cmd/sst/mosaic/cloudflare" - "github.com/sst/sst/v3/cmd/sst/mosaic/deployer" - "github.com/sst/sst/v3/cmd/sst/mosaic/dev" - "github.com/sst/sst/v3/cmd/sst/mosaic/monoplexer" - "github.com/sst/sst/v3/cmd/sst/mosaic/multiplexer" - "github.com/sst/sst/v3/cmd/sst/mosaic/socket" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/cmd/sst/mosaic/watcher" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/flag" - "github.com/sst/sst/v3/pkg/process" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/project/path" - "github.com/sst/sst/v3/pkg/runtime" - "github.com/sst/sst/v3/pkg/server" - "golang.org/x/sync/errgroup" -) - -func CmdMosaic(c *cli.Cli) error { - cwd, _ := os.Getwd() - var wg errgroup.Group - - child := os.Getenv("SST_CHILD") - // spawning child process - if len(c.Arguments()) > 0 || child != "" { - args := c.Arguments() - slog.Info("dev mode with target", "args", c.Arguments()) - cfgPath, err := c.Discover() - stage, err := c.Stage(cfgPath) - if err != nil { - return err - } - url, err := server.Discover(cfgPath, stage) - if err != nil { - return err - } - slog.Info("found server", "url", url) - evts, err := dev.Stream(c.Context, url, project.CompleteEvent{}) - if err != nil { - return err - } - cwd, _ := os.Getwd() - currentDir := cwd - for { - nodeBinPath := filepath.Join(currentDir, "node_modules", ".bin") - newPath := nodeBinPath + string(os.PathListSeparator) + os.Getenv("PATH") - os.Setenv("PATH", newPath) - parentDir := filepath.Dir(currentDir) - if parentDir == currentDir { - break - } - currentDir = parentDir - } - var cmd *exec.Cmd - var last *dev.EnvResponse - processExited := make(chan bool) - timeout := time.Minute * 50 - timer := time.NewTimer(timeout) - defer timer.Stop() - - for { - select { - case <-c.Context.Done(): - return nil - case <-processExited: - c.Cancel() - continue - case <-timer.C: - last = nil - go func() { - evts <- true - }() - fmt.Println("\n" + ui.TEXT_DIM.Render("[timeout]")) - timer.Reset(timeout) - continue - case _, ok := <-evts: - if !ok { - return nil - } - query := "directory=" + cwd - if child != "" { - query = "name=" + child - } - nextEnv, err := dev.Env(c.Context, query, url) - if err != nil { - return err - } - if _, ok := nextEnv.Env["AWS_ACCESS_KEY_ID"]; ok { - timeout = time.Minute * 45 - } - if last == nil || diff(last.Env, nextEnv.Env) || last.Command != nextEnv.Command { - if cmd != nil && cmd.Process != nil { - process.Kill(cmd.Process) - <-processExited - fmt.Println("\n[restarting]") - } - fields, _ := shellquote.Split(nextEnv.Command) - if len(args) > 0 { - fields = args - } - cmd = process.Command( - fields[0], - fields[1:]..., - ) - cmd.Env = os.Environ() - cmd.Env = append(cmd.Env, "FORCE_COLOR=1") - for k, v := range nextEnv.Env { - cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", k, v)) - } - process.DetachSession(cmd) - cmd.Stdin = os.Stdin - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - if child != "" && flag.SST_LOG_CHILDREN { - slog.Info("creating log file for child process") - file, err := os.Create(filepath.Join(path.ResolveLogDir(cfgPath), child+".log")) - if err != nil { - return err - } - cmd.Stdout = io.MultiWriter(file, os.Stdout) - cmd.Stderr = io.MultiWriter(file, os.Stderr) - } - cmd.Start() - go func() { - cmd.Wait() - processExited <- true - }() - } - last = nextEnv - } - } - } - - if os.Getenv("SST_SERVER") != "" { - return util.NewReadableError(nil, "The dev command for this process does not look right. Check your dev script in package.json to make sure it is simply starting your process and not running `sst dev`. More info here: https://sst.dev/docs/reference/cli/#dev") - } - - p, err := c.InitProject() - if err != nil { - return err - } - if p.App().Protect { - return project.ErrProtectedDevStage - } - policyPath := c.String("policy") - if policyPath != "" { - if _, err := p.ResolvePolicyPackPath(policyPath); err != nil { - return util.NewReadableError(nil, err.Error()) - } - } - os.Setenv("SST_STAGE", p.App().Stage) - slog.Info("mosaic", "project", p.PathRoot()) - - wg.Go(func() error { - defer c.Cancel() - return watcher.Start(c.Context, watcher.WatchConfig{ - Root: p.PathRoot(), - Watch: p.App().Watch, - }) - }) - - server, err := server.New() - if err != nil { - return err - } - - wg.Go(func() error { - defer c.Cancel() - return dev.Start(c.Context, p, server) - }) - - wg.Go(func() error { - defer c.Cancel() - return socket.Start(c.Context, p, server) - }) - - wg.Go(func() error { - evts := bus.Subscribe(&runtime.BuildInput{}) - for { - select { - case <-c.Context.Done(): - return nil - case evt := <-evts: - switch evt := evt.(type) { - case *runtime.BuildInput: - p.Runtime.AddTarget(evt) - } - } - } - }) - - os.Setenv("SST_SERVER", fmt.Sprintf("http://localhost:%v", server.Port)) - for name, a := range p.App().Providers { - args := a - switch name { - case "aws": - if flag.SST_SKIP_APPSYNC { - continue - } - wg.Go(func() error { - defer c.Cancel() - return aws.Start(c.Context, p, server, args.(map[string]interface{})) - }) - case "cloudflare": - wg.Go(func() error { - defer c.Cancel() - return cloudflare.Start(c.Context, p, args.(map[string]interface{})) - }) - } - } - - wg.Go(func() error { - defer c.Cancel() - return server.Start(c.Context, p) - }) - - currentExecutable, _ := os.Executable() - - mode := c.String("mode") - - if mode == "" { - mode = "multi" - if goruntime.GOOS == "windows" { - mode = "mono" - } - } - - evts := bus.Subscribe(&project.CompleteEvent{}) - - wg.Go(func() error { - defer c.Cancel() - return deployer.Start(c.Context, p, server, policyPath) - }) - - if mode == "multi" { - multi, err := multiplexer.New() - if err != nil { - return err - } - multiEnv := append( - c.Env(), - fmt.Sprintf("SST_SERVER=http://localhost:%v", server.Port), - "SST_STAGE="+p.App().Stage, - ) - serverURL := fmt.Sprintf("http://localhost:%v", server.Port) - _, hasAWS := p.App().Providers["aws"] - showWorkers := p.App().Home == "cloudflare" && !hasAWS - fnTitle := "Functions" - fnFilter := "function" - if showWorkers { - fnTitle = "Workers" - fnFilter = "worker" - } - multi.AddProcess(multiplexer.PaneConfig{ - Key: "deploy", - Args: []string{currentExecutable, "ui", "--filter=sst"}, - Icon: "⑆", - Title: "SST", - Autostart: true, - Env: append(multiEnv, "SST_LOG="+p.PathLog("ui-deploy")), - }) - multi.AddProcess(multiplexer.PaneConfig{ - Key: "function", - Args: []string{currentExecutable, "ui", "--filter=" + fnFilter}, - Icon: "λ", - Title: fnTitle, - Autostart: true, - Filterable: true, - FilterTitle: fnTitle, - FilterSubtitle: "Select to filter logs", - OnFilterChanged: func(value string) { - bus.Publish(&ui.PaneFilterEvent{PaneKey: "function", Value: value}) - }, - ListOptions: func() []multiplexer.FilterOption { - completed, err := dev.Completed(c.Context, serverURL) - if err != nil || completed == nil { - return nil - } - var options []multiplexer.FilterOption - for _, r := range completed.Resources { - if string(r.Type) == "sst:aws:Function" || string(r.Type) == "sst:cloudflare:Worker" { - name := r.URN.Name() - handler := name - if meta, ok := r.Outputs["_metadata"].(map[string]interface{}); ok { - if h, ok := meta["handler"].(string); ok { - handler = h - } - } - options = append(options, multiplexer.FilterOption{ - Label: name, - Description: handler, - Value: name, - }) - } - } - return options - }, - Env: append(multiEnv, "SST_LOG="+p.PathLog("ui-function")), - }) - defer func() { - multi.Exit() - }() - go func() { - multi.Start() - }() - wg.Go(func() error { - defer c.Cancel() - for { - select { - case <-c.Context.Done(): - return nil - case unknown := <-evts: - switch evt := unknown.(type) { - case *project.CompleteEvent: - for _, d := range evt.Devs { - if d.Command == "" { - continue - } - dir := filepath.Join(cwd, d.Directory) - title := d.Title - if title == "" { - title = d.Name - } - multi.AddProcess(multiplexer.PaneConfig{ - Key: d.Name, - Args: []string{currentExecutable, "dev"}, - Icon: "→", - Title: title, - Cwd: dir, - Killable: true, - Autostart: d.Autostart, - Env: append([]string{"SST_CHILD=" + d.Name}, multiEnv...), - }) - } - for name := range evt.Tunnels { - multi.AddProcess(multiplexer.PaneConfig{ - Key: "tunnel", - Args: []string{currentExecutable, "tunnel", "--stage", p.App().Stage}, - Icon: "⇌", - Title: "Tunnel", - Killable: true, - Autostart: true, - Env: append(multiEnv, "SST_LOG="+p.PathLog("tunnel_"+name)), - }) - } - if len(evt.Tasks) > 0 { - multi.AddProcess(multiplexer.PaneConfig{ - Key: "task", - Args: []string{currentExecutable, "ui", "--filter=task"}, - Icon: "⧉", - Title: "Tasks", - Autostart: true, - Filterable: true, - FilterTitle: "Tasks", - FilterSubtitle: "Select a task to filter logs", - OnFilterChanged: func(value string) { - bus.Publish(&ui.PaneFilterEvent{PaneKey: "task", Value: value}) - }, - ListOptions: func() []multiplexer.FilterOption { - completed, err := dev.Completed(c.Context, serverURL) - if err != nil || completed == nil { - return nil - } - var options []multiplexer.FilterOption - for name, t := range completed.Tasks { - desc := "" - if t.Command != nil { - desc = *t.Command - } - options = append(options, multiplexer.FilterOption{ - Label: name, - Description: desc, - Value: name, - }) - } - return options - }, - Env: append(multiEnv, "SST_LOG="+p.PathLog("ui-task")), - }) - } - var fnNames []string - for _, r := range evt.Resources { - if string(r.Type) == "sst:aws:Function" || string(r.Type) == "sst:cloudflare:Worker" { - fnNames = append(fnNames, r.URN.Name()) - } - } - multi.CheckFilter("function", fnNames) - var taskNames []string - for name := range evt.Tasks { - taskNames = append(taskNames, name) - } - multi.CheckFilter("task", taskNames) - break - } - } - } - }) - } - - if mode == "basic" { - wg.Go(func() error { - <-server.Ready - return CmdUI(c) - }) - } - - if mode == "mono" { - mono := monoplexer.New() - _, hasAWS := p.App().Providers["aws"] - fnTitle := "Function" - fnFilter := "function" - if p.App().Home == "cloudflare" && !hasAWS { - fnTitle = "Worker" - fnFilter = "worker" - } - mono.AddProcess("deploy", []string{currentExecutable, "ui", "--filter=sst"}, "", "SST", true) - mono.AddProcess("function", []string{currentExecutable, "ui", "--filter=" + fnFilter}, "", fnTitle, true) - - wg.Go(func() error { - defer c.Cancel() - return mono.Start(c.Context) - }) - - wg.Go(func() error { - defer c.Cancel() - for { - select { - case <-c.Context.Done(): - return nil - case unknown := <-evts: - switch evt := unknown.(type) { - case *project.CompleteEvent: - for _, d := range evt.Devs { - if d.Command == "" { - continue - } - dir := filepath.Join(cwd, d.Directory) - words, _ := shellquote.Split(d.Command) - title := d.Title - if title == "" { - title = d.Name - } - mono.AddProcess( - d.Name, - append([]string{currentExecutable, "dev", "--"}, words...), - dir, - title, - d.Autostart, - "SST_CHILD="+d.Name, - ) - } - for range evt.Tunnels { - mono.AddProcess("tunnel", []string{currentExecutable, "tunnel", "--stage", p.App().Stage}, "", "Tunnel", true) - } - break - } - } - } - }) - } - - err = wg.Wait() - slog.Info("done mosaic", "err", err) - return err -} - -func diff(a map[string]string, b map[string]string) bool { - if len(a) != len(b) { - return true - } - for k, v := range a { - if strings.HasPrefix(k, "AWS_") { - continue - } - if b[k] != v { - return true - } - } - return false -} diff --git a/cmd/sst/mosaic/aws/appsync/appsync.go b/cmd/sst/mosaic/aws/appsync/appsync.go deleted file mode 100644 index f2bb97726c..0000000000 --- a/cmd/sst/mosaic/aws/appsync/appsync.go +++ /dev/null @@ -1,393 +0,0 @@ -package appsync - -import ( - "bytes" - "context" - "crypto/sha256" - "encoding/base64" - "encoding/hex" - "encoding/json" - "fmt" - "io" - "log/slog" - "net/http" - "net/url" - "os" - "sync" - "time" - - "github.com/aws/aws-sdk-go-v2/aws" - v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" - "github.com/gorilla/websocket" - "github.com/sst/sst/v3/pkg/id" -) - -var log = slog.Default().With("service", "appsync.connection") - -var ErrSubscriptionFailed = fmt.Errorf("appsync subscription failed") -var ErrConnectionFailed = fmt.Errorf("appsync connection failed") - -func getProxyURL(isHTTPS bool) (*url.URL, error) { - var proxyEnv string - - if isHTTPS { - proxyEnv = os.Getenv("HTTPS_PROXY") - if proxyEnv == "" { - proxyEnv = os.Getenv("https_proxy") - } - } - - if proxyEnv == "" { - proxyEnv = os.Getenv("HTTP_PROXY") - if proxyEnv == "" { - proxyEnv = os.Getenv("http_proxy") - } - } - - if proxyEnv != "" { - noProxy := os.Getenv("NO_PROXY") - if noProxy == "" { - noProxy = os.Getenv("no_proxy") - } - - if noProxy == "*" { - return nil, nil - } - } - - if proxyEnv == "" { - return nil, nil - } - - return url.Parse(proxyEnv) -} - -func getHTTPClient() *http.Client { - proxyURL, err := getProxyURL(true) - if err != nil { - log.Warn("failed to parse proxy URL", "err", err) - return http.DefaultClient - } - - if proxyURL == nil { - return http.DefaultClient - } - - log.Info("using proxy for HTTP requests", "proxy", proxyURL.String()) - return &http.Client{ - Transport: &http.Transport{ - Proxy: http.ProxyURL(proxyURL), - }, - } -} - -type Connection struct { - conn *websocket.Conn - cfg aws.Config - httpEndpoint string - realtimeEndpoint string - subscriptions map[string]SubscriptionInfo - lock sync.Mutex -} - -type SubscriptionInfo struct { - Channel string - Out chan string -} - -type SubscribeEvent struct { - Type string `json:"type"` - ID string `json:"id"` - Channel string `json:"channel"` - Authorization interface{} `json:"authorization"` -} - -func Dial( - ctx context.Context, - cfg aws.Config, - httpEndpoint string, - realtimeEndpoint string, -) (*Connection, error) { - result := &Connection{ - cfg: cfg, - httpEndpoint: httpEndpoint, - realtimeEndpoint: realtimeEndpoint, - subscriptions: map[string]SubscriptionInfo{}, - } - - err := result.connect(ctx) - if err != nil { - return nil, err - } - - go func() { - <-ctx.Done() - if result.conn != nil { - result.conn.Close() - } - for _, item := range result.subscriptions { - close(item.Out) - } - }() - return result, nil -} - -func (c *Connection) connect(ctx context.Context) error { - log.Info("connecting") - auth, err := c.getAuth(ctx, map[string]interface{}{}) - if err != nil { - return err - } - authJson, err := json.Marshal(auth) - if err != nil { - return err - } - auth64 := base64.URLEncoding.WithPadding(base64.NoPadding).EncodeToString(authJson) - - // Configure WebSocket dialer with proxy support - dialer := websocket.Dialer{ - Subprotocols: []string{"aws-appsync-event-ws", "header-" + auth64}, - } - - // Add proxy support to WebSocket dialer - proxyURL, err := getProxyURL(true) // WebSocket uses wss:// (HTTPS) - if err != nil { - log.Warn("failed to parse proxy URL", "err", err) - } else if proxyURL != nil { - dialer.Proxy = http.ProxyURL(proxyURL) - log.Info("using proxy for WebSocket connection", "proxy", proxyURL.String()) - } - - conn, _, err := dialer.DialContext(ctx, "wss://"+c.realtimeEndpoint+"/event/realtime", nil) - if err != nil { - return err - } - conn.WriteJSON(map[string]interface{}{ - "type": "connection_init", - }) - c.conn = conn - - msg := map[string]interface{}{} - err = conn.ReadJSON(&msg) - if err != nil { - log.Error("write to connection failed", "err", err) - return ErrConnectionFailed - } - log.Info("connect message", "msg", msg) - if msg["type"] != "connection_ack" { - return ErrConnectionFailed - } - duration := time.Millisecond * time.Duration(msg["connectionTimeoutMs"].(float64)) - - timer := time.NewTimer(duration) - go func() { - select { - case <-ctx.Done(): - return - case <-timer.C: - log.Info("connection timeout") - conn.Close() - for { - select { - case <-ctx.Done(): - return - default: - err := c.connect(ctx) - if err != nil { - log.Info("failed to reconnect", "err", err) - time.Sleep(time.Second * 5) - continue - } - for id, sub := range c.subscriptions { - log.Info("resubscribing", "channel", sub.Channel, "id", id) - err := c.subscribe(ctx, sub.Channel, id) - if err != nil { - log.Error("failed to resubscribe", "err", err) - continue - } - } - return - } - } - } - }() - - go func() { - for { - msg := map[string]interface{}{} - err := conn.ReadJSON(&msg) - if err != nil { - log.Info("connection closed") - timer.Reset(1 * time.Millisecond) - return - } - log.Info("msg", "type", msg["type"], "id", msg["id"]) - - if msg["type"] == "connection_ack" { - duration = time.Millisecond * time.Duration(msg["connectionTimeoutMs"].(float64)) - log.Info("keep alive set", "duration", duration.Seconds()) - timer.Reset(duration) - } - - if msg["type"] == "ka" { - timer.Reset(duration) - } - - if msg["type"] == "subscribe_success" { - id := msg["id"].(string) - if item, ok := c.subscriptions[id]; ok { - item.Out <- "ok" - } - } - if t := msg["type"]; t == "data" { - id := msg["id"].(string) - if item, ok := c.subscriptions[id]; ok { - item.Out <- msg["event"].(string) - } - } - } - }() - - return nil -} - -func (c *Connection) Subscribe(ctx context.Context, channel string) (chan string, error) { - out := make(chan string, 1000) - subscriptionID := id.Ascending() - c.subscriptions[subscriptionID] = SubscriptionInfo{ - Channel: channel, - Out: out, - } - err := c.subscribe(ctx, channel, subscriptionID) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *Connection) subscribe(ctx context.Context, channel string, subscriptionID string) error { - c.lock.Lock() - defer c.lock.Unlock() - auth, err := c.getAuth(ctx, map[string]interface{}{ - "channel": channel, - }) - if err != nil { - return err - } - old := c.subscriptions[subscriptionID].Out - tmp := make(chan string, 1) - defer func() { - c.subscriptions[subscriptionID] = SubscriptionInfo{ - Channel: channel, - Out: old, - } - }() - c.subscriptions[subscriptionID] = SubscriptionInfo{ - Channel: channel, - Out: tmp, - } - c.conn.WriteJSON(map[string]interface{}{ - "type": "subscribe", - "id": subscriptionID, - "channel": channel, - "authorization": auth, - }) - select { - case <-tmp: - log.Info("subscribed", "channel", channel, "id", subscriptionID) - return nil - case <-time.After(time.Second * 3): - return ErrSubscriptionFailed - } -} - -func (c *Connection) getAuth(ctx context.Context, body interface{}) (interface{}, error) { - credentials, err := c.cfg.Credentials.Retrieve(ctx) - if err != nil { - return nil, err - } - bodyJson, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader := bytes.NewReader(bodyJson) - req, err := http.NewRequest("POST", - "https://"+c.httpEndpoint+"/event", - bodyReader) - if err != nil { - return nil, err - } - req.Header.Set("accept", "application/json, text/javascript") - req.Header.Set("content-encoding", "amz-1.0") - req.Header.Set("content-type", "application/json; charset=UTF-8") - - // Compute SHA256 hash of the payload - h := sha256.New() - h.Write(bodyJson) - payloadHash := hex.EncodeToString(h.Sum(nil)) - - signer := v4.NewSigner() - err = signer.SignHTTP(ctx, - credentials, - req, - payloadHash, - "appsync", - c.cfg.Region, - time.Now(), - ) - auth := map[string]string{ - "accept": req.Header.Get("accept"), - "content-encoding": req.Header.Get("content-encoding"), - "content-type": req.Header.Get("content-type"), - "host": req.Host, - "x-amz-date": req.Header.Get("x-amz-date"), - "Authorization": req.Header.Get("Authorization"), - } - if req.Header.Get("X-Amz-Security-Token") != "" { - auth["X-Amz-Security-Token"] = req.Header.Get("X-Amz-Security-Token") - } - return auth, nil -} - -func (c *Connection) Publish(ctx context.Context, channel string, event interface{}) error { - credentials, err := c.cfg.Credentials.Retrieve(ctx) - if err != nil { - return err - } - eventJson, err := json.Marshal(event) - body, err := json.Marshal(map[string]interface{}{ - "channel": channel, - "events": []string{string(eventJson)}, - }) - if err != nil { - return err - } - req, err := http.NewRequest("POST", "https://"+c.httpEndpoint+"/event", bytes.NewReader(body)) - if err != nil { - return err - } - req.Header.Set("Content-Type", "application/json") - signer := v4.NewSigner() - h := sha256.New() - h.Write(body) - payloadHash := hex.EncodeToString(h.Sum(nil)) - err = signer.SignHTTP(ctx, credentials, req, payloadHash, "appsync", c.cfg.Region, time.Now()) - if err != nil { - return err - } - - // Use HTTP client that respects proxy settings - client := getHTTPClient() - resp, err := client.Do(req) - if err != nil { - return err - } - defer resp.Body.Close() - - if resp.StatusCode != http.StatusOK { - bodyBytes, _ := io.ReadAll(resp.Body) - return fmt.Errorf("request failed with status %d: %s", resp.StatusCode, string(bodyBytes)) - } - - return nil -} diff --git a/cmd/sst/mosaic/aws/aws.go b/cmd/sst/mosaic/aws/aws.go deleted file mode 100644 index c035d7238f..0000000000 --- a/cmd/sst/mosaic/aws/aws.go +++ /dev/null @@ -1,91 +0,0 @@ -package aws - -import ( - "context" - "fmt" - "log/slog" - "net/http" - "time" - - "github.com/sst/sst/v3/cmd/sst/mosaic/aws/appsync" - "github.com/sst/sst/v3/cmd/sst/mosaic/aws/bridge" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/project/provider" - "github.com/sst/sst/v3/pkg/server" -) - -var ErrIoTDelay = fmt.Errorf("iot not available") -var ErrAppsyncNotReady = fmt.Errorf("appsync not ready") - -func Start( - ctx context.Context, - p *project.Project, - s *server.Server, - args map[string]interface{}, -) error { - uncasted, _ := p.Provider("aws") - prov := uncasted.(*provider.AwsProvider) - config := prov.Config() - slog.Info("getting endpoint") - prefix := fmt.Sprintf("/sst/%s/%s", p.App().Name, p.App().Stage) - - rest, realtime, err := prov.ResolveAppSync(ctx) - if err != nil { - return err - } - slog.Info("found appsync", "rest", rest, "realtime", realtime) - - now := time.Now() - for { - slog.Info("checking if appsync is ready") - _, err := http.Get("https://" + rest) - if err != nil { - slog.Error("appsync not ready", "err", err) - if time.Since(now) > time.Second*10 { - return ErrAppsyncNotReady - } - select { - case <-ctx.Done(): - return nil - case <-time.After(time.Second): - continue - } - } - break - } - conn, err := appsync.Dial(ctx, config, rest, realtime) - if err != nil { - return err - } - client := bridge.NewClient(ctx, conn, "dev", prefix) - - functionsChan := make(chan bridge.Message, 1000) - tasksChan := make(chan bridge.Message, 1000) - - in := input{ - config: config, - server: s, - client: client, - project: p, - prefix: prefix, - } - - in.msg = functionsChan - go function(ctx, in) - - in.msg = tasksChan - go task(ctx, in) - - for { - select { - case <-ctx.Done(): - return nil - case msg := <-client.Read(): - if msg.Source == "dev" { - continue - } - functionsChan <- msg - tasksChan <- msg - } - } -} diff --git a/cmd/sst/mosaic/aws/bridge/bridge.go b/cmd/sst/mosaic/aws/bridge/bridge.go deleted file mode 100644 index c6abb6edb8..0000000000 --- a/cmd/sst/mosaic/aws/bridge/bridge.go +++ /dev/null @@ -1,282 +0,0 @@ -package bridge - -import ( - "context" - "encoding/base64" - "encoding/json" - "io" - "iter" - "log/slog" - - "github.com/sst/sst/v3/cmd/sst/mosaic/aws/appsync" - "github.com/sst/sst/v3/pkg/id" -) - -type Packet struct { - Type MessageType `json:"type"` - Source string `json:"source"` - ID string `json:"id"` - Index int `json:"index"` - Data string `json:"data"` - Final bool `json:"final"` -} - -type MessageType int - -const ( - MessageInit MessageType = iota - MessagePing - MessageNext - MessageResponse - MessageError - MessageReboot - MessageInitError - - MessageTaskStart - MessageTaskComplete -) - -type Message struct { - ID string - Type MessageType - Source string - Body io.Reader -} - -type Writer struct { - conn *appsync.Connection - message MessageType - source string - channel string - event string - buffer []byte - position int - index int - id string - streaming bool -} - -type InitBody struct { - FunctionID string `json:"functionID"` - Environment []string `json:"environment"` -} - -type TaskStartBody struct { - TaskID string `json:"taskID"` - Environment []string `json:"environment"` -} - -type TaskCompleteBody struct { -} - -type PingBody struct { -} - -type RebootBody struct { -} - -func newWriter(conn *appsync.Connection, source string, channel string, message MessageType) *Writer { - return &Writer{ - id: id.Ascending(), - conn: conn, - source: source, - message: message, - channel: channel, - buffer: make([]byte, BUFFER_SIZE), - position: 0, - index: 0, - } -} - -func (w *Writer) SetID(id string) { - w.id = id -} - -func (w *Writer) SetStreaming(streaming bool) { - w.streaming = streaming -} - -const BUFFER_SIZE = 1024 * 128 - -func (w *Writer) Write(p []byte) (int, error) { - total := 0 - - for total < len(p) { - space := cap(w.buffer) - w.position - toWrite := min(space, len(p)-total) - copy(w.buffer[w.position:], p[total:total+toWrite]) - w.position += toWrite - total += toWrite - if w.position == len(w.buffer) { - if err := w.Flush(false); err != nil { - return total, err - } - } - } - if w.streaming && w.position > 0 { - if err := w.Flush(false); err != nil { - return total, err - } - } - return total, nil -} - -func (w *Writer) Flush(final bool) error { - if !final && w.position == 0 { - return nil - } - encoded := base64.StdEncoding.EncodeToString(w.buffer[:w.position]) - err := w.conn.Publish(context.Background(), w.channel, Packet{ - ID: w.id, - Index: w.index, - Type: w.message, - Source: w.source, - Data: encoded, - Final: final, - }) - w.index++ - if err != nil { - return err - } - w.buffer = make([]byte, BUFFER_SIZE) - w.position = 0 - return nil -} - -func (w *Writer) Close() error { - return w.Flush(true) -} - -type Client struct { - as *appsync.Connection - prefix string - pending map[string]chan []byte - out chan Message - source string -} - -func NewClient(ctx context.Context, as *appsync.Connection, source string, prefix string) *Client { - slog.Info("subscribing to", "prefix", prefix+"/in") - sub, _ := as.Subscribe(ctx, prefix+"/in") - result := &Client{ - as: as, - source: source, - prefix: prefix, - pending: map[string]chan []byte{}, - out: make(chan Message, 1000), - } - go func() { - for packet := range sorted(ctx, sub) { - pending, ok := result.pending[packet.ID] - if !ok { - pending = make(chan []byte, 100) - result.pending[packet.ID] = pending - result.out <- Message{ - Type: packet.Type, - ID: packet.ID, - Source: packet.Source, - Body: NewChannelReader(ctx, pending), - } - } - bytes, err := base64.StdEncoding.DecodeString(packet.Data) - if err != nil { - continue - } - pending <- bytes - if packet.Final { - close(pending) - delete(result.pending, packet.ID) - } - } - }() - - return result -} - -func (c *Client) Read() <-chan Message { - return c.out -} - -func (c *Client) NewWriter(message MessageType, destination string) *Writer { - writer := newWriter(c.as, c.source, destination, message) - return writer -} - -type ChannelReader struct { - ch chan []byte - buffer []byte - err error - ctx context.Context -} - -func NewChannelReader(ctx context.Context, ch chan []byte) *ChannelReader { - return &ChannelReader{ - ch: ch, - buffer: nil, - err: nil, - ctx: ctx, - } -} - -func (r *ChannelReader) Read(p []byte) (n int, err error) { - if len(r.buffer) == 0 && r.err == nil { - select { - case chunk, ok := <-r.ch: - if !ok { - return 0, io.EOF - } - r.buffer = chunk - case <-r.ctx.Done(): - return 0, io.EOF - } - } - if len(r.buffer) > 0 { - n = copy(p, r.buffer) - r.buffer = r.buffer[n:] - return n, nil - } - - if r.err != nil { - return 0, r.err - } - return 0, io.EOF -} - -func sorted(ctx context.Context, sub chan string) iter.Seq[Packet] { - return func(yield func(Packet) bool) { - history := make(map[string]map[int]Packet) - next := map[string]int{} - for { - select { - case <-ctx.Done(): - return - case msg := <-sub: - var packet Packet - json.Unmarshal([]byte(msg), &packet) - slog.Info("got packet", "id", packet.ID, "type", packet.Type, "from", packet.Source) - unprocessed, ok := history[packet.ID] - if !ok { - unprocessed = map[int]Packet{} - history[packet.ID] = unprocessed - } - unprocessed[packet.Index] = packet - for { - index := next[packet.ID] - envelope, ok := unprocessed[index] - if !ok { - break - } - delete(unprocessed, index) - next[envelope.ID] = index + 1 - if !yield(envelope) { - return - } - if envelope.Final { - delete(history, envelope.ID) - } - } - } - - } - } -} diff --git a/cmd/sst/mosaic/aws/function.go b/cmd/sst/mosaic/aws/function.go deleted file mode 100644 index ae7406d761..0000000000 --- a/cmd/sst/mosaic/aws/function.go +++ /dev/null @@ -1,481 +0,0 @@ -package aws - -import ( - "bufio" - "bytes" - "context" - "encoding/json" - "fmt" - "io" - "log/slog" - "net/http" - "os" - "path/filepath" - "strings" - "time" - - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/sst/sst/v3/cmd/sst/mosaic/aws/bridge" - "github.com/sst/sst/v3/cmd/sst/mosaic/watcher" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/runtime" - "github.com/sst/sst/v3/pkg/server" -) - -type FunctionInvokedEvent struct { - FunctionID string - WorkerID string - RequestID string - Input []byte -} - -type FunctionResponseEvent struct { - FunctionID string - WorkerID string - RequestID string - Output []byte -} - -type FunctionErrorEvent struct { - FunctionID string - WorkerID string - RequestID string - ErrorType string `json:"errorType"` - ErrorMessage string `json:"errorMessage"` - Trace []string `json:"trace"` -} - -type FunctionBuildEvent struct { - FunctionID string - Errors []string -} - -type FunctionLogEvent struct { - FunctionID string - WorkerID string - RequestID string - Line string -} - -type input struct { - config aws.Config - project *project.Project - server *server.Server - client *bridge.Client - msg chan bridge.Message - prefix string -} - -func function(ctx context.Context, input input) { - log := slog.Default().With("service", "aws.function") - server := fmt.Sprintf("localhost:%d/lambda/", input.server.Port) - type WorkerInfo struct { - FunctionID string - WorkerID string - Worker runtime.Worker - CurrentRequestID string - Env []string - Streaming bool - } - workerShutdownChan := make(chan *WorkerInfo, 1000) - nextChan := map[string]chan io.Reader{} - workers := map[string]*WorkerInfo{} - evts := bus.Subscribe(&watcher.FileChangedEvent{}, &project.CompleteEvent{}, &runtime.BuildInput{}, &FunctionInvokedEvent{}) - go fileLogger(input.project) - - input.server.Mux.HandleFunc(`/lambda/{workerID}/2018-06-01/runtime/invocation/next`, func(w http.ResponseWriter, r *http.Request) { - log.Info("got next request", "workerID", r.PathValue("workerID")) - workerID := r.PathValue("workerID") - ch := nextChan[workerID] - select { - case <-r.Context().Done(): - log.Info("worker disconnected", "workerID", workerID) - return - case reader := <-ch: - log.Info("worker got next request", "workerID", workerID) - resp, _ := http.ReadResponse(bufio.NewReader(reader), r) - requestID := resp.Header.Get("lambda-runtime-aws-request-id") - for key, values := range resp.Header { - for _, value := range values { - w.Header().Add(key, value) - } - } - w.WriteHeader(resp.StatusCode) - - var buf bytes.Buffer - tee := io.TeeReader(resp.Body, &buf) - io.Copy(w, tee) - workerInfo, ok := workers[workerID] - if ok { - bus.Publish(&FunctionInvokedEvent{ - FunctionID: workerInfo.FunctionID, - WorkerID: workerID, - RequestID: requestID, - Input: buf.Bytes(), - }) - } - } - }) - - input.server.Mux.HandleFunc(`/lambda/{workerID}/2018-06-01/runtime/init/error`, func(w http.ResponseWriter, r *http.Request) { - workerID := r.PathValue("workerID") - log.Info("got init error", "workerID", workerID, "requestID", r.PathValue("requestID")) - writer := input.client.NewWriter(bridge.MessageInitError, input.prefix+"/"+workerID+"/in") - var buf bytes.Buffer - tee := io.TeeReader(r.Body, &buf) - io.Copy(writer, tee) - writer.Close() - w.WriteHeader(200) - info, ok := workers[workerID] - if ok { - fee := &FunctionErrorEvent{ - FunctionID: info.FunctionID, - WorkerID: info.WorkerID, - } - json.Unmarshal(buf.Bytes(), &fee) - bus.Publish(fee) - } - }) - - input.server.Mux.HandleFunc(`/lambda/{workerID}/2018-06-01/runtime/invocation/{requestID}/response`, func(w http.ResponseWriter, r *http.Request) { - workerID := r.PathValue("workerID") - requestID := r.PathValue("requestID") - log.Info("got response", "workerID", workerID, "requestID", r.PathValue("requestID")) - writer := input.client.NewWriter(bridge.MessageResponse, input.prefix+"/"+workerID+"/in") - writer.SetID(requestID) - info, ok := workers[workerID] - if ok && info.Streaming { - writer.SetStreaming(true) - io.Copy(writer, r.Body) - writer.Close() - w.WriteHeader(202) - bus.Publish(&FunctionResponseEvent{ - FunctionID: info.FunctionID, - WorkerID: workerID, - RequestID: requestID, - Output: []byte("[streaming response]"), - }) - } else { - var buf bytes.Buffer - tee := io.TeeReader(r.Body, &buf) - io.Copy(writer, tee) - writer.Close() - w.WriteHeader(202) - if ok { - bus.Publish(&FunctionResponseEvent{ - FunctionID: info.FunctionID, - WorkerID: workerID, - RequestID: requestID, - Output: buf.Bytes(), - }) - } - } - }) - - input.server.Mux.HandleFunc(`/lambda/{workerID}/2018-06-01/runtime/invocation/{requestID}/error`, func(w http.ResponseWriter, r *http.Request) { - workerID := r.PathValue("workerID") - requestID := r.PathValue("requestID") - log.Info("got error", "workerID", workerID, "requestID", r.PathValue("requestID")) - writer := input.client.NewWriter(bridge.MessageError, input.prefix+"/"+workerID+"/in") - writer.SetID(requestID) - var buf bytes.Buffer - tee := io.TeeReader(r.Body, &buf) - io.Copy(writer, tee) - writer.Close() - w.WriteHeader(202) - info, ok := workers[workerID] - if ok { - fee := &FunctionErrorEvent{ - FunctionID: info.FunctionID, - WorkerID: info.WorkerID, - RequestID: requestID, - } - json.Unmarshal(buf.Bytes(), &fee) - bus.Publish(fee) - } - }) - - workerEnv := map[string][]string{} - builds := map[string]*runtime.BuildOutput{} - targets := map[string]*runtime.BuildInput{} - - getBuildOutput := func(functionID string) *runtime.BuildOutput { - build := builds[functionID] - if build != nil { - return build - } - target, _ := targets[functionID] - build, err := input.project.Runtime.Build(ctx, target) - if err == nil { - bus.Publish(&FunctionBuildEvent{ - FunctionID: functionID, - Errors: build.Errors, - }) - } else { - bus.Publish(&FunctionBuildEvent{ - FunctionID: functionID, - Errors: []string{err.Error()}, - }) - } - if err != nil || len(build.Errors) > 0 { - delete(builds, functionID) - return nil - } - builds[functionID] = build - return build - } - - startWorker := func(functionID string, workerID string) bool { - build := getBuildOutput(functionID) - if build == nil { - return false - } - target, ok := targets[functionID] - if !ok { - return false - } - worker, err := input.project.Runtime.Run(ctx, &runtime.RunInput{ - CfgPath: input.project.PathConfig(), - Runtime: target.Runtime, - Server: server + workerID, - WorkerID: workerID, - FunctionID: functionID, - Build: build, - Env: workerEnv[workerID], - }) - if err != nil { - log.Error("failed to run worker", "error", err) - return false - } - streaming := false - for _, e := range workerEnv[workerID] { - if e == "SST_FUNCTION_STREAMING=true" { - streaming = true - break - } - } - info := &WorkerInfo{ - FunctionID: functionID, - Worker: worker, - WorkerID: workerID, - Streaming: streaming, - } - go func() { - logs := worker.Logs() - scanner := bufio.NewScanner(logs) - for scanner.Scan() { - line := scanner.Text() - bus.Publish(&FunctionLogEvent{ - FunctionID: functionID, - WorkerID: workerID, - RequestID: info.CurrentRequestID, - Line: line, - }) - } - workerShutdownChan <- info - }() - workers[workerID] = info - - return true - } - - restartOrDeferWorker := func(workerID string, info *WorkerInfo) { - target, ok := targets[info.FunctionID] - if !ok { - return - } - if input.project.Runtime.ShouldRunEagerly(target.Runtime) { - startWorker(info.FunctionID, workerID) - } else { - log.Info("lazy startup: deferring worker restart until invoked", "workerID", workerID, "functionID", info.FunctionID) - delete(workers, workerID) - } - } - - for { - select { - case <-ctx.Done(): - return - case msg := <-input.msg: - switch msg.Type { - case bridge.MessageInit: - ch, ok := nextChan[msg.Source] - if !ok { - ch = make(chan io.Reader, 100) - nextChan[msg.Source] = ch - } - init := bridge.InitBody{} - json.NewDecoder(msg.Body).Decode(&init) - if _, ok := targets[init.FunctionID]; !ok { - log.Error("function not found", "functionID", init.FunctionID) - continue - } - workerID := msg.Source - if _, ok := workers[workerID]; ok { - log.Error("got reboot but worker already exists", "workerID", workerID, "functionID", init.FunctionID) - continue - } - log.Info("worker init", "workerID", msg.Source, "functionID", init.FunctionID) - workerEnv[workerID] = init.Environment - if ok := startWorker(init.FunctionID, workerID); !ok { - result, err := http.Post("http://"+server+workerID+"/runtime/init/error", "application/json", strings.NewReader(`{"errorMessage":"Function failed to build"}`)) - if err != nil { - continue - } - defer result.Body.Close() - body, err := io.ReadAll(result.Body) - if err != nil { - continue - } - log.Info("error", "body", string(body), "status", result.StatusCode) - - if result.StatusCode != 202 { - result, err := http.Get("http://" + server + workerID + "/runtime/invocation/next") - if err != nil { - continue - } - requestID := result.Header.Get("lambda-runtime-aws-request-id") - result, err = http.Post("http://"+server+workerID+"/runtime/invocation/"+requestID+"/error", "application/json", strings.NewReader(`{"errorMessage":"Function failed to build"}`)) - if err != nil { - continue - } - defer result.Body.Close() - body, err := io.ReadAll(result.Body) - if err != nil { - continue - } - log.Info("error", "body", string(body), "status", result.StatusCode) - } - } - case bridge.MessageNext: - writer := input.client.NewWriter(bridge.MessagePing, input.prefix+"/"+msg.Source+"/in") - json.NewEncoder(writer).Encode(bridge.PingBody{}) - writer.Close() - ch, ok := nextChan[msg.Source] - if !ok { - ch = make(chan io.Reader, 100) - nextChan[msg.Source] = ch - } - _, ok = workers[msg.Source] - if !ok { - log.Info("asking for reboot", "workerID", msg.Source) - writer := input.client.NewWriter(bridge.MessageReboot, input.prefix+"/"+msg.Source+"/in") - json.NewEncoder(writer).Encode(bridge.RebootBody{}) - writer.Close() - } - ch <- msg.Body - continue - } - - case info := <-workerShutdownChan: - log.Info("worker died", "workerID", info.WorkerID) - existing, ok := workers[info.WorkerID] - if !ok { - continue - } - // only delete if a new worker hasn't already been started - if existing == info { - log.Info("deleting worker", "workerID", info.WorkerID) - delete(workers, info.WorkerID) - delete(nextChan, info.WorkerID) - } - break - case unknown := <-evts: - switch evt := unknown.(type) { - case *FunctionInvokedEvent: - info, ok := workers[evt.WorkerID] - if !ok { - continue - } - info.CurrentRequestID = evt.RequestID - case *project.CompleteEvent: - if evt.Old { - continue - } - for _, info := range workers { - info.Worker.Stop() - } - builds = map[string]*runtime.BuildOutput{} - for workerID, info := range workers { - restartOrDeferWorker(workerID, info) - } - case *runtime.BuildInput: - targets[evt.FunctionID] = evt - case *watcher.FileChangedEvent: - log.Info("checking if code needs to be rebuilt", "file", evt.Path) - toBuild := map[string]bool{} - - for functionID := range builds { - target, ok := targets[functionID] - if !ok { - continue - } - if input.project.Runtime.ShouldRebuild(target.Runtime, target.FunctionID, evt.Path) { - for _, worker := range workers { - if worker.FunctionID == functionID { - log.Info("stopping", "workerID", worker.WorkerID, "functionID", worker.FunctionID) - worker.Worker.Stop() - } - } - delete(builds, functionID) - toBuild[functionID] = true - } - } - - for functionID := range toBuild { - output := getBuildOutput(functionID) - if output == nil { - delete(toBuild, functionID) - } - } - - for workerID, info := range workers { - if toBuild[info.FunctionID] { - restartOrDeferWorker(workerID, info) - } - } - break - } - } - } -} - -func fileLogger(p *project.Project) { - evts := bus.Subscribe(&FunctionLogEvent{}, &FunctionInvokedEvent{}, &FunctionResponseEvent{}, &FunctionErrorEvent{}, &FunctionBuildEvent{}) - logs := map[string]*os.File{} - - getLog := func(functionID string, requestID string) *os.File { - log, ok := logs[requestID] - if !ok { - path := p.PathLog(fmt.Sprintf("lambda/%s/%d-%s", functionID, time.Now().Unix(), requestID)) - os.MkdirAll(filepath.Dir(path), 0755) - log, _ = os.Create(path) - logs[requestID] = log - } - return log - } - - for range evts { - for evt := range evts { - switch evt := evt.(type) { - case *FunctionInvokedEvent: - log := getLog(evt.FunctionID, evt.RequestID) - log.WriteString("invocation " + evt.RequestID + "\n") - log.WriteString(string(evt.Input)) - log.WriteString("\n") - case *FunctionLogEvent: - getLog(evt.FunctionID, evt.RequestID).WriteString(evt.Line + "\n") - case *FunctionResponseEvent: - log := getLog(evt.FunctionID, evt.RequestID) - log.WriteString("response " + evt.RequestID + "\n") - log.WriteString(string(evt.Output)) - log.WriteString("\n") - delete(logs, evt.RequestID) - case *FunctionErrorEvent: - getLog(evt.FunctionID, evt.RequestID).WriteString(evt.ErrorType + ": " + evt.ErrorMessage + "\n") - delete(logs, evt.RequestID) - } - } - } -} diff --git a/cmd/sst/mosaic/aws/task.go b/cmd/sst/mosaic/aws/task.go deleted file mode 100644 index 53a21cbd3c..0000000000 --- a/cmd/sst/mosaic/aws/task.go +++ /dev/null @@ -1,206 +0,0 @@ -package aws - -import ( - "bufio" - "context" - "encoding/json" - "log/slog" - "os" - "time" - - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/ecs" - "github.com/aws/aws-sdk-go-v2/service/ecs/types" - "github.com/kballard/go-shellquote" - "github.com/sst/sst/v3/cmd/sst/mosaic/aws/bridge" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/process" - "github.com/sst/sst/v3/pkg/project" -) - -type TaskProvisionEvent struct { - Name string -} - -type TaskStartEvent struct { - TaskID string - WorkerID string - Command string -} - -type TaskLogEvent struct { - TaskID string - WorkerID string - Line string -} - -type TaskCompleteEvent struct { - TaskID string - WorkerID string -} - -type TaskMissingCommandEvent struct { - Name string -} - -func task(ctx context.Context, input input) { - log := slog.Default().With("service", "aws.task") - log.Info("starting") - defer log.Info("done") - events := bus.Subscribe(&project.CompleteEvent{}) - var complete *project.CompleteEvent - - ticker := time.NewTicker(time.Second * 3) - defer ticker.Stop() - - ecsClient := ecs.NewFromConfig(input.config) - trackedTasks := map[string]bool{} - - for { - select { - case <-ticker.C: - if complete == nil || len(complete.Tasks) == 0 { - continue - } - for _, item := range complete.Resources { - if item.URN.Type() != "aws:ecs/cluster:Cluster" { - continue - } - name := item.Outputs["name"] - tasks, err := ecsClient.ListTasks(ctx, &ecs.ListTasksInput{ - Cluster: aws.String(name.(string)), - DesiredStatus: types.DesiredStatusRunning, - }) - if err != nil { - continue - } - dirty := []string{} - for _, task := range tasks.TaskArns { - if _, ok := trackedTasks[task]; !ok { - dirty = append(dirty, task) - trackedTasks[task] = true - continue - } - } - if len(dirty) == 0 { - continue - } - log.Info("describing tasks", "tasks", dirty) - described, err := ecsClient.DescribeTasks(ctx, &ecs.DescribeTasksInput{ - Tasks: dirty, - Cluster: aws.String(name.(string)), - }) - if err != nil { - continue - } - for _, item := range described.Tasks { - bus.Publish(&TaskProvisionEvent{ - Name: *item.Containers[0].Name, - }) - log.Info("task status", "status", *item.LastStatus, "desired", *item.LastStatus, "tags", item.Tags) - if err != nil { - continue - } - } - } - break - - case <-ctx.Done(): - return - - case msg := <-input.msg: - if complete == nil { - continue - } - switch msg.Type { - case bridge.MessageTaskStart: - log.Info("starting task", "task", task) - body := bridge.TaskStartBody{} - json.NewDecoder(msg.Body).Decode(&body) - task, ok := complete.Tasks[body.TaskID] - if !ok { - continue - } - if task.Command == nil { - bus.Publish(&TaskMissingCommandEvent{ - Name: task.Name, - }) - continue - } - fields, err := shellquote.Split(*task.Command) - if err != nil { - log.Error("failed to parse command", "err", err) - continue - } - cmd := process.Command(fields[0], fields[1:]...) - cmd.Dir = task.Directory - cmd.Env = append(os.Environ(), body.Environment...) - stdout, _ := cmd.StdoutPipe() - stderr, _ := cmd.StderrPipe() - go func() { - scanner := bufio.NewScanner(stdout) - for scanner.Scan() { - line := scanner.Text() - bus.Publish(&TaskLogEvent{ - TaskID: body.TaskID, - WorkerID: msg.Source, - Line: line, - }) - } - }() - go func() { - scanner := bufio.NewScanner(stderr) - for scanner.Scan() { - line := scanner.Text() - bus.Publish(&TaskLogEvent{ - TaskID: body.TaskID, - WorkerID: msg.Source, - Line: line, - }) - } - }() - go func() { - done := make(chan struct{}) - cmd.Start() - bus.Publish(&TaskStartEvent{ - TaskID: body.TaskID, - WorkerID: msg.Source, - Command: cmd.String(), - }) - go func() { - cmd.Wait() - done <- struct{}{} - }() - for { - writer := input.client.NewWriter(bridge.MessagePing, input.prefix+"/"+msg.Source+"/in") - json.NewEncoder(writer).Encode(bridge.PingBody{}) - writer.Close() - select { - case <-done: - writer := input.client.NewWriter(bridge.MessageTaskComplete, input.prefix+"/"+msg.Source+"/in") - json.NewEncoder(writer).Encode(bridge.TaskCompleteBody{}) - writer.Close() - bus.Publish(&TaskCompleteEvent{ - TaskID: body.TaskID, - WorkerID: msg.Source, - }) - return - case <-ctx.Done(): - return - case <-time.After(time.Second * 5): - continue - } - } - }() - } - break - - case unknown := <-events: - switch evt := unknown.(type) { - case *project.CompleteEvent: - complete = evt - } - break - } - } -} diff --git a/cmd/sst/mosaic/cloudflare/cloudflare.go b/cmd/sst/mosaic/cloudflare/cloudflare.go deleted file mode 100644 index f67c1f8054..0000000000 --- a/cmd/sst/mosaic/cloudflare/cloudflare.go +++ /dev/null @@ -1,158 +0,0 @@ -package cloudflare - -import ( - "context" - "encoding/json" - "log/slog" - "net/http" - "os" - "path/filepath" - - "github.com/cloudflare/cloudflare-go" - "github.com/gorilla/websocket" - "github.com/sst/sst/v3/cmd/sst/mosaic/watcher" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/project/provider" - "github.com/sst/sst/v3/pkg/runtime" - "github.com/sst/sst/v3/pkg/runtime/worker" -) - -type WorkerBuildEvent struct { - WorkerID string - Errors []string -} - -type WorkerUpdatedEvent struct { - WorkerID string -} - -type WorkerInvokedEvent struct { - WorkerID string - TailEvent *TailEvent -} - -func Start(ctx context.Context, proj *project.Project, args map[string]interface{}) error { - prov, ok := proj.Provider("cloudflare") - if !ok { - return util.NewReadableError(nil, "Cloudflare provider not found in project configuration") - } - api := prov.(*provider.CloudflareProvider).Api() - evts := bus.Subscribe(&project.CompleteEvent{}, &watcher.FileChangedEvent{}, &runtime.BuildInput{}) - builds := map[string]*runtime.BuildOutput{} - targets := map[string]*runtime.BuildInput{} - type tailRef struct { - ID string - ScriptName string - Account *cloudflare.ResourceContainer - } - tails := map[string]tailRef{} - -exit: - for { - select { - case <-ctx.Done(): - break exit - case unknown := <-evts: - switch evt := unknown.(type) { - case *runtime.BuildInput: - target := evt - if target.Runtime != "worker" { - continue - } - targets[target.FunctionID] = target - var properties worker.Properties - json.Unmarshal(target.Properties, &properties) - account := cloudflare.AccountIdentifier(properties.AccountID) - if _, ok := tails[target.FunctionID]; !ok { - slog.Info("cloudflare tail creating", "functionID", target.FunctionID) - tail, err := api.StartWorkersTail(ctx, account, properties.ScriptName) - if err != nil { - slog.Error("error creating tail", "error", err) - continue - } - tails[target.FunctionID] = tailRef{ - ID: tail.ID, - ScriptName: properties.ScriptName, - Account: account, - } - conn, _, err := websocket.DefaultDialer.DialContext(ctx, tail.URL, http.Header{ - "Sec-WebSocket-Protocol": []string{"trace-v1"}, - }) - if err != nil { - slog.Info("error dialing websocket", "error", err) - continue - } - go func(functionID string) { - defer delete(tails, functionID) - for { - msg := &TailEvent{} - err := conn.ReadJSON(msg) - if err != nil { - slog.Info("error reading websocket", "error", err) - return - } - bus.Publish(&WorkerInvokedEvent{ - WorkerID: functionID, - TailEvent: msg, - }) - } - }(target.FunctionID) - } - if _, ok := builds[target.FunctionID]; ok { - continue - } - output, err := proj.Runtime.Build(ctx, target) - if err != nil { - continue - } - builds[target.FunctionID] = output - case *watcher.FileChangedEvent: - for workerID, target := range targets { - if proj.Runtime.ShouldRebuild(target.Runtime, workerID, evt.Path) { - output, err := proj.Runtime.Build(ctx, target) - if err != nil { - continue - } - bus.Publish(&WorkerBuildEvent{ - WorkerID: target.FunctionID, - Errors: output.Errors, - }) - builds[target.FunctionID] = output - var properties worker.Properties - json.Unmarshal(target.Properties, &properties) - account := cloudflare.AccountIdentifier(properties.AccountID) - - content, err := os.ReadFile(filepath.Join(output.Out, output.Handler)) - if err != nil { - slog.Info("error reading file", "error", err, "out", filepath.Join(output.Out, output.Handler)) - continue - } - slog.Info("updating worker script", "functionID", target.FunctionID) - _, err = api.UpdateWorkersScriptContent(ctx, account, cloudflare.UpdateWorkersScriptContentParams{ - ScriptName: properties.ScriptName, - Script: string(content), - Module: true, - }) - if err != nil { - slog.Info("error updating worker script", "error", err) - } - slog.Info("done worker script", "functionID", target.FunctionID) - bus.Publish(&WorkerUpdatedEvent{ - WorkerID: target.FunctionID, - }) - - } - } - break - } - } - } - - for _, tail := range tails { - api.DeleteWorkersTail(ctx, tail.Account, tail.ScriptName, tail.ID) - } - - return nil -} diff --git a/cmd/sst/mosaic/cloudflare/tail.go b/cmd/sst/mosaic/cloudflare/tail.go deleted file mode 100644 index bb26e86fd1..0000000000 --- a/cmd/sst/mosaic/cloudflare/tail.go +++ /dev/null @@ -1,99 +0,0 @@ -package cloudflare - -type TailEvent struct { - DiagnosticsChannelEvents []any `json:"diagnosticsChannelEvents"` - Event struct { - Request struct { - Cf struct { - AsOrganization string `json:"asOrganization"` - Asn int `json:"asn"` - City string `json:"city"` - ClientAcceptEncoding string `json:"clientAcceptEncoding"` - Colo string `json:"colo"` - Continent string `json:"continent"` - Country string `json:"country"` - EdgeRequestKeepAliveStatus int `json:"edgeRequestKeepAliveStatus"` - HTTPProtocol string `json:"httpProtocol"` - Latitude string `json:"latitude"` - Longitude string `json:"longitude"` - MetroCode string `json:"metroCode"` - PostalCode string `json:"postalCode"` - Region string `json:"region"` - RegionCode string `json:"regionCode"` - RequestPriority string `json:"requestPriority"` - Timezone string `json:"timezone"` - TLSCipher string `json:"tlsCipher"` - TLSClientAuth struct { - CertFingerprintSHA1 string `json:"certFingerprintSHA1"` - CertFingerprintSHA256 string `json:"certFingerprintSHA256"` - CertIssuerDN string `json:"certIssuerDN"` - CertIssuerDNLegacy string `json:"certIssuerDNLegacy"` - CertIssuerDNRFC2253 string `json:"certIssuerDNRFC2253"` - CertIssuerSKI string `json:"certIssuerSKI"` - CertIssuerSerial string `json:"certIssuerSerial"` - CertNotAfter string `json:"certNotAfter"` - CertNotBefore string `json:"certNotBefore"` - CertPresented string `json:"certPresented"` - CertRevoked string `json:"certRevoked"` - CertSKI string `json:"certSKI"` - CertSerial string `json:"certSerial"` - CertSubjectDN string `json:"certSubjectDN"` - CertSubjectDNLegacy string `json:"certSubjectDNLegacy"` - CertSubjectDNRFC2253 string `json:"certSubjectDNRFC2253"` - CertVerified string `json:"certVerified"` - } `json:"tlsClientAuth"` - TLSClientExtensionsSha1 string `json:"tlsClientExtensionsSha1"` - TLSClientHelloLength string `json:"tlsClientHelloLength"` - TLSClientRandom string `json:"tlsClientRandom"` - TLSExportedAuthenticator struct { - ClientFinished string `json:"clientFinished"` - ClientHandshake string `json:"clientHandshake"` - ServerFinished string `json:"serverFinished"` - ServerHandshake string `json:"serverHandshake"` - } `json:"tlsExportedAuthenticator"` - TLSVersion string `json:"tlsVersion"` - VerifiedBotCategory string `json:"verifiedBotCategory"` - } `json:"cf"` - Headers struct { - Accept string `json:"accept"` - AcceptEncoding string `json:"accept-encoding"` - AcceptLanguage string `json:"accept-language"` - CfConnectingIP string `json:"cf-connecting-ip"` - CfIpcountry string `json:"cf-ipcountry"` - CfRay string `json:"cf-ray"` - CfVisitor string `json:"cf-visitor"` - Connection string `json:"connection"` - Host string `json:"host"` - Priority string `json:"priority"` - SecChUa string `json:"sec-ch-ua"` - SecChUaMobile string `json:"sec-ch-ua-mobile"` - SecChUaPlatform string `json:"sec-ch-ua-platform"` - SecFetchDest string `json:"sec-fetch-dest"` - SecFetchMode string `json:"sec-fetch-mode"` - SecFetchSite string `json:"sec-fetch-site"` - SecFetchUser string `json:"sec-fetch-user"` - UpgradeInsecureRequests string `json:"upgrade-insecure-requests"` - UserAgent string `json:"user-agent"` - XForwardedProto string `json:"x-forwarded-proto"` - XRealIP string `json:"x-real-ip"` - } `json:"headers"` - Method string `json:"method"` - URL string `json:"url"` - } `json:"request"` - Response struct { - Status int `json:"status"` - } `json:"response"` - } `json:"event"` - EventTimestamp int64 `json:"eventTimestamp"` - Exceptions []any `json:"exceptions"` - Logs []struct { - Level string `json:"level"` - Message []interface{} `json:"message"` - Timestamp int64 `json:"timestamp"` - } `json:"logs"` - Outcome string `json:"outcome"` - ScriptName string `json:"scriptName"` - ScriptVersion struct { - ID string `json:"id"` - } `json:"scriptVersion"` -} diff --git a/cmd/sst/mosaic/deployer/deployer.go b/cmd/sst/mosaic/deployer/deployer.go deleted file mode 100644 index ff507c0142..0000000000 --- a/cmd/sst/mosaic/deployer/deployer.go +++ /dev/null @@ -1,93 +0,0 @@ -package deployer - -import ( - "context" - "log/slog" - "reflect" - - "github.com/sst/sst/v3/cmd/sst/mosaic/errors" - "github.com/sst/sst/v3/cmd/sst/mosaic/watcher" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/server" -) - -type DeployRequestedEvent struct{} -type DeployFailedEvent struct { - Error string -} - -func Start(ctx context.Context, p *project.Project, server *server.Server, policyPath string) error { - log := slog.Default().With("service", "deployer") - log.Info("starting") - defer log.Info("done") - watchedFiles := make(map[string]bool) - events := bus.Subscribe(ctx, &watcher.FileChangedEvent{}, &DeployRequestedEvent{}, &project.BuildSuccessEvent{}) - lastBuildHash := "" - for { - log.Info("waiting for trigger") - select { - case <-ctx.Done(): - return nil - case evt := <-events: - switch evt := evt.(type) { - case *project.BuildSuccessEvent: - lastBuildHash = evt.Hash - log.Info("build hash", "hash", lastBuildHash) - for _, file := range evt.Files { - watchedFiles[file] = true - } - continue - case *watcher.FileChangedEvent, *DeployRequestedEvent: - if evt, ok := evt.(*watcher.FileChangedEvent); !ok || watchedFiles[evt.Path] { - log.Info("deploying") - err := p.Run(ctx, &project.StackInput{ - Command: "deploy", - Dev: true, - ServerPort: server.Port, - SkipHash: lastBuildHash, - PolicyPath: policyPath, - }) - if err != nil { - log.Error("stack deploy error", "error", err) - transformed := errors.Transform(err) - if _, ok := transformed.(*util.ReadableError); ok && transformed.Error() != "" { - bus.Publish(&DeployFailedEvent{Error: transformed.Error()}) - } - } - } - } - continue - } - } -} - -func publishFields(v interface{}) { - val := reflect.ValueOf(v) - - if val.Kind() == reflect.Ptr { - val = val.Elem() - } - - if val.Kind() != reflect.Struct { - bus.Publish(v) - return - } - - for i := 0; i < val.NumField(); i++ { - field := val.Field(i) - switch field.Kind() { - case reflect.Struct: - publishFields(field.Interface()) - break - case reflect.Ptr, reflect.Interface, reflect.Slice, reflect.Map, reflect.Chan, reflect.Func: - if !field.IsNil() { - bus.Publish(field.Interface()) - } - break - default: - // bus.Publish(field.Interface()) - } - } -} diff --git a/cmd/sst/mosaic/dev/dev.go b/cmd/sst/mosaic/dev/dev.go deleted file mode 100644 index 5b2b419392..0000000000 --- a/cmd/sst/mosaic/dev/dev.go +++ /dev/null @@ -1,238 +0,0 @@ -package dev - -import ( - "context" - "encoding/json" - "log/slog" - "net/http" - "os" - "path/filepath" - "reflect" - - "github.com/sst/sst/v3/cmd/sst/mosaic/deployer" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/server" - "golang.org/x/sync/errgroup" -) - -type Message struct { - Type string `json:"type"` - Event json.RawMessage `json:"event"` -} - -func Start(ctx context.Context, p *project.Project, server *server.Server) error { - var complete *project.CompleteEvent - var wg errgroup.Group - - log := slog.Default().With("service", "dev") - log.Info("starting") - defer log.Info("done") - - wg.Go(func() error { - evts := bus.Subscribe(&project.CompleteEvent{}) - for { - select { - case <-ctx.Done(): - return nil - case evt := <-evts: - complete = evt.(*project.CompleteEvent) - } - } - }) - - server.Mux.HandleFunc("/stream", func(w http.ResponseWriter, r *http.Request) { - w.Header().Add("content-type", "application/x-ndjson") - w.WriteHeader(http.StatusOK) - log.Info("subscribed", "addr", r.RemoteAddr) - flusher, _ := w.(http.Flusher) - flusher.Flush() - ctx := r.Context() - events := bus.SubscribeAll() - defer bus.Unsubscribe(events) - if complete != nil { - go func() { - events <- complete - }() - } - for { - select { - case <-ctx.Done(): - return - case event := <-events: - t := reflect.TypeOf(event) - if t.Kind() == reflect.Ptr { - t = t.Elem() - } - bytes, _ := json.Marshal(event) - data, _ := json.Marshal(&Message{ - Type: t.String(), - Event: json.RawMessage(bytes), - }) - w.Write(data) - flusher.Flush() - } - } - }) - - server.Mux.HandleFunc(("/api/deploy"), func(w http.ResponseWriter, r *http.Request) { - log.Info("deploy requested") - bus.Publish(&deployer.DeployRequestedEvent{}) - }) - - server.Mux.HandleFunc("/api/env", func(w http.ResponseWriter, r *http.Request) { - directory := r.URL.Query().Get("directory") - name := r.URL.Query().Get("name") - resolved := complete - latest, err := p.GetCompleted(ctx) - if err == nil && (resolved == nil || resolved.Old) { - resolved = latest - } - if resolved == nil { - http.Error(w, "dev state not ready", http.StatusServiceUnavailable) - return - } - cwd, _ := os.Getwd() - for _, d := range resolved.Devs { - full := filepath.Join(cwd, d.Directory) - log.Info("matching dev", "full", full, "directory", directory) - if (directory != "" && full == directory) || (name != "" && d.Name == name) { - env, err := p.EnvFor(ctx, resolved, d.Name) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - body, err := json.Marshal(map[string]interface{}{ - "env": env, - "command": d.Command, - }) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - w.Write(body) - return - } - } - log.Info("dev not found", "directory", directory) - http.Error(w, "dev not found", http.StatusNotFound) - return - }) - - server.Mux.HandleFunc("/api/completed", func(w http.ResponseWriter, r *http.Request) { - w.Header().Add("content-type", "application/json") - w.WriteHeader(http.StatusOK) - json.NewEncoder(w).Encode(complete) - return - }) - - return wg.Wait() -} - -func Stream(ctx context.Context, url string, types ...interface{}) (chan any, error) { - out := make(chan any) - req, err := http.NewRequestWithContext(ctx, "GET", url+"/stream", nil) - if err != nil { - return nil, err - } - - resp, err := http.DefaultClient.Do(req) - if err != nil { - return nil, err - } - decoder := json.NewDecoder(resp.Body) - - registry := map[string]reflect.Type{} - for _, v := range types { - t := reflect.TypeOf(v) - if t.Kind() == reflect.Ptr { - t = t.Elem() - } - name := t.String() - registry[name] = t - } - - go func() { - defer close(out) - defer resp.Body.Close() - for { - select { - case <-ctx.Done(): - return - default: - var msg Message - err := decoder.Decode(&msg) - if err != nil { - return - } - prototype, ok := registry[msg.Type] - if !ok { - continue - } - target := reflect.New(prototype).Interface() - err = json.Unmarshal(msg.Event, target) - if err != nil { - continue - } - out <- target - } - } - }() - - return out, nil -} - -type EnvResponse struct { - Env map[string]string `json:"env"` - Command string `json:"command"` -} - -func Env(ctx context.Context, query string, url string) (*EnvResponse, error) { - req, err := http.NewRequestWithContext(ctx, "GET", url+"/api/env?"+query, nil) - if err != nil { - return nil, err - } - resp, err := http.DefaultClient.Do(req) - if err != nil { - return nil, err - } - defer resp.Body.Close() - var result EnvResponse - err = json.NewDecoder(resp.Body).Decode(&result) - if err != nil { - return nil, err - } - return &result, nil -} - -func Deploy(ctx context.Context, url string) error { - req, err := http.NewRequestWithContext(ctx, "POST", url+"/api/deploy", nil) - if err != nil { - return err - } - _, err = http.DefaultClient.Do(req) - if err != nil { - return err - } - return nil -} - -func Completed(ctx context.Context, url string) (*project.CompleteEvent, error) { - req, err := http.NewRequestWithContext(ctx, "GET", url+"/api/completed", nil) - if err != nil { - return nil, err - } - resp, err := http.DefaultClient.Do(req) - if err != nil { - return nil, err - } - defer resp.Body.Close() - var result project.CompleteEvent - err = json.NewDecoder(resp.Body).Decode(&result) - if err != nil { - return nil, err - } - return &result, nil -} diff --git a/cmd/sst/mosaic/errors/errors.go b/cmd/sst/mosaic/errors/errors.go deleted file mode 100644 index 635b1081f1..0000000000 --- a/cmd/sst/mosaic/errors/errors.go +++ /dev/null @@ -1,109 +0,0 @@ -package errors - -import ( - "errors" - "fmt" - "strings" - - "github.com/sst/sst/v3/cmd/sst/mosaic/aws" - "github.com/sst/sst/v3/cmd/sst/mosaic/aws/appsync" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/js" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/project/provider" - "github.com/sst/sst/v3/pkg/server" -) - -type ErrorTransformer = func(err error) (bool, error) - -var transformers = []ErrorTransformer{ - exact(appsync.ErrSubscriptionFailed, "Failed to subscribe to appsync websocket endpoint which powers live lambda. Check to see if you have proper appsync permissions."), - exact(project.ErrInvalidStageName, "The stage name is invalid. It must start with a letter and can only contain alphanumeric characters and hyphens."), - exact(project.ErrInvalidAppName, "The app name is invalid. It must start with a letter and can only contain alphanumeric characters and hyphens."), - exact(project.ErrAppNameChanged, "The app name has changed.\n\nIf you want to rename the app, make sure to run `sst remove` to remove the old app first. Alternatively, remove the \".sst\" folder and try again.\n"), - exact(project.ErrV2Config, "You are using sst v3 and this looks like an sst v2 config"), - exact(project.ErrStageNotFound, "Stage not found"), - exact(project.ErrPassphraseInvalid, "The passphrase for this app / stage is missing or invalid"), - exact(aws.ErrIoTDelay, "This aws account has not had iot initialized in it before which sst depends on. It may take a few minutes before it is ready."), - exact(project.ErrStackRunFailed, ""), - exact(project.ErrPolicyViolation, ""), - exact(project.ErrPolicyConfigError, ""), - exact(provider.ErrLockExists, ""), - exact(project.ErrVersionInvalid, "The version range defined in the config is invalid"), - exact(provider.ErrCloudflareMissingAccount, "The Cloudflare Account ID was not able to be determined from this token. Make sure it has permissions to fetch account information or you can set the CLOUDFLARE_DEFAULT_ACCOUNT_ID environment variable to the account id you want to use."), - exact(server.ErrServerNotFound, "Could not find an `sst dev` session to connect to. Since you are running a command outside of the multiplexer be sure to start `sst dev` first."), - exact(provider.ErrBucketMissing, "The state bucket is missing, it may have been accidentally deleted. Go to https://console.aws.amazon.com/systems-manager/parameters/%252Fsst%252Fbootstrap/description?tab=Table and check if the state bucket mentioned there exists. If it doesn't you can recreate it or delete the `/sst/bootstrap` key to force recreation."), - exact(project.ErrProtectedStage, "Cannot remove protected stage. To remove a protected stage edit your sst.config.ts and remove the `protect` property."), - exact(project.ErrProtectedDevStage, "Cannot run `sst dev` on a protected stage."), - exact(provider.ErrLockNotFound, "This app / stage is not locked"), - exact(aws.ErrAppsyncNotReady, "SST creates an appsync event api to power live lambda. After 10 seconds of waiting this cli could not connect to it."), - exact(js.ErrTopLevelImport, "Your sst.config.ts has top level imports - this is not allowed. Move imports inside the function they are used and do a dynamic import: `const mod = await import(\"./mod\")`"), - match(func(err *project.ErrBuildFailed) string { - result := "Failed to build sst.config.ts" - for _, msg := range err.Errors { - result += "\n - " - if msg.Location != nil { - result += msg.Location.File + ":" + fmt.Sprint(msg.Location.Line) + ":" + fmt.Sprint(msg.Location.Column) + " " - } - result += msg.Text - } - return result - }), - match(func(err *project.ErrProviderVersionTooLow) string { - return fmt.Sprintf("You specified version %s of the \"%s\" provider. SST needs %s or higher.", err.Version, err.Name, err.Needed) - }), - match(func(err *project.ErrVersionMismatch) string { - return fmt.Sprintf("You are using v%s which does not match v%s in your \"sst.config.ts\".", err.Needed, err.Received) - }), - func(err error) (bool, error) { - msg := err.Error() - if !strings.HasPrefix(msg, "aws:") { - return false, nil - } - if strings.Contains(msg, "cached SSO token is expired") { - return true, util.NewHintedError(err, "It looks like you are using AWS SSO but your credentials have expired. Try running `aws sso login` to refresh your credentials.") - } - if strings.Contains(msg, "no EC2 IMDS role found") { - return true, util.NewHintedError(err, "AWS credentials are not configured. Try configuring your profile in `~/.aws/config` and setting the `AWS_PROFILE` environment variable or specifying `providers.aws.profile` in your sst.config.ts") - } - return false, nil - }, -} - -func Transform(err error) error { - for _, t := range transformers { - if ok, err := t(err); ok { - return err - } - } - return err -} - -func match[T error](transformer func(T) string) ErrorTransformer { - return func(err error) (bool, error) { - var match T - if errors.As(err, &match) { - str := transformer(match) - return true, util.NewReadableError(err, str) - } - return false, nil - } -} - -func exact(compare error, msg string) ErrorTransformer { - return func(err error) (bool, error) { - if errors.Is(err, compare) { - return true, util.NewReadableError(err, msg) - } - return false, nil - } -} - -func passthrough(compare error) ErrorTransformer { - return func(err error) (bool, error) { - if errors.Is(err, compare) { - return true, util.NewReadableError(err, err.Error()) - } - return false, nil - } -} diff --git a/cmd/sst/mosaic/monoplexer/monoplexer.go b/cmd/sst/mosaic/monoplexer/monoplexer.go deleted file mode 100644 index 702ba84f7a..0000000000 --- a/cmd/sst/mosaic/monoplexer/monoplexer.go +++ /dev/null @@ -1,136 +0,0 @@ -package monoplexer - -import ( - "bufio" - "context" - "fmt" - "io" - "os" - "os/exec" - - "github.com/sst/sst/v3/pkg/process" -) - -type Monoplexer struct { - processes map[string]*Process - lines chan Line -} - -type Line struct { - process string - line string -} - -type Process struct { - name string - title string - command []string - cmd *exec.Cmd - dir string - env []string - started bool -} - -func (p *Process) IsDifferent(title string, command []string, directory string) bool { - if len(command) != len(p.command) { - return true - } - for i := range command { - if command[i] != p.command[i] { - return true - } - } - if title != p.title { - return true - } - if directory != p.dir { - return true - } - return false -} - -func New() *Monoplexer { - return &Monoplexer{ - processes: map[string]*Process{}, - lines: make(chan Line, 32), - } -} - -func (p *Process) start(lines chan Line) { - r, w := io.Pipe() - cmd := process.Command(p.command[0], p.command[1:]...) - cmd.SysProcAttr = getProcAttr() - cmd.Stdout = w - cmd.Stderr = w - if p.dir != "" { - cmd.Dir = p.dir - } - if len(p.env) > 0 { - cmd.Env = append(os.Environ(), p.env...) - } - go func() { - // read r line by line - scanner := bufio.NewScanner(r) - for scanner.Scan() { - lines <- Line{ - line: scanner.Text(), - process: p.name, - } - } - }() - cmd.Start() - p.cmd = cmd - p.started = true -} - -func (m *Monoplexer) AddProcess(name string, command []string, directory string, title string, autostart bool, env ...string) { - exists, ok := m.processes[name] - if ok { - if !exists.IsDifferent(title, command, directory) { - if !exists.started && autostart { - exists.start(m.lines) - } - return - } - if exists.started { - m.lines <- Line{ - line: "dev config changed, restarting...", - process: name, - } - process.Kill(exists.cmd.Process) - } - delete(m.processes, name) - } - - proc := &Process{ - name: name, - title: title, - command: command, - dir: directory, - env: env, - } - m.processes[name] = proc - if autostart { - proc.start(m.lines) - return - } - m.lines <- Line{ - line: "auto-start disabled", - process: name, - } -} - -func (m *Monoplexer) Start(ctx context.Context) error { - for { - select { - case line := <-m.lines: - match, ok := m.processes[line.process] - if !ok { - continue - } - fmt.Println("["+match.title+"]", line.line) - case <-ctx.Done(): - return nil - } - } -} diff --git a/cmd/sst/mosaic/monoplexer/monoplexer_test.go b/cmd/sst/mosaic/monoplexer/monoplexer_test.go deleted file mode 100644 index 93f7e40b6e..0000000000 --- a/cmd/sst/mosaic/monoplexer/monoplexer_test.go +++ /dev/null @@ -1,98 +0,0 @@ -package monoplexer - -import ( - "strings" - "testing" - "time" - - "github.com/sst/sst/v3/pkg/process" -) - -func TestAddProcessAutostartFalse(t *testing.T) { - m := New() - m.AddProcess("web", []string{"sh", "-c", "sleep 5"}, "", "Web", false) - - proc := m.processes["web"] - if proc == nil { - t.Fatal("expected process to be registered") - } - if proc.started { - t.Fatal("expected process to remain stopped") - } - - select { - case line := <-m.lines: - if line.process != "web" { - t.Fatalf("expected message for web, got %q", line.process) - } - if !strings.Contains(line.line, "auto-start disabled") { - t.Fatalf("expected disabled message, got %q", line.line) - } - case <-time.After(time.Second): - t.Fatal("expected disabled message") - } -} - -func TestAddProcessAutostartTrue(t *testing.T) { - m := New() - m.AddProcess("web", []string{"sh", "-c", "sleep 5"}, "", "Web", true) - - proc := m.processes["web"] - if proc == nil { - t.Fatal("expected process to be registered") - } - if !proc.started { - t.Fatal("expected process to start") - } - if proc.cmd == nil || proc.cmd.Process == nil { - t.Fatal("expected child process to be running") - } - - defer process.Kill(proc.cmd.Process) -} - -func TestAddProcessStartsWhenAutostartEnabledLater(t *testing.T) { - m := New() - m.AddProcess("web", []string{"sh", "-c", "sleep 5"}, "", "Web", false) - <-m.lines - - m.AddProcess("web", []string{"sh", "-c", "sleep 5"}, "", "Web", true) - - proc := m.processes["web"] - if proc == nil { - t.Fatal("expected process to be registered") - } - if !proc.started { - t.Fatal("expected process to start when autostart becomes enabled") - } - if proc.cmd == nil || proc.cmd.Process == nil { - t.Fatal("expected child process to be running") - } - - defer process.Kill(proc.cmd.Process) -} - -func TestAddProcessConfigChangeKeepsProcessStopped(t *testing.T) { - m := New() - m.AddProcess("web", []string{"sh", "-c", "sleep 5"}, "", "Web", false) - <-m.lines - - m.AddProcess("web", []string{"sh", "-c", "sleep 10"}, "", "Web", false) - - proc := m.processes["web"] - if proc == nil { - t.Fatal("expected process to be registered") - } - if proc.started { - t.Fatal("expected process to remain stopped after config change") - } - - select { - case line := <-m.lines: - if !strings.Contains(line.line, "auto-start disabled") { - t.Fatalf("expected disabled message, got %q", line.line) - } - case <-time.After(time.Second): - t.Fatal("expected disabled message after config change") - } -} diff --git a/cmd/sst/mosaic/monoplexer/monoplexer_unix.go b/cmd/sst/mosaic/monoplexer/monoplexer_unix.go deleted file mode 100644 index cb5eed0555..0000000000 --- a/cmd/sst/mosaic/monoplexer/monoplexer_unix.go +++ /dev/null @@ -1,13 +0,0 @@ -//go:build !windows -// +build !windows - -package monoplexer - -import "syscall" - -func getProcAttr() *syscall.SysProcAttr { - return &syscall.SysProcAttr{ - Setpgid: true, - Pgid: 0, - } -} diff --git a/cmd/sst/mosaic/monoplexer/monoplexer_windows.go b/cmd/sst/mosaic/monoplexer/monoplexer_windows.go deleted file mode 100644 index 9949429e70..0000000000 --- a/cmd/sst/mosaic/monoplexer/monoplexer_windows.go +++ /dev/null @@ -1,10 +0,0 @@ -//go:build windows -// +build windows - -package monoplexer - -import "syscall" - -func getProcAttr() *syscall.SysProcAttr { - return &syscall.SysProcAttr{} -} diff --git a/cmd/sst/mosaic/multiplexer/draw.go b/cmd/sst/mosaic/multiplexer/draw.go deleted file mode 100644 index 0142598ac6..0000000000 --- a/cmd/sst/mosaic/multiplexer/draw.go +++ /dev/null @@ -1,288 +0,0 @@ -package multiplexer - -import ( - "fmt" - "slices" - "sort" - "strings" - "unicode/utf8" - - "github.com/gdamore/tcell/v2" - "github.com/gdamore/tcell/v2/views" -) - -func (s *Multiplexer) draw() { - defer s.screen.Show() - s.screen.Clear() - softGray := tcell.NewRGBColor(138, 138, 138) - for _, w := range s.stack.Widgets() { - s.stack.RemoveWidget(w) - } - selected := s.selectedProcess() - - for index, item := range s.processes { - if index > 0 && !s.processes[index-1].dead && item.dead { - spacer := views.NewTextBar() - spacer.SetLeft("──────────────────────", tcell.StyleDefault.Foreground(tcell.ColorGray)) - s.stack.AddWidget(spacer, 0) - } - style := tcell.StyleDefault - if item.dead { - style = style.Foreground(tcell.ColorGray) - } - if index == s.selected { - style = style.Bold(true) - if !s.focused { - if item.dead { - style = style.Foreground(tcell.ColorOrange).Dim(true) - } else { - style = style.Foreground(tcell.ColorOrange) - } - } - } - label := item.Title - textStyle := style - if item.filter != "" { - label = item.filter - textStyle = textStyle.Italic(true) - } - title := views.NewTextBar() - title.SetStyle(style) - title.SetLeft(item.Icon+" "+label, textStyle) - s.stack.AddWidget(title, 0) - } - s.stack.AddWidget(views.NewSpacer(), 1) - - hotkeys := map[string]string{} - if s.filtering && s.filterSearching { - hotkeys["esc"] = "cancel" - hotkeys["enter"] = "confirm" - } else if s.filtering { - hotkeys["j/k/↓/↑"] = "move" - hotkeys["enter"] = "select" - hotkeys["/"] = "search" - hotkeys["esc"] = "clear" - } else { - if selected != nil && selected.Killable && !s.focused { - if !selected.dead { - hotkeys["x"] = "kill" - hotkeys["enter"] = "focus" - } - - if selected.dead { - hotkeys["enter"] = "start" - } - } - if !s.focused { - hotkeys["j/k/↓/↑"] = "up/down" - } - if s.focused { - hotkeys["ctrl-z"] = "sidebar" - } - if selected != nil && selected.vt.HasSelection() { - hotkeys["enter"] = "copy" - } - hotkeys["ctrl-u/d"] = "scroll" - if selected != nil && selected.isScrolling() { - hotkeys["ctrl-g"] = "bottom" - } - hotkeys["ctrl-l"] = "clear" - if selected != nil && !s.focused && selected.Filterable && selected.filterAvailable { - hotkeys["f"] = "filter" - } - } - // sort hotkeys - keys := make([]string, 0, len(hotkeys)) - for key := range hotkeys { - keys = append(keys, key) - } - slices.SortFunc(keys, func(i, j string) int { - ilength := utf8.RuneCountInString(i) - jlength := utf8.RuneCountInString(j) - if ilength != jlength { - return ilength - jlength - } - return strings.Compare(i, j) - }) - for _, key := range keys { - label := hotkeys[key] - title := views.NewTextBar() - title.SetStyle(tcell.StyleDefault.Foreground(softGray)) - title.SetLeft(key, tcell.StyleDefault.Foreground(softGray).Bold(true)) - title.SetRight(label+" ", tcell.StyleDefault) - s.stack.AddWidget(title, 0) - } - s.stack.Draw() - - borderStyle := tcell.StyleDefault.Foreground(tcell.ColorGray).Dim(true) - for i := PAD_HEIGHT; i < s.height-PAD_HEIGHT; i++ { - s.screen.SetContent(SIDEBAR_WIDTH, i, '│', nil, borderStyle) - } - - // render virtual terminal - if selected != nil && !s.filtering { - selected.vt.Draw() - if s.focused { - y, x, _, _ := selected.vt.Cursor() - s.screen.ShowCursor(s.mainX()+x, y+s.contentY()) - } - if !s.focused { - s.screen.HideCursor() - } - } - - if s.filtering { - if !s.filterSearching { - s.screen.HideCursor() - } - s.drawFilterSelect(selected) - } -} - -func (s *Multiplexer) drawFilterSelect(selected *pane) { - startX := s.mainX() - startY := s.contentY() - endY := s.height - s.contentY() - mainW := s.mainWidth() - softGray := tcell.NewRGBColor(138, 138, 138) - dimStyle := tcell.StyleDefault.Foreground(tcell.ColorGray) - grayStyle := tcell.StyleDefault.Foreground(softGray) - tealStyle := tcell.StyleDefault.Foreground(tcell.ColorTeal).Bold(true) - tealDimStyle := tcell.StyleDefault.Foreground(tcell.ColorTeal).Dim(true) - normalStyle := tcell.StyleDefault.Foreground(tcell.ColorWhite) - - // clear main area - for y := startY; y < endY; y++ { - for x := startX; x < s.width; x++ { - s.screen.SetContent(x, y, ' ', nil, tcell.StyleDefault) - } - } - - y := startY - s.drawLine(startX, y, selected.FilterTitle, tealStyle, mainW) - y++ // blank - y++ - - if s.filterSearching { - x := s.drawLine(startX, y, "Search: ", grayStyle, mainW) - x = s.drawLine(x, y, s.filterQuery, normalStyle, mainW-(x-startX)) - s.screen.ShowCursor(x, y) - } else if s.filterQuery != "" { - x := s.drawLine(startX, y, "Search: ", grayStyle, mainW) - s.drawLine(x, y, s.filterQuery, normalStyle.Italic(true), mainW-(x-startX)) - } else { - s.drawLine(startX, y, selected.FilterSubtitle, grayStyle, mainW) - } - y++ // blank - y++ - - total := len(s.filterFiltered) - - if total > 0 && s.filterScroll > 0 { - s.drawLine(startX, y, fmt.Sprintf("↑ %d more", s.filterScroll), dimStyle, mainW) - } - y++ - - if total == 0 { - s.drawLine(startX, y, "No results found.", dimStyle, mainW) - return - } - - visible := s.filterVisibleRows() - end := min(s.filterScroll+visible, total) - - for fi := s.filterScroll; fi < end && y < endY-1; fi++ { - opt := s.filterOptions[s.filterFiltered[fi]] - style := normalStyle - descStyle := dimStyle - prefix := " " - if fi == s.filterSelected { - style = tealStyle - descStyle = tealDimStyle - prefix = "> " - } - x := s.drawLine(startX, y, prefix+opt.Label, style, mainW) - if opt.Description != "" { - s.drawLine(x, y, " "+opt.Description, descStyle, mainW-(x-startX)) - } - y++ - } - - if end < total && y < endY { - s.drawLine(startX, y, fmt.Sprintf("↓ %d more", total-end), dimStyle, mainW) - } -} - -func (s *Multiplexer) drawLine(startX, y int, text string, style tcell.Style, maxW int) int { - x := startX - for _, ch := range text { - if x-startX >= maxW { - break - } - s.screen.SetContent(x, y, ch, nil, style) - x++ - } - return x -} - -func (s *Multiplexer) move(offset int) { - index := s.selected + offset - if index < 0 { - index = 0 - } - if index >= len(s.processes) { - index = len(s.processes) - 1 - } - s.selected = index - s.draw() -} - -func (s *Multiplexer) focus() { - s.focused = true - s.draw() -} - -func (s *Multiplexer) blur() { - s.focused = false - selected := s.selectedProcess() - if selected != nil { - selected.scrollReset() - } - s.screen.HideCursor() - s.draw() -} - -func (s *Multiplexer) sort() { - if len(s.processes) == 0 { - return - } - key := s.selectedProcess().Key - sort.Slice(s.processes, func(i, j int) bool { - if !s.processes[i].Killable && s.processes[j].Killable { - return true - } - if s.processes[i].Killable && !s.processes[j].Killable { - return false - } - if !s.processes[i].dead && s.processes[j].dead { - return true - } - if s.processes[i].dead && !s.processes[j].dead { - return false - } - return len(s.processes[i].Title) < len(s.processes[j].Title) - }) - for i, p := range s.processes { - if p.Key == key { - s.selected = i - return - } - } -} - -func (s *Multiplexer) selectedProcess() *pane { - if s.selected >= len(s.processes) { - return nil - } - return s.processes[s.selected] -} diff --git a/cmd/sst/mosaic/multiplexer/keycode.go b/cmd/sst/mosaic/multiplexer/keycode.go deleted file mode 100644 index 0452e2ceb9..0000000000 --- a/cmd/sst/mosaic/multiplexer/keycode.go +++ /dev/null @@ -1,691 +0,0 @@ -package multiplexer - -import ( - "strings" - - "github.com/gdamore/tcell/v2" -) - -func keyCode(ev *tcell.EventKey) string { - key := strings.Builder{} - switch ev.Modifiers() { - case tcell.ModNone: - switch ev.Key() { - case tcell.KeyRune: - key.WriteRune(ev.Rune()) - default: - if str, ok := keyCodes[ev.Key()]; ok { - key.WriteString(str) - } else { - key.WriteRune(rune(ev.Key())) - } - } - case tcell.ModShift: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(info.KeyShfUp) - case tcell.KeyDown: - key.WriteString(info.KeyShfDown) - case tcell.KeyRight: - key.WriteString(info.KeyShfRight) - case tcell.KeyLeft: - key.WriteString(info.KeyShfLeft) - case tcell.KeyHome: - key.WriteString(info.KeyShfHome) - case tcell.KeyEnd: - key.WriteString(info.KeyShfEnd) - case tcell.KeyInsert: - key.WriteString(info.KeyShfInsert) - case tcell.KeyDelete: - key.WriteString(info.KeyShfDelete) - case tcell.KeyPgUp: - key.WriteString(info.KeyShfPgUp) - case tcell.KeyPgDn: - key.WriteString(info.KeyShfPgDn) - case tcell.KeyF1: - key.WriteString(info.KeyF13) - case tcell.KeyF2: - key.WriteString(info.KeyF14) - case tcell.KeyF3: - key.WriteString(info.KeyF15) - case tcell.KeyF4: - key.WriteString(info.KeyF16) - case tcell.KeyF5: - key.WriteString(info.KeyF17) - case tcell.KeyF6: - key.WriteString(info.KeyF18) - case tcell.KeyF7: - key.WriteString(info.KeyF19) - case tcell.KeyF8: - key.WriteString(info.KeyF20) - case tcell.KeyF9: - key.WriteString(info.KeyF21) - case tcell.KeyF10: - key.WriteString(info.KeyF22) - case tcell.KeyF11: - key.WriteString(info.KeyF23) - case tcell.KeyF12: - key.WriteString(info.KeyF24) - } - case tcell.ModAlt: - switch ev.Key() { - case tcell.KeyRune: - key.WriteString("\x1b") - key.WriteRune(ev.Rune()) - case tcell.KeyUp: - key.WriteString(info.KeyAltUp) - case tcell.KeyDown: - key.WriteString(info.KeyAltDown) - case tcell.KeyRight: - key.WriteString(info.KeyAltRight) - case tcell.KeyLeft: - key.WriteString(info.KeyAltLeft) - case tcell.KeyHome: - key.WriteString(info.KeyAltHome) - case tcell.KeyEnd: - key.WriteString(info.KeyAltEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyAltInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyAltDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyAltPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyAltPgDown) - case tcell.KeyF1: - key.WriteString(info.KeyF49) - case tcell.KeyF2: - key.WriteString(info.KeyF50) - case tcell.KeyF3: - key.WriteString(info.KeyF51) - case tcell.KeyF4: - key.WriteString(info.KeyF53) - case tcell.KeyF5: - key.WriteString(info.KeyF54) - case tcell.KeyF6: - key.WriteString(info.KeyF55) - case tcell.KeyF7: - key.WriteString(info.KeyF56) - case tcell.KeyF8: - key.WriteString(info.KeyF57) - case tcell.KeyF9: - key.WriteString(info.KeyF58) - case tcell.KeyF10: - key.WriteString(info.KeyF59) - case tcell.KeyF11: - key.WriteString(info.KeyF60) - case tcell.KeyF12: - key.WriteString(info.KeyF61) - } - case tcell.ModCtrl: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(info.KeyCtrlUp) - case tcell.KeyDown: - key.WriteString(info.KeyCtrlDown) - case tcell.KeyRight: - key.WriteString(info.KeyCtrlRight) - case tcell.KeyLeft: - key.WriteString(info.KeyCtrlLeft) - case tcell.KeyHome: - key.WriteString(info.KeyCtrlHome) - case tcell.KeyEnd: - key.WriteString(info.KeyCtrlEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyCtrlInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyCtrlDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyCtrlPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyCtrlPgDown) - case tcell.KeyF1: - key.WriteString(info.KeyF25) - case tcell.KeyF2: - key.WriteString(info.KeyF26) - case tcell.KeyF3: - key.WriteString(info.KeyF27) - case tcell.KeyF4: - key.WriteString(info.KeyF28) - case tcell.KeyF5: - key.WriteString(info.KeyF29) - case tcell.KeyF6: - key.WriteString(info.KeyF30) - case tcell.KeyF7: - key.WriteString(info.KeyF31) - case tcell.KeyF8: - key.WriteString(info.KeyF32) - case tcell.KeyF9: - key.WriteString(info.KeyF33) - case tcell.KeyF10: - key.WriteString(info.KeyF34) - case tcell.KeyF11: - key.WriteString(info.KeyF35) - case tcell.KeyF12: - key.WriteString(info.KeyF36) - default: - key.WriteRune(ev.Rune()) - } - case tcell.ModCtrl | tcell.ModShift: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(info.KeyCtrlShfUp) - case tcell.KeyDown: - key.WriteString(info.KeyCtrlShfDown) - case tcell.KeyRight: - key.WriteString(info.KeyCtrlShfRight) - case tcell.KeyLeft: - key.WriteString(info.KeyCtrlShfLeft) - case tcell.KeyHome: - key.WriteString(info.KeyCtrlShfHome) - case tcell.KeyEnd: - key.WriteString(info.KeyCtrlShfEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyCtrlShfInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyCtrlShfDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyCtrlShfPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyCtrlShfPgDown) - case tcell.KeyF1: - key.WriteString(info.KeyF37) - case tcell.KeyF2: - key.WriteString(info.KeyF38) - case tcell.KeyF3: - key.WriteString(info.KeyF39) - case tcell.KeyF4: - key.WriteString(info.KeyF40) - case tcell.KeyF5: - key.WriteString(info.KeyF41) - case tcell.KeyF6: - key.WriteString(info.KeyF42) - case tcell.KeyF7: - key.WriteString(info.KeyF43) - case tcell.KeyF8: - key.WriteString(info.KeyF44) - case tcell.KeyF9: - key.WriteString(info.KeyF45) - case tcell.KeyF10: - key.WriteString(info.KeyF46) - case tcell.KeyF11: - key.WriteString(info.KeyF47) - case tcell.KeyF12: - key.WriteString(info.KeyF48) - } - case tcell.ModAlt | tcell.ModShift: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(info.KeyAltShfUp) - case tcell.KeyDown: - key.WriteString(info.KeyAltShfDown) - case tcell.KeyRight: - key.WriteString(info.KeyAltShfRight) - case tcell.KeyLeft: - key.WriteString(info.KeyAltShfLeft) - case tcell.KeyHome: - key.WriteString(info.KeyAltShfHome) - case tcell.KeyEnd: - key.WriteString(info.KeyAltShfEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyAltShfInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyAltShfDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyAltShfPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyAltShfPgDown) - case tcell.KeyF1: - key.WriteString(info.KeyF61) - case tcell.KeyF2: - key.WriteString(info.KeyF62) - case tcell.KeyF3: - key.WriteString(info.KeyF63) - case tcell.KeyF4: - key.WriteString(info.KeyF64) - } - case tcell.ModAlt | tcell.ModCtrl: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(extendedInfo.KeyCtrlAltUp) - case tcell.KeyDown: - key.WriteString(extendedInfo.KeyCtrlAltDown) - case tcell.KeyRight: - key.WriteString(extendedInfo.KeyCtrlAltRight) - case tcell.KeyLeft: - key.WriteString(extendedInfo.KeyCtrlAltLeft) - case tcell.KeyHome: - key.WriteString(extendedInfo.KeyCtrlAltHome) - case tcell.KeyEnd: - key.WriteString(extendedInfo.KeyCtrlAltEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyCtrlAltInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyCtrlAltDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyCtrlAltPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyCtrlAltPgDown) - } - case tcell.ModAlt | tcell.ModCtrl | tcell.ModShift: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(extendedInfo.KeyCtrlAltShfUp) - case tcell.KeyDown: - key.WriteString(extendedInfo.KeyCtrlAltShfDown) - case tcell.KeyRight: - key.WriteString(extendedInfo.KeyCtrlAltShfRight) - case tcell.KeyLeft: - key.WriteString(extendedInfo.KeyCtrlAltShfLeft) - case tcell.KeyHome: - key.WriteString(extendedInfo.KeyCtrlAltShfHome) - case tcell.KeyEnd: - key.WriteString(extendedInfo.KeyCtrlAltShfEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyCtrlAltShfInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyCtrlAltShfDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyCtrlAltShfPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyCtrlAltShfPgDown) - } - case tcell.ModMeta: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";9~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;9") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModShift: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";10~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;10") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModAlt: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";11~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;11") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModAlt | tcell.ModShift: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";12~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;12") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModCtrl: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";13~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;13") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModCtrl | tcell.ModShift: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";14~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;14") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModCtrl | tcell.ModAlt: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";15~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;15") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModCtrl | tcell.ModAlt | tcell.ModShift: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";16~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;16") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - } - return key.String() -} - -var keyCodes = map[tcell.Key]string{ - tcell.KeyBackspace: info.KeyBackspace, - tcell.KeyF1: info.KeyF1, - tcell.KeyF2: info.KeyF2, - tcell.KeyF3: info.KeyF3, - tcell.KeyF4: info.KeyF4, - tcell.KeyF5: info.KeyF5, - tcell.KeyF6: info.KeyF6, - tcell.KeyF7: info.KeyF7, - tcell.KeyF8: info.KeyF8, - tcell.KeyF9: info.KeyF9, - tcell.KeyF10: info.KeyF10, - tcell.KeyF11: info.KeyF11, - tcell.KeyF12: info.KeyF12, - tcell.KeyF13: info.KeyF13, - tcell.KeyF14: info.KeyF14, - tcell.KeyF15: info.KeyF15, - tcell.KeyF16: info.KeyF16, - tcell.KeyF17: info.KeyF17, - tcell.KeyF18: info.KeyF18, - tcell.KeyF19: info.KeyF19, - tcell.KeyF20: info.KeyF20, - tcell.KeyF21: info.KeyF21, - tcell.KeyF22: info.KeyF22, - tcell.KeyF23: info.KeyF23, - tcell.KeyF24: info.KeyF24, - tcell.KeyF25: info.KeyF25, - tcell.KeyF26: info.KeyF26, - tcell.KeyF27: info.KeyF27, - tcell.KeyF28: info.KeyF28, - tcell.KeyF29: info.KeyF29, - tcell.KeyF30: info.KeyF30, - tcell.KeyF31: info.KeyF31, - tcell.KeyF32: info.KeyF32, - tcell.KeyF33: info.KeyF33, - tcell.KeyF34: info.KeyF34, - tcell.KeyF35: info.KeyF35, - tcell.KeyF36: info.KeyF36, - tcell.KeyF37: info.KeyF37, - tcell.KeyF38: info.KeyF38, - tcell.KeyF39: info.KeyF39, - tcell.KeyF40: info.KeyF40, - tcell.KeyF41: info.KeyF41, - tcell.KeyF42: info.KeyF42, - tcell.KeyF43: info.KeyF43, - tcell.KeyF44: info.KeyF44, - tcell.KeyF45: info.KeyF45, - tcell.KeyF46: info.KeyF46, - tcell.KeyF47: info.KeyF47, - tcell.KeyF48: info.KeyF48, - tcell.KeyF49: info.KeyF49, - tcell.KeyF50: info.KeyF50, - tcell.KeyF51: info.KeyF51, - tcell.KeyF52: info.KeyF52, - tcell.KeyF53: info.KeyF53, - tcell.KeyF54: info.KeyF54, - tcell.KeyF55: info.KeyF55, - tcell.KeyF56: info.KeyF56, - tcell.KeyF57: info.KeyF57, - tcell.KeyF58: info.KeyF58, - tcell.KeyF59: info.KeyF59, - tcell.KeyF60: info.KeyF60, - tcell.KeyF61: info.KeyF61, - tcell.KeyF62: info.KeyF62, - tcell.KeyF63: info.KeyF63, - tcell.KeyF64: info.KeyF64, - tcell.KeyInsert: info.KeyInsert, - tcell.KeyDelete: info.KeyDelete, - tcell.KeyHome: info.KeyHome, - tcell.KeyEnd: info.KeyEnd, - tcell.KeyHelp: info.KeyHelp, - tcell.KeyPgUp: info.KeyPgUp, - tcell.KeyPgDn: info.KeyPgDn, - tcell.KeyUp: info.KeyUp, - tcell.KeyDown: info.KeyDown, - tcell.KeyLeft: info.KeyLeft, - tcell.KeyRight: info.KeyRight, - tcell.KeyBacktab: info.KeyBacktab, - tcell.KeyExit: info.KeyExit, - tcell.KeyClear: info.KeyClear, - tcell.KeyPrint: info.KeyPrint, - tcell.KeyCancel: info.KeyCancel, -} diff --git a/cmd/sst/mosaic/multiplexer/multiplexer.go b/cmd/sst/mosaic/multiplexer/multiplexer.go deleted file mode 100644 index cba7a37a44..0000000000 --- a/cmd/sst/mosaic/multiplexer/multiplexer.go +++ /dev/null @@ -1,734 +0,0 @@ -package multiplexer - -import ( - "encoding/base64" - "fmt" - "log/slog" - "os" - "runtime/debug" - "strings" - "syscall" - "time" - - "github.com/gdamore/tcell/v2" - "github.com/gdamore/tcell/v2/views" - tcellterm "github.com/sst/sst/v3/cmd/sst/mosaic/multiplexer/tcell-term" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/pkg/process" -) - -var PAD_HEIGHT = 1 -var PAD_WIDTH = 1 -var MAIN_PAD_WIDTH = 3 -var CONTENT_PAD_HEIGHT = 0 -var SIDEBAR_WIDTH = 24 - -type Multiplexer struct { - focused bool - width int - height int - selected int - processes []*pane - screen tcell.Screen - root *views.ViewPort - main *views.ViewPort - stack *views.BoxLayout - - dragging bool - click *tcell.EventMouse - scrollTicker *time.Ticker - scrollDone chan struct{} - scrollDir int - lastDragX int - - filtering bool - filterOptions []FilterOption - filterFiltered []int - filterSelected int - filterScroll int - filterSearching bool - filterQuery string -} - -type FilterOption struct { - Label string - Description string - Value string -} - -func New() (*Multiplexer, error) { - var err error - result := &Multiplexer{} - result.processes = []*pane{} - result.screen, err = tcell.NewScreen() - if err != nil { - return nil, err - } - result.screen.Init() - result.screen.EnableMouse() - result.screen.Show() - width, height := result.screen.Size() - result.width = width - result.height = height - result.root = views.NewViewPort(result.screen, 0, 0, 0, 0) - result.main = views.NewViewPort(result.screen, 0, 0, 0, 0) - result.stack = views.NewBoxLayout(views.Vertical) - result.stack.SetView(result.root) - if os.Getenv("TMUX") != "" { - process.Command("tmux", "set-option", "-p", "set-clipboard", "on").Run() - } - return result, nil -} - -func (s *Multiplexer) mainRect() (int, int) { - return s.mainWidth(), s.mainHeight() -} - -func (s *Multiplexer) mainX() int { - return SIDEBAR_WIDTH + 1 + MAIN_PAD_WIDTH -} - -func (s *Multiplexer) mainWidth() int { - return max(0, s.width-s.mainX()-MAIN_PAD_WIDTH) -} - -func (s *Multiplexer) contentY() int { - return PAD_HEIGHT + CONTENT_PAD_HEIGHT -} - -func (s *Multiplexer) mainHeight() int { - return max(0, s.height-s.contentY()*2) -} - -func (s *Multiplexer) sidebarWidth() int { - return SIDEBAR_WIDTH - PAD_WIDTH - 1 -} - -func (s *Multiplexer) resize(width int, height int) { - s.width = width - s.height = height - s.root.Resize(PAD_WIDTH, s.contentY(), s.sidebarWidth(), s.mainHeight()) - s.main.Resize(s.mainX(), s.contentY(), s.mainWidth(), s.mainHeight()) - mw, mh := s.main.Size() - for _, p := range s.processes { - p.vt.Resize(mw, mh) - } -} - -func (s *Multiplexer) Start() { - defer func() { - s.stopAutoScroll() - s.screen.Fini() - }() - - s.resize(s.screen.Size()) - - for { - unknown := s.screen.PollEvent() - if unknown == nil { - continue - } - shouldBreak := false - func() { - defer func() { - if r := recover(); r != nil { - slog.Error("mutliplexer panic", "err", r, "stack", string(debug.Stack())) - } - }() - - selected := s.selectedProcess() - - switch evt := unknown.(type) { - - case *tcell.EventInterrupt: - if s.scrollDir != 0 && s.dragging && selected != nil { - if s.scrollDir < 0 { - s.scrollUp(1) - selected.vt.SelectEnd(s.lastDragX, 0) - } else { - s.scrollDown(1) - selected.vt.SelectEnd(s.lastDragX, max(0, s.mainHeight()-1)) - } - } - return - - case *EventExit: - shouldBreak = true - return - - case *EventCheckFilter: - for _, p := range s.processes { - if p.Key != evt.PaneKey || !p.Filterable { - continue - } - p.filterAvailable = len(evt.Names) > 0 - if p.filter == "" { - continue - } - found := false - for _, name := range evt.Names { - if name == p.filter { - found = true - break - } - } - if !found { - s.clearPaneFilter(p) - } - } - s.draw() - return - - case *EventProcess: - for _, p := range s.processes { - if p.Key == evt.Key { - if p.dead && evt.Autostart { - p.start() - s.sort() - s.draw() - } - return - } - } - proc := &pane{PaneConfig: evt.PaneConfig} - term := tcellterm.New() - term.SetSurface(s.main) - term.Attach(func(ev tcell.Event) { - s.screen.PostEvent(ev) - }) - proc.vt = term - if evt.Autostart { - proc.start() - } - if !evt.Autostart { - proc.vt.Start(process.Command("echo", ui.TEXT_DIM.Render(evt.Key+" has auto-start disabled, press enter to start."))) - proc.dead = true - } - s.processes = append(s.processes, proc) - s.sort() - s.draw() - break - - case *tcell.EventMouse: - if evt.Buttons()&tcell.WheelUp != 0 { - s.scrollUp(3) - return - } - if evt.Buttons()&tcell.WheelDown != 0 { - s.scrollDown(3) - return - } - if evt.Buttons() == tcell.ButtonNone { - s.stopAutoScroll() - if s.dragging && selected != nil { - s.copy() - } - s.dragging = false - return - } - if evt.Buttons()&tcell.ButtonPrimary != 0 { - x, y := evt.Position() - contentY := y - s.contentY() - maxContentY := max(0, s.mainHeight()-1) - if x < s.mainX() && s.dragging && selected != nil { - if y < s.contentY() { - s.scrollUp(1) - s.startAutoScroll(-1) - selected.vt.SelectEnd(0, 0) - s.draw() - } else if y >= s.height-s.contentY() { - s.scrollDown(1) - s.startAutoScroll(1) - selected.vt.SelectEnd(0, maxContentY) - s.draw() - } else if contentY >= 0 && contentY <= maxContentY { - s.stopAutoScroll() - selected.vt.SelectEnd(0, contentY) - s.draw() - } - return - } - if x < SIDEBAR_WIDTH && !s.dragging { - if contentY < 0 || contentY > maxContentY { - return - } - y = contentY - alive := 0 - for _, p := range s.processes { - if !p.dead { - alive++ - } - } - if alive != len(s.processes) { - if y == alive { - return - } - if y > alive { - y-- - } - } - if y >= len(s.processes) { - return - } - s.selected = y - s.blur() - return - } - if x >= s.mainX() { - if selected == nil { - return - } - if !s.dragging && (contentY < 0 || contentY > maxContentY) { - return - } - if !s.dragging && s.click != nil && time.Since(s.click.When()) < time.Millisecond*500 { - oldX, oldY := s.click.Position() - if oldX == x && oldY == y { - selected.vt.SelectStart(0, contentY) - selected.vt.SelectEnd(s.width-1, contentY) - s.dragging = true - s.draw() - return - } - } - s.click = evt - offsetX := x - s.mainX() - s.lastDragX = offsetX - if s.dragging { - if y < s.contentY() { - s.scrollUp(1) - s.startAutoScroll(-1) - } else if y >= s.height-s.contentY() { - s.scrollDown(1) - s.startAutoScroll(1) - } else { - s.stopAutoScroll() - } - selected.vt.SelectEnd(offsetX, min(max(contentY, 0), maxContentY)) - } - if !s.dragging { - s.dragging = true - selected.vt.SelectStart(offsetX, contentY) - } - s.draw() - return - } - } - break - - case *tcell.EventResize: - slog.Info("resize") - s.resize(evt.Size()) - s.draw() - s.screen.Sync() - return - - case *tcellterm.EventRedraw: - if s.filtering { - return - } - if selected != nil && selected.vt == evt.VT() { - selected.vt.Draw() - s.screen.Show() - } - return - - case *tcellterm.EventClosed: - for index, proc := range s.processes { - if proc.vt == evt.VT() { - if !proc.dead { - proc.vt.Start(process.Command("echo", "\n"+ui.TEXT_DIM.Render("[process exited]"))) - proc.dead = true - s.sort() - if index == s.selected { - s.blur() - } - } - } - } - s.draw() - return - - case *tcell.EventKey: - if s.filtering && evt.Key() != tcell.KeyCtrlC { - s.handleFilterKey(evt) - return - } - switch evt.Key() { - case 256: - switch evt.Rune() { - case 'j': - if !s.focused { - s.move(1) - return - } - case 'k': - if !s.focused { - s.move(-1) - return - } - case 'x': - if selected.Killable && !selected.dead && !s.focused { - selected.Kill() - } - case 'f': - if !s.focused && selected != nil && selected.Filterable && selected.filterAvailable && selected.ListOptions != nil { - options := selected.ListOptions() - if len(options) == 0 { - return - } - s.filterOptions = options - s.filterFiltered = make([]int, len(options)) - for i := range options { - s.filterFiltered[i] = i - } - s.filterSelected = 0 - for i, opt := range s.filterOptions { - if opt.Value == selected.filter { - s.filterSelected = i - break - } - } - s.filterScroll = 0 - s.filterSearching = false - s.filterQuery = "" - s.filtering = true - s.filterEnsureVisible() - s.draw() - return - } - } - case tcell.KeyUp: - if !s.focused { - s.move(-1) - return - } - case tcell.KeyDown: - if !s.focused { - s.move(1) - return - } - case tcell.KeyCtrlU: - if selected != nil { - s.scrollUp(s.mainHeight()/2 + 1) - return - } - case tcell.KeyCtrlD: - if selected != nil { - s.scrollDown(s.mainHeight()/2 + 1) - return - } - case tcell.KeyEnter: - if selected != nil && selected.vt.HasSelection() { - s.copy() - selected.vt.ClearSelection() - s.draw() - return - } - if !s.focused { - if selected.Killable { - if selected.dead { - selected.start() - s.sort() - s.draw() - return - } - s.focus() - } - return - } - case tcell.KeyCtrlC: - if !s.focused { - s.move(-99999) - pid := os.Getpid() - process, _ := os.FindProcess(pid) - process.Signal(syscall.SIGINT) - return - } - case tcell.KeyEscape: - if !s.focused && selected != nil && selected.filter != "" { - s.clearPaneFilter(selected) - return - } - case tcell.KeyCtrlZ: - if s.focused { - s.blur() - return - } - case tcell.KeyCtrlG: - if selected != nil && selected.isScrolling() { - selected.scrollReset() - s.draw() - s.screen.Sync() - return - } - case tcell.KeyCtrlL: - if selected != nil { - selected.Clear() - s.draw() - return - } - } - - if selected != nil && s.focused && !selected.isScrolling() { - selected.vt.HandleEvent(evt) - s.draw() - } - } - }() - if shouldBreak { - return - } - } -} - -func (s *Multiplexer) handleFilterKey(evt *tcell.EventKey) { - if s.filterSearching { - s.handleFilterSearchKey(evt) - return - } - switch evt.Key() { - case tcell.KeyEscape: - selected := s.selectedProcess() - if selected != nil && selected.filter != "" { - s.clearPaneFilter(selected) - } - s.filtering = false - s.draw() - case tcell.KeyEnter: - if len(s.filterFiltered) == 0 { - return - } - value := s.filterOptions[s.filterFiltered[s.filterSelected]].Value - selected := s.selectedProcess() - if selected != nil && selected.filter == value { - value = "" - } - s.applyFilter(value) - s.filtering = false - s.draw() - case tcell.KeyUp: - if s.filterSelected > 0 { - s.filterSelected-- - s.filterEnsureVisible() - s.draw() - } - case tcell.KeyDown: - if s.filterSelected < len(s.filterFiltered)-1 { - s.filterSelected++ - s.filterEnsureVisible() - s.draw() - } - case tcell.KeyRune: - switch evt.Rune() { - case 'j': - if s.filterSelected < len(s.filterFiltered)-1 { - s.filterSelected++ - s.filterEnsureVisible() - s.draw() - } - case 'k': - if s.filterSelected > 0 { - s.filterSelected-- - s.filterEnsureVisible() - s.draw() - } - case '/': - s.filterSearching = true - s.filterQuery = "" - s.draw() - } - } -} - -func (s *Multiplexer) handleFilterSearchKey(evt *tcell.EventKey) { - switch evt.Key() { - case tcell.KeyEscape: - s.filterSearching = false - s.filterQuery = "" - s.refilterOptions() - s.draw() - case tcell.KeyEnter: - if len(s.filterFiltered) == 1 { - value := s.filterOptions[s.filterFiltered[0]].Value - selected := s.selectedProcess() - if selected != nil && selected.filter == value { - value = "" - } - s.applyFilter(value) - s.filtering = false - s.filterSearching = false - s.draw() - return - } - s.filterSearching = false - s.draw() - case tcell.KeyBackspace, tcell.KeyBackspace2: - if len(s.filterQuery) > 0 { - s.filterQuery = s.filterQuery[:len(s.filterQuery)-1] - s.refilterOptions() - s.draw() - } - case tcell.KeyRune: - s.filterQuery += string(evt.Rune()) - s.refilterOptions() - s.draw() - } -} - -func (s *Multiplexer) refilterOptions() { - q := strings.ToLower(s.filterQuery) - s.filterFiltered = s.filterFiltered[:0] - for i, opt := range s.filterOptions { - if q == "" || strings.Contains(strings.ToLower(opt.Label), q) || strings.Contains(strings.ToLower(opt.Description), q) { - s.filterFiltered = append(s.filterFiltered, i) - } - } - if s.filterSelected >= len(s.filterFiltered) { - s.filterSelected = max(0, len(s.filterFiltered)-1) - } - s.filterEnsureVisible() -} - -func (s *Multiplexer) filterVisibleRows() int { - // header (y=0) + blank + subtitle (y=2) + blank + ↑/blank (y=4) = list starts at y=5 - // reserve 1 row at bottom for ↓ indicator + 6 rows padding - rows := s.mainHeight() - 5 - 1 - 6 - if rows < 1 { - rows = 1 - } - return rows -} - -func (s *Multiplexer) filterEnsureVisible() { - visible := s.filterVisibleRows() - if s.filterSelected < s.filterScroll { - s.filterScroll = s.filterSelected - } - if s.filterSelected >= s.filterScroll+visible { - s.filterScroll = s.filterSelected - visible + 1 - } - if s.filterScroll < 0 { - s.filterScroll = 0 - } -} - -func (s *Multiplexer) clearPaneFilter(p *pane) { - if p.filter == "" { - return - } - p.filter = "" - if p.OnFilterChanged != nil { - p.OnFilterChanged("") - } - s.draw() -} - -func (s *Multiplexer) applyFilter(value string) { - selected := s.selectedProcess() - if selected == nil { - return - } - if selected.filter == value { - return - } - selected.filter = value - if selected.OnFilterChanged != nil { - selected.OnFilterChanged(value) - } -} - -type EventExit struct { - when time.Time -} - -func (e *EventExit) When() time.Time { - return e.when -} - -func (s *Multiplexer) Exit() { - s.screen.PostEvent(&EventExit{}) -} - -type EventCheckFilter struct { - tcell.EventTime - PaneKey string - Names []string -} - -func (s *Multiplexer) CheckFilter(paneKey string, names []string) { - s.screen.PostEvent(&EventCheckFilter{PaneKey: paneKey, Names: names}) -} - -func (s *Multiplexer) stopAutoScroll() { - if s.scrollTicker != nil { - s.scrollTicker.Stop() - close(s.scrollDone) - s.scrollTicker = nil - s.scrollDone = nil - s.scrollDir = 0 - } -} - -func (s *Multiplexer) startAutoScroll(dir int) { - if s.scrollDir == dir && s.scrollTicker != nil { - return - } - s.stopAutoScroll() - s.scrollDir = dir - s.scrollTicker = time.NewTicker(50 * time.Millisecond) - s.scrollDone = make(chan struct{}) - go func() { - for { - select { - case <-s.scrollDone: - return - case <-s.scrollTicker.C: - s.screen.PostEvent(tcell.NewEventInterrupt(nil)) - } - } - }() -} - -func (s *Multiplexer) scrollDown(n int) { - selected := s.selectedProcess() - if selected == nil { - return - } - selected.scrollDown(n) - s.draw() - s.screen.Sync() -} - -func (s *Multiplexer) scrollUp(n int) { - selected := s.selectedProcess() - if selected == nil { - return - } - selected.scrollUp(n) - s.draw() -} - -func (s *Multiplexer) copy() { - selected := s.selectedProcess() - if selected == nil { - return - } - data := selected.vt.Copy() - if data == "" { - return - } - // check if mac terminal - if os.Getenv("TERM_PROGRAM") == "Apple_Terminal" { - // use pbcopy - cmd := process.Command("pbcopy") - cmd.Stdin = strings.NewReader(data) - err := cmd.Run() - if err != nil { - fmt.Fprintf(os.Stderr, "failed to copy to clipboard: %v\n", err) - } - return - } - encoded := base64.StdEncoding.EncodeToString([]byte(data)) - fmt.Fprintf(os.Stdout, "\x1b]52;c;%s\x07", encoded) -} diff --git a/cmd/sst/mosaic/multiplexer/process.go b/cmd/sst/mosaic/multiplexer/process.go deleted file mode 100644 index c929bbfaa3..0000000000 --- a/cmd/sst/mosaic/multiplexer/process.go +++ /dev/null @@ -1,90 +0,0 @@ -package multiplexer - -import ( - "os/exec" - - "github.com/gdamore/tcell/v2" - tcellterm "github.com/sst/sst/v3/cmd/sst/mosaic/multiplexer/tcell-term" - "github.com/sst/sst/v3/pkg/process" -) - -type PaneConfig struct { - Key string - Args []string - Icon string - Title string - Cwd string - Killable bool - Autostart bool - Env []string - Filterable bool - FilterTitle string - FilterSubtitle string - ListOptions func() []FilterOption - OnFilterChanged func(string) -} - -type pane struct { - PaneConfig - filterAvailable bool - vt *tcellterm.VT - dead bool - cmd *exec.Cmd - filter string -} - -type EventProcess struct { - tcell.EventTime - PaneConfig -} - -func (s *Multiplexer) AddProcess(cfg PaneConfig) { - s.screen.PostEventWait(&EventProcess{ - PaneConfig: cfg, - }) -} - -func (p *pane) start() error { - p.cmd = process.Command(p.Args[0], p.Args[1:]...) - p.cmd.Env = p.Env - if p.Cwd != "" { - p.cmd.Dir = p.Cwd - } - p.vt.Clear() - err := p.vt.Start(p.cmd) - if err != nil { - return err - } - p.dead = false - return nil -} - -func (p *pane) Kill() { - p.vt.Close() -} - -func (s *pane) scrollUp(offset int) { - s.vt.ScrollUp(offset) -} - -func (s *pane) scrollDown(offset int) { - s.vt.ScrollDown(offset) -} - -func (s *pane) scrollReset() { - s.vt.ScrollReset() -} - -func (s *pane) isScrolling() bool { - return s.vt.IsScrolling() -} - -func (s *pane) scrollable() bool { - return s.vt.Scrollable() -} - -func (s *pane) Clear() { - s.vt.Clear() - s.vt.ScrollReset() - s.vt.ClearScrollback() -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/LICENSE b/cmd/sst/mosaic/multiplexer/tcell-term/LICENSE deleted file mode 100644 index 677ccc536c..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) 2023 Tim Culverhouse - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/c0.go b/cmd/sst/mosaic/multiplexer/tcell-term/c0.go deleted file mode 100644 index 7bcd00cff8..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/c0.go +++ /dev/null @@ -1,72 +0,0 @@ -package tcellterm - -func (vt *VT) c0(r rune) { - switch r { - case 0x07: - vt.postEvent(EventBell{ - EventTerminal: newEventTerminal(vt), - }) - case 0x08: - vt.bs() - case 0x09: - vt.ht() - case 0x0A: - vt.lf() - case 0x0B: - vt.vt() - case 0x0C: - vt.ff() - case 0x0D: - vt.cr() - case 0x0E: - vt.charsets.selected = g1 - case 0x0F: - vt.charsets.selected = g2 - } -} - -// Backspace 0x08 -func (vt *VT) bs() { - vt.lastCol = false - if vt.cursor.col == vt.margin.left { - if vt.cursor.row == vt.margin.top { - return - } - // reverse wrap - vt.cursor.col = vt.margin.right - vt.cursor.row -= 1 - return - } - vt.cursor.col -= 1 -} - -// Horizontal tab 0x09 -func (vt *VT) ht() { - vt.cht(1) -} - -// Linefeed 0x10 -func (vt *VT) lf() { - vt.ind() - - if vt.mode&lnm != lnm { - return - } - vt.cursor.col = vt.margin.left -} - -// Vertical tabulation 0x11 -func (vt *VT) vt() { - vt.lf() -} - -// Form feed 0x12 -func (vt *VT) ff() { - vt.lf() -} - -// Carriage return 0x13 -func (vt *VT) cr() { - vt.lastCol = false - vt.cursor.col = vt.margin.left -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/c0_test.go b/cmd/sst/mosaic/multiplexer/tcell-term/c0_test.go deleted file mode 100644 index 6daea85d55..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/c0_test.go +++ /dev/null @@ -1,65 +0,0 @@ -package tcellterm - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestBS(t *testing.T) { - vt := New() - vt.Resize(4, 1) - vt.cursor.col = 1 - vt.bs() - assert.Equal(t, column(0), vt.cursor.col) - vt.bs() - assert.Equal(t, column(0), vt.cursor.col) -} - -func TestLF(t *testing.T) { - t.Run("LNM reset", func(t *testing.T) { - vt := New() - vt.Resize(2, 2) - vt.print('v') - vt.print('t') - assert.Equal(t, "vt\n ", vt.String()) - vt.lf() - assert.Equal(t, "vt\n ", vt.String()) - assert.Equal(t, column(1), vt.cursor.col) - assert.Equal(t, row(1), vt.cursor.row) - }) - - t.Run("LNM set", func(t *testing.T) { - vt := New() - vt.Resize(2, 2) - vt.print('v') - vt.print('t') - assert.Equal(t, "vt\n ", vt.String()) - vt.mode |= lnm - vt.lf() - assert.Equal(t, "vt\n ", vt.String()) - assert.Equal(t, column(0), vt.cursor.col) - assert.Equal(t, row(1), vt.cursor.row) - - vt.print('x') - vt.lf() - assert.Equal(t, "x \n ", vt.String()) - assert.Equal(t, column(0), vt.cursor.col) - assert.Equal(t, row(1), vt.cursor.row) - }) -} - -// // Linefeed 0x10 -// func (vt *vt) LF() { -// switch { -// case vt.cursor.row == vt.margin.bottom: -// vt.ScrollUp(1) -// default: -// vt.cursor.row += 1 -// } -// -// if vt.mode&LNM != LNM { -// return -// } -// vt.cursor.col = vt.margin.left -// } diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/cell.go b/cmd/sst/mosaic/multiplexer/tcell-term/cell.go deleted file mode 100644 index fc32b8a324..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/cell.go +++ /dev/null @@ -1,33 +0,0 @@ -package tcellterm - -import "github.com/gdamore/tcell/v2" - -type cell struct { - content rune - combining []rune - width int - attrs tcell.Style - wrapped bool -} - -func (c *cell) rune() rune { - if c.content == rune(0) { - return ' ' - } - return c.content -} - -// Erasing removes characters from the screen without affecting other characters -// on the screen. Erased characters are lost. The cursor position does not -// change when erasing characters or lines. Erasing resets the attributes, but -// applies the background color of the passed style -func (c *cell) erase(s tcell.Style) { - _, bg, _ := s.Decompose() - c.content = 0 - c.attrs = tcell.StyleDefault.Background(bg) -} - -// selectiveErase removes the cell content, but keeps the attributes -func (c *cell) selectiveErase() { - c.content = 0 -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/charset.go b/cmd/sst/mosaic/multiplexer/tcell-term/charset.go deleted file mode 100644 index 058aa0e58f..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/charset.go +++ /dev/null @@ -1,59 +0,0 @@ -package tcellterm - -type charset int - -const ( - ascii charset = iota - decSpecialAndLineDrawing -) - -type charsets struct { - selected charsetDesignator - saved charsetDesignator - designations map[charsetDesignator]charset - singleShift bool -} - -type charsetDesignator int - -const ( - g0 = iota - g1 - g2 - g3 -) - -var decSpecial = map[rune]rune{ - 0x5f: 0x00A0, // NO-BREAK SPACE - 0x60: 0x25C6, // BLACK DIAMOND - 0x61: 0x2592, // MEDIUM SHADE - 0x62: 0x2409, // SYMBOL FOR HORIZONTAL TABULATION - 0x63: 0x240C, // SYMBOL FOR FORM FEED - 0x64: 0x240D, // SYMBOL FOR CARRIAGE RETURN - 0x65: 0x240A, // SYMBOL FOR LINE FEED - 0x66: 0x00B0, // DEGREE SIGN - 0x67: 0x00B1, // PLUS-MINUS SIGN - 0x68: 0x2424, // SYMBOL FOR NEWLINE - 0x69: 0x240B, // SYMBOL FOR VERTICAL TABULATION - 0x6a: 0x2518, // BOX DRAWINGS LIGHT UP AND LEFT - 0x6b: 0x2510, // BOX DRAWINGS LIGHT DOWN AND LEFT - 0x6c: 0x250C, // BOX DRAWINGS LIGHT DOWN AND RIGHT - 0x6d: 0x2514, // BOX DRAWINGS LIGHT UP AND RIGHT - 0x6e: 0x253C, // BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL - 0x6f: 0x23BA, // HORIZONTAL SCAN LINE-1 - 0x70: 0x23BB, // HORIZONTAL SCAN LINE-3 - 0x71: 0x2500, // BOX DRAWINGS LIGHT HORIZONTAL - 0x72: 0x23BC, // HORIZONTAL SCAN LINE-7 - 0x73: 0x23BD, // HORIZONTAL SCAN LINE-9 - 0x74: 0x251C, // BOX DRAWINGS LIGHT VERTICAL AND RIGHT - 0x75: 0x2524, // BOX DRAWINGS LIGHT VERTICAL AND LEFT - 0x76: 0x2534, // BOX DRAWINGS LIGHT UP AND HORIZONTAL - 0x77: 0x252C, // BOX DRAWINGS LIGHT DOWN AND HORIZONTAL - 0x78: 0x2502, // BOX DRAWINGS LIGHT VERTICAL - 0x79: 0x2264, // LESS-THAN OR EQUAL TO - 0x7a: 0x2265, // GREATER-THAN OR EQUAL TO - 0x7b: 0x03C0, // GREEK SMALL LETTER PI - 0x7c: 0x2260, // NOT EQUAL TO - 0x7d: 0x00A3, // POUND SIGN - 0x7e: 0x00B7, // MIDDLE DOT -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/csi.go b/cmd/sst/mosaic/multiplexer/tcell-term/csi.go deleted file mode 100644 index fe2d6ee31e..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/csi.go +++ /dev/null @@ -1,634 +0,0 @@ -package tcellterm - -import ( - "fmt" - "strings" - - "github.com/gdamore/tcell/v2" -) - -func (vt *VT) csi(csi string, params []int) { - switch csi { - case "@": - vt.ich(ps(params)) - case "A": - vt.cuu(ps(params)) - case "B": - vt.cud(ps(params)) - case "C": - vt.cuf(ps(params)) - case "D": - vt.cub(ps(params)) - case "E": - vt.cnl(ps(params)) - case "F": - vt.cpl(ps(params)) - case "G": - vt.cha(ps(params)) - case "H": - vt.cup(params) - case "I": - vt.cht(ps(params)) - case "J": - vt.ed(ps(params)) - case "K": - vt.el(ps(params)) - case "L": - vt.il(ps(params)) - case "M": - vt.dl(ps(params)) - case "P": - vt.dch(ps(params)) - case "S": - ps := ps(params) - if ps == 0 { - ps = 1 - } - vt.scrollUp(ps) - case "T": - // 5 params is XTHIMOUSE, ignore - if len(params) == 5 { - return - } - ps := ps(params) - if ps == 0 { - ps = 1 - } - vt.scrollDown(ps) - case "X": - vt.ech(ps(params)) - case "Z": - vt.cbt(ps(params)) - case "`": - vt.hpa(ps(params)) - case "a": - vt.hpr(ps(params)) - case "b": - vt.rep(ps(params)) - case "c": - // Send device attributes - resp := strings.Builder{} - // Response introducer - resp.WriteString("\x1B[?") - // We are a vt220 - resp.WriteString("62;") - // We have sixel support - resp.WriteString("4;") - // We have ANSI color support - resp.WriteString("22") - // Response terminator - resp.WriteString("c") - vt.pty.WriteString(resp.String()) - case "d": - vt.vpa(ps(params)) - case "e": - vt.vpr(ps(params)) - case "f": - // Same as CUP - vt.cup(params) - case "g": - vt.tbc(ps(params)) - case "h": - vt.sm(params) - case "?h": - vt.decset(params) - case "l": - vt.rm(params) - case "?l": - vt.decrst(params) - case "m": - vt.sgr(params) - case "n": - // Send device status report - switch ps(params) { - case 5: - // "Ok" - vt.pty.WriteString("\x1B[0n") - case 6: - // report cursor position - // This sequence can be identical to a function key? - // CSI r ; c R - resp := fmt.Sprintf("\x1B[%d;%dR", vt.cursor.row+1, vt.cursor.col+1) - vt.pty.WriteString(resp) - } - case "r": - vt.decstbm(params) - case "s": - vt.decsc() - case "u": - vt.decrc() - case " q": - ps(params) - vt.cursor.style = tcell.CursorStyle(ps(params)) - } -} - -// Returns a single parameter from a slice of parameters, or 0 if the slice is -// empty -func ps(params []int) int { - var ps int - if len(params) > 0 { - ps = params[0] - } - return ps -} - -// Insert Blank Character (ICH) CSI Ps @ -// Insert Ps blank characters. Cursor does not change position. -func (vt *VT) ich(ps int) { - if ps == 0 { - ps = 1 - } - col := vt.cursor.col - row := vt.cursor.row - line := vt.activeScreen[row] - for i := vt.margin.right; i > col; i -= 1 { - if col+i > column(vt.width()-1) { - break - } - if (i - column(ps)) < 0 { - continue - } - line[i] = line[i-column(ps)] - } - for i := 0; i < ps; i += 1 { - if int(col)+i >= (vt.width() - 1) { - break - } - line[col+column(i)] = cell{ - content: ' ', - width: 1, - } - } -} - -// Cursur Up (CUU) CSI Ps A -// Move cursor up in same column, stopping at top margin -func (vt *VT) cuu(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - clamp := row(0) - if vt.cursor.row >= vt.margin.top { - clamp = vt.margin.top - } - vt.cursor.row -= row(ps) - if vt.cursor.row < clamp { - vt.cursor.row = clamp - } -} - -// Cursur Down (CUD) CSI Ps B -// Move cursor down in same column, stopping at bottom margin -func (vt *VT) cud(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - vt.cursor.row += row(ps) - if vt.cursor.row > vt.margin.bottom { - vt.cursor.row = vt.margin.bottom - } -} - -// Cursur Forward (CUF) CSI Ps C -// Move cursor forward Ps columns, stopping at the right margin -func (vt *VT) cuf(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - vt.cursor.col += column(ps) - if vt.cursor.col > vt.margin.right { - vt.cursor.col = vt.margin.right - } -} - -// Cursur Backward (CUB) CSI Ps D -// Move cursor backward Ps columns, stopping at the left margin -func (vt *VT) cub(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - vt.cursor.col -= column(ps) - if vt.cursor.col < vt.margin.left { - vt.cursor.col = vt.margin.left - } -} - -// Cursor Next Line (CNL) CSI Ps E -// Move cursor to left margin Ps lines down, scrolling if necessary -func (vt *VT) cnl(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - for i := 0; i < ps; i += 1 { - vt.nel() - } -} - -// Cursor Preceding Line (CPL) CSI Ps F -// Move cursor to left margin Ps lines down, scrolling if necessary -func (vt *VT) cpl(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - for i := 0; i < ps; i += 1 { - vt.ri() - } - vt.cursor.col = vt.margin.left -} - -// Cursor Character Absolute (CHA) CSI Ps G -// Move cursor to Ps column, stopping at right/left margin. Default is 1, but we -// default to 0 since our columns our 0 indexed -func (vt *VT) cha(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - vt.cursor.col = column(ps - 1) - if vt.cursor.col > vt.margin.right { - vt.cursor.col = vt.margin.right - } - if vt.cursor.col < vt.margin.left { - vt.cursor.col = vt.margin.left - } -} - -// Cursor Position (CUP) CSI Ps;Ps H -// Move cursor to the absolute position -func (vt *VT) cup(pm []int) { - vt.lastCol = false - switch len(pm) { - case 0: - pm = []int{1, 1} - case 1: - pm = []int{pm[0], 1} - case 2: - default: - return - } - vt.cursor.row = row(pm[0] - 1) - vt.cursor.col = column(pm[1] - 1) - if vt.cursor.col > column(vt.width()-1) { - vt.cursor.col = column(vt.width() - 1) - } - if vt.cursor.row > row(vt.height()-1) { - vt.cursor.row = row(vt.height() - 1) - } -} - -// Cursor Forward Tabulation (CHT) CSI Ps I -// Move cursor forward Ps tab stops -func (vt *VT) cht(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - n := 0 - for _, ts := range vt.tabStop { - if n == ps { - break - } - if vt.cursor.col > ts { - continue - } - vt.cursor.col = ts - n += 1 - } -} - -// Erase in Display (ED) CSI Ps J -func (vt *VT) ed(ps int) { - switch ps { - - // Erases from the cursor to the end of the screen, including the cursor - // position. Line attribute becomes single-height, single-width for all - // completely erased lines. - case 0: - vt.lastCol = false - for r := vt.cursor.row; r < row(vt.height()); r += 1 { - for col := column(0); col < column(vt.width()); col += 1 { - if r == vt.cursor.row && col < vt.cursor.col { - // Don't erase current row before cursor - continue - } - vt.activeScreen[r][col].erase(vt.cursor.attrs) - } - } - - // Erases from the beginning of the screen to the cursor, including the - // cursor position. Line attribute becomes single-height, single-width - // for all completely erased lines. - case 1: - vt.lastCol = false - for r := row(0); r <= vt.cursor.row; r += 1 { - for col := column(0); col < column(vt.width()); col += 1 { - if r == vt.cursor.row && col > vt.cursor.col { - // Don't erase current row after current - // column - break - } - vt.activeScreen[r][col].erase(vt.cursor.attrs) - } - } - - // Erases the complete display. All lines are erased and changed to - // single-width. The cursor does not move. - case 2: - vt.lastCol = false - for r := row(0); r < row(vt.height()); r += 1 { - for col := column(0); col < column(vt.width()); col += 1 { - vt.activeScreen[r][col].erase(vt.cursor.attrs) - } - } - } -} - -// Erase in Line (EL) CSI Ps K -func (vt *VT) el(ps int) { - r := vt.cursor.row - vt.lastCol = false - switch ps { - // Erases from the cursor to the end of the line, including the cursor - // position. Line attribute is not affected. - case 0: - for col := vt.cursor.col; col < column(vt.width()); col += 1 { - vt.activeScreen[r][col].erase(vt.cursor.attrs) - } - - // Erases from the beginning of the line to the cursor, including the - // cursor position. Line attribute is not affected. - case 1: - for col := column(0); col <= vt.cursor.col; col += 1 { - vt.activeScreen[r][col].erase(vt.cursor.attrs) - } - - // Erases the complete line. - case 2: - for col := column(0); col < column(vt.width()); col += 1 { - vt.activeScreen[r][col].erase(vt.cursor.attrs) - } - } -} - -// Insert Lines (IL) CSI Ps L -// -// Insert Ps lines at the cursor. If fewer than Ps lines remain from the current -// line to the end of the scrolling region, the number of lines inserted is the -// lesser number. Lines within the scrolling region at and below the cursor move -// down. Lines moved past the bottom margin are lost. The cursor is reset to the -// first column. This sequence is ignored when the cursor is outside the -// scrolling region. -func (vt *VT) il(ps int) { - vt.lastCol = false - if vt.cursor.row < vt.margin.top { - return - } - if vt.cursor.row > vt.margin.bottom { - return - } - if vt.cursor.col < vt.margin.left { - return - } - if vt.cursor.col > vt.margin.right { - return - } - - if ps == 0 { - ps = 1 - } - - if int(vt.margin.bottom-vt.cursor.row) < (ps - 1) { - ps = int(vt.margin.bottom - vt.cursor.row) - } - - // move the lines first - for r := vt.margin.bottom; r >= (vt.cursor.row + row(ps)); r -= 1 { - copy(vt.activeScreen[r], vt.activeScreen[r-row(ps)]) - } - - // insert the blank lines (we do this by erasing the cells) - for r := row(0); r < row(ps); r += 1 { - for col := vt.margin.left; col <= vt.margin.right; col += 1 { - vt.activeScreen[vt.cursor.row+r][col].erase(vt.cursor.attrs) - } - } - vt.cursor.col = vt.margin.left -} - -// Delete Line (DL) CSI Ps M -// -// Deletes Ps lines starting at the line with the cursor. If fewer than Ps lines -// remain from the current line to the end of the scrolling region, the number -// of lines deleted is the lesser number. As lines are deleted, lines within the -// scrolling region and below the cursor move up, and blank lines are added at -// the bottom of the scrolling region. The cursor is reset to the first column. -// This sequence is ignored when the cursor is outside the scrolling region. -func (vt *VT) dl(ps int) { - vt.lastCol = false - if vt.cursor.row < vt.margin.top { - return - } - if vt.cursor.row > vt.margin.bottom { - return - } - if vt.cursor.col < vt.margin.left { - return - } - if vt.cursor.col > vt.margin.right { - return - } - - if ps == 0 { - ps = 1 - } - - if int(vt.margin.bottom-vt.cursor.row) < (ps - 1) { - ps = int(vt.margin.bottom - vt.cursor.row) - } - - for r := vt.cursor.row; r <= vt.margin.bottom; r += 1 { - if r <= vt.margin.bottom-row(ps) { - copy(vt.activeScreen[r], vt.activeScreen[r+row(ps)]) - continue - } - for col := vt.margin.left; col <= vt.margin.right; col += 1 { - vt.activeScreen[r][col].erase(vt.cursor.attrs) - } - } - vt.cursor.col = vt.margin.left -} - -// Delete Characters (DCH) CSI Ps P -// -// Deletes Ps characters starting with the character at the cursor position. -// When a character is deleted, all characters to the right of the cursor move -// to the left. This creates a space character at the right margin for each -// character deleted. Character attributes move with the characters. The spaces -// created at the end of the line have all their character attributes off. -func (vt *VT) dch(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - row := vt.cursor.row - for col := vt.cursor.col; col <= vt.margin.right; col += 1 { - if col+column(ps) > vt.margin.right { - vt.activeScreen[row][col].erase(vt.cursor.attrs) - continue - } - vt.activeScreen[row][col] = vt.activeScreen[row][col+column(ps)] - } -} - -// Erase Characters (ECH) CSI Ps X -// -// Erases characters at the cursor position and the next Ps-1 characters. A -// parameter of 0 or 1 erases a single character. Character attributes are set -// to normal. No reformatting of data on the line occurs. The cursor remains in -// the same position. -func (vt *VT) ech(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - - for i := column(0); i < column(ps); i += 1 { - if vt.cursor.col+i == column(vt.width())-1 { - return - } - vt.activeScreen[vt.cursor.row][vt.cursor.col+i].erase(vt.cursor.attrs) - } -} - -// Cursor Backward Tabulation (CBT) CSI Ps Z -// -// Move cursor backward Ps tabulations -func (vt *VT) cbt(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - n := 0 - for i := len(vt.tabStop) - 1; i >= 0; i -= 1 { - if n == ps { - break - } - if vt.cursor.col < vt.tabStop[i] { - break - } - vt.cursor.col = vt.tabStop[i] - n += 1 - } -} - -// Tab Clear (TBC) CSI Ps g -func (vt *VT) tbc(ps int) { - switch ps { - case 0: - tabs := []column{} - for _, tab := range vt.tabStop { - if tab == vt.cursor.col { - continue - } - tabs = append(tabs, tab) - } - vt.tabStop = tabs - case 3: - vt.tabStop = []column{} - } -} - -// Line Position Absolute (VPA) CSI Ps d -// -// Move cursor to line Ps -func (vt *VT) vpa(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - vt.cursor.row = row(ps - 1) - if vt.cursor.row > row(vt.height()-1) { - vt.cursor.row = row(vt.height() - 1) - } -} - -// Line Position Relative (VPR) CSI Ps e -// -// Move down Ps lines -func (vt *VT) vpr(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - vt.cursor.row += row(ps) - if vt.cursor.row > row(vt.height()-1) { - vt.cursor.row = row(vt.height() - 1) - } -} - -// Character Position Absolute (HPA) CSI Ps ` -// -// Move cursor to column Ps -func (vt *VT) hpa(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - vt.cursor.col = column(ps - 1) - if vt.cursor.col > column(vt.width()-1) { - vt.cursor.col = column(vt.width() - 1) - } -} - -// Character Position Relative (HPR) CSI Ps a -// -// Move cursor to the right Ps times -func (vt *VT) hpr(ps int) { - vt.lastCol = false - if ps == 0 { - ps = 1 - } - vt.cursor.col += column(ps) - if vt.cursor.col > column(vt.width()-1) { - vt.cursor.col = column(vt.width() - 1) - } -} - -// Repeat (REP) CSI Ps b -// -// Repeat preceding graphic character Ps times -func (vt *VT) rep(ps int) { - vt.lastCol = false - col := vt.cursor.col - if col == 0 { - return - } - ch := vt.activeScreen[vt.cursor.row][col-1] - for i := 0; i < ps; i += 1 { - if col+column(i) == vt.margin.right { - return - } - vt.activeScreen[vt.cursor.row][vt.cursor.col+column(i)].content = ch.content - } -} - -// Set top and bottom margins CSI Ps ; Ps r -func (vt *VT) decstbm(pm []int) { - vt.lastCol = false - if len(pm) != 2 { - vt.margin.top = 0 - vt.margin.bottom = row(vt.height()) - 1 - return - } - vt.margin.top = row(pm[0]) - 1 - vt.margin.bottom = row(pm[1]) - 1 - vt.cursor.row = 0 - vt.cursor.col = 0 -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/csi_test.go b/cmd/sst/mosaic/multiplexer/tcell-term/csi_test.go deleted file mode 100644 index cc4a076000..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/csi_test.go +++ /dev/null @@ -1,105 +0,0 @@ -package tcellterm - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestICH(t *testing.T) { - vt := New() - vt.Resize(2, 1) - vt.mode = 0 - - vt.print('a') - vt.print('b') - assert.Equal(t, "ab", vt.String()) - vt.cursor.col = 0 - vt.ich(0) - assert.Equal(t, " a", vt.String()) - assert.Equal(t, column(0), vt.cursor.col) -} - -func TestCUU(t *testing.T) { - vt := New() - vt.Resize(2, 2) - - vt.cursor.row = 1 - vt.cursor.col = 1 - assert.Equal(t, column(1), vt.cursor.col) - assert.Equal(t, row(1), vt.cursor.row) - vt.cuu(0) - - assert.Equal(t, row(0), vt.cursor.row) - assert.Equal(t, column(1), vt.cursor.col) - vt.cuu(0) - assert.Equal(t, row(0), vt.cursor.row) - assert.Equal(t, column(1), vt.cursor.col) -} - -func TestIL(t *testing.T) { - vt := New() - vt.Resize(2, 2) - vt.print('a') - vt.print('b') - vt.cursor.col = 0 - vt.cursor.row = 0 - - vt.il(1) - assert.Equal(t, " \nab", vt.String()) - - vt = New() - vt.Resize(2, 2) - vt.print('a') - vt.print('b') - vt.cursor.col = 0 - vt.cursor.row = 0 - - vt.il(2) - assert.Equal(t, " \n ", vt.String()) -} - -func TestDL(t *testing.T) { - vt := New() - vt.Resize(2, 2) - vt.cursor.row = 1 - vt.print('a') - vt.print('b') - assert.Equal(t, " \nab", vt.String()) - vt.cursor.col = 0 - vt.cursor.row = 0 - - vt.dl(1) - assert.Equal(t, "ab\n ", vt.String()) - - vt = New() - vt.Resize(2, 2) - vt.cursor.row = 1 - vt.print('a') - vt.print('b') - assert.Equal(t, " \nab", vt.String()) - vt.cursor.col = 0 - vt.cursor.row = 0 - vt.dl(2) - assert.Equal(t, " \n ", vt.String()) -} - -func TestDCH(t *testing.T) { - vt := New() - vt.Resize(4, 1) - vt.print('a') - vt.print('b') - vt.print('c') - vt.print('d') - assert.Equal(t, "abcd", vt.String()) - - vt.dch(1) - assert.Equal(t, "abc ", vt.String()) - vt.dch(2) - assert.Equal(t, "abc ", vt.String()) - vt.print('d') - assert.Equal(t, "abcd", vt.String()) - vt.cursor.col = 1 - vt.dch(2) - assert.Equal(t, "ad ", vt.String()) -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/cursor.go b/cmd/sst/mosaic/multiplexer/tcell-term/cursor.go deleted file mode 100644 index d5ae235fa1..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/cursor.go +++ /dev/null @@ -1,14 +0,0 @@ -package tcellterm - -import ( - "github.com/gdamore/tcell/v2" -) - -type cursor struct { - attrs tcell.Style - style tcell.CursorStyle - - // position - row row // 0-indexed - col column // 0-indexed -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/esc.go b/cmd/sst/mosaic/multiplexer/tcell-term/esc.go deleted file mode 100644 index fde23ecae3..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/esc.go +++ /dev/null @@ -1,187 +0,0 @@ -package tcellterm - -func (vt *VT) esc(esc string) { - switch esc { - case "7": - vt.decsc() - case "8": - vt.decrc() - case "D": - vt.ind() - case "E": - vt.nel() - case "H": - vt.hts() - case "M": - vt.ri() - case "N": - vt.charsets.singleShift = true - vt.charsets.selected = g2 - case "O": - vt.charsets.singleShift = true - vt.charsets.selected = g3 - case "=": - // DECKPAM - case ">": - // DECKPNM - case "c": - vt.ris() - case "(0": - vt.charsets.designations[g0] = decSpecialAndLineDrawing - case ")0": - vt.charsets.designations[g1] = decSpecialAndLineDrawing - case "*0": - vt.charsets.designations[g2] = decSpecialAndLineDrawing - case "+0": - vt.charsets.designations[g3] = decSpecialAndLineDrawing - case "(B": - vt.charsets.designations[g0] = ascii - case ")B": - vt.charsets.designations[g1] = ascii - case "*B": - vt.charsets.designations[g2] = ascii - case "+B": - vt.charsets.designations[g3] = ascii - case "#8": - // DECALN - // Fill the screen with capital Es - // Not supported - } -} - -// Index ESC-D -func (vt *VT) ind() { - vt.lastCol = false - if vt.cursor.row == vt.margin.bottom { - vt.scrollUp(1) - return - } - if vt.cursor.row >= row(vt.height()-1) { - // don't let row go beyond the height - - return - } - vt.cursor.row += 1 -} - -// Next line ESC-E -// Moves cursor to the left margin of the next line, scrolling if necessary -func (vt *VT) nel() { - vt.ind() - vt.cursor.col = vt.margin.left -} - -// Horizontal tab set ESC-H -func (vt *VT) hts() { - vt.tabStop = append(vt.tabStop, vt.cursor.col) -} - -// Reverse Index ESC-M -func (vt *VT) ri() { - vt.lastCol = false - if vt.cursor.row < 0 { - return - } - if vt.cursor.row == vt.margin.top { - vt.scrollDown(1) - return - } - vt.cursor.row -= 1 -} - -// Save Cursor DECSC ESC-7 -func (vt *VT) decsc() { - state := cursorState{ - cursor: vt.cursor, - decawm: vt.mode&decawm != 0, - decom: vt.mode&decom != 0, - charsets: charsets{ - selected: vt.charsets.selected, - saved: vt.charsets.saved, - designations: map[charsetDesignator]charset{ - g0: vt.charsets.designations[g0], - g1: vt.charsets.designations[g1], - g2: vt.charsets.designations[g2], - g3: vt.charsets.designations[g3], - }, - }, - } - switch { - case vt.mode&smcup != 0: - // We are in alt screen - vt.altState = state - default: - vt.primaryState = state - } -} - -// Restore Cursor DECRC ESC-8 -func (vt *VT) decrc() { - var state cursorState - switch { - case vt.mode&smcup != 0: - // In the alt screen - state = vt.altState - default: - state = vt.primaryState - } - - vt.cursor = state.cursor - vt.charsets = charsets{ - selected: state.charsets.selected, - saved: state.charsets.saved, - designations: map[charsetDesignator]charset{ - g0: state.charsets.designations[g0], - g1: state.charsets.designations[g1], - g2: state.charsets.designations[g2], - g3: state.charsets.designations[g3], - }, - } - - switch state.decawm { - case true: - vt.mode |= decawm - case false: - vt.mode &^= decawm - } - - switch state.decom { - case true: - vt.mode |= decom - case false: - vt.mode &^= decom - } -} - -// Reset Initial State (RIS) ESC-c -func (vt *VT) ris() { - w := vt.width() - h := vt.height() - vt.altScreen = make([][]cell, h) - vt.primaryScreen = make([][]cell, h) - for i := range vt.altScreen { - vt.altScreen[i] = make([]cell, w) - vt.primaryScreen[i] = make([]cell, w) - } - vt.margin.bottom = row(h) - 1 - vt.margin.right = column(w) - 1 - vt.cursor.row = 0 - vt.cursor.col = 0 - vt.lastCol = false - vt.activeScreen = vt.primaryScreen - vt.charsets = charsets{ - selected: 0, - saved: 0, - designations: map[charsetDesignator]charset{ - g0: ascii, - g1: ascii, - g2: ascii, - g3: ascii, - }, - } - vt.mode = decawm | dectcem - vt.tabStop = []column{} - for i := 7; i < (50 * 7); i += 8 { - vt.tabStop = append(vt.tabStop, column(i)) - } -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/events.go b/cmd/sst/mosaic/multiplexer/tcell-term/events.go deleted file mode 100644 index 2072741984..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/events.go +++ /dev/null @@ -1,69 +0,0 @@ -package tcellterm - -import ( - "time" - - "github.com/gdamore/tcell/v2" -) - -// EventTerminal is a generic terminal event -type EventTerminal struct { - when time.Time - vt *VT -} - -func newEventTerminal(vt *VT) *EventTerminal { - return &EventTerminal{ - when: time.Now(), - vt: vt, - } -} - -func (ev *EventTerminal) When() time.Time { - return ev.when -} - -func (ev *EventTerminal) VT() *VT { - return ev.vt -} - -// EventRedraw is emitted when the terminal requires redrawing -type EventRedraw struct { - *EventTerminal -} - -// EventClosed is emitted when the terminal exits -type EventClosed struct { - *EventTerminal -} - -// EventTitle is emitted when the terminal's title changes -type EventTitle struct { - *EventTerminal - title string -} - -func (ev *EventTitle) Title() string { - return ev.title -} - -// EventMouseMode is emitted when the terminal mouse mode changes -type EventMouseMode struct { - modes []tcell.MouseFlags - - *EventTerminal -} - -func (ev *EventMouseMode) Flags() []tcell.MouseFlags { - return ev.modes -} - -// EventBell is emitted when BEL is received -type EventBell struct { - *EventTerminal -} - -type EventPanic struct { - *EventTerminal - Error error -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/key.go b/cmd/sst/mosaic/multiplexer/tcell-term/key.go deleted file mode 100644 index ec9549533e..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/key.go +++ /dev/null @@ -1,691 +0,0 @@ -package tcellterm - -import ( - "strings" - - "github.com/gdamore/tcell/v2" -) - -func keyCode(ev *tcell.EventKey) string { - key := strings.Builder{} - switch ev.Modifiers() { - case tcell.ModNone: - switch ev.Key() { - case tcell.KeyRune: - key.WriteRune(ev.Rune()) - default: - if str, ok := keyCodes[ev.Key()]; ok { - key.WriteString(str) - } else { - key.WriteRune(rune(ev.Key())) - } - } - case tcell.ModShift: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(info.KeyShfUp) - case tcell.KeyDown: - key.WriteString(info.KeyShfDown) - case tcell.KeyRight: - key.WriteString(info.KeyShfRight) - case tcell.KeyLeft: - key.WriteString(info.KeyShfLeft) - case tcell.KeyHome: - key.WriteString(info.KeyShfHome) - case tcell.KeyEnd: - key.WriteString(info.KeyShfEnd) - case tcell.KeyInsert: - key.WriteString(info.KeyShfInsert) - case tcell.KeyDelete: - key.WriteString(info.KeyShfDelete) - case tcell.KeyPgUp: - key.WriteString(info.KeyShfPgUp) - case tcell.KeyPgDn: - key.WriteString(info.KeyShfPgDn) - case tcell.KeyF1: - key.WriteString(info.KeyF13) - case tcell.KeyF2: - key.WriteString(info.KeyF14) - case tcell.KeyF3: - key.WriteString(info.KeyF15) - case tcell.KeyF4: - key.WriteString(info.KeyF16) - case tcell.KeyF5: - key.WriteString(info.KeyF17) - case tcell.KeyF6: - key.WriteString(info.KeyF18) - case tcell.KeyF7: - key.WriteString(info.KeyF19) - case tcell.KeyF8: - key.WriteString(info.KeyF20) - case tcell.KeyF9: - key.WriteString(info.KeyF21) - case tcell.KeyF10: - key.WriteString(info.KeyF22) - case tcell.KeyF11: - key.WriteString(info.KeyF23) - case tcell.KeyF12: - key.WriteString(info.KeyF24) - } - case tcell.ModAlt: - switch ev.Key() { - case tcell.KeyRune: - key.WriteString("\x1b") - key.WriteRune(ev.Rune()) - case tcell.KeyUp: - key.WriteString(info.KeyAltUp) - case tcell.KeyDown: - key.WriteString(info.KeyAltDown) - case tcell.KeyRight: - key.WriteString(info.KeyAltRight) - case tcell.KeyLeft: - key.WriteString(info.KeyAltLeft) - case tcell.KeyHome: - key.WriteString(info.KeyAltHome) - case tcell.KeyEnd: - key.WriteString(info.KeyAltEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyAltInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyAltDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyAltPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyAltPgDown) - case tcell.KeyF1: - key.WriteString(info.KeyF49) - case tcell.KeyF2: - key.WriteString(info.KeyF50) - case tcell.KeyF3: - key.WriteString(info.KeyF51) - case tcell.KeyF4: - key.WriteString(info.KeyF53) - case tcell.KeyF5: - key.WriteString(info.KeyF54) - case tcell.KeyF6: - key.WriteString(info.KeyF55) - case tcell.KeyF7: - key.WriteString(info.KeyF56) - case tcell.KeyF8: - key.WriteString(info.KeyF57) - case tcell.KeyF9: - key.WriteString(info.KeyF58) - case tcell.KeyF10: - key.WriteString(info.KeyF59) - case tcell.KeyF11: - key.WriteString(info.KeyF60) - case tcell.KeyF12: - key.WriteString(info.KeyF61) - } - case tcell.ModCtrl: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(info.KeyCtrlUp) - case tcell.KeyDown: - key.WriteString(info.KeyCtrlDown) - case tcell.KeyRight: - key.WriteString(info.KeyCtrlRight) - case tcell.KeyLeft: - key.WriteString(info.KeyCtrlLeft) - case tcell.KeyHome: - key.WriteString(info.KeyCtrlHome) - case tcell.KeyEnd: - key.WriteString(info.KeyCtrlEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyCtrlInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyCtrlDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyCtrlPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyCtrlPgDown) - case tcell.KeyF1: - key.WriteString(info.KeyF25) - case tcell.KeyF2: - key.WriteString(info.KeyF26) - case tcell.KeyF3: - key.WriteString(info.KeyF27) - case tcell.KeyF4: - key.WriteString(info.KeyF28) - case tcell.KeyF5: - key.WriteString(info.KeyF29) - case tcell.KeyF6: - key.WriteString(info.KeyF30) - case tcell.KeyF7: - key.WriteString(info.KeyF31) - case tcell.KeyF8: - key.WriteString(info.KeyF32) - case tcell.KeyF9: - key.WriteString(info.KeyF33) - case tcell.KeyF10: - key.WriteString(info.KeyF34) - case tcell.KeyF11: - key.WriteString(info.KeyF35) - case tcell.KeyF12: - key.WriteString(info.KeyF36) - default: - key.WriteRune(ev.Rune()) - } - case tcell.ModCtrl | tcell.ModShift: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(info.KeyCtrlShfUp) - case tcell.KeyDown: - key.WriteString(info.KeyCtrlShfDown) - case tcell.KeyRight: - key.WriteString(info.KeyCtrlShfRight) - case tcell.KeyLeft: - key.WriteString(info.KeyCtrlShfLeft) - case tcell.KeyHome: - key.WriteString(info.KeyCtrlShfHome) - case tcell.KeyEnd: - key.WriteString(info.KeyCtrlShfEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyCtrlShfInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyCtrlShfDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyCtrlShfPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyCtrlShfPgDown) - case tcell.KeyF1: - key.WriteString(info.KeyF37) - case tcell.KeyF2: - key.WriteString(info.KeyF38) - case tcell.KeyF3: - key.WriteString(info.KeyF39) - case tcell.KeyF4: - key.WriteString(info.KeyF40) - case tcell.KeyF5: - key.WriteString(info.KeyF41) - case tcell.KeyF6: - key.WriteString(info.KeyF42) - case tcell.KeyF7: - key.WriteString(info.KeyF43) - case tcell.KeyF8: - key.WriteString(info.KeyF44) - case tcell.KeyF9: - key.WriteString(info.KeyF45) - case tcell.KeyF10: - key.WriteString(info.KeyF46) - case tcell.KeyF11: - key.WriteString(info.KeyF47) - case tcell.KeyF12: - key.WriteString(info.KeyF48) - } - case tcell.ModAlt | tcell.ModShift: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(info.KeyAltShfUp) - case tcell.KeyDown: - key.WriteString(info.KeyAltShfDown) - case tcell.KeyRight: - key.WriteString(info.KeyAltShfRight) - case tcell.KeyLeft: - key.WriteString(info.KeyAltShfLeft) - case tcell.KeyHome: - key.WriteString(info.KeyAltShfHome) - case tcell.KeyEnd: - key.WriteString(info.KeyAltShfEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyAltShfInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyAltShfDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyAltShfPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyAltShfPgDown) - case tcell.KeyF1: - key.WriteString(info.KeyF61) - case tcell.KeyF2: - key.WriteString(info.KeyF62) - case tcell.KeyF3: - key.WriteString(info.KeyF63) - case tcell.KeyF4: - key.WriteString(info.KeyF64) - } - case tcell.ModAlt | tcell.ModCtrl: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(extendedInfo.KeyCtrlAltUp) - case tcell.KeyDown: - key.WriteString(extendedInfo.KeyCtrlAltDown) - case tcell.KeyRight: - key.WriteString(extendedInfo.KeyCtrlAltRight) - case tcell.KeyLeft: - key.WriteString(extendedInfo.KeyCtrlAltLeft) - case tcell.KeyHome: - key.WriteString(extendedInfo.KeyCtrlAltHome) - case tcell.KeyEnd: - key.WriteString(extendedInfo.KeyCtrlAltEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyCtrlAltInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyCtrlAltDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyCtrlAltPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyCtrlAltPgDown) - } - case tcell.ModAlt | tcell.ModCtrl | tcell.ModShift: - switch ev.Key() { - case tcell.KeyUp: - key.WriteString(extendedInfo.KeyCtrlAltShfUp) - case tcell.KeyDown: - key.WriteString(extendedInfo.KeyCtrlAltShfDown) - case tcell.KeyRight: - key.WriteString(extendedInfo.KeyCtrlAltShfRight) - case tcell.KeyLeft: - key.WriteString(extendedInfo.KeyCtrlAltShfLeft) - case tcell.KeyHome: - key.WriteString(extendedInfo.KeyCtrlAltShfHome) - case tcell.KeyEnd: - key.WriteString(extendedInfo.KeyCtrlAltShfEnd) - case tcell.KeyInsert: - key.WriteString(extendedInfo.KeyCtrlAltShfInsert) - case tcell.KeyDelete: - key.WriteString(extendedInfo.KeyCtrlAltShfDelete) - case tcell.KeyPgUp: - key.WriteString(extendedInfo.KeyCtrlAltShfPgUp) - case tcell.KeyPgDn: - key.WriteString(extendedInfo.KeyCtrlAltShfPgDown) - } - case tcell.ModMeta: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";9~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;9") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModShift: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";10~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;10") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModAlt: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";11~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;11") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModAlt | tcell.ModShift: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";12~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;12") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModCtrl: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";13~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;13") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModCtrl | tcell.ModShift: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";14~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;14") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModCtrl | tcell.ModAlt: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";15~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;15") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - case tcell.ModMeta | tcell.ModCtrl | tcell.ModAlt | tcell.ModShift: - // Meta keys we just do the math, only allowing modifiable keys - switch ev.Key() { - case tcell.KeyUp: - case tcell.KeyDown: - case tcell.KeyRight: - case tcell.KeyLeft: - case tcell.KeyHome: - case tcell.KeyEnd: - case tcell.KeyInsert: - case tcell.KeyDelete: - case tcell.KeyPgUp: - case tcell.KeyPgDn: - case tcell.KeyF1: - case tcell.KeyF2: - case tcell.KeyF3: - case tcell.KeyF4: - case tcell.KeyF5: - case tcell.KeyF6: - case tcell.KeyF7: - case tcell.KeyF8: - case tcell.KeyF9: - case tcell.KeyF10: - case tcell.KeyF11: - case tcell.KeyF12: - default: - return "" - } - kc := keyCodes[ev.Key()] - switch { - case strings.HasSuffix(kc, "~"): - key.WriteString(strings.TrimSuffix(kc, "~")) - key.WriteString(";16~") - default: - // Tcell is using khome etc instead of home, these are - // different codes (\x1b0H vs \x1b[H) - key.WriteString("\x1b[1;16") - key.WriteString(strings.TrimPrefix(kc, "\x1bO")) - } - } - return key.String() -} - -var keyCodes = map[tcell.Key]string{ - tcell.KeyBackspace: info.KeyBackspace, - tcell.KeyF1: info.KeyF1, - tcell.KeyF2: info.KeyF2, - tcell.KeyF3: info.KeyF3, - tcell.KeyF4: info.KeyF4, - tcell.KeyF5: info.KeyF5, - tcell.KeyF6: info.KeyF6, - tcell.KeyF7: info.KeyF7, - tcell.KeyF8: info.KeyF8, - tcell.KeyF9: info.KeyF9, - tcell.KeyF10: info.KeyF10, - tcell.KeyF11: info.KeyF11, - tcell.KeyF12: info.KeyF12, - tcell.KeyF13: info.KeyF13, - tcell.KeyF14: info.KeyF14, - tcell.KeyF15: info.KeyF15, - tcell.KeyF16: info.KeyF16, - tcell.KeyF17: info.KeyF17, - tcell.KeyF18: info.KeyF18, - tcell.KeyF19: info.KeyF19, - tcell.KeyF20: info.KeyF20, - tcell.KeyF21: info.KeyF21, - tcell.KeyF22: info.KeyF22, - tcell.KeyF23: info.KeyF23, - tcell.KeyF24: info.KeyF24, - tcell.KeyF25: info.KeyF25, - tcell.KeyF26: info.KeyF26, - tcell.KeyF27: info.KeyF27, - tcell.KeyF28: info.KeyF28, - tcell.KeyF29: info.KeyF29, - tcell.KeyF30: info.KeyF30, - tcell.KeyF31: info.KeyF31, - tcell.KeyF32: info.KeyF32, - tcell.KeyF33: info.KeyF33, - tcell.KeyF34: info.KeyF34, - tcell.KeyF35: info.KeyF35, - tcell.KeyF36: info.KeyF36, - tcell.KeyF37: info.KeyF37, - tcell.KeyF38: info.KeyF38, - tcell.KeyF39: info.KeyF39, - tcell.KeyF40: info.KeyF40, - tcell.KeyF41: info.KeyF41, - tcell.KeyF42: info.KeyF42, - tcell.KeyF43: info.KeyF43, - tcell.KeyF44: info.KeyF44, - tcell.KeyF45: info.KeyF45, - tcell.KeyF46: info.KeyF46, - tcell.KeyF47: info.KeyF47, - tcell.KeyF48: info.KeyF48, - tcell.KeyF49: info.KeyF49, - tcell.KeyF50: info.KeyF50, - tcell.KeyF51: info.KeyF51, - tcell.KeyF52: info.KeyF52, - tcell.KeyF53: info.KeyF53, - tcell.KeyF54: info.KeyF54, - tcell.KeyF55: info.KeyF55, - tcell.KeyF56: info.KeyF56, - tcell.KeyF57: info.KeyF57, - tcell.KeyF58: info.KeyF58, - tcell.KeyF59: info.KeyF59, - tcell.KeyF60: info.KeyF60, - tcell.KeyF61: info.KeyF61, - tcell.KeyF62: info.KeyF62, - tcell.KeyF63: info.KeyF63, - tcell.KeyF64: info.KeyF64, - tcell.KeyInsert: info.KeyInsert, - tcell.KeyDelete: info.KeyDelete, - tcell.KeyHome: info.KeyHome, - tcell.KeyEnd: info.KeyEnd, - tcell.KeyHelp: info.KeyHelp, - tcell.KeyPgUp: info.KeyPgUp, - tcell.KeyPgDn: info.KeyPgDn, - tcell.KeyUp: info.KeyUp, - tcell.KeyDown: info.KeyDown, - tcell.KeyLeft: info.KeyLeft, - tcell.KeyRight: info.KeyRight, - tcell.KeyBacktab: info.KeyBacktab, - tcell.KeyExit: info.KeyExit, - tcell.KeyClear: info.KeyClear, - tcell.KeyPrint: info.KeyPrint, - tcell.KeyCancel: info.KeyCancel, -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/key_test.go b/cmd/sst/mosaic/multiplexer/tcell-term/key_test.go deleted file mode 100644 index 19e1ce920e..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/key_test.go +++ /dev/null @@ -1,105 +0,0 @@ -package tcellterm - -import ( - "testing" - - "github.com/gdamore/tcell/v2" - "github.com/stretchr/testify/assert" -) - -func TestKey(t *testing.T) { - tests := []struct { - name string - event *tcell.EventKey - expected string - }{ - { - name: "rune", - event: tcell.NewEventKey( - tcell.KeyRune, - 'j', - tcell.ModNone, - ), - expected: "j", - }, - { - name: "F1", - event: tcell.NewEventKey( - tcell.KeyF1, - 0, - tcell.ModNone, - ), - expected: "\x1bOP", - }, - { - name: "Shift-right", - event: tcell.NewEventKey( - tcell.KeyRight, - 0, - tcell.ModShift, - ), - expected: "\x1b[1;2C", - }, - { - name: "Ctrl-Shift-right", - event: tcell.NewEventKey( - tcell.KeyRight, - 0, - tcell.ModShift|tcell.ModCtrl, - ), - expected: "\x1b[1;6C", - }, - { - name: "Alt-Shift-right", - event: tcell.NewEventKey( - tcell.KeyRight, - 0, - tcell.ModShift|tcell.ModAlt, - ), - expected: "\x1b[1;4C", - }, - { - name: "rune + mod alt", - event: tcell.NewEventKey( - tcell.KeyRune, - 'j', - tcell.ModAlt, - ), - expected: "\x1Bj", - }, - { - name: "rune + mod ctrl", - event: tcell.NewEventKey( - tcell.KeyCtrlJ, - 0x0A, - tcell.ModCtrl, - ), - expected: "\n", - }, - { - name: "shift + f5", - event: tcell.NewEventKey( - tcell.KeyF5, - 0, - tcell.ModShift, - ), - expected: "\x1B[15;2~", - }, - { - name: "shift + arrow", - event: tcell.NewEventKey( - tcell.KeyRight, - 0, - tcell.ModShift, - ), - expected: "\x1B[1;2C", - }, - } - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - actual := keyCode(test.event) - assert.Equal(t, test.expected, actual) - }) - } -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/mode.go b/cmd/sst/mosaic/multiplexer/tcell-term/mode.go deleted file mode 100644 index 26401ca9de..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/mode.go +++ /dev/null @@ -1,178 +0,0 @@ -package tcellterm - -type mode int - -const ( - // ANSI-Standardized modes - // - // Keyboard Action mode - kam mode = 1 << iota - // Insert/Replace mode - irm - // Send/Receive mode - srm - // Line feed/new line mode - lnm - - // ANSI-Compatible DEC Private Modes - // - // Cursor Key mode - decckm - // ANSI/VT52 mode - decanm - // Column mode - deccolm - // Scroll mode - decsclm - // Origin mode - decom - // Autowrap mode - decawm - // Autorepeat mode - decarm - // Printer form feed mode - decpff - // Printer extent mode - decpex - // Text Cursor Enable mode - dectcem - // National replacement character sets - decnrcm - - // xterm - // - // Use alternate screen - smcup - // Bracketed paste - paste - // vt220 mouse - mouseButtons - // vt220 + drag - mouseDrag - // vt220 + all motion - mouseMotion - // Mouse SGR mode - mouseSGR - // Alternate scroll - altScroll -) - -func (vt *VT) sm(params []int) { - for _, param := range params { - switch param { - case 2: - vt.mode |= kam - case 4: - vt.mode |= irm - case 12: - vt.mode |= srm - case 20: - vt.mode |= lnm - } - } -} - -func (vt *VT) rm(params []int) { - for _, param := range params { - switch param { - case 2: - vt.mode &^= kam - case 4: - vt.mode &^= irm - case 12: - vt.mode &^= srm - case 20: - vt.mode &^= lnm - } - } -} - -func (vt *VT) decset(params []int) { - for _, param := range params { - switch param { - case 1: - vt.mode |= decckm - case 2: - vt.mode |= decanm - case 3: - vt.mode |= deccolm - case 4: - vt.mode |= decsclm - case 5: - case 6: - vt.mode |= decom - case 7: - vt.mode |= decawm - vt.lastCol = false - case 8: - vt.mode |= decarm - case 25: - vt.mode |= dectcem - case 1000: - vt.mode |= mouseButtons - case 1002: - vt.mode |= mouseDrag - case 1003: - vt.mode |= mouseMotion - case 1006: - vt.mode |= mouseSGR - case 1007: - vt.mode |= altScroll - case 1049: - vt.decsc() - vt.activeScreen = vt.altScreen - vt.mode |= smcup - // Enable altScroll in the alt screen. This is only used - // if the application doesn't enable mouse - vt.mode |= altScroll - case 2004: - vt.mode |= paste - } - } -} - -func (vt *VT) decrst(params []int) { - for _, param := range params { - switch param { - case 1: - vt.mode &^= decckm - case 2: - vt.mode &^= decanm - case 3: - vt.mode &^= deccolm - case 4: - vt.mode &^= decsclm - case 5: - case 6: - vt.mode &^= decom - case 7: - vt.mode &^= decawm - vt.lastCol = false - case 8: - vt.mode &^= decarm - case 25: - vt.mode &^= dectcem - case 1000: - vt.mode &^= mouseButtons - case 1002: - vt.mode &^= mouseDrag - case 1003: - vt.mode &^= mouseMotion - case 1006: - vt.mode &^= mouseSGR - case 1007: - vt.mode &^= altScroll - case 1049: - if vt.mode&smcup != 0 { - // Only clear if we were in the alternate - vt.ed(2) - } - vt.activeScreen = vt.primaryScreen - vt.mode &^= smcup - vt.mode &^= altScroll - vt.decrc() - case 2004: - vt.mode &^= paste - } - } -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/mouse.go b/cmd/sst/mosaic/multiplexer/tcell-term/mouse.go deleted file mode 100644 index 36a1384bf4..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/mouse.go +++ /dev/null @@ -1,109 +0,0 @@ -package tcellterm - -import ( - "fmt" - - "github.com/gdamore/tcell/v2" -) - -func (vt *VT) handleMouse(ev *tcell.EventMouse) string { - if vt.mode&mouseButtons == 0 && vt.mode&mouseDrag == 0 && vt.mode&mouseMotion == 0 && vt.mode&mouseSGR == 0 { - if vt.mode&altScroll != 0 && vt.mode&smcup != 0 { - // Translate wheel motion into arrows up and down - // 3x rows - if ev.Buttons()&tcell.WheelUp != 0 { - vt.pty.WriteString(info.KeyUp) - vt.pty.WriteString(info.KeyUp) - vt.pty.WriteString(info.KeyUp) - } - if ev.Buttons()&tcell.WheelDown != 0 { - vt.pty.WriteString(info.KeyDown) - vt.pty.WriteString(info.KeyDown) - vt.pty.WriteString(info.KeyDown) - } - } - return "" - } - // Return early if we aren't reporting motion or drag events - if vt.mode&mouseButtons != 0 && vt.mouseBtn == ev.Buttons() { - // motion or drag - return "" - } - - if vt.mode&mouseDrag != 0 && vt.mouseBtn == tcell.ButtonNone && ev.Buttons() == tcell.ButtonNone { - // Motion event - return "" - } - - // Encode the button - var b int - if ev.Buttons()&tcell.Button1 != 0 { - b += 0 - } - if ev.Buttons()&tcell.Button3 != 0 { - b += 1 - } - if ev.Buttons()&tcell.Button2 != 0 { - b += 2 - } - if ev.Buttons() == tcell.ButtonNone { - b += 3 - } - if ev.Buttons()&tcell.WheelUp != 0 { - b += 0 + 64 - } - if ev.Buttons()&tcell.WheelDown != 0 { - b += 1 + 64 - } - if ev.Modifiers()&tcell.ModShift != 0 { - b += 4 - } - if ev.Modifiers()&tcell.ModAlt != 0 { - b += 8 - } - if ev.Modifiers()&tcell.ModCtrl != 0 { - b += 16 - } - - if vt.mode&mouseButtons == 0 && vt.mouseBtn != tcell.ButtonNone && ev.Buttons() != tcell.ButtonNone { - // drag event - b += 32 - } - - col, row := ev.Position() - - if vt.mode&mouseSGR != 0 { - switch { - case ev.Buttons()&tcell.WheelUp != 0: - return fmt.Sprintf("\x1b[<%d;%d;%dM", b, col+1, row+1) - - case ev.Buttons()&tcell.WheelDown != 0: - return fmt.Sprintf("\x1b[<%d;%d;%dM", b, col+1, row+1) - - case ev.Buttons() == tcell.ButtonNone && vt.mouseBtn != tcell.ButtonNone: - // Button was in, and now it's not - var button int - switch vt.mouseBtn { - case tcell.Button1: - button = 0 - case tcell.Button3: - button = 1 - case tcell.Button2: - button = 2 - } - vt.mouseBtn = ev.Buttons() - return fmt.Sprintf("\x1b[<%d;%d;%dm", button, col+1, row+1) - - default: - vt.mouseBtn = ev.Buttons() - return fmt.Sprintf("\x1b[<%d;%d;%dM", b, col+1, row+1) - } - } - - encodedCol := 32 + col + 1 - encodedRow := 32 + row + 1 - b += 32 - - vt.mouseBtn = ev.Buttons() - return fmt.Sprintf("\x1b[M%c%c%c", b, encodedCol, encodedRow) -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/mouse_test.go b/cmd/sst/mosaic/multiplexer/tcell-term/mouse_test.go deleted file mode 100644 index 30972fcf83..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/mouse_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package tcellterm - -import ( - "testing" - - "github.com/gdamore/tcell/v2" - "github.com/stretchr/testify/assert" -) - -func TestHandleMouse(t *testing.T) { - tests := []struct { - name string - mode mode - button tcell.ButtonMask - event *tcell.EventMouse - expected string - }{ - { - name: "button 1", - mode: mouseButtons, - button: tcell.ButtonNone, - event: tcell.NewEventMouse(0, 0, tcell.Button1, tcell.ModNone), - expected: "\x1b[M !!", - }, - { - name: "button 1 + shift", - mode: mouseButtons, - button: tcell.ButtonNone, - event: tcell.NewEventMouse(0, 0, tcell.Button1, tcell.ModShift), - expected: "\x1b[M$!!", - }, - { - name: "button 1 drag, in normal mode", - mode: mouseButtons, - button: tcell.Button1, - event: tcell.NewEventMouse(0, 0, tcell.Button1, tcell.ModNone), - expected: "", - }, - { - name: "button 1 release, in normal mode", - mode: mouseButtons, - button: tcell.Button1, - event: tcell.NewEventMouse(0, 0, tcell.ButtonNone, tcell.ModNone), - expected: "\x1b[M#!!", - }, - { - name: "button 1 drag, in drag mode", - mode: mouseDrag, - button: tcell.Button1, - event: tcell.NewEventMouse(0, 0, tcell.Button1, tcell.ModNone), - expected: "\x1b[M@!!", - }, - { - name: "button 1 sgr", - mode: mouseSGR, - button: tcell.ButtonNone, - event: tcell.NewEventMouse(0, 0, tcell.Button1, tcell.ModNone), - expected: "\x1b[<0;1;1M", - }, - { - name: "no button motion sgr", - mode: mouseSGR, - button: tcell.ButtonNone, - event: tcell.NewEventMouse(0, 0, tcell.ButtonNone, tcell.ModNone), - expected: "\x1b[<3;1;1M", - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - vt := New() - vt.mouseBtn = test.button - vt.mode |= test.mode - actual := vt.handleMouse(test.event) - assert.Equal(t, test.expected, actual) - }) - } -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/osc.go b/cmd/sst/mosaic/multiplexer/tcell-term/osc.go deleted file mode 100644 index 53a7278042..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/osc.go +++ /dev/null @@ -1,56 +0,0 @@ -package tcellterm - -import ( - "strings" -) - -func (vt *VT) osc(data string) { - selector, val, found := cutString(data, ";") - if !found { - return - } - switch selector { - case "0", "2": - ev := &EventTitle{ - EventTerminal: newEventTerminal(vt), - title: val, - } - vt.postEvent(ev) - case "8": - if vt.OSC8 { - url, id := osc8(val) - vt.cursor.attrs = vt.cursor.attrs.Url(url) - vt.cursor.attrs = vt.cursor.attrs.UrlId(id) - } - } -} - -// parses an osc8 payload into the URL and optional ID -func osc8(val string) (string, string) { - // OSC 8 ; params ; url ST - // params: key1=value1:key2=value2 - var id string - params, url, found := cutString(val, ";") - if !found { - return "", "" - } - for _, param := range strings.Split(params, ":") { - key, val, found := cutString(param, "=") - if !found { - continue - } - switch key { - case "id": - id = val - } - } - return url, id -} - -// Copied from stdlib to here for go 1.16 compat -func cutString(s string, sep string) (before string, after string, found bool) { - if i := strings.Index(s, sep); i >= 0 { - return s[:i], s[i+len(sep):], true - } - return s, "", false -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/osc_test.go b/cmd/sst/mosaic/multiplexer/tcell-term/osc_test.go deleted file mode 100644 index 6bd5567ae4..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/osc_test.go +++ /dev/null @@ -1,74 +0,0 @@ -package tcellterm - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestParseOSC8(t *testing.T) { - tests := []struct { - name string - input string - expected string - expectedID string - }{ - { - name: "no semicolon in URI", - input: "8;;https://example.com", - expected: "https://example.com", - expectedID: "", - }, - { - name: "no semicolon in URI, with id", - input: "8;id=hello;https://example.com", - expected: "https://example.com", - expectedID: "hello", - }, - { - name: "semicolon in URI", - input: "8;;https://example.com/semi;colon", - expected: "https://example.com/semi;colon", - expectedID: "", - }, - { - name: "multiple semicolons in URI", - input: "8;;https://example.com/s;e;m;i;colon", - expected: "https://example.com/s;e;m;i;colon", - expectedID: "", - }, - { - name: "semicolon in URI, with id", - input: "8;id=hello;https://example.com/semi;colon", - expected: "https://example.com/semi;colon", - expectedID: "hello", - }, - { - name: "terminating sequence", - input: "8;;", - expected: "", - expectedID: "", - }, - { - name: "terminating sequence with id", - input: "8;id=hello;", - expected: "", - expectedID: "hello", - }, - } - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - // Simulate vt.osc - selector, val, found := cutString(test.input, ";") - if !found { - return - } - assert.Equal(t, "8", selector) - // parse the result - url, id := osc8(val) - assert.Equal(t, test.expected, url) - assert.Equal(t, test.expectedID, id) - }) - } -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/parse.go b/cmd/sst/mosaic/multiplexer/tcell-term/parse.go deleted file mode 100644 index 6a75b076b9..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/parse.go +++ /dev/null @@ -1,850 +0,0 @@ -package tcellterm - -import ( - "bufio" - "fmt" - "io" - "strconv" - "strings" - "unicode" -) - -const eof rune = -1 - -// https://vt100.net/emu/dec_ansi_parser -// -// parser is an implementation of Paul Flo Williams' VT500-series -// parser, as seen [here](https://vt100.net/emu/dec_ansi_parser). The -// architecture is designed after Rob Pike's text/template parser, with a -// few modifications. -// -// Many of the comments are directly from Paul Flo Williams description of -// the parser, licensed undo [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/) -type Parser struct { - r *bufio.Reader - sequences chan Sequence - state stateFn - exit func() - intermediate []rune - params []rune - final rune - - oscData []rune -} - -func NewParser(r io.Reader) *Parser { - parser := &Parser{ - r: bufio.NewReader(r), - sequences: make(chan Sequence, 2), - state: ground, - } - // Rob Pike didn't use concurrency since he wanted templates to be able - // to happen in init() functions, but we don't care about that. - go parser.run() - return parser -} - -// Next returns the next Sequence. Sequences will be of the following types: -// -// error Sent on any parsing error -// Print Print the character to the screen -// C0 Execute the C0 code -// ESC Execute the ESC sequence -// CSI Execute the CSI sequence -// OSCStart Signals the start of an OSC sequence -// OSCData Characters from the OSC sequence -// OSCEnd Signals end of the OSC sequence -// DCS Signals start of a DCS sequence, and DCS params/intermediates -// DCSData Raw DCS passthrough data -// DCSEndOfData Signals end of DCS sequence -// EOF Sent at end of input -func (p *Parser) Next() Sequence { - return <-p.sequences -} - -func (p *Parser) run() { - for { - r := p.readRune() - p.state = anywhere(r, p) - if p.state == nil { - break - } - } - p.emit(EOF{}) - close(p.sequences) -} - -func (p *Parser) readRune() rune { - r, _, err := p.r.ReadRune() - if r == unicode.ReplacementChar { - // If invalid UTF-8, let's read the byte and deliver - // it as is - err = p.r.UnreadRune() - if err != nil { - return eof - } - b, err := p.r.ReadByte() - if err != nil { - return eof - } - r = rune(b) - } - if err != nil { - return eof - } - return r -} - -func (p *Parser) emit(seq Sequence) { - p.sequences <- seq -} - -// This action only occurs in ground state. The current code should be mapped to -// a glyph according to the character set mappings and shift states in effect, -// and that glyph should be displayed. 20 (SP) and 7F (DEL) have special -// behaviour in later VT series, as described in ground. -func (p *Parser) print(r rune) { - p.emit(Print(r)) -} - -// The C0 or C1 control function should be executed, which may have any one of a -// variety of effects, including changing the cursor position, suspending or -// resuming communications or changing the shift states in effect. There are no -// parameters to this action. -func (p *Parser) execute(r rune) { - if in(r, 0x00, 0x1F) { - p.emit(C0(r)) - return - } -} - -// This action causes the current private flag, intermediate characters, final -// character and parameters to be forgotten. This occurs on entry to the escape, -// csi entry and dcs entry states, so that erroneous sequences like CSI 3 ; 1 -// CSI 2 J are handled correctly. -func (p *Parser) clear() { - p.intermediate = []rune{} - p.final = rune(0) - p.params = []rune{} -} - -// The private marker or intermediate character should be stored for later -// use in selecting a control function to be executed when a final -// character arrives. X3.64 doesn’t place any limit on the number of -// intermediate characters allowed before a final character, although it -// doesn’t define any control sequences with more than one. Digital defined -// escape sequences with two intermediate characters, and control sequences -// and device control strings with one. If more than two intermediate -// characters arrive, the parser can just flag this so that the dispatch -// can be turned into a null operation. -func (p *Parser) collect(r rune) { - p.intermediate = append(p.intermediate, r) -} - -// The final character of an escape sequence has arrived, so determined the -// control function to be executed from the intermediate character(s) and -// final character, and execute it. The intermediate characters are -// available because collect stored them as they arrived. -func (p *Parser) escapeDispatch(r rune) { - p.emit(ESC{ - Final: r, - Intermediate: p.intermediate, - }) - return -} - -// This action collects the characters of a parameter string for a control -// sequence or device control sequence and builds a list of parameters. The -// characters processed by this action are the digits 0-9 (codes 30-39) and -// the semicolon (code 3B). The semicolon separates parameters. There is no -// limit to the number of characters in a parameter string, although a -// maximum of 16 parameters need be stored. If more than 16 parameters -// arrive, all the extra parameters are silently ignored. -// -// Most control functions support default values for their parameters. The -// default value for a parameter is given by either leaving the parameter -// blank, or specifying a value of zero. Judging by previous threads on the -// newsgroup comp.terminals, this causes some confusion, with the -// occasional assertion that zero is the default parameter value for -// control functions. This is not the case: many control functions have a -// default value of 1, one (GSM) has a default value of 100, and some have -// no default. However, in all cases the default value is represented by -// either zero or a blank value. -// -// In the standard ECMA-48, which can be considered X3.64’s successor², -// there is a distinction between a parameter with an empty value -// (representing the default value), and one that has the value zero. There -// used to be a mode, ZDM (Zero Default Mode), in which the two cases were -// treated identically, but that is now deprecated in the fifth edition -// (1991). Although a VT500 parser needs to treat both empty and zero -// parameters as representing the default, it is worth considering future -// extensions by distinguishing them internally -func (p *Parser) param(r rune) { - p.params = append(p.params, r) -} - -// A final character has arrived, so determine the control function to be -// executed from private marker, intermediate character(s) and final -// character, and execute it, passing in the parameter list. -// -// csiDispatch will normalize SGR RGB sequences to a maximum of 5 parameters. IE -// '38:2::0:0:0' will return []int{38,2,0,0,0} -func (p *Parser) csiDispatch(r rune) { - csi := CSI{ - Final: r, - Intermediate: p.intermediate, - Parameters: []int{}, - } - if len(p.params) == 0 { - p.emit(csi) - return - } - paramStrRaw := strings.Split(string(p.params), ";") - paramStr := make([]string, 0, len(paramStrRaw)) - for _, param := range paramStrRaw { - if !strings.Contains(param, ":") { - paramStr = append(paramStr, param) - continue - } - // Contains an RGB param string. Preprocess this to normalize to - // a length of 5 - paramsRGB := strings.Split(param, ":") - switch len(paramsRGB) { - case 2: - // Could be an underline sequence CSI 4:Ps m. We only - // support underline, so drop the second param - paramStr = append(paramStr, paramsRGB[0]) - case 5: - paramStr = append(paramStr, paramsRGB...) - case 6: - for i, p := range paramsRGB { - if i == 2 { - continue - } - paramStr = append(paramStr, p) - } - } - } - params := make([]int, 0, len(paramStr)) - for _, param := range paramStr { - if param == "" { - params = append(params, 0) - continue - } - val, err := strconv.Atoi(param) - if err != nil { - p.emit(fmt.Errorf("csiDispatch: %w", err)) - return - } - params = append(params, val) - } - csi.Parameters = params - p.emit(csi) -} - -// When the control function OSC (Operating System Command) is recognised, -// this action initializes an external parser (the “OSC Handler”) to handle -// the characters from the control string. OSC control strings are not -// structured in the same way as device control strings, so there is no -// choice of parsers. -// -// oscStart registers oscEnd as the exit function. This will be called on when -// the state moves from oscString to any other state -func (p *Parser) oscStart() { - // p.emit(OSCStart{}) - p.exit = p.oscEnd -} - -// This action passes characters from the control string to the OSC Handler -// as they arrive. There is therefore no need to buffer characters until -// the end of the control string is recognised. -func (p *Parser) oscPut(r rune) { - p.oscData = append(p.oscData, r) - // p.emit(OSCData(r)) -} - -// This action is called when the OSC string is terminated by ST, CAN, SUB -// or ESC, to allow the OSC handler to finish neatly. -func (p *Parser) oscEnd() { - p.emit(OSC{ - Payload: p.oscData, - }) - p.oscData = []rune{} -} - -// This action is invoked when a final character arrives in the first part -// of a device control string. It determines the control function from the -// private marker, intermediate character(s) and final character, and -// executes it, passing in the parameter list. It also selects a handler -// function for the rest of the characters in the control string. This -// handler function will be called by the put action for every character in -// the control string as it arrives. -// -// This way of handling device control strings has been selected because it -// allows the simple plugging-in of extra parsers as functionality is -// added. Support for a fairly simple control string like DECDLD (Downline -// Load) could be added into the main parser if soft characters were -// required, but the main parser is no place for complicated protocols like -// ReGIS. -// -// hook registers unhook as the exit function. This will be called on when -// the state moves from dcsPassthrough to any other state -func (p *Parser) hook(r rune) { - p.exit = p.unhook - dcs := DCS{ - Final: r, - Intermediate: p.intermediate, - Parameters: []int{}, - } - if len(p.params) == 0 { - p.emit(dcs) - return - } - paramStr := strings.Split(string(p.params), ";") - params := make([]int, 0, len(paramStr)) - for _, param := range paramStr { - if param == "" { - params = append(params, 0) - continue - } - val, err := strconv.Atoi(param) - if err != nil { - p.emit(fmt.Errorf("hook: %w", err)) - return - } - params = append(params, val) - } - dcs.Parameters = params - p.emit(dcs) -} - -// This action passes characters from the data string part of a device -// control string to a handler that has previously been selected by the -// hook action. C0 controls are also passed to the handler. -func (p *Parser) put(r rune) { - p.emit(DCSData(r)) -} - -// When a device control string is terminated by ST, CAN, SUB or ESC, this -// action calls the previously selected handler function with an “end of -// data” parameter. This allows the handler to finish neatly. -func (p *Parser) unhook() { - p.emit(DCSEndOfData{}) -} - -// in returns true if the rune lies within the range, inclusive of the endpoints -func in(r rune, min int32, max int32) bool { - if r >= min && r <= max { - return true - } - return false -} - -// is returns true of the rune matches any of the provided values -func is(r rune, vals ...int32) bool { - for _, val := range vals { - if r == val { - return true - } - } - return false -} - -// State functions - -type stateFn func(rune, *Parser) stateFn - -// This isn’t a real state. It is used on the state diagram to show -// transitions that can occur from any state to some other state. -func anywhere(r rune, p *Parser) stateFn { - switch { - case r == eof: - if p.exit != nil { - p.exit() - p.exit = nil - } - p.emit(nil) - return nil - case is(r, 0x18, 0x1A): - if p.exit != nil { - p.exit() - p.exit = nil - } - p.execute(r) - return ground - case is(r, 0x1B): - if p.exit != nil { - p.exit() - p.exit = nil - } - p.clear() - return escape - default: - return p.state(r, p) - } -} - -// This state is entered when the control function CSI is recognised, in -// 7-bit or 8-bit form. This state will only deal with the first character -// of a control sequence, because the characters 3C-3F can only appear as -// the first character of a control sequence, if they appear at all. -// Strictly speaking, X3.64 says that the entire string is “subject to -// private or experimental interpretation” if the first character is one of -// 3C-3F, which allows sequences like CSI ?::) and 3F (?) were used by Digital. -// -// C0 controls are executed immediately during the recognition of a control -// sequence. C1 controls will cancel the sequence and then be executed. I -// imagine this treatment of C1 controls is prompted by the consideration -// that the 7-bit (ESC Fe) and 8-bit representations of C1 controls should -// act in the same way. When the first character of the 7-bit -// representation, ESC, is received, it will cancel the control sequence, -// so the 8-bit representation should do so as well. -func csiEntry(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - p.execute(r) - return csiEntry - case is(r, 0x7F): - // ignore - return csiEntry - case in(r, 0x30, 0x39), is(r, 0x3B, 0x3A): - // 0x3A is not per the PFW, but using colons is valid SGR - // syntax for separating params when including colorspace. The - // colorspace should be ignored - p.param(r) - return csiParam - case in(r, 0x3C, 0x3F): - p.collect(r) - return csiParam - // case is(r, 0x3A): - // return csiIgnore - case in(r, 0x20, 0x2F): - p.collect(r) - return csiIntermediate - case in(r, 0x40, 0x7E): - p.csiDispatch(r) - return ground - default: - // Return to ground on unexpected characters - p.emit(fmt.Errorf("unexpected character: %c", r)) - return ground - } -} - -// This state is entered when a parameter character is recognised in a -// control sequence. It then recognises other parameter characters until an -// intermediate or final character appears. Further occurrences of the -// private-marker characters 3C-3F or the character 3A, which has no -// standardised meaning, will cause transition to the csi ignore state. -func csiParam(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - p.execute(r) - return csiParam - case is(r, 0x7F): - // ignore - return csiParam - case in(r, 0x30, 0x39), is(r, 0x3B, 0x3A): - // 0x3A is not per the PFW, but using colons is valid SGR - // syntax for separating params when including colorspace. The - // colorspace should be ignored - p.param(r) - return csiParam - case in(r, 0x40, 0x7E): - p.csiDispatch(r) - return ground - case in(r, 0x20, 0x2F): - p.collect(r) - return csiIntermediate - case in(r, 0x3C, 0x3F): - return csiIgnore - default: - // Return to ground on unexpected characters - p.emit(fmt.Errorf("unexpected character: %c", r)) - return ground - } -} - -// This state is used to consume remaining characters of a control sequence -// that is still being recognised, but has already been disregarded as -// malformed. This state will only exit when a final character is -// recognised, at which point it transitions to ground state without -// dispatching the control function. This state may be entered because: -// -// 1. a private-marker character 3C-3F is recognised in any place other -// than the first character of the control sequence, -// 2. the character 3A appears anywhere, or -// 3. a parameter character 30-3F occurs after an intermediate -// character has been recognised. -// -// C0 controls will still be executed while a control sequence is being -// ignored -func csiIgnore(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - p.execute(r) - return csiIgnore - case is(r, 0x7F): - // ignore - return csiIgnore - case in(r, 0x40, 0x7E): - return ground - default: - return csiIgnore - } -} - -// This state is entered when an intermediate character is recognised in a -// control sequence. It then recognises other intermediate characters until -// a final character appears. If any more parameter characters appear, this -// is an error condition which will cause a transition to the csi ignore -// state. -func csiIntermediate(r rune, p *Parser) stateFn { - switch { - case r == eof: - return nil - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - p.execute(r) - return csiIntermediate - case is(r, 0x7F): - // ignore - return csiIntermediate - case in(r, 0x20, 0x2F): - p.collect(r) - return csiIntermediate - case in(r, 0x30, 0x3F): - return csiIgnore - case in(r, 0x40, 0x7E): - p.csiDispatch(r) - return ground - default: - // Return to ground on unexpected characters - p.emit(fmt.Errorf("unexpected character: %c", r)) - return ground - } -} - -// This state is entered when the control function DCS is recognised, in -// 7-bit or 8-bit form. X3.64 doesn’t define any structure for device -// control strings, but Digital made them appear like control sequences -// followed by a data string, with a form and length dependent on the -// control function. This state is only used to recognise the first -// character of the control string, mirroring the csi entry state. -// -// C0 controls other than CAN, SUB and ESC are not executed while -// recognising the first part of a device control string. -func dcsEntry(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - // ignore - return dcsEntry - case is(r, 0x7F): - // ignore - return dcsEntry - case in(r, 0x20, 0x2F): - p.collect(r) - return dcsIntermediate - case is(r, 0x3A): - return dcsIgnore - case in(r, 0x30, 0x39), is(r, 0x3B): - p.param(r) - return dcsParam - case in(r, 0x3C, 0x3F): - p.collect(r) - return dcsParam - case in(r, 0x40, 0x7E): - p.hook(r) - return dcsPassthrough - default: - p.hook(r) - return dcsPassthrough - } -} - -// This state is entered when an intermediate character is recognised in a -// device control string. It then recognises other intermediate characters -// until a final character appears. If any more parameter characters -// appear, this is an error condition which will cause a transition to the -// dcs ignore state. -func dcsIntermediate(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - // ignore - return dcsIntermediate - case in(r, 0x20, 0x2F): - p.collect(r) - return dcsIntermediate - case is(r, 0x7F): - // ignore - return dcsIntermediate - case in(r, 0x30, 0x3F): - return dcsIgnore - case in(r, 0x40, 0x7E): - p.hook(r) - return dcsPassthrough - default: - // Return to ground on unexpected characters - p.emit(fmt.Errorf("unexpected character: %c", r)) - return ground - } -} - -// This state is entered when a parameter character is recognised in a -// device control string. It then recognises other parameter characters -// until an intermediate or final character appears. Occurrences of the -// private-marker characters 3C-3F or the undefined character 3A will cause -// a transition to the dcs ignore state. -func dcsParam(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - // ignore - return dcsParam - case in(r, 0x30, 0x39), is(r, 0x3B): - p.param(r) - return dcsParam - case is(r, 0x7F): - // ignore - return dcsParam - case in(r, 0x20, 0x2F): - p.collect(r) - return dcsIntermediate - case is(r, 0x3A), in(r, 0x3C, 0x3F): - return dcsIgnore - case in(r, 0x40, 0x7E): - p.hook(r) - return dcsPassthrough - default: - // Return to ground on unexpected characters - p.emit(fmt.Errorf("unexpected character: %c", r)) - return ground - } -} - -// This state is used to consume remaining characters of a device control -// string that is still being recognised, but has already been disregarded -// as malformed. This state will only exit when the control function ST is -// recognised, at which point it transitions to ground state. This state -// may be entered because: -// -// 1. a private-marker character 3C-3F is recognised in any place other -// than the first character of the control string, -// 2. the character 3A appears anywhere, or -// 3. a parameter character 30-3F occurs after an intermediate -// character has been recognised. -// -// These conditions are only errors in the first part of the control -// string, until a final character has been recognised. The data string -// that follows is not checked by this parser. -func dcsIgnore(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - // ignore - return dcsIgnore - case in(r, 0x20, 0x7F): - // ignore - return dcsIgnore - default: - // ignore - return dcsIgnore - } -} - -// This state is a shortcut for writing state machines for all possible -// device control strings into the main parser. When a final character has -// been recognised in a device control string, this state will establish a -// channel to a handler for the appropriate control function, and then pass -// all subsequent characters through to this alternate handler, until the -// data string is terminated (usually by recognising the ST control -// function). -// -// This state has an exit action so that the control function handler can -// be informed when the data string has come to an end. This is so that the -// last soft character in a DECDLD string can be completed when there is no -// other means of knowing that its definition has ended, for example. -func dcsPassthrough(r rune, p *Parser) stateFn { - p.exit = p.unhook - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - p.put(r) - return dcsPassthrough - case in(r, 0x20, 0x7E): - p.put(r) - return dcsPassthrough - case is(r, 0x7F): - // ignore - return dcsPassthrough - default: - p.put(r) - return dcsPassthrough - } -} - -// This state is entered whenever the C0 control ESC is received. This will -// immediately cancel any escape sequence, control sequence or control -// string in progress. If an escape sequence or control sequence was in -// progress, “cancel” means that the sequence will have no effect, because -// the final character that determines the control function (in conjunction -// with any intermediates) will not have been received. However, the ESC -// that cancels a control string may occur after the control function has -// been determined and the following string has had some effect on terminal -// state. For example, some soft characters may already have been defined. -// Cancelling a control string does not undo these effects. -// -// A control string that started with DCS, OSC, PM or APC is usually -// terminated by the C1 control ST (String Terminator). In a 7-bit -// environment, ST will be represented by ESC \ (1B 5C). However, receiving -// the ESC character will “cancel” the control string, so the ST control -// function that is invoked by the arrival of the following “\” is -// essentially a “no-op” function. Does this point seem like pure trivia? -// Maybe, but I worried for ages about whether the control string -// recogniser needed a one character lookahead in order to know whether ESC -// \ was going to terminate it. The actual solution became clear when I was -// using ReGIS on a VT330: sending ESC immediately caused the graphics -// output cursor to disappear from the screen, so I knew that the control -// string had already finished before the “\” arrived. Many of the clues -// that enabled me to derive this state diagram have been as subtle as -// that. -func escape(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - p.execute(r) - return escape - case is(r, 0x7F): - // ignore - return escape - case in(r, 0x20, 0x2F): - p.collect(r) - return escapeIntermediate - case in(r, 0x30, 0x4F), - in(r, 0x51, 0x57), - is(r, 0x59, 0x5A, 0x5C), - in(r, 0x60, 0x7E): - p.escapeDispatch(r) - return ground - case is(r, 0x50): - p.clear() - return dcsEntry - case is(r, 0x58, 0x5E, 0x5F): - return sosPmApc - case is(r, 0x5B): - p.clear() - return csiEntry - case is(r, 0x5D): - p.oscStart() - return oscString - default: - // Return to ground on unexpected characters - return ground - } -} - -// This state is entered when an intermediate character arrives in an -// escape sequence. Escape sequences have no parameters, so the control -// function to be invoked is determined by the intermediate and final -// characters. In this parser there is just one escape intermediate, and -// the parser uses the collect action to remember intermediate characters -// as they arrive, for processing by the esc_dispatch action when the final -// character arrives. An alternate approach (and the one adopted by xterm) -// is to have multiple copies of this state and choose the next appropriate -// one as each intermediate character arrives. I think that this alternate -// approach is merely an optimisation; the approach presented here doesn’t -// require any more states if the repertoire of supported control functions -// increases. -// -// This state is only split from the escape state because certain escape -// sequences are the 7-bit representations of C1 controls that change the -// state of the parser. Without these “compatibility sequences”, there -// could just be one escape state to collect intermediates and dispatch the -// sequence when a final character was received. -func escapeIntermediate(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - p.execute(r) - return escapeIntermediate - case is(r, 0x7F): - // ignore - return escapeIntermediate - case in(r, 0x20, 0x2F): - p.collect(r) - return escapeIntermediate - case in(r, 0x30, 0x7E): - p.escapeDispatch(r) - return ground - default: - // Return to ground on unexpected characters - return ground - } -} - -// The VT500 doesn’t define any function for these control strings, so this -// state ignores all received characters until the control function ST is -// recognised. -func sosPmApc(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - // ignore - return sosPmApc - default: - return sosPmApc - } -} - -// This is the initial state of the parser, and the state used to consume -// all characters other than components of escape and control sequences. -// -// GL characters (20 to 7F) are printed. I have included 20 (SP) and 7F -// (DEL) in this area, although both codes have special behaviour. If a -// 94-character set is mapped into GL, 20 will cause a space to be -// displayed, and 7F will be ignored. When a 96-character set is mapped -// into GL, both 20 and 7F may cause a character to be displayed. Later -// models of the VT220 included the DEC Multinational Character Set (MCS), -// which has 94 characters in its supplemental set (i.e. the characters -// supplied in addition to ASCII), so terminals only claiming VT220 -// compatibility can always ignore 7F. The VT320 introduced ISO Latin-1, -// which has 96 characters in its supplemental set, so emulators with a -// VT320 compatibility mode need to treat 7F as a printable character. -func ground(r rune, p *Parser) stateFn { - switch { - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - p.execute(r) - return ground - case in(r, 0x20, 0x7F): - p.print(r) - return ground - default: - // Catchall for UTF-8 - p.print(r) - return ground - } -} - -// This state is entered when the control function OSC (Operating System -// Command) is recognised. On entry it prepares an external parser for OSC -// strings and passes all printable characters to a handler function. C0 -// controls other than CAN, SUB and ESC are ignored during reception of the -// control string. -// -// The only control functions invoked by OSC strings are DECSIN (Set Icon -// Name) and DECSWT (Set Window Title), present on the multisession VT520 -// and VT525 terminals. Earlier terminals treat OSC in the same way as PM -// and APC, ignoring the entire control string. -func oscString(r rune, p *Parser) stateFn { - switch { - case is(r, 0x07): - p.exit() - p.exit = nil - return ground - case in(r, 0x00, 0x17), is(r, 0x19), in(r, 0x1C, 0x1F): - // ignore - return oscString - case in(r, 0x20, 0x7F): - p.oscPut(r) - return oscString - default: - // catch all for UTF-8 - p.oscPut(r) - return oscString - } -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/parse_test.go b/cmd/sst/mosaic/multiplexer/tcell-term/parse_test.go deleted file mode 100644 index 6bc42331bf..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/parse_test.go +++ /dev/null @@ -1,885 +0,0 @@ -package tcellterm - -import ( - "bytes" - "reflect" - "strings" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestUTF8(t *testing.T) { - tests := []struct { - name string - input string - expected []Sequence - }{ - { - name: "UTF-8", - input: "🔥", - expected: []Sequence{ - Print('🔥'), - }, - }, - } - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - r := strings.NewReader(test.input) - parse := NewParser(r) - i := 0 - for { - seq := parse.Next() - if seq == nil { - assert.Equal(t, len(test.expected), i, "wrong amount of sequences") - break - } - if i < len(test.expected) { - assert.Equal(t, test.expected[i], seq) - } - i += 1 - } - }) - } -} - -func TestIn(t *testing.T) { - tests := []struct { - name string - inRange []rune - input rune - expected bool - }{ - { - name: "endpoint min", - inRange: []rune{0x00, 0x20}, - input: 0x00, - expected: true, - }, - { - name: "endpoint max", - inRange: []rune{0x00, 0x20}, - input: 0x20, - expected: true, - }, - { - name: "within", - inRange: []rune{0x00, 0x20}, - input: 0x19, - expected: true, - }, - { - name: "outside", - inRange: []rune{0x00, 0x20}, - input: 0x21, - expected: false, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - actual := in(test.input, test.inRange[0], test.inRange[1]) - assert.Equal(t, test.expected, actual) - }) - } -} - -func TestIs(t *testing.T) { - tests := []struct { - name string - isVals []rune - input rune - expected bool - }{ - { - name: "multiple", - isVals: []rune{0x00, 0x20}, - input: 0x00, - expected: true, - }, - { - name: "single", - isVals: []rune{0x00}, - input: 0x00, - expected: true, - }, - { - name: "false multiple", - isVals: []rune{0x00, 0x20}, - input: 0x19, - expected: false, - }, - { - name: "false single", - isVals: []rune{0x00}, - input: 0x21, - expected: false, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - actual := is(test.input, test.isVals...) - assert.Equal(t, test.expected, actual) - }) - } -} - -func TestAnywhere(t *testing.T) { - tests := []struct { - name string - input rune - expected stateFn - }{ - { - name: "0x18", - input: 0x18, - expected: ground, - }, - { - name: "0x1A", - input: 0x1A, - expected: ground, - }, - { - name: "0x1B", - input: 0x1B, - expected: escape, - }, - { - name: "eof", - input: eof, - expected: nil, - }, - } - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - r := bytes.NewBuffer(nil) - parse := NewParser(r) - called := false - parse.exit = func() { - called = true - } - actual := anywhere(test.input, parse) - act := reflect.ValueOf(actual).Pointer() - exp := reflect.ValueOf(test.expected).Pointer() - assert.Equal(t, exp, act, "wrong return function") - if test.expected != nil { - assert.True(t, called, "exit function not called") - } - }) - } -} - -func TestCSI(t *testing.T) { - tests := []struct { - name string - input string - expected []Sequence - }{ - { - name: "CSI Entry + C0", - input: "a\x1b[\x00", - expected: []Sequence{ - Print('a'), - C0(0x00), - }, - }, - { - name: "CSI Entry + escape", - input: "a\x1b[\x1b", - expected: []Sequence{ - Print('a'), - }, - }, - { - name: "CSI Entry + ignore", - input: "a\x1b[\x7F", - expected: []Sequence{ - Print('a'), - }, - }, - { - name: "CSI Entry + dispatch", - input: "a\x1b[c", - expected: []Sequence{ - Print('a'), - CSI{ - Final: 'c', - Intermediate: []rune{}, - Parameters: []int{}, - }, - }, - }, - { - name: "CSI Param with collect first", - input: "a\x1b[ lastLine { -// continue -// } -// -// visible = append(visible, visibleSixel{ -// ViewLineOffset: int(sixelImage.Y) - int(firstLine), -// Sixel: sixelImage, -// }) -// } -// -// return visible -// } -// -// func (t *Terminal) handleSixel(readChan chan measuredRune) (renderRequired bool) { -// var data []rune -// -// var inEscape bool -// -// for { -// r := <-readChan -// -// switch r.rune { -// case 0x1b: -// inEscape = true -// continue -// case 0x5c: -// if inEscape { -// t.activeBuffer.addSixel([]byte(string(data))) -// return true -// } -// } -// -// inEscape = false -// -// data = append(data, r.rune) -// } -// } diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/surface.go b/cmd/sst/mosaic/multiplexer/tcell-term/surface.go deleted file mode 100644 index ea79fccd84..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/surface.go +++ /dev/null @@ -1,15 +0,0 @@ -package tcellterm - -import "github.com/gdamore/tcell/v2" - -// Surface represents a logical view on an area. It uses a subset of methods -// from a tcell.Screen or a views.View, in order to be a more broad -// implementation. Both a Screen and a View are also a Surface -type Surface interface { - // SetContent is used to update the content of the Surface at the given - // location. - SetContent(x int, y int, ch rune, comb []rune, style tcell.Style) - - // Size represents the visible size. - Size() (int, int) -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tcell-term.info b/cmd/sst/mosaic/multiplexer/tcell-term/tcell-term.info deleted file mode 100644 index 8d608d71cf..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tcell-term.info +++ /dev/null @@ -1,47 +0,0 @@ -tcell-term|tcell-term embeddable terminal, - am, bce, bw, mir, msgr, xenl, - colors#1000000, cols#80, it#8, lines#24, pairs#1000000, - acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, - bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l, - clear=\E[H\E[2J, cnorm=\E[?12l\E[?25h, cr=\r, - csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, - cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C, - cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, - cvvis=\E[?12;25h, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, - dl=\E[%p1%dM, dl1=\E[M, dsl=\E]2;\E\\, ech=\E[%p1%dX, - ed=\E[J, el=\E[K, el1=\E[1K, home=\E[H, hpa=\E[%i%p1%dG, - ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, - il1=\E[L, ind=\n, indn=\E[%p1%dS, kDC=\E[3;2~, - kEND=\E[1;2F, kHOM=\E[1;2H, kIC=\E[2;2~, kLFT=\E[1;2D, - kNXT=\E[6;2~, kPRV=\E[5;2~, kRIT=\E[1;2C, kbs=^?, - kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, - kdch1=\E[3~, kend=\EOF, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, - kf12=\E[24~, kf13=\E[1;2P, kf14=\E[1;2Q, kf15=\E[1;2R, - kf16=\E[1;2S, kf17=\E[15;2~, kf18=\E[17;2~, - kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~, - kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~, - kf25=\E[1;5P, kf26=\E[1;5Q, kf27=\E[1;5R, kf28=\E[1;5S, - kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~, - kf32=\E[19;5~, kf33=\E[20;5~, kf34=\E[21;5~, - kf35=\E[23;5~, kf36=\E[24;5~, kf37=\E[1;6P, kf38=\E[1;6Q, - kf39=\E[1;6R, kf4=\EOS, kf40=\E[1;6S, kf41=\E[15;6~, - kf42=\E[17;6~, kf43=\E[18;6~, kf44=\E[19;6~, - kf45=\E[20;6~, kf46=\E[21;6~, kf47=\E[23;6~, - kf48=\E[24;6~, kf49=\E[1;3P, kf5=\E[15~, kf50=\E[1;3Q, - kf51=\E[1;3R, kf52=\E[1;3S, kf53=\E[15;3~, kf54=\E[17;3~, - kf55=\E[18;3~, kf56=\E[19;3~, kf57=\E[20;3~, - kf58=\E[21;3~, kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~, - kf61=\E[1;4P, kf62=\E[1;4Q, kf63=\E[1;4R, kf7=\E[18~, - kf8=\E[19~, kf9=\E[20~, khome=\EOH, kich1=\E[2~, - kind=\E[1;2B, kmous=\E[<, knp=\E[6~, kpp=\E[5~, - kri=\E[1;2A, op=\E[39;49m, rc=\E8, rep=%p1%c\E[%p2%{1}%-%db, - rev=\E[7m, ri=\EM, rin=\E[%p1%dT, ritm=\E[23m, rmacs=\E(B, - rmam=\E[?7l, rmcup=\E[?1049l,rmir=\E[4l, rmkx=\E[?1l\E>, - rmso=\E[27m, rmul=\E[24m, rs1=\Ec, sc=\E7, - setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48:5:%p1%d%;m, - setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38:5:%p1%d%;m, - sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m, - sgr0=\E(B\E[m, sitm=\E[3m, smacs=\E(0, smam=\E[?7h, smcup=\E[?1049h, - smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g, - BD=\E[?2004l, BE=\E[?2004h, PE=\E[201~, PS=\E[200~ - Se=\E[0 q, Ss=\E[%p1%d q, diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/terminfo.go b/cmd/sst/mosaic/multiplexer/tcell-term/terminfo.go deleted file mode 100644 index e3f0cbbf3b..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/terminfo.go +++ /dev/null @@ -1,289 +0,0 @@ -package tcellterm - -import "github.com/gdamore/tcell/v2/terminfo" - -// extended terminfo defines additional keys in a singular place, if missing -// from the terminfo.Terminfo struct -type extendedTerminfo struct { - KeyAltInsert string - KeyAltDelete string - KeyAltPgUp string - KeyAltPgDown string - - KeyCtrlInsert string - KeyCtrlDelete string - KeyCtrlPgUp string - KeyCtrlPgDown string - - KeyCtrlShfInsert string - KeyCtrlShfDelete string - KeyCtrlShfPgUp string - KeyCtrlShfPgDown string - - KeyAltShfInsert string - KeyAltShfDelete string - KeyAltShfPgUp string - KeyAltShfPgDown string - - KeyCtrlAltUp string - KeyCtrlAltDown string - KeyCtrlAltRight string - KeyCtrlAltLeft string - KeyCtrlAltHome string - KeyCtrlAltEnd string - KeyCtrlAltInsert string - KeyCtrlAltDelete string - KeyCtrlAltPgUp string - KeyCtrlAltPgDown string - - KeyCtrlAltShfUp string - KeyCtrlAltShfDown string - KeyCtrlAltShfRight string - KeyCtrlAltShfLeft string - KeyCtrlAltShfHome string - KeyCtrlAltShfEnd string - KeyCtrlAltShfInsert string - KeyCtrlAltShfDelete string - KeyCtrlAltShfPgUp string - KeyCtrlAltShfPgDown string -} - -var extendedInfo = &extendedTerminfo{ - KeyAltInsert: "\x1b[2;3~", - KeyAltDelete: "\x1b[3;3~", - KeyAltPgUp: "\x1b[5;3~", - KeyAltPgDown: "\x1b[6;3~", - - KeyCtrlInsert: "\x1b[2;5~", - KeyCtrlDelete: "\x1b[3;5~", - KeyCtrlPgUp: "\x1b[5;5~", - KeyCtrlPgDown: "\x1b[6;5~", - - KeyCtrlShfInsert: "\x1b[2;6~", - KeyCtrlShfDelete: "\x1b[3;6~", - KeyCtrlShfPgUp: "\x1b[5;6~", - KeyCtrlShfPgDown: "\x1b[6;6~", - - KeyAltShfInsert: "\x1b[2;4~", - KeyAltShfDelete: "\x1b[3;4~", - KeyAltShfPgUp: "\x1b[5;4~", - KeyAltShfPgDown: "\x1b[6;4~", - - KeyCtrlAltUp: "\x1b[1;7A", - KeyCtrlAltDown: "\x1b[1;7B", - KeyCtrlAltRight: "\x1b[1;7C", - KeyCtrlAltLeft: "\x1b[1;7D", - KeyCtrlAltHome: "\x1b[1;7H", - KeyCtrlAltEnd: "\x1b[1;7F", - KeyCtrlAltInsert: "\x1b[2;7~", - KeyCtrlAltDelete: "\x1b[3;7~", - KeyCtrlAltPgUp: "\x1b[5;7~", - KeyCtrlAltPgDown: "\x1b[6;7~", - - KeyCtrlAltShfUp: "\x1b[1;8A", - KeyCtrlAltShfDown: "\x1b[1;8B", - KeyCtrlAltShfRight: "\x1b[1;8C", - KeyCtrlAltShfLeft: "\x1b[1;8D", - KeyCtrlAltShfHome: "\x1b[1;8H", - KeyCtrlAltShfEnd: "\x1b[1;8F", - KeyCtrlAltShfInsert: "\x1b[2;8~", - KeyCtrlAltShfDelete: "\x1b[3;8~", - KeyCtrlAltShfPgUp: "\x1b[5;8~", - KeyCtrlAltShfPgDown: "\x1b[6;8~", -} - -var info = &terminfo.Terminfo{ - Name: "tcell-term", - Aliases: []string{}, - Columns: 80, // cols - Lines: 24, // lines - Colors: 256, // colors - Bell: "\a", // bell - Clear: "\x1b[H\x1b[2J", // clear - EnterCA: "\x1b[?1049h", // smcup - ExitCA: "\x1b[?1049l", // rmcup - ShowCursor: "\x1b[?12l\x1b[?25h", // cnorm - HideCursor: "\x1b[?25l", // civis - AttrOff: "\x1b(B\x1b[m", // sgr0 - Underline: "\x1b[4m", // smul - Bold: "\x1b[1m", // bold - Blink: "\x1b[5m", // blink - Reverse: "\x1b[7m", // rev - Dim: "\x1b[2m", // dim - Italic: "\x1b[3m", // sitm - EnterKeypad: "", // smkx - ExitKeypad: "", // rmkx - - SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38:5:%p1%d%;m", // setaf - SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48:5:%p1%d%;m", // setab - - ResetFgBg: "\x1b[39;49m", // op - SetCursor: "\x1b[%i%p1%d;%p2%dH", // cup - CursorBack1: "\b", // cub1 - CursorUp1: "\x1b[A", // cuu1 - PadChar: "\x00", // pad - KeyBackspace: "\x7F", // kbs - KeyF1: "\x1bOP", // kf1 - KeyF2: "\x1bOQ", // kf2 - KeyF3: "\x1bOR", // kf3 - KeyF4: "\x1bOS", // kf4 - KeyF5: "\x1b[15~", // kf5 - KeyF6: "\x1b[17~", // kf6 - KeyF7: "\x1b[18~", // kf7 - KeyF8: "\x1b[19~", // kf8 - KeyF9: "\x1b[20~", // kf9 - KeyF10: "\x1b[21~", // kf10 - KeyF11: "\x1b[23~", // kf11 - KeyF12: "\x1b[24~", // kf12 - KeyF13: "\x1b[1;2P", // kf13 - KeyF14: "\x1b[1;2Q", // kf14 - KeyF15: "\x1b[1;2R", // kf15 - KeyF16: "\x1b[1;2S", // kf16 - KeyF17: "\x1b[15;2~", // kf17 - KeyF18: "\x1b[17;2~", // kf18 - KeyF19: "\x1b[18;2~", // kf19 - KeyF20: "\x1b[19;2~", // kf20 - KeyF21: "\x1b[20;2~", // kf21 - KeyF22: "\x1b[21;2~", // kf22 - KeyF23: "\x1b[23;2~", // kf23 - KeyF24: "\x1b[24;2~", // kf24 - KeyF25: "\x1b[1;5P", // kf25 - KeyF26: "\x1b[1;5Q", // kf26 - KeyF27: "\x1b[1;5R", // kf27 - KeyF28: "\x1b[1;5S", // kf28 - KeyF29: "\x1b[15;5~", // kf29 - KeyF30: "\x1b[17;5~", // kf30 - KeyF31: "\x1b[18;5~", // kf31 - KeyF32: "\x1b[19;5~", // kf32 - KeyF33: "\x1b[20;5~", // kf33 - KeyF34: "\x1b[21;5~", // kf34 - KeyF35: "\x1b[23;5~", // kf35 - KeyF36: "\x1b[24;5~", // kf36 - KeyF37: "\x1b[1;6P", // kf37 - KeyF38: "\x1b[1;6Q", // kf38 - KeyF39: "\x1b[1;6R", // kf39 - KeyF40: "\x1b[1;6S", // kf40 - KeyF41: "\x1b[15;6~", // kf41 - KeyF42: "\x1b[17;6~", // kf42 - KeyF43: "\x1b[18;6~", // kf43 - KeyF44: "\x1b[19;6~", // kf44 - KeyF45: "\x1b[20;6~", // kf45 - KeyF46: "\x1b[21;6~", // kf46 - KeyF47: "\x1b[23;6~", // kf47 - KeyF48: "\x1b[24;6~", // kf48 - KeyF49: "\x1b[1;3P", // kf49 - KeyF50: "\x1b[1;3Q", // kf50 - KeyF51: "\x1b[1;3R", // kf51 - KeyF52: "\x1b[1;3S", // kf52 - KeyF53: "\x1b[15;3~", // kf53 - KeyF54: "\x1b[17;3~", // kf54 - KeyF55: "\x1b[18;3~", // kf55 - KeyF56: "\x1b[19;3~", // kf56 - KeyF57: "\x1b[20;3~", // kf57 - KeyF58: "\x1b[21;3~", // kf58 - KeyF59: "\x1b[23;3~", // kf59 - KeyF60: "\x1b[24;3~", // kf60 - KeyF61: "\x1b[1;4P", // kf61 - KeyF62: "\x1b[1;4Q", // kf62 - KeyF63: "\x1b[1;4R", // kf63 - KeyF64: "\x1b[1;4S", // kf64 - KeyInsert: "\x1b[2~", // kich1 - KeyDelete: "\x1b[3~", // kdch1 - KeyHome: "\x1bOH", // khome - KeyEnd: "\x1bOF", // kend - KeyHelp: "", // khlp - KeyPgUp: "\x1b[5~", // kpp - KeyPgDn: "\x1b[6~", // knp - KeyUp: "\x1bOA", // kcuu1 - KeyDown: "\x1bOB", // kcud1 - KeyRight: "\x1bOC", // kcuf1 - KeyLeft: "\x1bOD", // kcub1 - KeyBacktab: "\x1b[Z", // kcbt - KeyExit: "", // kext - KeyClear: "", // kclr - KeyPrint: "", // kprt - KeyCancel: "", // kcan - Mouse: "\x1b[<", // kmous - AltChars: "", // acsc - EnterAcs: "\x1b(0", // smacs - ExitAcs: "\x1b(B", // rmacs - EnableAcs: "", // enacs - KeyShfUp: "\x1b[1;2A", // kri - KeyShfDown: "\x1b[1;2B", // kind - KeyShfRight: "\x1b[1;2C", // kRIT - KeyShfLeft: "\x1b[1;2D", // kLFT - KeyShfHome: "\x1b[1;2H", // kHOM - KeyShfEnd: "\x1b[1;2F", // kEND - KeyShfInsert: "\x1b[2;2~", // kIC - KeyShfDelete: "\x1b[3;2~", // kDC - - // These are non-standard extensions to terminfo. This includes - // true color support, and some additional keys. Its kind of bizarre - // that shifted variants of left and right exist, but not up and down. - // Terminal support for these are going to vary amongst XTerm - // emulations, so don't depend too much on them in your application. - - StrikeThrough: "", // smxx - - SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38:5:%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48:5:%p2%d%;m", // setfgbg - - SetFgBgRGB: "", // setfgbgrgb - SetFgRGB: "", // setfrgb - SetBgRGB: "", // setbrgb - KeyShfPgUp: "\x1b[5;2~", // kPRV - KeyShfPgDn: "\x1b[6;2~", // kNXT - KeyCtrlUp: "\x1b[1;5A", // ctrl-up - KeyCtrlDown: "\x1b[1;5B", // ctrl-left - KeyCtrlRight: "\x1b[1;5C", // ctrl-right - KeyCtrlLeft: "\x1b[1;5D", // ctrl-left - KeyMetaUp: "\x1b[1;9A", // meta-up - KeyMetaDown: "\x1b[1;9B", // meta-left - KeyMetaRight: "\x1b[1;9C", // meta-right - KeyMetaLeft: "\x1b[1;9D", // meta-left - KeyAltUp: "\x1b[1;3A", // alt-up - KeyAltDown: "\x1b[1;3B", // alt-left - KeyAltRight: "\x1b[1;3C", // alt-right - KeyAltLeft: "\x1b[1;3D", // alt-left - KeyCtrlHome: "\x1b[1;5H", - KeyCtrlEnd: "\x1b[1;5F", - KeyMetaHome: "\x1b[1;9H", - KeyMetaEnd: "\x1b[1;9F", - KeyAltHome: "\x1b[1;3H", - KeyAltEnd: "\x1b[1;3F", - KeyAltShfUp: "\x1b[1;4A", - KeyAltShfDown: "\x1b[1;4B", - KeyAltShfRight: "\x1b[1;4C", - KeyAltShfLeft: "\x1b[1;4D", - KeyMetaShfUp: "\x1b[1;10A", - KeyMetaShfDown: "\x1b[1;10B", - KeyMetaShfLeft: "\x1b[1;10C", - KeyMetaShfRight: "\x1b[1;10D", - KeyCtrlShfUp: "\x1b[1;6A", - KeyCtrlShfDown: "\x1b[1;6B", - KeyCtrlShfRight: "\x1b[1;6C", - KeyCtrlShfLeft: "\x1b[1;6D", - KeyCtrlShfHome: "\x1b[1;6H", - KeyCtrlShfEnd: "\x1b[1;6F", - KeyAltShfHome: "\x1b[1;4H", - KeyAltShfEnd: "\x1b[1;4F", - KeyMetaShfHome: "\x1b[1;10H", - KeyMetaShfEnd: "\x1b[1;10F", - EnablePaste: "\x1b[?2004h", // BE - DisablePaste: "\x1b[?2004l", // BD - PasteStart: "\x1b[200~", // PS - PasteEnd: "\x1b[201~", // PE - Modifiers: 1, - InsertChar: "\x1b[@", // string to insert a character (ich1) - AutoMargin: true, // true if writing to last cell in line advances - TrueColor: true, // true if the terminal supports direct color - CursorDefault: "\x1b[0 q", // Se - CursorBlinkingBlock: "\x1b[1 q", - CursorSteadyBlock: "\x1b[2 q", - CursorBlinkingUnderline: "\x1b[3 q", - CursorSteadyUnderline: "\x1b[4 q", - CursorBlinkingBar: "\x1b[5 q", - CursorSteadyBar: "\x1b[6 q", - EnterUrl: "\x1b]8;%p2%s;%p1%s\x1b\\", - ExitUrl: "\x1b]8;;\x1b\\", - SetWindowSize: "", -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/README b/cmd/sst/mosaic/multiplexer/tcell-term/tests/README deleted file mode 100644 index 5e3c219a60..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/README +++ /dev/null @@ -1,6 +0,0 @@ -All tests in this directory should be compared against a known good terminal. -Personally, I compare to foot, but alacritty is known to be good too. The tests -can be run by 'cat'ing them to the terminal - -These tests are pulled from: -https://github.com/alacritty/alacritty/tree/master/alacritty_terminal/tests/ref diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/alt_reset b/cmd/sst/mosaic/multiplexer/tcell-term/tests/alt_reset deleted file mode 100644 index eb23719e15..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/alt_reset +++ /dev/null @@ -1,6 +0,0 @@ -[?2004h[kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ cargo cat ../alacritty.recording -[?2004l [?2004h[kchibisov@NightLord forks]$ [kchibisov@NightLord forks]$ [kchibisov@NightLord forks]$ princd Developer/rust/forks/alacritty htopprintf "\e[31;1;7;4;9mTEST asd\n" -[?2004l TEST asd -[?2004h[kchibisov@NightLord forks]$ [kchibisov@NightLord forks]$ htop -[?2004l [?1049h(B[?7h[?1h=[?25l[?1000h[?2004h[kchibisov@NightLord alacritty]$ [?2004l -exit diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/clear_undlerine b/cmd/sst/mosaic/multiplexer/tcell-term/tests/clear_undlerine deleted file mode 100644 index be36a43e2f..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/clear_undlerine +++ /dev/null @@ -1,5 +0,0 @@ -[undeadleech@undeadlap alacritty]$ echo -e "\e[4mUNDERLINED" -UNDERLINED -[undeadleech@undeadlap alacritty]$ clear -[undeadleech@undeadlap alacritty]$ exit -exit diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/colored_reset b/cmd/sst/mosaic/multiplexer/tcell-term/tests/colored_reset deleted file mode 100644 index b8fca085cb..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/colored_reset +++ /dev/null @@ -1,3 +0,0 @@ -[undeadleech@archhq colored_reset]$ printf "\e[41m" -[undeadleech@archhq colored_reset]$ [undeadleech@archhq colored_reset]$ printf "\e[0m" -[undeadleech@archhq colored_reset]$ ls - \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/colored_underline b/cmd/sst/mosaic/multiplexer/tcell-term/tests/colored_underline deleted file mode 100644 index 662d07c6dc..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/colored_underline +++ /dev/null @@ -1,3 +0,0 @@ -% ]133;A]2;kchibisov@Zodiac:~/src/rust/alacritty-workspace/fork fork on  colored-underlines-v3 via 🦀 v1.59.0 ➜ [?2004hcargo run -- --ref-test --config-file /dev/null -o scrolling.history=0echo -e '\e[58;2;255;0;255m\e[4:1mUNDERLINE\e[4:2mDOUBLE\e[58:5:196m\e[4:3mUh̷̗ERCURL\e[4:4mDOTTED\e[4:5mDASHED\e[59mNOT_COLORED_DASH\e[0m'[?2004l -]2;echo -e '\e[58;2;255;0;255m\e[4:1mUNDERLINE\e[4:2mDOUBLE\e[58:5:196m\e[4:3mUh̷̗ERCURL\e[4:4mDOTTED\e[4:5mDASHED\e[59mNOT_COLORED_DASH\e[0m'[4:1mUNDERLINE[4:2mDOUBLE[58:5:196m[4:3mUh̷̗ERCURL[4:4mDOTTED[4:5mDASHEDNOT_COLORED_DASH -% ]133;A]2;kchibisov@Zodiac:~/src/rust/alacritty-workspace/fork fork on  colored-underlines-v3 via 🦀 v1.59.0 ➜ [?2004h[?2004l diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/csi_rep b/cmd/sst/mosaic/multiplexer/tcell-term/tests/csi_rep deleted file mode 100644 index 9c78a0b649..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/csi_rep +++ /dev/null @@ -1,2 +0,0 @@ -% ]2;jwilm@jwilm-desk: ~/code/alacritty]1;..ode/alacritty jwilm@jwilm-desk ➜  ~/code/alacritty  [?1h=[?2004h -bck-i-search: _printf "f\e[10b"p_prr_prii_inn_ntt_tff_printf "f\e[10b" [?1l>[?2004l ]2;printf "f\e[10b"]1;printff% ]2;jwilm@jwilm-desk: ~/code/alacritty]1;..ode/alacritty jwilm@jwilm-desk ➜  ~/code/alacritty  [?1h=[?2004h \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/deccolm_reset b/cmd/sst/mosaic/multiplexer/tcell-term/tests/deccolm_reset deleted file mode 100644 index d30a08d06e..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/deccolm_reset +++ /dev/null @@ -1,30 +0,0 @@ -[?2004h[kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ echo -e "\033[?3h"printf "\e[31;1;7;4;9mTEST asd\n" -[?2004l TEST asd -[?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ printf "\e[31;1;7;4;9mTEST asd\n"echo -e "\033[?3h" -[?2004l [?3h -[?2004h[kchibisov@NightLord alacritty]$ \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/delete_chars_reset b/cmd/sst/mosaic/multiplexer/tcell-term/tests/delete_chars_reset deleted file mode 100644 index 1f6929a601..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/delete_chars_reset +++ /dev/null @@ -1,3 +0,0 @@ -[?2004h[kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ printf "\e[31;1;7;4;9md\n" -[?2004l d -[?2004h[kchibisov@NightLord alacritty]$ printf "\e[31;1;7;4;9md\n"d\n"d\n"d\n"d\n"d\n"d\n"d\n"d\n"d\n"d\n"d\n"d\n" \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/delete_lines b/cmd/sst/mosaic/multiplexer/tcell-term/tests/delete_lines deleted file mode 100644 index 2541d8feb6..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/delete_lines +++ /dev/null @@ -1,38 +0,0 @@ -[undeadleech@archhq alacritty]$ ls -lah -total 240K -drwxr-xr-x 17 undeadleech undeadleech 620 Nov 15 21:10 . -drwxrwxrwt 12 root root 300 Nov 15 21:08 .. --rw-r--r-- 1 undeadleech undeadleech 10 Nov 15 20:33 .agignore -drwxr-xr-x 3 undeadleech undeadleech 100 Nov 15 20:33 alacritty --rw-r--r-- 1 undeadleech undeadleech 41 Nov 15 21:10 alacritty.recording -drwxr-xr-x 4 undeadleech undeadleech 120 Nov 15 20:33 alacritty_terminal --rw-r--r-- 1 undeadleech undeadleech 17K Nov 15 20:33 alacritty.yml --rw-r--r-- 1 undeadleech undeadleech 128K Nov 15 20:33 Cargo.lock --rw-r--r-- 1 undeadleech undeadleech 245 Nov 15 20:33 Cargo.toml --rw-r--r-- 1 undeadleech undeadleech 22K Nov 15 20:38 CHANGELOG.md -drwxr-xr-x 4 undeadleech undeadleech 140 Nov 15 20:33 ci --rw-r--r-- 1 undeadleech undeadleech 5.5K Nov 15 20:33 CONTRIBUTING.md -drwxr-xr-x 2 undeadleech undeadleech 60 Nov 15 20:33 .copr -drwxr-xr-x 4 undeadleech undeadleech 160 Nov 15 20:33 copypasta -drwxr-xr-x 2 undeadleech undeadleech 60 Nov 15 20:33 docs -drwxr-xr-x 7 undeadleech undeadleech 180 Nov 15 20:33 extra -drwxr-xr-x 3 undeadleech undeadleech 80 Nov 15 20:33 font -drwxr-xr-x 8 undeadleech undeadleech 300 Nov 15 21:09 .git -drwxr-xr-x 2 undeadleech undeadleech 60 Nov 15 20:33 .github --rw-r--r-- 1 undeadleech undeadleech 333 Nov 15 20:33 .gitignore --rw-r--r-- 1 undeadleech undeadleech 9.1K Nov 15 20:33 INSTALL.md --rw-r--r-- 1 undeadleech undeadleech 11K Nov 15 20:33 LICENSE-APACHE --rw-r--r-- 1 undeadleech undeadleech 1.5K Nov 15 20:33 Makefile --rw-r--r-- 1 undeadleech undeadleech 6.8K Nov 15 20:33 README.md -drwxr-xr-x 2 undeadleech undeadleech 120 Nov 15 20:33 res --rw-r--r-- 1 undeadleech undeadleech 358 Nov 15 20:33 rustfmt.toml -drwxr-xr-x 2 undeadleech undeadleech 180 Nov 15 20:33 scripts -drwxr-xr-x 3 undeadleech undeadleech 100 Nov 15 20:33 servo-freetype-proxy -drwxr-xr-x 3 undeadleech undeadleech 80 Nov 15 20:36 target --rw-r--r-- 1 undeadleech undeadleech 1.7K Nov 15 20:33 .travis.yml -drwxr-xr-x 3 undeadleech undeadleech 100 Nov 15 20:33 winpty -[undeadleech@archhq alacritty]$ echo -[ "e "\e[10H" - -[undeadleech@archhq alacritty]$ echo -e "\e[1000M" - -[undeadleech@archhq alacritty]$ diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/erase_chars_reset b/cmd/sst/mosaic/multiplexer/tcell-term/tests/erase_chars_reset deleted file mode 100644 index ebe08116f5..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/erase_chars_reset +++ /dev/null @@ -1,5 +0,0 @@ -[?2004h[kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ echo -e "hello world" "\033[10;D" "\033[4;X" printf "\e[31;1;4;9mTEST asd\n" -[?2004l TEST asd -[?2004h[kchibisov@NightLord alacritty]$ printf "\e[31;1;4;9mTEST asd\n"echo -e "hello world" "\033[10;D" "\033[4;X" -[?2004l hello world   -[?2004h[kchibisov@NightLord alacritty]$ \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/erase_in_line b/cmd/sst/mosaic/multiplexer/tcell-term/tests/erase_in_line deleted file mode 100644 index c140222023..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/erase_in_line +++ /dev/null @@ -1,8 +0,0 @@ -[?2004h[undeadleech@archhq erase_in_line]$ s=$(echo {1..100}); echo ${s:0:$(($COLUMNS-2))}a$'+\e[0Kb' s=$(echo {1..100}); echo ${s:0:$(($COLUMNS-2))}a$'+\e[0Kb' -[?2004l 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49a+b -[?2004h[undeadleech@archhq erase_in_line]$ s=$(echo {1..100}); echo ${s:0:$(($COLUMNS-2))}a$'+\e[1Kb' s=$(echo {1..100}); echo ${s:0:$(($COLUMNS-2))}a$'+\e[1Kb' -[?2004l 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49a+b -[?2004h[undeadleech@archhq erase_in_line]$ s=$(echo {1..100}); echo ${s:0:$(($COLUMNS-2))}a$'+\e[2Kb' s=$(echo {1..100}); echo ${s:0:$(($COLUMNS-2))}a$'+\e[2Kb' -[?2004l 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49a+b -[?2004h[undeadleech@archhq erase_in_line]$ [?2004l -exit diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/fish_cc b/cmd/sst/mosaic/multiplexer/tcell-term/tests/fish_cc deleted file mode 100644 index d6cae7b89b..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/fish_cc +++ /dev/null @@ -1,6 +0,0 @@ -]50;CursorShape=0]0;fish alacritty(BWelcome to fish, the friendly interactive shell -Type help for instructions on how to use fish -]50;CursorShape=0]50;CursorShape=0]0;fish alacritty(B⏎(B [I](B ➜ alacritty git:(master) ✗(B aa(B52dec (B^C -]0;fish alacritty(B [I](B ➜ alacritty git:(master) ✗(B aa(B52dec (Ba(Bfire (Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(B^C - [I](B ➜ alacritty git:(master) ✗(B ]0;fish alacritty(B [I](B ➜ alacritty git:(master) ✗(B aa(B52dec (Ba(Bfire (Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(Ba(B^C -]0;fish alacritty(B [I](B ➜ alacritty git:(master) ✗(B  diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/grid_reset b/cmd/sst/mosaic/multiplexer/tcell-term/tests/grid_reset deleted file mode 100644 index 0e70d2dc90..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/grid_reset +++ /dev/null @@ -1,103 +0,0 @@ -%  UL  ~/…/tests/ref/grid_reset  dynamic-alloc  [?2004hfor i in {0..100}; do echo $i; donefor i in {0..100}; do echo $i; done[?2004l -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 -86 -87 -88 -89 -90 -91 -92 -93 -94 -95 -96 -97 -98 -99 -100 -c]104[!p[?3;4l> %  UL  ~/…/tests/ref/grid_reset  dynamic-alloc  [?2004h diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/hyperlinks b/cmd/sst/mosaic/multiplexer/tcell-term/tests/hyperlinks deleted file mode 100644 index f4d3bc9af3..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/hyperlinks +++ /dev/null @@ -1,14 +0,0 @@ -sh-5.2$ cat alacritty? _tir  erminal/tests/ref/hyperlinks/alacritty.recording -[?2004hsh-5.1$ printf '\e]8;;https://example.com\e\\foo\e]8;;\e\\\n' printf '\e]8;;https://example.com\e\\foo\e]8;;\e\\\n' -[?2004l ]8;;https://example.com\foo]8;;\ -[?2004hsh-5.1$ printf '\e]8;;https://example.com\e\\foo\e]8;;\e\\\n' printf '\e]8;;https://example.com\e\\foo\e]8;;\e\\\n' -[?2004l ]8;;https://example.com\foo]8;;\ -[?2004hsh-5.1$ printf '\e]8;id=42;https://example.com\e\\bar\e]8;;\e\\\n' printf '\e]8;id=42;https://example.com\e\\bar\e]8;;\e\\\n' -[?2004l ]8;id=42;https://example.com\bar]8;;\ -[?2004hsh-5.1$ printf '\e]8;id=42;https://example.com\e\\bar\e]8;;\e\\\n' printf '\e]8;id=42;https://example.com\e\\bar\e]8;;\e\\\n' -[?2004l ]8;id=42;https://example.com\bar]8;;\ -[?2004hsh-5.1$ [?2004l -exit -sh-5.2$ printf '\e]8;id=hello;http://example.com/naoheu;ntahoeu\e\\This is a link\e]8;id=hello;\e\\\n' -]8;id=hello;http://example.com/naoheu;ntahoeu\This is a link]8;id=hello;\ -sh-5.2$ exit diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/indexed_256_colors b/cmd/sst/mosaic/multiplexer/tcell-term/tests/indexed_256_colors deleted file mode 100644 index 6f2fb459f5..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/indexed_256_colors +++ /dev/null @@ -1,15 +0,0 @@ -% jwilm@kurast.local ➜  ~/code/alacritty  [?1h=[?2004h.././ccoolloorrss..p./colors.pl[?1l>[?2004l -]4;16;rgb:00/00/00\]4;17;rgb:00/00/5f\]4;18;rgb:00/00/87\]4;19;rgb:00/00/af\]4;20;rgb:00/00/d7\]4;21;rgb:00/00/ff\]4;22;rgb:00/5f/00\]4;23;rgb:00/5f/5f\]4;24;rgb:00/5f/87\]4;25;rgb:00/5f/af\]4;26;rgb:00/5f/d7\]4;27;rgb:00/5f/ff\]4;28;rgb:00/87/00\]4;29;rgb:00/87/5f\]4;30;rgb:00/87/87\]4;31;rgb:00/87/af\]4;32;rgb:00/87/d7\]4;33;rgb:00/87/ff\]4;34;rgb:00/af/00\]4;35;rgb:00/af/5f\]4;36;rgb:00/af/87\]4;37;rgb:00/af/af\]4;38;rgb:00/af/d7\]4;39;rgb:00/af/ff\]4;40;rgb:00/d7/00\]4;41;rgb:00/d7/5f\]4;42;rgb:00/d7/87\]4;43;rgb:00/d7/af\]4;44;rgb:00/d7/d7\]4;45;rgb:00/d7/ff\]4;46;rgb:00/ff/00\]4;47;rgb:00/ff/5f\]4;48;rgb:00/ff/87\]4;49;rgb:00/ff/af\]4;50;rgb:00/ff/d7\]4;51;rgb:00/ff/ff\]4;52;rgb:5f/00/00\]4;53;rgb:5f/00/5f\]4;54;rgb:5f/00/87\]4;55;rgb:5f/00/af\]4;56;rgb:5f/00/d7\]4;57;rgb:5f/00/ff\]4;58;rgb:5f/5f/00\]4;59;rgb:5f/5f/5f\]4;60;rgb:5f/5f/87\]4;61;rgb:5f/5f/af\]4;62;rgb:5f/5f/d7\]4;63;rgb:5f/5f/ff\]4;64;rgb:5f/87/00\]4;65;rgb:5f/87/5f\]4;66;rgb:5f/87/87\]4;67;rgb:5f/87/af\]4;68;rgb:5f/87/d7\]4;69;rgb:5f/87/ff\]4;70;rgb:5f/af/00\]4;71;rgb:5f/af/5f\]4;72;rgb:5f/af/87\]4;73;rgb:5f/af/af\]4;74;rgb:5f/af/d7\]4;75;rgb:5f/af/ff\]4;76;rgb:5f/d7/00\]4;77;rgb:5f/d7/5f\]4;78;rgb:5f/d7/87\]4;79;rgb:5f/d7/af\]4;80;rgb:5f/d7/d7\]4;81;rgb:5f/d7/ff\]4;82;rgb:5f/ff/00\]4;83;rgb:5f/ff/5f\]4;84;rgb:5f/ff/87\]4;85;rgb:5f/ff/af\]4;86;rgb:5f/ff/d7\]4;87;rgb:5f/ff/ff\]4;88;rgb:87/00/00\]4;89;rgb:87/00/5f\]4;90;rgb:87/00/87\]4;91;rgb:87/00/af\]4;92;rgb:87/00/d7\]4;93;rgb:87/00/ff\]4;94;rgb:87/5f/00\]4;95;rgb:87/5f/5f\]4;96;rgb:87/5f/87\]4;97;rgb:87/5f/af\]4;98;rgb:87/5f/d7\]4;99;rgb:87/5f/ff\]4;100;rgb:87/87/00\]4;101;rgb:87/87/5f\]4;102;rgb:87/87/87\]4;103;rgb:87/87/af\]4;104;rgb:87/87/d7\]4;105;rgb:87/87/ff\]4;106;rgb:87/af/00\]4;107;rgb:87/af/5f\]4;108;rgb:87/af/87\]4;109;rgb:87/af/af\]4;110;rgb:87/af/d7\]4;111;rgb:87/af/ff\]4;112;rgb:87/d7/00\]4;113;rgb:87/d7/5f\]4;114;rgb:87/d7/87\]4;115;rgb:87/d7/af\]4;116;rgb:87/d7/d7\]4;117;rgb:87/d7/ff\]4;118;rgb:87/ff/00\]4;119;rgb:87/ff/5f\]4;120;rgb:87/ff/87\]4;121;rgb:87/ff/af\]4;122;rgb:87/ff/d7\]4;123;rgb:87/ff/ff\]4;124;rgb:af/00/00\]4;125;rgb:af/00/5f\]4;126;rgb:af/00/87\]4;127;rgb:af/00/af\]4;128;rgb:af/00/d7\]4;129;rgb:af/00/ff\]4;130;rgb:af/5f/00\]4;131;rgb:af/5f/5f\]4;132;rgb:af/5f/87\]4;133;rgb:af/5f/af\]4;134;rgb:af/5f/d7\]4;135;rgb:af/5f/ff\]4;136;rgb:af/87/00\]4;137;rgb:af/87/5f\]4;138;rgb:af/87/87\]4;139;rgb:af/87/af\]4;140;rgb:af/87/d7\]4;141;rgb:af/87/ff\]4;142;rgb:af/af/00\]4;143;rgb:af/af/5f\]4;144;rgb:af/af/87\]4;145;rgb:af/af/af\]4;146;rgb:af/af/d7\]4;147;rgb:af/af/ff\]4;148;rgb:af/d7/00\]4;149;rgb:af/d7/5f\]4;150;rgb:af/d7/87\]4;151;rgb:af/d7/af\]4;152;rgb:af/d7/d7\]4;153;rgb:af/d7/ff\]4;154;rgb:af/ff/00\]4;155;rgb:af/ff/5f\]4;156;rgb:af/ff/87\]4;157;rgb:af/ff/af\]4;158;rgb:af/ff/d7\]4;159;rgb:af/ff/ff\]4;160;rgb:d7/00/00\]4;161;rgb:d7/00/5f\]4;162;rgb:d7/00/87\]4;163;rgb:d7/00/af\]4;164;rgb:d7/00/d7\]4;165;rgb:d7/00/ff\]4;166;rgb:d7/5f/00\]4;167;rgb:d7/5f/5f\]4;168;rgb:d7/5f/87\]4;169;rgb:d7/5f/af\]4;170;rgb:d7/5f/d7\]4;171;rgb:d7/5f/ff\]4;172;rgb:d7/87/00\]4;173;rgb:d7/87/5f\]4;174;rgb:d7/87/87\]4;175;rgb:d7/87/af\]4;176;rgb:d7/87/d7\]4;177;rgb:d7/87/ff\]4;178;rgb:d7/af/00\]4;179;rgb:d7/af/5f\]4;180;rgb:d7/af/87\]4;181;rgb:d7/af/af\]4;182;rgb:d7/af/d7\]4;183;rgb:d7/af/ff\]4;184;rgb:d7/d7/00\]4;185;rgb:d7/d7/5f\]4;186;rgb:d7/d7/87\]4;187;rgb:d7/d7/af\]4;188;rgb:d7/d7/d7\]4;189;rgb:d7/d7/ff\]4;190;rgb:d7/ff/00\]4;191;rgb:d7/ff/5f\]4;192;rgb:d7/ff/87\]4;193;rgb:d7/ff/af\]4;194;rgb:d7/ff/d7\]4;195;rgb:d7/ff/ff\]4;196;rgb:ff/00/00\]4;197;rgb:ff/00/5f\]4;198;rgb:ff/00/87\]4;199;rgb:ff/00/af\]4;200;rgb:ff/00/d7\]4;201;rgb:ff/00/ff\]4;202;rgb:ff/5f/00\]4;203;rgb:ff/5f/5f\]4;204;rgb:ff/5f/87\]4;205;rgb:ff/5f/af\]4;206;rgb:ff/5f/d7\]4;207;rgb:ff/5f/ff\]4;208;rgb:ff/87/00\]4;209;rgb:ff/87/5f\]4;210;rgb:ff/87/87\]4;211;rgb:ff/87/af\]4;212;rgb:ff/87/d7\]4;213;rgb:ff/87/ff\]4;214;rgb:ff/af/00\]4;215;rgb:ff/af/5f\]4;216;rgb:ff/af/87\]4;217;rgb:ff/af/af\]4;218;rgb:ff/af/d7\]4;219;rgb:ff/af/ff\]4;220;rgb:ff/d7/00\]4;221;rgb:ff/d7/5f\]4;222;rgb:ff/d7/87\]4;223;rgb:ff/d7/af\]4;224;rgb:ff/d7/d7\]4;225;rgb:ff/d7/ff\]4;226;rgb:ff/ff/00\]4;227;rgb:ff/ff/5f\]4;228;rgb:ff/ff/87\]4;229;rgb:ff/ff/af\]4;230;rgb:ff/ff/d7\]4;231;rgb:ff/ff/ff\]4;232;rgb:08/08/08\]4;233;rgb:12/12/12\]4;234;rgb:1c/1c/1c\]4;235;rgb:26/26/26\]4;236;rgb:30/30/30\]4;237;rgb:3a/3a/3a\]4;238;rgb:44/44/44\]4;239;rgb:4e/4e/4e\]4;240;rgb:58/58/58\]4;241;rgb:62/62/62\]4;242;rgb:6c/6c/6c\]4;243;rgb:76/76/76\]4;244;rgb:80/80/80\]4;245;rgb:8a/8a/8a\]4;246;rgb:94/94/94\]4;247;rgb:9e/9e/9e\]4;248;rgb:a8/a8/a8\]4;249;rgb:b2/b2/b2\]4;250;rgb:bc/bc/bc\]4;251;rgb:c6/c6/c6\]4;252;rgb:d0/d0/d0\]4;253;rgb:da/da/da\]4;254;rgb:e4/e4/e4\]4;255;rgb:ee/ee/ee\System colors: -         -         - -Color cube, 6x6x6: -                                          -                                          -                                          -                                          -                                          -                                          -Grayscale ramp: -                         -% jwilm@kurast.local ➜  ~/code/alacritty  [?1h=[?2004h \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/insert_blank_reset b/cmd/sst/mosaic/multiplexer/tcell-term/tests/insert_blank_reset deleted file mode 100644 index 6750852a27..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/insert_blank_reset +++ /dev/null @@ -1,5 +0,0 @@ -[?2004h[kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ resetprintf "\e[41;1;4;9mTEST asd\n"resetprintf "\e[41;1;4;9mTEST asd\n"[1@3 -[?2004l TEST asd -[?2004h[kchibisov@NightLord alacritty]$ printf "\e[31;1;4;9mTEST asd\n"resetprintf "\e[41;1;4;9mTEST asd\n"resetecho -e "\033[100;@" -[?2004l [100;@ -[?2004h[kchibisov@NightLord alacritty]$ diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/issue_855 b/cmd/sst/mosaic/multiplexer/tcell-term/tests/issue_855 deleted file mode 100644 index 2fa3494684..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/issue_855 +++ /dev/null @@ -1 +0,0 @@ -bck-i-search: t_tput cup 20 bck-i-search: tp_   tpuu_utt_sr 3 7tput [?1l>[?2004l ]2;tput csr 3 7]1;tput% ]2;jwilm@jwilm-desk: ~/code/alacritty]1;..ode/alacritty jwilm@jwilm-desk ➜  ~/code/alacritty  [?1h=[?2004h diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/kakoune b/cmd/sst/mosaic/multiplexer/tcell-term/tests/kakoune deleted file mode 100644 index d7d4d52894..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/kakoune +++ /dev/null @@ -1,3 +0,0 @@ -  -7~ $ [?25l8[5 q%  ~ $ [5 q[?25l ~ $ [?12l[?25h[5 q[?2004hkkakak[?2004l -]0;kak\[?1049h[?1004h[>4;1m[>5u[?25l=[?2026$p[?1006h[?1000h[?1002h]2;*scratch* 1:1 [scratch] 1 sel - client0@[70515] - Kakoune ╭─────────────────────────────────────┤Kakoune v2022.10.31├──────────────────────────────────────╮ │ • Kakoune v2022.10.31 │ │ »  does not end macro recording anymore, use Q │ │ » pipe commands do not append final end-of-lines anymore │ │ » complete-command to configure command completion │ │ » p, P, ! and  now select the inserted text │ │ » x now uses  behaviour │ │ »  and , have been swapped │ │  │ │ • Kakoune v2021.11.07 │ │ » colored and curly underlines support (undocumented in 20210828) │ │  │ │ • Kakoune v2021.10.28 │ │ » g and v do not auto-convert to lowercase anymore │ │  │ │ • Kakoune v2021.08.28 │ │ » write  will refuse to overwrite without -force │ │ » $kak_command_fifo support │ │ » set-option -remove support │ │ » prompts auto select menu completions on space │ │ » explicit completion support (...) in prompts │ │ » write -atomic was replaced with write -method  │ │  │ ╭──╮ │ • Kakoune v2020.09.01 │ │ │ │ » daemon mode does not fork anymore │ @ @ ╭│  │ ││ ││ ││ • Kakoune v2020.08.04 │ ││ ││ ╯│ » User hook support │ │╰─╯│ │ » Removed bold and italic faces from colorschemes │ ╰───╯ │ » Read from stdin support for clients │ │ » rgba:RRGGBBAA faces and alpha blending │ │  │ │ • Kakoune v2020.01.16 │ │ » InsertCompletionHide parameter is now the list of inserted ranges │ │  │ │ • Kakoune v2019.12.10 │ │ » ModeChange parameter has changed to contain push/pop │ │ » ModeBegin/ModeEnd hooks were removed │ │  │ │ • Kakoune v2019.07.01 │ │ » %file{} expansions to read files │ │ » echo -to-file  to write to file │ │ » completions option have an on select command instead of a docstring │ │ » Function key syntax do not accept lower case f anymore │ │ » shell quoting of list options is now opt-in with $kak_quoted_... │ │  │ │ • Kakoune v2019.01.20 │ │ » named capture groups in regex │ │ » auto_complete option renamed to autocomplete │ │  │ │ • Kakoune v2018.10.27 │ │ » define-commands -shell-completion and -shell-candidates has been renamed │ │ » exclusive face attributes is replaced with final (fg/bg/attr) │ ╰─┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄─╯*scratch* 1:1 [scratch] 1 sel - client0@[70515]]2;*scratch* 1:1 [scratch] 1 sel - client0@[70515] - Kakoune ╭─────────────────────────────────────┤Kakoune v2022.10.31├──────────────────────────────────────╮ │ • Kakoune v2022.10.31 │ │ »  does not end macro recording anymore, use Q │ │ » pipe commands do not append final end-of-lines anymore │ │ » complete-command to configure command completion │ │ » p, P, ! and  now select the inserted text │ │ » x now uses  behaviour │ │ »  and , have been swapped │ │  │ │ • Kakoune v2021.11.07 │ │ » colored and curly underlines support (undocumented in 20210828) │ │  │ │ • Kakoune v2021.10.28 │ │ » g and v do not auto-convert to lowercase anymore │ │  │ │ • Kakoune v2021.08.28 │ │ » write  will refuse to overwrite without -force │ │ » $kak_command_fifo support │ │ » set-option -remove support │ │ » prompts auto select menu completions on space │ │ » explicit completion support (...) in prompts │ │ » write -atomic was replaced with write -method  │ │  │ ╭──╮ │ • Kakoune v2020.09.01 │ │ │ │ » daemon mode does not fork anymore │ @ @ ╭│  │ ││ ││ ││ • Kakoune v2020.08.04 │ ││ ││ ╯│ » User hook support │ │╰─╯│ │ » Removed bold and italic faces from colorschemes │ ╰───╯ │ » Read from stdin support for clients │ │ » rgba:RRGGBBAA faces and alpha blending │ │  │ │ • Kakoune v2020.01.16 │ │ » InsertCompletionHide parameter is now the list of inserted ranges │ │  │ │ • Kakoune v2019.12.10 │ │ » ModeChange parameter has changed to contain push/pop │ │ » ModeBegin/ModeEnd hooks were removed │ │  │ │ • Kakoune v2019.07.01 │ │ » %file{} expansions to read files │ │ » echo -to-file  to write to file │ │ » completions option have an on select command instead of a docstring │ │ » Function key syntax do not accept lower case f anymore │ │ » shell quoting of list options is now opt-in with $kak_quoted_... │ │  │ │ • Kakoune v2019.01.20 │ │ » named capture groups in regex │ │ » auto_complete option renamed to autocomplete │ │  │ │ • Kakoune v2018.10.27 │ │ » define-commands -shell-completion and -shell-candidates has been renamed │ │ » exclusive face attributes is replaced with final (fg/bg/attr) │ ╰─┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄─╯*scratch* 1:1 [scratch] 1 sel - client0@[70515]]2;*scratch* 1:1 [scratch] prompt - client0@[70515] - Kakoune*** this is a *scratch* buffer which won't be automatically saved ****** use it for notes or open a file buffer with the :edit command ***~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~: *scratch* 1:1 [scratch] prompt - client0@[70515]]2;*scratch* 1:1 [scratch] prompt - client0@[70515] - Kakouneadd-highlighterbcomment-line█addhlbncompl█aliasbpcomplete-command█align-selections-leftbufferctags-complete░arrange-buffersbuffer-nextctags-disable-autocomplete░autorestore-disablebuffer-previousctags-disable-autoinfo░autorestore-purge-backupscdctags-enable-autocomplete░autorestore-restore-bufferchange-directoryctags-enable-autoinfo░autowrap-disablecolorschemectags-funcinfo░autowrap-enablecomment-blockctags-generate░: *scratch* 1:1 [scratch] prompt - client0@[70515]]2;*scratch* 1:1 [scratch] prompt - client0@[70515] - Kakoune:q *scratch* 1:1 [scratch] prompt - client0@[70515]]2;*scratch* 1:1 [scratch] prompt - client0@[70515] - Kakoune~ ╭──╮ ╭─────────────────────────────────────────────┤quit├─────────────────────────────────────────────╮ │ │ │ quit []: quit current client, and the kakoune session if the client is the last ( │ @ @ ╭│ if not running in daemon mode). An optional integer parameter can set the client exit status │ ││ ││ ││ Aliases: q │ ││ ││ ╯╰────────────────────────────────────────────────────────────────────────────────────────────────╯ │╰─╯│  ╰───╯ qquitwrite-quitwrite-all-quit wq!waq█q!quit!write-quit!wqrequire-module█:q *scratch* 1:1 [scratch] prompt - client0@[70515][?1002l[?1000l[?1006l>[?25h[?1004l[?1049l% ~ $ [5 q[?25l ~ $ [?12l[?25h[5 q[?2004h ~ $  \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/ll b/cmd/sst/mosaic/multiplexer/tcell-term/tests/ll deleted file mode 100644 index 8421359ce4..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/ll +++ /dev/null @@ -1,27 +0,0 @@ -% jwilm@kurast.local ➜  ~/code/alacritty  [?1h=[?2004hlll[?1l>[?2004l -total 16440 -drwxr-xr-x 3 jwilm staff 102B Nov 2 10:54 Alacritty.app --rw-r--r-- 1 jwilm staff 53K Nov 19 14:27 Cargo.lock --rw-r--r-- 1 jwilm staff 746B Nov 19 14:24 Cargo.toml --rw-r--r-- 1 jwilm staff 11K Jun 30 10:44 LICENSE-APACHE --rw-r--r-- 1 jwilm staff 1.6K Nov 2 10:52 Makefile --rw-r--r-- 1 jwilm staff 49B Jun 9 18:56 TASKS.md --rwxr-xr-x 1 jwilm staff 1.7M Sep 26 10:49 alacritty-pre-eloop --rw-r--r-- 1 jwilm staff 255B Nov 19 14:31 alacritty.recording --rw-r--r-- 1 jwilm staff 6.5K Nov 17 17:18 alacritty.yml --rw-r--r-- 1 jwilm staff 1.1K Jun 30 10:44 build.rs -drwxr-xr-x 6 jwilm staff 204B Oct 10 10:46 copypasta -drwxr-xr-x 3 jwilm staff 102B Jun 9 18:56 docs --rwxr-xr-x 1 jwilm staff 2.2M Nov 11 17:53 exitter -drwxr-xr-x 5 jwilm staff 170B Jun 28 14:50 font --rwxr-xr-x 1 jwilm staff 2.2M Nov 14 13:27 hardcoded_bindings_alacritty -drwxr-xr-x 6 jwilm staff 204B Nov 2 10:54 macos -drwxr-xr-x 4 jwilm staff 136B Oct 27 17:59 res --rw-r--r-- 1 jwilm staff 19B Nov 11 16:55 rustc-version -drwxr-xr-x 5 jwilm staff 170B Oct 10 10:46 scripts -drwxr-xr-x 17 jwilm staff 578B Nov 19 14:30 src -drwxr-xr-x 5 jwilm staff 170B Jun 28 15:49 target --rw-r--r-- 1 jwilm staff 8.1K Nov 17 11:13 thing.log --rw-r--r-- 1 jwilm staff 3.5K Sep 1 11:27 tmux-client-23038.log --rwxr-xr-x 1 jwilm staff 1.8M Sep 22 12:03 with_parallel -% jwilm@kurast.local ➜  ~/code/alacritty  [?1h=[?2004h \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/newline_with_cursor_beyond_scroll_region b/cmd/sst/mosaic/multiplexer/tcell-term/tests/newline_with_cursor_beyond_scroll_region deleted file mode 100644 index f9b23863fc..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/newline_with_cursor_beyond_scroll_region +++ /dev/null @@ -1,4 +0,0 @@ -% ]2;jwilm@jwilm-desk: ~/code/alacritty]1;..ode/alacritty jwilm@jwilm-desk ➜  ~/code/alacritty  [?1h=[?2004h -bck-i-search: _clear; cat ~/Downloads/xtest.txt; sleep 100c_caa_att_clearcat ~/Downloads/xtest.txtsleep [?1l>[?2004l ]2;clear; cat ~/Downloads/xtest.txt; sleep 100]1;clear; - 58 getprogname());  59 exit 9 9 - 59 !!!! diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/region_scroll_down b/cmd/sst/mosaic/multiplexer/tcell-term/tests/region_scroll_down deleted file mode 100644 index 34fc7f8be3..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/region_scroll_down +++ /dev/null @@ -1,46 +0,0 @@ -%  UL  ~/…/tests/ref/region_scroll_…  scroll_down    UL  ~/…/tests/ref/region_scroll_…  scroll_down  [?2004hecho -ne "\e[10000T" && sleep infinityecho "test"                           test"[?2004l -test -%  UL  ~/…/tests/ref/region_scroll_…  scroll_down    UL  ~/…/tests/ref/region_scroll_…  scroll_down  [?2004hlsls -lah-lah[?2004l -total 12K -drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 24 23:58 . -drwxr-xr-x 37 undeadleech undeadleech 4.0K Jun 24 23:57 .. --rw-r--r-- 1 undeadleech undeadleech 1.3K Jun 24 23:58 alacritty.recording -%  UL  ~/…/tests/ref/region_scroll_…  scroll_down    UL  ~/…/tests/ref/region_scroll_…  scroll_down  [?2004hls -lah[?2004l -total 12K -drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 24 23:58 . -drwxr-xr-x 37 undeadleech undeadleech 4.0K Jun 24 23:57 .. --rw-r--r-- 1 undeadleech undeadleech 1.9K Jun 24 23:58 alacritty.recording -%  UL  ~/…/tests/ref/region_scroll_…  scroll_down    UL  ~/…/tests/ref/region_scroll_…  scroll_down  [?2004hls -lahls -lah bin/snapshot.undo/      ./mov/.. ./../..[?2004l -total 300K -drwxr-xr-x 15 undeadleech undeadleech 4.0K Jun 24 23:53 . -drwxr-xr-x 34 undeadleech undeadleech 4.0K Jun 18 03:26 .. --rw-r--r-- 1 undeadleech undeadleech 10 Feb 8 2019 .agignore -drwxr-xr-x 3 undeadleech undeadleech 4.0K Jun 24 23:24 alacritty -drwxr-xr-x 4 undeadleech undeadleech 4.0K Jun 24 23:24 alacritty_terminal --rw-r--r-- 1 undeadleech undeadleech 21K Jun 24 23:24 alacritty.yml -drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 24 18:47 .builds --rw-r--r-- 1 undeadleech undeadleech 116K Jun 24 23:24 Cargo.lock --rw-r--r-- 1 undeadleech undeadleech 141 Jun 23 21:20 Cargo.toml --rw-r--r-- 1 undeadleech undeadleech 30K Jun 24 23:53 CHANGELOG.md -drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 24 18:47 ci --rw-r--r-- 1 undeadleech undeadleech 7.3K Jun 23 21:20 CONTRIBUTING.md -drwxr-xr-x 2 undeadleech undeadleech 4.0K Mar 6 00:06 .copr -drwxr-xr-x 2 undeadleech undeadleech 4.0K Feb 8 2019 docs -drwxr-xr-x 7 undeadleech undeadleech 4.0K Jun 23 21:20 extra -drwxr-xr-x 3 undeadleech undeadleech 4.0K Jun 23 21:20 font -drwxr-xr-x 8 undeadleech undeadleech 4.0K Jun 24 23:58 .git --rw-r--r-- 1 undeadleech undeadleech 26 Jun 23 21:20 .gitattributes -drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 23 21:20 .github --rw-r--r-- 1 undeadleech undeadleech 341 Jun 23 21:20 .gitignore --rw-r--r-- 1 undeadleech undeadleech 8.9K Jun 23 21:20 INSTALL.md --rw-r--r-- 1 undeadleech undeadleech 11K Jun 23 21:20 LICENSE-APACHE --rw-r--r-- 1 undeadleech undeadleech 1.5K Jun 23 21:20 Makefile --rw-r--r-- 1 undeadleech undeadleech 7.1K Jun 23 21:20 README.md -drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 23 21:20 res --rw-r--r-- 1 undeadleech undeadleech 358 Mar 6 00:06 rustfmt.toml -drwxr-xr-x 2 undeadleech undeadleech 4.0K Jun 23 21:20 scripts -drwxr-xr-x 4 undeadleech undeadleech 4.0K Jun 20 23:09 target --rw-r--r-- 1 undeadleech undeadleech 2.6K Jun 24 18:47 .travis.yml -%  UL  ~/…/tests/ref/region_scroll_…  scroll_down    UL  ~/…/tests/ref/region_scroll_…  scroll_down  [?2004hecho "test"echo -ne "\e[10000T" && sleep infinitye "\e[1  "\e[1001[e\" ne "\e[10000T" && sleep infinityne "\e[10000T" && sleep infinity[?2004l -^C -%  UL  ~/…/tests/ref/region_scroll_…  scroll_down    UL  ~/…/tests/ref/region_scroll_…  scroll_down  [?2004hecho -ne "\e[10000T" && sleep infinityexit                                  it[?2004l diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/row_reset b/cmd/sst/mosaic/multiplexer/tcell-term/tests/row_reset deleted file mode 100644 index 7619aeb3ff..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/row_reset +++ /dev/null @@ -1,616 +0,0 @@ -[undeadleech@archhq row_reset]$ cat ~/downloads/dmesg.txt -[228741.085647] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[228741.091432] wlp3s0: authenticate with 00:00:00:00:00:00 -[228741.097335] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[228741.135972] wlp3s0: authenticated -[228741.141525] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[228741.142955] wlp3s0: RX ReassocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=1) -[228741.144318] wlp3s0: associated -[228741.154942] wlp3s0: Limiting TX power to 23 (23 - 0) dBm as advertised by 00:00:00:00:00:00 -[228918.086333] wlp3s0: deauthenticated from 00:00:00:00:00:00 (Reason: 6=CLASS2_FRAME_FROM_NONAUTH_STA) -[229303.946685] wlp3s0: authenticated -[229303.947705] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[229303.948917] wlp3s0: RX ReassocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=1) -[229303.949916] wlp3s0: associated -[229304.048604] wlp3s0: Limiting TX power to 23 (23 - 0) dBm as advertised by 00:00:00:00:00:00 -[229396.541447] wlp3s0: deauthenticated from 00:00:00:00:00:00 (Reason: 6=CLASS2_FRAME_FROM_NONAUTH_STA) -[229398.267553] wlp3s0: authenticate with 00:00:00:00:00:00 -[229398.273829] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[229398.314512] wlp3s0: authenticated -[229398.315473] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[229398.316742] wlp3s0: RX AssocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=3) -[229398.318551] wlp3s0: associated -[229398.373686] wlp3s0: Limiting TX power to 30 (30 - 0) dBm as advertised by 00:00:00:00:00:00 -[229430.169385] wlp3s0: disconnect from AP 00:00:00:00:00:00 for new auth to 00:00:00:00:00:00 -[229430.209398] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209406] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209409] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209411] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209414] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209417] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209419] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209421] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209424] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209426] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209429] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209431] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209433] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209435] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209441] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209444] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209446] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209447] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209449] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209451] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209453] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209455] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209457] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209458] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209462] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209464] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209466] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209468] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209470] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209472] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209474] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209476] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209478] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209480] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209481] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209483] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209485] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209487] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209490] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209493] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209495] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209500] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209503] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.209506] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213606] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213610] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213612] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213614] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213616] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213617] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213619] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213621] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213623] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213624] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213626] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213628] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213630] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213632] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213634] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213635] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213639] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213641] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213642] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213644] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213646] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213649] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213651] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213654] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213656] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213658] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213661] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213663] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213666] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213668] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213670] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213673] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213674] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213676] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213678] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213680] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213681] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213683] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213685] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213689] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213691] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213693] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213694] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213696] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213698] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213700] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213701] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213704] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213706] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213708] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213711] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213713] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.213716] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218481] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218509] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218521] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218528] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218546] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218551] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218561] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218566] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218590] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218597] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218609] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218614] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218622] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218626] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218635] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218639] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218647] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218650] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218660] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218663] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218673] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218677] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218681] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218685] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218697] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218700] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218707] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218710] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218716] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218723] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218726] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218733] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218736] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218743] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.218747] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.219801] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.219834] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.219853] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.219858] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.219866] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.219870] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.219878] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229430.221124] wlp3s0: authenticate with 00:00:00:00:00:00 -[229430.222243] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[229430.262505] wlp3s0: authenticated -[229430.263310] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[229430.264564] wlp3s0: RX ReassocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=1) -[229430.266358] wlp3s0: associated -[229430.307441] wlp3s0: Limiting TX power to 23 (23 - 0) dBm as advertised by 00:00:00:00:00:00 -[229517.132398] wlp3s0: deauthenticated from 00:00:00:00:00:00 (Reason: 6=CLASS2_FRAME_FROM_NONAUTH_STA) -[229518.888561] wlp3s0: authenticate with 00:00:00:00:00:00 -[229518.894662] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[229518.937199] wlp3s0: authenticated -[229518.939160] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[229518.940460] wlp3s0: RX AssocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=3) -[229518.942378] wlp3s0: associated -[229519.001616] wlp3s0: Limiting TX power to 30 (30 - 0) dBm as advertised by 00:00:00:00:00:00 -[229824.281089] wlp3s0: disconnect from AP 00:00:00:00:00:00 for new auth to 00:00:00:00:00:00 -[229824.291293] wlp3s0: authenticate with 00:00:00:00:00:00 -[229824.297136] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[229824.336092] wlp3s0: authenticated -[229824.338750] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[229824.340205] wlp3s0: RX ReassocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=1) -[229824.341469] wlp3s0: associated -[229824.343528] wlp3s0: Limiting TX power to 23 (23 - 0) dBm as advertised by 00:00:00:00:00:00 -[229879.108005] wlp3s0: deauthenticated from 00:00:00:00:00:00 (Reason: 6=CLASS2_FRAME_FROM_NONAUTH_STA) -[229880.382542] wlp3s0: authenticate with 00:00:00:00:00:00 -[229880.389268] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[229880.429992] wlp3s0: authenticated -[229880.433634] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[229880.434832] wlp3s0: RX AssocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=3) -[229880.436867] wlp3s0: associated -[229880.475867] wlp3s0: Limiting TX power to 30 (30 - 0) dBm as advertised by 00:00:00:00:00:00 -[229893.920859] wlp3s0: disconnect from AP 00:00:00:00:00:00 for new auth to 00:00:00:00:00:00 -[229893.927177] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229893.927189] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229893.927191] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229893.927194] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229893.927196] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229893.927198] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229893.927201] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[229893.930495] iwlwifi 0000:03:00.0: Unhandled alg: 0x703 -[229893.930531] iwlwifi 0000:03:00.0: Unhandled alg: 0x703 -[229893.930536] iwlwifi 0000:03:00.0: Unhandled alg: 0x703 -[229893.930541] iwlwifi 0000:03:00.0: Unhandled alg: 0x703 -[229893.930548] iwlwifi 0000:03:00.0: Unhandled alg: 0x703 -[229893.930552] iwlwifi 0000:03:00.0: Unhandled alg: 0x703 -[229893.930557] iwlwifi 0000:03:00.0: Unhandled alg: 0x703 -[229893.935133] wlp3s0: authenticate with 00:00:00:00:00:00 -[229893.940801] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[229893.981689] wlp3s0: authenticated -[229893.986136] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[229893.989747] wlp3s0: RX ReassocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=1) -[229893.992245] wlp3s0: associated -[229894.077777] wlp3s0: Limiting TX power to 23 (23 - 0) dBm as advertised by 00:00:00:00:00:00 -[230231.830965] CPU9: Core temperature above threshold, cpu clock throttled (total events = 15794) -[230231.830966] CPU8: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.830967] CPU3: Core temperature above threshold, cpu clock throttled (total events = 15794) -[230231.830968] CPU2: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.830969] CPU3: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.830972] CPU9: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.831043] CPU0: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.831044] CPU1: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.831045] CPU7: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.831047] CPU10: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.831047] CPU6: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.831049] CPU4: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.831051] CPU11: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.831052] CPU5: Package temperature above threshold, cpu clock throttled (total events = 23046) -[230231.837979] CPU3: Core temperature/speed normal -[230231.837980] CPU9: Core temperature/speed normal -[230231.837981] CPU2: Package temperature/speed normal -[230231.837982] CPU8: Package temperature/speed normal -[230231.837983] CPU6: Package temperature/speed normal -[230231.837984] CPU0: Package temperature/speed normal -[230231.837985] CPU5: Package temperature/speed normal -[230231.837987] CPU10: Package temperature/speed normal -[230231.837988] CPU1: Package temperature/speed normal -[230231.837989] CPU11: Package temperature/speed normal -[230231.837991] CPU7: Package temperature/speed normal -[230231.837992] CPU4: Package temperature/speed normal -[230231.837994] CPU9: Package temperature/speed normal -[230231.838001] CPU3: Package temperature/speed normal -[230236.392394] wlp3s0: deauthenticated from 00:00:00:00:00:00 (Reason: 3=DEAUTH_LEAVING) -[230237.780651] wlp3s0: authenticate with 00:00:00:00:00:00 -[230237.787938] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[230237.828603] wlp3s0: authenticated -[230237.832087] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[230237.833363] wlp3s0: RX AssocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=3) -[230237.834675] wlp3s0: associated -[230237.854441] wlp3s0: Limiting TX power to 30 (30 - 0) dBm as advertised by 00:00:00:00:00:00 -[230257.232908] wlp3s0: disconnect from AP 00:00:00:00:00:00 for new auth to 00:00:00:00:00:00 -[230257.238433] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[230257.238455] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[230257.238511] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[230257.238519] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[230257.238530] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[230257.238537] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[230257.238562] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[230257.238572] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[230257.238586] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[230257.238595] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[230257.240338] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240418] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240471] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240489] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240506] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240525] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240557] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240571] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240606] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240618] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240635] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240653] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240688] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240714] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240741] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240755] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.240774] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243219] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243261] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243279] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243291] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243304] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243318] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243334] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243346] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243362] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243374] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243388] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243400] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243422] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243435] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243448] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243458] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243491] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243504] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243533] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243544] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243558] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243568] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243581] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243590] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243600] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243611] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243641] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243650] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243671] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243680] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243691] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243700] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243719] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.243728] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247443] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247471] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247484] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247492] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247501] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247509] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247517] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247525] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247550] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247559] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247567] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247575] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247596] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247604] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247612] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247620] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247629] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247637] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247648] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247655] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247663] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247671] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247680] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247688] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247698] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247707] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247716] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247723] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247733] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247741] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247749] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247756] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247765] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247773] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247781] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247788] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247809] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.247817] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251792] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251818] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251832] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251842] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251851] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251860] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251897] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251908] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251919] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251928] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251939] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251949] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251960] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251970] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.251982] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252017] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252032] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252042] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252054] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252065] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252076] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252086] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252101] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252111] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252123] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252133] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252140] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252147] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252157] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252167] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252178] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252187] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252197] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252207] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252220] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252230] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252240] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252250] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252265] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252276] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252287] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252294] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.252302] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256114] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256136] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256148] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256158] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256168] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256176] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256185] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256192] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256210] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256220] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256230] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256240] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256251] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256259] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256266] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256273] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256281] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256288] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256295] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256302] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256310] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256317] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256325] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256332] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256343] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256353] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256376] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256384] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256392] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256407] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256419] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256426] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256433] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256441] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256448] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256456] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256465] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256472] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256480] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256488] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256499] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256510] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256520] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256527] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256535] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256542] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256549] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256556] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256564] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256571] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.256579] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260414] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260471] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260502] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260515] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260559] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260574] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260590] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260606] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260622] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260632] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260646] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260671] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260685] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260696] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260710] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260722] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260742] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260768] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260782] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260792] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260815] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260827] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260843] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260855] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260869] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260880] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260891] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260903] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260916] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260928] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260947] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260962] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260975] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.260986] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264813] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264838] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264851] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264862] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264873] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264883] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264892] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264899] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264907] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264914] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264921] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264933] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264946] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264953] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264961] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264968] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264984] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264992] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.264999] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265006] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265014] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265021] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265028] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265036] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265044] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265051] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265062] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265069] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265078] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265087] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265103] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265110] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265120] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265127] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265135] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265142] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265151] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.265158] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269374] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269404] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269418] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269429] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269439] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269448] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269458] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269467] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269476] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269485] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269502] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269511] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269520] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269529] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269539] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269550] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269561] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269570] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269582] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269592] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269603] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269613] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269627] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269637] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269650] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269659] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269677] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269686] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269697] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269708] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269740] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269749] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269762] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269771] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269783] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269793] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269807] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269817] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269829] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269839] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269851] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269860] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.269874] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[230257.275363] wlp3s0: authenticate with 00:00:00:00:00:00 -[230257.281231] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[230257.326172] wlp3s0: authenticated -[230257.332040] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[230257.333311] wlp3s0: RX ReassocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=1) -[230257.334472] wlp3s0: associated -[230257.393437] wlp3s0: Limiting TX power to 23 (23 - 0) dBm as advertised by 00:00:00:00:00:00 -[230356.680918] wlp3s0: deauthenticated from 00:00:00:00:00:00 (Reason: 3=DEAUTH_LEAVING) -[230359.780467] wlp3s0: authenticate with 00:00:00:00:00:00 -[230359.786813] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[230359.827649] wlp3s0: authenticated -[230359.831632] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[230359.832798] wlp3s0: RX AssocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=3) -[230359.834228] wlp3s0: associated -[230359.915722] wlp3s0: Limiting TX power to 30 (30 - 0) dBm as advertised by 00:00:00:00:00:00 -[230391.707400] wlp3s0: disconnect from AP 00:00:00:00:00:00 for new auth to 00:00:00:00:00:00 -[230391.710358] wlp3s0: authenticate with 00:00:00:00:00:00 -[230391.716647] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[230391.756364] wlp3s0: authenticated -[230391.759536] wlp3s0: associate with 00:00:00:00:00:00 (try 1/3) -[230391.760897] wlp3s0: RX ReassocResp from 00:00:00:00:00:00 (capab=0x1411 status=0 aid=1) -[230391.762833] wlp3s0: associated -[230391.844511] wlp3s0: Limiting TX power to 23 (23 - 0) dBm as advertised by 00:00:00:00:00:00 -[231412.503669] wlp3s0: disconnect from AP 00:00:00:00:00:00 for new auth to 00:00:00:00:00:00 -[231412.513884] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[231412.513892] iwlwifi 0000:03:00.0: expected hw-decrypted unicast frame for station -[231412.515316] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.515352] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.515359] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.515363] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.515368] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.515373] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.516316] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.516327] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.516333] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.516338] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.516343] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.516347] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.517875] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.517893] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.517909] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.517921] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.517940] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.517951] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.518917] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.518942] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.518961] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.518975] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.519007] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.519022] iwlwifi 0000:03:00.0: Unhandled alg: 0x707 -[231412.523892] wlp3s0: authenticate with 00:00:00:00:00:00 -[231412.529652] wlp3s0: send auth to 00:00:00:00:00:00 (try 1/3) -[231412.575449] wlp3s0: authenticated -[undeadleech@archhq row_reset]$ exit -exit diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/runner.go b/cmd/sst/mosaic/multiplexer/tcell-term/tests/runner.go deleted file mode 100644 index b572a988e0..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/runner.go +++ /dev/null @@ -1,32 +0,0 @@ -//go:build ignore -// +build ignore - -package main - -import ( - "bufio" - "fmt" - "log" - "os" - "time" -) - -func main() { - if len(os.Args) < 2 { - log.Fatal("must pass a filename") - } - f, err := os.Open(os.Args[1]) - if err != nil { - log.Fatal(err) - } - buf := bufio.NewReader(f) - for { - r, _, err := buf.ReadRune() - if err != nil { - log.Fatal(err) - } - - fmt.Printf("%c", r) - time.Sleep(10 * time.Millisecond) - } -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/saved_cursor b/cmd/sst/mosaic/multiplexer/tcell-term/tests/saved_cursor deleted file mode 100644 index 102d7a631b..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/saved_cursor +++ /dev/null @@ -1,6 +0,0 @@ -[undeadleech@archhq saved_cursor]$ echo -e "\e7 \e(0 test \e8 xxx" -7 (0 test 8 xxx -[undeadleech@archhq saved_cursor]$ echo -e "\e[?1049h \e(0 test \e[?1049l xxx" -[?1049h (0 test [?1049l xxx -[undeadleech@archhq saved_cursor]$ echo -e "\e7 \e(0 \e[?1049h test \e[?1049l \e8 xxx" -7 (0 [?1049h test [?1049l 8 xxx diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/saved_cursor_alt b/cmd/sst/mosaic/multiplexer/tcell-term/tests/saved_cursor_alt deleted file mode 100644 index fb71b1d17e..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/saved_cursor_alt +++ /dev/null @@ -1 +0,0 @@ -(0 [?1049h7 [?1049l (B [?1049h test8xxx diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/scroll_up_reset b/cmd/sst/mosaic/multiplexer/tcell-term/tests/scroll_up_reset deleted file mode 100644 index 5d838a6445..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/scroll_up_reset +++ /dev/null @@ -1,105 +0,0 @@ -[?2004h[kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ [kchibisov@NightLord alacritty]$ ls -lah -[?2004l total 308K -drwxr-xr-x 17 kchibisov kchibisov 4.0K Nov 16 05:14 . -drwxr-xr-x 17 kchibisov kchibisov 4.0K Nov 15 23:21 .. --rw-r--r-- 1 kchibisov kchibisov 10 Sep 26 16:22 .agignore -drwxr-xr-x 4 kchibisov kchibisov 4.0K Nov 13 20:02 alacritty --rw-r--r-- 1 kchibisov kchibisov 133 Nov 16 05:14 alacritty.recording -drwxr-xr-x 5 kchibisov kchibisov 4.0K Nov 13 20:02 alacritty_terminal --rw-r--r-- 1 kchibisov kchibisov 17K Nov 13 20:02 alacritty.yml --rw-r--r-- 1 kchibisov kchibisov 128K Nov 13 20:02 Cargo.lock --rw-r--r-- 1 kchibisov kchibisov 245 Nov 3 09:50 Cargo.toml --rw-r--r-- 1 kchibisov kchibisov 22K Nov 16 04:47 CHANGELOG.md -drwxr-xr-x 4 kchibisov kchibisov 4.0K Nov 13 20:02 ci --rw-r--r-- 1 kchibisov kchibisov 5.5K Nov 13 20:02 CONTRIBUTING.md -drwxr-xr-x 2 kchibisov kchibisov 4.0K Nov 3 09:50 .copr -drwxr-xr-x 5 kchibisov kchibisov 4.0K Nov 13 20:02 copypasta -drwxr-xr-x 2 kchibisov kchibisov 4.0K Sep 26 16:22 docs -drwxr-xr-x 7 kchibisov kchibisov 4.0K Nov 13 20:02 extra -drwxr-xr-x 3 kchibisov kchibisov 4.0K Nov 13 20:02 font -drwxr-xr-x 8 kchibisov kchibisov 4.0K Nov 16 05:08 .git -drwxr-xr-x 2 kchibisov kchibisov 4.0K Sep 26 16:22 .github --rw-r--r-- 1 kchibisov kchibisov 333 Nov 3 09:50 .gitignore --rw-r--r-- 1 kchibisov kchibisov 9.1K Nov 13 20:02 INSTALL.md --rw-r--r-- 1 kchibisov kchibisov 11K Sep 26 16:22 LICENSE-APACHE --rw-r--r-- 1 kchibisov kchibisov 1.5K Nov 5 10:25 Makefile --rw-r--r-- 1 kchibisov kchibisov 6.8K Nov 13 20:02 README.md -drwxr-xr-x 2 kchibisov kchibisov 4.0K Nov 3 09:50 res --rw-r--r-- 1 kchibisov kchibisov 358 Nov 13 20:02 rustfmt.toml -drwxr-xr-x 2 kchibisov kchibisov 4.0K Nov 3 09:50 scripts -drwxr-xr-x 3 kchibisov kchibisov 4.0K Nov 3 09:50 servo-freetype-proxy -drwxr-xr-x 4 kchibisov kchibisov 4.0K Nov 12 16:22 target --rw-r--r-- 1 kchibisov kchibisov 1.7K Nov 13 20:02 .travis.yml -drwxr-xr-x 3 kchibisov kchibisov 4.0K Nov 13 20:02 winpty -[?2004h[kchibisov@NightLord alacritty]$ ls -lah -[?2004l total 308K -drwxr-xr-x 17 kchibisov kchibisov 4.0K Nov 16 05:14 . -drwxr-xr-x 17 kchibisov kchibisov 4.0K Nov 15 23:21 .. --rw-r--r-- 1 kchibisov kchibisov 10 Sep 26 16:22 .agignore -drwxr-xr-x 4 kchibisov kchibisov 4.0K Nov 13 20:02 alacritty --rw-r--r-- 1 kchibisov kchibisov 2.2K Nov 16 05:14 alacritty.recording -drwxr-xr-x 5 kchibisov kchibisov 4.0K Nov 13 20:02 alacritty_terminal --rw-r--r-- 1 kchibisov kchibisov 17K Nov 13 20:02 alacritty.yml --rw-r--r-- 1 kchibisov kchibisov 128K Nov 13 20:02 Cargo.lock --rw-r--r-- 1 kchibisov kchibisov 245 Nov 3 09:50 Cargo.toml --rw-r--r-- 1 kchibisov kchibisov 22K Nov 16 04:47 CHANGELOG.md -drwxr-xr-x 4 kchibisov kchibisov 4.0K Nov 13 20:02 ci --rw-r--r-- 1 kchibisov kchibisov 5.5K Nov 13 20:02 CONTRIBUTING.md -drwxr-xr-x 2 kchibisov kchibisov 4.0K Nov 3 09:50 .copr -drwxr-xr-x 5 kchibisov kchibisov 4.0K Nov 13 20:02 copypasta -drwxr-xr-x 2 kchibisov kchibisov 4.0K Sep 26 16:22 docs -drwxr-xr-x 7 kchibisov kchibisov 4.0K Nov 13 20:02 extra -drwxr-xr-x 3 kchibisov kchibisov 4.0K Nov 13 20:02 font -drwxr-xr-x 8 kchibisov kchibisov 4.0K Nov 16 05:08 .git -drwxr-xr-x 2 kchibisov kchibisov 4.0K Sep 26 16:22 .github --rw-r--r-- 1 kchibisov kchibisov 333 Nov 3 09:50 .gitignore --rw-r--r-- 1 kchibisov kchibisov 9.1K Nov 13 20:02 INSTALL.md --rw-r--r-- 1 kchibisov kchibisov 11K Sep 26 16:22 LICENSE-APACHE --rw-r--r-- 1 kchibisov kchibisov 1.5K Nov 5 10:25 Makefile --rw-r--r-- 1 kchibisov kchibisov 6.8K Nov 13 20:02 README.md -drwxr-xr-x 2 kchibisov kchibisov 4.0K Nov 3 09:50 res --rw-r--r-- 1 kchibisov kchibisov 358 Nov 13 20:02 rustfmt.toml -drwxr-xr-x 2 kchibisov kchibisov 4.0K Nov 3 09:50 scripts -drwxr-xr-x 3 kchibisov kchibisov 4.0K Nov 3 09:50 servo-freetype-proxy -drwxr-xr-x 4 kchibisov kchibisov 4.0K Nov 12 16:22 target --rw-r--r-- 1 kchibisov kchibisov 1.7K Nov 13 20:02 .travis.yml -drwxr-xr-x 3 kchibisov kchibisov 4.0K Nov 13 20:02 winpty -[?2004h[kchibisov@NightLord alacritty]$ ls - lah -[?2004l total 312K -drwxr-xr-x 17 kchibisov kchibisov 4.0K Nov 16 05:14 . -drwxr-xr-x 17 kchibisov kchibisov 4.0K Nov 15 23:21 .. --rw-r--r-- 1 kchibisov kchibisov 10 Sep 26 16:22 .agignore -drwxr-xr-x 4 kchibisov kchibisov 4.0K Nov 13 20:02 alacritty --rw-r--r-- 1 kchibisov kchibisov 4.1K Nov 16 05:14 alacritty.recording -drwxr-xr-x 5 kchibisov kchibisov 4.0K Nov 13 20:02 alacritty_terminal --rw-r--r-- 1 kchibisov kchibisov 17K Nov 13 20:02 alacritty.yml --rw-r--r-- 1 kchibisov kchibisov 128K Nov 13 20:02 Cargo.lock --rw-r--r-- 1 kchibisov kchibisov 245 Nov 3 09:50 Cargo.toml --rw-r--r-- 1 kchibisov kchibisov 22K Nov 16 04:47 CHANGELOG.md -drwxr-xr-x 4 kchibisov kchibisov 4.0K Nov 13 20:02 ci --rw-r--r-- 1 kchibisov kchibisov 5.5K Nov 13 20:02 CONTRIBUTING.md -drwxr-xr-x 2 kchibisov kchibisov 4.0K Nov 3 09:50 .copr -drwxr-xr-x 5 kchibisov kchibisov 4.0K Nov 13 20:02 copypasta -drwxr-xr-x 2 kchibisov kchibisov 4.0K Sep 26 16:22 docs -drwxr-xr-x 7 kchibisov kchibisov 4.0K Nov 13 20:02 extra -drwxr-xr-x 3 kchibisov kchibisov 4.0K Nov 13 20:02 font -drwxr-xr-x 8 kchibisov kchibisov 4.0K Nov 16 05:08 .git -drwxr-xr-x 2 kchibisov kchibisov 4.0K Sep 26 16:22 .github --rw-r--r-- 1 kchibisov kchibisov 333 Nov 3 09:50 .gitignore --rw-r--r-- 1 kchibisov kchibisov 9.1K Nov 13 20:02 INSTALL.md --rw-r--r-- 1 kchibisov kchibisov 11K Sep 26 16:22 LICENSE-APACHE --rw-r--r-- 1 kchibisov kchibisov 1.5K Nov 5 10:25 Makefile --rw-r--r-- 1 kchibisov kchibisov 6.8K Nov 13 20:02 README.md -drwxr-xr-x 2 kchibisov kchibisov 4.0K Nov 3 09:50 res --rw-r--r-- 1 kchibisov kchibisov 358 Nov 13 20:02 rustfmt.toml -drwxr-xr-x 2 kchibisov kchibisov 4.0K Nov 3 09:50 scripts -drwxr-xr-x 3 kchibisov kchibisov 4.0K Nov 3 09:50 servo-freetype-proxy -drwxr-xr-x 4 kchibisov kchibisov 4.0K Nov 12 16:22 target --rw-r--r-- 1 kchibisov kchibisov 1.7K Nov 13 20:02 .travis.yml -drwxr-xr-x 3 kchibisov kchibisov 4.0K Nov 13 20:02 winpty -[?2004h[kchibisov@NightLord alacritty]$ echo -e "\ (reverse-i-search)`':[24@p': printf "\e[31;1;4;9m"[1@r[1@i [8@[kchibisov@NightLord alacritty]$ -[?2004l [?2004h[kchibisov@NightLord alacritty]$ echo =e "-e \{"\e[10H" -[?2004l  -[?2004h[kchibisov@NightLord alacritty]$ echo -e "\p\e[[1-0M" -[?2004l  -[?2004h[kchibisov@NightLord alacritty]$ \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/selective_erasure b/cmd/sst/mosaic/multiplexer/tcell-term/tests/selective_erasure deleted file mode 100644 index aae1560ffe..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/selective_erasure +++ /dev/null @@ -1,2 +0,0 @@ -A[1"qB[2"qC[?2J -A[1"qB[2"qC[?2K diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/sgr b/cmd/sst/mosaic/multiplexer/tcell-term/tests/sgr deleted file mode 100644 index 18bc4885e7..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/sgr +++ /dev/null @@ -1,26 +0,0 @@ -[undeadleech@archhq sgr]$ echo -e "\e[9;38:2:255:0:255;4mTEST\e[0m" -[9;38:2:255:0:255;4mTEST -[undeadleech@archhq sgr]$ echo -e "\e[9;38:2:0:255:0:255;4mTEST\e[0m" -[9;38:2:0:255:0:255;4mTEST -[undeadleech@archhq sgr]$ echo -e "\e[9;38:5:1;4mTEST\e[0m" -[9;38:5:1;4mTEST -[undeadleech@archhq sgr]$ echo -e "\e[9;48:2:255:0:255;4mTEST\e[0m" -[9;48:2:255:0:255;4mTEST -[undeadleech@archhq sgr]$ echo -e "\e[9;48:2:0:255:0:255;4mTEST\e[0m" -[9;48:2:0:255:0:255;4mTEST -[undeadleech@archhq sgr]$ echo -e "\e[9;48:5:1;4mTEST\e[0m" -[9;48:5:1;4mTEST -[undeadleech@archhq sgr]$ echo -e "\e[9;38;2;255;0;255;4mTEST\e[0m" -TEST -[undeadleech@archhq sgr]$ echo -e "\e[9;38;2;0;255;0;255;4mTEST\e[0m" -TEST -[undeadleech@archhq sgr]$ echo -e "\e[9;38;5;1;4mTEST\e[0m" -TEST -[undeadleech@archhq sgr]$ echo -e "\e[9;48;2;255;0;255;4mTEST\e[0m" -TEST -[undeadleech@archhq sgr]$ echo -e "\e[9;48;2;0;255;0;255;4mTEST\e[0m" -TEST -[undeadleech@archhq sgr]$ echo -e "\e[9;48;5;1;4mTEST\e[0m" -TEST -[undeadleech@archhq sgr]$ exit -exit diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/tab_rendering b/cmd/sst/mosaic/multiplexer/tcell-term/tests/tab_rendering deleted file mode 100644 index 6ad299da4b..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/tab_rendering +++ /dev/null @@ -1,13 +0,0 @@ -%  UL  ~/…/tests/ref/tab_rendering  copy-tabs  [?2004hecho '\tb\na\tb\naa\tb\naaa\tb\naaaa\tb\naaaaa\tb\naaaaaa\tb\naaaaaaa\tb\naaaaaaaa\tb\naaaaaaaaa\tb\naaaaaaaaaa\tb'[?2004l - b -a b -aa b -aaa b -aaaa b -aaaaa b -aaaaaa b -aaaaaaa b -aaaaaaaa b -aaaaaaaaa b -aaaaaaaaaa b -%  UL  ~/…/tests/ref/tab_rendering  copy-tabs  [?2004h \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/tmux_git_log b/cmd/sst/mosaic/multiplexer/tcell-term/tests/tmux_git_log deleted file mode 100644 index e1baaa781c..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/tmux_git_log +++ /dev/null @@ -1,85 +0,0 @@ -[?1049h(B[?1l>[?12l[?25h[?1000l[?1002l[?1006l[?1005l]112[?25l - - - - - - - - - - - - - - - - - - - - - - -1:reattach-to-user-namespace* (B[?12l[?25hg[?25l1:zsh* (B[?12l[?25h%(B  - - -jwilm@kurast.local ➜ ~/code/alacritty (B [?1h=[?2004hg(Bgi(Bgit(B lg[?1l> -[?2004l[?25l - - - - - - - - - - - - - - - - - - - - - -[?12l[?25h[?1h=* bdd2181(B - (2 hours ago)(B Add support for recording/running ref tests - Joe Wilm(B  (HEAD -> ref-tests, origin/ref-tests) -(B| * d629f72(B - (2 days ago)(B WIP on master: d97996e Make bindings configurable f rom alacritty.yml - Joe Wilm(B (refs/stash) -(B| |\ -|/ / -|(B * 5908bde(B - (2 days ago)(B index on master: d97996e Make bindings configurable f rom alacritty.yml - Joe Wilm -(B|/ -* d97996e(B - (4 days (Bago)(B Make bindings configurable from alacritty.yml - Joe Wil(B m(B (o(Brigin/master, origin/bindings-v2, origin/HEAD, master, bindings-v2) -(B* cb2bc4e(B - (4 days ago)(B Fix test for Cell layout - Joe Wilm -(B* cbb9167(B - (5 days ago)(B Redraw screen on focus - Joe Wilm -(B* 8360ab4(B - (8 days ago)(B Fallback to received chars when no bindings - Joe Wilm -(B* 6925daa(B - (8 days ago)(B Fix/add some keybindings - Jo(Be Wilm -(B* e426013(B - (8 days ago)(B Fix alacritty shutdown when shell exits on macOS - Joe (B Wilm -(B* 8cbd768(B - (8 days ago)(B Fix resize on macOS leaving screen blank - Joe Wilm -(B* a652b4a(B - (8 days ago)(B Rustup - Joe Wilm -(B* 3e0b2b6(B - (8 days ago)(B Fix config file reloading on macOS - (BJoe Wilm -(B* be036ed(B - (8 days ago)(B Workaround for cutoff glyphs - Joe Wilm(B -* 82c8804(B - (3 weeks ago)(B Update default config - Joe Wilm(B -:[?25l -1:git* (B[?12l[?25h * a81152c(B - (3 weeks ago)(B Support drawing bold test with bright colors - Joe Wil(B : m(B -: * 7cd8a6c(B - (3 weeks ago)(B Merge branch 'reload-colors' - Joe Wilm(B -: |\ -: | * f8cb6d4(B - (3 weeks ago)(B Set colors on CPU - Joe Wilm(B -: | * cb2fa27(B - (3 weeks ago)(B Dynamically update render_timer config - Joe Wilm(B -: | * 06ea6c8(B - (3 weeks ago)(B Move config reloading to separate thread - Joe Wilm(B -: | * 0958c0f(B - (4 weeks ago)(B Move color indexing to vertex shader - Joe Wilm(B -: | * e9304af(B - (4 weeks ago)(B Expand cell::Color layout tests - Joe Wilm(B -: | * 741a8b3(B - (4 weeks ago)(B Fix some compiler warnings - Joe Wilm(B -: | * b29eed2(B - (4 weeks ago)(B Add discriminant_value test for cell::Color - Joe Wi(Bi(B : lm(B -: | * 5876b4b(B - (4 weeks ago)(B Proof of concept live reloading for colors - Joe Wil(Bl(B : m(B -: * | e503baf(B - (3 weeks ago)(B Live shader reloading is now a feature - Joe Wilm(B -: |/ -: | * 655e8f4(B - (4 weeks ago)(B WIP color management - Joe Wilm(B (live-reload-(Bcolors)(B -: |/ -: * ea07f03(B - (5 weeks ago)(B Add test exhibiting SIGBUS on my machine - Joe Wilm(B -: M* a652b4a(B - (8 days ago)(B Rustup - Joe Wilm(B: M* 8cbd768(B - (8 days ago)(B Fix resize on macOS leaving screen blank - Joe Wilm(B: MWilm(B: M* e426013(B - (8 days ago)(B Fix alacritty shutdown when shell exits on macOS - Joe (B: M* 6925daa(B - (8 days ago)(B Fix/add some keybindings - Joe Wilm(B: M* 8360ab4(B - (8 days ago)(B Fallback to received chars when no bindings - Joe Wilm(B: M* cbb9167(B - (5 days ago)(B Redraw screen on focus - Joe Wilm(B: M* cb2bc4e(B - (4 days ago)(B Fix test for Cell layout - Joe Wilm(B: Mm(B (origin/master, origin/bindings-v2, origin/HEAD, master, bindings-v2) -(B: M* d97996e(B - (4 days ago)(B Make bindings configurable from alacritty.yml - Joe Wil(B: M|/ : Mrom alacritty.yml - Joe Wilm(B: M| * 5908bde(B - (2 days ago)(B index on master: d97996e Make bindings configurable f: M|/ / : M| |\ : Mrom alacritty.yml - Joe Wilm(B (refs/stash)(B: M| * d629f72(B - (2 days ago)(B WIP on master: d97996e Make bindings configurable f: M (HEAD -> ref-tests, origin/ref-tests)(B: M* bdd2181(B - (2 hours ago)(B Add support for recording/running ref tests - Joe Wilm(B: : : : : : : : : : : : : diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/tmux_htop b/cmd/sst/mosaic/multiplexer/tcell-term/tests/tmux_htop deleted file mode 100644 index 9f6b754128..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/tmux_htop +++ /dev/null @@ -1,118 +0,0 @@ -% jwilm@kurast.local ➜  ~/code/alacritty  [?1h=[?2004httmtmutmux[?1l>[?2004l -[?1049h(B[?1l>[?12l[?25h[?1000l[?1002l[?1006l[?1005l]112[?25l - - - - - - - - - - - - - - - - - - - - - - -1:reattach-to-user-namespace* (B[?12l[?25h%(B   -jwilm@kurast.local ➜ ~/code/alacritty (B [?25l1:zsh* (B[?12l[?25h[?1h=[?2004hh(Bht(Bhto(Bhtop(B[?1l> -[?2004l[?25l - - - - - - - - - - - - - - - - - - - - - -[?1006h[?1000h[?1h= - 0 [ nan%](B Tasks: 363(B1:htop* (B, 1608(B thr; 1(B running1 [ nan(B%](B Load average: 1.71 1.83 (B1.80 2 [ (Bnan%](B Uptime: 2 days, 06:35:30(B3 [ nan%(B](BMem[(B|||||||||||||||||||9.25G/16.0G](BSwp(B[(B||||||||||||||| 1000M/2.00G](B PID USER PRI NI VIRT RES S (BCPU% MEM% TIME+ Command 29826 jwilm 17 0 9621M 7392 R 0 0.0 0:00.(B01 htop 29749 jwilm40 0 9630M 19040 R  nan 0.0 0:00.21 -zsh -29748 jwilm25 0 9554M 4528 R  nan 0.0 0:00.00 tmux -29617 jwilm40 0 9630M 19456 R  nan 0.0 0:00.27 /usr/local/bin/zsh -29598 jwilm26 0 10.1G (B 131M R  nan 0.2 0:00.55 target/debug/alacritty -29597 jwilm32 0 9577M 22608 R (B nan 0.0 0:00.01 cargo -29567 jwilm17 0 13.1G (B 443M R  nan 0.7 0:01.48 /Applications/Google Ch29565 jwilm17 0 9756M 36784 R  nan 0.1 0:00.09 /System/Library/Private29477 jwilm25 0 9630M 22192 R  nan 0.0 0:00.51 -zsh -29466 jwilm17 0  9.6G (B51936 R  nan 0.1 0:00.04 /System/Library/Framewo29368 root(B (B 17 0 0 0 R  0.0 0.0 0:00.00 com.apple.audio. -29349 root (B 17 0 0 0 R  0.0 0.0 0:00.00 ocspd -29240 jwilm17 0 13.8G (B 823M R (B nan 1.3 0:59.28 /Applications/Google ChF1Help F2Setup F3SearchF4FilterF5Tree F6SortByF7Nice -(BF8Nice +F9Kill F10Quit [1@t(B||||7.91(B||2.0(B|||(B5.91(B||2.0(B 114126 0 10.4G 226M (BR 3.3 0.3 11:34.48 target/release/alacritt 58017752M 58368 R  2.7  0.1 7:38.67 tmux24017 0 13.6G (B 825M R  2.0 1.3 0:59.30 /Applications/Google Ch59826 0 10.1G (B 132M R  1.9 0.257 target/debug/alacritty220173.2G (B 585M R  0.5 0.9 0:14.68 /Applications/Google Ch 92317 0 15.6G (B1800M R  0.3 2.7 51:50.80 /Applications/Google Ch199302G (B 584M R  0.3 0.9 1:00.2982624621M 7408 R  0.3 0.02 htop -1324817 0 13.8G (B 445M R  0.2 0.7 6:24.39 /Applications/Google Ch214113.3G (B 517M R  0.2 0.8 1:05.32 /Applications/Google Ch 433 jwilm  9.7G (B458562 0.1 2:35.94 /Applications/Karabiner 396 jwilm   9.8G (B74242 0.1 3:06.10 /System/Library/CoreSer187130G (B 529M R  0.1 0.8 0:31.53| 53323(B5G 227M R 2.7(B51400 R  18598260.1G (B 132M R (B 1.5 0.2 0:00.59 target/debug/alacritty  915146.3G (B 825M R  0.7 1.3  9:38.59 /Applications/Slack.app49459678M 13088 R  0.4 0.0 0:21.21 postgres: stats collect 9235.6G (B18004 2.7 51:50.80 9155244.9G (B1263 1.9  1h(B18:35Slack.app132488G (B 4457 6:24.40 -1993013.2G (B 584M 9 1:00.29Google Ch2214113.3G (B 517M 8 1:05.32 /Applications/Google Ch 396 9.8G (B74240 R  0.2 0.1 3:06.10 /System/Library/CoreSer07 182 1.85 (B1.81| 4.0(B3 1(B1.931637036029240173.6G (B 82690:59.31Google Ch5 - 8 9.6G (B 112M 2 0:37.22 /System/Library/Framewo322141173.3G (B 5172 0.8 1:05.32Google Ch 8543 9.9G (B 1372 0:39.54 /System/Library/Framewo32488G (B 4457 6:24.40 -199302G (B 5849 1:00.30 1141 jwilm 26 0 10.5G (B 227M R  1.9 0.3 11:34.53 target/release/alacritt 580 jwilm 17 0 9752M 58416 R 1.3 0.1 7:38.70 tmux (B 580 jwilm 17 0 9752M 58416 R  1.3 0.1 7:38.70 tmux -29598 jwilm (B 26 0 10.1G 132M R 1.3 0.2 0:00.60 target/debug/alacritty (B98(B|634(B|6(B554812533626700412306515(B29598 jwilm 26 0 10.1G (B 132M R  1.5 0.2 0:00.63 target/debug/alacritty 29240 jwilm 17 0 13.6G 823M R 0.6 1.3 0:59.32 /Applications/Google Ch(B29240 jwilm 17 0 13.6G (B 823M R  0.6 1.3 0:59.32 /Applications/Google Ch29220 jwilm 17 0 13.2G 586M R 0.5 0.9 0:14.70 /Applications/Google Ch(B29220 jwilm 17 0 13.2G (B 586M R  0.5 0.9 0:14.70 /Applications/Google Ch 8453 jwilm 17 0 9.6G 112M R 0.0 0.2 0:37.22 /System/Library/Framewo(B87362.5(B6764232.36241 - 8453 jwilm 17 0  9.6G (B 112M R  0.0 0.2 0:37.22 /System/Library/Framewo 923 jwilm 17 0 15.6G 1800M R 0.2 2.7 51:50.81 /Applications/Google Ch(B33823131 923 jwilm 17 0 15.6G (B1800M R  0.2 2.7 51:50.81 /Applications/Google Ch29826 jwilm 24 0 9621M 7408 R 0.3 0.0 0:00.03 htop (B7(B29826 jwilm 24 0 9621M 7408 R  0.3 0.0 0:00.03 htop22141 jwilm 17 0 13.3G 518M R 0.2 0.8 1:05.33 /Applications/Google Ch(B4.4 536 0.7(B2980 R (B 0.840(B1.585733(B522 -22141 jwilm 17 0 13.3G (B 518M R  0.1 0.8 1:05.33 /Applications/Google Ch 8543 jwilm 17 0 9.9G 137M R 0.0 0.2 0:39.54 /System/Library/Framewo(B311 8543 jwilm 17 0  9.9G (B 137M R  0.0 0.2 0:39.54 /System/Library/Framewo13248 jwilm 17 0 13.8G 446M R 0.3 0.7 6:24.41 /Applications/Google Ch(B8(B13248 jwilm 17 0 13.8G (B 446M R  0.3 0.7 6:24.41 /Applications/Google Ch19930 jwilm 17 0 13.2G 585M R 0.2 0.9 1:00.31 /Applications/Google Ch(B74(B|2.87(B|1.8(B86196 R  1.262.67122032019930 jwilm 17 0 13.2G (B 585M R  0.2 0.9 1:00.31 /Applications/Google Ch 396 jwilm 17 0 9.8G 74240 R 0.2 0.1 3:06.11 /System/Library/CoreSer(B9(B19930 jwilm 17 0 13.2G 585M R 0.2 0.9 1:00.31 /Applications/Google Ch(B 396 jwilm 17 0  9.8G (B74240 R  0.2 0.1 3:06.11 /System/Library/CoreSer13248 jwilm 17 0 13.8G 446M R 0.0 0.7 6:24.41 /Applications/Google Ch19930 jwilm  17 0 13.2G (B 585M R  0.2 0.9 1:00.31 /Applications/Google Ch 8543 jwilm 17 0 9.9G 137M R 0.0 0.2 0:39.54 /System/Library/Framewo13248 jwilm  17 0 13.8G (B 446M R  0.0 0.7 6:24.41 /Applications/Google Ch22141 jwilm 17 0 13.3G 518M R 0.2 0.8 1:05.33 /Applications/Google Ch 8543 jwilm  17 0  9.9G (B 137M R  0.0 0.2 0:39.54 /System/Library/Framewo29826 jwilm 24 0 9621M 7408 R 0.3 0.0 0:00.03 htop 22141 jwilm  17 0 13.3G (B 518M R  0.2 0.8 1:05.33 /Applications/Google Ch 923 jwilm 17 0 15.6G 1800M R 0.0 2.7 51:50.82 /Applications/Google Ch29826 jwilm  24 0 9621M 7408 R  0.3 0.0 0:00.03 htop 8453 jwilm 17 0 9.6G 112M R 0.0 0.2 0:37.22 /System/Library/Framewo 923 jwilm  17 0 15.6G (B1800M R  0.0 2.7 51:50.82 /Applications/Google Ch29220 jwilm 17 0 13.2G 583M R 0.4 0.9 0:14.72 /Applications/Google Ch 8453 jwilm  17 0  9.6G (B 112M R  0.0 0.2 0:37.22 /System/Library/Framewo29240 jwilm 17 0 13.6G 825M R 0.2 1.3 0:59.33 /Applications/Google Ch29220 jwilm  17 0 13.2G (B 583M R  0.4 0.9 0:14.72 /Applications/Google Ch29598 jwilm 26 0 10.0G 132M R 2.6 0.2 0:00.71 target/debug/alacritty 29240 jwilm  17 0 13.6G (B 825M R  0.2 1.3 0:59.33 /Applications/Google Ch 580 jwilm 17 0 9752M 58496 R 1.2 0.1 7:38.76 tmux 29598 jwilm  26 0 10.0G (B 132M R  2.6 0.2 0:00.71 target/debug/alacritty  1141 jwilm 26 0 10.5G 227M R 1.8 0.3 11:34.61 target/release/alacritt 580 jwilm  17 0 9752M 58496 R  1.2 0.1 7:38.76 tmux||8.22(B||6.6402(B3.16544 R  2.1804.7946553435434323|7.1 1.8 1.913.5(B29240(B173.6G 826M R 1.7 1.3 0:59.35 /Applications/Google Ch114126 0 10.5G (B 227M R  1.5 0.3 11:34.67 target/release/alacritt1.480 - 589752M 58544 R  1.0 0.1 7:38.80 tmux49 -2214113.3G (B 515(B6 0.8 1:05.34 /Applications/Google Ch199303.2G (B 5855 0.9 1:00.31 92317 0 15.6G (B1800M 2.7 51:50.83 /Applications/Google Ch982624 0 9621M 7408 R  0.4 0.0 0:00.04 htop - 3968G (B74(B240 R  0.3 0.1 3:06.12CoreSer7616G (B 3646 0:46.964337G (B458562:35.96 /Applications/Karabin| 4.03(B|2.0(B|3(B2 1.0(B 1141260.5G 2276 0.3 11:34.69 target/release/alacritt(B295980G (B 1322 0:00.82debug/alacritty  58017 0 9752M 58560 R  1.2 0.1 7:38.81 tmux -292213.2G (B 584M (BR  0.4 0.9 0:14.73 /Applications/Google Ch 9235.6G (B18003 2.7 51:50.83 -2982624 0 9621M 7408 R  0.2 0.0 0:00.05 htop -199303.2G (B 5852 0.9 1:00.32 -1324817 0 13.8G (B 446M R (B 0.2 0.7 6:24.42 /Applications/Google Ch2924013.6G (B 826M R  0.2 1.3 0:59.36 /Applications/Google Ch 9155244.9G (B12652 1.9  1h(B18:35Slack.app 396 9.8G (B74240 R  0.2 0.1 3:06.12 /System/Library/CoreSer187113.0G (B 529M 8 0:31.54Google Ch76 1.84 (B1.80 1141 jwilm 26 0 10.5G (B 227M R (B 1.6 0.3 11:34.69 target/release/alacritt29598 jwilm 26 0 10.0G 132M R 1.5 0.2 0:00.82 target/debu(Bg/alacritty (B3(B29598 jwilm 26 0 10.0G (B 132M R  1.5 0.2 0:00.82 target/debug/alacritty  580 jwilm 17 0 9752M 58560 R 1.2 0.1 7:38.81 tmux (B||||12.303.1(B||||10.7(B|2.3(B62.4722.35 - 580 jwilm 17 0 9752M 58592 R  1.9 0.1 7:38.84 tmux -29220 jwilm 17 0 13.2G 584M R 0.3 0.(B9 0:14.74 /Applications/Google Ch41317597011.1529220 jwilm 17 0 13.2G (B 584M R  0.3 0.9 0:14.74 /Applications/Google Ch 923 jwilm 17 0 15.6G 1800M R 0.3 2.7 51:50.84 /Applications/Google Ch(B 923 jwilm 17 0 15.6G (B1800M R  0.3 2.7 51:50.84 /Applications/Google Ch22141 jwilm 17 0 13.3G 515M R 0.1 0.8 1:05.34 /Applications/Google Ch(B4(B22141 jwilm 17 0 13.3G (B 515M R  0.1 0.8 1:05.34 /Applications/Google Ch29826 jwilm 24 0 9621M 7408 R 0.3 0.0 0:00.05 htop (B||  8.75961.8(B|  5.36(B25986245625 -29826 jwilm 24 0 9621M 7408 R  0.3 0.0 0:00.05 htop -19930 jwilm 17 0 13.2G 586M R 0.2 0.9 1:00.32 /Application(Bs/Google Ch1127M R  0.2619930 jwilm 17 0 13.2G (B 586M R  0.2 0.9 1:00.32 /Applications/Google Ch13248 jwilm 17 0 13.8G 447M R 0.2 0.7 6:24.42 /Applications/Google Ch(B5(B13248 jwilm 17 0 13.8G (B 447M R  0.2 0.7 6:24.42 /Applications/Google Ch29240 jwilm 17 0 13.6G 825M R 0.1 1.3 0:59.37 /Applications/Google Ch(B29240 jwilm 17 0 13.6G (B 825M R  0.1 1.3 0:59.37 /Applications/Google Ch 9155 jwilm 24 0 14.9G 1265M R 0.1 1.9 1h18:35 /Applications/Slack.app(B| 66022.5(B| 4.21.7(B71.7729140275M R  1.15263688 - 9155 jwilm 24 0 14.9G (B1265M R (B 0.0 1.9  1h(B18:35 /Applications/Slack.app 396 jwilm 17 0 9.8G 74240 R 0.1 (B 0.1 3:06.12 /System/Library/CoreSer16(B 396 jwilm 17 0  9.8G (B74240 R  0.1 0.1  3:06.12 /System/Library/CoreSer18713 jwilm 17 0 13.0G 527M R 0.1 0.8 0:31.56 /Applications/Google C(Bh(B5.112.972.2(B483M R  1.5356080.36553243499332(B 396 jwilm 17 0 9.8G 74240 R 0.3 0.1 3:06.13 /System/Library/CoreSer18713 jwilm  17 0 13.0G (B 527M R  0.2 0.8 0:31.56 /Applications/Google Ch0 1.82(B 9155 jwilm 24 0 14.9G 1265M R 0.0 1.9 1h18:35 /Applications/Slack.app(B 396 jwilm 17 0  9.8G (B74240 R  0.3 0.1 3:06.13 /System/Library/CoreSer29240 jwilm 17 0 13.6G 826M R 0.9 1.3 0:59.39 /Applications/Google Ch 9155 jwilm  24 0 14.9G (B1265M R  0.0 1.9  1h(B18:35 /Applications/Slack.app13248 jwilm 17 0 13.8G 447M R 0.4 0.7 6:24.43 /Applications/Google Ch29240 jwilm  17 0 13.6G (B 826M R  0.9 1.3 0:59.39 /Applications/Google Ch19930 jwilm 17 0 13.2G 586M R 0.4 0.9 1:00.33 /Applications/Google Ch13248 jwilm  17 0 13.8G (B 447M R  0.4 0.7 6:24.43 /Applications/Google Ch29826 jwilm 24 0 9621M 7408 R 0.2 0.0 0:00.06 htop 19930 jwilm  17 0 13.2G (B 586M R  0.4 0.9 1:00.33 /Applications/Google Ch22141 jwilm 17 0 13.3G 515M R 0.3 0.8 1:05.35 /Applications/Google Ch29826 jwilm  24 0 9621M 7408 R  0.2 0.0 0:00.06 htop 923 jwilm 17 0 15.6G 1800M R 0.5 2.7 51:50.85 /Applications/Google Ch22141 jwilm  17 0 13.3G (B 515M R  0.3 0.8 1:05.35 /Applications/Google Ch29220 jwilm 17 0 13.2G 585M R 0.3 0.9 0:14.76 /Applications/Google Ch 923 jwilm  17 0 15.6G (B1800M R  0.5 2.7 51:50.85 /Applications/Google Ch 580 jwilm 17 0 9752M 58656 R 1.0 0.1 7:38.88 tmux 29220 jwilm  17 0 13.2G (B 585M R  0.3 0.9 0:14.76 /Applications/Google Ch29598 jwilm 26 0 10.0G 133M R 1.5 0.2 0:00.93 target/debug/alacritty  580 jwilm  17 0 9752M 58656 R  1.0 0.1 7:38.88 tmux 1141 jwilm 26 0 10.5G 227M R 1.4 0.3 11:34.78 target/release/alacritt29598 jwilm  26 0 10.0G (B 133M R  1.5 0.2 0:00.93 target/debug/alacritty |||9.843.3(B||88(B3.3(B295980G 133M R 72 0:01.02debug/alacritty  11415G (B 227M R  5.1 0.3 11:34.85release/alacritt704 R  3.59382624 0 9621M 7408 R  0.8 0.0 0:00.07 htop352 5 (B 9.6G (B12880 0.0 1:24.87 /System/Library/CoreSer 9235.6G (B18002.7 51:50.8622017 0 13.2G (B 586M R  0.3 0.9 0:14.76 /Applications/Google Ch 4806 9.5G (B 6352 R  0.2 0.0 0:29.98 /System/Library/Private2 -19932G (B 582 0.9 1:00.33 -29240173.6G (B 8262 1.3 0:59.39Google Ch2214113.3G (B 515M (BR  0.2 0.8 1:05.36 /Applications/Google Ch| 5.0 2.0(B| 3.09 1.0(B 11415G 227M R 1.8 0.3 11:34.86release/alacritt 58017 0 9752M 58720 R  1.4 0.1 7:38.94 tmux -2959826 0 10.0G (B 133M (BR  1.4 0.2 0:01.03 target/debug/alacritty24017 0 13.6G (B 828M R  0.9 1.3 0:59.40 /Applications/Google Ch923 0 15.6G (B1800M R  0.4 2.7 51:50.86 /Applications/Google Ch292203.2G (B 5864 0.9 0:14.77 -19931:00.33 -298224 0 9621M 7408300.07 htop 433 9.7G (B45(B856 1 2:35.97Karabiner21413G (B 5150.8 1:05.36 -  396 9.8G (B74240 1 3:06.13 /System/Library/CoreSer 91575.3G (B 8151.2 3:14.92Slack.app7(B|450(B|2.9(B2.083664 -187131G (B 527M R  1.2 0.8 0:31.57 -199303.2G (B 5866 0.9 1:00.345 -221413G (B 515 0.8 1:05.36 - 43317 0  9.7G (B458561 2:35.97 /Applications/Karabiner 9235.6G (B18003 2.7 51:50.86 -2982624 0 9621M 74083 0.0 0:00.07 htop -292406G (B 8281.3 0:59.41 -1324813.8G (B 448M 7 6:24.44 /Applications/Google Ch269412.9G (B 5601 0.9 0:08.17Google Ch 131 1.0(B1.490 -2959826 0 10.0G (B 133M R  1.3 0.2 0:01.06 target/debug/alacritty - 58017 0 9752M 58768 R  1.1 0.1 7:38.97 tmux -292406G (B 8(B0 1.3 0:59.42 -292240:14.78 - 9235.6G (B18004 2.7 51:50.82982624 0 9621M 7408 R  0.3 0.0 0:00.08 htop -2214113.3G (B 516M R  0.2 0.8 1:05.36Google Ch132483.8G (B 4482 0.7 6:24.44 -1993017 0 13.2G (B 586M R  0.2 0.9 1:00.34 /Applications/Google Ch 396 9.8G (B74240 0.1 3:06.13 /System/Library/CoreSer87131G (B 5271 0.8 0:31.58 -176103.6G (B 3656 0:46.9 -||10.96(B|2.9(B|(B72(B|3(B2.029(B34448598260.0G (B 1333 0.2 0:01.07 target/debug/alacritty 35132488G (B 4487 6:24.44 -292406G (B 8271.3 0:59.42433 jwilm17 0  9.7G (B45888 R  0.2 0.1 2:35.97 /Applications/Karabiner221413G (B 518 1:05.37 -1993013.2G (B 586M 9 1:00.34 /Applications/Google Ch 9155244.9G (B12662 1.9  1h(B18:35Slack.app 396 9.8G (B74240 R  0.2 0.1 3:06.13 /System/Library/CoreSer3 1.83(B 1141 jwilm 26 0 10.5G (B 227M R  2.0 0.3 11:34.92 target/release/alacritt 580 jwilm 17 0 9752M 59344 R 1.4 0.1 7:38.98 tmux (B||  7.151(B|13(B1.9(B81.64 - 580 jwilm 17 0 9752M 59344 R  1.1  0.1 7:39.00 tmux -29598 jwilm 26 0 10.0G 133M R 1.4 0.2 0:01.09 target/debug/alacritty (B46982435973137350144(B29598 jwilm 26 0 10.0G (B 133M R  1.4 0.2 0:01.09 target/debug/alacritty 29220 jwilm 17 0 13.2G 584M R 0.6 0.9 0:14.79 /Applications/Google Ch(B29220 jwilm 17 0 13.2G (B 584M R  0.6 0.9 0:14.79 /Applications/Google Ch 923 jwilm 17 0 15.6G 1800M R 0.4 2.7 51:50.88 /Applications/Google Ch(B 923 jwilm 17 0 15.6G (B1800M R  0.4 2.7 51:50.88 /Applications/Google Ch29826 jwilm 24 0 9621M 7408 R 0.2 0.0 0:00.08 htop (B29826 jwilm 24 0 9621M 7408 R  0.2 0.0 0:00.08 htop -13248 jwilm (B 17 0 13.8G 444M R 0.3 0.7 6:24.45 /Applications/Google Ch(B55992.85.62.8(B27823.6134339 -13248 jwilm 17 0 13.8G (B 444M R  0.2 0.7 6:24.45 /Applications/Google Ch29240 jwilm 17 0 13.6G 828M R 0.9 1.3 0:59.44 /Applications/Google Ch(B8225(B29240 jwilm 17 0 13.6G (B 828M R  0.9 1.3 0:59.44 /Applications/Google Ch 433 jwilm 17 0 9.7G 45888 R 0.1 0.1 2:35.98 /Applications/Karabiner(B 433 jwilm 17 0  9.7G (B45888 R  0.1 0.1 2:35.98 /Applications/Karabiner22141 jwilm 17 0 13.3G 516M R 0.2 0.8 1:05.37 /Applications/Google Ch(B22141 jwilm 17 0 13.3G (B 516M R  0.2 0.8 1:05.37 /Applications/Google Ch19930 jwilm 17 0 13.2G 587M R 0.3 0.9 1:00.35 /Applications/Google Ch(B19930 jwilm 17 0 13.2G (B 587M R  0.3 0.9 1:00.35 /Applications/Google Ch 9155 jwilm 24 0 14.9G 1266M R 0.0 1.9 1h18:35 /Applications/Slack.app(B19930 jwilm 17 0 13.2G 587M R 0.3 0.9 1:00.35 /Applications/Google Ch 9155 jwilm  24 0 14.9G (B1266M R  0.0 1.9  1h(B18:35 /Applications/Slack.app|8.36021.961.9(B85.009487804532 -22141 jwilm 17 0 13.(B3G 516M R 0.2 0.8 1:05.38 /Applications/Google Ch19930 jwilm 17 0 13.2G (B 587(BM R  0.2 0.9 1:00.35 /Applications/Google Ch4 433 jwilm 17 0 9.7G 45888 R 0.2 0.1 2:35.98 /Applications/Karabiner22141 jwilm  17 0 13.3G (B 516M R  0.2 0.8 1:05.38 /Applications/Google Ch29240 jwilm 17 0 13.6G 828M R 0.3 1.3 0:59.44 /Applications/Google Ch 433 jwilm  17 0  9.7G (B45888 R  0.2 0.1 2:35.98 /Applications/Karabiner13248 jwilm 17 0 13.8G 445M R 0.2 0.7 6:24.45 /Applications/Google Ch29240 jwilm  17 0 13.6G (B 828M R  0.3 1.3 0:59.44 /Applications/Google Ch29826 jwilm 24 0 9621M 7408 R 0.4 0.0 0:00.09 htop 13248 jwilm  17 0 13.8G (B 445M R  0.2 0.7 6:24.45 /Applications/Google Ch 923 jwilm 17 0 15.6G 1800M R 0.3 2.7 51:50.88 /Applications/Google Ch29826 jwilm  24 0 9621M 7408 R  0.4 0.0 0:00.09 htop29220 jwilm 17 0 13.2G 584M R 0.4 0.9 0:14.80 /Applications/Google Ch 923 jwilm  17 0 15.6G (B1800M R  0.3 2.7 51:50.88 /Applications/Google Ch29598 jwilm 26 0 10.0G 133M R 3.8 0.2 0:01.17 target/debug/alacritty 29220 jwilm  17 0 13.2G (B 584M R  0.4 0.9 0:14.80 /Applications/Google Ch 580 jwilm 17 0 9752M 59344 R 1.9 0.1 7:39.04 tmux 29598 jwilm  26 0 10.0G (B 133M R  3.8 0.2 0:01.17 target/debug/alacritty  1141 jwilm 26 0 10.5G 227M R 2.8 0.3 11:35.00 target/release/alacritt 580 jwilm  17 0 9752M 59344 R  1.9 0.1 7:39.04 tmux||||14.5(B||5.8(B||(B10.1(B||5.7(B295980G 133M R 11.0 0.2 0:01.25debug/a(Blacritty 114126 0 10.5G (B 227M R  7.5 0.3 11:35.05 target/release/alacritt 58017 0 9752M 59344 R  5.5 0.1 7:39.08 tmux82624  0 9621M 7408 R  1.1 0.0 0:00.10 htop352 5  9.6G (B12(B880 R  0.7 0.0 1:24.89 /System/Library/CoreSer 48017 0  9.5G (B 6(B35229.98 /System/Library/Private233901.4G (B 2501 0.4 0:53.98Spotify.a 91575.3G (B 8151 1.2 3:14.93Slack.app1 - 91584.2G (B 5412:26.15Slack.app 17029656M 1(B392 R  0.1 0.0 0:47.83 redis-server *:19201 154617 0 9624M 1328 R (B 0.1 0.0 0:47.98 redis-server *:637997G (B169761 0.0 0:30.63 /Applications/Seil.app/|  5.0599 1.067 1.81 (B1.79|(B  4.07 1.0(B 11415G 227M R 2.4 0.3 11:35.08(Brelease/alacritt 58017 0 9752M 59344 R  11 7:39.09 tmux2959826 0 10.0G (B 133M R  12 0:01.26 target/debug/alacritty24017 0 13.6G (B 829M R  0.9 1.3 0:59.45 /Applications/Google Ch9158 0 14.2G (B 546M R  0.5 0.8 2:26.15 /Applications/Slack.app2922013.2G (B 584M 9 0:14.80 /Applications/Google Ch 9235.6G (B180(B3 2.7 51:50.89Google Ch199303.2G (B 5873 0.9 1:00.36Google Ch2982624 0 9621M 7403 0.0 0:00.10 htop -221413.3G (B 51(B21:05.38Google Ch8453 9.6G (B 112M R  0.2 0.2 0:37.23 /System/Library/Framewo1324813.8G (B 445M R  0.2 0.7 6:24.45 /Applications/Google Ch68G (B742402 0.1 3:06.14 /System/Library/CoreSer -9608(B|28(B|(B2(B9110114822G (B 5856 0.9 0:14.81 - 288 9.6G (B46016 R  0.5 0.1 0:18.70 /System/Library/Private221413G (B 5168 1:05.3813248 jwilm17 0 13.8G (B 445M R  0.3 0.7 6:24.46 /Applications/Google Ch187131G (B 5280:31.59 -2924013.6G (B 8291.3 0:59.45 /Applications/Google Ch99302G (B 5879 1:00.364337G (B458882:35.98 /Applications/Karabin3.07 2.99(B81.72(B2959826 0 10.0G (B 133M R  1.4 0.2 0:01.29 target/debug/alacritty - 58017 0 9752M 59344 R  1.2 0.1 7:39.12 tmux46G (B 828(BM R  1.1 1.3 0:59.46 -2922013.2G (B 585M R  0.4 0.9 0:14.81 /Applications/Google Ch982624 0 9621M 7408 0 0:00.11 htop -2214117 0 13.3G (B 517M R  0.2 0.8 1:05.38 /Applications/Google Ch99302G (B 5872 0.9 1:00.3 -132488G (B 4457 6:24.46 - 396 9.8G (B74240 0.1 3:06.15 /System/Library/CoreSer 433 9.7G (B45888 R  0.1 0.1 2:35.98Karabiner2339011.4G (B 250M (BR  0.1 0.4 0:53Spotify.a6:00(B 1141 jwilm 26 0 10.5G (B 227M R  1.7 0.3 11:35.12 target/release/alacritt29598 jwilm 26 0 10.0G 133M R 1.4 0.2 0:01.29 target/debug/alacritty (B|||7.86(B|3.0 (B9(B2.34 -29598 jwilm 26 0 10.0G (B 133M R  2.2 0.2 0:01.31 target/debug/alacritty  580 jwilm 17 0 9752M 59344 R 1.7 0.1 7:39.14 tmux (B0.2752903913991(B 580 jwilm 17 0 9752M 59344 R  1.7 0.1 7:39.14 tmux29240 jwilm 17 0 13.6G 828M R 0.2 1.3 0:59.47 /Applications/Google Ch(B29240 jwilm 17 0 13.6G (B 828M R  0.2 1.3 0:59.47 /Applications/Google Ch29220 jwilm 17 0 13.2G 585M R 0.5 0.9 0:14.82 /Applications/Google Ch(B| 4.7549(B|1.6(B151.640.857M R  1.08 -29220 jwilm 17 0 13.2G (B 586M R  0.8 0.9 0:14.83 /Applications/Google Ch 923 jwilm 17 0 15.(B6G 1800M R 0.5 2.7 51:50.90 /Applications/Google Ch24473562||5.96 1.01 1.8003(B 0(B060.769M R  0.99531283627661|||||20.03(B|5.9(B||||(B13.94(B||5.9(B0.872.2786243.74324022 \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/underline b/cmd/sst/mosaic/multiplexer/tcell-term/tests/underline deleted file mode 100644 index 6d34de2eb2..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/underline +++ /dev/null @@ -1,13 +0,0 @@ -[undeadleech@undeadlap underline]$ [undeadleech@undeadlap underline]$ echo -e "\e[4mUNDERLINED\e[0m" -UNDERLINED -[undeadleech@undeadlap underline]$ echo -e "\e[4:1mUNDERLINED\e[4:0m" -[4:1mUNDERLINED[4:0m -[undeadleech@undeadlap underline]$ echo -e "\e[4:2mUNDERLINED\e[24m" -[4:2mUNDERLINED -[undeadleech@undeadlap underline]$ echo -e "\e[4:3mUNDERLINED\e[21m";mUNDERLINED\e[21m"2mUNDERLINED\e[21m"1mUNDERLINED\e[21m"m"m"0m" -[4:3;21mUNDERLINED -[undeadleech@undeadlap underline]$ echo -e "\e[4;4:2mUNDERLINED\e[0m" -[4;4:2mUNDERLINED -[undeadleech@undeadlap underline]$ echo -e "\e[4;4:2mUNDERLINED\e[0m":;4:2mUNDERLINED\e[0m"1;4:2mUNDERLINED\e[0m";4:2mUNDERLINED\e[0m"2;4:2mUNDERLINED\e[0m"mUNDERLINED\e[0m"1mUNDERLINED\e[0m" -[4:2;4:1mUNDERLINED -[undeadleech@undeadlap underline]$ \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/vim_24bitcolors_bce b/cmd/sst/mosaic/multiplexer/tcell-term/tests/vim_24bitcolors_bce deleted file mode 100644 index bb8c3d0584..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/vim_24bitcolors_bce +++ /dev/null @@ -1,1227 +0,0 @@ -% jwilm@kurast.local ➜  ~/code/alacritty  [?1h=[?2004h -bck-i-search: _mv ../../../{grid.json,size.json,alacritty.recording} ./v_cd vim_large_window_scroll i_imm_     vvivim ssrrcc//rreenndderer/r [?1l>[?2004l [?1049h[?1h=▽ [?12;25h[?12l[?25h[?25l"src/renderer" is a directory[>c" ============================================================================   -" Netrw Directory Listing (netrw v156)   -" /Users/jwilm/code/alacritty/src/renderer  -" Sorted by name  -" Sort sequence: [\/]$,\,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$ -" Quick Help: :help -:go up dir D:delete R:rename s:sort-by x:special  -" ==============================================================================  -../ ./  -mod.rs  -~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 8,1All[?12l[?25h[?25l../ ./ 9[?12l[?25h[?25l./ mod.rs 10,1[?12l[?25h[?25l~/code/alacritty/src/renderer/mod.rs"1354L, 40527C 864  }   - 865    - 866  pub fn deactivate(&self) {    - 867  unsafe {    - 868  gl::UseProgram(0);   869  }   - 870  }   - 871    - 872  pub fn new(   - 873  config: &Config,  874 size: Size<Pixels<u32>>   875 ) -> Result<ShaderProgram, ShaderCreationError> {   876 let vertex_source = if cfg!(feature = "live-shader-reload") {   877 None   878 } else {   879 Some(TEXT_SHADER_V)   880 };   881 let vertex_shader = ShaderProgram::create_shader(   882 TEXT_SHADER_V_PATH,   883 gl::VERTEX_SHADER,   884 vertex_source   885 )?;   886 let frag_source = if cfg!(feature = "live-shader-reload") {   887 None   888 } else {   889 Some(TEXT_SHADER_F)   890 };   891 let fragment_shader = ShaderProgram::create_shader(   892 TEXT_SHADER_F_PATH,   893 gl::FRAGMENT_SHADER,   894 frag_source   895 )?;   896 let program = ShaderProgram::create_program(vertex_shader, fragment_shader);   897   898 unsafe {   899 gl::DeleteShader(vertex_shader);   900 gl::DeleteShader(fragment_shader);   901 gl::UseProgram(program);   902 }   903   904 macro_rules! cptr {   905 ($thing:expr) => { $thing.as_ptr() as *const _ }   906 }   907   908 macro_rules! assert_uniform_valid {   909 ($uniform:expr) => {   910 assert!($uniform != gl::INVALID_VALUE as i32);   911 assert!($uniform != gl::INVALID_OPERATION as i32);   912 };   913 ( $( $uniform:expr ),* ) => {   914 $( assert_uniform_valid!($uniform); )*   915 };   916 }   917   918 // get uniform locations   919 let (projection, term_dim, cell_dim, visual_bell, background) = unsafe {  891,166%[?12l[?25h[?25l 1 // Copyright 2016 Joe Wilm, The Alacritty Project Contributors  - 2 //  - 3 // Licensed under the Apache License, Version 2.0 (the "License");  - 4 // you may not use this file except in compliance with the License.  - 5 // You may obtain a copy of the License at  - 6 //  - 7 // http://www.apache.org/licenses/LICENSE-2.0  - 8 //  - 9 // Unless required by applicable law or agreed to in writing, software  - 10 // distributed under the License is distributed on an "AS IS" BASIS,  - 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  - 12 // See the License for the specific language governing permissions and  - 13 // limitations under the License.  - 14 use std::collections::HashMap;  - 15 use std::hash::BuildHasherDefault;  - 16 use std::fs::File;  - 17 use std::io::{self, Read};  - 18 use std::mem::size_of;  - 19 use std::path::{PathBuf};  - 20 use std::ptr;  - 21 use std::sync::mpsc;  - 22   - 23 use cgmath;  - 24 use fnv::FnvHasher;  - 25 use font::{self, Rasterizer, Rasterize, RasterizedGlyph, FontDesc, GlyphKey, FontKey};  - 26 use gl::types::*;  - 27 use gl;  - 28 use index::{Line, Column, RangeInclusive};  - 29 use notify::{Watcher as WatcherApi, RecommendedWatcher as Watcher, op};  - 30   - 31 use config::{self, Config, Delta};  - 32 use term::{self, cell, RenderableCell};  - 33 use window::{Size, Pixels};  - 34   - 35 use Rgb;  - 36   - 37 // Shader paths for live reload  - 38 static TEXT_SHADER_F_PATH: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.f.glsl");   - 39 static TEXT_SHADER_V_PATH: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.v.glsl");   - 40   - 41 // Shader source which is used when live-shader-reload feature is disable  - 42 static TEXT_SHADER_F: &'static str = include_str!(  - 43  concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.f.glsl")  - 44 );  - 45 static TEXT_SHADER_V: &'static str = include_str!(  - 46  concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.v.glsl")  - 47 );  - 48   - 49 /// `LoadGlyph` allows for copying a rasterized glyph into graphics memory  - 50 pub trait LoadGlyph {  - 51  /// Load the rasterized glyph into GPU memory  - 52  fn load_glyph(&mut self, rasterized: &RasterizedGlyph) -> Glyph;  - 53 }  - 54   - 55 enum Msg {  - 56  ShaderReload, 1,1Top[?12l[?25h[?25l:[?12l[?25hs[?25l[?12l[?25he[?25l[?12l[?25ht[?25l[?12l[?25h[?25l ft=yaml[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25hc[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25hc[?25l[?12l[?25ho[?25l[?12l[?25hl[?25l[?12l[?25ho[?25l[?12l[?25hr[?25l[?12l[?25hs[?25l[?12l[?25hh[?25l[?12l[?25h[?25l[?12l[?25hc[?25l[?12l[?25hh[?25l[?12l[?25he[?25l[?12l[?25hm[?25l[?12l[?25he[?25l[?12l[?25h[?25l [?12l[?25h...[?25lTomorrow-Night-Bright[?12l[?25h...[?25lblue[?12l[?25h...[?25ldarkblue[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25h[?25l[?12l[?25ht[?25l[?12l[?25h...[?25lTomorrow-Night-Bright[?12l[?25h...[?25ltende[?12l[?25h [?25l 1 // Copyright 2016 Joe Wilm, The Alacritty Project Contributors  - 2 //  - 3 // Licensed under the Apache License, Version 2.0 (the "License");  - 4 // you may not use this file except in compliance with the License.  - 5 // You may obtain a copy of the License at  - 6 //  - 7 // http://www.apache.org/licenses/LICENSE-2.0  - 8 //  - 9 // Unless required by applicable law or agreed to in writing, software  - 10 // distributed under the License is distributed on an "AS IS" BASIS,  - 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  - 12 // See the License for the specific language governing permissions and  - 13 // limitations under the License.  - 14 use std::collections::HashMap;  - 15 use std::hash::BuildHasherDefault;  - 16 use std::fs::File;  - 17 use std::io::{self, Read};  - 18 use std::mem::size_of;  - 19 use std::path::{PathBuf};  - 20 use std::ptr;  - 21 use std::sync::mpsc;  - 22   - 23 use cgmath;  - 24 use fnv::FnvHasher;  - 25 use font::{self, Rasterizer, Rasterize, RasterizedGlyph, FontDesc, GlyphKey, FontKey};  - 26 use gl::types::*;  - 27 use gl;  - 28 use index::{Line, Column, RangeInclusive};  - 29 use notify::{Watcher as WatcherApi, RecommendedWatcher as Watcher, op};  - 30   - 31 use config::{self, Config, Delta};  - 32 use term::{self, cell, RenderableCell};  - 33 use window::{Size, Pixels};  - 34   - 35 use Rgb;  - 36   - 37 // Shader paths for live reload  - 38 static TEXT_SHADER_F_PATH: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.f.glsl");   - 39 static TEXT_SHADER_V_PATH: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.v.glsl");   - 40   - 41 // Shader source which is used when live-shader-reload feature is disable  - 42 static TEXT_SHADER_F: &'static str = include_str!(  - 43  concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.f.glsl")  - 44 );  - 45 static TEXT_SHADER_V: &'static str = include_str!(  - 46  concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.v.glsl")  - 47 );  - 48   - 49 /// `LoadGlyph` allows for copying a rasterized glyph into graphics memory  - 50 pub trait LoadGlyph {  - 51  /// Load the rasterized glyph into GPU memory  - 52  fn load_glyph(&mut self, rasterized: &RasterizedGlyph) -> Glyph;  - 53 }  - 54   - 55 enum Msg {  - 56  ShaderReload, 1,1Top[?12l[?25h[?25l2[?12l[?25h[?25l3[?12l[?25h[?25l4[?12l[?25h[?25l5[?12l[?25h[?25l6[?12l[?25h[?25l7[?12l[?25h[?25l8[?12l[?25h[?25l9[?12l[?25h[?25l10,1[?12l[?25h[?25l1[?12l[?25h[?25l2[?12l[?25h[?25l3[?12l[?25h[?25l4[?12l[?25h[?25l5[?12l[?25h[?25l6[?12l[?25h[?25l7[?12l[?25h[?25l8[?12l[?25h[?25l9[?12l[?25h[?25l20[?12l[?25h[?25l1[?12l[?25h[?25l2,0-1[?12l[?25h[?25l3,1 [?12l[?25h[?25l4[?12l[?25h[?25l5[?12l[?25h[?25l6[?12l[?25h[?25l7[?12l[?25h[?25l8[?12l[?25h[?25l9[?12l[?25h[?25l30,0-1[?12l[?25h[?25l1,1 [?12l[?25h[?25l2[?12l[?25h[?25l3[?12l[?25h[?25l4,0-1[?12l[?25h[?25l5,1 [?12l[?25h[?25l6,0-1[?12l[?25h[?25l7,1 [?12l[?25h[?25l8[?12l[?25h[?25l9[?12l[?25h[?25l40,0-1[?12l[?25h[?25l1,1 [?12l[?25h[?25l2[?12l[?25h[?25l3[?12l[?25h[?25l()4[?12l[?25h[?25l( );5[?12l[?25h[?25l6[?12l[?25h[?25l()7[?12l[?25h[?25l( );8,0-1[?12l[?25h[?25l9,1 [?12l[?25h[?25l50[?12l[?25h[?25l1[?12l[?25h[?25l2[?12l[?25h[?25l{}3[?12l[?25h[?25l{ } 4,0-1[?12l[?25h[?25l5,1 [?12l[?25h[?25l6[?12l[?25h[?25l -{ - - 57 } 57,10%[?12l[?25h[?25l -{ } - 58  58,0-10%[?12l[?25h[?25l - 59 #[derive(Debug)] 59,10%[?12l[?25h[?25l - 60 pub enum Error { 60,10%[?12l[?25h[?25l - 61  ShaderCreation(ShaderCreationError), 61,10%[?12l[?25h[?25l -{ - - 62 } 62,10%[?12l[?25h[?25l -{ } - 63  63,0-10%[?12l[?25h[?25l - 64 impl ::std::error::Error for Error { 64,10%[?12l[?25h[?25l - 65  fn cause(&self) -> Option<&::std::error::Error> { 65,10%[?12l[?25h[?25l - 66 match *self { 66,10%[?12l[?25h[?25l - 67 Error::ShaderCreation(ref err) => Some(err), 67,10%[?12l[?25h[?25l - 68 } 68,10%[?12l[?25h[?25l - 69  } 69,11%[?12l[?25h[?25l - 70  70,0-11%[?12l[?25h[?25l - 71  fn description(&self) -> &str { 71,11%[?12l[?25h[?25l - 72 match *self { 72,11%[?12l[?25h[?25l - 73 Error::ShaderCreation(ref err) => err.description(), 73,11%[?12l[?25h[?25l - 74 } 74,11%[?12l[?25h[?25l - 75  } 75,11%[?12l[?25h[?25l -{ 76 } 76,11%[?12l[?25h[?25l -{ } - 77  77,0-11%[?12l[?25h[?25l - 78 impl ::std::fmt::Display for Error { 78,11%[?12l[?25h[?25l - 79  fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { 79,11%[?12l[?25h[?25l - 80 match *self { 80,11%[?12l[?25h[?25l - 81 Error::ShaderCreation(ref err) => { 81,11%[?12l[?25h[?25l - 82 write!(f, "There was an error initializing the shaders: {}", err) 82,12%[?12l[?25h[?25l - 83 } 83,12%[?12l[?25h[?25l - 84 } 84,12%[?12l[?25h[?25l - 85  } 85,12%[?12l[?25h[?25l -{ 86 } 86,12%[?12l[?25h[?25l -{ } - 87  87,0-12%[?12l[?25h[?25l - 88 impl From<ShaderCreationError> for Error { 88,12%[?12l[?25h[?25l - 89  fn from(val: ShaderCreationError) -> Error { 89,12%[?12l[?25h[?25l - 90 Error::ShaderCreation(val) 90,12%[?12l[?25h[?25l - 91  } 91,12%[?12l[?25h[?25l -{ 92 } 92,12%[?12l[?25h[?25l -{ } - 93  93,0-12%[?12l[?25h[?25l - 94  94,0-12%[?12l[?25h[?25l - 95 /// Text drawing program 95,13%[?12l[?25h[?25l - 96 /// 96,13%[?12l[?25h[?25l - 97 /// Uniforms are prefixed with "u", and vertex attributes are prefixed with "a". 97,13%[?12l[?25h[?25l - 98 #[derive(Debug)] 98,13%[?12l[?25h[?25l - 99 pub struct ShaderProgram { 99,13%[?12l[?25h[?25l - 100  // Program id 100,13%[?12l[?25h[?25l - 101  id: GLuint, 101,13%[?12l[?25h[?25l - 102  102,0-13%[?12l[?25h[?25l - 103  /// projection matrix uniform 103,13%[?12l[?25h[?25l - 104  u_projection: GLint, 104,13%[?12l[?25h[?25l - 105  105,0-13%[?12l[?25h[?25l - 106  /// Terminal dimensions (pixels) 106,13%[?12l[?25h[?25l - 107  u_term_dim: GLint, 107,13%[?12l[?25h[?25l - 108  108,0-14%[?12l[?25h[?25l - 109  /// Cell dimensions (pixels) 109,14%[?12l[?25h[?25l - 110  u_cell_dim: GLint, 110,14%[?12l[?25h[?25l - 111  111,0-14%[?12l[?25h[?25l - 112  /// Visual bell 112,14%[?12l[?25h[?25l - 113  u_visual_bell: GLint, 113,14%[?12l[?25h[?25l - 114  114,0-14%[?12l[?25h[?25l - 115  /// Background pass flag 115,14%[?12l[?25h[?25l - 116  /// 116,14%[?12l[?25h[?25l - 117  /// Rendering is split into two passes; 1 for backgrounds, and one for text 117,14%[?12l[?25h[?25l - 118  u_background: GLint, 118,14%[?12l[?25h[?25l - 119  119,0-14%[?12l[?25h[?25l - 120  padding_x: f32, 120,14%[?12l[?25h[?25l - 121  padding_y: f32, 121,15%[?12l[?25h[?25l -{ 122 } 122,15%[?12l[?25h[?25l -{ } - 123  123,0-15%[?12l[?25h[?25l - 124  124,0-15%[?12l[?25h[?25l - 125 #[derive(Debug, Clone)] 125,15%[?12l[?25h[?25l - 126 pub struct Glyph { 126,15%[?12l[?25h[?25l - 127  tex_id: GLuint, 127,15%[?12l[?25h[?25l - 128  top: f32, 128,15%[?12l[?25h[?25l - 129  left: f32, 129,15%[?12l[?25h[?25l - 130  width: f32, 130,15%[?12l[?25h[?25l - 131  height: f32, 131,15%[?12l[?25h[?25l - 132  uv_bot: f32, 132,15%[?12l[?25h[?25l - 133  uv_left: f32, 133,15%[?12l[?25h[?25l - 134  uv_width: f32, 134,16%[?12l[?25h[?25l - 135  uv_height: f32, 135,16%[?12l[?25h[?25l -{ 136 } 136,16%[?12l[?25h[?25l -{ } - 137  137,0-16%[?12l[?25h[?25l - 138 /// Naïve glyph cache 138,16%[?12l[?25h[?25l - 139 /// 139,16%[?12l[?25h[?25l - 140 /// Currently only keyed by `char`, and thus not possible to hold different 140,16%[?12l[?25h[?25l - 141 /// representations of the same code point. 141,16%[?12l[?25h[?25l - 142 pub struct GlyphCache { 142,16%[?12l[?25h[?25l - 143  /// Cache of buffered glyphs 143,16%[?12l[?25h[?25l - 144  cache: HashMap<GlyphKey, Glyph, BuildHasherDefault<FnvHasher>>, 144,16%[?12l[?25h[?25l - 145  145,0-16%[?12l[?25h[?25l - 146  /// Rasterizer for loading new glyphs 146,16%[?12l[?25h[?25l - 147  rasterizer: Rasterizer, 147,17%[?12l[?25h[?25l - 148  148,0-17%[?12l[?25h[?25l - 149  /// regular font 149,17%[?12l[?25h[?25l - 150  font_key: FontKey, 150,17%[?12l[?25h[?25l - 151  151,0-17%[?12l[?25h[?25l - 152  /// italic font 152,17%[?12l[?25h[?25l - 153  italic_key: FontKey, 153,17%[?12l[?25h[?25l - 154  154,0-17%[?12l[?25h[?25l - 155  /// bold font 155,17%[?12l[?25h[?25l - 156  bold_key: FontKey, 156,17%[?12l[?25h[?25l - 157  157,0-17%[?12l[?25h[?25l - 158  /// font size 158,17%[?12l[?25h[?25l - 159  font_size: font::Size, 159,17%[?12l[?25h[?25l - 160  160,0-18%[?12l[?25h[?25l - 161  /// glyph offset 161,18%[?12l[?25h[?25l - 162  glyph_offset: Delta, 162,18%[?12l[?25h[?25l - 163  163,0-18%[?12l[?25h[?25l - 164  metrics: ::font::Metrics, 164,18%[?12l[?25h[?25l -{ 165 } 165,18%[?12l[?25h[?25l -{ } - 166  166,0-18%[?12l[?25h[?25l - 167 impl GlyphCache { 167,18%[?12l[?25h[?25l - 168  pub fn new<L>( 168,18%[?12l[?25h[?25l - 169 mut rasterizer: Rasterizer, 169,18%[?12l[?25h[?25l - 170 config: &Config, 170,18%[?12l[?25h[?25l - 171 loader: &mut L 171,18%[?12l[?25h[?25l - 172  ) -> Result<GlyphCache, font::Error> 172,18%[?12l[?25h[?25l - 173 where L: LoadGlyph 173,19%[?12l[?25h[?25l - 174  { 174,19%[?12l[?25h[?25l - 175 let font = config.font(); 175,19%[?12l[?25h[?25l - 176 let size = font.size(); 176,19%[?12l[?25h[?25l - 177 let glyph_offset = *font.glyph_offset(); 177,19%[?12l[?25h[?25l - 178  178,0-19%[?12l[?25h[?25l - 179 fn make_desc( 179,19%[?12l[?25h[?25l - 180 desc: &config::FontDescription, 180,19%[?12l[?25h[?25l - 181 slant: font::Slant, 181,19%[?12l[?25h[?25l - 182 weight: font::Weight, 182,19%[?12l[?25h[?25l - 183 ) -> FontDesc 183,19%[?12l[?25h[?25l - 184 { 184,19%[?12l[?25h[?25l - 185 let style = if let Some(ref spec) = desc.style { 185,19%[?12l[?25h[?25l - 186 font::Style::Specific(spec.to_owned()) 186,110%[?12l[?25h[?25l - 187 } else { 187,110%[?12l[?25h[?25l - 188 font::Style::Description {slant:slant, weight:weight} 188,110%[?12l[?25h[?25l - 189 }; 189,110%[?12l[?25h[?25l - 190 FontDesc::new(&desc.family[..], style) 190,110%[?12l[?25h[?25l - 191 } 191,110%[?12l[?25h[?25l - 192  192,0-110%[?12l[?25h[?25l - 193 // Load regular font 193,110%[?12l[?25h[?25l - 194 let regular_desc = make_desc(&font.normal, font::Slant::Normal, font::Weight::Normal);  194,110%[?12l[?25h[?25l - 195  195,0-110%[?12l[?25h[?25l - 196 let regular = rasterizer 196,110%[?12l[?25h[?25l - 197 .load_font(®ular_desc, size)?; 197,110%[?12l[?25h[?25l - 198  198,0-110%[?12l[?25h[?25l - 199 // helper to load a description if it is not the regular_desc 199,111%[?12l[?25h[?25l - 200 let load_or_regular = |desc:FontDesc, rasterizer: &mut Rasterizer| { 200,111%[?12l[?25h[?25l - 201 if desc == regular_desc { 201,111%[?12l[?25h[?25l - 202 regular 202,111%[?12l[?25h[?25l - 203 } else { 203,111%[?12l[?25h[?25l - 204 rasterizer.load_font(&desc, size).unwrap_or_else(|_| regular) 204,111%[?12l[?25h[?25l - 205 } 205,111%[?12l[?25h[?25l - 206 }; 206,111%[?12l[?25h[?25l - 207  207,0-111%[?12l[?25h[?25l - 208 // Load bold font 208,111%[?12l[?25h[?25l - 209 let bold_desc = make_desc(&font.bold, font::Slant::Normal, font::Weight::Bold); 209,111%[?12l[?25h[?25l - 210  210,0-111%[?12l[?25h[?25l - 211 let bold = load_or_regular(bold_desc, &mut rasterizer); 211,111%[?12l[?25h[?25l - 212  212,0-112%[?12l[?25h[?25l - 213 // Load italic font 213,112%[?12l[?25h[?25l - 214 let italic_desc = make_desc(&font.italic, font::Slant::Italic, font::Weight::Normal); 214,112%[?12l[?25h[?25l - 215  215,0-112%[?12l[?25h[?25l - 216 let italic = load_or_regular(italic_desc, &mut rasterizer); 216,112%[?12l[?25h[?25l - 217  217,0-112%[?12l[?25h[?25l - 218 // Need to load at least one glyph for the face before calling metrics. 218,112%[?12l[?25h[?25l - 219 // The glyph requested here ('m' at the time of writing) has no special 219,112%[?12l[?25h[?25l - 220 // meaning. 220,112%[?12l[?25h[?25l - 221 rasterizer.get_glyph(&GlyphKey { font_key: regular, c: 'm', size: font.size() })?; 221,112%[?12l[?25h[?25l - 222 let metrics = rasterizer.metrics(regular)?; 222,112%[?12l[?25h[?25l - 223  223,0-112%[?12l[?25h[?25l - 224 let mut cache = GlyphCache { 224,112%[?12l[?25h[?25l - 225 cache: HashMap::default(), 225,113%[?12l[?25h[?25l - 226 rasterizer: rasterizer, 226,113%[?12l[?25h[?25l - 227 font_size: font.size(), 227,113%[?12l[?25h[?25l - 228 font_key: regular, 228,113%[?12l[?25h[?25l - 229 bold_key: bold, 229,113%[?12l[?25h[?25l - 230 italic_key: italic, 230,113%[?12l[?25h[?25l - 231 glyph_offset: glyph_offset, 231,113%[?12l[?25h[?25l - 232 metrics: metrics 232,113%[?12l[?25h[?25l - 233 }; 233,113%[?12l[?25h[?25l - 234  234,0-113%[?12l[?25h[?25l - 235 macro_rules! load_glyphs_for_font { 235,113%[?12l[?25h[?25l - 236 ($font:expr) => { 236,113%[?12l[?25h[?25l - 237 for i in RangeInclusive::new(32u8, 128u8) { 237,113%[?12l[?25h[?25l - 238 cache.get(&GlyphKey { 238,114%[?12l[?25h[?25l - 239 font_key: $font, 239,114%[?12l[?25h[?25l - 240 c: i as char, 240,114%[?12l[?25h[?25l - 241 size: font.size() 241,114%[?12l[?25h[?25l - 242 }, loader); 242,114%[?12l[?25h[?25l - 243 } 243,114%[?12l[?25h[?25l - 244 } 244,114%[?12l[?25h[?25l - 245 } 245,114%[?12l[?25h[?25l - 246  246,0-114%[?12l[?25h[?25l - 247 load_glyphs_for_font!(regular); 247,114%[?12l[?25h[?25l - 248 load_glyphs_for_font!(bold); 248,114%[?12l[?25h[?25l - 249 load_glyphs_for_font!(italic); 249,114%[?12l[?25h[?25l - 250  250,0-114%[?12l[?25h[?25l - 251 Ok(cache) 251,115%[?12l[?25h[?25l - 252  } 252,115%[?12l[?25h[?25l - 253  253,0-115%[?12l[?25h[?25l - 254  pub fn font_metrics(&self) -> font::Metrics { 254,115%[?12l[?25h[?25l - 255 self.rasterizer 255,115%[?12l[?25h[?25l - 256 .metrics(self.font_key) 256,115%[?12l[?25h[?25l - 257 .expect("metrics load since font is loaded at glyph cache creation") 257,115%[?12l[?25h[?25l - 258  } 258,115%[?12l[?25h[?25l - 259  259,0-115%[?12l[?25h[?25l - 260  pub fn get<'a, L>(&'a mut self, glyph_key: &GlyphKey, loader: &mut L) -> &'a Glyph 260,115%[?12l[?25h[?25l - 261 where L: LoadGlyph 261,115%[?12l[?25h[?25l - 262  { 262,115%[?12l[?25h[?25l - 263 let glyph_offset = self.glyph_offset; 263,115%[?12l[?25h[?25l - 264 let rasterizer = &mut self.rasterizer; 264,116%[?12l[?25h[?25l - 265 let metrics = &self.metrics; 265,116%[?12l[?25h[?25l - 266 self.cache 266,116%[?12l[?25h[?25l - 267 .entry(*glyph_key) 267,116%[?12l[?25h[?25l - 268 .or_insert_with(|| { 268,116%[?12l[?25h[?25l - 269 let mut rasterized = rasterizer.get_glyph(&glyph_key) 269,116%[?12l[?25h[?25l - 270 .unwrap_or_else(|_| Default::default()); 270,116%[?12l[?25h[?25l - 271  271,0-116%[?12l[?25h[?25l - 272 rasterized.left += glyph_offset.x as i32; 272,116%[?12l[?25h[?25l - 273 rasterized.top += glyph_offset.y as i32; 273,116%[?12l[?25h[?25l - 274 rasterized.top -= metrics.descent as i32; 274,116%[?12l[?25h[?25l - 275  275,0-116%[?12l[?25h[?25l - 276 loader.load_glyph(&rasterized) 276,116%[?12l[?25h[?25l - 277 }) 277,117%[?12l[?25h[?25l - 278  } 278,117%[?12l[?25h[?25l - 279 } 279,117%[?12l[?25h[?25l - 280  280,0-117%[?12l[?25h[?25l - 281 #[derive(Debug)] 281,117%[?12l[?25h[?25l - 282 #[repr(C)] 282,117%[?12l[?25h[?25l - 283 struct InstanceData { 283,117%[?12l[?25h[?25l - 284  // coords 284,117%[?12l[?25h[?25l - 285  col: f32, 285,117%[?12l[?25h[?25l - 286  row: f32, 286,117%[?12l[?25h[?25l - 287  // glyph offset 287,117%[?12l[?25h[?25l - 288  left: f32, 288,117%[?12l[?25h[?25l - 289  top: f32, 289,117%[?12l[?25h[?25l - 290  // glyph scale 290,118%[?12l[?25h[?25l - 291  width: f32, 291,118%[?12l[?25h[?25l - 292  height: f32, 292,118%[?12l[?25h[?25l - 293  // uv offset 293,118%[?12l[?25h[?25l - 294  uv_left: f32, 294,118%[?12l[?25h[?25l - 295  uv_bot: f32, 295,118%[?12l[?25h[?25l - 296  // uv scale 296,118%[?12l[?25h[?25l - 297  uv_width: f32, 297,118%[?12l[?25h[?25l - 298  uv_height: f32, 298,118%[?12l[?25h[?25l - 299  // color 299,118%[?12l[?25h[?25l - 300  r: f32, 300,118%[?12l[?25h[?25l - 301  g: f32, 301,118%[?12l[?25h[?25l - 302  b: f32, 302,118%[?12l[?25h[?25l - 303  // background color 303,119%[?12l[?25h[?25l - 304  bg_r: f32, 304,119%[?12l[?25h[?25l - 305  bg_g: f32, 305,119%[?12l[?25h[?25l - 306  bg_b: f32, 306,119%[?12l[?25h[?25l -{ 307 } 307,119%[?12l[?25h[?25l -{ } - 308  308,0-119%[?12l[?25h[?25l - 309 #[derive(Debug)] 309,119%[?12l[?25h[?25l - 310 pub struct QuadRenderer { 310,119%[?12l[?25h[?25l - 311  program: ShaderProgram, 311,119%[?12l[?25h[?25l - 312  vao: GLuint, 312,119%[?12l[?25h[?25l - 313  vbo: GLuint, 313,119%[?12l[?25h[?25l - 314  ebo: GLuint, 314,119%[?12l[?25h[?25l - 315  vbo_instance: GLuint, 315,119%[?12l[?25h[?25l - 316  atlas: Vec<Atlas>, 316,120%[?12l[?25h[?25l - 317  active_tex: GLuint, 317,120%[?12l[?25h[?25l - 318  batch: Batch, 318,120%[?12l[?25h[?25l - 319  rx: mpsc::Receiver<Msg>, 319,120%[?12l[?25h[?25l -{ 320 } 320,120%[?12l[?25h[?25l -{ } - 321  321,0-120%[?12l[?25h[?25l - 322 #[derive(Debug)] 322,120%[?12l[?25h[?25l - 323 pub struct RenderApi<'a> { 323,120%[?12l[?25h[?25l - 324  active_tex: &'a mut GLuint, 324,120%[?12l[?25h[?25l - 325  batch: &'a mut Batch, 325,120%[?12l[?25h[?25l - 326  atlas: &'a mut Vec<Atlas>, 326,120%[?12l[?25h[?25l - 327  program: &'a mut ShaderProgram, 327,120%[?12l[?25h[?25l - 328  config: &'a Config, 328,120%[?12l[?25h[?25l - 329  visual_bell_intensity: f32 329,121%[?12l[?25h[?25l -{ 330 } 330,121%[?12l[?25h[?25l -{ } - 331  331,0-121%[?12l[?25h[?25l - 332 #[derive(Debug)] 332,121%[?12l[?25h[?25l - 333 pub struct LoaderApi<'a> { 333,121%[?12l[?25h[?25l - 334  active_tex: &'a mut GLuint, 334,121%[?12l[?25h[?25l - 335  atlas: &'a mut Vec<Atlas>, 335,121%[?12l[?25h[?25l -{ - - - 336 } 336,121%[?12l[?25h[?25l -{ } - 337  337,0-121%[?12l[?25h[?25l - 338 #[derive(Debug)] 338,121%[?12l[?25h[?25l - 339 pub struct PackedVertex { 339,121%[?12l[?25h[?25l - 340  x: f32, 340,121%[?12l[?25h[?25l - 341  y: f32, 341,121%[?12l[?25h[?25l -{ - - - 342 } 342,122%[?12l[?25h[?25l -{ } - 343  343,0-122%[?12l[?25h[?25l - 344 #[derive(Debug)] 344,122%[?12l[?25h[?25l - 345 pub struct Batch { 345,122%[?12l[?25h[?25l - 346  tex: GLuint, 346,122%[?12l[?25h[?25l - 347  instances: Vec<InstanceData>, 347,122%[?12l[?25h[?25l 348 }  - 349   - 350 impl Batch {  - 351  #[inline]  - 352  pub fn new() -> Batch {  - 353 Batch {  - 354 tex: 0,  - 355 instances: Vec::with_capacity(BATCH_MAX),  - 356 }  - 357  }  - 358   - 359  pub fn add_item(  - 360 &mut self,  - 361 cell: &RenderableCell,  - 362 glyph: &Glyph,  - 363  ) {  - 364 if self.is_empty() {  - 365 self.tex = glyph.tex_id;  - 366 }  - 367   - 368 self.instances.push(InstanceData {  - 369 col: cell.column.0 as f32,  - 370 row: cell.line.0 as f32,  - 371   - 372 top: glyph.top,  - 373 left: glyph.left,  - 374 width: glyph.width,  - 375 height: glyph.height, 375,1324%[?12l[?25h[?25l 376   - 377 uv_bot: glyph.uv_bot,  - 378 uv_left: glyph.uv_left,  - 379 uv_width: glyph.uv_width,  - 380 uv_height: glyph.uv_height,  - 381   - 382 r: cell.fg.r as f32,  - 383 g: cell.fg.g as f32,  - 384 b: cell.fg.b as f32,  - 385   - 386 bg_r: cell.bg.r as f32,  - 387 bg_g: cell.bg.g as f32,  - 388 bg_b: cell.bg.b as f32,  - 389 });  - 390  }  - 391   - 392  #[inline]  - 393  pub fn full(&self) -> bool {  - 394 self.capacity() == self.len()  - 395  }  - 396   - 397  #[inline]  - 398  pub fn len(&self) -> usize {  - 399 self.instances.len()  - 400  }  - 401   - 402  #[inline]  - 403  pub fn capacity(&self) -> usize { 403,526%[?12l[?25h[?25l 404 BATCH_MAX  - 405  }  - 406   - 407  #[inline]  - 408  pub fn is_empty(&self) -> bool {  - 409 self.len() == 0  - 410  }  - 411   - 412  #[inline]  - 413  pub fn size(&self) -> usize {  - 414 self.len() * size_of::<InstanceData>()  - 415  }  - 416   - 417  pub fn clear(&mut self) {  - 418 self.tex = 0;  - 419 self.instances.clear();  - 420  }  - 421 }  - 422   - 423 /// Maximum items to be drawn in a batch.  - 424 const BATCH_MAX: usize = 65_536;  - 425 const ATLAS_SIZE: i32 = 1024;  - 426   - 427 impl QuadRenderer {  - 428  // TODO should probably hand this a transform instead of width/height  - 429  pub fn new(config: &Config, size: Size<Pixels<u32>>) -> Result<QuadRenderer, Error> {  - 430 let program = ShaderProgram::new(config, size)?;  - 431  431,0-128%[?12l[?25h[?25l 432 let mut vao: GLuint = 0;  - 433 let mut vbo: GLuint = 0;  - 434 let mut ebo: GLuint = 0;  - 435   - 436 let mut vbo_instance: GLuint = 0;  - 437   - 438 unsafe {  - 439 gl::Enable(gl::BLEND);  - 440 gl::BlendFunc(gl::SRC1_COLOR, gl::ONE_MINUS_SRC1_COLOR);  - 441 gl::Enable(gl::MULTISAMPLE);  - 442   - 443 gl::GenVertexArrays(1, &mut vao);  - 444 gl::GenBuffers(1, &mut vbo);  - 445 gl::GenBuffers(1, &mut ebo);  - 446 gl::GenBuffers(1, &mut vbo_instance);  - 447 gl::BindVertexArray(vao);  - 448   - 449 // ----------------------------  - 450 // setup vertex position buffer  - 451 // ----------------------------  - 452 // Top right, Bottom right, Bottom left, Top left  - 453 let vertices = [  - 454 PackedVertex { x: 1.0, y: 1.0 },  - 455 PackedVertex { x: 1.0, y: 0.0 },  - 456 PackedVertex { x: 0.0, y: 0.0 },  - 457 PackedVertex { x: 0.0, y: 1.0 },  - 458 ];  - 459  459,0-131%[?12l[?25h[?25l 460 gl::BindBuffer(gl::ARRAY_BUFFER, vbo);  - 461   - 462 gl::VertexAttribPointer(0, 2,  - 463 gl::FLOAT, gl::FALSE,  - 464 size_of::<PackedVertex>() as i32,  - 465 ptr::null());  - 466 gl::EnableVertexAttribArray(0);  - 467   - 468 gl::BufferData(gl::ARRAY_BUFFER,  - 469 (size_of::<PackedVertex>() * vertices.len()) as GLsizeiptr,  - 470 vertices.as_ptr() as *const _,  - 471 gl::STATIC_DRAW);  - 472   - 473 // ---------------------  - 474 // Set up element buffer  - 475 // ---------------------  - 476 let indices: [u32; 6] = [0, 1, 3,  - 477 1, 2, 3];  - 478   - 479 gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, ebo);  - 480 gl::BufferData(gl::ELEMENT_ARRAY_BUFFER,  - 481 (6 * size_of::<u32>()) as isize,  - 482 indices.as_ptr() as *const _,  - 483 gl::STATIC_DRAW);  - 484   - 485 // ----------------------------  - 486 // Setup vertex instance buffer  - 487 // ---------------------------- 487,1333%[?12l[?25h[?25l 488 gl::BindBuffer(gl::ARRAY_BUFFER, vbo_instance);  - 489 gl::BufferData(gl::ARRAY_BUFFER,  - 490 (BATCH_MAX * size_of::<InstanceData>()) as isize,  - 491 ptr::null(), gl::STREAM_DRAW);  - 492 // coords  - 493 gl::VertexAttribPointer(1, 2,  - 494 gl::FLOAT, gl::FALSE,  - 495 size_of::<InstanceData>() as i32,  - 496 ptr::null());  - 497 gl::EnableVertexAttribArray(1);  - 498 gl::VertexAttribDivisor(1, 1);  - 499 // glyphoffset  - 500 gl::VertexAttribPointer(2, 4,  - 501 gl::FLOAT, gl::FALSE,  - 502 size_of::<InstanceData>() as i32,  - 503 (2 * size_of::<f32>()) as *const _);  - 504 gl::EnableVertexAttribArray(2);  - 505 gl::VertexAttribDivisor(2, 1);  - 506 // uv  - 507 gl::VertexAttribPointer(3, 4,  - 508 gl::FLOAT, gl::FALSE,  - 509 size_of::<InstanceData>() as i32,  - 510 (6 * size_of::<f32>()) as *const _);  - 511 gl::EnableVertexAttribArray(3);  - 512 gl::VertexAttribDivisor(3, 1);  - 513 // color  - 514 gl::VertexAttribPointer(4, 3,  - 515 gl::FLOAT, gl::FALSE, 515,3735%[?12l[?25h[?25l 516 size_of::<InstanceData>() as i32,  - 517 (10 * size_of::<f32>()) as *const _);  - 518 gl::EnableVertexAttribArray(4);  - 519 gl::VertexAttribDivisor(4, 1);  - 520 // color  - 521 gl::VertexAttribPointer(5, 3,  - 522 gl::FLOAT, gl::FALSE,  - 523 size_of::<InstanceData>() as i32,  - 524 (13 * size_of::<f32>()) as *const _);  - 525 gl::EnableVertexAttribArray(5);  - 526 gl::VertexAttribDivisor(5, 1);  - 527   - 528 gl::BindVertexArray(0);  - 529 gl::BindBuffer(gl::ARRAY_BUFFER, 0);  - 530 }  - 531   - 532 let (msg_tx, msg_rx) = mpsc::channel();  - 533   - 534 if cfg!(feature = "live-shader-reload") {  - 535 ::std::thread::spawn(move || {  - 536 let (tx, rx) = ::std::sync::mpsc::channel();  - 537 let mut watcher = Watcher::new(tx).expect("create file watcher");  - 538 watcher.watch(TEXT_SHADER_F_PATH).expect("watch fragment shader");  - 539 watcher.watch(TEXT_SHADER_V_PATH).expect("watch vertex shader");  - 540   - 541 loop {  - 542 let event = rx.recv().expect("watcher event");  - 543 let ::notify::Event { path, op } = event; 543,2137%[?12l[?25h[?25l 544   - 545 if let Ok(op) = op {  - 546 if op.contains(op::RENAME) {  - 547 continue;  - 548 }  - 549   - 550 if op.contains(op::IGNORED) {  - 551 if let Some(path) = path.as_ref() {  - 552 if let Err(err) = watcher.watch(path) {  - 553 warn!("failed to establish watch on {:?}: {:?}", path, err);   - 554 }  - 555 }  - 556   - 557 msg_tx.send(Msg::ShaderReload)  - 558 .expect("msg send ok");  - 559 }  - 560 }  - 561 }  - 562 });  - 563 }  - 564   - 565 let mut renderer = QuadRenderer {  - 566 program: program,  - 567 vao: vao,  - 568 vbo: vbo,  - 569 ebo: ebo,  - 570 vbo_instance: vbo_instance,  - 571 atlas: Vec::new(), 571,1339%[?12l[?25h[?25l 572 active_tex: 0,  - 573 batch: Batch::new(),  - 574 rx: msg_rx,  - 575 };  - 576   - 577 let atlas = Atlas::new(ATLAS_SIZE);  - 578 renderer.atlas.push(atlas);  - 579   - 580 Ok(renderer)  - 581  }  - 582   - 583  pub fn with_api<F, T>(  - 584 &mut self,  - 585 config: &Config,  - 586 props: &term::SizeInfo,  - 587 visual_bell_intensity: f64,  - 588 func: F  - 589  ) -> T  - 590 where F: FnOnce(RenderApi) -> T  - 591  {  - 592 while let Ok(msg) = self.rx.try_recv() {  - 593 match msg {  - 594 Msg::ShaderReload => {  - 595 self.reload_shaders(&config, Size {  - 596 width: Pixels(props.width as u32),  - 597 height: Pixels(props.height as u32)  - 598 });  - 599 } 599,1741%[?12l[?25h[?25l{ } - 600 }  - 601 }  - 602   - 603 unsafe {  - 604 self.program.activate();  - 605 self.program.set_term_uniforms(props);  - 606 self.program.set_visual_bell(visual_bell_intensity as _);  - 607   - 608 gl::BindVertexArray(self.vao);  - 609 gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, self.ebo);  - 610 gl::BindBuffer(gl::ARRAY_BUFFER, self.vbo_instance);  - 611 gl::ActiveTexture(gl::TEXTURE0);  - 612 }  - 613   - 614 let res = func(RenderApi {  - 615 active_tex: &mut self.active_tex,  - 616 batch: &mut self.batch,  - 617 atlas: &mut self.atlas,  - 618 program: &mut self.program,  - 619 visual_bell_intensity: visual_bell_intensity as _,  - 620 config: config,  - 621 });  - 622   - 623 unsafe {  - 624 gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, 0);  - 625 gl::BindBuffer(gl::ARRAY_BUFFER, 0);  - 626 gl::BindVertexArray(0);  - 627  627,0-143%[?12l[?25h[?25l 628 self.program.deactivate();  - 629 }  - 630   - 631 res  - 632  }  - 633   - 634  pub fn with_loader<F, T>(&mut self, func: F) -> T  - 635 where F: FnOnce(LoaderApi) -> T  - 636  {  - 637 unsafe {  - 638 gl::ActiveTexture(gl::TEXTURE0);  - 639 }  - 640   - 641 func(LoaderApi {  - 642 active_tex: &mut self.active_tex,  - 643 atlas: &mut self.atlas,  - 644 })  - 645  }  - 646   - 647  pub fn reload_shaders(&mut self, config: &Config, size: Size<Pixels<u32>>) {  - 648 info!("Reloading shaders");  - 649 let program = match ShaderProgram::new(config, size) {  - 650 Ok(program) => program,  - 651 Err(err) => {  - 652 match err {  - 653 ShaderCreationError::Io(err) => {  - 654 error!("Error reading shader file: {}", err);  - 655 }, 655,2146%[?12l[?25h[?25l 572 active_tex: 0,  - 573 batch: Batch::new(),  - 574 rx: msg_rx,  - 575 };  - 576   - 577 let atlas = Atlas::new(ATLAS_SIZE);  - 578 renderer.atlas.push(atlas);  - 579   - 580 Ok(renderer)  - 581  }  - 582   - 583  pub fn with_api<F, T>(  - 584 &mut self,  - 585 config: &Config,  - 586 props: &term::SizeInfo,  - 587 visual_bell_intensity: f64,  - 588 func: F  - 589  ) -> T  - 590 where F: FnOnce(RenderApi) -> T  - 591  {  - 592 while let Ok(msg) = self.rx.try_recv() {  - 593 match msg {  - 594 Msg::ShaderReload => {  - 595 self.reload_shaders(&config, Size {  - 596 width: Pixels(props.width as u32),  - 597 height: Pixels(props.height as u32)  - 598 });  - 599 } 627,0-143%[?12l[?25h[?25l 544   - 545 if let Ok(op) = op {  - 546 if op.contains(op::RENAME) {  - 547 continue;  - 548 }  - 549   - 550 if op.contains(op::IGNORED) {  - 551 if let Some(path) = path.as_ref() {  - 552 if let Err(err) = watcher.watch(path) {  - 553 warn!("failed to establish watch on {:?}: {:?}", path, err);   - 554 }  - 555 }  - 556   - 557 msg_tx.send(Msg::ShaderReload)  - 558 .expect("msg send ok");  - 559 }  - 560 }  - 561 }  - 562 });  - 563 }  - 564   - 565 let mut renderer = QuadRenderer {  - 566 program: program,  - 567 vao: vao,  - 568 vbo: vbo,  - 569 ebo: ebo,  - 570 vbo_instance: vbo_instance,  - 571 atlas: Vec::new(), {}599,1741%[?12l[?25h[?25l 516 size_of::<InstanceData>() as i32,  - 517 (10 * size_of::<f32>()) as *const _);  - 518 gl::EnableVertexAttribArray(4);  - 519 gl::VertexAttribDivisor(4, 1);  - 520 // color  - 521 gl::VertexAttribPointer(5, 3,  - 522 gl::FLOAT, gl::FALSE,  - 523 size_of::<InstanceData>() as i32,  - 524 (13 * size_of::<f32>()) as *const _);  - 525 gl::EnableVertexAttribArray(5);  - 526 gl::VertexAttribDivisor(5, 1);  - 527   - 528 gl::BindVertexArray(0);  - 529 gl::BindBuffer(gl::ARRAY_BUFFER, 0);  - 530 }  - 531   - 532 let (msg_tx, msg_rx) = mpsc::channel();  - 533   - 534 if cfg!(feature = "live-shader-reload") {  - 535 ::std::thread::spawn(move || {  - 536 let (tx, rx) = ::std::sync::mpsc::channel();  - 537 let mut watcher = Watcher::new(tx).expect("create file watcher");  - 538 watcher.watch(TEXT_SHADER_F_PATH).expect("watch fragment shader");  - 539 watcher.watch(TEXT_SHADER_V_PATH).expect("watch vertex shader");  - 540   - 541 loop {  - 542 let event = rx.recv().expect("watcher event");  - 543 let ::notify::Event { path, op } = event; 571,1339%[?12l[?25h[?25l 488 gl::BindBuffer(gl::ARRAY_BUFFER, vbo_instance);  - 489 gl::BufferData(gl::ARRAY_BUFFER,  - 490 (BATCH_MAX * size_of::<InstanceData>()) as isize,  - 491 ptr::null(), gl::STREAM_DRAW);  - 492 // coords  - 493 gl::VertexAttribPointer(1, 2,  - 494 gl::FLOAT, gl::FALSE,  - 495 size_of::<InstanceData>() as i32,  - 496 ptr::null());  - 497 gl::EnableVertexAttribArray(1);  - 498 gl::VertexAttribDivisor(1, 1);  - 499 // glyphoffset  - 500 gl::VertexAttribPointer(2, 4,  - 501 gl::FLOAT, gl::FALSE,  - 502 size_of::<InstanceData>() as i32,  - 503 (2 * size_of::<f32>()) as *const _);  - 504 gl::EnableVertexAttribArray(2);  - 505 gl::VertexAttribDivisor(2, 1);  - 506 // uv  - 507 gl::VertexAttribPointer(3, 4,  - 508 gl::FLOAT, gl::FALSE,  - 509 size_of::<InstanceData>() as i32,  - 510 (6 * size_of::<f32>()) as *const _);  - 511 gl::EnableVertexAttribArray(3);  - 512 gl::VertexAttribDivisor(3, 1);  - 513 // color  - 514 gl::VertexAttribPointer(4, 3,  - 515 gl::FLOAT, gl::FALSE, 543,2137%[?12l[?25h[?25l 460 gl::BindBuffer(gl::ARRAY_BUFFER, vbo);  - 461   - 462 gl::VertexAttribPointer(0, 2,  - 463 gl::FLOAT, gl::FALSE,  - 464 size_of::<PackedVertex>() as i32,  - 465 ptr::null());  - 466 gl::EnableVertexAttribArray(0);  - 467   - 468 gl::BufferData(gl::ARRAY_BUFFER,  - 469 (size_of::<PackedVertex>() * vertices.len()) as GLsizeiptr,  - 470 vertices.as_ptr() as *const _,  - 471 gl::STATIC_DRAW);  - 472   - 473 // ---------------------  - 474 // Set up element buffer  - 475 // ---------------------  - 476 let indices: [u32; 6] = [0, 1, 3,  - 477 1, 2, 3];  - 478   - 479 gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, ebo);  - 480 gl::BufferData(gl::ELEMENT_ARRAY_BUFFER,  - 481 (6 * size_of::<u32>()) as isize,  - 482 indices.as_ptr() as *const _,  - 483 gl::STATIC_DRAW);  - 484   - 485 // ----------------------------  - 486 // Setup vertex instance buffer  - 487 // ---------------------------- 515,3735%[?12l[?25h[?25l 432 let mut vao: GLuint = 0;  - 433 let mut vbo: GLuint = 0;  - 434 let mut ebo: GLuint = 0;  - 435   - 436 let mut vbo_instance: GLuint = 0;  - 437   - 438 unsafe {  - 439 gl::Enable(gl::BLEND);  - 440 gl::BlendFunc(gl::SRC1_COLOR, gl::ONE_MINUS_SRC1_COLOR);  - 441 gl::Enable(gl::MULTISAMPLE);  - 442   - 443 gl::GenVertexArrays(1, &mut vao);  - 444 gl::GenBuffers(1, &mut vbo);  - 445 gl::GenBuffers(1, &mut ebo);  - 446 gl::GenBuffers(1, &mut vbo_instance);  - 447 gl::BindVertexArray(vao);  - 448   - 449 // ----------------------------  - 450 // setup vertex position buffer  - 451 // ----------------------------  - 452 // Top right, Bottom right, Bottom left, Top left  - 453 let vertices = [  - 454 PackedVertex { x: 1.0, y: 1.0 },  - 455 PackedVertex { x: 1.0, y: 0.0 },  - 456 PackedVertex { x: 0.0, y: 0.0 },  - 457 PackedVertex { x: 0.0, y: 1.0 },  - 458 ];  - 459  487,1333%[?12l[?25h[?25l 404 BATCH_MAX  - 405  }  - 406   - 407  #[inline]  - 408  pub fn is_empty(&self) -> bool {  - 409 self.len() == 0  - 410  }  - 411   - 412  #[inline]  - 413  pub fn size(&self) -> usize {  - 414 self.len() * size_of::<InstanceData>()  - 415  }  - 416   - 417  pub fn clear(&mut self) {  - 418 self.tex = 0;  - 419 self.instances.clear();  - 420  }  - 421 }  - 422   - 423 /// Maximum items to be drawn in a batch.  - 424 const BATCH_MAX: usize = 65_536;  - 425 const ATLAS_SIZE: i32 = 1024;  - 426   - 427 impl QuadRenderer {  - 428  // TODO should probably hand this a transform instead of width/height  - 429  pub fn new(config: &Config, size: Size<Pixels<u32>>) -> Result<QuadRenderer, Error> {  - 430 let program = ShaderProgram::new(config, size)?;  - 431  459,0-131%[?12l[?25h[?25l 376   - 377 uv_bot: glyph.uv_bot,  - 378 uv_left: glyph.uv_left,  - 379 uv_width: glyph.uv_width,  - 380 uv_height: glyph.uv_height,  - 381   - 382 r: cell.fg.r as f32,  - 383 g: cell.fg.g as f32,  - 384 b: cell.fg.b as f32,  - 385   - 386 bg_r: cell.bg.r as f32,  - 387 bg_g: cell.bg.g as f32,  - 388 bg_b: cell.bg.b as f32,  - 389 });  - 390  }  - 391   - 392  #[inline]  - 393  pub fn full(&self) -> bool {  - 394 self.capacity() == self.len()  - 395  }  - 396   - 397  #[inline]  - 398  pub fn len(&self) -> usize {  - 399 self.instances.len()  - 400  }  - 401   - 402  #[inline]  - 403  pub fn capacity(&self) -> usize { 431,0-128%[?12l[?25h[?25l 348 }  - 349   - 350 impl Batch {  - 351  #[inline]  - 352  pub fn new() -> Batch {  - 353 Batch {  - 354 tex: 0,  - 355 instances: Vec::with_capacity(BATCH_MAX),  - 356 }  - 357  }  - 358   - 359  pub fn add_item(  - 360 &mut self,  - 361 cell: &RenderableCell,  - 362 glyph: &Glyph,  - 363  ) {  - 364 if self.is_empty() {  - 365 self.tex = glyph.tex_id;  - 366 }  - 367   - 368 self.instances.push(InstanceData {  - 369 col: cell.column.0 as f32,  - 370 row: cell.line.0 as f32,  - 371   - 372 top: glyph.top,  - 373 left: glyph.left,  - 374 width: glyph.width,  - 375 height: glyph.height, 403,526%[?12l[?25h[?25l 320 }  - 321   - 322 #[derive(Debug)]  - 323 pub struct RenderApi<'a> {  - 324  active_tex: &'a mut GLuint,  - 325  batch: &'a mut Batch,  - 326  atlas: &'a mut Vec<Atlas>,  - 327  program: &'a mut ShaderProgram,  - 328  config: &'a Config,  - 329  visual_bell_intensity: f32  - 330 }  - 331   - 332 #[derive(Debug)]  - 333 pub struct LoaderApi<'a> {  - 334  active_tex: &'a mut GLuint,  - 335  atlas: &'a mut Vec<Atlas>,  - 336 }  - 337   - 338 #[derive(Debug)]  - 339 pub struct PackedVertex {  - 340  x: f32,  - 341  y: f32,  - 342 }  - 343   - 344 #[derive(Debug)]  - 345 pub struct Batch {  - 346  tex: GLuint,  - 347  instances: Vec<InstanceData>, 375,1324%[?12l[?25h[?25l 292  height: f32,  - 293  // uv offset  - 294  uv_left: f32,  - 295  uv_bot: f32,  - 296  // uv scale  - 297  uv_width: f32,  - 298  uv_height: f32,  - 299  // color  - 300  r: f32,  - 301  g: f32,  - 302  b: f32,  - 303  // background color  - 304  bg_r: f32,  - 305  bg_g: f32,  - 306  bg_b: f32,  - 307 }  - 308   - 309 #[derive(Debug)]  - 310 pub struct QuadRenderer {  - 311  program: ShaderProgram,  - 312  vao: GLuint,  - 313  vbo: GLuint,  - 314  ebo: GLuint,  - 315  vbo_instance: GLuint,  - 316  atlas: Vec<Atlas>,  - 317  active_tex: GLuint,  - 318  batch: Batch,  - 319  rx: mpsc::Receiver<Msg>, 347,522%[?12l[?25h[?25l 264 let rasterizer = &mut self.rasterizer;  - 265 let metrics = &self.metrics;  - 266 self.cache  - 267 .entry(*glyph_key)  - 268 .or_insert_with(|| {  - 269 let mut rasterized = rasterizer.get_glyph(&glyph_key)  - 270 .unwrap_or_else(|_| Default::default());  - 271   - 272 rasterized.left += glyph_offset.x as i32;  - 273 rasterized.top += glyph_offset.y as i32;  - 274 rasterized.top -= metrics.descent as i32;  - 275   - 276 loader.load_glyph(&rasterized)  - 277 })  - 278  }  - 279 }  - 280   - 281 #[derive(Debug)]  - 282 #[repr(C)]  - 283 struct InstanceData {  - 284  // coords  - 285  col: f32,  - 286  row: f32,  - 287  // glyph offset  - 288  left: f32,  - 289  top: f32,  - 290  // glyph scale  - 291  width: f32, 319,520%[?12l[?25h[?25l 236 ($font:expr) => {  - 237 for i in RangeInclusive::new(32u8, 128u8) {  - 238 cache.get(&GlyphKey {  - 239 font_key: $font,  - 240 c: i as char,  - 241 size: font.size()  - 242 }, loader);  - 243 }  - 244 }  - 245 }  - 246   - 247 load_glyphs_for_font!(regular);  - 248 load_glyphs_for_font!(bold);  - 249 load_glyphs_for_font!(italic);  - 250   - 251 Ok(cache)  - 252  }  - 253   - 254  pub fn font_metrics(&self) -> font::Metrics {  - 255 self.rasterizer  - 256 .metrics(self.font_key)  - 257 .expect("metrics load since font is loaded at glyph cache creation")  - 258  }  - 259   - 260  pub fn get<'a, L>(&'a mut self, glyph_key: &GlyphKey, loader: &mut L) -> &'a Glyph  - 261 where L: LoadGlyph  - 262  {  - 263 let glyph_offset = self.glyph_offset; 291,518%[?12l[?25h[?25l 208 // Load bold font  - 209 let bold_desc = make_desc(&font.bold, font::Slant::Normal, font::Weight::Bold);  - 210   - 211 let bold = load_or_regular(bold_desc, &mut rasterizer);  - 212   - 213 // Load italic font  - 214 let italic_desc = make_desc(&font.italic, font::Slant::Italic, font::Weight::Normal);  - 215   - 216 let italic = load_or_regular(italic_desc, &mut rasterizer);  - 217   - 218 // Need to load at least one glyph for the face before calling metrics.  - 219 // The glyph requested here ('m' at the time of writing) has no special  - 220 // meaning.  - 221 rasterizer.get_glyph(&GlyphKey { font_key: regular, c: 'm', size: font.size() })?;  - 222 let metrics = rasterizer.metrics(regular)?;  - 223   - 224 let mut cache = GlyphCache {  - 225 cache: HashMap::default(),  - 226 rasterizer: rasterizer,  - 227 font_size: font.size(),  - 228 font_key: regular,  - 229 bold_key: bold,  - 230 italic_key: italic,  - 231 glyph_offset: glyph_offset,  - 232 metrics: metrics  - 233 };  - 234   - 235 macro_rules! load_glyphs_for_font { 263,915%[?12l[?25h[?25l 180 desc: &config::FontDescription,  - 181 slant: font::Slant,  - 182 weight: font::Weight,  - 183 ) -> FontDesc  - 184 {  - 185 let style = if let Some(ref spec) = desc.style {  - 186 font::Style::Specific(spec.to_owned())  - 187 } else {  - 188 font::Style::Description {slant:slant, weight:weight}  - 189 };  - 190 FontDesc::new(&desc.family[..], style)  - 191 }  - 192   - 193 // Load regular font  - 194 let regular_desc = make_desc(&font.normal, font::Slant::Normal, font::Weight::Normal);   - 195   - 196 let regular = rasterizer  - 197 .load_font(®ular_desc, size)?;  - 198   - 199 // helper to load a description if it is not the regular_desc  - 200 let load_or_regular = |desc:FontDesc, rasterizer: &mut Rasterizer| {  - 201 if desc == regular_desc {  - 202 regular  - 203 } else {  - 204 rasterizer.load_font(&desc, size).unwrap_or_else(|_| regular)  - 205 }  - 206 };  - 207  235,913%[?12l[?25h[?25l 152  /// italic font  - 153  italic_key: FontKey,  - 154   - 155  /// bold font  - 156  bold_key: FontKey,  - 157   - 158  /// font size  - 159  font_size: font::Size,  - 160   - 161  /// glyph offset  - 162  glyph_offset: Delta,  - 163   - 164  metrics: ::font::Metrics,  - 165 }  - 166   - 167 impl GlyphCache {  - 168  pub fn new<L>(  - 169 mut rasterizer: Rasterizer,  - 170 config: &Config,  - 171 loader: &mut L  - 172  ) -> Result<GlyphCache, font::Error>  - 173 where L: LoadGlyph  - 174  {  - 175 let font = config.font();  - 176 let size = font.size();  - 177 let glyph_offset = *font.glyph_offset();  - 178   - 179 fn make_desc( 207,0-111%[?12l[?25h[?25l 124   - 125 #[derive(Debug, Clone)]  - 126 pub struct Glyph {  - 127  tex_id: GLuint,  - 128  top: f32,  - 129  left: f32,  - 130  width: f32,  - 131  height: f32,  - 132  uv_bot: f32,  - 133  uv_left: f32,  - 134  uv_width: f32,  - 135  uv_height: f32,  - 136 }  - 137   - 138 /// Naïve glyph cache  - 139 ///  - 140 /// Currently only keyed by `char`, and thus not possible to hold different  - 141 /// representations of the same code point.  - 142 pub struct GlyphCache {  - 143  /// Cache of buffered glyphs  - 144  cache: HashMap<GlyphKey, Glyph, BuildHasherDefault<FnvHasher>>,  - 145   - 146  /// Rasterizer for loading new glyphs  - 147  rasterizer: Rasterizer,  - 148   - 149  /// regular font  - 150  font_key: FontKey,  - 151  179,99%[?12l[?25h[?25l 96 ///  - 97 /// Uniforms are prefixed with "u", and vertex attributes are prefixed with "a".  - 98 #[derive(Debug)]  - 99 pub struct ShaderProgram {  - 100  // Program id  - 101  id: GLuint,  - 102   - 103  /// projection matrix uniform  - 104  u_projection: GLint,  - 105   - 106  /// Terminal dimensions (pixels)  - 107  u_term_dim: GLint,  - 108   - 109  /// Cell dimensions (pixels)  - 110  u_cell_dim: GLint,  - 111   - 112  /// Visual bell  - 113  u_visual_bell: GLint,  - 114   - 115  /// Background pass flag  - 116  ///  - 117  /// Rendering is split into two passes; 1 for backgrounds, and one for text  - 118  u_background: GLint,  - 119   - 120  padding_x: f32,  - 121  padding_y: f32,  - 122 }  - 123  151,0-17%[?12l[?25h[?25l:[?12l[?25hq[?25l[?12l[?25h[?25l[?12l[?25h [?25l151,0-17%[?12l[?25h diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/vim_large_window_scroll b/cmd/sst/mosaic/multiplexer/tcell-term/tests/vim_large_window_scroll deleted file mode 100644 index 2da4636fb1..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/vim_large_window_scroll +++ /dev/null @@ -1,977 +0,0 @@ -% jwilm@kurast.local ➜  ~/code/alacritty  [?1h=[?2004hvvivim ssrrcc//rreennderer//mmood.rs  [?1l>[?2004l -[?1049h[?1h=▽ [?12;25h[?12l[?25h[?25l"src/renderer/mod.rs" 1354L, 40527C[>c 78 impl ::std::fmt::Display for Error {  - 79  fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {  - 80 match *self {  - 81 Error::ShaderCreation(ref err) => {  - 82 write!(f, "There was an error initializing the shaders: {}", err)  - 83 }  - 84 }  - 85  }  - 86 }  - 87   - 88 impl From<ShaderCreationError> for Error {  - 89  fn from(val: ShaderCreationError) -> Error {  - 90 Error::ShaderCreation(val)  - 91  }  - 92 }  - 93   - 94   - 95 /// Text drawing program  - 96 ///  - 97 /// Uniforms are prefixed with "u", and vertex attributes are prefixed with "a".  - 98 #[derive(Debug)]  - 99 pub struct ShaderProgram {  - 100  // Program id  - 101  id: GLuint,  - 102   - 103  /// projection matrix uniform  - 104  u_projection: GLint,  - 105   - 106  /// Terminal dimensions (pixels)  - 107  u_term_dim: GLint,  - 108   - 109  /// Cell dimensions (pixels)  - 110  u_cell_dim: GLint,  - 111   - 112  /// Visual bell  - 113  u_visual_bell: GLint,  - 114   - 115  /// Background pass flag  - 116  ///  - 117  /// Rendering is split into two passes; 1 for backgrounds, and one for text  - 118  u_background: GLint,  - 119   - 120  padding_x: f32,  - 121  padding_y: f32,  - 122 }  - 123   - 124   - 125 #[derive(Debug, Clone)]  - 126 pub struct Glyph {  - 127  tex_id: GLuint,  - 128  top: f32,  - 129  left: f32,  - 130  width: f32,  - 131  height: f32,  - 132  uv_bot: f32,  - 133  uv_left: f32, 105,0-15%[?12l[?25h[?25l 1 // Copyright 2016 Joe Wilm, The Alacritty Project Contributors  - 2 //  - 3 // Licensed under the Apache License, Version 2.0 (the "License");  - 4 // you may not use this file except in compliance with the License.  - 5 // You may obtain a copy of the License at  - 6 //  - 7 // http://www.apache.org/licenses/LICENSE-2.0  - 8 //  - 9 // Unless required by applicable law or agreed to in writing, software  - 10 // distributed under the License is distributed on an "AS IS" BASIS,  - 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  - 12 // See the License for the specific language governing permissions and  - 13 // limitations under the License.  - 14 use std::collections::HashMap;  - 15 use std::hash::BuildHasherDefault;  - 16 use std::fs::File;  - 17 use std::io::{self, Read};  - 18 use std::mem::size_of;  - 19 use std::path::{PathBuf};  - 20 use std::ptr;  - 21 use std::sync::mpsc;  - 22   - 23 use cgmath;  - 24 use fnv::FnvHasher;  - 25 use font::{self, Rasterizer, Rasterize, RasterizedGlyph, FontDesc, GlyphKey, FontKey};  - 26 use gl::types::*;  - 27 use gl;  - 28 use index::{Line, Column, RangeInclusive};  - 29 use notify::{Watcher as WatcherApi, RecommendedWatcher as Watcher, op};  - 30   - 31 use config::{self, Config, Delta};  - 32 use term::{self, cell, RenderableCell};  - 33 use window::{Size, Pixels};  - 34   - 35 use Rgb;  - 36   - 37 // Shader paths for live reload  - 38 static TEXT_SHADER_F_PATH: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.f.glsl");   - 39 static TEXT_SHADER_V_PATH: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.v.glsl");   - 40   - 41 // Shader source which is used when live-shader-reload feature is disable  - 42 static TEXT_SHADER_F: &'static str = include_str!(  - 43  concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.f.glsl")  - 44 );  - 45 static TEXT_SHADER_V: &'static str = include_str!(  - 46  concat!(env!("CARGO_MANIFEST_DIR"), "/res/text.v.glsl")  - 47 );  - 48   - 49 /// `LoadGlyph` allows for copying a rasterized glyph into graphics memory  - 50 pub trait LoadGlyph {  - 51  /// Load the rasterized glyph into GPU memory  - 52  fn load_glyph(&mut self, rasterized: &RasterizedGlyph) -> Glyph;  - 53 }  - 54   - 55 enum Msg {  - 56  ShaderReload, 1,1Top[?12l[?25h[?25l2[?12l[?25h[?25l3[?12l[?25h[?25l4[?12l[?25h[?25l5[?12l[?25h[?25l6[?12l[?25h[?25l7[?12l[?25h[?25l8[?12l[?25h[?25l9[?12l[?25h[?25l10,1[?12l[?25h[?25l1[?12l[?25h[?25l2[?12l[?25h[?25l3[?12l[?25h[?25l4[?12l[?25h[?25l5[?12l[?25h[?25l6[?12l[?25h[?25l7[?12l[?25h[?25l8[?12l[?25h[?25l9[?12l[?25h[?25l20[?12l[?25h[?25l1[?12l[?25h[?25l2,0-1[?12l[?25h[?25l3,1 [?12l[?25h[?25l4[?12l[?25h[?25l5[?12l[?25h[?25l6[?12l[?25h[?25l7[?12l[?25h[?25l8[?12l[?25h[?25l9[?12l[?25h[?25l30,0-1[?12l[?25h[?25l1,1 [?12l[?25h[?25l2[?12l[?25h[?25l3[?12l[?25h[?25l4,0-1[?12l[?25h[?25l5,1 [?12l[?25h[?25l6,0-1[?12l[?25h[?25l7,1 [?12l[?25h[?25l8[?12l[?25h[?25l9[?12l[?25h[?25l40,0-1[?12l[?25h[?25l1,1 [?12l[?25h[?25l2[?12l[?25h[?25l3[?12l[?25h[?25l()4[?12l[?25h[?25l()5[?12l[?25h[?25l6[?12l[?25h[?25l()7[?12l[?25h[?25l()8,0-1[?12l[?25h[?25l9,1 [?12l[?25h[?25l50[?12l[?25h[?25l1[?12l[?25h[?25l2[?12l[?25h[?25l{}3[?12l[?25h[?25l{}4,0-1[?12l[?25h[?25l5,1 [?12l[?25h[?25l6[?12l[?25h[?25l -{ - - 57 } 57,10%[?12l[?25h[?25l -{} - 58  58,0-10%[?12l[?25h[?25l - 59 #[derive(Debug)] 59,10%[?12l[?25h[?25l - 60 pub enum Error { 60,10%[?12l[?25h[?25l - 61  ShaderCreation(ShaderCreationError), 61,10%[?12l[?25h[?25l -{ - - 62 } 62,10%[?12l[?25h[?25l -{} - 63  63,0-10%[?12l[?25h[?25l - 64 impl ::std::error::Error for Error { 64,10%[?12l[?25h[?25l - 65  fn cause(&self) -> Option<&::std::error::Error> { 65,10%[?12l[?25h[?25l - 66 match *self { 66,10%[?12l[?25h[?25l - 67 Error::ShaderCreation(ref err) => Some(err), 67,10%[?12l[?25h[?25l - 68 } 68,10%[?12l[?25h[?25l - 69  } 69,11%[?12l[?25h[?25l - 70  70,0-11%[?12l[?25h[?25l - 71  fn description(&self) -> &str { 71,11%[?12l[?25h[?25l - 72 match *self { 72,11%[?12l[?25h[?25l - 73 Error::ShaderCreation(ref err) => err.description(), 73,11%[?12l[?25h[?25l - 74 } 74,11%[?12l[?25h[?25l - 75  } 75,11%[?12l[?25h[?25l -{ 76 } 76,11%[?12l[?25h[?25l -{} - 77  77,0-11%[?12l[?25h[?25l - 78 impl ::std::fmt::Display for Error { 78,11%[?12l[?25h[?25l - 79  fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { 79,11%[?12l[?25h[?25l - 80 match *self { 80,11%[?12l[?25h[?25l - 81 Error::ShaderCreation(ref err) => { 81,11%[?12l[?25h[?25l - 82 write!(f, "There was an error initializing the shaders: {}", err) 82,12%[?12l[?25h[?25l - 83 } 83,12%[?12l[?25h[?25l - 84 } 84,12%[?12l[?25h[?25l - 85  } 85,12%[?12l[?25h[?25l -{ 86 } 86,12%[?12l[?25h[?25l -{} - 87  87,0-12%[?12l[?25h[?25l - 88 impl From<ShaderCreationError> for Error { 88,12%[?12l[?25h[?25l - 89  fn from(val: ShaderCreationError) -> Error { 89,12%[?12l[?25h[?25l - 90 Error::ShaderCreation(val) 90,12%[?12l[?25h[?25l - 91  } 91,12%[?12l[?25h[?25l -{ 92 } 92,12%[?12l[?25h[?25l -{} - 93  93,0-12%[?12l[?25h[?25l - 94  94,0-12%[?12l[?25h[?25l - 95 /// Text drawing program 95,13%[?12l[?25h[?25l - 96 /// 96,13%[?12l[?25h[?25l - 97 /// Uniforms are prefixed with "u", and vertex attributes are prefixed with "a". 97,13%[?12l[?25h[?25l - 98 #[derive(Debug)] 98,13%[?12l[?25h[?25l - 99 pub struct ShaderProgram { 99,13%[?12l[?25h[?25l - 100  // Program id 100,13%[?12l[?25h[?25l - 101  id: GLuint, 101,13%[?12l[?25h[?25l - 102  102,0-13%[?12l[?25h[?25l - 103  /// projection matrix uniform 103,13%[?12l[?25h[?25l - 104  u_projection: GLint, 104,13%[?12l[?25h[?25l - 105  105,0-13%[?12l[?25h[?25l - 106  /// Terminal dimensions (pixels) 106,13%[?12l[?25h[?25l - 107  u_term_dim: GLint, 107,13%[?12l[?25h[?25l - 108  108,0-14%[?12l[?25h[?25l - 109  /// Cell dimensions (pixels) 109,14%[?12l[?25h[?25l - 110  u_cell_dim: GLint, 110,14%[?12l[?25h[?25l - 111  111,0-14%[?12l[?25h[?25l - 112  /// Visual bell 112,14%[?12l[?25h[?25l - 113  u_visual_bell: GLint, 113,14%[?12l[?25h[?25l - 114  114,0-14%[?12l[?25h[?25l - 115  /// Background pass flag 115,14%[?12l[?25h[?25l - 116  /// 116,14%[?12l[?25h[?25l - 117  /// Rendering is split into two passes; 1 for backgrounds, and one for text 117,14%[?12l[?25h[?25l - 118  u_background: GLint, 118,14%[?12l[?25h[?25l - 119  119,0-14%[?12l[?25h[?25l - 120  padding_x: f32, 120,14%[?12l[?25h[?25l - 121  padding_y: f32, 121,15%[?12l[?25h[?25l -{ 122 } 122,15%[?12l[?25h[?25l -{} - 123  123,0-15%[?12l[?25h[?25l - 124  124,0-15%[?12l[?25h[?25l - 125 #[derive(Debug, Clone)] 125,15%[?12l[?25h[?25l - 126 pub struct Glyph { 126,15%[?12l[?25h[?25l - 127  tex_id: GLuint, 127,15%[?12l[?25h[?25l - 128  top: f32, 128,15%[?12l[?25h[?25l - 129  left: f32, 129,15%[?12l[?25h[?25l - 130  width: f32, 130,15%[?12l[?25h[?25l - 131  height: f32, 131,15%[?12l[?25h[?25l - 132  uv_bot: f32, 132,15%[?12l[?25h[?25l - 133  uv_left: f32, 133,15%[?12l[?25h[?25l - 134  uv_width: f32, 134,16%[?12l[?25h[?25l - 135  uv_height: f32, 135,16%[?12l[?25h[?25l -{ 136 } 136,16%[?12l[?25h[?25l -{} - 137  137,0-16%[?12l[?25h[?25l - 138 /// Naïve glyph cache 138,16%[?12l[?25h[?25l - 139 /// 139,16%[?12l[?25h[?25l - 140 /// Currently only keyed by `char`, and thus not possible to hold different 140,16%[?12l[?25h[?25l - 141 /// representations of the same code point. 141,16%[?12l[?25h[?25l - 142 pub struct GlyphCache { 142,16%[?12l[?25h[?25l - 143  /// Cache of buffered glyphs 143,16%[?12l[?25h[?25l - 144  cache: HashMap<GlyphKey, Glyph, BuildHasherDefault<FnvHasher>>, 144,16%[?12l[?25h[?25l - 145  145,0-16%[?12l[?25h[?25l - 146  /// Rasterizer for loading new glyphs 146,16%[?12l[?25h[?25l - 147  rasterizer: Rasterizer, 147,17%[?12l[?25h[?25l - 148  148,0-17%[?12l[?25h[?25l - 149  /// regular font 149,17%[?12l[?25h[?25l - 150  font_key: FontKey, 150,17%[?12l[?25h[?25l - 151  151,0-17%[?12l[?25h[?25l - 152  /// italic font 152,17%[?12l[?25h[?25l - 153  italic_key: FontKey, 153,17%[?12l[?25h[?25l - 154  154,0-17%[?12l[?25h[?25l - 155  /// bold font 155,17%[?12l[?25h[?25l - 156  bold_key: FontKey, 156,17%[?12l[?25h[?25l - 157  157,0-17%[?12l[?25h[?25l - 158  /// font size 158,17%[?12l[?25h[?25l - 159  font_size: font::Size, 159,17%[?12l[?25h[?25l - 160  160,0-18%[?12l[?25h[?25l - 161  /// glyph offset 161,18%[?12l[?25h[?25l - 162  glyph_offset: Delta, 162,18%[?12l[?25h[?25l - 163  163,0-18%[?12l[?25h[?25l - 164  metrics: ::font::Metrics, 164,18%[?12l[?25h[?25l -{ 165 } 165,18%[?12l[?25h[?25l -{} - 166  166,0-18%[?12l[?25h[?25l - 167 impl GlyphCache { 167,18%[?12l[?25h[?25l - 168  pub fn new<L>( 168,18%[?12l[?25h[?25l - 169 mut rasterizer: Rasterizer, 169,18%[?12l[?25h[?25l - 170 config: &Config, 170,18%[?12l[?25h[?25l - 171 loader: &mut L 171,18%[?12l[?25h[?25l - 172  ) -> Result<GlyphCache, font::Error> 172,18%[?12l[?25h[?25l - 173 where L: LoadGlyph 173,19%[?12l[?25h[?25l - 174  { 174,19%[?12l[?25h[?25l - 175 let font = config.font(); 175,19%[?12l[?25h[?25l - 176 let size = font.size(); 176,19%[?12l[?25h[?25l - 177 let glyph_offset = *font.glyph_offset(); 177,19%[?12l[?25h[?25l - 178  178,0-19%[?12l[?25h[?25l - 179 fn make_desc( 179,19%[?12l[?25h[?25l - 180 desc: &config::FontDescription, 180,19%[?12l[?25h[?25l - 181 slant: font::Slant, 181,19%[?12l[?25h[?25l - 182 weight: font::Weight, 182,19%[?12l[?25h[?25l - 183 ) -> FontDesc 183,19%[?12l[?25h[?25l - 184 { 184,19%[?12l[?25h[?25l - 185 let style = if let Some(ref spec) = desc.style { 185,19%[?12l[?25h[?25l - 186 font::Style::Specific(spec.to_owned()) 186,110%[?12l[?25h[?25l - 187 } else { 187,110%[?12l[?25h[?25l - 188 font::Style::Description {slant:slant, weight:weight} 188,110%[?12l[?25h[?25l - 189 }; 189,110%[?12l[?25h[?25l - 190 FontDesc::new(&desc.family[..], style) 190,110%[?12l[?25h[?25l - 191 } 191,110%[?12l[?25h[?25l - 192  192,0-110%[?12l[?25h[?25l - 193 // Load regular font 193,110%[?12l[?25h[?25l - 194 let regular_desc = make_desc(&font.normal, font::Slant::Normal, font::Weight::Normal);  194,110%[?12l[?25h[?25l - 195  195,0-110%[?12l[?25h[?25l - 196 let regular = rasterizer 196,110%[?12l[?25h[?25l - 197 .load_font(&regular_desc, size)?; 197,110%[?12l[?25h[?25l - 198  198,0-110%[?12l[?25h[?25l - 199 // helper to load a description if it is not the regular_desc 199,111%[?12l[?25h[?25l - 200 let load_or_regular = |desc:FontDesc, rasterizer: &mut Rasterizer| { 200,111%[?12l[?25h[?25l - 201 if desc == regular_desc { 201,111%[?12l[?25h[?25l - 202 regular 202,111%[?12l[?25h[?25l - 203 } else { 203,111%[?12l[?25h[?25l - 204 rasterizer.load_font(&desc, size).unwrap_or_else(|_| regular) 204,111%[?12l[?25h[?25l - 205 } 205,111%[?12l[?25h[?25l - 206 }; 206,111%[?12l[?25h[?25l - 207  207,0-111%[?12l[?25h[?25l - 208 // Load bold font 208,111%[?12l[?25h[?25l - 209 let bold_desc = make_desc(&font.bold, font::Slant::Normal, font::Weight::Bold); 209,111%[?12l[?25h[?25l - 210  210,0-111%[?12l[?25h[?25l - 211 let bold = load_or_regular(bold_desc, &mut rasterizer); 211,111%[?12l[?25h[?25l - 212  212,0-112%[?12l[?25h[?25l - 213 // Load italic font 213,112%[?12l[?25h[?25l - 214 let italic_desc = make_desc(&font.italic, font::Slant::Italic, font::Weight::Normal); 214,112%[?12l[?25h[?25l - 215  215,0-112%[?12l[?25h[?25l - 216 let italic = load_or_regular(italic_desc, &mut rasterizer); 216,112%[?12l[?25h[?25l - 217  217,0-112%[?12l[?25h[?25l - 218 // Need to load at least one glyph for the face before calling metrics. 218,112%[?12l[?25h[?25l - 219 // The glyph requested here ('m' at the time of writing) has no special 219,112%[?12l[?25h[?25l - 220 // meaning. 220,112%[?12l[?25h[?25l - 221 rasterizer.get_glyph(&GlyphKey { font_key: regular, c: 'm', size: font.size() })?; 221,112%[?12l[?25h[?25l - 222 let metrics = rasterizer.metrics(regular)?; 222,112%[?12l[?25h[?25l - 223  223,0-112%[?12l[?25h[?25l - 224 let mut cache = GlyphCache { 224,112%[?12l[?25h[?25l - 225 cache: HashMap::default(), 225,113%[?12l[?25h[?25l - 226 rasterizer: rasterizer, 226,113%[?12l[?25h[?25l - 227 font_size: font.size(), 227,113%[?12l[?25h[?25l - 228 font_key: regular, 228,113%[?12l[?25h[?25l - 229 bold_key: bold, 229,113%[?12l[?25h[?25l - 230 italic_key: italic, 230,113%[?12l[?25h[?25l - 231 glyph_offset: glyph_offset, 231,113%[?12l[?25h[?25l - 232 metrics: metrics 232,113%[?12l[?25h[?25l - 233 }; 233,113%[?12l[?25h[?25l - 234  234,0-113%[?12l[?25h[?25l - 235 macro_rules! load_glyphs_for_font { 235,113%[?12l[?25h[?25l - 236 ($font:expr) => { 236,113%[?12l[?25h[?25l - 237 for i in RangeInclusive::new(32u8, 128u8) { 237,113%[?12l[?25h[?25l - 238 cache.get(&GlyphKey { 238,114%[?12l[?25h[?25l - 239 font_key: $font, 239,114%[?12l[?25h[?25l - 240 c: i as char, 240,114%[?12l[?25h[?25l - 241 size: font.size() 241,114%[?12l[?25h[?25l - 242 }, loader); 242,114%[?12l[?25h[?25l - 243 } 243,114%[?12l[?25h[?25l - 244 } 244,114%[?12l[?25h[?25l - 245 } 245,114%[?12l[?25h[?25l - 246  246,0-114%[?12l[?25h[?25l - 247 load_glyphs_for_font!(regular); 247,114%[?12l[?25h[?25l - 248 load_glyphs_for_font!(bold); 248,114%[?12l[?25h[?25l - 249 load_glyphs_for_font!(italic); 249,114%[?12l[?25h[?25l - 250  250,0-114%[?12l[?25h[?25l - 251 Ok(cache) 251,115%[?12l[?25h[?25l - 252  } 252,115%[?12l[?25h[?25l - 253  253,0-115%[?12l[?25h[?25l - 254  pub fn font_metrics(&self) -> font::Metrics { 254,115%[?12l[?25h[?25l - 255 self.rasterizer 255,115%[?12l[?25h[?25l - 256 .metrics(self.font_key) 256,115%[?12l[?25h[?25l - 257 .expect("metrics load since font is loaded at glyph cache creation") 257,115%[?12l[?25h[?25l - 258  } 258,115%[?12l[?25h[?25l - 259  259,0-115%[?12l[?25h[?25l - 260  pub fn get<'a, L>(&'a mut self, glyph_key: &GlyphKey, loader: &mut L) -> &'a Glyph 260,115%[?12l[?25h[?25l - 261 where L: LoadGlyph 261,115%[?12l[?25h[?25l - 262  { 262,115%[?12l[?25h[?25l - 263 let glyph_offset = self.glyph_offset; 263,115%[?12l[?25h[?25l - 264 let rasterizer = &mut self.rasterizer; 264,116%[?12l[?25h[?25l - 265 let metrics = &self.metrics; 265,116%[?12l[?25h[?25l - 266 self.cache 266,116%[?12l[?25h[?25l - 267 .entry(*glyph_key) 267,116%[?12l[?25h[?25l - 268 .or_insert_with(|| { 268,116%[?12l[?25h[?25l - 269 let mut rasterized = rasterizer.get_glyph(&glyph_key) 269,116%[?12l[?25h[?25l - 270 .unwrap_or_else(|_| Default::default()); 270,116%[?12l[?25h[?25l - 271  271,0-116%[?12l[?25h[?25l - 272 rasterized.left += glyph_offset.x as i32; 272,116%[?12l[?25h[?25l - 273 rasterized.top += glyph_offset.y as i32; 273,116%[?12l[?25h[?25l - 274 rasterized.top -= metrics.descent as i32; 274,116%[?12l[?25h[?25l - 275  275,0-116%[?12l[?25h[?25l - 276 loader.load_glyph(&rasterized) 276,116%[?12l[?25h[?25l - 277 }) 277,117%[?12l[?25h[?25l - 278  } 278,117%[?12l[?25h[?25l - 279 } 279,117%[?12l[?25h[?25l - 280  280,0-117%[?12l[?25h[?25l - 281 #[derive(Debug)] 281,117%[?12l[?25h[?25l - 282 #[repr(C)] 282,117%[?12l[?25h[?25l - 283 struct InstanceData { 283,117%[?12l[?25h[?25l - 284  // coords 284,117%[?12l[?25h[?25l - 285  col: f32, 285,117%[?12l[?25h[?25l - 286  row: f32, 286,117%[?12l[?25h[?25l - 287  // glyph offset 287,117%[?12l[?25h[?25l - 288  left: f32, 288,117%[?12l[?25h[?25l - 289  top: f32, 289,117%[?12l[?25h[?25l - 290  // glyph scale 290,118%[?12l[?25h[?25l - 291  width: f32, 291,118%[?12l[?25h[?25l - 292  height: f32, 292,118%[?12l[?25h[?25l - 293  // uv offset 293,118%[?12l[?25h[?25l - 294  uv_left: f32, 294,118%[?12l[?25h[?25l - 295  uv_bot: f32, 295,118%[?12l[?25h[?25l - 296  // uv scale 296,118%[?12l[?25h[?25l - 297  uv_width: f32, 297,118%[?12l[?25h[?25l - 298  uv_height: f32, 298,118%[?12l[?25h[?25l - 299  // color 299,118%[?12l[?25h[?25l - 300  r: f32, 300,118%[?12l[?25h[?25l - 301  g: f32, 301,118%[?12l[?25h[?25l - 302  b: f32, 302,118%[?12l[?25h[?25l - 303  // background color 303,119%[?12l[?25h[?25l - 304  bg_r: f32, 304,119%[?12l[?25h[?25l - 305  bg_g: f32, 305,119%[?12l[?25h[?25l - 306  bg_b: f32, 306,119%[?12l[?25h[?25l -{ 307 } 307,119%[?12l[?25h[?25l -{} - 308  308,0-119%[?12l[?25h[?25l - 309 #[derive(Debug)] 309,119%[?12l[?25h[?25l - 310 pub struct QuadRenderer { 310,119%[?12l[?25h[?25l - 311  program: ShaderProgram, 311,119%[?12l[?25h[?25l - 312  vao: GLuint, 312,119%[?12l[?25h[?25l - 313  vbo: GLuint, 313,119%[?12l[?25h[?25l - 314  ebo: GLuint, 314,119%[?12l[?25h[?25l - 315  vbo_instance: GLuint, 315,119%[?12l[?25h[?25l - 316  atlas: Vec<Atlas>, 316,120%[?12l[?25h[?25l - 317  active_tex: GLuint, 317,120%[?12l[?25h[?25l - 318  batch: Batch, 318,120%[?12l[?25h[?25l - 319  rx: mpsc::Receiver<Msg>, 319,120%[?12l[?25h[?25l -{ 320 } 320,120%[?12l[?25h[?25l -{} - 321  321,0-120%[?12l[?25h[?25l - 322 #[derive(Debug)] 322,120%[?12l[?25h[?25l - 323 pub struct RenderApi<'a> { 323,120%[?12l[?25h[?25l - 324  active_tex: &'a mut GLuint, 324,120%[?12l[?25h[?25l - 325  batch: &'a mut Batch, 325,120%[?12l[?25h[?25l - 326  atlas: &'a mut Vec<Atlas>, 326,120%[?12l[?25h[?25l - 327  program: &'a mut ShaderProgram, 327,120%[?12l[?25h[?25l - 328  config: &'a Config, 328,120%[?12l[?25h[?25l - 329  visual_bell_intensity: f32 329,121%[?12l[?25h[?25l -{ 330 } 330,121%[?12l[?25h[?25l -{} - 331  331,0-121%[?12l[?25h[?25l - 332 #[derive(Debug)] 332,121%[?12l[?25h[?25l - 333 pub struct LoaderApi<'a> { 333,121%[?12l[?25h[?25l - 334  active_tex: &'a mut GLuint, 334,121%[?12l[?25h[?25l - 335  atlas: &'a mut Vec<Atlas>, 335,121%[?12l[?25h[?25l -{ - - - 336 } 336,121%[?12l[?25h[?25l -{} - 337  337,0-121%[?12l[?25h[?25l - 338 #[derive(Debug)] 338,121%[?12l[?25h[?25l - 339 pub struct PackedVertex { 339,121%[?12l[?25h[?25l - 340  x: f32, 340,121%[?12l[?25h[?25l - 341  y: f32, 341,121%[?12l[?25h[?25l -{ - - - 342 } 342,122%[?12l[?25h[?25l -{} - 343  343,0-122%[?12l[?25h[?25l - 344 #[derive(Debug)] 344,122%[?12l[?25h[?25l - 345 pub struct Batch { 345,122%[?12l[?25h[?25l - 346  tex: GLuint, 346,122%[?12l[?25h[?25l - 347  instances: Vec<InstanceData>, 347,122%[?12l[?25h[?25l -{ - - - 348 } 348,122%[?12l[?25h[?25l -{} - 349  349,0-122%[?12l[?25h[?25l - 350 impl Batch { 350,122%[?12l[?25h[?25l - 351  #[inline] 351,122%[?12l[?25h[?25l - 352  pub fn new() -> Batch { 352,122%[?12l[?25h[?25l - 353 Batch { 353,122%[?12l[?25h[?25l - 354 tex: 0, 354,122%[?12l[?25h[?25l - 355 instances: Vec::with_capacity(BATCH_MAX), 355,123%[?12l[?25h[?25l - 356 } 356,123%[?12l[?25h[?25l - 357  } 357,123%[?12l[?25h[?25l - 358  358,0-123%[?12l[?25h[?25l - 359  pub fn add_item( 359,123%[?12l[?25h[?25l - 360 &mut self, 360,123%[?12l[?25h[?25l - 361 cell: &RenderableCell, 361,123%[?12l[?25h[?25l - 362 glyph: &Glyph, 362,123%[?12l[?25h[?25l - 363  ) { 363,123%[?12l[?25h[?25l - 364 if self.is_empty() { 364,123%[?12l[?25h[?25l - 365 self.tex = glyph.tex_id; 365,123%[?12l[?25h[?25l - 366 } 366,123%[?12l[?25h[?25l - 367  367,0-123%[?12l[?25h[?25l - 368 self.instances.push(InstanceData { 368,124%[?12l[?25h[?25l - 369 col: cell.column.0 as f32, 369,124%[?12l[?25h[?25l - 370 row: cell.line.0 as f32, 370,124%[?12l[?25h[?25l - 371  371,0-124%[?12l[?25h[?25l - 372 top: glyph.top, 372,124%[?12l[?25h[?25l - 373 left: glyph.left, 373,124%[?12l[?25h[?25l - 374 width: glyph.width, 374,124%[?12l[?25h[?25l - 375 height: glyph.height, 375,124%[?12l[?25h[?25l - 376  376,0-124%[?12l[?25h[?25l - 377 uv_bot: glyph.uv_bot, 377,124%[?12l[?25h[?25l - 378 uv_left: glyph.uv_left, 378,124%[?12l[?25h[?25l - 379 uv_width: glyph.uv_width, 379,124%[?12l[?25h[?25l - 380 uv_height: glyph.uv_height, 380,124%[?12l[?25h[?25l - 381  381,0-125%[?12l[?25h[?25l - 382 r: cell.fg.r as f32, 382,125%[?12l[?25h[?25l - 383 g: cell.fg.g as f32, 383,125%[?12l[?25h[?25l - 384 b: cell.fg.b as f32, 384,125%[?12l[?25h[?25l - 385  385,0-125%[?12l[?25h[?25l - 386 bg_r: cell.bg.r as f32, 386,125%[?12l[?25h[?25l - 387 bg_g: cell.bg.g as f32, 387,125%[?12l[?25h[?25l - 388 bg_b: cell.bg.b as f32, 388,125%[?12l[?25h[?25l - 389 }); 389,125%[?12l[?25h[?25l - 390  } 390,125%[?12l[?25h[?25l - 391  391,0-125%[?12l[?25h[?25l - 392  #[inline] 392,125%[?12l[?25h[?25l - 393  pub fn full(&self) -> bool { 393,125%[?12l[?25h[?25l - 394 self.capacity() == self.len() 394,126%[?12l[?25h[?25l - 395  } 395,126%[?12l[?25h[?25l - 396  396,0-126%[?12l[?25h[?25l - 397  #[inline] 397,126%[?12l[?25h[?25l - 398  pub fn len(&self) -> usize { 398,126%[?12l[?25h[?25l - 399 self.instances.len() 399,126%[?12l[?25h[?25l - 400  } 400,126%[?12l[?25h[?25l - 401  401,0-126%[?12l[?25h[?25l - 402  #[inline] 402,126%[?12l[?25h[?25l - 403  pub fn capacity(&self) -> usize { 403,126%[?12l[?25h[?25l - 404 BATCH_MAX 404,126%[?12l[?25h[?25l - 405  } 405,126%[?12l[?25h[?25l - 406  406,0-126%[?12l[?25h[?25l - 407  #[inline] 407,127%[?12l[?25h[?25l - 408  pub fn is_empty(&self) -> bool { 408,127%[?12l[?25h[?25l - 409 self.len() == 0 409,127%[?12l[?25h[?25l - 410  } 410,127%[?12l[?25h[?25l - 411  411,0-127%[?12l[?25h[?25l - 412  #[inline] 412,127%[?12l[?25h[?25l - 413  pub fn size(&self) -> usize { 413,127%[?12l[?25h[?25l - 414 self.len() * size_of::<InstanceData>() 414,127%[?12l[?25h[?25l - 415  } 415,127%[?12l[?25h[?25l - 416  416,0-127%[?12l[?25h[?25l - 417  pub fn clear(&mut self) { 417,127%[?12l[?25h[?25l - 418 self.tex = 0; 418,127%[?12l[?25h[?25l - 419 self.instances.clear(); 419,127%[?12l[?25h[?25l - 420  } 420,128%[?12l[?25h[?25l - 421 } 421,128%[?12l[?25h[?25l - 422  422,0-128%[?12l[?25h[?25l - 423 /// Maximum items to be drawn in a batch. 423,128%[?12l[?25h[?25l - 424 const BATCH_MAX: usize = 65_536; 424,128%[?12l[?25h[?25l - 425 const ATLAS_SIZE: i32 = 1024; 425,128%[?12l[?25h[?25l - 426  426,0-128%[?12l[?25h[?25l - 427 impl QuadRenderer { 427,128%[?12l[?25h[?25l - 428  // TODO should probably hand this a transform instead of width/height 428,128%[?12l[?25h[?25l - 429  pub fn new(config: &Config, size: Size<Pixels<u32>>) -> Result<QuadRenderer, Error> { 429,128%[?12l[?25h[?25l - 430 let program = ShaderProgram::new(config, size)?; 430,128%[?12l[?25h[?25l - 431  431,0-128%[?12l[?25h[?25l - 432 let mut vao: GLuint = 0; 432,128%[?12l[?25h[?25l - 433 let mut vbo: GLuint = 0; 433,129%[?12l[?25h[?25l - 434 let mut ebo: GLuint = 0; 434,129%[?12l[?25h[?25l - 435  435,0-129%[?12l[?25h[?25l - 436 let mut vbo_instance: GLuint = 0; 436,129%[?12l[?25h[?25l - 437  437,0-129%[?12l[?25h[?25l - 438 unsafe { 438,129%[?12l[?25h[?25l - 439 gl::Enable(gl::BLEND); 439,129%[?12l[?25h[?25l - 440 gl::BlendFunc(gl::SRC1_COLOR, gl::ONE_MINUS_SRC1_COLOR); 440,129%[?12l[?25h[?25l - 441 gl::Enable(gl::MULTISAMPLE); 441,129%[?12l[?25h[?25l - 442  442,0-129%[?12l[?25h[?25l - 443 gl::GenVertexArrays(1, &mut vao); 443,129%[?12l[?25h[?25l - 444 gl::GenBuffers(1, &mut vbo); 444,129%[?12l[?25h[?25l - 445 gl::GenBuffers(1, &mut ebo); 445,129%[?12l[?25h[?25l - 446 gl::GenBuffers(1, &mut vbo_instance); 446,130%[?12l[?25h[?25l - 447 gl::BindVertexArray(vao); 447,130%[?12l[?25h[?25l - 448  448,0-130%[?12l[?25h[?25l - 449 // ---------------------------- 449,130%[?12l[?25h[?25l - 450 // setup vertex position buffer 450,130%[?12l[?25h[?25l - 451 // ---------------------------- 451,130%[?12l[?25h[?25l - 452 // Top right, Bottom right, Bottom left, Top left 452,130%[?12l[?25h[?25l - 453 let vertices = [ 453,130%[?12l[?25h[?25l - 454 PackedVertex { x: 1.0, y: 1.0 }, 454,130%[?12l[?25h[?25l - 455 PackedVertex { x: 1.0, y: 0.0 }, 455,130%[?12l[?25h[?25l - 456 PackedVertex { x: 0.0, y: 0.0 }, 456,130%[?12l[?25h[?25l - 457 PackedVertex { x: 0.0, y: 1.0 }, 457,130%[?12l[?25h[?25l - 458 ]; 458,130%[?12l[?25h[?25l - 459  459,0-131%[?12l[?25h[?25l - 460 gl::BindBuffer(gl::ARRAY_BUFFER, vbo); 460,131%[?12l[?25h[?25l - 461  461,0-131%[?12l[?25h[?25l - 462 gl::VertexAttribPointer(0, 2, 462,131%[?12l[?25h[?25l - 463 gl::FLOAT, gl::FALSE, 463,131%[?12l[?25h[?25l - 464 size_of::<PackedVertex>() as i32, 464,131%[?12l[?25h[?25l - 465 ptr::null()); 465,131%[?12l[?25h[?25l - 466 gl::EnableVertexAttribArray(0); 466,131%[?12l[?25h[?25l - 467  467,0-131%[?12l[?25h[?25l - 468 gl::BufferData(gl::ARRAY_BUFFER, 468,131%[?12l[?25h[?25l - 469 (size_of::<PackedVertex>() * vertices.len()) as GLsizeiptr, 469,131%[?12l[?25h[?25l - 470 vertices.as_ptr() as *const _, 470,131%[?12l[?25h[?25l - 471 gl::STATIC_DRAW); 471,131%[?12l[?25h[?25l - 472  472,0-132%[?12l[?25h[?25l - 473 // --------------------- 473,132%[?12l[?25h[?25l - 474 // Set up element buffer 474,132%[?12l[?25h[?25l - 475 // --------------------- 475,132%[?12l[?25h[?25l - 476 let indices: [u32; 6] = [0, 1, 3, 476,132%[?12l[?25h[?25l - 477 1, 2, 3]; 477,132%[?12l[?25h[?25l - 478  478,0-132%[?12l[?25h[?25l - 479 gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, ebo); 479,132%[?12l[?25h[?25l - 480 gl::BufferData(gl::ELEMENT_ARRAY_BUFFER, 480,132%[?12l[?25h[?25l - 481 (6 * size_of::<u32>()) as isize, 481,132%[?12l[?25h[?25l - 482 indices.as_ptr() as *const _, 482,132%[?12l[?25h[?25l - 483 gl::STATIC_DRAW); 483,132%[?12l[?25h[?25l - 484  484,0-132%[?12l[?25h[?25l - 485 // ---------------------------- 485,133%[?12l[?25h[?25l - 486 // Setup vertex instance buffer 486,133%[?12l[?25h[?25l - 487 // ---------------------------- 487,133%[?12l[?25h[?25l - 488 gl::BindBuffer(gl::ARRAY_BUFFER, vbo_instance); 488,133%[?12l[?25h[?25l - 489 gl::BufferData(gl::ARRAY_BUFFER, 489,133%[?12l[?25h[?25l - 490 (BATCH_MAX * size_of::<InstanceData>()) as isize, 490,133%[?12l[?25h[?25l - 491 ptr::null(), gl::STREAM_DRAW); 491,133%[?12l[?25h[?25l - 492 // coords 492,133%[?12l[?25h[?25l - 493 gl::VertexAttribPointer(1, 2, 493,133%[?12l[?25h[?25l - 494 gl::FLOAT, gl::FALSE, 494,133%[?12l[?25h[?25l - 495 size_of::<InstanceData>() as i32, 495,133%[?12l[?25h[?25l - 496 ptr::null()); 496,133%[?12l[?25h[?25l - 497 gl::EnableVertexAttribArray(1); 497,133%[?12l[?25h[?25l - 498 gl::VertexAttribDivisor(1, 1); 498,134%[?12l[?25h[?25l - 499 // glyphoffset 499,134%[?12l[?25h[?25l - 500 gl::VertexAttribPointer(2, 4, 500,134%[?12l[?25h[?25l - 501 gl::FLOAT, gl::FALSE, 501,134%[?12l[?25h[?25l - 502 size_of::<InstanceData>() as i32, 502,134%[?12l[?25h[?25l - 503 (2 * size_of::<f32>()) as *const _); 503,134%[?12l[?25h[?25l - 504 gl::EnableVertexAttribArray(2); 504,134%[?12l[?25h[?25l - 505 gl::VertexAttribDivisor(2, 1); 505,134%[?12l[?25h[?25l - 506 // uv 506,134%[?12l[?25h[?25l - 507 gl::VertexAttribPointer(3, 4, 507,134%[?12l[?25h[?25l - 508 gl::FLOAT, gl::FALSE, 508,134%[?12l[?25h[?25l - 509 size_of::<InstanceData>() as i32, 509,134%[?12l[?25h[?25l - 510 (6 * size_of::<f32>()) as *const _); 510,134%[?12l[?25h[?25l - 511 gl::EnableVertexAttribArray(3); 511,135%[?12l[?25h[?25l - 512 gl::VertexAttribDivisor(3, 1); 512,135%[?12l[?25h[?25l - 513 // color 513,135%[?12l[?25h[?25l - 514 gl::VertexAttribPointer(4, 3, 514,135%[?12l[?25h[?25l - 515 gl::FLOAT, gl::FALSE, 515,135%[?12l[?25h[?25l - 516 size_of::<InstanceData>() as i32, 516,135%[?12l[?25h[?25l - 517 (10 * size_of::<f32>()) as *const _); 517,135%[?12l[?25h[?25l - 518 gl::EnableVertexAttribArray(4); 518,135%[?12l[?25h[?25l - 519 gl::VertexAttribDivisor(4, 1); 519,135%[?12l[?25h[?25l - 520 // color 520,135%[?12l[?25h[?25l - 521 gl::VertexAttribPointer(5, 3, 521,135%[?12l[?25h[?25l - 522 gl::FLOAT, gl::FALSE, 522,135%[?12l[?25h[?25l - 523 size_of::<InstanceData>() as i32, 523,135%[?12l[?25h[?25l - 524 (13 * size_of::<f32>()) as *const _); 524,136%[?12l[?25h[?25l - 525 gl::EnableVertexAttribArray(5); 525,136%[?12l[?25h[?25l - 526 gl::VertexAttribDivisor(5, 1); 526,136%[?12l[?25h[?25l - 527  527,0-136%[?12l[?25h[?25l - 528 gl::BindVertexArray(0); 528,136%[?12l[?25h[?25l - 529 gl::BindBuffer(gl::ARRAY_BUFFER, 0); 529,136%[?12l[?25h[?25l - 530 } 530,136%[?12l[?25h[?25l - 531  531,0-136%[?12l[?25h[?25l - 532 let (msg_tx, msg_rx) = mpsc::channel(); 532,136%[?12l[?25h[?25l - 533  533,0-136%[?12l[?25h[?25l - 534 if cfg!(feature = "live-shader-reload") { 534,136%[?12l[?25h[?25l - 535 ::std::thread::spawn(move || { 535,136%[?12l[?25h[?25l - 536 let (tx, rx) = ::std::sync::mpsc::channel(); 536,136%[?12l[?25h[?25l - 537 let mut watcher = Watcher::new(tx).expect("create file watcher"); 537,137%[?12l[?25h[?25l - 538 watcher.watch(TEXT_SHADER_F_PATH).expect("watch fragment shader"); 538,137%[?12l[?25h[?25l - 539 watcher.watch(TEXT_SHADER_V_PATH).expect("watch vertex shader"); 539,137%[?12l[?25h[?25l - 540  540,0-137%[?12l[?25h[?25l - 541 loop { 541,137%[?12l[?25h[?25l - 542 let event = rx.recv().expect("watcher event"); 542,137%[?12l[?25h[?25l - 543 let ::notify::Event { path, op } = event; 543,137%[?12l[?25h[?25l - 544  544,0-137%[?12l[?25h[?25l - 545 if let Ok(op) = op { 545,137%[?12l[?25h[?25l - 546 if op.contains(op::RENAME) { 546,137%[?12l[?25h[?25l - 547 continue; 547,137%[?12l[?25h[?25l - 548 } 548,137%[?12l[?25h[?25l - 549  549,0-137%[?12l[?25h[?25l - 550 if op.contains(op::IGNORED) { 550,138%[?12l[?25h[?25l - 551 if let Some(path) = path.as_ref() { 551,138%[?12l[?25h[?25l - 552 if let Err(err) = watcher.watch(path) { 552,138%[?12l[?25h[?25l - 553 warn!("failed to establish watch on {:?}: {:?}", path, err);  553,138%[?12l[?25h[?25l - 554 } 554,138%[?12l[?25h[?25l - 555 } 555,138%[?12l[?25h[?25l - 556  556,0-138%[?12l[?25h[?25l - 557 msg_tx.send(Msg::ShaderReload) 557,138%[?12l[?25h[?25l - 558 .expect("msg send ok"); 558,138%[?12l[?25h[?25l - 559 } 559,138%[?12l[?25h[?25l - 560 } 560,138%[?12l[?25h[?25l - 561 } 561,138%[?12l[?25h[?25l - 562 }); 562,138%[?12l[?25h[?25l - 563 } 563,139%[?12l[?25h[?25l - 564  564,0-139%[?12l[?25h[?25l - 565 let mut renderer = QuadRenderer { 565,139%[?12l[?25h[?25l - 566 program: program, 566,139%[?12l[?25h[?25l - 567 vao: vao, 567,139%[?12l[?25h[?25l - 568 vbo: vbo, 568,139%[?12l[?25h[?25l - 569 ebo: ebo, 569,139%[?12l[?25h[?25l - 570 vbo_instance: vbo_instance, 570,139%[?12l[?25h[?25l - 571 atlas: Vec::new(), 571,139%[?12l[?25h[?25l - 572 active_tex: 0, 572,139%[?12l[?25h[?25l - 573 batch: Batch::new(), 573,139%[?12l[?25h[?25l - 574 rx: msg_rx, 574,139%[?12l[?25h[?25l - 575 }; 575,139%[?12l[?25h[?25l - 576  576,0-140%[?12l[?25h[?25l - 577 let atlas = Atlas::new(ATLAS_SIZE); 577,140%[?12l[?25h[?25l - 578 renderer.atlas.push(atlas); 578,140%[?12l[?25h[?25l - 579  579,0-140%[?12l[?25h[?25l - 580 Ok(renderer) 580,140%[?12l[?25h[?25l - 581  } 581,140%[?12l[?25h[?25l - 582  582,0-140%[?12l[?25h[?25l - 583  pub fn with_api<F, T>( 583,140%[?12l[?25h[?25l - 584 &mut self, 584,140%[?12l[?25h[?25l - 585 config: &Config, 585,140%[?12l[?25h[?25l - 586 props: &term::SizeInfo, 586,140%[?12l[?25h[?25l - 587 visual_bell_intensity: f64, 587,140%[?12l[?25h[?25l - 588 func: F 588,140%[?12l[?25h[?25l - 589  ) -> T 589,141%[?12l[?25h[?25l - 590 where F: FnOnce(RenderApi) -> T 590,141%[?12l[?25h[?25l - 591  { 591,141%[?12l[?25h[?25l - 592 while let Ok(msg) = self.rx.try_recv() { 592,141%[?12l[?25h[?25l - 593 match msg { 593,141%[?12l[?25h[?25l - 594 Msg::ShaderReload => { 594,141%[?12l[?25h[?25l - 595 self.reload_shaders(&config, Size { 595,141%[?12l[?25h[?25l - 596 width: Pixels(props.width as u32), 596,141%[?12l[?25h[?25l - 597 height: Pixels(props.height as u32) 597,141%[?12l[?25h[?25l - 598 }); 598,141%[?12l[?25h[?25l - 599 } 599,141%[?12l[?25h[?25l - 600 } 600,141%[?12l[?25h[?25l - 601 } 601,141%[?12l[?25h[?25l - 602  602,0-142%[?12l[?25h[?25l - 603 unsafe { 603,142%[?12l[?25h[?25l - 604 self.program.activate(); 604,142%[?12l[?25h[?25l - 605 self.program.set_term_uniforms(props); 605,142%[?12l[?25h[?25l - 606 self.program.set_visual_bell(visual_bell_intensity as _); 606,142%[?12l[?25h[?25l - 607  607,0-142%[?12l[?25h[?25l - 608 gl::BindVertexArray(self.vao); 608,142%[?12l[?25h[?25l - 609 gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, self.ebo); 609,142%[?12l[?25h[?25l - 610 gl::BindBuffer(gl::ARRAY_BUFFER, self.vbo_instance); 610,142%[?12l[?25h[?25l - 611 gl::ActiveTexture(gl::TEXTURE0); 611,142%[?12l[?25h[?25l - 612 } 612,142%[?12l[?25h[?25l - 613  613,0-142%[?12l[?25h[?25l - 614 let res = func(RenderApi { 614,142%[?12l[?25h[?25l - 615 active_tex: &mut self.active_tex, 615,143%[?12l[?25h[?25l - 616 batch: &mut self.batch, 616,143%[?12l[?25h[?25l - 617 atlas: &mut self.atlas, 617,143%[?12l[?25h[?25l - 618 program: &mut self.program, 618,143%[?12l[?25h[?25l - 619 visual_bell_intensity: visual_bell_intensity as _, 619,143%[?12l[?25h[?25l - 620 config: config, 620,143%[?12l[?25h[?25l - 621 }); 621,143%[?12l[?25h[?25l - 622  622,0-143%[?12l[?25h[?25l - 623 unsafe { 623,143%[?12l[?25h[?25l - 624 gl::BindBuffer(gl::ELEMENT_ARRAY_BUFFER, 0); 624,143%[?12l[?25h[?25l - 625 gl::BindBuffer(gl::ARRAY_BUFFER, 0); 625,143%[?12l[?25h[?25l - 626 gl::BindVertexArray(0); 626,143%[?12l[?25h[?25l - 627  627,0-143%[?12l[?25h[?25l - 628 self.program.deactivate(); 628,144%[?12l[?25h[?25l - 629 } 629,144%[?12l[?25h[?25l - 630  630,0-144%[?12l[?25h[?25l - 631 res 631,144%[?12l[?25h[?25l - 632  } 632,144%[?12l[?25h[?25l - 633  633,0-144%[?12l[?25h[?25l - 634  pub fn with_loader<F, T>(&mut self, func: F) -> T 634,144%[?12l[?25h[?25l - 635 where F: FnOnce(LoaderApi) -> T 635,144%[?12l[?25h[?25l - 636  { 636,144%[?12l[?25h[?25l - 637 unsafe { 637,144%[?12l[?25h[?25l - 638 gl::ActiveTexture(gl::TEXTURE0); 638,144%[?12l[?25h[?25l - 639 } 639,144%[?12l[?25h[?25l - 640  640,0-144%[?12l[?25h[?25l - 641 func(LoaderApi { 641,145%[?12l[?25h[?25l - 642 active_tex: &mut self.active_tex, 642,145%[?12l[?25h[?25l - 643 atlas: &mut self.atlas, 643,145%[?12l[?25h[?25l - 644 }) 644,145%[?12l[?25h[?25l - 645  } 645,145%[?12l[?25h[?25l - 646  646,0-145%[?12l[?25h[?25l - 647  pub fn reload_shaders(&mut self, config: &Config, size: Size<Pixels<u32>>) { 647,145%[?12l[?25h[?25l - 648 info!("Reloading shaders"); 648,145%[?12l[?25h[?25l - 649 let program = match ShaderProgram::new(config, size) { 649,145%[?12l[?25h[?25l - 650 Ok(program) => program, 650,145%[?12l[?25h[?25l - 651 Err(err) => { 651,145%[?12l[?25h[?25l - 652 match err { 652,145%[?12l[?25h[?25l - 653 ShaderCreationError::Io(err) => { 653,145%[?12l[?25h[?25l - 654 error!("Error reading shader file: {}", err); 654,146%[?12l[?25h[?25l - 655 }, 655,146%[?12l[?25h[?25l - 656 ShaderCreationError::Compile(path, log) => { 656,146%[?12l[?25h[?25l - 657 error!("Error compiling shader at {:?}", path); 657,146%[?12l[?25h[?25l - 658 let _ = io::copy(&mut log.as_bytes(), &mut io::stdout()); 658,146%[?12l[?25h[?25l - 659 } 659,146%[?12l[?25h[?25l - 660 } 660,146%[?12l[?25h[?25l - 661  661,0-146%[?12l[?25h[?25l - 662 return; 662,146%[?12l[?25h[?25l - 663 } 663,146%[?12l[?25h[?25l - 664 }; 664,146%[?12l[?25h[?25l - 665  665,0-146%[?12l[?25h[?25l - 666 self.active_tex = 0; 666,146%[?12l[?25h[?25l - 667 self.program = program; 667,147%[?12l[?25h[?25l - 668  } 668,147%[?12l[?25h[?25l - 669  669,0-147%[?12l[?25h[?25l - 670  pub fn resize(&mut self, width: i32, height: i32) { 670,147%[?12l[?25h[?25l - 671 let padding_x = self.program.padding_x as i32; 671,147%[?12l[?25h[?25l - 672 let padding_y = self.program.padding_y as i32; 672,147%[?12l[?25h[?25l - 673  673,0-147%[?12l[?25h[?25l - 674 // viewport 674,147%[?12l[?25h[?25l - 675 unsafe { 675,147%[?12l[?25h[?25l - 676 gl::Viewport(padding_x, padding_y, width - 2 * padding_x, height - 2 * padding_y);  676,147%[?12l[?25h[?25l - 677 } 677,147%[?12l[?25h[?25l - 678  678,0-147%[?12l[?25h[?25l - 679 // update projection 679,147%[?12l[?25h[?25l - 680 self.program.activate(); 680,148%[?12l[?25h[?25l - 681 self.program.update_projection(width as f32, height as f32); 681,148%[?12l[?25h[?25l - 682 self.program.deactivate(); 682,148%[?12l[?25h[?25l - 683  } 683,148%[?12l[?25h[?25l - 684 } 684,148%[?12l[?25h[?25l - 685  685,0-148%[?12l[?25h[?25l - 686 impl<'a> RenderApi<'a> { 686,148%[?12l[?25h[?25l - 687  pub fn clear(&self, color: Rgb) { 687,148%[?12l[?25h[?25l - 688 unsafe { 688,148%[?12l[?25h[?25l - 689 gl::ClearColor( 689,148%[?12l[?25h[?25l - 690 (self.visual_bell_intensity + color.r as f32 / 255.0).min(1.0), 690,148%[?12l[?25h[?25l - 691 (self.visual_bell_intensity + color.g as f32 / 255.0).min(1.0), 691,148%[?12l[?25h[?25l - 692 (self.visual_bell_intensity + color.b as f32 / 255.0).min(1.0), 692,148%[?12l[?25h[?25l - 693 1.0 693,149%[?12l[?25h[?25l - 694 ); 694,149%[?12l[?25h[?25l - 695 gl::Clear(gl::COLOR_BUFFER_BIT); 695,149%[?12l[?25h[?25l - 696 } 696,149%[?12l[?25h[?25l - 697  } 697,149%[?12l[?25h[?25l - 698  698,0-149%[?12l[?25h[?25l - 699  fn render_batch(&mut self) { 699,149%[?12l[?25h[?25l - 700 unsafe { 700,149%[?12l[?25h[?25l - 701 gl::BufferSubData(gl::ARRAY_BUFFER, 0, self.batch.size() as isize, 701,149%[?12l[?25h[?25l - 702 self.batch.instances.as_ptr() as *const _); 702,149%[?12l[?25h[?25l - 703 } 703,149%[?12l[?25h[?25l - 704  704,0-149%[?12l[?25h[?25l - 705 // Bind texture if necessary 705,150%[?12l[?25h[?25l - 706 if *self.active_tex != self.batch.tex { 706,150%[?12l[?25h[?25l - 707 unsafe { 707,150%[?12l[?25h[?25l - 708 gl::BindTexture(gl::TEXTURE_2D, self.batch.tex); 708,150%[?12l[?25h[?25l - 709 } 709,150%[?12l[?25h[?25l - 710 *self.active_tex = self.batch.tex; 710,150%[?12l[?25h[?25l - 711 } 711,150%[?12l[?25h[?25l - 712  712,0-150%[?12l[?25h[?25l - 713 unsafe { 713,150%[?12l[?25h[?25l - 714 self.program.set_background_pass(true); 714,150%[?12l[?25h[?25l - 715 gl::DrawElementsInstanced(gl::TRIANGLES, 715,150%[?12l[?25h[?25l - 716 6, gl::UNSIGNED_INT, ptr::null(), 716,150%[?12l[?25h[?25l - 717 self.batch.len() as GLsizei); 717,150%[?12l[?25h[?25l - 718 self.program.set_background_pass(false); 718,151%[?12l[?25h[?25l - 719 gl::DrawElementsInstanced(gl::TRIANGLES, 719,151%[?12l[?25h[?25l - 720 6, gl::UNSIGNED_INT, ptr::null(), 720,151%[?12l[?25h[?25l - 721 self.batch.len() as GLsizei); 721,151%[?12l[?25h[?25l - 722 } 722,151%[?12l[?25h[?25l - 723  723,0-151%[?12l[?25h[?25l - 724 self.batch.clear(); 724,151%[?12l[?25h[?25l - 725  } 725,151%[?12l[?25h[?25l - 726  /// Render a string in a predefined location. Used for printing render time for profiling and  726,151%[?12l[?25h[?25l - 727  /// optimization. 727,151%[?12l[?25h[?25l - 728  pub fn render_string( 728,151%[?12l[?25h[?25l - 729 &mut self, 729,151%[?12l[?25h[?25l - 730 string: &str, 730,151%[?12l[?25h[?25l - 731 glyph_cache: &mut GlyphCache, 731,152%[?12l[?25h[?25l - 732 color: Rgb, 732,152%[?12l[?25h[?25l - 733  ) { 733,152%[?12l[?25h[?25l - 734 let line = Line(23); 734,152%[?12l[?25h[?25l - 735 let col = Column(0); 735,152%[?12l[?25h[?25l - 736  736,0-152%[?12l[?25h[?25l - 737 let cells = string.chars() 737,152%[?12l[?25h[?25l - 738 .enumerate() 738,152%[?12l[?25h[?25l - 739 .map(|(i, c)| RenderableCell { 739,152%[?12l[?25h[?25l - 740 line: line, 740,152%[?12l[?25h[?25l - 741 column: col + i, 741,152%[?12l[?25h[?25l - 742 c: c, 742,152%[?12l[?25h[?25l - 743 bg: color, 743,152%[?12l[?25h[?25l - 744 fg: Rgb { r: 0, g: 0, b: 0 }, 744,153%[?12l[?25h[?25l - 745 flags: cell::Flags::empty(), 745,153%[?12l[?25h[?25l - 746 }) 746,153%[?12l[?25h[?25l - 747 .collect::<Vec<_>>(); 747,153%[?12l[?25h[?25l - 748  748,0-153%[?12l[?25h[?25l - 749 self.render_cells(cells.into_iter(), glyph_cache); 749,153%[?12l[?25h[?25l - 750  } 750,153%[?12l[?25h[?25l - 751  751,0-153%[?12l[?25h[?25l - 752  #[inline] 752,153%[?12l[?25h[?25l - 753  fn add_render_item(&mut self, cell: &RenderableCell, glyph: &Glyph) { 753,153%[?12l[?25h[?25l - 754 // Flush batch if tex changing 754,153%[?12l[?25h[?25l - 755 if !self.batch.is_empty() && self.batch.tex != glyph.tex_id { 755,153%[?12l[?25h[?25l - 756 self.render_batch(); 756,153%[?12l[?25h[?25l - 757 } 757,154%[?12l[?25h[?25l - 758  758,0-154%[?12l[?25h[?25l - 759 self.batch.add_item(cell, glyph); 759,154%[?12l[?25h[?25l - 760  760,0-154%[?12l[?25h[?25l - 761 // Render batch and clear if it's full 761,154%[?12l[?25h[?25l - 762 if self.batch.full() { 762,154%[?12l[?25h[?25l - 763 self.render_batch(); 763,154%[?12l[?25h[?25l - 764 } 764,154%[?12l[?25h[?25l - 765  } 765,154%[?12l[?25h[?25l - 766  766,0-154%[?12l[?25h[?25l - 767  pub fn render_cells<I>( 767,154%[?12l[?25h[?25l - 768 &mut self, 768,154%[?12l[?25h[?25l - 769 cells: I, 769,154%[?12l[?25h[?25l - 770 glyph_cache: &mut GlyphCache 770,155%[?12l[?25h[?25l - 771  ) 771,155%[?12l[?25h[?25l - 772 where I: Iterator<Item=RenderableCell> 772,155%[?12l[?25h[?25l - 773  { 773,155%[?12l[?25h[?25l - 774 for cell in cells { 774,155%[?12l[?25h[?25l - 775 // Get font key for cell 775,155%[?12l[?25h[?25l - 776 // FIXME this is super inefficient. 776,155%[?12l[?25h[?25l - 777 let mut font_key = glyph_cache.font_key; 777,155%[?12l[?25h[?25l - 778 if cell.flags.contains(cell::BOLD) { 778,155%[?12l[?25h[?25l - 779 font_key = glyph_cache.bold_key; 779,155%[?12l[?25h[?25l - 780 } else if cell.flags.contains(cell::ITALIC) { 780,155%[?12l[?25h[?25l - 781 font_key = glyph_cache.italic_key; 781,155%[?12l[?25h[?25l - 782 } 782,155%[?12l[?25h[?25l - 783  783,0-156%[?12l[?25h[?25l - 784 let glyph_key = GlyphKey { 784,156%[?12l[?25h[?25l - 785 font_key: font_key, 785,156%[?12l[?25h[?25l - 786 size: glyph_cache.font_size, 786,156%[?12l[?25h[?25l - 787 c: cell.c 787,156%[?12l[?25h[?25l - 788 }; 788,156%[?12l[?25h[?25l - 789  789,0-156%[?12l[?25h[?25l - 790 // Add cell to batch 790,156%[?12l[?25h[?25l - 791 { 791,156%[?12l[?25h[?25l - 792 let glyph = glyph_cache.get(&glyph_key, self); 792,156%[?12l[?25h[?25l - 793 self.add_render_item(&cell, glyph); 793,156%[?12l[?25h[?25l - 794 } 794,156%[?12l[?25h[?25l - 795  795,0-156%[?12l[?25h[?25l - 796 // FIXME This is a super hacky way to do underlined text. During 796,157%[?12l[?25h[?25l - 797 // a time crunch to release 0.1, this seemed like a really 797,157%[?12l[?25h[?25l - 798 // easy, clean hack. 798,157%[?12l[?25h[?25l - 799 if cell.flags.contains(cell::UNDERLINE) { 799,157%[?12l[?25h[?25l - 800 let glyph_key = GlyphKey { 800,157%[?12l[?25h[?25l - 801 font_key: font_key, 801,157%[?12l[?25h[?25l - 802 size: glyph_cache.font_size, 802,157%[?12l[?25h[?25l - 803 c: '_' 803,157%[?12l[?25h[?25l - 804 }; 804,157%[?12l[?25h[?25l - 805  805,0-157%[?12l[?25h[?25l - 806 let underscore = glyph_cache.get(&glyph_key, self); 806,157%[?12l[?25h[?25l - 807 self.add_render_item(&cell, underscore); 807,157%[?12l[?25h[?25l - 808 } 808,157%[?12l[?25h[?25l - 809 } 809,158%[?12l[?25h[?25l - 810  } 810,158%[?12l[?25h[?25l - 811 } 811,158%[?12l[?25h[?25l - 812  812,0-158%[?12l[?25h[?25l - 813 impl<'a> LoadGlyph for LoaderApi<'a> { 813,158%[?12l[?25h[?25l - 814  /// Load a glyph into a texture atlas 814,158%[?12l[?25h[?25l - 815  /// 815,158%[?12l[?25h[?25l - 816  /// If the current atlas is full, a new one will be created. 816,158%[?12l[?25h[?25l - 817  fn load_glyph(&mut self, rasterized: &RasterizedGlyph) -> Glyph { 817,158%[?12l[?25h[?25l - 818 // At least one atlas is guaranteed to be in the `self.atlas` list; thus 818,158%[?12l[?25h[?25l - 819 // the unwrap should always be ok. 819,158%[?12l[?25h[?25l - 820 match self.atlas.last_mut().unwrap().insert(rasterized, &mut self.active_tex) { 820,158%[?12l[?25h[?25l - 821 Ok(glyph) => glyph, 821,158%[?12l[?25h[?25l - 822 Err(_) => { 822,159%[?12l[?25h[?25l - 823 let atlas = Atlas::new(ATLAS_SIZE); 823,159%[?12l[?25h[?25l - 824 *self.active_tex = 0; // Atlas::new binds a texture. Ugh this is sloppy. 824,159%[?12l[?25h[?25l - 825 self.atlas.push(atlas); 825,159%[?12l[?25h[?25l - 826 self.load_glyph(rasterized) 826,159%[?12l[?25h[?25l - 827 } 827,159%[?12l[?25h[?25l - 828 } 828,159%[?12l[?25h[?25l - 829  } 829,159%[?12l[?25h[?25l -{ 830 } 830,159%[?12l[?25h[?25l -{} - 831  831,0-159%[?12l[?25h[?25l - 832 impl<'a> LoadGlyph for RenderApi<'a> { 832,159%[?12l[?25h[?25l - 833  /// Load a glyph into a texture atlas 833,159%[?12l[?25h[?25l - 834  /// 834,159%[?12l[?25h[?25l - 835  /// If the current atlas is full, a new one will be created. 835,160%[?12l[?25h[?25l - 836  fn load_glyph(&mut self, rasterized: &RasterizedGlyph) -> Glyph { 836,160%[?12l[?25h[?25l - 837 // At least one atlas is guaranteed to be in the `self.atlas` list; thus 837,160%[?12l[?25h[?25l - 838 // the unwrap. 838,160%[?12l[?25h[?25l - 839 match self.atlas.last_mut().unwrap().insert(rasterized, &mut self.active_tex) { 839,160%[?12l[?25h[?25l - 840 Ok(glyph) => glyph, 840,160%[?12l[?25h[?25l - 841 Err(_) => { 841,160%[?12l[?25h[?25l - 842 let atlas = Atlas::new(ATLAS_SIZE); 842,160%[?12l[?25h[?25l - 843 *self.active_tex = 0; // Atlas::new binds a texture. Ugh this is sloppy. 843,160%[?12l[?25h[?25l - 844 self.atlas.push(atlas); 844,160%[?12l[?25h[?25l - 845 self.load_glyph(rasterized) 845,160%[?12l[?25h[?25l - 846 } 846,160%[?12l[?25h[?25l - 847 } 847,160%[?12l[?25h[?25l - 848  } 848,161%[?12l[?25h[?25l -{ 849 } 849,161%[?12l[?25h[?25l -{} - 850  850,0-161%[?12l[?25h[?25l - 851 impl<'a> Drop for RenderApi<'a> { 851,161%[?12l[?25h[?25l - 852  fn drop(&mut self) { 852,161%[?12l[?25h[?25l - 853 if !self.batch.is_empty() { 853,161%[?12l[?25h[?25l - 854 self.render_batch(); 854,161%[?12l[?25h[?25l - 855 } 855,161%[?12l[?25h[?25l - 856  } 856,161%[?12l[?25h[?25l -{ 857 } 857,161%[?12l[?25h[?25l -{} - 858  858,0-161%[?12l[?25h[?25l - 859 impl ShaderProgram { 859,161%[?12l[?25h[?25l - 860  pub fn activate(&self) { 860,161%[?12l[?25h[?25l - 861 unsafe { 861,162%[?12l[?25h[?25l - 862 gl::UseProgram(self.id); 862,162%[?12l[?25h[?25l - 863 } 863,162%[?12l[?25h[?25l - 864  } 864,162%[?12l[?25h[?25l - 865  865,0-162%[?12l[?25h[?25l - 866  pub fn deactivate(&self) { 866,162%[?12l[?25h[?25l - 867 unsafe { 867,162%[?12l[?25h[?25l - 868 gl::UseProgram(0); 868,162%[?12l[?25h[?25l - 869 } 869,162%[?12l[?25h[?25l - 870  } 870,162%[?12l[?25h[?25l - 871  871,0-162%[?12l[?25h[?25l - 872  pub fn new( 872,162%[?12l[?25h[?25l - 873 config: &Config, 873,162%[?12l[?25h[?25l - 874 size: Size<Pixels<u32>> 874,163%[?12l[?25h[?25l - 875  ) -> Result<ShaderProgram, ShaderCreationError> { 875,163%[?12l[?25h[?25l - 876 let vertex_source = if cfg!(feature = "live-shader-reload") { 876,163%[?12l[?25h[?25l - 877 None 877,163%[?12l[?25h[?25l - 878 } else { 878,163%[?12l[?25h[?25l - 879 Some(TEXT_SHADER_V) 879,163%[?12l[?25h[?25l - 880 }; 880,163%[?12l[?25h[?25l - 881 let vertex_shader = ShaderProgram::create_shader( 881,163%[?12l[?25h[?25l - 882 TEXT_SHADER_V_PATH, 882,163%[?12l[?25h[?25l - 883 gl::VERTEX_SHADER, 883,163%[?12l[?25h[?25l - 884 vertex_source 884,163%[?12l[?25h[?25l - 885 )?; 885,163%[?12l[?25h[?25l - 886 let frag_source = if cfg!(feature = "live-shader-reload") { 886,163%[?12l[?25h[?25l - 887 None 887,164%[?12l[?25h[?25l - 888 } else { 888,164%[?12l[?25h[?25l - 889 Some(TEXT_SHADER_F) 889,164%[?12l[?25h[?25l - 890 }; 890,164%[?12l[?25h[?25l - 891 let fragment_shader = ShaderProgram::create_shader( 891,164%[?12l[?25h \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/vim_simple_edit b/cmd/sst/mosaic/multiplexer/tcell-term/tests/vim_simple_edit deleted file mode 100644 index 8f5c2c397e..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/vim_simple_edit +++ /dev/null @@ -1,6 +0,0 @@ -% ]2;jwilm@jwilm-desk: ~/code/alacritty]1;..ode/alacritty jwilm@jwilm-desk ➜  ~/code/alacritty  [?1h=[?2004hvvivim[?1l>[?2004l -]2;vim]1;vim[?1049h[?1h=▽ [?12;25h[?12l[?25h[>c[?25l 1 -~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 0,0-1AllVIM - Vi IMprovedversion 7.4.1832by Bram Moolenaar et al.Vim is open source and freely distributableBecome a registered Vim user!type :help register for information type :q to exit type :help or  for on-line helptype :help version7 for version info[?12l[?25h[?25l-- INSERT --0,1All         [?12l[?25h[?25lH1,2[?12l[?25h[?25le3[?12l[?25h[?25ll4[?12l[?25h[?25ll5[?12l[?25h[?25lo6[?12l[?25h[?25l,7[?12l[?25h[?25l·8[?12l[?25h[?25l w9[?12l[?25h[?25lo10[?12l[?25h[?25lr1[?12l[?25h[?25ll2[?12l[?25h[?25ld3[?12l[?25h[?25l.4[?12l[?25h[?25l.5[?12l[?25h[?25l - 2 2,1 [?12l[?25h[?25l - 3 3[?12l[?25h[?25l - 4 4[?12l[?25h[?25lO2[?12l[?25h[?25lk3[?12l[?25h[?25l.4[?12l[?25h[?25l4,3All[?12l[?25h[?25l3,0-1[?12l[?25h[?25l:[?12l[?25hw[?25l[?12l[?25h[?25l3,0-1All[?12l[?25h \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/vttest_cursor_movement_1 b/cmd/sst/mosaic/multiplexer/tcell-term/tests/vttest_cursor_movement_1 deleted file mode 100644 index 6d51cfdfae..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/vttest_cursor_movement_1 +++ /dev/null @@ -1,33 +0,0 @@ -% ]2;jwilm@jwilm-desk: ~/code/alacritty]1;..ode/alacritty jwilm@jwilm-desk ➜  ~/code/alacritty  [?1h=[?2004hvvtvttteesvttest[?1l>[?2004l -]2;vttest]1;vttest[?1l[?3l[?4l[?5l[?6l[?7h[?8l[?40h[?45lVT100 test program, version 2.7 (20140305)Line speed 38400bd Choose test type: - - 0. Exit - 1. Test of cursor movements - 2. Test of screen features - 3. Test of character sets - 4. Test of double-sized characters - 5. Test of keyboard - 6. Test of terminal reports - 7. Test of VT52 mode - 8. Test of VT102 features (Insert/Delete Char/Line) - 9. Test of known bugs - 10. Test of reset and self-test - 11. Test non-VT100 (e.g., VT220, XTERM) terminals - 12. Modify test-parameters - - Enter choice number (0 - 12): 1 -[?3l#8****************************************************************************************************************************************************************+D+D+D+D+D+D+D+D+D+D+D+D+D+D+D+D+D+D+D+D+D+D+M+M+M+M+M+M+M+M+M+M+M+M+M+M+M+M+M+M+M+M+M+M**E**E**E**E**E**E**E**E** -** -** -** -** -** -** -** -** -** -** -** -** -** -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++      The screen should be cleared, and have an unbroken bor-der of *'s and +'s around the edge, and exactly in themiddle there should be a frame of E's around this textwith one (1) free position around it. Push \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/vttest_insert b/cmd/sst/mosaic/multiplexer/tcell-term/tests/vttest_insert deleted file mode 100644 index 2986c82b4a..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/vttest_insert +++ /dev/null @@ -1,21 +0,0 @@ -% jwilm@sanctuary.local ➜  ~/code/alacritty  [?1h=[?2004hvvtvttteesvttest[?1l>[?2004l -[?1l[?3l[?4l[?5l[?6l[?7h[?8l[?40h[?45lVT100 test program, version 2.7 (20140305)Choose test type: - - 0. Exit - 1. Test of cursor movements - 2. Test of screen features - 3. Test of character sets - 4. Test of double-sized characters - 5. Test of keyboard - 6. Test of terminal reports - 7. Test of VT52 mode - 8. Test of VT102 features (Insert/Delete Char/Line) - 9. Test of known bugs - 10. Test of reset and self-test - 11. Test non-VT100 (e.g., VT220, XTERM) terminals - 12. Modify test-parameters - - Enter choice number (0 - 12): 8 -[?3lAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXScreen accordion test (Insert & Delete Line). Push -M[?6h[?6lTop line: A's, bottom line: X's, this line, nothing more. Push -B******************************************************************************Test of 'Insert Mode'. The top line should be 'A*** ... ***B'. Push \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/tests/zsh_tab_completion b/cmd/sst/mosaic/multiplexer/tcell-term/tests/zsh_tab_completion deleted file mode 100644 index 47b7c6298e..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/tests/zsh_tab_completion +++ /dev/null @@ -1,2 +0,0 @@ -% jwilm@kurast.local ➜  ~/code/alacritty  [?1h=[?2004hccacat cc -Cargo.lock Cargo.toml colors.pl* copypasta/ cat c \ No newline at end of file diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/vt.go b/cmd/sst/mosaic/multiplexer/tcell-term/vt.go deleted file mode 100644 index a36af4dc9b..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/vt.go +++ /dev/null @@ -1,673 +0,0 @@ -package tcellterm - -import ( - "fmt" - "io" - "log" - "os" - "os/exec" - "runtime/debug" - "strings" - "sync" - "unicode" - - "github.com/creack/pty" - "github.com/gdamore/tcell/v2" - "github.com/mattn/go-runewidth" - "github.com/sst/sst/v3/pkg/process" -) - -type ( - column int - row int -) - -// VT models a virtual terminal -type VT struct { - Logger *log.Logger - // If true, OSC8 enables the output of OSC8 strings. Otherwise, any OSC8 - // sequences will be stripped - OSC8 bool - // Set the TERM environment variable to be passed to the command's - // environment. If not set, xterm-256color will be used - TERM string - - mu sync.Mutex - - activeScreen [][]cell - altScreen [][]cell - primaryScreen [][]cell - primaryScrollback [][]cell - - scroll int - - charsets charsets - cursor cursor - margin margin - mode mode - sShift charset - tabStop []column - // lastCol is a flag indicating we printed in the last col - lastCol bool - - primaryState cursorState - altState cursorState - - cmd *exec.Cmd - dirty bool - eventHandler func(tcell.Event) - parser *Parser - pty *os.File - surface Surface - events chan tcell.Event - - mouseBtn tcell.ButtonMask - - selection *selection -} - -type selection struct { - content strings.Builder - startX int - startY int - endX int - endY int -} - -type cursorState struct { - cursor cursor - decawm bool - decom bool - charsets charsets -} - -type margin struct { - top row - bottom row - left column - right column -} - -func New() *VT { - tabs := []column{} - for i := 7; i < (50 * 7); i += 8 { - tabs = append(tabs, column(i)) - } - return &VT{ - Logger: log.New(io.Discard, "", log.Flags()), - OSC8: true, - scroll: -1, - selection: &selection{ - startX: 0, - startY: 0, - endX: -1, - endY: -1, - }, - charsets: charsets{ - designations: map[charsetDesignator]charset{ - g0: ascii, - g1: ascii, - g2: ascii, - g3: ascii, - }, - }, - mode: decawm | dectcem, - primaryState: cursorState{ - charsets: charsets{ - designations: map[charsetDesignator]charset{ - g0: ascii, - g1: ascii, - g2: ascii, - g3: ascii, - }, - }, - decawm: true, - }, - altState: cursorState{ - charsets: charsets{ - designations: map[charsetDesignator]charset{ - g0: ascii, - g1: ascii, - g2: ascii, - g3: ascii, - }, - }, - decawm: true, - }, - tabStop: tabs, - eventHandler: func(ev tcell.Event) { return }, - // Buffering to 2 events. If there is ever a case where one - // sequence can trigger two events, this should be increased - events: make(chan tcell.Event, 2), - } -} - -// Start starts the terminal with the specified command. Start returns when the -// command has been successfully started. -func (vt *VT) Start(cmd *exec.Cmd) error { - if cmd == nil { - return fmt.Errorf("no command to run") - } - vt.cmd = cmd - vt.mu.Lock() - w, h := vt.surface.Size() - vt.mu.Unlock() - - if vt.TERM == "" { - vt.TERM = "xterm-256color" - } - - cmd.Env = append(cmd.Env, "TERM="+vt.TERM) - - // Start the command with a pty. - var err error - winsize := pty.Winsize{ - Cols: uint16(w), - Rows: uint16(h), - } - vt.pty, err = pty.StartWithAttrs(cmd, &winsize, getPtyAttr()) - if err != nil { - return err - } - - vt.Resize(w, h) - vt.parser = NewParser(vt.pty) - go func() { - defer vt.recover() - for { - select { - case ev := <-vt.events: - vt.eventHandler(ev) - default: - seq := vt.parser.Next() - switch seq := seq.(type) { - case EOF: - vt.eventHandler(&EventClosed{ - EventTerminal: newEventTerminal(vt), - }) - return - default: - vt.update(seq) - } - } - } - }() - return nil -} - -func (vt *VT) update(seq Sequence) { - vt.mu.Lock() - defer vt.mu.Unlock() - switch seq := seq.(type) { - case Print: - vt.print(rune(seq)) - case C0: - vt.c0(rune(seq)) - case ESC: - esc := append(seq.Intermediate, seq.Final) - vt.esc(string(esc)) - case CSI: - csi := append(seq.Intermediate, seq.Final) - vt.csi(string(csi), seq.Parameters) - case OSC: - vt.osc(string(seq.Payload)) - case DCS: - case DCSData: - case DCSEndOfData: - } - // TODO optimize when we post EventRedraw - if !vt.dirty { - vt.dirty = true - vt.postEvent(&EventRedraw{ - EventTerminal: newEventTerminal(vt), - }) - } -} - -func (vt *VT) String() string { - vt.mu.Lock() - defer vt.mu.Unlock() - str := strings.Builder{} - for row := range vt.activeScreen { - for col := range vt.activeScreen[row] { - _, _ = str.WriteRune(vt.activeScreen[row][col].rune()) - for _, comb := range vt.activeScreen[row][col].combining { - _, _ = str.WriteRune(comb) - } - } - if row < vt.height()-1 { - str.WriteRune('\n') - } - } - return str.String() -} - -func (vt *VT) recover() { - err := recover() - if err == nil { - return - } - ret := strings.Builder{} - ret.WriteString(fmt.Sprintf("cursor row=%d col=%d\n", vt.cursor.row, vt.cursor.col)) - ret.WriteString(fmt.Sprintf("margin left=%d right=%d\n", vt.margin.left, vt.margin.right)) - ret.WriteString(fmt.Sprintf("%s\n", err)) - ret.Write(debug.Stack()) - - vt.postEvent(&EventPanic{ - EventTerminal: newEventTerminal(vt), - Error: fmt.Errorf("%s", ret.String()), - }) - vt.Close() -} - -// row, col, style, vis -func (vt *VT) Cursor() (int, int, tcell.CursorStyle, bool) { - vt.mu.Lock() - defer vt.mu.Unlock() - vis := vt.mode&dectcem > 0 - return int(vt.cursor.row), int(vt.cursor.col), vt.cursor.style, vis -} - -func (vt *VT) Resize(w int, h int) { - primary := vt.primaryScreen - vt.altScreen = make([][]cell, h) - vt.primaryScreen = make([][]cell, h) - for i := range vt.altScreen { - vt.altScreen[i] = make([]cell, w) - vt.primaryScreen[i] = make([]cell, w) - } - last := vt.cursor.row - vt.margin.bottom = row(h) - 1 - vt.margin.right = column(w) - 1 - vt.cursor.row = 0 - vt.cursor.col = 0 - vt.lastCol = false - vt.activeScreen = vt.primaryScreen - - // transfer primary to new, skipping the last row - for row := 0; row < len(primary); row += 1 { - if row == int(last) { - break - } - wrapped := false - for col := 0; col < len(primary[0]); col += 1 { - cell := primary[row][col] - vt.cursor.attrs = cell.attrs - vt.print(cell.content) - wrapped = cell.wrapped - } - if !wrapped { - vt.nel() - } - } - switch vt.mode & smcup { - case 0: - vt.activeScreen = vt.primaryScreen - default: - vt.activeScreen = vt.altScreen - } - /* - nextScrollback := [][]cell{} - currentRow := []cell{} - for _, row := range vt.primaryScrollback { - for col, c := range row { - if col >= w { - nextScrollback = append(nextScrollback, currentRow) - currentRow = []cell{} - } - currentRow = append(currentRow, c) - } - } - vt.primaryScrollback = nextScrollback - */ - - _ = pty.Setsize(vt.pty, &pty.Winsize{ - Cols: uint16(w), - Rows: uint16(h), - }) -} - -func (vt *VT) width() int { - if len(vt.activeScreen) > 0 { - return len(vt.activeScreen[0]) - } - return 0 -} - -func (vt *VT) height() int { - return len(vt.activeScreen) -} - -// print sets the current cell contents to the given rune. The attributes will -// be copied from the current cursor attributes -func (vt *VT) print(r rune) { - if vt.charsets.designations[vt.charsets.selected] == decSpecialAndLineDrawing { - shifted, ok := decSpecial[r] - if ok { - r = shifted - } - } - - // If we are single-shifted, move the previous charset into the current - if vt.charsets.singleShift { - vt.charsets.selected = vt.charsets.saved - } - - if vt.cursor.col == vt.margin.right && vt.lastCol { - col := vt.cursor.col - rw := vt.cursor.row - vt.activeScreen[rw][col].wrapped = true - vt.nel() - } - - col := vt.cursor.col - rw := vt.cursor.row - w := runewidth.RuneWidth(r) - - if vt.mode&irm != 0 { - line := vt.activeScreen[rw] - for i := vt.margin.right; i > col; i -= 1 { - line[i] = line[i-column(w)] - } - } - if col > column(vt.width())-1 { - col = column(vt.width()) - 1 - } - if rw > row(vt.height()-1) { - rw = row(vt.height() - 1) - } - - if w == 0 { - if col-1 < 0 { - return - } - vt.activeScreen[rw][col-1].combining = append(vt.activeScreen[rw][col-1].combining, r) - return - } - cell := cell{ - content: r, - width: w, - attrs: vt.cursor.attrs, - } - - vt.activeScreen[rw][col] = cell - - // Set trailing cells to a space if wide rune - for i := column(1); i < column(w); i += 1 { - if col+i > vt.margin.right { - break - } - vt.activeScreen[rw][col+i].content = ' ' - vt.activeScreen[rw][col+i].attrs = vt.cursor.attrs - } - - switch { - case vt.mode&decawm != 0 && col == vt.margin.right: - vt.lastCol = true - case col == vt.margin.right: - // don't move the cursor - default: - vt.cursor.col += column(w) - } -} - -// scrollUp shifts all text upward by n rows. Semantically, this is backwards - -// usually scroll up would mean you shift rows down -func (vt *VT) scrollUp(n int) { - for i := 0; i < n; i += 1 { - history := make([]cell, len(vt.activeScreen[i])) - copy(history, vt.activeScreen[i]) - vt.primaryScrollback = append(vt.primaryScrollback, history) - } - for row := range vt.activeScreen { - if row > int(vt.margin.bottom) { - continue - } - if row < int(vt.margin.top) { - continue - } - if row+n > int(vt.margin.bottom) { - for col := vt.margin.left; col <= vt.margin.right; col += 1 { - vt.activeScreen[row][col].erase(vt.cursor.attrs) - } - continue - } - copy(vt.activeScreen[row], vt.activeScreen[row+n]) - } -} - -// scrollDown shifts all lines down by n rows. -func (vt *VT) scrollDown(n int) { - for r := vt.margin.bottom; r >= vt.margin.top; r -= 1 { - if r-row(n) < vt.margin.top { - for col := vt.margin.left; col <= vt.margin.right; col += 1 { - vt.activeScreen[r][col].erase(vt.cursor.attrs) - } - continue - } - copy(vt.activeScreen[r], vt.activeScreen[r-row(n)]) - } -} - -func (vt *VT) Close() { - if vt.cmd != nil && vt.cmd.Process != nil { - process.Kill(vt.cmd.Process) - } - vt.mu.Lock() - defer vt.mu.Unlock() - vt.pty.Close() -} - -func (vt *VT) Attach(fn func(ev tcell.Event)) { - vt.mu.Lock() - defer vt.mu.Unlock() - vt.eventHandler = fn -} - -func (vt *VT) Detach() { - vt.mu.Lock() - defer vt.mu.Unlock() - vt.eventHandler = func(ev tcell.Event) { - return - } -} - -func (vt *VT) postEvent(ev tcell.Event) { - vt.events <- ev -} - -func (vt *VT) SetSurface(srf Surface) { - vt.mu.Lock() - defer vt.mu.Unlock() - vt.surface = srf -} - -func (vt *VT) ScrollUp(offset int) { - if !vt.IsScrolling() { - if len(vt.primaryScrollback) == 0 { - return - } - vt.scroll = len(vt.primaryScrollback) - } - vt.scroll = vt.scroll - offset - vt.scroll = max(0, vt.scroll) -} - -func (vt *VT) ScrollDown(offset int) { - if !vt.IsScrolling() { - return - } - vt.scroll = vt.scroll + offset - if vt.scroll >= len(vt.primaryScrollback) { - vt.ScrollReset() - } -} - -func (vt *VT) ScrollReset() { - vt.scroll = -1 -} - -func (vt *VT) ClearScrollback() { - vt.primaryScrollback = [][]cell{} -} - -func (vt *VT) Scrollable() bool { - return len(vt.primaryScrollback) > 0 -} - -func (vt *VT) IsScrolling() bool { - return vt.scroll != -1 -} - -func (vt *VT) Draw() { - vt.mu.Lock() - defer vt.mu.Unlock() - vt.dirty = false - if vt.surface == nil { - return - } - offset := 0 - vt.selection.content = strings.Builder{} - if vt.IsScrolling() { - for x := vt.scroll; x < len(vt.primaryScrollback); x += 1 { - if offset >= vt.height() { - break - } - vt.drawRow(offset, vt.primaryScrollback[x]) - offset += 1 - } - } - for cols := range vt.activeScreen { - if offset >= vt.height() { - break - } - vt.drawRow(offset, vt.activeScreen[cols]) - offset++ - } -} - -func (vt *VT) drawRow(row int, cols []cell) { - scrollOffset := len(vt.primaryScrollback) - if vt.scroll != -1 { - scrollOffset = vt.scroll - } - builder := strings.Builder{} - for col := 0; col < len(cols); { - cell := cols[col] - w := cell.width - content := cell.content - if cell.content == '\x00' { - content = ' ' - w = 1 - } - style := cell.attrs - if vt.selection != nil && isCellSelected(col, row+scrollOffset, vt.selection.startX, vt.selection.startY, vt.selection.endX, vt.selection.endY) { - style = style.Reverse(true) - builder.WriteRune(content) - } - vt.surface.SetContent(col, row, content, cell.combining, style) - if w == 0 { - w = 1 - } - col += 1 - } - if builder.Len() > 0 { - vt.selection.content.WriteString(strings.TrimRight(builder.String(), " ")) - vt.selection.content.WriteRune('\n') - } -} - -func (vt *VT) HandleEvent(e tcell.Event) bool { - vt.mu.Lock() - defer vt.mu.Unlock() - switch e := e.(type) { - case *tcell.EventKey: - vt.pty.WriteString(keyCode(e)) - return true - case *tcell.EventPaste: - switch { - case vt.mode&paste == 0: - return false - case e.Start(): - vt.pty.WriteString(info.PasteStart) - return true - case e.End(): - vt.pty.WriteString(info.PasteEnd) - return true - } - case *tcell.EventMouse: - str := vt.handleMouse(e) - vt.pty.WriteString(str) - } - return false -} - -func (vt *VT) Clear() { - vt.ris() -} - -func (vt *VT) Copy() string { - return strings.TrimRightFunc(vt.selection.content.String(), unicode.IsSpace) -} - -func (vt *VT) SelectStart(x int, y int) { - scrollOffset := len(vt.primaryScrollback) - if vt.scroll != -1 { - scrollOffset = vt.scroll - } - y += scrollOffset - vt.selection = &selection{ - startX: x, - startY: y, - endX: -1, - endY: -1, - } -} - -func (vt *VT) SelectEnd(x int, y int) { - scrollOffset := len(vt.primaryScrollback) - if vt.scroll != -1 { - scrollOffset = vt.scroll - } - y += scrollOffset - vt.selection.endX = x - vt.selection.endY = y -} - -func (vt *VT) HasSelection() bool { - return vt.selection.endX != -1 && vt.selection.endY != -1 -} - -func (vt *VT) ClearSelection() { - vt.selection.startX = 0 - vt.selection.startY = 0 - vt.selection.endX = -1 - vt.selection.endY = -1 -} - -func isCellSelected(x, y, startX, startY, endX, endY int) bool { - if endX < 0 || endY < 0 { - return false - } - // Normalize the selection coordinates - minY, maxY := startY, endY - minX, maxX := startX, endX - if endY < startY || endY == startY && endX < startX { - minY, maxY = endY, startY - minX, maxX = endX, startX - } - // Check if the cell is within the selection - if y > minY && y < maxY { - return true // Full line selected - } - if y == minY && y == maxY { - return x >= minX && x <= maxX // Single line selection - } - if y == minY { - return x >= minX // First line of multi-line selection - } - if y == maxY { - return x <= maxX // Last line of multi-line selection - } - return false -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/vt_test.go b/cmd/sst/mosaic/multiplexer/tcell-term/vt_test.go deleted file mode 100644 index 54e24ccc63..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/vt_test.go +++ /dev/null @@ -1,148 +0,0 @@ -package tcellterm - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestResize(t *testing.T) { - vt := New() - w := 4 - h := 1 - vt.Resize(w, h) - assert.Equal(t, h, len(vt.activeScreen)) - assert.Equal(t, w, len(vt.activeScreen[0])) -} - -func TestString(t *testing.T) { - vt := New() - w := 2 - h := 1 - vt.Resize(w, h) - assert.Equal(t, " ", vt.String()) - - vt.activeScreen[0][0].content = 'v' - vt.activeScreen[0][1].content = 't' - assert.Equal(t, "vt", vt.String()) -} - -func TestPrint(t *testing.T) { - t.Run("No modes", func(t *testing.T) { - vt := New() - vt.mode = 0 - w := 2 - h := 1 - vt.Resize(w, h) - - vt.print('v') - vt.print('t') - assert.Equal(t, "vt", vt.String()) - assert.Equal(t, column(1), vt.cursor.col) - vt.print('x') - assert.Equal(t, "vx", vt.String()) - }) - - t.Run("IRM = set", func(t *testing.T) { - vt := New() - w := 4 - h := 1 - vt.Resize(w, h) - - vt.print('v') - vt.print('t') - vt.bs() - vt.bs() - assert.Equal(t, column(0), vt.cursor.col) - assert.Equal(t, "vt ", vt.String()) - vt.mode |= irm - vt.print('i') - assert.Equal(t, "ivt ", vt.String()) - vt.print('j') - vt.print('k') - assert.Equal(t, "ijkv", vt.String()) - }) - - t.Run("DECAWM = set", func(t *testing.T) { - vt := New() - w := 3 - h := 2 - vt.Resize(w, h) - vt.mode |= decawm - - vt.print('v') - vt.print('t') - assert.Equal(t, "vt \n ", vt.String()) - vt.print('i') - assert.Equal(t, "vti\n ", vt.String()) - vt.print('j') - assert.Equal(t, "vti\nj ", vt.String()) - }) - - t.Run("Wide character", func(t *testing.T) { - vt := New() - w := 1 - h := 1 - vt.Resize(w, h) - - vt.print('つ') - assert.Equal(t, "つ", vt.String()) - }) -} - -func TestScrollUp(t *testing.T) { - vt := New() - vt.mode = 0 - w := 2 - h := 2 - vt.Resize(w, h) - - vt.print('v') - vt.print('t') - assert.Equal(t, "vt\n ", vt.String()) - vt.scrollUp(1) - assert.Equal(t, " \n ", vt.String()) - - vt = New() - w = 1 - h = 8 - vt.Resize(w, h) - - vt.cursor.row = 4 - vt.print('v') - vt.lastCol = false - vt.cursor.row = 7 - vt.print('t') - vt.margin.bottom = 5 - assert.Equal(t, " \n \n \n \nv\n \n \nt", vt.String()) - vt.scrollUp(1) - assert.Equal(t, " \n \n \nv\n \n \n \nt", vt.String()) -} - -func TestScrollDown(t *testing.T) { - vt := New() - w := 2 - h := 2 - vt.Resize(w, h) - - vt.print('v') - vt.print('t') - assert.Equal(t, "vt\n ", vt.String()) - vt.scrollDown(1) - assert.Equal(t, " \nvt", vt.String()) - vt.lastCol = false - vt.print('b') - assert.Equal(t, " b\nvt", vt.String()) - vt.scrollDown(1) - assert.Equal(t, " \n b", vt.String()) -} - -func TestCombiningRunes(t *testing.T) { - vt := New() - vt.Resize(2, 2) - vt.print('h') - vt.print(0x337) - vt.print(0x317) - - assert.Equal(t, "h̷̗ \n ", vt.String()) -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/vt_unix.go b/cmd/sst/mosaic/multiplexer/tcell-term/vt_unix.go deleted file mode 100644 index b5494ad00b..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/vt_unix.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build !windows -// +build !windows - -package tcellterm - -import "syscall" - -func getPtyAttr() *syscall.SysProcAttr { - return &syscall.SysProcAttr{ - Setsid: true, - Setctty: true, - Ctty: 1, - } -} diff --git a/cmd/sst/mosaic/multiplexer/tcell-term/vt_windows.go b/cmd/sst/mosaic/multiplexer/tcell-term/vt_windows.go deleted file mode 100644 index 50fdcee4f5..0000000000 --- a/cmd/sst/mosaic/multiplexer/tcell-term/vt_windows.go +++ /dev/null @@ -1,10 +0,0 @@ -//go:build windows -// +build windows - -package tcellterm - -import "syscall" - -func getPtyAttr() *syscall.SysProcAttr { - return &syscall.SysProcAttr{} -} diff --git a/cmd/sst/mosaic/multiplexer/terminfo.go b/cmd/sst/mosaic/multiplexer/terminfo.go deleted file mode 100644 index f980a4773e..0000000000 --- a/cmd/sst/mosaic/multiplexer/terminfo.go +++ /dev/null @@ -1,289 +0,0 @@ -package multiplexer - -import "github.com/gdamore/tcell/v2/terminfo" - -// extended terminfo defines additional keys in a singular place, if missing -// from the terminfo.Terminfo struct -type extendedTerminfo struct { - KeyAltInsert string - KeyAltDelete string - KeyAltPgUp string - KeyAltPgDown string - - KeyCtrlInsert string - KeyCtrlDelete string - KeyCtrlPgUp string - KeyCtrlPgDown string - - KeyCtrlShfInsert string - KeyCtrlShfDelete string - KeyCtrlShfPgUp string - KeyCtrlShfPgDown string - - KeyAltShfInsert string - KeyAltShfDelete string - KeyAltShfPgUp string - KeyAltShfPgDown string - - KeyCtrlAltUp string - KeyCtrlAltDown string - KeyCtrlAltRight string - KeyCtrlAltLeft string - KeyCtrlAltHome string - KeyCtrlAltEnd string - KeyCtrlAltInsert string - KeyCtrlAltDelete string - KeyCtrlAltPgUp string - KeyCtrlAltPgDown string - - KeyCtrlAltShfUp string - KeyCtrlAltShfDown string - KeyCtrlAltShfRight string - KeyCtrlAltShfLeft string - KeyCtrlAltShfHome string - KeyCtrlAltShfEnd string - KeyCtrlAltShfInsert string - KeyCtrlAltShfDelete string - KeyCtrlAltShfPgUp string - KeyCtrlAltShfPgDown string -} - -var extendedInfo = &extendedTerminfo{ - KeyAltInsert: "\x1b[2;3~", - KeyAltDelete: "\x1b[3;3~", - KeyAltPgUp: "\x1b[5;3~", - KeyAltPgDown: "\x1b[6;3~", - - KeyCtrlInsert: "\x1b[2;5~", - KeyCtrlDelete: "\x1b[3;5~", - KeyCtrlPgUp: "\x1b[5;5~", - KeyCtrlPgDown: "\x1b[6;5~", - - KeyCtrlShfInsert: "\x1b[2;6~", - KeyCtrlShfDelete: "\x1b[3;6~", - KeyCtrlShfPgUp: "\x1b[5;6~", - KeyCtrlShfPgDown: "\x1b[6;6~", - - KeyAltShfInsert: "\x1b[2;4~", - KeyAltShfDelete: "\x1b[3;4~", - KeyAltShfPgUp: "\x1b[5;4~", - KeyAltShfPgDown: "\x1b[6;4~", - - KeyCtrlAltUp: "\x1b[1;7A", - KeyCtrlAltDown: "\x1b[1;7B", - KeyCtrlAltRight: "\x1b[1;7C", - KeyCtrlAltLeft: "\x1b[1;7D", - KeyCtrlAltHome: "\x1b[1;7H", - KeyCtrlAltEnd: "\x1b[1;7F", - KeyCtrlAltInsert: "\x1b[2;7~", - KeyCtrlAltDelete: "\x1b[3;7~", - KeyCtrlAltPgUp: "\x1b[5;7~", - KeyCtrlAltPgDown: "\x1b[6;7~", - - KeyCtrlAltShfUp: "\x1b[1;8A", - KeyCtrlAltShfDown: "\x1b[1;8B", - KeyCtrlAltShfRight: "\x1b[1;8C", - KeyCtrlAltShfLeft: "\x1b[1;8D", - KeyCtrlAltShfHome: "\x1b[1;8H", - KeyCtrlAltShfEnd: "\x1b[1;8F", - KeyCtrlAltShfInsert: "\x1b[2;8~", - KeyCtrlAltShfDelete: "\x1b[3;8~", - KeyCtrlAltShfPgUp: "\x1b[5;8~", - KeyCtrlAltShfPgDown: "\x1b[6;8~", -} - -var info = &terminfo.Terminfo{ - Name: "tcell-term", - Aliases: []string{}, - Columns: 80, // cols - Lines: 24, // lines - Colors: 256, // colors - Bell: "\a", // bell - Clear: "\x1b[H\x1b[2J", // clear - EnterCA: "\x1b[?1049h", // smcup - ExitCA: "\x1b[?1049l", // rmcup - ShowCursor: "\x1b[?12l\x1b[?25h", // cnorm - HideCursor: "\x1b[?25l", // civis - AttrOff: "\x1b(B\x1b[m", // sgr0 - Underline: "\x1b[4m", // smul - Bold: "\x1b[1m", // bold - Blink: "\x1b[5m", // blink - Reverse: "\x1b[7m", // rev - Dim: "\x1b[2m", // dim - Italic: "\x1b[3m", // sitm - EnterKeypad: "", // smkx - ExitKeypad: "", // rmkx - - SetFg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38:5:%p1%d%;m", // setaf - SetBg: "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48:5:%p1%d%;m", // setab - - ResetFgBg: "\x1b[39;49m", // op - SetCursor: "\x1b[%i%p1%d;%p2%dH", // cup - CursorBack1: "\b", // cub1 - CursorUp1: "\x1b[A", // cuu1 - PadChar: "\x00", // pad - KeyBackspace: "\x7F", // kbs - KeyF1: "\x1bOP", // kf1 - KeyF2: "\x1bOQ", // kf2 - KeyF3: "\x1bOR", // kf3 - KeyF4: "\x1bOS", // kf4 - KeyF5: "\x1b[15~", // kf5 - KeyF6: "\x1b[17~", // kf6 - KeyF7: "\x1b[18~", // kf7 - KeyF8: "\x1b[19~", // kf8 - KeyF9: "\x1b[20~", // kf9 - KeyF10: "\x1b[21~", // kf10 - KeyF11: "\x1b[23~", // kf11 - KeyF12: "\x1b[24~", // kf12 - KeyF13: "\x1b[1;2P", // kf13 - KeyF14: "\x1b[1;2Q", // kf14 - KeyF15: "\x1b[1;2R", // kf15 - KeyF16: "\x1b[1;2S", // kf16 - KeyF17: "\x1b[15;2~", // kf17 - KeyF18: "\x1b[17;2~", // kf18 - KeyF19: "\x1b[18;2~", // kf19 - KeyF20: "\x1b[19;2~", // kf20 - KeyF21: "\x1b[20;2~", // kf21 - KeyF22: "\x1b[21;2~", // kf22 - KeyF23: "\x1b[23;2~", // kf23 - KeyF24: "\x1b[24;2~", // kf24 - KeyF25: "\x1b[1;5P", // kf25 - KeyF26: "\x1b[1;5Q", // kf26 - KeyF27: "\x1b[1;5R", // kf27 - KeyF28: "\x1b[1;5S", // kf28 - KeyF29: "\x1b[15;5~", // kf29 - KeyF30: "\x1b[17;5~", // kf30 - KeyF31: "\x1b[18;5~", // kf31 - KeyF32: "\x1b[19;5~", // kf32 - KeyF33: "\x1b[20;5~", // kf33 - KeyF34: "\x1b[21;5~", // kf34 - KeyF35: "\x1b[23;5~", // kf35 - KeyF36: "\x1b[24;5~", // kf36 - KeyF37: "\x1b[1;6P", // kf37 - KeyF38: "\x1b[1;6Q", // kf38 - KeyF39: "\x1b[1;6R", // kf39 - KeyF40: "\x1b[1;6S", // kf40 - KeyF41: "\x1b[15;6~", // kf41 - KeyF42: "\x1b[17;6~", // kf42 - KeyF43: "\x1b[18;6~", // kf43 - KeyF44: "\x1b[19;6~", // kf44 - KeyF45: "\x1b[20;6~", // kf45 - KeyF46: "\x1b[21;6~", // kf46 - KeyF47: "\x1b[23;6~", // kf47 - KeyF48: "\x1b[24;6~", // kf48 - KeyF49: "\x1b[1;3P", // kf49 - KeyF50: "\x1b[1;3Q", // kf50 - KeyF51: "\x1b[1;3R", // kf51 - KeyF52: "\x1b[1;3S", // kf52 - KeyF53: "\x1b[15;3~", // kf53 - KeyF54: "\x1b[17;3~", // kf54 - KeyF55: "\x1b[18;3~", // kf55 - KeyF56: "\x1b[19;3~", // kf56 - KeyF57: "\x1b[20;3~", // kf57 - KeyF58: "\x1b[21;3~", // kf58 - KeyF59: "\x1b[23;3~", // kf59 - KeyF60: "\x1b[24;3~", // kf60 - KeyF61: "\x1b[1;4P", // kf61 - KeyF62: "\x1b[1;4Q", // kf62 - KeyF63: "\x1b[1;4R", // kf63 - KeyF64: "\x1b[1;4S", // kf64 - KeyInsert: "\x1b[2~", // kich1 - KeyDelete: "\x1b[3~", // kdch1 - KeyHome: "\x1bOH", // khome - KeyEnd: "\x1bOF", // kend - KeyHelp: "", // khlp - KeyPgUp: "\x1b[5~", // kpp - KeyPgDn: "\x1b[6~", // knp - KeyUp: "\x1bOA", // kcuu1 - KeyDown: "\x1bOB", // kcud1 - KeyRight: "\x1bOC", // kcuf1 - KeyLeft: "\x1bOD", // kcub1 - KeyBacktab: "\x1b[Z", // kcbt - KeyExit: "", // kext - KeyClear: "", // kclr - KeyPrint: "", // kprt - KeyCancel: "", // kcan - Mouse: "\x1b[<", // kmous - AltChars: "", // acsc - EnterAcs: "\x1b(0", // smacs - ExitAcs: "\x1b(B", // rmacs - EnableAcs: "", // enacs - KeyShfUp: "\x1b[1;2A", // kri - KeyShfDown: "\x1b[1;2B", // kind - KeyShfRight: "\x1b[1;2C", // kRIT - KeyShfLeft: "\x1b[1;2D", // kLFT - KeyShfHome: "\x1b[1;2H", // kHOM - KeyShfEnd: "\x1b[1;2F", // kEND - KeyShfInsert: "\x1b[2;2~", // kIC - KeyShfDelete: "\x1b[3;2~", // kDC - - // These are non-standard extensions to terminfo. This includes - // true color support, and some additional keys. Its kind of bizarre - // that shifted variants of left and right exist, but not up and down. - // Terminal support for these are going to vary amongst XTerm - // emulations, so don't depend too much on them in your application. - - StrikeThrough: "", // smxx - - SetFgBg: "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38:5:%p1%d%;;%?%p2%{8}%<%t4%p2%d%e%p2%{16}%<%t10%p2%{8}%-%d%e48:5:%p2%d%;m", // setfgbg - - SetFgBgRGB: "", // setfgbgrgb - SetFgRGB: "", // setfrgb - SetBgRGB: "", // setbrgb - KeyShfPgUp: "\x1b[5;2~", // kPRV - KeyShfPgDn: "\x1b[6;2~", // kNXT - KeyCtrlUp: "\x1b[1;5A", // ctrl-up - KeyCtrlDown: "\x1b[1;5B", // ctrl-left - KeyCtrlRight: "\x1b[1;5C", // ctrl-right - KeyCtrlLeft: "\x1b[1;5D", // ctrl-left - KeyMetaUp: "\x1b[1;9A", // meta-up - KeyMetaDown: "\x1b[1;9B", // meta-left - KeyMetaRight: "\x1b[1;9C", // meta-right - KeyMetaLeft: "\x1b[1;9D", // meta-left - KeyAltUp: "\x1b[1;3A", // alt-up - KeyAltDown: "\x1b[1;3B", // alt-left - KeyAltRight: "\x1b[1;3C", // alt-right - KeyAltLeft: "\x1b[1;3D", // alt-left - KeyCtrlHome: "\x1b[1;5H", - KeyCtrlEnd: "\x1b[1;5F", - KeyMetaHome: "\x1b[1;9H", - KeyMetaEnd: "\x1b[1;9F", - KeyAltHome: "\x1b[1;3H", - KeyAltEnd: "\x1b[1;3F", - KeyAltShfUp: "\x1b[1;4A", - KeyAltShfDown: "\x1b[1;4B", - KeyAltShfRight: "\x1b[1;4C", - KeyAltShfLeft: "\x1b[1;4D", - KeyMetaShfUp: "\x1b[1;10A", - KeyMetaShfDown: "\x1b[1;10B", - KeyMetaShfLeft: "\x1b[1;10C", - KeyMetaShfRight: "\x1b[1;10D", - KeyCtrlShfUp: "\x1b[1;6A", - KeyCtrlShfDown: "\x1b[1;6B", - KeyCtrlShfRight: "\x1b[1;6C", - KeyCtrlShfLeft: "\x1b[1;6D", - KeyCtrlShfHome: "\x1b[1;6H", - KeyCtrlShfEnd: "\x1b[1;6F", - KeyAltShfHome: "\x1b[1;4H", - KeyAltShfEnd: "\x1b[1;4F", - KeyMetaShfHome: "\x1b[1;10H", - KeyMetaShfEnd: "\x1b[1;10F", - EnablePaste: "\x1b[?2004h", // BE - DisablePaste: "\x1b[?2004l", // BD - PasteStart: "\x1b[200~", // PS - PasteEnd: "\x1b[201~", // PE - Modifiers: 1, - InsertChar: "\x1b[@", // string to insert a character (ich1) - AutoMargin: true, // true if writing to last cell in line advances - TrueColor: true, // true if the terminal supports direct color - CursorDefault: "\x1b[0 q", // Se - CursorBlinkingBlock: "\x1b[1 q", - CursorSteadyBlock: "\x1b[2 q", - CursorBlinkingUnderline: "\x1b[3 q", - CursorSteadyUnderline: "\x1b[4 q", - CursorBlinkingBar: "\x1b[5 q", - CursorSteadyBar: "\x1b[6 q", - EnterUrl: "\x1b]8;%p2%s;%p1%s\x1b\\", - ExitUrl: "\x1b]8;;\x1b\\", - SetWindowSize: "", -} diff --git a/cmd/sst/mosaic/socket/socket.go b/cmd/sst/mosaic/socket/socket.go deleted file mode 100644 index b8c34dfdd4..0000000000 --- a/cmd/sst/mosaic/socket/socket.go +++ /dev/null @@ -1,241 +0,0 @@ -package socket - -import ( - "context" - "encoding/json" - "log/slog" - "net/http" - "time" - - "github.com/charmbracelet/x/ansi" - "github.com/gorilla/websocket" - "github.com/sst/sst/v3/cmd/sst/mosaic/aws" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/server" -) - -var upgrader = websocket.Upgrader{ - CheckOrigin: func(r *http.Request) bool { return true }, -} - -type CliDevEvent struct { - App string `json:"app"` - Stage string `json:"stage"` - Region string `json:"region"` -} - -type Invocation struct { - ID string `json:"id,omitempty"` - Source string `json:"source,omitempty"` - Cold bool `json:"cold,omitempty"` - Input json.RawMessage `json:"input,omitempty"` - Output interface{} `json:"output,omitempty"` - Start int64 `json:"start,omitempty"` - End int64 `json:"end,omitempty"` - Errors []InvocationError `json:"errors"` - Logs []InvocationLog `json:"logs"` - Report *InvocationReport `json:"report,omitempty"` -} - -type InvocationLog struct { - ID string `json:"id,omitempty"` - Timestamp int64 `json:"timestamp,omitempty"` - Message string `json:"message,omitempty"` -} - -type InvocationReport struct { - Duration int64 `json:"duration"` - Init int64 `json:"init"` - Size int64 `json:"size"` - Memory int64 `json:"memory"` - Xray string `json:"xray"` -} - -type InvocationError struct { - ID string `json:"id"` - Error string `json:"error"` - Message string `json:"message"` - Stack []Frame `json:"stack"` - Failed bool `json:"failed"` -} - -type Frame struct { - Raw string `json:"raw"` -} - -func Start(ctx context.Context, p *project.Project, server *server.Server) error { - log := slog.Default().With("service", "socket") - connected := make(chan *websocket.Conn) - disconnected := make(chan *websocket.Conn) - invocationClear := make(chan string) - server.Mux.HandleFunc("/socket", func(w http.ResponseWriter, r *http.Request) { - log.Info("socket upgrading", "addr", r.RemoteAddr) - ws, err := upgrader.Upgrade(w, r, nil) - if err != nil { - return - } - defer ws.Close() - - connected <- ws - defer func() { - disconnected <- ws - }() - - for { - _, data, err := ws.ReadMessage() - if err != nil { - log.Info("socket error", "err", err) - break - } - - log.Info("socket message", "message", string(data)) - var message map[string]interface{} - err = json.Unmarshal(data, &message) - if err != nil { - continue - } - - if message["type"] == "log.cleared" { - source := message["properties"].(map[string]interface{})["source"].(string) - invocationClear <- source - } - - } - }) - sockets := make(map[*websocket.Conn]struct{}) - invocations := make(map[string]*Invocation) - - evts := bus.SubscribeAll() - - publish := func(evt interface{}) { - for ws := range sockets { - ws.WriteJSON(evt) - } - } - - publishInvocation := func(invocation *Invocation) { - publish(map[string]interface{}{ - "type": "invocation", - "properties": []*Invocation{ - invocation, - }, - }) - } - - var complete *project.CompleteEvent - - for { - select { - case <-ctx.Done(): - return nil - case source := <-invocationClear: - if source == "all" { - invocations = map[string]*Invocation{} - break - } - for id, invocation := range invocations { - if invocation.Source == source { - delete(invocations, id) - } - } - break - - case unknown := <-evts: - switch evt := unknown.(type) { - case *project.CompleteEvent: - complete = evt - break - case *aws.FunctionInvokedEvent: - source := "" - if complete != nil { - for _, resource := range complete.Resources { - if resource.URN.Name() == evt.FunctionID && resource.Type == "sst:aws:Function" { - source = string(resource.URN) - } - } - } - invocation := &Invocation{ - ID: evt.RequestID, - Source: source, - Input: json.RawMessage(evt.Input), - Start: time.Now().UnixMilli(), - Errors: []InvocationError{}, - Logs: []InvocationLog{}, - } - invocations[evt.RequestID] = invocation - publishInvocation(invocation) - break - case *aws.FunctionResponseEvent: - invocation, ok := invocations[evt.RequestID] - if ok { - invocation.Output = json.RawMessage(evt.Output) - invocation.End = time.Now().UnixMilli() - invocation.Report = &InvocationReport{ - Duration: invocation.End - invocation.Start, - } - publishInvocation(invocation) - } - break - case *aws.FunctionErrorEvent: - invocation, ok := invocations[evt.RequestID] - if ok { - invocation.End = time.Now().UnixMilli() - invocation.Report = &InvocationReport{ - Duration: invocation.End - invocation.Start, - } - error := InvocationError{ - Message: evt.ErrorMessage, - Error: evt.ErrorType, - Failed: true, - Stack: []Frame{}, - } - for _, frame := range evt.Trace { - error.Stack = append(error.Stack, Frame{ - Raw: frame, - }) - } - invocation.Errors = append(invocation.Errors, error) - publishInvocation(invocation) - } - break - case *aws.FunctionLogEvent: - invocation, ok := invocations[evt.RequestID] - if ok { - invocation.Logs = append(invocation.Logs, InvocationLog{ - ID: time.Now().String(), - Timestamp: time.Now().UnixMilli(), - Message: ansi.Strip(evt.Line), - }) - publishInvocation(invocation) - } - break - } - case ws := <-connected: - log.Info("socket connected", "addr", ws.RemoteAddr()) - sockets[ws] = struct{}{} - ws.WriteJSON(map[string]interface{}{ - "type": "cli.dev", - "properties": CliDevEvent{ - App: p.App().Name, - Stage: p.App().Stage, - }, - }) - all := []*Invocation{} - for _, invocation := range invocations { - all = append(all, invocation) - } - log.Info("sending invocations", "count", len(all)) - ws.WriteJSON(map[string]interface{}{ - "type": "invocation", - "properties": all, - }) - break - case ws := <-disconnected: - log.Info("socket disconnected", "addr", ws.RemoteAddr()) - delete(sockets, ws) - break - } - } - -} diff --git a/cmd/sst/mosaic/ui/common/common.go b/cmd/sst/mosaic/ui/common/common.go deleted file mode 100644 index 3afb323c5b..0000000000 --- a/cmd/sst/mosaic/ui/common/common.go +++ /dev/null @@ -1,5 +0,0 @@ -package common - -type StdoutEvent struct { - Line string -} diff --git a/cmd/sst/mosaic/ui/diff.go b/cmd/sst/mosaic/ui/diff.go deleted file mode 100644 index e3387903a3..0000000000 --- a/cmd/sst/mosaic/ui/diff.go +++ /dev/null @@ -1,95 +0,0 @@ -package ui - -import ( - "fmt" - "reflect" - "strings" -) - -type DiffEntry struct { - Path string - Old interface{} - New interface{} -} - -func Diff(old map[string]interface{}, new map[string]interface{}, path ...string) []DiffEntry { - var result []DiffEntry - - for key, newValue := range new { - newPath := append(path, key) - pathString := strings.Join(newPath, ".") - - oldValue, exists := old[key] - if !exists { - result = append(result, DiffEntry{Path: pathString, Old: nil, New: newValue}) - continue - } - - switch typedNew := newValue.(type) { - case map[string]interface{}: - if typedOld, ok := oldValue.(map[string]interface{}); ok { - result = append(result, Diff(typedOld, typedNew, newPath...)...) - } else { - result = append(result, DiffEntry{Path: pathString, Old: oldValue, New: newValue}) - } - case []interface{}: - if typedOld, ok := oldValue.([]interface{}); ok { - result = append(result, diffArray(typedOld, typedNew, newPath)...) - } else { - result = append(result, DiffEntry{Path: pathString, Old: oldValue, New: newValue}) - } - default: - if !reflect.DeepEqual(oldValue, newValue) { - result = append(result, DiffEntry{Path: pathString, Old: oldValue, New: newValue}) - } - } - } - - for key, oldValue := range old { - if _, exists := new[key]; !exists { - deletedPath := append(path, key) - result = append(result, DiffEntry{Path: strings.Join(deletedPath, "."), Old: oldValue, New: nil}) - } - } - - return result -} - -func diffArray(old []interface{}, new []interface{}, path []string) []DiffEntry { - var result []DiffEntry - - for i := 0; i < len(new) || i < len(old); i++ { - indexPath := append(path, fmt.Sprintf("[%d]", i)) - pathString := strings.Join(indexPath, ".") - - if i >= len(old) { - result = append(result, DiffEntry{Path: pathString, Old: nil, New: new[i]}) - } else if i >= len(new) { - result = append(result, DiffEntry{Path: pathString, Old: old[i], New: nil}) - } else { - oldValue := old[i] - newValue := new[i] - - switch typedNew := newValue.(type) { - case map[string]interface{}: - if typedOld, ok := oldValue.(map[string]interface{}); ok { - result = append(result, Diff(typedOld, typedNew, indexPath...)...) - } else { - result = append(result, DiffEntry{Path: pathString, Old: oldValue, New: newValue}) - } - case []interface{}: - if typedOld, ok := oldValue.([]interface{}); ok { - result = append(result, diffArray(typedOld, typedNew, indexPath)...) - } else { - result = append(result, DiffEntry{Path: pathString, Old: oldValue, New: newValue}) - } - default: - if !reflect.DeepEqual(oldValue, newValue) { - result = append(result, DiffEntry{Path: pathString, Old: oldValue, New: newValue}) - } - } - } - } - - return result -} diff --git a/cmd/sst/mosaic/ui/error.go b/cmd/sst/mosaic/ui/error.go deleted file mode 100644 index a07f92d5a6..0000000000 --- a/cmd/sst/mosaic/ui/error.go +++ /dev/null @@ -1,59 +0,0 @@ -package ui - -import ( - "regexp" - "strings" -) - -func parseError(input string) []string { - input = strings.TrimRight(input, "\n") - if strings.Contains(input, "failed with an unhandled exception") { - input = regexp.MustCompile(`(?m)^Running program .*$\n?`).ReplaceAllString(input, "") - input = regexp.MustCompile(`\s*`).ReplaceAllString(input, "") - input = strings.TrimSpace(input) - lines := strings.Split(input, "\n") - - // Remove the "VisibleError: " prefix from the first line if it exists - if strings.HasPrefix(lines[0], "VisibleError: ") { - lines[0] = strings.TrimPrefix(lines[0], "VisibleError: ") - - // Find the first line that starts with spaces followed by "at" and - // remove that line and all following lines - for i, line := range lines { - trimmed := strings.TrimLeft(line, " ") - if strings.HasPrefix(trimmed, "at") { - // Remove all lines starting from this point - return lines[:i] - } - } - } - - return lines - } - - if strings.Contains(input, "occurred:") { - lines := []string{} - sections := strings.Split(input, "*") - for _, section := range sections[1:] { - for _, line := range strings.Split(section, "\n") { - line = strings.TrimSpace(line) - - // matches ExampleError: some thing went wrong - match := regexp.MustCompile(`\s[A-Z][a-zA-z]+\:.+`).FindString(line) - if match != "" { - lines = append(lines, strings.TrimSpace(match)) - continue - } - - // if json object is printed stop parsing - if line == "{" { - break - } - - lines = append(lines, line) - } - } - return lines - } - return []string{input} -} diff --git a/cmd/sst/mosaic/ui/error_test.go b/cmd/sst/mosaic/ui/error_test.go deleted file mode 100644 index 3fe25b1473..0000000000 --- a/cmd/sst/mosaic/ui/error_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package ui - -import ( - "reflect" - "testing" -) - -var examples = map[string][]string{ - "1 error occurred:\n\t* creating EventBridge Target (nextjs-frank-WebWarmerRule-WebWarmerTarget-1d76e5b): InvalidParameter: 1 validation error(s) found.\n- minimum field value of 60, PutTargetsInput.Targets[0].RetryPolicy.MaximumEventAgeInSeconds.\n\n\n\n": { - "InvalidParameter: 1 validation error(s) found.", - "- minimum field value of 60, PutTargetsInput.Targets[0].RetryPolicy.MaximumEventAgeInSeconds.", - }, - "1 error occurred:\n\t* creating Lambda Event Source Mapping (arn:aws:sqs:us-east-1:058264306954:stacks-ils-ion-aboza-BookEmbeddingQueueQueue): InvalidParameterValueException: Queue visibility timeout: 30 seconds is less than Function timeout: 900 seconds\n{\n RespMetadata: {\n StatusCode: 400,\n RequestID: \"4b3c8415-400f-437c-b1ea-af1a5c771c41\"\n },\n Message_: \"Queue visibility timeout: 30 seconds is less than Function timeout: 900 seconds\",\n Type: \"User\"\n}\n\n\n": { - "InvalidParameterValueException: Queue visibility timeout: 30 seconds is less than Function timeout: 900 seconds", - }, -} - -func TestParseError(t *testing.T) { - for input, expected := range examples { - result := parseError(input) - if !reflect.DeepEqual(result, expected) { - t.Errorf("Expected %v, got %v", expected, result) - } - } -} diff --git a/cmd/sst/mosaic/ui/footer.go b/cmd/sst/mosaic/ui/footer.go deleted file mode 100644 index 490a33367f..0000000000 --- a/cmd/sst/mosaic/ui/footer.go +++ /dev/null @@ -1,370 +0,0 @@ -package ui - -import ( - "bytes" - "context" - "fmt" - "os" - "slices" - "sort" - "strings" - "time" - - "github.com/charmbracelet/bubbles/spinner" - "github.com/charmbracelet/lipgloss" - "github.com/charmbracelet/x/ansi" - "github.com/pulumi/pulumi/sdk/v3/go/common/apitype" - "github.com/pulumi/pulumi/sdk/v3/go/common/resource" - "github.com/sst/sst/v3/cmd/sst/mosaic/deployer" - "github.com/sst/sst/v3/pkg/project" - "golang.org/x/crypto/ssh/terminal" -) - -type footer struct { - started bool - mode ProgressMode - complete *project.CompleteEvent - parents map[string]string - summary bool - pending []*apitype.ResourcePreEvent - downloading map[string]*apitype.ProgressEvent - skipped int - cancelled bool - - spinner int - - input chan any - - previous string -} - -type op struct { - urn string -} - -func NewFooter() *footer { - f := footer{ - input: make(chan any), - } - f.Reset() - return &f -} - -func (m *footer) Send(input any) { - m.input <- input -} - -type spinnerTick struct{} - -func (m *footer) Start(ctx context.Context) { - ticker := time.NewTicker(time.Millisecond * 100) - defer ticker.Stop() - go func() { - for range ticker.C { - m.Send(&spinnerTick{}) - } - }() - os.Stdout.WriteString("\033[2l") - os.Stdout.WriteString(ansi.HideCursor) - for { - select { - case <-ctx.Done(): - m.cancelled = true - break - case val, ok := <-m.input: - if !ok { - return - } - width, _, _ := terminal.GetSize(int(os.Stdout.Fd())) - switch evt := val.(type) { - case lineMsg: - m.clear() - fmt.Println(evt) - default: - m.Update(val) - } - next := m.View(width) - m.Render(width, next) - } - } -} - -func (m *footer) clear() { - if m.previous == "" { - return - } - oldLines := strings.Split(m.previous, "\n") - out := &bytes.Buffer{} - if len(oldLines) > 0 { - for i := range oldLines { - out.WriteString(ansi.EraseEntireLine) - if i < len(oldLines)-1 { - out.WriteString(ansi.CursorUp1) - } - } - } - os.Stdout.Write(out.Bytes()) - m.previous = "" -} - -func (m *footer) Render(width int, next string) { - if next == m.previous { - return - } - - var oldLines []string - if m.previous != "" { - oldLines = strings.Split(m.previous, "\n") - } - - var nextLines []string - if next != "" { - nextLines = strings.Split(next, "\n") - } - - out := &bytes.Buffer{} - - if len(oldLines) > 0 { - for i := range oldLines { - if i < len(oldLines)-len(nextLines) { - out.WriteString(ansi.EraseEntireLine) - } - if i < len(oldLines)-1 { - out.WriteString(ansi.CursorUp1) - } - } - } - - for i, line := range nextLines { - if i == 0 { - out.WriteByte('\r') - } - out.WriteString(ansi.Truncate(line, width, "…")) - out.WriteString(ansi.EraseLine(0)) - if i < len(nextLines)-1 { - out.WriteString("\r\n") - } - } - if out.Len() > 0 { - out.WriteString(ansi.CursorLeft(10000)) - os.Stdout.Write(out.Bytes()) - } - m.previous = next -} - -func (m *footer) Reset() { - m.started = false - m.skipped = 0 - m.parents = map[string]string{} - m.pending = []*apitype.ResourcePreEvent{} - m.downloading = map[string]*apitype.ProgressEvent{} - m.complete = nil - m.summary = false - m.cancelled = false -} - -func (m *footer) Update(msg any) { - switch msg := msg.(type) { - case *spinnerTick: - m.spinner++ - case *project.CancelledEvent: - m.cancelled = true - case *project.StackCommandEvent: - m.Reset() - m.started = true - if msg.Command == "diff" { - m.mode = ProgressModeDiff - } - if msg.Command == "refresh" { - m.mode = ProgressModeRefresh - } - if msg.Command == "remove" { - m.mode = ProgressModeRemove - } - if msg.Command == "deploy" { - m.mode = ProgressModeDeploy - } - case *project.CompleteEvent: - if msg.Old { - break - } - m.complete = msg - case *project.ConcurrentUpdateEvent: - m.Reset() - break - case *deployer.DeployFailedEvent: - m.Reset() - break - case *project.SkipEvent: - m.Reset() - break - case *apitype.ResourcePreEvent: - if slices.Contains(IGNORED_RESOURCES, msg.Metadata.Type) { - break - } - if msg.Metadata.Old != nil && msg.Metadata.Old.Parent != "" { - m.parents[msg.Metadata.URN] = msg.Metadata.Old.Parent - } - if msg.Metadata.New != nil && msg.Metadata.New.Parent != "" { - m.parents[msg.Metadata.URN] = msg.Metadata.New.Parent - } - if msg.Metadata.Op == apitype.OpSame || msg.Metadata.Op == apitype.OpRead { - m.skipped++ - } - if msg.Metadata.Op != apitype.OpSame && msg.Metadata.Op != apitype.OpRead { - m.pending = append(m.pending, msg) - } - case *apitype.ProgressEvent: - if msg.Type == apitype.PluginDownload { - m.downloading[msg.ID] = msg - } - case *apitype.SummaryEvent: - m.summary = true - case *apitype.ResOutputsEvent: - m.removePending(msg.Metadata.URN) - case *apitype.DiagnosticEvent: - if msg.URN != "" { - m.removePending(msg.URN) - } - } -} - -func (m *footer) Destroy() { - fmt.Print(ansi.ShowCursor) -} - -var TEXT_HIGHLIGHT = lipgloss.NewStyle().Foreground(lipgloss.Color("14")) -var TEXT_HIGHLIGHT_BOLD = TEXT_HIGHLIGHT.Copy().Bold(true) - -var SPINNER_STYLE = lipgloss.NewStyle().Foreground(lipgloss.Color("14")) - -var TEXT_DIM = lipgloss.NewStyle().Foreground(lipgloss.Color("8")) -var TEXT_DIM_BOLD = TEXT_DIM.Copy().Bold(true) -var TEXT_GRAY = lipgloss.NewStyle().Foreground(lipgloss.Color("245")) -var TEXT_GRAY_BOLD = TEXT_GRAY.Copy().Bold(true) - -var TEXT_NORMAL = lipgloss.NewStyle() -var TEXT_NORMAL_BOLD = TEXT_NORMAL.Copy().Bold(true) - -var TEXT_WARNING = lipgloss.NewStyle().Foreground(lipgloss.Color("11")) -var TEXT_WARNING_BOLD = TEXT_WARNING.Copy().Bold(true) -var TEXT_WARNING_DIM = lipgloss.NewStyle().Foreground(lipgloss.Color("3")) - -var TEXT_DANGER = lipgloss.NewStyle().Foreground(lipgloss.Color("1")) -var TEXT_DANGER_BOLD = TEXT_DANGER.Copy().Bold(true) - -var TEXT_SUCCESS = lipgloss.NewStyle().Foreground(lipgloss.Color("2")) -var TEXT_SUCCESS_BOLD = TEXT_SUCCESS.Copy().Bold(true) - -var TEXT_INFO = lipgloss.NewStyle().Foreground(lipgloss.Color("4")) -var TEXT_INFO_BOLD = TEXT_INFO.Copy().Bold(true) - -func (m *footer) View(width int) string { - if !m.started || m.complete != nil { - return "" - } - spinner := SPINNER_STYLE.Render(spinner.MiniDot.Frames[m.spinner%len(spinner.MiniDot.Frames)]) - result := []string{} - keys := make([]string, 0, len(m.downloading)) - for k := range m.downloading { - keys = append(keys, k) - } - sort.Strings(keys) - - for _, key := range keys { - progress := m.downloading[key] - if progress.Done { - continue - } - splits := strings.Split(progress.ID, ":") - percentage := int(float64(progress.Completed) / float64(progress.Total) * 100) - result = append(result, fmt.Sprintf("%s %-11s %s %d%%", spinner, "Downloading", splits[1], percentage)) - } - for _, r := range m.pending { - label := "Creating" - if r.Metadata.Op == apitype.OpUpdate { - label = "Updating" - } - if r.Metadata.Op == apitype.OpDelete { - label = "Deleting" - } - if r.Metadata.Op == apitype.OpReplace { - label = "Creating" - } - if r.Metadata.Op == apitype.OpRefresh { - label = "Refreshing" - } - if r.Metadata.Op == apitype.OpCreate { - label = "Creating" - } - result = append(result, fmt.Sprintf("%s %-11s %s", spinner, label, m.formatURN(r.Metadata.URN))) - } - label := "Finalizing" - if !m.summary { - if m.mode == ProgressModeDiff { - label = "Generating" - } - if m.mode == ProgressModeRemove { - label = "Removing" - } - if m.mode == ProgressModeRefresh { - label = "Refreshing" - } - if m.mode == ProgressModeDeploy { - label = "Deploying" - } - if m.cancelled { - label = "Cancelling Waiting for pending operations to complete. Press ctrl+c again to force cancel." - } - } - if m.skipped > 0 && !m.cancelled { - label = fmt.Sprintf("%-11s", label) - label += TEXT_DIM.Render(fmt.Sprintf(" %d skipped", m.skipped)) - } - result = append(result, spinner+" "+label) - return lipgloss.NewStyle().MaxWidth(width).Render(lipgloss.JoinVertical(lipgloss.Top, result...)) -} - -func (u *footer) removePending(urn string) { - next := []*apitype.ResourcePreEvent{} - for _, r := range u.pending { - if r.Metadata.URN == urn { - continue - } - next = append(next, r) - } - u.pending = next -} - -func (u *footer) formatURN(urn string) string { - if urn == "" { - return "" - } - - child := resource.URN(urn) - name := child.Name() - typeName := child.Type().DisplayName() - splits := strings.SplitN(child.Name(), ".", 2) - if len(splits) > 1 { - name = splits[0] - typeName = strings.ReplaceAll(splits[1], ".", ":") - } - result := name + " " + typeName - - for { - parent := resource.URN(u.parents[string(child)]) - if parent == "" { - break - } - if parent.Type().DisplayName() == "pulumi:pulumi:Stack" { - break - } - child = parent - } - if string(child) != urn { - result = child.Name() + " " + child.Type().DisplayName() + " → " + result - } - return result -} - -type lineMsg = string diff --git a/cmd/sst/mosaic/ui/logs.go b/cmd/sst/mosaic/ui/logs.go deleted file mode 100644 index 8ab7167ded..0000000000 --- a/cmd/sst/mosaic/ui/logs.go +++ /dev/null @@ -1,74 +0,0 @@ -package ui - -import ( - "encoding/json" -) - -func compactWorkflowLogLine(line string) (string, bool) { - var parsed map[string]any - if err := json.Unmarshal([]byte(line), &parsed); err != nil { - return "", false - } - - if !isWorkflowLogEnvelope(parsed) { - return "", false - } - - message, ok := parsed["message"] - if !ok { - return "", false - } - - switch value := message.(type) { - case string: - return value, true - default: - data, err := json.Marshal(value) - if err != nil { - return "", false - } - return string(data), true - } -} - -func isWorkflowLogEnvelope(parsed map[string]any) bool { - if _, hasMessage := parsed["message"]; !hasMessage { - return false - } - - if !hasStringField(parsed, "timestamp") { - return false - } - - if !hasStringField(parsed, "level") { - return false - } - - if !hasStringField(parsed, "requestId") && !hasStringField(parsed, "AWSrequestId") { - return false - } - - if hasStringField(parsed, "executionArn") { - return true - } - - if hasStringField(parsed, "execution_arn") { - return true - } - - return false -} - -func hasStringField(parsed map[string]any, key string) bool { - value, ok := parsed[key].(string) - return ok && value != "" -} - -func (u *UI) formatFunctionLogLine(line string) string { - formatted, ok := compactWorkflowLogLine(line) - if !ok { - return line - } - - return formatted -} diff --git a/cmd/sst/mosaic/ui/logs_test.go b/cmd/sst/mosaic/ui/logs_test.go deleted file mode 100644 index 33b7d0a07c..0000000000 --- a/cmd/sst/mosaic/ui/logs_test.go +++ /dev/null @@ -1,90 +0,0 @@ -package ui - -import ( - "testing" -) - -func TestCompactWorkflowLogLine(t *testing.T) { - tests := []struct { - name string - input string - expected string - ok bool - }{ - { - name: "plain text passthrough", - input: "Executing step 1: Hello from the invoker", - expected: "", - ok: false, - }, - { - name: "workflow string message", - input: `{"requestId":"a8220e1b-1f9b-4529-a40f-9e3419bc494f","timestamp":"2026-04-07T15:20:59.866Z","level":"INFO","executionArn":"arn:aws:lambda:us-east-1:123456789012:function:workflow","operationId":"c4ca4238a0b92382","attempt":1,"message":"Executing step 1: Hello from the invoker"}`, - expected: "Executing step 1: Hello from the invoker", - ok: true, - }, - { - name: "workflow object message", - input: `{"requestId":"a8220e1b-1f9b-4529-a40f-9e3419bc494f","timestamp":"2026-04-07T15:21:01.611Z","level":"INFO","executionArn":"arn:aws:lambda:us-east-1:123456789012:function:workflow","operationId":"eccbc87e4b5ce2fe","attempt":1,"message":{"callbackResult":"{\"message\":\"Hello from the invoker\"}","step1":"Hello from the invoker"}}`, - expected: `{"callbackResult":"{\"message\":\"Hello from the invoker\"}","step1":"Hello from the invoker"}`, - ok: true, - }, - { - name: "python workflow message", - input: `{"timestamp":"2026-04-07T15:21:01.611Z","level":"INFO","execution_arn":"arn:aws:lambda:us-east-1:123456789012:function:workflow","message":{"step":"complete","ok":true},"requestId":"req-123"}`, - expected: `{"ok":true,"step":"complete"}`, - ok: true, - }, - { - name: "raw user json passthrough", - input: `{"timestamp":"2026-04-07T15:21:01.611Z","level":"INFO","message":{"step":"complete","ok":true},"requestId":"req-123"}`, - expected: "", - ok: false, - }, - { - name: "custom json with execution arn passthrough", - input: `{"executionArn":"arn:aws:lambda:us-east-1:123456789012:function:workflow","message":{"step":"complete","ok":true}}`, - expected: "", - ok: false, - }, - { - name: "missing request id passthrough", - input: `{"timestamp":"2026-04-07T15:21:01.611Z","level":"INFO","executionArn":"arn:aws:lambda:us-east-1:123456789012:function:workflow","message":"hello"}`, - expected: "", - ok: false, - }, - { - name: "malformed json passthrough", - input: `{"timestamp":"2026-04-07T15:21:01.611Z","message":`, - expected: "", - ok: false, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - actual, ok := compactWorkflowLogLine(tt.input) - if ok != tt.ok { - t.Fatalf("expected ok=%v, got %v", tt.ok, ok) - } - if actual != tt.expected { - t.Fatalf("expected %q, got %q", tt.expected, actual) - } - }) - } -} - -func TestFormatFunctionLogLine(t *testing.T) { - line := `{"timestamp":"2026-04-07T15:20:59.866Z","level":"INFO","executionArn":"arn:aws:lambda:us-east-1:123456789012:function:workflow","message":"Executing step 1: Hello from the invoker","requestId":"req-123"}` - - u := &UI{} - - if actual := u.formatFunctionLogLine(line); actual != "Executing step 1: Hello from the invoker" { - t.Fatalf("expected compacted workflow log, got %q", actual) - } - - rawJSON := `{"timestamp":"2026-04-07T15:20:59.866Z","level":"INFO","message":{"user":true},"requestId":"req-123"}` - if actual := u.formatFunctionLogLine(rawJSON); actual != rawJSON { - t.Fatalf("expected raw user json to be unchanged, got %q", actual) - } -} diff --git a/cmd/sst/mosaic/ui/ui.go b/cmd/sst/mosaic/ui/ui.go deleted file mode 100644 index 0a17f05d49..0000000000 --- a/cmd/sst/mosaic/ui/ui.go +++ /dev/null @@ -1,727 +0,0 @@ -package ui - -import ( - "context" - "encoding/json" - "fmt" - "log/slog" - "net/url" - "os" - "slices" - "strings" - "time" - "unicode" - - "github.com/charmbracelet/lipgloss" - "github.com/charmbracelet/x/ansi" - "github.com/pulumi/pulumi/sdk/v3/go/common/apitype" - "github.com/pulumi/pulumi/sdk/v3/go/common/resource" - "github.com/sst/sst/v3/cmd/sst/mosaic/aws" - "github.com/sst/sst/v3/cmd/sst/mosaic/cloudflare" - "github.com/sst/sst/v3/cmd/sst/mosaic/deployer" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui/common" - "github.com/sst/sst/v3/pkg/flag" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/types/typescript" - - "golang.org/x/crypto/ssh/terminal" -) - -type ProgressMode string - -var IGNORED_RESOURCES = []string{"sst:sst:Version", "sst:sst:LinkRef", "pulumi:pulumi:Stack"} - -const ( - ProgressModeDeploy ProgressMode = "deploy" - ProgressModeRemove ProgressMode = "remove" - ProgressModeRefresh ProgressMode = "refresh" - ProgressModeDiff ProgressMode = "diff" -) - -const ( - IconX = "✕" - IconCheck = "✓" -) - -type UI struct { - mode ProgressMode - dedupe map[string]bool - timing map[string]time.Time - parents map[string]string - workerTime map[string]time.Time - complete *project.CompleteEvent - footer *footer - buffer []interface{} - hasBlank bool - hasHeader bool - options *Options - log *os.File -} - -type Options struct { - Silent bool - Log *os.File - Filter string -} - -type PaneFilterEvent struct { - PaneKey string `json:"paneKey"` - Value string `json:"value"` -} - -type Option func(*Options) - -func WithSilent(u *Options) { - u.Silent = true -} - -func (u *UI) SetFilter(filter string, paneKey string) { - icons := map[string]string{"function": "λ", "task": "⧉"} - icon := icons[paneKey] - u.options.Filter = filter - u.blank() - if filter != "" { - u.println(TEXT_HIGHLIGHT.Render(icon), " ", TEXT_NORMAL_BOLD.Render("Filter"), " ", TEXT_GRAY.Render(filter)) - } else { - u.println(TEXT_DANGER.Render(icon), " ", TEXT_NORMAL_BOLD.Render("Filter"), " ", TEXT_DIM.Render("Removed")) - } - u.blank() -} - -func WithLog(file *os.File) Option { - return func(opts *Options) { - opts.Log = file - } -} - -func New(ctx context.Context, options ...Option) *UI { - opts := &Options{} - for _, option := range options { - option(opts) - } - isTTY := terminal.IsTerminal(int(os.Stdout.Fd())) - slog.Info("initializing ui", "isTTY", isTTY) - result := &UI{ - workerTime: map[string]time.Time{}, - hasBlank: false, - options: opts, - } - if opts.Log != nil { - result.log = opts.Log - } - if isTTY && !opts.Silent { - result.footer = NewFooter() - go result.footer.Start(ctx) - } - result.reset() - return result -} - -func (u *UI) print(args ...interface{}) { - u.buffer = append(u.buffer, args...) -} - -func (u *UI) printf(tmpl string, args ...interface{}) { - u.buffer = append(u.buffer, fmt.Sprintf(tmpl, args...)) -} - -func (u *UI) println(args ...interface{}) { - u.buffer = append(u.buffer, args...) - line := fmt.Sprint(u.buffer...) - if u.footer == nil { - fmt.Println(line) - } - if u.footer != nil { - u.footer.Send(lineMsg(line)) - } - if u.log != nil { - stripped := ansi.Strip(line) - u.log.WriteString(stripped + "\n") - } - u.buffer = []interface{}{} - u.hasBlank = false -} - -func (u *UI) blank() { - if u.hasBlank { - return - } - u.println() - u.hasBlank = true -} - -func (u *UI) reset() { - u.complete = nil - u.parents = map[string]string{} - u.dedupe = map[string]bool{} - u.timing = map[string]time.Time{} - u.buffer = []interface{}{} -} - -func (u *UI) Event(unknown interface{}) { - if u.footer != nil { - defer u.footer.Send(unknown) - } - switch evt := unknown.(type) { - - case *common.StdoutEvent: - u.println(evt.Line) - - case *aws.TaskProvisionEvent: - if !u.matchFilter(evt.Name) { - return - } - u.printEvent(GetColor(""), fmt.Sprintf("%-11s", "Provision"), evt.Name) - - case *aws.TaskStartEvent: - if !u.matchFilter(evt.TaskID) { - return - } - u.workerTime[evt.WorkerID] = time.Now() - u.printEvent(GetColor(evt.WorkerID), fmt.Sprintf("%-11s", "Start"), evt.Command) - - case *aws.TaskLogEvent: - if !u.matchFilter(evt.TaskID) { - return - } - duration := time.Since(u.workerTime[evt.WorkerID]).Round(time.Millisecond) - formattedDuration := fmt.Sprintf("%.9s", fmt.Sprintf("+%v", duration)) - u.printEvent(GetColor(evt.WorkerID), formattedDuration, evt.Line) - - case *aws.TaskCompleteEvent: - if !u.matchFilter(evt.TaskID) { - return - } - duration := time.Since(u.workerTime[evt.WorkerID]).Round(time.Millisecond) - formattedDuration := fmt.Sprintf("took %.9s", fmt.Sprintf("+%v", duration)) - u.printEvent(GetColor(evt.WorkerID), "Done", formattedDuration) - - case *aws.TaskMissingCommandEvent: - if !u.matchFilter(evt.Name) { - return - } - u.printEvent(TEXT_DANGER, fmt.Sprintf("%-11s", "Missing"), fmt.Sprintf("Dev command not configured for the \"%s\" task. Set `dev.command` to configure how the task works in `sst dev`.", evt.Name)) - - case *aws.FunctionInvokedEvent: - if !u.matchFilter(evt.FunctionID) { - return - } - u.workerTime[evt.WorkerID] = time.Now() - u.printEvent(GetColor(evt.WorkerID), TEXT_NORMAL_BOLD.Render(fmt.Sprintf("%-11s", "Invoke")), u.functionName(evt.FunctionID)) - - case *aws.FunctionResponseEvent: - if !u.matchFilter(evt.FunctionID) { - return - } - duration := time.Since(u.workerTime[evt.WorkerID]).Round(time.Millisecond) - formattedDuration := fmt.Sprintf("took %.9s", fmt.Sprintf("+%v", duration)) - u.printEvent(GetColor(evt.WorkerID), "Done", formattedDuration) - - case *aws.FunctionLogEvent: - if !u.matchFilter(evt.FunctionID) { - return - } - duration := time.Since(u.workerTime[evt.WorkerID]).Round(time.Millisecond) - formattedDuration := fmt.Sprintf("%.9s", fmt.Sprintf("+%v", duration)) - u.printEvent(GetColor(evt.WorkerID), formattedDuration, u.formatFunctionLogLine(evt.Line)) - - case *aws.FunctionBuildEvent: - if !u.matchFilter(evt.FunctionID) { - return - } - if len(evt.Errors) > 0 { - u.printEvent(TEXT_DANGER, "Build Error", u.functionName(evt.FunctionID)) - for _, item := range evt.Errors { - u.printEvent(TEXT_DANGER, "", " "+strings.TrimSpace(item)) - } - return - } - u.printEvent(TEXT_SUCCESS, "Build", u.functionName(evt.FunctionID)) - - case *aws.FunctionErrorEvent: - if !u.matchFilter(evt.FunctionID) { - return - } - u.printEvent(GetColor(evt.WorkerID), TEXT_DANGER.Render(fmt.Sprintf("%-11s", "Error")), u.functionName(evt.FunctionID)) - u.printEvent(GetColor(evt.WorkerID), "", evt.ErrorMessage) - for _, item := range evt.Trace { - if strings.Contains(item, "Error:") { - continue - } - u.printEvent(GetColor(evt.WorkerID), "", "↳ "+strings.TrimSpace(item)) - } - - case *project.ConcurrentUpdateEvent: - u.reset() - u.printEvent(TEXT_DANGER, "Locked", "A concurrent update was detected on the app. Run `sst unlock` to remove the lock and try again.") - - case *deployer.DeployFailedEvent: - u.reset() - if evt.Error != "" { - u.printEvent(TEXT_DANGER, "Error", evt.Error) - } - - case *project.PolicyAdvisoryEvent: - u.printEvent(TEXT_WARNING, "Warning", u.FormatURN(evt.URN)+" "+evt.Policy+": "+evt.Message) - - case *typescript.WarningEvent: - u.printEvent(TEXT_WARNING, "Warning", evt.Message) - - case *project.StackCommandEvent: - u.reset() - u.header(evt.Version, evt.App, evt.Stage) - u.blank() - if evt.Command == "deploy" { - u.mode = ProgressModeDeploy - u.println( - TEXT_WARNING_BOLD.Render("~"), - TEXT_NORMAL_BOLD.Render(" Deploy"), - ) - } - if evt.Command == "remove" { - u.mode = ProgressModeRemove - u.println( - TEXT_DANGER_BOLD.Render("~"), - TEXT_NORMAL_BOLD.Render(" Remove"), - ) - } - if evt.Command == "refresh" { - u.mode = ProgressModeRefresh - u.println( - TEXT_INFO_BOLD.Render("~"), - TEXT_NORMAL_BOLD.Render(" Refresh"), - ) - } - if evt.Command == "diff" { - u.mode = ProgressModeDiff - u.println( - TEXT_INFO_BOLD.Render("~"), - TEXT_NORMAL_BOLD.Render(" Diff"), - ) - } - u.blank() - - case *project.BuildFailedEvent: - u.reset() - u.printEvent(TEXT_DANGER, "Error", evt.Error) - break - - case *project.SkipEvent: - u.println( - TEXT_INFO_BOLD.Render("~"), - TEXT_NORMAL_BOLD.Render(" No changes"), - ) - u.reset() - break - - case *apitype.ResourcePreEvent: - u.timing[evt.Metadata.URN] = time.Now() - if slices.Contains(IGNORED_RESOURCES, evt.Metadata.Type) { - return - } - - if evt.Metadata.Old != nil && evt.Metadata.Old.Parent != "" { - u.parents[evt.Metadata.URN] = evt.Metadata.Old.Parent - } - - if evt.Metadata.New != nil && evt.Metadata.New.Parent != "" { - u.parents[evt.Metadata.URN] = evt.Metadata.New.Parent - } - - if evt.Metadata.Op == apitype.OpSame { - return - } - - case *apitype.ResOpFailedEvent: - break - - case *apitype.ResOutputsEvent: - if slices.Contains(IGNORED_RESOURCES, evt.Metadata.Type) { - return - } - - duration := time.Since(u.timing[evt.Metadata.URN]).Round(time.Millisecond) - if evt.Metadata.Op == apitype.OpSame && u.mode == ProgressModeRefresh { - u.printProgress( - TEXT_SUCCESS, - "Refreshed", - duration, - evt.Metadata.URN, - ) - return - } - if evt.Metadata.Op == apitype.OpImport { - u.printProgress( - TEXT_SUCCESS, - "Imported", - duration, - evt.Metadata.URN, - ) - } - if evt.Metadata.Op == apitype.OpCreate { - u.printProgress( - TEXT_SUCCESS, - "Created", - duration, - evt.Metadata.URN, - ) - } - if evt.Metadata.Op == apitype.OpUpdate { - u.printProgress( - TEXT_SUCCESS, - "Updated", - duration, - evt.Metadata.URN, - ) - } - if evt.Metadata.Op == apitype.OpDelete { - u.printProgress( - TEXT_DIM, - "Deleted", - duration, - evt.Metadata.URN, - ) - } - if evt.Metadata.Op == apitype.OpDeleteReplaced { - u.printProgress( - TEXT_DIM, - "Deleted", - duration, - evt.Metadata.URN, - ) - } - if evt.Metadata.Op == apitype.OpCreateReplacement { - u.printProgress( - TEXT_SUCCESS, - "Created", - duration, - evt.Metadata.URN, - ) - } - if evt.Metadata.Op == apitype.OpReplace { - } - - case *apitype.DiagnosticEvent: - if evt.Severity == "error" { - message := []string{u.FormatURN(evt.URN)} - message = append(message, parseError(strings.TrimSpace(evt.Message))...) - u.printEvent(TEXT_DANGER, "Error", message...) - } - - if evt.Severity == "info" { - for _, line := range strings.Split(strings.TrimRightFunc(ansi.Strip(evt.Message), unicode.IsSpace), "\n") { - u.println(TEXT_DIM.Render(line)) - } - } - - if evt.Severity == "info#err" { - u.println(strings.TrimRightFunc(ansi.Strip(evt.Message), unicode.IsSpace)) - } - - case *apitype.ProgressEvent: - if evt.Done && evt.Type == apitype.PluginDownload { - splits := strings.Split(evt.ID, ":") - u.printEvent(TEXT_INFO, "Info", "Downloaded provider "+splits[1]) - } - - case *project.CompleteEvent: - u.complete = evt - if evt.Old { - break - } - - u.blank() - if len(evt.Errors) == 0 && evt.Finished { - u.print(TEXT_SUCCESS_BOLD.Render(IconCheck)) - if len(u.timing) == 0 { - if u.mode == ProgressModeRemove { - u.print(TEXT_NORMAL_BOLD.Render(" No resources to remove")) - } else { - u.print(TEXT_NORMAL_BOLD.Render(" No changes")) - } - } - if len(u.timing) > 0 { - label := "" - if u.mode == ProgressModeRemove { - label = "Removed" - } - if u.mode == ProgressModeDeploy { - label = "Complete" - } - if u.mode == ProgressModeRefresh { - label = "Refreshed" - } - if u.mode == ProgressModeDiff { - label = "Generated" - } - u.print(TEXT_NORMAL_BOLD.Render(" " + label + " ")) - } - u.println() - if len(evt.Hints) > 0 { - for k, v := range evt.Hints { - splits := strings.Split(k, "::") - u.println( - TEXT_GRAY_BOLD.Render(" "), - TEXT_GRAY_BOLD.Render(splits[len(splits)-1]+": "), - TEXT_NORMAL.Render(v), - ) - } - } - if len(evt.Outputs) > 0 { - if len(evt.Hints) > 0 { - u.println(TEXT_GRAY_BOLD.Render(" ---")) - } - for k, v := range evt.Outputs { - u.println( - TEXT_GRAY_BOLD.Render(" "), - TEXT_GRAY_BOLD.Render(k+": "), - TEXT_NORMAL.Render(fmt.Sprint(v)), - ) - } - } - } - if len(evt.Errors) == 0 && !evt.Finished { - u.println( - TEXT_DANGER_BOLD.Render(IconX), - TEXT_NORMAL_BOLD.Render(" Interrupted "), - ) - } - if len(evt.Errors) > 0 { - u.println( - TEXT_DANGER_BOLD.Render(IconX), - TEXT_NORMAL_BOLD.Render(" Failed "), - ) - - u.blank() - for _, status := range evt.Errors { - if status.URN != "" { - u.println(TEXT_DANGER_BOLD.Render(u.FormatURN(status.URN))) - } - for _, line := range parseError(status.Message) { - u.println(TEXT_NORMAL.Render(line)) - } - for i, line := range status.Help { - if i == 0 { - u.println() - } - u.println(TEXT_NORMAL.Render(line)) - } - - importDiffs, ok := evt.ImportDiffs[status.URN] - if ok { - isSSTComponent := strings.Contains(status.URN, "::sst") - if isSSTComponent { - u.println(TEXT_NORMAL.Render("\n\nSet the following in your transform:")) - } - if !isSSTComponent { - u.println(TEXT_NORMAL.Render("\n\nSet the following:")) - } - for _, diff := range importDiffs { - value, _ := json.Marshal(diff.Old) - if diff.Old == nil { - value = []byte("undefined") - } - u.print(TEXT_NORMAL.Render(" - ")) - if isSSTComponent { - u.print(TEXT_INFO.Render("`args." + string(diff.Input) + " = " + string(value) + ";`")) - } - if !isSSTComponent { - u.print(TEXT_INFO.Render("`" + string(diff.Input) + ": " + string(value) + ",`")) - } - u.blank() - } - } else { - u.blank() - } - } - - } - u.blank() - case *cloudflare.WorkerBuildEvent: - if !u.matchFilter(evt.WorkerID) { - return - } - if len(evt.Errors) > 0 { - u.printEvent(TEXT_DANGER, "Build Error", u.functionName(evt.WorkerID)+" "+strings.Join(evt.Errors, "\n")) - return - } - u.printEvent(TEXT_INFO, "Build", u.functionName(evt.WorkerID)) - case *cloudflare.WorkerUpdatedEvent: - if !u.matchFilter(evt.WorkerID) { - return - } - u.printEvent(TEXT_INFO, "Reload", u.functionName(evt.WorkerID)) - case *cloudflare.WorkerInvokedEvent: - if !u.matchFilter(evt.WorkerID) { - return - } - url, _ := url.Parse(evt.TailEvent.Event.Request.URL) - u.printEvent( - GetColor(evt.WorkerID), - TEXT_NORMAL_BOLD.Render(fmt.Sprintf("%-11s", "Invoke")), - u.functionName(evt.WorkerID)+" "+evt.TailEvent.Event.Request.Method+" "+url.Path, - ) - for _, log := range evt.TailEvent.Logs { - duration := time.UnixMilli(log.Timestamp).Sub(time.UnixMilli(evt.TailEvent.EventTimestamp)) - formattedDuration := fmt.Sprintf("%.9s", fmt.Sprintf("+%v", duration)) - - line := []string{} - for _, part := range log.Message { - switch v := part.(type) { - case string: - line = append(line, v) - case map[string]interface{}: - data, _ := json.Marshal(v) - line = append(line, string(data)) - } - } - - for _, item := range strings.Split(strings.Join(line, " "), "\n") { - u.printEvent(GetColor(evt.WorkerID), formattedDuration, item) - } - } - u.printEvent(GetColor(evt.WorkerID), "Done", evt.TailEvent.Outcome) - } - -} - -var Colors = []lipgloss.Style{ - lipgloss.NewStyle().Foreground(lipgloss.Color("13")), - lipgloss.NewStyle().Foreground(lipgloss.Color("14")), - lipgloss.NewStyle().Foreground(lipgloss.Color("2")), - lipgloss.NewStyle().Foreground(lipgloss.Color("12")), -} - -func GetColor(input string) lipgloss.Style { - hash := 0 - for _, c := range input { - hash += int(c) - } - return Colors[hash%len(Colors)] -} - -func (u *UI) functionName(functionID string) string { - if u.complete == nil { - return functionID - } - for _, resource := range u.complete.Resources { - if resource.Type == "sst:aws:Function" && resource.URN.Name() == functionID { - return strings.TrimPrefix(resource.Outputs["_metadata"].(map[string]interface{})["handler"].(string), "./") - } - if resource.Type == "sst:cloudflare:Worker" && resource.URN.Name() == functionID { - return strings.TrimPrefix(resource.Outputs["_metadata"].(map[string]interface{})["handler"].(string), "./") - } - } - return functionID -} - -func (u *UI) printProgress(barColor lipgloss.Style, label string, duration time.Duration, urn string) { - message := u.FormatURN(urn) - if duration > time.Second { - message += fmt.Sprintf(" (%.1fs)", duration.Seconds()) - } - u.printEvent(barColor, label, message) -} - -func (u *UI) printEvent(barColor lipgloss.Style, label string, message ...string) { - u.print(barColor.Copy().Bold(true).Render("| ")) - if label != "" { - u.print(TEXT_DIM.Render(fmt.Sprint(fmt.Sprintf("%-11s", label), " "))) - } - if len(message) > 0 { - u.print(TEXT_NORMAL.Render(message[0])) - } - u.println() - for _, msg := range message[1:] { - u.println(TEXT_NORMAL.Render(msg)) - } -} - -func (u *UI) Destroy() { - if u.footer != nil { - u.footer.Destroy() - } - if u.log != nil { - u.log.Close() - } -} - -func (u *UI) header(version, app, stage string) { - if u.hasHeader { - return - } - if flag.SST_EXPERIMENTAL { - version = version + " (experimental)" - } - u.println( - TEXT_HIGHLIGHT_BOLD.Render("SST "+version), - TEXT_GRAY.Render(" ready!"), - ) - u.blank() - u.println( - TEXT_HIGHLIGHT_BOLD.Render("➜ "), - TEXT_NORMAL_BOLD.Render(fmt.Sprintf("%-12s", "App:")), - TEXT_GRAY.Render(app), - ) - u.println( - TEXT_NORMAL_BOLD.Render(fmt.Sprintf(" %-12s", "Stage:")), - TEXT_GRAY.Render(stage), - ) - - u.blank() - u.hasHeader = true -} - -func (u *UI) FormatURN(urn string) string { - if urn == "" { - return "" - } - - child := resource.URN(urn) - name := child.Name() - typeName := child.Type().DisplayName() - splits := strings.SplitN(child.Name(), ".", 2) - if len(splits) > 1 { - name = splits[0] - typeName = strings.ReplaceAll(splits[1], ".", ":") - } - result := name + " " + typeName - - for { - parent := resource.URN(u.parents[string(child)]) - if parent == "" { - break - } - if slices.Contains(IGNORED_RESOURCES, parent.Type().DisplayName()) { - break - } - child = parent - } - if string(child) != urn { - result = child.Name() + " " + child.Type().DisplayName() + " → " + result - } - return result -} - -func Success(msg string) { - fmt.Fprintln(os.Stderr, strings.TrimSpace(TEXT_SUCCESS_BOLD.Render(IconCheck)+" "+TEXT_NORMAL.Render(msg))) -} - -func Error(msg string) { - fmt.Fprintln(os.Stderr, strings.TrimSpace(TEXT_DANGER_BOLD.Render(IconX)+" "+TEXT_NORMAL.Render(msg))) -} - -func (u *UI) matchFilter(id string) bool { - if u.options.Filter == "" { - return true - } - filter := strings.ToLower(u.options.Filter) - if strings.Contains(strings.ToLower(id), filter) { - return true - } - name := u.functionName(id) - if strings.Contains(strings.ToLower(name), filter) { - return true - } - return false -} diff --git a/cmd/sst/mosaic/watcher/watcher.go b/cmd/sst/mosaic/watcher/watcher.go deleted file mode 100644 index 48176d8dbf..0000000000 --- a/cmd/sst/mosaic/watcher/watcher.go +++ /dev/null @@ -1,380 +0,0 @@ -package watcher - -import ( - "context" - "log/slog" - "os" - pathpkg "path" - "path/filepath" - "strings" - "time" - - "github.com/fsnotify/fsnotify" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" -) - -type FileChangedEvent struct { - Path string -} - -type WatchConfig struct { - Root string - Watch project.Watch -} - -type fileChange struct { - timestamp time.Time - discovered bool -} - -func resolveWatch(root string, watch project.Watch) ([]string, []string, error) { - root = filepath.Clean(root) - paths := watch.Paths - if watch.UsesLegacyArray() { - var err error - paths, err = expandLegacyPaths(root, paths) - if err != nil { - return nil, nil, err - } - } - - roots, err := resolveRoots(root, paths) - if err != nil { - return nil, nil, err - } - - ignore := make([]string, 0, len(watch.Ignore)) - for _, path := range watch.Ignore { - ignore = append(ignore, normalizePath(path)) - } - - return roots, ignore, nil -} - -func expandLegacyPaths(root string, paths []string) ([]string, error) { - expanded := make([]string, 0, len(paths)) - seen := map[string]bool{} - for _, path := range paths { - matches := []string{path} - if strings.ContainsAny(path, "*?[") { - resolved, err := filepath.Glob(filepath.Join(root, filepath.FromSlash(path))) - if err != nil { - return nil, err - } - matches = nil - for _, match := range resolved { - watchPath, err := legacyWatchPath(root, match) - if err != nil { - return nil, err - } - matches = append(matches, watchPath) - } - } - - for _, match := range matches { - match = filepath.ToSlash(filepath.Clean(match)) - if seen[match] { - continue - } - seen[match] = true - expanded = append(expanded, match) - } - } - - return expanded, nil -} - -func legacyWatchPath(root string, path string) (string, error) { - resolved := path - if !filepath.IsAbs(resolved) { - resolved = filepath.Join(root, filepath.FromSlash(path)) - } - - info, err := os.Stat(resolved) - if err == nil && !info.IsDir() { - resolved = filepath.Dir(resolved) - } - if err != nil && !os.IsNotExist(err) { - return "", err - } - - rel, err := filepath.Rel(root, resolved) - if err != nil { - return "", err - } - - return filepath.ToSlash(rel), nil -} - -func resolveRoots(root string, paths []string) ([]string, error) { - if len(paths) == 0 { - paths = []string{"."} - } - - seen := map[string]bool{} - var roots []string - - for _, path := range paths { - resolved := filepath.Clean(filepath.Join(root, filepath.FromSlash(path))) - if seen[resolved] { - continue - } - - info, err := os.Stat(resolved) - if err != nil { - if os.IsNotExist(err) { - continue - } - return nil, err - } - - if !info.IsDir() { - continue - } - - seen[resolved] = true - roots = append(roots, resolved) - } - - return roots, nil -} - -func shouldSkipDir(root string, ignore []string, path string, info os.FileInfo) bool { - if !info.IsDir() { - return false - } - - if strings.HasPrefix(info.Name(), ".") { - return true - } - - if strings.Contains(path, "node_modules") { - return true - } - - return isIgnored(root, ignore, path) -} - -func isIgnored(root string, ignore []string, path string) bool { - if len(ignore) == 0 { - return false - } - - rel, err := filepath.Rel(root, path) - if err != nil { - return false - } - - rel = normalizePath(rel) - for _, prefix := range ignore { - if matchesIgnore(prefix, rel) { - return true - } - } - - return false -} - -func matchesIgnore(pattern string, path string) bool { - if pattern == "." { - return true - } - - if strings.Contains(pattern, "/") { - return path == pattern || strings.HasPrefix(path, pattern+"/") - } - - for part := range strings.SplitSeq(path, "/") { - matched, err := pathpkg.Match(pattern, part) - if err == nil && matched { - return true - } - } - - return false -} - -func isWatchedPath(roots []string, path string) bool { - for _, root := range roots { - if isWithinPath(root, path) { - return true - } - } - - return false -} - -func shouldWatchDir(projectRoot string, roots []string, path string) bool { - if filepath.Clean(path) == filepath.Clean(projectRoot) { - return true - } - if isWatchedPath(roots, path) { - return true - } - if !isWithinPath(projectRoot, path) { - return false - } - - for _, root := range roots { - if isWithinPath(path, root) { - return true - } - } - - return false -} - -func normalizePath(path string) string { - path = filepath.ToSlash(filepath.Clean(path)) - if path == "./" { - return "." - } - return strings.TrimPrefix(path, "./") -} - -func Start(ctx context.Context, config WatchConfig) error { - log := slog.Default().With("service", "watcher") - log.Info("starting", "root", config.Root) - defer log.Info("done") - - roots, ignore, err := resolveWatch(config.Root, config.Watch) - if err != nil { - return err - } - watcher, err := fsnotify.NewWatcher() - if err != nil { - return err - } - defer watcher.Close() - - err = watcher.AddWith(config.Root) - if err != nil { - return err - } - - limiter := map[string]fileChange{} - - publishChange := func(path string, discovered bool) { - last, ok := limiter[path] - if ok && time.Since(last.timestamp) <= 500*time.Millisecond { - if discovered || !last.discovered { - return - } - } - - limiter[path] = fileChange{timestamp: time.Now(), discovered: discovered} - bus.Publish(&FileChangedEvent{Path: path}) - } - - watchTree := func(path string, publish bool) error { - return filepath.Walk(path, func(path string, info os.FileInfo, err error) error { - if err != nil { - if os.IsNotExist(err) { - return nil - } - return err - } - - if info.IsDir() { - if shouldSkipDir(config.Root, ignore, path, info) { - return filepath.SkipDir - } - if !shouldWatchDir(config.Root, roots, path) { - return filepath.SkipDir - } - - log.Info("watching", "path", path) - return watcher.Add(path) - } - - if publish && isWatchedPath(roots, path) && !isIgnored(config.Root, ignore, path) { - log.Info("discovered new file in directory", "path", path) - publishChange(path, true) - } - - return nil - }) - } - - err = watchTree(config.Root, false) - if err != nil { - return err - } - - for _, match := range roots { - if isWithinPath(config.Root, match) { - continue - } - err = watchTree(match, false) - if err != nil { - return err - } - } - - headFile := filepath.Join(config.Root, ".git/HEAD") - watcher.Add(headFile) - for { - select { - case event, ok := <-watcher.Events: - if !ok { - return nil - } - if event.Op&(fsnotify.Write|fsnotify.Create) == 0 { - log.Info("ignoring file event", "path", event.Name, "op", event.Op) - continue - } - if event.Op&fsnotify.Create != 0 { - info, err := os.Stat(event.Name) - if err != nil && !os.IsNotExist(err) { - return err - } - if err == nil && info.IsDir() { - if shouldSkipDir(config.Root, ignore, event.Name, info) || !shouldWatchDir(config.Root, roots, event.Name) { - log.Info("ignoring created directory", "path", event.Name) - continue - } - - err = watchTree(event.Name, true) - if err != nil { - return err - } - - // Catch nested dirs/files created while fsnotify attaches to the new dir. - select { - case <-time.After(50 * time.Millisecond): - case <-ctx.Done(): - return nil - } - err = watchTree(event.Name, true) - if err != nil { - return err - } - continue - } - } - if !isWatchedPath(roots, event.Name) { - log.Info("ignoring unwatched file event", "path", event.Name, "op", event.Op) - continue - } - if isIgnored(config.Root, ignore, event.Name) { - log.Info("ignoring ignored file event", "path", event.Name, "op", event.Op) - continue - } - log.Info("file event", "path", event.Name, "op", event.Op) - publishChange(event.Name, false) - case <-ctx.Done(): - return nil - } - } -} - -func isWithinPath(root string, path string) bool { - rel, err := filepath.Rel(root, path) - if err != nil { - return false - } - - rel = normalizePath(rel) - return rel == "." || (!strings.HasPrefix(rel, "../") && rel != "..") -} diff --git a/cmd/sst/mosaic/watcher/watcher_test.go b/cmd/sst/mosaic/watcher/watcher_test.go deleted file mode 100644 index 3b645b1c66..0000000000 --- a/cmd/sst/mosaic/watcher/watcher_test.go +++ /dev/null @@ -1,284 +0,0 @@ -package watcher - -import ( - "context" - "encoding/json" - "os" - "path/filepath" - "testing" - "time" - - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestResolveWatchDefaultsToProjectRoot(t *testing.T) { - root := t.TempDir() - roots, ignore, err := resolveWatch(root, project.Watch{}) - require.NoError(t, err) - assert.Equal(t, []string{root}, roots) - assert.False(t, isIgnored(root, ignore, filepath.Join(root, "sst.config.ts"))) -} - -func TestResolveWatchResolvesExternalIncludeRoots(t *testing.T) { - workspace := t.TempDir() - root := filepath.Join(workspace, "app") - external := filepath.Join(workspace, "external-package") - require.NoError(t, os.MkdirAll(filepath.Join(root, "packages", "api"), 0755)) - require.NoError(t, os.MkdirAll(external, 0755)) - - roots, _, err := resolveWatch(root, project.Watch{ - Paths: []string{"packages/api", "../external-package"}, - }) - require.NoError(t, err) - assert.ElementsMatch(t, []string{filepath.Join(root, "packages", "api"), external}, roots) -} - -func TestResolveWatchExpandsLegacyArrayGlobs(t *testing.T) { - root := t.TempDir() - require.NoError(t, os.MkdirAll(filepath.Join(root, "packages", "api"), 0755)) - require.NoError(t, os.MkdirAll(filepath.Join(root, "packages", "web"), 0755)) - - var watch project.Watch - require.NoError(t, json.Unmarshal([]byte(`["packages/*"]`), &watch)) - - roots, _, err := resolveWatch(root, watch) - require.NoError(t, err) - assert.ElementsMatch(t, []string{filepath.Join(root, "packages", "api"), filepath.Join(root, "packages", "web")}, roots) -} - -func TestResolveWatchExpandsLegacyArrayFileGlobsToParentDirs(t *testing.T) { - root := t.TempDir() - require.NoError(t, os.MkdirAll(filepath.Join(root, "src"), 0755)) - require.NoError(t, os.WriteFile(filepath.Join(root, "src", "index.ts"), []byte("export {}\n"), 0644)) - - var watch project.Watch - require.NoError(t, json.Unmarshal([]byte(`["src/*"]`), &watch)) - - roots, _, err := resolveWatch(root, watch) - require.NoError(t, err) - assert.Equal(t, []string{filepath.Join(root, "src")}, roots) -} - -func TestResolveWatchMatchesIgnorePaths(t *testing.T) { - workspace := t.TempDir() - root := filepath.Join(workspace, "app") - external := filepath.Join(workspace, "external-package") - require.NoError(t, os.MkdirAll(filepath.Join(root, "packages", "api", "generated"), 0755)) - require.NoError(t, os.MkdirAll(filepath.Join(external, "dist"), 0755)) - - _, ignore, err := resolveWatch(root, project.Watch{ - Ignore: []string{"packages/api/generated", "../external-package/dist"}, - }) - require.NoError(t, err) - - generated := mustInfo(t, filepath.Join(root, "packages", "api", "generated")) - dist := mustInfo(t, filepath.Join(external, "dist")) - - assert.True(t, shouldSkipDir(root, ignore, filepath.Join(root, "packages", "api", "generated"), generated)) - assert.True(t, shouldSkipDir(root, ignore, filepath.Join(external, "dist"), dist)) - assert.True(t, isIgnored(root, ignore, filepath.Join(root, "packages", "api", "generated", "index.ts"))) - assert.True(t, isIgnored(root, ignore, filepath.Join(external, "dist", "index.js"))) - assert.False(t, isIgnored(root, ignore, filepath.Join(root, "sst.config.ts"))) -} - -func TestResolveWatchMatchesIgnoreNamesAnywhere(t *testing.T) { - root := t.TempDir() - _, ignore, err := resolveWatch(root, project.Watch{ - Ignore: []string{".env", "*.egg-info"}, - }) - require.NoError(t, err) - - eggInfo := mustInfo(t, filepath.Join(root, "packages", "api", "foo.egg-info")) - - assert.True(t, isIgnored(root, ignore, filepath.Join(root, ".env"))) - assert.True(t, isIgnored(root, ignore, filepath.Join(root, "packages", "api", ".env"))) - assert.True(t, shouldSkipDir(root, ignore, filepath.Join(root, "packages", "api", "foo.egg-info"), eggInfo)) - assert.True(t, isIgnored(root, ignore, filepath.Join(root, "packages", "api", "foo.egg-info", "PKG-INFO"))) - assert.False(t, isIgnored(root, ignore, filepath.Join(root, "packages", "api", ".env.local"))) -} - -func TestResolveWatchSkipsBuiltInDirs(t *testing.T) { - root := t.TempDir() - _, ignore, err := resolveWatch(root, project.Watch{}) - require.NoError(t, err) - - hidden := mustInfo(t, filepath.Join(root, ".sst")) - nodeModules := mustInfo(t, filepath.Join(root, "node_modules")) - normal := mustInfo(t, filepath.Join(root, "src")) - - assert.True(t, shouldSkipDir(root, ignore, filepath.Join(root, ".sst"), hidden)) - assert.True(t, shouldSkipDir(root, ignore, filepath.Join(root, "node_modules"), nodeModules)) - assert.False(t, shouldSkipDir(root, ignore, filepath.Join(root, "src"), normal)) -} - -func TestStartDiscoversFilesInNewDirectories(t *testing.T) { - root := t.TempDir() - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - events := bus.SubscribeAll() - defer bus.Unsubscribe(events) - - errCh := make(chan error, 1) - go func() { - errCh <- Start(ctx, WatchConfig{Root: root, Watch: project.Watch{}}) - }() - - waitForWatcherReady(t, filepath.Join(root, "watcher-ready.txt"), events) - - path := filepath.Join(root, "src", "newpkg", "handler.go") - require.NoError(t, os.MkdirAll(filepath.Dir(path), 0755)) - - deadline := time.Now().Add(5 * time.Second) - for time.Now().Before(deadline) { - require.NoError(t, os.WriteFile(path, []byte(time.Now().String()), 0644)) - if waitForFileChangedEvent(events, path, 200*time.Millisecond) { - cancel() - require.NoError(t, <-errCh) - return - } - time.Sleep(50 * time.Millisecond) - } - - t.Fatalf("expected file change for %s", path) -} - -func TestStartWatchesNewDirectories(t *testing.T) { - root := t.TempDir() - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - events := bus.SubscribeAll() - defer bus.Unsubscribe(events) - - errCh := make(chan error, 1) - go func() { - errCh <- Start(ctx, WatchConfig{Root: root, Watch: project.Watch{}}) - }() - - waitForWatcherReady(t, filepath.Join(root, "watcher-ready.txt"), events) - - dir := filepath.Join(root, "src", "newpkg") - require.NoError(t, os.MkdirAll(dir, 0755)) - - path := filepath.Join(dir, "handler.go") - deadline := time.Now().Add(5 * time.Second) - for time.Now().Before(deadline) { - require.NoError(t, os.WriteFile(path, []byte(time.Now().String()), 0644)) - if waitForFileChangedEvent(events, path, 200*time.Millisecond) { - cancel() - require.NoError(t, <-errCh) - return - } - time.Sleep(50 * time.Millisecond) - } - - t.Fatalf("expected file change for %s", path) -} - -func TestStartPicksUpImmediateEditsAfterNewFileDiscovery(t *testing.T) { - root := t.TempDir() - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - events := bus.SubscribeAll() - defer bus.Unsubscribe(events) - - errCh := make(chan error, 1) - go func() { - errCh <- Start(ctx, WatchConfig{Root: root, Watch: project.Watch{}}) - }() - - waitForWatcherReady(t, filepath.Join(root, "watcher-ready.txt"), events) - - dir := filepath.Join(root, "src", "newpkg") - require.NoError(t, os.MkdirAll(dir, 0755)) - - path := filepath.Join(dir, "handler.go") - require.NoError(t, os.WriteFile(path, []byte("package newpkg\n"), 0644)) - require.True(t, waitForFileChangedEvent(events, path, 5*time.Second), "expected initial file change for %s", path) - - require.NoError(t, os.WriteFile(path, []byte("package newpkg\n\nfunc Handler() {}\n"), 0644)) - require.True(t, waitForFileChangedEvent(events, path, 1*time.Second), "expected immediate follow-up file change for %s", path) - - cancel() - require.NoError(t, <-errCh) -} - -func TestStartOnlyWatchesConfiguredPaths(t *testing.T) { - root := t.TempDir() - watchedDir := filepath.Join(root, "packages", "api") - require.NoError(t, os.MkdirAll(watchedDir, 0755)) - - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - events := bus.SubscribeAll() - defer bus.Unsubscribe(events) - - errCh := make(chan error, 1) - go func() { - errCh <- Start(ctx, WatchConfig{ - Root: root, - Watch: project.Watch{ - Paths: []string{"packages/api"}, - }, - }) - }() - - waitForWatcherReady(t, filepath.Join(watchedDir, "watcher-ready.txt"), events) - - unwatched := filepath.Join(root, "docs", "guide.md") - require.NoError(t, os.MkdirAll(filepath.Dir(unwatched), 0755)) - require.NoError(t, os.WriteFile(unwatched, []byte("# docs\n"), 0644)) - assert.False(t, waitForFileChangedEvent(events, unwatched, 750*time.Millisecond), "did not expect file change for %s", unwatched) - - watched := filepath.Join(watchedDir, "handler.go") - require.NoError(t, os.WriteFile(watched, []byte("package api\n"), 0644)) - require.True(t, waitForFileChangedEvent(events, watched, 5*time.Second), "expected file change for %s", watched) - - cancel() - require.NoError(t, <-errCh) -} - -func mustInfo(t *testing.T, path string) os.FileInfo { - t.Helper() - require.NoError(t, os.MkdirAll(path, 0755)) - info, err := os.Stat(path) - require.NoError(t, err) - return info -} - -func waitForWatcherReady(t *testing.T, probe string, events <-chan interface{}) { - t.Helper() - - require.NoError(t, os.MkdirAll(filepath.Dir(probe), 0755)) - deadline := time.Now().Add(5 * time.Second) - for time.Now().Before(deadline) { - require.NoError(t, os.WriteFile(probe, []byte(time.Now().String()), 0644)) - if waitForFileChangedEvent(events, probe, 200*time.Millisecond) { - return - } - time.Sleep(50 * time.Millisecond) - } - - t.Fatalf("timed out waiting for watcher startup") -} - -func waitForFileChangedEvent(events <-chan interface{}, path string, timeout time.Duration) bool { - deadline := time.After(timeout) - for { - select { - case evt := <-events: - changed, ok := evt.(*FileChangedEvent) - if ok && changed.Path == path { - return true - } - case <-deadline: - return false - } - } -} diff --git a/cmd/sst/refresh.go b/cmd/sst/refresh.go deleted file mode 100644 index 35fddc9aee..0000000000 --- a/cmd/sst/refresh.go +++ /dev/null @@ -1,64 +0,0 @@ -package main - -import ( - "strings" - - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/server" - "golang.org/x/sync/errgroup" -) - -func CmdRefresh(c *cli.Cli) error { - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - - target := []string{} - if c.String("target") != "" { - target = strings.Split(c.String("target"), ",") - } - - exclude := []string{} - if c.String("exclude") != "" { - exclude = strings.Split(c.String("exclude"), ",") - } - - var wg errgroup.Group - defer wg.Wait() - ui := ui.New(c.Context) - events := bus.SubscribeAll() - defer close(events) - wg.Go(func() error { - for evt := range events { - ui.Event(evt) - } - return nil - }) - s, err := server.New() - if err != nil { - return err - } - wg.Go(func() error { - defer c.Cancel() - return s.Start(c.Context, p) - }) - defer ui.Destroy() - defer c.Cancel() - err = p.Run(c.Context, &project.StackInput{ - Command: "refresh", - Target: target, - Exclude: exclude, - ServerPort: s.Port, - Dev: c.Bool("dev"), - Verbose: c.Bool("verbose"), - }) - if err != nil { - return err - } - return nil -} diff --git a/cmd/sst/remove.go b/cmd/sst/remove.go deleted file mode 100644 index c7394e0d41..0000000000 --- a/cmd/sst/remove.go +++ /dev/null @@ -1,57 +0,0 @@ -package main - -import ( - "strings" - - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/pkg/bus" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/server" - "golang.org/x/sync/errgroup" -) - -func CmdRemove(c *cli.Cli) error { - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - - target := []string{} - if c.String("target") != "" { - target = strings.Split(c.String("target"), ",") - } - - var wg errgroup.Group - defer wg.Wait() - ui := ui.New(c.Context) - s, err := server.New() - if err != nil { - return err - } - wg.Go(func() error { - defer c.Cancel() - return s.Start(c.Context, p) - }) - events := bus.SubscribeAll() - defer close(events) - wg.Go(func() error { - for evt := range events { - ui.Event(evt) - } - return nil - }) - defer ui.Destroy() - defer c.Cancel() - err = p.Run(c.Context, &project.StackInput{ - Command: "remove", - Target: target, - ServerPort: s.Port, - Verbose: c.Bool("verbose"), - }) - if err != nil { - return err - } - return nil -} diff --git a/cmd/sst/secret.go b/cmd/sst/secret.go deleted file mode 100644 index 794858dd34..0000000000 --- a/cmd/sst/secret.go +++ /dev/null @@ -1,491 +0,0 @@ -package main - -import ( - "bufio" - "fmt" - "io" - "os" - "regexp" - "strings" - - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/dev" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/project/provider" - "github.com/sst/sst/v3/pkg/server" - "golang.org/x/sync/errgroup" -) - -var CmdSecretList = &cli.Command{ - Name: "list", - Description: cli.Description{ - Short: "List all secrets", - Long: strings.Join([]string{ - "Lists all the secrets.", - "", - "Optionally, list the secrets in a specific stage.", - "", - "```bash frame=\"none\" frame=\"none\"", - "sst secret list --stage production", - "```", - "", - "List only the fallback secrets.", - "", - "```bash frame=\"none\" frame=\"none\"", - "sst secret list --fallback", - "```", - }, "\n"), - }, - Examples: []cli.Example{ - { - Content: "sst secret list --stage production", - Description: cli.Description{ - Short: "List the secrets in production", - }, - }, - }, - Run: func(c *cli.Cli) error { - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - backend := p.Backend() - secrets := map[string]string{} - fallback := map[string]string{} - wg := errgroup.Group{} - if !c.Bool("fallback") { - wg.Go(func() error { - secrets, err = provider.GetSecrets(backend, p.App().Name, p.App().Stage) - if err != nil { - return err - } - return nil - }) - } - wg.Go(func() error { - fallback, err = provider.GetSecrets(backend, p.App().Name, "") - if err != nil { - return err - } - return nil - }) - if err := wg.Wait(); err != nil { - return err - } - if len(secrets) == 0 && len(fallback) == 0 { - return util.NewReadableError(nil, "No secrets found") - } - if len(fallback) > 0 { - fmt.Println(ui.TEXT_DIM.Render("# fallback")) - for key, value := range fallback { - fmt.Println(key + "=" + value) - } - } - if len(secrets) > 0 { - if len(fallback) > 0 { - fmt.Println() - } - fmt.Println(ui.TEXT_DIM.Render(fmt.Sprintf("# %s/%s", p.App().Name, p.App().Stage))) - for key, value := range secrets { - fmt.Println(key + "=" + value) - } - } - return nil - }, -} - -var CmdSecretLoad = &cli.Command{ - Name: "load", - Description: cli.Description{ - Short: "Set multiple secrets from file", - Long: strings.Join([]string{ - "Load all the secrets from a file and set them.", - "", - "```bash frame=\"none\"", - "sst secret load ./secrets.env", - "```", - "", - "The file needs to be in the _dotenv_ or bash format of key-value pairs.", - "", - "```sh title=\"secrets.env\"", - "KEY_1=VALUE1", - "KEY_2=VALUE2", - "```", - "", - "Optionally, set the secrets in a specific stage.", - "", - "```bash frame=\"none\"", - "sst secret load --stage production ./prod.env", - "```", - "", - "Set these secrets as _fallback_ values.", - "", - "```bash frame=\"none\" frame=\"none\"", - "sst secret load ./secrets.env --fallback", - "```", - "", - "This command can be paired with the `secret list` command to get all the", - "secrets from one stage and load them into another.", - "", - "```bash frame=\"none\"", - "sst secret list > ./secrets.env", - "sst secret load --stage production ./secrets.env", - "```", - "", - "This works because `secret list` outputs the secrets in the right format.", - }, "\n"), - }, - Args: []cli.Argument{ - { - Name: "file", - Required: true, - Description: cli.Description{ - Short: "The file to load secrets from", - Long: "The file to load the secrets from.", - }, - }, - }, - Examples: []cli.Example{ - { - Content: "sst secret load ./secrets.env", - Description: cli.Description{ - Short: "Loads all secrets from the file", - }, - }, - { - Content: "sst secret load ./prod.env --stage production", - Description: cli.Description{ - Short: "Set secrets for production", - }, - }, - }, - Run: func(c *cli.Cli) error { - filePath := c.Positional(0) - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - backend := p.Backend() - stage := p.App().Stage - if c.Bool("fallback") { - stage = "" - } - secrets, err := provider.GetSecrets(backend, p.App().Name, stage) - if err != nil { - return util.NewReadableError(err, "Could not get secrets") - } - file, err := os.Open(filePath) - if err != nil { - return util.NewReadableError(err, fmt.Sprintf("Could not open file %s", filePath)) - } - defer file.Close() - - scanner := bufio.NewScanner(file) - for scanner.Scan() { - line := scanner.Text() - // Skip comments and empty lines - if strings.HasPrefix(line, "#") || strings.TrimSpace(line) == "" { - continue - } - parts := strings.SplitN(line, "=", 2) - if len(parts) == 2 { - key := strings.TrimSpace(parts[0]) - value := strings.TrimSpace(parts[1]) - - // Handle quoted values (both single and double quotes) - if len(value) >= 2 { - // Check for double quotes - if strings.HasPrefix(value, "\"") && strings.HasSuffix(value, "\"") { - // Remove the quotes - value = value[1 : len(value)-1] - // Handle escaped characters within double quotes - value = strings.ReplaceAll(value, "\\\"", "\"") - value = strings.ReplaceAll(value, "\\n", "\n") - value = strings.ReplaceAll(value, "\\r", "\r") - value = strings.ReplaceAll(value, "\\t", "\t") - // Check for single quotes - } else if strings.HasPrefix(value, "'") && strings.HasSuffix(value, "'") { - // Remove the quotes - single quotes typically don't process escapes in .env files - value = value[1 : len(value)-1] - } - } - - ui.Success(fmt.Sprintf("Setting %s", key)) - secrets[key] = value - } - } - err = provider.PutSecrets(backend, p.App().Name, stage, secrets) - if err != nil { - return util.NewReadableError(err, "Could not set secret") - } - url, _ := server.Discover(p.PathConfig(), p.App().Stage) - if url != "" { - dev.Deploy(c.Context, url) - return nil - } - - ui.Success("Run \"sst deploy\" to update.") - return nil - }, -} - -var CmdSecretSet = &cli.Command{ - Name: "set", - Description: cli.Description{ - Short: "Set a secret", - Long: strings.Join([]string{ - "Set the value of the secret.", - "", - "The secrets are encrypted and stored in an S3 Bucket in your AWS account. They are also stored in the package of the functions using the secret.", - "", - ":::tip", - "If you are not running `sst dev`, you'll need to `sst deploy` to apply the secret.", - ":::", - "", - "For example, set the `sst.Secret` called `StripeSecret` to `123456789`.", - "", - "```bash frame=\"none\"", - "sst secret set StripeSecret dev_123456789", - "```", - "", - "Optionally, set the secret in a specific stage.", - "", - "```bash frame=\"none\"", - "sst secret set StripeSecret prod_123456789 --stage production", - "```", - "", - "You can also set a _fallback_ value for a secret with `--fallback`.", - "", - "```bash frame=\"none\"", - "sst secret set StripeSecret dev_123456789 --fallback", - "```", - "", - "So if the secret is not set for a specific stage, it'll use the fallback instead.", - "This only works for stages that are in the same AWS account.", - "", - ":::tip", - "Set fallback values for your PR stages.", - ":::", - "", - "This is useful for preview environments that are automatically deployed.", - "You won't have to set the secret for the stage after it's deployed.", - "", - "To set something like an RSA key, you can first save it to a file.", - "", - "```bash frame=\"none\"", - "cat > tmp.txt < 0 && args[0] != "cmd" { - // Try to find the executable directly - if execPath, err := exec.LookPath(args[0]); err == nil { - // Use exec.Command directly instead of process.Command to avoid potential issues - cmd = exec.Command(execPath, args[1:]...) - // Track it manually since we're not using process.Command - // (Note: this skips the process tracking in the process package) - } else { - cmd = process.Command(args[0], args[1:]...) - } - } else { - cmd = process.Command(args[0], args[1:]...) - } - // Initialize with current environment variables - cmd.Env = os.Environ() - // Add SST-specific environment variables - cmd.Env = append(cmd.Env, - fmt.Sprintf("PS1=%s/%s> ", p.App().Name, p.App().Stage), - ) - complete, err := p.GetCompleted(c.Context) - if err != nil { - return err - } - - target := c.String("target") - if target != "" { - cmd.Env = append(cmd.Env, c.Env()...) - env, err := p.EnvFor(c.Context, complete, target) - if err != nil { - return err - } - for key, value := range env { - cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", key, value)) - } - } - if target == "" { - // On Windows, always use a consolidated environment variable because - // Windows uppercases all environment variable names, breaking - // case-sensitive resource lookups. - if runtime.GOOS == "windows" { - // Create a single JSON with all resources - allResources := make(map[string]any) - for resource, value := range complete.Links { - allResources[resource] = value.Properties - } - allResources["App"] = map[string]string{ - "name": p.App().Name, - "stage": p.App().Stage, - } - - jsonData, err := json.Marshal(allResources) - if err != nil { - return err - } - - // Set as single environment variable that the SDK can parse - resourcesEnv := fmt.Sprintf("SST_RESOURCES_JSON=%s", string(jsonData)) - cmd.Env = append(cmd.Env, resourcesEnv) - } else { - // Original approach: Add individual SST resource environment variables - for resource, value := range complete.Links { - jsonValue, err := json.Marshal(value.Properties) - if err != nil { - return err - } - envVar := fmt.Sprintf("SST_RESOURCE_%s=%s", resource, string(jsonValue)) - cmd.Env = append(cmd.Env, envVar) - } - appEnv := fmt.Sprintf("SST_RESOURCE_App=%s", fmt.Sprintf(`{"name": "%s", "stage": "%s" }`, p.App().Name, p.App().Stage)) - cmd.Env = append(cmd.Env, appEnv) - } - - aws, ok := p.Provider("aws") - if ok { - // Remove AWS_PROFILE from environment - filteredEnv := []string{} - for _, envVar := range cmd.Env { - if !strings.HasPrefix(envVar, "AWS_PROFILE=") { - filteredEnv = append(filteredEnv, envVar) - } - } - cmd.Env = filteredEnv - - provider := aws.(*provider.AwsProvider) - cfg := provider.Config() - creds, err := cfg.Credentials.Retrieve(c.Context) - if err != nil { - return err - } - cmd.Env = append(cmd.Env, fmt.Sprintf("AWS_ACCESS_KEY_ID=%s", creds.AccessKeyID)) - cmd.Env = append(cmd.Env, fmt.Sprintf("AWS_SECRET_ACCESS_KEY=%s", creds.SecretAccessKey)) - cmd.Env = append(cmd.Env, fmt.Sprintf("AWS_SESSION_TOKEN=%s", creds.SessionToken)) - if cfg.Region != "" { - cmd.Env = append(cmd.Env, fmt.Sprintf("AWS_REGION=%s", cfg.Region)) - } - } - } - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Stdin = os.Stdin - err = cmd.Run() - if err != nil { - return util.NewReadableError(err, err.Error()) - } - return nil -} diff --git a/cmd/sst/state.go b/cmd/sst/state.go deleted file mode 100644 index 88140eb8a3..0000000000 --- a/cmd/sst/state.go +++ /dev/null @@ -1,445 +0,0 @@ -package main - -import ( - "encoding/json" - "fmt" - "os" - "strings" - "time" - - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/id" - "github.com/sst/sst/v3/pkg/process" - "github.com/sst/sst/v3/pkg/project/provider" - "github.com/sst/sst/v3/pkg/state" -) - -var CmdState = &cli.Command{ - Name: "state", - Description: cli.Description{ - Short: "Manage state of your app", - }, - Children: []*cli.Command{ - { - Name: "edit", - Description: cli.Description{ - Short: "Edit the state of your app", - Long: strings.Join([]string{ - "Edit the raw state of your app directly.", - "", - "This opens your state file in your local editor (`$EDITOR`, or `vim` by default).", - "When you save and exit, SST pushes those changes back to your backend.", - "", - ":::danger", - "This command is dangerous. If you make an invalid change, you can corrupt your state and break deploys.", - "Only use this if you understand the state format and know exactly what you are changing.", - "Consider using safer commands like `sst state remove` or `sst state repair` first.", - ":::", - }, "\n"), - }, - Run: func(c *cli.Cli) error { - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - - update, err := p.Lock("edit") - if err != nil { - return util.NewReadableError(err, "Could not lock state") - } - defer p.Unlock() - defer func() { - update.TimeCompleted = time.Now().UTC().Format(time.RFC3339) - provider.PutUpdate(p.Backend(), p.App().Name, p.App().Stage, update) - }() - workdir, err := p.NewWorkdir(update.ID) - if err != nil { - return err - } - defer workdir.Cleanup() - - path, err := workdir.Pull() - if err != nil { - return util.NewReadableError(err, "Could not pull state") - } - editor := os.Getenv("EDITOR") - if editor == "" { - editor = "vim" - } - editorArgs := append(strings.Fields(editor), path) - fmt.Println(editorArgs) - cmd := process.Command(editorArgs[0], editorArgs[1:]...) - cmd.Stdin = os.Stdin - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - if err := cmd.Start(); err != nil { - return util.NewReadableError(err, "Could not start editor") - } - if err := cmd.Wait(); err != nil { - return util.NewReadableError(err, "Editor exited with error") - } - - return workdir.Push(update.ID) - }, - }, - { - Name: "export", - Flags: []cli.Flag{ - { - Name: "decrypt", - Type: "bool", - Description: cli.Description{ - Short: "Decrypt the state", - Long: "Decrypt the state before printing it out.", - }, - }, - }, - Description: cli.Description{ - Short: "Prints the state of your app", - Long: strings.Join([]string{ - "Prints the state of your app.", - "", - "This pull the state of your app from the cloud provider and then prints it out.", - "You can write this to a file or view it directly in your terminal.", - "", - "This can be run for specific stages as well.", - "", - "```bash frame=\"none\"", - "sst state export --stage production", - "```", - "", - "By default, it runs on your personal stage.", - }, "\n"), - }, - Run: func(c *cli.Cli) error { - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - workdir, err := p.NewWorkdir(id.Descending()) - if err != nil { - return err - } - defer workdir.Cleanup() - - _, err = workdir.Pull() - if err != nil { - return util.NewReadableError(err, "Could not pull state") - } - exported, err := workdir.Export() - if err != nil { - return err - } - if c.Bool("decrypt") { - passphrase, err := provider.GetPassphrase(p.Backend(), p.App().Name, p.App().Stage) - if err != nil { - return err - } - exported, err = state.Decrypt(c.Context, passphrase, exported) - if err != nil { - return err - } - } - encoder := json.NewEncoder(os.Stdout) - encoder.SetIndent("", " ") - return encoder.Encode(exported) - }, - }, - { - Name: "list", - Description: cli.Description{ - Short: "List all deployed stages", - Long: strings.Join([]string{ - "Lists all the stages of your app for the current set of credentials.", - "", - ":::note", - "This does not list the stages that are deployed in other accounts.", - ":::", - "", - "This pulls the state of your app from the cloud provider and then prints out all the stages that are listed in the state.", - }, "\n"), - }, - Run: func(c *cli.Cli) error { - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - backend := p.Backend() - currentStage := p.App().Stage - - stages, err := provider.ListStages(backend, p.App().Name) - if err != nil { - return err - } - - lines, err := provider.Info(backend) - if err != nil { - ui.Error("Failed to load provider information") - return err - } - - renderKeyValue("App", p.App().Name) - - for _, line := range lines { - renderKeyValue(line.Key, line.Value) - } - - if len(stages) == 0 { - fmt.Println( - ui.TEXT_NORMAL_BOLD.Render(indent("Stages:")) + - ui.TEXT_NORMAL.Render(currentStage) + " " + ui.TEXT_WARNING_DIM.Render("(not deployed)"), - ) - return nil - } - - currentDeployed := false - for i, stage := range stages { - rendered := ui.TEXT_GRAY.Render(stage) - if stage == currentStage { - rendered = ui.TEXT_NORMAL.Render(stage) - currentDeployed = true - } - - if i == 0 { - fmt.Println(ui.TEXT_NORMAL_BOLD.Render(indent("Stages:")) + rendered) - continue - } - - fmt.Println(indent("") + rendered) - } - - if !currentDeployed { - fmt.Println(indent("") + ui.TEXT_NORMAL.Render(currentStage) + " " + ui.TEXT_WARNING_DIM.Render("(not deployed)")) - } - - return nil - }, - }, - { - Name: "remove", - Args: []cli.Argument{ - { - Name: "target", - Required: true, - Description: cli.Description{ - Short: "The name of the resource to remove", - Long: "The name of the resource to remove.", - }, - }, - }, - Description: cli.Description{ - Short: "Remove a resource from only the state", - Long: strings.Join([]string{ - "Removes the reference for the given resource from the state.", - "", - ":::note", - "This does not remove the resource itself.", - ":::", - "", - "This does not remove the resource itself, it only edits the state of your app.", - "", - "```bash frame=\"none\"", - "sst state remove MyBucket", - "```", - "", - "Here, `MyBucket` is the name of the resource as defined in your `sst.config.ts`.", - "", - "```ts title=\"sst.config.ts\"", - "new sst.aws.Bucket(\"MyBucket\");", - "```", - "", - "This command will:", - "", - "1. Find the resource with the given name in the state.", - "2. Remove that from the state. It does not remove the children of this resource.", - "3. Runs a `repair` to remove any dependencies to this resource.", - "", - "You can run this for specific stages as well.", - "", - "```bash frame=\"none\"", - "sst state remove MyBucket --stage production", - "```", - "", - "By default, it runs on your personal stage.", - }, "\n"), - }, - Run: func(c *cli.Cli) error { - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - - update, err := p.Lock("edit") - if err != nil { - return util.NewReadableError(err, "Could not lock state") - } - defer p.Unlock() - defer func() { - update.TimeCompleted = time.Now().UTC().Format(time.RFC3339) - provider.PutUpdate(p.Backend(), p.App().Name, p.App().Stage, update) - }() - workdir, err := p.NewWorkdir(update.ID) - if err != nil { - return err - } - defer workdir.Cleanup() - - _, err = workdir.Pull() - if err != nil { - return util.NewReadableError(err, "Could not pull state") - } - - checkpoint, err := workdir.Export() - if err != nil { - return util.NewReadableError(err, "Could not export state") - } - - target := c.Positional(0) - muts := state.Remove(target, checkpoint) - err = confirmMutations(muts) - if err != nil { - return err - } - - err = workdir.Import(checkpoint) - if err != nil { - return util.NewReadableError(err, "Could not import state") - } - - err = workdir.Push(update.ID) - if err != nil { - return err - } - ui.Success("Resource removed") - return nil - }, - }, - { - Name: "repair", - Description: cli.Description{ - Short: "Repair the state of your app", - Long: strings.Join([]string{ - "Repairs the state of your app if it's corrupted.", - "", - "Sometimes, if something goes wrong with your app, or if the state was directly", - "edited, the state can become corrupted. This will cause your `sst deploy` command", - "to fail.", - "", - "This command looks for the following issues and fixes them.", - "", - "1. Since the state is a list of resources, if one resource depends on another,", - " it needs to be listed after the one it depends on. This command finds resources", - " that depend on each other but are not ordered correctly and **reorders them**.", - "", - "2. If resource B depends on resource A, but resource A is not listed in the state,", - " it'll **remove the dependency**.", - "", - "This command does this by going through all the resources in the state, fixing the", - "issues and updating the state.", - "", - "You can run this for specific stages as well.", - "", - "```bash frame=\"none\"", - "sst state repair --stage production", - "```", - "", - "By default, it runs on your personal stage.", - }, "\n"), - }, - Run: func(c *cli.Cli) error { - p, err := c.InitProject() - if err != nil { - return err - } - defer p.Cleanup() - - update, err := p.Lock("repair") - if err != nil { - return util.NewReadableError(err, "Could not lock state") - } - defer p.Unlock() - defer func() { - update.TimeCompleted = time.Now().UTC().Format(time.RFC3339) - provider.PutUpdate(p.Backend(), p.App().Name, p.App().Stage, update) - }() - workdir, err := p.NewWorkdir(update.ID) - if err != nil { - return err - } - defer workdir.Cleanup() - - _, err = workdir.Pull() - if err != nil { - return util.NewReadableError(err, "Could not pull state") - } - - checkpoint, err := workdir.Export() - if err != nil { - return util.NewReadableError(err, "Could not export state") - } - - muts := state.Repair(checkpoint) - err = confirmMutations(muts) - if err != nil { - return err - } - - err = workdir.Import(checkpoint) - if err != nil { - return util.NewReadableError(err, "Could not import state") - } - - err = workdir.Push(update.ID) - if err != nil { - return err - } - ui.Success("State repaired") - return nil - }, - }, - }, -} - -func confirmMutations(muts []state.Mutation) error { - if len(muts) == 0 { - return util.NewReadableError(nil, "No changes made") - } - fmt.Println("Removing:") - for _, item := range muts { - if item.Remove != nil { - fmt.Printf("- %s → %s\n", item.Remove.Resource.Type().DisplayName(), item.Remove.Resource.Name()) - } - if item.RemoveDependency != nil { - fmt.Printf("- dependency from %s → %s on %s → %s\n", item.RemoveDependency.Resource.Type().DisplayName(), item.RemoveDependency.Resource.Name(), item.RemoveDependency.Dependency.Type().DisplayName(), item.RemoveDependency.Dependency.Name()) - } - if item.RemoveProperty != nil { - fmt.Printf("- property dependency from %s → %s → %s on %s → %s\n", item.RemoveProperty.Resource.URNName(), item.RemoveProperty.Resource.Name(), item.RemoveProperty.Property, item.RemoveProperty.Dependency.Type().DisplayName(), item.RemoveProperty.Dependency.Name()) - } - } - - // prompt for confirmation to continue - fmt.Print("Do you want to commit these changes? (Y/n): ") - var response string - _, err := fmt.Scanln(&response) - if err != nil { - return util.NewReadableError(err, "failed to read user input") - } - if strings.ToLower(response) != "y" { - return util.NewReadableError(nil, "Abandoning changes") - } - return nil -} - -func indent(key string) string { - return fmt.Sprintf("%-12s", key) -} - -func renderKeyValue(key string, value string) { - fmt.Println(ui.TEXT_NORMAL_BOLD.Render(indent(key+":")) + ui.TEXT_GRAY.Render(value)) -} diff --git a/cmd/sst/tunnel.go b/cmd/sst/tunnel.go deleted file mode 100644 index a03cb18786..0000000000 --- a/cmd/sst/tunnel.go +++ /dev/null @@ -1,261 +0,0 @@ -package main - -import ( - "fmt" - "io" - "log/slog" - "os" - "os/user" - "strings" - - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/dev" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/internal/util" - "github.com/sst/sst/v3/pkg/process" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/server" - "github.com/sst/sst/v3/pkg/tunnel" -) - -var CmdTunnel = &cli.Command{ - Name: "tunnel", - Description: cli.Description{ - Short: "Start a tunnel", - Long: strings.Join([]string{ - "Start a tunnel.", - "", - "```bash frame=\"none\"", - "sst tunnel", - "```", - "", - "If your app has a VPC with `bastion` enabled, you can use this to connect to it.", - "This will forward traffic from the following ranges over SSH:", - "- `10.0.4.0/22`", - "- `10.0.12.0/22`", - "- `10.0.0.0/22`", - "- `10.0.8.0/22`", - "", - "The tunnel allows your local machine to access resources that are in the VPC.", - "", - ":::note", - "The tunnel is only available for apps that have a VPC with `bastion` enabled.", - ":::", - "", - "If you are running `sst dev`, this tunnel will be started automatically under the", - "_Tunnel_ tab in the sidebar.", - "", - ":::tip", - "This is automatically started when you run `sst dev`.", - ":::", - "", - "You can start this manually if you want to connect to a different stage.", - "", - "```bash frame=\"none\"", - "sst tunnel --stage production", - "```", - "", - "This needs a network interface on your local machine. You can create this", - "with the `sst tunnel install` command.", - }, "\n"), - }, - Run: func(c *cli.Cli) error { - if tunnel.NeedsInstall() { - return util.NewReadableError(nil, "The sst tunnel needs to be installed or upgraded. Run `sudo sst tunnel install`") - } - - if tunnel.IsRunning() { - return util.NewReadableError(nil, "Another tunnel process is already running. Stop it before starting a new one.") - } - - cfgPath, err := c.Discover() - if err != nil { - return err - } - - slog.Info("starting tunnel") - - var completed *project.CompleteEvent - - stage, err := c.Stage(cfgPath) - if err != nil { - return err - } - - if url, err := server.Discover(cfgPath, stage); err == nil { - completed, err = dev.Completed(c.Context, url) - if err != nil { - return err - } - } else { - proj, err := c.InitProject() - if err != nil { - return err - } - completed, err = proj.GetCompleted(c.Context) - if err != nil { - return err - } - } - - if err != nil { - return err - } - if len(completed.Tunnels) == 0 { - return util.NewReadableError(nil, "No tunnels found for stage "+stage) - } - var tun project.Tunnel - for _, item := range completed.Tunnels { - tun = item - } - subnets := strings.Join(tun.Subnets, ",") - // run as root - tunnelCmd := process.CommandContext( - c.Context, - "sudo", "-n", "-E", - tunnel.BINARY_PATH, "tunnel", "start", - "--subnets", subnets, - "--host", tun.IP, - "--user", tun.Username, - "--print-logs", - ) - tunnelCmd.Env = append( - os.Environ(), - "SST_SKIP_LOCAL=true", - "SST_SKIP_DEPENDENCY_CHECK=true", - "SSH_PRIVATE_KEY="+tun.PrivateKey, - "SST_LOG="+strings.ReplaceAll(os.Getenv("SST_LOG"), ".log", "_sudo.log"), - ) - tunnelCmd.Stdout = os.Stdout - slog.Info("starting tunnel", "cmd", tunnelCmd.Args) - fmt.Println(ui.TEXT_HIGHLIGHT_BOLD.Render("Tunnel")) - fmt.Println() - fmt.Print(ui.TEXT_HIGHLIGHT_BOLD.Render("▤")) - fmt.Println(ui.TEXT_NORMAL.Render(" " + tun.IP)) - fmt.Println() - fmt.Print(ui.TEXT_SUCCESS_BOLD.Render("➜")) - fmt.Println(ui.TEXT_NORMAL.Render(" Ranges")) - for _, subnet := range tun.Subnets { - fmt.Println(ui.TEXT_DIM.Render(" " + subnet)) - } - fmt.Println() - fmt.Println(ui.TEXT_DIM.Render("Waiting for connections...")) - fmt.Println() - stderr, _ := tunnelCmd.StderrPipe() - tunnelCmd.Start() - output, _ := io.ReadAll(stderr) - if strings.Contains(string(output), "password is required") { - return util.NewReadableError(nil, "Make sure you have installed the tunnel with `sudo sst tunnel install`") - } - return nil - }, - Children: []*cli.Command{ - { - Name: "install", - Description: cli.Description{ - Short: "Install the tunnel", - Long: strings.Join([]string{ - "Install the tunnel.", - "", - "To be able to create a tunnel, SST needs to create a network interface on your local", - - "", - "```bash \"sudo\"", - "sudo sst tunnel install", - "```", - "", - "You only need to run this once on your machine.", - }, "\n"), - }, - Run: func(c *cli.Cli) error { - currentUser, err := user.Current() - if err != nil { - return err - } - if currentUser.Uid != "0" { - return util.NewReadableError(nil, "You need to run this command as root") - } - err = tunnel.Install() - if err != nil { - return err - } - ui.Success("Tunnel installed successfully.") - return nil - }, - }, - { - Name: "start", - Description: cli.Description{ - Short: "Start the tunnel", - Long: strings.Join([]string{ - "Start the tunnel.", - "", - "This will start the tunnel.", - "", - "This is required for the tunnel to work.", - }, "\n"), - }, - Hidden: true, - Flags: []cli.Flag{ - { - Name: "subnets", - Type: "string", - Description: cli.Description{ - Short: "The subnet to use for the tunnel", - Long: "The subnet to use for the tunnel", - }, - }, - { - Name: "host", - Type: "string", - Description: cli.Description{ - Short: "The host to use for the tunnel", - Long: "The host to use for the tunnel", - }, - }, - { - Name: "port", - Type: "string", - Description: cli.Description{ - Short: "The port to use for the tunnel", - Long: "The port to use for the tunnel", - }, - }, - { - Name: "user", - Type: "string", - Description: cli.Description{ - Short: "The user to use for the tunnel", - Long: "The user to use for the tunnel", - }, - }, - }, - Run: func(c *cli.Cli) error { - subnets := strings.Split(c.String("subnets"), ",") - host := c.String("host") - port := c.String("port") - user := c.String("user") - if port == "" { - port = "22" - } - slog.Info("starting tunnel", "subnet", subnets, "host", host, "port", port) - err := tunnel.Start(subnets...) - if err != nil { - return err - } - defer tunnel.Stop() - slog.Info("tunnel started") - err = tunnel.StartProxy( - c.Context, - user, - host+":"+port, - []byte(os.Getenv("SSH_PRIVATE_KEY")), - ) - if err != nil { - slog.Error("failed to start tunnel", "error", err) - } - return nil - }, - }, - }, -} diff --git a/cmd/sst/ui.go b/cmd/sst/ui.go deleted file mode 100644 index fb913a7b9e..0000000000 --- a/cmd/sst/ui.go +++ /dev/null @@ -1,125 +0,0 @@ -package main - -import ( - "fmt" - "log/slog" - - "github.com/pulumi/pulumi/sdk/v3/go/common/apitype" - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/aws" - "github.com/sst/sst/v3/cmd/sst/mosaic/cloudflare" - "github.com/sst/sst/v3/cmd/sst/mosaic/deployer" - "github.com/sst/sst/v3/cmd/sst/mosaic/dev" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui/common" - "github.com/sst/sst/v3/pkg/project" - "github.com/sst/sst/v3/pkg/server" - "github.com/sst/sst/v3/pkg/types/typescript" -) - -func CmdUI(c *cli.Cli) error { - url, err := server.Discover("", "") - if err != nil { - return err - } - types := []interface{}{} - filter := c.String("filter") - isWorker := filter == "worker" - if isWorker { - filter = "function" - } - var u *ui.UI - opts := []ui.Option{} - if filter == "function" || filter == "" { - if filter != "" { - title := "Function Logs" - if isWorker { - title = "Worker Logs" - } - fmt.Println(ui.TEXT_HIGHLIGHT_BOLD.Render(title)) - fmt.Println() - fmt.Println(ui.TEXT_GRAY.Render("Waiting for invocations...")) - fmt.Println() - } - types = append(types, - cloudflare.WorkerBuildEvent{}, - cloudflare.WorkerUpdatedEvent{}, - cloudflare.WorkerInvokedEvent{}, - project.CompleteEvent{}, - aws.FunctionInvokedEvent{}, - aws.FunctionResponseEvent{}, - aws.FunctionErrorEvent{}, - aws.FunctionLogEvent{}, - aws.FunctionBuildEvent{}, - ) - } - if filter == "task" || filter == "" { - if filter != "" { - fmt.Println(ui.TEXT_HIGHLIGHT_BOLD.Render("Task Logs")) - fmt.Println() - fmt.Println(ui.TEXT_GRAY.Render("Waiting for tasks...")) - fmt.Println() - } - types = append(types, - aws.TaskProvisionEvent{}, - aws.TaskStartEvent{}, - aws.TaskLogEvent{}, - aws.TaskCompleteEvent{}, - aws.TaskMissingCommandEvent{}, - ) - } - if filter == "function" || filter == "task" { - types = append(types, ui.PaneFilterEvent{}) - } - if filter == "sst" || filter == "" { - u = ui.New(c.Context) - types = append(types, - common.StdoutEvent{}, - deployer.DeployFailedEvent{}, - project.StackCommandEvent{}, - project.CancelledEvent{}, - project.ConcurrentUpdateEvent{}, - project.StackCommandEvent{}, - project.BuildFailedEvent{}, - project.SkipEvent{}, - apitype.ResourcePreEvent{}, - apitype.ResOpFailedEvent{}, - apitype.ResOutputsEvent{}, - apitype.DiagnosticEvent{}, - project.CompleteEvent{}, - typescript.WarningEvent{}, - ) - } - evts, err := dev.Stream(c.Context, url, types...) - if err != nil { - return err - } - u = ui.New(c.Context, opts...) - slog.Info("initialized ui") - if filter == "sst" || filter == "" { - err = dev.Deploy(c.Context, url) - } - if err != nil { - return err - } - for { - select { - case <-c.Context.Done(): - u.Destroy() - return nil - case evt, ok := <-evts: - if !ok { - c.Cancel() - return nil - } - switch e := evt.(type) { - case *ui.PaneFilterEvent: - if e.PaneKey == filter { - u.SetFilter(e.Value, e.PaneKey) - } - default: - u.Event(evt) - } - } - } -} diff --git a/cmd/sst/upgrade.go b/cmd/sst/upgrade.go deleted file mode 100644 index 4ea3b1bffc..0000000000 --- a/cmd/sst/upgrade.go +++ /dev/null @@ -1,67 +0,0 @@ -package main - -import ( - "fmt" - "os" - "strings" - - "github.com/fatih/color" - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/cmd/sst/mosaic/ui" - "github.com/sst/sst/v3/pkg/global" - "github.com/sst/sst/v3/pkg/npm" - "github.com/sst/sst/v3/pkg/process" -) - -func CmdUpgrade(c *cli.Cli) error { - if os.Getenv("npm_config_user_agent") != "" { - updated, err := global.UpgradeNode( - version, - c.Positional(0), - ) - if err != nil { - return err - } - hasAny := false - for file, newVersion := range updated { - fmt.Print(ui.TEXT_SUCCESS_BOLD.Render(ui.IconCheck) + " ") - fmt.Println(ui.TEXT_NORMAL.Render(file)) - fmt.Println(" " + ui.TEXT_DIM.Render(newVersion)) - if newVersion != version { - hasAny = true - } - } - if hasAny { - cwd, _ := os.Getwd() - mgr, _ := npm.DetectPackageManager(cwd) - if mgr != "" { - cmd := process.Command(mgr, "install") - fmt.Println() - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Stdin = os.Stdin - err := cmd.Run() - if err != nil { - return err - } - } - } - return nil - } - newVersion, err := global.Upgrade( - version, - c.Positional(0), - ) - if err != nil { - return err - } - newVersion = strings.TrimPrefix(newVersion, "v") - fmt.Print(ui.TEXT_SUCCESS_BOLD.Render(ui.IconCheck)) - if newVersion == version { - color.New(color.FgWhite).Printf(" Already on latest %s\n", version) - } else { - color.New(color.FgWhite).Printf(" Upgraded %s ➜ ", version) - color.New(color.FgCyan, color.Bold).Println(newVersion) - } - return nil -} diff --git a/cmd/sst/version.go b/cmd/sst/version.go deleted file mode 100644 index ca772a4299..0000000000 --- a/cmd/sst/version.go +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "fmt" - "runtime" - - "github.com/pulumi/pulumi/sdk/v3" - "github.com/sst/sst/v3/cmd/sst/cli" - "github.com/sst/sst/v3/pkg/global" -) - -var CmdVersion = &cli.Command{ - Name: "version", - Description: cli.Description{ - Short: "Print the version of the CLI", - Long: `Prints the current version of the CLI.`, - }, - Run: func(cli *cli.Cli) error { - fmt.Println("sst", version) - if cli.Bool("verbose") { - fmt.Println("pulumi", sdk.Version) - fmt.Println("config", global.ConfigDir()) - fmt.Println("GOARCH", runtime.GOARCH) - fmt.Println("GOOS", runtime.GOOS) - } - return nil - }, -} diff --git a/examples/.gitignore b/examples/.gitignore deleted file mode 100644 index bae80fcfad..0000000000 --- a/examples/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -pnpm-lock.yaml -package-lock.json -yarn.lock -bun.lockb diff --git a/examples/aws-analog/.editorconfig b/examples/aws-analog/.editorconfig deleted file mode 100644 index 59d9a3a3e7..0000000000 --- a/examples/aws-analog/.editorconfig +++ /dev/null @@ -1,16 +0,0 @@ -# Editor configuration, see https://editorconfig.org -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 2 -insert_final_newline = true -trim_trailing_whitespace = true - -[*.ts] -quote_type = single - -[*.md] -max_line_length = off -trim_trailing_whitespace = false diff --git a/examples/aws-analog/.gitignore b/examples/aws-analog/.gitignore deleted file mode 100644 index c48ce743bf..0000000000 --- a/examples/aws-analog/.gitignore +++ /dev/null @@ -1,47 +0,0 @@ -# See http://help.github.com/ignore-files/ for more about ignoring files. - -# Compiled output -/dist -/tmp -/out-tsc -/bazel-out - -# Node -/node_modules -npm-debug.log -yarn-error.log - -# IDEs and editors -.idea/ -.project -.classpath -.c9/ -*.launch -.settings/ -*.sublime-workspace - -# Visual Studio Code -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -.history/* - -# Miscellaneous -/.angular/cache -/.nx/cache -/.nx/workspace-data -.sass-cache/ -/connect.lock -/coverage -/libpeerconnection.log -testem.log -/typings - -# System files -.DS_Store -Thumbs.db - -# sst -.sst diff --git a/examples/aws-analog/.vscode/extensions.json b/examples/aws-analog/.vscode/extensions.json deleted file mode 100644 index e4679f326a..0000000000 --- a/examples/aws-analog/.vscode/extensions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846 - "recommendations": ["angular.ng-template", "analogjs.vscode-analog"] -} diff --git a/examples/aws-analog/.vscode/launch.json b/examples/aws-analog/.vscode/launch.json deleted file mode 100644 index 57dbf761ec..0000000000 --- a/examples/aws-analog/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "ng serve", - "type": "chrome", - "request": "launch", - "preLaunchTask": "npm: start", - "url": "http://localhost:5173/" - }, - { - "name": "ng test", - "type": "chrome", - "request": "launch", - "preLaunchTask": "npm: test" - } - ] -} diff --git a/examples/aws-analog/.vscode/tasks.json b/examples/aws-analog/.vscode/tasks.json deleted file mode 100644 index a298b5bd87..0000000000 --- a/examples/aws-analog/.vscode/tasks.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558 - "version": "2.0.0", - "tasks": [ - { - "type": "npm", - "script": "start", - "isBackground": true, - "problemMatcher": { - "owner": "typescript", - "pattern": "$tsc", - "background": { - "activeOnStart": true, - "beginsPattern": { - "regexp": "(.*?)" - }, - "endsPattern": { - "regexp": "bundle generation complete" - } - } - } - }, - { - "type": "npm", - "script": "test", - "isBackground": true, - "problemMatcher": { - "owner": "typescript", - "pattern": "$tsc", - "background": { - "activeOnStart": true, - "beginsPattern": { - "regexp": "(.*?)" - }, - "endsPattern": { - "regexp": "bundle generation complete" - } - } - } - } - ] -} diff --git a/examples/aws-analog/angular.json b/examples/aws-analog/angular.json deleted file mode 100644 index 60b166f354..0000000000 --- a/examples/aws-analog/angular.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "$schema": "./node_modules/@angular/cli/lib/config/schema.json", - "version": 1, - "newProjectRoot": "projects", - "projects": { - "my-app": { - "projectType": "application", - "root": ".", - "sourceRoot": "src", - "prefix": "app", - "architect": { - "build": { - "builder": "@analogjs/platform:vite", - "options": { - "configFile": "vite.config.ts", - "main": "src/main.ts", - "outputPath": "dist/client", - "tsConfig": "tsconfig.app.json" - }, - "defaultConfiguration": "production", - "configurations": { - "development": { - "mode": "development" - }, - "production": { - "sourcemap": false, - "mode": "production" - } - } - }, - "serve": { - "builder": "@analogjs/platform:vite-dev-server", - "defaultConfiguration": "development", - "options": { - "buildTarget": "my-app:build", - "port": 5173 - }, - "configurations": { - "development": { - "buildTarget": "my-app:build:development", - "hmr": true - }, - "production": { - "buildTarget": "my-app:build:production" - } - } - }, - "test": { - "builder": "@analogjs/vitest-angular:test" - } - } - } - } -} diff --git a/examples/aws-analog/index.html b/examples/aws-analog/index.html deleted file mode 100644 index 5facc429a4..0000000000 --- a/examples/aws-analog/index.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - My App - - - - - - - - - - diff --git a/examples/aws-analog/package.json b/examples/aws-analog/package.json deleted file mode 100644 index f56f53e377..0000000000 --- a/examples/aws-analog/package.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "aws-analog", - "version": "0.0.0", - "type": "module", - "engines": { - "node": ">=18.19.1" - }, - "scripts": { - "build": "ng build", - "dev": "ng serve", - "ng": "ng", - "start": "npm run dev", - "test": "ng test", - "watch": "ng build --watch --configuration development" - }, - "private": true, - "dependencies": { - "@analogjs/content": "^1.8.1", - "@analogjs/router": "^1.8.1", - "@angular/animations": "^18.0.0", - "@angular/build": "^18.0.0", - "@angular/common": "^18.0.0", - "@angular/compiler": "^18.0.0", - "@angular/core": "^18.0.0", - "@angular/forms": "^18.0.0", - "@angular/platform-browser": "^18.0.0", - "@angular/platform-browser-dynamic": "^18.0.0", - "@angular/platform-server": "^18.0.0", - "@angular/router": "^18.0.0", - "@aws-sdk/client-s3": "^3.654.0", - "@aws-sdk/s3-request-presigner": "^3.654.0", - "front-matter": "^4.0.2", - "marked": "^5.0.2", - "marked-gfm-heading-id": "^3.1.0", - "marked-highlight": "^2.0.1", - "marked-mangle": "^1.1.7", - "prismjs": "^1.29.0", - "rxjs": "~7.8.0", - "sst": "file:../../sdk/js", - "tslib": "^2.3.0", - "zone.js": "~0.14.3" - }, - "devDependencies": { - "@analogjs/platform": "^1.8.1", - "@analogjs/vite-plugin-angular": "^1.8.1", - "@analogjs/vitest-angular": "^1.8.1", - "@angular/cli": "^18.0.0", - "@angular/compiler-cli": "^18.0.0", - "jsdom": "^22.0.0", - "typescript": "~5.4.2", - "vite": "^5.0.0", - "vite-tsconfig-paths": "^4.2.0", - "vitest": "^1.3.1" - } -} diff --git a/examples/aws-analog/public/analog.svg b/examples/aws-analog/public/analog.svg deleted file mode 100644 index e4f555aa7d..0000000000 --- a/examples/aws-analog/public/analog.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-analog/public/favicon.ico b/examples/aws-analog/public/favicon.ico deleted file mode 100644 index 997406ad22..0000000000 Binary files a/examples/aws-analog/public/favicon.ico and /dev/null differ diff --git a/examples/aws-analog/public/vite.svg b/examples/aws-analog/public/vite.svg deleted file mode 100644 index e7b8dfb1b2..0000000000 --- a/examples/aws-analog/public/vite.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-analog/src/app/app.component.spec.ts b/examples/aws-analog/src/app/app.component.spec.ts deleted file mode 100644 index 9a08b4b25f..0000000000 --- a/examples/aws-analog/src/app/app.component.spec.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { TestBed } from '@angular/core/testing'; -import { provideRouter } from '@angular/router'; -import { provideLocationMocks } from '@angular/common/testing'; - -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [AppComponent], - providers: [provideRouter([]), provideLocationMocks()], - }).compileComponents(); - }); - - it('should create the app', () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - }); -}); diff --git a/examples/aws-analog/src/app/app.component.ts b/examples/aws-analog/src/app/app.component.ts deleted file mode 100644 index 2e02d16044..0000000000 --- a/examples/aws-analog/src/app/app.component.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Component } from '@angular/core'; -import { RouterOutlet } from '@angular/router'; - -@Component({ - selector: 'app-root', - standalone: true, - imports: [RouterOutlet], - template: ` `, - styles: [ - ` - :host { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; - text-align: center; - } - `, - ], -}) -export class AppComponent {} diff --git a/examples/aws-analog/src/app/app.config.server.ts b/examples/aws-analog/src/app/app.config.server.ts deleted file mode 100644 index 0da63b09b0..0000000000 --- a/examples/aws-analog/src/app/app.config.server.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { mergeApplicationConfig, ApplicationConfig } from '@angular/core'; -import { provideServerRendering } from '@angular/platform-server'; - -import { appConfig } from './app.config'; - -const serverConfig: ApplicationConfig = { - providers: [provideServerRendering()], -}; - -export const config = mergeApplicationConfig(appConfig, serverConfig); diff --git a/examples/aws-analog/src/app/app.config.ts b/examples/aws-analog/src/app/app.config.ts deleted file mode 100644 index a1a58ee8fc..0000000000 --- a/examples/aws-analog/src/app/app.config.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { - provideHttpClient, - withFetch, - withInterceptors, -} from '@angular/common/http'; -import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core'; -import { provideClientHydration } from '@angular/platform-browser'; -import { provideFileRouter, requestContextInterceptor } from '@analogjs/router'; - -export const appConfig: ApplicationConfig = { - providers: [ - provideZoneChangeDetection({ eventCoalescing: true }), - provideFileRouter(), - provideHttpClient( - withFetch(), - withInterceptors([requestContextInterceptor]) - ), - provideClientHydration(), - ], -}; diff --git a/examples/aws-analog/src/app/pages/index.page.ts b/examples/aws-analog/src/app/pages/index.page.ts deleted file mode 100644 index 56b2cfb557..0000000000 --- a/examples/aws-analog/src/app/pages/index.page.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { Component } from '@angular/core'; -import { FormsModule } from '@angular/forms'; -import { injectLoad } from '@analogjs/router'; -import { toSignal } from '@angular/core/rxjs-interop'; - -import { load } from './index.server'; - -@Component({ - selector: 'app-home', - standalone: true, - imports: [FormsModule], - template: ` -
- - -
- `, -}) -export default class HomeComponent { - data = toSignal(injectLoad(), { requireSync: true }); - - async onSubmit(event: Event): Promise { - const file = (event.target as HTMLFormElement)['file'].files?.[0]!; - - const image = await fetch(this.data().url, { - body: file, - method: 'PUT', - headers: { - 'Content-Type': file.type, - 'Content-Disposition': `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split('?')[0]; - } -} diff --git a/examples/aws-analog/src/app/pages/index.server.ts b/examples/aws-analog/src/app/pages/index.server.ts deleted file mode 100644 index a120302365..0000000000 --- a/examples/aws-analog/src/app/pages/index.server.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Resource } from 'sst'; -import { PageServerLoad } from '@analogjs/router'; -import { getSignedUrl } from '@aws-sdk/s3-request-presigner'; -import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3'; - -export const load = async ({ }: PageServerLoad) => { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - // @ts-ignore: Generated on deploy - Bucket: Resource.MyBucket.name, - }); - - const url = await getSignedUrl(new S3Client({}), command); - - return { - url - }; -}; diff --git a/examples/aws-analog/src/main.server.ts b/examples/aws-analog/src/main.server.ts deleted file mode 100644 index 2b6d4d14b5..0000000000 --- a/examples/aws-analog/src/main.server.ts +++ /dev/null @@ -1,32 +0,0 @@ -import 'zone.js/node'; -import '@angular/platform-server/init'; -import { enableProdMode } from '@angular/core'; -import { bootstrapApplication } from '@angular/platform-browser'; -import { renderApplication } from '@angular/platform-server'; -import { provideServerContext } from '@analogjs/router/server'; -import { ServerContext } from '@analogjs/router/tokens'; - -import { config } from './app/app.config.server'; -import { AppComponent } from './app/app.component'; - -if (import.meta.env.PROD) { - enableProdMode(); -} - -export function bootstrap() { - return bootstrapApplication(AppComponent, config); -} - -export default async function render( - url: string, - document: string, - serverContext: ServerContext -) { - const html = await renderApplication(bootstrap, { - document, - url, - platformProviders: [provideServerContext(serverContext)], - }); - - return html; -} diff --git a/examples/aws-analog/src/main.ts b/examples/aws-analog/src/main.ts deleted file mode 100644 index e774611399..0000000000 --- a/examples/aws-analog/src/main.ts +++ /dev/null @@ -1,7 +0,0 @@ -import 'zone.js'; -import { bootstrapApplication } from '@angular/platform-browser'; - -import { AppComponent } from './app/app.component'; -import { appConfig } from './app/app.config'; - -bootstrapApplication(AppComponent, appConfig); diff --git a/examples/aws-analog/src/server/routes/v1/hello.ts b/examples/aws-analog/src/server/routes/v1/hello.ts deleted file mode 100644 index 594c5d716d..0000000000 --- a/examples/aws-analog/src/server/routes/v1/hello.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { defineEventHandler } from 'h3'; - -export default defineEventHandler(() => ({ message: 'Hello World' })); diff --git a/examples/aws-analog/src/styles.css b/examples/aws-analog/src/styles.css deleted file mode 100644 index 8e92f8fcdc..0000000000 --- a/examples/aws-analog/src/styles.css +++ /dev/null @@ -1,75 +0,0 @@ -/* You can add global styles to this file, and also import other style files */ -:root { - font-family: Inter, Avenir, Helvetica, Arial, sans-serif; - font-size: 16px; - line-height: 24px; - font-weight: 400; - - color-scheme: light dark; - color: rgba(255, 255, 255, 0.87); - background-color: #242424; - - font-synthesis: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - -webkit-text-size-adjust: 100%; -} - -a { - font-weight: 500; - color: #646cff; - text-decoration: inherit; -} -a:hover { - color: #535bf2; -} - -body { - margin: 0; - display: flex; - place-items: center; - min-width: 320px; - min-height: 100vh; -} - -h1 { - font-size: 3.2em; - line-height: 1.1; -} - -button { - border-radius: 8px; - border: 1px solid transparent; - padding: 0.6em 1.2em; - font-size: 1em; - font-weight: 500; - font-family: inherit; - background-color: #1a1a1a; - cursor: pointer; - transition: border-color 0.25s; -} -button:hover { - border-color: #646cff; -} -button:focus, -button:focus-visible { - outline: 4px auto -webkit-focus-ring-color; -} - -.card { - padding: 2em; -} - -@media (prefers-color-scheme: light) { - :root { - color: #213547; - background-color: #ffffff; - } - a:hover { - color: #747bff; - } - button { - background-color: #f9f9f9; - } -} diff --git a/examples/aws-analog/src/test-setup.ts b/examples/aws-analog/src/test-setup.ts deleted file mode 100644 index 318c3b9d71..0000000000 --- a/examples/aws-analog/src/test-setup.ts +++ /dev/null @@ -1,12 +0,0 @@ -import '@analogjs/vitest-angular/setup-zone'; - -import { - BrowserDynamicTestingModule, - platformBrowserDynamicTesting, -} from '@angular/platform-browser-dynamic/testing'; -import { getTestBed } from '@angular/core/testing'; - -getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting() -); diff --git a/examples/aws-analog/src/vite-env.d.ts b/examples/aws-analog/src/vite-env.d.ts deleted file mode 100644 index 11f02fe2a0..0000000000 --- a/examples/aws-analog/src/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/examples/aws-analog/sst.config.ts b/examples/aws-analog/sst.config.ts deleted file mode 100644 index e7256be079..0000000000 --- a/examples/aws-analog/sst.config.ts +++ /dev/null @@ -1,20 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-analog", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" - }); - - new sst.aws.Analog("MyWeb", { - link: [bucket], - }); - }, -}); diff --git a/examples/aws-analog/tsconfig.app.json b/examples/aws-analog/tsconfig.app.json deleted file mode 100644 index ad965f67de..0000000000 --- a/examples/aws-analog/tsconfig.app.json +++ /dev/null @@ -1,14 +0,0 @@ -/* To learn more about this file see: https://angular.io/config/tsconfig. */ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "./out-tsc/app", - "types": [] - }, - "files": ["src/main.ts", "src/main.server.ts"], - "include": [ - "src/**/*.d.ts", - "src/app/pages/**/*.page.ts", - "src/server/middleware/**/*.ts" - ] -} diff --git a/examples/aws-analog/tsconfig.json b/examples/aws-analog/tsconfig.json deleted file mode 100644 index 94e11863a1..0000000000 --- a/examples/aws-analog/tsconfig.json +++ /dev/null @@ -1,31 +0,0 @@ -/* To learn more about this file see: https://angular.io/config/tsconfig. */ -{ - "compileOnSave": false, - "compilerOptions": { - "baseUrl": "./", - "outDir": "./dist/out-tsc", - "forceConsistentCasingInFileNames": true, - "strict": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "sourceMap": true, - "declaration": false, - "downlevelIteration": true, - "experimentalDecorators": true, - "moduleResolution": "node", - "importHelpers": true, - "target": "ES2022", - "module": "ES2022", - "lib": ["ES2022", "dom"], - "useDefineForClassFields": false, - "skipLibCheck": true - }, - "angularCompilerOptions": { - "enableI18nLegacyMessageIdFormat": false, - "strictInjectionParameters": true, - "strictInputAccessModifiers": true, - "strictTemplates": true - } -} diff --git a/examples/aws-analog/tsconfig.spec.json b/examples/aws-analog/tsconfig.spec.json deleted file mode 100644 index 06eb7cae61..0000000000 --- a/examples/aws-analog/tsconfig.spec.json +++ /dev/null @@ -1,11 +0,0 @@ -/* To learn more about this file see: https://angular.io/config/tsconfig. */ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "./out-tsc/spec", - "target": "es2016", - "types": ["node", "vitest/globals"] - }, - "files": ["src/test-setup.ts"], - "include": ["src/**/*.spec.ts", "src/**/*.d.ts"] -} diff --git a/examples/aws-analog/vite.config.ts b/examples/aws-analog/vite.config.ts deleted file mode 100644 index bb4ee185dd..0000000000 --- a/examples/aws-analog/vite.config.ts +++ /dev/null @@ -1,29 +0,0 @@ -/// - -import { defineConfig } from 'vite'; -import analog from '@analogjs/platform'; - -// https://vitejs.dev/config/ -export default defineConfig(({ mode }) => ({ - build: { - target: ['es2020'], - }, - resolve: { - mainFields: ['module'], - }, - plugins: [analog({ - nitro: { - preset: "aws-lambda", - } - })], - test: { - globals: true, - environment: 'jsdom', - setupFiles: ['src/test-setup.ts'], - include: ['**/*.spec.ts'], - reporters: ['default'], - }, - define: { - 'import.meta.vitest': mode !== 'production', - }, -})); diff --git a/examples/aws-angular/.editorconfig b/examples/aws-angular/.editorconfig deleted file mode 100644 index 59d9a3a3e7..0000000000 --- a/examples/aws-angular/.editorconfig +++ /dev/null @@ -1,16 +0,0 @@ -# Editor configuration, see https://editorconfig.org -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 2 -insert_final_newline = true -trim_trailing_whitespace = true - -[*.ts] -quote_type = single - -[*.md] -max_line_length = off -trim_trailing_whitespace = false diff --git a/examples/aws-angular/.gitignore b/examples/aws-angular/.gitignore deleted file mode 100644 index c23cd03a2f..0000000000 --- a/examples/aws-angular/.gitignore +++ /dev/null @@ -1,44 +0,0 @@ -# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files. - -# Compiled output -/dist -/tmp -/out-tsc -/bazel-out - -# Node -/node_modules -npm-debug.log -yarn-error.log - -# IDEs and editors -.idea/ -.project -.classpath -.c9/ -*.launch -.settings/ -*.sublime-workspace - -# Visual Studio Code -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -.history/* - -# Miscellaneous -/.angular/cache -.sass-cache/ -/connect.lock -/coverage -/libpeerconnection.log -testem.log -/typings - -# System files -.DS_Store -Thumbs.db - -.sst diff --git a/examples/aws-angular/.vscode/extensions.json b/examples/aws-angular/.vscode/extensions.json deleted file mode 100644 index 77b374577d..0000000000 --- a/examples/aws-angular/.vscode/extensions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846 - "recommendations": ["angular.ng-template"] -} diff --git a/examples/aws-angular/.vscode/launch.json b/examples/aws-angular/.vscode/launch.json deleted file mode 100644 index 925af83705..0000000000 --- a/examples/aws-angular/.vscode/launch.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "ng serve", - "type": "chrome", - "request": "launch", - "preLaunchTask": "npm: start", - "url": "http://localhost:4200/" - }, - { - "name": "ng test", - "type": "chrome", - "request": "launch", - "preLaunchTask": "npm: test", - "url": "http://localhost:9876/debug.html" - } - ] -} diff --git a/examples/aws-angular/.vscode/tasks.json b/examples/aws-angular/.vscode/tasks.json deleted file mode 100644 index a298b5bd87..0000000000 --- a/examples/aws-angular/.vscode/tasks.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558 - "version": "2.0.0", - "tasks": [ - { - "type": "npm", - "script": "start", - "isBackground": true, - "problemMatcher": { - "owner": "typescript", - "pattern": "$tsc", - "background": { - "activeOnStart": true, - "beginsPattern": { - "regexp": "(.*?)" - }, - "endsPattern": { - "regexp": "bundle generation complete" - } - } - } - }, - { - "type": "npm", - "script": "test", - "isBackground": true, - "problemMatcher": { - "owner": "typescript", - "pattern": "$tsc", - "background": { - "activeOnStart": true, - "beginsPattern": { - "regexp": "(.*?)" - }, - "endsPattern": { - "regexp": "bundle generation complete" - } - } - } - } - ] -} diff --git a/examples/aws-angular/angular.json b/examples/aws-angular/angular.json deleted file mode 100644 index e928c0184f..0000000000 --- a/examples/aws-angular/angular.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "$schema": "./node_modules/@angular/cli/lib/config/schema.json", - "version": 1, - "newProjectRoot": "projects", - "projects": { - "aws-angular": { - "projectType": "application", - "schematics": {}, - "root": "", - "sourceRoot": "src", - "prefix": "app", - "architect": { - "build": { - "builder": "@ngx-env/builder:application", - "options": { - "outputPath": "dist/aws-angular", - "index": "src/index.html", - "browser": "src/main.ts", - "polyfills": [ - "zone.js" - ], - "tsConfig": "tsconfig.app.json", - "assets": [ - { - "glob": "**/*", - "input": "public" - } - ], - "styles": [ - "src/styles.css" - ], - "scripts": [] - }, - "configurations": { - "production": { - "budgets": [ - { - "type": "initial", - "maximumWarning": "500kB", - "maximumError": "1MB" - }, - { - "type": "anyComponentStyle", - "maximumWarning": "2kB", - "maximumError": "4kB" - } - ], - "outputHashing": "all" - }, - "development": { - "optimization": false, - "extractLicenses": false, - "sourceMap": true - } - }, - "defaultConfiguration": "production" - }, - "serve": { - "builder": "@ngx-env/builder:dev-server", - "configurations": { - "production": { - "buildTarget": "aws-angular:build:production" - }, - "development": { - "buildTarget": "aws-angular:build:development" - } - }, - "defaultConfiguration": "development" - }, - "extract-i18n": { - "builder": "@ngx-env/builder:extract-i18n" - }, - "test": { - "builder": "@ngx-env/builder:karma", - "options": { - "polyfills": [ - "zone.js", - "zone.js/testing" - ], - "tsConfig": "tsconfig.spec.json", - "assets": [ - { - "glob": "**/*", - "input": "public" - } - ], - "styles": [ - "src/styles.css" - ], - "scripts": [] - } - } - } - } - } -} \ No newline at end of file diff --git a/examples/aws-angular/functions/presigned.ts b/examples/aws-angular/functions/presigned.ts deleted file mode 100644 index 063e82b94f..0000000000 --- a/examples/aws-angular/functions/presigned.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -export async function handler() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - - return { - statusCode: 200, - body: await getSignedUrl(new S3Client({}), command), - }; -} diff --git a/examples/aws-angular/package.json b/examples/aws-angular/package.json deleted file mode 100644 index 26c545ea06..0000000000 --- a/examples/aws-angular/package.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "aws-angular", - "version": "0.0.0", - "scripts": { - "ng": "ng", - "start": "ng serve", - "build": "ng build", - "watch": "ng build --watch --configuration development", - "test": "ng test" - }, - "private": true, - "dependencies": { - "@angular/animations": "^18.2.0", - "@angular/common": "^18.2.0", - "@angular/compiler": "^18.2.0", - "@angular/core": "^18.2.0", - "@angular/forms": "^18.2.0", - "@angular/platform-browser": "^18.2.0", - "@angular/platform-browser-dynamic": "^18.2.0", - "@angular/router": "^18.2.0", - "@aws-sdk/client-s3": "^3.637.0", - "@aws-sdk/s3-request-presigner": "^3.637.0", - "rxjs": "~7.8.0", - "tslib": "^2.3.0", - "zone.js": "~0.14.10" - }, - "devDependencies": { - "@angular-devkit/build-angular": "^18.2.2", - "@angular/cli": "^18.2.2", - "@angular/compiler-cli": "^18.2.0", - "@ngx-env/builder": "^18.0.1", - "@types/jasmine": "~5.1.0", - "jasmine-core": "~5.2.0", - "karma": "~6.4.0", - "karma-chrome-launcher": "~3.2.0", - "karma-coverage": "~2.2.0", - "karma-jasmine": "~5.1.0", - "karma-jasmine-html-reporter": "~2.1.0", - "sst": "file:../../sdk/js", - "typescript": "~5.5.2" - } -} diff --git a/examples/aws-angular/public/favicon.ico b/examples/aws-angular/public/favicon.ico deleted file mode 100644 index 57614f9c96..0000000000 Binary files a/examples/aws-angular/public/favicon.ico and /dev/null differ diff --git a/examples/aws-angular/src/app/app.component.html b/examples/aws-angular/src/app/app.component.html deleted file mode 100644 index 8a552a3da8..0000000000 --- a/examples/aws-angular/src/app/app.component.html +++ /dev/null @@ -1,336 +0,0 @@ - - - - - - - - - - - -
-
-
- -

Hello, {{ title }}

-

Congratulations! Your app is running. 🎉

-
- -
-
- @for (item of [ - { title: 'Explore the Docs', link: 'https://angular.dev' }, - { title: 'Learn with Tutorials', link: 'https://angular.dev/tutorials' }, - { title: 'CLI Docs', link: 'https://angular.dev/tools/cli' }, - { title: 'Angular Language Service', link: 'https://angular.dev/tools/language-service' }, - { title: 'Angular DevTools', link: 'https://angular.dev/tools/devtools' }, - ]; track item.title) { - - {{ item.title }} - - - - - } -
- -
-
-
- - - - - - - - - - - diff --git a/examples/aws-angular/src/app/app.component.spec.ts b/examples/aws-angular/src/app/app.component.spec.ts deleted file mode 100644 index c2e1a61504..0000000000 --- a/examples/aws-angular/src/app/app.component.spec.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { TestBed } from '@angular/core/testing'; -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [AppComponent], - }).compileComponents(); - }); - - it('should create the app', () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - }); - - it(`should have the 'aws-angular' title`, () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('aws-angular'); - }); - - it('should render title', () => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.nativeElement as HTMLElement; - expect(compiled.querySelector('h1')?.textContent).toContain('Hello, aws-angular'); - }); -}); diff --git a/examples/aws-angular/src/app/app.component.ts b/examples/aws-angular/src/app/app.component.ts deleted file mode 100644 index 8ed480a4d4..0000000000 --- a/examples/aws-angular/src/app/app.component.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Component } from '@angular/core'; -import { RouterOutlet } from '@angular/router'; -import { FileUploadComponent } from './file-upload.component'; - -@Component({ - selector: 'app-root', - standalone: true, - imports: [RouterOutlet, FileUploadComponent], - template: ` -
- -
- - `, - styles: [` - main { - margin: auto; - padding: 1.5rem; - max-width: 60ch; - } - `], -}) -export class AppComponent { } diff --git a/examples/aws-angular/src/app/app.config.ts b/examples/aws-angular/src/app/app.config.ts deleted file mode 100644 index 138d4e9d95..0000000000 --- a/examples/aws-angular/src/app/app.config.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core'; -import { provideHttpClient, withFetch } from '@angular/common/http'; -import { provideRouter } from '@angular/router'; - -import { routes } from './app.routes'; - -export const appConfig: ApplicationConfig = { - providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes), provideHttpClient(withFetch())] -}; diff --git a/examples/aws-angular/src/app/app.routes.ts b/examples/aws-angular/src/app/app.routes.ts deleted file mode 100644 index dc39edb5f2..0000000000 --- a/examples/aws-angular/src/app/app.routes.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { Routes } from '@angular/router'; - -export const routes: Routes = []; diff --git a/examples/aws-angular/src/app/file-upload.component.ts b/examples/aws-angular/src/app/file-upload.component.ts deleted file mode 100644 index 25d34d1e5e..0000000000 --- a/examples/aws-angular/src/app/file-upload.component.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { Component, inject } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; -import { FormsModule } from '@angular/forms'; - -@Component({ - selector: 'app-file-upload', - standalone: true, - imports: [FormsModule], - template: ` -
- - -
- `, - styles: [` - form { - color: white; - padding: 2rem; - display: flex; - align-items: center; - justify-content: space-between; - background-color: #23262d; - background-image: none; - background-size: 400%; - border-radius: 0.6rem; - background-position: 100%; - box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1); - } - button { - appearance: none; - border: 0; - font-weight: 500; - border-radius: 5px; - font-size: 0.875rem; - padding: 0.5rem 0.75rem; - background-color: white; - color: black; - } - button:active:enabled { - background-color: #EEE; - } - `] -}) -export class FileUploadComponent { - private http = inject(HttpClient); - - presignedApi = import.meta.env['NG_APP_PRESIGNED_API']; - - async onSubmit(event: Event): Promise { - const file = (event.target as HTMLFormElement)['file'].files?.[0]!; - - this.http.get(this.presignedApi, { responseType: 'text' }).subscribe({ - next: async (url: string) => { - const image = await fetch(url, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }, - }); - } -} diff --git a/examples/aws-angular/src/env.d.ts b/examples/aws-angular/src/env.d.ts deleted file mode 100644 index f27c3a9850..0000000000 --- a/examples/aws-angular/src/env.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Define the type of the environment variables. -declare interface Env { - readonly NODE_ENV: string; - // Replace the following with your own environment variables. - // Example: NGX_VERSION: string; - [key: string]: any; -} - -// Choose how to access the environment variables. -// Remove the unused options. - -// 1. Use import.meta.env.YOUR_ENV_VAR in your code. (conventional) -declare interface ImportMeta { - readonly env: Env; -} - -// 2. Use _NGX_ENV_.YOUR_ENV_VAR in your code. (customizable) -// You can modify the name of the variable in angular.json. -// ngxEnv: { -// define: '_NGX_ENV_', -// } -declare const _NGX_ENV_: Env; - -// 3. Use process.env.YOUR_ENV_VAR in your code. (deprecated) -declare namespace NodeJS { - export interface ProcessEnv extends Env {} -} diff --git a/examples/aws-angular/src/index.html b/examples/aws-angular/src/index.html deleted file mode 100644 index 21b153fb31..0000000000 --- a/examples/aws-angular/src/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - AwsAngular - - - - - - - - diff --git a/examples/aws-angular/src/main.ts b/examples/aws-angular/src/main.ts deleted file mode 100644 index 35b00f3463..0000000000 --- a/examples/aws-angular/src/main.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { bootstrapApplication } from '@angular/platform-browser'; -import { appConfig } from './app/app.config'; -import { AppComponent } from './app/app.component'; - -bootstrapApplication(AppComponent, appConfig) - .catch((err) => console.error(err)); diff --git a/examples/aws-angular/src/styles.css b/examples/aws-angular/src/styles.css deleted file mode 100644 index 90d4ee0072..0000000000 --- a/examples/aws-angular/src/styles.css +++ /dev/null @@ -1 +0,0 @@ -/* You can add global styles to this file, and also import other style files */ diff --git a/examples/aws-angular/sst.config.ts b/examples/aws-angular/sst.config.ts deleted file mode 100644 index 2a2628ce96..0000000000 --- a/examples/aws-angular/sst.config.ts +++ /dev/null @@ -1,36 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-angular", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public", - }); - - const pre = new sst.aws.Function("MyFunction", { - url: true, - link: [bucket], - handler: "functions/presigned.handler", - }); - - new sst.aws.StaticSite("MyWeb", { - dev: { - command: "npm run start", - }, - build: { - output: "dist/browser", - command: "ng build --output-path dist", - }, - environment: { - NG_APP_PRESIGNED_API: pre.url - } - }); - }, -}); - diff --git a/examples/aws-angular/tsconfig.app.json b/examples/aws-angular/tsconfig.app.json deleted file mode 100644 index 3775b37e3b..0000000000 --- a/examples/aws-angular/tsconfig.app.json +++ /dev/null @@ -1,15 +0,0 @@ -/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ -/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "./out-tsc/app", - "types": [] - }, - "files": [ - "src/main.ts" - ], - "include": [ - "src/**/*.d.ts" - ] -} diff --git a/examples/aws-angular/tsconfig.json b/examples/aws-angular/tsconfig.json deleted file mode 100644 index a8bb65b6e2..0000000000 --- a/examples/aws-angular/tsconfig.json +++ /dev/null @@ -1,33 +0,0 @@ -/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ -/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ -{ - "compileOnSave": false, - "compilerOptions": { - "outDir": "./dist/out-tsc", - "strict": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "skipLibCheck": true, - "isolatedModules": true, - "esModuleInterop": true, - "sourceMap": true, - "declaration": false, - "experimentalDecorators": true, - "moduleResolution": "bundler", - "importHelpers": true, - "target": "ES2022", - "module": "ES2022", - "lib": [ - "ES2022", - "dom" - ] - }, - "angularCompilerOptions": { - "enableI18nLegacyMessageIdFormat": false, - "strictInjectionParameters": true, - "strictInputAccessModifiers": true, - "strictTemplates": true - } -} diff --git a/examples/aws-angular/tsconfig.spec.json b/examples/aws-angular/tsconfig.spec.json deleted file mode 100644 index 5fb748d920..0000000000 --- a/examples/aws-angular/tsconfig.spec.json +++ /dev/null @@ -1,15 +0,0 @@ -/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ -/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "./out-tsc/spec", - "types": [ - "jasmine" - ] - }, - "include": [ - "src/**/*.spec.ts", - "src/**/*.d.ts" - ] -} diff --git a/examples/aws-api/.gitignore b/examples/aws-api/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-api/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-api/index.ts b/examples/aws-api/index.ts deleted file mode 100644 index 4c760bfc12..0000000000 --- a/examples/aws-api/index.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { - S3Client, - GetObjectCommand, - PutObjectCommand, - ListObjectsV2Command, -} from "@aws-sdk/client-s3"; - -const s3 = new S3Client({}); - -export async function upload() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - - return { - statusCode: 200, - body: await getSignedUrl(s3, command), - }; -} - -export async function latest() { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }) - ); - - const latestFile = objects.Contents!.sort( - (a, b) => - (b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0) - )[0]; - - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - - return { - statusCode: 302, - headers: { - Location: await getSignedUrl(s3, command), - }, - }; -} diff --git a/examples/aws-api/package.json b/examples/aws-api/package.json deleted file mode 100644 index 544351cff4..0000000000 --- a/examples/aws-api/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "aws-api", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@aws-sdk/client-s3": "^3.540.0", - "@aws-sdk/s3-request-presigner": "^3.540.0", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.142" - } -} diff --git a/examples/aws-api/sst.config.ts b/examples/aws-api/sst.config.ts deleted file mode 100644 index 5a8f1ddcb3..0000000000 --- a/examples/aws-api/sst.config.ts +++ /dev/null @@ -1,23 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-api", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket"); - const api = new sst.aws.ApiGatewayV2("MyApi"); - api.route("GET /", { - link: [bucket], - handler: "index.upload", - }); - api.route("GET /latest", { - link: [bucket], - handler: "index.latest", - }); - }, -}); diff --git a/examples/aws-api/tsconfig.json b/examples/aws-api/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-api/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-apig-auth/package.json b/examples/aws-apig-auth/package.json deleted file mode 100644 index 7776c8ad27..0000000000 --- a/examples/aws-apig-auth/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-apig-auth", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-apig-auth/route.ts b/examples/aws-apig-auth/route.ts deleted file mode 100644 index 3bc5653e3a..0000000000 --- a/examples/aws-apig-auth/route.ts +++ /dev/null @@ -1,7 +0,0 @@ -export const handler = async (event) => { - console.log(event); - return { - statusCode: 200, - body: JSON.stringify({ route: event.routeKey, status: "ok" }, null, 2), - }; -}; diff --git a/examples/aws-apig-auth/sst.config.ts b/examples/aws-apig-auth/sst.config.ts deleted file mode 100644 index 4c07cb077f..0000000000 --- a/examples/aws-apig-auth/sst.config.ts +++ /dev/null @@ -1,43 +0,0 @@ -/// - -/** - * ## API Gateway auth - * - * Enable IAM and JWT authorizers for API Gateway routes. - * - */ -export default $config({ - app(input) { - return { - name: "aws-apig-auth", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const api = new sst.aws.ApiGatewayV2("MyApi", { - domain: { - name: "api.ion.sst.sh", - path: "v1", - }, - }); - api.route("GET /", { - handler: "route.handler", - }); - api.route("GET /foo", "route.handler", { auth: { iam: true } }); - api.route("GET /bar", "route.handler", { - auth: { - jwt: { - issuer: - "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_Rq4d8zILG", - audiences: ["user@example.com"], - }, - }, - }); - api.route("$default", "route.handler"); - - return { - api: api.url, - }; - }, -}); diff --git a/examples/aws-apig-websocket/.gitignore b/examples/aws-apig-websocket/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-apig-websocket/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-apig-websocket/lambda.ts b/examples/aws-apig-websocket/lambda.ts deleted file mode 100644 index 9755466b92..0000000000 --- a/examples/aws-apig-websocket/lambda.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { Resource } from "sst"; -import { - ApiGatewayManagementApiClient, - PostToConnectionCommand, -} from "@aws-sdk/client-apigatewaymanagementapi"; - -export async function connect(event) { - console.log("!!! connect"); - - // If subprotocols are requested, return the allowed protocol. In this example, we only - // allow "MY_ALLOWED_PROTOCOL". - const protocolHeader = event.headers["Sec-WebSocket-Protocol"]; - if (protocolHeader) { - const subprotocols = protocolHeader.split(",").map((p) => p.trim()); - return subprotocols.includes("MY_ALLOWED_PROTOCOL") - ? { - statusCode: 200, - headers: { "Sec-WebSocket-Protocol": "MY_ALLOWED_PROTOCOL" }, - } - : { statusCode: 400 }; - } - - return { statusCode: 200 }; -} - -export async function disconnect(event) { - console.log("!!! disconnect"); - return { statusCode: 200 }; -} - -export async function sendMessage(event) { - console.log("!!! sendMessage"); - return { statusCode: 200 }; -} - -export async function catchAll(event) { - console.log("!!! default"); - - // Send a message back to the client - const client = new ApiGatewayManagementApiClient({ - endpoint: Resource.MyApi.managementEndpoint, - }); - await client.send( - new PostToConnectionCommand({ - ConnectionId: event.requestContext.connectionId, - Data: "Hey! What is this?", - }) - ); - - return { statusCode: 200 }; -} diff --git a/examples/aws-apig-websocket/package.json b/examples/aws-apig-websocket/package.json deleted file mode 100644 index 3b0dba2a21..0000000000 --- a/examples/aws-apig-websocket/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-apig-websocket", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@aws-sdk/client-apigatewaymanagementapi": "^3.699.0", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-apig-websocket/sst.config.ts b/examples/aws-apig-websocket/sst.config.ts deleted file mode 100644 index ebc05181b7..0000000000 --- a/examples/aws-apig-websocket/sst.config.ts +++ /dev/null @@ -1,22 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-apig-websocket", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const api = new sst.aws.ApiGatewayWebSocket("MyApi", {}); - api.route("$connect", "lambda.connect"); - api.route("$disconnect", "lambda.disconnect"); - api.route("$default", { handler: "lambda.catchAll", link: [api] }); - api.route("sendmessage", "lambda.sendMessage"); - - return { - managementEndpoint: api.managementEndpoint, - }; - }, -}); diff --git a/examples/aws-apig-websocket/tsconfig.json b/examples/aws-apig-websocket/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-apig-websocket/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-apigv1-stream/hono.ts b/examples/aws-apigv1-stream/hono.ts deleted file mode 100644 index a80f1f5cbc..0000000000 --- a/examples/aws-apigv1-stream/hono.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Hono } from "hono"; -import { streamText } from "hono/streaming"; -import { streamHandle } from "hono/aws-lambda"; - -const app = new Hono().get("/hono", (c) => { - return streamText(c, async (stream) => { - await stream.writeln("Hello"); - await stream.sleep(3000); - await stream.writeln("World"); - }); -}); - -export const handler = streamHandle(app); diff --git a/examples/aws-apigv1-stream/index.ts b/examples/aws-apigv1-stream/index.ts deleted file mode 100644 index fb8e0b89d2..0000000000 --- a/examples/aws-apigv1-stream/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -export const handler = awslambda.streamifyResponse( - async (event, stream) => { - stream = awslambda.HttpResponseStream.from(stream, { - statusCode: 200, - headers: { - "Content-Type": "text/plain; charset=UTF-8", - "X-Content-Type-Options": "nosniff", - }, - }); - - stream.write("Hello "); - await new Promise((resolve) => setTimeout(resolve, 3000)); - stream.write("World"); - - stream.end(); - }, -); diff --git a/examples/aws-apigv1-stream/package.json b/examples/aws-apigv1-stream/package.json deleted file mode 100644 index 6669ffcf77..0000000000 --- a/examples/aws-apigv1-stream/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "aws-apigv1-stream", - "version": "1.0.0", - "dependencies": { - "@types/aws-lambda": "^8.10.161", - "hono": "^4", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-apigv1-stream/sst.config.ts b/examples/aws-apigv1-stream/sst.config.ts deleted file mode 100644 index 8e27d03985..0000000000 --- a/examples/aws-apigv1-stream/sst.config.ts +++ /dev/null @@ -1,63 +0,0 @@ -/// - -/** - * ## AWS API Gateway V1 streaming - * - * An example on how to enable streaming for API Gateway REST API routes. - * - * ```ts title="sst.config.ts" - * api.route("GET /", { - * handler: "index.handler", - * streaming: true, - * }); - * ``` - * - * The handler uses the native `awslambda.streamifyResponse` and - * `awslambda.HttpResponseStream.from` to stream responses through API Gateway. - * - * ```ts title="index.ts" - * export const handler = awslambda.streamifyResponse( - * async (event, stream) => { - * stream = awslambda.HttpResponseStream.from(stream, { - * statusCode: 200, - * headers: { - * "Content-Type": "text/plain; charset=UTF-8", - * "X-Content-Type-Options": "nosniff", - * }, - * }); - * - * stream.write("Hello "); - * await new Promise((resolve) => setTimeout(resolve, 3000)); - * stream.write("World"); - * - * stream.end(); - * }, - * ); - * ``` - * - */ -export default $config({ - app(input) { - return { - name: "aws-apigv1-stream", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const api = new sst.aws.ApiGatewayV1("MyApi"); - api.route("GET /", { - handler: "index.handler", - streaming: true, - }); - api.route("GET /hono", { - handler: "hono.handler", - streaming: true, - }); - api.deploy(); - - return { - api: api.url, - }; - }, -}); diff --git a/examples/aws-apigv1-stream/tsconfig.json b/examples/aws-apigv1-stream/tsconfig.json deleted file mode 100644 index 853c71f05c..0000000000 --- a/examples/aws-apigv1-stream/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "compilerOptions": { - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true - } -} diff --git a/examples/aws-apigv1/.gitignore b/examples/aws-apigv1/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-apigv1/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-apigv1/index.ts b/examples/aws-apigv1/index.ts deleted file mode 100644 index 149485da7a..0000000000 --- a/examples/aws-apigv1/index.ts +++ /dev/null @@ -1,34 +0,0 @@ -export async function handler() { - return { - statusCode: 200, - body: "hello world", - }; -} - -export async function authorizer(event, context) { - const authHeader = event.authorizationToken; - let username, password; - - if (authHeader) { - const base64Info = authHeader.split(" ")[1]; - // Stored as 'username:password' in base64 - const userInfo = Buffer.from(base64Info, "base64").toString(); - [username, password] = userInfo.split(":"); - } - - return username === "hello" && password === "world" - ? { - principalId: "*", - policyDocument: { - Version: "2012-10-17", - Statement: [ - { - Action: "execute-api:Invoke", - Effect: "Allow", - Resource: "*", - }, - ], - }, - } - : "Unauthorized"; -} diff --git a/examples/aws-apigv1/package.json b/examples/aws-apigv1/package.json deleted file mode 100644 index 132ea3562d..0000000000 --- a/examples/aws-apigv1/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "aws-apigv1", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@aws-sdk/client-s3": "^3.540.0", - "@aws-sdk/s3-request-presigner": "^3.540.0", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-apigv1/sst.config.ts b/examples/aws-apigv1/sst.config.ts deleted file mode 100644 index d2991e0ed3..0000000000 --- a/examples/aws-apigv1/sst.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-apigv1", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const api = new sst.aws.ApiGatewayV1("MyApi"); - const authorizer = api.addAuthorizer({ - name: "MyAuthorizer", - tokenFunction: "index.authorizer", - }); - api.route("GET /", "index.handler"); - api.route("GET /iam", "index.handler", { - auth: { iam: true }, - }); - api.route("GET /token", "index.handler", { - auth: { custom: authorizer.id }, - }); - api.route("GET /{proxy+}", "index.handler"); - api.deploy(); - }, -}); diff --git a/examples/aws-apigv1/tsconfig.json b/examples/aws-apigv1/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-apigv1/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-app-sync/lambda.ts b/examples/aws-app-sync/lambda.ts deleted file mode 100644 index 08136570e8..0000000000 --- a/examples/aws-app-sync/lambda.ts +++ /dev/null @@ -1,10 +0,0 @@ -type AppSyncEvent = { - info: { - fieldName: string; - }; -}; - -export async function main(event: AppSyncEvent) { - console.log(event); - return { status: "ok" }; -} diff --git a/examples/aws-app-sync/package.json b/examples/aws-app-sync/package.json deleted file mode 100644 index 36cadba873..0000000000 --- a/examples/aws-app-sync/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-app-sync", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-app-sync/schema.graphql b/examples/aws-app-sync/schema.graphql deleted file mode 100644 index b2c0cef549..0000000000 --- a/examples/aws-app-sync/schema.graphql +++ /dev/null @@ -1,5 +0,0 @@ -type Query { - license: String - user: String - pipeline: String -} diff --git a/examples/aws-app-sync/sst.config.ts b/examples/aws-app-sync/sst.config.ts deleted file mode 100644 index 53412e24a2..0000000000 --- a/examples/aws-app-sync/sst.config.ts +++ /dev/null @@ -1,47 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-app-sync", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const table = new sst.aws.Dynamo("MyTable", { - fields: { - userId: "string", - }, - primaryIndex: { hashKey: "userId" }, - }); - - const api = new sst.aws.AppSync("MyApi", { - schema: "schema.graphql", - domain: "appsync.ion.sst.sh", - }); - const lambdaDS = api.addDataSource({ - name: "lambda", - lambda: "lambda.main", - }); - const dynamoDS = api.addDataSource({ name: "dyanmo", dynamodb: table.arn }); - api.addResolver("Query license", { dataSource: lambdaDS.name }); - api.addResolver("Query user", { - dataSource: dynamoDS.name, - requestTemplate: `{ - "version": "2017-02-28", - "operation": "Scan", - }`, - responseTemplate: `{ - "users": $utils.toJson($context.result.items) - }`, - }); - - const apiKey = new aws.appsync.ApiKey("MyApiKey", { - apiId: api.id, - }); - return { - API_KEY: apiKey.key, - }; - }, -}); diff --git a/examples/aws-astro-container/.dockerignore b/examples/aws-astro-container/.dockerignore deleted file mode 100644 index cf88ac3dd3..0000000000 --- a/examples/aws-astro-container/.dockerignore +++ /dev/null @@ -1,7 +0,0 @@ -.DS_Store -node_modules -dist - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-astro-container/.gitignore b/examples/aws-astro-container/.gitignore deleted file mode 100644 index 12ff1bf9ce..0000000000 --- a/examples/aws-astro-container/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ -# build output -dist/ - -# generated types -.astro/ - -# dependencies -node_modules/ - -# logs -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# environment variables -.env -.env.production - -# macOS-specific files -.DS_Store - -# jetbrains setting folder -.idea/ - -# sst -.sst diff --git a/examples/aws-astro-container/.vscode/extensions.json b/examples/aws-astro-container/.vscode/extensions.json deleted file mode 100644 index 22a15055d6..0000000000 --- a/examples/aws-astro-container/.vscode/extensions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "recommendations": ["astro-build.astro-vscode"], - "unwantedRecommendations": [] -} diff --git a/examples/aws-astro-container/.vscode/launch.json b/examples/aws-astro-container/.vscode/launch.json deleted file mode 100644 index d642209762..0000000000 --- a/examples/aws-astro-container/.vscode/launch.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "command": "./node_modules/.bin/astro dev", - "name": "Development server", - "request": "launch", - "type": "node-terminal" - } - ] -} diff --git a/examples/aws-astro-container/Dockerfile b/examples/aws-astro-container/Dockerfile deleted file mode 100644 index f096fbb0b5..0000000000 --- a/examples/aws-astro-container/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM node:lts AS base -WORKDIR /app - -COPY package.json package-lock.json ./ - -FROM base AS prod-deps -RUN npm install --omit=dev - -FROM base AS build-deps -RUN npm install - -FROM build-deps AS build -COPY . . -RUN npm run build - -FROM base AS runtime -COPY --from=prod-deps /app/node_modules ./node_modules -COPY --from=build /app/dist ./dist - -ENV HOST=0.0.0.0 -ENV PORT=4321 -EXPOSE 4321 -CMD node ./dist/server/entry.mjs diff --git a/examples/aws-astro-container/astro.config.mjs b/examples/aws-astro-container/astro.config.mjs deleted file mode 100644 index af450f938d..0000000000 --- a/examples/aws-astro-container/astro.config.mjs +++ /dev/null @@ -1,14 +0,0 @@ -// @ts-check -// @ts-check -import { defineConfig } from 'astro/config'; - -import node from '@astrojs/node'; - -// https://astro.build/config -export default defineConfig({ - output: 'server', - - adapter: node({ - mode: 'standalone' - }) -}); diff --git a/examples/aws-astro-container/package.json b/examples/aws-astro-container/package.json deleted file mode 100644 index 1bd6f7c6b7..0000000000 --- a/examples/aws-astro-container/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aws-astro-container", - "type": "module", - "version": "0.0.1", - "scripts": { - "astro": "astro", - "build": "astro check && astro build", - "dev": "astro dev", - "preview": "astro preview" - }, - "dependencies": { - "@astrojs/check": "^0.9.4", - "@astrojs/node": "^8.3.4", - "@aws-sdk/client-s3": "^3.701.0", - "@aws-sdk/s3-request-presigner": "^3.701.0", - "astro": "^4.16.16", - "astro-sst": "2.43.5", - "sst": "file:../../sdk/js", - "typescript": "^5.7.2" - } -} diff --git a/examples/aws-astro-container/public/favicon.svg b/examples/aws-astro-container/public/favicon.svg deleted file mode 100644 index f157bd1c5e..0000000000 --- a/examples/aws-astro-container/public/favicon.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - diff --git a/examples/aws-astro-container/src/assets/astro.svg b/examples/aws-astro-container/src/assets/astro.svg deleted file mode 100644 index 8cf8fb0c7d..0000000000 --- a/examples/aws-astro-container/src/assets/astro.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/aws-astro-container/src/assets/background.svg b/examples/aws-astro-container/src/assets/background.svg deleted file mode 100644 index 4b2be0ac0e..0000000000 --- a/examples/aws-astro-container/src/assets/background.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/aws-astro-container/src/components/Welcome.astro b/examples/aws-astro-container/src/components/Welcome.astro deleted file mode 100644 index d08955687f..0000000000 --- a/examples/aws-astro-container/src/components/Welcome.astro +++ /dev/null @@ -1,209 +0,0 @@ ---- -import astroLogo from '../assets/astro.svg'; -import background from '../assets/background.svg'; ---- - - - - diff --git a/examples/aws-astro-container/src/env.d.ts b/examples/aws-astro-container/src/env.d.ts deleted file mode 100644 index 9bc5cb41c2..0000000000 --- a/examples/aws-astro-container/src/env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// \ No newline at end of file diff --git a/examples/aws-astro-container/src/layouts/Layout.astro b/examples/aws-astro-container/src/layouts/Layout.astro deleted file mode 100644 index e455c61067..0000000000 --- a/examples/aws-astro-container/src/layouts/Layout.astro +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - Astro Basics - - - - - - - diff --git a/examples/aws-astro-container/src/pages/index.astro b/examples/aws-astro-container/src/pages/index.astro deleted file mode 100644 index cb2889fa2a..0000000000 --- a/examples/aws-astro-container/src/pages/index.astro +++ /dev/null @@ -1,74 +0,0 @@ ---- -import { Resource } from "sst"; -import Layout from '../layouts/Layout.astro'; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, -}); -const url = await getSignedUrl(new S3Client({}), command); ---- - - -
-
- - -
- -
-
- - diff --git a/examples/aws-astro-container/sst.config.ts b/examples/aws-astro-container/sst.config.ts deleted file mode 100644 index 4190fc3729..0000000000 --- a/examples/aws-astro-container/sst.config.ts +++ /dev/null @@ -1,30 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-astro-container", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public", - }); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [bucket], - loadBalancer: { - ports: [{ listen: "80/http", forward: "4321/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-astro-container/tsconfig.json b/examples/aws-astro-container/tsconfig.json deleted file mode 100644 index 96e2f10d1c..0000000000 --- a/examples/aws-astro-container/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "astro/tsconfigs/strict", - "include": [ - ".astro/types.d.ts", - "**/*" - ], - "exclude": [ - "dist","sst.config.ts" - ] -} diff --git a/examples/aws-astro-redis/.dockerignore b/examples/aws-astro-redis/.dockerignore deleted file mode 100644 index cf88ac3dd3..0000000000 --- a/examples/aws-astro-redis/.dockerignore +++ /dev/null @@ -1,7 +0,0 @@ -.DS_Store -node_modules -dist - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-astro-redis/.gitignore b/examples/aws-astro-redis/.gitignore deleted file mode 100644 index 12ff1bf9ce..0000000000 --- a/examples/aws-astro-redis/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ -# build output -dist/ - -# generated types -.astro/ - -# dependencies -node_modules/ - -# logs -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# environment variables -.env -.env.production - -# macOS-specific files -.DS_Store - -# jetbrains setting folder -.idea/ - -# sst -.sst diff --git a/examples/aws-astro-redis/.vscode/extensions.json b/examples/aws-astro-redis/.vscode/extensions.json deleted file mode 100644 index 22a15055d6..0000000000 --- a/examples/aws-astro-redis/.vscode/extensions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "recommendations": ["astro-build.astro-vscode"], - "unwantedRecommendations": [] -} diff --git a/examples/aws-astro-redis/.vscode/launch.json b/examples/aws-astro-redis/.vscode/launch.json deleted file mode 100644 index d642209762..0000000000 --- a/examples/aws-astro-redis/.vscode/launch.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "command": "./node_modules/.bin/astro dev", - "name": "Development server", - "request": "launch", - "type": "node-terminal" - } - ] -} diff --git a/examples/aws-astro-redis/Dockerfile b/examples/aws-astro-redis/Dockerfile deleted file mode 100644 index 843b983342..0000000000 --- a/examples/aws-astro-redis/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -# From https://docs.astro.build/en/recipes/docker/ - -FROM node:lts AS base -WORKDIR /app - -# By copying only the package.json and package-lock.json here, we ensure that the following `-deps` steps are independent of the source code. -# Therefore, the `-deps` steps will be skipped if only the source code changes. -COPY package.json package-lock.json ./ - -FROM base AS prod-deps -RUN npm install --omit=dev - -FROM base AS build-deps -RUN npm install - -FROM build-deps AS build -COPY . . -RUN npm run build - -FROM base AS runtime -COPY --from=prod-deps /app/node_modules ./node_modules -COPY --from=build /app/dist ./dist - -ENV HOST=0.0.0.0 -ENV PORT=4321 -EXPOSE 4321 -CMD node ./dist/server/entry.mjs diff --git a/examples/aws-astro-redis/astro.config.mjs b/examples/aws-astro-redis/astro.config.mjs deleted file mode 100644 index b806b438e1..0000000000 --- a/examples/aws-astro-redis/astro.config.mjs +++ /dev/null @@ -1,13 +0,0 @@ -// @ts-check -import { defineConfig } from 'astro/config'; - -import node from '@astrojs/node'; - -// https://astro.build/config -export default defineConfig({ - output: 'server', - - adapter: node({ - mode: 'standalone' - }) -}); \ No newline at end of file diff --git a/examples/aws-astro-redis/package.json b/examples/aws-astro-redis/package.json deleted file mode 100644 index 24ddfc5ac6..0000000000 --- a/examples/aws-astro-redis/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aws-astro-redis", - "type": "module", - "version": "0.0.1", - "scripts": { - "astro": "astro", - "build": "astro check && astro build", - "dev": "astro dev", - "preview": "astro preview", - "start": "astro dev" - }, - "dependencies": { - "@astrojs/check": "^0.9.4", - "@astrojs/node": "^8.3.4", - "astro": "^4.16.3", - "astro-sst": "2.43.5", - "ioredis": "^5.4.1", - "sst": "file:../../sdk/js", - "typescript": "^5.6.3" - } -} diff --git a/examples/aws-astro-redis/public/favicon.svg b/examples/aws-astro-redis/public/favicon.svg deleted file mode 100644 index f157bd1c5e..0000000000 --- a/examples/aws-astro-redis/public/favicon.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - diff --git a/examples/aws-astro-redis/src/components/Card.astro b/examples/aws-astro-redis/src/components/Card.astro deleted file mode 100644 index bd6d5971eb..0000000000 --- a/examples/aws-astro-redis/src/components/Card.astro +++ /dev/null @@ -1,61 +0,0 @@ ---- -interface Props { - title: string; - body: string; - href: string; -} - -const { href, title, body } = Astro.props; ---- - - - diff --git a/examples/aws-astro-redis/src/env.d.ts b/examples/aws-astro-redis/src/env.d.ts deleted file mode 100644 index 9bc5cb41c2..0000000000 --- a/examples/aws-astro-redis/src/env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// \ No newline at end of file diff --git a/examples/aws-astro-redis/src/layouts/Layout.astro b/examples/aws-astro-redis/src/layouts/Layout.astro deleted file mode 100644 index 181097125d..0000000000 --- a/examples/aws-astro-redis/src/layouts/Layout.astro +++ /dev/null @@ -1,50 +0,0 @@ ---- -interface Props { - title: string; -} - -const { title } = Astro.props; ---- - - - - - - - - - - {title} - - - - - - diff --git a/examples/aws-astro-redis/src/pages/index.astro b/examples/aws-astro-redis/src/pages/index.astro deleted file mode 100644 index d6602d4bce..0000000000 --- a/examples/aws-astro-redis/src/pages/index.astro +++ /dev/null @@ -1,44 +0,0 @@ ---- -import { Resource } from "sst"; -import { Cluster } from "ioredis"; -import Layout from '../layouts/Layout.astro'; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -const counter = await redis.incr("counter"); ---- - - -
-

Hit counter: {counter}

-
-
- - diff --git a/examples/aws-astro-redis/sst.config.ts b/examples/aws-astro-redis/sst.config.ts deleted file mode 100644 index 621ca85c0a..0000000000 --- a/examples/aws-astro-redis/sst.config.ts +++ /dev/null @@ -1,68 +0,0 @@ -/// - -/** - * ## AWS Astro container with Redis - * - * Creates a hit counter app with Astro and Redis. - * - * This deploys Astro as a Fargate service to ECS and it's linked to Redis. - * - * ```ts title="sst.config.ts" {3} - * new sst.aws.Service("MyService", { - * cluster, - * link: [redis], - * loadBalancer: { - * ports: [{ listen: "80/http", forward: "3000/http" }], - * }, - * dev: { - * command: "npm run dev", - * }, - * }); - * ``` - * - * Since our Redis cluster is in a VPC, we’ll need a tunnel to connect to it from our local - * machine. - * - * ```bash "sudo" - * sudo npx sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * To start your app locally run. - * - * ```bash - * npx sst dev - * ``` - * - * Now if you go to `http://localhost:4321` you’ll see a counter update as you refresh the page. - * - * Finally, you can deploy it by adding the `Dockerfile` that's included in this example and - * running `npx sst deploy --stage production`. - */ -export default $config({ - app(input) { - return { - name: "aws-astro-redis", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: "80/http", forward: "4321/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-astro-redis/tsconfig.json b/examples/aws-astro-redis/tsconfig.json deleted file mode 100644 index ddbfe3e6f3..0000000000 --- a/examples/aws-astro-redis/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "astro/tsconfigs/strict", - "exclude": ["sst.config.ts"] -} diff --git a/examples/aws-astro-stream/.gitignore b/examples/aws-astro-stream/.gitignore deleted file mode 100644 index 12ff1bf9ce..0000000000 --- a/examples/aws-astro-stream/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ -# build output -dist/ - -# generated types -.astro/ - -# dependencies -node_modules/ - -# logs -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# environment variables -.env -.env.production - -# macOS-specific files -.DS_Store - -# jetbrains setting folder -.idea/ - -# sst -.sst diff --git a/examples/aws-astro-stream/.vscode/extensions.json b/examples/aws-astro-stream/.vscode/extensions.json deleted file mode 100644 index 22a15055d6..0000000000 --- a/examples/aws-astro-stream/.vscode/extensions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "recommendations": ["astro-build.astro-vscode"], - "unwantedRecommendations": [] -} diff --git a/examples/aws-astro-stream/.vscode/launch.json b/examples/aws-astro-stream/.vscode/launch.json deleted file mode 100644 index d642209762..0000000000 --- a/examples/aws-astro-stream/.vscode/launch.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "command": "./node_modules/.bin/astro dev", - "name": "Development server", - "request": "launch", - "type": "node-terminal" - } - ] -} diff --git a/examples/aws-astro-stream/astro.config.mjs b/examples/aws-astro-stream/astro.config.mjs deleted file mode 100644 index d08eebd972..0000000000 --- a/examples/aws-astro-stream/astro.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -// @ts-check -import aws from "astro-sst"; -import { defineConfig } from 'astro/config'; - -// https://astro.build/config -export default defineConfig({ - output: "server", - adapter: aws({ - responseMode: "stream", - }), -}); diff --git a/examples/aws-astro-stream/package.json b/examples/aws-astro-stream/package.json deleted file mode 100644 index d2ee3a1fb7..0000000000 --- a/examples/aws-astro-stream/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-astro-stream", - "type": "module", - "version": "0.0.1", - "scripts": { - "astro": "astro", - "build": "astro check && astro build", - "dev": "astro dev", - "preview": "astro preview", - "start": "astro dev" - }, - "dependencies": { - "@astrojs/check": "^0.9.3", - "astro": "^4.15.9", - "astro-sst": "2.43.5", - "sst": "file:../../sdk/js", - "typescript": "^5.6.2" - } -} diff --git a/examples/aws-astro-stream/public/favicon.svg b/examples/aws-astro-stream/public/favicon.svg deleted file mode 100644 index f157bd1c5e..0000000000 --- a/examples/aws-astro-stream/public/favicon.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - diff --git a/examples/aws-astro-stream/public/mr-krabs.png b/examples/aws-astro-stream/public/mr-krabs.png deleted file mode 100644 index e94ea64054..0000000000 Binary files a/examples/aws-astro-stream/public/mr-krabs.png and /dev/null differ diff --git a/examples/aws-astro-stream/public/patrick.png b/examples/aws-astro-stream/public/patrick.png deleted file mode 100644 index 030eaaf8a3..0000000000 Binary files a/examples/aws-astro-stream/public/patrick.png and /dev/null differ diff --git a/examples/aws-astro-stream/public/sandy.png b/examples/aws-astro-stream/public/sandy.png deleted file mode 100644 index eb7a9cc324..0000000000 Binary files a/examples/aws-astro-stream/public/sandy.png and /dev/null differ diff --git a/examples/aws-astro-stream/public/spongebob.png b/examples/aws-astro-stream/public/spongebob.png deleted file mode 100644 index 18f7df537e..0000000000 Binary files a/examples/aws-astro-stream/public/spongebob.png and /dev/null differ diff --git a/examples/aws-astro-stream/public/squidward.png b/examples/aws-astro-stream/public/squidward.png deleted file mode 100644 index 4af85e000b..0000000000 Binary files a/examples/aws-astro-stream/public/squidward.png and /dev/null differ diff --git a/examples/aws-astro-stream/src/components/Bio.astro b/examples/aws-astro-stream/src/components/Bio.astro deleted file mode 100644 index 0cac88361e..0000000000 --- a/examples/aws-astro-stream/src/components/Bio.astro +++ /dev/null @@ -1,35 +0,0 @@ ---- -import type { Character } from "./character"; - -const spongebob: Character = { - name: "SpongeBob SquarePants", - description: "SpongeBob SquarePants is the main character of the popular animated TV series. He's a cheerful sea sponge who lives in a pineapple house in the underwater city of Bikini Bottom. SpongeBob works as a fry cook at the Krusty Krab and loves jellyfishing with his best friend Patrick Star.", - image: "spongebob.png", -}; ---- -
-

{spongebob.name}

-
-
-

{spongebob.description}

-
- {spongebob.name} -
-
- - diff --git a/examples/aws-astro-stream/src/components/Friends.astro b/examples/aws-astro-stream/src/components/Friends.astro deleted file mode 100644 index b3f69f2815..0000000000 --- a/examples/aws-astro-stream/src/components/Friends.astro +++ /dev/null @@ -1,43 +0,0 @@ ---- -import type { Character } from "./character"; - -const friends: Character[] = await new Promise((resolve) => setTimeout(() => { - setTimeout(() => { - resolve( - [ - { name: "Patrick Star", image: "patrick.png" }, - { name: "Sandy Cheeks", image: "sandy.png" }, - { name: "Squidward Tentacles", image: "squidward.png" }, - { name: "Mr. Krabs", image: "mr-krabs.png" }, - ] - ); - }, 3000); -})); ---- -
- {friends.map((friend) => ( -
- {friend.name} -

{friend.name}

-
- ))} -
- - diff --git a/examples/aws-astro-stream/src/components/character.ts b/examples/aws-astro-stream/src/components/character.ts deleted file mode 100644 index b1c51ce400..0000000000 --- a/examples/aws-astro-stream/src/components/character.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface Character { - name: string; - image: string; - description?: string; -} diff --git a/examples/aws-astro-stream/src/env.d.ts b/examples/aws-astro-stream/src/env.d.ts deleted file mode 100644 index 9bc5cb41c2..0000000000 --- a/examples/aws-astro-stream/src/env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// \ No newline at end of file diff --git a/examples/aws-astro-stream/src/layouts/Layout.astro b/examples/aws-astro-stream/src/layouts/Layout.astro deleted file mode 100644 index 9b3c662692..0000000000 --- a/examples/aws-astro-stream/src/layouts/Layout.astro +++ /dev/null @@ -1,39 +0,0 @@ ---- -interface Props { - title: string; -} - -const { title } = Astro.props; ---- - - - - - - - - - - {title} - - -
- -
- - - diff --git a/examples/aws-astro-stream/src/pages/index.astro b/examples/aws-astro-stream/src/pages/index.astro deleted file mode 100644 index 8b90a967db..0000000000 --- a/examples/aws-astro-stream/src/pages/index.astro +++ /dev/null @@ -1,73 +0,0 @@ ---- -import Layout from '../layouts/Layout.astro'; -import Bio from '../components/Bio.astro'; -import Friends from '../components/Friends.astro'; ---- - - - - -
-

Friends from Bikini Bottom

- -
-
- - diff --git a/examples/aws-astro-stream/sst.config.ts b/examples/aws-astro-stream/sst.config.ts deleted file mode 100644 index 856fce0412..0000000000 --- a/examples/aws-astro-stream/sst.config.ts +++ /dev/null @@ -1,70 +0,0 @@ -/// - -/** - * ## AWS Astro streaming - * - * Follows the [Astro Streaming](https://docs.astro.build/en/recipes/streaming-improve-page-performance/) guide to create an app that streams HTML. - * - * The `responseMode` in the [`astro-sst`](https://www.npmjs.com/package/astro-sst) adapter - * is set to enable streaming. - * - * - * ```ts title="astro.config.mjs" - * adapter: aws({ - * responseMode: "stream" - * }) - * ``` - * - * Now any components that return promises will be streamed. - * - * ```astro title="src/components/Friends.astro" - * --- - * import type { Character } from "./character"; - * - * const friends: Character[] = await new Promise((resolve) => setTimeout(() => { - * setTimeout(() => { - * resolve( - * [ - * { name: "Patrick Star", image: "patrick.png" }, - * { name: "Sandy Cheeks", image: "sandy.png" }, - * { name: "Squidward Tentacles", image: "squidward.png" }, - * { name: "Mr. Krabs", image: "mr-krabs.png" }, - * ] - * ); - * }, 3000); - * })); - * --- - *
- * {friends.map((friend) => ( - *
- * {friend.name} - *

{friend.name}

- *
- * ))} - *
- * ``` - * - * You should see the _friends_ section load after a 3 second delay. - * - * :::note - * Safari handles streaming differently than other browsers. - * ::: - * - * Safari uses a [different heuristic](https://bugs.webkit.org/show_bug.cgi?id=252413) to - * determine when to stream data. You need to render _enough_ initial HTML to trigger streaming. - * This is typically only a problem for demo apps. - * - * There's nothing to configure for streaming in the `Astro` component. - */ -export default $config({ - app(input) { - return { - name: "aws-astro-stream", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - new sst.aws.Astro("MyWeb"); - }, -}); diff --git a/examples/aws-astro-stream/tsconfig.json b/examples/aws-astro-stream/tsconfig.json deleted file mode 100644 index 77da9dd009..0000000000 --- a/examples/aws-astro-stream/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "astro/tsconfigs/strict" -} \ No newline at end of file diff --git a/examples/aws-astro/.gitignore b/examples/aws-astro/.gitignore deleted file mode 100644 index 9a746a2f70..0000000000 --- a/examples/aws-astro/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# build output -dist/ - -# generated types -.astro/ - -# dependencies -node_modules/ - -# logs -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# environment variables -.env -.env.production - -# macOS-specific files -.DS_Store - -# sst -.sst diff --git a/examples/aws-astro/.vscode/extensions.json b/examples/aws-astro/.vscode/extensions.json deleted file mode 100644 index 22a15055d6..0000000000 --- a/examples/aws-astro/.vscode/extensions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "recommendations": ["astro-build.astro-vscode"], - "unwantedRecommendations": [] -} diff --git a/examples/aws-astro/.vscode/launch.json b/examples/aws-astro/.vscode/launch.json deleted file mode 100644 index d642209762..0000000000 --- a/examples/aws-astro/.vscode/launch.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "command": "./node_modules/.bin/astro dev", - "name": "Development server", - "request": "launch", - "type": "node-terminal" - } - ] -} diff --git a/examples/aws-astro/astro.config.mjs b/examples/aws-astro/astro.config.mjs deleted file mode 100644 index b4f287b9a8..0000000000 --- a/examples/aws-astro/astro.config.mjs +++ /dev/null @@ -1,7 +0,0 @@ -import { defineConfig } from "astro/config"; -import aws from "astro-sst"; - -export default defineConfig({ - output: "server", - adapter: aws(), -}); diff --git a/examples/aws-astro/package.json b/examples/aws-astro/package.json deleted file mode 100644 index 6c677d9e32..0000000000 --- a/examples/aws-astro/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aws-astro", - "type": "module", - "version": "0.0.1", - "scripts": { - "dev": "astro dev", - "start": "astro dev", - "build": "astro check && astro build", - "preview": "astro preview", - "astro": "astro" - }, - "dependencies": { - "@astrojs/check": "^0.5.10", - "@aws-sdk/client-s3": "^3.540.0", - "@aws-sdk/s3-request-presigner": "^3.540.0", - "astro": "^4.5.9", - "astro-sst": "^2.41.2", - "sst": "file:../../sdk/js", - "typescript": "^5.4.3" - } -} diff --git a/examples/aws-astro/public/favicon.svg b/examples/aws-astro/public/favicon.svg deleted file mode 100644 index f157bd1c5e..0000000000 --- a/examples/aws-astro/public/favicon.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - diff --git a/examples/aws-astro/src/components/Card.astro b/examples/aws-astro/src/components/Card.astro deleted file mode 100644 index bd6d5971eb..0000000000 --- a/examples/aws-astro/src/components/Card.astro +++ /dev/null @@ -1,61 +0,0 @@ ---- -interface Props { - title: string; - body: string; - href: string; -} - -const { href, title, body } = Astro.props; ---- - - - diff --git a/examples/aws-astro/src/env.d.ts b/examples/aws-astro/src/env.d.ts deleted file mode 100644 index f964fe0cff..0000000000 --- a/examples/aws-astro/src/env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/examples/aws-astro/src/layouts/Layout.astro b/examples/aws-astro/src/layouts/Layout.astro deleted file mode 100644 index 7b552be19b..0000000000 --- a/examples/aws-astro/src/layouts/Layout.astro +++ /dev/null @@ -1,51 +0,0 @@ ---- -interface Props { - title: string; -} - -const { title } = Astro.props; ---- - - - - - - - - - - {title} - - - - - - diff --git a/examples/aws-astro/src/pages/index.astro b/examples/aws-astro/src/pages/index.astro deleted file mode 100644 index cb2889fa2a..0000000000 --- a/examples/aws-astro/src/pages/index.astro +++ /dev/null @@ -1,74 +0,0 @@ ---- -import { Resource } from "sst"; -import Layout from '../layouts/Layout.astro'; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, -}); -const url = await getSignedUrl(new S3Client({}), command); ---- - - -
-
- - -
- -
-
- - diff --git a/examples/aws-astro/sst.config.ts b/examples/aws-astro/sst.config.ts deleted file mode 100644 index f115965f2c..0000000000 --- a/examples/aws-astro/sst.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-astro", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public", - }); - new sst.aws.Astro("MyWeb", { - link: [bucket], - }); - }, -}); diff --git a/examples/aws-astro/tsconfig.json b/examples/aws-astro/tsconfig.json deleted file mode 100644 index 77da9dd009..0000000000 --- a/examples/aws-astro/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "astro/tsconfigs/strict" -} \ No newline at end of file diff --git a/examples/aws-aurora-local/.gitignore b/examples/aws-aurora-local/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-aurora-local/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-aurora-local/index.ts b/examples/aws-aurora-local/index.ts deleted file mode 100644 index b0f7a15ddd..0000000000 --- a/examples/aws-aurora-local/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -import postgres from "postgres"; -import { Resource } from "sst"; - -const sql = postgres({ - username: Resource.MyPostgres.username, - password: Resource.MyPostgres.password, - database: Resource.MyPostgres.database, - host: Resource.MyPostgres.host, - port: Resource.MyPostgres.port, -}); - -export async function handler() { - const result = await sql`SELECT NOW()`; - - return { - statusCode: 200, - body: `Querying ${Resource.MyPostgres.host}\n\n` + result.rows[0].now, - }; -} diff --git a/examples/aws-aurora-local/package.json b/examples/aws-aurora-local/package.json deleted file mode 100644 index d1dee66d4c..0000000000 --- a/examples/aws-aurora-local/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-aurora-local", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "postgres": "^3.4.5", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-aurora-local/sst.config.ts b/examples/aws-aurora-local/sst.config.ts deleted file mode 100644 index 940240acb1..0000000000 --- a/examples/aws-aurora-local/sst.config.ts +++ /dev/null @@ -1,87 +0,0 @@ -/// - -/** - * ## AWS Aurora local - * - * In this example, we connect to a locally running Postgres instance for dev. While - * on deploy, we use RDS Aurora. - * - * We use the [`docker run`](https://docs.docker.com/reference/cli/docker/container/run/) CLI - * to start a local container with Postgres. You don't have to use Docker, you can use - * Postgres.app or any other way to run Postgres locally. - * - * ```bash - * docker run \ - * --rm \ - * -p 5432:5432 \ - * -v $(pwd)/.sst/storage/postgres:/var/lib/postgresql/data \ - * -e POSTGRES_USER=postgres \ - * -e POSTGRES_PASSWORD=password \ - * -e POSTGRES_DB=local \ - * postgres:16.4 - * ``` - * - * The data is saved to the `.sst/storage` directory. So if you restart the dev server, the - * data will still be there. - * - * We then configure the `dev` property of the `Aurora` component with the settings for the - * local Postgres instance. - * - * ```ts title="sst.config.ts" - * dev: { - * username: "postgres", - * password: "password", - * database: "local", - * port: 5432, - * } - * ``` - * - * By providing the `dev` prop for Postgres, SST will use the local Postgres instance and - * not deploy a new RDS database when running `sst dev`. - * - * It also allows us to access the database through a Resource `link` without having to - * conditionally check if we are running locally. - * - * ```ts title="index.ts" - * const pool = new Pool({ - * host: Resource.MyPostgres.host, - * port: Resource.MyPostgres.port, - * user: Resource.MyPostgres.username, - * password: Resource.MyPostgres.password, - * database: Resource.MyPostgres.database, - * }); - * ``` - * - * The above will work in both `sst dev` and `sst deploy`. - */ -export default $config({ - app(input) { - return { - name: "aws-aurora-local", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { nat: "ec2" }); - - const database = new sst.aws.Aurora("MyPostgres", { - engine: "postgres", - dev: { - username: "postgres", - password: "password", - database: "local", - host: "localhost", - port: 5432, - }, - vpc, - }); - - new sst.aws.Function("MyFunction", { - vpc, - url: true, - link: [database], - handler: "index.handler", - }); - }, -}); diff --git a/examples/aws-aurora-local/tsconfig.json b/examples/aws-aurora-local/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-aurora-local/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-aurora-mysql/index.ts b/examples/aws-aurora-mysql/index.ts deleted file mode 100644 index dcfc68e8b2..0000000000 --- a/examples/aws-aurora-mysql/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Resource } from "sst"; -import mysql from "mysql2/promise"; - -const connection = await mysql.createConnection({ - database: Resource.MyDatabase.database, - host: Resource.MyDatabase.host, - port: Resource.MyDatabase.port, - user: Resource.MyDatabase.username, - password: Resource.MyDatabase.password, -}); - -export async function handler() { - const [rows] = await connection.query("SELECT ? as message", [ - "Hello world!", - ]); - return { - statusCode: 200, - body: rows[0].message, - }; -} diff --git a/examples/aws-aurora-mysql/package.json b/examples/aws-aurora-mysql/package.json deleted file mode 100644 index e1996251eb..0000000000 --- a/examples/aws-aurora-mysql/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-aurora-mysql", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "mysql2": "^3.12.0", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-aurora-mysql/sst.config.ts b/examples/aws-aurora-mysql/sst.config.ts deleted file mode 100644 index 72f57b73ac..0000000000 --- a/examples/aws-aurora-mysql/sst.config.ts +++ /dev/null @@ -1,83 +0,0 @@ -/// - -/** - * ## AWS Aurora MySQL - * - * In this example, we deploy a Aurora MySQL database. - * - * ```ts title="sst.config.ts" - * const mysql = new sst.aws.Aurora("MyDatabase", { - * engine: "mysql", - * vpc, - * }); - * ``` - * - * And link it to a Lambda function. - * - * ```ts title="sst.config.ts" {4} - * new sst.aws.Function("MyApp", { - * handler: "index.handler", - * link: [mysql], - * url: true, - * vpc, - * }); - * ``` - * - * Now in the function we can access the database. - * - * ```ts title="index.ts" - * const connection = await mysql.createConnection({ - * database: Resource.MyDatabase.database, - * host: Resource.MyDatabase.host, - * port: Resource.MyDatabase.port, - * user: Resource.MyDatabase.username, - * password: Resource.MyDatabase.password, - * }); - * ``` - * - * We also enable the `bastion` option for the VPC. This allows us to connect to the database - * from our local machine with the `sst tunnel` CLI. - * - * ```bash "sudo" - * sudo npx sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * Now you can run `npx sst dev` and you can connect to the database from your local machine. - * - */ -export default $config({ - app(input) { - return { - name: "aws-aurora-mysql", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { - nat: "ec2", - bastion: true, - }); - const mysql = new sst.aws.Aurora("MyDatabase", { - engine: "mysql", - vpc, - }); - new sst.aws.Function("MyApp", { - handler: "index.handler", - link: [mysql], - url: true, - vpc, - }); - - return { - host: mysql.host, - port: mysql.port, - username: mysql.username, - password: mysql.password, - database: mysql.database, - }; - }, -}); diff --git a/examples/aws-aurora-postgres/index.ts b/examples/aws-aurora-postgres/index.ts deleted file mode 100644 index cf76e8201a..0000000000 --- a/examples/aws-aurora-postgres/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -import postgres from "postgres"; -import { Resource } from "sst"; - -const sql = postgres({ - username: Resource.MyDatabase.username, - password: Resource.MyDatabase.password, - database: Resource.MyDatabase.database, - host: Resource.MyDatabase.host, - port: Resource.MyDatabase.port, -}); - -export async function handler() { - const res = await sql`SELECT ${"Hello world!"}::text as message`; - return { - statusCode: 200, - body: res.at(0)?.message, - }; -} diff --git a/examples/aws-aurora-postgres/package.json b/examples/aws-aurora-postgres/package.json deleted file mode 100644 index 941512a6ae..0000000000 --- a/examples/aws-aurora-postgres/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-aurora-postgres", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "postgres": "^3.4.5", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-aurora-postgres/sst.config.ts b/examples/aws-aurora-postgres/sst.config.ts deleted file mode 100644 index 55cfeda634..0000000000 --- a/examples/aws-aurora-postgres/sst.config.ts +++ /dev/null @@ -1,86 +0,0 @@ -/// - -/** - * ## AWS Aurora Postgres - * - * In this example, we deploy a Aurora Postgres database. - * - * ```ts title="sst.config.ts" - * const postgres = new sst.aws.Aurora("MyDatabase", { - * engine: "postgres", - * vpc, - * }); - * ``` - * - * And link it to a Lambda function. - * - * ```ts title="sst.config.ts" {4} - * new sst.aws.Function("MyApp", { - * handler: "index.handler", - * link: [postgres], - * url: true, - * vpc, - * }); - * ``` - * - * In the function we use the [`postgres`](https://www.npmjs.com/package/postgres) package. - * - * ```ts title="index.ts" - * import postgres from "postgres"; - * import { Resource } from "sst"; - * - * const sql = postgres({ - * username: Resource.MyDatabase.username, - * password: Resource.MyDatabase.password, - * database: Resource.MyDatabase.database, - * host: Resource.MyDatabase.host, - * port: Resource.MyDatabase.port, - * }); - * ``` - * - * We also enable the `bastion` option for the VPC. This allows us to connect to the database - * from our local machine with the `sst tunnel` CLI. - * - * ```bash "sudo" - * sudo npx sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * Now you can run `npx sst dev` and you can connect to the database from your local machine. - * - */ -export default $config({ - app(input) { - return { - name: "aws-aurora-postgres", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { - nat: "ec2", - bastion: true, - }); - const postgres = new sst.aws.Aurora("MyDatabase", { - engine: "postgres", - vpc, - }); - new sst.aws.Function("MyApp", { - handler: "index.handler", - link: [postgres], - url: true, - vpc, - }); - - return { - host: postgres.host, - port: postgres.port, - username: postgres.username, - password: postgres.password, - database: postgres.database, - }; - }, -}); diff --git a/examples/aws-auth-nextjs/.gitignore b/examples/aws-auth-nextjs/.gitignore deleted file mode 100644 index 845fae0e4b..0000000000 --- a/examples/aws-auth-nextjs/.gitignore +++ /dev/null @@ -1,47 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.* -.yarn/* -!.yarn/patches -!.yarn/plugins -!.yarn/releases -!.yarn/versions - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* -.pnpm-debug.log* - -# env files (can opt-in for committing if needed) -.env* - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts - -# sst -.sst - -# open-next -.open-next diff --git a/examples/aws-auth-nextjs/app/actions.ts b/examples/aws-auth-nextjs/app/actions.ts deleted file mode 100644 index 1a3e291c37..0000000000 --- a/examples/aws-auth-nextjs/app/actions.ts +++ /dev/null @@ -1,62 +0,0 @@ -"use server"; - -import { redirect } from "next/navigation"; -import { headers as getHeaders, cookies as getCookies } from "next/headers"; -import { subjects } from "../auth/subjects"; -import { client, setTokens } from "./auth"; - -export async function auth() { - const cookies = await getCookies(); - const accessToken = cookies.get("access_token"); - const refreshToken = cookies.get("refresh_token"); - - if (!accessToken) { - return false; - } - - const verified = await client.verify(subjects, accessToken.value, { - refresh: refreshToken?.value, - }); - - if (verified.err) { - return false; - } - if (verified.tokens) { - await setTokens(verified.tokens.access, verified.tokens.refresh); - } - - return verified.subject; -} - -export async function login() { - const cookies = await getCookies(); - const accessToken = cookies.get("access_token"); - const refreshToken = cookies.get("refresh_token"); - - if (accessToken) { - const verified = await client.verify(subjects, accessToken.value, { - refresh: refreshToken?.value, - }); - if (!verified.err && verified.tokens) { - await setTokens(verified.tokens.access, verified.tokens.refresh); - redirect("/"); - } - } - - const headers = await getHeaders(); - const host = headers.get("host"); - const protocol = host?.includes("localhost") ? "http" : "https"; - const { url } = await client.authorize( - `${protocol}://${host}/api/callback`, - "code", - ); - redirect(url); -} - -export async function logout() { - const cookies = await getCookies(); - cookies.delete("access_token"); - cookies.delete("refresh_token"); - - redirect("/"); -} diff --git a/examples/aws-auth-nextjs/app/api/callback/route.ts b/examples/aws-auth-nextjs/app/api/callback/route.ts deleted file mode 100644 index 6bcce834a7..0000000000 --- a/examples/aws-auth-nextjs/app/api/callback/route.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { client, setTokens } from "../../auth"; -import { type NextRequest, NextResponse } from "next/server"; - -export async function GET(req: NextRequest) { - const url = new URL(req.url); - const code = url.searchParams.get("code"); - - const exchanged = await client.exchange(code!, `${url.origin}/api/callback`); - - if (exchanged.err) return NextResponse.json(exchanged.err, { status: 400 }); - - await setTokens(exchanged.tokens.access, exchanged.tokens.refresh); - - return NextResponse.redirect(`${url.origin}/`); -} diff --git a/examples/aws-auth-nextjs/app/auth.ts b/examples/aws-auth-nextjs/app/auth.ts deleted file mode 100644 index 792ad3aeea..0000000000 --- a/examples/aws-auth-nextjs/app/auth.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Resource } from "sst"; -import { createClient } from "@openauthjs/openauth/client"; -import { cookies as getCookies } from "next/headers"; - -export const client = createClient({ - clientID: "nextjs", - issuer: Resource.MyAuth.url, -}); - -export async function setTokens(access: string, refresh: string) { - const cookies = await getCookies(); - - cookies.set({ - name: "access_token", - value: access, - httpOnly: true, - sameSite: "lax", - path: "/", - maxAge: 34560000, - }); - cookies.set({ - name: "refresh_token", - value: refresh, - httpOnly: true, - sameSite: "lax", - path: "/", - maxAge: 34560000, - }); -} diff --git a/examples/aws-auth-nextjs/app/favicon.ico b/examples/aws-auth-nextjs/app/favicon.ico deleted file mode 100644 index 718d6fea48..0000000000 Binary files a/examples/aws-auth-nextjs/app/favicon.ico and /dev/null differ diff --git a/examples/aws-auth-nextjs/app/globals.css b/examples/aws-auth-nextjs/app/globals.css deleted file mode 100644 index e3734be15e..0000000000 --- a/examples/aws-auth-nextjs/app/globals.css +++ /dev/null @@ -1,42 +0,0 @@ -:root { - --background: #ffffff; - --foreground: #171717; -} - -@media (prefers-color-scheme: dark) { - :root { - --background: #0a0a0a; - --foreground: #ededed; - } -} - -html, -body { - max-width: 100vw; - overflow-x: hidden; -} - -body { - color: var(--foreground); - background: var(--background); - font-family: Arial, Helvetica, sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -* { - box-sizing: border-box; - padding: 0; - margin: 0; -} - -a { - color: inherit; - text-decoration: none; -} - -@media (prefers-color-scheme: dark) { - html { - color-scheme: dark; - } -} diff --git a/examples/aws-auth-nextjs/app/layout.tsx b/examples/aws-auth-nextjs/app/layout.tsx deleted file mode 100644 index 8cdb9eb3b3..0000000000 --- a/examples/aws-auth-nextjs/app/layout.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import type { Metadata } from "next" -import { Geist, Geist_Mono } from "next/font/google" -import "./globals.css" - -const geistSans = Geist({ - variable: "--font-geist-sans", - subsets: ["latin"], -}) - -const geistMono = Geist_Mono({ - variable: "--font-geist-mono", - subsets: ["latin"], -}) - -export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", -} - -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode -}>) { - return ( - - - {children} - - - ) -} diff --git a/examples/aws-auth-nextjs/app/page.module.css b/examples/aws-auth-nextjs/app/page.module.css deleted file mode 100644 index 1f4ec4aaf0..0000000000 --- a/examples/aws-auth-nextjs/app/page.module.css +++ /dev/null @@ -1,200 +0,0 @@ -.page { - --gray-rgb: 0, 0, 0; - --gray-alpha-200: rgba(var(--gray-rgb), 0.08); - --gray-alpha-100: rgba(var(--gray-rgb), 0.05); - - --button-primary-hover: #383838; - --button-secondary-hover: #f2f2f2; - - display: grid; - grid-template-rows: 20px 1fr 20px; - align-items: center; - justify-items: center; - min-height: 100svh; - padding: 80px; - gap: 64px; - font-family: var(--font-geist-sans); -} - -@media (prefers-color-scheme: dark) { - .page { - --gray-rgb: 255, 255, 255; - --gray-alpha-200: rgba(var(--gray-rgb), 0.145); - --gray-alpha-100: rgba(var(--gray-rgb), 0.06); - - --button-primary-hover: #ccc; - --button-secondary-hover: #1a1a1a; - } -} - -.main { - display: flex; - flex-direction: column; - gap: 32px; - grid-row-start: 2; -} - -.main ol { - font-family: var(--font-geist-mono); - padding-left: 0; - margin: 0; - font-size: 14px; - line-height: 24px; - letter-spacing: -0.01em; - list-style-position: inside; -} - -.main li:not(:last-of-type) { - margin-bottom: 8px; -} - -.main code { - font-family: inherit; - background: var(--gray-alpha-100); - padding: 2px 4px; - border-radius: 4px; - font-weight: 600; -} - -.ctas { - display: flex; - gap: 16px; -} - -.ctas a { - appearance: none; - border-radius: 128px; - height: 48px; - padding: 0 20px; - border: none; - border: 1px solid transparent; - transition: - background 0.2s, - color 0.2s, - border-color 0.2s; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - font-size: 16px; - line-height: 20px; - font-weight: 500; -} - -a.primary { - background: var(--foreground); - color: var(--background); - gap: 8px; -} - -a.secondary { - border-color: var(--gray-alpha-200); - min-width: 180px; -} - -.footer { - grid-row-start: 3; - display: flex; - gap: 24px; -} - -.footer a { - display: flex; - align-items: center; - gap: 8px; -} - -.footer img { - flex-shrink: 0; -} - -/* Enable hover only on non-touch devices */ -@media (hover: hover) and (pointer: fine) { - a.primary:hover { - background: var(--button-primary-hover); - border-color: transparent; - } - - a.secondary:hover { - background: var(--button-secondary-hover); - border-color: transparent; - } - - .footer a:hover { - text-decoration: underline; - text-underline-offset: 4px; - } -} - -@media (max-width: 600px) { - .page { - padding: 32px; - padding-bottom: 80px; - } - - .main { - align-items: center; - } - - .main ol { - text-align: center; - } - - .ctas { - flex-direction: column; - } - - .ctas a { - font-size: 14px; - height: 40px; - padding: 0 16px; - } - - a.secondary { - min-width: auto; - } - - .footer { - flex-wrap: wrap; - align-items: center; - justify-content: center; - } -} - -@media (prefers-color-scheme: dark) { - .logo { - filter: invert(); - } -} - -.ctas button { - appearance: none; - background: transparent; - border-radius: 128px; - height: 48px; - padding: 0 20px; - border: none; - border: 1px solid transparent; - transition: - background 0.2s, - color 0.2s, - border-color 0.2s; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - font-size: 16px; - line-height: 20px; - font-weight: 500; -} - -button.primary { - background: var(--foreground); - color: var(--background); - gap: 8px; -} - -button.secondary { - border-color: var(--gray-alpha-200); - min-width: 180px; -} diff --git a/examples/aws-auth-nextjs/app/page.tsx b/examples/aws-auth-nextjs/app/page.tsx deleted file mode 100644 index 0916983bd4..0000000000 --- a/examples/aws-auth-nextjs/app/page.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import Image from "next/image"; -import styles from "./page.module.css"; -import { auth, login, logout } from "./actions"; - -export default async function Home() { - const subject = await auth(); - - return ( -
-
- Next.js logo -
    - {subject ? ( - <> -
  1. - Logged in as {subject.properties.id}. -
  2. -
  3. - And then check out app/page.tsx. -
  4. - - ) : ( - <> -
  5. Login with your email and password.
  6. -
  7. - And then check out app/page.tsx. -
  8. - - )} -
- -
- {subject ? ( -
- -
- ) : ( -
- -
- )} -
-
-
- ); -} diff --git a/examples/aws-auth-nextjs/auth/index.ts b/examples/aws-auth-nextjs/auth/index.ts deleted file mode 100644 index 7e298f674d..0000000000 --- a/examples/aws-auth-nextjs/auth/index.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { handle } from "hono/aws-lambda"; -import { issuer } from "@openauthjs/openauth"; -import { CodeUI } from "@openauthjs/openauth/ui/code"; -import { CodeProvider } from "@openauthjs/openauth/provider/code"; -import { subjects } from "./subjects"; - -async function getUser(email: string) { - // Get user from database and return user ID - return "123"; -} - -const app = issuer({ - subjects, - // Remove after setting custom domain - allow: async () => true, - providers: { - code: CodeProvider( - CodeUI({ - sendCode: async (email, code) => { - console.log(email, code); - }, - }), - ), - }, - success: async (ctx, value) => { - if (value.provider === "code") { - return ctx.subject("user", { - id: await getUser(value.claims.email), - }); - } - throw new Error("Invalid provider"); - }, -}); - -export const handler = handle(app); diff --git a/examples/aws-auth-nextjs/auth/subjects.ts b/examples/aws-auth-nextjs/auth/subjects.ts deleted file mode 100644 index f8e6ed2f57..0000000000 --- a/examples/aws-auth-nextjs/auth/subjects.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { object, string } from "valibot"; -import { createSubjects } from "@openauthjs/openauth/subject"; - -export const subjects = createSubjects({ - user: object({ - id: string(), - }), -}); diff --git a/examples/aws-auth-nextjs/next.config.ts b/examples/aws-auth-nextjs/next.config.ts deleted file mode 100644 index 3b84f68abf..0000000000 --- a/examples/aws-auth-nextjs/next.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { NextConfig } from "next" - -const nextConfig: NextConfig = { - /* config options here */ -} - -export default nextConfig diff --git a/examples/aws-auth-nextjs/package.json b/examples/aws-auth-nextjs/package.json deleted file mode 100644 index 0c83c699ac..0000000000 --- a/examples/aws-auth-nextjs/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "aws-auth-nextjs", - "version": "0.1.0", - "private": true, - "scripts": { - "build": "next build", - "dev": "next dev", - "lint": "next lint", - "start": "next start" - }, - "dependencies": { - "@openauthjs/openauth": "latest", - "hono": "^4.6.16", - "next": "15.1.4", - "react": "^19.0.0", - "react-dom": "^19.0.0", - "sst": "file:../../sdk/js", - "valibot": "^1.0.0-beta.11" - }, - "devDependencies": { - "@types/node": "^20", - "@types/react": "^19", - "@types/react-dom": "^19", - "typescript": "^5" - } -} diff --git a/examples/aws-auth-nextjs/public/file.svg b/examples/aws-auth-nextjs/public/file.svg deleted file mode 100644 index 004145cddf..0000000000 --- a/examples/aws-auth-nextjs/public/file.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-auth-nextjs/public/globe.svg b/examples/aws-auth-nextjs/public/globe.svg deleted file mode 100644 index 567f17b0d7..0000000000 --- a/examples/aws-auth-nextjs/public/globe.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-auth-nextjs/public/next.svg b/examples/aws-auth-nextjs/public/next.svg deleted file mode 100644 index 5174b28c56..0000000000 --- a/examples/aws-auth-nextjs/public/next.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-auth-nextjs/public/vercel.svg b/examples/aws-auth-nextjs/public/vercel.svg deleted file mode 100644 index 7705396033..0000000000 --- a/examples/aws-auth-nextjs/public/vercel.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-auth-nextjs/public/window.svg b/examples/aws-auth-nextjs/public/window.svg deleted file mode 100644 index b2b2a44f6e..0000000000 --- a/examples/aws-auth-nextjs/public/window.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-auth-nextjs/sst.config.ts b/examples/aws-auth-nextjs/sst.config.ts deleted file mode 100644 index 17a8c02f8a..0000000000 --- a/examples/aws-auth-nextjs/sst.config.ts +++ /dev/null @@ -1,21 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-auth-nextjs", - removal: input?.stage === "production" ? "retain" : "remove", - protect: ["production"].includes(input?.stage), - home: "aws", - }; - }, - async run() { - const auth = new sst.aws.Auth("MyAuth", { - issuer: "auth/index.handler", - }); - - new sst.aws.Nextjs("MyWeb", { - link: [auth], - }); - }, -}); diff --git a/examples/aws-auth-nextjs/tsconfig.json b/examples/aws-auth-nextjs/tsconfig.json deleted file mode 100644 index 30ced59690..0000000000 --- a/examples/aws-auth-nextjs/tsconfig.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2017", - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, - "plugins": [ - { - "name": "next" - } - ], - "paths": { - "@/*": ["./*"] - } - }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules", "sst.config.ts"] -} diff --git a/examples/aws-auth-react/.gitignore b/examples/aws-auth-react/.gitignore deleted file mode 100644 index e2ead72a02..0000000000 --- a/examples/aws-auth-react/.gitignore +++ /dev/null @@ -1,18 +0,0 @@ -# dependencies -node_modules - -# sst -.sst - -# tmp files -.#* - -# env -.env*.local -.env - -# opennext -.open-next - -# misc -.DS_Store diff --git a/examples/aws-auth-react/LICENSE b/examples/aws-auth-react/LICENSE deleted file mode 100644 index c6eca6eed7..0000000000 --- a/examples/aws-auth-react/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 SST - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/examples/aws-auth-react/infra/api.ts b/examples/aws-auth-react/infra/api.ts deleted file mode 100644 index e3e4d07413..0000000000 --- a/examples/aws-auth-react/infra/api.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { auth } from "./auth"; - -export const api = new sst.aws.Function("MyApi", { - url: true, - link: [auth], - handler: "packages/functions/src/api.handler", -}); diff --git a/examples/aws-auth-react/infra/auth.ts b/examples/aws-auth-react/infra/auth.ts deleted file mode 100644 index 96e0d2c7af..0000000000 --- a/examples/aws-auth-react/infra/auth.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const auth = new sst.aws.Auth("MyAuth", { - issuer: "packages/functions/src/auth.handler", -}); - diff --git a/examples/aws-auth-react/infra/web.ts b/examples/aws-auth-react/infra/web.ts deleted file mode 100644 index c49c45496d..0000000000 --- a/examples/aws-auth-react/infra/web.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { api } from "./api"; -import { auth } from "./auth"; - -export const web = new sst.aws.StaticSite("MyWeb", { - path: "packages/web", - build: { - output: "dist", - command: "npm run build", - }, - environment: { - VITE_API_URL: api.url, - VITE_AUTH_URL: auth.url, - }, -}); - diff --git a/examples/aws-auth-react/package.json b/examples/aws-auth-react/package.json deleted file mode 100644 index 1f1027b316..0000000000 --- a/examples/aws-auth-react/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-auth-react", - "version": "0.0.0", - "workspaces": [ - "packages/*" - ], - "scripts": {}, - "devDependencies": { - "@tsconfig/node22": "^22", - "typescript": "^5" - }, - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-auth-react/packages/core/package.json b/examples/aws-auth-react/packages/core/package.json deleted file mode 100644 index e7d239d85e..0000000000 --- a/examples/aws-auth-react/packages/core/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "@aws-auth-react/core", - "type": "module", - "version": "0.0.0", - "scripts": { - "test": "sst shell vitest" - }, - "exports": { - "./*": [ - "./src/*/index.ts", - "./src/*.ts" - ] - }, - "dependencies": { - "sst": "file:../../../../sdk/js" - }, - "devDependencies": { - "vitest": "^2" - } -} diff --git a/examples/aws-auth-react/packages/core/src/example/index.ts b/examples/aws-auth-react/packages/core/src/example/index.ts deleted file mode 100644 index 9cb1c03477..0000000000 --- a/examples/aws-auth-react/packages/core/src/example/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export namespace Example { - export function hello() { - return "Hello, world!"; - } -} diff --git a/examples/aws-auth-react/packages/core/src/example/test/index.test.ts b/examples/aws-auth-react/packages/core/src/example/test/index.test.ts deleted file mode 100644 index 18d84d117b..0000000000 --- a/examples/aws-auth-react/packages/core/src/example/test/index.test.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { expect, test } from "vitest"; -import { Example } from "../"; - -test("Hello test", () => { - const expected = "Hello, world!"; - - expect(Example.hello()).toEqual(expected); -}); diff --git a/examples/aws-auth-react/packages/core/tsconfig.json b/examples/aws-auth-react/packages/core/tsconfig.json deleted file mode 100644 index be3c6ace73..0000000000 --- a/examples/aws-auth-react/packages/core/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "@tsconfig/node22/tsconfig.json", - "compilerOptions": { - "module": "ESNext", - "moduleResolution": "Bundler", - }, -} diff --git a/examples/aws-auth-react/packages/functions/package.json b/examples/aws-auth-react/packages/functions/package.json deleted file mode 100644 index c6348f56a0..0000000000 --- a/examples/aws-auth-react/packages/functions/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "@aws-auth-react/functions", - "version": "0.0.0", - "type": "module", - "dependencies": { - "@aws-auth-react/core": "*", - "@openauthjs/openauth": "^0.3.6", - "hono": "^4.6.18", - "sst": "file:../../../../sdk/js", - "valibot": "^1.0.0-beta.14" - }, - "devDependencies": { - "@types/aws-lambda": "^8" - } -} diff --git a/examples/aws-auth-react/packages/functions/src/api.ts b/examples/aws-auth-react/packages/functions/src/api.ts deleted file mode 100644 index ee2410c0c3..0000000000 --- a/examples/aws-auth-react/packages/functions/src/api.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { Hono } from "hono"; -import { Resource } from "sst"; -import { handle } from "hono/aws-lambda"; -import { createClient } from "@openauthjs/openauth/client"; -import { subjects } from "./subjects"; - -const client = createClient({ - clientID: "jwt-api", - issuer: Resource.MyAuth.url, -}); - -async function getUserInfo(userId: string) { - // Get user from database - return { - userId, - name: "Patrick Star", - }; -} - -const app = new Hono(); - -app.get("/me", async (c) => { - const authHeader = c.req.header("Authorization"); - - if (!authHeader) { - return c.status(401); - } - - const token = authHeader.split(" ")[1]; - const verified = await client.verify(subjects, token); - - if (verified.err) { - return c.status(401); - } - - return c.json(await getUserInfo(verified.subject.properties.id)); -}); - -export const handler = handle(app); diff --git a/examples/aws-auth-react/packages/functions/src/auth.ts b/examples/aws-auth-react/packages/functions/src/auth.ts deleted file mode 100644 index 7e298f674d..0000000000 --- a/examples/aws-auth-react/packages/functions/src/auth.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { handle } from "hono/aws-lambda"; -import { issuer } from "@openauthjs/openauth"; -import { CodeUI } from "@openauthjs/openauth/ui/code"; -import { CodeProvider } from "@openauthjs/openauth/provider/code"; -import { subjects } from "./subjects"; - -async function getUser(email: string) { - // Get user from database and return user ID - return "123"; -} - -const app = issuer({ - subjects, - // Remove after setting custom domain - allow: async () => true, - providers: { - code: CodeProvider( - CodeUI({ - sendCode: async (email, code) => { - console.log(email, code); - }, - }), - ), - }, - success: async (ctx, value) => { - if (value.provider === "code") { - return ctx.subject("user", { - id: await getUser(value.claims.email), - }); - } - throw new Error("Invalid provider"); - }, -}); - -export const handler = handle(app); diff --git a/examples/aws-auth-react/packages/functions/src/subjects.ts b/examples/aws-auth-react/packages/functions/src/subjects.ts deleted file mode 100644 index f8e6ed2f57..0000000000 --- a/examples/aws-auth-react/packages/functions/src/subjects.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { object, string } from "valibot"; -import { createSubjects } from "@openauthjs/openauth/subject"; - -export const subjects = createSubjects({ - user: object({ - id: string(), - }), -}); diff --git a/examples/aws-auth-react/packages/functions/tsconfig.json b/examples/aws-auth-react/packages/functions/tsconfig.json deleted file mode 100644 index be3c6ace73..0000000000 --- a/examples/aws-auth-react/packages/functions/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "@tsconfig/node22/tsconfig.json", - "compilerOptions": { - "module": "ESNext", - "moduleResolution": "Bundler", - }, -} diff --git a/examples/aws-auth-react/packages/scripts/package.json b/examples/aws-auth-react/packages/scripts/package.json deleted file mode 100644 index 39ae89e8c4..0000000000 --- a/examples/aws-auth-react/packages/scripts/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "@aws-auth-react/scripts", - "version": "0.0.0", - "type": "module", - "dependencies": { - "@aws-auth-react/core": "*", - "sst": "file:../../../../sdk/js" - }, - "scripts": { - "shell": "sst shell tsx" - }, - "devDependencies": { - "@types/node": "^22", - "tsx": "^4" - } -} diff --git a/examples/aws-auth-react/packages/scripts/src/example.ts b/examples/aws-auth-react/packages/scripts/src/example.ts deleted file mode 100644 index 44c3c0263b..0000000000 --- a/examples/aws-auth-react/packages/scripts/src/example.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { Resource } from "sst"; -import { Example } from "@aws-auth-react/core/example"; - -console.log(`${Example.hello()} Linked to ${Resource.MyBucket.name}.`); diff --git a/examples/aws-auth-react/packages/scripts/tsconfig.json b/examples/aws-auth-react/packages/scripts/tsconfig.json deleted file mode 100644 index be3c6ace73..0000000000 --- a/examples/aws-auth-react/packages/scripts/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "@tsconfig/node22/tsconfig.json", - "compilerOptions": { - "module": "ESNext", - "moduleResolution": "Bundler", - }, -} diff --git a/examples/aws-auth-react/packages/web/.gitignore b/examples/aws-auth-react/packages/web/.gitignore deleted file mode 100644 index a547bf36d8..0000000000 --- a/examples/aws-auth-react/packages/web/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -node_modules -dist -dist-ssr -*.local - -# Editor directories and files -.vscode/* -!.vscode/extensions.json -.idea -.DS_Store -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? diff --git a/examples/aws-auth-react/packages/web/eslint.config.js b/examples/aws-auth-react/packages/web/eslint.config.js deleted file mode 100644 index 092408a9f0..0000000000 --- a/examples/aws-auth-react/packages/web/eslint.config.js +++ /dev/null @@ -1,28 +0,0 @@ -import js from '@eslint/js' -import globals from 'globals' -import reactHooks from 'eslint-plugin-react-hooks' -import reactRefresh from 'eslint-plugin-react-refresh' -import tseslint from 'typescript-eslint' - -export default tseslint.config( - { ignores: ['dist'] }, - { - extends: [js.configs.recommended, ...tseslint.configs.recommended], - files: ['**/*.{ts,tsx}'], - languageOptions: { - ecmaVersion: 2020, - globals: globals.browser, - }, - plugins: { - 'react-hooks': reactHooks, - 'react-refresh': reactRefresh, - }, - rules: { - ...reactHooks.configs.recommended.rules, - 'react-refresh/only-export-components': [ - 'warn', - { allowConstantExport: true }, - ], - }, - }, -) diff --git a/examples/aws-auth-react/packages/web/index.html b/examples/aws-auth-react/packages/web/index.html deleted file mode 100644 index e4b78eae12..0000000000 --- a/examples/aws-auth-react/packages/web/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - Vite + React + TS - - -
- - - diff --git a/examples/aws-auth-react/packages/web/package.json b/examples/aws-auth-react/packages/web/package.json deleted file mode 100644 index 4afc4bb251..0000000000 --- a/examples/aws-auth-react/packages/web/package.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "web", - "private": true, - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "vite", - "build": "tsc -b && vite build", - "lint": "eslint .", - "preview": "vite preview" - }, - "dependencies": { - "@openauthjs/openauth": "^0.3.8", - "react": "^18.3.1", - "react-dom": "^18.3.1" - }, - "devDependencies": { - "@eslint/js": "^9.17.0", - "@types/react": "^18.3.18", - "@types/react-dom": "^18.3.5", - "@vitejs/plugin-react": "^4.3.4", - "eslint": "^9.17.0", - "eslint-plugin-react-hooks": "^5.0.0", - "eslint-plugin-react-refresh": "^0.4.16", - "globals": "^15.14.0", - "typescript": "~5.6.2", - "typescript-eslint": "^8.18.2", - "vite": "^6.0.5" - } -} diff --git a/examples/aws-auth-react/packages/web/public/vite.svg b/examples/aws-auth-react/packages/web/public/vite.svg deleted file mode 100644 index e7b8dfb1b2..0000000000 --- a/examples/aws-auth-react/packages/web/public/vite.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-auth-react/packages/web/src/App.css b/examples/aws-auth-react/packages/web/src/App.css deleted file mode 100644 index 79f55915a0..0000000000 --- a/examples/aws-auth-react/packages/web/src/App.css +++ /dev/null @@ -1,48 +0,0 @@ -#root { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; - text-align: center; -} - -.logo { - height: 6em; - padding: 1.5em; - will-change: filter; - transition: filter 300ms; -} -.logo:hover { - filter: drop-shadow(0 0 2em #646cffaa); -} -.logo.react:hover { - filter: drop-shadow(0 0 2em #61dafbaa); -} - -@keyframes logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} - -@media (prefers-reduced-motion: no-preference) { - a:nth-of-type(2) .logo { - animation: logo-spin infinite 20s linear; - } -} - -.card { - padding: 2em; -} - -.read-the-docs { - color: #888; -} - -.controls { - display: flex; - justify-content: center; - gap: 1rem; -} diff --git a/examples/aws-auth-react/packages/web/src/App.tsx b/examples/aws-auth-react/packages/web/src/App.tsx deleted file mode 100644 index e049b006ec..0000000000 --- a/examples/aws-auth-react/packages/web/src/App.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { useState } from "react"; -import { useAuth } from "./AuthContext"; -import "./App.css"; - -function App() { - const auth = useAuth(); - const [status, setStatus] = useState(""); - - async function callApi() { - const res = await fetch(`${import.meta.env.VITE_API_URL}me`, { - headers: { - Authorization: `Bearer ${await auth.getToken()}`, - }, - }); - - setStatus(res.ok ? await res.text() : "error"); - } - - return !auth.loaded ? ( -
Loading...
- ) : ( -
- {auth.loggedIn ? ( -
-

- Logged in - {auth.userId && as {auth.userId}} -

- {status !== "" &&

API call: {status}

} -
- - -
-
- ) : ( - - )} -
- ); -} - -export default App; diff --git a/examples/aws-auth-react/packages/web/src/AuthContext.tsx b/examples/aws-auth-react/packages/web/src/AuthContext.tsx deleted file mode 100644 index 821757a6f9..0000000000 --- a/examples/aws-auth-react/packages/web/src/AuthContext.tsx +++ /dev/null @@ -1,156 +0,0 @@ -import { - useRef, - useState, - ReactNode, - useEffect, - useContext, - createContext, -} from "react"; -import { createClient } from "@openauthjs/openauth/client"; - -const client = createClient({ - clientID: "web", - issuer: import.meta.env.VITE_AUTH_URL, -}); - -interface AuthContextType { - userId?: string; - loaded: boolean; - loggedIn: boolean; - logout: () => void; - login: () => Promise; - getToken: () => Promise; -} - -const AuthContext = createContext({} as AuthContextType); - -export function AuthProvider({ children }: { children: ReactNode }) { - const initializing = useRef(true); - const [loaded, setLoaded] = useState(false); - const [loggedIn, setLoggedIn] = useState(false); - const token = useRef(undefined); - const [userId, setUserId] = useState(); - - useEffect(() => { - const hash = new URLSearchParams(location.search.slice(1)); - const code = hash.get("code"); - const state = hash.get("state"); - - if (!initializing.current) { - return; - } - - initializing.current = false; - - if (code && state) { - callback(code, state); - return; - } - - auth(); - }, []); - - async function auth() { - const token = await refreshTokens(); - - if (token) { - await user(); - } - - setLoaded(true); - } - - async function refreshTokens() { - const refresh = localStorage.getItem("refresh"); - if (!refresh) return; - const next = await client.refresh(refresh, { - access: token.current, - }); - if (next.err) return; - if (!next.tokens) return token.current; - - localStorage.setItem("refresh", next.tokens.refresh); - token.current = next.tokens.access; - - return next.tokens.access; - } - - async function getToken() { - const token = await refreshTokens(); - - if (!token) { - await login(); - return; - } - - return token; - } - - async function login() { - const { challenge, url } = await client.authorize(location.origin, "code", { - pkce: true, - }); - sessionStorage.setItem("challenge", JSON.stringify(challenge)); - location.href = url; - } - - async function callback(code: string, state: string) { - console.log("callback", code, state); - const challenge = JSON.parse(sessionStorage.getItem("challenge")!); - if (code) { - if (state === challenge.state && challenge.verifier) { - const exchanged = await client.exchange( - code!, - location.origin, - challenge.verifier, - ); - if (!exchanged.err) { - token.current = exchanged.tokens?.access; - localStorage.setItem("refresh", exchanged.tokens.refresh); - } - } - window.location.replace("/"); - } - } - - async function user() { - const res = await fetch(`${import.meta.env.VITE_API_URL}me`, { - headers: { - Authorization: `Bearer ${token.current}`, - }, - }); - - if (res.ok) { - const user = await res.json(); - - setUserId(user.userId); - setLoggedIn(true); - } - } - - function logout() { - localStorage.removeItem("refresh"); - token.current = undefined; - - window.location.replace("/"); - } - - return ( - - {children} - - ); -} - -export function useAuth() { - return useContext(AuthContext); -} diff --git a/examples/aws-auth-react/packages/web/src/assets/react.svg b/examples/aws-auth-react/packages/web/src/assets/react.svg deleted file mode 100644 index 6c87de9bb3..0000000000 --- a/examples/aws-auth-react/packages/web/src/assets/react.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-auth-react/packages/web/src/index.css b/examples/aws-auth-react/packages/web/src/index.css deleted file mode 100644 index 6119ad9a8f..0000000000 --- a/examples/aws-auth-react/packages/web/src/index.css +++ /dev/null @@ -1,68 +0,0 @@ -:root { - font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; - line-height: 1.5; - font-weight: 400; - - color-scheme: light dark; - color: rgba(255, 255, 255, 0.87); - background-color: #242424; - - font-synthesis: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -a { - font-weight: 500; - color: #646cff; - text-decoration: inherit; -} -a:hover { - color: #535bf2; -} - -body { - margin: 0; - display: flex; - place-items: center; - min-width: 320px; - min-height: 100vh; -} - -h1 { - font-size: 3.2em; - line-height: 1.1; -} - -button { - border-radius: 8px; - border: 1px solid transparent; - padding: 0.6em 1.2em; - font-size: 1em; - font-weight: 500; - font-family: inherit; - background-color: #1a1a1a; - cursor: pointer; - transition: border-color 0.25s; -} -button:hover { - border-color: #646cff; -} -button:focus, -button:focus-visible { - outline: 4px auto -webkit-focus-ring-color; -} - -@media (prefers-color-scheme: light) { - :root { - color: #213547; - background-color: #ffffff; - } - a:hover { - color: #747bff; - } - button { - background-color: #f9f9f9; - } -} diff --git a/examples/aws-auth-react/packages/web/src/main.tsx b/examples/aws-auth-react/packages/web/src/main.tsx deleted file mode 100644 index 2778110c85..0000000000 --- a/examples/aws-auth-react/packages/web/src/main.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { StrictMode } from "react"; -import { createRoot } from "react-dom/client"; -import { AuthProvider } from "./AuthContext"; -import "./index.css"; -import App from "./App.tsx"; - -createRoot(document.getElementById("root")!).render( - - - - - , -); diff --git a/examples/aws-auth-react/packages/web/src/vite-env.d.ts b/examples/aws-auth-react/packages/web/src/vite-env.d.ts deleted file mode 100644 index 11f02fe2a0..0000000000 --- a/examples/aws-auth-react/packages/web/src/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/examples/aws-auth-react/packages/web/tsconfig.app.json b/examples/aws-auth-react/packages/web/tsconfig.app.json deleted file mode 100644 index 358ca9ba93..0000000000 --- a/examples/aws-auth-react/packages/web/tsconfig.app.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "compilerOptions": { - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", - "target": "ES2020", - "useDefineForClassFields": true, - "lib": ["ES2020", "DOM", "DOM.Iterable"], - "module": "ESNext", - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "isolatedModules": true, - "moduleDetection": "force", - "noEmit": true, - "jsx": "react-jsx", - - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true - }, - "include": ["src"] -} diff --git a/examples/aws-auth-react/packages/web/tsconfig.json b/examples/aws-auth-react/packages/web/tsconfig.json deleted file mode 100644 index 1ffef600d9..0000000000 --- a/examples/aws-auth-react/packages/web/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "files": [], - "references": [ - { "path": "./tsconfig.app.json" }, - { "path": "./tsconfig.node.json" } - ] -} diff --git a/examples/aws-auth-react/packages/web/tsconfig.node.json b/examples/aws-auth-react/packages/web/tsconfig.node.json deleted file mode 100644 index db0becc8b0..0000000000 --- a/examples/aws-auth-react/packages/web/tsconfig.node.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", - "target": "ES2022", - "lib": ["ES2023"], - "module": "ESNext", - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "isolatedModules": true, - "moduleDetection": "force", - "noEmit": true, - - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedSideEffectImports": true - }, - "include": ["vite.config.ts"] -} diff --git a/examples/aws-auth-react/packages/web/vite.config.ts b/examples/aws-auth-react/packages/web/vite.config.ts deleted file mode 100644 index 8b0f57b91a..0000000000 --- a/examples/aws-auth-react/packages/web/vite.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react' - -// https://vite.dev/config/ -export default defineConfig({ - plugins: [react()], -}) diff --git a/examples/aws-auth-react/sst.config.ts b/examples/aws-auth-react/sst.config.ts deleted file mode 100644 index ac4f254171..0000000000 --- a/examples/aws-auth-react/sst.config.ts +++ /dev/null @@ -1,116 +0,0 @@ -/// - -/** - * ## AWS OpenAuth React SPA - * - * This is a full-stack monorepo app shows the OpenAuth flow for a single-page app - * and an authenticated API. It has: - * - * - React SPA built with Vite and the `StaticSite` component in the `packages/web` - * directory. - * ```ts title="infra/web.ts" - * export const web = new sst.aws.StaticSite("MyWeb", { - * path: "packages/web", - * build: { - * output: "dist", - * command: "npm run build", - * }, - * environment: { - * VITE_API_URL: api.url, - * VITE_AUTH_URL: auth.url, - * }, - * }); - * ``` - * - * - API with Hono and the `Function` component in `packages/functions/src/api.ts`. - * ```ts title="infra/api.ts" - * export const api = new sst.aws.Function("MyApi", { - * url: true, - * link: [auth], - * handler: "packages/functions/src/api.handler", - * }); - * ``` - * - * - OpenAuth with the `Auth` component in `packages/functions/src/auth.ts`. - * ```ts title="infra/auth.ts" - * export const auth = new sst.aws.Auth("MyAuth", { - * issuer: "packages/functions/src/auth.handler", - * }); - * ``` - * - * The React frontend uses a `AuthContext` provider to manage the auth flow. - * - * ```tsx title="packages/web/src/AuthContext.tsx" - * - * {children} - * - * ``` - * - * Now in `App.tsx`, we can use the `useAuth` hook. - * - * ```tsx title="packages/web/src/App.tsx" - * const auth = useAuth(); - * - * return !auth.loaded ? ( - *
Loading...
- * ) : ( - *
- * {auth.loggedIn ? ( - *
- *

- * Logged in - * {auth.userId && as {auth.userId}} - *

- *
- * ) : ( - * - * )} - *
- * ); - * ``` - * - * Once authenticated, we can call our authenticated API by passing in the access - * token. - * - * ```tsx title="packages/web/src/App.tsx" {3} - * await fetch(`${import.meta.env.VITE_API_URL}me`, { - * headers: { - * Authorization: `Bearer ${await auth.getToken()}`, - * }, - * }); - * ``` - * - * The API uses the OpenAuth client to verify the token. - * - * ```ts title="packages/functions/src/api.ts" {3} - * const authHeader = c.req.header("Authorization"); - * const token = authHeader.split(" ")[1]; - * const verified = await client.verify(subjects, token); - * ``` - * - * The `sst.config.ts` dynamically imports all the `infra/` files. - */ -export default $config({ - app(input) { - return { - name: "aws-auth-react", - removal: input?.stage === "production" ? "retain" : "remove", - protect: ["production"].includes(input?.stage), - home: "aws", - }; - }, - async run() { - await import("./infra/auth"); - await import("./infra/api"); - await import("./infra/web"); - }, -}); diff --git a/examples/aws-auth-react/tsconfig.json b/examples/aws-auth-react/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-auth-react/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-base/.gitignore b/examples/aws-base/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-base/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-base/package.json b/examples/aws-base/package.json deleted file mode 100644 index 8721162115..0000000000 --- a/examples/aws-base/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-base", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-base/sst.config.ts b/examples/aws-base/sst.config.ts deleted file mode 100644 index 825dc1c077..0000000000 --- a/examples/aws-base/sst.config.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-base", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() {}, -}); diff --git a/examples/aws-base/tsconfig.json b/examples/aws-base/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-base/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-bucket-lifecycle-rules/package.json b/examples/aws-bucket-lifecycle-rules/package.json deleted file mode 100644 index 5a92f09ea9..0000000000 --- a/examples/aws-bucket-lifecycle-rules/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-bucket-lifecycle-rules", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-bucket-lifecycle-rules/sst.config.ts b/examples/aws-bucket-lifecycle-rules/sst.config.ts deleted file mode 100644 index 012b5fd95c..0000000000 --- a/examples/aws-bucket-lifecycle-rules/sst.config.ts +++ /dev/null @@ -1,38 +0,0 @@ -/// - -/** - * ## Bucket lifecycle policies - * - * Configure S3 bucket lifecycle policies to expire objects automatically. - */ -export default $config({ - app(input) { - return { - name: "aws-bucket-lifecycle-rules", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - lifecycle: [ - { - expiresIn: "60 days", - }, - { - id: "expire-tmp-files", - prefix: "tmp/", - expiresIn: "30 days", - }, - { - prefix: "data/", - expiresAt: "2028-12-31", - }, - ], - }); - - return { - bucket: bucket.name, - }; - }, -}); diff --git a/examples/aws-bucket-policy/package.json b/examples/aws-bucket-policy/package.json deleted file mode 100644 index a336ca8ce1..0000000000 --- a/examples/aws-bucket-policy/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-bucket-policy", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-bucket-policy/sst.config.ts b/examples/aws-bucket-policy/sst.config.ts deleted file mode 100644 index 85140112f0..0000000000 --- a/examples/aws-bucket-policy/sst.config.ts +++ /dev/null @@ -1,38 +0,0 @@ -/// - -/** - * ## Bucket policy - * - * Create an S3 bucket and transform its bucket policy. - */ -export default $config({ - app(input) { - return { - name: "aws-bucket-policy", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - transform: { - policy: (args) => { - // use sst.aws.iamEdit helper function to manipulate IAM policy - // containing Output values from components - args.policy = sst.aws.iamEdit(args.policy, (policy) => { - policy.Statement.push({ - Effect: "Allow", - Principal: { Service: "ses.amazonaws.com" }, - Action: "s3:PutObject", - Resource: $interpolate`arn:aws:s3:::${args.bucket}/*`, - }); - }); - }, - }, - }); - - return { - bucket: bucket.name, - }; - }, -}); diff --git a/examples/aws-bucket-queue-subscriber/package.json b/examples/aws-bucket-queue-subscriber/package.json deleted file mode 100644 index f0361aa21e..0000000000 --- a/examples/aws-bucket-queue-subscriber/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-bucket-queue-subscriber", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "deploy": "go run ../../cmd/sst deploy", - "remove": "go run ../../cmd/sst remove", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "@types/aws-lambda": "^8.10.149", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-bucket-queue-subscriber/sst.config.ts b/examples/aws-bucket-queue-subscriber/sst.config.ts deleted file mode 100644 index 4b10069241..0000000000 --- a/examples/aws-bucket-queue-subscriber/sst.config.ts +++ /dev/null @@ -1,36 +0,0 @@ -/// - -/** - * ## Bucket queue notifications - * - * Create an S3 bucket and subscribe to its events with an SQS queue. - */ -export default $config({ - app(input) { - return { - name: "aws-bucket-queue-subscriber", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const queue = new sst.aws.Queue("MyQueue"); - queue.subscribe("subscriber.handler"); - - const bucket = new sst.aws.Bucket("MyBucket"); - bucket.notify({ - notifications: [ - { - name: "MySubscriber", - queue, - events: ["s3:ObjectCreated:*"], - }, - ], - }); - - return { - bucket: bucket.name, - queue: queue.url, - }; - }, -}); diff --git a/examples/aws-bucket-queue-subscriber/subscriber.ts b/examples/aws-bucket-queue-subscriber/subscriber.ts deleted file mode 100644 index c4264f003f..0000000000 --- a/examples/aws-bucket-queue-subscriber/subscriber.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { SQSEvent } from "aws-lambda"; - -export const handler = async (event: SQSEvent) => { - console.log(event); - return "ok"; -}; diff --git a/examples/aws-bucket-subscriber/package.json b/examples/aws-bucket-subscriber/package.json deleted file mode 100644 index 4cdabdf595..0000000000 --- a/examples/aws-bucket-subscriber/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-bucket-subscriber", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-bucket-subscriber/sst.config.ts b/examples/aws-bucket-subscriber/sst.config.ts deleted file mode 100644 index 2b8b5ef585..0000000000 --- a/examples/aws-bucket-subscriber/sst.config.ts +++ /dev/null @@ -1,32 +0,0 @@ -/// - -/** - * ## Bucket notifications - * - * Create an S3 bucket and subscribe to its events with a function. - */ -export default $config({ - app(input) { - return { - name: "aws-bucket-subscriber", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket"); - bucket.notify({ - notifications: [ - { - name: "MySubscriber", - function: "subscriber.handler", - events: ["s3:ObjectCreated:*"], - }, - ], - }); - - return { - bucket: bucket.name, - }; - }, -}); diff --git a/examples/aws-bucket-subscriber/subscriber.ts b/examples/aws-bucket-subscriber/subscriber.ts deleted file mode 100644 index f9e60137f3..0000000000 --- a/examples/aws-bucket-subscriber/subscriber.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Handler, S3Event } from 'aws-lambda'; - -export const handler: Handler = async (event) => { - console.log(event); - return "ok"; -}; diff --git a/examples/aws-bucket-topic-subscriber/package.json b/examples/aws-bucket-topic-subscriber/package.json deleted file mode 100644 index c54f3182da..0000000000 --- a/examples/aws-bucket-topic-subscriber/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-bucket-topic-subscriber", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-bucket-topic-subscriber/sst.config.ts b/examples/aws-bucket-topic-subscriber/sst.config.ts deleted file mode 100644 index 25e481759d..0000000000 --- a/examples/aws-bucket-topic-subscriber/sst.config.ts +++ /dev/null @@ -1,36 +0,0 @@ -/// - -/** - * ## Bucket topic notifications - * - * Create an S3 bucket and subscribe to its events with an SNS topic. - */ -export default $config({ - app(input) { - return { - name: "aws-bucket-topic-subscriber", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const topic = new sst.aws.SnsTopic("MyTopic"); - topic.subscribe("MySubscriber", "subscriber.handler"); - - const bucket = new sst.aws.Bucket("MyBucket"); - bucket.notify({ - notifications: [ - { - name: "MySubscriber", - topic, - events: ["s3:ObjectCreated:*"], - }, - ], - }); - - return { - bucket: bucket.name, - topic: topic.name, - }; - }, -}); diff --git a/examples/aws-bucket-topic-subscriber/subscriber.ts b/examples/aws-bucket-topic-subscriber/subscriber.ts deleted file mode 100644 index 118f4371ad..0000000000 --- a/examples/aws-bucket-topic-subscriber/subscriber.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const handler = async (event) => { - console.log(event); - return "ok"; -}; diff --git a/examples/aws-bun-elysia/.dockerignore b/examples/aws-bun-elysia/.dockerignore deleted file mode 100644 index d13a1cca01..0000000000 --- a/examples/aws-bun-elysia/.dockerignore +++ /dev/null @@ -1,2 +0,0 @@ -.sst -node_modules diff --git a/examples/aws-bun-elysia/.gitignore b/examples/aws-bun-elysia/.gitignore deleted file mode 100644 index 92b10320b7..0000000000 --- a/examples/aws-bun-elysia/.gitignore +++ /dev/null @@ -1,45 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env.local -.env.development.local -.env.test.local -.env.production.local - -# vercel -.vercel - -**/*.trace -**/*.zip -**/*.tar.gz -**/*.tgz -**/*.log -package-lock.json -**/*.bun - -# sst -.sst diff --git a/examples/aws-bun-elysia/Dockerfile b/examples/aws-bun-elysia/Dockerfile deleted file mode 100644 index 4af145b928..0000000000 --- a/examples/aws-bun-elysia/Dockerfile +++ /dev/null @@ -1,35 +0,0 @@ -# https://elysiajs.com/patterns/deployment.html#docker - -FROM oven/bun AS build - -WORKDIR /app - -# Cache packages installation -COPY package.json package.json -COPY bun.lockb bun.lockb - -RUN bun install - -COPY ./src ./src - -ENV NODE_ENV=production - -RUN bun build \ - --compile \ - --minify-whitespace \ - --minify-syntax \ - --target bun \ - --outfile server \ - ./src/index.ts - -FROM gcr.io/distroless/base - -WORKDIR /app - -COPY --from=build /app/server server - -ENV NODE_ENV=production - -CMD ["./server"] - -EXPOSE 3000 diff --git a/examples/aws-bun-elysia/elysia.png b/examples/aws-bun-elysia/elysia.png deleted file mode 100644 index 64dc586344..0000000000 Binary files a/examples/aws-bun-elysia/elysia.png and /dev/null differ diff --git a/examples/aws-bun-elysia/package.json b/examples/aws-bun-elysia/package.json deleted file mode 100644 index 931c1cff18..0000000000 --- a/examples/aws-bun-elysia/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "aws-bun-elysia", - "version": "1.0.50", - "scripts": { - "dev": "bun run --watch src/index.ts", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.658.1", - "@aws-sdk/lib-storage": "^3.658.1", - "@aws-sdk/s3-request-presigner": "^3.658.1", - "elysia": "latest", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145", - "bun-types": "latest" - }, - "module": "src/index.js" -} diff --git a/examples/aws-bun-elysia/src/index.ts b/examples/aws-bun-elysia/src/index.ts deleted file mode 100644 index cebfd22b9c..0000000000 --- a/examples/aws-bun-elysia/src/index.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { Elysia } from "elysia"; -import { Resource } from "sst"; -import { - S3Client, - GetObjectCommand, - ListObjectsV2Command, -} from "@aws-sdk/client-s3"; -import { Upload } from "@aws-sdk/lib-storage"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; - -const s3 = new S3Client(); - -const app = new Elysia() - .get("/", () => "Hello Elysia") - .post("/", async ({ body: { file } }: { body: { file: File } }) => { - const params = { - Bucket: Resource.MyBucket.name, - Key: file.name, - Body: file, - }; - const upload = new Upload({ - params, - client: s3, - }); - await upload.done(); - - return "File uploaded successfully."; - }) - .get("/latest", async ({ redirect }) => { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - const latestFile = objects.Contents!.sort( - (a, b) => - (b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0), - )[0]; - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - return redirect(await getSignedUrl(s3, command)); - }) - .listen(3000); - -console.log( - `🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}` -); diff --git a/examples/aws-bun-elysia/sst.config.ts b/examples/aws-bun-elysia/sst.config.ts deleted file mode 100644 index 794730233c..0000000000 --- a/examples/aws-bun-elysia/sst.config.ts +++ /dev/null @@ -1,69 +0,0 @@ -/// - -/** - * ## AWS Bun Elysia container - * - * Deploys a Bun [Elysia](https://elysiajs.com/) API to AWS. - * - * You can get started by running. - * - * ```bash - * bun create elysia aws-bun-elysia - * cd aws-bun-elysia - * bunx sst init - * ``` - * - * Now you can add a service. - * - * ```ts title="sst.config.ts" - * new sst.aws.Service("MyService", { - * cluster, - * loadBalancer: { - * ports: [{ listen: "80/http", forward: "3000/http" }], - * }, - * dev: { - * command: "bun dev", - * }, - * }); - * ``` - * - * Start your app locally. - * - * ```bash - * bun sst dev - * ``` - * - * This example lets you upload a file to S3 and then download it. - * - * ```bash - * curl -F file=@elysia.png http://localhost:3000/ - * curl http://localhost:3000/latest - * ``` - * - * Finally, you can deploy it using `bun sst deploy --stage production`. - */ -export default $config({ - app(input) { - return { - name: "aws-bun-elysia", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket"); - const vpc = new sst.aws.Vpc("MyVpc"); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "bun dev", - }, - link: [bucket], - }); - }, -}); diff --git a/examples/aws-bun-elysia/tsconfig.json b/examples/aws-bun-elysia/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-bun-elysia/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-bun-redis/.dockerignore b/examples/aws-bun-redis/.dockerignore deleted file mode 100644 index 8c3bacfca9..0000000000 --- a/examples/aws-bun-redis/.dockerignore +++ /dev/null @@ -1,9 +0,0 @@ -node_modules -.git -.gitignore -README.md -Dockerfile* - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-bun-redis/.gitignore b/examples/aws-bun-redis/.gitignore deleted file mode 100644 index 1426860d41..0000000000 --- a/examples/aws-bun-redis/.gitignore +++ /dev/null @@ -1,178 +0,0 @@ -# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore - -# Logs - -logs -_.log -npm-debug.log_ -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Caches - -.cache - -# Diagnostic reports (https://nodejs.org/api/report.html) - -report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json - -# Runtime data - -pids -_.pid -_.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover - -lib-cov - -# Coverage directory used by tools like istanbul - -coverage -*.lcov - -# nyc test coverage - -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) - -.grunt - -# Bower dependency directory (https://bower.io/) - -bower_components - -# node-waf configuration - -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) - -build/Release - -# Dependency directories - -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) - -web_modules/ - -# TypeScript cache - -*.tsbuildinfo - -# Optional npm cache directory - -.npm - -# Optional eslint cache - -.eslintcache - -# Optional stylelint cache - -.stylelintcache - -# Microbundle cache - -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history - -.node_repl_history - -# Output of 'npm pack' - -*.tgz - -# Yarn Integrity file - -.yarn-integrity - -# dotenv environment variable files - -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) - -.parcel-cache - -# Next.js build output - -.next -out - -# Nuxt.js build / generate output - -.nuxt -dist - -# Gatsby files - -# Comment in the public line in if your project uses Gatsby and not Next.js - -# https://nextjs.org/blog/next-9-1#public-directory-support - -# public - -# vuepress build output - -.vuepress/dist - -# vuepress v2.x temp and cache directory - -.temp - -# Docusaurus cache and generated files - -.docusaurus - -# Serverless directories - -.serverless/ - -# FuseBox cache - -.fusebox/ - -# DynamoDB Local files - -.dynamodb/ - -# TernJS port file - -.tern-port - -# Stores VSCode versions used for testing VSCode extensions - -.vscode-test - -# yarn v2 - -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* - -# IntelliJ based IDEs -.idea - -# Finder (MacOS) folder config -.DS_Store - -# sst -.sst diff --git a/examples/aws-bun-redis/Dockerfile b/examples/aws-bun-redis/Dockerfile deleted file mode 100644 index a50d40e263..0000000000 --- a/examples/aws-bun-redis/Dockerfile +++ /dev/null @@ -1,38 +0,0 @@ -# use the official Bun image -# see all versions at https://hub.docker.com/r/oven/bun/tags -FROM oven/bun:1 AS base -WORKDIR /usr/src/app - -# install dependencies into temp directory -# this will cache them and speed up future builds -FROM base AS install -RUN mkdir -p /temp/dev -COPY package.json bun.lockb /temp/dev/ -RUN cd /temp/dev && bun install --frozen-lockfile - -# install with --production (exclude devDependencies) -RUN mkdir -p /temp/prod -COPY package.json bun.lockb /temp/prod/ -RUN cd /temp/prod && bun install --frozen-lockfile --production - -# copy node_modules from temp directory -# then copy all (non-ignored) project files into the image -FROM base AS prerelease -COPY --from=install /temp/dev/node_modules node_modules -COPY . . - -# [optional] tests & build -ENV NODE_ENV=production -# RUN bun test -RUN bun run build - -# copy production dependencies and source code into final image -FROM base AS release -COPY --from=install /temp/prod/node_modules node_modules -COPY --from=prerelease /usr/src/app/index.ts . -COPY --from=prerelease /usr/src/app/package.json . - -# run the app -USER bun -EXPOSE 3000/tcp -ENTRYPOINT [ "bun", "run", "index.ts" ] diff --git a/examples/aws-bun-redis/index.ts b/examples/aws-bun-redis/index.ts deleted file mode 100644 index 0168d45220..0000000000 --- a/examples/aws-bun-redis/index.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Resource } from "sst"; -import { Cluster } from "ioredis"; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -const server = Bun.serve({ - async fetch(req) { - const url = new URL(req.url); - - if (url.pathname === "/" && req.method === "GET") { - const counter = await redis.incr("counter"); - return new Response(`Hit counter: ${counter}`); - } - - return new Response("404!"); - }, -}); - -console.log(`Listening on ${server.url}`); diff --git a/examples/aws-bun-redis/package.json b/examples/aws-bun-redis/package.json deleted file mode 100644 index c4aa0fa55c..0000000000 --- a/examples/aws-bun-redis/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "aws-bun-redis", - "module": "index.ts", - "type": "module", - "scripts": { - "build": "bun build --target bun index.ts", - "dev": "bun run --watch index.ts" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145", - "@types/bun": "latest" - }, - "peerDependencies": { - "typescript": "^5.0.0" - }, - "dependencies": { - "ioredis": "^5.4.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-bun-redis/sst.config.ts b/examples/aws-bun-redis/sst.config.ts deleted file mode 100644 index 6ca2730f76..0000000000 --- a/examples/aws-bun-redis/sst.config.ts +++ /dev/null @@ -1,80 +0,0 @@ -/// - -/** - * ## AWS Bun Redis - * - * Creates a hit counter app with Bun and Redis. - * - * This deploys Bun as a Fargate service to ECS and it's linked to Redis. - * - * ```ts title="sst.config.ts" {9} - * new sst.aws.Service("MyService", { - * cluster, - * loadBalancer: { - * ports: [{ listen: "80/http", forward: "3000/http" }], - * }, - * dev: { - * command: "bun dev", - * }, - * link: [redis], - * }); - * ``` - * - * We also have a couple of scripts. A `dev` script with a watcher and a `build` script - * that used when we deploy to production. - * - * ```json title="package.json" - * { - * "scripts": { - * "dev": "bun run --watch index.ts", - * "build": "bun build --target bun index.ts" - * }, - * } - * ``` - * - * Since our Redis cluster is in a VPC, we’ll need a tunnel to connect to it from our local - * machine. - * - * ```bash "sudo" - * sudo bun sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * To start your app locally run. - * - * ```bash - * bun sst dev - * ``` - * - * Now if you go to `http://localhost:3000` you’ll see a counter update as you refresh the page. - * - * Finally, you can deploy it using `bun sst deploy --stage production` using a `Dockerfile` - * that's included in the example. - */ -export default $config({ - app(input) { - return { - name: "aws-bun-redis", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "bun dev", - }, - }); - }, -}); diff --git a/examples/aws-bun-redis/tsconfig.json b/examples/aws-bun-redis/tsconfig.json deleted file mode 100644 index 238655f2ce..0000000000 --- a/examples/aws-bun-redis/tsconfig.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "compilerOptions": { - // Enable latest features - "lib": ["ESNext", "DOM"], - "target": "ESNext", - "module": "ESNext", - "moduleDetection": "force", - "jsx": "react-jsx", - "allowJs": true, - - // Bundler mode - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, - - // Best practices - "strict": true, - "skipLibCheck": true, - "noFallthroughCasesInSwitch": true, - - // Some stricter flags (disabled by default) - "noUnusedLocals": false, - "noUnusedParameters": false, - "noPropertyAccessFromIndexSignature": false - } -} diff --git a/examples/aws-bun/.dockerignore b/examples/aws-bun/.dockerignore deleted file mode 100644 index 8c3bacfca9..0000000000 --- a/examples/aws-bun/.dockerignore +++ /dev/null @@ -1,9 +0,0 @@ -node_modules -.git -.gitignore -README.md -Dockerfile* - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-bun/.gitignore b/examples/aws-bun/.gitignore deleted file mode 100644 index 1426860d41..0000000000 --- a/examples/aws-bun/.gitignore +++ /dev/null @@ -1,178 +0,0 @@ -# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore - -# Logs - -logs -_.log -npm-debug.log_ -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Caches - -.cache - -# Diagnostic reports (https://nodejs.org/api/report.html) - -report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json - -# Runtime data - -pids -_.pid -_.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover - -lib-cov - -# Coverage directory used by tools like istanbul - -coverage -*.lcov - -# nyc test coverage - -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) - -.grunt - -# Bower dependency directory (https://bower.io/) - -bower_components - -# node-waf configuration - -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) - -build/Release - -# Dependency directories - -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) - -web_modules/ - -# TypeScript cache - -*.tsbuildinfo - -# Optional npm cache directory - -.npm - -# Optional eslint cache - -.eslintcache - -# Optional stylelint cache - -.stylelintcache - -# Microbundle cache - -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history - -.node_repl_history - -# Output of 'npm pack' - -*.tgz - -# Yarn Integrity file - -.yarn-integrity - -# dotenv environment variable files - -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) - -.parcel-cache - -# Next.js build output - -.next -out - -# Nuxt.js build / generate output - -.nuxt -dist - -# Gatsby files - -# Comment in the public line in if your project uses Gatsby and not Next.js - -# https://nextjs.org/blog/next-9-1#public-directory-support - -# public - -# vuepress build output - -.vuepress/dist - -# vuepress v2.x temp and cache directory - -.temp - -# Docusaurus cache and generated files - -.docusaurus - -# Serverless directories - -.serverless/ - -# FuseBox cache - -.fusebox/ - -# DynamoDB Local files - -.dynamodb/ - -# TernJS port file - -.tern-port - -# Stores VSCode versions used for testing VSCode extensions - -.vscode-test - -# yarn v2 - -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* - -# IntelliJ based IDEs -.idea - -# Finder (MacOS) folder config -.DS_Store - -# sst -.sst diff --git a/examples/aws-bun/Dockerfile b/examples/aws-bun/Dockerfile deleted file mode 100644 index 457b544c5c..0000000000 --- a/examples/aws-bun/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM oven/bun - -COPY bun.lockb . -COPY package.json . - -RUN bun install --frozen-lockfile - -COPY . . - -EXPOSE 3000 -CMD ["bun", "index.ts"] diff --git a/examples/aws-bun/index.ts b/examples/aws-bun/index.ts deleted file mode 100644 index c552d40423..0000000000 --- a/examples/aws-bun/index.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { Resource } from "sst"; -import { - S3Client, - GetObjectCommand, - ListObjectsV2Command, -} from "@aws-sdk/client-s3"; -import { Upload } from "@aws-sdk/lib-storage"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; - -const s3 = new S3Client(); - -const server = Bun.serve({ - async fetch(req) { - const url = new URL(req.url); - - if (url.pathname === "/" && req.method === "GET") { - return new Response("Hello World!"); - } - - if (url.pathname === "/" && req.method === "POST") { - const formData = await req.formData(); - const file = formData.get("file")! as File; - const params = { - Bucket: Resource.MyBucket.name, - ContentType: file.type, - Key: file.name, - Body: file, - }; - const upload = new Upload({ - params, - client: s3, - }); - await upload.done(); - - return new Response("File uploaded successfully."); - } - - if (url.pathname === "/latest" && req.method === "GET") { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - const latestFile = objects.Contents!.sort( - (a, b) => - (b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0), - )[0]; - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - return Response.redirect(await getSignedUrl(s3, command)); - } - - return new Response("404!"); - }, -}); - -console.log(`Listening on ${server.url}`); diff --git a/examples/aws-bun/package.json b/examples/aws-bun/package.json deleted file mode 100644 index d2c2c3afb3..0000000000 --- a/examples/aws-bun/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aws-bun", - "module": "index.ts", - "type": "module", - "scripts": { - "dev": "bun run --watch index.ts" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145", - "@types/bun": "latest" - }, - "peerDependencies": { - "typescript": "^5.0.0" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.658.1", - "@aws-sdk/lib-storage": "^3.658.1", - "@aws-sdk/s3-request-presigner": "^3.658.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-bun/sst.config.ts b/examples/aws-bun/sst.config.ts deleted file mode 100644 index 6a75af0d44..0000000000 --- a/examples/aws-bun/sst.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-bun", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const bucket = new sst.aws.Bucket("MyBucket"); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "bun dev", - }, - link: [bucket], - }); - }, -}); diff --git a/examples/aws-bun/tsconfig.json b/examples/aws-bun/tsconfig.json deleted file mode 100644 index 238655f2ce..0000000000 --- a/examples/aws-bun/tsconfig.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "compilerOptions": { - // Enable latest features - "lib": ["ESNext", "DOM"], - "target": "ESNext", - "module": "ESNext", - "moduleDetection": "force", - "jsx": "react-jsx", - "allowJs": true, - - // Bundler mode - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, - - // Best practices - "strict": true, - "skipLibCheck": true, - "noFallthroughCasesInSwitch": true, - - // Some stricter flags (disabled by default) - "noUnusedLocals": false, - "noUnusedParameters": false, - "noPropertyAccessFromIndexSignature": false - } -} diff --git a/examples/aws-bundle/.gitignore b/examples/aws-bundle/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-bundle/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-bundle/package.json b/examples/aws-bundle/package.json deleted file mode 100644 index 737d546186..0000000000 --- a/examples/aws-bundle/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "aws-bundle", - "version": "0.0.0", - "type": "module", - "dependencies": { - "@types/node": "^22.13.2", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-bundle/src/file.json b/examples/aws-bundle/src/file.json deleted file mode 100644 index 29c5f233a6..0000000000 --- a/examples/aws-bundle/src/file.json +++ /dev/null @@ -1 +0,0 @@ -{ "test": "foo" } diff --git a/examples/aws-bundle/src/index.mjs b/examples/aws-bundle/src/index.mjs deleted file mode 100644 index 91c8642eba..0000000000 --- a/examples/aws-bundle/src/index.mjs +++ /dev/null @@ -1,10 +0,0 @@ -import { readFileSync } from "fs"; - -const data = readFileSync(new URL("./file.json", import.meta.url)); - -export async function handler() { - return { - statusCode: 200, - body: data.toString(), - }; -} diff --git a/examples/aws-bundle/src/resource.enc b/examples/aws-bundle/src/resource.enc deleted file mode 100644 index a34504402c..0000000000 --- a/examples/aws-bundle/src/resource.enc +++ /dev/null @@ -1 +0,0 @@ -aΚ NX\SMϻ j \ No newline at end of file diff --git a/examples/aws-bundle/sst.config.ts b/examples/aws-bundle/sst.config.ts deleted file mode 100644 index 76ee71699c..0000000000 --- a/examples/aws-bundle/sst.config.ts +++ /dev/null @@ -1,18 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-bundle", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - new sst.aws.Function("Function", { - bundle: "./src", - handler: "index.handler", - url: true, - }); - }, -}); diff --git a/examples/aws-bundle/tsconfig.json b/examples/aws-bundle/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-bundle/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-bus/.gitignore b/examples/aws-bus/.gitignore deleted file mode 100644 index 9a902f0c53..0000000000 --- a/examples/aws-bus/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# sst -.sst diff --git a/examples/aws-bus/package.json b/examples/aws-bus/package.json deleted file mode 100644 index 17ef5c7687..0000000000 --- a/examples/aws-bus/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "aws-bus", - "version": "0.0.0", - "dependencies": { - "@aws-sdk/client-eventbridge": "^3.582.0", - "sst": "file:../../sdk/js", - "zod": "^4.1.13" - }, - "devDependencies": { - "typescript": "^5.9.3" - } -} diff --git a/examples/aws-bus/src/events.ts b/examples/aws-bus/src/events.ts deleted file mode 100644 index 596f081190..0000000000 --- a/examples/aws-bus/src/events.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { event } from "sst/event"; -import { ZodValidator } from "sst/event/validator"; -import { z } from "zod"; - -const defineEvent = event.builder({ - validator: ZodValidator, - metadata: () => { - return { - timestamp: Date.now(), - }; - }, -}); - -export const MyEvent = defineEvent( - "app.myevent", - z.object({ - foo: z.string(), - }), -); diff --git a/examples/aws-bus/src/publisher.ts b/examples/aws-bus/src/publisher.ts deleted file mode 100644 index 228ff26366..0000000000 --- a/examples/aws-bus/src/publisher.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { bus } from "sst/aws/bus"; -import { z } from "zod"; -import { Resource } from "sst"; -import { MyEvent } from "./events"; - -export async function handler() { - await bus.publish(Resource.Bus, MyEvent, { foo: "hello" }); - - return { - statusCode: 200, - }; -} diff --git a/examples/aws-bus/src/receiver.ts b/examples/aws-bus/src/receiver.ts deleted file mode 100644 index 7d6230d6ea..0000000000 --- a/examples/aws-bus/src/receiver.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { bus } from "sst/aws/bus"; -import { MyEvent } from "./events"; - -export const handler = bus.subscriber([MyEvent], async (event) => { - console.log({ event }); -}); diff --git a/examples/aws-bus/sst.config.ts b/examples/aws-bus/sst.config.ts deleted file mode 100644 index 0e8840a675..0000000000 --- a/examples/aws-bus/sst.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// - -/** - * ## AWS Bus subscriptions - * - * Subscribe bus events with AWS Lambda functions. - */ -export default $config({ - app(input) { - return { - name: "aws-bus", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bus = new sst.aws.Bus("Bus"); - - const publisher = new sst.aws.Function("Publisher", { - handler: "./src/publisher.handler", - url: true, - link: [bus], - }); - - bus.subscribe("Example", "./src/receiver.handler"); - }, -}); diff --git a/examples/aws-bus/tsconfig.json b/examples/aws-bus/tsconfig.json deleted file mode 100644 index 62526ee80a..0000000000 --- a/examples/aws-bus/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "compilerOptions": { - "module": "ESNext", - "moduleResolution": "Bundler" - } -} diff --git a/examples/aws-cloudflare-combined/.gitignore b/examples/aws-cloudflare-combined/.gitignore deleted file mode 100644 index f4d5339fb2..0000000000 --- a/examples/aws-cloudflare-combined/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -node_modules/ -.env -.sst diff --git a/examples/aws-cloudflare-combined/package.json b/examples/aws-cloudflare-combined/package.json deleted file mode 100644 index 0b47f9bf35..0000000000 --- a/examples/aws-cloudflare-combined/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "aws-cloudflare-combined", - "type": "module", - "dependencies": { - "@aws-sdk/client-s3": "^3.701.0", - "@aws-sdk/s3-request-presigner": "^3.701.0", - "@cloudflare/workers-types": "^4.20240403.0", - "hono": "^4.6.12", - "sst": "../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.146" - } -} diff --git a/examples/aws-cloudflare-combined/src/index.ts b/examples/aws-cloudflare-combined/src/index.ts deleted file mode 100644 index cb7ac2f0ae..0000000000 --- a/examples/aws-cloudflare-combined/src/index.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { Hono } from "hono"; -import { handle } from "hono/aws-lambda"; -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { - S3Client, - GetObjectCommand, - PutObjectCommand, - ListObjectsV2Command, -} from "@aws-sdk/client-s3"; - -const s3 = new S3Client(); - -const app = new Hono(); - -app.get("/", async (c) => { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - - return c.text(await getSignedUrl(s3, command)); -}); - -app.get("/latest", async (c) => { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - - const latestFile = objects.Contents!.sort( - (a, b) => - (b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0), - )[0]; - - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - - return c.redirect(await getSignedUrl(s3, command)); -}); - -export const handler = handle(app); diff --git a/examples/aws-cloudflare-combined/sst.config.ts b/examples/aws-cloudflare-combined/sst.config.ts deleted file mode 100644 index 32c74ea0f1..0000000000 --- a/examples/aws-cloudflare-combined/sst.config.ts +++ /dev/null @@ -1,35 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-cloudflare-combined", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - providers: { - cloudflare: "6.13.0", - }, - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket"); - const api = new sst.aws.Function("Hono", { - url: true, - link: [bucket], - handler: "src/index.handler", - }); - - // Add a Cloudflare Bucket and link it to the worker - const cfBucket = new sst.cloudflare.Bucket("CfBucket"); - const worker = new sst.cloudflare.Worker("MyWorker", { - handler: "./worker.ts", - link: [cfBucket], - url: true, - }); - - return { - api: api.url, - worker: worker.url, - }; - }, -}); diff --git a/examples/aws-cloudflare-combined/tsconfig.json b/examples/aws-cloudflare-combined/tsconfig.json deleted file mode 100644 index 95a44f83fe..0000000000 --- a/examples/aws-cloudflare-combined/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "Bundler", - "strict": true, - "skipLibCheck": true, - "types": ["node"] - } -} diff --git a/examples/aws-cloudflare-combined/worker.ts b/examples/aws-cloudflare-combined/worker.ts deleted file mode 100644 index abea65a222..0000000000 --- a/examples/aws-cloudflare-combined/worker.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Resource } from "sst"; - -export default { - async fetch(req: Request) { - if (req.method === "PUT") { - const key = crypto.randomUUID(); - await Resource.CfBucket.put(key, req.body, { - httpMetadata: { - contentType: req.headers.get("content-type"), - }, - }); - return new Response(`Object created with key: ${key}`); - } - - if (req.method === "GET") { - const first = await Resource.CfBucket.list().then( - (res) => - res.objects.toSorted( - (a, b) => a.uploaded.getTime() - b.uploaded.getTime(), - )[0], - ); - if (!first) { - return new Response("No objects found"); - } - const result = await Resource.CfBucket.get(first.key); - return new Response(result.body, { - headers: { - "content-type": result.httpMetadata.contentType, - }, - }); - } - - return new Response("Hello from Cloudflare Worker!"); - }, -}; diff --git a/examples/aws-cluster-autoscaling/.dockerignore b/examples/aws-cluster-autoscaling/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-cluster-autoscaling/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-cluster-autoscaling/Dockerfile b/examples/aws-cluster-autoscaling/Dockerfile deleted file mode 100644 index 9cfff20241..0000000000 --- a/examples/aws-cluster-autoscaling/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] \ No newline at end of file diff --git a/examples/aws-cluster-autoscaling/index.mjs b/examples/aws-cluster-autoscaling/index.mjs deleted file mode 100644 index dc532b9de3..0000000000 --- a/examples/aws-cluster-autoscaling/index.mjs +++ /dev/null @@ -1,13 +0,0 @@ -import express from "express"; - -const PORT = 80; - -const app = express(); - -app.get("/", async (req, res) => { - res.send("Hello World"); -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-cluster-autoscaling/package.json b/examples/aws-cluster-autoscaling/package.json deleted file mode 100644 index 6afabf1390..0000000000 --- a/examples/aws-cluster-autoscaling/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "aws-cluster-autoscaling", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "@aws-sdk/client-sqs": "^3.682.0", - "express": "^4.21.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-cluster-autoscaling/queue.ts b/examples/aws-cluster-autoscaling/queue.ts deleted file mode 100644 index f9e07dd59e..0000000000 --- a/examples/aws-cluster-autoscaling/queue.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Resource } from "sst"; -import { - SQSClient, - SendMessageBatchCommand, - PurgeQueueCommand, -} from "@aws-sdk/client-sqs"; -const client = new SQSClient(); - -export const seeder = async () => { - await client.send( - new SendMessageBatchCommand({ - QueueUrl: Resource.MyQueue.url, - Entries: [ - { Id: "1", MessageBody: JSON.stringify({ foo: "bar" }) }, - { Id: "2", MessageBody: JSON.stringify({ foo: "bar" }) }, - { Id: "3", MessageBody: JSON.stringify({ foo: "bar" }) }, - { Id: "4", MessageBody: JSON.stringify({ foo: "bar" }) }, - { Id: "5", MessageBody: JSON.stringify({ foo: "bar" }) }, - ], - }) - ); - - return { statusCode: 200, body: "seeded" }; -}; - -export const purger = async () => { - await client.send( - new PurgeQueueCommand({ - QueueUrl: Resource.MyQueue.url, - }) - ); - - return { statusCode: 200, body: "purged" }; -}; diff --git a/examples/aws-cluster-autoscaling/sst.config.ts b/examples/aws-cluster-autoscaling/sst.config.ts deleted file mode 100644 index 2f5905f030..0000000000 --- a/examples/aws-cluster-autoscaling/sst.config.ts +++ /dev/null @@ -1,175 +0,0 @@ -/// - -/** - * ## AWS Cluster custom autoscaling - * - * In this example, we'll create a cluster that autoscales based on a custom - * metric. In this case, the number of messages in a queue. - * - * We'll create a queue, and two functions that'll seed and purge the queue. We'll - * also create two policies. - * - * One that scales it up. - * - * ```ts title="sst.config.ts" - * const scaleUpPolicy = new aws.appautoscaling.Policy("ScaleUpPolicy", { - * serviceNamespace: service.nodes.autoScalingTarget.serviceNamespace, - * scalableDimension: service.nodes.autoScalingTarget.scalableDimension, - * resourceId: service.nodes.autoScalingTarget.resourceId, - * policyType: "StepScaling", - * stepScalingPolicyConfiguration: { - * adjustmentType: "ChangeInCapacity", - * cooldown: 5, - * stepAdjustments: [ - * { - * metricIntervalLowerBound: "0", - * scalingAdjustment: 1, - * }, - * ], - * }, - * }); - * ``` - * - * And one that scales it down. - * - * ```ts title="sst.config.ts" - * const scaleDownPolicy = new aws.appautoscaling.Policy("ScaleDownPolicy", { - * serviceNamespace: service.nodes.autoScalingTarget.serviceNamespace, - * scalableDimension: service.nodes.autoScalingTarget.scalableDimension, - * resourceId: service.nodes.autoScalingTarget.resourceId, - * policyType: "StepScaling", - * stepScalingPolicyConfiguration: { - * adjustmentType: "ChangeInCapacity", - * cooldown: 5, - * stepAdjustments: [ - * { - * metricIntervalUpperBound: "0", - * scalingAdjustment: -1, - * }, - * ], - * }, - * }); - * ``` - * - * We'll add a CloudWatch metric alarm that triggers the scaling policies if the - * queue depth exceeds 3 messages. - * - * ```ts title="sst.config.ts" - * new aws.cloudwatch.MetricAlarm("QueueDepthAlarm", { - * comparisonOperator: "GreaterThanThreshold", - * evaluationPeriods: 1, - * metricName: "ApproximateNumberOfMessagesVisible", - * namespace: "AWS/SQS", - * period: 10, - * statistic: "Average", - * threshold: 3, - * dimensions: { - * QueueName: queue.nodes.queue.name, - * }, - * alarmDescription: "Scale up when queue depth exceeds 3 messages", - * alarmActions: [scaleUpPolicy.arn], - * okActions: [scaleDownPolicy.arn], - * }); - * ``` - * - * To test this example, first deploy your app then: - * - * 1. Invoke the `MyQueueSeeder` URL. This will cause the service to scale up to 5 - * instances in a few minutes. - * 2. Then invoke the `MyQueuePurger` URL. This will cause the service to scale - * down to 1 instance in a few minutes. - */ -export default $config({ - app(input) { - return { - name: "aws-cluster-autoscaling", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - - // Create a queue and two functions to seed and purge the queue - const queue = new sst.aws.Queue("MyQueue"); - new sst.aws.Function("MyQueueSeeder", { - handler: "queue.seeder", - link: [queue], - url: true, - }); - new sst.aws.Function("MyQueuePurger", { - handler: "queue.purger", - link: [queue], - url: true, - }); - - // Create a cluster and disable default scaling on CPU and memory utilization - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - const service = new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http" }], - }, - scaling: { - min: 1, - max: 5, - cpuUtilization: false, - memoryUtilization: false, - }, - }); - - // Create a scale up policy that scales up by 1 instance at a time - const scaleUpPolicy = new aws.appautoscaling.Policy("ScaleUpPolicy", { - serviceNamespace: service.nodes.autoScalingTarget.serviceNamespace, - scalableDimension: service.nodes.autoScalingTarget.scalableDimension, - resourceId: service.nodes.autoScalingTarget.resourceId, - policyType: "StepScaling", - stepScalingPolicyConfiguration: { - adjustmentType: "ChangeInCapacity", - cooldown: 5, - stepAdjustments: [ - { - metricIntervalLowerBound: "0", - scalingAdjustment: 1, - }, - ], - }, - }); - - // Create a scale down policy that scales down by 1 instance at a time - const scaleDownPolicy = new aws.appautoscaling.Policy("ScaleDownPolicy", { - serviceNamespace: service.nodes.autoScalingTarget.serviceNamespace, - scalableDimension: service.nodes.autoScalingTarget.scalableDimension, - resourceId: service.nodes.autoScalingTarget.resourceId, - policyType: "StepScaling", - stepScalingPolicyConfiguration: { - adjustmentType: "ChangeInCapacity", - cooldown: 5, - stepAdjustments: [ - { - metricIntervalUpperBound: "0", - scalingAdjustment: -1, - }, - ], - }, - }); - - // Create an alarm that scales up when the queue depth exceeds 3 messages - // and scales down when the queue depth is less than 3 messages - new aws.cloudwatch.MetricAlarm("QueueDepthAlarm", { - comparisonOperator: "GreaterThanThreshold", - evaluationPeriods: 1, - metricName: "ApproximateNumberOfMessagesVisible", - namespace: "AWS/SQS", - period: 10, - statistic: "Average", - threshold: 3, - dimensions: { - QueueName: queue.nodes.queue.name, - }, - alarmDescription: "Scale up when queue depth exceeds 3 messages", - alarmActions: [scaleUpPolicy.arn], - okActions: [scaleDownPolicy.arn], - }); - }, -}); diff --git a/examples/aws-cluster-internal/.dockerignore b/examples/aws-cluster-internal/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-cluster-internal/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-cluster-internal/Dockerfile b/examples/aws-cluster-internal/Dockerfile deleted file mode 100644 index 9cfff20241..0000000000 --- a/examples/aws-cluster-internal/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] \ No newline at end of file diff --git a/examples/aws-cluster-internal/index.mjs b/examples/aws-cluster-internal/index.mjs deleted file mode 100644 index dc532b9de3..0000000000 --- a/examples/aws-cluster-internal/index.mjs +++ /dev/null @@ -1,13 +0,0 @@ -import express from "express"; - -const PORT = 80; - -const app = express(); - -app.get("/", async (req, res) => { - res.send("Hello World"); -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-cluster-internal/package.json b/examples/aws-cluster-internal/package.json deleted file mode 100644 index 5b900c19c6..0000000000 --- a/examples/aws-cluster-internal/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-cluster-internal", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "express": "^4.21.1" - } -} diff --git a/examples/aws-cluster-internal/sst.config.ts b/examples/aws-cluster-internal/sst.config.ts deleted file mode 100644 index b218497fa3..0000000000 --- a/examples/aws-cluster-internal/sst.config.ts +++ /dev/null @@ -1,31 +0,0 @@ -/// - -/** - * ## AWS Cluster private service - * - * Adds a private load balancer to a service by setting the `loadBalancer.public` prop to - * `false`. - * - * This allows you to create internal services that can only be accessed inside a VPC. - */ -export default $config({ - app(input) { - return { - name: "aws-cluster-internal", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - public: false, - ports: [{ listen: "80/http" }], - }, - }); - }, -}); diff --git a/examples/aws-cluster-spot/.dockerignore b/examples/aws-cluster-spot/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-cluster-spot/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-cluster-spot/Dockerfile b/examples/aws-cluster-spot/Dockerfile deleted file mode 100644 index 9cfff20241..0000000000 --- a/examples/aws-cluster-spot/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] \ No newline at end of file diff --git a/examples/aws-cluster-spot/index.mjs b/examples/aws-cluster-spot/index.mjs deleted file mode 100644 index dc532b9de3..0000000000 --- a/examples/aws-cluster-spot/index.mjs +++ /dev/null @@ -1,13 +0,0 @@ -import express from "express"; - -const PORT = 80; - -const app = express(); - -app.get("/", async (req, res) => { - res.send("Hello World"); -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-cluster-spot/package.json b/examples/aws-cluster-spot/package.json deleted file mode 100644 index 4efa76a9ce..0000000000 --- a/examples/aws-cluster-spot/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-cluster-spot", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "express": "^4.21.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-cluster-spot/sst.config.ts b/examples/aws-cluster-spot/sst.config.ts deleted file mode 100644 index c3dc6f0d3f..0000000000 --- a/examples/aws-cluster-spot/sst.config.ts +++ /dev/null @@ -1,31 +0,0 @@ -/// - -/** - * ## AWS Cluster Spot capacity - * - * This example, shows how to use the Fargate Spot capacity provider for your services. - * - * We have it set to use only Fargate Spot instances for all non-production stages. Learn more - * about the [`capacity`](/docs/component/aws/cluster#capacity) prop. - */ -export default $config({ - app(input) { - return { - name: "aws-cluster-spot", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http" }], - }, - capacity: $app.stage === "production" ? undefined : "spot", - }); - }, -}); diff --git a/examples/aws-cluster-vpclink/.dockerignore b/examples/aws-cluster-vpclink/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-cluster-vpclink/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-cluster-vpclink/Dockerfile b/examples/aws-cluster-vpclink/Dockerfile deleted file mode 100644 index 9cfff20241..0000000000 --- a/examples/aws-cluster-vpclink/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] \ No newline at end of file diff --git a/examples/aws-cluster-vpclink/index.mjs b/examples/aws-cluster-vpclink/index.mjs deleted file mode 100644 index dc532b9de3..0000000000 --- a/examples/aws-cluster-vpclink/index.mjs +++ /dev/null @@ -1,13 +0,0 @@ -import express from "express"; - -const PORT = 80; - -const app = express(); - -app.get("/", async (req, res) => { - res.send("Hello World"); -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-cluster-vpclink/package.json b/examples/aws-cluster-vpclink/package.json deleted file mode 100644 index dfafa8b64a..0000000000 --- a/examples/aws-cluster-vpclink/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-cluster-vpclink", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "express": "^4.21.1" - } -} diff --git a/examples/aws-cluster-vpclink/sst.config.ts b/examples/aws-cluster-vpclink/sst.config.ts deleted file mode 100644 index f616f0017d..0000000000 --- a/examples/aws-cluster-vpclink/sst.config.ts +++ /dev/null @@ -1,68 +0,0 @@ -/// - -/** - * ## AWS Cluster with API Gateway - * - * Expose a service through API Gateway HTTP API using a VPC link. - * - * This is an alternative to using a load balancer. Since API Gateway is pay per request, it - * works out a lot cheaper for services that don't get a lot of traffic. - * - * You need to specify which port in your service will be exposed through API Gateway. - * - * ```ts title="sst.config.ts" {4} - * const service = new sst.aws.Service("MyService", { - * cluster, - * serviceRegistry: { - * port: 80, - * }, - * }); - * ``` - * - * A couple of things to note: - * - * 1. Your API Gateway HTTP API also needs to be in the **same VPC** as the service. - * - * 2. You also need to verify that your VPC's [**availability zones support VPC link**](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vpc-links.html#http-api-vpc-link-availability). - * - * 3. Run `aws ec2 describe-availability-zones` to get a list of AZs for your - * account. - * - * 4. Only list the AZ ID's that support VPC link. - * ```ts title="sst.config.ts" {4} - * vpc: { - * az: ["eu-west-3a", "eu-west-3c"] - * } - * ``` - * If the VPC picks an AZ automatically that doesn't support VPC link, you'll get - * the following error: - * ``` - * operation error ApiGatewayV2: BadRequestException: Subnet is in Availability - * Zone 'euw3-az2' where service is not available - * ``` - */ -export default $config({ - app(input) { - return { - name: "aws-cluster-vpclink", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { - // Pick at least two AZs that support VPC link - // az: ["eu-west-3a", "eu-west-3c"], - }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - const service = new sst.aws.Service("MyService", { - cluster, - serviceRegistry: { - port: 80, - }, - }); - - const api = new sst.aws.ApiGatewayV2("MyApi", { vpc }); - api.routePrivate("$default", service.nodes.cloudmapService.arn); - }, -}); diff --git a/examples/aws-cognito/index.ts b/examples/aws-cognito/index.ts deleted file mode 100644 index ce0c87f62d..0000000000 --- a/examples/aws-cognito/index.ts +++ /dev/null @@ -1 +0,0 @@ -export async function handler() {} diff --git a/examples/aws-cognito/package.json b/examples/aws-cognito/package.json deleted file mode 100644 index 0710943f9c..0000000000 --- a/examples/aws-cognito/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-cognito", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-cognito/sst.config.ts b/examples/aws-cognito/sst.config.ts deleted file mode 100644 index e1392fcf95..0000000000 --- a/examples/aws-cognito/sst.config.ts +++ /dev/null @@ -1,49 +0,0 @@ -/// - -/** - * ## AWS Cognito User Pool - * - * Create a Cognito User Pool with a hosted UI domain, client, and identity pool. - * - */ -export default $config({ - app(input) { - return { - name: "aws-cognito", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const userPool = new sst.aws.CognitoUserPool("MyUserPool", { - domain: { - prefix: `my-app-${$app.stage}`, - }, - triggers: { - preSignUp: { - handler: "index.handler", - }, - }, - }); - - const client = userPool.addClient("Web", { - callbackUrls: ['https://example.com/auth/callback'] - }); - - const identityPool = new sst.aws.CognitoIdentityPool("MyIdentityPool", { - userPools: [ - { - userPool: userPool.id, - client: client.id, - }, - ], - }); - - return { - UserPool: userPool.id, - Client: client.id, - IdentityPool: identityPool.id, - DomainUrl: userPool.domainUrl, - }; - }, -}); diff --git a/examples/aws-copy-files/.gitignore b/examples/aws-copy-files/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-copy-files/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-copy-files/files/foo.json b/examples/aws-copy-files/files/foo.json deleted file mode 100644 index c8c4105eb5..0000000000 --- a/examples/aws-copy-files/files/foo.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "foo": "bar" -} diff --git a/examples/aws-copy-files/index.ts b/examples/aws-copy-files/index.ts deleted file mode 100644 index ce0c87f62d..0000000000 --- a/examples/aws-copy-files/index.ts +++ /dev/null @@ -1 +0,0 @@ -export async function handler() {} diff --git a/examples/aws-copy-files/package.json b/examples/aws-copy-files/package.json deleted file mode 100644 index e343eb1f30..0000000000 --- a/examples/aws-copy-files/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-copy-files", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-copy-files/sst.config.ts b/examples/aws-copy-files/sst.config.ts deleted file mode 100644 index f828e9beab..0000000000 --- a/examples/aws-copy-files/sst.config.ts +++ /dev/null @@ -1,25 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-copy-files", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const fn = new sst.aws.Function("MyFunction", { - handler: "index.handler", - url: true, - copyFiles: [ - { - from: "./files", - }, - ], - }); - return { - url: fn.url, - }; - }, -}); diff --git a/examples/aws-copy-files/tsconfig.json b/examples/aws-copy-files/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-copy-files/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-dart-api/.gitignore b/examples/aws-dart-api/.gitignore deleted file mode 100644 index 214545df01..0000000000 --- a/examples/aws-dart-api/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -# https://dart.dev/guides/libraries/private-files -# Created by `dart pub` -.dart_tool/ - -# Avoid committing pubspec.lock for library packages; see -# https://dart.dev/guides/libraries/private-files#pubspeclock. -pubspec.lock - -# sst -.sst diff --git a/examples/aws-dart-api/CHANGELOG.md b/examples/aws-dart-api/CHANGELOG.md deleted file mode 100644 index effe43c82c..0000000000 --- a/examples/aws-dart-api/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## 1.0.0 - -- Initial version. diff --git a/examples/aws-dart-api/analysis_options.yaml b/examples/aws-dart-api/analysis_options.yaml deleted file mode 100644 index dee8927aaf..0000000000 --- a/examples/aws-dart-api/analysis_options.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# This file configures the static analysis results for your project (errors, -# warnings, and lints). -# -# This enables the 'recommended' set of lints from `package:lints`. -# This set helps identify many issues that may lead to problems when running -# or consuming Dart code, and enforces writing Dart using a single, idiomatic -# style and format. -# -# If you want a smaller set of lints you can change this to specify -# 'package:lints/core.yaml'. These are just the most critical lints -# (the recommended set includes the core lints). -# The core lints are also what is used by pub.dev for scoring packages. - -include: package:lints/recommended.yaml - -# Uncomment the following section to specify additional rules. - -# linter: -# rules: -# - camel_case_types - -# analyzer: -# exclude: -# - path/to/excluded/files/** - -# For more information about the core and recommended set of lints, see -# https://dart.dev/go/core-lints - -# For additional information about configuring this file, see -# https://dart.dev/guides/language/analysis-options diff --git a/examples/aws-dart-api/build.sh b/examples/aws-dart-api/build.sh deleted file mode 100755 index 4de7c08a2a..0000000000 --- a/examples/aws-dart-api/build.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# Install dependencies -dart pub get - -# build the binary -dart compile exe lib/src/main.dart -o .build/bootstrap - -# Exit -exit \ No newline at end of file diff --git a/examples/aws-dart-api/lib/src/main.dart b/examples/aws-dart-api/lib/src/main.dart deleted file mode 100644 index 56eb949b05..0000000000 --- a/examples/aws-dart-api/lib/src/main.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:aws_lambda_dart_runtime/aws_lambda_dart_runtime.dart'; -import 'package:aws_lambda_dart_runtime/runtime/context.dart'; - -void main() async { - /// This demo's handling an API Gateway request. - hello(Context context, AwsApiGatewayEvent event) async { - final response = { - "message": "Hello from Dart!", - }; - return AwsApiGatewayResponse.fromJson(response); - } - - /// The Runtime is a singleton. You can define the handlers as you wish. - Runtime() - ..registerHandler( - 'hello', - hello, - ) - ..invoke(); -} diff --git a/examples/aws-dart-api/pubspec.yaml b/examples/aws-dart-api/pubspec.yaml deleted file mode 100644 index ed5c78ed7c..0000000000 --- a/examples/aws-dart-api/pubspec.yaml +++ /dev/null @@ -1,16 +0,0 @@ -name: aws_dart_api -description: A starting point for an AWS Serverless Api using Dart and SST ION. -version: 1.0.0 -publish_to: none - -environment: - sdk: ^3.4.0 - -dependencies: - aws_lambda_dart_runtime: - git: - url: https://github.com/katallaxie/aws-lambda-dart-runtime - -dev_dependencies: - lints: ^3.0.0 - test: ^1.24.0 diff --git a/examples/aws-dart-api/sst.config.ts b/examples/aws-dart-api/sst.config.ts deleted file mode 100644 index d9b4232604..0000000000 --- a/examples/aws-dart-api/sst.config.ts +++ /dev/null @@ -1,28 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-dart-api", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const api = new sst.aws.ApiGatewayV2("MyApi"); - api.route("GET /", { - runtime: "provided.al2023", - architecture: process.arch === "arm64" ? "arm64" : "x86_64", - bundle: build(), - handler: "hello", - }); - }, -}); - -function build() { - require("child_process").execSync(` -mkdir -p .build -docker run -v $PWD:/app -w /app --entrypoint ./build.sh dart:stable-sdk -`); - return `.build/`; -} diff --git a/examples/aws-dead-letter-queue/package.json b/examples/aws-dead-letter-queue/package.json deleted file mode 100644 index f2b2de79e4..0000000000 --- a/examples/aws-dead-letter-queue/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "aws-dead-letter-queue", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "deploy": "go run ../../cmd/sst deploy", - "remove": "go run ../../cmd/sst remove", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "@types/aws-lambda": "^8.10.149", - "sst": "file:../../sdk/js" - }, - "dependencies": { - "@aws-sdk/client-sqs": "^3.515.0" - } -} diff --git a/examples/aws-dead-letter-queue/publisher.ts b/examples/aws-dead-letter-queue/publisher.ts deleted file mode 100644 index 3d71dac18d..0000000000 --- a/examples/aws-dead-letter-queue/publisher.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Resource } from "sst"; -import { SQSClient, SendMessageCommand } from "@aws-sdk/client-sqs"; -const client = new SQSClient(); - -export const handler = async (event) => { - // send a message - await client.send( - new SendMessageCommand({ - QueueUrl: Resource.MyQueue.url, - MessageBody: "Hello from the subscriber", - }) - ); - - return { - statusCode: 200, - body: JSON.stringify({ status: "sent" }, null, 2), - }; -}; diff --git a/examples/aws-dead-letter-queue/sst.config.ts b/examples/aws-dead-letter-queue/sst.config.ts deleted file mode 100644 index c9ebbb6f2b..0000000000 --- a/examples/aws-dead-letter-queue/sst.config.ts +++ /dev/null @@ -1,39 +0,0 @@ -/// - -/** - * ## Subscribe to queues with dead-letter queue - * - * Messages not processed successfully by the primary subscriber function will be sent to the dead-letter queue after the retry limit is reached. - */ -export default $config({ - app(input) { - return { - name: "aws-dead-letter-queue", - home: "aws", - removal: input.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - // create dead letter queue - const dlq = new sst.aws.Queue("DeadLetterQueue"); - dlq.subscribe("subscriber.dlq"); - - // create main queue - const queue = new sst.aws.Queue("MyQueue", { - dlq: dlq.arn, - }); - queue.subscribe("subscriber.main"); - - const app = new sst.aws.Function("MyApp", { - handler: "publisher.handler", - link: [queue], - url: true, - }); - - return { - app: app.url, - queue: queue.url, - dlq: dlq.url, - }; - }, -}); diff --git a/examples/aws-dead-letter-queue/subscriber.ts b/examples/aws-dead-letter-queue/subscriber.ts deleted file mode 100644 index c4b7967f0f..0000000000 --- a/examples/aws-dead-letter-queue/subscriber.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { SQSEvent, SQSHandler } from "aws-lambda"; - -export const main = async (event) => { - console.log(event); - throw new Error("Manual error"); -}; - -export const dlq: SQSHandler = async (event: SQSEvent) => { - console.log(event); - return; -}; diff --git a/examples/aws-deno-redis/.dockerignore b/examples/aws-deno-redis/.dockerignore deleted file mode 100644 index fa2aea8208..0000000000 --- a/examples/aws-deno-redis/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -.sst diff --git a/examples/aws-deno-redis/.gitignore b/examples/aws-deno-redis/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-deno-redis/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-deno-redis/Dockerfile b/examples/aws-deno-redis/Dockerfile deleted file mode 100644 index b5d22eb996..0000000000 --- a/examples/aws-deno-redis/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM denoland/deno - -EXPOSE 8000 - -USER deno - -WORKDIR /app - -ADD . /app - -RUN deno install --entrypoint main.ts - -CMD ["run", "--allow-all", "main.ts"] diff --git a/examples/aws-deno-redis/deno.json b/examples/aws-deno-redis/deno.json deleted file mode 100644 index 322530bdf8..0000000000 --- a/examples/aws-deno-redis/deno.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "tasks": { - "dev": "deno run --watch --allow-all main.ts" - }, - "imports": { - "@std/assert": "jsr:@std/assert@1", - "ioredis": "npm:ioredis@^5.4.1", - "sst": "npm:sst@latest" - } -} diff --git a/examples/aws-deno-redis/main.ts b/examples/aws-deno-redis/main.ts deleted file mode 100644 index 54cc884fe1..0000000000 --- a/examples/aws-deno-redis/main.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Resource } from "sst"; -import { Cluster } from "ioredis"; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - }, -); - -Deno.serve(async (_req) => { - const counter = await redis.incr("counter"); - return new Response(`Hit counter: ${counter}`); -}); diff --git a/examples/aws-deno-redis/main_test.ts b/examples/aws-deno-redis/main_test.ts deleted file mode 100644 index 3d981e9bed..0000000000 --- a/examples/aws-deno-redis/main_test.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { assertEquals } from "@std/assert"; -import { add } from "./main.ts"; - -Deno.test(function addTest() { - assertEquals(add(2, 3), 5); -}); diff --git a/examples/aws-deno-redis/sst.config.ts b/examples/aws-deno-redis/sst.config.ts deleted file mode 100644 index ab583c5152..0000000000 --- a/examples/aws-deno-redis/sst.config.ts +++ /dev/null @@ -1,68 +0,0 @@ -/// - -/** - * ## AWS Deno Redis - * - * Creates a hit counter app with Deno and Redis. - * - * This deploys Deno as a Fargate service to ECS and it's linked to Redis. - * - * ```ts title="sst.config.ts" {3} - * new sst.aws.Service("MyService", { - * cluster, - * link: [redis], - * loadBalancer: { - * ports: [{ listen: "80/http", forward: "8000/http" }], - * }, - * dev: { - * command: "deno task dev", - * }, - * }); - * ``` - * - * Since our Redis cluster is in a VPC, we’ll need a tunnel to connect to it from our local - * machine. - * - * ```bash "sudo" - * sudo sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * To start your app locally run. - * - * ```bash - * sst dev - * ``` - * - * Now if you go to `http://localhost:8000` you’ll see a counter update as you refresh the page. - * - * Finally, you can deploy it using `sst deploy --stage production` using a `Dockerfile` - * that's included in the example. - */ -export default $config({ - app(input) { - return { - name: "aws-deno-redis", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: "80/http", forward: "8000/http" }], - }, - dev: { - command: "deno task dev", - }, - }); - }, -}); diff --git a/examples/aws-deno/.dockerignore b/examples/aws-deno/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-deno/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-deno/.gitignore b/examples/aws-deno/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-deno/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-deno/Dockerfile b/examples/aws-deno/Dockerfile deleted file mode 100644 index b5d22eb996..0000000000 --- a/examples/aws-deno/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM denoland/deno - -EXPOSE 8000 - -USER deno - -WORKDIR /app - -ADD . /app - -RUN deno install --entrypoint main.ts - -CMD ["run", "--allow-all", "main.ts"] diff --git a/examples/aws-deno/deno.json b/examples/aws-deno/deno.json deleted file mode 100644 index bfc899069e..0000000000 --- a/examples/aws-deno/deno.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "tasks": { - "dev": "deno run --allow-all --watch main.ts" - }, - "imports": { - "@aws-sdk/client-s3": "npm:@aws-sdk/client-s3@^3.705.0", - "@aws-sdk/lib-storage": "npm:@aws-sdk/lib-storage@^3.705.0", - "@aws-sdk/s3-request-presigner": "npm:@aws-sdk/s3-request-presigner@^3.705.0", - "@std/assert": "jsr:@std/assert@1", - "sst": "npm:sst@latest" - } -} diff --git a/examples/aws-deno/main.ts b/examples/aws-deno/main.ts deleted file mode 100644 index 1518555c6a..0000000000 --- a/examples/aws-deno/main.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { Resource } from "sst"; -import { - S3Client, - GetObjectCommand, - ListObjectsV2Command, -} from "@aws-sdk/client-s3"; -import { Upload } from "@aws-sdk/lib-storage"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; - -const s3 = new S3Client(); - -Deno.serve(async (req) => { - const url = new URL(req.url); - - if (url.pathname === "/" && req.method === "GET") { - return new Response("Hello World!"); - } - - if (url.pathname === "/" && req.method === "POST") { - const formData: FormData = await req.formData(); - const file: File | null = formData?.get("file") as File; - - const params = { - Bucket: Resource.MyBucket.name, - ContentType: file.type, - Key: file.name, - Body: file, - }; - const upload = new Upload({ - params, - client: s3, - }); - await upload.done(); - - return new Response("File uploaded successfully."); - } - - if (url.pathname === "/latest" && req.method === "GET") { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - const latestFile = objects.Contents!.sort( - (a, b) => - (b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0), - )[0]; - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - return Response.redirect(await getSignedUrl(s3, command)); - } - - return new Response("404!"); -}); diff --git a/examples/aws-deno/sst.config.ts b/examples/aws-deno/sst.config.ts deleted file mode 100644 index a414477373..0000000000 --- a/examples/aws-deno/sst.config.ts +++ /dev/null @@ -1,28 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-deno", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const bucket = new sst.aws.Bucket("MyBucket"); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [bucket], - loadBalancer: { - ports: [{ listen: "80/http", forward: "8000/http" }], - }, - dev: { - command: "deno task dev", - }, - }); - }, -}); diff --git a/examples/aws-drizzle-migrations/.gitignore b/examples/aws-drizzle-migrations/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-drizzle-migrations/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-drizzle-migrations/drizzle.config.ts b/examples/aws-drizzle-migrations/drizzle.config.ts deleted file mode 100644 index 373785baed..0000000000 --- a/examples/aws-drizzle-migrations/drizzle.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Resource } from "sst"; -import { defineConfig } from "drizzle-kit"; - -export default defineConfig({ - dialect: "postgresql", - // Pick up all our schema files - schema: ["./src/**/*.sql.ts"], - out: "./migrations", - dbCredentials: { - ssl: { - rejectUnauthorized: false, - }, - host: Resource.MyPostgres.host, - port: Resource.MyPostgres.port, - user: Resource.MyPostgres.username, - password: Resource.MyPostgres.password, - database: Resource.MyPostgres.database, - }, -}); diff --git a/examples/aws-drizzle-migrations/migrations/0000_lethal_justin_hammer.sql b/examples/aws-drizzle-migrations/migrations/0000_lethal_justin_hammer.sql deleted file mode 100644 index db52d6f17f..0000000000 --- a/examples/aws-drizzle-migrations/migrations/0000_lethal_justin_hammer.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE IF NOT EXISTS "todo" ( - "id" serial PRIMARY KEY NOT NULL, - "title" text NOT NULL, - "description" text -); diff --git a/examples/aws-drizzle-migrations/migrations/meta/0000_snapshot.json b/examples/aws-drizzle-migrations/migrations/meta/0000_snapshot.json deleted file mode 100644 index 816f447c30..0000000000 --- a/examples/aws-drizzle-migrations/migrations/meta/0000_snapshot.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "id": "89cd0e0e-59a6-42ec-a876-c44671efc130", - "prevId": "00000000-0000-0000-0000-000000000000", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.todo": { - "name": "todo", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/examples/aws-drizzle-migrations/migrations/meta/_journal.json b/examples/aws-drizzle-migrations/migrations/meta/_journal.json deleted file mode 100644 index d1f9a2ea91..0000000000 --- a/examples/aws-drizzle-migrations/migrations/meta/_journal.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "version": "7", - "dialect": "postgresql", - "entries": [ - { - "idx": 0, - "version": "7", - "when": 1729181504948, - "tag": "0000_lethal_justin_hammer", - "breakpoints": true - } - ] -} \ No newline at end of file diff --git a/examples/aws-drizzle-migrations/package.json b/examples/aws-drizzle-migrations/package.json deleted file mode 100644 index 1e6443a3ed..0000000000 --- a/examples/aws-drizzle-migrations/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-drizzle-migrations", - "version": "0.0.0", - "type": "module", - "scripts": { - "db": "sst shell drizzle-kit" - }, - "dependencies": { - "@types/aws-lambda": "^8.10.142", - "@types/pg": "^8.11.10", - "drizzle-kit": "^0.26.2", - "drizzle-orm": "^0.35.1", - "pg": "^8.13.0", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-drizzle-migrations/src/api.ts b/examples/aws-drizzle-migrations/src/api.ts deleted file mode 100644 index 1cfb345fc0..0000000000 --- a/examples/aws-drizzle-migrations/src/api.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { db } from "./drizzle"; -import { todo } from "./todo.sql"; -import { APIGatewayProxyEventV2 } from "aws-lambda"; - -export const handler = async (evt: APIGatewayProxyEventV2) => { - if (evt.requestContext.http.method === "GET") { - const result = await db.select().from(todo).execute(); - - return { - statusCode: 200, - body: JSON.stringify(result, null, 2), - }; - } - - if (evt.requestContext.http.method === "POST") { - const result = await db - .insert(todo) - .values({ title: "Todo", description: crypto.randomUUID() }) - .returning() - .execute(); - - return { - statusCode: 200, - body: JSON.stringify(result), - }; - } -}; diff --git a/examples/aws-drizzle-migrations/src/drizzle.ts b/examples/aws-drizzle-migrations/src/drizzle.ts deleted file mode 100644 index c556a2c74a..0000000000 --- a/examples/aws-drizzle-migrations/src/drizzle.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { drizzle } from "drizzle-orm/node-postgres"; -import { Pool } from "pg"; -import { Resource } from "sst"; -import * as schema from "./todo.sql"; - -const pool = new Pool({ - host: Resource.MyPostgres.host, - port: Resource.MyPostgres.port, - user: Resource.MyPostgres.username, - password: Resource.MyPostgres.password, - database: Resource.MyPostgres.database, -}); - -export const db = drizzle(pool, { schema }); diff --git a/examples/aws-drizzle-migrations/src/migrator.ts b/examples/aws-drizzle-migrations/src/migrator.ts deleted file mode 100644 index d24594b9f2..0000000000 --- a/examples/aws-drizzle-migrations/src/migrator.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { db } from "./drizzle"; -import { migrate } from "drizzle-orm/postgres-js/migrator"; - -export const handler = async (event: any) => { - await migrate(db, { - migrationsFolder: "./migrations", - }); -}; \ No newline at end of file diff --git a/examples/aws-drizzle-migrations/src/scrap.ts b/examples/aws-drizzle-migrations/src/scrap.ts deleted file mode 100644 index ab59ad1118..0000000000 --- a/examples/aws-drizzle-migrations/src/scrap.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { eq } from "drizzle-orm"; -import { db } from "./drizzle"; -import { user } from "./todo.sql"; - -const uuid = "d997d46d-5769-4c78-9a35-93acadbe6076"; -await db.query.user.findMany({ - where: eq(user.id, uuid), - with: { - todos: { - with: { - todo: true, - }, - }, - }, -}); diff --git a/examples/aws-drizzle-migrations/src/todo.sql.ts b/examples/aws-drizzle-migrations/src/todo.sql.ts deleted file mode 100644 index 593829b61b..0000000000 --- a/examples/aws-drizzle-migrations/src/todo.sql.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { text, serial, pgTable } from "drizzle-orm/pg-core"; - -export const todo = pgTable("todo", { - id: serial("id").primaryKey(), - title: text("title").notNull(), - description: text("description"), -}); diff --git a/examples/aws-drizzle-migrations/sst.config.ts b/examples/aws-drizzle-migrations/sst.config.ts deleted file mode 100644 index c19a4bb35c..0000000000 --- a/examples/aws-drizzle-migrations/sst.config.ts +++ /dev/null @@ -1,95 +0,0 @@ -/// - -/** - * ## Drizzle migrations in CI/CD - * - * An example on how to run Drizzle migrations as a part of your CI/CD. - * - * Start by creating a function that runs migrations. - * - * ```ts title="sst.config.ts" - * const migrator = new sst.aws.Function("DatabaseMigrator", { - * handler: "src/migrator.handler", - * link: [rds], - * vpc, - * copyFiles: [ - * { - * from: "migrations", - * to: "./migrations", - * }, - * ], - * }); - * ``` - * - * Where `src/migrator.ts` looks like. - * - * ```ts title="src/migrator.ts" - * import { db } from "./drizzle"; - * import { migrate } from "drizzle-orm/postgres-js/migrator"; - * - * export const handler = async (event: any) => { - * await migrate(db, { - * migrationsFolder: "./migrations", - * }); - * }; - * ``` - * - * And we can set it up to run on every deploy. - * - * ```ts title="sst.config.ts" - * if (!$dev){ - * new aws.lambda.Invocation("DatabaseMigratorInvocation", { - * input: Date.now().toString(), - * functionName: migrator.name, - * }); - * } - * ``` - * - * We use the current time to make sure the function runs on every deploy. - */ -export default $config({ - app(input) { - return { - name: "aws-drizzle-migrations", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true, nat: "ec2" }); - const rds = new sst.aws.Postgres("MyPostgres", { vpc, proxy: true }); - - new sst.aws.Function("MyApi", { - vpc, - url: true, - link: [rds], - handler: "src/api.handler", - }); - - const migrator = new sst.aws.Function("DatabaseMigrator", { - handler: "src/migrator.handler", - link: [rds], - vpc, - copyFiles: [ - { - from: "migrations", - to: "./migrations", - }, - ], - }); - - if (!$dev) { - new aws.lambda.Invocation("DatabaseMigratorInvocation", { - input: Date.now().toString(), - functionName: migrator.name, - }); - } - - new sst.x.DevCommand("Studio", { - link: [rds], - dev: { - command: "npx drizzle-kit studio", - }, - }); - }, -}); diff --git a/examples/aws-drizzle-migrations/tsconfig.json b/examples/aws-drizzle-migrations/tsconfig.json deleted file mode 100644 index aee0ec940f..0000000000 --- a/examples/aws-drizzle-migrations/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strict": true - } -} diff --git a/examples/aws-drizzle/.gitignore b/examples/aws-drizzle/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-drizzle/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-drizzle/drizzle.config.ts b/examples/aws-drizzle/drizzle.config.ts deleted file mode 100644 index 373785baed..0000000000 --- a/examples/aws-drizzle/drizzle.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Resource } from "sst"; -import { defineConfig } from "drizzle-kit"; - -export default defineConfig({ - dialect: "postgresql", - // Pick up all our schema files - schema: ["./src/**/*.sql.ts"], - out: "./migrations", - dbCredentials: { - ssl: { - rejectUnauthorized: false, - }, - host: Resource.MyPostgres.host, - port: Resource.MyPostgres.port, - user: Resource.MyPostgres.username, - password: Resource.MyPostgres.password, - database: Resource.MyPostgres.database, - }, -}); diff --git a/examples/aws-drizzle/migrations/0000_lethal_justin_hammer.sql b/examples/aws-drizzle/migrations/0000_lethal_justin_hammer.sql deleted file mode 100644 index db52d6f17f..0000000000 --- a/examples/aws-drizzle/migrations/0000_lethal_justin_hammer.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE IF NOT EXISTS "todo" ( - "id" serial PRIMARY KEY NOT NULL, - "title" text NOT NULL, - "description" text -); diff --git a/examples/aws-drizzle/migrations/meta/0000_snapshot.json b/examples/aws-drizzle/migrations/meta/0000_snapshot.json deleted file mode 100644 index 816f447c30..0000000000 --- a/examples/aws-drizzle/migrations/meta/0000_snapshot.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "id": "89cd0e0e-59a6-42ec-a876-c44671efc130", - "prevId": "00000000-0000-0000-0000-000000000000", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.todo": { - "name": "todo", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/examples/aws-drizzle/migrations/meta/_journal.json b/examples/aws-drizzle/migrations/meta/_journal.json deleted file mode 100644 index d1f9a2ea91..0000000000 --- a/examples/aws-drizzle/migrations/meta/_journal.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "version": "7", - "dialect": "postgresql", - "entries": [ - { - "idx": 0, - "version": "7", - "when": 1729181504948, - "tag": "0000_lethal_justin_hammer", - "breakpoints": true - } - ] -} \ No newline at end of file diff --git a/examples/aws-drizzle/package.json b/examples/aws-drizzle/package.json deleted file mode 100644 index fde9d0b941..0000000000 --- a/examples/aws-drizzle/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-drizzle", - "version": "0.0.0", - "type": "module", - "scripts": { - "db": "sst shell drizzle-kit" - }, - "dependencies": { - "@types/aws-lambda": "^8.10.142", - "@types/pg": "^8.11.10", - "drizzle-kit": "^0.26.2", - "drizzle-orm": "^0.35.1", - "pg": "^8.13.0", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-drizzle/src/api.ts b/examples/aws-drizzle/src/api.ts deleted file mode 100644 index 1cfb345fc0..0000000000 --- a/examples/aws-drizzle/src/api.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { db } from "./drizzle"; -import { todo } from "./todo.sql"; -import { APIGatewayProxyEventV2 } from "aws-lambda"; - -export const handler = async (evt: APIGatewayProxyEventV2) => { - if (evt.requestContext.http.method === "GET") { - const result = await db.select().from(todo).execute(); - - return { - statusCode: 200, - body: JSON.stringify(result, null, 2), - }; - } - - if (evt.requestContext.http.method === "POST") { - const result = await db - .insert(todo) - .values({ title: "Todo", description: crypto.randomUUID() }) - .returning() - .execute(); - - return { - statusCode: 200, - body: JSON.stringify(result), - }; - } -}; diff --git a/examples/aws-drizzle/src/drizzle.ts b/examples/aws-drizzle/src/drizzle.ts deleted file mode 100644 index c556a2c74a..0000000000 --- a/examples/aws-drizzle/src/drizzle.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { drizzle } from "drizzle-orm/node-postgres"; -import { Pool } from "pg"; -import { Resource } from "sst"; -import * as schema from "./todo.sql"; - -const pool = new Pool({ - host: Resource.MyPostgres.host, - port: Resource.MyPostgres.port, - user: Resource.MyPostgres.username, - password: Resource.MyPostgres.password, - database: Resource.MyPostgres.database, -}); - -export const db = drizzle(pool, { schema }); diff --git a/examples/aws-drizzle/src/scrap.ts b/examples/aws-drizzle/src/scrap.ts deleted file mode 100644 index ab59ad1118..0000000000 --- a/examples/aws-drizzle/src/scrap.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { eq } from "drizzle-orm"; -import { db } from "./drizzle"; -import { user } from "./todo.sql"; - -const uuid = "d997d46d-5769-4c78-9a35-93acadbe6076"; -await db.query.user.findMany({ - where: eq(user.id, uuid), - with: { - todos: { - with: { - todo: true, - }, - }, - }, -}); diff --git a/examples/aws-drizzle/src/todo.sql.ts b/examples/aws-drizzle/src/todo.sql.ts deleted file mode 100644 index 593829b61b..0000000000 --- a/examples/aws-drizzle/src/todo.sql.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { text, serial, pgTable } from "drizzle-orm/pg-core"; - -export const todo = pgTable("todo", { - id: serial("id").primaryKey(), - title: text("title").notNull(), - description: text("description"), -}); diff --git a/examples/aws-drizzle/sst.config.ts b/examples/aws-drizzle/sst.config.ts deleted file mode 100644 index cc3b885b7c..0000000000 --- a/examples/aws-drizzle/sst.config.ts +++ /dev/null @@ -1,29 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-drizzle", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true, nat: "ec2" }); - const rds = new sst.aws.Postgres("MyPostgres", { vpc, proxy: true }); - - new sst.aws.Function("MyApi", { - vpc, - url: true, - link: [rds], - handler: "src/api.handler", - }); - - new sst.x.DevCommand("Studio", { - link: [rds], - dev: { - command: "npx drizzle-kit studio", - }, - }); - }, -}); diff --git a/examples/aws-drizzle/tsconfig.json b/examples/aws-drizzle/tsconfig.json deleted file mode 100644 index aee0ec940f..0000000000 --- a/examples/aws-drizzle/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strict": true - } -} diff --git a/examples/aws-dsql-drizzle/.gitignore b/examples/aws-dsql-drizzle/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-dsql-drizzle/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-dsql-drizzle/drizzle.config.ts b/examples/aws-dsql-drizzle/drizzle.config.ts deleted file mode 100644 index ba08a3f2c4..0000000000 --- a/examples/aws-dsql-drizzle/drizzle.config.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Resource } from "sst"; -import { defineConfig } from "drizzle-kit"; - -export default defineConfig({ - dialect: "postgresql", - schema: ["./src/**/*.sql.ts"], - out: "./migrations", - dbCredentials: { - host: Resource.MyCluster.endpoint, - port: 5432, - user: "admin", - password: process.env.DSQL_TOKEN!, - database: "postgres", - ssl: { - rejectUnauthorized: false, - }, - }, -}); diff --git a/examples/aws-dsql-drizzle/package.json b/examples/aws-dsql-drizzle/package.json deleted file mode 100644 index 6b24eb27a5..0000000000 --- a/examples/aws-dsql-drizzle/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "aws-dsql-drizzle", - "version": "0.0.0", - "type": "module", - "scripts": { - "db": "sst shell drizzle-kit" - }, - "dependencies": { - "@aws-sdk/credential-providers": "^3.844.0", - "@aws-sdk/dsql-signer": "^3.844.0", - "@aws/aurora-dsql-node-postgres-connector": "^0.1.8", - "@types/aws-lambda": "^8.10.142", - "@types/pg": "^8.11.10", - "drizzle-kit": "^0.26.2", - "drizzle-orm": "^0.35.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-dsql-drizzle/push.ts b/examples/aws-dsql-drizzle/push.ts deleted file mode 100644 index 8481e544ad..0000000000 --- a/examples/aws-dsql-drizzle/push.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { DsqlSigner } from "@aws-sdk/dsql-signer"; -import { Resource } from "sst"; -import { execSync } from "child_process"; - -const signer = new DsqlSigner({ - region: Resource.MyCluster.region, - hostname: Resource.MyCluster.endpoint, -}); - -const token = await signer.getDbConnectAdminAuthToken(); - -execSync("bunx drizzle-kit push", { - stdio: "inherit", - env: { - ...process.env, - DSQL_TOKEN: token, - }, -}); diff --git a/examples/aws-dsql-drizzle/src/api.ts b/examples/aws-dsql-drizzle/src/api.ts deleted file mode 100644 index 1cfb345fc0..0000000000 --- a/examples/aws-dsql-drizzle/src/api.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { db } from "./drizzle"; -import { todo } from "./todo.sql"; -import { APIGatewayProxyEventV2 } from "aws-lambda"; - -export const handler = async (evt: APIGatewayProxyEventV2) => { - if (evt.requestContext.http.method === "GET") { - const result = await db.select().from(todo).execute(); - - return { - statusCode: 200, - body: JSON.stringify(result, null, 2), - }; - } - - if (evt.requestContext.http.method === "POST") { - const result = await db - .insert(todo) - .values({ title: "Todo", description: crypto.randomUUID() }) - .returning() - .execute(); - - return { - statusCode: 200, - body: JSON.stringify(result), - }; - } -}; diff --git a/examples/aws-dsql-drizzle/src/drizzle.ts b/examples/aws-dsql-drizzle/src/drizzle.ts deleted file mode 100644 index 705e8e91e7..0000000000 --- a/examples/aws-dsql-drizzle/src/drizzle.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { drizzle } from "drizzle-orm/node-postgres"; -import { AuroraDSQLPool } from "@aws/aurora-dsql-node-postgres-connector"; -import { Resource } from "sst"; -import * as schema from "./todo.sql"; - -const pool = new AuroraDSQLPool({ - host: Resource.MyCluster.endpoint, - user: "admin", -}); - -export const db = drizzle(pool, { schema }); diff --git a/examples/aws-dsql-drizzle/src/todo.sql.ts b/examples/aws-dsql-drizzle/src/todo.sql.ts deleted file mode 100644 index b04e165a5c..0000000000 --- a/examples/aws-dsql-drizzle/src/todo.sql.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { text, bigint, pgTable } from "drizzle-orm/pg-core"; - -export const todo = pgTable("todo", { - id: bigint("id", { mode: "number" }).primaryKey().generatedAlwaysAsIdentity(), - title: text("title").notNull(), - description: text("description"), -}); diff --git a/examples/aws-dsql-drizzle/sst.config.ts b/examples/aws-dsql-drizzle/sst.config.ts deleted file mode 100644 index 4edaefc62a..0000000000 --- a/examples/aws-dsql-drizzle/sst.config.ts +++ /dev/null @@ -1,66 +0,0 @@ -/// - -/** - * ## AWS Aurora DSQL with Drizzle - * - * In this example, we use Drizzle ORM with an Aurora DSQL cluster. - * - * ```ts title="sst.config.ts" - * const cluster = new sst.aws.Dsql("MyCluster"); - * ``` - * - * And link it to a Lambda function. - * - * ```ts title="sst.config.ts" {4} - * new sst.aws.Function("MyApi", { - * handler: "src/api.handler", - * link: [cluster], - * url: true, - * }); - * ``` - * - * Push the Drizzle schema to the database. - * - * ```bash - * sst shell -- bun run push.ts - * ``` - * - * Now in the function we can connect to the cluster using Drizzle with the DSQL connector. - * Learn more about [DSQL Node.js connectors](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/SECTION_Node-js-connectors.html). - * - * ```ts title="src/drizzle.ts" - * import { drizzle } from "drizzle-orm/node-postgres"; - * import { AuroraDSQLPool } from "@aws/aurora-dsql-node-postgres-connector"; - * import { Resource } from "sst"; - * - * const pool = new AuroraDSQLPool({ - * host: Resource.MyCluster.endpoint, - * user: "admin", - * }); - * - * export const db = drizzle(pool, { schema }); - * ``` - */ -export default $config({ - app(input) { - return { - name: "aws-dsql-drizzle", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const cluster = new sst.aws.Dsql("MyCluster"); - - new sst.aws.Function("MyApi", { - handler: "src/api.handler", - link: [cluster], - url: true, - }); - - return { - endpoint: cluster.endpoint, - region: cluster.region, - }; - }, -}); diff --git a/examples/aws-dsql-drizzle/tsconfig.json b/examples/aws-dsql-drizzle/tsconfig.json deleted file mode 100644 index aee0ec940f..0000000000 --- a/examples/aws-dsql-drizzle/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strict": true - } -} diff --git a/examples/aws-dsql-multiregion/.gitignore b/examples/aws-dsql-multiregion/.gitignore deleted file mode 100644 index 2060062401..0000000000 --- a/examples/aws-dsql-multiregion/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# sst -.sst -bun.lock \ No newline at end of file diff --git a/examples/aws-dsql-multiregion/lambda.ts b/examples/aws-dsql-multiregion/lambda.ts deleted file mode 100644 index 28e5441dd8..0000000000 --- a/examples/aws-dsql-multiregion/lambda.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { AuroraDSQLClient } from "@aws/aurora-dsql-node-postgres-connector"; -import { Resource } from "sst"; - -async function connectToCluster(endpoint: string) { - const client = new AuroraDSQLClient({ - host: endpoint, - user: "admin", - }); - - await client.connect(); - const result = await client.query("SELECT NOW() as now"); - await client.end(); - - return result.rows[0].now; -} - -export const handler = async () => { - try { - const usEast1Time = await connectToCluster(Resource.MultiRegion.endpoint); - - const usEast2Time = await connectToCluster(Resource.MultiRegion.peer.endpoint); - - return { - statusCode: 200, - body: JSON.stringify({ - message: "Successfully connected to both DSQL clusters.", - usEast1Time, - usEast2Time, - }), - }; - } catch (error) { - console.error("Error accessing DSQL clusters:", error); - return { - statusCode: 500, - body: JSON.stringify({ - error: "Failed to access DSQL clusters", - details: error instanceof Error ? error.message : String(error), - }), - }; - } -}; diff --git a/examples/aws-dsql-multiregion/package.json b/examples/aws-dsql-multiregion/package.json deleted file mode 100644 index ad0e8cdc63..0000000000 --- a/examples/aws-dsql-multiregion/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-dsql-multiregion", - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "sst dev", - "deploy": "sst deploy", - "remove": "sst remove" - }, - "dependencies": { - "@aws-sdk/credential-providers": "^3.844.0", - "@aws/aurora-dsql-node-postgres-connector": "^0.1.8", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "^8.10.133", - "@types/pg": "^8.10.9" - } -} diff --git a/examples/aws-dsql-multiregion/sst.config.ts b/examples/aws-dsql-multiregion/sst.config.ts deleted file mode 100644 index 8d09ff4867..0000000000 --- a/examples/aws-dsql-multiregion/sst.config.ts +++ /dev/null @@ -1,82 +0,0 @@ -/// - -/** - * ## AWS Aurora DSQL Multi-Region - * - * In this example, we deploy a multi-region Aurora DSQL cluster and connect to both - * clusters from a Lambda function. - * - * :::note - * Multi-region with VPCs is not currently supported. - * ::: - * - * Create the cluster with a witness region and a peer region. The witness must differ - * from both cluster regions. - * - * ```ts title="sst.config.ts" - * const cluster = new sst.aws.Dsql("MultiRegion", { - * regions: { - * witness: "us-west-2", - * peer: "us-east-2", - * }, - * }); - * ``` - * - * Connect to both clusters from your function using the DSQL connector. - * Learn more about [DSQL Node.js connectors](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/SECTION_Node-js-connectors.html). - * - * ```ts title="lambda.ts" - * import { AuroraDSQLClient } from "@aws/aurora-dsql-node-postgres-connector"; - * import { Resource } from "sst"; - * - * async function connectToCluster(endpoint: string) { - * const client = new AuroraDSQLClient({ host: endpoint, user: "admin" }); - * await client.connect(); - * return client; - * } - * - * // Cluster in us-east-1 - * const usEast1 = await connectToCluster(Resource.MultiRegion.endpoint); - * - * // Cluster in us-east-2 - * const usEast2 = await connectToCluster(Resource.MultiRegion.peer.endpoint); - * ``` - */ - -export default $config({ - app(input) { - return { - name: "aws-dsql-multiregion", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - providers: { - aws: { region: "us-east-1" }, - }, - }; - }, - async run() { - const cluster = new sst.aws.Dsql("MultiRegion", { - backup: true, - regions: { - witness: "us-west-2", - peer: "us-east-2", - }, - }); - - const fn = new sst.aws.Function("MyFunction", { - handler: "lambda.handler", - link: [cluster], - url: true, - }); - - return { - url: fn.url, - arn: cluster.arn, - endpoint: cluster.endpoint, - region: cluster.region, - peerArn: cluster.peer.arn, - peerEndpoint: cluster.peer.endpoint, - peerRegion: cluster.peer.region, - }; - }, -}); diff --git a/examples/aws-dsql-vpc/.gitignore b/examples/aws-dsql-vpc/.gitignore deleted file mode 100644 index 2060062401..0000000000 --- a/examples/aws-dsql-vpc/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# sst -.sst -bun.lock \ No newline at end of file diff --git a/examples/aws-dsql-vpc/lambda.ts b/examples/aws-dsql-vpc/lambda.ts deleted file mode 100644 index 6c8c676be8..0000000000 --- a/examples/aws-dsql-vpc/lambda.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { AuroraDSQLClient } from "@aws/aurora-dsql-node-postgres-connector"; -import { Resource } from "sst"; - -export const handler = async () => { - try { - const client = new AuroraDSQLClient({ - host: Resource.MyCluster.endpoint, - user: "admin", - }); - - await client.connect(); - const now = await client.query("SELECT NOW() as now"); - await client.end(); - - return { - statusCode: 200, - body: JSON.stringify({ - message: "Successfully connected to DSQL cluster.", - now: now.rows[0].now, - }), - }; - } catch (error) { - console.error("Error accessing DSQL cluster:", error); - return { - statusCode: 500, - body: JSON.stringify({ - error: "Failed to access DSQL cluster", - details: error instanceof Error ? error.message : String(error), - }), - }; - } -}; diff --git a/examples/aws-dsql-vpc/package.json b/examples/aws-dsql-vpc/package.json deleted file mode 100644 index fe05e2ec1b..0000000000 --- a/examples/aws-dsql-vpc/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-dsql-vpc", - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "sst dev", - "deploy": "sst deploy", - "remove": "sst remove" - }, - "dependencies": { - "@aws-sdk/credential-providers": "^3.844.0", - "@aws/aurora-dsql-node-postgres-connector": "^0.1.8", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "^8.10.133", - "@types/pg": "^8.10.9" - } -} diff --git a/examples/aws-dsql-vpc/sst.config.ts b/examples/aws-dsql-vpc/sst.config.ts deleted file mode 100644 index 390c868187..0000000000 --- a/examples/aws-dsql-vpc/sst.config.ts +++ /dev/null @@ -1,84 +0,0 @@ -/// - -/** - * ## AWS Aurora DSQL in a VPC - * - * In this example, we connect to an Aurora DSQL cluster privately from a Lambda - * function using VPC endpoints, without routing traffic over the public internet. - * - * Create a VPC, then create the cluster with a connection endpoint inside it. - * - * ```ts title="sst.config.ts" - * const vpc = new sst.aws.Vpc("MyVpc"); - * - * const cluster = new sst.aws.Dsql("MyCluster", { - * vpc: { - * instance: vpc, - * endpoints: { connection: true }, - * }, - * }); - * ``` - * - * Link the cluster to a function that's also in the VPC. The linked `endpoint` will - * automatically resolve to the private VPC endpoint hostname instead of the public one. - * - * ```ts title="sst.config.ts" - * new sst.aws.Function("MyFunction", { - * handler: "lambda.handler", - * vpc, - * link: [cluster], - * }); - * ``` - * - * Connect from your function using the DSQL connector — no config changes needed. - * Learn more about [DSQL Node.js connectors](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/SECTION_Node-js-connectors.html). - * - * ```ts title="lambda.ts" - * import { AuroraDSQLClient } from "@aws/aurora-dsql-node-postgres-connector"; - * import { Resource } from "sst"; - * - * const client = new AuroraDSQLClient({ - * host: Resource.MyCluster.endpoint, - * user: "admin", - * }); - * - * await client.connect(); - * const result = await client.query("SELECT NOW()"); - * await client.end(); - * ``` - */ - -export default $config({ - app(input) { - return { - name: "aws-dsql-vpc", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("singleClusterVpc"); - - const cluster = new sst.aws.Dsql("MyCluster", { - vpc: { - instance: vpc, - endpoints: { - connection: true, - management: false, - }, - }, - }); - - const fn = new sst.aws.Function("MyFunction", { - handler: "lambda.handler", - vpc, - link: [cluster], - url: true, - }); - - return { - endpoint: cluster.endpoint, - region: cluster.region, - }; - }, -}); diff --git a/examples/aws-dsql/.gitignore b/examples/aws-dsql/.gitignore deleted file mode 100644 index 2060062401..0000000000 --- a/examples/aws-dsql/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# sst -.sst -bun.lock \ No newline at end of file diff --git a/examples/aws-dsql/lambda.ts b/examples/aws-dsql/lambda.ts deleted file mode 100644 index 6c8c676be8..0000000000 --- a/examples/aws-dsql/lambda.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { AuroraDSQLClient } from "@aws/aurora-dsql-node-postgres-connector"; -import { Resource } from "sst"; - -export const handler = async () => { - try { - const client = new AuroraDSQLClient({ - host: Resource.MyCluster.endpoint, - user: "admin", - }); - - await client.connect(); - const now = await client.query("SELECT NOW() as now"); - await client.end(); - - return { - statusCode: 200, - body: JSON.stringify({ - message: "Successfully connected to DSQL cluster.", - now: now.rows[0].now, - }), - }; - } catch (error) { - console.error("Error accessing DSQL cluster:", error); - return { - statusCode: 500, - body: JSON.stringify({ - error: "Failed to access DSQL cluster", - details: error instanceof Error ? error.message : String(error), - }), - }; - } -}; diff --git a/examples/aws-dsql/package.json b/examples/aws-dsql/package.json deleted file mode 100644 index 3038223d17..0000000000 --- a/examples/aws-dsql/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-dsql", - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "sst dev", - "deploy": "sst deploy", - "remove": "sst remove" - }, - "dependencies": { - "@aws-sdk/credential-providers": "^3.844.0", - "@aws/aurora-dsql-node-postgres-connector": "^0.1.8", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "^8.10.133", - "@types/pg": "^8.10.9" - } -} diff --git a/examples/aws-dsql/sst.config.ts b/examples/aws-dsql/sst.config.ts deleted file mode 100644 index cc3477e4f3..0000000000 --- a/examples/aws-dsql/sst.config.ts +++ /dev/null @@ -1,62 +0,0 @@ -/// - -/** - * ## AWS Aurora DSQL - * - * In this example, we deploy an Aurora DSQL cluster. - * - * ```ts title="sst.config.ts" - * const cluster = new sst.aws.Dsql("MyCluster"); - * ``` - * - * And link it to a Lambda function. - * - * ```ts title="sst.config.ts" {4} - * new sst.aws.Function("MyFunction", { - * handler: "lambda.handler", - * link: [cluster], - * url: true, - * }); - * ``` - * - * Now in the function we can connect to the cluster using the DSQL connector. - * Learn more about [DSQL Node.js connectors](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/SECTION_Node-js-connectors.html). - * - * ```ts title="lambda.ts" - * import { AuroraDSQLClient } from "@aws/aurora-dsql-node-postgres-connector"; - * import { Resource } from "sst"; - * - * const client = new AuroraDSQLClient({ - * host: Resource.MyCluster.endpoint, - * user: "admin", - * }); - * - * await client.connect(); - * const result = await client.query("SELECT NOW()"); - * await client.end(); - * ``` - */ - -export default $config({ - app(input) { - return { - name: "aws-dsql", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const cluster = new sst.aws.Dsql("MyCluster", {}); - - const fn = new sst.aws.Function("MyFunction", { - handler: "lambda.handler", - link: [cluster], - url: true, - }); - - return { - endpoint: cluster.endpoint, - region: cluster.region, - }; - }, -}); \ No newline at end of file diff --git a/examples/aws-dynamo-composite-keys/creator.ts b/examples/aws-dynamo-composite-keys/creator.ts deleted file mode 100644 index 4a9365b223..0000000000 --- a/examples/aws-dynamo-composite-keys/creator.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Resource } from "sst"; -import { DynamoDBClient, PutItemCommand } from "@aws-sdk/client-dynamodb"; -const client = new DynamoDBClient(); - -export const handler = async () => { - await client.send( - new PutItemCommand({ - TableName: Resource.MyTable.name, - Item: { - userId: { S: "user1" }, - noteId: { S: Date.now().toString() }, - region: { S: "us-east" }, - category: { S: "notes" }, - createdAt: { N: Date.now().toString() }, - }, - }) - ); - - return { - statusCode: 200, - body: JSON.stringify({ status: "sent" }, null, 2), - }; -}; diff --git a/examples/aws-dynamo-composite-keys/package.json b/examples/aws-dynamo-composite-keys/package.json deleted file mode 100644 index 1269793242..0000000000 --- a/examples/aws-dynamo-composite-keys/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aws-dynamo-composite-keys", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "deploy": "go run ../../cmd/sst deploy", - "remove": "go run ../../cmd/sst remove", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "sst": "file:../../sdk/js" - }, - "dependencies": { - "@aws-sdk/client-dynamodb": "^3.515.0" - } -} diff --git a/examples/aws-dynamo-composite-keys/reader.ts b/examples/aws-dynamo-composite-keys/reader.ts deleted file mode 100644 index dfb2b1527b..0000000000 --- a/examples/aws-dynamo-composite-keys/reader.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Resource } from "sst"; -import { DynamoDBClient, QueryCommand } from "@aws-sdk/client-dynamodb"; -const client = new DynamoDBClient(); - -export const handler = async () => { - const result = await client.send( - new QueryCommand({ - TableName: Resource.MyTable.name, - IndexName: "RegionCategoryIndex", - KeyConditionExpression: "#r = :region AND #c = :category", - ExpressionAttributeNames: { - "#r": "region", - "#c": "category", - }, - ExpressionAttributeValues: { - ":region": { S: "us-east" }, - ":category": { S: "notes" }, - }, - }) - ); - - return { - statusCode: 200, - body: JSON.stringify(result.Items, null, 2), - }; -}; diff --git a/examples/aws-dynamo-composite-keys/sst.config.ts b/examples/aws-dynamo-composite-keys/sst.config.ts deleted file mode 100644 index dfea2ec245..0000000000 --- a/examples/aws-dynamo-composite-keys/sst.config.ts +++ /dev/null @@ -1,52 +0,0 @@ -/// - -/** - * ## DynamoDB composite keys - * - * Create a DynamoDB table with multi-attribute composite keys in a global secondary index. - */ -export default $config({ - app(input) { - return { - name: "aws-dynamo-composite-keys", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const table = new sst.aws.Dynamo("MyTable", { - fields: { - userId: "string", - noteId: "string", - region: "string", - category: "string", - createdAt: "number", - }, - primaryIndex: { hashKey: "userId", rangeKey: "noteId" }, - globalIndexes: { - RegionCategoryIndex: { - hashKey: ["region", "category"], - rangeKey: "createdAt", - }, - }, - }); - - const creator = new sst.aws.Function("MyCreator", { - handler: "creator.handler", - link: [table], - url: true, - }); - - const reader = new sst.aws.Function("MyReader", { - handler: "reader.handler", - link: [table], - url: true, - }); - - return { - creator: creator.url, - reader: reader.url, - table: table.name, - }; - }, -}); diff --git a/examples/aws-dynamo/creator.ts b/examples/aws-dynamo/creator.ts deleted file mode 100644 index f90ac02884..0000000000 --- a/examples/aws-dynamo/creator.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Resource } from "sst"; -import { DynamoDBClient, PutItemCommand } from "@aws-sdk/client-dynamodb"; -const client = new DynamoDBClient(); - -export const handler = async (event) => { - await client.send( - new PutItemCommand({ - TableName: Resource.MyTable.name, - Item: { - id: { S: Date.now().toString() }, - message: { S: "Hello" }, - }, - }) - ); - - return { - statusCode: 200, - body: JSON.stringify({ status: "sent" }, null, 2), - }; -}; diff --git a/examples/aws-dynamo/package.json b/examples/aws-dynamo/package.json deleted file mode 100644 index fd944c5262..0000000000 --- a/examples/aws-dynamo/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aws-dynamo", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "deploy": "go run ../../cmd/sst deploy", - "remove": "go run ../../cmd/sst remove", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "sst": "file:../../sdk/js" - }, - "dependencies": { - "@aws-sdk/client-dynamodb": "^3.515.0" - } -} diff --git a/examples/aws-dynamo/reader.ts b/examples/aws-dynamo/reader.ts deleted file mode 100644 index fd68d74ea7..0000000000 --- a/examples/aws-dynamo/reader.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Resource } from "sst"; -import { DynamoDBClient, ScanCommand } from "@aws-sdk/client-dynamodb"; -const client = new DynamoDBClient(); - -export const handler = async () => { - const result = await client.send( - new ScanCommand({ - TableName: Resource.MyTable.name, - }) - ); - - return { - statusCode: 200, - body: JSON.stringify(result.Items, null, 2), - }; -}; diff --git a/examples/aws-dynamo/sst.config.ts b/examples/aws-dynamo/sst.config.ts deleted file mode 100644 index 9d9ff5d5b2..0000000000 --- a/examples/aws-dynamo/sst.config.ts +++ /dev/null @@ -1,56 +0,0 @@ -/// - -/** - * ## DynamoDB streams - * - * Create a DynamoDB table, enable streams, and subscribe to it with a function. - */ -export default $config({ - app(input) { - return { - name: "aws-dynamo", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const table = new sst.aws.Dynamo("MyTable", { - fields: { - id: "string", - }, - primaryIndex: { hashKey: "id" }, - stream: "new-and-old-images", - }); - table.subscribe("MySubscriber", "subscriber.handler", { - filters: [ - { - dynamodb: { - NewImage: { - message: { - S: ["Hello"], - }, - }, - }, - }, - ], - }); - - const creator = new sst.aws.Function("MyCreator", { - handler: "creator.handler", - link: [table], - url: true, - }); - - const reader = new sst.aws.Function("MyReader", { - handler: "reader.handler", - link: [table], - url: true, - }); - - return { - creator: creator.url, - reader: reader.url, - table: table.name, - }; - }, -}); diff --git a/examples/aws-dynamo/subscriber.ts b/examples/aws-dynamo/subscriber.ts deleted file mode 100644 index 342cf63a05..0000000000 --- a/examples/aws-dynamo/subscriber.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const handler = async (event) => { - console.log(JSON.stringify(event, null, 2)); - return "ok"; -}; diff --git a/examples/aws-ec2-pulumi/package.json b/examples/aws-ec2-pulumi/package.json deleted file mode 100644 index b4ad3bd51e..0000000000 --- a/examples/aws-ec2-pulumi/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "aws-ec2-pulumi", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "deploy": "go run ../../cmd/sst deploy", - "remove": "go run ../../cmd/sst remove", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "sst": "file:../../sdk/js" - }, - "dependencies": { - } -} diff --git a/examples/aws-ec2-pulumi/sst.config.ts b/examples/aws-ec2-pulumi/sst.config.ts deleted file mode 100644 index 0987879b00..0000000000 --- a/examples/aws-ec2-pulumi/sst.config.ts +++ /dev/null @@ -1,59 +0,0 @@ -/// - -/** - * ## EC2 with Pulumi - * - * Use raw Pulumi resources to create an EC2 instance. - */ -export default $config({ - app(input) { - return { - name: "aws-ec2-pulumi", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - // Notice you don't need to import pulumi, it is already part of sst. - const securityGroup = new aws.ec2.SecurityGroup("web-secgrp", { - ingress: [ - { - protocol: "tcp", - fromPort: 80, - toPort: 80, - cidrBlocks: ["0.0.0.0/0"], - }, - ], - }); - - // Find the latest Ubuntu AMI - const ami = aws.ec2.getAmi({ - filters: [ - { - name: "name", - values: ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"], - }, - ], - mostRecent: true, - owners: ["099720109477"], // Canonical - }); - - // User data to set up a simple web server - const userData = `#!/bin/bash - echo "Hello, World!" > index.html - nohup python3 -m http.server 80 &`; - - // Create an EC2 instance - const server = new aws.ec2.Instance("web-server", { - instanceType: "t2.micro", - ami: ami.then((ami) => ami.id), - userData: userData, - vpcSecurityGroupIds: [securityGroup.id], - associatePublicIpAddress: true, - }); - - return { - app: server.publicIp, - }; - }, -}); diff --git a/examples/aws-efs-sqlite/.gitignore b/examples/aws-efs-sqlite/.gitignore deleted file mode 100644 index 9b1ee42e84..0000000000 --- a/examples/aws-efs-sqlite/.gitignore +++ /dev/null @@ -1,175 +0,0 @@ -# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore - -# Logs - -logs -_.log -npm-debug.log_ -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Caches - -.cache - -# Diagnostic reports (https://nodejs.org/api/report.html) - -report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json - -# Runtime data - -pids -_.pid -_.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover - -lib-cov - -# Coverage directory used by tools like istanbul - -coverage -*.lcov - -# nyc test coverage - -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) - -.grunt - -# Bower dependency directory (https://bower.io/) - -bower_components - -# node-waf configuration - -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) - -build/Release - -# Dependency directories - -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) - -web_modules/ - -# TypeScript cache - -*.tsbuildinfo - -# Optional npm cache directory - -.npm - -# Optional eslint cache - -.eslintcache - -# Optional stylelint cache - -.stylelintcache - -# Microbundle cache - -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history - -.node_repl_history - -# Output of 'npm pack' - -*.tgz - -# Yarn Integrity file - -.yarn-integrity - -# dotenv environment variable files - -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) - -.parcel-cache - -# Next.js build output - -.next -out - -# Nuxt.js build / generate output - -.nuxt -dist - -# Gatsby files - -# Comment in the public line in if your project uses Gatsby and not Next.js - -# https://nextjs.org/blog/next-9-1#public-directory-support - -# public - -# vuepress build output - -.vuepress/dist - -# vuepress v2.x temp and cache directory - -.temp - -# Docusaurus cache and generated files - -.docusaurus - -# Serverless directories - -.serverless/ - -# FuseBox cache - -.fusebox/ - -# DynamoDB Local files - -.dynamodb/ - -# TernJS port file - -.tern-port - -# Stores VSCode versions used for testing VSCode extensions - -.vscode-test - -# yarn v2 - -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* - -# IntelliJ based IDEs -.idea - -# Finder (MacOS) folder config -.DS_Store diff --git a/examples/aws-efs-sqlite/index.ts b/examples/aws-efs-sqlite/index.ts deleted file mode 100644 index f407e5a1fd..0000000000 --- a/examples/aws-efs-sqlite/index.ts +++ /dev/null @@ -1,24 +0,0 @@ -import sqlite3 from "better-sqlite3"; -const db = sqlite3("/mnt/efs/mydb.sqlite"); - -export const handler = async () => { - db.exec(` - CREATE TABLE IF NOT EXISTS visits ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - timestamp TEXT NOT NULL - ); - `); - - // Record a visit - db.prepare("INSERT INTO visits (timestamp) VALUES (CURRENT_TIMESTAMP)").run(); - - // Get recent visits - const visits = db - .prepare("SELECT * FROM visits ORDER BY timestamp DESC LIMIT 10") - .all(); - - return { - statusCode: 200, - body: JSON.stringify({ "10 Most recent visits": visits }, null, 2), - }; -}; diff --git a/examples/aws-efs-sqlite/package.json b/examples/aws-efs-sqlite/package.json deleted file mode 100644 index 821d9ef6ab..0000000000 --- a/examples/aws-efs-sqlite/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-efs-sqlite", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "better-sqlite3": "^11.4.0" - } -} diff --git a/examples/aws-efs-sqlite/sst.config.ts b/examples/aws-efs-sqlite/sst.config.ts deleted file mode 100644 index ec903fa266..0000000000 --- a/examples/aws-efs-sqlite/sst.config.ts +++ /dev/null @@ -1,50 +0,0 @@ -/// - -/** - * ## AWS EFS with SQLite - * - * Mount an EFS file system to a function and write to a SQLite database. - * - * ```js title="index.ts" - * const db = sqlite3("/mnt/efs/mydb.sqlite"); - * ``` - * - * The file system is mounted to `/mnt/efs` in the function. - * - * :::note - * Given the performance of EFS, it's not recommended to use it for databases. - * ::: - * - * This example is for demonstration purposes only. It's not recommended to use - * EFS for databases in production. - */ -export default $config({ - app(input) { - return { - name: "aws-efs-sqlite", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - // NAT Gateways are required for Lambda functions - const vpc = new sst.aws.Vpc("MyVpc", { nat: "managed" }); - - // Create an EFS file system to store the SQLite database - const efs = new sst.aws.Efs("MyEfs", { vpc }); - - // Create a Lambda function that queries the database - new sst.aws.Function("MyFunction", { - vpc, - url: true, - volume: { - efs, - path: "/mnt/efs", - }, - handler: "index.handler", - nodejs: { - install: ["better-sqlite3"], - }, - }); - }, -}); diff --git a/examples/aws-efs-sqlite/tsconfig.json b/examples/aws-efs-sqlite/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-efs-sqlite/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-efs-surrealdb/.gitignore b/examples/aws-efs-surrealdb/.gitignore deleted file mode 100644 index f3c8b5fb20..0000000000 --- a/examples/aws-efs-surrealdb/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ - -# sst -.sst - -.envrc -shell.nix -pnpm-* \ No newline at end of file diff --git a/examples/aws-efs-surrealdb/index.ts b/examples/aws-efs-surrealdb/index.ts deleted file mode 100644 index fe20791598..0000000000 --- a/examples/aws-efs-surrealdb/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -import Surreal from "surrealdb"; -import { Resource } from "sst"; - -export const handler = async () => { - const endpoint = `http://${Resource.MyConfig.host}:${Resource.MyConfig.port}`; - - console.log(`Connecting to`, endpoint); - - const db = new Surreal(); - await db.connect(endpoint); - - await db.use({ - namespace: Resource.MyConfig.namespace, - database: Resource.MyConfig.database, - }); - - await db.signin({ - username: Resource.MyConfig.username, - password: Resource.MyConfig.password, - }); - - await db.query(`INSERT INTO visits { when: time::now() }`); - - const visits = await db.query( - `SELECT * FROM visits ORDER BY when DESC LIMIT 10` - ); - - return { - statusCode: 200, - body: JSON.stringify({ "10 Most recent visits": visits[0] }, null, 2), - }; -}; diff --git a/examples/aws-efs-surrealdb/package.json b/examples/aws-efs-surrealdb/package.json deleted file mode 100644 index adccacafad..0000000000 --- a/examples/aws-efs-surrealdb/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-efs-surrealdb", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "sst": "file:../../sdk/js", - "surrealdb": "^1.0.1" - } -} diff --git a/examples/aws-efs-surrealdb/sst.config.ts b/examples/aws-efs-surrealdb/sst.config.ts deleted file mode 100644 index d68d38b264..0000000000 --- a/examples/aws-efs-surrealdb/sst.config.ts +++ /dev/null @@ -1,106 +0,0 @@ -/// -/** - * ## AWS EFS with SurrealDB - * - * We use the SurrealDB docker image to run a server in a container and use EFS as the file - * system. - * - * ```ts title="sst.config.ts" - * const server = new sst.aws.Service("MyService", { - * cluster, - * architecture: "arm64", - * image: "surrealdb/surrealdb:v2.0.2", - * // ... - * volumes: [ - * { efs, path: "/data" }, - * ], - * }); - * ``` - * - * We then connect to the server from a Lambda function. - * - * ```js title="index.ts" - * const endpoint = `http://${Resource.MyConfig.host}:${Resource.MyConfig.port}`; - * - * const db = new Surreal(); - * await db.connect(endpoint); - * ``` - * - * This uses the SurrealDB client to connect to the server. - * - * :::note - * Given the performance of EFS, it's not recommended to use it for databases. - * ::: - * - * This example is for demonstration purposes only. It's not recommended to use - * EFS for databases in production. - */ -export default $config({ - app(input) { - return { - name: "aws-efs-surrealdb", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - providers: { "@pulumi/random": "4.16.7" }, - }; - }, - async run() { - const { RandomPassword } = await import("@pulumi/random"); - - // SurrealDB Credentials - const PORT = 8080; - const NAMESPACE = "test"; - const DATABASE = "test"; - const USERNAME = "root"; - const PASSWORD = new RandomPassword("Password", { - length: 32, - }).result; - - // NAT Gateways are required for Lambda functions - const vpc = new sst.aws.Vpc("MyVpc", { nat: "managed" }); - - // Store SurrealDB data in EFS - const efs = new sst.aws.Efs("MyEfs", { vpc }); - - // Run SurrealDB server in a container - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - const server = new sst.aws.Service("MyService", { - cluster, - architecture: "arm64", - image: "surrealdb/surrealdb:v2.0.2", - command: [ - "start", - "--bind", - $interpolate`0.0.0.0:${PORT}`, - "--log", - "info", - "--user", - USERNAME, - "--pass", - PASSWORD, - "surrealkv://data/data.skv", - "--allow-scripting", - ], - volumes: [{ efs, path: "/data" }], - }); - - // Lambda client to connect to SurrealDB - const config = new sst.Linkable("MyConfig", { - properties: { - username: USERNAME, - password: PASSWORD, - namespace: NAMESPACE, - database: DATABASE, - port: PORT, - host: server.service, - }, - }); - - new sst.aws.Function("MyApp", { - handler: "index.handler", - link: [config], - url: true, - vpc, - }); - }, -}); diff --git a/examples/aws-efs-surrealdb/tsconfig.json b/examples/aws-efs-surrealdb/tsconfig.json deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/examples/aws-efs-surrealdb/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/examples/aws-efs/.dockerignore b/examples/aws-efs/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-efs/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-efs/Dockerfile b/examples/aws-efs/Dockerfile deleted file mode 100644 index fdf9535d4a..0000000000 --- a/examples/aws-efs/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY service.mjs /app -COPY common.mjs /app - -ENTRYPOINT ["node", "service.mjs"] \ No newline at end of file diff --git a/examples/aws-efs/common.mjs b/examples/aws-efs/common.mjs deleted file mode 100644 index 3edae33c5e..0000000000 --- a/examples/aws-efs/common.mjs +++ /dev/null @@ -1,20 +0,0 @@ -import { readFile, writeFile } from "fs/promises"; - -export async function increment() { - // read the counter file from EFS - let oldValue = 0; - try { - oldValue = parseInt(await readFile("/mnt/efs/counter", "utf8")); - oldValue = isNaN(oldValue) ? 0 : oldValue; - } catch (e) { - // file doesn't exist - } - - // increment the counter - const newValue = oldValue + 1; - - // write the counter file to EFS - await writeFile("/mnt/efs/counter", newValue.toString()); - - return newValue; -} diff --git a/examples/aws-efs/lambda.ts b/examples/aws-efs/lambda.ts deleted file mode 100644 index a77e93aa24..0000000000 --- a/examples/aws-efs/lambda.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { increment } from "./common.mjs"; - -export const handler = async () => { - const counter = await increment(); - console.log("COUNTER", counter); - return { - statusCode: 200, - body: JSON.stringify({ - counter, - }), - }; -}; diff --git a/examples/aws-efs/package.json b/examples/aws-efs/package.json deleted file mode 100644 index 50dfa020a3..0000000000 --- a/examples/aws-efs/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "aws-efs", - "version": "1.0.0", - "description": "", - "main": "index.js", - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "express": "^4.19.2" - } -} diff --git a/examples/aws-efs/service.mjs b/examples/aws-efs/service.mjs deleted file mode 100644 index 6f8866d20d..0000000000 --- a/examples/aws-efs/service.mjs +++ /dev/null @@ -1,18 +0,0 @@ -import express from "express"; -import { increment } from "./common.mjs"; - -const PORT = 80; - -const app = express(); - -app.get("/", async (req, res) => { - res.send( - JSON.stringify({ - counter: await increment(), - }) - ); -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-efs/sst.config.ts b/examples/aws-efs/sst.config.ts deleted file mode 100644 index 352852780e..0000000000 --- a/examples/aws-efs/sst.config.ts +++ /dev/null @@ -1,58 +0,0 @@ -/// - -/** - * ## AWS EFS - * - * Mount an EFS file system to a function and a container. - * - * This allows both your function and the container to access the same file system. Here they - * both update a counter that's stored in the file system. - * - * ```js title="common.mjs" - * await writeFile("/mnt/efs/counter", newValue.toString()); - * ``` - * - * The file system is mounted to `/mnt/efs` in both the function and the container. - */ -export default $config({ - app(input) { - return { - name: "aws-efs", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - // NAT Gateways are required for Lambda functions - const vpc = new sst.aws.Vpc("MyVpc", { nat: "managed" }); - - // Create an EFS file system to store a counter - const efs = new sst.aws.Efs("MyEfs", { vpc }); - - // Create a Lambda function that increments the counter - new sst.aws.Function("MyFunction", { - handler: "lambda.handler", - url: true, - vpc, - volume: { - efs, - path: "/mnt/efs", - }, - }); - - // Create a service that increments the same counter - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http" }], - }, - volumes: [ - { - efs, - path: "/mnt/efs", - }, - ], - }); - }, -}); diff --git a/examples/aws-email/package.json b/examples/aws-email/package.json deleted file mode 100644 index c24cf0273c..0000000000 --- a/examples/aws-email/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "aws-email", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@aws-sdk/client-sesv2": "^3.515.0", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.142" - } -} diff --git a/examples/aws-email/sender.ts b/examples/aws-email/sender.ts deleted file mode 100644 index a1c2827b1c..0000000000 --- a/examples/aws-email/sender.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Resource } from "sst"; -import { SESv2Client, SendEmailCommand } from "@aws-sdk/client-sesv2"; - -const client = new SESv2Client(); - -export const handler = async () => { - await client.send( - new SendEmailCommand({ - FromEmailAddress: Resource.MyEmail.sender, - Destination: { - ToAddresses: [Resource.MyEmail.sender], - }, - Content: { - Simple: { - Subject: { - Data: "Hello World!", - }, - Body: { - Text: { - Data: "Sent from my SST app.", - }, - }, - }, - }, - }) - ); - - return { - statusCode: 200, - body: "Sent!" - }; -}; diff --git a/examples/aws-email/sst.config.ts b/examples/aws-email/sst.config.ts deleted file mode 100644 index bd9602537a..0000000000 --- a/examples/aws-email/sst.config.ts +++ /dev/null @@ -1,26 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-email", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const email = new sst.aws.Email("MyEmail", { - sender: "email@example.com", - }); - - const api = new sst.aws.Function("MyApi", { - handler: "sender.handler", - link: [email], - url: true, - }); - - return { - url: api.url, - }; - }, -}); diff --git a/examples/aws-email/tsconfig.json b/examples/aws-email/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-email/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-express-redis/.dockerignore b/examples/aws-express-redis/.dockerignore deleted file mode 100644 index ea0aaeeec9..0000000000 --- a/examples/aws-express-redis/.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-express-redis/.gitignore b/examples/aws-express-redis/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-express-redis/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-express-redis/Dockerfile b/examples/aws-express-redis/Dockerfile deleted file mode 100644 index 53718c02f4..0000000000 --- a/examples/aws-express-redis/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] diff --git a/examples/aws-express-redis/index.mjs b/examples/aws-express-redis/index.mjs deleted file mode 100644 index a951c70253..0000000000 --- a/examples/aws-express-redis/index.mjs +++ /dev/null @@ -1,28 +0,0 @@ -import express from "express"; -import { Resource } from "sst"; -import { Cluster } from "ioredis"; - -const PORT = 80; - -const app = express(); - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -app.get("/", async (req, res) => { - const counter = await redis.incr("counter"); - res.send(`Hit counter: ${counter}`); -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-express-redis/package.json b/examples/aws-express-redis/package.json deleted file mode 100644 index 376035cecd..0000000000 --- a/examples/aws-express-redis/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "aws-express-redis", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "express": "^4.21.0", - "ioredis": "^5.4.1", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145" - } -} diff --git a/examples/aws-express-redis/sst.config.ts b/examples/aws-express-redis/sst.config.ts deleted file mode 100644 index edf565f96c..0000000000 --- a/examples/aws-express-redis/sst.config.ts +++ /dev/null @@ -1,68 +0,0 @@ -/// - -/** - * ## AWS Express Redis - * - * Creates a hit counter app with Express and Redis. - * - * This deploys Express as a Fargate service to ECS and it's linked to Redis. - * - * ```ts title="sst.config.ts" {9} - * new sst.aws.Service("MyService", { - * cluster, - * loadBalancer: { - * ports: [{ listen: "80/http" }], - * }, - * dev: { - * command: "node --watch index.mjs", - * }, - * link: [redis], - * }); - * ``` - * - * Since our Redis cluster is in a VPC, we’ll need a tunnel to connect to it from our local - * machine. - * - * ```bash "sudo" - * sudo npx sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * To start your app locally run. - * - * ```bash - * npx sst dev - * ``` - * - * Now if you go to `http://localhost:80` you’ll see a counter update as you refresh the page. - * - * Finally, you can deploy it using `npx sst deploy --stage production` using a `Dockerfile` - * that's included in the example. - */ -export default $config({ - app(input) { - return { - name: "aws-express-redis", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: "80/http" }], - }, - dev: { - command: "node --watch index.mjs", - }, - }); - }, -}); diff --git a/examples/aws-express-redis/tsconfig.json b/examples/aws-express-redis/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-express-redis/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-express/.dockerignore b/examples/aws-express/.dockerignore deleted file mode 100644 index ea0aaeeec9..0000000000 --- a/examples/aws-express/.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-express/.gitignore b/examples/aws-express/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-express/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-express/Dockerfile b/examples/aws-express/Dockerfile deleted file mode 100644 index 1d16aa3311..0000000000 --- a/examples/aws-express/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:lts-alpine - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] diff --git a/examples/aws-express/index.mjs b/examples/aws-express/index.mjs deleted file mode 100644 index 507250ec18..0000000000 --- a/examples/aws-express/index.mjs +++ /dev/null @@ -1,63 +0,0 @@ -import multer from "multer"; -import express from "express"; -import { Resource } from "sst"; -import { Upload } from "@aws-sdk/lib-storage"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { - S3Client, - GetObjectCommand, - ListObjectsV2Command, -} from "@aws-sdk/client-s3"; - -const PORT = 80; - -const app = express(); -const s3 = new S3Client({}); -const upload = multer({ storage: multer.memoryStorage() }); - -app.get("/", (req, res) => { - res.send("Hello World!") -}); - -app.post("/", upload.single("file"), async (req, res) => { - const file = req.file; - const params = { - Bucket: Resource.MyBucket.name, - ContentType: file.mimetype, - Key: file.originalname, - Body: file.buffer, - }; - - const upload = new Upload({ - params, - client: s3, - }); - - await upload.done(); - - res.status(200).send("File uploaded successfully."); -}); - -app.get("/latest", async (req, res) => { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - - const latestFile = objects.Contents.sort( - (a, b) => b.LastModified - a.LastModified, - )[0]; - - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(s3, command); - - res.redirect(url); -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-express/package.json b/examples/aws-express/package.json deleted file mode 100644 index ad4e1fbccb..0000000000 --- a/examples/aws-express/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "aws-express", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@aws-sdk/client-s3": "^3.705.0", - "@aws-sdk/lib-storage": "^3.705.0", - "@aws-sdk/s3-request-presigner": "^3.705.0", - "express": "^4.21.1", - "multer": "^1.4.5-lts.1", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.146" - } -} diff --git a/examples/aws-express/sst.config.ts b/examples/aws-express/sst.config.ts deleted file mode 100644 index 1dd9704d68..0000000000 --- a/examples/aws-express/sst.config.ts +++ /dev/null @@ -1,28 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-express", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const bucket = new sst.aws.Bucket("MyBucket"); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [bucket], - loadBalancer: { - ports: [{ listen: "80/http" }], - }, - dev: { - command: "node --watch index.mjs", - }, - }); - }, -}); diff --git a/examples/aws-express/tsconfig.json b/examples/aws-express/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-express/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-fastapi/.gitignore b/examples/aws-fastapi/.gitignore deleted file mode 100644 index 17ace783f5..0000000000 --- a/examples/aws-fastapi/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.sst -.venv \ No newline at end of file diff --git a/examples/aws-fastapi/core/pyproject.toml b/examples/aws-fastapi/core/pyproject.toml deleted file mode 100644 index 4d9ed5884e..0000000000 --- a/examples/aws-fastapi/core/pyproject.toml +++ /dev/null @@ -1,11 +0,0 @@ -[project] -name = "core" -version = "0.1.0" -description = "Add your description here" -authors = [{ name = "Nick Wall", email = "mail@walln.dev" }] -requires-python = "==3.11.*" -dependencies = ["requests>=2.32.3"] - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" diff --git a/examples/aws-fastapi/core/src/core/__init__.py b/examples/aws-fastapi/core/src/core/__init__.py deleted file mode 100644 index 437615c6c1..0000000000 --- a/examples/aws-fastapi/core/src/core/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -from core.db import get_user - - -def hello() -> str: - return "Hello from core!" - - -__all__ = ["get_user", "hello"] diff --git a/examples/aws-fastapi/core/src/core/db.py b/examples/aws-fastapi/core/src/core/db.py deleted file mode 100644 index c719b87ba4..0000000000 --- a/examples/aws-fastapi/core/src/core/db.py +++ /dev/null @@ -1,5 +0,0 @@ -def get_user(user_id: str) -> dict: - return { - "user_id": user_id, - "name": "John Doe", - } diff --git a/examples/aws-fastapi/core/src/core/ping.py b/examples/aws-fastapi/core/src/core/ping.py deleted file mode 100644 index c13cfd5726..0000000000 --- a/examples/aws-fastapi/core/src/core/ping.py +++ /dev/null @@ -1,5 +0,0 @@ -import requests - - -def ping(): - return requests.get("https://api.github.com").status_code diff --git a/examples/aws-fastapi/functions/pyproject.toml b/examples/aws-fastapi/functions/pyproject.toml deleted file mode 100644 index ac5a78c4b8..0000000000 --- a/examples/aws-fastapi/functions/pyproject.toml +++ /dev/null @@ -1,14 +0,0 @@ -[project] -name = "functions" -version = "0.1.0" -description = "Lambda function handlers" -dependencies = ["core", "sst-sdk", "fastapi==0.115.8", "mangum==0.19.0"] -requires-python = "==3.11.*" - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" - -[tool.uv.sources] -core = { workspace = true } -sst-sdk = { git = "https://github.com/anomalyco/sst.git", branch = "dev", subdirectory = "sdk/python" } diff --git a/examples/aws-fastapi/functions/src/functions/__init__.py b/examples/aws-fastapi/functions/src/functions/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-fastapi/functions/src/functions/api.py b/examples/aws-fastapi/functions/src/functions/api.py deleted file mode 100644 index 56fb5c8fe7..0000000000 --- a/examples/aws-fastapi/functions/src/functions/api.py +++ /dev/null @@ -1,39 +0,0 @@ -from fastapi import FastAPI -from mangum import Mangum -from sst import Resource -from functions.shared import foo -from core.db import get_user -from core.ping import ping - -# Create FastAPI app with JSON configuration -app = FastAPI( - title="SST FastAPI App", - json_encoder=None # Use FastAPI's default JSON encoder -) - -# Create a route -@app.get("/") -async def root(): - print("Function invoked from Python") - - # Share code within the same workspace package - result = foo() - print(result) - - # Share code between workspace packages - res = ping() - user = get_user("1234") - print(user) - print("Ping result:", res) - - # Use the SST SDK to access resources - resource_value = Resource.MyLinkableValue.foo - print(f"Resource.MyLinkableValue.foo: {resource_value}") - - return { - "message": f"{resource_value} from Python!", - - } - -# Create handler for AWS Lambda with specific configuration -handler = Mangum(app, api_gateway_base_path=None, lifespan="off") diff --git a/examples/aws-fastapi/functions/src/functions/shared.py b/examples/aws-fastapi/functions/src/functions/shared.py deleted file mode 100644 index 1f022956c6..0000000000 --- a/examples/aws-fastapi/functions/src/functions/shared.py +++ /dev/null @@ -1,2 +0,0 @@ -def foo(): - return "bar" diff --git a/examples/aws-fastapi/package.json b/examples/aws-fastapi/package.json deleted file mode 100644 index ff07a387c7..0000000000 --- a/examples/aws-fastapi/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-fastapi", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-fastapi/pyproject.toml b/examples/aws-fastapi/pyproject.toml deleted file mode 100644 index c7a1678eeb..0000000000 --- a/examples/aws-fastapi/pyproject.toml +++ /dev/null @@ -1,16 +0,0 @@ -[project] -name = "aws-fastapi" -version = "0.1.0" -description = "A SST app" -authors = [{ name = "Nick Wall", email = "mail@walln.dev" }] -dependencies = [] - -# It is recommended to specify your python version to match your Lambda runtime otherwise you may -# encounter issues with dependencies. -requires-python = "==3.11.*" - -[tool.uv.workspace] -members = ["functions", "core"] - -[tool.uv.sources] -sst-sdk = { git = "https://github.com/anomalyco/sst.git", subdirectory = "sdk/python", branch = "dev" } diff --git a/examples/aws-fastapi/sst.config.ts b/examples/aws-fastapi/sst.config.ts deleted file mode 100644 index 4624a75bff..0000000000 --- a/examples/aws-fastapi/sst.config.ts +++ /dev/null @@ -1,37 +0,0 @@ -/// - -/** - * ## FastAPI - * - * Deploy a Python FastAPI app as a Lambda function with a linked value. - */ -export default $config({ - app(input) { - return { - name: "aws-fastapi", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - providers: { - aws: true, - }, - }; - }, - async run() { - const linkableValue = new sst.Linkable("MyLinkableValue", { - properties: { - foo: "Hello World", - }, - }); - - const fastapi = new sst.aws.Function("FastAPI", { - handler: "functions/src/functions/api.handler", - runtime: "python3.11", - url: true, - link: [linkableValue], - }); - - return { - fastapi: fastapi.url, - }; - }, -}); diff --git a/examples/aws-fastapi/tsconfig.json b/examples/aws-fastapi/tsconfig.json deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/examples/aws-fastapi/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/examples/aws-ffmpeg/.gitignore b/examples/aws-ffmpeg/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-ffmpeg/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-ffmpeg/clip.mp4 b/examples/aws-ffmpeg/clip.mp4 deleted file mode 100644 index 9efdbf0110..0000000000 Binary files a/examples/aws-ffmpeg/clip.mp4 and /dev/null differ diff --git a/examples/aws-ffmpeg/index.ts b/examples/aws-ffmpeg/index.ts deleted file mode 100644 index f0be094605..0000000000 --- a/examples/aws-ffmpeg/index.ts +++ /dev/null @@ -1,40 +0,0 @@ -import path from "path"; -import ffmpeg from "ffmpeg-static"; -import { promises as fs } from "fs"; -import { spawnSync } from "child_process"; - -export async function handler() { - const videoPath = "clip.mp4"; - - const outputFile = "thumbnail.jpg"; - const outputPath = process.env.SST_DEV - ? outputFile - : path.join("/tmp", outputFile); - - const ffmpegParams = [ - "-ss", - "1", - "-i", - videoPath, - "-vf", - "thumbnail,scale=960:540", - "-vframes", - "1", - outputPath, - ]; - - spawnSync(ffmpeg, ffmpegParams, { stdio: "pipe" }); - - const img = await fs.readFile(outputPath); - const body = Buffer.from(img).toString("base64"); - - return { - body, - statusCode: 200, - isBase64Encoded: true, - headers: { - "Content-Type": "image/jpeg", - "Content-Disposition": "inline", - }, - }; -} diff --git a/examples/aws-ffmpeg/package.json b/examples/aws-ffmpeg/package.json deleted file mode 100644 index 4bee839366..0000000000 --- a/examples/aws-ffmpeg/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-ffmpeg", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "ffmpeg-static": "^5.2.0", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145" - } -} diff --git a/examples/aws-ffmpeg/sst.config.ts b/examples/aws-ffmpeg/sst.config.ts deleted file mode 100644 index 01e1a3b46c..0000000000 --- a/examples/aws-ffmpeg/sst.config.ts +++ /dev/null @@ -1,59 +0,0 @@ -/// - -/** - * ## FFmpeg in Lambda - * - * Uses [FFmpeg](https://ffmpeg.org/) to process videos. In this example, it takes a `clip.mp4` - * and grabs a single frame from it. - * - * :::tip - * You don't need to use a Lambda layer to use FFmpeg. - * ::: - * - * We use the [`ffmpeg-static`](https://www.npmjs.com/package/ffmpeg-static) package that - * contains pre-built binaries for all architectures. - * - * ```ts title="index.ts" - * import ffmpeg from "ffmpeg-static"; - * ``` - * - * We can use this to spawn a child process and run FFmpeg. - * - * ```ts title="index.ts" - * spawnSync(ffmpeg, ffmpegParams, { stdio: "pipe" }); - * ``` - * - * We don't need a layer when we deploy this because SST will use the right binary for the - * target Lambda architecture; including `arm64`. - * - * ```json title="sst.config.ts" - * { - * nodejs: { install: ["ffmpeg-static"] } - * } - * ``` - * - * All this is handled by [`nodejs.install`](/docs/component/aws/function#nodejs-install). - */ -export default $config({ - app(input) { - return { - name: "aws-ffmpeg", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const func = new sst.aws.Function("MyFunction", { - url: true, - memory: "2 GB", - timeout: "15 minutes", - handler: "index.handler", - copyFiles: [{ from: "clip.mp4" }], - nodejs: { install: ["ffmpeg-static"] }, - }); - - return { - url: func.url, - }; - }, -}); diff --git a/examples/aws-ffmpeg/tsconfig.json b/examples/aws-ffmpeg/tsconfig.json deleted file mode 100644 index 2f98042715..0000000000 --- a/examples/aws-ffmpeg/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "esModuleInterop": true - } -} diff --git a/examples/aws-flutter-web/.gitignore b/examples/aws-flutter-web/.gitignore deleted file mode 100644 index 41160e58d7..0000000000 --- a/examples/aws-flutter-web/.gitignore +++ /dev/null @@ -1,46 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ -migrate_working_dir/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -**/ios/Flutter/.last_build_id -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.pub-cache/ -.pub/ -/build/ - -# Symbolication related -app.*.symbols - -# Obfuscation related -app.*.map.json - -# Android Studio will place build artifacts here -/android/app/debug -/android/app/profile -/android/app/release - -# sst -.sst diff --git a/examples/aws-flutter-web/.metadata b/examples/aws-flutter-web/.metadata deleted file mode 100644 index cbf1dc0e0d..0000000000 --- a/examples/aws-flutter-web/.metadata +++ /dev/null @@ -1,45 +0,0 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled and should not be manually edited. - -version: - revision: "a14f74ff3a1cbd521163c5f03d68113d50af93d3" - channel: "stable" - -project_type: app - -# Tracks metadata for the flutter migrate command -migration: - platforms: - - platform: root - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - - platform: android - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - - platform: ios - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - - platform: linux - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - - platform: macos - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - - platform: web - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - - platform: windows - create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3 - - # User provided section - - # List of Local paths (relative to this file) that should be - # ignored by the migrate tool. - # - # Files that are not part of the templates will be ignored by default. - unmanaged_files: - - 'lib/main.dart' - - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/examples/aws-flutter-web/analysis_options.yaml b/examples/aws-flutter-web/analysis_options.yaml deleted file mode 100644 index 0d2902135c..0000000000 --- a/examples/aws-flutter-web/analysis_options.yaml +++ /dev/null @@ -1,28 +0,0 @@ -# This file configures the analyzer, which statically analyzes Dart code to -# check for errors, warnings, and lints. -# -# The issues identified by the analyzer are surfaced in the UI of Dart-enabled -# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be -# invoked from the command line by running `flutter analyze`. - -# The following line activates a set of recommended lints for Flutter apps, -# packages, and plugins designed to encourage good coding practices. -include: package:flutter_lints/flutter.yaml - -linter: - # The lint rules applied to this project can be customized in the - # section below to disable rules from the `package:flutter_lints/flutter.yaml` - # included above or to enable additional rules. A list of all available lints - # and their documentation is published at https://dart.dev/lints. - # - # Instead of disabling a lint rule for the entire project in the - # section below, it can also be suppressed for a single line of code - # or a specific dart file by using the `// ignore: name_of_lint` and - # `// ignore_for_file: name_of_lint` syntax on the line or in the file - # producing the lint. - rules: - # avoid_print: false # Uncomment to disable the `avoid_print` rule - # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options diff --git a/examples/aws-flutter-web/android/.gitignore b/examples/aws-flutter-web/android/.gitignore deleted file mode 100644 index 6f568019d3..0000000000 --- a/examples/aws-flutter-web/android/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -gradle-wrapper.jar -/.gradle -/captures/ -/gradlew -/gradlew.bat -/local.properties -GeneratedPluginRegistrant.java - -# Remember to never publicly share your keystore. -# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app -key.properties -**/*.keystore -**/*.jks diff --git a/examples/aws-flutter-web/android/app/build.gradle b/examples/aws-flutter-web/android/app/build.gradle deleted file mode 100644 index b68da4a58e..0000000000 --- a/examples/aws-flutter-web/android/app/build.gradle +++ /dev/null @@ -1,58 +0,0 @@ -plugins { - id "com.android.application" - id "kotlin-android" - // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. - id "dev.flutter.flutter-gradle-plugin" -} - -def localProperties = new Properties() -def localPropertiesFile = rootProject.file("local.properties") -if (localPropertiesFile.exists()) { - localPropertiesFile.withReader("UTF-8") { reader -> - localProperties.load(reader) - } -} - -def flutterVersionCode = localProperties.getProperty("flutter.versionCode") -if (flutterVersionCode == null) { - flutterVersionCode = "1" -} - -def flutterVersionName = localProperties.getProperty("flutter.versionName") -if (flutterVersionName == null) { - flutterVersionName = "1.0" -} - -android { - namespace = "com.example.aws_flutter_web" - compileSdk = flutter.compileSdkVersion - ndkVersion = flutter.ndkVersion - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - - defaultConfig { - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId = "com.example.aws_flutter_web" - // You can update the following values to match your application needs. - // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. - minSdk = flutter.minSdkVersion - targetSdk = flutter.targetSdkVersion - versionCode = flutterVersionCode.toInteger() - versionName = flutterVersionName - } - - buildTypes { - release { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig = signingConfigs.debug - } - } -} - -flutter { - source = "../.." -} diff --git a/examples/aws-flutter-web/android/app/src/debug/AndroidManifest.xml b/examples/aws-flutter-web/android/app/src/debug/AndroidManifest.xml deleted file mode 100644 index 399f6981d5..0000000000 --- a/examples/aws-flutter-web/android/app/src/debug/AndroidManifest.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - diff --git a/examples/aws-flutter-web/android/app/src/main/AndroidManifest.xml b/examples/aws-flutter-web/android/app/src/main/AndroidManifest.xml deleted file mode 100644 index 6a5ac6fe10..0000000000 --- a/examples/aws-flutter-web/android/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/aws-flutter-web/android/app/src/main/kotlin/com/example/aws_flutter_web/MainActivity.kt b/examples/aws-flutter-web/android/app/src/main/kotlin/com/example/aws_flutter_web/MainActivity.kt deleted file mode 100644 index c85c87a074..0000000000 --- a/examples/aws-flutter-web/android/app/src/main/kotlin/com/example/aws_flutter_web/MainActivity.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.example.aws_flutter_web - -import io.flutter.embedding.android.FlutterActivity - -class MainActivity: FlutterActivity() diff --git a/examples/aws-flutter-web/android/app/src/main/res/drawable-v21/launch_background.xml b/examples/aws-flutter-web/android/app/src/main/res/drawable-v21/launch_background.xml deleted file mode 100644 index f74085f3f6..0000000000 --- a/examples/aws-flutter-web/android/app/src/main/res/drawable-v21/launch_background.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/examples/aws-flutter-web/android/app/src/main/res/drawable/launch_background.xml b/examples/aws-flutter-web/android/app/src/main/res/drawable/launch_background.xml deleted file mode 100644 index 304732f884..0000000000 --- a/examples/aws-flutter-web/android/app/src/main/res/drawable/launch_background.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/examples/aws-flutter-web/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/examples/aws-flutter-web/android/app/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index db77bb4b7b..0000000000 Binary files a/examples/aws-flutter-web/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/examples/aws-flutter-web/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/examples/aws-flutter-web/android/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index 17987b79bb..0000000000 Binary files a/examples/aws-flutter-web/android/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/examples/aws-flutter-web/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/examples/aws-flutter-web/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index 09d4391482..0000000000 Binary files a/examples/aws-flutter-web/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/examples/aws-flutter-web/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/examples/aws-flutter-web/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index d5f1c8d34e..0000000000 Binary files a/examples/aws-flutter-web/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/examples/aws-flutter-web/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/examples/aws-flutter-web/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index 4d6372eebd..0000000000 Binary files a/examples/aws-flutter-web/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/examples/aws-flutter-web/android/app/src/main/res/values-night/styles.xml b/examples/aws-flutter-web/android/app/src/main/res/values-night/styles.xml deleted file mode 100644 index 06952be745..0000000000 --- a/examples/aws-flutter-web/android/app/src/main/res/values-night/styles.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - diff --git a/examples/aws-flutter-web/android/app/src/main/res/values/styles.xml b/examples/aws-flutter-web/android/app/src/main/res/values/styles.xml deleted file mode 100644 index cb1ef88056..0000000000 --- a/examples/aws-flutter-web/android/app/src/main/res/values/styles.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - diff --git a/examples/aws-flutter-web/android/app/src/profile/AndroidManifest.xml b/examples/aws-flutter-web/android/app/src/profile/AndroidManifest.xml deleted file mode 100644 index 399f6981d5..0000000000 --- a/examples/aws-flutter-web/android/app/src/profile/AndroidManifest.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - diff --git a/examples/aws-flutter-web/android/build.gradle b/examples/aws-flutter-web/android/build.gradle deleted file mode 100644 index d2ffbffa4c..0000000000 --- a/examples/aws-flutter-web/android/build.gradle +++ /dev/null @@ -1,18 +0,0 @@ -allprojects { - repositories { - google() - mavenCentral() - } -} - -rootProject.buildDir = "../build" -subprojects { - project.buildDir = "${rootProject.buildDir}/${project.name}" -} -subprojects { - project.evaluationDependsOn(":app") -} - -tasks.register("clean", Delete) { - delete rootProject.buildDir -} diff --git a/examples/aws-flutter-web/android/gradle.properties b/examples/aws-flutter-web/android/gradle.properties deleted file mode 100644 index 3b5b324f6e..0000000000 --- a/examples/aws-flutter-web/android/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError -android.useAndroidX=true -android.enableJetifier=true diff --git a/examples/aws-flutter-web/android/gradle/wrapper/gradle-wrapper.properties b/examples/aws-flutter-web/android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index e1ca574ef0..0000000000 --- a/examples/aws-flutter-web/android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip diff --git a/examples/aws-flutter-web/android/settings.gradle b/examples/aws-flutter-web/android/settings.gradle deleted file mode 100644 index 536165d35a..0000000000 --- a/examples/aws-flutter-web/android/settings.gradle +++ /dev/null @@ -1,25 +0,0 @@ -pluginManagement { - def flutterSdkPath = { - def properties = new Properties() - file("local.properties").withInputStream { properties.load(it) } - def flutterSdkPath = properties.getProperty("flutter.sdk") - assert flutterSdkPath != null, "flutter.sdk not set in local.properties" - return flutterSdkPath - }() - - includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") - - repositories { - google() - mavenCentral() - gradlePluginPortal() - } -} - -plugins { - id "dev.flutter.flutter-plugin-loader" version "1.0.0" - id "com.android.application" version "7.3.0" apply false - id "org.jetbrains.kotlin.android" version "1.7.10" apply false -} - -include ":app" diff --git a/examples/aws-flutter-web/ios/.gitignore b/examples/aws-flutter-web/ios/.gitignore deleted file mode 100644 index 7a7f9873ad..0000000000 --- a/examples/aws-flutter-web/ios/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ -**/dgph -*.mode1v3 -*.mode2v3 -*.moved-aside -*.pbxuser -*.perspectivev3 -**/*sync/ -.sconsign.dblite -.tags* -**/.vagrant/ -**/DerivedData/ -Icon? -**/Pods/ -**/.symlinks/ -profile -xcuserdata -**/.generated/ -Flutter/App.framework -Flutter/Flutter.framework -Flutter/Flutter.podspec -Flutter/Generated.xcconfig -Flutter/ephemeral/ -Flutter/app.flx -Flutter/app.zip -Flutter/flutter_assets/ -Flutter/flutter_export_environment.sh -ServiceDefinitions.json -Runner/GeneratedPluginRegistrant.* - -# Exceptions to above rules. -!default.mode1v3 -!default.mode2v3 -!default.pbxuser -!default.perspectivev3 diff --git a/examples/aws-flutter-web/ios/Flutter/AppFrameworkInfo.plist b/examples/aws-flutter-web/ios/Flutter/AppFrameworkInfo.plist deleted file mode 100644 index 7c56964006..0000000000 --- a/examples/aws-flutter-web/ios/Flutter/AppFrameworkInfo.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - App - CFBundleIdentifier - io.flutter.flutter.app - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - App - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1.0 - MinimumOSVersion - 12.0 - - diff --git a/examples/aws-flutter-web/ios/Flutter/Debug.xcconfig b/examples/aws-flutter-web/ios/Flutter/Debug.xcconfig deleted file mode 100644 index 592ceee85b..0000000000 --- a/examples/aws-flutter-web/ios/Flutter/Debug.xcconfig +++ /dev/null @@ -1 +0,0 @@ -#include "Generated.xcconfig" diff --git a/examples/aws-flutter-web/ios/Flutter/Release.xcconfig b/examples/aws-flutter-web/ios/Flutter/Release.xcconfig deleted file mode 100644 index 592ceee85b..0000000000 --- a/examples/aws-flutter-web/ios/Flutter/Release.xcconfig +++ /dev/null @@ -1 +0,0 @@ -#include "Generated.xcconfig" diff --git a/examples/aws-flutter-web/ios/Runner.xcodeproj/project.pbxproj b/examples/aws-flutter-web/ios/Runner.xcodeproj/project.pbxproj deleted file mode 100644 index 332b360542..0000000000 --- a/examples/aws-flutter-web/ios/Runner.xcodeproj/project.pbxproj +++ /dev/null @@ -1,616 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 54; - objects = { - -/* Begin PBXBuildFile section */ - 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; - 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; - 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; - 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; - 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; - 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; - 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 331C8085294A63A400263BE5 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 97C146E61CF9000F007C117D /* Project object */; - proxyType = 1; - remoteGlobalIDString = 97C146ED1CF9000F007C117D; - remoteInfo = Runner; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 9705A1C41CF9048500538489 /* Embed Frameworks */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - ); - name = "Embed Frameworks"; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; - 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; - 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; - 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; - 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; - 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; - 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; - 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; - 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; - 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; - 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 97C146EB1CF9000F007C117D /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 331C8082294A63A400263BE5 /* RunnerTests */ = { - isa = PBXGroup; - children = ( - 331C807B294A618700263BE5 /* RunnerTests.swift */, - ); - path = RunnerTests; - sourceTree = ""; - }; - 9740EEB11CF90186004384FC /* Flutter */ = { - isa = PBXGroup; - children = ( - 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, - 9740EEB21CF90195004384FC /* Debug.xcconfig */, - 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, - 9740EEB31CF90195004384FC /* Generated.xcconfig */, - ); - name = Flutter; - sourceTree = ""; - }; - 97C146E51CF9000F007C117D = { - isa = PBXGroup; - children = ( - 9740EEB11CF90186004384FC /* Flutter */, - 97C146F01CF9000F007C117D /* Runner */, - 97C146EF1CF9000F007C117D /* Products */, - 331C8082294A63A400263BE5 /* RunnerTests */, - ); - sourceTree = ""; - }; - 97C146EF1CF9000F007C117D /* Products */ = { - isa = PBXGroup; - children = ( - 97C146EE1CF9000F007C117D /* Runner.app */, - 331C8081294A63A400263BE5 /* RunnerTests.xctest */, - ); - name = Products; - sourceTree = ""; - }; - 97C146F01CF9000F007C117D /* Runner */ = { - isa = PBXGroup; - children = ( - 97C146FA1CF9000F007C117D /* Main.storyboard */, - 97C146FD1CF9000F007C117D /* Assets.xcassets */, - 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, - 97C147021CF9000F007C117D /* Info.plist */, - 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, - 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, - 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, - 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, - ); - path = Runner; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 331C8080294A63A400263BE5 /* RunnerTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; - buildPhases = ( - 331C807D294A63A400263BE5 /* Sources */, - 331C807F294A63A400263BE5 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 331C8086294A63A400263BE5 /* PBXTargetDependency */, - ); - name = RunnerTests; - productName = RunnerTests; - productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 97C146ED1CF9000F007C117D /* Runner */ = { - isa = PBXNativeTarget; - buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; - buildPhases = ( - 9740EEB61CF901F6004384FC /* Run Script */, - 97C146EA1CF9000F007C117D /* Sources */, - 97C146EB1CF9000F007C117D /* Frameworks */, - 97C146EC1CF9000F007C117D /* Resources */, - 9705A1C41CF9048500538489 /* Embed Frameworks */, - 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = Runner; - productName = Runner; - productReference = 97C146EE1CF9000F007C117D /* Runner.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 97C146E61CF9000F007C117D /* Project object */ = { - isa = PBXProject; - attributes = { - BuildIndependentTargetsInParallel = YES; - LastUpgradeCheck = 1510; - ORGANIZATIONNAME = ""; - TargetAttributes = { - 331C8080294A63A400263BE5 = { - CreatedOnToolsVersion = 14.0; - TestTargetID = 97C146ED1CF9000F007C117D; - }; - 97C146ED1CF9000F007C117D = { - CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 1100; - }; - }; - }; - buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; - compatibilityVersion = "Xcode 9.3"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 97C146E51CF9000F007C117D; - productRefGroup = 97C146EF1CF9000F007C117D /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 97C146ED1CF9000F007C117D /* Runner */, - 331C8080294A63A400263BE5 /* RunnerTests */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 331C807F294A63A400263BE5 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 97C146EC1CF9000F007C117D /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, - 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, - 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, - 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { - isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", - ); - name = "Thin Binary"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; - }; - 9740EEB61CF901F6004384FC /* Run Script */ = { - isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Run Script"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 331C807D294A63A400263BE5 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 97C146EA1CF9000F007C117D /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, - 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 331C8086294A63A400263BE5 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 97C146ED1CF9000F007C117D /* Runner */; - targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin PBXVariantGroup section */ - 97C146FA1CF9000F007C117D /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 97C146FB1CF9000F007C117D /* Base */, - ); - name = Main.storyboard; - sourceTree = ""; - }; - 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 97C147001CF9000F007C117D /* Base */, - ); - name = LaunchScreen.storyboard; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 249021D3217E4FDB00AE95B9 /* Profile */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_USER_SCRIPT_SANDBOXING = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - SUPPORTED_PLATFORMS = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - }; - name = Profile; - }; - 249021D4217E4FDB00AE95B9 /* Profile */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - ENABLE_BITCODE = NO; - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.awsFlutterWeb; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; - SWIFT_VERSION = 5.0; - VERSIONING_SYSTEM = "apple-generic"; - }; - name = Profile; - }; - 331C8088294A63A400263BE5 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.example.awsFlutterWeb.RunnerTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; - }; - name = Debug; - }; - 331C8089294A63A400263BE5 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.example.awsFlutterWeb.RunnerTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; - }; - name = Release; - }; - 331C808A294A63A400263BE5 /* Profile */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.example.awsFlutterWeb.RunnerTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; - }; - name = Profile; - }; - 97C147031CF9000F007C117D /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - ENABLE_USER_SCRIPT_SANDBOXING = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 97C147041CF9000F007C117D /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_USER_SCRIPT_SANDBOXING = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - SUPPORTED_PLATFORMS = iphoneos; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 97C147061CF9000F007C117D /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - ENABLE_BITCODE = NO; - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.awsFlutterWeb; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; - VERSIONING_SYSTEM = "apple-generic"; - }; - name = Debug; - }; - 97C147071CF9000F007C117D /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - ENABLE_BITCODE = NO; - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.awsFlutterWeb; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; - SWIFT_VERSION = 5.0; - VERSIONING_SYSTEM = "apple-generic"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 331C8088294A63A400263BE5 /* Debug */, - 331C8089294A63A400263BE5 /* Release */, - 331C808A294A63A400263BE5 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 97C147031CF9000F007C117D /* Debug */, - 97C147041CF9000F007C117D /* Release */, - 249021D3217E4FDB00AE95B9 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 97C147061CF9000F007C117D /* Debug */, - 97C147071CF9000F007C117D /* Release */, - 249021D4217E4FDB00AE95B9 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 97C146E61CF9000F007C117D /* Project object */; -} diff --git a/examples/aws-flutter-web/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/examples/aws-flutter-web/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 919434a625..0000000000 --- a/examples/aws-flutter-web/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/examples/aws-flutter-web/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/examples/aws-flutter-web/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d981003d..0000000000 --- a/examples/aws-flutter-web/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/examples/aws-flutter-web/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/examples/aws-flutter-web/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings deleted file mode 100644 index f9b0d7c5ea..0000000000 --- a/examples/aws-flutter-web/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +++ /dev/null @@ -1,8 +0,0 @@ - - - - - PreviewsEnabled - - - diff --git a/examples/aws-flutter-web/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/examples/aws-flutter-web/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme deleted file mode 100644 index 8e3ca5dfe1..0000000000 --- a/examples/aws-flutter-web/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/aws-flutter-web/ios/Runner.xcworkspace/contents.xcworkspacedata b/examples/aws-flutter-web/ios/Runner.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 1d526a16ed..0000000000 --- a/examples/aws-flutter-web/ios/Runner.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/examples/aws-flutter-web/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/examples/aws-flutter-web/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d981003d..0000000000 --- a/examples/aws-flutter-web/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/examples/aws-flutter-web/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/examples/aws-flutter-web/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings deleted file mode 100644 index f9b0d7c5ea..0000000000 --- a/examples/aws-flutter-web/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +++ /dev/null @@ -1,8 +0,0 @@ - - - - - PreviewsEnabled - - - diff --git a/examples/aws-flutter-web/ios/Runner/AppDelegate.swift b/examples/aws-flutter-web/ios/Runner/AppDelegate.swift deleted file mode 100644 index 9074fee929..0000000000 --- a/examples/aws-flutter-web/ios/Runner/AppDelegate.swift +++ /dev/null @@ -1,13 +0,0 @@ -import Flutter -import UIKit - -@UIApplicationMain -@objc class AppDelegate: FlutterAppDelegate { - override func application( - _ application: UIApplication, - didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? - ) -> Bool { - GeneratedPluginRegistrant.register(with: self) - return super.application(application, didFinishLaunchingWithOptions: launchOptions) - } -} diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index d36b1fab2d..0000000000 --- a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "images" : [ - { - "size" : "20x20", - "idiom" : "iphone", - "filename" : "Icon-App-20x20@2x.png", - "scale" : "2x" - }, - { - "size" : "20x20", - "idiom" : "iphone", - "filename" : "Icon-App-20x20@3x.png", - "scale" : "3x" - }, - { - "size" : "29x29", - "idiom" : "iphone", - "filename" : "Icon-App-29x29@1x.png", - "scale" : "1x" - }, - { - "size" : "29x29", - "idiom" : "iphone", - "filename" : "Icon-App-29x29@2x.png", - "scale" : "2x" - }, - { - "size" : "29x29", - "idiom" : "iphone", - "filename" : "Icon-App-29x29@3x.png", - "scale" : "3x" - }, - { - "size" : "40x40", - "idiom" : "iphone", - "filename" : "Icon-App-40x40@2x.png", - "scale" : "2x" - }, - { - "size" : "40x40", - "idiom" : "iphone", - "filename" : "Icon-App-40x40@3x.png", - "scale" : "3x" - }, - { - "size" : "60x60", - "idiom" : "iphone", - "filename" : "Icon-App-60x60@2x.png", - "scale" : "2x" - }, - { - "size" : "60x60", - "idiom" : "iphone", - "filename" : "Icon-App-60x60@3x.png", - "scale" : "3x" - }, - { - "size" : "20x20", - "idiom" : "ipad", - "filename" : "Icon-App-20x20@1x.png", - "scale" : "1x" - }, - { - "size" : "20x20", - "idiom" : "ipad", - "filename" : "Icon-App-20x20@2x.png", - "scale" : "2x" - }, - { - "size" : "29x29", - "idiom" : "ipad", - "filename" : "Icon-App-29x29@1x.png", - "scale" : "1x" - }, - { - "size" : "29x29", - "idiom" : "ipad", - "filename" : "Icon-App-29x29@2x.png", - "scale" : "2x" - }, - { - "size" : "40x40", - "idiom" : "ipad", - "filename" : "Icon-App-40x40@1x.png", - "scale" : "1x" - }, - { - "size" : "40x40", - "idiom" : "ipad", - "filename" : "Icon-App-40x40@2x.png", - "scale" : "2x" - }, - { - "size" : "76x76", - "idiom" : "ipad", - "filename" : "Icon-App-76x76@1x.png", - "scale" : "1x" - }, - { - "size" : "76x76", - "idiom" : "ipad", - "filename" : "Icon-App-76x76@2x.png", - "scale" : "2x" - }, - { - "size" : "83.5x83.5", - "idiom" : "ipad", - "filename" : "Icon-App-83.5x83.5@2x.png", - "scale" : "2x" - }, - { - "size" : "1024x1024", - "idiom" : "ios-marketing", - "filename" : "Icon-App-1024x1024@1x.png", - "scale" : "1x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png deleted file mode 100644 index dc9ada4725..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png deleted file mode 100644 index 7353c41ecf..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png deleted file mode 100644 index 797d452e45..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png deleted file mode 100644 index 6ed2d933e1..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png deleted file mode 100644 index 4cd7b0099c..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png deleted file mode 100644 index fe730945a0..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png deleted file mode 100644 index 321773cd85..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png deleted file mode 100644 index 797d452e45..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png deleted file mode 100644 index 502f463a9b..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png deleted file mode 100644 index 0ec3034392..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png deleted file mode 100644 index 0ec3034392..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png deleted file mode 100644 index e9f5fea27c..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png deleted file mode 100644 index 84ac32ae7d..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png deleted file mode 100644 index 8953cba090..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png deleted file mode 100644 index 0467bf12aa..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json deleted file mode 100644 index 0bedcf2fd4..0000000000 --- a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "images" : [ - { - "idiom" : "universal", - "filename" : "LaunchImage.png", - "scale" : "1x" - }, - { - "idiom" : "universal", - "filename" : "LaunchImage@2x.png", - "scale" : "2x" - }, - { - "idiom" : "universal", - "filename" : "LaunchImage@3x.png", - "scale" : "3x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png deleted file mode 100644 index 9da19eacad..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png deleted file mode 100644 index 9da19eacad..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/examples/aws-flutter-web/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png deleted file mode 100644 index 9da19eacad..0000000000 Binary files a/examples/aws-flutter-web/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png and /dev/null differ diff --git a/examples/aws-flutter-web/ios/Runner/Base.lproj/LaunchScreen.storyboard b/examples/aws-flutter-web/ios/Runner/Base.lproj/LaunchScreen.storyboard deleted file mode 100644 index f2e259c7c9..0000000000 --- a/examples/aws-flutter-web/ios/Runner/Base.lproj/LaunchScreen.storyboard +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/aws-flutter-web/ios/Runner/Base.lproj/Main.storyboard b/examples/aws-flutter-web/ios/Runner/Base.lproj/Main.storyboard deleted file mode 100644 index f3c28516fb..0000000000 --- a/examples/aws-flutter-web/ios/Runner/Base.lproj/Main.storyboard +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/aws-flutter-web/ios/Runner/Info.plist b/examples/aws-flutter-web/ios/Runner/Info.plist deleted file mode 100644 index fae703d438..0000000000 --- a/examples/aws-flutter-web/ios/Runner/Info.plist +++ /dev/null @@ -1,49 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleDisplayName - Aws Flutter Web - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - aws_flutter_web - CFBundlePackageType - APPL - CFBundleShortVersionString - $(FLUTTER_BUILD_NAME) - CFBundleSignature - ???? - CFBundleVersion - $(FLUTTER_BUILD_NUMBER) - LSRequiresIPhoneOS - - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - CADisableMinimumFrameDurationOnPhone - - UIApplicationSupportsIndirectInputEvents - - - diff --git a/examples/aws-flutter-web/ios/Runner/Runner-Bridging-Header.h b/examples/aws-flutter-web/ios/Runner/Runner-Bridging-Header.h deleted file mode 100644 index 308a2a560b..0000000000 --- a/examples/aws-flutter-web/ios/Runner/Runner-Bridging-Header.h +++ /dev/null @@ -1 +0,0 @@ -#import "GeneratedPluginRegistrant.h" diff --git a/examples/aws-flutter-web/ios/RunnerTests/RunnerTests.swift b/examples/aws-flutter-web/ios/RunnerTests/RunnerTests.swift deleted file mode 100644 index 86a7c3b1b6..0000000000 --- a/examples/aws-flutter-web/ios/RunnerTests/RunnerTests.swift +++ /dev/null @@ -1,12 +0,0 @@ -import Flutter -import UIKit -import XCTest - -class RunnerTests: XCTestCase { - - func testExample() { - // If you add code to the Runner application, consider adding tests here. - // See https://developer.apple.com/documentation/xctest for more information about using XCTest. - } - -} diff --git a/examples/aws-flutter-web/lib/main.dart b/examples/aws-flutter-web/lib/main.dart deleted file mode 100644 index 8e94089121..0000000000 --- a/examples/aws-flutter-web/lib/main.dart +++ /dev/null @@ -1,125 +0,0 @@ -import 'package:flutter/material.dart'; - -void main() { - runApp(const MyApp()); -} - -class MyApp extends StatelessWidget { - const MyApp({super.key}); - - // This widget is the root of your application. - @override - Widget build(BuildContext context) { - return MaterialApp( - title: 'Flutter Demo', - theme: ThemeData( - // This is the theme of your application. - // - // TRY THIS: Try running your application with "flutter run". You'll see - // the application has a purple toolbar. Then, without quitting the app, - // try changing the seedColor in the colorScheme below to Colors.green - // and then invoke "hot reload" (save your changes or press the "hot - // reload" button in a Flutter-supported IDE, or press "r" if you used - // the command line to start the app). - // - // Notice that the counter didn't reset back to zero; the application - // state is not lost during the reload. To reset the state, use hot - // restart instead. - // - // This works for code too, not just values: Most code changes can be - // tested with just a hot reload. - colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), - useMaterial3: true, - ), - home: const MyHomePage(title: 'Flutter Demo Home Page'), - ); - } -} - -class MyHomePage extends StatefulWidget { - const MyHomePage({super.key, required this.title}); - - // This widget is the home page of your application. It is stateful, meaning - // that it has a State object (defined below) that contains fields that affect - // how it looks. - - // This class is the configuration for the state. It holds the values (in this - // case the title) provided by the parent (in this case the App widget) and - // used by the build method of the State. Fields in a Widget subclass are - // always marked "final". - - final String title; - - @override - State createState() => _MyHomePageState(); -} - -class _MyHomePageState extends State { - int _counter = 0; - - void _incrementCounter() { - setState(() { - // This call to setState tells the Flutter framework that something has - // changed in this State, which causes it to rerun the build method below - // so that the display can reflect the updated values. If we changed - // _counter without calling setState(), then the build method would not be - // called again, and so nothing would appear to happen. - _counter++; - }); - } - - @override - Widget build(BuildContext context) { - // This method is rerun every time setState is called, for instance as done - // by the _incrementCounter method above. - // - // The Flutter framework has been optimized to make rerunning build methods - // fast, so that you can just rebuild anything that needs updating rather - // than having to individually change instances of widgets. - return Scaffold( - appBar: AppBar( - // TRY THIS: Try changing the color here to a specific color (to - // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar - // change color while the other colors stay the same. - backgroundColor: Theme.of(context).colorScheme.inversePrimary, - // Here we take the value from the MyHomePage object that was created by - // the App.build method, and use it to set our appbar title. - title: Text(widget.title), - ), - body: Center( - // Center is a layout widget. It takes a single child and positions it - // in the middle of the parent. - child: Column( - // Column is also a layout widget. It takes a list of children and - // arranges them vertically. By default, it sizes itself to fit its - // children horizontally, and tries to be as tall as its parent. - // - // Column has various properties to control how it sizes itself and - // how it positions its children. Here we use mainAxisAlignment to - // center the children vertically; the main axis here is the vertical - // axis because Columns are vertical (the cross axis would be - // horizontal). - // - // TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint" - // action in the IDE, or press "p" in the console), to see the - // wireframe for each widget. - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text( - 'You have pushed the button this many times:', - ), - Text( - '$_counter', - style: Theme.of(context).textTheme.headlineMedium, - ), - ], - ), - ), - floatingActionButton: FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: const Icon(Icons.add), - ), // This trailing comma makes auto-formatting nicer for build methods. - ); - } -} diff --git a/examples/aws-flutter-web/linux/.gitignore b/examples/aws-flutter-web/linux/.gitignore deleted file mode 100644 index d3896c9844..0000000000 --- a/examples/aws-flutter-web/linux/.gitignore +++ /dev/null @@ -1 +0,0 @@ -flutter/ephemeral diff --git a/examples/aws-flutter-web/linux/CMakeLists.txt b/examples/aws-flutter-web/linux/CMakeLists.txt deleted file mode 100644 index a147894dec..0000000000 --- a/examples/aws-flutter-web/linux/CMakeLists.txt +++ /dev/null @@ -1,145 +0,0 @@ -# Project-level configuration. -cmake_minimum_required(VERSION 3.10) -project(runner LANGUAGES CXX) - -# The name of the executable created for the application. Change this to change -# the on-disk name of your application. -set(BINARY_NAME "aws_flutter_web") -# The unique GTK application identifier for this application. See: -# https://wiki.gnome.org/HowDoI/ChooseApplicationID -set(APPLICATION_ID "com.example.aws_flutter_web") - -# Explicitly opt in to modern CMake behaviors to avoid warnings with recent -# versions of CMake. -cmake_policy(SET CMP0063 NEW) - -# Load bundled libraries from the lib/ directory relative to the binary. -set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") - -# Root filesystem for cross-building. -if(FLUTTER_TARGET_PLATFORM_SYSROOT) - set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) - set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) - set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) - set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) - set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) - set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -endif() - -# Define build configuration options. -if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - set(CMAKE_BUILD_TYPE "Debug" CACHE - STRING "Flutter build mode" FORCE) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS - "Debug" "Profile" "Release") -endif() - -# Compilation settings that should be applied to most targets. -# -# Be cautious about adding new options here, as plugins use this function by -# default. In most cases, you should add new options to specific targets instead -# of modifying this function. -function(APPLY_STANDARD_SETTINGS TARGET) - target_compile_features(${TARGET} PUBLIC cxx_std_14) - target_compile_options(${TARGET} PRIVATE -Wall -Werror) - target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") - target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") -endfunction() - -# Flutter library and tool build rules. -set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") -add_subdirectory(${FLUTTER_MANAGED_DIR}) - -# System-level dependencies. -find_package(PkgConfig REQUIRED) -pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) - -add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") - -# Define the application target. To change its name, change BINARY_NAME above, -# not the value here, or `flutter run` will no longer work. -# -# Any new source files that you add to the application should be added here. -add_executable(${BINARY_NAME} - "main.cc" - "my_application.cc" - "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" -) - -# Apply the standard set of build settings. This can be removed for applications -# that need different build settings. -apply_standard_settings(${BINARY_NAME}) - -# Add dependency libraries. Add any application-specific dependencies here. -target_link_libraries(${BINARY_NAME} PRIVATE flutter) -target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) - -# Run the Flutter tool portions of the build. This must not be removed. -add_dependencies(${BINARY_NAME} flutter_assemble) - -# Only the install-generated bundle's copy of the executable will launch -# correctly, since the resources must in the right relative locations. To avoid -# people trying to run the unbundled copy, put it in a subdirectory instead of -# the default top-level location. -set_target_properties(${BINARY_NAME} - PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" -) - - -# Generated plugin build rules, which manage building the plugins and adding -# them to the application. -include(flutter/generated_plugins.cmake) - - -# === Installation === -# By default, "installing" just makes a relocatable bundle in the build -# directory. -set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) -endif() - -# Start with a clean build bundle directory every time. -install(CODE " - file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") - " COMPONENT Runtime) - -set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") -set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") - -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" - COMPONENT Runtime) - -install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" - COMPONENT Runtime) - -install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) - -foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) - install(FILES "${bundled_library}" - DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) -endforeach(bundled_library) - -# Copy the native assets provided by the build.dart from all packages. -set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") -install(DIRECTORY "${NATIVE_ASSETS_DIR}" - DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) - -# Fully re-copy the assets directory on each build to avoid having stale files -# from a previous install. -set(FLUTTER_ASSET_DIR_NAME "flutter_assets") -install(CODE " - file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") - " COMPONENT Runtime) -install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" - DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) - -# Install the AOT library on non-Debug builds only. -if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") - install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) -endif() diff --git a/examples/aws-flutter-web/linux/flutter/CMakeLists.txt b/examples/aws-flutter-web/linux/flutter/CMakeLists.txt deleted file mode 100644 index d5bd01648a..0000000000 --- a/examples/aws-flutter-web/linux/flutter/CMakeLists.txt +++ /dev/null @@ -1,88 +0,0 @@ -# This file controls Flutter-level build steps. It should not be edited. -cmake_minimum_required(VERSION 3.10) - -set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") - -# Configuration provided via flutter tool. -include(${EPHEMERAL_DIR}/generated_config.cmake) - -# TODO: Move the rest of this into files in ephemeral. See -# https://github.com/flutter/flutter/issues/57146. - -# Serves the same purpose as list(TRANSFORM ... PREPEND ...), -# which isn't available in 3.10. -function(list_prepend LIST_NAME PREFIX) - set(NEW_LIST "") - foreach(element ${${LIST_NAME}}) - list(APPEND NEW_LIST "${PREFIX}${element}") - endforeach(element) - set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) -endfunction() - -# === Flutter Library === -# System-level dependencies. -find_package(PkgConfig REQUIRED) -pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) -pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) -pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) - -set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") - -# Published to parent scope for install step. -set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) -set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) -set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) -set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) - -list(APPEND FLUTTER_LIBRARY_HEADERS - "fl_basic_message_channel.h" - "fl_binary_codec.h" - "fl_binary_messenger.h" - "fl_dart_project.h" - "fl_engine.h" - "fl_json_message_codec.h" - "fl_json_method_codec.h" - "fl_message_codec.h" - "fl_method_call.h" - "fl_method_channel.h" - "fl_method_codec.h" - "fl_method_response.h" - "fl_plugin_registrar.h" - "fl_plugin_registry.h" - "fl_standard_message_codec.h" - "fl_standard_method_codec.h" - "fl_string_codec.h" - "fl_value.h" - "fl_view.h" - "flutter_linux.h" -) -list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") -add_library(flutter INTERFACE) -target_include_directories(flutter INTERFACE - "${EPHEMERAL_DIR}" -) -target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") -target_link_libraries(flutter INTERFACE - PkgConfig::GTK - PkgConfig::GLIB - PkgConfig::GIO -) -add_dependencies(flutter flutter_assemble) - -# === Flutter tool backend === -# _phony_ is a non-existent file to force this command to run every time, -# since currently there's no way to get a full input/output list from the -# flutter tool. -add_custom_command( - OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} - ${CMAKE_CURRENT_BINARY_DIR}/_phony_ - COMMAND ${CMAKE_COMMAND} -E env - ${FLUTTER_TOOL_ENVIRONMENT} - "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" - ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} - VERBATIM -) -add_custom_target(flutter_assemble DEPENDS - "${FLUTTER_LIBRARY}" - ${FLUTTER_LIBRARY_HEADERS} -) diff --git a/examples/aws-flutter-web/linux/flutter/generated_plugin_registrant.cc b/examples/aws-flutter-web/linux/flutter/generated_plugin_registrant.cc deleted file mode 100644 index e71a16d23d..0000000000 --- a/examples/aws-flutter-web/linux/flutter/generated_plugin_registrant.cc +++ /dev/null @@ -1,11 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#include "generated_plugin_registrant.h" - - -void fl_register_plugins(FlPluginRegistry* registry) { -} diff --git a/examples/aws-flutter-web/linux/flutter/generated_plugin_registrant.h b/examples/aws-flutter-web/linux/flutter/generated_plugin_registrant.h deleted file mode 100644 index e0f0a47bc0..0000000000 --- a/examples/aws-flutter-web/linux/flutter/generated_plugin_registrant.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#ifndef GENERATED_PLUGIN_REGISTRANT_ -#define GENERATED_PLUGIN_REGISTRANT_ - -#include - -// Registers Flutter plugins. -void fl_register_plugins(FlPluginRegistry* registry); - -#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/examples/aws-flutter-web/linux/flutter/generated_plugins.cmake b/examples/aws-flutter-web/linux/flutter/generated_plugins.cmake deleted file mode 100644 index 2e1de87a7e..0000000000 --- a/examples/aws-flutter-web/linux/flutter/generated_plugins.cmake +++ /dev/null @@ -1,23 +0,0 @@ -# -# Generated file, do not edit. -# - -list(APPEND FLUTTER_PLUGIN_LIST -) - -list(APPEND FLUTTER_FFI_PLUGIN_LIST -) - -set(PLUGIN_BUNDLED_LIBRARIES) - -foreach(plugin ${FLUTTER_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) - target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) - list(APPEND PLUGIN_BUNDLED_LIBRARIES $) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) -endforeach(plugin) - -foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) -endforeach(ffi_plugin) diff --git a/examples/aws-flutter-web/linux/main.cc b/examples/aws-flutter-web/linux/main.cc deleted file mode 100644 index e7c5c54370..0000000000 --- a/examples/aws-flutter-web/linux/main.cc +++ /dev/null @@ -1,6 +0,0 @@ -#include "my_application.h" - -int main(int argc, char** argv) { - g_autoptr(MyApplication) app = my_application_new(); - return g_application_run(G_APPLICATION(app), argc, argv); -} diff --git a/examples/aws-flutter-web/linux/my_application.cc b/examples/aws-flutter-web/linux/my_application.cc deleted file mode 100644 index 809b553a5a..0000000000 --- a/examples/aws-flutter-web/linux/my_application.cc +++ /dev/null @@ -1,124 +0,0 @@ -#include "my_application.h" - -#include -#ifdef GDK_WINDOWING_X11 -#include -#endif - -#include "flutter/generated_plugin_registrant.h" - -struct _MyApplication { - GtkApplication parent_instance; - char** dart_entrypoint_arguments; -}; - -G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) - -// Implements GApplication::activate. -static void my_application_activate(GApplication* application) { - MyApplication* self = MY_APPLICATION(application); - GtkWindow* window = - GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); - - // Use a header bar when running in GNOME as this is the common style used - // by applications and is the setup most users will be using (e.g. Ubuntu - // desktop). - // If running on X and not using GNOME then just use a traditional title bar - // in case the window manager does more exotic layout, e.g. tiling. - // If running on Wayland assume the header bar will work (may need changing - // if future cases occur). - gboolean use_header_bar = TRUE; -#ifdef GDK_WINDOWING_X11 - GdkScreen* screen = gtk_window_get_screen(window); - if (GDK_IS_X11_SCREEN(screen)) { - const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); - if (g_strcmp0(wm_name, "GNOME Shell") != 0) { - use_header_bar = FALSE; - } - } -#endif - if (use_header_bar) { - GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); - gtk_widget_show(GTK_WIDGET(header_bar)); - gtk_header_bar_set_title(header_bar, "aws_flutter_web"); - gtk_header_bar_set_show_close_button(header_bar, TRUE); - gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); - } else { - gtk_window_set_title(window, "aws_flutter_web"); - } - - gtk_window_set_default_size(window, 1280, 720); - gtk_widget_show(GTK_WIDGET(window)); - - g_autoptr(FlDartProject) project = fl_dart_project_new(); - fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); - - FlView* view = fl_view_new(project); - gtk_widget_show(GTK_WIDGET(view)); - gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); - - fl_register_plugins(FL_PLUGIN_REGISTRY(view)); - - gtk_widget_grab_focus(GTK_WIDGET(view)); -} - -// Implements GApplication::local_command_line. -static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { - MyApplication* self = MY_APPLICATION(application); - // Strip out the first argument as it is the binary name. - self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); - - g_autoptr(GError) error = nullptr; - if (!g_application_register(application, nullptr, &error)) { - g_warning("Failed to register: %s", error->message); - *exit_status = 1; - return TRUE; - } - - g_application_activate(application); - *exit_status = 0; - - return TRUE; -} - -// Implements GApplication::startup. -static void my_application_startup(GApplication* application) { - //MyApplication* self = MY_APPLICATION(object); - - // Perform any actions required at application startup. - - G_APPLICATION_CLASS(my_application_parent_class)->startup(application); -} - -// Implements GApplication::shutdown. -static void my_application_shutdown(GApplication* application) { - //MyApplication* self = MY_APPLICATION(object); - - // Perform any actions required at application shutdown. - - G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application); -} - -// Implements GObject::dispose. -static void my_application_dispose(GObject* object) { - MyApplication* self = MY_APPLICATION(object); - g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); - G_OBJECT_CLASS(my_application_parent_class)->dispose(object); -} - -static void my_application_class_init(MyApplicationClass* klass) { - G_APPLICATION_CLASS(klass)->activate = my_application_activate; - G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; - G_APPLICATION_CLASS(klass)->startup = my_application_startup; - G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown; - G_OBJECT_CLASS(klass)->dispose = my_application_dispose; -} - -static void my_application_init(MyApplication* self) {} - -MyApplication* my_application_new() { - return MY_APPLICATION(g_object_new(my_application_get_type(), - "application-id", APPLICATION_ID, - "flags", G_APPLICATION_NON_UNIQUE, - nullptr)); -} diff --git a/examples/aws-flutter-web/linux/my_application.h b/examples/aws-flutter-web/linux/my_application.h deleted file mode 100644 index 72271d5e41..0000000000 --- a/examples/aws-flutter-web/linux/my_application.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef FLUTTER_MY_APPLICATION_H_ -#define FLUTTER_MY_APPLICATION_H_ - -#include - -G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, - GtkApplication) - -/** - * my_application_new: - * - * Creates a new Flutter-based application. - * - * Returns: a new #MyApplication. - */ -MyApplication* my_application_new(); - -#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/examples/aws-flutter-web/macos/.gitignore b/examples/aws-flutter-web/macos/.gitignore deleted file mode 100644 index 746adbb6b9..0000000000 --- a/examples/aws-flutter-web/macos/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -# Flutter-related -**/Flutter/ephemeral/ -**/Pods/ - -# Xcode-related -**/dgph -**/xcuserdata/ diff --git a/examples/aws-flutter-web/macos/Flutter/Flutter-Debug.xcconfig b/examples/aws-flutter-web/macos/Flutter/Flutter-Debug.xcconfig deleted file mode 100644 index c2efd0b608..0000000000 --- a/examples/aws-flutter-web/macos/Flutter/Flutter-Debug.xcconfig +++ /dev/null @@ -1 +0,0 @@ -#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/examples/aws-flutter-web/macos/Flutter/Flutter-Release.xcconfig b/examples/aws-flutter-web/macos/Flutter/Flutter-Release.xcconfig deleted file mode 100644 index c2efd0b608..0000000000 --- a/examples/aws-flutter-web/macos/Flutter/Flutter-Release.xcconfig +++ /dev/null @@ -1 +0,0 @@ -#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/examples/aws-flutter-web/macos/Flutter/GeneratedPluginRegistrant.swift b/examples/aws-flutter-web/macos/Flutter/GeneratedPluginRegistrant.swift deleted file mode 100644 index cccf817a52..0000000000 --- a/examples/aws-flutter-web/macos/Flutter/GeneratedPluginRegistrant.swift +++ /dev/null @@ -1,10 +0,0 @@ -// -// Generated file. Do not edit. -// - -import FlutterMacOS -import Foundation - - -func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { -} diff --git a/examples/aws-flutter-web/macos/Runner.xcodeproj/project.pbxproj b/examples/aws-flutter-web/macos/Runner.xcodeproj/project.pbxproj deleted file mode 100644 index 1745b1b23b..0000000000 --- a/examples/aws-flutter-web/macos/Runner.xcodeproj/project.pbxproj +++ /dev/null @@ -1,705 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 54; - objects = { - -/* Begin PBXAggregateTarget section */ - 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { - isa = PBXAggregateTarget; - buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; - buildPhases = ( - 33CC111E2044C6BF0003C045 /* ShellScript */, - ); - dependencies = ( - ); - name = "Flutter Assemble"; - productName = FLX; - }; -/* End PBXAggregateTarget section */ - -/* Begin PBXBuildFile section */ - 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; }; - 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; - 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; - 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; - 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; - 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 33CC10E52044A3C60003C045 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 33CC10EC2044A3C60003C045; - remoteInfo = Runner; - }; - 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 33CC10E52044A3C60003C045 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 33CC111A2044C6BA0003C045; - remoteInfo = FLX; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 33CC110E2044A8840003C045 /* Bundle Framework */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - ); - name = "Bundle Framework"; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; - 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; - 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; - 33CC10ED2044A3C60003C045 /* aws_flutter_web.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "aws_flutter_web.app"; sourceTree = BUILT_PRODUCTS_DIR; }; - 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; - 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; - 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; - 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; - 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; - 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; - 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; - 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; - 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; - 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; - 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; - 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 331C80D2294CF70F00263BE5 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 33CC10EA2044A3C60003C045 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 331C80D6294CF71000263BE5 /* RunnerTests */ = { - isa = PBXGroup; - children = ( - 331C80D7294CF71000263BE5 /* RunnerTests.swift */, - ); - path = RunnerTests; - sourceTree = ""; - }; - 33BA886A226E78AF003329D5 /* Configs */ = { - isa = PBXGroup; - children = ( - 33E5194F232828860026EE4D /* AppInfo.xcconfig */, - 9740EEB21CF90195004384FC /* Debug.xcconfig */, - 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, - 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, - ); - path = Configs; - sourceTree = ""; - }; - 33CC10E42044A3C60003C045 = { - isa = PBXGroup; - children = ( - 33FAB671232836740065AC1E /* Runner */, - 33CEB47122A05771004F2AC0 /* Flutter */, - 331C80D6294CF71000263BE5 /* RunnerTests */, - 33CC10EE2044A3C60003C045 /* Products */, - D73912EC22F37F3D000D13A0 /* Frameworks */, - ); - sourceTree = ""; - }; - 33CC10EE2044A3C60003C045 /* Products */ = { - isa = PBXGroup; - children = ( - 33CC10ED2044A3C60003C045 /* aws_flutter_web.app */, - 331C80D5294CF71000263BE5 /* RunnerTests.xctest */, - ); - name = Products; - sourceTree = ""; - }; - 33CC11242044D66E0003C045 /* Resources */ = { - isa = PBXGroup; - children = ( - 33CC10F22044A3C60003C045 /* Assets.xcassets */, - 33CC10F42044A3C60003C045 /* MainMenu.xib */, - 33CC10F72044A3C60003C045 /* Info.plist */, - ); - name = Resources; - path = ..; - sourceTree = ""; - }; - 33CEB47122A05771004F2AC0 /* Flutter */ = { - isa = PBXGroup; - children = ( - 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, - 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, - 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, - 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, - ); - path = Flutter; - sourceTree = ""; - }; - 33FAB671232836740065AC1E /* Runner */ = { - isa = PBXGroup; - children = ( - 33CC10F02044A3C60003C045 /* AppDelegate.swift */, - 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, - 33E51913231747F40026EE4D /* DebugProfile.entitlements */, - 33E51914231749380026EE4D /* Release.entitlements */, - 33CC11242044D66E0003C045 /* Resources */, - 33BA886A226E78AF003329D5 /* Configs */, - ); - path = Runner; - sourceTree = ""; - }; - D73912EC22F37F3D000D13A0 /* Frameworks */ = { - isa = PBXGroup; - children = ( - ); - name = Frameworks; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 331C80D4294CF70F00263BE5 /* RunnerTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; - buildPhases = ( - 331C80D1294CF70F00263BE5 /* Sources */, - 331C80D2294CF70F00263BE5 /* Frameworks */, - 331C80D3294CF70F00263BE5 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 331C80DA294CF71000263BE5 /* PBXTargetDependency */, - ); - name = RunnerTests; - productName = RunnerTests; - productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 33CC10EC2044A3C60003C045 /* Runner */ = { - isa = PBXNativeTarget; - buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; - buildPhases = ( - 33CC10E92044A3C60003C045 /* Sources */, - 33CC10EA2044A3C60003C045 /* Frameworks */, - 33CC10EB2044A3C60003C045 /* Resources */, - 33CC110E2044A8840003C045 /* Bundle Framework */, - 3399D490228B24CF009A79C7 /* ShellScript */, - ); - buildRules = ( - ); - dependencies = ( - 33CC11202044C79F0003C045 /* PBXTargetDependency */, - ); - name = Runner; - productName = Runner; - productReference = 33CC10ED2044A3C60003C045 /* aws_flutter_web.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 33CC10E52044A3C60003C045 /* Project object */ = { - isa = PBXProject; - attributes = { - BuildIndependentTargetsInParallel = YES; - LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1510; - ORGANIZATIONNAME = ""; - TargetAttributes = { - 331C80D4294CF70F00263BE5 = { - CreatedOnToolsVersion = 14.0; - TestTargetID = 33CC10EC2044A3C60003C045; - }; - 33CC10EC2044A3C60003C045 = { - CreatedOnToolsVersion = 9.2; - LastSwiftMigration = 1100; - ProvisioningStyle = Automatic; - SystemCapabilities = { - com.apple.Sandbox = { - enabled = 1; - }; - }; - }; - 33CC111A2044C6BA0003C045 = { - CreatedOnToolsVersion = 9.2; - ProvisioningStyle = Manual; - }; - }; - }; - buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; - compatibilityVersion = "Xcode 9.3"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 33CC10E42044A3C60003C045; - productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 33CC10EC2044A3C60003C045 /* Runner */, - 331C80D4294CF70F00263BE5 /* RunnerTests */, - 33CC111A2044C6BA0003C045 /* Flutter Assemble */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 331C80D3294CF70F00263BE5 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 33CC10EB2044A3C60003C045 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, - 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - 3399D490228B24CF009A79C7 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; - }; - 33CC111E2044C6BF0003C045 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - Flutter/ephemeral/FlutterInputs.xcfilelist, - ); - inputPaths = ( - Flutter/ephemeral/tripwire, - ); - outputFileListPaths = ( - Flutter/ephemeral/FlutterOutputs.xcfilelist, - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 331C80D1294CF70F00263BE5 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 33CC10E92044A3C60003C045 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, - 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, - 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 331C80DA294CF71000263BE5 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 33CC10EC2044A3C60003C045 /* Runner */; - targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */; - }; - 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; - targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin PBXVariantGroup section */ - 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { - isa = PBXVariantGroup; - children = ( - 33CC10F52044A3C60003C045 /* Base */, - ); - name = MainMenu.xib; - path = Runner; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 331C80DB294CF71000263BE5 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 1; - GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.example.awsFlutterWeb.RunnerTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/aws_flutter_web.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/aws_flutter_web"; - }; - name = Debug; - }; - 331C80DC294CF71000263BE5 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 1; - GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.example.awsFlutterWeb.RunnerTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/aws_flutter_web.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/aws_flutter_web"; - }; - name = Release; - }; - 331C80DD294CF71000263BE5 /* Profile */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - CURRENT_PROJECT_VERSION = 1; - GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.example.awsFlutterWeb.RunnerTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/aws_flutter_web.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/aws_flutter_web"; - }; - name = Profile; - }; - 338D0CE9231458BD00FA5F75 /* Profile */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - DEAD_CODE_STRIPPING = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_USER_SCRIPT_SANDBOXING = NO; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = macosx; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - }; - name = Profile; - }; - 338D0CEA231458BD00FA5F75 /* Profile */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - ); - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 5.0; - }; - name = Profile; - }; - 338D0CEB231458BD00FA5F75 /* Profile */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Manual; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Profile; - }; - 33CC10F92044A3C60003C045 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - DEAD_CODE_STRIPPING = YES; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - ENABLE_USER_SCRIPT_SANDBOXING = NO; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = macosx; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - 33CC10FA2044A3C60003C045 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - DEAD_CODE_STRIPPING = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_USER_SCRIPT_SANDBOXING = NO; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = macosx; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - }; - name = Release; - }; - 33CC10FC2044A3C60003C045 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - ); - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; - }; - name = Debug; - }; - 33CC10FD2044A3C60003C045 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - ); - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 5.0; - }; - name = Release; - }; - 33CC111C2044C6BA0003C045 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Manual; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - 33CC111D2044C6BA0003C045 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Automatic; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 331C80DB294CF71000263BE5 /* Debug */, - 331C80DC294CF71000263BE5 /* Release */, - 331C80DD294CF71000263BE5 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 33CC10F92044A3C60003C045 /* Debug */, - 33CC10FA2044A3C60003C045 /* Release */, - 338D0CE9231458BD00FA5F75 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 33CC10FC2044A3C60003C045 /* Debug */, - 33CC10FD2044A3C60003C045 /* Release */, - 338D0CEA231458BD00FA5F75 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 33CC111C2044C6BA0003C045 /* Debug */, - 33CC111D2044C6BA0003C045 /* Release */, - 338D0CEB231458BD00FA5F75 /* Profile */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 33CC10E52044A3C60003C045 /* Project object */; -} diff --git a/examples/aws-flutter-web/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/examples/aws-flutter-web/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d981003d..0000000000 --- a/examples/aws-flutter-web/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/examples/aws-flutter-web/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/examples/aws-flutter-web/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme deleted file mode 100644 index d57ff0ed0a..0000000000 --- a/examples/aws-flutter-web/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/aws-flutter-web/macos/Runner.xcworkspace/contents.xcworkspacedata b/examples/aws-flutter-web/macos/Runner.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 1d526a16ed..0000000000 --- a/examples/aws-flutter-web/macos/Runner.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/examples/aws-flutter-web/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/examples/aws-flutter-web/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d981003d..0000000000 --- a/examples/aws-flutter-web/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/examples/aws-flutter-web/macos/Runner/AppDelegate.swift b/examples/aws-flutter-web/macos/Runner/AppDelegate.swift deleted file mode 100644 index d53ef64377..0000000000 --- a/examples/aws-flutter-web/macos/Runner/AppDelegate.swift +++ /dev/null @@ -1,9 +0,0 @@ -import Cocoa -import FlutterMacOS - -@NSApplicationMain -class AppDelegate: FlutterAppDelegate { - override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { - return true - } -} diff --git a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index a2ec33f19f..0000000000 --- a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "images" : [ - { - "size" : "16x16", - "idiom" : "mac", - "filename" : "app_icon_16.png", - "scale" : "1x" - }, - { - "size" : "16x16", - "idiom" : "mac", - "filename" : "app_icon_32.png", - "scale" : "2x" - }, - { - "size" : "32x32", - "idiom" : "mac", - "filename" : "app_icon_32.png", - "scale" : "1x" - }, - { - "size" : "32x32", - "idiom" : "mac", - "filename" : "app_icon_64.png", - "scale" : "2x" - }, - { - "size" : "128x128", - "idiom" : "mac", - "filename" : "app_icon_128.png", - "scale" : "1x" - }, - { - "size" : "128x128", - "idiom" : "mac", - "filename" : "app_icon_256.png", - "scale" : "2x" - }, - { - "size" : "256x256", - "idiom" : "mac", - "filename" : "app_icon_256.png", - "scale" : "1x" - }, - { - "size" : "256x256", - "idiom" : "mac", - "filename" : "app_icon_512.png", - "scale" : "2x" - }, - { - "size" : "512x512", - "idiom" : "mac", - "filename" : "app_icon_512.png", - "scale" : "1x" - }, - { - "size" : "512x512", - "idiom" : "mac", - "filename" : "app_icon_1024.png", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} diff --git a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png deleted file mode 100644 index 82b6f9d9a3..0000000000 Binary files a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png and /dev/null differ diff --git a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png deleted file mode 100644 index 13b35eba55..0000000000 Binary files a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png and /dev/null differ diff --git a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png deleted file mode 100644 index 0a3f5fa40f..0000000000 Binary files a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png and /dev/null differ diff --git a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png deleted file mode 100644 index bdb57226d5..0000000000 Binary files a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png and /dev/null differ diff --git a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png deleted file mode 100644 index f083318e09..0000000000 Binary files a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png and /dev/null differ diff --git a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png deleted file mode 100644 index 326c0e72c9..0000000000 Binary files a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png and /dev/null differ diff --git a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png deleted file mode 100644 index 2f1632cfdd..0000000000 Binary files a/examples/aws-flutter-web/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png and /dev/null differ diff --git a/examples/aws-flutter-web/macos/Runner/Base.lproj/MainMenu.xib b/examples/aws-flutter-web/macos/Runner/Base.lproj/MainMenu.xib deleted file mode 100644 index 80e867a4e0..0000000000 --- a/examples/aws-flutter-web/macos/Runner/Base.lproj/MainMenu.xib +++ /dev/null @@ -1,343 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/aws-flutter-web/macos/Runner/Configs/AppInfo.xcconfig b/examples/aws-flutter-web/macos/Runner/Configs/AppInfo.xcconfig deleted file mode 100644 index c979ba0a98..0000000000 --- a/examples/aws-flutter-web/macos/Runner/Configs/AppInfo.xcconfig +++ /dev/null @@ -1,14 +0,0 @@ -// Application-level settings for the Runner target. -// -// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the -// future. If not, the values below would default to using the project name when this becomes a -// 'flutter create' template. - -// The application's name. By default this is also the title of the Flutter window. -PRODUCT_NAME = aws_flutter_web - -// The application's bundle identifier -PRODUCT_BUNDLE_IDENTIFIER = com.example.awsFlutterWeb - -// The copyright displayed in application information -PRODUCT_COPYRIGHT = Copyright © 2024 com.example. All rights reserved. diff --git a/examples/aws-flutter-web/macos/Runner/Configs/Debug.xcconfig b/examples/aws-flutter-web/macos/Runner/Configs/Debug.xcconfig deleted file mode 100644 index 36b0fd9464..0000000000 --- a/examples/aws-flutter-web/macos/Runner/Configs/Debug.xcconfig +++ /dev/null @@ -1,2 +0,0 @@ -#include "../../Flutter/Flutter-Debug.xcconfig" -#include "Warnings.xcconfig" diff --git a/examples/aws-flutter-web/macos/Runner/Configs/Release.xcconfig b/examples/aws-flutter-web/macos/Runner/Configs/Release.xcconfig deleted file mode 100644 index dff4f49561..0000000000 --- a/examples/aws-flutter-web/macos/Runner/Configs/Release.xcconfig +++ /dev/null @@ -1,2 +0,0 @@ -#include "../../Flutter/Flutter-Release.xcconfig" -#include "Warnings.xcconfig" diff --git a/examples/aws-flutter-web/macos/Runner/Configs/Warnings.xcconfig b/examples/aws-flutter-web/macos/Runner/Configs/Warnings.xcconfig deleted file mode 100644 index 42bcbf4780..0000000000 --- a/examples/aws-flutter-web/macos/Runner/Configs/Warnings.xcconfig +++ /dev/null @@ -1,13 +0,0 @@ -WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings -GCC_WARN_UNDECLARED_SELECTOR = YES -CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES -CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE -CLANG_WARN__DUPLICATE_METHOD_MATCH = YES -CLANG_WARN_PRAGMA_PACK = YES -CLANG_WARN_STRICT_PROTOTYPES = YES -CLANG_WARN_COMMA = YES -GCC_WARN_STRICT_SELECTOR_MATCH = YES -CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES -CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES -GCC_WARN_SHADOW = YES -CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/examples/aws-flutter-web/macos/Runner/DebugProfile.entitlements b/examples/aws-flutter-web/macos/Runner/DebugProfile.entitlements deleted file mode 100644 index dddb8a30c8..0000000000 --- a/examples/aws-flutter-web/macos/Runner/DebugProfile.entitlements +++ /dev/null @@ -1,12 +0,0 @@ - - - - - com.apple.security.app-sandbox - - com.apple.security.cs.allow-jit - - com.apple.security.network.server - - - diff --git a/examples/aws-flutter-web/macos/Runner/Info.plist b/examples/aws-flutter-web/macos/Runner/Info.plist deleted file mode 100644 index 4789daa6a4..0000000000 --- a/examples/aws-flutter-web/macos/Runner/Info.plist +++ /dev/null @@ -1,32 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIconFile - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - $(FLUTTER_BUILD_NAME) - CFBundleVersion - $(FLUTTER_BUILD_NUMBER) - LSMinimumSystemVersion - $(MACOSX_DEPLOYMENT_TARGET) - NSHumanReadableCopyright - $(PRODUCT_COPYRIGHT) - NSMainNibFile - MainMenu - NSPrincipalClass - NSApplication - - diff --git a/examples/aws-flutter-web/macos/Runner/MainFlutterWindow.swift b/examples/aws-flutter-web/macos/Runner/MainFlutterWindow.swift deleted file mode 100644 index 3cc05eb234..0000000000 --- a/examples/aws-flutter-web/macos/Runner/MainFlutterWindow.swift +++ /dev/null @@ -1,15 +0,0 @@ -import Cocoa -import FlutterMacOS - -class MainFlutterWindow: NSWindow { - override func awakeFromNib() { - let flutterViewController = FlutterViewController() - let windowFrame = self.frame - self.contentViewController = flutterViewController - self.setFrame(windowFrame, display: true) - - RegisterGeneratedPlugins(registry: flutterViewController) - - super.awakeFromNib() - } -} diff --git a/examples/aws-flutter-web/macos/Runner/Release.entitlements b/examples/aws-flutter-web/macos/Runner/Release.entitlements deleted file mode 100644 index 852fa1a472..0000000000 --- a/examples/aws-flutter-web/macos/Runner/Release.entitlements +++ /dev/null @@ -1,8 +0,0 @@ - - - - - com.apple.security.app-sandbox - - - diff --git a/examples/aws-flutter-web/macos/RunnerTests/RunnerTests.swift b/examples/aws-flutter-web/macos/RunnerTests/RunnerTests.swift deleted file mode 100644 index 61f3bd1fc5..0000000000 --- a/examples/aws-flutter-web/macos/RunnerTests/RunnerTests.swift +++ /dev/null @@ -1,12 +0,0 @@ -import Cocoa -import FlutterMacOS -import XCTest - -class RunnerTests: XCTestCase { - - func testExample() { - // If you add code to the Runner application, consider adding tests here. - // See https://developer.apple.com/documentation/xctest for more information about using XCTest. - } - -} diff --git a/examples/aws-flutter-web/pubspec.lock b/examples/aws-flutter-web/pubspec.lock deleted file mode 100644 index 5a8354a000..0000000000 --- a/examples/aws-flutter-web/pubspec.lock +++ /dev/null @@ -1,213 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - async: - dependency: transitive - description: - name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" - url: "https://pub.dev" - source: hosted - version: "2.11.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - characters: - dependency: transitive - description: - name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" - url: "https://pub.dev" - source: hosted - version: "1.3.0" - clock: - dependency: transitive - description: - name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf - url: "https://pub.dev" - source: hosted - version: "1.1.1" - collection: - dependency: transitive - description: - name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a - url: "https://pub.dev" - source: hosted - version: "1.18.0" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 - url: "https://pub.dev" - source: hosted - version: "1.0.8" - fake_async: - dependency: transitive - description: - name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" - url: "https://pub.dev" - source: hosted - version: "1.3.1" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_lints: - dependency: "direct dev" - description: - name: flutter_lints - sha256: "9e8c3858111da373efc5aa341de011d9bd23e2c5c5e0c62bccf32438e192d7b1" - url: "https://pub.dev" - source: hosted - version: "3.0.2" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - leak_tracker: - dependency: transitive - description: - name: leak_tracker - sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" - url: "https://pub.dev" - source: hosted - version: "10.0.4" - leak_tracker_flutter_testing: - dependency: transitive - description: - name: leak_tracker_flutter_testing - sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" - url: "https://pub.dev" - source: hosted - version: "3.0.3" - leak_tracker_testing: - dependency: transitive - description: - name: leak_tracker_testing - sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" - url: "https://pub.dev" - source: hosted - version: "3.0.1" - lints: - dependency: transitive - description: - name: lints - sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 - url: "https://pub.dev" - source: hosted - version: "3.0.0" - matcher: - dependency: transitive - description: - name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb - url: "https://pub.dev" - source: hosted - version: "0.12.16+1" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" - url: "https://pub.dev" - source: hosted - version: "0.8.0" - meta: - dependency: transitive - description: - name: meta - sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" - url: "https://pub.dev" - source: hosted - version: "1.12.0" - path: - dependency: transitive - description: - name: path - sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" - url: "https://pub.dev" - source: hosted - version: "1.9.0" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" - url: "https://pub.dev" - source: hosted - version: "1.10.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" - url: "https://pub.dev" - source: hosted - version: "1.11.1" - stream_channel: - dependency: transitive - description: - name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 - url: "https://pub.dev" - source: hosted - version: "2.1.2" - string_scanner: - dependency: transitive - description: - name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" - source: hosted - version: "1.2.0" - term_glyph: - dependency: transitive - description: - name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" - source: hosted - version: "1.2.1" - test_api: - dependency: transitive - description: - name: test_api - sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" - url: "https://pub.dev" - source: hosted - version: "0.7.0" - vector_math: - dependency: transitive - description: - name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" - url: "https://pub.dev" - source: hosted - version: "2.1.4" - vm_service: - dependency: transitive - description: - name: vm_service - sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" - url: "https://pub.dev" - source: hosted - version: "14.2.1" -sdks: - dart: ">=3.4.1 <4.0.0" - flutter: ">=3.18.0-18.0.pre.54" diff --git a/examples/aws-flutter-web/pubspec.yaml b/examples/aws-flutter-web/pubspec.yaml deleted file mode 100644 index b2467bbe68..0000000000 --- a/examples/aws-flutter-web/pubspec.yaml +++ /dev/null @@ -1,90 +0,0 @@ -name: aws_flutter_web -description: "A new Flutter project." -# The following line prevents the package from being accidentally published to -# pub.dev using `flutter pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev - -# The following defines the version and build number for your application. -# A version number is three numbers separated by dots, like 1.2.43 -# followed by an optional build number separated by a +. -# Both the version and the builder number may be overridden in flutter -# build by specifying --build-name and --build-number, respectively. -# In Android, build-name is used as versionName while build-number used as versionCode. -# Read more about Android versioning at https://developer.android.com/studio/publish/versioning -# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. -# Read more about iOS versioning at -# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -# In Windows, build-name is used as the major, minor, and patch parts -# of the product and file versions while build-number is used as the build suffix. -version: 1.0.0+1 - -environment: - sdk: '>=3.4.1 <4.0.0' - -# Dependencies specify other packages that your package needs in order to work. -# To automatically upgrade your package dependencies to the latest versions -# consider running `flutter pub upgrade --major-versions`. Alternatively, -# dependencies can be manually updated by changing the version numbers below to -# the latest version available on pub.dev. To see which dependencies have newer -# versions available, run `flutter pub outdated`. -dependencies: - flutter: - sdk: flutter - - - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.6 - -dev_dependencies: - flutter_test: - sdk: flutter - - # The "flutter_lints" package below contains a set of recommended lints to - # encourage good coding practices. The lint set provided by the package is - # activated in the `analysis_options.yaml` file located at the root of your - # package. See that file for information about deactivating specific lint - # rules and activating additional ones. - flutter_lints: ^3.0.0 - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. -flutter: - - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. - uses-material-design: true - - # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/assets-and-images/#from-packages - - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages diff --git a/examples/aws-flutter-web/sst.config.ts b/examples/aws-flutter-web/sst.config.ts deleted file mode 100644 index 688d10a07c..0000000000 --- a/examples/aws-flutter-web/sst.config.ts +++ /dev/null @@ -1,24 +0,0 @@ -/// - -/** - * ## Flutter web - * - * Deploy a Flutter web app as a static site to S3 and CloudFront. - */ -export default $config({ - app(input) { - return { - name: "aws-flutter-web", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - new sst.aws.StaticSite("MySite", { - build: { - command: "flutter build web", - output: "build/web", - }, - }); - }, -}); diff --git a/examples/aws-flutter-web/test/widget_test.dart b/examples/aws-flutter-web/test/widget_test.dart deleted file mode 100644 index c538691767..0000000000 --- a/examples/aws-flutter-web/test/widget_test.dart +++ /dev/null @@ -1,30 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility in the flutter_test package. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -import 'package:aws_flutter_web/main.dart'; - -void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); - - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); - - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); - await tester.pump(); - - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); - }); -} diff --git a/examples/aws-flutter-web/web/favicon.png b/examples/aws-flutter-web/web/favicon.png deleted file mode 100644 index 8aaa46ac1a..0000000000 Binary files a/examples/aws-flutter-web/web/favicon.png and /dev/null differ diff --git a/examples/aws-flutter-web/web/icons/Icon-192.png b/examples/aws-flutter-web/web/icons/Icon-192.png deleted file mode 100644 index b749bfef07..0000000000 Binary files a/examples/aws-flutter-web/web/icons/Icon-192.png and /dev/null differ diff --git a/examples/aws-flutter-web/web/icons/Icon-512.png b/examples/aws-flutter-web/web/icons/Icon-512.png deleted file mode 100644 index 88cfd48dff..0000000000 Binary files a/examples/aws-flutter-web/web/icons/Icon-512.png and /dev/null differ diff --git a/examples/aws-flutter-web/web/icons/Icon-maskable-192.png b/examples/aws-flutter-web/web/icons/Icon-maskable-192.png deleted file mode 100644 index eb9b4d76e5..0000000000 Binary files a/examples/aws-flutter-web/web/icons/Icon-maskable-192.png and /dev/null differ diff --git a/examples/aws-flutter-web/web/icons/Icon-maskable-512.png b/examples/aws-flutter-web/web/icons/Icon-maskable-512.png deleted file mode 100644 index d69c56691f..0000000000 Binary files a/examples/aws-flutter-web/web/icons/Icon-maskable-512.png and /dev/null differ diff --git a/examples/aws-flutter-web/web/index.html b/examples/aws-flutter-web/web/index.html deleted file mode 100644 index 4ba5cb2465..0000000000 --- a/examples/aws-flutter-web/web/index.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - aws_flutter_web - - - - - - diff --git a/examples/aws-flutter-web/web/manifest.json b/examples/aws-flutter-web/web/manifest.json deleted file mode 100644 index c27ccaa1dc..0000000000 --- a/examples/aws-flutter-web/web/manifest.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "aws_flutter_web", - "short_name": "aws_flutter_web", - "start_url": ".", - "display": "standalone", - "background_color": "#0175C2", - "theme_color": "#0175C2", - "description": "A new Flutter project.", - "orientation": "portrait-primary", - "prefer_related_applications": false, - "icons": [ - { - "src": "icons/Icon-192.png", - "sizes": "192x192", - "type": "image/png" - }, - { - "src": "icons/Icon-512.png", - "sizes": "512x512", - "type": "image/png" - }, - { - "src": "icons/Icon-maskable-192.png", - "sizes": "192x192", - "type": "image/png", - "purpose": "maskable" - }, - { - "src": "icons/Icon-maskable-512.png", - "sizes": "512x512", - "type": "image/png", - "purpose": "maskable" - } - ] -} diff --git a/examples/aws-flutter-web/windows/.gitignore b/examples/aws-flutter-web/windows/.gitignore deleted file mode 100644 index d492d0d98c..0000000000 --- a/examples/aws-flutter-web/windows/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -flutter/ephemeral/ - -# Visual Studio user-specific files. -*.suo -*.user -*.userosscache -*.sln.docstates - -# Visual Studio build-related files. -x64/ -x86/ - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ diff --git a/examples/aws-flutter-web/windows/CMakeLists.txt b/examples/aws-flutter-web/windows/CMakeLists.txt deleted file mode 100644 index d98ad262f1..0000000000 --- a/examples/aws-flutter-web/windows/CMakeLists.txt +++ /dev/null @@ -1,108 +0,0 @@ -# Project-level configuration. -cmake_minimum_required(VERSION 3.14) -project(aws_flutter_web LANGUAGES CXX) - -# The name of the executable created for the application. Change this to change -# the on-disk name of your application. -set(BINARY_NAME "aws_flutter_web") - -# Explicitly opt in to modern CMake behaviors to avoid warnings with recent -# versions of CMake. -cmake_policy(VERSION 3.14...3.25) - -# Define build configuration option. -get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -if(IS_MULTICONFIG) - set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" - CACHE STRING "" FORCE) -else() - if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - set(CMAKE_BUILD_TYPE "Debug" CACHE - STRING "Flutter build mode" FORCE) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS - "Debug" "Profile" "Release") - endif() -endif() -# Define settings for the Profile build mode. -set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") -set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") -set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") -set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") - -# Use Unicode for all projects. -add_definitions(-DUNICODE -D_UNICODE) - -# Compilation settings that should be applied to most targets. -# -# Be cautious about adding new options here, as plugins use this function by -# default. In most cases, you should add new options to specific targets instead -# of modifying this function. -function(APPLY_STANDARD_SETTINGS TARGET) - target_compile_features(${TARGET} PUBLIC cxx_std_17) - target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") - target_compile_options(${TARGET} PRIVATE /EHsc) - target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") - target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") -endfunction() - -# Flutter library and tool build rules. -set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") -add_subdirectory(${FLUTTER_MANAGED_DIR}) - -# Application build; see runner/CMakeLists.txt. -add_subdirectory("runner") - - -# Generated plugin build rules, which manage building the plugins and adding -# them to the application. -include(flutter/generated_plugins.cmake) - - -# === Installation === -# Support files are copied into place next to the executable, so that it can -# run in place. This is done instead of making a separate bundle (as on Linux) -# so that building and running from within Visual Studio will work. -set(BUILD_BUNDLE_DIR "$") -# Make the "install" step default, as it's required to run. -set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) -endif() - -set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") -set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") - -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" - COMPONENT Runtime) - -install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" - COMPONENT Runtime) - -install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) - -if(PLUGIN_BUNDLED_LIBRARIES) - install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" - DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) -endif() - -# Copy the native assets provided by the build.dart from all packages. -set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") -install(DIRECTORY "${NATIVE_ASSETS_DIR}" - DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) - -# Fully re-copy the assets directory on each build to avoid having stale files -# from a previous install. -set(FLUTTER_ASSET_DIR_NAME "flutter_assets") -install(CODE " - file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") - " COMPONENT Runtime) -install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" - DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) - -# Install the AOT library on non-Debug builds only. -install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" - CONFIGURATIONS Profile;Release - COMPONENT Runtime) diff --git a/examples/aws-flutter-web/windows/flutter/CMakeLists.txt b/examples/aws-flutter-web/windows/flutter/CMakeLists.txt deleted file mode 100644 index 903f4899d6..0000000000 --- a/examples/aws-flutter-web/windows/flutter/CMakeLists.txt +++ /dev/null @@ -1,109 +0,0 @@ -# This file controls Flutter-level build steps. It should not be edited. -cmake_minimum_required(VERSION 3.14) - -set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") - -# Configuration provided via flutter tool. -include(${EPHEMERAL_DIR}/generated_config.cmake) - -# TODO: Move the rest of this into files in ephemeral. See -# https://github.com/flutter/flutter/issues/57146. -set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") - -# Set fallback configurations for older versions of the flutter tool. -if (NOT DEFINED FLUTTER_TARGET_PLATFORM) - set(FLUTTER_TARGET_PLATFORM "windows-x64") -endif() - -# === Flutter Library === -set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") - -# Published to parent scope for install step. -set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) -set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) -set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) -set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) - -list(APPEND FLUTTER_LIBRARY_HEADERS - "flutter_export.h" - "flutter_windows.h" - "flutter_messenger.h" - "flutter_plugin_registrar.h" - "flutter_texture_registrar.h" -) -list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") -add_library(flutter INTERFACE) -target_include_directories(flutter INTERFACE - "${EPHEMERAL_DIR}" -) -target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") -add_dependencies(flutter flutter_assemble) - -# === Wrapper === -list(APPEND CPP_WRAPPER_SOURCES_CORE - "core_implementations.cc" - "standard_codec.cc" -) -list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") -list(APPEND CPP_WRAPPER_SOURCES_PLUGIN - "plugin_registrar.cc" -) -list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") -list(APPEND CPP_WRAPPER_SOURCES_APP - "flutter_engine.cc" - "flutter_view_controller.cc" -) -list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") - -# Wrapper sources needed for a plugin. -add_library(flutter_wrapper_plugin STATIC - ${CPP_WRAPPER_SOURCES_CORE} - ${CPP_WRAPPER_SOURCES_PLUGIN} -) -apply_standard_settings(flutter_wrapper_plugin) -set_target_properties(flutter_wrapper_plugin PROPERTIES - POSITION_INDEPENDENT_CODE ON) -set_target_properties(flutter_wrapper_plugin PROPERTIES - CXX_VISIBILITY_PRESET hidden) -target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) -target_include_directories(flutter_wrapper_plugin PUBLIC - "${WRAPPER_ROOT}/include" -) -add_dependencies(flutter_wrapper_plugin flutter_assemble) - -# Wrapper sources needed for the runner. -add_library(flutter_wrapper_app STATIC - ${CPP_WRAPPER_SOURCES_CORE} - ${CPP_WRAPPER_SOURCES_APP} -) -apply_standard_settings(flutter_wrapper_app) -target_link_libraries(flutter_wrapper_app PUBLIC flutter) -target_include_directories(flutter_wrapper_app PUBLIC - "${WRAPPER_ROOT}/include" -) -add_dependencies(flutter_wrapper_app flutter_assemble) - -# === Flutter tool backend === -# _phony_ is a non-existent file to force this command to run every time, -# since currently there's no way to get a full input/output list from the -# flutter tool. -set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") -set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) -add_custom_command( - OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} - ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} - ${CPP_WRAPPER_SOURCES_APP} - ${PHONY_OUTPUT} - COMMAND ${CMAKE_COMMAND} -E env - ${FLUTTER_TOOL_ENVIRONMENT} - "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" - ${FLUTTER_TARGET_PLATFORM} $ - VERBATIM -) -add_custom_target(flutter_assemble DEPENDS - "${FLUTTER_LIBRARY}" - ${FLUTTER_LIBRARY_HEADERS} - ${CPP_WRAPPER_SOURCES_CORE} - ${CPP_WRAPPER_SOURCES_PLUGIN} - ${CPP_WRAPPER_SOURCES_APP} -) diff --git a/examples/aws-flutter-web/windows/flutter/generated_plugin_registrant.cc b/examples/aws-flutter-web/windows/flutter/generated_plugin_registrant.cc deleted file mode 100644 index 8b6d4680af..0000000000 --- a/examples/aws-flutter-web/windows/flutter/generated_plugin_registrant.cc +++ /dev/null @@ -1,11 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#include "generated_plugin_registrant.h" - - -void RegisterPlugins(flutter::PluginRegistry* registry) { -} diff --git a/examples/aws-flutter-web/windows/flutter/generated_plugin_registrant.h b/examples/aws-flutter-web/windows/flutter/generated_plugin_registrant.h deleted file mode 100644 index dc139d85a9..0000000000 --- a/examples/aws-flutter-web/windows/flutter/generated_plugin_registrant.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#ifndef GENERATED_PLUGIN_REGISTRANT_ -#define GENERATED_PLUGIN_REGISTRANT_ - -#include - -// Registers Flutter plugins. -void RegisterPlugins(flutter::PluginRegistry* registry); - -#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/examples/aws-flutter-web/windows/flutter/generated_plugins.cmake b/examples/aws-flutter-web/windows/flutter/generated_plugins.cmake deleted file mode 100644 index b93c4c30c1..0000000000 --- a/examples/aws-flutter-web/windows/flutter/generated_plugins.cmake +++ /dev/null @@ -1,23 +0,0 @@ -# -# Generated file, do not edit. -# - -list(APPEND FLUTTER_PLUGIN_LIST -) - -list(APPEND FLUTTER_FFI_PLUGIN_LIST -) - -set(PLUGIN_BUNDLED_LIBRARIES) - -foreach(plugin ${FLUTTER_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) - target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) - list(APPEND PLUGIN_BUNDLED_LIBRARIES $) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) -endforeach(plugin) - -foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) -endforeach(ffi_plugin) diff --git a/examples/aws-flutter-web/windows/runner/CMakeLists.txt b/examples/aws-flutter-web/windows/runner/CMakeLists.txt deleted file mode 100644 index 394917c053..0000000000 --- a/examples/aws-flutter-web/windows/runner/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -cmake_minimum_required(VERSION 3.14) -project(runner LANGUAGES CXX) - -# Define the application target. To change its name, change BINARY_NAME in the -# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer -# work. -# -# Any new source files that you add to the application should be added here. -add_executable(${BINARY_NAME} WIN32 - "flutter_window.cpp" - "main.cpp" - "utils.cpp" - "win32_window.cpp" - "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" - "Runner.rc" - "runner.exe.manifest" -) - -# Apply the standard set of build settings. This can be removed for applications -# that need different build settings. -apply_standard_settings(${BINARY_NAME}) - -# Add preprocessor definitions for the build version. -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") - -# Disable Windows macros that collide with C++ standard library functions. -target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") - -# Add dependency libraries and include directories. Add any application-specific -# dependencies here. -target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) -target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") -target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") - -# Run the Flutter tool portions of the build. This must not be removed. -add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/examples/aws-flutter-web/windows/runner/Runner.rc b/examples/aws-flutter-web/windows/runner/Runner.rc deleted file mode 100644 index 92f602fc3c..0000000000 --- a/examples/aws-flutter-web/windows/runner/Runner.rc +++ /dev/null @@ -1,121 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#pragma code_page(65001) -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "winres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""winres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_APP_ICON ICON "resources\\app_icon.ico" - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) -#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD -#else -#define VERSION_AS_NUMBER 1,0,0,0 -#endif - -#if defined(FLUTTER_VERSION) -#define VERSION_AS_STRING FLUTTER_VERSION -#else -#define VERSION_AS_STRING "1.0.0" -#endif - -VS_VERSION_INFO VERSIONINFO - FILEVERSION VERSION_AS_NUMBER - PRODUCTVERSION VERSION_AS_NUMBER - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0x0L -#endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_APP - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904e4" - BEGIN - VALUE "CompanyName", "com.example" "\0" - VALUE "FileDescription", "aws_flutter_web" "\0" - VALUE "FileVersion", VERSION_AS_STRING "\0" - VALUE "InternalName", "aws_flutter_web" "\0" - VALUE "LegalCopyright", "Copyright (C) 2024 com.example. All rights reserved." "\0" - VALUE "OriginalFilename", "aws_flutter_web.exe" "\0" - VALUE "ProductName", "aws_flutter_web" "\0" - VALUE "ProductVersion", VERSION_AS_STRING "\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1252 - END -END - -#endif // English (United States) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED diff --git a/examples/aws-flutter-web/windows/runner/flutter_window.cpp b/examples/aws-flutter-web/windows/runner/flutter_window.cpp deleted file mode 100644 index 955ee3038f..0000000000 --- a/examples/aws-flutter-web/windows/runner/flutter_window.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "flutter_window.h" - -#include - -#include "flutter/generated_plugin_registrant.h" - -FlutterWindow::FlutterWindow(const flutter::DartProject& project) - : project_(project) {} - -FlutterWindow::~FlutterWindow() {} - -bool FlutterWindow::OnCreate() { - if (!Win32Window::OnCreate()) { - return false; - } - - RECT frame = GetClientArea(); - - // The size here must match the window dimensions to avoid unnecessary surface - // creation / destruction in the startup path. - flutter_controller_ = std::make_unique( - frame.right - frame.left, frame.bottom - frame.top, project_); - // Ensure that basic setup of the controller was successful. - if (!flutter_controller_->engine() || !flutter_controller_->view()) { - return false; - } - RegisterPlugins(flutter_controller_->engine()); - SetChildContent(flutter_controller_->view()->GetNativeWindow()); - - flutter_controller_->engine()->SetNextFrameCallback([&]() { - this->Show(); - }); - - // Flutter can complete the first frame before the "show window" callback is - // registered. The following call ensures a frame is pending to ensure the - // window is shown. It is a no-op if the first frame hasn't completed yet. - flutter_controller_->ForceRedraw(); - - return true; -} - -void FlutterWindow::OnDestroy() { - if (flutter_controller_) { - flutter_controller_ = nullptr; - } - - Win32Window::OnDestroy(); -} - -LRESULT -FlutterWindow::MessageHandler(HWND hwnd, UINT const message, - WPARAM const wparam, - LPARAM const lparam) noexcept { - // Give Flutter, including plugins, an opportunity to handle window messages. - if (flutter_controller_) { - std::optional result = - flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, - lparam); - if (result) { - return *result; - } - } - - switch (message) { - case WM_FONTCHANGE: - flutter_controller_->engine()->ReloadSystemFonts(); - break; - } - - return Win32Window::MessageHandler(hwnd, message, wparam, lparam); -} diff --git a/examples/aws-flutter-web/windows/runner/flutter_window.h b/examples/aws-flutter-web/windows/runner/flutter_window.h deleted file mode 100644 index 6da0652f05..0000000000 --- a/examples/aws-flutter-web/windows/runner/flutter_window.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef RUNNER_FLUTTER_WINDOW_H_ -#define RUNNER_FLUTTER_WINDOW_H_ - -#include -#include - -#include - -#include "win32_window.h" - -// A window that does nothing but host a Flutter view. -class FlutterWindow : public Win32Window { - public: - // Creates a new FlutterWindow hosting a Flutter view running |project|. - explicit FlutterWindow(const flutter::DartProject& project); - virtual ~FlutterWindow(); - - protected: - // Win32Window: - bool OnCreate() override; - void OnDestroy() override; - LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, - LPARAM const lparam) noexcept override; - - private: - // The project to run. - flutter::DartProject project_; - - // The Flutter instance hosted by this window. - std::unique_ptr flutter_controller_; -}; - -#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/examples/aws-flutter-web/windows/runner/main.cpp b/examples/aws-flutter-web/windows/runner/main.cpp deleted file mode 100644 index 420f00b523..0000000000 --- a/examples/aws-flutter-web/windows/runner/main.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include - -#include "flutter_window.h" -#include "utils.h" - -int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, - _In_ wchar_t *command_line, _In_ int show_command) { - // Attach to console when present (e.g., 'flutter run') or create a - // new console when running with a debugger. - if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { - CreateAndAttachConsole(); - } - - // Initialize COM, so that it is available for use in the library and/or - // plugins. - ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); - - flutter::DartProject project(L"data"); - - std::vector command_line_arguments = - GetCommandLineArguments(); - - project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); - - FlutterWindow window(project); - Win32Window::Point origin(10, 10); - Win32Window::Size size(1280, 720); - if (!window.Create(L"aws_flutter_web", origin, size)) { - return EXIT_FAILURE; - } - window.SetQuitOnClose(true); - - ::MSG msg; - while (::GetMessage(&msg, nullptr, 0, 0)) { - ::TranslateMessage(&msg); - ::DispatchMessage(&msg); - } - - ::CoUninitialize(); - return EXIT_SUCCESS; -} diff --git a/examples/aws-flutter-web/windows/runner/resource.h b/examples/aws-flutter-web/windows/runner/resource.h deleted file mode 100644 index 66a65d1e4a..0000000000 --- a/examples/aws-flutter-web/windows/runner/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by Runner.rc -// -#define IDI_APP_ICON 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/examples/aws-flutter-web/windows/runner/resources/app_icon.ico b/examples/aws-flutter-web/windows/runner/resources/app_icon.ico deleted file mode 100644 index c04e20caf6..0000000000 Binary files a/examples/aws-flutter-web/windows/runner/resources/app_icon.ico and /dev/null differ diff --git a/examples/aws-flutter-web/windows/runner/runner.exe.manifest b/examples/aws-flutter-web/windows/runner/runner.exe.manifest deleted file mode 100644 index a42ea7687c..0000000000 --- a/examples/aws-flutter-web/windows/runner/runner.exe.manifest +++ /dev/null @@ -1,20 +0,0 @@ - - - - - PerMonitorV2 - - - - - - - - - - - - - - - diff --git a/examples/aws-flutter-web/windows/runner/utils.cpp b/examples/aws-flutter-web/windows/runner/utils.cpp deleted file mode 100644 index 3a0b46511a..0000000000 --- a/examples/aws-flutter-web/windows/runner/utils.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "utils.h" - -#include -#include -#include -#include - -#include - -void CreateAndAttachConsole() { - if (::AllocConsole()) { - FILE *unused; - if (freopen_s(&unused, "CONOUT$", "w", stdout)) { - _dup2(_fileno(stdout), 1); - } - if (freopen_s(&unused, "CONOUT$", "w", stderr)) { - _dup2(_fileno(stdout), 2); - } - std::ios::sync_with_stdio(); - FlutterDesktopResyncOutputStreams(); - } -} - -std::vector GetCommandLineArguments() { - // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. - int argc; - wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); - if (argv == nullptr) { - return std::vector(); - } - - std::vector command_line_arguments; - - // Skip the first argument as it's the binary name. - for (int i = 1; i < argc; i++) { - command_line_arguments.push_back(Utf8FromUtf16(argv[i])); - } - - ::LocalFree(argv); - - return command_line_arguments; -} - -std::string Utf8FromUtf16(const wchar_t* utf16_string) { - if (utf16_string == nullptr) { - return std::string(); - } - unsigned int target_length = ::WideCharToMultiByte( - CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, - -1, nullptr, 0, nullptr, nullptr) - -1; // remove the trailing null character - int input_length = (int)wcslen(utf16_string); - std::string utf8_string; - if (target_length == 0 || target_length > utf8_string.max_size()) { - return utf8_string; - } - utf8_string.resize(target_length); - int converted_length = ::WideCharToMultiByte( - CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, - input_length, utf8_string.data(), target_length, nullptr, nullptr); - if (converted_length == 0) { - return std::string(); - } - return utf8_string; -} diff --git a/examples/aws-flutter-web/windows/runner/utils.h b/examples/aws-flutter-web/windows/runner/utils.h deleted file mode 100644 index 3879d54755..0000000000 --- a/examples/aws-flutter-web/windows/runner/utils.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef RUNNER_UTILS_H_ -#define RUNNER_UTILS_H_ - -#include -#include - -// Creates a console for the process, and redirects stdout and stderr to -// it for both the runner and the Flutter library. -void CreateAndAttachConsole(); - -// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string -// encoded in UTF-8. Returns an empty std::string on failure. -std::string Utf8FromUtf16(const wchar_t* utf16_string); - -// Gets the command line arguments passed in as a std::vector, -// encoded in UTF-8. Returns an empty std::vector on failure. -std::vector GetCommandLineArguments(); - -#endif // RUNNER_UTILS_H_ diff --git a/examples/aws-flutter-web/windows/runner/win32_window.cpp b/examples/aws-flutter-web/windows/runner/win32_window.cpp deleted file mode 100644 index 60608d0fe5..0000000000 --- a/examples/aws-flutter-web/windows/runner/win32_window.cpp +++ /dev/null @@ -1,288 +0,0 @@ -#include "win32_window.h" - -#include -#include - -#include "resource.h" - -namespace { - -/// Window attribute that enables dark mode window decorations. -/// -/// Redefined in case the developer's machine has a Windows SDK older than -/// version 10.0.22000.0. -/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute -#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE -#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 -#endif - -constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; - -/// Registry key for app theme preference. -/// -/// A value of 0 indicates apps should use dark mode. A non-zero or missing -/// value indicates apps should use light mode. -constexpr const wchar_t kGetPreferredBrightnessRegKey[] = - L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; -constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; - -// The number of Win32Window objects that currently exist. -static int g_active_window_count = 0; - -using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); - -// Scale helper to convert logical scaler values to physical using passed in -// scale factor -int Scale(int source, double scale_factor) { - return static_cast(source * scale_factor); -} - -// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. -// This API is only needed for PerMonitor V1 awareness mode. -void EnableFullDpiSupportIfAvailable(HWND hwnd) { - HMODULE user32_module = LoadLibraryA("User32.dll"); - if (!user32_module) { - return; - } - auto enable_non_client_dpi_scaling = - reinterpret_cast( - GetProcAddress(user32_module, "EnableNonClientDpiScaling")); - if (enable_non_client_dpi_scaling != nullptr) { - enable_non_client_dpi_scaling(hwnd); - } - FreeLibrary(user32_module); -} - -} // namespace - -// Manages the Win32Window's window class registration. -class WindowClassRegistrar { - public: - ~WindowClassRegistrar() = default; - - // Returns the singleton registrar instance. - static WindowClassRegistrar* GetInstance() { - if (!instance_) { - instance_ = new WindowClassRegistrar(); - } - return instance_; - } - - // Returns the name of the window class, registering the class if it hasn't - // previously been registered. - const wchar_t* GetWindowClass(); - - // Unregisters the window class. Should only be called if there are no - // instances of the window. - void UnregisterWindowClass(); - - private: - WindowClassRegistrar() = default; - - static WindowClassRegistrar* instance_; - - bool class_registered_ = false; -}; - -WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; - -const wchar_t* WindowClassRegistrar::GetWindowClass() { - if (!class_registered_) { - WNDCLASS window_class{}; - window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); - window_class.lpszClassName = kWindowClassName; - window_class.style = CS_HREDRAW | CS_VREDRAW; - window_class.cbClsExtra = 0; - window_class.cbWndExtra = 0; - window_class.hInstance = GetModuleHandle(nullptr); - window_class.hIcon = - LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); - window_class.hbrBackground = 0; - window_class.lpszMenuName = nullptr; - window_class.lpfnWndProc = Win32Window::WndProc; - RegisterClass(&window_class); - class_registered_ = true; - } - return kWindowClassName; -} - -void WindowClassRegistrar::UnregisterWindowClass() { - UnregisterClass(kWindowClassName, nullptr); - class_registered_ = false; -} - -Win32Window::Win32Window() { - ++g_active_window_count; -} - -Win32Window::~Win32Window() { - --g_active_window_count; - Destroy(); -} - -bool Win32Window::Create(const std::wstring& title, - const Point& origin, - const Size& size) { - Destroy(); - - const wchar_t* window_class = - WindowClassRegistrar::GetInstance()->GetWindowClass(); - - const POINT target_point = {static_cast(origin.x), - static_cast(origin.y)}; - HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); - UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); - double scale_factor = dpi / 96.0; - - HWND window = CreateWindow( - window_class, title.c_str(), WS_OVERLAPPEDWINDOW, - Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), - Scale(size.width, scale_factor), Scale(size.height, scale_factor), - nullptr, nullptr, GetModuleHandle(nullptr), this); - - if (!window) { - return false; - } - - UpdateTheme(window); - - return OnCreate(); -} - -bool Win32Window::Show() { - return ShowWindow(window_handle_, SW_SHOWNORMAL); -} - -// static -LRESULT CALLBACK Win32Window::WndProc(HWND const window, - UINT const message, - WPARAM const wparam, - LPARAM const lparam) noexcept { - if (message == WM_NCCREATE) { - auto window_struct = reinterpret_cast(lparam); - SetWindowLongPtr(window, GWLP_USERDATA, - reinterpret_cast(window_struct->lpCreateParams)); - - auto that = static_cast(window_struct->lpCreateParams); - EnableFullDpiSupportIfAvailable(window); - that->window_handle_ = window; - } else if (Win32Window* that = GetThisFromHandle(window)) { - return that->MessageHandler(window, message, wparam, lparam); - } - - return DefWindowProc(window, message, wparam, lparam); -} - -LRESULT -Win32Window::MessageHandler(HWND hwnd, - UINT const message, - WPARAM const wparam, - LPARAM const lparam) noexcept { - switch (message) { - case WM_DESTROY: - window_handle_ = nullptr; - Destroy(); - if (quit_on_close_) { - PostQuitMessage(0); - } - return 0; - - case WM_DPICHANGED: { - auto newRectSize = reinterpret_cast(lparam); - LONG newWidth = newRectSize->right - newRectSize->left; - LONG newHeight = newRectSize->bottom - newRectSize->top; - - SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, - newHeight, SWP_NOZORDER | SWP_NOACTIVATE); - - return 0; - } - case WM_SIZE: { - RECT rect = GetClientArea(); - if (child_content_ != nullptr) { - // Size and position the child window. - MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, - rect.bottom - rect.top, TRUE); - } - return 0; - } - - case WM_ACTIVATE: - if (child_content_ != nullptr) { - SetFocus(child_content_); - } - return 0; - - case WM_DWMCOLORIZATIONCOLORCHANGED: - UpdateTheme(hwnd); - return 0; - } - - return DefWindowProc(window_handle_, message, wparam, lparam); -} - -void Win32Window::Destroy() { - OnDestroy(); - - if (window_handle_) { - DestroyWindow(window_handle_); - window_handle_ = nullptr; - } - if (g_active_window_count == 0) { - WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); - } -} - -Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { - return reinterpret_cast( - GetWindowLongPtr(window, GWLP_USERDATA)); -} - -void Win32Window::SetChildContent(HWND content) { - child_content_ = content; - SetParent(content, window_handle_); - RECT frame = GetClientArea(); - - MoveWindow(content, frame.left, frame.top, frame.right - frame.left, - frame.bottom - frame.top, true); - - SetFocus(child_content_); -} - -RECT Win32Window::GetClientArea() { - RECT frame; - GetClientRect(window_handle_, &frame); - return frame; -} - -HWND Win32Window::GetHandle() { - return window_handle_; -} - -void Win32Window::SetQuitOnClose(bool quit_on_close) { - quit_on_close_ = quit_on_close; -} - -bool Win32Window::OnCreate() { - // No-op; provided for subclasses. - return true; -} - -void Win32Window::OnDestroy() { - // No-op; provided for subclasses. -} - -void Win32Window::UpdateTheme(HWND const window) { - DWORD light_mode; - DWORD light_mode_size = sizeof(light_mode); - LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, - kGetPreferredBrightnessRegValue, - RRF_RT_REG_DWORD, nullptr, &light_mode, - &light_mode_size); - - if (result == ERROR_SUCCESS) { - BOOL enable_dark_mode = light_mode == 0; - DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, - &enable_dark_mode, sizeof(enable_dark_mode)); - } -} diff --git a/examples/aws-flutter-web/windows/runner/win32_window.h b/examples/aws-flutter-web/windows/runner/win32_window.h deleted file mode 100644 index e901dde684..0000000000 --- a/examples/aws-flutter-web/windows/runner/win32_window.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef RUNNER_WIN32_WINDOW_H_ -#define RUNNER_WIN32_WINDOW_H_ - -#include - -#include -#include -#include - -// A class abstraction for a high DPI-aware Win32 Window. Intended to be -// inherited from by classes that wish to specialize with custom -// rendering and input handling -class Win32Window { - public: - struct Point { - unsigned int x; - unsigned int y; - Point(unsigned int x, unsigned int y) : x(x), y(y) {} - }; - - struct Size { - unsigned int width; - unsigned int height; - Size(unsigned int width, unsigned int height) - : width(width), height(height) {} - }; - - Win32Window(); - virtual ~Win32Window(); - - // Creates a win32 window with |title| that is positioned and sized using - // |origin| and |size|. New windows are created on the default monitor. Window - // sizes are specified to the OS in physical pixels, hence to ensure a - // consistent size this function will scale the inputted width and height as - // as appropriate for the default monitor. The window is invisible until - // |Show| is called. Returns true if the window was created successfully. - bool Create(const std::wstring& title, const Point& origin, const Size& size); - - // Show the current window. Returns true if the window was successfully shown. - bool Show(); - - // Release OS resources associated with window. - void Destroy(); - - // Inserts |content| into the window tree. - void SetChildContent(HWND content); - - // Returns the backing Window handle to enable clients to set icon and other - // window properties. Returns nullptr if the window has been destroyed. - HWND GetHandle(); - - // If true, closing this window will quit the application. - void SetQuitOnClose(bool quit_on_close); - - // Return a RECT representing the bounds of the current client area. - RECT GetClientArea(); - - protected: - // Processes and route salient window messages for mouse handling, - // size change and DPI. Delegates handling of these to member overloads that - // inheriting classes can handle. - virtual LRESULT MessageHandler(HWND window, - UINT const message, - WPARAM const wparam, - LPARAM const lparam) noexcept; - - // Called when CreateAndShow is called, allowing subclass window-related - // setup. Subclasses should return false if setup fails. - virtual bool OnCreate(); - - // Called when Destroy is called. - virtual void OnDestroy(); - - private: - friend class WindowClassRegistrar; - - // OS callback called by message pump. Handles the WM_NCCREATE message which - // is passed when the non-client area is being created and enables automatic - // non-client DPI scaling so that the non-client area automatically - // responds to changes in DPI. All other messages are handled by - // MessageHandler. - static LRESULT CALLBACK WndProc(HWND const window, - UINT const message, - WPARAM const wparam, - LPARAM const lparam) noexcept; - - // Retrieves a class instance pointer for |window| - static Win32Window* GetThisFromHandle(HWND const window) noexcept; - - // Update the window frame's theme to match the system theme. - static void UpdateTheme(HWND const window); - - bool quit_on_close_ = false; - - // window handle for top level window. - HWND window_handle_ = nullptr; - - // window handle for hosted content. - HWND child_content_ = nullptr; -}; - -#endif // RUNNER_WIN32_WINDOW_H_ diff --git a/examples/aws-go-api-gateway-v2/package.json b/examples/aws-go-api-gateway-v2/package.json deleted file mode 100644 index 73e5fb2b94..0000000000 --- a/examples/aws-go-api-gateway-v2/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "aws-go-api-gateway-v2", - "module": "index.ts", - "type": "module", - "devDependencies": { - "@types/aws-lambda": "8.10.146", - "@types/bun": "latest" - }, - "peerDependencies": { - "typescript": "^5.0.0" - }, - "dependencies": { - "sst": "file:../../sdk/js" - }, - "scripts": { - "dev": "bun sst dev" - } -} \ No newline at end of file diff --git a/examples/aws-go-api-gateway-v2/src/go.mod b/examples/aws-go-api-gateway-v2/src/go.mod deleted file mode 100644 index 518c0cb85f..0000000000 --- a/examples/aws-go-api-gateway-v2/src/go.mod +++ /dev/null @@ -1,8 +0,0 @@ -module sst-go-api - -go 1.23.3 - -require ( - github.com/aws/aws-lambda-go v1.47.0 // indirect - github.com/awslabs/aws-lambda-go-api-proxy v0.16.2 // indirect -) diff --git a/examples/aws-go-api-gateway-v2/src/go.sum b/examples/aws-go-api-gateway-v2/src/go.sum deleted file mode 100644 index 778c713c31..0000000000 --- a/examples/aws-go-api-gateway-v2/src/go.sum +++ /dev/null @@ -1,4 +0,0 @@ -github.com/aws/aws-lambda-go v1.47.0 h1:0H8s0vumYx/YKs4sE7YM0ktwL2eWse+kfopsRI1sXVI= -github.com/aws/aws-lambda-go v1.47.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A= -github.com/awslabs/aws-lambda-go-api-proxy v0.16.2 h1:CJyGEyO1CIwOnXTU40urf0mchf6t3voxpvUDikOU9LY= -github.com/awslabs/aws-lambda-go-api-proxy v0.16.2/go.mod h1:vxxjwBHe/KbgFeNlAP/Tvp4SsVRL3WQamcWRxqVh0z0= diff --git a/examples/aws-go-api-gateway-v2/src/main.go b/examples/aws-go-api-gateway-v2/src/main.go deleted file mode 100644 index 4ec3d6b278..0000000000 --- a/examples/aws-go-api-gateway-v2/src/main.go +++ /dev/null @@ -1,46 +0,0 @@ -package main - -import ( - "encoding/json" - "net/http" - - "github.com/aws/aws-lambda-go/lambda" - "github.com/awslabs/aws-lambda-go-api-proxy/httpadapter" -) - -func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) { - encoder := json.NewEncoder(w) - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(code) - encoder.Encode(payload) - -} - -func router() *http.ServeMux { - mux := http.NewServeMux() - - mux.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) { - respondWithJSON(w, http.StatusOK, map[string]string{"message": "hello world"}) - return - }) - mux.HandleFunc("/my-ping", func(w http.ResponseWriter, r *http.Request) { - respondWithJSON(w, http.StatusOK, map[string]string{"message": "pong"}) - return - }) - - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - respondWithJSON(w, http.StatusNotFound, map[string]string{"message": "not found"}) - return - }) - mux.HandleFunc("/{$}", func(w http.ResponseWriter, r *http.Request) { - respondWithJSON(w, http.StatusOK, map[string]string{"message": "home page"}) - }) - - return mux -} - -func main() { - - lambda.Start(httpadapter.NewV2(router()).ProxyWithContext) - -} diff --git a/examples/aws-go-api-gateway-v2/sst.config.ts b/examples/aws-go-api-gateway-v2/sst.config.ts deleted file mode 100644 index 4eb7a35105..0000000000 --- a/examples/aws-go-api-gateway-v2/sst.config.ts +++ /dev/null @@ -1,54 +0,0 @@ -/// - -/** - * ## AWS ApiGatewayV2 Go - * - * Uses [aws-lambda-go-api-proxy](https://github.com/awslabs/aws-lambda-go-api-proxy/tree/master) to allow you to run a Go API with API Gateway V2. - * - * :::tip - * We use the `aws-lambda-go-api-proxy` package to handle the API Gateway V2 event. - * ::: - * - * So you write your Go function as you normally would and then use the package to handle the API Gateway V2 event. - * - * ```go title="main.go" - * import ( - * "github.com/aws/aws-lambda-go/lambda" - * "github.com/awslabs/aws-lambda-go-api-proxy/httpadapter" - * ) - * - * func router() *http.ServeMux { - * mux := http.NewServeMux() - * - * mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - * w.Header().Set("Content-Type", "application/json") - * w.WriteHeader(http.StatusOK) - * w.Write([]byte(`{"message": "hello world"}`)) - * }) - * - * return mux - * } - * - * func main() { - * lambda.Start(httpadapter.NewV2(router()).ProxyWithContext) - * } - * ``` - * - */ -export default $config({ - app(input) { - return { - name: "aws-go-api-gateway-v2", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const api = new sst.aws.ApiGatewayV2("GoApi"); - - api.route("$default", { - handler: "src/", - runtime: "go", - }); - }, -}); diff --git a/examples/aws-go-api-gateway-v2/tsconfig.json b/examples/aws-go-api-gateway-v2/tsconfig.json deleted file mode 100644 index fd521c7b05..0000000000 --- a/examples/aws-go-api-gateway-v2/tsconfig.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "compilerOptions": { - // Enable latest features - "lib": ["ESNext"], - "target": "ESNext", - "module": "ESNext", - "moduleDetection": "force", - "allowJs": true, - - // Bundler mode - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, - - // Best practices - "strict": true, - "skipLibCheck": true, - "noFallthroughCasesInSwitch": true, - - // Some stricter flags (disabled by default) - "noUnusedLocals": false, - "noUnusedParameters": false, - "noPropertyAccessFromIndexSignature": false - } -} diff --git a/examples/aws-go-lambda-bucket-presigned-url/package.json b/examples/aws-go-lambda-bucket-presigned-url/package.json deleted file mode 100644 index 4c65464398..0000000000 --- a/examples/aws-go-lambda-bucket-presigned-url/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-go-lambda-bucket-presigned-url", - "module": "index.ts", - "type": "module", - "devDependencies": { - "@types/aws-lambda": "8.10.146", - "@types/bun": "latest" - }, - "peerDependencies": { - "typescript": "^5.0.0" - }, - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-go-lambda-bucket-presigned-url/src/go.mod b/examples/aws-go-lambda-bucket-presigned-url/src/go.mod deleted file mode 100644 index 6325fc595d..0000000000 --- a/examples/aws-go-lambda-bucket-presigned-url/src/go.mod +++ /dev/null @@ -1,31 +0,0 @@ -module sst-go-file-upload - -go 1.23.3 - -require ( - github.com/aws/aws-lambda-go v1.47.0 - github.com/aws/aws-sdk-go v1.44.298 - github.com/aws/aws-sdk-go-v2/config v1.28.7 - github.com/aws/aws-sdk-go-v2/service/s3 v1.71.1 - github.com/google/uuid v1.6.0 - github.com/sst/sst/v3 v3.4.27 -) - -require ( - github.com/aws/aws-sdk-go-v2 v1.32.7 // indirect - github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.17.48 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.22 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect - github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.26 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.7 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.24.8 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.7 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.33.3 // indirect - github.com/aws/smithy-go v1.22.1 // indirect -) diff --git a/examples/aws-go-lambda-bucket-presigned-url/src/go.sum b/examples/aws-go-lambda-bucket-presigned-url/src/go.sum deleted file mode 100644 index 8d659a9d1d..0000000000 --- a/examples/aws-go-lambda-bucket-presigned-url/src/go.sum +++ /dev/null @@ -1,87 +0,0 @@ -github.com/aws/aws-lambda-go v1.47.0 h1:0H8s0vumYx/YKs4sE7YM0ktwL2eWse+kfopsRI1sXVI= -github.com/aws/aws-lambda-go v1.47.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A= -github.com/aws/aws-sdk-go v1.44.298 h1:5qTxdubgV7PptZJmp/2qDwD2JL187ePL7VOxsSh1i3g= -github.com/aws/aws-sdk-go v1.44.298/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/aws-sdk-go-v2 v1.32.7 h1:ky5o35oENWi0JYWUZkB7WYvVPP+bcRF5/Iq7JWSb5Rw= -github.com/aws/aws-sdk-go-v2 v1.32.7/go.mod h1:P5WJBrYqqbWVaOxgH0X/FYYD47/nooaPOZPlQdmiN2U= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 h1:lL7IfaFzngfx0ZwUGOZdsFFnQ5uLvR0hWqqhyE7Q9M8= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7/go.mod h1:QraP0UcVlQJsmHfioCrveWOC1nbiWUl3ej08h4mXWoc= -github.com/aws/aws-sdk-go-v2/config v1.28.7 h1:GduUnoTXlhkgnxTD93g1nv4tVPILbdNQOzav+Wpg7AE= -github.com/aws/aws-sdk-go-v2/config v1.28.7/go.mod h1:vZGX6GVkIE8uECSUHB6MWAUsd4ZcG2Yq/dMa4refR3M= -github.com/aws/aws-sdk-go-v2/credentials v1.17.48 h1:IYdLD1qTJ0zanRavulofmqut4afs45mOWEI+MzZtTfQ= -github.com/aws/aws-sdk-go-v2/credentials v1.17.48/go.mod h1:tOscxHN3CGmuX9idQ3+qbkzrjVIx32lqDSU1/0d/qXs= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.22 h1:kqOrpojG71DxJm/KDPO+Z/y1phm1JlC8/iT+5XRmAn8= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.22/go.mod h1:NtSFajXVVL8TA2QNngagVZmUtXciyrHOt7xgz4faS/M= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26 h1:I/5wmGMffY4happ8NOCuIUEWGUvvFp5NSeQcXl9RHcI= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26/go.mod h1:FR8f4turZtNy6baO0KJ5FJUmXH/cSkI9fOngs0yl6mA= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26 h1:zXFLuEuMMUOvEARXFUVJdfqZ4bvvSgdGRq/ATcrQxzM= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26/go.mod h1:3o2Wpy0bogG1kyOPrgkXA8pgIfEEv0+m19O9D5+W8y8= -github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ= -github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.26 h1:GeNJsIFHB+WW5ap2Tec4K6dzcVTsRbsT1Lra46Hv9ME= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.26/go.mod h1:zfgMpwHDXX2WGoG84xG2H+ZlPTkJUU4YUvx2svLQYWo= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 h1:iXtILhvDxB6kPvEXgsDhGaZCSC6LQET5ZHSdJozeI0Y= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1/go.mod h1:9nu0fVANtYiAePIBh2/pFUSwtJ402hLnp854CNoDOeE= -github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.7 h1:tB4tNw83KcajNAzaIMhkhVI2Nt8fAZd5A5ro113FEMY= -github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.7/go.mod h1:lvpyBGkZ3tZ9iSsUIcC2EWp+0ywa7aK3BLT+FwZi+mQ= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7 h1:8eUsivBQzZHqe/3FE+cqwfH+0p5Jo8PFM/QYQSmeZ+M= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7/go.mod h1:kLPQvGUmxn/fqiCrDeohwG33bq2pQpGeY62yRO6Nrh0= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7 h1:Hi0KGbrnr57bEHWM0bJ1QcBzxLrL/k2DHvGYhb8+W1w= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7/go.mod h1:wKNgWgExdjjrm4qvfbTorkvocEstaoDl4WCvGfeCy9c= -github.com/aws/aws-sdk-go-v2/service/s3 v1.71.1 h1:aOVVZJgWbaH+EJYPvEgkNhCEbXXvH7+oML36oaPK3zE= -github.com/aws/aws-sdk-go-v2/service/s3 v1.71.1/go.mod h1:r+xl5yzMk9083rMR+sJ5TYj9Tihvf/l1oxzZXDgGj2Q= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.8 h1:CvuUmnXI7ebaUAhbJcDy9YQx8wHR69eZ9I7q5hszt/g= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.8/go.mod h1:XDeGv1opzwm8ubxddF0cgqkZWsyOtw4lr6dxwmb6YQg= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.7 h1:F2rBfNAL5UyswqoeWv9zs74N/NanhK16ydHW1pahX6E= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.7/go.mod h1:JfyQ0g2JG8+Krq0EuZNnRwX0mU0HrwY/tG6JNfcqh4k= -github.com/aws/aws-sdk-go-v2/service/sts v1.33.3 h1:Xgv/hyNgvLda/M9l9qxXc4UFSgppnRczLxlMs5Ae/QY= -github.com/aws/aws-sdk-go-v2/service/sts v1.33.3/go.mod h1:5Gn+d+VaaRgsjewpMvGazt0WfcFO+Md4wLOuBfGR9Bc= -github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro= -github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= -github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= -github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sst/sst/v3 v3.4.27 h1:LRPqw1HRhLZQ8EoL8rXacOkavZlf1k/Am8CZ0uEdMXg= -github.com/sst/sst/v3 v3.4.27/go.mod h1:rxQ4Pi7xaYAbyfLt0rFREzQDLE72clWKxudGKG9Xpt4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/examples/aws-go-lambda-bucket-presigned-url/src/main.go b/examples/aws-go-lambda-bucket-presigned-url/src/main.go deleted file mode 100644 index 2604490c67..0000000000 --- a/examples/aws-go-lambda-bucket-presigned-url/src/main.go +++ /dev/null @@ -1,98 +0,0 @@ -package main - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - "os" - "time" - - "github.com/aws/aws-lambda-go/events" - "github.com/aws/aws-lambda-go/lambda" - "github.com/aws/aws-sdk-go-v2/config" - "github.com/aws/aws-sdk-go-v2/service/s3" - "github.com/aws/aws-sdk-go/aws" - "github.com/google/uuid" - "github.com/sst/sst/v3/sdk/golang/resource" -) - -type App struct { - client *s3.Client - presignedClient *s3.PresignClient - bucketName string -} - -func NewApp() *App { - cfg, err := config.LoadDefaultConfig(context.Background(), func(opts *config.LoadOptions) error { - opts.Region = os.Getenv("AWS_REGION") - return nil - }) - if err != nil { - panic(err) - } - client := s3.NewFromConfig(cfg) - presignedClient := s3.NewPresignClient(client) - - bucketName, err := resource.Get("Bucket", "name") - if err != nil { - panic(err) - } - - return &App{ - client: client, - presignedClient: presignedClient, - bucketName: bucketName.(string), - } -} - -func (app *App) handler(ctx context.Context, r events.APIGatewayV2HTTPRequest) (events.APIGatewayV2HTTPResponse, error) { - - filename := r.QueryStringParameters["filename"] - filetype := r.QueryStringParameters["filetype"] - - id := uuid.New() - key := fmt.Sprintf("%s-%s", id, filename) - - url, err := app.presignedClient.PresignPutObject(context.Background(), &s3.PutObjectInput{ - Bucket: aws.String(app.bucketName), - Key: aws.String(key), - ContentType: aws.String(filetype), - }, func(opts *s3.PresignOptions) { - opts.Expires = 600 * time.Second // 10 minutes - }) - - if err != nil { - return apiErrorResponse(http.StatusInternalServerError, "Internal Server Error"), nil - } - - var response struct { - URL string `json:"url"` - } - response.URL = url.URL - body, err := json.Marshal(response) - if err != nil { - return apiErrorResponse(http.StatusInternalServerError, "Internal Server Error"), nil - } - - return events.APIGatewayV2HTTPResponse{ - StatusCode: http.StatusOK, - Headers: map[string]string{"Content-Type": "application/json"}, - Body: string(body), - }, nil - -} - -func main() { - app := NewApp() - lambda.Start(app.handler) -} - -func apiErrorResponse(statusCode int, message string) events.APIGatewayV2HTTPResponse { - body, _ := json.Marshal(map[string]string{"message": message}) - return events.APIGatewayV2HTTPResponse{ - StatusCode: statusCode, - Headers: map[string]string{"Content-Type": "application/json"}, - Body: string(body), - } -} diff --git a/examples/aws-go-lambda-bucket-presigned-url/sst.config.ts b/examples/aws-go-lambda-bucket-presigned-url/sst.config.ts deleted file mode 100644 index 0ad00c8fdb..0000000000 --- a/examples/aws-go-lambda-bucket-presigned-url/sst.config.ts +++ /dev/null @@ -1,52 +0,0 @@ -/// - -/** - * ## AWS Lambda Go S3 Presigned - * - * Generates a presigned URL for the linked S3 bucket in a Go Lambda function. - * - * Configure the S3 Client and the PresignedClient. - * - * ```go title="main.go" - * cfg, err := config.LoadDefaultConfig(context.TODO()) - * if err != nil { - * panic(err) - * } - * - * client := s3.NewFromConfig(cfg) - * presignedClient := s3.NewPresignClient(client) - * ``` - * - * Generate the presigned URL. - * - * ```go title="main.go" - * bucketName, err := resource.Get("Bucket", "name") - * if err != nil { - * panic(err) - * } - * url, err := presignedClient.PresignPutObject(context.TODO(), &s3.PutObjectInput{ - * Bucket: aws.String(bucket.(string)), - * Key: aws.String(key), - * }) - * ``` - */ -export default $config({ - app(input) { - return { - name: "aws-go-lambda-bucket-presigned-url", - removal: "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("Bucket"); - - const api = new sst.aws.ApiGatewayV2("Api"); - - api.route("GET /upload-url", { - handler: "src/", - runtime: "go", - link: [bucket], - }); - }, -}); diff --git a/examples/aws-go-lambda-bucket-presigned-url/tsconfig.json b/examples/aws-go-lambda-bucket-presigned-url/tsconfig.json deleted file mode 100644 index df2b488923..0000000000 --- a/examples/aws-go-lambda-bucket-presigned-url/tsconfig.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "compilerOptions": { - // Enable latest features - "lib": ["ESNext"], - "target": "ESNext", - "module": "ESNext", - "moduleDetection": "force", - "jsx": "react-jsx", - "allowJs": true, - - // Bundler mode - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, - - // Best practices - "strict": true, - "skipLibCheck": true, - "noFallthroughCasesInSwitch": true, - - // Some stricter flags - "noUnusedLocals": true, - "noUnusedParameters": true, - "noPropertyAccessFromIndexSignature": true - } -} diff --git a/examples/aws-go-lambda-dynamo/package.json b/examples/aws-go-lambda-dynamo/package.json deleted file mode 100644 index d230289740..0000000000 --- a/examples/aws-go-lambda-dynamo/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "aws-go-lambda-dynamo", - "module": "index.ts", - "type": "module", - "devDependencies": { - "@types/aws-lambda": "8.10.146", - "@types/bun": "latest" - }, - "peerDependencies": { - "typescript": "^5.0.0" - }, - "dependencies": { - "sst": "file:../../sdk/js" - }, - "scripts": { - "dev": "bun sst dev" - } -} diff --git a/examples/aws-go-lambda-dynamo/src/go.mod b/examples/aws-go-lambda-dynamo/src/go.mod deleted file mode 100644 index 9cde0324f9..0000000000 --- a/examples/aws-go-lambda-dynamo/src/go.mod +++ /dev/null @@ -1,28 +0,0 @@ -module sst-go-lambda-dynamo - -go 1.23.3 - -require ( - github.com/aws/aws-lambda-go v1.47.0 // indirect - github.com/aws/aws-sdk-go-v2 v1.32.7 // indirect - github.com/aws/aws-sdk-go-v2/config v1.28.7 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.17.48 // indirect - github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.15.22 // indirect - github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression v1.7.57 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.22 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect - github.com/aws/aws-sdk-go-v2/service/dynamodb v1.38.1 // indirect - github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.24.10 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.10.7 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.24.8 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.7 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.33.3 // indirect - github.com/aws/smithy-go v1.22.1 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/jmespath/go-jmespath v0.4.0 // indirect - github.com/sst/sst/v3 v3.4.27 // indirect -) diff --git a/examples/aws-go-lambda-dynamo/src/go.sum b/examples/aws-go-lambda-dynamo/src/go.sum deleted file mode 100644 index 81468832e1..0000000000 --- a/examples/aws-go-lambda-dynamo/src/go.sum +++ /dev/null @@ -1,50 +0,0 @@ -github.com/aws/aws-lambda-go v1.47.0 h1:0H8s0vumYx/YKs4sE7YM0ktwL2eWse+kfopsRI1sXVI= -github.com/aws/aws-lambda-go v1.47.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A= -github.com/aws/aws-sdk-go-v2 v1.32.7 h1:ky5o35oENWi0JYWUZkB7WYvVPP+bcRF5/Iq7JWSb5Rw= -github.com/aws/aws-sdk-go-v2 v1.32.7/go.mod h1:P5WJBrYqqbWVaOxgH0X/FYYD47/nooaPOZPlQdmiN2U= -github.com/aws/aws-sdk-go-v2/config v1.28.7 h1:GduUnoTXlhkgnxTD93g1nv4tVPILbdNQOzav+Wpg7AE= -github.com/aws/aws-sdk-go-v2/config v1.28.7/go.mod h1:vZGX6GVkIE8uECSUHB6MWAUsd4ZcG2Yq/dMa4refR3M= -github.com/aws/aws-sdk-go-v2/credentials v1.17.48 h1:IYdLD1qTJ0zanRavulofmqut4afs45mOWEI+MzZtTfQ= -github.com/aws/aws-sdk-go-v2/credentials v1.17.48/go.mod h1:tOscxHN3CGmuX9idQ3+qbkzrjVIx32lqDSU1/0d/qXs= -github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.15.22 h1:p2LDiYhvM9mMExEY1meHMAmjmVlzD1J1jVG+fGut+mE= -github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.15.22/go.mod h1:fo5T2fYMHVF2rHrym50h7Ue/+SECRJlUHUFZLjSX18g= -github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression v1.7.57 h1:5Pkmgr/HIgteZAXGHln1Y1X7wpI9+fyLe7T88utRRPk= -github.com/aws/aws-sdk-go-v2/feature/dynamodb/expression v1.7.57/go.mod h1:bCsUt9VsF1M4bb3ZKnpq88rvvq/XxtBJSt6/QUZzIKU= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.22 h1:kqOrpojG71DxJm/KDPO+Z/y1phm1JlC8/iT+5XRmAn8= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.22/go.mod h1:NtSFajXVVL8TA2QNngagVZmUtXciyrHOt7xgz4faS/M= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26 h1:I/5wmGMffY4happ8NOCuIUEWGUvvFp5NSeQcXl9RHcI= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26/go.mod h1:FR8f4turZtNy6baO0KJ5FJUmXH/cSkI9fOngs0yl6mA= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26 h1:zXFLuEuMMUOvEARXFUVJdfqZ4bvvSgdGRq/ATcrQxzM= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26/go.mod h1:3o2Wpy0bogG1kyOPrgkXA8pgIfEEv0+m19O9D5+W8y8= -github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ= -github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc= -github.com/aws/aws-sdk-go-v2/service/dynamodb v1.38.1 h1:AnSNs7Ogi0LXHPMDBx4RE7imU4/JmzWFziqkMKJA2AY= -github.com/aws/aws-sdk-go-v2/service/dynamodb v1.38.1/go.mod h1:J8xqRbx7HIc8ids2P8JbrKx9irONPEYq7Z1FpLDpi3I= -github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.24.10 h1:aWEbNPNdGiTGSR6/Yy9S0Ad07sMVaT/CFaVq7GuDGx4= -github.com/aws/aws-sdk-go-v2/service/dynamodbstreams v1.24.10/go.mod h1:HywkMgYwY0uaybPvvctx6fkm3L1ssRKeGv7TPZ6OQ/M= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 h1:iXtILhvDxB6kPvEXgsDhGaZCSC6LQET5ZHSdJozeI0Y= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1/go.mod h1:9nu0fVANtYiAePIBh2/pFUSwtJ402hLnp854CNoDOeE= -github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.10.7 h1:EqGlayejoCRXmnVC6lXl6phCm9R2+k35e0gWsO9G5DI= -github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.10.7/go.mod h1:BTw+t+/E5F3ZnDai/wSOYM54WUVjSdewE7Jvwtb7o+w= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7 h1:8eUsivBQzZHqe/3FE+cqwfH+0p5Jo8PFM/QYQSmeZ+M= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7/go.mod h1:kLPQvGUmxn/fqiCrDeohwG33bq2pQpGeY62yRO6Nrh0= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.8 h1:CvuUmnXI7ebaUAhbJcDy9YQx8wHR69eZ9I7q5hszt/g= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.8/go.mod h1:XDeGv1opzwm8ubxddF0cgqkZWsyOtw4lr6dxwmb6YQg= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.7 h1:F2rBfNAL5UyswqoeWv9zs74N/NanhK16ydHW1pahX6E= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.7/go.mod h1:JfyQ0g2JG8+Krq0EuZNnRwX0mU0HrwY/tG6JNfcqh4k= -github.com/aws/aws-sdk-go-v2/service/sts v1.33.3 h1:Xgv/hyNgvLda/M9l9qxXc4UFSgppnRczLxlMs5Ae/QY= -github.com/aws/aws-sdk-go-v2/service/sts v1.33.3/go.mod h1:5Gn+d+VaaRgsjewpMvGazt0WfcFO+Md4wLOuBfGR9Bc= -github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro= -github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= -github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= -github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sst/sst/v3 v3.4.27 h1:LRPqw1HRhLZQ8EoL8rXacOkavZlf1k/Am8CZ0uEdMXg= -github.com/sst/sst/v3 v3.4.27/go.mod h1:rxQ4Pi7xaYAbyfLt0rFREzQDLE72clWKxudGKG9Xpt4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/examples/aws-go-lambda-dynamo/src/handlers/handlers.go b/examples/aws-go-lambda-dynamo/src/handlers/handlers.go deleted file mode 100644 index 9a5f742d8d..0000000000 --- a/examples/aws-go-lambda-dynamo/src/handlers/handlers.go +++ /dev/null @@ -1,118 +0,0 @@ -package handlers - -import ( - "context" - "encoding/json" - "net/http" - "sst-go-lambda-dynamo/models" - "sst-go-lambda-dynamo/repository" - - "github.com/aws/aws-lambda-go/events" -) - -type Handlers struct { - userRepo repository.UserRepository -} - -func NewHandlers(userRepo repository.UserRepository) *Handlers { - return &Handlers{userRepo: userRepo} -} - -func (h *Handlers) GetUser(ctx context.Context, r events.LambdaFunctionURLRequest) (events.LambdaFunctionURLResponse, error) { - - queryString := r.QueryStringParameters - if queryString == nil { - return events.LambdaFunctionURLResponse{ - StatusCode: http.StatusBadRequest, - Body: `{"message": "Missing query string"}`, - }, nil - } - - id := queryString["id"] - - user, err := h.userRepo.GetUser(ctx, id) - if err != nil { - return events.LambdaFunctionURLResponse{ - StatusCode: http.StatusNotFound, - Body: `{"message": "User not found"}`, - }, nil - } - - userJSON, err := json.Marshal(user) - if err != nil { - return events.LambdaFunctionURLResponse{ - StatusCode: http.StatusInternalServerError, - Body: `{"message": "Failed to marshal user"}`, - }, err - } - - return events.LambdaFunctionURLResponse{ - StatusCode: http.StatusOK, - Body: string(userJSON), - }, nil -} - -type PostUserRequestData struct { - Name string `json:"name"` - Email string `json:"email"` -} - -func (h *Handlers) CreateUser(ctx context.Context, r events.LambdaFunctionURLRequest) (events.LambdaFunctionURLResponse, error) { - - var data PostUserRequestData - if err := json.Unmarshal([]byte(r.Body), &data); err != nil { - return events.LambdaFunctionURLResponse{ - StatusCode: 400, - Body: `{"message": "Invalid request body"}`, - }, err - } - - user, err := h.userRepo.CreateUser(ctx, models.UserCreate{ - Name: data.Name, - Email: data.Email, - }) - if err != nil { - return events.LambdaFunctionURLResponse{ - StatusCode: 500, - Body: `{"message": "Failed to create user"}`, - }, err - } - - userJSON, err := json.Marshal(user) - if err != nil { - return events.LambdaFunctionURLResponse{ - StatusCode: 500, - Body: `{"message": "Failed to marshal user"}`, - }, err - } - - return events.LambdaFunctionURLResponse{ - StatusCode: 201, - Body: string(userJSON), - }, nil -} - -func (h *Handlers) DeleteUser(ctx context.Context, r events.LambdaFunctionURLRequest) (events.LambdaFunctionURLResponse, error) { - - queryString := r.QueryStringParameters - if queryString == nil { - return events.LambdaFunctionURLResponse{ - StatusCode: http.StatusBadRequest, - Body: `{"message": "Missing query string"}`, - }, nil - } - - id := queryString["id"] - - if err := h.userRepo.DeleteUser(ctx, id); err != nil { - return events.LambdaFunctionURLResponse{ - StatusCode: http.StatusInternalServerError, - Body: `{"message": "Failed to delete user"}`, - }, err - } - - return events.LambdaFunctionURLResponse{ - StatusCode: http.StatusOK, - Body: `{"message": "User deleted"}`, - }, nil -} diff --git a/examples/aws-go-lambda-dynamo/src/main.go b/examples/aws-go-lambda-dynamo/src/main.go deleted file mode 100644 index 59d8e6270d..0000000000 --- a/examples/aws-go-lambda-dynamo/src/main.go +++ /dev/null @@ -1,63 +0,0 @@ -package main - -import ( - "context" - "net/http" - "os" - "sst-go-lambda-dynamo/handlers" - "sst-go-lambda-dynamo/repository" - - "github.com/aws/aws-lambda-go/events" - "github.com/aws/aws-lambda-go/lambda" - "github.com/aws/aws-sdk-go-v2/config" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" - "github.com/sst/sst/v3/sdk/golang/resource" -) - -type App struct { - handlers *handlers.Handlers -} - -func NewApp() *App { - cfg, err := config.LoadDefaultConfig(context.Background(), func(opts *config.LoadOptions) error { - // example of setting region from environment variable - opts.Region = os.Getenv("AWS_REGION") - return nil - }) - if err != nil { - panic(err) - } - client := dynamodb.NewFromConfig(cfg) - - tableName, err := resource.Get("Table", "name") - if err != nil { - panic(err) - } - - userRepo := repository.NewDynamoDBRepository(client, tableName.(string)) - handlers := handlers.NewHandlers(userRepo) - - return &App{handlers: handlers} -} - -func (app *App) handler(ctx context.Context, r events.LambdaFunctionURLRequest) (events.LambdaFunctionURLResponse, error) { - switch r.RequestContext.HTTP.Method { - case http.MethodGet: - return app.handlers.GetUser(ctx, r) - case http.MethodPost: - return app.handlers.CreateUser(ctx, r) - case http.MethodDelete: - return app.handlers.DeleteUser(ctx, r) - default: - return events.LambdaFunctionURLResponse{ - StatusCode: http.StatusMethodNotAllowed, - Headers: map[string]string{"Content-Type": "application/json"}, - Body: `{"message": "Method Not Allowed"}`, - }, nil - } -} - -func main() { - app := NewApp() - lambda.Start(app.handler) -} diff --git a/examples/aws-go-lambda-dynamo/src/models/user.go b/examples/aws-go-lambda-dynamo/src/models/user.go deleted file mode 100644 index addac21e76..0000000000 --- a/examples/aws-go-lambda-dynamo/src/models/user.go +++ /dev/null @@ -1,18 +0,0 @@ -package models - -import ( - "time" -) - -type User struct { - ID string `json:"id" dynamodbav:"id"` - Name string `json:"name" dynamodbav:"name"` - Email string `json:"email" dynamodbav:"email"` - CreatedAt time.Time `json:"created_at" dynamodbav:"created_at"` - UpdatedAt time.Time `json:"updated_at" dynamodbav:"updated_at"` -} - -type UserCreate struct { - Name string - Email string -} diff --git a/examples/aws-go-lambda-dynamo/src/repository/dynamodb.go b/examples/aws-go-lambda-dynamo/src/repository/dynamodb.go deleted file mode 100644 index 062b0b7135..0000000000 --- a/examples/aws-go-lambda-dynamo/src/repository/dynamodb.go +++ /dev/null @@ -1,126 +0,0 @@ -package repository - -import ( - "context" - "fmt" - "sst-go-lambda-dynamo/models" - "time" - - "github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" - "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" - "github.com/google/uuid" -) - -type DynamoUser struct { - models.User - PK string `dynamodbav:"PK"` - SK string `dynamodbav:"SK"` - TYPE string `dynamodbav:"TYPE"` -} - -func getKey(id string) (map[string]types.AttributeValue, error) { - return attributevalue.MarshalMap(map[string]string{ - "PK": "USER#" + id, - "SK": "USER#" + id, - }) -} - -func formatTo(u models.User) DynamoUser { - return DynamoUser{ - User: u, - PK: "USER#" + u.ID, - SK: "USER#" + u.ID, - TYPE: "USER", - } -} - -func formatFrom(item map[string]types.AttributeValue) (models.User, error) { - var user models.User - err := attributevalue.UnmarshalMap(item, &user) - return user, err -} - -type DynamoDBRepository struct { - client *dynamodb.Client - tableName string -} - -func NewDynamoDBRepository(client *dynamodb.Client, tableName string) UserRepository { - return &DynamoDBRepository{ - client: client, - tableName: tableName, - } -} - -func (r *DynamoDBRepository) GetUser(ctx context.Context, id string) (*models.User, error) { - key, err := getKey(id) - if err != nil { - return nil, fmt.Errorf("failed to get key: %w", err) - } - output, err := r.client.GetItem(ctx, &dynamodb.GetItemInput{ - TableName: &r.tableName, - Key: key, - }) - if err != nil { - return nil, fmt.Errorf("failed to get user: %w", err) - } - - if output.Item == nil { - return nil, fmt.Errorf("user not found") - } - - user, err := formatFrom(output.Item) - if err != nil { - return nil, fmt.Errorf("failed to format user: %w", err) - } - - return &user, nil -} - -func (r *DynamoDBRepository) CreateUser(ctx context.Context, user models.UserCreate) (*models.User, error) { - - id, err := uuid.NewV7() - if err != nil { - return nil, fmt.Errorf("failed to generate id: %w", err) - } - now := time.Now() - newUser := models.User{ - ID: id.String(), - Name: user.Name, - Email: user.Email, - CreatedAt: now, - UpdatedAt: now, - } - - dynamoUser := formatTo(newUser) - item, err := attributevalue.MarshalMap(dynamoUser) - if err != nil { - return nil, fmt.Errorf("failed to marshal user: %w", err) - } - _, err = r.client.PutItem(ctx, &dynamodb.PutItemInput{ - TableName: &r.tableName, - Item: item, - }) - if err != nil { - return nil, fmt.Errorf("failed to put user: %w", err) - } - - return &newUser, nil -} - -func (r *DynamoDBRepository) DeleteUser(ctx context.Context, id string) error { - key, err := getKey(id) - if err != nil { - return fmt.Errorf("failed to get key: %w", err) - } - - _, err = r.client.DeleteItem(ctx, &dynamodb.DeleteItemInput{ - TableName: &r.tableName, - Key: key, - }) - if err != nil { - return fmt.Errorf("failed to delete user: %w", err) - } - return nil -} diff --git a/examples/aws-go-lambda-dynamo/src/repository/repository.go b/examples/aws-go-lambda-dynamo/src/repository/repository.go deleted file mode 100644 index 5c6ee70503..0000000000 --- a/examples/aws-go-lambda-dynamo/src/repository/repository.go +++ /dev/null @@ -1,12 +0,0 @@ -package repository - -import ( - "context" - "sst-go-lambda-dynamo/models" -) - -type UserRepository interface { - GetUser(ctx context.Context, id string) (*models.User, error) - CreateUser(ctx context.Context, user models.UserCreate) (*models.User, error) - DeleteUser(ctx context.Context, id string) error -} diff --git a/examples/aws-go-lambda-dynamo/sst.config.ts b/examples/aws-go-lambda-dynamo/sst.config.ts deleted file mode 100644 index d1c97887bc..0000000000 --- a/examples/aws-go-lambda-dynamo/sst.config.ts +++ /dev/null @@ -1,69 +0,0 @@ -/// - -/** - * ## AWS Lambda Go DynamoDB - * - * An example on how to use a Go runtime Lambda with DynamoDB. - * - * You configure the DynamoDB client. - * - * ```go title="src/main.go" - * import ( - * "github.com/sst/sst/v3/sdk/golang/resource" - * ) - * - * func main() { - * cfg, err := config.LoadDefaultConfig(context.Background()) - * if err != nil { - * panic(err) - * } - * client := dynamodb.NewFromConfig(cfg) - * - * - * tableName, err := resource.Get("Table", "name") - * if err != nil { - * panic(err) - * } - * } - * ``` - * - * And make a request to DynamoDB. - * - * ```go title="src/main.go" - * _, err = r.client.PutItem(ctx, &dynamodb.PutItemInput{ - * TableName: tableName.(string), - * Item: item, - * }) - * ``` - * - */ -export default $config({ - app(input) { - return { - name: "aws-go-lambda-dynamo", - removal: "remove", - home: "aws", - providers: { - aws: { - region: "us-east-2", - }, - }, - }; - }, - async run() { - const table = new sst.aws.Dynamo("Table", { - fields: { - PK: "string", - SK: "string", - }, - primaryIndex: { hashKey: "PK", rangeKey: "SK" }, - }); - - new sst.aws.Function("GoFunction", { - url: true, - runtime: "go", - handler: "./src", - link: [table], - }); - }, -}); diff --git a/examples/aws-go-lambda-dynamo/tsconfig.json b/examples/aws-go-lambda-dynamo/tsconfig.json deleted file mode 100644 index fdc4236bd1..0000000000 --- a/examples/aws-go-lambda-dynamo/tsconfig.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "compilerOptions": { - //Enable latest features - "lib": ["ESNext"], - "target": "ESNext", - "module": "ESNext", - "moduleDetection": "force", - "jsx": "react-jsx", - "allowJs": true, - - // Bundler mode - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, - - // Best practices - "strict": true, - "skipLibCheck": true, - "noFallthroughCasesInSwitch": true, - "noUncheckedIndexedAccess": true, - "noImplicitOverride": true, - - // Some stricter flags (disabled by default) - "noUnusedLocals": false, - "noUnusedParameters": false, - "noPropertyAccessFromIndexSignature": false - } -} diff --git a/examples/aws-hono-container/.dockerignore b/examples/aws-hono-container/.dockerignore deleted file mode 100644 index 5eae331bf4..0000000000 --- a/examples/aws-hono-container/.dockerignore +++ /dev/null @@ -1,6 +0,0 @@ -node_modules -.git - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-hono-container/.gitignore b/examples/aws-hono-container/.gitignore deleted file mode 100644 index 349b782160..0000000000 --- a/examples/aws-hono-container/.gitignore +++ /dev/null @@ -1,31 +0,0 @@ -# dev -.yarn/ -!.yarn/releases -.vscode/* -!.vscode/launch.json -!.vscode/*.code-snippets -.idea/workspace.xml -.idea/usage.statistics.xml -.idea/shelf - -# deps -node_modules/ - -# env -.env -.env.production - -# logs -logs/ -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -# misc -.DS_Store - -# sst -.sst diff --git a/examples/aws-hono-container/Dockerfile b/examples/aws-hono-container/Dockerfile deleted file mode 100644 index 84684fd82a..0000000000 --- a/examples/aws-hono-container/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM node:lts-alpine AS base - -FROM base AS builder -RUN apk add --no-cache gcompat -WORKDIR /app -COPY package*json tsconfig.json src ./ -# Copy over generated types -COPY sst-env.d.ts* ./ -RUN npm ci && \ - npm run build && \ - npm prune --production - -FROM base AS runner -WORKDIR /app -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 hono -COPY --from=builder --chown=hono:nodejs /app/node_modules /app/node_modules -COPY --from=builder --chown=hono:nodejs /app/dist /app/dist -COPY --from=builder --chown=hono:nodejs /app/package.json /app/package.json - -USER hono -EXPOSE 3000 -CMD ["node", "/app/dist/index.js"] diff --git a/examples/aws-hono-container/package.json b/examples/aws-hono-container/package.json deleted file mode 100644 index 565f26f302..0000000000 --- a/examples/aws-hono-container/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "aws-hono-container", - "type": "module", - "scripts": { - "dev": "tsx watch src/index.ts", - "build": "tsc" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.701.0", - "@aws-sdk/lib-storage": "^3.701.0", - "@aws-sdk/s3-request-presigner": "^3.701.0", - "@hono/node-server": "^1.13.7", - "hono": "^4.6.12", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.146", - "@types/node": "^20.11.17", - "tsx": "^4.7.1", - "typescript": "^5.7.2" - } -} diff --git a/examples/aws-hono-container/src/index.ts b/examples/aws-hono-container/src/index.ts deleted file mode 100644 index 30af78b446..0000000000 --- a/examples/aws-hono-container/src/index.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { serve } from '@hono/node-server' -import { Hono } from 'hono' -import { Resource } from 'sst' -import { - S3Client, - GetObjectCommand, - ListObjectsV2Command, -} from '@aws-sdk/client-s3' -import { Upload } from '@aws-sdk/lib-storage' -import { getSignedUrl } from '@aws-sdk/s3-request-presigner' - -const s3 = new S3Client(); - -const app = new Hono() - -app.get('/', (c) => { - return c.text('Hello Hono!') -}) - -app.post('/', async (c) => { - const body = await c.req.parseBody(); - const file = body['file'] as File; - - const params = { - Bucket: Resource.MyBucket.name, - ContentType: file.type, - Key: file.name, - Body: file, - }; - const upload = new Upload({ - params, - client: s3, - }); - await upload.done(); - - return c.text('File uploaded successfully.'); -}); - -app.get('/latest', async (c) => { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - const latestFile = objects.Contents!.sort( - (a, b) => - (b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0), - )[0]; - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - return c.redirect(await getSignedUrl(s3, command)); -}); - -const port = 3000 -console.log(`Server is running on http://localhost:${port}`) - -serve({ - fetch: app.fetch, - port -}) diff --git a/examples/aws-hono-container/sst.config.ts b/examples/aws-hono-container/sst.config.ts deleted file mode 100644 index 67b166954e..0000000000 --- a/examples/aws-hono-container/sst.config.ts +++ /dev/null @@ -1,28 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-hono-container", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const bucket = new sst.aws.Bucket("MyBucket"); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [bucket], - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-hono-container/tsconfig.json b/examples/aws-hono-container/tsconfig.json deleted file mode 100644 index b55223e0d5..0000000000 --- a/examples/aws-hono-container/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "NodeNext", - "strict": true, - "verbatimModuleSyntax": true, - "skipLibCheck": true, - "types": [ - "node" - ], - "jsx": "react-jsx", - "jsxImportSource": "hono/jsx", - "outDir": "./dist" - }, - "exclude": ["node_modules"] -} diff --git a/examples/aws-hono-redis/.dockerignore b/examples/aws-hono-redis/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-hono-redis/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-hono-redis/.gitignore b/examples/aws-hono-redis/.gitignore deleted file mode 100644 index 349b782160..0000000000 --- a/examples/aws-hono-redis/.gitignore +++ /dev/null @@ -1,31 +0,0 @@ -# dev -.yarn/ -!.yarn/releases -.vscode/* -!.vscode/launch.json -!.vscode/*.code-snippets -.idea/workspace.xml -.idea/usage.statistics.xml -.idea/shelf - -# deps -node_modules/ - -# env -.env -.env.production - -# logs -logs/ -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -# misc -.DS_Store - -# sst -.sst diff --git a/examples/aws-hono-redis/Dockerfile b/examples/aws-hono-redis/Dockerfile deleted file mode 100644 index e63bc0b843..0000000000 --- a/examples/aws-hono-redis/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -FROM node:20-alpine AS base - -FROM base AS builder - -RUN apk add --no-cache gcompat -WORKDIR /app - -COPY package*json tsconfig.json src ./ - -# Copy over generated types -COPY sst-env.d.ts* ./ - -RUN npm ci && \ - npm run build && \ - npm prune --production - -FROM base AS runner -WORKDIR /app - -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 hono - -COPY --from=builder --chown=hono:nodejs /app/node_modules /app/node_modules -COPY --from=builder --chown=hono:nodejs /app/dist /app/dist -COPY --from=builder --chown=hono:nodejs /app/package.json /app/package.json - -USER hono -EXPOSE 3000 - -CMD ["node", "/app/dist/index.js"] diff --git a/examples/aws-hono-redis/package.json b/examples/aws-hono-redis/package.json deleted file mode 100644 index 7048149d5a..0000000000 --- a/examples/aws-hono-redis/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "aws-hono-redis", - "type": "module", - "scripts": { - "build": "tsc", - "dev": "tsx watch src/index.ts" - }, - "dependencies": { - "@hono/node-server": "^1.13.2", - "hono": "^4.6.5", - "ioredis": "^5.4.1", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145", - "@types/node": "^20.11.17", - "tsx": "^4.7.1", - "typescript": "^5.6.3" - } -} diff --git a/examples/aws-hono-redis/src/index.ts b/examples/aws-hono-redis/src/index.ts deleted file mode 100644 index eb89ae5adc..0000000000 --- a/examples/aws-hono-redis/src/index.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Hono } from "hono"; -import { Resource } from "sst"; -import { Cluster } from "ioredis"; -import { serve } from "@hono/node-server"; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - }, -); - -const app = new Hono(); - -app.get("/", async (c) => { - const counter = await redis.incr("counter"); - return c.text(`Hit counter: ${counter}`); -}); - -const port = 3000; -console.log(`Server is running on port ${port}`); - -serve({ - fetch: app.fetch, - port, -}); diff --git a/examples/aws-hono-redis/sst.config.ts b/examples/aws-hono-redis/sst.config.ts deleted file mode 100644 index d39e5dcf86..0000000000 --- a/examples/aws-hono-redis/sst.config.ts +++ /dev/null @@ -1,97 +0,0 @@ -/// - -/** - * ## AWS Hono container with Redis - * - * Creates a hit counter app with Hono and Redis. - * - * This deploys Hono API as a Fargate service to ECS and it's linked to Redis. - * - * ```ts title="sst.config.ts" {2} - * new sst.aws.Service("MyService", { - * cluster, - * link: [redis], - * loadBalancer: { - * ports: [{ listen: "80/http", forward: "3000/http" }], - * }, - * dev: { - * command: "npm run dev", - * }, - * }); - * ``` - * - * Since our Redis cluster is in a VPC, we’ll need a tunnel to connect to it from our local - * machine. - * - * ```bash "sudo" - * sudo npx sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * To start your app locally run. - * - * ```bash - * npx sst dev - * ``` - * - * Now if you go to `http://localhost:3000` you’ll see a counter update as you refresh the page. - * - * Finally, you can deploy it by: - - * 1. Using the `Dockerfile` that's included in this example. - * - * 2. This compiles our TypeScript file, so we'll need add the following to the `tsconfig.json`. - * - * ```diff lang="json" title="tsconfig.json" {4,6} - * { - * "compilerOptions": { - * // ... - * + "outDir": "./dist" - * }, - * + "exclude": ["node_modules"] - * } - * ``` - * - * 3. Install TypeScript. - * - * ```bash - * npm install typescript --save-dev - * ``` - * - * 3. And add a `build` script to our `package.json`. - * - * ```diff lang="json" title="package.json" - * "scripts": { - * // ... - * + "build": "tsc" - * } - * ``` - * And finally, running `npx sst deploy --stage production`. - */ -export default $config({ - app(input) { - return { - name: "aws-hono-redis", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-hono-redis/tsconfig.json b/examples/aws-hono-redis/tsconfig.json deleted file mode 100644 index 25d91658cc..0000000000 --- a/examples/aws-hono-redis/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "NodeNext", - "strict": true, - "outDir": "./dist", - "verbatimModuleSyntax": true, - "skipLibCheck": true, - "types": [ - "node" - ], - "jsx": "react-jsx", - "jsxImportSource": "hono/jsx", - }, - "exclude": ["node_modules"] -} diff --git a/examples/aws-hono-stream/.gitignore b/examples/aws-hono-stream/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-hono-stream/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-hono-stream/index.ts b/examples/aws-hono-stream/index.ts deleted file mode 100644 index 5a9239a382..0000000000 --- a/examples/aws-hono-stream/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Hono } from "hono"; -import { streamText } from "hono/streaming"; -import { streamHandle } from "hono/aws-lambda"; - -const app = new Hono() - .get("/", (c) => { - return streamText(c, async (stream) => { - await stream.writeln("Hello"); - await stream.sleep(3000); - await stream.writeln("World"); - }) - }); - -export const handler = streamHandle(app); diff --git a/examples/aws-hono-stream/package.json b/examples/aws-hono-stream/package.json deleted file mode 100644 index 51c7dd4fe7..0000000000 --- a/examples/aws-hono-stream/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-hono-stream", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "hono": "^4.6.2", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-hono-stream/sst.config.ts b/examples/aws-hono-stream/sst.config.ts deleted file mode 100644 index 005d16ee1a..0000000000 --- a/examples/aws-hono-stream/sst.config.ts +++ /dev/null @@ -1,46 +0,0 @@ -/// - -/** - * ## AWS Hono streaming - * - * An example on how to enable streaming for Lambda functions using Hono. - * - * ```ts title="sst.config.ts" - * { - * streaming: true - * } - * ``` - * - * ```ts title="index.ts" - * export const handler = streamHandle(app); - * ``` - * - * To test this in your terminal, use the `curl` command with the `--no-buffer` option. - * - * ```bash "--no-buffer" - * curl --no-buffer https://u3dyblk457ghskwbmzrbylpxoi0ayrbb.lambda-url.us-east-1.on.aws - * ``` - * - * Streaming is also supported through API Gateway REST API. - * - */ -export default $config({ - app(input) { - return { - name: "aws-hono-stream", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const hono = new sst.aws.Function("Hono", { - url: true, - streaming: true, - timeout: "15 minutes", - handler: "index.handler", - }); - return { - api: hono.url, - }; - }, -}); diff --git a/examples/aws-hono-stream/tsconfig.json b/examples/aws-hono-stream/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-hono-stream/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-hono/.gitignore b/examples/aws-hono/.gitignore deleted file mode 100644 index c84fd38455..0000000000 --- a/examples/aws-hono/.gitignore +++ /dev/null @@ -1,35 +0,0 @@ -# prod -dist/ -lambda.zip - -# dev -.yarn/ -!.yarn/releases -.vscode/* -!.vscode/launch.json -!.vscode/*.code-snippets -.idea/workspace.xml -.idea/usage.statistics.xml -.idea/shelf - -# deps -node_modules/ - -# env -.env -.env.production - -# logs -logs/ -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -# misc -.DS_Store - -# sst -.sst diff --git a/examples/aws-hono/package.json b/examples/aws-hono/package.json deleted file mode 100644 index 6ed2c8e0c7..0000000000 --- a/examples/aws-hono/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aws-hono", - "type": "module", - "scripts": { - "build": "esbuild --bundle --outfile=./dist/index.js --platform=node --target=node20 ./src/index.ts", - "deploy": "run-s build zip update", - "update": "aws lambda update-function-code --zip-file fileb://lambda.zip --function-name hello", - "zip": "zip -j lambda.zip dist/index.js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.146", - "esbuild": "^0.21.4", - "npm-run-all2": "^6.2.0" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.701.0", - "@aws-sdk/s3-request-presigner": "^3.701.0", - "hono": "^4.6.12", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-hono/src/index.ts b/examples/aws-hono/src/index.ts deleted file mode 100644 index cb7ac2f0ae..0000000000 --- a/examples/aws-hono/src/index.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { Hono } from "hono"; -import { handle } from "hono/aws-lambda"; -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { - S3Client, - GetObjectCommand, - PutObjectCommand, - ListObjectsV2Command, -} from "@aws-sdk/client-s3"; - -const s3 = new S3Client(); - -const app = new Hono(); - -app.get("/", async (c) => { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - - return c.text(await getSignedUrl(s3, command)); -}); - -app.get("/latest", async (c) => { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - - const latestFile = objects.Contents!.sort( - (a, b) => - (b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0), - )[0]; - - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - - return c.redirect(await getSignedUrl(s3, command)); -}); - -export const handler = handle(app); diff --git a/examples/aws-hono/sst.config.ts b/examples/aws-hono/sst.config.ts deleted file mode 100644 index 2c9f1db7b1..0000000000 --- a/examples/aws-hono/sst.config.ts +++ /dev/null @@ -1,20 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-hono", - removal: input?.stage === "production" ? "retain" : "remove", - protect: input?.stage === "production", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket"); - new sst.aws.Function("Hono", { - url: true, - link: [bucket], - handler: "src/index.handler", - }); - }, -}); diff --git a/examples/aws-hono/tsconfig.json b/examples/aws-hono/tsconfig.json deleted file mode 100644 index 667b7e7e6d..0000000000 --- a/examples/aws-hono/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "Bundler", - "strict": true, - "skipLibCheck": true, - "types": [ - "node" - ], - "jsx": "react-jsx", - "jsxImportSource": "hono/jsx", - } -} \ No newline at end of file diff --git a/examples/aws-iam-permission-boundary/index.ts b/examples/aws-iam-permission-boundary/index.ts deleted file mode 100644 index 09995bf3ca..0000000000 --- a/examples/aws-iam-permission-boundary/index.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { S3Client, ListBucketsCommand } from "@aws-sdk/client-s3"; -import { SQSClient, ListQueuesCommand } from "@aws-sdk/client-sqs"; -const s3 = new S3Client(); -const sqs = new SQSClient(); - -export const handler = async () => { - const response = []; - - // List buckets - try { - await s3.send(new ListBucketsCommand()); - response.push("s3:ListBuckets - success"); - } catch (e: any) { - response.push(`s3:ListBuckets - failed (${e.message})`); - } - - // List queues - try { - await sqs.send(new ListQueuesCommand()); - response.push("sqs:ListQueues - success"); - } catch (e: any) { - response.push(`sqs:ListQueues - failed (${e.message})`); - } - - return { - statusCode: 200, - body: `
${JSON.stringify(response, null, 2)}
`, - }; -}; diff --git a/examples/aws-iam-permission-boundary/package.json b/examples/aws-iam-permission-boundary/package.json deleted file mode 100644 index 347231b033..0000000000 --- a/examples/aws-iam-permission-boundary/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-iam-permission-boundary", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@aws-sdk/client-s3": "^3.564.0", - "@aws-sdk/client-sqs": "^3.564.0" - } -} diff --git a/examples/aws-iam-permission-boundary/sst.config.ts b/examples/aws-iam-permission-boundary/sst.config.ts deleted file mode 100644 index 953b39ad0a..0000000000 --- a/examples/aws-iam-permission-boundary/sst.config.ts +++ /dev/null @@ -1,61 +0,0 @@ -/// - -/** - * ## IAM permissions boundaries - * - * Use permissions boundaries to set the maximum permissions for all IAM roles that'll be - * created in your app. - * - * In this example, the Function has the `s3:ListAllMyBuckets` and `sqs:ListQueues` - * permissions. However, we create a permissions boundary that only allows `s3:ListAllMyBuckets`. - * And we apply it to all Roles in the app using the global - * [`$transform`](/docs/reference/global/#transform). - * - * As a result, the Function is only allowed to list S3 buckets. If you open the deployed URL, - * you'll see that the SQS list call fails. - * - * Learn more about [AWS IAM permissions boundaries](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html). - */ -export default $config({ - app(input) { - return { - name: "aws-iam-permission-boundary", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - // Create a permission boundary - const permissionsBoundary = new aws.iam.Policy("MyPermissionsBoundary", { - policy: aws.iam.getPolicyDocumentOutput({ - statements: [ - { - actions: ["s3:ListAllMyBuckets"], - resources: ["*"], - }, - ], - }).json, - }); - - // Apply the boundary to all roles - $transform(aws.iam.Role, (args) => { - args.permissionsBoundary = permissionsBoundary; - }); - - // The boundary automatically applies to this Function's role - const app = new sst.aws.Function("MyApp", { - handler: "index.handler", - permissions: [ - { - actions: ["s3:ListAllMyBuckets", "sqs:ListQueues"], - resources: ["*"], - }, - ], - url: true, - }); - - return { - app: app.url, - }; - }, -}); diff --git a/examples/aws-import/.gitignore b/examples/aws-import/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-import/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-import/package.json b/examples/aws-import/package.json deleted file mode 100644 index 62f02b1660..0000000000 --- a/examples/aws-import/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-import", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-import/sst.config.ts b/examples/aws-import/sst.config.ts deleted file mode 100644 index c8d3b84e1e..0000000000 --- a/examples/aws-import/sst.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// - -/** - * ## Import existing resource - * - * Import an existing AWS resource using the `transform` option with `opts.import`. - */ -export default $config({ - app(input) { - return { - name: "aws-import", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - new sst.aws.Bucket("MyBucket", { - transform: { - bucket(args, opts) { - opts.import = "aws-import-my-bucket"; - args.bucket = "aws-import-my-bucket"; - args.forceDestroy = undefined; - }, - }, - }); - }, -}); diff --git a/examples/aws-import/tsconfig.json b/examples/aws-import/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-import/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-info/package.json b/examples/aws-info/package.json deleted file mode 100644 index 9802a5872a..0000000000 --- a/examples/aws-info/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-info", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-info/sst.config.ts b/examples/aws-info/sst.config.ts deleted file mode 100644 index 3c09c1ee88..0000000000 --- a/examples/aws-info/sst.config.ts +++ /dev/null @@ -1,25 +0,0 @@ -/// - -/** - * ## Current AWS account - * - * You can use the `aws.getXXXXOutput()` provider functions to get info about the current - * AWS account. - * Learn more about [provider functions](/docs/providers/#functions). - */ -export default $config({ - app(input) { - return { - name: "aws-info", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - return { - region: aws.getRegionOutput().region, - account: aws.getCallerIdentityOutput({}).accountId, - }; - }, -}); - diff --git a/examples/aws-jsx-email/.gitignore b/examples/aws-jsx-email/.gitignore deleted file mode 100644 index fccbe3fea3..0000000000 --- a/examples/aws-jsx-email/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -node_modules - -# env -.env - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* -.pnpm-debug.log* - -# sst -.sst diff --git a/examples/aws-jsx-email/index.ts b/examples/aws-jsx-email/index.ts deleted file mode 100644 index 907afeca8b..0000000000 --- a/examples/aws-jsx-email/index.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { Resource } from "sst"; -import { render } from "jsx-email"; -import { Template } from "./templates/email"; -import { SESv2Client, SendEmailCommand } from "@aws-sdk/client-sesv2"; - -const client = new SESv2Client(); - -export const handler = async () => { - await client.send( - new SendEmailCommand({ - FromEmailAddress: Resource.MyEmail.sender, - Destination: { - ToAddresses: [Resource.MyEmail.sender], - }, - Content: { - Simple: { - Subject: { - Data: "Hello World!", - }, - Body: { - Html: { - Data: await render(Template({ - email: "spongebob@example.com", - name: "Spongebob Squarepants" - })), - }, - }, - }, - }, - }) - ); - - return { - statusCode: 200, - body: "Sent!" - }; -}; diff --git a/examples/aws-jsx-email/package.json b/examples/aws-jsx-email/package.json deleted file mode 100644 index 25b27b978c..0000000000 --- a/examples/aws-jsx-email/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "aws-jsx-email", - "version": "0.0.0", - "private": true, - "description": "A simple starter for jsx-email", - "scripts": { - "build": "email build ./templates", - "create": "email create", - "dev": "email preview ./templates" - }, - "dependencies": { - "@aws-sdk/client-sesv2": "^3.651.1", - "jsx-email": "^1.10.11", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145", - "@types/react": "^18.2.0", - "react": "^18.2.0", - "typescript": "^5.2.2" - } -} diff --git a/examples/aws-jsx-email/sst.config.ts b/examples/aws-jsx-email/sst.config.ts deleted file mode 100644 index a17fd32f97..0000000000 --- a/examples/aws-jsx-email/sst.config.ts +++ /dev/null @@ -1,63 +0,0 @@ -/// - -/** - * ## AWS JSX Email - * - * Uses [JSX Email](https://jsx.email) and the `Email` component to design and send emails. - * - * To test this example, change the `sst.config.ts` to use your own email address. - * - * ```ts title="sst.config.ts" - * sender: "email@example.com" - * ``` - * - * Then run. - * - * ```bash - * npm install - * npx sst dev - * ``` - * - * You'll get an email from AWS asking you to confirm your email address. Click the link to - * verify it. - * - * Next, go to the URL in the `sst dev` CLI output. You should now receive an email rendered - * using JSX Email. - * - * ```ts title="index.ts" - * import { Template } from "./templates/email"; - * - * await render(Template({ - * email: "spongebob@example.com", - * name: "Spongebob Squarepants" - * })) - * ``` - * - * Once you are ready to go to production, you can: - * - * - [Request production access](https://docs.aws.amazon.com/ses/latest/dg/request-production-access.html) for SES - * - And [use your domain](/docs/component/aws/email/) to send emails - */ -export default $config({ - app(input) { - return { - name: "aws-jsx-email", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const email = new sst.aws.Email("MyEmail", { - sender: "email@example.com", - }); - const api = new sst.aws.Function("MyApi", { - handler: "index.handler", - link: [email], - url: true, - }); - - return { - api: api.url, - }; - }, -}); diff --git a/examples/aws-jsx-email/templates/email.tsx b/examples/aws-jsx-email/templates/email.tsx deleted file mode 100644 index 4c4591a9e9..0000000000 --- a/examples/aws-jsx-email/templates/email.tsx +++ /dev/null @@ -1,96 +0,0 @@ -import { - Body, - Button, - Container, - Head, - Hr, - Html, - Link, - Preview, - Section, - Text -} from 'jsx-email'; - - -export type TemplateProps = { - email: string; - name: string; -} - -const main = { - backgroundColor: '#f6f9fc', - fontFamily: - '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Ubuntu,sans-serif' -}; - -const container = { - backgroundColor: '#ffffff', - margin: '0 auto', - marginBottom: '64px', - padding: '20px 0 48px' -}; - -const box = { - padding: '0 48px' -}; - -const hr = { - borderColor: '#e6ebf1', - margin: '20px 0' -}; - -const paragraph = { - color: '#777', - fontSize: '16px', - lineHeight: '24px', - textAlign: 'left' as const -}; - -const anchor = { - color: '#777' -}; - -const button = { - backgroundColor: 'coral', - borderRadius: '5px', - color: '#fff', - display: 'block', - fontSize: '16px', - fontWeight: 'bold', - textAlign: 'center' as const, - textDecoration: 'none', - width: '100%', - padding: '10px' -}; - -export const defaultProps = { - email: 'batman@example.com', - name: 'Bruce Wayne' -} as TemplateProps; - -export const templateName = 'aws-jsx-email'; - -export const Template = ({ email, name }: TemplateProps) => ( - - - This is our email preview text for {name} <{email}> - - -
- This is our email body text - -
- - This is text content with a{' '} - - link - - . - -
-
- - -); diff --git a/examples/aws-jsx-email/tsconfig.json b/examples/aws-jsx-email/tsconfig.json deleted file mode 100644 index b49214f869..0000000000 --- a/examples/aws-jsx-email/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/tsconfig", - "compilerOptions": { - "declaration": true, - "declarationMap": true, - "esModuleInterop": true, - "jsx": "react-jsx", - "lib": ["ES2023"], - "module": "ESNext", - "moduleResolution": "node", - "noEmitOnError": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "preserveSymlinks": true, - "preserveWatchOutput": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "strict": true, - "strictNullChecks": true, - "target": "ESNext" - }, - "exclude": ["**/dist", "**/node_modules", "sst.config.ts"], - "include": ["templates", "index.ts", "sst-env.d.ts"] -} diff --git a/examples/aws-kinesis-stream/package.json b/examples/aws-kinesis-stream/package.json deleted file mode 100644 index 5cf5cc605b..0000000000 --- a/examples/aws-kinesis-stream/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aws-kinesis-stream", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "deploy": "go run ../../cmd/sst deploy", - "remove": "go run ../../cmd/sst remove", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "sst": "file:../../sdk/js" - }, - "dependencies": { - "@aws-sdk/client-kinesis": "^3.598.0" - } -} diff --git a/examples/aws-kinesis-stream/publisher.ts b/examples/aws-kinesis-stream/publisher.ts deleted file mode 100644 index 1ef13cba14..0000000000 --- a/examples/aws-kinesis-stream/publisher.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { KinesisClient, PutRecordsCommand } from "@aws-sdk/client-kinesis"; -import { Resource } from "sst"; - -export const handler = async (event) => { - const client = new KinesisClient(); - - await client.send( - new PutRecordsCommand({ - Records: [ - { - Data: JSON.stringify({ type: "foo" }), - PartitionKey: "1", - }, - { - Data: JSON.stringify({ type: "bar" }), - PartitionKey: "1", - }, - ], - StreamName: Resource.MyStream.name, - }) - ); - - return { - statusCode: 200, - body: JSON.stringify({ status: "sent" }, null, 2), - }; -}; diff --git a/examples/aws-kinesis-stream/sst.config.ts b/examples/aws-kinesis-stream/sst.config.ts deleted file mode 100644 index 4e116e92d4..0000000000 --- a/examples/aws-kinesis-stream/sst.config.ts +++ /dev/null @@ -1,44 +0,0 @@ -/// - -/** - * ## Kinesis streams - * - * Create a Kinesis stream, and subscribe to it with a function. - */ -export default $config({ - app(input) { - return { - name: "aws-kinesis-stream", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const stream = new sst.aws.KinesisStream("MyStream"); - - // Create a function subscribing to all events - stream.subscribe("AllSub", "subscriber.all"); - - // Create a function subscribing to events of `bar` type - stream.subscribe("FilteredSub", "subscriber.filtered", { - filters: [ - { - data: { - type: ["bar"], - }, - }, - ], - }); - - const app = new sst.aws.Function("MyApp", { - handler: "publisher.handler", - link: [stream], - url: true, - }); - - return { - app: app.url, - stream: stream.name, - }; - }, -}); diff --git a/examples/aws-kinesis-stream/subscriber.ts b/examples/aws-kinesis-stream/subscriber.ts deleted file mode 100644 index 8042f2aafc..0000000000 --- a/examples/aws-kinesis-stream/subscriber.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { KinesisStreamHandler } from "aws-lambda"; - -export const all: KinesisStreamHandler = async (event) => { - for (const record of event.Records) { - const data = Buffer.from(record.kinesis.data, "base64").toString(); - console.log(`"All" subscriber received:`, data); - } -}; - -export const filtered: KinesisStreamHandler = async (event) => { - for (const record of event.Records) { - const data = Buffer.from(record.kinesis.data, "base64").toString(); - console.log(`"Filtered" subscriber received:`, data); - } -}; diff --git a/examples/aws-lambda-ai-stream/index.ts b/examples/aws-lambda-ai-stream/index.ts deleted file mode 100644 index 07cbaf48d0..0000000000 --- a/examples/aws-lambda-ai-stream/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { streamText } from 'ai'; - -export const handler = awslambda.streamifyResponse(async (_event, responseStream) => { - const result = streamText({ - model: 'amazon/nova-micro', - prompt: 'Write a poem about clouds that is twenty paragraphs long.', - }); - - responseStream.setContentType('text/plain'); - for await (const chunk of result.textStream) { - responseStream.write(chunk); - process.stdout.write(chunk); - } - responseStream.end(); -}); diff --git a/examples/aws-lambda-ai-stream/package.json b/examples/aws-lambda-ai-stream/package.json deleted file mode 100644 index dbb40556da..0000000000 --- a/examples/aws-lambda-ai-stream/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "aws-lambda-ai-stream", - "type": "module", - "dependencies": { - "ai": "^6.0.116", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145" - } -} diff --git a/examples/aws-lambda-ai-stream/sst.config.ts b/examples/aws-lambda-ai-stream/sst.config.ts deleted file mode 100644 index 97e6c3feb7..0000000000 --- a/examples/aws-lambda-ai-stream/sst.config.ts +++ /dev/null @@ -1,79 +0,0 @@ -/// - -/** - * ## AWS Lambda AI streaming - * - * An example on how to stream AI responses from a Lambda function using the - * [AI SDK](https://ai-sdk.dev). - * - * Uses `streamText` from the AI SDK to stream a response - * through a Lambda function URL. - * - * ```ts title="sst.config.ts" - * { - * streaming: true - * } - * ``` - * - * The handler uses `awslambda.streamifyResponse` to stream the AI response - * back to the client as it's generated. - * - * ```ts title="index.ts" - * export const handler = awslambda.streamifyResponse( - * async (_event, responseStream) => { - * const result = streamText({ - * model: "amazon/nova-micro", - * prompt: "Write a poem about clouds that is twenty paragraphs long.", - * }); - * - * responseStream.setContentType("text/plain"); - * for await (const chunk of result.textStream) { - * responseStream.write(chunk); - * } - * responseStream.end(); - * }, - * ); - * ``` - * - * Set the API key for the AI gateway. - * - * ```bash - * sst secret set AiGatewayApiKey your-api-key-here - * ``` - * - * Use the "Run Client" dev command in the multiplexer to invoke the server and see - * the streamed response. - * - */ -export default $config({ - app(input) { - return { - name: "aws-lambda-ai-stream", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const server = new sst.aws.Function("Server", { - url: true, - streaming: true, - timeout: "15 minutes", - handler: "index.handler", - environment: { - AI_GATEWAY_API_KEY: new sst.Secret("AiGatewayApiKey").value, - }, - }); - - new sst.x.DevCommand("Client", { - dev: { - autostart: false, - command: $interpolate`curl --no-buffer ${server.url}`, - title: "Run Client", - }, - }); - - return { - url: server.url, - }; - }, -}); diff --git a/examples/aws-lambda-cron/cron.ts b/examples/aws-lambda-cron/cron.ts deleted file mode 100644 index 8fabb78be5..0000000000 --- a/examples/aws-lambda-cron/cron.ts +++ /dev/null @@ -1,4 +0,0 @@ -export async function handler(event: any) { - console.log("Cron triggered", JSON.stringify(event)); - return { statusCode: 200 }; -} diff --git a/examples/aws-lambda-cron/package.json b/examples/aws-lambda-cron/package.json deleted file mode 100644 index 1725914407..0000000000 --- a/examples/aws-lambda-cron/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-cron-lambda", - "private": true, - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-lambda-cron/sst.config.ts b/examples/aws-lambda-cron/sst.config.ts deleted file mode 100644 index f3fc0b6ccc..0000000000 --- a/examples/aws-lambda-cron/sst.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-lambda-cron", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const queue = new sst.aws.Queue("MyDLQ"); - - const cron = new sst.aws.CronV2("MyCron", { - schedule: "rate(1 minute)", - function: "cron.handler", - timezone: "America/New_York", - retries: 3, - dlq: queue.arn, - }); - - return { - function: cron.nodes.function.name, - dlq: queue.arn, - }; - }, -}); diff --git a/examples/aws-lambda-cron/tsconfig.json b/examples/aws-lambda-cron/tsconfig.json deleted file mode 100644 index 6ec1c39406..0000000000 --- a/examples/aws-lambda-cron/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "bundler", - "strict": true, - "esModuleInterop": true - } -} diff --git a/examples/aws-lambda-golang/src/go.mod b/examples/aws-lambda-golang/src/go.mod deleted file mode 100644 index a7eafea675..0000000000 --- a/examples/aws-lambda-golang/src/go.mod +++ /dev/null @@ -1,8 +0,0 @@ -module aws-lambda - -go 1.23.4 - -require ( - github.com/aws/aws-lambda-go v1.47.0 - github.com/sst/sst/v3 v3.4.24-0.20241218234311-d6f5cc752318 -) diff --git a/examples/aws-lambda-golang/src/go.sum b/examples/aws-lambda-golang/src/go.sum deleted file mode 100644 index f3a3bcaf9f..0000000000 --- a/examples/aws-lambda-golang/src/go.sum +++ /dev/null @@ -1,12 +0,0 @@ -github.com/aws/aws-lambda-go v1.47.0 h1:0H8s0vumYx/YKs4sE7YM0ktwL2eWse+kfopsRI1sXVI= -github.com/aws/aws-lambda-go v1.47.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sst/sst/v3 v3.4.24-0.20241218234311-d6f5cc752318 h1:9qjY8XcNVRM6/Hbx+z3GdhkPgFImgUDJy1uWObko2h4= -github.com/sst/sst/v3 v3.4.24-0.20241218234311-d6f5cc752318/go.mod h1:rxQ4Pi7xaYAbyfLt0rFREzQDLE72clWKxudGKG9Xpt4= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/examples/aws-lambda-golang/src/main.go b/examples/aws-lambda-golang/src/main.go deleted file mode 100644 index f19721e58c..0000000000 --- a/examples/aws-lambda-golang/src/main.go +++ /dev/null @@ -1,18 +0,0 @@ -package main - -import ( - "github.com/aws/aws-lambda-go/lambda" - "github.com/sst/sst/v3/sdk/golang/resource" -) - -func handler() (string, error) { - bucket, err := resource.Get("MyBucket", "name") - if err != nil { - return "", err - } - return bucket.(string), nil -} - -func main() { - lambda.Start(handler) -} diff --git a/examples/aws-lambda-golang/sst.config.ts b/examples/aws-lambda-golang/sst.config.ts deleted file mode 100644 index 19d2c1301e..0000000000 --- a/examples/aws-lambda-golang/sst.config.ts +++ /dev/null @@ -1,60 +0,0 @@ -/// - -/** - * ## AWS Lambda Go - * - * This example shows how to use the [`go`](https://golang.org/) runtime in your Lambda - * functions. - * - * Our Go function is in the `src` directory and we point to it in our function. - * - * ```ts title="sst.config.ts" {5} - * new sst.aws.Function("MyFunction", { - * url: true, - * runtime: "go", - * link: [bucket], - * handler: "./src", - * }); - * ``` - * - * We are also linking it to an S3 bucket. We can reference the bucket in our function. - * - * ```go title="src/main.go" {2} - * func handler() (string, error) { - * bucket, err := resource.Get("MyBucket", "name") - * if err != nil { - * return "", err - * } - * return bucket.(string), nil - * } - * ``` - * - * The `resource.Get` function is from the SST Go SDK. - * - * ```go title="src/main.go" {2} - * import ( - * "github.com/sst/sst/v3/sdk/golang/resource" - * ) - * ``` - * - * The `sst dev` CLI also supports running your Go function [_Live_](/docs/live). - */ -export default $config({ - app(input) { - return { - name: "aws-lambda-golang", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket"); - - new sst.aws.Function("MyFunction", { - url: true, - runtime: "go", - link: [bucket], - handler: "./src", - }); - }, -}); diff --git a/examples/aws-lambda-hook/.gitignore b/examples/aws-lambda-hook/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-lambda-hook/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-lambda-hook/index.js b/examples/aws-lambda-hook/index.js deleted file mode 100644 index e65fb38036..0000000000 --- a/examples/aws-lambda-hook/index.js +++ /dev/null @@ -1,7 +0,0 @@ -export async function handler(event,) { - console.log(event); - return { - statusCode: 200, - body: 'Hello World', - }; -} diff --git a/examples/aws-lambda-hook/package.json b/examples/aws-lambda-hook/package.json deleted file mode 100644 index 90bae21e53..0000000000 --- a/examples/aws-lambda-hook/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-lambda-hook", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "type": "commonjs", - "dependencies": { - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.149" - } -} diff --git a/examples/aws-lambda-hook/sst.config.ts b/examples/aws-lambda-hook/sst.config.ts deleted file mode 100644 index 3935f30d6a..0000000000 --- a/examples/aws-lambda-hook/sst.config.ts +++ /dev/null @@ -1,33 +0,0 @@ -/// - -/** - * ## AWS Lambda build hook - * - * In this example we hook into the Lambda function build process with - * `hook.postbuild`. - * - * This is useful for modifying the generated Lambda function code before it's - * uploaded to AWS. It can also be used for uploading the generated sourcemaps - * to a service like Sentry. - */ -export default $config({ - app(input) { - return { - name: "aws-lambda-hook", - removal: input?.stage === "production" ? "retain" : "remove", - protect: ["production"].includes(input?.stage), - home: "aws", - }; - }, - async run() { - new sst.aws.Function("MyFunction", { - url: true, - handler: "index.handler", - hook: { - async postbuild(dir) { - console.log(`postbuild ------- ${dir}`); - }, - }, - }); - }, -}); diff --git a/examples/aws-lambda-hook/tsconfig.json b/examples/aws-lambda-hook/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-lambda-hook/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-lambda-retry-with-queues/package.json b/examples/aws-lambda-retry-with-queues/package.json deleted file mode 100644 index 64cfdc9882..0000000000 --- a/examples/aws-lambda-retry-with-queues/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-lambda-retry-with-queues", - "version": "1.0.0", - "description": "", - "type": "module", - "devDependencies": { - "@types/aws-lambda": "8.10.146" - }, - "dependencies": { - "sst": "file:../../sdk/js", - "@aws-sdk/client-lambda": "^3.714.0", - "@aws-sdk/client-sqs": "^3.714.0", - "zod": "^3.24.1" - } -} diff --git a/examples/aws-lambda-retry-with-queues/src/bus-subscriber.ts b/examples/aws-lambda-retry-with-queues/src/bus-subscriber.ts deleted file mode 100644 index fe11df3db3..0000000000 --- a/examples/aws-lambda-retry-with-queues/src/bus-subscriber.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { bus } from "sst/aws/bus"; -import { testEvent } from "./event"; - -export const handler = bus.subscriber([testEvent], async (evt, raw) => { - console.log("event", evt, raw, process.env); - const message = evt.properties.message; - - if (message !== "hello") { - throw new Error("🚨 bus subscriber failed"); - } -}); diff --git a/examples/aws-lambda-retry-with-queues/src/event.ts b/examples/aws-lambda-retry-with-queues/src/event.ts deleted file mode 100644 index 5cf54e780b..0000000000 --- a/examples/aws-lambda-retry-with-queues/src/event.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { event } from "sst/event"; -import crypto from "node:crypto"; -import { z } from "zod"; - -export const defineEvent = event.builder({ - validator: (schema) => { - return (input) => { - return schema.parse(input); - }; - }, - metadata: () => { - return { - idempotencyKey: crypto.randomUUID(), - timestamp: new Date().toISOString(), - }; - }, -}); - -export const testEvent = defineEvent( - "test", - z.object({ - message: z.string(), - }) -); diff --git a/examples/aws-lambda-retry-with-queues/src/publisher.ts b/examples/aws-lambda-retry-with-queues/src/publisher.ts deleted file mode 100644 index de80c2f044..0000000000 --- a/examples/aws-lambda-retry-with-queues/src/publisher.ts +++ /dev/null @@ -1,36 +0,0 @@ -import type { LambdaFunctionURLHandler } from "aws-lambda"; -import { bus } from "sst/aws/bus"; -import { Resource } from "sst"; -import { testEvent } from "./event"; - -// This function sends a message to the bus. This could be any other service which pugliches message to the bus. -export const handler: LambdaFunctionURLHandler = async (evt) => { - if (!evt.body) { - return { - statusCode: 400, - body: JSON.stringify({ message: "missing body" }), - }; - } - - try { - const body = JSON.parse(evt.body); - const message = body.message; - if (typeof message !== "string") { - return { - statusCode: 400, - body: JSON.stringify({ message: "message must be a string" }), - }; - } - bus.publish(Resource.bus.name, testEvent, { message }); - } catch (e) { - console.error(e); - return { - statusCode: 500, - body: JSON.stringify({ message: "error" }), - }; - } - - return { - statusCode: 200, - }; -}; diff --git a/examples/aws-lambda-retry-with-queues/src/retry.ts b/examples/aws-lambda-retry-with-queues/src/retry.ts deleted file mode 100644 index 93685227c5..0000000000 --- a/examples/aws-lambda-retry-with-queues/src/retry.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { - LambdaClient, - InvokeCommand, - GetFunctionCommand, - ResourceNotFoundException, -} from "@aws-sdk/client-lambda"; -import { SQSClient, SendMessageCommand } from "@aws-sdk/client-sqs"; -import type { SQSHandler } from "aws-lambda"; -import { Resource } from "sst"; - -const lambda = new LambdaClient({}); -lambda.middlewareStack.remove("recursionDetectionMiddleware"); -const sqs = new SQSClient({}); -sqs.middlewareStack.remove("recursionDetectionMiddleware"); - -export const handler: SQSHandler = async (evt) => { - for (const record of evt.Records) { - const parsed = JSON.parse(record.body); - console.log("body", parsed); - const functionName = parsed.requestContext.functionArn - .replace(":$LATEST", "") - .split(":") - .pop(); - if (parsed.responsePayload) { - const attempt = (parsed.requestPayload.attempts || 0) + 1; - - const info = await lambda.send( - new GetFunctionCommand({ - FunctionName: functionName, - }), - ); - const max = - Number.parseInt( - info.Configuration?.Environment?.Variables?.RETRIES || "", - ) || 0; - console.log("max retries", max); - if (attempt > max) { - console.log(`giving up after ${attempt} retries`); - // send to dlq - await sqs.send( - new SendMessageCommand({ - QueueUrl: Resource.dlq.url, - MessageBody: JSON.stringify({ - requestPayload: parsed.requestPayload, - requestContext: parsed.requestContext, - responsePayload: parsed.responsePayload, - }), - }), - ); - return; - } - const seconds = Math.min(Math.pow(2, attempt), 900); - console.log( - "delaying retry by ", - seconds, - "seconds for attempt", - attempt, - ); - parsed.requestPayload.attempts = attempt; - await sqs.send( - new SendMessageCommand({ - QueueUrl: Resource.retryQueue.url, - DelaySeconds: seconds, - MessageBody: JSON.stringify({ - requestPayload: parsed.requestPayload, - requestContext: parsed.requestContext, - }), - }), - ); - } - - if (!parsed.responsePayload) { - console.log("triggering function"); - try { - await lambda.send( - new InvokeCommand({ - InvocationType: "Event", - Payload: Buffer.from(JSON.stringify(parsed.requestPayload)), - FunctionName: functionName, - }), - ); - } catch (e) { - if (e instanceof ResourceNotFoundException) { - return; - } - throw e; - } - } - } -}; diff --git a/examples/aws-lambda-retry-with-queues/sst.config.ts b/examples/aws-lambda-retry-with-queues/sst.config.ts deleted file mode 100644 index 2f912c2147..0000000000 --- a/examples/aws-lambda-retry-with-queues/sst.config.ts +++ /dev/null @@ -1,223 +0,0 @@ -/// - -/** - * ## AWS Lambda retry with queues - * - * An example on how to retry Lambda invocations using SQS queues. - * - * Create a SQS retry queue which will be set as the destination for the Lambda function. - * - * ```ts title="src/retry.ts" - * const retryQueue = new sst.aws.Queue("retryQueue"); - * - * const bus = new sst.aws.Bus("bus"); - * - * const busSubscriber = bus.subscribe("busSubscriber", { - * handler: "src/bus-subscriber.handler", - * environment: { - * RETRIES: "2", // set the number of retries - * }, - * link: [retryQueue], // so the function can send messages to the retry queue - * }); - * - * new aws.lambda.FunctionEventInvokeConfig("eventConfig", { - * functionName: $resolve([busSubscriber.nodes.function.name]).apply( - * ([name]) => name, - * ), - * maximumRetryAttempts: 2, // default is 2, must be between 0 and 2 - * destinationConfig: { - * onFailure: { - * destination: retryQueue.arn, - * }, - * }, - * }); - * ``` - * - * Create a bus subscriber which will publish messages to the bus. Include a DLQ for messages that continue to fail. - * - * ```ts title="sst.config.ts" - * - * const dlq = new sst.aws.Queue("dlq"); - * - * retryQueue.subscribe({ - * handler: "src/retry.handler", - * link: [busSubscriber.nodes.function, retryQueue, dlq], - * timeout: "30 seconds", - * environment: { - * RETRIER_QUEUE_URL: retryQueue.url, - * }, - * permissions: [ - * { - * actions: ["lambda:GetFunction", "lambda:InvokeFunction"], - * resources: [ - * $interpolate`arn:aws:lambda:${aws.getRegionOutput().region}:${ - * aws.getCallerIdentityOutput().accountId - * }:function:*`, - * ], - * }, - * ], - * transform: { - * function: { - * deadLetterConfig: { - * targetArn: dlq.arn, - * }, - * }, - * }, - * }); - * ``` - * - * - * The Retry function will read mesaages and send back to the queue to be retried with a backoff. - * - * ```ts title="src/retry.ts" - * export const handler: SQSHandler = async (evt) => { - * for (const record of evt.Records) { - * const parsed = JSON.parse(record.body); - * console.log("body", parsed); - * const functionName = parsed.requestContext.functionArn - * .replace(":$LATEST", "") - * .split(":") - * .pop(); - * if (parsed.responsePayload) { - * const attempt = (parsed.requestPayload.attempts || 0) + 1; - * - * const info = await lambda.send( - * new GetFunctionCommand({ - * FunctionName: functionName, - * }), - * ); - * const max = - * Number.parseInt( - * info.Configuration?.Environment?.Variables?.RETRIES || "", - * ) || 0; - * console.log("max retries", max); - * if (attempt > max) { - * console.log(`giving up after ${attempt} retries`); - * // send to dlq - * await sqs.send( - * new SendMessageCommand({ - * QueueUrl: Resource.dlq.url, - * MessageBody: JSON.stringify({ - * requestPayload: parsed.requestPayload, - * requestContext: parsed.requestContext, - * responsePayload: parsed.responsePayload, - * }), - * }), - * ); - * return; - * } - * const seconds = Math.min(Math.pow(2, attempt), 900); - * console.log( - * "delaying retry by ", - * seconds, - * "seconds for attempt", - * attempt, - * ); - * parsed.requestPayload.attempts = attempt; - * await sqs.send( - * new SendMessageCommand({ - * QueueUrl: Resource.retryQueue.url, - * DelaySeconds: seconds, - * MessageBody: JSON.stringify({ - * requestPayload: parsed.requestPayload, - * requestContext: parsed.requestContext, - * }), - * }), - * ); - * } - * - * if (!parsed.responsePayload) { - * console.log("triggering function"); - * try { - * await lambda.send( - * new InvokeCommand({ - * InvocationType: "Event", - * Payload: Buffer.from(JSON.stringify(parsed.requestPayload)), - * FunctionName: functionName, - * }), - * ); - * } catch (e) { - * if (e instanceof ResourceNotFoundException) { - * return; - * } - * throw e; - * } - * } - * } - * }; - * ``` - */ -export default $config({ - app(input) { - return { - name: "aws-lambda-retry-with-queues", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const dlq = new sst.aws.Queue("dlq"); - - const retryQueue = new sst.aws.Queue("retryQueue"); - - const bus = new sst.aws.Bus("bus"); - - const busSubscriber = bus.subscribe("busSubscriber", { - handler: "src/bus-subscriber.handler", - environment: { - RETRIES: "2", - }, - link: [retryQueue], // so the function can send messages to the queue - }); - - const publisher = new sst.aws.Function("publisher", { - handler: "src/publisher.handler", - link: [bus], - url: true, - }); - - new aws.lambda.FunctionEventInvokeConfig("eventConfig", { - functionName: $resolve([busSubscriber.nodes.function.name]).apply( - ([name]) => name, - ), - maximumRetryAttempts: 1, - destinationConfig: { - onFailure: { - destination: retryQueue.arn, - }, - }, - }); - - retryQueue.subscribe({ - handler: "src/retry.handler", - link: [busSubscriber.nodes.function, retryQueue, dlq], - timeout: "30 seconds", - environment: { - RETRIER_QUEUE_URL: retryQueue.url, - }, - permissions: [ - { - actions: ["lambda:GetFunction", "lambda:InvokeFunction"], - resources: [ - $interpolate`arn:aws:lambda:${aws.getRegionOutput().region}:${ - aws.getCallerIdentityOutput().accountId - }:function:*`, - ], - }, - ], - transform: { - function: { - deadLetterConfig: { - targetArn: dlq.arn, - }, - }, - }, - }); - - return { - publisher: publisher.url, - dlq: dlq.url, - retryQueue: retryQueue.url, - }; - }, -}); diff --git a/examples/aws-lambda-retry-with-queues/tsconfig.json b/examples/aws-lambda-retry-with-queues/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-lambda-retry-with-queues/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-lambda-rust-multiple-binaries/.gitignore b/examples/aws-lambda-rust-multiple-binaries/.gitignore deleted file mode 100644 index 2a7be17e50..0000000000 --- a/examples/aws-lambda-rust-multiple-binaries/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -target - -# sst -.sst diff --git a/examples/aws-lambda-rust-multiple-binaries/Cargo.toml b/examples/aws-lambda-rust-multiple-binaries/Cargo.toml deleted file mode 100644 index 0c41f4ac1e..0000000000 --- a/examples/aws-lambda-rust-multiple-binaries/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -name = "aws-lambda-rust-multi-bin" -version = "0.1.0" -edition = "2021" - -[dependencies] -aws-config = { version = "1.5.16", features = ["behavior-version-latest"] } -aws-sdk-s3 = "1.73.0" -lambda_runtime = "0.13.0" -serde = { version = "1.0.217", features = ["derive"] } -serde_json = "1.0.138" -# this will break when not in this repo. -sst_sdk = { version = "0.1.0", path = "../../sdk/rust" } -# sst_sdk = "0.1.0" -tokio = { version = "1", features = ["macros"] } -uuid = { version = "1.13.1", features = ["v4"] } - -[[bin]] -name = "push" -path = "src/push.rs" - -[[bin]] -name = "pop" -path = "src/pop.rs" diff --git a/examples/aws-lambda-rust-multiple-binaries/src/pop.rs b/examples/aws-lambda-rust-multiple-binaries/src/pop.rs deleted file mode 100644 index 9106c96e6c..0000000000 --- a/examples/aws-lambda-rust-multiple-binaries/src/pop.rs +++ /dev/null @@ -1,48 +0,0 @@ -use std::time::Duration; - -use aws_sdk_s3::presigning::PresigningConfig; -use lambda_runtime::{service_fn, Error, LambdaEvent}; -use serde::Deserialize; -use serde_json::Value; -use sst_sdk::Resource; - -#[derive(Deserialize, Debug)] -struct Bucket { - name: String, -} - -async fn latest(_event: LambdaEvent) -> Result { - let config = aws_config::load_from_env().await; - let client = aws_sdk_s3::Client::new(&config); - let resource = Resource::init().unwrap(); - let Bucket { name } = resource.get("Bucket").unwrap(); - - let objects = client.list_objects().bucket(&name).send().await.unwrap(); - let latest = objects - .contents() - .into_iter() - .min_by_key(|o| o.last_modified().unwrap()) - .unwrap(); - - let url = client - .get_object() - .bucket(name) - .key(latest.key().unwrap()) - .presigned( - PresigningConfig::builder() - .expires_in(Duration::from_secs(60 * 10)) - .build() - .unwrap(), - ) - .await - .unwrap(); - - Ok(url.uri().to_string()) -} - -#[tokio::main] -async fn main() -> Result<(), Error> { - let func = service_fn(latest); - lambda_runtime::run(func).await?; - Ok(()) -} diff --git a/examples/aws-lambda-rust-multiple-binaries/src/push.rs b/examples/aws-lambda-rust-multiple-binaries/src/push.rs deleted file mode 100644 index 7ee767072c..0000000000 --- a/examples/aws-lambda-rust-multiple-binaries/src/push.rs +++ /dev/null @@ -1,41 +0,0 @@ -use std::time::Duration; - -use aws_sdk_s3::presigning::PresigningConfig; -use lambda_runtime::{service_fn, Error, LambdaEvent}; -use serde::Deserialize; -use serde_json::Value; -use sst_sdk::Resource; - -#[derive(Deserialize, Debug)] -struct Bucket { - name: String, -} - -async fn presigned_url(_event: LambdaEvent) -> Result { - let config = aws_config::load_from_env().await; - let client = aws_sdk_s3::Client::new(&config); - let resource = Resource::init().unwrap(); - let Bucket { name } = resource.get("Bucket").unwrap(); - - let url = client - .put_object() - .bucket(name) - .key(uuid::Uuid::new_v4()) - .presigned( - PresigningConfig::builder() - .expires_in(Duration::from_secs(60 * 10)) - .build() - .unwrap(), - ) - .await - .unwrap(); - - Ok(url.uri().to_string()) -} - -#[tokio::main] -async fn main() -> Result<(), Error> { - let func = service_fn(presigned_url); - lambda_runtime::run(func).await?; - Ok(()) -} diff --git a/examples/aws-lambda-rust-multiple-binaries/sst.config.ts b/examples/aws-lambda-rust-multiple-binaries/sst.config.ts deleted file mode 100644 index f229ab5948..0000000000 --- a/examples/aws-lambda-rust-multiple-binaries/sst.config.ts +++ /dev/null @@ -1,80 +0,0 @@ -/// - -/** - * ## AWS Lamda Rust multiple-binaries - * - * This example shows how to deploy multiple binary rust project to AWS Lambda. - * - * SST relies on the work of [cargo lambda](https://cargo-lambda) to build and deploy Rust Lambda functions. - * - * What is special about the following file is that we are defining multiple binaries using the `[[bin]]` section in the `Cargo.toml` file. - * - * ```toml title="Cargo.toml" {13,14,15,17,18,19} - * [package] - * name = "aws-lambda-rust-multi-bin" - * version = "0.1.0" - * edition = "2021" - * - * [dependencies] - * lambda_runtime = "0.13.0" - * serde = { version = "1.0.217", features = ["derive"] } - * serde_json = "1.0.138" - * tokio = { version = "1", features = ["macros"] } - * # -- please note ommited dependencies -- - * - * [[bin]] - * name = "push" - * path = "src/push.rs" - * - * [[bin]] - * name = "pop" - * path = "src/pop.rs" - * ``` - * - * We then utilise the . syntax to specify the handler binary - * - * ```ts title="sst.config.ts" {5,11} - * new sst.aws.Function("push", { - * url: true, - * runtime: "rust", - * link: [bucket], - * handler: "./.push", - * }); - * new sst.aws.Function("pop", { - * url: true, - * runtime: "rust", - * link: [bucket], - * handler: "./.pop", - * }); - * ``` - */ - -export default $config({ - app(input) { - return { - name: "aws-lambda-rust-multiple-binaries", - removal: input?.stage === "production" ? "retain" : "remove", - protect: ["production"].includes(input?.stage), - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("Bucket"); - const push = new sst.aws.Function("push", { - runtime: "rust", - handler: "./.push", - url: true, - architecture: "arm64", - link: [bucket], - }); - const pop = new sst.aws.Function("pop", { - runtime: "rust", - handler: "./.pop", - url: true, - architecture: "arm64", - link: [bucket], - }); - - return { push_url: push.url, pop_url: pop.url }; - }, -}); diff --git a/examples/aws-lambda-stream/.gitignore b/examples/aws-lambda-stream/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-lambda-stream/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-lambda-stream/index.ts b/examples/aws-lambda-stream/index.ts deleted file mode 100644 index fb8e0b89d2..0000000000 --- a/examples/aws-lambda-stream/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -export const handler = awslambda.streamifyResponse( - async (event, stream) => { - stream = awslambda.HttpResponseStream.from(stream, { - statusCode: 200, - headers: { - "Content-Type": "text/plain; charset=UTF-8", - "X-Content-Type-Options": "nosniff", - }, - }); - - stream.write("Hello "); - await new Promise((resolve) => setTimeout(resolve, 3000)); - stream.write("World"); - - stream.end(); - }, -); diff --git a/examples/aws-lambda-stream/package.json b/examples/aws-lambda-stream/package.json deleted file mode 100644 index bda03c194b..0000000000 --- a/examples/aws-lambda-stream/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "aws-lambda-stream", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "^8.10.161" - } -} diff --git a/examples/aws-lambda-stream/sst.config.ts b/examples/aws-lambda-stream/sst.config.ts deleted file mode 100644 index 8bea35f559..0000000000 --- a/examples/aws-lambda-stream/sst.config.ts +++ /dev/null @@ -1,60 +0,0 @@ -/// - -/** - * ## AWS Lambda streaming - * - * An example on how to enable streaming for Lambda functions. - * - * ```ts title="sst.config.ts" - * { - * streaming: true - * } - * ``` - * - * Use the `awslambda.streamifyResponse` function to wrap your handler. The `awslambda` - * global is provided by the Lambda execution environment at runtime, and SST provides it - * automatically during `sst dev` as well. For TypeScript types, importing from - * `@types/aws-lambda` will augment the global namespace. - * - * ```ts title="index.ts" - * export const handler = awslambda.streamifyResponse( - * async (event, stream) => { - * stream = awslambda.HttpResponseStream.from(stream, { - * statusCode: 200, - * headers: { - * "Content-Type": "text/plain; charset=UTF-8", - * "X-Content-Type-Options": "nosniff", - * }, - * }); - * - * stream.write("Hello "); - * await new Promise((resolve) => setTimeout(resolve, 3000)); - * stream.write("World"); - * - * stream.end(); - * }, - * ); - * ``` - * - */ -export default $config({ - app(input) { - return { - name: "aws-lambda-stream", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const fn = new sst.aws.Function("MyFunction", { - url: true, - streaming: true, - timeout: "15 minutes", - handler: "index.handler", - }); - - return { - url: fn.url, - }; - }, -}); diff --git a/examples/aws-lambda-stream/tsconfig.json b/examples/aws-lambda-stream/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-lambda-stream/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-lambda-trpc-stream/package.json b/examples/aws-lambda-trpc-stream/package.json deleted file mode 100644 index 94bc5f1505..0000000000 --- a/examples/aws-lambda-trpc-stream/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "aws-lambda-trpc-stream", - "type": "module", - "dependencies": { - "@trpc/client": "^11.11.0", - "@trpc/server": "^11.11.0", - "sst": "file:../../sdk/js", - "zod": "^4.3.6" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145" - } -} diff --git a/examples/aws-lambda-trpc-stream/sst.config.ts b/examples/aws-lambda-trpc-stream/sst.config.ts deleted file mode 100644 index 0d59f8a635..0000000000 --- a/examples/aws-lambda-trpc-stream/sst.config.ts +++ /dev/null @@ -1,48 +0,0 @@ -/// - -/** - * ## AWS Lambda tRPC streaming - * - * An example on how to use tRPC with Lambda streaming. - * - * Uses `@trpc/server`'s `awsLambdaStreamingRequestHandler` adapter to handle - * streaming responses through Lambda function URLs. - * - * The `trpc-server` function defines a tRPC router and streams responses. - * The `trpc-client` function invokes the server using `httpBatchStreamLink`. - * - * Streaming is supported in both `sst dev` and `sst deploy`. - * - */ -export default $config({ - app(input) { - return { - name: 'aws-lambda-trpc-stream', - removal: input?.stage === 'production' ? 'retain' : 'remove', - home: 'aws', - }; - }, - async run() { - const trpcServer = new sst.aws.Function('TrpcServer', { - handler: 'trpc-server.handler', - streaming: true, - url: true, - runtime: 'nodejs24.x', - }); - - new sst.x.DevCommand('Client', { - dev: { - autostart: false, - command: $interpolate`npx tsx trpc-client.ts`, - title: 'Run Client', - }, - environment: { - TRPC_SERVER_URL: trpcServer.url, - }, - }); - - return { - serverUrl: trpcServer.url, - }; - }, -}); diff --git a/examples/aws-lambda-trpc-stream/trpc-client.ts b/examples/aws-lambda-trpc-stream/trpc-client.ts deleted file mode 100644 index aec7000b10..0000000000 --- a/examples/aws-lambda-trpc-stream/trpc-client.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { - createTRPCClient, - httpBatchStreamLink, - TRPCClientError, -} from "@trpc/client"; -import { ApiRouter } from "./trpc-server"; - -const client = createTRPCClient({ - links: [ - httpBatchStreamLink({ - url: process.env.TRPC_SERVER_URL, - methodOverride: "POST", - }), - ], -}); - -export const main = async () => { - await Promise.all( - Array.from({ length: 10 }, async (_, idx) => { - const delay = Math.random() * 8_000; - console.log("sending request", idx); - try { - const res = await client.getById.query({ delay, idx }); - console.log("got response", res.idx); - } catch (err) { - if (isTrpcError(err)) { - console.error("received error", idx, err.shape.message); - } else { - console.error("received unexpecte error", idx); - } - } - }), - ); -}; - -const isTrpcError = (err: unknown): err is TRPCClientError => { - return !!err && err instanceof TRPCClientError; -}; - -main().catch(console.error); diff --git a/examples/aws-lambda-trpc-stream/trpc-server.ts b/examples/aws-lambda-trpc-stream/trpc-server.ts deleted file mode 100644 index 6fb341e390..0000000000 --- a/examples/aws-lambda-trpc-stream/trpc-server.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { initTRPC, TRPCError } from '@trpc/server'; -import { awsLambdaStreamingRequestHandler } from '@trpc/server/adapters/aws-lambda'; -import z from 'zod'; - -const { router, procedure } = initTRPC.create(); - -const apiRouter = router({ - getById: procedure - .input( - z.object({ - delay: z.number(), - idx: z.number(), - }), - ) - .query(async ({ input }) => { - await new Promise((r) => setTimeout(r, input.delay)); - if (Math.random() < 0.5) { - console.log('sending response', input.delay); - return { id: Math.random(), idx: input.idx }; - } - console.log('sending error', input.idx); - throw new TRPCError({ - code: 'BAD_REQUEST', - message: 'Random failure', - }); - }), -}); - -export type ApiRouter = typeof apiRouter; - -export const handler = awslambda.streamifyResponse( - awsLambdaStreamingRequestHandler({ - router: apiRouter, - allowMethodOverride: true, - }), -); diff --git a/examples/aws-lambda-vpc/.gitignore b/examples/aws-lambda-vpc/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-lambda-vpc/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-lambda-vpc/index.ts b/examples/aws-lambda-vpc/index.ts deleted file mode 100644 index 4cb5e4819a..0000000000 --- a/examples/aws-lambda-vpc/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Resource } from "sst"; -import { Cluster } from "ioredis"; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -export const handler = async () => { - const counter = await redis.incr("counter"); - return { - statusCode: 200, - body: `Hit counter: ${counter}` - }; -}; diff --git a/examples/aws-lambda-vpc/package.json b/examples/aws-lambda-vpc/package.json deleted file mode 100644 index 38b2e18d93..0000000000 --- a/examples/aws-lambda-vpc/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-lambda-vpc", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "ioredis": "^5.4.1", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145" - } -} diff --git a/examples/aws-lambda-vpc/sst.config.ts b/examples/aws-lambda-vpc/sst.config.ts deleted file mode 100644 index 6fef731bf9..0000000000 --- a/examples/aws-lambda-vpc/sst.config.ts +++ /dev/null @@ -1,66 +0,0 @@ -/// - -/** - * ## AWS Lambda in a VPC - * - * You can use SST to locally work on Lambda functions that are in a VPC. To do so, you'll - * need to enable `bastion` and `nat` on the `Vpc` component. - * - * ```ts title="sst.config.ts" - * new sst.aws.Vpc("MyVpc", { bastion: true, nat: "managed" }); - * ``` - * - * The NAT gateway is necessary to allow your Lambda function to connect to the internet. While, - * the bastion host is necessary for your local machine to be able to tunnel to the VPC. - * - * You'll need to install the tunnel, if you haven't done this before. - * - * ```bash "sudo" - * sudo sst tunnel install - * ``` - * - * This needs _sudo_ to create the network interface on your machine. You'll only need to do - * this once. - * - * Now you can run `sst dev`, your function can access resources in the VPC. For example, here - * we are connecting to a Redis cluster. - * - * ```ts title="index.ts" - * const redis = new Cluster( - * [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - * { - * dnsLookup: (address, callback) => callback(null, address), - * redisOptions: { - * tls: {}, - * username: Resource.MyRedis.username, - * password: Resource.MyRedis.password, - * }, - * } - * ); - * ``` - * - * The Redis cluster is in the same VPC as the function. - */ -export default $config({ - app(input) { - return { - name: "aws-lambda-vpc", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true, nat: "managed" }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const api = new sst.aws.Function("MyFunction", { - vpc, - url: true, - link: [redis], - handler: "index.handler" - }); - - return { - url: api.url, - }; - }, -}); diff --git a/examples/aws-lambda-vpc/tsconfig.json b/examples/aws-lambda-vpc/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-lambda-vpc/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-linkable-env/.gitignore b/examples/aws-linkable-env/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-linkable-env/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-linkable-env/package.json b/examples/aws-linkable-env/package.json deleted file mode 100644 index 9febdd34d5..0000000000 --- a/examples/aws-linkable-env/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-linkable-env", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-linkable-env/sst.config.ts b/examples/aws-linkable-env/sst.config.ts deleted file mode 100644 index 20acdfcd00..0000000000 --- a/examples/aws-linkable-env/sst.config.ts +++ /dev/null @@ -1,70 +0,0 @@ -/// - -/** - * ## Linkable env vars - * - * Pass SST link env vars to a native `aws.ecs.TaskDefinition` container using - * `sst.Linkable.env()`. This lets `Resource.MyResource` work at runtime - * in compute not managed by SST. - * - */ -export default $config({ - app(input) { - return { - name: "aws-linkable-env", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - // Create an SST bucket - const bucket = new sst.aws.Bucket("MyBucket"); - - // Create a custom linkable - const linkable = new sst.Linkable("MyLinkable", { - properties: { - foo: "bar", - }, - }); - - // Create VPC and ECS cluster using native AWS resources - const vpc = new aws.ec2.Vpc("Vpc", { cidrBlock: "10.0.0.0/16" }); - const subnet = new aws.ec2.Subnet("Subnet", { - vpcId: vpc.id, - cidrBlock: "10.0.0.0/24", - }); - const cluster = new aws.ecs.Cluster("Cluster"); - - // Linkable.env() returns a Record, but ECS expects - // environment as an array of { name, value } objects - const environment = sst.Linkable.env([bucket, linkable]).apply((env) => - Object.entries(env).map(([name, value]) => ({ name, value })), - ); - - const taskDefinition = new aws.ecs.TaskDefinition("TaskDefinition", { - family: $interpolate`${$app.name}-${$app.stage}`, - cpu: "256", - memory: "512", - networkMode: "awsvpc", - requiresCompatibilities: ["FARGATE"], - containerDefinitions: $jsonStringify([ - { - name: "app", - image: "public.ecr.aws/docker/library/node:20-slim", - essential: true, - environment, - }, - ]), - }); - - new aws.ecs.Service("Service", { - cluster: cluster.arn, - taskDefinition: taskDefinition.arn, - desiredCount: 0, - launchType: "FARGATE", - networkConfiguration: { - subnets: [subnet.id], - }, - }); - }, -}); diff --git a/examples/aws-linkable-env/tsconfig.json b/examples/aws-linkable-env/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-linkable-env/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-linkable/.gitignore b/examples/aws-linkable/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-linkable/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-linkable/index.ts b/examples/aws-linkable/index.ts deleted file mode 100644 index 1498966a26..0000000000 --- a/examples/aws-linkable/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Resource } from "sst"; - -export async function handler() { - console.log("Hello World!"); - console.log("topic", Resource.Topic.arn); - console.log( - "existingResources", - Resource.ExistingResources.queueName, - Resource.ExistingResources.bucketName, - ); -} diff --git a/examples/aws-linkable/package.json b/examples/aws-linkable/package.json deleted file mode 100644 index ccedf4fe7b..0000000000 --- a/examples/aws-linkable/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-linkable", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-linkable/sst.config.ts b/examples/aws-linkable/sst.config.ts deleted file mode 100644 index 3a27854d1c..0000000000 --- a/examples/aws-linkable/sst.config.ts +++ /dev/null @@ -1,46 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-linkable", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - // make a native resource linkable - sst.Linkable.wrap(aws.sns.Topic, (resource) => ({ - // these properties will be available when linked - properties: { - arn: resource.arn, - name: resource.name, - }, - })); - const topic = new aws.sns.Topic("Topic"); - - // create something that can be linked - const existingResources = new sst.Linkable("ExistingResources", { - properties: { - bucketName: "existing-bucket", - queueName: "existing-queue", - }, - include: [ - sst.aws.permission({ - actions: ["s3:GetObject", "sns:Publish"], - resources: ["*"], - }), - ], - }); - - const fn = new sst.aws.Function("Function", { - handler: "index.handler", - link: [topic, existingResources], - url: true, - }); - - return { - url: fn.url, - }; - }, -}); diff --git a/examples/aws-linkable/tsconfig.json b/examples/aws-linkable/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-linkable/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-load-balancer-waf/package.json b/examples/aws-load-balancer-waf/package.json deleted file mode 100644 index 668890f41c..0000000000 --- a/examples/aws-load-balancer-waf/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-load-balancer-waf", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-load-balancer-waf/sst.config.ts b/examples/aws-load-balancer-waf/sst.config.ts deleted file mode 100644 index 1a5fecc363..0000000000 --- a/examples/aws-load-balancer-waf/sst.config.ts +++ /dev/null @@ -1,85 +0,0 @@ -/// - -/** - * ## AWS Load Balancer Web Application Firewall (WAF) - * - * Enable WAF for an AWS Load Balancer. - * - * The WAF is configured to enable a rate limit and enables AWS managed rules. - * - */ -export default $config({ - app(input) { - return { - name: "aws-load-balancer-waf", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - const service = cluster.addService("MyAppService", { - image: { - context: "./", - dockerfile: "packages/server/Dockerfile", - }, - }); - - const rateLimitRule = { - name: "RateLimitRule", - statement: { - rateBasedStatement: { - limit: 200, - aggregateKeyType: "IP", - }, - }, - priority: 1, - action: { block: {} }, - visibilityConfig: { - cloudwatchMetricsEnabled: true, - sampledRequestsEnabled: true, - metricName: "MyAppRateLimitRule", - }, - }; - - const awsManagedRules = { - name: "AWSManagedRules", - statement: { - managedRuleGroupStatement: { - name: "AWSManagedRulesCommonRuleSet", - vendorName: "AWS", - }, - }, - priority: 2, - overrideAction: { - none: {}, - }, - visibilityConfig: { - cloudwatchMetricsEnabled: true, - sampledRequestsEnabled: true, - metricName: "MyAppAWSManagedRules", - }, - }; - - const webAcl = new aws.wafv2.WebAcl("AppAlbWebAcl", { - defaultAction: { allow: {} }, - scope: "REGIONAL", - visibilityConfig: { - cloudwatchMetricsEnabled: true, - sampledRequestsEnabled: true, - metricName: "AppAlbWebAcl", - }, - rules: [rateLimitRule, awsManagedRules], - }); - - service.nodes.loadBalancer.arn.apply((arn) => { - new aws.wafv2.WebAclAssociation("MyAppAlbWebAclAssociation", { - resourceArn: arn, - webAclArn: webAcl.arn, - }); - }); - - return {}; - }, -}); diff --git a/examples/aws-monorepo/.gitignore b/examples/aws-monorepo/.gitignore deleted file mode 100644 index c4a0d6f07c..0000000000 --- a/examples/aws-monorepo/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -node_modules - -# sst -.sst - -# temporary files -.#* diff --git a/examples/aws-monorepo/infra/api.ts b/examples/aws-monorepo/infra/api.ts deleted file mode 100644 index 2d09eeae8b..0000000000 --- a/examples/aws-monorepo/infra/api.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { database } from "./database"; - -export const api = new sst.aws.Function("Api", { - url: true, - link: [database], - handler: "./packages/functions/src/api.handler", - environment: { - foo: "9", - }, -}); diff --git a/examples/aws-monorepo/infra/astro.ts b/examples/aws-monorepo/infra/astro.ts deleted file mode 100644 index 1b7671fa07..0000000000 --- a/examples/aws-monorepo/infra/astro.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { api } from "./api"; - -const bucket = new sst.aws.Bucket("MyBucket"); -export const astro = new sst.aws.Astro("Astro", { - path: "packages/astro", - link: [bucket], - environment: { - VITE_API_URL: api.url, - }, -}); diff --git a/examples/aws-monorepo/infra/database.ts b/examples/aws-monorepo/infra/database.ts deleted file mode 100644 index 420a14a240..0000000000 --- a/examples/aws-monorepo/infra/database.ts +++ /dev/null @@ -1,10 +0,0 @@ -export const database = new sst.aws.Dynamo("Database", { - fields: { - PK: "string", - SK: "string", - }, - primaryIndex: { - hashKey: "PK", - rangeKey: "SK", - }, -}); diff --git a/examples/aws-monorepo/infra/frontend.ts b/examples/aws-monorepo/infra/frontend.ts deleted file mode 100644 index c32a095522..0000000000 --- a/examples/aws-monorepo/infra/frontend.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { api } from "./api"; - -export const web = new sst.aws.StaticSite("StaticSite", { - path: "packages/frontend", - build: { - output: "dist", - command: "npm run build", - }, - environment: { - VITE_API_URL: api.url, - }, -}); diff --git a/examples/aws-monorepo/infra/index.ts b/examples/aws-monorepo/infra/index.ts deleted file mode 100644 index f29a75d8b1..0000000000 --- a/examples/aws-monorepo/infra/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from "./api"; -export * from "./database"; -export * from "./frontend"; -export * from "./astro"; diff --git a/examples/aws-monorepo/package.json b/examples/aws-monorepo/package.json deleted file mode 100644 index 9f1076e6a4..0000000000 --- a/examples/aws-monorepo/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "aws-monorepo", - "version": "0.0.0", - "workspaces": [ - "packages/*" - ], - "scripts": { - "dev": "sst dev" - }, - "devDependencies": { - "@tsconfig/node20": "^20.1.4", - "typescript": "5.3.3" - }, - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-monorepo/packages/astro/.gitignore b/examples/aws-monorepo/packages/astro/.gitignore deleted file mode 100644 index 9a746a2f70..0000000000 --- a/examples/aws-monorepo/packages/astro/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# build output -dist/ - -# generated types -.astro/ - -# dependencies -node_modules/ - -# logs -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# environment variables -.env -.env.production - -# macOS-specific files -.DS_Store - -# sst -.sst diff --git a/examples/aws-monorepo/packages/astro/.vscode/extensions.json b/examples/aws-monorepo/packages/astro/.vscode/extensions.json deleted file mode 100644 index 22a15055d6..0000000000 --- a/examples/aws-monorepo/packages/astro/.vscode/extensions.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "recommendations": ["astro-build.astro-vscode"], - "unwantedRecommendations": [] -} diff --git a/examples/aws-monorepo/packages/astro/.vscode/launch.json b/examples/aws-monorepo/packages/astro/.vscode/launch.json deleted file mode 100644 index d642209762..0000000000 --- a/examples/aws-monorepo/packages/astro/.vscode/launch.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "command": "./node_modules/.bin/astro dev", - "name": "Development server", - "request": "launch", - "type": "node-terminal" - } - ] -} diff --git a/examples/aws-monorepo/packages/astro/astro.config.mjs b/examples/aws-monorepo/packages/astro/astro.config.mjs deleted file mode 100644 index b4f287b9a8..0000000000 --- a/examples/aws-monorepo/packages/astro/astro.config.mjs +++ /dev/null @@ -1,7 +0,0 @@ -import { defineConfig } from "astro/config"; -import aws from "astro-sst"; - -export default defineConfig({ - output: "server", - adapter: aws(), -}); diff --git a/examples/aws-monorepo/packages/astro/package.json b/examples/aws-monorepo/packages/astro/package.json deleted file mode 100644 index 677f362509..0000000000 --- a/examples/aws-monorepo/packages/astro/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aws-astro", - "type": "module", - "version": "0.0.1", - "scripts": { - "dev": "astro dev", - "start": "astro dev", - "build": "astro build", - "preview": "astro preview", - "astro": "astro" - }, - "dependencies": { - "@astrojs/check": "^0.5.10", - "@aws-sdk/client-s3": "^3.540.0", - "@aws-sdk/s3-request-presigner": "^3.540.0", - "astro": "^4.5.9", - "astro-sst": "^2.41.2", - "sst": "file:../../../../sdk/js", - "typescript": "^5.4.3" - } -} diff --git a/examples/aws-monorepo/packages/astro/public/favicon.svg b/examples/aws-monorepo/packages/astro/public/favicon.svg deleted file mode 100644 index f157bd1c5e..0000000000 --- a/examples/aws-monorepo/packages/astro/public/favicon.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - diff --git a/examples/aws-monorepo/packages/astro/src/components/Card.astro b/examples/aws-monorepo/packages/astro/src/components/Card.astro deleted file mode 100644 index bd6d5971eb..0000000000 --- a/examples/aws-monorepo/packages/astro/src/components/Card.astro +++ /dev/null @@ -1,61 +0,0 @@ ---- -interface Props { - title: string; - body: string; - href: string; -} - -const { href, title, body } = Astro.props; ---- - - - diff --git a/examples/aws-monorepo/packages/astro/src/env.d.ts b/examples/aws-monorepo/packages/astro/src/env.d.ts deleted file mode 100644 index acef35f175..0000000000 --- a/examples/aws-monorepo/packages/astro/src/env.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -/// -/// diff --git a/examples/aws-monorepo/packages/astro/src/layouts/Layout.astro b/examples/aws-monorepo/packages/astro/src/layouts/Layout.astro deleted file mode 100644 index 7b552be19b..0000000000 --- a/examples/aws-monorepo/packages/astro/src/layouts/Layout.astro +++ /dev/null @@ -1,51 +0,0 @@ ---- -interface Props { - title: string; -} - -const { title } = Astro.props; ---- - - - - - - - - - - {title} - - - - - - diff --git a/examples/aws-monorepo/packages/astro/src/pages/index.astro b/examples/aws-monorepo/packages/astro/src/pages/index.astro deleted file mode 100644 index bd93563ed4..0000000000 --- a/examples/aws-monorepo/packages/astro/src/pages/index.astro +++ /dev/null @@ -1,75 +0,0 @@ ---- -import { Resource } from "sst"; -import Layout from '../layouts/Layout.astro'; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, -}); -const url = await getSignedUrl(new S3Client({}), command); ---- - - -
-
- - -
- -
-
- - diff --git a/examples/aws-monorepo/packages/astro/tsconfig.json b/examples/aws-monorepo/packages/astro/tsconfig.json deleted file mode 100644 index 77da9dd009..0000000000 --- a/examples/aws-monorepo/packages/astro/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "astro/tsconfigs/strict" -} \ No newline at end of file diff --git a/examples/aws-monorepo/packages/core/package.json b/examples/aws-monorepo/packages/core/package.json deleted file mode 100644 index bfd1c917de..0000000000 --- a/examples/aws-monorepo/packages/core/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "@aws-monorepo/core", - "version": "0.0.0", - "exports": { - "./*": [ - "./src/*/index.ts", - "./src/*.ts" - ] - }, - "devDependencies": { - "sst": "file:../../../../sdk/js" - } -} diff --git a/examples/aws-monorepo/packages/core/src/example/index.ts b/examples/aws-monorepo/packages/core/src/example/index.ts deleted file mode 100644 index 9cb1c03477..0000000000 --- a/examples/aws-monorepo/packages/core/src/example/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export namespace Example { - export function hello() { - return "Hello, world!"; - } -} diff --git a/examples/aws-monorepo/packages/core/tsconfig.json b/examples/aws-monorepo/packages/core/tsconfig.json deleted file mode 100644 index ea59875db2..0000000000 --- a/examples/aws-monorepo/packages/core/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "@tsconfig/node20/tsconfig.json", - "compilerOptions": { - "module": "NodeNext", - "moduleResolution": "Bundler", - }, -} diff --git a/examples/aws-monorepo/packages/frontend/index.html b/examples/aws-monorepo/packages/frontend/index.html deleted file mode 100644 index 800ee5dbc2..0000000000 --- a/examples/aws-monorepo/packages/frontend/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - Vite App - - -

Vite is running in %MODE%

-

api: %VITE_API_URL%

- - - diff --git a/examples/aws-monorepo/packages/frontend/package.json b/examples/aws-monorepo/packages/frontend/package.json deleted file mode 100644 index 6a6424629f..0000000000 --- a/examples/aws-monorepo/packages/frontend/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "@aws-monorepo/frontend", - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "vite dev", - "build": "vite build" - }, - "devDependencies": { - "vite": "^5.2.8", - "sst": "file:../../../../sdk/js" - } -} diff --git a/examples/aws-monorepo/packages/frontend/vite.config.ts b/examples/aws-monorepo/packages/frontend/vite.config.ts deleted file mode 100644 index 0c4b848dbd..0000000000 --- a/examples/aws-monorepo/packages/frontend/vite.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { defineConfig } from "vite"; - -export default defineConfig({ - server: { - host: "0.0.0.0", - }, -}); diff --git a/examples/aws-monorepo/packages/functions/package.json b/examples/aws-monorepo/packages/functions/package.json deleted file mode 100644 index 9fd4eb3af9..0000000000 --- a/examples/aws-monorepo/packages/functions/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "@aws-monorepo/functions", - "version": "0.0.0", - "dependencies": { - "@aws-monorepo/core": "*", - "sst": "file:../../../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "^8.10.137", - "sst": "file:../../../../sdk/js" - } -} diff --git a/examples/aws-monorepo/packages/functions/src/api.ts b/examples/aws-monorepo/packages/functions/src/api.ts deleted file mode 100644 index 4b1bf2a200..0000000000 --- a/examples/aws-monorepo/packages/functions/src/api.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Resource } from "sst"; -import { Handler } from "aws-lambda"; -import { Example } from "@aws-monorepo/core/example"; - -export const handler: Handler = async (event) => { - console.log( - "this is a long time as a test for the long and to see if it wraps and here cool wow", - ); - return { - statusCode: 200, - body: `${Example.hello()} Linked to ${Resource.Database.name}.`, - }; -}; diff --git a/examples/aws-monorepo/packages/functions/tsconfig.json b/examples/aws-monorepo/packages/functions/tsconfig.json deleted file mode 100644 index ea59875db2..0000000000 --- a/examples/aws-monorepo/packages/functions/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "@tsconfig/node20/tsconfig.json", - "compilerOptions": { - "module": "NodeNext", - "moduleResolution": "Bundler", - }, -} diff --git a/examples/aws-monorepo/packages/scripts/package.json b/examples/aws-monorepo/packages/scripts/package.json deleted file mode 100644 index c8b78ff82a..0000000000 --- a/examples/aws-monorepo/packages/scripts/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "@aws-monorepo/scripts", - "version": "0.0.0", - "dependencies": { - "@aws-monorepo/core": "*", - "sst": "file:../../../../sdk/js" - }, - "scripts": { - "shell": "sst shell tsx" - }, - "devDependencies": { - "tsx": "^4.7.2" - } -} diff --git a/examples/aws-monorepo/packages/scripts/src/example.ts b/examples/aws-monorepo/packages/scripts/src/example.ts deleted file mode 100644 index 1e9ac7bb9a..0000000000 --- a/examples/aws-monorepo/packages/scripts/src/example.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { Resource } from "sst"; -import { Example } from "@aws-monorepo/core/example"; - -console.log(`${Example.hello()} Linked to ${Resource.Database.name}.`); diff --git a/examples/aws-monorepo/packages/scripts/tsconfig.json b/examples/aws-monorepo/packages/scripts/tsconfig.json deleted file mode 100644 index ea59875db2..0000000000 --- a/examples/aws-monorepo/packages/scripts/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "@tsconfig/node20/tsconfig.json", - "compilerOptions": { - "module": "NodeNext", - "moduleResolution": "Bundler", - }, -} diff --git a/examples/aws-monorepo/sst.config.ts b/examples/aws-monorepo/sst.config.ts deleted file mode 100644 index 724d416c16..0000000000 --- a/examples/aws-monorepo/sst.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-monorepo", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const infra = await import("./infra"); - - return { - api: infra.api.url, - astro: infra.astro.url, - }; - }, -}); diff --git a/examples/aws-monorepo/tsconfig.json b/examples/aws-monorepo/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-monorepo/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-multi-region/index.ts b/examples/aws-multi-region/index.ts deleted file mode 100644 index 0f59768d5e..0000000000 --- a/examples/aws-multi-region/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export async function handler() { - return { - statusCode: 200, - body: `Hello from ${process.env.AWS_REGION}`, - }; -} diff --git a/examples/aws-multi-region/package.json b/examples/aws-multi-region/package.json deleted file mode 100644 index b2370c5519..0000000000 --- a/examples/aws-multi-region/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-multi-region", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "^8.10.145", - "@types/node": "^22.5.4" - } -} diff --git a/examples/aws-multi-region/sst.config.ts b/examples/aws-multi-region/sst.config.ts deleted file mode 100644 index a11d183110..0000000000 --- a/examples/aws-multi-region/sst.config.ts +++ /dev/null @@ -1,51 +0,0 @@ -/// - -/** - * ## AWS multi-region - * - * To deploy resources to multiple AWS regions, you can create a new provider for the region - * you want to deploy to. - * - * ```ts title="sst.config.ts" - * const provider = new aws.Provider("MyProvider", { region: "us-west-2" }); - * ``` - * - * And then pass that in to the resource. - * - * ```ts title="sst.config.ts" - * new sst.aws.Function("MyFunction", { handler: "index.handler" }, { provider }); - * ``` - * - * If no provider is passed in, the default provider will be used. And if no region is - * specified, the default region from your credentials will be used. - */ -export default $config({ - app(input) { - return { - name: "aws-multi-region", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const east = new sst.aws.Function("MyEastFunction", { - url: true, - handler: "index.handler", - }); - - const provider = new aws.Provider("MyWestProvider", { region: "us-west-2" }); - const west = new sst.aws.Function( - "MyWestFunction", - { - url: true, - handler: "index.handler", - }, - { provider } - ); - - return { - east: east.url, - west: west.url, - }; - }, -}); diff --git a/examples/aws-mysql-local/.gitignore b/examples/aws-mysql-local/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-mysql-local/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-mysql-local/index.ts b/examples/aws-mysql-local/index.ts deleted file mode 100644 index 7d1712321c..0000000000 --- a/examples/aws-mysql-local/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -import mysql from "mysql2/promise"; -import { Resource } from "sst"; - -const connection = await mysql.createConnection({ - host: Resource.MyDatabase.host, - port: Resource.MyDatabase.port, - user: Resource.MyDatabase.username, - password: Resource.MyDatabase.password, - database: Resource.MyDatabase.database, -}); - -export async function handler() { - const [rows] = await connection.query("SELECT NOW()"); - return { - statusCode: 200, - body: `Querying ${Resource.MyDatabase.host}\n\n` + rows[0].now, - }; -} diff --git a/examples/aws-mysql-local/package.json b/examples/aws-mysql-local/package.json deleted file mode 100644 index 10eb83dc38..0000000000 --- a/examples/aws-mysql-local/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-mysql-local", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "mysql2": "3.14.0", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145" - } -} diff --git a/examples/aws-mysql-local/sst.config.ts b/examples/aws-mysql-local/sst.config.ts deleted file mode 100644 index 374825c605..0000000000 --- a/examples/aws-mysql-local/sst.config.ts +++ /dev/null @@ -1,86 +0,0 @@ -/// - -/** - * ## AWS MySQL local - * - * In this example, we connect to a locally running MySQL instance for dev. While - * on deploy, we use RDS. - * - * We use the [`docker run`](https://docs.docker.com/reference/cli/docker/container/run/) CLI - * to start a local container with MySQL. You don't have to use Docker, you can use - * any other way to run MySQL locally. - * - * ```bash - * docker run \ - * --rm \ - * -p 3306:3306 \ - * -v $(pwd)/.sst/storage/mysql:/var/lib/mysql/data \ - * -e MYSQL_ROOT_PASSWORD=password \ - * -e MYSQL_DATABASE=local \ - * mysql:8.0 - * ``` - * - * The data is saved to the `.sst/storage` directory. So if you restart the dev server, the - * data will still be there. - * - * We then configure the `dev` property of the `Mysql` component with the settings for the - * local MySQL instance. - * - * ```ts title="sst.config.ts" - * dev: { - * username: "root", - * password: "password", - * database: "local", - * host: "localhost", - * port: 3306, - * } - * ``` - * - * By providing the `dev` prop for Mysql, SST will use the local MySQL instance and - * not deploy a new RDS database when running `sst dev`. - * - * It also allows us to access the database through a Resource `link` without having to - * conditionally check if we are running locally. - * - * ```ts title="index.ts" - * const pool = new Pool({ - * host: Resource.MyDatabase.host, - * port: Resource.MyDatabase.port, - * user: Resource.MyDatabase.username, - * password: Resource.MyDatabase.password, - * database: Resource.MyDatabase.database, - * }); - * ``` - * - * The above will work in both `sst dev` and `sst deploy`. - */ -export default $config({ - app(input) { - return { - name: "aws-mysql-local", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { nat: "ec2" }); - - const mysql = new sst.aws.Mysql("MyDatabase", { - dev: { - username: "root", - password: "password", - database: "local", - host: "localhost", - port: 3306, - }, - vpc, - }); - - new sst.aws.Function("MyFunction", { - vpc, - url: true, - link: [mysql], - handler: "index.handler", - }); - }, -}); diff --git a/examples/aws-mysql-local/tsconfig.json b/examples/aws-mysql-local/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-mysql-local/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-mysql/index.ts b/examples/aws-mysql/index.ts deleted file mode 100644 index e589834de9..0000000000 --- a/examples/aws-mysql/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -import mysql from "mysql2/promise"; -import { Resource } from "sst"; - -const connection = await mysql.createConnection({ - host: Resource.MyDatabase.host, - port: Resource.MyDatabase.port, - user: Resource.MyDatabase.username, - password: Resource.MyDatabase.password, - database: Resource.MyDatabase.database, -}); - -export async function handler() { - const [rows] = await connection.execute("SELECT NOW()"); - return { - statusCode: 200, - body: `Querying ${Resource.MyDatabase.host}\n\n` + rows[0]['NOW()'], - }; -} diff --git a/examples/aws-mysql/package.json b/examples/aws-mysql/package.json deleted file mode 100644 index cdf175cd3c..0000000000 --- a/examples/aws-mysql/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-mysql", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "mysql2": "3.14.0", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-mysql/sst.config.ts b/examples/aws-mysql/sst.config.ts deleted file mode 100644 index f5baedce72..0000000000 --- a/examples/aws-mysql/sst.config.ts +++ /dev/null @@ -1,79 +0,0 @@ -/// - -/** - * ## AWS MySQL - * - * In this example, we deploy an RDS MySQL database. - * - * ```ts title="sst.config.ts" - * const mysql = new sst.aws.Mysql("MyDatabase", { - * vpc, - * }); - * ``` - * - * And link it to a Lambda function. - * - * ```ts title="sst.config.ts" {3} - * new sst.aws.Function("MyApp", { - * handler: "index.handler", - * link: [mysql], - * url: true, - * vpc, - * }); - * ``` - * - * Now in the function we can access the database. - * - * ```ts title="index.ts" - * const connection = await mysql.createConnection({ - * database: Resource.MyDatabase.database, - * host: Resource.MyDatabase.host, - * port: Resource.MyDatabase.port, - * user: Resource.MyDatabase.username, - * password: Resource.MyDatabase.password, - * }); - * ``` - * - * We also enable the `bastion` option for the VPC. This allows us to connect to - * the database from our local machine with the `sst tunnel` CLI. - * - * ```bash "sudo" - * sudo npx sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only - * need to do this once on your machine. - * - * Now you can run `npx sst dev` and you can connect to the database from your local machine. - * - */ -export default $config({ - app(input) { - return { - name: "aws-mysql", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { nat: "ec2", bastion: true }); - const mysql = new sst.aws.Mysql("MyDatabase", { - vpc, - }); - const app = new sst.aws.Function("MyApp", { - handler: "index.handler", - link: [mysql], - url: true, - vpc, - }); - - return { - app: app.url, - host: mysql.host, - port: mysql.port, - username: mysql.username, - password: mysql.password, - database: mysql.database, - }; - }, -}); diff --git a/examples/aws-nestjs-container/.dockerignore b/examples/aws-nestjs-container/.dockerignore deleted file mode 100644 index 3b5d5cb550..0000000000 --- a/examples/aws-nestjs-container/.dockerignore +++ /dev/null @@ -1,6 +0,0 @@ -dist -node_modules - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-nestjs-container/.eslintrc.js b/examples/aws-nestjs-container/.eslintrc.js deleted file mode 100644 index 259de13c73..0000000000 --- a/examples/aws-nestjs-container/.eslintrc.js +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = { - parser: '@typescript-eslint/parser', - parserOptions: { - project: 'tsconfig.json', - tsconfigRootDir: __dirname, - sourceType: 'module', - }, - plugins: ['@typescript-eslint/eslint-plugin'], - extends: [ - 'plugin:@typescript-eslint/recommended', - 'plugin:prettier/recommended', - ], - root: true, - env: { - node: true, - jest: true, - }, - ignorePatterns: ['.eslintrc.js'], - rules: { - '@typescript-eslint/interface-name-prefix': 'off', - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/no-explicit-any': 'off', - }, -}; diff --git a/examples/aws-nestjs-container/.gitignore b/examples/aws-nestjs-container/.gitignore deleted file mode 100644 index 8e0d8ec3b0..0000000000 --- a/examples/aws-nestjs-container/.gitignore +++ /dev/null @@ -1,59 +0,0 @@ -# compiled output -/dist -/node_modules -/build - -# Logs -logs -*.log -npm-debug.log* -pnpm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* - -# OS -.DS_Store - -# Tests -/coverage -/.nyc_output - -# IDEs and editors -/.idea -.project -.classpath -.c9/ -*.launch -.settings/ -*.sublime-workspace - -# IDE - VSCode -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# temp directory -.temp -.tmp - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# sst -.sst diff --git a/examples/aws-nestjs-container/.prettierrc b/examples/aws-nestjs-container/.prettierrc deleted file mode 100644 index dcb72794f5..0000000000 --- a/examples/aws-nestjs-container/.prettierrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "singleQuote": true, - "trailingComma": "all" -} \ No newline at end of file diff --git a/examples/aws-nestjs-container/Dockerfile b/examples/aws-nestjs-container/Dockerfile deleted file mode 100644 index 143907a2df..0000000000 --- a/examples/aws-nestjs-container/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:22 - -WORKDIR /usr/src/app -COPY package*.json ./ -RUN npm install -COPY . . -RUN npm run build - -EXPOSE 3000 -CMD ["node", "dist/main"] diff --git a/examples/aws-nestjs-container/nest-cli.json b/examples/aws-nestjs-container/nest-cli.json deleted file mode 100644 index f9aa683b1a..0000000000 --- a/examples/aws-nestjs-container/nest-cli.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/nest-cli", - "collection": "@nestjs/schematics", - "sourceRoot": "src", - "compilerOptions": { - "deleteOutDir": true - } -} diff --git a/examples/aws-nestjs-container/package.json b/examples/aws-nestjs-container/package.json deleted file mode 100644 index 0beae8372e..0000000000 --- a/examples/aws-nestjs-container/package.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "name": "aws-nestjs-container", - "version": "0.0.1", - "description": "", - "author": "", - "private": true, - "license": "UNLICENSED", - "scripts": { - "build": "nest build", - "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", - "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", - "start": "nest start", - "start:debug": "nest start --debug --watch", - "start:dev": "nest start --watch", - "start:prod": "node dist/main", - "test": "jest", - "test:cov": "jest --coverage", - "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", - "test:e2e": "jest --config ./test/jest-e2e.json", - "test:watch": "jest --watch" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.717.0", - "@aws-sdk/lib-storage": "^3.717.0", - "@aws-sdk/s3-request-presigner": "^3.717.0", - "@nestjs/common": "^10.0.0", - "@nestjs/core": "^10.0.0", - "@nestjs/platform-express": "^10.0.0", - "reflect-metadata": "^0.2.0", - "rxjs": "^7.8.1", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@nestjs/cli": "^10.0.0", - "@nestjs/schematics": "^10.0.0", - "@nestjs/testing": "^10.0.0", - "@types/aws-lambda": "8.10.146", - "@types/express": "^5.0.0", - "@types/jest": "^29.5.2", - "@types/multer": "^1.4.12", - "@types/node": "^20.3.1", - "@types/supertest": "^6.0.0", - "@typescript-eslint/eslint-plugin": "^8.0.0", - "@typescript-eslint/parser": "^8.0.0", - "eslint": "^8.0.0", - "eslint-config-prettier": "^9.0.0", - "eslint-plugin-prettier": "^5.0.0", - "jest": "^29.5.0", - "prettier": "^3.0.0", - "source-map-support": "^0.5.21", - "supertest": "^7.0.0", - "ts-jest": "^29.1.0", - "ts-loader": "^9.4.3", - "ts-node": "^10.9.1", - "tsconfig-paths": "^4.2.0", - "typescript": "^5.1.3" - }, - "jest": { - "collectCoverageFrom": [ - "**/*.(t|j)s" - ], - "coverageDirectory": "../coverage", - "moduleFileExtensions": [ - "js", - "json", - "ts" - ], - "rootDir": "src", - "testEnvironment": "node", - "testRegex": ".*\\.spec\\.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - } - } -} diff --git a/examples/aws-nestjs-container/src/app.controller.spec.ts b/examples/aws-nestjs-container/src/app.controller.spec.ts deleted file mode 100644 index d22f3890a3..0000000000 --- a/examples/aws-nestjs-container/src/app.controller.spec.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; - -describe('AppController', () => { - let appController: AppController; - - beforeEach(async () => { - const app: TestingModule = await Test.createTestingModule({ - controllers: [AppController], - providers: [AppService], - }).compile(); - - appController = app.get(AppController); - }); - - describe('root', () => { - it('should return "Hello World!"', () => { - expect(appController.getHello()).toBe('Hello World!'); - }); - }); -}); diff --git a/examples/aws-nestjs-container/src/app.controller.ts b/examples/aws-nestjs-container/src/app.controller.ts deleted file mode 100644 index 1c84dea417..0000000000 --- a/examples/aws-nestjs-container/src/app.controller.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { - S3Client, - GetObjectCommand, - ListObjectsV2Command, -} from '@aws-sdk/client-s3'; -import { Resource } from 'sst'; -import { Express } from 'express'; -import { Upload } from '@aws-sdk/lib-storage'; -import { FileInterceptor } from '@nestjs/platform-express'; -import { getSignedUrl } from '@aws-sdk/s3-request-presigner'; -import { Controller, Get, Post, Redirect, UploadedFile, UseInterceptors } from '@nestjs/common'; -import { AppService } from './app.service'; - -const s3 = new S3Client({}); - -@Controller() -export class AppController { - constructor(private readonly appService: AppService) { } - - @Get() - getHello(): string { - return this.appService.getHello(); - } - - @Post() - @UseInterceptors(FileInterceptor('file')) - async uploadFile(@UploadedFile() file: Express.Multer.File): Promise { - const params = { - Bucket: Resource.MyBucket.name, - ContentType: file.mimetype, - Key: file.originalname, - Body: file.buffer, - }; - - const upload = new Upload({ - params, - client: s3, - }); - - await upload.done(); - - return 'File uploaded successfully.'; - } - - @Get('latest') - @Redirect('/', 302) - async getLatestFile() { - const objects = await s3.send( - new ListObjectsV2Command({ - Bucket: Resource.MyBucket.name, - }), - ); - - const latestFile = objects.Contents.sort( - (a, b) => b.LastModified.getTime() - a.LastModified.getTime(), - )[0]; - - const command = new GetObjectCommand({ - Key: latestFile.Key, - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(s3, command); - - return { url }; - } -} diff --git a/examples/aws-nestjs-container/src/app.module.ts b/examples/aws-nestjs-container/src/app.module.ts deleted file mode 100644 index 86628031ca..0000000000 --- a/examples/aws-nestjs-container/src/app.module.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Module } from '@nestjs/common'; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; - -@Module({ - imports: [], - controllers: [AppController], - providers: [AppService], -}) -export class AppModule {} diff --git a/examples/aws-nestjs-container/src/app.service.ts b/examples/aws-nestjs-container/src/app.service.ts deleted file mode 100644 index 927d7cca0b..0000000000 --- a/examples/aws-nestjs-container/src/app.service.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { Injectable } from '@nestjs/common'; - -@Injectable() -export class AppService { - getHello(): string { - return 'Hello World!'; - } -} diff --git a/examples/aws-nestjs-container/src/main.ts b/examples/aws-nestjs-container/src/main.ts deleted file mode 100644 index f76bc8d977..0000000000 --- a/examples/aws-nestjs-container/src/main.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { NestFactory } from '@nestjs/core'; -import { AppModule } from './app.module'; - -async function bootstrap() { - const app = await NestFactory.create(AppModule); - await app.listen(process.env.PORT ?? 3000); -} -bootstrap(); diff --git a/examples/aws-nestjs-container/sst.config.ts b/examples/aws-nestjs-container/sst.config.ts deleted file mode 100644 index a5f5a85951..0000000000 --- a/examples/aws-nestjs-container/sst.config.ts +++ /dev/null @@ -1,29 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: 'aws-nestjs-container', - removal: input?.stage === 'production' ? 'retain' : 'remove', - protect: ['production'].includes(input?.stage), - home: 'aws', - }; - }, - async run() { - const vpc = new sst.aws.Vpc('MyVpc'); - const bucket = new sst.aws.Bucket('MyBucket'); - - const cluster = new sst.aws.Cluster('MyCluster', { vpc }); - - new sst.aws.Service('MyService', { - cluster, - link: [bucket], - loadBalancer: { - ports: [{ listen: '80/http', forward: '3000/http' }], - }, - dev: { - command: 'npm run start:dev', - }, - }); - }, -}); diff --git a/examples/aws-nestjs-container/test/app.e2e-spec.ts b/examples/aws-nestjs-container/test/app.e2e-spec.ts deleted file mode 100644 index 50cda62332..0000000000 --- a/examples/aws-nestjs-container/test/app.e2e-spec.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { INestApplication } from '@nestjs/common'; -import * as request from 'supertest'; -import { AppModule } from './../src/app.module'; - -describe('AppController (e2e)', () => { - let app: INestApplication; - - beforeEach(async () => { - const moduleFixture: TestingModule = await Test.createTestingModule({ - imports: [AppModule], - }).compile(); - - app = moduleFixture.createNestApplication(); - await app.init(); - }); - - it('/ (GET)', () => { - return request(app.getHttpServer()) - .get('/') - .expect(200) - .expect('Hello World!'); - }); -}); diff --git a/examples/aws-nestjs-container/test/jest-e2e.json b/examples/aws-nestjs-container/test/jest-e2e.json deleted file mode 100644 index e9d912f3e3..0000000000 --- a/examples/aws-nestjs-container/test/jest-e2e.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "moduleFileExtensions": ["js", "json", "ts"], - "rootDir": ".", - "testEnvironment": "node", - "testRegex": ".e2e-spec.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - } -} diff --git a/examples/aws-nestjs-container/tsconfig.build.json b/examples/aws-nestjs-container/tsconfig.build.json deleted file mode 100644 index 64f86c6bd2..0000000000 --- a/examples/aws-nestjs-container/tsconfig.build.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "./tsconfig.json", - "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] -} diff --git a/examples/aws-nestjs-container/tsconfig.json b/examples/aws-nestjs-container/tsconfig.json deleted file mode 100644 index 162793367a..0000000000 --- a/examples/aws-nestjs-container/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "declaration": true, - "removeComments": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "allowSyntheticDefaultImports": true, - "target": "ES2021", - "sourceMap": true, - "outDir": "./dist", - "baseUrl": "./", - "incremental": true, - "skipLibCheck": true, - "strictNullChecks": false, - "noImplicitAny": false, - "strictBindCallApply": false, - "forceConsistentCasingInFileNames": false, - "noFallthroughCasesInSwitch": false - }, - "include": ["src/**/*", "test/**/*", "sst-env.d.ts"] -} diff --git a/examples/aws-nestjs-redis/.dockerignore b/examples/aws-nestjs-redis/.dockerignore deleted file mode 100644 index 533d93408b..0000000000 --- a/examples/aws-nestjs-redis/.dockerignore +++ /dev/null @@ -1,6 +0,0 @@ -node_modules -dist - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-nestjs-redis/.eslintrc.js b/examples/aws-nestjs-redis/.eslintrc.js deleted file mode 100644 index 259de13c73..0000000000 --- a/examples/aws-nestjs-redis/.eslintrc.js +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = { - parser: '@typescript-eslint/parser', - parserOptions: { - project: 'tsconfig.json', - tsconfigRootDir: __dirname, - sourceType: 'module', - }, - plugins: ['@typescript-eslint/eslint-plugin'], - extends: [ - 'plugin:@typescript-eslint/recommended', - 'plugin:prettier/recommended', - ], - root: true, - env: { - node: true, - jest: true, - }, - ignorePatterns: ['.eslintrc.js'], - rules: { - '@typescript-eslint/interface-name-prefix': 'off', - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/no-explicit-any': 'off', - }, -}; diff --git a/examples/aws-nestjs-redis/.gitignore b/examples/aws-nestjs-redis/.gitignore deleted file mode 100644 index 8e0d8ec3b0..0000000000 --- a/examples/aws-nestjs-redis/.gitignore +++ /dev/null @@ -1,59 +0,0 @@ -# compiled output -/dist -/node_modules -/build - -# Logs -logs -*.log -npm-debug.log* -pnpm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* - -# OS -.DS_Store - -# Tests -/coverage -/.nyc_output - -# IDEs and editors -/.idea -.project -.classpath -.c9/ -*.launch -.settings/ -*.sublime-workspace - -# IDE - VSCode -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# temp directory -.temp -.tmp - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# sst -.sst diff --git a/examples/aws-nestjs-redis/.prettierrc b/examples/aws-nestjs-redis/.prettierrc deleted file mode 100644 index dcb72794f5..0000000000 --- a/examples/aws-nestjs-redis/.prettierrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "singleQuote": true, - "trailingComma": "all" -} \ No newline at end of file diff --git a/examples/aws-nestjs-redis/Dockerfile b/examples/aws-nestjs-redis/Dockerfile deleted file mode 100644 index 143907a2df..0000000000 --- a/examples/aws-nestjs-redis/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:22 - -WORKDIR /usr/src/app -COPY package*.json ./ -RUN npm install -COPY . . -RUN npm run build - -EXPOSE 3000 -CMD ["node", "dist/main"] diff --git a/examples/aws-nestjs-redis/nest-cli.json b/examples/aws-nestjs-redis/nest-cli.json deleted file mode 100644 index f9aa683b1a..0000000000 --- a/examples/aws-nestjs-redis/nest-cli.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/nest-cli", - "collection": "@nestjs/schematics", - "sourceRoot": "src", - "compilerOptions": { - "deleteOutDir": true - } -} diff --git a/examples/aws-nestjs-redis/package.json b/examples/aws-nestjs-redis/package.json deleted file mode 100644 index 83fae61d50..0000000000 --- a/examples/aws-nestjs-redis/package.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "aws-nestjs-redis", - "version": "0.0.1", - "description": "", - "author": "", - "private": true, - "license": "UNLICENSED", - "scripts": { - "build": "nest build", - "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", - "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", - "start": "nest start", - "start:debug": "nest start --debug --watch", - "start:dev": "nest start --watch", - "start:prod": "node dist/main", - "test": "jest", - "test:cov": "jest --coverage", - "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", - "test:e2e": "jest --config ./test/jest-e2e.json", - "test:watch": "jest --watch" - }, - "dependencies": { - "@nestjs/common": "^10.0.0", - "@nestjs/core": "^10.0.0", - "@nestjs/platform-express": "^10.0.0", - "ioredis": "^5.4.1", - "reflect-metadata": "^0.2.0", - "rxjs": "^7.8.1", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@nestjs/cli": "^10.0.0", - "@nestjs/schematics": "^10.0.0", - "@nestjs/testing": "^10.0.0", - "@types/aws-lambda": "8.10.145", - "@types/express": "^4.17.17", - "@types/jest": "^29.5.2", - "@types/node": "^20.3.1", - "@types/supertest": "^6.0.0", - "@typescript-eslint/eslint-plugin": "^8.0.0", - "@typescript-eslint/parser": "^8.0.0", - "eslint": "^8.42.0", - "eslint-config-prettier": "^9.0.0", - "eslint-plugin-prettier": "^5.0.0", - "jest": "^29.5.0", - "prettier": "^3.0.0", - "source-map-support": "^0.5.21", - "supertest": "^7.0.0", - "ts-jest": "^29.1.0", - "ts-loader": "^9.4.3", - "ts-node": "^10.9.1", - "tsconfig-paths": "^4.2.0", - "typescript": "^5.1.3" - }, - "jest": { - "collectCoverageFrom": [ - "**/*.(t|j)s" - ], - "coverageDirectory": "../coverage", - "moduleFileExtensions": [ - "js", - "json", - "ts" - ], - "rootDir": "src", - "testEnvironment": "node", - "testRegex": ".*\\.spec\\.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - } - } -} diff --git a/examples/aws-nestjs-redis/src/app.controller.spec.ts b/examples/aws-nestjs-redis/src/app.controller.spec.ts deleted file mode 100644 index d22f3890a3..0000000000 --- a/examples/aws-nestjs-redis/src/app.controller.spec.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; - -describe('AppController', () => { - let appController: AppController; - - beforeEach(async () => { - const app: TestingModule = await Test.createTestingModule({ - controllers: [AppController], - providers: [AppService], - }).compile(); - - appController = app.get(AppController); - }); - - describe('root', () => { - it('should return "Hello World!"', () => { - expect(appController.getHello()).toBe('Hello World!'); - }); - }); -}); diff --git a/examples/aws-nestjs-redis/src/app.controller.ts b/examples/aws-nestjs-redis/src/app.controller.ts deleted file mode 100644 index e821e40746..0000000000 --- a/examples/aws-nestjs-redis/src/app.controller.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Controller, Get } from '@nestjs/common'; -import { AppService } from './app.service'; - -@Controller() -export class AppController { - constructor(private readonly appService: AppService) { } - - @Get() - async getCounter(): Promise { - return (await this.appService.getCounter()).toString(); - } -} diff --git a/examples/aws-nestjs-redis/src/app.module.ts b/examples/aws-nestjs-redis/src/app.module.ts deleted file mode 100644 index 86628031ca..0000000000 --- a/examples/aws-nestjs-redis/src/app.module.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Module } from '@nestjs/common'; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; - -@Module({ - imports: [], - controllers: [AppController], - providers: [AppService], -}) -export class AppModule {} diff --git a/examples/aws-nestjs-redis/src/app.service.ts b/examples/aws-nestjs-redis/src/app.service.ts deleted file mode 100644 index 25a01b7010..0000000000 --- a/examples/aws-nestjs-redis/src/app.service.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { Resource } from "sst"; -import { Cluster } from "ioredis"; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -@Injectable() -export class AppService { - getHello(): string { - return 'Hello World!'; - } - - async getCounter(): Promise { - return await redis.incr("counter"); - } -} diff --git a/examples/aws-nestjs-redis/src/main.ts b/examples/aws-nestjs-redis/src/main.ts deleted file mode 100644 index 13cad38cff..0000000000 --- a/examples/aws-nestjs-redis/src/main.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { NestFactory } from '@nestjs/core'; -import { AppModule } from './app.module'; - -async function bootstrap() { - const app = await NestFactory.create(AppModule); - await app.listen(3000); -} -bootstrap(); diff --git a/examples/aws-nestjs-redis/sst.config.ts b/examples/aws-nestjs-redis/sst.config.ts deleted file mode 100644 index dcc3f4aa0f..0000000000 --- a/examples/aws-nestjs-redis/sst.config.ts +++ /dev/null @@ -1,75 +0,0 @@ -/// - -/** - * ## AWS NestJS with Redis - * - * Creates a hit counter app with NestJS and Redis. - * - * :::note - * You need Node 22.12 or higher for this example to work. - * ::: - * - * Also make sure you have Node 22.12. Or set the `--experimental-require-module` flag. - * This'll allow NestJS to import the SST SDK. - * - * This deploys NestJS as a Fargate service to ECS and it's linked to Redis. - * - * ```ts title="sst.config.ts" {3} - * new sst.aws.Service("MyService", { - * cluster, - * link: [redis], - * loadBalancer: { - * ports: [{ listen: "80/http", forward: "3000/http" }], - * }, - * dev: { - * command: "npm run start:dev", - * }, - * }); - * ``` - * - * Since our Redis cluster is in a VPC, we’ll need a tunnel to connect to it from our local - * machine. - * - * ```bash "sudo" - * sudo npx sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * To start your app locally run. - * - * ```bash - * npx sst dev - * ``` - * - * Now if you go to `http://localhost:3000` you’ll see a counter update as you refresh the page. - * - * Finally, you can deploy it using `npx sst deploy --stage production` using a `Dockerfile` - * that's included in the example. - */ -export default $config({ - app(input) { - return { - name: 'aws-nestjs-redis', - removal: input?.stage === 'production' ? 'retain' : 'remove', - home: 'aws', - }; - }, - async run() { - const vpc = new sst.aws.Vpc('MyVpc', { bastion: true }); - const redis = new sst.aws.Redis('MyRedis', { vpc }); - const cluster = new sst.aws.Cluster('MyCluster', { vpc }); - - new sst.aws.Service('MyService', { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: '80/http', forward: '3000/http' }], - }, - dev: { - command: 'npm run start:dev', - }, - }); - }, -}); diff --git a/examples/aws-nestjs-redis/test/app.e2e-spec.ts b/examples/aws-nestjs-redis/test/app.e2e-spec.ts deleted file mode 100644 index 50cda62332..0000000000 --- a/examples/aws-nestjs-redis/test/app.e2e-spec.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { INestApplication } from '@nestjs/common'; -import * as request from 'supertest'; -import { AppModule } from './../src/app.module'; - -describe('AppController (e2e)', () => { - let app: INestApplication; - - beforeEach(async () => { - const moduleFixture: TestingModule = await Test.createTestingModule({ - imports: [AppModule], - }).compile(); - - app = moduleFixture.createNestApplication(); - await app.init(); - }); - - it('/ (GET)', () => { - return request(app.getHttpServer()) - .get('/') - .expect(200) - .expect('Hello World!'); - }); -}); diff --git a/examples/aws-nestjs-redis/test/jest-e2e.json b/examples/aws-nestjs-redis/test/jest-e2e.json deleted file mode 100644 index e9d912f3e3..0000000000 --- a/examples/aws-nestjs-redis/test/jest-e2e.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "moduleFileExtensions": ["js", "json", "ts"], - "rootDir": ".", - "testEnvironment": "node", - "testRegex": ".e2e-spec.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - } -} diff --git a/examples/aws-nestjs-redis/tsconfig.build.json b/examples/aws-nestjs-redis/tsconfig.build.json deleted file mode 100644 index 64f86c6bd2..0000000000 --- a/examples/aws-nestjs-redis/tsconfig.build.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "./tsconfig.json", - "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] -} diff --git a/examples/aws-nestjs-redis/tsconfig.json b/examples/aws-nestjs-redis/tsconfig.json deleted file mode 100644 index bf0b1c3ad8..0000000000 --- a/examples/aws-nestjs-redis/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "declaration": true, - "removeComments": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "allowSyntheticDefaultImports": true, - "target": "ES2021", - "sourceMap": true, - "outDir": "./dist", - "baseUrl": "./", - "incremental": true, - "skipLibCheck": true, - "strictNullChecks": false, - "noImplicitAny": false, - "strictBindCallApply": false, - "forceConsistentCasingInFileNames": false, - "noFallthroughCasesInSwitch": false - }, - "include": ["src/**/*", "test/**/*", "sst-env.d.ts"], -} diff --git a/examples/aws-nextjs-add-behavior/.gitignore b/examples/aws-nextjs-add-behavior/.gitignore deleted file mode 100644 index 3ecba30f1c..0000000000 --- a/examples/aws-nextjs-add-behavior/.gitignore +++ /dev/null @@ -1,46 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.* -.yarn/* -!.yarn/patches -!.yarn/plugins -!.yarn/releases -!.yarn/versions - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# env files (can opt-in for commiting if needed) -.env* - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts - -# sst -.sst - -# open-next -.open-next diff --git a/examples/aws-nextjs-add-behavior/app/favicon.ico b/examples/aws-nextjs-add-behavior/app/favicon.ico deleted file mode 100644 index 718d6fea48..0000000000 Binary files a/examples/aws-nextjs-add-behavior/app/favicon.ico and /dev/null differ diff --git a/examples/aws-nextjs-add-behavior/app/fonts/GeistMonoVF.woff b/examples/aws-nextjs-add-behavior/app/fonts/GeistMonoVF.woff deleted file mode 100644 index f2ae185cbf..0000000000 Binary files a/examples/aws-nextjs-add-behavior/app/fonts/GeistMonoVF.woff and /dev/null differ diff --git a/examples/aws-nextjs-add-behavior/app/fonts/GeistVF.woff b/examples/aws-nextjs-add-behavior/app/fonts/GeistVF.woff deleted file mode 100644 index 1b62daacff..0000000000 Binary files a/examples/aws-nextjs-add-behavior/app/fonts/GeistVF.woff and /dev/null differ diff --git a/examples/aws-nextjs-add-behavior/app/globals.css b/examples/aws-nextjs-add-behavior/app/globals.css deleted file mode 100644 index e3734be15e..0000000000 --- a/examples/aws-nextjs-add-behavior/app/globals.css +++ /dev/null @@ -1,42 +0,0 @@ -:root { - --background: #ffffff; - --foreground: #171717; -} - -@media (prefers-color-scheme: dark) { - :root { - --background: #0a0a0a; - --foreground: #ededed; - } -} - -html, -body { - max-width: 100vw; - overflow-x: hidden; -} - -body { - color: var(--foreground); - background: var(--background); - font-family: Arial, Helvetica, sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -* { - box-sizing: border-box; - padding: 0; - margin: 0; -} - -a { - color: inherit; - text-decoration: none; -} - -@media (prefers-color-scheme: dark) { - html { - color-scheme: dark; - } -} diff --git a/examples/aws-nextjs-add-behavior/app/layout.tsx b/examples/aws-nextjs-add-behavior/app/layout.tsx deleted file mode 100644 index dca06aee77..0000000000 --- a/examples/aws-nextjs-add-behavior/app/layout.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import type { Metadata } from "next"; -import localFont from "next/font/local"; -import "./globals.css"; - -const geistSans = localFont({ - src: "./fonts/GeistVF.woff", - variable: "--font-geist-sans", - weight: "100 900", -}); -const geistMono = localFont({ - src: "./fonts/GeistMonoVF.woff", - variable: "--font-geist-mono", - weight: "100 900", -}); - -export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", -}; - -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { - return ( - - - {children} - - - ); -} diff --git a/examples/aws-nextjs-add-behavior/app/page.module.css b/examples/aws-nextjs-add-behavior/app/page.module.css deleted file mode 100644 index ee9b8e6339..0000000000 --- a/examples/aws-nextjs-add-behavior/app/page.module.css +++ /dev/null @@ -1,168 +0,0 @@ -.page { - --gray-rgb: 0, 0, 0; - --gray-alpha-200: rgba(var(--gray-rgb), 0.08); - --gray-alpha-100: rgba(var(--gray-rgb), 0.05); - - --button-primary-hover: #383838; - --button-secondary-hover: #f2f2f2; - - display: grid; - grid-template-rows: 20px 1fr 20px; - align-items: center; - justify-items: center; - min-height: 100svh; - padding: 80px; - gap: 64px; - font-family: var(--font-geist-sans); -} - -@media (prefers-color-scheme: dark) { - .page { - --gray-rgb: 255, 255, 255; - --gray-alpha-200: rgba(var(--gray-rgb), 0.145); - --gray-alpha-100: rgba(var(--gray-rgb), 0.06); - - --button-primary-hover: #ccc; - --button-secondary-hover: #1a1a1a; - } -} - -.main { - display: flex; - flex-direction: column; - gap: 32px; - grid-row-start: 2; -} - -.main ol { - font-family: var(--font-geist-mono); - padding-left: 0; - margin: 0; - font-size: 14px; - line-height: 24px; - letter-spacing: -0.01em; - list-style-position: inside; -} - -.main li:not(:last-of-type) { - margin-bottom: 8px; -} - -.main code { - font-family: inherit; - background: var(--gray-alpha-100); - padding: 2px 4px; - border-radius: 4px; - font-weight: 600; -} - -.ctas { - display: flex; - gap: 16px; -} - -.ctas a { - appearance: none; - border-radius: 128px; - height: 48px; - padding: 0 20px; - border: none; - border: 1px solid transparent; - transition: - background 0.2s, - color 0.2s, - border-color 0.2s; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - font-size: 16px; - line-height: 20px; - font-weight: 500; -} - -a.primary { - background: var(--foreground); - color: var(--background); - gap: 8px; -} - -a.secondary { - border-color: var(--gray-alpha-200); - min-width: 180px; -} - -.footer { - grid-row-start: 3; - display: flex; - gap: 24px; -} - -.footer a { - display: flex; - align-items: center; - gap: 8px; -} - -.footer img { - flex-shrink: 0; -} - -/* Enable hover only on non-touch devices */ -@media (hover: hover) and (pointer: fine) { - a.primary:hover { - background: var(--button-primary-hover); - border-color: transparent; - } - - a.secondary:hover { - background: var(--button-secondary-hover); - border-color: transparent; - } - - .footer a:hover { - text-decoration: underline; - text-underline-offset: 4px; - } -} - -@media (max-width: 600px) { - .page { - padding: 32px; - padding-bottom: 80px; - } - - .main { - align-items: center; - } - - .main ol { - text-align: center; - } - - .ctas { - flex-direction: column; - } - - .ctas a { - font-size: 14px; - height: 40px; - padding: 0 16px; - } - - a.secondary { - min-width: auto; - } - - .footer { - flex-wrap: wrap; - align-items: center; - justify-content: center; - } -} - -@media (prefers-color-scheme: dark) { - .logo { - filter: invert(); - } -} diff --git a/examples/aws-nextjs-add-behavior/app/page.tsx b/examples/aws-nextjs-add-behavior/app/page.tsx deleted file mode 100644 index 52bd15ee7f..0000000000 --- a/examples/aws-nextjs-add-behavior/app/page.tsx +++ /dev/null @@ -1,95 +0,0 @@ -import Image from "next/image"; -import styles from "./page.module.css"; - -export default function Home() { - return ( -
-
- Next.js logo -
    -
  1. - Get started by editing app/page.tsx. -
  2. -
  3. Save and see your changes instantly.
  4. -
- - -
- -
- ); -} diff --git a/examples/aws-nextjs-add-behavior/next.config.ts b/examples/aws-nextjs-add-behavior/next.config.ts deleted file mode 100644 index e9ffa3083a..0000000000 --- a/examples/aws-nextjs-add-behavior/next.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { NextConfig } from "next"; - -const nextConfig: NextConfig = { - /* config options here */ -}; - -export default nextConfig; diff --git a/examples/aws-nextjs-add-behavior/package.json b/examples/aws-nextjs-add-behavior/package.json deleted file mode 100644 index aae5dbed9e..0000000000 --- a/examples/aws-nextjs-add-behavior/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "aws-nextjs-add-behavior", - "version": "0.1.0", - "private": true, - "scripts": { - "build": "next build", - "dev": "next dev", - "lint": "next lint", - "start": "next start" - }, - "dependencies": { - "next": "15.0.1", - "react": "19.0.0-rc-69d4b800-20241021", - "react-dom": "19.0.0-rc-69d4b800-20241021", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/node": "^20", - "@types/react": "^18", - "@types/react-dom": "^18", - "typescript": "^5" - } -} diff --git a/examples/aws-nextjs-add-behavior/public/file.svg b/examples/aws-nextjs-add-behavior/public/file.svg deleted file mode 100644 index 004145cddf..0000000000 --- a/examples/aws-nextjs-add-behavior/public/file.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-nextjs-add-behavior/public/globe.svg b/examples/aws-nextjs-add-behavior/public/globe.svg deleted file mode 100644 index 567f17b0d7..0000000000 --- a/examples/aws-nextjs-add-behavior/public/globe.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-nextjs-add-behavior/public/next.svg b/examples/aws-nextjs-add-behavior/public/next.svg deleted file mode 100644 index 5174b28c56..0000000000 --- a/examples/aws-nextjs-add-behavior/public/next.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-nextjs-add-behavior/public/vercel.svg b/examples/aws-nextjs-add-behavior/public/vercel.svg deleted file mode 100644 index 7705396033..0000000000 --- a/examples/aws-nextjs-add-behavior/public/vercel.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-nextjs-add-behavior/public/window.svg b/examples/aws-nextjs-add-behavior/public/window.svg deleted file mode 100644 index b2b2a44f6e..0000000000 --- a/examples/aws-nextjs-add-behavior/public/window.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-nextjs-add-behavior/sst.config.ts b/examples/aws-nextjs-add-behavior/sst.config.ts deleted file mode 100644 index c50649d7d4..0000000000 --- a/examples/aws-nextjs-add-behavior/sst.config.ts +++ /dev/null @@ -1,73 +0,0 @@ -/// - -/** - * ## AWS Next.js add behavior - * - * Here's how to add additional routes or cache behaviors to the CDN of a Next.js app deployed - * with OpenNext to AWS. - * - * Specify the path pattern that you want to forward to your new origin. For example, to forward - * all requests to the `/blog` path to a different origin. - * - * ```ts title="sst.config.ts" - * pathPattern: "/blog/*" - * ``` - * - * And then specify the domain of the new origin. - * - * ```ts title="sst.config.ts" - * domainName: "blog.example.com" - * ``` - * - * We use this to `transform` our site's CDN and add the additional behaviors. - */ -export default $config({ - app(input) { - return { - name: "aws-nextjs-add-behavior", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const blogOrigin = { - // The domain of the new origin - domainName: "blog.example.com", - originId: "blogCustomOrigin", - customOriginConfig: { - httpPort: 80, - httpsPort: 443, - originSslProtocols: ["TLSv1.2"], - // If HTTPS is supported - originProtocolPolicy: "https-only", - }, - }; - - const cacheBehavior = { - // The path to forward to the new origin - pathPattern: "/blog/*", - targetOriginId: blogOrigin.originId, - viewerProtocolPolicy: "redirect-to-https", - allowedMethods: ["GET", "HEAD", "OPTIONS"], - cachedMethods: ["GET", "HEAD"], - forwardedValues: { - queryString: true, - cookies: { - forward: "all", - }, - }, - }; - - new sst.aws.Nextjs("MyWeb", { - transform: { - cdn: (options: sst.aws.CdnArgs) => { - options.origins = $resolve(options.origins).apply(val => [...val, blogOrigin]); - - options.orderedCacheBehaviors = $resolve( - options.orderedCacheBehaviors || [] - ).apply(val => [...val, cacheBehavior]); - }, - }, - }); - }, -}); diff --git a/examples/aws-nextjs-add-behavior/tsconfig.json b/examples/aws-nextjs-add-behavior/tsconfig.json deleted file mode 100644 index 3577577791..0000000000 --- a/examples/aws-nextjs-add-behavior/tsconfig.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2017", - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, - "plugins": [ - { - "name": "next" - } - ], - "paths": { - "@/*": ["./*"] - } - }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules","sst.config.ts"] -} diff --git a/examples/aws-nextjs-basic-auth/.eslintrc.json b/examples/aws-nextjs-basic-auth/.eslintrc.json deleted file mode 100644 index 3722418549..0000000000 --- a/examples/aws-nextjs-basic-auth/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["next/core-web-vitals", "next/typescript"] -} diff --git a/examples/aws-nextjs-basic-auth/.gitignore b/examples/aws-nextjs-basic-auth/.gitignore deleted file mode 100644 index 69d7f97469..0000000000 --- a/examples/aws-nextjs-basic-auth/.gitignore +++ /dev/null @@ -1,42 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js -.yarn/install-state.gz - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env*.local - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts - -# sst -.sst - -# open-next -.open-next diff --git a/examples/aws-nextjs-basic-auth/app/favicon.ico b/examples/aws-nextjs-basic-auth/app/favicon.ico deleted file mode 100644 index 718d6fea48..0000000000 Binary files a/examples/aws-nextjs-basic-auth/app/favicon.ico and /dev/null differ diff --git a/examples/aws-nextjs-basic-auth/app/fonts/GeistMonoVF.woff b/examples/aws-nextjs-basic-auth/app/fonts/GeistMonoVF.woff deleted file mode 100644 index f2ae185cbf..0000000000 Binary files a/examples/aws-nextjs-basic-auth/app/fonts/GeistMonoVF.woff and /dev/null differ diff --git a/examples/aws-nextjs-basic-auth/app/fonts/GeistVF.woff b/examples/aws-nextjs-basic-auth/app/fonts/GeistVF.woff deleted file mode 100644 index 1b62daacff..0000000000 Binary files a/examples/aws-nextjs-basic-auth/app/fonts/GeistVF.woff and /dev/null differ diff --git a/examples/aws-nextjs-basic-auth/app/globals.css b/examples/aws-nextjs-basic-auth/app/globals.css deleted file mode 100644 index e3734be15e..0000000000 --- a/examples/aws-nextjs-basic-auth/app/globals.css +++ /dev/null @@ -1,42 +0,0 @@ -:root { - --background: #ffffff; - --foreground: #171717; -} - -@media (prefers-color-scheme: dark) { - :root { - --background: #0a0a0a; - --foreground: #ededed; - } -} - -html, -body { - max-width: 100vw; - overflow-x: hidden; -} - -body { - color: var(--foreground); - background: var(--background); - font-family: Arial, Helvetica, sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -* { - box-sizing: border-box; - padding: 0; - margin: 0; -} - -a { - color: inherit; - text-decoration: none; -} - -@media (prefers-color-scheme: dark) { - html { - color-scheme: dark; - } -} diff --git a/examples/aws-nextjs-basic-auth/app/layout.tsx b/examples/aws-nextjs-basic-auth/app/layout.tsx deleted file mode 100644 index dca06aee77..0000000000 --- a/examples/aws-nextjs-basic-auth/app/layout.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import type { Metadata } from "next"; -import localFont from "next/font/local"; -import "./globals.css"; - -const geistSans = localFont({ - src: "./fonts/GeistVF.woff", - variable: "--font-geist-sans", - weight: "100 900", -}); -const geistMono = localFont({ - src: "./fonts/GeistMonoVF.woff", - variable: "--font-geist-mono", - weight: "100 900", -}); - -export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", -}; - -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { - return ( - - - {children} - - - ); -} diff --git a/examples/aws-nextjs-basic-auth/app/page.module.css b/examples/aws-nextjs-basic-auth/app/page.module.css deleted file mode 100644 index 8a460419f9..0000000000 --- a/examples/aws-nextjs-basic-auth/app/page.module.css +++ /dev/null @@ -1,165 +0,0 @@ -.page { - --gray-rgb: 0, 0, 0; - --gray-alpha-200: rgba(var(--gray-rgb), 0.08); - --gray-alpha-100: rgba(var(--gray-rgb), 0.05); - - --button-primary-hover: #383838; - --button-secondary-hover: #f2f2f2; - - display: grid; - grid-template-rows: 20px 1fr 20px; - align-items: center; - justify-items: center; - min-height: 100svh; - padding: 80px; - gap: 64px; - font-family: var(--font-geist-sans); -} - -@media (prefers-color-scheme: dark) { - .page { - --gray-rgb: 255, 255, 255; - --gray-alpha-200: rgba(var(--gray-rgb), 0.145); - --gray-alpha-100: rgba(var(--gray-rgb), 0.06); - - --button-primary-hover: #ccc; - --button-secondary-hover: #1a1a1a; - } -} - -.main { - display: flex; - flex-direction: column; - gap: 32px; - grid-row-start: 2; -} - -.main ol { - font-family: var(--font-geist-mono); - padding-left: 0; - margin: 0; - font-size: 14px; - line-height: 24px; - letter-spacing: -0.01em; - list-style-position: inside; -} - -.main li:not(:last-of-type) { - margin-bottom: 8px; -} - -.main code { - font-family: inherit; - background: var(--gray-alpha-100); - padding: 2px 4px; - border-radius: 4px; - font-weight: 600; -} - -.ctas { - display: flex; - gap: 16px; -} - -.ctas a { - appearance: none; - border-radius: 128px; - height: 48px; - padding: 0 20px; - border: none; - border: 1px solid transparent; - transition: background 0.2s, color 0.2s, border-color 0.2s; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - font-size: 16px; - line-height: 20px; - font-weight: 500; -} - -a.primary { - background: var(--foreground); - color: var(--background); - gap: 8px; -} - -a.secondary { - border-color: var(--gray-alpha-200); - min-width: 180px; -} - -.footer { - grid-row-start: 3; - display: flex; - gap: 24px; -} - -.footer a { - display: flex; - align-items: center; - gap: 8px; -} - -.footer img { - flex-shrink: 0; -} - -/* Enable hover only on non-touch devices */ -@media (hover: hover) and (pointer: fine) { - a.primary:hover { - background: var(--button-primary-hover); - border-color: transparent; - } - - a.secondary:hover { - background: var(--button-secondary-hover); - border-color: transparent; - } - - .footer a:hover { - text-decoration: underline; - text-underline-offset: 4px; - } -} - -@media (max-width: 600px) { - .page { - padding: 32px; - padding-bottom: 80px; - } - - .main { - align-items: center; - } - - .main ol { - text-align: center; - } - - .ctas { - flex-direction: column; - } - - .ctas a { - font-size: 14px; - height: 40px; - padding: 0 16px; - } - - a.secondary { - min-width: auto; - } - - .footer { - flex-wrap: wrap; - align-items: center; - justify-content: center; - } -} - -@media (prefers-color-scheme: dark) { - .logo { - filter: invert(); - } -} diff --git a/examples/aws-nextjs-basic-auth/app/page.tsx b/examples/aws-nextjs-basic-auth/app/page.tsx deleted file mode 100644 index df5d042428..0000000000 --- a/examples/aws-nextjs-basic-auth/app/page.tsx +++ /dev/null @@ -1,95 +0,0 @@ -import Image from "next/image"; -import styles from "./page.module.css"; - -export default function Home() { - return ( -
-
- Next.js logo -
    -
  1. - Get started by editing app/page.tsx. -
  2. -
  3. Save and see your changes instantly.
  4. -
- - -
- -
- ); -} diff --git a/examples/aws-nextjs-basic-auth/next.config.mjs b/examples/aws-nextjs-basic-auth/next.config.mjs deleted file mode 100644 index 4678774e6d..0000000000 --- a/examples/aws-nextjs-basic-auth/next.config.mjs +++ /dev/null @@ -1,4 +0,0 @@ -/** @type {import('next').NextConfig} */ -const nextConfig = {}; - -export default nextConfig; diff --git a/examples/aws-nextjs-basic-auth/package.json b/examples/aws-nextjs-basic-auth/package.json deleted file mode 100644 index f9239740de..0000000000 --- a/examples/aws-nextjs-basic-auth/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "aws-nextjs-basic-auth", - "version": "0.1.0", - "private": true, - "scripts": { - "build": "next build", - "dev": "next dev", - "lint": "next lint", - "start": "next start" - }, - "dependencies": { - "next": "14.2.9", - "react": "^18", - "react-dom": "^18", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/node": "^20", - "@types/react": "^18", - "@types/react-dom": "^18", - "eslint": "^8", - "eslint-config-next": "14.2.9", - "typescript": "^5" - } -} diff --git a/examples/aws-nextjs-basic-auth/sst.config.ts b/examples/aws-nextjs-basic-auth/sst.config.ts deleted file mode 100644 index 775cdb274d..0000000000 --- a/examples/aws-nextjs-basic-auth/sst.config.ts +++ /dev/null @@ -1,85 +0,0 @@ -/// - -/** - * ## AWS Next.js basic auth - * - * Deploys a simple Next.js app and adds basic auth to it. - * - * This is useful for dev environments where you want to share your app your team but ensure - * that it's not publicly accessible. - * - * :::tip - * You can use this for all the SSR sites, like Astro, Remix, SvelteKit, etc. - * ::: - * - * This works by injecting some code into a CloudFront function that checks the basic auth - * header and matches it against the `USERNAME` and `PASSWORD` secrets. - * - * ```ts title="sst.config.ts" - * { - * injection: $interpolate` - * if ( - * !event.request.headers.authorization - * || event.request.headers.authorization.value !== "Basic ${basicAuth}" - * ) { - * return { - * statusCode: 401, - * headers: { - * "www-authenticate": { value: "Basic" } - * } - * }; - * }`, - * } - * ``` - * - * To deploy this, you need to first set the `USERNAME` and `PASSWORD` secrets. - * - * ```bash - * sst secret set USERNAME my-username - * sst secret set PASSWORD my-password - * ``` - * - * If you are deploying this to preview environments, you might want to set the secrets using - * the [`--fallback`](/docs/reference/cli#secret) flag. - */ -export default $config({ - app(input) { - return { - name: "aws-nextjs-basic-auth", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const username = new sst.Secret("USERNAME"); - const password = new sst.Secret("PASSWORD"); - const basicAuth = $resolve([username.value, password.value]).apply( - ([username, password]) => - Buffer.from(`${username}:${password}`).toString("base64") - ); - - new sst.aws.Nextjs("MyWeb", { - server: { - // Don't password protect prod - edge: $app.stage !== "production" - ? { - viewerRequest: { - injection: $interpolate` - if ( - !event.request.headers.authorization - || event.request.headers.authorization.value !== "Basic ${basicAuth}" - ) { - return { - statusCode: 401, - headers: { - "www-authenticate": { value: "Basic" } - } - }; - }`, - }, - } - : undefined, - }, - }); - }, -}); diff --git a/examples/aws-nextjs-basic-auth/tsconfig.json b/examples/aws-nextjs-basic-auth/tsconfig.json deleted file mode 100644 index 56433afeb2..0000000000 --- a/examples/aws-nextjs-basic-auth/tsconfig.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "compilerOptions": { - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, - "plugins": [ - { - "name": "next" - } - ], - "paths": { - "@/*": ["./*"] - } - }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules","sst.config.ts"] -} diff --git a/examples/aws-nextjs-container/.dockerignore b/examples/aws-nextjs-container/.dockerignore deleted file mode 100644 index d0a41b0f28..0000000000 --- a/examples/aws-nextjs-container/.dockerignore +++ /dev/null @@ -1,7 +0,0 @@ -.git -.next -node_modules - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-nextjs-container/.gitignore b/examples/aws-nextjs-container/.gitignore deleted file mode 100644 index e1f9fd2d79..0000000000 --- a/examples/aws-nextjs-container/.gitignore +++ /dev/null @@ -1,46 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.* -.yarn/* -!.yarn/patches -!.yarn/plugins -!.yarn/releases -!.yarn/versions - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# env files (can opt-in for committing if needed) -.env* - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts - -# sst -.sst - -# open-next -.open-next diff --git a/examples/aws-nextjs-container/Dockerfile b/examples/aws-nextjs-container/Dockerfile deleted file mode 100644 index ff80689629..0000000000 --- a/examples/aws-nextjs-container/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -# https://github.com/nextjs/deploy-sst/blob/main/Dockerfile -FROM node:lts-alpine AS base - -# Stage 1: Install dependencies -FROM base AS deps -WORKDIR /app -COPY package.json package-lock.json* ./ -COPY sst-env.d.ts* ./ -RUN npm ci - -# Stage 2: Build the application -FROM base AS builder -WORKDIR /app -COPY --from=deps /app/node_modules ./node_modules -COPY . . -RUN npm run build - -# Stage 3: Production server -FROM base AS runner -WORKDIR /app -ENV NODE_ENV=production -COPY --from=builder /app/.next/standalone ./ -COPY --from=builder /app/.next/static ./.next/static - -EXPOSE 3000 -CMD ["node", "server.js"] diff --git a/examples/aws-nextjs-container/app/favicon.ico b/examples/aws-nextjs-container/app/favicon.ico deleted file mode 100644 index 718d6fea48..0000000000 Binary files a/examples/aws-nextjs-container/app/favicon.ico and /dev/null differ diff --git a/examples/aws-nextjs-container/app/fonts/GeistMonoVF.woff b/examples/aws-nextjs-container/app/fonts/GeistMonoVF.woff deleted file mode 100644 index f2ae185cbf..0000000000 Binary files a/examples/aws-nextjs-container/app/fonts/GeistMonoVF.woff and /dev/null differ diff --git a/examples/aws-nextjs-container/app/fonts/GeistVF.woff b/examples/aws-nextjs-container/app/fonts/GeistVF.woff deleted file mode 100644 index 1b62daacff..0000000000 Binary files a/examples/aws-nextjs-container/app/fonts/GeistVF.woff and /dev/null differ diff --git a/examples/aws-nextjs-container/app/globals.css b/examples/aws-nextjs-container/app/globals.css deleted file mode 100644 index e3734be15e..0000000000 --- a/examples/aws-nextjs-container/app/globals.css +++ /dev/null @@ -1,42 +0,0 @@ -:root { - --background: #ffffff; - --foreground: #171717; -} - -@media (prefers-color-scheme: dark) { - :root { - --background: #0a0a0a; - --foreground: #ededed; - } -} - -html, -body { - max-width: 100vw; - overflow-x: hidden; -} - -body { - color: var(--foreground); - background: var(--background); - font-family: Arial, Helvetica, sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -* { - box-sizing: border-box; - padding: 0; - margin: 0; -} - -a { - color: inherit; - text-decoration: none; -} - -@media (prefers-color-scheme: dark) { - html { - color-scheme: dark; - } -} diff --git a/examples/aws-nextjs-container/app/layout.tsx b/examples/aws-nextjs-container/app/layout.tsx deleted file mode 100644 index dca06aee77..0000000000 --- a/examples/aws-nextjs-container/app/layout.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import type { Metadata } from "next"; -import localFont from "next/font/local"; -import "./globals.css"; - -const geistSans = localFont({ - src: "./fonts/GeistVF.woff", - variable: "--font-geist-sans", - weight: "100 900", -}); -const geistMono = localFont({ - src: "./fonts/GeistMonoVF.woff", - variable: "--font-geist-mono", - weight: "100 900", -}); - -export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", -}; - -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { - return ( - - - {children} - - - ); -} diff --git a/examples/aws-nextjs-container/app/page.module.css b/examples/aws-nextjs-container/app/page.module.css deleted file mode 100644 index ee9b8e6339..0000000000 --- a/examples/aws-nextjs-container/app/page.module.css +++ /dev/null @@ -1,168 +0,0 @@ -.page { - --gray-rgb: 0, 0, 0; - --gray-alpha-200: rgba(var(--gray-rgb), 0.08); - --gray-alpha-100: rgba(var(--gray-rgb), 0.05); - - --button-primary-hover: #383838; - --button-secondary-hover: #f2f2f2; - - display: grid; - grid-template-rows: 20px 1fr 20px; - align-items: center; - justify-items: center; - min-height: 100svh; - padding: 80px; - gap: 64px; - font-family: var(--font-geist-sans); -} - -@media (prefers-color-scheme: dark) { - .page { - --gray-rgb: 255, 255, 255; - --gray-alpha-200: rgba(var(--gray-rgb), 0.145); - --gray-alpha-100: rgba(var(--gray-rgb), 0.06); - - --button-primary-hover: #ccc; - --button-secondary-hover: #1a1a1a; - } -} - -.main { - display: flex; - flex-direction: column; - gap: 32px; - grid-row-start: 2; -} - -.main ol { - font-family: var(--font-geist-mono); - padding-left: 0; - margin: 0; - font-size: 14px; - line-height: 24px; - letter-spacing: -0.01em; - list-style-position: inside; -} - -.main li:not(:last-of-type) { - margin-bottom: 8px; -} - -.main code { - font-family: inherit; - background: var(--gray-alpha-100); - padding: 2px 4px; - border-radius: 4px; - font-weight: 600; -} - -.ctas { - display: flex; - gap: 16px; -} - -.ctas a { - appearance: none; - border-radius: 128px; - height: 48px; - padding: 0 20px; - border: none; - border: 1px solid transparent; - transition: - background 0.2s, - color 0.2s, - border-color 0.2s; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - font-size: 16px; - line-height: 20px; - font-weight: 500; -} - -a.primary { - background: var(--foreground); - color: var(--background); - gap: 8px; -} - -a.secondary { - border-color: var(--gray-alpha-200); - min-width: 180px; -} - -.footer { - grid-row-start: 3; - display: flex; - gap: 24px; -} - -.footer a { - display: flex; - align-items: center; - gap: 8px; -} - -.footer img { - flex-shrink: 0; -} - -/* Enable hover only on non-touch devices */ -@media (hover: hover) and (pointer: fine) { - a.primary:hover { - background: var(--button-primary-hover); - border-color: transparent; - } - - a.secondary:hover { - background: var(--button-secondary-hover); - border-color: transparent; - } - - .footer a:hover { - text-decoration: underline; - text-underline-offset: 4px; - } -} - -@media (max-width: 600px) { - .page { - padding: 32px; - padding-bottom: 80px; - } - - .main { - align-items: center; - } - - .main ol { - text-align: center; - } - - .ctas { - flex-direction: column; - } - - .ctas a { - font-size: 14px; - height: 40px; - padding: 0 16px; - } - - a.secondary { - min-width: auto; - } - - .footer { - flex-wrap: wrap; - align-items: center; - justify-content: center; - } -} - -@media (prefers-color-scheme: dark) { - .logo { - filter: invert(); - } -} diff --git a/examples/aws-nextjs-container/app/page.tsx b/examples/aws-nextjs-container/app/page.tsx deleted file mode 100644 index a7ce977382..0000000000 --- a/examples/aws-nextjs-container/app/page.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { Resource } from "sst"; -import Form from "@/components/form"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; -import styles from "./page.module.css"; - -export const dynamic = "force-dynamic"; - -export default async function Home() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return ( -
-
-
-
-
- ); -} diff --git a/examples/aws-nextjs-container/components/form.module.css b/examples/aws-nextjs-container/components/form.module.css deleted file mode 100644 index 6a12c9ae58..0000000000 --- a/examples/aws-nextjs-container/components/form.module.css +++ /dev/null @@ -1,24 +0,0 @@ -.form { - padding: 2rem; - border-radius: 0.5rem; - background-color: var(--gray-alpha-100); -} - -.form input { - margin-right: 1rem; -} - -.form button { - appearance: none; - padding: 0.5rem 0.75rem; - font-weight: 500; - font-size: 0.875rem; - border-radius: 0.375rem; - background-color: transparent; - font-family: var(--font-geist-sans); - border: 1px solid var(--gray-alpha-200); -} - -.form button:active:enabled { - background-color: var(--gray-alpha-200); -} diff --git a/examples/aws-nextjs-container/components/form.tsx b/examples/aws-nextjs-container/components/form.tsx deleted file mode 100644 index adaa22afdc..0000000000 --- a/examples/aws-nextjs-container/components/form.tsx +++ /dev/null @@ -1,30 +0,0 @@ -"use client"; - -import styles from "./form.module.css"; - -export default function Form({ url }: { url: string }) { - return ( - { - e.preventDefault(); - - const file = (e.target as HTMLFormElement).file.files?.[0] ?? null; - - const image = await fetch(url, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }} - > - - - - ); -} diff --git a/examples/aws-nextjs-container/next.config.ts b/examples/aws-nextjs-container/next.config.ts deleted file mode 100644 index e23d70d906..0000000000 --- a/examples/aws-nextjs-container/next.config.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { NextConfig } from "next"; - -const nextConfig: NextConfig = { - /* config options here */ - output: "standalone" -}; - -export default nextConfig; diff --git a/examples/aws-nextjs-container/package.json b/examples/aws-nextjs-container/package.json deleted file mode 100644 index 9e89772fb6..0000000000 --- a/examples/aws-nextjs-container/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "aws-nextjs-container", - "version": "0.1.0", - "private": true, - "scripts": { - "build": "next build", - "dev": "next dev", - "lint": "next lint", - "start": "next start" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.701.0", - "@aws-sdk/s3-request-presigner": "^3.701.0", - "next": "15.0.3", - "react": "19.0.0-rc-66855b96-20241106", - "react-dom": "19.0.0-rc-66855b96-20241106", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/node": "^20", - "@types/react": "^18", - "@types/react-dom": "^18", - "typescript": "^5" - } -} diff --git a/examples/aws-nextjs-container/public/file.svg b/examples/aws-nextjs-container/public/file.svg deleted file mode 100644 index 004145cddf..0000000000 --- a/examples/aws-nextjs-container/public/file.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-nextjs-container/public/globe.svg b/examples/aws-nextjs-container/public/globe.svg deleted file mode 100644 index 567f17b0d7..0000000000 --- a/examples/aws-nextjs-container/public/globe.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-nextjs-container/public/next.svg b/examples/aws-nextjs-container/public/next.svg deleted file mode 100644 index 5174b28c56..0000000000 --- a/examples/aws-nextjs-container/public/next.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-nextjs-container/public/vercel.svg b/examples/aws-nextjs-container/public/vercel.svg deleted file mode 100644 index 7705396033..0000000000 --- a/examples/aws-nextjs-container/public/vercel.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-nextjs-container/public/window.svg b/examples/aws-nextjs-container/public/window.svg deleted file mode 100644 index b2b2a44f6e..0000000000 --- a/examples/aws-nextjs-container/public/window.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-nextjs-container/sst.config.ts b/examples/aws-nextjs-container/sst.config.ts deleted file mode 100644 index 5550e64e57..0000000000 --- a/examples/aws-nextjs-container/sst.config.ts +++ /dev/null @@ -1,30 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-nextjs-container", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public", - }); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - link: [bucket], - }); - }, -}); diff --git a/examples/aws-nextjs-container/tsconfig.json b/examples/aws-nextjs-container/tsconfig.json deleted file mode 100644 index 3577577791..0000000000 --- a/examples/aws-nextjs-container/tsconfig.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2017", - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, - "plugins": [ - { - "name": "next" - } - ], - "paths": { - "@/*": ["./*"] - } - }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules","sst.config.ts"] -} diff --git a/examples/aws-nextjs-redis/.dockerignore b/examples/aws-nextjs-redis/.dockerignore deleted file mode 100644 index ff7df5d861..0000000000 --- a/examples/aws-nextjs-redis/.dockerignore +++ /dev/null @@ -1,12 +0,0 @@ -Dockerfile -.dockerignore -node_modules -npm-debug.log -README.md -.next -docker -.git - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-nextjs-redis/.gitignore b/examples/aws-nextjs-redis/.gitignore deleted file mode 100644 index 69d7f97469..0000000000 --- a/examples/aws-nextjs-redis/.gitignore +++ /dev/null @@ -1,42 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js -.yarn/install-state.gz - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env*.local - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts - -# sst -.sst - -# open-next -.open-next diff --git a/examples/aws-nextjs-redis/Dockerfile b/examples/aws-nextjs-redis/Dockerfile deleted file mode 100644 index 2d16514a6d..0000000000 --- a/examples/aws-nextjs-redis/Dockerfile +++ /dev/null @@ -1,75 +0,0 @@ -# https://github.com/vercel/next.js/tree/canary/examples/with-docker - -FROM node:18-alpine AS base - -# Install dependencies only when needed -FROM base AS deps -# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. -RUN apk add --no-cache libc6-compat -WORKDIR /app - -COPY sst-env.d.ts* ./ - -# Install dependencies based on the preferred package manager -COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ -RUN \ - if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ - elif [ -f package-lock.json ]; then npm ci; \ - elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \ - else echo "Lockfile not found." && exit 1; \ - fi - -# Rebuild the source code only when needed -FROM base AS builder - -# Add linked resources to the environment -ARG SST_RESOURCE_MyRedis - -WORKDIR /app -COPY --from=deps /app/node_modules ./node_modules -COPY . . - -# Next.js collects completely anonymous telemetry data about general usage. -# Learn more here: https://nextjs.org/telemetry -# Uncomment the following line in case you want to disable telemetry during the build. -# ENV NEXT_TELEMETRY_DISABLED=1 - -RUN \ - if [ -f yarn.lock ]; then yarn run build; \ - elif [ -f package-lock.json ]; then npm run build; \ - elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \ - else echo "Lockfile not found." && exit 1; \ - fi - -# Production image, copy all the files and run next -FROM base AS runner -WORKDIR /app - -ENV NODE_ENV=production -# Uncomment the following line in case you want to disable telemetry during runtime. -# ENV NEXT_TELEMETRY_DISABLED=1 - -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 nextjs - -COPY --from=builder /app/public* ./public - -# Set the correct permission for prerender cache -RUN mkdir .next -RUN chown nextjs:nodejs .next - -# Automatically leverage output traces to reduce image size -# https://nextjs.org/docs/advanced-features/output-file-tracing -COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ -COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static - -USER nextjs - -EXPOSE 3000 - -ENV PORT=3000 - -# server.js is created by next build from the standalone output -# https://nextjs.org/docs/pages/api-reference/next-config-js/output -ENV HOSTNAME="0.0.0.0" -CMD ["node", "server.js"] diff --git a/examples/aws-nextjs-redis/app/favicon.ico b/examples/aws-nextjs-redis/app/favicon.ico deleted file mode 100644 index 718d6fea48..0000000000 Binary files a/examples/aws-nextjs-redis/app/favicon.ico and /dev/null differ diff --git a/examples/aws-nextjs-redis/app/fonts/GeistMonoVF.woff b/examples/aws-nextjs-redis/app/fonts/GeistMonoVF.woff deleted file mode 100644 index f2ae185cbf..0000000000 Binary files a/examples/aws-nextjs-redis/app/fonts/GeistMonoVF.woff and /dev/null differ diff --git a/examples/aws-nextjs-redis/app/fonts/GeistVF.woff b/examples/aws-nextjs-redis/app/fonts/GeistVF.woff deleted file mode 100644 index 1b62daacff..0000000000 Binary files a/examples/aws-nextjs-redis/app/fonts/GeistVF.woff and /dev/null differ diff --git a/examples/aws-nextjs-redis/app/globals.css b/examples/aws-nextjs-redis/app/globals.css deleted file mode 100644 index e3734be15e..0000000000 --- a/examples/aws-nextjs-redis/app/globals.css +++ /dev/null @@ -1,42 +0,0 @@ -:root { - --background: #ffffff; - --foreground: #171717; -} - -@media (prefers-color-scheme: dark) { - :root { - --background: #0a0a0a; - --foreground: #ededed; - } -} - -html, -body { - max-width: 100vw; - overflow-x: hidden; -} - -body { - color: var(--foreground); - background: var(--background); - font-family: Arial, Helvetica, sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -* { - box-sizing: border-box; - padding: 0; - margin: 0; -} - -a { - color: inherit; - text-decoration: none; -} - -@media (prefers-color-scheme: dark) { - html { - color-scheme: dark; - } -} diff --git a/examples/aws-nextjs-redis/app/layout.tsx b/examples/aws-nextjs-redis/app/layout.tsx deleted file mode 100644 index dca06aee77..0000000000 --- a/examples/aws-nextjs-redis/app/layout.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import type { Metadata } from "next"; -import localFont from "next/font/local"; -import "./globals.css"; - -const geistSans = localFont({ - src: "./fonts/GeistVF.woff", - variable: "--font-geist-sans", - weight: "100 900", -}); -const geistMono = localFont({ - src: "./fonts/GeistMonoVF.woff", - variable: "--font-geist-mono", - weight: "100 900", -}); - -export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", -}; - -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { - return ( - - - {children} - - - ); -} diff --git a/examples/aws-nextjs-redis/app/page.module.css b/examples/aws-nextjs-redis/app/page.module.css deleted file mode 100644 index 51ed5f08db..0000000000 --- a/examples/aws-nextjs-redis/app/page.module.css +++ /dev/null @@ -1,41 +0,0 @@ -.page { - --gray-rgb: 0, 0, 0; - --gray-alpha-200: rgba(var(--gray-rgb), 0.08); - --gray-alpha-100: rgba(var(--gray-rgb), 0.05); - - --button-primary-hover: #383838; - --button-secondary-hover: #f2f2f2; - - display: grid; - grid-template-rows: 20px 1fr 20px; - align-items: center; - justify-items: center; - min-height: 100svh; - padding: 80px; - gap: 64px; - font-family: var(--font-geist-sans); -} - -@media (prefers-color-scheme: dark) { - .page { - --gray-rgb: 255, 255, 255; - --gray-alpha-200: rgba(var(--gray-rgb), 0.145); - --gray-alpha-100: rgba(var(--gray-rgb), 0.06); - - --button-primary-hover: #ccc; - --button-secondary-hover: #1a1a1a; - } -} - -.main { - display: flex; - flex-direction: column; - gap: 32px; - grid-row-start: 2; -} - -.main p { - font-family: var(--font-geist-mono); - font-size: 14px; - letter-spacing: -0.01em; -} diff --git a/examples/aws-nextjs-redis/app/page.tsx b/examples/aws-nextjs-redis/app/page.tsx deleted file mode 100644 index 09eda0ef92..0000000000 --- a/examples/aws-nextjs-redis/app/page.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { Resource } from "sst"; -import { Cluster } from "ioredis"; -import styles from "./page.module.css"; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -export const dynamic = "force-dynamic"; - -export default async function Home() { - const counter = await redis.incr("counter"); - - return ( -
-
-

Hit counter: {counter}

-
-
- ); -} diff --git a/examples/aws-nextjs-redis/next.config.mjs b/examples/aws-nextjs-redis/next.config.mjs deleted file mode 100644 index 68dea63186..0000000000 --- a/examples/aws-nextjs-redis/next.config.mjs +++ /dev/null @@ -1,6 +0,0 @@ -/** @type {import('next').NextConfig} */ -const nextConfig = { - output: "standalone" -}; - -export default nextConfig; diff --git a/examples/aws-nextjs-redis/package.json b/examples/aws-nextjs-redis/package.json deleted file mode 100644 index cc3f62615b..0000000000 --- a/examples/aws-nextjs-redis/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "aws-nextjs-redis", - "version": "0.1.0", - "private": true, - "scripts": { - "build": "next build", - "dev": "next dev", - "lint": "next lint", - "start": "next start" - }, - "dependencies": { - "ioredis": "^5.4.1", - "next": "14.2.14", - "react": "^18", - "react-dom": "^18", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/node": "^20", - "@types/react": "^18", - "@types/react-dom": "^18", - "typescript": "^5" - } -} diff --git a/examples/aws-nextjs-redis/sst.config.ts b/examples/aws-nextjs-redis/sst.config.ts deleted file mode 100644 index edc3bb7886..0000000000 --- a/examples/aws-nextjs-redis/sst.config.ts +++ /dev/null @@ -1,71 +0,0 @@ -/// - -/** - * ## AWS Next.js container with Redis - * - * Creates a hit counter app with Next.js and Redis. - * - * This deploys Next.js as a Fargate service to ECS and it's linked to Redis. - * - * ```ts title="sst.config.ts" {3} - * new sst.aws.Service("MyService", { - * cluster, - * link: [redis], - * loadBalancer: { - * ports: [{ listen: "80/http", forward: "3000/http" }], - * }, - * dev: { - * command: "npm run dev", - * }, - * }); - * ``` - * - * Since our Redis cluster is in a VPC, we’ll need a tunnel to connect to it from our local - * machine. - * - * ```bash "sudo" - * sudo npx sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * To start your app locally run. - * - * ```bash - * npx sst dev - * ``` - * - * Now if you go to `http://localhost:3000` you’ll see a counter update as you refresh the page. - * - * Finally, you can deploy it by: - * - * 1. Setting `output: "standalone"` in your `next.config.mjs` file. - * 2. Adding a `Dockerfile` that's included in this example. - * 3. Running `npx sst deploy --stage production`. - */ -export default $config({ - app(input) { - return { - name: "aws-nextjs-redis", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-nextjs-redis/tsconfig.json b/examples/aws-nextjs-redis/tsconfig.json deleted file mode 100644 index 56433afeb2..0000000000 --- a/examples/aws-nextjs-redis/tsconfig.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "compilerOptions": { - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, - "plugins": [ - { - "name": "next" - } - ], - "paths": { - "@/*": ["./*"] - } - }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules","sst.config.ts"] -} diff --git a/examples/aws-nextjs-stream/.gitignore b/examples/aws-nextjs-stream/.gitignore deleted file mode 100644 index 69d7f97469..0000000000 --- a/examples/aws-nextjs-stream/.gitignore +++ /dev/null @@ -1,42 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js -.yarn/install-state.gz - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env*.local - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts - -# sst -.sst - -# open-next -.open-next diff --git a/examples/aws-nextjs-stream/app/favicon.ico b/examples/aws-nextjs-stream/app/favicon.ico deleted file mode 100644 index 718d6fea48..0000000000 Binary files a/examples/aws-nextjs-stream/app/favicon.ico and /dev/null differ diff --git a/examples/aws-nextjs-stream/app/fonts/GeistMonoVF.woff b/examples/aws-nextjs-stream/app/fonts/GeistMonoVF.woff deleted file mode 100644 index f2ae185cbf..0000000000 Binary files a/examples/aws-nextjs-stream/app/fonts/GeistMonoVF.woff and /dev/null differ diff --git a/examples/aws-nextjs-stream/app/fonts/GeistVF.woff b/examples/aws-nextjs-stream/app/fonts/GeistVF.woff deleted file mode 100644 index 1b62daacff..0000000000 Binary files a/examples/aws-nextjs-stream/app/fonts/GeistVF.woff and /dev/null differ diff --git a/examples/aws-nextjs-stream/app/globals.css b/examples/aws-nextjs-stream/app/globals.css deleted file mode 100644 index 8f2485f332..0000000000 --- a/examples/aws-nextjs-stream/app/globals.css +++ /dev/null @@ -1,8 +0,0 @@ -body { - font-family: Arial, sans-serif; - margin: 0; - padding: 0; - background-color: #f0f8ff; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} diff --git a/examples/aws-nextjs-stream/app/layout.tsx b/examples/aws-nextjs-stream/app/layout.tsx deleted file mode 100644 index dca06aee77..0000000000 --- a/examples/aws-nextjs-stream/app/layout.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import type { Metadata } from "next"; -import localFont from "next/font/local"; -import "./globals.css"; - -const geistSans = localFont({ - src: "./fonts/GeistVF.woff", - variable: "--font-geist-sans", - weight: "100 900", -}); -const geistMono = localFont({ - src: "./fonts/GeistMonoVF.woff", - variable: "--font-geist-mono", - weight: "100 900", -}); - -export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", -}; - -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { - return ( - - - {children} - - - ); -} diff --git a/examples/aws-nextjs-stream/app/page.module.css b/examples/aws-nextjs-stream/app/page.module.css deleted file mode 100644 index 579a1e6288..0000000000 --- a/examples/aws-nextjs-stream/app/page.module.css +++ /dev/null @@ -1,5 +0,0 @@ -.container { - max-width: 800px; - margin: 0 auto; - padding: 20px; -} diff --git a/examples/aws-nextjs-stream/app/page.tsx b/examples/aws-nextjs-stream/app/page.tsx deleted file mode 100644 index 00597dbc40..0000000000 --- a/examples/aws-nextjs-stream/app/page.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { Suspense } from "react"; -import Bio from "@/components/bio"; -import Friends from "@/components/friends"; -import styles from "./page.module.css"; - -export const dynamic = "force-dynamic"; - -export default async function Home() { - return ( -
- - -
-

Friends from Bikini Bottom

- Loading...
}> - - - - - ); -} diff --git a/examples/aws-nextjs-stream/components/bio.module.css b/examples/aws-nextjs-stream/components/bio.module.css deleted file mode 100644 index e07167d438..0000000000 --- a/examples/aws-nextjs-stream/components/bio.module.css +++ /dev/null @@ -1,15 +0,0 @@ -.section { - background-color: #fff; - padding: 20px; - margin-bottom: 20px; - border-radius: 10px; -} -.content { - display: flex; - align-items: center; -} -.text { - flex: 1; - padding-right: 20px; -} - diff --git a/examples/aws-nextjs-stream/components/bio.tsx b/examples/aws-nextjs-stream/components/bio.tsx deleted file mode 100644 index 8c116ce0f7..0000000000 --- a/examples/aws-nextjs-stream/components/bio.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import styles from "./bio.module.css"; - -const spongebob = { - name: "SpongeBob SquarePants", - description: "SpongeBob SquarePants is the main character of the popular animated TV series. He's a cheerful sea sponge who lives in a pineapple house in the underwater city of Bikini Bottom. SpongeBob works as a fry cook at the Krusty Krab and loves jellyfishing with his best friend Patrick Star.", - image: "spongebob.png", -}; - -export default function Bio({ }) { - return ( -
-

{spongebob.name}

-
-
-

{spongebob.description}

-
- {spongebob.name} -
-
- ); -} diff --git a/examples/aws-nextjs-stream/components/friends.module.css b/examples/aws-nextjs-stream/components/friends.module.css deleted file mode 100644 index c04d006655..0000000000 --- a/examples/aws-nextjs-stream/components/friends.module.css +++ /dev/null @@ -1,16 +0,0 @@ -.grid { - display: grid; - grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); - gap: 20px; -} -.card { - background-color: #fff; - padding: 10px; - border-radius: 5px; - text-align: center; -} -.img { - max-width: 100%; - height: auto; - border-radius: 5px; -} diff --git a/examples/aws-nextjs-stream/components/friends.tsx b/examples/aws-nextjs-stream/components/friends.tsx deleted file mode 100644 index ee01bd962c..0000000000 --- a/examples/aws-nextjs-stream/components/friends.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import styles from "./friends.module.css"; - -interface Character { - name: string; - image: string; -} - -function friendsPromise() { - return new Promise((resolve) => { - setTimeout(() => { - resolve( - [ - { name: "Patrick Star", image: "patrick.png" }, - { name: "Sandy Cheeks", image: "sandy.png" }, - { name: "Squidward Tentacles", image: "squidward.png" }, - { name: "Mr. Krabs", image: "mr-krabs.png" }, - ] - ); - }, 3000); - }); -} - -export default async function Friends() { - const friends = await friendsPromise() as Character[]; - - return ( -
- {friends.map((friend) => ( -
- {friend.name} -

{friend.name}

-
- ))} -
- ); -} diff --git a/examples/aws-nextjs-stream/next.config.mjs b/examples/aws-nextjs-stream/next.config.mjs deleted file mode 100644 index 4678774e6d..0000000000 --- a/examples/aws-nextjs-stream/next.config.mjs +++ /dev/null @@ -1,4 +0,0 @@ -/** @type {import('next').NextConfig} */ -const nextConfig = {}; - -export default nextConfig; diff --git a/examples/aws-nextjs-stream/open-next.config.ts b/examples/aws-nextjs-stream/open-next.config.ts deleted file mode 100644 index 15aa84d402..0000000000 --- a/examples/aws-nextjs-stream/open-next.config.ts +++ /dev/null @@ -1,9 +0,0 @@ -const config = { - default: { - override: { - wrapper: "aws-lambda-streaming", - }, - }, -}; - -export default config; diff --git a/examples/aws-nextjs-stream/package.json b/examples/aws-nextjs-stream/package.json deleted file mode 100644 index 324de7960c..0000000000 --- a/examples/aws-nextjs-stream/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "aws-nextjs-stream", - "version": "0.1.0", - "private": true, - "scripts": { - "build": "next build", - "dev": "next dev", - "lint": "next lint", - "start": "next start" - }, - "dependencies": { - "next": "14.2.12", - "react": "^18", - "react-dom": "^18", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/node": "^20", - "@types/react": "^18", - "@types/react-dom": "^18", - "typescript": "^5" - } -} diff --git a/examples/aws-nextjs-stream/public/mr-krabs.png b/examples/aws-nextjs-stream/public/mr-krabs.png deleted file mode 100644 index e94ea64054..0000000000 Binary files a/examples/aws-nextjs-stream/public/mr-krabs.png and /dev/null differ diff --git a/examples/aws-nextjs-stream/public/patrick.png b/examples/aws-nextjs-stream/public/patrick.png deleted file mode 100644 index 030eaaf8a3..0000000000 Binary files a/examples/aws-nextjs-stream/public/patrick.png and /dev/null differ diff --git a/examples/aws-nextjs-stream/public/sandy.png b/examples/aws-nextjs-stream/public/sandy.png deleted file mode 100644 index eb7a9cc324..0000000000 Binary files a/examples/aws-nextjs-stream/public/sandy.png and /dev/null differ diff --git a/examples/aws-nextjs-stream/public/spongebob.png b/examples/aws-nextjs-stream/public/spongebob.png deleted file mode 100644 index 18f7df537e..0000000000 Binary files a/examples/aws-nextjs-stream/public/spongebob.png and /dev/null differ diff --git a/examples/aws-nextjs-stream/public/squidward.png b/examples/aws-nextjs-stream/public/squidward.png deleted file mode 100644 index 4af85e000b..0000000000 Binary files a/examples/aws-nextjs-stream/public/squidward.png and /dev/null differ diff --git a/examples/aws-nextjs-stream/sst.config.ts b/examples/aws-nextjs-stream/sst.config.ts deleted file mode 100644 index 866bda8298..0000000000 --- a/examples/aws-nextjs-stream/sst.config.ts +++ /dev/null @@ -1,53 +0,0 @@ -/// - -/** - * ## AWS Next.js streaming - * - * An example of how to use streaming Next.js RSC. Uses `Suspense` to stream an async component. - * - * ```tsx title="app/page.tsx" - * Loading...}> - * - * - * ``` - * - * For this demo we also need to make sure the route is not statically built. - * - * ```ts title="app/page.tsx" - * export const dynamic = "force-dynamic"; - * ``` - * - * This is deployed with OpenNext, which needs a config to enable streaming. - * - * ```ts title="open-next.config.ts" {4} - * export default { - * default: { - * override: { - * wrapper: "aws-lambda-streaming" - * } - * } - * }; - * ``` - * - * You should see the _friends_ section load after a 3 second delay. - * - * :::note - * Safari handles streaming differently than other browsers. - * ::: - * - * Safari uses a [different heuristic](https://bugs.webkit.org/show_bug.cgi?id=252413) to - * determine when to stream data. You need to render _enough_ initial HTML to trigger streaming. - * This is typically only a problem for demo apps. - */ -export default $config({ - app(input) { - return { - name: "aws-nextjs-stream", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - new sst.aws.Nextjs("MyWeb"); - }, -}); diff --git a/examples/aws-nextjs-stream/tsconfig.json b/examples/aws-nextjs-stream/tsconfig.json deleted file mode 100644 index 56433afeb2..0000000000 --- a/examples/aws-nextjs-stream/tsconfig.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "compilerOptions": { - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, - "plugins": [ - { - "name": "next" - } - ], - "paths": { - "@/*": ["./*"] - } - }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules","sst.config.ts"] -} diff --git a/examples/aws-nextjs/.gitignore b/examples/aws-nextjs/.gitignore deleted file mode 100644 index 69d7f97469..0000000000 --- a/examples/aws-nextjs/.gitignore +++ /dev/null @@ -1,42 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js -.yarn/install-state.gz - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env*.local - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts - -# sst -.sst - -# open-next -.open-next diff --git a/examples/aws-nextjs/app/favicon.ico b/examples/aws-nextjs/app/favicon.ico deleted file mode 100644 index 718d6fea48..0000000000 Binary files a/examples/aws-nextjs/app/favicon.ico and /dev/null differ diff --git a/examples/aws-nextjs/app/fonts/GeistMonoVF.woff b/examples/aws-nextjs/app/fonts/GeistMonoVF.woff deleted file mode 100644 index f2ae185cbf..0000000000 Binary files a/examples/aws-nextjs/app/fonts/GeistMonoVF.woff and /dev/null differ diff --git a/examples/aws-nextjs/app/fonts/GeistVF.woff b/examples/aws-nextjs/app/fonts/GeistVF.woff deleted file mode 100644 index 1b62daacff..0000000000 Binary files a/examples/aws-nextjs/app/fonts/GeistVF.woff and /dev/null differ diff --git a/examples/aws-nextjs/app/globals.css b/examples/aws-nextjs/app/globals.css deleted file mode 100644 index e3734be15e..0000000000 --- a/examples/aws-nextjs/app/globals.css +++ /dev/null @@ -1,42 +0,0 @@ -:root { - --background: #ffffff; - --foreground: #171717; -} - -@media (prefers-color-scheme: dark) { - :root { - --background: #0a0a0a; - --foreground: #ededed; - } -} - -html, -body { - max-width: 100vw; - overflow-x: hidden; -} - -body { - color: var(--foreground); - background: var(--background); - font-family: Arial, Helvetica, sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -* { - box-sizing: border-box; - padding: 0; - margin: 0; -} - -a { - color: inherit; - text-decoration: none; -} - -@media (prefers-color-scheme: dark) { - html { - color-scheme: dark; - } -} diff --git a/examples/aws-nextjs/app/layout.tsx b/examples/aws-nextjs/app/layout.tsx deleted file mode 100644 index dca06aee77..0000000000 --- a/examples/aws-nextjs/app/layout.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import type { Metadata } from "next"; -import localFont from "next/font/local"; -import "./globals.css"; - -const geistSans = localFont({ - src: "./fonts/GeistVF.woff", - variable: "--font-geist-sans", - weight: "100 900", -}); -const geistMono = localFont({ - src: "./fonts/GeistMonoVF.woff", - variable: "--font-geist-mono", - weight: "100 900", -}); - -export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", -}; - -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { - return ( - - - {children} - - - ); -} diff --git a/examples/aws-nextjs/app/page.module.css b/examples/aws-nextjs/app/page.module.css deleted file mode 100644 index 8a460419f9..0000000000 --- a/examples/aws-nextjs/app/page.module.css +++ /dev/null @@ -1,165 +0,0 @@ -.page { - --gray-rgb: 0, 0, 0; - --gray-alpha-200: rgba(var(--gray-rgb), 0.08); - --gray-alpha-100: rgba(var(--gray-rgb), 0.05); - - --button-primary-hover: #383838; - --button-secondary-hover: #f2f2f2; - - display: grid; - grid-template-rows: 20px 1fr 20px; - align-items: center; - justify-items: center; - min-height: 100svh; - padding: 80px; - gap: 64px; - font-family: var(--font-geist-sans); -} - -@media (prefers-color-scheme: dark) { - .page { - --gray-rgb: 255, 255, 255; - --gray-alpha-200: rgba(var(--gray-rgb), 0.145); - --gray-alpha-100: rgba(var(--gray-rgb), 0.06); - - --button-primary-hover: #ccc; - --button-secondary-hover: #1a1a1a; - } -} - -.main { - display: flex; - flex-direction: column; - gap: 32px; - grid-row-start: 2; -} - -.main ol { - font-family: var(--font-geist-mono); - padding-left: 0; - margin: 0; - font-size: 14px; - line-height: 24px; - letter-spacing: -0.01em; - list-style-position: inside; -} - -.main li:not(:last-of-type) { - margin-bottom: 8px; -} - -.main code { - font-family: inherit; - background: var(--gray-alpha-100); - padding: 2px 4px; - border-radius: 4px; - font-weight: 600; -} - -.ctas { - display: flex; - gap: 16px; -} - -.ctas a { - appearance: none; - border-radius: 128px; - height: 48px; - padding: 0 20px; - border: none; - border: 1px solid transparent; - transition: background 0.2s, color 0.2s, border-color 0.2s; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - font-size: 16px; - line-height: 20px; - font-weight: 500; -} - -a.primary { - background: var(--foreground); - color: var(--background); - gap: 8px; -} - -a.secondary { - border-color: var(--gray-alpha-200); - min-width: 180px; -} - -.footer { - grid-row-start: 3; - display: flex; - gap: 24px; -} - -.footer a { - display: flex; - align-items: center; - gap: 8px; -} - -.footer img { - flex-shrink: 0; -} - -/* Enable hover only on non-touch devices */ -@media (hover: hover) and (pointer: fine) { - a.primary:hover { - background: var(--button-primary-hover); - border-color: transparent; - } - - a.secondary:hover { - background: var(--button-secondary-hover); - border-color: transparent; - } - - .footer a:hover { - text-decoration: underline; - text-underline-offset: 4px; - } -} - -@media (max-width: 600px) { - .page { - padding: 32px; - padding-bottom: 80px; - } - - .main { - align-items: center; - } - - .main ol { - text-align: center; - } - - .ctas { - flex-direction: column; - } - - .ctas a { - font-size: 14px; - height: 40px; - padding: 0 16px; - } - - a.secondary { - min-width: auto; - } - - .footer { - flex-wrap: wrap; - align-items: center; - justify-content: center; - } -} - -@media (prefers-color-scheme: dark) { - .logo { - filter: invert(); - } -} diff --git a/examples/aws-nextjs/app/page.tsx b/examples/aws-nextjs/app/page.tsx deleted file mode 100644 index a7ce977382..0000000000 --- a/examples/aws-nextjs/app/page.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { Resource } from "sst"; -import Form from "@/components/form"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; -import styles from "./page.module.css"; - -export const dynamic = "force-dynamic"; - -export default async function Home() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return ( -
-
-
-
-
- ); -} diff --git a/examples/aws-nextjs/components/form.module.css b/examples/aws-nextjs/components/form.module.css deleted file mode 100644 index 6a12c9ae58..0000000000 --- a/examples/aws-nextjs/components/form.module.css +++ /dev/null @@ -1,24 +0,0 @@ -.form { - padding: 2rem; - border-radius: 0.5rem; - background-color: var(--gray-alpha-100); -} - -.form input { - margin-right: 1rem; -} - -.form button { - appearance: none; - padding: 0.5rem 0.75rem; - font-weight: 500; - font-size: 0.875rem; - border-radius: 0.375rem; - background-color: transparent; - font-family: var(--font-geist-sans); - border: 1px solid var(--gray-alpha-200); -} - -.form button:active:enabled { - background-color: var(--gray-alpha-200); -} diff --git a/examples/aws-nextjs/components/form.tsx b/examples/aws-nextjs/components/form.tsx deleted file mode 100644 index adaa22afdc..0000000000 --- a/examples/aws-nextjs/components/form.tsx +++ /dev/null @@ -1,30 +0,0 @@ -"use client"; - -import styles from "./form.module.css"; - -export default function Form({ url }: { url: string }) { - return ( - { - e.preventDefault(); - - const file = (e.target as HTMLFormElement).file.files?.[0] ?? null; - - const image = await fetch(url, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }} - > - - - - ); -} diff --git a/examples/aws-nextjs/next.config.mjs b/examples/aws-nextjs/next.config.mjs deleted file mode 100644 index 4678774e6d..0000000000 --- a/examples/aws-nextjs/next.config.mjs +++ /dev/null @@ -1,4 +0,0 @@ -/** @type {import('next').NextConfig} */ -const nextConfig = {}; - -export default nextConfig; diff --git a/examples/aws-nextjs/package.json b/examples/aws-nextjs/package.json deleted file mode 100644 index 5c3a68a25a..0000000000 --- a/examples/aws-nextjs/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "aws-nextjs", - "version": "0.1.0", - "private": true, - "scripts": { - "build": "next build", - "dev": "next dev", - "lint": "next lint", - "start": "next start" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.668.0", - "@aws-sdk/s3-request-presigner": "^3.668.0", - "next": "14.2.15", - "react": "^18", - "react-dom": "^18", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/node": "^20", - "@types/react": "^18", - "@types/react-dom": "^18", - "typescript": "^5" - } -} diff --git a/examples/aws-nextjs/public/next.svg b/examples/aws-nextjs/public/next.svg deleted file mode 100644 index 5174b28c56..0000000000 --- a/examples/aws-nextjs/public/next.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-nextjs/public/vercel.svg b/examples/aws-nextjs/public/vercel.svg deleted file mode 100644 index d2f8422273..0000000000 --- a/examples/aws-nextjs/public/vercel.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-nextjs/sst.config.ts b/examples/aws-nextjs/sst.config.ts deleted file mode 100644 index fd9b633273..0000000000 --- a/examples/aws-nextjs/sst.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-nextjs", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" - }); - new sst.aws.Nextjs("MyWeb", { - link: [bucket] - }); - } -}); diff --git a/examples/aws-nextjs/tsconfig.json b/examples/aws-nextjs/tsconfig.json deleted file mode 100644 index 56433afeb2..0000000000 --- a/examples/aws-nextjs/tsconfig.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "compilerOptions": { - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, - "plugins": [ - { - "name": "next" - } - ], - "paths": { - "@/*": ["./*"] - } - }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules","sst.config.ts"] -} diff --git a/examples/aws-nuxt-container/.dockerignore b/examples/aws-nuxt-container/.dockerignore deleted file mode 100644 index ea0aaeeec9..0000000000 --- a/examples/aws-nuxt-container/.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-nuxt-container/.gitignore b/examples/aws-nuxt-container/.gitignore deleted file mode 100644 index cf7b41ed76..0000000000 --- a/examples/aws-nuxt-container/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ -# Nuxt dev/build outputs -.output -.data -.nuxt -.nitro -.cache -dist - -# Node dependencies -node_modules - -# Logs -logs -*.log - -# Misc -.DS_Store -.fleet -.idea - -# Local env files -.env -.env.* -!.env.example - -# sst -.sst diff --git a/examples/aws-nuxt-container/Dockerfile b/examples/aws-nuxt-container/Dockerfile deleted file mode 100644 index eb842b02d5..0000000000 --- a/examples/aws-nuxt-container/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM node:lts AS base - -WORKDIR /src - -# Build -FROM base as build - -COPY --link package.json package-lock.json ./ -RUN npm install - -COPY --link . . - -RUN npm run build - -# Run -FROM base - -ENV PORT=3000 -ENV NODE_ENV=production - -COPY --from=build /src/.output /src/.output - -CMD [ "node", ".output/server/index.mjs" ] diff --git a/examples/aws-nuxt-container/app.vue b/examples/aws-nuxt-container/app.vue deleted file mode 100644 index 66c4a4c37a..0000000000 --- a/examples/aws-nuxt-container/app.vue +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/examples/aws-nuxt-container/nuxt.config.ts b/examples/aws-nuxt-container/nuxt.config.ts deleted file mode 100644 index 6425fa7cd8..0000000000 --- a/examples/aws-nuxt-container/nuxt.config.ts +++ /dev/null @@ -1,5 +0,0 @@ -// https://nuxt.com/docs/api/configuration/nuxt-config -export default defineNuxtConfig({ - compatibilityDate: '2024-04-03', - devtools: { enabled: true } -}) diff --git a/examples/aws-nuxt-container/package.json b/examples/aws-nuxt-container/package.json deleted file mode 100644 index 962195505a..0000000000 --- a/examples/aws-nuxt-container/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "aws-nuxt-container", - "private": true, - "type": "module", - "scripts": { - "build": "nuxt build", - "dev": "nuxt dev", - "generate": "nuxt generate", - "postinstall": "nuxt prepare", - "preview": "nuxt preview" - }, - "dependencies": { - "ioredis": "^5.4.1", - "nuxt": "^3.13.0", - "sst": "file:../../sdk/js", - "vue": "latest", - "vue-router": "latest" - }, - "overrides": { - "nitropack": "npm:nitropack-nightly@latest" - } -} diff --git a/examples/aws-nuxt-container/public/favicon.ico b/examples/aws-nuxt-container/public/favicon.ico deleted file mode 100644 index 18993ad91c..0000000000 Binary files a/examples/aws-nuxt-container/public/favicon.ico and /dev/null differ diff --git a/examples/aws-nuxt-container/public/robots.txt b/examples/aws-nuxt-container/public/robots.txt deleted file mode 100644 index 8b13789179..0000000000 --- a/examples/aws-nuxt-container/public/robots.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/aws-nuxt-container/server/api/counter.ts b/examples/aws-nuxt-container/server/api/counter.ts deleted file mode 100644 index b46ecd1276..0000000000 --- a/examples/aws-nuxt-container/server/api/counter.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Resource } from "sst"; -import { Cluster } from "ioredis"; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -export default defineEventHandler(async () => { - return await redis.incr("counter"); -}) diff --git a/examples/aws-nuxt-container/server/tsconfig.json b/examples/aws-nuxt-container/server/tsconfig.json deleted file mode 100644 index b9ed69c19e..0000000000 --- a/examples/aws-nuxt-container/server/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../.nuxt/tsconfig.server.json" -} diff --git a/examples/aws-nuxt-container/sst.config.ts b/examples/aws-nuxt-container/sst.config.ts deleted file mode 100644 index ef36277d5d..0000000000 --- a/examples/aws-nuxt-container/sst.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-nuxt-container", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-nuxt-container/tsconfig.json b/examples/aws-nuxt-container/tsconfig.json deleted file mode 100644 index a746f2a70c..0000000000 --- a/examples/aws-nuxt-container/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - // https://nuxt.com/docs/guide/concepts/typescript - "extends": "./.nuxt/tsconfig.json" -} diff --git a/examples/aws-nuxt-stream/.gitignore b/examples/aws-nuxt-stream/.gitignore deleted file mode 100644 index cf7b41ed76..0000000000 --- a/examples/aws-nuxt-stream/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ -# Nuxt dev/build outputs -.output -.data -.nuxt -.nitro -.cache -dist - -# Node dependencies -node_modules - -# Logs -logs -*.log - -# Misc -.DS_Store -.fleet -.idea - -# Local env files -.env -.env.* -!.env.example - -# sst -.sst diff --git a/examples/aws-nuxt-stream/app.vue b/examples/aws-nuxt-stream/app.vue deleted file mode 100644 index c7e6100872..0000000000 --- a/examples/aws-nuxt-stream/app.vue +++ /dev/null @@ -1,30 +0,0 @@ - - - diff --git a/examples/aws-nuxt-stream/nuxt.config.ts b/examples/aws-nuxt-stream/nuxt.config.ts deleted file mode 100644 index c67efbbe32..0000000000 --- a/examples/aws-nuxt-stream/nuxt.config.ts +++ /dev/null @@ -1,12 +0,0 @@ -// https://nuxt.com/docs/api/configuration/nuxt-config -export default defineNuxtConfig({ - ignore: ['**/.sst/**'], - compatibilityDate: '2025-05-15', - nitro: { - preset: 'aws-lambda', - awsLambda: { - streaming: true - } - }, - devtools: { enabled: true } -}) diff --git a/examples/aws-nuxt-stream/package.json b/examples/aws-nuxt-stream/package.json deleted file mode 100644 index 34569ea7a4..0000000000 --- a/examples/aws-nuxt-stream/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "nuxt-app", - "private": true, - "type": "module", - "scripts": { - "build": "nuxt build", - "dev": "nuxt dev", - "generate": "nuxt generate", - "postinstall": "nuxt prepare", - "preview": "nuxt preview" - }, - "dependencies": { - "nuxt": "^3.15.5", - "sst": "file:../../sdk/js", - "vue": "latest", - "vue-router": "latest" - } -} diff --git a/examples/aws-nuxt-stream/public/favicon.ico b/examples/aws-nuxt-stream/public/favicon.ico deleted file mode 100644 index 18993ad91c..0000000000 Binary files a/examples/aws-nuxt-stream/public/favicon.ico and /dev/null differ diff --git a/examples/aws-nuxt-stream/public/robots.txt b/examples/aws-nuxt-stream/public/robots.txt deleted file mode 100644 index 8b13789179..0000000000 --- a/examples/aws-nuxt-stream/public/robots.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/aws-nuxt-stream/server/api/streaming.ts b/examples/aws-nuxt-stream/server/api/streaming.ts deleted file mode 100644 index d237103432..0000000000 --- a/examples/aws-nuxt-stream/server/api/streaming.ts +++ /dev/null @@ -1,20 +0,0 @@ -export default defineEventHandler(async (event) => { - const eventStream = createEventStream(event); - - eventStream.push("Start\n\n"); - - const interval = setInterval(async () => { - await eventStream.push(`Random: ${Math.random().toFixed(5)} `); - }, 1000); - - setTimeout(async () => { - clearInterval(interval); - await eventStream.close(); - }, 10000); - - eventStream.onClosed(() => { - clearInterval(interval); - }); - - return eventStream.send(); -}) diff --git a/examples/aws-nuxt-stream/server/tsconfig.json b/examples/aws-nuxt-stream/server/tsconfig.json deleted file mode 100644 index b9ed69c19e..0000000000 --- a/examples/aws-nuxt-stream/server/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../.nuxt/tsconfig.server.json" -} diff --git a/examples/aws-nuxt-stream/sst.config.ts b/examples/aws-nuxt-stream/sst.config.ts deleted file mode 100644 index cb1615d890..0000000000 --- a/examples/aws-nuxt-stream/sst.config.ts +++ /dev/null @@ -1,86 +0,0 @@ -/// - -/** - * ## AWS Nuxt streaming - * - * An example of how to use streaming with Nuxt.js. Uses `createEventStream` to stream data from a server API. - * - * ```ts title="server/api/streaming.ts" - * export default defineEventHandler(async (event) => { - * const eventStream = createEventStream(event); - * eventStream.push("Start\n\n"); - * - * // Send a message every second - * const interval = setInterval(async () => { - * await eventStream.push(`Random: ${Math.random().toFixed(5)} `); - * }, 1000); - * } - * ``` - * - * The client uses the Fetch API to consume the stream. - * - * ```vue title="app.vue" - * - * - * - * ``` - * - * Make sure to have your nuxt.config.ts set up to handle the streaming API correctly. - * - * ```ts title="nuxt.config.ts" {4-6} - * export default defineNuxtConfig({ - * nitro: { - * preset: 'aws-lambda', - * awsLambda: { - * streaming: true - * } - * } - * }); - * ``` - * - * You should see random numbers streamed to the page every second for 10 seconds. - * - * :::note - * Safari handles streaming differently than other browsers. - * ::: - * - * Safari uses a [different heuristic](https://bugs.webkit.org/show_bug.cgi?id=252413) to - * determine when to stream data. You need to render _enough_ initial HTML to trigger streaming. - * This is typically only a problem for demo apps. - */ -export default $config({ - app(input) { - return { - name: "aws-nuxt-stream", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - new sst.aws.Nuxt("MyWeb"); - }, -}); diff --git a/examples/aws-nuxt-stream/tsconfig.json b/examples/aws-nuxt-stream/tsconfig.json deleted file mode 100644 index a746f2a70c..0000000000 --- a/examples/aws-nuxt-stream/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - // https://nuxt.com/docs/guide/concepts/typescript - "extends": "./.nuxt/tsconfig.json" -} diff --git a/examples/aws-nuxt/.gitignore b/examples/aws-nuxt/.gitignore deleted file mode 100644 index cf7b41ed76..0000000000 --- a/examples/aws-nuxt/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ -# Nuxt dev/build outputs -.output -.data -.nuxt -.nitro -.cache -dist - -# Node dependencies -node_modules - -# Logs -logs -*.log - -# Misc -.DS_Store -.fleet -.idea - -# Local env files -.env -.env.* -!.env.example - -# sst -.sst diff --git a/examples/aws-nuxt/app.vue b/examples/aws-nuxt/app.vue deleted file mode 100644 index 5947ef77d1..0000000000 --- a/examples/aws-nuxt/app.vue +++ /dev/null @@ -1,24 +0,0 @@ - - diff --git a/examples/aws-nuxt/nuxt.config.ts b/examples/aws-nuxt/nuxt.config.ts deleted file mode 100644 index f4c5faca38..0000000000 --- a/examples/aws-nuxt/nuxt.config.ts +++ /dev/null @@ -1,8 +0,0 @@ -// https://nuxt.com/docs/api/configuration/nuxt-config -export default defineNuxtConfig({ - compatibilityDate: '2024-04-03', - nitro: { - preset: 'aws-lambda' - }, - devtools: { enabled: true } -}) diff --git a/examples/aws-nuxt/package.json b/examples/aws-nuxt/package.json deleted file mode 100644 index 2001ffcfb3..0000000000 --- a/examples/aws-nuxt/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "aws-nuxt", - "private": true, - "type": "module", - "scripts": { - "build": "nuxt build", - "dev": "nuxt dev", - "generate": "nuxt generate", - "postinstall": "nuxt prepare", - "preview": "nuxt preview" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.651.1", - "@aws-sdk/s3-request-presigner": "^3.651.1", - "nuxt": "^3.13.0", - "sst": "file:../../sdk/js", - "vue": "latest", - "vue-router": "latest" - } -} diff --git a/examples/aws-nuxt/public/favicon.ico b/examples/aws-nuxt/public/favicon.ico deleted file mode 100644 index 18993ad91c..0000000000 Binary files a/examples/aws-nuxt/public/favicon.ico and /dev/null differ diff --git a/examples/aws-nuxt/public/robots.txt b/examples/aws-nuxt/public/robots.txt deleted file mode 100644 index 8b13789179..0000000000 --- a/examples/aws-nuxt/public/robots.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/aws-nuxt/server/api/presigned.ts b/examples/aws-nuxt/server/api/presigned.ts deleted file mode 100644 index b8c29a2e5b..0000000000 --- a/examples/aws-nuxt/server/api/presigned.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -export default defineEventHandler(async () => { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - - return await getSignedUrl(new S3Client({}), command); -}) diff --git a/examples/aws-nuxt/server/tsconfig.json b/examples/aws-nuxt/server/tsconfig.json deleted file mode 100644 index b9ed69c19e..0000000000 --- a/examples/aws-nuxt/server/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../.nuxt/tsconfig.server.json" -} diff --git a/examples/aws-nuxt/sst.config.ts b/examples/aws-nuxt/sst.config.ts deleted file mode 100644 index 462d330512..0000000000 --- a/examples/aws-nuxt/sst.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-nuxt", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public", - }); - new sst.aws.Nuxt("MyWeb", { - link: [bucket], - }); - }, -}); diff --git a/examples/aws-nuxt/tsconfig.json b/examples/aws-nuxt/tsconfig.json deleted file mode 100644 index a746f2a70c..0000000000 --- a/examples/aws-nuxt/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - // https://nuxt.com/docs/guide/concepts/typescript - "extends": "./.nuxt/tsconfig.json" -} diff --git a/examples/aws-open-search-local/.gitignore b/examples/aws-open-search-local/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-open-search-local/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-open-search-local/index.ts b/examples/aws-open-search-local/index.ts deleted file mode 100644 index a31d07708e..0000000000 --- a/examples/aws-open-search-local/index.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Resource } from "sst"; -import { Client } from "@opensearch-project/opensearch"; - -const client = new Client({ - node: Resource.MySearch.url, - auth: { - username: Resource.MySearch.username, - password: Resource.MySearch.password, - }, -}); - -export async function handler() { - // Add a document - await client.index({ - index: "my-index", - body: { message: "Hello world!" }, - }); - - // Search for documents - const result = await client.search({ - index: "my-index", - body: { query: { match: { message: "world" } } }, - }); - - return { - statusCode: 200, - body: - `Querying ${Resource.MySearch.url}\n\n` + - JSON.stringify(result.body.hits, null, 2), - }; -} diff --git a/examples/aws-open-search-local/package.json b/examples/aws-open-search-local/package.json deleted file mode 100644 index 599559797b..0000000000 --- a/examples/aws-open-search-local/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-open-search-local", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@opensearch-project/opensearch": "^3.5.1", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145" - } -} diff --git a/examples/aws-open-search-local/sst.config.ts b/examples/aws-open-search-local/sst.config.ts deleted file mode 100644 index 19429f8814..0000000000 --- a/examples/aws-open-search-local/sst.config.ts +++ /dev/null @@ -1,79 +0,0 @@ -/// - -/** - * ## AWS OpenSearch local - * - * In this example, we connect to a locally running OpenSearch process for dev. While - * on deploy, we use AWS' OpenSearch Service. - * - * We use the [`docker run`](https://docs.docker.com/reference/cli/docker/container/run/) - * CLI to start a local container with OpenSearch. You don't have to use Docker, you can use - * any other way to run OpenSearch locally. - * - * ```bash - * docker run \ - * --rm \ - * -p 9200:9200 \ - * -v $(pwd)/.sst/storage/opensearch:/usr/share/opensearch/data \ - * -e discovery.type=single-node \ - * -e plugins.security.disabled=true \ - * -e OPENSEARCH_INITIAL_ADMIN_PASSWORD=^Passw0rd^ \ - * opensearchproject/opensearch:2.17.0 - * ``` - * - * The data is saved to the `.sst/storage` directory. So if you restart the dev server, the - * data will still be there. - * - * We then configure the `dev` property of the `OpenSearch` component with the settings for - * the local OpenSearch instance. - * - * ```ts title="sst.config.ts" - * dev: { - * url: "http://localhost:9200", - * username: "admin", - * password: "^Passw0rd^" - * } - * ``` - * - * By providing the `dev` prop for OpenSearch, SST will use the local OpenSearch process and - * not deploy a new OpenSearch domain when running `sst dev`. - * - * It also allows us to access the local process through a Resource `link` without having - * to conditionally check if we are running locally. - * - * ```ts title="index.ts" - * const client = new Client({ - * node: Resource.MySearch.url, - * auth: { - * username: Resource.MySearch.username, - * password: Resource.MySearch.password, - * }, - * }); - * ``` - * - * The above will work in both `sst dev` and `sst deploy`. - */ -export default $config({ - app(input) { - return { - name: "aws-open-search-local", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const search = new sst.aws.OpenSearch("MySearch", { - dev: { - url: "http://localhost:9200", - username: "admin", - password: "^Passw0rd^", - }, - }); - - new sst.aws.Function("MyApp", { - handler: "index.handler", - url: true, - link: [search], - }); - }, -}); diff --git a/examples/aws-open-search-local/tsconfig.json b/examples/aws-open-search-local/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-open-search-local/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-open-search/index.ts b/examples/aws-open-search/index.ts deleted file mode 100644 index a31d07708e..0000000000 --- a/examples/aws-open-search/index.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Resource } from "sst"; -import { Client } from "@opensearch-project/opensearch"; - -const client = new Client({ - node: Resource.MySearch.url, - auth: { - username: Resource.MySearch.username, - password: Resource.MySearch.password, - }, -}); - -export async function handler() { - // Add a document - await client.index({ - index: "my-index", - body: { message: "Hello world!" }, - }); - - // Search for documents - const result = await client.search({ - index: "my-index", - body: { query: { match: { message: "world" } } }, - }); - - return { - statusCode: 200, - body: - `Querying ${Resource.MySearch.url}\n\n` + - JSON.stringify(result.body.hits, null, 2), - }; -} diff --git a/examples/aws-open-search/package.json b/examples/aws-open-search/package.json deleted file mode 100644 index 8776398850..0000000000 --- a/examples/aws-open-search/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-open-search", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "@opensearch-project/opensearch": "^3.5.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-open-search/sst.config.ts b/examples/aws-open-search/sst.config.ts deleted file mode 100644 index 009e1491fb..0000000000 --- a/examples/aws-open-search/sst.config.ts +++ /dev/null @@ -1,55 +0,0 @@ -/// - -/** - * ## AWS OpenSearch - * - * In this example we create a new OpenSearch domain, link it to a function, and - * then query it. - * - * Start by creating a new OpenSearch domain. - * - * ```ts title="sst.config.ts" - * const search = new sst.aws.OpenSearch("MySearch"); - * ``` - * - * Once linked to a function, we can connect to it. - * - * ```ts title="index.ts" - * import { Resource } from "sst"; - * import { Client } from "@opensearch-project/opensearch"; - * - * const client = new Client({ - * node: Resource.MySearch.url, - * auth: { - * username: Resource.MySearch.username, - * password: Resource.MySearch.password - * } - * }); - * ``` - * - * This is using the [OpenSearch JS SDK](https://docs.opensearch.org/docs/latest/clients/javascript/index) to connect to the OpenSearch domain.. - */ -export default $config({ - app(input) { - return { - name: "aws-open-search", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const search = new sst.aws.OpenSearch("MySearch"); - const app = new sst.aws.Function("MyApp", { - handler: "index.handler", - url: true, - link: [search], - }); - - return { - app: app.url, - url: search.url, - username: search.username, - password: search.password, - }; - }, -}); diff --git a/examples/aws-planetscale-drizzle-mysql/.gitignore b/examples/aws-planetscale-drizzle-mysql/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-planetscale-drizzle-mysql/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-planetscale-drizzle-mysql/drizzle.config.ts b/examples/aws-planetscale-drizzle-mysql/drizzle.config.ts deleted file mode 100644 index 1fd6c1a4d3..0000000000 --- a/examples/aws-planetscale-drizzle-mysql/drizzle.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { defineConfig } from "drizzle-kit"; -import { Resource } from "sst"; - -export default defineConfig({ - dialect: "mysql", - dbCredentials: { - url: `mysql://${Resource.Database.username}:${Resource.Database.password}@${Resource.Database.host}/${Resource.Database.database}?ssl={"rejectUnauthorized":true}`, - }, - schema: ["./src/schema.ts"], -}); diff --git a/examples/aws-planetscale-drizzle-mysql/package.json b/examples/aws-planetscale-drizzle-mysql/package.json deleted file mode 100644 index 760c01bdce..0000000000 --- a/examples/aws-planetscale-drizzle-mysql/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-planetscale-drizzle-mysql", - "version": "0.0.0", - "scripts": { - "db": "sst shell drizzle-kit", - "db:push": "sst shell drizzle-kit push", - "db:studio": "sst shell drizzle-kit studio" - }, - "dependencies": { - "@planetscale/database": "^1.19.0", - "drizzle-kit": "^0.31.10", - "drizzle-orm": "^0.45.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-planetscale-drizzle-mysql/src/api.ts b/examples/aws-planetscale-drizzle-mysql/src/api.ts deleted file mode 100644 index 025826383a..0000000000 --- a/examples/aws-planetscale-drizzle-mysql/src/api.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { db } from "./drizzle"; -import { todosTable } from "./schema"; -import { APIGatewayProxyHandlerV2 } from "aws-lambda"; - -export const handler: APIGatewayProxyHandlerV2 = async (evt) => { - if (evt.requestContext.http.method === "GET") { - const result = await db.select().from(todosTable).execute(); - return { - statusCode: 200, - body: JSON.stringify(result), - }; - } - - if (evt.requestContext.http.method === "POST") { - await db.insert(todosTable).values({ title: "new todosTable" }).execute(); - return { - statusCode: 200, - body: "created", - }; - } - - return { - statusCode: 404, - body: "not found", - }; -}; diff --git a/examples/aws-planetscale-drizzle-mysql/src/drizzle.ts b/examples/aws-planetscale-drizzle-mysql/src/drizzle.ts deleted file mode 100644 index bd89904058..0000000000 --- a/examples/aws-planetscale-drizzle-mysql/src/drizzle.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { drizzle } from "drizzle-orm/planetscale-serverless"; -import { Resource } from "sst"; - -export const db = drizzle({ - connection: { - host: Resource.Database.host, - username: Resource.Database.username, - password: Resource.Database.password, - }, -}); diff --git a/examples/aws-planetscale-drizzle-mysql/src/schema.ts b/examples/aws-planetscale-drizzle-mysql/src/schema.ts deleted file mode 100644 index d987a283ee..0000000000 --- a/examples/aws-planetscale-drizzle-mysql/src/schema.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { mysqlTable, int, text, varchar } from "drizzle-orm/mysql-core"; - -export const todosTable = mysqlTable("todo", { - id: int("id").primaryKey().autoincrement(), - title: varchar("title", { length: 255 }).notNull(), - description: text("description"), -}); diff --git a/examples/aws-planetscale-drizzle-mysql/sst.config.ts b/examples/aws-planetscale-drizzle-mysql/sst.config.ts deleted file mode 100644 index 1778249823..0000000000 --- a/examples/aws-planetscale-drizzle-mysql/sst.config.ts +++ /dev/null @@ -1,122 +0,0 @@ -/// - -/** - * ## AWS PlanetScale Drizzle MySQL - * - * In this example, we use PlanetScale with a branch-per-stage pattern. Every stage gets its own - * database branch — so each PR can have an isolated database. - * - * ```ts title="sst.config.ts" - * const db = planetscale.getDatabaseVitessOutput({ - * id: "mydb", - * organization: "myorg", - * }); - * - * const branch = - * $app.stage === "production" - * ? planetscale.getVitessBranchOutput({ - * id: db.defaultBranch, - * organization: db.organization, - * database: db.name, - * }) - * : new planetscale.VitessBranch("DatabaseBranch", { - * database: db.name, - * organization: db.organization, - * name: $app.stage, - * parentBranch: db.defaultBranch, - * }); - * ``` - * - * We then create a password and wrap it in a `Linkable` to link it to a function. - * - * ```ts title="sst.config.ts" {3} - * new sst.aws.Function("Api", { - * handler: "src/api.handler", - * link: [database], - * url: true, - * }); - * ``` - * - * You can push your Drizzle schema changes to PlanetScale with: - * - * ```bash - * bun run db:push - * ``` - * - * In the function we use [Drizzle ORM](https://orm.drizzle.team) with the - * [`Resource`](/docs/reference/sdk/#resource) helper. - * - * ```ts title="src/drizzle.ts" - * import { drizzle } from "drizzle-orm/planetscale-serverless"; - * import { Resource } from "sst"; - * - * export const db = drizzle({ - * connection: { - * host: Resource.Database.host, - * username: Resource.Database.username, - * password: Resource.Database.password, - * }, - * }); - * ``` - * - */ -export default $config({ - app(input) { - return { - name: "aws-planetscale-drizzle-mysql", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - providers: { - planetscale: "1.0.0", - }, - }; - }, - async run() { - const db = planetscale.getDatabaseVitessOutput({ - id: "example", - organization: "vimtor", - }); - - const branch = - $app.stage === "production" - ? planetscale.getVitessBranchOutput({ - id: db.defaultBranch, - organization: db.organization, - database: db.name, - }) - : new planetscale.VitessBranch("DatabaseBranch", { - database: db.name, - organization: db.organization, - name: $app.stage, - parentBranch: db.defaultBranch, - }); - - const password = new planetscale.VitessBranchPassword("DatabasePassword", { - database: db.name, - organization: db.organization, - branch: branch.name, - role: "admin", - name: `${$app.name}-${$app.stage}`, - }); - - const database = new sst.Linkable("Database", { - properties: { - host: password.accessHostUrl, - username: password.username, - password: password.plainText, - database: db.name, - port: 3306, - }, - }); - - const api = new sst.aws.Function("Api", { - handler: "src/api.handler", - link: [database], - url: true, - }); - - return { - url: api.url, - }; - }, -}); diff --git a/examples/aws-planetscale-drizzle-mysql/tsconfig.json b/examples/aws-planetscale-drizzle-mysql/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-planetscale-drizzle-mysql/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-planetscale-drizzle-postgres/.gitignore b/examples/aws-planetscale-drizzle-postgres/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-planetscale-drizzle-postgres/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-planetscale-drizzle-postgres/drizzle.config.ts b/examples/aws-planetscale-drizzle-postgres/drizzle.config.ts deleted file mode 100644 index 03f4e900e9..0000000000 --- a/examples/aws-planetscale-drizzle-postgres/drizzle.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { defineConfig } from "drizzle-kit"; -import { Resource } from "sst"; - -export default defineConfig({ - dialect: "postgresql", - dbCredentials: { - url: `postgresql://${Resource.Database.username}:${Resource.Database.password}@${Resource.Database.host}/${Resource.Database.database}?sslmode=require`, - }, - schema: ["./src/schema.ts"], -}); diff --git a/examples/aws-planetscale-drizzle-postgres/package.json b/examples/aws-planetscale-drizzle-postgres/package.json deleted file mode 100644 index 8c4f0ecd74..0000000000 --- a/examples/aws-planetscale-drizzle-postgres/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-planetscale-drizzle-postgres", - "version": "0.0.0", - "scripts": { - "db": "sst shell drizzle-kit", - "db:push": "sst shell drizzle-kit push", - "db:studio": "sst shell drizzle-kit studio" - }, - "dependencies": { - "@neondatabase/serverless": "^1.0.2", - "drizzle-kit": "^0.31.10", - "drizzle-orm": "^0.45.1", - "postgres": "^3.4.5", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-planetscale-drizzle-postgres/src/api.ts b/examples/aws-planetscale-drizzle-postgres/src/api.ts deleted file mode 100644 index 025826383a..0000000000 --- a/examples/aws-planetscale-drizzle-postgres/src/api.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { db } from "./drizzle"; -import { todosTable } from "./schema"; -import { APIGatewayProxyHandlerV2 } from "aws-lambda"; - -export const handler: APIGatewayProxyHandlerV2 = async (evt) => { - if (evt.requestContext.http.method === "GET") { - const result = await db.select().from(todosTable).execute(); - return { - statusCode: 200, - body: JSON.stringify(result), - }; - } - - if (evt.requestContext.http.method === "POST") { - await db.insert(todosTable).values({ title: "new todosTable" }).execute(); - return { - statusCode: 200, - body: "created", - }; - } - - return { - statusCode: 404, - body: "not found", - }; -}; diff --git a/examples/aws-planetscale-drizzle-postgres/src/drizzle.ts b/examples/aws-planetscale-drizzle-postgres/src/drizzle.ts deleted file mode 100644 index a521bdc43f..0000000000 --- a/examples/aws-planetscale-drizzle-postgres/src/drizzle.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Resource } from "sst"; -import { neon, neonConfig } from "@neondatabase/serverless"; -import { drizzle } from "drizzle-orm/neon-http"; - -// Required for PlanetScale Postgres connections -neonConfig.fetchEndpoint = (host) => `https://${host}/sql`; -const sql = neon( - `postgresql://${Resource.Database.username}:${Resource.Database.password}@${Resource.Database.host}:${Resource.Database.port}/postgres?sslmode=verify-full`, -); - -export const db = drizzle({ client: sql }); diff --git a/examples/aws-planetscale-drizzle-postgres/src/schema.ts b/examples/aws-planetscale-drizzle-postgres/src/schema.ts deleted file mode 100644 index f75c5cd19e..0000000000 --- a/examples/aws-planetscale-drizzle-postgres/src/schema.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { pgTable, serial, text, varchar } from "drizzle-orm/pg-core"; - -export const todosTable = pgTable("todo", { - id: serial("id").primaryKey(), - title: varchar("title", { length: 255 }).notNull(), - description: text("description"), -}); diff --git a/examples/aws-planetscale-drizzle-postgres/sst.config.ts b/examples/aws-planetscale-drizzle-postgres/sst.config.ts deleted file mode 100644 index 3128227068..0000000000 --- a/examples/aws-planetscale-drizzle-postgres/sst.config.ts +++ /dev/null @@ -1,128 +0,0 @@ -/// - -/** - * ## AWS PlanetScale Drizzle Postgres - * - * In this example, we use PlanetScale Postgres with a branch-per-stage pattern. Every stage - * gets its own database branch — so each PR can have an isolated database. - * - * ```ts title="sst.config.ts" - * const db = planetscale.getDatabasePostgresOutput({ - * id: "mydb", - * organization: "myorg", - * }); - * - * const branch = - * $app.stage === "production" - * ? planetscale.getPostgresBranchOutput({ - * id: db.defaultBranch, - * organization: db.organization, - * database: db.name, - * }) - * : new planetscale.PostgresBranch("DatabaseBranch", { - * database: db.name, - * organization: db.organization, - * name: $app.stage, - * parentBranch: db.defaultBranch, - * }); - * ``` - * - * We then create a role and wrap it in a `Linkable` to link it to a function. - * - * ```ts title="sst.config.ts" {3} - * new sst.aws.Function("Api", { - * handler: "src/api.handler", - * link: [database], - * url: true, - * }); - * ``` - * - * You can push your Drizzle schema changes to PlanetScale with: - * - * ```bash - * bun run db:push - * ``` - * - * In the function we use [Drizzle ORM](https://orm.drizzle.team) with the - * [`Resource`](/docs/reference/sdk/#resource) helper. - * - * ```ts title="src/drizzle.ts" - * import { drizzle } from "drizzle-orm/postgres-js"; - * import { Resource } from "sst"; - * import postgres from "postgres"; - * - * const client = postgres({ - * host: Resource.Database.host, - * username: Resource.Database.username, - * password: Resource.Database.password, - * database: Resource.Database.database, - * }); - * - * export const db = drizzle(client); - * ``` - * - */ -export default $config({ - app(input) { - return { - name: "aws-planetscale-drizzle-postgres", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - providers: { - planetscale: "1.0.0", - }, - }; - }, - async run() { - const db = planetscale.getDatabasePostgresOutput({ - id: "mydb", - organization: "myorg", - }); - - const branch = - $app.stage === "production" - ? planetscale.getPostgresBranchOutput({ - id: db.defaultBranch, - organization: db.organization, - database: db.name, - }) - : new planetscale.PostgresBranch("DatabaseBranch", { - database: db.name, - organization: db.organization, - name: $app.stage, - parentBranch: db.defaultBranch, - }); - - const role = new planetscale.PostgresBranchRole("DatabaseRole", { - database: db.name, - organization: db.organization, - branch: branch.name, - name: `${$app.name}-${$app.stage}`, - inheritedRoles: [ - "pg_read_all_data", - "pg_write_all_data", - "postgres", // Only needed for pushing schema changes - ], - }); - - const database = new sst.Linkable("Database", { - properties: { - host: role.accessHostUrl, - username: role.username, - password: role.password, - database: role.databaseName, - port: 6432, // Use 5432 for direct connection instead of PgBouncer - }, - }); - - const api = new sst.aws.Function("Api", { - handler: "src/api.handler", - link: [database], - url: true, - }); - - return { - url: api.url, - }; - }, -}); diff --git a/examples/aws-planetscale-drizzle-postgres/tsconfig.json b/examples/aws-planetscale-drizzle-postgres/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-planetscale-drizzle-postgres/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-policy-pack/package.json b/examples/aws-policy-pack/package.json deleted file mode 100644 index b984f65082..0000000000 --- a/examples/aws-policy-pack/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-policy-pack", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-policy-pack/policy-pack/.gitignore b/examples/aws-policy-pack/policy-pack/.gitignore deleted file mode 100644 index 6ba7daaf94..0000000000 --- a/examples/aws-policy-pack/policy-pack/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/bin/ -/node_modules/ -bun.lock diff --git a/examples/aws-policy-pack/policy-pack/PulumiPolicy.yaml b/examples/aws-policy-pack/policy-pack/PulumiPolicy.yaml deleted file mode 100644 index c6c1e5b116..0000000000 --- a/examples/aws-policy-pack/policy-pack/PulumiPolicy.yaml +++ /dev/null @@ -1,3 +0,0 @@ -description: A minimal Policy Pack for AWS using TypeScript. -runtime: nodejs -main: dist/index.js diff --git a/examples/aws-policy-pack/policy-pack/index.ts b/examples/aws-policy-pack/policy-pack/index.ts deleted file mode 100644 index a684f3ff21..0000000000 --- a/examples/aws-policy-pack/policy-pack/index.ts +++ /dev/null @@ -1,50 +0,0 @@ -import * as aws from "@pulumi/aws"; -import { PolicyPack, validateResourceOfType } from "@pulumi/policy"; - -new PolicyPack("iam-roles-policies", { - policies: [ - { - name: "iam-role-requires-permission-boundary", - description: "IAM roles must have a permission boundary.", - enforcementLevel: "mandatory", - validateResource: validateResourceOfType( - aws.iam.Role, - (role, _args, reportViolation) => { - if (!role.permissionsBoundary) { - reportViolation( - "Permission boundaries are important for limiting the maximum permissions that can be granted to an IAM role." - ); - } - }, - ), - }, - { - name: "iam-role-policy-no-wildcard-resources", - description: - "IAM role policies should avoid wildcard resources for better security.", - enforcementLevel: "advisory", - validateResource: validateResourceOfType( - aws.iam.RolePolicy, - (policy, _args, reportViolation) => { - if (policy.policy && typeof policy.policy === "string") { - try { - const policyDoc = JSON.parse(policy.policy); - const statements = policyDoc.Statement || []; - for (const statement of statements) { - const resources = Array.isArray(statement.Resource) - ? statement.Resource - : [statement.Resource]; - if (resources.includes("*")) { - reportViolation( - "IAM role policies should not use wildcard (*) for resources. Specify explicit resource ARNs to follow the principle of least privilege." - ); - break; - } - } - } catch (e) {} - } - }, - ), - }, - ], -}); diff --git a/examples/aws-policy-pack/policy-pack/package.json b/examples/aws-policy-pack/policy-pack/package.json deleted file mode 100644 index 2210bd57a9..0000000000 --- a/examples/aws-policy-pack/policy-pack/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "policy-pack", - "version": "0.0.1", - "dependencies": { - "@pulumi/aws": "^6.0.0", - "@pulumi/policy": "^1.20.0" - }, - "devDependencies": { - "@types/node": "^10.0.0" - } -} diff --git a/examples/aws-policy-pack/policy-pack/tsconfig.json b/examples/aws-policy-pack/policy-pack/tsconfig.json deleted file mode 100644 index ecb951b692..0000000000 --- a/examples/aws-policy-pack/policy-pack/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2018", - "module": "CommonJS", - "moduleResolution": "node", - "declaration": true, - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "outDir": "dist" - }, - "include": ["index.ts"] -} diff --git a/examples/aws-policy-pack/sst.config.ts b/examples/aws-policy-pack/sst.config.ts deleted file mode 100644 index 7430ea092a..0000000000 --- a/examples/aws-policy-pack/sst.config.ts +++ /dev/null @@ -1,63 +0,0 @@ -/// - -/** - * ## Policy Pack Validation - * - * You can use Pulumi Policy Packs to enforce compliance and security policies on your - * infrastructure before deployment. Created policies with and enforcement level of "mandatory" will block the deployment. - * - * This example shows how to use the `--policy` flag with `sst diff` and `sst deploy` to - * validate your infrastructure against a policy pack. - * - * Run the diff command with a policy pack to preview changes and check for violations: - * - * ```bash - * sst diff --policy ./policy-pack --stage prod - * ``` - * - * Deploy with policy validation: - * - * ```bash - * sst deploy --policy ./policy-pack --stage prod - * ``` - * - * To get started you can create a new policy pack for AWS using: - * - * ```bash - * mkdir policy-pack - * cd policy-pack - * pulumi policy new aws-typescript - * ``` - * - * The example policy pack (check the full example) enforces that all IAM roles must have a permission boundary, blocking the deployment in this sst example. - */ -export default $config({ - app(input) { - return { - name: "aws-policy-pack", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const role = new aws.iam.Role("ExampleRoleWithBoundary", { - assumeRolePolicy: aws.iam.assumeRolePolicyForPrincipal({ - Service: "lambda.amazonaws.com", - }), - // To make this compliant with the policy example, uncomment the following line: - // permissionsBoundary: "arn:aws:iam::aws:policy/PowerUserAccess", - }); - - new aws.iam.RolePolicy("S3GetItemPolicy", { - role: role.id, - policy: aws.iam.getPolicyDocumentOutput({ - statements: [ - { - actions: ["s3:GetObject"], - resources: ["*"], - }, - ], - }).json, - }); - }, -}); diff --git a/examples/aws-policy-pack/tsconfig.json b/examples/aws-policy-pack/tsconfig.json deleted file mode 100644 index 7811c6e56f..0000000000 --- a/examples/aws-policy-pack/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "node", - "esModuleInterop": true, - "strict": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "outDir": ".build" - }, - "include": ["**/*.ts"] -} diff --git a/examples/aws-postgres-local/.gitignore b/examples/aws-postgres-local/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-postgres-local/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-postgres-local/index.ts b/examples/aws-postgres-local/index.ts deleted file mode 100644 index 318f08fefa..0000000000 --- a/examples/aws-postgres-local/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Pool } from "pg"; -import { Resource } from "sst"; - -const pool = new Pool({ - host: Resource.MyPostgres.host, - port: Resource.MyPostgres.port, - user: Resource.MyPostgres.username, - password: Resource.MyPostgres.password, - database: Resource.MyPostgres.database, -}); - -export async function handler() { - const client = await pool.connect(); - const result = await client.query('SELECT NOW()'); - client.release(); - - return { - statusCode: 200, - body: `Querying ${Resource.MyPostgres.host}\n\n` - + result.rows[0].now, - }; -} diff --git a/examples/aws-postgres-local/package.json b/examples/aws-postgres-local/package.json deleted file mode 100644 index b5d4a4644c..0000000000 --- a/examples/aws-postgres-local/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "aws-postgres-local", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "pg": "^8.13.1", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145", - "@types/pg": "^8.11.10" - } -} diff --git a/examples/aws-postgres-local/sst.config.ts b/examples/aws-postgres-local/sst.config.ts deleted file mode 100644 index a88ea4a37b..0000000000 --- a/examples/aws-postgres-local/sst.config.ts +++ /dev/null @@ -1,86 +0,0 @@ -/// - -/** - * ## AWS Postgres local - * - * In this example, we connect to a locally running Postgres instance for dev. While - * on deploy, we use RDS. - * - * We use the [`docker run`](https://docs.docker.com/reference/cli/docker/container/run/) CLI - * to start a local container with Postgres. You don't have to use Docker, you can use - * Postgres.app or any other way to run Postgres locally. - * - * ```bash - * docker run \ - * --rm \ - * -p 5432:5432 \ - * -v $(pwd)/.sst/storage/postgres:/var/lib/postgresql/data \ - * -e POSTGRES_USER=postgres \ - * -e POSTGRES_PASSWORD=password \ - * -e POSTGRES_DB=local \ - * postgres:16.4 - * ``` - * - * The data is saved to the `.sst/storage` directory. So if you restart the dev server, the - * data will still be there. - * - * We then configure the `dev` property of the `Postgres` component with the settings for the - * local Postgres instance. - * - * ```ts title="sst.config.ts" - * dev: { - * username: "postgres", - * password: "password", - * database: "local", - * port: 5432, - * } - * ``` - * - * By providing the `dev` prop for Postgres, SST will use the local Postgres instance and - * not deploy a new RDS database when running `sst dev`. - * - * It also allows us to access the database through a Resource `link` without having to - * conditionally check if we are running locally. - * - * ```ts title="index.ts" - * const pool = new Pool({ - * host: Resource.MyPostgres.host, - * port: Resource.MyPostgres.port, - * user: Resource.MyPostgres.username, - * password: Resource.MyPostgres.password, - * database: Resource.MyPostgres.database, - * }); - * ``` - * - * The above will work in both `sst dev` and `sst deploy`. - */ -export default $config({ - app(input) { - return { - name: "aws-postgres-local", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { nat: "ec2" }); - - const rds = new sst.aws.Postgres("MyPostgres", { - dev: { - username: "postgres", - password: "password", - database: "local", - host: "localhost", - port: 5432, - }, - vpc, - }); - - new sst.aws.Function("MyFunction", { - vpc, - url: true, - link: [rds], - handler: "index.handler", - }); - }, -}); diff --git a/examples/aws-postgres-local/tsconfig.json b/examples/aws-postgres-local/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-postgres-local/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-postgres-shared-parameter-group/sst.config.ts b/examples/aws-postgres-shared-parameter-group/sst.config.ts deleted file mode 100644 index ab0e7dc8e6..0000000000 --- a/examples/aws-postgres-shared-parameter-group/sst.config.ts +++ /dev/null @@ -1,72 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-postgres-shared-pg", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - - // Alternative: create a standalone parameter group and reference it - // - // const sharedParameterGroup = new aws.rds.ParameterGroup( - // "SharedParameterGroup", - // { - // name: "shared-parameter-group", - // family: "postgres17", - // parameters: [ - // { name: "rds.force_ssl", value: "0" }, - // { name: "log_min_duration_statement", value: "1000" }, - // ], - // }, - // ); - // - // Then use in each Postgres: - // transform: { - // instance: { parameterGroupName: sharedParameterGroup.name }, - // } - - // First database with custom parameters - const db1 = new sst.aws.Postgres("Database1", { - vpc, - transform: { - parameterGroup: { - parameters: [ - { - name: "rds.force_ssl", - value: "0", - }, - { - name: "rds.logical_replication", - value: "1", - applyMethod: "pending-reboot", - }, - { - name: "log_min_duration_statement", - value: "1000", - }, - ], - }, - }, - }); - - // Second database reuses db1's parameter group - const db2 = new sst.aws.Postgres("Database2", { - vpc, - transform: { - instance: { - parameterGroupName: db1.nodes.instance.parameterGroupName, - }, - }, - }); - - return { - db1Host: db1.host, - db2Host: db2.host, - }; - }, -}); diff --git a/examples/aws-postgres/index.ts b/examples/aws-postgres/index.ts deleted file mode 100644 index 1c6dfd2185..0000000000 --- a/examples/aws-postgres/index.ts +++ /dev/null @@ -1,21 +0,0 @@ -import pg from "pg"; -import { Resource } from "sst"; -const { Client } = pg; -const client = new Client({ - user: Resource.MyDatabase.username, - password: Resource.MyDatabase.password, - database: Resource.MyDatabase.database, - host: Resource.MyDatabase.host, - port: Resource.MyDatabase.port, -}); -await client.connect(); - -export async function handler() { - const res = await client.query("SELECT $1::text as message", [ - "Hello world!", - ]); - return { - statusCode: 200, - body: res.rows[0].message, - }; -} diff --git a/examples/aws-postgres/package.json b/examples/aws-postgres/package.json deleted file mode 100644 index b90c7345e2..0000000000 --- a/examples/aws-postgres/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-postgres", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "pg": "^8.13.0", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-postgres/sst.config.ts b/examples/aws-postgres/sst.config.ts deleted file mode 100644 index 8a82eda60b..0000000000 --- a/examples/aws-postgres/sst.config.ts +++ /dev/null @@ -1,37 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-postgres", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - // NAT Gateways are required for Lambda functions - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const postgres = new sst.aws.Postgres("MyDatabase", { - vpc, - }); - const app = new sst.aws.Function("MyApp", { - handler: "index.handler", - url: true, - link: [postgres], - nodejs: { - esbuild: { - external: ["pg"], - }, - }, - }); - - return { - app: app.url, - host: postgres.host, - port: postgres.port, - username: postgres.username, - password: postgres.password, - database: postgres.database, - }; - }, -}); diff --git a/examples/aws-pothos-graphql/.gitignore b/examples/aws-pothos-graphql/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-pothos-graphql/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-pothos-graphql/client.ts b/examples/aws-pothos-graphql/client.ts deleted file mode 100644 index 4216224d56..0000000000 --- a/examples/aws-pothos-graphql/client.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Resource } from "sst"; -import { createClient } from "./graphql/genql"; - -const client = createClient({ - url: `${Resource.Api.url}/graphql`, -}); - -export async function handler() { - const createGiraffe = await client.mutation({ - createGiraffe: { - __args: { - name: "Jonny", - }, - name: true, - }, - }); - - return { - statusCode: 200, - body: createGiraffe, - }; -} diff --git a/examples/aws-pothos-graphql/graphql/genql/index.ts b/examples/aws-pothos-graphql/graphql/genql/index.ts deleted file mode 100644 index d6b343103f..0000000000 --- a/examples/aws-pothos-graphql/graphql/genql/index.ts +++ /dev/null @@ -1,65 +0,0 @@ -// @ts-nocheck -import type { - QueryGenqlSelection, - Query, - MutationGenqlSelection, - Mutation, -} from './schema' -import { - linkTypeMap, - createClient as createClientOriginal, - generateGraphqlOperation, - type FieldsSelection, - type GraphqlOperation, - type ClientOptions, - GenqlError, -} from './runtime' -export type { FieldsSelection } from './runtime' -export { GenqlError } - -import types from './types' -export * from './schema' -const typeMap = linkTypeMap(types as any) - -export interface Client { - query( - request: R & { __name?: string }, - ): Promise> - - mutation( - request: R & { __name?: string }, - ): Promise> -} - -export const createClient = function (options?: ClientOptions): Client { - return createClientOriginal({ - url: undefined, - - ...options, - queryRoot: typeMap.Query!, - mutationRoot: typeMap.Mutation!, - subscriptionRoot: typeMap.Subscription!, - }) as any -} - -export const everything = { - __scalar: true, -} - -export type QueryResult = FieldsSelection< - Query, - fields -> -export const generateQueryOp: ( - fields: QueryGenqlSelection & { __name?: string }, -) => GraphqlOperation = function (fields) { - return generateGraphqlOperation('query', typeMap.Query!, fields as any) -} - -export type MutationResult = - FieldsSelection -export const generateMutationOp: ( - fields: MutationGenqlSelection & { __name?: string }, -) => GraphqlOperation = function (fields) { - return generateGraphqlOperation('mutation', typeMap.Mutation!, fields as any) -} diff --git a/examples/aws-pothos-graphql/graphql/genql/runtime/batcher.ts b/examples/aws-pothos-graphql/graphql/genql/runtime/batcher.ts deleted file mode 100644 index c092551010..0000000000 --- a/examples/aws-pothos-graphql/graphql/genql/runtime/batcher.ts +++ /dev/null @@ -1,275 +0,0 @@ -// @ts-nocheck -import type { GraphqlOperation } from './generateGraphqlOperation' -import { GenqlError } from './error' - -type Variables = Record - -type QueryError = Error & { - message: string - - locations?: Array<{ - line: number - column: number - }> - path?: any - rid: string - details?: Record -} -type Result = { - data: Record - errors: Array -} -type Fetcher = ( - batchedQuery: GraphqlOperation | Array, -) => Promise> -type Options = { - batchInterval?: number - shouldBatch?: boolean - maxBatchSize?: number -} -type Queue = Array<{ - request: GraphqlOperation - resolve: (...args: Array) => any - reject: (...args: Array) => any -}> - -/** - * takes a list of requests (queue) and batches them into a single server request. - * It will then resolve each individual requests promise with the appropriate data. - * @private - * @param {QueryBatcher} client - the client to use - * @param {Queue} queue - the list of requests to batch - */ -function dispatchQueueBatch(client: QueryBatcher, queue: Queue): void { - let batchedQuery: any = queue.map((item) => item.request) - - if (batchedQuery.length === 1) { - batchedQuery = batchedQuery[0] - } - (() => { - try { - return client.fetcher(batchedQuery); - } catch(e) { - return Promise.reject(e); - } - })().then((responses: any) => { - if (queue.length === 1 && !Array.isArray(responses)) { - if (responses.errors && responses.errors.length) { - queue[0].reject( - new GenqlError(responses.errors, responses.data), - ) - return - } - - queue[0].resolve(responses) - return - } else if (responses.length !== queue.length) { - throw new Error('response length did not match query length') - } - - for (let i = 0; i < queue.length; i++) { - if (responses[i].errors && responses[i].errors.length) { - queue[i].reject( - new GenqlError(responses[i].errors, responses[i].data), - ) - } else { - queue[i].resolve(responses[i]) - } - } - }) - .catch((e) => { - for (let i = 0; i < queue.length; i++) { - queue[i].reject(e) - } - }); -} - -/** - * creates a list of requests to batch according to max batch size. - * @private - * @param {QueryBatcher} client - the client to create list of requests from from - * @param {Options} options - the options for the batch - */ -function dispatchQueue(client: QueryBatcher, options: Options): void { - const queue = client._queue - const maxBatchSize = options.maxBatchSize || 0 - client._queue = [] - - if (maxBatchSize > 0 && maxBatchSize < queue.length) { - for (let i = 0; i < queue.length / maxBatchSize; i++) { - dispatchQueueBatch( - client, - queue.slice(i * maxBatchSize, (i + 1) * maxBatchSize), - ) - } - } else { - dispatchQueueBatch(client, queue) - } -} -/** - * Create a batcher client. - * @param {Fetcher} fetcher - A function that can handle the network requests to graphql endpoint - * @param {Options} options - the options to be used by client - * @param {boolean} options.shouldBatch - should the client batch requests. (default true) - * @param {integer} options.batchInterval - duration (in MS) of each batch window. (default 6) - * @param {integer} options.maxBatchSize - max number of requests in a batch. (default 0) - * @param {boolean} options.defaultHeaders - default headers to include with every request - * - * @example - * const fetcher = batchedQuery => fetch('path/to/graphql', { - * method: 'post', - * headers: { - * Accept: 'application/json', - * 'Content-Type': 'application/json', - * }, - * body: JSON.stringify(batchedQuery), - * credentials: 'include', - * }) - * .then(response => response.json()) - * - * const client = new QueryBatcher(fetcher, { maxBatchSize: 10 }) - */ - -export class QueryBatcher { - fetcher: Fetcher - _options: Options - _queue: Queue - - constructor( - fetcher: Fetcher, - { - batchInterval = 6, - shouldBatch = true, - maxBatchSize = 0, - }: Options = {}, - ) { - this.fetcher = fetcher - this._options = { - batchInterval, - shouldBatch, - maxBatchSize, - } - this._queue = [] - } - - /** - * Fetch will send a graphql request and return the parsed json. - * @param {string} query - the graphql query. - * @param {Variables} variables - any variables you wish to inject as key/value pairs. - * @param {[string]} operationName - the graphql operationName. - * @param {Options} overrides - the client options overrides. - * - * @return {promise} resolves to parsed json of server response - * - * @example - * client.fetch(` - * query getHuman($id: ID!) { - * human(id: $id) { - * name - * height - * } - * } - * `, { id: "1001" }, 'getHuman') - * .then(human => { - * // do something with human - * console.log(human); - * }); - */ - fetch( - query: string, - variables?: Variables, - operationName?: string, - overrides: Options = {}, - ): Promise { - const request: GraphqlOperation = { - query, - } - const options = Object.assign({}, this._options, overrides) - - if (variables) { - request.variables = variables - } - - if (operationName) { - request.operationName = operationName - } - - const promise = new Promise((resolve, reject) => { - this._queue.push({ - request, - resolve, - reject, - }) - - if (this._queue.length === 1) { - if (options.shouldBatch) { - setTimeout( - () => dispatchQueue(this, options), - options.batchInterval, - ) - } else { - dispatchQueue(this, options) - } - } - }) - return promise - } - - /** - * Fetch will send a graphql request and return the parsed json. - * @param {string} query - the graphql query. - * @param {Variables} variables - any variables you wish to inject as key/value pairs. - * @param {[string]} operationName - the graphql operationName. - * @param {Options} overrides - the client options overrides. - * - * @return {Promise>} resolves to parsed json of server response - * - * @example - * client.forceFetch(` - * query getHuman($id: ID!) { - * human(id: $id) { - * name - * height - * } - * } - * `, { id: "1001" }, 'getHuman') - * .then(human => { - * // do something with human - * console.log(human); - * }); - */ - forceFetch( - query: string, - variables?: Variables, - operationName?: string, - overrides: Options = {}, - ): Promise { - const request: GraphqlOperation = { - query, - } - const options = Object.assign({}, this._options, overrides, { - shouldBatch: false, - }) - - if (variables) { - request.variables = variables - } - - if (operationName) { - request.operationName = operationName - } - - const promise = new Promise((resolve, reject) => { - const client = new QueryBatcher(this.fetcher, this._options) - client._queue = [ - { - request, - resolve, - reject, - }, - ] - dispatchQueue(client, options) - }) - return promise - } -} diff --git a/examples/aws-pothos-graphql/graphql/genql/runtime/createClient.ts b/examples/aws-pothos-graphql/graphql/genql/runtime/createClient.ts deleted file mode 100644 index 755617ed7a..0000000000 --- a/examples/aws-pothos-graphql/graphql/genql/runtime/createClient.ts +++ /dev/null @@ -1,68 +0,0 @@ -// @ts-nocheck - -import { type BatchOptions, createFetcher } from './fetcher' -import type { ExecutionResult, LinkedType } from './types' -import { - generateGraphqlOperation, - type GraphqlOperation, -} from './generateGraphqlOperation' - -export type Headers = - | HeadersInit - | (() => HeadersInit) - | (() => Promise) - -export type BaseFetcher = ( - operation: GraphqlOperation | GraphqlOperation[], -) => Promise - -export type ClientOptions = Omit & { - url?: string - batch?: BatchOptions | boolean - fetcher?: BaseFetcher - fetch?: Function - headers?: Headers -} - -export const createClient = ({ - queryRoot, - mutationRoot, - subscriptionRoot, - ...options -}: ClientOptions & { - queryRoot?: LinkedType - mutationRoot?: LinkedType - subscriptionRoot?: LinkedType -}) => { - const fetcher = createFetcher(options) - const client: { - query?: Function - mutation?: Function - } = {} - - if (queryRoot) { - client.query = (request: any) => { - if (!queryRoot) throw new Error('queryRoot argument is missing') - - const resultPromise = fetcher( - generateGraphqlOperation('query', queryRoot, request), - ) - - return resultPromise - } - } - if (mutationRoot) { - client.mutation = (request: any) => { - if (!mutationRoot) - throw new Error('mutationRoot argument is missing') - - const resultPromise = fetcher( - generateGraphqlOperation('mutation', mutationRoot, request), - ) - - return resultPromise - } - } - - return client as any -} diff --git a/examples/aws-pothos-graphql/graphql/genql/runtime/error.ts b/examples/aws-pothos-graphql/graphql/genql/runtime/error.ts deleted file mode 100644 index d9039ebe0c..0000000000 --- a/examples/aws-pothos-graphql/graphql/genql/runtime/error.ts +++ /dev/null @@ -1,29 +0,0 @@ -// @ts-nocheck -export class GenqlError extends Error { - errors: Array = [] - /** - * Partial data returned by the server - */ - data?: any - constructor(errors: any[], data: any) { - let message = Array.isArray(errors) - ? errors.map((x) => x?.message || '').join('\n') - : '' - if (!message) { - message = 'GraphQL error' - } - super(message) - this.errors = errors - this.data = data - } -} - -interface GraphqlError { - message: string - locations?: Array<{ - line: number - column: number - }> - path?: string[] - extensions?: Record -} diff --git a/examples/aws-pothos-graphql/graphql/genql/runtime/fetcher.ts b/examples/aws-pothos-graphql/graphql/genql/runtime/fetcher.ts deleted file mode 100644 index 74e6d4ce9a..0000000000 --- a/examples/aws-pothos-graphql/graphql/genql/runtime/fetcher.ts +++ /dev/null @@ -1,97 +0,0 @@ -// @ts-nocheck -import { QueryBatcher } from './batcher' - -import type { ClientOptions } from './createClient' -import type { GraphqlOperation } from './generateGraphqlOperation' -import { GenqlError } from './error' - -export interface Fetcher { - (gql: GraphqlOperation): Promise -} - -export type BatchOptions = { - batchInterval?: number // ms - maxBatchSize?: number -} - -const DEFAULT_BATCH_OPTIONS = { - maxBatchSize: 10, - batchInterval: 40, -} - -export const createFetcher = ({ - url, - headers = {}, - fetcher, - fetch: _fetch, - batch = false, - ...rest -}: ClientOptions): Fetcher => { - if (!url && !fetcher) { - throw new Error('url or fetcher is required') - } - - fetcher = fetcher || (async (body) => { - let headersObject = - typeof headers == 'function' ? await headers() : headers - headersObject = headersObject || {} - if (typeof fetch === 'undefined' && !_fetch) { - throw new Error( - 'Global `fetch` function is not available, pass a fetch polyfill to Genql `createClient`', - ) - } - let fetchImpl = _fetch || fetch - const res = await fetchImpl(url!, { - headers: { - 'Content-Type': 'application/json', - ...headersObject, - }, - method: 'POST', - body: JSON.stringify(body), - ...rest, - }) - if (!res.ok) { - throw new Error(`${res.statusText}: ${await res.text()}`) - } - const json = await res.json() - return json - }) - - if (!batch) { - return async (body) => { - const json = await fetcher!(body) - if (Array.isArray(json)) { - return json.map((json) => { - if (json?.errors?.length) { - throw new GenqlError(json.errors || [], json.data) - } - return json.data - }) - } else { - if (json?.errors?.length) { - throw new GenqlError(json.errors || [], json.data) - } - return json.data - } - } - } - - const batcher = new QueryBatcher( - async (batchedQuery) => { - // console.log(batchedQuery) // [{ query: 'query{user{age}}', variables: {} }, ...] - const json = await fetcher!(batchedQuery) - return json as any - }, - batch === true ? DEFAULT_BATCH_OPTIONS : batch, - ) - - return async ({ query, variables }) => { - const json = await batcher.fetch(query, variables) - if (json?.data) { - return json.data - } - throw new Error( - 'Genql batch fetcher returned unexpected result ' + JSON.stringify(json), - ) - } -} diff --git a/examples/aws-pothos-graphql/graphql/genql/runtime/generateGraphqlOperation.ts b/examples/aws-pothos-graphql/graphql/genql/runtime/generateGraphqlOperation.ts deleted file mode 100644 index c618019ec8..0000000000 --- a/examples/aws-pothos-graphql/graphql/genql/runtime/generateGraphqlOperation.ts +++ /dev/null @@ -1,225 +0,0 @@ -// @ts-nocheck -import type { LinkedField, LinkedType } from './types' - -export interface Args { - [arg: string]: any | undefined -} - -export interface Fields { - [field: string]: Request -} - -export type Request = boolean | number | Fields - -export interface Variables { - [name: string]: { - value: any - typing: [LinkedType, string] - } -} - -export interface Context { - root: LinkedType - varCounter: number - variables: Variables - fragmentCounter: number - fragments: string[] -} - -export interface GraphqlOperation { - query: string - variables?: { [name: string]: any } - operationName?: string -} - -const parseRequest = ( - request: Request | undefined, - ctx: Context, - path: string[], -): string => { - if (typeof request === 'object' && '__args' in request) { - const args: any = request.__args - let fields: Request | undefined = { ...request } - delete fields.__args - const argNames = Object.keys(args) - - if (argNames.length === 0) { - return parseRequest(fields, ctx, path) - } - - const field = getFieldFromPath(ctx.root, path) - - const argStrings = argNames.map((argName) => { - ctx.varCounter++ - const varName = `v${ctx.varCounter}` - - const typing = field.args && field.args[argName] // typeMap used here, .args - - if (!typing) { - throw new Error( - `no typing defined for argument \`${argName}\` in path \`${path.join( - '.', - )}\``, - ) - } - - ctx.variables[varName] = { - value: args[argName], - typing, - } - - return `${argName}:$${varName}` - }) - return `(${argStrings})${parseRequest(fields, ctx, path)}` - } else if (typeof request === 'object' && Object.keys(request).length > 0) { - const fields = request - const fieldNames = Object.keys(fields).filter((k) => Boolean(fields[k])) - - if (fieldNames.length === 0) { - throw new Error( - `field selection should not be empty: ${path.join('.')}`, - ) - } - - const type = - path.length > 0 ? getFieldFromPath(ctx.root, path).type : ctx.root - const scalarFields = type.scalar - - let scalarFieldsFragment: string | undefined - - if (fieldNames.includes('__scalar')) { - const falsyFieldNames = new Set( - Object.keys(fields).filter((k) => !Boolean(fields[k])), - ) - if (scalarFields?.length) { - ctx.fragmentCounter++ - scalarFieldsFragment = `f${ctx.fragmentCounter}` - - ctx.fragments.push( - `fragment ${scalarFieldsFragment} on ${ - type.name - }{${scalarFields - .filter((f) => !falsyFieldNames.has(f)) - .join(',')}}`, - ) - } - } - - const fieldsSelection = fieldNames - .filter((f) => !['__scalar', '__name'].includes(f)) - .map((f) => { - const parsed = parseRequest(fields[f], ctx, [...path, f]) - - if (f.startsWith('on_')) { - ctx.fragmentCounter++ - const implementationFragment = `f${ctx.fragmentCounter}` - - const typeMatch = f.match(/^on_(.+)/) - - if (!typeMatch || !typeMatch[1]) - throw new Error('match failed') - - ctx.fragments.push( - `fragment ${implementationFragment} on ${typeMatch[1]}${parsed}`, - ) - - return `...${implementationFragment}` - } else { - return `${f}${parsed}` - } - }) - .concat(scalarFieldsFragment ? [`...${scalarFieldsFragment}`] : []) - .join(',') - - return `{${fieldsSelection}}` - } else { - return '' - } -} - -export const generateGraphqlOperation = ( - operation: 'query' | 'mutation' | 'subscription', - root: LinkedType, - fields?: Fields, -): GraphqlOperation => { - const ctx: Context = { - root: root, - varCounter: 0, - variables: {}, - fragmentCounter: 0, - fragments: [], - } - const result = parseRequest(fields, ctx, []) - - const varNames = Object.keys(ctx.variables) - - const varsString = - varNames.length > 0 - ? `(${varNames.map((v) => { - const variableType = ctx.variables[v].typing[1] - return `$${v}:${variableType}` - })})` - : '' - - const operationName = fields?.__name || '' - - return { - query: [ - `${operation} ${operationName}${varsString}${result}`, - ...ctx.fragments, - ].join(','), - variables: Object.keys(ctx.variables).reduce<{ [name: string]: any }>( - (r, v) => { - r[v] = ctx.variables[v].value - return r - }, - {}, - ), - ...(operationName ? { operationName: operationName.toString() } : {}), - } -} - -export const getFieldFromPath = ( - root: LinkedType | undefined, - path: string[], -) => { - let current: LinkedField | undefined - - if (!root) throw new Error('root type is not provided') - - if (path.length === 0) throw new Error(`path is empty`) - - path.forEach((f) => { - const type = current ? current.type : root - - if (!type.fields) - throw new Error(`type \`${type.name}\` does not have fields`) - - const possibleTypes = Object.keys(type.fields) - .filter((i) => i.startsWith('on_')) - .reduce( - (types, fieldName) => { - const field = type.fields && type.fields[fieldName] - if (field) types.push(field.type) - return types - }, - [type], - ) - - let field: LinkedField | null = null - - possibleTypes.forEach((type) => { - const found = type.fields && type.fields[f] - if (found) field = found - }) - - if (!field) - throw new Error( - `type \`${type.name}\` does not have a field \`${f}\``, - ) - - current = field - }) - - return current as LinkedField -} diff --git a/examples/aws-pothos-graphql/graphql/genql/runtime/index.ts b/examples/aws-pothos-graphql/graphql/genql/runtime/index.ts deleted file mode 100644 index 130ed4bf79..0000000000 --- a/examples/aws-pothos-graphql/graphql/genql/runtime/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -// @ts-nocheck -export { createClient } from './createClient' -export type { ClientOptions } from './createClient' -export type { FieldsSelection } from './typeSelection' -export { generateGraphqlOperation } from './generateGraphqlOperation' -export type { GraphqlOperation } from './generateGraphqlOperation' -export { linkTypeMap } from './linkTypeMap' -// export { Observable } from 'zen-observable-ts' -export { createFetcher } from './fetcher' -export { GenqlError } from './error' -export const everything = { - __scalar: true, -} diff --git a/examples/aws-pothos-graphql/graphql/genql/runtime/linkTypeMap.ts b/examples/aws-pothos-graphql/graphql/genql/runtime/linkTypeMap.ts deleted file mode 100644 index 3e12c54598..0000000000 --- a/examples/aws-pothos-graphql/graphql/genql/runtime/linkTypeMap.ts +++ /dev/null @@ -1,156 +0,0 @@ -// @ts-nocheck -import type { - CompressedType, - CompressedTypeMap, - LinkedArgMap, - LinkedField, - LinkedType, - LinkedTypeMap, -} from './types' - -export interface PartialLinkedFieldMap { - [field: string]: { - type: string - args?: LinkedArgMap - } -} - -export const linkTypeMap = ( - typeMap: CompressedTypeMap, -): LinkedTypeMap => { - const indexToName: Record = Object.assign( - {}, - ...Object.keys(typeMap.types).map((k, i) => ({ [i]: k })), - ) - - let intermediaryTypeMap = Object.assign( - {}, - ...Object.keys(typeMap.types || {}).map( - (k): Record => { - const type: CompressedType = typeMap.types[k]! - const fields = type || {} - return { - [k]: { - name: k, - // type scalar properties - scalar: Object.keys(fields).filter((f) => { - const [type] = fields[f] || [] - - const isScalar = - type && typeMap.scalars.includes(type) - if (!isScalar) { - return false - } - const args = fields[f]?.[1] - const argTypes = Object.values(args || {}) - .map((x) => x?.[1]) - .filter(Boolean) - - const hasRequiredArgs = argTypes.some( - (str) => str && str.endsWith('!'), - ) - if (hasRequiredArgs) { - return false - } - return true - }), - // fields with corresponding `type` and `args` - fields: Object.assign( - {}, - ...Object.keys(fields).map( - (f): PartialLinkedFieldMap => { - const [typeIndex, args] = fields[f] || [] - if (typeIndex == null) { - return {} - } - return { - [f]: { - // replace index with type name - type: indexToName[typeIndex], - args: Object.assign( - {}, - ...Object.keys(args || {}).map( - (k) => { - // if argTypeString == argTypeName, argTypeString is missing, need to readd it - if (!args || !args[k]) { - return - } - const [ - argTypeName, - argTypeString, - ] = args[k] as any - return { - [k]: [ - indexToName[ - argTypeName - ], - argTypeString || - indexToName[ - argTypeName - ], - ], - } - }, - ), - ), - }, - } - }, - ), - ), - }, - } - }, - ), - ) - const res = resolveConcreteTypes(intermediaryTypeMap) - return res -} - -// replace typename with concrete type -export const resolveConcreteTypes = (linkedTypeMap: LinkedTypeMap) => { - Object.keys(linkedTypeMap).forEach((typeNameFromKey) => { - const type: LinkedType = linkedTypeMap[typeNameFromKey]! - // type.name = typeNameFromKey - if (!type.fields) { - return - } - - const fields = type.fields - - Object.keys(fields).forEach((f) => { - const field: LinkedField = fields[f]! - - if (field.args) { - const args = field.args - Object.keys(args).forEach((key) => { - const arg = args[key] - - if (arg) { - const [typeName] = arg - - if (typeof typeName === 'string') { - if (!linkedTypeMap[typeName]) { - linkedTypeMap[typeName] = { name: typeName } - } - - arg[0] = linkedTypeMap[typeName]! - } - } - }) - } - - const typeName = field.type as LinkedType | string - - if (typeof typeName === 'string') { - if (!linkedTypeMap[typeName]) { - linkedTypeMap[typeName] = { name: typeName } - } - - field.type = linkedTypeMap[typeName]! - } - }) - }) - - return linkedTypeMap -} diff --git a/examples/aws-pothos-graphql/graphql/genql/runtime/typeSelection.ts b/examples/aws-pothos-graphql/graphql/genql/runtime/typeSelection.ts deleted file mode 100644 index a021d00bf5..0000000000 --- a/examples/aws-pothos-graphql/graphql/genql/runtime/typeSelection.ts +++ /dev/null @@ -1,95 +0,0 @@ -// @ts-nocheck -////////////////////////////////////////////////// - -// SOME THINGS TO KNOW BEFORE DIVING IN -/* -0. DST is the request type, SRC is the response type - -1. FieldsSelection uses an object because currently is impossible to make recursive types - -2. FieldsSelection is a recursive type that makes a type based on request type and fields - -3. HandleObject handles object types - -4. Handle__scalar adds all scalar properties excluding non scalar props -*/ - -export type FieldsSelection | undefined, DST> = { - scalar: SRC - union: Handle__isUnion - object: HandleObject - array: SRC extends Nil - ? never - : SRC extends Array - ? Array> - : never - __scalar: Handle__scalar - never: never -}[DST extends Nil - ? 'never' - : DST extends false | 0 - ? 'never' - : SRC extends Scalar - ? 'scalar' - : SRC extends any[] - ? 'array' - : SRC extends { __isUnion?: any } - ? 'union' - : DST extends { __scalar?: any } - ? '__scalar' - : DST extends {} - ? 'object' - : 'never'] - -type HandleObject, DST> = DST extends boolean - ? SRC - : SRC extends Nil - ? never - : Pick< - { - // using keyof SRC to maintain ?: relations of SRC type - [Key in keyof SRC]: Key extends keyof DST - ? FieldsSelection> - : SRC[Key] - }, - Exclude - // { - // // remove falsy values - // [Key in keyof DST]: DST[Key] extends false | 0 ? never : Key - // }[keyof DST] - > - -type Handle__scalar, DST> = SRC extends Nil - ? never - : Pick< - // continue processing fields that are in DST, directly pass SRC type if not in DST - { - [Key in keyof SRC]: Key extends keyof DST - ? FieldsSelection - : SRC[Key] - }, - // remove fields that are not scalars or are not in DST - { - [Key in keyof SRC]: SRC[Key] extends Nil - ? never - : Key extends FieldsToRemove - ? never - : SRC[Key] extends Scalar - ? Key - : Key extends keyof DST - ? Key - : never - }[keyof SRC] - > - -type Handle__isUnion, DST> = SRC extends Nil - ? never - : Omit // just return the union type - -type Scalar = string | number | Date | boolean | null | undefined - -type Anify = { [P in keyof T]?: any } - -type FieldsToRemove = '__isUnion' | '__scalar' | '__name' | '__args' - -type Nil = undefined | null diff --git a/examples/aws-pothos-graphql/graphql/genql/runtime/types.ts b/examples/aws-pothos-graphql/graphql/genql/runtime/types.ts deleted file mode 100644 index 3f0bc30b9e..0000000000 --- a/examples/aws-pothos-graphql/graphql/genql/runtime/types.ts +++ /dev/null @@ -1,69 +0,0 @@ -// @ts-nocheck - -export interface ExecutionResult { - errors?: Array - data?: TData | null -} - -export interface ArgMap { - [arg: string]: [keyType, string] | [keyType] | undefined -} - -export type CompressedField = [ - type: keyType, - args?: ArgMap, -] - -export interface CompressedFieldMap { - [field: string]: CompressedField | undefined -} - -export type CompressedType = CompressedFieldMap - -export interface CompressedTypeMap { - scalars: Array - types: { - [type: string]: CompressedType | undefined - } -} - -// normal types -export type Field = { - type: keyType - args?: ArgMap -} - -export interface FieldMap { - [field: string]: Field | undefined -} - -export type Type = FieldMap - -export interface TypeMap { - scalars: Array - types: { - [type: string]: Type | undefined - } -} - -export interface LinkedArgMap { - [arg: string]: [LinkedType, string] | undefined -} -export interface LinkedField { - type: LinkedType - args?: LinkedArgMap -} - -export interface LinkedFieldMap { - [field: string]: LinkedField | undefined -} - -export interface LinkedType { - name: string - fields?: LinkedFieldMap - scalar?: string[] -} - -export interface LinkedTypeMap { - [type: string]: LinkedType | undefined -} diff --git a/examples/aws-pothos-graphql/graphql/genql/schema.graphql b/examples/aws-pothos-graphql/graphql/genql/schema.graphql deleted file mode 100644 index 017afa4426..0000000000 --- a/examples/aws-pothos-graphql/graphql/genql/schema.graphql +++ /dev/null @@ -1,12 +0,0 @@ -"""Long necks, cool patterns, taller than you.""" -type Giraffe { - name: String! -} - -type Mutation { - createGiraffe(name: String!): Giraffe! -} - -type Query { - giraffe: Giraffe! -} \ No newline at end of file diff --git a/examples/aws-pothos-graphql/graphql/genql/schema.ts b/examples/aws-pothos-graphql/graphql/genql/schema.ts deleted file mode 100644 index 9677818f0e..0000000000 --- a/examples/aws-pothos-graphql/graphql/genql/schema.ts +++ /dev/null @@ -1,70 +0,0 @@ -// @ts-nocheck -/* istanbul ignore file */ -/* tslint:disable */ -/* eslint-disable */ - -export type Scalars = { - String: string, - Boolean: boolean, -} - - -/** Long necks, cool patterns, taller than you. */ -export interface Giraffe { - name: Scalars['String'] - __typename: 'Giraffe' -} - -export interface Mutation { - createGiraffe: Giraffe - __typename: 'Mutation' -} - -export interface Query { - giraffe: Giraffe - __typename: 'Query' -} - - -/** Long necks, cool patterns, taller than you. */ -export interface GiraffeGenqlSelection{ - name?: boolean | number - __typename?: boolean | number - __scalar?: boolean | number -} - -export interface MutationGenqlSelection{ - createGiraffe?: (GiraffeGenqlSelection & { __args: {name: Scalars['String']} }) - __typename?: boolean | number - __scalar?: boolean | number -} - -export interface QueryGenqlSelection{ - giraffe?: GiraffeGenqlSelection - __typename?: boolean | number - __scalar?: boolean | number -} - - - const Giraffe_possibleTypes: string[] = ['Giraffe'] - export const isGiraffe = (obj?: { __typename?: any } | null): obj is Giraffe => { - if (!obj?.__typename) throw new Error('__typename is missing in "isGiraffe"') - return Giraffe_possibleTypes.includes(obj.__typename) - } - - - - const Mutation_possibleTypes: string[] = ['Mutation'] - export const isMutation = (obj?: { __typename?: any } | null): obj is Mutation => { - if (!obj?.__typename) throw new Error('__typename is missing in "isMutation"') - return Mutation_possibleTypes.includes(obj.__typename) - } - - - - const Query_possibleTypes: string[] = ['Query'] - export const isQuery = (obj?: { __typename?: any } | null): obj is Query => { - if (!obj?.__typename) throw new Error('__typename is missing in "isQuery"') - return Query_possibleTypes.includes(obj.__typename) - } - \ No newline at end of file diff --git a/examples/aws-pothos-graphql/graphql/genql/types.ts b/examples/aws-pothos-graphql/graphql/genql/types.ts deleted file mode 100644 index 8ddc017cce..0000000000 --- a/examples/aws-pothos-graphql/graphql/genql/types.ts +++ /dev/null @@ -1,40 +0,0 @@ -export default { - "scalars": [ - 1, - 4 - ], - "types": { - "Giraffe": { - "name": [ - 1 - ], - "__typename": [ - 1 - ] - }, - "String": {}, - "Mutation": { - "createGiraffe": [ - 0, - { - "name": [ - 1, - "String!" - ] - } - ], - "__typename": [ - 1 - ] - }, - "Query": { - "giraffe": [ - 0 - ], - "__typename": [ - 1 - ] - }, - "Boolean": {} - } -} \ No newline at end of file diff --git a/examples/aws-pothos-graphql/graphql/schema.graphql b/examples/aws-pothos-graphql/graphql/schema.graphql deleted file mode 100644 index 017afa4426..0000000000 --- a/examples/aws-pothos-graphql/graphql/schema.graphql +++ /dev/null @@ -1,12 +0,0 @@ -"""Long necks, cool patterns, taller than you.""" -type Giraffe { - name: String! -} - -type Mutation { - createGiraffe(name: String!): Giraffe! -} - -type Query { - giraffe: Giraffe! -} \ No newline at end of file diff --git a/examples/aws-pothos-graphql/graphql/urql.ts b/examples/aws-pothos-graphql/graphql/urql.ts deleted file mode 100644 index 60833df69e..0000000000 --- a/examples/aws-pothos-graphql/graphql/urql.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { - useQuery, - useClient, - createRequest, - RequestPolicy, - OperationResult, - UseMutationState, - OperationContext, - UseMutationResponse, -} from "urql"; -import { useEffect, useState, useCallback, useRef } from "react"; -import { - QueryResult, - QueryGenqlSelection, - MutationResult, - MutationGenqlSelection, - generateQueryOp, - generateMutationOp, -} from "./genql"; - -import { pipe, toPromise } from "wonka"; - -export function useTypedQuery(opts: { - query: Query; - pause?: boolean; - requestPolicy?: RequestPolicy; - context?: Partial; -}) { - const { query, variables } = generateQueryOp(opts.query); - return useQuery>({ - ...opts, - query, - variables, - }); -} - -const initialState = { - stale: false, - fetching: false, - data: undefined, - error: undefined, - operation: undefined, - extensions: undefined, -}; - -export function useTypedMutation< - Variables extends Record, - Mutation extends MutationGenqlSelection, - Data extends MutationResult ->( - builder: (vars: Variables) => Mutation, - opts?: Partial -): UseMutationResponse { - const client = useClient(); - const isMounted = useRef(true); - const [state, setState] = - useState>(initialState); - const executeMutation = useCallback( - ( - vars?: Variables, - context?: Partial - ): Promise> => { - setState({ ...initialState, fetching: true }); - const buildArgs = vars || ({} as Variables); - const built = builder(buildArgs); - const { query, variables } = generateMutationOp(built); - return pipe( - client.executeMutation( - createRequest(query, variables as Variables), - { ...opts, ...context } - ), - toPromise - ).then((result: OperationResult) => { - if (isMounted.current) { - setState({ - fetching: false, - stale: !!result.stale, - data: result.data, - error: result.error, - extensions: result.extensions, - operation: result.operation, - }); - } - return result; - }); - }, - [state, setState] - ); - - useEffect(() => { - isMounted.current = true; - return () => { - isMounted.current = false; - }; - }, []); - - return [state, executeMutation]; -} diff --git a/examples/aws-pothos-graphql/package.json b/examples/aws-pothos-graphql/package.json deleted file mode 100644 index cb287214e0..0000000000 --- a/examples/aws-pothos-graphql/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "aws-pothos-graphql", - "dependencies": { - "@pothos/core": "^3.41.1", - "@urql/core": "^5.0.4", - "graphql-yoga": "^5.3.1", - "react": "^18.3.1", - "sst": "file:../../sdk/js", - "urql": "^4.1.0", - "wonka": "^6.3.4" - }, - "devDependencies": { - "@genql/cli": "^6.3.3", - "@types/aws-lambda": "8.10.138", - "@types/react": "^18.3.3" - } -} diff --git a/examples/aws-pothos-graphql/pothos/builder.ts b/examples/aws-pothos-graphql/pothos/builder.ts deleted file mode 100644 index 3dc1195588..0000000000 --- a/examples/aws-pothos-graphql/pothos/builder.ts +++ /dev/null @@ -1,6 +0,0 @@ -import SchemaBuilder from "@pothos/core"; - -export const builder = new SchemaBuilder({}); - -builder.queryType({}); -builder.mutationType({}); diff --git a/examples/aws-pothos-graphql/pothos/extract.ts b/examples/aws-pothos-graphql/pothos/extract.ts deleted file mode 100644 index 0326d4a3fa..0000000000 --- a/examples/aws-pothos-graphql/pothos/extract.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { lexicographicSortSchema, printSchema } from "graphql"; -import path from "path"; -import { schema } from "./schema"; - -async function extract() { - const schemaAsString = printSchema(lexicographicSortSchema(schema)); - - await Bun.write("./graphql/schema.graphql", schemaAsString); - - const proc = Bun.spawn( - [ - "bun", - "x", - "@genql/cli", - "--output", - "./genql", - "--schema", - "./schema.graphql", - "--esm", - ], - { - cwd: "./graphql", - } - ); - - const exitCode = await proc.exited; - if (exitCode !== 0) { - throw Error(`Genegration faild with code ${exitCode}`); - } -} - -extract() - .then(() => { - console.log("Pothos schema extracted successfully."); - }) - .catch((error) => { - console.error("Failed to extract pothos schema the database:", error); - }); diff --git a/examples/aws-pothos-graphql/pothos/graphql.ts b/examples/aws-pothos-graphql/pothos/graphql.ts deleted file mode 100644 index a11cb0cfb7..0000000000 --- a/examples/aws-pothos-graphql/pothos/graphql.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { schema } from "./schema"; -import { awsLambdaRequestHandler } from "./server"; - -export const handler = awsLambdaRequestHandler({ - schema, -}); diff --git a/examples/aws-pothos-graphql/pothos/schema.ts b/examples/aws-pothos-graphql/pothos/schema.ts deleted file mode 100644 index fb2921ffe5..0000000000 --- a/examples/aws-pothos-graphql/pothos/schema.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { builder } from "./builder"; - -import "./types/giraffe"; - -export const schema = builder.toSchema({}); diff --git a/examples/aws-pothos-graphql/pothos/server.ts b/examples/aws-pothos-graphql/pothos/server.ts deleted file mode 100644 index 56536f2bc6..0000000000 --- a/examples/aws-pothos-graphql/pothos/server.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { - APIGatewayProxyEventV2, - APIGatewayProxyResult, - Context, -} from "aws-lambda"; -import { createYoga, YogaServerOptions } from "graphql-yoga"; - -type ServerContext = { - event: APIGatewayProxyEventV2; - context: Context; -}; - -export function awsLambdaRequestHandler( - options: YogaServerOptions -) { - const yoga = createYoga({ - ...options, - }); - - return async ( - event: APIGatewayProxyEventV2, - lambdaContext: Context - ): Promise => { - const parameters = new URLSearchParams( - (event.queryStringParameters as Record) || {} - ).toString(); - - const url = `${event.rawPath}?${parameters}`; - - const request: RequestInit = { - method: event.requestContext.http.method, - headers: event.headers as HeadersInit, - body: event.body - ? Buffer.from(event.body, event.isBase64Encoded ? "base64" : "utf8") - : undefined, - }; - - const serverContext: ServerContext = { - event, - context: lambdaContext, - }; - - const response = await yoga.fetch(url, request, serverContext); - const responseHeaders = Object.fromEntries(response.headers.entries()); - - return { - statusCode: response.status, - headers: responseHeaders, - body: await response.text(), - isBase64Encoded: false, - }; - }; -} diff --git a/examples/aws-pothos-graphql/pothos/types/giraffe.ts b/examples/aws-pothos-graphql/pothos/types/giraffe.ts deleted file mode 100644 index d0dbeab188..0000000000 --- a/examples/aws-pothos-graphql/pothos/types/giraffe.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { builder } from "../builder"; - -export class Giraffe { - name: string; - - constructor(name: string) { - this.name = name; - } -} - -builder.objectType(Giraffe, { - name: "Giraffe", - description: "Long necks, cool patterns, taller than you.", - fields: (t) => ({ - name: t.exposeString("name", {}), - }), -}); - -builder.queryFields((t) => ({ - giraffe: t.field({ - type: Giraffe, - resolve: () => new Giraffe("James"), - }), -})); - -builder.mutationFields((t) => ({ - createGiraffe: t.field({ - type: Giraffe, - args: { - name: t.arg.string({ required: true }), - }, - resolve: async (root, args) => { - const giraffe = { name: args.name }; - - return giraffe; - }, - }), -})); diff --git a/examples/aws-pothos-graphql/sst.config.ts b/examples/aws-pothos-graphql/sst.config.ts deleted file mode 100644 index ef154806d8..0000000000 --- a/examples/aws-pothos-graphql/sst.config.ts +++ /dev/null @@ -1,35 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-pothos-graphql", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - if ($dev) { - new sst.x.DevCommand("PothosGraphqlExtractor", { - dev: { - command: "bun --watch run pothos/extract.ts", - autostart: true, - }, - }); - } - - const api = new sst.aws.ApiGatewayV2("Api"); - api.route("POST /graphql", "pothos/graphql.handler"); - - const client = new sst.aws.Function("Client", { - url: true, - link: [api], - handler: "client.handler", - }); - - return { - api: api.url, - client: client.url, - }; - }, -}); diff --git a/examples/aws-pothos-graphql/tsconfig.json b/examples/aws-pothos-graphql/tsconfig.json deleted file mode 100644 index aee0ec940f..0000000000 --- a/examples/aws-pothos-graphql/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "strict": true - } -} diff --git a/examples/aws-prisma-lambda/.gitignore b/examples/aws-prisma-lambda/.gitignore deleted file mode 100644 index 11ddd8dbe6..0000000000 --- a/examples/aws-prisma-lambda/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -node_modules -# Keep environment variables out of version control -.env diff --git a/examples/aws-prisma-lambda/index.ts b/examples/aws-prisma-lambda/index.ts deleted file mode 100644 index 99633c21b1..0000000000 --- a/examples/aws-prisma-lambda/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { prisma } from "./prisma"; - -async function createUser(name: string, email: string) { - return prisma.user.create({ - data: { name, email }, - }); -} - -export async function handler() { - const user = await createUser("Alice", `alice-${crypto.randomUUID()}@example.com`); - return { - statusCode: 201, - body: JSON.stringify({ user }), - }; -} diff --git a/examples/aws-prisma-lambda/package.json b/examples/aws-prisma-lambda/package.json deleted file mode 100644 index 423d683d52..0000000000 --- a/examples/aws-prisma-lambda/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "aws-prisma-lambda", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "postinstall": "prisma generate", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "@types/aws-lambda": "^8.10.145", - "@types/node": "^22.5.4", - "prisma": "^5.19.1", - "ts-node": "^10.9.2", - "typescript": "^5.5.4" - }, - "dependencies": { - "@prisma/client": "^5.19.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-prisma-lambda/prisma.ts b/examples/aws-prisma-lambda/prisma.ts deleted file mode 100644 index 4a1ae94b80..0000000000 --- a/examples/aws-prisma-lambda/prisma.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Resource } from "sst"; -import { PrismaClient } from '@prisma/client'; - -const globalForPrisma = global as unknown as { prisma: PrismaClient } - -export const prisma = globalForPrisma.prisma || - new PrismaClient({ - datasources: { - db: { - url: `postgresql://${Resource.MyPostgres.username}:${Resource.MyPostgres.password}@${Resource.MyPostgres.host}:${Resource.MyPostgres.port}/${Resource.MyPostgres.database}?connection_limit=1`, - }, - }, - }); - -// Create single client in `sst dev` -if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma diff --git a/examples/aws-prisma-lambda/prisma/migrations/0_init/migration.sql b/examples/aws-prisma-lambda/prisma/migrations/0_init/migration.sql deleted file mode 100644 index 1e9eb8fd02..0000000000 --- a/examples/aws-prisma-lambda/prisma/migrations/0_init/migration.sql +++ /dev/null @@ -1,11 +0,0 @@ --- CreateTable -CREATE TABLE "User" ( - "id" SERIAL NOT NULL, - "name" TEXT, - "email" TEXT NOT NULL, - - CONSTRAINT "User_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); diff --git a/examples/aws-prisma-lambda/prisma/schema.prisma b/examples/aws-prisma-lambda/prisma/schema.prisma deleted file mode 100644 index c377c80546..0000000000 --- a/examples/aws-prisma-lambda/prisma/schema.prisma +++ /dev/null @@ -1,18 +0,0 @@ -generator client { - provider = "prisma-client-js" - // For x86 - binaryTargets = ["native", "rhel-openssl-3.0.x"] - // For ARM - // binaryTargets = ["native", "linux-arm64-openssl-3.0.x"] -} - -datasource db { - provider = "postgresql" - url = env("DATABASE_URL") -} - -model User { - id Int @id @default(autoincrement()) - name String? - email String @unique -} diff --git a/examples/aws-prisma-lambda/sst.config.ts b/examples/aws-prisma-lambda/sst.config.ts deleted file mode 100644 index a10fb65e69..0000000000 --- a/examples/aws-prisma-lambda/sst.config.ts +++ /dev/null @@ -1,98 +0,0 @@ -/// - -/** - * ## Prisma in Lambda - * - * To use Prisma in a Lambda function you need to - * - * - Generate the Prisma Client with the right architecture - * - Copy the generated client to the function - * - Run the function inside a VPC - * - * You can set the architecture using the `binaryTargets` option in `prisma/schema.prisma`. - * - * ```prisma title="prisma/schema.prisma" - * // For x86 - * binaryTargets = ["native", "rhel-openssl-3.0.x"] - * // For ARM - * // binaryTargets = ["native", "linux-arm64-openssl-3.0.x"] - * ``` - * - * You can also switch to ARM, just make sure to also change the function architecture in your - * `sst.config.ts`. - * - * ```ts title="sst.config.ts" - * { - * // For ARM - * architecture: "arm64" - * } - * ``` - * - * To generate the client, you need to run `prisma generate` when you make changes to the - * schema. - * - * Since this [needs to be done on every deploy](https://www.prisma.io/docs/orm/more/help-and-troubleshooting/help-articles/vercel-caching-issue#a-custom-postinstall-script), we add a `postinstall` script to the `package.json`. - * - * ```json title="package.json" - * "scripts": { - * "postinstall": "prisma generate" - * } - * ``` - * - * This runs the command on `npm install`. - * - * We then need to copy the generated client to the function when we deploy. - * - * ```ts title="sst.config.ts" - * { - * copyFiles: [{ from: "node_modules/.prisma/client/" }] - * } - * ``` - * - * Our function also needs to run inside a VPC, since Prisma doesn't support the Data API. - * - * ```ts title="sst.config.ts" - * { - * vpc - * } - * ``` - * - * #### Prisma in serverless environments - * - * Prisma is [not great in serverless environments](https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/databases-connections#serverless-environments-faas). For a couple of reasons: - * - * 1. It doesn't support Data API, so you need to manage the connection pool on your own. - * 2. Without the Data API, your functions need to run inside a VPC. - * - You cannot use `sst dev` without [connecting to the VPC](/docs/live#using-a-vpc). - * 3. Due to the internal architecture of their client, it's also has slower cold starts. - * - * Instead we recommend using [Drizzle](https://orm.drizzle.team). This example is here for - * reference for people that are already using Prisma. - */ -export default $config({ - app(input) { - return { - name: "aws-prisma-lambda", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { nat: "managed" }); - const rds = new sst.aws.Postgres("MyPostgres", { vpc }); - - const api = new sst.aws.Function("MyApi", { - vpc, - url: true, - link: [rds], - // For ARM - // architecture: "arm64", - handler: "index.handler", - copyFiles: [{ from: "node_modules/.prisma/client/" }], - }); - - return { - api: api.url, - }; - }, -}); diff --git a/examples/aws-prisma-lambda/tsconfig.json b/examples/aws-prisma-lambda/tsconfig.json deleted file mode 100644 index 8bb6097f80..0000000000 --- a/examples/aws-prisma-lambda/tsconfig.json +++ /dev/null @@ -1,108 +0,0 @@ -{ - "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - - /* Projects */ - // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - - /* Language and Environment */ - "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ - // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ - - /* Modules */ - "module": "commonjs", /* Specify what module code is generated. */ - // "rootDir": "./", /* Specify the root folder within your source files. */ - // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ - // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ - // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ - // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ - // "resolveJsonModule": true, /* Enable importing .json files. */ - // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ - // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ - - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ - - /* Emit */ - // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "./", /* Specify an output folder for all emitted files. */ - // "removeComments": true, /* Disable emitting comments. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ - // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ - - /* Type Checking */ - "strict": true, /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ - } -} diff --git a/examples/aws-prisma/.dockerignore b/examples/aws-prisma/.dockerignore deleted file mode 100644 index ea0aaeeec9..0000000000 --- a/examples/aws-prisma/.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-prisma/.gitignore b/examples/aws-prisma/.gitignore deleted file mode 100644 index 033b3ef1cc..0000000000 --- a/examples/aws-prisma/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -node_modules -# Keep environment variables out of version control -.env - -# sst -.sst diff --git a/examples/aws-prisma/Dockerfile b/examples/aws-prisma/Dockerfile deleted file mode 100644 index c532d99a54..0000000000 --- a/examples/aws-prisma/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json index.mjs prisma /app/ -RUN npm install - -RUN npx prisma generate - -ENTRYPOINT ["node", "index.mjs"] diff --git a/examples/aws-prisma/index.mjs b/examples/aws-prisma/index.mjs deleted file mode 100644 index f90c0e4a50..0000000000 --- a/examples/aws-prisma/index.mjs +++ /dev/null @@ -1,21 +0,0 @@ -import express from "express"; -import { PrismaClient } from '@prisma/client'; - -const PORT = 80; - -const app = express(); -const prisma = new PrismaClient(); - -app.get("/", async (_req, res) => { - const user = await prisma.user.create({ - data: { - name: "Alice", - email: `alice-${crypto.randomUUID()}@example.com` - }, - }); - res.send(JSON.stringify(user)); -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-prisma/package.json b/examples/aws-prisma/package.json deleted file mode 100644 index 6be9028453..0000000000 --- a/examples/aws-prisma/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "aws-prisma", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "@types/aws-lambda": "8.10.145", - "@types/node": "^22.7.8", - "prisma": "^5.21.1", - "ts-node": "^10.9.2", - "typescript": "^5.6.3" - }, - "dependencies": { - "@prisma/client": "^5.21.1", - "express": "^4.21.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-prisma/prisma/migrations/20241022202928_init/migration.sql b/examples/aws-prisma/prisma/migrations/20241022202928_init/migration.sql deleted file mode 100644 index 1e9eb8fd02..0000000000 --- a/examples/aws-prisma/prisma/migrations/20241022202928_init/migration.sql +++ /dev/null @@ -1,11 +0,0 @@ --- CreateTable -CREATE TABLE "User" ( - "id" SERIAL NOT NULL, - "name" TEXT, - "email" TEXT NOT NULL, - - CONSTRAINT "User_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); diff --git a/examples/aws-prisma/prisma/migrations/migration_lock.toml b/examples/aws-prisma/prisma/migrations/migration_lock.toml deleted file mode 100644 index fbffa92c2b..0000000000 --- a/examples/aws-prisma/prisma/migrations/migration_lock.toml +++ /dev/null @@ -1,3 +0,0 @@ -# Please do not edit this file manually -# It should be added in your version-control system (i.e. Git) -provider = "postgresql" \ No newline at end of file diff --git a/examples/aws-prisma/prisma/schema.prisma b/examples/aws-prisma/prisma/schema.prisma deleted file mode 100644 index 3c4e2ed8f5..0000000000 --- a/examples/aws-prisma/prisma/schema.prisma +++ /dev/null @@ -1,20 +0,0 @@ -// This is your Prisma schema file, -// learn more about it in the docs: https://pris.ly/d/prisma-schema - -// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? -// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init - -generator client { - provider = "prisma-client-js" -} - -datasource db { - provider = "postgresql" - url = env("DATABASE_URL") -} - -model User { - id Int @id @default(autoincrement()) - name String? - email String @unique -} diff --git a/examples/aws-prisma/sst.config.ts b/examples/aws-prisma/sst.config.ts deleted file mode 100644 index 0b72a75085..0000000000 --- a/examples/aws-prisma/sst.config.ts +++ /dev/null @@ -1,39 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-prisma", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const rds = new sst.aws.Postgres("MyPostgres", { vpc }); - - const DATABASE_URL = $interpolate`postgresql://${rds.username}:${rds.password}@${rds.host}:${rds.port}/${rds.database}`; - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [rds], - environment: { DATABASE_URL }, - loadBalancer: { - ports: [{ listen: "80/http" }], - }, - dev: { - command: "node --watch index.mjs", - }, - }); - - new sst.x.DevCommand("Prisma", { - environment: { DATABASE_URL }, - dev: { - autostart: false, - command: "npx prisma studio", - }, - }); - }, -}); diff --git a/examples/aws-prisma/tsconfig.json b/examples/aws-prisma/tsconfig.json deleted file mode 100644 index 56a8ab8109..0000000000 --- a/examples/aws-prisma/tsconfig.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - - /* Projects */ - // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - - /* Language and Environment */ - "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ - // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ - - /* Modules */ - "module": "commonjs", /* Specify what module code is generated. */ - // "rootDir": "./", /* Specify the root folder within your source files. */ - // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ - // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ - // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ - // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ - // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ - // "resolveJsonModule": true, /* Enable importing .json files. */ - // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ - // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ - - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ - - /* Emit */ - // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "./", /* Specify an output folder for all emitted files. */ - // "removeComments": true, /* Disable emitting comments. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ - // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ - - /* Type Checking */ - "strict": true, /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */ - // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ - } -} diff --git a/examples/aws-puppeteer/.gitignore b/examples/aws-puppeteer/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-puppeteer/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-puppeteer/index.ts b/examples/aws-puppeteer/index.ts deleted file mode 100644 index da3500de7c..0000000000 --- a/examples/aws-puppeteer/index.ts +++ /dev/null @@ -1,42 +0,0 @@ -import puppeteer from "puppeteer-core"; -import chromium from "@sparticuz/chromium"; - -// This is the path to the local Chromium binary -const YOUR_LOCAL_CHROMIUM_PATH = - "/tmp/localChromium/chromium/mac_arm-1350406/chrome-mac/Chromium.app/Contents/MacOS/Chromium"; - -export async function handler() { - const url = "https://sst.dev"; - const width = 1024; - const height = 768; - - const browser = await puppeteer.launch({ - args: chromium.args, - defaultViewport: chromium.defaultViewport, - executablePath: process.env.SST_DEV - ? YOUR_LOCAL_CHROMIUM_PATH - : await chromium.executablePath(), - headless: chromium.headless, - }); - - const page = await browser.newPage(); - - await page.setViewport({ - width: width, - height: height, - }); - - await page.goto(url!); - - const screenshot = (await page.screenshot({ encoding: "base64" })) as string; - - return { - statusCode: 200, - body: screenshot, - isBase64Encoded: true, - headers: { - "Content-Type": "image/png", - "Content-Disposition": "inline", - }, - }; -} diff --git a/examples/aws-puppeteer/package.json b/examples/aws-puppeteer/package.json deleted file mode 100644 index 892b488539..0000000000 --- a/examples/aws-puppeteer/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "aws-puppeteer", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@sparticuz/chromium": "^127.0.0", - "puppeteer-core": "^23.1.1", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145" - } -} diff --git a/examples/aws-puppeteer/sst.config.ts b/examples/aws-puppeteer/sst.config.ts deleted file mode 100644 index b65b788afd..0000000000 --- a/examples/aws-puppeteer/sst.config.ts +++ /dev/null @@ -1,108 +0,0 @@ -/// - -/** - * ## Puppeteer in Lambda - * - * To use Puppeteer in a Lambda function you need: - * - * 1. [`puppeteer-core`](https://www.npmjs.com/package/puppeteer-core) - * 2. Chromium - * - In `sst dev`, we'll use a locally installed Chromium version. - * - In `sst deploy`, we'll use the [`@sparticuz/chromium`](https://github.com/sparticuz/chromium) package. It comes with a pre-built binary for Lambda. - * - * #### Chromium version - * - * Since Puppeteer has a preferred version of Chromium, we'll need to check the version of - * Chrome that a given version of Puppeteer supports. Head over to the - * [Puppeteer's Chromium Support page](https://pptr.dev/chromium-support) and check which - * versions work together. - * - * For example, Puppeteer v23.1.1 supports Chrome for Testing 127.0.6533.119. So, we'll use the - * v127 of `@sparticuz/chromium`. - * - * ```bash - * npm install puppeteer-core@23.1.1 @sparticuz/chromium@127.0.0 - * ``` - * - * #### Install Chromium locally - * - * To use this locally, you'll need to install Chromium. - * - * ```bash - * npx @puppeteer/browsers install chromium@latest --path /tmp/localChromium - * ``` - * - * Once installed you'll see the location of the Chromium binary, `/tmp/localChromium/chromium/mac_arm-1350406/chrome-mac/Chromium.app/Contents/MacOS/Chromium`. - * - * Update this in your Lambda function. - * - * ```ts title="index.ts" - * // This is the path to the local Chromium binary - * const YOUR_LOCAL_CHROMIUM_PATH = "/tmp/localChromium/chromium/mac_arm-1350406/chrome-mac/Chromium.app/Contents/MacOS/Chromium"; - * ``` - * - * You'll notice we are using the right binary with the `SST_DEV` environment variable. - * - * ```ts title="index.ts" {4-6} - * const browser = await puppeteer.launch({ - * args: chromium.args, - * defaultViewport: chromium.defaultViewport, - * executablePath: process.env.SST_DEV - * ? YOUR_LOCAL_CHROMIUM_PATH - * : await chromium.executablePath(), - * headless: chromium.headless, - * }); - * ``` - * - * #### Deploy - * - * We don't need a layer to deploy this because `@sparticuz/chromium` comes with a pre-built - * binary for Lambda. - * - * :::note - * As of writing this, `arm64` is not supported by `@sparticuz/chromium`. - * ::: - * - * We just need to set it in the [`nodejs.install`](/docs/component/aws/function#nodejs-install). - * - * ```ts title="sst.config.ts" - * { - * nodejs: { - * install: ["@sparticuz/chromium"] - * } - * } - * ``` - * - * And on deploy, SST will use the right binary. - * - * :::tip - * You don't need to use a Lambda layer to use Puppeteer. - * ::: - * - * We are giving our function more memory and a longer timeout since running Puppeteer can - * take a while. - */ -export default $config({ - app(input) { - return { - name: "aws-puppeteer", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const api = new sst.aws.Function("MyFunction", { - url: true, - memory: "2 GB", - timeout: "15 minutes", - handler: "index.handler", - nodejs: { - install: ["@sparticuz/chromium"], - }, - }); - - return { - url: api.url, - }; - }, -}); diff --git a/examples/aws-puppeteer/tsconfig.json b/examples/aws-puppeteer/tsconfig.json deleted file mode 100644 index 2f98042715..0000000000 --- a/examples/aws-puppeteer/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "esModuleInterop": true - } -} diff --git a/examples/aws-python-container/.gitignore b/examples/aws-python-container/.gitignore deleted file mode 100644 index 17ace783f5..0000000000 --- a/examples/aws-python-container/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.sst -.venv \ No newline at end of file diff --git a/examples/aws-python-container/core/pyproject.toml b/examples/aws-python-container/core/pyproject.toml deleted file mode 100644 index 4d9ed5884e..0000000000 --- a/examples/aws-python-container/core/pyproject.toml +++ /dev/null @@ -1,11 +0,0 @@ -[project] -name = "core" -version = "0.1.0" -description = "Add your description here" -authors = [{ name = "Nick Wall", email = "mail@walln.dev" }] -requires-python = "==3.11.*" -dependencies = ["requests>=2.32.3"] - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" diff --git a/examples/aws-python-container/core/src/core/__init__.py b/examples/aws-python-container/core/src/core/__init__.py deleted file mode 100644 index 8b13789179..0000000000 --- a/examples/aws-python-container/core/src/core/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/examples/aws-python-container/core/src/core/ping.py b/examples/aws-python-container/core/src/core/ping.py deleted file mode 100644 index c13cfd5726..0000000000 --- a/examples/aws-python-container/core/src/core/ping.py +++ /dev/null @@ -1,5 +0,0 @@ -import requests - - -def ping(): - return requests.get("https://api.github.com").status_code diff --git a/examples/aws-python-container/custom_dockerfile/Dockerfile b/examples/aws-python-container/custom_dockerfile/Dockerfile deleted file mode 100644 index a8383a707c..0000000000 --- a/examples/aws-python-container/custom_dockerfile/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -# The python version to use is supplied as an arg from SST -ARG PYTHON_VERSION=3.11 - -# Use an official AWS Lambda base image for Python -FROM public.ecr.aws/lambda/python:${PYTHON_VERSION} - -# # Ensure git is installed so we can install git based dependencies (such as sst) -RUN if command -v dnf > /dev/null 2>&1; then \ - dnf update -y && dnf install -y git gcc && dnf clean all; \ - elif command -v yum > /dev/null 2>&1; then \ - yum install -y git gcc && yum clean all; \ - fi - -# Install UV to manage your python runtime -COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv - -# Copy everything first so workspace packages (referenced as ./pkg in requirements.txt) -# are available during dependency installation -COPY . ${LAMBDA_TASK_ROOT} - -# Install the dependencies to the lambda runtime -RUN uv pip install -r requirements.txt --target ${LAMBDA_TASK_ROOT} --system - -# Perform any steps that you want here: -# Example: pre-bake in model weights from huggingface to image - -# No need to configure the handler or entrypoint - SST will do that diff --git a/examples/aws-python-container/custom_dockerfile/pyproject.toml b/examples/aws-python-container/custom_dockerfile/pyproject.toml deleted file mode 100644 index feae2e5b61..0000000000 --- a/examples/aws-python-container/custom_dockerfile/pyproject.toml +++ /dev/null @@ -1,14 +0,0 @@ -[project] -name = "custom_dockerfile" -version = "0.1.0" -description = "Custom Dockerfile" -dependencies = ["core", "sst-sdk"] -requires-python = "==3.11.*" - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" - -[tool.uv.sources] -core = { workspace = true } -sst-sdk = { git = "https://github.com/anomalyco/sst.git", branch = "dev", subdirectory = "sdk/python" } diff --git a/examples/aws-python-container/custom_dockerfile/src/custom_dockerfile/__init__.py b/examples/aws-python-container/custom_dockerfile/src/custom_dockerfile/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-python-container/custom_dockerfile/src/custom_dockerfile/api.py b/examples/aws-python-container/custom_dockerfile/src/custom_dockerfile/api.py deleted file mode 100644 index 62a8ff638b..0000000000 --- a/examples/aws-python-container/custom_dockerfile/src/custom_dockerfile/api.py +++ /dev/null @@ -1,12 +0,0 @@ -from core.ping import ping -from sst import Resource - - -def handler(event, context): - response_code = ping() - print(f"Response code: {response_code}") - - return { - "statusCode": 200, - "body": f"Hello, World! - Linkable value: {Resource.MyLinkableValue.foo}", - } diff --git a/examples/aws-python-container/functions/pyproject.toml b/examples/aws-python-container/functions/pyproject.toml deleted file mode 100644 index 8eefe8e19d..0000000000 --- a/examples/aws-python-container/functions/pyproject.toml +++ /dev/null @@ -1,14 +0,0 @@ -[project] -name = "functions" -version = "0.1.0" -description = "Lambda function (container-mode)handlers" -dependencies = ["core", "sst-sdk"] -requires-python = "==3.11.*" - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" - -[tool.uv.sources] -core = { workspace = true } -sst-sdk = { git = "https://github.com/anomalyco/sst.git", branch = "dev", subdirectory = "sdk/python" } diff --git a/examples/aws-python-container/functions/src/functions/__init__.py b/examples/aws-python-container/functions/src/functions/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-python-container/functions/src/functions/api.py b/examples/aws-python-container/functions/src/functions/api.py deleted file mode 100644 index 62a8ff638b..0000000000 --- a/examples/aws-python-container/functions/src/functions/api.py +++ /dev/null @@ -1,12 +0,0 @@ -from core.ping import ping -from sst import Resource - - -def handler(event, context): - response_code = ping() - print(f"Response code: {response_code}") - - return { - "statusCode": 200, - "body": f"Hello, World! - Linkable value: {Resource.MyLinkableValue.foo}", - } diff --git a/examples/aws-python-container/pyproject.toml b/examples/aws-python-container/pyproject.toml deleted file mode 100644 index 4cd1c70628..0000000000 --- a/examples/aws-python-container/pyproject.toml +++ /dev/null @@ -1,16 +0,0 @@ -[project] -name = "aws-python-container" -version = "0.1.0" -description = "A SST app" -authors = [{ name = "Nick Wall", email = "mail@walln.dev" }] -dependencies = [] - -# It is recommended to specify your python version to match your Lambda runtime otherwise you may -# encounter issues with dependencies. -requires-python = "==3.11.*" - -[tool.uv.workspace] -members = ["functions", "core", "custom_dockerfile"] - -[tool.uv.sources] -sst-sdk = { git = "https://github.com/anomalyco/sst.git", subdirectory = "sdk/python", branch = "dev" } diff --git a/examples/aws-python-container/sst.config.ts b/examples/aws-python-container/sst.config.ts deleted file mode 100644 index f49506a8f5..0000000000 --- a/examples/aws-python-container/sst.config.ts +++ /dev/null @@ -1,118 +0,0 @@ -/// - -/** - * ## AWS Lambda Python container - * - * Python Lambda function that use large dependencies like `numpy` and `pandas`, can - * hit the 250MB Lambda package limit. To work around this, you can deploy them - * as a container image to Lambda. - * - * :::tip - * Container images on Lambda have a limit of 10GB. - * ::: - * - * In this example, we deploy two functions as container image. - * - * ```ts title="sst.config.ts" {2-4} - * const base = new sst.aws.Function("PythonFn", { - * python: { - * container: true, - * }, - * handler: "./functions/src/functions/api.handler", - * runtime: "python3.11", - * link: [linkableValue], - * url: true, - * }); - * ``` - * - * Now when you run `sst deploy`, it uses a built-in Dockerfile to build the image - * and deploy it. You'll need to have the Docker daemon running. - * - * :::note - * You need to have the Docker daemon running locally. - * ::: - * - * To use a custom Dockerfile, you can place a `Dockerfile` in the root of the - * uv workspace for your function. - * - * ```ts title="sst.config.ts" {5} - * const custom = new sst.aws.Function("PythonFnCustom", { - * python: { - * container: true, - * }, - * handler: "./custom_dockerfile/src/custom_dockerfile/api.handler", - * runtime: "python3.11", - * link: [linkableValue], - * url: true, - * }); - * ``` - * - * Here we have a `Dockerfile` in the `custom_dockerfile/` directory. - * - * ```dockerfile title="custom_dockerfile/Dockerfile" - * # The python version to use is supplied as an arg from SST - * ARG PYTHON_VERSION=3.11 - * - * # Use an official AWS Lambda base image for Python - * FROM public.ecr.aws/lambda/python:${PYTHON_VERSION} - * - * # ... - * ``` - * - * The project structure looks something like this. - * - * ```txt {5} - * ├── sst.config.ts - * ├── pyproject.toml - * └── custom_dockerfile - * ├── pyproject.toml - * ├── Dockerfile - * └── src - * └── custom_dockerfile - * └── api.py - * ``` - * - * Locally, you want to set the Python version in your `pyproject.toml` to make sure - * that `sst dev` uses the same version as `sst deploy`. - */ -export default $config({ - app(input) { - return { - name: "aws-python-container", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const linkableValue = new sst.Linkable("MyLinkableValue", { - properties: { - foo: "Hello World", - }, - }); - - const base = new sst.aws.Function("PythonFn", { - python: { - container: true, - }, - handler: "./functions/src/functions/api.handler", - runtime: "python3.11", - link: [linkableValue], - url: true, - }); - - const custom = new sst.aws.Function("PythonFnCustom", { - python: { - container: true, - }, - handler: "./custom_dockerfile/src/custom_dockerfile/api.handler", - runtime: "python3.11", - link: [linkableValue], - url: true, - }); - - return { - base: base.url, - custom: custom.url, - }; - }, -}); diff --git a/examples/aws-python-container/tsconfig.json b/examples/aws-python-container/tsconfig.json deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/examples/aws-python-container/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/examples/aws-python-huggingface/.gitignore b/examples/aws-python-huggingface/.gitignore deleted file mode 100644 index 17ace783f5..0000000000 --- a/examples/aws-python-huggingface/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.sst -.venv \ No newline at end of file diff --git a/examples/aws-python-huggingface/functions/Dockerfile b/examples/aws-python-huggingface/functions/Dockerfile deleted file mode 100644 index b7f8c97a6e..0000000000 --- a/examples/aws-python-huggingface/functions/Dockerfile +++ /dev/null @@ -1,42 +0,0 @@ -# If any docker wizard is interested, a multi-stage build would be better for caching -# and reducing the size of the final image - -# The python version to use is supplied as an arg from SST -ARG PYTHON_VERSION=3.12 - -# Use an official AWS Lambda base image for Python -FROM public.ecr.aws/lambda/python:${PYTHON_VERSION} as builder - -# # Ensure git is installed so we can install git based dependencies (such as sst) -ARG PYTHON_RUNTIME - -# Install git and gcc using appropriate package manager based on Python version -RUN dnf install -y git gcc gcc-c++ openssl-devel - -# Install Rust using rustup -RUN curl https://sh.rustup.rs -sSf | sh -s -- -y - -# Add Cargo to PATH -ENV PATH="/root/.cargo/bin:${PATH}" - -# Install UV to manage your python runtime -COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv - -# Copy everything first so workspace package references (e.g., ./functions) -# in requirements.txt resolve correctly during installation -COPY . ${LAMBDA_TASK_ROOT} - -# Install the dependencies to the lambda runtime -RUN uv pip install -r requirements.txt --target ${LAMBDA_TASK_ROOT} --system --no-verify-hashes - -FROM public.ecr.aws/lambda/python:${PYTHON_VERSION} - -ENV HF_HOME=/tmp/transformers_cache - -# Copy installed dependencies and application code from the builder stage -COPY --from=builder ${LAMBDA_TASK_ROOT} ${LAMBDA_TASK_ROOT} - -# Copy the rest of the code -COPY . ${LAMBDA_TASK_ROOT} - -# No need to configure the handler or entrypoint - SST will do that \ No newline at end of file diff --git a/examples/aws-python-huggingface/functions/pyproject.toml b/examples/aws-python-huggingface/functions/pyproject.toml deleted file mode 100644 index 1c8df57c9a..0000000000 --- a/examples/aws-python-huggingface/functions/pyproject.toml +++ /dev/null @@ -1,22 +0,0 @@ -[project] -name = "functions" -version = "0.1.0" -description = "A SST app" -authors = [{ name = "Nick Wall", email = "mail@walln.dev" }] -dependencies = ["transformers>=4.44.2", "torch==2.3.1"] - -# It is recommended to specify your python version to match your Lambda runtime otherwise you may -# encounter issues with dependencies. -requires-python = "==3.12.*" - -[tool.uv.sources] -torch = [{ index = "pytorch-cpu", marker = "platform_system != 'Darwin'" }] - -[[tool.uv.index]] -name = "pytorch-cpu" -url = "https://download.pytorch.org/whl/cpu" -explicit = true - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" diff --git a/examples/aws-python-huggingface/functions/src/functions/__init__.py b/examples/aws-python-huggingface/functions/src/functions/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-python-huggingface/functions/src/functions/api.py b/examples/aws-python-huggingface/functions/src/functions/api.py deleted file mode 100644 index c25dc9af41..0000000000 --- a/examples/aws-python-huggingface/functions/src/functions/api.py +++ /dev/null @@ -1,29 +0,0 @@ -from transformers import pipeline -import json - -# Initialize the pipeline once (outside the handler) to avoid reloading the model on each request -pipe = pipeline("text-generation", model="roneneldan/TinyStories-1M") - - -def handler(event, context): - # Define the prompt for text generation - prompt = "Write a short story about the magical framework SST that makes the cloud so easy to use!" - - # Generate text using the pipeline - response = pipe( - prompt, - max_length=150, - num_return_sequences=1, - temperature=0.6, - top_k=50, - do_sample=True, - ) - - # Extract the generated text - generated_text = response[0]["generated_text"] - - # Return the response with a status code and JSON-encoded body - return { - "statusCode": 200, - "body": json.dumps({"story": generated_text}), - } diff --git a/examples/aws-python-huggingface/pyproject.toml b/examples/aws-python-huggingface/pyproject.toml deleted file mode 100644 index fb335d9b8f..0000000000 --- a/examples/aws-python-huggingface/pyproject.toml +++ /dev/null @@ -1,16 +0,0 @@ -[project] -name = "aws-python-huggingface" -version = "0.1.0" -description = "A SST app" -authors = [{ name = "Nick Wall", email = "mail@walln.dev" }] -dependencies = [] - -# It is recommended to specify your python version to match your Lambda runtime otherwise you may -# encounter issues with dependencies. -requires-python = "==3.12.*" - -[tool.uv.workspace] -members = ["functions"] - -[tool.uv.sources] -sst-sdk = { git = "https://github.com/anomalyco/sst.git", subdirectory = "sdk/python", branch = "dev" } diff --git a/examples/aws-python-huggingface/sst.config.ts b/examples/aws-python-huggingface/sst.config.ts deleted file mode 100644 index 14d3b52c6e..0000000000 --- a/examples/aws-python-huggingface/sst.config.ts +++ /dev/null @@ -1,43 +0,0 @@ -/// - -/** - * ## AWS Lambda Python Hugging Face - * - * Uses a Python Lambda container image to deploy a lightweight - * [Hugging Face](https://huggingface.co/) model. - * - * Uses the [transformers](https://github.com/huggingface/transformers) library to - * generate text using the - * [TinyStories-33M](https://huggingface.co/roneneldan/TinyStories-33M) model. The - * backend is the pytorch cpu runtime. - * - * :::note - * This is not a production ready example. - * ::: - * - * This example also shows how it is possible to use custom index resolution to get - * dependencies from a private pypi server such as the pytorch cpu link. This - * example also shows how to use a custom Dockerfile to handle complex builds such - * as installing pytorch and pruning the build size. - */ -export default $config({ - app(input) { - return { - name: "aws-python-huggingface", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - new sst.aws.Function("PythonFunction", { - python: { - container: true, - }, - handler: "functions/src/functions/api.handler", - runtime: "python3.12", - memory: "2048 MB", - timeout: "120 seconds", - url: true, - }); - }, -}); diff --git a/examples/aws-python-huggingface/tsconfig.json b/examples/aws-python-huggingface/tsconfig.json deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/examples/aws-python-huggingface/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/examples/aws-python/.gitignore b/examples/aws-python/.gitignore deleted file mode 100644 index 17ace783f5..0000000000 --- a/examples/aws-python/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.sst -.venv \ No newline at end of file diff --git a/examples/aws-python/core/pyproject.toml b/examples/aws-python/core/pyproject.toml deleted file mode 100644 index 4d9ed5884e..0000000000 --- a/examples/aws-python/core/pyproject.toml +++ /dev/null @@ -1,11 +0,0 @@ -[project] -name = "core" -version = "0.1.0" -description = "Add your description here" -authors = [{ name = "Nick Wall", email = "mail@walln.dev" }] -requires-python = "==3.11.*" -dependencies = ["requests>=2.32.3"] - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" diff --git a/examples/aws-python/core/src/core/__init__.py b/examples/aws-python/core/src/core/__init__.py deleted file mode 100644 index 437615c6c1..0000000000 --- a/examples/aws-python/core/src/core/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -from core.db import get_user - - -def hello() -> str: - return "Hello from core!" - - -__all__ = ["get_user", "hello"] diff --git a/examples/aws-python/core/src/core/db.py b/examples/aws-python/core/src/core/db.py deleted file mode 100644 index c719b87ba4..0000000000 --- a/examples/aws-python/core/src/core/db.py +++ /dev/null @@ -1,5 +0,0 @@ -def get_user(user_id: str) -> dict: - return { - "user_id": user_id, - "name": "John Doe", - } diff --git a/examples/aws-python/core/src/core/ping.py b/examples/aws-python/core/src/core/ping.py deleted file mode 100644 index c13cfd5726..0000000000 --- a/examples/aws-python/core/src/core/ping.py +++ /dev/null @@ -1,5 +0,0 @@ -import requests - - -def ping(): - return requests.get("https://api.github.com").status_code diff --git a/examples/aws-python/core/src/core/py.typed b/examples/aws-python/core/src/core/py.typed deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-python/functions/pyproject.toml b/examples/aws-python/functions/pyproject.toml deleted file mode 100644 index 2d8dfe7819..0000000000 --- a/examples/aws-python/functions/pyproject.toml +++ /dev/null @@ -1,14 +0,0 @@ -[project] -name = "functions" -version = "0.1.0" -description = "Lambda function handlers" -dependencies = ["core", "sst-sdk"] -requires-python = "==3.11.*" - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" - -[tool.uv.sources] -core = { workspace = true } -sst-sdk = { git = "https://github.com/anomalyco/sst.git", branch = "dev", subdirectory = "sdk/python" } diff --git a/examples/aws-python/functions/src/functions/__init__.py b/examples/aws-python/functions/src/functions/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-python/functions/src/functions/api.py b/examples/aws-python/functions/src/functions/api.py deleted file mode 100644 index dec26af61f..0000000000 --- a/examples/aws-python/functions/src/functions/api.py +++ /dev/null @@ -1,23 +0,0 @@ -from sst import Resource -from functions.shared import foo -from core.db import get_user -from core.ping import ping - -def handler(event, context): - print("Function invoked from Python") - - # Share code within the same workspace package - print(foo()) - - # Share code between workspace packages - res = ping() - print(get_user("1234")) - print("Ping result:", res) - - # Use the SST SDK to access resources - print(f"Resource.MyLinkableValue.foo: {Resource.MyLinkableValue.foo}") - - return { - "statusCode": 200, - "body": f"{Resource.MyLinkableValue.foo} from Python!", - } diff --git a/examples/aws-python/functions/src/functions/shared.py b/examples/aws-python/functions/src/functions/shared.py deleted file mode 100644 index 1f022956c6..0000000000 --- a/examples/aws-python/functions/src/functions/shared.py +++ /dev/null @@ -1,2 +0,0 @@ -def foo(): - return "bar" diff --git a/examples/aws-python/pyproject.toml b/examples/aws-python/pyproject.toml deleted file mode 100644 index 177fb56105..0000000000 --- a/examples/aws-python/pyproject.toml +++ /dev/null @@ -1,16 +0,0 @@ -[project] -name = "aws-python" -version = "0.1.0" -description = "A SST app" -authors = [{ name = "Nick Wall", email = "mail@walln.dev" }] -dependencies = [] - -# It is recommended to specify your python version to match your Lambda runtime otherwise you may -# encounter issues with dependencies. -requires-python = "==3.11.*" - -[tool.uv.workspace] -members = ["functions", "core"] - -[tool.uv.sources] -sst-sdk = { git = "https://github.com/anomalyco/sst.git", subdirectory = "sdk/python", branch = "dev" } diff --git a/examples/aws-python/sst.config.ts b/examples/aws-python/sst.config.ts deleted file mode 100644 index fc3f7c2cc0..0000000000 --- a/examples/aws-python/sst.config.ts +++ /dev/null @@ -1,102 +0,0 @@ -/// - -/** - * ## AWS Lambda Python - * - * SST uses [uv](https://docs.astral.sh/uv/) to manage your Python runtime, make - * sure you have it [installed](https://docs.astral.sh/uv/getting-started/installation/). - * - * Any [uv workspace](https://docs.astral.sh/uv/concepts/projects/workspaces/#workspace-sources) - * package can be built and deployed as a Lambda function using SST. Drop-in mode - * is currently not supported. - * - * :::note - * Each function is packaged with only the dependencies from its own `pyproject.toml` - * and any workspace packages it depends on. - * ::: - * - * In this example we deploy a handler from the `functions/` directory. It depends - * on shared code from another uv workspace in the `core/` directory. - * - * ```txt - * ├── sst.config.ts - * ├── pyproject.toml - * ├── core - * │ ├── pyproject.toml - * │ └── src - * │ └── core - * │ └── __init__.py - * └── functions - * ├── pyproject.toml - * └── src - * └── functions - * ├── __init__.py - * └── api.py - * ``` - * - * The `handler` is the path to the handler file and the name of the handler function - * in it. - * - * ```ts title="sst.config.ts" {2} - * new sst.aws.Function("PythonFunction", { - * handler: "functions/src/functions/api.handler", - * runtime: "python3.11", - * link: [linkableValue], - * url: true, - * }); - * ``` - * - * SST will traverse up from the handler path and look for the nearest - * `pyproject.toml`. And will throw an error if it can't find one. - * - * To access linked resources, you can use the SST SDK. - * - * ```py title="functions/src/functions/api.py" {1} - * from sst import Resource - * - * def handler(event, context): - * print(Resource.MyLinkableValue.foo) - * ``` - * - * Where the `sst-sdk` package can be added to your `pyproject.toml`. - * - * ```toml title="functions/pyproject.toml" - * [project] - * dependencies = ["sst-sdk"] - * - * [tool.uv.sources] - * sst-sdk = { git = "https://github.com/anomalyco/sst.git", subdirectory = "sdk/python", branch = "dev" } - * ``` - * - * You also want to set the Python version in your `pyproject.toml` to the same - * version as the one in Lambda. - * - * ```toml title="functions/pyproject.toml" - * requires-python = "==3.11.*" - * ``` - * - * This makes sure that your functions work the same in `sst dev` as `sst deploy`. - */ -export default $config({ - app(input) { - return { - name: "aws-python", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const linkableValue = new sst.Linkable("MyLinkableValue", { - properties: { - foo: "Hello World", - }, - }); - - new sst.aws.Function("PythonFunction", { - handler: "functions/src/functions/api.handler", - runtime: "python3.11", - link: [linkableValue], - url: true, - }); - }, -}); diff --git a/examples/aws-python/tsconfig.json b/examples/aws-python/tsconfig.json deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/examples/aws-python/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/examples/aws-queue/package.json b/examples/aws-queue/package.json deleted file mode 100644 index def9afd4f2..0000000000 --- a/examples/aws-queue/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "aws-queue", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "deploy": "go run ../../cmd/sst deploy", - "remove": "go run ../../cmd/sst remove", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "@types/aws-lambda": "^8.10.149", - "sst": "file:../../sdk/js" - }, - "dependencies": { - "@aws-sdk/client-sqs": "^3.515.0" - } -} diff --git a/examples/aws-queue/publisher.ts b/examples/aws-queue/publisher.ts deleted file mode 100644 index 3d71dac18d..0000000000 --- a/examples/aws-queue/publisher.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Resource } from "sst"; -import { SQSClient, SendMessageCommand } from "@aws-sdk/client-sqs"; -const client = new SQSClient(); - -export const handler = async (event) => { - // send a message - await client.send( - new SendMessageCommand({ - QueueUrl: Resource.MyQueue.url, - MessageBody: "Hello from the subscriber", - }) - ); - - return { - statusCode: 200, - body: JSON.stringify({ status: "sent" }, null, 2), - }; -}; diff --git a/examples/aws-queue/sst.config.ts b/examples/aws-queue/sst.config.ts deleted file mode 100644 index 8e9cb97906..0000000000 --- a/examples/aws-queue/sst.config.ts +++ /dev/null @@ -1,102 +0,0 @@ -/// - -/** - * ## Subscribe to queues - * - * Create an SQS queue, subscribe to it, and publish to it from a function. - * - * ```ts title="sst.config.ts" - * const queue = new sst.aws.Queue("MyQueue"); - * queue.subscribe("subscriber.handler"); - * - * const app = new sst.aws.Function("MyApp", { - * handler: "publisher.handler", - * link: [queue], - * url: true, - * }); - * - * return { - * app: app.url, - * queue: queue.url, - * }; - * ``` - * - * The subscriber will read messages from the queue in batches. This array of messages exists on the `Records` property of the `SQSEvent`. - * - * ```ts title="subscriber.ts" - * import type { SQSEvent, SQSHandler } from "aws-lambda"; - * - * export const handler: SQSHandler = async (event: SQSEvent) => { - * for (const record of event.Records){ - * // Message bodies are always strings - * console.log(record.body) - * } - * return; - * }; - * ``` - * - * By default, all messages in the batch become visible in the queue again if an error occurs. This can lead to unnecessary extra processing and messages being processed more than once. The solution is to enable [partial batch responsese](https://docs.aws.amazon.com/lambda/latest/dg/services-sqs-errorhandling.html#services-sqs-batchfailurereporting) and return which specific messages within the batch should be made visible again in the queue. - * - * Update the queue subscriber. - * - * ```ts title="sst.config.ts" - * queue.subscribe("subscriber.handler", { - * batch: { - * partialResponses: true, - * } - * }); - * ``` - * - * Then update the handler to return the failed items. - * - * ```ts title="subscriber.ts" - * import type { SQSEvent, SQSHandler } from "aws-lambda"; - * - * export const handler: SQSHandler = async (event: SQSEvent) => { - * const batchItemFailures = [] - * for (const record of event.Records){ - * try { - * console.log(record.body) - * if (Math.random() < 0.1){ - * throw new Error("An error occurred") - * } - * } - * catch (e) { - * batchItemFailures.push({ itemIdentifier: record.messageId }); - * } - * } - * - * // Failed items will be made visible in the queue again - * return { batchItemFailures }; - * }; - * ``` - * - */ -export default $config({ - app(input) { - return { - name: "aws-queue", - home: "aws", - removal: input.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const queue = new sst.aws.Queue("MyQueue"); - queue.subscribe("subscriber.handler", { - batch: { - partialResponses: true, - } - }); - - const app = new sst.aws.Function("MyApp", { - handler: "publisher.handler", - link: [queue], - url: true, - }); - - return { - app: app.url, - queue: queue.url, - }; - }, -}); diff --git a/examples/aws-queue/subscriber.ts b/examples/aws-queue/subscriber.ts deleted file mode 100644 index 7fbec8d5c1..0000000000 --- a/examples/aws-queue/subscriber.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { SQSEvent, SQSHandler } from "aws-lambda"; - -export const handler: SQSHandler = async (event: SQSEvent) => { - const batchItemFailures = [] - for (const record of event.Records){ - try { - console.log(record.body) - if (Math.random() < 0.1){ - throw new Error("An error occurred") - } - } - catch (e) { - batchItemFailures.push({ itemIdentifier: record.messageId }); - } - } - - // Failed items will be made visible in the queue again - return { batchItemFailures }; -}; diff --git a/examples/aws-quota-increase/package.json b/examples/aws-quota-increase/package.json deleted file mode 100644 index ddfcda6b92..0000000000 --- a/examples/aws-quota-increase/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-quota-increase", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-quota-increase/sst.config.ts b/examples/aws-quota-increase/sst.config.ts deleted file mode 100644 index 6ce0343ca3..0000000000 --- a/examples/aws-quota-increase/sst.config.ts +++ /dev/null @@ -1,28 +0,0 @@ -/// - -/** - * ## AWS Quota Increase - * - * Use the Pulumi AWS provider to request an increase to an AWS service quota. - * In this example, we increase the Lambda concurrent executions quota. - * - * You can find service and quota codes in the - * [AWS Service Quotas console](https://console.aws.amazon.com/servicequotas) or by running - * `aws service-quotas list-service-quotas --service-code `. - */ -export default $config({ - app(input) { - return { - name: "aws-quota-increase", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - new aws.servicequotas.ServiceQuota("LambdaConcurrentExecutions", { - serviceCode: "lambda", - quotaCode: "L-B99A9384", - value: 2000, - }); - }, -}); diff --git a/examples/aws-rails/.dockerignore b/examples/aws-rails/.dockerignore deleted file mode 100644 index 00ce171646..0000000000 --- a/examples/aws-rails/.dockerignore +++ /dev/null @@ -1,52 +0,0 @@ -# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files. - -# Ignore git directory. -/.git/ -/.gitignore - -# Ignore bundler config. -/.bundle - -# Ignore all environment files (except templates). -/.env* -!/.env*.erb - -# Ignore all default key files. -/config/master.key -/config/credentials/*.key - -# Ignore all logfiles and tempfiles. -/log/* -/tmp/* -!/log/.keep -!/tmp/.keep - -# Ignore pidfiles, but keep the directory. -/tmp/pids/* -!/tmp/pids/.keep - -# Ignore storage (uploaded files in development and any SQLite databases). -/storage/* -!/storage/.keep -/tmp/storage/* -!/tmp/storage/.keep - -# Ignore assets. -/node_modules/ -/app/assets/builds/* -!/app/assets/builds/.keep -/public/assets - -# Ignore CI service files. -/.github - -# Ignore development files -/.devcontainer - -# Ignore Docker-related files -/.dockerignore -/Dockerfile* - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-rails/.gitattributes b/examples/aws-rails/.gitattributes deleted file mode 100644 index 8dc4323435..0000000000 --- a/examples/aws-rails/.gitattributes +++ /dev/null @@ -1,9 +0,0 @@ -# See https://git-scm.com/docs/gitattributes for more about git attribute files. - -# Mark the database schema as having been generated. -db/schema.rb linguist-generated - -# Mark any vendored files as having been vendored. -vendor/* linguist-vendored -config/credentials/*.yml.enc diff=rails_credentials -config/credentials.yml.enc diff=rails_credentials diff --git a/examples/aws-rails/.github/dependabot.yml b/examples/aws-rails/.github/dependabot.yml deleted file mode 100644 index f0527e6be1..0000000000 --- a/examples/aws-rails/.github/dependabot.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: 2 -updates: -- package-ecosystem: bundler - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 10 -- package-ecosystem: github-actions - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 10 diff --git a/examples/aws-rails/.github/workflows/ci.yml b/examples/aws-rails/.github/workflows/ci.yml deleted file mode 100644 index 00af91f692..0000000000 --- a/examples/aws-rails/.github/workflows/ci.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: CI - -on: - pull_request: - push: - branches: [ main ] - -jobs: - scan_ruby: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: .ruby-version - bundler-cache: true - - - name: Scan for common Rails security vulnerabilities using static analysis - run: bin/brakeman --no-pager - - scan_js: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: .ruby-version - bundler-cache: true - - - name: Scan for security vulnerabilities in JavaScript dependencies - run: bin/importmap audit - - lint: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: .ruby-version - bundler-cache: true - - - name: Lint code for consistent style - run: bin/rubocop -f github - - test: - runs-on: ubuntu-latest - - # services: - # redis: - # image: redis - # ports: - # - 6379:6379 - # options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 - steps: - - name: Install packages - run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl libjemalloc2 libvips sqlite3 - - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: .ruby-version - bundler-cache: true - - - name: Run tests - env: - RAILS_ENV: test - # REDIS_URL: redis://localhost:6379/0 - run: bin/rails db:test:prepare test test:system - - - name: Keep screenshots from failed system tests - uses: actions/upload-artifact@v4 - if: failure() - with: - name: screenshots - path: ${{ github.workspace }}/tmp/screenshots - if-no-files-found: ignore diff --git a/examples/aws-rails/.gitignore b/examples/aws-rails/.gitignore deleted file mode 100644 index 4aaf1022e5..0000000000 --- a/examples/aws-rails/.gitignore +++ /dev/null @@ -1,35 +0,0 @@ -# See https://help.github.com/articles/ignoring-files for more about ignoring files. -# -# Temporary files generated by your text editor or operating system -# belong in git's global ignore instead: -# `$XDG_CONFIG_HOME/git/ignore` or `~/.config/git/ignore` - -# Ignore bundler config. -/.bundle - -# Ignore all environment files (except templates). -/.env* -!/.env*.erb - -# Ignore all logfiles and tempfiles. -/log/* -/tmp/* -!/log/.keep -!/tmp/.keep - -# Ignore pidfiles, but keep the directory. -/tmp/pids/* -!/tmp/pids/ -!/tmp/pids/.keep - -# Ignore storage (uploaded files in development and any SQLite databases). -/storage/* -!/storage/.keep -/tmp/storage/* -!/tmp/storage/ -!/tmp/storage/.keep - -/public/assets - -# Ignore master key for decrypting credentials and more. -/config/master.key diff --git a/examples/aws-rails/.rubocop.yml b/examples/aws-rails/.rubocop.yml deleted file mode 100644 index f9d86d4a54..0000000000 --- a/examples/aws-rails/.rubocop.yml +++ /dev/null @@ -1,8 +0,0 @@ -# Omakase Ruby styling for Rails -inherit_gem: { rubocop-rails-omakase: rubocop.yml } - -# Overwrite or add rules to create your own house style -# -# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]` -# Layout/SpaceInsideArrayLiteralBrackets: -# Enabled: false diff --git a/examples/aws-rails/.ruby-version b/examples/aws-rails/.ruby-version deleted file mode 100644 index 6d5369b963..0000000000 --- a/examples/aws-rails/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -ruby-3.3.4 diff --git a/examples/aws-rails/Dockerfile b/examples/aws-rails/Dockerfile deleted file mode 100644 index 2cb400ed0c..0000000000 --- a/examples/aws-rails/Dockerfile +++ /dev/null @@ -1,69 +0,0 @@ -# syntax = docker/dockerfile:1 - -# This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand: -# docker build -t my-app . -# docker run -d -p 80:80 -p 443:443 --name my-app -e RAILS_MASTER_KEY= my-app - -# Make sure RUBY_VERSION matches the Ruby version in .ruby-version -ARG RUBY_VERSION=3.3.4 -FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base - -# Rails app lives here -WORKDIR /rails - -# Install base packages -RUN apt-get update -qq && \ - apt-get install --no-install-recommends -y curl libjemalloc2 libvips sqlite3 && \ - rm -rf /var/lib/apt/lists /var/cache/apt/archives - -# Set production environment -ENV RAILS_ENV="production" \ - BUNDLE_DEPLOYMENT="1" \ - BUNDLE_PATH="/usr/local/bundle" \ - BUNDLE_WITHOUT="development" - -# Throw-away build stage to reduce size of final image -FROM base AS build - -# Install packages needed to build gems -RUN apt-get update -qq && \ - apt-get install --no-install-recommends -y build-essential git pkg-config && \ - rm -rf /var/lib/apt/lists /var/cache/apt/archives - -# Install application gems -COPY Gemfile Gemfile.lock ./ -RUN bundle install && \ - rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \ - bundle exec bootsnap precompile --gemfile - -# Copy application code -COPY . . - -# Precompile bootsnap code for faster boot times -RUN bundle exec bootsnap precompile app/ lib/ - -# Precompiling assets for production without requiring secret RAILS_MASTER_KEY -RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile - - - - -# Final stage for app image -FROM base - -# Copy built artifacts: gems, application -COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}" -COPY --from=build /rails /rails - -# Run and own only the runtime files as a non-root user for security -RUN groupadd --system --gid 1000 rails && \ - useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \ - chown -R rails:rails db log storage tmp -USER 1000:1000 - -# Entrypoint prepares the database. -ENTRYPOINT ["/rails/bin/docker-entrypoint"] - -# Start the server by default, this can be overwritten at runtime -EXPOSE 3000 -CMD ["./bin/rails", "server"] diff --git a/examples/aws-rails/Gemfile b/examples/aws-rails/Gemfile deleted file mode 100644 index 6f0b5c34d8..0000000000 --- a/examples/aws-rails/Gemfile +++ /dev/null @@ -1,59 +0,0 @@ -source "https://rubygems.org" - -# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" -gem "rails", "~> 7.2.1" -# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] -gem "sprockets-rails" -# Use sqlite3 as the database for Active Record -gem "sqlite3", ">= 1.4" -# Use the Puma web server [https://github.com/puma/puma] -gem "puma", ">= 5.0" -# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] -gem "importmap-rails" -# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] -gem "turbo-rails" -# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] -gem "stimulus-rails" -# Build JSON APIs with ease [https://github.com/rails/jbuilder] -gem "jbuilder" -# Use Redis adapter to run Action Cable in production -# gem "redis", ">= 4.0.1" - -# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] -# gem "kredis" - -# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] -# gem "bcrypt", "~> 3.1.7" - -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem "tzinfo-data", platforms: %i[ windows jruby ] - -# Reduces boot times through caching; required in config/boot.rb -gem "bootsnap", require: false - -# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] -# gem "image_processing", "~> 1.2" - -group :development, :test do - # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem - gem "debug", platforms: %i[ mri windows ], require: "debug/prelude" - - # Static analysis for security vulnerabilities [https://brakemanscanner.org/] - gem "brakeman", require: false - - # Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/] - gem "rubocop-rails-omakase", require: false -end - -group :development do - # Use console on exceptions pages [https://github.com/rails/web-console] - gem "web-console" -end - -group :test do - # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] - gem "capybara" - gem "selenium-webdriver" -end - -gem "aws-sdk-s3", "~> 1.166" diff --git a/examples/aws-rails/Gemfile.lock b/examples/aws-rails/Gemfile.lock deleted file mode 100644 index b1e77a3e8c..0000000000 --- a/examples/aws-rails/Gemfile.lock +++ /dev/null @@ -1,344 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - actioncable (7.2.1) - actionpack (= 7.2.1) - activesupport (= 7.2.1) - nio4r (~> 2.0) - websocket-driver (>= 0.6.1) - zeitwerk (~> 2.6) - actionmailbox (7.2.1) - actionpack (= 7.2.1) - activejob (= 7.2.1) - activerecord (= 7.2.1) - activestorage (= 7.2.1) - activesupport (= 7.2.1) - mail (>= 2.8.0) - actionmailer (7.2.1) - actionpack (= 7.2.1) - actionview (= 7.2.1) - activejob (= 7.2.1) - activesupport (= 7.2.1) - mail (>= 2.8.0) - rails-dom-testing (~> 2.2) - actionpack (7.2.1) - actionview (= 7.2.1) - activesupport (= 7.2.1) - nokogiri (>= 1.8.5) - racc - rack (>= 2.2.4, < 3.2) - rack-session (>= 1.0.1) - rack-test (>= 0.6.3) - rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - useragent (~> 0.16) - actiontext (7.2.1) - actionpack (= 7.2.1) - activerecord (= 7.2.1) - activestorage (= 7.2.1) - activesupport (= 7.2.1) - globalid (>= 0.6.0) - nokogiri (>= 1.8.5) - actionview (7.2.1) - activesupport (= 7.2.1) - builder (~> 3.1) - erubi (~> 1.11) - rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - activejob (7.2.1) - activesupport (= 7.2.1) - globalid (>= 0.3.6) - activemodel (7.2.1) - activesupport (= 7.2.1) - activerecord (7.2.1) - activemodel (= 7.2.1) - activesupport (= 7.2.1) - timeout (>= 0.4.0) - activestorage (7.2.1) - actionpack (= 7.2.1) - activejob (= 7.2.1) - activerecord (= 7.2.1) - activesupport (= 7.2.1) - marcel (~> 1.0) - activesupport (7.2.1) - base64 - bigdecimal - concurrent-ruby (~> 1.0, >= 1.3.1) - connection_pool (>= 2.2.5) - drb - i18n (>= 1.6, < 2) - logger (>= 1.4.2) - minitest (>= 5.1) - securerandom (>= 0.3) - tzinfo (~> 2.0, >= 2.0.5) - addressable (2.8.7) - public_suffix (>= 2.0.2, < 7.0) - ast (2.4.2) - aws-eventstream (1.3.0) - aws-partitions (1.978.0) - aws-sdk-core (3.209.0) - aws-eventstream (~> 1, >= 1.3.0) - aws-partitions (~> 1, >= 1.651.0) - aws-sigv4 (~> 1.9) - jmespath (~> 1, >= 1.6.1) - aws-sdk-kms (1.94.0) - aws-sdk-core (~> 3, >= 3.207.0) - aws-sigv4 (~> 1.5) - aws-sdk-s3 (1.166.0) - aws-sdk-core (~> 3, >= 3.207.0) - aws-sdk-kms (~> 1) - aws-sigv4 (~> 1.5) - aws-sigv4 (1.10.0) - aws-eventstream (~> 1, >= 1.0.2) - base64 (0.2.0) - bigdecimal (3.1.8) - bindex (0.8.1) - bootsnap (1.18.4) - msgpack (~> 1.2) - brakeman (6.2.1) - racc - builder (3.3.0) - capybara (3.40.0) - addressable - matrix - mini_mime (>= 0.1.3) - nokogiri (~> 1.11) - rack (>= 1.6.0) - rack-test (>= 0.6.3) - regexp_parser (>= 1.5, < 3.0) - xpath (~> 3.2) - concurrent-ruby (1.3.4) - connection_pool (2.4.1) - crass (1.0.6) - date (3.3.4) - debug (1.9.2) - irb (~> 1.10) - reline (>= 0.3.8) - drb (2.2.1) - erubi (1.13.0) - globalid (1.2.1) - activesupport (>= 6.1) - i18n (1.14.6) - concurrent-ruby (~> 1.0) - importmap-rails (2.0.1) - actionpack (>= 6.0.0) - activesupport (>= 6.0.0) - railties (>= 6.0.0) - io-console (0.7.2) - irb (1.14.0) - rdoc (>= 4.0.0) - reline (>= 0.4.2) - jbuilder (2.13.0) - actionview (>= 5.0.0) - activesupport (>= 5.0.0) - jmespath (1.6.2) - json (2.7.2) - language_server-protocol (3.17.0.3) - logger (1.6.1) - loofah (2.22.0) - crass (~> 1.0.2) - nokogiri (>= 1.12.0) - mail (2.8.1) - mini_mime (>= 0.1.1) - net-imap - net-pop - net-smtp - marcel (1.0.4) - matrix (0.4.2) - mini_mime (1.1.5) - minitest (5.25.1) - msgpack (1.7.2) - net-imap (0.4.16) - date - net-protocol - net-pop (0.1.2) - net-protocol - net-protocol (0.2.2) - timeout - net-smtp (0.5.0) - net-protocol - nio4r (2.7.3) - nokogiri (1.16.7-aarch64-linux) - racc (~> 1.4) - nokogiri (1.16.7-arm-linux) - racc (~> 1.4) - nokogiri (1.16.7-arm64-darwin) - racc (~> 1.4) - nokogiri (1.16.7-x86-linux) - racc (~> 1.4) - nokogiri (1.16.7-x86_64-darwin) - racc (~> 1.4) - nokogiri (1.16.7-x86_64-linux) - racc (~> 1.4) - parallel (1.26.3) - parser (3.3.5.0) - ast (~> 2.4.1) - racc - psych (5.1.2) - stringio - public_suffix (6.0.1) - puma (6.4.3) - nio4r (~> 2.0) - racc (1.8.1) - rack (3.1.7) - rack-session (2.0.0) - rack (>= 3.0.0) - rack-test (2.1.0) - rack (>= 1.3) - rackup (2.1.0) - rack (>= 3) - webrick (~> 1.8) - rails (7.2.1) - actioncable (= 7.2.1) - actionmailbox (= 7.2.1) - actionmailer (= 7.2.1) - actionpack (= 7.2.1) - actiontext (= 7.2.1) - actionview (= 7.2.1) - activejob (= 7.2.1) - activemodel (= 7.2.1) - activerecord (= 7.2.1) - activestorage (= 7.2.1) - activesupport (= 7.2.1) - bundler (>= 1.15.0) - railties (= 7.2.1) - rails-dom-testing (2.2.0) - activesupport (>= 5.0.0) - minitest - nokogiri (>= 1.6) - rails-html-sanitizer (1.6.0) - loofah (~> 2.21) - nokogiri (~> 1.14) - railties (7.2.1) - actionpack (= 7.2.1) - activesupport (= 7.2.1) - irb (~> 1.13) - rackup (>= 1.0.0) - rake (>= 12.2) - thor (~> 1.0, >= 1.2.2) - zeitwerk (~> 2.6) - rainbow (3.1.1) - rake (13.2.1) - rdoc (6.7.0) - psych (>= 4.0.0) - regexp_parser (2.9.2) - reline (0.5.10) - io-console (~> 0.5) - rexml (3.3.7) - rubocop (1.66.1) - json (~> 2.3) - language_server-protocol (>= 3.17.0) - parallel (~> 1.10) - parser (>= 3.3.0.2) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 2.4, < 3.0) - rubocop-ast (>= 1.32.2, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.32.3) - parser (>= 3.3.1.0) - rubocop-minitest (0.36.0) - rubocop (>= 1.61, < 2.0) - rubocop-ast (>= 1.31.1, < 2.0) - rubocop-performance (1.22.1) - rubocop (>= 1.48.1, < 2.0) - rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rails (2.26.2) - activesupport (>= 4.2.0) - rack (>= 1.1) - rubocop (>= 1.52.0, < 2.0) - rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rails-omakase (1.0.0) - rubocop - rubocop-minitest - rubocop-performance - rubocop-rails - ruby-progressbar (1.13.0) - rubyzip (2.3.2) - securerandom (0.3.1) - selenium-webdriver (4.25.0) - base64 (~> 0.2) - logger (~> 1.4) - rexml (~> 3.2, >= 3.2.5) - rubyzip (>= 1.2.2, < 3.0) - websocket (~> 1.0) - sprockets (4.2.1) - concurrent-ruby (~> 1.0) - rack (>= 2.2.4, < 4) - sprockets-rails (3.5.2) - actionpack (>= 6.1) - activesupport (>= 6.1) - sprockets (>= 3.0.0) - sqlite3 (2.0.4-aarch64-linux-gnu) - sqlite3 (2.0.4-aarch64-linux-musl) - sqlite3 (2.0.4-arm-linux-gnu) - sqlite3 (2.0.4-arm-linux-musl) - sqlite3 (2.0.4-arm64-darwin) - sqlite3 (2.0.4-x86-linux-gnu) - sqlite3 (2.0.4-x86-linux-musl) - sqlite3 (2.0.4-x86_64-darwin) - sqlite3 (2.0.4-x86_64-linux-gnu) - sqlite3 (2.0.4-x86_64-linux-musl) - stimulus-rails (1.3.4) - railties (>= 6.0.0) - stringio (3.1.1) - thor (1.3.2) - timeout (0.4.1) - turbo-rails (2.0.10) - actionpack (>= 6.0.0) - railties (>= 6.0.0) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - unicode-display_width (2.6.0) - useragent (0.16.10) - web-console (4.2.1) - actionview (>= 6.0.0) - activemodel (>= 6.0.0) - bindex (>= 0.4.0) - railties (>= 6.0.0) - webrick (1.8.2) - websocket (1.2.11) - websocket-driver (0.7.6) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.5) - xpath (3.2.0) - nokogiri (~> 1.8) - zeitwerk (2.6.18) - -PLATFORMS - aarch64-linux - aarch64-linux-gnu - aarch64-linux-musl - arm-linux - arm-linux-gnu - arm-linux-musl - arm64-darwin - x86-linux - x86-linux-gnu - x86-linux-musl - x86_64-darwin - x86_64-linux - x86_64-linux-gnu - x86_64-linux-musl - -DEPENDENCIES - aws-sdk-s3 (~> 1.166) - bootsnap - brakeman - capybara - debug - importmap-rails - jbuilder - puma (>= 5.0) - rails (~> 7.2.1) - rubocop-rails-omakase - selenium-webdriver - sprockets-rails - sqlite3 (>= 1.4) - stimulus-rails - turbo-rails - tzinfo-data - web-console - -BUNDLED WITH - 2.5.11 diff --git a/examples/aws-rails/Rakefile b/examples/aws-rails/Rakefile deleted file mode 100644 index 9a5ea7383a..0000000000 --- a/examples/aws-rails/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -# Add your own tasks in files placed in lib/tasks ending in .rake, -# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. - -require_relative "config/application" - -Rails.application.load_tasks diff --git a/examples/aws-rails/app/assets/config/manifest.js b/examples/aws-rails/app/assets/config/manifest.js deleted file mode 100644 index ddd546a0be..0000000000 --- a/examples/aws-rails/app/assets/config/manifest.js +++ /dev/null @@ -1,4 +0,0 @@ -//= link_tree ../images -//= link_directory ../stylesheets .css -//= link_tree ../../javascript .js -//= link_tree ../../../vendor/javascript .js diff --git a/examples/aws-rails/app/assets/images/.keep b/examples/aws-rails/app/assets/images/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/app/assets/stylesheets/application.css b/examples/aws-rails/app/assets/stylesheets/application.css deleted file mode 100644 index 288b9ab718..0000000000 --- a/examples/aws-rails/app/assets/stylesheets/application.css +++ /dev/null @@ -1,15 +0,0 @@ -/* - * This is a manifest file that'll be compiled into application.css, which will include all the files - * listed below. - * - * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's - * vendor/assets/stylesheets directory can be referenced here using a relative path. - * - * You're free to add application-wide styles to this file and they'll appear at the bottom of the - * compiled file so the styles you add here take precedence over styles defined in any other CSS - * files in this directory. Styles in this file should be added after the last require_* statement. - * It is generally better to create a new file per style scope. - * - *= require_tree . - *= require_self - */ diff --git a/examples/aws-rails/app/channels/application_cable/channel.rb b/examples/aws-rails/app/channels/application_cable/channel.rb deleted file mode 100644 index d672697283..0000000000 --- a/examples/aws-rails/app/channels/application_cable/channel.rb +++ /dev/null @@ -1,4 +0,0 @@ -module ApplicationCable - class Channel < ActionCable::Channel::Base - end -end diff --git a/examples/aws-rails/app/channels/application_cable/connection.rb b/examples/aws-rails/app/channels/application_cable/connection.rb deleted file mode 100644 index 0ff5442f47..0000000000 --- a/examples/aws-rails/app/channels/application_cable/connection.rb +++ /dev/null @@ -1,4 +0,0 @@ -module ApplicationCable - class Connection < ActionCable::Connection::Base - end -end diff --git a/examples/aws-rails/app/controllers/application_controller.rb b/examples/aws-rails/app/controllers/application_controller.rb deleted file mode 100644 index 0d95db22b4..0000000000 --- a/examples/aws-rails/app/controllers/application_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -class ApplicationController < ActionController::Base - # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has. - allow_browser versions: :modern -end diff --git a/examples/aws-rails/app/controllers/concerns/.keep b/examples/aws-rails/app/controllers/concerns/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/app/controllers/uploads_controller.rb b/examples/aws-rails/app/controllers/uploads_controller.rb deleted file mode 100644 index ed99b774d6..0000000000 --- a/examples/aws-rails/app/controllers/uploads_controller.rb +++ /dev/null @@ -1,16 +0,0 @@ -class UploadsController < ApplicationController - skip_before_action :verify_authenticity_token - - def new - end - - def create - blob = ActiveStorage::Blob.create_and_upload!( - io: params[:file].tempfile, - filename: params[:file].original_filename, - content_type: params[:file].content_type - ) - url = "https://#{ActiveStorage::Blob.service.bucket.name}.s3.amazonaws.com/#{blob.key}" - redirect_to root_path(uploaded_url: url) - end -end diff --git a/examples/aws-rails/app/helpers/application_helper.rb b/examples/aws-rails/app/helpers/application_helper.rb deleted file mode 100644 index de6be7945c..0000000000 --- a/examples/aws-rails/app/helpers/application_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module ApplicationHelper -end diff --git a/examples/aws-rails/app/helpers/uploads_helper.rb b/examples/aws-rails/app/helpers/uploads_helper.rb deleted file mode 100644 index f4f8250f5e..0000000000 --- a/examples/aws-rails/app/helpers/uploads_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module UploadsHelper -end diff --git a/examples/aws-rails/app/javascript/application.js b/examples/aws-rails/app/javascript/application.js deleted file mode 100644 index 0d7b49404c..0000000000 --- a/examples/aws-rails/app/javascript/application.js +++ /dev/null @@ -1,3 +0,0 @@ -// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails -import "@hotwired/turbo-rails" -import "controllers" diff --git a/examples/aws-rails/app/javascript/controllers/application.js b/examples/aws-rails/app/javascript/controllers/application.js deleted file mode 100644 index 1213e85c7a..0000000000 --- a/examples/aws-rails/app/javascript/controllers/application.js +++ /dev/null @@ -1,9 +0,0 @@ -import { Application } from "@hotwired/stimulus" - -const application = Application.start() - -// Configure Stimulus development experience -application.debug = false -window.Stimulus = application - -export { application } diff --git a/examples/aws-rails/app/javascript/controllers/hello_controller.js b/examples/aws-rails/app/javascript/controllers/hello_controller.js deleted file mode 100644 index 5975c0789d..0000000000 --- a/examples/aws-rails/app/javascript/controllers/hello_controller.js +++ /dev/null @@ -1,7 +0,0 @@ -import { Controller } from "@hotwired/stimulus" - -export default class extends Controller { - connect() { - this.element.textContent = "Hello World!" - } -} diff --git a/examples/aws-rails/app/javascript/controllers/index.js b/examples/aws-rails/app/javascript/controllers/index.js deleted file mode 100644 index 1156bf8362..0000000000 --- a/examples/aws-rails/app/javascript/controllers/index.js +++ /dev/null @@ -1,4 +0,0 @@ -// Import and register all your controllers from the importmap via controllers/**/*_controller -import { application } from "controllers/application" -import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading" -eagerLoadControllersFrom("controllers", application) diff --git a/examples/aws-rails/app/jobs/application_job.rb b/examples/aws-rails/app/jobs/application_job.rb deleted file mode 100644 index d394c3d106..0000000000 --- a/examples/aws-rails/app/jobs/application_job.rb +++ /dev/null @@ -1,7 +0,0 @@ -class ApplicationJob < ActiveJob::Base - # Automatically retry jobs that encountered a deadlock - # retry_on ActiveRecord::Deadlocked - - # Most jobs are safe to ignore if the underlying records are no longer available - # discard_on ActiveJob::DeserializationError -end diff --git a/examples/aws-rails/app/mailers/application_mailer.rb b/examples/aws-rails/app/mailers/application_mailer.rb deleted file mode 100644 index 3c34c8148f..0000000000 --- a/examples/aws-rails/app/mailers/application_mailer.rb +++ /dev/null @@ -1,4 +0,0 @@ -class ApplicationMailer < ActionMailer::Base - default from: "from@example.com" - layout "mailer" -end diff --git a/examples/aws-rails/app/models/application_record.rb b/examples/aws-rails/app/models/application_record.rb deleted file mode 100644 index b63caeb8a5..0000000000 --- a/examples/aws-rails/app/models/application_record.rb +++ /dev/null @@ -1,3 +0,0 @@ -class ApplicationRecord < ActiveRecord::Base - primary_abstract_class -end diff --git a/examples/aws-rails/app/models/concerns/.keep b/examples/aws-rails/app/models/concerns/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/app/views/layouts/application.html.erb b/examples/aws-rails/app/views/layouts/application.html.erb deleted file mode 100644 index bcf1d45a7d..0000000000 --- a/examples/aws-rails/app/views/layouts/application.html.erb +++ /dev/null @@ -1,23 +0,0 @@ - - - - <%= content_for(:title) || "Aws Rails" %> - - - <%= csrf_meta_tags %> - <%= csp_meta_tag %> - - <%= yield :head %> - - - - - - <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> - <%= javascript_importmap_tags %> - - - - <%= yield %> - - diff --git a/examples/aws-rails/app/views/layouts/mailer.html.erb b/examples/aws-rails/app/views/layouts/mailer.html.erb deleted file mode 100644 index 3aac9002ed..0000000000 --- a/examples/aws-rails/app/views/layouts/mailer.html.erb +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - <%= yield %> - - diff --git a/examples/aws-rails/app/views/layouts/mailer.text.erb b/examples/aws-rails/app/views/layouts/mailer.text.erb deleted file mode 100644 index 37f0bddbd7..0000000000 --- a/examples/aws-rails/app/views/layouts/mailer.text.erb +++ /dev/null @@ -1 +0,0 @@ -<%= yield %> diff --git a/examples/aws-rails/app/views/pwa/manifest.json.erb b/examples/aws-rails/app/views/pwa/manifest.json.erb deleted file mode 100644 index 107dff4398..0000000000 --- a/examples/aws-rails/app/views/pwa/manifest.json.erb +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "AwsRails", - "icons": [ - { - "src": "/icon.png", - "type": "image/png", - "sizes": "512x512" - }, - { - "src": "/icon.png", - "type": "image/png", - "sizes": "512x512", - "purpose": "maskable" - } - ], - "start_url": "/", - "display": "standalone", - "scope": "/", - "description": "AwsRails.", - "theme_color": "red", - "background_color": "red" -} diff --git a/examples/aws-rails/app/views/pwa/service-worker.js b/examples/aws-rails/app/views/pwa/service-worker.js deleted file mode 100644 index b3a13fb7bb..0000000000 --- a/examples/aws-rails/app/views/pwa/service-worker.js +++ /dev/null @@ -1,26 +0,0 @@ -// Add a service worker for processing Web Push notifications: -// -// self.addEventListener("push", async (event) => { -// const { title, options } = await event.data.json() -// event.waitUntil(self.registration.showNotification(title, options)) -// }) -// -// self.addEventListener("notificationclick", function(event) { -// event.notification.close() -// event.waitUntil( -// clients.matchAll({ type: "window" }).then((clientList) => { -// for (let i = 0; i < clientList.length; i++) { -// let client = clientList[i] -// let clientPath = (new URL(client.url)).pathname -// -// if (clientPath == event.notification.data.path && "focus" in client) { -// return client.focus() -// } -// } -// -// if (clients.openWindow) { -// return clients.openWindow(event.notification.data.path) -// } -// }) -// ) -// }) diff --git a/examples/aws-rails/app/views/uploads/create.html.erb b/examples/aws-rails/app/views/uploads/create.html.erb deleted file mode 100644 index 40f4a011c9..0000000000 --- a/examples/aws-rails/app/views/uploads/create.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

Uploads#create

-

Find me in app/views/uploads/create.html.erb

diff --git a/examples/aws-rails/app/views/uploads/new.html.erb b/examples/aws-rails/app/views/uploads/new.html.erb deleted file mode 100644 index ff92b3994d..0000000000 --- a/examples/aws-rails/app/views/uploads/new.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -

Upload an Image

- -<%= form_with(url: upload_path, local: true, multipart: true) do |form| %> -
- <%= form.label :file %> - <%= form.file_field :file %> -
- - <%= form.submit 'Upload Image' %> -<% end %> - -<% if params[:uploaded_url].present? %> -

Your file has been uploaded! You can access it here:

- <%= link_to params[:uploaded_url], params[:uploaded_url], target: '_blank' %> -<% end %> \ No newline at end of file diff --git a/examples/aws-rails/bin/brakeman b/examples/aws-rails/bin/brakeman deleted file mode 100755 index ace1c9ba08..0000000000 --- a/examples/aws-rails/bin/brakeman +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env ruby -require "rubygems" -require "bundler/setup" - -ARGV.unshift("--ensure-latest") - -load Gem.bin_path("brakeman", "brakeman") diff --git a/examples/aws-rails/bin/bundle b/examples/aws-rails/bin/bundle deleted file mode 100755 index 50da5fdf9e..0000000000 --- a/examples/aws-rails/bin/bundle +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -# -# This file was generated by Bundler. -# -# The application 'bundle' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require "rubygems" - -m = Module.new do - module_function - - def invoked_as_script? - File.expand_path($0) == File.expand_path(__FILE__) - end - - def env_var_version - ENV["BUNDLER_VERSION"] - end - - def cli_arg_version - return unless invoked_as_script? # don't want to hijack other binstubs - return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` - bundler_version = nil - update_index = nil - ARGV.each_with_index do |a, i| - if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN) - bundler_version = a - end - next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ - bundler_version = $1 - update_index = i - end - bundler_version - end - - def gemfile - gemfile = ENV["BUNDLE_GEMFILE"] - return gemfile if gemfile && !gemfile.empty? - - File.expand_path("../Gemfile", __dir__) - end - - def lockfile - lockfile = - case File.basename(gemfile) - when "gems.rb" then gemfile.sub(/\.rb$/, ".locked") - else "#{gemfile}.lock" - end - File.expand_path(lockfile) - end - - def lockfile_version - return unless File.file?(lockfile) - lockfile_contents = File.read(lockfile) - return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ - Regexp.last_match(1) - end - - def bundler_requirement - @bundler_requirement ||= - env_var_version || - cli_arg_version || - bundler_requirement_for(lockfile_version) - end - - def bundler_requirement_for(version) - return "#{Gem::Requirement.default}.a" unless version - - bundler_gem_version = Gem::Version.new(version) - - bundler_gem_version.approximate_recommendation - end - - def load_bundler! - ENV["BUNDLE_GEMFILE"] ||= gemfile - - activate_bundler - end - - def activate_bundler - gem_error = activation_error_handling do - gem "bundler", bundler_requirement - end - return if gem_error.nil? - require_error = activation_error_handling do - require "bundler/version" - end - return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) - warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" - exit 42 - end - - def activation_error_handling - yield - nil - rescue StandardError, LoadError => e - e - end -end - -m.load_bundler! - -if m.invoked_as_script? - load Gem.bin_path("bundler", "bundle") -end diff --git a/examples/aws-rails/bin/docker-entrypoint b/examples/aws-rails/bin/docker-entrypoint deleted file mode 100755 index 840d093a9a..0000000000 --- a/examples/aws-rails/bin/docker-entrypoint +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -e - -# Enable jemalloc for reduced memory usage and latency. -if [ -z "${LD_PRELOAD+x}" ] && [ -f /usr/lib/*/libjemalloc.so.2 ]; then - export LD_PRELOAD="$(echo /usr/lib/*/libjemalloc.so.2)" -fi - -# If running the rails server then create or migrate existing database -if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then - ./bin/rails db:prepare -fi - -exec "${@}" diff --git a/examples/aws-rails/bin/importmap b/examples/aws-rails/bin/importmap deleted file mode 100755 index 36502ab16c..0000000000 --- a/examples/aws-rails/bin/importmap +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby - -require_relative "../config/application" -require "importmap/commands" diff --git a/examples/aws-rails/bin/rails b/examples/aws-rails/bin/rails deleted file mode 100755 index efc0377492..0000000000 --- a/examples/aws-rails/bin/rails +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby -APP_PATH = File.expand_path("../config/application", __dir__) -require_relative "../config/boot" -require "rails/commands" diff --git a/examples/aws-rails/bin/rake b/examples/aws-rails/bin/rake deleted file mode 100755 index 4fbf10b960..0000000000 --- a/examples/aws-rails/bin/rake +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby -require_relative "../config/boot" -require "rake" -Rake.application.run diff --git a/examples/aws-rails/bin/rubocop b/examples/aws-rails/bin/rubocop deleted file mode 100755 index 40330c0ff1..0000000000 --- a/examples/aws-rails/bin/rubocop +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env ruby -require "rubygems" -require "bundler/setup" - -# explicit rubocop config increases performance slightly while avoiding config confusion. -ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__)) - -load Gem.bin_path("rubocop", "rubocop") diff --git a/examples/aws-rails/bin/setup b/examples/aws-rails/bin/setup deleted file mode 100755 index ee2b54d365..0000000000 --- a/examples/aws-rails/bin/setup +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env ruby -require "fileutils" - -APP_ROOT = File.expand_path("..", __dir__) -APP_NAME = "aws-rails" - -def system!(*args) - system(*args, exception: true) -end - -FileUtils.chdir APP_ROOT do - # This script is a way to set up or update your development environment automatically. - # This script is idempotent, so that you can run it at any time and get an expectable outcome. - # Add necessary setup steps to this file. - - puts "== Installing dependencies ==" - system! "gem install bundler --conservative" - system("bundle check") || system!("bundle install") - - # puts "\n== Copying sample files ==" - # unless File.exist?("config/database.yml") - # FileUtils.cp "config/database.yml.sample", "config/database.yml" - # end - - puts "\n== Preparing database ==" - system! "bin/rails db:prepare" - - puts "\n== Removing old logs and tempfiles ==" - system! "bin/rails log:clear tmp:clear" - - puts "\n== Restarting application server ==" - system! "bin/rails restart" - - # puts "\n== Configuring puma-dev ==" - # system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}" - # system "curl -Is https://#{APP_NAME}.test/up | head -n 1" -end diff --git a/examples/aws-rails/config.ru b/examples/aws-rails/config.ru deleted file mode 100644 index 4a3c09a688..0000000000 --- a/examples/aws-rails/config.ru +++ /dev/null @@ -1,6 +0,0 @@ -# This file is used by Rack-based servers to start the application. - -require_relative "config/environment" - -run Rails.application -Rails.application.load_server diff --git a/examples/aws-rails/config/application.rb b/examples/aws-rails/config/application.rb deleted file mode 100644 index 2cfa3ae1b8..0000000000 --- a/examples/aws-rails/config/application.rb +++ /dev/null @@ -1,27 +0,0 @@ -require_relative "boot" - -require "rails/all" - -# Require the gems listed in Gemfile, including any gems -# you've limited to :test, :development, or :production. -Bundler.require(*Rails.groups) - -module AwsRails - class Application < Rails::Application - # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.2 - - # Please, add to the `ignore` list any other `lib` subdirectories that do - # not contain `.rb` files, or that should not be reloaded or eager loaded. - # Common ones are `templates`, `generators`, or `middleware`, for example. - config.autoload_lib(ignore: %w[assets tasks]) - - # Configuration for the application, engines, and railties goes here. - # - # These settings can be overridden in specific environments using the files - # in config/environments, which are processed later. - # - # config.time_zone = "Central Time (US & Canada)" - # config.eager_load_paths << Rails.root.join("extras") - end -end diff --git a/examples/aws-rails/config/boot.rb b/examples/aws-rails/config/boot.rb deleted file mode 100644 index 988a5ddc46..0000000000 --- a/examples/aws-rails/config/boot.rb +++ /dev/null @@ -1,4 +0,0 @@ -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) - -require "bundler/setup" # Set up gems listed in the Gemfile. -require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/examples/aws-rails/config/cable.yml b/examples/aws-rails/config/cable.yml deleted file mode 100644 index 054e1be48a..0000000000 --- a/examples/aws-rails/config/cable.yml +++ /dev/null @@ -1,10 +0,0 @@ -development: - adapter: async - -test: - adapter: test - -production: - adapter: redis - url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> - channel_prefix: aws_rails_production diff --git a/examples/aws-rails/config/credentials.yml.enc b/examples/aws-rails/config/credentials.yml.enc deleted file mode 100644 index d4211c0f89..0000000000 --- a/examples/aws-rails/config/credentials.yml.enc +++ /dev/null @@ -1 +0,0 @@ -vEY6y3HLNkBS+aarod5P3ix27Cd3nK+QXtCvgMCUsEh1EmWcwsCRYJk/hBzwZyKtjHjTIUTJ7oeF2NkzKbYeAPOTBazpjAg7GC5oVAy1GLYVTZM+h0c58AWMLCjww8v1/i4Ju4AgcigPyNSlary4KnCjJO6HGsBXGHCH9FxHIasacQYz6ZvblHWQ1qEshmdfY3OWStRjyNCJS3a6KzTrFDwpMwP1s6ZyJxGCUj4ldqTI8s/EUyWdRcNg+CRyaXA/ElwgF78uvQe8RSHtC0ited59VtgaUIXRyKnrJ3Tz1kNYFICmERrny5rrOUFpnEbaujGdPj4xLhiMGQtuafzW1c32dZgFehchE7fIuR2jP+nDpIbglJ3z5MXnLNPanIkai4Xq6X2UVlZwCXhFUOE2cEc3eVUm--KhoSxVW3jXtFnuv8--AoRt1fW/zNvGsMnm7tOOZQ== \ No newline at end of file diff --git a/examples/aws-rails/config/database.yml b/examples/aws-rails/config/database.yml deleted file mode 100644 index c480dcb827..0000000000 --- a/examples/aws-rails/config/database.yml +++ /dev/null @@ -1,31 +0,0 @@ -# SQLite. Versions 3.8.0 and up are supported. -# gem install sqlite3 -# -# Ensure the SQLite 3 gem is defined in your Gemfile -# gem "sqlite3" -# -default: &default - adapter: sqlite3 - pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - timeout: 5000 - -development: - <<: *default - database: storage/development.sqlite3 - -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - <<: *default - database: storage/test.sqlite3 - -# SQLite3 write its data on the local filesystem, as such it requires -# persistent disks. If you are deploying to a managed service, you should -# make sure it provides disk persistence, as many don't. -# -# Similarly, if you deploy your application as a Docker container, you must -# ensure the database is located in a persisted volume. -production: - <<: *default - database: /tmp/production.sqlite3 diff --git a/examples/aws-rails/config/environment.rb b/examples/aws-rails/config/environment.rb deleted file mode 100644 index cac5315775..0000000000 --- a/examples/aws-rails/config/environment.rb +++ /dev/null @@ -1,5 +0,0 @@ -# Load the Rails application. -require_relative "application" - -# Initialize the Rails application. -Rails.application.initialize! diff --git a/examples/aws-rails/config/environments/development.rb b/examples/aws-rails/config/environments/development.rb deleted file mode 100644 index fc5d7282e3..0000000000 --- a/examples/aws-rails/config/environments/development.rb +++ /dev/null @@ -1,81 +0,0 @@ -require "active_support/core_ext/integer/time" - -Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - - # In the development environment your application's code is reloaded any time - # it changes. This slows down response time but is perfect for development - # since you don't have to restart the web server when you make code changes. - config.enable_reloading = true - - # Do not eager load code on boot. - config.eager_load = false - - # Show full error reports. - config.consider_all_requests_local = true - - # Enable server timing. - config.server_timing = true - - # Enable/disable caching. By default caching is disabled. - # Run rails dev:cache to toggle caching. - if Rails.root.join("tmp/caching-dev.txt").exist? - config.action_controller.perform_caching = true - config.action_controller.enable_fragment_cache_logging = true - - config.cache_store = :memory_store - config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" } - else - config.action_controller.perform_caching = false - - config.cache_store = :null_store - end - - # Store uploaded files on the local file system (see config/storage.yml for options). - config.active_storage.service = :amazon - - # Don't care if the mailer can't send. - config.action_mailer.raise_delivery_errors = false - - # Disable caching for Action Mailer templates even if Action Controller - # caching is enabled. - config.action_mailer.perform_caching = false - - config.action_mailer.default_url_options = { host: "localhost", port: 3000 } - - # Print deprecation notices to the Rails logger. - config.active_support.deprecation = :log - - # Raise exceptions for disallowed deprecations. - config.active_support.disallowed_deprecation = :raise - - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] - - # Raise an error on page load if there are pending migrations. - config.active_record.migration_error = :page_load - - # Highlight code that triggered database queries in logs. - config.active_record.verbose_query_logs = true - - # Highlight code that enqueued background job in logs. - config.active_job.verbose_enqueue_logs = true - - # Suppress logger output for asset requests. - config.assets.quiet = true - - # Raises error for missing translations. - # config.i18n.raise_on_missing_translations = true - - # Annotate rendered view with file names. - config.action_view.annotate_rendered_view_with_filenames = true - - # Uncomment if you wish to allow Action Cable access from any origin. - # config.action_cable.disable_request_forgery_protection = true - - # Raise error when a before_action's only/except options reference missing actions. - config.action_controller.raise_on_missing_callback_actions = true - - # Apply autocorrection by RuboCop to files generated by `bin/rails generate`. - # config.generators.apply_rubocop_autocorrect_after_generate! -end diff --git a/examples/aws-rails/config/environments/production.rb b/examples/aws-rails/config/environments/production.rb deleted file mode 100644 index ff26add9ba..0000000000 --- a/examples/aws-rails/config/environments/production.rb +++ /dev/null @@ -1,102 +0,0 @@ -require "active_support/core_ext/integer/time" - -Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - - # Code is not reloaded between requests. - config.enable_reloading = false - - # Eager load code on boot. This eager loads most of Rails and - # your application in memory, allowing both threaded web servers - # and those relying on copy on write to perform better. - # Rake tasks automatically ignore this option for performance. - config.eager_load = true - - # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false - config.action_controller.perform_caching = true - - # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment - # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files). - # config.require_master_key = true - - # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead. - # config.public_file_server.enabled = false - - # Compress CSS using a preprocessor. - # config.assets.css_compressor = :sass - - # Do not fall back to assets pipeline if a precompiled asset is missed. - config.assets.compile = false - - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.asset_host = "http://assets.example.com" - - # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache - # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX - - # Store uploaded files on the local file system (see config/storage.yml for options). - config.active_storage.service = :amazon - - # Mount Action Cable outside main process or domain. - # config.action_cable.mount_path = nil - # config.action_cable.url = "wss://example.com/cable" - # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] - - # Assume all access to the app is happening through a SSL-terminating reverse proxy. - # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. - # config.assume_ssl = true - - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true - - # Skip http-to-https redirect for the default health check endpoint. - # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } - - # Log to STDOUT by default - config.logger = ActiveSupport::Logger.new(STDOUT) - .tap { |logger| logger.formatter = ::Logger::Formatter.new } - .then { |logger| ActiveSupport::TaggedLogging.new(logger) } - - # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] - - # "info" includes generic and useful information about system operation, but avoids logging too much - # information to avoid inadvertent exposure of personally identifiable information (PII). If you - # want to log everything, set the level to "debug". - config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") - - # Use a different cache store in production. - # config.cache_store = :mem_cache_store - - # Use a real queuing backend for Active Job (and separate queues per environment). - # config.active_job.queue_adapter = :resque - # config.active_job.queue_name_prefix = "aws_rails_production" - - # Disable caching for Action Mailer templates even if Action Controller - # caching is enabled. - config.action_mailer.perform_caching = false - - # Ignore bad email addresses and do not raise email delivery errors. - # Set this to true and configure the email server for immediate delivery to raise delivery errors. - # config.action_mailer.raise_delivery_errors = false - - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation cannot be found). - config.i18n.fallbacks = true - - # Don't log any deprecations. - config.active_support.report_deprecations = false - - # Do not dump schema after migrations. - config.active_record.dump_schema_after_migration = false - - # Enable DNS rebinding protection and other `Host` header attacks. - # config.hosts = [ - # "example.com", # Allow requests from example.com - # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` - # ] - # Skip DNS rebinding protection for the default health check endpoint. - # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } -end diff --git a/examples/aws-rails/config/environments/test.rb b/examples/aws-rails/config/environments/test.rb deleted file mode 100644 index 0c616a1bf5..0000000000 --- a/examples/aws-rails/config/environments/test.rb +++ /dev/null @@ -1,67 +0,0 @@ -require "active_support/core_ext/integer/time" - -# The test environment is used exclusively to run your application's -# test suite. You never need to work with it otherwise. Remember that -# your test database is "scratch space" for the test suite and is wiped -# and recreated between test runs. Don't rely on the data there! - -Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - - # While tests run files are not watched, reloading is not necessary. - config.enable_reloading = false - - # Eager loading loads your entire application. When running a single test locally, - # this is usually not necessary, and can slow down your test suite. However, it's - # recommended that you enable it in continuous integration systems to ensure eager - # loading is working properly before deploying your code. - config.eager_load = ENV["CI"].present? - - # Configure public file server for tests with Cache-Control for performance. - config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" } - - # Show full error reports and disable caching. - config.consider_all_requests_local = true - config.action_controller.perform_caching = false - config.cache_store = :null_store - - # Render exception templates for rescuable exceptions and raise for other exceptions. - config.action_dispatch.show_exceptions = :rescuable - - # Disable request forgery protection in test environment. - config.action_controller.allow_forgery_protection = false - - # Store uploaded files on the local file system in a temporary directory. - config.active_storage.service = :test - - # Disable caching for Action Mailer templates even if Action Controller - # caching is enabled. - config.action_mailer.perform_caching = false - - # Tell Action Mailer not to deliver emails to the real world. - # The :test delivery method accumulates sent emails in the - # ActionMailer::Base.deliveries array. - config.action_mailer.delivery_method = :test - - # Unlike controllers, the mailer instance doesn't have any context about the - # incoming request so you'll need to provide the :host parameter yourself. - config.action_mailer.default_url_options = { host: "www.example.com" } - - # Print deprecation notices to the stderr. - config.active_support.deprecation = :stderr - - # Raise exceptions for disallowed deprecations. - config.active_support.disallowed_deprecation = :raise - - # Tell Active Support which deprecation messages to disallow. - config.active_support.disallowed_deprecation_warnings = [] - - # Raises error for missing translations. - # config.i18n.raise_on_missing_translations = true - - # Annotate rendered view with file names. - # config.action_view.annotate_rendered_view_with_filenames = true - - # Raise error when a before_action's only/except options reference missing actions. - config.action_controller.raise_on_missing_callback_actions = true -end diff --git a/examples/aws-rails/config/importmap.rb b/examples/aws-rails/config/importmap.rb deleted file mode 100644 index 909dfc542d..0000000000 --- a/examples/aws-rails/config/importmap.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Pin npm packages by running ./bin/importmap - -pin "application" -pin "@hotwired/turbo-rails", to: "turbo.min.js" -pin "@hotwired/stimulus", to: "stimulus.min.js" -pin "@hotwired/stimulus-loading", to: "stimulus-loading.js" -pin_all_from "app/javascript/controllers", under: "controllers" diff --git a/examples/aws-rails/config/initializers/assets.rb b/examples/aws-rails/config/initializers/assets.rb deleted file mode 100644 index bd5bcd2b6a..0000000000 --- a/examples/aws-rails/config/initializers/assets.rb +++ /dev/null @@ -1,12 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Version of your assets, change this if you want to expire all your assets. -Rails.application.config.assets.version = "1.0" - -# Add additional assets to the asset load path. -# Rails.application.config.assets.paths << Emoji.images_path - -# Precompile additional assets. -# application.js, application.css, and all non-JS/CSS in the app/assets -# folder are already added. -# Rails.application.config.assets.precompile += %w[ admin.js admin.css ] diff --git a/examples/aws-rails/config/initializers/content_security_policy.rb b/examples/aws-rails/config/initializers/content_security_policy.rb deleted file mode 100644 index b3076b38fe..0000000000 --- a/examples/aws-rails/config/initializers/content_security_policy.rb +++ /dev/null @@ -1,25 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Define an application-wide content security policy. -# See the Securing Rails Applications Guide for more information: -# https://guides.rubyonrails.org/security.html#content-security-policy-header - -# Rails.application.configure do -# config.content_security_policy do |policy| -# policy.default_src :self, :https -# policy.font_src :self, :https, :data -# policy.img_src :self, :https, :data -# policy.object_src :none -# policy.script_src :self, :https -# policy.style_src :self, :https -# # Specify URI for violation reports -# # policy.report_uri "/csp-violation-report-endpoint" -# end -# -# # Generate session nonces for permitted importmap, inline scripts, and inline styles. -# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } -# config.content_security_policy_nonce_directives = %w(script-src style-src) -# -# # Report violations without enforcing the policy. -# # config.content_security_policy_report_only = true -# end diff --git a/examples/aws-rails/config/initializers/filter_parameter_logging.rb b/examples/aws-rails/config/initializers/filter_parameter_logging.rb deleted file mode 100644 index c010b83ddd..0000000000 --- a/examples/aws-rails/config/initializers/filter_parameter_logging.rb +++ /dev/null @@ -1,8 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. -# Use this to limit dissemination of sensitive information. -# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. -Rails.application.config.filter_parameters += [ - :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn -] diff --git a/examples/aws-rails/config/initializers/inflections.rb b/examples/aws-rails/config/initializers/inflections.rb deleted file mode 100644 index 3860f659ea..0000000000 --- a/examples/aws-rails/config/initializers/inflections.rb +++ /dev/null @@ -1,16 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Add new inflection rules using the following format. Inflections -# are locale specific, and you may define rules for as many different -# locales as you wish. All of these examples are active by default: -# ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.plural /^(ox)$/i, "\\1en" -# inflect.singular /^(ox)en/i, "\\1" -# inflect.irregular "person", "people" -# inflect.uncountable %w( fish sheep ) -# end - -# These inflection rules are supported but not enabled by default: -# ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.acronym "RESTful" -# end diff --git a/examples/aws-rails/config/initializers/permissions_policy.rb b/examples/aws-rails/config/initializers/permissions_policy.rb deleted file mode 100644 index 7db3b9577e..0000000000 --- a/examples/aws-rails/config/initializers/permissions_policy.rb +++ /dev/null @@ -1,13 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Define an application-wide HTTP permissions policy. For further -# information see: https://developers.google.com/web/updates/2018/06/feature-policy - -# Rails.application.config.permissions_policy do |policy| -# policy.camera :none -# policy.gyroscope :none -# policy.microphone :none -# policy.usb :none -# policy.fullscreen :self -# policy.payment :self, "https://secure.example.com" -# end diff --git a/examples/aws-rails/config/locales/en.yml b/examples/aws-rails/config/locales/en.yml deleted file mode 100644 index 6c349ae5e3..0000000000 --- a/examples/aws-rails/config/locales/en.yml +++ /dev/null @@ -1,31 +0,0 @@ -# Files in the config/locales directory are used for internationalization and -# are automatically loaded by Rails. If you want to use locales other than -# English, add the necessary files in this directory. -# -# To use the locales, use `I18n.t`: -# -# I18n.t "hello" -# -# In views, this is aliased to just `t`: -# -# <%= t("hello") %> -# -# To use a different locale, set it with `I18n.locale`: -# -# I18n.locale = :es -# -# This would use the information in config/locales/es.yml. -# -# To learn more about the API, please read the Rails Internationalization guide -# at https://guides.rubyonrails.org/i18n.html. -# -# Be aware that YAML interprets the following case-insensitive strings as -# booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings -# must be quoted to be interpreted as strings. For example: -# -# en: -# "yes": yup -# enabled: "ON" - -en: - hello: "Hello world" diff --git a/examples/aws-rails/config/puma.rb b/examples/aws-rails/config/puma.rb deleted file mode 100644 index 03c166f4cf..0000000000 --- a/examples/aws-rails/config/puma.rb +++ /dev/null @@ -1,34 +0,0 @@ -# This configuration file will be evaluated by Puma. The top-level methods that -# are invoked here are part of Puma's configuration DSL. For more information -# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. - -# Puma starts a configurable number of processes (workers) and each process -# serves each request in a thread from an internal thread pool. -# -# The ideal number of threads per worker depends both on how much time the -# application spends waiting for IO operations and on how much you wish to -# to prioritize throughput over latency. -# -# As a rule of thumb, increasing the number of threads will increase how much -# traffic a given process can handle (throughput), but due to CRuby's -# Global VM Lock (GVL) it has diminishing returns and will degrade the -# response time (latency) of the application. -# -# The default is set to 3 threads as it's deemed a decent compromise between -# throughput and latency for the average Rails application. -# -# Any libraries that use a connection pool or another resource pool should -# be configured to provide at least as many connections as the number of -# threads. This includes Active Record's `pool` parameter in `database.yml`. -threads_count = ENV.fetch("RAILS_MAX_THREADS", 3) -threads threads_count, threads_count - -# Specifies the `port` that Puma will listen on to receive requests; default is 3000. -port ENV.fetch("PORT", 3000) - -# Allow puma to be restarted by `bin/rails restart` command. -plugin :tmp_restart - -# Specify the PID file. Defaults to tmp/pids/server.pid in development. -# In other environments, only set the PID file if requested. -pidfile ENV["PIDFILE"] if ENV["PIDFILE"] diff --git a/examples/aws-rails/config/routes.rb b/examples/aws-rails/config/routes.rb deleted file mode 100644 index 0a9237b608..0000000000 --- a/examples/aws-rails/config/routes.rb +++ /dev/null @@ -1,16 +0,0 @@ -Rails.application.routes.draw do - # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html - root 'uploads#new' - post 'upload', to: 'uploads#create' - - # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. - # Can be used by load balancers and uptime monitors to verify that the app is live. - get "up" => "rails/health#show", as: :rails_health_check - - # Render dynamic PWA files from app/views/pwa/* - get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker - get "manifest" => "rails/pwa#manifest", as: :pwa_manifest - - # Defines the root path route ("/") - # root "posts#index" -end diff --git a/examples/aws-rails/config/storage.yml b/examples/aws-rails/config/storage.yml deleted file mode 100644 index 823aa5f7ff..0000000000 --- a/examples/aws-rails/config/storage.yml +++ /dev/null @@ -1,34 +0,0 @@ -test: - service: Disk - root: <%= Rails.root.join("tmp/storage") %> - -local: - service: Disk - root: <%= Rails.root.join("storage") %> - -# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) -amazon: - service: S3 - # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> - # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> - # region: us-east-1 - bucket: <%= JSON.parse(ENV["SST_RESOURCE_MyBucket"])["name"] %> - -# Remember not to checkin your GCS keyfile to a repository -# google: -# service: GCS -# project: your_project -# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> -# bucket: your_own_bucket-<%= Rails.env %> - -# Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) -# microsoft: -# service: AzureStorage -# storage_account_name: your_account_name -# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> -# container: your_container_name-<%= Rails.env %> - -# mirror: -# service: Mirror -# primary: local -# mirrors: [ amazon, google, microsoft ] diff --git a/examples/aws-rails/db/migrate/20240925124201_create_active_storage_tables.active_storage.rb b/examples/aws-rails/db/migrate/20240925124201_create_active_storage_tables.active_storage.rb deleted file mode 100644 index 6bd8bd082a..0000000000 --- a/examples/aws-rails/db/migrate/20240925124201_create_active_storage_tables.active_storage.rb +++ /dev/null @@ -1,57 +0,0 @@ -# This migration comes from active_storage (originally 20170806125915) -class CreateActiveStorageTables < ActiveRecord::Migration[7.0] - def change - # Use Active Record's configured type for primary and foreign keys - primary_key_type, foreign_key_type = primary_and_foreign_key_types - - create_table :active_storage_blobs, id: primary_key_type do |t| - t.string :key, null: false - t.string :filename, null: false - t.string :content_type - t.text :metadata - t.string :service_name, null: false - t.bigint :byte_size, null: false - t.string :checksum - - if connection.supports_datetime_with_precision? - t.datetime :created_at, precision: 6, null: false - else - t.datetime :created_at, null: false - end - - t.index [ :key ], unique: true - end - - create_table :active_storage_attachments, id: primary_key_type do |t| - t.string :name, null: false - t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type - t.references :blob, null: false, type: foreign_key_type - - if connection.supports_datetime_with_precision? - t.datetime :created_at, precision: 6, null: false - else - t.datetime :created_at, null: false - end - - t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true - t.foreign_key :active_storage_blobs, column: :blob_id - end - - create_table :active_storage_variant_records, id: primary_key_type do |t| - t.belongs_to :blob, null: false, index: false, type: foreign_key_type - t.string :variation_digest, null: false - - t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true - t.foreign_key :active_storage_blobs, column: :blob_id - end - end - - private - def primary_and_foreign_key_types - config = Rails.configuration.generators - setting = config.options[config.orm][:primary_key_type] - primary_key_type = setting || :primary_key - foreign_key_type = setting || :bigint - [ primary_key_type, foreign_key_type ] - end -end diff --git a/examples/aws-rails/db/schema.rb b/examples/aws-rails/db/schema.rb deleted file mode 100644 index 19ba58775c..0000000000 --- a/examples/aws-rails/db/schema.rb +++ /dev/null @@ -1,44 +0,0 @@ -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# This file is the source Rails uses to define your schema when running `bin/rails -# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to -# be faster and is potentially less error prone than running all of your -# migrations from scratch. Old migrations may fail to apply correctly if those -# migrations use external dependencies or application code. -# -# It's strongly recommended that you check this file into your version control system. - -ActiveRecord::Schema[7.2].define(version: 2024_09_25_124201) do - create_table "active_storage_attachments", force: :cascade do |t| - t.string "name", null: false - t.string "record_type", null: false - t.bigint "record_id", null: false - t.bigint "blob_id", null: false - t.datetime "created_at", null: false - t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id" - t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true - end - - create_table "active_storage_blobs", force: :cascade do |t| - t.string "key", null: false - t.string "filename", null: false - t.string "content_type" - t.text "metadata" - t.string "service_name", null: false - t.bigint "byte_size", null: false - t.string "checksum" - t.datetime "created_at", null: false - t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true - end - - create_table "active_storage_variant_records", force: :cascade do |t| - t.bigint "blob_id", null: false - t.string "variation_digest", null: false - t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true - end - - add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" - add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" -end diff --git a/examples/aws-rails/db/seeds.rb b/examples/aws-rails/db/seeds.rb deleted file mode 100644 index 4fbd6ed970..0000000000 --- a/examples/aws-rails/db/seeds.rb +++ /dev/null @@ -1,9 +0,0 @@ -# This file should ensure the existence of records required to run the application in every environment (production, -# development, test). The code here should be idempotent so that it can be executed at any point in every environment. -# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). -# -# Example: -# -# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name| -# MovieGenre.find_or_create_by!(name: genre_name) -# end diff --git a/examples/aws-rails/lib/assets/.keep b/examples/aws-rails/lib/assets/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/lib/sst.rb b/examples/aws-rails/lib/sst.rb deleted file mode 100644 index 6b5cda9152..0000000000 --- a/examples/aws-rails/lib/sst.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'json' -module SST - class << self - private - - def parse_resource(resource_name) - env_var = "SST_RESOURCE_#{resource_name}" - parse_json(ENV[env_var]) - end - - def parse_json(json_string) - return nil if json_string.nil? - JSON.parse(json_string) - rescue JSON::ParserError - json_string # Return the original string if it's not valid JSON - end - - end - - def MyService - @MyService ||= parse_resource('MyService') - end - - def MyVpc - @MyVpc ||= parse_resource('MyVpc') - end - - def MyBucket - @MyBucket ||= parse_resource('MyBucket') - end - -end diff --git a/examples/aws-rails/lib/tasks/.keep b/examples/aws-rails/lib/tasks/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/log/.keep b/examples/aws-rails/log/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/public/404.html b/examples/aws-rails/public/404.html deleted file mode 100644 index 2be3af26fc..0000000000 --- a/examples/aws-rails/public/404.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - The page you were looking for doesn't exist (404) - - - - - - -
-
-

The page you were looking for doesn't exist.

-

You may have mistyped the address or the page may have moved.

-
-

If you are the application owner check the logs for more information.

-
- - diff --git a/examples/aws-rails/public/406-unsupported-browser.html b/examples/aws-rails/public/406-unsupported-browser.html deleted file mode 100644 index 7cf1e168e6..0000000000 --- a/examples/aws-rails/public/406-unsupported-browser.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - Your browser is not supported (406) - - - - - - -
-
-

Your browser is not supported.

-

Please upgrade your browser to continue.

-
-
- - diff --git a/examples/aws-rails/public/422.html b/examples/aws-rails/public/422.html deleted file mode 100644 index c08eac0d1d..0000000000 --- a/examples/aws-rails/public/422.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - The change you wanted was rejected (422) - - - - - - -
-
-

The change you wanted was rejected.

-

Maybe you tried to change something you didn't have access to.

-
-

If you are the application owner check the logs for more information.

-
- - diff --git a/examples/aws-rails/public/500.html b/examples/aws-rails/public/500.html deleted file mode 100644 index 78a030af22..0000000000 --- a/examples/aws-rails/public/500.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - We're sorry, but something went wrong (500) - - - - - - -
-
-

We're sorry, but something went wrong.

-
-

If you are the application owner check the logs for more information.

-
- - diff --git a/examples/aws-rails/public/icon.png b/examples/aws-rails/public/icon.png deleted file mode 100644 index f3b5abcbde..0000000000 Binary files a/examples/aws-rails/public/icon.png and /dev/null differ diff --git a/examples/aws-rails/public/icon.svg b/examples/aws-rails/public/icon.svg deleted file mode 100644 index 78307ccd4b..0000000000 --- a/examples/aws-rails/public/icon.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/aws-rails/public/robots.txt b/examples/aws-rails/public/robots.txt deleted file mode 100644 index c19f78ab68..0000000000 --- a/examples/aws-rails/public/robots.txt +++ /dev/null @@ -1 +0,0 @@ -# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/examples/aws-rails/sst.config.ts b/examples/aws-rails/sst.config.ts deleted file mode 100644 index 9e2658ee3f..0000000000 --- a/examples/aws-rails/sst.config.ts +++ /dev/null @@ -1,41 +0,0 @@ -/// - -/** - * ## Rails container - * - * Deploy a Ruby on Rails app in a container with a linked public S3 bucket. - */ -export default $config({ - app(input) { - return { - name: "aws-rails", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public", - }); - const vpc = new sst.aws.Vpc("MyVpc"); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - environment: { - RAILS_MASTER_KEY: (await import("fs")).readFileSync( - "config/master.key", - "utf8" - ), - }, - dev: { - command: "bin/rails server", - }, - link: [bucket], - }); - return { vpc: vpc.id }; - }, -}); diff --git a/examples/aws-rails/storage/.keep b/examples/aws-rails/storage/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/test/application_system_test_case.rb b/examples/aws-rails/test/application_system_test_case.rb deleted file mode 100644 index cee29fd214..0000000000 --- a/examples/aws-rails/test/application_system_test_case.rb +++ /dev/null @@ -1,5 +0,0 @@ -require "test_helper" - -class ApplicationSystemTestCase < ActionDispatch::SystemTestCase - driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ] -end diff --git a/examples/aws-rails/test/channels/application_cable/connection_test.rb b/examples/aws-rails/test/channels/application_cable/connection_test.rb deleted file mode 100644 index 6340bf9c04..0000000000 --- a/examples/aws-rails/test/channels/application_cable/connection_test.rb +++ /dev/null @@ -1,13 +0,0 @@ -require "test_helper" - -module ApplicationCable - class ConnectionTest < ActionCable::Connection::TestCase - # test "connects with cookies" do - # cookies.signed[:user_id] = 42 - # - # connect - # - # assert_equal connection.user_id, "42" - # end - end -end diff --git a/examples/aws-rails/test/controllers/.keep b/examples/aws-rails/test/controllers/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/test/controllers/uploads_controller_test.rb b/examples/aws-rails/test/controllers/uploads_controller_test.rb deleted file mode 100644 index c46b10c54e..0000000000 --- a/examples/aws-rails/test/controllers/uploads_controller_test.rb +++ /dev/null @@ -1,13 +0,0 @@ -require "test_helper" - -class UploadsControllerTest < ActionDispatch::IntegrationTest - test "should get new" do - get uploads_new_url - assert_response :success - end - - test "should get create" do - get uploads_create_url - assert_response :success - end -end diff --git a/examples/aws-rails/test/fixtures/files/.keep b/examples/aws-rails/test/fixtures/files/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/test/helpers/.keep b/examples/aws-rails/test/helpers/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/test/integration/.keep b/examples/aws-rails/test/integration/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/test/mailers/.keep b/examples/aws-rails/test/mailers/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/test/models/.keep b/examples/aws-rails/test/models/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/test/system/.keep b/examples/aws-rails/test/system/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/test/test_helper.rb b/examples/aws-rails/test/test_helper.rb deleted file mode 100644 index 0c22470ec1..0000000000 --- a/examples/aws-rails/test/test_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -ENV["RAILS_ENV"] ||= "test" -require_relative "../config/environment" -require "rails/test_help" - -module ActiveSupport - class TestCase - # Run tests in parallel with specified workers - parallelize(workers: :number_of_processors) - - # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. - fixtures :all - - # Add more helper methods to be used by all tests here... - end -end diff --git a/examples/aws-rails/vendor/.keep b/examples/aws-rails/vendor/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rails/vendor/javascript/.keep b/examples/aws-rails/vendor/javascript/.keep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/aws-rds-instance-mysql-public/.gitignore b/examples/aws-rds-instance-mysql-public/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-rds-instance-mysql-public/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-rds-instance-mysql-public/package.json b/examples/aws-rds-instance-mysql-public/package.json deleted file mode 100644 index 041968a701..0000000000 --- a/examples/aws-rds-instance-mysql-public/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-rds-instance-mysql-public-example", - "version": "1.0.0", - "description": "", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "sst": "file:../../sdk/js" - }, - "devDependencies": { - } -} diff --git a/examples/aws-rds-instance-mysql-public/sst.config.ts b/examples/aws-rds-instance-mysql-public/sst.config.ts deleted file mode 100644 index 1fa876189a..0000000000 --- a/examples/aws-rds-instance-mysql-public/sst.config.ts +++ /dev/null @@ -1,63 +0,0 @@ -/// - -/** - * ## AWS RDS MySQL public - * - * Create a publicly accessible MySQL RDS instance with a security group that - * allows external connections. - */ -export default $config({ - app(input) { - return { - name: "aws-rds-instance-mysql-public", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const MYSQL_PORT = 3306; - const ALL_IPS = '0.0.0.0/0'; - const publicSecurityGroup = new aws.ec2.SecurityGroup( - 'MyPublicSecurityGroup', - { - ingress: [ - { - // Expose to public connection. Remove if not needed - protocol: 'tcp', - fromPort: MYSQL_PORT, - toPort: MYSQL_PORT, - cidrBlocks: [ALL_IPS], - }, - ], - }, - ); - - const identifier = 'my-db-instance'; - - const database = new aws.rds.Instance( - 'MyDbInstanceMySQL', - { - identifier, - engine: 'mysql', - // free-tier - instanceClass: 'db.t3.micro', - allocatedStorage: 20, // free-tier 20GB - // credentials - username: 'dev-user', - password: 'dev-password', - dbName: 'dev-database', - // settings - tags: { Name: identifier }, - skipFinalSnapshot: true, - - // allow public access - vpcSecurityGroupIds: [publicSecurityGroup.id], - publiclyAccessible: true, - }, - ); - - return { - Database: database.address - }; - }, -}); diff --git a/examples/aws-rds-instance-mysql-public/tsconfig.json b/examples/aws-rds-instance-mysql-public/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-rds-instance-mysql-public/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-react-router/.dockerignore b/examples/aws-react-router/.dockerignore deleted file mode 100644 index 9b8d514712..0000000000 --- a/examples/aws-react-router/.dockerignore +++ /dev/null @@ -1,4 +0,0 @@ -.react-router -build -node_modules -README.md \ No newline at end of file diff --git a/examples/aws-react-router/.gitignore b/examples/aws-react-router/.gitignore deleted file mode 100644 index 5913deaa94..0000000000 --- a/examples/aws-react-router/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -.DS_Store -/node_modules/ - -# React Router -/.react-router/ -/build/ - -# sst -.sst diff --git a/examples/aws-react-router/Dockerfile b/examples/aws-react-router/Dockerfile deleted file mode 100644 index 207bf937e3..0000000000 --- a/examples/aws-react-router/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -FROM node:20-alpine AS development-dependencies-env -COPY . /app -WORKDIR /app -RUN npm ci - -FROM node:20-alpine AS production-dependencies-env -COPY ./package.json package-lock.json /app/ -WORKDIR /app -RUN npm ci --omit=dev - -FROM node:20-alpine AS build-env -COPY . /app/ -COPY --from=development-dependencies-env /app/node_modules /app/node_modules -WORKDIR /app -RUN npm run build - -FROM node:20-alpine -COPY ./package.json package-lock.json /app/ -COPY --from=production-dependencies-env /app/node_modules /app/node_modules -COPY --from=build-env /app/build /app/build -WORKDIR /app -CMD ["npm", "run", "start"] \ No newline at end of file diff --git a/examples/aws-react-router/app/app.css b/examples/aws-react-router/app/app.css deleted file mode 100644 index 99345d8218..0000000000 --- a/examples/aws-react-router/app/app.css +++ /dev/null @@ -1,15 +0,0 @@ -@import "tailwindcss"; - -@theme { - --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif, - "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; -} - -html, -body { - @apply bg-white dark:bg-gray-950; - - @media (prefers-color-scheme: dark) { - color-scheme: dark; - } -} diff --git a/examples/aws-react-router/app/root.tsx b/examples/aws-react-router/app/root.tsx deleted file mode 100644 index 9fc663618c..0000000000 --- a/examples/aws-react-router/app/root.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import { - isRouteErrorResponse, - Links, - Meta, - Outlet, - Scripts, - ScrollRestoration, -} from "react-router"; - -import type { Route } from "./+types/root"; -import "./app.css"; - -export const links: Route.LinksFunction = () => [ - { rel: "preconnect", href: "https://fonts.googleapis.com" }, - { - rel: "preconnect", - href: "https://fonts.gstatic.com", - crossOrigin: "anonymous", - }, - { - rel: "stylesheet", - href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap", - }, -]; - -export function Layout({ children }: { children: React.ReactNode }) { - return ( - - - - - - - - - {children} - - - - - ); -} - -export default function App() { - return ; -} - -export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) { - let message = "Oops!"; - let details = "An unexpected error occurred."; - let stack: string | undefined; - - if (isRouteErrorResponse(error)) { - message = error.status === 404 ? "404" : "Error"; - details = - error.status === 404 - ? "The requested page could not be found." - : error.statusText || details; - } else if (import.meta.env.DEV && error && error instanceof Error) { - details = error.message; - stack = error.stack; - } - - return ( -
-

{message}

-

{details}

- {stack && ( -
-          {stack}
-        
- )} -
- ); -} diff --git a/examples/aws-react-router/app/routes.ts b/examples/aws-react-router/app/routes.ts deleted file mode 100644 index 102b402587..0000000000 --- a/examples/aws-react-router/app/routes.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { type RouteConfig, index } from "@react-router/dev/routes"; - -export default [index("routes/home.tsx")] satisfies RouteConfig; diff --git a/examples/aws-react-router/app/routes/home.tsx b/examples/aws-react-router/app/routes/home.tsx deleted file mode 100644 index c61efecfa8..0000000000 --- a/examples/aws-react-router/app/routes/home.tsx +++ /dev/null @@ -1,72 +0,0 @@ -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; -import type { Route } from "./+types/home"; -import { Welcome } from "../welcome/welcome"; - -export function meta({}: Route.MetaArgs) { - return [ - { title: "New React Router App" }, - { name: "description", content: "Welcome to React Router!" }, - ]; -} - -export async function loader() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return { url }; -} - -export default function Home({ loaderData }: Route.ComponentProps) { - const { url } = loaderData; - return ( -
-
-

- Welcome to React Router! -

-
{ - e.preventDefault(); - - const file = (e.target as HTMLFormElement).file.files?.[0]!; - - const image = await fetch(url, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }} - > - - -
-
-
- ); -} diff --git a/examples/aws-react-router/app/welcome/logo-dark.svg b/examples/aws-react-router/app/welcome/logo-dark.svg deleted file mode 100644 index dd82028944..0000000000 --- a/examples/aws-react-router/app/welcome/logo-dark.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/aws-react-router/app/welcome/logo-light.svg b/examples/aws-react-router/app/welcome/logo-light.svg deleted file mode 100644 index 73284929d3..0000000000 --- a/examples/aws-react-router/app/welcome/logo-light.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/aws-react-router/app/welcome/welcome.tsx b/examples/aws-react-router/app/welcome/welcome.tsx deleted file mode 100644 index 8ac6e1d30b..0000000000 --- a/examples/aws-react-router/app/welcome/welcome.tsx +++ /dev/null @@ -1,89 +0,0 @@ -import logoDark from "./logo-dark.svg"; -import logoLight from "./logo-light.svg"; - -export function Welcome() { - return ( -
-
-
-
- React Router - React Router -
-
-
- -
-
-
- ); -} - -const resources = [ - { - href: "https://reactrouter.com/docs", - text: "React Router Docs", - icon: ( - - - - ), - }, - { - href: "https://rmx.as/discord", - text: "Join Discord", - icon: ( - - - - ), - }, -]; diff --git a/examples/aws-react-router/package.json b/examples/aws-react-router/package.json deleted file mode 100644 index eb7861a131..0000000000 --- a/examples/aws-react-router/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "aws-react-router", - "private": true, - "type": "module", - "scripts": { - "build": "react-router build", - "dev": "react-router dev", - "start": "react-router-serve ./build/server/index.js", - "typecheck": "react-router typegen && tsc" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.796.0", - "@aws-sdk/s3-request-presigner": "^3.796.0", - "@react-router/node": "^7.5.2", - "@react-router/serve": "^7.5.2", - "isbot": "^5.1.17", - "react": "^19.0.0", - "react-dom": "^19.0.0", - "react-router": "^7.5.2", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@react-router/dev": "^7.5.2", - "@tailwindcss/vite": "^4.0.0", - "@types/node": "^20", - "@types/react": "^19.0.1", - "@types/react-dom": "^19.0.1", - "react-router-devtools": "^1.1.0", - "tailwindcss": "^4.0.0", - "typescript": "^5.7.2", - "vite": "^5.4.11", - "vite-tsconfig-paths": "^5.1.4" - } -} diff --git a/examples/aws-react-router/public/favicon.ico b/examples/aws-react-router/public/favicon.ico deleted file mode 100644 index 5dbdfcddcb..0000000000 Binary files a/examples/aws-react-router/public/favicon.ico and /dev/null differ diff --git a/examples/aws-react-router/react-router.config.ts b/examples/aws-react-router/react-router.config.ts deleted file mode 100644 index 6ff16f9177..0000000000 --- a/examples/aws-react-router/react-router.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { Config } from "@react-router/dev/config"; - -export default { - // Config options... - // Server-side render by default, to enable SPA mode set this to `false` - ssr: true, -} satisfies Config; diff --git a/examples/aws-react-router/sst.config.ts b/examples/aws-react-router/sst.config.ts deleted file mode 100644 index 97ecb1054f..0000000000 --- a/examples/aws-react-router/sst.config.ts +++ /dev/null @@ -1,21 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-react-router", - removal: input?.stage === "production" ? "retain" : "remove", - protect: ["production"].includes(input?.stage), - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public", - }); - - new sst.aws.React("MyWeb", { - link: [bucket], - }); - }, -}); diff --git a/examples/aws-react-router/tsconfig.json b/examples/aws-react-router/tsconfig.json deleted file mode 100644 index 65fa16a18d..0000000000 --- a/examples/aws-react-router/tsconfig.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "include": [ - "**/*", - "**/.server/**/*", - "**/.client/**/*", - ".react-router/types/**/*" - ], - "compilerOptions": { - "lib": ["DOM", "DOM.Iterable", "ES2022"], - "types": ["node", "vite/client"], - "target": "ES2022", - "module": "ES2022", - "moduleResolution": "bundler", - "jsx": "react-jsx", - "rootDirs": [".", "./.react-router/types"], - "baseUrl": ".", - "paths": { - "~/*": ["./app/*"] - }, - "esModuleInterop": true, - "verbatimModuleSyntax": true, - "noEmit": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "strict": true - },"exclude":["sst.config.ts"] -} diff --git a/examples/aws-react-router/vite.config.ts b/examples/aws-react-router/vite.config.ts deleted file mode 100644 index 4a88d5871c..0000000000 --- a/examples/aws-react-router/vite.config.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { reactRouter } from "@react-router/dev/vite"; -import tailwindcss from "@tailwindcss/vite"; -import { defineConfig } from "vite"; -import tsconfigPaths from "vite-tsconfig-paths"; - -export default defineConfig({ - plugins: [tailwindcss(), reactRouter(), tsconfigPaths()], -}); diff --git a/examples/aws-realtime-nextjs/.gitignore b/examples/aws-realtime-nextjs/.gitignore deleted file mode 100644 index 69d7f97469..0000000000 --- a/examples/aws-realtime-nextjs/.gitignore +++ /dev/null @@ -1,42 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js -.yarn/install-state.gz - -# testing -/coverage - -# next.js -/.next/ -/out/ - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# local env files -.env*.local - -# vercel -.vercel - -# typescript -*.tsbuildinfo -next-env.d.ts - -# sst -.sst - -# open-next -.open-next diff --git a/examples/aws-realtime-nextjs/app/favicon.ico b/examples/aws-realtime-nextjs/app/favicon.ico deleted file mode 100644 index 718d6fea48..0000000000 Binary files a/examples/aws-realtime-nextjs/app/favicon.ico and /dev/null differ diff --git a/examples/aws-realtime-nextjs/app/globals.css b/examples/aws-realtime-nextjs/app/globals.css deleted file mode 100644 index f4bd77c0cc..0000000000 --- a/examples/aws-realtime-nextjs/app/globals.css +++ /dev/null @@ -1,107 +0,0 @@ -:root { - --max-width: 1100px; - --border-radius: 12px; - --font-mono: ui-monospace, Menlo, Monaco, "Cascadia Mono", "Segoe UI Mono", - "Roboto Mono", "Oxygen Mono", "Ubuntu Monospace", "Source Code Pro", - "Fira Mono", "Droid Sans Mono", "Courier New", monospace; - - --foreground-rgb: 0, 0, 0; - --background-start-rgb: 214, 219, 220; - --background-end-rgb: 255, 255, 255; - - --primary-glow: conic-gradient( - from 180deg at 50% 50%, - #16abff33 0deg, - #0885ff33 55deg, - #54d6ff33 120deg, - #0071ff33 160deg, - transparent 360deg - ); - --secondary-glow: radial-gradient( - rgba(255, 255, 255, 1), - rgba(255, 255, 255, 0) - ); - - --tile-start-rgb: 239, 245, 249; - --tile-end-rgb: 228, 232, 233; - --tile-border: conic-gradient( - #00000080, - #00000040, - #00000030, - #00000020, - #00000010, - #00000010, - #00000080 - ); - - --callout-rgb: 238, 240, 241; - --callout-border-rgb: 172, 175, 176; - --card-rgb: 180, 185, 188; - --card-border-rgb: 131, 134, 135; -} - -@media (prefers-color-scheme: dark) { - :root { - --foreground-rgb: 255, 255, 255; - --background-start-rgb: 0, 0, 0; - --background-end-rgb: 0, 0, 0; - - --primary-glow: radial-gradient(rgba(1, 65, 255, 0.4), rgba(1, 65, 255, 0)); - --secondary-glow: linear-gradient( - to bottom right, - rgba(1, 65, 255, 0), - rgba(1, 65, 255, 0), - rgba(1, 65, 255, 0.3) - ); - - --tile-start-rgb: 2, 13, 46; - --tile-end-rgb: 2, 5, 19; - --tile-border: conic-gradient( - #ffffff80, - #ffffff40, - #ffffff30, - #ffffff20, - #ffffff10, - #ffffff10, - #ffffff80 - ); - - --callout-rgb: 20, 20, 20; - --callout-border-rgb: 108, 108, 108; - --card-rgb: 100, 100, 100; - --card-border-rgb: 200, 200, 200; - } -} - -* { - box-sizing: border-box; - padding: 0; - margin: 0; -} - -html, -body { - max-width: 100vw; - overflow-x: hidden; -} - -body { - color: rgb(var(--foreground-rgb)); - background: linear-gradient( - to bottom, - transparent, - rgb(var(--background-end-rgb)) - ) - rgb(var(--background-start-rgb)); -} - -a { - color: inherit; - text-decoration: none; -} - -@media (prefers-color-scheme: dark) { - html { - color-scheme: dark; - } -} diff --git a/examples/aws-realtime-nextjs/app/layout.tsx b/examples/aws-realtime-nextjs/app/layout.tsx deleted file mode 100644 index 3314e4780a..0000000000 --- a/examples/aws-realtime-nextjs/app/layout.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import type { Metadata } from "next"; -import { Inter } from "next/font/google"; -import "./globals.css"; - -const inter = Inter({ subsets: ["latin"] }); - -export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", -}; - -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { - return ( - - {children} - - ); -} diff --git a/examples/aws-realtime-nextjs/app/page.module.css b/examples/aws-realtime-nextjs/app/page.module.css deleted file mode 100644 index 5c4b1e6a2c..0000000000 --- a/examples/aws-realtime-nextjs/app/page.module.css +++ /dev/null @@ -1,230 +0,0 @@ -.main { - display: flex; - flex-direction: column; - justify-content: space-between; - align-items: center; - padding: 6rem; - min-height: 100vh; -} - -.description { - display: inherit; - justify-content: inherit; - align-items: inherit; - font-size: 0.85rem; - max-width: var(--max-width); - width: 100%; - z-index: 2; - font-family: var(--font-mono); -} - -.description a { - display: flex; - justify-content: center; - align-items: center; - gap: 0.5rem; -} - -.description p { - position: relative; - margin: 0; - padding: 1rem; - background-color: rgba(var(--callout-rgb), 0.5); - border: 1px solid rgba(var(--callout-border-rgb), 0.3); - border-radius: var(--border-radius); -} - -.code { - font-weight: 700; - font-family: var(--font-mono); -} - -.grid { - display: grid; - grid-template-columns: repeat(4, minmax(25%, auto)); - max-width: 100%; - width: var(--max-width); -} - -.card { - padding: 1rem 1.2rem; - border-radius: var(--border-radius); - background: rgba(var(--card-rgb), 0); - border: 1px solid rgba(var(--card-border-rgb), 0); - transition: background 200ms, border 200ms; -} - -.card span { - display: inline-block; - transition: transform 200ms; -} - -.card h2 { - font-weight: 600; - margin-bottom: 0.7rem; -} - -.card p { - margin: 0; - opacity: 0.6; - font-size: 0.9rem; - line-height: 1.5; - max-width: 30ch; - text-wrap: balance; -} - -.center { - display: flex; - justify-content: center; - align-items: center; - position: relative; - padding: 4rem 0; -} - -.center::before { - background: var(--secondary-glow); - border-radius: 50%; - width: 480px; - height: 360px; - margin-left: -400px; -} - -.center::after { - background: var(--primary-glow); - width: 240px; - height: 180px; - z-index: -1; -} - -.center::before, -.center::after { - content: ""; - left: 50%; - position: absolute; - filter: blur(45px); - transform: translateZ(0); -} - -.logo { - position: relative; -} -/* Enable hover only on non-touch devices */ -@media (hover: hover) and (pointer: fine) { - .card:hover { - background: rgba(var(--card-rgb), 0.1); - border: 1px solid rgba(var(--card-border-rgb), 0.15); - } - - .card:hover span { - transform: translateX(4px); - } -} - -@media (prefers-reduced-motion) { - .card:hover span { - transform: none; - } -} - -/* Mobile */ -@media (max-width: 700px) { - .content { - padding: 4rem; - } - - .grid { - grid-template-columns: 1fr; - margin-bottom: 120px; - max-width: 320px; - text-align: center; - } - - .card { - padding: 1rem 2.5rem; - } - - .card h2 { - margin-bottom: 0.5rem; - } - - .center { - padding: 8rem 0 6rem; - } - - .center::before { - transform: none; - height: 300px; - } - - .description { - font-size: 0.8rem; - } - - .description a { - padding: 1rem; - } - - .description p, - .description div { - display: flex; - justify-content: center; - position: fixed; - width: 100%; - } - - .description p { - align-items: center; - inset: 0 0 auto; - padding: 2rem 1rem 1.4rem; - border-radius: 0; - border: none; - border-bottom: 1px solid rgba(var(--callout-border-rgb), 0.25); - background: linear-gradient( - to bottom, - rgba(var(--background-start-rgb), 1), - rgba(var(--callout-rgb), 0.5) - ); - background-clip: padding-box; - backdrop-filter: blur(24px); - } - - .description div { - align-items: flex-end; - pointer-events: none; - inset: auto 0 0; - padding: 2rem; - height: 200px; - background: linear-gradient( - to bottom, - transparent 0%, - rgb(var(--background-end-rgb)) 40% - ); - z-index: 1; - } -} - -/* Tablet and Smaller Desktop */ -@media (min-width: 701px) and (max-width: 1120px) { - .grid { - grid-template-columns: repeat(2, 50%); - } -} - -@media (prefers-color-scheme: dark) { - .vercelLogo { - filter: invert(1); - } - - .logo { - filter: invert(1) drop-shadow(0 0 0.3rem #ffffff70); - } -} - -@keyframes rotate { - from { - transform: rotate(360deg); - } - to { - transform: rotate(0deg); - } -} diff --git a/examples/aws-realtime-nextjs/app/page.tsx b/examples/aws-realtime-nextjs/app/page.tsx deleted file mode 100644 index 34bd2ddd90..0000000000 --- a/examples/aws-realtime-nextjs/app/page.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { Resource } from "sst"; -import Image from "next/image"; -import Chat from "@/components/chat"; -import styles from "./page.module.css"; - -const topic = "sst-chat"; - -export default function Home() { - return ( -
- -
- Next.js Logo -
- -
- -
- -
- ); -} diff --git a/examples/aws-realtime-nextjs/authorizer.ts b/examples/aws-realtime-nextjs/authorizer.ts deleted file mode 100644 index f415e08b67..0000000000 --- a/examples/aws-realtime-nextjs/authorizer.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Resource } from "sst"; -import { realtime } from "sst/aws/realtime"; - -export const handler = realtime.authorizer(async (token) => { - const prefix = `${Resource.App.name}/${Resource.App.stage}`; - - const isValid = token === "PLACEHOLDER_TOKEN"; - - return isValid - ? { - publish: [`${prefix}/*`], - subscribe: [`${prefix}/*`], - } - : { - publish: [], - subscribe: [], - }; -}); diff --git a/examples/aws-realtime-nextjs/components/chat.module.css b/examples/aws-realtime-nextjs/components/chat.module.css deleted file mode 100644 index f5c6e5b1b7..0000000000 --- a/examples/aws-realtime-nextjs/components/chat.module.css +++ /dev/null @@ -1,50 +0,0 @@ -.chat { - gap: 1rem; - width: 30rem; - display: flex; - padding: 1rem; - flex-direction: column; - border-radius: var(--border-radius); - background-color: rgba(var(--callout-rgb), 0.5); - border: 1px solid rgba(var(--callout-border-rgb), 0.3); -} - -.messages { - padding-bottom: 0.125rem; - border-bottom: 1px solid rgba(var(--callout-border-rgb), 0.3); -} -.messages > div { - line-height: 1.1; - padding-bottom: 0.625rem; -} - -.form { - display: flex; - gap: 0.625rem; -} -.form input { - flex: 1; - font-size: 0.875rem; - padding: 0.5rem 0.75rem; - border-radius: calc(1rem - var(--border-radius)); - border: 1px solid rgba(var(--callout-border-rgb), 1); -} -.form button { - font-weight: 500; - font-size: 0.875rem; - padding: 0.5rem 0.75rem; - border-radius: calc(1rem - var(--border-radius)); - background: linear-gradient( - to bottom right, - rgba(var(--tile-start-rgb), 1), - rgba(var(--tile-end-rgb), 1) - ); - border: 1px solid rgba(var(--callout-border-rgb), 1); -} -.form button:active:enabled { - background: linear-gradient( - to top left, - rgba(var(--tile-start-rgb), 1), - rgba(var(--tile-end-rgb), 1) - ); -} diff --git a/examples/aws-realtime-nextjs/components/chat.tsx b/examples/aws-realtime-nextjs/components/chat.tsx deleted file mode 100644 index 299f4596a6..0000000000 --- a/examples/aws-realtime-nextjs/components/chat.tsx +++ /dev/null @@ -1,83 +0,0 @@ -"use client"; - -import mqtt from "mqtt"; -import { useState, useEffect } from "react"; -import styles from "./chat.module.css"; - -function createConnection(endpoint: string, authorizer: string) { - return mqtt.connect(`wss://${endpoint}/mqtt?x-amz-customauthorizer-name=${authorizer}`, { - protocolVersion: 5, - manualConnect: true, - username: "", // Must be empty for the authorizer - password: "PLACEHOLDER_TOKEN", // Passed as the token to the authorizer - clientId: `client_${window.crypto.randomUUID()}`, - }); -} - -export default function Chat( - { topic, endpoint, authorizer }: { topic: string, endpoint: string, authorizer: string } -) { - const [messages, setMessages] = useState([]); - const [connection, setConnection] = useState(null); - - useEffect(() => { - const connection = createConnection(endpoint, authorizer); - - connection.on("connect", async () => { - try { - await connection.subscribeAsync(topic, { qos: 1 }); - setConnection(connection); - } catch (e) { } - }); - connection.on("message", (_fullTopic, payload) => { - const message = new TextDecoder("utf8").decode(new Uint8Array(payload)); - setMessages((prev) => [...prev, message]); - }); - connection.on("error", console.error); - - connection.connect(); - - return () => { - connection.end(); - setConnection(null); - }; - }, [topic, endpoint, authorizer]); - - return ( -
- {connection && messages.length > 0 && -
- {messages.map((msg, i) => ( -
{JSON.parse(msg).message}
- ))} -
- } -
{ - e.preventDefault(); - - const input = (e.target as HTMLFormElement).message; - - connection!.publish( - topic, - JSON.stringify({ message: input.value }), - { qos: 1 } - ); - input.value = ""; - }} - > - - -
-
- ); -} diff --git a/examples/aws-realtime-nextjs/next.config.mjs b/examples/aws-realtime-nextjs/next.config.mjs deleted file mode 100644 index 4678774e6d..0000000000 --- a/examples/aws-realtime-nextjs/next.config.mjs +++ /dev/null @@ -1,4 +0,0 @@ -/** @type {import('next').NextConfig} */ -const nextConfig = {}; - -export default nextConfig; diff --git a/examples/aws-realtime-nextjs/package.json b/examples/aws-realtime-nextjs/package.json deleted file mode 100644 index 3cce662c8b..0000000000 --- a/examples/aws-realtime-nextjs/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "aws-realtime-nextjs", - "version": "0.1.0", - "private": true, - "scripts": { - "build": "next build", - "dev": "next dev", - "lint": "next lint", - "start": "next start" - }, - "dependencies": { - "mqtt": "^5.10.1", - "next": "14.2.3", - "react": "^18", - "react-dom": "^18", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/node": "^20", - "@types/react": "^18", - "@types/react-dom": "^18", - "typescript": "^5" - } -} diff --git a/examples/aws-realtime-nextjs/public/next.svg b/examples/aws-realtime-nextjs/public/next.svg deleted file mode 100644 index 5174b28c56..0000000000 --- a/examples/aws-realtime-nextjs/public/next.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-realtime-nextjs/public/vercel.svg b/examples/aws-realtime-nextjs/public/vercel.svg deleted file mode 100644 index d2f8422273..0000000000 --- a/examples/aws-realtime-nextjs/public/vercel.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-realtime-nextjs/sst.config.ts b/examples/aws-realtime-nextjs/sst.config.ts deleted file mode 100644 index f65031cdd1..0000000000 --- a/examples/aws-realtime-nextjs/sst.config.ts +++ /dev/null @@ -1,20 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-realtime-nextjs", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const realtime = new sst.aws.Realtime("MyRealtime", { - authorizer: "authorizer.handler", - }); - - new sst.aws.Nextjs("MyWeb", { - link: [realtime], - }); - }, -}); diff --git a/examples/aws-realtime-nextjs/tsconfig.json b/examples/aws-realtime-nextjs/tsconfig.json deleted file mode 100644 index 56433afeb2..0000000000 --- a/examples/aws-realtime-nextjs/tsconfig.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "compilerOptions": { - "lib": ["dom", "dom.iterable", "esnext"], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, - "plugins": [ - { - "name": "next" - } - ], - "paths": { - "@/*": ["./*"] - } - }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules","sst.config.ts"] -} diff --git a/examples/aws-realtime/authorizer.ts b/examples/aws-realtime/authorizer.ts deleted file mode 100644 index 27f8b1266d..0000000000 --- a/examples/aws-realtime/authorizer.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { RealtimeAuthHandler } from "sst"; - -export const handler = RealtimeAuthHandler(async () => { - return { - subscribe: [process.env.SST_TOPIC], - publish: [process.env.SST_TOPIC], - }; -}); diff --git a/examples/aws-realtime/package.json b/examples/aws-realtime/package.json deleted file mode 100644 index 5d2271a4b7..0000000000 --- a/examples/aws-realtime/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "aws-realtime", - "workspaces": [ - "web" - ], - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "devDependencies": { - "sst": "file:../../sdk/js" - }, - "dependencies": { - "@aws-sdk/client-iot-data-plane": "^3.569.0" - } -} diff --git a/examples/aws-realtime/publisher.ts b/examples/aws-realtime/publisher.ts deleted file mode 100644 index 0651e2f725..0000000000 --- a/examples/aws-realtime/publisher.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { - IoTDataPlaneClient, - PublishCommand, -} from "@aws-sdk/client-iot-data-plane"; -const data = new IoTDataPlaneClient({}); - -export const handler = async () => { - await data.send( - new PublishCommand({ - payload: Buffer.from( - JSON.stringify({ message: "A greeting from Lambda" }) - ), - topic: process.env.SST_TOPIC, - }) - ); - return { - statusCode: 200, - body: "Sent", - }; -}; diff --git a/examples/aws-realtime/sst.config.ts b/examples/aws-realtime/sst.config.ts deleted file mode 100644 index 2a511b418f..0000000000 --- a/examples/aws-realtime/sst.config.ts +++ /dev/null @@ -1,51 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-realtime", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const topic = `${$app.name}/${$app.stage}/chat`; - const realtime = new sst.aws.Realtime("MyRealtime", { - authorizer: { - handler: "authorizer.handler", - environment: { - SST_TOPIC: topic, - }, - }, - }); - realtime.subscribe("subscriber.handler", { - filter: topic, - }); - - new sst.aws.StaticSite("Web", { - path: "web", - build: { - command: "npm run build", - output: "dist", - }, - environment: { - VITE_REALTIME_ENDPOINT: realtime.endpoint, - VITE_TOPIC: topic, - VITE_AUTHORIZER: realtime.authorizer, - }, - }); - - const publisher = new sst.aws.Function("MyApp", { - handler: "publisher.handler", - environment: { - SST_TOPIC: topic, - }, - url: true, - link: [realtime], - }); - - return { - publisher: publisher.url, - }; - }, -}); diff --git a/examples/aws-realtime/subscriber.ts b/examples/aws-realtime/subscriber.ts deleted file mode 100644 index a33af0f71e..0000000000 --- a/examples/aws-realtime/subscriber.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const handler = async (event: any) => { - console.log(event); -}; diff --git a/examples/aws-realtime/tsconfig.json b/examples/aws-realtime/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-realtime/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-realtime/web/.gitignore b/examples/aws-realtime/web/.gitignore deleted file mode 100644 index a547bf36d8..0000000000 --- a/examples/aws-realtime/web/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -node_modules -dist -dist-ssr -*.local - -# Editor directories and files -.vscode/* -!.vscode/extensions.json -.idea -.DS_Store -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? diff --git a/examples/aws-realtime/web/index.html b/examples/aws-realtime/web/index.html deleted file mode 100644 index 44a933506f..0000000000 --- a/examples/aws-realtime/web/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - Vite + TS - - -
- - - diff --git a/examples/aws-realtime/web/package.json b/examples/aws-realtime/web/package.json deleted file mode 100644 index 9cb15e316e..0000000000 --- a/examples/aws-realtime/web/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "web", - "private": true, - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "sst dev vite", - "build": "tsc && vite build", - "preview": "vite preview" - }, - "dependencies": { - "@paralleldrive/cuid2": "^2.2.2", - "aws-iot-device-sdk-v2": "1.13.1", - "events": "^3.3.0" - }, - "devDependencies": { - "typescript": "^5.2.2", - "vite": "^5.2.0" - } -} diff --git a/examples/aws-realtime/web/public/vite.svg b/examples/aws-realtime/web/public/vite.svg deleted file mode 100644 index e7b8dfb1b2..0000000000 --- a/examples/aws-realtime/web/public/vite.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-realtime/web/src/main.ts b/examples/aws-realtime/web/src/main.ts deleted file mode 100644 index 3a546f7575..0000000000 --- a/examples/aws-realtime/web/src/main.ts +++ /dev/null @@ -1,73 +0,0 @@ -import "./style.css"; -import { iot, mqtt } from "aws-iot-device-sdk-v2"; -import { createId } from "@paralleldrive/cuid2"; - -const endpoint = import.meta.env.VITE_REALTIME_ENDPOINT; -const topic = import.meta.env.VITE_TOPIC; -const authorizer = import.meta.env.VITE_AUTHORIZER; - -const messages: string[] = []; - -// Setup MQTT connection -let connection: mqtt.MqttClientConnection; -async function createConnection() { - const config = iot.AwsIotMqttConnectionConfigBuilder.new_with_websockets() - .with_clean_session(true) - .with_client_id("client_" + createId()) - .with_endpoint(endpoint) - .with_custom_authorizer("", authorizer, "", "PLACEHOLDER_TOKEN") - .with_keep_alive_seconds(1200) - .build(); - const client = new mqtt.MqttClient(); - connection = client.new_connection(config); - connection.on("connect", async () => { - console.log("WS connected"); - await connection.subscribe(topic, mqtt.QoS.AtLeastOnce); - console.log("WS subscribed to chat"); - }); - connection.on("interrupt", (e) => { - console.log("interrupted, restarting", e, JSON.stringify(e)); - createConnection(); - }); - connection.on("error", (e) => { - console.log("connection error", e); - }); - connection.on("resume", console.log); - connection.on("message", (_fullTopic, payload) => { - const message = new TextDecoder("utf8").decode(new Uint8Array(payload)); - addMessage(message); - }); - connection.on("disconnect", console.log); - await connection.connect(); -} -createConnection(); - -const addMessage = (message: string) => { - messages.push(message); - document.querySelector("#messages")!.innerHTML = messages - .map((m) => `
${m}
`) - .join(""); -}; - -document.querySelector("#app")!.innerHTML = ` -
-

Realtime Demo

-
-
- -
-
-`; - -const input = document.querySelector("#message")!; -input.addEventListener("keypress", (event: KeyboardEvent) => { - const message = input.value.trim(); - if (event.key === "Enter" && message.length > 0) { - connection.publish( - topic, - JSON.stringify({ message }), - mqtt.QoS.AtLeastOnce - ); - input.value = ""; - } -}); diff --git a/examples/aws-realtime/web/src/style.css b/examples/aws-realtime/web/src/style.css deleted file mode 100644 index f9c7350248..0000000000 --- a/examples/aws-realtime/web/src/style.css +++ /dev/null @@ -1,96 +0,0 @@ -:root { - font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; - line-height: 1.5; - font-weight: 400; - - color-scheme: light dark; - color: rgba(255, 255, 255, 0.87); - background-color: #242424; - - font-synthesis: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -a { - font-weight: 500; - color: #646cff; - text-decoration: inherit; -} -a:hover { - color: #535bf2; -} - -body { - margin: 0; - display: flex; - place-items: center; - min-width: 320px; - min-height: 100vh; -} - -h1 { - font-size: 3.2em; - line-height: 1.1; -} - -#app { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; - text-align: center; -} - -.logo { - height: 6em; - padding: 1.5em; - will-change: filter; - transition: filter 300ms; -} -.logo:hover { - filter: drop-shadow(0 0 2em #646cffaa); -} -.logo.vanilla:hover { - filter: drop-shadow(0 0 2em #3178c6aa); -} - -.card { - padding: 2em; -} - -.read-the-docs { - color: #888; -} - -button { - border-radius: 8px; - border: 1px solid transparent; - padding: 0.6em 1.2em; - font-size: 1em; - font-weight: 500; - font-family: inherit; - background-color: #1a1a1a; - cursor: pointer; - transition: border-color 0.25s; -} -button:hover { - border-color: #646cff; -} -button:focus, -button:focus-visible { - outline: 4px auto -webkit-focus-ring-color; -} - -@media (prefers-color-scheme: light) { - :root { - color: #213547; - background-color: #ffffff; - } - a:hover { - color: #747bff; - } - button { - background-color: #f9f9f9; - } -} diff --git a/examples/aws-realtime/web/src/typescript.svg b/examples/aws-realtime/web/src/typescript.svg deleted file mode 100644 index d91c910cc3..0000000000 --- a/examples/aws-realtime/web/src/typescript.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-realtime/web/src/vite-env.d.ts b/examples/aws-realtime/web/src/vite-env.d.ts deleted file mode 100644 index 11f02fe2a0..0000000000 --- a/examples/aws-realtime/web/src/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/examples/aws-realtime/web/tsconfig.json b/examples/aws-realtime/web/tsconfig.json deleted file mode 100644 index 75abdef265..0000000000 --- a/examples/aws-realtime/web/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2020", - "useDefineForClassFields": true, - "module": "ESNext", - "lib": ["ES2020", "DOM", "DOM.Iterable"], - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true - }, - "include": ["src"] -} diff --git a/examples/aws-redis-local/index.ts b/examples/aws-redis-local/index.ts deleted file mode 100644 index cebc9ce47b..0000000000 --- a/examples/aws-redis-local/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Redis, Cluster } from "ioredis"; -import { Resource } from "sst"; - -const client = - Resource.MyRedis.host === "localhost" - ? new Redis({ - host: Resource.MyRedis.host, - port: Resource.MyRedis.port, - }) - : new Cluster( - [{ - host: Resource.MyRedis.host, - port: Resource.MyRedis.port, - }], - { - redisOptions: { - tls: { checkServerIdentity: () => undefined }, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - }, - ); - -export async function handler() { - await client.set("foo", `bar-${Date.now()}`); - return { - statusCode: 200, - body: JSON.stringify({ - foo: await client.get("foo"), - }), - }; -} diff --git a/examples/aws-redis-local/package.json b/examples/aws-redis-local/package.json deleted file mode 100644 index 128e5439f7..0000000000 --- a/examples/aws-redis-local/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "aws-redis-local", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "ioredis": "^5.4.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-redis-local/sst.config.ts b/examples/aws-redis-local/sst.config.ts deleted file mode 100644 index b32f069188..0000000000 --- a/examples/aws-redis-local/sst.config.ts +++ /dev/null @@ -1,89 +0,0 @@ -/// - -/** - * ## AWS Redis local - * - * In this example, we connect to a local Docker Redis instance for dev. While on deploy, we use - * Redis ElastiCache. - * - * We use the [`docker run`](https://docs.docker.com/reference/cli/docker/container/run/) CLI - * to start a local Redis server. You don't have to use Docker, you can run it locally any way - * you want. - * - * ```bash - * docker run \ - * --rm \ - * -p 6379:6379 \ - * -v $(pwd)/.sst/storage/redis:/data \ - * redis:latest - * ``` - * - * The data is persisted to the `.sst/storage` directory. So if you restart the dev server, - * the data will still be there. - * - * We then configure the `dev` property of the `Redis` component with the settings for the - * local Redis server. - * - * ```ts title="sst.config.ts" - * dev: { - * host: "localhost", - * port: 6379 - * } - * ``` - * - * By providing the `dev` prop for Redis, SST will use the local Redis server and - * not deploy a new Redis ElastiCache cluster when running `sst dev`. - * - * It also allows us to access Redis through a Resource `link`. - * - * ```ts title="index.ts" - * const client = Resource.MyRedis.host === "localhost" - * ? new Redis({ - * host: Resource.MyRedis.host, - * port: Resource.MyRedis.port, - * }) - * : new Cluster( - * [{ - * host: Resource.MyRedis.host, - * port: Resource.MyRedis.port, - * }], - * { - * redisOptions: { - * tls: { checkServerIdentity: () => undefined }, - * username: Resource.MyRedis.username, - * password: Resource.MyRedis.password, - * }, - * }, - * ); - * ``` - * - * The local Redis server is running in `standalone` mode, whereas on deploy it'll be in - * `cluster` mode. So our Lambda function needs to connect using the right config. - */ -export default $config({ - app(input) { - return { - name: "aws-redis-local", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { nat: "managed" }); - - const redis = new sst.aws.Redis("MyRedis", { - dev: { - host: "localhost", - port: 6379, - }, - vpc, - }); - - new sst.aws.Function("MyApp", { - vpc, - url: true, - link: [redis], - handler: "index.handler", - }); - }, -}); diff --git a/examples/aws-redis-local/tsconfig.json b/examples/aws-redis-local/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-redis-local/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-redis/index.ts b/examples/aws-redis/index.ts deleted file mode 100644 index 07da57201f..0000000000 --- a/examples/aws-redis/index.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Cluster } from "ioredis"; -import { Resource } from "sst"; - -const client = new Cluster( - [ - { - host: Resource.MyRedis.host, - port: Resource.MyRedis.port, - }, - ], - { - redisOptions: { - tls: { - checkServerIdentity: () => undefined, - }, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -export async function handler() { - await client.set("foo", `bar-${Date.now()}`); - return { - statusCode: 200, - body: JSON.stringify({ - foo: await client.get("foo"), - }), - }; -} diff --git a/examples/aws-redis/package.json b/examples/aws-redis/package.json deleted file mode 100644 index b888afbfcc..0000000000 --- a/examples/aws-redis/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-redis", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "deploy": "go run ../../cmd/sst deploy", - "remove": "go run ../../cmd/sst remove", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "ioredis": "^5.4.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-redis/sst.config.ts b/examples/aws-redis/sst.config.ts deleted file mode 100644 index ac7a05e258..0000000000 --- a/examples/aws-redis/sst.config.ts +++ /dev/null @@ -1,22 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-redis", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - // NAT Gateways are required for Lambda functions - const vpc = new sst.aws.Vpc("MyVpc", { nat: "managed" }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - new sst.aws.Function("MyApp", { - handler: "index.handler", - url: true, - vpc, - link: [redis], - }); - }, -}); diff --git a/examples/aws-remix-container/.dockerignore b/examples/aws-remix-container/.dockerignore deleted file mode 100644 index d0a41b0f28..0000000000 --- a/examples/aws-remix-container/.dockerignore +++ /dev/null @@ -1,7 +0,0 @@ -.git -.next -node_modules - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-remix-container/.eslintrc.cjs b/examples/aws-remix-container/.eslintrc.cjs deleted file mode 100644 index 4f6f59eee1..0000000000 --- a/examples/aws-remix-container/.eslintrc.cjs +++ /dev/null @@ -1,84 +0,0 @@ -/** - * This is intended to be a basic starting point for linting in your app. - * It relies on recommended configs out of the box for simplicity, but you can - * and should modify this configuration to best suit your team's needs. - */ - -/** @type {import('eslint').Linter.Config} */ -module.exports = { - root: true, - parserOptions: { - ecmaVersion: "latest", - sourceType: "module", - ecmaFeatures: { - jsx: true, - }, - }, - env: { - browser: true, - commonjs: true, - es6: true, - }, - ignorePatterns: ["!**/.server", "!**/.client"], - - // Base config - extends: ["eslint:recommended"], - - overrides: [ - // React - { - files: ["**/*.{js,jsx,ts,tsx}"], - plugins: ["react", "jsx-a11y"], - extends: [ - "plugin:react/recommended", - "plugin:react/jsx-runtime", - "plugin:react-hooks/recommended", - "plugin:jsx-a11y/recommended", - ], - settings: { - react: { - version: "detect", - }, - formComponents: ["Form"], - linkComponents: [ - { name: "Link", linkAttribute: "to" }, - { name: "NavLink", linkAttribute: "to" }, - ], - "import/resolver": { - typescript: {}, - }, - }, - }, - - // Typescript - { - files: ["**/*.{ts,tsx}"], - plugins: ["@typescript-eslint", "import"], - parser: "@typescript-eslint/parser", - settings: { - "import/internal-regex": "^~/", - "import/resolver": { - node: { - extensions: [".ts", ".tsx"], - }, - typescript: { - alwaysTryTypes: true, - }, - }, - }, - extends: [ - "plugin:@typescript-eslint/recommended", - "plugin:import/recommended", - "plugin:import/typescript", - ], - }, - - // Node - { - files: [".eslintrc.cjs"], - env: { - node: true, - }, - }, - ], -}; diff --git a/examples/aws-remix-container/.gitignore b/examples/aws-remix-container/.gitignore deleted file mode 100644 index 6a1b35d13a..0000000000 --- a/examples/aws-remix-container/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules - -/.cache -/build -.env - -# sst -.sst diff --git a/examples/aws-remix-container/Dockerfile b/examples/aws-remix-container/Dockerfile deleted file mode 100644 index c910cea1b6..0000000000 --- a/examples/aws-remix-container/Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -# Based on https://github.com/remix-run/blues-stack/blob/main/Dockerfile - -FROM node:lts-alpine as base -ENV NODE_ENV production - -# Stage 1: Install all node_modules, including dev dependencies -FROM base as deps -WORKDIR /myapp -ADD package.json ./ -RUN npm install --include=dev - -# Stage 2: Setup production node_modules -FROM base as production-deps -WORKDIR /myapp -COPY --from=deps /myapp/node_modules /myapp/node_modules -ADD package.json ./ -RUN npm prune --omit=dev - -# Stage 3: Build the app -FROM base as build -WORKDIR /myapp -COPY --from=deps /myapp/node_modules /myapp/node_modules -ADD . . -RUN npm run build - -# Stage 4: Build the production image -FROM base -WORKDIR /myapp -COPY --from=production-deps /myapp/node_modules /myapp/node_modules -COPY --from=build /myapp/build /myapp/build -COPY --from=build /myapp/public /myapp/public -ADD . . - -CMD ["npm", "start"] diff --git a/examples/aws-remix-container/app/entry.client.tsx b/examples/aws-remix-container/app/entry.client.tsx deleted file mode 100644 index 94d5dc0de0..0000000000 --- a/examples/aws-remix-container/app/entry.client.tsx +++ /dev/null @@ -1,18 +0,0 @@ -/** - * By default, Remix will handle hydrating your app on the client for you. - * You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨ - * For more information, see https://remix.run/file-conventions/entry.client - */ - -import { RemixBrowser } from "@remix-run/react"; -import { startTransition, StrictMode } from "react"; -import { hydrateRoot } from "react-dom/client"; - -startTransition(() => { - hydrateRoot( - document, - - - - ); -}); diff --git a/examples/aws-remix-container/app/entry.server.tsx b/examples/aws-remix-container/app/entry.server.tsx deleted file mode 100644 index 45db3229c6..0000000000 --- a/examples/aws-remix-container/app/entry.server.tsx +++ /dev/null @@ -1,140 +0,0 @@ -/** - * By default, Remix will handle generating the HTTP Response for you. - * You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨ - * For more information, see https://remix.run/file-conventions/entry.server - */ - -import { PassThrough } from "node:stream"; - -import type { AppLoadContext, EntryContext } from "@remix-run/node"; -import { createReadableStreamFromReadable } from "@remix-run/node"; -import { RemixServer } from "@remix-run/react"; -import { isbot } from "isbot"; -import { renderToPipeableStream } from "react-dom/server"; - -const ABORT_DELAY = 5_000; - -export default function handleRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext, - // This is ignored so we can keep it in the template for visibility. Feel - // free to delete this parameter in your app if you're not using it! - // eslint-disable-next-line @typescript-eslint/no-unused-vars - loadContext: AppLoadContext -) { - return isbot(request.headers.get("user-agent") || "") - ? handleBotRequest( - request, - responseStatusCode, - responseHeaders, - remixContext - ) - : handleBrowserRequest( - request, - responseStatusCode, - responseHeaders, - remixContext - ); -} - -function handleBotRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext -) { - return new Promise((resolve, reject) => { - let shellRendered = false; - const { pipe, abort } = renderToPipeableStream( - , - { - onAllReady() { - shellRendered = true; - const body = new PassThrough(); - const stream = createReadableStreamFromReadable(body); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(stream, { - headers: responseHeaders, - status: responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError(error: unknown) { - reject(error); - }, - onError(error: unknown) { - responseStatusCode = 500; - // Log streaming rendering errors from inside the shell. Don't log - // errors encountered during initial shell rendering since they'll - // reject and get logged in handleDocumentRequest. - if (shellRendered) { - console.error(error); - } - }, - } - ); - - setTimeout(abort, ABORT_DELAY); - }); -} - -function handleBrowserRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext -) { - return new Promise((resolve, reject) => { - let shellRendered = false; - const { pipe, abort } = renderToPipeableStream( - , - { - onShellReady() { - shellRendered = true; - const body = new PassThrough(); - const stream = createReadableStreamFromReadable(body); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(stream, { - headers: responseHeaders, - status: responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError(error: unknown) { - reject(error); - }, - onError(error: unknown) { - responseStatusCode = 500; - // Log streaming rendering errors from inside the shell. Don't log - // errors encountered during initial shell rendering since they'll - // reject and get logged in handleDocumentRequest. - if (shellRendered) { - console.error(error); - } - }, - } - ); - - setTimeout(abort, ABORT_DELAY); - }); -} diff --git a/examples/aws-remix-container/app/root.tsx b/examples/aws-remix-container/app/root.tsx deleted file mode 100644 index 61c8b983d2..0000000000 --- a/examples/aws-remix-container/app/root.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { - Links, - Meta, - Outlet, - Scripts, - ScrollRestoration, -} from "@remix-run/react"; -import type { LinksFunction } from "@remix-run/node"; - -import "./tailwind.css"; - -export const links: LinksFunction = () => [ - { rel: "preconnect", href: "https://fonts.googleapis.com" }, - { - rel: "preconnect", - href: "https://fonts.gstatic.com", - crossOrigin: "anonymous", - }, - { - rel: "stylesheet", - href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap", - }, -]; - -export function Layout({ children }: { children: React.ReactNode }) { - return ( - - - - - - - - - {children} - - - - - ); -} - -export default function App() { - return ; -} diff --git a/examples/aws-remix-container/app/routes/_index.tsx b/examples/aws-remix-container/app/routes/_index.tsx deleted file mode 100644 index 38db41f396..0000000000 --- a/examples/aws-remix-container/app/routes/_index.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import { Resource } from "sst"; -import { useLoaderData } from "@remix-run/react"; -import type { MetaFunction } from "@remix-run/node"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -export const meta: MetaFunction = () => { - return [ - { title: "New Remix App" }, - { name: "description", content: "Welcome to Remix!" }, - ]; -}; - -export async function loader() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return { url }; -} - -export default function Index() { - const data = useLoaderData(); - return ( -
-
-

- Welcome to Remix -

-
{ - e.preventDefault(); - - const file = (e.target as HTMLFormElement).file.files?.[0]!; - - const image = await fetch(data.url, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }} - > - - -
-
-
- ); -} diff --git a/examples/aws-remix-container/app/tailwind.css b/examples/aws-remix-container/app/tailwind.css deleted file mode 100644 index 303fe158fc..0000000000 --- a/examples/aws-remix-container/app/tailwind.css +++ /dev/null @@ -1,12 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; - -html, -body { - @apply bg-white dark:bg-gray-950; - - @media (prefers-color-scheme: dark) { - color-scheme: dark; - } -} diff --git a/examples/aws-remix-container/package.json b/examples/aws-remix-container/package.json deleted file mode 100644 index 8fdad703fa..0000000000 --- a/examples/aws-remix-container/package.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "aws-remix-container", - "private": true, - "sideEffects": false, - "type": "module", - "scripts": { - "build": "remix vite:build", - "dev": "remix vite:dev", - "lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .", - "start": "remix-serve ./build/server/index.js", - "typecheck": "tsc" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.701.0", - "@aws-sdk/s3-request-presigner": "^3.701.0", - "@remix-run/node": "^2.15.0", - "@remix-run/react": "^2.15.0", - "@remix-run/serve": "^2.15.0", - "isbot": "^4.1.0", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@remix-run/dev": "^2.15.0", - "@types/react": "^18.2.20", - "@types/react-dom": "^18.2.7", - "@typescript-eslint/eslint-plugin": "^6.7.4", - "@typescript-eslint/parser": "^6.7.4", - "autoprefixer": "^10.4.19", - "eslint": "^8.38.0", - "eslint-import-resolver-typescript": "^3.6.1", - "eslint-plugin-import": "^2.28.1", - "eslint-plugin-jsx-a11y": "^6.7.1", - "eslint-plugin-react": "^7.33.2", - "eslint-plugin-react-hooks": "^4.6.0", - "postcss": "^8.4.38", - "tailwindcss": "^3.4.4", - "typescript": "^5.1.6", - "vite": "^5.1.0", - "vite-tsconfig-paths": "^4.2.1" - }, - "engines": { - "node": ">=20.0.0" - }, - "overrides": { - "valibot": "^0.41.0" - } -} diff --git a/examples/aws-remix-container/postcss.config.js b/examples/aws-remix-container/postcss.config.js deleted file mode 100644 index 2aa7205d4b..0000000000 --- a/examples/aws-remix-container/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, -}; diff --git a/examples/aws-remix-container/public/favicon.ico b/examples/aws-remix-container/public/favicon.ico deleted file mode 100644 index 8830cf6821..0000000000 Binary files a/examples/aws-remix-container/public/favicon.ico and /dev/null differ diff --git a/examples/aws-remix-container/public/logo-dark.png b/examples/aws-remix-container/public/logo-dark.png deleted file mode 100644 index b24c7aee3a..0000000000 Binary files a/examples/aws-remix-container/public/logo-dark.png and /dev/null differ diff --git a/examples/aws-remix-container/public/logo-light.png b/examples/aws-remix-container/public/logo-light.png deleted file mode 100644 index 4490ae7930..0000000000 Binary files a/examples/aws-remix-container/public/logo-light.png and /dev/null differ diff --git a/examples/aws-remix-container/sst.config.ts b/examples/aws-remix-container/sst.config.ts deleted file mode 100644 index 9f55a2d505..0000000000 --- a/examples/aws-remix-container/sst.config.ts +++ /dev/null @@ -1,30 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-remix-container", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public", - }); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [bucket], - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-remix-container/tailwind.config.ts b/examples/aws-remix-container/tailwind.config.ts deleted file mode 100644 index 5f06ad4ba5..0000000000 --- a/examples/aws-remix-container/tailwind.config.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { Config } from "tailwindcss"; - -export default { - content: ["./app/**/{**,.client,.server}/**/*.{js,jsx,ts,tsx}"], - theme: { - extend: { - fontFamily: { - sans: [ - "Inter", - "ui-sans-serif", - "system-ui", - "sans-serif", - "Apple Color Emoji", - "Segoe UI Emoji", - "Segoe UI Symbol", - "Noto Color Emoji", - ], - }, - }, - }, - plugins: [], -} satisfies Config; diff --git a/examples/aws-remix-container/tsconfig.json b/examples/aws-remix-container/tsconfig.json deleted file mode 100644 index 9d87dd378f..0000000000 --- a/examples/aws-remix-container/tsconfig.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "include": [ - "**/*.ts", - "**/*.tsx", - "**/.server/**/*.ts", - "**/.server/**/*.tsx", - "**/.client/**/*.ts", - "**/.client/**/*.tsx" - ], - "compilerOptions": { - "lib": ["DOM", "DOM.Iterable", "ES2022"], - "types": ["@remix-run/node", "vite/client"], - "isolatedModules": true, - "esModuleInterop": true, - "jsx": "react-jsx", - "module": "ESNext", - "moduleResolution": "Bundler", - "resolveJsonModule": true, - "target": "ES2022", - "strict": true, - "allowJs": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "baseUrl": ".", - "paths": { - "~/*": ["./app/*"] - }, - - // Vite takes care of building everything, not tsc. - "noEmit": true - } -} diff --git a/examples/aws-remix-container/vite.config.ts b/examples/aws-remix-container/vite.config.ts deleted file mode 100644 index e4e8cefc3b..0000000000 --- a/examples/aws-remix-container/vite.config.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { vitePlugin as remix } from "@remix-run/dev"; -import { defineConfig } from "vite"; -import tsconfigPaths from "vite-tsconfig-paths"; - -declare module "@remix-run/node" { - interface Future { - v3_singleFetch: true; - } -} - -export default defineConfig({ - plugins: [ - remix({ - future: { - v3_fetcherPersist: true, - v3_relativeSplatPath: true, - v3_throwAbortReason: true, - v3_singleFetch: true, - v3_lazyRouteDiscovery: true, - }, - }), - tsconfigPaths(), - ], -}); diff --git a/examples/aws-remix-redis/.dockerignore b/examples/aws-remix-redis/.dockerignore deleted file mode 100644 index 25316b7aa8..0000000000 --- a/examples/aws-remix-redis/.dockerignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules -.cache -build -public/build - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-remix-redis/.eslintrc.cjs b/examples/aws-remix-redis/.eslintrc.cjs deleted file mode 100644 index 4f6f59eee1..0000000000 --- a/examples/aws-remix-redis/.eslintrc.cjs +++ /dev/null @@ -1,84 +0,0 @@ -/** - * This is intended to be a basic starting point for linting in your app. - * It relies on recommended configs out of the box for simplicity, but you can - * and should modify this configuration to best suit your team's needs. - */ - -/** @type {import('eslint').Linter.Config} */ -module.exports = { - root: true, - parserOptions: { - ecmaVersion: "latest", - sourceType: "module", - ecmaFeatures: { - jsx: true, - }, - }, - env: { - browser: true, - commonjs: true, - es6: true, - }, - ignorePatterns: ["!**/.server", "!**/.client"], - - // Base config - extends: ["eslint:recommended"], - - overrides: [ - // React - { - files: ["**/*.{js,jsx,ts,tsx}"], - plugins: ["react", "jsx-a11y"], - extends: [ - "plugin:react/recommended", - "plugin:react/jsx-runtime", - "plugin:react-hooks/recommended", - "plugin:jsx-a11y/recommended", - ], - settings: { - react: { - version: "detect", - }, - formComponents: ["Form"], - linkComponents: [ - { name: "Link", linkAttribute: "to" }, - { name: "NavLink", linkAttribute: "to" }, - ], - "import/resolver": { - typescript: {}, - }, - }, - }, - - // Typescript - { - files: ["**/*.{ts,tsx}"], - plugins: ["@typescript-eslint", "import"], - parser: "@typescript-eslint/parser", - settings: { - "import/internal-regex": "^~/", - "import/resolver": { - node: { - extensions: [".ts", ".tsx"], - }, - typescript: { - alwaysTryTypes: true, - }, - }, - }, - extends: [ - "plugin:@typescript-eslint/recommended", - "plugin:import/recommended", - "plugin:import/typescript", - ], - }, - - // Node - { - files: [".eslintrc.cjs"], - env: { - node: true, - }, - }, - ], -}; diff --git a/examples/aws-remix-redis/.gitignore b/examples/aws-remix-redis/.gitignore deleted file mode 100644 index 6a1b35d13a..0000000000 --- a/examples/aws-remix-redis/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules - -/.cache -/build -.env - -# sst -.sst diff --git a/examples/aws-remix-redis/Dockerfile b/examples/aws-remix-redis/Dockerfile deleted file mode 100644 index 026c033291..0000000000 --- a/examples/aws-remix-redis/Dockerfile +++ /dev/null @@ -1,45 +0,0 @@ -# base node image -FROM node:18-bullseye-slim as base - -# set for base and all layer that inherit from it -ENV NODE_ENV production - -# Install all node_modules, including dev dependencies -FROM base as deps - -WORKDIR /myapp - -ADD package.json ./ -RUN npm install --include=dev - -# Setup production node_modules -FROM base as production-deps - -WORKDIR /myapp - -COPY --from=deps /myapp/node_modules /myapp/node_modules -ADD package.json ./ -RUN npm prune --omit=dev - -# Build the app -FROM base as build - -WORKDIR /myapp - -COPY --from=deps /myapp/node_modules /myapp/node_modules - -ADD . . -RUN npm run build - -# Finally, build the production image with minimal footprint -FROM base - -WORKDIR /myapp - -COPY --from=production-deps /myapp/node_modules /myapp/node_modules - -COPY --from=build /myapp/build /myapp/build -COPY --from=build /myapp/public /myapp/public -ADD . . - -CMD ["npm", "start"] diff --git a/examples/aws-remix-redis/app/entry.client.tsx b/examples/aws-remix-redis/app/entry.client.tsx deleted file mode 100644 index 94d5dc0de0..0000000000 --- a/examples/aws-remix-redis/app/entry.client.tsx +++ /dev/null @@ -1,18 +0,0 @@ -/** - * By default, Remix will handle hydrating your app on the client for you. - * You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨ - * For more information, see https://remix.run/file-conventions/entry.client - */ - -import { RemixBrowser } from "@remix-run/react"; -import { startTransition, StrictMode } from "react"; -import { hydrateRoot } from "react-dom/client"; - -startTransition(() => { - hydrateRoot( - document, - - - - ); -}); diff --git a/examples/aws-remix-redis/app/entry.server.tsx b/examples/aws-remix-redis/app/entry.server.tsx deleted file mode 100644 index 45db3229c6..0000000000 --- a/examples/aws-remix-redis/app/entry.server.tsx +++ /dev/null @@ -1,140 +0,0 @@ -/** - * By default, Remix will handle generating the HTTP Response for you. - * You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨ - * For more information, see https://remix.run/file-conventions/entry.server - */ - -import { PassThrough } from "node:stream"; - -import type { AppLoadContext, EntryContext } from "@remix-run/node"; -import { createReadableStreamFromReadable } from "@remix-run/node"; -import { RemixServer } from "@remix-run/react"; -import { isbot } from "isbot"; -import { renderToPipeableStream } from "react-dom/server"; - -const ABORT_DELAY = 5_000; - -export default function handleRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext, - // This is ignored so we can keep it in the template for visibility. Feel - // free to delete this parameter in your app if you're not using it! - // eslint-disable-next-line @typescript-eslint/no-unused-vars - loadContext: AppLoadContext -) { - return isbot(request.headers.get("user-agent") || "") - ? handleBotRequest( - request, - responseStatusCode, - responseHeaders, - remixContext - ) - : handleBrowserRequest( - request, - responseStatusCode, - responseHeaders, - remixContext - ); -} - -function handleBotRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext -) { - return new Promise((resolve, reject) => { - let shellRendered = false; - const { pipe, abort } = renderToPipeableStream( - , - { - onAllReady() { - shellRendered = true; - const body = new PassThrough(); - const stream = createReadableStreamFromReadable(body); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(stream, { - headers: responseHeaders, - status: responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError(error: unknown) { - reject(error); - }, - onError(error: unknown) { - responseStatusCode = 500; - // Log streaming rendering errors from inside the shell. Don't log - // errors encountered during initial shell rendering since they'll - // reject and get logged in handleDocumentRequest. - if (shellRendered) { - console.error(error); - } - }, - } - ); - - setTimeout(abort, ABORT_DELAY); - }); -} - -function handleBrowserRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext -) { - return new Promise((resolve, reject) => { - let shellRendered = false; - const { pipe, abort } = renderToPipeableStream( - , - { - onShellReady() { - shellRendered = true; - const body = new PassThrough(); - const stream = createReadableStreamFromReadable(body); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(stream, { - headers: responseHeaders, - status: responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError(error: unknown) { - reject(error); - }, - onError(error: unknown) { - responseStatusCode = 500; - // Log streaming rendering errors from inside the shell. Don't log - // errors encountered during initial shell rendering since they'll - // reject and get logged in handleDocumentRequest. - if (shellRendered) { - console.error(error); - } - }, - } - ); - - setTimeout(abort, ABORT_DELAY); - }); -} diff --git a/examples/aws-remix-redis/app/root.tsx b/examples/aws-remix-redis/app/root.tsx deleted file mode 100644 index 61c8b983d2..0000000000 --- a/examples/aws-remix-redis/app/root.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { - Links, - Meta, - Outlet, - Scripts, - ScrollRestoration, -} from "@remix-run/react"; -import type { LinksFunction } from "@remix-run/node"; - -import "./tailwind.css"; - -export const links: LinksFunction = () => [ - { rel: "preconnect", href: "https://fonts.googleapis.com" }, - { - rel: "preconnect", - href: "https://fonts.gstatic.com", - crossOrigin: "anonymous", - }, - { - rel: "stylesheet", - href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap", - }, -]; - -export function Layout({ children }: { children: React.ReactNode }) { - return ( - - - - - - - - - {children} - - - - - ); -} - -export default function App() { - return ; -} diff --git a/examples/aws-remix-redis/app/routes/_index.tsx b/examples/aws-remix-redis/app/routes/_index.tsx deleted file mode 100644 index b5be858188..0000000000 --- a/examples/aws-remix-redis/app/routes/_index.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { Resource } from "sst"; -import { Cluster } from "ioredis"; -import { json } from "@remix-run/node"; -import type { MetaFunction } from "@remix-run/node"; -import { useLoaderData } from "@remix-run/react"; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -export const meta: MetaFunction = () => { - return [ - { title: "New Remix App" }, - { name: "description", content: "Welcome to Remix!" }, - ]; -}; - -export async function loader() { - const counter = await redis.incr("counter"); - - return json({ counter }); -} - -export default function Index() { - const data = useLoaderData(); - return ( -

- Hit counter: {data.counter} -

- ); -} diff --git a/examples/aws-remix-redis/app/tailwind.css b/examples/aws-remix-redis/app/tailwind.css deleted file mode 100644 index 303fe158fc..0000000000 --- a/examples/aws-remix-redis/app/tailwind.css +++ /dev/null @@ -1,12 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; - -html, -body { - @apply bg-white dark:bg-gray-950; - - @media (prefers-color-scheme: dark) { - color-scheme: dark; - } -} diff --git a/examples/aws-remix-redis/package.json b/examples/aws-remix-redis/package.json deleted file mode 100644 index 22a6d322b2..0000000000 --- a/examples/aws-remix-redis/package.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "aws-remix-redis", - "private": true, - "sideEffects": false, - "type": "module", - "scripts": { - "build": "remix vite:build", - "dev": "remix vite:dev", - "lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .", - "start": "remix-serve ./build/server/index.js", - "typecheck": "tsc" - }, - "dependencies": { - "@remix-run/node": "^2.12.1", - "@remix-run/react": "^2.12.1", - "@remix-run/serve": "^2.12.1", - "ioredis": "^5.4.1", - "isbot": "^4.1.0", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@remix-run/dev": "^2.12.1", - "@types/react": "^18.2.20", - "@types/react-dom": "^18.2.7", - "@typescript-eslint/eslint-plugin": "^6.7.4", - "@typescript-eslint/parser": "^6.7.4", - "autoprefixer": "^10.4.19", - "eslint": "^8.38.0", - "eslint-import-resolver-typescript": "^3.6.1", - "eslint-plugin-import": "^2.28.1", - "eslint-plugin-jsx-a11y": "^6.7.1", - "eslint-plugin-react": "^7.33.2", - "eslint-plugin-react-hooks": "^4.6.0", - "postcss": "^8.4.38", - "tailwindcss": "^3.4.4", - "typescript": "^5.1.6", - "vite": "^5.1.0", - "vite-tsconfig-paths": "^4.2.1" - }, - "engines": { - "node": ">=20.0.0" - } -} diff --git a/examples/aws-remix-redis/postcss.config.js b/examples/aws-remix-redis/postcss.config.js deleted file mode 100644 index 2aa7205d4b..0000000000 --- a/examples/aws-remix-redis/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, -}; diff --git a/examples/aws-remix-redis/public/favicon.ico b/examples/aws-remix-redis/public/favicon.ico deleted file mode 100644 index 8830cf6821..0000000000 Binary files a/examples/aws-remix-redis/public/favicon.ico and /dev/null differ diff --git a/examples/aws-remix-redis/public/logo-dark.png b/examples/aws-remix-redis/public/logo-dark.png deleted file mode 100644 index b24c7aee3a..0000000000 Binary files a/examples/aws-remix-redis/public/logo-dark.png and /dev/null differ diff --git a/examples/aws-remix-redis/public/logo-light.png b/examples/aws-remix-redis/public/logo-light.png deleted file mode 100644 index 4490ae7930..0000000000 Binary files a/examples/aws-remix-redis/public/logo-light.png and /dev/null differ diff --git a/examples/aws-remix-redis/sst.config.ts b/examples/aws-remix-redis/sst.config.ts deleted file mode 100644 index 8abd9c423f..0000000000 --- a/examples/aws-remix-redis/sst.config.ts +++ /dev/null @@ -1,68 +0,0 @@ -/// - -/** - * ## AWS Remix container with Redis - * - * Creates a hit counter app with Remix and Redis. - * - * This deploys Remix as a Fargate service to ECS and it's linked to Redis. - * - * ```ts title="sst.config.ts" {3} - * new sst.aws.Service("MyService", { - * cluster, - * link: [redis], - * loadBalancer: { - * ports: [{ listen: "80/http", forward: "3000/http" }], - * }, - * dev: { - * command: "npm run dev", - * }, - * }); - * ``` - * - * Since our Redis cluster is in a VPC, we’ll need a tunnel to connect to it from our local - * machine. - * - * ```bash "sudo" - * sudo npx sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * To start your app locally run. - * - * ```bash - * npx sst dev - * ``` - * - * Now if you go to `http://localhost:5173` you’ll see a counter update as you refresh the page. - * - * Finally, you can deploy it by adding the `Dockerfile` that's included in this example and - * running `npx sst deploy --stage production`. - */ -export default $config({ - app(input) { - return { - name: "aws-remix-redis", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-remix-redis/tailwind.config.ts b/examples/aws-remix-redis/tailwind.config.ts deleted file mode 100644 index 14d0f00ce6..0000000000 --- a/examples/aws-remix-redis/tailwind.config.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { Config } from "tailwindcss"; - -export default { - content: ["./app/**/{**,.client,.server}/**/*.{js,jsx,ts,tsx}"], - theme: { - extend: { - fontFamily: { - sans: [ - '"Inter"', - "ui-sans-serif", - "system-ui", - "sans-serif", - '"Apple Color Emoji"', - '"Segoe UI Emoji"', - '"Segoe UI Symbol"', - '"Noto Color Emoji"', - ], - }, - }, - }, - plugins: [], -} satisfies Config; diff --git a/examples/aws-remix-redis/tsconfig.json b/examples/aws-remix-redis/tsconfig.json deleted file mode 100644 index 9d87dd378f..0000000000 --- a/examples/aws-remix-redis/tsconfig.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "include": [ - "**/*.ts", - "**/*.tsx", - "**/.server/**/*.ts", - "**/.server/**/*.tsx", - "**/.client/**/*.ts", - "**/.client/**/*.tsx" - ], - "compilerOptions": { - "lib": ["DOM", "DOM.Iterable", "ES2022"], - "types": ["@remix-run/node", "vite/client"], - "isolatedModules": true, - "esModuleInterop": true, - "jsx": "react-jsx", - "module": "ESNext", - "moduleResolution": "Bundler", - "resolveJsonModule": true, - "target": "ES2022", - "strict": true, - "allowJs": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "baseUrl": ".", - "paths": { - "~/*": ["./app/*"] - }, - - // Vite takes care of building everything, not tsc. - "noEmit": true - } -} diff --git a/examples/aws-remix-redis/vite.config.ts b/examples/aws-remix-redis/vite.config.ts deleted file mode 100644 index 54066fb7ad..0000000000 --- a/examples/aws-remix-redis/vite.config.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { vitePlugin as remix } from "@remix-run/dev"; -import { defineConfig } from "vite"; -import tsconfigPaths from "vite-tsconfig-paths"; - -export default defineConfig({ - plugins: [ - remix({ - future: { - v3_fetcherPersist: true, - v3_relativeSplatPath: true, - v3_throwAbortReason: true, - }, - }), - tsconfigPaths(), - ], -}); diff --git a/examples/aws-remix-stream/.eslintrc.cjs b/examples/aws-remix-stream/.eslintrc.cjs deleted file mode 100644 index 4f6f59eee1..0000000000 --- a/examples/aws-remix-stream/.eslintrc.cjs +++ /dev/null @@ -1,84 +0,0 @@ -/** - * This is intended to be a basic starting point for linting in your app. - * It relies on recommended configs out of the box for simplicity, but you can - * and should modify this configuration to best suit your team's needs. - */ - -/** @type {import('eslint').Linter.Config} */ -module.exports = { - root: true, - parserOptions: { - ecmaVersion: "latest", - sourceType: "module", - ecmaFeatures: { - jsx: true, - }, - }, - env: { - browser: true, - commonjs: true, - es6: true, - }, - ignorePatterns: ["!**/.server", "!**/.client"], - - // Base config - extends: ["eslint:recommended"], - - overrides: [ - // React - { - files: ["**/*.{js,jsx,ts,tsx}"], - plugins: ["react", "jsx-a11y"], - extends: [ - "plugin:react/recommended", - "plugin:react/jsx-runtime", - "plugin:react-hooks/recommended", - "plugin:jsx-a11y/recommended", - ], - settings: { - react: { - version: "detect", - }, - formComponents: ["Form"], - linkComponents: [ - { name: "Link", linkAttribute: "to" }, - { name: "NavLink", linkAttribute: "to" }, - ], - "import/resolver": { - typescript: {}, - }, - }, - }, - - // Typescript - { - files: ["**/*.{ts,tsx}"], - plugins: ["@typescript-eslint", "import"], - parser: "@typescript-eslint/parser", - settings: { - "import/internal-regex": "^~/", - "import/resolver": { - node: { - extensions: [".ts", ".tsx"], - }, - typescript: { - alwaysTryTypes: true, - }, - }, - }, - extends: [ - "plugin:@typescript-eslint/recommended", - "plugin:import/recommended", - "plugin:import/typescript", - ], - }, - - // Node - { - files: [".eslintrc.cjs"], - env: { - node: true, - }, - }, - ], -}; diff --git a/examples/aws-remix-stream/.gitignore b/examples/aws-remix-stream/.gitignore deleted file mode 100644 index 6a1b35d13a..0000000000 --- a/examples/aws-remix-stream/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules - -/.cache -/build -.env - -# sst -.sst diff --git a/examples/aws-remix-stream/app/entry.client.tsx b/examples/aws-remix-stream/app/entry.client.tsx deleted file mode 100644 index 94d5dc0de0..0000000000 --- a/examples/aws-remix-stream/app/entry.client.tsx +++ /dev/null @@ -1,18 +0,0 @@ -/** - * By default, Remix will handle hydrating your app on the client for you. - * You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨ - * For more information, see https://remix.run/file-conventions/entry.client - */ - -import { RemixBrowser } from "@remix-run/react"; -import { startTransition, StrictMode } from "react"; -import { hydrateRoot } from "react-dom/client"; - -startTransition(() => { - hydrateRoot( - document, - - - - ); -}); diff --git a/examples/aws-remix-stream/app/entry.server.tsx b/examples/aws-remix-stream/app/entry.server.tsx deleted file mode 100644 index 45db3229c6..0000000000 --- a/examples/aws-remix-stream/app/entry.server.tsx +++ /dev/null @@ -1,140 +0,0 @@ -/** - * By default, Remix will handle generating the HTTP Response for you. - * You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨ - * For more information, see https://remix.run/file-conventions/entry.server - */ - -import { PassThrough } from "node:stream"; - -import type { AppLoadContext, EntryContext } from "@remix-run/node"; -import { createReadableStreamFromReadable } from "@remix-run/node"; -import { RemixServer } from "@remix-run/react"; -import { isbot } from "isbot"; -import { renderToPipeableStream } from "react-dom/server"; - -const ABORT_DELAY = 5_000; - -export default function handleRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext, - // This is ignored so we can keep it in the template for visibility. Feel - // free to delete this parameter in your app if you're not using it! - // eslint-disable-next-line @typescript-eslint/no-unused-vars - loadContext: AppLoadContext -) { - return isbot(request.headers.get("user-agent") || "") - ? handleBotRequest( - request, - responseStatusCode, - responseHeaders, - remixContext - ) - : handleBrowserRequest( - request, - responseStatusCode, - responseHeaders, - remixContext - ); -} - -function handleBotRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext -) { - return new Promise((resolve, reject) => { - let shellRendered = false; - const { pipe, abort } = renderToPipeableStream( - , - { - onAllReady() { - shellRendered = true; - const body = new PassThrough(); - const stream = createReadableStreamFromReadable(body); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(stream, { - headers: responseHeaders, - status: responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError(error: unknown) { - reject(error); - }, - onError(error: unknown) { - responseStatusCode = 500; - // Log streaming rendering errors from inside the shell. Don't log - // errors encountered during initial shell rendering since they'll - // reject and get logged in handleDocumentRequest. - if (shellRendered) { - console.error(error); - } - }, - } - ); - - setTimeout(abort, ABORT_DELAY); - }); -} - -function handleBrowserRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext -) { - return new Promise((resolve, reject) => { - let shellRendered = false; - const { pipe, abort } = renderToPipeableStream( - , - { - onShellReady() { - shellRendered = true; - const body = new PassThrough(); - const stream = createReadableStreamFromReadable(body); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(stream, { - headers: responseHeaders, - status: responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError(error: unknown) { - reject(error); - }, - onError(error: unknown) { - responseStatusCode = 500; - // Log streaming rendering errors from inside the shell. Don't log - // errors encountered during initial shell rendering since they'll - // reject and get logged in handleDocumentRequest. - if (shellRendered) { - console.error(error); - } - }, - } - ); - - setTimeout(abort, ABORT_DELAY); - }); -} diff --git a/examples/aws-remix-stream/app/root.tsx b/examples/aws-remix-stream/app/root.tsx deleted file mode 100644 index e82f26fd17..0000000000 --- a/examples/aws-remix-stream/app/root.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { - Links, - Meta, - Outlet, - Scripts, - ScrollRestoration, -} from "@remix-run/react"; - -export function Layout({ children }: { children: React.ReactNode }) { - return ( - - - - - - - - - {children} - - - - - ); -} - -export default function App() { - return ; -} diff --git a/examples/aws-remix-stream/app/routes/_index.tsx b/examples/aws-remix-stream/app/routes/_index.tsx deleted file mode 100644 index df765aae81..0000000000 --- a/examples/aws-remix-stream/app/routes/_index.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import { Suspense } from "react"; -import { Await, useLoaderData } from "@remix-run/react"; -import { defer, LoaderFunction } from "@remix-run/node"; -import styles from "~/styles/index.css?url"; - -export const links = () => [ - { rel: "stylesheet", href: styles }, -]; - -interface Character { - name: string; - image: string; - description?: string; -} - -interface LoaderData { - spongebob: Character; - friends: Character[]; -} - -export const loader: LoaderFunction = async () => { - const spongebob = { - name: "SpongeBob SquarePants", - description: "SpongeBob SquarePants is the main character of the popular animated TV series. He's a cheerful sea sponge who lives in a pineapple house in the underwater city of Bikini Bottom. SpongeBob works as a fry cook at the Krusty Krab and loves jellyfishing with his best friend Patrick Star.", - image: "spongebob.png", - }; - const friendsPromise = new Promise((resolve) => { - setTimeout(() => { - resolve( - [ - { name: "Patrick Star", image: "patrick.png" }, - { name: "Sandy Cheeks", image: "sandy.png" }, - { name: "Squidward Tentacles", image: "squidward.png" }, - { name: "Mr. Krabs", image: "mr-krabs.png" }, - ] - ); - }, 3000); - }); - - return defer({ - spongebob, - friends: friendsPromise, - }); -}; - -export default function Index() { - const { spongebob, friends } = useLoaderData(); - - return ( -
-
-

{spongebob.name}

-
-
-

{spongebob.description}

-
- {spongebob.name} -
-
- -
-

Friends from Bikini Bottom

- Loading...
}> - - {(friends) => ( -
- {friends.map((friend) => ( -
- {friend.name} -

{friend.name}

-
- ))} -
- )} -
- - - - ); -} diff --git a/examples/aws-remix-stream/app/styles/index.css b/examples/aws-remix-stream/app/styles/index.css deleted file mode 100644 index 8e562771e4..0000000000 --- a/examples/aws-remix-stream/app/styles/index.css +++ /dev/null @@ -1,41 +0,0 @@ -body { - font-family: Arial, sans-serif; - margin: 0; - padding: 0; - background-color: #f0f8ff; -} -.container { - max-width: 800px; - margin: 0 auto; - padding: 20px; -} -.bio-section { - background-color: #fff; - padding: 20px; - margin-bottom: 20px; - border-radius: 10px; -} -.bio-content { - display: flex; - align-items: center; -} -.bio-text { - flex: 1; - padding-right: 20px; -} -.character-grid { - display: grid; - grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); - gap: 20px; -} -.character-card { - background-color: #fff; - padding: 10px; - border-radius: 5px; - text-align: center; -} -img { - max-width: 100%; - height: auto; - border-radius: 5px; -} diff --git a/examples/aws-remix-stream/package.json b/examples/aws-remix-stream/package.json deleted file mode 100644 index b3f71965b1..0000000000 --- a/examples/aws-remix-stream/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "aws-remix-stream", - "private": true, - "sideEffects": false, - "type": "module", - "scripts": { - "build": "remix vite:build", - "dev": "remix vite:dev", - "lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .", - "start": "remix-serve ./build/server/index.js", - "typecheck": "tsc" - }, - "dependencies": { - "@remix-run/node": "^2.12.1", - "@remix-run/react": "^2.12.1", - "@remix-run/serve": "^2.12.1", - "isbot": "^4.1.0", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@remix-run/dev": "^2.12.1", - "@types/react": "^18.2.20", - "@types/react-dom": "^18.2.7", - "@typescript-eslint/eslint-plugin": "^6.7.4", - "@typescript-eslint/parser": "^6.7.4", - "eslint": "^8.38.0", - "eslint-import-resolver-typescript": "^3.6.1", - "eslint-plugin-import": "^2.28.1", - "eslint-plugin-jsx-a11y": "^6.7.1", - "eslint-plugin-react": "^7.33.2", - "eslint-plugin-react-hooks": "^4.6.0", - "typescript": "^5.1.6", - "vite": "^5.1.0", - "vite-tsconfig-paths": "^4.2.1" - }, - "engines": { - "node": ">=18.0.0" - } -} diff --git a/examples/aws-remix-stream/public/favicon.ico b/examples/aws-remix-stream/public/favicon.ico deleted file mode 100644 index 8830cf6821..0000000000 Binary files a/examples/aws-remix-stream/public/favicon.ico and /dev/null differ diff --git a/examples/aws-remix-stream/public/mr-krabs.png b/examples/aws-remix-stream/public/mr-krabs.png deleted file mode 100644 index e94ea64054..0000000000 Binary files a/examples/aws-remix-stream/public/mr-krabs.png and /dev/null differ diff --git a/examples/aws-remix-stream/public/patrick.png b/examples/aws-remix-stream/public/patrick.png deleted file mode 100644 index 030eaaf8a3..0000000000 Binary files a/examples/aws-remix-stream/public/patrick.png and /dev/null differ diff --git a/examples/aws-remix-stream/public/sandy.png b/examples/aws-remix-stream/public/sandy.png deleted file mode 100644 index eb7a9cc324..0000000000 Binary files a/examples/aws-remix-stream/public/sandy.png and /dev/null differ diff --git a/examples/aws-remix-stream/public/spongebob.png b/examples/aws-remix-stream/public/spongebob.png deleted file mode 100644 index 18f7df537e..0000000000 Binary files a/examples/aws-remix-stream/public/spongebob.png and /dev/null differ diff --git a/examples/aws-remix-stream/public/squidward.png b/examples/aws-remix-stream/public/squidward.png deleted file mode 100644 index 4af85e000b..0000000000 Binary files a/examples/aws-remix-stream/public/squidward.png and /dev/null differ diff --git a/examples/aws-remix-stream/sst.config.ts b/examples/aws-remix-stream/sst.config.ts deleted file mode 100644 index 23d914db47..0000000000 --- a/examples/aws-remix-stream/sst.config.ts +++ /dev/null @@ -1,52 +0,0 @@ -/// - -/** - * ## AWS Remix streaming - * - * Follows the [Remix Streaming](https://remix.run/docs/en/main/guides/streaming) guide to create - * an app that streams data. - * - * Uses the `defer` utility to stream data through the `loader` function. - * - * ```tsx title="app/routes/_index.tsx" - * return defer({ - * spongebob, - * friends: friendsPromise, - * }); - * ``` - * - * Then uses the the `Suspense` and `Await` components to render the data. - * - * ```tsx title="app/routes/_index.tsx" - * Loading...}> - * - * { /* ... *\/ } - * - * - * ``` - * - * You should see the _friends_ section load after a 3 second delay. - * - * :::note - * Safari handles streaming differently than other browsers. - * ::: - * - * Safari uses a [different heuristic](https://bugs.webkit.org/show_bug.cgi?id=252413) to - * determine when to stream data. You need to render _enough_ initial HTML to trigger streaming. - * This is typically only a problem for demo apps. - * - * Streaming works out of the box with the `Remix` component. - * - */ -export default $config({ - app(input) { - return { - name: "aws-remix-stream", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - new sst.aws.Remix("MyWeb"); - }, -}); diff --git a/examples/aws-remix-stream/tsconfig.json b/examples/aws-remix-stream/tsconfig.json deleted file mode 100644 index 9d87dd378f..0000000000 --- a/examples/aws-remix-stream/tsconfig.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "include": [ - "**/*.ts", - "**/*.tsx", - "**/.server/**/*.ts", - "**/.server/**/*.tsx", - "**/.client/**/*.ts", - "**/.client/**/*.tsx" - ], - "compilerOptions": { - "lib": ["DOM", "DOM.Iterable", "ES2022"], - "types": ["@remix-run/node", "vite/client"], - "isolatedModules": true, - "esModuleInterop": true, - "jsx": "react-jsx", - "module": "ESNext", - "moduleResolution": "Bundler", - "resolveJsonModule": true, - "target": "ES2022", - "strict": true, - "allowJs": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "baseUrl": ".", - "paths": { - "~/*": ["./app/*"] - }, - - // Vite takes care of building everything, not tsc. - "noEmit": true - } -} diff --git a/examples/aws-remix-stream/vite.config.ts b/examples/aws-remix-stream/vite.config.ts deleted file mode 100644 index 2b6aff9872..0000000000 --- a/examples/aws-remix-stream/vite.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { vitePlugin as remix } from "@remix-run/dev"; -import { installGlobals } from "@remix-run/node"; -import { defineConfig } from "vite"; -import tsconfigPaths from "vite-tsconfig-paths"; - -installGlobals(); - -export default defineConfig({ - plugins: [remix(), tsconfigPaths()], -}); diff --git a/examples/aws-remix/.eslintrc.cjs b/examples/aws-remix/.eslintrc.cjs deleted file mode 100644 index 4f6f59eee1..0000000000 --- a/examples/aws-remix/.eslintrc.cjs +++ /dev/null @@ -1,84 +0,0 @@ -/** - * This is intended to be a basic starting point for linting in your app. - * It relies on recommended configs out of the box for simplicity, but you can - * and should modify this configuration to best suit your team's needs. - */ - -/** @type {import('eslint').Linter.Config} */ -module.exports = { - root: true, - parserOptions: { - ecmaVersion: "latest", - sourceType: "module", - ecmaFeatures: { - jsx: true, - }, - }, - env: { - browser: true, - commonjs: true, - es6: true, - }, - ignorePatterns: ["!**/.server", "!**/.client"], - - // Base config - extends: ["eslint:recommended"], - - overrides: [ - // React - { - files: ["**/*.{js,jsx,ts,tsx}"], - plugins: ["react", "jsx-a11y"], - extends: [ - "plugin:react/recommended", - "plugin:react/jsx-runtime", - "plugin:react-hooks/recommended", - "plugin:jsx-a11y/recommended", - ], - settings: { - react: { - version: "detect", - }, - formComponents: ["Form"], - linkComponents: [ - { name: "Link", linkAttribute: "to" }, - { name: "NavLink", linkAttribute: "to" }, - ], - "import/resolver": { - typescript: {}, - }, - }, - }, - - // Typescript - { - files: ["**/*.{ts,tsx}"], - plugins: ["@typescript-eslint", "import"], - parser: "@typescript-eslint/parser", - settings: { - "import/internal-regex": "^~/", - "import/resolver": { - node: { - extensions: [".ts", ".tsx"], - }, - typescript: { - alwaysTryTypes: true, - }, - }, - }, - extends: [ - "plugin:@typescript-eslint/recommended", - "plugin:import/recommended", - "plugin:import/typescript", - ], - }, - - // Node - { - files: [".eslintrc.cjs"], - env: { - node: true, - }, - }, - ], -}; diff --git a/examples/aws-remix/.gitignore b/examples/aws-remix/.gitignore deleted file mode 100644 index 6a1b35d13a..0000000000 --- a/examples/aws-remix/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules - -/.cache -/build -.env - -# sst -.sst diff --git a/examples/aws-remix/app/entry.client.tsx b/examples/aws-remix/app/entry.client.tsx deleted file mode 100644 index 94d5dc0de0..0000000000 --- a/examples/aws-remix/app/entry.client.tsx +++ /dev/null @@ -1,18 +0,0 @@ -/** - * By default, Remix will handle hydrating your app on the client for you. - * You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨ - * For more information, see https://remix.run/file-conventions/entry.client - */ - -import { RemixBrowser } from "@remix-run/react"; -import { startTransition, StrictMode } from "react"; -import { hydrateRoot } from "react-dom/client"; - -startTransition(() => { - hydrateRoot( - document, - - - - ); -}); diff --git a/examples/aws-remix/app/entry.server.tsx b/examples/aws-remix/app/entry.server.tsx deleted file mode 100644 index 45db3229c6..0000000000 --- a/examples/aws-remix/app/entry.server.tsx +++ /dev/null @@ -1,140 +0,0 @@ -/** - * By default, Remix will handle generating the HTTP Response for you. - * You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨ - * For more information, see https://remix.run/file-conventions/entry.server - */ - -import { PassThrough } from "node:stream"; - -import type { AppLoadContext, EntryContext } from "@remix-run/node"; -import { createReadableStreamFromReadable } from "@remix-run/node"; -import { RemixServer } from "@remix-run/react"; -import { isbot } from "isbot"; -import { renderToPipeableStream } from "react-dom/server"; - -const ABORT_DELAY = 5_000; - -export default function handleRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext, - // This is ignored so we can keep it in the template for visibility. Feel - // free to delete this parameter in your app if you're not using it! - // eslint-disable-next-line @typescript-eslint/no-unused-vars - loadContext: AppLoadContext -) { - return isbot(request.headers.get("user-agent") || "") - ? handleBotRequest( - request, - responseStatusCode, - responseHeaders, - remixContext - ) - : handleBrowserRequest( - request, - responseStatusCode, - responseHeaders, - remixContext - ); -} - -function handleBotRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext -) { - return new Promise((resolve, reject) => { - let shellRendered = false; - const { pipe, abort } = renderToPipeableStream( - , - { - onAllReady() { - shellRendered = true; - const body = new PassThrough(); - const stream = createReadableStreamFromReadable(body); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(stream, { - headers: responseHeaders, - status: responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError(error: unknown) { - reject(error); - }, - onError(error: unknown) { - responseStatusCode = 500; - // Log streaming rendering errors from inside the shell. Don't log - // errors encountered during initial shell rendering since they'll - // reject and get logged in handleDocumentRequest. - if (shellRendered) { - console.error(error); - } - }, - } - ); - - setTimeout(abort, ABORT_DELAY); - }); -} - -function handleBrowserRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext -) { - return new Promise((resolve, reject) => { - let shellRendered = false; - const { pipe, abort } = renderToPipeableStream( - , - { - onShellReady() { - shellRendered = true; - const body = new PassThrough(); - const stream = createReadableStreamFromReadable(body); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(stream, { - headers: responseHeaders, - status: responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError(error: unknown) { - reject(error); - }, - onError(error: unknown) { - responseStatusCode = 500; - // Log streaming rendering errors from inside the shell. Don't log - // errors encountered during initial shell rendering since they'll - // reject and get logged in handleDocumentRequest. - if (shellRendered) { - console.error(error); - } - }, - } - ); - - setTimeout(abort, ABORT_DELAY); - }); -} diff --git a/examples/aws-remix/app/root.tsx b/examples/aws-remix/app/root.tsx deleted file mode 100644 index 61c8b983d2..0000000000 --- a/examples/aws-remix/app/root.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { - Links, - Meta, - Outlet, - Scripts, - ScrollRestoration, -} from "@remix-run/react"; -import type { LinksFunction } from "@remix-run/node"; - -import "./tailwind.css"; - -export const links: LinksFunction = () => [ - { rel: "preconnect", href: "https://fonts.googleapis.com" }, - { - rel: "preconnect", - href: "https://fonts.gstatic.com", - crossOrigin: "anonymous", - }, - { - rel: "stylesheet", - href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap", - }, -]; - -export function Layout({ children }: { children: React.ReactNode }) { - return ( - - - - - - - - - {children} - - - - - ); -} - -export default function App() { - return ; -} diff --git a/examples/aws-remix/app/routes/_index.tsx b/examples/aws-remix/app/routes/_index.tsx deleted file mode 100644 index 38db41f396..0000000000 --- a/examples/aws-remix/app/routes/_index.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import { Resource } from "sst"; -import { useLoaderData } from "@remix-run/react"; -import type { MetaFunction } from "@remix-run/node"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -export const meta: MetaFunction = () => { - return [ - { title: "New Remix App" }, - { name: "description", content: "Welcome to Remix!" }, - ]; -}; - -export async function loader() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return { url }; -} - -export default function Index() { - const data = useLoaderData(); - return ( -
-
-

- Welcome to Remix -

-
{ - e.preventDefault(); - - const file = (e.target as HTMLFormElement).file.files?.[0]!; - - const image = await fetch(data.url, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }} - > - - -
-
-
- ); -} diff --git a/examples/aws-remix/app/tailwind.css b/examples/aws-remix/app/tailwind.css deleted file mode 100644 index 303fe158fc..0000000000 --- a/examples/aws-remix/app/tailwind.css +++ /dev/null @@ -1,12 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; - -html, -body { - @apply bg-white dark:bg-gray-950; - - @media (prefers-color-scheme: dark) { - color-scheme: dark; - } -} diff --git a/examples/aws-remix/package.json b/examples/aws-remix/package.json deleted file mode 100644 index b0cc925225..0000000000 --- a/examples/aws-remix/package.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "aws-remix", - "private": true, - "sideEffects": false, - "type": "module", - "scripts": { - "build": "remix vite:build", - "dev": "remix vite:dev", - "lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .", - "start": "remix-serve ./build/server/index.js", - "typecheck": "tsc" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.699.0", - "@aws-sdk/s3-request-presigner": "^3.699.0", - "@remix-run/node": "^2.15.0", - "@remix-run/react": "^2.15.0", - "@remix-run/serve": "^2.15.0", - "isbot": "^4.1.0", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@remix-run/dev": "^2.15.0", - "@types/react": "^18.2.20", - "@types/react-dom": "^18.2.7", - "@typescript-eslint/eslint-plugin": "^6.7.4", - "@typescript-eslint/parser": "^6.7.4", - "autoprefixer": "^10.4.19", - "eslint": "^8.38.0", - "eslint-import-resolver-typescript": "^3.6.1", - "eslint-plugin-import": "^2.28.1", - "eslint-plugin-jsx-a11y": "^6.7.1", - "eslint-plugin-react": "^7.33.2", - "eslint-plugin-react-hooks": "^4.6.0", - "postcss": "^8.4.38", - "tailwindcss": "^3.4.4", - "typescript": "^5.1.6", - "vite": "^5.1.0", - "vite-tsconfig-paths": "^4.2.1" - }, - "engines": { - "node": ">=20.0.0" - }, - "overrides": { - "valibot": "^0.41.0" - } -} diff --git a/examples/aws-remix/postcss.config.js b/examples/aws-remix/postcss.config.js deleted file mode 100644 index 2aa7205d4b..0000000000 --- a/examples/aws-remix/postcss.config.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, -}; diff --git a/examples/aws-remix/public/favicon.ico b/examples/aws-remix/public/favicon.ico deleted file mode 100644 index 8830cf6821..0000000000 Binary files a/examples/aws-remix/public/favicon.ico and /dev/null differ diff --git a/examples/aws-remix/public/logo-dark.png b/examples/aws-remix/public/logo-dark.png deleted file mode 100644 index b24c7aee3a..0000000000 Binary files a/examples/aws-remix/public/logo-dark.png and /dev/null differ diff --git a/examples/aws-remix/public/logo-light.png b/examples/aws-remix/public/logo-light.png deleted file mode 100644 index 4490ae7930..0000000000 Binary files a/examples/aws-remix/public/logo-light.png and /dev/null differ diff --git a/examples/aws-remix/sst.config.ts b/examples/aws-remix/sst.config.ts deleted file mode 100644 index 71ea60c142..0000000000 --- a/examples/aws-remix/sst.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-remix", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" - }); - new sst.aws.Remix("MyWeb", { - link: [bucket], - }); - }, -}); diff --git a/examples/aws-remix/tailwind.config.ts b/examples/aws-remix/tailwind.config.ts deleted file mode 100644 index 5f06ad4ba5..0000000000 --- a/examples/aws-remix/tailwind.config.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { Config } from "tailwindcss"; - -export default { - content: ["./app/**/{**,.client,.server}/**/*.{js,jsx,ts,tsx}"], - theme: { - extend: { - fontFamily: { - sans: [ - "Inter", - "ui-sans-serif", - "system-ui", - "sans-serif", - "Apple Color Emoji", - "Segoe UI Emoji", - "Segoe UI Symbol", - "Noto Color Emoji", - ], - }, - }, - }, - plugins: [], -} satisfies Config; diff --git a/examples/aws-remix/tsconfig.json b/examples/aws-remix/tsconfig.json deleted file mode 100644 index 9d87dd378f..0000000000 --- a/examples/aws-remix/tsconfig.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "include": [ - "**/*.ts", - "**/*.tsx", - "**/.server/**/*.ts", - "**/.server/**/*.tsx", - "**/.client/**/*.ts", - "**/.client/**/*.tsx" - ], - "compilerOptions": { - "lib": ["DOM", "DOM.Iterable", "ES2022"], - "types": ["@remix-run/node", "vite/client"], - "isolatedModules": true, - "esModuleInterop": true, - "jsx": "react-jsx", - "module": "ESNext", - "moduleResolution": "Bundler", - "resolveJsonModule": true, - "target": "ES2022", - "strict": true, - "allowJs": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "baseUrl": ".", - "paths": { - "~/*": ["./app/*"] - }, - - // Vite takes care of building everything, not tsc. - "noEmit": true - } -} diff --git a/examples/aws-remix/vite.config.ts b/examples/aws-remix/vite.config.ts deleted file mode 100644 index e4e8cefc3b..0000000000 --- a/examples/aws-remix/vite.config.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { vitePlugin as remix } from "@remix-run/dev"; -import { defineConfig } from "vite"; -import tsconfigPaths from "vite-tsconfig-paths"; - -declare module "@remix-run/node" { - interface Future { - v3_singleFetch: true; - } -} - -export default defineConfig({ - plugins: [ - remix({ - future: { - v3_fetcherPersist: true, - v3_relativeSplatPath: true, - v3_throwAbortReason: true, - v3_singleFetch: true, - v3_lazyRouteDiscovery: true, - }, - }), - tsconfigPaths(), - ], -}); diff --git a/examples/aws-router-bucket/package.json b/examples/aws-router-bucket/package.json deleted file mode 100644 index 8870a7c91c..0000000000 --- a/examples/aws-router-bucket/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-router-bucket", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-router-bucket/spongebob.svg b/examples/aws-router-bucket/spongebob.svg deleted file mode 100644 index a9dd142f31..0000000000 --- a/examples/aws-router-bucket/spongebob.svg +++ /dev/null @@ -1 +0,0 @@ -Don’tflop character artwork \ No newline at end of file diff --git a/examples/aws-router-bucket/sst.config.ts b/examples/aws-router-bucket/sst.config.ts deleted file mode 100644 index b1382a1f62..0000000000 --- a/examples/aws-router-bucket/sst.config.ts +++ /dev/null @@ -1,45 +0,0 @@ -/// - -import path from "path"; - -/** - * ## Router and bucket - * - * Creates a router that serves static files from the `public` folder of a given bucket. - */ -export default $config({ - app(input) { - return { - name: "aws-router-bucket", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - // Create a bucket that CloudFront can access - const bucket = new sst.aws.Bucket("MyBucket", { - access: "cloudfront", - }); - - // Upload the image to the `public` folder - new aws.s3.BucketObjectv2("MyImage", { - bucket: bucket.name, - key: "public/spongebob.svg", - contentType: "image/svg+xml", - source: $asset("spongebob.svg"), - }); - - const router = new sst.aws.Router("MyRouter", { - routes: { - "/*": { - bucket, - rewrite: { regex: "^/(.*)$", to: "/public/$1" }, - }, - }, - }); - - return { - image: $interpolate`${router.url}/spongebob.svg`, - }; - }, -}); diff --git a/examples/aws-router-protection/api.ts b/examples/aws-router-protection/api.ts deleted file mode 100644 index bb310ecba1..0000000000 --- a/examples/aws-router-protection/api.ts +++ /dev/null @@ -1,9 +0,0 @@ -export const handler = async (event: any) => { - return { - statusCode: 200, - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(event.headers), - }; -}; diff --git a/examples/aws-router-protection/package.json b/examples/aws-router-protection/package.json deleted file mode 100644 index 6e962323f7..0000000000 --- a/examples/aws-router-protection/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-router-protection", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-router-protection/sst.config.ts b/examples/aws-router-protection/sst.config.ts deleted file mode 100644 index ee813c3267..0000000000 --- a/examples/aws-router-protection/sst.config.ts +++ /dev/null @@ -1,34 +0,0 @@ -/// - -/** - * ## Router protection with OAC - * - * Creates a router with Origin Access Control (OAC) to secure Lambda function URLs - * behind CloudFront. Direct access to the Lambda URL returns 403. - */ -export default $config({ - app(input) { - return { - name: "aws-router-protection", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const router = new sst.aws.Router("MyRouter", { - protection: "oac", - }); - - const api = new sst.aws.Function("MyApi", { - handler: "api.handler", - url: { - router: { instance: router, path: "/api" }, - }, - }); - - return { - router: router.url, - api: api.url, - }; - }, -}); diff --git a/examples/aws-router-waf/api.ts b/examples/aws-router-waf/api.ts deleted file mode 100644 index fb693b1801..0000000000 --- a/examples/aws-router-waf/api.ts +++ /dev/null @@ -1,9 +0,0 @@ -export const handler = async (event: any) => { - return { - statusCode: 200, - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ message: "Hello from WAF-protected Router!" }), - }; -}; diff --git a/examples/aws-router-waf/sst.config.ts b/examples/aws-router-waf/sst.config.ts deleted file mode 100644 index 793edf49ff..0000000000 --- a/examples/aws-router-waf/sst.config.ts +++ /dev/null @@ -1,47 +0,0 @@ -/// - -/** - * ## Router with WAF - * - * Enable WAF (Web Application Firewall) for a Router to protect against common - * web exploits and bots. - * - * WAF includes rate limiting per IP, and AWS managed rules for core rule set, - * known bad inputs, and SQL injection protection. - * - * You can also enable WAF logging to CloudWatch to monitor requests. - */ -export default $config({ - app(input) { - return { - name: "aws-router-waf", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const api = new sst.aws.Function("MyApi", { - handler: "api.handler", - url: true, - }); - - const router = new sst.aws.Router("MyRouter", { - routes: { - "/*": api.url, - }, - waf: { - rateLimitPerIp: 1000, - managedRules: { - coreRuleSet: true, - knownBadInputs: true, - sqlInjection: true, - }, - logging: true, - }, - }); - - return { - url: router.url, - }; - }, -}); diff --git a/examples/aws-router/api.ts b/examples/aws-router/api.ts deleted file mode 100644 index bb310ecba1..0000000000 --- a/examples/aws-router/api.ts +++ /dev/null @@ -1,9 +0,0 @@ -export const handler = async (event: any) => { - return { - statusCode: 200, - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(event.headers), - }; -}; diff --git a/examples/aws-router/package.json b/examples/aws-router/package.json deleted file mode 100644 index 87a5d86ce2..0000000000 --- a/examples/aws-router/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-router", - "version": "0.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-router/sst.config.ts b/examples/aws-router/sst.config.ts deleted file mode 100644 index 5db6f2d75c..0000000000 --- a/examples/aws-router/sst.config.ts +++ /dev/null @@ -1,36 +0,0 @@ -/// - -/** - * ## Router and function URL - * - * Creates a router that routes all requests to a function with a URL. - */ -export default $config({ - app(input) { - return { - name: "aws-router", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const api = new sst.aws.Function("MyApi", { - handler: "api.handler", - url: true, - }); - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public", - }); - const router = new sst.aws.Router("MyRouter", { - routes: { - "/api/*": api.url, - "/*": $interpolate`https://${bucket.domain}`, - }, - }); - - return { - router: router.url, - bucket: bucket.domain, - }; - }, -}); diff --git a/examples/aws-rust-api/.gitignore b/examples/aws-rust-api/.gitignore deleted file mode 100644 index 2a7be17e50..0000000000 --- a/examples/aws-rust-api/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -target - -# sst -.sst diff --git a/examples/aws-rust-api/Cargo.toml b/examples/aws-rust-api/Cargo.toml deleted file mode 100644 index 72282cdc91..0000000000 --- a/examples/aws-rust-api/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "aws-rust-lambda" -version = "0.1.0" -edition = "2021" - -[dependencies] -aws-config = { version = "1.5.16", features = ["behavior-version-latest"] } -aws-sdk-s3 = "1.73.0" -axum = "0.8.1" -lambda_http = "0.13.0" -serde = { version = "1.0.217", features = ["derive"] } -serde_json = "1.0.138" -# this will break when not in this repo. -sst_sdk = { version = "0.1.0", path = "../../sdk/rust" } -# sst_sdk = "0.1.0" -tokio = { version = "1", features = ["macros"] } -uuid = { version = "1.13.1", features = ["v4"] } diff --git a/examples/aws-rust-api/src/main.rs b/examples/aws-rust-api/src/main.rs deleted file mode 100644 index 7675ea7282..0000000000 --- a/examples/aws-rust-api/src/main.rs +++ /dev/null @@ -1,82 +0,0 @@ -use std::{env::set_var, time::Duration}; - -use aws_sdk_s3::presigning::PresigningConfig; -use axum::{routing::get, Router}; -use lambda_http::{run, tracing, Error}; -use serde::Deserialize; -use sst_sdk::Resource; - -#[derive(Deserialize, Debug)] -struct Bucket { - name: String, -} - -async fn presigned_url() -> String { - let config = aws_config::load_from_env().await; - let client = aws_sdk_s3::Client::new(&config); - let resource = Resource::init().unwrap(); - let Bucket { name } = resource.get("Bucket").unwrap(); - - let url = client - .put_object() - .bucket(name) - .key(uuid::Uuid::new_v4()) - .presigned( - PresigningConfig::builder() - .expires_in(Duration::from_secs(60 * 10)) - .build() - .unwrap(), - ) - .await - .unwrap(); - - url.uri().to_string() -} - -async fn latest() -> String { - let config = aws_config::load_from_env().await; - let client = aws_sdk_s3::Client::new(&config); - let resource = Resource::init().unwrap(); - let Bucket { name } = resource.get("Bucket").unwrap(); - - let objects = client.list_objects().bucket(&name).send().await.unwrap(); - let latest = objects - .contents() - .into_iter() - .min_by_key(|o| o.last_modified().unwrap()) - .unwrap(); - - let url = client - .get_object() - .bucket(name) - .key(latest.key().unwrap()) - .presigned( - PresigningConfig::builder() - .expires_in(Duration::from_secs(60 * 10)) - .build() - .unwrap(), - ) - .await - .unwrap(); - - url.uri().to_string() -} - -#[tokio::main] -async fn main() -> Result<(), Error> { - // If you use API Gateway stages, the Rust Runtime will include the stage name - // as part of the path that your application receives. - // Setting the following environment variable, you can remove the stage from the path. - // This variable only applies to API Gateway stages, - // you can remove it if you don't use them. - // i.e with: `GET /test-stage/todo/id/123` without: `GET /todo/id/123` - set_var("AWS_LAMBDA_HTTP_IGNORE_STAGE_IN_PATH", "true"); - - tracing::init_default_subscriber(); - - let app = Router::new() - .route("/", get(presigned_url)) - .route("/latest", get(latest)); - - run(app).await -} diff --git a/examples/aws-rust-api/sst.config.ts b/examples/aws-rust-api/sst.config.ts deleted file mode 100644 index de11b367dc..0000000000 --- a/examples/aws-rust-api/sst.config.ts +++ /dev/null @@ -1,29 +0,0 @@ -/// - -/** - * ## Rust function - * - * Deploy a Rust Lambda function with a function URL and a linked S3 bucket. - */ -export default $config({ - app(input) { - return { - name: "aws-rust-api", - removal: input?.stage === "production" ? "retain" : "remove", - protect: ["production"].includes(input?.stage), - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("Bucket"); - const lambda = new sst.aws.Function("RustFunction", { - runtime: "rust", - handler: "./", - url: true, - architecture: "arm64", - link: [bucket], - }); - - return { url: lambda.url }; - }, -}); diff --git a/examples/aws-rust-cluster/.dockerignore b/examples/aws-rust-cluster/.dockerignore deleted file mode 100644 index 3821f7cc63..0000000000 --- a/examples/aws-rust-cluster/.dockerignore +++ /dev/null @@ -1,24 +0,0 @@ -# rust -/target - -# dotfiles -*.env -.git -.gitignore -.dockerignore -.build - -# misc -Dockerfile -docker-compose.yml -README.md - -# node -node_modules -package.json -package-lock.json -tsconfig.json - -# sst -sst.config.ts -.sst \ No newline at end of file diff --git a/examples/aws-rust-cluster/.gitignore b/examples/aws-rust-cluster/.gitignore deleted file mode 100644 index 6b247dbcba..0000000000 --- a/examples/aws-rust-cluster/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -# sst -.sst - -# rust -Cargo.lock -target/ \ No newline at end of file diff --git a/examples/aws-rust-cluster/Cargo.toml b/examples/aws-rust-cluster/Cargo.toml deleted file mode 100644 index 36a109f013..0000000000 --- a/examples/aws-rust-cluster/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "aws_rust_cluster" -version = "0.1.0" -edition = "2021" - -[dependencies] -anyhow = "1.0.86" -axum = "0.7.5" -serde = { version = "1.0.209", features = ["derive"] } -tokio = { version = "1.40.0", features = ["rt-multi-thread", "macros", "net"] } diff --git a/examples/aws-rust-cluster/Dockerfile b/examples/aws-rust-cluster/Dockerfile deleted file mode 100644 index 679bdab9e4..0000000000 --- a/examples/aws-rust-cluster/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -FROM rust:slim AS chef - -# install build tools -RUN apt-get update -y && \ - apt-get install -y pkg-config make g++ libssl-dev && \ - rustup target add x86_64-unknown-linux-gnu - -# add cargo chef (this installs only once on first build) -RUN cargo install cargo-chef -WORKDIR /app - -FROM chef AS planner -COPY . . -RUN cargo chef prepare --recipe-path recipe.json - -FROM chef AS builder -COPY --from=planner /app/recipe.json recipe.json -# build docker caching layer -RUN cargo chef cook --release --recipe-path recipe.json - -# build binary -COPY . . -RUN cargo build --release --target x86_64-unknown-linux-gnu - -# distroless image; launch app -FROM gcr.io/distroless/cc -COPY --from=builder /app/target/x86_64-unknown-linux-gnu/release/aws_rust_cluster /bin/aws_rust_cluster -ENTRYPOINT [ "/bin/aws_rust_cluster" ] diff --git a/examples/aws-rust-cluster/docker-compose.yml b/examples/aws-rust-cluster/docker-compose.yml deleted file mode 100644 index 7b22f1ec37..0000000000 --- a/examples/aws-rust-cluster/docker-compose.yml +++ /dev/null @@ -1,9 +0,0 @@ -services: - api: - build: - context: . - dockerfile: ./Dockerfile - ports: - - 80:80 - expose: - - 80 \ No newline at end of file diff --git a/examples/aws-rust-cluster/package.json b/examples/aws-rust-cluster/package.json deleted file mode 100644 index 3523728cc7..0000000000 --- a/examples/aws-rust-cluster/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-rust-cluster", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", - "devDependencies": { - "@types/aws-lambda": "8.10.145", - "sst": "file:../../sdk/js", - "sst-linux-x64": "^4" - }, - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-rust-cluster/src/main.rs b/examples/aws-rust-cluster/src/main.rs deleted file mode 100644 index f8a4e7649f..0000000000 --- a/examples/aws-rust-cluster/src/main.rs +++ /dev/null @@ -1,29 +0,0 @@ -use anyhow::Result; -use axum::{http::StatusCode, response::IntoResponse, routing::get, Json, Router}; -use serde::Serialize; -use tokio::net::TcpListener; - -#[derive(Serialize)] -pub struct Ping { - message: &'static str, -} - -pub async fn ping() -> impl IntoResponse { - ( - StatusCode::IM_A_TEAPOT, - Json(Ping { - message: "hello from rust :)", - }), - ) -} - -#[tokio::main] -async fn main() -> Result<()> { - let api = Router::new().route("/", get(ping)); - let addr = match cfg!(debug_assertions) { - true => "0.0.0.0:3000", - false => "0.0.0.0:80", - }; - let listener = TcpListener::bind(addr).await?; - Ok(axum::serve(listener, api).await?) -} diff --git a/examples/aws-rust-cluster/sst.config.ts b/examples/aws-rust-cluster/sst.config.ts deleted file mode 100644 index 0641cf6a35..0000000000 --- a/examples/aws-rust-cluster/sst.config.ts +++ /dev/null @@ -1,42 +0,0 @@ -/// - -/** - * ## Rust container - * - * Deploy a Rust app in a container with a load balancer using a Dockerfile. - */ -export default $config({ - app(input) { - return { - name: "aws-rust-cluster", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - providers: { - aws: { region: "us-east-1" }, - }, - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { nat: "gateway" }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - const service = new sst.aws.Service("MyService", { - cluster, - image: { - context: "./", - dockerfile: "Dockerfile", - }, - loadBalancer: { - domain: "rust.dockerfile.dev.sst.dev", - ports: [ - { listen: "80/http" }, - { listen: "443/https", forward: "80/http" }, - ], - }, - }); - - return { - url: service.url, - }; - }, -}); diff --git a/examples/aws-rust-cluster/tsconfig.json b/examples/aws-rust-cluster/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-rust-cluster/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-rust-loco/.dockerignore b/examples/aws-rust-loco/.dockerignore deleted file mode 100644 index f403586fdf..0000000000 --- a/examples/aws-rust-loco/.dockerignore +++ /dev/null @@ -1,9 +0,0 @@ -target -dockerfile -.dockerignore -.git -.gitignore -.cargo - -# sst -.sst diff --git a/examples/aws-rust-loco/.github/workflows/ci.yaml b/examples/aws-rust-loco/.github/workflows/ci.yaml deleted file mode 100644 index b2e3e1162d..0000000000 --- a/examples/aws-rust-loco/.github/workflows/ci.yaml +++ /dev/null @@ -1,101 +0,0 @@ -name: CI -on: - push: - branches: - - master - - main - pull_request: - -env: - RUST_TOOLCHAIN: stable - TOOLCHAIN_PROFILE: minimal - -jobs: - rustfmt: - name: Check Style - runs-on: ubuntu-latest - - permissions: - contents: read - - steps: - - name: Checkout the code - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - components: rustfmt - - name: Run cargo fmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - clippy: - name: Run Clippy - runs-on: ubuntu-latest - - permissions: - contents: read - - steps: - - name: Checkout the code - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - - name: Setup Rust cache - uses: Swatinem/rust-cache@v2 - - name: Run cargo clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --all-features -- -D warnings -W clippy::pedantic -W clippy::nursery -W rust-2018-idioms - - test: - name: Run Tests - runs-on: ubuntu-latest - - permissions: - contents: read - - services: - redis: - image: redis - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - "6379:6379" - postgres: - image: postgres - env: - POSTGRES_DB: postgres_test - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - ports: - - "5432:5432" - # Set health checks to wait until postgres has started - options: --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - - steps: - - name: Checkout the code - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - - name: Setup Rust cache - uses: Swatinem/rust-cache@v2 - - name: Run cargo test - uses: actions-rs/cargo@v1 - with: - command: test - args: --all-features --all - env: - REDIS_URL: redis://localhost:${{job.services.redis.ports[6379]}} - DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres_test diff --git a/examples/aws-rust-loco/.gitignore b/examples/aws-rust-loco/.gitignore deleted file mode 100644 index 1902da3f36..0000000000 --- a/examples/aws-rust-loco/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -**/config/local.yaml -**/config/*.local.yaml -**/config/production.yaml - -# Generated by Cargo -# will have compiled files and executables -debug/ -target/ - -# include cargo lock -!Cargo.lock -.cargo - -# These are backup files generated by rustfmt -**/*.rs.bk - -# MSVC Windows builds of rustc generate these, which store debugging information -*.pdb - -*.sqlite - -# sst -.sst diff --git a/examples/aws-rust-loco/.rustfmt.toml b/examples/aws-rust-loco/.rustfmt.toml deleted file mode 100644 index d862e08106..0000000000 --- a/examples/aws-rust-loco/.rustfmt.toml +++ /dev/null @@ -1,2 +0,0 @@ -max_width = 100 -use_small_heuristics = "Default" diff --git a/examples/aws-rust-loco/Cargo.toml b/examples/aws-rust-loco/Cargo.toml deleted file mode 100644 index 52b82829ee..0000000000 --- a/examples/aws-rust-loco/Cargo.toml +++ /dev/null @@ -1,50 +0,0 @@ -[workspace] - -[package] -name = "server" -version = "0.1.0" -edition = "2021" -publish = false -default-run = "server-cli" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] - -loco-rs = { version = "0.9.0" } -migration = { path = "migration" } - -serde = { version = "1", features = ["derive"] } -serde_json = "1" -tokio = { version = "1.33.0", default-features = false } -async-trait = "0.1.74" -tracing = "0.1.40" -chrono = "0.4" -validator = { version = "0.16" } -sea-orm = { version = "1.0.0", features = [ - "sqlx-sqlite", - "sqlx-postgres", - "runtime-tokio-rustls", - "macros", -] } - -axum = "0.7.5" -include_dir = "0.7" -uuid = { version = "1.6.0", features = ["v4"] } -tracing-subscriber = { version = "0.3.17", features = ["env-filter", "json"] } - -[[bin]] -name = "server-cli" -path = "src/bin/main.rs" -required-features = [] - -[[bin]] -name = "tool" -path = "src/bin/tool.rs" -required-features = [] - -[dev-dependencies] -serial_test = "3.1.1" -rstest = "0.21.0" -loco-rs = { version = "0.9.0", features = ["testing"] } -insta = { version = "1.34.0", features = ["redactions", "yaml", "filters"] } diff --git a/examples/aws-rust-loco/Dockerfile b/examples/aws-rust-loco/Dockerfile deleted file mode 100644 index 99315f26d2..0000000000 --- a/examples/aws-rust-loco/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM rust:1.74-slim as builder - -WORKDIR /usr/src/ - -COPY . . - -RUN cargo build --release - -FROM debian:bookworm-slim - -WORKDIR /usr/app - -COPY --from=builder /usr/src/config /usr/app/config -COPY --from=builder /usr/src/target/release/server-cli /usr/app/server-cli - -ENTRYPOINT ["/usr/app/server-cli"] \ No newline at end of file diff --git a/examples/aws-rust-loco/Justfile b/examples/aws-rust-loco/Justfile deleted file mode 100644 index 1c1d9b2d59..0000000000 --- a/examples/aws-rust-loco/Justfile +++ /dev/null @@ -1,24 +0,0 @@ -# Command to run SST, process SST_RESOURCE_LocoDatabase, and run cargo loco start -dev stage="production": - #!/usr/bin/env bash - set -euo pipefail - - # Run SST shell and capture its output - SST_OUTPUT=$(pnpm sst shell --stage={{stage}} -- env) - - # Extract SST_RESOURCE_LocoDatabase from SST output - SST_RESOURCE_LocoDatabase=$(echo "$SST_OUTPUT" | grep SST_RESOURCE_LocoDatabase | cut -d '=' -f2-) - - # Ensure the environment variable exists - if [ -z "${SST_RESOURCE_LocoDatabase:-}" ]; then - echo "Error: SST_RESOURCE_LocoDatabase is not set" >&2 - exit 1 - fi - - # Use jq to parse the JSON and construct the DATABASE_URL - export DATABASE_URL=$(echo "$SST_RESOURCE_LocoDatabase" | jq -r ' - "postgres://\(.username):\(.password | @uri)@\(.host):\(.port)/\(.database)" - ') - - # Run cargo loco start with the processed DATABASE_URL - pnpm sst shell --stage={{stage}} -- cargo loco start diff --git a/examples/aws-rust-loco/config/development.yaml b/examples/aws-rust-loco/config/development.yaml deleted file mode 100644 index 940e654b71..0000000000 --- a/examples/aws-rust-loco/config/development.yaml +++ /dev/null @@ -1,145 +0,0 @@ -# Loco configuration file documentation - -# Application logging configuration -logger: - # Enable or disable logging. - enable: true - # Enable pretty backtrace (sets RUST_BACKTRACE=1) - pretty_backtrace: false - # Log level, options: trace, debug, info, warn or error. - level: info - # Define the logging format. options: compact, pretty or json - format: json - # By default the logger has filtering only logs that came from your code or logs that came from `loco` framework. to see all third party libraries - # Uncomment the line below to override to see all third party libraries you can enable this config and override the logger filters. - # override_filter: trace - -# Web server configuration -server: - # Port on which the server will listen. the server binding is 0.0.0.0:{PORT} - port: 5150 - binding: 0.0.0.0 - # The UI hostname or IP address that mailers will point to. - host: http://localhost - # Out of the box middleware configuration. to disable middleware you can changed the `enable` field to `false` of comment the middleware block - middlewares: - # Enable Etag cache header middleware - etag: - enable: true - # Allows to limit the payload size request. payload that bigger than this file will blocked the request. - limit_payload: - # Enable/Disable the middleware. - enable: true - # the limit size. can be b,kb,kib,mb,mib,gb,gib - body_limit: 5mb - # set secure headers - secure_headers: - preset: github - # calculate remote IP based on `X-Forwarded-For` when behind a proxy or load balancer - # use RemoteIP(..) extractor to get the remote IP. - # without this middleware, you'll get the proxy IP instead. - # For more: https://github.com/rails/rails/blob/main/actionpack/lib/action_dispatch/middleware/remote_ip.rb - # - # NOTE! only enable when under a proxy, otherwise this can lead to IP spoofing vulnerabilities - # trust me, you'll know if you need this middleware. - remote_ip: - enable: false - # # replace the default trusted proxies: - # trusted_proxies: - # - ip range 1 - # - ip range 2 .. - # Generating a unique request ID and enhancing logging with additional information such as the start and completion of request processing, latency, status code, and other request details. - logger: - # Enable/Disable the middleware. - enable: true - # when your code is panicked, the request still returns 500 status code. - catch_panic: - # Enable/Disable the middleware. - enable: true - # Timeout for incoming requests middleware. requests that take more time from the configuration will cute and 408 status code will returned. - timeout_request: - # Enable/Disable the middleware. - enable: false - # Duration time in milliseconds. - timeout: 5000 - cors: - enable: true - # Set the value of the [`Access-Control-Allow-Origin`][mdn] header - # allow_origins: - # - https://loco.rs - # Set the value of the [`Access-Control-Allow-Headers`][mdn] header - # allow_headers: - # - Content-Type - # Set the value of the [`Access-Control-Allow-Methods`][mdn] header - # allow_methods: - # - POST - # Set the value of the [`Access-Control-Max-Age`][mdn] header in seconds - # max_age: 3600 - -# Worker Configuration -workers: - # specifies the worker mode. Options: - # - BackgroundQueue - Workers operate asynchronously in the background, processing queued. - # - ForegroundBlocking - Workers operate in the foreground and block until tasks are completed. - # - BackgroundAsync - Workers operate asynchronously in the background, processing tasks with async capabilities. - mode: BackgroundQueue - -# Mailer Configuration. -mailer: - # SMTP mailer configuration. - smtp: - # Enable/Disable smtp mailer. - enable: false - # SMTP server host. e.x localhost, smtp.gmail.com - host: {{ get_env(name="MAILER_HOST", default="localhost") }} - # SMTP server port - port: 1025 - # Use secure connection (SSL/TLS). - secure: false - # auth: - # user: - # password: - -# Initializers Configuration -# initializers: -# oauth2: -# authorization_code: # Authorization code grant type -# - client_identifier: google # Identifier for the OAuth2 provider. Replace 'google' with your provider's name if different, must be unique within the oauth2 config. -# ... other fields - -# Database Configuration -database: - # Database connection URI - uri: {{ get_env(name="DATABASE_URL", default="postgres://loco:loco@localhost:5432/server_development") }} - # When enabled, the sql query will be logged. - enable_logging: false - # Set the timeout duration when acquiring a connection. - connect_timeout: {{ get_env(name="DB_CONNECT_TIMEOUT", default="500") }} - # Set the idle duration before closing a connection. - idle_timeout: 500 - # Minimum number of connections for a pool. - min_connections: 1 - # Maximum number of connections for a pool. - max_connections: 1 - # Run migration up when application loaded - auto_migrate: false - # Truncate database when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode - dangerously_truncate: false - # Recreating schema when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode - dangerously_recreate: false - -# Queue Configuration -queue: - # Redis connection URI - uri: {{ get_env(name="REDIS_URL", default="redis://127.0.0.1") }} - # Dangerously flush all data in Redis on startup. dangerous operation, make sure that you using this flag only on dev environments or test mode - dangerously_flush: false - -# Authentication Configuration -auth: - # JWT authentication - jwt: - # Secret key for token generation and verification - secret: KRVK4VAddJ3zV8IkOCTh - # Token expiration time in seconds - expiration: 604800 # 7 days diff --git a/examples/aws-rust-loco/config/test.yaml b/examples/aws-rust-loco/config/test.yaml deleted file mode 100644 index 947d5b1de5..0000000000 --- a/examples/aws-rust-loco/config/test.yaml +++ /dev/null @@ -1,126 +0,0 @@ -# Loco configuration file documentation - -# Application logging configuration -logger: - # Enable or disable logging. - enable: false - # Log level, options: trace, debug, info, warn or error. - level: debug - # Define the logging format. options: compact, pretty or json - format: compact - # By default the logger has filtering only logs that came from your code or logs that came from `loco` framework. to see all third party libraries - # Uncomment the line below to override to see all third party libraries you can enable this config and override the logger filters. - # override_filter: trace - -# Web server configuration -server: - # Port on which the server will listen. the server binding is 0.0.0.0:{PORT} - port: 5150 - # The UI hostname or IP address that mailers will point to. - host: http://localhost - # Out of the box middleware configuration. to disable middleware you can changed the `enable` field to `false` of comment the middleware block - middlewares: - # Allows to limit the payload size request. payload that bigger than this file will blocked the request. - limit_payload: - # Enable/Disable the middleware. - enable: true - # the limit size. can be b,kb,kib,mb,mib,gb,gib - body_limit: 5mb - # Generating a unique request ID and enhancing logging with additional information such as the start and completion of request processing, latency, status code, and other request details. - logger: - # Enable/Disable the middleware. - enable: true - # when your code is panicked, the request still returns 500 status code. - catch_panic: - # Enable/Disable the middleware. - enable: true - # Timeout for incoming requests middleware. requests that take more time from the configuration will cute and 408 status code will returned. - timeout_request: - # Enable/Disable the middleware. - enable: false - # Duration time in milliseconds. - timeout: 5000 - cors: - enable: true - # Set the value of the [`Access-Control-Allow-Origin`][mdn] header - # allow_origins: - # - https://loco.rs - # Set the value of the [`Access-Control-Allow-Headers`][mdn] header - # allow_headers: - # - Content-Type - # Set the value of the [`Access-Control-Allow-Methods`][mdn] header - # allow_methods: - # - POST - # Set the value of the [`Access-Control-Max-Age`][mdn] header in seconds - # max_age: 3600 - -# Worker Configuration -workers: - # specifies the worker mode. Options: - # - BackgroundQueue - Workers operate asynchronously in the background, processing queued. - # - ForegroundBlocking - Workers operate in the foreground and block until tasks are completed. - # - BackgroundAsync - Workers operate asynchronously in the background, processing tasks with async capabilities. - mode: ForegroundBlocking - -# Mailer Configuration. -mailer: - # SMTP mailer configuration. - smtp: - # Enable/Disable smtp mailer. - enable: true - # SMTP server host. e.x localhost, smtp.gmail.com - host: localhost - # SMTP server port - port: 1025 - # Use secure connection (SSL/TLS). - secure: false - # auth: - # user: - # password: - stub: true - -# Initializers Configuration -# initializers: -# oauth2: -# authorization_code: # Authorization code grant type -# - client_identifier: google # Identifier for the OAuth2 provider. Replace 'google' with your provider's name if different, must be unique within the oauth2 config. -# ... other fields - - -# Database Configuration -database: - # Database connection URI - uri: {{get_env(name="DATABASE_URL", default="postgres://loco:loco@localhost:5432/server_test")}} - # When enabled, the sql query will be logged. - enable_logging: false - # Set the timeout duration when acquiring a connection. - connect_timeout: {{ get_env(name="DB_CONNECT_TIMEOUT", default="500") }} - # Set the idle duration before closing a connection. - idle_timeout: 500 - # Minimum number of connections for a pool. - min_connections: 1 - # Maximum number of connections for a pool. - max_connections: 1 - # Run migration up when application loaded - auto_migrate: true - # Truncate database when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode - dangerously_truncate: true - # Recreating schema when application loaded. This is a dangerous operation, make sure that you using this flag only on dev environments or test mode - dangerously_recreate: false - -# Queue Configuration -queue: - # Redis connection URI - uri: {{get_env(name="REDIS_URL", default="redis://127.0.0.1")}} - # Dangerously flush all data in Redis on startup. dangerous operation, make sure that you using this flag only on dev environments or test mode - dangerously_flush: false - -# Authentication Configuration -auth: - # JWT authentication - jwt: - # Secret key for token generation and verification - secret: jFb88JjbJsVEsVdwNa8U - # Token expiration time in seconds - expiration: 604800 # 7 days - diff --git a/examples/aws-rust-loco/examples/playground.rs b/examples/aws-rust-loco/examples/playground.rs deleted file mode 100644 index 4dc0bb3873..0000000000 --- a/examples/aws-rust-loco/examples/playground.rs +++ /dev/null @@ -1,21 +0,0 @@ -#[allow(unused_imports)] -use loco_rs::{cli::playground, prelude::*}; -use server::app::App; - -#[tokio::main] -async fn main() -> loco_rs::Result<()> { - let _ctx = playground::().await?; - - // let active_model: articles::ActiveModel = ActiveModel { - // title: Set(Some("how to build apps in 3 steps".to_string())), - // content: Set(Some("use Loco: https://loco.rs".to_string())), - // ..Default::default() - // }; - // active_model.insert(&ctx.db).await.unwrap(); - - // let res = articles::Entity::find().all(&ctx.db).await.unwrap(); - // println!("{:?}", res); - println!("welcome to playground. edit me at `examples/playground.rs`"); - - Ok(()) -} diff --git a/examples/aws-rust-loco/migration/Cargo.toml b/examples/aws-rust-loco/migration/Cargo.toml deleted file mode 100644 index 723b73ccf4..0000000000 --- a/examples/aws-rust-loco/migration/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "migration" -version = "0.1.0" -edition = "2021" -publish = false - -[lib] -name = "migration" -path = "src/lib.rs" - -[dependencies] -async-std = { version = "1", features = ["attributes", "tokio1"] } -loco-rs = { version = "0.9.0" } - -[dependencies.sea-orm-migration] -version = "1.0.0" -features = [ - # Enable at least one `ASYNC_RUNTIME` and `DATABASE_DRIVER` feature if you want to run migration via CLI. - # View the list of supported features at https://www.sea-ql.org/SeaORM/docs/install-and-config/database-and-async-runtime. - # e.g. - "runtime-tokio-rustls", # `ASYNC_RUNTIME` feature -] diff --git a/examples/aws-rust-loco/migration/src/lib.rs b/examples/aws-rust-loco/migration/src/lib.rs deleted file mode 100644 index 3352f5c573..0000000000 --- a/examples/aws-rust-loco/migration/src/lib.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![allow(elided_lifetimes_in_paths)] -#![allow(clippy::wildcard_imports)] -pub use sea_orm_migration::prelude::*; - -mod m20220101_000001_users; -mod m20231103_114510_notes; - -pub struct Migrator; - -#[async_trait::async_trait] -impl MigratorTrait for Migrator { - fn migrations() -> Vec> { - vec![ - Box::new(m20220101_000001_users::Migration), - Box::new(m20231103_114510_notes::Migration), - ] - } -} diff --git a/examples/aws-rust-loco/migration/src/m20220101_000001_users.rs b/examples/aws-rust-loco/migration/src/m20220101_000001_users.rs deleted file mode 100644 index 936ad3d0cb..0000000000 --- a/examples/aws-rust-loco/migration/src/m20220101_000001_users.rs +++ /dev/null @@ -1,50 +0,0 @@ -use loco_rs::schema::table_auto_tz; -use sea_orm_migration::{prelude::*, schema::*}; - -#[derive(DeriveMigrationName)] -pub struct Migration; - -#[async_trait::async_trait] -impl MigrationTrait for Migration { - async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { - let table = table_auto_tz(Users::Table) - .col(pk_auto(Users::Id)) - .col(uuid(Users::Pid)) - .col(string_uniq(Users::Email)) - .col(string(Users::Password)) - .col(string(Users::ApiKey).unique_key()) - .col(string(Users::Name)) - .col(string_null(Users::ResetToken)) - .col(timestamp_with_time_zone_null(Users::ResetSentAt)) - .col(string_null(Users::EmailVerificationToken)) - .col(timestamp_with_time_zone_null( - Users::EmailVerificationSentAt, - )) - .col(timestamp_with_time_zone_null(Users::EmailVerifiedAt)) - .to_owned(); - manager.create_table(table).await?; - Ok(()) - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .drop_table(Table::drop().table(Users::Table).to_owned()) - .await - } -} - -#[derive(Iden)] -pub enum Users { - Table, - Id, - Pid, - Email, - Name, - Password, - ApiKey, - ResetToken, - ResetSentAt, - EmailVerificationToken, - EmailVerificationSentAt, - EmailVerifiedAt, -} diff --git a/examples/aws-rust-loco/migration/src/m20231103_114510_notes.rs b/examples/aws-rust-loco/migration/src/m20231103_114510_notes.rs deleted file mode 100644 index d0d8a5a0f7..0000000000 --- a/examples/aws-rust-loco/migration/src/m20231103_114510_notes.rs +++ /dev/null @@ -1,34 +0,0 @@ -use loco_rs::schema::table_auto_tz; -use sea_orm_migration::{prelude::*, schema::*}; - -#[derive(DeriveMigrationName)] -pub struct Migration; - -#[async_trait::async_trait] -impl MigrationTrait for Migration { - async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .create_table( - table_auto_tz(Notes::Table) - .col(pk_auto(Notes::Id)) - .col(string_null(Notes::Title)) - .col(string_null(Notes::Content)) - .to_owned(), - ) - .await - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .drop_table(Table::drop().table(Notes::Table).to_owned()) - .await - } -} - -#[derive(DeriveIden)] -enum Notes { - Table, - Id, - Title, - Content, -} diff --git a/examples/aws-rust-loco/src/app.rs b/examples/aws-rust-loco/src/app.rs deleted file mode 100644 index 4b76c503bc..0000000000 --- a/examples/aws-rust-loco/src/app.rs +++ /dev/null @@ -1,72 +0,0 @@ -use std::path::Path; - -use async_trait::async_trait; -use loco_rs::{ - app::{AppContext, Hooks}, - boot::{create_app, BootResult, StartMode}, - controller::AppRoutes, - db::{self, truncate_table}, - environment::Environment, - task::Tasks, - worker::{AppWorker, Processor}, - Result, -}; -use migration::Migrator; -use sea_orm::DatabaseConnection; - -use crate::{ - controllers, - models::_entities::{notes, users}, - tasks, - workers::downloader::DownloadWorker, -}; - -pub struct App; -#[async_trait] -impl Hooks for App { - fn app_name() -> &'static str { - env!("CARGO_CRATE_NAME") - } - - fn app_version() -> String { - format!( - "{} ({})", - env!("CARGO_PKG_VERSION"), - option_env!("BUILD_SHA") - .or(option_env!("GITHUB_SHA")) - .unwrap_or("dev") - ) - } - - async fn boot(mode: StartMode, environment: &Environment) -> Result { - create_app::(mode, environment).await - } - - fn routes(_ctx: &AppContext) -> AppRoutes { - AppRoutes::with_default_routes() - .add_route(controllers::health::routes()) - .add_route(controllers::notes::routes()) - .add_route(controllers::auth::routes()) - .add_route(controllers::user::routes()) - } - - fn connect_workers<'a>(p: &'a mut Processor, ctx: &'a AppContext) { - p.register(DownloadWorker::build(ctx)); - } - - fn register_tasks(tasks: &mut Tasks) { - tasks.register(tasks::seed::SeedData); - } - - async fn truncate(db: &DatabaseConnection) -> Result<()> { - truncate_table(db, users::Entity).await?; - truncate_table(db, notes::Entity).await?; - Ok(()) - } - - async fn seed(db: &DatabaseConnection, base: &Path) -> Result<()> { - db::seed::(db, &base.join("users.yaml").display().to_string()).await?; - db::seed::(db, &base.join("notes.yaml").display().to_string()).await?; - Ok(()) - } -} diff --git a/examples/aws-rust-loco/src/bin/main.rs b/examples/aws-rust-loco/src/bin/main.rs deleted file mode 100644 index 9b895c1be2..0000000000 --- a/examples/aws-rust-loco/src/bin/main.rs +++ /dev/null @@ -1,8 +0,0 @@ -use loco_rs::cli; -use server::app::App; -use migration::Migrator; - -#[tokio::main] -async fn main() -> loco_rs::Result<()> { - cli::main::().await -} diff --git a/examples/aws-rust-loco/src/bin/tool.rs b/examples/aws-rust-loco/src/bin/tool.rs deleted file mode 100644 index 9b895c1be2..0000000000 --- a/examples/aws-rust-loco/src/bin/tool.rs +++ /dev/null @@ -1,8 +0,0 @@ -use loco_rs::cli; -use server::app::App; -use migration::Migrator; - -#[tokio::main] -async fn main() -> loco_rs::Result<()> { - cli::main::().await -} diff --git a/examples/aws-rust-loco/src/controllers/auth.rs b/examples/aws-rust-loco/src/controllers/auth.rs deleted file mode 100644 index dba78a3e90..0000000000 --- a/examples/aws-rust-loco/src/controllers/auth.rs +++ /dev/null @@ -1,150 +0,0 @@ -use axum::debug_handler; -use loco_rs::prelude::*; -use serde::{Deserialize, Serialize}; - -use crate::{ - mailers::auth::AuthMailer, - models::{ - _entities::users, - users::{LoginParams, RegisterParams}, - }, - views::auth::LoginResponse, -}; -#[derive(Debug, Deserialize, Serialize)] -pub struct VerifyParams { - pub token: String, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct ForgotParams { - pub email: String, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct ResetParams { - pub token: String, - pub password: String, -} - -/// Register function creates a new user with the given parameters and sends a -/// welcome email to the user -#[debug_handler] -async fn register( - State(ctx): State, - Json(params): Json, -) -> Result { - let res = users::Model::create_with_password(&ctx.db, ¶ms).await; - - let user = match res { - Ok(user) => user, - Err(err) => { - tracing::info!( - message = err.to_string(), - user_email = ¶ms.email, - "could not register user", - ); - return format::json(()); - } - }; - - let user = user - .into_active_model() - .set_email_verification_sent(&ctx.db) - .await?; - - AuthMailer::send_welcome(&ctx, &user).await?; - - format::json(()) -} - -/// Verify register user. if the user not verified his email, he can't login to -/// the system. -#[debug_handler] -async fn verify( - State(ctx): State, - Json(params): Json, -) -> Result { - let user = users::Model::find_by_verification_token(&ctx.db, ¶ms.token).await?; - - if user.email_verified_at.is_some() { - tracing::info!(pid = user.pid.to_string(), "user already verified"); - } else { - let active_model = user.into_active_model(); - let user = active_model.verified(&ctx.db).await?; - tracing::info!(pid = user.pid.to_string(), "user verified"); - } - - format::json(()) -} - -/// In case the user forgot his password this endpoints generate a forgot token -/// and send email to the user. In case the email not found in our DB, we are -/// returning a valid request for for security reasons (not exposing users DB -/// list). -#[debug_handler] -async fn forgot( - State(ctx): State, - Json(params): Json, -) -> Result { - let Ok(user) = users::Model::find_by_email(&ctx.db, ¶ms.email).await else { - // we don't want to expose our users email. if the email is invalid we still - // returning success to the caller - return format::json(()); - }; - - let user = user - .into_active_model() - .set_forgot_password_sent(&ctx.db) - .await?; - - AuthMailer::forgot_password(&ctx, &user).await?; - - format::json(()) -} - -/// reset user password by the given parameters -#[debug_handler] -async fn reset(State(ctx): State, Json(params): Json) -> Result { - let Ok(user) = users::Model::find_by_reset_token(&ctx.db, ¶ms.token).await else { - // we don't want to expose our users email. if the email is invalid we still - // returning success to the caller - tracing::info!("reset token not found"); - - return format::json(()); - }; - user.into_active_model() - .reset_password(&ctx.db, ¶ms.password) - .await?; - - format::json(()) -} - -/// Creates a user login and returns a token -#[debug_handler] -async fn login(State(ctx): State, Json(params): Json) -> Result { - let user = users::Model::find_by_email(&ctx.db, ¶ms.email).await?; - - let valid = user.verify_password(¶ms.password); - - if !valid { - return unauthorized("unauthorized!"); - } - - let jwt_secret = ctx.config.get_jwt_config()?; - - let token = user - .generate_jwt(&jwt_secret.secret, &jwt_secret.expiration) - .or_else(|_| unauthorized("unauthorized!"))?; - - format::json(LoginResponse::new(&user, &token)) -} - -pub fn routes() -> Routes { - Routes::new() - .prefix("auth") - .add("/register", post(register)) - .add("/verify", post(verify)) - .add("/login", post(login)) - .add("/forgot", post(forgot)) - .add("/reset", post(reset)) -} diff --git a/examples/aws-rust-loco/src/controllers/health.rs b/examples/aws-rust-loco/src/controllers/health.rs deleted file mode 100644 index 09858ee4b0..0000000000 --- a/examples/aws-rust-loco/src/controllers/health.rs +++ /dev/null @@ -1,10 +0,0 @@ -use loco_rs::prelude::*; -use serde_json::json; - -async fn check() -> Result { - format::json(json!({ "message": "ok" })) -} - -pub fn routes() -> Routes { - Routes::new().add("/", get(check)) -} diff --git a/examples/aws-rust-loco/src/controllers/mod.rs b/examples/aws-rust-loco/src/controllers/mod.rs deleted file mode 100644 index 5cbdcb54e5..0000000000 --- a/examples/aws-rust-loco/src/controllers/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod auth; -pub mod health; -pub mod notes; -pub mod user; diff --git a/examples/aws-rust-loco/src/controllers/notes.rs b/examples/aws-rust-loco/src/controllers/notes.rs deleted file mode 100644 index f378fb4d8d..0000000000 --- a/examples/aws-rust-loco/src/controllers/notes.rs +++ /dev/null @@ -1,75 +0,0 @@ -#![allow(clippy::missing_errors_doc)] -#![allow(clippy::unnecessary_struct_initialization)] -#![allow(clippy::unused_async)] -use axum::debug_handler; -use loco_rs::prelude::*; -use serde::{Deserialize, Serialize}; - -use crate::models::_entities::notes::{ActiveModel, Entity, Model}; - -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct Params { - pub title: Option, - pub content: Option, -} - -impl Params { - fn update(&self, item: &mut ActiveModel) { - item.title = Set(self.title.clone()); - item.content = Set(self.content.clone()); - } -} - -async fn load_item(ctx: &AppContext, id: i32) -> Result { - let item = Entity::find_by_id(id).one(&ctx.db).await?; - item.ok_or_else(|| Error::NotFound) -} - -#[debug_handler] -pub async fn list(State(ctx): State) -> Result { - format::json(Entity::find().all(&ctx.db).await?) -} - -#[debug_handler] -pub async fn add(State(ctx): State, Json(params): Json) -> Result { - let mut item = ActiveModel { - ..Default::default() - }; - params.update(&mut item); - let item = item.insert(&ctx.db).await?; - format::json(item) -} - -#[debug_handler] -pub async fn update( - Path(id): Path, - State(ctx): State, - Json(params): Json, -) -> Result { - let item = load_item(&ctx, id).await?; - let mut item = item.into_active_model(); - params.update(&mut item); - let item = item.update(&ctx.db).await?; - format::json(item) -} - -#[debug_handler] -pub async fn remove(Path(id): Path, State(ctx): State) -> Result { - load_item(&ctx, id).await?.delete(&ctx.db).await?; - format::empty() -} - -#[debug_handler] -pub async fn get_one(Path(id): Path, State(ctx): State) -> Result { - format::json(load_item(&ctx, id).await?) -} - -pub fn routes() -> Routes { - Routes::new() - .prefix("notes") - .add("/", get(list)) - .add("/", post(add)) - .add("/:id", get(get_one)) - .add("/:id", delete(remove)) - .add("/:id", post(update)) -} diff --git a/examples/aws-rust-loco/src/controllers/user.rs b/examples/aws-rust-loco/src/controllers/user.rs deleted file mode 100644 index 1f432ae9ef..0000000000 --- a/examples/aws-rust-loco/src/controllers/user.rs +++ /dev/null @@ -1,14 +0,0 @@ -use axum::debug_handler; -use loco_rs::prelude::*; - -use crate::{models::_entities::users, views::user::CurrentResponse}; - -#[debug_handler] -async fn current(auth: auth::JWT, State(ctx): State) -> Result { - let user = users::Model::find_by_pid(&ctx.db, &auth.claims.pid).await?; - format::json(CurrentResponse::new(&user)) -} - -pub fn routes() -> Routes { - Routes::new().prefix("user").add("/current", get(current)) -} diff --git a/examples/aws-rust-loco/src/fixtures/notes.yaml b/examples/aws-rust-loco/src/fixtures/notes.yaml deleted file mode 100644 index 0e66c95314..0000000000 --- a/examples/aws-rust-loco/src/fixtures/notes.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -- id: 1 - title: Loco note 1 - content: Loco note 1 content - created_at: "2023-11-12T12:34:56.789Z" - updated_at: "2023-11-12T12:34:56.789Z" -- id: 2 - title: Loco note 2 - content: Loco note 2 content - created_at: "2023-11-12T12:34:56.789Z" - updated_at: "2023-11-12T12:34:56.789Z" diff --git a/examples/aws-rust-loco/src/fixtures/users.yaml b/examples/aws-rust-loco/src/fixtures/users.yaml deleted file mode 100644 index 8f5b5ed2e2..0000000000 --- a/examples/aws-rust-loco/src/fixtures/users.yaml +++ /dev/null @@ -1,17 +0,0 @@ ---- -- id: 1 - pid: 11111111-1111-1111-1111-111111111111 - email: user1@example.com - password: "$argon2id$v=19$m=19456,t=2,p=1$ETQBx4rTgNAZhSaeYZKOZg$eYTdH26CRT6nUJtacLDEboP0li6xUwUF/q5nSlQ8uuc" - api_key: lo-95ec80d7-cb60-4b70-9b4b-9ef74cb88758 - name: user1 - created_at: "2023-11-12T12:34:56.789Z" - updated_at: "2023-11-12T12:34:56.789Z" -- id: 2 - pid: 22222222-2222-2222-2222-222222222222 - email: user2@example.com - password: "$argon2id$v=19$m=19456,t=2,p=1$ETQBx4rTgNAZhSaeYZKOZg$eYTdH26CRT6nUJtacLDEboP0li6xUwUF/q5nSlQ8uuc" - api_key: lo-153561ca-fa84-4e1b-813a-c62526d0a77e - name: user2 - created_at: "2023-11-12T12:34:56.789Z" - updated_at: "2023-11-12T12:34:56.789Z" diff --git a/examples/aws-rust-loco/src/lib.rs b/examples/aws-rust-loco/src/lib.rs deleted file mode 100644 index bcd9cbed82..0000000000 --- a/examples/aws-rust-loco/src/lib.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub mod app; -pub mod controllers; -pub mod mailers; -pub mod models; -pub mod tasks; -pub mod views; -pub mod workers; diff --git a/examples/aws-rust-loco/src/mailers/auth.rs b/examples/aws-rust-loco/src/mailers/auth.rs deleted file mode 100644 index 30bb1bf2f5..0000000000 --- a/examples/aws-rust-loco/src/mailers/auth.rs +++ /dev/null @@ -1,65 +0,0 @@ -// auth mailer -#![allow(non_upper_case_globals)] - -use loco_rs::prelude::*; -use serde_json::json; - -use crate::models::users; - -static welcome: Dir<'_> = include_dir!("src/mailers/auth/welcome"); -static forgot: Dir<'_> = include_dir!("src/mailers/auth/forgot"); -// #[derive(Mailer)] // -- disabled for faster build speed. it works. but lets -// move on for now. - -#[allow(clippy::module_name_repetitions)] -pub struct AuthMailer {} -impl Mailer for AuthMailer {} -impl AuthMailer { - /// Sending welcome email the the given user - /// - /// # Errors - /// - /// When email sending is failed - pub async fn send_welcome(ctx: &AppContext, user: &users::Model) -> Result<()> { - Self::mail_template( - ctx, - &welcome, - mailer::Args { - to: user.email.to_string(), - locals: json!({ - "name": user.name, - "verifyToken": user.email_verification_token, - "domain": ctx.config.server.full_url() - }), - ..Default::default() - }, - ) - .await?; - - Ok(()) - } - - /// Sending forgot password email - /// - /// # Errors - /// - /// When email sending is failed - pub async fn forgot_password(ctx: &AppContext, user: &users::Model) -> Result<()> { - Self::mail_template( - ctx, - &forgot, - mailer::Args { - to: user.email.to_string(), - locals: json!({ - "name": user.name, - "resetToken": user.reset_token, - "domain": ctx.config.server.full_url() - }), - ..Default::default() - }, - ) - .await?; - - Ok(()) - } -} diff --git a/examples/aws-rust-loco/src/mailers/auth/forgot/html.t b/examples/aws-rust-loco/src/mailers/auth/forgot/html.t deleted file mode 100644 index 221dd60205..0000000000 --- a/examples/aws-rust-loco/src/mailers/auth/forgot/html.t +++ /dev/null @@ -1,11 +0,0 @@ -; - - - Hey {{name}}, - Forgot your password? No worries! You can reset it by clicking the link below: - Reset Your Password - If you didn't request a password reset, please ignore this email. - Best regards,
The Loco Team
- - - diff --git a/examples/aws-rust-loco/src/mailers/auth/forgot/subject.t b/examples/aws-rust-loco/src/mailers/auth/forgot/subject.t deleted file mode 100644 index 4938df1e30..0000000000 --- a/examples/aws-rust-loco/src/mailers/auth/forgot/subject.t +++ /dev/null @@ -1 +0,0 @@ -Your reset password link diff --git a/examples/aws-rust-loco/src/mailers/auth/forgot/text.t b/examples/aws-rust-loco/src/mailers/auth/forgot/text.t deleted file mode 100644 index 58c30fd8d1..0000000000 --- a/examples/aws-rust-loco/src/mailers/auth/forgot/text.t +++ /dev/null @@ -1,3 +0,0 @@ -Reset your password with this link: - -http://localhost/reset#{{resetToken}} diff --git a/examples/aws-rust-loco/src/mailers/auth/welcome/html.t b/examples/aws-rust-loco/src/mailers/auth/welcome/html.t deleted file mode 100644 index ae4c41c654..0000000000 --- a/examples/aws-rust-loco/src/mailers/auth/welcome/html.t +++ /dev/null @@ -1,13 +0,0 @@ -; - - - Dear {{name}}, - Welcome to Loco! You can now log in to your account. - Before you get started, please verify your account by clicking the link below: - - Verify Your Account - -

Best regards,
The Loco Team

- - - diff --git a/examples/aws-rust-loco/src/mailers/auth/welcome/subject.t b/examples/aws-rust-loco/src/mailers/auth/welcome/subject.t deleted file mode 100644 index 82cc6fbf7b..0000000000 --- a/examples/aws-rust-loco/src/mailers/auth/welcome/subject.t +++ /dev/null @@ -1 +0,0 @@ -Welcome {{name}} diff --git a/examples/aws-rust-loco/src/mailers/auth/welcome/text.t b/examples/aws-rust-loco/src/mailers/auth/welcome/text.t deleted file mode 100644 index 63beefd565..0000000000 --- a/examples/aws-rust-loco/src/mailers/auth/welcome/text.t +++ /dev/null @@ -1,4 +0,0 @@ -Welcome {{name}}, you can now log in. - Verify your account with the link below: - - http://localhost/verify#{{verifyToken}} diff --git a/examples/aws-rust-loco/src/mailers/mod.rs b/examples/aws-rust-loco/src/mailers/mod.rs deleted file mode 100644 index 0e4a05d597..0000000000 --- a/examples/aws-rust-loco/src/mailers/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod auth; diff --git a/examples/aws-rust-loco/src/models/_entities/mod.rs b/examples/aws-rust-loco/src/models/_entities/mod.rs deleted file mode 100644 index c04afbb655..0000000000 --- a/examples/aws-rust-loco/src/models/_entities/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0 - -pub mod prelude; - -pub mod notes; -pub mod users; diff --git a/examples/aws-rust-loco/src/models/_entities/notes.rs b/examples/aws-rust-loco/src/models/_entities/notes.rs deleted file mode 100644 index a803353897..0000000000 --- a/examples/aws-rust-loco/src/models/_entities/notes.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0 - -use sea_orm::entity::prelude::*; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] -#[sea_orm(table_name = "notes")] -pub struct Model { - pub created_at: DateTimeWithTimeZone, - pub updated_at: DateTimeWithTimeZone, - #[sea_orm(primary_key)] - pub id: i32, - pub title: Option, - pub content: Option, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation {} diff --git a/examples/aws-rust-loco/src/models/_entities/prelude.rs b/examples/aws-rust-loco/src/models/_entities/prelude.rs deleted file mode 100644 index 4d1101962e..0000000000 --- a/examples/aws-rust-loco/src/models/_entities/prelude.rs +++ /dev/null @@ -1,4 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0 - -pub use super::notes::Entity as Notes; -pub use super::users::Entity as Users; diff --git a/examples/aws-rust-loco/src/models/_entities/users.rs b/examples/aws-rust-loco/src/models/_entities/users.rs deleted file mode 100644 index 120b1a1b1f..0000000000 --- a/examples/aws-rust-loco/src/models/_entities/users.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0 - -use sea_orm::entity::prelude::*; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] -#[sea_orm(table_name = "users")] -pub struct Model { - pub created_at: DateTimeWithTimeZone, - pub updated_at: DateTimeWithTimeZone, - #[sea_orm(primary_key)] - pub id: i32, - pub pid: Uuid, - #[sea_orm(unique)] - pub email: String, - pub password: String, - #[sea_orm(unique)] - pub api_key: String, - pub name: String, - pub reset_token: Option, - pub reset_sent_at: Option, - pub email_verification_token: Option, - pub email_verification_sent_at: Option, - pub email_verified_at: Option, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation {} diff --git a/examples/aws-rust-loco/src/models/mod.rs b/examples/aws-rust-loco/src/models/mod.rs deleted file mode 100644 index 917969b1c7..0000000000 --- a/examples/aws-rust-loco/src/models/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod _entities; -pub mod notes; -pub mod users; diff --git a/examples/aws-rust-loco/src/models/notes.rs b/examples/aws-rust-loco/src/models/notes.rs deleted file mode 100644 index 1102598236..0000000000 --- a/examples/aws-rust-loco/src/models/notes.rs +++ /dev/null @@ -1,7 +0,0 @@ -use sea_orm::entity::prelude::*; - -use super::_entities::notes::ActiveModel; - -impl ActiveModelBehavior for ActiveModel { - // extend activemodel below (keep comment for generators) -} diff --git a/examples/aws-rust-loco/src/models/users.rs b/examples/aws-rust-loco/src/models/users.rs deleted file mode 100644 index 510802e0bb..0000000000 --- a/examples/aws-rust-loco/src/models/users.rs +++ /dev/null @@ -1,297 +0,0 @@ -use async_trait::async_trait; -use chrono::offset::Local; -use loco_rs::{auth::jwt, hash, prelude::*}; -use serde::{Deserialize, Serialize}; -use uuid::Uuid; - -pub use super::_entities::users::{self, ActiveModel, Entity, Model}; - -#[derive(Debug, Deserialize, Serialize)] -pub struct LoginParams { - pub email: String, - pub password: String, -} - -#[derive(Debug, Deserialize, Serialize)] -pub struct RegisterParams { - pub email: String, - pub password: String, - pub name: String, -} - -#[derive(Debug, Validate, Deserialize)] -pub struct Validator { - #[validate(length(min = 2, message = "Name must be at least 2 characters long."))] - pub name: String, - #[validate(custom = "validation::is_valid_email")] - pub email: String, -} - -impl Validatable for super::_entities::users::ActiveModel { - fn validator(&self) -> Box { - Box::new(Validator { - name: self.name.as_ref().to_owned(), - email: self.email.as_ref().to_owned(), - }) - } -} - -#[async_trait::async_trait] -impl ActiveModelBehavior for super::_entities::users::ActiveModel { - async fn before_save(self, _db: &C, insert: bool) -> Result - where - C: ConnectionTrait, - { - self.validate()?; - if insert { - let mut this = self; - this.pid = ActiveValue::Set(Uuid::new_v4()); - this.api_key = ActiveValue::Set(format!("lo-{}", Uuid::new_v4())); - Ok(this) - } else { - Ok(self) - } - } -} - -#[async_trait] -impl Authenticable for super::_entities::users::Model { - async fn find_by_api_key(db: &DatabaseConnection, api_key: &str) -> ModelResult { - let user = users::Entity::find() - .filter( - model::query::condition() - .eq(users::Column::ApiKey, api_key) - .build(), - ) - .one(db) - .await?; - user.ok_or_else(|| ModelError::EntityNotFound) - } - - async fn find_by_claims_key(db: &DatabaseConnection, claims_key: &str) -> ModelResult { - Self::find_by_pid(db, claims_key).await - } -} - -impl super::_entities::users::Model { - /// finds a user by the provided email - /// - /// # Errors - /// - /// When could not find user by the given token or DB query error - pub async fn find_by_email(db: &DatabaseConnection, email: &str) -> ModelResult { - let user = users::Entity::find() - .filter( - model::query::condition() - .eq(users::Column::Email, email) - .build(), - ) - .one(db) - .await?; - user.ok_or_else(|| ModelError::EntityNotFound) - } - - /// finds a user by the provided verification token - /// - /// # Errors - /// - /// When could not find user by the given token or DB query error - pub async fn find_by_verification_token( - db: &DatabaseConnection, - token: &str, - ) -> ModelResult { - let user = users::Entity::find() - .filter( - model::query::condition() - .eq(users::Column::EmailVerificationToken, token) - .build(), - ) - .one(db) - .await?; - user.ok_or_else(|| ModelError::EntityNotFound) - } - - /// /// finds a user by the provided reset token - /// - /// # Errors - /// - /// When could not find user by the given token or DB query error - pub async fn find_by_reset_token(db: &DatabaseConnection, token: &str) -> ModelResult { - let user = users::Entity::find() - .filter( - model::query::condition() - .eq(users::Column::ResetToken, token) - .build(), - ) - .one(db) - .await?; - user.ok_or_else(|| ModelError::EntityNotFound) - } - - /// finds a user by the provided pid - /// - /// # Errors - /// - /// When could not find user or DB query error - pub async fn find_by_pid(db: &DatabaseConnection, pid: &str) -> ModelResult { - let parse_uuid = Uuid::parse_str(pid).map_err(|e| ModelError::Any(e.into()))?; - let user = users::Entity::find() - .filter( - model::query::condition() - .eq(users::Column::Pid, parse_uuid) - .build(), - ) - .one(db) - .await?; - user.ok_or_else(|| ModelError::EntityNotFound) - } - - /// finds a user by the provided api key - /// - /// # Errors - /// - /// When could not find user by the given token or DB query error - pub async fn find_by_api_key(db: &DatabaseConnection, api_key: &str) -> ModelResult { - let user = users::Entity::find() - .filter( - model::query::condition() - .eq(users::Column::ApiKey, api_key) - .build(), - ) - .one(db) - .await?; - user.ok_or_else(|| ModelError::EntityNotFound) - } - - /// Verifies whether the provided plain password matches the hashed password - /// - /// # Errors - /// - /// when could not verify password - #[must_use] - pub fn verify_password(&self, password: &str) -> bool { - hash::verify_password(password, &self.password) - } - - /// Asynchronously creates a user with a password and saves it to the - /// database. - /// - /// # Errors - /// - /// When could not save the user into the DB - pub async fn create_with_password( - db: &DatabaseConnection, - params: &RegisterParams, - ) -> ModelResult { - let txn = db.begin().await?; - - if users::Entity::find() - .filter( - model::query::condition() - .eq(users::Column::Email, ¶ms.email) - .build(), - ) - .one(&txn) - .await? - .is_some() - { - return Err(ModelError::EntityAlreadyExists {}); - } - - let password_hash = - hash::hash_password(¶ms.password).map_err(|e| ModelError::Any(e.into()))?; - let user = users::ActiveModel { - email: ActiveValue::set(params.email.to_string()), - password: ActiveValue::set(password_hash), - name: ActiveValue::set(params.name.to_string()), - ..Default::default() - } - .insert(&txn) - .await?; - - txn.commit().await?; - - Ok(user) - } - - /// Creates a JWT - /// - /// # Errors - /// - /// when could not convert user claims to jwt token - pub fn generate_jwt(&self, secret: &str, expiration: &u64) -> ModelResult { - Ok(jwt::JWT::new(secret).generate_token(expiration, self.pid.to_string(), None)?) - } -} - -impl super::_entities::users::ActiveModel { - /// Sets the email verification information for the user and - /// updates it in the database. - /// - /// This method is used to record the timestamp when the email verification - /// was sent and generate a unique verification token for the user. - /// - /// # Errors - /// - /// when has DB query error - pub async fn set_email_verification_sent( - mut self, - db: &DatabaseConnection, - ) -> ModelResult { - self.email_verification_sent_at = ActiveValue::set(Some(Local::now().into())); - self.email_verification_token = ActiveValue::Set(Some(Uuid::new_v4().to_string())); - Ok(self.update(db).await?) - } - - /// Sets the information for a reset password request, - /// generates a unique reset password token, and updates it in the - /// database. - /// - /// This method records the timestamp when the reset password token is sent - /// and generates a unique token for the user. - /// - /// # Arguments - /// - /// # Errors - /// - /// when has DB query error - pub async fn set_forgot_password_sent(mut self, db: &DatabaseConnection) -> ModelResult { - self.reset_sent_at = ActiveValue::set(Some(Local::now().into())); - self.reset_token = ActiveValue::Set(Some(Uuid::new_v4().to_string())); - Ok(self.update(db).await?) - } - - /// Records the verification time when a user verifies their - /// email and updates it in the database. - /// - /// This method sets the timestamp when the user successfully verifies their - /// email. - /// - /// # Errors - /// - /// when has DB query error - pub async fn verified(mut self, db: &DatabaseConnection) -> ModelResult { - self.email_verified_at = ActiveValue::set(Some(Local::now().into())); - Ok(self.update(db).await?) - } - - /// Resets the current user password with a new password and - /// updates it in the database. - /// - /// This method hashes the provided password and sets it as the new password - /// for the user. - /// # Errors - /// - /// when has DB query error or could not hashed the given password - pub async fn reset_password( - mut self, - db: &DatabaseConnection, - password: &str, - ) -> ModelResult { - self.password = - ActiveValue::set(hash::hash_password(password).map_err(|e| ModelError::Any(e.into()))?); - self.reset_token = ActiveValue::Set(None); - self.reset_sent_at = ActiveValue::Set(None); - Ok(self.update(db).await?) - } -} diff --git a/examples/aws-rust-loco/src/tasks/mod.rs b/examples/aws-rust-loco/src/tasks/mod.rs deleted file mode 100644 index 01fbddaa29..0000000000 --- a/examples/aws-rust-loco/src/tasks/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod seed; diff --git a/examples/aws-rust-loco/src/tasks/seed.rs b/examples/aws-rust-loco/src/tasks/seed.rs deleted file mode 100644 index 1647beb84c..0000000000 --- a/examples/aws-rust-loco/src/tasks/seed.rs +++ /dev/null @@ -1,45 +0,0 @@ -//! This task implements data seeding functionality for initializing new -//! development/demo environments. -//! -//! # Example -//! -//! Run the task with the following command: -//! ```sh -//! cargo run task -//! ``` -//! -//! To override existing data and reset the data structure, use the following -//! command with the `refresh:true` argument: -//! ```sh -//! cargo run task seed_data refresh:true -//! ``` - -use loco_rs::{db, prelude::*}; -use migration::Migrator; - -use crate::app::App; - -#[allow(clippy::module_name_repetitions)] -pub struct SeedData; -#[async_trait] -impl Task for SeedData { - fn task(&self) -> TaskInfo { - TaskInfo { - name: "seed_data".to_string(), - detail: "Task for seeding data".to_string(), - } - } - - async fn run(&self, app_context: &AppContext, vars: &task::Vars) -> Result<()> { - let refresh = vars - .cli_arg("refresh") - .is_ok_and(|refresh| refresh == "true"); - - if refresh { - db::reset::(&app_context.db).await?; - } - let path = std::path::Path::new("src/fixtures"); - db::run_app_seed::(&app_context.db, path).await?; - Ok(()) - } -} diff --git a/examples/aws-rust-loco/src/views/auth.rs b/examples/aws-rust-loco/src/views/auth.rs deleted file mode 100644 index 2240a5087e..0000000000 --- a/examples/aws-rust-loco/src/views/auth.rs +++ /dev/null @@ -1,23 +0,0 @@ -use serde::{Deserialize, Serialize}; - -use crate::models::_entities::users; - -#[derive(Debug, Deserialize, Serialize)] -pub struct LoginResponse { - pub token: String, - pub pid: String, - pub name: String, - pub is_verified: bool, -} - -impl LoginResponse { - #[must_use] - pub fn new(user: &users::Model, token: &String) -> Self { - Self { - token: token.to_string(), - pid: user.pid.to_string(), - name: user.name.clone(), - is_verified: user.email_verified_at.is_some(), - } - } -} diff --git a/examples/aws-rust-loco/src/views/mod.rs b/examples/aws-rust-loco/src/views/mod.rs deleted file mode 100644 index f9bae3db2a..0000000000 --- a/examples/aws-rust-loco/src/views/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod auth; -pub mod user; diff --git a/examples/aws-rust-loco/src/views/user.rs b/examples/aws-rust-loco/src/views/user.rs deleted file mode 100644 index 9d830410fb..0000000000 --- a/examples/aws-rust-loco/src/views/user.rs +++ /dev/null @@ -1,21 +0,0 @@ -use serde::{Deserialize, Serialize}; - -use crate::models::_entities::users; - -#[derive(Debug, Deserialize, Serialize)] -pub struct CurrentResponse { - pub pid: String, - pub name: String, - pub email: String, -} - -impl CurrentResponse { - #[must_use] - pub fn new(user: &users::Model) -> Self { - Self { - pid: user.pid.to_string(), - name: user.name.clone(), - email: user.email.clone(), - } - } -} diff --git a/examples/aws-rust-loco/src/workers/downloader.rs b/examples/aws-rust-loco/src/workers/downloader.rs deleted file mode 100644 index 42c0bd7a46..0000000000 --- a/examples/aws-rust-loco/src/workers/downloader.rs +++ /dev/null @@ -1,43 +0,0 @@ -use std::time::Duration; - -use loco_rs::prelude::*; -use serde::{Deserialize, Serialize}; -use tokio::time::sleep; - -use crate::models::users; - -pub struct DownloadWorker { - pub ctx: AppContext, -} - -#[derive(Deserialize, Debug, Serialize)] -pub struct DownloadWorkerArgs { - pub user_guid: String, -} - -impl worker::AppWorker for DownloadWorker { - fn build(ctx: &AppContext) -> Self { - Self { ctx: ctx.clone() } - } -} - -#[async_trait] -impl worker::Worker for DownloadWorker { - async fn perform(&self, args: DownloadWorkerArgs) -> worker::Result<()> { - // TODO: Some actual work goes here... - println!("================================================"); - println!("Sending payment report to user {}", args.user_guid); - - sleep(Duration::from_millis(2000)).await; - - let all = users::Entity::find() - .all(&self.ctx.db) - .await - .map_err(Box::from)?; - for user in &all { - println!("user: {}", user.id); - } - println!("================================================"); - Ok(()) - } -} diff --git a/examples/aws-rust-loco/src/workers/mod.rs b/examples/aws-rust-loco/src/workers/mod.rs deleted file mode 100644 index acb5733da2..0000000000 --- a/examples/aws-rust-loco/src/workers/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod downloader; diff --git a/examples/aws-rust-loco/sst.config.ts b/examples/aws-rust-loco/sst.config.ts deleted file mode 100644 index bc9a6289d8..0000000000 --- a/examples/aws-rust-loco/sst.config.ts +++ /dev/null @@ -1,68 +0,0 @@ -/// - -/** - * ## Rust Loco - * - * Deploy a Rust Loco app with a Postgres database, Redis, and a background worker - * service. - */ -export default $config({ - app(input) { - return { - name: "aws-rust-loco", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("LocoVpc", { - bastion: true, - }); - - const database = new sst.aws.Postgres("LocoDatabase", { vpc }); - - const redis = new sst.aws.Redis("LocoRedis", { vpc }); - - const DATABASE_URL = $interpolate`postgres://${ - database.username - }:${database.password.apply(encodeURIComponent)}@${database.host}:${ - database.port - }/${database.database}`; - const REDIS_URL = $interpolate`redis://${ - redis.username - }:${redis.password.apply(encodeURIComponent)}@${redis.host}:${redis.port}`; - - const locoCluster = new sst.aws.Cluster("LocoCluster", { vpc }); - - // external facing http service - const locoServer = new sst.aws.Service("LocoApp", { - cluster: locoCluster, - architecture: "x86_64", - scaling: { min: 2, max: 4 }, - command: ["start"], - loadBalancer: { - ports: [{ listen: "80/http", forward: "5150/http" }], - }, - environment: { - DATABASE_URL, - REDIS_URL, - }, - link: [database, redis], - dev: { - command: "cargo loco start", - }, - }); - - // add a worker that uses redis to process jobs off a queue - new sst.aws.Service("LocoWorker", { - cluster: locoCluster, - architecture: "x86_64", - command: ["start", "--worker"], - environment: { - DATABASE_URL, - REDIS_URL, - }, - link: [database, redis], - }); - }, -}); diff --git a/examples/aws-rust-loco/tests/mod.rs b/examples/aws-rust-loco/tests/mod.rs deleted file mode 100644 index e56e882575..0000000000 --- a/examples/aws-rust-loco/tests/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod models; -mod requests; -mod tasks; diff --git a/examples/aws-rust-loco/tests/models/mod.rs b/examples/aws-rust-loco/tests/models/mod.rs deleted file mode 100644 index 59759880db..0000000000 --- a/examples/aws-rust-loco/tests/models/mod.rs +++ /dev/null @@ -1 +0,0 @@ -mod users; diff --git a/examples/aws-rust-loco/tests/models/snapshots/can_create_with_password@users.snap b/examples/aws-rust-loco/tests/models/snapshots/can_create_with_password@users.snap deleted file mode 100644 index 6e66fd35ae..0000000000 --- a/examples/aws-rust-loco/tests/models/snapshots/can_create_with_password@users.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: tests/models/users.rs -expression: res ---- -Ok( - Model { - created_at: DATE, - updated_at: DATE, - id: ID - pid: PID, - email: "test@framework.com", - password: "PASSWORD", - api_key: "lo-PID", - name: "framework", - reset_token: None, - reset_sent_at: None, - email_verification_token: None, - email_verification_sent_at: None, - email_verified_at: None, - }, -) diff --git a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_email-2@users.snap b/examples/aws-rust-loco/tests/models/snapshots/can_find_by_email-2@users.snap deleted file mode 100644 index 83dc06e1d9..0000000000 --- a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_email-2@users.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: tests/models/main.rs -expression: non_existing_user_results ---- -Err( - EntityNotFound, -) diff --git a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_email@users-2.snap b/examples/aws-rust-loco/tests/models/snapshots/can_find_by_email@users-2.snap deleted file mode 100644 index 25c700a5a8..0000000000 --- a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_email@users-2.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: tests/models/users.rs -expression: non_existing_user_results ---- -Err( - EntityNotFound, -) diff --git a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_email@users.snap b/examples/aws-rust-loco/tests/models/snapshots/can_find_by_email@users.snap deleted file mode 100644 index 067d0e7521..0000000000 --- a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_email@users.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: tests/models/users.rs -expression: existing_user ---- -Ok( - Model { - created_at: 2023-11-12T12:34:56.789+00:00, - updated_at: 2023-11-12T12:34:56.789+00:00, - id: 1, - pid: 11111111-1111-1111-1111-111111111111, - email: "user1@example.com", - password: "$argon2id$v=19$m=19456,t=2,p=1$ETQBx4rTgNAZhSaeYZKOZg$eYTdH26CRT6nUJtacLDEboP0li6xUwUF/q5nSlQ8uuc", - api_key: "lo-95ec80d7-cb60-4b70-9b4b-9ef74cb88758", - name: "user1", - reset_token: None, - reset_sent_at: None, - email_verification_token: None, - email_verification_sent_at: None, - email_verified_at: None, - }, -) diff --git a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_pid-2@users.snap b/examples/aws-rust-loco/tests/models/snapshots/can_find_by_pid-2@users.snap deleted file mode 100644 index 83dc06e1d9..0000000000 --- a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_pid-2@users.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: tests/models/main.rs -expression: non_existing_user_results ---- -Err( - EntityNotFound, -) diff --git a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_pid@users-2.snap b/examples/aws-rust-loco/tests/models/snapshots/can_find_by_pid@users-2.snap deleted file mode 100644 index 25c700a5a8..0000000000 --- a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_pid@users-2.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: tests/models/users.rs -expression: non_existing_user_results ---- -Err( - EntityNotFound, -) diff --git a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_pid@users.snap b/examples/aws-rust-loco/tests/models/snapshots/can_find_by_pid@users.snap deleted file mode 100644 index 067d0e7521..0000000000 --- a/examples/aws-rust-loco/tests/models/snapshots/can_find_by_pid@users.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: tests/models/users.rs -expression: existing_user ---- -Ok( - Model { - created_at: 2023-11-12T12:34:56.789+00:00, - updated_at: 2023-11-12T12:34:56.789+00:00, - id: 1, - pid: 11111111-1111-1111-1111-111111111111, - email: "user1@example.com", - password: "$argon2id$v=19$m=19456,t=2,p=1$ETQBx4rTgNAZhSaeYZKOZg$eYTdH26CRT6nUJtacLDEboP0li6xUwUF/q5nSlQ8uuc", - api_key: "lo-95ec80d7-cb60-4b70-9b4b-9ef74cb88758", - name: "user1", - reset_token: None, - reset_sent_at: None, - email_verification_token: None, - email_verification_sent_at: None, - email_verified_at: None, - }, -) diff --git a/examples/aws-rust-loco/tests/models/snapshots/can_validate_model@users.snap b/examples/aws-rust-loco/tests/models/snapshots/can_validate_model@users.snap deleted file mode 100644 index 4d457a7032..0000000000 --- a/examples/aws-rust-loco/tests/models/snapshots/can_validate_model@users.snap +++ /dev/null @@ -1,9 +0,0 @@ ---- -source: tests/models/main.rs -expression: res ---- -Err( - Custom( - "{\"email\":[{\"code\":\"invalid email\",\"message\":null}],\"name\":[{\"code\":\"length\",\"message\":\"Name must be at least 2 characters long.\"}]}", - ), -) diff --git a/examples/aws-rust-loco/tests/models/snapshots/handle_create_with_password_with_duplicate@users.snap b/examples/aws-rust-loco/tests/models/snapshots/handle_create_with_password_with_duplicate@users.snap deleted file mode 100644 index ff28ea196a..0000000000 --- a/examples/aws-rust-loco/tests/models/snapshots/handle_create_with_password_with_duplicate@users.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: tests/models/users.rs -expression: new_user ---- -Err( - EntityAlreadyExists, -) diff --git a/examples/aws-rust-loco/tests/models/users.rs b/examples/aws-rust-loco/tests/models/users.rs deleted file mode 100644 index f57a32213e..0000000000 --- a/examples/aws-rust-loco/tests/models/users.rs +++ /dev/null @@ -1,223 +0,0 @@ -use insta::assert_debug_snapshot; -use loco_rs::{model::ModelError, testing}; -use server::{ - app::App, - models::users::{self, Model, RegisterParams}, -}; -use sea_orm::{ActiveModelTrait, ActiveValue, IntoActiveModel}; -use serial_test::serial; - -macro_rules! configure_insta { - ($($expr:expr),*) => { - let mut settings = insta::Settings::clone_current(); - settings.set_prepend_module_to_snapshot(false); - settings.set_snapshot_suffix("users"); - let _guard = settings.bind_to_scope(); - }; -} - -#[tokio::test] -#[serial] -async fn test_can_validate_model() { - configure_insta!(); - - let boot = testing::boot_test::().await.unwrap(); - - let res = users::ActiveModel { - name: ActiveValue::set("1".to_string()), - email: ActiveValue::set("invalid-email".to_string()), - ..Default::default() - } - .insert(&boot.app_context.db) - .await; - - assert_debug_snapshot!(res); -} - -#[tokio::test] -#[serial] -async fn can_create_with_password() { - configure_insta!(); - - let boot = testing::boot_test::().await.unwrap(); - - let params = RegisterParams { - email: "test@framework.com".to_string(), - password: "1234".to_string(), - name: "framework".to_string(), - }; - let res = Model::create_with_password(&boot.app_context.db, ¶ms).await; - - insta::with_settings!({ - filters => testing::cleanup_user_model() - }, { - assert_debug_snapshot!(res); - }); -} - -#[tokio::test] -#[serial] -async fn handle_create_with_password_with_duplicate() { - configure_insta!(); - - let boot = testing::boot_test::().await.unwrap(); - testing::seed::(&boot.app_context.db).await.unwrap(); - - let new_user: Result = Model::create_with_password( - &boot.app_context.db, - &RegisterParams { - email: "user1@example.com".to_string(), - password: "1234".to_string(), - name: "framework".to_string(), - }, - ) - .await; - assert_debug_snapshot!(new_user); -} - -#[tokio::test] -#[serial] -async fn can_find_by_email() { - configure_insta!(); - - let boot = testing::boot_test::().await.unwrap(); - testing::seed::(&boot.app_context.db).await.unwrap(); - - let existing_user = Model::find_by_email(&boot.app_context.db, "user1@example.com").await; - let non_existing_user_results = - Model::find_by_email(&boot.app_context.db, "un@existing-email.com").await; - - assert_debug_snapshot!(existing_user); - assert_debug_snapshot!(non_existing_user_results); -} - -#[tokio::test] -#[serial] -async fn can_find_by_pid() { - configure_insta!(); - - let boot = testing::boot_test::().await.unwrap(); - testing::seed::(&boot.app_context.db).await.unwrap(); - - let existing_user = - Model::find_by_pid(&boot.app_context.db, "11111111-1111-1111-1111-111111111111").await; - let non_existing_user_results = - Model::find_by_pid(&boot.app_context.db, "23232323-2323-2323-2323-232323232323").await; - - assert_debug_snapshot!(existing_user); - assert_debug_snapshot!(non_existing_user_results); -} - -#[tokio::test] -#[serial] -async fn can_verification_token() { - configure_insta!(); - - let boot = testing::boot_test::().await.unwrap(); - testing::seed::(&boot.app_context.db).await.unwrap(); - - let user = Model::find_by_pid(&boot.app_context.db, "11111111-1111-1111-1111-111111111111") - .await - .unwrap(); - - assert!(user.email_verification_sent_at.is_none()); - assert!(user.email_verification_token.is_none()); - - assert!(user - .into_active_model() - .set_email_verification_sent(&boot.app_context.db) - .await - .is_ok()); - - let user = Model::find_by_pid(&boot.app_context.db, "11111111-1111-1111-1111-111111111111") - .await - .unwrap(); - - assert!(user.email_verification_sent_at.is_some()); - assert!(user.email_verification_token.is_some()); -} - -#[tokio::test] -#[serial] -async fn can_set_forgot_password_sent() { - configure_insta!(); - - let boot = testing::boot_test::().await.unwrap(); - testing::seed::(&boot.app_context.db).await.unwrap(); - - let user = Model::find_by_pid(&boot.app_context.db, "11111111-1111-1111-1111-111111111111") - .await - .unwrap(); - - assert!(user.reset_sent_at.is_none()); - assert!(user.reset_token.is_none()); - - assert!(user - .into_active_model() - .set_forgot_password_sent(&boot.app_context.db) - .await - .is_ok()); - - let user = Model::find_by_pid(&boot.app_context.db, "11111111-1111-1111-1111-111111111111") - .await - .unwrap(); - - assert!(user.reset_sent_at.is_some()); - assert!(user.reset_token.is_some()); -} - -#[tokio::test] -#[serial] -async fn can_verified() { - configure_insta!(); - - let boot = testing::boot_test::().await.unwrap(); - testing::seed::(&boot.app_context.db).await.unwrap(); - - let user = Model::find_by_pid(&boot.app_context.db, "11111111-1111-1111-1111-111111111111") - .await - .unwrap(); - - assert!(user.email_verified_at.is_none()); - - assert!(user - .into_active_model() - .verified(&boot.app_context.db) - .await - .is_ok()); - - let user = Model::find_by_pid(&boot.app_context.db, "11111111-1111-1111-1111-111111111111") - .await - .unwrap(); - - assert!(user.email_verified_at.is_some()); -} - -#[tokio::test] -#[serial] -async fn can_reset_password() { - configure_insta!(); - - let boot = testing::boot_test::().await.unwrap(); - testing::seed::(&boot.app_context.db).await.unwrap(); - - let user = Model::find_by_pid(&boot.app_context.db, "11111111-1111-1111-1111-111111111111") - .await - .unwrap(); - - assert!(user.verify_password("12341234")); - - assert!(user - .clone() - .into_active_model() - .reset_password(&boot.app_context.db, "new-password") - .await - .is_ok()); - - assert!( - Model::find_by_pid(&boot.app_context.db, "11111111-1111-1111-1111-111111111111") - .await - .unwrap() - .verify_password("new-password") - ); -} diff --git a/examples/aws-rust-loco/tests/requests/auth.rs b/examples/aws-rust-loco/tests/requests/auth.rs deleted file mode 100644 index 43352ed1c7..0000000000 --- a/examples/aws-rust-loco/tests/requests/auth.rs +++ /dev/null @@ -1,195 +0,0 @@ -use insta::{assert_debug_snapshot, with_settings}; -use loco_rs::testing; -use server::{app::App, models::users}; -use rstest::rstest; -use serial_test::serial; - -use super::prepare_data; - -// TODO: see how to dedup / extract this to app-local test utils -// not to framework, because that would require a runtime dep on insta -macro_rules! configure_insta { - ($($expr:expr),*) => { - let mut settings = insta::Settings::clone_current(); - settings.set_prepend_module_to_snapshot(false); - settings.set_snapshot_suffix("auth_request"); - let _guard = settings.bind_to_scope(); - }; -} - -#[tokio::test] -#[serial] -async fn can_register() { - configure_insta!(); - - testing::request::(|request, ctx| async move { - let email = "test@loco.com"; - let payload = serde_json::json!({ - "name": "loco", - "email": email, - "password": "12341234" - }); - - let _response = request.post("/api/auth/register").json(&payload).await; - let saved_user = users::Model::find_by_email(&ctx.db, email).await; - - with_settings!({ - filters => testing::cleanup_user_model() - }, { - assert_debug_snapshot!(saved_user); - }); - - with_settings!({ - filters => testing::cleanup_email() - }, { - assert_debug_snapshot!(ctx.mailer.unwrap().deliveries()); - }); - }) - .await; -} - -#[rstest] -#[case("login_with_valid_password", "12341234")] -#[case("login_with_invalid_password", "invalid-password")] -#[tokio::test] -#[serial] -async fn can_login_with_verify(#[case] test_name: &str, #[case] password: &str) { - configure_insta!(); - - testing::request::(|request, ctx| async move { - let email = "test@loco.com"; - let register_payload = serde_json::json!({ - "name": "loco", - "email": email, - "password": "12341234" - }); - - //Creating a new user - _ = request - .post("/api/auth/register") - .json(®ister_payload) - .await; - - let user = users::Model::find_by_email(&ctx.db, email).await.unwrap(); - let verify_payload = serde_json::json!({ - "token": user.email_verification_token, - }); - request.post("/api/auth/verify").json(&verify_payload).await; - - //verify user request - let response = request - .post("/api/auth/login") - .json(&serde_json::json!({ - "email": email, - "password": password - })) - .await; - - // Make sure email_verified_at is set - assert!(users::Model::find_by_email(&ctx.db, email) - .await - .unwrap() - .email_verified_at - .is_some()); - - with_settings!({ - filters => testing::cleanup_user_model() - }, { - assert_debug_snapshot!(test_name, (response.status_code(), response.text())); - }); - }) - .await; -} - -#[tokio::test] -#[serial] -async fn can_login_without_verify() { - configure_insta!(); - - testing::request::(|request, _ctx| async move { - let email = "test@loco.com"; - let password = "12341234"; - let register_payload = serde_json::json!({ - "name": "loco", - "email": email, - "password": password - }); - - //Creating a new user - _ = request - .post("/api/auth/register") - .json(®ister_payload) - .await; - - //verify user request - let response = request - .post("/api/auth/login") - .json(&serde_json::json!({ - "email": email, - "password": password - })) - .await; - - with_settings!({ - filters => testing::cleanup_user_model() - }, { - assert_debug_snapshot!((response.status_code(), response.text())); - }); - }) - .await; -} - -#[tokio::test] -#[serial] -async fn can_reset_password() { - configure_insta!(); - - testing::request::(|request, ctx| async move { - let login_data = prepare_data::init_user_login(&request, &ctx).await; - - let forgot_payload = serde_json::json!({ - "email": login_data.user.email, - }); - _ = request.post("/api/auth/forgot").json(&forgot_payload).await; - - let user = users::Model::find_by_email(&ctx.db, &login_data.user.email) - .await - .unwrap(); - assert!(user.reset_token.is_some()); - assert!(user.reset_sent_at.is_some()); - - let new_password = "new-password"; - let reset_payload = serde_json::json!({ - "token": user.reset_token, - "password": new_password, - }); - - let reset_response = request.post("/api/auth/reset").json(&reset_payload).await; - - let user = users::Model::find_by_email(&ctx.db, &user.email) - .await - .unwrap(); - - assert!(user.reset_token.is_none()); - assert!(user.reset_sent_at.is_none()); - - assert_debug_snapshot!((reset_response.status_code(), reset_response.text())); - - let response = request - .post("/api/auth/login") - .json(&serde_json::json!({ - "email": user.email, - "password": new_password - })) - .await; - - assert_eq!(response.status_code(), 200); - - with_settings!({ - filters => testing::cleanup_email() - }, { - assert_debug_snapshot!(ctx.mailer.unwrap().deliveries()); - }); - }) - .await; -} diff --git a/examples/aws-rust-loco/tests/requests/mod.rs b/examples/aws-rust-loco/tests/requests/mod.rs deleted file mode 100644 index 81ed68f960..0000000000 --- a/examples/aws-rust-loco/tests/requests/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -mod auth; -mod notes; -mod prepare_data; -mod user; diff --git a/examples/aws-rust-loco/tests/requests/notes.rs b/examples/aws-rust-loco/tests/requests/notes.rs deleted file mode 100644 index 4709cf6f47..0000000000 --- a/examples/aws-rust-loco/tests/requests/notes.rs +++ /dev/null @@ -1,123 +0,0 @@ -use insta::{assert_debug_snapshot, with_settings}; -use loco_rs::testing; -use server::{app::App, models::_entities::notes::Entity}; -use sea_orm::entity::prelude::*; -use serial_test::serial; - -// TODO: see how to dedup / extract this to app-local test utils -// not to framework, because that would require a runtime dep on insta -macro_rules! configure_insta { - ($($expr:expr),*) => { - let mut settings = insta::Settings::clone_current(); - settings.set_prepend_module_to_snapshot(false); - settings.set_snapshot_suffix("notes_request"); - let _guard = settings.bind_to_scope(); - }; -} - -#[tokio::test] -#[serial] -async fn can_get_notes() { - configure_insta!(); - - testing::request::(|request, ctx| async move { - testing::seed::(&ctx.db).await.unwrap(); - - let notes = request.get("/api/notes").await; - - with_settings!({ - filters => { - let mut combined_filters = testing::CLEANUP_DATE.to_vec(); - combined_filters.extend(vec![(r#"\"id\\":\d+"#, r#""id\":ID"#)]); - combined_filters - } - }, { - assert_debug_snapshot!( - (notes.status_code(), notes.text()) - ); - }); - }) - .await; -} - -#[tokio::test] -#[serial] -async fn can_add_note() { - configure_insta!(); - - testing::request::(|request, _ctx| async move { - let payload = serde_json::json!({ - "title": "loco", - "content": "loco note test", - }); - - let add_note_request = request.post("/api/notes").json(&payload).await; - - with_settings!({ - filters => { - let mut combined_filters = testing::CLEANUP_DATE.to_vec(); - combined_filters.extend(vec![(r#"\"id\\":\d+"#, r#""id\":ID"#)]); - combined_filters - } - }, { - assert_debug_snapshot!( - (add_note_request.status_code(), add_note_request.text()) - ); - }); - }) - .await; -} - -#[tokio::test] -#[serial] -async fn can_get_note() { - configure_insta!(); - - testing::request::(|request, ctx| async move { - testing::seed::(&ctx.db).await.unwrap(); - - let add_note_request = request.get("/api/notes/1").await; - - with_settings!({ - filters => { - let mut combined_filters = testing::CLEANUP_DATE.to_vec(); - combined_filters.extend(vec![(r#"\"id\\":\d+"#, r#""id\":ID"#)]); - combined_filters - } - }, { - assert_debug_snapshot!( - (add_note_request.status_code(), add_note_request.text()) - ); - }); - }) - .await; -} - -#[tokio::test] -#[serial] -async fn can_delete_note() { - configure_insta!(); - - testing::request::(|request, ctx| async move { - testing::seed::(&ctx.db).await.unwrap(); - - let count_before_delete = Entity::find().all(&ctx.db).await.unwrap().len(); - let delete_note_request = request.delete("/api/notes/1").await; - - with_settings!({ - filters => { - let mut combined_filters = testing::CLEANUP_DATE.to_vec(); - combined_filters.extend(vec![(r#"\"id\\":\d+"#, r#""id\":ID"#)]); - combined_filters - } - }, { - assert_debug_snapshot!( - (delete_note_request.status_code(), delete_note_request.text()) - ); - }); - - let count_after_delete = Entity::find().all(&ctx.db).await.unwrap().len(); - assert_eq!(count_after_delete, count_before_delete - 1); - }) - .await; -} diff --git a/examples/aws-rust-loco/tests/requests/prepare_data.rs b/examples/aws-rust-loco/tests/requests/prepare_data.rs deleted file mode 100644 index 13f9940a7a..0000000000 --- a/examples/aws-rust-loco/tests/requests/prepare_data.rs +++ /dev/null @@ -1,57 +0,0 @@ -use axum::http::{HeaderName, HeaderValue}; -use loco_rs::{app::AppContext, TestServer}; -use server::{models::users, views::auth::LoginResponse}; - -const USER_EMAIL: &str = "test@loco.com"; -const USER_PASSWORD: &str = "1234"; - -pub struct LoggedInUser { - pub user: users::Model, - pub token: String, -} - -pub async fn init_user_login(request: &TestServer, ctx: &AppContext) -> LoggedInUser { - let register_payload = serde_json::json!({ - "name": "loco", - "email": USER_EMAIL, - "password": USER_PASSWORD - }); - - //Creating a new user - request - .post("/api/auth/register") - .json(®ister_payload) - .await; - let user = users::Model::find_by_email(&ctx.db, USER_EMAIL) - .await - .unwrap(); - - let verify_payload = serde_json::json!({ - "token": user.email_verification_token, - }); - - request.post("/api/auth/verify").json(&verify_payload).await; - - let response = request - .post("/api/auth/login") - .json(&serde_json::json!({ - "email": USER_EMAIL, - "password": USER_PASSWORD - })) - .await; - - let login_response: LoginResponse = serde_json::from_str(&response.text()).unwrap(); - - LoggedInUser { - user: users::Model::find_by_email(&ctx.db, USER_EMAIL) - .await - .unwrap(), - token: login_response.token, - } -} - -pub fn auth_header(token: &str) -> (HeaderName, HeaderValue) { - let auth_header_value = HeaderValue::from_str(&format!("Bearer {}", &token)).unwrap(); - - (HeaderName::from_static("authorization"), auth_header_value) -} diff --git a/examples/aws-rust-loco/tests/requests/snapshots/can_add_note@notes_request.snap b/examples/aws-rust-loco/tests/requests/snapshots/can_add_note@notes_request.snap deleted file mode 100644 index f8457d7a47..0000000000 --- a/examples/aws-rust-loco/tests/requests/snapshots/can_add_note@notes_request.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: tests/requests/notes.rs -expression: "(add_note_request.status_code(), add_note_request.text())" ---- -( - 200, - "{\"created_at\":\"DATEZ\",\"updated_at\":\"DATEZ\",\"id\":ID,\"title\":\"loco\",\"content\":\"loco note test\"}", -) diff --git a/examples/aws-rust-loco/tests/requests/snapshots/can_delete_note@notes_request.snap b/examples/aws-rust-loco/tests/requests/snapshots/can_delete_note@notes_request.snap deleted file mode 100644 index 3481fc36d8..0000000000 --- a/examples/aws-rust-loco/tests/requests/snapshots/can_delete_note@notes_request.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: tests/requests/notes.rs -expression: "(delete_note_request.status_code(), delete_note_request.text())" ---- -( - 200, - "", -) diff --git a/examples/aws-rust-loco/tests/requests/snapshots/can_get_current_user@user_request.snap b/examples/aws-rust-loco/tests/requests/snapshots/can_get_current_user@user_request.snap deleted file mode 100644 index 85d53db17c..0000000000 --- a/examples/aws-rust-loco/tests/requests/snapshots/can_get_current_user@user_request.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: tests/requests/user.rs -expression: "(response.status_code(), response.text())" ---- -( - 200, - "{\"pid\":\"PID\",\"name\":\"loco\",\"email\":\"test@loco.com\"}", -) diff --git a/examples/aws-rust-loco/tests/requests/snapshots/can_get_current_user_with_api_key@user_request.snap b/examples/aws-rust-loco/tests/requests/snapshots/can_get_current_user_with_api_key@user_request.snap deleted file mode 100644 index 85d53db17c..0000000000 --- a/examples/aws-rust-loco/tests/requests/snapshots/can_get_current_user_with_api_key@user_request.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: tests/requests/user.rs -expression: "(response.status_code(), response.text())" ---- -( - 200, - "{\"pid\":\"PID\",\"name\":\"loco\",\"email\":\"test@loco.com\"}", -) diff --git a/examples/aws-rust-loco/tests/requests/snapshots/can_get_note@notes_request.snap b/examples/aws-rust-loco/tests/requests/snapshots/can_get_note@notes_request.snap deleted file mode 100644 index 8af1604c96..0000000000 --- a/examples/aws-rust-loco/tests/requests/snapshots/can_get_note@notes_request.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: tests/requests/notes.rs -expression: "(add_note_request.status_code(), add_note_request.text())" ---- -( - 200, - "{\"created_at\":\"DATEZ\",\"updated_at\":\"DATEZ\",\"id\":ID,\"title\":\"Loco note 1\",\"content\":\"Loco note 1 content\"}", -) diff --git a/examples/aws-rust-loco/tests/requests/snapshots/can_get_notes@notes_request.snap b/examples/aws-rust-loco/tests/requests/snapshots/can_get_notes@notes_request.snap deleted file mode 100644 index 014b75c03d..0000000000 --- a/examples/aws-rust-loco/tests/requests/snapshots/can_get_notes@notes_request.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: tests/requests/notes.rs -expression: "(notes.status_code(), notes.text())" ---- -( - 200, - "[{\"created_at\":\"DATEZ\",\"updated_at\":\"DATEZ\",\"id\":ID,\"title\":\"Loco note 1\",\"content\":\"Loco note 1 content\"},{\"created_at\":\"DATEZ\",\"updated_at\":\"DATEZ\",\"id\":ID,\"title\":\"Loco note 2\",\"content\":\"Loco note 2 content\"}]", -) diff --git a/examples/aws-rust-loco/tests/requests/snapshots/can_login_without_verify@auth_request.snap b/examples/aws-rust-loco/tests/requests/snapshots/can_login_without_verify@auth_request.snap deleted file mode 100644 index ef54ba6711..0000000000 --- a/examples/aws-rust-loco/tests/requests/snapshots/can_login_without_verify@auth_request.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: tests/requests/auth.rs -expression: "(response.status_code(), response.text())" ---- -( - 200, - "{\"token\":\"TOKEN\",\"pid\":\"PID\",\"name\":\"loco\",\"is_verified\":false}", -) diff --git a/examples/aws-rust-loco/tests/requests/snapshots/can_register@auth_request-2.snap b/examples/aws-rust-loco/tests/requests/snapshots/can_register@auth_request-2.snap deleted file mode 100644 index 45c63cb14c..0000000000 --- a/examples/aws-rust-loco/tests/requests/snapshots/can_register@auth_request-2.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: tests/requests/auth.rs -expression: ctx.mailer.unwrap().deliveries() ---- -Deliveries { - count: 1, - messages: [ - "From: System \r\nTo: test@loco.com\r\nSubject: Welcome =?utf-8?b?bG9jbwo=?=\r\nMIME-Version: 1.0\r\nDate: DATE\r\nContent-Type: multipart/alternative;\r\n boundary=\"IDENTIFIER\"\r\n\r\n--IDENTIFIER\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\nWelcome loco, you can now log in.\r\n Verify your account with the link below:\r\n\r\n http://localhost/verify#RANDOM_ID\r\n\r\n--IDENTIFIER\r\nContent-Type: text/html; charset=utf-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n;\r\n\r\n\r\n Dear loco,\r\n Welcome to Loco! You can now log in to your account.\r\n Before you get started, please verify your account by clicking the link b=\r\nelow:\r\n \r\nTo: test@loco.com\r\nSubject: Welcome =?utf-8?b?bG9jbwo=?=\r\nMIME-Version: 1.0\r\nDate: DATE\r\nContent-Type: multipart/alternative;\r\n boundary=\"IDENTIFIER\"\r\n\r\n--IDENTIFIER\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\nWelcome loco, you can now log in.\r\n Verify your account with the link below:\r\n\r\n http://localhost/verify#RANDOM_ID\r\n\r\n--IDENTIFIER\r\nContent-Type: text/html; charset=utf-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n;\r\n\r\n\r\n Dear loco,\r\n Welcome to Loco! You can now log in to your account.\r\n Before you get started, please verify your account by clicking the link b=\r\nelow:\r\n \r\nTo: test@loco.com\r\nSubject: Your reset password =?utf-8?b?bGluawo=?=\r\nMIME-Version: 1.0\r\nDate: DATE\r\nContent-Type: multipart/alternative;\r\n boundary=\"IDENTIFIER\"\r\n\r\n--IDENTIFIER\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\nReset your password with this link:\r\n\r\nhttp://localhost/reset#RANDOM_ID\r\n\r\n--IDENTIFIER\r\nContent-Type: text/html; charset=utf-8\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n;\r\n\r\n\r\n Hey loco,\r\n Forgot your password? No worries! You can reset it by clicking the link b=\r\nelow:\r\n { - let mut settings = insta::Settings::clone_current(); - settings.set_prepend_module_to_snapshot(false); - settings.set_snapshot_suffix("user_request"); - let _guard = settings.bind_to_scope(); - }; -} - -#[tokio::test] -#[serial] -async fn can_get_current_user() { - configure_insta!(); - - testing::request::(|request, ctx| async move { - let user = prepare_data::init_user_login(&request, &ctx).await; - - let (auth_key, auth_value) = prepare_data::auth_header(&user.token); - let response = request - .get("/api/user/current") - .add_header(auth_key, auth_value) - .await; - - with_settings!({ - filters => testing::cleanup_user_model() - }, { - assert_debug_snapshot!((response.status_code(), response.text())); - }); - }) - .await; -} diff --git a/examples/aws-rust-loco/tests/tasks/mod.rs b/examples/aws-rust-loco/tests/tasks/mod.rs deleted file mode 100644 index 01fbddaa29..0000000000 --- a/examples/aws-rust-loco/tests/tasks/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod seed; diff --git a/examples/aws-rust-loco/tests/tasks/seed.rs b/examples/aws-rust-loco/tests/tasks/seed.rs deleted file mode 100644 index 444c53b697..0000000000 --- a/examples/aws-rust-loco/tests/tasks/seed.rs +++ /dev/null @@ -1,17 +0,0 @@ -use loco_rs::{boot::run_task, task, testing}; -use server::app::App; -use serial_test::serial; - -#[tokio::test] -#[serial] -async fn test_can_seed_data() { - let boot = testing::boot_test::().await.unwrap(); - - assert!(run_task::( - &boot.app_context, - Some(&"seed_data".to_string()), - &task::Vars::default() - ) - .await - .is_ok()); -} diff --git a/examples/aws-service-discovery/.dockerignore b/examples/aws-service-discovery/.dockerignore deleted file mode 100644 index 52467addcf..0000000000 --- a/examples/aws-service-discovery/.dockerignore +++ /dev/null @@ -1,4 +0,0 @@ -node_modules - -# sst -.sst diff --git a/examples/aws-service-discovery/.gitignore b/examples/aws-service-discovery/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-service-discovery/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-service-discovery/Dockerfile b/examples/aws-service-discovery/Dockerfile deleted file mode 100644 index 53718c02f4..0000000000 --- a/examples/aws-service-discovery/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] diff --git a/examples/aws-service-discovery/index.mjs b/examples/aws-service-discovery/index.mjs deleted file mode 100644 index 4bedf3130f..0000000000 --- a/examples/aws-service-discovery/index.mjs +++ /dev/null @@ -1,13 +0,0 @@ -import express from "express"; - -const PORT = 80; - -const app = express(); - -app.get("/", (_req, res) => { - res.send(`Hello from http://localhost:${PORT}`) -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-service-discovery/lambda.ts b/examples/aws-service-discovery/lambda.ts deleted file mode 100644 index f7a871f838..0000000000 --- a/examples/aws-service-discovery/lambda.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Resource } from "sst"; - -export async function handler() { - const response = await fetch( - `http://${Resource.MyService.service}` - ); - - return { - statusCode: 200, - body: await response.text(), - }; -} diff --git a/examples/aws-service-discovery/package.json b/examples/aws-service-discovery/package.json deleted file mode 100644 index 078810d63a..0000000000 --- a/examples/aws-service-discovery/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-service-discovery", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "express": "^4.21.1", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145" - } -} diff --git a/examples/aws-service-discovery/sst.config.ts b/examples/aws-service-discovery/sst.config.ts deleted file mode 100644 index 8e2fc28f1a..0000000000 --- a/examples/aws-service-discovery/sst.config.ts +++ /dev/null @@ -1,40 +0,0 @@ -/// - -/** - * ## AWS Cluster Service Discovery - * - * In this example, we are connecting to a service running on a cluster using its AWS Cloud - * Map service host name. This is useful for service discovery. - * - * We are deploying a service to a cluster in a VPC. And we can access it within the VPC using - * the service's cloud map hostname. - * - * ```ts title="lambda.ts" - * const response = await fetch(`http://${Resource.MyService.service}`); - * ``` - * - * Here we are accessing it through a Lambda function that's linked to the service and is - * deployed to the same VPC. - */ -export default $config({ - app(input) { - return { - name: "aws-service-discovery", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { nat: "ec2" }); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - const service = new sst.aws.Service("MyService", { cluster }); - - new sst.aws.Function("MyFunction", { - vpc, - url: true, - link: [service], - handler: "lambda.handler", - }); - }, -}); diff --git a/examples/aws-service-discovery/tsconfig.json b/examples/aws-service-discovery/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-service-discovery/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-service-transform-container/.dockerignore b/examples/aws-service-transform-container/.dockerignore deleted file mode 100644 index 52467addcf..0000000000 --- a/examples/aws-service-transform-container/.dockerignore +++ /dev/null @@ -1,4 +0,0 @@ -node_modules - -# sst -.sst diff --git a/examples/aws-service-transform-container/.gitignore b/examples/aws-service-transform-container/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-service-transform-container/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-service-transform-container/Dockerfile b/examples/aws-service-transform-container/Dockerfile deleted file mode 100644 index 53718c02f4..0000000000 --- a/examples/aws-service-transform-container/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] diff --git a/examples/aws-service-transform-container/index.mjs b/examples/aws-service-transform-container/index.mjs deleted file mode 100644 index 4bedf3130f..0000000000 --- a/examples/aws-service-transform-container/index.mjs +++ /dev/null @@ -1,13 +0,0 @@ -import express from "express"; - -const PORT = 80; - -const app = express(); - -app.get("/", (_req, res) => { - res.send(`Hello from http://localhost:${PORT}`) -}); - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-service-transform-container/package.json b/examples/aws-service-transform-container/package.json deleted file mode 100644 index 7dad309412..0000000000 --- a/examples/aws-service-transform-container/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "aws-service-transform-container", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "express": "^4.21.1", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-service-transform-container/sst.config.ts b/examples/aws-service-transform-container/sst.config.ts deleted file mode 100644 index 6b64bedb9c..0000000000 --- a/examples/aws-service-transform-container/sst.config.ts +++ /dev/null @@ -1,39 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-service-transform-container", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - new sst.aws.Service("MyService", { - cluster, - transform: { - taskDefinition: (args) => { - // "containerDefinitions" is a JSON string, parse first - let value = $jsonParse(args.containerDefinitions); - - // Update "portMappings" - value = value.apply((containerDefinitions) => { - containerDefinitions[0].portMappings = [ - { - containerPort: 80, - protocol: "tcp", - }, - ]; - return containerDefinitions; - }); - - // Convert back to JSON string - args.containerDefinitions = $jsonStringify(value); - }, - }, - }); - }, -}); diff --git a/examples/aws-service-transform-container/tsconfig.json b/examples/aws-service-transform-container/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-service-transform-container/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-shared-alb-static/api/.dockerignore b/examples/aws-shared-alb-static/api/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-shared-alb-static/api/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-shared-alb-static/api/Dockerfile b/examples/aws-shared-alb-static/api/Dockerfile deleted file mode 100644 index 53718c02f4..0000000000 --- a/examples/aws-shared-alb-static/api/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] diff --git a/examples/aws-shared-alb-static/api/index.mjs b/examples/aws-shared-alb-static/api/index.mjs deleted file mode 100644 index 68f1eb62b0..0000000000 --- a/examples/aws-shared-alb-static/api/index.mjs +++ /dev/null @@ -1,29 +0,0 @@ -import express from "express"; - -const PORT = 3000; - -const app = express(); - -app.get("/", (req, res) => { - res.json({ status: "ok" }); -}); - -app.get("/api", (req, res) => { - res.json({ service: "api", message: "Hello from the API service" }); -}); - -app.get("/api/health", (req, res) => { - res.json({ status: "ok" }); -}); - -app.get("/api/greeting", (req, res) => { - res.json({ service: "api", message: "Hello from the API service" }); -}); - -app.get("/api/*", (req, res) => { - res.json({ service: "api", path: req.path }); -}); - -app.listen(PORT, () => { - console.log(`API service is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-shared-alb-static/api/package.json b/examples/aws-shared-alb-static/api/package.json deleted file mode 100644 index bf11689dd1..0000000000 --- a/examples/aws-shared-alb-static/api/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "api", - "version": "1.0.0", - "dependencies": { - "express": "^4.21.1" - } -} diff --git a/examples/aws-shared-alb-static/package.json b/examples/aws-shared-alb-static/package.json deleted file mode 100644 index 138aaa3168..0000000000 --- a/examples/aws-shared-alb-static/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-shared-alb-static", - "version": "1.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-shared-alb-static/sst.config.ts b/examples/aws-shared-alb-static/sst.config.ts deleted file mode 100644 index 87fd8c4550..0000000000 --- a/examples/aws-shared-alb-static/sst.config.ts +++ /dev/null @@ -1,80 +0,0 @@ -/// - -/** - * ## AWS Shared ALB - * - * Creates a standalone ALB that is shared across stages. In dev, the ALB is - * referenced via `Alb.get()`. In production, it's created fresh. - * - * Uses the `$dev ? get : new` pattern to share infrastructure across stages. - */ -export default $config({ - app(input) { - return { - name: "aws-shared-alb", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - providers: { - aws: { - region: "us-east-1", - }, - }, - }; - }, - async run() { - const vpc = $dev - ? sst.aws.Vpc.get("MyVpc", "vpc-xxx") - : new sst.aws.Vpc("MyVpc"); - - const cluster = $dev - ? sst.aws.Cluster.get("MyCluster", { id: "cluster-xxx", vpc }) - : new sst.aws.Cluster("MyCluster", { vpc }); - - const alb = $dev - ? sst.aws.Alb.get("SharedAlb", "arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/xxx") - : new sst.aws.Alb("SharedAlb", { - vpc, - listeners: [ - { port: 80, protocol: "http" }, - ], - }); - - if ($dev) { - new sst.aws.Service("Web", { - cluster, - image: { context: "web/" }, - loadBalancer: { - instance: alb, - rules: [ - { - listen: "80/http", - forward: "3000/http", - conditions: { path: "/app/*" }, - priority: 200, - }, - ], - }, - }); - } - - new sst.aws.Service("Api", { - cluster, - image: { context: "api/" }, - loadBalancer: { - instance: alb, - rules: [ - { - listen: "80/http", - forward: "3000/http", - conditions: { path: "/api/*" }, - priority: 100, - }, - ], - }, - }); - - return { - url: alb.url, - }; - }, -}); diff --git a/examples/aws-shared-alb-static/web/.dockerignore b/examples/aws-shared-alb-static/web/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-shared-alb-static/web/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-shared-alb-static/web/Dockerfile b/examples/aws-shared-alb-static/web/Dockerfile deleted file mode 100644 index 53718c02f4..0000000000 --- a/examples/aws-shared-alb-static/web/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] diff --git a/examples/aws-shared-alb-static/web/index.mjs b/examples/aws-shared-alb-static/web/index.mjs deleted file mode 100644 index 0d64a1452d..0000000000 --- a/examples/aws-shared-alb-static/web/index.mjs +++ /dev/null @@ -1,29 +0,0 @@ -import express from "express"; - -const PORT = 3000; - -const app = express(); - -app.get("/", (req, res) => { - res.json({ status: "ok" }); -}); - -app.get("/app", (req, res) => { - res.send("

Web App

Hello from the Web service

"); -}); - -app.get("/app/health", (req, res) => { - res.json({ status: "ok" }); -}); - -app.get("/app/greeting", (req, res) => { - res.send("

Web App

Hello from the Web service

"); -}); - -app.get("/app/*", (req, res) => { - res.send(`

Web App

Path: ${req.path}

`); -}); - -app.listen(PORT, () => { - console.log(`Web service is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-shared-alb-static/web/package.json b/examples/aws-shared-alb-static/web/package.json deleted file mode 100644 index 9c43fe9bb1..0000000000 --- a/examples/aws-shared-alb-static/web/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "web", - "version": "1.0.0", - "dependencies": { - "express": "^4.21.1" - } -} diff --git a/examples/aws-shared-alb/api/.dockerignore b/examples/aws-shared-alb/api/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-shared-alb/api/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-shared-alb/api/Dockerfile b/examples/aws-shared-alb/api/Dockerfile deleted file mode 100644 index 53718c02f4..0000000000 --- a/examples/aws-shared-alb/api/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] diff --git a/examples/aws-shared-alb/api/index.mjs b/examples/aws-shared-alb/api/index.mjs deleted file mode 100644 index d229500c93..0000000000 --- a/examples/aws-shared-alb/api/index.mjs +++ /dev/null @@ -1,21 +0,0 @@ -import express from "express"; - -const PORT = 3000; - -const app = express(); - -app.get("/api", (req, res) => { - res.json({ service: "api", message: "Hello from the API service" }); -}); - -app.get("/api/health", (req, res) => { - res.json({ status: "ok" }); -}); - -app.get("/api/*", (req, res) => { - res.json({ service: "api", path: req.path }); -}); - -app.listen(PORT, () => { - console.log(`API service is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-shared-alb/api/package.json b/examples/aws-shared-alb/api/package.json deleted file mode 100644 index bf11689dd1..0000000000 --- a/examples/aws-shared-alb/api/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "api", - "version": "1.0.0", - "dependencies": { - "express": "^4.21.1" - } -} diff --git a/examples/aws-shared-alb/package.json b/examples/aws-shared-alb/package.json deleted file mode 100644 index 0f75962a1a..0000000000 --- a/examples/aws-shared-alb/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "aws-shared-alb", - "version": "1.0.0", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-shared-alb/sst.config.ts b/examples/aws-shared-alb/sst.config.ts deleted file mode 100644 index 34f2c072f1..0000000000 --- a/examples/aws-shared-alb/sst.config.ts +++ /dev/null @@ -1,124 +0,0 @@ -/// - -/** - * ## AWS Shared ALB - * - * Creates a standalone ALB shared across multiple services. - * Shows advanced routing with path conditions, header conditions, and health checks. - * - * ```ts title="sst.config.ts" - * const alb = new sst.aws.Alb("SharedAlb", { - * vpc, - * listeners: [ - * { port: 80, protocol: "http" }, - * ], - * }); - * ``` - * - * Services can use header-based routing in addition to path-based: - * - * ```ts title="sst.config.ts" - * new sst.aws.Service("InternalApi", { - * cluster, - * image: { context: "api/" }, - * loadBalancer: { - * instance: alb, - * rules: [ - * { - * listen: "80/http", - * forward: "3000/http", - * conditions: { - * path: "/api/*", - * header: { name: "x-internal", values: ["true"] }, - * }, - * priority: 50, - * }, - * ], - * }, - * }); - * ``` - * - * This example creates: - * - A shared ALB with an HTTP listener - * - An API service with path-based routing and custom health check - * - A Web service with path-based routing - * - Both services share the same ALB - */ -export default $config({ - app(input) { - return { - name: "aws-shared-alb", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - providers: { - aws: { - region: "us-east-1", - }, - }, - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - // Create a shared ALB with an HTTP listener - const alb = new sst.aws.Alb("SharedAlb", { - vpc, - listeners: [{ port: 80, protocol: "http" }], - }); - - // API service — handles /api/* with a custom health check path - new sst.aws.Service("Api", { - cluster, - image: { context: "api/" }, - loadBalancer: { - instance: alb, - rules: [ - { - listen: "80/http", - forward: "3000/http", - conditions: { path: "/api/*" }, - priority: 100, - }, - ], - health: { - "3000/http": { - path: "/api/health", - interval: "10 seconds", - timeout: "5 seconds", - healthyThreshold: 2, - unhealthyThreshold: 3, - }, - }, - }, - }); - - // Web service — handles everything else under /app/* - new sst.aws.Service("Web", { - cluster, - image: { context: "web/" }, - loadBalancer: { - instance: alb, - rules: [ - { - listen: "80/http", - forward: "3000/http", - conditions: { path: "/app/*" }, - priority: 200, - }, - ], - health: { - "3000/http": { - path: "/app/health", - interval: "10 seconds", - timeout: "5 seconds", - }, - }, - }, - }); - - return { - url: alb.url, - }; - }, -}); diff --git a/examples/aws-shared-alb/test.sh b/examples/aws-shared-alb/test.sh deleted file mode 100755 index 2f7495c709..0000000000 --- a/examples/aws-shared-alb/test.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# Test the shared ALB example endpoints after deployment. -# -# Usage: -# ./test.sh [alb-url] -# -# If no URL is provided, attempts to read it from sst output. - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -cd "$SCRIPT_DIR" - -# Get ALB URL from argument or sst output -if [ -n "${1:-}" ]; then - ALB_URL="$1" -else - echo "Fetching ALB URL from sst output..." - ALB_URL=$(npx sst output url 2>/dev/null || true) - if [ -z "$ALB_URL" ]; then - echo "ERROR: Could not determine ALB URL." - echo "Usage: ./test.sh " - echo " e.g. ./test.sh http://SharedAlb-123456.us-east-1.elb.amazonaws.com" - exit 1 - fi -fi - -# Strip trailing slash -ALB_URL="${ALB_URL%/}" - -echo "=== Testing Shared ALB Example ===" -echo "ALB URL: $ALB_URL" -echo "" - -PASS=0 -FAIL=0 - -run_test() { - local name="$1" - local url="$2" - local expected="$3" - - echo -n "TEST: $name ... " - HTTP_CODE=$(curl -s -o /tmp/alb_test_response -w "%{http_code}" --max-time 10 "$url" 2>/dev/null || echo "000") - BODY=$(cat /tmp/alb_test_response 2>/dev/null || echo "") - - if [ "$HTTP_CODE" = "000" ]; then - echo "FAIL (connection error)" - FAIL=$((FAIL + 1)) - return - fi - - if echo "$BODY" | grep -q "$expected"; then - echo "OK (HTTP $HTTP_CODE) → $BODY" - PASS=$((PASS + 1)) - else - echo "FAIL (HTTP $HTTP_CODE, expected '$expected')" - echo " Got: $BODY" - FAIL=$((FAIL + 1)) - fi -} - -# Note: ALB path pattern "/api/*" matches "/api/" but NOT "/api" itself. -# Tests use paths with a trailing segment to match the wildcard. - -# Test 1: API service — /api/health returns { "status": "ok" } -run_test "API health (/api/health)" "$ALB_URL/api/health" '"status":"ok"' - -# Test 2: API service — /api/users returns { "service": "api", "path": "/api/users" } -run_test "API routing (/api/users)" "$ALB_URL/api/users" '"service":"api"' - -# Test 3: API service — /api/greeting returns path info -run_test "API greeting (/api/greeting)" "$ALB_URL/api/greeting" "/api/greeting" - -# Test 4: Web service — /app/health returns { "status": "ok" } -run_test "Web health (/app/health)" "$ALB_URL/app/health" '"status":"ok"' - -# Test 5: Web service — /app/dashboard returns HTML with path -run_test "Web routing (/app/dashboard)" "$ALB_URL/app/dashboard" "/app/dashboard" - -# Test 6: Web service — /app/greeting returns path info -run_test "Web greeting (/app/greeting)" "$ALB_URL/app/greeting" "/app/greeting" - -# Test 7: Default action — / should return 404 (ALB default) -echo -n "TEST: Default action (/) ... " -HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 10 "$ALB_URL/" 2>/dev/null || echo "000") -if [ "$HTTP_CODE" = "403" ]; then - echo "PASS (HTTP 403 as expected)" - PASS=$((PASS + 1)) -else - echo "FAIL (expected 403, got HTTP $HTTP_CODE)" - FAIL=$((FAIL + 1)) -fi - -echo "" -echo "=== Results: $PASS passed, $FAIL failed ===" - -if [ "$FAIL" -gt 0 ]; then - exit 1 -fi diff --git a/examples/aws-shared-alb/web/.dockerignore b/examples/aws-shared-alb/web/.dockerignore deleted file mode 100644 index d98fe17111..0000000000 --- a/examples/aws-shared-alb/web/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-shared-alb/web/Dockerfile b/examples/aws-shared-alb/web/Dockerfile deleted file mode 100644 index 53718c02f4..0000000000 --- a/examples/aws-shared-alb/web/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM node:18-bullseye-slim - -WORKDIR /app/ - -COPY package.json /app -RUN npm install - -COPY index.mjs /app - -ENTRYPOINT ["node", "index.mjs"] diff --git a/examples/aws-shared-alb/web/index.mjs b/examples/aws-shared-alb/web/index.mjs deleted file mode 100644 index 6640bec96f..0000000000 --- a/examples/aws-shared-alb/web/index.mjs +++ /dev/null @@ -1,21 +0,0 @@ -import express from "express"; - -const PORT = 3000; - -const app = express(); - -app.get("/app", (req, res) => { - res.send("

Web App

Hello from the Web service

"); -}); - -app.get("/app/health", (req, res) => { - res.json({ status: "ok" }); -}); - -app.get("/app/*", (req, res) => { - res.send(`

Web App

Path: ${req.path}

`); -}); - -app.listen(PORT, () => { - console.log(`Web service is running on http://localhost:${PORT}`); -}); diff --git a/examples/aws-shared-alb/web/package.json b/examples/aws-shared-alb/web/package.json deleted file mode 100644 index 9c43fe9bb1..0000000000 --- a/examples/aws-shared-alb/web/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "web", - "version": "1.0.0", - "dependencies": { - "express": "^4.21.1" - } -} diff --git a/examples/aws-sharp/.gitignore b/examples/aws-sharp/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-sharp/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-sharp/index.ts b/examples/aws-sharp/index.ts deleted file mode 100644 index 7bb58fff18..0000000000 --- a/examples/aws-sharp/index.ts +++ /dev/null @@ -1,37 +0,0 @@ -import sharp from "sharp"; -import { promises as fs } from "fs"; - -export async function handler() { - const imagePath = "logo.png"; - - try { - // Read the image file - const imageBuffer = await fs.readFile(imagePath); - - // Resize the image - const resizedImage = await sharp(imageBuffer) - .resize(100, 100) // Resize to 100x100 - .toBuffer(); - - // Convert the buffer to base64 - const body = resizedImage.toString("base64"); - - console.log("Successfully resized logo.png"); - - return { - body, - statusCode: 200, - headers: { - "Content-Type": "image/png", - "Content-Disposition": "inline" - }, - isBase64Encoded: true - }; - } catch (error) { - console.log(error); - return { - statusCode: 500, - body: JSON.stringify("Error resizing image: " + error.message), - }; - } -} diff --git a/examples/aws-sharp/logo.png b/examples/aws-sharp/logo.png deleted file mode 100644 index 4a98ec9023..0000000000 Binary files a/examples/aws-sharp/logo.png and /dev/null differ diff --git a/examples/aws-sharp/package.json b/examples/aws-sharp/package.json deleted file mode 100644 index 941e53db73..0000000000 --- a/examples/aws-sharp/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "aws-sharp", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "sharp": "^0.33.5", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "8.10.145" - } -} diff --git a/examples/aws-sharp/sst.config.ts b/examples/aws-sharp/sst.config.ts deleted file mode 100644 index 533c44b782..0000000000 --- a/examples/aws-sharp/sst.config.ts +++ /dev/null @@ -1,55 +0,0 @@ -/// - -/** - * ## Sharp in Lambda - * - * Uses the [Sharp](https://sharp.pixelplumbing.com/) library to resize images. In this example, - * it resizes a `logo.png` local file to 100x100 pixels. - * - * ```json title="sst.config.ts" - * { - * nodejs: { install: ["sharp"] } - * } - * ``` - * - * We don't need a layer to deploy this because `sharp` comes with a pre-built binary for Lambda. - * This is handled by [`nodejs.install`](/docs/component/aws/function#nodejs-install). - * - * :::tip - * You don't need to use a Lambda layer to use Sharp. - * ::: - * - * In dev, this uses the sharp npm package locally. - * - * ```json title="package.json" - * { - * "dependencies": { - * "sharp": "^0.33.5" - * } - * } - * ``` - * - * On deploy, SST will use the right binary from the sharp package for the target Lambda - * architecture. - */ -export default $config({ - app(input) { - return { - name: "aws-sharp", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const func = new sst.aws.Function("MyFunction", { - url: true, - handler: "index.handler", - nodejs: { install: ["sharp"] }, - copyFiles: [{ from: "logo.png" }], - }); - - return { - url: func.url, - }; - }, -}); diff --git a/examples/aws-sharp/tsconfig.json b/examples/aws-sharp/tsconfig.json deleted file mode 100644 index 2f98042715..0000000000 --- a/examples/aws-sharp/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "esModuleInterop": true - } -} diff --git a/examples/aws-solid-container-ws/.dockerignore b/examples/aws-solid-container-ws/.dockerignore deleted file mode 100644 index 89e3d841fd..0000000000 --- a/examples/aws-solid-container-ws/.dockerignore +++ /dev/null @@ -1,3 +0,0 @@ -node_modules -# sst -.sst diff --git a/examples/aws-solid-container-ws/.gitignore b/examples/aws-solid-container-ws/.gitignore deleted file mode 100644 index 8ebae30246..0000000000 --- a/examples/aws-solid-container-ws/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ - -dist -.solid -.output -.vercel -.netlify -.vinxi -app.config.timestamp_*.js - -# Environment -.env -.env*.local - -# dependencies -/node_modules - -# IDEs and editors -/.idea -.project -.classpath -*.launch -.settings/ - -# Temp -gitignore - -# System Files -.DS_Store -Thumbs.db - -# sst -.sst diff --git a/examples/aws-solid-container-ws/Dockerfile b/examples/aws-solid-container-ws/Dockerfile deleted file mode 100644 index eb842b02d5..0000000000 --- a/examples/aws-solid-container-ws/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM node:lts AS base - -WORKDIR /src - -# Build -FROM base as build - -COPY --link package.json package-lock.json ./ -RUN npm install - -COPY --link . . - -RUN npm run build - -# Run -FROM base - -ENV PORT=3000 -ENV NODE_ENV=production - -COPY --from=build /src/.output /src/.output - -CMD [ "node", ".output/server/index.mjs" ] diff --git a/examples/aws-solid-container-ws/app.config.ts b/examples/aws-solid-container-ws/app.config.ts deleted file mode 100644 index 792fe7a649..0000000000 --- a/examples/aws-solid-container-ws/app.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from "@solidjs/start/config"; - -export default defineConfig({ - server: { - experimental: { - websocket: true, - }, - }, -}).addRouter({ - name: "ws", - type: "http", - handler: "./src/ws.ts", - target: "server", - base: "/ws", -}); diff --git a/examples/aws-solid-container-ws/package.json b/examples/aws-solid-container-ws/package.json deleted file mode 100644 index 27a783d39f..0000000000 --- a/examples/aws-solid-container-ws/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aws-solid-container-ws", - "type": "module", - "scripts": { - "build": "vinxi build", - "dev": "vinxi dev", - "start": "vinxi start", - "version": "vinxi version" - }, - "dependencies": { - "@solidjs/meta": "^0.29.4", - "@solidjs/router": "^0.14.7", - "@solidjs/start": "^1.0.8", - "solid-js": "^1.9.1", - "sst": "file:../../sdk/js", - "vinxi": "^0.4.3" - }, - "engines": { - "node": ">=18" - } -} diff --git a/examples/aws-solid-container-ws/public/favicon.ico b/examples/aws-solid-container-ws/public/favicon.ico deleted file mode 100644 index fb282da071..0000000000 Binary files a/examples/aws-solid-container-ws/public/favicon.ico and /dev/null differ diff --git a/examples/aws-solid-container-ws/src/app.css b/examples/aws-solid-container-ws/src/app.css deleted file mode 100644 index 8596998a49..0000000000 --- a/examples/aws-solid-container-ws/src/app.css +++ /dev/null @@ -1,39 +0,0 @@ -body { - font-family: Gordita, Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; -} - -a { - margin-right: 1rem; -} - -main { - text-align: center; - padding: 1em; - margin: 0 auto; -} - -h1 { - color: #335d92; - text-transform: uppercase; - font-size: 4rem; - font-weight: 100; - line-height: 1.1; - margin: 4rem auto; - max-width: 14rem; -} - -p { - max-width: 14rem; - margin: 2rem auto; - line-height: 1.35; -} - -@media (min-width: 480px) { - h1 { - max-width: none; - } - - p { - max-width: none; - } -} diff --git a/examples/aws-solid-container-ws/src/app.tsx b/examples/aws-solid-container-ws/src/app.tsx deleted file mode 100644 index d1359c8d82..0000000000 --- a/examples/aws-solid-container-ws/src/app.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { MetaProvider, Title } from "@solidjs/meta"; -import { Router } from "@solidjs/router"; -import { FileRoutes } from "@solidjs/start/router"; -import { Suspense } from "solid-js"; -import "./app.css"; - -export default function App() { - return ( - ( - - SolidStart - Basic -
Index - About - {props.children} - - )} - > - - - ); -} diff --git a/examples/aws-solid-container-ws/src/components/Counter.css b/examples/aws-solid-container-ws/src/components/Counter.css deleted file mode 100644 index 220e179460..0000000000 --- a/examples/aws-solid-container-ws/src/components/Counter.css +++ /dev/null @@ -1,21 +0,0 @@ -.increment { - font-family: inherit; - font-size: inherit; - padding: 1em 2em; - color: #335d92; - background-color: rgba(68, 107, 158, 0.1); - border-radius: 2em; - border: 2px solid rgba(68, 107, 158, 0); - outline: none; - width: 200px; - font-variant-numeric: tabular-nums; - cursor: pointer; -} - -.increment:focus { - border: 2px solid #335d92; -} - -.increment:active { - background-color: rgba(68, 107, 158, 0.2); -} \ No newline at end of file diff --git a/examples/aws-solid-container-ws/src/components/Counter.tsx b/examples/aws-solid-container-ws/src/components/Counter.tsx deleted file mode 100644 index 091fc5d0bc..0000000000 --- a/examples/aws-solid-container-ws/src/components/Counter.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { createSignal } from "solid-js"; -import "./Counter.css"; - -export default function Counter() { - const [count, setCount] = createSignal(0); - return ( - - ); -} diff --git a/examples/aws-solid-container-ws/src/entry-client.tsx b/examples/aws-solid-container-ws/src/entry-client.tsx deleted file mode 100644 index 0ca4e3c300..0000000000 --- a/examples/aws-solid-container-ws/src/entry-client.tsx +++ /dev/null @@ -1,4 +0,0 @@ -// @refresh reload -import { mount, StartClient } from "@solidjs/start/client"; - -mount(() => , document.getElementById("app")!); diff --git a/examples/aws-solid-container-ws/src/entry-server.tsx b/examples/aws-solid-container-ws/src/entry-server.tsx deleted file mode 100644 index 401eff83fd..0000000000 --- a/examples/aws-solid-container-ws/src/entry-server.tsx +++ /dev/null @@ -1,21 +0,0 @@ -// @refresh reload -import { createHandler, StartServer } from "@solidjs/start/server"; - -export default createHandler(() => ( - ( - - - - - - {assets} - - -
{children}
- {scripts} - - - )} - /> -)); diff --git a/examples/aws-solid-container-ws/src/global.d.ts b/examples/aws-solid-container-ws/src/global.d.ts deleted file mode 100644 index dc6f10c226..0000000000 --- a/examples/aws-solid-container-ws/src/global.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/examples/aws-solid-container-ws/src/routes/[...404].tsx b/examples/aws-solid-container-ws/src/routes/[...404].tsx deleted file mode 100644 index 4ea71ec7fe..0000000000 --- a/examples/aws-solid-container-ws/src/routes/[...404].tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { Title } from "@solidjs/meta"; -import { HttpStatusCode } from "@solidjs/start"; - -export default function NotFound() { - return ( -
- Not Found - -

Page Not Found

-

- Visit{" "} - - start.solidjs.com - {" "} - to learn how to build SolidStart apps. -

-
- ); -} diff --git a/examples/aws-solid-container-ws/src/routes/about.tsx b/examples/aws-solid-container-ws/src/routes/about.tsx deleted file mode 100644 index 8371d911cd..0000000000 --- a/examples/aws-solid-container-ws/src/routes/about.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { Title } from "@solidjs/meta"; - -export default function Home() { - return ( -
- About -

About

-
- ); -} diff --git a/examples/aws-solid-container-ws/src/routes/index.tsx b/examples/aws-solid-container-ws/src/routes/index.tsx deleted file mode 100644 index 5d557d819f..0000000000 --- a/examples/aws-solid-container-ws/src/routes/index.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { Title } from "@solidjs/meta"; -import Counter from "~/components/Counter"; - -export default function Home() { - return ( -
- Hello World -

Hello world!

- -

- Visit{" "} - - start.solidjs.com - {" "} - to learn how to build SolidStart apps. -

-
- ); -} diff --git a/examples/aws-solid-container-ws/src/ws.ts b/examples/aws-solid-container-ws/src/ws.ts deleted file mode 100644 index 7ee8d34f4c..0000000000 --- a/examples/aws-solid-container-ws/src/ws.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { eventHandler } from "vinxi/http"; -export default eventHandler({ - handler() { }, - websocket: { - async open(peer) { - console.log("open", peer.id, peer.url); - }, - async message(peer, msg) { - const message = msg.text(); - console.log("msg", peer.id, peer.url, message); - - setTimeout(() => { - peer.send("Message received from: #" + peer.id); - }, 3000); - }, - async close(peer, _details) { - console.log("close", peer.id, peer.url); - }, - async error(peer, error) { - console.log("error", peer.id, peer.url, error); - }, - }, -}); diff --git a/examples/aws-solid-container-ws/sst.config.ts b/examples/aws-solid-container-ws/sst.config.ts deleted file mode 100644 index 2b1905639e..0000000000 --- a/examples/aws-solid-container-ws/sst.config.ts +++ /dev/null @@ -1,51 +0,0 @@ -/// - -/** - * ## AWS SolidStart WebSocket endpoint - * - * Deploys a SolidStart app with a [WebSocket endpoint](https://docs.solidjs.com/solid-start/advanced/websocket) - * in a container to AWS. - * - * Uses the experimental WebSocket support in Nitro. - * - * ```ts title="app.config.ts" {4} - * export default defineConfig({ - * server: { - * experimental: { - * websocket: true, - * }, - * }, - * }).addRouter({ - * name: "ws", - * type: "http", - * handler: "./src/ws.ts", - * target: "server", - * base: "/ws", - * }); - * ``` - * - * Once deployed you can test the `/ws` endpoint and it'll send a message back after a 3s delay. - */ -export default $config({ - app(input) { - return { - name: "aws-solid-container-ws", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-solid-container-ws/tsconfig.json b/examples/aws-solid-container-ws/tsconfig.json deleted file mode 100644 index 7d5871a07a..0000000000 --- a/examples/aws-solid-container-ws/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "jsx": "preserve", - "jsxImportSource": "solid-js", - "allowJs": true, - "strict": true, - "noEmit": true, - "types": ["vinxi/types/client"], - "isolatedModules": true, - "paths": { - "~/*": ["./src/*"] - } - } -} diff --git a/examples/aws-solid-container/.dockerignore b/examples/aws-solid-container/.dockerignore deleted file mode 100644 index ea0aaeeec9..0000000000 --- a/examples/aws-solid-container/.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-solid-container/.gitignore b/examples/aws-solid-container/.gitignore deleted file mode 100644 index 8ebae30246..0000000000 --- a/examples/aws-solid-container/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ - -dist -.solid -.output -.vercel -.netlify -.vinxi -app.config.timestamp_*.js - -# Environment -.env -.env*.local - -# dependencies -/node_modules - -# IDEs and editors -/.idea -.project -.classpath -*.launch -.settings/ - -# Temp -gitignore - -# System Files -.DS_Store -Thumbs.db - -# sst -.sst diff --git a/examples/aws-solid-container/Dockerfile b/examples/aws-solid-container/Dockerfile deleted file mode 100644 index eb842b02d5..0000000000 --- a/examples/aws-solid-container/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM node:lts AS base - -WORKDIR /src - -# Build -FROM base as build - -COPY --link package.json package-lock.json ./ -RUN npm install - -COPY --link . . - -RUN npm run build - -# Run -FROM base - -ENV PORT=3000 -ENV NODE_ENV=production - -COPY --from=build /src/.output /src/.output - -CMD [ "node", ".output/server/index.mjs" ] diff --git a/examples/aws-solid-container/app.config.ts b/examples/aws-solid-container/app.config.ts deleted file mode 100644 index de7f83103a..0000000000 --- a/examples/aws-solid-container/app.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { defineConfig } from "@solidjs/start/config"; - -export default defineConfig({}); diff --git a/examples/aws-solid-container/package.json b/examples/aws-solid-container/package.json deleted file mode 100644 index 3f3f4c9222..0000000000 --- a/examples/aws-solid-container/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "aws-solid-container", - "type": "module", - "scripts": { - "build": "vinxi build", - "dev": "vinxi dev", - "start": "vinxi start", - "version": "vinxi version" - }, - "dependencies": { - "@solidjs/meta": "^0.29.4", - "@solidjs/router": "^0.14.8", - "@solidjs/start": "^1.0.8", - "ioredis": "^5.4.1", - "solid-js": "^1.9.1", - "sst": "file:../../sdk/js", - "vinxi": "^0.4.3" - }, - "engines": { - "node": ">=18" - }, - "overrides": { - "nitropack": "npm:nitropack-nightly@latest" - } -} diff --git a/examples/aws-solid-container/public/favicon.ico b/examples/aws-solid-container/public/favicon.ico deleted file mode 100644 index fb282da071..0000000000 Binary files a/examples/aws-solid-container/public/favicon.ico and /dev/null differ diff --git a/examples/aws-solid-container/src/app.css b/examples/aws-solid-container/src/app.css deleted file mode 100644 index 8596998a49..0000000000 --- a/examples/aws-solid-container/src/app.css +++ /dev/null @@ -1,39 +0,0 @@ -body { - font-family: Gordita, Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; -} - -a { - margin-right: 1rem; -} - -main { - text-align: center; - padding: 1em; - margin: 0 auto; -} - -h1 { - color: #335d92; - text-transform: uppercase; - font-size: 4rem; - font-weight: 100; - line-height: 1.1; - margin: 4rem auto; - max-width: 14rem; -} - -p { - max-width: 14rem; - margin: 2rem auto; - line-height: 1.35; -} - -@media (min-width: 480px) { - h1 { - max-width: none; - } - - p { - max-width: none; - } -} diff --git a/examples/aws-solid-container/src/app.tsx b/examples/aws-solid-container/src/app.tsx deleted file mode 100644 index d1359c8d82..0000000000 --- a/examples/aws-solid-container/src/app.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { MetaProvider, Title } from "@solidjs/meta"; -import { Router } from "@solidjs/router"; -import { FileRoutes } from "@solidjs/start/router"; -import { Suspense } from "solid-js"; -import "./app.css"; - -export default function App() { - return ( - ( - - SolidStart - Basic - Index - About - {props.children} - - )} - > - - - ); -} diff --git a/examples/aws-solid-container/src/components/Counter.css b/examples/aws-solid-container/src/components/Counter.css deleted file mode 100644 index 220e179460..0000000000 --- a/examples/aws-solid-container/src/components/Counter.css +++ /dev/null @@ -1,21 +0,0 @@ -.increment { - font-family: inherit; - font-size: inherit; - padding: 1em 2em; - color: #335d92; - background-color: rgba(68, 107, 158, 0.1); - border-radius: 2em; - border: 2px solid rgba(68, 107, 158, 0); - outline: none; - width: 200px; - font-variant-numeric: tabular-nums; - cursor: pointer; -} - -.increment:focus { - border: 2px solid #335d92; -} - -.increment:active { - background-color: rgba(68, 107, 158, 0.2); -} \ No newline at end of file diff --git a/examples/aws-solid-container/src/components/Counter.tsx b/examples/aws-solid-container/src/components/Counter.tsx deleted file mode 100644 index 091fc5d0bc..0000000000 --- a/examples/aws-solid-container/src/components/Counter.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { createSignal } from "solid-js"; -import "./Counter.css"; - -export default function Counter() { - const [count, setCount] = createSignal(0); - return ( - - ); -} diff --git a/examples/aws-solid-container/src/entry-client.tsx b/examples/aws-solid-container/src/entry-client.tsx deleted file mode 100644 index 0ca4e3c300..0000000000 --- a/examples/aws-solid-container/src/entry-client.tsx +++ /dev/null @@ -1,4 +0,0 @@ -// @refresh reload -import { mount, StartClient } from "@solidjs/start/client"; - -mount(() => , document.getElementById("app")!); diff --git a/examples/aws-solid-container/src/entry-server.tsx b/examples/aws-solid-container/src/entry-server.tsx deleted file mode 100644 index 401eff83fd..0000000000 --- a/examples/aws-solid-container/src/entry-server.tsx +++ /dev/null @@ -1,21 +0,0 @@ -// @refresh reload -import { createHandler, StartServer } from "@solidjs/start/server"; - -export default createHandler(() => ( - ( - - - - - - {assets} - - -
{children}
- {scripts} - - - )} - /> -)); diff --git a/examples/aws-solid-container/src/global.d.ts b/examples/aws-solid-container/src/global.d.ts deleted file mode 100644 index dc6f10c226..0000000000 --- a/examples/aws-solid-container/src/global.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/examples/aws-solid-container/src/routes/[...404].tsx b/examples/aws-solid-container/src/routes/[...404].tsx deleted file mode 100644 index 4ea71ec7fe..0000000000 --- a/examples/aws-solid-container/src/routes/[...404].tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { Title } from "@solidjs/meta"; -import { HttpStatusCode } from "@solidjs/start"; - -export default function NotFound() { - return ( -
- Not Found - -

Page Not Found

-

- Visit{" "} - - start.solidjs.com - {" "} - to learn how to build SolidStart apps. -

-
- ); -} diff --git a/examples/aws-solid-container/src/routes/about.tsx b/examples/aws-solid-container/src/routes/about.tsx deleted file mode 100644 index 8371d911cd..0000000000 --- a/examples/aws-solid-container/src/routes/about.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { Title } from "@solidjs/meta"; - -export default function Home() { - return ( -
- About -

About

-
- ); -} diff --git a/examples/aws-solid-container/src/routes/index.tsx b/examples/aws-solid-container/src/routes/index.tsx deleted file mode 100644 index ff472de40e..0000000000 --- a/examples/aws-solid-container/src/routes/index.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { Resource } from "sst"; -import { Cluster } from "ioredis"; -import { createAsync, cache } from "@solidjs/router"; - -const getCounter = cache(async () => { - "use server"; - const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } - ); - - return await redis.incr("counter"); -}, "counter"); - -export const route = { - load: () => getCounter(), -}; - -export default function Page() { - const counter = createAsync(() => getCounter()); - - return

Hit counter: {counter()}

; -} diff --git a/examples/aws-solid-container/sst.config.ts b/examples/aws-solid-container/sst.config.ts deleted file mode 100644 index 34e9e92282..0000000000 --- a/examples/aws-solid-container/sst.config.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-solid-container", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-solid-container/tsconfig.json b/examples/aws-solid-container/tsconfig.json deleted file mode 100644 index 7d5871a07a..0000000000 --- a/examples/aws-solid-container/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "jsx": "preserve", - "jsxImportSource": "solid-js", - "allowJs": true, - "strict": true, - "noEmit": true, - "types": ["vinxi/types/client"], - "isolatedModules": true, - "paths": { - "~/*": ["./src/*"] - } - } -} diff --git a/examples/aws-solid/.gitignore b/examples/aws-solid/.gitignore deleted file mode 100644 index 8ebae30246..0000000000 --- a/examples/aws-solid/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ - -dist -.solid -.output -.vercel -.netlify -.vinxi -app.config.timestamp_*.js - -# Environment -.env -.env*.local - -# dependencies -/node_modules - -# IDEs and editors -/.idea -.project -.classpath -*.launch -.settings/ - -# Temp -gitignore - -# System Files -.DS_Store -Thumbs.db - -# sst -.sst diff --git a/examples/aws-solid/app.config.ts b/examples/aws-solid/app.config.ts deleted file mode 100644 index 499d53e43b..0000000000 --- a/examples/aws-solid/app.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { defineConfig } from "@solidjs/start/config"; - -export default defineConfig({ - server: { - preset: "aws-lambda", - awsLambda: { - streaming: true, - }, - }, -}); diff --git a/examples/aws-solid/package.json b/examples/aws-solid/package.json deleted file mode 100644 index a9fa8b8ca3..0000000000 --- a/examples/aws-solid/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "aws-solid", - "type": "module", - "scripts": { - "build": "vinxi build", - "dev": "vinxi dev", - "start": "vinxi start", - "version": "vinxi version" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.670.0", - "@aws-sdk/s3-request-presigner": "^3.670.0", - "@solidjs/meta": "^0.29.4", - "@solidjs/router": "^0.14.8", - "@solidjs/start": "^1.0.8", - "solid-js": "^1.9.1", - "sst": "file:../../sdk/js", - "vinxi": "^0.4.3" - }, - "engines": { - "node": ">=18" - }, - "overrides": { - "nitropack": "npm:nitropack-nightly@latest" - } -} diff --git a/examples/aws-solid/public/favicon.ico b/examples/aws-solid/public/favicon.ico deleted file mode 100644 index fb282da071..0000000000 Binary files a/examples/aws-solid/public/favicon.ico and /dev/null differ diff --git a/examples/aws-solid/src/app.css b/examples/aws-solid/src/app.css deleted file mode 100644 index 8596998a49..0000000000 --- a/examples/aws-solid/src/app.css +++ /dev/null @@ -1,39 +0,0 @@ -body { - font-family: Gordita, Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; -} - -a { - margin-right: 1rem; -} - -main { - text-align: center; - padding: 1em; - margin: 0 auto; -} - -h1 { - color: #335d92; - text-transform: uppercase; - font-size: 4rem; - font-weight: 100; - line-height: 1.1; - margin: 4rem auto; - max-width: 14rem; -} - -p { - max-width: 14rem; - margin: 2rem auto; - line-height: 1.35; -} - -@media (min-width: 480px) { - h1 { - max-width: none; - } - - p { - max-width: none; - } -} diff --git a/examples/aws-solid/src/app.tsx b/examples/aws-solid/src/app.tsx deleted file mode 100644 index d1359c8d82..0000000000 --- a/examples/aws-solid/src/app.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { MetaProvider, Title } from "@solidjs/meta"; -import { Router } from "@solidjs/router"; -import { FileRoutes } from "@solidjs/start/router"; -import { Suspense } from "solid-js"; -import "./app.css"; - -export default function App() { - return ( - ( - - SolidStart - Basic - Index - About - {props.children} - - )} - > - - - ); -} diff --git a/examples/aws-solid/src/components/Counter.css b/examples/aws-solid/src/components/Counter.css deleted file mode 100644 index 220e179460..0000000000 --- a/examples/aws-solid/src/components/Counter.css +++ /dev/null @@ -1,21 +0,0 @@ -.increment { - font-family: inherit; - font-size: inherit; - padding: 1em 2em; - color: #335d92; - background-color: rgba(68, 107, 158, 0.1); - border-radius: 2em; - border: 2px solid rgba(68, 107, 158, 0); - outline: none; - width: 200px; - font-variant-numeric: tabular-nums; - cursor: pointer; -} - -.increment:focus { - border: 2px solid #335d92; -} - -.increment:active { - background-color: rgba(68, 107, 158, 0.2); -} \ No newline at end of file diff --git a/examples/aws-solid/src/components/Counter.tsx b/examples/aws-solid/src/components/Counter.tsx deleted file mode 100644 index 091fc5d0bc..0000000000 --- a/examples/aws-solid/src/components/Counter.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { createSignal } from "solid-js"; -import "./Counter.css"; - -export default function Counter() { - const [count, setCount] = createSignal(0); - return ( - - ); -} diff --git a/examples/aws-solid/src/entry-client.tsx b/examples/aws-solid/src/entry-client.tsx deleted file mode 100644 index 0ca4e3c300..0000000000 --- a/examples/aws-solid/src/entry-client.tsx +++ /dev/null @@ -1,4 +0,0 @@ -// @refresh reload -import { mount, StartClient } from "@solidjs/start/client"; - -mount(() => , document.getElementById("app")!); diff --git a/examples/aws-solid/src/entry-server.tsx b/examples/aws-solid/src/entry-server.tsx deleted file mode 100644 index 401eff83fd..0000000000 --- a/examples/aws-solid/src/entry-server.tsx +++ /dev/null @@ -1,21 +0,0 @@ -// @refresh reload -import { createHandler, StartServer } from "@solidjs/start/server"; - -export default createHandler(() => ( - ( - - - - - - {assets} - - -
{children}
- {scripts} - - - )} - /> -)); diff --git a/examples/aws-solid/src/global.d.ts b/examples/aws-solid/src/global.d.ts deleted file mode 100644 index dc6f10c226..0000000000 --- a/examples/aws-solid/src/global.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/examples/aws-solid/src/routes/[...404].tsx b/examples/aws-solid/src/routes/[...404].tsx deleted file mode 100644 index 4ea71ec7fe..0000000000 --- a/examples/aws-solid/src/routes/[...404].tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { Title } from "@solidjs/meta"; -import { HttpStatusCode } from "@solidjs/start"; - -export default function NotFound() { - return ( -
- Not Found - -

Page Not Found

-

- Visit{" "} - - start.solidjs.com - {" "} - to learn how to build SolidStart apps. -

-
- ); -} diff --git a/examples/aws-solid/src/routes/about.tsx b/examples/aws-solid/src/routes/about.tsx deleted file mode 100644 index 8371d911cd..0000000000 --- a/examples/aws-solid/src/routes/about.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { Title } from "@solidjs/meta"; - -export default function Home() { - return ( -
- About -

About

-
- ); -} diff --git a/examples/aws-solid/src/routes/index.tsx b/examples/aws-solid/src/routes/index.tsx deleted file mode 100644 index 9d59f86dee..0000000000 --- a/examples/aws-solid/src/routes/index.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import { Resource } from "sst"; -import { createAsync } from "@solidjs/router"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -async function presignedUrl() { - "use server"; - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - return await getSignedUrl(new S3Client({}), command); -} - -export const route = { - load: () => presignedUrl(), -}; - -export default function Home() { - const url = createAsync(() => presignedUrl()); - - return ( -
-

Hello world!

-
{ - e.preventDefault(); - - const file = (e.target as HTMLFormElement).file.files?.[0]!; - - const image = await fetch(url() as string, { - body: file, - method: "PUT", - headers: { - "Content-Type": file.type, - "Content-Disposition": `attachment; filename="${file.name}"`, - }, - }); - - window.location.href = image.url.split("?")[0]; - }} - > - - -
-
- ); -} diff --git a/examples/aws-solid/sst.config.ts b/examples/aws-solid/sst.config.ts deleted file mode 100644 index b14575b398..0000000000 --- a/examples/aws-solid/sst.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-solid", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" - }); - new sst.aws.SolidStart("MyWeb", { - link: [bucket], - }); - }, -}); diff --git a/examples/aws-solid/tsconfig.json b/examples/aws-solid/tsconfig.json deleted file mode 100644 index 7d5871a07a..0000000000 --- a/examples/aws-solid/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "jsx": "preserve", - "jsxImportSource": "solid-js", - "allowJs": true, - "strict": true, - "noEmit": true, - "types": ["vinxi/types/client"], - "isolatedModules": true, - "paths": { - "~/*": ["./src/*"] - } - } -} diff --git a/examples/aws-static-site-basic-auth/package.json b/examples/aws-static-site-basic-auth/package.json deleted file mode 100644 index da474b02d6..0000000000 --- a/examples/aws-static-site-basic-auth/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-static-site-basic-auth", - "version": "1.0.0", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-static-site-basic-auth/site/index.html b/examples/aws-static-site-basic-auth/site/index.html deleted file mode 100644 index 781e1c2cf4..0000000000 --- a/examples/aws-static-site-basic-auth/site/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - -

hello world!

- - diff --git a/examples/aws-static-site-basic-auth/sst.config.ts b/examples/aws-static-site-basic-auth/sst.config.ts deleted file mode 100644 index 212e65f84c..0000000000 --- a/examples/aws-static-site-basic-auth/sst.config.ts +++ /dev/null @@ -1,80 +0,0 @@ -/// - -/** - * ## AWS static site basic auth - * - * This deploys a simple static site and adds basic auth to it. - * - * This is useful for dev environments where you want to share a static site with your team but - * ensure that it's not publicly accessible. - * - * This works by injecting some code into a CloudFront function that checks the basic auth - * header and matches it against the `USERNAME` and `PASSWORD` secrets. - * - * ```ts title="sst.config.ts" - * { - * injection: $interpolate` - * if ( - * !event.request.headers.authorization - * || event.request.headers.authorization.value !== "Basic ${basicAuth}" - * ) { - * return { - * statusCode: 401, - * headers: { - * "www-authenticate": { value: "Basic" } - * } - * }; - * }`, - * } - * ``` - * - * To deploy this, you need to first set the `USERNAME` and `PASSWORD` secrets. - * - * ```bash - * sst secret set USERNAME my-username - * sst secret set PASSWORD my-password - * ``` - * - * If you are deploying this to preview environments, you might want to set the secrets using - * the [`--fallback`](/docs/reference/cli#secret) flag. - */ -export default $config({ - app(input) { - return { - name: "aws-static-site-basic-auth", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - const username = new sst.Secret("USERNAME"); - const password = new sst.Secret("PASSWORD"); - const basicAuth = $resolve([username.value, password.value]).apply( - ([username, password]) => - Buffer.from(`${username}:${password}`).toString("base64") - ); - - new sst.aws.StaticSite("MySite", { - path: "site", - // Don't password protect prod - edge: $app.stage !== "production" - ? { - viewerRequest: { - injection: $interpolate` - if ( - !event.request.headers.authorization - || event.request.headers.authorization.value !== "Basic ${basicAuth}" - ) { - return { - statusCode: 401, - headers: { - "www-authenticate": { value: "Basic" } - } - }; - }`, - }, - } - : undefined, - }); - }, -}); diff --git a/examples/aws-static-site/package.json b/examples/aws-static-site/package.json deleted file mode 100644 index 5e4a51b0c2..0000000000 --- a/examples/aws-static-site/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "aws-static-site", - "version": "1.0.0", - "main": "index.js", - "devDependencies": { - "sst": "file:../../sdk/js" - }, - "scripts": { - "dev": "npx --yes serve ./site" - }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "" -} diff --git a/examples/aws-static-site/site/404.html b/examples/aws-static-site/site/404.html deleted file mode 100644 index e1dc7559af..0000000000 --- a/examples/aws-static-site/site/404.html +++ /dev/null @@ -1,7 +0,0 @@ - - - 404 Not Found - -

404 - Page Not Found

- - diff --git a/examples/aws-static-site/site/index.html b/examples/aws-static-site/site/index.html deleted file mode 100644 index 9605cebdeb..0000000000 --- a/examples/aws-static-site/site/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - -

Hello World!

- - diff --git a/examples/aws-static-site/sst.config.ts b/examples/aws-static-site/sst.config.ts deleted file mode 100644 index 2cde0b1837..0000000000 --- a/examples/aws-static-site/sst.config.ts +++ /dev/null @@ -1,23 +0,0 @@ -/// - -/** - * ## AWS static site - * - * Deploy a simple HTML file as a static site with S3 and CloudFront. The website is stored in - * the `site/` directory. - */ -export default $config({ - app(input) { - return { - name: "aws-static-site", - home: "aws", - removal: input?.stage === "production" ? "retain" : "remove", - }; - }, - async run() { - new sst.aws.StaticSite("MySite", { - path: "site", - errorPage: "404.html", - }); - }, -}); diff --git a/examples/aws-step-functions-task-token/.gitignore b/examples/aws-step-functions-task-token/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-step-functions-task-token/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-step-functions-task-token/index.ts b/examples/aws-step-functions-task-token/index.ts deleted file mode 100644 index 4019bcbab7..0000000000 --- a/examples/aws-step-functions-task-token/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { SQSEvent } from "aws-lambda"; -import { SFNClient, SendTaskSuccessCommand } from "@aws-sdk/client-sfn"; - -const sfn = new SFNClient(); - -export async function handler(e: SQSEvent) { - // Parse the task token - const { body } = e.Records[0]; - const { MyTaskToken } = JSON.parse(body); - - // Do some work - await new Promise((resolve) => setTimeout(resolve, 1000)); - - // Call `SendTaskSuccess` to mark the task done - await sfn.send( - new SendTaskSuccessCommand({ - taskToken: MyTaskToken, - output: JSON.stringify({ result: "foo" }), - }) - ); - - return "ok"; -} diff --git a/examples/aws-step-functions-task-token/package.json b/examples/aws-step-functions-task-token/package.json deleted file mode 100644 index 6f54d1065d..0000000000 --- a/examples/aws-step-functions-task-token/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "aws-step-functions-task-token", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "deploy": "go run ../../cmd/sst deploy", - "remove": "go run ../../cmd/sst remove", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@aws-sdk/client-sfn": "^3.812.0", - "sst": "file:../../sdk/js" - }, - "devDependencies": { - "@types/aws-lambda": "^8.10.11" - } -} diff --git a/examples/aws-step-functions-task-token/sst.config.ts b/examples/aws-step-functions-task-token/sst.config.ts deleted file mode 100644 index bb47484940..0000000000 --- a/examples/aws-step-functions-task-token/sst.config.ts +++ /dev/null @@ -1,45 +0,0 @@ -/// - -/** - * ## AWS Step Functions task token - * - * Use Step Functions with task tokens to pause execution, send a message to an - * SQS queue, and resume after processing. - */ -export default $config({ - app(input) { - return { - name: "aws-step-functions-task-token", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - // Create a queue the state machine will send messages to - const queue = new sst.aws.Queue("MyQueue"); - - // Define all the states of the state machine - const sendMessage = sst.aws.StepFunctions.sqsSendMessage({ - name: "SendMessage", - integration: "token", - queue, - messageBody: { - // Task token passed in the message body - MyTaskToken: "{% $states.context.Task.Token %}", - }, - }); - const success = sst.aws.StepFunctions.succeed({ name: "Succeed" }); - - // Create the state machine - const stepFunction = new sst.aws.StepFunctions("MyStateMachine", { - definition: sendMessage.next(success), - }); - - // Create a function that will receive messages from the queue - queue.subscribe({ - handler: "index.handler", - // Linking the state machine to grant permissions to call `SendTaskSuccess` - link: [stepFunction], - }); - }, -}); diff --git a/examples/aws-step-functions-task-token/tsconfig.json b/examples/aws-step-functions-task-token/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-step-functions-task-token/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-step-functions/.gitignore b/examples/aws-step-functions/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-step-functions/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-step-functions/index.ts b/examples/aws-step-functions/index.ts deleted file mode 100644 index 6e7064b8d5..0000000000 --- a/examples/aws-step-functions/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export async function handler() { - return { - message: "v1", - }; -} diff --git a/examples/aws-step-functions/package.json b/examples/aws-step-functions/package.json deleted file mode 100644 index f1d60f0a31..0000000000 --- a/examples/aws-step-functions/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "aws-step-functions", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "deploy": "go run ../../cmd/sst deploy", - "remove": "go run ../../cmd/sst remove", - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-step-functions/sst.config.ts b/examples/aws-step-functions/sst.config.ts deleted file mode 100644 index e8982e1878..0000000000 --- a/examples/aws-step-functions/sst.config.ts +++ /dev/null @@ -1,62 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-step-functions", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - // Create a function to be invoked by the state machine - const app = new sst.aws.Function("MyApp", { - handler: "index.handler", - }); - - // Define all the states of the state machine - const lambdaInvoke = sst.aws.StepFunctions.lambdaInvoke({ - name: "LambdaInvoke", - function: app, - payload: { - foo: "bar", - }, - }); - const pass = sst.aws.StepFunctions.pass({ name: "Pass" }); - const wait = sst.aws.StepFunctions.wait({ - name: "Wait", - time: "2 seconds", - }); - const choice = sst.aws.StepFunctions.choice({ name: "Choice" }); - const parallel = sst.aws.StepFunctions.parallel({ name: "Parallel" }); - const parallelA = sst.aws.StepFunctions.pass({ name: "ParallelA" }); - const parallelB = sst.aws.StepFunctions.pass({ name: "ParallelB" }); - const parallelC = sst.aws.StepFunctions.pass({ name: "ParallelC" }); - const mapA = sst.aws.StepFunctions.pass({ name: "MapA" }); - const mapB = sst.aws.StepFunctions.pass({ name: "MapB" }); - const map = sst.aws.StepFunctions.map({ - name: "Map", - processor: mapA.next(mapB), - items: ["a", "b", "c"], - }); - const success = sst.aws.StepFunctions.succeed({ name: "Succeed" }); - const fail = sst.aws.StepFunctions.fail({ name: "Fail" }); - const last = sst.aws.StepFunctions.pass({ name: "Last" }); - - // Create the state machine - new sst.aws.StepFunctions("MyStateMachine", { - definition: lambdaInvoke - .catch(fail) - .next(pass) - .next(wait) - .next(parallel.branch(parallelA.next(parallelB)).branch(parallelC)) - .next(map) - .next( - choice - .when("{% 1+1 = 2 %}", success) - .when("{% 1+1 = 3 %}", fail) - .otherwise(last) - ), - }); - }, -}); diff --git a/examples/aws-step-functions/tsconfig.json b/examples/aws-step-functions/tsconfig.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/aws-step-functions/tsconfig.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/aws-supabase-drizzle/.gitignore b/examples/aws-supabase-drizzle/.gitignore deleted file mode 100644 index cc54d25a17..0000000000 --- a/examples/aws-supabase-drizzle/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# sst -.sst diff --git a/examples/aws-supabase-drizzle/drizzle.config.ts b/examples/aws-supabase-drizzle/drizzle.config.ts deleted file mode 100644 index 7f110ab1ad..0000000000 --- a/examples/aws-supabase-drizzle/drizzle.config.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { defineConfig } from "drizzle-kit"; -import { Resource } from "sst"; -export default defineConfig({ - schema: ["./src/**/*.sql.ts"], - out: "./migrations", - dialect: "postgresql", - dbCredentials: { - host: Resource.Database.host, - database: Resource.Database.database, - port: Resource.Database.port, - user: Resource.Database.user, - password: Resource.Database.password, - }, -}); diff --git a/examples/aws-supabase-drizzle/migrations/0000_great_solo.sql b/examples/aws-supabase-drizzle/migrations/0000_great_solo.sql deleted file mode 100644 index db52d6f17f..0000000000 --- a/examples/aws-supabase-drizzle/migrations/0000_great_solo.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE IF NOT EXISTS "todo" ( - "id" serial PRIMARY KEY NOT NULL, - "title" text NOT NULL, - "description" text -); diff --git a/examples/aws-supabase-drizzle/migrations/meta/0000_snapshot.json b/examples/aws-supabase-drizzle/migrations/meta/0000_snapshot.json deleted file mode 100644 index 64994dcf98..0000000000 --- a/examples/aws-supabase-drizzle/migrations/meta/0000_snapshot.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "id": "60c8abb1-7e2d-4b3d-8bc3-68b4a51c8fb8", - "prevId": "00000000-0000-0000-0000-000000000000", - "version": "6", - "dialect": "postgresql", - "tables": { - "public.todo": { - "name": "todo", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - } - }, - "enums": {}, - "schemas": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/examples/aws-supabase-drizzle/migrations/meta/_journal.json b/examples/aws-supabase-drizzle/migrations/meta/_journal.json deleted file mode 100644 index 6088d1cbd8..0000000000 --- a/examples/aws-supabase-drizzle/migrations/meta/_journal.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "version": "5", - "dialect": "pg", - "entries": [ - { - "idx": 0, - "version": "6", - "when": 1715012302701, - "tag": "0000_great_solo", - "breakpoints": true - } - ] -} \ No newline at end of file diff --git a/examples/aws-supabase-drizzle/package.json b/examples/aws-supabase-drizzle/package.json deleted file mode 100644 index 9439872cd4..0000000000 --- a/examples/aws-supabase-drizzle/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "aws-supabase-drizzle", - "version": "0.0.0", - "type": "module", - "scripts": { - "db": "sst shell drizzle-kit", - "db:studio": "sst shell drizzle-kit studio", - "db:migrate": "sst shell drizzle-kit migrate" - }, - "dependencies": { - "@aws-sdk/client-rds-data": "^3.564.0", - "drizzle-kit": "0.20.17-679add7", - "drizzle-orm": "^0.30.9", - "postgres": "^3.4.4", - "sst": "file:../../sdk/js" - } -} diff --git a/examples/aws-supabase-drizzle/src/api.ts b/examples/aws-supabase-drizzle/src/api.ts deleted file mode 100644 index b4abb9a66d..0000000000 --- a/examples/aws-supabase-drizzle/src/api.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { db } from "./drizzle"; -import { todo } from "./todo.sql"; -import { APIGatewayProxyHandlerV2 } from "aws-lambda"; -import { randomUUID } from "node:crypto"; - -export const handler: APIGatewayProxyHandlerV2 = async (evt) => { - if (evt.requestContext.http.method === "GET") { - const result = await db.select().from(todo).execute(); - return { - statusCode: 200, - body: JSON.stringify(result), - }; - } - - if (evt.requestContext.http.method === "POST") { - const result = await db - .insert(todo) - .values({ title: "new todo " + randomUUID() }) - .returning() - .execute(); - return { - statusCode: 200, - body: JSON.stringify(result), - }; - } - - return { - statusCode: 404, - body: "not found", - }; -}; diff --git a/examples/aws-supabase-drizzle/src/drizzle.ts b/examples/aws-supabase-drizzle/src/drizzle.ts deleted file mode 100644 index 72efbb6aa3..0000000000 --- a/examples/aws-supabase-drizzle/src/drizzle.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { drizzle } from "drizzle-orm/postgres-js"; -import { Resource } from "sst"; -import postgres from "postgres"; - -const client = postgres({ - password: Resource.Database.password, - user: Resource.Database.user, - port: Resource.Database.port, - host: Resource.Database.host, - db: "postgres", -}); - -export const db = drizzle(client); diff --git a/examples/aws-supabase-drizzle/src/todo.sql.ts b/examples/aws-supabase-drizzle/src/todo.sql.ts deleted file mode 100644 index 1de457f10b..0000000000 --- a/examples/aws-supabase-drizzle/src/todo.sql.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { pgTable, text, serial } from "drizzle-orm/pg-core"; - -export const todo = pgTable("todo", { - id: serial("id").primaryKey(), - title: text("title").notNull(), - description: text("description"), -}); diff --git a/examples/aws-supabase-drizzle/sst.config.ts b/examples/aws-supabase-drizzle/sst.config.ts deleted file mode 100644 index 232b2e7e53..0000000000 --- a/examples/aws-supabase-drizzle/sst.config.ts +++ /dev/null @@ -1,44 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-supabase-drizzle", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - providers: { - random: true, - supabase: true, - }, - }; - }, - async run() { - sst.Linkable.wrap(supabase.Project, function (item) { - return { - properties: { - user: $interpolate`postgres.${item.id}`, - password: item.databasePassword, - host: $interpolate`aws-0-${item.region}.pooler.supabase.com`, - port: 5432, - database: "postgres", - }, - }; - }); - const project = new supabase.Project("Database", { - name: $interpolate`${$app.name}-${$app.stage}`, - region: "us-east-1", - organizationId: process.env.SUPABASE_ORG_ID!, - databasePassword: new random.RandomString("DatabasePassword", { - length: 16, - }).result, - }); - const api = new sst.aws.Function("Api", { - url: true, - handler: "src/api.handler", - link: [project], - }); - return { - url: api.url, - }; - }, -}); diff --git a/examples/aws-supabase-drizzle/tsconfig.json b/examples/aws-supabase-drizzle/tsconfig.json deleted file mode 100644 index b6955c086e..0000000000 --- a/examples/aws-supabase-drizzle/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "esModuleInterop": true, - } -} diff --git a/examples/aws-svelte-container/.dockerignore b/examples/aws-svelte-container/.dockerignore deleted file mode 100644 index 54159dd073..0000000000 --- a/examples/aws-svelte-container/.dockerignore +++ /dev/null @@ -1,6 +0,0 @@ -.DS_Store -node_modules - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-svelte-container/.gitignore b/examples/aws-svelte-container/.gitignore deleted file mode 100644 index 82ed85c1d6..0000000000 --- a/examples/aws-svelte-container/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -node_modules - -# Output -.output -.vercel -/.svelte-kit -/build - -# OS -.DS_Store -Thumbs.db - -# Env -.env -.env.* -!.env.example -!.env.test - -# Vite -vite.config.js.timestamp-* -vite.config.ts.timestamp-* - -# sst -.sst diff --git a/examples/aws-svelte-container/.npmrc b/examples/aws-svelte-container/.npmrc deleted file mode 100644 index b6f27f1359..0000000000 --- a/examples/aws-svelte-container/.npmrc +++ /dev/null @@ -1 +0,0 @@ -engine-strict=true diff --git a/examples/aws-svelte-container/Dockerfile b/examples/aws-svelte-container/Dockerfile deleted file mode 100644 index 6c82f47358..0000000000 --- a/examples/aws-svelte-container/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM node:18.18.0-alpine AS builder - -WORKDIR /app -COPY package*.json . -RUN npm install -COPY . . -RUN npm run build -RUN npm prune --prod - -FROM builder AS deployer - -WORKDIR /app -COPY --from=builder /app/build build/ -COPY --from=builder /app/package.json . -EXPOSE 3000 -ENV NODE_ENV=production -CMD [ "node", "build" ] diff --git a/examples/aws-svelte-container/package.json b/examples/aws-svelte-container/package.json deleted file mode 100644 index f62de0b433..0000000000 --- a/examples/aws-svelte-container/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "aws-svelte-container", - "version": "0.0.1", - "type": "module", - "scripts": { - "build": "vite build", - "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", - "dev": "vite dev", - "preview": "vite preview" - }, - "devDependencies": { - "@sveltejs/adapter-auto": "^3.0.0", - "@sveltejs/adapter-node": "^5.2.9", - "@sveltejs/kit": "^2.0.0", - "@sveltejs/vite-plugin-svelte": "^4.0.0", - "svelte": "^5.0.0", - "svelte-check": "^4.0.0", - "typescript": "^5.0.0", - "vite": "^5.0.3" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.701.0", - "@aws-sdk/s3-request-presigner": "^3.701.0", - "sst": "file:../../sdk/js", - "svelte-kit-sst": "2.43.5" - } -} diff --git a/examples/aws-svelte-container/src/app.d.ts b/examples/aws-svelte-container/src/app.d.ts deleted file mode 100644 index da08e6da59..0000000000 --- a/examples/aws-svelte-container/src/app.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -// See https://svelte.dev/docs/kit/types#app.d.ts -// for information about these interfaces -declare global { - namespace App { - // interface Error {} - // interface Locals {} - // interface PageData {} - // interface PageState {} - // interface Platform {} - } -} - -export {}; diff --git a/examples/aws-svelte-container/src/app.html b/examples/aws-svelte-container/src/app.html deleted file mode 100644 index 77a5ff52c9..0000000000 --- a/examples/aws-svelte-container/src/app.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - %sveltekit.head% - - -
%sveltekit.body%
- - diff --git a/examples/aws-svelte-container/src/lib/index.ts b/examples/aws-svelte-container/src/lib/index.ts deleted file mode 100644 index 856f2b6c38..0000000000 --- a/examples/aws-svelte-container/src/lib/index.ts +++ /dev/null @@ -1 +0,0 @@ -// place files you want to import through the `$lib` alias in this folder. diff --git a/examples/aws-svelte-container/src/routes/+page.server.ts b/examples/aws-svelte-container/src/routes/+page.server.ts deleted file mode 100644 index d5ff41caed..0000000000 --- a/examples/aws-svelte-container/src/routes/+page.server.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -/** @type {import('./$types').PageServerLoad} */ -export async function load() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return { url }; -} diff --git a/examples/aws-svelte-container/src/routes/+page.svelte b/examples/aws-svelte-container/src/routes/+page.svelte deleted file mode 100644 index cbc3260f8b..0000000000 --- a/examples/aws-svelte-container/src/routes/+page.svelte +++ /dev/null @@ -1,38 +0,0 @@ - - - - -
-
- - -
-
diff --git a/examples/aws-svelte-container/sst.config.ts b/examples/aws-svelte-container/sst.config.ts deleted file mode 100644 index dac8837874..0000000000 --- a/examples/aws-svelte-container/sst.config.ts +++ /dev/null @@ -1,30 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-svelte-container", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc"); - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public", - }); - - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [bucket], - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-svelte-container/static/favicon.png b/examples/aws-svelte-container/static/favicon.png deleted file mode 100644 index 825b9e65af..0000000000 Binary files a/examples/aws-svelte-container/static/favicon.png and /dev/null differ diff --git a/examples/aws-svelte-container/svelte.config.js b/examples/aws-svelte-container/svelte.config.js deleted file mode 100644 index e0a641ee7f..0000000000 --- a/examples/aws-svelte-container/svelte.config.js +++ /dev/null @@ -1,18 +0,0 @@ -import adapter from '@sveltejs/adapter-node'; -import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; - -/** @type {import('@sveltejs/kit').Config} */ -const config = { - // Consult https://svelte.dev/docs/kit/integrations - // for more information about preprocessors - preprocess: vitePreprocess(), - - kit: { - // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. - // If your environment is not supported, or you settled on a specific environment, switch out the adapter. - // See https://svelte.dev/docs/kit/adapters for more information about adapters. - adapter: adapter() - } -}; - -export default config; diff --git a/examples/aws-svelte-container/tsconfig.json b/examples/aws-svelte-container/tsconfig.json deleted file mode 100644 index 0b2d8865f4..0000000000 --- a/examples/aws-svelte-container/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./.svelte-kit/tsconfig.json", - "compilerOptions": { - "allowJs": true, - "checkJs": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "sourceMap": true, - "strict": true, - "moduleResolution": "bundler" - } - // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias - // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files - // - // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes - // from the referenced tsconfig.json - TypeScript does not merge them in -} diff --git a/examples/aws-svelte-container/vite.config.ts b/examples/aws-svelte-container/vite.config.ts deleted file mode 100644 index bbf8c7da43..0000000000 --- a/examples/aws-svelte-container/vite.config.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { sveltekit } from '@sveltejs/kit/vite'; -import { defineConfig } from 'vite'; - -export default defineConfig({ - plugins: [sveltekit()] -}); diff --git a/examples/aws-svelte-kit-remote-functions/.gitignore b/examples/aws-svelte-kit-remote-functions/.gitignore deleted file mode 100644 index 37e9161d16..0000000000 --- a/examples/aws-svelte-kit-remote-functions/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -node_modules - -# Output -.output -.vercel -/.svelte-kit -/build - -# OS -.DS_Store -Thumbs.db - -# Env -.env -.env.* -!.env.example -!.env.test - -# Vite -vite.config.js.timestamp-* -vite.config.ts.timestamp-* - -# sst -.sst - diff --git a/examples/aws-svelte-kit-remote-functions/.npmrc b/examples/aws-svelte-kit-remote-functions/.npmrc deleted file mode 100644 index b6f27f1359..0000000000 --- a/examples/aws-svelte-kit-remote-functions/.npmrc +++ /dev/null @@ -1 +0,0 @@ -engine-strict=true diff --git a/examples/aws-svelte-kit-remote-functions/package.json b/examples/aws-svelte-kit-remote-functions/package.json deleted file mode 100644 index 2996b0ffc1..0000000000 --- a/examples/aws-svelte-kit-remote-functions/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "aws-svelte-kit-remote-functions", - "private": true, - "version": "0.0.1", - "type": "module", - "scripts": { - "dev": "vite dev", - "build": "vite build", - "preview": "vite preview", - "prepare": "svelte-kit sync || echo ''", - "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch" - }, - "devDependencies": { - "@sveltejs/adapter-auto": "^6.1.0", - "@sveltejs/kit": "^2.43.2", - "@sveltejs/vite-plugin-svelte": "^6.2.0", - "@tailwindcss/vite": "^4.1.13", - "svelte": "^5.39.5", - "svelte-check": "^4.3.2", - "tailwindcss": "^4.1.13", - "typescript": "^5.9.2", - "vite": "^7.1.7" - }, - "dependencies": { - "sst": "file:../../sdk/js", - "svelte-kit-sst": "latest" - } -} diff --git a/examples/aws-svelte-kit-remote-functions/src/app.css b/examples/aws-svelte-kit-remote-functions/src/app.css deleted file mode 100644 index d4b5078586..0000000000 --- a/examples/aws-svelte-kit-remote-functions/src/app.css +++ /dev/null @@ -1 +0,0 @@ -@import 'tailwindcss'; diff --git a/examples/aws-svelte-kit-remote-functions/src/app.d.ts b/examples/aws-svelte-kit-remote-functions/src/app.d.ts deleted file mode 100644 index da08e6da59..0000000000 --- a/examples/aws-svelte-kit-remote-functions/src/app.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -// See https://svelte.dev/docs/kit/types#app.d.ts -// for information about these interfaces -declare global { - namespace App { - // interface Error {} - // interface Locals {} - // interface PageData {} - // interface PageState {} - // interface Platform {} - } -} - -export {}; diff --git a/examples/aws-svelte-kit-remote-functions/src/app.html b/examples/aws-svelte-kit-remote-functions/src/app.html deleted file mode 100644 index f273cc58f7..0000000000 --- a/examples/aws-svelte-kit-remote-functions/src/app.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - %sveltekit.head% - - -
%sveltekit.body%
- - diff --git a/examples/aws-svelte-kit-remote-functions/src/lib/assets/favicon.svg b/examples/aws-svelte-kit-remote-functions/src/lib/assets/favicon.svg deleted file mode 100644 index cc5dc66a3a..0000000000 --- a/examples/aws-svelte-kit-remote-functions/src/lib/assets/favicon.svg +++ /dev/null @@ -1 +0,0 @@ -svelte-logo \ No newline at end of file diff --git a/examples/aws-svelte-kit-remote-functions/src/routes/+page.svelte b/examples/aws-svelte-kit-remote-functions/src/routes/+page.svelte deleted file mode 100644 index 9890126cad..0000000000 --- a/examples/aws-svelte-kit-remote-functions/src/routes/+page.svelte +++ /dev/null @@ -1,24 +0,0 @@ - - - - {#snippet pending()} -

Loading...

- {/snippet} - - {#snippet failed(err, reset)} -

Error: {err}

- - {/snippet} - -
    - {#each await getArbitraryData() as item} -
  • {item}
  • - {/each} -
-
diff --git a/examples/aws-svelte-kit-remote-functions/src/routes/home.remote.ts b/examples/aws-svelte-kit-remote-functions/src/routes/home.remote.ts deleted file mode 100644 index b36e1eb5c7..0000000000 --- a/examples/aws-svelte-kit-remote-functions/src/routes/home.remote.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { query } from "$app/server"; - -export const getArbitraryData = query(async () => { - await new Promise((resolve) => setTimeout(resolve, 2000)); - return ["foo", "bar", "baz"]; -}); diff --git a/examples/aws-svelte-kit-remote-functions/sst.config.ts b/examples/aws-svelte-kit-remote-functions/sst.config.ts deleted file mode 100644 index b50ebbfb2b..0000000000 --- a/examples/aws-svelte-kit-remote-functions/sst.config.ts +++ /dev/null @@ -1,18 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-svelte-kit-remote-functions", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - new sst.aws.SvelteKit("MyWeb", { - dev: { - command: "bun run dev", - }, - }); - }, -}); diff --git a/examples/aws-svelte-kit-remote-functions/static/robots.txt b/examples/aws-svelte-kit-remote-functions/static/robots.txt deleted file mode 100644 index b6dd6670cb..0000000000 --- a/examples/aws-svelte-kit-remote-functions/static/robots.txt +++ /dev/null @@ -1,3 +0,0 @@ -# allow crawling everything by default -User-agent: * -Disallow: diff --git a/examples/aws-svelte-kit-remote-functions/svelte.config.js b/examples/aws-svelte-kit-remote-functions/svelte.config.js deleted file mode 100644 index 77f720c3d8..0000000000 --- a/examples/aws-svelte-kit-remote-functions/svelte.config.js +++ /dev/null @@ -1,25 +0,0 @@ -import adapter from "svelte-kit-sst"; -import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"; - -/** @type {import('@sveltejs/kit').Config} */ -const config = { - // Consult https://svelte.dev/docs/kit/integrations - // for more information about preprocessors - preprocess: vitePreprocess(), - compilerOptions: { - experimental: { - async: true, - }, - }, - kit: { - experimental: { - remoteFunctions: true, - }, - // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. - // If your environment is not supported, or you settled on a specific environment, switch out the adapter. - // See https://svelte.dev/docs/kit/adapters for more information about adapters. - adapter: adapter(), - }, -}; - -export default config; diff --git a/examples/aws-svelte-kit-remote-functions/tsconfig.json b/examples/aws-svelte-kit-remote-functions/tsconfig.json deleted file mode 100644 index a5567ee6bb..0000000000 --- a/examples/aws-svelte-kit-remote-functions/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./.svelte-kit/tsconfig.json", - "compilerOptions": { - "allowJs": true, - "checkJs": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "sourceMap": true, - "strict": true, - "moduleResolution": "bundler" - } - // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias - // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files - // - // To make changes to top-level options such as include and exclude, we recommend extending - // the generated config; see https://svelte.dev/docs/kit/configuration#typescript -} diff --git a/examples/aws-svelte-kit-remote-functions/vite.config.ts b/examples/aws-svelte-kit-remote-functions/vite.config.ts deleted file mode 100644 index 2d35c4f5af..0000000000 --- a/examples/aws-svelte-kit-remote-functions/vite.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import tailwindcss from '@tailwindcss/vite'; -import { sveltekit } from '@sveltejs/kit/vite'; -import { defineConfig } from 'vite'; - -export default defineConfig({ - plugins: [tailwindcss(), sveltekit()] -}); diff --git a/examples/aws-svelte-kit/.gitignore b/examples/aws-svelte-kit/.gitignore deleted file mode 100644 index 82ed85c1d6..0000000000 --- a/examples/aws-svelte-kit/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -node_modules - -# Output -.output -.vercel -/.svelte-kit -/build - -# OS -.DS_Store -Thumbs.db - -# Env -.env -.env.* -!.env.example -!.env.test - -# Vite -vite.config.js.timestamp-* -vite.config.ts.timestamp-* - -# sst -.sst diff --git a/examples/aws-svelte-kit/.npmrc b/examples/aws-svelte-kit/.npmrc deleted file mode 100644 index b6f27f1359..0000000000 --- a/examples/aws-svelte-kit/.npmrc +++ /dev/null @@ -1 +0,0 @@ -engine-strict=true diff --git a/examples/aws-svelte-kit/package.json b/examples/aws-svelte-kit/package.json deleted file mode 100644 index 7db901eb05..0000000000 --- a/examples/aws-svelte-kit/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "aws-svelte-kit", - "version": "0.0.1", - "type": "module", - "scripts": { - "build": "vite build", - "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", - "dev": "vite dev", - "preview": "vite preview" - }, - "devDependencies": { - "@sveltejs/adapter-auto": "^3.0.0", - "@sveltejs/kit": "^2.0.0", - "@sveltejs/vite-plugin-svelte": "^4.0.0", - "svelte": "^5.0.0", - "svelte-check": "^4.0.0", - "typescript": "^5.0.0", - "vite": "^5.0.3" - }, - "dependencies": { - "@aws-sdk/client-s3": "^3.700.0", - "@aws-sdk/s3-request-presigner": "^3.700.0", - "sst": "file:../../sdk/js", - "svelte-kit-sst": "2.43.5" - } -} diff --git a/examples/aws-svelte-kit/src/app.d.ts b/examples/aws-svelte-kit/src/app.d.ts deleted file mode 100644 index da08e6da59..0000000000 --- a/examples/aws-svelte-kit/src/app.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -// See https://svelte.dev/docs/kit/types#app.d.ts -// for information about these interfaces -declare global { - namespace App { - // interface Error {} - // interface Locals {} - // interface PageData {} - // interface PageState {} - // interface Platform {} - } -} - -export {}; diff --git a/examples/aws-svelte-kit/src/app.html b/examples/aws-svelte-kit/src/app.html deleted file mode 100644 index 77a5ff52c9..0000000000 --- a/examples/aws-svelte-kit/src/app.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - %sveltekit.head% - - -
%sveltekit.body%
- - diff --git a/examples/aws-svelte-kit/src/lib/index.ts b/examples/aws-svelte-kit/src/lib/index.ts deleted file mode 100644 index 856f2b6c38..0000000000 --- a/examples/aws-svelte-kit/src/lib/index.ts +++ /dev/null @@ -1 +0,0 @@ -// place files you want to import through the `$lib` alias in this folder. diff --git a/examples/aws-svelte-kit/src/routes/+page.server.ts b/examples/aws-svelte-kit/src/routes/+page.server.ts deleted file mode 100644 index d5ff41caed..0000000000 --- a/examples/aws-svelte-kit/src/routes/+page.server.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Resource } from "sst"; -import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; -import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; - -/** @type {import('./$types').PageServerLoad} */ -export async function load() { - const command = new PutObjectCommand({ - Key: crypto.randomUUID(), - Bucket: Resource.MyBucket.name, - }); - const url = await getSignedUrl(new S3Client({}), command); - - return { url }; -} diff --git a/examples/aws-svelte-kit/src/routes/+page.svelte b/examples/aws-svelte-kit/src/routes/+page.svelte deleted file mode 100644 index cbc3260f8b..0000000000 --- a/examples/aws-svelte-kit/src/routes/+page.svelte +++ /dev/null @@ -1,38 +0,0 @@ - - - - -
-
- - -
-
diff --git a/examples/aws-svelte-kit/sst.config.ts b/examples/aws-svelte-kit/sst.config.ts deleted file mode 100644 index ac35800175..0000000000 --- a/examples/aws-svelte-kit/sst.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -export default $config({ - app(input) { - return { - name: "aws-svelte-kit", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const bucket = new sst.aws.Bucket("MyBucket", { - access: "public" - }); - new sst.aws.SvelteKit("MyWeb", { - link: [bucket] - }); - }, -}); diff --git a/examples/aws-svelte-kit/static/favicon.png b/examples/aws-svelte-kit/static/favicon.png deleted file mode 100644 index 825b9e65af..0000000000 Binary files a/examples/aws-svelte-kit/static/favicon.png and /dev/null differ diff --git a/examples/aws-svelte-kit/svelte.config.js b/examples/aws-svelte-kit/svelte.config.js deleted file mode 100644 index 7ea4b69156..0000000000 --- a/examples/aws-svelte-kit/svelte.config.js +++ /dev/null @@ -1,18 +0,0 @@ -import adapter from "svelte-kit-sst"; -import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; - -/** @type {import('@sveltejs/kit').Config} */ -const config = { - // Consult https://svelte.dev/docs/kit/integrations - // for more information about preprocessors - preprocess: vitePreprocess(), - - kit: { - // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. - // If your environment is not supported, or you settled on a specific environment, switch out the adapter. - // See https://svelte.dev/docs/kit/adapters for more information about adapters. - adapter: adapter() - } -}; - -export default config; diff --git a/examples/aws-svelte-kit/tsconfig.json b/examples/aws-svelte-kit/tsconfig.json deleted file mode 100644 index 0b2d8865f4..0000000000 --- a/examples/aws-svelte-kit/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./.svelte-kit/tsconfig.json", - "compilerOptions": { - "allowJs": true, - "checkJs": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "sourceMap": true, - "strict": true, - "moduleResolution": "bundler" - } - // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias - // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files - // - // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes - // from the referenced tsconfig.json - TypeScript does not merge them in -} diff --git a/examples/aws-svelte-kit/vite.config.ts b/examples/aws-svelte-kit/vite.config.ts deleted file mode 100644 index bbf8c7da43..0000000000 --- a/examples/aws-svelte-kit/vite.config.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { sveltekit } from '@sveltejs/kit/vite'; -import { defineConfig } from 'vite'; - -export default defineConfig({ - plugins: [sveltekit()] -}); diff --git a/examples/aws-svelte-redis/.dockerignore b/examples/aws-svelte-redis/.dockerignore deleted file mode 100644 index ea0aaeeec9..0000000000 --- a/examples/aws-svelte-redis/.dockerignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules - - -# sst -.sst \ No newline at end of file diff --git a/examples/aws-svelte-redis/.gitignore b/examples/aws-svelte-redis/.gitignore deleted file mode 100644 index 82ed85c1d6..0000000000 --- a/examples/aws-svelte-redis/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -node_modules - -# Output -.output -.vercel -/.svelte-kit -/build - -# OS -.DS_Store -Thumbs.db - -# Env -.env -.env.* -!.env.example -!.env.test - -# Vite -vite.config.js.timestamp-* -vite.config.ts.timestamp-* - -# sst -.sst diff --git a/examples/aws-svelte-redis/.npmrc b/examples/aws-svelte-redis/.npmrc deleted file mode 100644 index b6f27f1359..0000000000 --- a/examples/aws-svelte-redis/.npmrc +++ /dev/null @@ -1 +0,0 @@ -engine-strict=true diff --git a/examples/aws-svelte-redis/Dockerfile b/examples/aws-svelte-redis/Dockerfile deleted file mode 100644 index 442e34ca15..0000000000 --- a/examples/aws-svelte-redis/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -FROM node:lts-alpine AS builder - -# Add linked resources to the environment -ARG SST_RESOURCE_MyRedis - -WORKDIR /app - -COPY package*.json . - -RUN npm install - -COPY . . - -RUN npm run build -RUN npm prune --prod - -FROM builder AS deployer - -WORKDIR /app - -COPY --from=builder /app/build build/ -COPY --from=builder /app/package.json . - -EXPOSE 3000 - -ENV NODE_ENV=production - -CMD [ "node", "build" ] diff --git a/examples/aws-svelte-redis/package.json b/examples/aws-svelte-redis/package.json deleted file mode 100644 index 4eee5e0d29..0000000000 --- a/examples/aws-svelte-redis/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "aws-svelte-redis", - "version": "0.0.1", - "private": true, - "scripts": { - "build": "vite build", - "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", - "dev": "vite dev", - "preview": "vite preview" - }, - "devDependencies": { - "@sveltejs/adapter-auto": "^3.0.0", - "@sveltejs/adapter-node": "^5.2.6", - "@sveltejs/kit": "^2.0.0", - "@sveltejs/vite-plugin-svelte": "^3.0.0", - "svelte": "^4.2.7", - "svelte-check": "^4.0.0", - "typescript": "^5.0.0", - "vite": "^5.0.3" - }, - "type": "module", - "dependencies": { - "ioredis": "^5.4.1", - "sst": "file:../../sdk/js", - "svelte-kit-sst": "2.43.5" - } -} diff --git a/examples/aws-svelte-redis/src/app.d.ts b/examples/aws-svelte-redis/src/app.d.ts deleted file mode 100644 index 743f07b2e5..0000000000 --- a/examples/aws-svelte-redis/src/app.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -// See https://kit.svelte.dev/docs/types#app -// for information about these interfaces -declare global { - namespace App { - // interface Error {} - // interface Locals {} - // interface PageData {} - // interface PageState {} - // interface Platform {} - } -} - -export {}; diff --git a/examples/aws-svelte-redis/src/app.html b/examples/aws-svelte-redis/src/app.html deleted file mode 100644 index 77a5ff52c9..0000000000 --- a/examples/aws-svelte-redis/src/app.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - %sveltekit.head% - - -
%sveltekit.body%
- - diff --git a/examples/aws-svelte-redis/src/lib/index.ts b/examples/aws-svelte-redis/src/lib/index.ts deleted file mode 100644 index 856f2b6c38..0000000000 --- a/examples/aws-svelte-redis/src/lib/index.ts +++ /dev/null @@ -1 +0,0 @@ -// place files you want to import through the `$lib` alias in this folder. diff --git a/examples/aws-svelte-redis/src/routes/+page.server.ts b/examples/aws-svelte-redis/src/routes/+page.server.ts deleted file mode 100644 index 237509c421..0000000000 --- a/examples/aws-svelte-redis/src/routes/+page.server.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Resource } from "sst"; -import { Cluster } from "ioredis"; - -const redis = new Cluster( - [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], - { - dnsLookup: (address, callback) => callback(null, address), - redisOptions: { - tls: {}, - username: Resource.MyRedis.username, - password: Resource.MyRedis.password, - }, - } -); - -/** @type {import('./$types').PageServerLoad} */ -export async function load() { - const counter = await redis.incr("counter"); - - return { counter }; -} diff --git a/examples/aws-svelte-redis/src/routes/+page.svelte b/examples/aws-svelte-redis/src/routes/+page.svelte deleted file mode 100644 index d128445512..0000000000 --- a/examples/aws-svelte-redis/src/routes/+page.svelte +++ /dev/null @@ -1,6 +0,0 @@ - - -

Hit counter: {data.counter}

diff --git a/examples/aws-svelte-redis/sst.config.ts b/examples/aws-svelte-redis/sst.config.ts deleted file mode 100644 index dba368da71..0000000000 --- a/examples/aws-svelte-redis/sst.config.ts +++ /dev/null @@ -1,68 +0,0 @@ -/// - -/** - * ## AWS SvelteKit container with Redis - * - * Creates a hit counter app with SvelteKit and Redis. - * - * This deploys SvelteKit as a Fargate service to ECS and it's linked to Redis. - * - * ```ts title="sst.config.ts" {3} - * new sst.aws.Service("MyService", { - * cluster, - * link: [redis], - * loadBalancer: { - * ports: [{ listen: "80/http", forward: "3000/http" }], - * }, - * dev: { - * command: "npm run dev", - * }, - * }); - * ``` - * - * Since our Redis cluster is in a VPC, we’ll need a tunnel to connect to it from our local - * machine. - * - * ```bash "sudo" - * sudo npx sst tunnel install - * ``` - * - * This needs _sudo_ to create a network interface on your machine. You’ll only need to do this - * once on your machine. - * - * To start your app locally run. - * - * ```bash - * npx sst dev - * ``` - * - * Now if you go to `http://localhost:5173` you’ll see a counter update as you refresh the page. - * - * Finally, you can deploy it by adding the `Dockerfile` that's included in this example and - * running `npx sst deploy --stage production`. - */ -export default $config({ - app(input) { - return { - name: "aws-svelte-redis", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true }); - const redis = new sst.aws.Redis("MyRedis", { vpc }); - const cluster = new sst.aws.Cluster("MyCluster", { vpc }); - - new sst.aws.Service("MyService", { - cluster, - link: [redis], - loadBalancer: { - ports: [{ listen: "80/http", forward: "3000/http" }], - }, - dev: { - command: "npm run dev", - }, - }); - }, -}); diff --git a/examples/aws-svelte-redis/static/favicon.png b/examples/aws-svelte-redis/static/favicon.png deleted file mode 100644 index 825b9e65af..0000000000 Binary files a/examples/aws-svelte-redis/static/favicon.png and /dev/null differ diff --git a/examples/aws-svelte-redis/svelte.config.js b/examples/aws-svelte-redis/svelte.config.js deleted file mode 100644 index fffb8494ec..0000000000 --- a/examples/aws-svelte-redis/svelte.config.js +++ /dev/null @@ -1,18 +0,0 @@ -import adapter from '@sveltejs/adapter-node'; -import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; - -/** @type {import('@sveltejs/kit').Config} */ -const config = { - // Consult https://kit.svelte.dev/docs/integrations#preprocessors - // for more information about preprocessors - preprocess: vitePreprocess(), - - kit: { - // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. - // If your environment is not supported, or you settled on a specific environment, switch out the adapter. - // See https://kit.svelte.dev/docs/adapters for more information about adapters. - adapter: adapter() - } -}; - -export default config; diff --git a/examples/aws-svelte-redis/tsconfig.json b/examples/aws-svelte-redis/tsconfig.json deleted file mode 100644 index 60c2cf6020..0000000000 --- a/examples/aws-svelte-redis/tsconfig.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "extends": "./.svelte-kit/tsconfig.json", - "include": [ - "ambient.d.ts", - "non-ambient.d.ts", - "./types/**/$types.d.ts", - "../sst-env.d.ts", - "../vite.config.js", - "../vite.config.ts", - "../src/**/*.js", - "../src/**/*.ts", - "../src/**/*.svelte", - "../tests/**/*.js", - "../tests/**/*.ts", - "../tests/**/*.svelte" - ], - "compilerOptions": { - "allowJs": true, - "checkJs": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "sourceMap": true, - "strict": true, - "moduleResolution": "bundler" - } - // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias - // except $lib which is handled by https://kit.svelte.dev/docs/configuration#files - // - // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes - // from the referenced tsconfig.json - TypeScript does not merge them in -} diff --git a/examples/aws-svelte-redis/vite.config.ts b/examples/aws-svelte-redis/vite.config.ts deleted file mode 100644 index bbf8c7da43..0000000000 --- a/examples/aws-svelte-redis/vite.config.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { sveltekit } from '@sveltejs/kit/vite'; -import { defineConfig } from 'vite'; - -export default defineConfig({ - plugins: [sveltekit()] -}); diff --git a/examples/aws-swift/.gitignore b/examples/aws-swift/.gitignore deleted file mode 100644 index 170c6abc12..0000000000 --- a/examples/aws-swift/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.DS_Store -/.build -/Packages -xcuserdata/ -DerivedData/ -.swiftpm/configuration/registries.json -.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata -.netrc - -# sst -.sst diff --git a/examples/aws-swift/Package.resolved b/examples/aws-swift/Package.resolved deleted file mode 100644 index cdd70ce01d..0000000000 --- a/examples/aws-swift/Package.resolved +++ /dev/null @@ -1,69 +0,0 @@ -{ - "originHash" : "3450710b2977c7d009c49e0f4520bf340c82a58cf41f2fbcfa9012df78a27936", - "pins" : [ - { - "identity" : "swift-atomics", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-atomics.git", - "state" : { - "revision" : "cd142fd2f64be2100422d658e7411e39489da985", - "version" : "1.2.0" - } - }, - { - "identity" : "swift-aws-lambda-events", - "kind" : "remoteSourceControl", - "location" : "https://github.com/swift-server/swift-aws-lambda-events.git", - "state" : { - "branch" : "main", - "revision" : "5b4633d1cc511a179ace6793d45fb973232b2c6c" - } - }, - { - "identity" : "swift-aws-lambda-runtime", - "kind" : "remoteSourceControl", - "location" : "https://github.com/swift-server/swift-aws-lambda-runtime.git", - "state" : { - "branch" : "main", - "revision" : "e6a59c2cf0f35740d4ea72a702f69e45c20a974d" - } - }, - { - "identity" : "swift-collections", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-collections.git", - "state" : { - "revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb", - "version" : "1.1.0" - } - }, - { - "identity" : "swift-log", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-log.git", - "state" : { - "revision" : "e97a6fcb1ab07462881ac165fdbb37f067e205d5", - "version" : "1.5.4" - } - }, - { - "identity" : "swift-nio", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-nio.git", - "state" : { - "revision" : "fc63f0cf4e55a4597407a9fc95b16a2bc44b4982", - "version" : "2.64.0" - } - }, - { - "identity" : "swift-system", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-system.git", - "state" : { - "revision" : "025bcb1165deab2e20d4eaba79967ce73013f496", - "version" : "1.2.1" - } - } - ], - "version" : 3 -} diff --git a/examples/aws-swift/Package.swift b/examples/aws-swift/Package.swift deleted file mode 100644 index 00ce5fb110..0000000000 --- a/examples/aws-swift/Package.swift +++ /dev/null @@ -1,23 +0,0 @@ -// swift-tools-version: 5.10 - -import PackageDescription - -let package = Package( - name: "swift", - platforms: [ - .macOS(.v14) - ], - dependencies: [ - .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "main"), - .package(url: "https://github.com/swift-server/swift-aws-lambda-events.git", branch: "main"), - ], - targets: [ - .executableTarget( - name: "app", - dependencies: [ - .product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"), - .product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events"), - ] - ) - ] -) diff --git a/examples/aws-swift/Sources/App.swift b/examples/aws-swift/Sources/App.swift deleted file mode 100644 index 0ca9f498f3..0000000000 --- a/examples/aws-swift/Sources/App.swift +++ /dev/null @@ -1,15 +0,0 @@ -import AWSLambdaEvents -import AWSLambdaRuntime - -@main -struct App: SimpleLambdaHandler { - func handle( - _ event: APIGatewayV2Request, context: LambdaContext - ) async throws -> APIGatewayV2Response { - .init( - statusCode: .ok, - headers: ["Content-Type": "text/plain"], - body: "Hello, Swift" - ) - } -} diff --git a/examples/aws-swift/sst.config.ts b/examples/aws-swift/sst.config.ts deleted file mode 100644 index 7ed8591bfd..0000000000 --- a/examples/aws-swift/sst.config.ts +++ /dev/null @@ -1,51 +0,0 @@ -/// - -const swiftVersion = "5.10"; - -/** - * ## Swift in Lambda - * - * Deploys a simple Swift application to Lambda using the `al2023` runtime. - * - * :::note - * Building this function requires Docker. - * ::: - * - * Check out the README in the repo for more details. - */ -export default $config({ - app(input) { - return { - name: "aws-swift", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const swift = new sst.aws.Function("Swift", { - runtime: "provided.al2023", - architecture: process.arch === "arm64" ? "arm64" : "x86_64", - bundle: build("app"), - handler: "bootstrap", - url: true, - }); - const router = new sst.aws.Router("SwiftRouter", { - routes: { - "/*": swift.url, - }, - domain: "swift.dev.sst.dev", - }); - return { - url: router.url, - }; - }, -}); - -function build(target: string) { - require("child_process").execSync(` - swift package --disable-sandbox archive --products ${target} --swift-version ${swiftVersion} - mkdir -p .build/lambda/${target} - cp .build/release/${target} .build/lambda/${target}/bootstrap - `); - return `.build/lambda/${target}`; -} diff --git a/examples/aws-t3/.eslintrc.cjs b/examples/aws-t3/.eslintrc.cjs deleted file mode 100644 index 88c180dda5..0000000000 --- a/examples/aws-t3/.eslintrc.cjs +++ /dev/null @@ -1,61 +0,0 @@ -/** @type {import("eslint").Linter.Config} */ -const config = { - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": true - }, - "plugins": [ - "@typescript-eslint", - "drizzle" - ], - "extends": [ - "next/core-web-vitals", - "plugin:@typescript-eslint/recommended-type-checked", - "plugin:@typescript-eslint/stylistic-type-checked" - ], - "rules": { - "@typescript-eslint/array-type": "off", - "@typescript-eslint/consistent-type-definitions": "off", - "@typescript-eslint/consistent-type-imports": [ - "warn", - { - "prefer": "type-imports", - "fixStyle": "inline-type-imports" - } - ], - "@typescript-eslint/no-unused-vars": [ - "warn", - { - "argsIgnorePattern": "^_" - } - ], - "@typescript-eslint/require-await": "off", - "@typescript-eslint/no-misused-promises": [ - "error", - { - "checksVoidReturn": { - "attributes": false - } - } - ], - "drizzle/enforce-delete-with-where": [ - "error", - { - "drizzleObjectName": [ - "db", - "ctx.db" - ] - } - ], - "drizzle/enforce-update-with-where": [ - "error", - { - "drizzleObjectName": [ - "db", - "ctx.db" - ] - } - ] - } -} -module.exports = config; \ No newline at end of file diff --git a/examples/aws-t3/.gitignore b/examples/aws-t3/.gitignore deleted file mode 100644 index 9b3f2f5fbc..0000000000 --- a/examples/aws-t3/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# database -/prisma/db.sqlite -/prisma/db.sqlite-journal -db.sqlite - -# next.js -/.next/ -/out/ -next-env.d.ts - -# production -/build - -# misc -.DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* -.pnpm-debug.log* - -# local env files -# do not commit any .env files to git, except for the .env.example file. https://create.t3.gg/en/usage/env-variables#using-environment-variables -.env -.env*.local - -# vercel -.vercel - -# typescript -*.tsbuildinfo - -# idea files -.idea - -# sst -.sst - - -# open-next -.open-next diff --git a/examples/aws-t3/drizzle.config.ts b/examples/aws-t3/drizzle.config.ts deleted file mode 100644 index d66cca49e1..0000000000 --- a/examples/aws-t3/drizzle.config.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Resource } from "sst"; -import { type Config } from "drizzle-kit"; - -export default { - schema: "./src/server/db/schema.ts", - dialect: "postgresql", - dbCredentials: { - ssl: { - rejectUnauthorized: false, - }, - host: Resource.MyPostgres.host, - port: Resource.MyPostgres.port, - user: Resource.MyPostgres.username, - password: Resource.MyPostgres.password, - database: Resource.MyPostgres.database, - }, - tablesFilter: ["aws-t3_*"], -} satisfies Config; diff --git a/examples/aws-t3/next.config.js b/examples/aws-t3/next.config.js deleted file mode 100644 index 9bfe4a0e2a..0000000000 --- a/examples/aws-t3/next.config.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful - * for Docker builds. - */ -await import("./src/env.js"); - -/** @type {import("next").NextConfig} */ -const config = {}; - -export default config; diff --git a/examples/aws-t3/package.json b/examples/aws-t3/package.json deleted file mode 100644 index 101bfcffd5..0000000000 --- a/examples/aws-t3/package.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "aws-t3", - "version": "0.1.0", - "private": true, - "type": "module", - "scripts": { - "build": "next build", - "db:generate": "sst shell drizzle-kit generate", - "db:migrate": "sst shell drizzle-kit migrate", - "db:push": "sst shell drizzle-kit push", - "db:studio": "sst shell drizzle-kit studio", - "dev": "next dev", - "lint": "next lint", - "start": "next start" - }, - "dependencies": { - "@t3-oss/env-nextjs": "^0.10.1", - "@tanstack/react-query": "^5.50.0", - "@trpc/client": "^11.0.0-rc.446", - "@trpc/react-query": "^11.0.0-rc.446", - "@trpc/server": "^11.0.0-rc.446", - "drizzle-orm": "^0.35.1", - "geist": "^1.3.0", - "next": "^14.2.4", - "pg": "^8.13.1", - "postgres": "^3.4.4", - "react": "^18.3.1", - "react-dom": "^18.3.1", - "server-only": "^0.0.1", - "sst": "file:../../sdk/js", - "superjson": "^2.2.1", - "zod": "^3.23.3" - }, - "devDependencies": { - "@types/eslint": "^8.56.10", - "@types/node": "^20.14.10", - "@types/pg": "^8.11.10", - "@types/react": "^18.3.3", - "@types/react-dom": "^18.3.0", - "@typescript-eslint/eslint-plugin": "^8.1.0", - "@typescript-eslint/parser": "^8.1.0", - "drizzle-kit": "^0.26.2", - "eslint": "^8.57.0", - "eslint-config-next": "^14.2.4", - "eslint-plugin-drizzle": "^0.2.3", - "postcss": "^8.4.39", - "prettier": "^3.3.2", - "prettier-plugin-tailwindcss": "^0.6.5", - "tailwindcss": "^3.4.3", - "typescript": "^5.5.3" - }, - "ct3aMetadata": { - "initVersion": "7.37.0" - }, - "packageManager": "npm@10.2.4" -} diff --git a/examples/aws-t3/postcss.config.cjs b/examples/aws-t3/postcss.config.cjs deleted file mode 100644 index 4cdb2f430f..0000000000 --- a/examples/aws-t3/postcss.config.cjs +++ /dev/null @@ -1,7 +0,0 @@ -const config = { - plugins: { - tailwindcss: {}, - }, -}; - -module.exports = config; diff --git a/examples/aws-t3/prettier.config.js b/examples/aws-t3/prettier.config.js deleted file mode 100644 index b2d59b460f..0000000000 --- a/examples/aws-t3/prettier.config.js +++ /dev/null @@ -1,6 +0,0 @@ -/** @type {import('prettier').Config & import('prettier-plugin-tailwindcss').PluginOptions} */ -const config = { - plugins: ["prettier-plugin-tailwindcss"], -}; - -export default config; diff --git a/examples/aws-t3/public/favicon.ico b/examples/aws-t3/public/favicon.ico deleted file mode 100644 index 60c702aac1..0000000000 Binary files a/examples/aws-t3/public/favicon.ico and /dev/null differ diff --git a/examples/aws-t3/src/app/_components/post.tsx b/examples/aws-t3/src/app/_components/post.tsx deleted file mode 100644 index ebe15eab4a..0000000000 --- a/examples/aws-t3/src/app/_components/post.tsx +++ /dev/null @@ -1,50 +0,0 @@ -"use client"; - -import { useState } from "react"; - -import { api } from "~/trpc/react"; - -export function LatestPost() { - const [latestPost] = api.post.getLatest.useSuspenseQuery(); - - const utils = api.useUtils(); - const [name, setName] = useState(""); - const createPost = api.post.create.useMutation({ - onSuccess: async () => { - await utils.post.invalidate(); - setName(""); - }, - }); - - return ( -
- {latestPost ? ( -

Your most recent post: {latestPost.name}

- ) : ( -

You have no posts yet.

- )} -
{ - e.preventDefault(); - createPost.mutate({ name }); - }} - className="flex flex-col gap-2" - > - setName(e.target.value)} - className="w-full rounded-full px-4 py-2 text-black" - /> - -
-
- ); -} diff --git a/examples/aws-t3/src/app/api/trpc/[trpc]/route.ts b/examples/aws-t3/src/app/api/trpc/[trpc]/route.ts deleted file mode 100644 index 5fbd827d90..0000000000 --- a/examples/aws-t3/src/app/api/trpc/[trpc]/route.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { fetchRequestHandler } from "@trpc/server/adapters/fetch"; -import { type NextRequest } from "next/server"; - -import { env } from "~/env"; -import { appRouter } from "~/server/api/root"; -import { createTRPCContext } from "~/server/api/trpc"; - -/** - * This wraps the `createTRPCContext` helper and provides the required context for the tRPC API when - * handling a HTTP request (e.g. when you make requests from Client Components). - */ -const createContext = async (req: NextRequest) => { - return createTRPCContext({ - headers: req.headers, - }); -}; - -const handler = (req: NextRequest) => - fetchRequestHandler({ - endpoint: "/api/trpc", - req, - router: appRouter, - createContext: () => createContext(req), - onError: - env.NODE_ENV === "development" - ? ({ path, error }) => { - console.error( - `❌ tRPC failed on ${path ?? ""}: ${error.message}` - ); - } - : undefined, - }); - -export { handler as GET, handler as POST }; diff --git a/examples/aws-t3/src/app/layout.tsx b/examples/aws-t3/src/app/layout.tsx deleted file mode 100644 index c2215fff12..0000000000 --- a/examples/aws-t3/src/app/layout.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import "~/styles/globals.css"; - -import { GeistSans } from "geist/font/sans"; -import { type Metadata } from "next"; - -import { TRPCReactProvider } from "~/trpc/react"; - -export const metadata: Metadata = { - title: "Create T3 App", - description: "Generated by create-t3-app", - icons: [{ rel: "icon", url: "/favicon.ico" }], -}; - -export default function RootLayout({ - children, -}: Readonly<{ children: React.ReactNode }>) { - return ( - - - {children} - - - ); -} diff --git a/examples/aws-t3/src/app/page.tsx b/examples/aws-t3/src/app/page.tsx deleted file mode 100644 index d7121d83d6..0000000000 --- a/examples/aws-t3/src/app/page.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import Link from "next/link"; - -import { LatestPost } from "~/app/_components/post"; -import { api, HydrateClient } from "~/trpc/server"; - -export default async function Home() { - const hello = await api.post.hello({ text: "from tRPC" }); - - void api.post.getLatest.prefetch(); - - return ( - -
-
-

- Create T3 App -

-
- -

First Steps →

-
- Just the basics - Everything you need to know to set up your - database and authentication. -
- - -

Documentation →

-
- Learn more about Create T3 App, the libraries it uses, and how - to deploy it. -
- -
-
-

- {hello ? hello.greeting : "Loading tRPC query..."} -

-
- - -
-
-
- ); -} diff --git a/examples/aws-t3/src/env.js b/examples/aws-t3/src/env.js deleted file mode 100644 index c884758c63..0000000000 --- a/examples/aws-t3/src/env.js +++ /dev/null @@ -1,44 +0,0 @@ -import { createEnv } from "@t3-oss/env-nextjs"; -import { z } from "zod"; - -export const env = createEnv({ - /** - * Specify your server-side environment variables schema here. This way you can ensure the app - * isn't built with invalid env vars. - */ - server: { - // DATABASE_URL: z.string().url(), - NODE_ENV: z - .enum(["development", "test", "production"]) - .default("development"), - }, - - /** - * Specify your client-side environment variables schema here. This way you can ensure the app - * isn't built with invalid env vars. To expose them to the client, prefix them with - * `NEXT_PUBLIC_`. - */ - client: { - // NEXT_PUBLIC_CLIENTVAR: z.string(), - }, - - /** - * You can't destruct `process.env` as a regular object in the Next.js edge runtimes (e.g. - * middlewares) or client-side so we need to destruct manually. - */ - runtimeEnv: { - // DATABASE_URL: process.env.DATABASE_URL, - NODE_ENV: process.env.NODE_ENV, - // NEXT_PUBLIC_CLIENTVAR: process.env.NEXT_PUBLIC_CLIENTVAR, - }, - /** - * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially - * useful for Docker builds. - */ - skipValidation: !!process.env.SKIP_ENV_VALIDATION, - /** - * Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and - * `SOME_VAR=''` will throw an error. - */ - emptyStringAsUndefined: true, -}); diff --git a/examples/aws-t3/src/server/api/root.ts b/examples/aws-t3/src/server/api/root.ts deleted file mode 100644 index b341fc4d64..0000000000 --- a/examples/aws-t3/src/server/api/root.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { postRouter } from "~/server/api/routers/post"; -import { createCallerFactory, createTRPCRouter } from "~/server/api/trpc"; - -/** - * This is the primary router for your server. - * - * All routers added in /api/routers should be manually added here. - */ -export const appRouter = createTRPCRouter({ - post: postRouter, -}); - -// export type definition of API -export type AppRouter = typeof appRouter; - -/** - * Create a server-side caller for the tRPC API. - * @example - * const trpc = createCaller(createContext); - * const res = await trpc.post.all(); - * ^? Post[] - */ -export const createCaller = createCallerFactory(appRouter); diff --git a/examples/aws-t3/src/server/api/routers/post.ts b/examples/aws-t3/src/server/api/routers/post.ts deleted file mode 100644 index 4bbf615b31..0000000000 --- a/examples/aws-t3/src/server/api/routers/post.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { z } from "zod"; - -import { createTRPCRouter, publicProcedure } from "~/server/api/trpc"; -import { posts } from "~/server/db/schema"; - -export const postRouter = createTRPCRouter({ - hello: publicProcedure - .input(z.object({ text: z.string() })) - .query(({ input }) => { - return { - greeting: `Hello ${input.text}`, - }; - }), - - create: publicProcedure - .input(z.object({ name: z.string().min(1) })) - .mutation(async ({ ctx, input }) => { - await ctx.db.insert(posts).values({ - name: input.name, - }); - }), - - getLatest: publicProcedure.query(async ({ ctx }) => { - const post = await ctx.db.query.posts.findFirst({ - orderBy: (posts, { desc }) => [desc(posts.createdAt)], - }); - - return post ?? null; - }), -}); diff --git a/examples/aws-t3/src/server/api/trpc.ts b/examples/aws-t3/src/server/api/trpc.ts deleted file mode 100644 index 4e24ba4373..0000000000 --- a/examples/aws-t3/src/server/api/trpc.ts +++ /dev/null @@ -1,106 +0,0 @@ -/** - * YOU PROBABLY DON'T NEED TO EDIT THIS FILE, UNLESS: - * 1. You want to modify request context (see Part 1). - * 2. You want to create a new middleware or type of procedure (see Part 3). - * - * TL;DR - This is where all the tRPC server stuff is created and plugged in. The pieces you will - * need to use are documented accordingly near the end. - */ -import { initTRPC } from "@trpc/server"; -import superjson from "superjson"; -import { ZodError } from "zod"; - -import { db } from "~/server/db"; - -/** - * 1. CONTEXT - * - * This section defines the "contexts" that are available in the backend API. - * - * These allow you to access things when processing a request, like the database, the session, etc. - * - * This helper generates the "internals" for a tRPC context. The API handler and RSC clients each - * wrap this and provides the required context. - * - * @see https://trpc.io/docs/server/context - */ -export const createTRPCContext = async (opts: { headers: Headers }) => { - return { - db, - ...opts, - }; -}; - -/** - * 2. INITIALIZATION - * - * This is where the tRPC API is initialized, connecting the context and transformer. We also parse - * ZodErrors so that you get typesafety on the frontend if your procedure fails due to validation - * errors on the backend. - */ -const t = initTRPC.context().create({ - transformer: superjson, - errorFormatter({ shape, error }) { - return { - ...shape, - data: { - ...shape.data, - zodError: - error.cause instanceof ZodError ? error.cause.flatten() : null, - }, - }; - }, -}); - -/** - * Create a server-side caller. - * - * @see https://trpc.io/docs/server/server-side-calls - */ -export const createCallerFactory = t.createCallerFactory; - -/** - * 3. ROUTER & PROCEDURE (THE IMPORTANT BIT) - * - * These are the pieces you use to build your tRPC API. You should import these a lot in the - * "/src/server/api/routers" directory. - */ - -/** - * This is how you create new routers and sub-routers in your tRPC API. - * - * @see https://trpc.io/docs/router - */ -export const createTRPCRouter = t.router; - -/** - * Middleware for timing procedure execution and adding an artificial delay in development. - * - * You can remove this if you don't like it, but it can help catch unwanted waterfalls by simulating - * network latency that would occur in production but not in local development. - */ -const timingMiddleware = t.middleware(async ({ next, path }) => { - const start = Date.now(); - - if (t._config.isDev) { - // artificial delay in dev - const waitMs = Math.floor(Math.random() * 400) + 100; - await new Promise((resolve) => setTimeout(resolve, waitMs)); - } - - const result = await next(); - - const end = Date.now(); - console.log(`[TRPC] ${path} took ${end - start}ms to execute`); - - return result; -}); - -/** - * Public (unauthenticated) procedure - * - * This is the base piece you use to build new queries and mutations on your tRPC API. It does not - * guarantee that a user querying is authorized, but you can still access user session data if they - * are logged in. - */ -export const publicProcedure = t.procedure.use(timingMiddleware); diff --git a/examples/aws-t3/src/server/db/index.ts b/examples/aws-t3/src/server/db/index.ts deleted file mode 100644 index 580dbfc0ff..0000000000 --- a/examples/aws-t3/src/server/db/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Pool } from "pg"; -import { Resource } from "sst"; -import { drizzle } from "drizzle-orm/node-postgres"; - -import * as schema from "./schema"; - -const pool = new Pool({ - host: Resource.MyPostgres.host, - port: Resource.MyPostgres.port, - user: Resource.MyPostgres.username, - password: Resource.MyPostgres.password, - database: Resource.MyPostgres.database, -}); - -export const db = drizzle(pool, { schema }); diff --git a/examples/aws-t3/src/server/db/schema.ts b/examples/aws-t3/src/server/db/schema.ts deleted file mode 100644 index 19ffe2a0c7..0000000000 --- a/examples/aws-t3/src/server/db/schema.ts +++ /dev/null @@ -1,36 +0,0 @@ -// Example model schema from the Drizzle docs -// https://orm.drizzle.team/docs/sql-schema-declaration - -import { sql } from "drizzle-orm"; -import { - index, - pgTableCreator, - serial, - timestamp, - varchar, -} from "drizzle-orm/pg-core"; - -/** - * This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same - * database instance for multiple projects. - * - * @see https://orm.drizzle.team/docs/goodies#multi-project-schema - */ -export const createTable = pgTableCreator((name) => `aws-t3_${name}`); - -export const posts = createTable( - "post", - { - id: serial("id").primaryKey(), - name: varchar("name", { length: 256 }), - createdAt: timestamp("created_at", { withTimezone: true }) - .default(sql`CURRENT_TIMESTAMP`) - .notNull(), - updatedAt: timestamp("updated_at", { withTimezone: true }).$onUpdate( - () => new Date() - ), - }, - (example) => ({ - nameIndex: index("name_idx").on(example.name), - }) -); diff --git a/examples/aws-t3/src/styles/globals.css b/examples/aws-t3/src/styles/globals.css deleted file mode 100644 index b5c61c9567..0000000000 --- a/examples/aws-t3/src/styles/globals.css +++ /dev/null @@ -1,3 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; diff --git a/examples/aws-t3/src/trpc/query-client.ts b/examples/aws-t3/src/trpc/query-client.ts deleted file mode 100644 index bda64397ca..0000000000 --- a/examples/aws-t3/src/trpc/query-client.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { - defaultShouldDehydrateQuery, - QueryClient, -} from "@tanstack/react-query"; -import SuperJSON from "superjson"; - -export const createQueryClient = () => - new QueryClient({ - defaultOptions: { - queries: { - // With SSR, we usually want to set some default staleTime - // above 0 to avoid refetching immediately on the client - staleTime: 30 * 1000, - }, - dehydrate: { - serializeData: SuperJSON.serialize, - shouldDehydrateQuery: (query) => - defaultShouldDehydrateQuery(query) || - query.state.status === "pending", - }, - hydrate: { - deserializeData: SuperJSON.deserialize, - }, - }, - }); diff --git a/examples/aws-t3/src/trpc/react.tsx b/examples/aws-t3/src/trpc/react.tsx deleted file mode 100644 index 8c0521a74e..0000000000 --- a/examples/aws-t3/src/trpc/react.tsx +++ /dev/null @@ -1,76 +0,0 @@ -"use client"; - -import { QueryClientProvider, type QueryClient } from "@tanstack/react-query"; -import { loggerLink, unstable_httpBatchStreamLink } from "@trpc/client"; -import { createTRPCReact } from "@trpc/react-query"; -import { type inferRouterInputs, type inferRouterOutputs } from "@trpc/server"; -import { useState } from "react"; -import SuperJSON from "superjson"; - -import { type AppRouter } from "~/server/api/root"; -import { createQueryClient } from "./query-client"; - -let clientQueryClientSingleton: QueryClient | undefined = undefined; -const getQueryClient = () => { - if (typeof window === "undefined") { - // Server: always make a new query client - return createQueryClient(); - } - // Browser: use singleton pattern to keep the same query client - return (clientQueryClientSingleton ??= createQueryClient()); -}; - -export const api = createTRPCReact(); - -/** - * Inference helper for inputs. - * - * @example type HelloInput = RouterInputs['example']['hello'] - */ -export type RouterInputs = inferRouterInputs; - -/** - * Inference helper for outputs. - * - * @example type HelloOutput = RouterOutputs['example']['hello'] - */ -export type RouterOutputs = inferRouterOutputs; - -export function TRPCReactProvider(props: { children: React.ReactNode }) { - const queryClient = getQueryClient(); - - const [trpcClient] = useState(() => - api.createClient({ - links: [ - loggerLink({ - enabled: (op) => - process.env.NODE_ENV === "development" || - (op.direction === "down" && op.result instanceof Error), - }), - unstable_httpBatchStreamLink({ - transformer: SuperJSON, - url: getBaseUrl() + "/api/trpc", - headers: () => { - const headers = new Headers(); - headers.set("x-trpc-source", "nextjs-react"); - return headers; - }, - }), - ], - }) - ); - - return ( - - - {props.children} - - - ); -} - -function getBaseUrl() { - if (typeof window !== "undefined") return window.location.origin; - if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}`; - return `http://localhost:${process.env.PORT ?? 3000}`; -} diff --git a/examples/aws-t3/src/trpc/server.ts b/examples/aws-t3/src/trpc/server.ts deleted file mode 100644 index 59300a638b..0000000000 --- a/examples/aws-t3/src/trpc/server.ts +++ /dev/null @@ -1,30 +0,0 @@ -import "server-only"; - -import { createHydrationHelpers } from "@trpc/react-query/rsc"; -import { headers } from "next/headers"; -import { cache } from "react"; - -import { createCaller, type AppRouter } from "~/server/api/root"; -import { createTRPCContext } from "~/server/api/trpc"; -import { createQueryClient } from "./query-client"; - -/** - * This wraps the `createTRPCContext` helper and provides the required context for the tRPC API when - * handling a tRPC call from a React Server Component. - */ -const createContext = cache(() => { - const heads = new Headers(headers()); - heads.set("x-trpc-source", "rsc"); - - return createTRPCContext({ - headers: heads, - }); -}); - -const getQueryClient = cache(createQueryClient); -const caller = createCaller(createContext); - -export const { trpc: api, HydrateClient } = createHydrationHelpers( - caller, - getQueryClient -); diff --git a/examples/aws-t3/sst.config.ts b/examples/aws-t3/sst.config.ts deleted file mode 100644 index 240886315c..0000000000 --- a/examples/aws-t3/sst.config.ts +++ /dev/null @@ -1,145 +0,0 @@ -/// - -/** - * ## T3 Stack in AWS - * - * Deploy [T3 stack](https://create.t3.gg) with Drizzle and Postgres to AWS. - * - * This example was created using `create-t3-app` and the following options: tRPC, Drizzle, - * no auth, Tailwind, Postgres, and the App Router. - * - * Instead of a local database, we'll be using an RDS Postgres database. - * - * ```ts title="src/server/db/index.ts" {2-6} - * const pool = new Pool({ - * host: Resource.MyPostgres.host, - * port: Resource.MyPostgres.port, - * user: Resource.MyPostgres.username, - * password: Resource.MyPostgres.password, - * database: Resource.MyPostgres.database, - * }); - * ``` - * - * Similarly, for Drizzle Kit. - * - * ```ts title="drizzle.config.ts" {8-12} - * export default { - * schema: "./src/server/db/schema.ts", - * dialect: "postgresql", - * dbCredentials: { - * ssl: { - * rejectUnauthorized: false, - * }, - * host: Resource.MyPostgres.host, - * port: Resource.MyPostgres.port, - * user: Resource.MyPostgres.username, - * password: Resource.MyPostgres.password, - * database: Resource.MyPostgres.database, - * }, - * tablesFilter: ["aws-t3_*"], - * } satisfies Config; - * ``` - * - * In our Next.js app we can access our Postgres database because we [link them](/docs/linking/) - * both. We don't need to use our `.env` files. - * - * ```ts title="sst.config.ts" {5} - * const rds = new sst.aws.Postgres("MyPostgres", { vpc, proxy: true }); - * - * new sst.aws.Nextjs("MyWeb", { - * vpc, - * link: [rds] - * }); - * ``` - * - * To run this in dev mode run: - * - * ```bash - * npm install - * npx sst dev - * ``` - * - * It'll take a few minutes to deploy the database and the VPC. - * - * This also starts a tunnel to let your local machine connect to the RDS Postgres database. - * Make sure you have it installed, you only need to do this once for your local machine. - * - * ```bash - * sudo npx sst tunnel install - * ``` - * - * Now in a new terminal you can run the database migrations. - * - * ```bash - * npm run db:push - * ``` - * - * We also have the Drizzle Studio start automatically in dev mode under the **Studio** tab. - * - * ```ts title="sst.config.ts" - * new sst.x.DevCommand("Studio", { - * link: [rds], - * dev: { - * command: "npx drizzle-kit studio", - * }, - * }); - * ``` - * - * And to make sure our credentials are available, we update our `package.json` - * with the [`sst shell`](/docs/reference/cli) CLI. - * - * ```json title="package.json" - * "db:generate": "sst shell drizzle-kit generate", - * "db:migrate": "sst shell drizzle-kit migrate", - * "db:push": "sst shell drizzle-kit push", - * "db:studio": "sst shell drizzle-kit studio", - * ``` - * - * So running `npm run db:push` will run Drizzle Kit with the right credentials. - * - * To deploy this to production run: - * - * ```bash - * npx sst deploy --stage production - * ``` - * - * Then run the migrations. - * - * ```bash - * npx sst shell --stage production npx drizzle-kit push - * ``` - * - * If you are running this locally, you'll need to have a tunnel running. - * - * ```bash - * npx sst tunnel --stage production - * ``` - * - * If you are doing this in a CI/CD pipeline, you'd want your build containers to be in the - * same VPC. - */ -export default $config({ - app(input) { - return { - name: "aws-t3", - removal: input?.stage === "production" ? "retain" : "remove", - home: "aws", - }; - }, - async run() { - const vpc = new sst.aws.Vpc("MyVpc", { bastion: true, nat: "ec2" }); - const rds = new sst.aws.Postgres("MyPostgres", { vpc, proxy: true }); - - new sst.aws.Nextjs("MyWeb", { - vpc, - link: [rds] - }); - - new sst.x.DevCommand("Studio", { - link: [rds], - dev: { - command: "npx drizzle-kit studio", - }, - }); - }, -}); diff --git a/examples/aws-t3/start-database.sh b/examples/aws-t3/start-database.sh deleted file mode 100755 index 610f54b3f5..0000000000 --- a/examples/aws-t3/start-database.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bash -# Use this script to start a docker container for a local development database - -# TO RUN ON WINDOWS: -# 1. Install WSL (Windows Subsystem for Linux) - https://learn.microsoft.com/en-us/windows/wsl/install -# 2. Install Docker Desktop for Windows - https://docs.docker.com/docker-for-windows/install/ -# 3. Open WSL - `wsl` -# 4. Run this script - `./start-database.sh` - -# On Linux and macOS you can run this script directly - `./start-database.sh` - -DB_CONTAINER_NAME="aws-t3-postgres" - -if ! [ -x "$(command -v docker)" ]; then - echo -e "Docker is not installed. Please install docker and try again.\nDocker install guide: https://docs.docker.com/engine/install/" - exit 1 -fi - -if [ "$(docker ps -q -f name=$DB_CONTAINER_NAME)" ]; then - echo "Database container '$DB_CONTAINER_NAME' already running" - exit 0 -fi - -if [ "$(docker ps -q -a -f name=$DB_CONTAINER_NAME)" ]; then - docker start "$DB_CONTAINER_NAME" - echo "Existing database container '$DB_CONTAINER_NAME' started" - exit 0 -fi - -# import env variables from .env -set -a -source .env - -DB_PASSWORD=$(echo "$DATABASE_URL" | awk -F':' '{print $3}' | awk -F'@' '{print $1}') -DB_PORT=$(echo "$DATABASE_URL" | awk -F':' '{print $4}' | awk -F'\/' '{print $1}') - -if [ "$DB_PASSWORD" = "password" ]; then - echo "You are using the default database password" - read -p "Should we generate a random password for you? [y/N]: " -r REPLY - if ! [[ $REPLY =~ ^[Yy]$ ]]; then - echo "Please change the default password in the .env file and try again" - exit 1 - fi - # Generate a random URL-safe password - DB_PASSWORD=$(openssl rand -base64 12 | tr '+/' '-_') - sed -i -e "s#:password@#:$DB_PASSWORD@#" .env -fi - -docker run -d \ - --name $DB_CONTAINER_NAME \ - -e POSTGRES_USER="postgres" \ - -e POSTGRES_PASSWORD="$DB_PASSWORD" \ - -e POSTGRES_DB=aws-t3 \ - -p "$DB_PORT":5432 \ - docker.io/postgres && echo "Database container '$DB_CONTAINER_NAME' was successfully created" diff --git a/examples/aws-t3/tailwind.config.ts b/examples/aws-t3/tailwind.config.ts deleted file mode 100644 index 5fd44e8f23..0000000000 --- a/examples/aws-t3/tailwind.config.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { type Config } from "tailwindcss"; -import { fontFamily } from "tailwindcss/defaultTheme"; - -export default { - content: ["./src/**/*.tsx"], - theme: { - extend: { - fontFamily: { - sans: ["var(--font-geist-sans)", ...fontFamily.sans], - }, - }, - }, - plugins: [], -} satisfies Config; diff --git a/examples/aws-t3/tsconfig.json b/examples/aws-t3/tsconfig.json deleted file mode 100644 index ba905904d9..0000000000 --- a/examples/aws-t3/tsconfig.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "compilerOptions": { - /* Base Options: */ - "esModuleInterop": true, - "skipLibCheck": true, - "target": "es2022", - "allowJs": true, - "resolveJsonModule": true, - "moduleDetection": "force", - "isolatedModules": true, - - /* Strictness */ - "strict": true, - "noUncheckedIndexedAccess": true, - "checkJs": true, - - /* Bundled projects */ - "lib": ["dom", "dom.iterable", "ES2022"], - "noEmit": true, - "module": "ESNext", - "moduleResolution": "Bundler", - "jsx": "preserve", - "plugins": [{ "name": "next" }], - "incremental": true, - - /* Path Aliases */ - "baseUrl": ".", - "paths": { - "~/*": ["./src/*"] - } - }, - "include": [ - ".eslintrc.cjs", - "next-env.d.ts", - "**/*.ts", - "**/*.tsx", - "**/*.cjs", - "**/*.js", - ".next/types/**/*.ts" - ], - "exclude": ["node_modules","sst.config.ts"] -} diff --git a/examples/aws-tanstack-start/.cta.json b/examples/aws-tanstack-start/.cta.json deleted file mode 100644 index 82493fe963..0000000000 --- a/examples/aws-tanstack-start/.cta.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "projectName": "app", - "mode": "file-router", - "typescript": true, - "tailwind": true, - "packageManager": "pnpm", - "addOnOptions": {}, - "git": true, - "version": 1, - "framework": "react-cra", - "chosenAddOns": [ - "eslint", - "nitro", - "start", - "form", - "shadcn", - "tanstack-query" - ] -} \ No newline at end of file diff --git a/examples/aws-tanstack-start/.cursorrules b/examples/aws-tanstack-start/.cursorrules deleted file mode 100644 index 1472639b19..0000000000 --- a/examples/aws-tanstack-start/.cursorrules +++ /dev/null @@ -1,7 +0,0 @@ -# shadcn instructions - -Use the latest version of Shadcn to install new components, like this command to add a button component: - -```bash -pnpx shadcn@latest add button -``` diff --git a/examples/aws-tanstack-start/.gitignore b/examples/aws-tanstack-start/.gitignore deleted file mode 100644 index b4687f1d19..0000000000 --- a/examples/aws-tanstack-start/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -.sst -node_modules -.DS_Store -dist -dist-ssr -*.local -count.txt -.env -.nitro -.tanstack -.wrangler -.output -.vinxi -todos.json diff --git a/examples/aws-tanstack-start/.prettierignore b/examples/aws-tanstack-start/.prettierignore deleted file mode 100644 index 5322d7feea..0000000000 --- a/examples/aws-tanstack-start/.prettierignore +++ /dev/null @@ -1,3 +0,0 @@ -package-lock.json -pnpm-lock.yaml -yarn.lock \ No newline at end of file diff --git a/examples/aws-tanstack-start/.vscode/settings.json b/examples/aws-tanstack-start/.vscode/settings.json deleted file mode 100644 index 00b5278e58..0000000000 --- a/examples/aws-tanstack-start/.vscode/settings.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "files.watcherExclude": { - "**/routeTree.gen.ts": true - }, - "search.exclude": { - "**/routeTree.gen.ts": true - }, - "files.readonlyInclude": { - "**/routeTree.gen.ts": true - } -} diff --git a/examples/aws-tanstack-start/components.json b/examples/aws-tanstack-start/components.json deleted file mode 100644 index 6998bdfb97..0000000000 --- a/examples/aws-tanstack-start/components.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "$schema": "https://ui.shadcn.com/schema.json", - "style": "new-york", - "rsc": false, - "tsx": true, - "tailwind": { - "config": "", - "css": "src/styles.css", - "baseColor": "zinc", - "cssVariables": true, - "prefix": "" - }, - "aliases": { - "components": "@/components", - "utils": "@/lib/utils", - "ui": "@/components/ui", - "lib": "@/lib", - "hooks": "@/hooks" - }, - "iconLibrary": "lucide" -} \ No newline at end of file diff --git a/examples/aws-tanstack-start/eslint.config.js b/examples/aws-tanstack-start/eslint.config.js deleted file mode 100644 index 676b32a87f..0000000000 --- a/examples/aws-tanstack-start/eslint.config.js +++ /dev/null @@ -1,5 +0,0 @@ -// @ts-check - -import { tanstackConfig } from '@tanstack/eslint-config' - -export default [...tanstackConfig] diff --git a/examples/aws-tanstack-start/package.json b/examples/aws-tanstack-start/package.json deleted file mode 100644 index 854758a5ea..0000000000 --- a/examples/aws-tanstack-start/package.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "name": "aws-tanstack-start", - "private": true, - "type": "module", - "scripts": { - "dev": "vite dev --port 3000", - "build": "vite build", - "serve": "vite preview", - "test": "vitest run", - "lint": "eslint", - "format": "prettier", - "check": "prettier --write . && eslint --fix" - }, - "dependencies": { - "@radix-ui/react-label": "^2.1.8", - "@radix-ui/react-select": "^2.2.6", - "@radix-ui/react-slider": "^1.3.6", - "@radix-ui/react-slot": "^1.2.4", - "@radix-ui/react-switch": "^1.2.6", - "@tailwindcss/vite": "^4.0.6", - "@tanstack/react-devtools": "^0.7.0", - "@tanstack/react-form": "^1.0.0", - "@tanstack/react-query": "^5.66.5", - "@tanstack/react-query-devtools": "^5.84.2", - "@tanstack/react-router": "^1.132.0", - "@tanstack/react-router-devtools": "^1.132.0", - "@tanstack/react-router-ssr-query": "^1.131.7", - "@tanstack/react-start": "^1.132.0", - "@tanstack/router-plugin": "^1.132.0", - "class-variance-authority": "^0.7.1", - "clsx": "^2.1.1", - "lucide-react": "^0.544.0", - "nitro": "latest", - "react": "^19.2.0", - "react-dom": "^19.2.0", - "sst": "file:../../sdk/js", - "tailwind-merge": "^3.0.2", - "tailwindcss": "^4.0.6", - "tw-animate-css": "^1.3.6", - "vite-tsconfig-paths": "^5.1.4", - "zod": "^4.1.11" - }, - "devDependencies": { - "@tanstack/devtools-vite": "^0.3.11", - "@tanstack/eslint-config": "^0.3.0", - "@testing-library/dom": "^10.4.0", - "@testing-library/react": "^16.2.0", - "@types/node": "^22.10.2", - "@types/react": "^19.2.0", - "@types/react-dom": "^19.2.0", - "@vitejs/plugin-react": "^5.0.4", - "jsdom": "^27.0.0", - "prettier": "^3.5.3", - "typescript": "^5.7.2", - "vite": "^7.1.7", - "vitest": "^3.0.5", - "web-vitals": "^5.1.0" - } -} \ No newline at end of file diff --git a/examples/aws-tanstack-start/prettier.config.js b/examples/aws-tanstack-start/prettier.config.js deleted file mode 100644 index aea1c4804b..0000000000 --- a/examples/aws-tanstack-start/prettier.config.js +++ /dev/null @@ -1,10 +0,0 @@ -// @ts-check - -/** @type {import('prettier').Config} */ -const config = { - semi: false, - singleQuote: true, - trailingComma: "all", -}; - -export default config; diff --git a/examples/aws-tanstack-start/public/favicon.ico b/examples/aws-tanstack-start/public/favicon.ico deleted file mode 100644 index a11777cc47..0000000000 Binary files a/examples/aws-tanstack-start/public/favicon.ico and /dev/null differ diff --git a/examples/aws-tanstack-start/public/logo192.png b/examples/aws-tanstack-start/public/logo192.png deleted file mode 100644 index fc44b0a379..0000000000 Binary files a/examples/aws-tanstack-start/public/logo192.png and /dev/null differ diff --git a/examples/aws-tanstack-start/public/logo512.png b/examples/aws-tanstack-start/public/logo512.png deleted file mode 100644 index a4e47a6545..0000000000 Binary files a/examples/aws-tanstack-start/public/logo512.png and /dev/null differ diff --git a/examples/aws-tanstack-start/public/manifest.json b/examples/aws-tanstack-start/public/manifest.json deleted file mode 100644 index 078ef50116..0000000000 --- a/examples/aws-tanstack-start/public/manifest.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "short_name": "TanStack App", - "name": "Create TanStack App Sample", - "icons": [ - { - "src": "favicon.ico", - "sizes": "64x64 32x32 24x24 16x16", - "type": "image/x-icon" - }, - { - "src": "logo192.png", - "type": "image/png", - "sizes": "192x192" - }, - { - "src": "logo512.png", - "type": "image/png", - "sizes": "512x512" - } - ], - "start_url": ".", - "display": "standalone", - "theme_color": "#000000", - "background_color": "#ffffff" -} diff --git a/examples/aws-tanstack-start/public/robots.txt b/examples/aws-tanstack-start/public/robots.txt deleted file mode 100644 index e9e57dc4d4..0000000000 --- a/examples/aws-tanstack-start/public/robots.txt +++ /dev/null @@ -1,3 +0,0 @@ -# https://www.robotstxt.org/robotstxt.html -User-agent: * -Disallow: diff --git a/examples/aws-tanstack-start/public/tanstack-circle-logo.png b/examples/aws-tanstack-start/public/tanstack-circle-logo.png deleted file mode 100644 index 9db3e67bad..0000000000 Binary files a/examples/aws-tanstack-start/public/tanstack-circle-logo.png and /dev/null differ diff --git a/examples/aws-tanstack-start/public/tanstack-word-logo-white.svg b/examples/aws-tanstack-start/public/tanstack-word-logo-white.svg deleted file mode 100644 index b6ec5086c2..0000000000 --- a/examples/aws-tanstack-start/public/tanstack-word-logo-white.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/examples/aws-tanstack-start/src/components/Header.tsx b/examples/aws-tanstack-start/src/components/Header.tsx deleted file mode 100644 index b6e0cd0d4f..0000000000 --- a/examples/aws-tanstack-start/src/components/Header.tsx +++ /dev/null @@ -1,217 +0,0 @@ -import { Link } from '@tanstack/react-router' - -import { useState } from 'react' -import { - ChevronDown, - ChevronRight, - ClipboardType, - Home, - Menu, - Network, - SquareFunction, - StickyNote, - X, -} from 'lucide-react' - -export default function Header() { - const [isOpen, setIsOpen] = useState(false) - const [groupedExpanded, setGroupedExpanded] = useState< - Record - >({}) - - return ( - <> -
- -

- - TanStack Logo - -

-
- - - - ) -} diff --git a/examples/aws-tanstack-start/src/components/demo.FormComponents.tsx b/examples/aws-tanstack-start/src/components/demo.FormComponents.tsx deleted file mode 100644 index 0419620dff..0000000000 --- a/examples/aws-tanstack-start/src/components/demo.FormComponents.tsx +++ /dev/null @@ -1,174 +0,0 @@ -import { useStore } from '@tanstack/react-form' - -import { useFieldContext, useFormContext } from '@/hooks/demo.form-context' - -import { Button } from '@/components/ui/button' -import { Input } from '@/components/ui/input' -import { Textarea as ShadcnTextarea } from '@/components/ui/textarea' -import * as ShadcnSelect from '@/components/ui/select' -import { Slider as ShadcnSlider } from '@/components/ui/slider' -import { Switch as ShadcnSwitch } from '@/components/ui/switch' -import { Label } from '@/components/ui/label' - -export function SubscribeButton({ label }: { label: string }) { - const form = useFormContext() - return ( - state.isSubmitting}> - {(isSubmitting) => ( - - )} - - ) -} - -function ErrorMessages({ - errors, -}: { - errors: Array -}) { - return ( - <> - {errors.map((error) => ( -
- {typeof error === 'string' ? error : error.message} -
- ))} - - ) -} - -export function TextField({ - label, - placeholder, -}: { - label: string - placeholder?: string -}) { - const field = useFieldContext() - const errors = useStore(field.store, (state) => state.meta.errors) - - return ( -
- - field.handleChange(e.target.value)} - /> - {field.state.meta.isTouched && } -
- ) -} - -export function TextArea({ - label, - rows = 3, -}: { - label: string - rows?: number -}) { - const field = useFieldContext() - const errors = useStore(field.store, (state) => state.meta.errors) - - return ( -
- - field.handleChange(e.target.value)} - /> - {field.state.meta.isTouched && } -
- ) -} - -export function Select({ - label, - values, - placeholder, -}: { - label: string - values: Array<{ label: string; value: string }> - placeholder?: string -}) { - const field = useFieldContext() - const errors = useStore(field.store, (state) => state.meta.errors) - - return ( -
- field.handleChange(value)} - > - - - - - - {label} - {values.map((value) => ( - - {value.label} - - ))} - - - - {field.state.meta.isTouched && } -
- ) -} - -export function Slider({ label }: { label: string }) { - const field = useFieldContext() - const errors = useStore(field.store, (state) => state.meta.errors) - - return ( -
- - field.handleChange(value[0])} - /> - {field.state.meta.isTouched && } -
- ) -} - -export function Switch({ label }: { label: string }) { - const field = useFieldContext() - const errors = useStore(field.store, (state) => state.meta.errors) - - return ( -
-
- field.handleChange(checked)} - /> - -
- {field.state.meta.isTouched && } -
- ) -} diff --git a/examples/aws-tanstack-start/src/components/ui/button.tsx b/examples/aws-tanstack-start/src/components/ui/button.tsx deleted file mode 100644 index 21409a0666..0000000000 --- a/examples/aws-tanstack-start/src/components/ui/button.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import * as React from "react" -import { Slot } from "@radix-ui/react-slot" -import { cva, type VariantProps } from "class-variance-authority" - -import { cn } from "@/lib/utils" - -const buttonVariants = cva( - "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", - { - variants: { - variant: { - default: "bg-primary text-primary-foreground hover:bg-primary/90", - destructive: - "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60", - outline: - "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50", - secondary: - "bg-secondary text-secondary-foreground hover:bg-secondary/80", - ghost: - "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50", - link: "text-primary underline-offset-4 hover:underline", - }, - size: { - default: "h-9 px-4 py-2 has-[>svg]:px-3", - sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5", - lg: "h-10 rounded-md px-6 has-[>svg]:px-4", - icon: "size-9", - "icon-sm": "size-8", - "icon-lg": "size-10", - }, - }, - defaultVariants: { - variant: "default", - size: "default", - }, - } -) - -function Button({ - className, - variant, - size, - asChild = false, - ...props -}: React.ComponentProps<"button"> & - VariantProps & { - asChild?: boolean - }) { - const Comp = asChild ? Slot : "button" - - return ( - - ) -} - -export { Button, buttonVariants } diff --git a/examples/aws-tanstack-start/src/components/ui/input.tsx b/examples/aws-tanstack-start/src/components/ui/input.tsx deleted file mode 100644 index 89169058d0..0000000000 --- a/examples/aws-tanstack-start/src/components/ui/input.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import * as React from "react" - -import { cn } from "@/lib/utils" - -function Input({ className, type, ...props }: React.ComponentProps<"input">) { - return ( - - ) -} - -export { Input } diff --git a/examples/aws-tanstack-start/src/components/ui/label.tsx b/examples/aws-tanstack-start/src/components/ui/label.tsx deleted file mode 100644 index fb5fbc3eee..0000000000 --- a/examples/aws-tanstack-start/src/components/ui/label.tsx +++ /dev/null @@ -1,24 +0,0 @@ -"use client" - -import * as React from "react" -import * as LabelPrimitive from "@radix-ui/react-label" - -import { cn } from "@/lib/utils" - -function Label({ - className, - ...props -}: React.ComponentProps) { - return ( - - ) -} - -export { Label } diff --git a/examples/aws-tanstack-start/src/components/ui/select.tsx b/examples/aws-tanstack-start/src/components/ui/select.tsx deleted file mode 100644 index d34798fafe..0000000000 --- a/examples/aws-tanstack-start/src/components/ui/select.tsx +++ /dev/null @@ -1,185 +0,0 @@ -import * as React from "react" -import * as SelectPrimitive from "@radix-ui/react-select" -import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react" - -import { cn } from "@/lib/utils" - -function Select({ - ...props -}: React.ComponentProps) { - return -} - -function SelectGroup({ - ...props -}: React.ComponentProps) { - return -} - -function SelectValue({ - ...props -}: React.ComponentProps) { - return -} - -function SelectTrigger({ - className, - size = "default", - children, - ...props -}: React.ComponentProps & { - size?: "sm" | "default" -}) { - return ( - - {children} - - - - - ) -} - -function SelectContent({ - className, - children, - position = "popper", - align = "center", - ...props -}: React.ComponentProps) { - return ( - - - - - {children} - - - - - ) -} - -function SelectLabel({ - className, - ...props -}: React.ComponentProps) { - return ( - - ) -} - -function SelectItem({ - className, - children, - ...props -}: React.ComponentProps) { - return ( - - - - - - - {children} - - ) -} - -function SelectSeparator({ - className, - ...props -}: React.ComponentProps) { - return ( - - ) -} - -function SelectScrollUpButton({ - className, - ...props -}: React.ComponentProps) { - return ( - - - - ) -} - -function SelectScrollDownButton({ - className, - ...props -}: React.ComponentProps) { - return ( - - - - ) -} - -export { - Select, - SelectContent, - SelectGroup, - SelectItem, - SelectLabel, - SelectScrollDownButton, - SelectScrollUpButton, - SelectSeparator, - SelectTrigger, - SelectValue, -} diff --git a/examples/aws-tanstack-start/src/components/ui/slider.tsx b/examples/aws-tanstack-start/src/components/ui/slider.tsx deleted file mode 100644 index 1a1bd735a2..0000000000 --- a/examples/aws-tanstack-start/src/components/ui/slider.tsx +++ /dev/null @@ -1,63 +0,0 @@ -"use client" - -import * as React from "react" -import * as SliderPrimitive from "@radix-ui/react-slider" - -import { cn } from "@/lib/utils" - -function Slider({ - className, - defaultValue, - value, - min = 0, - max = 100, - ...props -}: React.ComponentProps) { - const _values = React.useMemo( - () => - Array.isArray(value) - ? value - : Array.isArray(defaultValue) - ? defaultValue - : [min, max], - [value, defaultValue, min, max] - ) - - return ( - - - - - {Array.from({ length: _values.length }, (_, index) => ( - - ))} - - ) -} - -export { Slider } diff --git a/examples/aws-tanstack-start/src/components/ui/switch.tsx b/examples/aws-tanstack-start/src/components/ui/switch.tsx deleted file mode 100644 index b0363e3f86..0000000000 --- a/examples/aws-tanstack-start/src/components/ui/switch.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import * as React from "react" -import * as SwitchPrimitive from "@radix-ui/react-switch" - -import { cn } from "@/lib/utils" - -function Switch({ - className, - ...props -}: React.ComponentProps) { - return ( - - - - ) -} - -export { Switch } diff --git a/examples/aws-tanstack-start/src/components/ui/textarea.tsx b/examples/aws-tanstack-start/src/components/ui/textarea.tsx deleted file mode 100644 index 7f21b5e78a..0000000000 --- a/examples/aws-tanstack-start/src/components/ui/textarea.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import * as React from "react" - -import { cn } from "@/lib/utils" - -function Textarea({ className, ...props }: React.ComponentProps<"textarea">) { - return ( -