cli-engine-config
Advanced tools
Comparing version 4.0.0 to 4.0.1-ts.0
@@ -1,3 +0,3 @@ | ||
import { IArg, Flag, ValueFlag } from "cli-flags"; | ||
import "core-js/library"; | ||
import { IArg, Flag, ValueFlag } from 'cli-flags'; | ||
import 'core-js/library'; | ||
export declare type Topic = { | ||
@@ -37,3 +37,3 @@ name: string; | ||
}; | ||
"cli-engine": CLI; | ||
'cli-engine': CLI; | ||
}; | ||
@@ -61,3 +61,3 @@ export declare type Config = { | ||
windows: boolean; | ||
_version: "1"; | ||
_version: '1'; | ||
skipAnalytics: boolean; | ||
@@ -64,0 +64,0 @@ install: string | undefined; |
@@ -12,5 +12,3 @@ "use strict"; | ||
return cache; | ||
d = | ||
d || | ||
path.join(config.home, category === "data" ? ".local/share" : "." + category); | ||
d = d || path.join(config.home, category === 'data' ? '.local/share' : '.' + category); | ||
if (config.windows) | ||
@@ -25,4 +23,3 @@ d = process.env.LOCALAPPDATA || d; | ||
function debug(bin) { | ||
const debug = (process.env.DEBUG || "").includes("*") || | ||
envVarTrue(envVarKey(bin, "DEBUG")); | ||
const debug = (process.env.DEBUG || '').includes('*') || envVarTrue(envVarKey(bin, 'DEBUG')); | ||
return debug ? 1 : 0; | ||
@@ -32,4 +29,4 @@ } | ||
return parts | ||
.map(p => p.replace(/-/g, "_")) | ||
.join("_") | ||
.map(p => p.replace(/-/g, '_')) | ||
.join('_') | ||
.toUpperCase(); | ||
@@ -39,9 +36,9 @@ } | ||
let v = process.env[k]; | ||
return v === "1" || v === "true"; | ||
return v === '1' || v === 'true'; | ||
} | ||
function loadUserConfig(config) { | ||
const cache = config.__cache["userConfig"]; | ||
const cache = config.__cache['userConfig']; | ||
if (cache) | ||
return cache; | ||
const configPath = path.join(config.configDir, "config.json"); | ||
const configPath = path.join(config.configDir, 'config.json'); | ||
let userConfig; | ||
@@ -52,3 +49,3 @@ try { | ||
catch (e) { | ||
if (e.code === "ENOENT") { | ||
if (e.code === 'ENOENT') { | ||
userConfig = {}; | ||
@@ -60,7 +57,7 @@ } | ||
} | ||
config.__cache["userConfig"] = userConfig; | ||
config.__cache['userConfig'] = userConfig; | ||
if (config.skipAnalytics) | ||
delete userConfig.install; | ||
else if (!userConfig.install) { | ||
const uuid = require("uuid/v4"); | ||
const uuid = require('uuid/v4'); | ||
userConfig.install = uuid(); | ||
@@ -87,3 +84,3 @@ try { | ||
else { | ||
shellPath = ["unknown"]; | ||
shellPath = ['unknown']; | ||
} | ||
@@ -93,9 +90,9 @@ return shellPath[shellPath.length - 1]; | ||
function userAgent(config) { | ||
const channel = config.channel === "stable" ? "" : ` ${config.channel}`; | ||
const channel = config.channel === 'stable' ? '' : ` ${config.channel}`; | ||
return `${config.name}/${config.version}${channel} (${config.platform}-${config.arch}) node-${process.version}`; | ||
} | ||
function commandsDir(config) { | ||
if (!config.root || !config.pjson || !config.pjson["cli-engine"]) | ||
if (!config.root || !config.pjson || !config.pjson['cli-engine']) | ||
return; | ||
let commandsDir = config.pjson["cli-engine"].commands; | ||
let commandsDir = config.pjson['cli-engine'].commands; | ||
if (!commandsDir) | ||
@@ -116,4 +113,3 @@ return; | ||
} | ||
else if (envVarTrue("TESTING") || | ||
envVarTrue(envVarKey(config.bin, "SKIP_ANALYTICS"))) { | ||
else if (envVarTrue('TESTING') || envVarTrue(envVarKey(config.bin, 'SKIP_ANALYTICS'))) { | ||
return true; | ||
@@ -132,3 +128,3 @@ } | ||
function updateHost(config) { | ||
const cli = config.pjson["cli-engine"]; | ||
const cli = config.pjson['cli-engine']; | ||
if (cli.updateHost) | ||
@@ -142,24 +138,24 @@ return cli.updateHost; | ||
existing = {}; | ||
if (existing._version === "1") | ||
if (existing._version === '1') | ||
return existing; | ||
if (existing.root && !existing.pjson) { | ||
let pjsonPath = path.join(existing.root, "package.json"); | ||
let pjsonPath = path.join(existing.root, 'package.json'); | ||
if (fs.existsSync(pjsonPath)) { | ||
// parse the package.json at the root | ||
let pjson = fs.readJSONSync(path.join(existing.root, "package.json")); | ||
existing.pjson = Object.assign({}, exports.defaultConfig.pjson, { "cli-engine": Object.assign({}, exports.defaultConfig.pjson["cli-engine"], pjson["cli-engine"] || {}) }, pjson); | ||
let pjson = fs.readJSONSync(path.join(existing.root, 'package.json')); | ||
existing.pjson = Object.assign({}, exports.defaultConfig.pjson, { 'cli-engine': Object.assign({}, exports.defaultConfig.pjson['cli-engine'], pjson['cli-engine'] || {}) }, pjson); | ||
} | ||
} | ||
const pjson = existing.pjson || { | ||
name: "cli-engine", | ||
version: "0.0.0", | ||
name: 'cli-engine', | ||
version: '0.0.0', | ||
dependencies: {}, | ||
"cli-engine": { | ||
'cli-engine': { | ||
hooks: {}, | ||
defaultCommand: "help", | ||
userPlugins: false | ||
} | ||
defaultCommand: 'help', | ||
userPlugins: false, | ||
}, | ||
}; | ||
return Object.assign({ _version: "1", pjson, channel: "stable", home: os.homedir() || os.tmpdir(), root: path.join(__dirname, ".."), arch: os.arch() === "ia32" ? "x86" : os.arch(), platform: os.platform() === "win32" ? "windows" : os.platform(), mock: false, argv: process.argv.slice(1), name: pjson.name, version: pjson.version, hooks: hooks(pjson["cli-engine"].hooks), defaultCommand: pjson["cli-engine"].defaultCommand || "help", topics: topics(pjson["cli-engine"].topics), commandsDir: commandsDir(existing), get windows() { | ||
return this.platform === "windows"; | ||
return Object.assign({ _version: '1', pjson, channel: 'stable', home: os.homedir() || os.tmpdir(), root: path.join(__dirname, '..'), arch: os.arch() === 'ia32' ? 'x86' : os.arch(), platform: os.platform() === 'win32' ? 'windows' : os.platform(), mock: false, argv: process.argv.slice(1), name: pjson.name, version: pjson.version, hooks: hooks(pjson['cli-engine'].hooks), defaultCommand: pjson['cli-engine'].defaultCommand || 'help', topics: topics(pjson['cli-engine'].topics), commandsDir: commandsDir(existing), get windows() { | ||
return this.platform === 'windows'; | ||
}, | ||
@@ -170,3 +166,3 @@ get userAgent() { | ||
get dirname() { | ||
return pjson["cli-engine"].dirname || this.bin; | ||
return pjson['cli-engine'].dirname || this.bin; | ||
}, | ||
@@ -177,17 +173,15 @@ get shell() { | ||
get bin() { | ||
return pjson["cli-engine"].bin || this.name; | ||
return pjson['cli-engine'].bin || this.name; | ||
}, | ||
get debug() { | ||
return debug(this.bin || "cli-engine") || 0; | ||
return debug(this.bin || 'cli-engine') || 0; | ||
}, | ||
get dataDir() { | ||
return dir(this, "data"); | ||
return dir(this, 'data'); | ||
}, | ||
get configDir() { | ||
return dir(this, "config"); | ||
return dir(this, 'config'); | ||
}, | ||
get cacheDir() { | ||
return dir(this, "cache", this.platform === "darwin" | ||
? path.join(this.home, "Library", "Caches") | ||
: undefined); | ||
return dir(this, 'cache', this.platform === 'darwin' ? path.join(this.home, 'Library', 'Caches') : undefined); | ||
}, | ||
@@ -207,6 +201,6 @@ get userConfig() { | ||
get legacyConverter() { | ||
return pjson["cli-engine"].legacyConverter; | ||
return pjson['cli-engine'].legacyConverter; | ||
}, | ||
get userPlugins() { | ||
return pjson["cli-engine"].userPlugins; | ||
return pjson['cli-engine'].userPlugins; | ||
} }, existing, { __cache: {} }); | ||
@@ -213,0 +207,0 @@ } |
{ | ||
"name": "cli-engine-config", | ||
"description": "base cli-engine config objects and interfaces", | ||
"version": "4.0.0", | ||
"version": "4.0.1-ts.0", | ||
"author": "Jeff Dickey @dickeyxxx", | ||
@@ -26,9 +26,6 @@ "bugs": "https://github.com/heroku/cli-engine-config/issues", | ||
}, | ||
"engines": { | ||
"node": ">=7.6.0" | ||
}, | ||
"files": [ | ||
"lib" | ||
], | ||
"homepage": "https://github.com/heroku/cli-engine-command", | ||
"homepage": "https://github.com/heroku/cli-engine-config", | ||
"jest": { | ||
@@ -60,3 +57,3 @@ "coverageReporters": [ | ||
"main": "lib/config.js", | ||
"repository": "heroku/cli-engine-command", | ||
"repository": "heroku/cli-engine-config", | ||
"scripts": { | ||
@@ -68,3 +65,4 @@ "coverage": "cat coverage/coverage-final.json | remap-istanbul -o coverage/coverage-final.json && curl -s https://codecov.io/bash | bash", | ||
"test": "jest" | ||
} | ||
}, | ||
"types": "./lib/config.d.ts" | ||
} |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
0
10979
303
1