@tsparticles/cli 3.0.18 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dependency-cruiser.cjs +382 -0
- package/dist/build/build-bundle.js +1 -1
- package/dist/build/build-circular-deps.d.ts +2 -2
- package/dist/build/build-circular-deps.js +61 -21
- package/dist/build/build-clear.js +1 -1
- package/dist/build/build-distfiles.js +1 -1
- package/dist/build/build-prettier.js +1 -1
- package/dist/build/build-tsc.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/create/plugin/create-plugin.js +1 -1
- package/dist/create/plugin/plugin.js +1 -1
- package/dist/create/preset/create-preset.js +1 -1
- package/dist/create/preset/preset.js +1 -1
- package/dist/create/shape/create-shape.js +1 -1
- package/dist/create/shape/shape.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/file-utils.js +2 -2
- package/dist/utils/template-utils.js +2 -2
- package/files/empty-project/package.json +5 -7
- package/package.json +9 -12
- package/pnpm-workspace.yaml +1 -0
- package/src/build/build-bundle.ts +1 -1
- package/src/build/build-circular-deps.ts +92 -24
- package/src/build/build-clear.ts +1 -1
- package/src/build/build-distfiles.ts +1 -1
- package/src/build/build-prettier.ts +1 -1
- package/src/build/build-tsc.ts +1 -1
- package/src/cli.ts +1 -1
- package/src/create/plugin/create-plugin.ts +1 -1
- package/src/create/plugin/plugin.ts +1 -1
- package/src/create/preset/create-preset.ts +1 -1
- package/src/create/preset/preset.ts +1 -1
- package/src/create/shape/create-shape.ts +1 -1
- package/src/create/shape/shape.ts +1 -1
- package/src/utils/file-utils.ts +2 -2
- package/src/utils/template-utils.ts +2 -2
- package/tests/create-plugin.test.ts +1 -1
- package/tests/create-preset.test.ts +1 -1
- package/tests/create-shape.test.ts +1 -1
- package/tests/file-utils.test.ts +1 -1
- package/tsconfig.json +0 -1
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
/** @type {import('dependency-cruiser').IConfiguration} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
forbidden: [
|
|
4
|
+
{
|
|
5
|
+
name: 'no-circular',
|
|
6
|
+
severity: 'warn',
|
|
7
|
+
comment:
|
|
8
|
+
"This dependency is part of a circular relationship. You might want to revise " +
|
|
9
|
+
"your solution (i.e. use dependency inversion, make sure the modules have a single responsibility) ",
|
|
10
|
+
from: {},
|
|
11
|
+
to: {
|
|
12
|
+
circular: true
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: 'no-orphans',
|
|
17
|
+
comment:
|
|
18
|
+
"This is an orphan module - it's likely not used (anymore?). Either use it or " +
|
|
19
|
+
"remove it. If it's logical this module is an orphan (i.e. it's a config file), " +
|
|
20
|
+
"add an exception for it in your dependency-cruiser configuration. By default " +
|
|
21
|
+
"this rule does not scrutinize dot-files (e.g. .eslintrc.js), TypeScript declaration " +
|
|
22
|
+
"files (.d.ts), tsconfig.json and some of the babel and webpack configs.",
|
|
23
|
+
severity: 'warn',
|
|
24
|
+
from: {
|
|
25
|
+
orphan: true,
|
|
26
|
+
pathNot: [
|
|
27
|
+
'(^|/)[.][^/]+[.](?:js|cjs|mjs|ts|cts|mts|json)$', // dot files
|
|
28
|
+
'[.]d[.]ts$', // TypeScript declaration files
|
|
29
|
+
'(^|/)tsconfig[.]json$', // TypeScript config
|
|
30
|
+
'(^|/)(?:babel|webpack)[.]config[.](?:js|cjs|mjs|ts|cts|mts|json)$' // other configs
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
to: {},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'no-deprecated-core',
|
|
37
|
+
comment:
|
|
38
|
+
'A module depends on a node core module that has been deprecated. Find an alternative - these are ' +
|
|
39
|
+
"bound to exist - node doesn't deprecate lightly.",
|
|
40
|
+
severity: 'warn',
|
|
41
|
+
from: {},
|
|
42
|
+
to: {
|
|
43
|
+
dependencyTypes: [
|
|
44
|
+
'core'
|
|
45
|
+
],
|
|
46
|
+
path: [
|
|
47
|
+
'^v8/tools/codemap$',
|
|
48
|
+
'^v8/tools/consarray$',
|
|
49
|
+
'^v8/tools/csvparser$',
|
|
50
|
+
'^v8/tools/logreader$',
|
|
51
|
+
'^v8/tools/profile_view$',
|
|
52
|
+
'^v8/tools/profile$',
|
|
53
|
+
'^v8/tools/SourceMap$',
|
|
54
|
+
'^v8/tools/splaytree$',
|
|
55
|
+
'^v8/tools/tickprocessor-driver$',
|
|
56
|
+
'^v8/tools/tickprocessor$',
|
|
57
|
+
'^node-inspect/lib/_inspect$',
|
|
58
|
+
'^node-inspect/lib/internal/inspect_client$',
|
|
59
|
+
'^node-inspect/lib/internal/inspect_repl$',
|
|
60
|
+
'^async_hooks$',
|
|
61
|
+
'^punycode$',
|
|
62
|
+
'^domain$',
|
|
63
|
+
'^constants$',
|
|
64
|
+
'^sys$',
|
|
65
|
+
'^_linklist$',
|
|
66
|
+
'^_stream_wrap$'
|
|
67
|
+
],
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'not-to-deprecated',
|
|
72
|
+
comment:
|
|
73
|
+
'This module uses a (version of an) npm module that has been deprecated. Either upgrade to a later ' +
|
|
74
|
+
'version of that module, or find an alternative. Deprecated modules are a security risk.',
|
|
75
|
+
severity: 'warn',
|
|
76
|
+
from: {},
|
|
77
|
+
to: {
|
|
78
|
+
dependencyTypes: [
|
|
79
|
+
'deprecated'
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'no-non-package-json',
|
|
85
|
+
severity: 'error',
|
|
86
|
+
comment:
|
|
87
|
+
"This module depends on an npm package that isn't in the 'dependencies' section of your package.json. " +
|
|
88
|
+
"That's problematic as the package either (1) won't be available on live (2 - worse) will be " +
|
|
89
|
+
"available on live with an non-guaranteed version. Fix it by adding the package to the dependencies " +
|
|
90
|
+
"in your package.json.",
|
|
91
|
+
from: {},
|
|
92
|
+
to: {
|
|
93
|
+
dependencyTypes: [
|
|
94
|
+
'npm-no-pkg',
|
|
95
|
+
'npm-unknown'
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'not-to-unresolvable',
|
|
101
|
+
comment:
|
|
102
|
+
"This module depends on a module that cannot be found ('resolved to disk'). If it's an npm " +
|
|
103
|
+
'module: add it to your package.json. In all other cases you likely already know what to do.',
|
|
104
|
+
severity: 'error',
|
|
105
|
+
from: {},
|
|
106
|
+
to: {
|
|
107
|
+
couldNotResolve: true
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: 'no-duplicate-dep-types',
|
|
112
|
+
comment:
|
|
113
|
+
"Likely this module depends on an external ('npm') package that occurs more than once " +
|
|
114
|
+
"in your package.json i.e. bot as a devDependencies and in dependencies. This will cause " +
|
|
115
|
+
"maintenance problems later on.",
|
|
116
|
+
severity: 'warn',
|
|
117
|
+
from: {},
|
|
118
|
+
to: {
|
|
119
|
+
moreThanOneDependencyType: true,
|
|
120
|
+
// as it's common to use a devDependency for type-only imports: don't
|
|
121
|
+
// consider type-only dependencyTypes for this rule
|
|
122
|
+
dependencyTypesNot: ["type-only"]
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
// rules you might want to tweak for your specific situation:
|
|
127
|
+
{
|
|
128
|
+
name: 'not-to-test',
|
|
129
|
+
comment:
|
|
130
|
+
"This module depends on code within a folder that should only contain tests. As tests don't " +
|
|
131
|
+
"implement functionality this is odd. Either you're writing a test outside the test folder " +
|
|
132
|
+
"or there's something in the test folder that isn't a test.",
|
|
133
|
+
severity: 'error',
|
|
134
|
+
from: {
|
|
135
|
+
pathNot: '^(tests)'
|
|
136
|
+
},
|
|
137
|
+
to: {
|
|
138
|
+
path: '^(tests)'
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: 'not-to-spec',
|
|
143
|
+
comment:
|
|
144
|
+
'This module depends on a spec (test) file. The responsibility of a spec file is to test code. ' +
|
|
145
|
+
"If there's something in a spec that's of use to other modules, it doesn't have that single " +
|
|
146
|
+
'responsibility anymore. Factor it out into (e.g.) a separate utility/ helper or a mock.',
|
|
147
|
+
severity: 'error',
|
|
148
|
+
from: {},
|
|
149
|
+
to: {
|
|
150
|
+
path: '[.](?:spec|test)[.](?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$'
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: 'not-to-dev-dep',
|
|
155
|
+
severity: 'error',
|
|
156
|
+
comment:
|
|
157
|
+
"This module depends on an npm package from the 'devDependencies' section of your " +
|
|
158
|
+
'package.json. It looks like something that ships to production, though. To prevent problems ' +
|
|
159
|
+
"with npm packages that aren't there on production declare it (only!) in the 'dependencies'" +
|
|
160
|
+
'section of your package.json. If this module is development only - add it to the ' +
|
|
161
|
+
'from.pathNot re of the not-to-dev-dep rule in the dependency-cruiser configuration',
|
|
162
|
+
from: {
|
|
163
|
+
path: '^(src)',
|
|
164
|
+
pathNot: '[.](?:spec|test)[.](?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$'
|
|
165
|
+
},
|
|
166
|
+
to: {
|
|
167
|
+
dependencyTypes: [
|
|
168
|
+
'npm-dev',
|
|
169
|
+
],
|
|
170
|
+
// type only dependencies are not a problem as they don't end up in the
|
|
171
|
+
// production code or are ignored by the runtime.
|
|
172
|
+
dependencyTypesNot: [
|
|
173
|
+
'type-only'
|
|
174
|
+
],
|
|
175
|
+
pathNot: [
|
|
176
|
+
'node_modules/@types/'
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: 'optional-deps-used',
|
|
182
|
+
severity: 'info',
|
|
183
|
+
comment:
|
|
184
|
+
"This module depends on an npm package that is declared as an optional dependency " +
|
|
185
|
+
"in your package.json. As this makes sense in limited situations only, it's flagged here. " +
|
|
186
|
+
"If you use an optional dependency here by design - add an exception to your" +
|
|
187
|
+
"dependency-cruiser configuration.",
|
|
188
|
+
from: {},
|
|
189
|
+
to: {
|
|
190
|
+
dependencyTypes: [
|
|
191
|
+
'npm-optional'
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: 'peer-deps-used',
|
|
197
|
+
comment:
|
|
198
|
+
"This module depends on an npm package that is declared as a peer dependency " +
|
|
199
|
+
"in your package.json. This makes sense if your package is e.g. a plugin, but in " +
|
|
200
|
+
"other cases - maybe not so much. If the use of a peer dependency is intentional " +
|
|
201
|
+
"add an exception to your dependency-cruiser configuration.",
|
|
202
|
+
severity: 'warn',
|
|
203
|
+
from: {},
|
|
204
|
+
to: {
|
|
205
|
+
dependencyTypes: [
|
|
206
|
+
'npm-peer'
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
],
|
|
211
|
+
options: {
|
|
212
|
+
// Which modules not to follow further when encountered
|
|
213
|
+
doNotFollow: {
|
|
214
|
+
// path: an array of regular expressions in strings to match against
|
|
215
|
+
path: ['node_modules']
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
// Which modules to exclude
|
|
219
|
+
// exclude : {
|
|
220
|
+
// // path: an array of regular expressions in strings to match against
|
|
221
|
+
// path: '',
|
|
222
|
+
// },
|
|
223
|
+
|
|
224
|
+
// Which modules to exclusively include (array of regular expressions in strings)
|
|
225
|
+
// dependency-cruiser will skip everything that doesn't match this pattern
|
|
226
|
+
// includeOnly : [''],
|
|
227
|
+
|
|
228
|
+
// List of module systems to cruise.
|
|
229
|
+
// When left out dependency-cruiser will fall back to the list of _all_
|
|
230
|
+
// module systems it knows of ('amd', 'cjs', 'es6', 'tsd']). It's the
|
|
231
|
+
// default because it's the safe option. It comes at a performance penalty, though
|
|
232
|
+
// As in practice only commonjs ('cjs') and ecmascript modules ('es6')
|
|
233
|
+
// are in wide use, you can limit the moduleSystems to those.
|
|
234
|
+
// moduleSystems: ['cjs', 'es6'],
|
|
235
|
+
|
|
236
|
+
// false: don't look at JSDoc imports (the default)
|
|
237
|
+
// true: detect dependencies in JSDoc-style import statements.
|
|
238
|
+
// Implies parser: 'tsc', which a.o. means the typescript compiler will need
|
|
239
|
+
// to be installed in the same spot you run dependency-cruiser from.
|
|
240
|
+
// detectJSDocImports: true,
|
|
241
|
+
|
|
242
|
+
// false: don't look at process.getBuiltinModule calls (the default)
|
|
243
|
+
// true: dependency-cruiser will detect calls to process.getBuiltinModule/
|
|
244
|
+
// globalThis.process.getBuiltinModule as imports.
|
|
245
|
+
// detectProcessBuiltinModuleCalls: true,
|
|
246
|
+
|
|
247
|
+
// prefix for links in html, d2, mermaid and dot/ svg output (e.g. 'https://github.com/you/yourrepo/blob/main/'
|
|
248
|
+
// to open it on your online repo or `vscode://file/${process.cwd()}/` to
|
|
249
|
+
// open it in visual studio code),
|
|
250
|
+
// prefix: `vscode://file/${process.cwd()}/`,
|
|
251
|
+
|
|
252
|
+
// suffix for links in output. E.g. put .html here if you use it to link to
|
|
253
|
+
// your coverage reports.
|
|
254
|
+
// suffix: '.html',
|
|
255
|
+
|
|
256
|
+
// false (the default): ignore dependencies that only exist before typescript-to-javascript compilation
|
|
257
|
+
// true: also detect dependencies that only exist before typescript-to-javascript compilation
|
|
258
|
+
// 'specify': for each dependency identify whether it only exists before compilation or also after
|
|
259
|
+
// tsPreCompilationDeps: false,
|
|
260
|
+
|
|
261
|
+
// list of extensions to scan that aren't javascript or compile-to-javascript.
|
|
262
|
+
// Empty by default. Only put extensions in here that you want to take into
|
|
263
|
+
// account that are _not_ parsable.
|
|
264
|
+
// extraExtensionsToScan: ['.json', '.jpg', '.png', '.svg', '.webp'],
|
|
265
|
+
|
|
266
|
+
// if true combines the package.jsons found from the module up to the base
|
|
267
|
+
// folder the cruise is initiated from. Useful for how (some) mono-repos
|
|
268
|
+
// manage dependencies & dependency definitions.
|
|
269
|
+
// combinedDependencies: false,
|
|
270
|
+
|
|
271
|
+
// if true leave symlinks untouched, otherwise use the realpath
|
|
272
|
+
// preserveSymlinks: false,
|
|
273
|
+
|
|
274
|
+
// TypeScript project file ('tsconfig.json') to use for
|
|
275
|
+
// (1) compilation and
|
|
276
|
+
// (2) resolution (e.g. with the paths property)
|
|
277
|
+
//
|
|
278
|
+
// The (optional) fileName attribute specifies which file to take (relative to
|
|
279
|
+
// dependency-cruiser's current working directory). When not provided
|
|
280
|
+
// defaults to './tsconfig.json'.
|
|
281
|
+
tsConfig: {
|
|
282
|
+
fileName: 'src/tsconfig.json'
|
|
283
|
+
},
|
|
284
|
+
|
|
285
|
+
// Webpack configuration to use to get resolve options from.
|
|
286
|
+
//
|
|
287
|
+
// The (optional) fileName attribute specifies which file to take (relative
|
|
288
|
+
// to dependency-cruiser's current working directory. When not provided defaults
|
|
289
|
+
// to './webpack.conf.js'.
|
|
290
|
+
//
|
|
291
|
+
// The (optional) 'env' and 'arguments' attributes contain the parameters
|
|
292
|
+
// to be passed if your webpack config is a function and takes them (see
|
|
293
|
+
// webpack documentation for details)
|
|
294
|
+
// webpackConfig: {
|
|
295
|
+
// fileName: 'webpack.config.js',
|
|
296
|
+
// env: {},
|
|
297
|
+
// arguments: {}
|
|
298
|
+
// },
|
|
299
|
+
|
|
300
|
+
// Babel config ('.babelrc', '.babelrc.json', '.babelrc.json5', ...) to use
|
|
301
|
+
// for compilation
|
|
302
|
+
// babelConfig: {
|
|
303
|
+
// fileName: '.babelrc',
|
|
304
|
+
// },
|
|
305
|
+
|
|
306
|
+
// List of strings you have in use in addition to cjs/ es6 requires
|
|
307
|
+
// & imports to declare module dependencies. Use this e.g. if you've
|
|
308
|
+
// re-declared require, use a require-wrapper or use window.require as
|
|
309
|
+
// a hack.
|
|
310
|
+
// exoticRequireStrings: [],
|
|
311
|
+
|
|
312
|
+
// options to pass on to enhanced-resolve, the package dependency-cruiser
|
|
313
|
+
// uses to resolve module references to disk. The values below should be
|
|
314
|
+
// suitable for most situations
|
|
315
|
+
//
|
|
316
|
+
// If you use webpack: you can also set these in webpack.conf.js. The set
|
|
317
|
+
// there will override the ones specified here.
|
|
318
|
+
enhancedResolveOptions: {
|
|
319
|
+
// What to consider as an 'exports' field in package.jsons
|
|
320
|
+
exportsFields: ['exports'],
|
|
321
|
+
|
|
322
|
+
// List of conditions to check for in the exports field.
|
|
323
|
+
// Only works when the 'exportsFields' array is non-empty.
|
|
324
|
+
conditionNames: ['import', 'require', 'node', 'default', 'types'],
|
|
325
|
+
|
|
326
|
+
// The extensions, by default are the same as the ones dependency-cruiser
|
|
327
|
+
// can access (run `npx depcruise --info` to see which ones that are in
|
|
328
|
+
// _your_ environment). If that list is larger than you need you can pass
|
|
329
|
+
// the extensions you actually use (e.g. ['.js', '.jsx']). This can speed
|
|
330
|
+
// up module resolution, which is the most expensive step.
|
|
331
|
+
// extensions: [".js", ".jsx", ".ts", ".tsx", ".d.ts"],
|
|
332
|
+
|
|
333
|
+
// What to consider a 'main' field in package.json
|
|
334
|
+
mainFields: ["module", "main", "types", "typings"],
|
|
335
|
+
|
|
336
|
+
// A list of alias fields in package.jsons
|
|
337
|
+
// See https://github.com/defunctzombie/package-browser-field-spec and
|
|
338
|
+
// the webpack [resolve.alias](https://webpack.js.org/configuration/resolve/#resolvealiasfields)
|
|
339
|
+
// documentation.
|
|
340
|
+
// Defaults to an empty array (= don't use alias fields).
|
|
341
|
+
// aliasFields: ['browser'],
|
|
342
|
+
},
|
|
343
|
+
|
|
344
|
+
// skipAnalysisNotInRules will make dependency-cruiser execute
|
|
345
|
+
// analysis strictly necessary for checking the rule set only.
|
|
346
|
+
// See https://github.com/sverweij/dependency-cruiser/blob/main/doc/options-reference.md#skipanalysisnotinrules
|
|
347
|
+
skipAnalysisNotInRules: true,
|
|
348
|
+
|
|
349
|
+
reporterOptions: {
|
|
350
|
+
dot: {
|
|
351
|
+
// Pattern of modules to consolidate to. The default pattern in this configuration
|
|
352
|
+
// collapses everything in node_modules to one folder deep so you see
|
|
353
|
+
// the external modules, but not their innards.
|
|
354
|
+
collapsePattern: 'node_modules/(?:@[^/]+/[^/]+|[^/]+)',
|
|
355
|
+
|
|
356
|
+
// Options to tweak the appearance of your graph. See
|
|
357
|
+
// https://github.com/sverweij/dependency-cruiser/blob/main/doc/options-reference.md#reporteroptions
|
|
358
|
+
// If you don't specify a theme dependency-cruiser falls back to a built-in one.
|
|
359
|
+
// theme: {
|
|
360
|
+
// graph: {
|
|
361
|
+
// // splines: 'ortho' - straight lines; slow on big graphs
|
|
362
|
+
// // splines: 'true' - bezier curves; fast but not as nice as ortho
|
|
363
|
+
// splines: 'true'
|
|
364
|
+
// },
|
|
365
|
+
// },
|
|
366
|
+
},
|
|
367
|
+
archi: {
|
|
368
|
+
// Pattern of modules to consolidate to.
|
|
369
|
+
collapsePattern: '^(?:packages|src|lib(s?)|app(s?)|bin|test(s?)|spec(s?))/[^/]+|node_modules/(?:@[^/]+/[^/]+|[^/]+)',
|
|
370
|
+
|
|
371
|
+
// Options to tweak the appearance of your graph. If you don't specify a
|
|
372
|
+
// theme for 'archi' dependency-cruiser will use the one specified in the
|
|
373
|
+
// dot section above and otherwise use the default one.
|
|
374
|
+
// theme: { },
|
|
375
|
+
},
|
|
376
|
+
text: {
|
|
377
|
+
highlightFocused: true
|
|
378
|
+
},
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
// generated: dependency-cruiser@17.3.7 on 2026-01-28T14:30:16.611Z
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @param basePath -
|
|
2
|
+
* Checks for circular dependencies using dependency-cruiser
|
|
3
|
+
* @param basePath - The project root path
|
|
4
4
|
* @returns true if no circular dependencies are found, false otherwise
|
|
5
5
|
*/
|
|
6
6
|
export declare function buildCircularDeps(basePath: string): Promise<boolean>;
|
|
@@ -1,34 +1,74 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { cruise, } from "dependency-cruiser";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
const ZERO_VIOLATIONS = 0;
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param basePath -
|
|
6
|
+
* Checks for circular dependencies using dependency-cruiser
|
|
7
|
+
* @param basePath - The project root path
|
|
6
8
|
* @returns true if no circular dependencies are found, false otherwise
|
|
7
9
|
*/
|
|
8
10
|
export async function buildCircularDeps(basePath) {
|
|
9
|
-
|
|
11
|
+
const srcPath = path.join(basePath, "src"), configPath = path.join(basePath, ".dependency-cruiser.js"), configPathCjs = path.join(basePath, ".dependency-cruiser.cjs");
|
|
12
|
+
// Base options with explicit type
|
|
13
|
+
let cruiseOptions = {
|
|
14
|
+
tsPreCompilationDeps: false,
|
|
15
|
+
tsConfig: {
|
|
16
|
+
fileName: path.join(srcPath, "tsconfig.json"),
|
|
17
|
+
},
|
|
18
|
+
};
|
|
10
19
|
try {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
if (await fs.pathExists(configPath)) {
|
|
21
|
+
const configModule = (await import(configPath)), extendedConfig = configModule.default;
|
|
22
|
+
cruiseOptions = {
|
|
23
|
+
...cruiseOptions,
|
|
24
|
+
...extendedConfig.options,
|
|
25
|
+
ruleSet: {
|
|
26
|
+
forbidden: extendedConfig.forbidden ?? [],
|
|
16
27
|
},
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
else if (await fs.pathExists(configPathCjs)) {
|
|
31
|
+
const configModule = (await import(configPathCjs)), extendedConfig = configModule.default;
|
|
32
|
+
cruiseOptions = {
|
|
33
|
+
...cruiseOptions,
|
|
34
|
+
...extendedConfig.options,
|
|
35
|
+
ruleSet: {
|
|
36
|
+
forbidden: extendedConfig.forbidden ?? [],
|
|
37
|
+
},
|
|
38
|
+
};
|
|
24
39
|
}
|
|
25
40
|
else {
|
|
26
|
-
|
|
41
|
+
console.log("No .dependency-cruiser.js found, applying default circular check.");
|
|
42
|
+
cruiseOptions.ruleSet = {
|
|
43
|
+
forbidden: [
|
|
44
|
+
{
|
|
45
|
+
name: "no-circular",
|
|
46
|
+
severity: "error",
|
|
47
|
+
from: {},
|
|
48
|
+
to: { circular: true },
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|
|
27
52
|
}
|
|
53
|
+
const result = await cruise([srcPath], cruiseOptions), cruiseResult = result, violations = cruiseResult.summary.violations, circularViolations = violations.filter((violation) => violation.rule.name === "no-circular");
|
|
54
|
+
if (circularViolations.length > ZERO_VIOLATIONS) {
|
|
55
|
+
console.error("⚠️ Circular dependencies found!");
|
|
56
|
+
for (const violation of circularViolations) {
|
|
57
|
+
const cyclePath = (violation.cycle ?? []).map(step => {
|
|
58
|
+
return step.name;
|
|
59
|
+
});
|
|
60
|
+
console.error(`Cycle detected: ${cyclePath.join(" -> ")}`);
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
console.log("✅ No circular dependencies found.");
|
|
65
|
+
return true;
|
|
28
66
|
}
|
|
29
67
|
catch (e) {
|
|
30
|
-
console.error(e);
|
|
68
|
+
console.error("❌ Error while checking dependencies:", e);
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
console.log("Finished checking circular dependencies.");
|
|
31
73
|
}
|
|
32
|
-
console.log("Finished checking circular dependencies.");
|
|
33
|
-
return res;
|
|
34
74
|
}
|
package/dist/build/build-tsc.js
CHANGED
package/dist/cli.js
CHANGED
|
@@ -3,7 +3,7 @@ import { buildCommand } from "./build/build.js";
|
|
|
3
3
|
import { createCommand } from "./create/create.js";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
import fs from "fs-extra";
|
|
6
|
-
import path from "path";
|
|
6
|
+
import path from "node:path";
|
|
7
7
|
import { program } from "commander";
|
|
8
8
|
const __filename = fileURLToPath(import.meta.url), __dirname = path.dirname(__filename), rootPkgPath = path.join(__dirname, "..", "package.json"), pkg = (await fs.readJson(rootPkgPath));
|
|
9
9
|
program.name("tsparticles-cli");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { camelize, capitalize, dash } from "../../utils/string-utils.js";
|
|
2
2
|
import { copyEmptyTemplateFiles, copyFilter, runBuild, runInstall, updatePackageDistFile, updatePackageFile, updateWebpackFile, } from "../../utils/template-utils.js";
|
|
3
3
|
import fs from "fs-extra";
|
|
4
|
-
import path from "path";
|
|
4
|
+
import path from "node:path";
|
|
5
5
|
import { replaceTokensInFile } from "../../utils/file-utils.js";
|
|
6
6
|
/**
|
|
7
7
|
* Updates the index file with the correct function name
|
|
@@ -3,7 +3,7 @@ import prompts from "prompts";
|
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
import { capitalize } from "../../utils/string-utils.js";
|
|
5
5
|
import { createPluginTemplate } from "./create-plugin.js";
|
|
6
|
-
import path from "path";
|
|
6
|
+
import path from "node:path";
|
|
7
7
|
const pluginCommand = new Command("plugin");
|
|
8
8
|
pluginCommand.description("Create a new tsParticles plugin");
|
|
9
9
|
pluginCommand.argument("<destination>", "Destination folder");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { camelize, capitalize, dash } from "../../utils/string-utils.js";
|
|
2
2
|
import { copyEmptyTemplateFiles, copyFilter, runBuild, runInstall, updatePackageDistFile, updatePackageFile, updateWebpackFile, } from "../../utils/template-utils.js";
|
|
3
3
|
import fs from "fs-extra";
|
|
4
|
-
import path from "path";
|
|
4
|
+
import path from "node:path";
|
|
5
5
|
import { replaceTokensInFile } from "../../utils/file-utils.js";
|
|
6
6
|
/**
|
|
7
7
|
* Updates the bundle file with the correct function name
|
|
@@ -3,7 +3,7 @@ import prompts from "prompts";
|
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
import { capitalize } from "../../utils/string-utils.js";
|
|
5
5
|
import { createPresetTemplate } from "./create-preset.js";
|
|
6
|
-
import path from "path";
|
|
6
|
+
import path from "node:path";
|
|
7
7
|
const presetCommand = new Command("preset");
|
|
8
8
|
presetCommand.description("Create a new tsParticles preset");
|
|
9
9
|
presetCommand.argument("<destination>", "Destination folder");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { camelize, capitalize, dash } from "../../utils/string-utils.js";
|
|
2
2
|
import { copyEmptyTemplateFiles, copyFilter, runBuild, runInstall, updatePackageDistFile, updatePackageFile, updateWebpackFile, } from "../../utils/template-utils.js";
|
|
3
3
|
import fs from "fs-extra";
|
|
4
|
-
import path from "path";
|
|
4
|
+
import path from "node:path";
|
|
5
5
|
import { replaceTokensInFile } from "../../utils/file-utils.js";
|
|
6
6
|
/**
|
|
7
7
|
* Updates the index file with the correct function name
|
|
@@ -3,7 +3,7 @@ import prompts from "prompts";
|
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
import { capitalize } from "../../utils/string-utils.js";
|
|
5
5
|
import { createShapeTemplate } from "./create-shape.js";
|
|
6
|
-
import path from "path";
|
|
6
|
+
import path from "node:path";
|
|
7
7
|
const shapeCommand = new Command("shape");
|
|
8
8
|
shapeCommand.description("Create a new tsParticles shape");
|
|
9
9
|
shapeCommand.argument("<destination>", "Destination folder");
|