Skip to content

Commit 48bc6e5

Browse files
committed
Fix technologies
1 parent 5f2266a commit 48bc6e5

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

packages/create-next-stack/src/main/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export type Package = {
5757
version: string
5858
}
5959

60-
type Technology = {
60+
export type Technology = {
6161
/** ID that uniquely identified the technology across all plugins' technologies. */
6262
id: string
6363
/** The name of the technology. */

packages/create-next-stack/src/main/plugins/create-next-stack/add-content/templates/LandingPage/generate-technologies.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
import endent from "endent"
22
import { ValidCNSInputs } from "../../../../../create-next-stack-types"
3+
import { DeeplyReadonly } from "../../../../../helpers/deeply-readonly"
34
import { stringify } from "../../../../../helpers/stringify"
4-
import { getSortedFilteredTechnologies } from "../../../sort-orders/technologies"
5+
import { getTechnologies } from "../../../sort-orders/technologies"
56

67
// This type should match the one in the template below.
7-
export type Technology = {
8+
export type Technology = DeeplyReadonly<{
89
name: string
910
description: string
1011
links: Array<{
1112
title: string
1213
url: string
1314
}>
14-
}
15+
}>
1516

1617
export const generateTechnologies = (inputs: ValidCNSInputs): string => {
17-
const technologies = getSortedFilteredTechnologies(inputs)
18+
const technologies: Technology[] = getTechnologies(inputs)
1819

1920
return endent`
2021
export type Technology = {

packages/create-next-stack/src/main/plugins/create-next-stack/add-readme/generate-technology-table-rows.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import { ValidCNSInputs } from "../../../create-next-stack-types"
2-
import { getSortedFilteredTechnologies } from "../sort-orders/technologies"
2+
import { getTechnologies } from "../sort-orders/technologies"
33

44
export const generateTechnologyTableRows = async (
55
inputs: ValidCNSInputs
66
): Promise<string> => {
7-
const technologies = getSortedFilteredTechnologies(inputs).map(
8-
(technology) => ({
9-
name: technology.name,
10-
links: technology.links.map((l) => `[${l.title}](${l.url})`).join(" - "),
11-
})
12-
)
7+
const technologies = getTechnologies(inputs).map((technology) => ({
8+
name: technology.name,
9+
links: technology.links.map((l) => `[${l.title}](${l.url})`).join(" - "),
10+
}))
1311
return technologies
1412
.map((technology) => `| ${technology.name} | ${technology.links} |`)
1513
.join("\n")

packages/create-next-stack/src/main/plugins/create-next-stack/sort-orders/technologies.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { ValidCNSInputs } from "../../../create-next-stack-types"
2+
import { DeeplyReadonly } from "../../../helpers/deeply-readonly"
23
import { compareByOrder } from "../../../helpers/sort-by-order"
4+
import { Technology } from "../../../plugin"
35
import { filterPlugins } from "../../../setup/setup"
46

57
export const technologiesSortOrder: string[] = [
@@ -27,12 +29,13 @@ export const technologiesSortOrder: string[] = [
2729
"reactIcons",
2830
]
2931

30-
export const getSortedFilteredTechnologies = (inputs: ValidCNSInputs) => {
31-
const technologies = filterPlugins(inputs).flatMap(
32-
(plugin) => plugin.technologies ?? []
33-
)
34-
const dedupedTechnologies = [...new Set(technologies)]
35-
return dedupedTechnologies.sort((a, b) =>
36-
compareByOrder(a.name, b.name, technologiesSortOrder)
37-
)
32+
export const getTechnologies = (
33+
inputs: ValidCNSInputs
34+
): Array<Omit<DeeplyReadonly<Technology>, "id">> => {
35+
return filterPlugins(inputs)
36+
.flatMap((plugin) => plugin.technologies ?? [])
37+
.sort((a, b) => compareByOrder(a.id, b.id, technologiesSortOrder))
38+
.map(({ id, ...rest }) => ({
39+
...rest,
40+
}))
3841
}

0 commit comments

Comments
 (0)