@swovohq/fuel 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/fuel.d.ts +3 -0
- package/dist/bin/fuel.d.ts.map +1 -0
- package/dist/bin/fuel.js +353 -0
- package/dist/bin/fuel.js.map +1 -0
- package/dist/cleanup/finalize.d.ts +11 -0
- package/dist/cleanup/finalize.d.ts.map +1 -0
- package/dist/cleanup/finalize.js +116 -0
- package/dist/cleanup/finalize.js.map +1 -0
- package/dist/commands/create-app.d.ts +14 -0
- package/dist/commands/create-app.d.ts.map +1 -0
- package/dist/commands/create-app.js +354 -0
- package/dist/commands/create-app.js.map +1 -0
- package/dist/commands/infra-deploy.d.ts +8 -0
- package/dist/commands/infra-deploy.d.ts.map +1 -0
- package/dist/commands/infra-deploy.js +102 -0
- package/dist/commands/infra-deploy.js.map +1 -0
- package/dist/commands/infra-destroy.d.ts +5 -0
- package/dist/commands/infra-destroy.d.ts.map +1 -0
- package/dist/commands/infra-destroy.js +85 -0
- package/dist/commands/infra-destroy.js.map +1 -0
- package/dist/commands/infra-init.d.ts +75 -0
- package/dist/commands/infra-init.d.ts.map +1 -0
- package/dist/commands/infra-init.js +577 -0
- package/dist/commands/infra-init.js.map +1 -0
- package/dist/commands/list-modules.d.ts +2 -0
- package/dist/commands/list-modules.d.ts.map +1 -0
- package/dist/commands/list-modules.js +71 -0
- package/dist/commands/list-modules.js.map +1 -0
- package/dist/commands/migrate-init.d.ts +6 -0
- package/dist/commands/migrate-init.d.ts.map +1 -0
- package/dist/commands/migrate-init.js +174 -0
- package/dist/commands/migrate-init.js.map +1 -0
- package/dist/engines/convention.d.ts +3 -0
- package/dist/engines/convention.d.ts.map +1 -0
- package/dist/engines/convention.js +76 -0
- package/dist/engines/convention.js.map +1 -0
- package/dist/engines/dependencies.d.ts +20 -0
- package/dist/engines/dependencies.d.ts.map +1 -0
- package/dist/engines/dependencies.js +26 -0
- package/dist/engines/dependencies.js.map +1 -0
- package/dist/engines/monorepo.d.ts +6 -0
- package/dist/engines/monorepo.d.ts.map +1 -0
- package/dist/engines/monorepo.js +56 -0
- package/dist/engines/monorepo.js.map +1 -0
- package/dist/engines/template-source.d.ts +9 -0
- package/dist/engines/template-source.d.ts.map +1 -0
- package/dist/engines/template-source.js +123 -0
- package/dist/engines/template-source.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/infra/config-loader.d.ts +4 -0
- package/dist/infra/config-loader.d.ts.map +1 -0
- package/dist/infra/config-loader.js +57 -0
- package/dist/infra/config-loader.js.map +1 -0
- package/dist/infra/config-writer.d.ts +9 -0
- package/dist/infra/config-writer.d.ts.map +1 -0
- package/dist/infra/config-writer.js +58 -0
- package/dist/infra/config-writer.js.map +1 -0
- package/dist/infra/credentials.d.ts +3 -0
- package/dist/infra/credentials.d.ts.map +1 -0
- package/dist/infra/credentials.js +74 -0
- package/dist/infra/credentials.js.map +1 -0
- package/dist/infra/dependency-checker.d.ts +9 -0
- package/dist/infra/dependency-checker.d.ts.map +1 -0
- package/dist/infra/dependency-checker.js +41 -0
- package/dist/infra/dependency-checker.js.map +1 -0
- package/dist/infra/git-client.d.ts +2 -0
- package/dist/infra/git-client.d.ts.map +1 -0
- package/dist/infra/git-client.js +22 -0
- package/dist/infra/git-client.js.map +1 -0
- package/dist/infra/github-secrets-client.d.ts +3 -0
- package/dist/infra/github-secrets-client.d.ts.map +1 -0
- package/dist/infra/github-secrets-client.js +37 -0
- package/dist/infra/github-secrets-client.js.map +1 -0
- package/dist/infra/orchestrator.d.ts +7 -0
- package/dist/infra/orchestrator.d.ts.map +1 -0
- package/dist/infra/orchestrator.js +187 -0
- package/dist/infra/orchestrator.js.map +1 -0
- package/dist/infra/preflight.d.ts +9 -0
- package/dist/infra/preflight.d.ts.map +1 -0
- package/dist/infra/preflight.js +75 -0
- package/dist/infra/preflight.js.map +1 -0
- package/dist/infra/s3-state-bucket.d.ts +5 -0
- package/dist/infra/s3-state-bucket.d.ts.map +1 -0
- package/dist/infra/s3-state-bucket.js +92 -0
- package/dist/infra/s3-state-bucket.js.map +1 -0
- package/dist/infra/secrets-manager-client.d.ts +3 -0
- package/dist/infra/secrets-manager-client.d.ts.map +1 -0
- package/dist/infra/secrets-manager-client.js +26 -0
- package/dist/infra/secrets-manager-client.js.map +1 -0
- package/dist/infra/subprocess.d.ts +5 -0
- package/dist/infra/subprocess.d.ts.map +1 -0
- package/dist/infra/subprocess.js +26 -0
- package/dist/infra/subprocess.js.map +1 -0
- package/dist/infra/template-engine.d.ts +43 -0
- package/dist/infra/template-engine.d.ts.map +1 -0
- package/dist/infra/template-engine.js +233 -0
- package/dist/infra/template-engine.js.map +1 -0
- package/dist/infra/tofu-runner.d.ts +26 -0
- package/dist/infra/tofu-runner.d.ts.map +1 -0
- package/dist/infra/tofu-runner.js +210 -0
- package/dist/infra/tofu-runner.js.map +1 -0
- package/dist/infra/types.d.ts +69 -0
- package/dist/infra/types.d.ts.map +1 -0
- package/dist/infra/types.js +44 -0
- package/dist/infra/types.js.map +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fuel.d.ts","sourceRoot":"","sources":["../../src/bin/fuel.ts"],"names":[],"mappings":""}
|
package/dist/bin/fuel.js
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const fs = __importStar(require("fs-extra"));
|
|
39
|
+
const commander_1 = require("commander");
|
|
40
|
+
const create_app_1 = require("../commands/create-app");
|
|
41
|
+
const list_modules_1 = require("../commands/list-modules");
|
|
42
|
+
const infra_init_1 = require("../commands/infra-init");
|
|
43
|
+
const infra_deploy_1 = require("../commands/infra-deploy");
|
|
44
|
+
const migrate_init_1 = require("../commands/migrate-init");
|
|
45
|
+
const infra_destroy_1 = require("../commands/infra-destroy");
|
|
46
|
+
const packageJson = require(path.join(__dirname, '..', '..', 'package.json'));
|
|
47
|
+
const program = new commander_1.Command();
|
|
48
|
+
program
|
|
49
|
+
.name('fuel')
|
|
50
|
+
.description('Fuel CLI – scaffold apps from the fuel monorepo and provision cloud infrastructure.')
|
|
51
|
+
.version(packageJson.version)
|
|
52
|
+
.addHelpText('after', `
|
|
53
|
+
Workflows:
|
|
54
|
+
|
|
55
|
+
1. Scaffolding only (no cloud infra):
|
|
56
|
+
fuel create:app <name> [-m modules]
|
|
57
|
+
|
|
58
|
+
2. Full ECS provisioning (scaffold + cloud infra):
|
|
59
|
+
fuel infra:init Step 1: generate config.json + .fuel-credentials
|
|
60
|
+
fuel create:app <name> -d ecs -c config.json Step 2: scaffold code and provision infrastructure
|
|
61
|
+
|
|
62
|
+
3. Add infra to an existing project (created without -d ecs):
|
|
63
|
+
fuel infra:init Step 1: generate config.json + .fuel-credentials
|
|
64
|
+
fuel infra:deploy --config config.json Step 2: generate fuel.config.json + provision infrastructure
|
|
65
|
+
|
|
66
|
+
4. Resume / retry infra (after a failure in step 2 or 3):
|
|
67
|
+
fuel infra:deploy [--path <project>] Re-run infrastructure provisioning without re-scaffolding
|
|
68
|
+
|
|
69
|
+
5. Re-run migrations (after a failure during create:app):
|
|
70
|
+
fuel migrate:init [--path <project>] Start Docker, generate and run migrations
|
|
71
|
+
|
|
72
|
+
6. Tear down infrastructure:
|
|
73
|
+
fuel infra:destroy [--path <project>] Destroy all provisioned cloud resources
|
|
74
|
+
|
|
75
|
+
Credentials:
|
|
76
|
+
Infrastructure commands require AWS and GitHub credentials. They are resolved in order:
|
|
77
|
+
1. Environment variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION,
|
|
78
|
+
GITHUB_TOKEN, GITHUB_USERNAME, GITHUB_ORGANIZATION
|
|
79
|
+
2. .fuel-credentials JSON file in the project root
|
|
80
|
+
3. .fuel-credentials JSON file in the current working directory
|
|
81
|
+
Run "fuel infra:init" to generate .fuel-credentials interactively.
|
|
82
|
+
|
|
83
|
+
Quick examples:
|
|
84
|
+
fuel list:modules List available modules
|
|
85
|
+
fuel create:app my-app Scaffold base app
|
|
86
|
+
fuel create:app my-app -m billing,documents Scaffold with modules
|
|
87
|
+
fuel infra:init Interactive infra config setup
|
|
88
|
+
fuel create:app my-app -d ecs -c config.json Full ECS provisioning
|
|
89
|
+
fuel infra:deploy Resume failed infra provisioning
|
|
90
|
+
fuel infra:deploy --config config.json Add infra to existing project
|
|
91
|
+
fuel infra:deploy --path ./my-app --regenerate Regenerate /infra and re-deploy
|
|
92
|
+
fuel migrate:init Re-run migration generation
|
|
93
|
+
fuel infra:destroy Tear down all infrastructure`);
|
|
94
|
+
program
|
|
95
|
+
.command('list:modules')
|
|
96
|
+
.description('List available modules defined in fuel.modules.json.\n Walks up from the current directory to find the monorepo root.')
|
|
97
|
+
.option('-s, --source <path>', 'Path to the monorepo root containing fuel.modules.json. If omitted, walks up from the current directory.')
|
|
98
|
+
.addHelpText('after', `
|
|
99
|
+
Examples:
|
|
100
|
+
fuel list:modules List modules (auto-detect monorepo root)
|
|
101
|
+
fuel list:modules -s ../fuel List modules from a specific monorepo path`)
|
|
102
|
+
.action(async (opts) => {
|
|
103
|
+
try {
|
|
104
|
+
await (0, list_modules_1.listModules)(opts.source);
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
console.error(`\n Error: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
program
|
|
112
|
+
.command('create:app [appName]')
|
|
113
|
+
.description('Create a new app from the fuel monorepo.\n\n' +
|
|
114
|
+
' This command operates in two modes:\n\n' +
|
|
115
|
+
' Scaffolding mode (default):\n' +
|
|
116
|
+
' Copies the monorepo template, removes unselected modules, installs\n' +
|
|
117
|
+
' dependencies, builds, starts Docker, generates database migrations,\n' +
|
|
118
|
+
' and creates an initial git commit.\n\n' +
|
|
119
|
+
' ECS mode (-d ecs):\n' +
|
|
120
|
+
' Performs all scaffolding steps above, then provisions cloud infrastructure:\n' +
|
|
121
|
+
' writes fuel.config.json, generates /infra (OpenTofu) and .github/workflows/,\n' +
|
|
122
|
+
' creates the S3 state bucket, writes secrets to AWS Secrets Manager, runs\n' +
|
|
123
|
+
' tofu apply in 3 passes (ECR + GitHub repo, GitHub Actions, full ECS),\n' +
|
|
124
|
+
' and prints ALB/ECR/GitHub URLs.\n' +
|
|
125
|
+
' Requires --config. Run "fuel infra:init" first to generate config.json.')
|
|
126
|
+
.option('-m, --modules <list>', 'Comma-separated modules to include (e.g. billing,documents). Omit for base only.', '')
|
|
127
|
+
.option('-o, --output <path>', 'Output directory. Defaults to ./<appName> in the current directory.')
|
|
128
|
+
.option('-s, --source <path>', 'Path to the monorepo root containing fuel.modules.json. If omitted, walks up from the current directory.')
|
|
129
|
+
.option('--dry-run', 'Preview what would be done without writing any files or provisioning resources.')
|
|
130
|
+
.option('--skip-install', 'Skip yarn install. Also implicitly skips migration generation (requires build).')
|
|
131
|
+
.option('--skip-git', 'Skip git init and the initial commit.')
|
|
132
|
+
.option('--skip-build', 'Skip yarn build. Also implicitly skips migration generation (requires build).')
|
|
133
|
+
.option('--skip-migration-generation', 'Skip database migration generation and execution. Docker will not be started.')
|
|
134
|
+
.option('-d, --deployment <type>', 'Deployment target. Only "ecs" is supported. Cannot be combined with --skip-install, --skip-build, or --skip-migration-generation.')
|
|
135
|
+
.option('-c, --config <path>', 'Path to config.json for ECS provisioning (required when -d ecs is set). Generate one with "fuel infra:init".')
|
|
136
|
+
.addHelpText('after', `
|
|
137
|
+
Scaffolding examples:
|
|
138
|
+
fuel create:app my-app Base app, no optional modules
|
|
139
|
+
fuel create:app my-app -m billing Include the billing module
|
|
140
|
+
fuel create:app my-app -m billing,documents Include multiple modules
|
|
141
|
+
fuel create:app my-app -o ./out Write to ./out instead of ./my-app
|
|
142
|
+
fuel create:app my-app --dry-run Preview without writing files
|
|
143
|
+
fuel create:app my-app --skip-install --skip-git Scaffold only, no install/git/migrations
|
|
144
|
+
|
|
145
|
+
ECS provisioning (full workflow):
|
|
146
|
+
fuel infra:init Step 1: generate config.json + .fuel-credentials
|
|
147
|
+
fuel create:app my-app -d ecs -c config.json Step 2: scaffold + provision cloud infrastructure
|
|
148
|
+
|
|
149
|
+
Recovery commands:
|
|
150
|
+
cd my-app && fuel infra:deploy Resume failed infra provisioning
|
|
151
|
+
cd my-app && fuel migrate:init Re-run failed migration generation
|
|
152
|
+
cd my-app && fuel infra:destroy Tear down all provisioned resources`)
|
|
153
|
+
.action(async (appName, opts) => {
|
|
154
|
+
try {
|
|
155
|
+
let resolvedAppName;
|
|
156
|
+
if (appName) {
|
|
157
|
+
resolvedAppName = appName;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
if (!opts.config) {
|
|
161
|
+
throw new Error('Missing app name. Provide it as a positional argument or use --config to read it from a config file.');
|
|
162
|
+
}
|
|
163
|
+
const configPath = path.resolve(opts.config);
|
|
164
|
+
const raw = await fs.readJson(configPath);
|
|
165
|
+
if (!raw.name || typeof raw.name !== 'string') {
|
|
166
|
+
throw new Error(`Config file "${opts.config}" does not contain a valid "name" field.`);
|
|
167
|
+
}
|
|
168
|
+
resolvedAppName = raw.name;
|
|
169
|
+
}
|
|
170
|
+
const modules = opts.modules
|
|
171
|
+
? opts.modules.split(',').map((m) => m.trim()).filter(Boolean)
|
|
172
|
+
: [];
|
|
173
|
+
await (0, create_app_1.createApp)(resolvedAppName, {
|
|
174
|
+
modules,
|
|
175
|
+
output: opts.output,
|
|
176
|
+
source: opts.source,
|
|
177
|
+
dryRun: opts.dryRun,
|
|
178
|
+
skipInstall: opts.skipInstall,
|
|
179
|
+
skipGit: opts.skipGit,
|
|
180
|
+
skipBuild: opts.skipBuild,
|
|
181
|
+
skipMigrationGeneration: opts.skipMigrationGeneration,
|
|
182
|
+
deployment: opts.deployment,
|
|
183
|
+
config: opts.config,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
console.error(`\n Error: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
188
|
+
process.exit(1);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
program
|
|
192
|
+
.command('infra:init')
|
|
193
|
+
.description('Generate config.json and .fuel-credentials for ECS infrastructure provisioning.\n\n' +
|
|
194
|
+
' Interactive mode (default):\n' +
|
|
195
|
+
' Prompts for AWS credentials, GitHub token, app configuration (API/Web,\n' +
|
|
196
|
+
' PostgreSQL, Redis, CPU/memory), environments (dev/staging/production),\n' +
|
|
197
|
+
' domains, and environment variables. Validates credentials against AWS\n' +
|
|
198
|
+
' and GitHub APIs. Writes config.json and .fuel-credentials (auto-added\n' +
|
|
199
|
+
' to .gitignore).\n\n' +
|
|
200
|
+
' Template mode (--template):\n' +
|
|
201
|
+
' Writes a minimal config.json template for manual editing. Does not\n' +
|
|
202
|
+
' prompt for credentials or validate anything.')
|
|
203
|
+
.option('-o, --output <path>', 'Output path for config.json. Defaults to ./config.json in the current directory.')
|
|
204
|
+
.option('--template', 'Write a minimal config.json template without prompts or credential validation.')
|
|
205
|
+
.addHelpText('after', `
|
|
206
|
+
Generated files:
|
|
207
|
+
config.json Infrastructure configuration (apps, environments, domains, resources)
|
|
208
|
+
.fuel-credentials AWS + GitHub credentials (auto-added to .gitignore, never commit this file)
|
|
209
|
+
|
|
210
|
+
Workflows using this command:
|
|
211
|
+
New project (scaffold + infra in one step):
|
|
212
|
+
1. fuel infra:init Generate config.json + .fuel-credentials
|
|
213
|
+
2. fuel create:app <name> -d ecs -c config.json Scaffold + provision infrastructure
|
|
214
|
+
|
|
215
|
+
Existing project (add infra later):
|
|
216
|
+
1. fuel infra:init Generate config.json + .fuel-credentials
|
|
217
|
+
2. fuel infra:deploy -c config.json Generate fuel.config.json + provision infrastructure
|
|
218
|
+
|
|
219
|
+
Examples:
|
|
220
|
+
fuel infra:init Interactive setup
|
|
221
|
+
fuel infra:init --template Write base template (no prompts, no credentials)
|
|
222
|
+
fuel infra:init -o ./infra/config.json Write config.json to a custom path`)
|
|
223
|
+
.action(async (opts) => {
|
|
224
|
+
try {
|
|
225
|
+
await (0, infra_init_1.infraInit)(opts);
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
console.error(`\n Error: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
229
|
+
process.exit(1);
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
program
|
|
233
|
+
.command('infra:deploy')
|
|
234
|
+
.description('Run or resume infrastructure provisioning on an already-generated project.\n\n' +
|
|
235
|
+
' Use this command after "fuel create:app -d ecs" fails during the infrastructure\n' +
|
|
236
|
+
' phase (e.g. missing AWS credentials, network timeout, OpenTofu errors).\n' +
|
|
237
|
+
' It re-runs only the infrastructure steps without re-scaffolding the project.\n\n' +
|
|
238
|
+
' You can also use this to add infrastructure to a project that was originally\n' +
|
|
239
|
+
' created without -d ecs, by passing --config <path> to generate fuel.config.json.\n\n' +
|
|
240
|
+
' Prerequisites:\n' +
|
|
241
|
+
' - The project must contain a fuel.config.json, or --config must be provided\n' +
|
|
242
|
+
' - Credentials must be available via env vars or .fuel-credentials file\n\n' +
|
|
243
|
+
' On failure, partial cloud resources are preserved (no rollback), so you\n' +
|
|
244
|
+
' can fix the issue and re-run this command as many times as needed.')
|
|
245
|
+
.option('-p, --path <path>', 'Path to the project root. Defaults to the current directory.')
|
|
246
|
+
.option('-c, --config <path>', 'Path to config.json. Generates fuel.config.json in the project and provisions infrastructure. Use this to add infra to a project created without -d ecs.')
|
|
247
|
+
.option('--regenerate', 'Delete and regenerate the /infra folder from templates before deploying. Use this if you changed config.json and need fresh OpenTofu files.')
|
|
248
|
+
.option('--plan-only', 'Run OpenTofu plan instead of apply. Shows what would change without creating any resources.')
|
|
249
|
+
.addHelpText('after', `
|
|
250
|
+
Credential resolution (in order of priority):
|
|
251
|
+
1. Environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION,
|
|
252
|
+
GITHUB_TOKEN, GITHUB_USERNAME, GITHUB_ORGANIZATION)
|
|
253
|
+
2. .fuel-credentials file in the project root (--path)
|
|
254
|
+
3. .fuel-credentials file in the current working directory
|
|
255
|
+
|
|
256
|
+
What this command does:
|
|
257
|
+
1. If --config is provided, writes fuel.config.json to the project root
|
|
258
|
+
2. Validates fuel.config.json, OpenTofu version, and credentials
|
|
259
|
+
3. Generates the /infra folder if missing (or if --regenerate / --config is passed)
|
|
260
|
+
4. Creates the S3 state bucket if it does not exist (with a unique suffix)
|
|
261
|
+
5. Writes infrastructure secrets to AWS Secrets Manager
|
|
262
|
+
6. Runs OpenTofu in 3 passes: ECR + GitHub repo, GitHub Actions, full ECS
|
|
263
|
+
7. Wires the git remote and prints ALB/ECR/GitHub URLs
|
|
264
|
+
|
|
265
|
+
Examples:
|
|
266
|
+
cd my-app && fuel infra:deploy Resume from inside the project
|
|
267
|
+
fuel infra:deploy -p ./my-app Resume from outside the project
|
|
268
|
+
fuel infra:deploy -c config.json Add infra to an existing project
|
|
269
|
+
fuel infra:deploy -c config.json --plan-only Preview what infra would be created
|
|
270
|
+
fuel infra:deploy --regenerate Regenerate /infra folder, then deploy
|
|
271
|
+
fuel infra:deploy --plan-only Preview changes without deploying
|
|
272
|
+
|
|
273
|
+
To tear down provisioned resources:
|
|
274
|
+
fuel infra:destroy Destroy all infrastructure`)
|
|
275
|
+
.action(async (opts) => {
|
|
276
|
+
try {
|
|
277
|
+
await (0, infra_deploy_1.infraDeploy)(opts);
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
console.error(`\n Error: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
281
|
+
process.exit(1);
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
program
|
|
285
|
+
.command('migrate:init')
|
|
286
|
+
.description('Generate and run database migrations for an existing project.\n\n' +
|
|
287
|
+
' Use this command when "fuel create:app" failed during the migration step,\n' +
|
|
288
|
+
' or when you need to re-run migration generation on a project that was\n' +
|
|
289
|
+
' created with --skip-migration-generation.\n\n' +
|
|
290
|
+
' This command starts Docker services, waits for Postgres to be ready,\n' +
|
|
291
|
+
' generates an initial TypeORM migration, runs it, and commits the result.')
|
|
292
|
+
.option('-p, --path <path>', 'Path to the project root. Defaults to the current directory.')
|
|
293
|
+
.option('--skip-commit', 'Skip the git commit after generating and running migrations.')
|
|
294
|
+
.addHelpText('after', `
|
|
295
|
+
What this command does:
|
|
296
|
+
1. Checks Docker and Docker Compose are available and running
|
|
297
|
+
2. Copies .env.example to .env for api/web/playwright (if .env is missing)
|
|
298
|
+
3. Runs "docker compose up -d" to start services
|
|
299
|
+
4. Waits for Postgres to become healthy (up to 120s)
|
|
300
|
+
5. Generates initial migration via "yarn workspace api database:migration:generate"
|
|
301
|
+
6. Runs migrations via "yarn workspace api database:migration:run"
|
|
302
|
+
7. Commits the migration files (unless --skip-commit)
|
|
303
|
+
|
|
304
|
+
Prerequisites:
|
|
305
|
+
- The project must have been scaffolded by "fuel create:app"
|
|
306
|
+
- Dependencies must be installed (yarn install) and built (yarn build)
|
|
307
|
+
- Docker must be installed and running
|
|
308
|
+
|
|
309
|
+
Examples:
|
|
310
|
+
cd my-app && fuel migrate:init Run from inside the project
|
|
311
|
+
fuel migrate:init -p ./my-app Run from outside the project
|
|
312
|
+
fuel migrate:init --skip-commit Generate and run without committing`)
|
|
313
|
+
.action(async (opts) => {
|
|
314
|
+
try {
|
|
315
|
+
await (0, migrate_init_1.migrateInit)(opts);
|
|
316
|
+
}
|
|
317
|
+
catch (error) {
|
|
318
|
+
console.error(`\n Error: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
319
|
+
process.exit(1);
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
program
|
|
323
|
+
.command('infra:destroy')
|
|
324
|
+
.description('Destroy all infrastructure resources provisioned by "fuel infra:deploy".\n\n' +
|
|
325
|
+
' Runs "tofu destroy" against the /infra folder, tearing down all AWS and\n' +
|
|
326
|
+
' GitHub resources managed by OpenTofu (ECR, ECS, RDS, ALB, GitHub repo, etc.).\n\n' +
|
|
327
|
+
' Prerequisites:\n' +
|
|
328
|
+
' - The project must contain fuel.config.json and an /infra folder\n' +
|
|
329
|
+
' - Credentials must be available via env vars or .fuel-credentials file')
|
|
330
|
+
.option('-p, --path <path>', 'Path to the project root. Defaults to the current directory.')
|
|
331
|
+
.addHelpText('after', `
|
|
332
|
+
What this command does:
|
|
333
|
+
1. Validates fuel.config.json, OpenTofu version, and credentials
|
|
334
|
+
2. Runs "tofu init" to initialize the backend
|
|
335
|
+
3. Runs "tofu destroy -auto-approve" to tear down all resources
|
|
336
|
+
|
|
337
|
+
Examples:
|
|
338
|
+
cd my-app && fuel infra:destroy Destroy from inside the project
|
|
339
|
+
fuel infra:destroy -p ./my-app Destroy from outside the project
|
|
340
|
+
|
|
341
|
+
To re-provision after destroying:
|
|
342
|
+
fuel infra:deploy Re-create all infrastructure`)
|
|
343
|
+
.action(async (opts) => {
|
|
344
|
+
try {
|
|
345
|
+
await (0, infra_destroy_1.infraDestroy)(opts);
|
|
346
|
+
}
|
|
347
|
+
catch (error) {
|
|
348
|
+
console.error(`\n Error: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
349
|
+
process.exit(1);
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
program.parse();
|
|
353
|
+
//# sourceMappingURL=fuel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fuel.js","sourceRoot":"","sources":["../../src/bin/fuel.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,6CAA+B;AAC/B,yCAAoC;AACpC,uDAAmD;AACnD,2DAAuD;AACvD,uDAAmD;AACnD,2DAAuD;AACvD,2DAAuD;AACvD,6DAAyD;AAEzD,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;AAE9E,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B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C,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** npm scope segment must match [a-z0-9-~][a-z0-9-._~]* */
|
|
2
|
+
export declare const sanitizeNpmScope: (name: string) => string;
|
|
3
|
+
export declare const cleanPackageJsonDeps: (projectRoot: string, removedModules: string[]) => Promise<void>;
|
|
4
|
+
export declare const renameProject: (projectRoot: string, appName: string) => Promise<void>;
|
|
5
|
+
export interface InitializeProjectOptions {
|
|
6
|
+
skipGit?: boolean;
|
|
7
|
+
skipInstall?: boolean;
|
|
8
|
+
skipBuild?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const initializeProject: (projectRoot: string, options?: InitializeProjectOptions) => void;
|
|
11
|
+
//# sourceMappingURL=finalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finalize.d.ts","sourceRoot":"","sources":["../../src/cleanup/finalize.ts"],"names":[],"mappings":"AAKA,2DAA2D;AAC3D,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,MAQ/C,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,aAAa,MAAM,EACnB,gBAAgB,MAAM,EAAE,kBA2BzB,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,aAAa,MAAM,EACnB,SAAS,MAAM,kBAwBhB,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,iBAAiB,GAC5B,aAAa,MAAM,EACnB,UAAS,wBAA6B,SAuBvC,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.initializeProject = exports.renameProject = exports.cleanPackageJsonDeps = exports.sanitizeNpmScope = void 0;
|
|
37
|
+
const fs = __importStar(require("fs-extra"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const glob_1 = require("glob");
|
|
40
|
+
const child_process_1 = require("child_process");
|
|
41
|
+
/** npm scope segment must match [a-z0-9-~][a-z0-9-._~]* */
|
|
42
|
+
const sanitizeNpmScope = (name) => {
|
|
43
|
+
const s = name
|
|
44
|
+
.toLowerCase()
|
|
45
|
+
.replace(/[^a-z0-9._~-]/g, '-')
|
|
46
|
+
.replace(/-+/g, '-')
|
|
47
|
+
.replace(/^[-._]+|[-._]+$/g, '')
|
|
48
|
+
.replace(/^[._]/, '-');
|
|
49
|
+
return s || 'app';
|
|
50
|
+
};
|
|
51
|
+
exports.sanitizeNpmScope = sanitizeNpmScope;
|
|
52
|
+
const cleanPackageJsonDeps = async (projectRoot, removedModules) => {
|
|
53
|
+
const packageJsonFiles = await (0, glob_1.glob)(path.join(projectRoot, '**/package.json'), { ignore: ['**/node_modules/**'] });
|
|
54
|
+
const depsToRemove = removedModules.map((m) => `@fuel/${m}-types`);
|
|
55
|
+
for (const pkgPath of packageJsonFiles) {
|
|
56
|
+
const pkg = await fs.readJson(pkgPath);
|
|
57
|
+
let modified = false;
|
|
58
|
+
for (const depType of ['dependencies', 'devDependencies', 'peerDependencies']) {
|
|
59
|
+
if (!pkg[depType])
|
|
60
|
+
continue;
|
|
61
|
+
for (const dep of depsToRemove) {
|
|
62
|
+
if (pkg[depType][dep]) {
|
|
63
|
+
delete pkg[depType][dep];
|
|
64
|
+
modified = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (modified) {
|
|
69
|
+
await fs.writeJson(pkgPath, pkg, { spaces: 2 });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
exports.cleanPackageJsonDeps = cleanPackageJsonDeps;
|
|
74
|
+
const renameProject = async (projectRoot, appName) => {
|
|
75
|
+
const packageJsonFiles = await (0, glob_1.glob)(path.join(projectRoot, '**/package.json'), { ignore: ['**/node_modules/**'] });
|
|
76
|
+
const scope = `@${(0, exports.sanitizeNpmScope)(appName)}`;
|
|
77
|
+
for (const pkgPath of packageJsonFiles) {
|
|
78
|
+
const pkg = await fs.readJson(pkgPath);
|
|
79
|
+
if (pkg.name) {
|
|
80
|
+
pkg.name = pkg.name.replace(/@fuel\//g, `${scope}/`);
|
|
81
|
+
}
|
|
82
|
+
for (const depType of ['dependencies', 'devDependencies', 'peerDependencies']) {
|
|
83
|
+
if (!pkg[depType])
|
|
84
|
+
continue;
|
|
85
|
+
const renamed = {};
|
|
86
|
+
for (const [key, value] of Object.entries(pkg[depType])) {
|
|
87
|
+
renamed[key.replace(/@fuel\//g, `${scope}/`)] = value;
|
|
88
|
+
}
|
|
89
|
+
pkg[depType] = renamed;
|
|
90
|
+
}
|
|
91
|
+
await fs.writeJson(pkgPath, pkg, { spaces: 2 });
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
exports.renameProject = renameProject;
|
|
95
|
+
const initializeProject = (projectRoot, options = {}) => {
|
|
96
|
+
const { skipGit = false, skipInstall = false, skipBuild = false } = options;
|
|
97
|
+
if (!skipGit) {
|
|
98
|
+
console.log(' Initializing git repository...');
|
|
99
|
+
(0, child_process_1.execSync)('git init -b main', { cwd: projectRoot, stdio: 'pipe' });
|
|
100
|
+
(0, child_process_1.execSync)('git add -A', { cwd: projectRoot, stdio: 'pipe' });
|
|
101
|
+
(0, child_process_1.execSync)('git commit -m "Initial commit from fuel create:app"', {
|
|
102
|
+
cwd: projectRoot,
|
|
103
|
+
stdio: 'pipe',
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if (!skipInstall) {
|
|
107
|
+
console.log(' Installing dependencies (this may take a moment)...');
|
|
108
|
+
(0, child_process_1.execSync)('yarn install', { cwd: projectRoot, stdio: 'inherit' });
|
|
109
|
+
}
|
|
110
|
+
if (!skipInstall && !skipBuild) {
|
|
111
|
+
console.log(' Building...');
|
|
112
|
+
(0, child_process_1.execSync)('yarn build', { cwd: projectRoot, stdio: 'inherit' });
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
exports.initializeProject = initializeProject;
|
|
116
|
+
//# sourceMappingURL=finalize.js.map
|
|
@@ -0,0 +1 @@
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,CAAC,WAAW,IAAI,CAAC,SAAS,EAAE,CAAC;QAC/B,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QAC7B,IAAA,wBAAQ,EAAC,YAAY,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IACjE,CAAC;AACH,CAAC,CAAC;AAzBW,QAAA,iBAAiB,qBAyB5B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface CreateAppOptions {
|
|
2
|
+
modules: string[];
|
|
3
|
+
output?: string;
|
|
4
|
+
source?: string;
|
|
5
|
+
dryRun?: boolean;
|
|
6
|
+
skipInstall?: boolean;
|
|
7
|
+
skipGit?: boolean;
|
|
8
|
+
skipBuild?: boolean;
|
|
9
|
+
skipMigrationGeneration?: boolean;
|
|
10
|
+
deployment?: string;
|
|
11
|
+
config?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const createApp: (appName: string, options: CreateAppOptions) => Promise<void>;
|
|
14
|
+
//# sourceMappingURL=create-app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-app.d.ts","sourceRoot":"","sources":["../../src/commands/create-app.ts"],"names":[],"mappings":"AAoBA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAmJD,eAAO,MAAM,SAAS,GAAU,SAAS,MAAM,EAAE,SAAS,gBAAgB,kBA2QzE,CAAA"}
|