@dcl/sdk-commands 7.0.0-4286109573.commit-baaf951 → 7.0.0-4294380152.commit-0d08b10
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.
- package/dist/commands/build/index.d.ts +1 -1
- package/dist/commands/build/index.js +9 -0
- package/dist/commands/export-static/index.d.ts +1 -1
- package/dist/commands/export-static/index.js +7 -0
- package/dist/commands/init/index.d.ts +1 -1
- package/dist/commands/init/index.js +1 -0
- package/dist/commands/start/index.d.ts +1 -1
- package/dist/commands/start/index.js +9 -1
- package/dist/commands/start/server/endpoints.js +2 -3
- package/dist/components/analytics.d.ts +38 -0
- package/dist/components/analytics.js +66 -0
- package/dist/components/dcl-info-config.d.ts +11 -0
- package/dist/components/dcl-info-config.js +75 -0
- package/dist/components/index.d.ts +5 -1
- package/dist/components/index.js +9 -3
- package/dist/index.js +2 -1
- package/dist/logic/config.d.ts +16 -0
- package/dist/logic/config.js +42 -0
- package/dist/logic/dcl-ignore.js +1 -0
- package/dist/logic/fs.d.ts +12 -0
- package/dist/logic/fs.js +29 -1
- package/dist/logic/project-files.d.ts +5 -0
- package/dist/logic/project-files.js +18 -2
- package/dist/logic/scene-validations.d.ts +4 -0
- package/dist/logic/scene-validations.js +11 -3
- package/package.json +10 -4
- package/src/commands/build/index.ts +0 -68
- package/src/commands/export-static/index.ts +0 -142
- package/src/commands/init/index.ts +0 -67
- package/src/commands/init/repos.ts +0 -17
- package/src/commands/start/index.ts +0 -213
- package/src/commands/start/server/endpoints.ts +0 -473
- package/src/commands/start/server/file-watch-notifier.ts +0 -45
- package/src/commands/start/server/realm.ts +0 -63
- package/src/commands/start/server/routes.ts +0 -36
- package/src/commands/start/server/ws.ts +0 -24
- package/src/commands/start/types.ts +0 -26
- package/src/components/eth.ts +0 -3
- package/src/components/fetch.ts +0 -11
- package/src/components/fs.ts +0 -62
- package/src/components/index.ts +0 -18
- package/src/components/log.ts +0 -48
- package/src/index.ts +0 -90
- package/src/logic/args.ts +0 -19
- package/src/logic/beautiful-logs.ts +0 -26
- package/src/logic/catalyst-requests.ts +0 -31
- package/src/logic/commands.ts +0 -28
- package/src/logic/coordinates.ts +0 -95
- package/src/logic/dcl-ignore.ts +0 -49
- package/src/logic/error.ts +0 -1
- package/src/logic/exec.ts +0 -36
- package/src/logic/fs.ts +0 -41
- package/src/logic/get-free-port.ts +0 -15
- package/src/logic/project-files.ts +0 -76
- package/src/logic/project-validations.ts +0 -61
- package/src/logic/realm.ts +0 -28
- package/src/logic/scene-validations.ts +0 -73
- package/tsconfig.json +0 -28
|
@@ -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
|
-
}
|
package/src/logic/realm.ts
DELETED
|
@@ -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,73 +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
|
-
|
|
7
|
-
export const SCENE_FILE = 'scene.json'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Composes the path to the `scene.json` file based on the provided path.
|
|
11
|
-
* @param projectRoot The path to the directory containing the scene file.
|
|
12
|
-
*/
|
|
13
|
-
export function getSceneFilePath(projectRoot: string): string {
|
|
14
|
-
return resolve(projectRoot, SCENE_FILE)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function assertValidScene(scene: Scene) {
|
|
18
|
-
if (!Scene.validate(scene)) {
|
|
19
|
-
const errors: string[] = []
|
|
20
|
-
if (Scene.validate.errors) {
|
|
21
|
-
for (const error of Scene.validate.errors) {
|
|
22
|
-
errors.push(`Error validating scene.json: ${error.message}`)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
throw new CliError('Invalid scene.json file:\n' + errors.join('\n'))
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const parcelSet = new Set(scene.scene?.parcels)
|
|
29
|
-
|
|
30
|
-
if (parcelSet.size < scene.scene?.parcels?.length) {
|
|
31
|
-
throw new CliError(`There are duplicated parcels at scene.json.`)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (!parcelSet.has(scene.scene?.base)) {
|
|
35
|
-
throw new CliError(`Your base parcel ${scene.scene?.base} should be included on parcels attribute at scene.json`)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const objParcels = scene.scene?.parcels?.map(getObject)
|
|
39
|
-
objParcels.forEach(({ x, y }) => {
|
|
40
|
-
if (inBounds(x, y)) {
|
|
41
|
-
return
|
|
42
|
-
}
|
|
43
|
-
const { minX, maxX } = getBounds()
|
|
44
|
-
throw new CliError(`Coordinates ${x},${y} are outside of allowed limits (from ${minX} to ${maxX})`)
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
if (!areConnected(objParcels)) {
|
|
48
|
-
throw new CliError('Parcels described on scene.json are not connected. They should be one next to each other')
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (!scene.main?.endsWith('.js')) {
|
|
52
|
-
throw new CliError(`Main scene format file (${scene.main}) is not a supported format`)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return scene
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Fails the execution if one of the parcel data is invalid
|
|
60
|
-
*/
|
|
61
|
-
export async function validateSceneJson(
|
|
62
|
-
components: Pick<CliComponents, 'fs' | 'logger'>,
|
|
63
|
-
projectRoot: string
|
|
64
|
-
): Promise<Scene> {
|
|
65
|
-
try {
|
|
66
|
-
const sceneJsonRaw = await components.fs.readFile(getSceneFilePath(projectRoot), 'utf8')
|
|
67
|
-
const sceneJson = JSON.parse(sceneJsonRaw) as Scene
|
|
68
|
-
|
|
69
|
-
return assertValidScene(sceneJson)
|
|
70
|
-
} catch (err: any) {
|
|
71
|
-
throw new CliError(`Error reading the scene.json file: ${err.message}`)
|
|
72
|
-
}
|
|
73
|
-
}
|
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
|
-
}
|