Skip to content

Commit

Permalink
Move files
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jan 30, 2022
1 parent a5dbec1 commit 8451e3a
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 119 deletions.
2 changes: 1 addition & 1 deletion src/config/load/npx.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { env } from 'process'

import { CONFIG_PLUGIN_TYPE } from '../plugin/types/config.js'
import { CONFIG_PLUGIN_TYPE } from '../plugin/types.js'

// In principle, users can use `npx` with the "npm" resolver by doing:
// npx --package=spyd-config-{name} spyd --config=spyd-config-{name} ...
Expand Down
2 changes: 1 addition & 1 deletion src/config/load/resolvers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { UserError } from '../../error/main.js'
import { getPluginPath } from '../plugin/load.js'
import { CONFIG_PLUGIN_TYPE } from '../plugin/types/config.js'
import { CONFIG_PLUGIN_TYPE } from '../plugin/types.js'

// The `config` can be:
// - a file path
Expand Down
2 changes: 1 addition & 1 deletion src/config/lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { findUp } from 'find-up'
import pLocate from 'p-locate'
import { pathExists } from 'path-exists'

import { CONFIG_PLUGIN_TYPE } from './plugin/types/config.js'
import { CONFIG_PLUGIN_TYPE } from './plugin/types.js'

// The default values for `config` and `tasks` look for `spyd.*` and `tasks.*`
// in the current or parent directories.
Expand Down
2 changes: 1 addition & 1 deletion src/config/merge/tasks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PLUGIN_TYPES } from '../plugin/types/main.js'
import { PLUGIN_TYPES } from '../plugin/types.js'

// Custom merging logic for tasks.
// `tasks` or `runnnerConfig.{runnerId}.tasks` are concatenated, not overridden
Expand Down
2 changes: 1 addition & 1 deletion src/config/plugin/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { normalizeReporters } from '../../report/config/main.js'

import { addPluginsConfig } from './config.js'
import { loadPlugins } from './load.js'
import { PLUGIN_TYPES_ARRAY } from './types/main.js'
import { PLUGIN_TYPES_ARRAY } from './types.js'

// Several configuration properties (`runner`, `reporter`)
// can be customized with custom modules. This loads them. Each type can specify
Expand Down
2 changes: 1 addition & 1 deletion src/config/plugin/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
validateJson,
} from '../normalize/validate.js'

import { PLUGIN_TYPES_ARRAY } from './types/main.js'
import { PLUGIN_TYPES_ARRAY } from './types.js'

// Retrieve the definition for plugins, both the selection property
// (like `reporter`) and the configuration one (like `reporterConfig`).
Expand Down
17 changes: 17 additions & 0 deletions src/config/plugin/types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { REPORTER_PLUGIN_TYPE } from '../../report/reporters/plugin.js'
import { RUNNER_PLUGIN_TYPE } from '../../runners/plugin.js'

// All plugin types
export const PLUGIN_TYPES = {
[RUNNER_PLUGIN_TYPE.type]: RUNNER_PLUGIN_TYPE,
[REPORTER_PLUGIN_TYPE.type]: REPORTER_PLUGIN_TYPE,
}

export const PLUGIN_TYPES_ARRAY = Object.values(PLUGIN_TYPES)

// Shared configurations are plugins when using the npm resolver.
// They are handled differently, i.e. require a separate type.
export const CONFIG_PLUGIN_TYPE = {
type: 'config',
modulePrefix: 'spyd-config-',
}
6 changes: 0 additions & 6 deletions src/config/plugin/types/config.js

This file was deleted.

107 changes: 0 additions & 107 deletions src/config/plugin/types/main.js

This file was deleted.

64 changes: 64 additions & 0 deletions src/report/reporters/plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { normalizeOptionalArray } from '../../config/normalize/transform.js'
import {
validateBoolean,
validateDefinedString,
validateObject,
validateFunction,
} from '../../config/normalize/validate.js'
import { DEFAULT_REPORTER_OUTPUT } from '../contents/output.js'
import { getReportMethods } from '../formats/list.js'

import { BUILTIN_REPORTERS, DEFAULT_REPORTERS } from './main.js'

export const REPORTER_PLUGIN_TYPE = {
type: 'reporter',
varName: 'reporters',
selectProp: 'reporter',
configProp: 'reporterConfig',
topProps: [
'quiet',
'output',
'colors',
'showTitles',
'showSystem',
'showMetadata',
'showPrecision',
'showDiff',
],
modulePrefix: 'spyd-reporter-',
commands: ['remove', 'run', 'show'],
isCombinationDimension: false,
builtins: BUILTIN_REPORTERS,
selectPropDefault: DEFAULT_REPORTERS,
selectPropDefinition: {
transform(value, { config }) {
return config.force ? [] : normalizeOptionalArray(value)
},
},
mainDefinitions: [
...getReportMethods().map((name) => ({
name,
validate: validateFunction,
})),
{
name: 'capabilities',
default: {},
validate: validateObject,
},
{
name: 'capabilities.debugStats',
default: false,
validate: validateBoolean,
},
{
name: 'capabilities.history',
default: false,
validate: validateBoolean,
},
{
name: 'defaultOutput',
default: DEFAULT_REPORTER_OUTPUT,
validate: validateDefinedString,
},
],
}
42 changes: 42 additions & 0 deletions src/runners/plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import {
validateEmptyArray,
validateFunction,
} from '../config/normalize/validate.js'

import { BUILTIN_RUNNERS, DEFAULT_RUNNERS } from './main.js'

export const RUNNER_PLUGIN_TYPE = {
// Shown in error message
type: 'runner',
// Internal variable name
varName: 'runners',
// Configuration property selecting the plugin
selectProp: 'runner',
// Configuration property configuring the plugin
configProp: 'runnerConfig',
// Configuration properties which can be overridden by each plugin
topProps: ['tasks'],
// Prefix of the npm package
modulePrefix: 'spyd-runner-',
// Commands which use the plugin
commands: ['dev', 'run'],
// Whether this is a combination's dimension.
// When false, this allows using custom prefixes.
isCombinationDimension: true,
// Builtin plugins
builtins: BUILTIN_RUNNERS,
// Default value for the `selectProp`
selectPropDefault: DEFAULT_RUNNERS,
// Additional configuration definition for `selectProp`
selectPropDefinition: {
validate: validateEmptyArray,
},
// Configuration definition for the plugin itself
mainDefinitions: [
{
name: 'launch',
required: true,
validate: validateFunction,
},
],
}

0 comments on commit 8451e3a

Please sign in to comment.