Skip to content

Commit 7ce2bdd

Browse files
committed
fix(deps): remove heavy deps. Fix win32 edit. Docs
1 parent dee6356 commit 7ce2bdd

19 files changed

+790
-289
lines changed

package.json

+1-6
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
"@octokit/plugin-retry": "7.1.4",
8787
"@octokit/plugin-throttling": "9.4.0",
8888
"@types/chalk": "2.2.4",
89-
"@types/date-fns": "2.6.3",
9089
"@types/download": "8.0.5",
9190
"@types/fs-extra": "11.0.4",
9291
"@types/shelljs": "0.8.15",
@@ -101,7 +100,6 @@
101100
"chalk-template": "1.1.0",
102101
"chrome-trace-event": "^1.0.4",
103102
"color-name": "2.0.0",
104-
"date-fns": "4.1.0",
105103
"dotenv": "^16.4.7",
106104
"dotenv-flow": "4.1.0",
107105
"download": "8.0.0",
@@ -125,12 +123,10 @@
125123
"minimist": "1.2.8",
126124
"open": "10.1.0",
127125
"p-retry": "6.2.1",
128-
"pnpm": "10.4.1",
129126
"project-name-generator": "2.1.9",
130127
"quick-score": "^0.2.0",
131128
"replace-in-file": "8.3.0",
132129
"rimraf": "6.0.1",
133-
"rxjs": "7.8.1",
134130
"safe-stable-stringify": "^2.5.0",
135131
"shelljs": "0.8.5",
136132
"slugify": "1.6.6",
@@ -140,7 +136,6 @@
140136
"untildify": "5.0.0"
141137
},
142138
"devDependencies": {
143-
"@biomejs/biome": "1.9.4",
144139
"@types/debug": "4.1.12",
145140
"@types/node": "^22.13.4",
146141
"@types/node-ipc": "9.2.3",
@@ -214,5 +209,5 @@
214209
"file-icon": "5.1.1",
215210
"get-app-icon": "1.0.1"
216211
},
217-
"packageManager": "pnpm@10.4.1"
212+
"packageManager": "pnpm@10.5.0"
218213
}

pnpm-lock.yaml

-123
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/analyze-date-fns.js

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// Script to analyze the size impact of date-fns imports
2+
import fs from 'node:fs'
3+
import path from 'node:path'
4+
import { filesize } from 'filesize'
5+
6+
// Path to node_modules
7+
const nodeModulesPath = path.resolve(process.cwd(), 'node_modules')
8+
const dateFnsPath = path.resolve(nodeModulesPath, 'date-fns')
9+
10+
// Functions we're using
11+
const usedFunctions = ['formatDistanceToNow', 'formatDistanceToNowStrict', 'compareAsc', 'format', 'parseISO']
12+
13+
// Calculate size of the entire date-fns package
14+
function getDirectorySize(dirPath) {
15+
let size = 0
16+
const files = fs.readdirSync(dirPath, { withFileTypes: true })
17+
18+
for (const file of files) {
19+
const filePath = path.join(dirPath, file.name)
20+
21+
if (file.isDirectory()) {
22+
size += getDirectorySize(filePath)
23+
} else {
24+
size += fs.statSync(filePath).size
25+
}
26+
}
27+
28+
return size
29+
}
30+
31+
// Calculate size of individual functions
32+
function getFunctionSize(funcName) {
33+
try {
34+
const funcPath = path.resolve(dateFnsPath, funcName, 'index.js')
35+
if (fs.existsSync(funcPath)) {
36+
return fs.statSync(funcPath).size
37+
}
38+
return 0
39+
} catch (err) {
40+
return 0
41+
}
42+
}
43+
44+
// Main analysis
45+
try {
46+
console.log('='.repeat(80))
47+
console.log('DATE-FNS SIZE ANALYSIS')
48+
console.log('='.repeat(80))
49+
50+
const totalSize = getDirectorySize(dateFnsPath)
51+
console.log(`Total date-fns package size: ${filesize(totalSize)}`)
52+
53+
console.log('\nSize of individual functions we use:')
54+
console.log('-'.repeat(60))
55+
56+
let usedSize = 0
57+
for (const func of usedFunctions) {
58+
const size = getFunctionSize(func)
59+
usedSize += size
60+
console.log(`${func}: ${filesize(size)}`)
61+
}
62+
63+
console.log('-'.repeat(60))
64+
console.log(`Total size of used functions: ${filesize(usedSize)}`)
65+
console.log(`Percentage of total package: ${((usedSize / totalSize) * 100).toFixed(2)}%`)
66+
console.log(`Potential savings: ${filesize(totalSize - usedSize)}`)
67+
68+
console.log('\nRecommendation:')
69+
if (usedSize / totalSize < 0.2) {
70+
console.log('✅ Using individual imports from date-fns will significantly reduce bundle size.')
71+
} else {
72+
console.log('⚠️ The functions you use make up a significant portion of date-fns.')
73+
console.log(' Consider using native JavaScript Date methods where possible.')
74+
}
75+
} catch (err) {
76+
console.error('Error analyzing date-fns:', err)
77+
}

src/api/global.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type { PromptConfig } from "../types/core"
1818
import {
1919
format,
2020
formatDistanceToNow,
21-
} from "date-fns"
21+
} from "../utils/date.js"
2222
import { kitPnpmPath } from "../core/resolvers.js"
2323

2424
global.actionFlag = ""

src/api/kit.ts

+6-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as os from 'node:os'
66
import { pathToFileURL } from 'node:url'
77
import * as JSONSafe from 'safe-stable-stringify'
88
import { QuickScore, quickScore, createConfig, type Options, type ConfigOptions } from 'quick-score'
9-
import { formatDistanceToNow } from 'date-fns'
9+
import { formatDistanceToNow } from '../utils/date.js'
1010
import type {
1111
Action,
1212
Choice,
@@ -1190,7 +1190,7 @@ export let scriptFlags: FlagsObject = {
11901190
let compileMessage = stamp?.compileMessage?.trim() || ''
11911191
let compileStamp = stamp?.compileStamp
11921192
? `Last compiled: ${formatDistanceToNow(new Date(stamp?.compileStamp), {
1193-
includeSeconds: true
1193+
addSuffix: false
11941194
})} ago`
11951195
: ''
11961196
let executionTime = stamp?.executionTime ? `Last run duration: ${stamp?.executionTime}ms` : ''
@@ -1305,7 +1305,7 @@ ${lastRunBlock}
13051305
},
13061306
'share-copy': {
13071307
group: 'Copy',
1308-
name: 'Copy',
1308+
name: 'Copy script contents to clipboard',
13091309
description: 'Copy script contents to clipboard',
13101310
shortcut: `${cmd}+c`
13111311
},
@@ -1834,14 +1834,9 @@ export let processScript =
18341834

18351835
if (stamp.compileMessage && stamp.compileStamp) {
18361836
infoBlock = `~~~
1837-
⚠️ Last compiled ${formatDistanceToNow(new Date(stamp.compileStamp))} ago
1838-
1839-
${stamp.compileMessage}
1840-
~~~
1841-
1842-
<p/>
1843-
1844-
`
1837+
⚠️ Last compiled ${formatDistanceToNow(new Date(stamp.compileStamp), {
1838+
addSuffix: false
1839+
})} ago`
18451840
}
18461841
}
18471842
if (!(s as Scriptlet)?.scriptlet) {

src/cli/install.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
formatDistanceToNow,
33
parseISO,
4-
} from "date-fns"
4+
} from "../utils/date.js"
55
import { getKenvFromPath, KIT_FIRST_PATH } from "../core/utils.js"
66
import { createPackageManagerCommand } from "./lib/install.js"
77
import { stat, readlink } from "node:fs/promises"

0 commit comments

Comments
 (0)