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

Have common issues make a copy of itself #106

Merged
merged 3 commits into from
Apr 4, 2023
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
59 changes: 43 additions & 16 deletions src/handlers/work/_lib/common-assign-parameters.mjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,47 @@
// import * as fsPath from 'node:path'

// import { CredentialsDB, purposes } from '@liquid-labs/liq-credentials-db'
// import { Octocache } from '@liquid-labs/octocache'

import { commonIssuesParameters } from './common-issues-parameters'

const commonAssignParameters = () => [
{
name : 'assignee',
description : 'The assignee (github login ID) to add to the issues. See `noAutoAssign`.'
},
{
name : 'comment',
description : "The comment to use when claiming an issue. Defaults to: 'Work for this issue has begun on branch <work branch name>.'"
},
{
name : 'noAutoAssign',
isBoolean : true,
description : "Suppresses the default behavior of assigning the issue based on the current user's GitHub authentication."
},
...commonIssuesParameters
]
const commonAssignParameters = () => {
const parameters = [
{
name : 'assignee',
description : 'The assignee (github login ID) to add to the issues. See `noAutoAssign`.'
},
{
name : 'comment',
description : "The comment to use when claiming an issue. Defaults to: 'Work for this issue has begun on branch <work branch name>.'"
},
{
name : 'noAutoAssign',
isBoolean : true,
description : "Suppresses the default behavior of assigning the issue based on the current user's GitHub authentication."
},
...commonIssuesParameters()
]
/*
const issuesParam = commonIssuesParameters.find((p) => p.name === 'issues')

issuesParam.optionsFunc = async ({ localProjectName, model, orgKey, req }) => {
if (orgKey === undefined) {
const cwd = req.get('X-CWD')
const pkgPath = fsPath.join(cwd, 'package.json')

}

const credDB = new CredentialsDB({ app, cache })
const authToken = credDB.getToken(purposes.GITHUB_API)

// TODO: I think it makes sense to create a octocache instance on app so we share and it can cache
const octocache = new Octocache({ authToken })

octocache.paginate()
} */

return parameters
}

export { commonAssignParameters }
2 changes: 1 addition & 1 deletion src/handlers/work/_lib/common-issues-parameters.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const commonIssuesParameters = [
const commonIssuesParameters = () => [
{
name : 'issues',
required : true,
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/work/issues/_lib/remove-lib.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const getIssuesRemoveEndpointParameters = ({ workDesc }) => {
isBoolean : true,
description : "Setting `noUnlabel` to true keeps the 'claim label' on the issue rather than the default behavior of removing it."
},
...commonIssuesParameters
...commonIssuesParameters()
]
parameters.find((p) => p.name === 'issues').optionsFunc = issueOptionsFunc
Object.freeze(parameters)
Expand Down