mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-21 05:24:45 +00:00
.
This commit is contained in:
parent
a004f0ae58
commit
fc725ba36b
7280 changed files with 19 additions and 1796407 deletions
21
node_modules/y18n/CHANGELOG.md
generated
vendored
21
node_modules/y18n/CHANGELOG.md
generated
vendored
|
@ -1,21 +0,0 @@
|
|||
# Change Log
|
||||
|
||||
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.
|
||||
|
||||
<a name="4.0.0"></a>
|
||||
# [4.0.0](https://github.com/yargs/y18n/compare/v3.2.1...v4.0.0) (2017-10-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* allow support for falsy values like 0 in tagged literal ([#45](https://github.com/yargs/y18n/issues/45)) ([c926123](https://github.com/yargs/y18n/commit/c926123))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **__:** added tagged template literal support ([#44](https://github.com/yargs/y18n/issues/44)) ([0598daf](https://github.com/yargs/y18n/commit/0598daf))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* **__:** dropping Node 0.10/Node 0.12 support
|
13
node_modules/y18n/LICENSE
generated
vendored
13
node_modules/y18n/LICENSE
generated
vendored
|
@ -1,13 +0,0 @@
|
|||
Copyright (c) 2015, Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose
|
||||
with or without fee is hereby granted, provided that the above copyright notice
|
||||
and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
THIS SOFTWARE.
|
109
node_modules/y18n/README.md
generated
vendored
109
node_modules/y18n/README.md
generated
vendored
|
@ -1,109 +0,0 @@
|
|||
# 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]
|
||||
[](https://conventionalcommits.org)
|
||||
|
||||
The bare-bones internationalization library used by yargs.
|
||||
|
||||
Inspired by [i18n](https://www.npmjs.com/package/i18n).
|
||||
|
||||
## Examples
|
||||
|
||||
_simple string translation:_
|
||||
|
||||
```js
|
||||
var __ = require('y18n').__
|
||||
|
||||
console.log(__('my awesome string %s', 'foo'))
|
||||
```
|
||||
|
||||
output:
|
||||
|
||||
`my awesome string foo`
|
||||
|
||||
_using tagged template literals_
|
||||
|
||||
```js
|
||||
var __ = require('y18n').__
|
||||
var str = 'foo'
|
||||
|
||||
console.log(__`my awesome string ${str}`)
|
||||
```
|
||||
|
||||
output:
|
||||
|
||||
`my awesome string foo`
|
||||
|
||||
_pluralization support:_
|
||||
|
||||
```js
|
||||
var __n = require('y18n').__n
|
||||
|
||||
console.log(__n('one fish %s', '%d fishes %s', 2, 'foo'))
|
||||
```
|
||||
|
||||
output:
|
||||
|
||||
`2 fishes foo`
|
||||
|
||||
## JSON Language Files
|
||||
|
||||
The JSON language files should be stored in a `./locales` folder.
|
||||
File names correspond to locales, e.g., `en.json`, `pirate.json`.
|
||||
|
||||
When strings are observed for the first time they will be
|
||||
added to the JSON file corresponding to the current locale.
|
||||
|
||||
## Methods
|
||||
|
||||
### require('y18n')(config)
|
||||
|
||||
Create an instance of y18n with the config provided, options include:
|
||||
|
||||
* `directory`: the locale directory, default `./locales`.
|
||||
* `updateFiles`: should newly observed strings be updated in file, default `true`.
|
||||
* `locale`: what locale should be used.
|
||||
* `fallbackToLanguage`: should fallback to a language-only file (e.g. `en.json`)
|
||||
be allowed if a file matching the locale does not exist (e.g. `en_US.json`),
|
||||
default `true`.
|
||||
|
||||
### y18n.\_\_(str, arg, arg, arg)
|
||||
|
||||
Print a localized string, `%s` will be replaced with `arg`s.
|
||||
|
||||
This function can also be used as a tag for a template literal. You can use it
|
||||
like this: <code>__`hello ${'world'}`</code>. This will be equivalent to
|
||||
`__('hello %s', 'world')`.
|
||||
|
||||
### y18n.\_\_n(singularString, pluralString, count, arg, arg, arg)
|
||||
|
||||
Print a localized string with appropriate pluralization. If `%d` is provided
|
||||
in the string, the `count` will replace this placeholder.
|
||||
|
||||
### y18n.setLocale(str)
|
||||
|
||||
Set the current locale being used.
|
||||
|
||||
### y18n.getLocale()
|
||||
|
||||
What locale is currently being used?
|
||||
|
||||
### y18n.updateLocale(obj)
|
||||
|
||||
Update the current locale with the key value pairs in `obj`.
|
||||
|
||||
## License
|
||||
|
||||
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
|
||||
[standard-url]: https://github.com/feross/standard
|
188
node_modules/y18n/index.js
generated
vendored
188
node_modules/y18n/index.js
generated
vendored
|
@ -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
|
||||
}
|
71
node_modules/y18n/package.json
generated
vendored
71
node_modules/y18n/package.json
generated
vendored
|
@ -1,71 +0,0 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
"y18n@4.0.0",
|
||||
"/Users/eric/repos/actions/setup-node"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "y18n@4.0.0",
|
||||
"_id": "y18n@4.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==",
|
||||
"_location": "/y18n",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "y18n@4.0.0",
|
||||
"name": "y18n",
|
||||
"escapedName": "y18n",
|
||||
"rawSpec": "4.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "4.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/yargs"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz",
|
||||
"_spec": "4.0.0",
|
||||
"_where": "/Users/eric/repos/actions/setup-node",
|
||||
"author": {
|
||||
"name": "Ben Coe",
|
||||
"email": "ben@npmjs.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/yargs/y18n/issues"
|
||||
},
|
||||
"description": "the bare-bones internationalization library used by yargs",
|
||||
"devDependencies": {
|
||||
"chai": "^4.0.1",
|
||||
"coveralls": "^3.0.0",
|
||||
"mocha": "^4.0.1",
|
||||
"nyc": "^11.0.1",
|
||||
"rimraf": "^2.5.0",
|
||||
"standard": "^10.0.0-beta.0",
|
||||
"standard-version": "^4.2.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/yargs/y18n",
|
||||
"keywords": [
|
||||
"i18n",
|
||||
"internationalization",
|
||||
"yargs"
|
||||
],
|
||||
"license": "ISC",
|
||||
"main": "index.js",
|
||||
"name": "y18n",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/yargs/y18n.git"
|
||||
},
|
||||
"scripts": {
|
||||
"coverage": "nyc report --reporter=text-lcov | coveralls",
|
||||
"pretest": "standard",
|
||||
"release": "standard-version",
|
||||
"test": "nyc mocha"
|
||||
},
|
||||
"version": "4.0.0"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue