mirror of
https://github.com/github/awesome-copilot.git
synced 2026-02-21 10:55:13 +00:00
Convert build scripts from CommonJS to ES Modules (#416)
* Convert build scripts from CommonJS to ES Modules - Convert all eng/*.js files to ES Modules (.mjs) - Update package.json scripts to reference .mjs files - Fix ERR_REQUIRE_ESM error with vfile v6.0.3 - Add __dirname polyfills for ES Modules * completing the migration of all files to es modules --------- Co-authored-by: Lyubomir Filipov <lyubomir.filipov@jakala.com> Co-authored-by: Aaron Powell <me@aaron-powell.com>
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
10
eng/create-collection.js → eng/create-collection.mjs
Executable file → Normal file
10
eng/create-collection.js → eng/create-collection.mjs
Executable file → Normal file
@@ -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);
|
||||
18
eng/update-readme.js → eng/update-readme.mjs
Executable file → Normal file
18
eng/update-readme.js → eng/update-readme.mjs
Executable file → Normal file
@@ -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);
|
||||
}
|
||||
|
||||
11
eng/validate-collections.js → eng/validate-collections.mjs
Executable file → Normal file
11
eng/validate-collections.js → eng/validate-collections.mjs
Executable file → Normal file
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
Reference in New Issue
Block a user