@friggframework/devtools 2.0.0--canary.545.c459392.0 → 2.0.0--canary.547.67ebb53.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 (128) hide show
  1. package/frigg-cli/README.md +1 -1
  2. package/frigg-cli/__tests__/unit/commands/build.test.js +1 -1
  3. package/frigg-cli/__tests__/unit/commands/doctor.test.js +2 -0
  4. package/frigg-cli/__tests__/unit/commands/install.test.js +19 -23
  5. package/frigg-cli/__tests__/unit/dependencies.test.js +2 -2
  6. package/frigg-cli/build-command/index.js +11 -123
  7. package/frigg-cli/deploy-command/index.js +1 -83
  8. package/frigg-cli/doctor-command/index.js +16 -37
  9. package/frigg-cli/generate-iam-command.js +1 -21
  10. package/frigg-cli/index.js +6 -21
  11. package/frigg-cli/index.test.js +2 -7
  12. package/frigg-cli/init-command/backend-first-handler.js +42 -124
  13. package/frigg-cli/init-command/index.js +1 -2
  14. package/frigg-cli/init-command/template-handler.js +3 -13
  15. package/frigg-cli/install-command/backend-js.js +3 -3
  16. package/frigg-cli/install-command/environment-variables.js +19 -16
  17. package/frigg-cli/install-command/environment-variables.test.js +13 -12
  18. package/frigg-cli/install-command/index.js +9 -14
  19. package/frigg-cli/install-command/integration-file.js +3 -3
  20. package/frigg-cli/install-command/logger.js +12 -0
  21. package/frigg-cli/install-command/validate-package.js +9 -5
  22. package/frigg-cli/jest.config.js +1 -4
  23. package/frigg-cli/repair-command/index.js +128 -121
  24. package/frigg-cli/start-command/index.js +2 -324
  25. package/frigg-cli/ui-command/index.js +36 -58
  26. package/frigg-cli/utils/repo-detection.js +37 -85
  27. package/infrastructure/create-frigg-infrastructure.js +0 -93
  28. package/infrastructure/docs/iam-policy-templates.md +1 -1
  29. package/infrastructure/domains/networking/vpc-builder.test.js +4 -2
  30. package/infrastructure/domains/networking/vpc-resolver.test.js +1 -1
  31. package/infrastructure/domains/shared/cloudformation-discovery.test.js +7 -4
  32. package/infrastructure/domains/shared/resource-discovery.js +5 -5
  33. package/infrastructure/domains/shared/types/app-definition.js +0 -21
  34. package/infrastructure/domains/shared/types/discovery-result.test.js +1 -1
  35. package/infrastructure/domains/shared/utilities/base-definition-factory.js +1 -10
  36. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +2 -2
  37. package/infrastructure/infrastructure-composer.js +0 -2
  38. package/infrastructure/infrastructure-composer.test.js +2 -2
  39. package/management-ui/README.md +109 -245
  40. package/package.json +7 -8
  41. package/frigg-cli/__tests__/application/use-cases/AddApiModuleToIntegrationUseCase.test.js +0 -326
  42. package/frigg-cli/__tests__/application/use-cases/CreateApiModuleUseCase.test.js +0 -337
  43. package/frigg-cli/__tests__/domain/entities/ApiModule.test.js +0 -373
  44. package/frigg-cli/__tests__/domain/entities/AppDefinition.test.js +0 -313
  45. package/frigg-cli/__tests__/domain/services/IntegrationValidator.test.js +0 -269
  46. package/frigg-cli/__tests__/domain/value-objects/IntegrationName.test.js +0 -82
  47. package/frigg-cli/__tests__/infrastructure/adapters/IntegrationJsUpdater.test.js +0 -408
  48. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemApiModuleRepository.test.js +0 -583
  49. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemAppDefinitionRepository.test.js +0 -314
  50. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemIntegrationRepository.test.js +0 -383
  51. package/frigg-cli/__tests__/unit/commands/init.test.js +0 -406
  52. package/frigg-cli/__tests__/unit/commands/provider-dispatch.test.js +0 -383
  53. package/frigg-cli/__tests__/unit/commands/repair.test.js +0 -275
  54. package/frigg-cli/__tests__/unit/start-command/application/RunPreflightChecksUseCase.test.js +0 -411
  55. package/frigg-cli/__tests__/unit/start-command/infrastructure/DatabaseAdapter.test.js +0 -405
  56. package/frigg-cli/__tests__/unit/start-command/infrastructure/DockerAdapter.test.js +0 -496
  57. package/frigg-cli/__tests__/unit/start-command/presentation/InteractivePromptAdapter.test.js +0 -474
  58. package/frigg-cli/__tests__/unit/utils/output.test.js +0 -196
  59. package/frigg-cli/application/use-cases/AddApiModuleToIntegrationUseCase.js +0 -93
  60. package/frigg-cli/application/use-cases/CreateApiModuleUseCase.js +0 -93
  61. package/frigg-cli/application/use-cases/CreateIntegrationUseCase.js +0 -103
  62. package/frigg-cli/container.js +0 -172
  63. package/frigg-cli/docs/OUTPUT_MIGRATION_GUIDE.md +0 -286
  64. package/frigg-cli/domain/entities/ApiModule.js +0 -272
  65. package/frigg-cli/domain/entities/AppDefinition.js +0 -227
  66. package/frigg-cli/domain/entities/Integration.js +0 -198
  67. package/frigg-cli/domain/exceptions/DomainException.js +0 -24
  68. package/frigg-cli/domain/ports/IApiModuleRepository.js +0 -53
  69. package/frigg-cli/domain/ports/IAppDefinitionRepository.js +0 -43
  70. package/frigg-cli/domain/ports/IIntegrationRepository.js +0 -61
  71. package/frigg-cli/domain/services/IntegrationValidator.js +0 -185
  72. package/frigg-cli/domain/value-objects/IntegrationId.js +0 -42
  73. package/frigg-cli/domain/value-objects/IntegrationName.js +0 -60
  74. package/frigg-cli/domain/value-objects/SemanticVersion.js +0 -70
  75. package/frigg-cli/infrastructure/UnitOfWork.js +0 -46
  76. package/frigg-cli/infrastructure/adapters/BackendJsUpdater.js +0 -197
  77. package/frigg-cli/infrastructure/adapters/FileSystemAdapter.js +0 -224
  78. package/frigg-cli/infrastructure/adapters/IntegrationJsUpdater.js +0 -249
  79. package/frigg-cli/infrastructure/adapters/SchemaValidator.js +0 -92
  80. package/frigg-cli/infrastructure/repositories/FileSystemApiModuleRepository.js +0 -373
  81. package/frigg-cli/infrastructure/repositories/FileSystemAppDefinitionRepository.js +0 -116
  82. package/frigg-cli/infrastructure/repositories/FileSystemIntegrationRepository.js +0 -277
  83. package/frigg-cli/package-lock.json +0 -16226
  84. package/frigg-cli/start-command/application/RunPreflightChecksUseCase.js +0 -376
  85. package/frigg-cli/start-command/infrastructure/DatabaseAdapter.js +0 -591
  86. package/frigg-cli/start-command/infrastructure/DockerAdapter.js +0 -306
  87. package/frigg-cli/start-command/presentation/InteractivePromptAdapter.js +0 -329
  88. package/frigg-cli/templates/backend/.env.example +0 -62
  89. package/frigg-cli/templates/backend/.eslintrc.json +0 -12
  90. package/frigg-cli/templates/backend/.prettierrc +0 -6
  91. package/frigg-cli/templates/backend/docker-compose.yml +0 -22
  92. package/frigg-cli/templates/backend/index.js +0 -96
  93. package/frigg-cli/templates/backend/infrastructure.js +0 -12
  94. package/frigg-cli/templates/backend/jest.config.js +0 -17
  95. package/frigg-cli/templates/backend/package.json +0 -50
  96. package/frigg-cli/templates/backend/src/api-modules/.gitkeep +0 -10
  97. package/frigg-cli/templates/backend/src/base/.gitkeep +0 -7
  98. package/frigg-cli/templates/backend/src/integrations/.gitkeep +0 -10
  99. package/frigg-cli/templates/backend/src/integrations/ExampleIntegration.js +0 -65
  100. package/frigg-cli/templates/backend/src/utils/.gitkeep +0 -7
  101. package/frigg-cli/templates/backend/test/setup.js +0 -30
  102. package/frigg-cli/templates/backend/ui-extensions/.gitkeep +0 -0
  103. package/frigg-cli/templates/backend/ui-extensions/README.md +0 -77
  104. package/frigg-cli/utils/__tests__/provider-helper.test.js +0 -55
  105. package/frigg-cli/utils/__tests__/repo-detection.test.js +0 -436
  106. package/frigg-cli/utils/output.js +0 -382
  107. package/frigg-cli/utils/provider-helper.js +0 -75
  108. package/frigg-cli/validate-command/__tests__/adapters/validate-command.test.js +0 -205
  109. package/frigg-cli/validate-command/__tests__/application/validate-app-use-case.test.js +0 -104
  110. package/frigg-cli/validate-command/__tests__/domain/fix-suggestion.test.js +0 -153
  111. package/frigg-cli/validate-command/__tests__/domain/validation-error.test.js +0 -162
  112. package/frigg-cli/validate-command/__tests__/domain/validation-result.test.js +0 -152
  113. package/frigg-cli/validate-command/__tests__/infrastructure/api-module-validator.test.js +0 -332
  114. package/frigg-cli/validate-command/__tests__/infrastructure/app-definition-validator.test.js +0 -191
  115. package/frigg-cli/validate-command/__tests__/infrastructure/integration-class-validator.test.js +0 -146
  116. package/frigg-cli/validate-command/__tests__/infrastructure/template-validation.test.js +0 -155
  117. package/frigg-cli/validate-command/adapters/cli/validate-command.js +0 -199
  118. package/frigg-cli/validate-command/application/use-cases/validate-app-use-case.js +0 -35
  119. package/frigg-cli/validate-command/domain/entities/validation-result.js +0 -74
  120. package/frigg-cli/validate-command/domain/value-objects/fix-suggestion.js +0 -74
  121. package/frigg-cli/validate-command/domain/value-objects/validation-error.js +0 -68
  122. package/frigg-cli/validate-command/infrastructure/validators/api-module-validator.js +0 -181
  123. package/frigg-cli/validate-command/infrastructure/validators/app-definition-validator.js +0 -128
  124. package/frigg-cli/validate-command/infrastructure/validators/integration-class-validator.js +0 -113
  125. package/infrastructure/domains/admin-scripts/admin-script-builder.js +0 -200
  126. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +0 -499
  127. package/infrastructure/domains/admin-scripts/index.js +0 -5
  128. package/infrastructure/jest.config.js +0 -16
@@ -1,406 +0,0 @@
1
- /**
2
- * Tests for the init command and BackendFirstHandler
3
- * TDD: These tests define the expected behavior for frigg init
4
- */
5
-
6
- const path = require('path');
7
- const fs = require('fs-extra');
8
-
9
- // Mock dependencies before requiring the modules
10
- jest.mock('@inquirer/prompts', () => ({
11
- select: jest.fn(),
12
- confirm: jest.fn(),
13
- multiselect: jest.fn()
14
- }));
15
-
16
- jest.mock('../../../utils/npm-registry', () => ({
17
- searchApiModules: jest.fn().mockResolvedValue([]),
18
- getModulesByType: jest.fn().mockResolvedValue({})
19
- }));
20
-
21
- jest.mock('@friggframework/schemas', () => ({
22
- validateAppDefinition: jest.fn().mockReturnValue({ valid: true, errors: [] }),
23
- formatErrors: jest.fn().mockReturnValue('')
24
- }));
25
-
26
- const { select, confirm, multiselect } = require('@inquirer/prompts');
27
- const BackendFirstHandler = require('../../../init-command/backend-first-handler');
28
-
29
- describe('BackendFirstHandler', () => {
30
- let tempDir;
31
- let targetPath;
32
-
33
- beforeEach(async () => {
34
- // Create a real temporary directory for each test
35
- tempDir = global.TestHelpers.createTempDir();
36
- targetPath = path.join(tempDir, 'test-frigg-app');
37
-
38
- // Reset all mocks
39
- jest.clearAllMocks();
40
- });
41
-
42
- afterEach(async () => {
43
- // Clean up
44
- global.TestHelpers.cleanupTempDir(tempDir);
45
- });
46
-
47
- describe('constructor', () => {
48
- test('initializes with target path and options', () => {
49
- const handler = new BackendFirstHandler(targetPath, { verbose: true });
50
-
51
- expect(handler.targetPath).toBe(targetPath);
52
- expect(handler.appName).toBe('test-frigg-app');
53
- expect(handler.options.verbose).toBe(true);
54
- });
55
-
56
- test('sets templates directory correctly', () => {
57
- const handler = new BackendFirstHandler(targetPath);
58
-
59
- expect(handler.templatesDir).toContain('templates');
60
- });
61
- });
62
-
63
- describe('selectDeploymentMode', () => {
64
- test('returns mode from options if provided', async () => {
65
- const handler = new BackendFirstHandler(targetPath, { mode: 'standalone' });
66
-
67
- const mode = await handler.selectDeploymentMode();
68
-
69
- expect(mode).toBe('standalone');
70
- expect(select).not.toHaveBeenCalled();
71
- });
72
-
73
- test('prompts user if mode not provided', async () => {
74
- select.mockResolvedValue('embedded');
75
- const handler = new BackendFirstHandler(targetPath, {});
76
-
77
- const mode = await handler.selectDeploymentMode();
78
-
79
- expect(mode).toBe('embedded');
80
- expect(select).toHaveBeenCalledWith(expect.objectContaining({
81
- message: expect.stringContaining('deploy')
82
- }));
83
- });
84
- });
85
-
86
- describe('getProjectConfiguration', () => {
87
- test('collects all required configuration options', async () => {
88
- const handler = new BackendFirstHandler(targetPath, { frontend: false });
89
-
90
- // Mock all prompts in correct order
91
- // 1. appPurpose
92
- select.mockResolvedValueOnce('own-app');
93
- // 2. needsCustomApiModule (only asked when appPurpose === 'own-app')
94
- confirm.mockResolvedValueOnce(true);
95
- // 3. includeIntegrations
96
- confirm.mockResolvedValueOnce(false);
97
- // 4. serverlessProvider (only for standalone)
98
- select.mockResolvedValueOnce('aws');
99
- // 5. installDependencies
100
- confirm.mockResolvedValueOnce(true);
101
- // 6. initializeGit
102
- confirm.mockResolvedValueOnce(true);
103
-
104
- const config = await handler.getProjectConfiguration('standalone');
105
-
106
- expect(config.deploymentMode).toBe('standalone');
107
- expect(config.appPurpose).toBe('own-app');
108
- expect(config.needsCustomApiModule).toBe(true);
109
- expect(config.installDependencies).toBe(true);
110
- expect(config.initializeGit).toBe(true);
111
- });
112
-
113
- test('asks about demo frontend when not disabled', async () => {
114
- const handler = new BackendFirstHandler(targetPath, { frontend: undefined });
115
-
116
- // Mock prompts in correct order:
117
- // 1. appPurpose
118
- select.mockResolvedValueOnce('exploring');
119
- // 2. includeIntegrations
120
- confirm.mockResolvedValueOnce(false);
121
- // 3. includeDemoFrontend (asked when frontend !== false)
122
- confirm.mockResolvedValueOnce(true);
123
- // 4. frontendFramework (asked when includeDemoFrontend is true)
124
- select.mockResolvedValueOnce('react');
125
- // 5. demoAuthMode (asked when includeDemoFrontend is true)
126
- select.mockResolvedValueOnce('mock');
127
- // 6. serverlessProvider (for standalone mode)
128
- select.mockResolvedValueOnce('local');
129
- // 7. installDependencies
130
- confirm.mockResolvedValueOnce(true);
131
- // 8. initializeGit
132
- confirm.mockResolvedValueOnce(true);
133
-
134
- const config = await handler.getProjectConfiguration('standalone');
135
-
136
- expect(config.includeDemoFrontend).toBe(true);
137
- expect(config.frontendFramework).toBe('react');
138
- expect(config.demoAuthMode).toBe('mock');
139
- });
140
-
141
- test('skips demo frontend question when frontend is false', async () => {
142
- const handler = new BackendFirstHandler(targetPath, { frontend: false });
143
-
144
- select.mockResolvedValueOnce('exploring') // appPurpose
145
- .mockResolvedValueOnce('local'); // serverlessProvider
146
- confirm.mockResolvedValueOnce(false) // includeIntegrations
147
- .mockResolvedValueOnce(true) // installDependencies
148
- .mockResolvedValueOnce(true); // initializeGit
149
-
150
- const config = await handler.getProjectConfiguration('standalone');
151
-
152
- expect(config.includeDemoFrontend).toBeUndefined();
153
- });
154
- });
155
-
156
- describe('createProject', () => {
157
- test('creates target directory if it does not exist', async () => {
158
- const handler = new BackendFirstHandler(targetPath, { force: true });
159
-
160
- // Create minimal config
161
- const config = {
162
- deploymentMode: 'standalone',
163
- installDependencies: false,
164
- initializeGit: false,
165
- serverlessProvider: 'local'
166
- };
167
-
168
- // Mock that templates exist
169
- const templatesDir = handler.templatesDir;
170
- const backendTemplateDir = path.join(templatesDir, 'backend');
171
-
172
- // We expect the directory to be created
173
- await handler.ensureSafeDirectory();
174
-
175
- expect(fs.existsSync(targetPath)).toBe(true);
176
- });
177
-
178
- test('throws error when directory is not empty without force flag', async () => {
179
- // Create target directory with a file in it
180
- await fs.ensureDir(targetPath);
181
- await fs.writeFile(path.join(targetPath, 'existing-file.js'), 'content');
182
-
183
- const handler = new BackendFirstHandler(targetPath, { force: false });
184
-
185
- await expect(handler.ensureSafeDirectory())
186
- .rejects
187
- .toThrow('Directory not empty');
188
- });
189
-
190
- test('allows non-empty directory with force flag', async () => {
191
- // Create target directory with a file in it
192
- await fs.ensureDir(targetPath);
193
- await fs.writeFile(path.join(targetPath, 'existing-file.js'), 'content');
194
-
195
- const handler = new BackendFirstHandler(targetPath, { force: true });
196
-
197
- // Should not throw
198
- await handler.ensureSafeDirectory();
199
-
200
- expect(fs.existsSync(targetPath)).toBe(true);
201
- });
202
-
203
- test('allows allowed files without force flag', async () => {
204
- // Create target directory with allowed files
205
- await fs.ensureDir(targetPath);
206
- await fs.writeFile(path.join(targetPath, '.git'), '');
207
- await fs.writeFile(path.join(targetPath, '.gitignore'), '');
208
- await fs.writeFile(path.join(targetPath, 'README.md'), '');
209
-
210
- const handler = new BackendFirstHandler(targetPath, { force: false });
211
-
212
- // Should not throw for allowed files
213
- await handler.ensureSafeDirectory();
214
-
215
- expect(fs.existsSync(targetPath)).toBe(true);
216
- });
217
- });
218
-
219
- describe('createStandaloneProject', () => {
220
- // Note: These tests rely on the real backend template in templates/backend
221
- // If the template doesn't exist, tests will be skipped
222
-
223
- test('creates package.json with correct scripts', async () => {
224
- const handler = new BackendFirstHandler(targetPath, { force: true });
225
- await fs.ensureDir(targetPath);
226
-
227
- const config = {
228
- serverlessProvider: 'aws',
229
- starterIntegrations: [],
230
- installDependencies: false
231
- };
232
-
233
- await handler.createStandaloneProject(config);
234
-
235
- const packageJson = await fs.readJSON(path.join(targetPath, 'package.json'));
236
-
237
- expect(packageJson.name).toBe('test-frigg-app');
238
- expect(packageJson.scripts).toHaveProperty('start');
239
- expect(packageJson.scripts).toHaveProperty('build');
240
- expect(packageJson.scripts).toHaveProperty('deploy');
241
- expect(packageJson.scripts).toHaveProperty('test');
242
- });
243
-
244
- test('adds selected integrations as dependencies', async () => {
245
- const handler = new BackendFirstHandler(targetPath, { force: true });
246
- await fs.ensureDir(targetPath);
247
-
248
- const config = {
249
- serverlessProvider: 'aws',
250
- starterIntegrations: ['salesforce', 'hubspot'],
251
- installDependencies: false
252
- };
253
-
254
- await handler.createStandaloneProject(config);
255
-
256
- const packageJson = await fs.readJSON(path.join(targetPath, 'package.json'));
257
-
258
- expect(packageJson.dependencies).toHaveProperty('@friggframework/api-module-salesforce');
259
- expect(packageJson.dependencies).toHaveProperty('@friggframework/api-module-hubspot');
260
- });
261
-
262
- test('includes @friggframework/core as dependency', async () => {
263
- const handler = new BackendFirstHandler(targetPath, { force: true });
264
- await fs.ensureDir(targetPath);
265
-
266
- const config = {
267
- serverlessProvider: 'local',
268
- starterIntegrations: [],
269
- installDependencies: false
270
- };
271
-
272
- await handler.createStandaloneProject(config);
273
-
274
- const packageJson = await fs.readJSON(path.join(targetPath, 'package.json'));
275
-
276
- expect(packageJson.dependencies).toHaveProperty('@friggframework/core');
277
- });
278
- });
279
-
280
- describe('createEmbeddedProject', () => {
281
- // Note: These tests rely on the real backend template in templates/backend
282
- // If the template doesn't exist, tests will be skipped
283
-
284
- test('creates frigg-integration subdirectory', async () => {
285
- const handler = new BackendFirstHandler(targetPath, { force: true });
286
- await fs.ensureDir(targetPath);
287
-
288
- const config = {
289
- installDependencies: false
290
- };
291
-
292
- await handler.createEmbeddedProject(config);
293
-
294
- const integrationDir = path.join(targetPath, 'frigg-integration');
295
- expect(fs.existsSync(integrationDir)).toBe(true);
296
- });
297
-
298
- test('creates FRIGG_INTEGRATION.md guide', async () => {
299
- const handler = new BackendFirstHandler(targetPath, { force: true });
300
- await fs.ensureDir(targetPath);
301
-
302
- const config = {
303
- installDependencies: false
304
- };
305
-
306
- await handler.createEmbeddedProject(config);
307
-
308
- const guidePath = path.join(targetPath, 'FRIGG_INTEGRATION.md');
309
- expect(fs.existsSync(guidePath)).toBe(true);
310
-
311
- const content = await fs.readFile(guidePath, 'utf8');
312
- expect(content).toContain('# Frigg Integration Guide');
313
- expect(content).toContain('@friggframework/core');
314
- });
315
- });
316
-
317
- describe('getIntegrationClassName', () => {
318
- test('converts known integrations to class names', () => {
319
- const handler = new BackendFirstHandler(targetPath);
320
-
321
- expect(handler.getIntegrationClassName('salesforce')).toBe('SalesforceIntegration');
322
- expect(handler.getIntegrationClassName('hubspot')).toBe('HubSpotIntegration');
323
- expect(handler.getIntegrationClassName('slack')).toBe('SlackIntegration');
324
- expect(handler.getIntegrationClassName('google-sheets')).toBe('GoogleSheetsIntegration');
325
- });
326
-
327
- test('generates class name for unknown integrations', () => {
328
- const handler = new BackendFirstHandler(targetPath);
329
-
330
- expect(handler.getIntegrationClassName('custom-api')).toBe('Custom-apiIntegration');
331
- });
332
- });
333
-
334
- describe('isUsingYarn', () => {
335
- test('returns true when npm_config_user_agent contains yarn', () => {
336
- const originalEnv = process.env.npm_config_user_agent;
337
- process.env.npm_config_user_agent = 'yarn/1.22.0';
338
-
339
- const handler = new BackendFirstHandler(targetPath);
340
-
341
- expect(handler.isUsingYarn()).toBe(true);
342
-
343
- process.env.npm_config_user_agent = originalEnv;
344
- });
345
-
346
- test('returns false when using npm', () => {
347
- const originalEnv = process.env.npm_config_user_agent;
348
- process.env.npm_config_user_agent = 'npm/8.0.0';
349
-
350
- const handler = new BackendFirstHandler(targetPath);
351
-
352
- expect(handler.isUsingYarn()).toBe(false);
353
-
354
- process.env.npm_config_user_agent = originalEnv;
355
- });
356
- });
357
- });
358
-
359
- describe('initCommand', () => {
360
- const { initCommand } = require('../../../init-command');
361
- let tempDir;
362
-
363
- beforeEach(() => {
364
- tempDir = global.TestHelpers.createTempDir();
365
- jest.clearAllMocks();
366
- });
367
-
368
- afterEach(() => {
369
- global.TestHelpers.cleanupTempDir(tempDir);
370
- });
371
-
372
- test('validates project name - uppercase names are allowed in npm', async () => {
373
- // Note: npm actually allows uppercase names now, they get lowercased
374
- // The validate-npm-package-name package allows uppercase
375
- const validName = path.join(tempDir, 'Valid-Name');
376
-
377
- // Mock prompts to allow the command to proceed
378
- select.mockResolvedValue('standalone');
379
- confirm.mockResolvedValue(false);
380
-
381
- // This should not throw for package name validation
382
- // It may fail for other reasons like missing templates
383
- try {
384
- await initCommand(validName, { mode: 'standalone' });
385
- } catch (e) {
386
- // Expected to fail for missing template, not for name validation
387
- expect(e.message).not.toContain('npm naming restrictions');
388
- }
389
- });
390
-
391
- test('checks Node version', async () => {
392
- const projectPath = path.join(tempDir, 'valid-project');
393
-
394
- // Mock prompts to return quickly
395
- select.mockResolvedValue('standalone');
396
- confirm.mockResolvedValue(false);
397
-
398
- // This should not throw for invalid Node version (just warn)
399
- // The test validates checkNodeVersion is called
400
- try {
401
- await initCommand(projectPath, { mode: 'standalone' });
402
- } catch (e) {
403
- // May fail for other reasons, but shouldn't throw for Node version
404
- }
405
- });
406
- });