From 070b2ae04b60bb832e7f22aebc243c1ec0114444 Mon Sep 17 00:00:00 2001 From: Josh GM Walker <56300765+Josh-Walker-GM@users.noreply.github.com> Date: Wed, 11 Sep 2024 23:17:09 +0100 Subject: [PATCH 1/2] handle double quotes too --- packages/cli-helpers/src/auth/authTasks.ts | 8 ++++---- packages/cli/src/lib/index.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/cli-helpers/src/auth/authTasks.ts b/packages/cli-helpers/src/auth/authTasks.ts index 4682c89204f1..b81e3122570b 100644 --- a/packages/cli-helpers/src/auth/authTasks.ts +++ b/packages/cli-helpers/src/auth/authTasks.ts @@ -109,14 +109,14 @@ export const addApiConfig = ({ } const hasCurrentUserImport = - /(^import {.*?getCurrentUser(?!getCurrentUser).*?} from 'src\/lib\/auth')/s.test( + /(^import {.*?getCurrentUser(?!getCurrentUser).*?} from ['"]src\/lib\/auth['"])/s.test( newContent, ) if (!hasCurrentUserImport) { // add import statement newContent = newContent.replace( - /^(import { db } from 'src\/lib\/db')$/m, + /^(import { db } from ['"]src\/lib\/db['"])$/m, `import { getCurrentUser } from 'src/lib/auth'\n$1`, ) @@ -140,7 +140,7 @@ const addAuthImportToApp = (content: string) => { const contentLines = content.split('\n') // Find the last import line that's not a .css or .scss import const importIndex = contentLines.findLastIndex((line: string) => - /^\s*import (?!.*(?:.css'|.scss'))/.test(line), + /^\s*import (?!.*(?:.css['"]|.scss['"]))/.test(line), ) // After the import found above, insert a blank line followed by the @@ -154,7 +154,7 @@ const addAuthImportToRoutes = (content: string) => { const contentLines = content.split('\n') // Find the last import line that's not a .css or .scss import const importIndex = contentLines.findLastIndex((line: string) => - /^\s*import (?!.*(?:.css'|.scss'))/.test(line), + /^\s*import (?!.*(?:.css['"]|.scss['"]))/.test(line), ) // After the import found above, insert a blank line followed by the diff --git a/packages/cli/src/lib/index.js b/packages/cli/src/lib/index.js index 0150ba32f6e9..e3b64a0023d4 100644 --- a/packages/cli/src/lib/index.js +++ b/packages/cli/src/lib/index.js @@ -444,7 +444,7 @@ export const addScaffoldImport = () => { } appJsContents = appJsContents.replace( - "import './index.css'", + /import ['"]\.\/index\.css['"]/, "import './index.css'\nimport './scaffold.css'\n", ) writeFile(appJsPath, appJsContents, { overwriteExisting: true }) From f0da7b77568b250de36434a17aed29f7fe2965f0 Mon Sep 17 00:00:00 2001 From: Josh GM Walker <56300765+Josh-Walker-GM@users.noreply.github.com> Date: Wed, 11 Sep 2024 23:44:20 +0100 Subject: [PATCH 2/2] changelog entry --- .changesets/11534.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changesets/11534.md diff --git a/.changesets/11534.md b/.changesets/11534.md new file mode 100644 index 000000000000..e765781df95c --- /dev/null +++ b/.changesets/11534.md @@ -0,0 +1,3 @@ +- fix(cli): handle both single and double quotes during dbAuth setup (#11534) by @Josh-Walker-GM + +If you had changed your prettier config to use double quotes instead of the default single quotes then the `yarn rw setup auth dbAuth` would fail. This change fixes that command to work regardless of quote flavour.