@friggframework/devtools 2.0.0--canary.474.295ae1f.0 → 2.0.0--canary.474.a0b734c.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.
- package/management-ui/server/utils/cliIntegration.js +1 -1
- package/package.json +6 -6
- package/frigg-cli/.eslintrc.js +0 -141
- package/frigg-cli/README.md +0 -1290
- package/frigg-cli/__tests__/unit/commands/build.test.js +0 -279
- package/frigg-cli/__tests__/unit/commands/db-setup.test.js +0 -548
- package/frigg-cli/__tests__/unit/commands/deploy.test.js +0 -320
- package/frigg-cli/__tests__/unit/commands/install.test.js +0 -400
- package/frigg-cli/__tests__/unit/commands/ui.test.js +0 -346
- package/frigg-cli/__tests__/unit/utils/database-validator.test.js +0 -366
- package/frigg-cli/__tests__/unit/utils/error-messages.test.js +0 -304
- package/frigg-cli/__tests__/unit/version-detection.test.js +0 -171
- package/frigg-cli/__tests__/utils/mock-factory.js +0 -270
- package/frigg-cli/__tests__/utils/prisma-mock.js +0 -194
- package/frigg-cli/__tests__/utils/test-fixtures.js +0 -463
- package/frigg-cli/__tests__/utils/test-setup.js +0 -287
- package/frigg-cli/build-command/index.js +0 -66
- package/frigg-cli/db-setup-command/index.js +0 -193
- package/frigg-cli/deploy-command/index.js +0 -302
- package/frigg-cli/doctor-command/index.js +0 -249
- package/frigg-cli/generate-command/__tests__/generate-command.test.js +0 -301
- package/frigg-cli/generate-command/azure-generator.js +0 -43
- package/frigg-cli/generate-command/gcp-generator.js +0 -47
- package/frigg-cli/generate-command/index.js +0 -332
- package/frigg-cli/generate-command/terraform-generator.js +0 -555
- package/frigg-cli/generate-iam-command.js +0 -118
- package/frigg-cli/index.js +0 -173
- package/frigg-cli/index.test.js +0 -158
- package/frigg-cli/init-command/backend-first-handler.js +0 -756
- package/frigg-cli/init-command/index.js +0 -93
- package/frigg-cli/init-command/template-handler.js +0 -143
- package/frigg-cli/install-command/backend-js.js +0 -33
- package/frigg-cli/install-command/commit-changes.js +0 -16
- package/frigg-cli/install-command/environment-variables.js +0 -127
- package/frigg-cli/install-command/environment-variables.test.js +0 -136
- package/frigg-cli/install-command/index.js +0 -54
- package/frigg-cli/install-command/install-package.js +0 -13
- package/frigg-cli/install-command/integration-file.js +0 -30
- package/frigg-cli/install-command/logger.js +0 -12
- package/frigg-cli/install-command/template.js +0 -90
- package/frigg-cli/install-command/validate-package.js +0 -75
- package/frigg-cli/jest.config.js +0 -124
- package/frigg-cli/package.json +0 -58
- package/frigg-cli/repair-command/index.js +0 -341
- package/frigg-cli/start-command/index.js +0 -149
- package/frigg-cli/start-command/start-command.test.js +0 -297
- package/frigg-cli/test/init-command.test.js +0 -180
- package/frigg-cli/test/npm-registry.test.js +0 -319
- package/frigg-cli/ui-command/index.js +0 -154
- package/frigg-cli/utils/app-resolver.js +0 -319
- package/frigg-cli/utils/backend-path.js +0 -25
- package/frigg-cli/utils/database-validator.js +0 -154
- package/frigg-cli/utils/error-messages.js +0 -257
- package/frigg-cli/utils/npm-registry.js +0 -167
- package/frigg-cli/utils/process-manager.js +0 -199
- package/frigg-cli/utils/repo-detection.js +0 -405
- /package/infrastructure/{DOCTOR.md → HEALTH.md} +0 -0
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test suite for deploy command
|
|
3
|
-
*
|
|
4
|
-
* Tests the serverless deployment functionality including:
|
|
5
|
-
* - Command execution with spawn
|
|
6
|
-
* - Stage option handling
|
|
7
|
-
* - Environment variable filtering and propagation
|
|
8
|
-
* - SLS_STAGE propagation for resource discovery
|
|
9
|
-
* - Error handling
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
// Mock dependencies BEFORE requiring modules
|
|
13
|
-
jest.mock('child_process', () => ({
|
|
14
|
-
spawn: jest.fn()
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
jest.mock('fs', () => ({
|
|
18
|
-
existsSync: jest.fn()
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
// Require after mocks
|
|
22
|
-
const { spawn } = require('child_process');
|
|
23
|
-
const fs = require('fs');
|
|
24
|
-
const { deployCommand } = require('../../../deploy-command');
|
|
25
|
-
|
|
26
|
-
describe('CLI Command: deploy', () => {
|
|
27
|
-
let consoleLogSpy;
|
|
28
|
-
let consoleWarnSpy;
|
|
29
|
-
let consoleErrorSpy;
|
|
30
|
-
let mockChildProcess;
|
|
31
|
-
|
|
32
|
-
beforeEach(() => {
|
|
33
|
-
jest.clearAllMocks();
|
|
34
|
-
|
|
35
|
-
// Mock console methods
|
|
36
|
-
consoleLogSpy = jest.spyOn(console, 'log').mockImplementation();
|
|
37
|
-
consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation();
|
|
38
|
-
consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation();
|
|
39
|
-
|
|
40
|
-
// Mock child process
|
|
41
|
-
mockChildProcess = {
|
|
42
|
-
on: jest.fn()
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// Mock successful spawn by default
|
|
46
|
-
spawn.mockReturnValue(mockChildProcess);
|
|
47
|
-
|
|
48
|
-
// Mock fs.existsSync to return false (no app definition)
|
|
49
|
-
fs.existsSync.mockReturnValue(false);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
afterEach(() => {
|
|
53
|
-
consoleLogSpy.mockRestore();
|
|
54
|
-
consoleWarnSpy.mockRestore();
|
|
55
|
-
consoleErrorSpy.mockRestore();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
describe('Success Cases', () => {
|
|
59
|
-
it('should spawn serverless with default stage', async () => {
|
|
60
|
-
await deployCommand({ stage: 'dev' });
|
|
61
|
-
|
|
62
|
-
expect(spawn).toHaveBeenCalledWith(
|
|
63
|
-
'osls',
|
|
64
|
-
['deploy', '--config', 'infrastructure.js', '--stage', 'dev'],
|
|
65
|
-
expect.objectContaining({
|
|
66
|
-
cwd: expect.any(String),
|
|
67
|
-
stdio: 'inherit'
|
|
68
|
-
})
|
|
69
|
-
);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('should spawn serverless with production stage', async () => {
|
|
73
|
-
await deployCommand({ stage: 'production' });
|
|
74
|
-
|
|
75
|
-
expect(spawn).toHaveBeenCalledWith(
|
|
76
|
-
'osls',
|
|
77
|
-
expect.arrayContaining(['--stage', 'production']),
|
|
78
|
-
expect.any(Object)
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('should spawn serverless with qa stage', async () => {
|
|
83
|
-
await deployCommand({ stage: 'qa' });
|
|
84
|
-
|
|
85
|
-
expect(spawn).toHaveBeenCalledWith(
|
|
86
|
-
'osls',
|
|
87
|
-
expect.arrayContaining(['--stage', 'qa']),
|
|
88
|
-
expect.any(Object)
|
|
89
|
-
);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('should spawn serverless with --force flag when force option is true', async () => {
|
|
93
|
-
await deployCommand({ stage: 'dev', force: true });
|
|
94
|
-
|
|
95
|
-
expect(spawn).toHaveBeenCalledWith(
|
|
96
|
-
'osls',
|
|
97
|
-
['deploy', '--config', 'infrastructure.js', '--stage', 'dev', '--force'],
|
|
98
|
-
expect.objectContaining({
|
|
99
|
-
cwd: expect.any(String),
|
|
100
|
-
stdio: 'inherit'
|
|
101
|
-
})
|
|
102
|
-
);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('should spawn serverless without --force flag when force option is false', async () => {
|
|
106
|
-
await deployCommand({ stage: 'dev', force: false });
|
|
107
|
-
|
|
108
|
-
expect(spawn).toHaveBeenCalledWith(
|
|
109
|
-
'osls',
|
|
110
|
-
['deploy', '--config', 'infrastructure.js', '--stage', 'dev'],
|
|
111
|
-
expect.objectContaining({
|
|
112
|
-
cwd: expect.any(String),
|
|
113
|
-
stdio: 'inherit'
|
|
114
|
-
})
|
|
115
|
-
);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('should spawn serverless without --force flag when force option is undefined', async () => {
|
|
119
|
-
await deployCommand({ stage: 'dev' });
|
|
120
|
-
|
|
121
|
-
expect(spawn).toHaveBeenCalledWith(
|
|
122
|
-
'osls',
|
|
123
|
-
['deploy', '--config', 'infrastructure.js', '--stage', 'dev'],
|
|
124
|
-
expect.objectContaining({
|
|
125
|
-
cwd: expect.any(String),
|
|
126
|
-
stdio: 'inherit'
|
|
127
|
-
})
|
|
128
|
-
);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('should use process.cwd() as working directory', async () => {
|
|
132
|
-
await deployCommand({ stage: 'dev' });
|
|
133
|
-
|
|
134
|
-
const call = spawn.mock.calls[0];
|
|
135
|
-
const options = call[2];
|
|
136
|
-
|
|
137
|
-
expect(options.cwd).toBe(process.cwd());
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it('should use stdio inherit for output streaming', async () => {
|
|
141
|
-
await deployCommand({ stage: 'dev' });
|
|
142
|
-
|
|
143
|
-
const call = spawn.mock.calls[0];
|
|
144
|
-
const options = call[2];
|
|
145
|
-
|
|
146
|
-
expect(options.stdio).toBe('inherit');
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('should set SLS_STAGE environment variable to match stage option', async () => {
|
|
150
|
-
await deployCommand({ stage: 'qa' });
|
|
151
|
-
|
|
152
|
-
const call = spawn.mock.calls[0];
|
|
153
|
-
const options = call[2];
|
|
154
|
-
|
|
155
|
-
// Verify SLS_STAGE is set for discovery to use
|
|
156
|
-
expect(options.env.SLS_STAGE).toBe('qa');
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it('should set SLS_STAGE for production stage', async () => {
|
|
160
|
-
await deployCommand({ stage: 'production' });
|
|
161
|
-
|
|
162
|
-
const call = spawn.mock.calls[0];
|
|
163
|
-
const options = call[2];
|
|
164
|
-
|
|
165
|
-
expect(options.env.SLS_STAGE).toBe('production');
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it('should set SLS_STAGE for dev stage', async () => {
|
|
169
|
-
await deployCommand({ stage: 'dev' });
|
|
170
|
-
|
|
171
|
-
const call = spawn.mock.calls[0];
|
|
172
|
-
const options = call[2];
|
|
173
|
-
|
|
174
|
-
expect(options.env.SLS_STAGE).toBe('dev');
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('should use infrastructure.js as config file', async () => {
|
|
178
|
-
await deployCommand({ stage: 'dev' });
|
|
179
|
-
|
|
180
|
-
expect(spawn).toHaveBeenCalledWith(
|
|
181
|
-
'osls',
|
|
182
|
-
expect.arrayContaining(['--config', 'infrastructure.js']),
|
|
183
|
-
expect.any(Object)
|
|
184
|
-
);
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it('should log deployment start messages', async () => {
|
|
188
|
-
await deployCommand({ stage: 'dev' });
|
|
189
|
-
|
|
190
|
-
expect(consoleLogSpy).toHaveBeenCalledWith('Deploying the serverless application...');
|
|
191
|
-
expect(consoleLogSpy).toHaveBeenCalledWith('🚀 Deploying serverless application...');
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it('should include essential system environment variables', async () => {
|
|
195
|
-
process.env.PATH = '/usr/bin';
|
|
196
|
-
process.env.HOME = '/home/user';
|
|
197
|
-
process.env.USER = 'testuser';
|
|
198
|
-
|
|
199
|
-
await deployCommand({ stage: 'dev' });
|
|
200
|
-
|
|
201
|
-
const call = spawn.mock.calls[0];
|
|
202
|
-
const options = call[2];
|
|
203
|
-
|
|
204
|
-
expect(options.env.PATH).toBe('/usr/bin');
|
|
205
|
-
expect(options.env.HOME).toBe('/home/user');
|
|
206
|
-
expect(options.env.USER).toBe('testuser');
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it('should include AWS environment variables', async () => {
|
|
210
|
-
process.env.AWS_REGION = 'us-east-1';
|
|
211
|
-
process.env.AWS_PROFILE = 'test-profile';
|
|
212
|
-
process.env.AWS_ACCESS_KEY_ID = 'test-key';
|
|
213
|
-
|
|
214
|
-
await deployCommand({ stage: 'dev' });
|
|
215
|
-
|
|
216
|
-
const call = spawn.mock.calls[0];
|
|
217
|
-
const options = call[2];
|
|
218
|
-
|
|
219
|
-
expect(options.env.AWS_REGION).toBe('us-east-1');
|
|
220
|
-
expect(options.env.AWS_PROFILE).toBe('test-profile');
|
|
221
|
-
expect(options.env.AWS_ACCESS_KEY_ID).toBe('test-key');
|
|
222
|
-
|
|
223
|
-
delete process.env.AWS_REGION;
|
|
224
|
-
delete process.env.AWS_PROFILE;
|
|
225
|
-
delete process.env.AWS_ACCESS_KEY_ID;
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
it('should register error handler', async () => {
|
|
229
|
-
await deployCommand({ stage: 'dev' });
|
|
230
|
-
|
|
231
|
-
expect(mockChildProcess.on).toHaveBeenCalledWith('error', expect.any(Function));
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it('should register close handler', async () => {
|
|
235
|
-
await deployCommand({ stage: 'dev' });
|
|
236
|
-
|
|
237
|
-
expect(mockChildProcess.on).toHaveBeenCalledWith('close', expect.any(Function));
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
describe('Environment Variable Filtering', () => {
|
|
242
|
-
it('should filter environment variables when app definition exists', async () => {
|
|
243
|
-
// Mock app definition with environment config
|
|
244
|
-
fs.existsSync.mockReturnValue(true);
|
|
245
|
-
jest.mock(
|
|
246
|
-
process.cwd() + '/index.js',
|
|
247
|
-
() => ({
|
|
248
|
-
Definition: {
|
|
249
|
-
environment: {
|
|
250
|
-
DATABASE_URL: true,
|
|
251
|
-
API_KEY: true
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}),
|
|
255
|
-
{ virtual: true }
|
|
256
|
-
);
|
|
257
|
-
|
|
258
|
-
process.env.DATABASE_URL = 'postgres://localhost';
|
|
259
|
-
process.env.API_KEY = 'test-key';
|
|
260
|
-
process.env.RANDOM_VAR = 'should-not-be-included';
|
|
261
|
-
|
|
262
|
-
await deployCommand({ stage: 'dev' });
|
|
263
|
-
|
|
264
|
-
const call = spawn.mock.calls[0];
|
|
265
|
-
const options = call[2];
|
|
266
|
-
|
|
267
|
-
// Should include app-defined variables
|
|
268
|
-
expect(options.env.DATABASE_URL).toBe('postgres://localhost');
|
|
269
|
-
expect(options.env.API_KEY).toBe('test-key');
|
|
270
|
-
|
|
271
|
-
// Should NOT include non-app-defined variables (except system/AWS)
|
|
272
|
-
expect(options.env.RANDOM_VAR).toBeUndefined();
|
|
273
|
-
|
|
274
|
-
delete process.env.DATABASE_URL;
|
|
275
|
-
delete process.env.API_KEY;
|
|
276
|
-
delete process.env.RANDOM_VAR;
|
|
277
|
-
});
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
describe('Error Handling', () => {
|
|
281
|
-
it('should log error when spawn fails', async () => {
|
|
282
|
-
const testError = new Error('Spawn failed');
|
|
283
|
-
|
|
284
|
-
await deployCommand({ stage: 'dev' });
|
|
285
|
-
|
|
286
|
-
// Simulate error event
|
|
287
|
-
const errorHandler = mockChildProcess.on.mock.calls.find(
|
|
288
|
-
call => call[0] === 'error'
|
|
289
|
-
)[1];
|
|
290
|
-
errorHandler(testError);
|
|
291
|
-
|
|
292
|
-
expect(consoleErrorSpy).toHaveBeenCalledWith('Error executing command: Spawn failed');
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
it('should log when child process exits with non-zero code', async () => {
|
|
296
|
-
await deployCommand({ stage: 'dev' });
|
|
297
|
-
|
|
298
|
-
// Simulate close event with error code
|
|
299
|
-
const closeHandler = mockChildProcess.on.mock.calls.find(
|
|
300
|
-
call => call[0] === 'close'
|
|
301
|
-
)[1];
|
|
302
|
-
closeHandler(1);
|
|
303
|
-
|
|
304
|
-
expect(consoleLogSpy).toHaveBeenCalledWith('Child process exited with code 1');
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
it('should NOT log when child process exits with zero code', async () => {
|
|
308
|
-
await deployCommand({ stage: 'dev' });
|
|
309
|
-
|
|
310
|
-
// Simulate close event with success code
|
|
311
|
-
const closeHandler = mockChildProcess.on.mock.calls.find(
|
|
312
|
-
call => call[0] === 'close'
|
|
313
|
-
)[1];
|
|
314
|
-
closeHandler(0);
|
|
315
|
-
|
|
316
|
-
// Should not log exit message for success
|
|
317
|
-
expect(consoleLogSpy).not.toHaveBeenCalledWith('Child process exited with code 0');
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
});
|