New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@opaline/core

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opaline/core - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

cli/commands/compiler-491af673.js

6

CHANGELOG.md
# @opaline/core
## 0.3.0
### Minor Changes
- d8bf2ef: allow nesting folders inside commands
## 0.2.0

@@ -4,0 +10,0 @@

4

cli/commands/build.js

@@ -14,4 +14,4 @@ 'use strict';

require('chalk');
require('./messages-353156fc.js');
var compiler = require('./compiler-49f61bfa.js');
require('./messages-1184afb9.js');
var compiler = require('./compiler-491af673.js');
require('@babel/parser');

@@ -18,0 +18,0 @@ require('@babel/traverse');

@@ -10,3 +10,3 @@ 'use strict';

var chalk = _interopDefault(require('chalk'));
var messages = require('./messages-353156fc.js');
var messages = require('./messages-1184afb9.js');
var cp = require('child_process');

@@ -13,0 +13,0 @@ var enquirer = require('enquirer');

@@ -14,4 +14,4 @@ 'use strict';

require('chalk');
require('./messages-353156fc.js');
var compiler = require('./compiler-49f61bfa.js');
require('./messages-1184afb9.js');
var compiler = require('./compiler-491af673.js');
require('@babel/parser');

@@ -18,0 +18,0 @@ require('@babel/traverse');

@@ -1,2 +0,2 @@

import { Compiler } from "../compiler/compiler";
import { Compiler } from "./compiler/compiler";

@@ -3,0 +3,0 @@ /**

@@ -13,3 +13,3 @@ import * as fs from "fs";

OP007_errorProjectFolderExists
} from "../compiler/messages";
} from "./compiler/messages";

@@ -16,0 +16,0 @@ let writeFile = promisify(fs.writeFile);

@@ -1,2 +0,2 @@

import { Compiler } from "../compiler/compiler";
import { Compiler } from "./compiler/compiler";

@@ -3,0 +3,0 @@ /**

@@ -6,6 +6,3 @@ import { OpalineError } from "./utils/error";

export { print, printError, printInfo, printWarning };
export default function opaline(
rawArgv: typeof process.argv,
config: OpalineConfig
): Promise<void>;
//# sourceMappingURL=index.d.ts.map
export default function opaline(rawArgv: typeof process.argv, config: OpalineConfig): Promise<void>;
//# sourceMappingURL=index.d.ts.map
"use strict";
var __importDefault =
(this && this.__importDefault) ||
function(mod) {
return mod && mod.__esModule ? mod : { default: mod };
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const help_theme_default_1 = __importDefault(
require("@opaline/help-theme-default")
);
const help_theme_default_1 = __importDefault(require("@opaline/help-theme-default"));
const help_1 = require("./handlers/help");

@@ -21,136 +17,136 @@ const args_1 = require("./utils/args");

async function opaline(rawArgv, config) {
let helpFormatter = help_theme_default_1.default;
let argv = rawArgv.slice(2);
let commandName = argv[0];
let isCommand = !!commandName && !commandName.startsWith("-");
let hasCommand = name => !!config.commands[name];
// 0. If no commands -> blow up!
// 1. If --version and command is not passed -> print version
// 2. If --help
// 2.1. If command is not passed -> help
// 2.2. If command is passed and exists -> help
// 2.3. If command is passed and doesn't exist -> error
// 3. If command is passed and exists -> run
// 4. If command doesn't exist and single command cli
// 4.1. Check if index exists -> run
// 4.2. If index doesn't exist -> help
// 5. If command doesn't exist and multi command cli
// 5.1. If index exists -> run
// 5.2. If index doesn't exist -> help
// # 0
if (!Object.keys(config.commands).length) {
return error(`Need to add at least 1 command...`);
}
// # 1
if (args_1.isVersion(argv) && !isCommand) {
return version(config.cliVersion);
}
// # 2
else if (args_1.isHelp(argv)) {
if (!isCommand) {
return help({
helpFormatter,
config,
commandName: "index"
});
} else if (isCommand && hasCommand(commandName)) {
return help({
helpFormatter,
config,
commandName
});
} else if (isCommand && !hasCommand(commandName)) {
return error(
`Command "${commandName}" doesn't exist, help can't be printed for it. Try "${config.cliName} --help"`
);
let helpFormatter = help_theme_default_1.default;
let argv = rawArgv.slice(2);
let commandName = argv[0];
let isCommand = !!commandName && !commandName.startsWith("-");
let hasCommand = (name) => !!config.commands[name];
// 0. If no commands -> blow up!
// 1. If --version and command is not passed -> print version
// 2. If --help
// 2.1. If command is not passed -> help
// 2.2. If command is passed and exists -> help
// 2.3. If command is passed and doesn't exist -> error
// 3. If command is passed and exists -> run
// 4. If command doesn't exist and single command cli
// 4.1. Check if index exists -> run
// 4.2. If index doesn't exist -> help
// 5. If command doesn't exist and multi command cli
// 5.1. If index exists -> run
// 5.2. If index doesn't exist -> help
// # 0
if (!Object.keys(config.commands).length) {
return error(`Need to add at least 1 command...`);
}
}
// # 3
else if (isCommand && hasCommand(commandName)) {
return await run({
commandName,
config,
argv,
isCommand
});
}
// # 4 – single command cli
else if (config.isSingleCommand) {
// # 4.1 | 4.2
if (hasCommand("index")) {
return await run({
commandName: "index",
config,
argv,
isCommand
});
} else {
return help({
helpFormatter,
config,
commandName: ""
});
// # 1
if (args_1.isVersion(argv) && !isCommand) {
return version(config.cliVersion);
}
}
// # 5 – multi-command cli
else if (!config.isSingleCommand) {
// # 5.1 | 5.2
if (hasCommand("index")) {
return await run({
commandName: "index",
config,
argv,
isCommand
});
} else {
return help({
helpFormatter,
config,
commandName: ""
});
// # 2
else if (args_1.isHelp(argv)) {
if (!isCommand) {
return help({
helpFormatter,
config,
commandName: "index"
});
}
else if (isCommand && hasCommand(commandName)) {
return help({
helpFormatter,
config,
commandName
});
}
else if (isCommand && !hasCommand(commandName)) {
return error(`Command "${commandName}" doesn't exist, help can't be printed for it. Try "${config.cliName} --help"`);
}
}
}
// # 3
else if (isCommand && hasCommand(commandName)) {
return await run({
commandName,
config,
argv,
isCommand
});
}
// # 4 – single command cli
else if (config.isSingleCommand) {
// # 4.1 | 4.2
if (hasCommand("index")) {
return await run({
commandName: "index",
config,
argv,
isCommand
});
}
else {
return help({
helpFormatter,
config,
commandName: ""
});
}
}
// # 5 – multi-command cli
else if (!config.isSingleCommand) {
// # 5.1 | 5.2
if (hasCommand("index")) {
return await run({
commandName: "index",
config,
argv,
isCommand
});
}
else {
return help({
helpFormatter,
config,
commandName: ""
});
}
}
}
exports.default = opaline;
async function run({ config, commandName, argv, isCommand }) {
let minimist = require("minimist");
let buildOptions = require("minimist-options");
let command = config.commands[commandName];
let { _: rawInputs, ...flags } = minimist(
argv,
buildOptions(command.meta.options)
);
let inputs =
isCommand && commandName !== "index" ? rawInputs.slice(1) : rawInputs;
let args = Object.keys(command.meta.options || {}).map(opt => flags[opt]);
try {
await command
.load()
.apply(null, command.meta.shouldPassInputs ? [inputs, ...args] : args);
} catch (error) {
print_1.printError(error);
if (error instanceof error_1.OpalineError) {
process.exit(error.code);
} else {
process.exit(1);
let minimist = require("minimist");
let buildOptions = require("minimist-options");
let command = config.commands[commandName];
let { _: rawInputs, ...flags } = minimist(argv, buildOptions(command.meta.options));
let inputs = isCommand && commandName !== "index" ? rawInputs.slice(1) : rawInputs;
let args = Object.keys(command.meta.options || {}).map(opt => flags[opt]);
try {
await command
.load()
.apply(null, command.meta.shouldPassInputs ? [inputs, ...args] : args);
}
}
catch (error) {
print_1.printError(error);
if (error instanceof error_1.OpalineError) {
process.exit(error.code);
}
else {
process.exit(1);
}
}
}
function version(v) {
console.log(v);
process.exit(0);
console.log(v);
process.exit(0);
}
function error(msg) {
print_1.printError(msg);
process.exit(1);
print_1.printError(msg);
process.exit(1);
}
function help({ helpFormatter, config, commandName }) {
help_1.helpCommand({
helpFormatter,
config,
commandName
});
process.exit(0);
help_1.helpCommand({
helpFormatter,
config,
commandName
});
process.exit(0);
}
// TODO: logging
// TODO: command aliases
export declare class OpalineError extends Error {
code?: number;
hint?: string | readonly string[];
constructor(
message?: string,
hint?: string | readonly string[],
code?: number
);
static fromArray(
data:
| readonly [string]
| readonly [string, string | readonly string[]]
| readonly [string, string | readonly string[], number]
): OpalineError;
code?: number;
hint?: string | readonly string[];
constructor(message?: string, hint?: string | readonly string[], code?: number);
static fromArray(data: readonly [string] | readonly [string, string | readonly string[]] | readonly [string, string | readonly string[], number]): OpalineError;
}
//# sourceMappingURL=error.d.ts.map
//# sourceMappingURL=error.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class OpalineError extends Error {
constructor(message, hint, code = 1) {
super(message);
this.code = code;
this.hint = hint;
}
static fromArray(data) {
return new OpalineError(data[0], data[1], data[2]);
}
constructor(message, hint, code = 1) {
super(message);
this.code = code;
this.hint = hint;
}
static fromArray(data) {
return new OpalineError(data[0], data[1], data[2]);
}
}
exports.OpalineError = OpalineError;
import { OpalineError } from "../utils/error";
export interface NestedPrintableOutput extends Array<PrintableOutput> {}
export declare type PrintableOutput =
| string
| Array<string | NestedPrintableOutput>;
export interface NestedPrintableOutput extends Array<PrintableOutput> {
}
export declare type PrintableOutput = string | Array<string | NestedPrintableOutput>;
export declare function indent(text: string, level?: number): string;
export declare function print(text: PrintableOutput, level?: number): void;
export declare function printWarning(text: string): void;
export declare function printError(
err: OpalineError | Error | string,
verbose?: boolean
): void;
export declare function printError(err: OpalineError | Error | string, verbose?: boolean): void;
export declare function printInfo(text: string): void;
//# sourceMappingURL=print.d.ts.map
//# sourceMappingURL=print.d.ts.map
"use strict";
var __importDefault =
(this && this.__importDefault) ||
function(mod) {
return mod && mod.__esModule ? mod : { default: mod };
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_1 = __importDefault(require("chalk"));
function indent(text, level = 1) {
return `${"".padStart(level * 2, " ")}${text}`;
return `${"".padStart(level * 2, " ")}${text}`;
}
exports.indent = indent;
function print(text, level = 0) {
if (Array.isArray(text)) {
text.forEach(item => {
if (Array.isArray(item)) {
print(item, level + 1);
} else {
console.log(indent(item, level));
}
});
} else {
console.log(indent(text, level));
}
if (Array.isArray(text)) {
text.forEach(item => {
if (Array.isArray(item)) {
print(item, level + 1);
}
else {
console.log(indent(item, level));
}
});
}
else {
console.log(indent(text, level));
}
}
exports.print = print;
function printWarning(text) {
print(chalk_1.default.yellow("[WARN] ") + text);
print(chalk_1.default.yellow("[WARN] ") + text);
}
exports.printWarning = printWarning;
function printError(err, verbose = false) {
if (typeof err === "string") {
print(err);
} else {
print(
[chalk_1.default.red(`${err.message}`)]
.concat(err.hint ? err.hint : [])
.concat(verbose && err.stack ? err.stack.split("\n") : [])
);
}
if (typeof err === "string") {
print(err);
}
else {
print([chalk_1.default.red(`${err.message}`)]
.concat(err.hint ? err.hint : [])
.concat(verbose && err.stack ? err.stack.split("\n") : []));
}
}
exports.printError = printError;
function printInfo(text) {
print(chalk_1.default.blue("[INFO] ") + text);
print(chalk_1.default.blue("[INFO] ") + text);
}
exports.printInfo = printInfo;
{
"name": "@opaline/core",
"version": "0.2.0",
"version": "0.3.0",
"main": "./dist/index.js",

@@ -5,0 +5,0 @@ "description": "Opaline CLI Tools Framework",

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