@factiii/stack 0.1.203 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -364
- package/dist/plugins/addons/auth/index.d.ts.map +1 -1
- package/dist/plugins/addons/auth/index.js +24 -5
- package/dist/plugins/addons/auth/index.js.map +1 -1
- package/dist/plugins/addons/auth/scanfix/secrets.d.ts +3 -0
- package/dist/plugins/addons/auth/scanfix/secrets.d.ts.map +1 -1
- package/dist/plugins/addons/auth/scanfix/secrets.js +54 -19
- package/dist/plugins/addons/auth/scanfix/secrets.js.map +1 -1
- package/dist/plugins/addons/auth/scanfix/validate.d.ts +3 -0
- package/dist/plugins/addons/auth/scanfix/validate.d.ts.map +1 -1
- package/dist/plugins/addons/auth/scanfix/validate.js +37 -18
- package/dist/plugins/addons/auth/scanfix/validate.js.map +1 -1
- package/dist/utils/ssh-helper.d.ts.map +1 -1
- package/dist/utils/ssh-helper.js +89 -41
- package/dist/utils/ssh-helper.js.map +1 -1
- package/package.json +6 -13
package/README.md
CHANGED
|
@@ -1,402 +1,94 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @factiii/stack
|
|
2
2
|
|
|
3
|
-
Infrastructure management CLI
|
|
3
|
+
Infrastructure management CLI. Scan, fix, and deploy Node.js apps to AWS with Docker, Nginx, and GitHub Actions.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
# Install in your project
|
|
9
8
|
npm install @factiii/stack
|
|
10
|
-
|
|
11
|
-
# Initialize configuration (run this first!)
|
|
12
|
-
npx stack init
|
|
13
|
-
|
|
14
|
-
# This creates:
|
|
15
|
-
# - stack.yml (user-editable config)
|
|
16
|
-
# - stackAuto.yml (auto-detected config)
|
|
17
|
-
# - .github/workflows/ (CI/CD workflows)
|
|
18
|
-
|
|
19
|
-
# Edit stack.yml to replace EXAMPLE_ values
|
|
20
|
-
# Then run:
|
|
21
|
-
npx stack scan # Check for issues
|
|
22
|
-
npx stack fix # Auto-fix issues
|
|
23
|
-
npx stack deploy --staging # Deploy to staging
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## How It Works
|
|
27
|
-
|
|
28
|
-
Stack uses a **plugin-based architecture** where each plugin:
|
|
29
|
-
1. Defines its own configuration schema
|
|
30
|
-
2. Auto-detects project settings
|
|
31
|
-
3. Validates and fixes issues
|
|
32
|
-
4. Handles deployment for its domain
|
|
33
|
-
|
|
34
|
-
### The Two Config Files
|
|
35
|
-
|
|
36
|
-
**`stack.yml`** - User-Editable Configuration
|
|
37
|
-
```yaml
|
|
38
|
-
name: my-app
|
|
39
|
-
|
|
40
|
-
# Environment configurations
|
|
41
|
-
staging:
|
|
42
|
-
domain: staging.myapp.com
|
|
43
|
-
server: mac # OS type: mac, ubuntu, windows, amazon-linux
|
|
44
|
-
server_mode: true # Enable server hardening (default: true)
|
|
45
|
-
|
|
46
|
-
prod:
|
|
47
|
-
domain: myapp.com
|
|
48
|
-
server: ubuntu # OS type for production
|
|
49
|
-
pipeline: aws # Use AWS pipeline for deployment
|
|
50
|
-
config: free-tier # AWS tier: ec2, free-tier, standard, enterprise
|
|
51
|
-
access_key_id: AKIAXXXXXXXX
|
|
52
|
-
region: us-east-1
|
|
53
|
-
|
|
54
|
-
prisma:
|
|
55
|
-
schema_path: null # Optional override
|
|
56
|
-
version: null # Optional override
|
|
57
|
-
|
|
58
|
-
# Exclude Docker containers from unmanaged container cleanup
|
|
59
|
-
container_exclusions:
|
|
60
|
-
- factiii_postgres
|
|
61
|
-
- legacy_container
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
**`stackAuto.yml`** - Auto-Detected Configuration
|
|
65
|
-
```yaml
|
|
66
|
-
# Auto-detected by plugins
|
|
67
|
-
factiii_version: 1.0.0
|
|
68
|
-
has_prisma: true
|
|
69
|
-
has_trpc: true
|
|
70
|
-
prisma_schema: prisma/schema.prisma
|
|
71
|
-
prisma_version: 5.0.0
|
|
72
|
-
ssh_user: ubuntu
|
|
73
|
-
dockerfile: Dockerfile
|
|
74
|
-
package_manager: pnpm
|
|
75
|
-
node_version: 20
|
|
76
|
-
pnpm_version: 9
|
|
77
|
-
aws_cli_installed: true
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## CLI Commands
|
|
81
|
-
|
|
82
|
-
### Init (Run This First!)
|
|
83
|
-
|
|
84
|
-
Scans your project and generates configuration files:
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
npx stack init # Initialize Stack
|
|
88
|
-
npx stack init --force # Regenerate configs
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
**What it does:**
|
|
92
|
-
- Detects which plugins are relevant to your project
|
|
93
|
-
- Generates `stack.yml` with only relevant sections
|
|
94
|
-
- Generates `stackAuto.yml` with auto-detected values
|
|
95
|
-
- Creates GitHub Actions workflows
|
|
96
|
-
|
|
97
|
-
### Scan
|
|
98
|
-
|
|
99
|
-
Checks all environments for issues:
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
npx stack scan # Scan all (dev, secrets, staging, prod)
|
|
103
|
-
npx stack scan --dev # Scan dev only
|
|
104
|
-
npx stack scan --staging # Scan staging only
|
|
105
|
-
npx stack scan --prod # Scan prod only
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
**Note:** Requires `stack.yml` (or legacy factiii.yml) to exist. Run `npx stack init` first.
|
|
109
|
-
|
|
110
|
-
### Fix
|
|
111
|
-
|
|
112
|
-
Automatically fixes issues where possible:
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
npx stack fix # Fix all environments
|
|
116
|
-
npx stack fix --dev # Fix dev only
|
|
117
|
-
npx stack fix --staging # Fix staging only
|
|
118
|
-
npx stack fix --prod # Fix prod only
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
**Note:** Requires `stack.yml` (or legacy factiii.yml) to exist. Run `npx stack init` first.
|
|
122
|
-
|
|
123
|
-
### Deploy
|
|
124
|
-
|
|
125
|
-
Deploys to environments (runs scan first, aborts on issues):
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
npx stack deploy --dev # Start local dev containers
|
|
129
|
-
npx stack deploy --staging # Deploy to staging server
|
|
130
|
-
npx stack deploy --prod # Deploy to production server
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
**Note:** Requires `stack.yml` (or legacy factiii.yml) to exist. Run `npx stack init` first.
|
|
134
|
-
|
|
135
|
-
### AWS EC2 Deployment (2 Commands)
|
|
136
|
-
|
|
137
|
-
Deploy your full-stack app to AWS EC2 with just two commands:
|
|
138
|
-
|
|
139
|
-
```bash
|
|
140
|
-
# 1. Provision all AWS infrastructure
|
|
141
|
-
npx factiii fix
|
|
142
|
-
|
|
143
|
-
# Creates: VPC, Security Groups, EC2 instance, RDS database,
|
|
144
|
-
# S3 bucket, ECR repository, IAM users, SES email
|
|
145
|
-
|
|
146
|
-
# 2. Deploy your application
|
|
147
|
-
npx factiii deploy --prod
|
|
148
|
-
|
|
149
|
-
# Configures: Docker, Nginx, SSL certificates, pulls images, starts containers
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
**Prerequisites:** You need an IAM user with the `factiii-bootstrap` policy configured via `aws configure`.
|
|
153
|
-
|
|
154
|
-
See [docs/aws-setup-guide.md](docs/aws-setup-guide.md) for the full step-by-step setup guide including the IAM policy JSON.
|
|
155
|
-
|
|
156
|
-
### Secrets Management
|
|
157
|
-
|
|
158
|
-
Manage secrets via Ansible Vault and deploy them directly to servers:
|
|
159
|
-
|
|
160
|
-
```bash
|
|
161
|
-
# List all secrets (SSH keys + environment variables)
|
|
162
|
-
npx stack deploy --secrets list
|
|
163
|
-
|
|
164
|
-
# Set SSH keys (required for deployment)
|
|
165
|
-
npx stack deploy --secrets set STAGING_SSH
|
|
166
|
-
npx stack deploy --secrets set PROD_SSH
|
|
167
|
-
|
|
168
|
-
# Set environment variables for each stage
|
|
169
|
-
npx stack deploy --secrets set-env DATABASE_URL --staging
|
|
170
|
-
npx stack deploy --secrets set-env JWT_SECRET --staging
|
|
171
|
-
npx stack deploy --secrets set-env DATABASE_URL --prod
|
|
172
|
-
npx stack deploy --secrets set-env JWT_SECRET --prod
|
|
173
|
-
|
|
174
|
-
# List environment variables
|
|
175
|
-
npx stack deploy --secrets list-env --staging
|
|
176
|
-
npx stack deploy --secrets list-env --prod
|
|
177
|
-
|
|
178
|
-
# Deploy secrets to servers via SSH
|
|
179
|
-
npx stack deploy --secrets deploy --staging # Deploy to staging server
|
|
180
|
-
npx stack deploy --secrets deploy --prod # Deploy to production server
|
|
181
|
-
npx stack deploy --secrets deploy --all # Deploy to all servers
|
|
182
|
-
|
|
183
|
-
# Options
|
|
184
|
-
npx stack deploy --secrets deploy --staging --restart # Restart container after deploy
|
|
185
|
-
npx stack deploy --secrets deploy --staging --dry-run # Show what would be deployed
|
|
186
9
|
```
|
|
187
10
|
|
|
188
|
-
|
|
189
|
-
1. Secrets are stored locally in Ansible Vault (encrypted)
|
|
190
|
-
2. When you run `secrets deploy`, Factiii:
|
|
191
|
-
- Reads the SSH key from the vault
|
|
192
|
-
- Connects to the server via SSH
|
|
193
|
-
- Writes a `.env.{stage}` file with your environment variables
|
|
194
|
-
3. Your application reads the `.env.{stage}` file on startup
|
|
195
|
-
|
|
196
|
-
**Note:** Requires `stack.yml` with Ansible Vault configured. Run `npx stack init` first.
|
|
197
|
-
|
|
198
|
-
## Stage Execution
|
|
199
|
-
|
|
200
|
-
Stack commands work with four stages: `dev`, `secrets`, `staging`, `prod`.
|
|
201
|
-
|
|
202
|
-
### Running Commands
|
|
203
|
-
|
|
204
|
-
```bash
|
|
205
|
-
npx stack scan # Scan all reachable stages
|
|
206
|
-
npx stack scan --dev # Scan only dev stage
|
|
207
|
-
npx stack scan --staging # Scan only staging stage
|
|
208
|
-
|
|
209
|
-
npx stack fix # Fix all reachable stages
|
|
210
|
-
npx stack fix --staging # Fix only staging stage
|
|
211
|
-
|
|
212
|
-
npx stack deploy --staging # Deploy to staging
|
|
213
|
-
npx stack deploy --prod # Deploy to prod
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### How Stages Are Reached
|
|
217
|
-
|
|
218
|
-
The pipeline plugin decides how to reach each stage:
|
|
219
|
-
|
|
220
|
-
| Stage | How it's reached |
|
|
221
|
-
|-------|------------------|
|
|
222
|
-
| dev | Always runs locally |
|
|
223
|
-
| secrets | Runs locally (needs Ansible Vault configured) |
|
|
224
|
-
| staging | Via workflow → SSH → runs with `--staging` |
|
|
225
|
-
| prod | Via workflow → SSH → runs with `--prod` |
|
|
226
|
-
|
|
227
|
-
### For Pipeline Plugin Authors
|
|
228
|
-
|
|
229
|
-
When your CI/CD workflow SSHs to a server to run commands, you **MUST** specify the stage:
|
|
11
|
+
## Quick Start
|
|
230
12
|
|
|
231
13
|
```bash
|
|
232
|
-
#
|
|
233
|
-
|
|
234
|
-
npx stack
|
|
14
|
+
npx stack # Self-bootstrap + scan
|
|
15
|
+
npx stack init # First-time vault/secrets setup
|
|
16
|
+
npx stack scan --dev # Read-only issue detection
|
|
17
|
+
npx stack fix --dev # Auto-fix detected issues
|
|
18
|
+
npx stack deploy --staging # Scan then deploy
|
|
235
19
|
```
|
|
236
20
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
See [STANDARDS.md](STANDARDS.md) for full documentation of the stage execution pattern.
|
|
240
|
-
|
|
241
|
-
## Plugin Architecture
|
|
242
|
-
|
|
243
|
-
### Built-in Plugins
|
|
21
|
+
## Commands
|
|
244
22
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
23
|
+
| Command | Description |
|
|
24
|
+
|---------|-------------|
|
|
25
|
+
| `npx stack` | Self-bootstrap + scan (default) |
|
|
26
|
+
| `npx stack init` | First-time vault/secrets setup |
|
|
27
|
+
| `npx stack scan [--stage]` | Read-only issue detection |
|
|
28
|
+
| `npx stack fix [--stage]` | Auto-fix detected issues |
|
|
29
|
+
| `npx stack deploy --<stage>` | Scan then deploy |
|
|
30
|
+
| `npx stack deploy --secrets <action>` | Manage Ansible Vault secrets |
|
|
31
|
+
| `npx stack db <cmd> --<stage>` | Database operations (migrate, seed, reset, status) |
|
|
32
|
+
| `npx stack ops <cmd> --<stage>` | Server operations (logs, restart, shell, status) |
|
|
33
|
+
| `npx stack backup <cmd> --<stage>` | Database backup/restore |
|
|
34
|
+
| `npx stack dev-reset [--dry-run]` | Reset local config/secrets for fresh bootstrap |
|
|
248
35
|
|
|
249
|
-
|
|
250
|
-
- `mac` - macOS (Homebrew, launchctl)
|
|
251
|
-
- `ubuntu` - Ubuntu Linux (apt, systemd)
|
|
252
|
-
- `windows` - Windows Server (Chocolatey) - template
|
|
253
|
-
- `amazon-linux` - Amazon Linux 2023 (dnf, systemd)
|
|
254
|
-
|
|
255
|
-
**Frameworks**
|
|
256
|
-
- `prisma-trpc` - Prisma database + tRPC API
|
|
257
|
-
|
|
258
|
-
**Addons**
|
|
259
|
-
- `server-mode` - Configure machines as deployment servers (disable sleep, enable SSH, etc.)
|
|
260
|
-
|
|
261
|
-
### How Plugins Work
|
|
262
|
-
|
|
263
|
-
Each plugin defines:
|
|
264
|
-
|
|
265
|
-
```javascript
|
|
266
|
-
class MyPlugin {
|
|
267
|
-
static id = 'my-plugin';
|
|
268
|
-
static category = 'framework'; // or: pipeline, server, addon
|
|
269
|
-
|
|
270
|
-
// Schema for factiii.yml (user-editable)
|
|
271
|
-
static configSchema = {
|
|
272
|
-
my_plugin: {
|
|
273
|
-
setting: 'default-value'
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
// Schema for factiiiAuto.yml (auto-detected)
|
|
278
|
-
static autoConfigSchema = {
|
|
279
|
-
has_my_plugin: 'boolean',
|
|
280
|
-
my_plugin_version: 'string'
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
// Auto-detect configuration
|
|
284
|
-
static async detectConfig(rootDir) {
|
|
285
|
-
return {
|
|
286
|
-
has_my_plugin: true,
|
|
287
|
-
my_plugin_version: '1.0.0'
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// Fixes array - issues this plugin can detect and resolve
|
|
292
|
-
static fixes = [
|
|
293
|
-
{
|
|
294
|
-
id: 'missing-config',
|
|
295
|
-
stage: 'dev',
|
|
296
|
-
severity: 'critical',
|
|
297
|
-
description: 'Configuration missing',
|
|
298
|
-
scan: async (config, rootDir) => {
|
|
299
|
-
// Return true if problem exists
|
|
300
|
-
return !config.my_plugin;
|
|
301
|
-
},
|
|
302
|
-
fix: async (config, rootDir) => {
|
|
303
|
-
// Auto-fix the problem
|
|
304
|
-
return true;
|
|
305
|
-
},
|
|
306
|
-
manualFix: 'Add my_plugin config to factiii.yml'
|
|
307
|
-
}
|
|
308
|
-
];
|
|
309
|
-
|
|
310
|
-
// Deploy method
|
|
311
|
-
async deploy(config, environment) {
|
|
312
|
-
// Handle deployment for this environment
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
```
|
|
36
|
+
## Stages
|
|
316
37
|
|
|
317
|
-
|
|
38
|
+
`--dev`, `--secrets`, `--staging`, `--prod`
|
|
318
39
|
|
|
319
|
-
|
|
40
|
+
Routing priority:
|
|
41
|
+
1. `dev` / `secrets` → always runs locally
|
|
42
|
+
2. `staging` / `prod` → tries SSH key (`~/.ssh/{stage}_deploy_key`) → falls back to GitHub Actions workflow → unreachable
|
|
320
43
|
|
|
321
|
-
|
|
322
|
-
# .github/workflows/factiii-staging.yml
|
|
323
|
-
- name: Deploy via CLI
|
|
324
|
-
run: |
|
|
325
|
-
ssh user@host << EOF
|
|
326
|
-
cd ~/.factiii/my-app
|
|
327
|
-
git pull
|
|
328
|
-
GITHUB_ACTIONS=true npx stack deploy --staging
|
|
329
|
-
EOF
|
|
330
|
-
```
|
|
44
|
+
## Config Files
|
|
331
45
|
|
|
332
|
-
|
|
46
|
+
| File | Purpose | Editable By |
|
|
47
|
+
|------|---------|-------------|
|
|
48
|
+
| `stack.yml` | Manual settings (committed) | User |
|
|
49
|
+
| `stackAuto.yml` | Auto-detected settings | Stack CLI |
|
|
50
|
+
| `stack.local.yml` | Per-developer overrides (gitignored) | User |
|
|
333
51
|
|
|
334
|
-
|
|
52
|
+
Legacy `factiii.yml` is also supported.
|
|
335
53
|
|
|
336
|
-
##
|
|
54
|
+
## Plugins
|
|
337
55
|
|
|
338
|
-
|
|
56
|
+
**Pipelines** — CI/CD routing: `factiii`, `aws`
|
|
339
57
|
|
|
340
|
-
|
|
341
|
-
ansible:
|
|
342
|
-
vault_path: group_vars/all/vault.yml
|
|
343
|
-
vault_password_file: ~/.vault_pass # or set ANSIBLE_VAULT_PASSWORD env var
|
|
344
|
-
```
|
|
58
|
+
**Servers** — OS-specific commands: `mac`, `ubuntu`, `windows`, `amazon-linux`
|
|
345
59
|
|
|
346
|
-
**
|
|
60
|
+
**Frameworks** — App scaffolding: `prisma-trpc`, `expo`
|
|
347
61
|
|
|
348
|
-
**
|
|
62
|
+
**Addons** — Extensions: `server-mode` (hardening), `openclaw` (AI agent), `auth` (@factiii/auth integration)
|
|
349
63
|
|
|
350
|
-
|
|
64
|
+
Plugins auto-detect from your project. No manual registration needed.
|
|
351
65
|
|
|
352
|
-
##
|
|
66
|
+
## AWS Strategy
|
|
353
67
|
|
|
354
|
-
|
|
68
|
+
Two IAM users per project:
|
|
69
|
+
- **Dev account** (dev + staging): `factiii-{project}-dev`
|
|
70
|
+
- **Prod account** (prod only): `factiii-{project}-prod`
|
|
355
71
|
|
|
356
|
-
|
|
357
|
-
class MyPlugin {
|
|
358
|
-
static requiredEnvVars = ['DATABASE_URL', 'API_KEY'];
|
|
359
|
-
}
|
|
360
|
-
```
|
|
72
|
+
Provisioning covers EC2, RDS, VPC, ECR, Route 53, and S3.
|
|
361
73
|
|
|
362
|
-
|
|
363
|
-
- `.env.example` (template, committed to git)
|
|
364
|
-
- `.env` (local dev, gitignored, auto-created from example)
|
|
365
|
-
- `.env.staging` (staging values, user creates)
|
|
366
|
-
- `.env.prod` (production values, user creates)
|
|
74
|
+
## Deployment Flow
|
|
367
75
|
|
|
368
|
-
|
|
76
|
+
1. `npx stack` — bootstrap (installs deps, detects frameworks, generates config)
|
|
77
|
+
2. `npx stack init` — create vault, store secrets
|
|
78
|
+
3. `npx stack fix --staging` — provision infrastructure, push workflows
|
|
79
|
+
4. `npx stack deploy --staging` — scan, build, deploy via SSH or GitHub Actions
|
|
369
80
|
|
|
370
|
-
|
|
81
|
+
Workflows are ultra-thin: trigger + secrets + SSH + CLI call. No setup/clone/build logic in CI.
|
|
371
82
|
|
|
372
83
|
```yaml
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
config: free-tier # Choose your bundle
|
|
376
|
-
region: us-east-1
|
|
377
|
-
```
|
|
378
|
-
|
|
379
|
-
**Available Bundles:**
|
|
380
|
-
- `ec2` - Basic EC2 instance
|
|
381
|
-
- `free-tier` - Complete free tier (EC2 + RDS + S3 + ECR)
|
|
382
|
-
- `standard` - Production-ready setup (coming soon)
|
|
383
|
-
- `enterprise` - HA, multi-AZ, auto-scaling (coming soon)
|
|
384
|
-
|
|
385
|
-
## External Plugins
|
|
386
|
-
|
|
387
|
-
Install external plugins via npm:
|
|
388
|
-
|
|
389
|
-
```bash
|
|
390
|
-
npm install @factiii/stack-plugin-nextjs
|
|
84
|
+
ssh -i ~/.ssh/deploy_key "$USER@$HOST" \
|
|
85
|
+
"GITHUB_ACTIONS=true npx stack deploy --staging"
|
|
391
86
|
```
|
|
392
87
|
|
|
393
|
-
|
|
394
|
-
- `@factiii/stack-plugin-*`
|
|
395
|
-
- Listed in `factiii.yml` under `plugins`
|
|
396
|
-
|
|
397
|
-
## Development
|
|
88
|
+
## Requirements
|
|
398
89
|
|
|
399
|
-
|
|
90
|
+
- Node.js >= 18.0.0
|
|
91
|
+
- pnpm, npm, or yarn
|
|
400
92
|
|
|
401
93
|
## License
|
|
402
94
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/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AO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAqC5E,OAAO,CAAC,OAAO,CAAgB;gBAEnB,MAAM,EAAE,aAAa;CAGlC;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -65,6 +65,22 @@ const path = __importStar(require("path"));
|
|
|
65
65
|
const setup_js_1 = require("./scanfix/setup.js");
|
|
66
66
|
const secrets_js_1 = require("./scanfix/secrets.js");
|
|
67
67
|
const validate_js_1 = require("./scanfix/validate.js");
|
|
68
|
+
/**
|
|
69
|
+
* Load the stack-plugin contract from @factiii/auth.
|
|
70
|
+
* Returns null if auth is not installed or doesn't export it.
|
|
71
|
+
*/
|
|
72
|
+
function loadAuthContract() {
|
|
73
|
+
try {
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
75
|
+
return require('@factiii/auth/stack-plugin');
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// @factiii/auth not installed or doesn't export stack-plugin
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Load the contract once at module init
|
|
83
|
+
const authContract = loadAuthContract();
|
|
68
84
|
/**
|
|
69
85
|
* Try to load scanfixes from @factiii/auth's stackPlugin export.
|
|
70
86
|
* Returns the exported fixes if available, null otherwise.
|
|
@@ -106,10 +122,12 @@ class AuthAddon {
|
|
|
106
122
|
*/
|
|
107
123
|
static compatibleServers = ['mac', 'ubuntu', 'windows'];
|
|
108
124
|
static defaultServer = 'ubuntu';
|
|
109
|
-
// Env vars this plugin requires
|
|
110
|
-
static requiredEnvVars =
|
|
111
|
-
|
|
112
|
-
|
|
125
|
+
// Env vars this plugin requires — sourced from @factiii/auth's contract
|
|
126
|
+
static requiredEnvVars = authContract
|
|
127
|
+
? [...authContract.requiredEnvVars]
|
|
128
|
+
: ['JWT_SECRET'];
|
|
129
|
+
// Schema for stack.yml (user-editable, optional) — sourced from @factiii/auth's contract
|
|
130
|
+
static configSchema = authContract?.configSchema ?? {
|
|
113
131
|
auth: {
|
|
114
132
|
features: {
|
|
115
133
|
oauth: false,
|
|
@@ -175,11 +193,12 @@ class AuthAddon {
|
|
|
175
193
|
detected.auth_installed = false;
|
|
176
194
|
}
|
|
177
195
|
// Check if auth models exist in Prisma schema
|
|
196
|
+
const modelsToCheck = authContract?.prismaModels ?? ['User', 'Session'];
|
|
178
197
|
try {
|
|
179
198
|
const schemaPath = path.join(rootDir, 'prisma', 'schema.prisma');
|
|
180
199
|
if (fs.existsSync(schemaPath)) {
|
|
181
200
|
const content = fs.readFileSync(schemaPath, 'utf8');
|
|
182
|
-
detected.auth_initialized =
|
|
201
|
+
detected.auth_initialized = modelsToCheck.every((model) => content.includes('model ' + model));
|
|
183
202
|
}
|
|
184
203
|
else {
|
|
185
204
|
detected.auth_initialized = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugins/addons/auth/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AAG7B,iFAAiF;AACjF,iDAAgD;AAChD,qDAAoD;AACpD,uDAAsD;AAEtD;;;GAGG;AACH,SAAS,iBAAiB;IACxB,IAAI,CAAC;QACH,iEAAiE;QACjE,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;QACzC,IAAI,OAAO,CAAC,WAAW,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YACpE,OAAO,OAAO,CAAC,WAAmC,CAAC;QACrD,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,4DAA4D;IAC9D,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,SAAS,SAAS;IAChB,MAAM,QAAQ,GAAG,iBAAiB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AI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;;AAGH,kBAAe,SAAS,CAAC"}
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
* Manages authentication secrets in Ansible Vault:
|
|
5
5
|
* - JWT_SECRET: auto-generated 256-bit random key
|
|
6
6
|
* - OAuth keys: prompted from user (Google, Apple)
|
|
7
|
+
*
|
|
8
|
+
* Secret names are sourced from @factiii/auth's stack-plugin contract
|
|
9
|
+
* to avoid hardcoded strings drifting out of sync.
|
|
7
10
|
*/
|
|
8
11
|
import type { Fix } from '../../../../types/index.js';
|
|
9
12
|
export declare const secretsFixes: Fix[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/addons/auth/scanfix/secrets.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/addons/auth/scanfix/secrets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAiB,GAAG,EAAE,MAAM,4BAA4B,CAAC;AA2ErE,eAAO,MAAM,YAAY,EAAE,GAAG,EA+H7B,CAAC"}
|