diff --git a/.vscode/tasks.json b/.vscode/tasks.json index bd51afe..364442e 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -12,19 +12,19 @@ { "label": "generate-readme", "type": "shell", - "command": "node ${workspaceFolder}/eng/update-readme.js", + "command": "npm run build", "problemMatcher": [], "group": { "kind": "build", "isDefault": true }, - "detail": "Generates the README.md file using update-readme.js script.", + "detail": "Generates the README.md file using npm build run-script.", "dependsOn": "npm install" }, { "label": "validate-collections", "type": "shell", - "command": "node ${workspaceFolder}/eng/validate-collections.js", + "command": "npm run collection:validate", "problemMatcher": [], "group": "build", "detail": "Validates all collection manifest files.", @@ -33,9 +33,8 @@ { "label": "create-collection", "type": "shell", - "command": "node", + "command": "npm run collection:create", "args": [ - "${workspaceFolder}/eng/create-collection.js", "--id", "${input:collectionId}", "--tags", diff --git a/eng/constants.js b/eng/constants.mjs similarity index 96% rename from eng/constants.js rename to eng/constants.mjs index bb7c785..5626e97 100644 --- a/eng/constants.js +++ b/eng/constants.mjs @@ -1,4 +1,9 @@ -const path = require("path"); +import path from "path"; +import { fileURLToPath } from "url"; +import { dirname } from "path"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); // Template sections for the README const TEMPLATES = { @@ -115,7 +120,7 @@ const MAX_COLLECTION_ITEMS = 50; const DOCS_DIR = path.join(ROOT_FOLDER, "docs"); -module.exports = { +export { TEMPLATES, vscodeInstallImage, vscodeInsidersInstallImage, @@ -130,3 +135,4 @@ module.exports = { MAX_COLLECTION_ITEMS, DOCS_DIR, }; + diff --git a/eng/create-collection.js b/eng/create-collection.mjs old mode 100755 new mode 100644 similarity index 95% rename from eng/create-collection.js rename to eng/create-collection.mjs index 28099be..0a67469 --- a/eng/create-collection.js +++ b/eng/create-collection.mjs @@ -1,9 +1,9 @@ #!/usr/bin/env node -const fs = require("fs"); -const path = require("path"); -const readline = require("readline"); -const { COLLECTIONS_DIR } = require("./constants"); +import fs from "fs"; +import path from "path"; +import readline from "readline"; +import { COLLECTIONS_DIR } from "./constants.mjs"; const rl = readline.createInterface({ input: process.stdin, @@ -166,7 +166,7 @@ display: console.log("\nšŸ“ Next steps:"); console.log("1. Edit the collection manifest to add your items"); console.log("2. Update the name, description, and tags as needed"); - console.log("3. Run 'npm run validate:collections' to validate"); + console.log("3. Run 'npm run collection:validate' to validate"); console.log("4. Run 'npm start' to generate documentation"); console.log("\nšŸ“„ Collection template contents:"); console.log(template); diff --git a/eng/update-readme.js b/eng/update-readme.mjs old mode 100755 new mode 100644 similarity index 99% rename from eng/update-readme.js rename to eng/update-readme.mjs index 7c7e993..997ec0c --- a/eng/update-readme.js +++ b/eng/update-readme.mjs @@ -1,14 +1,16 @@ #!/usr/bin/env node -const fs = require("fs"); -const path = require("path"); -const { +import fs from "fs"; +import path from "path"; +import { fileURLToPath } from "url"; +import { dirname } from "path"; +import { parseCollectionYaml, extractMcpServers, extractMcpServerConfigs, parseFrontmatter, -} = require("./yaml-parser"); -const { +} from "./yaml-parser.mjs"; +import { TEMPLATES, AKA_INSTALL_URLS, repoBaseUrl, @@ -21,7 +23,10 @@ const { COLLECTIONS_DIR, INSTRUCTIONS_DIR, DOCS_DIR, -} = require("./constants"); +} from "./constants.mjs"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); // Cache of MCP registry server names (lower-cased) loaded from github-mcp-registry.json let MCP_REGISTRY_SET = null; @@ -968,3 +973,4 @@ try { console.error(`Error generating category README files: ${error.message}`); process.exit(1); } + diff --git a/eng/validate-collections.js b/eng/validate-collections.mjs old mode 100755 new mode 100644 similarity index 98% rename from eng/validate-collections.js rename to eng/validate-collections.mjs index 23ba552..8650797 --- a/eng/validate-collections.js +++ b/eng/validate-collections.mjs @@ -1,13 +1,13 @@ #!/usr/bin/env node -const fs = require("fs"); -const path = require("path"); -const { parseCollectionYaml, parseFrontmatter } = require("./yaml-parser"); -const { +import fs from "fs"; +import path from "path"; +import { parseCollectionYaml, parseFrontmatter } from "./yaml-parser.mjs"; +import { ROOT_FOLDER, COLLECTIONS_DIR, MAX_COLLECTION_ITEMS, -} = require("./constants"); +} from "./constants.mjs"; // Validation functions function validateCollectionId(id) { @@ -370,3 +370,4 @@ try { console.error(`Error during validation: ${error.message}`); process.exit(1); } + diff --git a/eng/yaml-parser.js b/eng/yaml-parser.mjs similarity index 96% rename from eng/yaml-parser.js rename to eng/yaml-parser.mjs index 76e56ab..79d4dfc 100644 --- a/eng/yaml-parser.js +++ b/eng/yaml-parser.mjs @@ -1,8 +1,8 @@ // YAML parser for collection files and frontmatter parsing using vfile-matter -const fs = require("fs"); -const yaml = require("js-yaml"); -const { VFile } = require("vfile"); -const { matter } = require("vfile-matter"); +import fs from "fs"; +import yaml from "js-yaml"; +import { VFile } from "vfile"; +import { matter } from "vfile-matter"; function safeFileOperation(operation, filePath, defaultValue = null) { try { @@ -137,7 +137,7 @@ function extractMcpServerConfigs(filePath) { }); } -module.exports = { +export { parseCollectionYaml, parseFrontmatter, extractAgentMetadata, diff --git a/package.json b/package.json index 3b72f2b..4fc8d12 100644 --- a/package.json +++ b/package.json @@ -6,11 +6,12 @@ "private": true, "scripts": { "start": "npm run build", - "build": "node ./eng/update-readme.js", + "build": "node ./eng/update-readme.mjs", "contributors:add": "all-contributors add", "contributors:generate": "all-contributors generate", "contributors:check": "all-contributors check", - "validate:collections": "node ./eng/validate-collections.js" + "collection:validate": "node ./eng/validate-collections.mjs", + "collection:create": "node ./eng/create-collection.mjs" }, "repository": { "type": "git",