firebase-tools-with-isolate 12.9.1-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/LICENSE +21 -0
- package/README.md +48 -0
- package/lib/accountExporter.js +207 -0
- package/lib/accountImporter.js +305 -0
- package/lib/api.js +84 -0
- package/lib/apiv2.js +353 -0
- package/lib/appdistribution/client.js +193 -0
- package/lib/appdistribution/distribution.js +51 -0
- package/lib/appdistribution/options-parser-util.js +51 -0
- package/lib/archiveDirectory.js +120 -0
- package/lib/auth.js +535 -0
- package/lib/bin/firebase.js +132 -0
- package/lib/checkMinRequiredVersion.js +14 -0
- package/lib/checkValidTargetFilters.js +46 -0
- package/lib/command.js +250 -0
- package/lib/commands/appdistribution-distribute.js +121 -0
- package/lib/commands/appdistribution-group-create.js +19 -0
- package/lib/commands/appdistribution-group-delete.js +24 -0
- package/lib/commands/appdistribution-testers-add.js +24 -0
- package/lib/commands/appdistribution-testers-remove.js +40 -0
- package/lib/commands/apps-android-sha-create.js +29 -0
- package/lib/commands/apps-android-sha-delete.js +16 -0
- package/lib/commands/apps-android-sha-list.js +42 -0
- package/lib/commands/apps-create.js +166 -0
- package/lib/commands/apps-list.js +53 -0
- package/lib/commands/apps-sdkconfig.js +103 -0
- package/lib/commands/auth-export.js +44 -0
- package/lib/commands/auth-import.js +114 -0
- package/lib/commands/crashlytics-mappingfile-generateid.js +26 -0
- package/lib/commands/crashlytics-mappingfile-upload.js +46 -0
- package/lib/commands/crashlytics-symbols-upload.js +78 -0
- package/lib/commands/database-get.js +122 -0
- package/lib/commands/database-import.js +85 -0
- package/lib/commands/database-instances-create.js +29 -0
- package/lib/commands/database-instances-list.js +53 -0
- package/lib/commands/database-profile.js +46 -0
- package/lib/commands/database-push.js +63 -0
- package/lib/commands/database-remove.js +42 -0
- package/lib/commands/database-rules-canary.js +24 -0
- package/lib/commands/database-rules-get.js +22 -0
- package/lib/commands/database-rules-list.js +36 -0
- package/lib/commands/database-rules-release.js +24 -0
- package/lib/commands/database-rules-stage.js +26 -0
- package/lib/commands/database-set.js +68 -0
- package/lib/commands/database-settings-get.js +44 -0
- package/lib/commands/database-settings-set.js +46 -0
- package/lib/commands/database-update.js +69 -0
- package/lib/commands/deploy.js +101 -0
- package/lib/commands/emulators-exec.js +19 -0
- package/lib/commands/emulators-export.js +14 -0
- package/lib/commands/emulators-start.js +115 -0
- package/lib/commands/experimental-functions-shell.js +13 -0
- package/lib/commands/experiments-describe.js +31 -0
- package/lib/commands/experiments-disable.js +28 -0
- package/lib/commands/experiments-enable.js +28 -0
- package/lib/commands/experiments-list.js +29 -0
- package/lib/commands/ext-configure.js +110 -0
- package/lib/commands/ext-dev-deprecate.js +68 -0
- package/lib/commands/ext-dev-init.js +148 -0
- package/lib/commands/ext-dev-list.js +47 -0
- package/lib/commands/ext-dev-publish.js +32 -0
- package/lib/commands/ext-dev-register.js +50 -0
- package/lib/commands/ext-dev-undeprecate.js +57 -0
- package/lib/commands/ext-dev-upload.js +88 -0
- package/lib/commands/ext-dev-usage.js +141 -0
- package/lib/commands/ext-export.js +68 -0
- package/lib/commands/ext-info.js +118 -0
- package/lib/commands/ext-install.js +167 -0
- package/lib/commands/ext-list.js +18 -0
- package/lib/commands/ext-uninstall.js +29 -0
- package/lib/commands/ext-update.js +105 -0
- package/lib/commands/ext.js +41 -0
- package/lib/commands/firestore-databases-create.js +55 -0
- package/lib/commands/firestore-databases-delete.js +39 -0
- package/lib/commands/firestore-databases-get.js +25 -0
- package/lib/commands/firestore-databases-list.js +24 -0
- package/lib/commands/firestore-databases-update.js +59 -0
- package/lib/commands/firestore-delete.js +88 -0
- package/lib/commands/firestore-indexes-list.js +38 -0
- package/lib/commands/firestore-locations.js +24 -0
- package/lib/commands/frameworks-backends-create.js +14 -0
- package/lib/commands/frameworks-backends-delete.js +98 -0
- package/lib/commands/frameworks-backends-get.js +80 -0
- package/lib/commands/frameworks-backends-list.js +68 -0
- package/lib/commands/functions-config-clone.js +53 -0
- package/lib/commands/functions-config-export.js +118 -0
- package/lib/commands/functions-config-get.js +35 -0
- package/lib/commands/functions-config-set.js +43 -0
- package/lib/commands/functions-config-unset.js +42 -0
- package/lib/commands/functions-delete.js +95 -0
- package/lib/commands/functions-deletegcfartifacts.js +44 -0
- package/lib/commands/functions-list.js +47 -0
- package/lib/commands/functions-log.js +34 -0
- package/lib/commands/functions-secrets-access.js +22 -0
- package/lib/commands/functions-secrets-destroy.js +64 -0
- package/lib/commands/functions-secrets-get.js +28 -0
- package/lib/commands/functions-secrets-prune.js +57 -0
- package/lib/commands/functions-secrets-set.js +108 -0
- package/lib/commands/functions-shell.js +15 -0
- package/lib/commands/help.js +27 -0
- package/lib/commands/hosting-channel-create.js +78 -0
- package/lib/commands/hosting-channel-delete.js +47 -0
- package/lib/commands/hosting-channel-deploy.js +146 -0
- package/lib/commands/hosting-channel-list.js +40 -0
- package/lib/commands/hosting-channel-open.js +48 -0
- package/lib/commands/hosting-clone.js +103 -0
- package/lib/commands/hosting-disable.js +31 -0
- package/lib/commands/hosting-sites-create.js +34 -0
- package/lib/commands/hosting-sites-delete.js +39 -0
- package/lib/commands/hosting-sites-get.js +27 -0
- package/lib/commands/hosting-sites-list.js +28 -0
- package/lib/commands/index.js +191 -0
- package/lib/commands/init.js +195 -0
- package/lib/commands/internaltesting-frameworks-compose.js +22 -0
- package/lib/commands/internaltesting-functions-discover.js +25 -0
- package/lib/commands/login-add.js +32 -0
- package/lib/commands/login-ci.js +25 -0
- package/lib/commands/login-list.js +28 -0
- package/lib/commands/login-use.js +24 -0
- package/lib/commands/login.js +57 -0
- package/lib/commands/logout.js +76 -0
- package/lib/commands/open.js +100 -0
- package/lib/commands/projects-addfirebase.js +19 -0
- package/lib/commands/projects-create.js +37 -0
- package/lib/commands/projects-list.js +61 -0
- package/lib/commands/remoteconfig-get.js +68 -0
- package/lib/commands/remoteconfig-rollback.js +48 -0
- package/lib/commands/remoteconfig-versions-list.js +34 -0
- package/lib/commands/serve.js +60 -0
- package/lib/commands/setup-emulators-database.js +12 -0
- package/lib/commands/setup-emulators-firestore.js +12 -0
- package/lib/commands/setup-emulators-pubsub.js +12 -0
- package/lib/commands/setup-emulators-storage.js +12 -0
- package/lib/commands/setup-emulators-ui.js +12 -0
- package/lib/commands/target-apply.js +24 -0
- package/lib/commands/target-clear.js +20 -0
- package/lib/commands/target-remove.js +20 -0
- package/lib/commands/target.js +34 -0
- package/lib/commands/use.js +162 -0
- package/lib/config.js +227 -0
- package/lib/configstore.js +6 -0
- package/lib/crashlytics/buildToolsJarHelper.js +51 -0
- package/lib/database/api.js +19 -0
- package/lib/database/import.js +218 -0
- package/lib/database/listRemote.js +37 -0
- package/lib/database/metadata.js +67 -0
- package/lib/database/remove.js +88 -0
- package/lib/database/removeRemote.js +51 -0
- package/lib/database/rulesConfig.js +79 -0
- package/lib/database/settings.js +62 -0
- package/lib/defaultCredentials.js +80 -0
- package/lib/deploy/database/deploy.js +5 -0
- package/lib/deploy/database/index.js +9 -0
- package/lib/deploy/database/prepare.js +54 -0
- package/lib/deploy/database/release.js +30 -0
- package/lib/deploy/extensions/args.js +2 -0
- package/lib/deploy/extensions/deploy.js +49 -0
- package/lib/deploy/extensions/deploymentSummary.js +56 -0
- package/lib/deploy/extensions/errors.js +31 -0
- package/lib/deploy/extensions/index.js +9 -0
- package/lib/deploy/extensions/planner.js +157 -0
- package/lib/deploy/extensions/prepare.js +110 -0
- package/lib/deploy/extensions/release.js +57 -0
- package/lib/deploy/extensions/secrets.js +150 -0
- package/lib/deploy/extensions/tasks.js +156 -0
- package/lib/deploy/extensions/v2FunctionHelper.js +53 -0
- package/lib/deploy/extensions/validate.js +17 -0
- package/lib/deploy/firestore/deploy.js +44 -0
- package/lib/deploy/firestore/index.js +9 -0
- package/lib/deploy/firestore/prepare.js +59 -0
- package/lib/deploy/firestore/release.js +22 -0
- package/lib/deploy/functions/args.js +2 -0
- package/lib/deploy/functions/backend.js +316 -0
- package/lib/deploy/functions/build.js +311 -0
- package/lib/deploy/functions/cache/applyHash.js +22 -0
- package/lib/deploy/functions/cache/hash.js +30 -0
- package/lib/deploy/functions/cel.js +365 -0
- package/lib/deploy/functions/checkIam.js +183 -0
- package/lib/deploy/functions/containerCleaner.js +305 -0
- package/lib/deploy/functions/deploy.js +108 -0
- package/lib/deploy/functions/ensure.js +105 -0
- package/lib/deploy/functions/ensureCloudBuildEnabled.js +1 -0
- package/lib/deploy/functions/functionsDeployHelper.js +134 -0
- package/lib/deploy/functions/index.js +9 -0
- package/lib/deploy/functions/params.js +517 -0
- package/lib/deploy/functions/prepare.js +304 -0
- package/lib/deploy/functions/prepareFunctionsUpload.js +113 -0
- package/lib/deploy/functions/pricing.js +171 -0
- package/lib/deploy/functions/prompts.js +157 -0
- package/lib/deploy/functions/release/executor.js +51 -0
- package/lib/deploy/functions/release/fabricator.js +584 -0
- package/lib/deploy/functions/release/index.js +93 -0
- package/lib/deploy/functions/release/planner.js +205 -0
- package/lib/deploy/functions/release/reporter.js +196 -0
- package/lib/deploy/functions/release/sourceTokenScraper.js +67 -0
- package/lib/deploy/functions/release/timer.js +14 -0
- package/lib/deploy/functions/runtimes/discovery/index.js +85 -0
- package/lib/deploy/functions/runtimes/discovery/mockDiscoveryServer.js +14 -0
- package/lib/deploy/functions/runtimes/discovery/parsing.js +95 -0
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +296 -0
- package/lib/deploy/functions/runtimes/index.js +59 -0
- package/lib/deploy/functions/runtimes/node/extractTriggers.js +23 -0
- package/lib/deploy/functions/runtimes/node/index.js +173 -0
- package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +57 -0
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +332 -0
- package/lib/deploy/functions/runtimes/node/triggerParser.js +72 -0
- package/lib/deploy/functions/runtimes/node/validate.js +34 -0
- package/lib/deploy/functions/runtimes/node/versioning.js +95 -0
- package/lib/deploy/functions/runtimes/python/index.js +154 -0
- package/lib/deploy/functions/services/auth.js +95 -0
- package/lib/deploy/functions/services/database.js +14 -0
- package/lib/deploy/functions/services/firebaseAlerts.js +14 -0
- package/lib/deploy/functions/services/firestore.js +17 -0
- package/lib/deploy/functions/services/index.js +117 -0
- package/lib/deploy/functions/services/remoteConfig.js +14 -0
- package/lib/deploy/functions/services/storage.js +44 -0
- package/lib/deploy/functions/services/testLab.js +14 -0
- package/lib/deploy/functions/triggerRegionHelper.js +16 -0
- package/lib/deploy/functions/validate.js +198 -0
- package/lib/deploy/hosting/args.js +2 -0
- package/lib/deploy/hosting/context.js +2 -0
- package/lib/deploy/hosting/convertConfig.js +181 -0
- package/lib/deploy/hosting/deploy.js +85 -0
- package/lib/deploy/hosting/hashcache.js +48 -0
- package/lib/deploy/hosting/index.js +9 -0
- package/lib/deploy/hosting/prepare.js +162 -0
- package/lib/deploy/hosting/release.js +40 -0
- package/lib/deploy/hosting/uploader.js +207 -0
- package/lib/deploy/index.js +127 -0
- package/lib/deploy/lifecycleHooks.js +151 -0
- package/lib/deploy/remoteconfig/deploy.js +4 -0
- package/lib/deploy/remoteconfig/functions.js +69 -0
- package/lib/deploy/remoteconfig/index.js +9 -0
- package/lib/deploy/remoteconfig/prepare.js +23 -0
- package/lib/deploy/remoteconfig/release.js +14 -0
- package/lib/deploy/storage/deploy.js +12 -0
- package/lib/deploy/storage/index.js +9 -0
- package/lib/deploy/storage/prepare.js +52 -0
- package/lib/deploy/storage/release.js +27 -0
- package/lib/deploymentTool.js +22 -0
- package/lib/detectProjectRoot.js +28 -0
- package/lib/downloadUtils.js +37 -0
- package/lib/dynamicImport.js +22 -0
- package/lib/emulator/ExpressBasedEmulator.js +92 -0
- package/lib/emulator/adminSdkConfig.js +65 -0
- package/lib/emulator/auth/apiSpec.js +8138 -0
- package/lib/emulator/auth/cloudFunctions.js +70 -0
- package/lib/emulator/auth/errors.js +77 -0
- package/lib/emulator/auth/handlers.js +281 -0
- package/lib/emulator/auth/index.js +146 -0
- package/lib/emulator/auth/operations.js +2145 -0
- package/lib/emulator/auth/schema.js +2 -0
- package/lib/emulator/auth/server.js +474 -0
- package/lib/emulator/auth/state.js +668 -0
- package/lib/emulator/auth/types.js +2 -0
- package/lib/emulator/auth/utils.js +84 -0
- package/lib/emulator/auth/widget_ui.js +620 -0
- package/lib/emulator/commandUtils.js +380 -0
- package/lib/emulator/constants.js +111 -0
- package/lib/emulator/controller.js +654 -0
- package/lib/emulator/databaseEmulator.js +172 -0
- package/lib/emulator/dns.js +49 -0
- package/lib/emulator/download.js +88 -0
- package/lib/emulator/downloadableEmulators.js +384 -0
- package/lib/emulator/emulatorLogger.js +237 -0
- package/lib/emulator/env.js +37 -0
- package/lib/emulator/eventarcEmulator.js +143 -0
- package/lib/emulator/eventarcEmulatorUtils.js +62 -0
- package/lib/emulator/events/types.js +28 -0
- package/lib/emulator/extensions/postinstall.js +41 -0
- package/lib/emulator/extensions/validation.js +72 -0
- package/lib/emulator/extensionsEmulator.js +254 -0
- package/lib/emulator/firestoreEmulator.js +96 -0
- package/lib/emulator/functionsEmulator.js +1038 -0
- package/lib/emulator/functionsEmulatorRuntime.js +730 -0
- package/lib/emulator/functionsEmulatorShared.js +322 -0
- package/lib/emulator/functionsEmulatorShell.js +88 -0
- package/lib/emulator/functionsEmulatorUtils.js +91 -0
- package/lib/emulator/functionsRuntimeWorker.js +314 -0
- package/lib/emulator/hostingEmulator.js +40 -0
- package/lib/emulator/hub.js +162 -0
- package/lib/emulator/hubClient.js +53 -0
- package/lib/emulator/hubExport.js +208 -0
- package/lib/emulator/loggingEmulator.js +118 -0
- package/lib/emulator/portUtils.js +323 -0
- package/lib/emulator/pubsubEmulator.js +186 -0
- package/lib/emulator/registry.js +122 -0
- package/lib/emulator/shared/request.js +19 -0
- package/lib/emulator/storage/apis/firebase.js +500 -0
- package/lib/emulator/storage/apis/gcloud.js +405 -0
- package/lib/emulator/storage/apis/shared.js +44 -0
- package/lib/emulator/storage/cloudFunctions.js +88 -0
- package/lib/emulator/storage/crc.js +33 -0
- package/lib/emulator/storage/errors.js +9 -0
- package/lib/emulator/storage/files.js +410 -0
- package/lib/emulator/storage/index.js +98 -0
- package/lib/emulator/storage/metadata.js +349 -0
- package/lib/emulator/storage/multipart.js +63 -0
- package/lib/emulator/storage/persistence.js +92 -0
- package/lib/emulator/storage/rules/config.js +53 -0
- package/lib/emulator/storage/rules/expressionValue.js +2 -0
- package/lib/emulator/storage/rules/manager.js +88 -0
- package/lib/emulator/storage/rules/runtime.js +363 -0
- package/lib/emulator/storage/rules/types.js +19 -0
- package/lib/emulator/storage/rules/utils.js +60 -0
- package/lib/emulator/storage/server.js +113 -0
- package/lib/emulator/storage/upload.js +143 -0
- package/lib/emulator/types.js +200 -0
- package/lib/emulator/ui.js +52 -0
- package/lib/emulator/workQueue.js +114 -0
- package/lib/ensureApiEnabled.js +110 -0
- package/lib/ensureCloudResourceLocation.js +12 -0
- package/lib/error.js +29 -0
- package/lib/errorOut.js +23 -0
- package/lib/experiments.js +153 -0
- package/lib/extensions/askUserForEventsConfig.js +97 -0
- package/lib/extensions/askUserForParam.js +338 -0
- package/lib/extensions/billingMigrationHelper.js +61 -0
- package/lib/extensions/change-log.js +95 -0
- package/lib/extensions/checkProjectBilling.js +82 -0
- package/lib/extensions/diagnose.js +56 -0
- package/lib/extensions/displayExtensionInfo.js +175 -0
- package/lib/extensions/emulator/optionsHelper.js +73 -0
- package/lib/extensions/emulator/specHelper.js +102 -0
- package/lib/extensions/emulator/triggerHelper.js +105 -0
- package/lib/extensions/etags.js +28 -0
- package/lib/extensions/export.js +64 -0
- package/lib/extensions/extensionsApi.js +361 -0
- package/lib/extensions/extensionsHelper.js +862 -0
- package/lib/extensions/listExtensions.js +53 -0
- package/lib/extensions/localHelper.js +67 -0
- package/lib/extensions/manifest.js +205 -0
- package/lib/extensions/metricsTypeDef.js +2 -0
- package/lib/extensions/metricsUtils.js +98 -0
- package/lib/extensions/paramHelper.js +140 -0
- package/lib/extensions/provisioningHelper.js +109 -0
- package/lib/extensions/publishHelpers.js +8 -0
- package/lib/extensions/publisherApi.js +214 -0
- package/lib/extensions/refs.js +67 -0
- package/lib/extensions/resolveSource.js +24 -0
- package/lib/extensions/secretsUtils.js +60 -0
- package/lib/extensions/tos.js +90 -0
- package/lib/extensions/types.js +25 -0
- package/lib/extensions/updateHelper.js +127 -0
- package/lib/extensions/utils.js +63 -0
- package/lib/extensions/versionHelper.js +14 -0
- package/lib/extensions/warnings.js +44 -0
- package/lib/fetchMOTD.js +46 -0
- package/lib/fetchWebSetup.js +75 -0
- package/lib/filterTargets.js +34 -0
- package/lib/firebaseConfig.js +2 -0
- package/lib/firebaseConfigValidate.js +29 -0
- package/lib/firestore/api-sort.js +118 -0
- package/lib/firestore/api-spec.js +2 -0
- package/lib/firestore/api-types.js +60 -0
- package/lib/firestore/api.js +566 -0
- package/lib/firestore/checkDatabaseType.js +18 -0
- package/lib/firestore/delete.js +347 -0
- package/lib/firestore/encodeFirestoreValue.js +59 -0
- package/lib/firestore/fsConfig.js +74 -0
- package/lib/firestore/options.js +2 -0
- package/lib/firestore/util.js +39 -0
- package/lib/firestore/validator.js +38 -0
- package/lib/frameworks/angular/index.js +193 -0
- package/lib/frameworks/angular/interfaces.js +2 -0
- package/lib/frameworks/angular/utils.js +431 -0
- package/lib/frameworks/astro/index.js +73 -0
- package/lib/frameworks/astro/utils.js +40 -0
- package/lib/frameworks/compose/discover/filesystem.js +52 -0
- package/lib/frameworks/compose/discover/frameworkMatcher.js +76 -0
- package/lib/frameworks/compose/discover/frameworkSpec.js +39 -0
- package/lib/frameworks/compose/discover/index.js +32 -0
- package/lib/frameworks/compose/discover/runtime/node.js +149 -0
- package/lib/frameworks/compose/discover/types.js +2 -0
- package/lib/frameworks/compose/driver/docker.js +187 -0
- package/lib/frameworks/compose/driver/hooks.js +22 -0
- package/lib/frameworks/compose/driver/index.js +16 -0
- package/lib/frameworks/compose/driver/local.js +51 -0
- package/lib/frameworks/compose/index.js +31 -0
- package/lib/frameworks/compose/interfaces.js +21 -0
- package/lib/frameworks/constants.js +40 -0
- package/lib/frameworks/docs/index.js +2 -0
- package/lib/frameworks/express/index.js +102 -0
- package/lib/frameworks/flutter/constants.js +72 -0
- package/lib/frameworks/flutter/index.js +58 -0
- package/lib/frameworks/flutter/utils.js +11 -0
- package/lib/frameworks/frameworks.js +31 -0
- package/lib/frameworks/index.js +421 -0
- package/lib/frameworks/interfaces.js +2 -0
- package/lib/frameworks/lit/index.js +23 -0
- package/lib/frameworks/next/constants.js +12 -0
- package/lib/frameworks/next/index.js +403 -0
- package/lib/frameworks/next/interfaces.js +2 -0
- package/lib/frameworks/next/utils.js +197 -0
- package/lib/frameworks/nuxt/index.js +92 -0
- package/lib/frameworks/nuxt/interfaces.js +2 -0
- package/lib/frameworks/nuxt/utils.js +23 -0
- package/lib/frameworks/nuxt2/index.js +79 -0
- package/lib/frameworks/preact/index.js +23 -0
- package/lib/frameworks/react/index.js +23 -0
- package/lib/frameworks/svelte/index.js +23 -0
- package/lib/frameworks/sveltekit/index.js +54 -0
- package/lib/frameworks/sveltekit/interfaces.js +2 -0
- package/lib/frameworks/utils.js +260 -0
- package/lib/frameworks/vite/index.js +99 -0
- package/lib/fsAsync.js +43 -0
- package/lib/fsutils.js +35 -0
- package/lib/functional.js +87 -0
- package/lib/functions/constants.js +14 -0
- package/lib/functions/ensureTargeted.js +21 -0
- package/lib/functions/env.js +246 -0
- package/lib/functions/events/index.js +7 -0
- package/lib/functions/events/v1.js +6 -0
- package/lib/functions/events/v2.js +25 -0
- package/lib/functions/functionslog.js +35 -0
- package/lib/functions/projectConfig.js +68 -0
- package/lib/functions/python.js +23 -0
- package/lib/functions/runtimeConfigExport.js +141 -0
- package/lib/functions/secrets.js +239 -0
- package/lib/functionsConfig.js +157 -0
- package/lib/functionsConfigClone.js +68 -0
- package/lib/functionsShellCommandAction.js +112 -0
- package/lib/gcp/artifactregistry.js +16 -0
- package/lib/gcp/auth.js +16 -0
- package/lib/gcp/cloudbilling.js +25 -0
- package/lib/gcp/cloudbuild.js +50 -0
- package/lib/gcp/cloudfunctions.js +351 -0
- package/lib/gcp/cloudfunctionsv2.js +389 -0
- package/lib/gcp/cloudlogging.js +25 -0
- package/lib/gcp/cloudmonitoring.js +77 -0
- package/lib/gcp/cloudscheduler.js +155 -0
- package/lib/gcp/cloudtasks.js +162 -0
- package/lib/gcp/docker.js +80 -0
- package/lib/gcp/eventarc.js +42 -0
- package/lib/gcp/firestore.js +47 -0
- package/lib/gcp/frameworks.js +40 -0
- package/lib/gcp/iam.js +76 -0
- package/lib/gcp/identityPlatform.js +44 -0
- package/lib/gcp/index.js +11 -0
- package/lib/gcp/location.js +44 -0
- package/lib/gcp/proto.js +130 -0
- package/lib/gcp/pubsub.js +34 -0
- package/lib/gcp/resourceManager.js +74 -0
- package/lib/gcp/rules.js +156 -0
- package/lib/gcp/run.js +157 -0
- package/lib/gcp/runtimeconfig.js +127 -0
- package/lib/gcp/secretManager.js +207 -0
- package/lib/gcp/serviceusage.js +24 -0
- package/lib/gcp/storage.js +111 -0
- package/lib/getDefaultDatabaseInstance.js +10 -0
- package/lib/getDefaultHostingSite.js +32 -0
- package/lib/getProjectNumber.js +15 -0
- package/lib/handlePreviewToggles.js +38 -0
- package/lib/hosting/api.js +289 -0
- package/lib/hosting/cloudRunProxy.js +52 -0
- package/lib/hosting/config.js +189 -0
- package/lib/hosting/expireUtils.js +33 -0
- package/lib/hosting/functionsProxy.js +42 -0
- package/lib/hosting/implicitInit.js +58 -0
- package/lib/hosting/initMiddleware.js +63 -0
- package/lib/hosting/interactive.js +75 -0
- package/lib/hosting/options.js +3 -0
- package/lib/hosting/proxy.js +143 -0
- package/lib/hosting/runTags.js +114 -0
- package/lib/index.js +71 -0
- package/lib/init/features/account.js +62 -0
- package/lib/init/features/database.js +133 -0
- package/lib/init/features/emulators.js +102 -0
- package/lib/init/features/extensions/index.js +16 -0
- package/lib/init/features/firestore/index.js +36 -0
- package/lib/init/features/firestore/indexes.js +71 -0
- package/lib/init/features/firestore/rules.js +80 -0
- package/lib/init/features/frameworks/constants.js +7 -0
- package/lib/init/features/frameworks/index.js +116 -0
- package/lib/init/features/frameworks/repo.js +125 -0
- package/lib/init/features/functions/index.js +165 -0
- package/lib/init/features/functions/javascript.js +46 -0
- package/lib/init/features/functions/npm-dependencies.js +37 -0
- package/lib/init/features/functions/python.js +48 -0
- package/lib/init/features/functions/typescript.js +61 -0
- package/lib/init/features/hosting/github.js +397 -0
- package/lib/init/features/hosting/index.js +183 -0
- package/lib/init/features/index.js +27 -0
- package/lib/init/features/project.js +101 -0
- package/lib/init/features/remoteconfig.js +32 -0
- package/lib/init/features/storage.js +27 -0
- package/lib/init/index.js +45 -0
- package/lib/listFiles.js +15 -0
- package/lib/loadCJSON.js +17 -0
- package/lib/localFunction.js +222 -0
- package/lib/logError.js +29 -0
- package/lib/logger.js +31 -0
- package/lib/management/apps.js +280 -0
- package/lib/management/database.js +184 -0
- package/lib/management/projects.js +312 -0
- package/lib/metaprogramming.js +2 -0
- package/lib/monospace/index.js +82 -0
- package/lib/monospace/interfaces.js +2 -0
- package/lib/operation-poller.js +59 -0
- package/lib/options.js +2 -0
- package/lib/parseBoltRules.js +29 -0
- package/lib/profileReport.js +577 -0
- package/lib/profiler.js +99 -0
- package/lib/projectPath.js +16 -0
- package/lib/projectUtils.js +59 -0
- package/lib/prompt.js +50 -0
- package/lib/rc.js +165 -0
- package/lib/remoteconfig/get.js +49 -0
- package/lib/remoteconfig/interfaces.js +17 -0
- package/lib/remoteconfig/rollback.js +22 -0
- package/lib/remoteconfig/versionslist.js +33 -0
- package/lib/requireAuth.js +81 -0
- package/lib/requireConfig.js +13 -0
- package/lib/requireDatabaseInstance.js +26 -0
- package/lib/requireHostingSite.js +12 -0
- package/lib/requireInteractive.js +12 -0
- package/lib/requirePermissions.js +30 -0
- package/lib/responseToError.js +58 -0
- package/lib/rtdb.js +35 -0
- package/lib/rulesDeploy.js +180 -0
- package/lib/scopes.js +10 -0
- package/lib/serve/functions.js +64 -0
- package/lib/serve/hosting.js +115 -0
- package/lib/serve/index.js +53 -0
- package/lib/shortenUrl.js +29 -0
- package/lib/throttler/errors/retries-exhausted-error.js +11 -0
- package/lib/throttler/errors/task-error.js +9 -0
- package/lib/throttler/errors/timeout-error.js +9 -0
- package/lib/throttler/queue.js +23 -0
- package/lib/throttler/stack.js +28 -0
- package/lib/throttler/throttler.js +230 -0
- package/lib/track.js +196 -0
- package/lib/unzip.js +126 -0
- package/lib/utils.js +488 -0
- package/package.json +239 -0
- package/schema/extension-yaml.json +432 -0
- package/schema/firebase-config.json +2619 -0
- package/standalone/check.js +6 -0
- package/standalone/config.template.js +19 -0
- package/standalone/firepit.js +1074 -0
- package/standalone/package-lock.json +7019 -0
- package/standalone/package.json +36 -0
- package/standalone/runtime.js +122 -0
- package/standalone/welcome.js +178 -0
- package/templates/_gitignore +66 -0
- package/templates/banner.txt +6 -0
- package/templates/emulators/default_storage.rules +8 -0
- package/templates/extensions/CL-template.md +2 -0
- package/templates/extensions/POSTINSTALL.md +29 -0
- package/templates/extensions/PREINSTALL.md +22 -0
- package/templates/extensions/extension.yaml +61 -0
- package/templates/extensions/integration-test.env +2 -0
- package/templates/extensions/integration-test.json +14 -0
- package/templates/extensions/javascript/WELCOME.md +18 -0
- package/templates/extensions/javascript/_gitignore +1 -0
- package/templates/extensions/javascript/index.js +25 -0
- package/templates/extensions/javascript/integration-test.js +13 -0
- package/templates/extensions/javascript/package.lint.json +25 -0
- package/templates/extensions/javascript/package.nolint.json +19 -0
- package/templates/extensions/typescript/WELCOME.md +22 -0
- package/templates/extensions/typescript/_gitignore +8 -0
- package/templates/extensions/typescript/_mocharc +10 -0
- package/templates/extensions/typescript/index.ts +26 -0
- package/templates/extensions/typescript/integration-test.ts +13 -0
- package/templates/extensions/typescript/package.lint.json +31 -0
- package/templates/extensions/typescript/package.nolint.json +24 -0
- package/templates/extensions/typescript/tsconfig.dev.json +5 -0
- package/templates/extensions/typescript/tsconfig.json +15 -0
- package/templates/firebase.json +9 -0
- package/templates/hosting/init.js +36 -0
- package/templates/init/firestore/firestore.indexes.json +26 -0
- package/templates/init/firestore/firestore.rules +16 -0
- package/templates/init/functions/javascript/_eslintrc +28 -0
- package/templates/init/functions/javascript/_gitignore +1 -0
- package/templates/init/functions/javascript/index.js +19 -0
- package/templates/init/functions/javascript/package.lint.json +26 -0
- package/templates/init/functions/javascript/package.nolint.json +23 -0
- package/templates/init/functions/python/_gitignore +0 -0
- package/templates/init/functions/python/main.py +13 -0
- package/templates/init/functions/python/requirements.txt +1 -0
- package/templates/init/functions/typescript/_eslintrc +32 -0
- package/templates/init/functions/typescript/_gitignore +9 -0
- package/templates/init/functions/typescript/index.ts +19 -0
- package/templates/init/functions/typescript/package.lint.json +31 -0
- package/templates/init/functions/typescript/package.nolint.json +25 -0
- package/templates/init/functions/typescript/tsconfig.dev.json +5 -0
- package/templates/init/functions/typescript/tsconfig.json +15 -0
- package/templates/init/hosting/404.html +33 -0
- package/templates/init/hosting/index.html +89 -0
- package/templates/init/storage/storage.rules +12 -0
- package/templates/loginFailure.html +34 -0
- package/templates/loginSuccess.html +32 -0
- package/templates/loginSuccessGithub.html +32 -0
- package/templates/setup/web.js +5 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unsafePins = exports.prepare = exports.addPinnedFunctionsToOnlyString = exports.hasPinnedFunctions = void 0;
|
|
4
|
+
const error_1 = require("../../error");
|
|
5
|
+
const api = require("../../hosting/api");
|
|
6
|
+
const config = require("../../hosting/config");
|
|
7
|
+
const deploymentTool = require("../../deploymentTool");
|
|
8
|
+
const clc = require("colorette");
|
|
9
|
+
const functional_1 = require("../../functional");
|
|
10
|
+
const track_1 = require("../../track");
|
|
11
|
+
const utils = require("../../utils");
|
|
12
|
+
const backend = require("../functions/backend");
|
|
13
|
+
const ensureTargeted_1 = require("../../functions/ensureTargeted");
|
|
14
|
+
const frameworks_1 = require("../../frameworks");
|
|
15
|
+
function handlePublicDirectoryFlag(options) {
|
|
16
|
+
if (options.public) {
|
|
17
|
+
if (Array.isArray(options.config.get("hosting"))) {
|
|
18
|
+
throw new error_1.FirebaseError("Cannot specify --public option with multi-site configuration.");
|
|
19
|
+
}
|
|
20
|
+
options.config.set("hosting.public", options.public);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function hasPinnedFunctions(options) {
|
|
24
|
+
handlePublicDirectoryFlag(options);
|
|
25
|
+
for (const c of config.hostingConfig(options)) {
|
|
26
|
+
for (const r of c.rewrites || []) {
|
|
27
|
+
if ("function" in r && typeof r.function === "object" && r.function.pinTag) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
exports.hasPinnedFunctions = hasPinnedFunctions;
|
|
35
|
+
async function addPinnedFunctionsToOnlyString(context, options) {
|
|
36
|
+
var _a;
|
|
37
|
+
if (!options.only) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
handlePublicDirectoryFlag(options);
|
|
41
|
+
const addedFunctions = [];
|
|
42
|
+
for (const c of config.hostingConfig(options)) {
|
|
43
|
+
const addedFunctionsPerSite = [];
|
|
44
|
+
for (const r of c.rewrites || []) {
|
|
45
|
+
if (!("function" in r) || typeof r.function !== "object" || !r.function.pinTag) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const endpoint = (_a = (await backend.existingBackend(context)).endpoints[r.function.region || "us-central1"]) === null || _a === void 0 ? void 0 : _a[r.function.functionId];
|
|
49
|
+
if (endpoint) {
|
|
50
|
+
options.only = (0, ensureTargeted_1.ensureTargeted)(options.only, endpoint.codebase || "default", endpoint.id);
|
|
51
|
+
}
|
|
52
|
+
else if (c.webFramework) {
|
|
53
|
+
options.only = (0, ensureTargeted_1.ensureTargeted)(options.only, (0, frameworks_1.generateSSRCodebaseId)(c.site), r.function.functionId);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
options.only = (0, ensureTargeted_1.ensureTargeted)(options.only, r.function.functionId);
|
|
57
|
+
}
|
|
58
|
+
addedFunctionsPerSite.push(r.function.functionId);
|
|
59
|
+
}
|
|
60
|
+
if (addedFunctionsPerSite.length) {
|
|
61
|
+
utils.logLabeledBullet("hosting", "The following function(s) are pinned to site " +
|
|
62
|
+
`${clc.bold(c.site)} and will be deployed as well: ` +
|
|
63
|
+
addedFunctionsPerSite.map(clc.bold).join(","));
|
|
64
|
+
addedFunctions.push(...addedFunctionsPerSite);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return addedFunctions.length !== 0;
|
|
68
|
+
}
|
|
69
|
+
exports.addPinnedFunctionsToOnlyString = addPinnedFunctionsToOnlyString;
|
|
70
|
+
async function prepare(context, options) {
|
|
71
|
+
handlePublicDirectoryFlag(options);
|
|
72
|
+
const configs = config.hostingConfig(options);
|
|
73
|
+
if (configs.length === 0) {
|
|
74
|
+
return Promise.resolve();
|
|
75
|
+
}
|
|
76
|
+
const versions = await Promise.all(configs.map(async (config) => {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
const labels = Object.assign({}, deploymentTool.labels());
|
|
79
|
+
if (config.webFramework) {
|
|
80
|
+
labels["firebase-web-framework"] = config.webFramework;
|
|
81
|
+
}
|
|
82
|
+
const unsafe = await unsafePins(context, config);
|
|
83
|
+
if (unsafe.length) {
|
|
84
|
+
const msg = `Cannot deploy site ${clc.bold(config.site)} to channel ` +
|
|
85
|
+
`${clc.bold(context.hostingChannel)} because it would modify one or ` +
|
|
86
|
+
`more rewrites in "live" that are not pinned, breaking production. ` +
|
|
87
|
+
`Please pin "live" before pinning other channels.`;
|
|
88
|
+
utils.logLabeledError("Hosting", msg);
|
|
89
|
+
throw new Error(msg);
|
|
90
|
+
}
|
|
91
|
+
const runPins = (_b = (_a = config.rewrites) === null || _a === void 0 ? void 0 : _a.filter((r) => "run" in r && r.run.pinTag)) === null || _b === void 0 ? void 0 : _b.map((r) => r.run.serviceId);
|
|
92
|
+
if (runPins === null || runPins === void 0 ? void 0 : runPins.length) {
|
|
93
|
+
utils.logLabeledBullet("hosting", `The site ${clc.bold(config.site)} will pin rewrites to the current ` +
|
|
94
|
+
`latest revision of service(s) ${runPins.map(clc.bold).join(",")}`);
|
|
95
|
+
}
|
|
96
|
+
const version = {
|
|
97
|
+
status: "CREATED",
|
|
98
|
+
labels,
|
|
99
|
+
};
|
|
100
|
+
const [, versionName] = await Promise.all([
|
|
101
|
+
(0, track_1.trackGA4)("hosting_version", {
|
|
102
|
+
framework: config.webFramework || "classic",
|
|
103
|
+
}),
|
|
104
|
+
api.createVersion(config.site, version),
|
|
105
|
+
]);
|
|
106
|
+
return versionName;
|
|
107
|
+
}));
|
|
108
|
+
context.hosting = {
|
|
109
|
+
deploys: [],
|
|
110
|
+
};
|
|
111
|
+
for (const [config, version] of configs.map((0, functional_1.zipIn)(versions))) {
|
|
112
|
+
context.hosting.deploys.push({ config, version });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.prepare = prepare;
|
|
116
|
+
function rewriteTarget(source) {
|
|
117
|
+
if ("glob" in source) {
|
|
118
|
+
return source.glob;
|
|
119
|
+
}
|
|
120
|
+
else if ("source" in source) {
|
|
121
|
+
return source.source;
|
|
122
|
+
}
|
|
123
|
+
else if ("regex" in source) {
|
|
124
|
+
return source.regex;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
(0, functional_1.assertExhaustive)(source);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async function unsafePins(context, config) {
|
|
131
|
+
var _a, _b, _c, _d;
|
|
132
|
+
if ((context.hostingChannel || "live") === "live") {
|
|
133
|
+
return [];
|
|
134
|
+
}
|
|
135
|
+
const targetTaggedRewrites = {};
|
|
136
|
+
for (const rewrite of config.rewrites || []) {
|
|
137
|
+
const target = rewriteTarget(rewrite);
|
|
138
|
+
if ("run" in rewrite && rewrite.run.pinTag) {
|
|
139
|
+
targetTaggedRewrites[target] = `${rewrite.run.region || "us-central1"}/${rewrite.run.serviceId}`;
|
|
140
|
+
}
|
|
141
|
+
if ("function" in rewrite && typeof rewrite.function === "object" && rewrite.function.pinTag) {
|
|
142
|
+
const region = rewrite.function.region || "us-central1";
|
|
143
|
+
const endpoint = (_a = (await backend.existingBackend(context)).endpoints[region]) === null || _a === void 0 ? void 0 : _a[rewrite.function.functionId];
|
|
144
|
+
if (!endpoint) {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
targetTaggedRewrites[target] = `${region}/${endpoint.runServiceId || endpoint.id}`;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (!Object.keys(targetTaggedRewrites).length) {
|
|
151
|
+
return [];
|
|
152
|
+
}
|
|
153
|
+
const channelConfig = await api.getChannel(context.projectId, config.site, "live");
|
|
154
|
+
const existingUntaggedRewrites = {};
|
|
155
|
+
for (const rewrite of ((_d = (_c = (_b = channelConfig === null || channelConfig === void 0 ? void 0 : channelConfig.release) === null || _b === void 0 ? void 0 : _b.version) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.rewrites) || []) {
|
|
156
|
+
if ("run" in rewrite && !rewrite.run.tag) {
|
|
157
|
+
existingUntaggedRewrites[rewriteTarget(rewrite)] = `${rewrite.run.region}/${rewrite.run.serviceId}`;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return Object.keys(targetTaggedRewrites).filter((target) => targetTaggedRewrites[target] === existingUntaggedRewrites[target]);
|
|
161
|
+
}
|
|
162
|
+
exports.unsafePins = unsafePins;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.release = void 0;
|
|
4
|
+
const api = require("../../hosting/api");
|
|
5
|
+
const logger_1 = require("../../logger");
|
|
6
|
+
const utils = require("../../utils");
|
|
7
|
+
const convertConfig_1 = require("./convertConfig");
|
|
8
|
+
const error_1 = require("../../error");
|
|
9
|
+
async function release(context, options, functionsPayload) {
|
|
10
|
+
if (!context.hosting || !context.hosting.deploys) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
logger_1.logger.debug(JSON.stringify(context.hosting.deploys, null, 2));
|
|
14
|
+
await Promise.all(context.hosting.deploys.map(async (deploy) => {
|
|
15
|
+
if (!deploy.version) {
|
|
16
|
+
throw new error_1.FirebaseError("Assertion failed: Hosting version should have been set in the prepare phase", { exit: 2 });
|
|
17
|
+
}
|
|
18
|
+
utils.logLabeledBullet(`hosting[${deploy.config.site}]`, "finalizing version...");
|
|
19
|
+
const update = {
|
|
20
|
+
status: "FINALIZED",
|
|
21
|
+
config: await (0, convertConfig_1.convertConfig)(context, functionsPayload, deploy),
|
|
22
|
+
};
|
|
23
|
+
const versionId = utils.last(deploy.version.split("/"));
|
|
24
|
+
const finalizedVersion = await api.updateVersion(deploy.config.site, versionId, update);
|
|
25
|
+
logger_1.logger.debug(`[hosting] finalized version for ${deploy.config.site}:${finalizedVersion}`);
|
|
26
|
+
utils.logLabeledSuccess(`hosting[${deploy.config.site}]`, "version finalized");
|
|
27
|
+
utils.logLabeledBullet(`hosting[${deploy.config.site}]`, "releasing new version...");
|
|
28
|
+
if (context.hostingChannel) {
|
|
29
|
+
logger_1.logger.debug("[hosting] releasing to channel:", context.hostingChannel);
|
|
30
|
+
}
|
|
31
|
+
const otherReleaseOpts = {};
|
|
32
|
+
if (options.message) {
|
|
33
|
+
otherReleaseOpts.message = options.message;
|
|
34
|
+
}
|
|
35
|
+
const release = await api.createRelease(deploy.config.site, context.hostingChannel || "live", deploy.version, otherReleaseOpts);
|
|
36
|
+
logger_1.logger.debug("[hosting] release:", release);
|
|
37
|
+
utils.logLabeledSuccess(`hosting[${deploy.config.site}]`, "release complete");
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
exports.release = release;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Uploader = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const abort_controller_1 = require("abort-controller");
|
|
6
|
+
const clc = require("colorette");
|
|
7
|
+
const crypto = require("crypto");
|
|
8
|
+
const fs = require("fs");
|
|
9
|
+
const path = require("path");
|
|
10
|
+
const zlib = require("zlib");
|
|
11
|
+
const apiv2_1 = require("../../apiv2");
|
|
12
|
+
const queue_1 = require("../../throttler/queue");
|
|
13
|
+
const api_1 = require("../../api");
|
|
14
|
+
const hashcache_1 = require("./hashcache");
|
|
15
|
+
const logger_1 = require("../../logger");
|
|
16
|
+
const error_1 = require("../../error");
|
|
17
|
+
const MIN_UPLOAD_TIMEOUT = 30000;
|
|
18
|
+
const MAX_UPLOAD_TIMEOUT = 7200000;
|
|
19
|
+
function progressMessage(message, current, total) {
|
|
20
|
+
current = Math.min(current, total);
|
|
21
|
+
const percent = Math.floor(((current * 1.0) / total) * 100).toString();
|
|
22
|
+
return `${message} [${current}/${total}] (${clc.bold(clc.green(`${percent}%`))})`;
|
|
23
|
+
}
|
|
24
|
+
class Uploader {
|
|
25
|
+
constructor(options) {
|
|
26
|
+
this.hashClient = new apiv2_1.Client({
|
|
27
|
+
urlPrefix: api_1.hostingApiOrigin,
|
|
28
|
+
auth: true,
|
|
29
|
+
apiVersion: "v1beta1",
|
|
30
|
+
});
|
|
31
|
+
this.version = options.version;
|
|
32
|
+
this.cwd = options.cwd || process.cwd();
|
|
33
|
+
this.projectRoot = options.projectRoot;
|
|
34
|
+
this.gzipLevel = options.gzipLevel || 9;
|
|
35
|
+
this.hashQueue = new queue_1.Queue({
|
|
36
|
+
name: "hashQueue",
|
|
37
|
+
concurrency: options.hashConcurrency || 50,
|
|
38
|
+
handler: this.hashHandler.bind(this),
|
|
39
|
+
});
|
|
40
|
+
this.populateBatchSize = options.populateBatchSize || 1000;
|
|
41
|
+
this.populateBatch = {};
|
|
42
|
+
this.populateQueue = new queue_1.Queue({
|
|
43
|
+
name: "populateQueue",
|
|
44
|
+
concurrency: options.populateConcurrency || 10,
|
|
45
|
+
handler: this.populateHandler.bind(this),
|
|
46
|
+
retries: 3,
|
|
47
|
+
});
|
|
48
|
+
this.uploadQueue = new queue_1.Queue({
|
|
49
|
+
name: "uploadQueue",
|
|
50
|
+
concurrency: options.uploadConcurrency || 200,
|
|
51
|
+
handler: this.uploadHandler.bind(this),
|
|
52
|
+
retries: 5,
|
|
53
|
+
});
|
|
54
|
+
this.public = options.public || this.cwd;
|
|
55
|
+
this.files = options.files;
|
|
56
|
+
this.fileCount = this.files.length;
|
|
57
|
+
this.cache = (0, hashcache_1.load)(this.projectRoot, this.hashcacheName());
|
|
58
|
+
this.cacheNew = new Map();
|
|
59
|
+
this.sizeMap = {};
|
|
60
|
+
this.hashMap = {};
|
|
61
|
+
this.pathMap = {};
|
|
62
|
+
}
|
|
63
|
+
hashcacheName() {
|
|
64
|
+
return Buffer.from(path.relative(this.projectRoot, this.public))
|
|
65
|
+
.toString("base64")
|
|
66
|
+
.replace(/=+$/, "");
|
|
67
|
+
}
|
|
68
|
+
async start() {
|
|
69
|
+
if (this.files.length === 0) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
for (const f of this.files) {
|
|
73
|
+
this.hashQueue.add(f);
|
|
74
|
+
}
|
|
75
|
+
this.hashQueue.close();
|
|
76
|
+
this.hashQueue.process();
|
|
77
|
+
this.hashQueue
|
|
78
|
+
.wait()
|
|
79
|
+
.then(this.queuePopulate.bind(this))
|
|
80
|
+
.then(() => {
|
|
81
|
+
(0, hashcache_1.dump)(this.projectRoot, this.hashcacheName(), this.cacheNew);
|
|
82
|
+
logger_1.logger.debug("[hosting][hash queue][FINAL]", this.hashQueue.stats());
|
|
83
|
+
this.populateQueue.close();
|
|
84
|
+
return this.populateQueue.wait();
|
|
85
|
+
})
|
|
86
|
+
.then(() => {
|
|
87
|
+
logger_1.logger.debug("[hosting][populate queue][FINAL]", this.populateQueue.stats());
|
|
88
|
+
logger_1.logger.debug("[hosting] uploads queued:", this.uploadQueue.stats().total);
|
|
89
|
+
this.uploadQueue.close();
|
|
90
|
+
});
|
|
91
|
+
this.uploadQueue.wait().catch((err) => {
|
|
92
|
+
if (err.message.includes("content hash")) {
|
|
93
|
+
logger_1.logger.debug("[hosting][upload queue] upload failed with content hash error. Deleting hash cache");
|
|
94
|
+
(0, hashcache_1.dump)(this.projectRoot, this.hashcacheName(), new Map());
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
const fin = (err) => {
|
|
98
|
+
logger_1.logger.debug("[hosting][upload queue][FINAL]", this.uploadQueue.stats());
|
|
99
|
+
if (err) {
|
|
100
|
+
throw err;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
return this.wait().then(fin).catch(fin);
|
|
104
|
+
}
|
|
105
|
+
async wait() {
|
|
106
|
+
await Promise.all([this.hashQueue.wait(), this.populateQueue.wait(), this.uploadQueue.wait()]);
|
|
107
|
+
}
|
|
108
|
+
statusMessage() {
|
|
109
|
+
if (!this.hashQueue.finished) {
|
|
110
|
+
return progressMessage("hashing files", this.hashQueue.complete, this.fileCount);
|
|
111
|
+
}
|
|
112
|
+
else if (!this.populateQueue.finished) {
|
|
113
|
+
return progressMessage("adding files to version", this.populateQueue.complete * 1000, this.fileCount);
|
|
114
|
+
}
|
|
115
|
+
else if (!this.uploadQueue.finished) {
|
|
116
|
+
return progressMessage("uploading new files", this.uploadQueue.complete, this.uploadQueue.stats().total);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
return "upload complete";
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async hashHandler(filePath) {
|
|
123
|
+
const stats = fs.statSync(path.resolve(this.public, filePath));
|
|
124
|
+
const mtime = stats.mtime.getTime();
|
|
125
|
+
this.sizeMap[filePath] = stats.size;
|
|
126
|
+
const cached = this.cache.get(filePath);
|
|
127
|
+
if (cached && cached.mtime === mtime) {
|
|
128
|
+
this.cacheNew.set(filePath, cached);
|
|
129
|
+
this.addHash(filePath, cached.hash);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const fstream = this.zipStream(filePath);
|
|
133
|
+
const hash = crypto.createHash("sha256");
|
|
134
|
+
fstream.pipe(hash);
|
|
135
|
+
return new Promise((resolve, reject) => {
|
|
136
|
+
fstream.on("end", resolve);
|
|
137
|
+
fstream.on("error", reject);
|
|
138
|
+
}).then(() => {
|
|
139
|
+
const hashVal = hash.read().toString("hex");
|
|
140
|
+
this.cacheNew.set(filePath, { mtime: mtime, hash: hashVal });
|
|
141
|
+
this.addHash(filePath, hashVal);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
addHash(filePath, hash) {
|
|
145
|
+
this.hashMap[hash] = filePath;
|
|
146
|
+
this.pathMap[filePath] = hash;
|
|
147
|
+
this.populateBatch["/" + filePath] = hash;
|
|
148
|
+
const curBatchSize = (0, lodash_1.size)(this.populateBatch);
|
|
149
|
+
if (curBatchSize > 0 && curBatchSize % this.populateBatchSize === 0) {
|
|
150
|
+
this.queuePopulate();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
queuePopulate() {
|
|
154
|
+
const pop = this.populateBatch;
|
|
155
|
+
this.populateQueue.add(pop);
|
|
156
|
+
this.populateBatch = {};
|
|
157
|
+
this.populateQueue.process();
|
|
158
|
+
}
|
|
159
|
+
async populateHandler(batch) {
|
|
160
|
+
const res = await this.hashClient.post(`/${this.version}:populateFiles`, { files: batch });
|
|
161
|
+
this.uploadUrl = res.body.uploadUrl;
|
|
162
|
+
this.uploadClient = new apiv2_1.Client({ urlPrefix: this.uploadUrl, auth: true });
|
|
163
|
+
this.addUploads(res.body.uploadRequiredHashes || []);
|
|
164
|
+
}
|
|
165
|
+
addUploads(hashes) {
|
|
166
|
+
for (const hash of hashes) {
|
|
167
|
+
this.uploadQueue.add(hash);
|
|
168
|
+
}
|
|
169
|
+
this.uploadQueue.process();
|
|
170
|
+
}
|
|
171
|
+
async uploadHandler(toUpload) {
|
|
172
|
+
if (!this.uploadClient) {
|
|
173
|
+
throw new error_1.FirebaseError("No upload client available.", { exit: 2 });
|
|
174
|
+
}
|
|
175
|
+
const controller = new abort_controller_1.default();
|
|
176
|
+
const timeout = setTimeout(() => {
|
|
177
|
+
controller.abort();
|
|
178
|
+
}, this.uploadTimeout(this.hashMap[toUpload]));
|
|
179
|
+
const res = await this.uploadClient.request({
|
|
180
|
+
method: "POST",
|
|
181
|
+
path: `/${toUpload}`,
|
|
182
|
+
body: this.zipStream(this.hashMap[toUpload]),
|
|
183
|
+
resolveOnHTTPError: true,
|
|
184
|
+
responseType: "stream",
|
|
185
|
+
signal: controller.signal,
|
|
186
|
+
});
|
|
187
|
+
clearTimeout(timeout);
|
|
188
|
+
if (this.uploadQueue.cursor % 100 === 0) {
|
|
189
|
+
logger_1.logger.debug("[hosting][upload]", this.uploadQueue.stats());
|
|
190
|
+
}
|
|
191
|
+
if (res.status !== 200) {
|
|
192
|
+
const errorMessage = await res.response.text();
|
|
193
|
+
logger_1.logger.debug(`[hosting][upload] ${this.hashMap[toUpload]} (${toUpload}) HTTP ERROR ${res.status}: headers=${JSON.stringify(res.response.headers)} ${errorMessage}`);
|
|
194
|
+
throw new Error(`Unexpected error while uploading file: ${errorMessage}`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
zipStream(filePath) {
|
|
198
|
+
const file = fs.createReadStream(path.resolve(this.public, filePath));
|
|
199
|
+
const gzip = zlib.createGzip({ level: this.gzipLevel });
|
|
200
|
+
return file.pipe(gzip);
|
|
201
|
+
}
|
|
202
|
+
uploadTimeout(filePath) {
|
|
203
|
+
const size = this.sizeMap[filePath] || 0;
|
|
204
|
+
return Math.min(Math.max(Math.round(size / 1000) * 20, MIN_UPLOAD_TIMEOUT), MAX_UPLOAD_TIMEOUT);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
exports.Uploader = Uploader;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deploy = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const logger_1 = require("../logger");
|
|
6
|
+
const api_1 = require("../api");
|
|
7
|
+
const colorette_1 = require("colorette");
|
|
8
|
+
const lodash_1 = require("lodash");
|
|
9
|
+
const projectUtils_1 = require("../projectUtils");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
const error_1 = require("../error");
|
|
12
|
+
const track_1 = require("../track");
|
|
13
|
+
const lifecycleHooks_1 = require("./lifecycleHooks");
|
|
14
|
+
const experiments = require("../experiments");
|
|
15
|
+
const HostingTarget = require("./hosting");
|
|
16
|
+
const DatabaseTarget = require("./database");
|
|
17
|
+
const FirestoreTarget = require("./firestore");
|
|
18
|
+
const FunctionsTarget = require("./functions");
|
|
19
|
+
const StorageTarget = require("./storage");
|
|
20
|
+
const RemoteConfigTarget = require("./remoteconfig");
|
|
21
|
+
const ExtensionsTarget = require("./extensions");
|
|
22
|
+
const frameworks_1 = require("../frameworks");
|
|
23
|
+
const prepare_1 = require("./hosting/prepare");
|
|
24
|
+
const github_1 = require("../init/features/hosting/github");
|
|
25
|
+
const deploy_1 = require("../commands/deploy");
|
|
26
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
27
|
+
const TARGETS = {
|
|
28
|
+
hosting: HostingTarget,
|
|
29
|
+
database: DatabaseTarget,
|
|
30
|
+
firestore: FirestoreTarget,
|
|
31
|
+
functions: FunctionsTarget,
|
|
32
|
+
storage: StorageTarget,
|
|
33
|
+
remoteconfig: RemoteConfigTarget,
|
|
34
|
+
extensions: ExtensionsTarget,
|
|
35
|
+
};
|
|
36
|
+
const chain = async function (fns, context, options, payload) {
|
|
37
|
+
for (const latest of fns) {
|
|
38
|
+
await latest(context, options, payload);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const deploy = async function (targetNames, options, customContext = {}) {
|
|
42
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
43
|
+
const payload = {};
|
|
44
|
+
const context = Object.assign({ projectId }, customContext);
|
|
45
|
+
const predeploys = [];
|
|
46
|
+
const prepares = [];
|
|
47
|
+
const deploys = [];
|
|
48
|
+
const releases = [];
|
|
49
|
+
const postdeploys = [];
|
|
50
|
+
const startTime = Date.now();
|
|
51
|
+
if (targetNames.includes("hosting")) {
|
|
52
|
+
const config = options.config.get("hosting");
|
|
53
|
+
if (Array.isArray(config) ? config.some((it) => it.source) : config.source) {
|
|
54
|
+
experiments.assertEnabled("webframeworks", "deploy a web framework from source");
|
|
55
|
+
await (0, frameworks_1.prepareFrameworks)("deploy", targetNames, context, options);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (targetNames.includes("hosting") && (0, prepare_1.hasPinnedFunctions)(options)) {
|
|
59
|
+
experiments.assertEnabled("pintags", "deploy a tagged function as a hosting rewrite");
|
|
60
|
+
if (!targetNames.includes("functions")) {
|
|
61
|
+
targetNames.unshift("functions");
|
|
62
|
+
try {
|
|
63
|
+
await (0, requirePermissions_1.requirePermissions)(options, deploy_1.TARGET_PERMISSIONS["functions"]);
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
if ((0, github_1.isRunningInGithubAction)()) {
|
|
67
|
+
throw new error_1.FirebaseError("It looks like you are deploying a Hosting site along with Cloud Functions " +
|
|
68
|
+
"using a GitHub action version that did not include Cloud Functions " +
|
|
69
|
+
"permissions. Please reinstall the GitHub action with" +
|
|
70
|
+
clc.bold("firebase init hosting:github"), { original: e });
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
throw e;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
await (0, prepare_1.addPinnedFunctionsToOnlyString)(context, options);
|
|
78
|
+
}
|
|
79
|
+
for (const targetName of targetNames) {
|
|
80
|
+
const target = TARGETS[targetName];
|
|
81
|
+
if (!target) {
|
|
82
|
+
return Promise.reject(new error_1.FirebaseError(`${(0, colorette_1.bold)(targetName)} is not a valid deploy target`));
|
|
83
|
+
}
|
|
84
|
+
predeploys.push((0, lifecycleHooks_1.lifecycleHooks)(targetName, "predeploy"));
|
|
85
|
+
prepares.push(target.prepare);
|
|
86
|
+
deploys.push(target.deploy);
|
|
87
|
+
releases.push(target.release);
|
|
88
|
+
postdeploys.push((0, lifecycleHooks_1.lifecycleHooks)(targetName, "postdeploy"));
|
|
89
|
+
}
|
|
90
|
+
logger_1.logger.info();
|
|
91
|
+
logger_1.logger.info((0, colorette_1.bold)((0, colorette_1.white)("===") + " Deploying to '" + projectId + "'..."));
|
|
92
|
+
logger_1.logger.info();
|
|
93
|
+
(0, utils_1.logBullet)("deploying " + (0, colorette_1.bold)(targetNames.join(", ")));
|
|
94
|
+
await chain(predeploys, context, options, payload);
|
|
95
|
+
await chain(prepares, context, options, payload);
|
|
96
|
+
await chain(deploys, context, options, payload);
|
|
97
|
+
await chain(releases, context, options, payload);
|
|
98
|
+
await chain(postdeploys, context, options, payload);
|
|
99
|
+
const duration = Date.now() - startTime;
|
|
100
|
+
const analyticsParams = {
|
|
101
|
+
interactive: options.nonInteractive ? "false" : "true",
|
|
102
|
+
};
|
|
103
|
+
Object.keys(TARGETS).reduce((accum, t) => {
|
|
104
|
+
accum[t] = "false";
|
|
105
|
+
return accum;
|
|
106
|
+
}, analyticsParams);
|
|
107
|
+
for (const t of targetNames) {
|
|
108
|
+
analyticsParams[t] = "true";
|
|
109
|
+
}
|
|
110
|
+
await (0, track_1.trackGA4)("product_deploy", analyticsParams, duration);
|
|
111
|
+
logger_1.logger.info();
|
|
112
|
+
(0, utils_1.logSuccess)((0, colorette_1.bold)((0, colorette_1.underline)("Deploy complete!")));
|
|
113
|
+
logger_1.logger.info();
|
|
114
|
+
const deployedHosting = (0, lodash_1.includes)(targetNames, "hosting");
|
|
115
|
+
logger_1.logger.info((0, colorette_1.bold)("Project Console:"), (0, utils_1.consoleUrl)(options.project, "/overview"));
|
|
116
|
+
if (deployedHosting) {
|
|
117
|
+
(0, lodash_1.each)(context.hosting.deploys, (deploy) => {
|
|
118
|
+
logger_1.logger.info((0, colorette_1.bold)("Hosting URL:"), (0, utils_1.addSubdomain)(api_1.hostingOrigin, deploy.config.site));
|
|
119
|
+
});
|
|
120
|
+
const versionNames = context.hosting.deploys.map((deploy) => deploy.version);
|
|
121
|
+
return { hosting: versionNames.length === 1 ? versionNames[0] : versionNames };
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
return { hosting: undefined };
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
exports.deploy = deploy;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lifecycleHooks = void 0;
|
|
4
|
+
const utils = require("../utils");
|
|
5
|
+
const clc = require("colorette");
|
|
6
|
+
const childProcess = require("child_process");
|
|
7
|
+
const error_1 = require("../error");
|
|
8
|
+
const needProjectId = require("../projectUtils").needProjectId;
|
|
9
|
+
const logger_1 = require("../logger");
|
|
10
|
+
const path = require("path");
|
|
11
|
+
function runCommand(command, childOptions) {
|
|
12
|
+
const escapedCommand = command.replace(/\"/g, '\\"');
|
|
13
|
+
const isVSCode = utils.isVSCodeExtension();
|
|
14
|
+
const nodeExecutable = isVSCode ? "node" : process.execPath;
|
|
15
|
+
const crossEnvShellPath = isVSCode
|
|
16
|
+
? path.resolve(__dirname, "./cross-env/dist/bin/cross-env-shell.js")
|
|
17
|
+
: path.resolve(require.resolve("cross-env"), "..", "bin", "cross-env-shell.js");
|
|
18
|
+
const translatedCommand = '"' + nodeExecutable + '" "' + crossEnvShellPath + '" "' + escapedCommand + '"';
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
logger_1.logger.info("Running command: " + command);
|
|
21
|
+
if (translatedCommand === "") {
|
|
22
|
+
return resolve();
|
|
23
|
+
}
|
|
24
|
+
const child = childProcess.spawn(translatedCommand, [], childOptions);
|
|
25
|
+
child.on("error", (err) => {
|
|
26
|
+
reject(err);
|
|
27
|
+
});
|
|
28
|
+
child.on("exit", (code, signal) => {
|
|
29
|
+
if (signal) {
|
|
30
|
+
reject(new Error("Command terminated with signal " + signal));
|
|
31
|
+
}
|
|
32
|
+
else if (code !== 0) {
|
|
33
|
+
reject(new Error("Command terminated with non-zero exit code " + code));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
resolve();
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function getChildEnvironment(target, overallOptions, config) {
|
|
42
|
+
var _a;
|
|
43
|
+
const projectId = needProjectId(overallOptions);
|
|
44
|
+
const projectDir = overallOptions.projectRoot;
|
|
45
|
+
let resourceDir;
|
|
46
|
+
switch (target) {
|
|
47
|
+
case "hosting":
|
|
48
|
+
resourceDir = overallOptions.config.path((_a = config.public) !== null && _a !== void 0 ? _a : config.source);
|
|
49
|
+
break;
|
|
50
|
+
case "functions":
|
|
51
|
+
resourceDir = overallOptions.config.path(config.source);
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
resourceDir = overallOptions.config.path(overallOptions.config.projectDir);
|
|
55
|
+
}
|
|
56
|
+
return Object.assign({}, process.env, {
|
|
57
|
+
GCLOUD_PROJECT: projectId,
|
|
58
|
+
PROJECT_DIR: projectDir,
|
|
59
|
+
RESOURCE_DIR: resourceDir,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function runTargetCommands(target, hook, overallOptions, config) {
|
|
63
|
+
let commands = config[hook];
|
|
64
|
+
if (!commands) {
|
|
65
|
+
return Promise.resolve();
|
|
66
|
+
}
|
|
67
|
+
if (typeof commands === "string") {
|
|
68
|
+
commands = [commands];
|
|
69
|
+
}
|
|
70
|
+
const childOptions = {
|
|
71
|
+
cwd: overallOptions.config.projectDir,
|
|
72
|
+
env: getChildEnvironment(target, overallOptions, config),
|
|
73
|
+
shell: true,
|
|
74
|
+
stdio: [0, 1, 2],
|
|
75
|
+
};
|
|
76
|
+
const runAllCommands = commands.reduce((soFar, command) => {
|
|
77
|
+
return soFar.then(() => runCommand(command, childOptions));
|
|
78
|
+
}, Promise.resolve());
|
|
79
|
+
let logIdentifier = target;
|
|
80
|
+
if (config.target) {
|
|
81
|
+
logIdentifier += `[${config.target}]`;
|
|
82
|
+
}
|
|
83
|
+
return runAllCommands
|
|
84
|
+
.then(() => {
|
|
85
|
+
utils.logSuccess(clc.green(clc.bold(logIdentifier + ":")) +
|
|
86
|
+
" Finished running " +
|
|
87
|
+
clc.bold(hook) +
|
|
88
|
+
" script.");
|
|
89
|
+
})
|
|
90
|
+
.catch((err) => {
|
|
91
|
+
throw new error_1.FirebaseError(logIdentifier + " " + hook + " error: " + err.message);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function getReleventConfigs(target, options) {
|
|
95
|
+
let targetConfigs = options.config.get(target);
|
|
96
|
+
if (!targetConfigs) {
|
|
97
|
+
return [];
|
|
98
|
+
}
|
|
99
|
+
if (!Array.isArray(targetConfigs)) {
|
|
100
|
+
targetConfigs = [targetConfigs];
|
|
101
|
+
}
|
|
102
|
+
if (!options.only) {
|
|
103
|
+
return targetConfigs;
|
|
104
|
+
}
|
|
105
|
+
let onlyTargets = options.only.split(",");
|
|
106
|
+
if (onlyTargets.includes(target)) {
|
|
107
|
+
return targetConfigs;
|
|
108
|
+
}
|
|
109
|
+
onlyTargets = onlyTargets
|
|
110
|
+
.filter((individualOnly) => {
|
|
111
|
+
return individualOnly.startsWith(`${target}:`);
|
|
112
|
+
})
|
|
113
|
+
.map((individualOnly) => {
|
|
114
|
+
return individualOnly.replace(`${target}:`, "");
|
|
115
|
+
});
|
|
116
|
+
if (target === "functions") {
|
|
117
|
+
let onlyConfigs = [];
|
|
118
|
+
const matched = onlyTargets.reduce((matched, target) => (Object.assign(Object.assign({}, matched), { [target]: false })), {});
|
|
119
|
+
for (const config of targetConfigs) {
|
|
120
|
+
if (!config.codebase) {
|
|
121
|
+
onlyConfigs.push(config);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
const found = onlyTargets.find((individualOnly) => config.codebase === individualOnly.split(":")[0]);
|
|
125
|
+
if (found) {
|
|
126
|
+
onlyConfigs.push(config);
|
|
127
|
+
matched[found] = true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (!Object.values(matched).every((matched) => matched)) {
|
|
132
|
+
onlyConfigs = targetConfigs;
|
|
133
|
+
}
|
|
134
|
+
return onlyConfigs;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
return targetConfigs.filter((config) => {
|
|
138
|
+
return !config.target || onlyTargets.includes(config.target);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function lifecycleHooks(target, hook) {
|
|
143
|
+
return function (context, options) {
|
|
144
|
+
return getReleventConfigs(target, options).reduce((previousCommands, individualConfig) => {
|
|
145
|
+
return previousCommands.then(() => {
|
|
146
|
+
return runTargetCommands(target, hook, options, individualConfig);
|
|
147
|
+
});
|
|
148
|
+
}, Promise.resolve());
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
exports.lifecycleHooks = lifecycleHooks;
|