@chiragrupani/package-install-cmd
Advanced tools
Comparing version 2.2.2 to 2.2.3
#!/usr/bin/env node | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -7,17 +30,20 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const fs = __importStar(require("fs")); | ||
const path_1 = __importDefault(require("path")); | ||
const colorFormat_1 = require("./colorFormat"); | ||
const packageFileReader_1 = __importDefault(require("./packageFileReader")); | ||
console.log(colorFormat_1.colors.GreenFormat, `[PIC 2.2.2] Generating commands ...`); | ||
// Get process.argv | ||
const packageJson = JSON.parse(fs.readFileSync(path_1.default.join(__dirname, "..", "package.json"), "utf8")); | ||
let version = packageJson.version; | ||
console.log(colorFormat_1.colors.GreenFormat, `[PIC ${version}] Generating commands ...`); | ||
let args = process.argv; | ||
let includeVersion = false; | ||
if (process.argv.length > 2) { | ||
let versionArg = process.argv[2].toUpperCase(); | ||
if (versionArg == "--WithVersion".toUpperCase() || versionArg == "-WV") { | ||
let listMode = false; | ||
for (var i = 0; i < args.length; i++) { | ||
var arg = args[i]; | ||
if (arg.toUpperCase() === "--WithVersion".toUpperCase() || | ||
arg.toUpperCase() == "-WV") { | ||
includeVersion = true; | ||
} | ||
} | ||
let listMode = false; | ||
if (process.argv.length > 3) { | ||
let versionArg = process.argv[3].toUpperCase(); | ||
if (versionArg == "--list".toUpperCase() || versionArg == "-l") { | ||
else if (arg.toUpperCase() == "--list".toUpperCase() || | ||
arg.toUpperCase() == "-L") { | ||
listMode = true; | ||
@@ -28,3 +54,3 @@ } | ||
.then((alldependency) => { | ||
packageFileReader_1.default.DisplayDependency(alldependency); | ||
packageFileReader_1.default.DisplayDependency(alldependency, listMode); | ||
}) | ||
@@ -31,0 +57,0 @@ .then(() => console.log(colorFormat_1.colors.GreenFormat, "Done!")) |
@@ -8,2 +8,3 @@ export type DependencyType = "Dev Dependency" | "Dependency"; | ||
get DependencyCommand(): string[]; | ||
get ListDependencyCommand(): string[]; | ||
} |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Commands = void 0; | ||
const os_1 = __importDefault(require("os")); | ||
class Commands { | ||
@@ -31,3 +35,15 @@ Dependency; | ||
} | ||
get ListDependencyCommand() { | ||
let commands = []; | ||
if (this.Dependency.length > 0) { | ||
let dependenciesCmd = this.Dependency.join(os_1.default.EOL); | ||
commands.push(dependenciesCmd); | ||
} | ||
if (this.TypesDependency.length > 0) { | ||
let typeDependenciesCmd = this.TypesDependency.join(os_1.default.EOL); | ||
commands.push(typeDependenciesCmd); | ||
} | ||
return commands; | ||
} | ||
} | ||
exports.Commands = Commands; |
@@ -7,3 +7,3 @@ import { Commands } from "./commands"; | ||
static GetInstallCommands(includeVersion: boolean, listMode: boolean): Promise<Commands[]>; | ||
static DisplayDependency(commands: Commands[]): void; | ||
static DisplayDependency(commands: Commands[], listMode: boolean): void; | ||
} |
@@ -65,3 +65,3 @@ "use strict"; | ||
dependencyValue = includeVersion | ||
? value + " ".repeat(6) + obj[key][value] | ||
? value.padEnd(50, " ") + obj[key][value] | ||
: value; | ||
@@ -97,3 +97,3 @@ } | ||
} | ||
static DisplayDependency(commands) { | ||
static DisplayDependency(commands, listMode) { | ||
if (commands.length == 0) { | ||
@@ -104,3 +104,5 @@ console.log(`No dependencies are installed`); | ||
commands.forEach((command) => { | ||
let npmCommands = command.DependencyCommand; | ||
let npmCommands = listMode | ||
? command.ListDependencyCommand | ||
: command.DependencyCommand; | ||
if (npmCommands.length > 0) { | ||
@@ -110,3 +112,5 @@ console.log(colorFormat_1.colors.cyanUnderscoreFormat, command.dependencyType + ":"); | ||
console.log(npmCommands[index]); | ||
console.log(); | ||
if (!listMode) { | ||
console.log(); | ||
} | ||
} | ||
@@ -113,0 +117,0 @@ console.log(); |
{ | ||
"name": "@chiragrupani/package-install-cmd", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"description": "Lists the dependency and dev dependency in the project and generates commands to install them using npm", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -60,2 +60,23 @@ ## Package Install Command generator (PIC) | ||
Get output in list format | ||
```sh | ||
# Navigate to folder containing package.json and execute below command: | ||
pic --withversion --list | ||
``` | ||
or | ||
```sh | ||
# Navigate to folder containing package.json and execute below command, if version is not required: | ||
pic --list | ||
``` | ||
OR | ||
```sh | ||
# Navigate to folder containing package.json and execute below command: | ||
pic -l | ||
``` | ||
<hr/> | ||
@@ -62,0 +83,0 @@ |
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
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
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
16186
277
111
0
2