@jayrdeaton/scripts 1.1.3 → 1.1.5
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
CHANGED
|
@@ -149,6 +149,19 @@ Example: `jrd find-dep react-native expo`
|
|
|
149
149
|
|
|
150
150
|
---
|
|
151
151
|
|
|
152
|
+
### `jrd find-overrides`
|
|
153
|
+
|
|
154
|
+
Find projects in a directory that have an `overrides` field in their `package.json`.
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
jrd find-overrides [options]
|
|
158
|
+
|
|
159
|
+
Options:
|
|
160
|
+
-d, --dir <dir> Root directory to scan (default: ~/Developer)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
152
165
|
### `jrd find-script`
|
|
153
166
|
|
|
154
167
|
Find projects in a directory whose `package.json` scripts contain an exact command value.
|
|
@@ -321,7 +334,7 @@ jrd update-boilerplate
|
|
|
321
334
|
|
|
322
335
|
### `jrd update-deps`
|
|
323
336
|
|
|
324
|
-
Update all npm dependencies to `@latest`. Automatically runs `npx expo install --fix` if the project uses Expo.
|
|
337
|
+
Update all npm dependencies to `@latest`. Automatically runs `npx expo install --fix` if the project uses Expo. Skips any dependency whose version is not a plain version number — `file:`, `yalc:`, `link:`, `workspace:`, and similar non-registry entries are left untouched.
|
|
325
338
|
|
|
326
339
|
```
|
|
327
340
|
jrd update-deps [options]
|
package/package.json
CHANGED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
|
|
2
|
+
import { homedir } from 'node:os'
|
|
3
|
+
import { join, resolve } from 'node:path'
|
|
4
|
+
|
|
5
|
+
import { Color, Program, Spinner } from 'termkit'
|
|
6
|
+
|
|
7
|
+
function findOverrides(pkgPath) {
|
|
8
|
+
let pkg
|
|
9
|
+
try {
|
|
10
|
+
pkg = JSON.parse(readFileSync(pkgPath, 'utf8'))
|
|
11
|
+
} catch {
|
|
12
|
+
return null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const overrides = pkg.overrides ?? {}
|
|
16
|
+
const entries = Object.entries(overrides)
|
|
17
|
+
|
|
18
|
+
return { projectName: pkg.name, entries }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const command = Program.command('find-overrides')
|
|
22
|
+
.description('Find projects in a directory that have overrides in their package.json')
|
|
23
|
+
.option('d', 'dir', '[dir]', 'Root directory to scan (default: ~/Developer)')
|
|
24
|
+
.action(async (options) => {
|
|
25
|
+
const root = resolve(options.dir ?? join(homedir(), 'Developer'))
|
|
26
|
+
|
|
27
|
+
let entries
|
|
28
|
+
try {
|
|
29
|
+
entries = readdirSync(root)
|
|
30
|
+
} catch {
|
|
31
|
+
console.error(Color.red(`Could not read directory: ${root}`))
|
|
32
|
+
process.exit(1)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const spinner = new Spinner({ text: 'Scanning projects...' })
|
|
36
|
+
spinner.start()
|
|
37
|
+
|
|
38
|
+
const results = []
|
|
39
|
+
|
|
40
|
+
for (const name of entries) {
|
|
41
|
+
const dir = join(root, name)
|
|
42
|
+
try {
|
|
43
|
+
if (!statSync(dir).isDirectory()) continue
|
|
44
|
+
} catch {
|
|
45
|
+
continue
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
spinner.message(name)
|
|
49
|
+
|
|
50
|
+
const pkgPath = join(dir, 'package.json')
|
|
51
|
+
if (!existsSync(pkgPath)) continue
|
|
52
|
+
|
|
53
|
+
const { projectName, entries: overrideEntries } = findOverrides(pkgPath)
|
|
54
|
+
|
|
55
|
+
if (overrideEntries.length) {
|
|
56
|
+
results.push({ dir: name, projectName, overrideEntries })
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!results.length) {
|
|
61
|
+
spinner.succeed('No projects with overrides found')
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
spinner.stop()
|
|
66
|
+
|
|
67
|
+
console.log(Color.bold(`\n${results.length} project${results.length !== 1 ? 's' : ''} with overrides:\n`))
|
|
68
|
+
|
|
69
|
+
for (const result of results) {
|
|
70
|
+
const label =
|
|
71
|
+
result.projectName && result.projectName !== result.dir
|
|
72
|
+
? `${Color.bold(result.dir)} ${Color.faint(`(${result.projectName})`)}`
|
|
73
|
+
: Color.bold(result.dir)
|
|
74
|
+
|
|
75
|
+
console.log(` ${label}`)
|
|
76
|
+
|
|
77
|
+
for (const [pkg, version] of result.overrideEntries) {
|
|
78
|
+
console.log(` ${Color.cyan(pkg)} ${Color.faint(typeof version === 'string' ? version : JSON.stringify(version))}`)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
console.log()
|
|
83
|
+
})
|
|
@@ -65,10 +65,7 @@ export const command = Program.command('find-script', '<command>')
|
|
|
65
65
|
console.log(Color.bold(`\nFound ${results.length} project${results.length !== 1 ? 's' : ''}:\n`))
|
|
66
66
|
|
|
67
67
|
for (const result of results) {
|
|
68
|
-
const label =
|
|
69
|
-
result.projectName && result.projectName !== result.dir
|
|
70
|
-
? `${Color.bold(result.dir)} ${Color.faint(`(${result.projectName})`)}`
|
|
71
|
-
: Color.bold(result.dir)
|
|
68
|
+
const label = result.projectName && result.projectName !== result.dir ? `${Color.bold(result.dir)} ${Color.faint(`(${result.projectName})`)}` : Color.bold(result.dir)
|
|
72
69
|
|
|
73
70
|
console.log(` ${label}`)
|
|
74
71
|
|
|
@@ -10,7 +10,9 @@ function exec(cmd) {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
function latestPackages(deps = {}) {
|
|
13
|
-
return Object.
|
|
13
|
+
return Object.entries(deps)
|
|
14
|
+
.filter(([, version]) => /^\^?[\d*]/.test(version))
|
|
15
|
+
.map(([name]) => `${name}@latest`)
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
export const command = Program.command('update-deps')
|
|
@@ -77,10 +77,7 @@ export const command = Program.command('yalc-check')
|
|
|
77
77
|
console.log(Color.bold(`\n${results.length} project${results.length !== 1 ? 's' : ''} with yalc dependencies:\n`))
|
|
78
78
|
|
|
79
79
|
for (const result of results) {
|
|
80
|
-
const label =
|
|
81
|
-
result.projectName && result.projectName !== result.dir
|
|
82
|
-
? `${Color.bold(result.dir)} ${Color.faint(`(${result.projectName})`)}`
|
|
83
|
-
: Color.bold(result.dir)
|
|
80
|
+
const label = result.projectName && result.projectName !== result.dir ? `${Color.bold(result.dir)} ${Color.faint(`(${result.projectName})`)}` : Color.bold(result.dir)
|
|
84
81
|
|
|
85
82
|
const lockNote = result.hasLock && !result.found.length ? Color.yellow(' yalc.lock present') : ''
|
|
86
83
|
console.log(` ${label}${lockNote}`)
|