@squiz/dxp-cli-next 5.33.0-develop.5 → 5.33.0-develop.7
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.
- package/bin/dxp.js +6 -1
- package/dist/dxp.js +4480 -0
- package/package.json +36 -30
- package/lib/ApiService.d.ts +0 -39
- package/lib/ApiService.js +0 -120
- package/lib/ApiService.spec.d.ts +0 -1
- package/lib/ApiService.spec.js +0 -182
- package/lib/ApplicationConfig.d.ts +0 -7
- package/lib/ApplicationConfig.js +0 -38
- package/lib/ApplicationConfig.spec.d.ts +0 -1
- package/lib/ApplicationConfig.spec.js +0 -84
- package/lib/ApplicationStore.d.ts +0 -13
- package/lib/ApplicationStore.js +0 -53
- package/lib/__tests__/cmp/dev-mode.spec.d.ts +0 -1
- package/lib/__tests__/cmp/dev-mode.spec.js +0 -54
- package/lib/__tests__/helpers.d.ts +0 -17
- package/lib/__tests__/helpers.js +0 -54
- package/lib/__tests__/integration/main.spec.d.ts +0 -1
- package/lib/__tests__/integration/main.spec.js +0 -45
- package/lib/__tests__/smoke/validate.spec.d.ts +0 -1
- package/lib/__tests__/smoke/validate.spec.js +0 -37
- package/lib/__tests__/unit/cli.d.ts +0 -0
- package/lib/__tests__/unit/cli.js +0 -7
- package/lib/auth/index.d.ts +0 -3
- package/lib/auth/index.js +0 -14
- package/lib/auth/login/login.d.ts +0 -22
- package/lib/auth/login/login.js +0 -268
- package/lib/auth/login/login.spec.d.ts +0 -1
- package/lib/auth/login/login.spec.js +0 -179
- package/lib/auth/logout/logout.d.ts +0 -3
- package/lib/auth/logout/logout.js +0 -115
- package/lib/auth/logout/logout.spec.d.ts +0 -1
- package/lib/auth/logout/logout.spec.js +0 -67
- package/lib/cdp/constants.d.ts +0 -1
- package/lib/cdp/constants.js +0 -4
- package/lib/cdp/index.d.ts +0 -3
- package/lib/cdp/index.js +0 -16
- package/lib/cdp/instance/activate/activate.d.ts +0 -5
- package/lib/cdp/instance/activate/activate.js +0 -107
- package/lib/cdp/instance/activate/activate.spec.d.ts +0 -1
- package/lib/cdp/instance/activate/activate.spec.js +0 -274
- package/lib/cdp/instance/instanceCommand.d.ts +0 -3
- package/lib/cdp/instance/instanceCommand.js +0 -15
- package/lib/cdp/schema/deploy/deploy.const.d.ts +0 -5
- package/lib/cdp/schema/deploy/deploy.const.js +0 -8
- package/lib/cdp/schema/deploy/deploy.d.ts +0 -4
- package/lib/cdp/schema/deploy/deploy.js +0 -107
- package/lib/cdp/schema/deploy/deploy.spec.d.ts +0 -1
- package/lib/cdp/schema/deploy/deploy.spec.js +0 -137
- package/lib/cdp/schema/schemaCommand.d.ts +0 -3
- package/lib/cdp/schema/schemaCommand.js +0 -15
- package/lib/cdp/utils.d.ts +0 -23
- package/lib/cdp/utils.js +0 -133
- package/lib/cmp/deploy.d.ts +0 -3
- package/lib/cmp/deploy.js +0 -124
- package/lib/cmp/dev-mode-ui.d.ts +0 -4
- package/lib/cmp/dev-mode-ui.js +0 -51
- package/lib/cmp/dev-mode.d.ts +0 -4
- package/lib/cmp/dev-mode.js +0 -58
- package/lib/cmp/edge-components/compiler.d.ts +0 -13
- package/lib/cmp/edge-components/compiler.js +0 -55
- package/lib/cmp/index.d.ts +0 -3
- package/lib/cmp/index.js +0 -18
- package/lib/cmp/init.d.ts +0 -3
- package/lib/cmp/init.js +0 -105
- package/lib/cmp/utils/definitions.d.ts +0 -481
- package/lib/cmp/utils/definitions.js +0 -262
- package/lib/cmp/utils/definitions.spec.d.ts +0 -1
- package/lib/cmp/utils/definitions.spec.js +0 -503
- package/lib/constants.d.ts +0 -1
- package/lib/constants.js +0 -4
- package/lib/datastore/blueprint/add/add.d.ts +0 -3
- package/lib/datastore/blueprint/add/add.js +0 -119
- package/lib/datastore/blueprint/add/add.spec.d.ts +0 -1
- package/lib/datastore/blueprint/add/add.spec.js +0 -134
- package/lib/datastore/blueprint/blueprintCommand.d.ts +0 -3
- package/lib/datastore/blueprint/blueprintCommand.js +0 -21
- package/lib/datastore/blueprint/list/list.d.ts +0 -3
- package/lib/datastore/blueprint/list/list.js +0 -76
- package/lib/datastore/blueprint/list/list.spec.d.ts +0 -1
- package/lib/datastore/blueprint/list/list.spec.js +0 -51
- package/lib/datastore/blueprint/rename/rename.d.ts +0 -3
- package/lib/datastore/blueprint/rename/rename.js +0 -93
- package/lib/datastore/blueprint/rename/rename.spec.d.ts +0 -1
- package/lib/datastore/blueprint/rename/rename.spec.js +0 -142
- package/lib/datastore/blueprint/update/update.d.ts +0 -3
- package/lib/datastore/blueprint/update/update.js +0 -89
- package/lib/datastore/blueprint/update/update.spec.d.ts +0 -1
- package/lib/datastore/blueprint/update/update.spec.js +0 -99
- package/lib/datastore/bundle/bundle.d.ts +0 -3
- package/lib/datastore/bundle/bundle.js +0 -176
- package/lib/datastore/bundle/bundle.spec.d.ts +0 -1
- package/lib/datastore/bundle/bundle.spec.js +0 -94
- package/lib/datastore/index.d.ts +0 -3
- package/lib/datastore/index.js +0 -16
- package/lib/datastore/simulator/add/add.d.ts +0 -3
- package/lib/datastore/simulator/add/add.js +0 -125
- package/lib/datastore/simulator/add/add.spec.d.ts +0 -1
- package/lib/datastore/simulator/add/add.spec.js +0 -114
- package/lib/datastore/simulator/clear/clear.d.ts +0 -3
- package/lib/datastore/simulator/clear/clear.js +0 -70
- package/lib/datastore/simulator/clear/clear.spec.d.ts +0 -1
- package/lib/datastore/simulator/clear/clear.spec.js +0 -224
- package/lib/datastore/simulator/list/list.d.ts +0 -3
- package/lib/datastore/simulator/list/list.js +0 -115
- package/lib/datastore/simulator/list/list.spec.d.ts +0 -1
- package/lib/datastore/simulator/list/list.spec.js +0 -95
- package/lib/datastore/simulator/pause/pause.d.ts +0 -3
- package/lib/datastore/simulator/pause/pause.js +0 -84
- package/lib/datastore/simulator/pause/pause.spec.d.ts +0 -1
- package/lib/datastore/simulator/pause/pause.spec.js +0 -90
- package/lib/datastore/simulator/remove/remove.d.ts +0 -3
- package/lib/datastore/simulator/remove/remove.js +0 -68
- package/lib/datastore/simulator/remove/remove.spec.d.ts +0 -1
- package/lib/datastore/simulator/remove/remove.spec.js +0 -224
- package/lib/datastore/simulator/resume/resume.d.ts +0 -3
- package/lib/datastore/simulator/resume/resume.js +0 -84
- package/lib/datastore/simulator/resume/resume.spec.d.ts +0 -1
- package/lib/datastore/simulator/resume/resume.spec.js +0 -90
- package/lib/datastore/simulator/simulatorCommand.d.ts +0 -3
- package/lib/datastore/simulator/simulatorCommand.js +0 -27
- package/lib/datastore/simulator/upgrade/upgrade.d.ts +0 -3
- package/lib/datastore/simulator/upgrade/upgrade.js +0 -157
- package/lib/datastore/simulator/upgrade/upgrade.spec.d.ts +0 -1
- package/lib/datastore/simulator/upgrade/upgrade.spec.js +0 -199
- package/lib/datastore/simulator/utils.d.ts +0 -29
- package/lib/datastore/simulator/utils.js +0 -218
- package/lib/datastore/simulator/utils.spec.d.ts +0 -1
- package/lib/datastore/simulator/utils.spec.js +0 -201
- package/lib/datastore/utils.d.ts +0 -20
- package/lib/datastore/utils.js +0 -241
- package/lib/datastore/utils.spec.d.ts +0 -1
- package/lib/datastore/utils.spec.js +0 -113
- package/lib/dxp.d.ts +0 -1
- package/lib/dxp.js +0 -57
- package/lib/job-runner/index.d.ts +0 -3
- package/lib/job-runner/index.js +0 -22
- package/lib/job-runner/job/listJobs/listJobs.d.ts +0 -3
- package/lib/job-runner/job/listJobs/listJobs.js +0 -66
- package/lib/job-runner/job/listJobs/listJobs.spec.d.ts +0 -1
- package/lib/job-runner/job/listJobs/listJobs.spec.js +0 -42
- package/lib/job-runner/job/uploadJob/uploadJob.d.ts +0 -3
- package/lib/job-runner/job/uploadJob/uploadJob.js +0 -56
- package/lib/job-runner/job/uploadJob/uploadJob.spec.d.ts +0 -1
- package/lib/job-runner/job/uploadJob/uploadJob.spec.js +0 -42
- package/lib/job-runner/jobContext/listJobContexts.d.ts +0 -3
- package/lib/job-runner/jobContext/listJobContexts.js +0 -66
- package/lib/job-runner/jobContext/listJobContexts.spec.d.ts +0 -1
- package/lib/job-runner/jobContext/listJobContexts.spec.js +0 -58
- package/lib/job-runner/jobExecution/beginJob/beginJob.d.ts +0 -3
- package/lib/job-runner/jobExecution/beginJob/beginJob.js +0 -68
- package/lib/job-runner/jobExecution/beginJob/beginJob.spec.d.ts +0 -1
- package/lib/job-runner/jobExecution/beginJob/beginJob.spec.js +0 -62
- package/lib/job-runner/jobExecution/listJobExecutions/listJobExecutions.d.ts +0 -3
- package/lib/job-runner/jobExecution/listJobExecutions/listJobExecutions.js +0 -67
- package/lib/job-runner/jobExecution/listJobExecutions/listJobExecutions.spec.d.ts +0 -1
- package/lib/job-runner/jobExecution/listJobExecutions/listJobExecutions.spec.js +0 -64
- package/lib/job-runner/jobExecution/terminateJob/terminateJob.d.ts +0 -3
- package/lib/job-runner/jobExecution/terminateJob/terminateJob.js +0 -64
- package/lib/job-runner/jobExecution/terminateJob/terminateJob.spec.d.ts +0 -1
- package/lib/job-runner/jobExecution/terminateJob/terminateJob.spec.js +0 -61
- package/lib/job-runner/utils.d.ts +0 -19
- package/lib/job-runner/utils.js +0 -145
- package/lib/job-runner/utils.spec.d.ts +0 -1
- package/lib/job-runner/utils.spec.js +0 -116
- package/lib/migration/batch-get/batch-get.d.ts +0 -3
- package/lib/migration/batch-get/batch-get.js +0 -45
- package/lib/migration/batch-get/batch-get.spec.d.ts +0 -1
- package/lib/migration/batch-get/batch-get.spec.js +0 -182
- package/lib/migration/batch-next/batch-next.d.ts +0 -3
- package/lib/migration/batch-next/batch-next.js +0 -60
- package/lib/migration/batch-next/batch-next.spec.d.ts +0 -1
- package/lib/migration/batch-next/batch-next.spec.js +0 -251
- package/lib/migration/batch-revert/batch-revert.d.ts +0 -3
- package/lib/migration/batch-revert/batch-revert.js +0 -45
- package/lib/migration/batch-revert/batch-revert.spec.d.ts +0 -1
- package/lib/migration/batch-revert/batch-revert.spec.js +0 -197
- package/lib/migration/create/create.d.ts +0 -3
- package/lib/migration/create/create.js +0 -76
- package/lib/migration/create/create.spec.d.ts +0 -1
- package/lib/migration/create/create.spec.js +0 -308
- package/lib/migration/get/get.d.ts +0 -3
- package/lib/migration/get/get.js +0 -46
- package/lib/migration/get/get.spec.d.ts +0 -1
- package/lib/migration/get/get.spec.js +0 -276
- package/lib/migration/index.d.ts +0 -3
- package/lib/migration/index.js +0 -32
- package/lib/migration/list/list.d.ts +0 -3
- package/lib/migration/list/list.js +0 -45
- package/lib/migration/list/list.spec.d.ts +0 -1
- package/lib/migration/list/list.spec.js +0 -139
- package/lib/migration/mark-deployed/mark-deployed.d.ts +0 -3
- package/lib/migration/mark-deployed/mark-deployed.js +0 -55
- package/lib/migration/mark-deployed/mark-deployed.spec.d.ts +0 -1
- package/lib/migration/mark-deployed/mark-deployed.spec.js +0 -217
- package/lib/migration/next/next.d.ts +0 -3
- package/lib/migration/next/next.js +0 -75
- package/lib/migration/next/next.spec.d.ts +0 -1
- package/lib/migration/next/next.spec.js +0 -254
- package/lib/migration/pre/pre.d.ts +0 -3
- package/lib/migration/pre/pre.js +0 -54
- package/lib/migration/pre/pre.spec.d.ts +0 -1
- package/lib/migration/pre/pre.spec.js +0 -269
- package/lib/migration/revert/revert.d.ts +0 -3
- package/lib/migration/revert/revert.js +0 -47
- package/lib/migration/revert/revert.spec.d.ts +0 -1
- package/lib/migration/revert/revert.spec.js +0 -153
- package/lib/migration/settings/settings.d.ts +0 -3
- package/lib/migration/settings/settings.js +0 -63
- package/lib/migration/settings/settings.spec.d.ts +0 -1
- package/lib/migration/settings/settings.spec.js +0 -339
- package/lib/migration/types/common.types.d.ts +0 -60
- package/lib/migration/types/common.types.js +0 -19
- package/lib/migration/types/createMigration.types.d.ts +0 -48
- package/lib/migration/types/createMigration.types.js +0 -2
- package/lib/migration/types/getMigration.types.d.ts +0 -9
- package/lib/migration/types/getMigration.types.js +0 -2
- package/lib/migration/types/index.d.ts +0 -8
- package/lib/migration/types/index.js +0 -24
- package/lib/migration/types/listMigrations.types.d.ts +0 -2
- package/lib/migration/types/listMigrations.types.js +0 -2
- package/lib/migration/types/markDeployed.types.d.ts +0 -20
- package/lib/migration/types/markDeployed.types.js +0 -2
- package/lib/migration/types/nextStage.types.d.ts +0 -31
- package/lib/migration/types/nextStage.types.js +0 -2
- package/lib/migration/types/preMigration.types.d.ts +0 -10
- package/lib/migration/types/preMigration.types.js +0 -2
- package/lib/migration/types/revert.types.d.ts +0 -18
- package/lib/migration/types/revert.types.js +0 -2
- package/lib/migration/types/settings.types.d.ts +0 -15
- package/lib/migration/types/settings.types.js +0 -2
- package/lib/migration/utils/common.d.ts +0 -53
- package/lib/migration/utils/common.js +0 -166
- package/lib/migration/utils/common.spec.d.ts +0 -1
- package/lib/migration/utils/common.spec.js +0 -236
- package/lib/migration/utils/createMigration.d.ts +0 -16
- package/lib/migration/utils/createMigration.js +0 -116
- package/lib/migration/utils/createMigration.spec.d.ts +0 -1
- package/lib/migration/utils/createMigration.spec.js +0 -260
- package/lib/migration/utils/getMigration.d.ts +0 -3
- package/lib/migration/utils/getMigration.js +0 -46
- package/lib/migration/utils/getMigration.spec.d.ts +0 -1
- package/lib/migration/utils/getMigration.spec.js +0 -295
- package/lib/migration/utils/index.d.ts +0 -10
- package/lib/migration/utils/index.js +0 -26
- package/lib/migration/utils/listMigrations.d.ts +0 -3
- package/lib/migration/utils/listMigrations.js +0 -41
- package/lib/migration/utils/listMigrations.spec.d.ts +0 -1
- package/lib/migration/utils/listMigrations.spec.js +0 -109
- package/lib/migration/utils/loadAssetIdsFromFile.d.ts +0 -9
- package/lib/migration/utils/loadAssetIdsFromFile.js +0 -40
- package/lib/migration/utils/loadAssetIdsFromFile.spec.d.ts +0 -1
- package/lib/migration/utils/loadAssetIdsFromFile.spec.js +0 -91
- package/lib/migration/utils/loadStageOptionsFromFile.d.ts +0 -2
- package/lib/migration/utils/loadStageOptionsFromFile.js +0 -32
- package/lib/migration/utils/loadStageOptionsFromFile.spec.d.ts +0 -1
- package/lib/migration/utils/loadStageOptionsFromFile.spec.js +0 -77
- package/lib/migration/utils/markComponentsDeployed.d.ts +0 -2
- package/lib/migration/utils/markComponentsDeployed.js +0 -37
- package/lib/migration/utils/markComponentsDeployed.spec.d.ts +0 -1
- package/lib/migration/utils/markComponentsDeployed.spec.js +0 -222
- package/lib/migration/utils/nextStage.d.ts +0 -3
- package/lib/migration/utils/nextStage.js +0 -55
- package/lib/migration/utils/nextStage.spec.d.ts +0 -1
- package/lib/migration/utils/nextStage.spec.js +0 -323
- package/lib/migration/utils/options.d.ts +0 -18
- package/lib/migration/utils/options.js +0 -136
- package/lib/migration/utils/options.spec.d.ts +0 -1
- package/lib/migration/utils/options.spec.js +0 -115
- package/lib/migration/utils/promptForMorphConfirmation.d.ts +0 -5
- package/lib/migration/utils/promptForMorphConfirmation.js +0 -55
- package/lib/migration/utils/promptForMorphConfirmation.spec.d.ts +0 -1
- package/lib/migration/utils/promptForMorphConfirmation.spec.js +0 -101
- package/lib/migration/utils/revertMigration.d.ts +0 -3
- package/lib/migration/utils/revertMigration.js +0 -58
- package/lib/migration/utils/revertMigration.spec.d.ts +0 -1
- package/lib/migration/utils/revertMigration.spec.js +0 -210
- package/lib/migration/utils/setMigrationSettings.d.ts +0 -2
- package/lib/migration/utils/setMigrationSettings.js +0 -52
- package/lib/migration/utils/setMigrationSettings.spec.d.ts +0 -1
- package/lib/migration/utils/setMigrationSettings.spec.js +0 -163
- package/lib/page/index.d.ts +0 -3
- package/lib/page/index.js +0 -12
- package/lib/page/layouts/deploy/deploy.d.ts +0 -5
- package/lib/page/layouts/deploy/deploy.js +0 -157
- package/lib/page/layouts/deploy/deploy.spec.d.ts +0 -1
- package/lib/page/layouts/deploy/deploy.spec.js +0 -319
- package/lib/page/layouts/dev/dev.d.ts +0 -5
- package/lib/page/layouts/dev/dev.js +0 -84
- package/lib/page/layouts/dev/dev.spec.d.ts +0 -1
- package/lib/page/layouts/dev/dev.spec.js +0 -271
- package/lib/page/layouts/layouts.d.ts +0 -3
- package/lib/page/layouts/layouts.js +0 -17
- package/lib/page/layouts/layouts.spec.d.ts +0 -1
- package/lib/page/layouts/layouts.spec.js +0 -29
- package/lib/page/layouts/validation/index.d.ts +0 -3
- package/lib/page/layouts/validation/index.js +0 -9
- package/lib/page/layouts/validation/property-consistency.d.ts +0 -7
- package/lib/page/layouts/validation/property-consistency.js +0 -92
- package/lib/page/layouts/validation/property-consistency.spec.d.ts +0 -1
- package/lib/page/layouts/validation/property-consistency.spec.js +0 -307
- package/lib/page/layouts/validation/validateLayoutFormat.d.ts +0 -2
- package/lib/page/layouts/validation/validateLayoutFormat.js +0 -27
- package/lib/page/layouts/validation/validateLayoutFormat.spec.d.ts +0 -1
- package/lib/page/layouts/validation/validateLayoutFormat.spec.js +0 -42
- package/lib/page/layouts/validation/zone-consistency.d.ts +0 -7
- package/lib/page/layouts/validation/zone-consistency.js +0 -50
- package/lib/page/layouts/validation/zone-consistency.spec.d.ts +0 -1
- package/lib/page/layouts/validation/zone-consistency.spec.js +0 -94
- package/lib/page/templates/validation.d.ts +0 -11
- package/lib/page/templates/validation.js +0 -30
- package/lib/page/templates/validation.spec.d.ts +0 -1
- package/lib/page/templates/validation.spec.js +0 -89
- package/lib/page/utils/definitions.d.ts +0 -596
- package/lib/page/utils/definitions.js +0 -253
- package/lib/page/utils/definitions.spec.d.ts +0 -1
- package/lib/page/utils/definitions.spec.js +0 -804
- package/lib/page/utils/normalize.d.ts +0 -8
- package/lib/page/utils/normalize.js +0 -54
- package/lib/page/utils/normalize.spec.d.ts +0 -1
- package/lib/page/utils/normalize.spec.js +0 -309
- package/lib/page/utils/parse-args.d.ts +0 -44
- package/lib/page/utils/parse-args.js +0 -119
- package/lib/page/utils/parse-args.spec.d.ts +0 -1
- package/lib/page/utils/parse-args.spec.js +0 -284
- package/lib/page/utils/render.d.ts +0 -51
- package/lib/page/utils/render.js +0 -112
- package/lib/page/utils/render.spec.d.ts +0 -1
- package/lib/page/utils/render.spec.js +0 -134
- package/lib/page/utils/server.d.ts +0 -12
- package/lib/page/utils/server.js +0 -201
- package/lib/page/utils/server.spec.d.ts +0 -1
- package/lib/page/utils/server.spec.js +0 -275
- package/lib/porter/constants.d.ts +0 -11
- package/lib/porter/constants.js +0 -14
- package/lib/porter/index.d.ts +0 -3
- package/lib/porter/index.js +0 -24
- package/lib/porter/port/abort/abort.d.ts +0 -3
- package/lib/porter/port/abort/abort.js +0 -80
- package/lib/porter/port/abort/abort.spec.d.ts +0 -1
- package/lib/porter/port/abort/abort.spec.js +0 -182
- package/lib/porter/port/get/get.d.ts +0 -3
- package/lib/porter/port/get/get.js +0 -96
- package/lib/porter/port/get/get.spec.d.ts +0 -1
- package/lib/porter/port/get/get.spec.js +0 -277
- package/lib/porter/port/start/start.d.ts +0 -3
- package/lib/porter/port/start/start.js +0 -82
- package/lib/porter/port/start/start.spec.d.ts +0 -1
- package/lib/porter/port/start/start.spec.js +0 -198
- package/lib/porter/project/add/add.d.ts +0 -3
- package/lib/porter/project/add/add.js +0 -138
- package/lib/porter/project/add/add.spec.d.ts +0 -1
- package/lib/porter/project/add/add.spec.js +0 -269
- package/lib/porter/project/get/get.d.ts +0 -3
- package/lib/porter/project/get/get.js +0 -65
- package/lib/porter/project/get/get.spec.d.ts +0 -1
- package/lib/porter/project/get/get.spec.js +0 -185
- package/lib/porter/project/remove/remove.d.ts +0 -3
- package/lib/porter/project/remove/remove.js +0 -69
- package/lib/porter/project/remove/remove.spec.d.ts +0 -1
- package/lib/porter/project/remove/remove.spec.js +0 -201
- package/lib/porter/types.d.ts +0 -5
- package/lib/porter/types.js +0 -2
- package/lib/porter/utils/BuildDXPUrl/BuildDXPUrl.d.ts +0 -4
- package/lib/porter/utils/BuildDXPUrl/BuildDXPUrl.js +0 -34
- package/lib/porter/utils/BuildPorterUrl/BuildPorterUrl.d.ts +0 -1
- package/lib/porter/utils/BuildPorterUrl/BuildPorterUrl.js +0 -21
- package/lib/porter/utils/BuildPorterUrl/BuildPorterUrl.spec.d.ts +0 -1
- package/lib/porter/utils/BuildPorterUrl/BuildPorterUrl.spec.js +0 -52
- package/lib/porter/utils/CoreUtils/CoreUtils.d.ts +0 -2
- package/lib/porter/utils/CoreUtils/CoreUtils.js +0 -13
- package/lib/porter/utils/CoreUtils/CoreUtils.spec.d.ts +0 -1
- package/lib/porter/utils/CoreUtils/CoreUtils.spec.js +0 -36
- package/lib/porter/utils/DoesPathExist/DoesPathExist.d.ts +0 -1
- package/lib/porter/utils/DoesPathExist/DoesPathExist.js +0 -27
- package/lib/porter/utils/DoesPathExist/DoesPathExist.spec.d.ts +0 -1
- package/lib/porter/utils/DoesPathExist/DoesPathExist.spec.js +0 -40
- package/lib/porter/utils/ErrorUtils/ErrorUtils.d.ts +0 -4
- package/lib/porter/utils/ErrorUtils/ErrorUtils.js +0 -66
- package/lib/porter/utils/ErrorUtils/ErrorUtils.spec.d.ts +0 -1
- package/lib/porter/utils/ErrorUtils/ErrorUtils.spec.js +0 -176
- package/lib/porter/utils/GetProjectConfig/GetProjectConfig.d.ts +0 -2
- package/lib/porter/utils/GetProjectConfig/GetProjectConfig.js +0 -33
- package/lib/porter/utils/GetProjectConfig/GetProjectConfig.spec.d.ts +0 -1
- package/lib/porter/utils/GetProjectConfig/GetProjectConfig.spec.js +0 -50
- package/lib/porter/utils/GetProjectName/GetProjectName.d.ts +0 -4
- package/lib/porter/utils/GetProjectName/GetProjectName.js +0 -30
- package/lib/porter/utils/GetProjectName/GetProjectName.spec.d.ts +0 -1
- package/lib/porter/utils/GetProjectName/GetProjectName.spec.js +0 -91
- package/lib/porter/utils/index.d.ts +0 -7
- package/lib/porter/utils/index.js +0 -23
|
@@ -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,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 {};
|