@speedkit/cli 2.4.1
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/README.md +775 -0
- package/bin/dev +18 -0
- package/bin/dev.cmd +3 -0
- package/bin/run +4 -0
- package/bin/run.cmd +3 -0
- package/dist/commands/airports_iata.json +1 -0
- package/dist/commands/build-parameter-query.d.ts +15 -0
- package/dist/commands/build-parameter-query.js +95 -0
- package/dist/commands/build-prewarm-query.d.ts +15 -0
- package/dist/commands/build-prewarm-query.js +69 -0
- package/dist/commands/deploy.d.ts +17 -0
- package/dist/commands/deploy.js +39 -0
- package/dist/commands/document-handler.d.ts +16 -0
- package/dist/commands/document-handler.js +36 -0
- package/dist/commands/find-pops.d.ts +17 -0
- package/dist/commands/find-pops.js +84 -0
- package/dist/commands/generate-customer-config.d.ts +10 -0
- package/dist/commands/generate-customer-config.js +29 -0
- package/dist/commands/generate-pop-config.d.ts +27 -0
- package/dist/commands/generate-pop-config.js +231 -0
- package/dist/commands/login.d.ts +10 -0
- package/dist/commands/login.js +35 -0
- package/dist/commands/onboarding.d.ts +16 -0
- package/dist/commands/onboarding.js +25 -0
- package/dist/commands/param-diff.d.ts +16 -0
- package/dist/commands/param-diff.js +111 -0
- package/dist/commands/pop-prewarm.d.ts +17 -0
- package/dist/commands/pop-prewarm.js +80 -0
- package/dist/commands/prewarm.d.ts +40 -0
- package/dist/commands/prewarm.js +127 -0
- package/dist/commands/pull.d.ts +14 -0
- package/dist/commands/pull.js +24 -0
- package/dist/commands/wpt-launcher.d.ts +21 -0
- package/dist/commands/wpt-launcher.js +79 -0
- package/dist/helpers/CustomerConfig.d.ts +51 -0
- package/dist/helpers/CustomerConfig.js +150 -0
- package/dist/helpers/build-query-helper.d.ts +32 -0
- package/dist/helpers/build-query-helper.js +216 -0
- package/dist/helpers/cli-config.d.ts +22 -0
- package/dist/helpers/cli-config.js +85 -0
- package/dist/helpers/file-helper.d.ts +8 -0
- package/dist/helpers/file-helper.js +63 -0
- package/dist/helpers/get-parsed-config.d.ts +11 -0
- package/dist/helpers/get-parsed-config.js +63 -0
- package/dist/helpers/getChromePath.d.ts +7 -0
- package/dist/helpers/getChromePath.js +27 -0
- package/dist/helpers/isDirectory.d.ts +1 -0
- package/dist/helpers/isDirectory.js +17 -0
- package/dist/helpers/isExecutable.d.ts +1 -0
- package/dist/helpers/isExecutable.js +15 -0
- package/dist/helpers/isFile.d.ts +1 -0
- package/dist/helpers/isFile.js +17 -0
- package/dist/helpers/logging-helper.d.ts +12 -0
- package/dist/helpers/logging-helper.js +27 -0
- package/dist/helpers/normalize.d.ts +40 -0
- package/dist/helpers/normalize.js +112 -0
- package/dist/helpers/race.d.ts +1 -0
- package/dist/helpers/race.js +16 -0
- package/dist/helpers/safe.d.ts +10 -0
- package/dist/helpers/safe.js +34 -0
- package/dist/helpers/scrape.d.ts +1 -0
- package/dist/helpers/scrape.js +11 -0
- package/dist/helpers/speedKitRuleToRegExp.d.ts +1 -0
- package/dist/helpers/speedKitRuleToRegExp.js +10 -0
- package/dist/helpers/watchFiles.d.ts +1 -0
- package/dist/helpers/watchFiles.js +20 -0
- package/dist/models/cli-parameters.d.ts +73 -0
- package/dist/models/cli-parameters.js +82 -0
- package/dist/models/files.d.ts +20 -0
- package/dist/models/files.js +23 -0
- package/dist/models/install.d.ts +24 -0
- package/dist/models/install.js +2 -0
- package/dist/services/athena-service.d.ts +30 -0
- package/dist/services/athena-service.js +139 -0
- package/dist/services/bundler/bundle-service-factory.d.ts +4 -0
- package/dist/services/bundler/bundle-service-factory.js +10 -0
- package/dist/services/bundler/bundle-service.d.ts +25 -0
- package/dist/services/bundler/bundle-service.js +84 -0
- package/dist/services/bundler/index.d.ts +2 -0
- package/dist/services/bundler/index.js +5 -0
- package/dist/services/cli/cli-service-factory.d.ts +5 -0
- package/dist/services/cli/cli-service-factory.js +14 -0
- package/dist/services/cli/cli-service-model.d.ts +27 -0
- package/dist/services/cli/cli-service-model.js +9 -0
- package/dist/services/cli/cli-service.d.ts +37 -0
- package/dist/services/cli/cli-service.js +123 -0
- package/dist/services/cli/error/cli-type-error.d.ts +3 -0
- package/dist/services/cli/error/cli-type-error.js +7 -0
- package/dist/services/cli/hooks.d.ts +11 -0
- package/dist/services/cli/hooks.js +33 -0
- package/dist/services/cli/index.d.ts +3 -0
- package/dist/services/cli/index.js +6 -0
- package/dist/services/config-api/client.d.ts +16 -0
- package/dist/services/config-api/client.js +54 -0
- package/dist/services/config-api/config-api-service.d.ts +16 -0
- package/dist/services/config-api/config-api-service.js +56 -0
- package/dist/services/config-api/context/config-api-context.d.ts +5 -0
- package/dist/services/config-api/context/config-api-context.js +9 -0
- package/dist/services/config-api/error/json-response-error.d.ts +2 -0
- package/dist/services/config-api/error/json-response-error.js +5 -0
- package/dist/services/config-api/error/login-error.d.ts +5 -0
- package/dist/services/config-api/error/login-error.js +12 -0
- package/dist/services/config-api/factory/config-api-service-factory.d.ts +10 -0
- package/dist/services/config-api/factory/config-api-service-factory.js +38 -0
- package/dist/services/config-api/factory/entity-manager-factory.d.ts +5 -0
- package/dist/services/config-api/factory/entity-manager-factory.js +21 -0
- package/dist/services/config-api/interface/config-api-context-interface.d.ts +4 -0
- package/dist/services/config-api/interface/config-api-context-interface.js +2 -0
- package/dist/services/config-api/interface/request-extension-interface.d.ts +5 -0
- package/dist/services/config-api/interface/request-extension-interface.js +2 -0
- package/dist/services/config-api-service.d.ts +18 -0
- package/dist/services/config-api-service.js +96 -0
- package/dist/services/context/app-context.d.ts +1 -0
- package/dist/services/context/app-context.js +2 -0
- package/dist/services/context/error/context-runtime-error.d.ts +3 -0
- package/dist/services/context/error/context-runtime-error.js +7 -0
- package/dist/services/context/interface/context-interface.d.ts +2 -0
- package/dist/services/context/interface/context-interface.js +2 -0
- package/dist/services/customer-config/customer-config-service-context.d.ts +5 -0
- package/dist/services/customer-config/customer-config-service-context.js +15 -0
- package/dist/services/customer-config/customer-config-service-factory.d.ts +8 -0
- package/dist/services/customer-config/customer-config-service-factory.js +24 -0
- package/dist/services/customer-config/customer-config-service-model.d.ts +39 -0
- package/dist/services/customer-config/customer-config-service-model.js +23 -0
- package/dist/services/customer-config/customer-config-service.d.ts +27 -0
- package/dist/services/customer-config/customer-config-service.js +263 -0
- package/dist/services/customer-config/index.d.ts +4 -0
- package/dist/services/customer-config/index.js +7 -0
- package/dist/services/customer-config/templates/config_SpeedKit.js.hbs +351 -0
- package/dist/services/customer-config/templates/config_customer.js.hbs +75 -0
- package/dist/services/customer-config/templates/config_documentHandler.js.hbs +162 -0
- package/dist/services/customer-config/templates/config_dynamicBlocks.es6.hbs +263 -0
- package/dist/services/customer-config/templates/config_dynamicStyles.css.hbs +116 -0
- package/dist/services/customer-config/templates/config_loadHandler.js.hbs +394 -0
- package/dist/services/customer-config/templates/deploymentDetection.es6.hbs +262 -0
- package/dist/services/customer-config/templates/downtimeDetection.js.hbs +110 -0
- package/dist/services/deploy/builder/install-resource-builder.d.ts +14 -0
- package/dist/services/deploy/builder/install-resource-builder.js +48 -0
- package/dist/services/deploy/checks/post-deploy/revalidated-module-check.d.ts +11 -0
- package/dist/services/deploy/checks/post-deploy/revalidated-module-check.js +30 -0
- package/dist/services/deploy/checks/post-deploy/save-files-check.d.ts +9 -0
- package/dist/services/deploy/checks/post-deploy/save-files-check.js +25 -0
- package/dist/services/deploy/context/deploy-context.d.ts +12 -0
- package/dist/services/deploy/context/deploy-context.js +26 -0
- package/dist/services/deploy/deploy-service-factory.d.ts +15 -0
- package/dist/services/deploy/deploy-service-factory.js +68 -0
- package/dist/services/deploy/deploy-service.d.ts +17 -0
- package/dist/services/deploy/deploy-service.js +63 -0
- package/dist/services/deploy/error/create-find-temp-directory-error.d.ts +4 -0
- package/dist/services/deploy/error/create-find-temp-directory-error.js +10 -0
- package/dist/services/deploy/error/deploy-app-error.d.ts +2 -0
- package/dist/services/deploy/error/deploy-app-error.js +5 -0
- package/dist/services/deploy/error/no-active-installation-error.d.ts +4 -0
- package/dist/services/deploy/error/no-active-installation-error.js +10 -0
- package/dist/services/deploy/handler/customer-config-handler.d.ts +21 -0
- package/dist/services/deploy/handler/customer-config-handler.js +85 -0
- package/dist/services/deploy/handler/install-resource-handler.d.ts +25 -0
- package/dist/services/deploy/handler/install-resource-handler.js +104 -0
- package/dist/services/deploy/handler/install-resource-modifier/deleted-file-check.d.ts +13 -0
- package/dist/services/deploy/handler/install-resource-modifier/deleted-file-check.js +51 -0
- package/dist/services/deploy/handler/module-handler.d.ts +14 -0
- package/dist/services/deploy/handler/module-handler.js +81 -0
- package/dist/services/deploy/handler/module-modifier/deployment-detection-modifier.d.ts +9 -0
- package/dist/services/deploy/handler/module-modifier/deployment-detection-modifier.js +24 -0
- package/dist/services/deploy/handler/server-config-handler.d.ts +12 -0
- package/dist/services/deploy/handler/server-config-handler.js +63 -0
- package/dist/services/deploy/interface/deploy-handler-interface.d.ts +6 -0
- package/dist/services/deploy/interface/deploy-handler-interface.js +2 -0
- package/dist/services/deploy/interface/install-configs.d.ts +11 -0
- package/dist/services/deploy/interface/install-configs.js +2 -0
- package/dist/services/deploy/interface/install-resource-processor-interface.d.ts +5 -0
- package/dist/services/deploy/interface/install-resource-processor-interface.js +2 -0
- package/dist/services/deploy/interface/install.d.ts +14 -0
- package/dist/services/deploy/interface/install.js +2 -0
- package/dist/services/deploy/interface/post-deploy-check-interface.d.ts +3 -0
- package/dist/services/deploy/interface/post-deploy-check-interface.js +2 -0
- package/dist/services/deploy/interface/runtime-modifier.d.ts +6 -0
- package/dist/services/deploy/interface/runtime-modifier.js +2 -0
- package/dist/services/deploy/interface/validate-origins-response.d.ts +4 -0
- package/dist/services/deploy/interface/validate-origins-response.js +2 -0
- package/dist/services/diff/diff-model.d.ts +5 -0
- package/dist/services/diff/diff-model.js +12 -0
- package/dist/services/diff/diff-service-factory.d.ts +7 -0
- package/dist/services/diff/diff-service-factory.js +20 -0
- package/dist/services/diff/diff-service.d.ts +34 -0
- package/dist/services/diff/diff-service.js +134 -0
- package/dist/services/diff/index.d.ts +3 -0
- package/dist/services/diff/index.js +6 -0
- package/dist/services/diff-service.d.ts +24 -0
- package/dist/services/diff-service.js +112 -0
- package/dist/services/document-handler-runtime/context/document-handler-runtime-context.d.ts +23 -0
- package/dist/services/document-handler-runtime/context/document-handler-runtime-context.js +41 -0
- package/dist/services/document-handler-runtime/document-handler-runtime-service.d.ts +32 -0
- package/dist/services/document-handler-runtime/document-handler-runtime-service.js +220 -0
- package/dist/services/document-handler-runtime/document-handler-server.d.ts +42 -0
- package/dist/services/document-handler-runtime/document-handler-server.js +225 -0
- package/dist/services/document-handler-runtime/error/handler/required-file-not-found-handler.d.ts +6 -0
- package/dist/services/document-handler-runtime/error/handler/required-file-not-found-handler.js +14 -0
- package/dist/services/document-handler-runtime/error/required-file-not-found-error.d.ts +3 -0
- package/dist/services/document-handler-runtime/error/required-file-not-found-error.js +7 -0
- package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.d.ts +24 -0
- package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.js +106 -0
- package/dist/services/document-handler-runtime/interface/document-handler-runtime-config-interface.d.ts +3 -0
- package/dist/services/document-handler-runtime/interface/document-handler-runtime-config-interface.js +6 -0
- package/dist/services/document-handler-runtime/interface/template-context-interface.d.ts +3 -0
- package/dist/services/document-handler-runtime/interface/template-context-interface.js +2 -0
- package/dist/services/document-handler-runtime/interface/template-interface.d.ts +6 -0
- package/dist/services/document-handler-runtime/interface/template-interface.js +2 -0
- package/dist/services/document-handler-runtime/interface/template-param-interface.d.ts +4 -0
- package/dist/services/document-handler-runtime/interface/template-param-interface.js +2 -0
- package/dist/services/document-handler-runtime/templates/abstract-template.d.ts +9 -0
- package/dist/services/document-handler-runtime/templates/abstract-template.js +18 -0
- package/dist/services/document-handler-runtime/templates/database-mock.d.ts +6 -0
- package/dist/services/document-handler-runtime/templates/database-mock.js +111 -0
- package/dist/services/document-handler-runtime/templates/execute-document-handler.d.ts +6 -0
- package/dist/services/document-handler-runtime/templates/execute-document-handler.js +76 -0
- package/dist/services/document-handler-runtime/templates/orestes-mock.d.ts +9 -0
- package/dist/services/document-handler-runtime/templates/orestes-mock.js +168 -0
- package/dist/services/document-handler-runtime/templates/package-json.d.ts +8 -0
- package/dist/services/document-handler-runtime/templates/package-json.js +21 -0
- package/dist/services/document-handler-runtime/templates/test.d.ts +6 -0
- package/dist/services/document-handler-runtime/templates/test.js +63 -0
- package/dist/services/error-handling/abstract/abstract-async-error-handling-factory.d.ts +6 -0
- package/dist/services/error-handling/abstract/abstract-async-error-handling-factory.js +19 -0
- package/dist/services/error-handling/abstract/abstract-async-error-handling-service.d.ts +6 -0
- package/dist/services/error-handling/abstract/abstract-async-error-handling-service.js +18 -0
- package/dist/services/error-handling/abstract/abstract-error-handling-factory.d.ts +6 -0
- package/dist/services/error-handling/abstract/abstract-error-handling-factory.js +19 -0
- package/dist/services/error-handling/abstract/abstract-error-handling-service.d.ts +6 -0
- package/dist/services/error-handling/abstract/abstract-error-handling-service.js +19 -0
- package/dist/services/error-handling/error/application-error.d.ts +5 -0
- package/dist/services/error-handling/error/application-error.js +11 -0
- package/dist/services/error-handling/error/handler/default-error-handler.d.ts +5 -0
- package/dist/services/error-handling/error/handler/default-error-handler.js +13 -0
- package/dist/services/error-handling/error-handling-service.d.ts +7 -0
- package/dist/services/error-handling/error-handling-service.js +27 -0
- package/dist/services/error-handling/factory/error-handling-factory.d.ts +8 -0
- package/dist/services/error-handling/factory/error-handling-factory.js +21 -0
- package/dist/services/error-handling/interface/error-context-interface.d.ts +6 -0
- package/dist/services/error-handling/interface/error-context-interface.js +2 -0
- package/dist/services/error-handling/interface/error-handler-interface.d.ts +5 -0
- package/dist/services/error-handling/interface/error-handler-interface.js +2 -0
- package/dist/services/error-handling/interface/error-handling-factory-interface.d.ts +8 -0
- package/dist/services/error-handling/interface/error-handling-factory-interface.js +2 -0
- package/dist/services/error-handling/interface/error-handling-service-interface.d.ts +8 -0
- package/dist/services/error-handling/interface/error-handling-service-interface.js +2 -0
- package/dist/services/integration-api/context/integration-api-context.d.ts +9 -0
- package/dist/services/integration-api/context/integration-api-context.js +20 -0
- package/dist/services/integration-api/error/customer-config-error.d.ts +2 -0
- package/dist/services/integration-api/error/customer-config-error.js +5 -0
- package/dist/services/integration-api/error/customer-config-legacy-error.d.ts +3 -0
- package/dist/services/integration-api/error/customer-config-legacy-error.js +7 -0
- package/dist/services/integration-api/error/handler/customer-config-handler.d.ts +5 -0
- package/dist/services/integration-api/error/handler/customer-config-handler.js +19 -0
- package/dist/services/integration-api/error/handler/customer-config-legacy-handler.d.ts +6 -0
- package/dist/services/integration-api/error/handler/customer-config-legacy-handler.js +24 -0
- package/dist/services/integration-api/error/handler/origin-handler.d.ts +6 -0
- package/dist/services/integration-api/error/handler/origin-handler.js +22 -0
- package/dist/services/integration-api/error/load-customer-error.d.ts +4 -0
- package/dist/services/integration-api/error/load-customer-error.js +10 -0
- package/dist/services/integration-api/error/mandatory-file-missing-error.d.ts +3 -0
- package/dist/services/integration-api/error/mandatory-file-missing-error.js +8 -0
- package/dist/services/integration-api/error/origin-error.d.ts +3 -0
- package/dist/services/integration-api/error/origin-error.js +7 -0
- package/dist/services/integration-api/external/external-file-reader.d.ts +4 -0
- package/dist/services/integration-api/external/external-file-reader.js +17 -0
- package/dist/services/integration-api/factory/integration-api-service-factory.d.ts +13 -0
- package/dist/services/integration-api/factory/integration-api-service-factory.js +55 -0
- package/dist/services/integration-api/file-list.d.ts +18 -0
- package/dist/services/integration-api/file-list.js +79 -0
- package/dist/services/integration-api/file-reader.d.ts +15 -0
- package/dist/services/integration-api/file-reader.js +97 -0
- package/dist/services/integration-api/file-writer.d.ts +9 -0
- package/dist/services/integration-api/file-writer.js +27 -0
- package/dist/services/integration-api/handler/customer-config-handler.d.ts +16 -0
- package/dist/services/integration-api/handler/customer-config-handler.js +55 -0
- package/dist/services/integration-api/handler/file-handler.d.ts +9 -0
- package/dist/services/integration-api/handler/file-handler.js +20 -0
- package/dist/services/integration-api/handler/install-resource-handler.d.ts +33 -0
- package/dist/services/integration-api/handler/install-resource-handler.js +67 -0
- package/dist/services/integration-api/handler/module-handler.d.ts +12 -0
- package/dist/services/integration-api/handler/module-handler.js +20 -0
- package/dist/services/integration-api/handler/server-config-handler.d.ts +8 -0
- package/dist/services/integration-api/handler/server-config-handler.js +21 -0
- package/dist/services/integration-api/integration-api-model.d.ts +89 -0
- package/dist/services/integration-api/integration-api-model.js +2 -0
- package/dist/services/integration-api/integration-api-service.d.ts +21 -0
- package/dist/services/integration-api/integration-api-service.js +76 -0
- package/dist/services/integration-api/struct/customer-config-file.d.ts +10 -0
- package/dist/services/integration-api/struct/customer-config-file.js +32 -0
- package/dist/services/integration-api/struct/customer-config.d.ts +22 -0
- package/dist/services/integration-api/struct/customer-config.js +67 -0
- package/dist/services/integration-api/struct/file.d.ts +19 -0
- package/dist/services/integration-api/struct/file.js +61 -0
- package/dist/services/integration-api/struct/install-resource-file.d.ts +6 -0
- package/dist/services/integration-api/struct/install-resource-file.js +12 -0
- package/dist/services/integration-api/struct/module-file.d.ts +5 -0
- package/dist/services/integration-api/struct/module-file.js +10 -0
- package/dist/services/integration-api/struct/ro-file.d.ts +13 -0
- package/dist/services/integration-api/struct/ro-file.js +26 -0
- package/dist/services/integration-api/struct/server-config-file.d.ts +9 -0
- package/dist/services/integration-api/struct/server-config-file.js +22 -0
- package/dist/services/integration-api/struct/virtual-file.d.ts +14 -0
- package/dist/services/integration-api/struct/virtual-file.js +28 -0
- package/dist/services/integration-api/validator/customer-config-validator.d.ts +5 -0
- package/dist/services/integration-api/validator/customer-config-validator.js +23 -0
- package/dist/services/integration-api/validator/mandatory-files-validator.d.ts +7 -0
- package/dist/services/integration-api/validator/mandatory-files-validator.js +39 -0
- package/dist/services/integration-api/virtual/external-recipe.d.ts +9 -0
- package/dist/services/integration-api/virtual/external-recipe.js +19 -0
- package/dist/services/integration-api/virtual/virtual-file-handler.d.ts +7 -0
- package/dist/services/integration-api/virtual/virtual-file-handler.js +38 -0
- package/dist/services/onboarding/browser/abort-response.d.ts +5 -0
- package/dist/services/onboarding/browser/abort-response.js +10 -0
- package/dist/services/onboarding/browser/baqend-response.d.ts +12 -0
- package/dist/services/onboarding/browser/baqend-response.js +52 -0
- package/dist/services/onboarding/browser/origin-response.d.ts +8 -0
- package/dist/services/onboarding/browser/origin-response.js +20 -0
- package/dist/services/onboarding/config-renderer/install-file-recipe.d.ts +7 -0
- package/dist/services/onboarding/config-renderer/install-file-recipe.js +13 -0
- package/dist/services/onboarding/config-renderer/speed-kit-install-context.d.ts +22 -0
- package/dist/services/onboarding/config-renderer/speed-kit-install-context.js +78 -0
- package/dist/services/onboarding/dashboard/athena-service.d.ts +11 -0
- package/dist/services/onboarding/dashboard/athena-service.js +70 -0
- package/dist/services/onboarding/dashboard/frontend-dist/assets/index-87b53ed4.css +1 -0
- package/dist/services/onboarding/dashboard/frontend-dist/assets/main-274b5625.js +9 -0
- package/dist/services/onboarding/dashboard/frontend-dist/index.html +18 -0
- package/dist/services/onboarding/dashboard/index.d.ts +16 -0
- package/dist/services/onboarding/dashboard/index.js +78 -0
- package/dist/services/onboarding/dashboard/param-query-builder.d.ts +9 -0
- package/dist/services/onboarding/dashboard/param-query-builder.js +67 -0
- package/dist/services/onboarding/dashboard/request-diff-service.d.ts +11 -0
- package/dist/services/onboarding/dashboard/request-diff-service.js +59 -0
- package/dist/services/onboarding/error/vm-error.d.ts +2 -0
- package/dist/services/onboarding/error/vm-error.js +6 -0
- package/dist/services/onboarding/fetch-event-handler.d.ts +19 -0
- package/dist/services/onboarding/fetch-event-handler.js +155 -0
- package/dist/services/onboarding/fetch-events/customer-domain-document-response.d.ts +24 -0
- package/dist/services/onboarding/fetch-events/customer-domain-document-response.js +118 -0
- package/dist/services/onboarding/fetch-events/customer-service-worker-js.d.ts +14 -0
- package/dist/services/onboarding/fetch-events/customer-service-worker-js.js +30 -0
- package/dist/services/onboarding/fetch-events/dashboard-request.d.ts +15 -0
- package/dist/services/onboarding/fetch-events/dashboard-request.js +29 -0
- package/dist/services/onboarding/fetch-events/speed-kit-asset-request.d.ts +26 -0
- package/dist/services/onboarding/fetch-events/speed-kit-asset-request.js +138 -0
- package/dist/services/onboarding/fetch-events/speed-kit-install-html.d.ts +15 -0
- package/dist/services/onboarding/fetch-events/speed-kit-install-html.js +49 -0
- package/dist/services/onboarding/fetch-events/speed-kit-install-js.d.ts +22 -0
- package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +62 -0
- package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +21 -0
- package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.js +43 -0
- package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +17 -0
- package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.js +27 -0
- package/dist/services/onboarding/file-events/fileWatcher.d.ts +28 -0
- package/dist/services/onboarding/file-events/fileWatcher.js +133 -0
- package/dist/services/onboarding/index.d.ts +3 -0
- package/dist/services/onboarding/index.js +8 -0
- package/dist/services/onboarding/onboarding-model.d.ts +30 -0
- package/dist/services/onboarding/onboarding-model.js +53 -0
- package/dist/services/onboarding/onboarding-service-factory.d.ts +16 -0
- package/dist/services/onboarding/onboarding-service-factory.js +163 -0
- package/dist/services/onboarding/onboarding-service.d.ts +31 -0
- package/dist/services/onboarding/onboarding-service.js +130 -0
- package/dist/services/onboarding/request-cache/cache.d.ts +15 -0
- package/dist/services/onboarding/request-cache/cache.js +32 -0
- package/dist/services/onboarding/templates/install-speed-kit-html-template.d.ts +4 -0
- package/dist/services/onboarding/templates/install-speed-kit-html-template.js +264 -0
- package/dist/services/onboarding/templates/install-speed-kit-js-template.d.ts +4 -0
- package/dist/services/onboarding/templates/install-speed-kit-js-template.js +41 -0
- package/dist/services/onboarding/todo-collector.d.ts +18 -0
- package/dist/services/onboarding/todo-collector.js +48 -0
- package/dist/services/prewarm-service.d.ts +5 -0
- package/dist/services/prewarm-service.js +57 -0
- package/dist/services/pull/index.d.ts +3 -0
- package/dist/services/pull/index.js +6 -0
- package/dist/services/pull/pull-service-factory.d.ts +12 -0
- package/dist/services/pull/pull-service-factory.js +44 -0
- package/dist/services/pull/pull-service-model.d.ts +43 -0
- package/dist/services/pull/pull-service-model.js +27 -0
- package/dist/services/pull/pull-service.d.ts +18 -0
- package/dist/services/pull/pull-service.js +106 -0
- package/dist/templates/pops.js +97 -0
- package/dist/templates/speedKit.Revalidated.js +86 -0
- package/oclif.manifest.json +700 -0
- package/package.json +128 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import { BaseBundle } from 'rum/BaseBundle';
|
|
2
|
+
{{#if useGATracking}}
|
|
3
|
+
import { GAEcommerceTrackingPlugin } from 'rum/GAEcommerceTrackingPlugin';
|
|
4
|
+
{{/if}}
|
|
5
|
+
|
|
6
|
+
!function() {
|
|
7
|
+
if (window !== window.top) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
window.SpeedKit = window.SpeedKit || {};
|
|
12
|
+
SpeedKit.rumPlugins = SpeedKit.rumPlugins || [];
|
|
13
|
+
SpeedKit.rumPlugins.push(
|
|
14
|
+
new BaseBundle(),
|
|
15
|
+
{{#if useGATracking}}
|
|
16
|
+
new GAEcommerceTrackingPlugin(),
|
|
17
|
+
{{/if}}
|
|
18
|
+
|
|
19
|
+
{
|
|
20
|
+
key: 'language',
|
|
21
|
+
type: 'SessionDimension',
|
|
22
|
+
{{#if useGATracking}}
|
|
23
|
+
on: 'dataLayer',
|
|
24
|
+
set: function(pushedEvent) {
|
|
25
|
+
// TODO: verify event property
|
|
26
|
+
return pushedEvent?.language;
|
|
27
|
+
},
|
|
28
|
+
{{else}}
|
|
29
|
+
{{#if isShopify}}
|
|
30
|
+
on: ShopifyReady,
|
|
31
|
+
set: function() {
|
|
32
|
+
return window.Shopify?.locale;
|
|
33
|
+
},
|
|
34
|
+
{{else}}
|
|
35
|
+
// TODO: set proper 'on' event listener
|
|
36
|
+
set: function() {
|
|
37
|
+
// TODO: return value
|
|
38
|
+
},
|
|
39
|
+
{{/if}}
|
|
40
|
+
{{/if}}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
key: 'country',
|
|
44
|
+
type: 'SessionDimension',
|
|
45
|
+
{{#if useGATracking}}
|
|
46
|
+
on: 'dataLayer',
|
|
47
|
+
set: function(pushedEvent) {
|
|
48
|
+
// TODO: verify event property
|
|
49
|
+
return pushedEvent?.country;
|
|
50
|
+
},
|
|
51
|
+
{{else}}
|
|
52
|
+
{{#if isShopify}}
|
|
53
|
+
on: ShopifyReady,
|
|
54
|
+
set: function() {
|
|
55
|
+
return window.Shopify?.country;
|
|
56
|
+
},
|
|
57
|
+
{{else}}
|
|
58
|
+
// TODO: set proper 'on' event listener
|
|
59
|
+
set: function() {
|
|
60
|
+
// TODO: return value
|
|
61
|
+
},
|
|
62
|
+
{{/if}}
|
|
63
|
+
{{/if}}
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
key: 'currency',
|
|
67
|
+
type: 'SessionDimension',
|
|
68
|
+
{{#if useGATracking}}
|
|
69
|
+
on: 'dataLayer',
|
|
70
|
+
set: function(pushedEvent) {
|
|
71
|
+
// TODO: verify event property
|
|
72
|
+
return pushedEvent?.currency;
|
|
73
|
+
},
|
|
74
|
+
{{else}}
|
|
75
|
+
{{#if isShopify}}
|
|
76
|
+
on: ShopifyReady,
|
|
77
|
+
set: function() {
|
|
78
|
+
return window.Shopify?.currency?.active;
|
|
79
|
+
},
|
|
80
|
+
{{else}}
|
|
81
|
+
// TODO: set proper 'on' event listener
|
|
82
|
+
set: function() {
|
|
83
|
+
// TODO: return value
|
|
84
|
+
},
|
|
85
|
+
{{/if}}
|
|
86
|
+
{{/if}}
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
key: 'loggedIn',
|
|
90
|
+
type: 'SessionDimension',
|
|
91
|
+
{{#if useGATracking}}
|
|
92
|
+
on: 'dataLayer',
|
|
93
|
+
set: function(pushedEvent) {
|
|
94
|
+
return pushedEvent?.isLoggedIn;
|
|
95
|
+
},
|
|
96
|
+
{{else}}
|
|
97
|
+
// TODO: set proper 'on' event listener
|
|
98
|
+
set: function() {
|
|
99
|
+
// TODO: return value
|
|
100
|
+
},
|
|
101
|
+
{{/if}}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
key: 'pageType',
|
|
105
|
+
type: 'PiDimension',
|
|
106
|
+
{{#if isShopify}}
|
|
107
|
+
on: ShopifyAnalyticsReady,
|
|
108
|
+
set: function() {
|
|
109
|
+
var pathname = window.location.pathname;
|
|
110
|
+
// TODO: verify pathname patterns
|
|
111
|
+
if (pathname.indexOf('/checkouts/') > -1) {
|
|
112
|
+
return 'checkout';
|
|
113
|
+
} if (pathname.indexOf('/account/login') > -1) {
|
|
114
|
+
return 'login';
|
|
115
|
+
} if (pathname.indexOf('/account/register') > -1) {
|
|
116
|
+
return 'register';
|
|
117
|
+
} if (pathname.indexOf('/account') > -1) {
|
|
118
|
+
return 'account';
|
|
119
|
+
} else {
|
|
120
|
+
return window.ShopifyAnalytics?.meta?.page?.pageType;
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{{else}}
|
|
124
|
+
{{#if useGATracking}}
|
|
125
|
+
on: 'dataLayer',
|
|
126
|
+
set: function(pushedEvent) {
|
|
127
|
+
// TODO: verify event property
|
|
128
|
+
return pushedEvent?.pageCategory;
|
|
129
|
+
},
|
|
130
|
+
{{else}}
|
|
131
|
+
// TODO: set proper 'on' event listener
|
|
132
|
+
set: function() {
|
|
133
|
+
// TODO: return value
|
|
134
|
+
},
|
|
135
|
+
{{/if}}
|
|
136
|
+
{{/if}}
|
|
137
|
+
},
|
|
138
|
+
{{#if useGATracking}}
|
|
139
|
+
|
|
140
|
+
// TODO: remove or adapt if events are not properly covered by GAEcommerceTrackingPlugin
|
|
141
|
+
// {
|
|
142
|
+
// key: 'ecAddToCart',
|
|
143
|
+
// on: 'dataLayer',
|
|
144
|
+
// append: function (pushedEvent) {
|
|
145
|
+
// if (!pushedEvent?.ecommerce?.add?.products) {
|
|
146
|
+
// // Ignore, because the passed event was not a 'addToCart' event.
|
|
147
|
+
// return;
|
|
148
|
+
// }
|
|
149
|
+
//
|
|
150
|
+
// var aTCProductsArray = [];
|
|
151
|
+
// var ecommerce = pushedEvent.ecommerce;
|
|
152
|
+
// var currencyCode = ecommerce.currencyCode;
|
|
153
|
+
//
|
|
154
|
+
// // iterate over all added products
|
|
155
|
+
// for (var i = 0; i < ecommerce.add.products.length; i++) {
|
|
156
|
+
// aTCProductsArray.push({
|
|
157
|
+
// id: ecommerce.add.products[i].id ? ecommerce.add.products[i].id : location.href,
|
|
158
|
+
// currencyCode: currencyCode ? currencyCode : 'EUR',
|
|
159
|
+
// price: Number(ecommerce.add.products[i].price),
|
|
160
|
+
// quantity: ecommerce.add.products[i].quantity ? ecommerce.add.products[i].quantity : 1,
|
|
161
|
+
// });
|
|
162
|
+
// }
|
|
163
|
+
//
|
|
164
|
+
// if (aTCProductsArray.length > 0) {
|
|
165
|
+
// return aTCProductsArray;
|
|
166
|
+
// }
|
|
167
|
+
// },
|
|
168
|
+
// },
|
|
169
|
+
//
|
|
170
|
+
// // Confirmation tracking
|
|
171
|
+
// {
|
|
172
|
+
// key: 'ecConversion',
|
|
173
|
+
// on: 'dataLayer',
|
|
174
|
+
// set: function (pushedEvent) {
|
|
175
|
+
// if (!pushedEvent?.ecommerce?.purchase) {
|
|
176
|
+
// // Ignore, because the passed event was not a 'purchase' event.
|
|
177
|
+
// return;
|
|
178
|
+
// }
|
|
179
|
+
//
|
|
180
|
+
// var purchase = pushedEvent.ecommerce.purchase;
|
|
181
|
+
// if (!purchase.actionField) {
|
|
182
|
+
// return;
|
|
183
|
+
// }
|
|
184
|
+
//
|
|
185
|
+
// var orderId = purchase.actionField.id;
|
|
186
|
+
// var orderValue = String(purchase.actionField.revenue).replace(',', '.');
|
|
187
|
+
// return {
|
|
188
|
+
// id: String(orderId), currencyCode: 'EUR', revenue: Number(orderValue),
|
|
189
|
+
// };
|
|
190
|
+
// },
|
|
191
|
+
// },
|
|
192
|
+
{{else}}
|
|
193
|
+
{{#if isShopify}}
|
|
194
|
+
|
|
195
|
+
// {
|
|
196
|
+
// key: 'ecAddToCart',
|
|
197
|
+
// on: onAddToCartClick,
|
|
198
|
+
// set: function () {
|
|
199
|
+
// if (window.ShopifyAnalytics?.lib) {
|
|
200
|
+
// var shopifyData = window.ShopifyAnalytics.lib;
|
|
201
|
+
// var product;
|
|
202
|
+
//
|
|
203
|
+
// if (shopifyData && shopifyData.length) {
|
|
204
|
+
// shopifyData.forEach(item => {
|
|
205
|
+
// if (item[1] === "Viewed Product Variant") {
|
|
206
|
+
// if(item.length > 2){
|
|
207
|
+
// product = item[2];
|
|
208
|
+
// }
|
|
209
|
+
// }
|
|
210
|
+
// });
|
|
211
|
+
//
|
|
212
|
+
// if (product) {
|
|
213
|
+
// return {
|
|
214
|
+
// productId: product.productId,
|
|
215
|
+
// variantId: product.variantId,
|
|
216
|
+
// price: Number(product.price),
|
|
217
|
+
// currency: product.currency,
|
|
218
|
+
// quantity: 1,
|
|
219
|
+
// }
|
|
220
|
+
// }
|
|
221
|
+
// }
|
|
222
|
+
// }
|
|
223
|
+
// },
|
|
224
|
+
// },
|
|
225
|
+
{
|
|
226
|
+
key: 'ecConversion',
|
|
227
|
+
on: ShopifyReady,
|
|
228
|
+
set: function() {
|
|
229
|
+
var confirmationPage = location.pathname.indexOf('/thank_you') > -1;
|
|
230
|
+
if (
|
|
231
|
+
confirmationPage &&
|
|
232
|
+
window.Shopify?.checkout
|
|
233
|
+
) {
|
|
234
|
+
var orderId = window.Shopify.checkout.order_id;
|
|
235
|
+
var orderCurrency = window.Shopify.checkout.currency;
|
|
236
|
+
var orderValue = window.Shopify.checkout.total_price;
|
|
237
|
+
|
|
238
|
+
return {
|
|
239
|
+
id: orderId, currencyCode: orderCurrency, revenue: Number(orderValue),
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
{{else}}
|
|
245
|
+
|
|
246
|
+
{
|
|
247
|
+
key: 'ecAddToCart',
|
|
248
|
+
// TODO: set proper 'on' event listener
|
|
249
|
+
set: function() {
|
|
250
|
+
// TODO: return value
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
key: 'ecConversion',
|
|
255
|
+
// TODO: set proper 'on' event listener
|
|
256
|
+
set: function() {
|
|
257
|
+
// TODO: return value
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
{{/if}}
|
|
261
|
+
{{/if}}
|
|
262
|
+
);
|
|
263
|
+
{{#if isShopify}}
|
|
264
|
+
|
|
265
|
+
/* ==== */
|
|
266
|
+
|
|
267
|
+
// Shopify specific:
|
|
268
|
+
|
|
269
|
+
function ShopifyReady(cb, controller) {
|
|
270
|
+
controller.onDOMInteractive(function() {
|
|
271
|
+
function init() {
|
|
272
|
+
if (!window.Shopify) {
|
|
273
|
+
setTimeout(init, 500);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
cb();
|
|
277
|
+
}
|
|
278
|
+
init();
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function ShopifyAnalyticsReady(cb, controller) {
|
|
283
|
+
controller.onDOMInteractive(function() {
|
|
284
|
+
function init() {
|
|
285
|
+
var SA = window.ShopifyAnalytics;
|
|
286
|
+
if (!SA) {
|
|
287
|
+
setTimeout(init, 500);
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
cb();
|
|
291
|
+
}
|
|
292
|
+
init();
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// function onAddToCartClick(cb, controller) {
|
|
297
|
+
// controller.onDOMInteractive(function() {
|
|
298
|
+
// var addToCartBtn = document.querySelector('.button--add-to-cart');
|
|
299
|
+
// if(addToCartBtn) {
|
|
300
|
+
// addToCartBtn.addEventListener('click', function (t) {
|
|
301
|
+
// cb(controller);
|
|
302
|
+
// }, true);
|
|
303
|
+
// }
|
|
304
|
+
// })
|
|
305
|
+
// }
|
|
306
|
+
{{/if}}
|
|
307
|
+
{{#if isPlentymarkets}}
|
|
308
|
+
|
|
309
|
+
/* ==== */
|
|
310
|
+
|
|
311
|
+
// Plentymarkets specific:
|
|
312
|
+
|
|
313
|
+
// code for dynamic blacklisting upon user logging in
|
|
314
|
+
function sendCookiesToSpeedKit() {
|
|
315
|
+
try {
|
|
316
|
+
if (navigator.serviceWorker?.controller) {
|
|
317
|
+
navigator.serviceWorker.controller.postMessage({
|
|
318
|
+
type: 'send-cookies',
|
|
319
|
+
data: document.cookie,
|
|
320
|
+
event: 'domLoaded',
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
} catch (e) {}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function setBlacklistCookie() {
|
|
327
|
+
var expires = (new Date(Date.now() + 30*24*60*60000));
|
|
328
|
+
document.cookie = "baqend-speedkit-blacklist=true; path=/; expires=" + expires.toGMTString();
|
|
329
|
+
localStorage.setItem('baqend-speedkit-blacklist', 'true');
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function removeBlacklistCookie() {
|
|
333
|
+
document.cookie = "baqend-speedkit-blacklist=; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC";
|
|
334
|
+
localStorage.removeItem('baqend-speedkit-blacklist');
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function onDomInteractive(cb) {
|
|
338
|
+
if (document.readyState !== 'loading') {
|
|
339
|
+
return setTimeout(cb, 0);
|
|
340
|
+
}
|
|
341
|
+
document.addEventListener('DOMContentLoaded', cb);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function blacklistIfLoggedIn() {
|
|
345
|
+
// TODO: replace with customer-specific selector
|
|
346
|
+
var loggedIn = document.querySelector('#accountMenuList');
|
|
347
|
+
if (!loggedIn) {
|
|
348
|
+
removeBlacklistCookie();
|
|
349
|
+
} else {
|
|
350
|
+
setBlacklistCookie();
|
|
351
|
+
}
|
|
352
|
+
sendCookiesToSpeedKit();
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function onJSdone(cb) {
|
|
356
|
+
onDomInteractive(function() {
|
|
357
|
+
// resolve if element is already there
|
|
358
|
+
// TODO: replace with customer-specific selector
|
|
359
|
+
if (document.querySelector('#newsletterSignup')) {
|
|
360
|
+
cb();
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
|
|
364
|
+
|
|
365
|
+
// TODO: replace with customer-specific selector
|
|
366
|
+
if (!MutationObserver || !document.querySelector('header')) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
var observer = new MutationObserver(function(mutations) {
|
|
371
|
+
mutations.forEach(function(mutation) {
|
|
372
|
+
// TODO: replace with customer-specific selector
|
|
373
|
+
if(mutation.target.id ==="newsletterSignup") {
|
|
374
|
+
cb();
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
// TODO: replace with customer-specific selector
|
|
380
|
+
var target = document.querySelector('header');
|
|
381
|
+
observer.observe(target, {
|
|
382
|
+
attributes: true,
|
|
383
|
+
childList: true,
|
|
384
|
+
characterData: true,
|
|
385
|
+
subtree:true,
|
|
386
|
+
});
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
onJSdone(function() {
|
|
391
|
+
blacklistIfLoggedIn();
|
|
392
|
+
});
|
|
393
|
+
{{/if}}
|
|
394
|
+
}();
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
// Salesforce specific:
|
|
2
|
+
|
|
3
|
+
const { run: executeRefresh } = require('./speedKit.CronJob');
|
|
4
|
+
const fetch = require('node-fetch');
|
|
5
|
+
|
|
6
|
+
const minutesToMilliseconds = (minutes) => {
|
|
7
|
+
return minutes * 60000;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const deploymentConfig = {
|
|
11
|
+
slack: "<1Password deployment token>",
|
|
12
|
+
origins: [
|
|
13
|
+
"https://{{production.host}}",
|
|
14
|
+
],
|
|
15
|
+
jobType: "deployment", // "instant" | "deployment"
|
|
16
|
+
|
|
17
|
+
// configure how long the origin deployment takes in milliseconds:
|
|
18
|
+
deploymentDelay: minutesToMilliseconds(15),
|
|
19
|
+
|
|
20
|
+
// throttling the HTML refresh:
|
|
21
|
+
revalidationDelay: minutesToMilliseconds(0),
|
|
22
|
+
|
|
23
|
+
compareVersionStrings: false, // Compares version strings of the new and previous assets and only triggers deployment, when the current is newer. The version must be the first group in the regex
|
|
24
|
+
compareContentHashes: true,
|
|
25
|
+
|
|
26
|
+
assetList: [
|
|
27
|
+
// TODO: adjust/replace this exemplary list
|
|
28
|
+
"^https://{{production.host}}/on/demandware.static/Sites-(?:.*)-Site/-/[a-z]{2}_[A-Z]{2}/v(\\d{13})/js/main.js",
|
|
29
|
+
"^https://{{production.host}}/on/demandware.static/Sites-(?:.*)-Site/-/[a-z]{2}_[A-Z]{2}/v(\\d{13})/css/style.css",
|
|
30
|
+
],
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getQuery(assetRegex, origin) {
|
|
34
|
+
const query = getBaseQuery(origin);
|
|
35
|
+
query.url = { "$regex": assetRegex };
|
|
36
|
+
return query;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function getBaseQuery(...origins) {
|
|
40
|
+
return {
|
|
41
|
+
"contentType": { "$in": ["script", "style"] },
|
|
42
|
+
"variation": "DEFAULT",
|
|
43
|
+
"origin": { "$in": origins },
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const DEPLOYMENT_REFRESH_JOB_ID_TEMPLATE = '/db/jobs.Definition/deployment-refresh'
|
|
48
|
+
const DEPLOYMENT_CHECKER_JOB_ID = '/db/jobs.Definition/deployment-check'
|
|
49
|
+
const MINUTE = 60 * 1000;
|
|
50
|
+
|
|
51
|
+
exports.get = async function(db, req, res) {
|
|
52
|
+
if (!db.User.me || db.User.me.key !== '1') {
|
|
53
|
+
throw new Abort("Unauthorized");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const assetsByOrigin = {};
|
|
57
|
+
|
|
58
|
+
for (const origin of deploymentConfig.origins) {
|
|
59
|
+
assetsByOrigin[origin] = await Promise.all(deploymentConfig.assetList.map(async asset => {
|
|
60
|
+
const { url } = await findAsset(db, asset, origin) || { url: null };
|
|
61
|
+
return url;
|
|
62
|
+
}))
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
res.json(assetsByOrigin);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
exports.post = async function(db, req, res) {
|
|
70
|
+
if (!db.User.me || db.User.me.key !== '1') {
|
|
71
|
+
throw new Abort("Unauthorized");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const deploymentJobs = await Promise.all(deploymentConfig.origins.map(
|
|
75
|
+
origin => createDeploymentJob(db, deploymentConfig, origin)));
|
|
76
|
+
|
|
77
|
+
const deploymentChecker = await (new db['jobs.Definition']({
|
|
78
|
+
id: DEPLOYMENT_CHECKER_JOB_ID,
|
|
79
|
+
module: 'deploymentDetection',
|
|
80
|
+
cronpattern: '42 */10 * * * *',
|
|
81
|
+
startsAt: new Date(),
|
|
82
|
+
}).save().catch(e => e.message));
|
|
83
|
+
|
|
84
|
+
res.json({ deploymentChecker, deploymentJobs });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function getDeploymentJobId(origin) {
|
|
88
|
+
const originWithoutSlashes = origin.replace(/https:/g, '').replace(/\//g, '');
|
|
89
|
+
return `${DEPLOYMENT_REFRESH_JOB_ID_TEMPLATE}-${originWithoutSlashes}`;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function getDeploymentJobName(origin) {
|
|
93
|
+
const originWithoutSlashes = origin.replace(/https:/g, '').replace(/\//g, '');
|
|
94
|
+
return `Deployment ${originWithoutSlashes}`
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function createDeploymentJob(db, deploymentConfig, origin) {
|
|
98
|
+
return (new db['jobs.Definition']({
|
|
99
|
+
id: getDeploymentJobId(origin),
|
|
100
|
+
module: 'speedKit.CronJob',
|
|
101
|
+
cronpattern: '*/60 */24 */30 */12 *',
|
|
102
|
+
startsAt: new Date(),
|
|
103
|
+
expiresAt: new Date(1970,0, 1),
|
|
104
|
+
data: {
|
|
105
|
+
"name": getDeploymentJobName(origin),
|
|
106
|
+
"jobType": deploymentConfig.jobType || "deployment",
|
|
107
|
+
"filter": {
|
|
108
|
+
"contentTypes": [ "document" ],
|
|
109
|
+
"origin": [ origin ],
|
|
110
|
+
},
|
|
111
|
+
"scheduleIn": deploymentConfig.deploymentDelay,
|
|
112
|
+
"revalidationDelay": deploymentConfig.revalidationDelay,
|
|
113
|
+
},
|
|
114
|
+
}).save({ force: true }).catch(e => e.message));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
exports.run = async function triggerRefreshAfterDeployment(db, status) {
|
|
118
|
+
const interval = new Date(Date.now() - 10 * MINUTE - 10);
|
|
119
|
+
const origins = await findNewAsset(db, interval, deploymentConfig.origins);
|
|
120
|
+
const app = db.connection.host;
|
|
121
|
+
|
|
122
|
+
if (origins.size === 0) {
|
|
123
|
+
status.data = {refreshing: false, reason: "no new asset" };
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const data = status.data = {};
|
|
128
|
+
for (const origin of origins) {
|
|
129
|
+
try {
|
|
130
|
+
const changedAsset = await getChangedAssets(db, origin);
|
|
131
|
+
if (!changedAsset) {
|
|
132
|
+
data[origin] = {
|
|
133
|
+
refreshing: false, origin, reason: "asset hash not changed",
|
|
134
|
+
};
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const reason = `Asset changed: ${changedAsset}`;
|
|
139
|
+
fetch(deploymentConfig.slack, {
|
|
140
|
+
username: 'Deployment Detection',
|
|
141
|
+
method: 'post',
|
|
142
|
+
body: JSON.stringify({text: `Deployment on ${app} on ${origin} detected. Starting HTML ${deploymentConfig.jobType || "deployment"} Refresh. ${reason}`}),
|
|
143
|
+
}).catch(db.log.warn);
|
|
144
|
+
|
|
145
|
+
await runDeploymentJob(db, origin, reason);
|
|
146
|
+
|
|
147
|
+
data[origin] = {
|
|
148
|
+
refreshing: true, origin, latestAsset: changedAsset,
|
|
149
|
+
};
|
|
150
|
+
} catch (e) {
|
|
151
|
+
fetch(deploymentConfig.slack, {
|
|
152
|
+
username: 'Deployment Detection',
|
|
153
|
+
method: 'post',
|
|
154
|
+
body: JSON.stringify({text: `Deployment detection on ${app} and ${origin} failed. ${e.message}`}),
|
|
155
|
+
}).catch(db.log.warn);
|
|
156
|
+
data[origin] = {
|
|
157
|
+
refreshing: false, origin, reason: e.stack,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return data;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
async function getChangedAssets(db, origin) {
|
|
165
|
+
for (const urlRegex of deploymentConfig.assetList) {
|
|
166
|
+
const interval = new Date(Date.now() - 10 * MINUTE - 10);
|
|
167
|
+
const current = await findAsset(db, urlRegex, origin, interval);
|
|
168
|
+
const previous = await findAsset(db, urlRegex, origin, null, interval);
|
|
169
|
+
|
|
170
|
+
if (!current) {
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// trigger deployment since we see a new matching asset
|
|
175
|
+
if (!previous) {
|
|
176
|
+
return current.url;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (deploymentConfig.compareContentHashes) {
|
|
180
|
+
if (current.contentHash === previous.contentHash) {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (await hasCachedAsset(db, current, urlRegex, interval)) {
|
|
185
|
+
db.log.info('contentHash already known', {current, previous});
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (deploymentConfig.compareVersionStrings) {
|
|
191
|
+
const prevVersion = previous.url.match(urlRegex)[1];
|
|
192
|
+
const currentVersion = current.url.match(urlRegex)[1];
|
|
193
|
+
if (currentVersion < prevVersion) {
|
|
194
|
+
db.log.info('content version has not increased', {current, previous});
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return current.url;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
async function findAsset(db, urlRegex, origin, from, to) {
|
|
206
|
+
return await db["speedKit.Asset"].find()
|
|
207
|
+
.where(getQuery(urlRegex, origin))
|
|
208
|
+
.le('createdAt', to || new Date(Date.now() + MINUTE))
|
|
209
|
+
.gt('createdAt', from || new Date(1970, 0, 1))
|
|
210
|
+
.descending('createdAt')
|
|
211
|
+
.singleResult();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async function findNewAsset(db, from, origins) {
|
|
215
|
+
const result = await db["speedKit.Asset"].find()
|
|
216
|
+
.where(getBaseQuery(...origins))
|
|
217
|
+
.gt('createdAt', from || new Date(1970, 0, 1))
|
|
218
|
+
.resultList();
|
|
219
|
+
|
|
220
|
+
return new Set(result.map(asset => asset.origin));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
async function hasAssetChanged(asset1, asset2) {
|
|
224
|
+
const res1 = await fetch(asset1.url);
|
|
225
|
+
const text1 = await res1.text();
|
|
226
|
+
|
|
227
|
+
const res2 = await fetch(asset2.url);
|
|
228
|
+
const text2 = await res2.text();
|
|
229
|
+
|
|
230
|
+
return text1 !== text2;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Check whether we have seen the hash before
|
|
235
|
+
*/
|
|
236
|
+
async function hasCachedAsset(db, asset, urlRegex, to) {
|
|
237
|
+
return (await db["speedKit.Asset"].find()
|
|
238
|
+
.where(getQuery(urlRegex, asset.origin))
|
|
239
|
+
.equal('contentType', asset.contentType)
|
|
240
|
+
.equal('variation', asset.variation)
|
|
241
|
+
.equal('contentHash', asset.contentHash)
|
|
242
|
+
.le('createdAt', to || new Date(Date.now() + MINUTE))
|
|
243
|
+
.count()
|
|
244
|
+
) > 0;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
async function runDeploymentJob(db, origin, reason) {
|
|
248
|
+
const status = new db['jobs.Status']();
|
|
249
|
+
const jobId = getDeploymentJobId(origin);
|
|
250
|
+
const cronjob = await db['jobs.Definition'].load(jobId);
|
|
251
|
+
// TODO: quite hacky right now we may need a way to pass additional parameters to the run job code
|
|
252
|
+
cronjob.data.reason = reason;
|
|
253
|
+
status.cronjob = cronjob;
|
|
254
|
+
|
|
255
|
+
try {
|
|
256
|
+
await executeRefresh(db, status, cronjob);
|
|
257
|
+
} catch(error) {
|
|
258
|
+
status.status = 'failed';
|
|
259
|
+
status.error = error;
|
|
260
|
+
await status.save();
|
|
261
|
+
}
|
|
262
|
+
}
|