@squiz/dxp-cli-next 5.33.0-develop.1 → 5.33.0-develop.11

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 (370) hide show
  1. package/README.md +1 -0
  2. package/bin/dxp.js +6 -1
  3. package/dist/dxp.js +4480 -0
  4. package/package.json +36 -30
  5. package/lib/ApiService.d.ts +0 -39
  6. package/lib/ApiService.js +0 -120
  7. package/lib/ApiService.spec.d.ts +0 -1
  8. package/lib/ApiService.spec.js +0 -182
  9. package/lib/ApplicationConfig.d.ts +0 -7
  10. package/lib/ApplicationConfig.js +0 -38
  11. package/lib/ApplicationConfig.spec.d.ts +0 -1
  12. package/lib/ApplicationConfig.spec.js +0 -84
  13. package/lib/ApplicationStore.d.ts +0 -13
  14. package/lib/ApplicationStore.js +0 -53
  15. package/lib/__tests__/cmp/dev-mode.spec.d.ts +0 -1
  16. package/lib/__tests__/cmp/dev-mode.spec.js +0 -54
  17. package/lib/__tests__/helpers.d.ts +0 -17
  18. package/lib/__tests__/helpers.js +0 -54
  19. package/lib/__tests__/integration/main.spec.d.ts +0 -1
  20. package/lib/__tests__/integration/main.spec.js +0 -45
  21. package/lib/__tests__/smoke/validate.spec.d.ts +0 -1
  22. package/lib/__tests__/smoke/validate.spec.js +0 -37
  23. package/lib/__tests__/unit/cli.d.ts +0 -0
  24. package/lib/__tests__/unit/cli.js +0 -7
  25. package/lib/auth/index.d.ts +0 -3
  26. package/lib/auth/index.js +0 -14
  27. package/lib/auth/login/login.d.ts +0 -22
  28. package/lib/auth/login/login.js +0 -268
  29. package/lib/auth/login/login.spec.d.ts +0 -1
  30. package/lib/auth/login/login.spec.js +0 -179
  31. package/lib/auth/logout/logout.d.ts +0 -3
  32. package/lib/auth/logout/logout.js +0 -115
  33. package/lib/auth/logout/logout.spec.d.ts +0 -1
  34. package/lib/auth/logout/logout.spec.js +0 -67
  35. package/lib/cdp/constants.d.ts +0 -1
  36. package/lib/cdp/constants.js +0 -4
  37. package/lib/cdp/index.d.ts +0 -3
  38. package/lib/cdp/index.js +0 -16
  39. package/lib/cdp/instance/activate/activate.d.ts +0 -5
  40. package/lib/cdp/instance/activate/activate.js +0 -107
  41. package/lib/cdp/instance/activate/activate.spec.d.ts +0 -1
  42. package/lib/cdp/instance/activate/activate.spec.js +0 -274
  43. package/lib/cdp/instance/instanceCommand.d.ts +0 -3
  44. package/lib/cdp/instance/instanceCommand.js +0 -15
  45. package/lib/cdp/schema/deploy/deploy.const.d.ts +0 -5
  46. package/lib/cdp/schema/deploy/deploy.const.js +0 -8
  47. package/lib/cdp/schema/deploy/deploy.d.ts +0 -4
  48. package/lib/cdp/schema/deploy/deploy.js +0 -107
  49. package/lib/cdp/schema/deploy/deploy.spec.d.ts +0 -1
  50. package/lib/cdp/schema/deploy/deploy.spec.js +0 -137
  51. package/lib/cdp/schema/schemaCommand.d.ts +0 -3
  52. package/lib/cdp/schema/schemaCommand.js +0 -15
  53. package/lib/cdp/utils.d.ts +0 -23
  54. package/lib/cdp/utils.js +0 -133
  55. package/lib/cmp/deploy.d.ts +0 -3
  56. package/lib/cmp/deploy.js +0 -124
  57. package/lib/cmp/dev-mode-ui.d.ts +0 -4
  58. package/lib/cmp/dev-mode-ui.js +0 -51
  59. package/lib/cmp/dev-mode.d.ts +0 -4
  60. package/lib/cmp/dev-mode.js +0 -58
  61. package/lib/cmp/edge-components/compiler.d.ts +0 -13
  62. package/lib/cmp/edge-components/compiler.js +0 -55
  63. package/lib/cmp/index.d.ts +0 -3
  64. package/lib/cmp/index.js +0 -18
  65. package/lib/cmp/init.d.ts +0 -3
  66. package/lib/cmp/init.js +0 -105
  67. package/lib/cmp/utils/definitions.d.ts +0 -481
  68. package/lib/cmp/utils/definitions.js +0 -262
  69. package/lib/cmp/utils/definitions.spec.d.ts +0 -1
  70. package/lib/cmp/utils/definitions.spec.js +0 -503
  71. package/lib/constants.d.ts +0 -1
  72. package/lib/constants.js +0 -4
  73. package/lib/datastore/blueprint/add/add.d.ts +0 -3
  74. package/lib/datastore/blueprint/add/add.js +0 -119
  75. package/lib/datastore/blueprint/add/add.spec.d.ts +0 -1
  76. package/lib/datastore/blueprint/add/add.spec.js +0 -134
  77. package/lib/datastore/blueprint/blueprintCommand.d.ts +0 -3
  78. package/lib/datastore/blueprint/blueprintCommand.js +0 -21
  79. package/lib/datastore/blueprint/list/list.d.ts +0 -3
  80. package/lib/datastore/blueprint/list/list.js +0 -76
  81. package/lib/datastore/blueprint/list/list.spec.d.ts +0 -1
  82. package/lib/datastore/blueprint/list/list.spec.js +0 -51
  83. package/lib/datastore/blueprint/rename/rename.d.ts +0 -3
  84. package/lib/datastore/blueprint/rename/rename.js +0 -93
  85. package/lib/datastore/blueprint/rename/rename.spec.d.ts +0 -1
  86. package/lib/datastore/blueprint/rename/rename.spec.js +0 -142
  87. package/lib/datastore/blueprint/update/update.d.ts +0 -3
  88. package/lib/datastore/blueprint/update/update.js +0 -89
  89. package/lib/datastore/blueprint/update/update.spec.d.ts +0 -1
  90. package/lib/datastore/blueprint/update/update.spec.js +0 -99
  91. package/lib/datastore/bundle/bundle.d.ts +0 -3
  92. package/lib/datastore/bundle/bundle.js +0 -176
  93. package/lib/datastore/bundle/bundle.spec.d.ts +0 -1
  94. package/lib/datastore/bundle/bundle.spec.js +0 -94
  95. package/lib/datastore/index.d.ts +0 -3
  96. package/lib/datastore/index.js +0 -16
  97. package/lib/datastore/simulator/add/add.d.ts +0 -3
  98. package/lib/datastore/simulator/add/add.js +0 -125
  99. package/lib/datastore/simulator/add/add.spec.d.ts +0 -1
  100. package/lib/datastore/simulator/add/add.spec.js +0 -114
  101. package/lib/datastore/simulator/clear/clear.d.ts +0 -3
  102. package/lib/datastore/simulator/clear/clear.js +0 -70
  103. package/lib/datastore/simulator/clear/clear.spec.d.ts +0 -1
  104. package/lib/datastore/simulator/clear/clear.spec.js +0 -224
  105. package/lib/datastore/simulator/list/list.d.ts +0 -3
  106. package/lib/datastore/simulator/list/list.js +0 -115
  107. package/lib/datastore/simulator/list/list.spec.d.ts +0 -1
  108. package/lib/datastore/simulator/list/list.spec.js +0 -95
  109. package/lib/datastore/simulator/pause/pause.d.ts +0 -3
  110. package/lib/datastore/simulator/pause/pause.js +0 -84
  111. package/lib/datastore/simulator/pause/pause.spec.d.ts +0 -1
  112. package/lib/datastore/simulator/pause/pause.spec.js +0 -90
  113. package/lib/datastore/simulator/remove/remove.d.ts +0 -3
  114. package/lib/datastore/simulator/remove/remove.js +0 -68
  115. package/lib/datastore/simulator/remove/remove.spec.d.ts +0 -1
  116. package/lib/datastore/simulator/remove/remove.spec.js +0 -224
  117. package/lib/datastore/simulator/resume/resume.d.ts +0 -3
  118. package/lib/datastore/simulator/resume/resume.js +0 -84
  119. package/lib/datastore/simulator/resume/resume.spec.d.ts +0 -1
  120. package/lib/datastore/simulator/resume/resume.spec.js +0 -90
  121. package/lib/datastore/simulator/simulatorCommand.d.ts +0 -3
  122. package/lib/datastore/simulator/simulatorCommand.js +0 -27
  123. package/lib/datastore/simulator/upgrade/upgrade.d.ts +0 -3
  124. package/lib/datastore/simulator/upgrade/upgrade.js +0 -157
  125. package/lib/datastore/simulator/upgrade/upgrade.spec.d.ts +0 -1
  126. package/lib/datastore/simulator/upgrade/upgrade.spec.js +0 -199
  127. package/lib/datastore/simulator/utils.d.ts +0 -29
  128. package/lib/datastore/simulator/utils.js +0 -218
  129. package/lib/datastore/simulator/utils.spec.d.ts +0 -1
  130. package/lib/datastore/simulator/utils.spec.js +0 -201
  131. package/lib/datastore/utils.d.ts +0 -20
  132. package/lib/datastore/utils.js +0 -241
  133. package/lib/datastore/utils.spec.d.ts +0 -1
  134. package/lib/datastore/utils.spec.js +0 -113
  135. package/lib/dxp.d.ts +0 -1
  136. package/lib/dxp.js +0 -57
  137. package/lib/job-runner/index.d.ts +0 -3
  138. package/lib/job-runner/index.js +0 -22
  139. package/lib/job-runner/job/listJobs/listJobs.d.ts +0 -3
  140. package/lib/job-runner/job/listJobs/listJobs.js +0 -66
  141. package/lib/job-runner/job/listJobs/listJobs.spec.d.ts +0 -1
  142. package/lib/job-runner/job/listJobs/listJobs.spec.js +0 -42
  143. package/lib/job-runner/job/uploadJob/uploadJob.d.ts +0 -3
  144. package/lib/job-runner/job/uploadJob/uploadJob.js +0 -56
  145. package/lib/job-runner/job/uploadJob/uploadJob.spec.d.ts +0 -1
  146. package/lib/job-runner/job/uploadJob/uploadJob.spec.js +0 -42
  147. package/lib/job-runner/jobContext/listJobContexts.d.ts +0 -3
  148. package/lib/job-runner/jobContext/listJobContexts.js +0 -66
  149. package/lib/job-runner/jobContext/listJobContexts.spec.d.ts +0 -1
  150. package/lib/job-runner/jobContext/listJobContexts.spec.js +0 -58
  151. package/lib/job-runner/jobExecution/beginJob/beginJob.d.ts +0 -3
  152. package/lib/job-runner/jobExecution/beginJob/beginJob.js +0 -68
  153. package/lib/job-runner/jobExecution/beginJob/beginJob.spec.d.ts +0 -1
  154. package/lib/job-runner/jobExecution/beginJob/beginJob.spec.js +0 -62
  155. package/lib/job-runner/jobExecution/listJobExecutions/listJobExecutions.d.ts +0 -3
  156. package/lib/job-runner/jobExecution/listJobExecutions/listJobExecutions.js +0 -67
  157. package/lib/job-runner/jobExecution/listJobExecutions/listJobExecutions.spec.d.ts +0 -1
  158. package/lib/job-runner/jobExecution/listJobExecutions/listJobExecutions.spec.js +0 -64
  159. package/lib/job-runner/jobExecution/terminateJob/terminateJob.d.ts +0 -3
  160. package/lib/job-runner/jobExecution/terminateJob/terminateJob.js +0 -64
  161. package/lib/job-runner/jobExecution/terminateJob/terminateJob.spec.d.ts +0 -1
  162. package/lib/job-runner/jobExecution/terminateJob/terminateJob.spec.js +0 -61
  163. package/lib/job-runner/utils.d.ts +0 -19
  164. package/lib/job-runner/utils.js +0 -145
  165. package/lib/job-runner/utils.spec.d.ts +0 -1
  166. package/lib/job-runner/utils.spec.js +0 -116
  167. package/lib/migration/create/create.d.ts +0 -3
  168. package/lib/migration/create/create.js +0 -56
  169. package/lib/migration/create/create.spec.d.ts +0 -1
  170. package/lib/migration/create/create.spec.js +0 -280
  171. package/lib/migration/get/get.d.ts +0 -3
  172. package/lib/migration/get/get.js +0 -46
  173. package/lib/migration/get/get.spec.d.ts +0 -1
  174. package/lib/migration/get/get.spec.js +0 -287
  175. package/lib/migration/index.d.ts +0 -3
  176. package/lib/migration/index.js +0 -24
  177. package/lib/migration/list/list.d.ts +0 -3
  178. package/lib/migration/list/list.js +0 -45
  179. package/lib/migration/list/list.spec.d.ts +0 -1
  180. package/lib/migration/list/list.spec.js +0 -138
  181. package/lib/migration/next/next.d.ts +0 -3
  182. package/lib/migration/next/next.js +0 -75
  183. package/lib/migration/next/next.spec.d.ts +0 -1
  184. package/lib/migration/next/next.spec.js +0 -253
  185. package/lib/migration/pre/pre.d.ts +0 -3
  186. package/lib/migration/pre/pre.js +0 -54
  187. package/lib/migration/pre/pre.spec.d.ts +0 -1
  188. package/lib/migration/pre/pre.spec.js +0 -269
  189. package/lib/migration/revert/revert.d.ts +0 -3
  190. package/lib/migration/revert/revert.js +0 -47
  191. package/lib/migration/revert/revert.spec.d.ts +0 -1
  192. package/lib/migration/revert/revert.spec.js +0 -153
  193. package/lib/migration/settings/settings.d.ts +0 -3
  194. package/lib/migration/settings/settings.js +0 -63
  195. package/lib/migration/settings/settings.spec.d.ts +0 -1
  196. package/lib/migration/settings/settings.spec.js +0 -339
  197. package/lib/migration/types/common.types.d.ts +0 -29
  198. package/lib/migration/types/common.types.js +0 -2
  199. package/lib/migration/types/createMigration.types.d.ts +0 -10
  200. package/lib/migration/types/createMigration.types.js +0 -2
  201. package/lib/migration/types/getMigration.types.d.ts +0 -5
  202. package/lib/migration/types/getMigration.types.js +0 -2
  203. package/lib/migration/types/index.d.ts +0 -7
  204. package/lib/migration/types/index.js +0 -23
  205. package/lib/migration/types/listMigrations.types.d.ts +0 -2
  206. package/lib/migration/types/listMigrations.types.js +0 -2
  207. package/lib/migration/types/nextStage.types.d.ts +0 -10
  208. package/lib/migration/types/nextStage.types.js +0 -2
  209. package/lib/migration/types/preMigration.types.d.ts +0 -10
  210. package/lib/migration/types/preMigration.types.js +0 -2
  211. package/lib/migration/types/revert.types.d.ts +0 -6
  212. package/lib/migration/types/revert.types.js +0 -2
  213. package/lib/migration/types/settings.types.d.ts +0 -15
  214. package/lib/migration/types/settings.types.js +0 -2
  215. package/lib/migration/utils/common.d.ts +0 -39
  216. package/lib/migration/utils/common.js +0 -134
  217. package/lib/migration/utils/common.spec.d.ts +0 -1
  218. package/lib/migration/utils/common.spec.js +0 -165
  219. package/lib/migration/utils/createMigration.d.ts +0 -33
  220. package/lib/migration/utils/createMigration.js +0 -125
  221. package/lib/migration/utils/createMigration.spec.d.ts +0 -1
  222. package/lib/migration/utils/createMigration.spec.js +0 -259
  223. package/lib/migration/utils/getMigration.d.ts +0 -2
  224. package/lib/migration/utils/getMigration.js +0 -41
  225. package/lib/migration/utils/getMigration.spec.d.ts +0 -1
  226. package/lib/migration/utils/getMigration.spec.js +0 -156
  227. package/lib/migration/utils/index.d.ts +0 -9
  228. package/lib/migration/utils/index.js +0 -25
  229. package/lib/migration/utils/listMigrations.d.ts +0 -3
  230. package/lib/migration/utils/listMigrations.js +0 -41
  231. package/lib/migration/utils/listMigrations.spec.d.ts +0 -1
  232. package/lib/migration/utils/listMigrations.spec.js +0 -108
  233. package/lib/migration/utils/loadCctIdsFromFile.d.ts +0 -1
  234. package/lib/migration/utils/loadCctIdsFromFile.js +0 -32
  235. package/lib/migration/utils/loadCctIdsFromFile.spec.d.ts +0 -1
  236. package/lib/migration/utils/loadCctIdsFromFile.spec.js +0 -91
  237. package/lib/migration/utils/loadStageOptionsFromFile.d.ts +0 -1
  238. package/lib/migration/utils/loadStageOptionsFromFile.js +0 -32
  239. package/lib/migration/utils/loadStageOptionsFromFile.spec.d.ts +0 -1
  240. package/lib/migration/utils/loadStageOptionsFromFile.spec.js +0 -77
  241. package/lib/migration/utils/nextStage.d.ts +0 -2
  242. package/lib/migration/utils/nextStage.js +0 -45
  243. package/lib/migration/utils/nextStage.spec.d.ts +0 -1
  244. package/lib/migration/utils/nextStage.spec.js +0 -151
  245. package/lib/migration/utils/options.d.ts +0 -15
  246. package/lib/migration/utils/options.js +0 -106
  247. package/lib/migration/utils/options.spec.d.ts +0 -1
  248. package/lib/migration/utils/options.spec.js +0 -115
  249. package/lib/migration/utils/promptForMorphConfirmation.d.ts +0 -5
  250. package/lib/migration/utils/promptForMorphConfirmation.js +0 -55
  251. package/lib/migration/utils/promptForMorphConfirmation.spec.d.ts +0 -1
  252. package/lib/migration/utils/promptForMorphConfirmation.spec.js +0 -101
  253. package/lib/migration/utils/revertMigration.d.ts +0 -2
  254. package/lib/migration/utils/revertMigration.js +0 -38
  255. package/lib/migration/utils/revertMigration.spec.d.ts +0 -1
  256. package/lib/migration/utils/revertMigration.spec.js +0 -95
  257. package/lib/migration/utils/setMigrationSettings.d.ts +0 -2
  258. package/lib/migration/utils/setMigrationSettings.js +0 -52
  259. package/lib/migration/utils/setMigrationSettings.spec.d.ts +0 -1
  260. package/lib/migration/utils/setMigrationSettings.spec.js +0 -163
  261. package/lib/page/index.d.ts +0 -3
  262. package/lib/page/index.js +0 -12
  263. package/lib/page/layouts/deploy/deploy.d.ts +0 -5
  264. package/lib/page/layouts/deploy/deploy.js +0 -157
  265. package/lib/page/layouts/deploy/deploy.spec.d.ts +0 -1
  266. package/lib/page/layouts/deploy/deploy.spec.js +0 -319
  267. package/lib/page/layouts/dev/dev.d.ts +0 -5
  268. package/lib/page/layouts/dev/dev.js +0 -84
  269. package/lib/page/layouts/dev/dev.spec.d.ts +0 -1
  270. package/lib/page/layouts/dev/dev.spec.js +0 -271
  271. package/lib/page/layouts/layouts.d.ts +0 -3
  272. package/lib/page/layouts/layouts.js +0 -17
  273. package/lib/page/layouts/layouts.spec.d.ts +0 -1
  274. package/lib/page/layouts/layouts.spec.js +0 -29
  275. package/lib/page/layouts/validation/index.d.ts +0 -3
  276. package/lib/page/layouts/validation/index.js +0 -9
  277. package/lib/page/layouts/validation/property-consistency.d.ts +0 -7
  278. package/lib/page/layouts/validation/property-consistency.js +0 -92
  279. package/lib/page/layouts/validation/property-consistency.spec.d.ts +0 -1
  280. package/lib/page/layouts/validation/property-consistency.spec.js +0 -305
  281. package/lib/page/layouts/validation/validateLayoutFormat.d.ts +0 -2
  282. package/lib/page/layouts/validation/validateLayoutFormat.js +0 -27
  283. package/lib/page/layouts/validation/validateLayoutFormat.spec.d.ts +0 -1
  284. package/lib/page/layouts/validation/validateLayoutFormat.spec.js +0 -42
  285. package/lib/page/layouts/validation/zone-consistency.d.ts +0 -7
  286. package/lib/page/layouts/validation/zone-consistency.js +0 -50
  287. package/lib/page/layouts/validation/zone-consistency.spec.d.ts +0 -1
  288. package/lib/page/layouts/validation/zone-consistency.spec.js +0 -99
  289. package/lib/page/templates/validation.d.ts +0 -11
  290. package/lib/page/templates/validation.js +0 -30
  291. package/lib/page/templates/validation.spec.d.ts +0 -1
  292. package/lib/page/templates/validation.spec.js +0 -89
  293. package/lib/page/utils/definitions.d.ts +0 -552
  294. package/lib/page/utils/definitions.js +0 -241
  295. package/lib/page/utils/definitions.spec.d.ts +0 -1
  296. package/lib/page/utils/definitions.spec.js +0 -749
  297. package/lib/page/utils/normalize.d.ts +0 -8
  298. package/lib/page/utils/normalize.js +0 -54
  299. package/lib/page/utils/normalize.spec.d.ts +0 -1
  300. package/lib/page/utils/normalize.spec.js +0 -315
  301. package/lib/page/utils/parse-args.d.ts +0 -44
  302. package/lib/page/utils/parse-args.js +0 -119
  303. package/lib/page/utils/parse-args.spec.d.ts +0 -1
  304. package/lib/page/utils/parse-args.spec.js +0 -284
  305. package/lib/page/utils/render.d.ts +0 -51
  306. package/lib/page/utils/render.js +0 -112
  307. package/lib/page/utils/render.spec.d.ts +0 -1
  308. package/lib/page/utils/render.spec.js +0 -134
  309. package/lib/page/utils/server.d.ts +0 -12
  310. package/lib/page/utils/server.js +0 -201
  311. package/lib/page/utils/server.spec.d.ts +0 -1
  312. package/lib/page/utils/server.spec.js +0 -275
  313. package/lib/porter/constants.d.ts +0 -11
  314. package/lib/porter/constants.js +0 -14
  315. package/lib/porter/index.d.ts +0 -3
  316. package/lib/porter/index.js +0 -24
  317. package/lib/porter/port/abort/abort.d.ts +0 -3
  318. package/lib/porter/port/abort/abort.js +0 -80
  319. package/lib/porter/port/abort/abort.spec.d.ts +0 -1
  320. package/lib/porter/port/abort/abort.spec.js +0 -182
  321. package/lib/porter/port/get/get.d.ts +0 -3
  322. package/lib/porter/port/get/get.js +0 -96
  323. package/lib/porter/port/get/get.spec.d.ts +0 -1
  324. package/lib/porter/port/get/get.spec.js +0 -277
  325. package/lib/porter/port/start/start.d.ts +0 -3
  326. package/lib/porter/port/start/start.js +0 -82
  327. package/lib/porter/port/start/start.spec.d.ts +0 -1
  328. package/lib/porter/port/start/start.spec.js +0 -198
  329. package/lib/porter/project/add/add.d.ts +0 -3
  330. package/lib/porter/project/add/add.js +0 -138
  331. package/lib/porter/project/add/add.spec.d.ts +0 -1
  332. package/lib/porter/project/add/add.spec.js +0 -269
  333. package/lib/porter/project/get/get.d.ts +0 -3
  334. package/lib/porter/project/get/get.js +0 -65
  335. package/lib/porter/project/get/get.spec.d.ts +0 -1
  336. package/lib/porter/project/get/get.spec.js +0 -185
  337. package/lib/porter/project/remove/remove.d.ts +0 -3
  338. package/lib/porter/project/remove/remove.js +0 -69
  339. package/lib/porter/project/remove/remove.spec.d.ts +0 -1
  340. package/lib/porter/project/remove/remove.spec.js +0 -201
  341. package/lib/porter/types.d.ts +0 -5
  342. package/lib/porter/types.js +0 -2
  343. package/lib/porter/utils/BuildDXPUrl/BuildDXPUrl.d.ts +0 -4
  344. package/lib/porter/utils/BuildDXPUrl/BuildDXPUrl.js +0 -34
  345. package/lib/porter/utils/BuildPorterUrl/BuildPorterUrl.d.ts +0 -1
  346. package/lib/porter/utils/BuildPorterUrl/BuildPorterUrl.js +0 -21
  347. package/lib/porter/utils/BuildPorterUrl/BuildPorterUrl.spec.d.ts +0 -1
  348. package/lib/porter/utils/BuildPorterUrl/BuildPorterUrl.spec.js +0 -52
  349. package/lib/porter/utils/CoreUtils/CoreUtils.d.ts +0 -2
  350. package/lib/porter/utils/CoreUtils/CoreUtils.js +0 -13
  351. package/lib/porter/utils/CoreUtils/CoreUtils.spec.d.ts +0 -1
  352. package/lib/porter/utils/CoreUtils/CoreUtils.spec.js +0 -36
  353. package/lib/porter/utils/DoesPathExist/DoesPathExist.d.ts +0 -1
  354. package/lib/porter/utils/DoesPathExist/DoesPathExist.js +0 -27
  355. package/lib/porter/utils/DoesPathExist/DoesPathExist.spec.d.ts +0 -1
  356. package/lib/porter/utils/DoesPathExist/DoesPathExist.spec.js +0 -40
  357. package/lib/porter/utils/ErrorUtils/ErrorUtils.d.ts +0 -4
  358. package/lib/porter/utils/ErrorUtils/ErrorUtils.js +0 -66
  359. package/lib/porter/utils/ErrorUtils/ErrorUtils.spec.d.ts +0 -1
  360. package/lib/porter/utils/ErrorUtils/ErrorUtils.spec.js +0 -176
  361. package/lib/porter/utils/GetProjectConfig/GetProjectConfig.d.ts +0 -2
  362. package/lib/porter/utils/GetProjectConfig/GetProjectConfig.js +0 -33
  363. package/lib/porter/utils/GetProjectConfig/GetProjectConfig.spec.d.ts +0 -1
  364. package/lib/porter/utils/GetProjectConfig/GetProjectConfig.spec.js +0 -50
  365. package/lib/porter/utils/GetProjectName/GetProjectName.d.ts +0 -4
  366. package/lib/porter/utils/GetProjectName/GetProjectName.js +0 -30
  367. package/lib/porter/utils/GetProjectName/GetProjectName.spec.d.ts +0 -1
  368. package/lib/porter/utils/GetProjectName/GetProjectName.spec.js +0 -91
  369. package/lib/porter/utils/index.d.ts +0 -7
  370. package/lib/porter/utils/index.js +0 -23
package/lib/page/index.js DELETED
@@ -1,12 +0,0 @@
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
- const commander_1 = require("commander");
7
- const layouts_1 = __importDefault(require("./layouts/layouts"));
8
- const pageCommand = new commander_1.Command('page');
9
- pageCommand
10
- .description('Page Content Service Commands')
11
- .addCommand((0, layouts_1.default)());
12
- exports.default = pageCommand;
@@ -1,5 +0,0 @@
1
- import { Command } from 'commander';
2
- import { Logger } from '@squiz/dx-logger-lib';
3
- export declare const logger: Logger;
4
- declare const createDeployCommand: () => Command;
5
- export default createDeployCommand;
@@ -1,157 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.logger = void 0;
16
- const commander_1 = require("commander");
17
- const cli_color_1 = __importDefault(require("cli-color"));
18
- const ApiService_1 = require("../../../ApiService");
19
- const ApplicationConfig_1 = require("../../../ApplicationConfig");
20
- const constants_1 = require("../../../constants");
21
- const definitions_1 = require("../../utils/definitions");
22
- const validation_1 = require("../validation");
23
- const dx_logger_lib_1 = require("@squiz/dx-logger-lib");
24
- exports.logger = (0, dx_logger_lib_1.getLogger)({
25
- name: 'upload-layout',
26
- format: 'human',
27
- });
28
- const createDeployCommand = () => {
29
- const deployCommand = new commander_1.Command()
30
- .name('deploy')
31
- .addOption(new commander_1.Option('--config <string>', 'File path to the page layout config file'))
32
- .addOption(new commander_1.Option('-cu, --content-service-url <string>', 'Override the content service url from login')
33
- .env('CONTENT_SERVICE_URL')
34
- .hideHelp(true))
35
- .addOption(new commander_1.Option('--dxp-base-url <baseURL>', 'DXP Console URL').env('DXP_BASE_URL'))
36
- .addOption(new commander_1.Option('-t, --tenant <string>', 'Tenant ID to deploy to. If not provided will use configured tenant from login').env('SQUIZ_DXP_TENANT_ID'))
37
- .addOption(new commander_1.Option('--dry-run', 'Run all pre-deployment processes without deploying').default(false))
38
- .action((options) => __awaiter(void 0, void 0, void 0, function* () {
39
- var _a, _b, _c, _d, _e;
40
- if (options.contentServiceUrl) {
41
- console.log(`NOTICE: CONTENT_SERVICE_URL is set and will deploy to ${options.contentServiceUrl}`);
42
- }
43
- const maybeConfig = yield maybeGetApplicationConfig();
44
- const baseUrl = (_b = (_a = options.dxpBaseUrl) !== null && _a !== void 0 ? _a : maybeConfig === null || maybeConfig === void 0 ? void 0 : maybeConfig.baseUrl) !== null && _b !== void 0 ? _b : constants_1.PRODUCTION_URL;
45
- const apiService = new ApiService_1.ApiService({
46
- baseUrl,
47
- tenantId: (_c = options.tenant) !== null && _c !== void 0 ? _c : maybeConfig === null || maybeConfig === void 0 ? void 0 : maybeConfig.tenant,
48
- });
49
- const contentServiceUrl = (_d = options.contentServiceUrl) !== null && _d !== void 0 ? _d : new URL('/__dxp/service/components-content', baseUrl).toString();
50
- let layoutFile = options.config;
51
- (0, validation_1.validateLayoutFormat)(exports.logger, layoutFile);
52
- if (!layoutFile) {
53
- layoutFile = `./${definitions_1.LAYOUT_MANIFEST_FILE}`;
54
- }
55
- exports.logger.info(`Loading layout data from the file ${layoutFile}`);
56
- try {
57
- const layout = yield (0, definitions_1.loadLayoutDefinition)(layoutFile);
58
- if (layout !== undefined) {
59
- // Pre-deployment validation: check zones match between manifest and template
60
- const zoneValidationError = (0, validation_1.validateZoneConsistency)(layout);
61
- if (zoneValidationError) {
62
- throw new Error(zoneValidationError);
63
- }
64
- // Validate Handlebars template only refers to properties if manifest.json is used
65
- const propertyValidationError = (0, validation_1.validatePropertyConsistency)(layout, layoutFile);
66
- if (propertyValidationError) {
67
- throw new Error(propertyValidationError);
68
- }
69
- const response = yield uploadLayout(apiService.client, layout, contentServiceUrl, options.dryRun);
70
- if (!options.dryRun) {
71
- exports.logger.info(`Layout "${layout.name}" version ${response.data.version} deployed successfully.`);
72
- // Log the deployed layout URL (clickable)
73
- const layoutUrl = `${baseUrl}/organization/${(_e = options.tenant) !== null && _e !== void 0 ? _e : maybeConfig === null || maybeConfig === void 0 ? void 0 : maybeConfig.tenant}/component-service/all-layouts/${encodeURIComponent(layout.name)}`;
74
- exports.logger.info(`Deployed layout URL: \u001b]8;;${layoutUrl}\u001b\\${layoutUrl}\u001b]8;;\u001b\\`);
75
- }
76
- else {
77
- exports.logger.info(`Layout "${layout.name}" dry run successful.`);
78
- }
79
- }
80
- }
81
- catch (error) {
82
- if (!!process.env.DEBUG && error.stack) {
83
- deployCommand.error(error.stack);
84
- }
85
- if (error instanceof ApiService_1.InvalidLoginSessionError) {
86
- deployCommand.error(cli_color_1.default.red('ERROR:', 'Login session expired. Please login again.'));
87
- }
88
- if (error instanceof ApiService_1.InvalidTenantError) {
89
- deployCommand.error(cli_color_1.default.red('ERROR:', 'Cannot deploy to specified tenant'));
90
- }
91
- if (error.message) {
92
- deployCommand.error(cli_color_1.default.red('ERROR:', error.message));
93
- }
94
- else {
95
- deployCommand.error(cli_color_1.default.red('ERROR:', 'An unknown error occurred'));
96
- }
97
- }
98
- }));
99
- return deployCommand;
100
- };
101
- exports.default = createDeployCommand;
102
- /**
103
- * Formats backend error responses into user-friendly error messages.
104
- * Handles both validation errors (400s) and unknown server errors (500s).
105
- *
106
- * @param data - The error response data from the backend
107
- * @param statusCode - The HTTP status code (optional)
108
- * @returns Formatted error message string
109
- */
110
- function formatErrorResponse(data, statusCode) {
111
- // For 500 errors or unknown errors, show a generic message
112
- if (statusCode && statusCode >= 500) {
113
- return data.message || data.data || 'An unknown error occurred';
114
- }
115
- // For validation errors (400s), format with details
116
- let errorMessage = data.message || 'Validation failed';
117
- // Properties/options validation errors come as an object with field keys
118
- if (data.details &&
119
- typeof data.details === 'object' &&
120
- !Array.isArray(data.details)) {
121
- const details = Object.entries(data.details)
122
- .map(([field, error]) => ` - ${field}: ${error.message}`)
123
- .join('\n');
124
- errorMessage += `\n${details}`;
125
- }
126
- return errorMessage;
127
- }
128
- function uploadLayout(client, layout, contentServiceUrl, dryRun) {
129
- var _a;
130
- return __awaiter(this, void 0, void 0, function* () {
131
- try {
132
- const queryParam = dryRun ? '?_dryRun=true' : '';
133
- const response = yield client.post('/page-layout' + queryParam, layout, {
134
- baseURL: contentServiceUrl,
135
- });
136
- if (response.status === 200) {
137
- return response;
138
- }
139
- throw new Error(formatErrorResponse(response.data, response.status));
140
- }
141
- catch (error) {
142
- // Extract error details from axios error response
143
- if ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) {
144
- throw new Error(formatErrorResponse(error.response.data, error.response.status));
145
- }
146
- throw error;
147
- }
148
- });
149
- }
150
- function maybeGetApplicationConfig() {
151
- return __awaiter(this, void 0, void 0, function* () {
152
- try {
153
- return yield (0, ApplicationConfig_1.fetchApplicationConfig)();
154
- }
155
- catch (_a) { }
156
- });
157
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,319 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- jest.mock('../../utils/definitions');
16
- jest.mock('@squiz/dx-logger-lib', () => ({
17
- getLogger: () => {
18
- return {
19
- info: mockLoggerInfoFn,
20
- warn: mockLoggerWarnFn,
21
- };
22
- },
23
- }));
24
- const mockLoggerInfoFn = jest.fn();
25
- const mockLoggerWarnFn = jest.fn();
26
- const nock_1 = __importDefault(require("nock"));
27
- const deploy_1 = __importDefault(require("./deploy"));
28
- const definitions_1 = require("../../utils/definitions");
29
- function createMockArgs(opts) {
30
- const args = ['node', 'dxp-cli', 'deploy'];
31
- if (opts.config)
32
- args.push('--config', opts.config);
33
- if (opts.contentServiceUrl)
34
- args.push('--content-service-url', opts.contentServiceUrl);
35
- if (opts.tenant)
36
- args.push('--tenant', opts.tenant);
37
- if (opts.dxpBaseUrl)
38
- args.push('--dxp-base-url', opts.dxpBaseUrl);
39
- if (opts.dryRun)
40
- args.push('--dry-run');
41
- return args;
42
- }
43
- describe('deployCommand', () => {
44
- let logSpy;
45
- let errorSpy;
46
- beforeAll(() => {
47
- process.env.SQUIZ_DXP_TENANT_ID = 'myTenant';
48
- });
49
- beforeEach(() => {
50
- logSpy = jest.spyOn(console, 'log').mockImplementation(() => { });
51
- if (!nock_1.default.isActive()) {
52
- nock_1.default.activate();
53
- }
54
- nock_1.default.cleanAll();
55
- });
56
- afterEach(() => {
57
- jest.clearAllMocks();
58
- });
59
- it('correctly handles command option defaults', () => __awaiter(void 0, void 0, void 0, function* () {
60
- const program = (0, deploy_1.default)();
61
- yield program.parseAsync(createMockArgs({}));
62
- const opts = program.opts();
63
- expect(opts.config).toBeUndefined();
64
- expect(opts.tenant).toEqual('myTenant');
65
- expect(opts.dryRun).toEqual(false);
66
- }));
67
- it('correctly handles command arguments', () => __awaiter(void 0, void 0, void 0, function* () {
68
- const config = './src/__tests__/layout.yaml';
69
- const contentServiceUrl = 'http://localhost:9999';
70
- const tenant = 'myTenant';
71
- const dxpBaseUrl = 'http://dxp-base-url.com';
72
- const dryRun = true;
73
- const program = (0, deploy_1.default)();
74
- yield program.parseAsync(createMockArgs({
75
- config,
76
- contentServiceUrl,
77
- tenant,
78
- dxpBaseUrl,
79
- dryRun,
80
- }));
81
- const opts = program.opts();
82
- expect(opts.config).toEqual(config);
83
- expect(opts.contentServiceUrl).toEqual(contentServiceUrl);
84
- expect(opts.tenant).toEqual(tenant);
85
- expect(opts.dxpBaseUrl).toEqual(dxpBaseUrl);
86
- expect(opts.dryRun).toEqual(true);
87
- }));
88
- it('logs a notice when contentServiceUrl is set', () => __awaiter(void 0, void 0, void 0, function* () {
89
- const contentServiceUrl = 'http://localhost:9999';
90
- const program = (0, deploy_1.default)();
91
- yield program.parseAsync(createMockArgs({ contentServiceUrl }));
92
- expect(logSpy).toHaveBeenCalledWith(`NOTICE: CONTENT_SERVICE_URL is set and will deploy to ${contentServiceUrl}`);
93
- }));
94
- it('deploys a layout successfully', () => __awaiter(void 0, void 0, void 0, function* () {
95
- const file = `./src/__tests__/layouts/${definitions_1.LAYOUT_MANIFEST_FILE}`;
96
- const dxpBaseUrl = 'http://dxp-base-url.com';
97
- const mockLayout = {
98
- name: 'test-layout',
99
- zones: [
100
- {
101
- key: 'content',
102
- displayName: 'Content',
103
- description: 'Main content',
104
- },
105
- ],
106
- template: '<div>{{zones.content}}</div>',
107
- };
108
- const mockResponse = { name: 'test-layout', version: '12345' };
109
- definitions_1.loadLayoutDefinition.mockResolvedValue(mockLayout);
110
- (0, nock_1.default)(dxpBaseUrl + '/__dxp/service/components-content')
111
- .post('/page-layout', mockLayout)
112
- .reply(200, mockResponse);
113
- const program = (0, deploy_1.default)();
114
- yield program.parseAsync(createMockArgs({ config: file, dxpBaseUrl }));
115
- expect(mockLoggerInfoFn).toHaveBeenNthCalledWith(1, `Loading layout data from the file ${file}`);
116
- expect(mockLoggerInfoFn).toHaveBeenNthCalledWith(2, 'Layout "test-layout" version 12345 deployed successfully.');
117
- expect(mockLoggerInfoFn).toHaveBeenNthCalledWith(3, 'Deployed layout URL: \u001b]8;;http://dxp-base-url.com/organization/myTenant/component-service/all-layouts/test-layout\u001b\\http://dxp-base-url.com/organization/myTenant/component-service/all-layouts/test-layout\u001b]8;;\u001b\\');
118
- }));
119
- it('deploys a layout with dry-run option', () => __awaiter(void 0, void 0, void 0, function* () {
120
- const file = './src/__tests__/layout.yaml';
121
- const dxpBaseUrl = 'http://dxp-base-url.com';
122
- const dryRun = true;
123
- const mockLayout = {
124
- name: 'test-layout',
125
- zones: [
126
- {
127
- key: 'content',
128
- displayName: 'Content',
129
- description: 'Main content',
130
- },
131
- ],
132
- template: '<div>{{zones.content}}</div>',
133
- };
134
- const mockResponse = { name: 'test-layout', version: '12345' };
135
- definitions_1.loadLayoutDefinition.mockResolvedValue(mockLayout);
136
- (0, nock_1.default)(dxpBaseUrl + '/__dxp/service/components-content')
137
- .post('/page-layout', mockLayout)
138
- .query({ _dryRun: 'true' })
139
- .reply(200, mockResponse);
140
- const program = (0, deploy_1.default)();
141
- yield program.parseAsync(createMockArgs({ config: file, dxpBaseUrl, dryRun }));
142
- expect(mockLoggerInfoFn).toHaveBeenNthCalledWith(1, `Loading layout data from the file ${file}`);
143
- expect(mockLoggerInfoFn).toHaveBeenNthCalledWith(2, 'Layout "test-layout" dry run successful.');
144
- }));
145
- it('handles InvalidLoginSessionError', () => __awaiter(void 0, void 0, void 0, function* () {
146
- const dxpBaseUrl = 'http://dxp-base-url.com';
147
- (0, nock_1.default)(dxpBaseUrl + '/__dxp/service/components-content')
148
- .post('/page-layout')
149
- .reply(401, { message: 'Invalid request: no session' });
150
- const program = (0, deploy_1.default)();
151
- errorSpy = jest.spyOn(program, 'error').mockImplementation();
152
- yield program.parseAsync(createMockArgs({ dxpBaseUrl }));
153
- expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining('Login session expired. Please login again.'));
154
- }));
155
- it('handles InvalidTenantError', () => __awaiter(void 0, void 0, void 0, function* () {
156
- const dxpBaseUrl = 'http://dxp-base-url.com';
157
- (0, nock_1.default)(dxpBaseUrl + '/__dxp/service/components-content')
158
- .post('/page-layout')
159
- .reply(400, { message: 'Cannot deploy to specified tenant' });
160
- const program = (0, deploy_1.default)();
161
- errorSpy = jest.spyOn(program, 'error').mockImplementation();
162
- yield program.parseAsync(createMockArgs({ dxpBaseUrl }));
163
- expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining('Cannot deploy to specified tenant'));
164
- }));
165
- it('handles errors with message', () => __awaiter(void 0, void 0, void 0, function* () {
166
- const dxpBaseUrl = 'http://dxp-base-url.com';
167
- (0, nock_1.default)(dxpBaseUrl + '/__dxp/service/components-content')
168
- .post('/page-layout')
169
- .reply(400, { message: 'Invalid layout data!' });
170
- const program = (0, deploy_1.default)();
171
- errorSpy = jest.spyOn(program, 'error').mockImplementation();
172
- yield program.parseAsync(createMockArgs({ dxpBaseUrl }));
173
- expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining('Invalid layout data!'));
174
- }));
175
- it('handles unknown errors', () => __awaiter(void 0, void 0, void 0, function* () {
176
- const contentServiceUrl = 'http://localhost:9999';
177
- (0, nock_1.default)(contentServiceUrl)
178
- .post('/page-layout')
179
- .reply(500, { data: 'Internal server error' });
180
- const program = (0, deploy_1.default)();
181
- errorSpy = jest.spyOn(program, 'error').mockImplementation();
182
- yield program.parseAsync(createMockArgs({ contentServiceUrl }));
183
- expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining('Internal server error'));
184
- }));
185
- it('should log additional details when layout validation fails', () => __awaiter(void 0, void 0, void 0, function* () {
186
- const dxpBaseUrl = 'http://dxp-base-url.com';
187
- (0, nock_1.default)(dxpBaseUrl + '/__dxp/service/components-content')
188
- .post('/page-layout')
189
- .reply(400, {
190
- message: 'Layout validation failed',
191
- details: {
192
- input: {
193
- message: 'ERROR: Validation failed: "version" is an excess property and therefore is not allowed',
194
- },
195
- },
196
- });
197
- const program = (0, deploy_1.default)();
198
- errorSpy = jest.spyOn(program, 'error').mockImplementation();
199
- yield program.parseAsync(createMockArgs({ dxpBaseUrl }));
200
- const errorCall = errorSpy.mock.calls[0][0];
201
- expect(errorCall).toContain('- input: ERROR: Validation failed: "version" is an excess property and therefore is not allowed');
202
- }));
203
- describe('backend property validation error reporting', () => {
204
- it('should display clean error when single property validation fails', () => __awaiter(void 0, void 0, void 0, function* () {
205
- const contentServiceUrl = 'http://localhost:9999';
206
- (0, nock_1.default)(contentServiceUrl)
207
- .post('/page-layout')
208
- .reply(400, {
209
- message: 'Validation failed',
210
- details: {
211
- 'input.properties.myBoolean': {
212
- message: "Property 'myBoolean' with type 'boolean' can not have values specified",
213
- },
214
- },
215
- });
216
- const program = (0, deploy_1.default)();
217
- errorSpy = jest.spyOn(program, 'error').mockImplementation();
218
- yield program.parseAsync(createMockArgs({ contentServiceUrl }));
219
- const errorCall = errorSpy.mock.calls[0][0];
220
- expect(errorCall).toContain('Validation failed');
221
- expect(errorCall).toContain("- input.properties.myBoolean: Property 'myBoolean' with type 'boolean' can not have values specified");
222
- }));
223
- it('should display multiple property validation errors cleanly', () => __awaiter(void 0, void 0, void 0, function* () {
224
- const contentServiceUrl = 'http://localhost:9999';
225
- (0, nock_1.default)(contentServiceUrl)
226
- .post('/page-layout')
227
- .reply(400, {
228
- message: 'Validation failed',
229
- details: {
230
- 'input.properties.badBoolean': {
231
- message: "Property 'badBoolean' with type 'boolean' cannot have enum values specified",
232
- },
233
- 'input.properties.badProperty.type': {
234
- message: "Property 'badProperty' has invalid type 'INVALID'. Must be one of: string, boolean",
235
- },
236
- },
237
- });
238
- const program = (0, deploy_1.default)();
239
- errorSpy = jest.spyOn(program, 'error').mockImplementation();
240
- yield program.parseAsync(createMockArgs({ contentServiceUrl }));
241
- const errorCall = errorSpy.mock.calls[0][0];
242
- expect(errorCall).toContain('Validation failed');
243
- expect(errorCall).toContain("- input.properties.badBoolean: Property 'badBoolean' with type 'boolean' cannot have enum values specified");
244
- expect(errorCall).toContain("- input.properties.badProperty.type: Property 'badProperty' has invalid type 'INVALID'. Must be one of: string, boolean");
245
- }));
246
- });
247
- describe('zone consistency validation', () => {
248
- it('should handle zone consistency validation errors where zones are used but not defined in the layout', () => __awaiter(void 0, void 0, void 0, function* () {
249
- const file = './src/__tests__/layout.yaml';
250
- const dxpBaseUrl = 'http://dxp-base-url.com';
251
- // Mock layout with zones that don't match the template
252
- const mockLayout = {
253
- name: 'test-layout',
254
- zones: [
255
- {
256
- key: 'col1',
257
- displayName: 'Column 1',
258
- description: 'The first column',
259
- },
260
- ],
261
- template: '{{zones.col1}} {{zones.col2}}', // col2 is used but not defined in zones
262
- };
263
- definitions_1.loadLayoutDefinition.mockResolvedValue(mockLayout);
264
- const program = (0, deploy_1.default)();
265
- errorSpy = jest.spyOn(program, 'error').mockImplementation();
266
- yield program.parseAsync(createMockArgs({ config: file, dxpBaseUrl }));
267
- expect(errorSpy).toHaveBeenCalledWith(expect.stringMatching(/Zone consistency validation failed[\s\S]*Zones used in template but not defined in layout definition: col2/));
268
- }));
269
- it('should handle zone consistency validation errors where zones are defined but not used in the template', () => __awaiter(void 0, void 0, void 0, function* () {
270
- const file = './src/__tests__/layout.yaml';
271
- const dxpBaseUrl = 'http://dxp-base-url.com';
272
- const mockLayout = {
273
- name: 'test-layout',
274
- zones: [
275
- {
276
- key: 'col1',
277
- displayName: 'Column 1',
278
- description: 'The first column',
279
- },
280
- {
281
- key: 'col2',
282
- displayName: 'Column 2',
283
- description: 'The second column',
284
- }, // col2 is defined but not used in the template
285
- ],
286
- template: '{{zones.col1}}',
287
- };
288
- definitions_1.loadLayoutDefinition.mockResolvedValue(mockLayout);
289
- const program = (0, deploy_1.default)();
290
- errorSpy = jest.spyOn(program, 'error').mockImplementation();
291
- yield program.parseAsync(createMockArgs({ config: file, dxpBaseUrl }));
292
- expect(errorSpy).toHaveBeenCalledWith(expect.stringMatching(/Zone consistency validation failed[\s\S]*Zones defined in layout definition but not used in template: col2/));
293
- }));
294
- });
295
- describe('property consistency validation', () => {
296
- it('should handle property consistency validation errors where properties are used but not defined in the layout', () => __awaiter(void 0, void 0, void 0, function* () {
297
- const file = './src/__tests__/manifest.json';
298
- const dxpBaseUrl = 'http://dxp-base-url.com';
299
- // Mock layout with properties that don't match the template
300
- const mockLayout = {
301
- name: 'test-layout',
302
- zones: [],
303
- properties: {
304
- title: {
305
- type: 'string',
306
- title: 'Title',
307
- description: 'Page title',
308
- },
309
- },
310
- template: '{{properties.title}} {{properties.undefined}}', // undefined is used but not defined in properties
311
- };
312
- definitions_1.loadLayoutDefinition.mockResolvedValue(mockLayout);
313
- const program = (0, deploy_1.default)();
314
- errorSpy = jest.spyOn(program, 'error').mockImplementation();
315
- yield program.parseAsync(createMockArgs({ config: file, dxpBaseUrl }));
316
- expect(errorSpy).toHaveBeenCalledWith(expect.stringMatching(/Property consistency validation failed[\s\S]*Properties used in template but not defined in layout definition: undefined/));
317
- }));
318
- });
319
- });
@@ -1,5 +0,0 @@
1
- import { Command } from 'commander';
2
- import { Logger } from '@squiz/dx-logger-lib';
3
- export declare const logger: Logger;
4
- declare const createDevCommand: () => Command;
5
- export default createDevCommand;
@@ -1,84 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.logger = void 0;
16
- const commander_1 = require("commander");
17
- const dx_logger_lib_1 = require("@squiz/dx-logger-lib");
18
- const definitions_1 = require("../../utils/definitions");
19
- const path_1 = __importDefault(require("path"));
20
- const server_1 = require("../../utils/server");
21
- const parse_args_1 = require("../../utils/parse-args");
22
- const validation_1 = require("../validation");
23
- exports.logger = (0, dx_logger_lib_1.getLogger)({
24
- name: 'layout-dev',
25
- format: 'human',
26
- });
27
- const createDevCommand = () => {
28
- const devCommand = new commander_1.Command()
29
- .name('dev')
30
- .description('Start a development server for page layouts')
31
- .option('--config <string>', 'File path to the page layout config file', `./${definitions_1.LAYOUT_MANIFEST_FILE}`)
32
- .option('--port <number>', 'Port to run the development server on', '4040')
33
- .option('--no-open', 'Do not automatically open browser')
34
- .option('--stylesheet <path>', 'Path to CSS file to include')
35
- .option('--zones <items>', 'Zone content mappings', parse_args_1.parseZonesList, {})
36
- .option('--properties <items>', 'Layout properties', parse_args_1.parsePropertiesList, {})
37
- .allowUnknownOption(false)
38
- .allowExcessArguments(true)
39
- .action((options) => __awaiter(void 0, void 0, void 0, function* () {
40
- try {
41
- // Load layout definition
42
- exports.logger.info(`Loading layout definition from ${options.config}`);
43
- const rawLayoutDefinition = yield (0, definitions_1.loadLayoutDefinition)(options.config);
44
- if (!rawLayoutDefinition) {
45
- throw new Error(`Failed to load layout definition from ${options.config}`);
46
- }
47
- (0, validation_1.validateLayoutFormat)(exports.logger, options.config);
48
- // Check zones match between manifest and template
49
- const zoneValidationError = (0, validation_1.validateZoneConsistency)(rawLayoutDefinition);
50
- if (zoneValidationError) {
51
- throw new Error(zoneValidationError);
52
- }
53
- // Validate Handlebars template only refers to properties if manifest.json is used
54
- const propertyValidationError = (0, validation_1.validatePropertyConsistency)(rawLayoutDefinition, options.config);
55
- if (propertyValidationError) {
56
- throw new Error(propertyValidationError);
57
- }
58
- // Confirm for entry property
59
- const layoutDefinition = Object.assign({}, rawLayoutDefinition);
60
- // Normalize properties to convert string booleans to actual booleans
61
- const normalizedProperties = (0, parse_args_1.normalizeLayoutProperties)(options.properties, layoutDefinition);
62
- exports.logger.info('Starting development server...');
63
- yield (0, server_1.startDevServer)({
64
- configPath: path_1.default.resolve(options.config),
65
- layoutDefinition,
66
- zoneContent: options.zones,
67
- layoutProperties: normalizedProperties,
68
- stylesheet: options.stylesheet
69
- ? path_1.default.resolve(options.stylesheet)
70
- : undefined,
71
- port: parseInt(options.port) || 4040,
72
- openBrowser: options.open !== false,
73
- });
74
- }
75
- catch (error) {
76
- if (error.stack && process.env.DEBUG) {
77
- console.error(error.stack);
78
- }
79
- exports.logger.error(error.message || 'An unknown error occurred');
80
- }
81
- }));
82
- return devCommand;
83
- };
84
- exports.default = createDevCommand;
@@ -1 +0,0 @@
1
- export {};