@jayrdeaton/scripts 1.1.0 → 1.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/bin/cli.mjs +3 -3
- package/package.json +2 -2
- package/src/commands/base64.mjs +4 -4
- package/src/commands/binary.mjs +4 -4
- package/src/commands/bump-ota.mjs +2 -2
- package/src/commands/check-domains.mjs +2 -2
- package/src/commands/clean-builds.mjs +2 -2
- package/src/commands/clean-junk.mjs +2 -2
- package/src/commands/code-count.mjs +2 -2
- package/src/commands/find-dep.mjs +2 -2
- package/src/commands/focus.mjs +2 -2
- package/src/commands/folder-sizes.mjs +2 -2
- package/src/commands/new-expo-project.mjs +2 -2
- package/src/commands/npm-downloads.mjs +2 -2
- package/src/commands/npm-namer.mjs +2 -2
- package/src/commands/rename-season.mjs +2 -2
- package/src/commands/repo-status.mjs +2 -2
- package/src/commands/update-boilerplate.mjs +2 -2
- package/src/commands/update-deps.mjs +2 -2
package/bin/cli.mjs
CHANGED
|
@@ -3,13 +3,13 @@ import { readdirSync } from 'node:fs'
|
|
|
3
3
|
import { dirname, resolve } from 'node:path'
|
|
4
4
|
import { fileURLToPath } from 'node:url'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { Program } from 'termkit'
|
|
7
7
|
|
|
8
8
|
const __dir = dirname(fileURLToPath(import.meta.url))
|
|
9
9
|
const commandsDir = resolve(__dir, '../src/commands')
|
|
10
10
|
|
|
11
11
|
// Must be created first so termkit registers this as the root command
|
|
12
|
-
const program = command('jrd').description('Personal dev scripts')
|
|
12
|
+
const program = Program.command('jrd').description('Personal dev scripts')
|
|
13
13
|
|
|
14
14
|
const files = readdirSync(commandsDir).filter((f) => f.endsWith('.mjs'))
|
|
15
15
|
const mods = await Promise.all(files.map((f) => import(`../src/commands/${f}`)))
|
|
@@ -17,7 +17,7 @@ const mods = await Promise.all(files.map((f) => import(`../src/commands/${f}`)))
|
|
|
17
17
|
program.commands(mods.map((m) => m.command))
|
|
18
18
|
|
|
19
19
|
try {
|
|
20
|
-
await parse(process.argv)
|
|
20
|
+
await Program.parse(process.argv)
|
|
21
21
|
} catch (err) {
|
|
22
22
|
console.error(err.message)
|
|
23
23
|
process.exit(1)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jayrdeaton/scripts",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Personal dev scripts",
|
|
6
6
|
"repository": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"preversion": "npm ci && npm run lint"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"termkit": "
|
|
29
|
+
"termkit": "^2.2.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"eslint": "^10.4.1",
|
package/src/commands/base64.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'node:fs'
|
|
2
2
|
import { execSync } from 'node:child_process'
|
|
3
3
|
|
|
4
|
-
import { Color,
|
|
4
|
+
import { Color, Program } from 'termkit'
|
|
5
5
|
|
|
6
6
|
function resolveInput(value, file) {
|
|
7
7
|
if (file) {
|
|
@@ -20,10 +20,10 @@ function output(result, copy) {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export const command =
|
|
23
|
+
export const command = Program.command('base64')
|
|
24
24
|
.description('Encode or decode base64')
|
|
25
25
|
.commands([
|
|
26
|
-
|
|
26
|
+
Program.command('encode')
|
|
27
27
|
.description('Encode a string or file to base64')
|
|
28
28
|
.variable('<value>')
|
|
29
29
|
.option('f', 'file', null, 'treat value as a file path')
|
|
@@ -34,7 +34,7 @@ export const command = createCommand('base64')
|
|
|
34
34
|
output(result, copy)
|
|
35
35
|
}),
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
Program.command('decode')
|
|
38
38
|
.description('Decode a base64 string')
|
|
39
39
|
.variable('<value>')
|
|
40
40
|
.option('c', 'copy', null, 'copy result to clipboard')
|
package/src/commands/binary.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
|
2
2
|
import { execSync } from 'node:child_process'
|
|
3
3
|
|
|
4
|
-
import { Color,
|
|
4
|
+
import { Color, Program } from 'termkit'
|
|
5
5
|
|
|
6
|
-
export const command =
|
|
6
|
+
export const command = Program.command('binary')
|
|
7
7
|
.description('Encode or decode binary strings')
|
|
8
8
|
.commands([
|
|
9
|
-
|
|
9
|
+
Program.command('encode')
|
|
10
10
|
.description('Encode a file to a binary string')
|
|
11
11
|
.variable('<file>')
|
|
12
12
|
.option('c', 'copy', null, 'copy result to clipboard')
|
|
@@ -25,7 +25,7 @@ export const command = createCommand('binary')
|
|
|
25
25
|
}
|
|
26
26
|
}),
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
Program.command('decode')
|
|
29
29
|
.description('Restore a binary string file back to its original format')
|
|
30
30
|
.variable('<file>')
|
|
31
31
|
.variable('<destination>')
|
|
@@ -2,9 +2,9 @@ import { execSync } from 'node:child_process'
|
|
|
2
2
|
import { readFileSync, writeFileSync } from 'node:fs'
|
|
3
3
|
import { resolve } from 'node:path'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Program, Spinner } from 'termkit'
|
|
6
6
|
|
|
7
|
-
export const command =
|
|
7
|
+
export const command = Program.command('bump-ota')
|
|
8
8
|
.description('Bump otaVersion in src/constants/release.ts and commit')
|
|
9
9
|
.option('f', 'file', '[file]', 'Path to release file (default: src/constants/release.ts)')
|
|
10
10
|
.action(async (options) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { writeFile } from 'node:fs/promises'
|
|
2
2
|
|
|
3
|
-
import { Color,
|
|
3
|
+
import { Color, Program, Spinner } from 'termkit'
|
|
4
4
|
|
|
5
5
|
const RDAP = {
|
|
6
6
|
com: 'https://rdap.verisign.com/com/v1',
|
|
@@ -46,7 +46,7 @@ async function withConcurrency(items, limit, fn) {
|
|
|
46
46
|
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker))
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export const command =
|
|
49
|
+
export const command = Program.command('check-domains')
|
|
50
50
|
.description('Check domain availability via RDAP for a wildcard pattern (? = any letter)')
|
|
51
51
|
.variable('[pattern]')
|
|
52
52
|
.option('c', 'concurrency', '<n>', 'Concurrent requests (default: 5)')
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readdirSync, rmSync, statSync } from 'node:fs'
|
|
2
2
|
import { join, resolve } from 'node:path'
|
|
3
3
|
|
|
4
|
-
import { Color,
|
|
4
|
+
import { Color, Program, Spinner } from 'termkit'
|
|
5
5
|
|
|
6
6
|
const BUILD_TARGETS = ['build', 'dist', 'ios', 'android']
|
|
7
7
|
|
|
@@ -64,7 +64,7 @@ function resolveProjects(dirs) {
|
|
|
64
64
|
return projects
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
export const command =
|
|
67
|
+
export const command = Program.command('clean-builds')
|
|
68
68
|
.description('Delete build artifacts across repos — dry run by default')
|
|
69
69
|
.variable('[dir...]')
|
|
70
70
|
.option('m', 'modules', null, 'Also delete node_modules')
|
|
@@ -3,7 +3,7 @@ import { readdirSync, rmSync, statSync } from 'node:fs'
|
|
|
3
3
|
import { createInterface } from 'node:readline'
|
|
4
4
|
import { join, resolve } from 'node:path'
|
|
5
5
|
|
|
6
|
-
import { Color,
|
|
6
|
+
import { Color, Program, Spinner } from 'termkit'
|
|
7
7
|
|
|
8
8
|
function prompt(question) {
|
|
9
9
|
return new Promise((res) => {
|
|
@@ -41,7 +41,7 @@ function getItemSize(itemPath) {
|
|
|
41
41
|
return total
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export const command =
|
|
44
|
+
export const command = Program.command('clean-junk')
|
|
45
45
|
.description('Delete files and directories matching given criteria')
|
|
46
46
|
.variable('[dir]')
|
|
47
47
|
.option('i', 'includes', '<str>', 'Delete items whose name includes this string')
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createReadStream, existsSync, lstatSync, readdirSync } from 'node:fs'
|
|
2
2
|
import { extname, join, resolve } from 'node:path'
|
|
3
3
|
|
|
4
|
-
import { Color,
|
|
4
|
+
import { Color, Program, Spinner } from 'termkit'
|
|
5
5
|
|
|
6
6
|
const WHITELIST = new Set(['.cjs', '.css', '.csv', '.ejs', '.env', '.gitignore', '.haml', '.html', '.java', '.js', '.json', '.mjs', '.paw', '.plist', '.py', '.rake', '.scss', '.sh', '.sql', '.stl', '.swift', '.ts', '.tsx', '.txt', '.xib', '.xml', '.yaml', '.yml'])
|
|
7
7
|
|
|
@@ -48,7 +48,7 @@ function commaString(n) {
|
|
|
48
48
|
return n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
export const command =
|
|
51
|
+
export const command = Program.command('code-count')
|
|
52
52
|
.description('Count lines of code by file type')
|
|
53
53
|
.variable('[paths...]')
|
|
54
54
|
.option('i', 'ignore', '[types...]', 'ignore files or file types')
|
|
@@ -2,7 +2,7 @@ import { readFileSync, readdirSync, statSync } from 'node:fs'
|
|
|
2
2
|
import { homedir } from 'node:os'
|
|
3
3
|
import { join, resolve } from 'node:path'
|
|
4
4
|
|
|
5
|
-
import { Color,
|
|
5
|
+
import { Color, Program, Spinner } from 'termkit'
|
|
6
6
|
|
|
7
7
|
const DEP_FIELDS = ['dependencies', 'devDependencies', 'peerDependencies']
|
|
8
8
|
|
|
@@ -27,7 +27,7 @@ function findMatches(pkgPath, targets) {
|
|
|
27
27
|
return found.length ? { projectName: pkg.name, found } : null
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export const command =
|
|
30
|
+
export const command = Program.command('find-dep', '[deps...]')
|
|
31
31
|
.description('Find projects in a directory that use any of the given dependencies')
|
|
32
32
|
.option('d', 'dir', '[dir]', 'Root directory to scan (default: ~/Developer)')
|
|
33
33
|
.action(async (options) => {
|
package/src/commands/focus.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { execSync } from 'node:child_process'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Program } from 'termkit'
|
|
4
4
|
|
|
5
|
-
export const command =
|
|
5
|
+
export const command = Program.command('focus')
|
|
6
6
|
.description('Bring an application to the front')
|
|
7
7
|
.variable('[app]')
|
|
8
8
|
.action((args) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readdirSync, statSync } from 'node:fs'
|
|
2
2
|
import { join, resolve } from 'node:path'
|
|
3
3
|
|
|
4
|
-
import { Color,
|
|
4
|
+
import { Color, Program, Spinner } from 'termkit'
|
|
5
5
|
|
|
6
6
|
function getDirSize(dirPath) {
|
|
7
7
|
let total = 0
|
|
@@ -28,7 +28,7 @@ function formatSize(bytes) {
|
|
|
28
28
|
return `${bytes} B`
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export const command =
|
|
31
|
+
export const command = Program.command('folder-sizes')
|
|
32
32
|
.description('List folders sorted by size, largest first')
|
|
33
33
|
.variable('[dir]')
|
|
34
34
|
.action(async (args) => {
|
|
@@ -3,7 +3,7 @@ import { cpSync, existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs
|
|
|
3
3
|
import { homedir } from 'node:os'
|
|
4
4
|
import { join } from 'node:path'
|
|
5
5
|
|
|
6
|
-
import { Color,
|
|
6
|
+
import { Color, Program, log } from 'termkit'
|
|
7
7
|
|
|
8
8
|
const BOILERPLATE_REPO = 'git@github.com:jayrdeaton/Expo-Boilerplate.git'
|
|
9
9
|
const BOILERPLATE_DIR = join(homedir(), 'Developer', 'Expo-Boilerplate')
|
|
@@ -21,7 +21,7 @@ function parseWords(name) {
|
|
|
21
21
|
.filter(Boolean)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export const command =
|
|
24
|
+
export const command = Program.command('new-expo-project')
|
|
25
25
|
.description('Bootstrap a new Expo project from the boilerplate')
|
|
26
26
|
.option('n', 'name', '<name>', 'Project name')
|
|
27
27
|
.action(async (options) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { execSync } from 'node:child_process'
|
|
2
2
|
|
|
3
|
-
import { Color,
|
|
3
|
+
import { Color, Program, Spinner } from 'termkit'
|
|
4
4
|
|
|
5
5
|
async function fetchJson(url) {
|
|
6
6
|
const res = await fetch(url)
|
|
@@ -32,7 +32,7 @@ async function getDownloads(pkg, period) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export const command =
|
|
35
|
+
export const command = Program.command('npm-downloads')
|
|
36
36
|
.description('List all your npm packages sorted by total downloads')
|
|
37
37
|
.option('u', 'user', '<name>', 'npm username (defaults to npm whoami)')
|
|
38
38
|
.option('p', 'period', '<period>', 'last-day | last-week | last-month | last-year (default: last-month)')
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Color,
|
|
1
|
+
import { Color, Program, Spinner } from 'termkit'
|
|
2
2
|
|
|
3
3
|
async function isAvailable(name) {
|
|
4
4
|
try {
|
|
@@ -32,7 +32,7 @@ async function getSynonyms(word) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export const command =
|
|
35
|
+
export const command = Program.command('npm-namer')
|
|
36
36
|
.description('Check npm package name availability, including variations')
|
|
37
37
|
.variable('<name>')
|
|
38
38
|
.option('s', 'synonyms', null, 'Also check synonyms of the name')
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { readdirSync, renameSync, statSync } from 'node:fs'
|
|
2
2
|
import { extname, join } from 'node:path'
|
|
3
3
|
|
|
4
|
-
import { Color,
|
|
4
|
+
import { Color, Program, log } from 'termkit'
|
|
5
5
|
|
|
6
|
-
export const command =
|
|
6
|
+
export const command = Program.command('rename-season')
|
|
7
7
|
.description('Rename files in a directory to SxEE format for TV library pickup')
|
|
8
8
|
.variable('<season> [dir]')
|
|
9
9
|
.action(async (args) => {
|
|
@@ -2,7 +2,7 @@ import { execSync } from 'node:child_process'
|
|
|
2
2
|
import { readdirSync, statSync } from 'node:fs'
|
|
3
3
|
import { join, resolve } from 'node:path'
|
|
4
4
|
|
|
5
|
-
import { Color,
|
|
5
|
+
import { Color, Program, Spinner } from 'termkit'
|
|
6
6
|
|
|
7
7
|
function getGitStatus(dir) {
|
|
8
8
|
try {
|
|
@@ -33,7 +33,7 @@ function getGitStatus(dir) {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export const command =
|
|
36
|
+
export const command = Program.command('repo-status')
|
|
37
37
|
.description('Report dirty and untracked files across repos in a directory')
|
|
38
38
|
.variable('[dir]')
|
|
39
39
|
.action(async (args) => {
|
|
@@ -3,7 +3,7 @@ import { existsSync } from 'node:fs'
|
|
|
3
3
|
import { homedir } from 'node:os'
|
|
4
4
|
import { join } from 'node:path'
|
|
5
5
|
|
|
6
|
-
import { Color,
|
|
6
|
+
import { Color, Program, log } from 'termkit'
|
|
7
7
|
|
|
8
8
|
const BOILERPLATE_REPO = 'git@github.com:jayrdeaton/Expo-Boilerplate.git'
|
|
9
9
|
const BOILERPLATE_DIR = join(homedir(), 'Developer', 'Expo-Boilerplate')
|
|
@@ -13,7 +13,7 @@ function exec(cmd, opts = {}) {
|
|
|
13
13
|
execSync(cmd, { stdio: 'inherit', ...opts })
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const command =
|
|
16
|
+
export const command = Program.command('update-boilerplate')
|
|
17
17
|
.description('Update Expo boilerplate — clones if absent, updates deps, commits, and pushes')
|
|
18
18
|
.action(async () => {
|
|
19
19
|
if (existsSync(BOILERPLATE_DIR)) {
|
|
@@ -2,7 +2,7 @@ import { execSync } from 'node:child_process'
|
|
|
2
2
|
import { readFileSync } from 'node:fs'
|
|
3
3
|
import { resolve } from 'node:path'
|
|
4
4
|
|
|
5
|
-
import { Color,
|
|
5
|
+
import { Color, Program, log } from 'termkit'
|
|
6
6
|
|
|
7
7
|
function exec(cmd) {
|
|
8
8
|
console.log(Color.faint(`$ ${cmd}`))
|
|
@@ -13,7 +13,7 @@ function latestPackages(deps = {}) {
|
|
|
13
13
|
return Object.keys(deps).map((name) => `${name}@latest`)
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const command =
|
|
16
|
+
export const command = Program.command('update-deps')
|
|
17
17
|
.description('Update all npm deps to @latest, then run expo install --fix if applicable')
|
|
18
18
|
.option('d', 'dev', null, 'Only update devDependencies')
|
|
19
19
|
.option('p', 'prod', null, 'Only update dependencies')
|