From dea7bf7757e6d1883ecc2a4cd9f0c9e19328c6ed Mon Sep 17 00:00:00 2001 From: Valter Balegas Date: Mon, 18 Nov 2024 12:46:02 +0000 Subject: [PATCH 1/6] load initial data --- examples/linearlite/sst.config.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/linearlite/sst.config.ts b/examples/linearlite/sst.config.ts index 4e210f145d..685a80d88c 100644 --- a/examples/linearlite/sst.config.ts +++ b/examples/linearlite/sst.config.ts @@ -33,6 +33,7 @@ export default $config({ const databaseUri = getNeonDbUri(project, db) try { databaseUri.apply(applyMigrations) + databaseUri.apply(loadData) const electricInfo = databaseUri.apply((uri) => addDatabaseToElectric(uri) @@ -60,6 +61,15 @@ function applyMigrations(uri: string) { }) } +function loadData(uri: string) { + execSync(`pnpm run db:load-data`, { + env: { + ...process.env, + DATABASE_URL: uri, + }, + }) +} + function deployLinearLite( electricInfo: $util.Output<{ id: string; token: string }> ) { From 7911f80253665ba7fe36f2057d356b896ba170a1 Mon Sep 17 00:00:00 2001 From: Valter Balegas Date: Mon, 18 Nov 2024 13:36:17 +0000 Subject: [PATCH 2/6] use stage in database name --- examples/linearlite/sst.config.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/linearlite/sst.config.ts b/examples/linearlite/sst.config.ts index 685a80d88c..22b6fbe292 100644 --- a/examples/linearlite/sst.config.ts +++ b/examples/linearlite/sst.config.ts @@ -27,6 +27,10 @@ export default $config({ const db = new neon.Database(`linearlite`, { ...base, + name: + $app.stage === `Production` + ? `linearlite-production` + : `linearlite-${$app.stage}`, ownerName: `neondb_owner`, }) From cefebed1b27d82cce5a3b081dfd520d8d181bcf8 Mon Sep 17 00:00:00 2001 From: Valter Balegas Date: Mon, 18 Nov 2024 15:49:34 +0000 Subject: [PATCH 3/6] make nextjs happy --- examples/nextjs-example/sst-env.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/nextjs-example/sst-env.d.ts b/examples/nextjs-example/sst-env.d.ts index e973cf25d9..886b767062 100644 --- a/examples/nextjs-example/sst-env.d.ts +++ b/examples/nextjs-example/sst-env.d.ts @@ -6,5 +6,9 @@ import "sst" export {} declare module "sst" { export interface Resource { + "nextjs": { + "type": "sst.aws.Nextjs" + "url": string + } } } From e78a93016b22561322de6a394435b8d3e1a884eb Mon Sep 17 00:00:00 2001 From: Valter Balegas Date: Mon, 18 Nov 2024 16:02:41 +0000 Subject: [PATCH 4/6] It misses the providers --- .github/workflows/deploy_examples.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy_examples.yml b/.github/workflows/deploy_examples.yml index dac547b78d..f3fa2309dc 100644 --- a/.github/workflows/deploy_examples.yml +++ b/.github/workflows/deploy_examples.yml @@ -64,6 +64,7 @@ jobs: - name: Deploy NextJs example working-directory: examples/nextjs-example run: | + pnpm sst install pnpm sst deploy --stage ${{ env.DEPLOY_ENV }} if [ -f ".sst/outputs.json" ]; then nextjs=$(jq -r '.website' .sst/outputs.json) From c2d48186a60cc64b9447c8d5f73591b4b5ea0c5a Mon Sep 17 00:00:00 2001 From: Valter Balegas Date: Mon, 18 Nov 2024 23:08:05 +0000 Subject: [PATCH 5/6] Add missing sst types to next-js example --- .github/workflows/deploy_examples.yml | 1 - examples/nextjs-example/.sst/platform/config.d.ts | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy_examples.yml b/.github/workflows/deploy_examples.yml index f3fa2309dc..dac547b78d 100644 --- a/.github/workflows/deploy_examples.yml +++ b/.github/workflows/deploy_examples.yml @@ -64,7 +64,6 @@ jobs: - name: Deploy NextJs example working-directory: examples/nextjs-example run: | - pnpm sst install pnpm sst deploy --stage ${{ env.DEPLOY_ENV }} if [ -f ".sst/outputs.json" ]; then nextjs=$(jq -r '.website' .sst/outputs.json) diff --git a/examples/nextjs-example/.sst/platform/config.d.ts b/examples/nextjs-example/.sst/platform/config.d.ts index 08a1c1a1c1..012a6e7551 100644 --- a/examples/nextjs-example/.sst/platform/config.d.ts +++ b/examples/nextjs-example/.sst/platform/config.d.ts @@ -2,22 +2,22 @@ import "./src/global.d.ts" import "../types.generated" import { AppInput, App, Config } from "./src/config" import * as _neon from "@sst-provider/neon"; -import * as _cloudflare from "@pulumi/cloudflare"; import * as _aws from "@pulumi/aws"; +import * as _cloudflare from "@pulumi/cloudflare"; declare global { // @ts-expect-error export import neon = _neon // @ts-expect-error - export import cloudflare = _cloudflare - // @ts-expect-error export import aws = _aws + // @ts-expect-error + export import cloudflare = _cloudflare interface Providers { providers?: { "neon"?: (_neon.ProviderArgs & { version?: string }) | boolean | string; - "cloudflare"?: (_cloudflare.ProviderArgs & { version?: string }) | boolean | string; "aws"?: (_aws.ProviderArgs & { version?: string }) | boolean | string; + "cloudflare"?: (_cloudflare.ProviderArgs & { version?: string }) | boolean | string; } } export const $config: ( From efdf2078d95f1c28503fe1d7e9530bb86847b0fe Mon Sep 17 00:00:00 2001 From: Valter Balegas Date: Mon, 18 Nov 2024 23:42:02 +0000 Subject: [PATCH 6/6] This makes the trick --- examples/nextjs-example/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/nextjs-example/tsconfig.json b/examples/nextjs-example/tsconfig.json index 3a2d3a6d52..94cf32e88f 100644 --- a/examples/nextjs-example/tsconfig.json +++ b/examples/nextjs-example/tsconfig.json @@ -24,5 +24,5 @@ } }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], - "exclude": ["node_modules"] + "exclude": ["node_modules", "sst.config.ts"] }