@dcl/sdk-commands 7.1.4-4542949081.commit-c326cfb → 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.
Files changed (55) hide show
  1. package/.dclrc +19 -0
  2. package/dist/commands/build/index.d.ts +3 -1
  3. package/dist/commands/build/index.js +13 -20
  4. package/dist/commands/deploy/index.js +4 -4
  5. package/dist/commands/deploy/linker-dapp/api.d.ts +1 -1
  6. package/dist/commands/deploy/linker-dapp/api.js +14 -17
  7. package/dist/commands/deploy/linker-dapp/routes.d.ts +1 -1
  8. package/dist/commands/deploy/linker-dapp/routes.js +2 -2
  9. package/dist/commands/export-static/index.d.ts +1 -1
  10. package/dist/commands/export-static/index.js +2 -2
  11. package/dist/commands/init/index.d.ts +1 -1
  12. package/dist/commands/init/index.js +1 -1
  13. package/dist/commands/start/data-layer/fs.d.ts +2 -1
  14. package/dist/commands/start/data-layer/fs.js +17 -15
  15. package/dist/commands/start/data-layer/rpc.d.ts +1 -1
  16. package/dist/commands/start/data-layer/rpc.js +3 -4
  17. package/dist/commands/start/data-layer/ws.js +1 -1
  18. package/dist/commands/start/index.d.ts +1 -1
  19. package/dist/commands/start/index.js +6 -14
  20. package/dist/commands/start/server/endpoints.d.ts +1 -1
  21. package/dist/commands/start/server/endpoints.js +7 -11
  22. package/dist/commands/start/server/routes.js +1 -1
  23. package/dist/commands/start/types.d.ts +1 -3
  24. package/dist/components/analytics.d.ts +6 -5
  25. package/dist/components/analytics.js +46 -51
  26. package/dist/components/config.d.ts +18 -0
  27. package/dist/components/config.js +56 -0
  28. package/dist/components/exit-signal.d.ts +5 -0
  29. package/dist/components/exit-signal.js +21 -0
  30. package/dist/components/fs.d.ts +1 -1
  31. package/dist/components/fs.js +1 -0
  32. package/dist/components/index.d.ts +4 -3
  33. package/dist/components/index.js +10 -6
  34. package/dist/index.js +1 -2
  35. package/dist/logic/bundle.d.ts +51 -0
  36. package/dist/logic/bundle.js +120 -0
  37. package/dist/logic/catalyst-requests.d.ts +16 -1
  38. package/dist/logic/catalyst-requests.js +28 -4
  39. package/dist/logic/config.d.ts +15 -7
  40. package/dist/logic/config.js +54 -28
  41. package/dist/logic/exec.d.ts +6 -1
  42. package/dist/logic/exec.js +25 -22
  43. package/dist/logic/fs.d.ts +1 -7
  44. package/dist/logic/fs.js +3 -22
  45. package/dist/logic/project-validations.d.ts +2 -2
  46. package/dist/logic/project-validations.js +4 -5
  47. package/dist/logic/realm.d.ts +2 -1
  48. package/dist/logic/realm.js +6 -4
  49. package/package.json +9 -5
  50. package/dist/commands/deploy/linker-dapp/catalyst-pointers.d.ts +0 -20
  51. package/dist/commands/deploy/linker-dapp/catalyst-pointers.js +0 -45
  52. package/dist/components/dcl-info-config.d.ts +0 -11
  53. package/dist/components/dcl-info-config.js +0 -79
  54. package/dist/logic/dcl-info.d.ts +0 -27
  55. package/dist/logic/dcl-info.js +0 -90
@@ -8,75 +8,70 @@ 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, logger }) {
11
+ const config_1 = require("./config");
12
+ const config_2 = require("../logic/config");
13
+ const noopAnalytics = {
14
+ track() { },
15
+ async stop() { }
16
+ };
17
+ async function createAnalyticsComponent(components) {
18
+ const analyticsEnabled = (await (0, config_1.readStringConfig)(components, 'DCL_DISABLE_ANALYTICS')) !== 'true';
19
+ if (!analyticsEnabled) {
20
+ return noopAnalytics;
21
+ }
12
22
  const USER_ID = 'sdk-commands-user';
13
- const config = await dclInfoConfig.get();
14
- const analytics = new analytics_node_1.Analytics({ writeKey: config.segmentKey ?? '' });
23
+ let anonId = await (0, config_1.readStringConfig)(components, 'DCL_ANON_ID');
24
+ const analytics = new analytics_node_1.Analytics({ writeKey: (0, config_2.getSegmentKey)() });
25
+ if (!anonId) {
26
+ anonId = (0, uuid_1.v4)();
27
+ await (0, config_1.writeGlobalConfig)(components, 'DCL_ANON_ID', anonId);
28
+ analytics.identify({
29
+ userId: USER_ID,
30
+ traits: {
31
+ devId: anonId,
32
+ createdAt: new Date()
33
+ }
34
+ });
35
+ components.logger.info([
36
+ `By default, Decentraland CLI sends anonymous usage stats to improve the products, if you want to disable it, add the following line to the configuration file at ${log_1.colors.bold((0, config_1.getGlobalDclRcPath)())}.`,
37
+ ` DCL_DISABLE_ANALYTICS=true`,
38
+ `More info https://dcl.gg/sdk/analytics`
39
+ ].join('\n'));
40
+ }
15
41
  const promises = [];
16
- async function track(eventName, eventProps) {
17
- const trackFuture = (0, fp_future_1.default)();
18
- const { userId, trackStats } = await dclInfoConfig.get();
19
- const version = await dclInfoConfig.getVersion();
20
- if (!trackStats) {
21
- return trackFuture.resolve();
42
+ const sdkVersion = await (0, config_2.getInstalledPackageVersion)(components, '@dcl/sdk', process.cwd());
43
+ // the following properties are added to every telemetry report
44
+ const baseTelemetryProperties = {
45
+ os: process.platform,
46
+ nodeVersion: process.version,
47
+ cliVersion: await (0, config_2.getSdkCommandsVersion)(),
48
+ isCI: (0, config_2.isCI)(),
49
+ isEditor: (0, config_2.isEditor)(),
50
+ devId: anonId,
51
+ ecs: {
52
+ ecsVersion: 'ecs7',
53
+ packageVersion: sdkVersion
22
54
  }
55
+ };
56
+ function track(eventName, eventProps) {
57
+ const trackFuture = (0, fp_future_1.default)();
23
58
  const trackInfo = {
24
59
  userId: USER_ID,
25
60
  event: eventName,
26
61
  properties: {
27
62
  ...eventProps,
28
- os: process.platform,
29
- nodeVersion: process.version,
30
- cliVersion: version,
31
- isCI: dclInfoConfig.isCI(),
32
- isEditor: dclInfoConfig.isEditor(),
33
- devId: userId,
34
- ecs: {
35
- ecsVersion: 'ecs7',
36
- packageVersion: version
37
- }
63
+ ...baseTelemetryProperties
38
64
  }
39
65
  };
40
66
  analytics.track(trackInfo, () => {
41
67
  trackFuture.resolve();
42
68
  });
43
- if (!dclInfoConfig.isProduction()) {
44
- // TODO: what is this supposed to do?
45
- logger.info('TrackingInfo: ' + JSON.stringify(trackInfo));
46
- }
47
- return trackFuture;
69
+ promises.push(trackFuture);
48
70
  }
49
71
  return {
50
72
  get() {
51
73
  return analytics;
52
74
  },
53
- async identify() {
54
- if (config.userId && !config.trackStats) {
55
- return;
56
- }
57
- const userId = config.userId ?? (0, uuid_1.v4)();
58
- let dclInfo = {};
59
- if (!config.userId) {
60
- dclInfo = { userId, trackStats: true };
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`);
62
- }
63
- if (!config.userIdentified) {
64
- dclInfo.userIdentified = true;
65
- analytics.identify({
66
- userId: USER_ID,
67
- traits: {
68
- devId: userId,
69
- createdAt: new Date()
70
- }
71
- });
72
- }
73
- if (Object.keys(dclInfo).length) {
74
- await dclInfoConfig.updateDCLInfo(dclInfo);
75
- }
76
- },
77
- trackSync(eventName, eventProps) {
78
- promises.push(track(eventName, eventProps));
79
- },
80
75
  track,
81
76
  async stop() {
82
77
  await Promise.all(promises);
@@ -0,0 +1,18 @@
1
+ import { CliComponents } from '.';
2
+ import { IFileSystemComponent } from './fs';
3
+ export type ConfigKeys = 'DCL_ANON_ID' | 'DCL_DISABLE_ANALYTICS' | 'DCL_LAND_REGISTRY_ADDRESS' | 'DCL_ESTATE_REGISTRY_ADDRESS' | 'DCL_CATALYST';
4
+ export declare const DCL_RC = ".dclrc";
5
+ /**
6
+ * This function creates a chained .env loader for configurations.
7
+ * It loads sdk-commands/.dclrc then ~/.dclrc and lastly $(pwd)/.dclrc
8
+ * By default, process.env overrides any configuration.
9
+ */
10
+ export declare function createConfigComponent({ fs }: {
11
+ fs: IFileSystemComponent;
12
+ }): Promise<import("@well-known-components/interfaces").IConfigComponent>;
13
+ export declare function writeGlobalConfig({ fs }: {
14
+ fs: IFileSystemComponent;
15
+ }, key: ConfigKeys, value: string): Promise<void>;
16
+ export declare function getGlobalDclRcPath(): string;
17
+ export declare function readStringConfig(components: Pick<CliComponents, 'config'>, key: ConfigKeys): Promise<string | undefined>;
18
+ export declare function requireStringConfig(components: Pick<CliComponents, 'config'>, key: ConfigKeys): Promise<string>;
@@ -0,0 +1,56 @@
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.requireStringConfig = exports.readStringConfig = exports.getGlobalDclRcPath = exports.writeGlobalConfig = exports.createConfigComponent = exports.DCL_RC = void 0;
7
+ const env_config_provider_1 = require("@well-known-components/env-config-provider");
8
+ const os_1 = require("os");
9
+ const path_1 = __importDefault(require("path"));
10
+ const error_1 = require("../logic/error");
11
+ exports.DCL_RC = '.dclrc';
12
+ /**
13
+ * This function creates a chained .env loader for configurations.
14
+ * It loads sdk-commands/.dclrc then ~/.dclrc and lastly $(pwd)/.dclrc
15
+ * By default, process.env overrides any configuration.
16
+ */
17
+ async function createConfigComponent({ fs }) {
18
+ const dotEnvFilesToLoad = [await getSdkCommandsDclRcPath(fs)];
19
+ const userDclRc = getGlobalDclRcPath();
20
+ if (await fs.fileExists(userDclRc))
21
+ dotEnvFilesToLoad.push(userDclRc);
22
+ const projectDclRc = exports.DCL_RC;
23
+ /* istanbul ignore if */
24
+ if (await fs.fileExists(projectDclRc))
25
+ dotEnvFilesToLoad.push(projectDclRc);
26
+ return (0, env_config_provider_1.createDotEnvConfigComponent)({ path: dotEnvFilesToLoad });
27
+ }
28
+ exports.createConfigComponent = createConfigComponent;
29
+ async function writeGlobalConfig({ fs }, key, value) {
30
+ const data = ['', '# ' + new Date().toISOString(), key + '=' + value, ''];
31
+ await fs.appendFile(getGlobalDclRcPath(), data.join('\n'));
32
+ }
33
+ exports.writeGlobalConfig = writeGlobalConfig;
34
+ function getGlobalDclRcPath() {
35
+ return path_1.default.resolve((0, os_1.homedir)(), exports.DCL_RC);
36
+ }
37
+ exports.getGlobalDclRcPath = getGlobalDclRcPath;
38
+ async function getSdkCommandsDclRcPath(fs) {
39
+ const dclRc = path_1.default.resolve(__dirname, '..', '..', exports.DCL_RC);
40
+ /* istanbul ignore if */
41
+ if (!(await fs.fileExists(dclRc))) {
42
+ throw new Error(dclRc + ' not found');
43
+ }
44
+ return dclRc;
45
+ }
46
+ async function readStringConfig(components, key) {
47
+ return components.config.getString(key);
48
+ }
49
+ exports.readStringConfig = readStringConfig;
50
+ async function requireStringConfig(components, key) {
51
+ const address = await readStringConfig(components, key);
52
+ if (!address)
53
+ throw new error_1.CliError(`configuration ${key} was not provided`);
54
+ return address;
55
+ }
56
+ exports.requireStringConfig = requireStringConfig;
@@ -0,0 +1,5 @@
1
+ import { IBaseComponent } from '@well-known-components/interfaces';
2
+ export type ISignalerComponent = {
3
+ programClosed: Promise<void>;
4
+ };
5
+ export declare function createExitSignalComponent(): IBaseComponent & ISignalerComponent;
@@ -0,0 +1,21 @@
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.createExitSignalComponent = void 0;
7
+ const fp_future_1 = __importDefault(require("fp-future"));
8
+ // this component exists to "await program stopped" at the end of Lifecycle.main
9
+ function createExitSignalComponent() {
10
+ const programClosed = (0, fp_future_1.default)();
11
+ const signaler = {
12
+ programClosed,
13
+ async stop() {
14
+ // this promise is resolved upon SIGTERM or SIGHUP
15
+ // or when program.stop is called
16
+ programClosed.resolve();
17
+ }
18
+ };
19
+ return signaler;
20
+ }
21
+ exports.createExitSignalComponent = createExitSignalComponent;
@@ -7,7 +7,7 @@ import * as fsPromises from 'fs/promises';
7
7
  *
8
8
  * This may be moved to well-known-components in the future
9
9
  */
10
- export type IFileSystemComponent = Pick<typeof fs, 'createReadStream'> & Pick<typeof fs, 'createWriteStream'> & Pick<typeof fsPromises, 'access' | 'opendir' | 'stat' | 'unlink' | 'mkdir' | 'readFile' | 'writeFile' | 'rename' | 'rmdir'> & {
10
+ export type IFileSystemComponent = Pick<typeof fs, 'createReadStream'> & Pick<typeof fs, 'createWriteStream'> & Pick<typeof fsPromises, 'access' | 'opendir' | 'stat' | 'unlink' | 'mkdir' | 'readFile' | 'writeFile' | 'rename' | 'rmdir' | 'appendFile'> & {
11
11
  constants: Pick<typeof fs.constants, 'F_OK' | 'R_OK'>;
12
12
  } & {
13
13
  fileExists(path: string): Promise<boolean>;
@@ -51,6 +51,7 @@ function createFsComponent() {
51
51
  createReadStream: fs.createReadStream,
52
52
  createWriteStream: fs.createWriteStream,
53
53
  access: fsPromises.access,
54
+ appendFile: fsPromises.appendFile,
54
55
  writeFile: fsPromises.writeFile,
55
56
  opendir: fsPromises.opendir,
56
57
  stat: fsPromises.stat,
@@ -1,13 +1,14 @@
1
- import { ILoggerComponent } from '@well-known-components/interfaces';
1
+ import { ILoggerComponent, IConfigComponent } from '@well-known-components/interfaces';
2
+ import { IProcessSpawnerComponent } from '../logic/exec';
2
3
  import { IAnalyticsComponent } from './analytics';
3
- import { IDCLInfoConfigComponent } from './dcl-info-config';
4
4
  import { IFetchComponent } from './fetch';
5
5
  import { IFileSystemComponent } from './fs';
6
6
  export type CliComponents = {
7
7
  fs: IFileSystemComponent;
8
8
  fetch: IFetchComponent;
9
9
  logger: ILoggerComponent.ILogger;
10
- dclInfoConfig: IDCLInfoConfigComponent;
11
10
  analytics: IAnalyticsComponent;
11
+ spawner: IProcessSpawnerComponent;
12
+ config: IConfigComponent;
12
13
  };
13
14
  export declare function initComponents(): Promise<CliComponents>;
@@ -1,21 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initComponents = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const exec_1 = require("../logic/exec");
4
6
  const analytics_1 = require("./analytics");
5
- const dcl_info_config_1 = require("./dcl-info-config");
7
+ const config_1 = require("./config");
6
8
  const fetch_1 = require("./fetch");
7
9
  const fs_1 = require("./fs");
8
10
  const log_1 = require("./log");
9
11
  async function initComponents() {
10
- const fsComponent = (0, fs_1.createFsComponent)();
11
- const dclInfoConfig = await (0, dcl_info_config_1.createDCLInfoConfigComponent)({ fs: fsComponent });
12
+ const fs = (0, fs_1.createFsComponent)();
13
+ const config = await (0, config_1.createConfigComponent)({ fs });
12
14
  const logger = (0, log_1.createStderrCliLogger)();
15
+ const spawner = (0, exec_1.createProcessSpawnerComponent)(child_process_1.spawn);
13
16
  return {
14
- fs: fsComponent,
17
+ fs,
15
18
  fetch: (0, fetch_1.createFetchComponent)(),
16
19
  logger,
17
- dclInfoConfig,
18
- analytics: await (0, analytics_1.createAnalyticsComponent)({ dclInfoConfig, logger })
20
+ config,
21
+ spawner,
22
+ analytics: await (0, analytics_1.createAnalyticsComponent)({ config, logger, fs })
19
23
  };
20
24
  }
21
25
  exports.initComponents = initComponents;
package/dist/index.js CHANGED
@@ -36,7 +36,6 @@ async function main() {
36
36
  // eslint-disable-next-line @typescript-eslint/no-var-requires
37
37
  const cmd = require(`${commands_1.COMMANDS_PATH}/${command}`);
38
38
  if (commandFnsAreValid(cmd)) {
39
- await components.analytics.identify();
40
39
  const options = { args: cmd.args, components };
41
40
  if (needsHelp) {
42
41
  await cmd.help(options);
@@ -66,5 +65,5 @@ main().catch(function handleError(err) {
66
65
  (0, log_1.writeToStderr)(`Developer: All errors thrown must be an instance of "CliError"`);
67
66
  }
68
67
  // set an exit code but not finish the program immediately to close any pending work
69
- process.exitCode = 1;
68
+ process.exit(process.exitCode ?? 1);
70
69
  });
@@ -0,0 +1,51 @@
1
+ import esbuild from 'esbuild';
2
+ import { CliComponents } from '../components';
3
+ export type BundleComponents = Pick<CliComponents, 'logger' | 'fs'>;
4
+ export type SceneJson = {
5
+ main: string;
6
+ runtimeVersion: string;
7
+ };
8
+ export type CompileOptions = {
9
+ production: boolean;
10
+ watch: boolean;
11
+ single?: string;
12
+ workingDirectory: string;
13
+ emitDeclaration: boolean;
14
+ };
15
+ export declare function bundleProject(components: BundleComponents, options: CompileOptions): Promise<{
16
+ context: esbuild.BuildContext<{
17
+ entryPoints: string[];
18
+ bundle: true;
19
+ platform: "browser";
20
+ format: "cjs";
21
+ preserveSymlinks: false;
22
+ outfile: string;
23
+ allowOverwrite: false;
24
+ sourcemap: "external" | "inline";
25
+ minify: boolean;
26
+ minifyIdentifiers: boolean;
27
+ minifySyntax: boolean;
28
+ minifyWhitespace: boolean;
29
+ treeShaking: true;
30
+ metafile: true;
31
+ absWorkingDir: string;
32
+ target: string;
33
+ external: string[];
34
+ sourceRoot: string;
35
+ define: {
36
+ document: string;
37
+ window: string;
38
+ DEBUG: string;
39
+ 'globalThis.DEBUG': string;
40
+ 'process.env.NODE_ENV': string;
41
+ };
42
+ tsconfig: string;
43
+ supported: {
44
+ 'import-assertions': false;
45
+ 'import-meta': false;
46
+ 'dynamic-import': false;
47
+ hashbang: false;
48
+ };
49
+ }>;
50
+ sceneJson: import("@dcl/schemas").Scene;
51
+ }>;
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ // this file is tested extensively to build scenes in the `make test` command
3
+ // but since it runs outiside the testing harness, coverage is not collected
4
+ var __importDefault = (this && this.__importDefault) || function (mod) {
5
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.bundleProject = void 0;
9
+ /* istanbul ignore file */
10
+ const esbuild_1 = __importDefault(require("esbuild"));
11
+ const child_process_1 = __importDefault(require("child_process"));
12
+ const fp_future_1 = require("fp-future");
13
+ const error_1 = require("./error");
14
+ const scene_validations_1 = require("./scene-validations");
15
+ const path_1 = require("path");
16
+ const beautiful_logs_1 = require("./beautiful-logs");
17
+ const log_1 = require("../components/log");
18
+ const url_1 = require("url");
19
+ const MAX_STEP = 3;
20
+ async function bundleProject(components, options) {
21
+ const sceneJson = await (0, scene_validations_1.getValidSceneJson)(components, options.workingDirectory);
22
+ const tsconfig = (0, path_1.join)(options.workingDirectory, 'tsconfig.json');
23
+ (0, beautiful_logs_1.printProgressStep)(components.logger, `Validating project structure`, 1, MAX_STEP);
24
+ if (!options.single && !sceneJson.main) {
25
+ throw new error_1.CliError('scene.json .main must be present');
26
+ }
27
+ if (sceneJson.runtimeVersion !== '7') {
28
+ throw new error_1.CliError('scene.json `"runtimeVersion": "7"` must be present');
29
+ }
30
+ if (!(await components.fs.fileExists(tsconfig))) {
31
+ throw new error_1.CliError(`File ${tsconfig} must exist to compile the Typescript project`);
32
+ }
33
+ const input = options.single ?? 'src/index.ts';
34
+ const output = !options.single ? sceneJson.main : options.single.replace(/\.ts$/, '.js');
35
+ const outfile = (0, path_1.join)(options.workingDirectory, output);
36
+ (0, beautiful_logs_1.printProgressStep)(components.logger, `Bundling file ${log_1.colors.bold(input)}`, 2, MAX_STEP);
37
+ const context = await esbuild_1.default.context({
38
+ entryPoints: [input],
39
+ bundle: true,
40
+ platform: 'browser',
41
+ format: 'cjs',
42
+ preserveSymlinks: false,
43
+ outfile,
44
+ allowOverwrite: false,
45
+ sourcemap: options.production ? 'external' : 'inline',
46
+ minify: options.production,
47
+ minifyIdentifiers: options.production,
48
+ minifySyntax: options.production,
49
+ minifyWhitespace: options.production,
50
+ treeShaking: true,
51
+ metafile: true,
52
+ absWorkingDir: options.workingDirectory,
53
+ target: 'es2020',
54
+ external: ['~system/*'],
55
+ // convert filesystem paths into file:// to enable VSCode debugger
56
+ sourceRoot: (0, url_1.pathToFileURL)((0, path_1.dirname)(outfile)).toString(),
57
+ define: {
58
+ document: 'undefined',
59
+ window: 'undefined',
60
+ DEBUG: options.production ? 'false' : 'true',
61
+ 'globalThis.DEBUG': options.production ? 'false' : 'true',
62
+ 'process.env.NODE_ENV': JSON.stringify(options.production ? 'production' : 'development')
63
+ },
64
+ tsconfig: (0, path_1.join)(options.workingDirectory, 'tsconfig.json'),
65
+ supported: {
66
+ 'import-assertions': false,
67
+ 'import-meta': false,
68
+ 'dynamic-import': false,
69
+ hashbang: false
70
+ }
71
+ });
72
+ if (options.watch) {
73
+ await context.watch({});
74
+ }
75
+ else {
76
+ try {
77
+ await context.rebuild();
78
+ }
79
+ catch (err) {
80
+ throw new error_1.CliError(err.toString());
81
+ }
82
+ await context.dispose();
83
+ }
84
+ (0, beautiful_logs_1.printProgressInfo)(components.logger, `Bundle saved ${log_1.colors.bold(output)}`);
85
+ if (options.watch)
86
+ (0, beautiful_logs_1.printProgressInfo)(components.logger, `The compiler is watching for changes`);
87
+ await runTypeChecker(components, options);
88
+ return { context, sceneJson };
89
+ }
90
+ exports.bundleProject = bundleProject;
91
+ function runTypeChecker(components, options) {
92
+ const args = [
93
+ require.resolve('typescript/lib/tsc'),
94
+ '-p',
95
+ 'tsconfig.json',
96
+ '--preserveWatchOutput',
97
+ options.emitDeclaration ? '--emitDeclarationOnly' : '--noEmit'
98
+ ];
99
+ if (options.watch)
100
+ args.push('--watch');
101
+ (0, beautiful_logs_1.printProgressStep)(components.logger, `Running type checker`, 3, MAX_STEP);
102
+ const ts = child_process_1.default.spawn('node', args, { env: process.env, cwd: options.workingDirectory });
103
+ const typeCheckerFuture = (0, fp_future_1.future)();
104
+ ts.on('close', (code) => {
105
+ if (code === 0) {
106
+ (0, beautiful_logs_1.printProgressInfo)(components.logger, `Type checking completed without errors`);
107
+ }
108
+ else {
109
+ typeCheckerFuture.reject(new error_1.CliError(`Typechecker exited with code ${code}.`));
110
+ return;
111
+ }
112
+ typeCheckerFuture.resolve(code);
113
+ });
114
+ ts.stdout.pipe(process.stdout);
115
+ ts.stderr.pipe(process.stderr);
116
+ if (options.watch) {
117
+ typeCheckerFuture.resolve(-1);
118
+ }
119
+ return typeCheckerFuture;
120
+ }
@@ -1,5 +1,20 @@
1
1
  import { Entity } from '@dcl/schemas';
2
- export declare function fetchEntityByPointer(baseUrl: string, pointers: string[]): Promise<{
2
+ import { CliComponents } from '../components';
3
+ export type DAOCatalyst = {
4
+ baseUrl: string;
5
+ owner: string;
6
+ id: string;
7
+ };
8
+ type CatalystInfo = {
9
+ url: string;
10
+ timestamp: number;
11
+ entityId: string;
12
+ };
13
+ export type Network = 'mainnet' | 'goerli';
14
+ export declare function daoCatalysts(components: Pick<CliComponents, 'fetch' | 'config'>, network: Network): Promise<Array<DAOCatalyst>>;
15
+ export declare function fetchEntityByPointer({ fetch }: Pick<CliComponents, 'fetch'>, baseUrl: string, pointers: string[]): Promise<{
3
16
  baseUrl: string;
4
17
  deployments: Entity[];
5
18
  }>;
19
+ export declare function getPointers(components: Pick<CliComponents, 'fetch' | 'logger' | 'config'>, pointer: string, network: Network): Promise<CatalystInfo[]>;
20
+ export {};
@@ -1,15 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchEntityByPointer = void 0;
4
- const undici_1 = require("undici");
5
- async function fetchEntityByPointer(baseUrl, pointers) {
3
+ exports.getPointers = exports.fetchEntityByPointer = exports.daoCatalysts = void 0;
4
+ const config_1 = require("./config");
5
+ async function daoCatalysts(components, network) {
6
+ const tld = network === 'mainnet' ? 'org' : 'zone';
7
+ const catalystUrl = network === 'mainnet' ? await (0, config_1.getCatalystBaseUrl)(components) : `https://peer.decentraland.${tld}`;
8
+ const resp = await (await components.fetch.fetch(`${catalystUrl}/lambdas/contracts/servers`)).json();
9
+ return resp;
10
+ }
11
+ exports.daoCatalysts = daoCatalysts;
12
+ async function fetchEntityByPointer({ fetch }, baseUrl, pointers) {
6
13
  if (pointers.length === 0)
7
14
  return {
8
15
  baseUrl,
9
16
  deployments: []
10
17
  };
11
18
  const activeEntities = baseUrl + '/content/entities/active';
12
- const response = await (0, undici_1.fetch)(activeEntities, {
19
+ const response = await fetch.fetch(activeEntities, {
13
20
  method: 'post',
14
21
  headers: { 'content-type': 'application/json', connection: 'close' },
15
22
  body: JSON.stringify({ pointers })
@@ -21,3 +28,20 @@ async function fetchEntityByPointer(baseUrl, pointers) {
21
28
  };
22
29
  }
23
30
  exports.fetchEntityByPointer = fetchEntityByPointer;
31
+ async function getPointers(components, pointer, network) {
32
+ const catalysts = await daoCatalysts(components, network);
33
+ const catalystInfo = [];
34
+ for (const { baseUrl } of catalysts) {
35
+ try {
36
+ const result = await fetchEntityByPointer(components, baseUrl, [pointer]);
37
+ const timestamp = result.deployments[0]?.timestamp;
38
+ const entityId = result.deployments[0]?.id || '';
39
+ catalystInfo.push({ timestamp, entityId, url: baseUrl });
40
+ }
41
+ catch (err) {
42
+ components.logger.log('Error fetching catalyst pointers', err);
43
+ }
44
+ }
45
+ return catalystInfo;
46
+ }
47
+ exports.getPointers = getPointers;
@@ -1,12 +1,20 @@
1
1
  import { CliComponents } from '../components';
2
- import { DCLInfo } from './dcl-info';
3
- export declare const getDclInfoPath: () => string;
4
2
  /**
5
- * Reads the contents of the `.dclinfo` file
3
+ * Returns the version of the sdk-commands that is running
6
4
  */
7
- export declare function getDCLInfoConfig(components: Pick<CliComponents, 'fs'>): Promise<DCLInfo>;
5
+ export declare function getSdkCommandsVersion(): Promise<any>;
8
6
  /**
9
- * Config that can be override via ENV variables
7
+ * Returns the installed version of a certain package in the current working directory.
8
+ * Returns "unknown" if the package is not installed.
10
9
  */
11
- export declare function getEnvConfig(): Partial<DCLInfo>;
12
- export declare function removeEmptyKeys(obj: Record<string, unknown>): Record<string, unknown>;
10
+ export declare function getInstalledPackageVersion(components: Pick<CliComponents, 'fs'>, packageName: string, workingDirectory: string): Promise<string>;
11
+ /**
12
+ * Returns true if the Decentraland Editor is running.
13
+ * TODO: EDITOR is a unix reserved env var. Change it for something more specific.
14
+ */
15
+ export declare function isEditor(): boolean;
16
+ export declare function isCI(): boolean;
17
+ export declare function getCatalystBaseUrl(components: Pick<CliComponents, 'config'>): Promise<string>;
18
+ export declare function getSegmentKey(): "sFdziRVDJo0taOnGzTZwafEL9nLIANZ3" | "mjCV5Dc4VAKXLJAH5g7LyHyW1jrIR3to";
19
+ export declare function getLandRegistry(components: Pick<CliComponents, 'config'>): Promise<string>;
20
+ export declare function getEstateRegistry(components: Pick<CliComponents, 'config'>): Promise<string>;