1
- import { getProjectFileByFilePath } from '../../../../components/assets'
2
1
import type { ProjectContentTreeRoot } from 'utopia-shared/src/types'
3
- import { isTextFile } from '../../project-file-types'
4
2
import type { EditorDispatch } from '../../../../components/editor/action-types'
5
3
import CheckPackageJson from './requirements/requirement-package-json'
6
4
import CheckLanguage from './requirements/requirement-language'
7
5
import CheckReactVersion from './requirements/requirement-react'
8
6
import { RequirementResolutionResult } from './utopia-requirements-types'
9
7
import type { ProjectRequirement, RequirementCheck } from './utopia-requirements-types'
10
- import { notifyCheckingRequirement, notifyResolveRequirement } from './utopia-requirements-service'
8
+ import {
9
+ initialTexts,
10
+ notifyCheckingRequirement,
11
+ notifyResolveRequirement,
12
+ } from './utopia-requirements-service'
11
13
import CheckStoryboard from './requirements/requirement-storyboard'
14
+ import CheckServerPackages from './requirements/requirement-server-packages'
12
15
13
16
export function checkAndFixUtopiaRequirements(
14
17
dispatch: EditorDispatch,
@@ -19,13 +22,14 @@ export function checkAndFixUtopiaRequirements(
19
22
packageJsonEntries: new CheckPackageJson(),
20
23
language: new CheckLanguage(),
21
24
reactVersion: new CheckReactVersion(),
25
+ serverPackages: new CheckServerPackages(),
22
26
}
23
27
let projectContents = parsedProjectContents
24
28
let result: RequirementResolutionResult = RequirementResolutionResult.Found
25
29
// iterate over all checks, updating the project contents as we go
26
30
for (const [name, check] of Object.entries(checks)) {
27
31
const checkName = name as ProjectRequirement
28
- notifyCheckingRequirement(dispatch, checkName, check.getStartText() )
32
+ notifyCheckingRequirement(dispatch, checkName, initialTexts[checkName] )
29
33
const checkResult = check.check(projectContents)
30
34
if (checkResult.resolution === RequirementResolutionResult.Critical) {
31
35
result = RequirementResolutionResult.Critical
@@ -41,29 +45,3 @@ export function checkAndFixUtopiaRequirements(
41
45
}
42
46
return { result: result, fixedProjectContents: projectContents }
43
47
}
44
-
45
- export function getPackageJson(
46
- projectContents: ProjectContentTreeRoot,
47
- ): { utopia?: Record<string, string>; dependencies?: Record<string, string> } | null {
48
- return getJsonFile<{ utopia?: Record<string, string>; dependencies?: Record<string, string> }>(
49
- projectContents,
50
- '/package.json',
51
- )
52
- }
53
-
54
- export function getPackageLockJson(
55
- projectContents: ProjectContentTreeRoot,
56
- ): { dependencies?: Record<string, string> } | null {
57
- return getJsonFile<{ dependencies?: Record<string, string> }>(
58
- projectContents,
59
- '/package-lock.json',
60
- )
61
- }
62
-
63
- function getJsonFile<T>(projectContents: ProjectContentTreeRoot, fileName: string): T | null {
64
- const file = getProjectFileByFilePath(projectContents, fileName)
65
- if (file != null && isTextFile(file)) {
66
- return JSON.parse(file.fileContents.code) as T
67
- }
68
- return null
69
- }
0 commit comments