@take-out/cli 0.0.39
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 +274 -0
- package/cli.mjs +3 -0
- package/dist/cjs/cli.cjs +71 -0
- package/dist/cjs/cli.js +70 -0
- package/dist/cjs/cli.js.map +6 -0
- package/dist/cjs/cli.native.js +79 -0
- package/dist/cjs/cli.native.js.map +6 -0
- package/dist/cjs/commands/changed.cjs +212 -0
- package/dist/cjs/commands/changed.js +214 -0
- package/dist/cjs/commands/changed.js.map +6 -0
- package/dist/cjs/commands/changed.native.js +289 -0
- package/dist/cjs/commands/changed.native.js.map +6 -0
- package/dist/cjs/commands/docs.cjs +388 -0
- package/dist/cjs/commands/docs.js +313 -0
- package/dist/cjs/commands/docs.js.map +6 -0
- package/dist/cjs/commands/docs.native.js +476 -0
- package/dist/cjs/commands/docs.native.js.map +6 -0
- package/dist/cjs/commands/env-setup.cjs +90 -0
- package/dist/cjs/commands/env-setup.js +78 -0
- package/dist/cjs/commands/env-setup.js.map +6 -0
- package/dist/cjs/commands/env-setup.native.js +85 -0
- package/dist/cjs/commands/env-setup.native.js.map +6 -0
- package/dist/cjs/commands/onboard.cjs +479 -0
- package/dist/cjs/commands/onboard.js +631 -0
- package/dist/cjs/commands/onboard.js.map +6 -0
- package/dist/cjs/commands/onboard.native.js +608 -0
- package/dist/cjs/commands/onboard.native.js.map +6 -0
- package/dist/cjs/commands/run.cjs +148 -0
- package/dist/cjs/commands/run.js +116 -0
- package/dist/cjs/commands/run.js.map +6 -0
- package/dist/cjs/commands/run.native.js +140 -0
- package/dist/cjs/commands/run.native.js.map +6 -0
- package/dist/cjs/commands/script.cjs +379 -0
- package/dist/cjs/commands/script.js +339 -0
- package/dist/cjs/commands/script.js.map +6 -0
- package/dist/cjs/commands/script.native.js +449 -0
- package/dist/cjs/commands/script.native.js.map +6 -0
- package/dist/cjs/commands/sync.cjs +190 -0
- package/dist/cjs/commands/sync.js +168 -0
- package/dist/cjs/commands/sync.js.map +6 -0
- package/dist/cjs/commands/sync.native.js +211 -0
- package/dist/cjs/commands/sync.native.js.map +6 -0
- package/dist/cjs/constants/ascii.cjs +36 -0
- package/dist/cjs/constants/ascii.js +30 -0
- package/dist/cjs/constants/ascii.js.map +6 -0
- package/dist/cjs/constants/ascii.native.js +36 -0
- package/dist/cjs/constants/ascii.native.js.map +6 -0
- package/dist/cjs/index.cjs +64 -0
- package/dist/cjs/index.js +55 -0
- package/dist/cjs/index.js.map +6 -0
- package/dist/cjs/index.native.js +94 -0
- package/dist/cjs/index.native.js.map +6 -0
- package/dist/cjs/types.cjs +16 -0
- package/dist/cjs/types.js +14 -0
- package/dist/cjs/types.js.map +6 -0
- package/dist/cjs/types.native.js +15 -0
- package/dist/cjs/types.native.js.map +6 -0
- package/dist/cjs/utils/env-categories.cjs +272 -0
- package/dist/cjs/utils/env-categories.js +296 -0
- package/dist/cjs/utils/env-categories.js.map +6 -0
- package/dist/cjs/utils/env-categories.native.js +317 -0
- package/dist/cjs/utils/env-categories.native.js.map +6 -0
- package/dist/cjs/utils/env-setup.cjs +181 -0
- package/dist/cjs/utils/env-setup.js +190 -0
- package/dist/cjs/utils/env-setup.js.map +6 -0
- package/dist/cjs/utils/env-setup.native.js +264 -0
- package/dist/cjs/utils/env-setup.native.js.map +6 -0
- package/dist/cjs/utils/env.cjs +118 -0
- package/dist/cjs/utils/env.js +97 -0
- package/dist/cjs/utils/env.js.map +6 -0
- package/dist/cjs/utils/env.native.js +128 -0
- package/dist/cjs/utils/env.native.js.map +6 -0
- package/dist/cjs/utils/files.cjs +215 -0
- package/dist/cjs/utils/files.js +164 -0
- package/dist/cjs/utils/files.js.map +6 -0
- package/dist/cjs/utils/files.native.js +266 -0
- package/dist/cjs/utils/files.native.js.map +6 -0
- package/dist/cjs/utils/parallel-runner.cjs +99 -0
- package/dist/cjs/utils/parallel-runner.js +84 -0
- package/dist/cjs/utils/parallel-runner.js.map +6 -0
- package/dist/cjs/utils/parallel-runner.native.js +123 -0
- package/dist/cjs/utils/parallel-runner.native.js.map +6 -0
- package/dist/cjs/utils/ports.cjs +101 -0
- package/dist/cjs/utils/ports.js +81 -0
- package/dist/cjs/utils/ports.js.map +6 -0
- package/dist/cjs/utils/ports.native.js +130 -0
- package/dist/cjs/utils/ports.native.js.map +6 -0
- package/dist/cjs/utils/prerequisites.cjs +119 -0
- package/dist/cjs/utils/prerequisites.js +107 -0
- package/dist/cjs/utils/prerequisites.js.map +6 -0
- package/dist/cjs/utils/prerequisites.native.js +127 -0
- package/dist/cjs/utils/prerequisites.native.js.map +6 -0
- package/dist/cjs/utils/prompts.cjs +161 -0
- package/dist/cjs/utils/prompts.js +162 -0
- package/dist/cjs/utils/prompts.js.map +6 -0
- package/dist/cjs/utils/prompts.native.js +179 -0
- package/dist/cjs/utils/prompts.native.js.map +6 -0
- package/dist/cjs/utils/script-listing.cjs +113 -0
- package/dist/cjs/utils/script-listing.js +108 -0
- package/dist/cjs/utils/script-listing.js.map +6 -0
- package/dist/cjs/utils/script-listing.native.js +174 -0
- package/dist/cjs/utils/script-listing.native.js.map +6 -0
- package/dist/cjs/utils/sync.cjs +85 -0
- package/dist/cjs/utils/sync.js +70 -0
- package/dist/cjs/utils/sync.js.map +6 -0
- package/dist/cjs/utils/sync.native.js +84 -0
- package/dist/cjs/utils/sync.native.js.map +6 -0
- package/dist/cjs/utils/welcome.cjs +50 -0
- package/dist/cjs/utils/welcome.js +42 -0
- package/dist/cjs/utils/welcome.js.map +6 -0
- package/dist/cjs/utils/welcome.native.js +47 -0
- package/dist/cjs/utils/welcome.native.js.map +6 -0
- package/dist/esm/cli.js +79 -0
- package/dist/esm/cli.js.map +6 -0
- package/dist/esm/cli.mjs +71 -0
- package/dist/esm/cli.mjs.map +1 -0
- package/dist/esm/cli.native.js +69 -0
- package/dist/esm/cli.native.js.map +1 -0
- package/dist/esm/commands/changed.js +194 -0
- package/dist/esm/commands/changed.js.map +6 -0
- package/dist/esm/commands/changed.mjs +178 -0
- package/dist/esm/commands/changed.mjs.map +1 -0
- package/dist/esm/commands/changed.native.js +273 -0
- package/dist/esm/commands/changed.native.js.map +1 -0
- package/dist/esm/commands/docs.js +306 -0
- package/dist/esm/commands/docs.js.map +6 -0
- package/dist/esm/commands/docs.mjs +353 -0
- package/dist/esm/commands/docs.mjs.map +1 -0
- package/dist/esm/commands/docs.native.js +516 -0
- package/dist/esm/commands/docs.native.js.map +1 -0
- package/dist/esm/commands/env-setup.js +56 -0
- package/dist/esm/commands/env-setup.js.map +6 -0
- package/dist/esm/commands/env-setup.mjs +56 -0
- package/dist/esm/commands/env-setup.mjs.map +1 -0
- package/dist/esm/commands/env-setup.native.js +59 -0
- package/dist/esm/commands/env-setup.native.js.map +1 -0
- package/dist/esm/commands/onboard.js +645 -0
- package/dist/esm/commands/onboard.js.map +6 -0
- package/dist/esm/commands/onboard.mjs +445 -0
- package/dist/esm/commands/onboard.mjs.map +1 -0
- package/dist/esm/commands/onboard.native.js +584 -0
- package/dist/esm/commands/onboard.native.js.map +1 -0
- package/dist/esm/commands/run.js +95 -0
- package/dist/esm/commands/run.js.map +6 -0
- package/dist/esm/commands/run.mjs +114 -0
- package/dist/esm/commands/run.mjs.map +1 -0
- package/dist/esm/commands/run.native.js +133 -0
- package/dist/esm/commands/run.native.js.map +1 -0
- package/dist/esm/commands/script.js +338 -0
- package/dist/esm/commands/script.js.map +6 -0
- package/dist/esm/commands/script.mjs +336 -0
- package/dist/esm/commands/script.mjs.map +1 -0
- package/dist/esm/commands/script.native.js +445 -0
- package/dist/esm/commands/script.native.js.map +1 -0
- package/dist/esm/commands/sync.js +158 -0
- package/dist/esm/commands/sync.js.map +6 -0
- package/dist/esm/commands/sync.mjs +155 -0
- package/dist/esm/commands/sync.mjs.map +1 -0
- package/dist/esm/commands/sync.native.js +173 -0
- package/dist/esm/commands/sync.native.js.map +1 -0
- package/dist/esm/constants/ascii.js +14 -0
- package/dist/esm/constants/ascii.js.map +6 -0
- package/dist/esm/constants/ascii.mjs +12 -0
- package/dist/esm/constants/ascii.mjs.map +1 -0
- package/dist/esm/constants/ascii.native.js +12 -0
- package/dist/esm/constants/ascii.native.js.map +1 -0
- package/dist/esm/index.js +83 -0
- package/dist/esm/index.js.map +6 -0
- package/dist/esm/index.mjs +7 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +7 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +6 -0
- package/dist/esm/types.mjs +2 -0
- package/dist/esm/types.mjs.map +1 -0
- package/dist/esm/types.native.js +2 -0
- package/dist/esm/types.native.js.map +1 -0
- package/dist/esm/utils/env-categories.js +272 -0
- package/dist/esm/utils/env-categories.js.map +6 -0
- package/dist/esm/utils/env-categories.mjs +233 -0
- package/dist/esm/utils/env-categories.mjs.map +1 -0
- package/dist/esm/utils/env-categories.native.js +246 -0
- package/dist/esm/utils/env-categories.native.js.map +1 -0
- package/dist/esm/utils/env-setup.js +173 -0
- package/dist/esm/utils/env-setup.js.map +6 -0
- package/dist/esm/utils/env-setup.mjs +146 -0
- package/dist/esm/utils/env-setup.mjs.map +1 -0
- package/dist/esm/utils/env-setup.native.js +243 -0
- package/dist/esm/utils/env-setup.native.js.map +1 -0
- package/dist/esm/utils/env.js +83 -0
- package/dist/esm/utils/env.js.map +6 -0
- package/dist/esm/utils/env.mjs +90 -0
- package/dist/esm/utils/env.mjs.map +1 -0
- package/dist/esm/utils/env.native.js +99 -0
- package/dist/esm/utils/env.native.js.map +1 -0
- package/dist/esm/utils/files.js +150 -0
- package/dist/esm/utils/files.js.map +6 -0
- package/dist/esm/utils/files.mjs +187 -0
- package/dist/esm/utils/files.mjs.map +1 -0
- package/dist/esm/utils/files.native.js +247 -0
- package/dist/esm/utils/files.native.js.map +1 -0
- package/dist/esm/utils/parallel-runner.js +69 -0
- package/dist/esm/utils/parallel-runner.js.map +6 -0
- package/dist/esm/utils/parallel-runner.mjs +76 -0
- package/dist/esm/utils/parallel-runner.mjs.map +1 -0
- package/dist/esm/utils/parallel-runner.native.js +109 -0
- package/dist/esm/utils/parallel-runner.native.js.map +1 -0
- package/dist/esm/utils/ports.js +65 -0
- package/dist/esm/utils/ports.js.map +6 -0
- package/dist/esm/utils/ports.mjs +74 -0
- package/dist/esm/utils/ports.mjs.map +1 -0
- package/dist/esm/utils/ports.native.js +93 -0
- package/dist/esm/utils/ports.native.js.map +1 -0
- package/dist/esm/utils/prerequisites.js +91 -0
- package/dist/esm/utils/prerequisites.js.map +6 -0
- package/dist/esm/utils/prerequisites.mjs +91 -0
- package/dist/esm/utils/prerequisites.mjs.map +1 -0
- package/dist/esm/utils/prerequisites.native.js +97 -0
- package/dist/esm/utils/prerequisites.native.js.map +1 -0
- package/dist/esm/utils/prompts.js +139 -0
- package/dist/esm/utils/prompts.js.map +6 -0
- package/dist/esm/utils/prompts.mjs +112 -0
- package/dist/esm/utils/prompts.mjs.map +1 -0
- package/dist/esm/utils/prompts.native.js +115 -0
- package/dist/esm/utils/prompts.native.js.map +1 -0
- package/dist/esm/utils/script-listing.js +91 -0
- package/dist/esm/utils/script-listing.js.map +6 -0
- package/dist/esm/utils/script-listing.mjs +76 -0
- package/dist/esm/utils/script-listing.mjs.map +1 -0
- package/dist/esm/utils/script-listing.native.js +151 -0
- package/dist/esm/utils/script-listing.native.js.map +1 -0
- package/dist/esm/utils/sync.js +50 -0
- package/dist/esm/utils/sync.js.map +6 -0
- package/dist/esm/utils/sync.mjs +48 -0
- package/dist/esm/utils/sync.mjs.map +1 -0
- package/dist/esm/utils/sync.native.js +53 -0
- package/dist/esm/utils/sync.native.js.map +1 -0
- package/dist/esm/utils/welcome.js +21 -0
- package/dist/esm/utils/welcome.js.map +6 -0
- package/dist/esm/utils/welcome.mjs +15 -0
- package/dist/esm/utils/welcome.mjs.map +1 -0
- package/dist/esm/utils/welcome.native.js +18 -0
- package/dist/esm/utils/welcome.native.js.map +1 -0
- package/docs/aggregates.md +579 -0
- package/docs/cloudflare-dev-tunnel.md +41 -0
- package/docs/database.md +203 -0
- package/docs/docs.md +8 -0
- package/docs/emitters.md +562 -0
- package/docs/hot-updater.md +223 -0
- package/docs/native-hot-update.md +252 -0
- package/docs/one-components.md +234 -0
- package/docs/one-hooks.md +570 -0
- package/docs/one-routes.md +660 -0
- package/docs/package-json.md +115 -0
- package/docs/react-native-navigation-flow.md +184 -0
- package/docs/scripts.md +147 -0
- package/docs/sync-prompt.md +208 -0
- package/docs/tamagui.md +478 -0
- package/docs/testing-integration.md +564 -0
- package/docs/triggers.md +450 -0
- package/docs/zero.md +719 -0
- package/package.json +76 -0
- package/scripts/seed.ts +209 -0
- package/src/cli.ts +147 -0
- package/src/commands/changed.ts +313 -0
- package/src/commands/docs.ts +582 -0
- package/src/commands/env-setup.ts +69 -0
- package/src/commands/onboard.ts +1391 -0
- package/src/commands/run.ts +173 -0
- package/src/commands/script.ts +587 -0
- package/src/commands/sync.ts +305 -0
- package/src/constants/ascii.ts +17 -0
- package/src/index.ts +63 -0
- package/src/types.ts +59 -0
- package/src/utils/env-categories.ts +245 -0
- package/src/utils/env-setup.ts +338 -0
- package/src/utils/env.ts +127 -0
- package/src/utils/files.ts +302 -0
- package/src/utils/parallel-runner.ts +129 -0
- package/src/utils/ports.ts +77 -0
- package/src/utils/prerequisites.ts +137 -0
- package/src/utils/prompts.ts +197 -0
- package/src/utils/script-listing.ts +214 -0
- package/src/utils/sync.ts +101 -0
- package/src/withOpSqliteStatic.cjs +51 -0
- package/types/cli.d.ts +7 -0
- package/types/cli.d.ts.map +1 -0
- package/types/commands/changed.d.ts +14 -0
- package/types/commands/changed.d.ts.map +1 -0
- package/types/commands/docs.d.ts +5 -0
- package/types/commands/docs.d.ts.map +1 -0
- package/types/commands/env-setup.d.ts +25 -0
- package/types/commands/env-setup.d.ts.map +1 -0
- package/types/commands/onboard.d.ts +16 -0
- package/types/commands/onboard.d.ts.map +1 -0
- package/types/commands/run.d.ts +8 -0
- package/types/commands/run.d.ts.map +1 -0
- package/types/commands/script.d.ts +28 -0
- package/types/commands/script.d.ts.map +1 -0
- package/types/commands/sync.d.ts +5 -0
- package/types/commands/sync.d.ts.map +1 -0
- package/types/constants/ascii.d.ts +6 -0
- package/types/constants/ascii.d.ts.map +1 -0
- package/types/index.d.ts +12 -0
- package/types/index.d.ts.map +1 -0
- package/types/types.d.ts +54 -0
- package/types/types.d.ts.map +1 -0
- package/types/utils/env-categories.d.ts +8 -0
- package/types/utils/env-categories.d.ts.map +1 -0
- package/types/utils/env-setup.d.ts +10 -0
- package/types/utils/env-setup.d.ts.map +1 -0
- package/types/utils/env.d.ts +19 -0
- package/types/utils/env.d.ts.map +1 -0
- package/types/utils/files.d.ts +47 -0
- package/types/utils/files.d.ts.map +1 -0
- package/types/utils/parallel-runner.d.ts +15 -0
- package/types/utils/parallel-runner.d.ts.map +1 -0
- package/types/utils/ports.d.ts +16 -0
- package/types/utils/ports.d.ts.map +1 -0
- package/types/utils/prerequisites.d.ts +11 -0
- package/types/utils/prerequisites.d.ts.map +1 -0
- package/types/utils/prompts.d.ts +30 -0
- package/types/utils/prompts.d.ts.map +1 -0
- package/types/utils/script-listing.d.ts +7 -0
- package/types/utils/script-listing.d.ts.map +1 -0
- package/types/utils/sync.d.ts +16 -0
- package/types/utils/sync.d.ts.map +1 -0
- package/types/utils/welcome.d.ts +6 -0
- package/types/utils/welcome.d.ts.map +1 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Changed command - show what's changed in upstream Takeout since last sync
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { execSync } from 'node:child_process'
|
|
6
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
7
|
+
import { join } from 'node:path'
|
|
8
|
+
|
|
9
|
+
import { defineCommand } from 'citty'
|
|
10
|
+
import pc from 'picocolors'
|
|
11
|
+
|
|
12
|
+
const UPSTREAM_REPO = 'tamagui/takeout3'
|
|
13
|
+
const UPSTREAM_REMOTE = 'takeout-upstream'
|
|
14
|
+
const TAKEOUT_FILE = '.takeout'
|
|
15
|
+
|
|
16
|
+
const COMMIT_TYPE_ORDER = [
|
|
17
|
+
'feat',
|
|
18
|
+
'fix',
|
|
19
|
+
'perf',
|
|
20
|
+
'refactor',
|
|
21
|
+
'docs',
|
|
22
|
+
'chore',
|
|
23
|
+
'test',
|
|
24
|
+
'ci',
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
interface CommitInfo {
|
|
28
|
+
hash: string
|
|
29
|
+
type: string
|
|
30
|
+
scope?: string
|
|
31
|
+
message: string
|
|
32
|
+
breaking: boolean
|
|
33
|
+
date: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface TakeoutConfig {
|
|
37
|
+
sha?: string
|
|
38
|
+
date?: string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function readTakeoutConfig(): TakeoutConfig | null {
|
|
42
|
+
const configPath = join(process.cwd(), TAKEOUT_FILE)
|
|
43
|
+
|
|
44
|
+
if (!existsSync(configPath)) {
|
|
45
|
+
return null
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
const content = readFileSync(configPath, 'utf-8')
|
|
50
|
+
const config: TakeoutConfig = {}
|
|
51
|
+
|
|
52
|
+
for (const line of content.split('\n')) {
|
|
53
|
+
const trimmed = line.trim()
|
|
54
|
+
if (trimmed.startsWith('#') || !trimmed) continue
|
|
55
|
+
|
|
56
|
+
const [key, ...valueParts] = trimmed.split('=')
|
|
57
|
+
const value = valueParts.join('=').trim()
|
|
58
|
+
|
|
59
|
+
if (key === 'sha') config.sha = value
|
|
60
|
+
if (key === 'date') config.date = value
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return config
|
|
64
|
+
} catch {
|
|
65
|
+
return null
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function parseConventionalCommit(
|
|
70
|
+
message: string
|
|
71
|
+
): { type: string; scope?: string; message: string; breaking: boolean } | null {
|
|
72
|
+
// match conventional commit format: type(scope)!: message or type!: message
|
|
73
|
+
const match = message.match(/^(\w+)(?:\(([^)]+)\))?(!)?: (.+)$/)
|
|
74
|
+
if (!match) return null
|
|
75
|
+
|
|
76
|
+
const [, type, scope, breaking, msg] = match
|
|
77
|
+
|
|
78
|
+
// include all commit types for takeout
|
|
79
|
+
const validTypes = [
|
|
80
|
+
'feat',
|
|
81
|
+
'fix',
|
|
82
|
+
'perf',
|
|
83
|
+
'refactor',
|
|
84
|
+
'docs',
|
|
85
|
+
'chore',
|
|
86
|
+
'test',
|
|
87
|
+
'ci',
|
|
88
|
+
'build',
|
|
89
|
+
'style',
|
|
90
|
+
]
|
|
91
|
+
if (!validTypes.includes(type)) return null
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
type,
|
|
95
|
+
scope,
|
|
96
|
+
message: msg,
|
|
97
|
+
breaking: !!breaking || message.toLowerCase().includes('breaking'),
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function ensureUpstreamRemote(): boolean {
|
|
102
|
+
try {
|
|
103
|
+
// check if remote exists
|
|
104
|
+
const remotes = execSync('git remote', { encoding: 'utf-8' })
|
|
105
|
+
if (!remotes.includes(UPSTREAM_REMOTE)) {
|
|
106
|
+
console.info(pc.dim(` adding ${UPSTREAM_REMOTE} remote...`))
|
|
107
|
+
execSync(`git remote add ${UPSTREAM_REMOTE} git@github.com:${UPSTREAM_REPO}.git`, {
|
|
108
|
+
stdio: 'pipe',
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// fetch latest
|
|
113
|
+
console.info(pc.dim(` fetching from ${UPSTREAM_REMOTE}...`))
|
|
114
|
+
execSync(`git fetch ${UPSTREAM_REMOTE} --quiet`, { stdio: 'pipe' })
|
|
115
|
+
return true
|
|
116
|
+
} catch (err) {
|
|
117
|
+
console.error(pc.red(`failed to setup upstream remote: ${err}`))
|
|
118
|
+
return false
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function getCommitsBetween(fromSha: string, toRef: string): CommitInfo[] {
|
|
123
|
+
const commits: CommitInfo[] = []
|
|
124
|
+
|
|
125
|
+
try {
|
|
126
|
+
// format: hash|date|message
|
|
127
|
+
const result = execSync(
|
|
128
|
+
`git log ${fromSha}..${toRef} --pretty=format:"%H|%ad|%s" --date=short 2>/dev/null`,
|
|
129
|
+
{ encoding: 'utf-8', maxBuffer: 10 * 1024 * 1024 }
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
const lines = result.trim().split('\n').filter(Boolean)
|
|
133
|
+
|
|
134
|
+
for (const line of lines) {
|
|
135
|
+
const [hash, date, ...messageParts] = line.split('|')
|
|
136
|
+
const message = messageParts.join('|')
|
|
137
|
+
|
|
138
|
+
const parsed = parseConventionalCommit(message)
|
|
139
|
+
|
|
140
|
+
// include non-conventional commits too, just categorize them as "other"
|
|
141
|
+
commits.push({
|
|
142
|
+
hash: hash.slice(0, 7),
|
|
143
|
+
type: parsed?.type || 'other',
|
|
144
|
+
scope: parsed?.scope,
|
|
145
|
+
message: parsed?.message || message,
|
|
146
|
+
breaking: parsed?.breaking || false,
|
|
147
|
+
date,
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
} catch {
|
|
151
|
+
// no commits or error
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return commits
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function formatChangelog(commits: CommitInfo[]): void {
|
|
158
|
+
if (commits.length === 0) {
|
|
159
|
+
console.info(pc.dim(' no changes found'))
|
|
160
|
+
return
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// group by type
|
|
164
|
+
const grouped = new Map<string, CommitInfo[]>()
|
|
165
|
+
for (const commit of commits) {
|
|
166
|
+
const existing = grouped.get(commit.type) || []
|
|
167
|
+
existing.push(commit)
|
|
168
|
+
grouped.set(commit.type, existing)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// sort by type order
|
|
172
|
+
const sortedTypes = Array.from(grouped.keys()).sort((a, b) => {
|
|
173
|
+
const aIdx = COMMIT_TYPE_ORDER.indexOf(a)
|
|
174
|
+
const bIdx = COMMIT_TYPE_ORDER.indexOf(b)
|
|
175
|
+
return (aIdx === -1 ? 999 : aIdx) - (bIdx === -1 ? 999 : bIdx)
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
// show breaking changes first
|
|
179
|
+
const breakingChanges = commits.filter((c) => c.breaking)
|
|
180
|
+
if (breakingChanges.length > 0) {
|
|
181
|
+
console.info()
|
|
182
|
+
console.info(pc.red(pc.bold(' BREAKING CHANGES')))
|
|
183
|
+
for (const commit of breakingChanges) {
|
|
184
|
+
const scope = commit.scope ? pc.cyan(`(${commit.scope})`) : ''
|
|
185
|
+
console.info(
|
|
186
|
+
` ${pc.red('!')} ${scope} ${commit.message} ${pc.dim(`(${commit.hash})`)}`
|
|
187
|
+
)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const typeLabels: Record<string, string> = {
|
|
192
|
+
feat: 'Features',
|
|
193
|
+
fix: 'Bug Fixes',
|
|
194
|
+
perf: 'Performance',
|
|
195
|
+
refactor: 'Refactoring',
|
|
196
|
+
docs: 'Documentation',
|
|
197
|
+
chore: 'Maintenance',
|
|
198
|
+
test: 'Tests',
|
|
199
|
+
ci: 'CI',
|
|
200
|
+
build: 'Build',
|
|
201
|
+
style: 'Style',
|
|
202
|
+
other: 'Other',
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const typeColors: Record<string, (s: string) => string> = {
|
|
206
|
+
feat: pc.green,
|
|
207
|
+
fix: pc.yellow,
|
|
208
|
+
perf: pc.magenta,
|
|
209
|
+
refactor: pc.blue,
|
|
210
|
+
docs: pc.dim,
|
|
211
|
+
chore: pc.dim,
|
|
212
|
+
test: pc.dim,
|
|
213
|
+
ci: pc.dim,
|
|
214
|
+
build: pc.dim,
|
|
215
|
+
style: pc.dim,
|
|
216
|
+
other: pc.white,
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
for (const type of sortedTypes) {
|
|
220
|
+
const typeCommits = grouped.get(type)!.filter((c) => !c.breaking)
|
|
221
|
+
if (typeCommits.length === 0) continue
|
|
222
|
+
|
|
223
|
+
const label = typeLabels[type] || type
|
|
224
|
+
const color = typeColors[type] || pc.white
|
|
225
|
+
|
|
226
|
+
console.info()
|
|
227
|
+
console.info(color(pc.bold(` ${label}`)))
|
|
228
|
+
|
|
229
|
+
for (const commit of typeCommits) {
|
|
230
|
+
const scope = commit.scope ? pc.cyan(`(${commit.scope}) `) : ''
|
|
231
|
+
console.info(
|
|
232
|
+
` ${pc.dim('-')} ${scope}${commit.message} ${pc.dim(`(${commit.hash})`)}`
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export const changedCommand = defineCommand({
|
|
239
|
+
meta: {
|
|
240
|
+
name: 'changed',
|
|
241
|
+
description: 'Show changes in upstream Takeout since last sync',
|
|
242
|
+
},
|
|
243
|
+
args: {
|
|
244
|
+
from: {
|
|
245
|
+
type: 'string',
|
|
246
|
+
description: 'Starting commit SHA (defaults to .takeout file)',
|
|
247
|
+
},
|
|
248
|
+
to: {
|
|
249
|
+
type: 'string',
|
|
250
|
+
description: 'Ending commit ref (defaults to upstream main)',
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
async run({ args }) {
|
|
254
|
+
console.info()
|
|
255
|
+
console.info(pc.bold(pc.cyan('Takeout Changes')))
|
|
256
|
+
console.info()
|
|
257
|
+
|
|
258
|
+
// determine from SHA
|
|
259
|
+
let fromSha = args.from
|
|
260
|
+
const config = readTakeoutConfig()
|
|
261
|
+
|
|
262
|
+
if (!fromSha) {
|
|
263
|
+
if (!config?.sha) {
|
|
264
|
+
console.info(pc.yellow('No .takeout file found with last sync SHA.'))
|
|
265
|
+
console.info()
|
|
266
|
+
console.info(pc.dim('Either:'))
|
|
267
|
+
console.info(pc.dim(' 1. Create a .takeout file with: sha=<commit-sha>'))
|
|
268
|
+
console.info(pc.dim(' 2. Run with --from <sha> to specify starting point'))
|
|
269
|
+
console.info(pc.dim(' 3. Run `tko sync` to sync and create the file'))
|
|
270
|
+
console.info()
|
|
271
|
+
return
|
|
272
|
+
}
|
|
273
|
+
fromSha = config.sha
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// setup upstream remote and fetch
|
|
277
|
+
if (!ensureUpstreamRemote()) {
|
|
278
|
+
return
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const toRef = args.to || `${UPSTREAM_REMOTE}/main`
|
|
282
|
+
|
|
283
|
+
console.info(pc.dim(` from: ${fromSha.slice(0, 7)}`))
|
|
284
|
+
console.info(pc.dim(` to: ${toRef}`))
|
|
285
|
+
|
|
286
|
+
if (config?.date) {
|
|
287
|
+
console.info(pc.dim(` last sync: ${config.date}`))
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// get commits
|
|
291
|
+
const commits = getCommitsBetween(fromSha, toRef)
|
|
292
|
+
|
|
293
|
+
if (commits.length === 0) {
|
|
294
|
+
console.info()
|
|
295
|
+
console.info(pc.green('✓ Already up to date with upstream!'))
|
|
296
|
+
console.info()
|
|
297
|
+
return
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
console.info()
|
|
301
|
+
console.info(
|
|
302
|
+
pc.bold(
|
|
303
|
+
`${commits.length} commit${commits.length === 1 ? '' : 's'} since last sync:`
|
|
304
|
+
)
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
formatChangelog(commits)
|
|
308
|
+
|
|
309
|
+
console.info()
|
|
310
|
+
console.info(pc.dim('Run `tko sync` to sync these changes into your fork.'))
|
|
311
|
+
console.info()
|
|
312
|
+
},
|
|
313
|
+
})
|