From 61da6c9ffb0f572e897e1e518060a4c6a0603636 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" <23040076+greenkeeper[bot]@users.noreply.github.com> Date: Sun, 10 Nov 2019 19:09:10 -0800 Subject: [PATCH 01/39] chore(package): update standard-version to version 5.0.0 (#73) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f44d52d3..636cfddf 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,6 @@ "nyc": "^11.0.1", "rimraf": "^2.5.0", "standard": "^10.0.0-beta.0", - "standard-version": "^4.2.0" + "standard-version": "^5.0.0" } } From 007cd70640764a45dc7630cf928838ddb32e6b9c Mon Sep 17 00:00:00 2001 From: bcoe Date: Sun, 9 Feb 2020 19:26:32 -0800 Subject: [PATCH 02/39] chore: add renovate config --- renovate.json | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 renovate.json diff --git a/renovate.json b/renovate.json new file mode 100644 index 00000000..f6dd45e1 --- /dev/null +++ b/renovate.json @@ -0,0 +1,8 @@ +{ + "extends": [ + "config:base" + ], + "pinVersions": false, + "rebaseStalePrs": true, + "gitAuthor": null +} From 3cc0c287240727b84eaf1927f903612ec80f5e43 Mon Sep 17 00:00:00 2001 From: QmarkC Date: Tue, 4 Aug 2020 01:24:53 -0500 Subject: [PATCH 03/39] build!: drops Node 6 and 4. begin following Node.js LTS schedule (#89) --- .github/workflows/ci.yaml | 41 +++++++++++++++++++++++++++++++++++++++ .gitignore | 1 + .nvmrc | 1 + .travis.yml | 7 ------- README.md | 6 ++++++ package.json | 35 ++++++++++++++++++--------------- 6 files changed, 68 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/ci.yaml create mode 100644 .nvmrc delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..18714f3a --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,41 @@ +name: ci +on: + push: + branches: + - master + pull_request: +env: + CI: true +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + node: [10.x, 12.x, 14.x] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node }} + - run: node --version + - run: npm install + - run: npm test + windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '12.x' + - run: npm install + - run: npm test + coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '14.x' + - run: npm install + - run: npm test + - run: npm run coverage diff --git a/.gitignore b/.gitignore index 62adae57..7f616c8a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store node_modules .nyc_output +package-lock.json diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..b009dfb9 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +lts/* diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2465405e..00000000 --- a/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: node_js -sudo: false -node_js: - - "4" - - "6" - - "node" -after_success: npm run coverage diff --git a/README.md b/README.md index 826474f2..36cd3495 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,12 @@ What locale is currently being used? Update the current locale with the key value pairs in `obj`. +## Supported Node.js Versions + +Libraries in this ecosystem make a best effort to track +[Node.js' release schedule](https://nodejs.org/en/about/releases/). Here's [a +post on why we think this is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a). + ## License ISC diff --git a/package.json b/package.json index 636cfddf..e64aca3a 100644 --- a/package.json +++ b/package.json @@ -2,31 +2,31 @@ "name": "y18n", "version": "4.0.0", "description": "the bare-bones internationalization library used by yargs", - "main": "index.js", - "scripts": { - "pretest": "standard", - "test": "nyc mocha", - "coverage": "nyc report --reporter=text-lcov | coveralls", - "release": "standard-version" + "keywords": [ + "i18n", + "internationalization", + "yargs" + ], + "homepage": "https://github.com/yargs/y18n", + "bugs": { + "url": "https://github.com/yargs/y18n/issues" }, "repository": { "type": "git", "url": "git@github.com:yargs/y18n.git" }, + "license": "ISC", + "author": "Ben Coe ", + "main": "index.js", "files": [ "index.js" ], - "keywords": [ - "i18n", - "internationalization", - "yargs" - ], - "author": "Ben Coe ", - "license": "ISC", - "bugs": { - "url": "https://github.com/yargs/y18n/issues" + "scripts": { + "coverage": "nyc report --reporter=text-lcov | coveralls", + "release": "standard-version", + "pretest": "standard", + "test": "nyc mocha" }, - "homepage": "https://github.com/yargs/y18n", "devDependencies": { "chai": "^4.0.1", "coveralls": "^3.0.0", @@ -35,5 +35,8 @@ "rimraf": "^2.5.0", "standard": "^10.0.0-beta.0", "standard-version": "^5.0.0" + }, + "engines": { + "node": ">=10" } } From 3bedfcd26ba0ed53c2ee67730d1577679ff86dbb Mon Sep 17 00:00:00 2001 From: bcoe Date: Mon, 3 Aug 2020 23:53:41 -0700 Subject: [PATCH 04/39] build: add release-please workflow --- .github/workflows/release-please.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/release-please.yml diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 00000000..38ace4d2 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,14 @@ +on: + push: + branches: + - master +name: release-please +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - uses: GoogleCloudPlatform/release-please-action@v1.6.3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + release-type: node + package-name: y18n From 23605867872536b89f84049643f7ba6c5b15679e Mon Sep 17 00:00:00 2001 From: QmarkC Date: Tue, 4 Aug 2020 22:35:57 -0500 Subject: [PATCH 05/39] ci: remove coveralls (#92) --- .gitignore | 1 + .nycrc | 13 +++++++++++++ README.md | 6 ------ package.json | 7 +++---- 4 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 .nycrc diff --git a/.gitignore b/.gitignore index 7f616c8a..20bf8fcb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store node_modules .nyc_output +coverage package-lock.json diff --git a/.nycrc b/.nycrc new file mode 100644 index 00000000..258129d5 --- /dev/null +++ b/.nycrc @@ -0,0 +1,13 @@ +{ + "exclude": [ + "test/**" + ], + "reporter": [ + "html", + "text" + ], + "branches": 96.5, + "lines": 100, + "functions": 94, + "statements": 100 +} diff --git a/README.md b/README.md index 36cd3495..b80abac5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # y18n -[![Build Status][travis-image]][travis-url] -[![Coverage Status][coveralls-image]][coveralls-url] [![NPM version][npm-image]][npm-url] [![js-standard-style][standard-image]][standard-url] [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) @@ -105,10 +103,6 @@ post on why we think this is important](https://medium.com/the-node-js-collectio ISC -[travis-url]: https://travis-ci.org/yargs/y18n -[travis-image]: https://img.shields.io/travis/yargs/y18n.svg -[coveralls-url]: https://coveralls.io/github/yargs/y18n -[coveralls-image]: https://img.shields.io/coveralls/yargs/y18n.svg [npm-url]: https://npmjs.org/package/y18n [npm-image]: https://img.shields.io/npm/v/y18n.svg [standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg diff --git a/package.json b/package.json index e64aca3a..3c523913 100644 --- a/package.json +++ b/package.json @@ -22,17 +22,16 @@ "index.js" ], "scripts": { - "coverage": "nyc report --reporter=text-lcov | coveralls", + "coverage": "nyc report && nyc check-coverage", "release": "standard-version", "pretest": "standard", "test": "nyc mocha" }, "devDependencies": { "chai": "^4.0.1", - "coveralls": "^3.0.0", "mocha": "^4.0.1", - "nyc": "^11.0.1", - "rimraf": "^2.5.0", + "nyc": "^15.1.0", + "rimraf": "^3.0.2", "standard": "^10.0.0-beta.0", "standard-version": "^5.0.0" }, From 887d8da59a84462313cd25b60d3217cf6f622166 Mon Sep 17 00:00:00 2001 From: bcoe Date: Tue, 4 Aug 2020 20:42:05 -0700 Subject: [PATCH 06/39] build: remove unused standard-version --- package.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/package.json b/package.json index 3c523913..ba621e74 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ ], "scripts": { "coverage": "nyc report && nyc check-coverage", - "release": "standard-version", "pretest": "standard", "test": "nyc mocha" }, @@ -32,8 +31,7 @@ "mocha": "^4.0.1", "nyc": "^15.1.0", "rimraf": "^3.0.2", - "standard": "^10.0.0-beta.0", - "standard-version": "^5.0.0" + "standard": "^10.0.0-beta.0" }, "engines": { "node": ">=10" From d35bfd3a34f6aa102d1b6d33e95d1c262552147a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 4 Aug 2020 20:43:12 -0700 Subject: [PATCH 07/39] chore(deps): update dependency mocha to v8 (#88) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ba621e74..f15959c8 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ }, "devDependencies": { "chai": "^4.0.1", - "mocha": "^4.0.1", + "mocha": "^8.0.0", "nyc": "^15.1.0", "rimraf": "^3.0.2", "standard": "^10.0.0-beta.0" From c51842196c8349519666911402f91735c707752b Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Tue, 4 Aug 2020 20:59:04 -0700 Subject: [PATCH 08/39] chore: update additional deps (#93) --- .nycrc | 2 +- package.json | 9 +++++---- test/y18n-test.js | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.nycrc b/.nycrc index 258129d5..22f97ab9 100644 --- a/.nycrc +++ b/.nycrc @@ -8,6 +8,6 @@ ], "branches": 96.5, "lines": 100, - "functions": 94, + "functions": 93, "statements": 100 } diff --git a/package.json b/package.json index f15959c8..ad989b65 100644 --- a/package.json +++ b/package.json @@ -22,16 +22,17 @@ "index.js" ], "scripts": { - "coverage": "nyc report && nyc check-coverage", + "fix": "standard --fix", + "coverage": "c8 --check-coverage report", "pretest": "standard", - "test": "nyc mocha" + "test": "c8 mocha" }, "devDependencies": { + "c8": "^7.3.0", "chai": "^4.0.1", "mocha": "^8.0.0", - "nyc": "^15.1.0", "rimraf": "^3.0.2", - "standard": "^10.0.0-beta.0" + "standard": "^14.3.4" }, "engines": { "node": ">=10" diff --git a/test/y18n-test.js b/test/y18n-test.js index 2ef27377..e96e8e69 100644 --- a/test/y18n-test.js +++ b/test/y18n-test.js @@ -11,7 +11,7 @@ require('chai').should() describe('y18n', function () { describe('configure', function () { it('allows you to override the default y18n configuration', function () { - var y = y18n({locale: 'fr'}) + var y = y18n({ locale: 'fr' }) y.locale.should.equal('fr') }) }) From e037d0be165f1acd7fe899fa43e43ba6d0c7cc8f Mon Sep 17 00:00:00 2001 From: QmarkC Date: Wed, 5 Aug 2020 01:00:29 -0500 Subject: [PATCH 09/39] docs: correct examples in README (#94) --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b80abac5..2d0b6cca 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,9 @@ Inspired by [i18n](https://www.npmjs.com/package/i18n). _simple string translation:_ ```js -var __ = require('y18n').__ +const __ = require('y18n')().__; -console.log(__('my awesome string %s', 'foo')) +console.log(__('my awesome string %s', 'foo')); ``` output: @@ -25,10 +25,11 @@ output: _using tagged template literals_ ```js -var __ = require('y18n').__ -var str = 'foo' +const __ = require('y18n')().__; -console.log(__`my awesome string ${str}`) +const str = 'foo'; + +console.log(__`my awesome string ${str}`); ``` output: @@ -38,9 +39,9 @@ output: _pluralization support:_ ```js -var __n = require('y18n').__n +const __n = require('y18n')().__n; -console.log(__n('one fish %s', '%d fishes %s', 2, 'foo')) +console.log(__n('one fish %s', '%d fishes %s', 2, 'foo')); ``` output: From 4d7ae94bcb42e84164e2180366474b1cd321ed94 Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Fri, 4 Sep 2020 17:20:51 -0700 Subject: [PATCH 10/39] feat: add support for ESM and Deno #95) BREAKING CHANGE: exports maps are now used, which modifies import behavior. --- .eslintrc | 21 +++ .github/workflows/ci.yaml | 22 +++ .github/workflows/release-please.yml | 32 +++- .gitignore | 2 + .nvmrc | 1 - README.md | 17 ++ deno.ts | 9 ++ index.js | 188 ---------------------- index.mjs | 8 + lib/cjs.ts | 8 + lib/index.ts | 227 +++++++++++++++++++++++++++ lib/platform-shims/deno.ts | 34 ++++ lib/platform-shims/node.ts | 19 +++ package.json | 45 +++++- rollup.config.js | 22 +++ test/deno/y18n-test.ts | 19 +++ test/esm/y18n-test.mjs | 18 +++ test/{y18n-test.js => y18n-test.cjs} | 13 +- tsconfig.json | 17 ++ tsconfig.test.json | 9 ++ 20 files changed, 526 insertions(+), 205 deletions(-) create mode 100644 .eslintrc delete mode 100644 .nvmrc create mode 100644 deno.ts delete mode 100644 index.js create mode 100644 index.mjs create mode 100644 lib/cjs.ts create mode 100644 lib/index.ts create mode 100644 lib/platform-shims/deno.ts create mode 100644 lib/platform-shims/node.ts create mode 100644 rollup.config.js create mode 100644 test/deno/y18n-test.ts create mode 100644 test/esm/y18n-test.mjs rename test/{y18n-test.js => y18n-test.cjs} (98%) create mode 100644 tsconfig.json create mode 100644 tsconfig.test.json diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..5ce8c64a --- /dev/null +++ b/.eslintrc @@ -0,0 +1,21 @@ +{ + "overrides": [ + { + "files": "*.ts", + "parser": "@typescript-eslint/parser", + "rules": { + "no-unused-vars": "off", + "no-useless-constructor": "off", + "@typescript-eslint/no-unused-vars": "error", + "@typescript-eslint/no-useless-constructor": "error" + } + } + ], + "parserOptions": { + "ecmaVersion": 2017, + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint/eslint-plugin" + ] +} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 18714f3a..a423c85b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -39,3 +39,25 @@ jobs: - run: npm install - run: npm test - run: npm run coverage + esm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '14.x' + - run: npm install + - run: npm run test:esm + deno: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 14 + - run: npm install + - run: npm run compile + - uses: denolib/setup-deno@v2 + - run: | + deno --version + deno test --allow-read test/deno/y18n-test.ts diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 38ace4d2..2fdb8216 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -7,8 +7,38 @@ jobs: release-please: runs-on: ubuntu-latest steps: - - uses: GoogleCloudPlatform/release-please-action@v1.6.3 + - uses: bcoe/release-please-action@v2.0.0 + id: release with: token: ${{ secrets.GITHUB_TOKEN }} release-type: node package-name: y18n + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 14 + - run: npm install + - run: npm run compile + - name: push Deno release + run: | + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + git remote add gh-token "https://${{ secrets.GITHUB_TOKEN}}@github.com/yargs/y18n.git" + git checkout -b deno + git add -f build + git commit -a -m 'chore: ${{ steps.release.outputs.tag_name }} release' + git push origin +deno + git tag -a ${{ steps.release.outputs.tag_name }}-deno -m 'chore: ${{ steps.release.outputs.tag_name }} release' + git push origin ${{ steps.release.outputs.tag_name }}-deno + if: ${{ steps.release.outputs.release_created }} + - uses: actions/setup-node@v1 + with: + node-version: 14 + registry-url: 'https://external-dot-oss-automation.appspot.com/' + if: ${{ steps.release.outputs.release_created }} + - run: npm install + if: ${{ steps.release.outputs.release_created }} + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + if: ${{ steps.release.outputs.release_created }} diff --git a/.gitignore b/.gitignore index 20bf8fcb..6430fa79 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ .DS_Store node_modules .nyc_output +build coverage package-lock.json +example.* diff --git a/.nvmrc b/.nvmrc deleted file mode 100644 index b009dfb9..00000000 --- a/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -lts/* diff --git a/README.md b/README.md index 2d0b6cca..5102bb17 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,23 @@ output: `2 fishes foo` +## Deno Example + +As of `v5` `y18n` supports [Deno](https://github.com/denoland/deno): + +```typescript +import y18n from "https://deno.land/x/y18n/deno.ts"; + +const __ = y18n({ + locale: 'pirate', + directory: './test/locales' +}).__ + +console.info(__`Hi, ${'Ben'} ${'Coe'}!`) +``` + +You will need to run with `--allow-read` to load alternative locales. + ## JSON Language Files The JSON language files should be stored in a `./locales` folder. diff --git a/deno.ts b/deno.ts new file mode 100644 index 00000000..b743c4f2 --- /dev/null +++ b/deno.ts @@ -0,0 +1,9 @@ +import { y18n as _y18n } from './build/lib/index.js' +import { Y18NOpts } from './build/lib/index.d.ts' +import shim from './lib/platform-shims/deno.ts' + +const y18n = (opts: Y18NOpts) => { + return _y18n(opts, shim) +} + +export default y18n diff --git a/index.js b/index.js deleted file mode 100644 index d7206816..00000000 --- a/index.js +++ /dev/null @@ -1,188 +0,0 @@ -var fs = require('fs') -var path = require('path') -var util = require('util') - -function Y18N (opts) { - // configurable options. - opts = opts || {} - this.directory = opts.directory || './locales' - this.updateFiles = typeof opts.updateFiles === 'boolean' ? opts.updateFiles : true - this.locale = opts.locale || 'en' - this.fallbackToLanguage = typeof opts.fallbackToLanguage === 'boolean' ? opts.fallbackToLanguage : true - - // internal stuff. - this.cache = {} - this.writeQueue = [] -} - -Y18N.prototype.__ = function () { - if (typeof arguments[0] !== 'string') { - return this._taggedLiteral.apply(this, arguments) - } - var args = Array.prototype.slice.call(arguments) - var str = args.shift() - var cb = function () {} // start with noop. - - if (typeof args[args.length - 1] === 'function') cb = args.pop() - cb = cb || function () {} // noop. - - if (!this.cache[this.locale]) this._readLocaleFile() - - // we've observed a new string, update the language file. - if (!this.cache[this.locale][str] && this.updateFiles) { - this.cache[this.locale][str] = str - - // include the current directory and locale, - // since these values could change before the - // write is performed. - this._enqueueWrite([this.directory, this.locale, cb]) - } else { - cb() - } - - return util.format.apply(util, [this.cache[this.locale][str] || str].concat(args)) -} - -Y18N.prototype._taggedLiteral = function (parts) { - var args = arguments - var str = '' - parts.forEach(function (part, i) { - var arg = args[i + 1] - str += part - if (typeof arg !== 'undefined') { - str += '%s' - } - }) - return this.__.apply(null, [str].concat([].slice.call(arguments, 1))) -} - -Y18N.prototype._enqueueWrite = function (work) { - this.writeQueue.push(work) - if (this.writeQueue.length === 1) this._processWriteQueue() -} - -Y18N.prototype._processWriteQueue = function () { - var _this = this - var work = this.writeQueue[0] - - // destructure the enqueued work. - var directory = work[0] - var locale = work[1] - var cb = work[2] - - var languageFile = this._resolveLocaleFile(directory, locale) - var serializedLocale = JSON.stringify(this.cache[locale], null, 2) - - fs.writeFile(languageFile, serializedLocale, 'utf-8', function (err) { - _this.writeQueue.shift() - if (_this.writeQueue.length > 0) _this._processWriteQueue() - cb(err) - }) -} - -Y18N.prototype._readLocaleFile = function () { - var localeLookup = {} - var languageFile = this._resolveLocaleFile(this.directory, this.locale) - - try { - localeLookup = JSON.parse(fs.readFileSync(languageFile, 'utf-8')) - } catch (err) { - if (err instanceof SyntaxError) { - err.message = 'syntax error in ' + languageFile - } - - if (err.code === 'ENOENT') localeLookup = {} - else throw err - } - - this.cache[this.locale] = localeLookup -} - -Y18N.prototype._resolveLocaleFile = function (directory, locale) { - var file = path.resolve(directory, './', locale + '.json') - if (this.fallbackToLanguage && !this._fileExistsSync(file) && ~locale.lastIndexOf('_')) { - // attempt fallback to language only - var languageFile = path.resolve(directory, './', locale.split('_')[0] + '.json') - if (this._fileExistsSync(languageFile)) file = languageFile - } - return file -} - -// this only exists because fs.existsSync() "will be deprecated" -// see https://nodejs.org/api/fs.html#fs_fs_existssync_path -Y18N.prototype._fileExistsSync = function (file) { - try { - return fs.statSync(file).isFile() - } catch (err) { - return false - } -} - -Y18N.prototype.__n = function () { - var args = Array.prototype.slice.call(arguments) - var singular = args.shift() - var plural = args.shift() - var quantity = args.shift() - - var cb = function () {} // start with noop. - if (typeof args[args.length - 1] === 'function') cb = args.pop() - - if (!this.cache[this.locale]) this._readLocaleFile() - - var str = quantity === 1 ? singular : plural - if (this.cache[this.locale][singular]) { - str = this.cache[this.locale][singular][quantity === 1 ? 'one' : 'other'] - } - - // we've observed a new string, update the language file. - if (!this.cache[this.locale][singular] && this.updateFiles) { - this.cache[this.locale][singular] = { - one: singular, - other: plural - } - - // include the current directory and locale, - // since these values could change before the - // write is performed. - this._enqueueWrite([this.directory, this.locale, cb]) - } else { - cb() - } - - // if a %d placeholder is provided, add quantity - // to the arguments expanded by util.format. - var values = [str] - if (~str.indexOf('%d')) values.push(quantity) - - return util.format.apply(util, values.concat(args)) -} - -Y18N.prototype.setLocale = function (locale) { - this.locale = locale -} - -Y18N.prototype.getLocale = function () { - return this.locale -} - -Y18N.prototype.updateLocale = function (obj) { - if (!this.cache[this.locale]) this._readLocaleFile() - - for (var key in obj) { - this.cache[this.locale][key] = obj[key] - } -} - -module.exports = function (opts) { - var y18n = new Y18N(opts) - - // bind all functions to y18n, so that - // they can be used in isolation. - for (var key in y18n) { - if (typeof y18n[key] === 'function') { - y18n[key] = y18n[key].bind(y18n) - } - } - - return y18n -} diff --git a/index.mjs b/index.mjs new file mode 100644 index 00000000..46c82133 --- /dev/null +++ b/index.mjs @@ -0,0 +1,8 @@ +import shim from './build/lib/platform-shims/node.js' +import { y18n as _y18n } from './build/lib/index.js' + +const y18n = (opts) => { + return _y18n(opts, shim) +} + +export default y18n diff --git a/lib/cjs.ts b/lib/cjs.ts new file mode 100644 index 00000000..1ba6a58c --- /dev/null +++ b/lib/cjs.ts @@ -0,0 +1,8 @@ +import { y18n as _y18n, Y18NOpts } from './index.js' +import nodePlatformShim from './platform-shims/node.js' + +const y18n = (opts: Y18NOpts) => { + return _y18n(opts, nodePlatformShim) +} + +export default y18n diff --git a/lib/index.ts b/lib/index.ts new file mode 100644 index 00000000..864cbac2 --- /dev/null +++ b/lib/index.ts @@ -0,0 +1,227 @@ +export interface Y18NOpts { + directory?: string; + updateFiles?: boolean; + locale?: string; + fallbackToLanguage?: boolean; +} + +interface Work { + directory: string; + locale: string; + cb: Function +} + +export interface Locale { + [key: string]: string +} + +interface CacheEntry { + [key: string]: string; +} + +export interface PlatformShim { + fs: { + readFileSync: Function, + writeFile: Function + }, + exists: Function, + format: Function, + resolve: Function +} + +let shim: PlatformShim +class Y18N { + directory: string; + updateFiles: boolean; + locale: string; + fallbackToLanguage: boolean; + writeQueue: Work[]; + cache: {[key: string]: {[key: string]: CacheEntry|string}}; + + constructor (opts: Y18NOpts) { + // configurable options. + opts = opts || {} + this.directory = opts.directory || './locales' + this.updateFiles = typeof opts.updateFiles === 'boolean' ? opts.updateFiles : true + this.locale = opts.locale || 'en' + this.fallbackToLanguage = typeof opts.fallbackToLanguage === 'boolean' ? opts.fallbackToLanguage : true + + // internal stuff. + this.cache = {} + this.writeQueue = [] + } + + __ (...args: (string|Function)[]): string { + if (typeof arguments[0] !== 'string') { + return this._taggedLiteral(arguments[0] as string[], ...arguments) + } + const str: string = args.shift() as string + + let cb: Function = function () {} // start with noop. + if (typeof args[args.length - 1] === 'function') cb = (args.pop() as Function) + cb = cb || function () {} // noop. + + if (!this.cache[this.locale]) this._readLocaleFile() + + // we've observed a new string, update the language file. + if (!this.cache[this.locale][str] && this.updateFiles) { + this.cache[this.locale][str] = str + + // include the current directory and locale, + // since these values could change before the + // write is performed. + this._enqueueWrite({ + directory: this.directory, + locale: this.locale, + cb + }) + } else { + cb() + } + + return shim.format.apply(shim.format, [this.cache[this.locale][str] || str].concat(args as string[])) + } + + __n () { + const args = Array.prototype.slice.call(arguments) + const singular: string = args.shift() + const plural: string = args.shift() + const quantity: number = args.shift() + + let cb = function () {} // start with noop. + if (typeof args[args.length - 1] === 'function') cb = args.pop() + + if (!this.cache[this.locale]) this._readLocaleFile() + + let str = quantity === 1 ? singular : plural + if (this.cache[this.locale][singular]) { + const entry = this.cache[this.locale][singular] as CacheEntry + str = entry[quantity === 1 ? 'one' : 'other'] + } + + // we've observed a new string, update the language file. + if (!this.cache[this.locale][singular] && this.updateFiles) { + this.cache[this.locale][singular] = { + one: singular, + other: plural + } + + // include the current directory and locale, + // since these values could change before the + // write is performed. + this._enqueueWrite({ + directory: this.directory, + locale: this.locale, + cb + }) + } else { + cb() + } + + // if a %d placeholder is provided, add quantity + // to the arguments expanded by util.format. + var values: (string|number)[] = [str] + if (~str.indexOf('%d')) values.push(quantity) + + return shim.format.apply(shim.format, values.concat(args)) + } + + setLocale (locale: string) { + this.locale = locale + } + + getLocale () { + return this.locale + } + + updateLocale (obj: Locale) { + if (!this.cache[this.locale]) this._readLocaleFile() + + for (const key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + this.cache[this.locale][key] = obj[key] + } + } + } + + _taggedLiteral (parts: string[], ...args: string[]) { + let str = '' + parts.forEach(function (part, i) { + var arg = args[i + 1] + str += part + if (typeof arg !== 'undefined') { + str += '%s' + } + }) + return this.__.apply(this, [str].concat([].slice.call(args, 1))) + } + + _enqueueWrite (work: Work) { + this.writeQueue.push(work) + if (this.writeQueue.length === 1) this._processWriteQueue() + } + + _processWriteQueue () { + var _this = this + var work = this.writeQueue[0] + + // destructure the enqueued work. + var directory = work.directory + var locale = work.locale + var cb = work.cb + + var languageFile = this._resolveLocaleFile(directory, locale) + var serializedLocale = JSON.stringify(this.cache[locale], null, 2) + + shim.fs.writeFile(languageFile, serializedLocale, 'utf-8', function (err: Error) { + _this.writeQueue.shift() + if (_this.writeQueue.length > 0) _this._processWriteQueue() + cb(err) + }) + } + + _readLocaleFile () { + var localeLookup = {} + var languageFile = this._resolveLocaleFile(this.directory, this.locale) + + try { + localeLookup = JSON.parse(shim.fs.readFileSync(languageFile, 'utf-8')) + } catch (err) { + if (err instanceof SyntaxError) { + err.message = 'syntax error in ' + languageFile + } + + if (err.code === 'ENOENT') localeLookup = {} + else throw err + } + + this.cache[this.locale] = localeLookup + } + + _resolveLocaleFile (directory: string, locale: string) { + var file = shim.resolve(directory, './', locale + '.json') + if (this.fallbackToLanguage && !this._fileExistsSync(file) && ~locale.lastIndexOf('_')) { + // attempt fallback to language only + var languageFile = shim.resolve(directory, './', locale.split('_')[0] + '.json') + if (this._fileExistsSync(languageFile)) file = languageFile + } + return file + } + + _fileExistsSync (file: string) { + return shim.exists(file) + } +} + +export function y18n (opts: Y18NOpts, _shim: PlatformShim) { + shim = _shim + const y18n = new Y18N(opts) + return { + __: y18n.__.bind(y18n), + __n: y18n.__n.bind(y18n), + setLocale: y18n.setLocale.bind(y18n), + getLocale: y18n.getLocale.bind(y18n), + updateLocale: y18n.updateLocale.bind(y18n), + locale: y18n.locale + } +} diff --git a/lib/platform-shims/deno.ts b/lib/platform-shims/deno.ts new file mode 100644 index 00000000..3cd243ea --- /dev/null +++ b/lib/platform-shims/deno.ts @@ -0,0 +1,34 @@ +/* global Deno */ + +import { posix } from 'https://deno.land/std/path/mod.ts' +import { sprintf } from 'https://deno.land/std/fmt/printf.ts' + +export default { + fs: { + readFileSync: (path: string) => { + try { + return Deno.readTextFileSync(path) + } catch (err) { + // Fake the same error as Node.js, so that it does not bubble. + err.code = 'ENOENT' + throw err + } + }, + writeFile: Deno.writeFile + }, + format: sprintf, + resolve: (base: string, p1: string, p2: string) => { + try { + return posix.resolve(base, p1, p2) + } catch (err) { + // Most likely we simply don't have --allow-read set. + } + }, + exists: (file: string) => { + try { + return Deno.statSync(file).isFile + } catch (err) { + return false + } + } +} diff --git a/lib/platform-shims/node.ts b/lib/platform-shims/node.ts new file mode 100644 index 00000000..2d40e7b7 --- /dev/null +++ b/lib/platform-shims/node.ts @@ -0,0 +1,19 @@ +import { readFileSync, statSync, writeFile } from 'fs' +import { format } from 'util' +import { resolve } from 'path' + +export default { + fs: { + readFileSync, + writeFile + }, + format, + resolve, + exists: (file: string) => { + try { + return statSync(file).isFile() + } catch (err) { + return false + } + } +} diff --git a/package.json b/package.json index ad989b65..df422086 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,13 @@ "name": "y18n", "version": "4.0.0", "description": "the bare-bones internationalization library used by yargs", + "exports": { + "import": "./index.mjs", + "require": "./build/index.cjs" + }, + "type": "module", + "module": "./build/lib/index.js", + "types": "./build/index.cjs.d.ts", "keywords": [ "i18n", "internationalization", @@ -18,23 +25,45 @@ "license": "ISC", "author": "Ben Coe ", "main": "index.js", - "files": [ - "index.js" - ], "scripts": { - "fix": "standard --fix", - "coverage": "c8 --check-coverage report", - "pretest": "standard", - "test": "c8 mocha" + "check": "standardx '**/*.ts' '**/*.cjs' '**/*.mjs'", + "fix": "standardx --fix '**/*.ts' '**/*.cjs' '**/*.mjs'", + "pretest": "rimraf build && tsc -p tsconfig.test.json && cross-env NODE_ENV=test npm run build:cjs", + "test": "c8 --reporter=text --reporter=html mocha test/*.cjs", + "test:esm": "c8 --reporter=text --reporter=html mocha test/esm/*.mjs", + "posttest": "npm run check", + "coverage": "c8 report --check-coverage", + "precompile": "rimraf build", + "compile": "tsc", + "postcompile": "npm run build:cjs", + "build:cjs": "rollup -c", + "prepare": "npm run compile" }, "devDependencies": { + "@types/node": "^14.6.4", + "@wessberg/rollup-plugin-ts": "^1.3.1", "c8": "^7.3.0", "chai": "^4.0.1", + "cross-env": "^7.0.2", + "gts": "^2.0.2", "mocha": "^8.0.0", "rimraf": "^3.0.2", - "standard": "^14.3.4" + "rollup": "^2.26.10", + "standardx": "^5.0.0", + "ts-transform-default-export": "^1.0.2", + "typescript": "^3.9.7" }, + "files": [ + "build", + "index.mjs", + "!*.d.ts" + ], "engines": { "node": ">=10" + }, + "standardx": { + "ignore": [ + "build" + ] } } diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 00000000..537ce1e7 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,22 @@ +import ts from '@wessberg/rollup-plugin-ts' +import transformDefaultExport from 'ts-transform-default-export' + +const output = { + format: 'cjs', + file: './build/index.cjs', + exports: 'default' +} + +if (process.env.NODE_ENV === 'test') output.sourcemap = true + +export default { + input: './lib/cjs.ts', + output, + plugins: [ + ts({ + transformers: ({ program }) => ({ + afterDeclarations: transformDefaultExport(program) + }) + }), + ] +} diff --git a/test/deno/y18n-test.ts b/test/deno/y18n-test.ts new file mode 100644 index 00000000..9b1b497c --- /dev/null +++ b/test/deno/y18n-test.ts @@ -0,0 +1,19 @@ +/* global Deno */ + +import { + assertEquals +} from 'https://deno.land/std/testing/asserts.ts' +import y18n from '../../deno.ts' + +// Parser: +Deno.test('smoke test', () => { + const __ = y18n({ + locale: 'pirate', + directory: './test/locales' + }).__ + + assertEquals( + __`Hi, ${'Ben'} ${'Coe'}!`, + 'Yarr! Shiver me timbers, why \'tis Ben Coe!' + ) +}) diff --git a/test/esm/y18n-test.mjs b/test/esm/y18n-test.mjs new file mode 100644 index 00000000..c8675ae7 --- /dev/null +++ b/test/esm/y18n-test.mjs @@ -0,0 +1,18 @@ +/* global describe, it */ + +import * as assert from 'assert' +import y18n from '../../index.mjs' + +describe('y18n', function () { + it('__ smoke test', function () { + const __ = y18n({ + locale: 'pirate', + directory: './test/locales' + }).__ + + assert.strictEqual( + __`Hi, ${'Ben'} ${'Coe'}!`, + 'Yarr! Shiver me timbers, why \'tis Ben Coe!' + ) + }) +}) diff --git a/test/y18n-test.js b/test/y18n-test.cjs similarity index 98% rename from test/y18n-test.js rename to test/y18n-test.cjs index e96e8e69..d65b14b9 100644 --- a/test/y18n-test.js +++ b/test/y18n-test.cjs @@ -1,17 +1,17 @@ /* global describe, it, after, beforeEach */ -var expect = require('chai').expect -var fs = require('fs') -var rimraf = require('rimraf') -var y18n = require('../') -var path = require('path') +const expect = require('chai').expect +const fs = require('fs') +const rimraf = require('rimraf') +const y18n = require('../build/index.cjs') +const path = require('path') require('chai').should() describe('y18n', function () { describe('configure', function () { it('allows you to override the default y18n configuration', function () { - var y = y18n({ locale: 'fr' }) + const y = y18n({ locale: 'fr' }) y.locale.should.equal('fr') }) }) @@ -43,7 +43,6 @@ describe('y18n', function () { locale: 'pirate', directory: path.join(__dirname, 'locales') }).__ - __`Hi, ${'Ben'} ${''}!`.should.equal('Yarr! Shiver me timbers, why \'tis Ben !') }) it('uses replacements from the default locale if none is configured', function () { diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..93187451 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "outDir": "build", + "rootDir": ".", + "sourceMap": false, + "target": "es2017", + "moduleResolution": "node", + "module": "es2015" + }, + "include": [ + "lib/**/*.ts" + ], + "exclude": [ + "lib/platform-shims/deno.ts" + ] +} \ No newline at end of file diff --git a/tsconfig.test.json b/tsconfig.test.json new file mode 100644 index 00000000..b2175ed7 --- /dev/null +++ b/tsconfig.test.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "sourceMap": true + }, + "exclude": [ + "lib/platform-shims/deno.ts" + ] +} From cb3020d7a1e600c05de4f0241dd975df978fe44c Mon Sep 17 00:00:00 2001 From: bcoe Date: Fri, 4 Sep 2020 17:33:26 -0700 Subject: [PATCH 11/39] build: debugging bad build --- .github/workflows/release-please.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 2fdb8216..8e6931a6 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -7,7 +7,7 @@ jobs: release-please: runs-on: ubuntu-latest steps: - - uses: bcoe/release-please-action@v2.0.0 + - uses: bcoe/release-please-action@vbd0f83e02efdd2c31be9dce8b84029901937b8c3 id: release with: token: ${{ secrets.GITHUB_TOKEN }} From 6545bac809a0cc70760ee6ef4db69ec6748bbbdc Mon Sep 17 00:00:00 2001 From: bcoe Date: Fri, 4 Sep 2020 17:34:57 -0700 Subject: [PATCH 12/39] build: debugging bad build --- .github/workflows/release-please.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 8e6931a6..95808250 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -7,7 +7,7 @@ jobs: release-please: runs-on: ubuntu-latest steps: - - uses: bcoe/release-please-action@vbd0f83e02efdd2c31be9dce8b84029901937b8c3 + - uses: bcoe/release-please-action@bd0f83e02efdd2c31be9dce8b84029901937b8c3 id: release with: token: ${{ secrets.GITHUB_TOKEN }} From 2da6117cb957e1237a995a20f78ea0c99e4f620b Mon Sep 17 00:00:00 2001 From: bcoe Date: Fri, 4 Sep 2020 17:38:19 -0700 Subject: [PATCH 13/39] build: debugging bad build --- .github/workflows/release-please.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 95808250..954518a4 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -7,7 +7,7 @@ jobs: release-please: runs-on: ubuntu-latest steps: - - uses: bcoe/release-please-action@bd0f83e02efdd2c31be9dce8b84029901937b8c3 + - uses: bcoe/release-please-action@2de94231038df0944a3337e28aed6265e1c3cd75 id: release with: token: ${{ secrets.GITHUB_TOKEN }} From 5b3d158920e2b503d7b1cf22bf53366034d25920 Mon Sep 17 00:00:00 2001 From: bcoe Date: Fri, 4 Sep 2020 17:44:16 -0700 Subject: [PATCH 14/39] build: debugging bad build --- .github/workflows/release-please.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 954518a4..dcb037c9 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -7,7 +7,7 @@ jobs: release-please: runs-on: ubuntu-latest steps: - - uses: bcoe/release-please-action@2de94231038df0944a3337e28aed6265e1c3cd75 + - uses: bcoe/release-please-action@bdeb9cc0a2b91f41f878097a61b9587c86f422b3 id: release with: token: ${{ secrets.GITHUB_TOKEN }} From 90eda2d6b11d07b6e5fe021833a0d57f4c821db1 Mon Sep 17 00:00:00 2001 From: bcoe Date: Fri, 4 Sep 2020 17:56:29 -0700 Subject: [PATCH 15/39] build: debugging bad build --- .github/workflows/release-please.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index dcb037c9..56da58f4 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -7,7 +7,7 @@ jobs: release-please: runs-on: ubuntu-latest steps: - - uses: bcoe/release-please-action@bdeb9cc0a2b91f41f878097a61b9587c86f422b3 + - uses: bcoe/release-please-action@f941de91f075b1d1b343d87afb7640279182635f id: release with: token: ${{ secrets.GITHUB_TOKEN }} From b9489dc3bcff1fc1729d36147ea1e048b58a2ea8 Mon Sep 17 00:00:00 2001 From: bcoe Date: Fri, 4 Sep 2020 18:08:51 -0700 Subject: [PATCH 16/39] build: debugging bad build --- .github/workflows/release-please.yml | 2 +- CHANGELOG.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 56da58f4..35322243 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -7,7 +7,7 @@ jobs: release-please: runs-on: ubuntu-latest steps: - - uses: bcoe/release-please-action@f941de91f075b1d1b343d87afb7640279182635f + - uses: bcoe/release-please-action@2.1.0 id: release with: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index c259076a..0d6bdfe2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. -# [4.0.0](https://github.com/yargs/y18n/compare/v3.2.1...v4.0.0) (2017-10-10) +## [4.0.0](https://github.com/yargs/y18n/compare/v3.2.1...v4.0.0) (2017-10-10) ### Bug Fixes From 0d90d507685717cac145fa932ebe6f27900b4605 Mon Sep 17 00:00:00 2001 From: bcoe Date: Fri, 4 Sep 2020 18:14:30 -0700 Subject: [PATCH 17/39] force workflow From 467b4b781607fc9d8e8ea4eceb08a1084efc6a29 Mon Sep 17 00:00:00 2001 From: bcoe Date: Fri, 4 Sep 2020 18:45:48 -0700 Subject: [PATCH 18/39] build: use 2.x release --- .github/workflows/release-please.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 35322243..83e4d180 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -7,7 +7,7 @@ jobs: release-please: runs-on: ubuntu-latest steps: - - uses: bcoe/release-please-action@2.1.0 + - uses: bcoe/release-please-action@2.x id: release with: token: ${{ secrets.GITHUB_TOKEN }} From 25d896227b6d52f312f7139276ddada29b743f78 Mon Sep 17 00:00:00 2001 From: bcoe Date: Fri, 4 Sep 2020 18:47:14 -0700 Subject: [PATCH 19/39] build: fix action release tag --- .github/workflows/release-please.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 83e4d180..2c35d8af 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -7,7 +7,7 @@ jobs: release-please: runs-on: ubuntu-latest steps: - - uses: bcoe/release-please-action@2.x + - uses: bcoe/release-please-action@v2.1.0 id: release with: token: ${{ secrets.GITHUB_TOKEN }} From 1a5852ab157124e270970509a2701bbe0623e923 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 4 Sep 2020 19:06:19 -0700 Subject: [PATCH 20/39] chore(deps): update dependency typescript to v4 (#97) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index df422086..92a297ef 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "rollup": "^2.26.10", "standardx": "^5.0.0", "ts-transform-default-export": "^1.0.2", - "typescript": "^3.9.7" + "typescript": "^4.0.0" }, "files": [ "build", From b28463122cf0018724075c2604900ee5e2cdd35a Mon Sep 17 00:00:00 2001 From: bcoe Date: Fri, 4 Sep 2020 19:20:17 -0700 Subject: [PATCH 21/39] build: experiment with label for kicking off build --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a423c85b..5959957d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,6 +4,7 @@ on: branches: - master pull_request: + types: [ assigned, opened, synchronize, reopened, labeled ] env: CI: true jobs: From f2beb1ea02532b8508a696bbc0407f32c1e89599 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 4 Sep 2020 19:28:00 -0700 Subject: [PATCH 22/39] chore: release 5.0.0 (#91) --- CHANGELOG.md | 18 +++++++++++++++++- package.json | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d6bdfe2..27c75c41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,23 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. - +## [5.0.0](https://www.github.com/yargs/y18n/compare/v4.0.0...v5.0.0) (2020-09-05) + + +### ⚠ BREAKING CHANGES + +* exports maps are now used, which modifies import behavior. +* drops Node 6 and 4. begin following Node.js LTS schedule (#89) + +### Features + +* add support for ESM and Deno [#95](https://www.github.com/yargs/y18n/issues/95)) ([4d7ae94](https://www.github.com/yargs/y18n/commit/4d7ae94bcb42e84164e2180366474b1cd321ed94)) + + +### Build System + +* drops Node 6 and 4. begin following Node.js LTS schedule ([#89](https://www.github.com/yargs/y18n/issues/89)) ([3cc0c28](https://www.github.com/yargs/y18n/commit/3cc0c287240727b84eaf1927f903612ec80f5e43)) + ## [4.0.0](https://github.com/yargs/y18n/compare/v3.2.1...v4.0.0) (2017-10-10) diff --git a/package.json b/package.json index 92a297ef..d0b99fbb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "y18n", - "version": "4.0.0", + "version": "5.0.0", "description": "the bare-bones internationalization library used by yargs", "exports": { "import": "./index.mjs", From 335133842bfa398ba34d53ae17135d2604bf3e68 Mon Sep 17 00:00:00 2001 From: bcoe Date: Fri, 4 Sep 2020 19:30:50 -0700 Subject: [PATCH 23/39] build: switch package.json to format supported by wombat --- package.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/package.json b/package.json index d0b99fbb..805f6f65 100644 --- a/package.json +++ b/package.json @@ -18,10 +18,7 @@ "bugs": { "url": "https://github.com/yargs/y18n/issues" }, - "repository": { - "type": "git", - "url": "git@github.com:yargs/y18n.git" - }, + "repository": "yargs/y18n", "license": "ISC", "author": "Ben Coe ", "main": "index.js", From 124f7b047ba9596bdbdf64459988304e77f3de1b Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Sat, 5 Sep 2020 16:51:50 -0700 Subject: [PATCH 24/39] fix: main had old index path (#98) --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 805f6f65..78e772b9 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ }, "type": "module", "module": "./build/lib/index.js", - "types": "./build/index.cjs.d.ts", "keywords": [ "i18n", "internationalization", @@ -21,7 +20,7 @@ "repository": "yargs/y18n", "license": "ISC", "author": "Ben Coe ", - "main": "index.js", + "main": "./build/index.cjs", "scripts": { "check": "standardx '**/*.ts' '**/*.cjs' '**/*.mjs'", "fix": "standardx --fix '**/*.ts' '**/*.cjs' '**/*.mjs'", From 9c8a079a2917b71dd55086233f4272da521fc600 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 5 Sep 2020 16:56:24 -0700 Subject: [PATCH 25/39] chore: release 5.0.1 (#99) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27c75c41..e6d63df0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [5.0.1](https://www.github.com/yargs/y18n/compare/v5.0.0...v5.0.1) (2020-09-05) + + +### Bug Fixes + +* main had old index path ([#98](https://www.github.com/yargs/y18n/issues/98)) ([124f7b0](https://www.github.com/yargs/y18n/commit/124f7b047ba9596bdbdf64459988304e77f3de1b)) + ## [5.0.0](https://www.github.com/yargs/y18n/compare/v4.0.0...v5.0.0) (2020-09-05) diff --git a/package.json b/package.json index 78e772b9..62f695e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "y18n", - "version": "5.0.0", + "version": "5.0.1", "description": "the bare-bones internationalization library used by yargs", "exports": { "import": "./index.mjs", From 3834d9ab1332f2937c935ada5e76623290efae81 Mon Sep 17 00:00:00 2001 From: Luke John Date: Fri, 2 Oct 2020 02:08:55 +0800 Subject: [PATCH 26/39] fix(deno): update types for deno ^1.4.0 (#100) In version 1.4 Deno adopted; - the tsconfig setting [importsNotUsedAsValues](https://www.typescriptlang.org/tsconfig#importsNotUsedAsValues) - https://github.com/denoland/deno/pull/7413 This requires the use of; - type only imports for values which are only used as types (`importsNotUsedAsValues`) --- deno.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deno.ts b/deno.ts index b743c4f2..feae3e4f 100644 --- a/deno.ts +++ b/deno.ts @@ -1,5 +1,5 @@ import { y18n as _y18n } from './build/lib/index.js' -import { Y18NOpts } from './build/lib/index.d.ts' +import type { Y18NOpts } from './build/lib/index.d.ts' import shim from './lib/platform-shims/deno.ts' const y18n = (opts: Y18NOpts) => { From fd0e21a8adb303142d9f160615e75ce847bd415a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 1 Oct 2020 11:21:45 -0700 Subject: [PATCH 27/39] chore: release 5.0.2 (#101) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6d63df0..8d85a890 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [5.0.2](https://www.github.com/yargs/y18n/compare/v5.0.1...v5.0.2) (2020-10-01) + + +### Bug Fixes + +* **deno:** update types for deno ^1.4.0 ([#100](https://www.github.com/yargs/y18n/issues/100)) ([3834d9a](https://www.github.com/yargs/y18n/commit/3834d9ab1332f2937c935ada5e76623290efae81)) + ### [5.0.1](https://www.github.com/yargs/y18n/compare/v5.0.0...v5.0.1) (2020-09-05) diff --git a/package.json b/package.json index 62f695e1..424f8638 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "y18n", - "version": "5.0.1", + "version": "5.0.2", "description": "the bare-bones internationalization library used by yargs", "exports": { "import": "./index.mjs", From bbf3bfdb1c24f89e8e8132abb88a832becdf9bf0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 14 Oct 2020 12:18:49 -0700 Subject: [PATCH 28/39] chore(deps): update dependency gts to v3 (#102) Co-authored-by: Renovate Bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 424f8638..35d97d43 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "c8": "^7.3.0", "chai": "^4.0.1", "cross-env": "^7.0.2", - "gts": "^2.0.2", + "gts": "^3.0.0", "mocha": "^8.0.0", "rimraf": "^3.0.2", "rollup": "^2.26.10", From 091c7cd2f7ff770d00b045a107d2c727b56dfc5d Mon Sep 17 00:00:00 2001 From: bcoe Date: Wed, 14 Oct 2020 12:21:39 -0700 Subject: [PATCH 29/39] build: newest version of action --- .github/workflows/release-please.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 2c35d8af..b9a3b136 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -7,7 +7,7 @@ jobs: release-please: runs-on: ubuntu-latest steps: - - uses: bcoe/release-please-action@v2.1.0 + - uses: bcoe/release-please-action@v2.5.5 id: release with: token: ${{ secrets.GITHUB_TOKEN }} From e39921e1017f88f5d8ea97ddea854ffe92d68e74 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 15 Oct 2020 18:31:53 -0700 Subject: [PATCH 30/39] fix(exports): node 13.0-13.6 require a string fallback (#103) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit package.json’s "engines" field claims yargs-parser supports node >= 10; node v13.0-v13.6 are included in this semver range. This change is required to be able to require() from yargs-parser successfully in these versions. See https://github.com/yargs/yargs/pull/1776 --- package.json | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 35d97d43..420d52f8 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,13 @@ "name": "y18n", "version": "5.0.2", "description": "the bare-bones internationalization library used by yargs", - "exports": { - "import": "./index.mjs", - "require": "./build/index.cjs" - }, + "exports": [ + { + "import": "./index.mjs", + "require": "./build/index.cjs" + }, + "./build/index.cjs" + ], "type": "module", "module": "./build/lib/index.js", "keywords": [ From 3c4e24168c650b4a4a2facd68744c701780b60a9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 15 Oct 2020 18:50:41 -0700 Subject: [PATCH 31/39] chore: release 5.0.3 (#104) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d85a890..19f14b02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [5.0.3](https://www.github.com/yargs/y18n/compare/v5.0.2...v5.0.3) (2020-10-16) + + +### Bug Fixes + +* **exports:** node 13.0-13.6 require a string fallback ([#103](https://www.github.com/yargs/y18n/issues/103)) ([e39921e](https://www.github.com/yargs/y18n/commit/e39921e1017f88f5d8ea97ddea854ffe92d68e74)) + ### [5.0.2](https://www.github.com/yargs/y18n/compare/v5.0.1...v5.0.2) (2020-10-01) diff --git a/package.json b/package.json index 420d52f8..9854a5bd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "y18n", - "version": "5.0.2", + "version": "5.0.3", "description": "the bare-bones internationalization library used by yargs", "exports": [ { From 4f85d80dbaae6d2c7899ae394f7ad97805df4886 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 15 Oct 2020 22:49:52 -0700 Subject: [PATCH 32/39] fix(exports): node 13.0 and 13.1 require the dotted object form _with_ a string fallback (#105) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit package.json’s "engines" field claims yargs-parser supports node >= 10; node v13.0 and v13.1 are included in this semver range. This change is required to be able to require() from yargs-parser successfully in these versions. See https://github.com/yargs/yargs/pull/1776 --- package.json | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 9854a5bd..5632b4c6 100644 --- a/package.json +++ b/package.json @@ -2,13 +2,15 @@ "name": "y18n", "version": "5.0.3", "description": "the bare-bones internationalization library used by yargs", - "exports": [ - { - "import": "./index.mjs", - "require": "./build/index.cjs" - }, - "./build/index.cjs" - ], + "exports": { + ".": [ + { + "import": "./index.mjs", + "require": "./build/index.cjs" + }, + "./build/index.cjs" + ] + }, "type": "module", "module": "./build/lib/index.js", "keywords": [ From 61a8b9a4c747f7482bcee7a7c134b499313ebb52 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 16 Oct 2020 08:43:22 -0700 Subject: [PATCH 33/39] chore: release 5.0.4 (#106) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19f14b02..b86ddf9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [5.0.4](https://www.github.com/yargs/y18n/compare/v5.0.3...v5.0.4) (2020-10-16) + + +### Bug Fixes + +* **exports:** node 13.0 and 13.1 require the dotted object form _with_ a string fallback ([#105](https://www.github.com/yargs/y18n/issues/105)) ([4f85d80](https://www.github.com/yargs/y18n/commit/4f85d80dbaae6d2c7899ae394f7ad97805df4886)) + ### [5.0.3](https://www.github.com/yargs/y18n/compare/v5.0.2...v5.0.3) (2020-10-16) diff --git a/package.json b/package.json index 5632b4c6..ba713184 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "y18n", - "version": "5.0.3", + "version": "5.0.4", "description": "the bare-bones internationalization library used by yargs", "exports": { ".": [ From a9ac604abf756dec9687be3843e2c93bfe581f25 Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Sun, 25 Oct 2020 10:59:56 -0400 Subject: [PATCH 34/39] fix: address prototype pollution issue (#108) --- lib/index.ts | 2 +- test/y18n-test.cjs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/index.ts b/lib/index.ts index 864cbac2..07d99e3b 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -47,7 +47,7 @@ class Y18N { this.fallbackToLanguage = typeof opts.fallbackToLanguage === 'boolean' ? opts.fallbackToLanguage : true // internal stuff. - this.cache = {} + this.cache = Object.create(null) this.writeQueue = [] } diff --git a/test/y18n-test.cjs b/test/y18n-test.cjs index d65b14b9..a14941b1 100644 --- a/test/y18n-test.cjs +++ b/test/y18n-test.cjs @@ -351,6 +351,24 @@ describe('y18n', function () { }) }) + // See: https://github.com/yargs/y18n/issues/96, + // https://github.com/yargs/y18n/pull/107 + describe('prototype pollution', () => { + it('does not pollute prototype, with __proto__ locale', () => { + const y = y18n() + y.setLocale('__proto__') + y.updateLocale({ polluted: '👽' }) + y.__('polluted').should.equal('👽') + ;(typeof polluted).should.equal('undefined') + }) + + it('does not pollute prototype, when __ is used with __proto__ locale', () => { + const __ = y18n({ locale: '__proto__' }).__ + __('hello') + ;(typeof {}.hello).should.equal('undefined') + }) + }) + after(function () { rimraf.sync('./test/locales/fr.json') }) From b22c0df59d0851d7be9fd1d51f6a5ee974c9fc94 Mon Sep 17 00:00:00 2001 From: "Benjamin E. Coe" Date: Tue, 6 Apr 2021 18:28:19 -0700 Subject: [PATCH 35/39] fix(security): ensure entry exists for backport (#120) --- .github/workflows/release-please.yml | 36 +++------------------------- .release-please-manifest.json | 3 +++ package.json | 2 +- release-please-config.json | 8 +++++++ 4 files changed, 15 insertions(+), 34 deletions(-) create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index b9a3b136..d17988ef 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -1,44 +1,14 @@ on: push: branches: - - master + - 4.x.x name: release-please jobs: release-please: runs-on: ubuntu-latest steps: - - uses: bcoe/release-please-action@v2.5.5 + - uses: bcoe/release-please-action@v2 id: release with: token: ${{ secrets.GITHUB_TOKEN }} - release-type: node - package-name: y18n - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 14 - - run: npm install - - run: npm run compile - - name: push Deno release - run: | - git config user.name github-actions[bot] - git config user.email 41898282+github-actions[bot]@users.noreply.github.com - git remote add gh-token "https://${{ secrets.GITHUB_TOKEN}}@github.com/yargs/y18n.git" - git checkout -b deno - git add -f build - git commit -a -m 'chore: ${{ steps.release.outputs.tag_name }} release' - git push origin +deno - git tag -a ${{ steps.release.outputs.tag_name }}-deno -m 'chore: ${{ steps.release.outputs.tag_name }} release' - git push origin ${{ steps.release.outputs.tag_name }}-deno - if: ${{ steps.release.outputs.release_created }} - - uses: actions/setup-node@v1 - with: - node-version: 14 - registry-url: 'https://external-dot-oss-automation.appspot.com/' - if: ${{ steps.release.outputs.release_created }} - - run: npm install - if: ${{ steps.release.outputs.release_created }} - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} - if: ${{ steps.release.outputs.release_created }} + command: manifest diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..cbecc517 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "4.0.1", +} diff --git a/package.json b/package.json index ba713184..8e2a64d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "y18n", - "version": "5.0.4", + "version": "4.0.1", "description": "the bare-bones internationalization library used by yargs", "exports": { ".": [ diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..25edcf30 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,8 @@ +{ + "bootstrap-sha": "a9ac604abf756dec9687be3843e2c93bfe581f25", + "packages": { + ".": { + "release-type": "node" + } + } +} From 910ff4cada50c52e77bac7d031f257b33ff1d12d Mon Sep 17 00:00:00 2001 From: bcoe Date: Tue, 6 Apr 2021 18:33:25 -0700 Subject: [PATCH 36/39] build: use appropriate releaser --- .github/workflows/release-please.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index d17988ef..3471b097 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -7,7 +7,7 @@ jobs: release-please: runs-on: ubuntu-latest steps: - - uses: bcoe/release-please-action@v2 + - uses: google-github-actions/release-please-action@v2 id: release with: token: ${{ secrets.GITHUB_TOKEN }} From d65aef19626d17077361e9ae5c1d99af77acb078 Mon Sep 17 00:00:00 2001 From: bcoe Date: Tue, 6 Apr 2021 18:35:41 -0700 Subject: [PATCH 37/39] build: add default branch --- .github/workflows/release-please.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 3471b097..ad2308a3 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -12,3 +12,4 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} command: manifest + default-branch: 4.x.x From af90f175857921a35a34ee293f99c845c3823859 Mon Sep 17 00:00:00 2001 From: bcoe Date: Tue, 6 Apr 2021 18:36:29 -0700 Subject: [PATCH 38/39] build: fix json in manifest --- .release-please-manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index cbecc517..cf533f28 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.0.1", + ".": "4.0.1" } From bcfdd05cf8405593cd3261e25fde4976efd8672f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 6 Apr 2021 18:37:25 -0700 Subject: [PATCH 39/39] chore: release (#122) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .release-please-manifest.json | 2 +- CHANGELOG.md | 7 +++++++ package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index cf533f28..1778b2a6 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.0.1" + ".": "4.0.2" } diff --git a/CHANGELOG.md b/CHANGELOG.md index b86ddf9d..8b42afcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [4.0.2](https://www.github.com/yargs/y18n/compare/y18n-v4.0.1...y18n-v4.0.2) (2021-04-07) + + +### Bug Fixes + +* **security:** ensure entry exists for backport ([#120](https://www.github.com/yargs/y18n/issues/120)) ([b22c0df](https://www.github.com/yargs/y18n/commit/b22c0df59d0851d7be9fd1d51f6a5ee974c9fc94)) + ### [5.0.4](https://www.github.com/yargs/y18n/compare/v5.0.3...v5.0.4) (2020-10-16) diff --git a/package.json b/package.json index 8e2a64d2..d6944aaf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "y18n", - "version": "4.0.1", + "version": "4.0.2", "description": "the bare-bones internationalization library used by yargs", "exports": { ".": [