Skip to content

Commit d5beccd

Browse files
authored
Remove pkg.json check (#4248)
* Remove pkg.json check * Remove unused imports
1 parent 929d8ab commit d5beccd

File tree

2 files changed

+0
-57
lines changed

2 files changed

+0
-57
lines changed

packages/app/src/app/overmind/internalActions.ts

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import { getModulePath } from '@codesandbox/common/lib/sandbox/modules';
2-
import { generateFileFromSandbox as generatePackageJsonFromSandbox } from '@codesandbox/common/lib/templates/configuration/package-json';
31
import {
4-
Module,
52
ModuleTab,
63
NotificationButton,
74
Sandbox,
@@ -14,7 +11,6 @@ import { NotificationStatus } from '@codesandbox/notifications';
1411
import values from 'lodash-es/values';
1512

1613
import { ApiError } from './effects/api/apiFactory';
17-
import { createOptimisticModule } from './utils/common';
1814
import { defaultOpenedModule, mainModule } from './utils/main-module';
1915
import { parseConfigurations } from './utils/parse-configurations';
2016
import { Action, AsyncAction } from '.';
@@ -270,57 +266,6 @@ export const setCurrentSandbox: AsyncAction<Sandbox> = async (
270266
actions.server.startContainer(sandbox);
271267
};
272268

273-
export const ensurePackageJSON: AsyncAction = async ({
274-
state,
275-
actions,
276-
effects,
277-
}) => {
278-
const sandbox = state.editor.currentSandbox;
279-
if (!sandbox) {
280-
return;
281-
}
282-
283-
const existingPackageJson = sandbox.modules.find(
284-
module => module.directoryShortid == null && module.title === 'package.json'
285-
);
286-
287-
if (sandbox.owned && !existingPackageJson) {
288-
const optimisticId = effects.utils.createOptimisticId();
289-
const optimisticModule = createOptimisticModule({
290-
id: optimisticId,
291-
title: 'package.json',
292-
code: generatePackageJsonFromSandbox(sandbox),
293-
path: '/package.json',
294-
});
295-
296-
sandbox.modules.push(optimisticModule as Module);
297-
optimisticModule.path = getModulePath(
298-
sandbox.modules,
299-
sandbox.directories,
300-
optimisticId
301-
);
302-
303-
// We grab the module from the state to continue working with it (proxy)
304-
const module = sandbox.modules[sandbox.modules.length - 1];
305-
306-
effects.vscode.sandboxFsSync.writeFile(state.editor.modulesByPath, module);
307-
308-
try {
309-
const updatedModule = await effects.api.createModule(sandbox.id, module);
310-
311-
module.id = updatedModule.id;
312-
module.shortid = updatedModule.shortid;
313-
} catch (error) {
314-
sandbox.modules.splice(sandbox.modules.indexOf(module), 1);
315-
state.editor.modulesByPath = effects.vscode.sandboxFsSync.create(sandbox);
316-
actions.internal.handleError({
317-
message: 'Could not add package.json file',
318-
error,
319-
});
320-
}
321-
}
322-
};
323-
324269
export const closeTabByIndex: Action<number> = ({ state }, tabIndex) => {
325270
const { currentModule } = state.editor;
326271
const tabs = state.editor.tabs as ModuleTab[];

packages/app/src/app/overmind/namespaces/editor/actions.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,6 @@ export const sandboxChanged: AsyncAction<{ id: string }> = withLoadApp<{
261261
});
262262
}
263263

264-
actions.internal.ensurePackageJSON();
265-
266264
await actions.editor.internal.initializeSandbox(sandbox);
267265

268266
// We only recover files at this point if we are not live. When live we recover them

0 commit comments

Comments
 (0)