Skip to content

Commit

Permalink
more dog food
Browse files Browse the repository at this point in the history
  • Loading branch information
sverweij committed Nov 17, 2024
1 parent 5d1606e commit b787f94
Show file tree
Hide file tree
Showing 33 changed files with 303 additions and 175 deletions.
4 changes: 2 additions & 2 deletions .dependency-cruiser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ export default {
// },
/* Experimental: the parser to use
*/
parser: "tsc", // acorn, tsc
// detectJSDocImports: true, // implies parser: "tsc"
// parser: "tsc", // acorn, tsc
detectJSDocImports: true, // implies parser: "tsc"
experimentalStats: true,
metrics: true,
enhancedResolveOptions: {
Expand Down
7 changes: 4 additions & 3 deletions src/cache/content-strategy.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import {
} from "./helpers.mjs";

/**
* @import {IModule, IRevisionChange, IRevisionData, ICruiseResult } from "../../types/dependency-cruiser.mjs"
* @import { IModule, IRevisionChange, IRevisionData, ICruiseResult } from "../../types/dependency-cruiser.mjs"
* @import { IStrictCruiseOptions } from "../../types/strict-options.mjs"
* @import { changeType, getSHA } from "watskeburt"
*/

/**
Expand Down Expand Up @@ -53,10 +54,10 @@ export default class ContentStrategy {
* @param {IStrictCruiseOptions} pCruiseOptions
* @param {Object} pOptions
* @param {Set<string>} pOptions.extensions
* @param {Set<import("watskeburt").changeType>=} pOptions.interestingChangeTypes?
* @param {Set<changeType>=} pOptions.interestingChangeTypes?
* @param {string=} pOptions.baseDir
* @param {typeof findContentChanges=} pOptions.diffListFn
* @param {typeof import('watskeburt').getSHA=} pOptions.checksumFn
* @param {typeof getSHA=} pOptions.checksumFn
* @returns {IRevisionData}
*/
getRevisionData(pDirectory, pCachedCruiseResult, pCruiseOptions, pOptions) {
Expand Down
16 changes: 11 additions & 5 deletions src/cache/find-content-changes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ import {
import { bus } from "#utl/bus.mjs";
import findAllFiles from "#utl/find-all-files.mjs";

/**
* @import { IModule, IRevisionChange } from "../../types/dependency-cruiser.mjs"
* @import { ICruiseResult } from "../../types/cruise-result.mjs"
* @import { IStrictExcludeType, IStrictIncludeOnlyType } from "../../types/strict-filter-types.mjs"
*/

/**
* @param {Set<string>} pFileSet
* @param {typeof getFileHashSync} pFileHashFunction
* @returns {(pModule:import("../..").IModule) => import('../..').IRevisionChange}
* @returns {(pModule:IModule) => IRevisionChange}
*/
function diffCachedModuleAgainstFileSet(
pFileSet,
Expand Down Expand Up @@ -63,13 +69,13 @@ function diffCachedModuleAgainstFileSet(
- there is a cache, but it doesn't contain checksums => same as before, except
all files will be marked as 'modified'
* @param {string} pDirectory
* @param {import("../..").ICruiseResult} pCachedCruiseResult
* @param {ICruiseResult} pCachedCruiseResult
* @param {Object} pOptions
* @param {Set<string>} pOptions.extensions
* @param {string} pOptions.baseDir
* @param {import("../../types/strict-filter-types.mjs").IStrictExcludeType} pOptions.exclude
* @param {import("../../types/strict-filter-types.mjs").IStrictIncludeOnlyType=} pOptions.includeOnly
* @returns {import("../..").IRevisionChange[]}
* @param {IStrictExcludeType} pOptions.exclude
* @param {IStrictIncludeOnlyType=} pOptions.includeOnly
* @returns {IRevisionChange[]}
*/
export default function findContentChanges(
pDirectory,
Expand Down
9 changes: 5 additions & 4 deletions src/cache/helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { filenameMatchesPattern } from "#graph-utl/match-facade.mjs";
* @import { IModule, IRevisionChange, } from "../../types/dependency-cruiser.mjs"
* @import { IExcludeType } from "../../types/filter-types.mjs"
* @import { IStrictIncludeOnlyType } from "../../types/strict-filter-types.mjs"
* @import { changeType, IChange } from "watskeburt"
*/

/**
Expand All @@ -34,7 +35,7 @@ function _getFileHashSync(pFileName) {
export const getFileHashSync = memoize(_getFileHashSync);

/**
* @param {import("watskeburt").IChange} pChange
* @param {IChange} pChange
* @return {IRevisionChange}
*/
export function addCheckSumToChangeSync(pChange) {
Expand Down Expand Up @@ -79,7 +80,7 @@ export function hasInterestingExtension(pExtensions) {

/**
* @param {Set<string>} pExtensions
* @returns {(pChange: import("watskeburt").IChange) => boolean}
* @returns {(pChange: IChange) => boolean}
*/
export function changeHasInterestingExtension(pExtensions) {
return (pChange) => {
Expand All @@ -105,8 +106,8 @@ const DEFAULT_INTERESTING_CHANGE_TYPES = new Set([
]);

/**
* @param {Set<import("watskeburt").changeType>=} pInterestingChangeTypes
* @returns {(pChange: import("watskeburt").IChange) => boolean}
* @param {Set<changeType>=} pInterestingChangeTypes
* @returns {(pChange: IChange) => boolean}
*/
export function isInterestingChangeType(pInterestingChangeTypes) {
return (pChange) =>
Expand Down
7 changes: 4 additions & 3 deletions src/cache/metadata-strategy.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ import { bus } from "#utl/bus.mjs";
/**
* @import {IModule, IRevisionChange, IRevisionData, ICruiseResult } from "../../types/dependency-cruiser.mjs"
* @import { IStrictCruiseOptions } from "../../types/strict-options.mjs"
* @import { changeType, IChange } from "watskeburt"
*/

export default class MetaDataStrategy {
/**
* @param {string} _pDirectory
* @param {import("../../types/cruise-result.mjs").ICruiseResult} _pCachedCruiseResult
* @param {ICruiseResult} _pCachedCruiseResult
* @param {Object} pOptions
* @param {Set<string>} pOptions.extensions
* @param {Set<import("watskeburt").changeType>=} pOptions.interestingChangeTypes
* @param {Set<changeType>=} pOptions.interestingChangeTypes
* @param {typeof getSHA=} pOptions.shaRetrievalFn
* @param {typeof list=} pOptions.diffListFn
* @param {typeof addCheckSumToChangeSync=} pOptions.checksumFn
Expand All @@ -44,7 +45,7 @@ export default class MetaDataStrategy {
bus.debug("cache: - getting sha");
const lSHA = await lOptions.shaRetrievalFn();
bus.debug("cache: - getting diff");
const lDiff = /** @type {import("watskeburt").IChange[]} */ (
const lDiff = /** @type {IChange[]} */ (
await lOptions.diffListFn({ oldRevision: lSHA })
);
const lChanges = lDiff
Expand Down
22 changes: 13 additions & 9 deletions src/cli/init-config/build-config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
import { folderNameArrayToRE } from "./utl.mjs";
import configTemplate from "./config-template.mjs";

/**
* @import { IInitConfig } from "./types.js";
*/

/**
* @param {string} pString
* @returns {string}
Expand All @@ -22,7 +26,7 @@ function extensionsToString(pExtensions) {
}

/**
* @param {import("./types.js").IInitConfig} pInitOptions
* @param {IInitConfig} pInitOptions
* @returns {string}
*/
function buildNotToTestRule(pInitOptions) {
Expand All @@ -49,7 +53,7 @@ function buildNotToTestRule(pInitOptions) {
}

/**
* @param {import("./types.js").IInitConfig} pInitOptions
* @param {IInitConfig} pInitOptions
* @returns {string}
*/
function buildTsPreCompilationDepsAttribute(pInitOptions) {
Expand All @@ -59,7 +63,7 @@ function buildTsPreCompilationDepsAttribute(pInitOptions) {
}

/**
* @param {import("./types.js").IInitConfig} pInitOptions
* @param {IInitConfig} pInitOptions
* @returns {string}
*/
function buildCombinedDependenciesAttribute(pInitOptions) {
Expand All @@ -69,7 +73,7 @@ function buildCombinedDependenciesAttribute(pInitOptions) {
}

/**
* @param {import("./types.js").IInitConfig} pInitOptions
* @param {IInitConfig} pInitOptions
* @returns {string}
*/
function buildTsOrJsConfigAttribute(pInitOptions) {
Expand All @@ -89,7 +93,7 @@ function buildTsOrJsConfigAttribute(pInitOptions) {
}

/**
* @param {import("./types.js").IInitConfig} pInitOptions
* @param {IInitConfig} pInitOptions
* @returns {string}
*/
function buildWebpackConfigAttribute(pInitOptions) {
Expand All @@ -107,7 +111,7 @@ function buildWebpackConfigAttribute(pInitOptions) {
}

/**
* @param {import("./types.js").IInitConfig} pInitOptions
* @param {IInitConfig} pInitOptions
* @returns {string}
*/
function buildBabelConfigAttribute(pInitOptions) {
Expand All @@ -121,7 +125,7 @@ function buildBabelConfigAttribute(pInitOptions) {
}

/**
* @param {import("./types.js").IInitConfig} pInitOptions
* @param {IInitConfig} pInitOptions
* @returns {string}
*/
function buildExtensionsAttribute(pInitOptions) {
Expand All @@ -131,7 +135,7 @@ function buildExtensionsAttribute(pInitOptions) {
}

/**
* @param {import("./types.js").IInitConfig} pInitOptions
* @param {IInitConfig} pInitOptions
* @returns {string}
*/
function buildMainFieldsAttribute(pInitOptions) {
Expand All @@ -149,7 +153,7 @@ function buildMainFieldsAttribute(pInitOptions) {
* Creates a .dependency-cruiser config with a set of basic validations
* to the current directory.
*
* @param {import("./types.js").IInitConfig} pInitOptions ('Normalized') options that influence the shape of
* @param {IInitConfig} pInitOptions ('Normalized') options that influence the shape of
* the configuration
* @returns {string} the configuration as a string
*/
Expand Down
16 changes: 10 additions & 6 deletions src/cli/init-config/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,21 @@ import {
} from "./environment-helpers.mjs";
import { writeRunScriptsToManifest } from "./write-run-scripts-to-manifest.mjs";

/**
* @import { IInitConfig, IPartialInitConfig, OneShotConfigIDType } from "./types.js";
*/

const PACKAGE_MANIFEST = `./${_PACKAGE_MANIFEST}`;

/**
* Create a initialization configuration based on guessed defaults
* (e.g. a tsconfig exists => use it and assume typescript is used)
*
* @param {import("./types").OneShotConfigIDType} pOneShotConfigId
* @return {import("./types").IPartialInitConfig} an initialization configuration
* @param {OneShotConfigIDType} pOneShotConfigId
* @return {IPartialInitConfig} an initialization configuration
*/
function getOneShotConfig(pOneShotConfigId) {
/** @type {import("./types").IPartialInitConfig} */
/** @type {IPartialInitConfig} */
const lBaseConfig = {
isMonoRepo: isLikelyMonoRepo(),
isTypeModule: isTypeModule(),
Expand All @@ -46,7 +50,7 @@ function getOneShotConfig(pOneShotConfigId) {
babelConfig: getBabelConfigCandidates().shift(),
specifyResolutionExtensions: true,
};
/** @type {Map<import("./types").OneShotConfigIDType, import("./types").IPartialInitConfig>} */
/** @type {Map<OneShotConfigIDType, IPartialInitConfig>} */
const lOneShotConfigs = new Map([
["yes", lBaseConfig],
[
Expand All @@ -63,7 +67,7 @@ function getOneShotConfig(pOneShotConfigId) {

/**
*
* @param {import("./types").IInitConfig} pNormalizedInitConfig
* @param {IInitConfig} pNormalizedInitConfig
*/
function manifestIsUpdatable(pNormalizedInitConfig) {
return (
Expand All @@ -73,7 +77,7 @@ function manifestIsUpdatable(pNormalizedInitConfig) {
}

/**
* @param {boolean|import("./types").OneShotConfigIDType} pInit
* @param {boolean|OneShotConfigIDType} pInit
* @param {string=} pConfigFileName
* @param {{stdout: NodeJS.WritableStream, stderr: NodeJS.WritableStream}=} pStreams
*/
Expand Down
16 changes: 10 additions & 6 deletions src/cli/init-config/normalize-init-options.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import findExtensions from "./find-extensions.mjs";
import meta from "#meta.cjs";

/**
* @param {import("./types.js").IInitConfig} pInitOptions
* @import { IInitConfig, IPartialInitConfig } from "./types.js";
*/

/**
* @param {IInitConfig} pInitOptions
* @param {string[]} pExtensions
* @returns {boolean}
*/
Expand All @@ -25,7 +29,7 @@ function usesTypeScript(pInitOptions, pExtensions) {
}

/**
* @param {import("./types.js").IInitConfig} pInitOptions
* @param {IInitConfig} pInitOptions
* @returns {string[]}
*/
function getExtensions(pInitOptions) {
Expand All @@ -38,8 +42,8 @@ function getExtensions(pInitOptions) {
}

/**
* @param {import("./types.js").IPartialInitConfig} pInitOptions
* @return {import("./types.js").IPartialInitConfig}
* @param {IPartialInitConfig} pInitOptions
* @return {IPartialInitConfig}
*/
function populate(pInitOptions) {
const lReturnValue = {
Expand All @@ -66,8 +70,8 @@ function populate(pInitOptions) {

/**
*
* @param {import("./types.js").IPartialInitConfig} pInitOptions
* @return {import("./types.js").IInitConfig}
* @param {IPartialInitConfig} pInitOptions
* @return {IInitConfig}
*/
export default function normalizeInitOptions(pInitOptions) {
let lReturnValue = populate(pInitOptions);
Expand Down
12 changes: 8 additions & 4 deletions src/config-utl/extract-depcruise-options.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import extractDepcruiseConfig from "./extract-depcruise-config/index.mjs";

/**
*
* @param {import('../../../types/configuration.mjs').IConfiguration}} pConfiguration
* @returns {import('../../../types/configuration.mjs').ICruiseOptions}
* @import { IConfiguration } from "../../types/configuration.mjs";
* @import { ICruiseOptions } from "../../types/options.mjs";
*/

/**
* @param {IConfiguration} pConfiguration
* @returns {ICruiseOptions}
*/
function configuration2options(pConfiguration) {
/* c8 ignore next 1 */
Expand All @@ -20,7 +24,7 @@ function configuration2options(pConfiguration) {
/**
*
* @param {string} pConfigFileName
* @returns {Promise<import('../../../types/configuration.mjs').ICruiseOptions>}
* @returns {Promise<ICruiseOptions>}
*/
export default async function extractDepcruiseOptions(pConfigFileName) {
const lReturnValue = await extractDepcruiseConfig(pConfigFileName);
Expand Down
4 changes: 2 additions & 2 deletions src/config-utl/extract-known-violations.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import json5 from "json5";
import makeAbsolute from "./make-absolute.mjs";

/**
* @typedef {import("../../types/violations.d.mjs").IViolation} IViolation
* @typedef {import("../../types/shared-types.d.mts").DependencyType} DependencyType
* @import { IViolation } from "../../types/violations.mjs"
* @import { DependencyType } from "../../types/shared-types.mjs"
*
* @typedef {IViolation & {cycle: Array<{name: string, dependencyTypes: Array<DependencyType>}>} | {cycle: Array<DependencyType>}} IMaybeOldFormatViolation
*/
Expand Down
Loading

0 comments on commit b787f94

Please sign in to comment.