create-foldkit-app 0.39.1 → 0.40.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/dist/templates/base/.oxlintrc.effect.json +26 -0
- package/dist/templates/base/package.json +1 -1
- package/dist/templates/examples/charting/src/githubApi.ts +53 -29
- package/dist/templates/examples/charting/src/main.fixture.ts +4 -38
- package/dist/templates/examples/charting/src/telemetry.ts +42 -32
- package/dist/templates/examples/charting/src/weeks.ts +15 -36
- package/dist/templates/examples/kanban/src/story.test.ts +8 -21
- package/dist/templates/examples/route-transitions/src/main.ts +26 -38
- package/dist/templates/examples/routing/src/main.ts +15 -8
- package/dist/templates/examples/routing/src/story.test.ts +21 -0
- package/dist/templates/release.json +14 -12
- package/dist/templates/rendering/ssg/package.json +1 -1
- package/dist/templates/rendering/ssr/package.json +1 -1
- package/dist/utils/packages.js +2 -0
- package/package.json +1 -1
- package/dist/templates/examples/charting/src/telemetry.test.ts +0 -70
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/@effect/tsgo/oxlint-schema.json",
|
|
3
|
+
"extends": ["./node_modules/@effect/tsgo/oxlint-presets/correctness.json"],
|
|
4
|
+
"categories": {
|
|
5
|
+
"correctness": "off"
|
|
6
|
+
},
|
|
7
|
+
"rules": {
|
|
8
|
+
"effecttsgo/catch-unfailable-effect": "warn",
|
|
9
|
+
"effecttsgo/effect-fn-iife": "warn",
|
|
10
|
+
"effecttsgo/effect-gen-uses-adapter": "warn",
|
|
11
|
+
"effecttsgo/effect-in-failure": "warn",
|
|
12
|
+
"effecttsgo/effect-in-void-success": "warn",
|
|
13
|
+
"effecttsgo/layer-merge-all-with-dependencies": "warn",
|
|
14
|
+
"effecttsgo/lazy-promise-in-effect-sync": "warn",
|
|
15
|
+
"effecttsgo/leaking-requirements": "warn",
|
|
16
|
+
"effecttsgo/multiple-effect-provide": "warn",
|
|
17
|
+
"effecttsgo/prefer-typed-schema-decoder": "warn",
|
|
18
|
+
"effecttsgo/prefer-unsafe-constructor": "warn",
|
|
19
|
+
"effecttsgo/return-effect-in-gen": "warn",
|
|
20
|
+
"effecttsgo/schema-sync-in-effect": "warn",
|
|
21
|
+
"effecttsgo/scope-in-layer-effect": "warn",
|
|
22
|
+
"effecttsgo/try-catch-in-effect-gen": "warn",
|
|
23
|
+
"effecttsgo/unstable-api-usage": "off",
|
|
24
|
+
"effecttsgo/unknown-in-effect-catch": "warn"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -2,12 +2,14 @@ import {
|
|
|
2
2
|
Array,
|
|
3
3
|
Context,
|
|
4
4
|
Data,
|
|
5
|
+
DateTime,
|
|
5
6
|
Effect,
|
|
6
7
|
Layer,
|
|
7
8
|
Number,
|
|
8
9
|
Option,
|
|
9
10
|
Schedule,
|
|
10
11
|
Schema,
|
|
12
|
+
pipe,
|
|
11
13
|
} from 'effect'
|
|
12
14
|
import { HttpClient, HttpClientRequest } from 'effect/http'
|
|
13
15
|
|
|
@@ -17,8 +19,7 @@ import { fetchJson, isSuccessfulStatus, makeUrl } from './http'
|
|
|
17
19
|
|
|
18
20
|
const GITHUB_REPOSITORY_API = 'https://api.github.com/repos/foldkit/foldkit'
|
|
19
21
|
const HTTP_ACCEPTED = 202
|
|
20
|
-
const
|
|
21
|
-
const MAX_STARGAZER_PAGES = 10
|
|
22
|
+
const STAR_HISTORY_PAGE_SIZE = 30
|
|
22
23
|
const STAT_MAX_RETRIES = 1
|
|
23
24
|
const STAT_RETRY_DELAY = '2 seconds' as const
|
|
24
25
|
const RELEASE_PAGE_SIZE = 100
|
|
@@ -53,8 +54,10 @@ export const GitHubReleaseResponse = Schema.Struct({
|
|
|
53
54
|
published_at: Schema.OptionFromOptional(Schema.String),
|
|
54
55
|
})
|
|
55
56
|
|
|
56
|
-
export const
|
|
57
|
-
|
|
57
|
+
export const GitHubStarHistoryResponse = Schema.Struct({
|
|
58
|
+
week: Schema.Number,
|
|
59
|
+
total: Schema.Number,
|
|
60
|
+
days: Schema.Array(Schema.Number),
|
|
58
61
|
})
|
|
59
62
|
|
|
60
63
|
export const GitHubCommitActivityResponse = Schema.Struct({
|
|
@@ -84,11 +87,14 @@ type GitHubApiShape = Readonly<{
|
|
|
84
87
|
Error
|
|
85
88
|
>
|
|
86
89
|
fetchReleases: (
|
|
87
|
-
|
|
90
|
+
yearCutoff: DateTime.Utc,
|
|
88
91
|
) => Effect.Effect<ReadonlyArray<typeof GitHubReleaseResponse.Type>, Error>
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
) => Effect.Effect<
|
|
92
|
+
fetchStarHistory: (
|
|
93
|
+
yearCutoff: DateTime.Utc,
|
|
94
|
+
) => Effect.Effect<
|
|
95
|
+
ReadonlyArray<typeof GitHubStarHistoryResponse.Type>,
|
|
96
|
+
Error
|
|
97
|
+
>
|
|
92
98
|
fetchCommitActivity: Effect.Effect<
|
|
93
99
|
GitHubStatResult<ReadonlyArray<typeof GitHubCommitActivityResponse.Type>>,
|
|
94
100
|
never
|
|
@@ -196,7 +202,7 @@ export const GitHubApiLive: Layer.Layer<
|
|
|
196
202
|
per_page: '100',
|
|
197
203
|
}),
|
|
198
204
|
),
|
|
199
|
-
fetchReleases: (
|
|
205
|
+
fetchReleases: (yearCutoff: DateTime.Utc) => {
|
|
200
206
|
const fetchPage = (page: number) =>
|
|
201
207
|
fetch_(Schema.Array(GitHubReleaseResponse))(
|
|
202
208
|
makeUrl(`${GITHUB_REPOSITORY_API}/releases`, {
|
|
@@ -218,10 +224,12 @@ export const GitHubApiLive: Layer.Layer<
|
|
|
218
224
|
onEmpty: () => Effect.succeed(accumulated),
|
|
219
225
|
onNonEmpty: releases => {
|
|
220
226
|
const withinYear = Array.filter(releases, release =>
|
|
221
|
-
|
|
227
|
+
pipe(
|
|
222
228
|
release.published_at,
|
|
223
|
-
|
|
224
|
-
|
|
229
|
+
Option.flatMap(DateTime.make),
|
|
230
|
+
Option.exists(
|
|
231
|
+
DateTime.isGreaterThanOrEqualTo(yearCutoff),
|
|
232
|
+
),
|
|
225
233
|
),
|
|
226
234
|
)
|
|
227
235
|
|
|
@@ -244,23 +252,39 @@ export const GitHubApiLive: Layer.Layer<
|
|
|
244
252
|
|
|
245
253
|
return fetchFrom(1, [])
|
|
246
254
|
},
|
|
247
|
-
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
)
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
255
|
+
fetchStarHistory: (yearCutoff: DateTime.Utc) => {
|
|
256
|
+
const fetchFrom = (
|
|
257
|
+
page: number,
|
|
258
|
+
accumulated: ReadonlyArray<typeof GitHubStarHistoryResponse.Type>,
|
|
259
|
+
): Effect.Effect<
|
|
260
|
+
ReadonlyArray<typeof GitHubStarHistoryResponse.Type>,
|
|
261
|
+
Error
|
|
262
|
+
> =>
|
|
263
|
+
fetch_(Schema.Array(GitHubStarHistoryResponse))(
|
|
264
|
+
makeUrl(`${GITHUB_REPOSITORY_API}/stargazers/history`, {
|
|
265
|
+
per_page: `${STAR_HISTORY_PAGE_SIZE}`,
|
|
266
|
+
page: `${page}`,
|
|
267
|
+
}),
|
|
268
|
+
).pipe(
|
|
269
|
+
Effect.flatMap(history => {
|
|
270
|
+
const nextAccumulated = Array.appendAll(accumulated, history)
|
|
271
|
+
const isLastPage = Array.length(history) < STAR_HISTORY_PAGE_SIZE
|
|
272
|
+
const isCutoffReached = Array.some(history, ({ week }) =>
|
|
273
|
+
DateTime.isLessThanOrEqualTo(
|
|
274
|
+
DateTime.fromEpochSeconds(week),
|
|
275
|
+
yearCutoff,
|
|
276
|
+
),
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
if (isLastPage || isCutoffReached) {
|
|
280
|
+
return Effect.succeed(nextAccumulated)
|
|
281
|
+
} else {
|
|
282
|
+
return fetchFrom(Number.increment(page), nextAccumulated)
|
|
283
|
+
}
|
|
284
|
+
}),
|
|
285
|
+
)
|
|
286
|
+
|
|
287
|
+
return fetchFrom(1, [])
|
|
264
288
|
},
|
|
265
289
|
fetchCommitActivity: fetchStat_(
|
|
266
290
|
Schema.Array(GitHubCommitActivityResponse),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Option } from 'effect'
|
|
1
|
+
import { DateTime, Option } from 'effect'
|
|
2
2
|
import { modifyFields } from 'foldkit/struct'
|
|
3
3
|
|
|
4
4
|
import { RadioGroup } from '@foldkit/ui'
|
|
@@ -20,7 +20,9 @@ import {
|
|
|
20
20
|
} from './radioGroups'
|
|
21
21
|
|
|
22
22
|
export const sampleTelemetry = Telemetry.make({
|
|
23
|
-
fetchedAt:
|
|
23
|
+
fetchedAt: DateTime.toEpochMillis(
|
|
24
|
+
DateTime.makeUnsafe('2026-06-22T12:00:00Z'),
|
|
25
|
+
),
|
|
24
26
|
repository: RepositorySnapshot.make({
|
|
25
27
|
stars: 342,
|
|
26
28
|
forks: 18,
|
|
@@ -124,39 +126,3 @@ export const readyModel = modifyFields(loadingModel, {
|
|
|
124
126
|
telemetry: () => TelemetryAsyncData.Success({ data: sampleTelemetry }),
|
|
125
127
|
maybeChartHostId: () => Option.some('test-chart-host'),
|
|
126
128
|
})
|
|
127
|
-
|
|
128
|
-
export const mockGitHubRepository = {
|
|
129
|
-
stargazers_count: 342,
|
|
130
|
-
forks_count: 18,
|
|
131
|
-
watchers_count: 342,
|
|
132
|
-
open_issues_count: 15,
|
|
133
|
-
pushed_at: '2026-06-21T19:20:00Z',
|
|
134
|
-
default_branch: 'main',
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export const mockNpmDownloads = {
|
|
138
|
-
downloads: [
|
|
139
|
-
{ day: '2026-06-01', downloads: 10 },
|
|
140
|
-
{ day: '2026-06-02', downloads: 12 },
|
|
141
|
-
{ day: '2026-06-08', downloads: 20 },
|
|
142
|
-
{ day: '2026-06-15', downloads: 30 },
|
|
143
|
-
],
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export const mockNpmPackument = {
|
|
147
|
-
name: 'foldkit',
|
|
148
|
-
time: {
|
|
149
|
-
'0.115.0': '2026-06-20T12:00:00Z',
|
|
150
|
-
},
|
|
151
|
-
versions: {
|
|
152
|
-
'0.115.0': {
|
|
153
|
-
dependencies: {},
|
|
154
|
-
peerDependencies: {
|
|
155
|
-
effect: '^4.0.0',
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
'dist-tags': {
|
|
160
|
-
latest: '0.115.0',
|
|
161
|
-
},
|
|
162
|
-
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Array,
|
|
1
|
+
import { Array, DateTime, Effect, Option, Order, Record, pipe } from 'effect'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
ContributorSummary,
|
|
@@ -18,7 +18,7 @@ import type {
|
|
|
18
18
|
GitHubPullRequestResponse,
|
|
19
19
|
GitHubReleaseResponse,
|
|
20
20
|
GitHubRepositoryResponse,
|
|
21
|
-
|
|
21
|
+
GitHubStarHistoryResponse,
|
|
22
22
|
GitHubStatResult,
|
|
23
23
|
} from './githubApi'
|
|
24
24
|
import { GitHubApi } from './githubApi'
|
|
@@ -29,21 +29,18 @@ import type {
|
|
|
29
29
|
} from './npmApi'
|
|
30
30
|
import { NpmApi } from './npmApi'
|
|
31
31
|
import {
|
|
32
|
+
LAST_YEAR_WEEKS,
|
|
32
33
|
type WeeklyCount,
|
|
33
34
|
countByWeek,
|
|
34
35
|
countForWeek,
|
|
35
|
-
dateStringToMilliseconds,
|
|
36
36
|
sumByWeek,
|
|
37
37
|
valueForWeek,
|
|
38
|
-
|
|
38
|
+
weekStartForDateTime,
|
|
39
39
|
weekStartsForLastYear,
|
|
40
40
|
} from './weeks'
|
|
41
41
|
|
|
42
42
|
// CONSTANT
|
|
43
43
|
|
|
44
|
-
const MILLISECONDS_PER_SECOND = 1_000
|
|
45
|
-
const MILLISECONDS_PER_WEEK = 7 * 24 * 60 * 60 * MILLISECONDS_PER_SECOND
|
|
46
|
-
const LAST_YEAR_MILLISECONDS = 52 * MILLISECONDS_PER_WEEK
|
|
47
44
|
const TOP_CONTRIBUTOR_COUNT = 6
|
|
48
45
|
|
|
49
46
|
// MODEL
|
|
@@ -61,7 +58,7 @@ export type RawTelemetry = Readonly<{
|
|
|
61
58
|
issues: ReadonlyArray<typeof GitHubIssueResponse.Type>
|
|
62
59
|
pullRequests: ReadonlyArray<typeof GitHubPullRequestResponse.Type>
|
|
63
60
|
releases: ReadonlyArray<typeof GitHubReleaseResponse.Type>
|
|
64
|
-
|
|
61
|
+
starHistory: ReadonlyArray<typeof GitHubStarHistoryResponse.Type>
|
|
65
62
|
commitActivity: GitHubStatResult<
|
|
66
63
|
ReadonlyArray<typeof GitHubCommitActivityResponse.Type>
|
|
67
64
|
>
|
|
@@ -77,7 +74,7 @@ const weeklyDownloads = (
|
|
|
77
74
|
const weeklySums = sumByWeek(
|
|
78
75
|
downloads.downloads,
|
|
79
76
|
weekStarts,
|
|
80
|
-
({ day }) =>
|
|
77
|
+
({ day }) => weekStartForDateTime(DateTime.makeUnsafe(day)),
|
|
81
78
|
({ downloads: dayDownloads }) => dayDownloads,
|
|
82
79
|
)
|
|
83
80
|
|
|
@@ -200,20 +197,34 @@ export const packageSnapshotFromResponses = (
|
|
|
200
197
|
}
|
|
201
198
|
|
|
202
199
|
export const weeklyStars = (
|
|
203
|
-
|
|
200
|
+
starHistory: ReadonlyArray<typeof GitHubStarHistoryResponse.Type>,
|
|
204
201
|
weekStarts: ReadonlyArray<string>,
|
|
205
202
|
): ReadonlyArray<WeeklyCount> =>
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
203
|
+
pipe(
|
|
204
|
+
sumByWeek(
|
|
205
|
+
Array.flatMap(starHistory, ({ week, days }) => {
|
|
206
|
+
const sunday = pipe(
|
|
207
|
+
DateTime.fromEpochSeconds(week),
|
|
208
|
+
DateTime.nearest('week', { weekStartsOn: 0 }),
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
return Array.map(days, (count, dayIndex) => ({
|
|
212
|
+
weekStart: weekStartForDateTime(
|
|
213
|
+
DateTime.add(sunday, { days: dayIndex }),
|
|
214
|
+
),
|
|
215
|
+
count,
|
|
216
|
+
}))
|
|
217
|
+
}),
|
|
218
|
+
weekStarts,
|
|
219
|
+
({ weekStart }) => weekStart,
|
|
220
|
+
({ count }) => count,
|
|
211
221
|
),
|
|
222
|
+
Array.map(({ weekStart, amount }) => ({ weekStart, count: amount })),
|
|
212
223
|
)
|
|
213
224
|
|
|
214
225
|
export const cumulativeStarsByWeek = (
|
|
215
226
|
currentStars: number,
|
|
216
|
-
|
|
227
|
+
starHistory: ReadonlyArray<typeof GitHubStarHistoryResponse.Type>,
|
|
217
228
|
weekStarts: ReadonlyArray<string>,
|
|
218
229
|
): ReadonlyArray<WeeklyCount> => {
|
|
219
230
|
const emptyWeeks: ReadonlyArray<WeeklyCount> = []
|
|
@@ -221,7 +232,7 @@ export const cumulativeStarsByWeek = (
|
|
|
221
232
|
weekStart,
|
|
222
233
|
count: 0,
|
|
223
234
|
}))
|
|
224
|
-
const weekly = weeklyStars(
|
|
235
|
+
const weekly = weeklyStars(starHistory, weekStarts)
|
|
225
236
|
const fetchedStars = Array.reduce(
|
|
226
237
|
weekly,
|
|
227
238
|
0,
|
|
@@ -252,7 +263,7 @@ const commitCountForWeek =
|
|
|
252
263
|
activity,
|
|
253
264
|
Array.findFirst(
|
|
254
265
|
item =>
|
|
255
|
-
|
|
266
|
+
weekStartForDateTime(DateTime.fromEpochSeconds(item.week)) ===
|
|
256
267
|
weekStart,
|
|
257
268
|
),
|
|
258
269
|
Option.match({
|
|
@@ -279,13 +290,12 @@ export const weeklyReleaseTotals = (
|
|
|
279
290
|
releases: ReadonlyArray<typeof GitHubReleaseResponse.Type>,
|
|
280
291
|
weekStarts: ReadonlyArray<string>,
|
|
281
292
|
): ReadonlyArray<WeeklyCount> =>
|
|
282
|
-
countByWeek(
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
Option.map(
|
|
287
|
-
|
|
288
|
-
),
|
|
293
|
+
countByWeek(releases, weekStarts, release =>
|
|
294
|
+
pipe(
|
|
295
|
+
release.published_at,
|
|
296
|
+
Option.flatMap(DateTime.make),
|
|
297
|
+
Option.map(weekStartForDateTime),
|
|
298
|
+
),
|
|
289
299
|
)
|
|
290
300
|
|
|
291
301
|
export const makeWeeklyTelemetry = (
|
|
@@ -321,10 +331,10 @@ export const fetchRawTelemetry: Effect.Effect<
|
|
|
321
331
|
> = Effect.gen(function* () {
|
|
322
332
|
const github = yield* GitHubApi
|
|
323
333
|
const npm = yield* NpmApi
|
|
324
|
-
const fetchedAt = yield*
|
|
334
|
+
const fetchedAt = yield* DateTime.now
|
|
325
335
|
|
|
326
336
|
const repository = yield* github.fetchRepository
|
|
327
|
-
const yearCutoff = fetchedAt
|
|
337
|
+
const yearCutoff = DateTime.subtract(fetchedAt, { weeks: LAST_YEAR_WEEKS })
|
|
328
338
|
const [contributors, issues, pullRequests, releases] = yield* Effect.all(
|
|
329
339
|
[
|
|
330
340
|
github.fetchContributors,
|
|
@@ -334,7 +344,7 @@ export const fetchRawTelemetry: Effect.Effect<
|
|
|
334
344
|
],
|
|
335
345
|
{ concurrency: 'unbounded' },
|
|
336
346
|
)
|
|
337
|
-
const
|
|
347
|
+
const starHistory = yield* github.fetchStarHistory(yearCutoff)
|
|
338
348
|
const commitActivity = yield* github.fetchCommitActivity
|
|
339
349
|
const packageData = yield* Effect.forEach(
|
|
340
350
|
packageSpecs,
|
|
@@ -350,13 +360,13 @@ export const fetchRawTelemetry: Effect.Effect<
|
|
|
350
360
|
)
|
|
351
361
|
|
|
352
362
|
return {
|
|
353
|
-
fetchedAt,
|
|
363
|
+
fetchedAt: DateTime.toEpochMillis(fetchedAt),
|
|
354
364
|
repository,
|
|
355
365
|
contributors,
|
|
356
366
|
issues,
|
|
357
367
|
pullRequests,
|
|
358
368
|
releases,
|
|
359
|
-
|
|
369
|
+
starHistory,
|
|
360
370
|
commitActivity,
|
|
361
371
|
packageData,
|
|
362
372
|
}
|
|
@@ -365,7 +375,7 @@ export const fetchRawTelemetry: Effect.Effect<
|
|
|
365
375
|
export const transformTelemetry = (
|
|
366
376
|
raw: RawTelemetry,
|
|
367
377
|
): typeof Telemetry.Type => {
|
|
368
|
-
const weekStarts = weekStartsForLastYear(raw.fetchedAt)
|
|
378
|
+
const weekStarts = weekStartsForLastYear(DateTime.makeUnsafe(raw.fetchedAt))
|
|
369
379
|
|
|
370
380
|
const packageResults = Array.map(
|
|
371
381
|
raw.packageData,
|
|
@@ -390,7 +400,7 @@ export const transformTelemetry = (
|
|
|
390
400
|
)
|
|
391
401
|
const cumulativeStars = cumulativeStarsByWeek(
|
|
392
402
|
raw.repository.stargazers_count,
|
|
393
|
-
raw.
|
|
403
|
+
raw.starHistory,
|
|
394
404
|
weekStarts,
|
|
395
405
|
)
|
|
396
406
|
const warnings = raw.commitActivity.warnings
|
|
@@ -1,51 +1,30 @@
|
|
|
1
|
-
import { Array, Option } from 'effect'
|
|
1
|
+
import { Array, DateTime, Option, pipe } from 'effect'
|
|
2
2
|
|
|
3
3
|
// CONSTANT
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const HOURS_PER_DAY = 24
|
|
7
|
-
const MINUTES_PER_HOUR = 60
|
|
8
|
-
const SECONDS_PER_MINUTE = 60
|
|
9
|
-
const MILLISECONDS_PER_SECOND = 1_000
|
|
10
|
-
const MILLISECONDS_PER_DAY =
|
|
11
|
-
HOURS_PER_DAY *
|
|
12
|
-
MINUTES_PER_HOUR *
|
|
13
|
-
SECONDS_PER_MINUTE *
|
|
14
|
-
MILLISECONDS_PER_SECOND
|
|
15
|
-
const MILLISECONDS_PER_WEEK = DAYS_PER_WEEK * MILLISECONDS_PER_DAY
|
|
16
|
-
const ISO_DATE_LENGTH = 10
|
|
17
|
-
|
|
18
|
-
const LAST_YEAR_WEEKS = 52
|
|
5
|
+
export const LAST_YEAR_WEEKS = 52
|
|
19
6
|
|
|
20
7
|
// WEEKS
|
|
21
8
|
|
|
22
9
|
export type WeeklyCount = Readonly<{ weekStart: string; count: number }>
|
|
23
10
|
|
|
24
|
-
export const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export const utcWeekStartMilliseconds = (milliseconds: number): number => {
|
|
31
|
-
const date = new Date(milliseconds)
|
|
32
|
-
const dayOffset = (date.getUTCDay() + DAYS_PER_WEEK - 1) % DAYS_PER_WEEK
|
|
33
|
-
return Date.UTC(
|
|
34
|
-
date.getUTCFullYear(),
|
|
35
|
-
date.getUTCMonth(),
|
|
36
|
-
date.getUTCDate() - dayOffset,
|
|
11
|
+
export const weekStartForDateTime = (dateTime: DateTime.Utc): string =>
|
|
12
|
+
pipe(
|
|
13
|
+
dateTime,
|
|
14
|
+
DateTime.startOf('week', { weekStartsOn: 1 }),
|
|
15
|
+
DateTime.formatIsoDateUtc,
|
|
37
16
|
)
|
|
38
|
-
}
|
|
39
17
|
|
|
40
|
-
export const
|
|
41
|
-
|
|
18
|
+
export const weekStartsForLastYear = (
|
|
19
|
+
now: DateTime.Utc,
|
|
20
|
+
): ReadonlyArray<string> => {
|
|
21
|
+
const currentWeekStart = DateTime.startOf(now, 'week', { weekStartsOn: 1 })
|
|
42
22
|
|
|
43
|
-
export const weekStartsForLastYear = (now: number): ReadonlyArray<string> => {
|
|
44
|
-
const currentWeekStart = utcWeekStartMilliseconds(now)
|
|
45
23
|
return Array.makeBy(LAST_YEAR_WEEKS, weekIndex =>
|
|
46
|
-
|
|
47
|
-
currentWeekStart
|
|
48
|
-
|
|
24
|
+
pipe(
|
|
25
|
+
currentWeekStart,
|
|
26
|
+
DateTime.subtract({ weeks: LAST_YEAR_WEEKS - weekIndex - 1 }),
|
|
27
|
+
DateTime.formatIsoDateUtc,
|
|
49
28
|
),
|
|
50
29
|
)
|
|
51
30
|
}
|
|
@@ -260,19 +260,13 @@ describe('update', () => {
|
|
|
260
260
|
}),
|
|
261
261
|
}),
|
|
262
262
|
),
|
|
263
|
-
|
|
264
|
-
DragAndDrop.FocusItem({ itemId: firstCardId }),
|
|
265
|
-
DragAndDrop.Message.CompletedFocusItem(),
|
|
266
|
-
),
|
|
263
|
+
DragAndDrop.test.settleFocus({ itemId: firstCardId }),
|
|
267
264
|
message(
|
|
268
265
|
Message.GotDragAndDropMessage({
|
|
269
266
|
message: DragAndDrop.Message.ConfirmedKeyboardDrop(),
|
|
270
267
|
}),
|
|
271
268
|
),
|
|
272
|
-
|
|
273
|
-
DragAndDrop.FocusItem,
|
|
274
|
-
DragAndDrop.Message.CompletedFocusItem(),
|
|
275
|
-
),
|
|
269
|
+
DragAndDrop.test.settleFocus({ itemId: firstCardId }),
|
|
276
270
|
Command.resolve(SaveBoard, Message.CompletedSaveBoard()),
|
|
277
271
|
model(model => {
|
|
278
272
|
const todoColumn = model.columns.find(column => column.id === 'todo')
|
|
@@ -304,19 +298,13 @@ describe('update', () => {
|
|
|
304
298
|
}),
|
|
305
299
|
}),
|
|
306
300
|
),
|
|
307
|
-
|
|
308
|
-
DragAndDrop.FocusItem({ itemId: cardId }),
|
|
309
|
-
DragAndDrop.Message.CompletedFocusItem(),
|
|
310
|
-
),
|
|
301
|
+
DragAndDrop.test.settleFocus({ itemId: cardId }),
|
|
311
302
|
message(
|
|
312
303
|
Message.GotDragAndDropMessage({
|
|
313
304
|
message: DragAndDrop.Message.ConfirmedKeyboardDrop(),
|
|
314
305
|
}),
|
|
315
306
|
),
|
|
316
|
-
|
|
317
|
-
DragAndDrop.FocusItem,
|
|
318
|
-
DragAndDrop.Message.CompletedFocusItem(),
|
|
319
|
-
),
|
|
307
|
+
DragAndDrop.test.settleFocus({ itemId: cardId }),
|
|
320
308
|
Command.resolve(SaveBoard, Message.CompletedSaveBoard()),
|
|
321
309
|
model(model => {
|
|
322
310
|
const todoCards = model.columns
|
|
@@ -332,13 +320,15 @@ describe('update', () => {
|
|
|
332
320
|
})
|
|
333
321
|
|
|
334
322
|
test('cancelled keyboard drag does not change columns', () => {
|
|
323
|
+
const cardId = 'card-1'
|
|
324
|
+
|
|
335
325
|
story(
|
|
336
326
|
update,
|
|
337
327
|
given(emptyModel),
|
|
338
328
|
message(
|
|
339
329
|
Message.GotDragAndDropMessage({
|
|
340
330
|
message: DragAndDrop.Message.ActivatedKeyboardDrag({
|
|
341
|
-
itemId:
|
|
331
|
+
itemId: cardId,
|
|
342
332
|
containerId: 'todo',
|
|
343
333
|
index: 0,
|
|
344
334
|
}),
|
|
@@ -349,10 +339,7 @@ describe('update', () => {
|
|
|
349
339
|
message: DragAndDrop.Message.CancelledDrag(),
|
|
350
340
|
}),
|
|
351
341
|
),
|
|
352
|
-
|
|
353
|
-
DragAndDrop.FocusItem,
|
|
354
|
-
DragAndDrop.Message.CompletedFocusItem(),
|
|
355
|
-
),
|
|
342
|
+
DragAndDrop.test.settleFocus({ itemId: cardId }),
|
|
356
343
|
model(model => {
|
|
357
344
|
expect(model.columns).toStrictEqual(emptyModel.columns)
|
|
358
345
|
}),
|
|
@@ -153,48 +153,37 @@ const loadCatalogOnGalleryEntry =
|
|
|
153
153
|
}
|
|
154
154
|
: { model }
|
|
155
155
|
|
|
156
|
-
const
|
|
157
|
-
(transition: AppTransition): Step =>
|
|
158
|
-
model =>
|
|
159
|
-
Option.match(Transition.entered(transition, 'Painting'), {
|
|
160
|
-
onNone: () => ({ model }),
|
|
161
|
-
onSome: ({ paintingId }) => ({
|
|
162
|
-
model: modifyFields(model, {
|
|
163
|
-
paintingStatus: () => PaintingStatus.Loading({ paintingId }),
|
|
164
|
-
}),
|
|
165
|
-
commands: [LoadPainting({ paintingId })],
|
|
166
|
-
}),
|
|
167
|
-
})
|
|
156
|
+
const keepModel: Step = model => ({ model })
|
|
168
157
|
|
|
169
|
-
const
|
|
170
|
-
(
|
|
171
|
-
model =>
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
158
|
+
const loadPainting =
|
|
159
|
+
(paintingId: number): Step =>
|
|
160
|
+
model => ({
|
|
161
|
+
model: modifyFields(model, {
|
|
162
|
+
paintingStatus: () => PaintingStatus.Loading({ paintingId }),
|
|
163
|
+
}),
|
|
164
|
+
commands: [LoadPainting({ paintingId })],
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
const reconcilePaintingRoute = (transition: AppTransition): Step =>
|
|
168
|
+
Transition.matchOrElse<Step>()(
|
|
169
|
+
transition,
|
|
170
|
+
'Painting',
|
|
171
|
+
{
|
|
172
|
+
Entered: ({ paintingId }) => loadPainting(paintingId),
|
|
173
|
+
Stayed: ({ previousRoute, nextRoute }) =>
|
|
175
174
|
previousRoute.paintingId === nextRoute.paintingId
|
|
176
|
-
?
|
|
177
|
-
:
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
paintingId: nextRoute.paintingId,
|
|
182
|
-
}),
|
|
183
|
-
}),
|
|
184
|
-
commands: [LoadPainting({ paintingId: nextRoute.paintingId })],
|
|
185
|
-
},
|
|
186
|
-
})
|
|
175
|
+
? keepModel
|
|
176
|
+
: loadPainting(nextRoute.paintingId),
|
|
177
|
+
},
|
|
178
|
+
() => keepModel,
|
|
179
|
+
)
|
|
187
180
|
|
|
188
181
|
const saveDraftOnStudioExit =
|
|
189
182
|
(transition: AppTransition): Step =>
|
|
190
183
|
model =>
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
model.studioDraft === ''
|
|
195
|
-
? { model }
|
|
196
|
-
: { model, commands: [SaveDraft({ draft: model.studioDraft })] },
|
|
197
|
-
})
|
|
184
|
+
Transition.isExiting(transition, 'Studio') && model.studioDraft !== ''
|
|
185
|
+
? { model, commands: [SaveDraft({ draft: model.studioDraft })] }
|
|
186
|
+
: { model }
|
|
198
187
|
|
|
199
188
|
const handleTransition = (
|
|
200
189
|
model: Model,
|
|
@@ -203,8 +192,7 @@ const handleTransition = (
|
|
|
203
192
|
Update.combine(model, [
|
|
204
193
|
logTransition(transition),
|
|
205
194
|
loadCatalogOnGalleryEntry(transition),
|
|
206
|
-
|
|
207
|
-
reloadPaintingOnIdChange(transition),
|
|
195
|
+
reconcilePaintingRoute(transition),
|
|
208
196
|
saveDraftOnStudioExit(transition),
|
|
209
197
|
])
|
|
210
198
|
|
|
@@ -3,6 +3,7 @@ import { Command, Dom, Runtime, Subscription, Update } from 'foldkit'
|
|
|
3
3
|
import { Document, Html, HtmlBuilder } from 'foldkit/html'
|
|
4
4
|
import { defineMessageUnion } from 'foldkit/message'
|
|
5
5
|
import { UrlRequest, load, pushUrl } from 'foldkit/navigation'
|
|
6
|
+
import { Transition } from 'foldkit/route'
|
|
6
7
|
import { modifyFields } from 'foldkit/struct'
|
|
7
8
|
import { Url, toString as urlToString } from 'foldkit/url'
|
|
8
9
|
|
|
@@ -88,6 +89,7 @@ const LoadExternal = Command.define('LoadExternal', {
|
|
|
88
89
|
// UPDATE
|
|
89
90
|
|
|
90
91
|
type UpdateReturn = Update.Return<Model, Message>
|
|
92
|
+
type Step = Update.Step<Model, Message>
|
|
91
93
|
|
|
92
94
|
const navigationUrlByShortcut: Readonly<
|
|
93
95
|
Record<NavigationShortcut, () => string>
|
|
@@ -114,9 +116,11 @@ const foldPeople = foldPeopleEntry(People.update)
|
|
|
114
116
|
const foldPeopleRouteChanged = foldPeopleEntry(People.informRouteChanged)
|
|
115
117
|
|
|
116
118
|
const setRoute =
|
|
117
|
-
(nextRoute: AppRoute):
|
|
119
|
+
(nextRoute: AppRoute): Step =>
|
|
118
120
|
model => ({ model: modifyFields(model, { route: () => nextRoute }) })
|
|
119
121
|
|
|
122
|
+
const keepModel: Step = model => ({ model })
|
|
123
|
+
|
|
120
124
|
export const update = (model: Model, message: Message) =>
|
|
121
125
|
Message.match<UpdateReturn>(message, {
|
|
122
126
|
CompletedNavigateInternal: () => ({ model }),
|
|
@@ -137,15 +141,18 @@ export const update = (model: Model, message: Message) =>
|
|
|
137
141
|
ChangedUrl: ({ url }) => {
|
|
138
142
|
const nextRoute = urlToAppRoute(url)
|
|
139
143
|
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
const transition = Transition.make(model.route, nextRoute)
|
|
145
|
+
const informPeopleRoute = Transition.matchOrElse<Step>()(
|
|
146
|
+
transition,
|
|
147
|
+
'People',
|
|
148
|
+
{
|
|
149
|
+
Entered: peopleRoute => foldPeopleRouteChanged(peopleRoute),
|
|
150
|
+
Stayed: ({ nextRoute }) => foldPeopleRouteChanged(nextRoute),
|
|
151
|
+
},
|
|
152
|
+
() => keepModel,
|
|
146
153
|
)
|
|
147
154
|
|
|
148
|
-
return Update.combine(model, [setRoute(nextRoute),
|
|
155
|
+
return Update.combine(model, [setRoute(nextRoute), informPeopleRoute])
|
|
149
156
|
},
|
|
150
157
|
|
|
151
158
|
EnteredNavigationShortcut: ({ shortcut }) => {
|
|
@@ -246,6 +246,27 @@ describe('update', () => {
|
|
|
246
246
|
}),
|
|
247
247
|
)
|
|
248
248
|
})
|
|
249
|
+
|
|
250
|
+
test('a hash-only URL change keeps the People page in sync', () => {
|
|
251
|
+
story(
|
|
252
|
+
update,
|
|
253
|
+
given(onPeople('designer')),
|
|
254
|
+
message(
|
|
255
|
+
Message.ChangedUrl({
|
|
256
|
+
url: urlOrThrow(
|
|
257
|
+
'http://localhost/people?searchText=designer#results',
|
|
258
|
+
),
|
|
259
|
+
}),
|
|
260
|
+
),
|
|
261
|
+
model(model => {
|
|
262
|
+
expect(model.peoplePage.searchInput).toBe('designer')
|
|
263
|
+
expect(model.peoplePage.searchHistory).toStrictEqual(['designer'])
|
|
264
|
+
expect(model.peoplePage.results._tag).toBe('Loading')
|
|
265
|
+
}),
|
|
266
|
+
Command.expectHas(People.FetchPeople),
|
|
267
|
+
resolveFetch('designer'),
|
|
268
|
+
)
|
|
269
|
+
})
|
|
249
270
|
})
|
|
250
271
|
|
|
251
272
|
describe('GotPeopleMessage', () => {
|
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"channel": "stable",
|
|
4
|
-
"sourceCommit": "
|
|
4
|
+
"sourceCommit": "7ee214268c602967937b80f6f20d1e831f2e8ab6",
|
|
5
5
|
"packages": {
|
|
6
|
-
"create-foldkit-app": "0.
|
|
7
|
-
"@foldkit/devtools": "0.
|
|
8
|
-
"@foldkit/devtools-mcp": "0.
|
|
9
|
-
"foldkit": "0.
|
|
10
|
-
"@foldkit/markdown": "0.14.
|
|
6
|
+
"create-foldkit-app": "0.40.0",
|
|
7
|
+
"@foldkit/devtools": "0.169.0",
|
|
8
|
+
"@foldkit/devtools-mcp": "0.25.0",
|
|
9
|
+
"foldkit": "0.169.0",
|
|
10
|
+
"@foldkit/markdown": "0.14.4",
|
|
11
11
|
"@foldkit/node": "0.1.0",
|
|
12
12
|
"@foldkit/oxlint-plugin": "0.15.3",
|
|
13
|
-
"@foldkit/ui": "0.
|
|
14
|
-
"@foldkit/vite-plugin": "0.
|
|
13
|
+
"@foldkit/ui": "0.169.0",
|
|
14
|
+
"@foldkit/vite-plugin": "0.28.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"@foldkit/
|
|
19
|
-
"@foldkit/
|
|
17
|
+
"@effect/tsgo": "0.50.0",
|
|
18
|
+
"@foldkit/devtools": "0.169.0",
|
|
19
|
+
"@foldkit/vite-plugin": "0.28.0",
|
|
20
|
+
"@foldkit/devtools-mcp": "0.25.0",
|
|
20
21
|
"@foldkit/oxlint-plugin": "0.15.3",
|
|
21
22
|
"@types/node": "26.4.0",
|
|
22
23
|
"happy-dom": "^20.14.5",
|
|
23
24
|
"oxfmt": "^0.66.0",
|
|
24
|
-
"oxlint": "
|
|
25
|
+
"oxlint": "1.85.0",
|
|
26
|
+
"oxlint-tsgolint": "7.0.2003",
|
|
25
27
|
"vitest": "^5.0.2"
|
|
26
28
|
}
|
|
27
29
|
}
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
"typecheck": "tsc --noEmit",
|
|
10
10
|
"format": "oxfmt",
|
|
11
11
|
"test": "vitest run",
|
|
12
|
-
"lint": "oxlint src scripts"
|
|
12
|
+
"lint": "oxlint src scripts && effect-tsgo patch --no-typescript --oxlint && oxlint --config .oxlintrc.effect.json --deny-warnings src scripts"
|
|
13
13
|
}
|
|
14
14
|
}
|
package/dist/utils/packages.js
CHANGED
|
@@ -36,6 +36,7 @@ const ReleaseManifest = Schema.Struct({
|
|
|
36
36
|
dependencies: StringRecord,
|
|
37
37
|
});
|
|
38
38
|
const TEMPLATE_DEV_DEPENDENCIES = [
|
|
39
|
+
'@effect/tsgo',
|
|
39
40
|
'@foldkit/devtools',
|
|
40
41
|
'@foldkit/vite-plugin',
|
|
41
42
|
'@foldkit/devtools-mcp',
|
|
@@ -43,6 +44,7 @@ const TEMPLATE_DEV_DEPENDENCIES = [
|
|
|
43
44
|
'happy-dom',
|
|
44
45
|
'oxfmt',
|
|
45
46
|
'oxlint',
|
|
47
|
+
'oxlint-tsgolint',
|
|
46
48
|
'vitest',
|
|
47
49
|
];
|
|
48
50
|
const SERVER_RENDERING_DEV_DEPENDENCIES = ['@types/node'];
|
package/package.json
CHANGED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { Array, Effect, Layer, Match, String } from 'effect'
|
|
2
|
-
import { HttpClient, HttpClientResponse } from 'effect/http'
|
|
3
|
-
import { expect, test } from 'vitest'
|
|
4
|
-
|
|
5
|
-
import { GitHubApiLive } from './githubApi'
|
|
6
|
-
import {
|
|
7
|
-
mockGitHubRepository,
|
|
8
|
-
mockNpmDownloads,
|
|
9
|
-
mockNpmPackument,
|
|
10
|
-
} from './main.fixture'
|
|
11
|
-
import { NpmApiLive } from './npmApi'
|
|
12
|
-
import { fetchRawTelemetry, transformTelemetry } from './telemetry'
|
|
13
|
-
|
|
14
|
-
test('folds public API responses into a Telemetry value', async () => {
|
|
15
|
-
const mockClient = HttpClient.make(request =>
|
|
16
|
-
Effect.sync(() => {
|
|
17
|
-
const body = Match.value(request.url).pipe(
|
|
18
|
-
Match.when(String.includes('/contributors'), () => [
|
|
19
|
-
{ login: 'devin', contributions: 42 },
|
|
20
|
-
]),
|
|
21
|
-
Match.when(String.includes('/issues'), () => [
|
|
22
|
-
{},
|
|
23
|
-
{ pull_request: {} },
|
|
24
|
-
]),
|
|
25
|
-
Match.when(String.includes('/pulls'), () => [{ id: 1 }]),
|
|
26
|
-
Match.when(String.includes('/releases'), () => [
|
|
27
|
-
{
|
|
28
|
-
tag_name: 'v0.115.0',
|
|
29
|
-
published_at: '2026-06-20T12:00:00Z',
|
|
30
|
-
prerelease: false,
|
|
31
|
-
draft: false,
|
|
32
|
-
},
|
|
33
|
-
]),
|
|
34
|
-
Match.when(String.includes('/stargazers'), () => [
|
|
35
|
-
{ starred_at: '2026-06-15T12:00:00Z' },
|
|
36
|
-
]),
|
|
37
|
-
Match.when(String.includes('/stats/commit_activity'), () => [
|
|
38
|
-
{ week: 1781481600, total: 5 },
|
|
39
|
-
]),
|
|
40
|
-
Match.when(String.includes('/stats/code_frequency'), () => [
|
|
41
|
-
[1781481600, 120, -35],
|
|
42
|
-
]),
|
|
43
|
-
Match.when(String.includes('api.npmjs.org'), () => mockNpmDownloads),
|
|
44
|
-
Match.when(
|
|
45
|
-
String.includes('registry.npmjs.org'),
|
|
46
|
-
() => mockNpmPackument,
|
|
47
|
-
),
|
|
48
|
-
Match.orElse(() => mockGitHubRepository),
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
return HttpClientResponse.fromWeb(
|
|
52
|
-
request,
|
|
53
|
-
new Response(JSON.stringify(body), { status: 200 }),
|
|
54
|
-
)
|
|
55
|
-
}),
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
const telemetryLayer = Layer.mergeAll(GitHubApiLive, NpmApiLive).pipe(
|
|
59
|
-
Layer.provide(Layer.succeed(HttpClient.HttpClient, mockClient)),
|
|
60
|
-
)
|
|
61
|
-
const telemetry = await fetchRawTelemetry.pipe(
|
|
62
|
-
Effect.map(transformTelemetry),
|
|
63
|
-
Effect.provide(telemetryLayer),
|
|
64
|
-
Effect.runPromise,
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
expect(telemetry.repository.stars).toBe(342)
|
|
68
|
-
expect(telemetry.repository.openIssues).toBe(1)
|
|
69
|
-
expect(Array.length(telemetry.packages)).toBeGreaterThan(0)
|
|
70
|
-
})
|