-
Notifications
You must be signed in to change notification settings - Fork 2
feat(maker): add package update policy check #258
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f8fc855
feat(maker): add package update policy check
529951164 03d05ec
fix(maker): harden package update checks
529951164 66e17db
fix(maker): validate manual publish tag versions
529951164 30b3386
fix(maker): clarify disabled update refresh status
529951164 a503a76
fix(maker): validate policy cache sources
529951164 878fafb
fix(maker): avoid stale policy details in status
529951164 23798c4
fix(maker): harden review edge cases
529951164 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -193,3 +193,4 @@ native/node_modules/ | |
| # TapTap Maker local runtime state | ||
| .maker/ | ||
| .npm-cache | ||
| docs/superpowers | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "schema_version": 1, | ||
| "latest": "0.0.20", | ||
| "latest_beta": "0.0.19-beta.1", | ||
| "minimum_supported": "0.0.1", | ||
| "blacklist": [], | ||
| "message": "TapTap Maker MCP package policy is current.", | ||
| "updated_at": "2026-06-23T00:00:00.000Z" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,169 @@ | ||
| #!/usr/bin/env node | ||
| 'use strict'; | ||
|
|
||
| const fs = require('node:fs'); | ||
| const path = require('node:path'); | ||
|
|
||
| const DEFAULT_POLICY_FILE = path.join(__dirname, '..', 'config', 'maker-version-policy.json'); | ||
| const VERSION_PATTERN = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/; | ||
|
|
||
| function parseArgs(argv) { | ||
| const parsed = { | ||
| file: DEFAULT_POLICY_FILE, | ||
| }; | ||
|
|
||
| for (let index = 0; index < argv.length; index += 1) { | ||
| const arg = argv[index]; | ||
| if (arg === '--tag' || arg === '--version' || arg === '--file' || arg === '--updated-at') { | ||
| const value = argv[index + 1]; | ||
| if (!value || value.startsWith('--')) { | ||
| throw new Error(`Missing value for ${arg}.`); | ||
| } | ||
| parsed[toCamelCase(arg.slice(2))] = value; | ||
| index += 1; | ||
| continue; | ||
| } | ||
| throw new Error(`Unknown argument: ${arg}`); | ||
| } | ||
|
|
||
| if (!parsed.tag) { | ||
| throw new Error('Missing required --tag.'); | ||
| } | ||
| if (!parsed.version) { | ||
| throw new Error('Missing required --version.'); | ||
| } | ||
|
|
||
| return parsed; | ||
| } | ||
|
|
||
| function updateMakerVersionPolicy(options) { | ||
| const tag = options.tag; | ||
| const version = options.version; | ||
| const file = path.resolve(options.file || DEFAULT_POLICY_FILE); | ||
| const field = tag === 'latest' ? 'latest' : tag === 'beta' ? 'latest_beta' : undefined; | ||
|
|
||
| assertValidVersion(version); | ||
| assertVersionMatchesTag(tag, version); | ||
|
529951164 marked this conversation as resolved.
|
||
|
|
||
| if (!field) { | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
| return { | ||
| changed: false, | ||
| field: undefined, | ||
| version, | ||
| }; | ||
| } | ||
|
|
||
| const policy = readPolicy(file); | ||
| assertPolicy(policy, file); | ||
|
|
||
| if (policy[field] === version) { | ||
| return { | ||
| changed: false, | ||
| field, | ||
| version, | ||
| }; | ||
| } | ||
|
|
||
| const nextPolicy = { | ||
| ...policy, | ||
| [field]: version, | ||
| updated_at: options.updatedAt || new Date().toISOString(), | ||
| }; | ||
| fs.writeFileSync(file, `${JSON.stringify(nextPolicy, null, 2)}\n`, 'utf8'); | ||
|
|
||
| return { | ||
| changed: true, | ||
| field, | ||
| version, | ||
| }; | ||
| } | ||
|
|
||
| function readPolicy(file) { | ||
| try { | ||
| return JSON.parse(fs.readFileSync(file, 'utf8')); | ||
| } catch (error) { | ||
| throw new Error( | ||
| `Failed to read Maker version policy ${file}: ${ | ||
| error instanceof Error ? error.message : String(error) | ||
| }` | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| function assertPolicy(policy, file) { | ||
| if (!policy || typeof policy !== 'object' || Array.isArray(policy)) { | ||
| throw new Error(`Invalid Maker version policy ${file}: expected JSON object.`); | ||
| } | ||
| if (policy.schema_version !== 1) { | ||
| throw new Error(`Invalid Maker version policy ${file}: schema_version must be 1.`); | ||
| } | ||
| for (const field of ['latest', 'latest_beta', 'minimum_supported']) { | ||
| assertValidVersion(policy[field], `policy.${field}`); | ||
| } | ||
| if ( | ||
| !Array.isArray(policy.blacklist) || | ||
| policy.blacklist.some((item) => typeof item !== 'string' || !VERSION_PATTERN.test(item)) | ||
| ) { | ||
| throw new Error(`Invalid Maker version policy ${file}: blacklist must be a semver string array.`); | ||
| } | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
| } | ||
|
|
||
| function assertValidVersion(version, label = 'version') { | ||
| if (typeof version !== 'string' || !VERSION_PATTERN.test(version)) { | ||
| throw new Error(`Invalid ${label}: ${version}. Expected semver like 0.0.1 or 0.0.1-beta.1.`); | ||
| } | ||
| } | ||
|
|
||
| function assertVersionMatchesTag(tag, version) { | ||
| const isPrerelease = version.includes('-'); | ||
| if (tag === 'latest' && isPrerelease) { | ||
| throw new Error(`Invalid latest version: ${version}. The latest tag must publish a stable version.`); | ||
| } | ||
| if (tag === 'beta' && !isPrerelease) { | ||
| throw new Error(`Invalid beta version: ${version}. The beta tag must publish a prerelease version.`); | ||
| } | ||
| } | ||
|
|
||
| function toCamelCase(value) { | ||
| return value.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase()); | ||
| } | ||
|
|
||
| function writeGithubOutput(result) { | ||
| const outputPath = process.env.GITHUB_OUTPUT; | ||
| if (!outputPath) { | ||
| return; | ||
| } | ||
| fs.appendFileSync(outputPath, `changed=${String(result.changed)}\n`, 'utf8'); | ||
| fs.appendFileSync(outputPath, `field=${result.field || ''}\n`, 'utf8'); | ||
| fs.appendFileSync(outputPath, `version=${result.version}\n`, 'utf8'); | ||
| } | ||
|
|
||
| function main() { | ||
| const parsed = parseArgs(process.argv.slice(2)); | ||
| const result = updateMakerVersionPolicy({ | ||
| file: parsed.file, | ||
| tag: parsed.tag, | ||
| version: parsed.version, | ||
| updatedAt: parsed.updatedAt, | ||
| }); | ||
| writeGithubOutput(result); | ||
|
|
||
| if (result.changed) { | ||
| console.log(`Updated Maker version policy ${result.field} to ${result.version}.`); | ||
| } else { | ||
| console.log(`Maker version policy unchanged for tag ${parsed.tag}.`); | ||
| } | ||
| } | ||
|
|
||
| if (require.main === module) { | ||
| try { | ||
| main(); | ||
| } catch (error) { | ||
| console.error(error instanceof Error ? error.message : String(error)); | ||
| process.exit(1); | ||
| } | ||
| } | ||
|
|
||
| module.exports = { | ||
| updateMakerVersionPolicy, | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.