specweave 0.22.0 → 0.22.3
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/CLAUDE.md +373 -13
- package/README.md +5 -5
- package/bin/specweave.js +5 -8
- package/dist/plugins/specweave-github/lib/CodeValidator.d.ts +1 -1
- package/dist/plugins/specweave-github/lib/CodeValidator.js +1 -1
- package/dist/plugins/specweave-github/lib/github-client-v2.d.ts +10 -0
- package/dist/plugins/specweave-github/lib/github-client-v2.d.ts.map +1 -1
- package/dist/plugins/specweave-github/lib/github-client-v2.js +26 -0
- package/dist/plugins/specweave-github/lib/github-client-v2.js.map +1 -1
- package/dist/plugins/specweave-github/lib/task-sync.d.ts.map +1 -1
- package/dist/plugins/specweave-github/lib/task-sync.js +7 -0
- package/dist/plugins/specweave-github/lib/task-sync.js.map +1 -1
- package/dist/src/cli/commands/migrate-to-profiles.d.ts +1 -0
- package/dist/src/cli/commands/migrate-to-profiles.d.ts.map +1 -1
- package/dist/src/cli/commands/migrate-to-profiles.js +12 -1
- package/dist/src/cli/commands/migrate-to-profiles.js.map +1 -1
- package/dist/src/cli/commands/next-command.d.ts +52 -0
- package/dist/src/cli/commands/next-command.d.ts.map +1 -0
- package/dist/src/cli/commands/next-command.js +204 -0
- package/dist/src/cli/commands/next-command.js.map +1 -0
- package/dist/src/cli/commands/repair-status-desync.d.ts +69 -0
- package/dist/src/cli/commands/repair-status-desync.d.ts.map +1 -0
- package/dist/src/cli/commands/repair-status-desync.js +221 -0
- package/dist/src/cli/commands/repair-status-desync.js.map +1 -0
- package/dist/src/cli/commands/sync-specs.d.ts +16 -0
- package/dist/src/cli/commands/sync-specs.d.ts.map +1 -0
- package/dist/src/cli/commands/sync-specs.js +130 -0
- package/dist/src/cli/commands/sync-specs.js.map +1 -0
- package/dist/src/cli/commands/validate-status-sync.d.ts +52 -0
- package/dist/src/cli/commands/validate-status-sync.d.ts.map +1 -0
- package/dist/src/cli/commands/validate-status-sync.js +176 -0
- package/dist/src/cli/commands/validate-status-sync.js.map +1 -0
- package/dist/src/cli/count-tasks.d.ts +20 -0
- package/dist/src/cli/count-tasks.d.ts.map +1 -0
- package/dist/src/cli/count-tasks.js +50 -0
- package/dist/src/cli/count-tasks.js.map +1 -0
- package/dist/src/cli/update-status-line.d.ts +16 -0
- package/dist/src/cli/update-status-line.d.ts.map +1 -0
- package/dist/src/cli/update-status-line.js +44 -0
- package/dist/src/cli/update-status-line.js.map +1 -0
- package/dist/src/config/ConfigManager.d.ts.map +1 -1
- package/dist/src/config/ConfigManager.js +2 -1
- package/dist/src/config/ConfigManager.js.map +1 -1
- package/dist/src/config/types.d.ts +50 -50
- package/dist/src/core/cicd/state-manager.d.ts +8 -0
- package/dist/src/core/cicd/state-manager.d.ts.map +1 -1
- package/dist/src/core/cicd/state-manager.js +60 -15
- package/dist/src/core/cicd/state-manager.js.map +1 -1
- package/dist/src/core/cost-tracker.d.ts.map +1 -1
- package/dist/src/core/cost-tracker.js +2 -1
- package/dist/src/core/cost-tracker.js.map +1 -1
- package/dist/src/core/iac/template-engine.d.ts.map +1 -1
- package/dist/src/core/iac/template-engine.js +28 -0
- package/dist/src/core/iac/template-engine.js.map +1 -1
- package/dist/src/core/iac/template-generator.d.ts +53 -0
- package/dist/src/core/iac/template-generator.d.ts.map +1 -0
- package/dist/src/core/iac/template-generator.js +125 -0
- package/dist/src/core/iac/template-generator.js.map +1 -0
- package/dist/src/core/increment/completion-validator.d.ts +56 -0
- package/dist/src/core/increment/completion-validator.d.ts.map +1 -0
- package/dist/src/core/increment/completion-validator.js +102 -0
- package/dist/src/core/increment/completion-validator.js.map +1 -0
- package/dist/src/core/increment/metadata-manager.d.ts.map +1 -1
- package/dist/src/core/increment/metadata-manager.js +10 -0
- package/dist/src/core/increment/metadata-manager.js.map +1 -1
- package/dist/src/core/increment/spec-frontmatter-updater.d.ts +78 -0
- package/dist/src/core/increment/spec-frontmatter-updater.d.ts.map +1 -0
- package/dist/src/core/increment/spec-frontmatter-updater.js +152 -0
- package/dist/src/core/increment/spec-frontmatter-updater.js.map +1 -0
- package/dist/src/core/increment/status-auto-transition.js +3 -3
- package/dist/src/core/increment/status-auto-transition.js.map +1 -1
- package/dist/src/core/living-docs/CodeValidator.js +1 -1
- package/dist/src/core/living-docs/CodeValidator.js.map +1 -1
- package/dist/src/core/living-docs/content-distributor.d.ts.map +1 -1
- package/dist/src/core/living-docs/content-distributor.js +11 -1
- package/dist/src/core/living-docs/content-distributor.js.map +1 -1
- package/dist/src/core/living-docs/living-docs-sync.d.ts +166 -0
- package/dist/src/core/living-docs/living-docs-sync.d.ts.map +1 -0
- package/dist/src/core/living-docs/living-docs-sync.js +727 -0
- package/dist/src/core/living-docs/living-docs-sync.js.map +1 -0
- package/dist/src/core/living-docs/task-project-specific-generator.d.ts +7 -3
- package/dist/src/core/living-docs/task-project-specific-generator.d.ts.map +1 -1
- package/dist/src/core/living-docs/task-project-specific-generator.js +40 -24
- package/dist/src/core/living-docs/task-project-specific-generator.js.map +1 -1
- package/dist/src/core/plugin-loader.d.ts +7 -0
- package/dist/src/core/plugin-loader.d.ts.map +1 -1
- package/dist/src/core/plugin-loader.js +18 -1
- package/dist/src/core/plugin-loader.js.map +1 -1
- package/dist/src/core/serverless/platform-data-loader.d.ts +8 -0
- package/dist/src/core/serverless/platform-data-loader.d.ts.map +1 -1
- package/dist/src/core/serverless/platform-data-loader.js +14 -0
- package/dist/src/core/serverless/platform-data-loader.js.map +1 -1
- package/dist/src/core/serverless/types.d.ts +1 -1
- package/dist/src/core/serverless/types.d.ts.map +1 -1
- package/dist/src/core/status-line/status-line-manager.d.ts +7 -2
- package/dist/src/core/status-line/status-line-manager.d.ts.map +1 -1
- package/dist/src/core/status-line/status-line-manager.js +47 -18
- package/dist/src/core/status-line/status-line-manager.js.map +1 -1
- package/dist/src/core/status-line/status-line-updater.d.ts +67 -0
- package/dist/src/core/status-line/status-line-updater.d.ts.map +1 -0
- package/dist/src/core/status-line/status-line-updater.js +203 -0
- package/dist/src/core/status-line/status-line-updater.js.map +1 -0
- package/dist/src/core/status-line/task-counter.d.ts +69 -0
- package/dist/src/core/status-line/task-counter.d.ts.map +1 -0
- package/dist/src/core/status-line/task-counter.js +107 -0
- package/dist/src/core/status-line/task-counter.js.map +1 -0
- package/dist/src/core/status-line/types.d.ts +19 -5
- package/dist/src/core/status-line/types.d.ts.map +1 -1
- package/dist/src/core/status-line/types.js +3 -3
- package/dist/src/core/status-line/types.js.map +1 -1
- package/dist/src/core/workflow/autonomous-executor.d.ts +111 -0
- package/dist/src/core/workflow/autonomous-executor.d.ts.map +1 -0
- package/dist/src/core/workflow/autonomous-executor.js +275 -0
- package/dist/src/core/workflow/autonomous-executor.js.map +1 -0
- package/dist/src/core/workflow/backlog-scanner.d.ts +94 -0
- package/dist/src/core/workflow/backlog-scanner.d.ts.map +1 -0
- package/dist/src/core/workflow/backlog-scanner.js +170 -0
- package/dist/src/core/workflow/backlog-scanner.js.map +1 -0
- package/dist/src/core/workflow/command-invoker.d.ts +86 -0
- package/dist/src/core/workflow/command-invoker.d.ts.map +1 -0
- package/dist/src/core/workflow/command-invoker.js +131 -0
- package/dist/src/core/workflow/command-invoker.js.map +1 -0
- package/dist/src/core/workflow/cost-estimator.d.ts +120 -0
- package/dist/src/core/workflow/cost-estimator.d.ts.map +1 -0
- package/dist/src/core/workflow/cost-estimator.js +222 -0
- package/dist/src/core/workflow/cost-estimator.js.map +1 -0
- package/dist/src/core/workflow/index.d.ts +20 -0
- package/dist/src/core/workflow/index.d.ts.map +1 -0
- package/dist/src/core/workflow/index.js +24 -0
- package/dist/src/core/workflow/index.js.map +1 -0
- package/dist/src/core/workflow/state-manager.d.ts +107 -0
- package/dist/src/core/workflow/state-manager.d.ts.map +1 -0
- package/dist/src/core/workflow/state-manager.js +126 -0
- package/dist/src/core/workflow/state-manager.js.map +1 -0
- package/dist/src/core/workflow/workflow-orchestrator.d.ts +93 -0
- package/dist/src/core/workflow/workflow-orchestrator.d.ts.map +1 -0
- package/dist/src/core/workflow/workflow-orchestrator.js +195 -0
- package/dist/src/core/workflow/workflow-orchestrator.js.map +1 -0
- package/dist/src/init/architecture/types.d.ts +10 -10
- package/dist/src/metrics/dora-calculator.js +2 -2
- package/dist/src/metrics/dora-calculator.js.map +1 -1
- package/dist/src/utils/pricing-constants.d.ts +5 -2
- package/dist/src/utils/pricing-constants.d.ts.map +1 -1
- package/dist/src/utils/pricing-constants.js +3 -2
- package/dist/src/utils/pricing-constants.js.map +1 -1
- package/package.json +4 -4
- package/plugins/specweave/agents/infrastructure/AGENT.md +88 -46
- package/plugins/specweave/agents/pm/AGENT.md +58 -1
- package/plugins/specweave/commands/specweave-archive-features.md +1 -1
- package/plugins/specweave/commands/specweave-archive-increments.md +1 -1
- package/plugins/specweave/commands/specweave-check-hooks.md +5 -0
- package/plugins/specweave/commands/specweave-done.md +72 -4
- package/plugins/specweave/commands/specweave-plan.md +1 -1
- package/plugins/specweave/commands/specweave-progress.md +108 -379
- package/plugins/specweave/commands/specweave-reopen.md +30 -3
- package/plugins/specweave/commands/specweave-restore-feature.md +1 -1
- package/plugins/specweave/commands/specweave-sync-docs.md +71 -4
- package/plugins/specweave/commands/specweave-sync-specs.md +20 -48
- package/plugins/specweave/commands/specweave-update-status.md +151 -0
- package/plugins/specweave/hooks/lib/update-status-line.sh +78 -41
- package/plugins/specweave/hooks/lib/validate-spec-status.sh +163 -0
- package/plugins/specweave/hooks/user-prompt-submit.sh +38 -35
- package/plugins/specweave/hooks/validate-increment-completion.sh +113 -0
- package/plugins/specweave/lib/hooks/update-tasks-md.js +52 -9
- package/plugins/specweave/lib/hooks/update-tasks-md.ts +77 -16
- package/plugins/specweave/templates/iac/aws-lambda/defaults.json +24 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/README.md.hbs +260 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/environments/dev.tfvars.hbs +34 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/environments/prod.tfvars.hbs +37 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/environments/staging.tfvars.hbs +35 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/outputs.tf.hbs +77 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/providers.tf.hbs +36 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/variables.tf.hbs +115 -0
- package/plugins/specweave/templates/iac/azure-functions/defaults.json +25 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/README.md.hbs +268 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/environments/dev.tfvars.hbs +34 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/environments/prod.tfvars.hbs +46 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/environments/staging.tfvars.hbs +34 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/main.tf.hbs +225 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/outputs.tf.hbs +89 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/provider.tf.hbs +27 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/providers.tf.hbs +35 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/variables.tf.hbs +124 -0
- package/plugins/specweave/templates/iac/firebase/defaults.json +29 -0
- package/plugins/specweave/templates/iac/firebase/templates/README.md.hbs +35 -0
- package/plugins/specweave/templates/iac/firebase/templates/environments/dev.tfvars.hbs +7 -0
- package/plugins/specweave/templates/iac/firebase/templates/environments/prod.tfvars.hbs +7 -0
- package/plugins/specweave/templates/iac/firebase/templates/environments/staging.tfvars.hbs +7 -0
- package/plugins/specweave/templates/iac/firebase/templates/main.tf.hbs +90 -0
- package/plugins/specweave/templates/iac/firebase/templates/outputs.tf.hbs +15 -0
- package/plugins/specweave/templates/iac/firebase/templates/providers.tf.hbs +23 -0
- package/plugins/specweave/templates/iac/firebase/templates/variables.tf.hbs +42 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/defaults.json +26 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/README.md.hbs +299 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/environments/dev.tfvars.hbs +36 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/environments/prod.tfvars.hbs +48 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/environments/staging.tfvars.hbs +41 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/main.tf.hbs +192 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/outputs.tf.hbs +66 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/providers.tf.hbs +25 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/variables.tf.hbs +119 -0
- package/plugins/specweave/templates/iac/supabase/defaults.json +15 -0
- package/plugins/specweave/templates/iac/supabase/templates/README.md.hbs +46 -0
- package/plugins/specweave/templates/iac/supabase/templates/main.tf.hbs +50 -0
- package/plugins/specweave-ado/lib/ado-multi-project-sync.js +0 -1
- package/plugins/specweave-github/agents/github-manager/AGENT.md +39 -7
- package/plugins/specweave-github/commands/specweave-github-cleanup-duplicates.md +21 -0
- package/plugins/specweave-github/commands/specweave-github-create-issue.md +5 -5
- package/plugins/specweave-github/lib/CodeValidator.ts +1 -1
- package/plugins/specweave-github/lib/github-client-v2.js +29 -0
- package/plugins/specweave-github/lib/github-client-v2.ts +30 -0
- package/plugins/specweave-github/lib/task-sync.js +4 -0
- package/plugins/specweave-github/lib/task-sync.ts +7 -0
- package/src/templates/CLAUDE.md.template +31 -0
- package/dist/src/core/living-docs/ThreeLayerSyncManager.d.ts +0 -116
- package/dist/src/core/living-docs/ThreeLayerSyncManager.d.ts.map +0 -1
- package/dist/src/core/living-docs/ThreeLayerSyncManager.js +0 -356
- package/dist/src/core/living-docs/ThreeLayerSyncManager.js.map +0 -1
- package/plugins/specweave-ado/lib/enhanced-ado-sync.js +0 -170
- package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +0 -1200
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Firebase (Hosting + Functions + Firestore) Terraform Configuration
|
|
2
|
+
# Generated by SpecWeave Serverless Architecture Intelligence
|
|
3
|
+
|
|
4
|
+
# Enable Firebase for existing GCP project
|
|
5
|
+
resource "google_firebase_project" "default" {
|
|
6
|
+
provider = google-beta
|
|
7
|
+
project = "{{projectId}}"
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
# Enable required APIs
|
|
11
|
+
resource "google_project_service" "firebasehosting" {
|
|
12
|
+
project = "{{projectId}}"
|
|
13
|
+
service = "firebasehosting.googleapis.com"
|
|
14
|
+
disable_on_destroy = false
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
resource "google_project_service" "firebase" {
|
|
18
|
+
project = "{{projectId}}"
|
|
19
|
+
service = "firebase.googleapis.com"
|
|
20
|
+
disable_on_destroy = false
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
# Firebase Web App
|
|
24
|
+
resource "google_firebase_web_app" "{{snakeCase appDisplayName}}" {
|
|
25
|
+
provider = google-beta
|
|
26
|
+
project = "{{projectId}}"
|
|
27
|
+
display_name = "{{appDisplayName}}"
|
|
28
|
+
|
|
29
|
+
depends_on = [google_firebase_project.default]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
# Firebase Hosting Site
|
|
33
|
+
resource "google_firebase_hosting_site" "{{snakeCase siteId}}" {
|
|
34
|
+
provider = google-beta
|
|
35
|
+
project = "{{projectId}}"
|
|
36
|
+
site_id = "{{siteId}}"
|
|
37
|
+
|
|
38
|
+
depends_on = [google_firebase_project.default]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
# Firestore Database (same as GCP)
|
|
42
|
+
resource "google_firestore_database" "{{snakeCase databaseId}}" {
|
|
43
|
+
project = "{{projectId}}"
|
|
44
|
+
name = "{{databaseId}}"
|
|
45
|
+
location_id = "{{region}}"
|
|
46
|
+
type = "FIRESTORE_NATIVE"
|
|
47
|
+
|
|
48
|
+
depends_on = [google_firebase_project.default]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# Cloud Functions for Firebase (similar to GCP Cloud Functions)
|
|
52
|
+
resource "google_cloudfunctions2_function" "{{snakeCase functionName}}" {
|
|
53
|
+
name = "{{functionName}}"
|
|
54
|
+
location = "{{region}}"
|
|
55
|
+
project = "{{projectId}}"
|
|
56
|
+
|
|
57
|
+
build_config {
|
|
58
|
+
runtime = "{{runtime}}"
|
|
59
|
+
entry_point = "{{entryPoint}}"
|
|
60
|
+
source {
|
|
61
|
+
storage_source {
|
|
62
|
+
bucket = "{{projectId}}.appspot.com"
|
|
63
|
+
object = "function-source.zip"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
service_config {
|
|
69
|
+
max_instance_count = 10
|
|
70
|
+
available_memory = "{{memoryMb}}M"
|
|
71
|
+
timeout_seconds = {{timeoutSeconds}}
|
|
72
|
+
environment_variables = {
|
|
73
|
+
FIREBASE_CONFIG = google_firebase_web_app.{{snakeCase appDisplayName}}.app_id
|
|
74
|
+
ENVIRONMENT = "{{environment}}"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
depends_on = [google_firebase_project.default]
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
{{#if enableStorage}}
|
|
82
|
+
# Firebase Storage Bucket
|
|
83
|
+
resource "google_firebase_storage_bucket" "{{snakeCase storageBucket}}" {
|
|
84
|
+
provider = google-beta
|
|
85
|
+
project = "{{projectId}}"
|
|
86
|
+
bucket_id = "{{storageBucket}}"
|
|
87
|
+
|
|
88
|
+
depends_on = [google_firebase_project.default]
|
|
89
|
+
}
|
|
90
|
+
{{/if}}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Firebase Outputs
|
|
2
|
+
output "web_app_id" {
|
|
3
|
+
description = "Firebase Web App ID"
|
|
4
|
+
value = google_firebase_web_app.{{snakeCase appDisplayName}}.app_id
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
output "hosting_site_url" {
|
|
8
|
+
description = "Firebase Hosting URL"
|
|
9
|
+
value = "https://${google_firebase_hosting_site.{{snakeCase siteId}}.default_url}"
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
output "function_url" {
|
|
13
|
+
description = "Cloud Function URL"
|
|
14
|
+
value = google_cloudfunctions2_function.{{snakeCase functionName}}.service_config[0].uri
|
|
15
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
terraform {
|
|
2
|
+
required_version = ">= 1.5.0"
|
|
3
|
+
required_providers {
|
|
4
|
+
google = {
|
|
5
|
+
source = "hashicorp/google"
|
|
6
|
+
version = "~> 5.0"
|
|
7
|
+
}
|
|
8
|
+
google-beta = {
|
|
9
|
+
source = "hashicorp/google-beta"
|
|
10
|
+
version = "~> 5.0"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
provider "google" {
|
|
16
|
+
project = "{{projectId}}"
|
|
17
|
+
region = "{{region}}"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
provider "google-beta" {
|
|
21
|
+
project = "{{projectId}}"
|
|
22
|
+
region = "{{region}}"
|
|
23
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Input Variables for Firebase
|
|
2
|
+
variable "project_id" {
|
|
3
|
+
description = "GCP/Firebase Project ID"
|
|
4
|
+
type = string
|
|
5
|
+
default = "{{projectId}}"
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
variable "region" {
|
|
9
|
+
description = "Firebase/GCP region"
|
|
10
|
+
type = string
|
|
11
|
+
default = "{{region}}"
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
variable "app_display_name" {
|
|
15
|
+
description = "Firebase Web App display name"
|
|
16
|
+
type = string
|
|
17
|
+
default = "{{appDisplayName}}"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
variable "site_id" {
|
|
21
|
+
description = "Firebase Hosting site ID"
|
|
22
|
+
type = string
|
|
23
|
+
default = "{{siteId}}"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
variable "function_name" {
|
|
27
|
+
description = "Cloud Function name"
|
|
28
|
+
type = string
|
|
29
|
+
default = "{{functionName}}"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
variable "runtime" {
|
|
33
|
+
description = "Function runtime"
|
|
34
|
+
type = string
|
|
35
|
+
default = "{{runtime}}"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
variable "environment" {
|
|
39
|
+
description = "Environment (dev/staging/prod)"
|
|
40
|
+
type = string
|
|
41
|
+
default = "{{environment}}"
|
|
42
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"projectId": "my-gcp-project",
|
|
3
|
+
"region": "us-central1",
|
|
4
|
+
"functionName": "my-cloud-function",
|
|
5
|
+
"runtime": "nodejs20",
|
|
6
|
+
"entryPoint": "handler",
|
|
7
|
+
"memoryMb": 256,
|
|
8
|
+
"timeoutSeconds": 60,
|
|
9
|
+
"minInstances": 0,
|
|
10
|
+
"maxInstances": 100,
|
|
11
|
+
"environment": "dev",
|
|
12
|
+
"databaseId": "(default)",
|
|
13
|
+
"collectionId": "my-collection",
|
|
14
|
+
"serviceAccountId": "my-function-sa",
|
|
15
|
+
"corsOrigins": ["*"],
|
|
16
|
+
"projectName": "my-project",
|
|
17
|
+
"enableSecretManager": false,
|
|
18
|
+
"enableVpc": false,
|
|
19
|
+
"enableCloudArmor": false,
|
|
20
|
+
"enableConcurrency": false,
|
|
21
|
+
"maxConcurrentRequests": 80,
|
|
22
|
+
"enableCloudLogging": true,
|
|
23
|
+
"enableCloudMonitoring": true,
|
|
24
|
+
"bucketName": "my-function-source",
|
|
25
|
+
"bucketLocation": "US"
|
|
26
|
+
}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
# GCP Cloud Functions + Firestore Terraform Configuration
|
|
2
|
+
|
|
3
|
+
**Generated by SpecWeave Serverless Architecture Intelligence**
|
|
4
|
+
|
|
5
|
+
This Terraform configuration deploys:
|
|
6
|
+
- Cloud Functions (2nd gen) with HTTP trigger
|
|
7
|
+
- Firestore database (Native mode)
|
|
8
|
+
- Cloud Storage bucket for function source code
|
|
9
|
+
- Service Account with Firestore access
|
|
10
|
+
{{#if enableSecretManager}}- Secret Manager for sensitive configuration{{/if}}
|
|
11
|
+
{{#if enableVpc}}- VPC Access Connector for private networking{{/if}}
|
|
12
|
+
|
|
13
|
+
## Architecture
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
Cloud Function ({{functionName}})
|
|
17
|
+
├── Runtime: {{runtime}}
|
|
18
|
+
├── Memory: {{memoryMb}} MB
|
|
19
|
+
├── Timeout: {{timeoutSeconds}}s
|
|
20
|
+
├── Min Instances: {{minInstances}} ({{#if (eq minInstances 0)}}scales to zero{{else}}always-on{{/if}})
|
|
21
|
+
└── Max Instances: {{maxInstances}}
|
|
22
|
+
|
|
23
|
+
Firestore Database ({{databaseId}})
|
|
24
|
+
├── Type: FIRESTORE_NATIVE
|
|
25
|
+
├── Location: {{region}}
|
|
26
|
+
└── Collection: {{collectionId}}
|
|
27
|
+
|
|
28
|
+
Service Account ({{serviceAccountId}})
|
|
29
|
+
└── Roles: roles/datastore.user{{#if enableSecretManager}}, roles/secretmanager.secretAccessor{{/if}}
|
|
30
|
+
|
|
31
|
+
Cloud Storage ({{bucketName}})
|
|
32
|
+
├── Location: {{bucketLocation}}
|
|
33
|
+
└── Purpose: Function source code
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Prerequisites
|
|
37
|
+
|
|
38
|
+
1. **GCP Project** with billing enabled:
|
|
39
|
+
```bash
|
|
40
|
+
gcloud config set project {{projectId}}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
2. **gcloud CLI** authenticated:
|
|
44
|
+
```bash
|
|
45
|
+
gcloud auth application-default login
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
3. **Terraform** v1.5.0+ installed:
|
|
49
|
+
```bash
|
|
50
|
+
terraform version
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
4. **Function source code** ready to deploy:
|
|
54
|
+
- Node.js: `package.json`, `index.js`, etc.
|
|
55
|
+
- Python: `requirements.txt`, `main.py`, etc.
|
|
56
|
+
- Go: `go.mod`, `main.go`, etc.
|
|
57
|
+
|
|
58
|
+
5. **Zip function source code**:
|
|
59
|
+
```bash
|
|
60
|
+
cd ../src # Navigate to your function source code
|
|
61
|
+
zip -r ../infrastructure/function-source.zip .
|
|
62
|
+
cd ../infrastructure
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Deployment Instructions
|
|
66
|
+
|
|
67
|
+
### 1. Initialize Terraform
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
terraform init
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 2. Review the Plan
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
terraform plan
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Expected resources**: ~{{#if enableVpc}}10{{else if enableSecretManager}}9{{else}}7{{/if}} resources will be created
|
|
80
|
+
|
|
81
|
+
### 3. Deploy Infrastructure
|
|
82
|
+
|
|
83
|
+
**Development**:
|
|
84
|
+
```bash
|
|
85
|
+
terraform apply -var-file="environments/dev.tfvars"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Staging**:
|
|
89
|
+
```bash
|
|
90
|
+
terraform apply -var-file="environments/staging.tfvars"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Production**:
|
|
94
|
+
```bash
|
|
95
|
+
terraform apply -var-file="environments/prod.tfvars"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 4. Deploy Function Code (Alternative)
|
|
99
|
+
|
|
100
|
+
You can also deploy function code using `gcloud`:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
gcloud functions deploy {{functionName}} \
|
|
104
|
+
--gen2 \
|
|
105
|
+
--runtime={{runtime}} \
|
|
106
|
+
--region={{region}} \
|
|
107
|
+
--source=../src \
|
|
108
|
+
--entry-point={{entryPoint}} \
|
|
109
|
+
--trigger-http \
|
|
110
|
+
--allow-unauthenticated
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 5. Test Your Function
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# Get function URL
|
|
117
|
+
FUNCTION_URL=$(terraform output -raw function_url)
|
|
118
|
+
|
|
119
|
+
# Test HTTP trigger
|
|
120
|
+
curl "${FUNCTION_URL}"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Cost Estimation
|
|
124
|
+
|
|
125
|
+
### Development Environment
|
|
126
|
+
|
|
127
|
+
**Cloud Functions (2nd gen)**:
|
|
128
|
+
- Invocations: 2M/month = Free (2M free tier)
|
|
129
|
+
- Compute time: 400,000 GB-s/month = Free (free tier)
|
|
130
|
+
- Networking: 5 GB egress = Free (1 GB free, then $0.12/GB)
|
|
131
|
+
- **Total**: $0/month (within free tier)
|
|
132
|
+
|
|
133
|
+
**Firestore**:
|
|
134
|
+
- Stored data: 1 GB = Free (1 GB free tier)
|
|
135
|
+
- Document reads: 50K/day = Free (50K free tier)
|
|
136
|
+
- Document writes: 20K/day = Free (20K free tier)
|
|
137
|
+
- Document deletes: 20K/day = Free (20K free tier)
|
|
138
|
+
- **Total**: $0/month (within free tier)
|
|
139
|
+
|
|
140
|
+
**Cloud Storage**:
|
|
141
|
+
- Storage: < 5 GB = Free (5 GB free tier)
|
|
142
|
+
- Class A operations: Minimal cost
|
|
143
|
+
- Class B operations: Free (50K free tier)
|
|
144
|
+
- **Total**: $0/month (within free tier)
|
|
145
|
+
|
|
146
|
+
**Total Monthly Cost (Dev)**: $0/month
|
|
147
|
+
|
|
148
|
+
{{#if (eq environment "prod")}}
|
|
149
|
+
### Production Environment (Estimated)
|
|
150
|
+
|
|
151
|
+
**Note**: Production costs depend on actual usage. Estimate above assumes:
|
|
152
|
+
- 10M requests/month
|
|
153
|
+
- 5 GB Firestore storage
|
|
154
|
+
- 100K document writes/day
|
|
155
|
+
|
|
156
|
+
For accurate production estimates, use [GCP Pricing Calculator](https://cloud.google.com/products/calculator).
|
|
157
|
+
{{/if}}
|
|
158
|
+
|
|
159
|
+
## Free Tier Optimization Tips
|
|
160
|
+
|
|
161
|
+
1. **Cloud Functions**:
|
|
162
|
+
- Keep min_instances = 0 to scale to zero
|
|
163
|
+
- Use 256 MB memory (good balance of performance/cost)
|
|
164
|
+
- Set appropriate timeout (avoid long-running functions)
|
|
165
|
+
- Stay under 2M invocations/month for free tier
|
|
166
|
+
|
|
167
|
+
2. **Firestore**:
|
|
168
|
+
- Use composite indexes wisely (counts against storage)
|
|
169
|
+
- Batch writes when possible (reduces write operations)
|
|
170
|
+
- Use server-side timestamps (avoids extra writes)
|
|
171
|
+
- Monitor read/write quota in console
|
|
172
|
+
|
|
173
|
+
3. **Cloud Storage**:
|
|
174
|
+
- Store only function source code (minimal storage)
|
|
175
|
+
- Use lifecycle policies to delete old versions
|
|
176
|
+
- Stay under 5 GB for free tier
|
|
177
|
+
|
|
178
|
+
4. **Networking**:
|
|
179
|
+
- Minimize egress (first 1 GB free)
|
|
180
|
+
- Use Cloud CDN for static assets
|
|
181
|
+
- Keep responses small
|
|
182
|
+
|
|
183
|
+
## Monitoring
|
|
184
|
+
|
|
185
|
+
**Cloud Logging** and **Cloud Monitoring** are enabled by default.
|
|
186
|
+
|
|
187
|
+
View logs:
|
|
188
|
+
```bash
|
|
189
|
+
gcloud functions logs read {{functionName}} \
|
|
190
|
+
--region={{region}} \
|
|
191
|
+
--limit=50
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
View metrics in Cloud Console:
|
|
195
|
+
```
|
|
196
|
+
https://console.cloud.google.com/functions/details/{{region}}/{{functionName}}?project={{projectId}}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Key metrics to monitor:
|
|
200
|
+
- Invocation count
|
|
201
|
+
- Execution time (p50, p95, p99)
|
|
202
|
+
- Error count and error rate
|
|
203
|
+
- Active instances
|
|
204
|
+
- Memory usage
|
|
205
|
+
|
|
206
|
+
## Security Best Practices
|
|
207
|
+
|
|
208
|
+
1. **Service Account**: Function uses dedicated Service Account
|
|
209
|
+
- ✅ Least privilege principle (only Firestore access)
|
|
210
|
+
- ✅ No default compute service account
|
|
211
|
+
|
|
212
|
+
2. **Secrets Management**:
|
|
213
|
+
{{#if enableSecretManager}}
|
|
214
|
+
- ✅ Secret Manager enabled
|
|
215
|
+
- Store sensitive config in Secret Manager
|
|
216
|
+
- Access via `google_secret_manager_secret_version` data source
|
|
217
|
+
{{else}}
|
|
218
|
+
- ⚠️ Secret Manager not enabled
|
|
219
|
+
- Enable with `enableSecretManager = true`
|
|
220
|
+
{{/if}}
|
|
221
|
+
|
|
222
|
+
3. **HTTPS Only**: Function enforces HTTPS
|
|
223
|
+
4. **CORS**: Configured for origins: {{corsOrigins}}
|
|
224
|
+
5. **Network Security**:
|
|
225
|
+
{{#if enableVpc}}
|
|
226
|
+
- ✅ VPC Connector enabled for private networking
|
|
227
|
+
{{else}}
|
|
228
|
+
- ⚠️ Public internet access (no VPC)
|
|
229
|
+
- Enable with `enableVpc = true`
|
|
230
|
+
{{/if}}
|
|
231
|
+
|
|
232
|
+
6. **IAM**: Function allows unauthenticated invocations
|
|
233
|
+
- ⚠️ Change `allUsers` to specific members for private APIs
|
|
234
|
+
- Use Cloud Armor for DDoS protection (production)
|
|
235
|
+
|
|
236
|
+
## Cleanup
|
|
237
|
+
|
|
238
|
+
To destroy all resources:
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
terraform destroy
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**Warning**: This will permanently delete:
|
|
245
|
+
- Cloud Function and all code
|
|
246
|
+
- Firestore database and all data
|
|
247
|
+
- Storage bucket and all objects
|
|
248
|
+
- Service Account
|
|
249
|
+
|
|
250
|
+
## Troubleshooting
|
|
251
|
+
|
|
252
|
+
### "Project not found"
|
|
253
|
+
- Ensure GCP project exists and billing is enabled
|
|
254
|
+
- Run `gcloud config set project {{projectId}}`
|
|
255
|
+
- Verify with `gcloud projects describe {{projectId}}`
|
|
256
|
+
|
|
257
|
+
### "API not enabled"
|
|
258
|
+
- APIs are enabled automatically by Terraform
|
|
259
|
+
- If issues persist, manually enable:
|
|
260
|
+
```bash
|
|
261
|
+
gcloud services enable cloudfunctions.googleapis.com
|
|
262
|
+
gcloud services enable cloudbuild.googleapis.com
|
|
263
|
+
gcloud services enable firestore.googleapis.com
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### "Insufficient permissions"
|
|
267
|
+
- Ensure you have `roles/editor` or `roles/owner` on project
|
|
268
|
+
- Check with: `gcloud projects get-iam-policy {{projectId}}`
|
|
269
|
+
|
|
270
|
+
### "function-source.zip not found"
|
|
271
|
+
- Create zip file from your function source code:
|
|
272
|
+
```bash
|
|
273
|
+
cd ../src
|
|
274
|
+
zip -r ../infrastructure/function-source.zip .
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### "Function not responding"
|
|
278
|
+
- Check Cloud Logging for errors
|
|
279
|
+
- Verify function code has correct entry point
|
|
280
|
+
- Check CORS settings if calling from browser
|
|
281
|
+
|
|
282
|
+
## Next Steps
|
|
283
|
+
|
|
284
|
+
1. **Deploy your function code** (see step 4-5 above)
|
|
285
|
+
2. **Set up CI/CD** with Cloud Build or GitHub Actions
|
|
286
|
+
3. **Configure custom domains** for production
|
|
287
|
+
4. **Set up monitoring alerts** in Cloud Monitoring
|
|
288
|
+
5. **Enable Cloud Armor** for DDoS protection (production)
|
|
289
|
+
|
|
290
|
+
## Support
|
|
291
|
+
|
|
292
|
+
- **GCP Documentation**: https://cloud.google.com/functions/docs
|
|
293
|
+
- **Terraform GCP Provider**: https://registry.terraform.io/providers/hashicorp/google/
|
|
294
|
+
- **SpecWeave**: https://spec-weave.com
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
**Generated**: {{currentDate}}
|
|
299
|
+
**SpecWeave Version**: {{specweaveVersion}}
|
package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/environments/dev.tfvars.hbs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Development Environment Variables for GCP Cloud Functions + Firestore
|
|
2
|
+
# Generated by SpecWeave Serverless Architecture Intelligence
|
|
3
|
+
|
|
4
|
+
project_id = "{{projectId}}"
|
|
5
|
+
region = "us-central1"
|
|
6
|
+
function_name = "{{projectName}}-dev-function"
|
|
7
|
+
runtime = "{{runtime}}"
|
|
8
|
+
entry_point = "{{entryPoint}}"
|
|
9
|
+
memory_mb = 256 # Free tier: up to 2M GB-s/month
|
|
10
|
+
timeout_seconds = 60
|
|
11
|
+
min_instances = 0 # Scale to zero for cost savings
|
|
12
|
+
max_instances = 10 # Limit for dev environment
|
|
13
|
+
environment = "dev"
|
|
14
|
+
|
|
15
|
+
# Firestore (free tier: 1 GB storage, 50K reads/day, 20K writes/day)
|
|
16
|
+
database_id = "(default)"
|
|
17
|
+
collection_id = "{{collectionId}}"
|
|
18
|
+
|
|
19
|
+
# Service Account
|
|
20
|
+
service_account_id = "{{projectName}}-dev-sa"
|
|
21
|
+
|
|
22
|
+
# CORS (allow all for development)
|
|
23
|
+
cors_origins = ["*"]
|
|
24
|
+
|
|
25
|
+
# Storage Bucket
|
|
26
|
+
bucket_name = "{{projectName}}-dev-source"
|
|
27
|
+
bucket_location = "US" # Multi-region for better availability
|
|
28
|
+
|
|
29
|
+
# Project tagging
|
|
30
|
+
project_name = "{{projectName}}"
|
|
31
|
+
|
|
32
|
+
# Free tier optimization
|
|
33
|
+
# - min_instances = 0 (scale to zero, no idle cost)
|
|
34
|
+
# - memory_mb = 256 (within free tier compute limits)
|
|
35
|
+
# - timeout_seconds = 60 (avoid long-running functions)
|
|
36
|
+
# - max_instances = 10 (prevent runaway costs)
|
package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/environments/prod.tfvars.hbs
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Production Environment Variables for GCP Cloud Functions + Firestore
|
|
2
|
+
# Generated by SpecWeave Serverless Architecture Intelligence
|
|
3
|
+
|
|
4
|
+
project_id = "{{projectId}}"
|
|
5
|
+
region = "us-central1"
|
|
6
|
+
function_name = "{{projectName}}-prod-function"
|
|
7
|
+
runtime = "{{runtime}}"
|
|
8
|
+
entry_point = "{{entryPoint}}"
|
|
9
|
+
memory_mb = 1024 # Production-grade memory
|
|
10
|
+
timeout_seconds = 300 # 5 minutes max
|
|
11
|
+
min_instances = 3 # Keep 3 instances warm for low latency
|
|
12
|
+
max_instances = 200 # Handle production traffic
|
|
13
|
+
environment = "prod"
|
|
14
|
+
|
|
15
|
+
# Firestore
|
|
16
|
+
database_id = "(default)"
|
|
17
|
+
collection_id = "{{collectionId}}"
|
|
18
|
+
|
|
19
|
+
# Service Account
|
|
20
|
+
service_account_id = "{{projectName}}-prod-sa"
|
|
21
|
+
|
|
22
|
+
# CORS (restrict to production domain only)
|
|
23
|
+
cors_origins = ["https://{{projectName}}.com"]
|
|
24
|
+
|
|
25
|
+
# Storage Bucket
|
|
26
|
+
bucket_name = "{{projectName}}-prod-source"
|
|
27
|
+
bucket_location = "US"
|
|
28
|
+
|
|
29
|
+
# Project tagging
|
|
30
|
+
project_name = "{{projectName}}"
|
|
31
|
+
|
|
32
|
+
# Concurrency settings
|
|
33
|
+
enable_concurrency = true
|
|
34
|
+
max_concurrent_requests = 80
|
|
35
|
+
|
|
36
|
+
# Production features (uncomment to enable)
|
|
37
|
+
# enable_secret_manager = true
|
|
38
|
+
# enable_vpc = true
|
|
39
|
+
# vpc_network = "my-vpc"
|
|
40
|
+
|
|
41
|
+
# Production optimizations
|
|
42
|
+
# - min_instances = 3 (eliminate cold starts)
|
|
43
|
+
# - memory_mb = 1024 (better performance, handles concurrent requests)
|
|
44
|
+
# - timeout_seconds = 300 (handle complex operations)
|
|
45
|
+
# - max_instances = 200 (auto-scale for traffic spikes)
|
|
46
|
+
# - enable_concurrency = true (maximize instance utilization)
|
|
47
|
+
# - enable_secret_manager = true (secure secrets management)
|
|
48
|
+
# - enable_vpc = true (private networking)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Staging Environment Variables for GCP Cloud Functions + Firestore
|
|
2
|
+
# Generated by SpecWeave Serverless Architecture Intelligence
|
|
3
|
+
|
|
4
|
+
project_id = "{{projectId}}"
|
|
5
|
+
region = "us-central1"
|
|
6
|
+
function_name = "{{projectName}}-staging-function"
|
|
7
|
+
runtime = "{{runtime}}"
|
|
8
|
+
entry_point = "{{entryPoint}}"
|
|
9
|
+
memory_mb = 512 # Higher memory for better performance
|
|
10
|
+
timeout_seconds = 120
|
|
11
|
+
min_instances = 1 # Keep 1 instance warm
|
|
12
|
+
max_instances = 50 # Higher limit for staging tests
|
|
13
|
+
environment = "staging"
|
|
14
|
+
|
|
15
|
+
# Firestore
|
|
16
|
+
database_id = "(default)"
|
|
17
|
+
collection_id = "{{collectionId}}"
|
|
18
|
+
|
|
19
|
+
# Service Account
|
|
20
|
+
service_account_id = "{{projectName}}-staging-sa"
|
|
21
|
+
|
|
22
|
+
# CORS (restrict to staging domain)
|
|
23
|
+
cors_origins = ["https://staging.{{projectName}}.com"]
|
|
24
|
+
|
|
25
|
+
# Storage Bucket
|
|
26
|
+
bucket_name = "{{projectName}}-staging-source"
|
|
27
|
+
bucket_location = "US"
|
|
28
|
+
|
|
29
|
+
# Project tagging
|
|
30
|
+
project_name = "{{projectName}}"
|
|
31
|
+
|
|
32
|
+
# Concurrency settings (2nd gen feature)
|
|
33
|
+
enable_concurrency = true
|
|
34
|
+
max_concurrent_requests = 80
|
|
35
|
+
|
|
36
|
+
# Staging optimizations
|
|
37
|
+
# - min_instances = 1 (reduce cold starts)
|
|
38
|
+
# - memory_mb = 512 (better performance than dev)
|
|
39
|
+
# - timeout_seconds = 120 (allow longer-running operations)
|
|
40
|
+
# - max_instances = 50 (handle load testing)
|
|
41
|
+
# - enable_concurrency = true (better resource utilization)
|