@rulebricks/cli 1.9.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 (93) hide show
  1. package/README.md +62 -0
  2. package/dist/commands/clone.d.ts +6 -0
  3. package/dist/commands/clone.js +60 -0
  4. package/dist/commands/deploy.d.ts +8 -0
  5. package/dist/commands/deploy.js +409 -0
  6. package/dist/commands/destroy.d.ts +8 -0
  7. package/dist/commands/destroy.js +298 -0
  8. package/dist/commands/init.d.ts +7 -0
  9. package/dist/commands/init.js +201 -0
  10. package/dist/commands/logs.d.ts +9 -0
  11. package/dist/commands/logs.js +222 -0
  12. package/dist/commands/open.d.ts +7 -0
  13. package/dist/commands/open.js +139 -0
  14. package/dist/commands/status.d.ts +5 -0
  15. package/dist/commands/status.js +125 -0
  16. package/dist/commands/upgrade.d.ts +7 -0
  17. package/dist/commands/upgrade.js +239 -0
  18. package/dist/components/DNSWaitScreen.d.ts +9 -0
  19. package/dist/components/DNSWaitScreen.js +73 -0
  20. package/dist/components/Wizard/WizardContext.d.ts +176 -0
  21. package/dist/components/Wizard/WizardContext.js +346 -0
  22. package/dist/components/Wizard/index.d.ts +2 -0
  23. package/dist/components/Wizard/index.js +2 -0
  24. package/dist/components/Wizard/steps/CloudProviderStep.d.ts +6 -0
  25. package/dist/components/Wizard/steps/CloudProviderStep.js +210 -0
  26. package/dist/components/Wizard/steps/CredentialsStep.d.ts +6 -0
  27. package/dist/components/Wizard/steps/CredentialsStep.js +22 -0
  28. package/dist/components/Wizard/steps/DatabaseStep.d.ts +6 -0
  29. package/dist/components/Wizard/steps/DatabaseStep.js +80 -0
  30. package/dist/components/Wizard/steps/DeploymentModeStep.d.ts +5 -0
  31. package/dist/components/Wizard/steps/DeploymentModeStep.js +26 -0
  32. package/dist/components/Wizard/steps/DomainStep.d.ts +6 -0
  33. package/dist/components/Wizard/steps/DomainStep.js +126 -0
  34. package/dist/components/Wizard/steps/FeatureConfigStep.d.ts +6 -0
  35. package/dist/components/Wizard/steps/FeatureConfigStep.js +765 -0
  36. package/dist/components/Wizard/steps/FeaturesStep.d.ts +6 -0
  37. package/dist/components/Wizard/steps/FeaturesStep.js +119 -0
  38. package/dist/components/Wizard/steps/ReviewStep.d.ts +6 -0
  39. package/dist/components/Wizard/steps/ReviewStep.js +56 -0
  40. package/dist/components/Wizard/steps/SMTPStep.d.ts +6 -0
  41. package/dist/components/Wizard/steps/SMTPStep.js +191 -0
  42. package/dist/components/Wizard/steps/SupabaseCredentialsStep.d.ts +6 -0
  43. package/dist/components/Wizard/steps/SupabaseCredentialsStep.js +76 -0
  44. package/dist/components/Wizard/steps/TierStep.d.ts +6 -0
  45. package/dist/components/Wizard/steps/TierStep.js +29 -0
  46. package/dist/components/Wizard/steps/VersionStep.d.ts +6 -0
  47. package/dist/components/Wizard/steps/VersionStep.js +113 -0
  48. package/dist/components/Wizard/steps/index.d.ts +12 -0
  49. package/dist/components/Wizard/steps/index.js +12 -0
  50. package/dist/components/common/AppShell.d.ts +31 -0
  51. package/dist/components/common/AppShell.js +31 -0
  52. package/dist/components/common/Box.d.ts +20 -0
  53. package/dist/components/common/Box.js +20 -0
  54. package/dist/components/common/Logo.d.ts +7 -0
  55. package/dist/components/common/Logo.js +22 -0
  56. package/dist/components/common/Spinner.d.ts +12 -0
  57. package/dist/components/common/Spinner.js +28 -0
  58. package/dist/components/common/index.d.ts +6 -0
  59. package/dist/components/common/index.js +5 -0
  60. package/dist/index.d.ts +2 -0
  61. package/dist/index.js +202 -0
  62. package/dist/lib/cloudCli.d.ts +156 -0
  63. package/dist/lib/cloudCli.js +691 -0
  64. package/dist/lib/config.d.ts +91 -0
  65. package/dist/lib/config.js +278 -0
  66. package/dist/lib/dns.d.ts +41 -0
  67. package/dist/lib/dns.js +235 -0
  68. package/dist/lib/dockerHub.d.ts +57 -0
  69. package/dist/lib/dockerHub.js +128 -0
  70. package/dist/lib/helm.d.ts +53 -0
  71. package/dist/lib/helm.js +209 -0
  72. package/dist/lib/helmValues.d.ts +17 -0
  73. package/dist/lib/helmValues.js +693 -0
  74. package/dist/lib/kubernetes.d.ts +161 -0
  75. package/dist/lib/kubernetes.js +755 -0
  76. package/dist/lib/terraform.d.ts +44 -0
  77. package/dist/lib/terraform.js +230 -0
  78. package/dist/lib/theme.d.ts +81 -0
  79. package/dist/lib/theme.js +115 -0
  80. package/dist/lib/validation.d.ts +47 -0
  81. package/dist/lib/validation.js +164 -0
  82. package/dist/lib/versions.d.ts +69 -0
  83. package/dist/lib/versions.js +139 -0
  84. package/dist/types/index.d.ts +718 -0
  85. package/dist/types/index.js +556 -0
  86. package/email-templates/email_change.html +325 -0
  87. package/email-templates/invite.html +383 -0
  88. package/email-templates/password_change.html +414 -0
  89. package/email-templates/verify.html +396 -0
  90. package/package.json +78 -0
  91. package/terraform/aws/main.tf +327 -0
  92. package/terraform/azure/main.tf +326 -0
  93. package/terraform/gcp/main.tf +369 -0
@@ -0,0 +1,69 @@
1
+ import { ChartVersion, AppVersion } from "../types/index.js";
2
+ import { ImageTag } from "./dockerHub.js";
3
+ /**
4
+ * Gets version information for display (legacy chart-based)
5
+ */
6
+ export interface VersionInfo {
7
+ current: string | null;
8
+ latest: string | null;
9
+ available: ChartVersion[];
10
+ hasUpdate: boolean;
11
+ changelogUrl: string;
12
+ }
13
+ /**
14
+ * App version information with matched HPS version
15
+ */
16
+ export interface AppVersionInfo {
17
+ current: AppVersion | null;
18
+ latest: AppVersion | null;
19
+ available: AppVersion[];
20
+ hasUpdate: boolean;
21
+ changelogUrl: string;
22
+ }
23
+ /**
24
+ * Fetches complete version information (legacy chart-based)
25
+ */
26
+ export declare function getVersionInfo(deploymentName: string, overrideNamespace?: string): Promise<VersionInfo>;
27
+ /**
28
+ * Matches HPS versions to app versions based on release dates.
29
+ * For each app version, finds the latest HPS version released on or before that date.
30
+ * Compares dates only (ignoring time), so an HPS released later in the same day
31
+ * as the app version will still be matched.
32
+ *
33
+ * @param appTags - Array of app image tags
34
+ * @param hpsTags - Array of HPS image tags
35
+ * @returns Array of AppVersion with matched HPS versions
36
+ */
37
+ export declare function matchHpsVersions(appTags: ImageTag[], hpsTags: ImageTag[]): AppVersion[];
38
+ /**
39
+ * Fetches app versions with matched HPS versions from Docker Hub
40
+ *
41
+ * @param licenseKey - The Rulebricks license key (Docker PAT)
42
+ * @returns Array of AppVersion objects
43
+ */
44
+ export declare function fetchAppVersions(licenseKey: string): Promise<AppVersion[]>;
45
+ /**
46
+ * Gets complete app version information for a deployment
47
+ *
48
+ * @param licenseKey - The Rulebricks license key
49
+ * @param currentAppVersion - Currently installed app version (if known)
50
+ * @returns AppVersionInfo with current, latest, and available versions
51
+ */
52
+ export declare function getAppVersionInfo(licenseKey: string, currentAppVersion?: string | null): Promise<AppVersionInfo>;
53
+ /**
54
+ * Formats a version for display
55
+ */
56
+ export declare function formatVersion(version: string | null): string;
57
+ /**
58
+ * Compares two versions
59
+ * Returns: negative if a < b, positive if a > b, 0 if equal
60
+ */
61
+ export declare function compareVersions(a: string, b: string): number;
62
+ /**
63
+ * Checks if a version is newer than another
64
+ */
65
+ export declare function isNewerVersion(version: string, than: string): boolean;
66
+ /**
67
+ * Formats a date for display
68
+ */
69
+ export declare function formatDate(dateString: string): string;
@@ -0,0 +1,139 @@
1
+ import { CHANGELOG_URL, getNamespace, getReleaseName, } from "../types/index.js";
2
+ import { fetchChartVersions, getInstalledVersion } from "./helm.js";
3
+ import { fetchAllImageTags, normalizeVersion, } from "./dockerHub.js";
4
+ /**
5
+ * Fetches complete version information (legacy chart-based)
6
+ */
7
+ export async function getVersionInfo(deploymentName, overrideNamespace) {
8
+ const namespace = overrideNamespace || getNamespace(deploymentName);
9
+ const releaseName = getReleaseName(deploymentName);
10
+ const [current, available] = await Promise.all([
11
+ getInstalledVersion(releaseName, namespace),
12
+ fetchChartVersions(),
13
+ ]);
14
+ const latest = available.length > 0 ? available[0].version : null;
15
+ const hasUpdate = !!(current && latest && current !== latest);
16
+ return {
17
+ current,
18
+ latest,
19
+ available,
20
+ hasUpdate,
21
+ changelogUrl: CHANGELOG_URL,
22
+ };
23
+ }
24
+ /**
25
+ * Normalizes a Date to the start of day (midnight UTC).
26
+ * This allows comparing dates without time components.
27
+ */
28
+ function toStartOfDay(date) {
29
+ const d = new Date(date);
30
+ d.setUTCHours(0, 0, 0, 0);
31
+ return d;
32
+ }
33
+ /**
34
+ * Matches HPS versions to app versions based on release dates.
35
+ * For each app version, finds the latest HPS version released on or before that date.
36
+ * Compares dates only (ignoring time), so an HPS released later in the same day
37
+ * as the app version will still be matched.
38
+ *
39
+ * @param appTags - Array of app image tags
40
+ * @param hpsTags - Array of HPS image tags
41
+ * @returns Array of AppVersion with matched HPS versions
42
+ */
43
+ export function matchHpsVersions(appTags, hpsTags) {
44
+ // Sort HPS tags by date descending for efficient matching
45
+ const sortedHpsTags = [...hpsTags].sort((a, b) => b.lastUpdated.getTime() - a.lastUpdated.getTime());
46
+ return appTags.map((appTag) => {
47
+ // Normalize app release date to start of day for comparison
48
+ const appDateStart = toStartOfDay(appTag.lastUpdated);
49
+ // Find the latest HPS version released on or before the app version's date
50
+ // Compare by date only (start of day), ignoring time
51
+ const matchedHps = sortedHpsTags.find((hpsTag) => toStartOfDay(hpsTag.lastUpdated).getTime() <= appDateStart.getTime());
52
+ return {
53
+ version: normalizeVersion(appTag.name),
54
+ releaseDate: appTag.lastUpdated.toISOString(),
55
+ hpsVersion: matchedHps ? normalizeVersion(matchedHps.name) : null,
56
+ digest: appTag.digest,
57
+ };
58
+ });
59
+ }
60
+ /**
61
+ * Fetches app versions with matched HPS versions from Docker Hub
62
+ *
63
+ * @param licenseKey - The Rulebricks license key (Docker PAT)
64
+ * @returns Array of AppVersion objects
65
+ */
66
+ export async function fetchAppVersions(licenseKey) {
67
+ const { appTags, hpsTags } = await fetchAllImageTags(licenseKey);
68
+ return matchHpsVersions(appTags, hpsTags);
69
+ }
70
+ /**
71
+ * Gets complete app version information for a deployment
72
+ *
73
+ * @param licenseKey - The Rulebricks license key
74
+ * @param currentAppVersion - Currently installed app version (if known)
75
+ * @returns AppVersionInfo with current, latest, and available versions
76
+ */
77
+ export async function getAppVersionInfo(licenseKey, currentAppVersion) {
78
+ const available = await fetchAppVersions(licenseKey);
79
+ const latest = available.length > 0 ? available[0] : null;
80
+ // Find current version in available list
81
+ const current = currentAppVersion
82
+ ? available.find((v) => v.version === normalizeVersion(currentAppVersion)) || null
83
+ : null;
84
+ const hasUpdate = !!(current &&
85
+ latest &&
86
+ normalizeVersion(current.version) !== normalizeVersion(latest.version));
87
+ return {
88
+ current,
89
+ latest,
90
+ available,
91
+ hasUpdate,
92
+ changelogUrl: CHANGELOG_URL,
93
+ };
94
+ }
95
+ /**
96
+ * Formats a version for display
97
+ */
98
+ export function formatVersion(version) {
99
+ if (!version)
100
+ return "Not installed";
101
+ return version.startsWith("v") ? version : `v${version}`;
102
+ }
103
+ /**
104
+ * Compares two versions
105
+ * Returns: negative if a < b, positive if a > b, 0 if equal
106
+ */
107
+ export function compareVersions(a, b) {
108
+ const parseVersion = (v) => {
109
+ const clean = v.replace(/^v/, "");
110
+ return clean.split(".").map((n) => parseInt(n, 10) || 0);
111
+ };
112
+ const aParts = parseVersion(a);
113
+ const bParts = parseVersion(b);
114
+ for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {
115
+ const aVal = aParts[i] ?? 0;
116
+ const bVal = bParts[i] ?? 0;
117
+ if (aVal !== bVal) {
118
+ return aVal - bVal;
119
+ }
120
+ }
121
+ return 0;
122
+ }
123
+ /**
124
+ * Checks if a version is newer than another
125
+ */
126
+ export function isNewerVersion(version, than) {
127
+ return compareVersions(version, than) > 0;
128
+ }
129
+ /**
130
+ * Formats a date for display
131
+ */
132
+ export function formatDate(dateString) {
133
+ const date = new Date(dateString);
134
+ return date.toLocaleDateString("en-US", {
135
+ year: "numeric",
136
+ month: "short",
137
+ day: "numeric",
138
+ });
139
+ }