Browse Source

Fix CLI checks

Leszek Wiesner 4 years ago
parent
commit
278f597651
4 changed files with 5 additions and 13 deletions
  1. 1 0
      cli/.eslintignore
  2. 1 5
      cli/src/helpers/InputOutput.ts
  3. 1 7
      cli/src/helpers/JsonSchemaPrompt.ts
  4. 2 1
      cli/tsconfig.json

+ 1 - 0
cli/.eslintignore

@@ -2,4 +2,5 @@
 # Temporarly ignore before merging `Sumer`
 /src/commands/media
 /src/commands/content-directory
+/src/base/MediaCommandBase.ts
 .eslintrc.js

+ 1 - 5
cli/src/helpers/InputOutput.ts

@@ -5,12 +5,8 @@ import fs from 'fs'
 import path from 'path'
 import Ajv from 'ajv'
 import $RefParser, { JSONSchema } from '@apidevtools/json-schema-ref-parser'
-import { getSchemasLocation } from '@joystream/cd-schemas'
 import chalk from 'chalk'
 
-// Default schema path for resolving refs
-const DEFAULT_SCHEMA_PATH = getSchemasLocation('entities') + path.sep
-
 export const IOFlags = {
   input: flags.string({
     char: 'i',
@@ -50,7 +46,7 @@ export async function getInputJson<T>(inputPath?: string, schema?: JSONSchema, s
 
 export async function validateInput(input: unknown, schema: JSONSchema, schemaPath?: string): Promise<void> {
   const ajv = new Ajv({ allErrors: true })
-  schema = await $RefParser.dereference(schemaPath || DEFAULT_SCHEMA_PATH, schema, {})
+  schema = await $RefParser.dereference(schemaPath || '.', schema, {})
   const valid = ajv.validate(schema, input) as boolean
   if (!valid) {
     throw new CLIError(`Input JSON file is not valid: ${ajv.errorsText()}`)

+ 1 - 7
cli/src/helpers/JsonSchemaPrompt.ts

@@ -4,8 +4,6 @@ import _ from 'lodash'
 import RefParser, { JSONSchema } from '@apidevtools/json-schema-ref-parser'
 import chalk from 'chalk'
 import { BOOL_PROMPT_OPTIONS } from './prompting'
-import { getSchemasLocation } from '@joystream/cd-schemas'
-import path from 'path'
 
 type CustomPromptMethod = () => Promise<any>
 type CustomPrompt = DistinctQuestion | CustomPromptMethod | { $item: CustomPrompt } | 'skip'
@@ -14,10 +12,6 @@ type CustomPrompt = DistinctQuestion | CustomPromptMethod | { $item: CustomPromp
 // eslint-disable-next-line @typescript-eslint/ban-types
 export type JsonSchemaCustomPrompts<T = Record<string, unknown>> = [keyof T | (string & {}) | RegExp, CustomPrompt][]
 
-// Default schema path for resolving refs
-// TODO: Would be nice to skip the filename part (but without it it doesn't work)
-const DEFAULT_SCHEMA_PATH = getSchemasLocation('entities') + path.sep
-
 export class JsonSchemaPrompter<JsonResult> {
   schema: JSONSchema
   schemaPath: string
@@ -29,7 +23,7 @@ export class JsonSchemaPrompter<JsonResult> {
     schema: JSONSchema,
     defaults?: Partial<JsonResult>,
     customPrompts?: JsonSchemaCustomPrompts,
-    schemaPath: string = DEFAULT_SCHEMA_PATH
+    schemaPath = '.'
   ) {
     this.customPropmpts = customPrompts
     this.schema = schema

+ 2 - 1
cli/tsconfig.json

@@ -24,6 +24,7 @@
   /* Temporary exclude before merging `Sumer` */
   "exclude": [
     "src/commands/content-directory/*",
-    "src/commands/media/*"
+    "src/commands/media/*",
+    "src/base/MediaCommandBase.ts"
   ]
 }