forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
36 lines (31 loc) · 996 Bytes
/
index.ts
File metadata and controls
36 lines (31 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { Sandbox } from '../../../types';
import slugify from '../../../utils/slugify';
import { ConfigurationFile } from '../types';
export function generateFileFromSandbox(sandbox: Sandbox) {
const jsonFile: {
name: string;
version: string;
description: string;
main: string;
dependencies: object;
keywords: string[];
} = {
name: slugify(sandbox.title || sandbox.id),
version: '1.0.0',
description: sandbox.description || '',
keywords: sandbox.tags,
main: sandbox.entry,
dependencies: sandbox.npmDependencies,
};
return JSON.stringify(jsonFile, null, 2);
}
const config: ConfigurationFile = {
title: 'package.json',
type: 'package',
description: 'Describes the overall configuration of your project.',
moreInfoUrl: 'https://docs.npmjs.com/files/package.json',
generateFileFromSandbox,
schema:
'https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/package.json',
};
export default config;