@geekmidas/cli 0.10.0 → 0.12.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 (145) hide show
  1. package/README.md +525 -0
  2. package/dist/bundler-DRXCw_YR.mjs +70 -0
  3. package/dist/bundler-DRXCw_YR.mjs.map +1 -0
  4. package/dist/bundler-WsEvH_b2.cjs +71 -0
  5. package/dist/bundler-WsEvH_b2.cjs.map +1 -0
  6. package/dist/{config-C9aXOHBe.cjs → config-AmInkU7k.cjs} +8 -8
  7. package/dist/config-AmInkU7k.cjs.map +1 -0
  8. package/dist/{config-BrkUalUh.mjs → config-DYULeEv8.mjs} +3 -3
  9. package/dist/config-DYULeEv8.mjs.map +1 -0
  10. package/dist/config.cjs +1 -1
  11. package/dist/config.d.cts +1 -1
  12. package/dist/config.d.mts +1 -1
  13. package/dist/config.mjs +1 -1
  14. package/dist/encryption-C8H-38Yy.mjs +42 -0
  15. package/dist/encryption-C8H-38Yy.mjs.map +1 -0
  16. package/dist/encryption-Dyf_r1h-.cjs +44 -0
  17. package/dist/encryption-Dyf_r1h-.cjs.map +1 -0
  18. package/dist/index.cjs +2116 -179
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.mjs +2134 -192
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/{openapi-CZLI4QTr.mjs → openapi-BfFlOBCG.mjs} +801 -38
  23. package/dist/openapi-BfFlOBCG.mjs.map +1 -0
  24. package/dist/{openapi-BeHLKcwP.cjs → openapi-Bt_1FDpT.cjs} +794 -31
  25. package/dist/openapi-Bt_1FDpT.cjs.map +1 -0
  26. package/dist/{openapi-react-query-o5iMi8tz.cjs → openapi-react-query-B-sNWHFU.cjs} +5 -5
  27. package/dist/openapi-react-query-B-sNWHFU.cjs.map +1 -0
  28. package/dist/{openapi-react-query-CcciaVu5.mjs → openapi-react-query-B6XTeGqS.mjs} +5 -5
  29. package/dist/openapi-react-query-B6XTeGqS.mjs.map +1 -0
  30. package/dist/openapi-react-query.cjs +1 -1
  31. package/dist/openapi-react-query.d.cts.map +1 -1
  32. package/dist/openapi-react-query.d.mts.map +1 -1
  33. package/dist/openapi-react-query.mjs +1 -1
  34. package/dist/openapi.cjs +2 -2
  35. package/dist/openapi.d.cts +1 -1
  36. package/dist/openapi.d.cts.map +1 -1
  37. package/dist/openapi.d.mts +1 -1
  38. package/dist/openapi.d.mts.map +1 -1
  39. package/dist/openapi.mjs +2 -2
  40. package/dist/storage-BUYQJgz7.cjs +4 -0
  41. package/dist/storage-BXoJvmv2.cjs +149 -0
  42. package/dist/storage-BXoJvmv2.cjs.map +1 -0
  43. package/dist/storage-C9PU_30f.mjs +101 -0
  44. package/dist/storage-C9PU_30f.mjs.map +1 -0
  45. package/dist/storage-DLJAYxzJ.mjs +3 -0
  46. package/dist/{types-b-vwGpqc.d.cts → types-BR0M2v_c.d.mts} +100 -1
  47. package/dist/types-BR0M2v_c.d.mts.map +1 -0
  48. package/dist/{types-DXgiA1sF.d.mts → types-BhkZc-vm.d.cts} +100 -1
  49. package/dist/types-BhkZc-vm.d.cts.map +1 -0
  50. package/examples/cron-example.ts +27 -27
  51. package/examples/env.ts +27 -27
  52. package/examples/function-example.ts +31 -31
  53. package/examples/gkm.config.json +20 -20
  54. package/examples/gkm.config.ts +8 -8
  55. package/examples/gkm.minimal.config.json +5 -5
  56. package/examples/gkm.production.config.json +25 -25
  57. package/examples/logger.ts +2 -2
  58. package/package.json +6 -6
  59. package/src/__tests__/EndpointGenerator.hooks.spec.ts +191 -191
  60. package/src/__tests__/config.spec.ts +55 -55
  61. package/src/__tests__/loadEnvFiles.spec.ts +93 -93
  62. package/src/__tests__/normalizeHooksConfig.spec.ts +58 -58
  63. package/src/__tests__/openapi-react-query.spec.ts +497 -497
  64. package/src/__tests__/openapi.spec.ts +428 -428
  65. package/src/__tests__/test-helpers.ts +76 -76
  66. package/src/auth/__tests__/credentials.spec.ts +204 -0
  67. package/src/auth/__tests__/index.spec.ts +168 -0
  68. package/src/auth/credentials.ts +187 -0
  69. package/src/auth/index.ts +226 -0
  70. package/src/build/__tests__/index-new.spec.ts +474 -474
  71. package/src/build/__tests__/manifests.spec.ts +333 -333
  72. package/src/build/bundler.ts +141 -0
  73. package/src/build/endpoint-analyzer.ts +236 -0
  74. package/src/build/handler-templates.ts +1253 -0
  75. package/src/build/index.ts +250 -179
  76. package/src/build/manifests.ts +52 -52
  77. package/src/build/providerResolver.ts +145 -145
  78. package/src/build/types.ts +64 -43
  79. package/src/config.ts +39 -39
  80. package/src/deploy/__tests__/docker.spec.ts +111 -0
  81. package/src/deploy/__tests__/dokploy.spec.ts +245 -0
  82. package/src/deploy/__tests__/init.spec.ts +662 -0
  83. package/src/deploy/docker.ts +128 -0
  84. package/src/deploy/dokploy.ts +204 -0
  85. package/src/deploy/index.ts +136 -0
  86. package/src/deploy/init.ts +484 -0
  87. package/src/deploy/types.ts +48 -0
  88. package/src/dev/__tests__/index.spec.ts +266 -266
  89. package/src/dev/index.ts +647 -601
  90. package/src/docker/__tests__/compose.spec.ts +531 -0
  91. package/src/docker/__tests__/templates.spec.ts +280 -0
  92. package/src/docker/compose.ts +273 -0
  93. package/src/docker/index.ts +230 -0
  94. package/src/docker/templates.ts +446 -0
  95. package/src/generators/CronGenerator.ts +72 -72
  96. package/src/generators/EndpointGenerator.ts +699 -398
  97. package/src/generators/FunctionGenerator.ts +84 -84
  98. package/src/generators/Generator.ts +72 -72
  99. package/src/generators/OpenApiTsGenerator.ts +577 -577
  100. package/src/generators/SubscriberGenerator.ts +124 -124
  101. package/src/generators/__tests__/CronGenerator.spec.ts +433 -433
  102. package/src/generators/__tests__/EndpointGenerator.spec.ts +532 -382
  103. package/src/generators/__tests__/FunctionGenerator.spec.ts +244 -244
  104. package/src/generators/__tests__/SubscriberGenerator.spec.ts +397 -382
  105. package/src/generators/index.ts +4 -4
  106. package/src/index.ts +623 -201
  107. package/src/init/__tests__/generators.spec.ts +334 -334
  108. package/src/init/__tests__/init.spec.ts +332 -332
  109. package/src/init/__tests__/utils.spec.ts +89 -89
  110. package/src/init/generators/config.ts +175 -175
  111. package/src/init/generators/docker.ts +41 -41
  112. package/src/init/generators/env.ts +72 -72
  113. package/src/init/generators/index.ts +1 -1
  114. package/src/init/generators/models.ts +64 -64
  115. package/src/init/generators/monorepo.ts +161 -161
  116. package/src/init/generators/package.ts +71 -71
  117. package/src/init/generators/source.ts +6 -6
  118. package/src/init/index.ts +203 -208
  119. package/src/init/templates/api.ts +115 -115
  120. package/src/init/templates/index.ts +75 -75
  121. package/src/init/templates/minimal.ts +98 -98
  122. package/src/init/templates/serverless.ts +89 -89
  123. package/src/init/templates/worker.ts +98 -98
  124. package/src/init/utils.ts +54 -56
  125. package/src/openapi-react-query.ts +194 -194
  126. package/src/openapi.ts +63 -63
  127. package/src/secrets/__tests__/encryption.spec.ts +226 -0
  128. package/src/secrets/__tests__/generator.spec.ts +319 -0
  129. package/src/secrets/__tests__/index.spec.ts +91 -0
  130. package/src/secrets/__tests__/storage.spec.ts +403 -0
  131. package/src/secrets/encryption.ts +91 -0
  132. package/src/secrets/generator.ts +164 -0
  133. package/src/secrets/index.ts +383 -0
  134. package/src/secrets/storage.ts +134 -0
  135. package/src/secrets/types.ts +53 -0
  136. package/src/types.ts +295 -176
  137. package/tsdown.config.ts +11 -8
  138. package/dist/config-BrkUalUh.mjs.map +0 -1
  139. package/dist/config-C9aXOHBe.cjs.map +0 -1
  140. package/dist/openapi-BeHLKcwP.cjs.map +0 -1
  141. package/dist/openapi-CZLI4QTr.mjs.map +0 -1
  142. package/dist/openapi-react-query-CcciaVu5.mjs.map +0 -1
  143. package/dist/openapi-react-query-o5iMi8tz.cjs.map +0 -1
  144. package/dist/types-DXgiA1sF.d.mts.map +0 -1
  145. package/dist/types-b-vwGpqc.d.cts.map +0 -1
@@ -4,90 +4,90 @@ import { Cron } from '@geekmidas/constructs/crons';
4
4
  import type { BuildContext } from '../build/types';
5
5
  import type { CronInfo } from '../types';
6
6
  import {
7
- ConstructGenerator,
8
- type GeneratedConstruct,
9
- type GeneratorOptions,
7
+ ConstructGenerator,
8
+ type GeneratedConstruct,
9
+ type GeneratorOptions,
10
10
  } from './Generator';
11
11
 
12
12
  export class CronGenerator extends ConstructGenerator<
13
- Cron<any, any, any, any, any, any, any, any>,
14
- CronInfo[]
13
+ Cron<any, any, any, any, any, any, any, any>,
14
+ CronInfo[]
15
15
  > {
16
- async build(
17
- context: BuildContext,
18
- constructs: GeneratedConstruct<
19
- Cron<any, any, any, any, any, any, any, any>
20
- >[],
21
- outputDir: string,
22
- options?: GeneratorOptions,
23
- ): Promise<CronInfo[]> {
24
- const provider = options?.provider || 'aws-lambda';
25
- const logger = console;
26
- const cronInfos: CronInfo[] = [];
16
+ async build(
17
+ context: BuildContext,
18
+ constructs: GeneratedConstruct<
19
+ Cron<any, any, any, any, any, any, any, any>
20
+ >[],
21
+ outputDir: string,
22
+ options?: GeneratorOptions,
23
+ ): Promise<CronInfo[]> {
24
+ const provider = options?.provider || 'aws-lambda';
25
+ const logger = console;
26
+ const cronInfos: CronInfo[] = [];
27
27
 
28
- if (constructs.length === 0 || provider !== 'aws-lambda') {
29
- return cronInfos;
30
- }
28
+ if (constructs.length === 0 || provider !== 'aws-lambda') {
29
+ return cronInfos;
30
+ }
31
31
 
32
- // Create crons subdirectory
33
- const cronsDir = join(outputDir, 'crons');
34
- await mkdir(cronsDir, { recursive: true });
32
+ // Create crons subdirectory
33
+ const cronsDir = join(outputDir, 'crons');
34
+ await mkdir(cronsDir, { recursive: true });
35
35
 
36
- // Generate cron handlers
37
- for (const { key, construct, path } of constructs) {
38
- const handlerFile = await this.generateCronHandler(
39
- cronsDir,
40
- path.relative,
41
- key,
42
- context,
43
- );
36
+ // Generate cron handlers
37
+ for (const { key, construct, path } of constructs) {
38
+ const handlerFile = await this.generateCronHandler(
39
+ cronsDir,
40
+ path.relative,
41
+ key,
42
+ context,
43
+ );
44
44
 
45
- cronInfos.push({
46
- name: key,
47
- handler: relative(process.cwd(), handlerFile).replace(
48
- /\.ts$/,
49
- '.handler',
50
- ),
51
- schedule: construct.schedule || 'rate(1 hour)',
52
- timeout: construct.timeout,
53
- memorySize: construct.memorySize,
54
- environment: await construct.getEnvironment(),
55
- });
45
+ cronInfos.push({
46
+ name: key,
47
+ handler: relative(process.cwd(), handlerFile).replace(
48
+ /\.ts$/,
49
+ '.handler',
50
+ ),
51
+ schedule: construct.schedule || 'rate(1 hour)',
52
+ timeout: construct.timeout,
53
+ memorySize: construct.memorySize,
54
+ environment: await construct.getEnvironment(),
55
+ });
56
56
 
57
- logger.log(`Generated cron handler: ${key}`);
58
- }
57
+ logger.log(`Generated cron handler: ${key}`);
58
+ }
59
59
 
60
- return cronInfos;
61
- }
60
+ return cronInfos;
61
+ }
62
62
 
63
- isConstruct(
64
- value: any,
65
- ): value is Cron<any, any, any, any, any, any, any, any> {
66
- return Cron.isCron(value);
67
- }
63
+ isConstruct(
64
+ value: any,
65
+ ): value is Cron<any, any, any, any, any, any, any, any> {
66
+ return Cron.isCron(value);
67
+ }
68
68
 
69
- private async generateCronHandler(
70
- outputDir: string,
71
- sourceFile: string,
72
- exportName: string,
73
- context: BuildContext,
74
- ): Promise<string> {
75
- const handlerFileName = `${exportName}.ts`;
76
- const handlerPath = join(outputDir, handlerFileName);
69
+ private async generateCronHandler(
70
+ outputDir: string,
71
+ sourceFile: string,
72
+ exportName: string,
73
+ context: BuildContext,
74
+ ): Promise<string> {
75
+ const handlerFileName = `${exportName}.ts`;
76
+ const handlerPath = join(outputDir, handlerFileName);
77
77
 
78
- const relativePath = relative(dirname(handlerPath), sourceFile);
79
- const importPath = relativePath.replace(/\.ts$/, '.js');
78
+ const relativePath = relative(dirname(handlerPath), sourceFile);
79
+ const importPath = relativePath.replace(/\.ts$/, '.js');
80
80
 
81
- const relativeEnvParserPath = relative(
82
- dirname(handlerPath),
83
- context.envParserPath,
84
- );
85
- const relativeLoggerPath = relative(
86
- dirname(handlerPath),
87
- context.loggerPath,
88
- );
81
+ const relativeEnvParserPath = relative(
82
+ dirname(handlerPath),
83
+ context.envParserPath,
84
+ );
85
+ const relativeLoggerPath = relative(
86
+ dirname(handlerPath),
87
+ context.loggerPath,
88
+ );
89
89
 
90
- const content = `import { AWSScheduledFunction } from '@geekmidas/constructs/crons';
90
+ const content = `import { AWSScheduledFunction } from '@geekmidas/constructs/crons';
91
91
  import { ${exportName} } from '${importPath}';
92
92
  import ${context.envParserImportPattern} from '${relativeEnvParserPath}';
93
93
  import ${context.loggerImportPattern} from '${relativeLoggerPath}';
@@ -97,7 +97,7 @@ const adapter = new AWSScheduledFunction(envParser, ${exportName});
97
97
  export const handler = adapter.handler;
98
98
  `;
99
99
 
100
- await writeFile(handlerPath, content);
101
- return handlerPath;
102
- }
100
+ await writeFile(handlerPath, content);
101
+ return handlerPath;
102
+ }
103
103
  }