@friggframework/devtools 2.0.0-next.47 → 2.0.0-next.48

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 (69) hide show
  1. package/frigg-cli/README.md +1290 -0
  2. package/frigg-cli/__tests__/unit/commands/build.test.js +279 -0
  3. package/frigg-cli/__tests__/unit/commands/db-setup.test.js +548 -0
  4. package/frigg-cli/__tests__/unit/commands/deploy.test.js +320 -0
  5. package/frigg-cli/__tests__/unit/commands/doctor.test.js +309 -0
  6. package/frigg-cli/__tests__/unit/commands/install.test.js +400 -0
  7. package/frigg-cli/__tests__/unit/commands/ui.test.js +346 -0
  8. package/frigg-cli/__tests__/unit/dependencies.test.js +74 -0
  9. package/frigg-cli/__tests__/unit/utils/database-validator.test.js +366 -0
  10. package/frigg-cli/__tests__/unit/utils/error-messages.test.js +304 -0
  11. package/frigg-cli/__tests__/unit/version-detection.test.js +171 -0
  12. package/frigg-cli/__tests__/utils/mock-factory.js +270 -0
  13. package/frigg-cli/__tests__/utils/prisma-mock.js +194 -0
  14. package/frigg-cli/__tests__/utils/test-fixtures.js +463 -0
  15. package/frigg-cli/__tests__/utils/test-setup.js +287 -0
  16. package/frigg-cli/build-command/index.js +66 -0
  17. package/frigg-cli/db-setup-command/index.js +193 -0
  18. package/frigg-cli/deploy-command/SPEC-DEPLOY-DRY-RUN.md +981 -0
  19. package/frigg-cli/deploy-command/index.js +302 -0
  20. package/frigg-cli/doctor-command/index.js +335 -0
  21. package/frigg-cli/generate-command/__tests__/generate-command.test.js +301 -0
  22. package/frigg-cli/generate-command/azure-generator.js +43 -0
  23. package/frigg-cli/generate-command/gcp-generator.js +47 -0
  24. package/frigg-cli/generate-command/index.js +332 -0
  25. package/frigg-cli/generate-command/terraform-generator.js +555 -0
  26. package/frigg-cli/generate-iam-command.js +118 -0
  27. package/frigg-cli/index.js +173 -0
  28. package/frigg-cli/index.test.js +158 -0
  29. package/frigg-cli/init-command/backend-first-handler.js +756 -0
  30. package/frigg-cli/init-command/index.js +93 -0
  31. package/frigg-cli/init-command/template-handler.js +143 -0
  32. package/frigg-cli/install-command/backend-js.js +33 -0
  33. package/frigg-cli/install-command/commit-changes.js +16 -0
  34. package/frigg-cli/install-command/environment-variables.js +127 -0
  35. package/frigg-cli/install-command/environment-variables.test.js +136 -0
  36. package/frigg-cli/install-command/index.js +54 -0
  37. package/frigg-cli/install-command/install-package.js +13 -0
  38. package/frigg-cli/install-command/integration-file.js +30 -0
  39. package/frigg-cli/install-command/logger.js +12 -0
  40. package/frigg-cli/install-command/template.js +90 -0
  41. package/frigg-cli/install-command/validate-package.js +75 -0
  42. package/frigg-cli/jest.config.js +124 -0
  43. package/frigg-cli/package.json +63 -0
  44. package/frigg-cli/repair-command/index.js +564 -0
  45. package/frigg-cli/start-command/index.js +149 -0
  46. package/frigg-cli/start-command/start-command.test.js +297 -0
  47. package/frigg-cli/test/init-command.test.js +180 -0
  48. package/frigg-cli/test/npm-registry.test.js +319 -0
  49. package/frigg-cli/ui-command/index.js +154 -0
  50. package/frigg-cli/utils/app-resolver.js +319 -0
  51. package/frigg-cli/utils/backend-path.js +25 -0
  52. package/frigg-cli/utils/database-validator.js +154 -0
  53. package/frigg-cli/utils/error-messages.js +257 -0
  54. package/frigg-cli/utils/npm-registry.js +167 -0
  55. package/frigg-cli/utils/process-manager.js +199 -0
  56. package/frigg-cli/utils/repo-detection.js +405 -0
  57. package/infrastructure/create-frigg-infrastructure.js +125 -12
  58. package/infrastructure/docs/PRE-DEPLOYMENT-HEALTH-CHECK-SPEC.md +1317 -0
  59. package/infrastructure/domains/shared/resource-discovery.enhanced.test.js +306 -0
  60. package/infrastructure/domains/shared/resource-discovery.js +31 -2
  61. package/infrastructure/domains/shared/utilities/base-definition-factory.js +1 -1
  62. package/infrastructure/domains/shared/utilities/prisma-layer-manager.js +109 -5
  63. package/infrastructure/domains/shared/utilities/prisma-layer-manager.test.js +310 -4
  64. package/infrastructure/domains/shared/validation/plugin-validator.js +187 -0
  65. package/infrastructure/domains/shared/validation/plugin-validator.test.js +323 -0
  66. package/infrastructure/infrastructure-composer.js +22 -0
  67. package/layers/prisma/.build-complete +3 -0
  68. package/package.json +18 -7
  69. package/management-ui/package-lock.json +0 -16517
@@ -0,0 +1,90 @@
1
+ const path = require('path');
2
+
3
+ function getIntegrationTemplate(apiModuleName, backendPath, ApiClass) {
4
+ // Find the sample data method
5
+ const apiMethods = Object.getOwnPropertyNames(ApiClass.prototype);
6
+ const sampleDataMethod =
7
+ apiMethods.find(
8
+ (method) =>
9
+ method.toLowerCase().includes('search') ||
10
+ method.toLowerCase().includes('list') ||
11
+ method.toLowerCase().includes('get')
12
+ ) || 'searchDeals';
13
+
14
+ return `const { get, IntegrationBase, Options } = require('@friggframework/core');
15
+ const { Definition: ${apiModuleName}Module, Config: defaultConfig } = require('@friggframework/api-module-${apiModuleName.toLowerCase()}');
16
+
17
+ class ${apiModuleName}Integration extends IntegrationBase {
18
+ static Config = {
19
+ name: defaultConfig.name || '${apiModuleName.toLowerCase()}',
20
+ version: '1.0.0',
21
+ supportedVersions: ['1.0.0'],
22
+ events: ['SEARCH_DEALS'],
23
+ };
24
+
25
+ static Options =
26
+ new Options({
27
+ module: ${apiModuleName}Module,
28
+ integrations: [${apiModuleName}Module],
29
+ display: {
30
+ name: defaultConfig.displayName || '${apiModuleName}',
31
+ description: defaultConfig.description || 'Sales & CRM, Marketing',
32
+ category: defaultConfig.category || 'Sales & CRM, Marketing',
33
+ detailsUrl: defaultConfig.detailsUrl || 'https://www.${apiModuleName.toLowerCase()}.com',
34
+ icon: defaultConfig.icon || 'https://friggframework.org/assets/img/${apiModuleName.toLowerCase()}.jpeg',
35
+ },
36
+ hasUserConfig: true,
37
+ });
38
+
39
+ static modules = {
40
+ ${apiModuleName.toLowerCase()}: ${apiModuleName}Module,
41
+ }
42
+
43
+ /**
44
+ * HANDLE EVENTS
45
+ */
46
+ async receiveNotification(notifier, event, object = null) {
47
+ if (event === 'SEARCH_DEALS') {
48
+ return this.target.api.searchDeals(object);
49
+ }
50
+ }
51
+
52
+ /**
53
+ * ALL CUSTOM/OPTIONAL METHODS FOR AN INTEGRATION MANAGER
54
+ */
55
+ async getSampleData() {
56
+ const res = await this.target.api.${sampleDataMethod}();
57
+ return { data: res };
58
+ }
59
+
60
+ /**
61
+ * ALL REQUIRED METHODS FOR AN INTEGRATION MANAGER
62
+ */
63
+ async onCreate(params) {
64
+ // Validate that we have all of the data we need
65
+ // Set integration status as makes sense. Default ENABLED
66
+ // TODO turn this into a validateConfig method/function
67
+ this.record.status = 'ENABLED';
68
+ await this.record.save();
69
+ return this.record;
70
+ }
71
+
72
+ async onUpdate(params) {
73
+ const newConfig = get(params, 'config');
74
+ const oldConfig = this.record.config;
75
+ // Just save whatever
76
+ this.record.markModified('config');
77
+ await this.record.save();
78
+ return this.validateConfig();
79
+ }
80
+
81
+ async getConfigOptions() {
82
+ const options = {}
83
+ return options;
84
+ }
85
+ }
86
+
87
+ module.exports = ${apiModuleName}Integration;`;
88
+ }
89
+
90
+ module.exports = { getIntegrationTemplate };
@@ -0,0 +1,75 @@
1
+ const { execSync } = require('child_process');
2
+ const axios = require('axios');
3
+ const { logError } = require('./logger');
4
+ const { checkbox } = require('@inquirer/prompts');
5
+
6
+ async function searchPackages(apiModuleName) {
7
+ const searchCommand = `npm search @friggframework/api-module-${apiModuleName} --json`;
8
+ const result = execSync(searchCommand, { encoding: 'utf8' });
9
+ return JSON.parse(result);
10
+ }
11
+
12
+ async function checkPackageExists(packageName) {
13
+ try {
14
+ const response = await axios.get(
15
+ `https://registry.npmjs.org/${packageName}`
16
+ );
17
+ return response.status === 200;
18
+ } catch (error) {
19
+ return false;
20
+ }
21
+ }
22
+
23
+ async function validatePackageExists(packageName) {
24
+ const packageExists = await checkPackageExists(packageName);
25
+ if (!packageExists) {
26
+ throw new Error(`Package ${packageName} does not exist on npm.`);
27
+ }
28
+ }
29
+
30
+ const searchAndSelectPackage = async (apiModuleName) => {
31
+ const searchResults = await searchPackages(apiModuleName || '');
32
+
33
+ if (searchResults.length === 0) {
34
+ logError(`No packages found matching ${apiModuleName}`);
35
+ process.exit(1);
36
+ }
37
+
38
+ const filteredResults = searchResults.filter((pkg) => {
39
+ const version = pkg.version ? pkg.version.split('.').map(Number) : [];
40
+ return version[0] >= 1;
41
+ });
42
+
43
+ if (filteredResults.length === 0) {
44
+ const earlierVersions = searchResults
45
+ .map((pkg) => `${pkg.name} (${pkg.version})`)
46
+ .join(', ');
47
+ logError(
48
+ `No packages found with version 1.0.0 or above for ${apiModuleName}. Found earlier versions: ${earlierVersions}`
49
+ );
50
+ process.exit(1);
51
+ }
52
+
53
+ const choices = filteredResults.map((pkg) => {
54
+ return {
55
+ name: `${pkg.name} (${pkg.version})`,
56
+ value: pkg.name,
57
+ checked: filteredResults.length === 1, // Automatically select if only one result
58
+ };
59
+ });
60
+
61
+ const selectedPackages = await checkbox({
62
+ message: 'Select the packages to install:',
63
+ choices,
64
+ });
65
+ console.log('Selected packages:', selectedPackages);
66
+
67
+ return selectedPackages.map((choice) => choice.split(' ')[0]);
68
+ };
69
+
70
+ module.exports = {
71
+ validatePackageExists,
72
+ checkPackageExists,
73
+ searchPackages,
74
+ searchAndSelectPackage,
75
+ };
@@ -0,0 +1,124 @@
1
+ module.exports = {
2
+ displayName: 'Frigg CLI Tests',
3
+ testMatch: [
4
+ '<rootDir>/__tests__/**/*.test.js',
5
+ '<rootDir>/__tests__/**/*.spec.js',
6
+ '<rootDir>/**/start-command.test.js',
7
+ '<rootDir>/**/__tests__/**/*.test.js'
8
+ ],
9
+ // Exclude utility files and config from being treated as tests
10
+ testPathIgnorePatterns: [
11
+ '/node_modules/',
12
+ '/__tests__/utils/',
13
+ '/__tests__/jest.config.js',
14
+ '/test-setup.js'
15
+ ],
16
+ testEnvironment: 'node',
17
+ collectCoverageFrom: [
18
+ '**/*.js',
19
+ '!**/*.test.js',
20
+ '!**/*.spec.js',
21
+ '!**/node_modules/**',
22
+ '!**/__tests__/**',
23
+ '!**/coverage/**'
24
+ ],
25
+ coverageDirectory: 'coverage',
26
+ coverageReporters: [
27
+ 'text',
28
+ 'text-summary',
29
+ 'html',
30
+ 'lcov',
31
+ 'json'
32
+ ],
33
+ coverageThreshold: {
34
+ global: {
35
+ branches: 85,
36
+ functions: 85,
37
+ lines: 85,
38
+ statements: 85
39
+ },
40
+ './install-command/index.js': {
41
+ branches: 90,
42
+ functions: 90,
43
+ lines: 90,
44
+ statements: 90
45
+ },
46
+ './build-command/index.js': {
47
+ branches: 90,
48
+ functions: 90,
49
+ lines: 90,
50
+ statements: 90
51
+ },
52
+ './deploy-command/index.js': {
53
+ branches: 90,
54
+ functions: 90,
55
+ lines: 90,
56
+ statements: 90
57
+ },
58
+ './ui-command/index.js': {
59
+ branches: 90,
60
+ functions: 90,
61
+ lines: 90,
62
+ statements: 90
63
+ },
64
+ './generate-command/index.js': {
65
+ branches: 90,
66
+ functions: 90,
67
+ lines: 90,
68
+ statements: 90
69
+ },
70
+ './db-setup-command/index.js': {
71
+ branches: 90,
72
+ functions: 90,
73
+ lines: 90,
74
+ statements: 90
75
+ },
76
+ './utils/database-validator.js': {
77
+ branches: 85,
78
+ functions: 85,
79
+ lines: 85,
80
+ statements: 85
81
+ },
82
+ './utils/prisma-runner.js': {
83
+ branches: 85,
84
+ functions: 85,
85
+ lines: 85,
86
+ statements: 85
87
+ },
88
+ './utils/error-messages.js': {
89
+ branches: 85,
90
+ functions: 85,
91
+ lines: 85,
92
+ statements: 85
93
+ }
94
+ },
95
+ setupFilesAfterEnv: [
96
+ '<rootDir>/__tests__/utils/test-setup.js'
97
+ ],
98
+ testTimeout: 10000,
99
+ maxWorkers: '50%',
100
+ verbose: true,
101
+ collectCoverage: true,
102
+ coveragePathIgnorePatterns: [
103
+ '/node_modules/',
104
+ '/__tests__/',
105
+ '/coverage/',
106
+ '.test.js',
107
+ '.spec.js'
108
+ ],
109
+ moduleFileExtensions: [
110
+ 'js',
111
+ 'json',
112
+ 'node'
113
+ ],
114
+ transform: {},
115
+ // testResultsProcessor: 'jest-sonar-reporter', // Optional dependency
116
+ reporters: [
117
+ 'default'
118
+ // jest-junit reporter removed - optional dependency
119
+ ],
120
+ watchman: false,
121
+ forceExit: true,
122
+ detectOpenHandles: true,
123
+ errorOnDeprecated: true
124
+ };
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@friggframework/frigg-cli",
3
+ "version": "2.0.0-next.0",
4
+ "description": "Frigg Framework CLI tool",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "frigg": "./index.js"
8
+ },
9
+ "scripts": {
10
+ "test": "jest"
11
+ },
12
+ "dependencies": {
13
+ "@aws-sdk/client-cloudformation": "^3.705.0",
14
+ "@babel/parser": "^7.25.3",
15
+ "@babel/traverse": "^7.25.3",
16
+ "@friggframework/core": "^2.0.0-next.0",
17
+ "@friggframework/schemas": "^2.0.0-next.0",
18
+ "@inquirer/prompts": "^5.3.8",
19
+ "axios": "^1.7.2",
20
+ "chalk": "^4.1.2",
21
+ "commander": "^12.1.0",
22
+ "cross-spawn": "^7.0.3",
23
+ "dotenv": "^16.4.5",
24
+ "fs-extra": "^11.2.0",
25
+ "js-yaml": "^4.1.0",
26
+ "lodash": "4.17.21",
27
+ "node-cache": "^5.1.2",
28
+ "open": "^8.4.2",
29
+ "osls": "^3.40.1",
30
+ "semver": "^7.6.0",
31
+ "validate-npm-package-name": "^5.0.0"
32
+ },
33
+ "peerDependencies": {
34
+ "@friggframework/devtools": "*"
35
+ },
36
+ "devDependencies": {
37
+ "@friggframework/devtools": "^2.0.0-next.0",
38
+ "jest": "^29.7.0",
39
+ "jest-mock-extended": "^3.0.5"
40
+ },
41
+ "keywords": [
42
+ "frigg",
43
+ "cli",
44
+ "integration",
45
+ "framework"
46
+ ],
47
+ "author": "Frigg Framework Team",
48
+ "license": "MIT",
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "git+https://github.com/friggframework/frigg.git"
52
+ },
53
+ "bugs": {
54
+ "url": "https://github.com/friggframework/frigg/issues"
55
+ },
56
+ "homepage": "https://github.com/friggframework/frigg#readme",
57
+ "engines": {
58
+ "node": ">=18"
59
+ },
60
+ "publishConfig": {
61
+ "access": "public"
62
+ }
63
+ }