const _ = require("lodash");
const PACKAGES = ["lodash", "@google-cloud/bigquery", "axios"];
const isPackageInstalled = (packageName) => {
try {
require.resolve(packageName);
return true;
} catch (e) {
return false;
}
};
const getPackageVersion = (packageName) => {
if (!isPackageInstalled(packageName)) return {
isInstalled: false,
version: null,
message: "Package is not installed",
package: packageName,
};
const version = require(`${packageName}/package.json`).version;
return {
isInstalled: true,
version,
message: `Package is installed with version ${version}`,
package: packageName,
};
};
const test = () => {
return _.map(PACKAGES, (pkg) => getPackageVersion(pkg));
};
async function main(inputText, maxLength = 100, options = {}) {
/**
* Main function that will be executed
*
* @param {string} inputText - The text to process
* @param {number} maxLength - Maximum length of output (default: 100)
* @param {object} options - Additional processing options (default: {})
*/
return { data: test() };
}
// The entry point function will be called with the arguments you define
module.exports = { main };