adamantite 0.3.3 → 0.4.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 CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://biomejs.dev/schemas/2.1.2/schema.json",
2
+ "$schema": "https://biomejs.dev/schemas/2.1.4/schema.json",
3
3
 
4
4
  // ---------------------------- FORMATTER -----------------------------
5
5
  // These are the generic settings that apply to all files in the project.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
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=`
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,multiselect 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";async function y(e=process.cwd()){try{let t=await S(e),n=t.devDependencies?.[`@biomejs/biome`];if(!n)throw Error(`@biomejs/biome not found in devDependencies`);return n}catch(e){throw Error(`Failed to get Biome version: ${e instanceof Error?e.message:`Unknown error`}`)}}function b(e,t=[],r={}){let i=`${e} ${t.join(` `)}`;n(i,{...r,stdio:`inherit`})}async function x(e){try{return await r(e),!0}catch{return!1}}async function S(e=process.cwd()){let t=o(e,`package.json`);if(!await x(t))throw Error(`package.json not found in the current directory`);try{let e=await i(t,`utf-8`),n=JSON.parse(e);return n}catch(e){throw Error(`Failed to parse package.json: ${e instanceof Error?e.message:`Unknown error`}`)}}async function C(e,t=process.cwd()){let n=o(t,`package.json`);try{await a(n,JSON.stringify(e,null,2))}catch(e){throw Error(`Failed to write package.json: ${e instanceof Error?e.message:`Unknown error`}`)}}const w=[`npm`,`yarn`,`pnpm`,`bun`];async function T(){let e=process.cwd(),t=await x(o(e,`package-lock.json`));if(t)return`npm`;let n=await x(o(e,`yarn.lock`));if(n)return`yarn`;let r=await x(o(e,`pnpm-lock.yaml`));if(r)return`pnpm`;let i=await x(o(e,`bun.lockb`))||await x(o(e,`bun.lock`));return i?`bun`:null}function E(e){switch(e){case`npm`:return`npx`;case`yarn`:return`yarn dlx`;case`pnpm`:return`pnpm dlx`;case`bun`:return`bunx`;default:return`npx`}}function D(){let e=process.stdout.columns||80;return e>=120?`
2
2
  █████ █████ ███ █████
3
3
  ░░███ ░░███ ░░░ ░░███
4
4
  ██████ ███████ ██████ █████████████ ██████ ████████ ███████ ████ ███████ ██████
@@ -7,4 +7,8 @@ import{Command as e}from"commander";import t from"process";import{execSync as n}
7
7
  ███░░███ ░███ ░███ ███░░███ ░███ ░███ ░███ ███░░███ ░███ ░███ ░███ ███ ░███ ░███ ███░███░░░
8
8
  ░░████████░░████████░░████████ █████░███ █████░░████████ ████ █████ ░░█████ █████ ░░█████ ░░██████
9
9
  ░░░░░░░░ ░░░░░░░░ ░░░░░░░░ ░░░░░ ░░░ ░░░░░ ░░░░░░░░ ░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░
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,monorepo: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 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,monorepo: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();
10
+ `:`
11
+ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
12
+ ┃ ADAMANTITE ┃
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 k={config:{extends:`adamantite/presets/tsconfig.json`},async exists(){return await x(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=_(e),n=g(t,this.config);await a(o(process.cwd(),`tsconfig.json`),JSON.stringify(n,null,2))}},A={config:{$schema:`./node_modules/@biomejs/biome/configuration_schema.json`},async exists(){return await x(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 x(o(process.cwd(),`biome.jsonc`))?o(process.cwd(),`biome.jsonc`):o(process.cwd(),`biome.json`),t=await i(e,`utf-8`),n=_(t),r={...n};Array.isArray(r.extends)||(r.extends=r.extends?[r.extends]:[]),r.extends.includes(`adamantite`)||r.extends.push(`adamantite`);let s=g(r,this.config);await a(o(process.cwd(),`biome.jsonc`),JSON.stringify(s,null,2))}},j={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(o(process.cwd(),`.vscode`,`settings.json`))},async create(){await a(o(process.cwd(),`.vscode`,`settings.json`),JSON.stringify(this.config,null,2))},async update(){let e=(await x(o(process.cwd(),`.vscode`,`settings.json`)),o(process.cwd(),`.vscode`,`settings.json`)),t=await i(e,`utf-8`),n=_(t),r=g(n,this.config);await a(o(process.cwd(),`.vscode`,`settings.json`),JSON.stringify(r,null,2))}};async function M(){let e=await m({message:`Select your package manager`,options:w.map(e=>({label:e,value:e})),initialValue:await T()});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 N(){let e=t.cwd();if(await x(o(e,`pnpm-workspace.yaml`)))return!0;try{let e=await S();return e.workspaces!==void 0}catch{return!1}}async function P(){let e=h();await A.exists()?(e.start(`Biome config found, updating...`),await A.update(),e.stop(`Biome config updated with Adamantite preset`)):(e.start(`Biome config not found, creating...`),await A.create(),e.stop(`Biome config created with Adamantite preset`))}async function F({lint:e,format:t,monorepo:n}){let r=h();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 I(){let e=h();await k.exists()?(e.start("`tsconfig.json` found, updating..."),await k.update(),e.stop("Updated `tsconfig.json` with preset")):(e.start("`tsconfig.json` not found, creating..."),await k.create(),e.stop("Created `tsconfig.json` with preset"))}async function L(){let e=await f({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(u(e))throw Error(`Operation cancelled`);return e}async function R(e){if(!e||e.length===0)return;let t=h();e.includes(`vscode`)&&(await j.exists()?(t.start(`VSCode settings found, updating...`),await j.update(),t.stop(`VSCode settings updated with Adamantite preset`)):(t.start(`VSCode settings not found, creating...`),await j.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 z(e){let t=await c({message:e});if(u(t))throw Error(`Operation cancelled`);return t}async function B(e,t){let n=h();n.start(`Installing dependencies...`);try{let r=await y(),i=[`adamantite`,`@biomejs/biome@^${r}`];switch(t?.monorepo&&i.push(`sherif@1.6.1`),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 V(){l(D());try{let e=await M(),t=await N(),n=await z("Do you want to add the `format` and `lint` scripts to your `package.json`?"),r=t?await z(`We've detected a monorepo setup in your project. Would you like to install monorepo linting scripts?`):!1,i=await z(`Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to install it?`),a=await L();await B(e,{monorepo:r}),await P(),(n||r)&&await F({lint:n,format:n,monorepo:r}),i&&await I(),await R(a),p(`💠 Adamantite initialized successfully!`)}catch(e){d.error(`${e instanceof Error?e.message:`Unknown error`}`),s(`Failed to initialize Adamantite`)}}async function H(e){try{let t=await T(),n=E(t),r=[`@biomejs/biome`,`lint`,`--fix`];e.length>0&&r.push(...e),b(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 U(){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)}}function W(){let e=JSON.parse(v(o(process.cwd(),`package.json`),`utf-8`));return e.version}const G=W();var K=G;const q=new e;q.version(K),q.name(`adamantite`).description(`An opinionated set of presets for modern TypeScript applications`),q.command(`init`).description(`Initialize Adamantite in the current directory`).action(V),q.command(`lint`).description(`Run Biome linter and fix files`).argument(`[files...]`,`specific files to lint (optional)`).action(H),q.command(`format`).description(`Run Biome formatter and fix files`).argument(`[files...]`,`specific files to format (optional)`).option(`--unsafe`,`apply unsafe fixes`).action(O),q.command(`monorepo`).description(`Lint and automatically fix monorepo-specific issues using Sherif`).action(U),q.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adamantite",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "description": "An strict and opinionated set of presets for modern TypeScript applications",
5
5
  "keywords": [
6
6
  "adamantite",
@@ -43,19 +43,20 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@clack/prompts": "0.11.0",
46
- "commander": "^14.0.0",
47
- "defu": "^6.1.4",
48
- "jsonc-parser": "^3.3.1"
46
+ "commander": "14.0.0",
47
+ "defu": "6.1.4",
48
+ "jsonc-parser": "3.3.1"
49
49
  },
50
50
  "devDependencies": {
51
- "@biomejs/biome": "2.1.2",
51
+ "@biomejs/biome": "2.1.4",
52
52
  "@changesets/cli": "2.29.5",
53
53
  "@types/bun": "1.2.19",
54
- "tsdown": "^0.12.9",
55
- "type-fest": "^4.41.0"
54
+ "tsdown": "0.13.5",
55
+ "type-fest": "4.41.0",
56
+ "typescript": "5.9.2"
56
57
  },
57
58
  "peerDependencies": {
58
- "typescript": "5.8.3"
59
+ "typescript": ">=5.8"
59
60
  },
60
- "packageManager": "bun@1.2.18"
61
+ "packageManager": "bun@1.2.19"
61
62
  }