@webmaster-droid/cli 0.2.0 → 0.3.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/index.js +9 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -127,32 +127,19 @@ async function readJson(filePath) {
|
|
|
127
127
|
return JSON.parse(raw);
|
|
128
128
|
}
|
|
129
129
|
program.name("webmaster-droid").description("Webmaster Droid CLI").version(CLI_VERSION);
|
|
130
|
-
program.command("init").description("Initialize
|
|
130
|
+
program.command("init").description("Initialize webmaster-droid environment template in current project").option("--backend <backend>", "backend (supabase|aws)", "supabase").option("--out <dir>", "output dir", ".").action(async (opts) => {
|
|
131
131
|
const backendRaw = String(opts.backend ?? "supabase").trim().toLowerCase();
|
|
132
132
|
if (backendRaw !== "supabase" && backendRaw !== "aws") {
|
|
133
133
|
throw new Error(`Unsupported backend '${opts.backend}'. Expected 'supabase' or 'aws'.`);
|
|
134
134
|
}
|
|
135
135
|
const backend = backendRaw;
|
|
136
136
|
const outDir = path2.resolve(process.cwd(), opts.out);
|
|
137
|
-
const configPath = path2.join(outDir, "webmaster-droid.config.ts");
|
|
138
|
-
await ensureDir(configPath);
|
|
139
|
-
const config = `export default {
|
|
140
|
-
framework: "${opts.framework}",
|
|
141
|
-
backend: "${backend}",
|
|
142
|
-
apiBaseUrlEnv: "NEXT_PUBLIC_AGENT_API_BASE_URL"
|
|
143
|
-
};
|
|
144
|
-
`;
|
|
145
|
-
try {
|
|
146
|
-
await fs.access(configPath);
|
|
147
|
-
console.log(`Config already exists: ${configPath}`);
|
|
148
|
-
} catch {
|
|
149
|
-
await fs.writeFile(configPath, config, "utf8");
|
|
150
|
-
console.log(`Created: ${configPath}`);
|
|
151
|
-
}
|
|
152
137
|
const envExample = path2.join(outDir, ".env.webmaster-droid.example");
|
|
138
|
+
let createdEnvTemplate = false;
|
|
153
139
|
try {
|
|
154
140
|
await fs.access(envExample);
|
|
155
141
|
} catch {
|
|
142
|
+
await ensureDir(envExample);
|
|
156
143
|
await fs.writeFile(
|
|
157
144
|
envExample,
|
|
158
145
|
[
|
|
@@ -180,8 +167,14 @@ program.command("init").description("Initialize optional webmaster-droid config
|
|
|
180
167
|
].join("\n") + "\n",
|
|
181
168
|
"utf8"
|
|
182
169
|
);
|
|
170
|
+
createdEnvTemplate = true;
|
|
171
|
+
}
|
|
172
|
+
if (createdEnvTemplate) {
|
|
183
173
|
console.log(`Created: ${envExample}`);
|
|
174
|
+
} else {
|
|
175
|
+
console.log(`Env template already exists: ${envExample}`);
|
|
184
176
|
}
|
|
177
|
+
console.log(`Backend preset: ${backend}`);
|
|
185
178
|
});
|
|
186
179
|
var schema = program.command("schema").description("Optional schema helpers");
|
|
187
180
|
schema.command("init").description("Create starter schema file").option("--out <file>", "schema output", "cms/schema.webmaster.ts").action(async (opts) => {
|