Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove legacy and addToPackageSet flags from operations #338

Merged
merged 2 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.psc*
f-f marked this conversation as resolved.
Show resolved Hide resolved
examples
registry-index
16 changes: 8 additions & 8 deletions ci/src/Registry/API.purs
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,21 @@ readOperation eventPath = do
runOperation :: Operation -> RegistryM Unit
runOperation operation = case operation of
-- TODO handle addToPackageSet
Addition { packageName, legacy, newRef, newPackageLocation } -> do
Addition { packageName, newRef, newPackageLocation } -> do
-- check that we don't have a metadata file for that package
ifM (liftAff $ FS.exists $ metadataFile packageName)
-- if the metadata file already exists then we steer this to be an Update instead
(runOperation $ Update { packageName, legacy, updateRef: newRef })
(runOperation $ Update { packageName, updateRef: newRef })
do
addOrUpdate { packageName, legacy, ref: newRef } $ mkNewMetadata newPackageLocation
addOrUpdate { packageName, ref: newRef } $ mkNewMetadata newPackageLocation

Update { packageName, legacy, updateRef } -> do
Update { packageName, updateRef } -> do
ifM (liftAff $ FS.exists $ metadataFile packageName)
do
metadata <- readPackagesMetadata >>= \packages -> case Map.lookup packageName packages of
Nothing -> throwWithComment "Couldn't read metadata file for your package"
Just m -> pure m
addOrUpdate { packageName, legacy, ref: updateRef } metadata
addOrUpdate { packageName, ref: updateRef } metadata
(throwWithComment "Metadata file should exist. Did you mean to create an Addition?")

Unpublish _ -> throwWithComment "Unpublish not implemented! Ask us for help!" -- TODO
Expand All @@ -133,8 +133,8 @@ metadataFile packageName = metadataDir <> "/" <> PackageName.print packageName <
indexDir :: FilePath
indexDir = "../registry-index"

addOrUpdate :: { legacy :: Boolean, ref :: String, packageName :: PackageName } -> Metadata -> RegistryM Unit
addOrUpdate { ref, legacy, packageName } metadata = do
addOrUpdate :: { ref :: String, packageName :: PackageName } -> Metadata -> RegistryM Unit
addOrUpdate { ref, packageName } metadata = do
-- let's get a temp folder to do our stuffs
tmpDir <- liftEffect $ Tmp.mkTmpDir
-- fetch the repo and put it in the tempdir, returning the name of its toplevel dir
Expand Down Expand Up @@ -168,7 +168,7 @@ addOrUpdate { ref, legacy, packageName } metadata = do
log $ "Package extracted in " <> absoluteFolderPath

-- If this is a legacy import, then we need to construct a `Manifest` for it
when legacy do
unlessM (liftAff $ FS.exists manifestPath) do
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As described in this issue, a "legacy" package is any package without a purs.json manifest file.

address <- case metadata.location of
Git _ -> throwWithComment "Legacy packages can only come from GitHub. Aborting."
GitHub { owner, repo } -> pure { owner, repo }
Expand Down
5 changes: 1 addition & 4 deletions ci/src/Registry/Schema.purs
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,13 @@ instance RegistryJson Operation where
parseAddition <|> parseUpdate <|> parseUnpublish

type AdditionData =
{ addToPackageSet :: Boolean
, legacy :: Boolean
, newPackageLocation :: Repo
{ newPackageLocation :: Repo
, newRef :: String
, packageName :: PackageName
}

type UpdateData =
{ packageName :: PackageName
, legacy :: Boolean
, updateRef :: String
}

Expand Down
4 changes: 1 addition & 3 deletions ci/src/Registry/Scripts/LegacyImport.purs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ main = Aff.launchAff_ do
for_ packagesToUpload \manifest -> do
let
addition = Addition
{ addToPackageSet: false -- heh, we don't have package sets until we do this import!
, legacy: true
, newPackageLocation: manifest.repository
{ newPackageLocation: manifest.repository
, newRef: Version.rawVersion manifest.version
, packageName: manifest.name
}
Expand Down
3 changes: 0 additions & 3 deletions ci/test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ decodeEventsToOps = do
operation = Update
{ packageName: unsafeFromRight $ PackageName.parse "something"
, updateRef: "v1.2.3"
, legacy: false
}

res <- API.readOperation "test/fixtures/issue_comment.json"
Expand All @@ -241,8 +240,6 @@ decodeEventsToOps = do
operation = Addition
{ packageName: unsafeFromRight $ PackageName.parse "prelude"
, newRef: "v5.0.0"
, legacy: true
, addToPackageSet: true
, newPackageLocation: GitHub { subdir: Nothing, owner: "purescript", repo: "purescript-prelude" }
}

Expand Down
2 changes: 1 addition & 1 deletion ci/test/fixtures/issue_comment.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"action": "created",
"comment": {
"author_association": "MEMBER",
"body": "{\"legacy\": false,\"packageName\":\"something\",\"updateRef\":\"v1.2.3\"}",
"body": "{\"packageName\":\"something\",\"updateRef\":\"v1.2.3\"}",
"created_at": "2021-03-09T02:03:56Z",
"html_url": "https://github.com/purescript/registry/issues/43#issuecomment-793265839",
"id": 793265839,
Expand Down
2 changes: 1 addition & 1 deletion ci/test/fixtures/issue_created.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"assignee": null,
"assignees": [],
"author_association": "CONTRIBUTOR",
"body": "{\"addToPackageSet\": true,\"legacy\": true,\"newPackageLocation\": {\"githubOwner\": \"purescript\",\"githubRepo\": \"purescript-prelude\"},\"newRef\": \"v5.0.0\",\"packageName\": \"prelude\"}",
"body": "{\"newPackageLocation\": {\"githubOwner\": \"purescript\",\"githubRepo\": \"purescript-prelude\"},\"newRef\": \"v5.0.0\",\"packageName\": \"prelude\"}",
"closed_at": null,
"comments": 0,
"comments_url": "https://api.github.com/repos/purescript/registry/issues/149/comments",
Expand Down
4 changes: 2 additions & 2 deletions v1/Operation.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A type describing all the possible operations for the Registry API.
let Repo = ./Repo.dhall

in
< Addition : { packageName : Text, newPackageLocation : Repo, newRef : Text, addToPackageSet: Bool, legacy : Bool }
| Update : { packageName : Text, updateRef : Text, legacy : Bool }
< Addition : { packageName : Text, newPackageLocation : Repo, newRef : Text, addToPackageSet: Bool }
| Update : { packageName : Text, updateRef : Text }
| Unpublish : { packageName : Text, unpublishVersion : Text, unpublishReason: Text }
>