Skip to content

Commit 15d0921

Browse files
committed
Configure VSCode extensions to be available by default in GitPod
1 parent 2bee44f commit 15d0921

File tree

10 files changed

+92
-48
lines changed

10 files changed

+92
-48
lines changed

.last-exported-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Last exported commit from parent repo: 1919c62c945cb2bf81acf583dd4f7725c3174242
1+
Last exported commit from parent repo: ea12b1609ea5f0fc254b245dfe929a7864b4be87

nix-bootstrap.cabal

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cabal-version: 2.0
55
-- see: https://github.com/sol/hpack
66

77
name: nix-bootstrap
8-
version: 1.5.2.1
8+
version: 1.5.3.0
99
author: gchquser
1010
maintainer: [email protected]
1111
copyright: Crown Copyright
@@ -67,6 +67,7 @@ library
6767
Bootstrap.Data.ProjectName
6868
Bootstrap.Data.ProjectType
6969
Bootstrap.Data.Version
70+
Bootstrap.Data.VSCodeExtension
7071
Bootstrap.Error
7172
Bootstrap.GitPod
7273
Bootstrap.Monad

package.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
name: nix-bootstrap
15-
version: 1.5.2.1
15+
version: 1.5.3.0
1616
author: gchquser
1717
maintainer: [email protected]
1818
copyright: Crown Copyright

src/Bootstrap.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import Bootstrap.Data.Bootstrappable.Elm.Review.ElmJson
3535
)
3636
import Bootstrap.Data.Bootstrappable.Envrc (Envrc (Envrc))
3737
import Bootstrap.Data.Bootstrappable.FlakeNix (flakeNixFor)
38-
import Bootstrap.Data.Bootstrappable.GitPodYml (GitPodYml (GitPodYml))
38+
import Bootstrap.Data.Bootstrappable.GitPodYml (gitPodYmlFor)
3939
import Bootstrap.Data.Bootstrappable.Gitignore (gitignoreFor)
4040
import Bootstrap.Data.Bootstrappable.GitlabCIConfig (gitlabCIConfigFor)
4141
import Bootstrap.Data.Bootstrappable.Go.Modfile (goModfileFor)
@@ -528,7 +528,7 @@ makeBuildPlan MakeBuildPlanArgs {..} = do
528528
~: cargoLockFor mbpProjectType mbpProjectName
529529
~: cargoTomlFor mbpProjectType mbpProjectName
530530
~: mainRsFor mbpProjectType
531-
~: GitPodYml
531+
~: gitPodYmlFor mbpProjectType
532532
~: HNil
533533
)
534534
readmeWithBuildPlan :: BuildPlan -> m BuildPlanFile

src/Bootstrap/Data/Bootstrappable/DevContainer.hs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@ module Bootstrap.Data.Bootstrappable.DevContainer
1010
where
1111

1212
import Bootstrap.Data.Bootstrappable (Bootstrappable (bootstrapContent, bootstrapName, bootstrapReason), bootstrapContentPrettyJson, bootstrapContentYaml)
13-
import Bootstrap.Data.Bootstrappable.VSCodeExtensions
14-
( VSCodeExtension,
15-
extensionsFor,
16-
)
1713
import Bootstrap.Data.DevContainer (DevContainerConfig (DevContainerConfig))
1814
import Bootstrap.Data.ProjectName (ProjectName (unProjectName))
1915
import qualified Bootstrap.Data.ProjectName as ProjectName
2016
import Bootstrap.Data.ProjectType (ProjectType)
17+
import Bootstrap.Data.VSCodeExtension (VSCodeExtension, vsCodeExtensionsFor)
2118
import Data.Aeson (KeyValue ((.=)), ToJSON (toJSON))
2219
import qualified Data.Aeson as Aeson
2320
import Data.Char (isSpace)
@@ -154,7 +151,7 @@ devContainerJsonFor (DevContainerConfig True) projectName projectType =
154151
Just
155152
DevContainerJson
156153
{ projectName = projectName,
157-
extensions = extensionsFor projectType
154+
extensions = vsCodeExtensionsFor projectType
158155
}
159156

160157
newtype DevContainerDockerCompose = DevContainerDockerCompose
Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,33 @@
11
-- | Copyright : (c) Crown Copyright GCHQ
2-
module Bootstrap.Data.Bootstrappable.GitPodYml (GitPodYml (GitPodYml)) where
2+
module Bootstrap.Data.Bootstrappable.GitPodYml (GitPodYml, gitPodYmlFor) where
33

4-
import Bootstrap.Data.Bootstrappable (Bootstrappable (bootstrapContent, bootstrapName, bootstrapReason), bootstrapContentYaml)
4+
import Bootstrap.Data.Bootstrappable
5+
( Bootstrappable
6+
( bootstrapContent,
7+
bootstrapName,
8+
bootstrapReason
9+
),
10+
bootstrapContentYaml,
11+
)
12+
import Bootstrap.Data.ProjectType (ProjectType)
13+
import Bootstrap.Data.VSCodeExtension (vsCodeExtensionsFor)
514
import Data.Aeson (KeyValue ((.=)), ToJSON (toJSON))
615
import qualified Data.Aeson as Aeson
716
import Data.Aeson.Types (emptyArray)
817

9-
data GitPodYml = GitPodYml
18+
newtype GitPodYml = GitPodYml ProjectType
1019

1120
instance Bootstrappable GitPodYml where
1221
bootstrapName = const ".gitpod.yml"
1322
bootstrapReason = const "This overrides GitPod's automated tasks; they are not needed."
1423
bootstrapContent = pure . Right . bootstrapContentYaml
1524

1625
instance ToJSON GitPodYml where
17-
toJSON = const $ Aeson.object ["tasks" .= emptyArray]
26+
toJSON (GitPodYml projectType) =
27+
Aeson.object
28+
[ "tasks" .= emptyArray,
29+
"vscode" .= Aeson.object ["extensions" .= toJSON (vsCodeExtensionsFor projectType)]
30+
]
31+
32+
gitPodYmlFor :: ProjectType -> Maybe GitPodYml
33+
gitPodYmlFor = Just . GitPodYml
Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
1-
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
2-
31
-- |
42
-- Description : Bootstraps .vscode/extensions.json
53
-- Copyright : (c) Crown Copyright GCHQ
64
module Bootstrap.Data.Bootstrappable.VSCodeExtensions
75
( VSCodeExtensions,
86
vsCodeExtensionsFileFor,
9-
VSCodeExtension (..),
10-
extensionsFor,
117
)
128
where
139

1410
import Bootstrap.Data.Bootstrappable
1511
( Bootstrappable (bootstrapContent, bootstrapName, bootstrapReason),
1612
bootstrapContentPrettyJson,
1713
)
18-
import Bootstrap.Data.ProjectType
19-
( HaskellOptions (HaskellOptions),
20-
InstallLombok (unInstallLombok),
21-
JavaOptions (JavaOptions),
22-
ProjectType (Elm, Go, Haskell, Java, Minimal, Node, Python, Rust),
23-
)
14+
import Bootstrap.Data.ProjectType (ProjectType)
15+
import Bootstrap.Data.VSCodeExtension (vsCodeExtensionsFor)
2416
import Data.Aeson (KeyValue ((.=)), ToJSON (toJSON))
2517
import qualified Data.Aeson as Aeson
2618

@@ -35,27 +27,8 @@ instance Bootstrappable VSCodeExtensions where
3527
instance ToJSON VSCodeExtensions where
3628
toJSON (VSCodeExtensions projectType) =
3729
Aeson.object
38-
["recommendations" .= Aeson.Array (fromList . (toJSON <$>) $ extensionsFor projectType)]
30+
["recommendations" .= Aeson.Array (fromList . (toJSON <$>) $ vsCodeExtensionsFor projectType)]
3931

4032
-- | Constructs `VSCodeExtensions` for the given `ProjectType`
4133
vsCodeExtensionsFileFor :: ProjectType -> Maybe VSCodeExtensions
4234
vsCodeExtensionsFileFor = Just . VSCodeExtensions
43-
44-
-- | Represents the ID of an individual extension
45-
newtype VSCodeExtension = VSCodeExtension Text
46-
deriving newtype (ToJSON)
47-
48-
-- | The list of extensions we recommend for the given `ProjectType`
49-
extensionsFor :: ProjectType -> [VSCodeExtension]
50-
extensionsFor =
51-
(VSCodeExtension <$>) . (["arrterian.nix-env-selector", "jnoortheen.nix-ide"] <>) . \case
52-
Minimal -> []
53-
Elm _ -> ["Elmtooling.elm-ls-vscode"]
54-
(Haskell (HaskellOptions _ _)) -> ["haskell.haskell"]
55-
Node _ -> []
56-
Go _ -> ["golang.Go"]
57-
Java (JavaOptions _ installLombok _) ->
58-
["vscjava.vscode-java-pack"]
59-
<> ["gabrielbb.vscode-lombok" | unInstallLombok installLombok]
60-
Python _ -> ["ms-python.python"]
61-
Rust -> ["rust-lang.rust-analyzer"]
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
2+
3+
-- | Copyright : (c) Crown Copyright GCHQ
4+
-- Description : Utilities for working with VSCode extensions
5+
module Bootstrap.Data.VSCodeExtension (VSCodeExtension (..), vsCodeExtensionsFor) where
6+
7+
import Bootstrap.Data.ProjectType
8+
( HaskellOptions (HaskellOptions),
9+
InstallLombok (unInstallLombok),
10+
JavaOptions (JavaOptions),
11+
ProjectType
12+
( Elm,
13+
Go,
14+
Haskell,
15+
Java,
16+
Minimal,
17+
Node,
18+
Python,
19+
Rust
20+
),
21+
)
22+
import Data.Aeson (ToJSON)
23+
24+
-- | Represents the ID of an individual extension
25+
newtype VSCodeExtension = VSCodeExtension Text
26+
deriving newtype (ToJSON)
27+
28+
-- | The list of extensions we recommend for the given `ProjectType`
29+
vsCodeExtensionsFor :: ProjectType -> [VSCodeExtension]
30+
vsCodeExtensionsFor =
31+
(VSCodeExtension <$>) . (["arrterian.nix-env-selector", "jnoortheen.nix-ide"] <>) . \case
32+
Minimal -> []
33+
Elm _ -> ["Elmtooling.elm-ls-vscode"]
34+
(Haskell (HaskellOptions _ _)) -> ["haskell.haskell"]
35+
Node _ -> []
36+
Go _ -> ["golang.Go"]
37+
Java (JavaOptions _ installLombok _) ->
38+
["vscjava.vscode-java-pack"]
39+
<> ["gabrielbb.vscode-lombok" | unInstallLombok installLombok]
40+
Python _ -> ["ms-python.python"]
41+
Rust -> ["rust-lang.rust-analyzer"]
Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
1+
{-# LANGUAGE QuasiQuotes #-}
2+
13
-- | Copyright : (c) Crown Copyright GCHQ
24
module Bootstrap.Data.Bootstrappable.GitPodYmlSpec (spec) where
35

46
import Bootstrap.Data.Bootstrappable (Bootstrappable (bootstrapContent))
5-
import Bootstrap.Data.Bootstrappable.GitPodYml (GitPodYml (GitPodYml))
7+
import Bootstrap.Data.Bootstrappable.GitPodYml (gitPodYmlFor)
8+
import Bootstrap.Data.ProjectType
9+
( NodePackageManager (NPM),
10+
ProjectType (Node),
11+
)
612
import Test.Hspec (Spec, describe, it)
713
import Test.Hspec.Expectations.Pretty (shouldBe)
14+
import Text.RawString.QQ (r)
815

916
spec :: Spec
1017
spec = describe ".gitpod.yml rendering" do
1118
it "renders the yml correctly" do
12-
bootstrapContent GitPodYml >>= (`shouldBe` Right "tasks: []\n")
19+
bootstrapContent (gitPodYmlFor (Node NPM))
20+
>>= ( `shouldBe`
21+
Right
22+
[r|tasks: []
23+
vscode:
24+
extensions:
25+
- arrterian.nix-env-selector
26+
- jnoortheen.nix-ide
27+
|]
28+
)

test/Bootstrap/Data/BuildPlanSpec.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Bootstrap.Data.Bootstrappable.DevContainer
1010
)
1111
import Bootstrap.Data.Bootstrappable.Envrc (Envrc (Envrc))
1212
import Bootstrap.Data.Bootstrappable.FlakeNix (flakeNixFor)
13-
import Bootstrap.Data.Bootstrappable.GitPodYml (GitPodYml (GitPodYml))
13+
import Bootstrap.Data.Bootstrappable.GitPodYml (gitPodYmlFor)
1414
import Bootstrap.Data.Bootstrappable.Gitignore (gitignoreFor)
1515
import Bootstrap.Data.Bootstrappable.GitlabCIConfig (gitlabCIConfigFor)
1616
import Bootstrap.Data.Bootstrappable.Haskell.LibHs (libHsFor)
@@ -86,7 +86,7 @@ spec = describe "toReasonTree" do
8686
~: cargoLockFor Rust projectName
8787
~: cargoTomlFor Rust projectName
8888
~: mainRsFor Rust
89-
~: GitPodYml
89+
~: gitPodYmlFor projectType
9090
~: HNil
9191
)
9292
pure $ toReasonTree buildPlan

0 commit comments

Comments
 (0)