cli-engine-config
Advanced tools
Comparing version 5.0.6 to 5.0.7
@@ -40,3 +40,3 @@ import { args, flags } from 'cli-flags'; | ||
dirname: string; | ||
initPath: string; | ||
reexecBin: string; | ||
commandsDir: string; | ||
@@ -95,2 +95,3 @@ bin: string; | ||
id: string; | ||
aliases: string[]; | ||
buildHelp: (config: IConfig) => string; | ||
@@ -100,6 +101,5 @@ buildHelpLine: (config: IConfig) => [string, string | undefined]; | ||
flags?: flags.Input; | ||
run: (argv: string[], options: IConfig) => Promise<any>; | ||
run: (argv: string[], config: IConfig) => Promise<any>; | ||
plugin?: IPlugin; | ||
} | ||
export declare function buildConfig(existing?: ConfigOptions): IConfig; | ||
export declare const defaultConfig: IConfig; |
@@ -6,11 +6,18 @@ "use strict"; | ||
const path = require("path"); | ||
function dir(config, category, d) { | ||
function dir({ dirname, category, home, platform, d, }) { | ||
let cacheKey = `dir:${category}`; | ||
d = d || path.join(config.home, category === 'data' ? '.local/share' : '.' + category); | ||
if (config.windows) | ||
d = d || path.join(home, category === 'data' ? '.local/share' : '.' + category); | ||
if (platform === 'windows') | ||
d = process.env.LOCALAPPDATA || d; | ||
d = process.env.XDG_DATA_HOME || d; | ||
d = path.join(d, config.dirname); | ||
d = path.join(d, dirname); | ||
return d; | ||
} | ||
function windowsHome() { | ||
return (process.env.HOME || | ||
(process.env.HOMEDRIVE && process.env.HOMEPATH && path.join(process.env.HOMEDRIVE, process.env.HOMEPATH)) || | ||
process.env.USERPROFILE || | ||
os.homedir() || | ||
os.tmpdir()); | ||
} | ||
function debug(bin) { | ||
@@ -95,7 +102,3 @@ try { | ||
existing.pjson = { | ||
...exports.defaultConfig.pjson, | ||
'cli-engine': { | ||
...exports.defaultConfig.pjson['cli-engine'], | ||
...(pjson['cli-engine'] || {}), | ||
}, | ||
'cli-engine': pjson['cli-engine'] || {}, | ||
...pjson, | ||
@@ -112,3 +115,3 @@ }; | ||
hooks: {}, | ||
s3: { host: null }, | ||
s3: { host: undefined }, | ||
userPlugins: false, | ||
@@ -121,4 +124,14 @@ }, | ||
}; | ||
const bin = existing.bin || pjson['cli-engine'].bin || pjson.name; | ||
const platform = existing.platform || os.platform(); | ||
const dirname = existing.dirname || pjson['cli-engine'].dirname || bin; | ||
const windows = platform === 'win32'; | ||
const home = existing.home || (windows && windowsHome()) || os.homedir() || os.tmpdir(); | ||
return { | ||
_version: '1', | ||
bin, | ||
dirname, | ||
pjson, | ||
platform, | ||
home, | ||
arch: os.arch() === 'ia32' ? 'x86' : os.arch(), | ||
@@ -128,41 +141,25 @@ argv: process.argv.slice(1), | ||
defaultCommand: pjson['cli-engine'].defaultCommand, | ||
home: os.homedir() || os.tmpdir(), | ||
name: pjson.name, | ||
pjson, | ||
platform: os.platform() === 'win32' ? 'windows' : os.platform(), | ||
root: path.join(__dirname, '..'), | ||
version: pjson.version, | ||
get hooks() { | ||
return objValsToArrays(this.pjson['cli-engine'].hooks); | ||
}, | ||
get aliases() { | ||
return objValsToArrays(this.pjson['cli-engine'].aliases); | ||
}, | ||
get windows() { | ||
return this.platform === 'windows'; | ||
}, | ||
reexecBin: process.env[envVarKey(bin, 'CLI_BINPATH')], | ||
hooks: objValsToArrays(pjson['cli-engine'].hooks), | ||
aliases: objValsToArrays(pjson['cli-engine'].aliases), | ||
windows, | ||
shell: shell(windows), | ||
debug: debug(bin || 'cli-engine') || 0, | ||
dataDir: dir({ category: 'data', home, platform, dirname }), | ||
configDir: dir({ category: 'config', home, platform, dirname }), | ||
cacheDir: dir({ | ||
category: 'cache', | ||
home, | ||
platform, | ||
dirname, | ||
d: platform === 'darwin' ? path.join(home, 'Library', 'Caches') : undefined, | ||
}), | ||
corePlugins: pjson['cli-engine'].plugins || [], | ||
userPlugins: pjson['cli-engine'].userPlugins, | ||
get userAgent() { | ||
return userAgent(this); | ||
}, | ||
get dirname() { | ||
return this.pjson['cli-engine'].dirname || this.bin; | ||
}, | ||
get shell() { | ||
return shell(this.windows); | ||
}, | ||
get bin() { | ||
return this.pjson['cli-engine'].bin || this.name; | ||
}, | ||
get debug() { | ||
return debug(this.bin || 'cli-engine') || 0; | ||
}, | ||
get dataDir() { | ||
return dir(this, 'data'); | ||
}, | ||
get configDir() { | ||
return dir(this, 'config'); | ||
}, | ||
get cacheDir() { | ||
return dir(this, 'cache', this.platform === 'darwin' ? path.join(this.home, 'Library', 'Caches') : undefined); | ||
}, | ||
get updateDisabled() { | ||
@@ -184,8 +181,2 @@ const k = envVarKey(this.bin, 'SKIP_CORE_UPDATES'); | ||
}, | ||
get corePlugins() { | ||
return this.pjson['cli-engine'].plugins || []; | ||
}, | ||
get userPlugins() { | ||
return this.pjson['cli-engine'].userPlugins; | ||
}, | ||
get topics() { | ||
@@ -204,2 +195,1 @@ return topics(this); | ||
exports.buildConfig = buildConfig; | ||
exports.defaultConfig = buildConfig(); |
{ | ||
"name": "cli-engine-config", | ||
"description": "base cli-engine config objects and interfaces", | ||
"version": "5.0.6", | ||
"version": "5.0.7", | ||
"author": "Jeff Dickey @jdxcode", | ||
@@ -11,7 +11,7 @@ "bugs": "https://github.com/heroku/cli-engine-config/issues", | ||
"@types/node": "8.5.2", | ||
"cli-flags": "2.0.2", | ||
"cli-flags": "2.0.3", | ||
"debug": "^3.1.0", | ||
"del-cli": "1.1.0", | ||
"husky": "^0.14.3", | ||
"jest": "^22.0.3", | ||
"jest": "^22.0.4", | ||
"lint-staged": "^6.0.0", | ||
@@ -22,5 +22,5 @@ "mock-fs": "^4.4.2", | ||
"ts-jest": "22.0.0", | ||
"ts-node": "4.0.2", | ||
"ts-node": "4.1.0", | ||
"tslint": "^5.8.0", | ||
"tslint-cli-engine": "^1.0.1", | ||
"tslint-cli-engine": "^1.0.3", | ||
"typescript": "2.6.2" | ||
@@ -41,5 +41,2 @@ }, | ||
"main": "lib/config.js", | ||
"peerDependencies": { | ||
"cli-flags": "^2.0.0" | ||
}, | ||
"repository": "heroku/cli-engine-config", | ||
@@ -49,3 +46,3 @@ "scripts": { | ||
"precommit": "lint-staged", | ||
"prepare": "del lib && tsc", | ||
"prepare": "del-cli lib && tsc && del-cli \"lib/**/*.test.+(d.ts|js)\"", | ||
"pretest": "tsc", | ||
@@ -52,0 +49,0 @@ "test": "jest" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
0
10261
290
16