@dcl-regenesislabs/sdk-commands 0.0.0-stage → 7.0.0-42707159203.commit-ff138cd

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 (250) hide show
  1. package/.dclrc +19 -0
  2. package/LICENSE +201 -0
  3. package/README.md +106 -2
  4. package/dist/commands/build/index.d.ts +23 -0
  5. package/dist/commands/build/index.js +80 -0
  6. package/dist/commands/build/index.js.map +1 -0
  7. package/dist/commands/code-to-composite/asset-migrator.d.ts +25 -0
  8. package/dist/commands/code-to-composite/asset-migrator.js +238 -0
  9. package/dist/commands/code-to-composite/asset-migrator.js.map +1 -0
  10. package/dist/commands/code-to-composite/code-commenter.d.ts +11 -0
  11. package/dist/commands/code-to-composite/code-commenter.js +87 -0
  12. package/dist/commands/code-to-composite/code-commenter.js.map +1 -0
  13. package/dist/commands/code-to-composite/composite-generator.d.ts +6 -0
  14. package/dist/commands/code-to-composite/composite-generator.js +65 -0
  15. package/dist/commands/code-to-composite/composite-generator.js.map +1 -0
  16. package/dist/commands/code-to-composite/index.d.ts +16 -0
  17. package/dist/commands/code-to-composite/index.js +130 -0
  18. package/dist/commands/code-to-composite/index.js.map +1 -0
  19. package/dist/commands/code-to-composite/name-generator.d.ts +9 -0
  20. package/dist/commands/code-to-composite/name-generator.js +139 -0
  21. package/dist/commands/code-to-composite/name-generator.js.map +1 -0
  22. package/dist/commands/code-to-composite/scene-executor.d.ts +15 -0
  23. package/dist/commands/code-to-composite/scene-executor.js +421 -0
  24. package/dist/commands/code-to-composite/scene-executor.js.map +1 -0
  25. package/dist/commands/deploy/analytics-features.d.ts +4 -0
  26. package/dist/commands/deploy/analytics-features.js +11 -0
  27. package/dist/commands/deploy/analytics-features.js.map +1 -0
  28. package/dist/commands/deploy/deployment.d.ts +51 -0
  29. package/dist/commands/deploy/deployment.js +122 -0
  30. package/dist/commands/deploy/deployment.js.map +1 -0
  31. package/dist/commands/deploy/index.d.ts +37 -0
  32. package/dist/commands/deploy/index.js +312 -0
  33. package/dist/commands/deploy/index.js.map +1 -0
  34. package/dist/commands/deploy/routes.d.ts +27 -0
  35. package/dist/commands/deploy/routes.js +144 -0
  36. package/dist/commands/deploy/routes.js.map +1 -0
  37. package/dist/commands/deploy/state.d.ts +60 -0
  38. package/dist/commands/deploy/state.js +144 -0
  39. package/dist/commands/deploy/state.js.map +1 -0
  40. package/dist/commands/deploy/upload.d.ts +23 -0
  41. package/dist/commands/deploy/upload.js +120 -0
  42. package/dist/commands/deploy/upload.js.map +1 -0
  43. package/dist/commands/deploy/utils.d.ts +131 -0
  44. package/dist/commands/deploy/utils.js +432 -0
  45. package/dist/commands/deploy/utils.js.map +1 -0
  46. package/dist/commands/export-static/index.d.ts +27 -0
  47. package/dist/commands/export-static/index.js +155 -0
  48. package/dist/commands/export-static/index.js.map +1 -0
  49. package/dist/commands/get-context-files/index.d.ts +12 -0
  50. package/dist/commands/get-context-files/index.js +119 -0
  51. package/dist/commands/get-context-files/index.js.map +1 -0
  52. package/dist/commands/init/download-github-folder.d.ts +2 -0
  53. package/dist/commands/init/download-github-folder.js +69 -0
  54. package/dist/commands/init/download-github-folder.js.map +1 -0
  55. package/dist/commands/init/index.d.ts +18 -0
  56. package/dist/commands/init/index.js +98 -0
  57. package/dist/commands/init/index.js.map +1 -0
  58. package/dist/commands/init/project.d.ts +7 -0
  59. package/dist/commands/init/project.js +36 -0
  60. package/dist/commands/init/project.js.map +1 -0
  61. package/dist/commands/init/repos.d.ts +4 -0
  62. package/dist/commands/init/repos.js +21 -0
  63. package/dist/commands/init/repos.js.map +1 -0
  64. package/dist/commands/pack-smart-wearable/index.d.ts +16 -0
  65. package/dist/commands/pack-smart-wearable/index.js +108 -0
  66. package/dist/commands/pack-smart-wearable/index.js.map +1 -0
  67. package/dist/commands/quests/index.d.ts +28 -0
  68. package/dist/commands/quests/index.js +271 -0
  69. package/dist/commands/quests/index.js.map +1 -0
  70. package/dist/commands/quests/types.d.ts +41 -0
  71. package/dist/commands/quests/types.js +3 -0
  72. package/dist/commands/quests/types.js.map +1 -0
  73. package/dist/commands/quests/utils.d.ts +20 -0
  74. package/dist/commands/quests/utils.js +253 -0
  75. package/dist/commands/quests/utils.js.map +1 -0
  76. package/dist/commands/start/data-layer/fs.d.ts +8 -0
  77. package/dist/commands/start/data-layer/fs.js +73 -0
  78. package/dist/commands/start/data-layer/fs.js.map +1 -0
  79. package/dist/commands/start/data-layer/rpc.d.ts +8 -0
  80. package/dist/commands/start/data-layer/rpc.js +54 -0
  81. package/dist/commands/start/data-layer/rpc.js.map +1 -0
  82. package/dist/commands/start/data-layer/ws.d.ts +4 -0
  83. package/dist/commands/start/data-layer/ws.js +17 -0
  84. package/dist/commands/start/data-layer/ws.js.map +1 -0
  85. package/dist/commands/start/explorer-alpha.d.ts +19 -0
  86. package/dist/commands/start/explorer-alpha.js +109 -0
  87. package/dist/commands/start/explorer-alpha.js.map +1 -0
  88. package/dist/commands/start/index.d.ts +46 -0
  89. package/dist/commands/start/index.js +300 -0
  90. package/dist/commands/start/index.js.map +1 -0
  91. package/dist/commands/start/server/endpoints.d.ts +5 -0
  92. package/dist/commands/start/server/endpoints.js +417 -0
  93. package/dist/commands/start/server/endpoints.js.map +1 -0
  94. package/dist/commands/start/server/file-watch-notifier.d.ts +12 -0
  95. package/dist/commands/start/server/file-watch-notifier.js +96 -0
  96. package/dist/commands/start/server/file-watch-notifier.js.map +1 -0
  97. package/dist/commands/start/server/realm.d.ts +7 -0
  98. package/dist/commands/start/server/realm.js +58 -0
  99. package/dist/commands/start/server/realm.js.map +1 -0
  100. package/dist/commands/start/server/routes.d.ts +6 -0
  101. package/dist/commands/start/server/routes.js +77 -0
  102. package/dist/commands/start/server/routes.js.map +1 -0
  103. package/dist/commands/start/server/ws.d.ts +11 -0
  104. package/dist/commands/start/server/ws.js +19 -0
  105. package/dist/commands/start/server/ws.js.map +1 -0
  106. package/dist/commands/start/types.d.ts +16 -0
  107. package/dist/commands/start/types.js +3 -0
  108. package/dist/commands/start/types.js.map +1 -0
  109. package/dist/commands/start/utils.d.ts +8 -0
  110. package/dist/commands/start/utils.js +57 -0
  111. package/dist/commands/start/utils.js.map +1 -0
  112. package/dist/components/analytics.d.ts +105 -0
  113. package/dist/components/analytics.js +76 -0
  114. package/dist/components/analytics.js.map +1 -0
  115. package/dist/components/config.d.ts +18 -0
  116. package/dist/components/config.js +58 -0
  117. package/dist/components/config.js.map +1 -0
  118. package/dist/components/eth.d.ts +2 -0
  119. package/dist/components/eth.js +6 -0
  120. package/dist/components/eth.js.map +1 -0
  121. package/dist/components/exit-signal.d.ts +5 -0
  122. package/dist/components/exit-signal.js +21 -0
  123. package/dist/components/exit-signal.js.map +1 -0
  124. package/dist/components/fetch.d.ts +6 -0
  125. package/dist/components/fetch.js +9 -0
  126. package/dist/components/fetch.js.map +1 -0
  127. package/dist/components/fs.d.ts +18 -0
  128. package/dist/components/fs.js +85 -0
  129. package/dist/components/fs.js.map +1 -0
  130. package/dist/components/index.d.ts +14 -0
  131. package/dist/components/index.js +25 -0
  132. package/dist/components/index.js.map +1 -0
  133. package/dist/components/log.d.ts +24 -0
  134. package/dist/components/log.js +67 -0
  135. package/dist/components/log.js.map +1 -0
  136. package/dist/generated/decentraland/common/border_rect.gen.d.ts +49 -0
  137. package/dist/generated/decentraland/common/border_rect.gen.js +199 -0
  138. package/dist/generated/decentraland/common/border_rect.gen.js.map +1 -0
  139. package/dist/generated/decentraland/common/vectors.gen.d.ts +71 -0
  140. package/dist/generated/decentraland/common/vectors.gen.js +334 -0
  141. package/dist/generated/decentraland/common/vectors.gen.js.map +1 -0
  142. package/dist/generated/decentraland/realm/about.gen.d.ts +229 -0
  143. package/dist/generated/decentraland/realm/about.gen.js +1175 -0
  144. package/dist/generated/decentraland/realm/about.gen.js.map +1 -0
  145. package/dist/generated/decentraland/sdk/development/local_development.gen.d.ts +70 -0
  146. package/dist/generated/decentraland/sdk/development/local_development.gen.js +278 -0
  147. package/dist/generated/decentraland/sdk/development/local_development.gen.js.map +1 -0
  148. package/dist/index.d.ts +2 -0
  149. package/dist/index.js +37 -0
  150. package/dist/index.js.map +1 -0
  151. package/dist/linker-dapp/routes.d.ts +32 -0
  152. package/dist/linker-dapp/routes.js +140 -0
  153. package/dist/linker-dapp/routes.js.map +1 -0
  154. package/dist/locales/en.json +84 -0
  155. package/dist/locales/es.json +84 -0
  156. package/dist/locales/zh.json +84 -0
  157. package/dist/logic/account.d.ts +6 -0
  158. package/dist/logic/account.js +25 -0
  159. package/dist/logic/account.js.map +1 -0
  160. package/dist/logic/args.d.ts +6 -0
  161. package/dist/logic/args.js +25 -0
  162. package/dist/logic/args.js.map +1 -0
  163. package/dist/logic/beautiful-logs.d.ts +14 -0
  164. package/dist/logic/beautiful-logs.js +55 -0
  165. package/dist/logic/beautiful-logs.js.map +1 -0
  166. package/dist/logic/bundle.d.ts +47 -0
  167. package/dist/logic/bundle.js +573 -0
  168. package/dist/logic/bundle.js.map +1 -0
  169. package/dist/logic/catalyst-requests.d.ts +20 -0
  170. package/dist/logic/catalyst-requests.js +54 -0
  171. package/dist/logic/catalyst-requests.js.map +1 -0
  172. package/dist/logic/commands.d.ts +3 -0
  173. package/dist/logic/commands.js +30 -0
  174. package/dist/logic/commands.js.map +1 -0
  175. package/dist/logic/composite.d.ts +15 -0
  176. package/dist/logic/composite.js +105 -0
  177. package/dist/logic/composite.js.map +1 -0
  178. package/dist/logic/config.d.ts +24 -0
  179. package/dist/logic/config.js +88 -0
  180. package/dist/logic/config.js.map +1 -0
  181. package/dist/logic/coordinates.d.ts +14 -0
  182. package/dist/logic/coordinates.js +31 -0
  183. package/dist/logic/coordinates.js.map +1 -0
  184. package/dist/logic/dcl-ignore.d.ts +8 -0
  185. package/dist/logic/dcl-ignore.js +53 -0
  186. package/dist/logic/dcl-ignore.js.map +1 -0
  187. package/dist/logic/debounce.d.ts +1 -0
  188. package/dist/logic/debounce.js +11 -0
  189. package/dist/logic/debounce.js.map +1 -0
  190. package/dist/logic/error.d.ts +7 -0
  191. package/dist/logic/error.js +13 -0
  192. package/dist/logic/error.js.map +1 -0
  193. package/dist/logic/exec.d.ts +12 -0
  194. package/dist/logic/exec.js +40 -0
  195. package/dist/logic/exec.js.map +1 -0
  196. package/dist/logic/fetch.d.ts +25 -0
  197. package/dist/logic/fetch.js +42 -0
  198. package/dist/logic/fetch.js.map +1 -0
  199. package/dist/logic/fs.d.ts +33 -0
  200. package/dist/logic/fs.js +57 -0
  201. package/dist/logic/fs.js.map +1 -0
  202. package/dist/logic/future.d.ts +6 -0
  203. package/dist/logic/future.js +14 -0
  204. package/dist/logic/future.js.map +1 -0
  205. package/dist/logic/get-free-port.d.ts +1 -0
  206. package/dist/logic/get-free-port.js +70 -0
  207. package/dist/logic/get-free-port.js.map +1 -0
  208. package/dist/logic/lang.d.ts +7 -0
  209. package/dist/logic/lang.js +41 -0
  210. package/dist/logic/lang.js.map +1 -0
  211. package/dist/logic/open.d.ts +1 -0
  212. package/dist/logic/open.js +41 -0
  213. package/dist/logic/open.js.map +1 -0
  214. package/dist/logic/portable-experience-sw-validations.d.ts +18 -0
  215. package/dist/logic/portable-experience-sw-validations.js +48 -0
  216. package/dist/logic/portable-experience-sw-validations.js.map +1 -0
  217. package/dist/logic/project-files.d.ts +40 -0
  218. package/dist/logic/project-files.js +158 -0
  219. package/dist/logic/project-files.js.map +1 -0
  220. package/dist/logic/project-validations.d.ts +45 -0
  221. package/dist/logic/project-validations.js +143 -0
  222. package/dist/logic/project-validations.js.map +1 -0
  223. package/dist/logic/promise-utils.d.ts +1 -0
  224. package/dist/logic/promise-utils.js +20 -0
  225. package/dist/logic/promise-utils.js.map +1 -0
  226. package/dist/logic/prompts.d.ts +23 -0
  227. package/dist/logic/prompts.js +74 -0
  228. package/dist/logic/prompts.js.map +1 -0
  229. package/dist/logic/realm.d.ts +3 -0
  230. package/dist/logic/realm.js +32 -0
  231. package/dist/logic/realm.js.map +1 -0
  232. package/dist/logic/runtime-script.d.ts +42 -0
  233. package/dist/logic/runtime-script.js +217 -0
  234. package/dist/logic/runtime-script.js.map +1 -0
  235. package/dist/logic/runtime-script.ts +270 -0
  236. package/dist/logic/scene-validations.d.ts +35 -0
  237. package/dist/logic/scene-validations.js +135 -0
  238. package/dist/logic/scene-validations.js.map +1 -0
  239. package/dist/logic/script-module.d.ts.template +87 -0
  240. package/dist/logic/workspace-validations.d.ts +27 -0
  241. package/dist/logic/workspace-validations.js +136 -0
  242. package/dist/logic/workspace-validations.js.map +1 -0
  243. package/dist/run-command.d.ts +7 -0
  244. package/dist/run-command.js +95 -0
  245. package/dist/run-command.js.map +1 -0
  246. package/dist/run-dapp.d.ts +23 -0
  247. package/dist/run-dapp.js +66 -0
  248. package/dist/run-dapp.js.map +1 -0
  249. package/package.json +74 -3
  250. package/scripts/postinstall.js +17 -0
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.drainResponse = drainResponse;
4
+ exports.withDeadline = withDeadline;
5
+ /**
6
+ * Discards an unread fetch Response body.
7
+ *
8
+ * Native fetch (undici) — used here via the global `fetch`, `undici.fetch`, and the
9
+ * fetch component — keeps the keep-alive socket pinned until the body is consumed or
10
+ * cancelled. Any path that discards a response without reading it (a non-ok early
11
+ * return/throw, or a success branch that only checks the status) must drain it first,
12
+ * or the socket leaks until garbage collection.
13
+ *
14
+ * Typed structurally so it accepts both the global `Response` and `undici.Response`.
15
+ */
16
+ async function drainResponse(response) {
17
+ if (!response.bodyUsed) {
18
+ await response.body?.cancel().catch(() => undefined);
19
+ }
20
+ }
21
+ /**
22
+ * Runs `operation` with a signal aborted after `timeoutMs` or when `signal` aborts, and rejects as soon as it
23
+ * aborts even if the operation doesn't follow it (e.g. a response body that stalls after the headers arrived).
24
+ */
25
+ async function withDeadline(operation, options) {
26
+ const signals = [options.signal, options.timeoutMs !== undefined ? AbortSignal.timeout(options.timeoutMs) : undefined];
27
+ const signal = AbortSignal.any(signals.filter((s) => !!s));
28
+ if (signal.aborted)
29
+ throw signal.reason;
30
+ let onAbort = () => { };
31
+ const aborted = new Promise((_resolve, reject) => {
32
+ onAbort = () => reject(signal.reason);
33
+ signal.addEventListener('abort', onAbort, { once: true });
34
+ });
35
+ try {
36
+ return await Promise.race([operation(signal), aborted]);
37
+ }
38
+ finally {
39
+ signal.removeEventListener('abort', onAbort);
40
+ }
41
+ }
42
+ //# sourceMappingURL=fetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/logic/fetch.ts"],"names":[],"mappings":";;AAWA,sCAOC;AAMD,oCAiBC;AAzCD;;;;;;;;;;GAUG;AACI,KAAK,UAAU,aAAa,CAAC,QAGnC;IACC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACvB,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;IACtD,CAAC;AACH,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,YAAY,CAChC,SAA8C,EAC9C,OAAqD;IAErD,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IACtH,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAoB,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC5E,IAAI,MAAM,CAAC,OAAO;QAAE,MAAM,MAAM,CAAC,MAAM,CAAA;IACvC,IAAI,OAAO,GAAG,GAAG,EAAE,GAAE,CAAC,CAAA;IACtB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE;QACtD,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACrC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IAC3D,CAAC,CAAC,CAAA;IACF,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,CAAA;IACzD,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC9C,CAAC;AACH,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { IFileSystemComponent } from '../components/fs';
2
+ import { IFetchComponent } from '../components/fetch';
3
+ import { CliComponents } from '../components';
4
+ /**
5
+ * Check's if directory is empty
6
+ * @param dir Directory to check for emptyness
7
+ */
8
+ export declare function isDirectoryEmpty(components: {
9
+ fs: IFileSystemComponent;
10
+ }, dir: string): Promise<boolean>;
11
+ /**
12
+ * Download a file
13
+ * @param url URL of the file
14
+ * @param dest Path to where to save the file
15
+ */
16
+ export declare function download(components: {
17
+ fs: IFileSystemComponent;
18
+ fetch: IFetchComponent;
19
+ }, url: string, dest: string): Promise<string>;
20
+ /**
21
+ * Extracts a .zip file
22
+ * @param url Path of the zip file
23
+ * @param dest Path to where to extract the zip file
24
+ */
25
+ export declare function extract(path: string, dest: string): Promise<{
26
+ destPath: string;
27
+ topLevelFolders: string[];
28
+ }>;
29
+ /**
30
+ * Reads a file and parses it's JSON content
31
+ * @param path The path to the subject json file
32
+ */
33
+ export declare function readJson<T>(components: Pick<CliComponents, 'fs'>, path: string): Promise<T>;
@@ -0,0 +1,57 @@
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.isDirectoryEmpty = isDirectoryEmpty;
7
+ exports.download = download;
8
+ exports.extract = extract;
9
+ exports.readJson = readJson;
10
+ const extract_zip_1 = __importDefault(require("extract-zip"));
11
+ const path_1 = require("path");
12
+ /**
13
+ * Check's if directory is empty
14
+ * @param dir Directory to check for emptyness
15
+ */
16
+ async function isDirectoryEmpty(components, dir) {
17
+ const files = await components.fs.readdir(dir);
18
+ return !files.length;
19
+ }
20
+ /**
21
+ * Download a file
22
+ * @param url URL of the file
23
+ * @param dest Path to where to save the file
24
+ */
25
+ async function download(components, url, dest) {
26
+ // we should remove this package and use the native "fetch" when Node
27
+ // releases it as stable: https://nodejs.org/docs/latest-v18.x/api/globals.html#fetch
28
+ const data = await (await components.fetch.fetch(url)).arrayBuffer();
29
+ await components.fs.writeFile(dest, Buffer.from(data));
30
+ return dest;
31
+ }
32
+ /**
33
+ * Extracts a .zip file
34
+ * @param url Path of the zip file
35
+ * @param dest Path to where to extract the zip file
36
+ */
37
+ async function extract(path, dest) {
38
+ const destPath = (0, path_1.resolve)(dest);
39
+ const topLevelFolders = new Set();
40
+ await (0, extract_zip_1.default)((0, path_1.resolve)(path), {
41
+ dir: destPath,
42
+ onEntry(entry, _zipfile) {
43
+ const topLevel = entry.fileName.split('/')[0];
44
+ topLevelFolders.add(topLevel);
45
+ }
46
+ });
47
+ return { destPath, topLevelFolders: Array.from(topLevelFolders) };
48
+ }
49
+ /**
50
+ * Reads a file and parses it's JSON content
51
+ * @param path The path to the subject json file
52
+ */
53
+ async function readJson(components, path) {
54
+ const content = await components.fs.readFile(path, 'utf-8');
55
+ return JSON.parse(content);
56
+ }
57
+ //# sourceMappingURL=fs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/logic/fs.ts"],"names":[],"mappings":";;;;;AAUA,4CAGC;AAOD,4BAUC;AAOD,0BAWC;AAMD,4BAGC;AAzDD,8DAAoC;AACpC,+BAA8B;AAK9B;;;GAGG;AACI,KAAK,UAAU,gBAAgB,CAAC,UAAwC,E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C,IAAI,EAAE,OAAO,CAAC,CAAA;IAC3D,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAM,CAAA;AACjC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export type IFuture<T> = Promise<T> & {
2
+ resolve: (value: T | PromiseLike<T>) => void;
3
+ reject: (reason?: any) => void;
4
+ };
5
+ export declare function future<T = void>(): IFuture<T>;
6
+ export default future;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.future = future;
4
+ function future() {
5
+ let resolve;
6
+ let reject;
7
+ const promise = new Promise((res, rej) => {
8
+ resolve = res;
9
+ reject = rej;
10
+ });
11
+ return Object.assign(promise, { resolve, reject });
12
+ }
13
+ exports.default = future;
14
+ //# sourceMappingURL=future.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"future.js","sourceRoot":"","sources":["../../src/logic/future.ts"],"names":[],"mappings":";;AAKA,wBAQC;AARD,SAAgB,MAAM;IACpB,IAAI,OAA6C,CAAA;IACjD,IAAI,MAA+B,CAAA;IACnC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC1C,OAAO,GAAG,GAAG,CAAA;QACb,MAAM,GAAG,GAAG,CAAA;IACd,CAAC,CAAC,CAAA;IACF,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA;AACpD,CAAC;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1 @@
1
+ export declare function getPort(port: number, failoverPort?: number): Promise<number>;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getPort = getPort;
37
+ const net = __importStar(require("net"));
38
+ // search upward from 8000 (portfinder's contract) so the preview URL stays stable across runs
39
+ const BASE_PORT = 8000;
40
+ const HIGHEST_PORT = 65535;
41
+ function tryListen(port) {
42
+ return new Promise((resolve, reject) => {
43
+ const server = net.createServer();
44
+ server.unref();
45
+ server.once('error', reject);
46
+ // probe the same address the servers bind (HTTP_SERVER_HOST=0.0.0.0): a hostless
47
+ // listen binds the IPv6 wildcard, which on macOS coexists with an IPv4 listener
48
+ // and reports ports as free that the real server then fails to bind (EADDRINUSE)
49
+ server.listen(port, '0.0.0.0', () => {
50
+ const address = server.address();
51
+ server.close(() => resolve(typeof address === 'object' && address ? address.port : port));
52
+ });
53
+ });
54
+ }
55
+ async function getPort(port, failoverPort = 2044) {
56
+ const resolvedPort = port && Number.isInteger(port) ? +port : 0;
57
+ if (!resolvedPort) {
58
+ for (let candidate = BASE_PORT; candidate <= HIGHEST_PORT; candidate++) {
59
+ try {
60
+ return await tryListen(candidate);
61
+ }
62
+ catch {
63
+ // busy, try the next one
64
+ }
65
+ }
66
+ return failoverPort;
67
+ }
68
+ return resolvedPort;
69
+ }
70
+ //# sourceMappingURL=get-free-port.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-free-port.js","sourceRoot":"","sources":["../../src/logic/get-free-port.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,0BAeC;AApCD,yCAA0B;AAE1B,8FAA8F;AAC9F,MAAM,SAAS,GAAG,IAAI,CAAA;AACtB,MAAM,YAAY,GAAG,KAAK,CAAA;AAE1B,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,GAAG,CAAC,YAAY,EAAE,CAAA;QACjC,MAAM,CAAC,KAAK,EAAE,CAAA;QACd,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;QAC5B,iFAAiF;QACjF,gFAAgF;QAChF,iFAAiF;QACjF,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE;YAClC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;YAChC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;QAC3F,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC;AAEM,KAAK,UAAU,OAAO,CAAC,IAAY,EAAE,YAAY,GAAG,IAAI;IAC7D,MAAM,YAAY,GAAG,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IAE/D,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,KAAK,IAAI,SAAS,GAAG,SAAS,EAAE,SAAS,IAAI,YAAY,EAAE,SAAS,EAAE,EAAE,CAAC;YACvE,IAAI,CAAC;gBACH,OAAO,MAAM,SAAS,CAAC,SAAS,CAAC,CAAA;YACnC,CAAC;YAAC,MAAM,CAAC;gBACP,yBAAyB;YAC3B,CAAC;QACH,CAAC;QACD,OAAO,YAAY,CAAA;IACrB,CAAC;IAED,OAAO,YAAY,CAAA;AACrB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare enum Language {
2
+ EN = "en",
3
+ ES = "es",
4
+ ZH = "zh"
5
+ }
6
+ export declare function getLanguage(args: string[]): Language;
7
+ export declare function initLanguage(language: Language): Promise<import("i18next").TFunction<"translation", undefined>>;
@@ -0,0 +1,41 @@
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.Language = void 0;
7
+ exports.getLanguage = getLanguage;
8
+ exports.initLanguage = initLanguage;
9
+ const path_1 = require("path");
10
+ const arg_1 = __importDefault(require("arg"));
11
+ const i18next_1 = __importDefault(require("i18next"));
12
+ const i18next_fs_backend_1 = __importDefault(require("i18next-fs-backend"));
13
+ var Language;
14
+ (function (Language) {
15
+ Language["EN"] = "en";
16
+ Language["ES"] = "es";
17
+ Language["ZH"] = "zh";
18
+ })(Language || (exports.Language = Language = {}));
19
+ function getLanguage(args) {
20
+ try {
21
+ const language = (0, arg_1.default)({ '--language': String }, { permissive: true, argv: args })['--language'];
22
+ return Language[language?.toUpperCase()] || Language.EN;
23
+ }
24
+ catch (e) {
25
+ return Language.EN;
26
+ }
27
+ }
28
+ function initLanguage(language) {
29
+ return i18next_1.default.use(i18next_fs_backend_1.default).init({
30
+ lng: language,
31
+ fallbackLng: 'en',
32
+ showSupportNotice: false,
33
+ interpolation: {
34
+ escapeValue: false
35
+ },
36
+ backend: {
37
+ loadPath: (0, path_1.join)(__dirname, '../locales/{{lng}}.json')
38
+ },
39
+ });
40
+ }
41
+ //# sourceMappingURL=lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lang.js","sourceRoot":"","sources":["../../src/logic/lang.ts"],"names":[],"mappings":";;;;;;AAWA,kCAOC;AAED,oCAYC;AAhCD,+BAA2B;AAC3B,8CAAqB;AACrB,sDAA6B;AAC7B,4EAAwC;AAExC,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,qBAAS,CAAA;IACT,qBAAS,CAAA;IACT,qBAAS,CAAA;AACX,CAAC,EAJW,QAAQ,wBAAR,QAAQ,QAInB;AAED,SAAgB,WAAW,CAAC,IAAc;IACxC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAA,aAAG,EAAC,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC,CAAA;QAC9F,OAAO,QAAQ,CAAC,QAAQ,EAAE,WAAW,EAA2B,CAAC,IAAI,QAAQ,CAAC,EAAE,CAAA;IAClF,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,QAAQ,CAAC,EAAE,CAAA;IACpB,CAAC;AACH,CAAC;AAED,SAAgB,YAAY,CAAC,QAAkB;IAC7C,OAAO,iBAAO,CAAC,GAAG,CAAC,4BAAO,CAAC,CAAC,IAAI,CAAC;QAC/B,GAAG,EAAE,QAAQ;QACb,WAAW,EAAE,IAAI;QACjB,iBAAiB,EAAE,KAAK;QACxB,aAAa,EAAE;YACb,WAAW,EAAE,KAAK;SACnB;QACD,OAAO,EAAE;YACP,QAAQ,EAAE,IAAA,WAAI,EAAC,SAAS,EAAE,yBAAyB,CAAC;SACrD;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1 @@
1
+ export default function open(target: string): Promise<void>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = open;
4
+ const child_process_1 = require("child_process");
5
+ const os_1 = require("os");
6
+ function isWsl() {
7
+ return process.platform === 'linux' && (0, os_1.release)().toLowerCase().includes('microsoft');
8
+ }
9
+ async function open(target) {
10
+ const protocol = new URL(target).protocol;
11
+ if (protocol !== 'http:' && protocol !== 'https:') {
12
+ throw new Error(`Refusing to open non-http(s) URL: ${target}`);
13
+ }
14
+ const spawnOptions = { stdio: 'ignore', detached: true };
15
+ let command;
16
+ let args;
17
+ if (process.platform === 'darwin') {
18
+ command = 'open';
19
+ args = [target];
20
+ }
21
+ else if (process.platform === 'win32') {
22
+ // libuv's CRT-style quoting mangles the '""' title arg, so hand cmd the exact line
23
+ command = 'cmd';
24
+ args = ['/c', `start "" "${target}"`];
25
+ spawnOptions.windowsVerbatimArguments = true;
26
+ }
27
+ else if (isWsl()) {
28
+ command = 'cmd.exe';
29
+ args = ['/c', 'start', '""', target.replace(/&/g, '^&')];
30
+ }
31
+ else {
32
+ command = 'xdg-open';
33
+ args = [target];
34
+ }
35
+ const child = (0, child_process_1.spawn)(command, args, spawnOptions);
36
+ // opening the browser is best-effort: without this handler a missing
37
+ // xdg-open/open/cmd (headless, containers) crashes the CLI
38
+ child.on('error', () => { });
39
+ child.unref();
40
+ }
41
+ //# sourceMappingURL=open.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open.js","sourceRoot":"","sources":["../../src/logic/open.ts"],"names":[],"mappings":";;AAOA,uBA4BC;AAnCD,iDAAmD;AACnD,2BAA4B;AAE5B,SAAS,KAAK;IACZ,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,IAAA,YAAO,GAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;AACtF,CAAC;AAEc,KAAK,UAAU,IAAI,CAAC,MAAc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EAAE,CAAA;AACf,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { Scene } from '@dcl/schemas';
2
+ import { CliComponents } from '../components';
3
+ export interface IFile {
4
+ path: string;
5
+ content: Buffer;
6
+ size: number;
7
+ }
8
+ export declare const SMART_WEARABLE_FILE = "wearable.json";
9
+ /**
10
+ * Composes the path to the `scene.json` file based on the provided path.
11
+ * @param projectRoot The path to the directory containing the scene file.
12
+ */
13
+ export declare function getSmartWearableFile(projectRoot: string): string;
14
+ export declare function assertValidSmartWearable(scene: Scene): boolean;
15
+ /**
16
+ * Get valid Scene JSON
17
+ */
18
+ export declare function getValidWearableJson(components: Pick<CliComponents, 'fs' | 'logger'>, projectRoot: string): Promise<Scene>;
@@ -0,0 +1,48 @@
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.SMART_WEARABLE_FILE = void 0;
7
+ exports.getSmartWearableFile = getSmartWearableFile;
8
+ exports.assertValidSmartWearable = assertValidSmartWearable;
9
+ exports.getValidWearableJson = getValidWearableJson;
10
+ const path_1 = require("path");
11
+ const schemas_1 = require("@dcl/schemas");
12
+ const i18next_1 = __importDefault(require("i18next"));
13
+ const error_1 = require("./error");
14
+ exports.SMART_WEARABLE_FILE = 'wearable.json';
15
+ /**
16
+ * Composes the path to the `scene.json` file based on the provided path.
17
+ * @param projectRoot The path to the directory containing the scene file.
18
+ */
19
+ function getSmartWearableFile(projectRoot) {
20
+ return (0, path_1.resolve)(projectRoot, exports.SMART_WEARABLE_FILE);
21
+ }
22
+ function assertValidSmartWearable(scene) {
23
+ if (!schemas_1.Scene.validate(scene)) {
24
+ const errors = [];
25
+ if (schemas_1.Scene.validate.errors) {
26
+ for (const error of schemas_1.Scene.validate.errors) {
27
+ errors.push(`Error validating scene.json: ${error.message}`);
28
+ }
29
+ }
30
+ throw new error_1.CliError('PORTABLE_EXPERIENCE_SW_INVALID_SCENE_JSON', i18next_1.default.t('errors.portable_experience_sw_validations.invalid_scene_json', { errors: errors.join('\n') }));
31
+ }
32
+ // TODO
33
+ return true;
34
+ }
35
+ /**
36
+ * Get valid Scene JSON
37
+ */
38
+ async function getValidWearableJson(components, projectRoot) {
39
+ try {
40
+ const wearableJsonRaw = await components.fs.readFile(getSmartWearableFile(projectRoot), 'utf8');
41
+ const wearableJson = JSON.parse(wearableJsonRaw);
42
+ return wearableJson;
43
+ }
44
+ catch (err) {
45
+ throw new error_1.CliError('PORTABLE_EXPERIENCE_SW_INVALID_SCENE_JSON', i18next_1.default.t('errors.portable_experience_sw_validations.invalid_scene_json', { errors: err.message }));
46
+ }
47
+ }
48
+ //# sourceMappingURL=portable-experience-sw-validations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portable-experience-sw-validations.js","sourceRoot":"","sources":["../../src/logic/portable-experience-sw-validations.ts"],"names":[],"mappings":";;;;;;AAkBA,oDAEC;AAED,4DAeC;AAKD,oDAcC;AAxDD,+BAA8B;AAC9B,0CAAoC;AACpC,sDAA6B;AAE7B,mCAAkC;AAQrB,QAAA,mBAAmB,GAAG,eAAe,CAAA;AAElD;;;GAGG;AACH,SAAgB,oBAAoB,CAAC,WAAmB;IACtD,OAAO,IAAA,cAAO,EAAC,WAAW,EAAE,2BAAmB,CAAC,CAAA;AAClD,CAAC;AAED,SAAgB,wBAAwB,CAAC,KAAY;IACnD,IAAI,CAAC,eAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAa,EAAE,CAAA;QAC3B,IAAI,eAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YAC1B,KAAK,MAAM,KAAK,IAAI,eAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;gBAC1C,MAAM,CAAC,IAAI,CAAC,gCAAgC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YAC9D,CAAC;QACH,CAAC;QACD,MAAM,IAAI,gBAAQ,CAChB,2CAA2C,EAC3C,iBAAO,CAAC,CAAC,CAAC,8DAA8D,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CACzG,CAAA;IACH,CAAC;IACD,OAAO;IACP,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,oBAAoB,CACxC,UAAgD,EAChD,WAAmB;IAEnB,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,MAAM,UAAU,CAAC,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,CAAA;QAC/F,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAU,CAAA;QACzD,OAAO,YAAY,CAAA;IACrB,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,MAAM,IAAI,gBAAQ,CAChB,2CAA2C,EAC3C,iBAAO,CAAC,CAAC,CAAC,8DAA8D,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CACnG,CAAA;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { ContentMapping } from '@dcl/schemas/dist/misc/content-mapping';
2
+ import { CliComponents } from '../components';
3
+ export type ProjectFile = {
4
+ absolutePath: string;
5
+ hash: string;
6
+ };
7
+ /**
8
+ * Returns an array of the publishable files for a given folder.
9
+ *
10
+ */
11
+ export declare function getPublishableFiles(components: Pick<CliComponents, 'fs'>, projectRoot: string): Promise<Array<string>>;
12
+ /**
13
+ * This function converts paths to decentraland-compatible paths.
14
+ * - From windows separators to unix separators.
15
+ * - All to lowercase
16
+ */
17
+ export declare function normalizeDecentralandFilename(projectRoot: string, filename: string): string;
18
+ /**
19
+ * This function normalizes the content mappings of a project to be used by the
20
+ * Decentraland file system
21
+ */
22
+ export declare function projectFilesToContentMappings(projectRoot: string, files: ProjectFile[]): ContentMapping[];
23
+ /**
24
+ * Returns the content mappings for a specific project folder.
25
+ * NOTE: the result of this function IS NOT NORMALIZED. Paths sould be normalized
26
+ * with normalizeDecentralandFilename before usage
27
+ *
28
+ * TODO: Unit test this function
29
+ */
30
+ export declare function getProjectPublishableFilesWithHashes(components: Pick<CliComponents, 'fs'>, projectRoot: string, hashingFunction: (filePath: string) => Promise<string>): Promise<ProjectFile[]>;
31
+ export declare const machineId: string;
32
+ export declare const b64HashingFunction: (str: string) => string;
33
+ export declare const b64ContentVersionedHashingFunction: (str: string, mtimeMs: number) => string;
34
+ export declare const b64HashDecodingFunction: (hash: string) => string;
35
+ interface PackageJson {
36
+ dependencies: Record<string, string>;
37
+ devDependencies: Record<string, string>;
38
+ }
39
+ export declare function getPackageJson(components: Pick<CliComponents, 'fs'>, projectRoot: string): Promise<PackageJson>;
40
+ export {};
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.b64HashDecodingFunction = exports.b64ContentVersionedHashingFunction = exports.b64HashingFunction = exports.machineId = void 0;
40
+ exports.getPublishableFiles = getPublishableFiles;
41
+ exports.normalizeDecentralandFilename = normalizeDecentralandFilename;
42
+ exports.projectFilesToContentMappings = projectFilesToContentMappings;
43
+ exports.getProjectPublishableFilesWithHashes = getProjectPublishableFilesWithHashes;
44
+ exports.getPackageJson = getPackageJson;
45
+ const dcl_ignore_1 = require("./dcl-ignore");
46
+ const fs_1 = require("fs");
47
+ const ignore_1 = __importDefault(require("ignore"));
48
+ const i18next_1 = __importDefault(require("i18next"));
49
+ const os_1 = __importDefault(require("os"));
50
+ const path_1 = __importStar(require("path"));
51
+ const error_1 = require("./error");
52
+ const promise_utils_1 = require("./promise-utils");
53
+ /**
54
+ * Returns an array of the publishable files for a given folder.
55
+ *
56
+ */
57
+ async function getPublishableFiles(components, projectRoot) {
58
+ const ignorePatterns = await (0, dcl_ignore_1.getDCLIgnorePatterns)(components, projectRoot);
59
+ const ig = (0, ignore_1.default)().add(ignorePatterns);
60
+ const allFiles = (0, fs_1.globSync)('**/*', {
61
+ cwd: projectRoot,
62
+ // prune walking into trees ig.filter below always excludes anyway (perf only;
63
+ // exclude receives a string on some Node versions and a Dirent on others)
64
+ exclude: (entry) => {
65
+ const name = typeof entry === 'string' ? path_1.default.basename(entry) : entry.name;
66
+ return name.startsWith('.') || name === 'node_modules';
67
+ }
68
+ });
69
+ return ig.filter(allFiles).filter((file) => (0, fs_1.statSync)((0, path_1.resolve)(projectRoot, file)).isFile());
70
+ }
71
+ /**
72
+ * This function converts paths to decentraland-compatible paths.
73
+ * - From windows separators to unix separators.
74
+ * - All to lowercase
75
+ */
76
+ function normalizeDecentralandFilename(projectRoot, filename) {
77
+ const newAbsolute = path_1.default.resolve(projectRoot, filename);
78
+ const relativePath = path_1.default.relative(projectRoot, newAbsolute);
79
+ // 1. win->unix style
80
+ // 2. remove heading /
81
+ return relativePath.replace(/(\\)/g, '/').replace(/^\/+/, '').toLowerCase();
82
+ }
83
+ /**
84
+ * This function normalizes the content mappings of a project to be used by the
85
+ * Decentraland file system
86
+ */
87
+ function projectFilesToContentMappings(projectRoot, files) {
88
+ return files.map((file) => {
89
+ return {
90
+ file: normalizeDecentralandFilename(projectRoot, file.absolutePath),
91
+ hash: file.hash
92
+ };
93
+ });
94
+ }
95
+ /**
96
+ * Returns the content mappings for a specific project folder.
97
+ * NOTE: the result of this function IS NOT NORMALIZED. Paths sould be normalized
98
+ * with normalizeDecentralandFilename before usage
99
+ *
100
+ * TODO: Unit test this function
101
+ */
102
+ async function getProjectPublishableFilesWithHashes(components, projectRoot, hashingFunction) {
103
+ const projectFiles = await getPublishableFiles(components, projectRoot);
104
+ const existingFiles = (await (0, promise_utils_1.concurrentMap)(projectFiles, async (file) => {
105
+ const absolutePath = path_1.default.resolve(projectRoot, file);
106
+ return (await components.fs.fileExists(absolutePath)) ? { file, absolutePath } : null;
107
+ })).filter((file) => file !== null);
108
+ const usedFilenames = new Set();
109
+ for (const { file } of existingFiles) {
110
+ const normalizedFile = normalizeDecentralandFilename(projectRoot, file);
111
+ /* istanbul ignore if */
112
+ if (usedFilenames.has(normalizedFile)) {
113
+ throw new error_1.CliError('PROJECT_FILES_DUPLICATE_FILE', i18next_1.default.t('errors.project_files.duplicate_file', { file }));
114
+ }
115
+ usedFilenames.add(normalizedFile);
116
+ }
117
+ return (0, promise_utils_1.concurrentMap)(existingFiles, async ({ absolutePath }) => {
118
+ return {
119
+ absolutePath,
120
+ hash: await hashingFunction(absolutePath)
121
+ };
122
+ });
123
+ }
124
+ exports.machineId = os_1.default.hostname() || os_1.default.userInfo().username;
125
+ const b64HashingFunction = (str) => {
126
+ const unique = `${str}-${exports.machineId}`;
127
+ return 'b64-' + Buffer.from(unique).toString('base64');
128
+ };
129
+ exports.b64HashingFunction = b64HashingFunction;
130
+ // Content-versioned variant for preview file ids: embeds the file's mtime so the id — and any URL
131
+ // or client cache key derived from it — changes whenever the file changes, while staying decodable
132
+ // back to the path. NUL separates the path from the version; file paths cannot contain NUL bytes.
133
+ const b64ContentVersionedHashingFunction = (str, mtimeMs) => {
134
+ const unique = `${str}\u0000${Math.trunc(mtimeMs)}-${exports.machineId}`;
135
+ return 'b64-' + Buffer.from(unique).toString('base64');
136
+ };
137
+ exports.b64ContentVersionedHashingFunction = b64ContentVersionedHashingFunction;
138
+ // Decodes a `b64-` preview id back to its absolute path, stripping the machineId suffix and, when
139
+ // present, the NUL-separated mtime version segment. Accepts both plain and content-versioned ids.
140
+ const b64HashDecodingFunction = (hash) => {
141
+ const decoded = Buffer.from(hash.replace(/^b64-/, ''), 'base64').toString('utf8');
142
+ const withoutMachineId = decoded.slice(0, -(exports.machineId.length + 1));
143
+ const versionSeparator = withoutMachineId.indexOf('\u0000');
144
+ return versionSeparator === -1 ? withoutMachineId : withoutMachineId.slice(0, versionSeparator);
145
+ };
146
+ exports.b64HashDecodingFunction = b64HashDecodingFunction;
147
+ /* istanbul ignore next */
148
+ async function getPackageJson(components, projectRoot) {
149
+ try {
150
+ const packageJsonRaw = await components.fs.readFile((0, path_1.resolve)(projectRoot, 'package.json'), 'utf8');
151
+ const packageJson = JSON.parse(packageJsonRaw);
152
+ return packageJson;
153
+ }
154
+ catch (err) {
155
+ throw new error_1.CliError('PROJECT_FILES_INVALID_PACKAGE_JSON', i18next_1.default.t('errors.project_files.invalid_package_json', { error: err.message }));
156
+ }
157
+ }
158
+ //# sourceMappingURL=project-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-files.js","sourceRoot":"","sources":["../../src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