@vtriv/cli 0.1.2 → 0.1.3

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 (3) hide show
  1. package/README.md +3 -0
  2. package/index.ts +31 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -123,6 +123,9 @@ vtriv template set ai-enabled <<< '{"x-db": true, "x-blob": true, "x-ai": true}'
123
123
 
124
124
  # Delete a template (cannot delete 'default')
125
125
  vtriv template rm ai-enabled
126
+
127
+ # Reset templates to server defaults (useful after server updates)
128
+ vtriv template reset
126
129
  ```
127
130
 
128
131
  ### Database Commands
package/index.ts CHANGED
@@ -694,6 +694,37 @@ template
694
694
  console.log(chalk.green(`Template '${name}' deleted.`));
695
695
  });
696
696
 
697
+ template
698
+ .command("reset")
699
+ .description("Reset templates to server defaults")
700
+ .action(async () => {
701
+ const opts = program.opts<GlobalOptions>();
702
+ const { config, profile, fullProjectName } = getProfile(opts.profile);
703
+
704
+ const res = await fetch(`${config.baseUrl}/auth/${fullProjectName}/templates/_reset`, {
705
+ method: "POST",
706
+ headers: { Authorization: `Bearer ${profile.apiKey}` },
707
+ });
708
+
709
+ if (!res.ok) {
710
+ const data = await res.json();
711
+ error((data as { error?: string }).error || "Failed to reset templates", opts);
712
+ }
713
+
714
+ const data = (await res.json()) as { templates: Record<string, { claims: Record<string, unknown> }> };
715
+
716
+ if (opts.json) {
717
+ console.log(JSON.stringify(data.templates, null, 2));
718
+ } else {
719
+ console.log(chalk.green("Templates reset to defaults:"));
720
+ const rows = Object.entries(data.templates).map(([name, tmpl]) => ({
721
+ name,
722
+ claims: JSON.stringify(tmpl.claims),
723
+ }));
724
+ printTable(rows);
725
+ }
726
+ });
727
+
697
728
  // =============================================================================
698
729
  // DB Commands
699
730
  // =============================================================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtriv/cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "description": "CLI for vtriv backend services - auth, db, blob, search, ai, cron",