@cedarjs/cli 7.0.1-next.467 → 7.1.0-rc.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/build/buildHandler.js +1 -2
- package/dist/commands/build.js +1 -1
- package/dist/commands/check.js +1 -2
- package/dist/commands/deploy/baremetal/baremetalHandler.js +73 -364
- package/dist/commands/deploy/baremetal.js +1 -7
- package/dist/commands/deploy/flightcontrolHandler.js +1 -1
- package/dist/commands/deploy/helpers/deployHandler.js +1 -1
- package/dist/commands/deploy/netlify.js +1 -1
- package/dist/commands/deploy/renderHandler.js +1 -1
- package/dist/commands/deploy/serverlessHandler.js +1 -2
- package/dist/commands/deploy/vercel.js +1 -1
- package/dist/commands/destroy/handlerHelpers.js +1 -1
- package/dist/commands/destroy/page/pageHandler.js +1 -2
- package/dist/commands/destroy/scaffold/scaffoldHandler.js +26 -65
- package/dist/commands/destroy/sdl/sdlHandler.js +1 -2
- package/dist/commands/dev/devHandler.js +4 -3
- package/dist/commands/dev/packageWatchCommands.js +3 -8
- package/dist/commands/dev.js +1 -1
- package/dist/commands/execHandler.js +1 -2
- package/dist/commands/experimental/live-queries/liveQueries.js +1 -1
- package/dist/commands/experimental/live-queries/liveQueriesHandler.js +3 -3
- package/dist/commands/experimental/setupInngest.js +1 -1
- package/dist/commands/experimental/setupInngestHandler.js +1 -1
- package/dist/commands/experimental/setupOpentelemetry.js +1 -1
- package/dist/commands/experimental/setupOpentelemetryHandler.js +1 -2
- package/dist/commands/experimental/setupReactCompiler.js +1 -1
- package/dist/commands/experimental/setupReactCompilerHandler.js +4 -4
- package/dist/commands/experimental/setupRsc.js +1 -1
- package/dist/commands/experimental/setupRscHandler.js +1 -2
- package/dist/commands/experimental/setupStreamingSsr.js +1 -1
- package/dist/commands/experimental/setupStreamingSsrHandler.js +2 -3
- package/dist/commands/generate/cell/cell.js +0 -20
- package/dist/commands/generate/cell/cellHandler.js +20 -68
- package/dist/commands/generate/cell/templates/cell.tsx.template +2 -21
- package/dist/commands/generate/cell/templates/cellList.tsx.template +2 -21
- package/dist/commands/generate/cell/templates/test.js.template +1 -1
- package/dist/commands/generate/dataMigration/dataMigration.js +1 -2
- package/dist/commands/generate/dbAuth/dbAuth.js +2 -6
- package/dist/commands/generate/dbAuth/dbAuthHandler.js +17 -80
- package/dist/commands/generate/dbAuth/templates/login.webAuthn.tsx.template +12 -20
- package/dist/commands/generate/directive/directiveHandler.js +1 -2
- package/dist/commands/generate/function/functionHandler.js +1 -2
- package/dist/commands/generate/helpers.js +0 -26
- package/dist/commands/generate/job/jobHandler.js +1 -2
- package/dist/commands/generate/model/modelHandler.js +1 -2
- package/dist/commands/generate/ogImage/ogImageHandler.js +1 -2
- package/dist/commands/generate/ogImage/templates/ogImage.og.tsx.template +1 -1
- package/dist/commands/generate/package/filesTask.js +12 -9
- package/dist/commands/generate/package/packageHandler.js +4 -3
- package/dist/commands/generate/package/templates/tsconfig.json.template +0 -1
- package/dist/commands/generate/page/pageHandler.js +1 -2
- package/dist/commands/generate/realtime/realtime.js +1 -1
- package/dist/commands/generate/realtime/realtimeHandler.js +9 -2
- package/dist/commands/generate/realtime/templates/liveQueries/blank/blank.service.ts.template +4 -12
- package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.service.ts.template +2 -2
- package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.ts.template +4 -4
- package/dist/commands/generate/scaffold/scaffold.js +1 -1
- package/dist/commands/generate/scaffold/scaffoldHandler.js +49 -93
- package/dist/commands/generate/scaffold/templates/assets/scaffold.tailwind.css.template +7 -12
- package/dist/commands/generate/scaffold/templates/components/EditNameCell.tsx.template +7 -5
- package/dist/commands/generate/scaffold/templates/components/NameForm.tsx.template +9 -10
- package/dist/commands/generate/scaffold/templates/lib/formatters.test.tsx.template +0 -11
- package/dist/commands/generate/scaffold/templates/lib/formatters.tsx.template +4 -16
- package/dist/commands/generate/script/scriptHandler.js +1 -2
- package/dist/commands/generate/script/templates/tsconfig.json.template +0 -1
- package/dist/commands/generate/sdl/sdlHandler.js +4 -10
- package/dist/commands/generate/secret/secret.js +1 -1
- package/dist/commands/generate/service/serviceHandler.js +49 -79
- package/dist/commands/generate/service/templates/service.ts.template +13 -40
- package/dist/commands/generate/service/templates/test.ts.template +6 -8
- package/dist/commands/generate/yargsCommandHelpers.js +1 -1
- package/dist/commands/generate/yargsHandlerHelpers.js +1 -2
- package/dist/commands/generate.js +1 -1
- package/dist/commands/info.js +1 -1
- package/dist/commands/jobsHandler.js +3 -5
- package/dist/commands/lint.js +1 -1
- package/dist/commands/prerenderHandler.js +4 -11
- package/dist/commands/prismaHandler.js +2 -7
- package/dist/commands/record/init.js +1 -1
- package/dist/commands/serve.js +1 -2
- package/dist/commands/setup/auth/auth.js +4 -2
- package/dist/commands/setup/cache/cache.js +1 -1
- package/dist/commands/setup/cache/cacheHandler.js +1 -2
- package/dist/commands/setup/cache/templates/memcached.ts.template +17 -14
- package/dist/commands/setup/cache/templates/redis.ts.template +20 -12
- package/dist/commands/setup/database/postgres.js +1 -1
- package/dist/commands/setup/database/postgresHandler.js +1 -3
- package/dist/commands/setup/deploy/providers/baremetal.js +0 -7
- package/dist/commands/setup/deploy/providers/baremetalHandler.js +21 -130
- package/dist/commands/setup/deploy/providers/coherence.js +1 -1
- package/dist/commands/setup/deploy/providers/coherenceHandler.js +6 -7
- package/dist/commands/setup/deploy/providers/flightcontrolHandler.js +1 -2
- package/dist/commands/setup/deploy/providers/netlifyHandler.js +1 -2
- package/dist/commands/setup/deploy/providers/renderHandler.js +1 -2
- package/dist/commands/setup/deploy/providers/serverlessHandler.js +1 -2
- package/dist/commands/setup/deploy/providers/universalDeployHandler.js +6 -4
- package/dist/commands/setup/deploy/providers/vercelHandler.js +1 -2
- package/dist/commands/setup/deploy/templates/baremetal.js +9 -119
- package/dist/commands/setup/deploy/templates/netlifyUD.js +0 -3
- package/dist/commands/setup/docker/docker.js +1 -1
- package/dist/commands/setup/docker/dockerHandler.js +1 -2
- package/dist/commands/setup/generator/generator.js +1 -1
- package/dist/commands/setup/generator/generatorHandler.js +1 -1
- package/dist/commands/setup/graphql/features/fragments/fragments.js +1 -1
- package/dist/commands/setup/graphql/features/fragments/fragmentsHandler.js +5 -3
- package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocuments.js +1 -1
- package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocumentsHandler.js +1 -2
- package/dist/commands/setup/i18n/i18n.js +1 -1
- package/dist/commands/setup/i18n/i18nHandler.js +1 -1
- package/dist/commands/setup/jobs/jobs.js +1 -1
- package/dist/commands/setup/jobs/jobsHandler.js +1 -4
- package/dist/commands/setup/mailer/mailer.js +1 -1
- package/dist/commands/setup/mailer/mailerHandler.js +1 -2
- package/dist/commands/setup/middleware/ogImage/ogImage.js +1 -1
- package/dist/commands/setup/middleware/ogImage/ogImageHandler.js +1 -2
- package/dist/commands/setup/monitoring/sentry/sentry.js +1 -1
- package/dist/commands/setup/monitoring/sentry/sentryHandler.js +9 -13
- package/dist/commands/setup/monitoring/sentry/templates/sentryApi.ts.template +4 -1
- package/dist/commands/setup/monitoring/sentry/templates/sentryWeb.ts.template +4 -7
- package/dist/commands/setup/neon/neon.js +1 -1
- package/dist/commands/setup/neon/neonHandler.js +9 -5
- package/dist/commands/setup/package/package.js +1 -1
- package/dist/commands/setup/package/packageHandler.js +4 -4
- package/dist/commands/setup/realtime/addRealtimeToGraphql.js +1 -1
- package/dist/commands/setup/realtime/realtime.js +1 -1
- package/dist/commands/setup/realtime/realtimeHandler.js +16 -4
- package/dist/commands/setup/realtime/templates/defer/fastAndSlowFields/fastAndSlowFields.ts.template +1 -4
- package/dist/commands/setup/realtime/templates/liveQueries/auctions/auctions.ts.template +4 -12
- package/dist/commands/setup/realtime/templates/subscriptions/countdown/countdown.ts.template +1 -1
- package/dist/commands/setup/realtime/templates/subscriptions/newMessage/newMessage.ts.template +2 -2
- package/dist/commands/setup/server-file/serverFile.js +1 -1
- package/dist/commands/setup/server-file/serverFileHandler.js +1 -2
- package/dist/commands/setup/ui/libraries/chakra-uiHandler.js +1 -2
- package/dist/commands/setup/ui/libraries/mantineHandler.js +1 -2
- package/dist/commands/setup/ui/libraries/tailwindcssHandler.js +82 -63
- package/dist/commands/setup/ui/templates/postcss.config.cjs.template +9 -0
- package/dist/commands/setup/uploads/dbCodemod.js +28 -0
- package/dist/commands/setup/uploads/templates/signedUrl.ts.template +21 -0
- package/dist/commands/setup/uploads/templates/srcLibUploads.ts.template +24 -23
- package/dist/commands/setup/uploads/uploads.js +7 -49
- package/dist/commands/setup/uploads/uploadsHandler.js +69 -277
- package/dist/commands/setup.js +1 -2
- package/dist/commands/studio.js +1 -1
- package/dist/commands/test/testHandler.js +71 -25
- package/dist/commands/test/testHandlerEsm.js +109 -0
- package/dist/commands/test.js +18 -10
- package/dist/commands/testEsm.js +41 -0
- package/dist/commands/type-checkHandler.js +1 -1
- package/dist/commands/upgrade/preUpgradeScripts.js +3 -3
- package/dist/commands/upgrade/upgrade.js +1 -1
- package/dist/commands/upgrade/upgradeHandler.js +1 -2
- package/dist/index.js +8 -5
- package/dist/lib/exit.js +1 -1
- package/dist/lib/index.js +31 -16
- package/dist/lib/loadEnvFiles.js +1 -1
- package/dist/lib/plugin.js +1 -1
- package/dist/lib/test.js +1 -1
- package/dist/lib/updateCheck.js +4 -4
- package/dist/middleware/checkNodeVersion.js +4 -4
- package/package.json +27 -27
- package/dist/commands/deploy/baremetal/monitors.js +0 -66
- package/dist/commands/generate/cell/templates/cellFragment.tsx.template +0 -43
- package/dist/commands/generate/cell/templates/storiesFragment.tsx.template +0 -23
- package/dist/commands/generate/cell/templates/testFragment.js.template +0 -30
- package/dist/commands/generate/dbAuth/templates/changePassword.tsx.template +0 -131
- package/dist/commands/generate/dbAuth/templates/login.oauth.tsx.template +0 -164
- package/dist/commands/generate/dbAuth/templates/signup.oauth.tsx.template +0 -147
- package/dist/commands/generate/scaffold/templates/layouts/NamesScaffoldLayout.tsx.template +0 -18
- package/dist/commands/setup/tenancy/authCodemod.js +0 -66
- package/dist/commands/setup/tenancy/dbCodemod.js +0 -64
- package/dist/commands/setup/tenancy/graphqlCodemod.js +0 -88
- package/dist/commands/setup/tenancy/preflight.js +0 -49
- package/dist/commands/setup/tenancy/schemaPrisma.js +0 -81
- package/dist/commands/setup/tenancy/signupCodemod.js +0 -154
- package/dist/commands/setup/tenancy/templates/InvitePage.tsx.template +0 -72
- package/dist/commands/setup/tenancy/templates/OrgScope.tsx.template +0 -40
- package/dist/commands/setup/tenancy/templates/ensureDefaultOrganizations.dataMigration.ts.template +0 -39
- package/dist/commands/setup/tenancy/templates/organizations.scenarios.ts.template +0 -57
- package/dist/commands/setup/tenancy/templates/organizations.sdl.ts.template +0 -89
- package/dist/commands/setup/tenancy/templates/organizations.test.ts.template +0 -381
- package/dist/commands/setup/tenancy/templates/organizations.ts.template +0 -394
- package/dist/commands/setup/tenancy/templates/requireMembership.test.ts.template +0 -35
- package/dist/commands/setup/tenancy/templates/requireMembership.ts.template +0 -25
- package/dist/commands/setup/tenancy/tenancy.js +0 -30
- package/dist/commands/setup/tenancy/tenancyHandler.js +0 -425
- package/dist/commands/setup/uploads/gitignore.js +0 -17
- package/dist/commands/setup/uploads/schemaPrisma.js +0 -41
- package/dist/commands/setup/uploads/serverFile.js +0 -217
- package/dist/commands/setup/uploads/templates/requireUploadToken.ts.template +0 -15
- package/dist/commands/setup/uploads/templates/uploads.sdl.ts.template +0 -79
- package/dist/commands/setup/uploads/templates/uploads.ts.template +0 -98
- package/dist/commands/setup/uploads/templates/withDataUri.ts.template +0 -14
- package/dist/commands/setup/uploads/templates/withSignedUrl.ts.template +0 -16
- package/dist/commands/test/viteVersionCheck.js +0 -75
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
|
-
import { colors } from "@cedarjs/cli-helpers/colors";
|
|
5
|
-
import { prettify, writeFilesTask } from "@cedarjs/cli-helpers/fileHelpers";
|
|
6
4
|
import {
|
|
7
5
|
addApiPackages,
|
|
8
|
-
addWebPackages
|
|
9
|
-
} from "@cedarjs/cli-helpers/installHelpers";
|
|
10
|
-
import { getPaths } from "@cedarjs/cli-helpers/paths";
|
|
11
|
-
import {
|
|
12
6
|
addEnvVarTask,
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
addWebPackages,
|
|
8
|
+
colors,
|
|
9
|
+
getPaths,
|
|
10
|
+
isTypeScriptProject,
|
|
11
|
+
prettify,
|
|
12
|
+
writeFilesTask
|
|
13
|
+
} from "@cedarjs/cli-helpers";
|
|
15
14
|
import { getConfigPath } from "@cedarjs/project-config";
|
|
16
15
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
17
16
|
const rwPaths = getPaths();
|
|
@@ -76,6 +75,7 @@ const handler = async ({ force }) => {
|
|
|
76
75
|
"export const handler = createGraphQLHandler({",
|
|
77
76
|
"extraPlugins: [useSentry({",
|
|
78
77
|
" includeRawResult: true,",
|
|
78
|
+
" includeResolverArgs: true,",
|
|
79
79
|
" includeExecuteVariables: true,",
|
|
80
80
|
"})],"
|
|
81
81
|
);
|
|
@@ -111,11 +111,7 @@ const handler = async ({ force }) => {
|
|
|
111
111
|
contentLines.splice(
|
|
112
112
|
boundaryOpenIndex,
|
|
113
113
|
1,
|
|
114
|
-
"<Sentry.ErrorBoundary"
|
|
115
|
-
" fallback={({ error }) => (",
|
|
116
|
-
" <FatalErrorPage error={error instanceof Error ? error : undefined} />",
|
|
117
|
-
" )}",
|
|
118
|
-
">"
|
|
114
|
+
"<Sentry.ErrorBoundary fallback={FatalErrorPage}>"
|
|
119
115
|
);
|
|
120
116
|
const boundaryCloseIndex = contentLines.findLastIndex(
|
|
121
117
|
(line) => line.includes("</FatalErrorBoundary>")
|
|
@@ -3,7 +3,10 @@ import * as Sentry from '@sentry/node'
|
|
|
3
3
|
Sentry.init({
|
|
4
4
|
dsn: process.env.SENTRY_DSN,
|
|
5
5
|
environment: process.env.NODE_ENV,
|
|
6
|
-
integrations: [
|
|
6
|
+
integrations: [
|
|
7
|
+
Sentry.prismaIntegration(),
|
|
8
|
+
Sentry.httpIntegration(),
|
|
9
|
+
],
|
|
7
10
|
tracesSampleRate: 1.0,
|
|
8
11
|
})
|
|
9
12
|
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import * as Sentry from '@sentry/react'
|
|
2
2
|
|
|
3
|
-
const sentryDsn =
|
|
4
|
-
typeof process === 'undefined' ? undefined : process.env?.SENTRY_DSN
|
|
5
|
-
|
|
6
3
|
let dsn = ''
|
|
7
4
|
let environment = 'development'
|
|
8
5
|
|
|
9
|
-
if (!
|
|
6
|
+
if (typeof process === 'undefined' || !process.env?.SENTRY_DSN) {
|
|
10
7
|
console.error(
|
|
11
8
|
'Missing SENTRY_DSN environment variable. Did you forget to add it to ' +
|
|
12
9
|
'your cedar.toml (or redwood.toml) in `includeEnvironmentVariables`?'
|
|
@@ -20,14 +17,14 @@ if (!sentryDsn) {
|
|
|
20
17
|
`)
|
|
21
18
|
console.error('Sentry is disabled for now')
|
|
22
19
|
} else {
|
|
23
|
-
dsn =
|
|
24
|
-
environment = process.env.NODE_ENV
|
|
20
|
+
dsn = process.env.SENTRY_DSN
|
|
21
|
+
environment = process.env.NODE_ENV
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
Sentry.init({
|
|
28
25
|
dsn,
|
|
29
26
|
environment,
|
|
30
|
-
integrations: [Sentry.browserTracingIntegration()],
|
|
27
|
+
integrations: [ Sentry.browserTracingIntegration() ],
|
|
31
28
|
tracesSampleRate: 1.0,
|
|
32
29
|
})
|
|
33
30
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
2
2
|
const command = "neon";
|
|
3
3
|
const description = "Provision a Neon Postgres database and configure your project";
|
|
4
4
|
function builder(yargs) {
|
|
@@ -3,11 +3,8 @@ import path from "node:path";
|
|
|
3
3
|
import execa from "execa";
|
|
4
4
|
import { Listr } from "listr2";
|
|
5
5
|
import prompts from "prompts";
|
|
6
|
-
import { colors } from "@cedarjs/cli-helpers
|
|
7
|
-
import { installPackages } from "@cedarjs/cli-helpers/installHelpers";
|
|
6
|
+
import { colors, getPaths, installPackages } from "@cedarjs/cli-helpers";
|
|
8
7
|
import { prettyPrintCedarCommand } from "@cedarjs/cli-helpers/packageManager";
|
|
9
|
-
import { getPaths } from "@cedarjs/cli-helpers/paths";
|
|
10
|
-
import { requireTTYOrExit } from "@cedarjs/cli-helpers/tty";
|
|
11
8
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
12
9
|
import {
|
|
13
10
|
checkProjectShape,
|
|
@@ -57,7 +54,14 @@ async function handler({ force, migrations, verbose }) {
|
|
|
57
54
|
}
|
|
58
55
|
let runMigrations = migrations;
|
|
59
56
|
if (!skipProvisioning && runMigrations === void 0) {
|
|
60
|
-
|
|
57
|
+
if (!process.stdin.isTTY) {
|
|
58
|
+
const error = new Error(
|
|
59
|
+
"Cannot prompt for confirmation in a non-interactive terminal. Please pass --migrations or --no-migrations explicitly."
|
|
60
|
+
);
|
|
61
|
+
errorTelemetry(process.argv, error.message);
|
|
62
|
+
console.error(colors.error(error.message));
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
61
65
|
const response = await prompts({
|
|
62
66
|
type: "toggle",
|
|
63
67
|
name: "runMigrations",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { terminalLink } from "termi-link";
|
|
2
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers
|
|
2
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
3
3
|
const command = "package <npm-package>";
|
|
4
4
|
const description = "Run a bin from an NPM package with version compatibility checks";
|
|
5
5
|
const builder = (yargs) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import enq from "enquirer";
|
|
2
|
-
import
|
|
2
|
+
import semver from "semver";
|
|
3
|
+
import { getCompatibilityData } from "@cedarjs/cli-helpers";
|
|
3
4
|
import { dlx } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
4
|
-
import { getCompatibilityData } from "@cedarjs/cli-helpers/version";
|
|
5
5
|
import { getPaths } from "@cedarjs/project-config";
|
|
6
6
|
async function handler({
|
|
7
7
|
npmPackage,
|
|
@@ -16,7 +16,7 @@ async function handler({
|
|
|
16
16
|
console.log(
|
|
17
17
|
"No compatibility check will be performed because you used the --force flag."
|
|
18
18
|
);
|
|
19
|
-
if (
|
|
19
|
+
if (semver.parse(packageVersion) !== null && semver.lt(packageVersion, "1.0.0")) {
|
|
20
20
|
console.log(
|
|
21
21
|
"Be aware that this package is under version 1.0.0 and so should be considered experimental."
|
|
22
22
|
);
|
|
@@ -86,7 +86,7 @@ The latest version compatible with your project is ${latestCompatibleVersionText
|
|
|
86
86
|
await runPackage(packageName, versionToUse, additionalOptionsToForward);
|
|
87
87
|
}
|
|
88
88
|
async function showExperimentalWarning(version) {
|
|
89
|
-
if (version === void 0 ||
|
|
89
|
+
if (version === void 0 || semver.parse(version) === null || semver.gte(version, "1.0.0")) {
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
92
|
const decision = await promptWithChoices(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { isTypeScriptProject } from "@cedarjs/cli-helpers
|
|
3
|
+
import { isTypeScriptProject } from "@cedarjs/cli-helpers";
|
|
4
4
|
import { getPaths } from "@cedarjs/project-config";
|
|
5
5
|
function addRealtimeToGraphqlHandler(ctx, task, force) {
|
|
6
6
|
const graphqlHandlerPath = path.join(
|
|
@@ -2,10 +2,10 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
4
|
import prompts from "prompts";
|
|
5
|
-
import { colors as c } from "@cedarjs/cli-helpers
|
|
6
|
-
import { addApiPackages } from "@cedarjs/cli-helpers/installHelpers";
|
|
5
|
+
import { addApiPackages, colors as c } from "@cedarjs/cli-helpers";
|
|
7
6
|
import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
8
7
|
import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
|
|
8
|
+
import { projectIsEsm } from "@cedarjs/project-config";
|
|
9
9
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
10
10
|
import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
|
|
11
11
|
import { isTypeScriptProject, serverFileExists } from "../../../lib/project.js";
|
|
@@ -77,7 +77,7 @@ async function handler(args) {
|
|
|
77
77
|
title: "Adding Countdown example subscription...",
|
|
78
78
|
enabled: () => includeExamples,
|
|
79
79
|
task: async () => {
|
|
80
|
-
|
|
80
|
+
let exampleSubscriptionTemplateContent = fs.readFileSync(
|
|
81
81
|
path.resolve(
|
|
82
82
|
import.meta.dirname,
|
|
83
83
|
"templates",
|
|
@@ -87,6 +87,12 @@ async function handler(args) {
|
|
|
87
87
|
),
|
|
88
88
|
"utf-8"
|
|
89
89
|
);
|
|
90
|
+
if (projectIsEsm()) {
|
|
91
|
+
exampleSubscriptionTemplateContent = exampleSubscriptionTemplateContent.replace(
|
|
92
|
+
"import gql from 'graphql-tag'",
|
|
93
|
+
"import { gql } from 'graphql-tag'"
|
|
94
|
+
);
|
|
95
|
+
}
|
|
90
96
|
const exampleFile = path.join(
|
|
91
97
|
cedarPaths.api.subscriptions,
|
|
92
98
|
"countdown",
|
|
@@ -138,7 +144,7 @@ async function handler(args) {
|
|
|
138
144
|
`rooms.${isTypeScriptProject() ? "ts" : "js"}`
|
|
139
145
|
);
|
|
140
146
|
const serviceContent = ts ? exampleServiceTemplateContent : await transformTSToJS(serviceFile, exampleServiceTemplateContent);
|
|
141
|
-
|
|
147
|
+
let exampleSubscriptionTemplateContent = fs.readFileSync(
|
|
142
148
|
path.resolve(
|
|
143
149
|
import.meta.dirname,
|
|
144
150
|
"templates",
|
|
@@ -148,6 +154,12 @@ async function handler(args) {
|
|
|
148
154
|
),
|
|
149
155
|
"utf-8"
|
|
150
156
|
);
|
|
157
|
+
if (projectIsEsm()) {
|
|
158
|
+
exampleSubscriptionTemplateContent = exampleSubscriptionTemplateContent.replace(
|
|
159
|
+
"import gql from 'graphql-tag'",
|
|
160
|
+
"import { gql } from 'graphql-tag'"
|
|
161
|
+
);
|
|
162
|
+
}
|
|
151
163
|
const exampleFile = path.join(
|
|
152
164
|
cedarPaths.api.subscriptions,
|
|
153
165
|
"newMessage",
|
package/dist/commands/setup/realtime/templates/defer/fastAndSlowFields/fastAndSlowFields.ts.template
CHANGED
|
@@ -7,10 +7,7 @@ export const fastField = async () => {
|
|
|
7
7
|
return 'I am fast'
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const slowField = async (
|
|
11
|
-
_: unknown,
|
|
12
|
-
{ waitFor = 5000 }: { waitFor?: number }
|
|
13
|
-
) => {
|
|
10
|
+
export const slowField = async (_, { waitFor = 5000 }) => {
|
|
14
11
|
logger.debug('waiting on slowField')
|
|
15
12
|
await wait(waitFor)
|
|
16
13
|
return 'I am slow'
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
import type { BidInput } from 'types/graphql'
|
|
2
|
-
|
|
3
1
|
import type { LiveQueryStorageMechanism } from '@cedarjs/realtime'
|
|
4
2
|
|
|
5
3
|
import { logger } from 'src/lib/logger'
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
id: string
|
|
9
|
-
title: string
|
|
10
|
-
bids: { amount: number }[]
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const auctions: AuctionData[] = [
|
|
5
|
+
const auctions = [
|
|
14
6
|
{ id: '1', title: 'RedwoodJS Logo Shirt', bids: [{ amount: 20 }] },
|
|
15
7
|
{ id: '2', title: 'RedwoodJS Lapel Pin', bids: [{ amount: 5 }] },
|
|
16
8
|
{ id: '3', title: 'RedwoodJS Beanie', bids: [{ amount: 15 }] },
|
|
@@ -42,14 +34,14 @@ const auctions: AuctionData[] = [
|
|
|
42
34
|
* }
|
|
43
35
|
* }
|
|
44
36
|
*/
|
|
45
|
-
export const auction = async ({ id }
|
|
37
|
+
export const auction = async ({ id }) => {
|
|
46
38
|
const foundAuction = auctions.find((a) => a.id === id)
|
|
47
39
|
logger.debug({ id, auction: foundAuction }, 'auction')
|
|
48
40
|
return foundAuction
|
|
49
41
|
}
|
|
50
42
|
|
|
51
43
|
export const bid = async (
|
|
52
|
-
{ input }
|
|
44
|
+
{ input },
|
|
53
45
|
{ context }: { context: { liveQueryStore: LiveQueryStorageMechanism } }
|
|
54
46
|
) => {
|
|
55
47
|
const { auctionId, amount } = input
|
|
@@ -70,7 +62,7 @@ export const bid = async (
|
|
|
70
62
|
}
|
|
71
63
|
|
|
72
64
|
export const Auction = {
|
|
73
|
-
highestBid: (obj
|
|
65
|
+
highestBid: (obj, { root }) => {
|
|
74
66
|
const [max] = root.bids.sort((a, b) => b.amount - a.amount)
|
|
75
67
|
|
|
76
68
|
logger.debug({ obj, root }, 'highestBid')
|
package/dist/commands/setup/realtime/templates/subscriptions/newMessage/newMessage.ts.template
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import gql from 'graphql-tag'
|
|
2
2
|
|
|
3
3
|
import type { PubSub } from '@cedarjs/realtime'
|
|
4
4
|
|
|
@@ -48,7 +48,7 @@ const newMessage = {
|
|
|
48
48
|
|
|
49
49
|
return pubSub.subscribe('newMessage', roomId)
|
|
50
50
|
},
|
|
51
|
-
resolve: (payload
|
|
51
|
+
resolve: (payload) => {
|
|
52
52
|
logger.debug({ payload }, 'newMessage subscription resolve')
|
|
53
53
|
|
|
54
54
|
return payload
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
|
-
import { colors as c } from "@cedarjs/cli-helpers
|
|
5
|
-
import { addApiPackages } from "@cedarjs/cli-helpers/installHelpers";
|
|
4
|
+
import { addApiPackages, colors as c } from "@cedarjs/cli-helpers";
|
|
6
5
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
7
6
|
import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
|
|
8
7
|
import { isTypeScriptProject } from "../../../lib/project.js";
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { Listr } from "listr2";
|
|
3
|
-
import { colors as c } from "@cedarjs/cli-helpers
|
|
3
|
+
import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
4
4
|
import { addWorkspacePackages } from "@cedarjs/cli-helpers/packageManager/packages";
|
|
5
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
6
5
|
import extendStorybookConfiguration from "../../../../lib/configureStorybook.js";
|
|
7
6
|
import { extendJSXFile, fileIncludes } from "../../../../lib/extendFile.js";
|
|
8
7
|
import { getPaths, writeFile } from "../../../../lib/index.js";
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
|
-
import { colors as c } from "@cedarjs/cli-helpers
|
|
4
|
+
import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
5
5
|
import { addWorkspacePackages } from "@cedarjs/cli-helpers/packageManager/packages";
|
|
6
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
7
6
|
import extendStorybookConfiguration from "../../../../lib/configureStorybook.js";
|
|
8
7
|
import { extendJSXFile, fileIncludes } from "../../../../lib/extendFile.js";
|
|
9
8
|
import { getPaths, writeFile } from "../../../../lib/index.js";
|
|
@@ -4,33 +4,45 @@ import { ListrEnquirerPromptAdapter } from "@listr2/prompt-adapter-enquirer";
|
|
|
4
4
|
import execa from "execa";
|
|
5
5
|
import { Listr } from "listr2";
|
|
6
6
|
import { terminalLink } from "termi-link";
|
|
7
|
-
import { colors as c } from "@cedarjs/cli-helpers
|
|
7
|
+
import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
8
8
|
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
9
|
+
import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
9
10
|
import {
|
|
10
11
|
addRootPackages,
|
|
11
12
|
addWorkspacePackages
|
|
12
13
|
} from "@cedarjs/cli-helpers/packageManager/packages";
|
|
13
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
14
14
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
15
15
|
import { getPaths, usingVSCode } from "../../../../lib/index.js";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const tailwindDirectives = [
|
|
17
|
+
"@tailwind base;",
|
|
18
|
+
"@tailwind components;",
|
|
19
|
+
"@tailwind utilities;"
|
|
20
|
+
];
|
|
21
|
+
const tailwindDirectivesExist = (indexCSS) => tailwindDirectives.every(
|
|
22
|
+
(tailwindDirective) => indexCSS.includes(tailwindDirective)
|
|
23
|
+
);
|
|
24
|
+
const tailwindImportsAndNotes = [
|
|
20
25
|
"/**",
|
|
21
26
|
" * START --- SETUP TAILWINDCSS EDIT",
|
|
22
27
|
" *",
|
|
23
|
-
` * \`${formatCedarCommand(["setup", "ui", "tailwindcss"])}\` placed
|
|
28
|
+
` * \`${formatCedarCommand(["setup", "ui", "tailwindcss"])}\` placed these directives here`,
|
|
24
29
|
" * to inject Tailwind's styles into your CSS.",
|
|
25
30
|
" * For more information, see: https://tailwindcss.com/docs/installation",
|
|
26
31
|
" */",
|
|
27
|
-
|
|
32
|
+
...tailwindDirectives,
|
|
28
33
|
"/**",
|
|
29
34
|
" * END --- SETUP TAILWINDCSS EDIT",
|
|
30
35
|
" */\n"
|
|
31
36
|
];
|
|
32
|
-
const recommendedVSCodeExtensions = [
|
|
37
|
+
const recommendedVSCodeExtensions = [
|
|
38
|
+
"csstools.postcss",
|
|
39
|
+
"bradlc.vscode-tailwindcss"
|
|
40
|
+
];
|
|
33
41
|
const recommendationTexts = {
|
|
42
|
+
"csstools.postcss": terminalLink(
|
|
43
|
+
"PostCSS Language Support",
|
|
44
|
+
"https://marketplace.visualstudio.com/items?itemName=csstools.postcss"
|
|
45
|
+
),
|
|
34
46
|
"bradlc.vscode-tailwindcss": terminalLink(
|
|
35
47
|
"Tailwind CSS IntelliSense",
|
|
36
48
|
"https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss"
|
|
@@ -74,8 +86,9 @@ const handler = async ({
|
|
|
74
86
|
const rwPaths = getPaths();
|
|
75
87
|
const projectPackages = ["prettier-plugin-tailwindcss@^0.8.0"];
|
|
76
88
|
const webWorkspacePackages = [
|
|
77
|
-
"
|
|
78
|
-
"
|
|
89
|
+
"postcss",
|
|
90
|
+
"tailwindcss@^3.4.17",
|
|
91
|
+
"autoprefixer"
|
|
79
92
|
];
|
|
80
93
|
const tasks = new Listr(
|
|
81
94
|
[
|
|
@@ -126,45 +139,62 @@ const handler = async ({
|
|
|
126
139
|
}
|
|
127
140
|
},
|
|
128
141
|
{
|
|
129
|
-
title: "
|
|
130
|
-
task: (
|
|
131
|
-
const
|
|
132
|
-
if (!
|
|
133
|
-
throw new Error("Could not find web/vite.config.{ts,js}");
|
|
134
|
-
}
|
|
135
|
-
const viteConfig = fs.readFileSync(viteConfigPath, "utf-8");
|
|
136
|
-
if (viteConfig.includes("@tailwindcss/vite")) {
|
|
137
|
-
task.skip("The Tailwind CSS Vite plugin is already configured");
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
const viteConfigWithPlugin = insertPluginsBeforeCedar({
|
|
141
|
-
content: viteConfig,
|
|
142
|
-
pluginCodes: ["tailwindcss()"]
|
|
143
|
-
});
|
|
144
|
-
if (!viteConfigWithPlugin) {
|
|
142
|
+
title: "Configuring PostCSS...",
|
|
143
|
+
task: () => {
|
|
144
|
+
const postCSSConfigPath = rwPaths.web.postcss;
|
|
145
|
+
if (!force && fs.existsSync(postCSSConfigPath)) {
|
|
145
146
|
throw new Error(
|
|
146
|
-
|
|
147
|
-
Add \`import tailwindcss from '@tailwindcss/vite'\` to the top of the file and \`tailwindcss()\` to the plugins array yourself, and then run this command again.`
|
|
147
|
+
"PostCSS config already exists.\nUse --force to override existing config."
|
|
148
148
|
);
|
|
149
|
+
} else {
|
|
150
|
+
const postCSSConfig = fs.readFileSync(
|
|
151
|
+
path.join(
|
|
152
|
+
import.meta.dirname,
|
|
153
|
+
"../templates/postcss.config.cjs.template"
|
|
154
|
+
),
|
|
155
|
+
"utf-8"
|
|
156
|
+
);
|
|
157
|
+
fs.mkdirSync(path.dirname(postCSSConfigPath), { recursive: true });
|
|
158
|
+
return fs.writeFileSync(postCSSConfigPath, postCSSConfig);
|
|
149
159
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
title: "Initializing Tailwind CSS...",
|
|
164
|
+
task: async () => {
|
|
165
|
+
const tailwindConfigPath = path.join(
|
|
166
|
+
rwPaths.web.config,
|
|
167
|
+
"tailwind.config.cjs"
|
|
156
168
|
);
|
|
169
|
+
if (fs.existsSync(tailwindConfigPath)) {
|
|
170
|
+
if (force) {
|
|
171
|
+
fs.unlinkSync(tailwindConfigPath);
|
|
172
|
+
} else {
|
|
173
|
+
throw new Error(
|
|
174
|
+
"Tailwind CSS config already exists.\nUse --force to override existing config."
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
await runBin("tailwindcss", ["init", tailwindConfigPath], {
|
|
179
|
+
cwd: rwPaths.web.base
|
|
180
|
+
});
|
|
181
|
+
const tailwindConfig = fs.readFileSync(tailwindConfigPath, "utf-8");
|
|
182
|
+
const newTailwindConfig = 'const { join } = require("node:path");\n\n' + tailwindConfig.replace(
|
|
183
|
+
"content: []",
|
|
184
|
+
"content: [join(__dirname, '../src/**/*.{js,jsx,ts,tsx}')]"
|
|
185
|
+
).replace("export default {", "module.exports = {");
|
|
186
|
+
fs.writeFileSync(tailwindConfigPath, newTailwindConfig);
|
|
157
187
|
}
|
|
158
188
|
},
|
|
159
189
|
{
|
|
160
|
-
title: "Adding
|
|
190
|
+
title: "Adding directives to index.css...",
|
|
161
191
|
task: (_ctx, task) => {
|
|
162
192
|
const INDEX_CSS_PATH = path.join(rwPaths.web.src, "index.css");
|
|
163
193
|
const indexCSS = fs.readFileSync(INDEX_CSS_PATH, "utf-8");
|
|
164
|
-
if (
|
|
165
|
-
task.skip("
|
|
194
|
+
if (tailwindDirectivesExist(indexCSS)) {
|
|
195
|
+
task.skip("Directives already exist in index.css");
|
|
166
196
|
} else {
|
|
167
|
-
const newIndexCSS =
|
|
197
|
+
const newIndexCSS = tailwindImportsAndNotes.join("\n") + indexCSS;
|
|
168
198
|
fs.writeFileSync(INDEX_CSS_PATH, newIndexCSS);
|
|
169
199
|
}
|
|
170
200
|
}
|
|
@@ -245,9 +275,7 @@ Add \`import tailwindcss from '@tailwindcss/vite'\` to the top of the file and \
|
|
|
245
275
|
"activeClassName",
|
|
246
276
|
"errorClassName"
|
|
247
277
|
];
|
|
248
|
-
const fileAssociations = { "*.css": "tailwindcss" };
|
|
249
278
|
let newSettingsJson = {
|
|
250
|
-
["files.associations"]: fileAssociations,
|
|
251
279
|
["tailwindCSS.classAttributes"]: classAttributes
|
|
252
280
|
};
|
|
253
281
|
if (fs.existsSync(VS_CODE_SETTINGS_PATH)) {
|
|
@@ -265,13 +293,8 @@ Add \`import tailwindcss from '@tailwindcss/vite'\` to the top of the file and \
|
|
|
265
293
|
const mergedClassAttributes = Array.from(
|
|
266
294
|
/* @__PURE__ */ new Set([...classAttributes, ...originalTwClassAttributesJson])
|
|
267
295
|
);
|
|
268
|
-
const existingAssociations = originalSettingsJson["files.associations"];
|
|
269
296
|
newSettingsJson = {
|
|
270
297
|
...originalSettingsJson,
|
|
271
|
-
["files.associations"]: {
|
|
272
|
-
...existingAssociations && typeof existingAssociations === "object" && !Array.isArray(existingAssociations) ? existingAssociations : {},
|
|
273
|
-
...fileAssociations
|
|
274
|
-
},
|
|
275
298
|
["tailwindCSS.classAttributes"]: mergedClassAttributes
|
|
276
299
|
};
|
|
277
300
|
}
|
|
@@ -282,38 +305,34 @@ Add \`import tailwindcss from '@tailwindcss/vite'\` to the top of the file and \
|
|
|
282
305
|
}
|
|
283
306
|
},
|
|
284
307
|
{
|
|
285
|
-
title: "Adding tailwind
|
|
308
|
+
title: "Adding tailwind config entry in prettier...",
|
|
286
309
|
task: async (_ctx) => {
|
|
287
310
|
const prettierConfigPath = path.join(
|
|
288
311
|
rwPaths.base,
|
|
289
312
|
"prettier.config.cjs"
|
|
290
313
|
);
|
|
291
314
|
const prettierConfig = fs.readFileSync(prettierConfigPath, "utf-8");
|
|
292
|
-
const
|
|
293
|
-
|
|
315
|
+
const tailwindConfigPath = path.relative(
|
|
316
|
+
rwPaths.base,
|
|
317
|
+
path.posix.join(rwPaths.web.config, "tailwind.config.cjs")
|
|
318
|
+
).replaceAll("\\", "/");
|
|
294
319
|
let newPrettierConfig = prettierConfig;
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
320
|
+
if (newPrettierConfig.includes("tailwindConfig: ")) {
|
|
321
|
+
if (force) {
|
|
322
|
+
newPrettierConfig = newPrettierConfig.replace(
|
|
323
|
+
/tailwindConfig: .*(,)?/,
|
|
324
|
+
`tailwindConfig: './${tailwindConfigPath}',`
|
|
300
325
|
);
|
|
301
|
-
}
|
|
302
|
-
if (!stringEntryRegExp.test(newPrettierConfig)) {
|
|
326
|
+
} else {
|
|
303
327
|
throw new Error(
|
|
304
|
-
|
|
305
|
-
Set it to './${tailwindStylesheetPath}' yourself.`
|
|
328
|
+
"tailwindConfig setting already exists in prettier configuration.\nUse --force to override existing config."
|
|
306
329
|
);
|
|
307
330
|
}
|
|
308
|
-
newPrettierConfig = newPrettierConfig.replace(
|
|
309
|
-
stringEntryRegExp,
|
|
310
|
-
tailwindStylesheetEntry
|
|
311
|
-
);
|
|
312
331
|
} else {
|
|
313
332
|
newPrettierConfig = newPrettierConfig.replace(
|
|
314
333
|
/,(\n\s*)(\}\n?)$/,
|
|
315
334
|
`,
|
|
316
|
-
|
|
335
|
+
tailwindConfig: './${tailwindConfigPath}',$1$2`
|
|
317
336
|
);
|
|
318
337
|
}
|
|
319
338
|
fs.writeFileSync(prettierConfigPath, newPrettierConfig);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import j from "jscodeshift";
|
|
2
|
+
function transform(fileInfo) {
|
|
3
|
+
const root = j(fileInfo.source);
|
|
4
|
+
const imports = root.find(j.ImportDeclaration);
|
|
5
|
+
imports.at(-1).insertAfter(
|
|
6
|
+
j.importDeclaration(
|
|
7
|
+
[j.importSpecifier(j.identifier("storagePrismaExtension"))],
|
|
8
|
+
j.literal("./uploads.js")
|
|
9
|
+
)
|
|
10
|
+
);
|
|
11
|
+
root.find(j.VariableDeclaration, { declarations: [{ id: { name: "db" } }] }).forEach((path) => {
|
|
12
|
+
const dbDeclaration = path.node.declarations[0];
|
|
13
|
+
if (j.VariableDeclarator.check(dbDeclaration) && j.NewExpression.check(dbDeclaration.init)) {
|
|
14
|
+
throw new Error("RW_CODEMOD_ERR_OLD_FORMAT");
|
|
15
|
+
}
|
|
16
|
+
if (j.VariableDeclarator.check(dbDeclaration) && j.Expression.check(dbDeclaration.init)) {
|
|
17
|
+
const newInit = j.callExpression(
|
|
18
|
+
j.memberExpression(dbDeclaration.init, j.identifier("$extends")),
|
|
19
|
+
[j.identifier("storagePrismaExtension")]
|
|
20
|
+
);
|
|
21
|
+
dbDeclaration.init = newInit;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return root.toSource();
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
transform as default
|
|
28
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { APIGatewayEvent, Context } from 'aws-lambda'
|
|
2
|
+
|
|
3
|
+
import type { SignatureValidationArgs } from '@cedarjs/storage/UrlSigner'
|
|
4
|
+
|
|
5
|
+
import { urlSigner, fsStorage } from 'src/lib/uploads'
|
|
6
|
+
|
|
7
|
+
export const handler = async (event: APIGatewayEvent, _context: Context) => {
|
|
8
|
+
const fileToReturn = urlSigner.validateSignature(
|
|
9
|
+
event.queryStringParameters as SignatureValidationArgs
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
const { contents, type } = await fsStorage.read(fileToReturn)
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
statusCode: 200,
|
|
16
|
+
headers: {
|
|
17
|
+
'Content-Type': type,
|
|
18
|
+
},
|
|
19
|
+
body: contents,
|
|
20
|
+
}
|
|
21
|
+
}
|