@vibecodemax/cli 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.
Files changed (4) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +156 -0
  3. package/dist/cli.js +378 -0
  4. package/package.json +35 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 VibeCodeMax
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,156 @@
1
+ # @vibecodemax/cli
2
+
3
+ Local VibeCodeMax CLI for bootstrap and future project operations.
4
+
5
+ This package is intended to run on the user's machine from the project root. It reads local environment files such as `.env.local` and `.env.bootstrap.local`, performs provider configuration locally, and prints JSON-only results to stdout.
6
+
7
+ ## Principles
8
+
9
+ - Secrets stay local to the user's machine
10
+ - No secret values are passed through MCP payloads
11
+ - No secret values are printed to stdout
12
+ - Commands return structured JSON only
13
+ - Exit code `0` means success; non-zero means failure
14
+
15
+ ## Requirements
16
+
17
+ - Node.js 20+
18
+ - npm, pnpm, or yarn
19
+
20
+ ## Development
21
+
22
+ Install dependencies:
23
+
24
+ ```bash
25
+ npm install
26
+ ```
27
+
28
+ Build the CLI:
29
+
30
+ ```bash
31
+ npm run build
32
+ ```
33
+
34
+ Type-check without emitting files:
35
+
36
+ ```bash
37
+ npm run typecheck
38
+ ```
39
+
40
+ Run the built CLI help command:
41
+
42
+ ```bash
43
+ node dist/cli.js help
44
+ ```
45
+
46
+ ## Local Execution
47
+
48
+ Use an exact package version when invoking the published package.
49
+
50
+ npm:
51
+
52
+ ```bash
53
+ npx @vibecodemax/cli@0.1.0 help
54
+ ```
55
+
56
+ pnpm:
57
+
58
+ ```bash
59
+ pnpm dlx @vibecodemax/cli@0.1.0 help
60
+ ```
61
+
62
+ yarn:
63
+
64
+ ```bash
65
+ yarn dlx @vibecodemax/cli@0.1.0 help
66
+ ```
67
+
68
+ ## Commands
69
+
70
+ ### `configure-site-redirects`
71
+
72
+ Configures Supabase auth site URL and redirect allow-list for test or production mode.
73
+
74
+ Example:
75
+
76
+ ```bash
77
+ node dist/cli.js configure-site-redirects --mode test
78
+ ```
79
+
80
+ Production example:
81
+
82
+ ```bash
83
+ node dist/cli.js configure-site-redirects --mode production --production-domain https://yourdomain.com
84
+ ```
85
+
86
+ ### `configure-email-password`
87
+
88
+ Configures email/password signup behavior in Supabase.
89
+
90
+ Example:
91
+
92
+ ```bash
93
+ node dist/cli.js configure-email-password --email-confirmation yes
94
+ ```
95
+
96
+ ### `enable-google-provider`
97
+
98
+ Enables Google auth in Supabase using local credentials from `.env.bootstrap.local`.
99
+
100
+ Example:
101
+
102
+ ```bash
103
+ node dist/cli.js enable-google-provider
104
+ ```
105
+
106
+ ### `apply-auth-templates`
107
+
108
+ Applies custom auth email template content from local project files.
109
+
110
+ Example:
111
+
112
+ ```bash
113
+ node dist/cli.js apply-auth-templates \
114
+ --confirm-email-enabled true \
115
+ --confirm-email-path src/email/confirm-email.html \
116
+ --reset-password-enabled true \
117
+ --reset-password-path src/email/reset-password.html
118
+ ```
119
+
120
+ ## Output Contract
121
+
122
+ Success example:
123
+
124
+ ```json
125
+ {
126
+ "ok": true,
127
+ "command": "configure-site-redirects",
128
+ "applied": ["site_url", "uri_allow_list", "NEXT_PUBLIC_SITE_URL"]
129
+ }
130
+ ```
131
+
132
+ Failure example:
133
+
134
+ ```json
135
+ {
136
+ "ok": false,
137
+ "code": "MISSING_ENV",
138
+ "message": "SUPABASE_MANAGEMENT_TOKEN is missing. Add it to .env.bootstrap.local."
139
+ }
140
+ ```
141
+
142
+ Error output must reference file names and environment variable names, not secret values.
143
+
144
+ ## Publishing
145
+
146
+ Verify the package contents:
147
+
148
+ ```bash
149
+ npm pack --dry-run
150
+ ```
151
+
152
+ Publish publicly:
153
+
154
+ ```bash
155
+ npm publish --access public
156
+ ```
package/dist/cli.js ADDED
@@ -0,0 +1,378 @@
1
+ #!/usr/bin/env node
2
+ import * as fs from "node:fs";
3
+ import * as path from "node:path";
4
+ const MANAGEMENT_API_BASE = "https://api.supabase.com";
5
+ const DEFAULT_LOCALHOST_URL = "http://localhost:3000";
6
+ function printJson(value) {
7
+ process.stdout.write(`${JSON.stringify(value)}\n`);
8
+ }
9
+ function fail(code, message, exitCode = 1, extra = {}) {
10
+ printJson({ ok: false, code, message, ...extra });
11
+ process.exit(exitCode);
12
+ }
13
+ function parseArgs(argv) {
14
+ const [command, ...rest] = argv;
15
+ const flags = {};
16
+ for (let index = 0; index < rest.length; index += 1) {
17
+ const token = rest[index];
18
+ if (!token.startsWith("--"))
19
+ continue;
20
+ const key = token.slice(2);
21
+ const next = rest[index + 1];
22
+ if (!next || next.startsWith("--")) {
23
+ flags[key] = true;
24
+ continue;
25
+ }
26
+ flags[key] = next;
27
+ index += 1;
28
+ }
29
+ return { command, flags };
30
+ }
31
+ function readFileIfExists(filePath) {
32
+ try {
33
+ return fs.readFileSync(filePath, "utf8");
34
+ }
35
+ catch {
36
+ return "";
37
+ }
38
+ }
39
+ function parseDotEnv(content) {
40
+ const env = {};
41
+ for (const rawLine of content.split(/\r?\n/)) {
42
+ const line = rawLine.trim();
43
+ if (!line || line.startsWith("#"))
44
+ continue;
45
+ const eq = line.indexOf("=");
46
+ if (eq === -1)
47
+ continue;
48
+ const key = line.slice(0, eq).trim();
49
+ const value = line.slice(eq + 1).trim();
50
+ if (!key)
51
+ continue;
52
+ env[key] = value;
53
+ }
54
+ return env;
55
+ }
56
+ function loadLocalEnv(cwd = process.cwd()) {
57
+ const envLocalPath = path.join(cwd, ".env.local");
58
+ const envBootstrapPath = path.join(cwd, ".env.bootstrap.local");
59
+ return {
60
+ envLocalPath,
61
+ envBootstrapPath,
62
+ values: {
63
+ ...parseDotEnv(readFileIfExists(envLocalPath)),
64
+ ...parseDotEnv(readFileIfExists(envBootstrapPath)),
65
+ },
66
+ };
67
+ }
68
+ function isNonEmptyString(value) {
69
+ return typeof value === "string" && value.trim().length > 0;
70
+ }
71
+ function readStringFlag(flags, key) {
72
+ const value = flags[key];
73
+ return typeof value === "string" ? value.trim() : "";
74
+ }
75
+ function normalizeBaseUrl(value) {
76
+ if (!isNonEmptyString(value))
77
+ return "";
78
+ try {
79
+ const parsed = new URL(value.trim());
80
+ if (parsed.protocol !== "https:")
81
+ return "";
82
+ return `${parsed.protocol}//${parsed.host}`;
83
+ }
84
+ catch {
85
+ return "";
86
+ }
87
+ }
88
+ function normalizeLocalUrl(value) {
89
+ if (!isNonEmptyString(value))
90
+ return DEFAULT_LOCALHOST_URL;
91
+ try {
92
+ const parsed = new URL(value.trim());
93
+ if (parsed.protocol !== "http:" || parsed.hostname !== "localhost") {
94
+ return DEFAULT_LOCALHOST_URL;
95
+ }
96
+ return `${parsed.protocol}//${parsed.host}`;
97
+ }
98
+ catch {
99
+ return DEFAULT_LOCALHOST_URL;
100
+ }
101
+ }
102
+ function parseUriAllowList(value) {
103
+ if (!isNonEmptyString(value))
104
+ return [];
105
+ return value.split(",").map((entry) => entry.trim()).filter(Boolean);
106
+ }
107
+ function dedupe(values) {
108
+ return [...new Set(values.filter((value) => isNonEmptyString(value)).map((value) => value.trim()))];
109
+ }
110
+ function buildRequiredRedirects(productionBaseUrl, localhostBaseUrl = DEFAULT_LOCALHOST_URL) {
111
+ const bases = dedupe([productionBaseUrl, localhostBaseUrl]);
112
+ const routes = ["/auth/confirm", "/auth/callback"];
113
+ return bases.flatMap((baseUrl) => routes.map((route) => `${baseUrl}${route}`));
114
+ }
115
+ function resolvePrimarySiteUrl(productionBaseUrl, localhostBaseUrl) {
116
+ return productionBaseUrl || localhostBaseUrl;
117
+ }
118
+ function parseProjectRefFromUrl(value) {
119
+ if (!isNonEmptyString(value))
120
+ return "";
121
+ try {
122
+ const parsed = new URL(value.trim());
123
+ const match = parsed.hostname.match(/^([a-z0-9]{20})\.supabase\.co$/);
124
+ return match ? match[1] : "";
125
+ }
126
+ catch {
127
+ return "";
128
+ }
129
+ }
130
+ function resolveProjectRef(flags, envValues) {
131
+ return String(readStringFlag(flags, "project-ref")
132
+ || envValues.SUPABASE_PROJECT_REF
133
+ || parseProjectRefFromUrl(envValues.NEXT_PUBLIC_SUPABASE_URL)
134
+ || parseProjectRefFromUrl(envValues.SUPABASE_URL)
135
+ || "").trim();
136
+ }
137
+ function requireEnvValue(envValues, key, fileHint) {
138
+ const value = envValues[key];
139
+ if (!isNonEmptyString(value)) {
140
+ fail("MISSING_ENV", `${key} is missing. Add it to ${fileHint}.`);
141
+ }
142
+ return value.trim();
143
+ }
144
+ function mergeEnvFile(filePath, nextValues) {
145
+ const existing = parseDotEnv(readFileIfExists(filePath));
146
+ const merged = { ...existing, ...nextValues };
147
+ const keys = Object.keys(merged).sort();
148
+ const content = `${keys.map((key) => `${key}=${merged[key]}`).join("\n")}\n`;
149
+ fs.writeFileSync(filePath, content, "utf8");
150
+ }
151
+ async function managementRequest({ method, projectRef, token, body }) {
152
+ const endpoint = `${MANAGEMENT_API_BASE}/v1/projects/${projectRef}/config/auth`;
153
+ const response = await fetch(endpoint, {
154
+ method,
155
+ headers: {
156
+ Accept: "application/json",
157
+ "Content-Type": "application/json",
158
+ Authorization: `Bearer ${token}`,
159
+ },
160
+ body: body ? JSON.stringify(body) : undefined,
161
+ });
162
+ let json = null;
163
+ try {
164
+ json = await response.json();
165
+ }
166
+ catch {
167
+ json = null;
168
+ }
169
+ if (!response.ok) {
170
+ const message = isNonEmptyString(json?.message)
171
+ ? json.message
172
+ : isNonEmptyString(json?.error)
173
+ ? json.error
174
+ : `Supabase returned ${response.status}`;
175
+ fail("MANAGEMENT_API_ERROR", `${message}. Check project ref and local token configuration.`, 1, { status: response.status });
176
+ }
177
+ return json;
178
+ }
179
+ function readAuthConfigEnvelope(responseJson) {
180
+ if (!responseJson || typeof responseJson !== "object")
181
+ return {};
182
+ const envelope = responseJson;
183
+ if (envelope.auth && typeof envelope.auth === "object")
184
+ return envelope.auth;
185
+ if (envelope.config?.auth && typeof envelope.config.auth === "object")
186
+ return envelope.config.auth;
187
+ return responseJson;
188
+ }
189
+ function normalizeTemplateText(value) {
190
+ if (!isNonEmptyString(value))
191
+ return "";
192
+ return value.replace(/\r\n/g, "\n").trim();
193
+ }
194
+ function buildTemplateDesiredFields(options) {
195
+ const desired = {};
196
+ if (options.confirmEmailEnabled) {
197
+ const confirmHtml = normalizeTemplateText(readFileIfExists(path.resolve(process.cwd(), options.confirmEmailPath || "")));
198
+ if (!confirmHtml) {
199
+ fail("MISSING_TEMPLATE_FILE", `Confirm email template content is missing. Check ${options.confirmEmailPath}.`);
200
+ }
201
+ desired.mailer_subjects_confirmation = isNonEmptyString(options.confirmEmailSubject)
202
+ ? options.confirmEmailSubject.trim()
203
+ : "Confirm your signup";
204
+ desired.mailer_templates_confirmation_content = confirmHtml;
205
+ }
206
+ if (options.resetPasswordEnabled) {
207
+ const resetHtml = normalizeTemplateText(readFileIfExists(path.resolve(process.cwd(), options.resetPasswordPath || "")));
208
+ if (!resetHtml) {
209
+ fail("MISSING_TEMPLATE_FILE", `Reset password template content is missing. Check ${options.resetPasswordPath}.`);
210
+ }
211
+ desired.mailer_subjects_recovery = isNonEmptyString(options.resetPasswordSubject)
212
+ ? options.resetPasswordSubject.trim()
213
+ : "Reset your password";
214
+ desired.mailer_templates_recovery_content = resetHtml;
215
+ }
216
+ return desired;
217
+ }
218
+ function diffTemplateFields(currentAuthConfig = {}, desiredFields) {
219
+ const patch = {};
220
+ const changedKeys = [];
221
+ for (const [key, desiredValue] of Object.entries(desiredFields)) {
222
+ const currentValue = currentAuthConfig[key];
223
+ const normalizedCurrent = typeof currentValue === "string" ? normalizeTemplateText(currentValue) : currentValue;
224
+ const normalizedDesired = typeof desiredValue === "string" ? normalizeTemplateText(desiredValue) : desiredValue;
225
+ if (normalizedCurrent !== normalizedDesired) {
226
+ patch[key] = desiredValue;
227
+ changedKeys.push(key);
228
+ }
229
+ }
230
+ return { patch, changedKeys, noChanges: changedKeys.length === 0 };
231
+ }
232
+ async function configureSiteRedirects(flags) {
233
+ const { envLocalPath, envBootstrapPath, values } = loadLocalEnv();
234
+ const projectRef = resolveProjectRef(flags, values);
235
+ if (!projectRef) {
236
+ fail("MISSING_PROJECT_REF", "SUPABASE_PROJECT_REF is missing. Add it to .env.bootstrap.local or ensure NEXT_PUBLIC_SUPABASE_URL is present in .env.local.");
237
+ }
238
+ const accessToken = requireEnvValue(values, "SUPABASE_ACCESS_TOKEN", path.basename(envBootstrapPath));
239
+ const mode = readStringFlag(flags, "mode") === "production" ? "production" : "test";
240
+ const productionDomain = mode === "production" ? normalizeBaseUrl(readStringFlag(flags, "production-domain")) : "";
241
+ if (mode === "production" && !productionDomain) {
242
+ fail("MISSING_PRODUCTION_DOMAIN", "Production mode requires --production-domain https://yourdomain.com.");
243
+ }
244
+ const localhostUrl = normalizeLocalUrl(readStringFlag(flags, "localhost-url"));
245
+ const primarySiteUrl = resolvePrimarySiteUrl(productionDomain, localhostUrl);
246
+ const requiredRedirects = buildRequiredRedirects(productionDomain, localhostUrl);
247
+ const current = await managementRequest({ method: "GET", projectRef, token: accessToken });
248
+ const currentAuthConfig = readAuthConfigEnvelope(current);
249
+ const mergedAllowList = dedupe([...parseUriAllowList(currentAuthConfig.uri_allow_list), ...requiredRedirects]);
250
+ await managementRequest({
251
+ method: "PATCH",
252
+ projectRef,
253
+ token: accessToken,
254
+ body: {
255
+ site_url: primarySiteUrl,
256
+ uri_allow_list: mergedAllowList.join(","),
257
+ },
258
+ });
259
+ mergeEnvFile(envLocalPath, { NEXT_PUBLIC_SITE_URL: primarySiteUrl });
260
+ printJson({
261
+ ok: true,
262
+ command: "configure-site-redirects",
263
+ mode,
264
+ projectRef,
265
+ siteUrl: primarySiteUrl,
266
+ redirectUrls: requiredRedirects,
267
+ applied: ["site_url", "uri_allow_list", "NEXT_PUBLIC_SITE_URL"],
268
+ });
269
+ }
270
+ async function configureEmailPassword(flags) {
271
+ const { envBootstrapPath, values } = loadLocalEnv();
272
+ const projectRef = resolveProjectRef(flags, values);
273
+ if (!projectRef) {
274
+ fail("MISSING_PROJECT_REF", "SUPABASE_PROJECT_REF is missing. Add it to .env.bootstrap.local or ensure NEXT_PUBLIC_SUPABASE_URL is present in .env.local.");
275
+ }
276
+ const accessToken = requireEnvValue(values, "SUPABASE_ACCESS_TOKEN", path.basename(envBootstrapPath));
277
+ const emailConfirmation = readStringFlag(flags, "email-confirmation") !== "no";
278
+ await managementRequest({
279
+ method: "PATCH",
280
+ projectRef,
281
+ token: accessToken,
282
+ body: {
283
+ disable_signup: false,
284
+ mailer_autoconfirm: !emailConfirmation,
285
+ },
286
+ });
287
+ printJson({
288
+ ok: true,
289
+ command: "configure-email-password",
290
+ projectRef,
291
+ emailConfirmationEnabled: emailConfirmation,
292
+ applied: ["disable_signup", "mailer_autoconfirm"],
293
+ });
294
+ }
295
+ async function enableGoogleProvider(flags) {
296
+ const { envBootstrapPath, values } = loadLocalEnv();
297
+ const projectRef = resolveProjectRef(flags, values);
298
+ if (!projectRef) {
299
+ fail("MISSING_PROJECT_REF", "SUPABASE_PROJECT_REF is missing. Add it to .env.bootstrap.local or ensure NEXT_PUBLIC_SUPABASE_URL is present in .env.local.");
300
+ }
301
+ const managementToken = requireEnvValue(values, "SUPABASE_MANAGEMENT_TOKEN", path.basename(envBootstrapPath));
302
+ const googleClientId = requireEnvValue(values, "GOOGLE_CLIENT_ID", path.basename(envBootstrapPath));
303
+ const googleClientSecret = requireEnvValue(values, "GOOGLE_CLIENT_SECRET", path.basename(envBootstrapPath));
304
+ await managementRequest({
305
+ method: "PATCH",
306
+ projectRef,
307
+ token: managementToken,
308
+ body: {
309
+ external_google_enabled: true,
310
+ external_google_client_id: googleClientId,
311
+ external_google_secret: googleClientSecret,
312
+ },
313
+ });
314
+ printJson({
315
+ ok: true,
316
+ command: "enable-google-provider",
317
+ projectRef,
318
+ externalGoogleEnabled: true,
319
+ applied: ["external_google_enabled", "external_google_client_id", "external_google_secret"],
320
+ });
321
+ }
322
+ async function applyAuthTemplates(flags) {
323
+ const { envBootstrapPath, values } = loadLocalEnv();
324
+ const projectRef = resolveProjectRef(flags, values);
325
+ if (!projectRef) {
326
+ fail("MISSING_PROJECT_REF", "SUPABASE_PROJECT_REF is missing. Add it to .env.bootstrap.local or ensure NEXT_PUBLIC_SUPABASE_URL is present in .env.local.");
327
+ }
328
+ const managementToken = requireEnvValue(values, "SUPABASE_MANAGEMENT_TOKEN", path.basename(envBootstrapPath));
329
+ const desiredFields = buildTemplateDesiredFields({
330
+ confirmEmailEnabled: readStringFlag(flags, "confirm-email-enabled") === "true",
331
+ confirmEmailSubject: readStringFlag(flags, "confirm-email-subject"),
332
+ confirmEmailPath: readStringFlag(flags, "confirm-email-path"),
333
+ resetPasswordEnabled: readStringFlag(flags, "reset-password-enabled") === "true",
334
+ resetPasswordSubject: readStringFlag(flags, "reset-password-subject"),
335
+ resetPasswordPath: readStringFlag(flags, "reset-password-path"),
336
+ });
337
+ const current = await managementRequest({ method: "GET", projectRef, token: managementToken });
338
+ const currentAuthConfig = readAuthConfigEnvelope(current);
339
+ const diff = diffTemplateFields(currentAuthConfig, desiredFields);
340
+ if (!diff.noChanges) {
341
+ await managementRequest({ method: "PATCH", projectRef, token: managementToken, body: diff.patch });
342
+ }
343
+ printJson({
344
+ ok: true,
345
+ command: "apply-auth-templates",
346
+ projectRef,
347
+ changedKeys: diff.changedKeys,
348
+ appliedKeys: diff.changedKeys,
349
+ noChanges: diff.noChanges,
350
+ });
351
+ }
352
+ async function main() {
353
+ const { command, flags } = parseArgs(process.argv.slice(2));
354
+ if (!command || command === "--help" || command === "help") {
355
+ printJson({
356
+ ok: true,
357
+ commands: [
358
+ "configure-site-redirects",
359
+ "configure-email-password",
360
+ "enable-google-provider",
361
+ "apply-auth-templates",
362
+ ],
363
+ });
364
+ return;
365
+ }
366
+ if (command === "configure-site-redirects")
367
+ return configureSiteRedirects(flags);
368
+ if (command === "configure-email-password")
369
+ return configureEmailPassword(flags);
370
+ if (command === "enable-google-provider")
371
+ return enableGoogleProvider(flags);
372
+ if (command === "apply-auth-templates")
373
+ return applyAuthTemplates(flags);
374
+ fail("UNKNOWN_COMMAND", `Unknown command: ${command}`);
375
+ }
376
+ main().catch((error) => {
377
+ fail("UNEXPECTED_ERROR", error instanceof Error ? error.message : "Unexpected CLI error");
378
+ });
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@vibecodemax/cli",
3
+ "version": "0.1.0",
4
+ "description": "Local VibeCodeMax CLI for bootstrap and future project operations",
5
+ "type": "module",
6
+ "bin": {
7
+ "vibecodemax-cli": "./dist/cli.js"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "README.md",
12
+ "LICENSE"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsc -p tsconfig.json",
16
+ "typecheck": "tsc -p tsconfig.json --noEmit"
17
+ },
18
+ "engines": {
19
+ "node": ">=20"
20
+ },
21
+ "devDependencies": {
22
+ "@types/node": "^24.0.0",
23
+ "typescript": "^5.9.0"
24
+ },
25
+ "license": "Apache-2.0",
26
+ "author": "Gwinyai Nyatsoka",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/VibeCodeMax/cli"
30
+ },
31
+ "homepage": "https://github.com/VibeCodeMax/cli#readme",
32
+ "bugs": {
33
+ "url": "https://github.com/VibeCodeMax/cli/issues"
34
+ }
35
+ }