@dcl/sdk-commands 7.0.0-4217957637.commit-a393ef7

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 (96) hide show
  1. package/LICENSE +201 -0
  2. package/dist/commands/build/index.d.ts +20 -0
  3. package/dist/commands/build/index.js +58 -0
  4. package/dist/commands/export-static/index.d.ts +23 -0
  5. package/dist/commands/export-static/index.js +119 -0
  6. package/dist/commands/init/index.d.ts +18 -0
  7. package/dist/commands/init/index.js +52 -0
  8. package/dist/commands/init/repos.d.ts +9 -0
  9. package/dist/commands/init/repos.js +11 -0
  10. package/dist/commands/start/index.d.ts +30 -0
  11. package/dist/commands/start/index.js +217 -0
  12. package/dist/commands/start/server/endpoints.d.ts +4 -0
  13. package/dist/commands/start/server/endpoints.js +399 -0
  14. package/dist/commands/start/server/file-watch-notifier.d.ts +8 -0
  15. package/dist/commands/start/server/file-watch-notifier.js +44 -0
  16. package/dist/commands/start/server/realm.d.ts +7 -0
  17. package/dist/commands/start/server/realm.js +57 -0
  18. package/dist/commands/start/server/routes.d.ts +2 -0
  19. package/dist/commands/start/server/routes.js +32 -0
  20. package/dist/commands/start/server/ws.d.ts +11 -0
  21. package/dist/commands/start/server/ws.js +19 -0
  22. package/dist/commands/start/types.d.ts +18 -0
  23. package/dist/commands/start/types.js +2 -0
  24. package/dist/components/eth.d.ts +2 -0
  25. package/dist/components/eth.js +5 -0
  26. package/dist/components/fetch.d.ts +5 -0
  27. package/dist/components/fetch.js +33 -0
  28. package/dist/components/fs.d.ts +20 -0
  29. package/dist/components/fs.js +71 -0
  30. package/dist/components/index.d.ts +9 -0
  31. package/dist/components/index.js +14 -0
  32. package/dist/components/log.d.ts +4 -0
  33. package/dist/components/log.js +47 -0
  34. package/dist/index.d.ts +7 -0
  35. package/dist/index.js +67 -0
  36. package/dist/logic/args.d.ts +11 -0
  37. package/dist/logic/args.js +18 -0
  38. package/dist/logic/beautiful-logs.d.ts +5 -0
  39. package/dist/logic/beautiful-logs.js +27 -0
  40. package/dist/logic/catalyst-requests.d.ts +5 -0
  41. package/dist/logic/catalyst-requests.js +23 -0
  42. package/dist/logic/commands.d.ts +3 -0
  43. package/dist/logic/commands.js +23 -0
  44. package/dist/logic/coordinates.d.ts +37 -0
  45. package/dist/logic/coordinates.js +83 -0
  46. package/dist/logic/dcl-ignore.d.ts +8 -0
  47. package/dist/logic/dcl-ignore.js +48 -0
  48. package/dist/logic/error.d.ts +2 -0
  49. package/dist/logic/error.js +6 -0
  50. package/dist/logic/exec.d.ts +8 -0
  51. package/dist/logic/exec.js +26 -0
  52. package/dist/logic/fs.d.ts +24 -0
  53. package/dist/logic/fs.js +41 -0
  54. package/dist/logic/get-free-port.d.ts +1 -0
  55. package/dist/logic/get-free-port.js +20 -0
  56. package/dist/logic/project-files.d.ts +16 -0
  57. package/dist/logic/project-files.js +62 -0
  58. package/dist/logic/project-validations.d.ts +15 -0
  59. package/dist/logic/project-validations.js +56 -0
  60. package/dist/logic/realm.d.ts +2 -0
  61. package/dist/logic/realm.js +30 -0
  62. package/dist/logic/scene-validations.d.ts +13 -0
  63. package/dist/logic/scene-validations.js +64 -0
  64. package/package.json +50 -0
  65. package/src/commands/build/index.ts +68 -0
  66. package/src/commands/export-static/index.ts +142 -0
  67. package/src/commands/init/index.ts +67 -0
  68. package/src/commands/init/repos.ts +17 -0
  69. package/src/commands/start/index.ts +213 -0
  70. package/src/commands/start/server/endpoints.ts +473 -0
  71. package/src/commands/start/server/file-watch-notifier.ts +45 -0
  72. package/src/commands/start/server/realm.ts +63 -0
  73. package/src/commands/start/server/routes.ts +36 -0
  74. package/src/commands/start/server/ws.ts +24 -0
  75. package/src/commands/start/types.ts +26 -0
  76. package/src/components/eth.ts +3 -0
  77. package/src/components/fetch.ts +11 -0
  78. package/src/components/fs.ts +62 -0
  79. package/src/components/index.ts +18 -0
  80. package/src/components/log.ts +48 -0
  81. package/src/index.ts +90 -0
  82. package/src/logic/args.ts +19 -0
  83. package/src/logic/beautiful-logs.ts +26 -0
  84. package/src/logic/catalyst-requests.ts +31 -0
  85. package/src/logic/commands.ts +28 -0
  86. package/src/logic/coordinates.ts +95 -0
  87. package/src/logic/dcl-ignore.ts +49 -0
  88. package/src/logic/error.ts +1 -0
  89. package/src/logic/exec.ts +36 -0
  90. package/src/logic/fs.ts +41 -0
  91. package/src/logic/get-free-port.ts +15 -0
  92. package/src/logic/project-files.ts +76 -0
  93. package/src/logic/project-validations.ts +61 -0
  94. package/src/logic/realm.ts +28 -0
  95. package/src/logic/scene-validations.ts +73 -0
  96. package/tsconfig.json +28 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2019 Metaverse Holdings Ltd.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,20 @@
1
+ import { CliComponents } from '../../components';
2
+ interface Options {
3
+ args: Omit<typeof args, '_'>;
4
+ components: Pick<CliComponents, 'fs' | 'logger'>;
5
+ }
6
+ export declare const args: import("arg").Result<{
7
+ '--help': BooleanConstructor;
8
+ '--json': BooleanConstructor;
9
+ '-h': string;
10
+ } & {
11
+ '--watch': BooleanConstructor;
12
+ '-w': string;
13
+ '--production': BooleanConstructor;
14
+ '-p': string;
15
+ '--skip-install': BooleanConstructor;
16
+ '--dir': StringConstructor;
17
+ }>;
18
+ export declare function help(): string;
19
+ export declare function main(options: Options): Promise<void>;
20
+ export {};
@@ -0,0 +1,58 @@
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.main = exports.help = exports.args = void 0;
7
+ const path_1 = require("path");
8
+ 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
+ const project_validations_1 = require("../../logic/project-validations");
12
+ exports.args = (0, args_1.getArgs)({
13
+ '--watch': Boolean,
14
+ '-w': '--watch',
15
+ '--production': Boolean,
16
+ '-p': '--production',
17
+ '--skip-install': Boolean,
18
+ '--dir': String
19
+ });
20
+ function help() {
21
+ return `
22
+ Usage: 'sdk-commands build [options]'
23
+ Options:'
24
+ -h, --help Displays complete help
25
+ -w, --watch Watch for file changes and build on change
26
+ -p, --production Build without sourcemaps
27
+ --skip-install Skip installing dependencies
28
+ --dir Path to directory to build
29
+
30
+ Example:
31
+ - Build your scene:
32
+ '$ sdk-commands build'
33
+ `;
34
+ }
35
+ exports.help = help;
36
+ async function main(options) {
37
+ const projectRoot = (0, path_1.resolve)(process.cwd(), options.args['--dir'] || '.');
38
+ await (0, project_validations_1.assertValidProjectFolder)(options.components, projectRoot);
39
+ const shouldInstallDeps = await (0, project_validations_1.needsDependencies)(options.components, projectRoot);
40
+ if (shouldInstallDeps && !options.args['--skip-install']) {
41
+ await (0, project_validations_1.installDependencies)(options.components, projectRoot);
42
+ }
43
+ const watch = !!options.args['--watch'];
44
+ const watchingFuture = (0, fp_future_1.default)();
45
+ await (0, compile_1.compile)({
46
+ project: projectRoot,
47
+ watch,
48
+ production: !!options.args['--production'],
49
+ watchingFuture
50
+ });
51
+ if (!watch) {
52
+ watchingFuture.resolve(null);
53
+ }
54
+ await watchingFuture;
55
+ // track stuff...
56
+ // https://github.com/decentraland/cli/blob/main/src/commands/build.ts
57
+ }
58
+ exports.main = main;
@@ -0,0 +1,23 @@
1
+ import { CliComponents } from '../../components';
2
+ interface Options {
3
+ args: typeof args;
4
+ components: Pick<CliComponents, 'fetch' | 'fs' | 'logger'>;
5
+ }
6
+ export declare const args: import("arg").Result<{
7
+ '--help': BooleanConstructor;
8
+ '--json': BooleanConstructor;
9
+ '-h': string;
10
+ } & {
11
+ '--dir': StringConstructor;
12
+ '--destination': StringConstructor;
13
+ '--timestamp': StringConstructor;
14
+ '--realmName': StringConstructor;
15
+ '--baseUrl': StringConstructor;
16
+ }>;
17
+ export declare function help(): Promise<string>;
18
+ export declare function main(options: Options): Promise<{
19
+ urn: string;
20
+ entityId: string;
21
+ destination: string;
22
+ }>;
23
+ export {};
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.main = exports.help = exports.args = void 0;
4
+ const path_1 = require("path");
5
+ const args_1 = require("../../logic/args");
6
+ const hashing_1 = require("@dcl/hashing");
7
+ const project_validations_1 = require("../../logic/project-validations");
8
+ const project_files_1 = require("../../logic/project-files");
9
+ const error_1 = require("../../logic/error");
10
+ const schemas_1 = require("@dcl/schemas");
11
+ const log_1 = require("../../components/log");
12
+ const beautiful_logs_1 = require("../../logic/beautiful-logs");
13
+ const realm_1 = require("../../logic/realm");
14
+ exports.args = (0, args_1.getArgs)({
15
+ '--dir': String,
16
+ '--destination': String,
17
+ '--timestamp': String,
18
+ '--realmName': String,
19
+ '--baseUrl': String
20
+ });
21
+ async function help() {
22
+ return `
23
+ Usage:
24
+ sdk-commands export-static --dir <directory> --destination <directory>
25
+
26
+ Description:
27
+
28
+ Exports all the contents of the scene as if they were uploaded to a content server
29
+
30
+ Options:
31
+
32
+ --dir <directory> The project's root folder to export
33
+ --destination <directory> A path in which all the assets will be stored
34
+ --timestamp <timestamp> A date to use in the deployable entity. Defaults to now()
35
+ --realmName <name> Creates a /<name>/about endpoint to expose the current deployment as a realm. Requires --baseUrl
36
+ --baseUrl <baseUrl> It is the public URL in which the --destination directory will be avaiable
37
+ `;
38
+ }
39
+ exports.help = help;
40
+ async function main(options) {
41
+ const { fs, logger } = options.components;
42
+ const projectRoot = (0, path_1.resolve)(process.cwd(), options.args['--dir'] || '.');
43
+ const destDirectory = (0, path_1.resolve)(process.cwd(), options.args['--destination'] || '.');
44
+ const willCreateRealm = !!exports.args['--realmName'];
45
+ let currentStep = 1;
46
+ const maxSteps = 3 + (willCreateRealm ? 1 : 0);
47
+ if (willCreateRealm && !exports.args['--baseUrl']) {
48
+ throw new error_1.CliError(`--baseUrl is mandatory when --realmName is provided`);
49
+ }
50
+ if (willCreateRealm && !/^[a-z][a-z0-9-.]*$/i.test(exports.args['--realmName'])) {
51
+ throw new error_1.CliError(`--realmName has invalid characters`);
52
+ }
53
+ (0, beautiful_logs_1.printProgressStep)(logger, 'Reading project files...', currentStep++, maxSteps);
54
+ await fs.mkdir(destDirectory, { recursive: true });
55
+ if (!(await fs.directoryExists(destDirectory))) {
56
+ throw new error_1.CliError(`The destination path ${destDirectory} is not a directory`);
57
+ }
58
+ const project = await (0, project_validations_1.assertValidProjectFolder)(options.components, projectRoot);
59
+ const filesToExport = await (0, project_files_1.getProjectContentMappings)(options.components, projectRoot, async (file) => {
60
+ return await (0, hashing_1.hashV1)(fs.createReadStream((0, path_1.resolve)(projectRoot, file)));
61
+ });
62
+ (0, beautiful_logs_1.printProgressStep)(logger, 'Copying files...', currentStep++, maxSteps);
63
+ for (const { file, hash } of filesToExport) {
64
+ const src = (0, path_1.resolve)(projectRoot, file);
65
+ const dst = (0, path_1.resolve)(destDirectory, hash);
66
+ if (src.startsWith(destDirectory))
67
+ continue;
68
+ (0, beautiful_logs_1.printProgressInfo)(logger, `> ${hash} -> ${file}`);
69
+ if (!(await fs.fileExists(dst))) {
70
+ const content = await fs.readFile(src);
71
+ await fs.writeFile(dst, content);
72
+ }
73
+ }
74
+ // entity with ID are the deployed ones, when we generate the entity the ID is not
75
+ // available because it is the result of hashing the following structure
76
+ const entity = {
77
+ content: filesToExport,
78
+ pointers: [],
79
+ timestamp: exports.args['--timestamp'] ? new Date(exports.args['--timestamp']).getTime() : Date.now(),
80
+ type: schemas_1.EntityType.SCENE,
81
+ // for now, the only valid export is for scenes
82
+ metadata: project.scene,
83
+ version: 'v3'
84
+ };
85
+ (0, beautiful_logs_1.printProgressStep)(logger, 'Generating files...', currentStep++, maxSteps);
86
+ // create the entity file and get the entityId
87
+ const entityRaw = Buffer.from(JSON.stringify(entity), 'utf8');
88
+ const entityId = await (0, hashing_1.hashV1)(entityRaw);
89
+ const dst = (0, path_1.resolve)(destDirectory, entityId);
90
+ await fs.writeFile(dst, entityRaw);
91
+ (0, beautiful_logs_1.printProgressInfo)(logger, `> ${entityId} -> [ENTITY FILE]`);
92
+ let urn = `urn:decentraland:entity:${entityId}`;
93
+ if (exports.args['--baseUrl']) {
94
+ urn += '?baseUrl=' + exports.args['--baseUrl'];
95
+ // baseUrl must end with /
96
+ if (!urn.endsWith('/'))
97
+ urn += '/';
98
+ }
99
+ if (willCreateRealm) {
100
+ // prepare the realm object
101
+ (0, beautiful_logs_1.printProgressStep)(logger, 'Creating realm file...', currentStep++, maxSteps);
102
+ const realm = (0, realm_1.createStaticRealm)();
103
+ const realmName = exports.args['--realmName'];
104
+ realm.configurations.scenesUrn = [urn];
105
+ realm.configurations.realmName = realmName;
106
+ // write the realm file
107
+ const realmDirectory = (0, path_1.resolve)(destDirectory, realmName);
108
+ await fs.mkdir(realmDirectory, { recursive: true });
109
+ if (!(await fs.directoryExists(realmDirectory))) {
110
+ throw new error_1.CliError(`The destination path ${realmDirectory} is not a directory`);
111
+ }
112
+ const dst = (0, path_1.resolve)(realmDirectory, 'about');
113
+ await fs.writeFile(dst, JSON.stringify(realm, null, 2));
114
+ (0, beautiful_logs_1.printProgressInfo)(logger, `> ${realmName}/about -> [REALM FILE]`);
115
+ }
116
+ (0, beautiful_logs_1.printSuccess)(logger, `Export finished!`, `=> The entity URN is ${log_1.colors.bold(urn)}`);
117
+ return { urn, entityId, destination: destDirectory };
118
+ }
119
+ exports.main = main;
@@ -0,0 +1,18 @@
1
+ import { CliComponents } from '../../components';
2
+ interface Options {
3
+ args: typeof args;
4
+ components: Pick<CliComponents, 'fetch' | 'fs' | 'logger'>;
5
+ }
6
+ export declare const args: import("arg").Result<{
7
+ '--help': BooleanConstructor;
8
+ '--json': BooleanConstructor;
9
+ '-h': string;
10
+ } & {
11
+ '--yes': BooleanConstructor;
12
+ '-y': string;
13
+ '--dir': StringConstructor;
14
+ '--skip-install': BooleanConstructor;
15
+ }>;
16
+ export declare function help(): Promise<void>;
17
+ export declare function main(options: Options): Promise<void>;
18
+ export {};
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.main = exports.help = exports.args = void 0;
4
+ const path_1 = require("path");
5
+ const args_1 = require("../../logic/args");
6
+ const error_1 = require("../../logic/error");
7
+ const fs_1 = require("../../logic/fs");
8
+ const repos_1 = require("./repos");
9
+ const project_validations_1 = require("../../logic/project-validations");
10
+ exports.args = (0, args_1.getArgs)({
11
+ '--yes': Boolean,
12
+ '-y': '--yes',
13
+ '--dir': String,
14
+ '--skip-install': Boolean
15
+ });
16
+ async function help() { }
17
+ exports.help = help;
18
+ async function main(options) {
19
+ const dir = (0, path_1.resolve)(process.cwd(), options.args['--dir'] || '.');
20
+ const isEmpty = await (0, fs_1.isDirectoryEmpty)(options.components, dir);
21
+ const yes = options.args['--yes'];
22
+ if (!isEmpty && !yes) {
23
+ throw new error_1.CliError('The target directory specified is not empty. Run this command with --yes to override.');
24
+ }
25
+ // download and extract template project
26
+ const scene = 'scene-template';
27
+ const { url, contentFolders } = (0, repos_1.get)(scene);
28
+ const zip = await (0, fs_1.download)(options.components, url, (0, path_1.join)(dir, `${scene}.zip`));
29
+ await (0, fs_1.extract)(zip, dir);
30
+ await options.components.fs.unlink(zip);
31
+ await moveFilesFromDirs(options.components, dir, contentFolders);
32
+ // npm install
33
+ const shouldInstallDeps = await (0, project_validations_1.needsDependencies)(options.components, dir);
34
+ if (shouldInstallDeps && !options.args['--skip-install']) {
35
+ await (0, project_validations_1.installDependencies)(options.components, dir);
36
+ }
37
+ }
38
+ exports.main = main;
39
+ const moveFilesFromDir = async (components, dir, folder) => {
40
+ const files = await components.fs.readdir(folder);
41
+ await Promise.all(files.map(($) => {
42
+ const filePath = (0, path_1.resolve)(folder, $);
43
+ return components.fs.rename(filePath, (0, path_1.resolve)(dir, $));
44
+ }));
45
+ await components.fs.rmdir(folder);
46
+ };
47
+ const moveFilesFromDirs = async (components, dir, folders) => {
48
+ await Promise.all(folders.map(($) => {
49
+ const folderPath = (0, path_1.resolve)(dir, $);
50
+ return moveFilesFromDir(components, dir, folderPath);
51
+ }));
52
+ };
@@ -0,0 +1,9 @@
1
+ type Scene = 'scene-template';
2
+ type Repos = {
3
+ [key in Scene]: {
4
+ url: string;
5
+ contentFolders: string[];
6
+ };
7
+ };
8
+ export declare const get: (scene: Scene) => Repos[Scene];
9
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.get = void 0;
4
+ const REPOS = {
5
+ 'scene-template': {
6
+ url: 'https://github.com/decentraland/sdk7-scene-template/archive/refs/heads/main.zip',
7
+ contentFolders: ['sdk7-scene-template-main']
8
+ }
9
+ };
10
+ const get = (scene) => REPOS[scene];
11
+ exports.get = get;
@@ -0,0 +1,30 @@
1
+ import { CliComponents } from '../../components';
2
+ interface Options {
3
+ args: typeof args;
4
+ components: Pick<CliComponents, 'fetch' | 'fs' | 'logger'>;
5
+ }
6
+ export declare const args: import("arg").Result<{
7
+ '--help': BooleanConstructor;
8
+ '--json': BooleanConstructor;
9
+ '-h': string;
10
+ } & {
11
+ '--dir': StringConstructor;
12
+ '--help': BooleanConstructor;
13
+ '--port': NumberConstructor;
14
+ '--no-debug': BooleanConstructor;
15
+ '--no-browser': BooleanConstructor;
16
+ '--no-watch': BooleanConstructor;
17
+ '--ci': BooleanConstructor;
18
+ '--skip-install': BooleanConstructor;
19
+ '--web3': BooleanConstructor;
20
+ '-h': string;
21
+ '-p': string;
22
+ '-d': string;
23
+ '-b': string;
24
+ '-w': string;
25
+ '--skip-build': BooleanConstructor;
26
+ '--desktop-client': BooleanConstructor;
27
+ }>;
28
+ export declare function help(): string;
29
+ export declare function main(options: Options): Promise<void>;
30
+ export {};