Update prettier-internal.js exports for easier use (#12737)
This commit is contained in:
1 parent
fccf19503c
commit
88c036a869
12 files changed
+53
-48
No files matched your search
+1
-3
@@ -1,7 +1,5 @@
|
||||
import { outdent } from "outdent";
|
||||
import prettierInternal from "./prettier-internal.js";
|
||||
|
||||
const { coreOptions } = prettierInternal;
|
||||
import { coreOptions } from "./prettier-internal.js";
|
||||
|
||||
const categoryOrder = [
|
||||
coreOptions.CATEGORY_OUTPUT,
|
||||
|
||||
+1
-5
@@ -1,14 +1,10 @@
|
||||
import prettierInternal from "./prettier-internal.js";
|
||||
import { getLast } from "./utils.js";
|
||||
import getContextOptions from "./options/get-context-options.js";
|
||||
import {
|
||||
parseArgv,
|
||||
parseArgvWithoutPlugins,
|
||||
} from "./options/parse-cli-arguments.js";
|
||||
|
||||
const {
|
||||
utils: { getLast },
|
||||
} = prettierInternal;
|
||||
|
||||
/**
|
||||
* @typedef {Object} Context
|
||||
* @property logger
|
||||
|
||||
+2
-5
@@ -2,15 +2,12 @@ import { promises as fs } from "node:fs";
|
||||
import path from "node:path";
|
||||
import chalk from "chalk";
|
||||
import prettier from "../index.js";
|
||||
import thirdParty from "../common/third-party.cjs";
|
||||
import prettierInternal from "./prettier-internal.js";
|
||||
import { getStdin } from "../common/third-party.cjs";
|
||||
import { createIgnorer, errors } from "./prettier-internal.js";
|
||||
import { expandPatterns, fixWindowsSlashes } from "./expand-patterns.js";
|
||||
import getOptionsForFile from "./options/get-options-for-file.js";
|
||||
import isTTY from "./is-tty.js";
|
||||
|
||||
const { getStdin } = thirdParty;
|
||||
const { createIgnorer, errors } = prettierInternal;
|
||||
|
||||
let createTwoFilesPatch;
|
||||
async function diff(a, b) {
|
||||
if (!createTwoFilesPatch) {
|
||||
|
||||
+1
-6
@@ -7,12 +7,7 @@ import { createDetailedUsage, createUsage } from "./usage.js";
|
||||
import { formatStdin, formatFiles } from "./format.js";
|
||||
import logFileInfoOrDie from "./file-info.js";
|
||||
import logResolvedConfigPathOrDie from "./find-config-path.js";
|
||||
import prettierInternal from "./prettier-internal.js";
|
||||
import { printToScreen } from "./utils.js";
|
||||
|
||||
const {
|
||||
utils: { isNonEmptyArray },
|
||||
} = prettierInternal;
|
||||
import { printToScreen, isNonEmptyArray } from "./utils.js";
|
||||
|
||||
async function run(rawArguments) {
|
||||
// Create a default level logger, so we can log errors during `logLevel` parsing
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
import prettierInternal from "../prettier-internal.js";
|
||||
|
||||
const {
|
||||
utils: { partition },
|
||||
} = prettierInternal;
|
||||
import { partition } from "../utils.js";
|
||||
|
||||
export default function createMinimistOptions(detailedOptions) {
|
||||
const [boolean, string] = partition(
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
import prettier from "../../index.js";
|
||||
import prettierInternal from "../prettier-internal.js";
|
||||
import { optionsHiddenDefaults } from "../prettier-internal.js";
|
||||
import * as constant from "../constant.js";
|
||||
import { arrayify } from "../utils.js";
|
||||
import {
|
||||
normalizeDetailedOptionMap,
|
||||
createDetailedOptionMap,
|
||||
} from "./option-map.js";
|
||||
|
||||
const {
|
||||
optionsModule,
|
||||
utils: { arrayify },
|
||||
} = prettierInternal;
|
||||
|
||||
function getContextOptions(plugins, pluginSearchDirs) {
|
||||
const { options: supportOptions, languages } = prettier.getSupportInfo({
|
||||
showDeprecated: true,
|
||||
@@ -27,7 +23,7 @@ function getContextOptions(plugins, pluginSearchDirs) {
|
||||
const detailedOptions = arrayify(detailedOptionMap, "name");
|
||||
|
||||
const apiDefaultOptions = {
|
||||
...optionsModule.hiddenDefaults,
|
||||
...optionsHiddenDefaults,
|
||||
...Object.fromEntries(
|
||||
supportOptions
|
||||
.filter(({ deprecated }) => !deprecated)
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import dashify from "dashify";
|
||||
import prettier from "../../index.js";
|
||||
import prettierInternal from "../prettier-internal.js";
|
||||
import { normalizeApiOptions } from "../prettier-internal.js";
|
||||
import minimist from "./minimist.js";
|
||||
import createMinimistOptions from "./create-minimist-options.js";
|
||||
import normalizeCliOptions from "./normalize-cli-options.js";
|
||||
|
||||
const { optionsNormalizer } = prettierInternal;
|
||||
|
||||
function getOptions(argv, detailedOptions) {
|
||||
return Object.fromEntries(
|
||||
detailedOptions
|
||||
@@ -117,7 +115,7 @@ async function getOptionsForFile(context, filepath) {
|
||||
...applyConfigPrecedence(
|
||||
context,
|
||||
options &&
|
||||
optionsNormalizer.normalizeApiOptions(options, context.supportOptions, {
|
||||
normalizeApiOptions(options, context.supportOptions, {
|
||||
logger: context.logger,
|
||||
})
|
||||
),
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import chalk from "chalk";
|
||||
import leven from "leven";
|
||||
import prettierInternal from "../prettier-internal.js";
|
||||
|
||||
const { optionsNormalizer } = prettierInternal;
|
||||
import { normalizeCliOptions as prettierNormalizeCliOptions } from "../prettier-internal.js";
|
||||
|
||||
function normalizeCliOptions(options, optionInfos, opts) {
|
||||
return optionsNormalizer.normalizeCliOptions(options, optionInfos, {
|
||||
return prettierNormalizeCliOptions(options, optionInfos, {
|
||||
colorsModule: chalk,
|
||||
levenshteinDistance: leven,
|
||||
...opts,
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import dashify from "dashify";
|
||||
import prettierInternal from "../prettier-internal.js";
|
||||
|
||||
const { coreOptions } = prettierInternal;
|
||||
import { coreOptions } from "../prettier-internal.js";
|
||||
|
||||
function normalizeDetailedOption(name, option) {
|
||||
return {
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
import prettier from "../index.js";
|
||||
|
||||
export default prettier.__internal;
|
||||
const {
|
||||
errors,
|
||||
coreOptions,
|
||||
createIgnorer,
|
||||
optionsHiddenDefaults,
|
||||
normalizeApiOptions,
|
||||
normalizeCliOptions,
|
||||
} = prettier.__internal;
|
||||
|
||||
export {
|
||||
errors,
|
||||
coreOptions,
|
||||
createIgnorer,
|
||||
optionsHiddenDefaults,
|
||||
normalizeApiOptions,
|
||||
normalizeCliOptions,
|
||||
};
|
||||
+14
-1
@@ -1,3 +1,8 @@
|
||||
import prettier from "../index.js";
|
||||
|
||||
const { arrayify, getLast, isNonEmptyArray, partition } =
|
||||
prettier.__internal.utils;
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
const printToScreen = console.log.bind(console);
|
||||
|
||||
@@ -36,4 +41,12 @@ function pick(object, keys) {
|
||||
return Object.fromEntries(entries);
|
||||
}
|
||||
|
||||
export { printToScreen, groupBy, pick };
|
||||
export {
|
||||
arrayify,
|
||||
getLast,
|
||||
isNonEmptyArray,
|
||||
partition,
|
||||
printToScreen,
|
||||
groupBy,
|
||||
pick,
|
||||
};
|
||||
+8
-4
@@ -18,8 +18,11 @@ import languages from "./languages.js";
|
||||
import * as errors from "./common/errors.js";
|
||||
import * as coreOptions from "./main/core-options.js";
|
||||
import createIgnorer from "./common/create-ignorer.js";
|
||||
import * as optionsModule from "./main/options.js";
|
||||
import * as optionsNormalizer from "./main/options-normalizer.js";
|
||||
import { hiddenDefaults as optionsHiddenDefaults } from "./main/options.js";
|
||||
import {
|
||||
normalizeApiOptions,
|
||||
normalizeCliOptions,
|
||||
} from "./main/options-normalizer.js";
|
||||
import arrayify from "./utils/arrayify.js";
|
||||
import getLast from "./utils/get-last.js";
|
||||
import partition from "./utils/partition.js";
|
||||
@@ -97,8 +100,9 @@ const prettier = {
|
||||
errors,
|
||||
coreOptions,
|
||||
createIgnorer,
|
||||
optionsModule,
|
||||
optionsNormalizer,
|
||||
optionsHiddenDefaults,
|
||||
normalizeApiOptions,
|
||||
normalizeCliOptions,
|
||||
utils: {
|
||||
arrayify,
|
||||
getLast,
|
||||
|
||||
Reference in new issue
Block a user