libphonenumber-js 1.12.23 → 1.12.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +4 -4
  3. package/build-scripts/check-for-metadata-changes-and-create-pull-request.js +4 -3
  4. package/build-scripts/check-for-metadata-changes-and-release.js +10 -35
  5. package/build-scripts/check-for-uncommitted-files.js +10 -8
  6. package/build-scripts/helpers/commit.js +1 -2
  7. package/build-scripts/helpers/exec.js +3 -4
  8. package/build-scripts/helpers/getUncommittedChanges.js +3 -3
  9. package/build-scripts/helpers/sendEmail.js +62 -0
  10. package/build-scripts/helpers/{update-metadata-from-google-metadata.js → updateMetadataFromGoogleMetadata.js} +5 -9
  11. package/bundle/libphonenumber-js.min.js +1 -1
  12. package/bundle/libphonenumber-js.min.js.map +1 -1
  13. package/bundle/libphonenumber-max.js +1 -1
  14. package/bundle/libphonenumber-max.js.map +1 -1
  15. package/bundle/libphonenumber-min.js +1 -1
  16. package/bundle/libphonenumber-min.js.map +1 -1
  17. package/bundle/libphonenumber-mobile.js +1 -1
  18. package/bundle/libphonenumber-mobile.js.map +1 -1
  19. package/max/metadata/metadata.max.json +1 -1
  20. package/max/metadata/metadata.max.json.js +1 -1
  21. package/metadata.full.json +1 -1
  22. package/metadata.full.json.js +1 -1
  23. package/metadata.max.json +1 -1
  24. package/metadata.max.json.js +1 -1
  25. package/metadata.min.json +1 -1
  26. package/metadata.min.json.js +1 -1
  27. package/metadata.mobile.json +1 -1
  28. package/metadata.mobile.json.js +1 -1
  29. package/min/metadata/metadata.min.json +1 -1
  30. package/min/metadata/metadata.min.json.js +1 -1
  31. package/mobile/metadata/metadata.mobile.json +1 -1
  32. package/mobile/metadata/metadata.mobile.json.js +1 -1
  33. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -69,6 +69,29 @@ And edit the README:
69
69
 
70
70
  <!-- CHANGELOG START -->
71
71
 
72
+ 1.12.25 / 24.10.2025
73
+ ===================
74
+
75
+ * Updated metadata to version 9.0.17:
76
+ - Updated phone metadata for region code(s): AU, CC, CX, GB, LB, MG, SN
77
+ - Updated short number metadata for region code(s): RO
78
+ - Updated carrier data for country calling code(s):
79
+ 57 (en), 61 (en), 221 (en), 255 (en), 261 (en), 852 (zh), 961 (en)
80
+ - Updated / refreshed time zone meta data.
81
+
82
+ 1.12.24 / 10.10.2025
83
+ ===================
84
+
85
+ * Updated metadata to version 9.0.16:
86
+ - Updated phone metadata for region code(s): CZ, ES, GE, HK, JO, LI, US
87
+ - Updated short number metadata for region code(s): ES
88
+ - New geocoding data for country calling code(s): 1324 (en)
89
+ - Updated geocoding data for country calling code(s): 1437 (en)
90
+ - Updated carrier data for country calling code(s):
91
+ 34 (en), 65 (en), 233 (en), 423 (en), 673 (en), 852 (en, zh), 962 (en),
92
+ 995 (en)
93
+ - Updated / refreshed time zone meta data.
94
+
72
95
  1.12.23 / 26.9.2025
73
96
  ===================
74
97
 
package/README.md CHANGED
@@ -74,10 +74,6 @@ One part of me was curious about how all this phone number parsing and formattin
74
74
  (`.formatNumberForMobileDialing()` method is not implemented therefore there's no need to format carrier codes)
75
75
  -->
76
76
 
77
- ## GitHub Repository Status
78
-
79
- On March 9th, 2020, GitHub, Inc. silently [banned](https://medium.com/@catamphetamine/how-github-blocked-me-and-all-my-libraries-c32c61f061d3) my account — erasing all my repos, issues and comments, even in my employer's private repos — without any notice or explanation. Because of that, all source codes had to be promptly moved to GitLab. The [GitHub repo](https://github.com/catamphetamine/libphonenumber-js) is now only used as a backup (although you can still "star" it), and the primary repo is now the [GitLab one](https://gitlab.com/catamphetamine/libphonenumber-js). For users' convenience, issues can be reported in both places.
80
-
81
77
  ## Install
82
78
 
83
79
  via [npm](https://npmjs.org/)
@@ -1500,6 +1496,10 @@ Whenever there's a "business requirement" to validate phone number input, I pref
1500
1496
 
1501
1497
  If you’re trying to build a React component with this library, take a look at [`react-phone-number-input`](https://www.npmjs.com/package/react-phone-number-input).
1502
1498
 
1499
+ ## GitHub Repository Status
1500
+
1501
+ On March 9th, 2020, GitHub, Inc. silently [banned](https://medium.com/@catamphetamine/how-github-blocked-me-and-all-my-libraries-c32c61f061d3) my account — erasing all my repos, issues and comments, even in my employer's private repos — without any notice or explanation. Because of that, all source codes had to be promptly moved to GitLab. The [GitHub repo](https://github.com/catamphetamine/libphonenumber-js) is now only used as a backup (although you can still "star" it), and the primary repo is now the [GitLab one](https://gitlab.com/catamphetamine/libphonenumber-js). For users' convenience, issues can be reported in both places.
1502
+
1503
1503
  <!--
1504
1504
  ## Node ES Modules
1505
1505
 
@@ -9,7 +9,7 @@
9
9
  // * Create a "Personal Access Token" in GitHub account settings (just "repo_public" would be enough)
10
10
  // * Tell `hub` to use the token for creating GitHub pull requests: `echo "---\ngithub.com:\n- protocol: https\n user: GITHUB_USERNAME\n oauth_token: TOKEN" >> ~/.config/hub`
11
11
 
12
- import update_metadata_from_google_metadata from './helpers/update-metadata-from-google-metadata.js'
12
+ import updateMetadataFromGoogleMetadata from './helpers/updateMetadataFromGoogleMetadata.js'
13
13
  import commit from './helpers/commit.js'
14
14
  import exec from './helpers/exec.js'
15
15
 
@@ -20,8 +20,9 @@ const metadataInfoFilePath = process.argv[3]
20
20
  // See `createMetadataUpdateBranch()` function for how it could be set up.
21
21
  throw new Error('Run `createMetadataUpdateBranch()` function first')
22
22
 
23
- if (update_metadata_from_google_metadata(googleMetadataFilePath, metadataInfoFilePath))
24
- {
23
+ const metadataChanged = updateMetadataFromGoogleMetadata(googleMetadataFilePath, metadataInfoFilePath)
24
+
25
+ if (metadataChanged) {
25
26
  commit()
26
27
 
27
28
  console.log()
@@ -1,18 +1,17 @@
1
1
  // Pulls the latest metadata from Google's repo, and, if it has changed,
2
2
  // pushes the changes in the main branch and releases a new version on `npm`.
3
3
 
4
- import fs from 'fs'
5
- import gmailSend from 'gmail-send'
6
-
7
- import update_metadata_from_google_metadata from './helpers/update-metadata-from-google-metadata.js'
4
+ import updateMetadataFromGoogleMetadata from './helpers/updateMetadataFromGoogleMetadata.js'
8
5
  import commit from './helpers/commit.js'
9
6
  import exec from './helpers/exec.js'
7
+ import sendEmail from './helpers/sendEmail.js'
10
8
 
11
9
  const googleMetadataFilePath = process.argv[2]
12
10
  const metadataInfoFilePath = process.argv[3]
13
11
 
14
- if (update_metadata_from_google_metadata(googleMetadataFilePath, metadataInfoFilePath))
15
- {
12
+ const metadataChanged = updateMetadataFromGoogleMetadata(googleMetadataFilePath, metadataInfoFilePath)
13
+
14
+ if (metadataChanged) {
16
15
  commit()
17
16
 
18
17
  console.log()
@@ -45,24 +44,18 @@ if (update_metadata_from_google_metadata(googleMetadataFilePath, metadataInfoFil
45
44
  // In that case, instead of attempting to run `npm publish` command,
46
45
  // it will send an email notification to do that manually.
47
46
  //
48
- const emailSettings = getEmailSettings()
49
- if (emailSettings) {
47
+ if (await sendEmail({
50
48
  // Send an email notification about manually publishing the new version of the package to `npm`.
51
- gmailSend({
52
- user: emailSettings.email,
53
- pass: emailSettings.accessToken,
54
- to: emailSettings.email,
55
- subject: '[libphonenumber-js] Publish a new version',
56
- text: 'A new version of `libphonenumber-js` has been pushed to the repository:\nhttps://gitlab.com/catamphetamine/libphonenumber-js/-/commits/master\n\nRun `npm publish` in `libphonenumber-js` directory to publish the new version.',
57
- // html: '<b>html text</b>' // alternative to specifying `text`, one could specify `html`.
58
- })()
59
-
49
+ subject: '[libphonenumber-js] Publish a new version',
50
+ text: 'A new version of `libphonenumber-js` has been pushed to the repository:\nhttps://gitlab.com/catamphetamine/libphonenumber-js/-/commits/master\n\nRun `npm publish` in `libphonenumber-js` directory to publish the new version.'
51
+ })) {
60
52
  console.log()
61
53
  console.log('==========================================================')
62
54
  console.log('= Email notification sent. Publish the package manually. =')
63
55
  console.log('==========================================================')
64
56
  console.log()
65
57
  } else {
58
+ // Attempt to publish the `npm` package.
66
59
  console.log(exec('npm publish'))
67
60
 
68
61
  console.log()
@@ -71,22 +64,4 @@ if (update_metadata_from_google_metadata(googleMetadataFilePath, metadataInfoFil
71
64
  console.log('========================================')
72
65
  console.log()
73
66
  }
74
- }
75
-
76
- // Reads email settings from a JSON file just outside of `libphonenumber-js` repo folder.
77
- function getEmailSettings() {
78
- const emailSettingsPath = '../libphonenumber-js-autoupdate-email-notification-settings.json'
79
- if (fs.existsSync(emailSettingsPath)) {
80
- const emailSettings = JSON.parse(fs.readFileSync(emailSettingsPath, 'utf-8'))
81
- // Validate `emailSettings`.
82
- if (!emailSettings.email) {
83
- throw new Error('`email` parameter not specified in the email config file')
84
- }
85
- // The instructions on how to obtain an `accessToken` are described in `gmail-send` readme:
86
- // https://www.npmjs.com/package/gmail-send
87
- if (!emailSettings.accessToken) {
88
- throw new Error('`accessToken` parameter not specified in the email config file')
89
- }
90
- return emailSettings;
91
- }
92
67
  }
@@ -1,11 +1,13 @@
1
1
  import getUncommittedChanges from './helpers/getUncommittedChanges.js';
2
+ import sendEmail from './helpers/sendEmail.js'
2
3
 
3
- getUncommittedChanges().then((uncommittedChanges) => {
4
- if (uncommittedChanges.length > 0) {
5
- console.error(new Error(`You have uncommitted files in your repository:\n${uncommittedChanges.map(({ filename }) => filename).join('\n')}`))
6
- process.exit(1)
7
- }
8
- }).catch((error) => {
9
- console.error(error)
4
+ const uncommittedChanges = await getUncommittedChanges()
5
+ if (uncommittedChanges.length > 0) {
6
+ const errorText = `You have uncommitted files in your repository:\n\n${uncommittedChanges.map(({ filename }) => filename).join('\n')}`
7
+ console.error(new Error(errorText))
8
+ await sendEmail({
9
+ subject: '[libphonenumber-js] Uncommitted changes found',
10
+ text: errorText
11
+ })
10
12
  process.exit(1)
11
- })
13
+ }
@@ -1,8 +1,7 @@
1
1
  import exec from './exec.js'
2
2
 
3
3
  // Commits the current changes files in the local git repository.
4
- export default function()
5
- {
4
+ export default function() {
6
5
  console.log()
7
6
  console.log('========================================')
8
7
  console.log('= Committing changes =')
@@ -1,7 +1,6 @@
1
- import child_process from 'child_process'
1
+ import { execSync } from 'child_process'
2
2
 
3
3
  // Executes a command.
4
- export default function exec(command)
5
- {
6
- return child_process.execSync(command).toString().trim()
4
+ export default function exec(command) {
5
+ return execSync(command).toString().trim()
7
6
  }
@@ -21,9 +21,9 @@ export default function getUncommittedChanges() {
21
21
 
22
22
  const uncommittedFiles = output.trim().split('\n').map((line) => {
23
23
  line = line.trim()
24
- const status = line[0]
25
- line = line.slice(2)
26
- const filename = line
24
+ const whitespaceIndex = line.indexOf(' ')
25
+ const status = line.slice(0, whitespaceIndex)
26
+ const filename = line.slice(whitespaceIndex + ' '.length)
27
27
  return { status, filename }
28
28
  })
29
29
 
@@ -0,0 +1,62 @@
1
+ import fs from 'fs'
2
+ import gmailSend from 'gmail-send'
3
+
4
+ export default async function sendEmail({ subject, text }) {
5
+ const emailSettings = getEmailSettings()
6
+ if (emailSettings) {
7
+ // Send an email notification through GMail.
8
+ //
9
+ // Example output:
10
+ //
11
+ // {
12
+ // result: '250 2.0.0 OK 1759154240 2adb3069b0e04-58313dd67c4sm4173572e87.55 - gsmtp',
13
+ // full: {
14
+ // accepted: [ 'kuchumovn@gmail.com' ],
15
+ // rejected: [],
16
+ // ehlo: [
17
+ // 'SIZE 35882577',
18
+ // '8BITMIME',
19
+ // 'AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH',
20
+ // 'ENHANCEDSTATUSCODES',
21
+ // 'PIPELINING',
22
+ // 'CHUNKING',
23
+ // 'SMTPUTF8'
24
+ // ],
25
+ // envelopeTime: 297,
26
+ // messageTime: 565,
27
+ // messageSize: 799,
28
+ // response: '250 2.0.0 OK 1759154240 2adb3069b0e04-58313dd67c4sm4173572e87.55 - gsmtp',
29
+ // envelope: { from: 'kuchumovn@gmail.com', to: [Array] },
30
+ // messageId: '<b7c49e37-1f0f-5c42-13c5-2398a778abd2@gmail.com>'
31
+ // }
32
+ // }
33
+ //
34
+ const { result, full } = await gmailSend({
35
+ user: emailSettings.email,
36
+ pass: emailSettings.accessToken,
37
+ to: emailSettings.email,
38
+ subject,
39
+ text
40
+ // html: '<b>html text</b>' // alternative to specifying `text`, one could specify `html`.
41
+ })()
42
+ return true
43
+ }
44
+ }
45
+
46
+ // Reads email settings from a JSON file just outside of `libphonenumber-js` repo folder.
47
+ function getEmailSettings() {
48
+ const emailSettingsPath = '../libphonenumber-js-autoupdate-email-notification-settings.json'
49
+ if (fs.existsSync(emailSettingsPath)) {
50
+ const emailSettings = JSON.parse(fs.readFileSync(emailSettingsPath, 'utf-8'))
51
+ // Validate `emailSettings`.
52
+ if (!emailSettings.email) {
53
+ throw new Error('`email` parameter not specified in the email config file')
54
+ }
55
+ // The instructions on how to obtain an `accessToken` are described in `gmail-send` readme:
56
+ // https://www.npmjs.com/package/gmail-send
57
+ if (!emailSettings.accessToken) {
58
+ throw new Error('`accessToken` parameter not specified in the email config file')
59
+ }
60
+ return emailSettings;
61
+ }
62
+ }
@@ -5,12 +5,10 @@ import exec from './exec.js'
5
5
 
6
6
  // Checks if Google's metadata XML file has changes, and, if it has,
7
7
  // generates JSON metadata files from it, runs the tests and updates `CHANGELOG.md`.
8
- export default function(googleMetadataFilePath, metadataInfoFilePath)
9
- {
10
- let metadata_changed = exec(`git ls-files --modified ${googleMetadataFilePath}`)
8
+ export default function(googleMetadataFilePath, metadataInfoFilePath) {
9
+ let metadataChanged = exec(`git ls-files --modified ${googleMetadataFilePath}`)
11
10
 
12
- if (!metadata_changed)
13
- {
11
+ if (!metadataChanged) {
14
12
  console.log()
15
13
  console.log('========================================')
16
14
  console.log('= Metadata is up-to-date. Exiting. =')
@@ -40,8 +38,7 @@ export default function(googleMetadataFilePath, metadataInfoFilePath)
40
38
 
41
39
  let modified_files = exec('git ls-files --modified').split(/\s/)
42
40
 
43
- let unexpected_modified_files = modified_files.filter(function(file)
44
- {
41
+ let unexpected_modified_files = modified_files.filter((file) => {
45
42
  return file !== googleMetadataFilePath &&
46
43
  !/^metadata\.[a-z]+\.json$/.test(file) &&
47
44
  !/^examples\.[a-z]+\.json$/.test(file)
@@ -51,8 +48,7 @@ export default function(googleMetadataFilePath, metadataInfoFilePath)
51
48
  // because on Windows random files constantly got "modified"
52
49
  // without actually being modified.
53
50
  // (perhaps something related to line endings)
54
- if (false && unexpected_modified_files.length > 0)
55
- {
51
+ if (false && unexpected_modified_files.length > 0) {
56
52
  let error
57
53
 
58
54
  error += 'Only `' + googleMetadataFilePath + '`, `metadata.*.json` and `examples.*.json` files should be modified. Unexpected modified files:'