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,403 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDevModeHandle = exports.ɵcodegenFunctionsDirectory = exports.ɵcodegenPublicDirectory = exports.init = exports.build = exports.discover = exports.docsUrl = exports.type = exports.support = exports.name = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const cross_spawn_1 = require("cross-spawn");
|
|
6
|
+
const promises_1 = require("fs/promises");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const fs_extra_1 = require("fs-extra");
|
|
9
|
+
const url_1 = require("url");
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
const semver_1 = require("semver");
|
|
12
|
+
const clc = require("colorette");
|
|
13
|
+
const stream_chain_1 = require("stream-chain");
|
|
14
|
+
const stream_json_1 = require("stream-json");
|
|
15
|
+
const Pick_1 = require("stream-json/filters/Pick");
|
|
16
|
+
const StreamObject_1 = require("stream-json/streamers/StreamObject");
|
|
17
|
+
const fsutils_1 = require("../../fsutils");
|
|
18
|
+
const prompt_1 = require("../../prompt");
|
|
19
|
+
const error_1 = require("../../error");
|
|
20
|
+
const utils_1 = require("../utils");
|
|
21
|
+
const utils_2 = require("./utils");
|
|
22
|
+
const constants_1 = require("../constants");
|
|
23
|
+
const constants_2 = require("./constants");
|
|
24
|
+
const api_1 = require("../../hosting/api");
|
|
25
|
+
const logger_1 = require("../../logger");
|
|
26
|
+
const DEFAULT_BUILD_SCRIPT = ["next build"];
|
|
27
|
+
const PUBLIC_DIR = "public";
|
|
28
|
+
exports.name = "Next.js";
|
|
29
|
+
exports.support = "preview";
|
|
30
|
+
exports.type = 2;
|
|
31
|
+
exports.docsUrl = "https://firebase.google.com/docs/hosting/frameworks/nextjs";
|
|
32
|
+
const BUNDLE_NEXT_CONFIG_TIMEOUT = 60000;
|
|
33
|
+
const DEFAULT_NUMBER_OF_REASONS_TO_LIST = 5;
|
|
34
|
+
function getReactVersion(cwd) {
|
|
35
|
+
var _a;
|
|
36
|
+
return (_a = (0, utils_1.findDependency)("react-dom", { cwd, omitDev: false })) === null || _a === void 0 ? void 0 : _a.version;
|
|
37
|
+
}
|
|
38
|
+
async function discover(dir) {
|
|
39
|
+
if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "package.json"))))
|
|
40
|
+
return;
|
|
41
|
+
if (!(await (0, fs_extra_1.pathExists)("next.config.js")) && !(0, utils_2.getNextVersion)(dir))
|
|
42
|
+
return;
|
|
43
|
+
return { mayWantBackend: true, publicDirectory: (0, path_1.join)(dir, PUBLIC_DIR) };
|
|
44
|
+
}
|
|
45
|
+
exports.discover = discover;
|
|
46
|
+
async function build(dir) {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
await (0, utils_1.warnIfCustomBuildScript)(dir, exports.name, DEFAULT_BUILD_SCRIPT);
|
|
49
|
+
const reactVersion = getReactVersion(dir);
|
|
50
|
+
if (reactVersion && (0, semver_1.gte)(reactVersion, "18.0.0")) {
|
|
51
|
+
process.env.__NEXT_REACT_ROOT = "true";
|
|
52
|
+
}
|
|
53
|
+
const cli = (0, utils_1.getNodeModuleBin)("next", dir);
|
|
54
|
+
const nextBuild = new Promise((resolve, reject) => {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
const buildProcess = (0, cross_spawn_1.spawn)(cli, ["build"], { cwd: dir });
|
|
57
|
+
(_a = buildProcess.stdout) === null || _a === void 0 ? void 0 : _a.on("data", (data) => logger_1.logger.info(data.toString()));
|
|
58
|
+
(_b = buildProcess.stderr) === null || _b === void 0 ? void 0 : _b.on("data", (data) => logger_1.logger.info(data.toString()));
|
|
59
|
+
buildProcess.on("error", (err) => {
|
|
60
|
+
reject(new error_1.FirebaseError(`Unable to build your Next.js app: ${err}`));
|
|
61
|
+
});
|
|
62
|
+
buildProcess.on("exit", (code) => {
|
|
63
|
+
resolve(code);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
await nextBuild;
|
|
67
|
+
const reasonsForBackend = new Set();
|
|
68
|
+
const { distDir, trailingSlash, basePath: baseUrl } = await getConfig(dir);
|
|
69
|
+
if (await (0, utils_2.isUsingMiddleware)((0, path_1.join)(dir, distDir), false)) {
|
|
70
|
+
reasonsForBackend.add("middleware");
|
|
71
|
+
}
|
|
72
|
+
if (await (0, utils_2.isUsingImageOptimization)(dir, distDir)) {
|
|
73
|
+
reasonsForBackend.add(`Image Optimization`);
|
|
74
|
+
}
|
|
75
|
+
const prerenderManifest = await (0, utils_1.readJSON)((0, path_1.join)(dir, distDir, constants_2.PRERENDER_MANIFEST));
|
|
76
|
+
const dynamicRoutesWithFallback = Object.entries(prerenderManifest.dynamicRoutes || {}).filter(([, it]) => it.fallback !== false);
|
|
77
|
+
if (dynamicRoutesWithFallback.length > 0) {
|
|
78
|
+
for (const [key] of dynamicRoutesWithFallback) {
|
|
79
|
+
reasonsForBackend.add(`use of fallback ${key}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const routesWithRevalidate = Object.entries(prerenderManifest.routes).filter(([, it]) => it.initialRevalidateSeconds);
|
|
83
|
+
if (routesWithRevalidate.length > 0) {
|
|
84
|
+
for (const [, { srcRoute }] of routesWithRevalidate) {
|
|
85
|
+
reasonsForBackend.add(`use of revalidate ${srcRoute}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const pagesManifestJSON = await (0, utils_1.readJSON)((0, path_1.join)(dir, distDir, "server", constants_2.PAGES_MANIFEST));
|
|
89
|
+
const prerenderedRoutes = Object.keys(prerenderManifest.routes);
|
|
90
|
+
const dynamicRoutes = Object.keys(prerenderManifest.dynamicRoutes);
|
|
91
|
+
const unrenderedPages = (0, utils_2.getNonStaticRoutes)(pagesManifestJSON, prerenderedRoutes, dynamicRoutes);
|
|
92
|
+
for (const key of unrenderedPages) {
|
|
93
|
+
reasonsForBackend.add(`non-static route ${key}`);
|
|
94
|
+
}
|
|
95
|
+
const manifest = await (0, utils_1.readJSON)((0, path_1.join)(dir, distDir, constants_2.ROUTES_MANIFEST));
|
|
96
|
+
const { headers: nextJsHeaders = [], redirects: nextJsRedirects = [], rewrites: nextJsRewrites = [], i18n: nextjsI18n, } = manifest;
|
|
97
|
+
const isEveryHeaderSupported = nextJsHeaders.map(utils_2.cleanI18n).every(utils_2.isHeaderSupportedByHosting);
|
|
98
|
+
if (!isEveryHeaderSupported) {
|
|
99
|
+
reasonsForBackend.add("advanced headers");
|
|
100
|
+
}
|
|
101
|
+
const headers = nextJsHeaders
|
|
102
|
+
.map(utils_2.cleanI18n)
|
|
103
|
+
.filter(utils_2.isHeaderSupportedByHosting)
|
|
104
|
+
.map(({ source, headers }) => ({
|
|
105
|
+
source: (0, utils_2.cleanEscapedChars)(source),
|
|
106
|
+
headers,
|
|
107
|
+
}));
|
|
108
|
+
const [appPathsManifest, appPathRoutesManifest] = await Promise.all([
|
|
109
|
+
(0, utils_1.readJSON)((0, path_1.join)(dir, distDir, "server", constants_2.APP_PATHS_MANIFEST)).catch(() => undefined),
|
|
110
|
+
(0, utils_1.readJSON)((0, path_1.join)(dir, distDir, constants_2.APP_PATH_ROUTES_MANIFEST)).catch(() => undefined),
|
|
111
|
+
]);
|
|
112
|
+
if (appPathRoutesManifest) {
|
|
113
|
+
const headersFromMetaFiles = await (0, utils_2.getHeadersFromMetaFiles)(dir, distDir, baseUrl, appPathRoutesManifest);
|
|
114
|
+
headers.push(...headersFromMetaFiles);
|
|
115
|
+
if (appPathsManifest) {
|
|
116
|
+
const unrenderedServerComponents = (0, utils_2.getNonStaticServerComponents)(appPathsManifest, appPathRoutesManifest, prerenderedRoutes, dynamicRoutes);
|
|
117
|
+
for (const key of unrenderedServerComponents) {
|
|
118
|
+
reasonsForBackend.add(`non-static component ${key}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const isEveryRedirectSupported = nextJsRedirects
|
|
123
|
+
.filter((it) => !it.internal)
|
|
124
|
+
.every(utils_2.isRedirectSupportedByHosting);
|
|
125
|
+
if (!isEveryRedirectSupported) {
|
|
126
|
+
reasonsForBackend.add("advanced redirects");
|
|
127
|
+
}
|
|
128
|
+
const redirects = nextJsRedirects
|
|
129
|
+
.map(utils_2.cleanI18n)
|
|
130
|
+
.filter(utils_2.isRedirectSupportedByHosting)
|
|
131
|
+
.map(({ source, destination, statusCode: type }) => ({
|
|
132
|
+
source: (0, utils_2.cleanEscapedChars)(source),
|
|
133
|
+
destination,
|
|
134
|
+
type,
|
|
135
|
+
}));
|
|
136
|
+
const nextJsRewritesToUse = (0, utils_2.getNextjsRewritesToUse)(nextJsRewrites);
|
|
137
|
+
if (!Array.isArray(nextJsRewrites) &&
|
|
138
|
+
(((_a = nextJsRewrites.afterFiles) === null || _a === void 0 ? void 0 : _a.length) || ((_b = nextJsRewrites.fallback) === null || _b === void 0 ? void 0 : _b.length))) {
|
|
139
|
+
reasonsForBackend.add("advanced rewrites");
|
|
140
|
+
}
|
|
141
|
+
const isEveryRewriteSupported = nextJsRewritesToUse.every(utils_2.isRewriteSupportedByHosting);
|
|
142
|
+
if (!isEveryRewriteSupported) {
|
|
143
|
+
reasonsForBackend.add("advanced rewrites");
|
|
144
|
+
}
|
|
145
|
+
const rewrites = nextJsRewritesToUse
|
|
146
|
+
.filter(utils_2.isRewriteSupportedByHosting)
|
|
147
|
+
.map(utils_2.cleanI18n)
|
|
148
|
+
.map(({ source, destination }) => ({
|
|
149
|
+
source: (0, utils_2.cleanEscapedChars)(source),
|
|
150
|
+
destination,
|
|
151
|
+
}));
|
|
152
|
+
const wantsBackend = reasonsForBackend.size > 0;
|
|
153
|
+
if (wantsBackend) {
|
|
154
|
+
logger_1.logger.info("Building a Cloud Function to run this application. This is needed due to:");
|
|
155
|
+
for (const reason of Array.from(reasonsForBackend).slice(0, DEFAULT_NUMBER_OF_REASONS_TO_LIST)) {
|
|
156
|
+
logger_1.logger.info(` • ${reason}`);
|
|
157
|
+
}
|
|
158
|
+
for (const reason of Array.from(reasonsForBackend).slice(DEFAULT_NUMBER_OF_REASONS_TO_LIST)) {
|
|
159
|
+
logger_1.logger.debug(` • ${reason}`);
|
|
160
|
+
}
|
|
161
|
+
if (reasonsForBackend.size > DEFAULT_NUMBER_OF_REASONS_TO_LIST && !process.env.DEBUG) {
|
|
162
|
+
logger_1.logger.info(` • and ${reasonsForBackend.size - DEFAULT_NUMBER_OF_REASONS_TO_LIST} other reasons, use --debug to see more`);
|
|
163
|
+
}
|
|
164
|
+
logger_1.logger.info("");
|
|
165
|
+
}
|
|
166
|
+
const i18n = !!nextjsI18n;
|
|
167
|
+
return {
|
|
168
|
+
wantsBackend,
|
|
169
|
+
headers,
|
|
170
|
+
redirects,
|
|
171
|
+
rewrites,
|
|
172
|
+
trailingSlash,
|
|
173
|
+
i18n,
|
|
174
|
+
baseUrl,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
exports.build = build;
|
|
178
|
+
async function init(setup, config) {
|
|
179
|
+
const language = await (0, prompt_1.promptOnce)({
|
|
180
|
+
type: "list",
|
|
181
|
+
default: "TypeScript",
|
|
182
|
+
message: "What language would you like to use?",
|
|
183
|
+
choices: ["JavaScript", "TypeScript"],
|
|
184
|
+
});
|
|
185
|
+
(0, child_process_1.execSync)(`npx --yes create-next-app@latest -e hello-world ${setup.hosting.source} --use-npm ${language === "TypeScript" ? "--ts" : "--js"}`, { stdio: "inherit", cwd: config.projectDir });
|
|
186
|
+
}
|
|
187
|
+
exports.init = init;
|
|
188
|
+
async function ɵcodegenPublicDirectory(sourceDir, destDir, _, context) {
|
|
189
|
+
const { distDir, i18n, basePath } = await getConfig(sourceDir);
|
|
190
|
+
let matchingI18nDomain = undefined;
|
|
191
|
+
if (i18n === null || i18n === void 0 ? void 0 : i18n.domains) {
|
|
192
|
+
const siteDomains = await (0, api_1.getAllSiteDomains)(context.project, context.site);
|
|
193
|
+
matchingI18nDomain = i18n.domains.find(({ domain }) => siteDomains.includes(domain));
|
|
194
|
+
}
|
|
195
|
+
const singleLocaleDomain = !i18n || ((matchingI18nDomain || i18n).locales || []).length <= 1;
|
|
196
|
+
const publicPath = (0, path_1.join)(sourceDir, "public");
|
|
197
|
+
await (0, promises_1.mkdir)((0, path_1.join)(destDir, basePath, "_next", "static"), { recursive: true });
|
|
198
|
+
if (await (0, fs_extra_1.pathExists)(publicPath)) {
|
|
199
|
+
await (0, fs_extra_1.copy)(publicPath, (0, path_1.join)(destDir, basePath));
|
|
200
|
+
}
|
|
201
|
+
await (0, fs_extra_1.copy)((0, path_1.join)(sourceDir, distDir, "static"), (0, path_1.join)(destDir, basePath, "_next", "static"));
|
|
202
|
+
const [middlewareManifest, prerenderManifest, routesManifest, pagesManifest, appPathRoutesManifest,] = await Promise.all([
|
|
203
|
+
(0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, "server", constants_2.MIDDLEWARE_MANIFEST)),
|
|
204
|
+
(0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, constants_2.PRERENDER_MANIFEST)),
|
|
205
|
+
(0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, constants_2.ROUTES_MANIFEST)),
|
|
206
|
+
(0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, "server", constants_2.PAGES_MANIFEST)),
|
|
207
|
+
(0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, constants_2.APP_PATH_ROUTES_MANIFEST)).catch(() => ({})),
|
|
208
|
+
]);
|
|
209
|
+
const appPathRoutesEntries = Object.entries(appPathRoutesManifest);
|
|
210
|
+
const middlewareMatcherRegexes = (0, utils_2.getMiddlewareMatcherRegexes)(middlewareManifest);
|
|
211
|
+
const { redirects = [], rewrites = [], headers = [] } = routesManifest;
|
|
212
|
+
const rewritesRegexesNotSupportedByHosting = (0, utils_2.getNextjsRewritesToUse)(rewrites)
|
|
213
|
+
.filter((rewrite) => !(0, utils_2.isRewriteSupportedByHosting)(rewrite))
|
|
214
|
+
.map(utils_2.cleanI18n)
|
|
215
|
+
.map((rewrite) => new RegExp(rewrite.regex));
|
|
216
|
+
const redirectsRegexesNotSupportedByHosting = redirects
|
|
217
|
+
.filter((it) => !it.internal)
|
|
218
|
+
.filter((redirect) => !(0, utils_2.isRedirectSupportedByHosting)(redirect))
|
|
219
|
+
.map(utils_2.cleanI18n)
|
|
220
|
+
.map((redirect) => new RegExp(redirect.regex));
|
|
221
|
+
const headersRegexesNotSupportedByHosting = headers
|
|
222
|
+
.filter((header) => !(0, utils_2.isHeaderSupportedByHosting)(header))
|
|
223
|
+
.map((header) => new RegExp(header.regex));
|
|
224
|
+
const pathsUsingsFeaturesNotSupportedByHosting = [
|
|
225
|
+
...middlewareMatcherRegexes,
|
|
226
|
+
...rewritesRegexesNotSupportedByHosting,
|
|
227
|
+
...redirectsRegexesNotSupportedByHosting,
|
|
228
|
+
...headersRegexesNotSupportedByHosting,
|
|
229
|
+
];
|
|
230
|
+
const pagesManifestLikePrerender = Object.fromEntries(Object.entries(pagesManifest)
|
|
231
|
+
.filter(([, srcRoute]) => srcRoute.endsWith(".html"))
|
|
232
|
+
.map(([path]) => {
|
|
233
|
+
return [path, { srcRoute: null, initialRevalidateSeconds: false, dataRoute: "" }];
|
|
234
|
+
}));
|
|
235
|
+
const routesToCopy = Object.assign(Object.assign({}, prerenderManifest.routes), pagesManifestLikePrerender);
|
|
236
|
+
await Promise.all(Object.entries(routesToCopy).map(async ([path, route]) => {
|
|
237
|
+
var _a, _b;
|
|
238
|
+
if (route.initialRevalidateSeconds) {
|
|
239
|
+
logger_1.logger.debug(`skipping ${path} due to revalidate`);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (pathsUsingsFeaturesNotSupportedByHosting.some((it) => path.match(it))) {
|
|
243
|
+
logger_1.logger.debug(`skipping ${path} due to it matching an unsupported rewrite/redirect/header or middlware`);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const appPathRoute = route.srcRoute && ((_a = appPathRoutesEntries.find(([, it]) => it === route.srcRoute)) === null || _a === void 0 ? void 0 : _a[0]);
|
|
247
|
+
const contentDist = (0, path_1.join)(sourceDir, distDir, "server", appPathRoute ? "app" : "pages");
|
|
248
|
+
const sourceParts = path.split("/").filter((it) => !!it);
|
|
249
|
+
const locale = (i18n === null || i18n === void 0 ? void 0 : i18n.locales.includes(sourceParts[0])) ? sourceParts[0] : undefined;
|
|
250
|
+
const includeOnThisDomain = !locale ||
|
|
251
|
+
!matchingI18nDomain ||
|
|
252
|
+
matchingI18nDomain.defaultLocale === locale ||
|
|
253
|
+
!matchingI18nDomain.locales ||
|
|
254
|
+
matchingI18nDomain.locales.includes(locale);
|
|
255
|
+
if (!includeOnThisDomain) {
|
|
256
|
+
logger_1.logger.debug(`skipping ${path} since it is for a locale not deployed on this domain`);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const sourcePartsOrIndex = sourceParts.length > 0 ? sourceParts : ["index"];
|
|
260
|
+
const destParts = sourceParts.slice(locale ? 1 : 0);
|
|
261
|
+
const destPartsOrIndex = destParts.length > 0 ? destParts : ["index"];
|
|
262
|
+
const isDefaultLocale = !locale || ((_b = (matchingI18nDomain || i18n)) === null || _b === void 0 ? void 0 : _b.defaultLocale) === locale;
|
|
263
|
+
let sourcePath = (0, path_1.join)(contentDist, ...sourcePartsOrIndex);
|
|
264
|
+
let localizedDestPath = !singleLocaleDomain &&
|
|
265
|
+
locale &&
|
|
266
|
+
(0, path_1.join)(destDir, constants_1.I18N_ROOT, locale, basePath, ...destPartsOrIndex);
|
|
267
|
+
let defaultDestPath = isDefaultLocale && (0, path_1.join)(destDir, basePath, ...destPartsOrIndex);
|
|
268
|
+
if (!(0, fsutils_1.fileExistsSync)(sourcePath) && (0, fsutils_1.fileExistsSync)(`${sourcePath}.html`)) {
|
|
269
|
+
sourcePath += ".html";
|
|
270
|
+
if (localizedDestPath)
|
|
271
|
+
localizedDestPath += ".html";
|
|
272
|
+
if (defaultDestPath)
|
|
273
|
+
defaultDestPath += ".html";
|
|
274
|
+
}
|
|
275
|
+
else if (appPathRoute &&
|
|
276
|
+
(0, path_1.basename)(appPathRoute) === "route" &&
|
|
277
|
+
(0, fsutils_1.fileExistsSync)(`${sourcePath}.body`)) {
|
|
278
|
+
sourcePath += ".body";
|
|
279
|
+
}
|
|
280
|
+
else if (!(0, fs_extra_1.pathExistsSync)(sourcePath)) {
|
|
281
|
+
console.error(`Cannot find ${path} in your compiled Next.js application.`);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if (localizedDestPath) {
|
|
285
|
+
await (0, promises_1.mkdir)((0, path_1.dirname)(localizedDestPath), { recursive: true });
|
|
286
|
+
await (0, promises_1.copyFile)(sourcePath, localizedDestPath);
|
|
287
|
+
}
|
|
288
|
+
if (defaultDestPath) {
|
|
289
|
+
await (0, promises_1.mkdir)((0, path_1.dirname)(defaultDestPath), { recursive: true });
|
|
290
|
+
await (0, promises_1.copyFile)(sourcePath, defaultDestPath);
|
|
291
|
+
}
|
|
292
|
+
if (route.dataRoute && !appPathRoute) {
|
|
293
|
+
const dataSourcePath = `${(0, path_1.join)(...sourcePartsOrIndex)}.json`;
|
|
294
|
+
const dataDestPath = (0, path_1.join)(destDir, basePath, route.dataRoute);
|
|
295
|
+
await (0, promises_1.mkdir)((0, path_1.dirname)(dataDestPath), { recursive: true });
|
|
296
|
+
await (0, promises_1.copyFile)((0, path_1.join)(contentDist, dataSourcePath), dataDestPath);
|
|
297
|
+
}
|
|
298
|
+
}));
|
|
299
|
+
}
|
|
300
|
+
exports.ɵcodegenPublicDirectory = ɵcodegenPublicDirectory;
|
|
301
|
+
async function ɵcodegenFunctionsDirectory(sourceDir, destDir) {
|
|
302
|
+
const { distDir } = await getConfig(sourceDir);
|
|
303
|
+
const packageJson = await (0, utils_1.readJSON)((0, path_1.join)(sourceDir, "package.json"));
|
|
304
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(sourceDir, "next.config.js"))) {
|
|
305
|
+
try {
|
|
306
|
+
const productionDeps = await new Promise((resolve) => {
|
|
307
|
+
const dependencies = [];
|
|
308
|
+
const npmLs = (0, cross_spawn_1.spawn)("npm", ["ls", "--omit=dev", "--all", "--json=true"], {
|
|
309
|
+
cwd: sourceDir,
|
|
310
|
+
timeout: constants_1.NPM_COMMAND_TIMEOUT_MILLIES,
|
|
311
|
+
});
|
|
312
|
+
const pipeline = (0, stream_chain_1.chain)([
|
|
313
|
+
npmLs.stdout,
|
|
314
|
+
(0, stream_json_1.parser)({ packValues: false, packKeys: true, streamValues: false }),
|
|
315
|
+
(0, Pick_1.pick)({ filter: "dependencies" }),
|
|
316
|
+
(0, StreamObject_1.streamObject)(),
|
|
317
|
+
({ key, value }) => [
|
|
318
|
+
key,
|
|
319
|
+
...(0, utils_2.allDependencyNames)(value),
|
|
320
|
+
],
|
|
321
|
+
]);
|
|
322
|
+
pipeline.on("data", (it) => dependencies.push(it));
|
|
323
|
+
pipeline.on("end", () => {
|
|
324
|
+
resolve([...new Set(dependencies)]);
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
const esbuildArgs = productionDeps
|
|
328
|
+
.map((it) => `--external:${it}`)
|
|
329
|
+
.concat("--bundle", "--platform=node", `--target=node${constants_1.NODE_VERSION}`, `--outdir=${destDir}`, "--log-level=error");
|
|
330
|
+
const bundle = (0, cross_spawn_1.sync)("npx", ["--yes", `esbuild@${constants_2.ESBUILD_VERSION}`, "next.config.js", ...esbuildArgs], {
|
|
331
|
+
cwd: sourceDir,
|
|
332
|
+
timeout: BUNDLE_NEXT_CONFIG_TIMEOUT,
|
|
333
|
+
});
|
|
334
|
+
if (bundle.status !== 0) {
|
|
335
|
+
throw new error_1.FirebaseError(bundle.stderr.toString());
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
catch (e) {
|
|
339
|
+
console.warn("Unable to bundle next.config.js for use in Cloud Functions, proceeding with deploy but problems may be enountered.");
|
|
340
|
+
console.error(e.message || e);
|
|
341
|
+
(0, fs_extra_1.copy)((0, path_1.join)(sourceDir, "next.config.js"), (0, path_1.join)(destDir, "next.config.js"));
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (await (0, fs_extra_1.pathExists)((0, path_1.join)(sourceDir, "public"))) {
|
|
345
|
+
await (0, promises_1.mkdir)((0, path_1.join)(destDir, "public"));
|
|
346
|
+
await (0, fs_extra_1.copy)((0, path_1.join)(sourceDir, "public"), (0, path_1.join)(destDir, "public"));
|
|
347
|
+
}
|
|
348
|
+
if (await (0, utils_2.isUsingImageOptimization)(sourceDir, distDir)) {
|
|
349
|
+
packageJson.dependencies["sharp"] = constants_1.SHARP_VERSION;
|
|
350
|
+
}
|
|
351
|
+
await (0, fs_extra_1.mkdirp)((0, path_1.join)(destDir, distDir));
|
|
352
|
+
await (0, fs_extra_1.copy)((0, path_1.join)(sourceDir, distDir), (0, path_1.join)(destDir, distDir));
|
|
353
|
+
return { packageJson, frameworksEntry: "next.js" };
|
|
354
|
+
}
|
|
355
|
+
exports.ɵcodegenFunctionsDirectory = ɵcodegenFunctionsDirectory;
|
|
356
|
+
async function getDevModeHandle(dir, _, hostingEmulatorInfo) {
|
|
357
|
+
if (!hostingEmulatorInfo) {
|
|
358
|
+
if (await (0, utils_2.isUsingMiddleware)(dir, true)) {
|
|
359
|
+
throw new error_1.FirebaseError(`${clc.bold("firebase serve")} does not support Next.js Middleware. Please use ${clc.bold("firebase emulators:start")} instead.`);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
let next = (0, utils_1.relativeRequire)(dir, "next");
|
|
363
|
+
if ("default" in next)
|
|
364
|
+
next = next.default;
|
|
365
|
+
const nextApp = next({
|
|
366
|
+
dev: true,
|
|
367
|
+
dir,
|
|
368
|
+
hostname: hostingEmulatorInfo === null || hostingEmulatorInfo === void 0 ? void 0 : hostingEmulatorInfo.host,
|
|
369
|
+
port: hostingEmulatorInfo === null || hostingEmulatorInfo === void 0 ? void 0 : hostingEmulatorInfo.port,
|
|
370
|
+
});
|
|
371
|
+
const handler = nextApp.getRequestHandler();
|
|
372
|
+
await nextApp.prepare();
|
|
373
|
+
return (0, utils_1.simpleProxy)(async (req, res) => {
|
|
374
|
+
const parsedUrl = (0, url_1.parse)(req.url, true);
|
|
375
|
+
await handler(req, res, parsedUrl);
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
exports.getDevModeHandle = getDevModeHandle;
|
|
379
|
+
async function getConfig(dir) {
|
|
380
|
+
var _a;
|
|
381
|
+
var _b;
|
|
382
|
+
let config = {};
|
|
383
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(dir, "next.config.js"))) {
|
|
384
|
+
const version = (0, utils_2.getNextVersion)(dir);
|
|
385
|
+
if (!version)
|
|
386
|
+
throw new Error("Unable to find the next dep, try NPM installing?");
|
|
387
|
+
if ((0, semver_1.gte)(version, "12.0.0")) {
|
|
388
|
+
const { default: loadConfig } = (0, utils_1.relativeRequire)(dir, "next/dist/server/config");
|
|
389
|
+
const { PHASE_PRODUCTION_BUILD } = (0, utils_1.relativeRequire)(dir, "next/constants");
|
|
390
|
+
config = await loadConfig(PHASE_PRODUCTION_BUILD, dir);
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
try {
|
|
394
|
+
config = await (_a = (0, url_1.pathToFileURL)((0, path_1.join)(dir, "next.config.js")).toString(), Promise.resolve().then(() => require(_a)));
|
|
395
|
+
}
|
|
396
|
+
catch (e) {
|
|
397
|
+
throw new Error("Unable to load next.config.js.");
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
(0, utils_1.validateLocales)((_b = config.i18n) === null || _b === void 0 ? void 0 : _b.locales);
|
|
402
|
+
return Object.assign({ distDir: ".next", trailingSlash: false, basePath: "/" }, config);
|
|
403
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNextVersion = exports.getBuildId = exports.getHeadersFromMetaFiles = exports.getNonStaticServerComponents = exports.getNonStaticRoutes = exports.getMiddlewareMatcherRegexes = exports.allDependencyNames = exports.isUsingAppDirectory = exports.isUsingNextImageInAppDirectory = exports.isUsingImageOptimization = exports.isUsingMiddleware = exports.hasUnoptimizedImage = exports.usesNextImage = exports.usesAppDirRouter = exports.getNextjsRewritesToUse = exports.isHeaderSupportedByHosting = exports.isRedirectSupportedByHosting = exports.isRewriteSupportedByHosting = exports.cleanI18n = exports.cleanCustomRouteI18n = exports.cleanEscapedChars = exports.I18N_SOURCE = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const fs_extra_1 = require("fs-extra");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const promises_1 = require("fs/promises");
|
|
8
|
+
const glob_1 = require("glob");
|
|
9
|
+
const semver_1 = require("semver");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
const constants_1 = require("./constants");
|
|
12
|
+
const fsutils_1 = require("../../fsutils");
|
|
13
|
+
exports.I18N_SOURCE = /\/:nextInternalLocale(\([^\)]+\))?/;
|
|
14
|
+
function cleanEscapedChars(path) {
|
|
15
|
+
return path.replace(/\\([(){}:+?*])/g, (a, b) => b);
|
|
16
|
+
}
|
|
17
|
+
exports.cleanEscapedChars = cleanEscapedChars;
|
|
18
|
+
function cleanCustomRouteI18n(path) {
|
|
19
|
+
return path.replace(exports.I18N_SOURCE, "");
|
|
20
|
+
}
|
|
21
|
+
exports.cleanCustomRouteI18n = cleanCustomRouteI18n;
|
|
22
|
+
function cleanI18n(it) {
|
|
23
|
+
const [, localesRegex] = it.source.match(exports.I18N_SOURCE) || [undefined, undefined];
|
|
24
|
+
const source = localesRegex ? cleanCustomRouteI18n(it.source) : it.source;
|
|
25
|
+
const destination = "destination" in it && localesRegex ? cleanCustomRouteI18n(it.destination) : it.destination;
|
|
26
|
+
const regex = "regex" in it && localesRegex ? it.regex.replace(`(?:/${localesRegex})`, "") : it.regex;
|
|
27
|
+
return Object.assign(Object.assign({}, it), { source,
|
|
28
|
+
destination,
|
|
29
|
+
regex });
|
|
30
|
+
}
|
|
31
|
+
exports.cleanI18n = cleanI18n;
|
|
32
|
+
function isRewriteSupportedByHosting(rewrite) {
|
|
33
|
+
return !("has" in rewrite ||
|
|
34
|
+
"missing" in rewrite ||
|
|
35
|
+
(0, utils_1.isUrl)(rewrite.destination) ||
|
|
36
|
+
rewrite.destination.includes("?"));
|
|
37
|
+
}
|
|
38
|
+
exports.isRewriteSupportedByHosting = isRewriteSupportedByHosting;
|
|
39
|
+
function isRedirectSupportedByHosting(redirect) {
|
|
40
|
+
return !("has" in redirect ||
|
|
41
|
+
"missing" in redirect ||
|
|
42
|
+
"internal" in redirect ||
|
|
43
|
+
redirect.destination.includes("?"));
|
|
44
|
+
}
|
|
45
|
+
exports.isRedirectSupportedByHosting = isRedirectSupportedByHosting;
|
|
46
|
+
function isHeaderSupportedByHosting(header) {
|
|
47
|
+
return !("has" in header || "missing" in header);
|
|
48
|
+
}
|
|
49
|
+
exports.isHeaderSupportedByHosting = isHeaderSupportedByHosting;
|
|
50
|
+
function getNextjsRewritesToUse(nextJsRewrites) {
|
|
51
|
+
if (Array.isArray(nextJsRewrites)) {
|
|
52
|
+
return nextJsRewrites.map(cleanI18n);
|
|
53
|
+
}
|
|
54
|
+
if (nextJsRewrites === null || nextJsRewrites === void 0 ? void 0 : nextJsRewrites.beforeFiles) {
|
|
55
|
+
return nextJsRewrites.beforeFiles.map(cleanI18n);
|
|
56
|
+
}
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
exports.getNextjsRewritesToUse = getNextjsRewritesToUse;
|
|
60
|
+
function usesAppDirRouter(sourceDir) {
|
|
61
|
+
const appPathRoutesManifestPath = (0, path_1.join)(sourceDir, constants_1.APP_PATH_ROUTES_MANIFEST);
|
|
62
|
+
return (0, fs_1.existsSync)(appPathRoutesManifestPath);
|
|
63
|
+
}
|
|
64
|
+
exports.usesAppDirRouter = usesAppDirRouter;
|
|
65
|
+
async function usesNextImage(sourceDir, distDir) {
|
|
66
|
+
const exportMarker = await (0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, constants_1.EXPORT_MARKER));
|
|
67
|
+
return exportMarker.isNextImageImported;
|
|
68
|
+
}
|
|
69
|
+
exports.usesNextImage = usesNextImage;
|
|
70
|
+
async function hasUnoptimizedImage(sourceDir, distDir) {
|
|
71
|
+
const imagesManifest = await (0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, constants_1.IMAGES_MANIFEST));
|
|
72
|
+
return imagesManifest.images.unoptimized;
|
|
73
|
+
}
|
|
74
|
+
exports.hasUnoptimizedImage = hasUnoptimizedImage;
|
|
75
|
+
async function isUsingMiddleware(dir, isDevMode) {
|
|
76
|
+
if (isDevMode) {
|
|
77
|
+
const [middlewareJs, middlewareTs] = await Promise.all([
|
|
78
|
+
(0, fs_extra_1.pathExists)((0, path_1.join)(dir, "middleware.js")),
|
|
79
|
+
(0, fs_extra_1.pathExists)((0, path_1.join)(dir, "middleware.ts")),
|
|
80
|
+
]);
|
|
81
|
+
return middlewareJs || middlewareTs;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const middlewareManifest = await (0, utils_1.readJSON)((0, path_1.join)(dir, "server", constants_1.MIDDLEWARE_MANIFEST));
|
|
85
|
+
return Object.keys(middlewareManifest.middleware).length > 0;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.isUsingMiddleware = isUsingMiddleware;
|
|
89
|
+
async function isUsingImageOptimization(projectDir, distDir) {
|
|
90
|
+
let isNextImageImported = await usesNextImage(projectDir, distDir);
|
|
91
|
+
if (!isNextImageImported && isUsingAppDirectory((0, path_1.join)(projectDir, distDir))) {
|
|
92
|
+
if (await isUsingNextImageInAppDirectory(projectDir, distDir)) {
|
|
93
|
+
isNextImageImported = true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (isNextImageImported) {
|
|
97
|
+
const imagesManifest = await (0, utils_1.readJSON)((0, path_1.join)(projectDir, distDir, constants_1.IMAGES_MANIFEST));
|
|
98
|
+
return !imagesManifest.images.unoptimized;
|
|
99
|
+
}
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
exports.isUsingImageOptimization = isUsingImageOptimization;
|
|
103
|
+
async function isUsingNextImageInAppDirectory(projectDir, nextDir) {
|
|
104
|
+
const files = (0, glob_1.sync)((0, path_1.join)(projectDir, nextDir, "server", "**", "*client-reference-manifest.js"));
|
|
105
|
+
for (const filepath of files) {
|
|
106
|
+
const fileContents = await (0, promises_1.readFile)(filepath);
|
|
107
|
+
if (fileContents.includes("node_modules/next/dist/client/image")) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
exports.isUsingNextImageInAppDirectory = isUsingNextImageInAppDirectory;
|
|
114
|
+
function isUsingAppDirectory(dir) {
|
|
115
|
+
const appPathRoutesManifestPath = (0, path_1.join)(dir, constants_1.APP_PATH_ROUTES_MANIFEST);
|
|
116
|
+
return (0, fsutils_1.fileExistsSync)(appPathRoutesManifestPath);
|
|
117
|
+
}
|
|
118
|
+
exports.isUsingAppDirectory = isUsingAppDirectory;
|
|
119
|
+
function allDependencyNames(mod) {
|
|
120
|
+
if (!mod.dependencies)
|
|
121
|
+
return [];
|
|
122
|
+
const dependencyNames = Object.keys(mod.dependencies).reduce((acc, it) => [...acc, it, ...allDependencyNames(mod.dependencies[it])], []);
|
|
123
|
+
return dependencyNames;
|
|
124
|
+
}
|
|
125
|
+
exports.allDependencyNames = allDependencyNames;
|
|
126
|
+
function getMiddlewareMatcherRegexes(middlewareManifest) {
|
|
127
|
+
const middlewareObjectValues = Object.values(middlewareManifest.middleware);
|
|
128
|
+
let middlewareMatchers;
|
|
129
|
+
if (middlewareManifest.version === 1) {
|
|
130
|
+
middlewareMatchers = middlewareObjectValues.map((page) => ({ regexp: page.regexp }));
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
middlewareMatchers = middlewareObjectValues
|
|
134
|
+
.map((page) => page.matchers)
|
|
135
|
+
.flat();
|
|
136
|
+
}
|
|
137
|
+
return middlewareMatchers.map((matcher) => new RegExp(matcher.regexp));
|
|
138
|
+
}
|
|
139
|
+
exports.getMiddlewareMatcherRegexes = getMiddlewareMatcherRegexes;
|
|
140
|
+
function getNonStaticRoutes(pagesManifestJSON, prerenderedRoutes, dynamicRoutes) {
|
|
141
|
+
const nonStaticRoutes = Object.entries(pagesManifestJSON)
|
|
142
|
+
.filter(([it, src]) => !((0, path_1.extname)(src) !== ".js" ||
|
|
143
|
+
["/_app", "/_error", "/_document"].includes(it) ||
|
|
144
|
+
prerenderedRoutes.includes(it) ||
|
|
145
|
+
dynamicRoutes.includes(it)))
|
|
146
|
+
.map(([it]) => it);
|
|
147
|
+
return nonStaticRoutes;
|
|
148
|
+
}
|
|
149
|
+
exports.getNonStaticRoutes = getNonStaticRoutes;
|
|
150
|
+
function getNonStaticServerComponents(appPathsManifest, appPathRoutesManifest, prerenderedRoutes, dynamicRoutes) {
|
|
151
|
+
const nonStaticServerComponents = Object.entries(appPathsManifest)
|
|
152
|
+
.filter(([it, src]) => {
|
|
153
|
+
if ((0, path_1.extname)(src) !== ".js")
|
|
154
|
+
return;
|
|
155
|
+
const path = appPathRoutesManifest[it];
|
|
156
|
+
return !(prerenderedRoutes.includes(path) || dynamicRoutes.includes(path));
|
|
157
|
+
})
|
|
158
|
+
.map(([it]) => it);
|
|
159
|
+
return nonStaticServerComponents;
|
|
160
|
+
}
|
|
161
|
+
exports.getNonStaticServerComponents = getNonStaticServerComponents;
|
|
162
|
+
async function getHeadersFromMetaFiles(sourceDir, distDir, basePath, appPathRoutesManifest) {
|
|
163
|
+
const headers = [];
|
|
164
|
+
await Promise.all(Object.entries(appPathRoutesManifest).map(async ([key, source]) => {
|
|
165
|
+
if ((0, path_1.basename)(key) !== "route")
|
|
166
|
+
return;
|
|
167
|
+
const parts = source.split("/").filter((it) => !!it);
|
|
168
|
+
const partsOrIndex = parts.length > 0 ? parts : ["index"];
|
|
169
|
+
const routePath = (0, path_1.join)(sourceDir, distDir, "server", "app", ...partsOrIndex);
|
|
170
|
+
const metadataPath = `${routePath}.meta`;
|
|
171
|
+
if ((0, fsutils_1.dirExistsSync)(routePath) && (0, fsutils_1.fileExistsSync)(metadataPath)) {
|
|
172
|
+
const meta = await (0, utils_1.readJSON)(metadataPath);
|
|
173
|
+
if (meta.headers)
|
|
174
|
+
headers.push({
|
|
175
|
+
source: path_1.posix.join(basePath, source),
|
|
176
|
+
headers: Object.entries(meta.headers).map(([key, value]) => ({ key, value })),
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}));
|
|
180
|
+
return headers;
|
|
181
|
+
}
|
|
182
|
+
exports.getHeadersFromMetaFiles = getHeadersFromMetaFiles;
|
|
183
|
+
async function getBuildId(distDir) {
|
|
184
|
+
const buildId = await (0, promises_1.readFile)((0, path_1.join)(distDir, "BUILD_ID"));
|
|
185
|
+
return buildId.toString();
|
|
186
|
+
}
|
|
187
|
+
exports.getBuildId = getBuildId;
|
|
188
|
+
function getNextVersion(cwd) {
|
|
189
|
+
const dependency = (0, utils_1.findDependency)("next", { cwd, depth: 0, omitDev: false });
|
|
190
|
+
if (!dependency)
|
|
191
|
+
return undefined;
|
|
192
|
+
const nextVersionSemver = (0, semver_1.coerce)(dependency.version);
|
|
193
|
+
if (!nextVersionSemver)
|
|
194
|
+
return dependency.version;
|
|
195
|
+
return nextVersionSemver.toString();
|
|
196
|
+
}
|
|
197
|
+
exports.getNextVersion = getNextVersion;
|