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

Preparing convict 6 #353

Closed
wants to merge 26 commits into from
Closed

Preparing convict 6 #353

wants to merge 26 commits into from

Conversation

A-312
Copy link
Contributor

@A-312 A-312 commented Jan 5, 2020

Depending of #350 I will merge all my PRs into my branch to save the time on several rebase/merge/conflict resolving.

TODO :


Source: #342 (comment)

fix: #288

@A-312 A-312 changed the base branch from feat-multi-packages-split to master January 5, 2020 10:19
@A-312 A-312 changed the base branch from master to feat-multi-packages-split January 5, 2020 10:20
@A-312
Copy link
Contributor Author

A-312 commented Jan 5, 2020

BREAKCHANGES LIST :

  • _cvtProperties is a reserved word instead of properties. Now, properties is supported like property name in your schema (doesn't throw an parsing error anymore).

  • coerce method will be always applied:
    - Before this version: coerce was only applied with: .set(), .env: and .arg:.
    - With this version: coerce is also applied with: .load(), .loadFile() and .default:.

    This change mean the value (first argument of coerce method) can be another type of String. We advice you to add type checking in your coerce function to avoid an JS error with undefined value. See: array coerce change from: (v) => v.split(',') to: return (v) => (typeof v == 'string') ? v.split(',') : v;

  • agregate hack removed (Coerce from strings to their proper types (NOT MORE) + code review on coercing #352).

  • Fix .getSchema/getSchemaString() output.

  • Parsing behavior with format: [ typeof this !== 'object' ].

CHANGELOG :

Some of my change are tacit, I will try to add all of my tacit change here :

  • Error are more human-readable :
    image

    code
    var config = convict({
      something: {
        format: function (val, schema) {
            console.log(arguments);
            if (schema.env && val === '') {
              throw new Error(`env[${schema.env}] is not set !`)
            }

@coveralls
Copy link

coveralls commented Jan 5, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling 51c2483 on A-312:feat-multi-packages-split into 30bcc2e on mozilla:feat-multi-packages-split.

@A-312 A-312 mentioned this pull request Jan 5, 2020
7 tasks
@A-312 A-312 marked this pull request as ready for review January 5, 2020 15:55
@A-312
Copy link
Contributor Author

A-312 commented Jan 5, 2020

@madarche This PR is ready and the 6.0.0 too. 😀

@julian91
Copy link

julian91 commented Jan 6, 2020

when can we expect 6.0 to hit the shelf? saving quite some time on refactoring due to the fix with the dot notation object properties in the branch.

@A-312
Copy link
Contributor Author

A-312 commented Jan 6, 2020

(The new dot notation doesn't work well with backslash #354 (comment) )

@A-312
Copy link
Contributor Author

A-312 commented Jan 6, 2020

I will make another PR (for 6.0.0), to support default like property name in config. -> #357

 - Add `schema.required = true`
 - Improve schema parsing with `format: [ typeof this !== 'object' ]`
 - Transform: `$~default` to `default`
 - Fix: `.getSchema/getSchemaString()` to proper schema
 - Add `opt.strictParsing = true`, will throw an error if default or format are omitted
 - Improve error for users : .defaut() and .reset() errors + parents rewrited error.
@A-312 A-312 requested a review from madarche January 25, 2020 20:50
@A-312
Copy link
Contributor Author

A-312 commented Jan 25, 2020

My PR is ready @madarche. I hope that all my change will be ok with convict way.

@A-312
Copy link
Contributor Author

A-312 commented Jan 30, 2020

@vladikoff madarche seems to be inactive this month (The last weeks, I didn't get answer in #350), I think he got lot of things to do in IRL. I made lot of change, I don't know if he will have enough time to watch/review to merge my work. Do you think you can have a look ?

Also, @zaverden do you think you can review my changes in the README ? My english is not perfect and that will help the mozilla team to review/merge my PR.

Copy link
Contributor

@zaverden zaverden left a comment

Choose a reason for hiding this comment

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

I have run these changes through grammarly.com and there are results.

packages/convict/README.md Outdated Show resolved Hide resolved
packages/convict/README.md Outdated Show resolved Hide resolved
packages/convict/README.md Outdated Show resolved Hide resolved
packages/convict/README.md Outdated Show resolved Hide resolved
packages/convict/README.md Outdated Show resolved Hide resolved
packages/convict/README.md Outdated Show resolved Hide resolved
packages/convict/README.md Outdated Show resolved Hide resolved
packages/convict/README.md Outdated Show resolved Hide resolved
packages/convict/README.md Outdated Show resolved Hide resolved
packages/convict/lib/convicterror.js Outdated Show resolved Hide resolved
A-312 and others added 2 commits February 1, 2020 18:06
Co-Authored-By: Denis Zavershinskiy <[email protected]>
@A-312
Copy link
Contributor Author

A-312 commented Feb 1, 2020

Done, thanks you. Is there any other non-sense ?

@vladikoff
Copy link
Contributor

I'm away next week, will take a look when back

@A-312
Copy link
Contributor Author

A-312 commented Feb 23, 2020

ping @vladikoff

Also I would to know : #350 (comment) If I mark .load and loadFile deprecated, and I replace this two by merge function

Something like this :

convict.merge = function (source) {
  if (typeof source === 'string')
    loadFile(source)
  else
    load(source)
}

@A-312
Copy link
Contributor Author

A-312 commented Mar 2, 2020

@madarche @vladikoff I don't want to be insistent but I made a lot of work to improve convict, do you need help for this repository ? Should I wait more ? Should I make my own fork (but I like and understand the convict way & project) ?

@madarche
Copy link
Collaborator

madarche commented Mar 2, 2020

@A-312 your work is really really appreciated. I promise I'll deal with this PR before Saturday.

@madarche
Copy link
Collaborator

madarche commented Mar 2, 2020

@A-312 this is a quite a big work altogether now, hence the time that it takes to review it.

@vladikoff
Copy link
Contributor

I am traveling again, however I will be able to post a new version to npm when it is ready. Won't have time to deep dive into the changes for a few weeks.

@madarche
Copy link
Collaborator

madarche commented Mar 6, 2020

@A-312 I've not totally finished to read all the proposed changes. But at this point there is one change that I don't agree with: it's the use of Chai.js, because Chai.js has a design mistake: cf. https://github.com/moll/js-must/#asserting-on-property-access. With Should.js it's still possible to use the unsafe syntax, but at least it's not recommended/suggested.

So I'll not merge this specific PR, but will use it, as a guideline, to do the merge work on my side. Thanks for all the work nonetheless.

@A-312
Copy link
Contributor Author

A-312 commented Mar 6, 2020

@madarche It is why I use expect(problem).to.not.exist()

EDIT:

The output of must is hard to read and less readable than chai.js. To many conflict, you will never have enough time to merge all my change...

@A-312
Copy link
Contributor Author

A-312 commented Mar 6, 2020

Can we discuss about that on IRC or discord, or other thing ?

@madarche
Copy link
Collaborator

madarche commented Mar 6, 2020

@A-312 I've merged the first PRs and merged the feat-multi-packages-split branch into master.

Please don't work on any other PR or modification for now.

I'll be online in a very asynchronous manner in the following days. But I'll continue the review work.

Thank you

@A-312
Copy link
Contributor Author

A-312 commented Mar 6, 2020

I edited each test... You will have a lot of work to do. I don't understand why you don't want use chai.js because I used expect(), and I don't got any bug.
image

@A-312 A-312 closed this Mar 6, 2020
@A-312 A-312 deleted the feat-multi-packages-split branch March 6, 2020 18:44
@A-312
Copy link
Contributor Author

A-312 commented Mar 6, 2020

I will do the thing on my own way. (take the time you want, don't waste your time on this PR if you have lot of things to do IRL, I know it takes a long time to resolve conflicts)

Also i want to stay author of my commit/change i made.

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.

6 participants