File tree Expand file tree Collapse file tree 3 files changed +11
-9
lines changed
overmind/namespaces/editor
pages/Sandbox/Editor/Workspace/Dependencies
common/src/templates/configuration Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 11import getTemplate from '@codesandbox/common/lib/templates' ;
22import { generateFileFromSandbox } from '@codesandbox/common/lib/templates/configuration/package-json' ;
33import { getPreviewTabs } from '@codesandbox/common/lib/templates/devtools' ;
4- import { ViewConfig } from '@codesandbox/common/lib/templates/template' ;
4+ import {
5+ ParsedConfigurationFiles ,
6+ ViewConfig ,
7+ } from '@codesandbox/common/lib/templates/template' ;
58import {
69 DevToolsTabPosition ,
710 DiffTab ,
@@ -56,7 +59,7 @@ type State = {
5659 mainModule : Derive < State , Module > ;
5760 currentPackageJSON : Derive < State , Module > ;
5861 currentPackageJSONCode : Derive < State , string > ;
59- parsedConfigurations : Derive < State , any > ;
62+ parsedConfigurations : Derive < State , ParsedConfigurationFiles > | null ;
6063 currentTab : Derive < State , ModuleTab | DiffTab > ;
6164 modulesByPath : SandboxFs ;
6265 isAdvancedEditor : Derive < State , boolean > ;
Original file line number Diff line number Diff line change @@ -32,26 +32,27 @@ export const Dependencies: FunctionComponent = () => {
3232 resource => ! resource . includes ( 'fonts.googleapis.com/css' )
3333 ) ;
3434
35- if ( ! parsedConfigurations . package ) {
35+ if ( ! parsedConfigurations ? .package ) {
3636 return < ErrorMessage > Unable to find package.json</ ErrorMessage > ;
3737 }
3838
39- const { parsed , error } = parsedConfigurations . package ;
39+ const { error , parsed } = parsedConfigurations . package ;
4040 if ( error ) {
4141 return (
4242 < ErrorMessage > We weren{ "'" } t able to parse the package.json</ ErrorMessage >
4343 ) ;
4444 }
4545
46+ const { dependencies = { } /* devDependencies = {} */ } = parsed ;
4647 const { externalResourcesEnabled } = getTemplateDefinition ( template ) ;
4748 return (
4849 < div >
4950 < Margin bottom = { 0 } >
50- { Object . keys ( parsed . dependencies )
51+ { Object . keys ( dependencies )
5152 . sort ( )
5253 . map ( dependency => (
5354 < VersionEntry
54- dependencies = { parsed . dependencies }
55+ dependencies = { dependencies }
5556 dependency = { dependency }
5657 key = { dependency }
5758 onRefresh = { ( name , version ) => addNpmDependency ( { name, version } ) }
Original file line number Diff line number Diff line change @@ -18,12 +18,10 @@ export type ConfigurationFile = {
1818} ;
1919
2020export type ParsedConfigurationFile < T > = {
21- parsed ?: T ;
2221 code : string ;
2322 generated : boolean ;
24- error ?: Error ;
2523 path : string ;
26- } ;
24+ } & ( { parsed : T } | { error : Error } ) ;
2725
2826export type ConfigurationUIProps = {
2927 file : string ;
You can’t perform that action at this time.
0 commit comments