Skip to content

Commit

Permalink
fix(graph): update CLI event types (#4916)
Browse files Browse the repository at this point in the history
* feat: interim commit

* fix: pass config around

* feat: open codegen working

* fix: various type errors

* feat: track operations doc id in memory

* fix: various bugs in graph flow

* chore: update dep

* fix: refactor Graph codegen module singleton and call sites

* fix: commit unnecessary eslint suggestion

* fix: remove bad warnings

* fix: update docs

* feat: detect included codegen modules

* fix: commit unnecessary eslint suggestion

* fix: formatting

* chore: update dep

* fix: update snapshots

* fix: commit unnecessary eslint suggestion

* fix: update tests

* fix: update dep

* fix: update snapshots

* fix: support windows filename in tests

* feat: fix graph config monitoring and handle new UI metadata requirements

* fix: bad merge

* fix: typo

* fix: address PR comments

* fix: update graph event types
  • Loading branch information
sgrove authored Aug 10, 2022
1 parent 585d91e commit 91f4ab2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
14 changes: 7 additions & 7 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
"multiparty": "^4.2.1",
"netlify": "^12.0.0",
"netlify-headers-parser": "^6.0.2",
"netlify-onegraph-internal": "0.6.2",
"netlify-onegraph-internal": "0.7.0",
"netlify-redirect-parser": "^13.0.5",
"netlify-redirector": "^0.2.1",
"node-fetch": "^2.6.0",
Expand Down
10 changes: 8 additions & 2 deletions src/lib/one-graph/cli-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const monitorCLISessionEvents = (input) => {

const frequency = 5000
// 30 minutes
const defaultHeartbeatFrequency = 1_800_000
const defaultHeartbeatFrequency = 30_000
let shouldClose = false
let nextMarkActiveHeartbeat = defaultHeartbeatFrequency

Expand All @@ -95,8 +95,10 @@ const monitorCLISessionEvents = (input) => {
appId,
sessionId: currentSessionId,
})

const heartbeatIntervalms = fullSession.session.cliHeartbeatIntervalMs || defaultHeartbeatFrequency
nextMarkActiveHeartbeat = heartbeatIntervalms

const markCLISessionActiveResult = await OneGraphClient.executeMarkCliSessionActiveHeartbeat(
graphJwt.jwt,
site.id,
Expand Down Expand Up @@ -640,7 +642,11 @@ ${JSON.stringify(payload, null, 2)}`)
sessionId,
payload: {
editor,
filePaths: files.map((file) => file.filePath),
// @ts-expect-error
files: files.map((file) => ({
name: file.name,
filePath: file.filePath,
})),
},
audience: 'UI',
}
Expand Down
6 changes: 4 additions & 2 deletions src/lib/one-graph/cli-netlify-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const setNetlifyTomlCodeGeneratorModule = ({ codegenModuleImportPath, siteRoot }
let filepath

try {
const filepathArr = [...siteRoot.split(path.sep), 'netlify.toml']
const filepathArr = ['/', ...siteRoot.split(path.sep), 'netlify.toml']
filepath = path.resolve(...filepathArr)
const configText = fs.readFileSync(filepath, 'utf-8')

Expand Down Expand Up @@ -585,7 +585,7 @@ const generateHandlerSourceByOperationId = ({
* @param {string} input.operationId The operationId to use when generating the handler
* @param {object} input.handlerOptions The options to use when generating the handler
* @param {(message: string) => void=} input.logger A function that if provided will be used to log messages
* @returns {Array<{filePath: string, prettierSuccess: boolean}> | undefined} An array of the generated handler filepaths
* @returns {Array<{filePath: string, name:string, prettierSuccess: boolean}> | undefined} An array of the generated handler filepaths
*/
const generateHandlerByOperationId = ({ generate, handlerOptions, netlifyGraphConfig, operationId, schema }) => {
let currentOperationsDoc = readGraphQLOperationsSourceFile(netlifyGraphConfig)
Expand Down Expand Up @@ -618,6 +618,7 @@ const generateHandlerByOperationId = ({ generate, handlerOptions, netlifyGraphCo
return
}

/** @type {Array<{filePath: string, name:string, prettierSuccess: boolean}>} */
const results = []

exportedFiles.forEach((exportedFile) => {
Expand Down Expand Up @@ -650,6 +651,7 @@ const generateHandlerByOperationId = ({ generate, handlerOptions, netlifyGraphCo
runPrettier(absoluteFilename)

results.push({
name: filenameArr.slice(-1)[0],
filePath: absoluteFilename,
prettierSuccess: true,
})
Expand Down

1 comment on commit 91f4ab2

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Benchmark results

Package size: 228 MB

Please sign in to comment.