Fetch useYarn info

This commit is contained in:
Rémi de Juvigny 2022-02-18 20:15:46 +01:00
parent 9130c8304c
commit ab18a34b7a
3 changed files with 14 additions and 6 deletions

View File

@ -13,7 +13,7 @@ import { useNotifyAT } from '@strapi/design-system/LiveRegions';
import { Grid, GridItem } from '@strapi/design-system/Grid'; import { Grid, GridItem } from '@strapi/design-system/Grid';
import { Layout, HeaderLayout, ContentLayout } from '@strapi/design-system/Layout'; import { Layout, HeaderLayout, ContentLayout } from '@strapi/design-system/Layout';
import { Main } from '@strapi/design-system/Main'; import { Main } from '@strapi/design-system/Main';
import { fetchPlugins, fetchDependencies } from './utils/api'; import { fetchPlugins, fetchAppInformation } from './utils/api';
import adminPermissions from '../../permissions'; import adminPermissions from '../../permissions';
import PluginCard from './components/PluginCard'; import PluginCard from './components/PluginCard';
@ -41,8 +41,8 @@ const MarketPlacePage = () => {
}; };
const { status: installedDependenciesStatus, data: installedDependenciesResponse } = useQuery( const { status: installedDependenciesStatus, data: installedDependenciesResponse } = useQuery(
'list-dependencies', 'app-information',
() => fetchDependencies(notifyLoad), () => fetchAppInformation(notifyLoad),
{ {
onError: () => { onError: () => {
toggleNotification({ toggleNotification({
@ -91,7 +91,11 @@ const MarketPlacePage = () => {
); );
} }
const installedPackages = Object.keys(installedDependenciesResponse.data.dependencies); const { dependencies, useYarn } = installedDependenciesResponse.data;
const installedPackages = Object.keys(dependencies);
// TODO: implement and remove
console.log({ useYarn });
return ( return (
<CheckPagePermissions permissions={adminPermissions.marketplace.main}> <CheckPagePermissions permissions={adminPermissions.marketplace.main}>

View File

@ -17,7 +17,7 @@ const fetchPlugins = async notify => {
return filteredResponse; return filteredResponse;
}; };
const fetchDependencies = async notify => { const fetchAppInformation = async notify => {
const { data } = await axiosInstance.get('/admin/information'); const { data } = await axiosInstance.get('/admin/information');
notify(); notify();
@ -25,4 +25,4 @@ const fetchDependencies = async notify => {
return data; return data;
}; };
export { fetchPlugins, fetchDependencies }; export { fetchPlugins, fetchAppInformation };

View File

@ -1,7 +1,9 @@
'use strict'; 'use strict';
const path = require('path');
const execa = require('execa'); const execa = require('execa');
const _ = require('lodash'); const _ = require('lodash');
const { exists } = require('fs-extra');
const { ValidationError } = require('@strapi/utils').errors; const { ValidationError } = require('@strapi/utils').errors;
// eslint-disable-next-line node/no-extraneous-require // eslint-disable-next-line node/no-extraneous-require
const ee = require('@strapi/strapi/lib/utils/ee'); const ee = require('@strapi/strapi/lib/utils/ee');
@ -48,6 +50,7 @@ module.exports = {
const dependencies = strapi.config.get('info.dependencies', {}); const dependencies = strapi.config.get('info.dependencies', {});
const nodeVersion = process.version; const nodeVersion = process.version;
const communityEdition = !strapi.EE; const communityEdition = !strapi.EE;
const useYarn = await exists(path.join(process.cwd(), 'yarn.lock'));
return { return {
data: { data: {
@ -57,6 +60,7 @@ module.exports = {
nodeVersion, nodeVersion,
communityEdition, communityEdition,
dependencies, dependencies,
useYarn,
}, },
}; };
}, },