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,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initMiddleware = void 0;
|
|
4
|
+
const apiv2_1 = require("../apiv2");
|
|
5
|
+
const logger_1 = require("../logger");
|
|
6
|
+
const utils = require("../utils");
|
|
7
|
+
const SDK_PATH_REGEXP = /^\/__\/firebase\/([^/]+)\/([^/]+)$/;
|
|
8
|
+
function initMiddleware(init) {
|
|
9
|
+
return (req, res, next) => {
|
|
10
|
+
const parsedUrl = new URL(req.url || "", `http://${req.headers.host}`);
|
|
11
|
+
const match = RegExp(SDK_PATH_REGEXP).exec(parsedUrl.pathname);
|
|
12
|
+
if (match) {
|
|
13
|
+
const version = match[1];
|
|
14
|
+
const sdkName = match[2];
|
|
15
|
+
const u = new URL(`https://www.gstatic.com/firebasejs/${version}/${sdkName}`);
|
|
16
|
+
const c = new apiv2_1.Client({ urlPrefix: u.origin, auth: false });
|
|
17
|
+
const headers = {};
|
|
18
|
+
const acceptEncoding = req.headers["accept-encoding"];
|
|
19
|
+
if (typeof acceptEncoding === "string" && acceptEncoding) {
|
|
20
|
+
headers["accept-encoding"] = acceptEncoding;
|
|
21
|
+
}
|
|
22
|
+
c.request({
|
|
23
|
+
method: "GET",
|
|
24
|
+
path: u.pathname,
|
|
25
|
+
headers,
|
|
26
|
+
responseType: "stream",
|
|
27
|
+
resolveOnHTTPError: true,
|
|
28
|
+
compress: false,
|
|
29
|
+
})
|
|
30
|
+
.then((sdkRes) => {
|
|
31
|
+
if (sdkRes.status === 404) {
|
|
32
|
+
return next();
|
|
33
|
+
}
|
|
34
|
+
for (const [key, value] of Object.entries(sdkRes.response.headers.raw())) {
|
|
35
|
+
res.setHeader(key, value);
|
|
36
|
+
}
|
|
37
|
+
sdkRes.body.pipe(res);
|
|
38
|
+
})
|
|
39
|
+
.catch((e) => {
|
|
40
|
+
utils.logLabeledWarning("hosting", `Could not load Firebase SDK ${sdkName} v${version}, check your internet connection.`);
|
|
41
|
+
logger_1.logger.debug(e);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else if (parsedUrl.pathname === "/__/firebase/init.js") {
|
|
45
|
+
const query = parsedUrl.searchParams;
|
|
46
|
+
res.setHeader("Content-Type", "application/javascript");
|
|
47
|
+
if (query.get("useEmulator") === "true") {
|
|
48
|
+
res.end(init.emulatorsJs);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
res.end(init.js);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else if (parsedUrl.pathname === "/__/firebase/init.json") {
|
|
55
|
+
res.setHeader("Content-Type", "application/json");
|
|
56
|
+
res.end(init.json);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
next();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
exports.initMiddleware = initMiddleware;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.interactiveCreateHostingSite = void 0;
|
|
4
|
+
const error_1 = require("../error");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const projectUtils_1 = require("../projectUtils");
|
|
7
|
+
const prompt_1 = require("../prompt");
|
|
8
|
+
const api_1 = require("./api");
|
|
9
|
+
const nameSuggestion = new RegExp("try something like `(.+)`");
|
|
10
|
+
const prompt = "Please provide an unique, URL-friendly id for your site. Your site's URL will be <site-id>.web.app. " +
|
|
11
|
+
'We recommend using letters, numbers, and hyphens (e.g. "{project-id}-{random-hash}"):';
|
|
12
|
+
async function interactiveCreateHostingSite(siteId, appId, options) {
|
|
13
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
14
|
+
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
15
|
+
let id = siteId;
|
|
16
|
+
let newSite;
|
|
17
|
+
let suggestion;
|
|
18
|
+
if (!id) {
|
|
19
|
+
const attempt = await trySiteID(projectNumber, projectId);
|
|
20
|
+
if (attempt.available) {
|
|
21
|
+
suggestion = projectId;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
suggestion = attempt.suggestion;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
while (!newSite) {
|
|
28
|
+
if (!id || suggestion) {
|
|
29
|
+
id = await (0, prompt_1.promptOnce)({
|
|
30
|
+
type: "input",
|
|
31
|
+
message: prompt,
|
|
32
|
+
validate: (s) => s.length > 0,
|
|
33
|
+
default: suggestion,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
newSite = await (0, api_1.createSite)(projectNumber, id, appId);
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
if (!(err instanceof error_1.FirebaseError)) {
|
|
41
|
+
throw err;
|
|
42
|
+
}
|
|
43
|
+
if (options.nonInteractive) {
|
|
44
|
+
throw err;
|
|
45
|
+
}
|
|
46
|
+
suggestion = getSuggestionFromError(err);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return newSite;
|
|
50
|
+
}
|
|
51
|
+
exports.interactiveCreateHostingSite = interactiveCreateHostingSite;
|
|
52
|
+
async function trySiteID(projectNumber, id) {
|
|
53
|
+
try {
|
|
54
|
+
await (0, api_1.createSite)(projectNumber, id, "", true);
|
|
55
|
+
return { available: true };
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
if (!(err instanceof error_1.FirebaseError)) {
|
|
59
|
+
throw err;
|
|
60
|
+
}
|
|
61
|
+
const suggestion = getSuggestionFromError(err);
|
|
62
|
+
return { available: false, suggestion };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function getSuggestionFromError(err) {
|
|
66
|
+
if (err.status === 400 && err.message.includes("Invalid name:")) {
|
|
67
|
+
const i = err.message.indexOf("Invalid name:");
|
|
68
|
+
(0, utils_1.logWarning)(err.message.substring(i));
|
|
69
|
+
const match = nameSuggestion.exec(err.message);
|
|
70
|
+
if (match) {
|
|
71
|
+
return match[1];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.errorRequestHandler = exports.proxyRequestHandler = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const node_fetch_1 = require("node-fetch");
|
|
6
|
+
const stream_1 = require("stream");
|
|
7
|
+
const url_1 = require("url");
|
|
8
|
+
const apiv2_1 = require("../apiv2");
|
|
9
|
+
const error_1 = require("../error");
|
|
10
|
+
const logger_1 = require("../logger");
|
|
11
|
+
const REQUIRED_VARY_VALUES = ["Accept-Encoding", "Authorization", "Cookie"];
|
|
12
|
+
function makeVary(vary = "") {
|
|
13
|
+
if (!vary) {
|
|
14
|
+
return "Accept-Encoding, Authorization, Cookie";
|
|
15
|
+
}
|
|
16
|
+
const varies = vary.split(/, ?/).map((v) => {
|
|
17
|
+
return v
|
|
18
|
+
.split("-")
|
|
19
|
+
.map((part) => (0, lodash_1.capitalize)(part))
|
|
20
|
+
.join("-");
|
|
21
|
+
});
|
|
22
|
+
REQUIRED_VARY_VALUES.forEach((requiredVary) => {
|
|
23
|
+
if (!(0, lodash_1.includes)(varies, requiredVary)) {
|
|
24
|
+
varies.push(requiredVary);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return varies.join(", ");
|
|
28
|
+
}
|
|
29
|
+
function proxyRequestHandler(url, rewriteIdentifier, options = {}) {
|
|
30
|
+
return async (req, res, next) => {
|
|
31
|
+
var _a;
|
|
32
|
+
logger_1.logger.info(`[hosting] Rewriting ${req.url} to ${url} for ${rewriteIdentifier}`);
|
|
33
|
+
const cookie = req.headers.cookie || "";
|
|
34
|
+
const sessionCookie = cookie.split(/; ?/).find((c) => {
|
|
35
|
+
return c.trim().startsWith("__session=");
|
|
36
|
+
});
|
|
37
|
+
const u = new url_1.URL(url + req.url);
|
|
38
|
+
const c = new apiv2_1.Client({ urlPrefix: u.origin, auth: false });
|
|
39
|
+
let passThrough;
|
|
40
|
+
if (req.method && !["GET", "HEAD"].includes(req.method)) {
|
|
41
|
+
passThrough = new stream_1.PassThrough();
|
|
42
|
+
req.pipe(passThrough);
|
|
43
|
+
}
|
|
44
|
+
const headers = new node_fetch_1.Headers({
|
|
45
|
+
"X-Forwarded-Host": req.headers.host || "",
|
|
46
|
+
"X-Original-Url": req.url || "",
|
|
47
|
+
Pragma: "no-cache",
|
|
48
|
+
"Cache-Control": "no-cache, no-store",
|
|
49
|
+
Cookie: sessionCookie || "",
|
|
50
|
+
});
|
|
51
|
+
const headersToSkip = new Set(["host"]);
|
|
52
|
+
for (const key of Object.keys(req.headers)) {
|
|
53
|
+
if (headersToSkip.has(key)) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const value = req.headers[key];
|
|
57
|
+
if (value === undefined) {
|
|
58
|
+
headers.delete(key);
|
|
59
|
+
}
|
|
60
|
+
else if (Array.isArray(value)) {
|
|
61
|
+
headers.delete(key);
|
|
62
|
+
for (const v of value) {
|
|
63
|
+
headers.append(key, v);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
headers.set(key, value);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
let proxyRes;
|
|
71
|
+
try {
|
|
72
|
+
proxyRes = await c.request({
|
|
73
|
+
method: (req.method || "GET"),
|
|
74
|
+
path: u.pathname,
|
|
75
|
+
queryParams: u.searchParams,
|
|
76
|
+
headers,
|
|
77
|
+
resolveOnHTTPError: true,
|
|
78
|
+
responseType: "stream",
|
|
79
|
+
redirect: "manual",
|
|
80
|
+
body: passThrough,
|
|
81
|
+
timeout: 60000,
|
|
82
|
+
compress: false,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
const isAbortError = err instanceof error_1.FirebaseError && ((_a = err.original) === null || _a === void 0 ? void 0 : _a.name.includes("AbortError"));
|
|
87
|
+
const isTimeoutError = err instanceof error_1.FirebaseError &&
|
|
88
|
+
err.original instanceof node_fetch_1.FetchError &&
|
|
89
|
+
err.original.code === "ETIMEDOUT";
|
|
90
|
+
const isSocketTimeoutError = err instanceof error_1.FirebaseError &&
|
|
91
|
+
err.original instanceof node_fetch_1.FetchError &&
|
|
92
|
+
err.original.code === "ESOCKETTIMEDOUT";
|
|
93
|
+
if (isAbortError || isTimeoutError || isSocketTimeoutError) {
|
|
94
|
+
res.statusCode = 504;
|
|
95
|
+
return res.end("Timed out waiting for function to respond.\n");
|
|
96
|
+
}
|
|
97
|
+
res.statusCode = 500;
|
|
98
|
+
return res.end(`An internal error occurred while proxying for ${rewriteIdentifier}\n`);
|
|
99
|
+
}
|
|
100
|
+
if (proxyRes.status === 404) {
|
|
101
|
+
const cascade = proxyRes.response.headers.get("x-cascade");
|
|
102
|
+
if (options.forceCascade || (cascade && cascade.toUpperCase() === "PASS")) {
|
|
103
|
+
return next();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (!proxyRes.response.headers.get("cache-control")) {
|
|
107
|
+
proxyRes.response.headers.set("cache-control", "private");
|
|
108
|
+
}
|
|
109
|
+
const cc = proxyRes.response.headers.get("cache-control");
|
|
110
|
+
if (cc && !cc.includes("private")) {
|
|
111
|
+
proxyRes.response.headers.delete("set-cookie");
|
|
112
|
+
}
|
|
113
|
+
proxyRes.response.headers.set("vary", makeVary(proxyRes.response.headers.get("vary")));
|
|
114
|
+
const location = proxyRes.response.headers.get("location");
|
|
115
|
+
if (location) {
|
|
116
|
+
try {
|
|
117
|
+
const locationURL = new url_1.URL(location);
|
|
118
|
+
if (locationURL.origin === u.origin) {
|
|
119
|
+
const unborkedLocation = location.replace(locationURL.origin, "");
|
|
120
|
+
proxyRes.response.headers.set("location", unborkedLocation);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch (e) {
|
|
124
|
+
logger_1.logger.debug(`[hosting] had trouble parsing location header, but this may be okay: "${location}"`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
for (const [key, value] of Object.entries(proxyRes.response.headers.raw())) {
|
|
128
|
+
res.setHeader(key, value);
|
|
129
|
+
}
|
|
130
|
+
res.statusCode = proxyRes.status;
|
|
131
|
+
proxyRes.response.body.pipe(res);
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
exports.proxyRequestHandler = proxyRequestHandler;
|
|
135
|
+
function errorRequestHandler(error) {
|
|
136
|
+
return (req, res) => {
|
|
137
|
+
res.statusCode = 500;
|
|
138
|
+
const out = `A problem occurred while trying to handle a proxied rewrite: ${error}`;
|
|
139
|
+
logger_1.logger.error(out);
|
|
140
|
+
res.end(out);
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
exports.errorRequestHandler = errorRequestHandler;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureLatestRevisionTagged = exports.setRewriteTags = exports.setGarbageCollectionThreshold = exports.gcTagsForServices = exports.TODO_TAG_NAME = void 0;
|
|
4
|
+
const run = require("../gcp/run");
|
|
5
|
+
const api = require("./api");
|
|
6
|
+
const error_1 = require("../error");
|
|
7
|
+
const functional_1 = require("../functional");
|
|
8
|
+
exports.TODO_TAG_NAME = "this is an invalid tag name so it cannot be real";
|
|
9
|
+
async function gcTagsForServices(project, services) {
|
|
10
|
+
var _a;
|
|
11
|
+
const validTagsByServiceByRegion = {};
|
|
12
|
+
const sites = await api.listSites(project);
|
|
13
|
+
const allVersionsNested = await Promise.all(sites.map((site) => api.listVersions(site.name)));
|
|
14
|
+
const activeVersions = [...(0, functional_1.flattenArray)(allVersionsNested)].filter((version) => {
|
|
15
|
+
return version.status === "CREATED" || version.status === "FINALIZED";
|
|
16
|
+
});
|
|
17
|
+
for (const version of activeVersions) {
|
|
18
|
+
for (const rewrite of ((_a = version === null || version === void 0 ? void 0 : version.config) === null || _a === void 0 ? void 0 : _a.rewrites) || []) {
|
|
19
|
+
if (!("run" in rewrite) || !rewrite.run.tag) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
validTagsByServiceByRegion[rewrite.run.region] =
|
|
23
|
+
validTagsByServiceByRegion[rewrite.run.region] || {};
|
|
24
|
+
validTagsByServiceByRegion[rewrite.run.region][rewrite.run.serviceId] =
|
|
25
|
+
validTagsByServiceByRegion[rewrite.run.region][rewrite.run.serviceId] || new Set();
|
|
26
|
+
validTagsByServiceByRegion[rewrite.run.region][rewrite.run.serviceId].add(rewrite.run.tag);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
for (const service of services) {
|
|
30
|
+
const { region, serviceId } = run.gcpIds(service);
|
|
31
|
+
service.spec.traffic = (service.spec.traffic || []).filter((traffic) => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
if (traffic.percent) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
if (!traffic.tag) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
if (!traffic.tag.startsWith("fh-")) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
if ((_b = (_a = validTagsByServiceByRegion[region]) === null || _a === void 0 ? void 0 : _a[serviceId]) === null || _b === void 0 ? void 0 : _b.has(traffic.tag)) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.gcTagsForServices = gcTagsForServices;
|
|
50
|
+
let garbageCollectionThreshold = 500;
|
|
51
|
+
function setGarbageCollectionThreshold(threshold) {
|
|
52
|
+
garbageCollectionThreshold = threshold;
|
|
53
|
+
}
|
|
54
|
+
exports.setGarbageCollectionThreshold = setGarbageCollectionThreshold;
|
|
55
|
+
async function setRewriteTags(rewrites, project, version) {
|
|
56
|
+
const services = await Promise.all(rewrites
|
|
57
|
+
.map((rewrite) => {
|
|
58
|
+
if (!("run" in rewrite)) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
if (rewrite.run.tag !== exports.TODO_TAG_NAME) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
return run.getService(`projects/${project}/locations/${rewrite.run.region}/services/${rewrite.run.serviceId}`);
|
|
65
|
+
})
|
|
66
|
+
.filter((s) => s !== null));
|
|
67
|
+
if (!services.length) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const needsGC = services
|
|
71
|
+
.map((service) => {
|
|
72
|
+
return service.spec.traffic.filter((traffic) => traffic.tag).length;
|
|
73
|
+
})
|
|
74
|
+
.some((length) => length >= garbageCollectionThreshold);
|
|
75
|
+
if (needsGC) {
|
|
76
|
+
await exports.gcTagsForServices(project, services);
|
|
77
|
+
}
|
|
78
|
+
const tags = await exports.ensureLatestRevisionTagged(services, `fh-${version}`);
|
|
79
|
+
for (const rewrite of rewrites) {
|
|
80
|
+
if (!("run" in rewrite) || rewrite.run.tag !== exports.TODO_TAG_NAME) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const tag = tags[rewrite.run.region][rewrite.run.serviceId];
|
|
84
|
+
rewrite.run.tag = tag;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.setRewriteTags = setRewriteTags;
|
|
88
|
+
async function ensureLatestRevisionTagged(services, defaultTag) {
|
|
89
|
+
var _a;
|
|
90
|
+
const tags = {};
|
|
91
|
+
const updateServices = [];
|
|
92
|
+
for (const service of services) {
|
|
93
|
+
const { projectNumber, region, serviceId } = run.gcpIds(service);
|
|
94
|
+
tags[region] = tags[region] || {};
|
|
95
|
+
const latestRevision = (_a = service.status) === null || _a === void 0 ? void 0 : _a.latestReadyRevisionName;
|
|
96
|
+
if (!latestRevision) {
|
|
97
|
+
throw new error_1.FirebaseError(`Assertion failed: service ${service.metadata.name} has no ready revision`);
|
|
98
|
+
}
|
|
99
|
+
const alreadyTagged = service.spec.traffic.find((target) => target.revisionName === latestRevision && target.tag);
|
|
100
|
+
if (alreadyTagged) {
|
|
101
|
+
tags[region][serviceId] = alreadyTagged.tag;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
tags[region][serviceId] = defaultTag;
|
|
105
|
+
service.spec.traffic.push({
|
|
106
|
+
revisionName: latestRevision,
|
|
107
|
+
tag: defaultTag,
|
|
108
|
+
});
|
|
109
|
+
updateServices.push(run.updateService(`projects/${projectNumber}/locations/${region}/services/${serviceId}`, service));
|
|
110
|
+
}
|
|
111
|
+
await Promise.all(updateServices);
|
|
112
|
+
return tags;
|
|
113
|
+
}
|
|
114
|
+
exports.ensureLatestRevisionTagged = ensureLatestRevisionTagged;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const program = require("commander");
|
|
3
|
+
const clc = require("colorette");
|
|
4
|
+
const leven = require("leven");
|
|
5
|
+
const logger_1 = require("./logger");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
const pkg = require("../package.json");
|
|
8
|
+
program.version(pkg.version);
|
|
9
|
+
program.option("-P, --project <alias_or_project_id>", "the Firebase project to use for this command");
|
|
10
|
+
program.option("--account <email>", "the Google account to use for authorization");
|
|
11
|
+
program.option("-j, --json", "output JSON instead of text, also triggers non-interactive mode");
|
|
12
|
+
program.option("--token <token>", "DEPRECATED - will be removed in a future major version - supply an auth token for this command");
|
|
13
|
+
program.option("--non-interactive", "error out of the command instead of waiting for prompts");
|
|
14
|
+
program.option("-i, --interactive", "force prompts to be displayed");
|
|
15
|
+
program.option("--debug", "print verbose debug output and keep a debug log file");
|
|
16
|
+
program.option("-c, --config <path>", "path to the firebase.json file to use for configuration");
|
|
17
|
+
const client = {
|
|
18
|
+
cli: program,
|
|
19
|
+
logger: require("./logger"),
|
|
20
|
+
errorOut: require("./errorOut").errorOut,
|
|
21
|
+
getCommand: (name) => {
|
|
22
|
+
for (let i = 0; i < client.cli.commands.length; i++) {
|
|
23
|
+
if (client.cli.commands[i]._name === name) {
|
|
24
|
+
return client.cli.commands[i];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return;
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
require("./commands").load(client);
|
|
31
|
+
function suggestCommands(cmd, cmdList) {
|
|
32
|
+
const suggestion = cmdList.find((c) => {
|
|
33
|
+
return leven(c, cmd) < c.length * 0.4;
|
|
34
|
+
});
|
|
35
|
+
if (suggestion) {
|
|
36
|
+
logger_1.logger.error();
|
|
37
|
+
logger_1.logger.error("Did you mean " + clc.bold(suggestion) + "?");
|
|
38
|
+
return suggestion;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const commandNames = program.commands.map((cmd) => {
|
|
42
|
+
return cmd._name;
|
|
43
|
+
});
|
|
44
|
+
const RENAMED_COMMANDS = {
|
|
45
|
+
"delete-site": "hosting:disable",
|
|
46
|
+
"disable:hosting": "hosting:disable",
|
|
47
|
+
"data:get": "database:get",
|
|
48
|
+
"data:push": "database:push",
|
|
49
|
+
"data:remove": "database:remove",
|
|
50
|
+
"data:set": "database:set",
|
|
51
|
+
"data:update": "database:update",
|
|
52
|
+
"deploy:hosting": "deploy --only hosting",
|
|
53
|
+
"deploy:database": "deploy --only database",
|
|
54
|
+
"prefs:token": "login:ci",
|
|
55
|
+
};
|
|
56
|
+
program.action((_, args) => {
|
|
57
|
+
(0, utils_1.setupLoggers)();
|
|
58
|
+
const cmd = args[0];
|
|
59
|
+
logger_1.logger.error(clc.bold(clc.red("Error:")), clc.bold(cmd), "is not a Firebase command");
|
|
60
|
+
if (RENAMED_COMMANDS[cmd]) {
|
|
61
|
+
logger_1.logger.error();
|
|
62
|
+
logger_1.logger.error(clc.bold(cmd) + " has been renamed, please run", clc.bold("firebase " + RENAMED_COMMANDS[cmd]), "instead");
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
if (!suggestCommands(cmd, commandNames)) {
|
|
66
|
+
suggestCommands(args.join(":"), commandNames);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
process.exit(1);
|
|
70
|
+
});
|
|
71
|
+
module.exports = client;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.doSetup = void 0;
|
|
4
|
+
const logger_1 = require("../../logger");
|
|
5
|
+
const utils = require("../../utils");
|
|
6
|
+
const auth_1 = require("../../auth");
|
|
7
|
+
const prompt_1 = require("../../prompt");
|
|
8
|
+
const error_1 = require("../../error");
|
|
9
|
+
async function promptForAccount() {
|
|
10
|
+
logger_1.logger.info();
|
|
11
|
+
logger_1.logger.info(`Which account do you want to use for this project? Choose an account or add a new one now`);
|
|
12
|
+
logger_1.logger.info();
|
|
13
|
+
const allAccounts = (0, auth_1.getAllAccounts)();
|
|
14
|
+
const choices = allAccounts.map((a) => {
|
|
15
|
+
return {
|
|
16
|
+
name: a.user.email,
|
|
17
|
+
value: a.user.email,
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
choices.push({
|
|
21
|
+
name: "(add a new account)",
|
|
22
|
+
value: "__add__",
|
|
23
|
+
});
|
|
24
|
+
const emailChoice = await (0, prompt_1.promptOnce)({
|
|
25
|
+
type: "list",
|
|
26
|
+
name: "email",
|
|
27
|
+
message: "Please select an option:",
|
|
28
|
+
choices,
|
|
29
|
+
});
|
|
30
|
+
if (emailChoice === "__add__") {
|
|
31
|
+
const newAccount = await (0, auth_1.loginAdditionalAccount)(true);
|
|
32
|
+
if (!newAccount) {
|
|
33
|
+
throw new error_1.FirebaseError("Failed to add new account", { exit: 1 });
|
|
34
|
+
}
|
|
35
|
+
return newAccount;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return (0, auth_1.findAccountByEmail)(emailChoice);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function doSetup(setup, config, options) {
|
|
42
|
+
let account;
|
|
43
|
+
if (options.account) {
|
|
44
|
+
account = (0, auth_1.findAccountByEmail)(options.account);
|
|
45
|
+
if (!account) {
|
|
46
|
+
throw new error_1.FirebaseError(`Invalid account ${options.account}`, { exit: 1 });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
account = await promptForAccount();
|
|
51
|
+
}
|
|
52
|
+
if (!account) {
|
|
53
|
+
throw new error_1.FirebaseError(`No account selected, have you run "firebase login"?`, { exit: 1 });
|
|
54
|
+
}
|
|
55
|
+
(0, auth_1.setActiveAccount)(options, account);
|
|
56
|
+
if (config.projectDir) {
|
|
57
|
+
(0, auth_1.setProjectAccount)(config.projectDir, account.user.email);
|
|
58
|
+
}
|
|
59
|
+
logger_1.logger.info();
|
|
60
|
+
utils.logSuccess(`Using account: ${account.user.email}`);
|
|
61
|
+
}
|
|
62
|
+
exports.doSetup = doSetup;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.doSetup = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const prompt_1 = require("../../prompt");
|
|
6
|
+
const logger_1 = require("../../logger");
|
|
7
|
+
const utils = require("../../utils");
|
|
8
|
+
const fsutils = require("../../fsutils");
|
|
9
|
+
const database_1 = require("../../management/database");
|
|
10
|
+
const ora = require("ora");
|
|
11
|
+
const ensureApiEnabled_1 = require("../../ensureApiEnabled");
|
|
12
|
+
const getDefaultDatabaseInstance_1 = require("../../getDefaultDatabaseInstance");
|
|
13
|
+
const error_1 = require("../../error");
|
|
14
|
+
const apiv2_1 = require("../../apiv2");
|
|
15
|
+
const DEFAULT_RULES = JSON.stringify({ rules: { ".read": "auth != null", ".write": "auth != null" } }, null, 2);
|
|
16
|
+
async function getDBRules(instanceDetails) {
|
|
17
|
+
if (!instanceDetails || !instanceDetails.name) {
|
|
18
|
+
return DEFAULT_RULES;
|
|
19
|
+
}
|
|
20
|
+
const client = new apiv2_1.Client({ urlPrefix: instanceDetails.databaseUrl });
|
|
21
|
+
const response = await client.request({
|
|
22
|
+
method: "GET",
|
|
23
|
+
path: "/.settings/rules.json",
|
|
24
|
+
responseType: "stream",
|
|
25
|
+
resolveOnHTTPError: true,
|
|
26
|
+
});
|
|
27
|
+
if (response.status !== 200) {
|
|
28
|
+
throw new error_1.FirebaseError(`Failed to fetch current rules. Code: ${response.status}`);
|
|
29
|
+
}
|
|
30
|
+
return await response.response.text();
|
|
31
|
+
}
|
|
32
|
+
function writeDBRules(rules, logMessagePrefix, filename, config) {
|
|
33
|
+
config.writeProjectFile(filename, rules);
|
|
34
|
+
utils.logSuccess(`${logMessagePrefix} have been written to ${clc.bold(filename)}.`);
|
|
35
|
+
logger_1.logger.info(`Future modifications to ${clc.bold(filename)} will update Realtime Database Security Rules when you run`);
|
|
36
|
+
logger_1.logger.info(clc.bold("firebase deploy") + ".");
|
|
37
|
+
}
|
|
38
|
+
async function createDefaultDatabaseInstance(project) {
|
|
39
|
+
const selectedLocation = await (0, prompt_1.promptOnce)({
|
|
40
|
+
type: "list",
|
|
41
|
+
message: "Please choose the location for your default Realtime Database instance:",
|
|
42
|
+
choices: [
|
|
43
|
+
{ name: "us-central1", value: database_1.DatabaseLocation.US_CENTRAL1 },
|
|
44
|
+
{ name: "europe-west1", value: database_1.DatabaseLocation.EUROPE_WEST1 },
|
|
45
|
+
{ name: "asia-southeast1", value: database_1.DatabaseLocation.ASIA_SOUTHEAST1 },
|
|
46
|
+
],
|
|
47
|
+
});
|
|
48
|
+
let instanceName = `${project}-default-rtdb`;
|
|
49
|
+
const checkOutput = await (0, database_1.checkInstanceNameAvailable)(project, instanceName, database_1.DatabaseInstanceType.DEFAULT_DATABASE, selectedLocation);
|
|
50
|
+
if (!checkOutput.available) {
|
|
51
|
+
if (!checkOutput.suggestedIds || checkOutput.suggestedIds.length === 0) {
|
|
52
|
+
logger_1.logger.debug(`No instance names were suggested instead of conventional instance name: ${instanceName}`);
|
|
53
|
+
throw new error_1.FirebaseError("Failed to create default RTDB instance");
|
|
54
|
+
}
|
|
55
|
+
instanceName = checkOutput.suggestedIds[0];
|
|
56
|
+
logger_1.logger.info(`${clc.yellow("WARNING:")} your project ID has the legacy name format, so your default Realtime Database instance will be named differently: ${instanceName}`);
|
|
57
|
+
}
|
|
58
|
+
const spinner = ora(`Creating your default Realtime Database instance: ${instanceName}`).start();
|
|
59
|
+
try {
|
|
60
|
+
const createdInstance = await (0, database_1.createInstance)(project, instanceName, selectedLocation, database_1.DatabaseInstanceType.DEFAULT_DATABASE);
|
|
61
|
+
spinner.succeed();
|
|
62
|
+
return createdInstance;
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
spinner.fail();
|
|
66
|
+
throw err;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async function doSetup(setup, config) {
|
|
70
|
+
setup.config = setup.config || {};
|
|
71
|
+
let instanceDetails;
|
|
72
|
+
if (setup.projectId) {
|
|
73
|
+
await (0, ensureApiEnabled_1.ensure)(setup.projectId, "firebasedatabase.googleapis.com", "database", false);
|
|
74
|
+
logger_1.logger.info();
|
|
75
|
+
setup.instance =
|
|
76
|
+
setup.instance || (await (0, getDefaultDatabaseInstance_1.getDefaultDatabaseInstance)({ project: setup.projectId }));
|
|
77
|
+
if (setup.instance !== "") {
|
|
78
|
+
instanceDetails = await (0, database_1.getDatabaseInstanceDetails)(setup.projectId, setup.instance);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const confirm = await (0, prompt_1.promptOnce)({
|
|
82
|
+
type: "confirm",
|
|
83
|
+
name: "confirm",
|
|
84
|
+
default: true,
|
|
85
|
+
message: "It seems like you haven’t initialized Realtime Database in your project yet. Do you want to set it up?",
|
|
86
|
+
});
|
|
87
|
+
if (confirm) {
|
|
88
|
+
instanceDetails = await createDefaultDatabaseInstance(setup.projectId);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
setup.config.database = setup.config.database || {};
|
|
93
|
+
logger_1.logger.info();
|
|
94
|
+
logger_1.logger.info("Firebase Realtime Database Security Rules allow you to define how your data should be");
|
|
95
|
+
logger_1.logger.info("structured and when your data can be read from and written to.");
|
|
96
|
+
logger_1.logger.info();
|
|
97
|
+
await (0, prompt_1.prompt)(setup.config.database, [
|
|
98
|
+
{
|
|
99
|
+
type: "input",
|
|
100
|
+
name: "rules",
|
|
101
|
+
message: "What file should be used for Realtime Database Security Rules?",
|
|
102
|
+
default: "database.rules.json",
|
|
103
|
+
},
|
|
104
|
+
]);
|
|
105
|
+
const filename = setup.config.database.rules;
|
|
106
|
+
if (!filename) {
|
|
107
|
+
throw new error_1.FirebaseError("Must specify location for Realtime Database rules file.");
|
|
108
|
+
}
|
|
109
|
+
let writeRules = true;
|
|
110
|
+
if (fsutils.fileExistsSync(filename)) {
|
|
111
|
+
const rulesDescription = instanceDetails
|
|
112
|
+
? `the Realtime Database Security Rules for ${clc.bold(instanceDetails.name)} from the Firebase console`
|
|
113
|
+
: "default rules";
|
|
114
|
+
const msg = `File ${clc.bold(filename)} already exists. Do you want to overwrite it with ${rulesDescription}?`;
|
|
115
|
+
writeRules = await (0, prompt_1.promptOnce)({
|
|
116
|
+
type: "confirm",
|
|
117
|
+
message: msg,
|
|
118
|
+
default: false,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
if (writeRules) {
|
|
122
|
+
if (instanceDetails) {
|
|
123
|
+
writeDBRules(await getDBRules(instanceDetails), `Database Rules for ${instanceDetails.name}`, filename, config);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
writeDBRules(DEFAULT_RULES, "Default rules", filename, config);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
logger_1.logger.info("Skipping overwrite of Realtime Database Security Rules.");
|
|
130
|
+
logger_1.logger.info(`The security rules defined in ${clc.bold(filename)} will be published when you run ${clc.bold("firebase deploy")}.`);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
exports.doSetup = doSetup;
|