@snap/valdi 1.0.7 → 1.0.11

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 (170) hide show
  1. package/.bootstrap/modules/{ios_android_bridge_module → polyglot_bridge_module}/BUILD.bazel.template +16 -1
  2. package/.bootstrap/modules/polyglot_bridge_module/web/Calculator.ts +11 -0
  3. package/.bootstrap/modules/polyglot_bridge_module/web/tsconfig.json +16 -0
  4. package/.bootstrap/modules/polyglot_view_module/BUILD.bazel.template +75 -0
  5. package/.bootstrap/modules/polyglot_view_module/android/PolyglotNativeView.kt.template +41 -0
  6. package/.bootstrap/modules/polyglot_view_module/android/PolyglotNativeViewAttributesBinder.kt.template +17 -0
  7. package/.bootstrap/modules/polyglot_view_module/ios/SCPolyglotView.h +8 -0
  8. package/.bootstrap/modules/polyglot_view_module/ios/SCPolyglotView.m +23 -0
  9. package/.bootstrap/modules/polyglot_view_module/macos/SCPolyglotView.h +8 -0
  10. package/.bootstrap/modules/polyglot_view_module/macos/SCPolyglotView.m +23 -0
  11. package/.bootstrap/modules/polyglot_view_module/src/PolyglotCustomView.tsx.template +23 -0
  12. package/.bootstrap/modules/polyglot_view_module/web/PolyglotWeb.ts.template +30 -0
  13. package/.bootstrap/modules/polyglot_view_module/web/tsconfig.json +16 -0
  14. package/.metadata/AGENTS.md.template +8 -274
  15. package/.metadata/skill-reference.tsx.template +8 -0
  16. package/.metadata/skill-tests-BUILD.bazel.template +21 -0
  17. package/.metadata/skill-tests-README.md.template +17 -0
  18. package/.metadata/skill.md.template +27 -0
  19. package/README.md +12 -3
  20. package/bundled-skills/CONTRIBUTING_SKILLS.md +74 -0
  21. package/bundled-skills/registry.json +21 -0
  22. package/bundled-skills/skills/valdi-android/skill.md +89 -0
  23. package/bundled-skills/skills/valdi-async/skill.md +246 -0
  24. package/bundled-skills/skills/valdi-async/tests/BUILD.bazel +19 -0
  25. package/bundled-skills/skills/valdi-async/tests/README.md +25 -0
  26. package/bundled-skills/skills/valdi-async/tests/src/reference.tsx +210 -0
  27. package/bundled-skills/skills/valdi-async/tests/tsconfig.json +1 -0
  28. package/bundled-skills/skills/valdi-bazel/skill.md +141 -0
  29. package/bundled-skills/skills/valdi-compiler/skill.md +108 -0
  30. package/bundled-skills/skills/valdi-component-tests/skill.md +430 -0
  31. package/bundled-skills/skills/valdi-component-tests/tests/BUILD.bazel +24 -0
  32. package/bundled-skills/skills/valdi-component-tests/tests/README.md +35 -0
  33. package/bundled-skills/skills/valdi-component-tests/tests/src/ProfileCard.tsx +38 -0
  34. package/bundled-skills/skills/valdi-component-tests/tests/test/ProfileCardTest.spec.tsx +107 -0
  35. package/bundled-skills/skills/valdi-component-tests/tests/tsconfig.json +1 -0
  36. package/bundled-skills/skills/valdi-cpp-runtime/skill.md +103 -0
  37. package/bundled-skills/skills/valdi-custom-view/skill.md +64 -0
  38. package/bundled-skills/skills/valdi-inspect/skill.md +199 -0
  39. package/bundled-skills/skills/valdi-ios/skill.md +93 -0
  40. package/bundled-skills/skills/valdi-migrate/skill.md +175 -0
  41. package/bundled-skills/skills/valdi-migrate/tests/BUILD.bazel +23 -0
  42. package/bundled-skills/skills/valdi-migrate/tests/README.md +70 -0
  43. package/bundled-skills/skills/valdi-migrate/tests/check_antipatterns.py +89 -0
  44. package/bundled-skills/skills/valdi-migrate/tests/compose_example.kt +94 -0
  45. package/bundled-skills/skills/valdi-migrate/tests/flutter_example.dart +129 -0
  46. package/bundled-skills/skills/valdi-migrate/tests/react_example.tsx +98 -0
  47. package/bundled-skills/skills/valdi-migrate/tests/src/expected_valdi.tsx +267 -0
  48. package/bundled-skills/skills/valdi-migrate/tests/tsconfig.json +3 -0
  49. package/bundled-skills/skills/valdi-overview/skill.md +63 -0
  50. package/bundled-skills/skills/valdi-perf/skill.md +197 -0
  51. package/bundled-skills/skills/valdi-perf/tests/BUILD.bazel +19 -0
  52. package/bundled-skills/skills/valdi-perf/tests/README.md +26 -0
  53. package/bundled-skills/skills/valdi-perf/tests/src/reference.tsx +202 -0
  54. package/bundled-skills/skills/valdi-perf/tests/tsconfig.json +1 -0
  55. package/bundled-skills/skills/valdi-polyglot-module/skill.md +124 -0
  56. package/bundled-skills/skills/valdi-profile/skill.md +126 -0
  57. package/bundled-skills/skills/valdi-setup/skill.md +129 -0
  58. package/bundled-skills/skills/valdi-testing/skill.md +65 -0
  59. package/bundled-skills/skills/valdi-tsx/skill.md +385 -0
  60. package/bundled-skills/skills/valdi-tsx/tests/BUILD.bazel +19 -0
  61. package/bundled-skills/skills/valdi-tsx/tests/README.md +29 -0
  62. package/bundled-skills/skills/valdi-tsx/tests/src/reference.tsx +173 -0
  63. package/bundled-skills/skills/valdi-tsx/tests/tsconfig.json +1 -0
  64. package/dist/commands/bootstrap.js +0 -7
  65. package/dist/commands/inspect.js +16 -0
  66. package/dist/commands/inspect_commands/contexts.js +55 -0
  67. package/dist/commands/inspect_commands/devices.js +53 -0
  68. package/dist/commands/inspect_commands/heap.js +59 -0
  69. package/dist/commands/inspect_commands/select.js +43 -0
  70. package/dist/commands/inspect_commands/snapshot.js +64 -0
  71. package/dist/commands/inspect_commands/status.js +68 -0
  72. package/dist/commands/inspect_commands/tree.js +86 -0
  73. package/dist/commands/newModule.js +10 -14
  74. package/dist/commands/profile.js +16 -0
  75. package/dist/commands/profile_commands/capture.js +106 -0
  76. package/dist/commands/skills.js +16 -0
  77. package/dist/commands/skills_commands/create.js +125 -0
  78. package/dist/commands/skills_commands/install.js +96 -0
  79. package/dist/commands/skills_commands/list.js +83 -0
  80. package/dist/commands/skills_commands/remove.js +41 -0
  81. package/dist/commands/skills_commands/update.js +59 -0
  82. package/dist/core/constants.js +0 -1
  83. package/dist/core/packageFiles.spec.js +29 -0
  84. package/dist/setup/versions.js +1 -1
  85. package/dist/utils/daemonClient.js +342 -0
  86. package/dist/utils/hermesClient.js +252 -0
  87. package/dist/utils/skillsAdapters.js +140 -0
  88. package/dist/utils/skillsRegistry.js +40 -0
  89. package/dist/utils/stringUtils.spec.js +1 -1
  90. package/package.json +20 -5
  91. package/.bazelignore +0 -2
  92. package/.bootstrap/modules/cpp_bridge_module/BUILD.bazel.template +0 -21
  93. package/.bootstrap/modules/cpp_bridge_module/cpp/CalculatorModuleFactory.cpp.template +0 -28
  94. package/.bootstrap/modules/ios_android_bridge_module/src/Calculator.d.ts +0 -4
  95. package/.bootstrap/modules/ios_android_view_module/BUILD.bazel.template +0 -41
  96. package/.bootstrap/modules/ios_android_view_module/android/CircleView.kt.template +0 -42
  97. package/.bootstrap/modules/ios_android_view_module/android/CircleViewAttributesBinder.kt.template +0 -60
  98. package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.h +0 -6
  99. package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.m +0 -82
  100. package/.bootstrap/modules/ios_android_view_module/src/Circle.tsx.template +0 -15
  101. package/.config/copyconfig.json +0 -10
  102. package/.editorconfig +0 -21
  103. package/.eslintignore +0 -1
  104. package/.eslintrc.js +0 -72
  105. package/.github/README.md +0 -164
  106. package/.metadata/.cursorrules.template +0 -60
  107. package/.prettierignore +0 -2
  108. package/.prettierrc.json +0 -7
  109. package/LINUX_COMPATIBILITY.md +0 -248
  110. package/prettier.config.js +0 -4
  111. package/scripts/sync-agents-md.sh +0 -44
  112. package/scripts/update-agents-templates.ts +0 -170
  113. package/spec/support/jasmine.json +0 -6
  114. package/src/commands/bootstrap.ts +0 -410
  115. package/src/commands/build.ts +0 -89
  116. package/src/commands/devSetup.ts +0 -17
  117. package/src/commands/doctor.ts +0 -1832
  118. package/src/commands/export.ts +0 -131
  119. package/src/commands/hotreload.ts +0 -108
  120. package/src/commands/install.ts +0 -93
  121. package/src/commands/lint.ts +0 -15
  122. package/src/commands/lint_commands/lintCheck.ts +0 -53
  123. package/src/commands/lint_commands/lintFormat.ts +0 -49
  124. package/src/commands/log.ts +0 -108
  125. package/src/commands/newModule.ts +0 -286
  126. package/src/commands/package.ts +0 -102
  127. package/src/commands/projectsync.ts +0 -488
  128. package/src/commands/test.ts +0 -68
  129. package/src/core/constants.ts +0 -98
  130. package/src/core/errors.ts +0 -10
  131. package/src/index.ts +0 -27
  132. package/src/setup/DevSetupHelper.ts +0 -290
  133. package/src/setup/linuxSetup.ts +0 -261
  134. package/src/setup/macOSSetup.ts +0 -156
  135. package/src/setup/setupEntryPoint.ts +0 -64
  136. package/src/setup/versions.ts +0 -8
  137. package/src/utils/ArgumentsResolver.ts +0 -23
  138. package/src/utils/BazelClient.ts +0 -285
  139. package/src/utils/Digraph.ts +0 -81
  140. package/src/utils/LoadingIndicator.ts +0 -43
  141. package/src/utils/applicationUtils.ts +0 -276
  142. package/src/utils/buildInfo.ts +0 -99
  143. package/src/utils/byString.ts +0 -3
  144. package/src/utils/cliUtils.ts +0 -112
  145. package/src/utils/copyBootstrapFiles.ts +0 -30
  146. package/src/utils/deviceUtils.ts +0 -76
  147. package/src/utils/errorUtils.ts +0 -63
  148. package/src/utils/fileUtils.ts +0 -257
  149. package/src/utils/githubUtils.ts +0 -102
  150. package/src/utils/jsonUtils.ts +0 -30
  151. package/src/utils/lintUtils.ts +0 -190
  152. package/src/utils/linuxDistro.spec.ts +0 -219
  153. package/src/utils/linuxDistro.ts +0 -326
  154. package/src/utils/logUtils.ts +0 -9
  155. package/src/utils/pathUtils.ts +0 -12
  156. package/src/utils/stringUtils.spec.ts +0 -95
  157. package/src/utils/stringUtils.ts +0 -103
  158. package/src/utils/tempDir.ts +0 -24
  159. package/src/utils/zipUtils.ts +0 -14
  160. package/test/ValdiSmokeTest.ts +0 -279
  161. package/test/helpers/AsyncHelpers.ts +0 -113
  162. package/test/helpers/CommandHelpers.ts +0 -37
  163. package/test/helpers/ProjectHelpers.ts +0 -153
  164. package/test/helpers/StreamHelpers.ts +0 -37
  165. package/test/helpers/TypeScriptClient.ts +0 -217
  166. package/tsconfig.dist.json +0 -8
  167. package/tsconfig.json +0 -42
  168. /package/.bootstrap/modules/{ios_android_bridge_module → polyglot_bridge_module}/android/CalculatorModuleFactory.kt.template +0 -0
  169. /package/.bootstrap/modules/{ios_android_bridge_module → polyglot_bridge_module}/ios/SCCCalculatorModuleFactory.m.template +0 -0
  170. /package/.bootstrap/modules/{cpp_bridge_module → polyglot_bridge_module}/src/Calculator.d.ts +0 -0
@@ -1,219 +0,0 @@
1
- import 'jasmine';
2
- import {
3
- type LinuxDistroInfo,
4
- LinuxDistroType,
5
- buildInstallCommand,
6
- getCommonPackageMappings,
7
- getGitLfsRepoSetupCommand,
8
- getPackageName,
9
- needsGitLfsRepoSetup,
10
- } from './linuxDistro';
11
-
12
- describe('linuxDistro', () => {
13
- describe('getPackageName', () => {
14
- it('returns Debian package name for Debian distribution', () => {
15
- const packageMap = {
16
- debian: 'openjdk-17-jdk',
17
- redhat: 'java-17-openjdk-devel',
18
- unknown: 'openjdk-17',
19
- };
20
-
21
- const distro: LinuxDistroInfo = {
22
- type: LinuxDistroType.DEBIAN,
23
- name: 'Ubuntu',
24
- packageManager: { name: 'apt', installCommand: 'apt-get install', requiresSudo: true },
25
- };
26
-
27
- const result = getPackageName(packageMap, distro);
28
-
29
- expect(result).toBe('openjdk-17-jdk');
30
- });
31
-
32
- it('returns RedHat package name for RedHat distribution', () => {
33
- const packageMap = {
34
- debian: 'openjdk-17-jdk',
35
- redhat: 'java-17-openjdk-devel',
36
- unknown: 'openjdk-17',
37
- };
38
-
39
- const distro: LinuxDistroInfo = {
40
- type: LinuxDistroType.REDHAT,
41
- name: 'Fedora',
42
- packageManager: { name: 'dnf', installCommand: 'dnf install', requiresSudo: true },
43
- };
44
-
45
- const result = getPackageName(packageMap, distro);
46
-
47
- expect(result).toBe('java-17-openjdk-devel');
48
- });
49
-
50
- it('returns unknown fallback for distributions without specific mapping', () => {
51
- const packageMap = {
52
- debian: 'openjdk-17-jdk',
53
- unknown: 'openjdk-17',
54
- };
55
-
56
- const distro: LinuxDistroInfo = {
57
- type: LinuxDistroType.ARCH,
58
- name: 'Arch Linux',
59
- packageManager: { name: 'pacman', installCommand: 'pacman -S', requiresSudo: true },
60
- };
61
-
62
- const result = getPackageName(packageMap, distro);
63
-
64
- expect(result).toBe('openjdk-17');
65
- });
66
- });
67
-
68
- describe('buildInstallCommand', () => {
69
- it('builds install command for Debian', () => {
70
- const distro: LinuxDistroInfo = {
71
- type: LinuxDistroType.DEBIAN,
72
- name: 'Ubuntu',
73
- packageManager: { name: 'apt', installCommand: 'apt-get install', requiresSudo: true },
74
- };
75
-
76
- const result = buildInstallCommand(['git', 'npm', 'watchman'], distro);
77
-
78
- expect(result).toBe('sudo apt-get install git npm watchman');
79
- });
80
-
81
- it('builds install command for RedHat', () => {
82
- const distro: LinuxDistroInfo = {
83
- type: LinuxDistroType.REDHAT,
84
- name: 'Fedora',
85
- packageManager: { name: 'dnf', installCommand: 'dnf install', requiresSudo: true },
86
- };
87
-
88
- const result = buildInstallCommand(['git', 'npm'], distro);
89
-
90
- expect(result).toBe('sudo dnf install git npm');
91
- });
92
-
93
- it('builds install command for Arch', () => {
94
- const distro: LinuxDistroInfo = {
95
- type: LinuxDistroType.ARCH,
96
- name: 'Arch Linux',
97
- packageManager: { name: 'pacman', installCommand: 'pacman -S', requiresSudo: true },
98
- };
99
-
100
- const result = buildInstallCommand(['git', 'npm'], distro);
101
-
102
- expect(result).toBe('sudo pacman -S git npm');
103
- });
104
-
105
- it('returns comment for unknown distribution', () => {
106
- const distro: LinuxDistroInfo = {
107
- type: LinuxDistroType.UNKNOWN,
108
- name: 'Unknown',
109
- packageManager: { name: 'unknown', installCommand: '', requiresSudo: true },
110
- };
111
-
112
- const result = buildInstallCommand(['git', 'npm'], distro);
113
-
114
- expect(result).toContain('Unable to determine package manager');
115
- expect(result).toContain('git, npm');
116
- });
117
- });
118
-
119
- describe('needsGitLfsRepoSetup', () => {
120
- it('returns true for Debian distributions', () => {
121
- const distro: LinuxDistroInfo = {
122
- type: LinuxDistroType.DEBIAN,
123
- name: 'Ubuntu',
124
- packageManager: { name: 'apt', installCommand: 'apt-get install', requiresSudo: true },
125
- };
126
-
127
- expect(needsGitLfsRepoSetup(distro)).toBe(true);
128
- });
129
-
130
- it('returns false for Arch distributions', () => {
131
- const distro: LinuxDistroInfo = {
132
- type: LinuxDistroType.ARCH,
133
- name: 'Arch Linux',
134
- packageManager: { name: 'pacman', installCommand: 'pacman -S', requiresSudo: true },
135
- };
136
-
137
- expect(needsGitLfsRepoSetup(distro)).toBe(false);
138
- });
139
- });
140
-
141
- describe('getGitLfsRepoSetupCommand', () => {
142
- it('returns Debian script for Debian distributions', () => {
143
- const distro: LinuxDistroInfo = {
144
- type: LinuxDistroType.DEBIAN,
145
- name: 'Ubuntu',
146
- packageManager: { name: 'apt', installCommand: 'apt-get install', requiresSudo: true },
147
- };
148
-
149
- const result = getGitLfsRepoSetupCommand(distro);
150
-
151
- expect(result).toContain('script.deb.sh');
152
- });
153
-
154
- it('returns RPM script for RedHat distributions', () => {
155
- const distro: LinuxDistroInfo = {
156
- type: LinuxDistroType.REDHAT,
157
- name: 'Fedora',
158
- packageManager: { name: 'dnf', installCommand: 'dnf install', requiresSudo: true },
159
- };
160
-
161
- const result = getGitLfsRepoSetupCommand(distro);
162
-
163
- expect(result).toContain('script.rpm.sh');
164
- });
165
-
166
- it('returns null for distributions with git-lfs in standard repos', () => {
167
- const distro: LinuxDistroInfo = {
168
- type: LinuxDistroType.ARCH,
169
- name: 'Arch Linux',
170
- packageManager: { name: 'pacman', installCommand: 'pacman -S', requiresSudo: true },
171
- };
172
-
173
- const result = getGitLfsRepoSetupCommand(distro);
174
-
175
- expect(result).toBeNull();
176
- });
177
- });
178
-
179
- describe('getCommonPackageMappings', () => {
180
- it('returns package mappings for common dependencies', () => {
181
- const mappings = getCommonPackageMappings();
182
-
183
- expect(mappings['git']).toBeDefined();
184
- expect(mappings['git-lfs']).toBeDefined();
185
- expect(mappings['npm']).toBeDefined();
186
- expect(mappings['openjdk-17']).toBeDefined();
187
- expect(mappings['watchman']).toBeDefined();
188
- expect(mappings['adb']).toBeDefined();
189
- expect(mappings['fontconfig']).toBeDefined();
190
- expect(mappings['zlib']).toBeDefined();
191
- });
192
-
193
- it('has platform-specific mappings for Java', () => {
194
- const mappings = getCommonPackageMappings();
195
- const javaMappings = mappings['openjdk-17'];
196
-
197
- expect(javaMappings).toBeDefined();
198
- if (javaMappings) {
199
- expect(javaMappings.debian).toBe('openjdk-17-jdk');
200
- expect(javaMappings.redhat).toBe('java-17-openjdk-devel');
201
- expect(javaMappings.arch).toBe('jdk17-openjdk');
202
- expect(javaMappings.suse).toBe('java-17-openjdk-devel');
203
- }
204
- });
205
-
206
- it('has platform-specific mappings for adb', () => {
207
- const mappings = getCommonPackageMappings();
208
- const adbMappings = mappings['adb'];
209
-
210
- expect(adbMappings).toBeDefined();
211
- if (adbMappings) {
212
- expect(adbMappings.debian).toBe('adb');
213
- expect(adbMappings.redhat).toBe('android-tools');
214
- expect(adbMappings.arch).toBe('android-tools');
215
- expect(adbMappings.suse).toBe('android-tools');
216
- }
217
- });
218
- });
219
- });
@@ -1,326 +0,0 @@
1
- import fs from 'fs';
2
- import { checkCommandExists } from './cliUtils';
3
-
4
- /**
5
- * Detected Linux distribution type
6
- */
7
- export enum LinuxDistroType {
8
- DEBIAN = 'debian', // Debian, Ubuntu, Mint, Pop!_OS, etc.
9
- REDHAT = 'redhat', // RHEL, Fedora, CentOS, Rocky Linux, etc.
10
- ARCH = 'arch', // Arch Linux, Manjaro, EndeavourOS, etc.
11
- SUSE = 'suse', // openSUSE, SLES, etc.
12
- UNKNOWN = 'unknown',
13
- }
14
-
15
- /**
16
- * Package manager information for a Linux distribution
17
- */
18
- export interface PackageManager {
19
- /** Name of the package manager */
20
- name: string;
21
- /** Command to install packages (without sudo) */
22
- installCommand: string;
23
- /** Whether this package manager requires sudo */
24
- requiresSudo: boolean;
25
- /** Command to update package database */
26
- updateCommand?: string;
27
- }
28
-
29
- /**
30
- * Linux distribution information
31
- */
32
- export interface LinuxDistroInfo {
33
- /** Distribution type */
34
- type: LinuxDistroType;
35
- /** Distribution name (e.g., "Ubuntu", "Fedora") */
36
- name: string;
37
- /** Distribution version (if available) */
38
- version?: string;
39
- /** Package manager information */
40
- packageManager: PackageManager;
41
- }
42
-
43
- /**
44
- * Infer distribution keys from the enum, excluding 'unknown'
45
- */
46
- type Distros = Exclude<`${LinuxDistroType}`, 'unknown'>;
47
-
48
- /**
49
- * Package name mappings for different distributions
50
- * Keys are automatically inferred from LinuxDistroType enum
51
- */
52
- export type PackageNameMap = {
53
- [K in Distros]?: string;
54
- } & {
55
- unknown: string; // Fallback for unknown distributions
56
- };
57
-
58
- /**
59
- * Detects the current Linux distribution and package manager
60
- */
61
- export function detectLinuxDistro(): LinuxDistroInfo {
62
- // Try to read /etc/os-release (most modern distributions)
63
- if (fs.existsSync('/etc/os-release')) {
64
- try {
65
- const osRelease = fs.readFileSync('/etc/os-release', 'utf8');
66
- const lines = osRelease.split('\n');
67
- const info: { [key: string]: string } = {};
68
-
69
- for (const line of lines) {
70
- const match = line.match(/^([^=]+)=(.*)$/);
71
- if (match && match[1] && match[2]) {
72
- // Remove quotes from value
73
- info[match[1]] = match[2].replaceAll(/^["']|["']$/g, '');
74
- }
75
- }
76
-
77
- const id = info['ID']?.toLowerCase() ?? '';
78
- const idLike = info['ID_LIKE']?.toLowerCase() ?? '';
79
- const name = info['NAME'] ?? 'Linux';
80
- const version = info['VERSION_ID'];
81
-
82
- // Detect distribution type based on ID and ID_LIKE
83
- if (id.includes('debian') || id.includes('ubuntu') || idLike.includes('debian') || idLike.includes('ubuntu')) {
84
- const result: LinuxDistroInfo = {
85
- type: LinuxDistroType.DEBIAN,
86
- name,
87
- packageManager: getPackageManager(LinuxDistroType.DEBIAN),
88
- };
89
- if (version) result.version = version;
90
- return result;
91
- } else if (
92
- id.includes('fedora') ||
93
- id.includes('rhel') ||
94
- id.includes('centos') ||
95
- id.includes('rocky') ||
96
- idLike.includes('fedora') ||
97
- idLike.includes('rhel')
98
- ) {
99
- const result: LinuxDistroInfo = {
100
- type: LinuxDistroType.REDHAT,
101
- name,
102
- packageManager: getPackageManager(LinuxDistroType.REDHAT),
103
- };
104
- if (version) result.version = version;
105
- return result;
106
- } else if (id.includes('arch') || id.includes('manjaro') || idLike.includes('arch')) {
107
- const result: LinuxDistroInfo = {
108
- type: LinuxDistroType.ARCH,
109
- name,
110
- packageManager: getPackageManager(LinuxDistroType.ARCH),
111
- };
112
- if (version) result.version = version;
113
- return result;
114
- } else if (id.includes('suse') || idLike.includes('suse')) {
115
- const result: LinuxDistroInfo = {
116
- type: LinuxDistroType.SUSE,
117
- name,
118
- packageManager: getPackageManager(LinuxDistroType.SUSE),
119
- };
120
- if (version) result.version = version;
121
- return result;
122
- }
123
- } catch {
124
- // Fall through to legacy detection
125
- }
126
- }
127
-
128
- // Legacy detection methods
129
- if (checkCommandExists('apt-get')) {
130
- return {
131
- type: LinuxDistroType.DEBIAN,
132
- name: 'Debian/Ubuntu',
133
- packageManager: getPackageManager(LinuxDistroType.DEBIAN),
134
- };
135
- } else if (checkCommandExists('dnf')) {
136
- return {
137
- type: LinuxDistroType.REDHAT,
138
- name: 'Fedora/RHEL',
139
- packageManager: getPackageManager(LinuxDistroType.REDHAT),
140
- };
141
- } else if (checkCommandExists('yum')) {
142
- return {
143
- type: LinuxDistroType.REDHAT,
144
- name: 'RHEL/CentOS',
145
- packageManager: getPackageManager(LinuxDistroType.REDHAT),
146
- };
147
- } else if (checkCommandExists('pacman')) {
148
- return {
149
- type: LinuxDistroType.ARCH,
150
- name: 'Arch Linux',
151
- packageManager: getPackageManager(LinuxDistroType.ARCH),
152
- };
153
- } else if (checkCommandExists('zypper')) {
154
- return {
155
- type: LinuxDistroType.SUSE,
156
- name: 'openSUSE/SLES',
157
- packageManager: getPackageManager(LinuxDistroType.SUSE),
158
- };
159
- }
160
-
161
- // Unknown distribution
162
- return {
163
- type: LinuxDistroType.UNKNOWN,
164
- name: 'Unknown Linux',
165
- packageManager: {
166
- name: 'unknown',
167
- installCommand: '',
168
- requiresSudo: true,
169
- },
170
- };
171
- }
172
-
173
- /**
174
- * Gets the package manager for a specific distribution type
175
- */
176
- function getPackageManager(distroType: LinuxDistroType): PackageManager {
177
- switch (distroType) {
178
- case LinuxDistroType.DEBIAN: {
179
- return {
180
- name: 'apt',
181
- installCommand: 'apt-get install',
182
- requiresSudo: true,
183
- updateCommand: 'apt-get update',
184
- };
185
- }
186
- case LinuxDistroType.REDHAT: {
187
- // Prefer dnf over yum
188
- if (checkCommandExists('dnf')) {
189
- return {
190
- name: 'dnf',
191
- installCommand: 'dnf install',
192
- requiresSudo: true,
193
- };
194
- } else {
195
- return {
196
- name: 'yum',
197
- installCommand: 'yum install',
198
- requiresSudo: true,
199
- };
200
- }
201
- }
202
- case LinuxDistroType.ARCH: {
203
- return {
204
- name: 'pacman',
205
- installCommand: 'pacman -S',
206
- requiresSudo: true,
207
- updateCommand: 'pacman -Sy',
208
- };
209
- }
210
- case LinuxDistroType.SUSE: {
211
- return {
212
- name: 'zypper',
213
- installCommand: 'zypper install',
214
- requiresSudo: true,
215
- };
216
- }
217
- default: {
218
- return {
219
- name: 'unknown',
220
- installCommand: '',
221
- requiresSudo: true,
222
- };
223
- }
224
- }
225
- }
226
-
227
- /**
228
- * Gets the appropriate package name for the current distribution
229
- * Uses type-safe indexing based on the LinuxDistroType enum
230
- */
231
- export function getPackageName(packageMap: PackageNameMap, distro = detectLinuxDistro()): string {
232
- return packageMap[distro.type] ?? packageMap.unknown;
233
- }
234
-
235
- /**
236
- * Builds an install command for packages on the current distribution
237
- */
238
- export function buildInstallCommand(packages: string[], distro = detectLinuxDistro()): string {
239
- if (distro.type === LinuxDistroType.UNKNOWN) {
240
- return `# Unable to determine package manager. Please install manually: ${packages.join(', ')}`;
241
- }
242
-
243
- const { packageManager } = distro;
244
- const sudo = packageManager.requiresSudo ? 'sudo ' : '';
245
-
246
- return `${sudo}${packageManager.installCommand} ${packages.join(' ')}`;
247
- }
248
-
249
- /**
250
- * Gets the package name mappings for common dependencies
251
- */
252
- export function getCommonPackageMappings(): { [key: string]: PackageNameMap } {
253
- return {
254
- git: {
255
- unknown: 'git',
256
- },
257
- 'git-lfs': {
258
- unknown: 'git-lfs',
259
- },
260
- npm: {
261
- unknown: 'npm',
262
- },
263
- 'openjdk-17': {
264
- debian: 'openjdk-17-jdk',
265
- redhat: 'java-17-openjdk-devel',
266
- arch: 'jdk17-openjdk',
267
- suse: 'java-17-openjdk-devel',
268
- unknown: 'openjdk-17-jdk',
269
- },
270
- watchman: {
271
- debian: 'watchman',
272
- redhat: 'watchman', // May need EPEL repository
273
- arch: 'watchman',
274
- suse: 'watchman',
275
- unknown: 'watchman',
276
- },
277
- adb: {
278
- debian: 'adb',
279
- redhat: 'android-tools',
280
- arch: 'android-tools',
281
- suse: 'android-tools',
282
- unknown: 'adb',
283
- },
284
- fontconfig: {
285
- debian: 'libfontconfig1-dev',
286
- redhat: 'fontconfig-devel',
287
- arch: 'fontconfig',
288
- suse: 'fontconfig-devel',
289
- unknown: 'fontconfig',
290
- },
291
- zlib: {
292
- debian: 'zlib1g-dev',
293
- redhat: 'zlib-devel',
294
- arch: 'zlib',
295
- suse: 'zlib-devel',
296
- unknown: 'zlib',
297
- },
298
- };
299
- }
300
-
301
- /**
302
- * Checks if git-lfs can be installed directly or needs repository setup
303
- */
304
- export function needsGitLfsRepoSetup(distro = detectLinuxDistro()): boolean {
305
- // Only Debian/Ubuntu-based systems need the packagecloud repository setup
306
- // Other distributions usually have git-lfs in their standard repos
307
- return distro.type === LinuxDistroType.DEBIAN;
308
- }
309
-
310
- /**
311
- * Gets the shell command to setup git-lfs repository for the current distribution
312
- */
313
- export function getGitLfsRepoSetupCommand(distro = detectLinuxDistro()): string | null {
314
- switch (distro.type) {
315
- case LinuxDistroType.DEBIAN: {
316
- return 'curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash';
317
- }
318
- case LinuxDistroType.REDHAT: {
319
- return 'curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh | sudo bash';
320
- }
321
- default: {
322
- // Most other distributions have git-lfs in their standard repositories
323
- return null;
324
- }
325
- }
326
- }
@@ -1,9 +0,0 @@
1
- import * as Constants from '../core/constants';
2
-
3
- export function wrapInColor(
4
- s: string | undefined,
5
- color: Constants.ANSI_COLORS,
6
- reset_color: Constants.ANSI_COLORS = Constants.ANSI_COLORS.RESET_COLOR,
7
- ): string {
8
- return `${color}${s ?? ''}${reset_color}`;
9
- }
@@ -1,12 +0,0 @@
1
- import path from 'path';
2
-
3
- /**
4
- * Version of path.relative() that resolves equal paths to .
5
- */
6
- export function relativePathTo(from: string, to: string): string {
7
- const output = path.relative(from, to);
8
- if (!output) {
9
- return '.';
10
- }
11
- return output;
12
- }
@@ -1,95 +0,0 @@
1
- import 'jasmine';
2
- import { sanitizeProjectName, toPascalCase, toSnakeCase, validateProjectName } from './stringUtils';
3
-
4
- describe('stringUtils', () => {
5
- it('converts strings to pascal case', () => {
6
- const testCases: [string, string][] = [['hello', 'Hello'], ['hello world', 'HelloWorld'], ['My New Module', 'MyNewModule'], ['my_new_module', 'MyNewModule']];
7
- testCases.forEach(([input, expected]) => {
8
- expect(toPascalCase(input)).toBe(expected);
9
- });
10
- });
11
-
12
- it('converts strings to snake case', () => {
13
- const testCases: [string, string][] = [['hello', 'hello'], ['hello world', 'hello_world']];
14
- testCases.forEach(([input, expected]) => {
15
- expect(toSnakeCase(input)).toBe(expected);
16
- });
17
- });
18
-
19
- describe('sanitizeProjectName', () => {
20
- it('replaces dashes with underscores', () => {
21
- expect(sanitizeProjectName('my-project')).toBe('my_project');
22
- expect(sanitizeProjectName('my-cool-app')).toBe('my_cool_app');
23
- });
24
-
25
- it('preserves original case', () => {
26
- expect(sanitizeProjectName('MyProject')).toBe('MyProject');
27
- expect(sanitizeProjectName('MY_PROJECT')).toBe('MY_PROJECT');
28
- expect(sanitizeProjectName('testNewModule')).toBe('testNewModule');
29
- });
30
-
31
- it('removes invalid characters', () => {
32
- expect(sanitizeProjectName('my project!')).toBe('myproject');
33
- expect(sanitizeProjectName('my@project#')).toBe('myproject');
34
- expect(sanitizeProjectName('my.project')).toBe('myproject');
35
- });
36
-
37
- it('prefixes with underscore if starts with number', () => {
38
- expect(sanitizeProjectName('123project')).toBe('_123project');
39
- expect(sanitizeProjectName('7-eleven')).toBe('_7_eleven');
40
- });
41
-
42
- it('handles mixed cases', () => {
43
- expect(sanitizeProjectName('My-Cool_Project123')).toBe('My_Cool_Project123');
44
- });
45
-
46
- it('handles already valid names', () => {
47
- expect(sanitizeProjectName('my_project')).toBe('my_project');
48
- expect(sanitizeProjectName('myproject')).toBe('myproject');
49
- expect(sanitizeProjectName('my_project_123')).toBe('my_project_123');
50
- });
51
- });
52
-
53
- describe('validateProjectName', () => {
54
- it('rejects empty names', () => {
55
- expect(validateProjectName('')).toBeTruthy();
56
- expect(validateProjectName(' ')).toBeTruthy();
57
- });
58
-
59
- it('rejects reserved words (case-insensitive)', () => {
60
- expect(validateProjectName('test')).toContain('reserved word');
61
- expect(validateProjectName('Test')).toContain('reserved word');
62
- expect(validateProjectName('TEST')).toContain('reserved word');
63
- expect(validateProjectName('build')).toContain('reserved word');
64
- expect(validateProjectName('workspace')).toContain('reserved word');
65
- expect(validateProjectName('native')).toContain('reserved word');
66
- expect(validateProjectName('package')).toContain('reserved word');
67
- });
68
-
69
- it('accepts valid names with mixed case', () => {
70
- expect(validateProjectName('my_project')).toBeNull();
71
- expect(validateProjectName('myproject')).toBeNull();
72
- expect(validateProjectName('my_cool_app')).toBeNull();
73
- expect(validateProjectName('project123')).toBeNull();
74
- expect(validateProjectName('MyProject')).toBeNull();
75
- expect(validateProjectName('testNewModule')).toBeNull();
76
- });
77
-
78
- it('accepts names with dashes (they will be sanitized)', () => {
79
- expect(validateProjectName('my-project')).toBeNull();
80
- expect(validateProjectName('my-cool-app')).toBeNull();
81
- });
82
-
83
- it('rejects names with only invalid characters', () => {
84
- expect(validateProjectName('!!!')).toBeTruthy();
85
- expect(validateProjectName('...')).toBeTruthy();
86
- expect(validateProjectName('@#$')).toBeTruthy();
87
- });
88
-
89
- it('handles names that start with numbers', () => {
90
- // These are valid because sanitization will prefix with underscore
91
- expect(validateProjectName('123project')).toBeNull();
92
- });
93
- });
94
- });
95
-