Skip to content

Commit

Permalink
fix(enrich): adds used tsconfig to options used + adds it & babelConf…
Browse files Browse the repository at this point in the history
…ig, webpackConfig to IConfiguration type (#805)
  • Loading branch information
sverweij authored May 6, 2023
1 parent 8bac684 commit 4556fe3
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/enrich/summarize/summarize-options.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ const SHAREABLE_OPTIONS = [
"reaches",
"reporterOptions",
"rulesFile",
"tsConfig",
"tsPreCompilationDeps",
"webpackConfig",
// "progress", TODO: could be enabled
// "tsConfig", TODO: should be enabled
];

function makeOptionsPresentable(pOptions) {
Expand Down
3 changes: 3 additions & 0 deletions test/cli/__fixtures__/dynamic-import-nok.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
"outputTo": "test/cli/__output__/dynamic-import-nok.json",
"outputType": "json",
"preserveSymlinks": false,
"tsConfig": {
"fileName": "test/cli/__fixtures__/typescriptconfig/cli-dynamic-imports/tsconfig.error_on_compile_dynamic_imports.json"
},
"tsPreCompilationDeps": false,
"exoticRequireStrings": [],
"args": "test/cli/__fixtures__/typescriptconfig/cli-dynamic-imports/import_dynamically2.ts"
Expand Down
3 changes: 3 additions & 0 deletions test/cli/__fixtures__/dynamic-import-ok.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
"outputTo": "test/cli/__output__/dynamic-import-ok.json",
"outputType": "json",
"preserveSymlinks": false,
"tsConfig": {
"fileName": "test/cli/__fixtures__/typescriptconfig/cli-dynamic-imports/tsconfig.compile_dynamic_imports.json"
},
"tsPreCompilationDeps": false,
"exoticRequireStrings": [],
"args": "test/cli/__fixtures__/typescriptconfig/cli-dynamic-imports/import_dynamically.ts"
Expand Down
3 changes: 3 additions & 0 deletions test/cli/__fixtures__/typescript-path-resolution.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
"outputType": "json",
"preserveSymlinks": false,
"tsPreCompilationDeps": false,
"tsConfig": {
"fileName": "test/cli/__fixtures__/typescriptconfig/cli-config-with-path/tsconfig.json"
},
"webpackConfig": {
"fileName": "test/cli/__fixtures__/typescriptconfig/cli-config-with-path/webpack.config.js"
},
Expand Down
3 changes: 3 additions & 0 deletions test/main/__fixtures__/ts-no-precomp-cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
"metrics": false,
"moduleSystems": ["es6", "cjs", "tsd", "amd"],
"preserveSymlinks": false,
"tsConfig": {
"fileName": "test/main/__mocks__/tsconfig.targetcjs.json"
},
"tsPreCompilationDeps": false,
"args": "test/main/__mocks__/ts-precompilation-deps-off-cjs",
"baseDir": ""
Expand Down
3 changes: 3 additions & 0 deletions test/main/__fixtures__/ts-no-precomp-es.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
"metrics": false,
"moduleSystems": ["es6", "cjs", "tsd", "amd"],
"preserveSymlinks": false,
"tsConfig": {
"fileName": "test/main/__mocks__/tsconfig.targetes.json"
},
"tsPreCompilationDeps": false,
"args": "test/main/__mocks__/ts-precompilation-deps-off-es",
"baseDir": ""
Expand Down
3 changes: 3 additions & 0 deletions test/main/__fixtures__/ts-precomp-cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@
"metrics": false,
"moduleSystems": ["es6", "cjs", "tsd", "amd"],
"preserveSymlinks": false,
"tsConfig": {
"fileName": "test/main/__mocks__/tsconfig.targetcjs.json"
},
"tsPreCompilationDeps": true,
"args": "test/main/__mocks__/ts-precompilation-deps-on-cjs"
}
Expand Down
3 changes: 3 additions & 0 deletions test/main/__fixtures__/ts-precomp-es.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@
"metrics": false,
"moduleSystems": ["es6", "cjs", "tsd", "amd"],
"preserveSymlinks": false,
"tsConfig": {
"fileName": "test/main/__mocks__/tsconfig.targetes.json"
},
"tsPreCompilationDeps": true,
"args": "test/main/__mocks__/ts-precompilation-deps-on-es"
}
Expand Down
43 changes: 0 additions & 43 deletions types/cruise-result.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,51 +358,8 @@ export interface IOptions extends ICruiseOptions {
* The rules file used to validate the dependencies (if any)
*/
rulesFile?: string;
/**
* The TypeScript configuration file used (if any)
*/
tsConfig?: ITsConfig;
/**
* The webpack configuration options used for the cruise
*/
webpackConfig?: IWebpackConfig;
/**
* The Babel configuration file used (if any)
*/
babelConfig?: IBabelConfig;
}

export interface ITsConfig {
fileName?: string;
}

export interface IBabelConfig {
fileName?: string;
}

/**
* The webpack configuration options used for the cruise
*/
export interface IWebpackConfig {
/**
* The arguments used
*/
arguments?: { [key: string]: any };
/**
* The 'env' parameters passed
*/
env?: WebpackEnvType;
/**
* The name of the webpack configuration file used
*/
fileName?: string;
}

/**
* The 'env' parameters passed
*/
export type WebpackEnvType = { [key: string]: any } | string;

export interface IFolderDependency {
/**
* the (resolved) name of the dependency
Expand Down
57 changes: 56 additions & 1 deletion types/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,37 @@ export type ProgressType =
| "ndjson"
| "none";

export interface ITsConfig {
fileName?: string;
}

export interface IBabelConfig {
fileName?: string;
}

/**
* The 'env' parameters passed to webpack, if any
*/
export type WebpackEnvType = { [key: string]: any } | string;

/**
* The webpack configuration options used for the cruise
*/
export interface IWebpackConfig {
/**
* The arguments used
*/
arguments?: { [key: string]: any };
/**
* The 'env' parameters passed
*/
env?: WebpackEnvType;
/**
* The name of the webpack configuration file used
*/
fileName?: string;
}

export interface ICruiseOptions {
/**
* if true, will attempt to validate with the rules in ruleSet.
Expand Down Expand Up @@ -175,7 +206,7 @@ export interface ICruiseOptions {
/*
* List of strings you have in use in addition to cjs/ es6 requires
* & imports to declare module dependencies. Use this e.g. if you've
* redeclared require (`const want = require`), use a require-wrapper
* re-declared require (`const want = require`), use a require-wrapper
* (like semver-try-require) or use window.require as a hack
*
* Defaults to `[]`
Expand All @@ -186,6 +217,30 @@ export interface ICruiseOptions {
*/
reporterOptions?: IReporterOptions;

/**
* TypeScript project file ('tsconfig.json') to use for (1) compilation
* and (2) resolution (e.g. with the paths property)",
*/
tsConfig?: ITsConfig;

/**
* Webpack configuration to use to get resolve options from
*/
webpackConfig?: IWebpackConfig;

/**
* Babel configuration (e.g. '.babelrc.json') to use.
*/
babelConfig?: IBabelConfig;

/**
* Overrides the parser dependency-cruiser will use - EXPERIMENTAL
*
* Note that you'll _very_ likely not need this - dependency-cruiser will
* typically sort out what the best parser for the job is out of the ones
* available
*/
parser?: "acorn" | "tsc" | "swc";
/**
* Options used in module resolution that for dependency-cruiser's
* use cannot go in a webpack config.
Expand Down

0 comments on commit 4556fe3

Please sign in to comment.