adamantite 0.1.1 → 0.3.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/README.md +2 -2
- package/bin/adamantite +3 -0
- package/biome.jsonc +15 -18
- package/dist/index.js +2 -3
- package/package.json +2 -2
- package/presets/tsconfig.json +3 -4
- package/dist/utils-Clt8lmBo.js +0 -1
- package/dist/utils-YzGovySo.js +0 -1
package/README.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
<h1 align="center">💠 <code>adamantite</code></h1>
|
|
3
3
|
|
|
4
4
|
<p align="center">
|
|
5
|
-
<em><strong>
|
|
5
|
+
<em><strong>Bulletproof your code.</strong></em>
|
|
6
6
|
</p>
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Opinionated linting, formatting, and type-safety presets for modern TypeScript applications. Designed for humans and AI.
|
package/bin/adamantite
ADDED
package/biome.jsonc
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://biomejs.dev/schemas/2.1.2/schema.json",
|
|
3
3
|
|
|
4
|
-
//
|
|
4
|
+
// ---------------------------- FORMATTER -----------------------------
|
|
5
5
|
// These are the generic settings that apply to all files in the project.
|
|
6
6
|
"formatter": {
|
|
7
7
|
"enabled": true,
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"bracketSpacing": true
|
|
21
21
|
},
|
|
22
22
|
|
|
23
|
-
//
|
|
23
|
+
// ------------------------------ ASSIST ------------------------------
|
|
24
24
|
// Help with code organization.
|
|
25
25
|
"assist": {
|
|
26
26
|
"actions": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
|
|
45
|
-
//
|
|
45
|
+
// ------------------------------ LINTER ------------------------------
|
|
46
46
|
|
|
47
47
|
"linter": {
|
|
48
48
|
"enabled": true,
|
|
@@ -102,8 +102,7 @@
|
|
|
102
102
|
"useWhile": "error"
|
|
103
103
|
},
|
|
104
104
|
"correctness": {
|
|
105
|
-
//
|
|
106
|
-
|
|
105
|
+
// ----------------------- JavaScript ------------------------
|
|
107
106
|
"noChildrenProp": "error",
|
|
108
107
|
"noConstantCondition": "error",
|
|
109
108
|
"noConstantMathMinMaxClamp": "error",
|
|
@@ -147,7 +146,7 @@
|
|
|
147
146
|
"useValidTypeof": "error",
|
|
148
147
|
"useYield": "error",
|
|
149
148
|
|
|
150
|
-
//
|
|
149
|
+
// --------------------------- CSS ---------------------------
|
|
151
150
|
"noInvalidDirectionInLinearGradient": "error",
|
|
152
151
|
"noInvalidGridAreas": "error",
|
|
153
152
|
"noInvalidPositionAtImportRule": "error",
|
|
@@ -162,8 +161,7 @@
|
|
|
162
161
|
"noUnmatchableAnbSelector": "error"
|
|
163
162
|
},
|
|
164
163
|
"nursery": {
|
|
165
|
-
//
|
|
166
|
-
|
|
164
|
+
// ----------------------- JavaScript ------------------------
|
|
167
165
|
"noAwaitInLoop": "error",
|
|
168
166
|
"noBitwiseOperators": "error",
|
|
169
167
|
"noConstantBinaryExpression": "error",
|
|
@@ -212,13 +210,13 @@
|
|
|
212
210
|
"noImportCycles": "off",
|
|
213
211
|
"noUnresolvedImports": "off",
|
|
214
212
|
|
|
215
|
-
//
|
|
213
|
+
// --------------------------- CSS ---------------------------
|
|
216
214
|
"noImportantStyles": "error",
|
|
217
215
|
// Disabling this rule since we need custom at-rules for Tailwind
|
|
218
216
|
"noUnknownAtRule": "off"
|
|
219
217
|
},
|
|
220
218
|
"performance": {
|
|
221
|
-
//
|
|
219
|
+
// ----------------------- JavaScript ------------------------
|
|
222
220
|
|
|
223
221
|
"noAccumulatingSpread": "error",
|
|
224
222
|
"noBarrelFile": "off",
|
|
@@ -230,15 +228,14 @@
|
|
|
230
228
|
"useTopLevelRegex": "error"
|
|
231
229
|
},
|
|
232
230
|
"security": {
|
|
233
|
-
//
|
|
234
|
-
|
|
231
|
+
// ----------------------- JavaScript ------------------------
|
|
235
232
|
"noBlankTarget": "error",
|
|
236
233
|
"noDangerouslySetInnerHtml": "error",
|
|
237
234
|
"noDangerouslySetInnerHtmlWithChildren": "error",
|
|
238
235
|
"noGlobalEval": "error"
|
|
239
236
|
},
|
|
240
237
|
"style": {
|
|
241
|
-
//
|
|
238
|
+
// ----------------------- JavaScript ------------------------
|
|
242
239
|
"noCommonJs": "off",
|
|
243
240
|
"noDefaultExport": "off",
|
|
244
241
|
"noDoneCallback": "error",
|
|
@@ -305,7 +302,7 @@
|
|
|
305
302
|
"useThrowOnlyError": "error",
|
|
306
303
|
"useTrimStartEnd": "error",
|
|
307
304
|
|
|
308
|
-
//
|
|
305
|
+
// --------------------------- CSS ---------------------------
|
|
309
306
|
"noDescendingSpecificity": "error",
|
|
310
307
|
"noValueAtRule": "error"
|
|
311
308
|
},
|
|
@@ -384,7 +381,7 @@
|
|
|
384
381
|
"useNumberToFixedDigitsArgument": "error",
|
|
385
382
|
"useStrictMode": "error",
|
|
386
383
|
|
|
387
|
-
//
|
|
384
|
+
// --------------------------- CSS ---------------------------
|
|
388
385
|
"noDuplicateAtImportRules": "error",
|
|
389
386
|
"noDuplicateCustomProperties": "error",
|
|
390
387
|
"noDuplicateFontNames": "error",
|
|
@@ -396,7 +393,7 @@
|
|
|
396
393
|
}
|
|
397
394
|
}
|
|
398
395
|
},
|
|
399
|
-
//
|
|
396
|
+
// ---------------------------- JAVASCRIPT ----------------------------
|
|
400
397
|
// Options for JavaScript and TypeScript files.
|
|
401
398
|
"javascript": {
|
|
402
399
|
"formatter": {
|
|
@@ -415,7 +412,7 @@
|
|
|
415
412
|
"trailingCommas": "es5"
|
|
416
413
|
}
|
|
417
414
|
},
|
|
418
|
-
//
|
|
415
|
+
// ------------------------------- CSS -------------------------------
|
|
419
416
|
"css": {
|
|
420
417
|
"formatter": {
|
|
421
418
|
"quoteStyle": "double"
|
|
@@ -425,7 +422,7 @@
|
|
|
425
422
|
"cssModules": false
|
|
426
423
|
}
|
|
427
424
|
},
|
|
428
|
-
//
|
|
425
|
+
// ------------------------------ JSON -------------------------------
|
|
429
426
|
"json": {
|
|
430
427
|
"assist": {
|
|
431
428
|
"enabled": true
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import{exists as e,readPackageJson as t,runProcess as n,writePackageJson as r}from"./utils-Clt8lmBo.js";import{Command as i}from"commander";import a from"process";import{readFile as o,writeFile as s}from"fs/promises";import{join as c}from"path";import{confirm as l,intro as u,isCancel as d,log as f,outro as p,select as m,spinner as h}from"@clack/prompts";import g from"defu";import{parse as _}from"jsonc-parser";import{readFileSync as v}from"fs";function y(e,t){try{let r=[`@biomejs/biome`,`check`,`--write`];t.unsafe&&r.push(`--unsafe`),e.length>0&&r.push(...e),n(`npx`,r)}catch(e){let t=e instanceof Error?e.message:`An unknown error occurred`;console.error(`Failed to run Adamantite:`,t),a.exit(1)}}const b=[`npm`,`yarn`,`pnpm`,`bun`];async function x(){let t=process.cwd(),n=await e(c(t,`package-lock.json`));if(n)return`npm`;let r=await e(c(t,`yarn.lock`));if(r)return`yarn`;let i=await e(c(t,`pnpm-lock.yaml`));if(i)return`pnpm`;let a=await e(c(t,`bun.lockb`))||await e(c(t,`bun.lock`));return a?`bun`:null}const S={config:{extends:`adamantite/presets/tsconfig.json`},async exists(){return await e(c(process.cwd(),`tsconfig.json`))},async create(){await s(c(process.cwd(),`tsconfig.json`),JSON.stringify(this.config,null,2))},async update(){let e=await o(c(process.cwd(),`tsconfig.json`),`utf-8`),t=_(e),n=g(t,this.config);await s(c(process.cwd(),`tsconfig.json`),JSON.stringify(n,null,2))}},C={config:{$schema:`./node_modules/@biomejs/biome/configuration_schema.json`},async exists(){return await e(c(process.cwd(),`biome.jsonc`))},async create(){await s(c(process.cwd(),`biome.jsonc`),JSON.stringify({...this.config,extends:[`adamantite`]},null,2))},async update(){let t=await e(c(process.cwd(),`biome.jsonc`))?c(process.cwd(),`biome.jsonc`):c(process.cwd(),`biome.json`),n=await o(t,`utf-8`),r=_(n),i={...r};Array.isArray(i.extends)||(i.extends=i.extends?[i.extends]:[]),i.extends.includes(`adamantite`)||i.extends.push(`adamantite`);let a=g(i,this.config);await s(c(process.cwd(),`biome.jsonc`),JSON.stringify(a,null,2))}},w=`
|
|
1
|
+
import{Command as e}from"commander";import t from"process";import{execSync as n}from"child_process";import{access as r,readFile as i,writeFile as a}from"fs/promises";import{join as o}from"path";import{cancel as s,confirm as c,intro as l,isCancel as u,log as d,outro as f,select as p,spinner as m}from"@clack/prompts";import h from"defu";import{parse as g}from"jsonc-parser";import{readFileSync as _}from"fs";const v=`2.1.2`,y=`1.6.1`;let b=null,x=null;function S(e,t=[],r={}){let i=`${e} ${t.join(` `)}`;n(i,{...r,stdio:`inherit`})}async function C(e){try{return await r(e),!0}catch{return!1}}async function w(e=process.cwd()){let t=o(e,`package.json`);if(b&&x===t)return b;if(!await C(t))throw Error(`package.json not found in the current directory`);try{let e=await i(t,`utf-8`),n=JSON.parse(e);return b=n,x=t,n}catch(e){throw Error(`Failed to parse package.json: ${e instanceof Error?e.message:`Unknown error`}`)}}async function T(e,t=process.cwd()){let n=o(t,`package.json`);try{await a(n,JSON.stringify(e,null,2)),x===n&&(b=e)}catch(e){throw Error(`Failed to write package.json: ${e instanceof Error?e.message:`Unknown error`}`)}}const E=[`npm`,`yarn`,`pnpm`,`bun`];async function D(){let e=process.cwd(),t=await C(o(e,`package-lock.json`));if(t)return`npm`;let n=await C(o(e,`yarn.lock`));if(n)return`yarn`;let r=await C(o(e,`pnpm-lock.yaml`));if(r)return`pnpm`;let i=await C(o(e,`bun.lockb`))||await C(o(e,`bun.lock`));return i?`bun`:null}function O(e){switch(e){case`npm`:return`npx`;case`yarn`:return`yarn dlx`;case`pnpm`:return`pnpm dlx`;case`bun`:return`bunx`;default:return`npx`}}async function k(e,n){try{let t=await D(),r=O(t),i=[`@biomejs/biome`,`check`,`--write`];n.unsafe&&i.push(`--unsafe`),e.length>0&&i.push(...e),S(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 C(o(process.cwd(),`tsconfig.json`))},async create(){await a(o(process.cwd(),`tsconfig.json`),JSON.stringify(this.config,null,2))},async update(){let e=await i(o(process.cwd(),`tsconfig.json`),`utf-8`),t=g(e),n=h(t,this.config);await a(o(process.cwd(),`tsconfig.json`),JSON.stringify(n,null,2))}},j={config:{$schema:`./node_modules/@biomejs/biome/configuration_schema.json`},async exists(){return await C(o(process.cwd(),`biome.jsonc`))},async create(){await a(o(process.cwd(),`biome.jsonc`),JSON.stringify({...this.config,extends:[`adamantite`]},null,2))},async update(){let e=await C(o(process.cwd(),`biome.jsonc`))?o(process.cwd(),`biome.jsonc`):o(process.cwd(),`biome.json`),t=await i(e,`utf-8`),n=g(t),r={...n};Array.isArray(r.extends)||(r.extends=r.extends?[r.extends]:[]),r.extends.includes(`adamantite`)||r.extends.push(`adamantite`);let s=h(r,this.config);await a(o(process.cwd(),`biome.jsonc`),JSON.stringify(s,null,2))}},M=`
|
|
3
2
|
█████ █████ ███ █████
|
|
4
3
|
░░███ ░░███ ░░░ ░░███
|
|
5
4
|
██████ ███████ ██████ █████████████ ██████ ████████ ███████ ████ ███████ ██████
|
|
@@ -8,4 +7,4 @@ import{exists as e,readPackageJson as t,runProcess as n,writePackageJson as r}fr
|
|
|
8
7
|
███░░███ ░███ ░███ ███░░███ ░███ ░███ ░███ ███░░███ ░███ ░███ ░███ ███ ░███ ░███ ███░███░░░
|
|
9
8
|
░░████████░░████████░░████████ █████░███ █████░░████████ ████ █████ ░░█████ █████ ░░█████ ░░██████
|
|
10
9
|
░░░░░░░░ ░░░░░░░░ ░░░░░░░░ ░░░░░ ░░░ ░░░░░ ░░░░░░░░ ░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░
|
|
11
|
-
`;async function
|
|
10
|
+
`;async function N(){let e=await p({message:`Select your package manager`,options:E.map(e=>({label:e,value:e})),initialValue:await D()});if(u(e)||e===null)throw Error(`No package manager selected`);if(e===void 0)throw Error(`Invalid package manager selected`);return e}async function P(){let e=t.cwd();if(await C(o(e,`pnpm-workspace.yaml`)))return!0;try{let e=await w();return e.workspaces!==void 0}catch{return!1}}async function F(){let e=m();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 I({lint:e,format:t,lintMonorepo:n}){let r=m();r.start("Adding scripts to your `package.json`...");try{let i=await w();i.scripts||={},e&&(i.scripts.lint=`adamantite lint`),t&&(i.scripts.format=`adamantite format`),n&&(i.scripts[`lint:monorepo`]=`adamantite lint monorepo`),await T(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 L(){let e=m();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 R(e){let t=await c({message:e});if(u(t))throw Error(`Operation cancelled`);return t}function z(e,t){let n=m();n.start(`Installing dependencies...`);try{switch(e){case`npm`:S(`npm`,[`install`,`--save-dev`,`--exact`,`adamantite`,`@biomejs/biome@${v}`,t?.monorepo?`sherif@${y}`:``]);break;case`yarn`:S(`yarn`,[`add`,`--dev`,`--exact`,`adamantite`,`@biomejs/biome@${v}`,t?.monorepo?`sherif@${y}`:``]);break;case`pnpm`:S(`pnpm`,[`add`,`--save-dev`,`--save-exact`,`adamantite`,`@biomejs/biome@${v}`,t?.monorepo?`sherif@${y}`:``]);break;case`bun`:S(`bun`,[`add`,`--dev`,`--exact`,`adamantite`,`@biomejs/biome@${v}`,t?.monorepo?`sherif@${y}`:``]);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 B(){l(M);try{let e=await N(),t=await P(),n=await R("Do you want to add the `format` and `lint` scripts to your `package.json`?"),r=t?await R(`We've detected a monorepo setup in your project. Would you like to install monorepo linting scripts?`):!1,i=await R(`Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to install it?`);z(e,{monorepo:r}),await F(),(n||r)&&await I({lint:n,format:n,lintMonorepo:r}),i&&await L(),f(`💠 Adamantite initialized successfully!`)}catch(e){d.error(`${e instanceof Error?e.message:`Unknown error`}`),s(`Failed to initialize Adamantite`)}}async function V(e){try{let t=await D(),n=O(t),r=[`@biomejs/biome`,`lint`,`--fix`];e.length>0&&r.push(...e),S(n,r)}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 H(){try{let e=await D(),t=O(e);S(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)}}function U(){let e=JSON.parse(_(o(process.cwd(),`package.json`),`utf-8`));return e.version}const W=U();var G=W;const K=new e;K.version(G),K.name(`adamantite`).description(`An opinionated set of presets for modern TypeScript applications`),K.command(`init`).description(`Initialize Adamantite in the current directory`).action(B),K.command(`lint`).description(`Run Biome linter and fix files`).argument(`[files...]`,`specific files to lint (optional)`).action(V),K.command(`format`).description(`Run Biome formatter and fix files`).argument(`[files...]`,`specific files to format (optional)`).option(`--unsafe`,`apply unsafe fixes`).action(k),K.command(`monorepo`).description(`Lint and automatically fix monorepo-specific issues using Sherif`).action(H),K.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adamantite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "An strict and opinionated set of presets for modern TypeScript applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adamantite",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"type": "module",
|
|
24
24
|
"main": "biome.jsonc",
|
|
25
25
|
"bin": {
|
|
26
|
-
"adamantite": "
|
|
26
|
+
"adamantite": "bin/adamantite"
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"biome.jsonc",
|
package/presets/tsconfig.json
CHANGED
|
@@ -9,14 +9,13 @@
|
|
|
9
9
|
"resolveJsonModule": true,
|
|
10
10
|
"moduleDetection": "force",
|
|
11
11
|
|
|
12
|
-
// Strictness and best practices
|
|
12
|
+
// Strictness and best practices. We only recommend settings that are not
|
|
13
|
+
// covered by linting rules.
|
|
13
14
|
"strict": true,
|
|
14
15
|
"noUncheckedIndexedAccess": true,
|
|
15
|
-
"noFallthroughCasesInSwitch": true,
|
|
16
16
|
"noImplicitOverride": true,
|
|
17
17
|
"forceConsistentCasingInFileNames": true,
|
|
18
|
-
"
|
|
19
|
-
"noPropertyAccessFromIndexSignature": true,
|
|
18
|
+
"noImplicitAny": true,
|
|
20
19
|
"noImplicitThis": true,
|
|
21
20
|
"noImplicitReturns": true
|
|
22
21
|
}
|
package/dist/utils-Clt8lmBo.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{execSync as e}from"child_process";import{access as t,readFile as n,writeFile as r}from"fs/promises";import{join as i}from"path";const a=`2.1.2`;let o=null,s=null;function c(t,n=[],r={}){let i=`${t} ${n.join(` `)}`;e(i,{...r,stdio:`inherit`})}async function l(e){try{return await t(e),!0}catch{return!1}}async function u(e=process.cwd()){let t=i(e,`package.json`);if(o&&s===t)return o;if(!await l(t))throw Error(`package.json not found in the current directory`);try{let e=await n(t,`utf-8`),r=JSON.parse(e);return o=r,s=t,r}catch(e){throw Error(`Failed to parse package.json: ${e instanceof Error?e.message:`Unknown error`}`)}}async function d(e,t=process.cwd()){let n=i(t,`package.json`);try{await r(n,JSON.stringify(e,null,2)),s===n&&(o=e)}catch(e){throw Error(`Failed to write package.json: ${e instanceof Error?e.message:`Unknown error`}`)}}export{a as BIOME_VERSION,l as exists,u as readPackageJson,c as runProcess,d as writePackageJson};
|
package/dist/utils-YzGovySo.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{BIOME_VERSION as e,exists as t,readPackageJson as n,runProcess as r,writePackageJson as i}from"./utils-Clt8lmBo.js";export{e as BIOME_VERSION,r as runProcess};
|