@dcl/sdk-commands 7.1.4-4544067675.commit-d749052 → 7.1.4-4544451404.commit-3e8cb7c
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/.dclrc +19 -0
- package/dist/commands/build/index.d.ts +3 -1
- package/dist/commands/build/index.js +13 -20
- package/dist/commands/deploy/index.js +4 -4
- package/dist/commands/deploy/linker-dapp/api.d.ts +1 -1
- package/dist/commands/deploy/linker-dapp/api.js +14 -17
- package/dist/commands/deploy/linker-dapp/routes.d.ts +1 -1
- package/dist/commands/deploy/linker-dapp/routes.js +2 -2
- package/dist/commands/export-static/index.d.ts +1 -1
- package/dist/commands/export-static/index.js +2 -2
- package/dist/commands/init/index.d.ts +1 -1
- package/dist/commands/init/index.js +1 -1
- package/dist/commands/start/data-layer/fs.d.ts +2 -1
- package/dist/commands/start/data-layer/fs.js +17 -15
- package/dist/commands/start/data-layer/rpc.d.ts +1 -1
- package/dist/commands/start/data-layer/rpc.js +3 -4
- package/dist/commands/start/data-layer/ws.js +1 -1
- package/dist/commands/start/index.d.ts +1 -1
- package/dist/commands/start/index.js +6 -14
- package/dist/commands/start/server/endpoints.d.ts +1 -1
- package/dist/commands/start/server/endpoints.js +7 -11
- package/dist/commands/start/server/routes.js +1 -1
- package/dist/commands/start/types.d.ts +1 -3
- package/dist/components/analytics.d.ts +6 -5
- package/dist/components/analytics.js +46 -51
- package/dist/components/config.d.ts +18 -0
- package/dist/components/config.js +56 -0
- package/dist/components/exit-signal.d.ts +5 -0
- package/dist/components/exit-signal.js +21 -0
- package/dist/components/fs.d.ts +1 -1
- package/dist/components/fs.js +1 -0
- package/dist/components/index.d.ts +4 -3
- package/dist/components/index.js +10 -6
- package/dist/index.js +1 -2
- package/dist/logic/bundle.d.ts +51 -0
- package/dist/logic/bundle.js +120 -0
- package/dist/logic/catalyst-requests.d.ts +16 -1
- package/dist/logic/catalyst-requests.js +28 -4
- package/dist/logic/config.d.ts +15 -7
- package/dist/logic/config.js +54 -28
- package/dist/logic/exec.d.ts +6 -1
- package/dist/logic/exec.js +25 -22
- package/dist/logic/fs.d.ts +1 -7
- package/dist/logic/fs.js +3 -22
- package/dist/logic/project-validations.d.ts +2 -2
- package/dist/logic/project-validations.js +4 -5
- package/dist/logic/realm.d.ts +2 -1
- package/dist/logic/realm.js +6 -4
- package/package.json +9 -5
- package/dist/commands/deploy/linker-dapp/catalyst-pointers.d.ts +0 -20
- package/dist/commands/deploy/linker-dapp/catalyst-pointers.js +0 -45
- package/dist/components/dcl-info-config.d.ts +0 -11
- package/dist/components/dcl-info-config.js +0 -79
- package/dist/logic/dcl-info.d.ts +0 -27
- package/dist/logic/dcl-info.js +0 -90
package/.dclrc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# This file provides the default configurations for sdk-commands
|
2
|
+
|
3
|
+
# Several .dcl.rc configuration files are loaded for each session, each key of the file
|
4
|
+
# overrides the previously loaded, and finally it uses env vars if present. Meaning:
|
5
|
+
# - multiple keys can be present in the same file
|
6
|
+
# - the last file overrides the first file
|
7
|
+
# - env vars override the config files entirely
|
8
|
+
|
9
|
+
# DCL_ANON_ID=0000000-0000000000-0000000
|
10
|
+
DCL_DISABLE_ANALYTICS=false
|
11
|
+
|
12
|
+
# Address of the LAND_REGISTRY smart contract
|
13
|
+
#DCL_LAND_REGISTRY_ADDRESS=
|
14
|
+
|
15
|
+
# Address of the ESTATE_REGISTRY smart contract
|
16
|
+
#DCL_ESTATE_REGISTRY_ADDRESS=
|
17
|
+
|
18
|
+
# Default catalyst node
|
19
|
+
DCL_CATALYST=https://peer.decentraland.org
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { CliComponents } from '../../components';
|
2
2
|
interface Options {
|
3
3
|
args: typeof args;
|
4
|
-
components: Pick<CliComponents, 'fs' | 'logger' | '
|
4
|
+
components: Pick<CliComponents, 'fs' | 'logger' | 'analytics' | 'spawner'>;
|
5
5
|
}
|
6
6
|
export declare const args: import("arg").Result<{
|
7
7
|
'--help': BooleanConstructor;
|
@@ -11,6 +11,8 @@ export declare const args: import("arg").Result<{
|
|
11
11
|
'--watch': BooleanConstructor;
|
12
12
|
'-w': string;
|
13
13
|
'--production': BooleanConstructor;
|
14
|
+
'--single': StringConstructor;
|
15
|
+
'--emitDeclaration': BooleanConstructor;
|
14
16
|
'-p': string;
|
15
17
|
'--skip-install': BooleanConstructor;
|
16
18
|
'--dir': StringConstructor;
|
@@ -1,20 +1,18 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
3
|
exports.main = exports.help = exports.args = void 0;
|
7
4
|
const path_1 = require("path");
|
8
5
|
const args_1 = require("../../logic/args");
|
9
|
-
const compile_1 = require("@dcl/dcl-rollup/compile");
|
10
|
-
const fp_future_1 = __importDefault(require("fp-future"));
|
11
6
|
const project_validations_1 = require("../../logic/project-validations");
|
12
7
|
const scene_validations_1 = require("../../logic/scene-validations");
|
13
8
|
const project_files_1 = require("../../logic/project-files");
|
9
|
+
const bundle_1 = require("../../logic/bundle");
|
14
10
|
exports.args = (0, args_1.getArgs)({
|
15
11
|
'--watch': Boolean,
|
16
12
|
'-w': '--watch',
|
17
13
|
'--production': Boolean,
|
14
|
+
'--single': String,
|
15
|
+
'--emitDeclaration': Boolean,
|
18
16
|
'-p': '--production',
|
19
17
|
'--skip-install': Boolean,
|
20
18
|
'--dir': String
|
@@ -36,31 +34,26 @@ function help() {
|
|
36
34
|
}
|
37
35
|
exports.help = help;
|
38
36
|
async function main(options) {
|
39
|
-
const
|
40
|
-
await (0, project_validations_1.assertValidProjectFolder)(options.components,
|
41
|
-
const shouldInstallDeps = await (0, project_validations_1.needsDependencies)(options.components,
|
37
|
+
const workingDirectory = (0, path_1.resolve)(process.cwd(), options.args['--dir'] || '.');
|
38
|
+
await (0, project_validations_1.assertValidProjectFolder)(options.components, workingDirectory);
|
39
|
+
const shouldInstallDeps = await (0, project_validations_1.needsDependencies)(options.components, workingDirectory);
|
42
40
|
if (shouldInstallDeps && !options.args['--skip-install']) {
|
43
|
-
await (0, project_validations_1.installDependencies)(options.components,
|
41
|
+
await (0, project_validations_1.installDependencies)(options.components, workingDirectory);
|
44
42
|
}
|
45
43
|
const watch = !!options.args['--watch'];
|
46
|
-
const
|
47
|
-
|
48
|
-
project: projectRoot,
|
44
|
+
const { sceneJson } = await (0, bundle_1.bundleProject)(options.components, {
|
45
|
+
workingDirectory,
|
49
46
|
watch,
|
47
|
+
single: options.args['--single'],
|
50
48
|
production: !!options.args['--production'],
|
51
|
-
|
49
|
+
emitDeclaration: !!options.args['--emitDeclaration']
|
52
50
|
});
|
53
|
-
if (!watch) {
|
54
|
-
watchingFuture.resolve(null);
|
55
|
-
}
|
56
|
-
const sceneJson = await (0, scene_validations_1.getValidSceneJson)(options.components, projectRoot);
|
57
51
|
const coords = (0, scene_validations_1.getBaseCoords)(sceneJson);
|
58
|
-
options.components.analytics.
|
59
|
-
projectHash: await (0, project_files_1.b64HashingFunction)(
|
52
|
+
options.components.analytics.track('Build scene', {
|
53
|
+
projectHash: await (0, project_files_1.b64HashingFunction)(workingDirectory),
|
60
54
|
coords,
|
61
55
|
isWorkspace: false,
|
62
56
|
args: (0, args_1.getArgsUsed)(options.args)
|
63
57
|
});
|
64
|
-
await watchingFuture;
|
65
58
|
}
|
66
59
|
exports.main = main;
|
@@ -74,9 +74,9 @@ async function main(options) {
|
|
74
74
|
};
|
75
75
|
const packageJson = await (0, project_files_1.getPackageJson)(options.components, projectRoot);
|
76
76
|
const dependencies = Array.from(new Set([...Object.keys(packageJson.dependencies || {}), ...Object.keys(packageJson.devDependencies || {})]));
|
77
|
-
options.components.analytics.
|
77
|
+
options.components.analytics.track('Scene deploy started', trackProps);
|
78
78
|
if (!skipBuild) {
|
79
|
-
await (0, project_validations_1.npmRun)(projectRoot, 'build');
|
79
|
+
await (0, project_validations_1.npmRun)(options.components, projectRoot, 'build');
|
80
80
|
}
|
81
81
|
// Obtain list of files to deploy
|
82
82
|
const files = await (0, scene_validations_1.getFiles)(options.components, projectRoot);
|
@@ -116,9 +116,9 @@ async function main(options) {
|
|
116
116
|
catch (e) {
|
117
117
|
options.components.logger.error('Could not upload content:');
|
118
118
|
options.components.logger.error(e);
|
119
|
-
options.components.analytics.
|
119
|
+
options.components.analytics.track('Scene deploy failure', { ...trackProps, error: e.message ?? '' });
|
120
120
|
}
|
121
|
-
options.components.analytics.
|
121
|
+
options.components.analytics.track('Scene deploy success', { ...trackProps, dependencies });
|
122
122
|
}
|
123
123
|
exports.main = main;
|
124
124
|
async function getCatalyst(target, targetContent) {
|
@@ -17,7 +17,7 @@ export interface SceneInfo {
|
|
17
17
|
description?: string;
|
18
18
|
skipValidations: boolean;
|
19
19
|
}
|
20
|
-
export declare function runLinkerApp(cliComponents: Pick<CliComponents, 'fs' | 'logger' | 'fetch'>, scene: Scene, files: IFile[], port: number, rootCID: string, { isHttps, skipValidations, openBrowser }: {
|
20
|
+
export declare function runLinkerApp(cliComponents: Pick<CliComponents, 'fs' | 'logger' | 'fetch' | 'config'>, scene: Scene, files: IFile[], port: number, rootCID: string, { isHttps, skipValidations, openBrowser }: {
|
21
21
|
isHttps: boolean;
|
22
22
|
skipValidations: boolean;
|
23
23
|
openBrowser: boolean;
|
@@ -13,14 +13,13 @@ const schemas_1 = require("@dcl/schemas");
|
|
13
13
|
const querystring_1 = __importDefault(require("querystring"));
|
14
14
|
const open_1 = __importDefault(require("open"));
|
15
15
|
const get_free_port_1 = require("../../../logic/get-free-port");
|
16
|
-
const dcl_info_1 = require("../../../logic/dcl-info");
|
17
16
|
const beautiful_logs_1 = require("../../../logic/beautiful-logs");
|
18
17
|
const routes_1 = require("./routes");
|
18
|
+
const config_1 = require("../../../logic/config");
|
19
19
|
function runLinkerApp(cliComponents, scene, files, port, rootCID, { isHttps, skipValidations, openBrowser }) {
|
20
20
|
return new Promise(async (resolve) => {
|
21
|
-
const { logger } = cliComponents;
|
22
21
|
const resolvedPort = await (0, get_free_port_1.getPort)(port, 4044);
|
23
|
-
const sceneInfo = await getSceneInfo(scene, rootCID, skipValidations);
|
22
|
+
const sceneInfo = await getSceneInfo(cliComponents, scene, rootCID, skipValidations);
|
24
23
|
const protocol = isHttps ? 'https' : 'http';
|
25
24
|
const queryParams = querystring_1.default.stringify(sceneInfo);
|
26
25
|
const url = `${protocol}://localhost:${resolvedPort}`;
|
@@ -32,24 +31,23 @@ function runLinkerApp(cliComponents, scene, files, port, rootCID, { isHttps, ski
|
|
32
31
|
...process.env
|
33
32
|
});
|
34
33
|
const logs = await (0, logger_1.createConsoleLogComponent)({});
|
35
|
-
const components = { config, logs };
|
36
34
|
const https = isHttps ? await getCredentials(cliComponents) : undefined;
|
37
|
-
const server = await (0, http_server_1.createServerComponent)(
|
38
|
-
return { config, logs, server };
|
35
|
+
const server = await (0, http_server_1.createServerComponent)({ ...cliComponents, logs }, { https });
|
36
|
+
return { ...cliComponents, config, logs, server };
|
39
37
|
},
|
40
38
|
async main({ components, startComponents }) {
|
41
|
-
const { router, futureSignature } = (0, routes_1.setRoutes)(
|
39
|
+
const { router, futureSignature } = (0, routes_1.setRoutes)(components, files, sceneInfo);
|
42
40
|
components.server.setContext(components);
|
43
41
|
components.server.use(router.allowedMethods());
|
44
42
|
components.server.use(router.middleware());
|
45
43
|
await startComponents();
|
46
44
|
if (openBrowser)
|
47
|
-
await browse(
|
45
|
+
await browse(components, url, queryParams);
|
48
46
|
const value = await futureSignature;
|
49
|
-
(0, beautiful_logs_1.printSuccess)(
|
50
|
-
logger.info(`Address: ${value.address}`);
|
51
|
-
logger.info(`Signature: ${value.signature}`);
|
52
|
-
logger.info(`Network: ${(0, schemas_1.getChainName)(value.chainId)}`);
|
47
|
+
(0, beautiful_logs_1.printSuccess)(components.logger, `\nContent successfully signed.`, '');
|
48
|
+
components.logger.info(`Address: ${value.address}`);
|
49
|
+
components.logger.info(`Signature: ${value.signature}`);
|
50
|
+
components.logger.info(`Network: ${(0, schemas_1.getChainName)(value.chainId)}`);
|
53
51
|
resolve(value);
|
54
52
|
}
|
55
53
|
});
|
@@ -64,7 +62,7 @@ async function browse({ logger }, url, params) {
|
|
64
62
|
await (0, open_1.default)(`${url}?${params}`);
|
65
63
|
}
|
66
64
|
catch (e) {
|
67
|
-
logger.error(`Unable to open browser automatically`);
|
65
|
+
logger.error(`Unable to open browser automatically. Please manually navigate to:\n ${url}?${params}`);
|
68
66
|
}
|
69
67
|
}, 5000);
|
70
68
|
logger.info(`Signing app ready at ${url}`);
|
@@ -74,15 +72,14 @@ async function getCredentials({ fs }) {
|
|
74
72
|
const certificate = await fs.readFile((0, path_1.resolve)(__dirname, '../../../certs/localhost.crt'), 'utf-8');
|
75
73
|
return { key: privateKey, cert: certificate };
|
76
74
|
}
|
77
|
-
async function getSceneInfo(scene, rootCID, skipValidations) {
|
78
|
-
const { LANDRegistry, EstateRegistry } = (0, dcl_info_1.getCustomConfig)();
|
75
|
+
async function getSceneInfo(components, scene, rootCID, skipValidations) {
|
79
76
|
const { scene: { parcels, base }, display } = scene;
|
80
77
|
return {
|
81
78
|
baseParcel: base,
|
82
79
|
parcels,
|
83
80
|
rootCID,
|
84
|
-
landRegistry:
|
85
|
-
estateRegistry:
|
81
|
+
landRegistry: await (0, config_1.getLandRegistry)(components),
|
82
|
+
estateRegistry: await (0, config_1.getEstateRegistry)(components),
|
86
83
|
debug: !!process.env.DEBUG,
|
87
84
|
title: display?.title,
|
88
85
|
description: display?.description,
|
@@ -2,7 +2,7 @@ import { Router } from '@well-known-components/http-server';
|
|
2
2
|
import { CliComponents } from '../../../components';
|
3
3
|
import { IFile } from '../../../logic/scene-validations';
|
4
4
|
import { LinkerResponse, SceneInfo } from './api';
|
5
|
-
export declare function setRoutes(components: Pick<CliComponents, 'fs' | 'logger' | 'fetch'>, files: IFile[], sceneInfo: SceneInfo): {
|
5
|
+
export declare function setRoutes(components: Pick<CliComponents, 'fs' | 'logger' | 'fetch' | 'config'>, files: IFile[], sceneInfo: SceneInfo): {
|
6
6
|
router: Router<{}>;
|
7
7
|
futureSignature: import("fp-future").IFuture<LinkerResponse>;
|
8
8
|
};
|
@@ -9,7 +9,7 @@ const url_1 = __importDefault(require("url"));
|
|
9
9
|
const http_server_1 = require("@well-known-components/http-server");
|
10
10
|
const schemas_1 = require("@dcl/schemas");
|
11
11
|
const fp_future_1 = __importDefault(require("fp-future"));
|
12
|
-
const
|
12
|
+
const catalyst_requests_1 = require("../../../logic/catalyst-requests");
|
13
13
|
const coordinates_1 = require("../../../logic/coordinates");
|
14
14
|
function getContentType(type) {
|
15
15
|
switch (type) {
|
@@ -57,7 +57,7 @@ function setRoutes(components, files, sceneInfo) {
|
|
57
57
|
const pointer = `${x},${y}`;
|
58
58
|
const chainId = deployInfo.linkerResponse?.chainId || 1;
|
59
59
|
const network = chainId === schemas_1.ChainId.ETHEREUM_MAINNET ? 'mainnet' : 'goerli';
|
60
|
-
const value = await (0,
|
60
|
+
const value = await (0, catalyst_requests_1.getPointers)(components, pointer, network);
|
61
61
|
return {
|
62
62
|
body: {
|
63
63
|
catalysts: value,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { CliComponents } from '../../components';
|
2
2
|
interface Options {
|
3
3
|
args: typeof args;
|
4
|
-
components: Pick<CliComponents, 'fetch' | 'fs' | 'logger' | '
|
4
|
+
components: Pick<CliComponents, 'fetch' | 'fs' | 'logger' | 'analytics' | 'config'>;
|
5
5
|
}
|
6
6
|
export declare const args: import("arg").Result<{
|
7
7
|
'--help': BooleanConstructor;
|
@@ -100,7 +100,7 @@ async function main(options) {
|
|
100
100
|
if (willCreateRealm) {
|
101
101
|
// prepare the realm object
|
102
102
|
(0, beautiful_logs_1.printProgressStep)(logger, 'Creating realm file...', currentStep++, maxSteps);
|
103
|
-
const realm = (0, realm_1.createStaticRealm)();
|
103
|
+
const realm = await (0, realm_1.createStaticRealm)(options.components);
|
104
104
|
const realmName = exports.args['--realmName'];
|
105
105
|
realm.configurations.scenesUrn = [urn];
|
106
106
|
realm.configurations.realmName = realmName;
|
@@ -117,7 +117,7 @@ async function main(options) {
|
|
117
117
|
(0, beautiful_logs_1.printSuccess)(logger, `Export finished!`, `=> The entity URN is ${log_1.colors.bold(urn)}`);
|
118
118
|
const sceneJson = await (0, scene_validations_1.getValidSceneJson)(options.components, projectRoot);
|
119
119
|
const coords = (0, scene_validations_1.getBaseCoords)(sceneJson);
|
120
|
-
options.components.analytics.
|
120
|
+
options.components.analytics.track('Export static', {
|
121
121
|
projectHash: await (0, project_files_1.b64HashingFunction)(projectRoot),
|
122
122
|
coords,
|
123
123
|
args: (0, args_1.getArgsUsed)(options.args)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { CliComponents } from '../../components';
|
2
2
|
interface Options {
|
3
3
|
args: typeof args;
|
4
|
-
components: Pick<CliComponents, 'fetch' | 'fs' | 'logger' | '
|
4
|
+
components: Pick<CliComponents, 'fetch' | 'fs' | 'logger' | 'analytics' | 'spawner'>;
|
5
5
|
}
|
6
6
|
export declare const args: import("arg").Result<{
|
7
7
|
'--help': BooleanConstructor;
|
@@ -34,7 +34,7 @@ async function main(options) {
|
|
34
34
|
if (shouldInstallDeps && !options.args['--skip-install']) {
|
35
35
|
await (0, project_validations_1.installDependencies)(options.components, dir);
|
36
36
|
}
|
37
|
-
options.components.analytics.
|
37
|
+
options.components.analytics.track('Scene created', { projectType: scene, url, args: (0, args_1.getArgsUsed)(options.args) });
|
38
38
|
}
|
39
39
|
exports.main = main;
|
40
40
|
const moveFilesFromDir = async (components, dir, folder) => {
|
@@ -1,2 +1,3 @@
|
|
1
1
|
import { FileSystemInterface } from '@dcl/inspector';
|
2
|
-
|
2
|
+
import { IFileSystemComponent } from '../../../components/fs';
|
3
|
+
export declare function createFsFromFsComponent(fs: IFileSystemComponent): FileSystemInterface;
|
@@ -1,28 +1,30 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.
|
7
|
-
|
8
|
-
function createFsFromNode() {
|
3
|
+
exports.createFsFromFsComponent = void 0;
|
4
|
+
function createFsFromFsComponent(fs) {
|
9
5
|
return {
|
10
6
|
async existFile(filePath) {
|
11
|
-
|
7
|
+
try {
|
8
|
+
await fs.access(filePath, fs.constants.F_OK | fs.constants.R_OK);
|
9
|
+
return true;
|
10
|
+
}
|
11
|
+
catch (error) {
|
12
|
+
return false;
|
13
|
+
}
|
12
14
|
},
|
13
15
|
async readFile(filePath) {
|
14
|
-
return
|
16
|
+
return fs.readFile(filePath);
|
15
17
|
},
|
16
18
|
async writeFile(filePath, content) {
|
17
|
-
await
|
19
|
+
await fs.writeFile(filePath, content);
|
18
20
|
},
|
19
21
|
async readdir(dirPath) {
|
20
|
-
const result = await
|
21
|
-
return result.map((
|
22
|
-
name:
|
23
|
-
isDirectory:
|
24
|
-
}));
|
22
|
+
const result = await fs.readdir(dirPath);
|
23
|
+
return Promise.all(result.map(async (name) => ({
|
24
|
+
name: name,
|
25
|
+
isDirectory: await fs.directoryExists(name)
|
26
|
+
})));
|
25
27
|
}
|
26
28
|
};
|
27
29
|
}
|
28
|
-
exports.
|
30
|
+
exports.createFsFromFsComponent = createFsFromFsComponent;
|
@@ -8,4 +8,4 @@ export type DataLayer = {
|
|
8
8
|
rpcServer: RpcServer<DataLayerContext>;
|
9
9
|
context: DataLayerContext;
|
10
10
|
};
|
11
|
-
export declare function createDataLayer({ fs }: Pick<CliComponents, 'fs'>): Promise<DataLayer>;
|
11
|
+
export declare function createDataLayer({ fs, logger }: Pick<CliComponents, 'fs' | 'logger'>): Promise<DataLayer>;
|
@@ -28,13 +28,12 @@ const inspector_1 = require("@dcl/inspector");
|
|
28
28
|
const rpc_1 = require("@dcl/rpc");
|
29
29
|
const codegen = __importStar(require("@dcl/rpc/dist/codegen"));
|
30
30
|
const fs_1 = require("./fs");
|
31
|
-
async function createDataLayer({ fs
|
32
|
-
|
33
|
-
const dataLayerHost = await (0, inspector_1.createDataLayerHost)((0, fs_1.createFsFromNode)());
|
31
|
+
async function createDataLayer({ fs, logger }) {
|
32
|
+
const dataLayerHost = await (0, inspector_1.createDataLayerHost)((0, fs_1.createFsFromFsComponent)(fs));
|
34
33
|
const context = {
|
35
34
|
dataLayerHost
|
36
35
|
};
|
37
|
-
const rpcServer = (0, rpc_1.createRpcServer)({});
|
36
|
+
const rpcServer = (0, rpc_1.createRpcServer)({ logger });
|
38
37
|
async function rpcHandler(serverPort) {
|
39
38
|
// TODO: dataLayer as any
|
40
39
|
codegen.registerService(serverPort, inspector_1.DataServiceDefinition, async (_port, _ctx) => dataLayerHost.rpcMethods);
|
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.handleDataLayerWs = void 0;
|
4
4
|
const WebSocket_1 = require("@dcl/rpc/dist/transports/WebSocket");
|
5
|
-
// TODO: dataLayer should be an optional component
|
5
|
+
// TODO: dataLayer should be an optional component after WKC supports it
|
6
6
|
async function handleDataLayerWs(components, ws, dataLayer) {
|
7
7
|
const wsTransport = (0, WebSocket_1.WebSocketTransport)(ws);
|
8
8
|
dataLayer.rpcServer.attachTransport(wsTransport, dataLayer.context);
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { CliComponents } from '../../components';
|
2
2
|
interface Options {
|
3
3
|
args: typeof args;
|
4
|
-
components: Pick<CliComponents, 'fetch' | 'fs' | 'logger' | '
|
4
|
+
components: Pick<CliComponents, 'fetch' | 'fs' | 'logger' | 'analytics' | 'spawner'>;
|
5
5
|
}
|
6
6
|
export declare const args: import("arg").Result<{
|
7
7
|
'--help': BooleanConstructor;
|
@@ -30,7 +30,6 @@ exports.main = exports.help = exports.args = void 0;
|
|
30
30
|
const os = __importStar(require("os"));
|
31
31
|
const path = __importStar(require("path"));
|
32
32
|
const open_1 = __importDefault(require("open"));
|
33
|
-
const fp_future_1 = __importDefault(require("fp-future"));
|
34
33
|
const build_1 = require("../build");
|
35
34
|
const args_1 = require("../../logic/args");
|
36
35
|
const project_validations_1 = require("../../logic/project-validations");
|
@@ -50,6 +49,7 @@ const routes_1 = require("./server/routes");
|
|
50
49
|
const ws_1 = require("./server/ws");
|
51
50
|
const project_files_1 = require("../../logic/project-files");
|
52
51
|
const rpc_1 = require("./data-layer/rpc");
|
52
|
+
const exit_signal_1 = require("../../components/exit-signal");
|
53
53
|
exports.args = (0, args_1.getArgs)({
|
54
54
|
'--dir': String,
|
55
55
|
'--help': Boolean,
|
@@ -110,7 +110,7 @@ async function main(options) {
|
|
110
110
|
const hasPortableExperience = false;
|
111
111
|
// first run `npm run build`, this can be disabled with --skip-build
|
112
112
|
if (!skipBuild) {
|
113
|
-
await (0, project_validations_1.npmRun)(projectRoot, 'build');
|
113
|
+
await (0, project_validations_1.npmRun)(options.components, projectRoot, 'build');
|
114
114
|
}
|
115
115
|
// then start the embedded compiler, this can be disabled with --no-watch
|
116
116
|
if (watch) {
|
@@ -139,15 +139,7 @@ async function main(options) {
|
|
139
139
|
logs,
|
140
140
|
config
|
141
141
|
});
|
142
|
-
const
|
143
|
-
const signaler = {
|
144
|
-
programClosed,
|
145
|
-
async stop() {
|
146
|
-
// this promise is resolved upon SIGTERM or SIGHUP
|
147
|
-
// or when program.stop is called
|
148
|
-
programClosed.resolve();
|
149
|
-
}
|
150
|
-
};
|
142
|
+
const signaler = (0, exit_signal_1.createExitSignalComponent)();
|
151
143
|
return {
|
152
144
|
...options.components,
|
153
145
|
logger: (0, log_1.createStderrCliLogger)(),
|
@@ -163,15 +155,15 @@ async function main(options) {
|
|
163
155
|
},
|
164
156
|
async main({ components, startComponents }) {
|
165
157
|
// TODO: dataLayerRpc should be an optional component
|
166
|
-
const
|
167
|
-
await (0, routes_1.wireRouter)(components, projectRoot,
|
158
|
+
const dataLayer = withDataLayer ? await (0, rpc_1.createDataLayer)(components) : undefined;
|
159
|
+
await (0, routes_1.wireRouter)(components, projectRoot, dataLayer);
|
168
160
|
if (watch) {
|
169
161
|
await (0, file_watch_notifier_1.wireFileWatcherToWebSockets)(components, projectRoot);
|
170
162
|
}
|
171
163
|
await startComponents();
|
172
164
|
const networkInterfaces = os.networkInterfaces();
|
173
165
|
const availableURLs = [];
|
174
|
-
components.analytics.
|
166
|
+
components.analytics.track('Preview started', {
|
175
167
|
projectHash: await (0, project_files_1.b64HashingFunction)(projectRoot),
|
176
168
|
coords: baseCoords,
|
177
169
|
isWorkspace: false,
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import { Router } from '@well-known-components/http-server';
|
2
2
|
import { PreviewComponents } from '../types';
|
3
3
|
import { CliComponents } from '../../../components';
|
4
|
-
export declare function setupEcs6Endpoints(components: CliComponents, dir: string, router: Router<PreviewComponents>): void
|
4
|
+
export declare function setupEcs6Endpoints(components: CliComponents, dir: string, router: Router<PreviewComponents>): Promise<void>;
|
@@ -30,13 +30,12 @@ const schemas_1 = require("@dcl/schemas");
|
|
30
30
|
const node_fetch_1 = __importStar(require("node-fetch"));
|
31
31
|
const catalyst_requests_1 = require("../../../logic/catalyst-requests");
|
32
32
|
const project_files_1 = require("../../../logic/project-files");
|
33
|
-
|
34
|
-
return new URL('https://peer.decentraland.org');
|
35
|
-
}
|
33
|
+
const config_1 = require("../../../logic/config");
|
36
34
|
function smartWearableNameToId(name) {
|
37
35
|
return name.toLocaleLowerCase().replace(/ /g, '-');
|
38
36
|
}
|
39
|
-
function setupEcs6Endpoints(components, dir, router) {
|
37
|
+
async function setupEcs6Endpoints(components, dir, router) {
|
38
|
+
const catalystUrl = new URL(await (0, config_1.getCatalystBaseUrl)(components));
|
40
39
|
const baseFolders = [dir];
|
41
40
|
// handle old preview scene.json
|
42
41
|
router.get('/scene.json', async () => {
|
@@ -78,7 +77,6 @@ function setupEcs6Endpoints(components, dir, router) {
|
|
78
77
|
baseUrl
|
79
78
|
});
|
80
79
|
if (previewWearables.length === 1) {
|
81
|
-
const catalystUrl = getCatalystUrl();
|
82
80
|
const u = new URL(ctx.url.toString());
|
83
81
|
u.host = catalystUrl.host;
|
84
82
|
u.protocol = catalystUrl.protocol;
|
@@ -109,7 +107,6 @@ function setupEcs6Endpoints(components, dir, router) {
|
|
109
107
|
return next();
|
110
108
|
});
|
111
109
|
router.all('/lambdas/:path+', async (ctx) => {
|
112
|
-
const catalystUrl = getCatalystUrl();
|
113
110
|
const u = new URL(ctx.url.toString());
|
114
111
|
u.host = catalystUrl.host;
|
115
112
|
u.protocol = catalystUrl.protocol;
|
@@ -129,7 +126,6 @@ function setupEcs6Endpoints(components, dir, router) {
|
|
129
126
|
};
|
130
127
|
});
|
131
128
|
router.post('/content/entities', async (ctx) => {
|
132
|
-
const catalystUrl = getCatalystUrl();
|
133
129
|
const headers = new node_fetch_1.Headers();
|
134
130
|
const res = await (0, node_fetch_1.default)(`${catalystUrl.toString()}/content/entities`, {
|
135
131
|
method: 'post',
|
@@ -140,10 +136,11 @@ function setupEcs6Endpoints(components, dir, router) {
|
|
140
136
|
});
|
141
137
|
serveStatic(components, dir, router);
|
142
138
|
// TODO: get workspace scenes & wearables...
|
143
|
-
serveFolders(components, router, baseFolders);
|
139
|
+
await serveFolders(components, router, baseFolders);
|
144
140
|
}
|
145
141
|
exports.setupEcs6Endpoints = setupEcs6Endpoints;
|
146
|
-
function serveFolders(components, router, baseFolders) {
|
142
|
+
async function serveFolders(components, router, baseFolders) {
|
143
|
+
const catalystUrl = await (0, config_1.getCatalystBaseUrl)(components);
|
147
144
|
router.get('/content/contents/:hash', async (ctx, next) => {
|
148
145
|
if (ctx.params.hash && ctx.params.hash.startsWith('b64-')) {
|
149
146
|
const fullPath = path.resolve(Buffer.from(ctx.params.hash.replace(/^b64-/, ''), 'base64').toString('utf8'));
|
@@ -168,8 +165,7 @@ function serveFolders(components, router, baseFolders) {
|
|
168
165
|
}
|
169
166
|
const requestedPointers = new Set(pointers && typeof pointers === 'string' ? [pointers] : pointers);
|
170
167
|
const resultEntities = await getSceneJson(components, baseFolders, Array.from(requestedPointers));
|
171
|
-
const
|
172
|
-
const remote = (0, catalyst_requests_1.fetchEntityByPointer)(catalystUrl.toString(), pointers.filter(($) => !$.match(/-?\d+,-?\d+/)));
|
168
|
+
const remote = (0, catalyst_requests_1.fetchEntityByPointer)(components, catalystUrl.toString(), pointers.filter(($) => !$.match(/-?\d+,-?\d+/)));
|
173
169
|
const serverEntities = Array.isArray(remote) ? remote : [];
|
174
170
|
return [...resultEntities, ...serverEntities];
|
175
171
|
}
|
@@ -24,7 +24,7 @@ async function wireRouter(components, dir, dataLayer) {
|
|
24
24
|
return next();
|
25
25
|
});
|
26
26
|
(0, realm_1.setupRealmAndComms)(components, router);
|
27
|
-
(0, endpoints_1.setupEcs6Endpoints)(components, dir, router);
|
27
|
+
await (0, endpoints_1.setupEcs6Endpoints)(components, dir, router);
|
28
28
|
components.server.setContext(components);
|
29
29
|
components.server.use(router.allowedMethods());
|
30
30
|
components.server.use(router.middleware());
|
@@ -3,6 +3,7 @@ import { HTTPProvider } from 'eth-connect';
|
|
3
3
|
import { RoomComponent } from '@dcl/mini-comms/dist/adapters/rooms';
|
4
4
|
import { WebSocketComponent } from './server/ws';
|
5
5
|
import { CliComponents } from '../../components';
|
6
|
+
import { ISignalerComponent } from '../../components/exit-signal';
|
6
7
|
export type PreviewComponents = CliComponents & {
|
7
8
|
logs: ILoggerComponent;
|
8
9
|
server: IHttpServerComponent<PreviewComponents>;
|
@@ -13,6 +14,3 @@ export type PreviewComponents = CliComponents & {
|
|
13
14
|
ws: WebSocketComponent;
|
14
15
|
signaler: ISignalerComponent;
|
15
16
|
};
|
16
|
-
export type ISignalerComponent = {
|
17
|
-
programClosed: Promise<void>;
|
18
|
-
};
|
@@ -1,10 +1,7 @@
|
|
1
1
|
import { Analytics } from '@segment/analytics-node';
|
2
2
|
import { CliComponents } from '.';
|
3
3
|
export type IAnalyticsComponent = {
|
4
|
-
|
5
|
-
identify(): Promise<void>;
|
6
|
-
track<T extends keyof Events>(eventName: T, eventProps: Events[T]): Promise<void>;
|
7
|
-
trackSync<T extends keyof Events>(eventName: T, eventProps: Events[T]): void;
|
4
|
+
track<T extends keyof Events>(eventName: T, eventProps: Events[T]): void;
|
8
5
|
stop(): Promise<void>;
|
9
6
|
};
|
10
7
|
export type Events = {
|
@@ -69,4 +66,8 @@ export type Events = {
|
|
69
66
|
error: string;
|
70
67
|
};
|
71
68
|
};
|
72
|
-
export declare function createAnalyticsComponent(
|
69
|
+
export declare function createAnalyticsComponent(components: Pick<CliComponents, 'config' | 'logger' | 'fs'>): Promise<IAnalyticsComponent | {
|
70
|
+
get(): Analytics;
|
71
|
+
track: <T extends keyof Events>(eventName: T, eventProps: Events[T]) => void;
|
72
|
+
stop(): Promise<void>;
|
73
|
+
}>;
|