feat(cli): Ohif cli for modes and extensions modification (#2696)

* feat: Add initial cli tool structure

* feat: add copying template files

* feat: Add mode template and command

* feat: Add readme template generation

* feat: Add documentation to extension template

* feat: Enhance documentation of the template mode

* fix: cli module type

* feat: Add config-based mode and extension registration (#2660)

* feat: Add ohif cli add/remove extension/mode (#2661)

* Basic working CLI for add-extension and remove-extension

* Basic cli for add/remove extension/mode, lots more to do.

* Cleanup and harden]

* feat: Add list of tasks to add-mode

Co-authored-by: Alireza <ar.sedghi@gmail.com>

* feat: Add git initialization for the mode or extension template (#2662)

* fix: package json file to include templates

* feat: Add git initialization for the mode or extension template

* feat: Add more checks of git and target dir

* feat: refactore library utilities

* feat: Add the list command to print extensions and modes (#2664)

* feat: Add the list command to print extensions and modes

* Add todo

* Feat/ohif cli validation + auto install (#2671)

* WIP

* Working mode keyword verification

* Validation

* auto install extensions based on modes

* WIP remove unused extensions on removeMove

* Working add-mode, remove-mode automatic extension management.

* If extension is in used by a mode, don't allow the CLI to uninstall it

* Cleanup addExtension

* cleanup removeExtension and addMode

* Cleanup removeMode

* Update existing extensions with the needed keywords/peer deps

* Fix broken config

* Feat/cli search (#2677)

* feat: refactor pretty print for console

* feat: add search for modes and extensions

* fix: ugly colors

* Feat/ohif cli error handling publishing (#2679)

* WIP

* fix: webpack imports

* wip

* fix: react router dom private routes

* from last commit

* wip

* fix: webpack prod builds

* WIP

* Working regsitration with new IDs

* Stable

Co-authored-by: Alireza <ar.sedghi@gmail.com>

* verify extensions when constructing modes. (#2681)

* verify extensions when constructing modes.

* Add version to unit tests so it conforms to schema

* Update ohif utils exposed via @ohif/core

* Fix import

* fix tests

* feat: ohif-cli link local modes/extensions for development (#2682)

* feat: enable cli to work with project root

* feat: add initial link package

* feat: add link and unlink extension

* feat: add link and unlink mode

* erro handling for link-package

* feat: add comment on ohif-cli linking for development (#2686)

* Docs/ohif cli (#2687)

* feat: Add documentation for templates

* feat: Add more documentation

* Fix/core publish (#2685)

* versions

* wip

* remove webpack clean output

* fix publish

* use next as dist tag for v3 for now

* fix webpack pro recipe for output

* fix: lerna publish next

* fix(cli): fix issues when trying to link an extension or a mode (#2725)

The generated package.json doesn't contain keywords property which is
required by the linkPackage function. The module apth wasn't correclty
handled too, and when there is no pluginOptions, it fails while reading
the file or while generating a default configuration.

* make dicom pdf and video work after cli merge

* add axios dependency

* comment out the chdir for now

* create id and version based on user inputs

* customizable path for extension and modes

* fix template to make the template mode load

* fix the questions to loop if path is not desirable

* fix templates

* correct package json order

* unify the package creation for extension and mode

* bump versions for each package

* bump extension versions to 3.0

* add gitignore to templates

* fix version requirements when ^

* update docs

* update docs and fix tests

* try to fix the tests

* bump node version

* remove the version from extensions

* remove the version from modes

* remove version from extensionManager

* fix eslint

* revert husky version

* fix eslint

* fix node version for new eslint

* fix documentatoin removing version

* fix cicle ci image version

* fix circle ci node image

* fix circle ci node image

* add back the video and pdf

Co-authored-by: Matthis Duclos <matthis.duclos@gmail.com>
Co-authored-by: James A. Petts <jamesapetts@gmail.com>
This commit is contained in:
authored and GitHub committed 2022-04-06 13:28:42 -04:00
1 parent 82df3eac03
commit 7f0ad6f84d
181 files changed
+5985 -3689

No files matched your search

@@ -0,0 +1,34 @@
import {
addExtensionToConfigJson,
addModeToConfigJson,
readPluginConfigFile,
writePluginConfigFile,
} from './private/index.js';
function addToAndOverwriteConfig(packageName, options, augmentConfigFunction) {
const installedVersion = options.version;
let pluginConfig = readPluginConfigFile();
if (!pluginConfig) {
pluginConfig = {
extensions: [],
modes: [],
};
}
augmentConfigFunction(pluginConfig, {
packageName,
version: installedVersion,
});
writePluginConfigFile(pluginConfig);
}
function addExtensionToConfig(packageName, options) {
addToAndOverwriteConfig(packageName, options, addExtensionToConfigJson);
}
function addModeToConfig(packageName, options) {
addToAndOverwriteConfig(packageName, options, addModeToConfigJson);
}
export { addExtensionToConfig, addModeToConfig };
@@ -0,0 +1,42 @@
import fs from 'fs';
// https://github.dev/leoroese/template-cli/blob/628dd24db7df399ebb520edd0bc301bc7b5e8b66/index.js#L19
const createDirectoryContents = (
templatePath,
targetDirPath,
copyPrettierRules
) => {
const filesToCreate = fs.readdirSync(templatePath);
filesToCreate.forEach(file => {
if (!copyPrettierRules && file === '.prettierrc') {
return;
}
const origFilePath = `${templatePath}/${file}`;
// get stats about the current file
const stats = fs.statSync(origFilePath);
if (stats.isFile()) {
const contents = fs.readFileSync(origFilePath, 'utf8');
// Rename
if (file === '.npmignore') file = '.gitignore';
const writePath = `${targetDirPath}/${file}`;
fs.writeFileSync(writePath, contents, 'utf8');
} else if (stats.isDirectory()) {
fs.mkdirSync(`${targetDirPath}/${file}`);
// recursive call
createDirectoryContents(
`${templatePath}/${file}`,
`${targetDirPath}/${file}`,
copyPrettierRules
);
}
});
};
export default createDirectoryContents;
@@ -0,0 +1,31 @@
import chalk from 'chalk';
import fs from 'fs';
import path from 'path';
import { promisify } from 'util';
import spdxLicenseList from 'spdx-license-list/full.js';
const writeFile = promisify(fs.writeFile);
async function createLicense(options) {
const { targetDir, name, email } = options;
const targetPath = path.join(targetDir, 'LICENSE');
let license;
try {
license = spdxLicenseList[options.license];
} catch (err) {
console.error(
'%s License %s not found in the list of licenses',
chalk.red.bold('ERROR'),
options.license
);
process.exit(1);
}
const licenseContent = license.licenseText
.replace('<year>', new Date().getFullYear())
.replace('<copyright holders>', `${name} (${email})`);
return writeFile(targetPath, licenseContent, 'utf8');
}
export default createLicense;
@@ -0,0 +1,23 @@
import fs from 'fs';
import path from 'path';
import { promisify } from 'util';
import mustache from 'mustache';
const writeFile = promisify(fs.writeFile);
async function createReadme(options) {
let template = `# {{name}} \n## Description \n{{description}} \n## Author \n{{author}} \n## License \n{{license}}`;
const { name, description, author, license, targetDir } = options;
const targetPath = path.join(targetDir, 'README.md');
const readmeContent = mustache.render(template, {
name,
description,
author,
license,
});
return writeFile(targetPath, readmeContent, 'utf8');
}
export default createReadme;
@@ -0,0 +1,33 @@
import fs from 'fs';
import path from 'path';
async function editPackageJson(options) {
const { name, version, description, author, license, targetDir } = options;
// read package.json from targetDir
const dependenciesPath = path.join(targetDir, 'dependencies.json');
const rawData = fs.readFileSync(dependenciesPath, 'utf8');
const packageJson = JSON.parse(rawData);
// edit package.json
const mergedObj = Object.assign(
{
name,
version,
description,
author,
license,
files: ['dist', 'README.md'],
},
packageJson
);
// write package.json back to targetDir
const writePath = path.join(targetDir, 'package.json');
fs.writeFileSync(writePath, JSON.stringify(mergedObj, null, 2));
// remove the dependencies.json file
fs.unlinkSync(dependenciesPath);
}
export default editPackageJson;
@@ -0,0 +1,67 @@
import { readPluginConfigFile } from './private/index.js';
import getYarnInfo from './getYarnInfo.js';
export default async function findOhifExtensionsToRemoveAfterRemovingMode(
removedModeYarnInfo
) {
const pluginConfig = readPluginConfigFile();
if (!pluginConfig) {
// No other modes or extensions, no action item.
return [];
}
const { modes, extensions } = pluginConfig;
const registeredExtensions = extensions.map(
extension => extension.packageName
);
// TODO this is not a function
const ohifExtensionsOfMode = Object.keys(
removedModeYarnInfo.peerDependencies
).filter(peerDependency => registeredExtensions.includes(peerDependency));
const ohifExtensionsUsedInOtherModes = ohifExtensionsOfMode.map(
packageName => {
return {
packageName,
used: false,
};
}
);
// Check if other modes use each extension used by this mode
const otherModes = modes.filter(
mode => mode.packageName !== removedModeYarnInfo.name
);
for (let i = 0; i < otherModes.length; i++) {
const mode = otherModes[i];
const yarnInfo = await getYarnInfo(mode.packageName);
const peerDependencies = yarnInfo.peerDependencies;
if (!peerDependencies) {
continue;
}
for (let j = 0; j < ohifExtensionsUsedInOtherModes.length; j++) {
const ohifExtension = ohifExtensionsUsedInOtherModes[j];
if (ohifExtension.used) {
// Already accounted that we can't delete this, so don't waste effort
return;
}
if (Object.keys(peerDependencies).includes(ohifExtension.packageName)) {
ohifExtension.used = true;
}
}
}
// Return list of now unused extensions
const ohifExtensionsToRemove = ohifExtensionsUsedInOtherModes
.filter(ohifExtension => !ohifExtension.used)
.map(ohifExtension => ohifExtension.packageName);
return ohifExtensionsToRemove;
}
@@ -0,0 +1,41 @@
import { validateExtension } from './validate.js';
export default async function findRequiredOhifExtensionsForMode(yarnInfo) {
// Get yarn info file and get peer dependencies
if (!yarnInfo.peerDependencies) {
// No ohif-extension dependencies
return;
}
const peerDependencies = yarnInfo.peerDependencies;
const dependencies = [];
const ohifExtensions = [];
Object.keys(peerDependencies).forEach((packageName) => {
dependencies.push({
packageName,
version: peerDependencies[packageName],
});
});
const promises = [];
// Fetch each npm json and check which are ohif extensions
for (let i = 0; i < dependencies.length; i++) {
const dependency = dependencies[i];
const { packageName, version } = dependency;
const promise = validateExtension(packageName, version)
.then(() => {
ohifExtensions.push({ packageName, version });
})
.catch(() => {});
promises.push(promise);
}
// Await all the extensions // TODO -> Improve so we async install each
// extension and await all of those promises instead.
await Promise.all(promises);
return ohifExtensions;
}
@@ -0,0 +1,3 @@
export default function getVersionedPackageName(packageName, version) {
return version === undefined ? packageName : `${packageName}@${version}`;
}
@@ -0,0 +1,5 @@
import { info } from 'yarn-programmatic';
export default async function getYarnInfo(packageName) {
return await info(packageName);
}
+50
View File
@@ -0,0 +1,50 @@
import getVersionedPackageName from './getVersionedPackageName.js';
import installNPMPackage from './installNPMPackage.js';
import uninstallNPMPackage from './uninstallNPMPackage.js';
import {
validateMode,
validateExtension,
validateModeYarnInfo,
validateExtensionYarnInfo,
} from './validate.js';
import getYarnInfo from './getYarnInfo.js';
import { addExtensionToConfig, addModeToConfig } from './addToConfig.js';
import findRequiredOhifExtensionsForMode from './findRequiredOhifExtensionsForMode.js';
import {
removeExtensionFromConfig,
removeModeFromConfig,
} from './removeFromConfig.js';
import throwIfExtensionUsedByInstalledMode from './throwIfExtensionUsedByInstalledMode.js';
import findOhifExtensionsToRemoveAfterRemovingMode from './findOhifExtensionsToRemoveAfterRemovingMode.js';
import initGit from './initGit.js';
import createDirectoryContents from './createDirectoryContents.js';
import editPackageJson from './editPackageJson.js';
import createLicense from './createLicense.js';
import createReadme from './createReadme.js';
import prettyPrint from './prettyPrint.js';
import validateYarn from './validateYarn.js';
export {
getYarnInfo,
getVersionedPackageName,
installNPMPackage,
uninstallNPMPackage,
validateMode,
validateExtension,
validateModeYarnInfo,
validateExtensionYarnInfo,
addExtensionToConfig,
addModeToConfig,
findRequiredOhifExtensionsForMode,
removeExtensionFromConfig,
throwIfExtensionUsedByInstalledMode,
removeModeFromConfig,
findOhifExtensionsToRemoveAfterRemovingMode,
initGit,
createDirectoryContents,
editPackageJson,
createLicense,
createReadme,
prettyPrint,
validateYarn,
};
@@ -0,0 +1,35 @@
import chalk from 'chalk';
import fs from 'fs';
import path from 'path';
import { promisify } from 'util';
import { execa } from 'execa';
const exists = promisify(fs.exists);
async function initGit(options) {
const { targetDir } = options;
const targetPath = path.join(targetDir, '.git');
// Check if git is installed
try {
await execa('git', ['--version']);
} catch (err) {
console.error(
'%s Git is not installed. Please install git and try again.',
chalk.red.bold('ERROR')
);
process.exit(1);
}
if (!(await exists(targetPath))) {
try {
await execa('git', ['init'], { cwd: targetDir });
} catch (err) {
console.error('%s Failed to initialize git', chalk.red.bold('ERROR'));
console.error(err);
process.exit(1);
}
}
}
export default initGit;
@@ -0,0 +1,14 @@
import { install } from 'pkg-install';
const installNPMPackage = async (packageName, version) => {
let installObject = {};
installObject[packageName] = version;
await install(installObject, {
prefer: 'yarn',
cwd: process.cwd(),
});
};
export default installNPMPackage;
@@ -0,0 +1,79 @@
import chalk from 'chalk';
import { colors } from '../enums/index.js';
function getStyle({ color, bold }) {
return bold ? chalk.hex(color).bold : chalk.hex(color);
}
function levelOnePrint(items) {
let output = '';
if (Array.isArray(items)) {
items.forEach(item => {
output += ` |- ${item}\n`;
});
return output;
}
return ` |- ${items}\n`;
}
function levelTwoPrint(items) {
let output = '';
items.forEach(item => {
output += ` | |- ${item}\n`;
});
return output;
}
/**
*
* @param {string} title Title of the section
* @param {object} titleOptions Options for the title includes color and bold
* @param { [] | [][] } items Array of items to display, OR a list of lists
* @param {object} itemOptions Options for the items includes color and bold
*
*
* items= ['Mode-A', 'Mode-B', 'Mode-C']
*
* |- Mode-A
* |- Mode-B
* |- Mode-C
*
* items = [['Mode-A', ['Description-A', 'Authors-A', 'Repository-A]], ['Mode-B', ['Description-B', 'Authors-B', 'Repository-B]], ['Mode-C', ['Description-C', 'Authors-C', 'Repository-C]]]
*
* |- Mode-A
* | |- Description-A
* | |- Authors-A
* | |- Repository-A
* |
* |- Mode-B
* | |- Description-B
* | |- Authors-B
* | |- Repository-B
*
*
*/
function prettyPrint(
title,
titleOptions = { color: colors.MAIN, bold: true },
itemsArray = [[]],
itemOptions = {}
) {
console.log('');
console.log(getStyle(titleOptions)(title));
let output = '';
itemsArray.forEach(items => {
if (!Array.isArray(items)) {
output += levelOnePrint(items);
} else {
output += levelOnePrint(items[0]);
output += levelTwoPrint(items[1]);
}
});
const itmeStyle = itemOptions.color ? getStyle(itemOptions)(output) : output;
console.log(itmeStyle);
}
export default prettyPrint;
@@ -0,0 +1,15 @@
export default function getPackageNameAndScope(packageName) {
let scope;
let packageNameLessScope;
if (packageName.includes('@')) {
[scope, packageNameLessScope] = packageName.split('/');
} else {
packageNameLessScope = packageName;
}
return {
scope,
packageNameLessScope,
};
}
@@ -0,0 +1,19 @@
import getPackageNameAndScope from './getPackageNameAndScope.js';
import {
addExtensionToConfigJson,
removeExtensionFromConfigJson,
addModeToConfigJson,
removeModeFromConfigJson,
} from './manipulatePluginConfigFile.js';
import writePluginConfigFile from './writePluginConfigFile.js';
import readPluginConfigFile from './readPluginConfigFile.js';
export {
getPackageNameAndScope,
addExtensionToConfigJson,
removeExtensionFromConfigJson,
addModeToConfigJson,
removeModeFromConfigJson,
readPluginConfigFile,
writePluginConfigFile,
};
@@ -0,0 +1,40 @@
function addExtensionToConfigJson(pluginConfig, { packageName, version }) {
addToList('extensions', pluginConfig, { packageName, version });
}
function addModeToConfigJson(pluginConfig, { packageName, version }) {
addToList('modes', pluginConfig, { packageName, version });
}
function removeExtensionFromConfigJson(pluginConfig, { packageName }) {
removeFromList('extensions', pluginConfig, { packageName });
}
function removeModeFromConfigJson(pluginConfig, { packageName }) {
removeFromList('modes', pluginConfig, { packageName });
}
function removeFromList(listName, pluginConfig, { packageName }) {
const list = pluginConfig[listName];
const indexOfExistingEntry = list.findIndex(
entry => entry.packageName === packageName
);
if (indexOfExistingEntry !== -1) {
pluginConfig[listName].splice(indexOfExistingEntry, 1);
}
}
function addToList(listName, pluginConfig, { packageName, version }) {
removeFromList(listName, pluginConfig, { packageName });
pluginConfig[listName].push({ packageName, version });
}
export {
addExtensionToConfigJson,
addModeToConfigJson,
removeExtensionFromConfigJson,
removeModeFromConfigJson,
};
@@ -0,0 +1,17 @@
import fs from 'fs';
export default function readPluginConfigFile() {
let fileContents;
try {
fileContents = fs.readFileSync('./pluginConfig.json', { flag: 'r' });
} catch (err) {
return; // File doesn't exist yet.
}
if (fileContents) {
fileContents = JSON.parse(fileContents);
}
return fileContents;
}
@@ -0,0 +1,18 @@
import fs from 'fs';
export default function writePluginConfigFile(pluginConfig) {
// Note: Second 2 arguments are to pretty print the JSON so its human readable.
const jsonStringOfFileContents = JSON.stringify(pluginConfig, null, 2);
fs.writeFileSync(
`./pluginConfig.json`,
jsonStringOfFileContents,
{ flag: 'w+' },
(err) => {
if (err) {
console.error(err);
return;
}
}
);
}
@@ -0,0 +1,26 @@
import {
removeExtensionFromConfigJson,
removeModeFromConfigJson,
writePluginConfigFile,
readPluginConfigFile,
} from './private/index.js';
function removeFromAndOverwriteConfig(packageName, augmentConfigFunction) {
const pluginConfig = readPluginConfigFile();
// Note: if file is not found, nothing to remove.
if (pluginConfig) {
augmentConfigFunction(pluginConfig, { packageName });
writePluginConfigFile(pluginConfig);
}
}
function removeExtensionFromConfig(packageName) {
removeFromAndOverwriteConfig(packageName, removeExtensionFromConfigJson);
}
function removeModeFromConfig(packageName) {
removeFromAndOverwriteConfig(packageName, removeModeFromConfigJson);
}
export { removeExtensionFromConfig, removeModeFromConfig };
@@ -0,0 +1,48 @@
import { readPluginConfigFile } from './private/index.js';
import getYarnInfo from './getYarnInfo.js';
import chalk from 'chalk';
export default async function throwIfExtensionUsedByInstalledMode(packageName) {
const pluginConfig = readPluginConfigFile();
if (!pluginConfig) {
// No other modes, not in use
return false;
}
const { modes } = pluginConfig;
const modesUsingExtension = [];
for (let i = 0; i < modes.length; i++) {
const mode = modes[i];
const modePackageName = mode.packageName;
const yarnInfo = await getYarnInfo(modePackageName);
const peerDependencies = yarnInfo.peerDependencies;
if (!peerDependencies) {
continue;
}
if (Object.keys(peerDependencies).includes(packageName)) {
modesUsingExtension.push(modePackageName);
}
}
if (modesUsingExtension.length > 0) {
let modesString = '';
modesUsingExtension.forEach(packageName => {
modesString += ` ${packageName}`;
});
const error = new Error(
`${chalk.yellow.red(
'Error'
)} ohif-extension ${packageName} used by installed modes:${modesString}`
);
throw error;
}
}
@@ -0,0 +1,12 @@
import { remove } from 'yarn-programmatic';
const uninstallNPMPackage = async packageName => {
// TODO - Anoyingly pkg-install doesn't seem to have uninstall.
// So since we are using yarn we will just use yarn here, but the tool
// is certainly less generic. But its a super minor issue.
await remove(packageName).catch(err => {
console.log(err);
});
};
export default uninstallNPMPackage;
+160
View File
@@ -0,0 +1,160 @@
import registryUrl from 'registry-url';
import keywords from '../enums/keywords.js';
import { getPackageNameAndScope } from './private/index.js';
import chalk from 'chalk';
import fetch from 'node-fetch';
import getYarnInfo from './getYarnInfo.js';
import NOT_FOUND from '../constants/notFound.js';
async function validateMode(packageName, version) {
return validate(packageName, version, keywords.MODE);
}
async function validateExtension(packageName, version) {
return validate(packageName, version, keywords.EXTENSION);
}
async function validateModeYarnInfo(packageName) {
return validateYarnInfo(packageName, keywords.MODE);
}
async function validateExtensionYarnInfo(packageName) {
return validateYarnInfo(packageName, keywords.EXTENSION);
}
function validateYarnInfo(packageName, keyword) {
return new Promise(async (resolve, reject) => {
function rejectIfNotFound() {
const error = new Error(
`${chalk.red.bold('Error')} extension ${packageName} not installed`
);
reject(error);
}
const packageInfo = await getYarnInfo(packageName).catch(() => {
rejectIfNotFound();
});
if (!packageInfo) {
rejectIfNotFound();
return;
}
const { keywords } = packageInfo;
const isValid = keywords && keywords.includes(keyword);
if (isValid) {
resolve(true);
} else {
const error = new Error(
`${chalk.red.bold('Error')} package ${packageName} is not an ${keyword}`
);
reject(error);
}
});
}
function getVersion(json, version) {
const versions = Object.keys(json.versions);
// if no version is defined get the latest
if (version === undefined) {
return json['dist-tags'].latest;
}
// Get and validate version if it is explicitly defined
const allowMinorVersionUpgrade = version.startsWith('^');
if (!allowMinorVersionUpgrade) {
const isValidVersion = versions.includes(version);
if (!isValidVersion) {
return;
}
return version;
}
// Choose version based on the newer minor/patch versions
const [majorVersion] = version
.split('^')[1]
.split('.')
.map((v) => parseInt(v));
// Find the version that matches the major version, but is the latest minor version
versions
.filter((version) => parseInt(version.split('.')[0]) === majorVersion)
.sort((a, b) => {
const [majorA, minorA, patchA] = a.split('.').map((v) => parseInt(v));
const [majorB, minorB, patchB] = b.split('.').map((v) => parseInt(v));
if (majorA === majorB) {
if (minorA === minorB) {
return patchB - patchA;
}
return minorB - minorA;
}
return majorB - majorA;
});
if (versions.length === 0) {
return;
}
return versions[0];
}
function validate(packageName, version, keyword) {
return new Promise(async (resolve, reject) => {
const { scope } = getPackageNameAndScope(packageName);
// Gets the registry of the package. Scoped packages may not be using the global default.
const registryUrlOfPackage = registryUrl(scope);
const response = await fetch(`${registryUrlOfPackage}${packageName}`);
const json = await response.json();
if (json.error && json.error === NOT_FOUND) {
const error = new Error(
`${chalk.red.bold('Error')} package ${packageName} not found`
);
reject(error);
return;
}
const packageVersion = getVersion(json, version);
if (packageVersion) {
const versionedJson = json.versions[packageVersion];
const keywords = versionedJson.keywords;
const isValid = keywords && keywords.includes(keyword);
if (isValid) {
resolve(true);
} else {
const error = new Error(
`${chalk.red.bold(
'Error'
)} package ${packageName} is not an ${keyword}`
);
reject(error);
}
} else {
// Particular version undefined
const error = new Error(
`${chalk.red.bold(
'Error'
)} version ${packageVersion} of package ${packageName} not found`
);
reject(error);
}
});
}
export {
validateMode,
validateExtension,
validateModeYarnInfo,
validateExtensionYarnInfo,
};
@@ -0,0 +1,14 @@
import chalk from 'chalk';
import { execa } from 'execa';
export default async function validateYarn() {
try {
await execa('yarn', ['--version']);
} catch (err) {
console.log(
'%s Yarn is not installed, please install it before linking your extension',
chalk.red.bold('ERROR')
);
process.exit(1);
}
}