catamphetamine / libphonenumber-js

A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript
https://catamphetamine.gitlab.io/libphonenumber-js/
MIT License
2.79k stars 216 forks source link

Track metadata version #249

Closed shadowhand closed 5 years ago

shadowhand commented 6 years ago

How do I know what version of googlei18n/libphonenumber metadata is being used? It looks like this package just updates to the latest master version of PhoneNumberMetadata.xml (rather than the latest tagged release) and doesn't keep track of what version is being used.

In our project, we need to keep both JS and PHP copies of libphonenumber in sync. This is basically impossible unless we know the Google version number of the metadata. The PHP package tracks the metadata version specifically, and the version number is also the same as the Google version.

This package would be much more useful if it did at least one of these things, so that we can be sure that the metadata is the same version.

catamphetamine commented 6 years ago

How do I know what version of googlei18n/libphonenumber metadata is being used?

As far as I saw there's no version indication in the XML file. https://github.com/googlei18n/libphonenumber/blob/master/resources/PhoneNumberMetadata.xml So there seems to be no way to reliably tell what is the version of a given metadata file.

This package would be much more useful if it did at least one of these things, so that we can be sure that the metadata is the same version.

No, it wouldn't.

shadowhand commented 6 years ago

So there seems to be no way to reliably tell what is the version of a given metadata file.

Sure there is: use the tag version number as the metadata version.

No, it wouldn't.

That's a pretty rude response. I just detailed why it would be a useful change.

catamphetamine commented 6 years ago

That's a pretty rude response. I just detailed why it would be a useful change.

No. You're being rude by accusing others of being "rude".

Sure there is: use the tag version number as the metadata version.

You can do that in a pull request if you want. No guarantees about the acceptance of such pull request.

catamphetamine commented 6 years ago

For future people coming here from Google, to prevent subsequent questions on this topic:

Theoretically one could introduce a new property in metadata.json called googleVersion (analogous to the existing version property). The value of the googleVersion property could be parsed from the release notes' first line. https://github.com/googlei18n/libphonenumber/blob/master/release_notes.txt It would have to be added to generate.js and compress.js analogous to the existing version property. https://github.com/catamphetamine/libphonenumber-js/blob/4508bee6c85dd9ffd82517c81cbeeea87ea5af4f/source/tools/generate.js#L522 https://github.com/catamphetamine/libphonenumber-js/blob/4508bee6c85dd9ffd82517c81cbeeea87ea5af4f/source/tools/compress.js#L85 The entry point would be the bin script. https://github.com/catamphetamine/libphonenumber-js/blob/master/bin/update-metadata.js