adamantite 0.5.1 → 0.7.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/biome.jsonc +70 -61
- package/dist/index.js +1 -1
- package/package.json +2 -1
package/biome.jsonc
CHANGED
|
@@ -53,17 +53,16 @@
|
|
|
53
53
|
"enabled": true,
|
|
54
54
|
"rules": {
|
|
55
55
|
"a11y": {
|
|
56
|
-
//
|
|
56
|
+
// ----------------------- JavaScript ------------------------
|
|
57
57
|
"noAccessKey": "error",
|
|
58
|
-
// Enforce that the `aria-hidden` attribute is not used on any focusable element.
|
|
59
58
|
"noAriaHiddenOnFocusable": "error",
|
|
60
|
-
// Enforce that the `aria-unsupported-elements` attribute is not used on any HTML element.
|
|
61
59
|
"noAriaUnsupportedElements": "error",
|
|
62
|
-
|
|
60
|
+
"noAutofocus": "error",
|
|
63
61
|
"noDistractingElements": "error",
|
|
64
62
|
"noHeaderScope": "error",
|
|
65
63
|
"noInteractiveElementToNoninteractiveRole": "error",
|
|
66
64
|
"noLabelWithoutControl": "error",
|
|
65
|
+
"noNoninteractiveElementInteractions": "error",
|
|
67
66
|
"noNoninteractiveElementToInteractiveRole": "error",
|
|
68
67
|
"noNoninteractiveTabindex": "error",
|
|
69
68
|
"noPositiveTabindex": "error",
|
|
@@ -91,26 +90,52 @@
|
|
|
91
90
|
"useValidAriaValues": "error",
|
|
92
91
|
"useValidAutocomplete": "error",
|
|
93
92
|
"useValidLang": "error",
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
"
|
|
93
|
+
|
|
94
|
+
// --------------------------- CSS ---------------------------
|
|
95
|
+
"useGenericFontNames": "error"
|
|
97
96
|
},
|
|
98
97
|
"complexity": {
|
|
98
|
+
// ----------------------- JavaScript ------------------------
|
|
99
99
|
"noAdjacentSpacesInRegex": "error",
|
|
100
100
|
"noArguments": "error",
|
|
101
101
|
"noBannedTypes": "error",
|
|
102
102
|
"noCommaOperator": "error",
|
|
103
103
|
"noEmptyTypeParameters": "error",
|
|
104
|
+
"noExtraBooleanCast": "error",
|
|
104
105
|
"noExcessiveCognitiveComplexity": {
|
|
105
106
|
"level": "error",
|
|
106
107
|
"options": {
|
|
107
|
-
"maxAllowedComplexity":
|
|
108
|
+
"maxAllowedComplexity": 20
|
|
108
109
|
}
|
|
109
110
|
},
|
|
110
111
|
"noExcessiveNestedTestSuites": "error",
|
|
112
|
+
"noStaticOnlyClass": "error",
|
|
113
|
+
"noThisInStatic": "error",
|
|
114
|
+
"noUselessContinue": "error",
|
|
115
|
+
"noUselessEmptyExport": "error",
|
|
116
|
+
"noUselessEscapeInRegex": "error",
|
|
117
|
+
"noUselessFragments": "error",
|
|
118
|
+
"noUselessLabel": "error",
|
|
119
|
+
"noUselessLoneBlockStatements": "error",
|
|
120
|
+
"noUselessRename": "error",
|
|
121
|
+
"noUselessStringConcat": "error",
|
|
122
|
+
"noUselessStringRaw": "error",
|
|
123
|
+
"noUselessSwitchCase": "error",
|
|
124
|
+
"noUselessTernary": "error",
|
|
125
|
+
"noUselessThisAlias": "error",
|
|
126
|
+
"noUselessTypeConstraint": "error",
|
|
127
|
+
"noUselessUndefinedInitialization": "error",
|
|
128
|
+
"useArrowFunction": "error",
|
|
129
|
+
"useDateNow": "error",
|
|
130
|
+
"useFlatMap": "error",
|
|
131
|
+
"useIndexOf": "error",
|
|
132
|
+
"useLiteralKeys": "error",
|
|
133
|
+
"useNumericLiterals": "error",
|
|
134
|
+
"useOptionalChain": "error",
|
|
135
|
+
"useRegexLiterals": "error",
|
|
136
|
+
"useSimpleNumberKeys": "error",
|
|
111
137
|
"useSimplifiedLogicExpression": "error",
|
|
112
138
|
"useWhile": "error",
|
|
113
|
-
"useIndexOf": "error",
|
|
114
139
|
|
|
115
140
|
// --------------------------- CSS ---------------------------
|
|
116
141
|
"noImportantStyles": "error"
|
|
@@ -124,21 +149,23 @@
|
|
|
124
149
|
"noConstructorReturn": "error",
|
|
125
150
|
"noEmptyCharacterClassInRegex": "error",
|
|
126
151
|
"noEmptyPattern": "error",
|
|
152
|
+
"noGlobalDirnameFilename": "error",
|
|
127
153
|
"noGlobalObjectCalls": "error",
|
|
128
154
|
"noInnerDeclarations": "error",
|
|
129
155
|
"noInvalidBuiltinInstantiation": "error",
|
|
130
156
|
"noInvalidConstructorSuper": "error",
|
|
131
157
|
"noInvalidUseBeforeDeclaration": "error",
|
|
158
|
+
"noNestedComponentDefinitions": "error",
|
|
132
159
|
"noNodejsModules": "off",
|
|
133
160
|
"noNonoctalDecimalEscape": "error",
|
|
134
161
|
"noPrecisionLoss": "error",
|
|
135
162
|
"noPrivateImports": "error",
|
|
163
|
+
"noProcessGlobal": "off",
|
|
136
164
|
"noRenderReturnValue": "error",
|
|
137
165
|
"noSelfAssign": "error",
|
|
138
166
|
"noSetterReturn": "error",
|
|
139
167
|
"noStringCaseMismatch": "error",
|
|
140
168
|
"noSwitchDeclarations": "error",
|
|
141
|
-
"noUndeclaredDependencies": "off",
|
|
142
169
|
"noUndeclaredVariables": "error",
|
|
143
170
|
"noUnreachable": "error",
|
|
144
171
|
"noUnreachableSuper": "error",
|
|
@@ -153,9 +180,12 @@
|
|
|
153
180
|
"noVoidTypeReturn": "error",
|
|
154
181
|
"useExhaustiveDependencies": "error",
|
|
155
182
|
"useHookAtTopLevel": "error",
|
|
156
|
-
"useImportExtensions": "off",
|
|
157
183
|
"useIsNan": "error",
|
|
184
|
+
"useJsonImportAttributes": "error",
|
|
158
185
|
"useJsxKeyInIterable": "error",
|
|
186
|
+
"useParseIntRadix": "error",
|
|
187
|
+
"useSingleJsDocAsterisk": "error",
|
|
188
|
+
"useUniqueElementIds": "error",
|
|
159
189
|
"useValidForDirection": "error",
|
|
160
190
|
"useValidTypeof": "error",
|
|
161
191
|
"useYield": "error",
|
|
@@ -165,6 +195,8 @@
|
|
|
165
195
|
"noInvalidGridAreas": "error",
|
|
166
196
|
"noInvalidPositionAtImportRule": "error",
|
|
167
197
|
"noMissingVarFunction": "error",
|
|
198
|
+
"noReactPropAssignments": "error",
|
|
199
|
+
"noRestrictedElements": "error",
|
|
168
200
|
"noUnknownFunction": "error",
|
|
169
201
|
"noUnknownMediaFeatureName": "error",
|
|
170
202
|
"noUnknownProperty": "error",
|
|
@@ -172,27 +204,19 @@
|
|
|
172
204
|
"noUnknownPseudoElement": "error",
|
|
173
205
|
"noUnknownTypeSelector": "error",
|
|
174
206
|
"noUnknownUnit": "error",
|
|
175
|
-
"noUnmatchableAnbSelector": "error"
|
|
176
|
-
"noGlobalDirnameFilename": "error",
|
|
177
|
-
"noNestedComponentDefinitions": "error",
|
|
178
|
-
"noReactPropAssignments": "error",
|
|
179
|
-
"noRestrictedElements": "error",
|
|
180
|
-
"useJsonImportAttributes": "error",
|
|
181
|
-
"useParseIntRadix": "error",
|
|
182
|
-
"useSingleJsDocAsterisk": "error",
|
|
183
|
-
|
|
184
|
-
"noProcessGlobal": "off",
|
|
185
|
-
"useUniqueElementIds": "off"
|
|
207
|
+
"noUnmatchableAnbSelector": "error"
|
|
186
208
|
},
|
|
187
209
|
"nursery": {
|
|
188
210
|
// ----------------------- JavaScript ------------------------
|
|
211
|
+
"noFloatingPromises": "error",
|
|
212
|
+
"noMisusedPromises": "error",
|
|
213
|
+
"noNonNullAssertedOptionalChain": "error",
|
|
189
214
|
"noShadow": "error",
|
|
215
|
+
"noUnnecessaryConditions": "error",
|
|
190
216
|
"noUselessUndefined": "error",
|
|
191
217
|
"useExhaustiveSwitchCases": "error",
|
|
192
|
-
"
|
|
193
|
-
|
|
194
|
-
"useExplicitType": "off",
|
|
195
|
-
"noSecrets": "off",
|
|
218
|
+
"useReactFunctionComponents": "error",
|
|
219
|
+
"useAnchorHref": "error",
|
|
196
220
|
"useSortedClasses": {
|
|
197
221
|
"fix": "safe",
|
|
198
222
|
"level": "error",
|
|
@@ -200,26 +224,14 @@
|
|
|
200
224
|
"attributes": ["className"],
|
|
201
225
|
"functions": ["clsx", "cva", "tw", "twMerge", "cn", "twJoin", "tv"]
|
|
202
226
|
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// These rules should be enabled once improvements are made to
|
|
206
|
-
// performance
|
|
207
|
-
"noFloatingPromises": "off",
|
|
208
|
-
"noImportCycles": "off",
|
|
209
|
-
"noUnresolvedImports": "off",
|
|
210
|
-
"noMisusedPromises": "off"
|
|
227
|
+
}
|
|
211
228
|
},
|
|
212
229
|
"performance": {
|
|
213
230
|
// ----------------------- JavaScript ------------------------
|
|
214
|
-
|
|
215
231
|
"noAccumulatingSpread": "error",
|
|
216
232
|
"noAwaitInLoops": "error",
|
|
217
|
-
"noBarrelFile": "error",
|
|
218
233
|
"noDelete": "error",
|
|
219
234
|
"noDynamicNamespaceImportAccess": "error",
|
|
220
|
-
"noImgElement": "error",
|
|
221
|
-
"noNamespaceImport": "off",
|
|
222
|
-
"noReExportAll": "off",
|
|
223
235
|
"useTopLevelRegex": "error",
|
|
224
236
|
"noUnwantedPolyfillio": "error",
|
|
225
237
|
"useGoogleFontPreconnect": "error"
|
|
@@ -233,8 +245,6 @@
|
|
|
233
245
|
},
|
|
234
246
|
"style": {
|
|
235
247
|
// ----------------------- JavaScript ------------------------
|
|
236
|
-
"noCommonJs": "off",
|
|
237
|
-
"noDefaultExport": "off",
|
|
238
248
|
"noDoneCallback": "error",
|
|
239
249
|
"noEnum": "error",
|
|
240
250
|
"noExportedImports": "error",
|
|
@@ -243,11 +253,9 @@
|
|
|
243
253
|
"noInferrableTypes": "error",
|
|
244
254
|
"noNamespace": "error",
|
|
245
255
|
"noNegationElse": "error",
|
|
246
|
-
"noNestedTernary": "off",
|
|
247
256
|
"noNonNullAssertion": "error",
|
|
248
257
|
"noParameterAssign": "error",
|
|
249
258
|
"noParameterProperties": "error",
|
|
250
|
-
"noProcessEnv": "off",
|
|
251
259
|
"noRestrictedGlobals": "error",
|
|
252
260
|
"noRestrictedImports": "error",
|
|
253
261
|
"noRestrictedTypes": "error",
|
|
@@ -262,7 +270,6 @@
|
|
|
262
270
|
"useBlockStatements": "error",
|
|
263
271
|
"useCollapsedElseIf": "error",
|
|
264
272
|
"useCollapsedIf": "error",
|
|
265
|
-
"useComponentExportOnlyModules": "off",
|
|
266
273
|
"useConsistentArrayType": "error",
|
|
267
274
|
"useConsistentBuiltinInstantiation": "error",
|
|
268
275
|
"useConsistentCurlyBraces": "off",
|
|
@@ -271,7 +278,7 @@
|
|
|
271
278
|
"useDefaultParameterLast": "error",
|
|
272
279
|
"useDefaultSwitchClause": "error",
|
|
273
280
|
"useEnumInitializers": "error",
|
|
274
|
-
"useExplicitLengthCheck": "
|
|
281
|
+
"useExplicitLengthCheck": "error",
|
|
275
282
|
"useExponentiationOperator": "error",
|
|
276
283
|
"useExportType": "error",
|
|
277
284
|
"useFilenamingConvention": {
|
|
@@ -282,18 +289,22 @@
|
|
|
282
289
|
"match": "[-?%+]?(.+?)[.](.+)"
|
|
283
290
|
}
|
|
284
291
|
},
|
|
292
|
+
"useConsistentObjectDefinitions": "error",
|
|
285
293
|
"useForOf": "error",
|
|
286
294
|
"useFragmentSyntax": "error",
|
|
295
|
+
"useGroupedAccessorPairs": "error",
|
|
287
296
|
"useImportType": "error",
|
|
288
297
|
"useLiteralEnumMembers": "error",
|
|
289
|
-
"useNamingConvention": "off",
|
|
290
298
|
"useNodeAssertStrict": "error",
|
|
291
299
|
"useNodejsImportProtocol": "error",
|
|
292
300
|
"useNumberNamespace": "error",
|
|
301
|
+
"useNumericSeparators": "error",
|
|
302
|
+
"useObjectSpread": "error",
|
|
293
303
|
"useSelfClosingElements": "error",
|
|
294
304
|
"useShorthandAssign": "error",
|
|
295
305
|
"useShorthandFunctionType": "error",
|
|
296
|
-
"useSingleVarDeclarator": "
|
|
306
|
+
"useSingleVarDeclarator": "error",
|
|
307
|
+
"useSymbolDescription": "error",
|
|
297
308
|
"useTemplate": "error",
|
|
298
309
|
"useThrowNewError": "error",
|
|
299
310
|
"useThrowOnlyError": "error",
|
|
@@ -301,19 +312,14 @@
|
|
|
301
312
|
|
|
302
313
|
// --------------------------- CSS ---------------------------
|
|
303
314
|
"noDescendingSpecificity": "error",
|
|
304
|
-
"noValueAtRule": "error"
|
|
305
|
-
"useGroupedAccessorPairs": "error",
|
|
306
|
-
"useConsistentObjectDefinitions": "error",
|
|
307
|
-
"useNumericSeparators": "error",
|
|
308
|
-
"useObjectSpread": "error",
|
|
309
|
-
"useSymbolDescription": "error",
|
|
310
|
-
"useExportsLast": "off"
|
|
315
|
+
"noValueAtRule": "error"
|
|
311
316
|
},
|
|
312
317
|
"suspicious": {
|
|
313
318
|
"noApproximativeNumericConstant": "error",
|
|
314
319
|
"noArrayIndexKey": "error",
|
|
315
320
|
"noAssignInExpressions": "error",
|
|
316
321
|
"noAsyncPromiseExecutor": "error",
|
|
322
|
+
"noBitwiseOperators": "error",
|
|
317
323
|
"noCatchAssign": "error",
|
|
318
324
|
"noClassAssign": "error",
|
|
319
325
|
"noCommentText": "error",
|
|
@@ -322,6 +328,7 @@
|
|
|
322
328
|
"noConfusingVoidType": "error",
|
|
323
329
|
// Warn for the use of console to avoid accidental logging. Prefer a dedicated logger.
|
|
324
330
|
"noConsole": "warn",
|
|
331
|
+
"noConstantBinaryExpressions": "error",
|
|
325
332
|
"noConstEnum": "error",
|
|
326
333
|
"noControlCharactersInRegex": "error",
|
|
327
334
|
"noDebugger": "error",
|
|
@@ -358,6 +365,8 @@
|
|
|
358
365
|
"noMisrefactoredShorthandAssign": "error",
|
|
359
366
|
"noOctalEscape": "error",
|
|
360
367
|
"noPrototypeBuiltins": "error",
|
|
368
|
+
// Disabling to allow passing specific props (like `className`) from
|
|
369
|
+
// parent to child components
|
|
361
370
|
"noReactSpecificProps": "off",
|
|
362
371
|
"noRedeclare": "error",
|
|
363
372
|
"noRedundantUseStrict": "error",
|
|
@@ -368,8 +377,11 @@
|
|
|
368
377
|
"noSuspiciousSemicolonInJsx": "error",
|
|
369
378
|
"noTemplateCurlyInString": "error",
|
|
370
379
|
"noThenProperty": "error",
|
|
380
|
+
"noTsIgnore": "error",
|
|
371
381
|
"noUnsafeDeclarationMerging": "error",
|
|
372
382
|
"noUnsafeNegation": "error",
|
|
383
|
+
"noUselessEscapeInString": "error",
|
|
384
|
+
"noUselessRegexBackrefs": "error",
|
|
373
385
|
"noVar": "error",
|
|
374
386
|
"noWith": "error",
|
|
375
387
|
"useAdjacentOverloadSignatures": "error",
|
|
@@ -380,8 +392,10 @@
|
|
|
380
392
|
"useGoogleFontDisplay": "error",
|
|
381
393
|
"useGuardForIn": "error",
|
|
382
394
|
"useIsArray": "error",
|
|
395
|
+
"useIterableCallbackReturn": "error",
|
|
383
396
|
"useNamespaceKeyword": "error",
|
|
384
397
|
"useNumberToFixedDigitsArgument": "error",
|
|
398
|
+
"useStaticResponseMethods": "error",
|
|
385
399
|
"useStrictMode": "error",
|
|
386
400
|
|
|
387
401
|
// --------------------------- CSS ---------------------------
|
|
@@ -393,17 +407,12 @@
|
|
|
393
407
|
"noEmptyBlock": "error",
|
|
394
408
|
"noImportantInKeyframe": "error",
|
|
395
409
|
"noShorthandPropertyOverrides": "error",
|
|
396
|
-
"noBitwiseOperators": "error",
|
|
397
|
-
"noConstantBinaryExpressions": "error",
|
|
398
|
-
"noTsIgnore": "error",
|
|
399
|
-
"noUselessRegexBackrefs": "error",
|
|
400
|
-
"noUselessEscapeInString": "error",
|
|
401
|
-
"useStaticResponseMethods": "error",
|
|
402
|
-
"useIterableCallbackReturn": "error",
|
|
403
410
|
// Disabling this rule since we need custom at-rules for Tailwind
|
|
404
411
|
"noUnknownAtRules": "off",
|
|
405
412
|
|
|
406
413
|
// --------------------------- JSON ---------------------------
|
|
414
|
+
"noBiomeFirstException": "error",
|
|
415
|
+
"noQuickfixBiome": "error",
|
|
407
416
|
"useBiomeIgnoreFolder": "error"
|
|
408
417
|
}
|
|
409
418
|
}
|
package/dist/index.js
CHANGED
|
@@ -11,4 +11,4 @@ import{Command as e}from"commander";import t from"process";import{spawnSync as n
|
|
|
11
11
|
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
|
12
12
|
┃ ADAMANTITE ┃
|
|
13
13
|
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
14
|
-
`}async function O(e,n){try{let t=await T(),r=E(t),i=[`@biomejs/biome`,`check`,`--write`];n.unsafe&&i.push(`--unsafe`),e.length>0&&i.push(...e),b(r,i)}catch(e){let n=e instanceof Error?e.message:`An unknown error occurred`;console.error(`Failed to run Adamantite:`,n),t.exit(1)}}const
|
|
14
|
+
`}async function O({github:e,monorepo:n}){try{let t=await T(),r=E(t),i=[`@biomejs/biome`,`ci`];e&&i.push(`--reporter`,`github`),b(r,i),n&&b(r,[`sherif`])}catch(e){let n=e instanceof Error?e.message:`An unknown error occurred`;console.error(`Failed to run Adamantite:`,n),t.exit(1)}}async function k(e,n){try{let t=await T(),r=E(t),i=[`@biomejs/biome`,`check`,`--write`];n.unsafe&&i.push(`--unsafe`),e.length>0&&i.push(...e),b(r,i)}catch(e){let n=e instanceof Error?e.message:`An unknown error occurred`;console.error(`Failed to run Adamantite:`,n),t.exit(1)}}const A={config:{extends:`adamantite/presets/tsconfig.json`},async exists(){return await x(s(process.cwd(),`tsconfig.json`))},async create(){await o(s(process.cwd(),`tsconfig.json`),JSON.stringify(this.config,null,2))},async update(){let e=await a(s(process.cwd(),`tsconfig.json`),`utf-8`),t=v(e),n=_(this.config,t);await o(s(process.cwd(),`tsconfig.json`),JSON.stringify(n,null,2))}},j={version:`2.2.0`,config:{$schema:`./node_modules/@biomejs/biome/configuration_schema.json`},async exists(){return await x(s(process.cwd(),`biome.jsonc`))},async create(){await o(s(process.cwd(),`biome.jsonc`),JSON.stringify({...this.config,extends:[`adamantite`]},null,2))},async update(){let e=await x(s(process.cwd(),`biome.jsonc`))?s(process.cwd(),`biome.jsonc`):s(process.cwd(),`biome.json`),t=await a(e,`utf-8`),n=v(t),r={...n};Array.isArray(r.extends)||(r.extends=r.extends?[r.extends]:[]),r.extends.includes(`adamantite`)||r.extends.push(`adamantite`);let i=_(this.config,r);await o(s(process.cwd(),`biome.jsonc`),JSON.stringify(i,null,2))}},M={config:{"typescript.tsdk":`node_modules/typescript/lib`,"editor.defaultFormatter":`esbenp.prettier-vscode`,"editor.formatOnSave":!0,"editor.formatOnPaste":!0,"editor.codeActionsOnSave":{"quickfix.biome":`explicit`,"source.organizeImports.biome":`explicit`,"source.fixAll.biome":`explicit`},"[javascript][typescript][javascriptreact][typescriptreact][json][jsonc][css][graphql]":{"editor.defaultFormatter":`biomejs.biome`}},async exists(){return await x(s(process.cwd(),`.vscode`,`settings.json`))},async create(){let e=s(process.cwd(),`.vscode`);await i(e,{recursive:!0}),await o(s(e,`settings.json`),JSON.stringify(this.config,null,2))},async update(){let e=(await x(s(process.cwd(),`.vscode`,`settings.json`)),s(process.cwd(),`.vscode`,`settings.json`)),t=await a(e,`utf-8`),n=v(t),r=_(this.config,n);await o(s(process.cwd(),`.vscode`,`settings.json`),JSON.stringify(r,null,2))}},N={version:`1.6.1`};async function P(){let e=await h({message:`Select your package manager`,options:w.map(e=>({label:e,value:e})),initialValue:await T()});if(d(e)||e===null)throw Error(`No package manager selected`);if(e===void 0)throw Error(`Invalid package manager selected`);return e}async function F(){let e=t.cwd();if(await x(s(e,`pnpm-workspace.yaml`)))return!0;try{let e=await S();return e.workspaces!==void 0}catch{return!1}}async function I(){let e=g();await j.exists()?(e.start(`Biome config found, updating...`),await j.update(),e.stop(`Biome config updated with Adamantite preset`)):(e.start(`Biome config not found, creating...`),await j.create(),e.stop(`Biome config created with Adamantite preset`))}async function L({lint:e,format:t,monorepo:n}){let r=g();r.start("Adding scripts to your `package.json`...");try{let i=await S();i.scripts||={},e&&(i.scripts.lint=`adamantite lint`),t&&(i.scripts.format=`adamantite format`),n&&(i.scripts[`lint:monorepo`]=`adamantite monorepo`),await C(i),r.stop("Scripts added to your `package.json`")}catch(e){throw r.stop(`Failed to add scripts`),Error(`Failed to modify package.json: ${e instanceof Error?e.message:`Unknown error`}`)}}async function R(){let e=g();await A.exists()?(e.start("`tsconfig.json` found, updating..."),await A.update(),e.stop("Updated `tsconfig.json` with preset")):(e.start("`tsconfig.json` not found, creating..."),await A.create(),e.stop("Created `tsconfig.json` with preset"))}async function z(){let e=await p({message:`Which editors do you want to configure (recommended)?`,options:[{label:`VSCode / Cursor / Windsurf`,value:`vscode`},{label:`Zed (coming soon)`,value:`zed`}],required:!1});if(d(e))throw Error(`Operation cancelled`);return e}async function B(e){if(!e||e.length===0)return;let t=g();e.includes(`vscode`)&&(await M.exists()?(t.start(`VSCode settings found, updating...`),await M.update(),t.stop(`VSCode settings updated with Adamantite preset`)):(t.start(`VSCode settings not found, creating...`),await M.create(),t.stop(`VSCode settings created with Adamantite preset`))),e.includes(`zed`)&&(t.start(`Zed configuration coming soon...`),t.stop(`Zed configuration coming soon...`))}async function V(e){let t=await l({message:e});if(d(t))throw Error(`Operation cancelled`);return t}function H(e,t){let n=g();n.start(`Installing dependencies...`);try{let r=j.version,i=[`adamantite`,`@biomejs/biome@^${r}`];switch(t?.monorepo&&i.push(`sherif@${N.version}`),e){case`npm`:b(`npm`,[`install`,`--save-dev`,`--exact`,...i]);break;case`yarn`:b(`yarn`,[`add`,`--dev`,`--exact`,...i]);break;case`pnpm`:b(`pnpm`,[`add`,`--save-dev`,`--save-exact`,...i]);break;case`bun`:b(`bun`,[`add`,`--dev`,`--exact`,...i]);break;default:throw Error(`Invalid package manager: ${e}`)}n.stop(`Dependencies installed successfully`)}catch(e){throw n.stop(`Failed to install dependencies`),Error(`Failed to install dependencies: ${e instanceof Error?e.message:`Unknown error`}`)}}async function U(){u(D());try{let e=await P(),t=await F(),n=await V("Do you want to add the `format` and `lint` scripts to your `package.json`?"),r=t?await V(`We've detected a monorepo setup in your project. Would you like to install monorepo linting scripts?`):!1,i=await V(`Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to install it?`),a=await z();H(e,{monorepo:r}),await I(),(n||r)&&await L({lint:n,format:n,monorepo:r}),i&&await R(),await B(a),m(`💠 Adamantite initialized successfully!`)}catch(e){f.error(`${e instanceof Error?e.message:`Unknown error`}`),c(`Failed to initialize Adamantite`)}}async function W(e,{summary:n}){try{let t=await T(),r=E(t),i=[`@biomejs/biome`,`lint`,`--fix`];e.length>0&&i.push(...e),n&&i.push(`--reporter`,`summary`),b(r,i)}catch(e){let n=e instanceof Error?e.message:`An unknown error occurred`;console.error(`Failed to run Adamantite:`,n),t.exit(1)}}async function G(){try{let e=await T(),t=E(e);b(t,[`sherif`,`--fix`])}catch(e){let n=e instanceof Error?e.message:`An unknown error occurred`;console.error(`Failed to run Adamantite:`,n),t.exit(1)}}async function K(){let e=[];try{let t=await S(),n=t.devDependencies?.[`@biomejs/biome`];n&&n!==j.version&&e.push({name:`@biomejs/biome`,currentVersion:n,targetVersion:j.version,isDevDependency:!0});let r=t.devDependencies?.sherif;return r&&r!==N.version&&e.push({name:`sherif`,currentVersion:r,targetVersion:N.version,isDevDependency:!0}),e}catch(e){throw Error(`Failed to read package.json: ${e instanceof Error?e.message:`Unknown error`}`)}}function q(e,t){let n=g();n.start(`Updating dependencies...`);try{let r=t.map(e=>`${e.name}@${e.targetVersion}`);switch(e){case`npm`:b(`npm`,[`install`,`--save-dev`,`--save-exact`,...r]);break;case`yarn`:b(`yarn`,[`add`,`--dev`,`--exact`,...r]);break;case`pnpm`:b(`pnpm`,[`add`,`--save-dev`,`--save-exact`,...r]);break;case`bun`:b(`bun`,[`add`,`--dev`,`--exact`,...r]);break;default:throw Error(`Invalid package manager: ${e}`)}n.stop(`Dependencies updated successfully`)}catch(e){throw n.stop(`Failed to update dependencies`),Error(`Failed to update dependencies: ${e instanceof Error?e.message:`Unknown error`}`)}}async function J(e){f.message(`The following dependencies will be updated:`),f.message(``);for(let t of e)f.message(` ${t.name}: ${t.currentVersion} → ${t.targetVersion}`);f.message(``);let t=await l({message:`Do you want to proceed with these updates?`});if(d(t))throw Error(`Operation cancelled`);return t}async function Y(){u(D());try{let e=await T();if(!e)throw Error(`Unable to detect package manager. Please ensure you have a lock file (package-lock.json, yarn.lock, pnpm-lock.yaml, or bun.lock/bun.lockb) in your project.`);let t=await K();if(t.length===0){f.success(`All adamantite dependencies are already up to date!`),m(`💠 No updates needed`);return}let n=await J(t);if(!n){m(`💠 Update cancelled`);return}q(e,t),m(`💠 Dependencies updated successfully!`)}catch(e){f.error(`${e instanceof Error?e.message:`Unknown error`}`),c(`Failed to update dependencies`)}}function X(){let e=JSON.parse(y(s(process.cwd(),`package.json`),`utf-8`));return e.version}const Z=X();var Q=Z;const $=new e;$.version(Q),$.name(`adamantite`).description(`An opinionated set of presets for modern TypeScript applications`),$.command(`init`).description(`Initialize Adamantite in the current directory`).action(U),$.command(`lint`).description(`Run Biome linter and fix files`).argument(`[files...]`,`specific files to lint (optional)`).option(`--summary`,`show summary of lint results`).action(async(e,t)=>{await W(e,t)}),$.command(`format`).description(`Run Biome formatter and fix files`).argument(`[files...]`,`specific files to format (optional)`).option(`--unsafe`,`apply unsafe fixes`).action(async(e,t)=>{await k(e,t)}),$.command(`monorepo`).description(`Lint and automatically fix monorepo-specific issues using Sherif`).action(G),$.command(`ci`).description(`Run Biome CI`).option(`--monorepo`,`run additional monorepo-specific checks`).option(`--github`,`use GitHub reporter`).action(async e=>{await O(e)}),$.command(`update`).description(`Update adamantite dependencies to latest compatible versions`).action(Y),$.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adamantite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "An strict and opinionated set of presets for modern TypeScript applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adamantite",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@clack/prompts": "0.11.0",
|
|
46
|
+
"@commander-js/extra-typings": "^14.0.0",
|
|
46
47
|
"commander": "14.0.0",
|
|
47
48
|
"defu": "6.1.4",
|
|
48
49
|
"jsonc-parser": "3.3.1"
|