Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label override flags for dbAuth generator #6440

Merged
merged 47 commits into from Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
bf85e88
initial ability to pass label arguements
Josh-Walker-GM Sep 22, 2022
e6c3249
Added remaining parameters to auth template files
Josh-Walker-GM Sep 22, 2022
b793aed
Added no default value check in order to pass tests
Josh-Walker-GM Sep 22, 2022
2dbc0ad
Merge branch 'main' into dbAuth-labels-flag
Josh-Walker-GM Sep 22, 2022
f8350b0
Apply suggestions: reduce templateVars duplication
Josh-Walker-GM Sep 23, 2022
a2644be
Apply suggestions: replace ternary
Josh-Walker-GM Sep 23, 2022
0ef86c2
Added missing templateVars declaration
Josh-Walker-GM Sep 23, 2022
4c1d50f
Merge remote-tracking branch 'upstream/main' into dbAuth-labels-flag
Josh-Walker-GM Oct 3, 2022
9c952a8
Renamed template vars
Josh-Walker-GM Oct 3, 2022
1a32a51
Renamed flags to include 'label', added prompts and used listr2 tasks…
Josh-Walker-GM Oct 3, 2022
ce35751
Updated yarn.lock
Josh-Walker-GM Oct 3, 2022
a1a3e9f
Added default values within function
Josh-Walker-GM Oct 3, 2022
9eb3629
Updated web authn page template - not tested
Josh-Walker-GM Oct 3, 2022
e8cf844
Moved WebAuthn into listr
Josh-Walker-GM Oct 4, 2022
6a76388
Some tidying up
Josh-Walker-GM Oct 4, 2022
b3eb646
Fix default webauthn flag value check
Josh-Walker-GM Oct 4, 2022
8fb5998
Merge 'upstream/main' into dbAuth-labels-flag
Josh-Walker-GM Oct 9, 2022
5eb8e5f
Added enquirer option and other minor fixes
Josh-Walker-GM Oct 10, 2022
ee087d3
Added tests for prompts
Josh-Walker-GM Oct 10, 2022
a0d562f
Add web.app to the mocked getPaths
Josh-Walker-GM Oct 12, 2022
5a480a7
Fix password label and add listr2 options to task handler
Josh-Walker-GM Oct 12, 2022
9323bb7
Added snapshot tests
Josh-Walker-GM Oct 12, 2022
164385e
Merge remote-tracking branch 'upstream/main' into dbAuth-labels-flag
Josh-Walker-GM Oct 12, 2022
d28a124
Added --username-label and --password-label flags to the docs for rw …
Josh-Walker-GM Oct 12, 2022
f5fa114
Normalise paths within tests
Josh-Walker-GM Oct 12, 2022
532f35b
Added test for custom labels and webauthn enabled
Josh-Walker-GM Oct 12, 2022
6efc01b
Add flags to prevent test project creation prompting the user
Josh-Walker-GM Oct 12, 2022
ba54a2d
Updated test project fixtures
Josh-Walker-GM Oct 12, 2022
9f6f8db
Merge branch 'main' into dbAuth-labels-flag
cannikin Nov 7, 2022
f16d4ca
Merge remote-tracking branch 'upstream/main' into dbAuth-labels-flag
Josh-Walker-GM Nov 9, 2022
d38f18b
update snapshots and set mockfiles before test describe
Josh-Walker-GM Nov 13, 2022
8b785ae
Merge remote-tracking branch 'upstream/main' into dbAuth-labels-flag
Josh-Walker-GM Nov 13, 2022
aa08422
Merge branch 'main' into dbAuth-labels-flag
Tobbe Nov 13, 2022
999d69d
Customised auth variables similar to labels
Josh-Walker-GM Nov 13, 2022
b40a32b
updated test fixtures
Josh-Walker-GM Nov 13, 2022
763bcc7
Update test snapshots
Josh-Walker-GM Nov 13, 2022
d79294a
Updated to use customised variable names based on label option
Josh-Walker-GM Nov 14, 2022
3e60e0f
Add missing dbAuth command test
Josh-Walker-GM Nov 14, 2022
c2bb55d
Merge branch 'main' into dbAuth-labels-flag
cannikin Nov 17, 2022
3ddb62a
Merge branch 'main' into dbAuth-labels-flag
Josh-Walker-GM Nov 21, 2022
be6e9f8
Merge remote-tracking branch 'upstream/main' into dbAuth-labels-flag
Josh-Walker-GM Nov 22, 2022
bcc2759
Merge branch 'main' into dbAuth-labels-flag
Tobbe Nov 24, 2022
31b8966
Merge branch 'main' into dbAuth-labels-flag
Tobbe Nov 24, 2022
846a2a7
Merge branch 'main' into dbAuth-labels-flag
Tobbe Nov 24, 2022
fbd1f80
Merge branch 'main' into dbAuth-labels-flag
cannikin Dec 1, 2022
8d83aee
Merge branch 'main' into dbAuth-labels-flag
Josh-Walker-GM Dec 5, 2022
0a387ac
Merge branch 'main' into dbAuth-labels-flag
cannikin Dec 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 50 additions & 0 deletions packages/cli/src/commands/generate/dbAuth/dbAuth.js
Expand Up @@ -92,6 +92,16 @@ export const builder = (yargs) => {
description: 'Include WebAuthn support (TouchID/FaceID)',
type: 'boolean',
})
.option('username', {
default: 'username',
description: 'Override default form label for username field',
type: 'string',
})
.option('password', {
default: 'password',
description: 'Override default form label for password field',
type: 'string',
})

.epilogue(
`Also see the ${terminalLink(
Expand All @@ -114,9 +124,21 @@ export const files = ({
skipReset,
skipSignup,
webAuthn,
username,
password,
}) => {
const files = []

const usernameLowercase =
username == null ? 'username' : username.toLowerCase()
Josh-Walker-GM marked this conversation as resolved.
Show resolved Hide resolved
const usernameCapitalised =
usernameLowercase.charAt(0).toUpperCase() + usernameLowercase.slice(1)

const passwordLowercase =
password == null ? 'password' : password.toLowerCase()
Josh-Walker-GM marked this conversation as resolved.
Show resolved Hide resolved
const passwordCapitalised =
passwordLowercase.charAt(0).toUpperCase() + passwordLowercase.slice(1)

if (!skipForgot) {
files.push(
templateForComponentFile({
Expand All @@ -126,6 +148,12 @@ export const files = ({
webPathSection: 'pages',
generator: 'dbAuth',
templatePath: 'forgotPassword.tsx.template',
templateVars: {
usernameLowercase,
usernameCapitalised,
passwordLowercase,
passwordCapitalised,
},
Josh-Walker-GM marked this conversation as resolved.
Show resolved Hide resolved
})
)
}
Expand All @@ -141,6 +169,12 @@ export const files = ({
templatePath: webAuthn
? 'login.webAuthn.tsx.template'
: 'login.tsx.template',
templateVars: {
usernameLowercase,
usernameCapitalised,
passwordLowercase,
passwordCapitalised,
},
Josh-Walker-GM marked this conversation as resolved.
Show resolved Hide resolved
})
)
}
Expand All @@ -154,6 +188,12 @@ export const files = ({
webPathSection: 'pages',
generator: 'dbAuth',
templatePath: 'resetPassword.tsx.template',
templateVars: {
usernameLowercase,
usernameCapitalised,
passwordLowercase,
passwordCapitalised,
},
Josh-Walker-GM marked this conversation as resolved.
Show resolved Hide resolved
})
)
}
Expand All @@ -167,6 +207,12 @@ export const files = ({
webPathSection: 'pages',
generator: 'dbAuth',
templatePath: 'signup.tsx.template',
templateVars: {
usernameLowercase,
usernameCapitalised,
passwordLowercase,
passwordCapitalised,
},
Josh-Walker-GM marked this conversation as resolved.
Show resolved Hide resolved
})
)
}
Expand Down Expand Up @@ -213,6 +259,8 @@ const tasks = ({
skipReset,
skipSignup,
webAuthn,
username,
password,
}) => {
return new Listr(
[
Expand All @@ -228,6 +276,8 @@ const tasks = ({
skipReset,
skipSignup,
webAuthn,
username,
password,
}),
{
overwriteExisting: force,
Expand Down
Expand Up @@ -30,23 +30,23 @@ const ForgotPasswordPage = () => {
// been invoked, let the user know how to get the link to reset their
// password (sent in email, perhaps?)
toast.success(
'A link to reset your password was sent to ' + response.email
'A link to reset your ${passwordLowercase} was sent to ' + response.email
)
navigate(routes.login())
}
}

return (
<>
<MetaTags title="Forgot Password" />
<MetaTags title="Forgot ${passwordCapitalised}" />

<main className="rw-main">
<Toaster toastOptions={{ className: 'rw-toast', duration: 6000 }} />
<div className="rw-scaffold rw-login-container">
<div className="rw-segment">
<header className="rw-segment-header">
<h2 className="rw-heading rw-heading-secondary">
Forgot Password
Forgot ${passwordCapitalised}
</h2>
</header>

Expand All @@ -59,15 +59,18 @@ const ForgotPasswordPage = () => {
className="rw-label"
errorClassName="rw-label rw-label-error"
>
Username
${usernameCapitalised}
</Label>
<TextField
name="username"
className="rw-input"
errorClassName="rw-input rw-input-error"
ref={usernameRef}
validation={{
required: true,
required: {
value: true,
message: '${usernameCapitalised} is required',
},
}}
/>

Expand Down
Expand Up @@ -60,7 +60,7 @@ const LoginPage = () => {
className="rw-label"
errorClassName="rw-label rw-label-error"
>
Username
${usernameCapitalised}
</Label>
<TextField
name="username"
Expand All @@ -70,7 +70,7 @@ const LoginPage = () => {
validation={{
required: {
value: true,
message: 'Username is required',
message: '${usernameCapitalised} is required',
},
}}
/>
Expand All @@ -82,7 +82,7 @@ const LoginPage = () => {
className="rw-label"
errorClassName="rw-label rw-label-error"
>
Password
${passwordCapitalised}
</Label>
<PasswordField
name="password"
Expand All @@ -92,7 +92,7 @@ const LoginPage = () => {
validation={{
required: {
value: true,
message: 'Password is required',
message: '${passwordCapitalised} is required',
},
}}
/>
Expand All @@ -102,7 +102,7 @@ const LoginPage = () => {
to={routes.forgotPassword()}
className="rw-forgot-link"
>
Forgot Password?
Forgot ${passwordCapitalised}?
</Link>
</div>

Expand Down
Expand Up @@ -44,7 +44,7 @@ const LoginPage = ({ type }) => {
}
}, [loading, isAuthenticated])

// focus on the username field as soon as the page loads
// focus on the ${usernameLowercase} field as soon as the page loads
const usernameRef = useRef()
useEffect(() => {
usernameRef.current && usernameRef.current.focus()
Expand Down Expand Up @@ -146,7 +146,7 @@ const LoginPage = ({ type }) => {
className="rw-label"
errorClassName="rw-label rw-label-error"
>
Username
${usernameCapitalised}
</Label>
<TextField
name="username"
Expand All @@ -157,7 +157,7 @@ const LoginPage = ({ type }) => {
validation={{
required: {
value: true,
message: 'Username is required',
message: '${usernameCapitalised} is required',
},
}}
/>
Expand All @@ -169,7 +169,7 @@ const LoginPage = ({ type }) => {
className="rw-label"
errorClassName="rw-label rw-label-error"
>
Password
${passwordCapitalised}
</Label>
<PasswordField
name="password"
Expand All @@ -179,14 +179,14 @@ const LoginPage = ({ type }) => {
validation={{
required: {
value: true,
message: 'Password is required',
message: '${passwordCapitalised} is required',
},
}}
/>

<div className="rw-forgot-link">
<Link to={routes.forgotPassword()} className="rw-forgot-link">
Forgot Password?
Forgot ${passwordCapitalised}?
</Link>
</div>

Expand Down Expand Up @@ -217,7 +217,7 @@ const LoginPage = ({ type }) => {
<div className="rw-login-link">
<span>or login with </span>{' '}
<a href="?type=password" className="rw-link">
username and password
${usernameLowercase} and ${passwordLowercase}
</a>
</div>
)
Expand Down
Expand Up @@ -58,15 +58,15 @@ const ResetPasswordPage = ({ resetToken }: { resetToken: string }) => {

return (
<>
<MetaTags title="Reset Password" />
<MetaTags title="Reset ${passwordCapitalised}" />

<main className="rw-main">
<Toaster toastOptions={{ className: 'rw-toast', duration: 6000 }} />
<div className="rw-scaffold rw-login-container">
<div className="rw-segment">
<header className="rw-segment-header">
<h2 className="rw-heading rw-heading-secondary">
Reset Password
Reset ${passwordCapitalised}
</h2>
</header>

Expand All @@ -79,7 +79,7 @@ const ResetPasswordPage = ({ resetToken }: { resetToken: string }) => {
className="rw-label"
errorClassName="rw-label rw-label-error"
>
New Password
New ${passwordCapitalised}
</Label>
<PasswordField
name="password"
Expand All @@ -91,7 +91,7 @@ const ResetPasswordPage = ({ resetToken }: { resetToken: string }) => {
validation={{
required: {
value: true,
message: 'Password is required',
message: 'New ${passwordCapitalised} is required',
},
}}
/>
Expand Down
Expand Up @@ -23,7 +23,7 @@ const SignupPage = () => {
}
}, [isAuthenticated])

// focus on email box on page load
// focus on ${usernameLowercase} box on page load
const usernameRef = useRef<HTMLInputElement>(null)
useEffect(() => {
usernameRef.current?.focus()
Expand Down Expand Up @@ -62,7 +62,7 @@ const SignupPage = () => {
className="rw-label"
errorClassName="rw-label rw-label-error"
>
Username
${usernameCapitalised}
</Label>
<TextField
name="username"
Expand All @@ -72,7 +72,7 @@ const SignupPage = () => {
validation={{
required: {
value: true,
message: 'Username is required',
message: '${usernameCapitalised} is required',
},
}}
/>
Expand All @@ -83,7 +83,7 @@ const SignupPage = () => {
className="rw-label"
errorClassName="rw-label rw-label-error"
>
Password
${passwordCapitalised}
</Label>
<PasswordField
name="password"
Expand All @@ -93,7 +93,7 @@ const SignupPage = () => {
validation={{
required: {
value: true,
message: 'Password is required',
message: '${passwordCapitalised} is required',
},
}}
/>
Expand Down