adamantite 0.0.6 → 0.1.1
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/LICENSE +21 -0
- package/README.md +8 -2
- package/dist/index.js +10 -1
- package/dist/utils-Clt8lmBo.js +1 -0
- package/dist/utils-YzGovySo.js +1 -0
- package/package.json +11 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Adel Rodriguez
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<h1 align="center">💠 <code>adamantite</code></h1>
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
<p align="center">
|
|
5
|
+
<em><strong>Ship faster, with confidence.</strong></em>
|
|
6
|
+
</p>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
An opinionated set of presets for linting, formatting and type-safety. Built for modern TypeScript applications and AI-ready.
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
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=`
|
|
3
|
+
█████ █████ ███ █████
|
|
4
|
+
░░███ ░░███ ░░░ ░░███
|
|
5
|
+
██████ ███████ ██████ █████████████ ██████ ████████ ███████ ████ ███████ ██████
|
|
6
|
+
░░░░░███ ███░░███ ░░░░░███ ░░███░░███░░███ ░░░░░███ ░░███░░███ ░░░███░ ░░███ ░░░███░ ███░░███
|
|
7
|
+
███████ ░███ ░███ ███████ ░███ ░███ ░███ ███████ ░███ ░███ ░███ ░███ ░███ ░███████
|
|
8
|
+
███░░███ ░███ ░███ ███░░███ ░███ ░███ ░███ ███░░███ ░███ ░███ ░███ ███ ░███ ░███ ███░███░░░
|
|
9
|
+
░░████████░░████████░░████████ █████░███ █████░░████████ ████ █████ ░░█████ █████ ░░█████ ░░██████
|
|
10
|
+
░░░░░░░░ ░░░░░░░░ ░░░░░░░░ ░░░░░ ░░░ ░░░░░ ░░░░░░░░ ░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░
|
|
11
|
+
`;async function T(){let e=await m({message:`Select your package manager`,options:b.map(e=>({label:e,value:e})),initialValue:await x()});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 E(){let n=a.cwd();if(await e(c(n,`pnpm-workspace.yaml`)))return!0;try{let e=await t();return e.workspaces!==void 0}catch{return!1}}async function D(){let e=h();await C.exists()?(e.start(`Biome config found, updating...`),await C.update(),e.stop(`Biome config updated with Adamantite preset`)):(e.start(`Biome config not found, creating...`),await C.create(),e.stop(`Biome config created with Adamantite preset`))}async function O({lint:e,format:n}){let i=h();i.start("Adding scripts to your `package.json`...");try{let a=await t();a.scripts||={},e&&(a.scripts.lint=`adamantite lint`),n&&(a.scripts.format=`adamantite format`),await r(a),i.stop("Scripts added to your `package.json`")}catch(e){throw i.stop(`Failed to add scripts`),Error(`Failed to modify package.json: ${e instanceof Error?e.message:`Unknown error`}`)}}async function k(){let e=h();await S.exists()?(e.start("`tsconfig.json` found, updating..."),await S.update(),e.stop("Updated `tsconfig.json` with preset")):(e.start("`tsconfig.json` not found, creating..."),await S.create(),e.stop("Created `tsconfig.json` with preset"))}async function A(e){let t=await l({message:e});if(d(t))throw Error(`Operation cancelled`);return t}async function j(e){let t=h();t.start(`Installing dependencies...`);try{let{runProcess:n,BIOME_VERSION:r}=await import(`./utils-YzGovySo.js`);switch(e){case`npm`:n(`npm`,[`install`,`--save-dev`,`--exact`,`adamantite`,`@biomejs/biome@${r}`]);break;case`yarn`:n(`yarn`,[`add`,`--dev`,`--exact`,`adamantite`,`@biomejs/biome@${r}`]);break;case`pnpm`:n(`pnpm`,[`add`,`--save-dev`,`--save-exact`,`adamantite`,`@biomejs/biome@${r}`]);break;case`bun`:n(`bun`,[`add`,`--dev`,`--exact`,`adamantite`,`@biomejs/biome@${r}`]);break;default:throw Error(`Invalid package manager: ${e}`)}t.stop(`Dependencies installed successfully`)}catch(n){if(t.stop(`Failed to install dependencies`),n instanceof Error){if(n.message.includes(`EACCES`)||n.message.includes(`permission`))throw Error(`Failed to install dependencies: Permission denied. Try running with elevated permissions or check file permissions.`);if(n.message.includes(`ENOTFOUND`)||n.message.includes(`network`))throw Error(`Failed to install dependencies: Network error. Check your internet connection and try again.`);if(n.message.includes(`Invalid package manager`))throw Error(`Failed to install dependencies: Unsupported package manager: ${e}. Please use npm, yarn, pnpm, or bun.`)}throw Error(`Failed to install dependencies: ${n instanceof Error?n.message:`Unknown error`}`)}}async function M(){u(w);try{let e=await T(),t=await E(),n=await A("Do you want to add the `format` and `lint` scripts to your `package.json`?"),r=t?await A(`We've detected a monorepo setup in your project. Would you like to install monorepo linting scripts?`):!1,i=await A(`Adamantite provides a TypeScript preset to enforce strict type-safety. Would you like to install it?`);await j(e),await D(),(n||r)&&await O({lint:n,format:n,monorepoLinting:r}),i&&await k(),p(`💠 Adamantite initialized successfully!`)}catch(e){f.error(`${e instanceof Error?e.message:`Unknown error`}`),p(`Failed to initialize Adamantite`)}}function N(e){try{let t=[`@biomejs/biome`,`lint`,`--fix`];e.length>0&&t.push(...e),n(`npx`,t)}catch(e){let t=e instanceof Error?e.message:`An unknown error occurred`;console.error(`Failed to run Adamantite:`,t),a.exit(1)}}function P(){let e=JSON.parse(v(c(process.cwd(),`package.json`),`utf-8`));return e.version}const F=P();var I=F;const L=new i;L.version(I),L.name(`Adamantite`).description(`An opinionated set of presets for modern TypeScript applications.`),L.command(`init`).description(`Initialize Adamantite in the current directory`).action(M),L.command(`lint`).description(`Run Biome linter and fix files`).argument(`[files...]`,`specific files to lint (optional)`).action(N),L.command(`format`).description(`Run Biome formatter and fix files`).argument(`[files...]`,`specific files to format (optional)`).option(`--unsafe`,`apply unsafe fixes`).action(y),L.parse();
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adamantite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "An strict and opinionated set of presets for modern TypeScript applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adamantite",
|
|
@@ -32,23 +32,27 @@
|
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "tsdown",
|
|
35
|
+
"dev": "tsdown --watch",
|
|
35
36
|
"format": "biome check --write",
|
|
36
37
|
"lint": "biome lint --fix",
|
|
38
|
+
"release": "changeset publish",
|
|
37
39
|
"test": "bun test",
|
|
38
40
|
"test:watch": "bun --watch test",
|
|
39
41
|
"typecheck": "tsc --noEmit",
|
|
40
|
-
"version": "changeset version"
|
|
41
|
-
"release": "changeset publish"
|
|
42
|
+
"version": "changeset version"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@
|
|
45
|
-
"commander": "^14.0.0"
|
|
45
|
+
"@clack/prompts": "0.11.0",
|
|
46
|
+
"commander": "^14.0.0",
|
|
47
|
+
"defu": "^6.1.4",
|
|
48
|
+
"jsonc-parser": "^3.3.1"
|
|
46
49
|
},
|
|
47
50
|
"devDependencies": {
|
|
51
|
+
"@biomejs/biome": "2.1.2",
|
|
48
52
|
"@changesets/cli": "2.29.5",
|
|
49
|
-
"@clack/prompts": "0.11.0",
|
|
50
53
|
"@types/bun": "1.2.19",
|
|
51
|
-
"tsdown": "^0.12.9"
|
|
54
|
+
"tsdown": "^0.12.9",
|
|
55
|
+
"type-fest": "^4.41.0"
|
|
52
56
|
},
|
|
53
57
|
"peerDependencies": {
|
|
54
58
|
"typescript": "5.8.3"
|