Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function createDynamicFiles(args: { project: Project; scene: Scene; point: Coordinate; rotation: Rotation }) {
const { project, scene, rotation, point } = args
const files = {
[EXPORT_PATH.MANIFEST_FILE]: JSON.stringify({
version: MANIFEST_FILE_VERSION,
project,
scene
}),
[EXPORT_PATH.PACKAGE_FILE]: JSON.stringify(
{
...packageJson,
name: project.id,
dependencies: {
...packageJson.devDependencies,
'decentraland-builder-scripts': 'latest'
}
},
null,
2
),
[EXPORT_PATH.SCENE_FILE]: JSON.stringify(getSceneDefinition(project, point, rotation), null, 2),
[EXPORT_PATH.TSCONFIG_FILE]: JSON.stringify(
{
...tsconfig,
include: tsconfig.include.concat(['./node_modules/decentraland-builder-scripts/types.d.ts'])
},
null,
2
)
}
export function getSceneDefinition(project: Project, point: Coordinate, rotation: Rotation) {
const parcels = getParcelOrientation(project, point, rotation)
const base = parcels.reduce((base, parcel) => (parcel.x <= base.x && parcel.y <= base.y ? parcel : base), parcels[0])
return {
...sceneJson,
scene: {
...sceneJson.scene,
parcels: parcels.map(parcelToString),
base: parcelToString(base)
},
source: {
origin: 'builder',
projectId: project.id
}
}
}
{
...packageJson,
name: project.id,
dependencies: {
...packageJson.devDependencies,
'decentraland-builder-scripts': 'latest'
}
},
null,
2
),
[EXPORT_PATH.SCENE_FILE]: JSON.stringify(getSceneDefinition(project, point, rotation), null, 2),
[EXPORT_PATH.TSCONFIG_FILE]: JSON.stringify(
{
...tsconfig,
include: tsconfig.include.concat(['./node_modules/decentraland-builder-scripts/types.d.ts'])
},
null,
2
)
}
return files
}