Skip to content
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

chore(gatsby): Convert jobsV2 reducer to TS #23708

Merged
merged 9 commits into from
May 11, 2020
Merged

Conversation

gabrieluizramos
Copy link
Contributor

Description

In order to continue the conversion, this PR converts reducers/jobsv2 to TS.

Related Issues

Related to #21995

@gabrieluizramos gabrieluizramos requested a review from a team as a code owner May 2, 2020 19:58
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label May 2, 2020
@gabrieluizramos gabrieluizramos changed the title Convert jobsv2 reducer to TS Convert jobsV2 reducer to TS May 2, 2020
@gabrieluizramos gabrieluizramos force-pushed the ts/jobsv2-reducer branch 2 times, most recently from 2c7de34 to c065df4 Compare May 2, 2020 20:33
Copy link
Contributor

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

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

Thanks! Just a few changes related to behaviour when jobs aren't found.

packages/gatsby/src/bootstrap/remove-stale-jobs.ts Outdated Show resolved Hide resolved
packages/gatsby/src/redux/reducers/jobsv2.ts Outdated Show resolved Hide resolved
packages/gatsby/src/redux/reducers/jobsv2.ts Outdated Show resolved Hide resolved
@ascorbic ascorbic added status: inkteam assigned and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels May 4, 2020
Comment on lines 103 to 109
export interface IGatsbyJobV2 {
job: IGatsbyJobContent
plugin: IGatsbyPlugin
job?: IGatsbyJobContent
plugin?: IGatsbyPlugin
traceId?: string
result?: string[]
inputPaths?: string[]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for these changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that were some types that I didn't get right at the beggining, but now things are becoming more clear to me.

I'm removing the optional for the job, plugin, result and inputPaths keys inside this interface now. Since we actually set it inside the reducer we actually need the result and inputPaths in this interface. Am I right?

Co-authored-by: Ward Peeters <ward@coding-tech.com>
@wardpeet
Copy link
Contributor

wardpeet commented May 6, 2020

Sorry for not being super helpful before. Long day 😅.

You should make 2 types, 1 is the jobInput & the jobResult.

* @typedef {BaseJobInterface & JobInputInterface} JobInput

JobResult should be just an object, it could be anything but has to be an object.

* @return {Promise<object>}

@gabrieluizramos
Copy link
Contributor Author

gabrieluizramos commented May 6, 2020

@wardpeet No worries! You guys are being super helpful actually!

But I think I didn't get it right yet...
The job input looks a little bit like the IGatsbyJobContent, are they the same?

Thought about updating it with a BaseJobInterface. The related types would be something like:

export interface IGatsbyJobContent {
  name: string
  outputDir: string
  args: Record<string, any>
  inputPaths: string[]
  contentDigest: string
  plugin: IGatsbyPlugin
}

export type IGatsbyJobResult = Promise<Record<string, any>>

export interface IGatsbyJobV2 {
  job: IGatsbyJobContent
  plugin: IGatsbyPlugin
  traceId?: string
  result: IGatsbyJobResult
  inputPaths: string[]
}

// and the actions

export interface ICreateJobV2Action {
  type: `CREATE_JOB_V2`
  payload: {
    job: IGatsbyJobV2["job"]
    plugin: IGatsbyJobV2["plugin"]
  }
}

export interface IEndJobV2Action {
  type: `END_JOB_V2`
  payload: {
    jobContentDigest: string
    result: IGatsbyJobResult
  }
}

export interface IRemoveStaleJobV2Action {
  type: `REMOVE_STALE_JOB_V2`
  payload: {
    contentDigest: string
  }
}

Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

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

It seems like we have to do some cleanup here...

import { InternalJobInterface, JobResultInterface } from "../utils/jobs-manager"

export interface IGatsbyCreateJobV2 {
  job: InternalJobInterface
  plugin: IGatsbyPlugin
}
export interface IGatsbyCompleteJobV2 {
  result: JobResultInterface
  inputPaths: InternalJobInterface["inputPaths"]
}
jobsV2: {
  incomplete: Map<Identifier, IGatsbyCreateJobV2>
  complete: Map<Identifier, IGatsbyCompleteJobV2>
}

packages/gatsby/src/redux/reducers/jobsv2.ts Show resolved Hide resolved
packages/gatsby/src/redux/reducers/jobsv2.ts Outdated Show resolved Hide resolved
packages/gatsby/src/redux/reducers/jobsv2.ts Outdated Show resolved Hide resolved
packages/gatsby/src/redux/types.ts Outdated Show resolved Hide resolved
packages/gatsby/src/redux/types.ts Outdated Show resolved Hide resolved
@gabrieluizramos
Copy link
Contributor Author

@wardpeet Awesome! Thank you very much! I've already pushed the changes.

@wardpeet wardpeet changed the title Convert jobsV2 reducer to TS chore(gatsby): Convert jobsV2 reducer to TS May 6, 2020
@wardpeet wardpeet added the bot: merge on green Gatsbot will merge these PRs automatically when all tests passes label May 6, 2020
wardpeet
wardpeet previously approved these changes May 6, 2020
Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

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

Awesome work! You're a beast!

@gabrieluizramos
Copy link
Contributor Author

@wardpeet Thank you very much! You guys are awesome!!!

@gabrieluizramos
Copy link
Contributor Author

Hi @ascorbic ! I think that maybe you still need to approve this PR. Can you help us?

Copy link
Contributor

@blainekasten blainekasten left a comment

Choose a reason for hiding this comment

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

This looks great to me, let's merge it!

Thank you so much for contributing to our TypeScript refactor! We have more work to do and we would love to have you stay involved in our transition. Please submit more PRs! 💜

@gatsbybot gatsbybot merged commit 49dfc6f into master May 11, 2020
@delete-merged-branch delete-merged-branch bot deleted the ts/jobsv2-reducer branch May 11, 2020 13:42
KyleAMathews added a commit that referenced this pull request May 13, 2020
commit 9bd54be
Author: Hashim Warren <hashim@gatsbyjs.com>
Date:   Mon May 11 16:31:31 2020 -0400

    (chore)Update Incremental Builds blog post with list (#23981)

    * Update steps with ordered list

    * Update docs/blog/2020-04-22-announcing-incremental-builds/index.md

    Co-authored-by: Matt Kane <matt@gatsbyjs.com>

    * Update docs/blog/2020-04-22-announcing-incremental-builds/index.md

    Co-authored-by: Matt Kane <matt@gatsbyjs.com>

    * Update link and SEO title

    * chore: format

    Co-authored-by: Matt Kane <matt@gatsbyjs.com>
    Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com>

commit e8b6eea
Author: shannonbux <32467162+shannonbux@users.noreply.github.com>
Date:   Mon May 11 10:37:30 2020 -0700

    fixed capitalization

commit f457912
Author: Diogo Capela <diogocapela@gmail.com>
Date:   Mon May 11 18:04:08 2020 +0100

    chore(showcase): Add Zona Digital to Gatsby Showcase (#23980)

    Co-authored-by: Capela <diogo.capela@mindera.com>
    Co-authored-by: Matt Kane <matt@gatsbyjs.com>

commit eb0f0d8
Author: Mike Dane <mikedane94@gmail.com>
Date:   Tue May 12 02:42:34 2020 +1000

    removed space on bootstrap finished time (#23925)

    Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com>

commit c7e952b
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Mon May 11 17:39:08 2020 +0100

    chore: update www (#23971)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>

commit 224e84e
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Mon May 11 17:38:30 2020 +0100

    fix: update starters and examples (#23972)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>

commit 7b74535
Author: Raz Lifshitz <30860151+razrez@users.noreply.github.com>
Date:   Mon May 11 19:13:43 2020 +0300

    Update sites.yml (#23938)

    * Update sites.yml

    Added ofrilifshitz.com to sites.yml

    * chore: format

    Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com>

commit e5a2461
Author: Matt Kane <matt@gatsbyjs.com>
Date:   Mon May 11 17:11:20 2020 +0100

    Add redirect for Vercel docs (#23979)

commit 441f32a
Author: Christian Rackerseder <git@echooff.de>
Date:   Mon May 11 17:27:38 2020 +0200

    Rename ZEIT Now to Vercel (#23961)

commit 7a23392
Author: Dede Hamzah <dehamzah@users.noreply.github.com>
Date:   Mon May 11 21:45:23 2020 +0700

    fix: handle nullish announcementRef to fix client side redirect error (#23956)

commit 49dfc6f
Author: Gabriel Ramos <gabriel.luiz.ramos@gmail.com>
Date:   Mon May 11 10:42:17 2020 -0300

    chore(gatsby): Convert jobsV2 reducer to TS (#23708)

    * chore(ts): convert jobsv2 reducer to TS

    * Update packages/gatsby/src/redux/reducers/jobsv2.ts

    Co-authored-by: Ward Peeters <ward@coding-tech.com>

    * refactor(pr): refactor based on PR comments

    * Update packages/gatsby/src/redux/reducers/jobsv2.ts

    Co-authored-by: Ward Peeters <ward@coding-tech.com>

    * fix(lint): fix lint error

    * add result typing to jobs-manager

    Co-authored-by: Ward Peeters <ward@coding-tech.com>

commit c5144ea
Author: Rajeesh C V <cvrajeesh@gmail.com>
Date:   Mon May 11 18:53:21 2020 +0530

    chore(docs): add Clodui deployment guide (#23587)

    * chore(docs): add Clodui deployment guide

    * update Clodui deployment doc with review comments

    * Update docs/docs/deploying-to-clodui.md

    * Update docs/docs/deploying-to-clodui.md

    * Update docs/docs/deploying-to-clodui.md

    * Update docs/docs/deploying-to-clodui.md

    * chore: format

    Co-authored-by: Obinna Ekwuno <obinnacodes@gmail.com>
    Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com>

commit c34bd66
Author: Michal Piechowiak <misiek.piechowiak@gmail.com>
Date:   Mon May 11 12:54:24 2020 +0200

    chore(release): Publish

     - gatsby-admin@0.1.22
     - gatsby-cli@2.12.16
     - gatsby-recipes@0.1.15
     - gatsby-theme-blog-core@1.4.22
     - gatsby-theme-blog@1.5.22
     - gatsby-theme-notes@1.3.22
     - gatsby-theme-ui-preset@0.0.12
     - gatsby@2.21.22

commit f7dc43f
Author: Albert Lash <31164347+albertlincoln@users.noreply.github.com>
Date:   Mon May 11 11:52:59 2020 +0100

    fix(gatsby-cli): don't fail when using `--log-pages` and/or `--write-to-file` (#23951)

    * Adding new cli options for page optimization

    * prettier

    * make them hidden, add some description as well as comment about why they are hidden

    Co-authored-by: Michal Piechowiak <misiek.piechowiak@gmail.com>

commit 88056f0
Author: Michal Piechowiak <misiek.piechowiak@gmail.com>
Date:   Mon May 11 01:17:47 2020 +0200

    fix(www): allow to tree shake lodash-es (#23967)

commit e267ca0
Author: Andrés Bedoya <Angelfire@users.noreply.github.com>
Date:   Sat May 9 15:51:42 2020 -0500

    Update deploying-to-zeit-now.md (#23946)
gatsbybot pushed a commit that referenced this pull request May 13, 2020
* fix(gatsby-recipes): support code blocks on cli

* Squashed commit of the following:

commit 9bd54be
Author: Hashim Warren <hashim@gatsbyjs.com>
Date:   Mon May 11 16:31:31 2020 -0400

    (chore)Update Incremental Builds blog post with list (#23981)

    * Update steps with ordered list

    * Update docs/blog/2020-04-22-announcing-incremental-builds/index.md

    Co-authored-by: Matt Kane <matt@gatsbyjs.com>

    * Update docs/blog/2020-04-22-announcing-incremental-builds/index.md

    Co-authored-by: Matt Kane <matt@gatsbyjs.com>

    * Update link and SEO title

    * chore: format

    Co-authored-by: Matt Kane <matt@gatsbyjs.com>
    Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com>

commit e8b6eea
Author: shannonbux <32467162+shannonbux@users.noreply.github.com>
Date:   Mon May 11 10:37:30 2020 -0700

    fixed capitalization

commit f457912
Author: Diogo Capela <diogocapela@gmail.com>
Date:   Mon May 11 18:04:08 2020 +0100

    chore(showcase): Add Zona Digital to Gatsby Showcase (#23980)

    Co-authored-by: Capela <diogo.capela@mindera.com>
    Co-authored-by: Matt Kane <matt@gatsbyjs.com>

commit eb0f0d8
Author: Mike Dane <mikedane94@gmail.com>
Date:   Tue May 12 02:42:34 2020 +1000

    removed space on bootstrap finished time (#23925)

    Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com>

commit c7e952b
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Mon May 11 17:39:08 2020 +0100

    chore: update www (#23971)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>

commit 224e84e
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Mon May 11 17:38:30 2020 +0100

    fix: update starters and examples (#23972)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>

commit 7b74535
Author: Raz Lifshitz <30860151+razrez@users.noreply.github.com>
Date:   Mon May 11 19:13:43 2020 +0300

    Update sites.yml (#23938)

    * Update sites.yml

    Added ofrilifshitz.com to sites.yml

    * chore: format

    Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com>

commit e5a2461
Author: Matt Kane <matt@gatsbyjs.com>
Date:   Mon May 11 17:11:20 2020 +0100

    Add redirect for Vercel docs (#23979)

commit 441f32a
Author: Christian Rackerseder <git@echooff.de>
Date:   Mon May 11 17:27:38 2020 +0200

    Rename ZEIT Now to Vercel (#23961)

commit 7a23392
Author: Dede Hamzah <dehamzah@users.noreply.github.com>
Date:   Mon May 11 21:45:23 2020 +0700

    fix: handle nullish announcementRef to fix client side redirect error (#23956)

commit 49dfc6f
Author: Gabriel Ramos <gabriel.luiz.ramos@gmail.com>
Date:   Mon May 11 10:42:17 2020 -0300

    chore(gatsby): Convert jobsV2 reducer to TS (#23708)

    * chore(ts): convert jobsv2 reducer to TS

    * Update packages/gatsby/src/redux/reducers/jobsv2.ts

    Co-authored-by: Ward Peeters <ward@coding-tech.com>

    * refactor(pr): refactor based on PR comments

    * Update packages/gatsby/src/redux/reducers/jobsv2.ts

    Co-authored-by: Ward Peeters <ward@coding-tech.com>

    * fix(lint): fix lint error

    * add result typing to jobs-manager

    Co-authored-by: Ward Peeters <ward@coding-tech.com>

commit c5144ea
Author: Rajeesh C V <cvrajeesh@gmail.com>
Date:   Mon May 11 18:53:21 2020 +0530

    chore(docs): add Clodui deployment guide (#23587)

    * chore(docs): add Clodui deployment guide

    * update Clodui deployment doc with review comments

    * Update docs/docs/deploying-to-clodui.md

    * Update docs/docs/deploying-to-clodui.md

    * Update docs/docs/deploying-to-clodui.md

    * Update docs/docs/deploying-to-clodui.md

    * chore: format

    Co-authored-by: Obinna Ekwuno <obinnacodes@gmail.com>
    Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com>

commit c34bd66
Author: Michal Piechowiak <misiek.piechowiak@gmail.com>
Date:   Mon May 11 12:54:24 2020 +0200

    chore(release): Publish

     - gatsby-admin@0.1.22
     - gatsby-cli@2.12.16
     - gatsby-recipes@0.1.15
     - gatsby-theme-blog-core@1.4.22
     - gatsby-theme-blog@1.5.22
     - gatsby-theme-notes@1.3.22
     - gatsby-theme-ui-preset@0.0.12
     - gatsby@2.21.22

commit f7dc43f
Author: Albert Lash <31164347+albertlincoln@users.noreply.github.com>
Date:   Mon May 11 11:52:59 2020 +0100

    fix(gatsby-cli): don't fail when using `--log-pages` and/or `--write-to-file` (#23951)

    * Adding new cli options for page optimization

    * prettier

    * make them hidden, add some description as well as comment about why they are hidden

    Co-authored-by: Michal Piechowiak <misiek.piechowiak@gmail.com>

commit 88056f0
Author: Michal Piechowiak <misiek.piechowiak@gmail.com>
Date:   Mon May 11 01:17:47 2020 +0200

    fix(www): allow to tree shake lodash-es (#23967)

commit e267ca0
Author: Andrés Bedoya <Angelfire@users.noreply.github.com>
Date:   Sat May 9 15:51:42 2020 -0500

    Update deploying-to-zeit-now.md (#23946)

* Add hicat to do syntax highlighting

* fix

* Fix

* Add hicat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: merge on green Gatsbot will merge these PRs automatically when all tests passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants