chore: import upstream snapshot with attribution
This commit is contained in:
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
if [ -z "$1" ]; then
|
||||
echo "Error: integration name is not provided" >&2
|
||||
exit 1
|
||||
fi
|
||||
integration=$1
|
||||
|
||||
integration_path="integrations/$integration"
|
||||
if ! integration_def=$(pnpm bp read --work-dir "$integration_path" --json); then
|
||||
echo "Error: Failed to read integration definition for \"$integration\". Check the integration for TypeScript errors." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
name=$(echo "$integration_def" | jq -r ".name")
|
||||
version=$(echo "$integration_def" | jq -r ".version")
|
||||
|
||||
exists=$(pnpm bp integrations ls --name "$name" --version-number "$version" --json | jq '[ .[] | select(.public) ] | length') # 0 if not exists
|
||||
echo "$exists"
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
if [ -z "$1" ]; then
|
||||
echo "Error: integration name is not provided" >&2
|
||||
exit 1
|
||||
fi
|
||||
integration=$1
|
||||
|
||||
integration_path="integrations/$integration"
|
||||
if ! integration_def=$(pnpm bp read --work-dir "$integration_path" --json); then
|
||||
echo "Error: Failed to read integration definition for \"$integration\". Check the integration for TypeScript errors." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
category=$(echo "$integration_def" | jq -r '.attributes.category // empty')
|
||||
|
||||
valid_categories=(
|
||||
"AI Models"
|
||||
"Business Operations"
|
||||
"CRM & Sales"
|
||||
"Communication & Channels"
|
||||
"Customer Support"
|
||||
"Developer Tools"
|
||||
"E-commerce & Payments"
|
||||
"File Management"
|
||||
"Marketing & Email"
|
||||
"Other"
|
||||
"Project Management"
|
||||
)
|
||||
|
||||
if [ -z "$category" ]; then
|
||||
echo "Integration \"$integration\" is missing the \"category\" attribute in its definition file" >&2
|
||||
echo "Valid categories are: $(printf '"%s", ' "${valid_categories[@]}" | sed 's/, $//')" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for valid_category in "${valid_categories[@]}"; do
|
||||
if [ "$category" = "$valid_category" ]; then
|
||||
echo "Integration \"$integration\" has a valid category: \"$category\""
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Integration \"$integration\" has an invalid category: \"$category\"" >&2
|
||||
echo "Valid categories are: $(printf '"%s", ' "${valid_categories[@]}" | sed 's/, $//')" >&2
|
||||
exit 1
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
if [ -z "$1" ]; then
|
||||
echo "Error: integration name is not provided" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
integration=$1
|
||||
integration_path="integrations/$integration"
|
||||
|
||||
has_sandbox=false
|
||||
sandbox_script="$integration_path/sandboxIdentifierExtract.vrl"
|
||||
if [ -f "$sandbox_script" ]; then
|
||||
has_sandbox=true
|
||||
fi
|
||||
|
||||
echo "$has_sandbox"
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
if [ -z "$1" ]; then
|
||||
echo "Error: interface name is not provided" >&2
|
||||
exit 1
|
||||
fi
|
||||
interface=$1
|
||||
|
||||
interface_path="interfaces/$interface"
|
||||
interface_def=$(pnpm bp read --work-dir "$interface_path" --json)
|
||||
|
||||
name=$(echo "$interface_def" | jq -r ".name")
|
||||
version=$(echo "$interface_def" | jq -r ".version")
|
||||
|
||||
command="pnpm bp interfaces get \"$name@$version\" --json >/dev/null 2>&1"
|
||||
exists=$(eval "$command" && echo 1 || echo 0)
|
||||
echo "$exists"
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
if [ -z "$1" ]; then
|
||||
echo "Error: plugin name is not provided" >&2
|
||||
exit 1
|
||||
fi
|
||||
plugin=$1
|
||||
|
||||
plugin_path="plugins/$plugin"
|
||||
plugin_def=$(pnpm bp read --work-dir "$plugin_path" --json)
|
||||
|
||||
name=$(echo "$plugin_def" | jq -r ".name")
|
||||
version=$(echo "$plugin_def" | jq -r ".version")
|
||||
|
||||
command="pnpm bp plugins get \"$name@$version\" --json >/dev/null 2>&1"
|
||||
exists=$(eval "$command" && echo 1 || echo 0)
|
||||
echo "$exists"
|
||||
@@ -0,0 +1,93 @@
|
||||
import { LinearClient, Team, WorkflowState, IssueLabel } from '@linear/sdk'
|
||||
|
||||
const LINEAR_API_KEY = process.env.LINEAR_API_KEY
|
||||
const SOURCE_STATE_NAME = 'Staging'
|
||||
const TARGET_STATE_NAME = 'Production (Done)'
|
||||
const TEAM_NAME = process.env.TEAM_NAME
|
||||
const TARGET_LABEL = process.env.TARGET_LABEL
|
||||
|
||||
if (!LINEAR_API_KEY) {
|
||||
throw new Error('No LINEAR_API_KEY environment variable')
|
||||
}
|
||||
|
||||
if (!TEAM_NAME) {
|
||||
throw new Error('No TEAM_NAME environment variable')
|
||||
}
|
||||
|
||||
if (!TARGET_LABEL) {
|
||||
throw new Error('No TARGET_LABEL environment variable')
|
||||
}
|
||||
|
||||
void updateLinearIssues()
|
||||
|
||||
async function getTeam(): Promise<Team> {
|
||||
const client = new LinearClient({ apiKey: LINEAR_API_KEY })
|
||||
const teams = await client.teams()
|
||||
const targetTeam = teams.nodes.find((t) => t.name === TEAM_NAME)
|
||||
|
||||
if (!targetTeam) throw new Error(`Could not find team with name "${TEAM_NAME}"`)
|
||||
return targetTeam
|
||||
}
|
||||
|
||||
async function getStates(targetTeam: Team): Promise<{ sourceState: WorkflowState; targetState: WorkflowState }> {
|
||||
const states = await targetTeam.states()
|
||||
const sourceState = states.nodes.find((s) => s.name === SOURCE_STATE_NAME)
|
||||
const targetState = states.nodes.find((s) => s.name === TARGET_STATE_NAME)
|
||||
|
||||
if (!sourceState) throw new Error(`Could not find workflow state ${SOURCE_STATE_NAME}`)
|
||||
if (!targetState) throw new Error(`Could not find workflow state ${TARGET_STATE_NAME}`)
|
||||
|
||||
console.info(`Found source state: ${sourceState.name} (${sourceState.id})`)
|
||||
console.info(`Found target state: ${targetState.name} (${targetState.id})`)
|
||||
|
||||
return { sourceState, targetState }
|
||||
}
|
||||
|
||||
async function getTargetLabels(targetTeam: Team): Promise<IssueLabel[]> {
|
||||
let labels = await targetTeam.labels()
|
||||
const labelsArray = [...labels.nodes]
|
||||
|
||||
while (labels.pageInfo.hasNextPage) {
|
||||
labels = await labels.fetchNext()
|
||||
labelsArray.push(...labels.nodes)
|
||||
}
|
||||
|
||||
const targetLabels = labelsArray.filter(
|
||||
(label) => label.name === TARGET_LABEL || label.name.startsWith(TARGET_LABEL + '/')
|
||||
)
|
||||
|
||||
if (targetLabels.length === 0) {
|
||||
throw new Error(`Could not find any labels matching ${TARGET_LABEL}`)
|
||||
}
|
||||
|
||||
console.info(`Found ${targetLabels.length} matching label(s):`)
|
||||
targetLabels.forEach((label) => {
|
||||
console.info(` - ${label.name} (${label.id})`)
|
||||
})
|
||||
|
||||
return targetLabels
|
||||
}
|
||||
|
||||
async function updateLinearIssues() {
|
||||
const targetTeam = await getTeam()
|
||||
const { sourceState, targetState } = await getStates(targetTeam)
|
||||
const targetLabels = await getTargetLabels(targetTeam)
|
||||
|
||||
const targetLabelIds = targetLabels.map((label) => label.id)
|
||||
|
||||
const issues = await targetTeam.issues({
|
||||
filter: {
|
||||
labels: { some: { id: { in: targetLabelIds } } },
|
||||
state: { id: { eq: sourceState.id } },
|
||||
},
|
||||
})
|
||||
|
||||
console.info(`Found ${issues.nodes.length} issue(s) in state "${SOURCE_STATE_NAME}"`)
|
||||
|
||||
await Promise.all(
|
||||
issues.nodes.map(async (issue) => {
|
||||
console.info(`Updating issue ${issue.identifier} to ${TARGET_STATE_NAME}`)
|
||||
await issue.update({ stateId: targetState.id })
|
||||
})
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user