@cedarjs/cli 7.0.0-canary.3259 → 7.0.0-rc.123
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 +1 -1
- package/dist/commands/deploy/baremetal.js +1 -1
- 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 +1 -2
- 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/dbAuthHandler.js +3 -23
- package/dist/commands/generate/directive/directiveHandler.js +1 -2
- package/dist/commands/generate/function/functionHandler.js +1 -2
- 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/package/filesTask.js +12 -9
- package/dist/commands/generate/package/packageHandler.js +4 -3
- 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/subscriptions/blank/blank.ts.template +1 -1
- package/dist/commands/generate/scaffold/scaffoldHandler.js +5 -10
- package/dist/commands/generate/scaffold/templates/components/NameForm.tsx.template +3 -3
- package/dist/commands/generate/scaffold/templates/lib/formatters.test.tsx.template +0 -11
- package/dist/commands/generate/scaffold/templates/lib/formatters.tsx.template +1 -13
- package/dist/commands/generate/script/scriptHandler.js +1 -2
- package/dist/commands/generate/sdl/sdlHandler.js +1 -2
- package/dist/commands/generate/secret/secret.js +1 -1
- package/dist/commands/generate/service/serviceHandler.js +38 -47
- package/dist/commands/generate/service/templates/service.ts.template +8 -22
- package/dist/commands/generate/service/templates/test.ts.template +1 -1
- 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/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/database/postgres.js +1 -1
- package/dist/commands/setup/database/postgresHandler.js +1 -3
- package/dist/commands/setup/deploy/providers/baremetalHandler.js +1 -2
- 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/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 -2
- 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 +7 -8
- 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/subscriptions/countdown/countdown.ts.template +1 -1
- package/dist/commands/setup/realtime/templates/subscriptions/newMessage/newMessage.ts.template +1 -1
- 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 +1 -2
- 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 -256
- 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 +100 -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 +25 -6
- 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 +18 -18
- 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/login.oauth.tsx.template +0 -164
- package/dist/commands/generate/dbAuth/templates/signup.oauth.tsx.template +0 -147
- 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 -153
- package/dist/commands/setup/tenancy/templates/InvitePage.tsx.template +0 -63
- 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 -59
- package/dist/commands/setup/tenancy/templates/organizations.sdl.ts.template +0 -89
- package/dist/commands/setup/tenancy/templates/organizations.test.ts.template +0 -389
- 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/schemaPrisma.js +0 -41
- package/dist/commands/setup/uploads/serverFile.js +0 -151
- 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 -89
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "7.0.0-
|
|
3
|
+
"version": "7.0.0-rc.123",
|
|
4
4
|
"description": "The CedarJS Command Line",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -36,17 +36,17 @@
|
|
|
36
36
|
"@babel/preset-typescript": "7.29.7",
|
|
37
37
|
"@babel/traverse": "7.29.8",
|
|
38
38
|
"@babel/types": "7.29.8",
|
|
39
|
-
"@cedarjs/api-server": "7.0.0-
|
|
40
|
-
"@cedarjs/babel-config": "7.0.0-
|
|
41
|
-
"@cedarjs/cli-helpers": "7.0.0-
|
|
42
|
-
"@cedarjs/internal": "7.0.0-
|
|
43
|
-
"@cedarjs/prerender": "7.0.0-
|
|
44
|
-
"@cedarjs/project-config": "7.0.0-
|
|
45
|
-
"@cedarjs/structure": "7.0.0-
|
|
46
|
-
"@cedarjs/telemetry": "7.0.0-
|
|
47
|
-
"@cedarjs/utils": "7.0.0-
|
|
48
|
-
"@cedarjs/vite": "7.0.0-
|
|
49
|
-
"@cedarjs/web-server": "7.0.0-
|
|
39
|
+
"@cedarjs/api-server": "7.0.0-rc.123",
|
|
40
|
+
"@cedarjs/babel-config": "7.0.0-rc.123",
|
|
41
|
+
"@cedarjs/cli-helpers": "7.0.0-rc.123",
|
|
42
|
+
"@cedarjs/internal": "7.0.0-rc.123",
|
|
43
|
+
"@cedarjs/prerender": "7.0.0-rc.123",
|
|
44
|
+
"@cedarjs/project-config": "7.0.0-rc.123",
|
|
45
|
+
"@cedarjs/structure": "7.0.0-rc.123",
|
|
46
|
+
"@cedarjs/telemetry": "7.0.0-rc.123",
|
|
47
|
+
"@cedarjs/utils": "7.0.0-rc.123",
|
|
48
|
+
"@cedarjs/vite": "7.0.0-rc.123",
|
|
49
|
+
"@cedarjs/web-server": "7.0.0-rc.123",
|
|
50
50
|
"@listr2/prompt-adapter-enquirer": "4.3.2",
|
|
51
51
|
"@opentelemetry/api": "1.9.1",
|
|
52
52
|
"@opentelemetry/core": "2.11.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@opentelemetry/resources": "2.11.0",
|
|
55
55
|
"@opentelemetry/sdk-trace-node": "2.11.0",
|
|
56
56
|
"@opentelemetry/semantic-conventions": "1.43.0",
|
|
57
|
-
"@prisma/internals": "7.
|
|
57
|
+
"@prisma/internals": "7.8.0",
|
|
58
58
|
"ansis": "4.4.0",
|
|
59
59
|
"archiver": "7.0.1",
|
|
60
60
|
"boxen": "5.1.2",
|
|
@@ -79,9 +79,10 @@
|
|
|
79
79
|
"pascalcase": "1.0.0",
|
|
80
80
|
"pluralize": "8.0.0",
|
|
81
81
|
"portfinder": "1.0.38",
|
|
82
|
-
"prettier": "3.9.
|
|
82
|
+
"prettier": "3.9.8",
|
|
83
83
|
"prisma": "7.10.0",
|
|
84
84
|
"prompts": "2.4.2",
|
|
85
|
+
"semver": "7.8.5",
|
|
85
86
|
"smol-toml": "1.8.0",
|
|
86
87
|
"srvx": "0.12.8",
|
|
87
88
|
"string-env-interpolation": "1.0.1",
|
|
@@ -90,14 +91,13 @@
|
|
|
90
91
|
"title-case": "3.0.3",
|
|
91
92
|
"unionfs": "4.6.0",
|
|
92
93
|
"uuid": "11.1.1",
|
|
93
|
-
"verkit": "0.5.0",
|
|
94
94
|
"yargs": "17.7.3"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
97
|
-
"@cedarjs/framework-tools": "7.0.0-
|
|
98
|
-
"@prisma/dmmf": "7.
|
|
97
|
+
"@cedarjs/framework-tools": "7.0.0-rc.123",
|
|
98
|
+
"@prisma/dmmf": "7.8.0",
|
|
99
99
|
"@types/archiver": "^7.0.0",
|
|
100
|
-
"memfs": "4.
|
|
100
|
+
"memfs": "4.78.1",
|
|
101
101
|
"node-ssh": "13.2.1",
|
|
102
102
|
"ts-dedent": "2.3.0",
|
|
103
103
|
"typescript": "5.9.3",
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { ${fragmentName} } from 'types/graphql'
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
CellSuccessProps,<% if (afterQuery || isEmpty) { %>
|
|
5
|
-
DataObject,<% } %>
|
|
6
|
-
} from '@cedarjs/web'
|
|
7
|
-
|
|
8
|
-
// A parent Cell spreads this fragment by name in its own QUERY, and passes
|
|
9
|
-
// the matching field down as the `${camelName}` prop - no import needed,
|
|
10
|
-
// just render <${pascalName}Cell />:
|
|
11
|
-
//
|
|
12
|
-
// query FindSomething($id: Int!) {
|
|
13
|
-
// something(id: $id) {
|
|
14
|
-
// id
|
|
15
|
-
// ...${fragmentName}
|
|
16
|
-
// }
|
|
17
|
-
// }
|
|
18
|
-
//
|
|
19
|
-
// <${pascalName}Cell ${camelName}={something} />
|
|
20
|
-
export const FRAGMENT = gql`
|
|
21
|
-
fragment ${fragmentName} on ${fragmentOnType} {
|
|
22
|
-
id
|
|
23
|
-
}
|
|
24
|
-
`
|
|
25
|
-
<% if (isEmpty) { %>
|
|
26
|
-
export const isEmpty = (
|
|
27
|
-
data: DataObject,
|
|
28
|
-
{ isDataEmpty }: { isDataEmpty: (data: DataObject) => boolean },
|
|
29
|
-
) => {
|
|
30
|
-
return isDataEmpty(data)
|
|
31
|
-
}
|
|
32
|
-
<% } %><% if (afterQuery) { %>
|
|
33
|
-
export const afterQuery = (data: DataObject): DataObject => {
|
|
34
|
-
return data
|
|
35
|
-
}
|
|
36
|
-
<% } %>
|
|
37
|
-
export const Empty = () => <div>Empty</div>
|
|
38
|
-
|
|
39
|
-
export const Success = ({
|
|
40
|
-
${camelName},
|
|
41
|
-
}: CellSuccessProps<{ ${camelName}: ${fragmentName} }>) => {
|
|
42
|
-
return <div>{JSON.stringify(${camelName})}</div>
|
|
43
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
-
|
|
3
|
-
import { Empty, Success } from './${pascalName}Cell'
|
|
4
|
-
import { standard } from './${pascalName}Cell.mock'
|
|
5
|
-
|
|
6
|
-
const meta: Meta = {
|
|
7
|
-
title: 'Cells/${pascalName}Cell',
|
|
8
|
-
tags: ['autodocs']
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default meta
|
|
12
|
-
|
|
13
|
-
export const empty: StoryObj<typeof Empty> = {
|
|
14
|
-
render: () => {
|
|
15
|
-
return Empty ? <Empty /> : <></>
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const success: StoryObj<typeof Success> = {
|
|
20
|
-
render: (args) => {
|
|
21
|
-
return Success ? <Success {...standard()} {...args} /> : <></>
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { render } from '@cedarjs/testing/web'
|
|
2
|
-
|
|
3
|
-
import { Empty, Success } from './${pascalName}Cell'
|
|
4
|
-
import { standard } from './${pascalName}Cell.mock'
|
|
5
|
-
|
|
6
|
-
// Generated boilerplate tests do not account for all circumstances
|
|
7
|
-
// and can fail without adjustments, e.g. Float and DateTime types.
|
|
8
|
-
// Please refer to the RedwoodJS Testing Docs:
|
|
9
|
-
// https://cedarjs.com/docs/testing#testing-cells
|
|
10
|
-
// https://cedarjs.com/docs/testing#expect-type-considerations
|
|
11
|
-
|
|
12
|
-
describe('${pascalName}Cell', () => {
|
|
13
|
-
it('renders Empty successfully', async () => {
|
|
14
|
-
expect(() => {
|
|
15
|
-
render(<Empty />)
|
|
16
|
-
}).not.toThrow()
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
// When you're ready to test the actual output of your component render
|
|
20
|
-
// you could test that, for example, certain text is present:
|
|
21
|
-
//
|
|
22
|
-
// 1. import { screen } from '@cedarjs/testing/web'
|
|
23
|
-
// 2. Add test: expect(screen.getByText('Hello, world')).toBeInTheDocument()
|
|
24
|
-
|
|
25
|
-
it('renders Success successfully', async () => {
|
|
26
|
-
expect(() => {
|
|
27
|
-
render(<Success ${camelName}={standard().${camelName}} />)
|
|
28
|
-
}).not.toThrow()
|
|
29
|
-
})
|
|
30
|
-
})
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Form,
|
|
5
|
-
Label,
|
|
6
|
-
TextField,
|
|
7
|
-
PasswordField,
|
|
8
|
-
Submit,
|
|
9
|
-
FieldError,
|
|
10
|
-
} from '@cedarjs/forms'
|
|
11
|
-
import { Link, navigate, routes } from '@cedarjs/router'
|
|
12
|
-
import { Metadata } from '@cedarjs/web'
|
|
13
|
-
import { toast, Toaster } from '@cedarjs/web/toast'
|
|
14
|
-
|
|
15
|
-
import { getOAuthUrl, getOAuthError } from '@cedarjs/auth-dbauth-web/oauth'
|
|
16
|
-
|
|
17
|
-
import { useAuth } from 'src/auth'
|
|
18
|
-
|
|
19
|
-
const LoginPage = () => {
|
|
20
|
-
const { isAuthenticated, logIn } = useAuth()
|
|
21
|
-
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
if (isAuthenticated) {
|
|
24
|
-
navigate(routes.home())
|
|
25
|
-
}
|
|
26
|
-
}, [isAuthenticated])
|
|
27
|
-
|
|
28
|
-
// Surface an error that the OAuth provider redirect sent back, e.g.
|
|
29
|
-
// after the user cancels the provider's consent screen.
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
const oauthError = getOAuthError(window.location.search)
|
|
32
|
-
|
|
33
|
-
if (oauthError) {
|
|
34
|
-
toast.error('Could not log in: ' + oauthError)
|
|
35
|
-
}
|
|
36
|
-
}, [])
|
|
37
|
-
|
|
38
|
-
const ${usernameCamelCase}Ref = useRef<HTMLInputElement>(null)
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
${usernameCamelCase}Ref.current?.focus()
|
|
41
|
-
}, [])
|
|
42
|
-
|
|
43
|
-
const onSubmit = async (data: Record<string, string>) => {
|
|
44
|
-
const response = await logIn({ username: data.${usernameCamelCase}, password: data.${passwordCamelCase} })
|
|
45
|
-
|
|
46
|
-
if (response.message) {
|
|
47
|
-
toast(response.message)
|
|
48
|
-
} else if (response.error) {
|
|
49
|
-
toast.error(response.error)
|
|
50
|
-
} else {
|
|
51
|
-
toast.success('Welcome back!')
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<>
|
|
57
|
-
<Metadata title="Login" />
|
|
58
|
-
|
|
59
|
-
<main className="rw-main">
|
|
60
|
-
<Toaster toastOptions={{ className: 'rw-toast', duration: 6000 }} />
|
|
61
|
-
<div className="rw-scaffold rw-login-container">
|
|
62
|
-
<div className="rw-segment">
|
|
63
|
-
<header className="rw-segment-header">
|
|
64
|
-
<h2 className="rw-heading rw-heading-secondary">Login</h2>
|
|
65
|
-
</header>
|
|
66
|
-
|
|
67
|
-
<div className="rw-segment-main">
|
|
68
|
-
<div className="rw-form-wrapper">
|
|
69
|
-
<Form onSubmit={onSubmit} className="rw-form-wrapper">
|
|
70
|
-
<Label
|
|
71
|
-
name="${usernameCamelCase}"
|
|
72
|
-
className="rw-label"
|
|
73
|
-
errorClassName="rw-label rw-label-error"
|
|
74
|
-
>
|
|
75
|
-
${usernameTitleCase}
|
|
76
|
-
</Label>
|
|
77
|
-
<TextField
|
|
78
|
-
name="${usernameCamelCase}"
|
|
79
|
-
className="rw-input"
|
|
80
|
-
errorClassName="rw-input rw-input-error"
|
|
81
|
-
ref={${usernameCamelCase}Ref}
|
|
82
|
-
validation={{
|
|
83
|
-
required: {
|
|
84
|
-
value: true,
|
|
85
|
-
message: '${usernameTitleCase} is required',
|
|
86
|
-
},
|
|
87
|
-
}}
|
|
88
|
-
/>
|
|
89
|
-
|
|
90
|
-
<FieldError name="${usernameCamelCase}" className="rw-field-error" />
|
|
91
|
-
|
|
92
|
-
<Label
|
|
93
|
-
name="${passwordCamelCase}"
|
|
94
|
-
className="rw-label"
|
|
95
|
-
errorClassName="rw-label rw-label-error"
|
|
96
|
-
>
|
|
97
|
-
${passwordTitleCase}
|
|
98
|
-
</Label>
|
|
99
|
-
<PasswordField
|
|
100
|
-
name="${passwordCamelCase}"
|
|
101
|
-
className="rw-input"
|
|
102
|
-
errorClassName="rw-input rw-input-error"
|
|
103
|
-
autoComplete="current-password"
|
|
104
|
-
validation={{
|
|
105
|
-
required: {
|
|
106
|
-
value: true,
|
|
107
|
-
message: '${passwordTitleCase} is required',
|
|
108
|
-
},
|
|
109
|
-
}}
|
|
110
|
-
/>
|
|
111
|
-
|
|
112
|
-
<div className="rw-forgot-link">
|
|
113
|
-
<Link
|
|
114
|
-
to={routes.forgotPassword()}
|
|
115
|
-
className="rw-forgot-link"
|
|
116
|
-
>
|
|
117
|
-
Forgot ${passwordTitleCase}?
|
|
118
|
-
</Link>
|
|
119
|
-
</div>
|
|
120
|
-
|
|
121
|
-
<FieldError name="${passwordCamelCase}" className="rw-field-error" />
|
|
122
|
-
|
|
123
|
-
<div className="rw-button-group">
|
|
124
|
-
<Submit className="rw-button rw-button-blue">Login</Submit>
|
|
125
|
-
</div>
|
|
126
|
-
</Form>
|
|
127
|
-
|
|
128
|
-
{/*
|
|
129
|
-
* OAuth login buttons. Delete the ones for providers you
|
|
130
|
-
* haven't configured in `cedar setup auth dbAuth --oauth`.
|
|
131
|
-
* Each link is a full-page navigation to the provider's
|
|
132
|
-
* authorize route — it must not be turned into a fetch/XHR
|
|
133
|
-
* call.
|
|
134
|
-
*/}
|
|
135
|
-
<div className="rw-button-group">
|
|
136
|
-
<a
|
|
137
|
-
href={getOAuthUrl('google', { flow: 'login' })}
|
|
138
|
-
className="rw-button rw-button-blue"
|
|
139
|
-
>
|
|
140
|
-
Continue with Google
|
|
141
|
-
</a>
|
|
142
|
-
<a
|
|
143
|
-
href={getOAuthUrl('github', { flow: 'login' })}
|
|
144
|
-
className="rw-button rw-button-blue"
|
|
145
|
-
>
|
|
146
|
-
Continue with GitHub
|
|
147
|
-
</a>
|
|
148
|
-
</div>
|
|
149
|
-
</div>
|
|
150
|
-
</div>
|
|
151
|
-
</div>
|
|
152
|
-
<div className="rw-login-link">
|
|
153
|
-
<span>Don't have an account?</span>{' '}
|
|
154
|
-
<Link to={routes.signup()} className="rw-link">
|
|
155
|
-
Sign up!
|
|
156
|
-
</Link>
|
|
157
|
-
</div>
|
|
158
|
-
</div>
|
|
159
|
-
</main>
|
|
160
|
-
</>
|
|
161
|
-
)
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export default LoginPage
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Form,
|
|
5
|
-
Label,
|
|
6
|
-
TextField,
|
|
7
|
-
PasswordField,
|
|
8
|
-
FieldError,
|
|
9
|
-
Submit,
|
|
10
|
-
} from '@cedarjs/forms'
|
|
11
|
-
import { Link, navigate, routes } from '@cedarjs/router'
|
|
12
|
-
import { Metadata } from '@cedarjs/web'
|
|
13
|
-
import { toast, Toaster } from '@cedarjs/web/toast'
|
|
14
|
-
|
|
15
|
-
import { getOAuthUrl } from '@cedarjs/auth-dbauth-web/oauth'
|
|
16
|
-
|
|
17
|
-
import { useAuth } from 'src/auth'
|
|
18
|
-
|
|
19
|
-
const SignupPage = () => {
|
|
20
|
-
const { isAuthenticated, signUp } = useAuth()
|
|
21
|
-
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
if (isAuthenticated) {
|
|
24
|
-
navigate(routes.home())
|
|
25
|
-
}
|
|
26
|
-
}, [isAuthenticated])
|
|
27
|
-
|
|
28
|
-
// focus on ${usernameLowerCase} box on page load
|
|
29
|
-
const ${usernameCamelCase}Ref = useRef<HTMLInputElement>(null)
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
${usernameCamelCase}Ref.current?.focus()
|
|
32
|
-
}, [])
|
|
33
|
-
|
|
34
|
-
const onSubmit = async (data: Record<string, string>) => {
|
|
35
|
-
const response = await signUp({ username: data.${usernameCamelCase}, password: data.${passwordCamelCase} })
|
|
36
|
-
|
|
37
|
-
if (response.message) {
|
|
38
|
-
toast(response.message)
|
|
39
|
-
} else if (response.error) {
|
|
40
|
-
toast.error(response.error)
|
|
41
|
-
} else {
|
|
42
|
-
// user is signed in automatically
|
|
43
|
-
toast.success('Welcome!')
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<>
|
|
49
|
-
<Metadata title="Signup" />
|
|
50
|
-
|
|
51
|
-
<main className="rw-main">
|
|
52
|
-
<Toaster toastOptions={{ className: 'rw-toast', duration: 6000 }} />
|
|
53
|
-
<div className="rw-scaffold rw-login-container">
|
|
54
|
-
<div className="rw-segment">
|
|
55
|
-
<header className="rw-segment-header">
|
|
56
|
-
<h2 className="rw-heading rw-heading-secondary">Signup</h2>
|
|
57
|
-
</header>
|
|
58
|
-
|
|
59
|
-
<div className="rw-segment-main">
|
|
60
|
-
<div className="rw-form-wrapper">
|
|
61
|
-
<Form onSubmit={onSubmit} className="rw-form-wrapper">
|
|
62
|
-
<Label
|
|
63
|
-
name="${usernameCamelCase}"
|
|
64
|
-
className="rw-label"
|
|
65
|
-
errorClassName="rw-label rw-label-error"
|
|
66
|
-
>
|
|
67
|
-
${usernameTitleCase}
|
|
68
|
-
</Label>
|
|
69
|
-
<TextField
|
|
70
|
-
name="${usernameCamelCase}"
|
|
71
|
-
className="rw-input"
|
|
72
|
-
errorClassName="rw-input rw-input-error"
|
|
73
|
-
ref={${usernameCamelCase}Ref}
|
|
74
|
-
validation={{
|
|
75
|
-
required: {
|
|
76
|
-
value: true,
|
|
77
|
-
message: '${usernameTitleCase} is required',
|
|
78
|
-
},
|
|
79
|
-
}}
|
|
80
|
-
/>
|
|
81
|
-
<FieldError name="${usernameCamelCase}" className="rw-field-error" />
|
|
82
|
-
|
|
83
|
-
<Label
|
|
84
|
-
name="${passwordCamelCase}"
|
|
85
|
-
className="rw-label"
|
|
86
|
-
errorClassName="rw-label rw-label-error"
|
|
87
|
-
>
|
|
88
|
-
${passwordTitleCase}
|
|
89
|
-
</Label>
|
|
90
|
-
<PasswordField
|
|
91
|
-
name="${passwordCamelCase}"
|
|
92
|
-
className="rw-input"
|
|
93
|
-
errorClassName="rw-input rw-input-error"
|
|
94
|
-
autoComplete="current-password"
|
|
95
|
-
validation={{
|
|
96
|
-
required: {
|
|
97
|
-
value: true,
|
|
98
|
-
message: '${passwordTitleCase} is required',
|
|
99
|
-
},
|
|
100
|
-
}}
|
|
101
|
-
/>
|
|
102
|
-
<FieldError name="${passwordCamelCase}" className="rw-field-error" />
|
|
103
|
-
|
|
104
|
-
<div className="rw-button-group">
|
|
105
|
-
<Submit className="rw-button rw-button-blue">
|
|
106
|
-
Sign Up
|
|
107
|
-
</Submit>
|
|
108
|
-
</div>
|
|
109
|
-
</Form>
|
|
110
|
-
|
|
111
|
-
{/*
|
|
112
|
-
* OAuth signup buttons. Delete the ones for providers you
|
|
113
|
-
* haven't configured in `cedar setup auth dbAuth --oauth`.
|
|
114
|
-
* Each link is a full-page navigation to the provider's
|
|
115
|
-
* authorize route — it must not be turned into a fetch/XHR
|
|
116
|
-
* call.
|
|
117
|
-
*/}
|
|
118
|
-
<div className="rw-button-group">
|
|
119
|
-
<a
|
|
120
|
-
href={getOAuthUrl('google', { flow: 'signup' })}
|
|
121
|
-
className="rw-button rw-button-blue"
|
|
122
|
-
>
|
|
123
|
-
Continue with Google
|
|
124
|
-
</a>
|
|
125
|
-
<a
|
|
126
|
-
href={getOAuthUrl('github', { flow: 'signup' })}
|
|
127
|
-
className="rw-button rw-button-blue"
|
|
128
|
-
>
|
|
129
|
-
Continue with GitHub
|
|
130
|
-
</a>
|
|
131
|
-
</div>
|
|
132
|
-
</div>
|
|
133
|
-
</div>
|
|
134
|
-
</div>
|
|
135
|
-
<div className="rw-login-link">
|
|
136
|
-
<span>Already have an account?</span>{' '}
|
|
137
|
-
<Link to={routes.login()} className="rw-link">
|
|
138
|
-
Log in!
|
|
139
|
-
</Link>
|
|
140
|
-
</div>
|
|
141
|
-
</div>
|
|
142
|
-
</main>
|
|
143
|
-
</>
|
|
144
|
-
)
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export default SignupPage
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import j from "jscodeshift";
|
|
2
|
-
function buildMembershipsSelectProperty() {
|
|
3
|
-
const snippet = `
|
|
4
|
-
const __tenancySnippet = {
|
|
5
|
-
memberships: {
|
|
6
|
-
select: {
|
|
7
|
-
id: true,
|
|
8
|
-
organizationId: true,
|
|
9
|
-
role: true,
|
|
10
|
-
organization: { select: { id: true, slug: true, name: true } },
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
}
|
|
14
|
-
`;
|
|
15
|
-
const property = j.withParser("ts")(snippet).find(j.ObjectProperty, { key: { name: "memberships" } }).nodes()[0];
|
|
16
|
-
if (!property) {
|
|
17
|
-
throw new Error("CEDAR_CODEMOD_ERR_AUTH_SHAPE_NOT_FOUND");
|
|
18
|
-
}
|
|
19
|
-
return property;
|
|
20
|
-
}
|
|
21
|
-
function transform(fileInfo) {
|
|
22
|
-
const root = j.withParser("tsx")(fileInfo.source);
|
|
23
|
-
let selectFound = false;
|
|
24
|
-
root.find(j.CallExpression, {
|
|
25
|
-
callee: {
|
|
26
|
-
type: "MemberExpression",
|
|
27
|
-
object: {
|
|
28
|
-
type: "MemberExpression",
|
|
29
|
-
object: { name: "db" },
|
|
30
|
-
property: { name: "user" }
|
|
31
|
-
},
|
|
32
|
-
property: { name: "findUnique" }
|
|
33
|
-
}
|
|
34
|
-
}).forEach((path) => {
|
|
35
|
-
const [args] = path.node.arguments;
|
|
36
|
-
if (!j.ObjectExpression.check(args)) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const selectProperty = args.properties.find(
|
|
40
|
-
(prop) => j.ObjectProperty.check(prop) && j.Identifier.check(prop.key) && prop.key.name === "select"
|
|
41
|
-
);
|
|
42
|
-
if (!selectProperty || !j.ObjectProperty.check(selectProperty) || !j.ObjectExpression.check(selectProperty.value)) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const alreadyHasMemberships = selectProperty.value.properties.some(
|
|
46
|
-
(prop) => j.ObjectProperty.check(prop) && j.Identifier.check(prop.key) && prop.key.name === "memberships"
|
|
47
|
-
);
|
|
48
|
-
if (!alreadyHasMemberships) {
|
|
49
|
-
selectProperty.value.properties.push(buildMembershipsSelectProperty());
|
|
50
|
-
}
|
|
51
|
-
selectFound = true;
|
|
52
|
-
});
|
|
53
|
-
if (!selectFound) {
|
|
54
|
-
throw new Error("CEDAR_CODEMOD_ERR_AUTH_SHAPE_NOT_FOUND");
|
|
55
|
-
}
|
|
56
|
-
const tenancyExportSnippet = `export { hasOrgRole, requireMembership } from '@cedarjs/tenancy'
|
|
57
|
-
`;
|
|
58
|
-
const tenancyExport = j.withParser("ts")(tenancyExportSnippet).find(j.ExportNamedDeclaration).nodes()[0];
|
|
59
|
-
root.find(j.Program).forEach((path) => {
|
|
60
|
-
path.node.body.push(tenancyExport);
|
|
61
|
-
});
|
|
62
|
-
return root.toSource();
|
|
63
|
-
}
|
|
64
|
-
export {
|
|
65
|
-
transform as default
|
|
66
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import j from "jscodeshift";
|
|
2
|
-
const DEFAULT_GLOBAL_MODELS = ["user", "organization", "membership"];
|
|
3
|
-
function transform(fileInfo, _api, options) {
|
|
4
|
-
const root = j.withParser("tsx")(fileInfo.source);
|
|
5
|
-
const tenantField = typeof options.tenantField === "string" ? options.tenantField : void 0;
|
|
6
|
-
const imports = root.find(j.ImportDeclaration);
|
|
7
|
-
imports.at(-1).insertAfter(
|
|
8
|
-
j.importDeclaration(
|
|
9
|
-
[j.importSpecifier(j.identifier("createTenancyExtension"))],
|
|
10
|
-
j.literal("@cedarjs/tenancy")
|
|
11
|
-
)
|
|
12
|
-
);
|
|
13
|
-
const configProperties = [
|
|
14
|
-
...tenantField ? [
|
|
15
|
-
j.objectProperty(
|
|
16
|
-
j.identifier("tenantField"),
|
|
17
|
-
j.stringLiteral(tenantField)
|
|
18
|
-
)
|
|
19
|
-
] : [],
|
|
20
|
-
j.objectProperty(
|
|
21
|
-
j.identifier("models"),
|
|
22
|
-
j.objectExpression([
|
|
23
|
-
j.objectProperty(
|
|
24
|
-
j.identifier("allExcept"),
|
|
25
|
-
j.arrayExpression(
|
|
26
|
-
DEFAULT_GLOBAL_MODELS.map((name) => j.stringLiteral(name))
|
|
27
|
-
)
|
|
28
|
-
)
|
|
29
|
-
])
|
|
30
|
-
)
|
|
31
|
-
];
|
|
32
|
-
let found = false;
|
|
33
|
-
root.find(j.VariableDeclaration, { declarations: [{ id: { name: "db" } }] }).forEach((path) => {
|
|
34
|
-
const dbDeclaration = path.node.declarations[0];
|
|
35
|
-
if (!j.VariableDeclarator.check(dbDeclaration)) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (j.NewExpression.check(dbDeclaration.init)) {
|
|
39
|
-
throw new Error("CEDAR_CODEMOD_ERR_OLD_FORMAT");
|
|
40
|
-
}
|
|
41
|
-
if (!j.Expression.check(dbDeclaration.init)) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
found = true;
|
|
45
|
-
const extensionCall = j.callExpression(
|
|
46
|
-
j.identifier("createTenancyExtension"),
|
|
47
|
-
[j.objectExpression(configProperties)]
|
|
48
|
-
);
|
|
49
|
-
dbDeclaration.init = j.callExpression(
|
|
50
|
-
j.memberExpression(dbDeclaration.init, j.identifier("$extends")),
|
|
51
|
-
[extensionCall]
|
|
52
|
-
);
|
|
53
|
-
});
|
|
54
|
-
if (!found) {
|
|
55
|
-
throw new Error("CEDAR_CODEMOD_ERR_DB_SHAPE_NOT_FOUND");
|
|
56
|
-
}
|
|
57
|
-
return root.toSource().replace(
|
|
58
|
-
"createTenancyExtension(",
|
|
59
|
-
"createTenancyExtension<typeof prismaClient>("
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
export {
|
|
63
|
-
transform as default
|
|
64
|
-
};
|