Files
b353dfa42f chore: add initial ecosystem plugin tests workflow (#19643)
* chore: add initial ecosystem plugin tests workflow

* Apply suggestions from code review

Co-authored-by: Nicholas C. Zakas <[email protected]>

* Comments and structure

* Switch to nano-spawn, with plugins.json

* Revert unintentional docs/src/_data/further_reading_links.json changes

* Tweaked docs text for runCommand

* Added a script to update data

* Fix: errororing on error for unknown plugin

* Add weekly cron to update data

* Add comments to match index.mjs

* fix: .json files are formatted with two spaces

* Apply suggestions from code review

Co-authored-by: fisker Cheung <[email protected]>

* Added the once-a-week comment

* Default to all

* Mention the default of all

* npm run test:ecosystem:update

* rm duplicate .json

* DISCORD_CONTRIBUTORS_WEBHOOK

* Correct error message for all plugins

* Apply suggestions from code review

Co-authored-by: Percy Ma <[email protected]>

* Apply suggestions from code review

Co-authored-by: 루밀LuMir <[email protected]>
Co-authored-by: Percy Ma <[email protected]>

* Apply suggestions from code review

Co-authored-by: 루밀LuMir <[email protected]>

* Continue bumping to latest

* chore: formatting

* Finish migration off of chalk

* Remove nano-spawn

* Added typescript-eslint and docs

* Apply suggestions from code review

Co-authored-by: 루밀LuMir <[email protected]>

* More docs, and use prettier

* JSDoc correction

* Import sorting, while I'm in the area

* fix: proper cross-OS file path/URLs to package.json

* nit: proper comment placement

* 'local' ESLint, not 'built'

* further 'local'

* Add debug()

* NI_AUTO_INSTALL

* Update package.json

Co-authored-by: 唯然 <[email protected]>

* NI_DEFAULT_AGENT

* { NI_DEFAULT_AGENT: "npm" }

* Switch to hardcoded commands

* feat: granular failing

* fix: remove erroneous build scripts

* Bump to latest commits, and add quick summaries

* remove antfu/ni now

* remove markdown, typescript-eslint

* Apply suggestions from code review

Co-authored-by: Francesco Trotta <[email protected]>
Co-authored-by: 루밀LuMir <[email protected]>

* recursive

* correction: result(s); add to ignores

---------

Co-authored-by: Nicholas C. Zakas <[email protected]>
Co-authored-by: fisker Cheung <[email protected]>
Co-authored-by: Percy Ma <[email protected]>
Co-authored-by: 루밀LuMir <[email protected]>
Co-authored-by: 唯然 <[email protected]>
Co-authored-by: Francesco Trotta <[email protected]>
2026-04-27 20:14:39 +09:00

85 lines
2.5 KiB
JavaScript

/**
* @fileoverview Data utilities for ecosystem tests and updates to data.
* @author Josh Goldberg
*/
//-----------------------------------------------------------------------------
// Requirements
//-----------------------------------------------------------------------------
import util, { styleText } from "node:util";
//-----------------------------------------------------------------------------
// Types
//-----------------------------------------------------------------------------
/**
* Command-line scripts to run on a plugin.
* @typedef {Object} PluginData
* @property {string?} build Command to build files before tests, if defined.
* @property {string} install Command to install dependencies.
* @property {string} test Command to run tests.
*/
/**
* Settings for how to clone, set up, and test an ecosystem plugin.
* @typedef {Object} PluginData
* @property {PluginCommands} commands Command-line scripts to run on the plugin.
* @property {string} commit Hash to check out after cloning the plugin.
* @property {string} repository Repository URL to clone the plugin from.
*/
//-----------------------------------------------------------------------------
// Constants
//-----------------------------------------------------------------------------
export const pluginDataFilePath = new URL("plugins-data.json", import.meta.url);
//-----------------------------------------------------------------------------
// Functions
//-----------------------------------------------------------------------------
/**
* @param {"test" | "update"} action
* @returns {[string, PluginData][]}
*/
export async function getPlugins(action) {
const { values } = util.parseArgs({
options: {
plugin: {
type: "string",
},
},
});
const { plugin: pluginRequested = "all" } = values;
const { default: pluginsData } = await import(pluginDataFilePath, {
with: { type: "json" },
});
if (pluginRequested !== "all" && !(pluginRequested in pluginsData)) {
console.error(`The plugin "${values.plugin}" is not supported.`);
console.error(
`Supported plugins are: ${["", ...Object.keys(pluginsData)].join(
"\n ",
)}`,
);
console.error(
`Alternately, run without --plugin to ${action} all plugins.`,
);
process.exit(1);
}
const pluginsSelected =
pluginRequested === "all"
? Object.entries(pluginsData)
: [[pluginRequested, pluginsData[pluginRequested]]];
console.log(
`Plugins to ${action}:`,
styleText("bold", pluginsSelected.map(([key]) => key).join(", ")),
);
return { pluginsData, pluginsSelected };
}