Skip to content

Commit

Permalink
Split wild_wild_path_parser
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Mar 13, 2022
1 parent d83bbb7 commit 7af8fe3
Show file tree
Hide file tree
Showing 29 changed files with 36 additions and 38 deletions.
8 changes: 2 additions & 6 deletions src/config/load/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import { UserError } from '../../error/main.js'
import { findValues } from '../../utils/recurse.js'
import { addBases, getBasePath } from '../cwd.js'
import { deepMerge, isRecurseObject } from '../merge.js'
import {
get,
has,
serializePath,
set,
} from '../normalize/lib/wild_wild_path/main.js'
import { get, has, set } from '../normalize/lib/wild_wild_path/main.js'
import { serializePath } from '../normalize/lib/wild_wild_path_parser/main.js'

import { loadConfigContents } from './contents.js'
import { normalizeConfigProp } from './normalize.js'
Expand Down
3 changes: 2 additions & 1 deletion src/config/normalize/lib/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { applyRule } from './apply.js'
import { addMoves } from './move.js'
import { getOpts } from './opts.js'
import { addWarnings } from './warn.js'
import { set, remove, isSamePath } from './wild_wild_path/main.js'
import { set, remove } from './wild_wild_path/main.js'
import { isSamePath } from './wild_wild_path_parser/main.js'

// Apply rule for a specific entry
export const applyEntryRule = async function (
Expand Down
3 changes: 2 additions & 1 deletion src/config/normalize/lib/modify.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { callValueFunc, callUserFunc, getValidateExampleError } from './call.js'
import { resolvePath } from './path.js'
import { transformValue } from './transform.js'
import { getWarnings } from './warn.js'
import { has, parsePath } from './wild_wild_path/main.js'
import { has } from './wild_wild_path/main.js'
import { parsePath } from './wild_wild_path_parser/main.js'

// Once the initial value has been computed, apply validation and transforms,
// unless the value is `undefined`.
Expand Down
2 changes: 1 addition & 1 deletion src/config/normalize/lib/move.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isParentPath, isSamePath } from './wild_wild_path/main.js'
import { isParentPath, isSamePath } from './wild_wild_path_parser/main.js'

// When a property is moved to another, record it.
export const addMoves = function (moves, newPaths, oldNamePath) {
Expand Down
2 changes: 1 addition & 1 deletion src/config/normalize/lib/opts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { callUserFunc } from './call.js'
import { getCwd } from './cwd.js'
import { applyMoves } from './move.js'
import { getPrefix, DEFAULT_PREFIX } from './prefix.js'
import { parsePath, serializePath } from './wild_wild_path/main.js'
import { parsePath, serializePath } from './wild_wild_path_parser/main.js'

// Retrieve `opts` passed to most methods.
// `funcOpts` are passed to user-provided functions.
Expand Down
3 changes: 2 additions & 1 deletion src/config/normalize/lib/rule.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { get, parseQuery, serializeQuery } from './wild_wild_path/main.js'
import { get } from './wild_wild_path/main.js'
import { parseQuery, serializeQuery } from './wild_wild_path_parser/main.js'

// Validate and normalize rules.
// All methods and properties that use queries can use either the string or the
Expand Down
2 changes: 1 addition & 1 deletion src/config/normalize/lib/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import isPlainObj from 'is-plain-obj'
import pReduce from 'p-reduce'

import { callValueFunc } from './call.js'
import { parsePath } from './wild_wild_path/main.js'
import { parsePath } from './wild_wild_path_parser/main.js'

// Apply `transform(value, opts)` which transforms the value set by the user.
// If can also delete it by returning `undefined`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isSamePath, isSameToken } from '../parsing/compare.js'
import { isSamePath, isSameToken } from '../../wild_wild_path_parser/main.js'

// Remove duplicate entries
export const removeDuplicates = function (entries) {
Expand Down
3 changes: 1 addition & 2 deletions src/config/normalize/lib/wild_wild_path/iterate/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { parseQuery } from '../parsing/parse.js'
import { serializePath } from '../parsing/serialize.js'
import { parseQuery, serializePath } from '../../wild_wild_path_parser/main.js'

import { removeDuplicates } from './duplicate.js'
import { expandToken } from './expand.js'
Expand Down
2 changes: 1 addition & 1 deletion src/config/normalize/lib/wild_wild_path/iterate/missing.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import isPlainObj from 'is-plain-obj'

import { getTokenType } from '../tokens/main.js'
import { getTokenType } from '../../wild_wild_path_parser/main.js'

// When the value does not exist, we set it deeply with `set()` but not with
// `list|get|has()`.
Expand Down
8 changes: 0 additions & 8 deletions src/config/normalize/lib/wild_wild_path/main.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
export { list, get, has } from './get.js'
export { iterate } from './iterate/main.js'
export {
isSameQuery,
isSamePath,
isSameToken,
isParentPath,
} from './parsing/compare.js'
export { serializeQuery, serializePath } from './parsing/serialize.js'
export { parseQuery, parsePath } from './parsing/parse.js'
export { remove } from './remove.js'
export { set } from './set.js'
3 changes: 2 additions & 1 deletion src/config/normalize/lib/wild_wild_path/set.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { isParentPath } from '../wild_wild_path_parser/main.js'

import { list } from './get.js'
import { handleMissingValue } from './iterate/missing.js'
import { isParentPath } from './parsing/compare.js'

// Set a value to one or multiple properties in `target` using a query string.
// Unless `mutate` is `true`, this returns a new copy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { getObjectTokenType } from '../tokens/main.js'

import { validatePath } from './normalize.js'
import { parseQuery } from './parse.js'
import { getObjectTokenType } from './tokens/main.js'

// Check if two queries are equal.
// Works with:
Expand Down
9 changes: 9 additions & 0 deletions src/config/normalize/lib/wild_wild_path_parser/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export {
isSameQuery,
isSamePath,
isSameToken,
isParentPath,
} from './compare.js'
export { parseQuery, parsePath } from './parse.js'
export { serializeQuery, serializePath } from './serialize.js'
export { getTokenType } from './tokens/main.js'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { inspect } from 'util'

import { getObjectTokenType, getPathObjectTokenType } from '../tokens/main.js'
import { getObjectTokenType, getPathObjectTokenType } from './tokens/main.js'

// Most methods accept both query and array syntaxes.
// This checks which one is used.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { validateEmptyQuery } from './normalize.js'
import {
ESCAPE,
ARRAY_SEPARATOR,
ARRAY_SEPARATOR_NAME,
TOKEN_SEPARATOR,
SPECIAL_CHARS,
} from '../tokens/escape.js'
import { getStringTokenType } from '../tokens/main.js'

import { validateEmptyQuery } from './normalize.js'
} from './tokens/escape.js'
import { getStringTokenType } from './tokens/main.js'

// Parse a query string to query arrays of tokens
// Use imperative logic for performance
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { TOKEN_SEPARATOR, ARRAY_SEPARATOR } from '../tokens/escape.js'
import { getObjectTokenType } from '../tokens/main.js'

import { parseQuery, parsePath } from './parse.js'
import { TOKEN_SEPARATOR, ARRAY_SEPARATOR } from './tokens/escape.js'
import { getObjectTokenType } from './tokens/main.js'

// Inverse of `parseQuery()`
// When passing a query string, it is parsed and re-serialized to validate and
Expand Down
3 changes: 2 additions & 1 deletion src/config/normalize/lib/wild_wild_path_utils/include.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { set, remove, list, isParentPath } from '../wild_wild_path/main.js'
import { set, remove, list } from '../wild_wild_path/main.js'
import { isParentPath } from '../wild_wild_path_parser/main.js'

// Returns an object with only the properties being queried.
export const pick = function (target, query, { sort, classes } = {}) {
Expand Down
2 changes: 1 addition & 1 deletion src/config/plugin/lib/shape.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getDummyRules } from '../../normalize/dummy.js'
import { isSameQuery } from '../../normalize/lib/wild_wild_path/main.js'
import { isSameQuery } from '../../normalize/lib/wild_wild_path_parser/main.js'
import { validateDefinedString } from '../../normalize/validate/simple.js'

import { PluginError, UserError, CoreError } from './error.js'
Expand Down
2 changes: 1 addition & 1 deletion src/config/plugin/lib/shared.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parseQuery } from '../../normalize/lib/wild_wild_path/main.js'
import { parseQuery } from '../../normalize/lib/wild_wild_path_parser/main.js'
import { pick } from '../../normalize/lib/wild_wild_path_utils/main.js'

// Retrieve top-level properties that are shared with all plugins of a specific
Expand Down

0 comments on commit 7af8fe3

Please sign in to comment.