Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@magidoc/cli

Package Overview
Dependencies
Maintainers
1
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@magidoc/cli - npm Package Compare versions

Comparing version 0.10.0 to 0.10.1

22

build/commands/generate/config/parser.js

@@ -17,5 +17,6 @@ import { ZMagidocConfiguration } from './types.js';

const allOptionsByName = _.keyBy(Object.values(templates), (template) => String(template.name));
const issues = [];
let issues = [];
_.forEach(options, (value, key) => {
const variable = allOptionsByName[key];
const path = ['website', 'options', key];
if (!variable) {

@@ -25,3 +26,3 @@ issues.push({

code: 'custom',
path: [key],
path,
});

@@ -34,11 +35,14 @@ }

if (!result.success) {
issues.concat(result.error.issues);
issues = issues.concat(result.error.issues.map((issue) => ({
...issue,
path: path.concat(issue.path),
})));
}
});
if (issues.length > 0) {
throwConfigurationError(issues, 'website.options.');
throwConfigurationError(issues);
}
}
function throwConfigurationError(issues, basePath = '') {
const formattedIssues = convertZodIssues(issues, basePath);
function throwConfigurationError(issues) {
const formattedIssues = convertZodIssues(issues);
const pluralIssue = issues.length > 1 ? 'issues' : 'issue';

@@ -58,8 +62,8 @@ const issuesText = chalk.red(`${issues.length} ${pluralIssue}`);

}
function convertZodIssues(issues, basePath) {
function convertZodIssues(issues) {
return issues.map((issue) => {
const path = `${basePath}${formatErrorPath(issue.path)}`;
const path = formatErrorPath(issue.path);
switch (issue.code) {
case 'invalid_type':
return ` ‣ ${issue.message} '${issue.expected}' but received '${issue.received}' at path '${path}'`;
return ` ‣ Expected: '${issue.expected}' but received '${issue.received}' at path '${path}'`;
case 'invalid_union':

@@ -66,0 +70,0 @@ const formattedErrors = issue.unionErrors

@@ -31,4 +31,5 @@ import { magidoc } from '@magidoc/plugin-starter-variables';

if (nonExistingOptions.length > 0) {
throw new Error(`Options ${nonExistingOptions.toString()} are not supported by template ${config.website.template}... Supported option names are ${(ctx.templateConfiguration.supportedOptions.map((value) => value.name),
toString())}`);
throw new Error(`Options [${nonExistingOptions.toString()}] are not supported by template ${config.website.template}... Supported option names are [${ctx.templateConfiguration.supportedOptions
.map((value) => value.name)
.join(', ')}]`);
}

@@ -35,0 +36,0 @@ insertDefaultVariables(newRecord);

@@ -5,3 +5,3 @@ {

"private": false,
"version": "0.10.0",
"version": "0.10.1",
"type": "module",

@@ -20,4 +20,4 @@ "license": "MIT",

"dependencies": {
"@magidoc/plugin-starter-variables": "^0.10.0",
"@magidoc/rollup-plugin-fetch-gql-schema": "^0.10.0",
"@magidoc/plugin-starter-variables": "^0.10.1",
"@magidoc/rollup-plugin-fetch-gql-schema": "^0.10.1",
"axios": "^0.26.1",

@@ -24,0 +24,0 @@ "chalk": "^5.0.1",

@@ -21,5 +21,6 @@ import { MagidocConfiguration, ZMagidocConfiguration } from './types'

)
const issues: ZodIssue[] = []
let issues: ZodIssue[] = []
_.forEach(options, (value, key) => {
const variable = allOptionsByName[key]
const path: (string | number)[] = ['website', 'options', key]
if (!variable) {

@@ -29,3 +30,3 @@ issues.push({

code: 'custom',
path: [key],
path,
})

@@ -39,3 +40,8 @@ }

if (!result.success) {
issues.concat(result.error.issues)
issues = issues.concat(
result.error.issues.map((issue) => ({
...issue,
path: path.concat(issue.path),
})),
)
}

@@ -45,8 +51,8 @@ })

if (issues.length > 0) {
throwConfigurationError(issues, 'website.options.')
throwConfigurationError(issues)
}
}
function throwConfigurationError(issues: ZodIssue[], basePath = ''): never {
const formattedIssues = convertZodIssues(issues, basePath)
function throwConfigurationError(issues: ZodIssue[]): never {
const formattedIssues = convertZodIssues(issues)
const pluralIssue = issues.length > 1 ? 'issues' : 'issue'

@@ -71,8 +77,8 @@ const issuesText = chalk.red(`${issues.length} ${pluralIssue}`)

function convertZodIssues(issues: ZodIssue[], basePath: string): string[] {
function convertZodIssues(issues: ZodIssue[]): string[] {
return issues.map((issue) => {
const path = `${basePath}${formatErrorPath(issue.path)}`
const path = formatErrorPath(issue.path)
switch (issue.code) {
case 'invalid_type':
return ` ‣ ${issue.message} '${issue.expected}' but received '${issue.received}' at path '${path}'`
return ` ‣ Expected: '${issue.expected}' but received '${issue.received}' at path '${path}'`
case 'invalid_union':

@@ -79,0 +85,0 @@ const formattedErrors = issue.unionErrors

@@ -41,8 +41,7 @@ import { magidoc } from '@magidoc/plugin-starter-variables'

throw new Error(
`Options ${nonExistingOptions.toString()} are not supported by template ${
`Options [${nonExistingOptions.toString()}] are not supported by template ${
config.website.template
}... Supported option names are ${
(ctx.templateConfiguration.supportedOptions.map((value) => value.name),
toString())
}`,
}... Supported option names are [${ctx.templateConfiguration.supportedOptions
.map((value) => value.name)
.join(', ')}]`,
)

@@ -49,0 +48,0 @@ }

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