Socket
Socket
Sign inDemoInstall

@spinajs/cli

Package Overview
Dependencies
Maintainers
1
Versions
219
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spinajs/cli - npm Package Compare versions

Comparing version 2.0.249 to 2.0.250

lib/cjs/config/logger.dev.d.ts

6

lib/cjs/cli.js

@@ -7,4 +7,10 @@ #!/usr/bin/env node

const index_js_1 = require("./index.js");
const configuration_common_1 = require("@spinajs/configuration-common");
di_1.DI.register(() => {
return process.argv;
}).as('__cli_argv_provider__');
async function cli() {
await di_1.DI.resolve(configuration_common_1.Configuration);
const log = di_1.DI.resolve(log_1.Log, ['CLI']);
log.success('Welcome to spinajs cli...');
try {

@@ -11,0 +17,0 @@ await di_1.DI.resolve(index_js_1.Cli);

4

lib/cjs/index.d.ts
import { CliCommand } from './interfaces.js';
import { AsyncService, Class } from '@spinajs/di';
import { AsyncService, ClassInfo } from '@spinajs/di';
import { Log } from '@spinajs/log-common';

@@ -8,5 +8,5 @@ export * from './interfaces.js';

protected Log: Log;
Commands: Array<Class<CliCommand>>;
Commands: Promise<Array<ClassInfo<CliCommand>>>;
resolve(): Promise<void>;
}
//# sourceMappingURL=index.d.ts.map

@@ -31,20 +31,17 @@ "use strict";

const commander_1 = require("commander");
const reflection_1 = require("@spinajs/reflection");
__exportStar(require("./interfaces.js"), exports);
__exportStar(require("./decorators.js"), exports);
di_1.DI.register(() => {
return process.argv;
}).as('__cli_argv_provider__');
class Cli extends di_1.AsyncService {
constructor() {
super(...arguments);
this.Commands = [];
}
async resolve() {
this.Commands = di_1.DI.getRegisteredTypes('__cli_command__');
for (const cClass of this.Commands) {
this.Log.trace(`Found command ${cClass.name}`);
const command = await di_1.DI.resolve(cClass);
const cMeta = Reflect.getMetadata(decorators_js_1.META_COMMAND, cClass);
const oMeta = Reflect.getMetadata(decorators_js_1.META_OPTION, cClass);
const aMeta = Reflect.getMetadata(decorators_js_1.META_ARGUMENT, cClass);
const commands = await this.Commands;
if (!commands || commands.length === 0) {
this.Log.warn('No registered commands found !');
return;
}
for (const cmd of commands) {
this.Log.trace(`Found command ${cmd.name}`);
const cMeta = Reflect.getMetadata(decorators_js_1.META_COMMAND, cmd.instance);
const oMeta = Reflect.getMetadata(decorators_js_1.META_OPTION, cmd.instance);
const aMeta = Reflect.getMetadata(decorators_js_1.META_ARGUMENT, cmd.instance);
const c = commander_1.program.command(cMeta.nameAndArgs, cMeta.description, cMeta.opts);

@@ -62,6 +59,6 @@ oMeta.forEach((o) => {

});
command.onCreation(c);
cmd.instance.onCreation(c);
c.action(async (...args) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
await command.execute(...args);
await cmd.instance.execute(...args);
});

@@ -78,2 +75,6 @@ }

], Cli.prototype, "Log", void 0);
__decorate([
(0, reflection_1.ResolveFromFiles)('/**/!(*.d).{ts,js}', 'system.dirs.cli'),
__metadata("design:type", Promise)
], Cli.prototype, "Commands", void 0);
//# sourceMappingURL=index.js.map

@@ -5,4 +5,10 @@ #!/usr/bin/env node

import { Cli } from './index.js';
import { Configuration } from '@spinajs/configuration-common';
DI.register(() => {
return process.argv;
}).as('__cli_argv_provider__');
async function cli() {
await DI.resolve(Configuration);
const log = DI.resolve(Log, ['CLI']);
log.success('Welcome to spinajs cli...');
try {

@@ -9,0 +15,0 @@ await DI.resolve(Cli);

import { CliCommand } from './interfaces.js';
import { AsyncService, Class } from '@spinajs/di';
import { AsyncService, ClassInfo } from '@spinajs/di';
import { Log } from '@spinajs/log-common';

@@ -8,5 +8,5 @@ export * from './interfaces.js';

protected Log: Log;
Commands: Array<Class<CliCommand>>;
Commands: Promise<Array<ClassInfo<CliCommand>>>;
resolve(): Promise<void>;
}
//# sourceMappingURL=index.d.ts.map

@@ -14,20 +14,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

import { program } from 'commander';
import { ResolveFromFiles } from '@spinajs/reflection';
export * from './interfaces.js';
export * from './decorators.js';
DI.register(() => {
return process.argv;
}).as('__cli_argv_provider__');
export class Cli extends AsyncService {
constructor() {
super(...arguments);
this.Commands = [];
}
async resolve() {
this.Commands = DI.getRegisteredTypes('__cli_command__');
for (const cClass of this.Commands) {
this.Log.trace(`Found command ${cClass.name}`);
const command = await DI.resolve(cClass);
const cMeta = Reflect.getMetadata(META_COMMAND, cClass);
const oMeta = Reflect.getMetadata(META_OPTION, cClass);
const aMeta = Reflect.getMetadata(META_ARGUMENT, cClass);
const commands = await this.Commands;
if (!commands || commands.length === 0) {
this.Log.warn('No registered commands found !');
return;
}
for (const cmd of commands) {
this.Log.trace(`Found command ${cmd.name}`);
const cMeta = Reflect.getMetadata(META_COMMAND, cmd.instance);
const oMeta = Reflect.getMetadata(META_OPTION, cmd.instance);
const aMeta = Reflect.getMetadata(META_ARGUMENT, cmd.instance);
const c = program.command(cMeta.nameAndArgs, cMeta.description, cMeta.opts);

@@ -45,6 +42,6 @@ oMeta.forEach((o) => {

});
command.onCreation(c);
cmd.instance.onCreation(c);
c.action(async (...args) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
await command.execute(...args);
await cmd.instance.execute(...args);
});

@@ -60,2 +57,6 @@ }

], Cli.prototype, "Log", void 0);
__decorate([
ResolveFromFiles('/**/!(*.d).{ts,js}', 'system.dirs.cli'),
__metadata("design:type", Promise)
], Cli.prototype, "Commands", void 0);
//# sourceMappingURL=index.js.map
{
"name": "@spinajs/cli",
"version": "2.0.249",
"version": "2.0.250",
"description": "SpinaJS command line module",

@@ -45,7 +45,7 @@ "main": "lib/cjs/index.js",

"dependencies": {
"@spinajs/configuration": "^2.0.249",
"@spinajs/di": "^2.0.249",
"@spinajs/exceptions": "^2.0.249",
"@spinajs/log": "^2.0.249",
"@spinajs/reflection": "^2.0.249",
"@spinajs/configuration": "^2.0.250",
"@spinajs/di": "^2.0.250",
"@spinajs/exceptions": "^2.0.250",
"@spinajs/log": "^2.0.250",
"@spinajs/reflection": "^2.0.250",
"commander": "10.0.0",

@@ -52,0 +52,0 @@ "reflect-metadata": "^0.1.13"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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