Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jasonkuhrt
Copy link
Member

@jasonkuhrt jasonkuhrt commented Jun 12, 2020

This was intended to be some refactoring leading to #1012

However I discovered a reason to treat this beyond a refactor.

The fix is that version field is a required field of package json, and we were not supplying it during app creation.

@jasonkuhrt jasonkuhrt force-pushed the feat/project-scan-malformed-json branch from 7ce2f31 to 75de26c Compare June 12, 2020 04:06
@jasonkuhrt jasonkuhrt marked this pull request as draft June 12, 2020 04:45
@jasonkuhrt jasonkuhrt requested a review from Weakky June 12, 2020 11:57
@jasonkuhrt jasonkuhrt marked this pull request as ready for review June 12, 2020 11:57
@jasonkuhrt jasonkuhrt changed the title feat: malformed json case on project type scan fix: valid package json on app create Jun 12, 2020
Copy link
Collaborator

@Weakky Weakky left a comment

Choose a reason for hiding this comment

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

lgtm!

"http-errors": "^1.7.3",
"lodash": "^4.17.15",
"node-fetch": "^2.6.0",
"parse-json": "^5.0.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

Just to improve dx around the bad feedback given by JSON.parse

console.log() // space after codeblock

break
case 'malformed_package_json':
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a new feature that led to catching the bug.

fs.writeAsync(Path.join(options.projectRoot, 'package.json'), {
name: options.projectName,
license: 'UNLICENSED',
version: '0.0.0',
Copy link
Member Author

Choose a reason for hiding this comment

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

fixing the bug

},
],
"rootDir": ".",
"skipLibCheck": true,
Copy link
Member Author

Choose a reason for hiding this comment

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

This is reverting a temp feature we had in the release series.

export async function scan(opts?: {
cwd?: string
entrypointPath?: string
}): Promise<Either<Error, ScanResult>> {
Copy link
Member Author

Choose a reason for hiding this comment

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

Scan is now an either, since it cares about failed reads of package.json now.

/**
*
*/
function findPackageJson(opts: { projectRoot: string }): ScanResult['packageJson'] {
Copy link
Member Author

Choose a reason for hiding this comment

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

We have a new lib module for dealing with package json

e.context = ctx
return e
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I am not satisfied with the usability but it seems to get the job done which is a two step processes where we:

  1. define error types
  2. create instances of those error types

I am open to using classes but didn't see how that would help.

I hope we can make this better in the future.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I find it interesting as a first iteration and certainly not bad. Let's simply see how that works in practice for now and iterate if it turns out to not work well!

@jasonkuhrt jasonkuhrt merged commit db6cce9 into master Jun 12, 2020
@jasonkuhrt jasonkuhrt deleted the feat/project-scan-malformed-json branch June 12, 2020 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants