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,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.doSetup = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const _ = require("lodash");
|
|
6
|
+
const utils = require("../../utils");
|
|
7
|
+
const prompt_1 = require("../../prompt");
|
|
8
|
+
const types_1 = require("../../emulator/types");
|
|
9
|
+
const constants_1 = require("../../emulator/constants");
|
|
10
|
+
const downloadableEmulators_1 = require("../../emulator/downloadableEmulators");
|
|
11
|
+
async function doSetup(setup, config) {
|
|
12
|
+
const choices = types_1.ALL_SERVICE_EMULATORS.map((e) => {
|
|
13
|
+
return {
|
|
14
|
+
value: e,
|
|
15
|
+
name: constants_1.Constants.description(e),
|
|
16
|
+
checked: config && (config.has(e) || config.has(`emulators.${e}`)),
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
const selections = {};
|
|
20
|
+
await (0, prompt_1.prompt)(selections, [
|
|
21
|
+
{
|
|
22
|
+
type: "checkbox",
|
|
23
|
+
name: "emulators",
|
|
24
|
+
message: "Which Firebase emulators do you want to set up? " +
|
|
25
|
+
"Press Space to select emulators, then Enter to confirm your choices.",
|
|
26
|
+
choices: choices,
|
|
27
|
+
},
|
|
28
|
+
]);
|
|
29
|
+
if (!selections.emulators) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
setup.config.emulators = setup.config.emulators || {};
|
|
33
|
+
for (const selected of selections.emulators) {
|
|
34
|
+
setup.config.emulators[selected] = setup.config.emulators[selected] || {};
|
|
35
|
+
const currentPort = setup.config.emulators[selected].port;
|
|
36
|
+
if (currentPort) {
|
|
37
|
+
utils.logBullet(`Port for ${selected} already configured: ${clc.cyan(currentPort)}`);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
await (0, prompt_1.prompt)(setup.config.emulators[selected], [
|
|
41
|
+
{
|
|
42
|
+
type: "number",
|
|
43
|
+
name: "port",
|
|
44
|
+
message: `Which port do you want to use for the ${clc.underline(selected)} emulator?`,
|
|
45
|
+
default: constants_1.Constants.getDefaultPort(selected),
|
|
46
|
+
},
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (selections.emulators.length) {
|
|
51
|
+
const uiDesc = constants_1.Constants.description(types_1.Emulators.UI);
|
|
52
|
+
if (setup.config.emulators.ui && setup.config.emulators.ui.enabled !== false) {
|
|
53
|
+
const currentPort = setup.config.emulators.ui.port || "(automatic)";
|
|
54
|
+
utils.logBullet(`${uiDesc} already enabled with port: ${clc.cyan(currentPort)}`);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const ui = setup.config.emulators.ui || {};
|
|
58
|
+
setup.config.emulators.ui = ui;
|
|
59
|
+
await (0, prompt_1.prompt)(ui, [
|
|
60
|
+
{
|
|
61
|
+
name: "enabled",
|
|
62
|
+
type: "confirm",
|
|
63
|
+
message: `Would you like to enable the ${uiDesc}?`,
|
|
64
|
+
default: true,
|
|
65
|
+
},
|
|
66
|
+
]);
|
|
67
|
+
if (ui.enabled) {
|
|
68
|
+
await (0, prompt_1.prompt)(ui, [
|
|
69
|
+
{
|
|
70
|
+
type: "input",
|
|
71
|
+
name: "port",
|
|
72
|
+
message: `Which port do you want to use for the ${clc.underline(uiDesc)} (leave empty to use any available port)?`,
|
|
73
|
+
},
|
|
74
|
+
]);
|
|
75
|
+
const portNum = Number.parseInt(ui.port);
|
|
76
|
+
ui.port = isNaN(portNum) ? undefined : portNum;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
await (0, prompt_1.prompt)(selections, [
|
|
80
|
+
{
|
|
81
|
+
name: "download",
|
|
82
|
+
type: "confirm",
|
|
83
|
+
message: "Would you like to download the emulators now?",
|
|
84
|
+
default: true,
|
|
85
|
+
},
|
|
86
|
+
]);
|
|
87
|
+
}
|
|
88
|
+
if (setup.config.emulators.singleProjectMode === undefined) {
|
|
89
|
+
setup.config.emulators.singleProjectMode = true;
|
|
90
|
+
}
|
|
91
|
+
if (selections.download) {
|
|
92
|
+
for (const selected of selections.emulators) {
|
|
93
|
+
if ((0, types_1.isDownloadableEmulator)(selected)) {
|
|
94
|
+
await (0, downloadableEmulators_1.downloadIfNecessary)(selected);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (_.get(setup, "config.emulators.ui.enabled")) {
|
|
98
|
+
(0, downloadableEmulators_1.downloadIfNecessary)(types_1.Emulators.UI);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.doSetup = doSetup;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.doSetup = void 0;
|
|
4
|
+
const requirePermissions_1 = require("../../../requirePermissions");
|
|
5
|
+
const ensureApiEnabled_1 = require("../../../ensureApiEnabled");
|
|
6
|
+
const manifest = require("../../../extensions/manifest");
|
|
7
|
+
async function doSetup(setup, config, options) {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
const projectId = (_b = (_a = setup === null || setup === void 0 ? void 0 : setup.rcfile) === null || _a === void 0 ? void 0 : _a.projects) === null || _b === void 0 ? void 0 : _b.default;
|
|
10
|
+
if (projectId) {
|
|
11
|
+
await (0, requirePermissions_1.requirePermissions)(Object.assign(Object.assign({}, options), { project: projectId }));
|
|
12
|
+
await Promise.all([(0, ensureApiEnabled_1.ensure)(projectId, "firebaseextensions.googleapis.com", "unused", true)]);
|
|
13
|
+
}
|
|
14
|
+
return manifest.writeEmptyManifest(config, options);
|
|
15
|
+
}
|
|
16
|
+
exports.doSetup = doSetup;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.doSetup = void 0;
|
|
4
|
+
const logger_1 = require("../../../logger");
|
|
5
|
+
const apiEnabled = require("../../../ensureApiEnabled");
|
|
6
|
+
const requirePermissions_1 = require("../../../requirePermissions");
|
|
7
|
+
const checkDatabaseType_1 = require("../../../firestore/checkDatabaseType");
|
|
8
|
+
const rules = require("./rules");
|
|
9
|
+
const indexes = require("./indexes");
|
|
10
|
+
const error_1 = require("../../../error");
|
|
11
|
+
const clc = require("colorette");
|
|
12
|
+
async function checkProjectSetup(setup, config, options) {
|
|
13
|
+
const firestoreUnusedError = new error_1.FirebaseError(`It looks like you haven't used Cloud Firestore in this project before. Go to ${clc.bold(clc.underline(`https://console.firebase.google.com/project/${setup.projectId}/firestore`))} to create your Cloud Firestore database.`, { exit: 1 });
|
|
14
|
+
const isFirestoreEnabled = await apiEnabled.check(setup.projectId, "firestore.googleapis.com", "", true);
|
|
15
|
+
if (!isFirestoreEnabled) {
|
|
16
|
+
throw firestoreUnusedError;
|
|
17
|
+
}
|
|
18
|
+
const dbType = await (0, checkDatabaseType_1.checkDatabaseType)(setup.projectId);
|
|
19
|
+
logger_1.logger.debug(`database_type: ${dbType}`);
|
|
20
|
+
if (!dbType) {
|
|
21
|
+
throw firestoreUnusedError;
|
|
22
|
+
}
|
|
23
|
+
else if (dbType !== "FIRESTORE_NATIVE") {
|
|
24
|
+
throw new error_1.FirebaseError(`It looks like this project is using Cloud Datastore or Cloud Firestore in Datastore mode. The Firebase CLI can only manage projects using Cloud Firestore in Native mode. For more information, visit https://cloud.google.com/datastore/docs/firestore-or-datastore`, { exit: 1 });
|
|
25
|
+
}
|
|
26
|
+
await (0, requirePermissions_1.requirePermissions)(Object.assign(Object.assign({}, options), { project: setup.projectId }));
|
|
27
|
+
}
|
|
28
|
+
async function doSetup(setup, config, options) {
|
|
29
|
+
if (setup.projectId) {
|
|
30
|
+
await checkProjectSetup(setup, config, options);
|
|
31
|
+
}
|
|
32
|
+
setup.config.firestore = {};
|
|
33
|
+
await rules.initRules(setup, config);
|
|
34
|
+
await indexes.initIndexes(setup, config);
|
|
35
|
+
}
|
|
36
|
+
exports.doSetup = doSetup;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initIndexes = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const error_1 = require("../../../error");
|
|
7
|
+
const api = require("../../../firestore/api");
|
|
8
|
+
const fsutils = require("../../../fsutils");
|
|
9
|
+
const prompt_1 = require("../../../prompt");
|
|
10
|
+
const logger_1 = require("../../../logger");
|
|
11
|
+
const indexes = new api.FirestoreApi();
|
|
12
|
+
const INDEXES_TEMPLATE = fs.readFileSync(__dirname + "/../../../../templates/init/firestore/firestore.indexes.json", "utf8");
|
|
13
|
+
function initIndexes(setup, config) {
|
|
14
|
+
logger_1.logger.info();
|
|
15
|
+
logger_1.logger.info("Firestore indexes allow you to perform complex queries while");
|
|
16
|
+
logger_1.logger.info("maintaining performance that scales with the size of the result");
|
|
17
|
+
logger_1.logger.info("set. You can keep index definitions in your project directory");
|
|
18
|
+
logger_1.logger.info("and publish them with " + clc.bold("firebase deploy") + ".");
|
|
19
|
+
logger_1.logger.info();
|
|
20
|
+
return (0, prompt_1.prompt)(setup.config.firestore, [
|
|
21
|
+
{
|
|
22
|
+
type: "input",
|
|
23
|
+
name: "indexes",
|
|
24
|
+
message: "What file should be used for Firestore indexes?",
|
|
25
|
+
default: "firestore.indexes.json",
|
|
26
|
+
},
|
|
27
|
+
])
|
|
28
|
+
.then(() => {
|
|
29
|
+
const filename = setup.config.firestore.indexes;
|
|
30
|
+
if (fsutils.fileExistsSync(filename)) {
|
|
31
|
+
const msg = "File " +
|
|
32
|
+
clc.bold(filename) +
|
|
33
|
+
" already exists." +
|
|
34
|
+
" Do you want to overwrite it with the Firestore Indexes from the Firebase Console?";
|
|
35
|
+
return (0, prompt_1.promptOnce)({
|
|
36
|
+
type: "confirm",
|
|
37
|
+
message: msg,
|
|
38
|
+
default: false,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return Promise.resolve(true);
|
|
42
|
+
})
|
|
43
|
+
.then((overwrite) => {
|
|
44
|
+
if (!overwrite) {
|
|
45
|
+
return Promise.resolve();
|
|
46
|
+
}
|
|
47
|
+
if (!setup.projectId) {
|
|
48
|
+
return config.writeProjectFile(setup.config.firestore.indexes, INDEXES_TEMPLATE);
|
|
49
|
+
}
|
|
50
|
+
return getIndexesFromConsole(setup.projectId).then((contents) => {
|
|
51
|
+
return config.writeProjectFile(setup.config.firestore.indexes, contents);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
exports.initIndexes = initIndexes;
|
|
56
|
+
function getIndexesFromConsole(projectId) {
|
|
57
|
+
const indexesPromise = indexes.listIndexes(projectId);
|
|
58
|
+
const fieldOverridesPromise = indexes.listFieldOverrides(projectId);
|
|
59
|
+
return Promise.all([indexesPromise, fieldOverridesPromise])
|
|
60
|
+
.then((res) => {
|
|
61
|
+
return indexes.makeIndexSpec(res[0], res[1]);
|
|
62
|
+
})
|
|
63
|
+
.catch((e) => {
|
|
64
|
+
if (e.message.indexOf("is not a Cloud Firestore enabled project") >= 0) {
|
|
65
|
+
return INDEXES_TEMPLATE;
|
|
66
|
+
}
|
|
67
|
+
throw new error_1.FirebaseError("Error fetching Firestore indexes", {
|
|
68
|
+
original: e,
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initRules = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const gcp = require("../../../gcp");
|
|
7
|
+
const fsutils = require("../../../fsutils");
|
|
8
|
+
const prompt_1 = require("../../../prompt");
|
|
9
|
+
const logger_1 = require("../../../logger");
|
|
10
|
+
const utils = require("../../../utils");
|
|
11
|
+
const DEFAULT_RULES_FILE = "firestore.rules";
|
|
12
|
+
const RULES_TEMPLATE = fs.readFileSync(__dirname + "/../../../../templates/init/firestore/firestore.rules", "utf8");
|
|
13
|
+
function initRules(setup, config) {
|
|
14
|
+
logger_1.logger.info();
|
|
15
|
+
logger_1.logger.info("Firestore Security Rules allow you to define how and when to allow");
|
|
16
|
+
logger_1.logger.info("requests. You can keep these rules in your project directory");
|
|
17
|
+
logger_1.logger.info("and publish them with " + clc.bold("firebase deploy") + ".");
|
|
18
|
+
logger_1.logger.info();
|
|
19
|
+
return (0, prompt_1.prompt)(setup.config.firestore, [
|
|
20
|
+
{
|
|
21
|
+
type: "input",
|
|
22
|
+
name: "rules",
|
|
23
|
+
message: "What file should be used for Firestore Rules?",
|
|
24
|
+
default: DEFAULT_RULES_FILE,
|
|
25
|
+
},
|
|
26
|
+
])
|
|
27
|
+
.then(() => {
|
|
28
|
+
const filename = setup.config.firestore.rules;
|
|
29
|
+
if (fsutils.fileExistsSync(filename)) {
|
|
30
|
+
const msg = "File " +
|
|
31
|
+
clc.bold(filename) +
|
|
32
|
+
" already exists." +
|
|
33
|
+
" Do you want to overwrite it with the Firestore Rules from the Firebase Console?";
|
|
34
|
+
return (0, prompt_1.promptOnce)({
|
|
35
|
+
type: "confirm",
|
|
36
|
+
message: msg,
|
|
37
|
+
default: false,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return Promise.resolve(true);
|
|
41
|
+
})
|
|
42
|
+
.then((overwrite) => {
|
|
43
|
+
if (!overwrite) {
|
|
44
|
+
return Promise.resolve();
|
|
45
|
+
}
|
|
46
|
+
if (!setup.projectId) {
|
|
47
|
+
return config.writeProjectFile(setup.config.firestore.rules, getDefaultRules());
|
|
48
|
+
}
|
|
49
|
+
return getRulesFromConsole(setup.projectId).then((contents) => {
|
|
50
|
+
return config.writeProjectFile(setup.config.firestore.rules, contents);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.initRules = initRules;
|
|
55
|
+
function getDefaultRules() {
|
|
56
|
+
const date = utils.thirtyDaysFromNow();
|
|
57
|
+
const formattedForRules = `${date.getFullYear()}, ${date.getMonth() + 1}, ${date.getDate()}`;
|
|
58
|
+
return RULES_TEMPLATE.replace(/{{IN_30_DAYS}}/g, formattedForRules);
|
|
59
|
+
}
|
|
60
|
+
function getRulesFromConsole(projectId) {
|
|
61
|
+
return gcp.rules
|
|
62
|
+
.getLatestRulesetName(projectId, "cloud.firestore")
|
|
63
|
+
.then((name) => {
|
|
64
|
+
if (!name) {
|
|
65
|
+
logger_1.logger.debug("No rulesets found, using default.");
|
|
66
|
+
return [{ name: DEFAULT_RULES_FILE, content: getDefaultRules() }];
|
|
67
|
+
}
|
|
68
|
+
logger_1.logger.debug("Found ruleset: " + name);
|
|
69
|
+
return gcp.rules.getRulesetContent(name);
|
|
70
|
+
})
|
|
71
|
+
.then((rules) => {
|
|
72
|
+
if (rules.length <= 0) {
|
|
73
|
+
return utils.reject("Ruleset has no files", { exit: 1 });
|
|
74
|
+
}
|
|
75
|
+
if (rules.length > 1) {
|
|
76
|
+
return utils.reject("Ruleset has too many files: " + rules.length, { exit: 1 });
|
|
77
|
+
}
|
|
78
|
+
return rules[0].content;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ALLOWED_DEPLOY_METHODS = exports.DEFAULT_DEPLOY_METHOD = exports.ALLOWED_REGIONS = exports.DEFAULT_REGION = void 0;
|
|
4
|
+
exports.DEFAULT_REGION = "us-central1";
|
|
5
|
+
exports.ALLOWED_REGIONS = [{ name: "us-central1 (Iowa)", value: "us-central1" }];
|
|
6
|
+
exports.DEFAULT_DEPLOY_METHOD = "github";
|
|
7
|
+
exports.ALLOWED_DEPLOY_METHODS = [{ name: "Deploy using github", value: "github" }];
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBackend = exports.getOrCreateBackend = exports.doSetup = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const utils = require("../../../utils");
|
|
6
|
+
const logger_1 = require("../../../logger");
|
|
7
|
+
const prompt_1 = require("../../../prompt");
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
const repo = require("./repo");
|
|
10
|
+
const poller = require("../../../operation-poller");
|
|
11
|
+
const api_1 = require("../../../api");
|
|
12
|
+
const gcp = require("../../../gcp/frameworks");
|
|
13
|
+
const frameworks_1 = require("../../../gcp/frameworks");
|
|
14
|
+
const error_1 = require("../../../error");
|
|
15
|
+
const frameworksPollerOptions = {
|
|
16
|
+
apiOrigin: api_1.frameworksOrigin,
|
|
17
|
+
apiVersion: frameworks_1.API_VERSION,
|
|
18
|
+
masterTimeout: 25 * 60 * 1000,
|
|
19
|
+
maxBackoff: 10000,
|
|
20
|
+
};
|
|
21
|
+
async function doSetup(setup, projectId) {
|
|
22
|
+
setup.frameworks = {};
|
|
23
|
+
utils.logBullet("First we need a few details to create your backend.");
|
|
24
|
+
await (0, prompt_1.promptOnce)({
|
|
25
|
+
name: "serviceName",
|
|
26
|
+
type: "input",
|
|
27
|
+
default: "acme-inc-web",
|
|
28
|
+
message: "Create a name for your backend [1-30 characters]",
|
|
29
|
+
}, setup.frameworks);
|
|
30
|
+
await (0, prompt_1.promptOnce)({
|
|
31
|
+
name: "region",
|
|
32
|
+
type: "list",
|
|
33
|
+
default: constants_1.DEFAULT_REGION,
|
|
34
|
+
message: "Please select a region " +
|
|
35
|
+
`(${clc.yellow("info")}: Your region determines where your backend is located):\n`,
|
|
36
|
+
choices: constants_1.ALLOWED_REGIONS,
|
|
37
|
+
}, setup.frameworks);
|
|
38
|
+
utils.logSuccess(`Region set to ${setup.frameworks.region}.`);
|
|
39
|
+
const backend = await getOrCreateBackend(projectId, setup);
|
|
40
|
+
if (backend) {
|
|
41
|
+
logger_1.logger.info();
|
|
42
|
+
utils.logSuccess(`Successfully created backend:\n ${backend.name}`);
|
|
43
|
+
logger_1.logger.info();
|
|
44
|
+
utils.logSuccess(`Your site is being deployed at:\n https://${backend.uri}`);
|
|
45
|
+
logger_1.logger.info();
|
|
46
|
+
utils.logSuccess(`View the rollout status by running:\n firebase backends:get --backend=${backend.name}`);
|
|
47
|
+
logger_1.logger.info();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.doSetup = doSetup;
|
|
51
|
+
function toBackend(cloudBuildConnRepo) {
|
|
52
|
+
return {
|
|
53
|
+
codebase: {
|
|
54
|
+
repository: `${cloudBuildConnRepo.name}`,
|
|
55
|
+
rootDirectory: "/",
|
|
56
|
+
},
|
|
57
|
+
labels: {},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async function getOrCreateBackend(projectId, setup) {
|
|
61
|
+
const location = setup.frameworks.region;
|
|
62
|
+
try {
|
|
63
|
+
return await getExistingBackend(projectId, setup, location);
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
if (err.status === 404) {
|
|
67
|
+
const cloudBuildConnRepo = await repo.linkGitHubRepository(projectId, location);
|
|
68
|
+
logger_1.logger.info();
|
|
69
|
+
await (0, prompt_1.promptOnce)({
|
|
70
|
+
name: "branchName",
|
|
71
|
+
type: "input",
|
|
72
|
+
default: "main",
|
|
73
|
+
message: "Which branch do you want to deploy?",
|
|
74
|
+
}, setup.frameworks);
|
|
75
|
+
const backendDetails = toBackend(cloudBuildConnRepo);
|
|
76
|
+
logger_1.logger.info(clc.bold(`\n${clc.white("===")} Creating your backend`));
|
|
77
|
+
return await createBackend(projectId, location, backendDetails, setup.frameworks.serviceName);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
throw new error_1.FirebaseError(`Failed to get or create a backend using the given initialization details: ${err}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
exports.getOrCreateBackend = getOrCreateBackend;
|
|
86
|
+
async function getExistingBackend(projectId, setup, location) {
|
|
87
|
+
let backend = await gcp.getBackend(projectId, location, setup.frameworks.serviceName);
|
|
88
|
+
while (backend) {
|
|
89
|
+
setup.frameworks.serviceName = undefined;
|
|
90
|
+
await (0, prompt_1.promptOnce)({
|
|
91
|
+
name: "existingBackend",
|
|
92
|
+
type: "confirm",
|
|
93
|
+
default: true,
|
|
94
|
+
message: "A backend already exists for the given serviceName, do you want to use existing backend? (yes/no)",
|
|
95
|
+
}, setup.frameworks);
|
|
96
|
+
if (setup.frameworks.existingBackend) {
|
|
97
|
+
logger_1.logger.info("Using the existing backend.");
|
|
98
|
+
return backend;
|
|
99
|
+
}
|
|
100
|
+
await (0, prompt_1.promptOnce)({
|
|
101
|
+
name: "serviceName",
|
|
102
|
+
type: "input",
|
|
103
|
+
default: "acme-inc-web",
|
|
104
|
+
message: "Please enter a new service name [1-30 characters]",
|
|
105
|
+
}, setup.frameworks);
|
|
106
|
+
backend = await gcp.getBackend(projectId, location, setup.frameworks.serviceName);
|
|
107
|
+
setup.frameworks.existingBackend = undefined;
|
|
108
|
+
}
|
|
109
|
+
return backend;
|
|
110
|
+
}
|
|
111
|
+
async function createBackend(projectId, location, backendReqBoby, backendId) {
|
|
112
|
+
const op = await gcp.createBackend(projectId, location, backendReqBoby, backendId);
|
|
113
|
+
const backend = await poller.pollOperation(Object.assign(Object.assign({}, frameworksPollerOptions), { pollerName: `create-${projectId}-${location}-${backendId}`, operationResourceName: op.name }));
|
|
114
|
+
return backend;
|
|
115
|
+
}
|
|
116
|
+
exports.createBackend = createBackend;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOrCreateRepository = exports.getOrCreateConnection = exports.linkGitHubRepository = void 0;
|
|
4
|
+
const api_1 = require("../../../api");
|
|
5
|
+
const error_1 = require("../../../error");
|
|
6
|
+
const gcb = require("../../../gcp/cloudbuild");
|
|
7
|
+
const logger_1 = require("../../../logger");
|
|
8
|
+
const poller = require("../../../operation-poller");
|
|
9
|
+
const utils = require("../../../utils");
|
|
10
|
+
const prompt_1 = require("../../../prompt");
|
|
11
|
+
const clc = require("colorette");
|
|
12
|
+
const gcbPollerOptions = {
|
|
13
|
+
apiOrigin: api_1.cloudbuildOrigin,
|
|
14
|
+
apiVersion: "v2",
|
|
15
|
+
masterTimeout: 25 * 60 * 1000,
|
|
16
|
+
maxBackoff: 10000,
|
|
17
|
+
};
|
|
18
|
+
function extractRepoSlugFromURI(remoteUri) {
|
|
19
|
+
const match = /github.com\/(.+).git/.exec(remoteUri);
|
|
20
|
+
if (!match) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
return match[1];
|
|
24
|
+
}
|
|
25
|
+
function generateRepositoryId(remoteUri) {
|
|
26
|
+
var _a;
|
|
27
|
+
return (_a = extractRepoSlugFromURI(remoteUri)) === null || _a === void 0 ? void 0 : _a.replaceAll("/", "-");
|
|
28
|
+
}
|
|
29
|
+
function generateConnectionId(location) {
|
|
30
|
+
return `frameworks-${location}`;
|
|
31
|
+
}
|
|
32
|
+
async function linkGitHubRepository(projectId, location) {
|
|
33
|
+
logger_1.logger.info(clc.bold(`\n${clc.white("===")} Connect a github repository`));
|
|
34
|
+
const connectionId = generateConnectionId(location);
|
|
35
|
+
await getOrCreateConnection(projectId, location, connectionId);
|
|
36
|
+
let remoteUri = await promptRepositoryURI(projectId, location, connectionId);
|
|
37
|
+
while (remoteUri === "") {
|
|
38
|
+
await utils.openInBrowser("https://github.com/apps/google-cloud-build/installations/new");
|
|
39
|
+
await (0, prompt_1.promptOnce)({
|
|
40
|
+
type: "input",
|
|
41
|
+
message: "Press ENTER once you have finished configuring your installation's access settings.",
|
|
42
|
+
});
|
|
43
|
+
remoteUri = await promptRepositoryURI(projectId, location, connectionId);
|
|
44
|
+
}
|
|
45
|
+
const repo = await getOrCreateRepository(projectId, location, connectionId, remoteUri);
|
|
46
|
+
logger_1.logger.info();
|
|
47
|
+
utils.logSuccess(`Successfully linked GitHub repository at remote URI:\n ${remoteUri}`);
|
|
48
|
+
return repo;
|
|
49
|
+
}
|
|
50
|
+
exports.linkGitHubRepository = linkGitHubRepository;
|
|
51
|
+
async function promptRepositoryURI(projectId, location, connectionId) {
|
|
52
|
+
const resp = await gcb.fetchLinkableRepositories(projectId, location, connectionId);
|
|
53
|
+
if (!resp.repositories || resp.repositories.length === 0) {
|
|
54
|
+
throw new error_1.FirebaseError("The GitHub App does not have access to any repositories. Please configure " +
|
|
55
|
+
"your app installation permissions at https://github.com/settings/installations.");
|
|
56
|
+
}
|
|
57
|
+
const choices = resp.repositories.map((repo) => ({
|
|
58
|
+
name: extractRepoSlugFromURI(repo.remoteUri) || repo.remoteUri,
|
|
59
|
+
value: repo.remoteUri,
|
|
60
|
+
}));
|
|
61
|
+
choices.push({
|
|
62
|
+
name: "Missing a repo? Select this option to configure your installation's access settings",
|
|
63
|
+
value: "",
|
|
64
|
+
});
|
|
65
|
+
return await (0, prompt_1.promptOnce)({
|
|
66
|
+
type: "list",
|
|
67
|
+
message: "Which of the following repositories would you like to deploy?",
|
|
68
|
+
choices,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
async function promptConnectionAuth(conn, projectId, location, connectionId) {
|
|
72
|
+
logger_1.logger.info("First, log in to GitHub, install and authorize Cloud Build app:");
|
|
73
|
+
logger_1.logger.info(conn.installationState.actionUri);
|
|
74
|
+
await utils.openInBrowser(conn.installationState.actionUri);
|
|
75
|
+
await (0, prompt_1.promptOnce)({
|
|
76
|
+
type: "input",
|
|
77
|
+
message: "Press Enter once you have authorized the app (Cloud Build) to access your GitHub repo.",
|
|
78
|
+
});
|
|
79
|
+
return await gcb.getConnection(projectId, location, connectionId);
|
|
80
|
+
}
|
|
81
|
+
async function getOrCreateConnection(projectId, location, connectionId) {
|
|
82
|
+
let conn;
|
|
83
|
+
try {
|
|
84
|
+
conn = await gcb.getConnection(projectId, location, connectionId);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
if (err.status === 404) {
|
|
88
|
+
const op = await gcb.createConnection(projectId, location, connectionId);
|
|
89
|
+
conn = await poller.pollOperation(Object.assign(Object.assign({}, gcbPollerOptions), { pollerName: `create-${location}-${connectionId}`, operationResourceName: op.name }));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
throw err;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
while (conn.installationState.stage !== "COMPLETE") {
|
|
96
|
+
conn = await promptConnectionAuth(conn, projectId, location, connectionId);
|
|
97
|
+
}
|
|
98
|
+
return conn;
|
|
99
|
+
}
|
|
100
|
+
exports.getOrCreateConnection = getOrCreateConnection;
|
|
101
|
+
async function getOrCreateRepository(projectId, location, connectionId, remoteUri) {
|
|
102
|
+
const repositoryId = generateRepositoryId(remoteUri);
|
|
103
|
+
if (!repositoryId) {
|
|
104
|
+
throw new error_1.FirebaseError(`Failed to generate repositoryId for URI "${remoteUri}".`);
|
|
105
|
+
}
|
|
106
|
+
let repo;
|
|
107
|
+
try {
|
|
108
|
+
repo = await gcb.getRepository(projectId, location, connectionId, repositoryId);
|
|
109
|
+
const repoSlug = extractRepoSlugFromURI(repo.remoteUri);
|
|
110
|
+
if (repoSlug) {
|
|
111
|
+
throw new error_1.FirebaseError(`${repoSlug} has already been linked.`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
if (err.status === 404) {
|
|
116
|
+
const op = await gcb.createRepository(projectId, location, connectionId, repositoryId, remoteUri);
|
|
117
|
+
repo = await poller.pollOperation(Object.assign(Object.assign({}, gcbPollerOptions), { pollerName: `create-${location}-${connectionId}-${repositoryId}`, operationResourceName: op.name }));
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
throw err;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return repo;
|
|
124
|
+
}
|
|
125
|
+
exports.getOrCreateRepository = getOrCreateRepository;
|