@skitterbyte/skitterspec-linear 18.0.1 → 18.1.0
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/MIGRATION.md +81 -0
- package/assets/core/env.config.md +33 -9
- package/assets/hooks/main-guard.cjs +1 -1
- package/assets/hooks/review-gate.cjs +1 -1
- package/assets/rules/spec-planning.md +4 -2
- package/assets/skills/spec-complete/SKILL.md +67 -25
- package/assets/skills/spec-hotfix/SKILL.md +21 -11
- package/assets/skills/spec-sync/SKILL.md +10 -1
- package/package.json +1 -1
- package/src/cli.js +289 -34
- package/src/env/config.js +14 -2
- package/src/env/hotfix.js +261 -15
- package/src/env/hotfixland.js +302 -0
- package/src/env/resolve.js +22 -8
- package/src/init.js +36 -4
- package/src/vendor/linear/api.js +43 -56
- package/src/vendor/linear/cli-sanitise.js +2 -2
- package/src/vendor/linear/cli-sync.js +87 -390
- package/src/vendor/linear/config.js +46 -171
- package/src/vendor/linear/credentials.js +40 -370
- package/src/vendor/linear/dialect.js +177 -0
- package/src/vendor/linear/doctor.js +7 -15
- package/src/vendor/linear/identity.js +20 -70
- package/src/vendor/linear/released.js +4 -222
- package/src/vendor/{sync-core/src → linear}/sanitise.js +4 -3
- package/src/vendor/provider-kit/index.js +41 -0
- package/src/vendor/provider-kit/src/adapter.js +23 -0
- package/src/vendor/provider-kit/src/apply.js +197 -0
- package/src/vendor/provider-kit/src/args.js +68 -0
- package/src/vendor/provider-kit/src/config.js +198 -0
- package/src/vendor/provider-kit/src/credentials.js +404 -0
- package/src/vendor/provider-kit/src/doctor.js +35 -0
- package/src/vendor/provider-kit/src/http.js +44 -0
- package/src/vendor/provider-kit/src/identity.js +93 -0
- package/src/vendor/provider-kit/src/md-compare.js +39 -0
- package/src/vendor/{sync-core/src/tables.js → provider-kit/src/md-tables.js} +10 -18
- package/src/vendor/provider-kit/src/prompt.js +50 -0
- package/src/vendor/provider-kit/src/released.js +226 -0
- package/src/vendor/provider-kit/src/specs.js +166 -0
- package/src/vendor/provider-kit/src/transport.js +22 -0
- package/src/vendor/sync-core/index.js +22 -5
- package/src/vendor/sync-core/src/compare.js +14 -12
- package/src/vendor/sync-core/src/dialect.js +51 -0
- package/src/vendor/sync-core/src/fields.js +36 -0
- package/src/vendor/sync-core/src/legacy.js +19 -9
- package/src/vendor/sync-core/src/normalize.js +30 -158
- package/src/vendor/sync-core/src/push.js +1 -1
- package/src/vendor/sync-core/src/retarget.js +21 -17
- package/src/vendor/sync-core/src/verify.js +24 -45
- package/src/vendor/sync-core/src/write.js +7 -5
package/src/cli.js
CHANGED
|
@@ -161,7 +161,8 @@ const {
|
|
|
161
161
|
} = require('./env/mainguard.js')
|
|
162
162
|
const { planPrune, liveSlugsForSpecs, reconcileRegistry } = require('./env/prune.js')
|
|
163
163
|
const { planIntegrate, planIntegrateCheckout } = require('./env/integrate.js')
|
|
164
|
-
const { planHotfixLand } = require('./env/hotfix.js')
|
|
164
|
+
const { planHotfixLand, planHotfixFinish } = require('./env/hotfix.js')
|
|
165
|
+
const { runHotfixLand, describeStep: describeHotfixStep } = require('./env/hotfixland.js')
|
|
165
166
|
const { planDev } = require('./env/dev.js')
|
|
166
167
|
const { startProcess, stopProcess, waitHealthy, readPid, isAlive } = require('./env/supervise.js')
|
|
167
168
|
const { renderRoutes, portsInUse, portsInUseOn, waitListening } = require('./env/proxy.js')
|
|
@@ -178,11 +179,13 @@ const pkg = require('../package.json')
|
|
|
178
179
|
// Commands this (tracker-free) base does NOT ship, and the distribution that
|
|
179
180
|
// does. Without this the base says only "unknown command: spec-sync", which a
|
|
180
181
|
// user correctly reads as "no such feature" — nothing anywhere named the
|
|
181
|
-
// distribution that has it, so they were stranded. Naming
|
|
182
|
-
// diagnostic string, not provider machinery: `init.js` already knows
|
|
183
|
-
//
|
|
182
|
+
// distribution that has it, so they were stranded. Naming distributions here
|
|
183
|
+
// is a diagnostic string, not provider machinery: `init.js` already knows the
|
|
184
|
+
// provider config files by name in order to protect them. With two provider
|
|
185
|
+
// supersets the hand-off names both where both ship the command, and the one
|
|
186
|
+
// that does where only one does.
|
|
184
187
|
const PROVIDER_COMMANDS = {
|
|
185
|
-
'spec-sync': '@skitterbyte/skitterspec-linear',
|
|
188
|
+
'spec-sync': '@skitterbyte/skitterspec-linear or @skitterbyte/skitterspec-jira',
|
|
186
189
|
'spec-sanitise': '@skitterbyte/skitterspec-linear',
|
|
187
190
|
}
|
|
188
191
|
|
|
@@ -230,7 +233,11 @@ Usage:
|
|
|
230
233
|
dev down <spec> stop the spec's host dev servers
|
|
231
234
|
connect <spec> expose a spec on the canonical ports (main = off)
|
|
232
235
|
integrate <spec> plan rebase + fast-forward onto the base branch
|
|
233
|
-
hotfix land <spec>
|
|
236
|
+
hotfix land <spec>
|
|
237
|
+
release, push (--push), carry a hotfix to
|
|
238
|
+
the base branch (--plan, --also <tag>)
|
|
239
|
+
hotfix finish <spec>
|
|
240
|
+
tear a landed hotfix down once it deployed
|
|
234
241
|
live <spec> check a spec out in the primary checkout so
|
|
235
242
|
the running dev server serves it (take |
|
|
236
243
|
release | abort | status; main hands it back)
|
|
@@ -2040,30 +2047,196 @@ function afterLandSection(afterLand) {
|
|
|
2040
2047
|
return out.join('\n') + '\n'
|
|
2041
2048
|
}
|
|
2042
2049
|
|
|
2043
|
-
// Land a hotfix:
|
|
2044
|
-
//
|
|
2045
|
-
// the base branch for the next release.
|
|
2046
|
-
//
|
|
2047
|
-
//
|
|
2050
|
+
// Land a hotfix: release the branch (the project's `hotfix.releaseWith`, else
|
|
2051
|
+
// the built-in tagger), cherry-pick the fix onto any extra base tags (test/demo
|
|
2052
|
+
// lines) and onto the base branch for the next release.
|
|
2053
|
+
//
|
|
2054
|
+
// THE ENGINE RUNS IT, the way `bootstrap` runs a worktree's steps. It used to
|
|
2055
|
+
// print a plan for the skill to run, and a project's own release command broke
|
|
2056
|
+
// that: the prod tag is only known once the command has said what it cut. So
|
|
2057
|
+
// this probes git, plans (hotfix.js), runs (hotfixland.js), and records the
|
|
2058
|
+
// release beside the review store the moment it is cut, so a land that stops
|
|
2059
|
+
// later resumes without cutting a second one. `--plan` describes it and runs
|
|
2060
|
+
// nothing. NEVER pushes — pushing the deploy tag is the operator's.
|
|
2061
|
+
function hotfixRecordPath(dir, config, name) {
|
|
2062
|
+
return path.join(path.dirname(path.resolve(dir, config.registry)), 'hotfix', `${name}.json`)
|
|
2063
|
+
}
|
|
2064
|
+
|
|
2065
|
+
function readHotfixRecord(dir, config, name) {
|
|
2066
|
+
try {
|
|
2067
|
+
return JSON.parse(fs.readFileSync(hotfixRecordPath(dir, config, name), 'utf8'))
|
|
2068
|
+
} catch {
|
|
2069
|
+
return null
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
function writeHotfixRecord(dir, config, name, record) {
|
|
2074
|
+
const file = hotfixRecordPath(dir, config, name)
|
|
2075
|
+
fs.mkdirSync(path.dirname(file), { recursive: true })
|
|
2076
|
+
fs.writeFileSync(file, JSON.stringify(record, null, 2) + '\n')
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
/**
|
|
2080
|
+
* What `hotfix land` carries to the base branch, and how.
|
|
2081
|
+
*
|
|
2082
|
+
* The fix commits are `baseRef..branch` in order, minus the version commit a
|
|
2083
|
+
* recorded release left on the branch — it holds package.json, CHANGELOG and
|
|
2084
|
+
* RELEASES, and main's version line never moves on a hotfix. The carry is that
|
|
2085
|
+
* list minus whatever `git cherry` says the base branch already has, so a
|
|
2086
|
+
* re-run after a partial carry picks up where it stopped. A `git cherry` that
|
|
2087
|
+
* cannot answer excludes nothing: a duplicate then fails as an empty
|
|
2088
|
+
* cherry-pick, loudly, which is the safe direction to be wrong in.
|
|
2089
|
+
*
|
|
2090
|
+
* Where the base branch is decides the strategy: checked out and clean → in
|
|
2091
|
+
* place; checked out and dirty → refuse; not checked out → a throwaway worktree.
|
|
2092
|
+
*/
|
|
2093
|
+
function hotfixCarry(dir, spec, base, wtGit, released) {
|
|
2094
|
+
const version = released && released.versionCommit
|
|
2095
|
+
const listed = wtGit(['rev-list', '--reverse', `${spec.baseRef}..${spec.branch}`])
|
|
2096
|
+
const fixCommits = (listed ? listed.split('\n') : [])
|
|
2097
|
+
.map((x) => x.trim())
|
|
2098
|
+
.filter((sha) => sha && sha !== version)
|
|
2099
|
+
const git = gitReader(dir)
|
|
2100
|
+
const cherry = git(['cherry', base, spec.branch])
|
|
2101
|
+
const already = new Set(
|
|
2102
|
+
(cherry ? cherry.split('\n') : [])
|
|
2103
|
+
.map((l) => l.trim())
|
|
2104
|
+
.filter((l) => l.startsWith('- '))
|
|
2105
|
+
.map((l) => l.slice(2).trim()),
|
|
2106
|
+
)
|
|
2107
|
+
const commits = fixCommits.filter((sha) => !already.has(sha))
|
|
2108
|
+
|
|
2109
|
+
// Which checkout, if any, has the base branch checked out.
|
|
2110
|
+
const list = git(['worktree', 'list', '--porcelain']) || ''
|
|
2111
|
+
let where = null
|
|
2112
|
+
let current = null
|
|
2113
|
+
for (const line of list.split('\n')) {
|
|
2114
|
+
if (line.startsWith('worktree ')) current = line.slice('worktree '.length)
|
|
2115
|
+
else if (line === `branch refs/heads/${base}`) where = current
|
|
2116
|
+
}
|
|
2117
|
+
let carry
|
|
2118
|
+
if (where) {
|
|
2119
|
+
const st = gitReader(where)(['status', '--porcelain'])
|
|
2120
|
+
carry = { strategy: st ? 'dirty' : 'inplace', path: where, commits }
|
|
2121
|
+
} else {
|
|
2122
|
+
const tmpPath = path.join(path.dirname(spec.worktreePath), `${spec.slug}-carry-${base}`)
|
|
2123
|
+
carry = { strategy: 'worktree', path: dir, tmpPath, commits }
|
|
2124
|
+
}
|
|
2125
|
+
return { fixCommits, carry }
|
|
2126
|
+
}
|
|
2127
|
+
|
|
2128
|
+
// `hotfix finish`: tear a landed hotfix down once its deploy is out. The guards
|
|
2129
|
+
// live in `planHotfixFinish`; this gathers the facts, refuses from inside the
|
|
2130
|
+
// worktree it is about to remove, and runs the two git commands itself.
|
|
2131
|
+
function hotfixFinish(dir, config, specArg, flags) {
|
|
2132
|
+
const json = flags.json === true
|
|
2133
|
+
const say = (line) => process.stdout.write(line + '\n')
|
|
2134
|
+
const spec = resolveSpecWithWorktree(dir, config, specArg)
|
|
2135
|
+
const refuse = (reasons) => {
|
|
2136
|
+
if (json) say(JSON.stringify({ ok: false, spec: spec.folder, refused: reasons }, null, 2))
|
|
2137
|
+
else {
|
|
2138
|
+
say(`spec-env hotfix finish: ${spec.folder} — refused, nothing removed:`)
|
|
2139
|
+
for (const r of reasons) say(` - ${r}`)
|
|
2140
|
+
}
|
|
2141
|
+
process.exitCode = 1
|
|
2142
|
+
}
|
|
2143
|
+
if (spec.type !== 'hotfix') {
|
|
2144
|
+
refuse([`${spec.folder} is not a hotfix — \`spec-env down\` tears it down`])
|
|
2145
|
+
return
|
|
2146
|
+
}
|
|
2147
|
+
if (!fs.existsSync(spec.worktreePath)) {
|
|
2148
|
+
if (json) say(JSON.stringify({ ok: true, spec: spec.folder, noop: true }, null, 2))
|
|
2149
|
+
else say(`spec-env hotfix finish: ${spec.folder} has no worktree — nothing to do.`)
|
|
2150
|
+
return
|
|
2151
|
+
}
|
|
2152
|
+
// Removing the tree a shell is standing in succeeds, and then every command
|
|
2153
|
+
// after it fails with "Unable to read current working directory".
|
|
2154
|
+
const cwd = process.cwd()
|
|
2155
|
+
const inside = (() => {
|
|
2156
|
+
try {
|
|
2157
|
+
const rel = path.relative(fs.realpathSync(spec.worktreePath), fs.realpathSync(cwd))
|
|
2158
|
+
return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel))
|
|
2159
|
+
} catch {
|
|
2160
|
+
return false
|
|
2161
|
+
}
|
|
2162
|
+
})()
|
|
2163
|
+
if (inside) {
|
|
2164
|
+
refuse([`this shell is inside the worktree — \`cd ${dir}\` first, then re-run`])
|
|
2165
|
+
return
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
const wtGit = gitReader(spec.worktreePath)
|
|
2169
|
+
const status = wtGit(['status', '--porcelain'])
|
|
2170
|
+
const head = wtGit(['rev-parse', 'HEAD'])
|
|
2171
|
+
const remote = 'origin'
|
|
2172
|
+
// `ls-remote` exits 0 with nothing on stdout when the branch is absent, and
|
|
2173
|
+
// non-zero when the remote cannot be asked — two different answers.
|
|
2174
|
+
const lsRemote = wtGit(['ls-remote', '--heads', remote, `refs/heads/${spec.branch}`])
|
|
2175
|
+
const remoteHead = lsRemote === null ? undefined : lsRemote ? lsRemote.split(/\s+/)[0] : null
|
|
2176
|
+
const registry = readRegistry(dir, config)
|
|
2177
|
+
const plan = planHotfixFinish(spec, {
|
|
2178
|
+
dirty: status === null || status.length > 0,
|
|
2179
|
+
tagsAtHead: (wtGit(['tag', '--points-at', 'HEAD']) || '').split('\n').filter(Boolean),
|
|
2180
|
+
head,
|
|
2181
|
+
remoteHead,
|
|
2182
|
+
remote,
|
|
2183
|
+
mainRepoPath: dir,
|
|
2184
|
+
hasSlot: Object.prototype.hasOwnProperty.call(registry.slots, spec.folder),
|
|
2185
|
+
})
|
|
2186
|
+
if (plan.blocked) {
|
|
2187
|
+
refuse(plan.reasons)
|
|
2188
|
+
return
|
|
2189
|
+
}
|
|
2190
|
+
const git = gitReader(dir)
|
|
2191
|
+
for (const argv of plan.argvs) {
|
|
2192
|
+
if (git(argv) === null) {
|
|
2193
|
+
refuse([`git ${argv.join(' ')} failed — nothing after it ran`])
|
|
2194
|
+
return
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
fs.rmSync(hotfixRecordPath(dir, config, spec.folder), { force: true })
|
|
2198
|
+
if (json) {
|
|
2199
|
+
say(JSON.stringify({ ok: true, spec: spec.folder, releaseTag: plan.releaseTag, removed: spec.worktreePath, branchDeleted: spec.branch }, null, 2))
|
|
2200
|
+
return
|
|
2201
|
+
}
|
|
2202
|
+
say(`spec-env hotfix finish: ${spec.folder}`)
|
|
2203
|
+
say('')
|
|
2204
|
+
say(` release: ${plan.releaseTag} (on ${remote} with ${spec.branch})`)
|
|
2205
|
+
say(` removed: ${spec.worktreePath}`)
|
|
2206
|
+
say(` deleted: ${spec.branch} (local; ${remote} keeps it)`)
|
|
2207
|
+
}
|
|
2208
|
+
|
|
2048
2209
|
function specEnvHotfix(dir, config, positional, flags) {
|
|
2049
2210
|
const action = positional[0]
|
|
2050
2211
|
const specArg = positional[1]
|
|
2212
|
+
const json = flags.json === true
|
|
2213
|
+
const say = (line) => process.stdout.write(line + '\n')
|
|
2214
|
+
const refuse = (msg, extra = {}) => {
|
|
2215
|
+
if (json) say(JSON.stringify({ ok: false, refused: msg, ...extra }, null, 2))
|
|
2216
|
+
else say(`spec-env hotfix land: ${msg}`)
|
|
2217
|
+
process.exitCode = 1
|
|
2218
|
+
}
|
|
2051
2219
|
// The action must be named; the spec may be omitted (resolved from the registry).
|
|
2220
|
+
if (action === 'finish') {
|
|
2221
|
+
hotfixFinish(dir, config, specArg, flags)
|
|
2222
|
+
return
|
|
2223
|
+
}
|
|
2052
2224
|
if (action !== 'land') {
|
|
2053
|
-
process.stdout.write(
|
|
2225
|
+
process.stdout.write(
|
|
2226
|
+
'Usage: skitterspec spec-env hotfix land [spec] [--push] [--plan] [--json] [--also <tag>]...\n' +
|
|
2227
|
+
' skitterspec spec-env hotfix finish [spec] [--json]\n',
|
|
2228
|
+
)
|
|
2054
2229
|
return
|
|
2055
2230
|
}
|
|
2056
2231
|
|
|
2057
2232
|
// A hotfix may be authored entirely on its branch, so fall back to its worktree.
|
|
2058
2233
|
const spec = resolveSpecWithWorktree(dir, config, specArg)
|
|
2059
2234
|
if (spec.type !== 'hotfix') {
|
|
2060
|
-
|
|
2061
|
-
`spec-env hotfix land: ${spec.folder} is not a hotfix — needs Type: Hotfix / a hotfix- prefix.\n`,
|
|
2062
|
-
)
|
|
2235
|
+
refuse(`${spec.folder} is not a hotfix — needs Type: Hotfix / a hotfix- prefix.`)
|
|
2063
2236
|
return
|
|
2064
2237
|
}
|
|
2065
2238
|
if (!fs.existsSync(spec.worktreePath)) {
|
|
2066
|
-
|
|
2239
|
+
refuse(`${spec.folder} has no worktree — nothing to land.`)
|
|
2067
2240
|
return
|
|
2068
2241
|
}
|
|
2069
2242
|
|
|
@@ -2076,6 +2249,23 @@ function specEnvHotfix(dir, config, positional, flags) {
|
|
|
2076
2249
|
const tagList = wtGit(['tag', '--list'])
|
|
2077
2250
|
const existingTags = tagList ? tagList.split('\n').map((s) => s.trim()).filter(Boolean) : []
|
|
2078
2251
|
|
|
2252
|
+
// A release cut on an earlier run counts only while HEAD still carries its
|
|
2253
|
+
// tag — the positive signal that nothing has been committed since. A fix
|
|
2254
|
+
// added after a failed deploy moves HEAD, and the next run cuts a new one.
|
|
2255
|
+
const record = readHotfixRecord(dir, config, spec.folder)
|
|
2256
|
+
const atHead = (wtGit(['tag', '--points-at', 'HEAD']) || '').split('\n').map((s) => s.trim())
|
|
2257
|
+
const released = record && record.tag && atHead.includes(record.tag) ? record : null
|
|
2258
|
+
// Already published? Asked of the remote itself, for the one tag that could
|
|
2259
|
+
// be there. Only a non-empty answer counts: an unreachable remote is "cannot
|
|
2260
|
+
// tell", and cannot-tell holds rather than carrying a fix whose deploy tag
|
|
2261
|
+
// may not be public (`.claude/rules/negative-checks.md` rule 4).
|
|
2262
|
+
const remote = 'origin'
|
|
2263
|
+
const pushed =
|
|
2264
|
+
released !== null &&
|
|
2265
|
+
Boolean(wtGit(['ls-remote', '--tags', remote, `refs/tags/${released.tag}`]))
|
|
2266
|
+
|
|
2267
|
+
const carry = hotfixCarry(dir, spec, base, wtGit, released)
|
|
2268
|
+
|
|
2079
2269
|
// Extra targets: --also flags first, then any config defaults; drop blanks, the
|
|
2080
2270
|
// base tag itself, and duplicates.
|
|
2081
2271
|
const seen = new Set()
|
|
@@ -2088,6 +2278,8 @@ function specEnvHotfix(dir, config, positional, flags) {
|
|
|
2088
2278
|
let plan
|
|
2089
2279
|
try {
|
|
2090
2280
|
plan = planHotfixLand(spec, config, {
|
|
2281
|
+
// A recorded release leaves HEAD tagged and the tree clean; neither
|
|
2282
|
+
// `dirty` nor `aheadOfBase` changes because of it.
|
|
2091
2283
|
worktreeState: { dirty },
|
|
2092
2284
|
aheadOfBase,
|
|
2093
2285
|
fixRange: `${spec.baseRef}..${spec.branch}`,
|
|
@@ -2095,37 +2287,99 @@ function specEnvHotfix(dir, config, positional, flags) {
|
|
|
2095
2287
|
base,
|
|
2096
2288
|
extraTargets,
|
|
2097
2289
|
existingTags,
|
|
2290
|
+
released,
|
|
2291
|
+
push: flags.push === true,
|
|
2292
|
+
pushed,
|
|
2293
|
+
remote,
|
|
2294
|
+
fixCommits: carry.fixCommits,
|
|
2295
|
+
carry: carry.carry,
|
|
2098
2296
|
})
|
|
2099
2297
|
} catch (error) {
|
|
2100
|
-
|
|
2298
|
+
refuse(`${error.message}.`)
|
|
2101
2299
|
return
|
|
2102
2300
|
}
|
|
2103
2301
|
|
|
2104
2302
|
if (plan.blocked) {
|
|
2105
|
-
|
|
2303
|
+
refuse(`blocked — ${plan.reason}.`)
|
|
2106
2304
|
return
|
|
2107
2305
|
}
|
|
2108
2306
|
if (plan.noop) {
|
|
2109
|
-
|
|
2307
|
+
if (json) say(JSON.stringify({ ok: true, noop: true, reason: plan.reason }, null, 2))
|
|
2308
|
+
else say(`spec-env hotfix land: ${plan.reason}.`)
|
|
2110
2309
|
return
|
|
2111
2310
|
}
|
|
2112
2311
|
|
|
2113
|
-
const
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
out.push(` prod tag: ${plan.prodTag} (created locally — push to deploy)`)
|
|
2119
|
-
for (const t of plan.targets) {
|
|
2120
|
-
if (t.kind === 'extra') out.push(` target: ${t.base} -> ${t.tag}`)
|
|
2121
|
-
if (t.kind === 'main') out.push(` next rel: cherry-pick onto ${t.base}`)
|
|
2312
|
+
const header = () => {
|
|
2313
|
+
say(`spec-env hotfix land: ${spec.folder}${flags.plan ? ' (plan — nothing run)' : ''}`)
|
|
2314
|
+
say('')
|
|
2315
|
+
say(` base tag: ${spec.baseRef}`)
|
|
2316
|
+
say(` branch: ${spec.branch}`)
|
|
2122
2317
|
}
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2318
|
+
|
|
2319
|
+
if (flags.plan) {
|
|
2320
|
+
if (json) {
|
|
2321
|
+
say(JSON.stringify({ spec: spec.folder, planned: true, steps: plan.steps }, null, 2))
|
|
2322
|
+
return
|
|
2323
|
+
}
|
|
2324
|
+
header()
|
|
2325
|
+
say('')
|
|
2326
|
+
plan.steps.forEach((st, i) => say(` ${i + 1}. ${describeHotfixStep(st)}`))
|
|
2327
|
+
return
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
if (!json) {
|
|
2331
|
+
header()
|
|
2332
|
+
say('')
|
|
2333
|
+
}
|
|
2334
|
+
const result = runHotfixLand(plan.steps, {
|
|
2335
|
+
write: json ? () => {} : (line) => say(` ${line}`),
|
|
2336
|
+
childStdout: json ? process.stderr : 'inherit',
|
|
2337
|
+
record: (release) =>
|
|
2338
|
+
writeHotfixRecord(dir, config, spec.folder, { ...release, at: new Date().toISOString() }),
|
|
2339
|
+
})
|
|
2340
|
+
const tag = result.release ? result.release.tag : null
|
|
2341
|
+
|
|
2342
|
+
if (json) {
|
|
2343
|
+
say(
|
|
2344
|
+
JSON.stringify(
|
|
2345
|
+
{
|
|
2346
|
+
spec: spec.folder,
|
|
2347
|
+
planned: false,
|
|
2348
|
+
ok: result.ok,
|
|
2349
|
+
held: result.held === true,
|
|
2350
|
+
failedAt: result.failedAt,
|
|
2351
|
+
release: result.release,
|
|
2352
|
+
steps: result.results.map((r) => ({ ...r.step, outcome: r.outcome, line: r.line })),
|
|
2353
|
+
remaining: plan.steps.slice(result.results.length),
|
|
2354
|
+
},
|
|
2355
|
+
null,
|
|
2356
|
+
2,
|
|
2357
|
+
),
|
|
2358
|
+
)
|
|
2359
|
+
} else if (result.held) {
|
|
2360
|
+
// Stopped for want of consent. Both ways on are named: the engine pushes
|
|
2361
|
+
// on `--push`, or a push run by hand is found on the remote next time.
|
|
2362
|
+
say('')
|
|
2363
|
+
say(` prod tag: ${tag} (cut locally — not pushed, nothing carried yet)`)
|
|
2364
|
+
say(` to deploy, push the branch, then the tag — re-run with --push, or run:`)
|
|
2365
|
+
say(` git -C ${spec.worktreePath} push ${remote} ${spec.branch}`)
|
|
2366
|
+
say(` git -C ${spec.worktreePath} push ${remote} ${tag}`)
|
|
2367
|
+
say(` then re-run \`skitterspec spec-env hotfix land ${spec.folder}\` to carry the fix.`)
|
|
2368
|
+
} else if (result.ok) {
|
|
2369
|
+
say('')
|
|
2370
|
+
say(` prod tag: ${tag} (pushed to ${remote})`)
|
|
2371
|
+
// Only a carry that moved the base branch leaves anything to catch up on.
|
|
2372
|
+
if (result.carried) process.stdout.write(afterLandSection(plan.afterLand))
|
|
2373
|
+
} else {
|
|
2374
|
+
const failed = result.results[result.results.length - 1]
|
|
2375
|
+
process.stderr.write(` ${failed.line}\n`)
|
|
2376
|
+
say(
|
|
2377
|
+
`spec-env hotfix land: stopped at step ${result.failedAt} of ${plan.steps.length} ` +
|
|
2378
|
+
`(${describeHotfixStep(failed.step)}) — nothing after it ran.`,
|
|
2379
|
+
)
|
|
2380
|
+
if (tag) say(` ${tag} was cut and is recorded — a re-run carries on from it.`)
|
|
2381
|
+
}
|
|
2382
|
+
if (!result.ok) process.exitCode = 1
|
|
2129
2383
|
}
|
|
2130
2384
|
|
|
2131
2385
|
// What the primary checkout has GAINED right now, by content. `dir` is already
|
|
@@ -5344,6 +5598,7 @@ async function specEnv(rest) {
|
|
|
5344
5598
|
else if (args[i] === '--record-primary') flags.recordPrimary = true
|
|
5345
5599
|
else if (args[i] === '--docs') flags.docs = true
|
|
5346
5600
|
else if (args[i] === '--plan') flags.plan = true
|
|
5601
|
+
else if (args[i] === '--push') flags.push = true
|
|
5347
5602
|
else if (args[i] === '--from') flags.from = args[++i]
|
|
5348
5603
|
else if (args[i] === '--session') flags.session = args[++i]
|
|
5349
5604
|
else if (args[i] === '--path') flags.path = args[++i]
|
package/src/env/config.js
CHANGED
|
@@ -281,11 +281,22 @@ const DEFAULT_CONFIG = Object.freeze({
|
|
|
281
281
|
// `live take` refuses it (code-only v1). Default: none (nothing is stateful).
|
|
282
282
|
live: Object.freeze({ migrations: Object.freeze([]) }),
|
|
283
283
|
// Hotfix landing (`spec-env hotfix land`). `bump` is the version-bump strategy
|
|
284
|
-
// for the new deploy tag
|
|
284
|
+
// for the new deploy tag: "patch" (X.Y.Z -> X.Y.(Z+1)) or "hotfix-suffix"
|
|
285
|
+
// (X.Y.Z -> X.Y.Z-hotfix.N). The loader keeps whatever string it is given and
|
|
286
|
+
// `nextTag` refuses an unknown one at land time — a loader that threw would
|
|
287
|
+
// break every verb over a key only one of them reads. `cherryPickMain` also cherry-picks
|
|
285
288
|
// the fix onto the base branch for the next release (default true). `targets` is
|
|
286
289
|
// an optional default list of extra base tags to also patch (test/demo lines);
|
|
287
290
|
// `--also <tag>` on the command adds more at run time. Default: patch, main, none.
|
|
288
|
-
|
|
291
|
+
// `releaseWith` is a project's own release command, run in the hotfix
|
|
292
|
+
// worktree in place of the built-in tagger — e.g. skittership's
|
|
293
|
+
// `node scripts/release-hotfix.cjs --json`. Empty (the default) = built-in.
|
|
294
|
+
hotfix: Object.freeze({
|
|
295
|
+
bump: 'patch',
|
|
296
|
+
cherryPickMain: true,
|
|
297
|
+
targets: Object.freeze([]),
|
|
298
|
+
releaseWith: '',
|
|
299
|
+
}),
|
|
289
300
|
})
|
|
290
301
|
|
|
291
302
|
function isObject(value) {
|
|
@@ -675,6 +686,7 @@ function mergeConfig(base, parsed) {
|
|
|
675
686
|
if (isObject(parsed.hotfix)) {
|
|
676
687
|
assign(base.hotfix, parsed.hotfix, 'bump', 'string')
|
|
677
688
|
assign(base.hotfix, parsed.hotfix, 'cherryPickMain', 'boolean')
|
|
689
|
+
assign(base.hotfix, parsed.hotfix, 'releaseWith', 'string')
|
|
678
690
|
if (Array.isArray(parsed.hotfix.targets)) {
|
|
679
691
|
base.hotfix.targets = normalizeFileList(parsed.hotfix.targets)
|
|
680
692
|
}
|