@dcl/sdk-commands 7.0.0-4293371227.commit-54082c6 → 7.0.0-4295573637.commit-6d503ad

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/commands/build/index.js +1 -1
  2. package/dist/commands/deploy/index.d.ts +31 -0
  3. package/dist/commands/deploy/index.js +131 -0
  4. package/dist/commands/deploy/linker-dapp/api.d.ts +24 -0
  5. package/dist/commands/deploy/linker-dapp/api.js +92 -0
  6. package/dist/commands/deploy/linker-dapp/catalyst-pointers.d.ts +20 -0
  7. package/dist/commands/deploy/linker-dapp/catalyst-pointers.js +45 -0
  8. package/dist/commands/deploy/linker-dapp/routes.d.ts +8 -0
  9. package/dist/commands/deploy/linker-dapp/routes.js +91 -0
  10. package/dist/commands/export-static/index.js +1 -1
  11. package/dist/commands/start/index.js +2 -3
  12. package/dist/components/analytics.js +5 -1
  13. package/dist/logic/account.d.ts +6 -0
  14. package/dist/logic/account.js +21 -0
  15. package/dist/logic/dcl-info.d.ts +26 -0
  16. package/dist/logic/dcl-info.js +90 -0
  17. package/dist/logic/get-free-port.d.ts +1 -1
  18. package/dist/logic/get-free-port.js +6 -6
  19. package/dist/logic/project-files.d.ts +0 -2
  20. package/dist/logic/project-files.js +2 -8
  21. package/dist/logic/project-validations.js +1 -1
  22. package/dist/logic/scene-validations.d.ts +18 -3
  23. package/dist/logic/scene-validations.js +40 -7
  24. package/package.json +8 -3
  25. package/src/commands/build/index.ts +0 -77
  26. package/src/commands/export-static/index.ts +0 -150
  27. package/src/commands/init/index.ts +0 -68
  28. package/src/commands/init/repos.ts +0 -17
  29. package/src/commands/start/index.ts +0 -221
  30. package/src/commands/start/server/endpoints.ts +0 -471
  31. package/src/commands/start/server/file-watch-notifier.ts +0 -45
  32. package/src/commands/start/server/realm.ts +0 -63
  33. package/src/commands/start/server/routes.ts +0 -36
  34. package/src/commands/start/server/ws.ts +0 -24
  35. package/src/commands/start/types.ts +0 -26
  36. package/src/components/analytics.ts +0 -92
  37. package/src/components/dcl-info-config.ts +0 -63
  38. package/src/components/eth.ts +0 -3
  39. package/src/components/fetch.ts +0 -11
  40. package/src/components/fs.ts +0 -62
  41. package/src/components/index.ts +0 -26
  42. package/src/components/log.ts +0 -48
  43. package/src/index.ts +0 -90
  44. package/src/logic/args.ts +0 -19
  45. package/src/logic/beautiful-logs.ts +0 -26
  46. package/src/logic/catalyst-requests.ts +0 -31
  47. package/src/logic/commands.ts +0 -28
  48. package/src/logic/config.ts +0 -45
  49. package/src/logic/coordinates.ts +0 -95
  50. package/src/logic/dcl-ignore.ts +0 -50
  51. package/src/logic/error.ts +0 -1
  52. package/src/logic/exec.ts +0 -36
  53. package/src/logic/fs.ts +0 -76
  54. package/src/logic/get-free-port.ts +0 -15
  55. package/src/logic/project-files.ts +0 -92
  56. package/src/logic/project-validations.ts +0 -61
  57. package/src/logic/realm.ts +0 -28
  58. package/src/logic/scene-validations.ts +0 -81
  59. package/tsconfig.json +0 -28
@@ -1,28 +0,0 @@
1
- import { resolve } from 'path'
2
- import { CliComponents } from '../components'
3
- import { CliError } from './error'
4
-
5
- export const COMMANDS_PATH = resolve(__dirname, '../commands')
6
-
7
- export async function getCommands({ fs }: Pick<CliComponents, 'fs'>): Promise<string[]> {
8
- const commandDirs = await fs.readdir(COMMANDS_PATH)
9
-
10
- const commands = commandDirs.map(async (dir) => {
11
- const path = resolve(COMMANDS_PATH, dir)
12
-
13
- const statDir = await fs.stat(path)
14
-
15
- if (!statDir.isDirectory()) {
16
- throw new CliError('Developer: All commands must be inside a folder')
17
- }
18
-
19
- const statIndex = await fs.stat(`${path}/index.js`)
20
- if (!statIndex.isFile()) {
21
- throw new CliError('Developer: All commands must have an "index.js" file inside')
22
- }
23
-
24
- return dir
25
- })
26
-
27
- return Promise.all(commands)
28
- }
@@ -1,45 +0,0 @@
1
- import path from 'path'
2
- import { CliComponents } from '../components'
3
-
4
- export interface DCLInfo {
5
- segmentKey?: string
6
- userId?: string
7
- trackStats?: boolean
8
- }
9
-
10
- /* istanbul ignore next */
11
- export const getDclInfoPath = () =>
12
- path.resolve(process.env[process.platform === 'win32' ? 'USERPROFILE' : 'HOME'] ?? '', '.dclinfo')
13
-
14
- /**
15
- * Reads the contents of the `.dclinfo` file
16
- */
17
- export async function getDCLInfoConfig(components: Pick<CliComponents, 'fs'>): Promise<DCLInfo> {
18
- try {
19
- const content = await components.fs.readFile(getDclInfoPath(), 'utf8')
20
- return JSON.parse(content) as DCLInfo
21
- } catch (e) {
22
- return {}
23
- }
24
- }
25
-
26
- /**
27
- * Config that can be override via ENV variables
28
- */
29
- export function getEnvConfig(): Partial<DCLInfo> {
30
- const { SEGMENT_KEY } = process.env
31
-
32
- const envConfig = {
33
- segmentKey: SEGMENT_KEY
34
- }
35
-
36
- return removeEmptyKeys(envConfig)
37
- }
38
-
39
- export function removeEmptyKeys(obj: Record<string, unknown>) {
40
- const result: Record<string, unknown> = {}
41
- Object.keys(obj)
42
- .filter((k) => !!obj[k])
43
- .forEach((k) => (result[k] = obj[k]))
44
- return result
45
- }
@@ -1,95 +0,0 @@
1
- export interface IBounds {
2
- minX: number
3
- minY: number
4
- maxX: number
5
- maxY: number
6
- }
7
-
8
- export type Coords = {
9
- x: number
10
- y: number
11
- }
12
-
13
- /**
14
- * Returns metaverse coordinates bounds.
15
- * TODO: use functions from @dcl/schemas
16
- */
17
- export function getBounds(): IBounds {
18
- return {
19
- minX: -150,
20
- minY: -150,
21
- maxX: 165,
22
- maxY: 165
23
- }
24
- }
25
-
26
- /**
27
- * Parses a string-based set of coordinates.
28
- * - All spaces are removed
29
- * - Leading zeroes are removed
30
- * - `-0` is converted to `0`
31
- * @param coordinates An string containing coordinates in the `x,y; x,y; ...` format
32
- */
33
- export function parse(coordinates: string): string[] {
34
- return coordinates.split(';').map((coord: string) => {
35
- const [x, y] = coord.split(',').map(($) => {
36
- return parseInt($, 10)
37
- .toString() // removes spaces :)
38
- .replace('-0', '0')
39
- .replace(/undefined|NaN/g, '0')
40
- })
41
- return `${x},${y}`
42
- })
43
- }
44
-
45
- /**
46
- * Converts a string-based set of coordinates to an object
47
- * @param coords A string containing a set of coordinates
48
- */
49
- export function getObject(coords: string): Coords {
50
- const [x, y] = parse(coords)[0].split(',')
51
- return { x: parseInt(x.toString(), 10), y: parseInt(y.toString(), 10) }
52
- }
53
-
54
- /**
55
- * Returns true if the given coordinates are in metaverse bounds
56
- */
57
- export function inBounds(x: number, y: number): boolean {
58
- const { minX, minY, maxX, maxY } = getBounds()
59
- return x >= minX && x <= maxX && y >= minY && y <= maxY
60
- }
61
-
62
- /**
63
- * Returns true if the given parcels array are connected
64
- */
65
- export function areConnected(parcels: Coords[]): boolean {
66
- if (parcels.length === 0) {
67
- return false
68
- }
69
- const visited = visitParcel(parcels[0], parcels)
70
- return visited.length === parcels.length
71
- }
72
-
73
- function visitParcel(parcel: Coords, allParcels: Coords[], visited: Coords[] = []): Coords[] {
74
- const isVisited = visited.some((visitedParcel) => isEqual(visitedParcel, parcel))
75
- if (!isVisited) {
76
- visited.push(parcel)
77
- const neighbours = getNeighbours(parcel.x, parcel.y, allParcels)
78
- neighbours.forEach((neighbours) => visitParcel(neighbours, allParcels, visited))
79
- }
80
- return visited
81
- }
82
-
83
- function getIsNeighbourMatcher(x: number, y: number) {
84
- return (coords: Coords) =>
85
- (coords.x === x && (coords.y + 1 === y || coords.y - 1 === y)) ||
86
- (coords.y === y && (coords.x + 1 === x || coords.x - 1 === x))
87
- }
88
-
89
- function getNeighbours(x: number, y: number, parcels: Coords[]): Coords[] {
90
- return parcels.filter(getIsNeighbourMatcher(x, y))
91
- }
92
-
93
- export function isEqual(p1: Coords, p2: Coords): boolean {
94
- return p1.x === p2.x && p1.y === p2.y
95
- }
@@ -1,50 +0,0 @@
1
- /* istanbul ignore file */
2
- import path from 'path'
3
- import { CliComponents } from '../components'
4
-
5
- export const defaultDclIgnore = [
6
- '.*',
7
- 'package.json',
8
- 'package-lock.json',
9
- 'yarn-lock.json',
10
- 'build.json',
11
- 'export',
12
- 'tsconfig.json',
13
- 'tslint.json',
14
- 'node_modules',
15
- '**/*.ts',
16
- '**/*.tsx',
17
- 'Dockerfile',
18
- 'dist',
19
- 'README.md',
20
- '*.blend',
21
- '*.fbx',
22
- '*.zip',
23
- '*.rar'
24
- ]
25
-
26
- export async function getDCLIgnoreFileContents(
27
- components: Pick<CliComponents, 'fs'>,
28
- dir: string
29
- ): Promise<string | null> {
30
- try {
31
- return components.fs.readFile(path.resolve(dir, '.dclignore'), 'utf8')
32
- } catch (e) {}
33
-
34
- return null
35
- }
36
-
37
- /**
38
- * Returns the default .dclignore entries plus the ones provided by the user.
39
- * In case of .dclignore not existing, it returns a pre-defined list.
40
- */
41
- export async function getDCLIgnorePatterns(components: Pick<CliComponents, 'fs'>, dir: string): Promise<string[]> {
42
- const ignoredContent = await getDCLIgnoreFileContents(components, dir)
43
- const ignored = (ignoredContent?.split('\n') || defaultDclIgnore).filter(Boolean)
44
- ignored.push(...defaultDclIgnore)
45
-
46
- // by default many files need to be ignored
47
- ignored.push('.*', 'node_modules', '**/*.ts', '**/*.tsx')
48
-
49
- return Array.from(new Set(ignored))
50
- }
@@ -1 +0,0 @@
1
- export class CliError extends Error {}
package/src/logic/exec.ts DELETED
@@ -1,36 +0,0 @@
1
- import { spawn } from 'child_process'
2
-
3
- interface Options {
4
- env: { [key: string]: string }
5
- silent: boolean
6
- }
7
-
8
- export function exec(
9
- cwd: string,
10
- command: string,
11
- args: string[],
12
- { env, silent }: Partial<Options> = {}
13
- ): Promise<void> {
14
- return new Promise((resolve, reject) => {
15
- const child = spawn(command, args, {
16
- shell: true,
17
- cwd,
18
- env: { ...process.env, NODE_ENV: '', ...env }
19
- })
20
-
21
- if (!silent) {
22
- child.stdout.pipe(process.stdout)
23
- child.stderr.pipe(process.stderr)
24
- }
25
-
26
- child.on('close', (code: number) => {
27
- if (code !== 0) {
28
- const _ = `${command} ${args.join(' ')}`
29
- reject(new Error(`Command "${_}" exited with code ${code}. Please try running the command manually`))
30
- return
31
- }
32
-
33
- resolve(undefined)
34
- })
35
- })
36
- }
package/src/logic/fs.ts DELETED
@@ -1,76 +0,0 @@
1
- import extractZip from 'extract-zip'
2
- import { resolve } from 'path'
3
- import { IFileSystemComponent } from '../components/fs'
4
- import { IFetchComponent } from '../components/fetch'
5
- import { CliComponents } from '../components'
6
-
7
- /**
8
- * Check's if directory is empty
9
- * @param dir Directory to check for emptyness
10
- */
11
- export async function isDirectoryEmpty(components: { fs: IFileSystemComponent }, dir: string): Promise<boolean> {
12
- const files = await components.fs.readdir(dir)
13
- return !files.length
14
- }
15
-
16
- /**
17
- * Download a file
18
- * @param url URL of the file
19
- * @param dest Path to where to save the file
20
- */
21
- export async function download(
22
- components: { fs: IFileSystemComponent; fetch: IFetchComponent },
23
- url: string,
24
- dest: string
25
- ): Promise<string> {
26
- // we should remove this package and use the native "fetch" when Node
27
- // releases it as stable: https://nodejs.org/docs/latest-v18.x/api/globals.html#fetch
28
- const data = await (await components.fetch.fetch(url)).arrayBuffer()
29
- await components.fs.writeFile(dest, Buffer.from(data))
30
- return dest
31
- }
32
-
33
- /**
34
- * Extracts a .zip file
35
- * @param url Path of the zip file
36
- * @param dest Path to where to extract the zip file
37
- */
38
- export async function extract(path: string, dest: string): Promise<string> {
39
- const destPath = resolve(dest)
40
- await extractZip(resolve(path), { dir: destPath })
41
- return destPath
42
- }
43
-
44
- /**
45
- * Reads a file and parses it's JSON content
46
- * @param path The path to the subject json file
47
- */
48
- export async function readJSON<T>(components: Pick<CliComponents, 'fs'>, path: string): Promise<T> {
49
- const content = await components.fs.readFile(path, 'utf-8')
50
- return JSON.parse(content) as T
51
- }
52
-
53
- /**
54
- * Merges the provided content with a json file
55
- * @param path The path to the subject json file
56
- * @param content The content to be applied (as a plain object)
57
- */
58
- export async function writeJSON<T = unknown>(
59
- components: Pick<CliComponents, 'fs'>,
60
- path: string,
61
- content: Partial<T>
62
- ): Promise<Partial<T>> {
63
- let currentFile
64
-
65
- try {
66
- currentFile = await readJSON<T>(components, path)
67
- } catch (e) {
68
- currentFile = {}
69
- }
70
-
71
- const newJson = { ...currentFile, ...content }
72
- const strContent = JSON.stringify(newJson, null, 2)
73
-
74
- await components.fs.writeFile(path, strContent)
75
- return newJson
76
- }
@@ -1,15 +0,0 @@
1
- import portfinder from 'portfinder'
2
-
3
- export async function previewPort() {
4
- let resolvedPort = 0
5
-
6
- if (!resolvedPort) {
7
- try {
8
- resolvedPort = await portfinder.getPortPromise()
9
- } catch (e) {
10
- resolvedPort = 2044
11
- }
12
- }
13
-
14
- return resolvedPort
15
- }
@@ -1,92 +0,0 @@
1
- import { ContentMapping } from '@dcl/schemas/dist/misc/content-mapping'
2
- import { CliComponents } from '../components'
3
- import { getDCLIgnorePatterns } from './dcl-ignore'
4
- import { sync as globSync } from 'glob'
5
- import ignore from 'ignore'
6
- import path from 'path'
7
- import { CliError } from './error'
8
- import { getSceneFilePath } from './scene-validations'
9
- import { Scene } from '@dcl/schemas'
10
-
11
- /**
12
- * Returns an array of the publishable files for a given folder.
13
- *
14
- */
15
- /* istanbul ignore next */
16
- export async function getPublishableFiles(
17
- components: Pick<CliComponents, 'fs'>,
18
- projectRoot: string
19
- ): Promise<Array<string>> {
20
- const ignorePatterns = await getDCLIgnorePatterns(components, projectRoot)
21
-
22
- const ig = ignore().add(ignorePatterns)
23
-
24
- const allFiles = globSync('**/*', {
25
- cwd: projectRoot,
26
- absolute: false,
27
- dot: false,
28
- ignore: ignorePatterns,
29
- nodir: true
30
- })
31
-
32
- return ig.filter(allFiles)
33
- }
34
-
35
- /**
36
- * This function converts paths to decentraland-compatible paths.
37
- * - From windows separators to unix separators.
38
- * - All to lowercase
39
- *
40
- */
41
- /* istanbul ignore next */
42
- export function normalizeDecentralandFilename(filename: string) {
43
- return filename.replace(/(\\)/g, '/').toLowerCase()
44
- }
45
-
46
- /**
47
- * Returns the content mappings for a specific project folder.
48
- */
49
- /* istanbul ignore next */
50
- export async function getProjectContentMappings(
51
- components: Pick<CliComponents, 'fs'>,
52
- projectRoot: string,
53
- /* istanbul ignore next */
54
- hashingFunction: (filePath: string) => Promise<string>
55
- ): Promise<ContentMapping[]> {
56
- const projectFiles = await getPublishableFiles(components, projectRoot)
57
- const ret: ContentMapping[] = []
58
-
59
- const usedFilenames = new Set<string>()
60
-
61
- for (const file of projectFiles) {
62
- const absolutePath = path.resolve(projectRoot, file)
63
-
64
- /* istanbul ignore if */
65
- if (!(await components.fs.fileExists(absolutePath))) continue
66
-
67
- // remove heading '/'
68
- const normalizedFile = normalizeDecentralandFilename(file).replace(/^\/+/, '')
69
-
70
- /* istanbul ignore if */
71
- if (usedFilenames.has(normalizedFile)) {
72
- throw new CliError(
73
- `DuplicatedFilenameError: the file ${file} exists with a different casing. Please manually remove one occurrence`
74
- )
75
- }
76
-
77
- ret.push({
78
- file: normalizedFile,
79
- hash: await hashingFunction(absolutePath)
80
- })
81
- }
82
-
83
- return ret
84
- }
85
-
86
- export async function getSceneJson(components: Pick<CliComponents, 'fs'>, projectRoot: string): Promise<Scene> {
87
- const sceneJsonContent = await components.fs.readFile(getSceneFilePath(projectRoot), 'utf8')
88
- const sceneJson = JSON.parse(sceneJsonContent) as Scene
89
- return sceneJson
90
- }
91
-
92
- export const b64HashingFunction = async (str: string) => 'b64-' + Buffer.from(str).toString('base64')
@@ -1,61 +0,0 @@
1
- import { Scene } from '@dcl/schemas'
2
- import { resolve } from 'path'
3
- import { CliComponents } from '../components'
4
- import { CliError } from './error'
5
- import { exec } from './exec'
6
- import { validateSceneJson } from './scene-validations'
7
-
8
- /**
9
- * Asserts that the projectRoot is a valid project
10
- */
11
- export async function assertValidProjectFolder(
12
- components: Pick<CliComponents, 'fs' | 'logger'>,
13
- projectRoot: string
14
- ): Promise<{ scene: Scene }> {
15
- // no validations for now, only check that it exists
16
- if (!(await components.fs.fileExists(resolve(projectRoot, 'package.json'))))
17
- throw new CliError(`The project root doesn't have a package.json file`)
18
-
19
- // now we will iterate over different file to evaluate the project kind
20
- switch (true) {
21
- // case wearable
22
- case await components.fs.fileExists(resolve(projectRoot, 'scene.json')): {
23
- return { scene: await validateSceneJson(components, projectRoot) }
24
- }
25
- default: {
26
- throw new CliError(`UnknownProjectKind: the kind of project of the folder ${projectRoot} cannot be identified`)
27
- }
28
- }
29
- }
30
-
31
- /*
32
- * Returns true if the project contains an empty node_modules folder
33
- */
34
- export async function needsDependencies(components: Pick<CliComponents, 'fs'>, dir: string): Promise<boolean> {
35
- const nodeModulesPath = resolve(dir, 'node_modules')
36
- const hasNodeModulesFolder = await components.fs.directoryExists(nodeModulesPath)
37
- const isNodeModulesEmpty = hasNodeModulesFolder && (await components.fs.readdir(nodeModulesPath)).length === 0
38
-
39
- return !hasNodeModulesFolder || isNodeModulesEmpty
40
- }
41
-
42
- /* istanbul ignore next */
43
- export const npm = /^win/.test(process.platform) ? 'npm.cmd' : 'npm'
44
-
45
- /*
46
- * Runs "npm install" for desired project
47
- */
48
- export async function installDependencies(components: Pick<CliComponents, 'logger'>, directory: string): Promise<void> {
49
- components.logger.info('Installing dependencies...')
50
- // TODO: test in windows
51
- await exec(directory, npm, ['install'])
52
- components.logger.log('Installing dependencies... ✅')
53
- }
54
-
55
- /**
56
- * Run NPM commands
57
- */
58
- export async function npmRun(cwd: string, command: string, ...args: string[]): Promise<void> {
59
- // TODO: test in windows
60
- await exec(cwd, npm, ['run', command, '--silent', '--', ...args], { env: process.env as any })
61
- }
@@ -1,28 +0,0 @@
1
- import { AboutResponse } from '@dcl/protocol/out-js/decentraland/bff/http_endpoints.gen'
2
-
3
- export function createStaticRealm(): AboutResponse {
4
- return {
5
- acceptingUsers: true,
6
- bff: { healthy: false, publicUrl: `https://peer.decentraland.org/bff` },
7
- comms: {
8
- healthy: true,
9
- protocol: 'v3',
10
- fixedAdapter: `offline:offline`
11
- },
12
- configurations: {
13
- networkId: 0,
14
- globalScenesUrn: [],
15
- scenesUrn: [],
16
- realmName: 'SdkStaticExport'
17
- },
18
- content: {
19
- healthy: true,
20
- publicUrl: `https://peer.decentraland.org/content`
21
- },
22
- lambdas: {
23
- healthy: true,
24
- publicUrl: `https://peer.decentraland.org/lambdas`
25
- },
26
- healthy: true
27
- }
28
- }
@@ -1,81 +0,0 @@
1
- import { resolve } from 'path'
2
- import { Scene } from '@dcl/schemas'
3
- import { CliError } from './error'
4
- import { getObject, inBounds, getBounds, areConnected } from './coordinates'
5
- import { CliComponents } from '../components'
6
- import { getSceneJson } from './project-files'
7
-
8
- export const SCENE_FILE = 'scene.json'
9
-
10
- /**
11
- * Composes the path to the `scene.json` file based on the provided path.
12
- * @param projectRoot The path to the directory containing the scene file.
13
- */
14
- export function getSceneFilePath(projectRoot: string): string {
15
- return resolve(projectRoot, SCENE_FILE)
16
- }
17
-
18
- export function assertValidScene(scene: Scene) {
19
- if (!Scene.validate(scene)) {
20
- const errors: string[] = []
21
- if (Scene.validate.errors) {
22
- for (const error of Scene.validate.errors) {
23
- errors.push(`Error validating scene.json: ${error.message}`)
24
- }
25
- }
26
- throw new CliError('Invalid scene.json file:\n' + errors.join('\n'))
27
- }
28
-
29
- const parcelSet = new Set(scene.scene?.parcels)
30
-
31
- if (parcelSet.size < scene.scene?.parcels?.length) {
32
- throw new CliError(`There are duplicated parcels at scene.json.`)
33
- }
34
-
35
- if (!parcelSet.has(scene.scene?.base)) {
36
- throw new CliError(`Your base parcel ${scene.scene?.base} should be included on parcels attribute at scene.json`)
37
- }
38
-
39
- const objParcels = scene.scene?.parcels?.map(getObject)
40
- objParcels.forEach(({ x, y }) => {
41
- if (inBounds(x, y)) {
42
- return
43
- }
44
- const { minX, maxX } = getBounds()
45
- throw new CliError(`Coordinates ${x},${y} are outside of allowed limits (from ${minX} to ${maxX})`)
46
- })
47
-
48
- if (!areConnected(objParcels)) {
49
- throw new CliError('Parcels described on scene.json are not connected. They should be one next to each other')
50
- }
51
-
52
- if (!scene.main?.endsWith('.js')) {
53
- throw new CliError(`Main scene format file (${scene.main}) is not a supported format`)
54
- }
55
-
56
- return scene
57
- }
58
-
59
- /**
60
- * Fails the execution if one of the parcel data is invalid
61
- */
62
- export async function validateSceneJson(
63
- components: Pick<CliComponents, 'fs' | 'logger'>,
64
- projectRoot: string
65
- ): Promise<Scene> {
66
- try {
67
- const sceneJson = await getSceneJson(components, projectRoot)
68
-
69
- return assertValidScene(sceneJson)
70
- } catch (err: any) {
71
- throw new CliError(`Error reading the scene.json file: ${err.message}`)
72
- }
73
- }
74
-
75
- export function getBaseCoords(scene: Scene): { x: number; y: number } {
76
- const [x, y] = scene.scene.base
77
- .replace(/\ /g, '')
78
- .split(',')
79
- .map((a) => parseInt(a))
80
- return { x, y }
81
- }
package/tsconfig.json DELETED
@@ -1,28 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "commonjs",
5
- "esModuleInterop": true,
6
- "declaration": true,
7
- "noUnusedLocals": true,
8
- "stripInternal": true,
9
- "skipLibCheck": true,
10
- "forceConsistentCasingInFileNames": true,
11
- "allowJs": true,
12
- "resolveJsonModule": true,
13
- "strict": true,
14
- "types": [
15
- "node",
16
- ],
17
- "lib": [
18
- "es2020"
19
- ],
20
- "outDir": "./dist"
21
- },
22
- "include": [
23
- "src"
24
- ],
25
- "exclude": [
26
- "dist"
27
- ]
28
- }