@nickchristensen/cliftin 2.1.0 → 3.0.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/README.md CHANGED
@@ -73,7 +73,7 @@ DESCRIPTION
73
73
  List exercises
74
74
  ```
75
75
 
76
- _See code: [src/commands/exercises/list.ts](https://github.com/nickchristensen/cliftin/blob/v2.1.0/src/commands/exercises/list.ts)_
76
+ _See code: [src/commands/exercises/list.ts](https://github.com/nickchristensen/cliftin/blob/v3.0.0/src/commands/exercises/list.ts)_
77
77
 
78
78
  ## `cliftin exercises show SELECTOR`
79
79
 
@@ -107,7 +107,7 @@ DESCRIPTION
107
107
  Show one exercise detail and history
108
108
  ```
109
109
 
110
- _See code: [src/commands/exercises/show.ts](https://github.com/nickchristensen/cliftin/blob/v2.1.0/src/commands/exercises/show.ts)_
110
+ _See code: [src/commands/exercises/show.ts](https://github.com/nickchristensen/cliftin/blob/v3.0.0/src/commands/exercises/show.ts)_
111
111
 
112
112
  ## `cliftin help [COMMAND]`
113
113
 
@@ -144,7 +144,7 @@ DESCRIPTION
144
144
  List programs
145
145
  ```
146
146
 
147
- _See code: [src/commands/programs/list.ts](https://github.com/nickchristensen/cliftin/blob/v2.1.0/src/commands/programs/list.ts)_
147
+ _See code: [src/commands/programs/list.ts](https://github.com/nickchristensen/cliftin/blob/v3.0.0/src/commands/programs/list.ts)_
148
148
 
149
149
  ## `cliftin programs show [SELECTOR]`
150
150
 
@@ -164,7 +164,7 @@ DESCRIPTION
164
164
  Show one program hierarchy
165
165
  ```
166
166
 
167
- _See code: [src/commands/programs/show.ts](https://github.com/nickchristensen/cliftin/blob/v2.1.0/src/commands/programs/show.ts)_
167
+ _See code: [src/commands/programs/show.ts](https://github.com/nickchristensen/cliftin/blob/v3.0.0/src/commands/programs/show.ts)_
168
168
 
169
169
  ## `cliftin workouts list`
170
170
 
@@ -191,7 +191,7 @@ DESCRIPTION
191
191
  List workouts
192
192
  ```
193
193
 
194
- _See code: [src/commands/workouts/list.ts](https://github.com/nickchristensen/cliftin/blob/v2.1.0/src/commands/workouts/list.ts)_
194
+ _See code: [src/commands/workouts/list.ts](https://github.com/nickchristensen/cliftin/blob/v3.0.0/src/commands/workouts/list.ts)_
195
195
 
196
196
  ## `cliftin workouts next`
197
197
 
@@ -208,7 +208,7 @@ DESCRIPTION
208
208
  Show the up-next routine from the active program
209
209
  ```
210
210
 
211
- _See code: [src/commands/workouts/next.ts](https://github.com/nickchristensen/cliftin/blob/v2.1.0/src/commands/workouts/next.ts)_
211
+ _See code: [src/commands/workouts/next.ts](https://github.com/nickchristensen/cliftin/blob/v3.0.0/src/commands/workouts/next.ts)_
212
212
 
213
213
  ## `cliftin workouts show [WORKOUTID]`
214
214
 
@@ -228,5 +228,5 @@ DESCRIPTION
228
228
  Show one workout with exercises and sets
229
229
  ```
230
230
 
231
- _See code: [src/commands/workouts/show.ts](https://github.com/nickchristensen/cliftin/blob/v2.1.0/src/commands/workouts/show.ts)_
231
+ _See code: [src/commands/workouts/show.ts](https://github.com/nickchristensen/cliftin/blob/v3.0.0/src/commands/workouts/show.ts)_
232
232
  <!-- commandsstop -->
@@ -6,6 +6,24 @@ import { resolveIdOrName } from './selectors.js';
6
6
  function asBool(value) {
7
7
  return value === 1;
8
8
  }
9
+ function buildPlannedFallbackSets(summary, unitPreference) {
10
+ return Array.from({ length: Math.max(summary.plannedSets ?? 1, 1) }, () => ({
11
+ id: null,
12
+ reps: summary.plannedReps,
13
+ rpe: null,
14
+ timeSeconds: summary.plannedTimeSeconds,
15
+ weight: convertKgToDisplayWeight(summary.plannedWeight, unitPreference),
16
+ }));
17
+ }
18
+ function explicitSetsMatchSummary(explicitSets, summary, unitPreference) {
19
+ const expectedCount = Math.max(summary.plannedSets ?? 1, 1);
20
+ const expectedWeight = convertKgToDisplayWeight(summary.plannedWeight, unitPreference);
21
+ if (explicitSets.length !== expectedCount)
22
+ return false;
23
+ return explicitSets.every((set) => set.reps === summary.plannedReps &&
24
+ set.timeSeconds === summary.plannedTimeSeconds &&
25
+ set.weight === expectedWeight);
26
+ }
9
27
  export async function listPrograms(db) {
10
28
  const selectedProgram = await db
11
29
  .selectFrom('ZWORKOUTPROGRAMSINFO as info')
@@ -167,15 +185,16 @@ export async function getProgramDetail(db, programId) {
167
185
  continue;
168
186
  const current = exercisesByRoutine.get(row.routineId) ?? [];
169
187
  const explicitSets = setsByExerciseConfig.get(row.exerciseConfigId) ?? [];
170
- const fallbackSet = explicitSets.length > 0
188
+ const plannedSummary = {
189
+ plannedReps: row.plannedReps,
190
+ plannedSets: row.plannedSets,
191
+ plannedTimeSeconds: row.plannedTimeSeconds,
192
+ plannedWeight: row.plannedWeight,
193
+ };
194
+ const fallbackSet = buildPlannedFallbackSets(plannedSummary, unitPreference);
195
+ const selectedSets = explicitSets.length > 0 && explicitSetsMatchSummary(explicitSets, plannedSummary, unitPreference)
171
196
  ? explicitSets
172
- : Array.from({ length: Math.max(row.plannedSets ?? 1, 1) }, () => ({
173
- id: null,
174
- reps: row.plannedReps,
175
- rpe: null,
176
- timeSeconds: row.plannedTimeSeconds,
177
- weight: convertKgToDisplayWeight(row.plannedWeight, unitPreference),
178
- }));
197
+ : fallbackSet;
179
198
  current.push({
180
199
  exerciseConfigId: row.exerciseConfigId,
181
200
  id: row.exerciseId,
@@ -184,7 +203,7 @@ export async function getProgramDetail(db, programId) {
184
203
  plannedSets: row.plannedSets,
185
204
  plannedTimeSeconds: row.plannedTimeSeconds,
186
205
  plannedWeight: convertKgToDisplayWeight(row.plannedWeight, unitPreference),
187
- sets: fallbackSet,
206
+ sets: selectedSets,
188
207
  });
189
208
  exercisesByRoutine.set(row.routineId, current);
190
209
  }
@@ -399,5 +399,5 @@
399
399
  ]
400
400
  }
401
401
  },
402
- "version": "2.1.0"
402
+ "version": "3.0.0"
403
403
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nickchristensen/cliftin",
3
3
  "description": "CLIftin: A read-only CLI for Liftin'",
4
- "version": "2.1.0",
4
+ "version": "3.0.0",
5
5
  "author": "Nick Christensen",
6
6
  "bin": {
7
7
  "cliftin": "./bin/run.js"