Skip to content

Commit

Permalink
refactor: uses node imports aliasses in package.json for config-utl
Browse files Browse the repository at this point in the history
  • Loading branch information
sverweij committed Oct 9, 2023
1 parent 3315882 commit ef970df
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"main": "src/main/index.mjs",
"imports": {
"#cache/*": "./src/cache/*",
"#config-utl/*": "./src/config-utl/*",
"#configuration-schema": "./src/schema/configuration.schema.mjs",
"#cli/*": "./src/cli/*",
"#cruise-result-schema": "./src/schema/cruise-result.schema.mjs",
Expand Down
8 changes: 4 additions & 4 deletions src/cli/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function extractResolveOptions(pCruiseOptions) {

if (lWebPackConfigFileName) {
const { default: extractWebpackResolveConfig } = await import(
"../config-utl/extract-webpack-resolve-config.mjs"
"#config-utl/extract-webpack-resolve-config.mjs"
);
lResolveOptions = await extractWebpackResolveConfig(
lWebPackConfigFileName,
Expand All @@ -34,7 +34,7 @@ async function extractResolveOptions(pCruiseOptions) {
async function addKnownViolations(pCruiseOptions) {
if (pCruiseOptions.knownViolationsFile) {
const { default: extractKnownViolations } = await import(
"../config-utl/extract-known-violations.mjs"
"#config-utl/extract-known-violations.mjs"
);
const lKnownViolations = await extractKnownViolations(
pCruiseOptions.knownViolationsFile,
Expand All @@ -56,7 +56,7 @@ async function extractTSConfigOptions(pCruiseOptions) {

if (lTSConfigFileName) {
const { default: extractTSConfig } = await import(
"../config-utl/extract-ts-config.mjs"
"#config-utl/extract-ts-config.mjs"
);
lReturnValue = extractTSConfig(lTSConfigFileName);
}
Expand All @@ -70,7 +70,7 @@ async function extractBabelConfigOptions(pCruiseOptions) {
pCruiseOptions?.ruleSet?.options?.babelConfig?.fileName ?? null;
if (lBabelConfigFileName) {
const { default: extractBabelConfig } = await import(
"../config-utl/extract-babel-config.mjs"
"#config-utl/extract-babel-config.mjs"
);
lReturnValue = extractBabelConfig(lBabelConfigFileName);
}
Expand Down
2 changes: 1 addition & 1 deletion src/cli/normalize-cli-options.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { isAbsolute } from "node:path";
import set from "lodash/set.js";
import get from "lodash/get.js";
import has from "lodash/has.js";
import loadConfig from "../config-utl/extract-depcruise-config/index.mjs";
import {
RULES_FILE_NAME_SEARCH_ARRAY,
DEFAULT_BASELINE_FILE_NAME,
Expand All @@ -14,6 +13,7 @@ import {
BABEL_CONFIG,
OLD_DEFAULT_RULES_FILE_NAME,
} from "./defaults.mjs";
import loadConfig from "#config-utl/extract-depcruise-config/index.mjs";

function getOptionValue(pDefault) {
return (pValue) => (typeof pValue === "string" ? pValue : pDefault);
Expand Down
2 changes: 1 addition & 1 deletion test/config-utl/extract-babel-config.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { deepEqual, ok, equal } from "node:assert/strict";
import { fileURLToPath } from "node:url";
import omit from "lodash/omit.js";
import extractBabelConfig from "../../src/config-utl/extract-babel-config.mjs";
import extractBabelConfig from "#config-utl/extract-babel-config.mjs";
import pathToPosix from "#utl/path-to-posix.mjs";

function getFullPath(pRelativePath) {
Expand Down
2 changes: 1 addition & 1 deletion test/config-utl/extract-depcruise-config/index.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fileURLToPath } from "node:url";
import { join } from "node:path";
import { ok, deepEqual } from "node:assert/strict";
import loadConfig from "../../../src/config-utl/extract-depcruise-config/index.mjs";
import loadConfig from "#config-utl/extract-depcruise-config/index.mjs";

const __dirname = fileURLToPath(new URL(".", import.meta.url));
const mockDirectory = join(__dirname, "__mocks__");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { deepEqual } from "node:assert/strict";
import merge from "../../../src/config-utl/extract-depcruise-config/merge-configs.mjs";
import merge from "#config-utl/extract-depcruise-config/merge-configs.mjs";

describe("[U] config-utl/mergeRuleSets - general", () => {
it("two empty rule sets yield an empty rule set with named attributes", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fileURLToPath } from "node:url";
import { deepEqual } from "node:assert/strict";
import readConfig from "../../../src/config-utl/extract-depcruise-config/read-config.mjs";
import readConfig from "#config-utl/extract-depcruise-config/read-config.mjs";

function getFullPath(pRelativePath) {
return fileURLToPath(new URL(pRelativePath, import.meta.url));
Expand Down
2 changes: 1 addition & 1 deletion test/config-utl/extract-known-violations.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { deepEqual, ok } from "node:assert/strict";
import extractKnownViolations from "../../src/config-utl/extract-known-violations.mjs";
import extractKnownViolations from "#config-utl/extract-known-violations.mjs";

describe("[I] config-utl/extractKnownViolations", () => {
const WORKINGDIR = process.cwd();
Expand Down
2 changes: 1 addition & 1 deletion test/config-utl/extract-ts-config.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fileURLToPath } from "node:url";
import { deepEqual, throws } from "node:assert/strict";
import loadTSConfig from "../../src/config-utl/extract-ts-config.mjs";
import loadTSConfig from "#config-utl/extract-ts-config.mjs";
import pathToPosix from "#utl/path-to-posix.mjs";

function getFullPath(pRelativePath) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fileURLToPath } from "node:url";
import { deepEqual, equal } from "node:assert/strict";

import loadResolveConfig from "../../src/config-utl/extract-webpack-resolve-config.mjs";
import loadResolveConfig from "#config-utl/extract-webpack-resolve-config.mjs";

function getFullPath(pRelativePath) {
return fileURLToPath(new URL(pRelativePath, import.meta.url));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { deepEqual, match, equal } from "node:assert/strict";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import loadResolveConfig from "../../src/config-utl/extract-webpack-resolve-config.mjs";
import loadResolveConfig from "#config-utl/extract-webpack-resolve-config.mjs";

const __dirname = fileURLToPath(new URL(".", import.meta.url));

Expand Down
2 changes: 1 addition & 1 deletion test/config-utl/make-absolute.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { join } from "node:path";
import { equal } from "node:assert/strict";
import makeAbsolute from "../../src/config-utl/make-absolute.mjs";
import makeAbsolute from "#config-utl/make-absolute.mjs";

describe("[U] cli/utl/makeAbsolute", () => {
it("leaves absolute path names alone", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/extract/resolve/index.tsconfig.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import { deepEqual } from "node:assert/strict";
import extractTSConfig from "../../../src/config-utl/extract-ts-config.mjs";
import extractTSConfig from "#config-utl/extract-ts-config.mjs";
import normalizeResolveOptions from "#main/resolve-options/normalize.mjs";
import resolve from "#extract/resolve/index.mjs";

Expand Down

0 comments on commit ef970df

Please sign in to comment.