Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ samples/**/*terraform.tfstate*
/samples/**/*-package.zip
.terrable/
dist/
__debug_bin*
__debug_bin*
node_modules/
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "terrable-monorepo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"bin": {
"terrable": "./packages/cli/dist/cli.js"
},
"keywords": [],
"author": "Leonardo Petrucci",
"license": "ISC"
}
1 change: 1 addition & 0 deletions packages/cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terrable
21 changes: 21 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "terrable",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "tsc",
"start": "node dist/cli.js",
"dev": "tsc-watch ./src/cli.ts --outDir ./dist"
},
"keywords": [],
"author": "Leonardo Petrucci",
"license": "ISC",
"dependencies": {
"@types/node": "^22.9.0",
"commander": "^12.1.0",
"ts-node": "^10.9.2",
"tsc-watch": "^6.2.1",
"typescript": "^5.6.3"
}
}
43 changes: 43 additions & 0 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env node

import { Command } from "commander";
import { exec, spawn } from "child_process";
import * as path from "path";

const program = new Command();
const binaryPath = path.resolve(__dirname, "../terrable"); // Adjust the path to your binary

program.name("terrable-cli").description("CLI for Terrable").version("1.0.0");

program
.command("offline")
.description("Run the offline server")
.option("-f, --file <file>", "Path to the Terraform file")
.option("-m, --module <module>", "Name of the terraform module")
.option("-p, --port <port>", "Port number")
.action((options) => {
const args = [
"offline",
options.file ? `-file ${options.file}` : "",
options.module ? `-module ${options.module}` : "",
options.port ? `-port ${options.port}` : "",
]
.filter(Boolean)
.join(" ");

const child = spawn(binaryPath, args.split(" "));

child.stdout.on("data", (data) => {
process.stdout.write(data);
});

child.stderr.on("data", (data) => {
process.stderr.write(data);
});

child.on("close", (code) => {
console.log(`Child process exited with code ${code}`);
});
});

program.parse(process.argv);
11 changes: 11 additions & 0 deletions packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true
},
"include": ["src/**/*"]
}
274 changes: 274 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages:
- "packages/*"