@friggframework/devtools 2.0.0--canary.517.179491e.0 → 2.0.0--canary.522.893db5d.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/frigg-cli/README.md +1 -1
- package/frigg-cli/__tests__/application/use-cases/AddApiModuleToIntegrationUseCase.test.js +326 -0
- package/frigg-cli/__tests__/application/use-cases/CreateApiModuleUseCase.test.js +337 -0
- package/frigg-cli/__tests__/domain/entities/ApiModule.test.js +373 -0
- package/frigg-cli/__tests__/domain/entities/AppDefinition.test.js +313 -0
- package/frigg-cli/__tests__/domain/services/IntegrationValidator.test.js +269 -0
- package/frigg-cli/__tests__/domain/value-objects/IntegrationName.test.js +82 -0
- package/frigg-cli/__tests__/infrastructure/adapters/IntegrationJsUpdater.test.js +408 -0
- package/frigg-cli/__tests__/infrastructure/repositories/FileSystemApiModuleRepository.test.js +583 -0
- package/frigg-cli/__tests__/infrastructure/repositories/FileSystemAppDefinitionRepository.test.js +314 -0
- package/frigg-cli/__tests__/infrastructure/repositories/FileSystemIntegrationRepository.test.js +383 -0
- package/frigg-cli/__tests__/unit/commands/doctor.test.js +0 -2
- package/frigg-cli/__tests__/unit/commands/init.test.js +406 -0
- package/frigg-cli/__tests__/unit/commands/install.test.js +23 -19
- package/frigg-cli/__tests__/unit/commands/repair.test.js +275 -0
- package/frigg-cli/__tests__/unit/dependencies.test.js +2 -2
- package/frigg-cli/__tests__/unit/start-command/application/RunPreflightChecksUseCase.test.js +411 -0
- package/frigg-cli/__tests__/unit/start-command/infrastructure/DatabaseAdapter.test.js +405 -0
- package/frigg-cli/__tests__/unit/start-command/infrastructure/DockerAdapter.test.js +496 -0
- package/frigg-cli/__tests__/unit/start-command/presentation/InteractivePromptAdapter.test.js +474 -0
- package/frigg-cli/__tests__/unit/utils/output.test.js +196 -0
- package/frigg-cli/application/use-cases/AddApiModuleToIntegrationUseCase.js +93 -0
- package/frigg-cli/application/use-cases/CreateApiModuleUseCase.js +93 -0
- package/frigg-cli/application/use-cases/CreateIntegrationUseCase.js +103 -0
- package/frigg-cli/container.js +172 -0
- package/frigg-cli/docs/OUTPUT_MIGRATION_GUIDE.md +286 -0
- package/frigg-cli/doctor-command/index.js +17 -16
- package/frigg-cli/domain/entities/ApiModule.js +272 -0
- package/frigg-cli/domain/entities/AppDefinition.js +227 -0
- package/frigg-cli/domain/entities/Integration.js +198 -0
- package/frigg-cli/domain/exceptions/DomainException.js +24 -0
- package/frigg-cli/domain/ports/IApiModuleRepository.js +53 -0
- package/frigg-cli/domain/ports/IAppDefinitionRepository.js +43 -0
- package/frigg-cli/domain/ports/IIntegrationRepository.js +61 -0
- package/frigg-cli/domain/services/IntegrationValidator.js +185 -0
- package/frigg-cli/domain/value-objects/IntegrationId.js +42 -0
- package/frigg-cli/domain/value-objects/IntegrationName.js +60 -0
- package/frigg-cli/domain/value-objects/SemanticVersion.js +70 -0
- package/frigg-cli/index.js +21 -6
- package/frigg-cli/index.test.js +7 -2
- package/frigg-cli/infrastructure/UnitOfWork.js +46 -0
- package/frigg-cli/infrastructure/adapters/BackendJsUpdater.js +197 -0
- package/frigg-cli/infrastructure/adapters/FileSystemAdapter.js +224 -0
- package/frigg-cli/infrastructure/adapters/IntegrationJsUpdater.js +249 -0
- package/frigg-cli/infrastructure/adapters/SchemaValidator.js +92 -0
- package/frigg-cli/infrastructure/repositories/FileSystemApiModuleRepository.js +373 -0
- package/frigg-cli/infrastructure/repositories/FileSystemAppDefinitionRepository.js +116 -0
- package/frigg-cli/infrastructure/repositories/FileSystemIntegrationRepository.js +277 -0
- package/frigg-cli/init-command/backend-first-handler.js +124 -42
- package/frigg-cli/init-command/index.js +2 -1
- package/frigg-cli/init-command/template-handler.js +13 -3
- package/frigg-cli/install-command/backend-js.js +3 -3
- package/frigg-cli/install-command/environment-variables.js +16 -19
- package/frigg-cli/install-command/environment-variables.test.js +12 -13
- package/frigg-cli/install-command/index.js +14 -9
- package/frigg-cli/install-command/integration-file.js +3 -3
- package/frigg-cli/install-command/validate-package.js +5 -9
- package/frigg-cli/jest.config.js +4 -1
- package/frigg-cli/package-lock.json +16226 -0
- package/frigg-cli/repair-command/index.js +101 -128
- package/frigg-cli/start-command/application/RunPreflightChecksUseCase.js +376 -0
- package/frigg-cli/start-command/index.js +246 -2
- package/frigg-cli/start-command/infrastructure/DatabaseAdapter.js +591 -0
- package/frigg-cli/start-command/infrastructure/DockerAdapter.js +306 -0
- package/frigg-cli/start-command/presentation/InteractivePromptAdapter.js +329 -0
- package/frigg-cli/templates/backend/.env.example +62 -0
- package/frigg-cli/templates/backend/.eslintrc.json +12 -0
- package/frigg-cli/templates/backend/.prettierrc +6 -0
- package/frigg-cli/templates/backend/docker-compose.yml +22 -0
- package/frigg-cli/templates/backend/index.js +96 -0
- package/frigg-cli/templates/backend/infrastructure.js +12 -0
- package/frigg-cli/templates/backend/jest.config.js +17 -0
- package/frigg-cli/templates/backend/package.json +50 -0
- package/frigg-cli/templates/backend/src/api-modules/.gitkeep +10 -0
- package/frigg-cli/templates/backend/src/base/.gitkeep +7 -0
- package/frigg-cli/templates/backend/src/integrations/.gitkeep +10 -0
- package/frigg-cli/templates/backend/src/integrations/ExampleIntegration.js +65 -0
- package/frigg-cli/templates/backend/src/utils/.gitkeep +7 -0
- package/frigg-cli/templates/backend/test/setup.js +30 -0
- package/frigg-cli/templates/backend/ui-extensions/.gitkeep +0 -0
- package/frigg-cli/templates/backend/ui-extensions/README.md +77 -0
- package/frigg-cli/ui-command/index.js +58 -36
- package/frigg-cli/utils/__tests__/repo-detection.test.js +436 -0
- package/frigg-cli/utils/output.js +382 -0
- package/frigg-cli/utils/repo-detection.js +85 -37
- package/frigg-cli/validate-command/__tests__/adapters/validate-command.test.js +205 -0
- package/frigg-cli/validate-command/__tests__/application/validate-app-use-case.test.js +104 -0
- package/frigg-cli/validate-command/__tests__/domain/fix-suggestion.test.js +153 -0
- package/frigg-cli/validate-command/__tests__/domain/validation-error.test.js +162 -0
- package/frigg-cli/validate-command/__tests__/domain/validation-result.test.js +152 -0
- package/frigg-cli/validate-command/__tests__/infrastructure/api-module-validator.test.js +332 -0
- package/frigg-cli/validate-command/__tests__/infrastructure/app-definition-validator.test.js +191 -0
- package/frigg-cli/validate-command/__tests__/infrastructure/integration-class-validator.test.js +146 -0
- package/frigg-cli/validate-command/__tests__/infrastructure/template-validation.test.js +155 -0
- package/frigg-cli/validate-command/adapters/cli/validate-command.js +199 -0
- package/frigg-cli/validate-command/application/use-cases/validate-app-use-case.js +35 -0
- package/frigg-cli/validate-command/domain/entities/validation-result.js +74 -0
- package/frigg-cli/validate-command/domain/value-objects/fix-suggestion.js +74 -0
- package/frigg-cli/validate-command/domain/value-objects/validation-error.js +68 -0
- package/frigg-cli/validate-command/infrastructure/validators/api-module-validator.js +181 -0
- package/frigg-cli/validate-command/infrastructure/validators/app-definition-validator.js +128 -0
- package/frigg-cli/validate-command/infrastructure/validators/integration-class-validator.js +113 -0
- package/infrastructure/docs/iam-policy-templates.md +1 -1
- package/infrastructure/domains/networking/vpc-builder.test.js +2 -4
- package/infrastructure/domains/networking/vpc-resolver.test.js +1 -1
- package/infrastructure/domains/shared/cloudformation-discovery.test.js +4 -7
- package/infrastructure/domains/shared/resource-discovery.js +5 -5
- package/infrastructure/domains/shared/types/discovery-result.test.js +1 -1
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +10 -1
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +2 -2
- package/infrastructure/infrastructure-composer.test.js +2 -2
- package/infrastructure/jest.config.js +16 -0
- package/management-ui/README.md +245 -109
- package/package.json +8 -7
- package/frigg-cli/install-command/logger.js +0 -12
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const dotenv = require('dotenv');
|
|
3
3
|
const { readFileSync, writeFileSync, existsSync } = require('fs');
|
|
4
|
-
const
|
|
4
|
+
const output = require('../utils/output');
|
|
5
5
|
const { resolve } = require('node:path');
|
|
6
|
-
const { confirm, input } = require('@inquirer/prompts');
|
|
7
6
|
const { parse } = require('@babel/parser');
|
|
8
7
|
const traverse = require('@babel/traverse').default;
|
|
9
8
|
|
|
@@ -43,15 +42,14 @@ const extractRawEnvVariables = (modulePath) => {
|
|
|
43
42
|
return envVariables;
|
|
44
43
|
};
|
|
45
44
|
const handleEnvVariables = async (backendPath, modulePath) => {
|
|
46
|
-
|
|
45
|
+
output.info('Searching for missing environment variables...');
|
|
47
46
|
const Definition = { env: extractRawEnvVariables(modulePath) };
|
|
48
47
|
if (Definition && Definition.env) {
|
|
49
|
-
|
|
48
|
+
output.debug('Definition.env:', JSON.stringify(Definition.env));
|
|
50
49
|
const envVars = Object.values(Definition.env);
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
envVars
|
|
51
|
+
output.info(
|
|
52
|
+
`Found environment variables in API module: ${envVars.join(', ')}`
|
|
55
53
|
);
|
|
56
54
|
|
|
57
55
|
const localEnvPath = resolve(backendPath, '../.env');
|
|
@@ -78,23 +76,19 @@ const handleEnvVariables = async (backendPath, modulePath) => {
|
|
|
78
76
|
(envVar) => !localEnvVars[envVar] && !localDevConfig[envVar]
|
|
79
77
|
);
|
|
80
78
|
|
|
81
|
-
logInfo(`Missing environment variables: ${missingEnvVars.join(', ')}`);
|
|
82
|
-
|
|
83
79
|
if (missingEnvVars.length > 0) {
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
output.warn(`Missing environment variables: ${missingEnvVars.join(', ')}`);
|
|
81
|
+
|
|
82
|
+
const addEnvVars = await output.confirm(
|
|
83
|
+
`The following environment variables are required: ${missingEnvVars.join(
|
|
86
84
|
', '
|
|
87
|
-
)}. Do you want to add them now
|
|
88
|
-
|
|
85
|
+
)}. Do you want to add them now?`
|
|
86
|
+
);
|
|
89
87
|
|
|
90
88
|
if (addEnvVars) {
|
|
91
89
|
const envValues = {};
|
|
92
90
|
for (const envVar of missingEnvVars) {
|
|
93
|
-
const value = await input({
|
|
94
|
-
type: 'input',
|
|
95
|
-
name: 'value',
|
|
96
|
-
message: `Enter value for ${envVar}:`,
|
|
97
|
-
});
|
|
91
|
+
const value = await output.input(`Enter value for ${envVar}:`);
|
|
98
92
|
envValues[envVar] = value;
|
|
99
93
|
}
|
|
100
94
|
|
|
@@ -117,9 +111,12 @@ const handleEnvVariables = async (backendPath, modulePath) => {
|
|
|
117
111
|
JSON.stringify(updatedDevConfig, null, 2)
|
|
118
112
|
);
|
|
119
113
|
}
|
|
114
|
+
output.success('Environment variables added successfully');
|
|
120
115
|
} else {
|
|
121
|
-
|
|
116
|
+
output.info("Edit whenever you're able, safe travels friend!");
|
|
122
117
|
}
|
|
118
|
+
} else {
|
|
119
|
+
output.success('All required environment variables are already configured');
|
|
123
120
|
}
|
|
124
121
|
}
|
|
125
122
|
};
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
const { handleEnvVariables } = require('./environment-variables');
|
|
2
|
-
const
|
|
3
|
-
const inquirer = require('inquirer');
|
|
2
|
+
const output = require('../utils/output');
|
|
4
3
|
const fs = require('fs');
|
|
5
4
|
const dotenv = require('dotenv');
|
|
6
5
|
const { resolve } = require('node:path');
|
|
7
6
|
const { parse } = require('@babel/parser');
|
|
8
7
|
const traverse = require('@babel/traverse');
|
|
9
8
|
|
|
10
|
-
jest.mock('
|
|
9
|
+
jest.mock('../utils/output');
|
|
11
10
|
jest.mock('fs');
|
|
12
11
|
jest.mock('dotenv');
|
|
13
|
-
jest.mock('./logger');
|
|
14
12
|
jest.mock('@babel/parser');
|
|
15
13
|
jest.mock('@babel/traverse');
|
|
16
14
|
|
|
@@ -99,22 +97,23 @@ describe('handleEnvVariables', () => {
|
|
|
99
97
|
return '';
|
|
100
98
|
});
|
|
101
99
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
.mockResolvedValueOnce(
|
|
105
|
-
.mockResolvedValueOnce(
|
|
106
|
-
.mockResolvedValueOnce(
|
|
107
|
-
.mockResolvedValueOnce(
|
|
100
|
+
output.confirm.mockResolvedValueOnce(true);
|
|
101
|
+
output.input
|
|
102
|
+
.mockResolvedValueOnce('client_id_value')
|
|
103
|
+
.mockResolvedValueOnce('client_secret_value')
|
|
104
|
+
.mockResolvedValueOnce('redirect_uri_value')
|
|
105
|
+
.mockResolvedValueOnce('scope_value');
|
|
108
106
|
|
|
109
107
|
await handleEnvVariables(backendPath, modulePath);
|
|
110
108
|
|
|
111
|
-
expect(
|
|
109
|
+
expect(output.info).toHaveBeenCalledWith(
|
|
112
110
|
'Searching for missing environment variables...'
|
|
113
111
|
);
|
|
114
|
-
expect(
|
|
112
|
+
expect(output.warn).toHaveBeenCalledWith(
|
|
115
113
|
'Missing environment variables: GOOGLE_CALENDAR_CLIENT_ID, GOOGLE_CALENDAR_CLIENT_SECRET, REDIRECT_URI, GOOGLE_CALENDAR_SCOPE'
|
|
116
114
|
);
|
|
117
|
-
expect(
|
|
115
|
+
expect(output.confirm).toHaveBeenCalledTimes(1);
|
|
116
|
+
expect(output.input).toHaveBeenCalledTimes(4);
|
|
118
117
|
expect(fs.appendFileSync).toHaveBeenCalledWith(
|
|
119
118
|
localEnvPath,
|
|
120
119
|
'\nGOOGLE_CALENDAR_CLIENT_ID=client_id_value\nGOOGLE_CALENDAR_CLIENT_SECRET=client_secret_value\nREDIRECT_URI=redirect_uri_value\nGOOGLE_CALENDAR_SCOPE=scope_value'
|
|
@@ -2,7 +2,7 @@ const { installPackage } = require('./install-package');
|
|
|
2
2
|
const { createIntegrationFile } = require('./integration-file');
|
|
3
3
|
const { resolve } = require('node:path');
|
|
4
4
|
const { updateBackendJsFile } = require('./backend-js');
|
|
5
|
-
const
|
|
5
|
+
const output = require('../utils/output');
|
|
6
6
|
const { commitChanges } = require('./commit-changes');
|
|
7
7
|
const { handleEnvVariables } = require('./environment-variables');
|
|
8
8
|
const {
|
|
@@ -35,18 +35,23 @@ const installCommand = async (apiModuleName) => {
|
|
|
35
35
|
const sanitizedLabel = label.replace(
|
|
36
36
|
/[<>:"/\\|?*\x00-\x1F\s]/g,
|
|
37
37
|
''
|
|
38
|
-
); // Remove invalid characters and spaces
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
); // Remove invalid characters and spaces
|
|
39
|
+
|
|
40
|
+
const spinner = output.spinner(`Installing integration for ${sanitizedLabel}...`);
|
|
41
|
+
try {
|
|
42
|
+
createIntegrationFile(backendPath, sanitizedLabel, ApiClass);
|
|
43
|
+
updateBackendJsFile(backendPath, sanitizedLabel);
|
|
44
|
+
commitChanges(backendPath, sanitizedLabel);
|
|
45
|
+
spinner.succeed(`Successfully installed ${packageName} and updated the project.`);
|
|
46
|
+
} catch (innerError) {
|
|
47
|
+
spinner.fail(`Failed to install ${packageName}`);
|
|
48
|
+
throw innerError;
|
|
49
|
+
}
|
|
45
50
|
|
|
46
51
|
await handleEnvVariables(backendPath, modulePath);
|
|
47
52
|
}
|
|
48
53
|
} catch (error) {
|
|
49
|
-
|
|
54
|
+
output.error('An error occurred:', error);
|
|
50
55
|
process.exit(1);
|
|
51
56
|
}
|
|
52
57
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const fs = require('fs-extra');
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const
|
|
3
|
+
const output = require('../utils/output');
|
|
4
4
|
const { getIntegrationTemplate } = require('./template');
|
|
5
5
|
const INTEGRATIONS_DIR = 'src/integrations';
|
|
6
6
|
|
|
@@ -9,14 +9,14 @@ function createIntegrationFile(backendPath, apiModuleName, ApiClass) {
|
|
|
9
9
|
path.dirname(backendPath),
|
|
10
10
|
INTEGRATIONS_DIR
|
|
11
11
|
);
|
|
12
|
-
|
|
12
|
+
output.debug(`Ensuring directory exists: ${integrationDir}`);
|
|
13
13
|
fs.ensureDirSync(integrationDir);
|
|
14
14
|
|
|
15
15
|
const integrationFilePath = path.join(
|
|
16
16
|
integrationDir,
|
|
17
17
|
`${apiModuleName}Integration.js`
|
|
18
18
|
);
|
|
19
|
-
|
|
19
|
+
output.debug(`Writing integration file: ${integrationFilePath}`);
|
|
20
20
|
const integrationTemplate = getIntegrationTemplate(
|
|
21
21
|
apiModuleName,
|
|
22
22
|
backendPath,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const { execSync } = require('child_process');
|
|
2
2
|
const axios = require('axios');
|
|
3
|
-
const
|
|
4
|
-
const { checkbox } = require('@inquirer/prompts');
|
|
3
|
+
const output = require('../utils/output');
|
|
5
4
|
|
|
6
5
|
async function searchPackages(apiModuleName) {
|
|
7
6
|
const searchCommand = `npm search @friggframework/api-module-${apiModuleName} --json`;
|
|
@@ -31,7 +30,7 @@ const searchAndSelectPackage = async (apiModuleName) => {
|
|
|
31
30
|
const searchResults = await searchPackages(apiModuleName || '');
|
|
32
31
|
|
|
33
32
|
if (searchResults.length === 0) {
|
|
34
|
-
|
|
33
|
+
output.error(`No packages found matching ${apiModuleName}`);
|
|
35
34
|
process.exit(1);
|
|
36
35
|
}
|
|
37
36
|
|
|
@@ -44,7 +43,7 @@ const searchAndSelectPackage = async (apiModuleName) => {
|
|
|
44
43
|
const earlierVersions = searchResults
|
|
45
44
|
.map((pkg) => `${pkg.name} (${pkg.version})`)
|
|
46
45
|
.join(', ');
|
|
47
|
-
|
|
46
|
+
output.error(
|
|
48
47
|
`No packages found with version 1.0.0 or above for ${apiModuleName}. Found earlier versions: ${earlierVersions}`
|
|
49
48
|
);
|
|
50
49
|
process.exit(1);
|
|
@@ -58,11 +57,8 @@ const searchAndSelectPackage = async (apiModuleName) => {
|
|
|
58
57
|
};
|
|
59
58
|
});
|
|
60
59
|
|
|
61
|
-
const selectedPackages = await checkbox(
|
|
62
|
-
|
|
63
|
-
choices,
|
|
64
|
-
});
|
|
65
|
-
console.log('Selected packages:', selectedPackages);
|
|
60
|
+
const selectedPackages = await output.checkbox('Select the packages to install:', choices);
|
|
61
|
+
output.info(`Selected packages: ${selectedPackages.join(', ')}`);
|
|
66
62
|
|
|
67
63
|
return selectedPackages.map((choice) => choice.split(' ')[0]);
|
|
68
64
|
};
|
package/frigg-cli/jest.config.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
1
3
|
module.exports = {
|
|
2
4
|
displayName: 'Frigg CLI Tests',
|
|
5
|
+
rootDir: __dirname,
|
|
3
6
|
testMatch: [
|
|
4
7
|
'<rootDir>/__tests__/**/*.test.js',
|
|
5
8
|
'<rootDir>/__tests__/**/*.spec.js',
|
|
@@ -93,7 +96,7 @@ module.exports = {
|
|
|
93
96
|
}
|
|
94
97
|
},
|
|
95
98
|
setupFilesAfterEnv: [
|
|
96
|
-
'
|
|
99
|
+
path.join(__dirname, '__tests__', 'utils', 'test-setup.js')
|
|
97
100
|
],
|
|
98
101
|
testTimeout: 10000,
|
|
99
102
|
maxWorkers: '50%',
|