-
-
Notifications
You must be signed in to change notification settings - Fork 994
refactor: created npm folder and modularized scripts #4192
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
Changes from 4 commits
5e57996
6ed3594
5f27ad2
2f4f22f
2d499cc
388dfda
b382cf6
075cead
728ad2b
9ab9cc3
91e952f
1402f9b
b40ab1e
5a83f3f
e10c132
dc99fc0
9d0fc09
241396c
7f34ffa
b4c0184
48c9b20
cf0fddd
e1b44fc
e239484
db991db
0a79ab8
4db1a6f
77baacd
6c2c115
6d9872f
3789564
0145bda
cff3857
7bfd418
f025abc
d06e25a
47eeb0b
a8335dc
ce9fc7c
96cec2a
c48f1fd
f7d9a43
f1192e5
b206429
98486af
85add6f
800f03d
f1b3dc6
8d2bf22
60cf2f9
2b13160
e8c2279
79da91f
8767b93
0b20bf4
cb4a589
ce2a5b7
27cf32b
592dd9a
f836a26
8ee27a7
9e68f76
833008f
8b501e2
1669b3c
82442c4
a1e8b82
a65c553
d8f51e0
75599a7
7109472
8363ce3
d0ad117
5fea48b
0176ece
1f39b40
c5c0b61
b043ffd
f688215
dd9d6e6
11502cc
748c003
34637bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { runBuildPostList } from './runners/build-post-list-runner'; | ||
| import { runBuildDashboard } from './runners/build-dashboard-runner'; | ||
| import { runBuildTools } from './runners/build-tools-runner'; | ||
| import { runCaseStudies } from './runners/case-studies-runner'; | ||
| import { runBuildNewsroomVideos } from './runners/build-newsroom-videos-runner'; | ||
| import { logger } from '../scripts/helpers/logger'; | ||
| async function main() { | ||
|
|
||
| let errorFaced: Boolean = false; | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| try { | ||
|
|
||
| try { | ||
| await runBuildPostList(); | ||
| } catch (err) { | ||
| errorFaced = true; | ||
| logger.error('Error building posts: ', err as Error); | ||
| } | ||
|
|
||
| try { | ||
| await runBuildDashboard(); | ||
| } catch (err) { | ||
| errorFaced = true; | ||
| logger.error('Error building dashboard: ', err as Error); | ||
| } | ||
|
|
||
| try { | ||
| await runBuildTools(); | ||
| } catch (err) { | ||
| errorFaced = true; | ||
| logger.error('Error building tools: ', err as Error); | ||
| } | ||
|
|
||
| try { | ||
| await runCaseStudies(); | ||
| } catch (err) { | ||
| errorFaced = true; | ||
| logger.error('Error building cases studies: ', err as Error); | ||
| } | ||
|
|
||
| try { | ||
| await runBuildNewsroomVideos(); | ||
| } catch (err) { | ||
| errorFaced = true; | ||
| logger.error('Error building newsroom videos: ', err as Error); | ||
| } | ||
|
|
||
| if (errorFaced) { | ||
| console.log("Some scripts faced error while running please check the console for more details") | ||
| } | ||
| else { | ||
| console.log('Successfully executed all build scripts'); | ||
| } | ||
| } catch (error) { | ||
| console.error('Error executing build scripts:', error); | ||
| throw new Error('Error executing build scripts: ', error as Error); | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| main(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file contains improper eslint formatting with tab width 4. Fix eslint errors in the file. |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,17 @@ | ||||||||||||||
| import { start } from "../scripts/dashboard/build-dashboard"; | ||||||||||||||
|
|
||||||||||||||
| import { dirname, resolve } from 'path'; | ||||||||||||||
| import { fileURLToPath } from 'url'; | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| const currentFilePath = fileURLToPath(import.meta.url); | ||||||||||||||
| const currentDirPath = dirname(currentFilePath); | ||||||||||||||
|
|
||||||||||||||
| export async function runBuildDashboard() { | ||||||||||||||
| try { | ||||||||||||||
| await start(resolve(currentDirPath, '..', '..', 'dashboard.json')); | ||||||||||||||
| } | ||||||||||||||
| catch (error) { | ||||||||||||||
| throw new Error('Error building dashboard: ', error as Error); | ||||||||||||||
| } | ||||||||||||||
|
||||||||||||||
| catch (error) { | |
| throw new Error('Error building dashboard: ', error as Error); | |
| } | |
| catch (error) { | |
| throw new Error('Error building dashboard', { cause: error as Error }); | |
| } |
🤖 Prompt for AI Agents
In npm/runners/build-dashboard-runner.ts around lines 14 to 16, the Error
constructor is incorrectly used with two arguments, where the second argument is
ignored. Fix this by passing the original error as the cause in an options
object, like new Error('Error building dashboard', { cause: error }). Also,
review the start function for similar incorrect Error constructor usage and
apply the same fix.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,17 @@ | ||||||||||||||||||||||||||||||||||||||
| import { buildNewsroomVideos } from "../scripts/build-newsroom-videos"; | ||||||||||||||||||||||||||||||||||||||
| import { dirname, resolve } from 'path'; | ||||||||||||||||||||||||||||||||||||||
| import { fileURLToPath } from 'url'; | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| const currentFilePath = fileURLToPath(import.meta.url); | ||||||||||||||||||||||||||||||||||||||
| const currentDirPath = dirname(currentFilePath); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| export async function runBuildNewsroomVideos() { | ||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||
| await buildNewsroomVideos(resolve(currentDirPath, '../../config', 'newsroom_videos.json')); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| catch (error) { | ||||||||||||||||||||||||||||||||||||||
| throw new Error('Error building dashboard: ', error as Error); | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
| export async function runBuildNewsroomVideos() { | |
| try { | |
| await buildNewsroomVideos(resolve(currentDirPath, '../../config', 'newsroom_videos.json')); | |
| } | |
| catch (error) { | |
| throw new Error('Error building dashboard: ', error as Error); | |
| export async function runBuildNewsroomVideos() { | |
| try { | |
| const projectRoot = resolve(currentDirPath, '../../..'); | |
| await buildNewsroomVideos(resolve(projectRoot, 'config', 'newsroom_videos.json')); | |
| } | |
| catch (error) { | |
| throw new Error( | |
| `Error building newsroom videos: ${(error as Error).message}`, | |
| { cause: error } | |
| ); | |
| } | |
| } |
🤖 Prompt for AI Agents
In npm/runners/build-newsroom-videos-runner.ts around lines 10 to 15, the path
resolution uses currentDirPath which points to npm/config instead of the
repository root, and the error message incorrectly references "dashboard"
instead of "newsroom videos". Fix this by adjusting the path to correctly
resolve from the repository root to the config file, and update the error
message to accurately say "Error building newsroom videos". Also, ensure the
error is properly included in the thrown Error object.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { buildPostList } from '../scripts/build-post-list'; | ||
| import { dirname, resolve } from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
|
|
||
| const currentFilePath = fileURLToPath(import.meta.url); | ||
| const currentDirPath = dirname(currentFilePath); | ||
| const projectRoot = resolve(currentDirPath, '../../'); | ||
|
|
||
|
|
||
| export async function runBuildPostList() { | ||
| const postDirectories = [ | ||
| [resolve(projectRoot, 'pages', 'blog'), '/blog'], | ||
| [resolve(projectRoot, 'pages', 'docs'), '/docs'], | ||
| [resolve(projectRoot, 'pages', 'about'), '/about'] | ||
| ]; | ||
|
|
||
| const basePath = resolve(projectRoot, 'pages'); | ||
| const writeFilePath = resolve(projectRoot, 'config', 'posts.json'); | ||
|
|
||
| try { | ||
| await buildPostList(postDirectories, basePath, writeFilePath); | ||
| } catch (err) { | ||
| throw new Error('Error building post list: ', err as Error); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { buildTools } from "../scripts/build-tools"; | ||
|
|
||
| import { dirname, resolve } from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
| import { logger } from "../scripts/helpers/logger"; | ||
|
|
||
| const currentFilePath = fileURLToPath(import.meta.url); | ||
| const currentDirPath = dirname(currentFilePath); | ||
|
|
||
| export async function runBuildTools() { | ||
| try { | ||
| const automatedToolsPath = resolve(currentDirPath, '../../config', 'tools-automated.json'); | ||
| const manualToolsPath = resolve(currentDirPath, '../../config', 'tools-manual.json'); | ||
| const toolsPath = resolve(currentDirPath, '../../config', 'tools.json'); | ||
| const tagsPath = resolve(currentDirPath, '../../config', 'all-tags.json'); | ||
|
|
||
sagarkori143 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath).catch((err) => { | ||
| logger.error('Failed to build tools:', err); | ||
| process.exit(1); | ||
| }); | ||
| } catch (error) { | ||
| throw new Error('Error building tools: ', error as Error); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { buildCaseStudiesList } from '../scripts/casestudies'; | ||
| import { dirname, resolve } from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
| import fs from 'fs'; | ||
|
|
||
| const currentFilePath = fileURLToPath(import.meta.url); | ||
| const currentDirPath = dirname(currentFilePath); | ||
| const projectRoot = resolve(currentDirPath, '../../'); | ||
|
|
||
| export async function runCaseStudies() { | ||
| try { | ||
| const caseStudyDirectory = resolve(projectRoot, 'config', 'casestudies'); | ||
|
|
||
| if (!fs.existsSync(caseStudyDirectory)) { | ||
| console.error(`Directory does not exist: ${caseStudyDirectory}`); | ||
| return; | ||
sagarkori143 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| const writeFilePath = resolve(projectRoot, 'config', 'casestudies.json'); | ||
| await buildCaseStudiesList(caseStudyDirectory, writeFilePath); | ||
| } catch (error) { | ||
| throw new Error('Error building case studies: ', error as Error); | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this index.ts script? All scripts will never be executed at same time.