@dcl/sdk-commands 7.20.4-22576263908.commit-9ddd8ad → 7.20.4-22581991550.commit-9c72184
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/deploy/utils.d.ts +2 -0
- package/dist/commands/deploy/utils.js +2 -1
- package/dist/commands/deploy/utils.js.map +1 -1
- package/dist/commands/sdk-server-logs/index.d.ts +21 -0
- package/dist/commands/sdk-server-logs/index.js +262 -0
- package/dist/commands/sdk-server-logs/index.js.map +1 -0
- package/dist/commands/start/hammurabi-server.d.ts +19 -0
- package/dist/commands/start/hammurabi-server.js +78 -0
- package/dist/commands/start/hammurabi-server.js.map +1 -0
- package/dist/commands/start/index.d.ts +1 -1
- package/dist/commands/start/index.js +37 -32
- package/dist/commands/start/index.js.map +1 -1
- package/dist/commands/start/server/routes.js +5 -1
- package/dist/commands/start/server/routes.js.map +1 -1
- package/dist/commands/start/server/runtime-env.d.ts +71 -0
- package/dist/commands/start/server/runtime-env.js +226 -0
- package/dist/commands/start/server/runtime-env.js.map +1 -0
- package/dist/commands/start/server/storage-service.d.ts +8 -0
- package/dist/commands/start/server/storage-service.js +156 -0
- package/dist/commands/start/server/storage-service.js.map +1 -0
- package/dist/commands/start/types.d.ts +3 -0
- package/dist/commands/start/utils.d.ts +34 -0
- package/dist/commands/start/utils.js +104 -0
- package/dist/commands/start/utils.js.map +1 -1
- package/dist/commands/storage/env.d.ts +5 -0
- package/dist/commands/storage/env.js +86 -0
- package/dist/commands/storage/env.js.map +1 -0
- package/dist/commands/storage/index.d.ts +26 -0
- package/dist/commands/storage/index.js +142 -0
- package/dist/commands/storage/index.js.map +1 -0
- package/dist/commands/storage/player.d.ts +5 -0
- package/dist/commands/storage/player.js +143 -0
- package/dist/commands/storage/player.js.map +1 -0
- package/dist/commands/storage/scene.d.ts +5 -0
- package/dist/commands/storage/scene.js +105 -0
- package/dist/commands/storage/scene.js.map +1 -0
- package/dist/commands/storage/shared.d.ts +62 -0
- package/dist/commands/storage/shared.js +249 -0
- package/dist/commands/storage/shared.js.map +1 -0
- package/dist/commands/storage/types.d.ts +56 -0
- package/dist/commands/storage/types.js +23 -0
- package/dist/commands/storage/types.js.map +1 -0
- package/dist/components/analytics.d.ts +70 -1
- package/dist/components/analytics.js +3 -2
- package/dist/components/analytics.js.map +1 -1
- package/dist/logic/auth-chain-headers.d.ts +11 -0
- package/dist/logic/auth-chain-headers.js +25 -0
- package/dist/logic/auth-chain-headers.js.map +1 -0
- package/dist/logic/bundle.js +47 -12
- package/dist/logic/bundle.js.map +1 -1
- package/dist/logic/config.d.ts +1 -0
- package/dist/logic/config.js +7 -0
- package/dist/logic/config.js.map +1 -1
- package/dist/logic/error.d.ts +1 -1
- package/dist/logic/error.js.map +1 -1
- package/dist/logic/exec.d.ts +1 -0
- package/dist/logic/exec.js +2 -2
- package/dist/logic/exec.js.map +1 -1
- package/dist/logic/lang.js +1 -0
- package/dist/logic/lang.js.map +1 -1
- package/dist/logic/scene-validations.d.ts +8 -1
- package/dist/logic/scene-validations.js.map +1 -1
- package/package.json +7 -7
|
@@ -26,6 +26,7 @@ export interface SceneInfo {
|
|
|
26
26
|
skipValidations: boolean;
|
|
27
27
|
isPortableExperience: boolean;
|
|
28
28
|
isWorld: boolean;
|
|
29
|
+
world?: string;
|
|
29
30
|
}
|
|
30
31
|
export declare function getSceneInfo(components: Pick<CliComponents, 'config'>, scene: Scene, rootCID: string, skipValidations: boolean): Promise<{
|
|
31
32
|
baseParcel: string;
|
|
@@ -39,4 +40,5 @@ export declare function getSceneInfo(components: Pick<CliComponents, 'config'>,
|
|
|
39
40
|
skipValidations: boolean;
|
|
40
41
|
isPortableExperience: boolean;
|
|
41
42
|
isWorld: boolean;
|
|
43
|
+
world: string | undefined;
|
|
42
44
|
}>;
|
|
@@ -135,7 +135,8 @@ async function getSceneInfo(components, scene, rootCID, skipValidations) {
|
|
|
135
135
|
description: display?.description,
|
|
136
136
|
skipValidations,
|
|
137
137
|
isPortableExperience: !!isPortableExperience,
|
|
138
|
-
isWorld: sceneHasWorldCfg(scene)
|
|
138
|
+
isWorld: sceneHasWorldCfg(scene),
|
|
139
|
+
world: scene.worldConfiguration?.name
|
|
139
140
|
};
|
|
140
141
|
}
|
|
141
142
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/commands/deploy/utils.ts"],"names":[],"mappings":";;AAqBA,kCA8CC;AAED,wDA8BC;AAuED,4CAEC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/commands/deploy/utils.ts"],"names":[],"mappings":";;AAqBA,kCA8CC;AAED,wDA8BC;AAuED,4CAEC;AAiBD,oCA0BC;AAvND,0CAA6C;AAE7C,6DAA8G;AAC9G,sFAA0F;AAC1F,4EAA6E;AAC7E,6CAAwC;AACxC,oDAAiD;AACjD,wCAA2C;AAK3C,qDAAoD;AACpD,iDAAkD;AAElD,+CAAuE;AACvE,yDAAmD;AACnD,qEAA2D;AAE3D,6CAAqD;AAE9C,KAAK,UAAU,WAAW,CAC/B,UAAmB,iBAAO,CAAC,gBAAgB,EAC3C,MAAe,EACf,aAAsB;IAEtB,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,QAAQ,GAAG,IAAA,0CAAoB,EAAC;YACpC,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM;YACxD,OAAO,EAAE,IAAA,sCAAoB,GAAE;SAChC,CAAC,CAAA;QAEF,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,gBAAgB,EAAE,CAAA;QACjD,MAAM,EACJ,OAAO,EAAE,EAAE,SAAS,EAAE,EACvB,GAAG,MAAM,QAAQ,CAAC,UAAU,EAAE,CAAA;QAE/B,OAAO,EAAE,MA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BAAgB,CAAC,KAAY;IAC3C,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC,MAAM,CAAA;AAC7D,CAAC;AAiBM,KAAK,UAAU,YAAY,CAChC,UAAyC,EACzC,KAAY,EACZ,OAAe,EACf,eAAwB;IAExB,MAAM,EACJ,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EACxB,OAAO,EACP,oBAAoB,EACrB,GAAG,KAAK,CAAA;IAET,OAAO;QACL,UAAU,EAAE,IAAI;QAChB,OAAO;QACP,OAAO;QACP,YAAY,EAAE,MAAM,IAAA,wBAAe,EAAC,UAAU,CAAC;QAC/C,cAAc,EAAE,MAAM,IAAA,0BAAiB,EAAC,UAAU,CAAC;QACnD,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK;QAC1B,KAAK,EAAE,OAAO,EAAE,KAAK;QACrB,WAAW,EAAE,OAAO,EAAE,WAAW;QACjC,eAAe;QACf,oBAAoB,EAAE,CAAC,CAAC,oBAAoB;QAC5C,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC;QAChC,KAAK,EAAE,KAAK,CAAC,kBAAkB,EAAE,IAAI;KACtC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Result } from 'arg';
|
|
2
|
+
import { CliComponents } from '../../components';
|
|
3
|
+
interface Options {
|
|
4
|
+
args: Result<typeof args>;
|
|
5
|
+
components: CliComponents;
|
|
6
|
+
}
|
|
7
|
+
export declare const args: {
|
|
8
|
+
'--help': BooleanConstructor;
|
|
9
|
+
'-h': string;
|
|
10
|
+
'--dir': StringConstructor;
|
|
11
|
+
'--target': StringConstructor;
|
|
12
|
+
'-t': string;
|
|
13
|
+
'--port': NumberConstructor;
|
|
14
|
+
'-p': string;
|
|
15
|
+
'--https': BooleanConstructor;
|
|
16
|
+
'--no-browser': BooleanConstructor;
|
|
17
|
+
'-b': string;
|
|
18
|
+
};
|
|
19
|
+
export declare function help(options: Options): void;
|
|
20
|
+
export declare function main(options: Options): Promise<void>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.args = void 0;
|
|
7
|
+
exports.help = help;
|
|
8
|
+
exports.main = main;
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const fp_future_1 = __importDefault(require("fp-future"));
|
|
11
|
+
const crypto_1 = require("@dcl/crypto");
|
|
12
|
+
const crypto_2 = require("@dcl/crypto/dist/crypto");
|
|
13
|
+
const eth_connect_1 = require("eth-connect");
|
|
14
|
+
const args_1 = require("../../logic/args");
|
|
15
|
+
const beautiful_logs_1 = require("../../logic/beautiful-logs");
|
|
16
|
+
const account_1 = require("../../logic/account");
|
|
17
|
+
const auth_chain_headers_1 = require("../../logic/auth-chain-headers");
|
|
18
|
+
const routes_1 = require("../../linker-dapp/routes");
|
|
19
|
+
const run_dapp_1 = require("../../run-dapp");
|
|
20
|
+
const workspace_validations_1 = require("../../logic/workspace-validations");
|
|
21
|
+
const scene_validations_1 = require("../../logic/scene-validations");
|
|
22
|
+
exports.args = (0, args_1.declareArgs)({
|
|
23
|
+
'--help': Boolean,
|
|
24
|
+
'-h': '--help',
|
|
25
|
+
'--dir': String,
|
|
26
|
+
'--target': String,
|
|
27
|
+
'-t': '--target',
|
|
28
|
+
'--port': Number,
|
|
29
|
+
'-p': '--port',
|
|
30
|
+
'--https': Boolean,
|
|
31
|
+
'--no-browser': Boolean,
|
|
32
|
+
'-b': '--no-browser'
|
|
33
|
+
});
|
|
34
|
+
const DEFAULT_SERVER = 'https://multiplayer-server.decentraland.org';
|
|
35
|
+
function help(options) {
|
|
36
|
+
options.components.logger.log(`
|
|
37
|
+
Usage: 'sdk-commands sdk-server-logs [options]'
|
|
38
|
+
Streams real-time logs from the multiplayer server for your scene.
|
|
39
|
+
The scene identifier is automatically determined from scene.json:
|
|
40
|
+
- Worlds: uses worldConfiguration.name
|
|
41
|
+
- Genesis city scenes: uses scene.base parcel
|
|
42
|
+
|
|
43
|
+
Options:
|
|
44
|
+
-h, --help Displays complete help
|
|
45
|
+
-t, --target [URL] Target multiplayer server URL (default: ${DEFAULT_SERVER})
|
|
46
|
+
--dir [path] Path to the project directory
|
|
47
|
+
-p, --port [port] Select a custom port for the linker dApp
|
|
48
|
+
-b, --no-browser Do not open a new browser window
|
|
49
|
+
--https Use HTTPS for the linker dApp
|
|
50
|
+
|
|
51
|
+
Examples:
|
|
52
|
+
- View logs for your scene (run from project directory):
|
|
53
|
+
$ sdk-commands sdk-server-logs
|
|
54
|
+
|
|
55
|
+
- Connect to local development server:
|
|
56
|
+
$ sdk-commands sdk-server-logs --target http://localhost:8000
|
|
57
|
+
|
|
58
|
+
- Use private key for authentication (no browser):
|
|
59
|
+
$ DCL_PRIVATE_KEY=0x... sdk-commands sdk-server-logs
|
|
60
|
+
`);
|
|
61
|
+
}
|
|
62
|
+
function setServerLogsRoutes(router, components, awaitResponse, signCallback) {
|
|
63
|
+
const { logger } = components;
|
|
64
|
+
const resolveLinkerPromise = () => setTimeout(() => awaitResponse.resolve(), 100);
|
|
65
|
+
const rejectLinkerPromise = (e) => setTimeout(() => awaitResponse.reject(e), 100);
|
|
66
|
+
router.post('/api/logs', async (ctx) => {
|
|
67
|
+
const value = (await ctx.request.json());
|
|
68
|
+
if (!value.address || !value.authChain) {
|
|
69
|
+
const errorMessage = `Invalid payload: ${Object.keys(value).join(' - ')}`;
|
|
70
|
+
logger.error(errorMessage);
|
|
71
|
+
resolveLinkerPromise();
|
|
72
|
+
return { status: 400, body: { success: false, error: errorMessage } };
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
await signCallback(value);
|
|
76
|
+
resolveLinkerPromise();
|
|
77
|
+
return { body: { success: true } };
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
rejectLinkerPromise(e);
|
|
81
|
+
return { status: 400, body: { success: false, error: e.message } };
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return router;
|
|
85
|
+
}
|
|
86
|
+
async function getAddressAndSignature(components, awaitResponse, payload, sceneIdentifier, targetUrl, linkOptions, signCallback) {
|
|
87
|
+
// If DCL_PRIVATE_KEY is set, sign directly without the linker dapp
|
|
88
|
+
if (process.env.DCL_PRIVATE_KEY) {
|
|
89
|
+
const wallet = (0, account_1.createWallet)(process.env.DCL_PRIVATE_KEY);
|
|
90
|
+
const authChain = crypto_1.Authenticator.createSimpleAuthChain(payload, wallet.address, (0, crypto_2.ethSign)((0, eth_connect_1.hexToBytes)(wallet.privateKey), payload));
|
|
91
|
+
const linkerResponse = { authChain, address: wallet.address };
|
|
92
|
+
await signCallback(linkerResponse);
|
|
93
|
+
awaitResponse.resolve();
|
|
94
|
+
return {};
|
|
95
|
+
}
|
|
96
|
+
// Use linker dapp for signing - pass the payload as the rootCID
|
|
97
|
+
const { router: commonRouter } = (0, routes_1.setRoutes)(components, {
|
|
98
|
+
rootCID: payload,
|
|
99
|
+
baseParcel: '0,0',
|
|
100
|
+
parcels: ['0,0'],
|
|
101
|
+
skipValidations: true,
|
|
102
|
+
debug: !!process.env.DEBUG,
|
|
103
|
+
isWorld: true,
|
|
104
|
+
world: sceneIdentifier,
|
|
105
|
+
targetUrl,
|
|
106
|
+
action: 'view-logs'
|
|
107
|
+
});
|
|
108
|
+
const router = setServerLogsRoutes(commonRouter, components, awaitResponse, signCallback);
|
|
109
|
+
components.logger.info('You need to sign to access server logs');
|
|
110
|
+
const { program } = await (0, run_dapp_1.runDapp)(components, router, { ...linkOptions, uri: `/` });
|
|
111
|
+
return { program };
|
|
112
|
+
}
|
|
113
|
+
async function streamLogs(components, logsUrl, authHeaders) {
|
|
114
|
+
const { logger, fetch: fetchComponent } = components;
|
|
115
|
+
logger.info('\nConnecting to server logs...');
|
|
116
|
+
try {
|
|
117
|
+
const response = await fetchComponent.fetch(logsUrl, {
|
|
118
|
+
method: 'GET',
|
|
119
|
+
headers: {
|
|
120
|
+
...authHeaders,
|
|
121
|
+
Accept: 'text/event-stream'
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
if (!response.ok) {
|
|
125
|
+
const errorText = await response.text();
|
|
126
|
+
throw new Error(`Server returned ${response.status}: ${errorText}`);
|
|
127
|
+
}
|
|
128
|
+
const contentType = response.headers.get('content-type') || '';
|
|
129
|
+
if (!contentType.includes('text/event-stream') && !contentType.includes('application/stream')) {
|
|
130
|
+
throw new Error('Server does not support SSE streaming');
|
|
131
|
+
}
|
|
132
|
+
logger.info('Streaming logs in real-time (press CTRL+C to stop)');
|
|
133
|
+
if (response.body) {
|
|
134
|
+
const decoder = new TextDecoder();
|
|
135
|
+
let buffer = '';
|
|
136
|
+
for await (const chunk of response.body) {
|
|
137
|
+
buffer += decoder.decode(chunk, { stream: true });
|
|
138
|
+
const lines = buffer.split('\n');
|
|
139
|
+
buffer = lines.pop() || '';
|
|
140
|
+
for (const line of lines) {
|
|
141
|
+
if (line.trim()) {
|
|
142
|
+
formatAndPrintLog(logger, line);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
logger.info('\n======================= End Scene Logs =======================');
|
|
148
|
+
}
|
|
149
|
+
catch (e) {
|
|
150
|
+
(0, beautiful_logs_1.printError)(logger, 'Failed to stream logs:', e);
|
|
151
|
+
process.exit(1);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function formatAndPrintLog(logger, log) {
|
|
155
|
+
// If log is a string, try to parse as JSON
|
|
156
|
+
let logObj = log;
|
|
157
|
+
if (typeof log === 'string') {
|
|
158
|
+
try {
|
|
159
|
+
logObj = JSON.parse(log);
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
// If not JSON, just print the string
|
|
163
|
+
logger.log(log);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// Extract common log fields
|
|
168
|
+
const timestamp = logObj.timestamp || logObj.time || new Date().toISOString();
|
|
169
|
+
const level = (logObj.level || logObj.severity || 'INFO').toUpperCase();
|
|
170
|
+
const message = logObj.message || logObj.msg || JSON.stringify(logObj);
|
|
171
|
+
// Format timestamp
|
|
172
|
+
const date = new Date(timestamp);
|
|
173
|
+
const formattedTime = date.toISOString().replace('T', ' ').substring(0, 19);
|
|
174
|
+
// Format the log message with timestamp
|
|
175
|
+
const formattedMessage = `[${formattedTime}] [${level}] ${message}`;
|
|
176
|
+
// Map log levels to logger methods
|
|
177
|
+
const normalizedLevel = level.toLowerCase();
|
|
178
|
+
switch (normalizedLevel) {
|
|
179
|
+
case 'error':
|
|
180
|
+
logger.error(formattedMessage);
|
|
181
|
+
break;
|
|
182
|
+
case 'warn':
|
|
183
|
+
case 'warning':
|
|
184
|
+
logger.warn(formattedMessage);
|
|
185
|
+
break;
|
|
186
|
+
case 'debug':
|
|
187
|
+
logger.debug(formattedMessage);
|
|
188
|
+
break;
|
|
189
|
+
case 'info':
|
|
190
|
+
case 'trace':
|
|
191
|
+
default:
|
|
192
|
+
logger.info(formattedMessage);
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
// If there are additional fields, print them
|
|
196
|
+
const additionalFields = Object.keys(logObj).filter((key) => !['timestamp', 'time', 'level', 'severity', 'message', 'msg'].includes(key));
|
|
197
|
+
if (additionalFields.length > 0) {
|
|
198
|
+
const additional = {};
|
|
199
|
+
additionalFields.forEach((key) => {
|
|
200
|
+
additional[key] = logObj[key];
|
|
201
|
+
});
|
|
202
|
+
logger.log(` ${JSON.stringify(additional)}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
async function main(options) {
|
|
206
|
+
const { logger } = options.components;
|
|
207
|
+
const projectRoot = (0, path_1.resolve)(process.cwd(), options.args['--dir'] || '.');
|
|
208
|
+
// Validate workspace exists
|
|
209
|
+
await (0, workspace_validations_1.getValidWorkspace)(options.components, projectRoot);
|
|
210
|
+
const sceneJson = await (0, scene_validations_1.getValidSceneJson)(options.components, projectRoot);
|
|
211
|
+
const worldName = sceneJson.worldConfiguration?.name;
|
|
212
|
+
const isWorld = !!worldName;
|
|
213
|
+
const sceneIdentifier = isWorld ? worldName : sceneJson.scene.base;
|
|
214
|
+
// Determine target URL
|
|
215
|
+
const baseURL = options.args['--target'] || DEFAULT_SERVER;
|
|
216
|
+
// Build the logs URL
|
|
217
|
+
const logsUrl = `${baseURL}/logs`;
|
|
218
|
+
logger.info(`Viewing logs for ${isWorld ? 'world' : 'scene'}: ${sceneIdentifier}`);
|
|
219
|
+
logger.info(`Target: ${logsUrl}`);
|
|
220
|
+
// Build the pathname for signing
|
|
221
|
+
const pathname = '/logs';
|
|
222
|
+
// Linker dApp options
|
|
223
|
+
const linkerPort = options.args['--port'];
|
|
224
|
+
const openBrowser = !options.args['--no-browser'];
|
|
225
|
+
const isHttps = !!options.args['--https'];
|
|
226
|
+
const linkOptions = { linkerPort, openBrowser, isHttps };
|
|
227
|
+
const awaitResponse = (0, fp_future_1.default)();
|
|
228
|
+
const timestamp = String(Date.now());
|
|
229
|
+
// Build metadata following the standard signedFetch format
|
|
230
|
+
const metadata = JSON.stringify({
|
|
231
|
+
parcel: sceneJson.scene.base,
|
|
232
|
+
realm: { serverName: isWorld ? worldName : 'main' },
|
|
233
|
+
realmName: isWorld ? worldName : 'main',
|
|
234
|
+
sceneId: isWorld ? worldName : undefined
|
|
235
|
+
});
|
|
236
|
+
// Build the payload to sign: method:path:timestamp:metadata
|
|
237
|
+
const payload = ['get', pathname, timestamp, metadata].join(':').toLowerCase();
|
|
238
|
+
let authHeaders = {};
|
|
239
|
+
const { program } = await getAddressAndSignature(options.components, awaitResponse, payload, sceneIdentifier, baseURL, linkOptions, async (linkerResponse) => {
|
|
240
|
+
authHeaders = (0, auth_chain_headers_1.createAuthChainHeaders)(linkerResponse.authChain, timestamp, metadata);
|
|
241
|
+
});
|
|
242
|
+
try {
|
|
243
|
+
await awaitResponse;
|
|
244
|
+
logger.info('Authentication successful!');
|
|
245
|
+
// Close the browser window
|
|
246
|
+
if (program) {
|
|
247
|
+
await program.stop();
|
|
248
|
+
}
|
|
249
|
+
// Start streaming logs
|
|
250
|
+
await streamLogs(options.components, logsUrl, authHeaders);
|
|
251
|
+
}
|
|
252
|
+
catch (e) {
|
|
253
|
+
(0, beautiful_logs_1.printError)(logger, 'Failed to authenticate:', e);
|
|
254
|
+
throw e;
|
|
255
|
+
}
|
|
256
|
+
finally {
|
|
257
|
+
if (program) {
|
|
258
|
+
void program.stop();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/sdk-server-logs/index.ts"],"names":[],"mappings":";;;;;;AAuCA,oBA0BC;AAgMD,oBA4EC;AA7UD,+BAA8B;AAE9B,0DAA2C;AAC3C,wCAA2C;AAC3C,oDAAiD;AACjD,6CAAwC;AAIxC,2CAA8C;AAE9C,+DAAuD;AACvD,iDAAkD;AAClD,uEAAuE;AACvE,qDAAoE;AACpE,6CAAqD;AACrD,6EAAqE;AACrE,qEAAiE;AAOpD,QAAA,IAAI,GAAG,IAAA,kBAAW,EAAC;IAC9B,QAAQ,EAAE,OAAO;IACjB,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,MAAM;IACf,UAAU,EAAE,MAAM;IAClB,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,OAAO;IAClB,cAAc,EAAE,OAAO;IACvB,IAAI,EAAE,cAAc;CACrB,CAAC,CAAA;AAEF,MAAM,cAAc,GAAG,6CAA6C,CAAA;AAEpE,SAAgB,IAA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D;IAC5D,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAA;IAE9E,IAAI,WAAW,GAA2B,EAAE,CAAA;IAE5C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,sBAAsB,CAC9C,OAAO,CAAC,UAAU,EAClB,aAAa,EACb,OAAO,EACP,eAAe,EACf,OAAO,EACP,WAAW,EACX,KAAK,EAAE,cAAc,EAAE,EAAE;QACvB,WAAW,GAAG,IAAA,2CAAsB,EAAC,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA;IACrF,CAAC,CACF,CAAA;IAED,IAAI,CAAC;QACH,MAAM,aAAa,CAAA;QACnB,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAA;QAEzC,2BAA2B;QAC3B,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,OAAO,CAAC,IAAI,EAAE,CAAA;QACtB,CAAC;QAED,uBAAuB;QACvB,MAAM,UAAU,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,EAAE,WAAW,CAAC,CAAA;IAC5D,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAA,2BAAU,EAAC,MAAM,EAAE,yBAAyB,EAAE,CAAU,CAAC,CAAA;QACzD,MAAM,CAAC,CAAA;IACT,CAAC;YAAS,CAAC;QACT,IAAI,OAAO,EAAE,CAAC;YACZ,KAAK,OAAO,CAAC,IAAI,EAAE,CAAA;QACrB,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ChildProcess } from 'child_process';
|
|
2
|
+
import { CliComponents } from '../../components';
|
|
3
|
+
import { PreviewComponents } from './types';
|
|
4
|
+
import { ProjectUnion } from '../../logic/project-validations';
|
|
5
|
+
/**
|
|
6
|
+
* Starts the Multiplayer Server process using npx to install and run in one step
|
|
7
|
+
*/
|
|
8
|
+
export declare function startHammurabiServer(components: Pick<CliComponents, 'logger'>, workingDir: string, realm: string): ChildProcess;
|
|
9
|
+
/**
|
|
10
|
+
* Spawns the multiplayer server for the project.
|
|
11
|
+
* In the auth-server SDK, all scenes are authoritative multiplayer.
|
|
12
|
+
* Uses npx to handle installation and execution in a single step (works in Electron).
|
|
13
|
+
*
|
|
14
|
+
* @param components - Preview components including logger
|
|
15
|
+
* @param project - The project to start the multiplayer server for
|
|
16
|
+
* @param realm - The realm URL to pass to the hammurabi server
|
|
17
|
+
* @returns The ChildProcess if started, undefined otherwise
|
|
18
|
+
*/
|
|
19
|
+
export declare function spawnAuthServer(components: PreviewComponents, project: ProjectUnion, realm: string): ChildProcess | undefined;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.startHammurabiServer = startHammurabiServer;
|
|
4
|
+
exports.spawnAuthServer = spawnAuthServer;
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const beautiful_logs_1 = require("../../logic/beautiful-logs");
|
|
7
|
+
const log_1 = require("../../components/log");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
|
+
const HAMMURABI_PACKAGE = '@dcl/hammurabi-server';
|
|
10
|
+
const HAMMURABI_VERSION = 'next';
|
|
11
|
+
/**
|
|
12
|
+
* Registers cleanup handlers on the global process object
|
|
13
|
+
* Returns a function to remove the handlers
|
|
14
|
+
*/
|
|
15
|
+
function registerProcessCleanup(cleanup) {
|
|
16
|
+
process.on('SIGTERM', cleanup);
|
|
17
|
+
process.on('SIGINT', cleanup);
|
|
18
|
+
process.on('exit', cleanup);
|
|
19
|
+
return () => {
|
|
20
|
+
process.off('SIGTERM', cleanup);
|
|
21
|
+
process.off('SIGINT', cleanup);
|
|
22
|
+
process.off('exit', cleanup);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Starts the Multiplayer Server process using npx to install and run in one step
|
|
27
|
+
*/
|
|
28
|
+
function startHammurabiServer(components, workingDir, realm) {
|
|
29
|
+
(0, beautiful_logs_1.printProgressInfo)(components.logger, `Starting ${log_1.colors.bold('Multiplayer Server')} with realm: ${log_1.colors.bold(realm)}`);
|
|
30
|
+
const npxArgs = ['--yes', `${HAMMURABI_PACKAGE}@${HAMMURABI_VERSION}`, `--realm=${realm}`];
|
|
31
|
+
const npxCliJs = (0, utils_1.findNpxCliJs)();
|
|
32
|
+
// In Electron, override npm_config_prefix because npm derives its prefix from process.execPath,
|
|
33
|
+
// which points to the Electron Helper binary. This causes npm to look for a `lib/` directory
|
|
34
|
+
// inside the Helper bundle, which doesn't exist (ENOENT).
|
|
35
|
+
const env = (0, utils_1.isElectronEnvironment)() ? { ...(0, utils_1.getSpawnEnv)(), npm_config_prefix: workingDir } : (0, utils_1.getSpawnEnv)();
|
|
36
|
+
// If npx-cli.js was found, run it directly via process.execPath (node in regular env,
|
|
37
|
+
// Electron Helper with ELECTRON_RUN_AS_NODE=1 in Electron). Otherwise fall back to npx binary.
|
|
38
|
+
const hammurabiProcess = npxCliJs
|
|
39
|
+
? (0, child_process_1.spawn)(process.execPath, [npxCliJs, ...npxArgs], { cwd: workingDir, shell: false, stdio: 'inherit', env })
|
|
40
|
+
: (0, child_process_1.spawn)((0, utils_1.getNpxBin)(), npxArgs, { cwd: workingDir, shell: false, stdio: 'inherit', env });
|
|
41
|
+
hammurabiProcess.on('error', (error) => {
|
|
42
|
+
(0, beautiful_logs_1.printWarning)(components.logger, `Multiplayer Server process error: ${error.message}`);
|
|
43
|
+
});
|
|
44
|
+
// Register cleanup handlers
|
|
45
|
+
const cleanup = () => {
|
|
46
|
+
if (!hammurabiProcess.killed) {
|
|
47
|
+
hammurabiProcess.kill('SIGTERM');
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const removeCleanup = registerProcessCleanup(cleanup);
|
|
51
|
+
hammurabiProcess.on('close', (code) => {
|
|
52
|
+
removeCleanup();
|
|
53
|
+
if (code !== 0 && code !== null) {
|
|
54
|
+
(0, beautiful_logs_1.printWarning)(components.logger, `Multiplayer Server exited with code ${code}`);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return hammurabiProcess;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Spawns the multiplayer server for the project.
|
|
61
|
+
* In the auth-server SDK, all scenes are authoritative multiplayer.
|
|
62
|
+
* Uses npx to handle installation and execution in a single step (works in Electron).
|
|
63
|
+
*
|
|
64
|
+
* @param components - Preview components including logger
|
|
65
|
+
* @param project - The project to start the multiplayer server for
|
|
66
|
+
* @param realm - The realm URL to pass to the hammurabi server
|
|
67
|
+
* @returns The ChildProcess if started, undefined otherwise
|
|
68
|
+
*/
|
|
69
|
+
function spawnAuthServer(components, project, realm) {
|
|
70
|
+
try {
|
|
71
|
+
return startHammurabiServer(components, project.workingDirectory, realm);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
(0, beautiful_logs_1.printWarning)(components.logger, `Failed to start Multiplayer Server: ${error.message}`);
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=hammurabi-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hammurabi-server.js","sourceRoot":"","sources":["../../../src/commands/start/hammurabi-server.ts"],"names":[],"mappings":";;AA8BA,oDA6CC;AAYD,0CAWC;AAlGD,iDAAmD;AAEnD,+DAA4E;AAC5E,8CAA6C;AAG7C,mCAAqF;AAErF,MAAM,iBAAiB,GAAG,uBAAuB,CAAA;AACjD,MAAM,iBAAiB,GAAG,MAAM,CAAA;AAEhC;;;GAGG;AACH,SAAS,sBAAsB,CAAC,OAAmB;IACjD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IAC9B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CA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
@@ -21,7 +21,6 @@ export declare const args: {
|
|
|
21
21
|
'-w': string;
|
|
22
22
|
'--skip-build': BooleanConstructor;
|
|
23
23
|
'--data-layer': BooleanConstructor;
|
|
24
|
-
'--customEntryPoint': BooleanConstructor;
|
|
25
24
|
'--explorer-alpha': BooleanConstructor;
|
|
26
25
|
'--web-explorer': BooleanConstructor;
|
|
27
26
|
'--hub': BooleanConstructor;
|
|
@@ -36,6 +35,7 @@ export declare const args: {
|
|
|
36
35
|
'--landscape-terrain-enabled': BooleanConstructor;
|
|
37
36
|
'-n': BooleanConstructor;
|
|
38
37
|
'--bevy-web': BooleanConstructor;
|
|
38
|
+
'--no-client': BooleanConstructor;
|
|
39
39
|
};
|
|
40
40
|
export declare function help(options: Options): Promise<void>;
|
|
41
41
|
export declare function main(options: Options): Promise<void>;
|
|
@@ -66,6 +66,7 @@ const beautiful_logs_1 = require("../../logic/beautiful-logs");
|
|
|
66
66
|
const project_validations_1 = require("../../logic/project-validations");
|
|
67
67
|
const explorer_alpha_1 = require("./explorer-alpha");
|
|
68
68
|
const utils_1 = require("./utils");
|
|
69
|
+
const hammurabi_server_1 = require("./hammurabi-server");
|
|
69
70
|
exports.args = (0, args_1.declareArgs)({
|
|
70
71
|
'--dir': String,
|
|
71
72
|
'--help': Boolean,
|
|
@@ -83,7 +84,6 @@ exports.args = (0, args_1.declareArgs)({
|
|
|
83
84
|
'-w': '--no-watch',
|
|
84
85
|
'--skip-build': Boolean,
|
|
85
86
|
'--data-layer': Boolean,
|
|
86
|
-
'--customEntryPoint': Boolean,
|
|
87
87
|
'--explorer-alpha': Boolean,
|
|
88
88
|
'--web-explorer': Boolean,
|
|
89
89
|
'--hub': Boolean,
|
|
@@ -98,7 +98,8 @@ exports.args = (0, args_1.declareArgs)({
|
|
|
98
98
|
'--skip-auth-screen': Boolean,
|
|
99
99
|
'--landscape-terrain-enabled': Boolean,
|
|
100
100
|
'-n': Boolean,
|
|
101
|
-
'--bevy-web': Boolean
|
|
101
|
+
'--bevy-web': Boolean,
|
|
102
|
+
'--no-client': Boolean
|
|
102
103
|
});
|
|
103
104
|
async function help(options) {
|
|
104
105
|
options.components.logger.log(`
|
|
@@ -123,8 +124,8 @@ async function help(options) {
|
|
|
123
124
|
--skip-auth-screen Skip the auth screen (accepts 'true' or 'false').
|
|
124
125
|
--landscape-terrain-enabled Enable landscape terrain.
|
|
125
126
|
-n Open a new instance of the Client even if one is already running.
|
|
126
|
-
--bevy-web Opens preview using the Bevy Web browser window
|
|
127
|
-
--mobile
|
|
127
|
+
--bevy-web Opens preview using the Bevy Web browser window.
|
|
128
|
+
--mobile Show QR code for mobile preview on the same network
|
|
128
129
|
|
|
129
130
|
|
|
130
131
|
Examples:
|
|
@@ -149,10 +150,10 @@ async function main(options) {
|
|
|
149
150
|
const withDataLayer = options.args['--data-layer'];
|
|
150
151
|
const enableWeb3 = options.args['--web3'];
|
|
151
152
|
const isHub = !!options.args['--hub'];
|
|
152
|
-
|
|
153
|
-
const bevyWeb =
|
|
154
|
-
const isMobile =
|
|
155
|
-
const explorerAlpha = !options.args['--web-explorer'] && !bevyWeb;
|
|
153
|
+
const skipClient = !!options.args['--no-client'];
|
|
154
|
+
const bevyWeb = !!options.args['--bevy-web'] && !skipClient;
|
|
155
|
+
const isMobile = options.args['--mobile'] && !skipClient;
|
|
156
|
+
const explorerAlpha = !options.args['--web-explorer'] && !bevyWeb && !skipClient;
|
|
156
157
|
let hasSmartWearable = false;
|
|
157
158
|
const workspace = await (0, workspace_validations_1.getValidWorkspace)(options.components, workingDirectory);
|
|
158
159
|
/* istanbul ignore if */
|
|
@@ -166,15 +167,7 @@ async function main(options) {
|
|
|
166
167
|
// first run `npm run build`, this can be disabled with --skip-build
|
|
167
168
|
// then start the embedded compiler, this can be disabled with --no-watch
|
|
168
169
|
if (watch || build) {
|
|
169
|
-
await (0, build_1.buildScene)({
|
|
170
|
-
...options,
|
|
171
|
-
args: {
|
|
172
|
-
'--dir': project.workingDirectory,
|
|
173
|
-
'--watch': watch,
|
|
174
|
-
_: [],
|
|
175
|
-
'--customEntryPoint': !!options.args['--customEntryPoint']
|
|
176
|
-
}
|
|
177
|
-
}, project);
|
|
170
|
+
await (0, build_1.buildScene)({ ...options, args: { '--dir': project.workingDirectory, '--watch': watch, _: [] } }, project);
|
|
178
171
|
await (0, project_validations_1.startValidations)(options.components, project.workingDirectory);
|
|
179
172
|
}
|
|
180
173
|
// track the event
|
|
@@ -237,6 +230,22 @@ async function main(options) {
|
|
|
237
230
|
}
|
|
238
231
|
}
|
|
239
232
|
await startComponents();
|
|
233
|
+
// Start Hammurabi server if needed (stored outside components to avoid lifecycle management)
|
|
234
|
+
let hammurabiServer;
|
|
235
|
+
const project = workspace.projects[0];
|
|
236
|
+
if (project) {
|
|
237
|
+
const realm = `http://localhost:${port}`;
|
|
238
|
+
hammurabiServer = (0, hammurabi_server_1.spawnAuthServer)(components, project, realm);
|
|
239
|
+
// Register cleanup handler for hammurabi server
|
|
240
|
+
if (hammurabiServer) {
|
|
241
|
+
const cleanup = () => {
|
|
242
|
+
if (hammurabiServer && !hammurabiServer.killed) {
|
|
243
|
+
hammurabiServer.kill('SIGTERM');
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
components.signaler.programClosed.then(cleanup).catch(() => { });
|
|
247
|
+
}
|
|
248
|
+
}
|
|
240
249
|
const networkInterfaces = os.networkInterfaces();
|
|
241
250
|
const availableURLs = [];
|
|
242
251
|
(0, beautiful_logs_1.printProgressInfo)(options.components.logger, 'Preview server is now running!');
|
|
@@ -248,15 +257,14 @@ async function main(options) {
|
|
|
248
257
|
(networkInterfaces[dev] || []).forEach((details) => {
|
|
249
258
|
if (details.family === 'IPv4') {
|
|
250
259
|
const oldBackpack = 'DISABLE_backpack_editor_v2=&ENABLE_backpack_editor_v1';
|
|
251
|
-
|
|
252
|
-
let url = `${baseUrl}?position=${baseCoords.x}%2C${baseCoords.y}&${oldBackpack}`;
|
|
260
|
+
let addr = `http://${details.address}:${port}?position=${baseCoords.x}%2C${baseCoords.y}&${oldBackpack}`;
|
|
253
261
|
if (debug) {
|
|
254
|
-
|
|
262
|
+
addr = `${addr}&SCENE_DEBUG_PANEL`;
|
|
255
263
|
}
|
|
256
264
|
if (enableWeb3 || hasSmartWearable) {
|
|
257
|
-
|
|
265
|
+
addr = `${addr}&ENABLE_WEB3`;
|
|
258
266
|
}
|
|
259
|
-
availableURLs.push(
|
|
267
|
+
availableURLs.push(addr);
|
|
260
268
|
}
|
|
261
269
|
});
|
|
262
270
|
});
|
|
@@ -264,29 +272,26 @@ async function main(options) {
|
|
|
264
272
|
const lanUrl = (0, utils_1.getLanUrl)(port);
|
|
265
273
|
// Push localhost and 127.0.0.1 at top
|
|
266
274
|
const sortedURLs = availableURLs.sort((a, _b) => {
|
|
267
|
-
return a.
|
|
268
|
-
? -1
|
|
269
|
-
: 1;
|
|
275
|
+
return a.toLowerCase().includes('localhost') || a.includes('127.0.0.1') || a.includes('0.0.0.0') ? -1 : 1;
|
|
270
276
|
});
|
|
271
|
-
const bevyUrl = `https://decentraland.zone/bevy-web/?preview=true&realm=${sortedURLs[0].
|
|
277
|
+
const bevyUrl = `https://decentraland.zone/bevy-web/?preview=true&realm=${new URL(sortedURLs[0]).origin}&position=${baseCoords.x},${baseCoords.y}`;
|
|
272
278
|
if (!explorerAlpha) {
|
|
273
279
|
if (bevyWeb) {
|
|
274
280
|
components.logger.log(` ${bevyUrl}`);
|
|
275
281
|
}
|
|
276
282
|
else {
|
|
277
283
|
for (const addr of sortedURLs) {
|
|
278
|
-
components.logger.log(` ${addr
|
|
284
|
+
components.logger.log(` ${addr}`);
|
|
279
285
|
}
|
|
280
286
|
}
|
|
281
287
|
}
|
|
282
288
|
components.logger.log('\nPress CTRL+C to exit\n');
|
|
283
|
-
// Open preferably localhost/127.0.0.1
|
|
284
289
|
if (explorerAlpha && !isMobile) {
|
|
285
|
-
const realm = new URL(sortedURLs[0]
|
|
290
|
+
const realm = new URL(sortedURLs[0]).origin;
|
|
286
291
|
await (0, explorer_alpha_1.runExplorerAlpha)(components, { cwd: workingDirectory, realm, baseCoords, isHub, args: options.args });
|
|
287
292
|
}
|
|
288
|
-
if (
|
|
289
|
-
const deepLink = `decentraland://open?preview=${lanUrl}&position=${baseCoords.x}
|
|
293
|
+
if (options.args['--mobile'] && lanUrl) {
|
|
294
|
+
const deepLink = `decentraland://open?preview=${lanUrl}&position=${baseCoords.x},${baseCoords.y}`;
|
|
290
295
|
qrcode_1.default.toString(deepLink, { type: 'terminal', small: true }, (err, qr) => {
|
|
291
296
|
if (!err) {
|
|
292
297
|
components.logger.log(log_1.colors.bold('\nScan to preview on mobile: \n'));
|
|
@@ -298,7 +303,7 @@ async function main(options) {
|
|
|
298
303
|
// Open preferably localhost/127.0.0.1
|
|
299
304
|
if ((!explorerAlpha || bevyWeb) && openBrowser && sortedURLs.length) {
|
|
300
305
|
try {
|
|
301
|
-
const url = bevyWeb ? bevyUrl : sortedURLs[0]
|
|
306
|
+
const url = bevyWeb ? bevyUrl : sortedURLs[0];
|
|
302
307
|
await (0, open_1.default)(url);
|
|
303
308
|
}
|
|
304
309
|
catch (_) {
|