firebase-tools-with-isolate 13.29.1 → 14.10.1-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -4
- package/lib/api.js +10 -2
- package/lib/appdistribution/client.js +2 -2
- package/lib/apphosting/backend.js +157 -55
- package/lib/apphosting/config.js +121 -101
- package/lib/apphosting/githubConnections.js +65 -100
- package/lib/apphosting/repo.js +22 -36
- package/lib/apphosting/rollout.js +5 -11
- package/lib/apphosting/secrets/dialogs.js +13 -11
- package/lib/apphosting/secrets/index.js +47 -5
- package/lib/apphosting/utils.js +1 -3
- package/lib/apphosting/yaml.js +35 -49
- package/lib/auth.js +23 -6
- package/lib/bin/cli.js +99 -0
- package/lib/bin/firebase.js +7 -123
- package/lib/bin/mcp.js +49 -0
- package/lib/checkValidTargetFilters.js +1 -0
- package/lib/command.js +3 -2
- package/lib/commands/appdistribution-distribute.js +1 -1
- package/lib/commands/appdistribution-groups-create.js +1 -1
- package/lib/commands/appdistribution-groups-delete.js +1 -1
- package/lib/commands/appdistribution-groups-list.js +2 -2
- package/lib/commands/appdistribution-testers-add.js +1 -1
- package/lib/commands/appdistribution-testers-list.js +3 -3
- package/lib/commands/appdistribution-testers-remove.js +1 -1
- package/lib/commands/apphosting-backends-create.js +3 -3
- package/lib/commands/apphosting-backends-delete.js +23 -27
- package/lib/commands/apphosting-backends-get.js +12 -12
- package/lib/commands/apphosting-backends-list.js +5 -5
- package/lib/commands/apphosting-builds-create.js +8 -2
- package/lib/commands/apphosting-builds-get.js +8 -1
- package/lib/commands/apphosting-rollouts-create.js +3 -3
- package/lib/commands/apphosting-rollouts-list.js +8 -2
- package/lib/commands/apphosting-secrets-access.js +1 -1
- package/lib/commands/apphosting-secrets-describe.js +2 -2
- package/lib/commands/apphosting-secrets-grantaccess.js +20 -10
- package/lib/commands/apphosting-secrets-set.js +27 -1
- package/lib/commands/apps-android-sha-create.js +1 -1
- package/lib/commands/apps-android-sha-delete.js +1 -1
- package/lib/commands/apps-android-sha-list.js +2 -2
- package/lib/commands/apps-create.js +4 -108
- package/lib/commands/apps-init.js +94 -0
- package/lib/commands/apps-list.js +1 -1
- package/lib/commands/apps-sdkconfig.js +5 -10
- package/lib/commands/auth-export.js +1 -1
- package/lib/commands/auth-import.js +1 -1
- package/lib/commands/database-import.js +4 -6
- package/lib/commands/database-instances-create.js +1 -1
- package/lib/commands/database-instances-list.js +1 -1
- package/lib/commands/database-profile.js +1 -2
- package/lib/commands/database-remove.js +4 -6
- package/lib/commands/database-set.js +6 -6
- package/lib/commands/database-settings-set.js +1 -1
- package/lib/commands/database-update.js +6 -6
- package/lib/commands/dataconnect-sdk-generate.js +5 -2
- package/lib/commands/dataconnect-services-list.js +2 -2
- package/lib/commands/dataconnect-sql-diff.js +2 -2
- package/lib/commands/dataconnect-sql-grant.js +3 -3
- package/lib/commands/dataconnect-sql-migrate.js +2 -2
- package/lib/commands/dataconnect-sql-setup.js +39 -0
- package/lib/commands/dataconnect-sql-shell.js +5 -7
- package/lib/commands/deploy.js +4 -3
- package/lib/commands/emulators-exec.js +1 -1
- package/lib/commands/emulators-start.js +4 -3
- package/lib/commands/experiments-list.js +1 -1
- package/lib/commands/ext-dev-deprecate.js +1 -0
- package/lib/commands/ext-dev-init.js +3 -12
- package/lib/commands/ext-dev-list.js +1 -1
- package/lib/commands/ext-dev-register.js +3 -5
- package/lib/commands/ext-dev-undeprecate.js +1 -2
- package/lib/commands/ext-dev-usage.js +4 -6
- package/lib/commands/ext-export.js +1 -2
- package/lib/commands/ext-install.js +3 -3
- package/lib/commands/ext-sdk-install.js +1 -0
- package/lib/commands/ext-update.js +1 -0
- package/lib/commands/firestore-backups-delete.js +3 -4
- package/lib/commands/firestore-backups-get.js +1 -1
- package/lib/commands/firestore-backups-list.js +2 -2
- package/lib/commands/firestore-backups-schedules-create.js +4 -4
- package/lib/commands/firestore-backups-schedules-delete.js +3 -4
- package/lib/commands/firestore-backups-schedules-list.js +2 -2
- package/lib/commands/firestore-backups-schedules-update.js +1 -1
- package/lib/commands/firestore-databases-create.js +6 -6
- package/lib/commands/firestore-databases-delete.js +3 -7
- package/lib/commands/firestore-databases-get.js +1 -1
- package/lib/commands/firestore-databases-list.js +1 -1
- package/lib/commands/firestore-databases-restore.js +5 -5
- package/lib/commands/firestore-databases-update.js +4 -4
- package/lib/commands/firestore-delete.js +13 -14
- package/lib/commands/firestore-indexes-list.js +4 -4
- package/lib/commands/firestore-locations.js +1 -1
- package/lib/commands/functions-artifacts-setpolicy.js +132 -0
- package/lib/commands/functions-config-export.js +6 -10
- package/lib/commands/functions-delete.js +5 -7
- package/lib/commands/functions-deletegcfartifacts.js +5 -5
- package/lib/commands/functions-list.js +24 -33
- package/lib/commands/functions-secrets-access.js +1 -1
- package/lib/commands/functions-secrets-describe.js +1 -1
- package/lib/commands/functions-secrets-destroy.js +10 -12
- package/lib/commands/functions-secrets-get.js +1 -1
- package/lib/commands/functions-secrets-prune.js +14 -15
- package/lib/commands/functions-secrets-set.js +14 -18
- package/lib/commands/hosting-channel-create.js +1 -2
- package/lib/commands/hosting-channel-delete.js +4 -4
- package/lib/commands/hosting-channel-list.js +1 -1
- package/lib/commands/hosting-channel-open.js +2 -3
- package/lib/commands/hosting-disable.js +5 -5
- package/lib/commands/hosting-sites-delete.js +4 -4
- package/lib/commands/hosting-sites-get.js +1 -1
- package/lib/commands/hosting-sites-list.js +1 -1
- package/lib/commands/index.js +7 -4
- package/lib/commands/init.js +54 -60
- package/lib/commands/internaltesting-frameworks-compose.js +1 -1
- package/lib/commands/login-use.js +2 -11
- package/lib/commands/login.js +10 -8
- package/lib/commands/logout.js +2 -3
- package/lib/commands/mcp.js +11 -0
- package/lib/commands/open.js +4 -2
- package/lib/commands/projects-create.js +1 -2
- package/lib/commands/projects-list.js +1 -1
- package/lib/commands/remoteconfig-get.js +1 -1
- package/lib/commands/remoteconfig-rollback.js +5 -5
- package/lib/commands/remoteconfig-versions-list.js +2 -2
- package/lib/commands/setup-emulators-database.js +1 -1
- package/lib/commands/setup-emulators-dataconnect.js +1 -1
- package/lib/commands/setup-emulators-firestore.js +1 -1
- package/lib/commands/setup-emulators-pubsub.js +1 -1
- package/lib/commands/setup-emulators-storage.js +1 -1
- package/lib/commands/setup-emulators-ui.js +1 -1
- package/lib/commands/use.js +115 -111
- package/lib/config.js +49 -33
- package/lib/crashlytics/buildToolsJarHelper.js +1 -1
- package/lib/crashlytics/listTopIssues.js +45 -0
- package/lib/dataconnect/build.js +61 -4
- package/lib/dataconnect/client.js +26 -17
- package/lib/dataconnect/cloudAICompanionClient.js +72 -0
- package/lib/dataconnect/dataplaneClient.js +19 -2
- package/lib/dataconnect/ensureApis.js +6 -3
- package/lib/dataconnect/fileUtils.js +39 -6
- package/lib/dataconnect/freeTrial.js +21 -9
- package/lib/dataconnect/graphqlError.js +56 -2
- package/lib/dataconnect/provisionCloudSql.js +23 -12
- package/lib/dataconnect/schemaMigration.js +46 -26
- package/lib/dataconnect/types.js +5 -1
- package/lib/defaultCredentials.js +12 -1
- package/lib/deploy/apphosting/args.js +2 -0
- package/lib/deploy/apphosting/deploy.js +77 -0
- package/lib/deploy/apphosting/index.js +9 -0
- package/lib/deploy/apphosting/prepare.js +138 -0
- package/lib/deploy/apphosting/release.js +56 -0
- package/lib/deploy/apphosting/util.js +65 -0
- package/lib/deploy/dataconnect/deploy.js +14 -7
- package/lib/deploy/dataconnect/prepare.js +3 -5
- package/lib/deploy/extensions/v2FunctionHelper.js +2 -1
- package/lib/deploy/firestore/deploy.js +50 -4
- package/lib/deploy/functions/build.js +1 -0
- package/lib/deploy/functions/checkIam.js +41 -6
- package/lib/deploy/functions/containerCleaner.js +17 -2
- package/lib/deploy/functions/ensure.js +2 -1
- package/lib/deploy/functions/params.js +10 -17
- package/lib/deploy/functions/prepare.js +51 -18
- package/lib/deploy/functions/prepareFunctionsUpload.js +9 -5
- package/lib/deploy/functions/prompts.js +24 -17
- package/lib/deploy/functions/release/fabricator.js +4 -4
- package/lib/deploy/functions/release/index.js +27 -9
- package/lib/deploy/functions/release/planner.js +1 -0
- package/lib/deploy/functions/runtimes/discovery/index.js +13 -5
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +4 -4
- package/lib/deploy/functions/runtimes/python/index.js +4 -1
- package/lib/deploy/functions/runtimes/supported/types.js +17 -11
- package/lib/deploy/functions/services/firestore.js +23 -4
- package/lib/deploy/index.js +29 -10
- package/lib/deploy/lifecycleHooks.js +6 -12
- package/lib/emulator/ExpressBasedEmulator.js +1 -1
- package/lib/emulator/apphosting/config.js +15 -14
- package/lib/emulator/apphosting/index.js +2 -0
- package/lib/emulator/apphosting/serve.js +147 -10
- package/lib/emulator/auth/cloudFunctions.js +13 -1
- package/lib/emulator/auth/operations.js +2 -1
- package/lib/emulator/auth/widget_ui.js +2 -1
- package/lib/emulator/commandUtils.js +14 -20
- package/lib/emulator/constants.js +2 -0
- package/lib/emulator/controller.js +24 -9
- package/lib/emulator/dataconnect/pgliteServer.js +136 -45
- package/lib/emulator/dataconnectEmulator.js +34 -6
- package/lib/emulator/dataconnectToolkitController.js +5 -0
- package/lib/emulator/downloadableEmulatorInfo.json +81 -0
- package/lib/emulator/downloadableEmulators.js +28 -80
- package/lib/emulator/env.js +47 -1
- package/lib/emulator/extensionsEmulator.js +5 -3
- package/lib/emulator/functionsEmulator.js +6 -26
- package/lib/emulator/hub.js +5 -4
- package/lib/emulator/hubClient.js +5 -0
- package/lib/emulator/initEmulators.js +29 -15
- package/lib/emulator/ui.js +4 -8
- package/lib/ensureApiEnabled.js +32 -1
- package/lib/experiments.js +11 -12
- package/lib/extensions/askUserForEventsConfig.js +6 -15
- package/lib/extensions/askUserForParam.js +23 -52
- package/lib/extensions/change-log.js +1 -25
- package/lib/extensions/checkProjectBilling.js +3 -9
- package/lib/extensions/diagnose.js +3 -6
- package/lib/extensions/emulator/triggerHelper.js +4 -0
- package/lib/extensions/extensionsHelper.js +25 -31
- package/lib/extensions/listExtensions.js +1 -1
- package/lib/extensions/manifest.js +3 -7
- package/lib/extensions/paramHelper.js +11 -2
- package/lib/extensions/provisioningHelper.js +1 -1
- package/lib/extensions/tos.js +4 -2
- package/lib/extensions/utils.js +1 -10
- package/lib/firebaseConfigValidate.js +7 -5
- package/lib/firestore/delete.js +5 -4
- package/lib/firestore/pretty-print.js +1 -1
- package/lib/frameworks/angular/index.js +11 -6
- package/lib/frameworks/angular/utils.js +76 -47
- package/lib/frameworks/constants.js +1 -1
- package/lib/frameworks/index.js +6 -4
- package/lib/frameworks/next/index.js +7 -4
- package/lib/frameworks/utils.js +11 -3
- package/lib/frameworks/vite/index.js +2 -3
- package/lib/fsAsync.js +9 -2
- package/lib/fsutils.js +16 -1
- package/lib/functions/artifacts.js +196 -0
- package/lib/functions/secrets.js +15 -16
- package/lib/gcp/apphosting.js +13 -1
- package/lib/gcp/artifactregistry.js +27 -2
- package/lib/gcp/auth.js +113 -1
- package/lib/gcp/cloudbilling.js +12 -1
- package/lib/gcp/cloudfunctions.js +32 -4
- package/lib/gcp/cloudfunctionsv2.js +15 -9
- package/lib/gcp/cloudscheduler.js +2 -2
- package/lib/gcp/cloudsql/cloudsqladmin.js +32 -11
- package/lib/gcp/cloudsql/connect.js +21 -14
- package/lib/gcp/cloudsql/interactive.js +1 -1
- package/lib/gcp/cloudsql/permissions.js +46 -99
- package/lib/gcp/cloudsql/permissionsSetup.js +224 -0
- package/lib/gcp/computeEngine.js +19 -2
- package/lib/gcp/devConnect.js +6 -1
- package/lib/gcp/firestore.js +55 -16
- package/lib/gcp/iam.js +1 -5
- package/lib/gcp/proto.js +4 -3
- package/lib/gcp/run.js +18 -1
- package/lib/gcp/serviceusage.js +2 -1
- package/lib/gcp/storage.js +47 -1
- package/lib/gemini/fdcExperience.js +56 -0
- package/lib/gemini/types.js +2 -0
- package/lib/hosting/api.js +4 -0
- package/lib/hosting/implicitInit.js +7 -3
- package/lib/hosting/interactive.js +2 -3
- package/lib/index.js +1 -2
- package/lib/init/features/account.js +2 -4
- package/lib/init/features/apphosting.js +75 -6
- package/lib/init/features/database.js +63 -62
- package/lib/init/features/dataconnect/index.js +131 -85
- package/lib/init/features/dataconnect/sdk.js +73 -18
- package/lib/init/features/emulators.js +29 -46
- package/lib/init/features/firestore/index.js +79 -43
- package/lib/init/features/firestore/indexes.js +30 -45
- package/lib/init/features/firestore/rules.js +36 -62
- package/lib/init/features/functions/index.js +11 -16
- package/lib/init/features/functions/javascript.js +17 -30
- package/lib/init/features/functions/npm-dependencies.js +4 -8
- package/lib/init/features/functions/python.js +1 -3
- package/lib/init/features/functions/typescript.js +25 -43
- package/lib/init/features/genkit/index.js +111 -106
- package/lib/init/features/hosting/github.js +22 -52
- package/lib/init/features/hosting/index.js +37 -57
- package/lib/init/features/index.js +10 -5
- package/lib/init/features/project.js +18 -21
- package/lib/init/features/remoteconfig.js +5 -10
- package/lib/init/features/storage.js +30 -10
- package/lib/init/index.js +79 -24
- package/lib/logger.js +76 -3
- package/lib/management/apps.js +292 -7
- package/lib/management/projects.js +100 -52
- package/lib/mcp/errors.js +20 -0
- package/lib/mcp/index.js +227 -0
- package/lib/mcp/tool.js +12 -0
- package/lib/mcp/tools/apphosting/fetch_logs.js +68 -0
- package/lib/mcp/tools/apphosting/index.js +6 -0
- package/lib/mcp/tools/apphosting/list_backends.js +51 -0
- package/lib/mcp/tools/auth/disable_user.js +30 -0
- package/lib/mcp/tools/auth/get_user.js +38 -0
- package/lib/mcp/tools/auth/index.js +15 -0
- package/lib/mcp/tools/auth/list_users.js +36 -0
- package/lib/mcp/tools/auth/set_claims.js +43 -0
- package/lib/mcp/tools/auth/set_sms_region_policy.js +36 -0
- package/lib/mcp/tools/core/consult_assistant.js +28 -0
- package/lib/mcp/tools/core/create_android_sha.js +43 -0
- package/lib/mcp/tools/core/create_app.js +90 -0
- package/lib/mcp/tools/core/create_project.js +68 -0
- package/lib/mcp/tools/core/get_admin_sdk_config.js +26 -0
- package/lib/mcp/tools/core/get_environment.js +51 -0
- package/lib/mcp/tools/core/get_project.js +22 -0
- package/lib/mcp/tools/core/get_sdk_config.js +40 -0
- package/lib/mcp/tools/core/index.js +29 -0
- package/lib/mcp/tools/core/init.js +153 -0
- package/lib/mcp/tools/core/list_apps.js +34 -0
- package/lib/mcp/tools/core/list_projects.js +45 -0
- package/lib/mcp/tools/core/update_environment.js +55 -0
- package/lib/mcp/tools/crashlytics/index.js +5 -0
- package/lib/mcp/tools/crashlytics/list_top_issues.js +39 -0
- package/lib/mcp/tools/dataconnect/converter.js +60 -0
- package/lib/mcp/tools/dataconnect/emulator.js +16 -0
- package/lib/mcp/tools/dataconnect/execute_graphql.js +48 -0
- package/lib/mcp/tools/dataconnect/execute_graphql_read.js +48 -0
- package/lib/mcp/tools/dataconnect/execute_mutation.js +62 -0
- package/lib/mcp/tools/dataconnect/execute_query.js +62 -0
- package/lib/mcp/tools/dataconnect/generate_operation.js +34 -0
- package/lib/mcp/tools/dataconnect/generate_schema.js +26 -0
- package/lib/mcp/tools/dataconnect/get_connector.js +31 -0
- package/lib/mcp/tools/dataconnect/get_schema.js +31 -0
- package/lib/mcp/tools/dataconnect/index.js +23 -0
- package/lib/mcp/tools/dataconnect/list_services.js +23 -0
- package/lib/mcp/tools/firestore/converter.js +102 -0
- package/lib/mcp/tools/firestore/delete_document.js +50 -0
- package/lib/mcp/tools/firestore/get_documents.js +58 -0
- package/lib/mcp/tools/firestore/index.js +17 -0
- package/lib/mcp/tools/firestore/list_collections.js +36 -0
- package/lib/mcp/tools/firestore/query_collection.js +132 -0
- package/lib/mcp/tools/index.js +62 -0
- package/lib/mcp/tools/messaging/index.js +5 -0
- package/lib/mcp/tools/messaging/send_message.js +42 -0
- package/lib/mcp/tools/remoteconfig/get_template.js +27 -0
- package/lib/mcp/tools/remoteconfig/index.js +7 -0
- package/lib/mcp/tools/remoteconfig/publish_template.js +34 -0
- package/lib/mcp/tools/remoteconfig/rollback_template.js +29 -0
- package/lib/mcp/tools/rules/get_rules.js +29 -0
- package/lib/mcp/tools/rules/validate_rules.js +97 -0
- package/lib/mcp/tools/storage/get_download_url.js +40 -0
- package/lib/mcp/tools/storage/get_rules.js +26 -0
- package/lib/mcp/tools/storage/index.js +11 -0
- package/lib/mcp/types.js +13 -0
- package/lib/mcp/util.js +214 -0
- package/lib/mcp/util.test.js +468 -0
- package/lib/messaging/interfaces.js +2 -0
- package/lib/messaging/sendMessage.js +48 -0
- package/lib/operation-poller.js +3 -1
- package/lib/profileReport.js +1 -1
- package/lib/prompt.js +86 -54
- package/lib/remoteconfig/publish.js +39 -0
- package/lib/requireAuth.js +2 -2
- package/lib/requireTosAcceptance.js +4 -0
- package/lib/rulesDeploy.js +10 -15
- package/lib/track.js +7 -37
- package/lib/utils.js +28 -41
- package/lib/vsCodeUtils.js +7 -3
- package/package.json +31 -15
- package/schema/connector-yaml.json +12 -0
- package/schema/dataconnect-yaml.json +5 -0
- package/schema/extension-yaml.json +17 -4
- package/schema/firebase-config.json +1117 -2121
- package/standalone/package-lock.json +1255 -992
- package/standalone/package.json +1 -1
- package/templates/dataconnect-prompts/operation-generation-cursor-windsurf-rule.txt +273 -0
- package/templates/dataconnect-prompts/schema-generation-cursor-windsurf-rule.txt +653 -0
- package/templates/genkit/firebase.0.9.0.template +1 -1
- package/templates/genkit/firebase.1.0.0.template +71 -0
- package/templates/init/dataconnect/connector.yaml +4 -1
- package/templates/init/dataconnect/dataconnect.yaml +1 -1
- package/templates/init/dataconnect/mutations.gql +9 -26
- package/templates/init/dataconnect/queries.gql +9 -14
- package/templates/init/dataconnect/schema.gql +28 -21
- package/templates/init/firestore/firestore.rules +2 -0
- package/templates/init/functions/javascript/index.js +14 -1
- package/templates/init/functions/javascript/package.lint.json +1 -1
- package/templates/init/functions/javascript/package.nolint.json +1 -1
- package/templates/init/functions/python/_gitignore +6 -1
- package/templates/init/functions/python/main.py +8 -0
- package/templates/init/functions/typescript/index.ts +14 -1
- package/templates/init/functions/typescript/package.lint.json +2 -2
- package/templates/init/functions/typescript/package.nolint.json +3 -3
- package/lib/commands/apphosting-config-export.js +0 -28
- package/lib/commands/experimental-functions-shell.js +0 -13
- package/lib/emulator/dataconnect/pg-gateway/auth/base-auth-flow.js +0 -11
- package/lib/emulator/dataconnect/pg-gateway/auth/cert.js +0 -58
- package/lib/emulator/dataconnect/pg-gateway/auth/index.js +0 -22
- package/lib/emulator/dataconnect/pg-gateway/auth/md5.js +0 -124
- package/lib/emulator/dataconnect/pg-gateway/auth/password.js +0 -54
- package/lib/emulator/dataconnect/pg-gateway/auth/sasl/sasl-mechanism.js +0 -34
- package/lib/emulator/dataconnect/pg-gateway/auth/sasl/scram-sha-256.js +0 -270
- package/lib/emulator/dataconnect/pg-gateway/backend-error.js +0 -75
- package/lib/emulator/dataconnect/pg-gateway/buffer-reader.js +0 -54
- package/lib/emulator/dataconnect/pg-gateway/buffer-writer.js +0 -79
- package/lib/emulator/dataconnect/pg-gateway/connection.js +0 -315
- package/lib/emulator/dataconnect/pg-gateway/connection.types.js +0 -8
- package/lib/emulator/dataconnect/pg-gateway/crypto.js +0 -40
- package/lib/emulator/dataconnect/pg-gateway/duplex.js +0 -53
- package/lib/emulator/dataconnect/pg-gateway/index.js +0 -27
- package/lib/emulator/dataconnect/pg-gateway/message-buffer.js +0 -82
- package/lib/emulator/dataconnect/pg-gateway/message-codes.js +0 -52
- package/lib/emulator/dataconnect/pg-gateway/platforms/node/index.js +0 -16
- package/lib/emulator/dataconnect/pg-gateway/polyfills/readable-stream-async-iterator.js +0 -35
- package/lib/emulator/dataconnect/pg-gateway/utils.js +0 -40
- package/templates/setup/web.js +0 -5
- /package/lib/{emulator/dataconnect/pg-gateway/auth/trust.js → dataconnect/cloudAICompanionTypes.js} +0 -0
|
@@ -1,55 +1,91 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const logger_1 = require("../../../logger");
|
|
5
|
-
const apiEnabled = require("../../../ensureApiEnabled");
|
|
6
|
-
const requirePermissions_1 = require("../../../requirePermissions");
|
|
7
|
-
const checkDatabaseType_1 = require("../../../firestore/checkDatabaseType");
|
|
3
|
+
exports.actuate = exports.askQuestions = void 0;
|
|
8
4
|
const rules = require("./rules");
|
|
9
5
|
const indexes = require("./indexes");
|
|
10
6
|
const error_1 = require("../../../error");
|
|
11
|
-
const
|
|
7
|
+
const api_1 = require("../../../firestore/api");
|
|
12
8
|
const prompt_1 = require("../../../prompt");
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
const ensureApiEnabled_1 = require("../../../ensureApiEnabled");
|
|
10
|
+
const api_2 = require("../../../api");
|
|
11
|
+
async function askQuestions(setup, config) {
|
|
12
|
+
const firestore = !Array.isArray(setup.config.firestore) ? setup.config.firestore : undefined;
|
|
13
|
+
const info = {
|
|
14
|
+
databaseId: firestore?.database || "",
|
|
15
|
+
locationId: firestore?.location || "",
|
|
16
|
+
rulesFilename: firestore?.rules || "",
|
|
17
|
+
rules: "",
|
|
18
|
+
writeRules: true,
|
|
19
|
+
indexesFilename: firestore?.indexes || "",
|
|
20
|
+
indexes: "",
|
|
21
|
+
writeIndexes: true,
|
|
22
|
+
};
|
|
23
|
+
if (setup.projectId) {
|
|
24
|
+
await (0, ensureApiEnabled_1.ensure)(setup.projectId, (0, api_2.firestoreOrigin)(), "firestore");
|
|
25
|
+
info.databaseId = info.databaseId || "(default)";
|
|
26
|
+
const api = new api_1.FirestoreApi();
|
|
27
|
+
const databases = await api.listDatabases(setup.projectId);
|
|
28
|
+
const nativeDatabaseNames = databases
|
|
29
|
+
.filter((db) => db.type === "FIRESTORE_NATIVE")
|
|
30
|
+
.map((db) => db.name.split("/")[3]);
|
|
31
|
+
if (nativeDatabaseNames.length === 0) {
|
|
32
|
+
if (databases.length > 0) {
|
|
33
|
+
throw new error_1.FirebaseError(`It looks like this project is using Cloud Firestore in ${databases[0].type}. 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 });
|
|
34
|
+
}
|
|
35
|
+
info.databaseId = "(default)";
|
|
36
|
+
const locations = await api.locations(setup.projectId);
|
|
37
|
+
const choice = await (0, prompt_1.select)({
|
|
38
|
+
message: "Please select the location of your Firestore database:",
|
|
39
|
+
choices: locations.map((location) => location.name.split("/")[3]),
|
|
40
|
+
default: "nam5",
|
|
41
|
+
});
|
|
42
|
+
info.locationId = choice;
|
|
43
|
+
}
|
|
44
|
+
else if (nativeDatabaseNames.length === 1) {
|
|
45
|
+
info.databaseId = nativeDatabaseNames[0];
|
|
46
|
+
info.locationId = databases
|
|
47
|
+
.filter((db) => db.name.endsWith(`databases/${info.databaseId}`))
|
|
48
|
+
.map((db) => db.locationId)[0];
|
|
49
|
+
}
|
|
50
|
+
else if (nativeDatabaseNames.length > 1) {
|
|
51
|
+
const choice = await (0, prompt_1.select)({
|
|
52
|
+
message: "Please select the name of the Native Firestore database you would like to use:",
|
|
53
|
+
choices: nativeDatabaseNames,
|
|
54
|
+
});
|
|
55
|
+
info.databaseId = choice;
|
|
56
|
+
info.locationId = databases
|
|
57
|
+
.filter((db) => db.name.endsWith(`databases/${info.databaseId}`))
|
|
58
|
+
.map((db) => db.locationId)[0];
|
|
59
|
+
}
|
|
26
60
|
}
|
|
27
|
-
await (
|
|
61
|
+
await rules.initRules(setup, config, info);
|
|
62
|
+
await indexes.initIndexes(setup, config, info);
|
|
63
|
+
setup.featureInfo = setup.featureInfo || {};
|
|
64
|
+
setup.featureInfo.firestore = info;
|
|
28
65
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
return await getDatabaseType(setup);
|
|
66
|
+
exports.askQuestions = askQuestions;
|
|
67
|
+
async function actuate(setup, config) {
|
|
68
|
+
const info = setup.featureInfo?.firestore;
|
|
69
|
+
if (!info) {
|
|
70
|
+
throw new error_1.FirebaseError("Firestore featureInfo is not found");
|
|
35
71
|
}
|
|
36
|
-
|
|
37
|
-
|
|
72
|
+
info.databaseId = info.databaseId || "(default)";
|
|
73
|
+
info.locationId = info.locationId || "nam5";
|
|
74
|
+
info.rules = info.rules || rules.getDefaultRules();
|
|
75
|
+
info.rulesFilename = info.rulesFilename || rules.DEFAULT_RULES_FILE;
|
|
76
|
+
info.indexes = info.indexes || indexes.INDEXES_TEMPLATE;
|
|
77
|
+
info.indexesFilename = info.indexesFilename || indexes.DEFAULT_INDEXES_FILE;
|
|
78
|
+
setup.config.firestore = {
|
|
79
|
+
database: info.databaseId,
|
|
80
|
+
location: info.locationId,
|
|
81
|
+
rules: info.rulesFilename,
|
|
82
|
+
indexes: info.indexesFilename,
|
|
83
|
+
};
|
|
84
|
+
if (info.writeRules) {
|
|
85
|
+
config.writeProjectFile(info.rulesFilename, info.rules);
|
|
38
86
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const database = await (0, prompt_1.promptOnce)({
|
|
42
|
-
type: "input",
|
|
43
|
-
message: "Please input the name of the Native Firestore database you would like to use:",
|
|
44
|
-
});
|
|
45
|
-
return database;
|
|
46
|
-
}
|
|
47
|
-
async function doSetup(setup, config, options) {
|
|
48
|
-
if (setup.projectId) {
|
|
49
|
-
await checkProjectSetup(setup, config, options);
|
|
87
|
+
if (info.writeIndexes) {
|
|
88
|
+
config.writeProjectFile(info.indexesFilename, info.indexes);
|
|
50
89
|
}
|
|
51
|
-
setup.config.firestore = {};
|
|
52
|
-
await rules.initRules(setup, config);
|
|
53
|
-
await indexes.initIndexes(setup, config);
|
|
54
90
|
}
|
|
55
|
-
exports.
|
|
91
|
+
exports.actuate = actuate;
|
|
@@ -1,71 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initIndexes = void 0;
|
|
3
|
+
exports.initIndexes = exports.INDEXES_TEMPLATE = exports.DEFAULT_INDEXES_FILE = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const error_1 = require("../../../error");
|
|
6
6
|
const api = require("../../../firestore/api");
|
|
7
|
-
const fsutils = require("../../../fsutils");
|
|
8
7
|
const prompt_1 = require("../../../prompt");
|
|
8
|
+
const utils = require("../../../utils");
|
|
9
9
|
const logger_1 = require("../../../logger");
|
|
10
10
|
const templates_1 = require("../../../templates");
|
|
11
11
|
const indexes = new api.FirestoreApi();
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
exports.DEFAULT_INDEXES_FILE = "firestore.indexes.json";
|
|
13
|
+
exports.INDEXES_TEMPLATE = (0, templates_1.readTemplateSync)("init/firestore/firestore.indexes.json");
|
|
14
|
+
async function initIndexes(setup, config, info) {
|
|
14
15
|
logger_1.logger.info();
|
|
15
16
|
logger_1.logger.info("Firestore indexes allow you to perform complex queries while");
|
|
16
17
|
logger_1.logger.info("maintaining performance that scales with the size of the result");
|
|
17
18
|
logger_1.logger.info("set. You can keep index definitions in your project directory");
|
|
18
19
|
logger_1.logger.info("and publish them with " + clc.bold("firebase deploy") + ".");
|
|
19
20
|
logger_1.logger.info();
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
});
|
|
21
|
+
info.indexesFilename =
|
|
22
|
+
info.indexesFilename ||
|
|
23
|
+
(await (0, prompt_1.input)({
|
|
24
|
+
message: "What file should be used for Firestore indexes?",
|
|
25
|
+
default: exports.DEFAULT_INDEXES_FILE,
|
|
26
|
+
}));
|
|
27
|
+
info.indexes = exports.INDEXES_TEMPLATE;
|
|
28
|
+
if (setup.projectId) {
|
|
29
|
+
const downloadIndexes = await getIndexesFromConsole(setup.projectId, info.databaseId);
|
|
30
|
+
if (downloadIndexes) {
|
|
31
|
+
info.indexes = downloadIndexes;
|
|
32
|
+
utils.logBullet(`Downloaded the existing Firestore indexes from the Firebase console`);
|
|
40
33
|
}
|
|
41
|
-
|
|
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, setup.databaseId).then((contents) => {
|
|
51
|
-
return config.writeProjectFile(setup.config.firestore.indexes, contents);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
34
|
+
}
|
|
35
|
+
info.writeRules = await config.confirmWriteProjectFile(info.indexesFilename, info.indexes);
|
|
54
36
|
}
|
|
55
37
|
exports.initIndexes = initIndexes;
|
|
56
|
-
function getIndexesFromConsole(projectId, databaseId) {
|
|
38
|
+
async function getIndexesFromConsole(projectId, databaseId) {
|
|
57
39
|
const indexesPromise = indexes.listIndexes(projectId, databaseId);
|
|
58
40
|
const fieldOverridesPromise = indexes.listFieldOverrides(projectId, databaseId);
|
|
59
|
-
|
|
60
|
-
.
|
|
61
|
-
return indexes.makeIndexSpec(res[0], res[1]);
|
|
62
|
-
}
|
|
63
|
-
|
|
41
|
+
try {
|
|
42
|
+
const res = await Promise.all([indexesPromise, fieldOverridesPromise]);
|
|
43
|
+
return JSON.stringify(indexes.makeIndexSpec(res[0], res[1]), null, 2);
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
if (e.status === 404) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
64
49
|
if (e.message.indexOf("is not a Cloud Firestore enabled project") >= 0) {
|
|
65
|
-
return
|
|
50
|
+
return null;
|
|
66
51
|
}
|
|
67
52
|
throw new error_1.FirebaseError("Error fetching Firestore indexes", {
|
|
68
53
|
original: e,
|
|
69
54
|
});
|
|
70
|
-
}
|
|
55
|
+
}
|
|
71
56
|
}
|
|
@@ -1,80 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initRules = void 0;
|
|
3
|
+
exports.initRules = exports.getDefaultRules = exports.DEFAULT_RULES_FILE = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const gcp = require("../../../gcp");
|
|
6
|
-
const fsutils = require("../../../fsutils");
|
|
7
6
|
const prompt_1 = require("../../../prompt");
|
|
8
7
|
const logger_1 = require("../../../logger");
|
|
9
8
|
const utils = require("../../../utils");
|
|
10
9
|
const templates_1 = require("../../../templates");
|
|
11
|
-
|
|
10
|
+
exports.DEFAULT_RULES_FILE = "firestore.rules";
|
|
12
11
|
const RULES_TEMPLATE = (0, templates_1.readTemplateSync)("init/firestore/firestore.rules");
|
|
13
|
-
function
|
|
12
|
+
function getDefaultRules() {
|
|
13
|
+
const date = utils.thirtyDaysFromNow();
|
|
14
|
+
const formattedForRules = `${date.getFullYear()}, ${date.getMonth() + 1}, ${date.getDate()}`;
|
|
15
|
+
return RULES_TEMPLATE.replace(/{{IN_30_DAYS}}/g, formattedForRules);
|
|
16
|
+
}
|
|
17
|
+
exports.getDefaultRules = getDefaultRules;
|
|
18
|
+
async function initRules(setup, config, info) {
|
|
14
19
|
logger_1.logger.info();
|
|
15
20
|
logger_1.logger.info("Firestore Security Rules allow you to define how and when to allow");
|
|
16
21
|
logger_1.logger.info("requests. You can keep these rules in your project directory");
|
|
17
22
|
logger_1.logger.info("and publish them with " + clc.bold("firebase deploy") + ".");
|
|
18
23
|
logger_1.logger.info();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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();
|
|
24
|
+
info.rulesFilename =
|
|
25
|
+
info.rulesFilename ||
|
|
26
|
+
(await (0, prompt_1.input)({
|
|
27
|
+
message: "What file should be used for Firestore Rules?",
|
|
28
|
+
default: exports.DEFAULT_RULES_FILE,
|
|
29
|
+
}));
|
|
30
|
+
info.rules = getDefaultRules();
|
|
31
|
+
if (setup.projectId) {
|
|
32
|
+
const downloadedRules = await getRulesFromConsole(setup.projectId);
|
|
33
|
+
if (downloadedRules) {
|
|
34
|
+
info.rules = downloadedRules;
|
|
35
|
+
utils.logBullet(`Downloaded the existing Firestore Security Rules from the Firebase console`);
|
|
45
36
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
return getRulesFromConsole(setup.projectId).then((contents) => {
|
|
50
|
-
return config.writeProjectFile(setup.config.firestore.rules, contents);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
37
|
+
}
|
|
38
|
+
info.writeRules = await config.confirmWriteProjectFile(info.rulesFilename, info.rules);
|
|
53
39
|
}
|
|
54
40
|
exports.initRules = initRules;
|
|
55
|
-
function
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
});
|
|
41
|
+
async function getRulesFromConsole(projectId) {
|
|
42
|
+
const name = await gcp.rules.getLatestRulesetName(projectId, "cloud.firestore");
|
|
43
|
+
if (!name) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const rules = await gcp.rules.getRulesetContent(name);
|
|
47
|
+
if (rules.length <= 0) {
|
|
48
|
+
return utils.reject("Ruleset has no files", { exit: 1 });
|
|
49
|
+
}
|
|
50
|
+
if (rules.length > 1) {
|
|
51
|
+
return utils.reject("Ruleset has too many files: " + rules.length, { exit: 1 });
|
|
52
|
+
}
|
|
53
|
+
return rules[0].content;
|
|
80
54
|
}
|
|
@@ -9,6 +9,7 @@ const ensureApiEnabled_1 = require("../../../ensureApiEnabled");
|
|
|
9
9
|
const projectConfig_1 = require("../../../functions/projectConfig");
|
|
10
10
|
const error_1 = require("../../../error");
|
|
11
11
|
const api_1 = require("../../../api");
|
|
12
|
+
const supported = require("../../../deploy/functions/runtimes/supported");
|
|
12
13
|
const MAX_ATTEMPTS = 5;
|
|
13
14
|
async function doSetup(setup, config, options) {
|
|
14
15
|
const projectId = setup?.rcfile?.projects?.default;
|
|
@@ -37,8 +38,7 @@ async function doSetup(setup, config, options) {
|
|
|
37
38
|
value: "overwrite",
|
|
38
39
|
},
|
|
39
40
|
];
|
|
40
|
-
const initOpt = await (0, prompt_1.
|
|
41
|
-
type: "list",
|
|
41
|
+
const initOpt = await (0, prompt_1.select)({
|
|
42
42
|
message: "Would you like to initialize a new codebase, or overwrite an existing one?",
|
|
43
43
|
default: "new",
|
|
44
44
|
choices,
|
|
@@ -65,10 +65,7 @@ async function initNewCodebase(setup, config) {
|
|
|
65
65
|
if (attempts++ >= MAX_ATTEMPTS) {
|
|
66
66
|
throw new error_1.FirebaseError("Exceeded max number of attempts to input valid codebase name. Please restart.");
|
|
67
67
|
}
|
|
68
|
-
codebase = await (0, prompt_1.
|
|
69
|
-
type: "input",
|
|
70
|
-
message: "What should be the name of this codebase?",
|
|
71
|
-
});
|
|
68
|
+
codebase = await (0, prompt_1.input)("What should be the name of this codebase?");
|
|
72
69
|
try {
|
|
73
70
|
(0, projectConfig_1.validateCodebase)(codebase);
|
|
74
71
|
(0, projectConfig_1.assertUnique)(setup.config.functions, "codebase", codebase);
|
|
@@ -84,8 +81,7 @@ async function initNewCodebase(setup, config) {
|
|
|
84
81
|
throw new error_1.FirebaseError("Exceeded max number of attempts to input valid source. Please restart.");
|
|
85
82
|
}
|
|
86
83
|
attempts++;
|
|
87
|
-
source = await (0, prompt_1.
|
|
88
|
-
type: "input",
|
|
84
|
+
source = await (0, prompt_1.input)({
|
|
89
85
|
message: `In what sub-directory would you like to initialize your functions for codebase ${clc.bold(codebase)}?`,
|
|
90
86
|
default: codebase,
|
|
91
87
|
});
|
|
@@ -113,8 +109,7 @@ async function overwriteCodebase(setup, config) {
|
|
|
113
109
|
name: cfg["codebase"],
|
|
114
110
|
value: cfg["codebase"],
|
|
115
111
|
}));
|
|
116
|
-
codebase = await (0, prompt_1.
|
|
117
|
-
type: "list",
|
|
112
|
+
codebase = await (0, prompt_1.select)({
|
|
118
113
|
message: "Which codebase would you like to overwrite?",
|
|
119
114
|
choices,
|
|
120
115
|
});
|
|
@@ -141,13 +136,12 @@ async function languageSetup(setup, config) {
|
|
|
141
136
|
name: "TypeScript",
|
|
142
137
|
value: "typescript",
|
|
143
138
|
},
|
|
139
|
+
{
|
|
140
|
+
name: "Python",
|
|
141
|
+
value: "python",
|
|
142
|
+
},
|
|
144
143
|
];
|
|
145
|
-
|
|
146
|
-
name: "Python",
|
|
147
|
-
value: "python",
|
|
148
|
-
});
|
|
149
|
-
const language = await (0, prompt_1.promptOnce)({
|
|
150
|
-
type: "list",
|
|
144
|
+
const language = await (0, prompt_1.select)({
|
|
151
145
|
message: "What language would you like to use to write Cloud Functions?",
|
|
152
146
|
default: "javascript",
|
|
153
147
|
choices,
|
|
@@ -174,6 +168,7 @@ async function languageSetup(setup, config) {
|
|
|
174
168
|
break;
|
|
175
169
|
case "python":
|
|
176
170
|
cbconfig.ignore = ["venv", ".git", "firebase-debug.log", "firebase-debug.*.log", "*.local"];
|
|
171
|
+
cbconfig.runtime = supported.latest("python");
|
|
177
172
|
break;
|
|
178
173
|
}
|
|
179
174
|
setup.functions.languageChoice = language;
|
|
@@ -5,40 +5,27 @@ const npm_dependencies_1 = require("./npm-dependencies");
|
|
|
5
5
|
const prompt_1 = require("../../../prompt");
|
|
6
6
|
const projectConfig_1 = require("../../../functions/projectConfig");
|
|
7
7
|
const templates_1 = require("../../../templates");
|
|
8
|
+
const supported = require("../../../deploy/functions/runtimes/supported");
|
|
8
9
|
const INDEX_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/javascript/index.js");
|
|
9
10
|
const PACKAGE_LINTING_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/javascript/package.lint.json");
|
|
10
11
|
const PACKAGE_NO_LINTING_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/javascript/package.nolint.json");
|
|
11
12
|
const ESLINT_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/javascript/_eslintrc");
|
|
12
13
|
const GITIGNORE_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/javascript/_gitignore");
|
|
13
|
-
function setup(setup, config) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
config.askWriteProjectFile(`${setup.functions.source}/.eslintrc.js`, ESLINT_TEMPLATE);
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
return config.askWriteProjectFile(`${setup.functions.source}/package.json`, PACKAGE_NO_LINTING_TEMPLATE);
|
|
33
|
-
})
|
|
34
|
-
.then(() => {
|
|
35
|
-
return config.askWriteProjectFile(`${setup.functions.source}/index.js`, INDEX_TEMPLATE);
|
|
36
|
-
})
|
|
37
|
-
.then(() => {
|
|
38
|
-
return config.askWriteProjectFile(`${setup.functions.source}/.gitignore`, GITIGNORE_TEMPLATE);
|
|
39
|
-
})
|
|
40
|
-
.then(() => {
|
|
41
|
-
return (0, npm_dependencies_1.askInstallDependencies)(setup.functions, config);
|
|
42
|
-
});
|
|
14
|
+
async function setup(setup, config) {
|
|
15
|
+
setup.functions.lint =
|
|
16
|
+
setup.functions.lint ||
|
|
17
|
+
(await (0, prompt_1.confirm)("Do you want to use ESLint to catch probable bugs and enforce style?"));
|
|
18
|
+
if (setup.functions.lint) {
|
|
19
|
+
const cbconfig = (0, projectConfig_1.configForCodebase)(setup.config.functions, setup.functions.codebase);
|
|
20
|
+
cbconfig.predeploy = ['npm --prefix "$RESOURCE_DIR" run lint'];
|
|
21
|
+
await config.askWriteProjectFile(`${setup.functions.source}/package.json`, PACKAGE_LINTING_TEMPLATE.replace("{{RUNTIME}}", supported.latest("nodejs").replace("nodejs", "")));
|
|
22
|
+
await config.askWriteProjectFile(`${setup.functions.source}/.eslintrc.js`, ESLINT_TEMPLATE);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
await config.askWriteProjectFile(`${setup.functions.source}/package.json`, PACKAGE_NO_LINTING_TEMPLATE.replace("{{RUNTIME}}", supported.latest("nodejs").replace("nodejs", "")));
|
|
26
|
+
}
|
|
27
|
+
await config.askWriteProjectFile(`${setup.functions.source}/index.js`, INDEX_TEMPLATE);
|
|
28
|
+
await config.askWriteProjectFile(`${setup.functions.source}/.gitignore`, GITIGNORE_TEMPLATE);
|
|
29
|
+
await (0, npm_dependencies_1.askInstallDependencies)(setup.functions, config);
|
|
43
30
|
}
|
|
44
31
|
exports.setup = setup;
|
|
@@ -5,14 +5,10 @@ const logger_1 = require("../../../logger");
|
|
|
5
5
|
const prompt_1 = require("../../../prompt");
|
|
6
6
|
const spawn_1 = require("../../spawn");
|
|
7
7
|
async function askInstallDependencies(setup, config) {
|
|
8
|
-
await (0, prompt_1.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
message: "Do you want to install dependencies with npm now?",
|
|
13
|
-
default: true,
|
|
14
|
-
},
|
|
15
|
-
]);
|
|
8
|
+
setup.npm = await (0, prompt_1.confirm)({
|
|
9
|
+
message: "Do you want to install dependencies with npm now?",
|
|
10
|
+
default: true,
|
|
11
|
+
});
|
|
16
12
|
if (setup.npm) {
|
|
17
13
|
try {
|
|
18
14
|
await (0, spawn_1.wrapSpawn)("npm", ["install"], config.projectDir + `/${setup.source}`);
|
|
@@ -25,9 +25,7 @@ async function setup(setup, config) {
|
|
|
25
25
|
venvProcess.on("exit", resolve);
|
|
26
26
|
venvProcess.on("error", reject);
|
|
27
27
|
});
|
|
28
|
-
const install = await (0, prompt_1.
|
|
29
|
-
name: "install",
|
|
30
|
-
type: "confirm",
|
|
28
|
+
const install = await (0, prompt_1.confirm)({
|
|
31
29
|
message: "Do you want to install dependencies now?",
|
|
32
30
|
default: true,
|
|
33
31
|
});
|
|
@@ -5,6 +5,7 @@ const npm_dependencies_1 = require("./npm-dependencies");
|
|
|
5
5
|
const prompt_1 = require("../../../prompt");
|
|
6
6
|
const projectConfig_1 = require("../../../functions/projectConfig");
|
|
7
7
|
const templates_1 = require("../../../templates");
|
|
8
|
+
const supported = require("../../../deploy/functions/runtimes/supported");
|
|
8
9
|
const PACKAGE_LINTING_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/package.lint.json");
|
|
9
10
|
const PACKAGE_NO_LINTING_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/package.nolint.json");
|
|
10
11
|
const ESLINT_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/_eslintrc");
|
|
@@ -12,48 +13,29 @@ const TSCONFIG_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/type
|
|
|
12
13
|
const TSCONFIG_DEV_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/tsconfig.dev.json");
|
|
13
14
|
const INDEX_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/index.ts");
|
|
14
15
|
const GITIGNORE_TEMPLATE = (0, templates_1.readTemplateSync)("init/functions/typescript/_gitignore");
|
|
15
|
-
function setup(setup, config) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
]
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
cbconfig.predeploy
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return config.askWriteProjectFile(`${setup.functions.source}/package.json`, PACKAGE_NO_LINTING_TEMPLATE);
|
|
40
|
-
})
|
|
41
|
-
.then(() => {
|
|
42
|
-
return config.askWriteProjectFile(`${setup.functions.source}/tsconfig.json`, TSCONFIG_TEMPLATE);
|
|
43
|
-
})
|
|
44
|
-
.then(() => {
|
|
45
|
-
if (setup.functions.lint) {
|
|
46
|
-
return config.askWriteProjectFile(`${setup.functions.source}/tsconfig.dev.json`, TSCONFIG_DEV_TEMPLATE);
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
.then(() => {
|
|
50
|
-
return config.askWriteProjectFile(`${setup.functions.source}/src/index.ts`, INDEX_TEMPLATE);
|
|
51
|
-
})
|
|
52
|
-
.then(() => {
|
|
53
|
-
return config.askWriteProjectFile(`${setup.functions.source}/.gitignore`, GITIGNORE_TEMPLATE);
|
|
54
|
-
})
|
|
55
|
-
.then(() => {
|
|
56
|
-
return (0, npm_dependencies_1.askInstallDependencies)(setup.functions, config);
|
|
57
|
-
});
|
|
16
|
+
async function setup(setup, config) {
|
|
17
|
+
setup.functions.lint =
|
|
18
|
+
setup.functions.lint ||
|
|
19
|
+
(await (0, prompt_1.confirm)({
|
|
20
|
+
message: "Do you want to use ESLint to catch probable bugs and enforce style?",
|
|
21
|
+
default: true,
|
|
22
|
+
}));
|
|
23
|
+
const cbconfig = (0, projectConfig_1.configForCodebase)(setup.config.functions, setup.functions.codebase);
|
|
24
|
+
cbconfig.predeploy = [];
|
|
25
|
+
if (setup.functions.lint) {
|
|
26
|
+
cbconfig.predeploy.push('npm --prefix "$RESOURCE_DIR" run lint');
|
|
27
|
+
cbconfig.predeploy.push('npm --prefix "$RESOURCE_DIR" run build');
|
|
28
|
+
await config.askWriteProjectFile(`${setup.functions.source}/package.json`, PACKAGE_LINTING_TEMPLATE.replace("{{RUNTIME}}", supported.latest("nodejs").replace("nodejs", "")));
|
|
29
|
+
await config.askWriteProjectFile(`${setup.functions.source}/.eslintrc.js`, ESLINT_TEMPLATE);
|
|
30
|
+
await config.askWriteProjectFile(`${setup.functions.source}/tsconfig.dev.json`, TSCONFIG_DEV_TEMPLATE);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
cbconfig.predeploy.push('npm --prefix "$RESOURCE_DIR" run build');
|
|
34
|
+
await config.askWriteProjectFile(`${setup.functions.source}/package.json`, PACKAGE_NO_LINTING_TEMPLATE.replace("{{RUNTIME}}", supported.latest("nodejs").replace("nodejs", "")));
|
|
35
|
+
}
|
|
36
|
+
await config.askWriteProjectFile(`${setup.functions.source}/tsconfig.json`, TSCONFIG_TEMPLATE);
|
|
37
|
+
await config.askWriteProjectFile(`${setup.functions.source}/src/index.ts`, INDEX_TEMPLATE);
|
|
38
|
+
await config.askWriteProjectFile(`${setup.functions.source}/.gitignore`, GITIGNORE_TEMPLATE);
|
|
39
|
+
await (0, npm_dependencies_1.askInstallDependencies)(setup.functions, config);
|
|
58
40
|
}
|
|
59
41
|
exports.setup = setup;
|