@dcl/sdk-commands 7.1.4-4495128859.commit-9f954df → 7.1.4-4502579506.commit-4147243

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.
@@ -60,7 +60,6 @@ async function main(options) {
60
60
  const openBrowser = !options.args['--no-browser'];
61
61
  const skipBuild = options.args['--skip-build'];
62
62
  const linkerPort = options.args['--port'];
63
- const { error } = options.components.logger;
64
63
  if (options.args['--target'] && options.args['--target-content']) {
65
64
  throw new error_1.CliError(`You can't set both the 'target' and 'target-content' arguments.`);
66
65
  }
@@ -115,8 +114,8 @@ async function main(options) {
115
114
  (0, beautiful_logs_1.printSuccess)(options.components.logger, 'Content uploaded', sceneUrl);
116
115
  }
117
116
  catch (e) {
118
- error('Could not upload content:');
119
- console.log(e.message);
117
+ options.components.logger.error('Could not upload content:');
118
+ options.components.logger.error(e);
120
119
  options.components.analytics.trackSync('Scene deploy failure', { ...trackProps, error: e.message ?? '' });
121
120
  }
122
121
  options.components.analytics.trackSync('Scene deploy success', { ...trackProps, dependencies });
@@ -42,7 +42,6 @@ function runLinkerApp(cliComponents, scene, files, port, rootCID, { isHttps, ski
42
42
  components.server.setContext(components);
43
43
  components.server.use(router.allowedMethods());
44
44
  components.server.use(router.middleware());
45
- console.log('\x1Bc');
46
45
  await startComponents();
47
46
  if (openBrowser)
48
47
  await browse(cliComponents, url, queryParams);
@@ -16,5 +16,5 @@ export declare function fetchEntityByPointer({ fetch }: Pick<CliComponents, 'fet
16
16
  baseUrl: string;
17
17
  deployments: Entity[];
18
18
  }>;
19
- export declare function getPointers(components: Pick<CliComponents, 'fetch'>, pointer: string, network?: Network): Promise<CatalystInfo[]>;
19
+ export declare function getPointers(components: Pick<CliComponents, 'fetch' | 'logger'>, pointer: string, network?: Network): Promise<CatalystInfo[]>;
20
20
  export {};
@@ -37,7 +37,7 @@ async function getPointers(components, pointer, network = 'mainnet') {
37
37
  catalystInfo.push({ timestamp, entityId, url: baseUrl });
38
38
  }
39
39
  catch (err) {
40
- console.log('Error fetching catalyst pointers', err);
40
+ components.logger.log('Error fetching catalyst pointers', err);
41
41
  }
42
42
  }
43
43
  return catalystInfo;
@@ -1,3 +1,4 @@
1
1
  import { WebSocket } from 'ws';
2
+ import { PreviewComponents } from '../types';
2
3
  import { DataLayer } from './rpc';
3
- export declare function handleDataLayerWs(ws: WebSocket, dataLayer: DataLayer): Promise<void>;
4
+ export declare function handleDataLayerWs(components: PreviewComponents, ws: WebSocket, dataLayer: DataLayer): Promise<void>;
@@ -2,15 +2,16 @@
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
- async function handleDataLayerWs(ws, dataLayer) {
5
+ // TODO: dataLayer should be an optional component
6
+ async function handleDataLayerWs(components, ws, dataLayer) {
6
7
  const wsTransport = (0, WebSocket_1.WebSocketTransport)(ws);
7
8
  dataLayer.rpcServer.attachTransport(wsTransport, dataLayer.context);
8
9
  ws.on('error', (error) => {
9
- console.error(error);
10
+ components.logger.error(error);
10
11
  ws.close();
11
12
  });
12
13
  ws.on('close', () => {
13
- console.debug('Websocket closed');
14
+ components.logger.debug('Websocket closed');
14
15
  });
15
16
  }
16
17
  exports.handleDataLayerWs = handleDataLayerWs;
@@ -150,7 +150,7 @@ async function main(options) {
150
150
  };
151
151
  return {
152
152
  ...options.components,
153
- logger: (0, log_1.createStdoutCliLogger)(),
153
+ logger: (0, log_1.createStderrCliLogger)(),
154
154
  logs,
155
155
  ethereumProvider: eth_1.providerInstance,
156
156
  rooms,
@@ -162,6 +162,7 @@ async function main(options) {
162
162
  };
163
163
  },
164
164
  async main({ components, startComponents }) {
165
+ // TODO: dataLayerRpc should be an optional component
165
166
  const dataLayerRpc = withDataLayer ? await (0, rpc_1.createDataLayer)({ fs: components.fs }) : undefined;
166
167
  await (0, routes_1.wireRouter)(components, projectRoot, dataLayerRpc);
167
168
  if (watch) {
@@ -103,7 +103,8 @@ function setupEcs6Endpoints(components, dir, router) {
103
103
  }
104
104
  }
105
105
  catch (err) {
106
- console.warn(`Failed to catch profile and fill with preview wearables.`, err);
106
+ components.logger.warn(`Failed to catch profile and fill with preview wearables.`);
107
+ components.logger.error(err);
107
108
  }
108
109
  return next();
109
110
  });
@@ -130,7 +131,6 @@ function setupEcs6Endpoints(components, dir, router) {
130
131
  router.post('/content/entities', async (ctx) => {
131
132
  const catalystUrl = getCatalystUrl();
132
133
  const headers = new node_fetch_1.Headers();
133
- console.log(ctx.request.headers);
134
134
  const res = await (0, node_fetch_1.default)(`${catalystUrl.toString()}/content/entities`, {
135
135
  method: 'post',
136
136
  headers,
@@ -224,7 +224,7 @@ async function getAllPreviewWearables(components, { baseFolders, baseUrl }) {
224
224
  ret.push(await serveWearable(components, wearableJsonPath, baseUrl));
225
225
  }
226
226
  catch (err) {
227
- console.error(`Couldn't mock the wearable ${wearableJsonPath}. Please verify the correct format and scheme.`, err);
227
+ components.logger.error(`Couldn't mock the wearable ${wearableJsonPath}. Please verify the correct format and scheme.` + err);
228
228
  }
229
229
  }
230
230
  return ret;
@@ -234,7 +234,7 @@ async function serveWearable(components, wearableJsonPath, baseUrl) {
234
234
  const wearableJson = JSON.parse((await components.fs.readFile(wearableJsonPath)).toString());
235
235
  if (!sdk_1.WearableJson.validate(wearableJson)) {
236
236
  const errors = (sdk_1.WearableJson.validate.errors || []).map((a) => `${a.data} ${a.message}`).join('');
237
- console.error(`Unable to validate wearable.json properly, please check it.`, errors);
237
+ components.logger.error(`Unable to validate wearable.json properly, please check it.` + errors);
238
238
  throw new Error(`Invalid wearable.json (${wearableJsonPath})`);
239
239
  }
240
240
  const hashedFiles = await (0, project_files_1.getProjectContentMappings)(components, wearableDir, project_files_1.b64HashingFunction);
@@ -366,15 +366,16 @@ async function fakeEntityV3FromFolder(components, projectRoot, hashingFunction)
366
366
  const wearableJson = JSON.parse(await components.fs.readFile(wearableJsonPath, 'utf-8'));
367
367
  if (!sdk_1.WearableJson.validate(wearableJson)) {
368
368
  const errors = (sdk_1.WearableJson.validate.errors || []).map((a) => `${a.data} ${a.message}`).join('');
369
- console.error(`Unable to validate wearable.json properly, please check it.`, errors);
370
- console.error(`Invalid wearable.json (${wearableJsonPath})`);
369
+ components.logger.error(`Unable to validate wearable.json properly, please check its schema.` + errors);
370
+ components.logger.error(`Invalid wearable.json (${wearableJsonPath})`);
371
371
  }
372
372
  else {
373
373
  isParcelScene = false;
374
374
  }
375
375
  }
376
376
  catch (err) {
377
- console.error(`Unable to load wearable.json properly`, err);
377
+ components.logger.error(`Unable to load wearable.json`);
378
+ components.logger.error(err);
378
379
  }
379
380
  }
380
381
  if ((await components.fs.fileExists(sceneJsonPath)) && isParcelScene) {
@@ -40,14 +40,14 @@ function setupRealmAndComms(components, router) {
40
40
  return (0, ws_1.upgradeWebSocketResponse)((ws) => {
41
41
  if (ws.protocol === 'rfc5' || ws.protocol === 'rfc4') {
42
42
  ws.on('error', (error) => {
43
- console.error(error);
43
+ components.logger.error(error);
44
44
  ws.close();
45
45
  });
46
46
  ws.on('close', () => {
47
- console.debug('Websocket closed');
47
+ components.logger.debug('Websocket closed');
48
48
  });
49
49
  (0, handle_linear_protocol_1.handleSocketLinearProtocol)(components, ws, ctx.params.roomId).catch((err) => {
50
- console.info(err);
50
+ components.logger.info(err);
51
51
  ws.close();
52
52
  });
53
53
  }
@@ -12,7 +12,7 @@ async function wireRouter(components, dir, dataLayer) {
12
12
  if (dataLayer) {
13
13
  router.get('/data-layer', async (ctx, next) => {
14
14
  if (ctx.request.headers.get('upgrade') === 'websocket') {
15
- return (0, ws_1.upgradeWebSocketResponse)((ws) => (0, ws_2.handleDataLayerWs)(ws, dataLayer));
15
+ return (0, ws_1.upgradeWebSocketResponse)((ws) => (0, ws_2.handleDataLayerWs)(components, ws, dataLayer));
16
16
  }
17
17
  return next();
18
18
  });
@@ -69,4 +69,4 @@ export type Events = {
69
69
  error: string;
70
70
  };
71
71
  };
72
- export declare function createAnalyticsComponent({ dclInfoConfig }: Pick<CliComponents, 'dclInfoConfig'>): Promise<IAnalyticsComponent>;
72
+ export declare function createAnalyticsComponent({ dclInfoConfig, logger }: Pick<CliComponents, 'dclInfoConfig' | 'logger'>): Promise<IAnalyticsComponent>;
@@ -8,7 +8,7 @@ const uuid_1 = require("uuid");
8
8
  const analytics_node_1 = require("@segment/analytics-node");
9
9
  const fp_future_1 = __importDefault(require("fp-future"));
10
10
  const log_1 = require("./log");
11
- async function createAnalyticsComponent({ dclInfoConfig }) {
11
+ async function createAnalyticsComponent({ dclInfoConfig, logger }) {
12
12
  const USER_ID = 'sdk-commands-user';
13
13
  const config = await dclInfoConfig.get();
14
14
  const analytics = new analytics_node_1.Analytics({ writeKey: config.segmentKey ?? '' });
@@ -41,7 +41,8 @@ async function createAnalyticsComponent({ dclInfoConfig }) {
41
41
  trackFuture.resolve();
42
42
  });
43
43
  if (!dclInfoConfig.isProduction()) {
44
- console.log(trackInfo);
44
+ // TODO: what is this supposed to do?
45
+ logger.info('TrackingInfo: ' + JSON.stringify(trackInfo));
45
46
  }
46
47
  return trackFuture;
47
48
  }
@@ -57,7 +58,7 @@ async function createAnalyticsComponent({ dclInfoConfig }) {
57
58
  let dclInfo = {};
58
59
  if (!config.userId) {
59
60
  dclInfo = { userId, trackStats: true };
60
- console.log(`Decentraland CLI sends anonymous usage stats to improve their products, if you want to disable it change the configuration at ${log_1.colors.bold('~/.dclinfo')}\n`);
61
+ logger.info(`Decentraland CLI sends anonymous usage stats to improve their products, if you want to disable it change the configuration at ${log_1.colors.bold('~/.dclinfo')}\n`);
61
62
  }
62
63
  if (!config.userIdentified) {
63
64
  dclInfo.userIdentified = true;
@@ -9,12 +9,13 @@ const log_1 = require("./log");
9
9
  async function initComponents() {
10
10
  const fsComponent = (0, fs_1.createFsComponent)();
11
11
  const dclInfoConfig = await (0, dcl_info_config_1.createDCLInfoConfigComponent)({ fs: fsComponent });
12
+ const logger = (0, log_1.createStderrCliLogger)();
12
13
  return {
13
14
  fs: fsComponent,
14
15
  fetch: (0, fetch_1.createFetchComponent)(),
15
- logger: (0, log_1.createStdoutCliLogger)(),
16
+ logger,
16
17
  dclInfoConfig,
17
- analytics: await (0, analytics_1.createAnalyticsComponent)({ dclInfoConfig })
18
+ analytics: await (0, analytics_1.createAnalyticsComponent)({ dclInfoConfig, logger })
18
19
  };
19
20
  }
20
21
  exports.initComponents = initComponents;
@@ -1,4 +1,14 @@
1
1
  /// <reference types="colorette" />
2
2
  import { ILoggerComponent } from '@well-known-components/interfaces';
3
+ /**
4
+ * This file imitates "cargo" logs. The words are aligned with the colon like this:
5
+ * V
6
+ * Error: some text provided as argumen
7
+ * Info: some text provided as argumen
8
+ * Success: some text provided as argumen
9
+ * Warning: some text provided as argumen
10
+ * ^
11
+ */
12
+ export declare const writeToStderr: (...parameters: readonly unknown[]) => void;
3
13
  export declare const colors: import("colorette").Colorette;
4
- export declare function createStdoutCliLogger(): ILoggerComponent.ILogger;
14
+ export declare function createStderrCliLogger(): ILoggerComponent.ILogger;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createStdoutCliLogger = exports.colors = void 0;
3
+ exports.createStderrCliLogger = exports.colors = exports.writeToStderr = void 0;
4
4
  const colorette_1 = require("colorette");
5
5
  const error_1 = require("../logic/error");
6
6
  /**
@@ -12,36 +12,43 @@ const error_1 = require("../logic/error");
12
12
  * Warning: some text provided as argumen
13
13
  * ^
14
14
  */
15
- const stderr = (...parameters) => {
15
+ const writeToStderr = (...parameters) => {
16
16
  process.stderr.write(`${parameters.filter(($) => $ !== undefined).join('')}\n`);
17
17
  };
18
+ exports.writeToStderr = writeToStderr;
18
19
  // @see https://no-color.org
19
20
  // @see https://www.npmjs.com/package/chalk
20
21
  exports.colors = (0, colorette_1.createColors)({
21
22
  useColor: process.env.FORCE_COLOR !== '0' && !process.env.NO_COLOR
22
23
  });
23
- function createStdoutCliLogger() {
24
+ function createStderrCliLogger() {
24
25
  return {
25
26
  log(message, extra) {
26
- stderr(message, extra && JSON.stringify(extra));
27
+ (0, exports.writeToStderr)(message, extra && JSON.stringify(extra));
27
28
  },
28
29
  debug(message, extra) {
29
- stderr(exports.colors.blueBright('debug: '), message, extra && JSON.stringify(extra));
30
+ (0, exports.writeToStderr)(exports.colors.blueBright('debug: '), message, extra && JSON.stringify(extra));
30
31
  },
31
32
  error(error, extra) {
32
- stderr(exports.colors.redBright('error: '), error, extra && JSON.stringify(extra));
33
+ (0, exports.writeToStderr)(exports.colors.redBright('error: '), error, extra && JSON.stringify(extra));
33
34
  /* istanbul ignore next */
34
- if (!(error instanceof error_1.CliError) || process.env.DEBUG) {
35
- // print the stacktrace if it is not a CliError
36
- console.error(error);
35
+ if (!(error instanceof error_1.CliError)) {
36
+ if (error instanceof Error && error.stack) {
37
+ // print the stacktrace if it is not a CliError
38
+ (0, exports.writeToStderr)(error.stack);
39
+ }
40
+ else if (process.env.DEBUG) {
41
+ // print the stacktrace if it is not a CliError
42
+ (0, exports.writeToStderr)(error.toString());
43
+ }
37
44
  }
38
45
  },
39
46
  info(message, extra) {
40
- stderr(exports.colors.blueBright('info: '), message, extra && JSON.stringify(extra));
47
+ (0, exports.writeToStderr)(exports.colors.blueBright('info: '), message, extra && JSON.stringify(extra));
41
48
  },
42
49
  warn(message, extra) {
43
- stderr(exports.colors.yellow('warning: '), message, extra && JSON.stringify(extra));
50
+ (0, exports.writeToStderr)(exports.colors.yellow('warning: '), message, extra && JSON.stringify(extra));
44
51
  }
45
52
  };
46
53
  }
47
- exports.createStdoutCliLogger = createStdoutCliLogger;
54
+ exports.createStderrCliLogger = createStderrCliLogger;
package/dist/index.js CHANGED
@@ -57,12 +57,13 @@ async function main() {
57
57
  }
58
58
  main().catch(function handleError(err) {
59
59
  if (err instanceof error_1.CliError) {
60
- console.error(log_1.colors.redBright('Error: ') + err.message);
60
+ (0, log_1.writeToStderr)(log_1.colors.redBright('Error: ') + err.message);
61
61
  }
62
62
  else {
63
63
  // log with console to show stacktrace and debug information
64
+ // eslint-disable-next-line no-console
64
65
  console.error(err);
65
- console.warn(`Developer: All errors thrown must be an instance of "CliError"`);
66
+ (0, log_1.writeToStderr)(`Developer: All errors thrown must be an instance of "CliError"`);
66
67
  }
67
68
  // set an exit code but not finish the program immediately to close any pending work
68
69
  process.exitCode = 1;
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@dcl/sdk-commands",
3
3
  "description": "",
4
- "version": "7.1.4-4495128859.commit-9f954df",
4
+ "version": "7.1.4-4502579506.commit-4147243",
5
5
  "author": "Decentraland",
6
6
  "bin": {
7
7
  "sdk-commands": "./dist/index.js"
8
8
  },
9
9
  "dependencies": {
10
- "@dcl/dcl-rollup": "7.1.4-4495128859.commit-9f954df",
10
+ "@dcl/dcl-rollup": "7.1.4-4502579506.commit-4147243",
11
11
  "@dcl/hashing": "1.1.3",
12
- "@dcl/inspector": "7.1.4-4495128859.commit-9f954df",
12
+ "@dcl/inspector": "7.1.4-4502579506.commit-4147243",
13
13
  "@dcl/linker-dapp": "0.7.0",
14
14
  "@dcl/mini-comms": "1.0.1-20230216163137.commit-a4c75be",
15
15
  "@dcl/protocol": "1.0.0-4493564897.commit-c858f8a",
@@ -56,5 +56,5 @@
56
56
  "displayName": "SDK",
57
57
  "tsconfig": "./tsconfig.json"
58
58
  },
59
- "commit": "9f954df0bf811ad6c2f4af1e1ae86426ab05e950"
59
+ "commit": "41472432721ca80b377a54744da814b43fbf3631"
60
60
  }