Skip to content

Commit 6208a06

Browse files
committed
Fix dbAuth setup and TW setup
1 parent faa245f commit 6208a06

File tree

7 files changed

+18
-12
lines changed

7 files changed

+18
-12
lines changed

packages/auth-providers/dbAuth/setup/src/setupHandler.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ export const createAuthDecoderFunction = {
185185

186186
const content = fs.readFileSync(graphqlPath, 'utf-8')
187187

188+
if (!content) {
189+
throw new Error('Could not read ' + graphqlPath)
190+
}
191+
188192
let newContent = content.replace(
189193
'import { getCurrentUser } from',
190194
'import { cookieName, getCurrentUser } from',
@@ -205,6 +209,8 @@ export const createAuthDecoderFunction = {
205209
}
206210

207211
if (!newContent.includes('import { cookieName')) {
212+
console.error('unexpected content\n')
213+
console.error(newContent)
208214
throw new Error('Failed to import cookieName')
209215
}
210216

packages/cli-helpers/src/auth/authTasks.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import {
1818

1919
import { apiSideFiles, generateUniqueFileNames } from './authFiles.js'
2020

21-
const AUTH_PROVIDER_HOOK_IMPORT = `import { AuthProvider, useAuth } from './auth'`
22-
const AUTH_HOOK_IMPORT = `import { useAuth } from './auth'`
21+
const AUTH_PROVIDER_HOOK_IMPORT = `import { AuthProvider, useAuth } from './auth.js'`
22+
const AUTH_HOOK_IMPORT = `import { useAuth } from './auth.js'`
2323

2424
export const getWebAppPath = () => getPaths().web.app
2525

@@ -110,15 +110,15 @@ export const addApiConfig = ({
110110
}
111111

112112
const hasCurrentUserImport =
113-
/(^import {.*?getCurrentUser(?!getCurrentUser).*?} from ['"]src\/lib\/auth['"])/s.test(
113+
/(^import {.*?getCurrentUser(?!getCurrentUser).*?} from ['"]src\/lib\/auth(?:\.js)['"])/s.test(
114114
newContent,
115115
)
116116

117117
if (!hasCurrentUserImport) {
118118
// add import statement
119119
newContent = newContent.replace(
120-
/^(import { db } from ['"]src\/lib\/db['"])$/m,
121-
`import { getCurrentUser } from 'src/lib/auth'\n$1`,
120+
/^(import { db } from ['"]src\/lib\/db(?:\.js)['"])$/m,
121+
`import { getCurrentUser } from 'src/lib/auth.js'\n$1`,
122122
)
123123

124124
// add object to handler

packages/cli/src/commands/setup/ui/libraries/tailwindcssHandler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ export const handler = async ({ force, install }) => {
375375
task: async (_ctx) => {
376376
const prettierConfigPath = path.join(
377377
rwPaths.base,
378-
'prettier.config.js',
378+
'prettier.config.cjs',
379379
)
380380
// Add tailwindcss ordering plugin to prettier
381381
const prettierConfig = fs.readFileSync(prettierConfigPath, 'utf-8')
@@ -413,7 +413,7 @@ export const handler = async ({ force, install }) => {
413413
task: async (_ctx, task) => {
414414
const prettierConfigPath = path.join(
415415
rwPaths.base,
416-
'prettier.config.js',
416+
'prettier.config.cjs',
417417
)
418418
// Add tailwindcss ordering plugin to prettier
419419
const prettierConfig = fs.readFileSync(prettierConfigPath, 'utf-8')

packages/create-cedar-app/templates/js/scripts/seed.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// import { db } from 'api/src/lib/db'
1+
// import { db } from 'api/src/lib/db.js'
22

33
// Manually apply seeds via the `yarn rw prisma db seed` command.
44
//

packages/create-cedar-app/templates/ts/scripts/seed.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// import { db } from 'api/src/lib/db'
1+
// import { db } from 'api/src/lib/db.js'
22

33
// Manually apply seeds via the `yarn rw prisma db seed` command.
44
//

packages/project-config/src/paths.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export const getBaseDirFromFile = (file: string) => {
156156
*/
157157
export const resolveFile = (
158158
filePath: string,
159-
extensions: string[] = ['.js', '.tsx', '.ts', '.jsx', '.mjs', '.mts'],
159+
extensions: string[] = ['.js', '.tsx', '.ts', '.jsx', '.mjs', '.mts', '.cjs'],
160160
): string | null => {
161161
for (const extension of extensions) {
162162
const p = `${filePath}${extension}`

tasks/test-project/codemods/seed.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ export default (file, api) => {
6969

7070
// Uncomment the db import line
7171
newSource = newSource.replace(
72-
"// import { db } from 'api/src/lib/db'",
73-
"import { db } from 'api/src/lib/db'",
72+
"// import { db } from 'api/src/lib/db.js'",
73+
"import { db } from 'api/src/lib/db.js'",
7474
)
7575

7676
return newSource

0 commit comments

Comments
 (0)