-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed build process and added workflows to test dev and prod builds (#…
…2792) * Fixed build process * Moved import fixes to fix-imports dir * Fixed development errors * updated pr workflow to test dev and prod * Enabled introspection * Updated to ES module * Fix import sample data errors * Fixed PR workflow * Fixed PR workflow * Skip ssl verification for prod Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * improve code coverage and updated pr workflow * Added scripts for certs * Updated .gitignore * Added cert.pem and key.pem to gitignore * Updated PR workflow * Added empty certs dir * Remove .gitkeep * Updated certs dir * Added ssl version to pr workflow * Fixed github actions * Fixed node version in CI * Fixed ssl errors * Fixed existing processes at port 4000 * Added command to free port 4000 * Fixed errors * Fix port issues * Updated few packages * Updated node version to latest * Added coderabbitai changes * Fixed vulnerabilities * Update node-version to latest LTS version --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
- Loading branch information
1 parent
4b5c74f
commit 5c5b29a
Showing
72 changed files
with
8,007 additions
and
6,494 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v22.7.0 | ||
v22.12.0 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import fs from 'fs/promises'; | ||
import path from 'path'; | ||
|
||
const directoryPath = './build'; | ||
const oldImport = `import { express as voyagerMiddleware } from "graphql-voyager/middleware";`; | ||
const newImport = `import { express as voyagerMiddleware } from "graphql-voyager/middleware/index.js";`; | ||
|
||
async function replaceImports(dir) { | ||
try { | ||
const files = await fs.readdir(dir); | ||
|
||
for (const file of files) { | ||
const filePath = path.join(dir, file); | ||
const stat = await fs.stat(filePath); | ||
|
||
if (stat.isDirectory()) { | ||
await replaceImports(filePath); | ||
} else if (path.extname(file) === '.js') { | ||
let content = await fs.readFile(filePath, 'utf8'); | ||
|
||
if (content.includes(oldImport)) { | ||
content = content.replace(oldImport, newImport); | ||
await fs.writeFile(filePath, content, 'utf8'); | ||
console.log(`Updated graphql import in ${filePath}`); | ||
} | ||
} | ||
} | ||
} catch (error) { | ||
console.error('Error:', error); | ||
} | ||
} | ||
|
||
replaceImports(directoryPath); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { readdirSync, statSync, readFileSync, writeFileSync, existsSync } from 'fs'; | ||
import { join, extname, dirname, resolve } from 'path'; | ||
|
||
const directory = './build'; // Adjust this if the build output folder changes | ||
|
||
function fixImports(dir) { | ||
readdirSync(dir).forEach((file) => { | ||
const filePath = join(dir, file); | ||
|
||
if (statSync(filePath).isDirectory()) { | ||
fixImports(filePath); | ||
} else if (filePath.endsWith('.js')) { | ||
let content = readFileSync(filePath, 'utf-8'); | ||
|
||
// Fix missing extensions in import paths and add assert for JSON imports | ||
content = content.replace( | ||
/from\s+['"](\..*?)['"]/g, | ||
(match, path) => { | ||
const resolvedPath = resolve(dirname(filePath), path); | ||
|
||
// Handle directories and missing extensions | ||
if (existsSync(resolvedPath) && statSync(resolvedPath).isDirectory()) { | ||
return `from '${path}/index.js'`; | ||
} else if (!extname(path) && existsSync(`${resolvedPath}.js`)) { | ||
return `from '${path}.js'`; | ||
} | ||
|
||
// Add assert for JSON files | ||
if (path.endsWith('.json')) { | ||
return `from '${path}' with { type: 'json' }`; | ||
} | ||
|
||
// If the file or directory doesn't exist, leave the import unchanged | ||
return match; | ||
} | ||
); | ||
|
||
writeFileSync(filePath, content, 'utf-8'); | ||
} | ||
}); | ||
} | ||
|
||
fixImports(directory); | ||
console.log('Added index.js and .js extention to imports'); |
Oops, something went wrong.