Socket
Socket
Sign inDemoInstall

@oclif/plugin-autocomplete

Package Overview
Dependencies
Maintainers
2
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oclif/plugin-autocomplete - npm Package Compare versions

Comparing version 2.3.7 to 2.3.8

5

lib/autocomplete/powershell.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const util = require("util");
const tslib_1 = require("tslib");
const util = tslib_1.__importStar(require("util"));
const os_1 = require("os");
const ejs = require("ejs");
const ejs = tslib_1.__importStar(require("ejs"));
class PowerShellComp {

@@ -7,0 +8,0 @@ constructor(config) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const util = require("util");
const ejs = require("ejs");
const tslib_1 = require("tslib");
const util = tslib_1.__importStar(require("util"));
const ejs = tslib_1.__importStar(require("ejs"));
const argTemplate = ' "%s")\n %s\n ;;\n';

@@ -6,0 +7,0 @@ class ZshCompWithSpaces {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AutocompleteBase = void 0;
const tslib_1 = require("tslib");
const core_1 = require("@oclif/core");
const fs = require("fs-extra");
const path = require("path");
const fs_1 = require("fs");
const path = tslib_1.__importStar(require("path"));
class AutocompleteBase extends core_1.Command {

@@ -32,5 +33,6 @@ get cliBin() {

writeLogFile(msg) {
(0, fs_1.mkdirSync)(this.config.cacheDir, { recursive: true });
const entry = `[${(new Date()).toISOString()}] ${msg}\n`;
const fd = fs.openSync(this.acLogfilePath, 'a');
fs.write(fd, entry);
const fd = (0, fs_1.openSync)(this.acLogfilePath, 'a');
(0, fs_1.writeSync)(fd, entry);
}

@@ -37,0 +39,0 @@ isBashOnWindows(shell) {

50

lib/commands/autocomplete/create.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
const fs = require("fs-extra");
const bash_1 = require("../../autocomplete/bash");
const zsh_1 = require("../../autocomplete/zsh");
const powershell_1 = require("../../autocomplete/powershell");
const bash_spaces_1 = require("../../autocomplete/bash-spaces");
const tslib_1 = require("tslib");
const path = tslib_1.__importStar(require("path"));
const promises_1 = require("fs/promises");
const bash_1 = tslib_1.__importDefault(require("../../autocomplete/bash"));
const zsh_1 = tslib_1.__importDefault(require("../../autocomplete/zsh"));
const powershell_1 = tslib_1.__importDefault(require("../../autocomplete/powershell"));
const bash_spaces_1 = tslib_1.__importDefault(require("../../autocomplete/bash-spaces"));
const base_1 = require("../../base");

@@ -29,26 +30,23 @@ const debug = require('debug')('autocomplete:create');

async ensureDirs() {
// ensure autocomplete cache dir
await fs.ensureDir(this.autocompleteCacheDir);
// ensure autocomplete bash function dir
await fs.ensureDir(this.bashFunctionsDir);
// ensure autocomplete zsh function dir
await fs.ensureDir(this.zshFunctionsDir);
// ensure autocomplete powershell function dir
await fs.ensureDir(this.pwshFunctionsDir);
// ensure autocomplete cache dir before doing the children
await (0, promises_1.mkdir)(this.autocompleteCacheDir, { recursive: true });
await Promise.all([
(0, promises_1.mkdir)(this.bashFunctionsDir, { recursive: true }),
(0, promises_1.mkdir)(this.zshFunctionsDir, { recursive: true }),
(0, promises_1.mkdir)(this.pwshFunctionsDir, { recursive: true }),
]);
}
async createFiles() {
await fs.writeFile(this.bashSetupScriptPath, this.bashSetupScript);
await fs.writeFile(this.bashCompletionFunctionPath, this.bashCompletionFunction);
await fs.writeFile(this.zshSetupScriptPath, this.zshSetupScript);
// zsh
const supportSpaces = this.config.topicSeparator === ' ';
if (process.env.OCLIF_AUTOCOMPLETE_TOPIC_SEPARATOR === 'colon' || !supportSpaces) {
await fs.writeFile(this.zshCompletionFunctionPath, this.zshCompletionFunction);
}
else {
const zshCompWithSpaces = new zsh_1.default(this.config);
await fs.writeFile(this.zshCompletionFunctionPath, zshCompWithSpaces.generate());
const pwshComp = new powershell_1.default(this.config);
await fs.writeFile(this.pwshCompletionFunctionPath, pwshComp.generate());
}
await Promise.all([
(0, promises_1.writeFile)(this.bashSetupScriptPath, this.bashSetupScript),
(0, promises_1.writeFile)(this.bashCompletionFunctionPath, this.bashCompletionFunction),
(0, promises_1.writeFile)(this.zshSetupScriptPath, this.zshSetupScript),
].concat(process.env.OCLIF_AUTOCOMPLETE_TOPIC_SEPARATOR === 'colon' || !supportSpaces ? [
(0, promises_1.writeFile)(this.zshCompletionFunctionPath, this.zshCompletionFunction),
] : [
(0, promises_1.writeFile)(this.zshCompletionFunctionPath, new zsh_1.default(this.config).generate()),
(0, promises_1.writeFile)(this.pwshCompletionFunctionPath, new powershell_1.default(this.config).generate()),
]));
}

@@ -55,0 +53,0 @@ get bashSetupScriptPath() {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const core_1 = require("@oclif/core");
const os_1 = require("os");
const chalk = require("chalk");
const chalk_1 = tslib_1.__importDefault(require("chalk"));
const base_1 = require("../../base");
const create_1 = require("./create");
const create_1 = tslib_1.__importDefault(require("./create"));
const noteFromShell = (shell) => {
switch (shell) {
case 'zsh':
return `After sourcing, you can run \`${chalk_1.default.cyan('$ compaudit -D')}\` to ensure no permissions conflicts are present`;
case 'bash':
return 'If your terminal starts as a login shell you may need to print the init script into ~/.bash_profile or ~/.profile.';
case 'powershell':
return `Use the \`MenuComplete\` mode to get matching completions printed below the command line:\n${chalk_1.default.cyan('Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete')}`;
default:
return '';
}
};
class Index extends base_1.AutocompleteBase {

@@ -16,3 +29,3 @@ async run() {

}
core_1.ux.action.start(`${chalk.bold('Building the autocomplete cache')}`);
core_1.ux.action.start(`${chalk_1.default.bold('Building the autocomplete cache')}`);
await create_1.default.run([], this.config);

@@ -27,25 +40,15 @@ core_1.ux.action.stop();

`$ printf "eval $(${bin} autocomplete${this.config.topicSeparator}script ${shell})" >> ~/.${shell}rc; source ~/.${shell}rc`;
let note = '';
switch (shell) {
case 'zsh':
note = `After sourcing, you can run \`${chalk.cyan('$ compaudit -D')}\` to ensure no permissions conflicts are present`;
break;
case 'bash':
note = 'If your terminal starts as a login shell you may need to print the init script into ~/.bash_profile or ~/.profile.';
break;
case 'powershell':
note = `Use the \`MenuComplete\` mode to get matching completions printed below the command line:\n${chalk.cyan('Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete')}`;
}
const note = noteFromShell(shell);
this.log(`
${chalk.bold(`Setup Instructions for ${bin.toUpperCase()} CLI Autocomplete ---`)}
${chalk_1.default.bold(`Setup Instructions for ${bin.toUpperCase()} CLI Autocomplete ---`)}
1) Add the autocomplete ${shell === 'powershell' ? 'file' : 'env var'} to your ${shell} profile and source it
${chalk.cyan(instructions)}
${chalk_1.default.cyan(instructions)}
${chalk.bold('NOTE')}: ${note}
${chalk_1.default.bold('NOTE')}: ${note}
2) Test it out, e.g.:
${chalk.cyan(`$ ${bin} ${tabStr}`)} # Command completion
${chalk.cyan(`$ ${bin} command --${tabStr}`)} # Flag completion
${chalk_1.default.cyan(`$ ${bin} ${tabStr}`)} # Command completion
${chalk_1.default.cyan(`$ ${bin} command --${tabStr}`)} # Flag completion

@@ -52,0 +55,0 @@ Enjoy!

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const core_1 = require("@oclif/core");
const path = require("path");
const path = tslib_1.__importStar(require("path"));
const base_1 = require("../../base");

@@ -6,0 +7,0 @@ class Script extends base_1.AutocompleteBase {

{
"version": "2.3.7",
"version": "2.3.8",
"commands": {

@@ -4,0 +4,0 @@ "autocomplete:create": {

{
"name": "@oclif/plugin-autocomplete",
"description": "autocomplete plugin for oclif",
"version": "2.3.7",
"version": "2.3.8",
"author": "Salesforce",

@@ -10,15 +10,13 @@ "bugs": "https://github.com/oclif/plugin-autocomplete/issues",

"chalk": "^4.1.0",
"debug": "^4.3.4",
"fs-extra": "^9.0.1"
"debug": "^4.3.4"
},
"devDependencies": {
"@oclif/plugin-help": "^5",
"@oclif/test": "^2",
"@oclif/test": "^2.4.8",
"@types/chai": "^4",
"@types/chalk": "^2.2.0",
"@types/ejs": "^3.1.2",
"@types/fs-extra": "^9.0.13",
"@types/mocha": "^8",
"@types/nock": "^11.1.0",
"@types/node": "^15.14.9",
"@types/sinon-chai": "^3.2.9",
"chai": "^4",

@@ -32,6 +30,4 @@ "eslint": "^7.3.1",

"nyc": "^15.1.0",
"oclif": "^3.11.3",
"oclif": "^3.14.0",
"shx": "^0.3.3",
"sinon": "^12.0.1",
"sinon-chai": "^3.7.0",
"ts-node": "^9.0.0",

@@ -38,0 +34,0 @@ "tslib": "^2.6.2",

@@ -60,3 +60,3 @@ @oclif/plugin-autocomplete

_See code: [src/commands/autocomplete/index.ts](https://github.com/oclif/plugin-autocomplete/blob/v2.3.7/src/commands/autocomplete/index.ts)_
_See code: [src/commands/autocomplete/index.ts](https://github.com/oclif/plugin-autocomplete/blob/v2.3.8/src/commands/autocomplete/index.ts)_
<!-- commandsstop -->
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