Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

full-icu

Package Overview
Dependencies
Maintainers
4
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

full-icu - npm Package Compare versions

Comparing version 1.3.4 to 1.4.0-0

.eslintrc.js

157

full-icu.js
// Copyright (C) 2015 IBM Corporation and Others. All Rights Reserved.
//var process = require('process');
//console.dir(process.env);
// var process = require('process');
// console.dir(process.env);
var fs = require('fs');
var path = require('path');
const fs = require('fs')
const path = require('path')
if(!process || !process.versions || !process.versions.node) {
throw Error('Sorry- don’t know what version of Node you are on.');
if (!process || !process.versions || !process.versions.node) {
throw Error('Sorry- don’t know what version of Node you are on.')
}
var nodever = module.exports.nodever = process.versions.node;
const nodever = module.exports.nodever = process.versions.node
var nodesplit = nodever.split('.');
const nodesplit = nodever.split('.')
var node_maj = module.exports.node_maj = nodesplit[0];
var node_min = module.exports.node_min = nodesplit[1];
const major = module.exports.node_maj = nodesplit[0]
const minor = module.exports.node_min = nodesplit[1]
if((node_maj == 0) && (node_min < 12)) {
module.exports.oldNode = true;
} else if(process.config.variables.v8_enable_i18n_support === 0) {
module.exports.noi18n = true;
if ((major === 0) && (minor < 12)) {
module.exports.oldNode = true
} else if (process.config.variables.v8_enable_i18n_support === 0) {
module.exports.noi18n = true
} else {
/*
Commented until https://github.com/nodejs/node/issues/3460 is fixed.
if( node_maj >= 7 ) {
if( nodever === '7.0.0-pre' ) {
module.exports.nodeDetectIcu = 'maybe';
} else {
module.exports.nodeDetectIcu = true;
}
}
*/
/*
Commented until https://github.com/nodejs/node/issues/3460 is fixed.
if(!process.config.variables.icu_small) {
module.exports.icu_small = false;
// not going to work..
if(process.config.variables.icu_gyp_path === 'tools/icu/icu-system.gyp') {
// this will be the case under homebrew, redhat/fedora, others..
module.exports.icu_system = true;
}
} else {
module.exports.icu_small = true;
}
var icuver;
var icuend = 'l';
if(process.versions.icu) {
icuver = process.versions.icu; // Thanks https://github.com/nodejs/node/issues/3089
} else {
icuver = process.config.variables.icu_ver_major; // only get the major
}
if(!icuver) {
throw Error('Cannot determine Node’s ICU version!');
} else {
module.exports.icuver = icuver;
}
// get 'major' number
var icumaj = module.exports.icumaj = icuver.split('.')[0];
if(process.config.variables.icu_endianness) {
icuend = process.config.variables.icu_endianness.toLowerCase();
}
if( (icuend.length != 1) || ("lbe".indexOf(icuend) == -1)) {
throw Error('Don’t know what to make of endianness “'+icuend+'” - expected l, b, or e');
} else {
module.exports.icuend = icuend;
}
var icupkg = module.exports.icupkg = "icu4c-data@" + icumaj+icuend;
var icudat = module.exports.icudat = "icudt"+icumaj+icuend+".dat";
var haveDat = module.exports.haveDat = function haveDat(d) {
if(!d) d = path.resolve(__dirname, icudat);
return fs.existsSync(d);
}
var datPath = module.exports.datPath = function datPath(d) {
if(!d) d = path.resolve(__dirname, icudat);
if(haveDat(d)) return fs.realpathSync(d);
throw Error('Does not exist: ' + fs.realpathSync(d));
}
if( major >= 7 ) {
if( nodever === '7.0.0-pre' ) {
module.exports.nodeDetectIcu = 'maybe';
} else {
module.exports.nodeDetectIcu = true;
}
}
*/
if (!process.config.variables.icu_small) {
module.exports.icu_small = false
// not going to work..
if (process.config.variables.icu_gyp_path === 'tools/icu/icu-system.gyp') {
// this will be the case under homebrew, redhat/fedora, others..
module.exports.icu_system = true
}
} else {
module.exports.icu_small = true
}
let icuver
let icuend = 'l'
if (process.versions.icu) {
icuver = process.versions.icu // Thanks https://github.com/nodejs/node/issues/3089
} else {
icuver = process.config.variables.icu_ver_major // only get the major
}
if (!icuver) {
throw Error('Cannot determine Node’s ICU version!')
} else {
module.exports.icuver = icuver
}
// get 'major' number
const icumaj = module.exports.icumaj = icuver.split('.')[0]
if (process.config.variables.icu_endianness) {
icuend = process.config.variables.icu_endianness.toLowerCase()
}
if ((icuend.length !== 1) || ('lbe'.indexOf(icuend) === -1)) {
throw Error('Don’t know what to make of endianness “' + icuend + '” - expected l, b, or e')
} else {
module.exports.icuend = icuend
}
module.exports.icupkg = 'icu4c-data@' + icumaj + icuend
const icudat = module.exports.icudat = 'icudt' + icumaj + icuend + '.dat'
const haveDat = module.exports.haveDat = function haveDat (d) {
if (!d) d = path.resolve(__dirname, icudat)
return fs.existsSync(d)
}
module.exports.datPath = function datPath (d) {
if (!d) d = path.resolve(__dirname, icudat)
if (haveDat(d)) return fs.realpathSync(d)
throw Error('Does not exist: ' + fs.realpathSync(d))
}
}

@@ -5,86 +5,87 @@ // Copyright (C) 2015-2016 IBM Corporation and Others. All Rights Reserved.

var path = require('path');
var fs = require('fs');
var child_process = require('child_process');
const path = require('path')
const fs = require('fs')
const spawnSync = require('child_process').spawnSync
var isglobal = process.env.npm_config_global === 'true';
var npmrc = '.npmrc';
var npmrcPath = path.resolve(process.env.INIT_CWD, npmrc);
const isglobal = process.env.npm_config_global === 'true'
const npmrc = '.npmrc'
if (!process.env.INIT_CWD) {
throw Error('INIT_CWD was not set- does not seem like we were launched from npm')
}
const npmrcPath = path.resolve(process.env.INIT_CWD, npmrc)
// uses semver regex from https://semver.org/
const YARN_REGEX = /yarn(-(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)?((.*cli)?\.c?js)?$/;
const YARN_REGEX = /yarn(-(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)?((.*cli)?\.c?js)?$/
module.exports = function npmInstallNpm(fullIcu, advice) {
var icupkg = fullIcu.icupkg;
var icudat = fullIcu.icudat;
module.exports = function npmInstallNpm (fullIcu, advice) {
const icupkg = fullIcu.icupkg
const icudat = fullIcu.icudat
var cmdPath = nodePath = process.env.npm_node_execpath;
let cmdPath = process.env.npm_node_execpath
var npmPath = process.env.npm_execpath;
const npmPath = process.env.npm_execpath
var args;
let args
if (YARN_REGEX.test(npmPath)) {
console.log('Looks like you are using yarn…')
args = [npmPath, 'add', icupkg, '--no-lockfile', '--ignore-scripts']
} else if (npmPath) {
args = [npmPath, 'install', icupkg]
} else {
// attempt to launch npm.
// do not try yarn here
console.log('(Hmm… doesn’t look like NPM called us. Let’s try calling NPM.)')
cmdPath = 'npm'
args = ['install', icupkg]
}
if (YARN_REGEX.test(npmPath) ) {
console.log('Looks like you are using yarn…');
installVerb = 'add';
args = [ npmPath, 'add', icupkg, '--no-lockfile', '--ignore-scripts' ];
} else if(npmPath) {
args = [ npmPath, 'install', icupkg ];
} else {
// attempt to launch npm.
// do not try yarn here
console.log('(Hmm… doesn’t look like NPM called us. Let’s try calling NPM.)');
cmdPath = 'npm';
args = [ 'install', icupkg ];
}
if (fs.existsSync(npmrcPath)) {
try {
fs.linkSync(npmrcPath, npmrc)
} catch (e) {
fs.symlinkSync(npmrcPath, npmrc)
}
}
if(fs.existsSync(npmrcPath)) {
try {
fs.linkSync(npmrcPath, npmrc);
} catch(e) {
fs.symlinkSync(npmrcPath, npmrc);
}
}
console.log('full-icu$', cmdPath, args.join(' '))
const spawned = spawnSync(cmdPath, args, { stdio: 'inherit' })
console.log('full-icu$', cmdPath, args.join(' '));
var spawned = child_process.spawnSync(cmdPath, args, { stdio: 'inherit' });
if (fs.existsSync(npmrc)) {
try {
fs.unlinkSync(npmrc)
} catch (e) {
}
}
if(fs.existsSync(npmrc)) {
try {
fs.unlinkSync(npmrc);
} catch(e) {
}
}
if(spawned.error) {
throw(spawned.error);
} else if(spawned.status !== 0) {
throw(Error(cmdPath + ' ' + args.join(' ') + ' --> status ' + spawned.status));
} else {
var datPath;
if(isglobal) {
datPath = path.join('..','icu4c-data',icudat);
} else {
datPath = path.join('node_modules','icu4c-data',icudat);
}
if(fs.existsSync(icudat)) {
console.log(' √ ' + icudat + " (existing link?)");
} else if(!fs.existsSync(datPath)) {
console.log(' • ' + ' (no ' + icudat + ' at ‘' + datPath+'’)');
} else {
try {
fs.linkSync(datPath, icudat);
console.log(' √ ' + icudat + " (link)");
} catch(e) {
fs.symlinkSync(datPath, icudat);
console.log(' √ ' + icudat + " (symlink)");
}
}
if(!fullIcu.haveDat()) {
throw Error('Somehow failed to install ' + icudat);
} else {
advice();
}
}
};
if (spawned.error) {
throw (spawned.error)
} else if (spawned.status !== 0) {
throw (Error(cmdPath + ' ' + args.join(' ') + ' --> status ' + spawned.status))
} else {
let datPath
if (isglobal) {
datPath = path.join('..', 'icu4c-data', icudat)
} else {
datPath = path.join('node_modules', 'icu4c-data', icudat)
}
if (fs.existsSync(icudat)) {
console.log(' √ ' + icudat + ' (existing link?)')
} else if (!fs.existsSync(datPath)) {
console.log(' • ' + ' (no ' + icudat + ' at ‘' + datPath + '’)')
} else {
try {
fs.linkSync(datPath, icudat)
console.log(' √ ' + icudat + ' (link)')
} catch (e) {
fs.symlinkSync(datPath, icudat)
console.log(' √ ' + icudat + ' (symlink)')
}
}
if (!fullIcu.haveDat()) {
throw Error('Somehow failed to install ' + icudat)
} else {
advice()
}
}
}
#!/usr/bin/env node
// Copyright (C) 2015 IBM Corporation and Others. All Rights Reserved.
var fullIcu = require('./full-icu');
const fullIcu = require('./full-icu')
if(!fullIcu.datPath) {
throw Error('Full data path not available');
if (!fullIcu.datPath) {
throw Error('Full data path not available')
} else {
console.log(fullIcu.datPath());
console.log(fullIcu.datPath())
}
{
"name": "full-icu",
"version": "1.3.4",
"version": "1.4.0-0",
"description": "install 'full-icu' data for your current node",
"scripts": {
"postinstall": "node postinstall.js"
"lint": "standard && eslint *.js test/*.js",
"postinstall": "node postinstall.js",
"test": "tap test/*.js"
},

@@ -12,2 +14,3 @@ "keywords": [

"bin": {
"full-icu": "./node-full-icu.js",
"node-full-icu-path": "./node-icu-data.js"

@@ -24,3 +27,16 @@ },

"url": "https://github.com/unicode-org/full-icu-npm/issues"
},
"dependencies": {
"yauzl": "^2.10.0"
},
"devDependencies": {
"eslint": "^7.7.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-header": "^3.0.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"standard": "^16.0.3",
"tap": "^15.0.10"
}
}
// Copyright (C) 2015 IBM Corporation and Others. All Rights Reserved.
var fs = require('fs');
var path = require('path');
var fullIcu = require('./full-icu');
const fs = require('fs')
const path = require('path')
const fullIcu = require('./full-icu')
const myname = process.env.npm_package_name || 'full-icu'
var myname = process.env.npm_package_name || 'full-icu';
function exit(reason) {
console.log(reason);
process.exit(0);
function exit (reason) {
console.log(reason)
process.exit(0)
}
if (fullIcu.oldNode) {
exit('Not sure how to handle node < 0.12. Exitting.');
exit('Not sure how to handle node < 0.12. Exitting.')
} else if (fullIcu.noi18n) {
exit('Note: Your node was not compiled with i18n support. Nothing to do, Exitting.');
exit('Note: Your node was not compiled with i18n support. Nothing to do, Exitting.')
} else if (fullIcu.icu_system) {
exit('Note: Your node was compiled to link against an ' +
'externally-provided ICU, so the locale data is not customizable ' +
'through this script. Exitting.');
exit('Note: Your node was compiled to link against an ' +
'externally-provided ICU, so the locale data is not customizable ' +
'through this script. Exitting.')
} else if (!fullIcu.icu_small) {
// maybe already full icu, or some as-yet-unforseen case.
exit('Note: Your node was not compiled with the ‘small-icu’ case,' +
' so the ICU data is not customizable through this script. Exitting.');
} else if( fullIcu.icumaj < 54 ) {
// This is kind of a sanity check that the ICU version is correct.
// ICU 54 was what Node v0.12 started with.
throw Error('Don’t know how to work with ICU version ' + fullIcu.icumaj + ', sorry.');
// maybe already full icu, or some as-yet-unforseen case.
exit('Note: Your node was not compiled with the ‘small-icu’ case,' +
' so the ICU data is not customizable through this script. Exitting.')
} else if (fullIcu.icumaj < 54) {
// This is kind of a sanity check that the ICU version is correct.
// ICU 54 was what Node v0.12 started with.
throw Error('Don’t know how to work with ICU version ' + fullIcu.icumaj + ', sorry.')
}
var cwd = fs.realpathSync('.');
const cwd = fs.realpathSync('.')
var isglobal = process.env.npm_config_global === 'true';
const isglobal = process.env.npm_config_global === 'true'
var relpath = isglobal ? cwd : path.join('node_modules',myname);
const relpath = isglobal ? cwd : path.join('node_modules', myname)
function advice() {
if( fullIcu.nodeDetectIcu ) {
console.log('Note: If you manually copy ' + path.join(relpath,fullIcu.icudat) + ' to the directory ' +
path.normalize(path.join(relpath,'..','.node-icu'))
+ ' node will automatically detect this data.');
if(fullIcu.nodeDetectIcu === 'maybe') {
console.log(' - at least when https://github.com/nodejs/node/issues/3460 lands');
}
}
function advice () {
if (fullIcu.nodeDetectIcu) {
console.log('Note: If you manually copy ' + path.join(relpath, fullIcu.icudat) + ' to the directory ' +
path.normalize(path.join(relpath, '..', '.node-icu')) +
' node will automatically detect this data.')
if (fullIcu.nodeDetectIcu === 'maybe') {
console.log(' - at least when https://github.com/nodejs/node/issues/3460 lands')
}
}
if(fullIcu.nodeDetectIcu !== true) {
console.log('Node will use this ICU datafile if the environment variable NODE_ICU_DATA is set to “'+relpath+'”');
console.log('or with node --icu-data-dir='+relpath+' YOURAPP.js' );
if (fullIcu.nodeDetectIcu !== true) {
console.log('Node will use this ICU datafile if the environment variable NODE_ICU_DATA is set to “' + relpath + '”')
console.log('or with node --icu-data-dir=' + relpath + ' YOURAPP.js')
var asJson = {scripts: { start: "node --icu-data-dir="+relpath + " YOURAPP.js" }};
console.log(" For package.json:");
console.log(JSON.stringify(asJson));
}
console.log("");
console.log("By the way, if you have full data, running this in node:");
// 9E8 is 10 days into January, so TimeZone independent
console.log("> new Intl.DateTimeFormat('es',{month:'long'}).format(new Date(9E8));");
console.log("... will show “enero”. If it shows “January” you don't have full data.");
const asJson = { scripts: { start: 'node --icu-data-dir=' + relpath + ' YOURAPP.js' } }
console.log(' For package.json:')
console.log(JSON.stringify(asJson))
}
console.log('')
console.log('By the way, if you have full data, running this in node:')
// 9E8 is 10 days into January, so TimeZone independent
console.log("> new Intl.DateTimeFormat('es',{month:'long'}).format(new Date(9E8));")
console.log("... will show “enero”. If it shows “January” you don't have full data.")
}
// install by using spawn
var npmInstall = require('./install-spawn');
// Choose install method
let npmInstall
if(fs.existsSync(fullIcu.icudat)) {
console.log('√ ' + fullIcu.icudat + ' Already there (for Node ' + fullIcu.nodever + ' and small-icu ' + fullIcu.icuver + ')');
advice();
// GitHub has v50+ as releases
// Experimentally, pull from GitHub for little endian
if (!process.env.FULL_ICU_PREFER_NPM) {
if (fullIcu.icumaj >= 67) {
// Pull from bin data zip, first arrived in ICU v67
// https://unicode-org.atlassian.net/browse/ICU-20600
npmInstall = require('./install-gh-data')
} else {
if (fullIcu.icuend === 'l') {
// Little Endian can pull from icu4c-src.zip which contains a prebuilt data file
npmInstall = require('./install-gh')
} else {
// Fall back to npm
console.log(`ICU data bin zip not available until ICU v${fullIcu.icumaj} for endianness ${fullIcu.icuend}: Falling back to npm`)
npmInstall = require('./install-spawn')
}
}
} else {
console.log('npm install ' + fullIcu.icupkg + ' (Node ' + fullIcu.nodever + ' and small-icu ' + fullIcu.icuver + ') -> ' + fullIcu.icudat);
npmInstall(fullIcu, advice);
npmInstall = require('./install-spawn')
}
console.log('News: Please see https://github.com/icu-project/full-icu-npm/issues/6');
if (fs.existsSync(fullIcu.icudat)) {
console.log('√ ' + fullIcu.icudat + ' Already there (for Node ' + fullIcu.nodever + ' and small-icu ' + fullIcu.icuver + ')')
advice()
} else {
console.log('npm install ' + fullIcu.icupkg + ' (Node ' + fullIcu.nodever + ' and small-icu ' + fullIcu.icuver + ') -> ' + fullIcu.icudat)
npmInstall(fullIcu, advice)
}
console.log('News: Please see https://github.com/icu-project/full-icu-npm/issues/6')

@@ -1,26 +0,29 @@

Install full ICU data
###
# full-icu-npm
to use:
Install full ICU data from GitHub or npm
npm install full-icu
### To use
or for global install:
`npm install full-icu`
npm install -g full-icu
Note: Set env var `FULL_ICU_PREFER_NPM=true` to prefer using the `icu4c-data` npm module,
otherwise the default is now to load from ICU4C’s GitHub release.
### To install globally
`npm install -g full-icu`
### After Installation
Instructions will be printed out on how to activate this data for your version of node.
The work gets done in a `postinstall` script which copies the `icudt*.dat` file
up to this module's level.
This work gets done in a `postinstall` script which copies the `icudt*.dat` file up to this module's level.
## API
API
===
`require('full-icu')` returns a few properties:
* `nodever` - the full Node version (ex: `4.2.0`)
* `nodever` - the full Node version (ex: `14.2.0`)
* `node_maj` - the major part of the node version (ex: `4`)
* `node_maj` - the major part of the node version (ex: `14`)

@@ -30,7 +33,6 @@ * `node_min` - the minor part of the node version (ex `2`)

* `icu_small` - if truthy, means that node was built with
small-icu (English only). If falsy, means that the `full-icu`
**small-icu** (English only). If falsy, means that the `full-icu`
package is not relevant.
* `icuver` - full ICU version, if available, such as 55.1. Sometimes only the major
version is available.
* `icuver` - the full ICU version, if available, such as 55.1. Sometimes only the major version is available.

@@ -49,20 +51,20 @@ * `icumaj` - ICU major ver, such as `55`. May be === `icuver`.

* `oldNode` - Node is older (`<0.12`) than this package can really think about.
* `oldNode` - The node version is older than this package can really think about.
BIN
===
## BIN
`node-full-icu-path` will print the full `icudt*.dat` path, if available.
LICENSE
===
## CONTRIBUTING
- Usage of data and software is governed by the [Unicode Terms of Use](http://www.unicode.org/copyright.html)
a copy of which is included as [LICENSE](./LICENSE)
Please see our [`CONTRIBUTING`](./CONTRIBUTING.md) guide if you'd like to help with this initiative!
COPYRIGHT
===
## LICENSE
Copyright &copy; 1991-2021 Unicode, Inc.
All rights reserved.
[Terms of use](http://www.unicode.org/copyright.html)
This repository is subject to the terms under the [Node.js license](https://github.com/nodejs/node/blob/master/LICENSE). Some usage of this data is governed by the [Unicode Terms of Use](http://www.unicode.org/copyright.html), which is included in the [unicode-license.txt](./unicode-license.txt)
## COPYRIGHT
Copyright &copy; 1991-2021 Unicode, Inc. and Node.js contributors. All rights reserved.
[Unicode terms of use](http://www.unicode.org/copyright.html)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc