andrud 1.0.1 → 1.0.3

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 (121) hide show
  1. package/README.md +295 -306
  2. package/dist/__tests__/context.test.d.ts +5 -0
  3. package/dist/__tests__/context.test.d.ts.map +1 -0
  4. package/dist/__tests__/context.test.js +86 -0
  5. package/dist/__tests__/context.test.js.map +1 -0
  6. package/dist/__tests__/generator.test.d.ts +5 -0
  7. package/dist/__tests__/generator.test.d.ts.map +1 -0
  8. package/dist/__tests__/generator.test.js +83 -0
  9. package/dist/__tests__/generator.test.js.map +1 -0
  10. package/dist/__tests__/validation.test.d.ts +5 -0
  11. package/dist/__tests__/validation.test.d.ts.map +1 -0
  12. package/dist/__tests__/validation.test.js +81 -0
  13. package/dist/__tests__/validation.test.js.map +1 -0
  14. package/dist/cli/commands/create.d.ts +10 -0
  15. package/dist/cli/commands/create.d.ts.map +1 -0
  16. package/dist/cli/commands/create.js +203 -0
  17. package/dist/cli/commands/create.js.map +1 -0
  18. package/dist/cli/commands/info.d.ts +13 -0
  19. package/dist/cli/commands/info.d.ts.map +1 -0
  20. package/dist/cli/commands/info.js +153 -0
  21. package/dist/cli/commands/info.js.map +1 -0
  22. package/dist/cli/commands/init.d.ts +15 -0
  23. package/dist/cli/commands/init.d.ts.map +1 -0
  24. package/dist/cli/commands/init.js +141 -0
  25. package/dist/cli/commands/init.js.map +1 -0
  26. package/dist/cli/commands/list.d.ts +18 -0
  27. package/dist/cli/commands/list.d.ts.map +1 -0
  28. package/dist/cli/commands/list.js +122 -0
  29. package/dist/cli/commands/list.js.map +1 -0
  30. package/dist/cli/commands/new.d.ts +22 -0
  31. package/dist/cli/commands/new.d.ts.map +1 -0
  32. package/dist/cli/commands/new.js +245 -0
  33. package/dist/cli/commands/new.js.map +1 -0
  34. package/dist/cli/index.d.ts +5 -0
  35. package/dist/cli/index.d.ts.map +1 -0
  36. package/dist/cli/index.js +157 -0
  37. package/dist/cli/index.js.map +1 -0
  38. package/dist/core/config.d.ts +89 -0
  39. package/dist/core/config.d.ts.map +1 -0
  40. package/dist/core/config.js +151 -0
  41. package/dist/core/config.js.map +1 -0
  42. package/dist/core/context.d.ts +47 -0
  43. package/dist/core/context.d.ts.map +1 -0
  44. package/dist/core/context.js +175 -0
  45. package/dist/core/context.js.map +1 -0
  46. package/dist/core/generator.d.ts +44 -0
  47. package/dist/core/generator.d.ts.map +1 -0
  48. package/{src/core/generator.ts → dist/core/generator.js} +394 -484
  49. package/dist/core/generator.js.map +1 -0
  50. package/dist/core/types.d.ts +125 -0
  51. package/dist/core/types.d.ts.map +1 -0
  52. package/dist/core/types.js +22 -0
  53. package/dist/core/types.js.map +1 -0
  54. package/dist/templates/index.d.ts +36 -0
  55. package/dist/templates/index.d.ts.map +1 -0
  56. package/dist/templates/index.js +141 -0
  57. package/dist/templates/index.js.map +1 -0
  58. package/dist/ui/colors.d.ts +40 -0
  59. package/dist/ui/colors.d.ts.map +1 -0
  60. package/dist/ui/colors.js +117 -0
  61. package/dist/ui/colors.js.map +1 -0
  62. package/dist/ui/output.d.ts +69 -0
  63. package/dist/ui/output.d.ts.map +1 -0
  64. package/dist/ui/output.js +199 -0
  65. package/dist/ui/output.js.map +1 -0
  66. package/dist/ui/prompts.d.ts +20 -0
  67. package/dist/ui/prompts.d.ts.map +1 -0
  68. package/dist/ui/prompts.js +118 -0
  69. package/dist/ui/prompts.js.map +1 -0
  70. package/dist/ui/spinners.d.ts +30 -0
  71. package/dist/ui/spinners.d.ts.map +1 -0
  72. package/dist/ui/spinners.js +74 -0
  73. package/dist/ui/spinners.js.map +1 -0
  74. package/dist/ui/types.d.ts +35 -0
  75. package/dist/ui/types.d.ts.map +1 -0
  76. package/dist/ui/types.js +5 -0
  77. package/dist/ui/types.js.map +1 -0
  78. package/dist/utils/filesystem.d.ts +38 -0
  79. package/dist/utils/filesystem.d.ts.map +1 -0
  80. package/dist/utils/filesystem.js +181 -0
  81. package/dist/utils/filesystem.js.map +1 -0
  82. package/dist/utils/logger.d.ts +27 -0
  83. package/dist/utils/logger.d.ts.map +1 -0
  84. package/dist/utils/logger.js +52 -0
  85. package/dist/utils/logger.js.map +1 -0
  86. package/dist/utils/object.d.ts +140 -0
  87. package/dist/utils/object.d.ts.map +1 -0
  88. package/dist/utils/object.js +385 -0
  89. package/dist/utils/object.js.map +1 -0
  90. package/dist/utils/validation.d.ts +35 -0
  91. package/dist/utils/validation.d.ts.map +1 -0
  92. package/dist/utils/validation.js +270 -0
  93. package/dist/utils/validation.js.map +1 -0
  94. package/package.json +10 -21
  95. package/CHANGELOG.md +0 -70
  96. package/CONTRIBUTING.md +0 -132
  97. package/sc.png +0 -0
  98. package/src/__tests__/context.test.ts +0 -133
  99. package/src/__tests__/generator.test.ts +0 -107
  100. package/src/__tests__/validation.test.ts +0 -105
  101. package/src/cli/commands/create.ts +0 -252
  102. package/src/cli/commands/info.ts +0 -178
  103. package/src/cli/commands/init.ts +0 -186
  104. package/src/cli/commands/list.ts +0 -156
  105. package/src/cli/commands/new.ts +0 -316
  106. package/src/cli/index.ts +0 -116
  107. package/src/core/config.ts +0 -172
  108. package/src/core/context.ts +0 -212
  109. package/src/core/types.ts +0 -184
  110. package/src/templates/index.ts +0 -162
  111. package/src/types/gradient-string.d.ts +0 -25
  112. package/src/ui/colors.ts +0 -139
  113. package/src/ui/output.ts +0 -230
  114. package/src/ui/prompts.ts +0 -170
  115. package/src/ui/spinners.ts +0 -95
  116. package/src/ui/types.ts +0 -41
  117. package/src/utils/filesystem.ts +0 -222
  118. package/src/utils/logger.ts +0 -67
  119. package/src/utils/object.ts +0 -456
  120. package/src/utils/validation.ts +0 -345
  121. package/tsconfig.json +0 -25
package/src/cli/index.ts DELETED
@@ -1,116 +0,0 @@
1
- /**
2
- * Command registration and main CLI entry point
3
- */
4
-
5
- import { cac } from 'cac';
6
- import pc from 'picocolors';
7
- import { createCommand } from './commands/create.js';
8
- import { createNewCommand } from './commands/new.js';
9
- import { createInitCommand } from './commands/init.js';
10
- import { createInfoCommand } from './commands/info.js';
11
- import { createListCommand } from './commands/list.js';
12
-
13
- const pkg = { version: '1.0.0' };
14
-
15
- const cli = cac('andrud');
16
-
17
- cli.version(pkg.version);
18
-
19
- // Clean minimal help
20
- function printHelp(): void {
21
- console.log('');
22
- console.log(` ${pc.cyan('andrud')} - Android Project Scaffolding`);
23
- console.log('');
24
- console.log(` ${pc.gray('andrud create')} Create a new project`);
25
- console.log(` ${pc.gray('andrud list')} Show available templates`);
26
- console.log(` ${pc.gray('andrud info <template>')} View template details`);
27
- console.log('');
28
- console.log(` ${pc.gray('andrud create MyApp')} Create with name`);
29
- console.log('');
30
- }
31
-
32
- // Commands
33
- cli
34
- .command('create', 'Create a new Android project')
35
- .alias('c')
36
- .option('-f, --force', 'Overwrite existing files')
37
- .example('andrud create')
38
- .example('andrud create --force')
39
- .action(createCommand);
40
-
41
- cli
42
- .command('new [name]', 'Create a new project')
43
- .alias('n')
44
- .option('-t, --template <type>', 'Template type')
45
- .option('-p, --package <name>', 'Package name')
46
- .option('-f, --force', 'Overwrite')
47
- .example('andrud new MyApp -t kotlin-compose')
48
- .action(createNewCommand);
49
-
50
- cli
51
- .command('init', 'Initialize in current directory')
52
- .alias('i')
53
- .option('-f, --force', 'Overwrite')
54
- .example('andrud init')
55
- .action(createInitCommand);
56
-
57
- cli
58
- .command('info [template]', 'Show template info')
59
- .example('andrud info kotlin-compose')
60
- .action(createInfoCommand);
61
-
62
- cli
63
- .command('list', 'List all templates')
64
- .alias('ls')
65
- .option('--json', 'Output as JSON')
66
- .action(createListCommand);
67
-
68
- cli.on('command:!', () => {
69
- console.error(pc.red(` Unknown command. See ${pc.cyan('--help')}\n`));
70
- });
71
-
72
- process.on('uncaughtException', (error) => {
73
- console.error(pc.red(` ${error.message}\n`));
74
- process.exit(1);
75
- });
76
-
77
- process.on('unhandledRejection', (reason) => {
78
- console.error(pc.red(` ${reason}\n`));
79
- process.exit(1);
80
- });
81
-
82
- export function runCli(): void {
83
- try {
84
- const args = process.argv.slice(2);
85
-
86
- // Show help
87
- if (args.includes('--help') || args.includes('-h')) {
88
- printHelp();
89
- return;
90
- }
91
-
92
- // Show version
93
- if (args.includes('--version') || args.includes('-V')) {
94
- console.log(pkg.version);
95
- return;
96
- }
97
-
98
- // Quick help on no args
99
- if (args.length === 0) {
100
- console.log('');
101
- console.log(` ${pc.cyan('andrud')} - Create Android projects`);
102
- console.log('');
103
- console.log(` ${pc.gray('andrud create')} Start interactive setup`);
104
- console.log(` ${pc.gray('andrud --help')} Show all commands`);
105
- console.log('');
106
- return;
107
- }
108
-
109
- cli.parse(process.argv, { run: true });
110
- } catch (error) {
111
- console.error(pc.red(` ${(error as Error).message}\n`));
112
- process.exit(1);
113
- }
114
- }
115
-
116
- // Note: runCli() is called from bin/andrud.js
@@ -1,172 +0,0 @@
1
- /**
2
- * Configuration constants for Android and Gradle versions
3
- */
4
-
5
- /**
6
- * Default Android SDK configuration
7
- */
8
- export const ANDROID_SDK_DEFAULTS = {
9
- MIN_SDK: 24,
10
- TARGET_SDK: 36,
11
- COMPILE_SDK: 36,
12
- BUILD_TOOLS_VERSION: '36.0.0'
13
- };
14
-
15
- /**
16
- * Gradle-related versions
17
- */
18
- export const GRADLE_VERSIONS = {
19
- AGP: '8.7.3',
20
- GRADLE: '8.14',
21
- KOTLIN: '2.0.21',
22
- COMPOSE_COMPILER: '1.5.14',
23
- COMPOSE_BOM: '2024.09.03',
24
- NDK: '28.2.13676358'
25
- };
26
-
27
- /**
28
- * AndroidX library versions
29
- */
30
- export const ANDROIDX_VERSIONS = {
31
- CORE_KTX: '1.15.0',
32
- APP_COMPAT: '1.7.0',
33
- MATERIAL: '1.12.0',
34
- LIFECYCLE: '2.8.7',
35
- ACTIVITY: '1.9.3',
36
- CONSTRAINT_LAYOUT: '2.2.0',
37
- RECYCLER_VIEW: '1.3.2',
38
- CARD_VIEW: '1.0.0',
39
- SWIPE_REFRESH: '1.1.0',
40
- NAVIGATION: '2.8.4',
41
- ROOM: '2.6.1',
42
- WORK: '2.10.0',
43
- HILT: '2.52'
44
- };
45
-
46
- /**
47
- * Compose versions
48
- */
49
- export const COMPOSE_VERSIONS = {
50
- BOM: '2025.01.00',
51
- UI: '1.3.0',
52
- UI_GRAPHICS: '1.3.0',
53
- UI_TOOLING: '1.3.0',
54
- MATERIAL3: '1.3.0',
55
- MATERIAL_ICONS: '1.3.0',
56
- FOUNDATION: '1.3.0',
57
- ACTIVITY: '1.9.3',
58
- LIFECYCLE: '2.8.7',
59
- NAVIGATION: '2.8.4'
60
- };
61
-
62
- /**
63
- * Default Gradle properties for Android projects
64
- */
65
- export function getDefaultGradleProperties(): Record<string, string | number | boolean> {
66
- return {
67
- 'org.gradle.jvmargs': '-Xmx2048m -Dfile.encoding=UTF-8',
68
- 'android.useAndroidX': true,
69
- 'android.enableJetifier': true,
70
- 'kotlin.code.style': 'official',
71
- 'org.gradle.parallel': true,
72
- 'org.gradle.caching': true,
73
- 'org.gradle.configureondemand': true,
74
- 'android.nonTransitiveRClass': true,
75
- 'android.defaults.buildfeatures.buildconfig': true
76
- };
77
- }
78
-
79
- /**
80
- * Get recommended minimum SDK based on year
81
- */
82
- export function getRecommendedMinSdk(): number {
83
- return 24; // Android 7.0 Nougat
84
- }
85
-
86
- /**
87
- * Get target SDK for a given year
88
- */
89
- export function getTargetSdkForYear(year: number): number {
90
- // By default, target the latest stable SDK
91
- if (year >= 2024) {
92
- return 35; // Android 15
93
- } else if (year >= 2023) {
94
- return 34; // Android 14
95
- } else if (year >= 2022) {
96
- return 33; // Android 13
97
- } else {
98
- return 32; // Android 12L
99
- }
100
- }
101
-
102
- /**
103
- * Template-specific configurations
104
- */
105
- export interface TemplateConfig {
106
- language: 'kotlin' | 'java';
107
- uiFramework: 'xml' | 'compose' | 'none';
108
- minSdk: number;
109
- targetSdk: number;
110
- compileSdk: number;
111
- kotlinVersion: string;
112
- agpVersion: string;
113
- gradleVersion: string;
114
- composeEnabled: boolean;
115
- ndkVersion?: string;
116
- }
117
-
118
- export const TEMPLATE_CONFIGS: Record<string, TemplateConfig> = {
119
- 'kotlin-compose': {
120
- language: 'kotlin',
121
- uiFramework: 'compose',
122
- minSdk: 31,
123
- targetSdk: 36,
124
- compileSdk: 36,
125
- kotlinVersion: GRADLE_VERSIONS.KOTLIN,
126
- agpVersion: GRADLE_VERSIONS.AGP,
127
- gradleVersion: GRADLE_VERSIONS.GRADLE,
128
- composeEnabled: true
129
- },
130
- 'kotlin-xml': {
131
- language: 'kotlin',
132
- uiFramework: 'xml',
133
- minSdk: 31,
134
- targetSdk: 36,
135
- compileSdk: 36,
136
- kotlinVersion: GRADLE_VERSIONS.KOTLIN,
137
- agpVersion: GRADLE_VERSIONS.AGP,
138
- gradleVersion: GRADLE_VERSIONS.GRADLE,
139
- composeEnabled: false
140
- },
141
- 'java-xml': {
142
- language: 'java',
143
- uiFramework: 'xml',
144
- minSdk: 31,
145
- targetSdk: 36,
146
- compileSdk: 36,
147
- kotlinVersion: '', // Not used for Java
148
- agpVersion: GRADLE_VERSIONS.AGP,
149
- gradleVersion: GRADLE_VERSIONS.GRADLE,
150
- composeEnabled: false
151
- },
152
- 'native-cpp': {
153
- language: 'kotlin',
154
- uiFramework: 'xml',
155
- minSdk: 31,
156
- targetSdk: 36,
157
- compileSdk: 36,
158
- kotlinVersion: GRADLE_VERSIONS.KOTLIN,
159
- agpVersion: GRADLE_VERSIONS.AGP,
160
- gradleVersion: GRADLE_VERSIONS.GRADLE,
161
- composeEnabled: false,
162
- ndkVersion: GRADLE_VERSIONS.NDK
163
- }
164
- };
165
-
166
- /**
167
- * Get template configuration
168
- */
169
- export function getTemplateConfig(template: string): TemplateConfig {
170
- const config = TEMPLATE_CONFIGS[template];
171
- return config ?? TEMPLATE_CONFIGS['kotlin-xml']!;
172
- }
@@ -1,212 +0,0 @@
1
- /**
2
- * Context builder for generating Android project context
3
- */
4
-
5
- import { camelCase, kebabCase, pascalCase, snakeCase } from '../utils/validation.js';
6
- import { GRADLE_VERSIONS, ANDROID_SDK_DEFAULTS, getTemplateConfig } from './config.js';
7
- import type { TemplateType, TemplateContext, AndroidSdkConfig, GradleConfig, ProjectFeatures, NativeCppConfig } from './types.js';
8
-
9
- const GENERATOR_VERSION = '1.0.0';
10
-
11
- /**
12
- * Build default context from basic parameters
13
- */
14
- export function buildDefaultProjectContext(
15
- appName: string,
16
- packageName: string,
17
- projectDirectory: string,
18
- template: TemplateType,
19
- features: Partial<ProjectFeatures> = {},
20
- minSdk?: number,
21
- targetSdk?: number
22
- ): Omit<TemplateContext, 'packagePath' | 'appNameSnake' | 'appNameKebab' | 'appNamePascal' | 'appNameCamel' | 'appNameLower' | 'year' | 'generatorVersion'> {
23
- // Determine language and UI framework from template
24
- const isCompose = template === 'kotlin-compose';
25
- const isNativeCpp = template === 'native-cpp';
26
- const isKotlin = template !== 'java-xml';
27
- const isXml = !isCompose;
28
-
29
- // Get template config for version info
30
- const templateConfig = getTemplateConfig(template);
31
-
32
- // Create Android SDK config
33
- const android: AndroidSdkConfig = {
34
- minSdk: minSdk ?? templateConfig.minSdk,
35
- targetSdk: targetSdk ?? templateConfig.targetSdk,
36
- compileSdk: templateConfig.compileSdk,
37
- buildToolsVersion: ANDROID_SDK_DEFAULTS.BUILD_TOOLS_VERSION
38
- };
39
-
40
- // Create Gradle config
41
- const gradle: GradleConfig = {
42
- agpVersion: templateConfig.agpVersion,
43
- gradleVersion: templateConfig.gradleVersion,
44
- kotlinVersion: isKotlin ? templateConfig.kotlinVersion : undefined,
45
- composeCompilerVersion: isCompose ? GRADLE_VERSIONS.COMPOSE_COMPILER : undefined,
46
- composeBomVersion: isCompose ? GRADLE_VERSIONS.COMPOSE_BOM : undefined
47
- };
48
-
49
- // Build project features
50
- const projectFeatures: ProjectFeatures = {
51
- git: features.git ?? true,
52
- readme: features.readme ?? true,
53
- androidX: features.androidX ?? true,
54
- kotlinDsl: features.kotlinDsl ?? true,
55
- adaptiveIcon: features.adaptiveIcon ?? true,
56
- material3: isCompose || (features.material3 ?? true),
57
- viewBinding: features.viewBinding ?? isXml,
58
- dataBinding: features.dataBinding ?? false,
59
- jetpackCompose: isCompose ? true : (features.jetpackCompose ?? false)
60
- };
61
-
62
- // Build native C++ config if needed
63
- const nativeCpp: NativeCppConfig | undefined = isNativeCpp ? {
64
- cppStandard: 'c++17',
65
- ndkVersion: templateConfig.ndkVersion ?? GRADLE_VERSIONS.NDK,
66
- stlType: 'c++_shared',
67
- abiFilters: ['armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64']
68
- } : undefined;
69
-
70
- // Build base context - spread features at top level to match TemplateContext (which extends ProjectFeatures)
71
- const baseContext = {
72
- appName,
73
- packageName,
74
- projectDirectory,
75
- template,
76
- language: templateConfig.language,
77
- uiFramework: templateConfig.uiFramework,
78
- android,
79
- gradle,
80
- ...projectFeatures,
81
- nativeCpp
82
- };
83
-
84
- // Cast to Omit<TemplateContext, ...> for the fields that buildTemplateContext adds
85
- const contextForBuildTemplate: Omit<TemplateContext, 'packagePath' | 'appNameSnake' | 'appNameKebab' | 'appNamePascal' | 'appNameCamel' | 'appNameLower' | 'year' | 'generatorVersion'> = baseContext as unknown as Omit<TemplateContext, 'packagePath' | 'appNameSnake' | 'appNameKebab' | 'appNamePascal' | 'appNameCamel' | 'appNameLower' | 'year' | 'generatorVersion'>;
86
- return contextForBuildTemplate;
87
- }
88
-
89
- /**
90
- * Build full template context with all derived values
91
- */
92
- export function buildTemplateContext(
93
- context: {
94
- appName: string;
95
- packageName: string;
96
- projectDirectory: string;
97
- template: string;
98
- uiFramework: string;
99
- language: 'kotlin' | 'java';
100
- android: { minSdk: number; targetSdk: number; compileSdk: number };
101
- gradle: {
102
- agpVersion: string;
103
- gradleVersion: string;
104
- kotlinVersion?: string;
105
- composeCompilerVersion?: string;
106
- composeBomVersion?: string;
107
- };
108
- features: Record<string, boolean>;
109
- nativeCpp?: { cppStandard: string; ndkVersion?: string; stlType?: string; abiFilters?: string[] };
110
- year?: string;
111
- }
112
- ): TemplateContext {
113
- // Transform app name to various cases
114
- const normalizedAppName = context.appName.replace(/\s+/g, '_');
115
- const appNameSnake = snakeCase(context.appName);
116
- const appNameKebab = kebabCase(context.appName);
117
- const appNamePascal = pascalCase(context.appName);
118
- const appNameCamel = camelCase(context.appName);
119
- const appNameLower = context.appName.toLowerCase().replace(/\s+/g, '');
120
-
121
- // Convert package name to path format (e.g., "com.example.myapp" -> "com/example/myapp")
122
- const packagePath = context.packageName.replace(/\./g, '/');
123
-
124
- // Get current year
125
- const year = context.year ?? new Date().getFullYear().toString();
126
-
127
- // Build native C++ config
128
- const nativeCpp: NativeCppConfig | undefined = context.nativeCpp ? {
129
- cppStandard: (context.nativeCpp.cppStandard === 'c++20' ? 'c++20' : 'c++17') as 'c++17' | 'c++20',
130
- ndkVersion: context.nativeCpp.ndkVersion,
131
- stlType: (context.nativeCpp.stlType as NativeCppConfig['stlType']) ?? 'c++_shared',
132
- abiFilters: context.nativeCpp.abiFilters
133
- } : undefined;
134
-
135
- // Build project features from context (features may be at top level or nested)
136
- const featuresObj = context.features as Record<string, unknown> || {};
137
- const features: ProjectFeatures = {
138
- git: typeof featuresObj.git === 'boolean' ? featuresObj.git : true,
139
- readme: typeof featuresObj.readme === 'boolean' ? featuresObj.readme : true,
140
- androidX: typeof featuresObj.androidX === 'boolean' ? featuresObj.androidX : true,
141
- kotlinDsl: typeof featuresObj.kotlinDsl === 'boolean' ? featuresObj.kotlinDsl : true,
142
- adaptiveIcon: typeof featuresObj.adaptiveIcon === 'boolean' ? featuresObj.adaptiveIcon : true,
143
- material3: typeof featuresObj.material3 === 'boolean' ? featuresObj.material3 : true,
144
- viewBinding: typeof featuresObj.viewBinding === 'boolean' ? featuresObj.viewBinding : undefined,
145
- dataBinding: typeof featuresObj.dataBinding === 'boolean' ? featuresObj.dataBinding : undefined,
146
- jetpackCompose: typeof featuresObj.jetpackCompose === 'boolean' ? featuresObj.jetpackCompose : undefined
147
- };
148
-
149
- // Build the complete template context
150
- const templateContext: TemplateContext = {
151
- appName: context.appName,
152
- packageName: context.packageName,
153
- projectDirectory: context.projectDirectory,
154
- template: context.template as TemplateType,
155
- language: context.language,
156
- uiFramework: context.uiFramework as 'xml' | 'compose',
157
- android: {
158
- minSdk: context.android.minSdk,
159
- targetSdk: context.android.targetSdk,
160
- compileSdk: context.android.compileSdk,
161
- buildToolsVersion: context.android.compileSdk > 34 ? '35.0.0' : '34.0.0'
162
- },
163
- gradle: {
164
- agpVersion: context.gradle.agpVersion,
165
- gradleVersion: context.gradle.gradleVersion,
166
- kotlinVersion: context.gradle.kotlinVersion,
167
- composeCompilerVersion: context.gradle.composeCompilerVersion,
168
- composeBomVersion: context.gradle.composeBomVersion
169
- },
170
- appNameSnake,
171
- appNameKebab,
172
- appNamePascal,
173
- appNameCamel,
174
- appNameLower,
175
- packagePath,
176
- year,
177
- generatorVersion: GENERATOR_VERSION,
178
- ...features,
179
- nativeCpp
180
- };
181
-
182
- return templateContext;
183
- }
184
-
185
- /**
186
- * Validate context has all required fields
187
- */
188
- export function validateContext(context: Partial<TemplateContext>): { valid: boolean; errors: string[] } {
189
- const errors: string[] = [];
190
-
191
- if (!context.appName) errors.push('appName is required');
192
- if (!context.packageName) errors.push('packageName is required');
193
- if (!context.projectDirectory) errors.push('projectDirectory is required');
194
- if (!context.template) errors.push('template is required');
195
- if (!context.language) errors.push('language is required');
196
- if (!context.uiFramework) errors.push('uiFramework is required');
197
- if (!context.android) errors.push('android config is required');
198
- if (!context.gradle) errors.push('gradle config is required');
199
-
200
- if (context.android) {
201
- if (!context.android.minSdk) errors.push('android.minSdk is required');
202
- if (!context.android.targetSdk) errors.push('android.targetSdk is required');
203
- if (!context.android.compileSdk) errors.push('android.compileSdk is required');
204
- }
205
-
206
- if (context.gradle) {
207
- if (!context.gradle.agpVersion) errors.push('gradle.agpVersion is required');
208
- if (!context.gradle.gradleVersion) errors.push('gradle.gradleVersion is required');
209
- }
210
-
211
- return { valid: errors.length === 0, errors };
212
- }
package/src/core/types.ts DELETED
@@ -1,184 +0,0 @@
1
- /**
2
- * Core type definitions for the Android project generator
3
- */
4
-
5
- // Language and UI framework types
6
- export type LanguageType = 'kotlin' | 'java';
7
- export type UiFrameworkType = 'xml' | 'compose';
8
- export type TemplateType = 'kotlin-xml' | 'kotlin-compose' | 'java-xml' | 'native-cpp';
9
-
10
- // Android SDK configuration
11
- export interface AndroidSdkConfig {
12
- minSdk: number;
13
- targetSdk: number;
14
- compileSdk: number;
15
- buildToolsVersion?: string;
16
- }
17
-
18
- // Gradle configuration
19
- export interface GradleConfig {
20
- agpVersion: string;
21
- gradleVersion: string;
22
- kotlinVersion?: string;
23
- composeCompilerVersion?: string;
24
- composeBomVersion?: string;
25
- }
26
-
27
- // Project features
28
- export interface ProjectFeatures {
29
- git: boolean;
30
- readme: boolean;
31
- androidX: boolean;
32
- kotlinDsl: boolean;
33
- adaptiveIcon: boolean;
34
- material3: boolean;
35
- viewBinding?: boolean;
36
- dataBinding?: boolean;
37
- jetpackCompose?: boolean;
38
- }
39
-
40
- // Native C++ configuration
41
- export interface NativeCppConfig {
42
- cppStandard: 'c++17' | 'c++20';
43
- ndkVersion?: string;
44
- stlType?: 'c++_shared' | 'c++_static' | 'none' | 'system';
45
- abiFilters?: string[];
46
- }
47
-
48
- // Template context for project generation
49
- export interface TemplateContext extends ProjectFeatures {
50
- // Basic info
51
- appName: string;
52
- packageName: string;
53
- projectDirectory: string;
54
- template: TemplateType;
55
-
56
- // Derived info
57
- language: LanguageType;
58
- uiFramework: UiFrameworkType;
59
-
60
- // SDK and Gradle config
61
- android: AndroidSdkConfig;
62
- gradle: GradleConfig;
63
-
64
- // Transformed names
65
- appNameSnake: string;
66
- appNameKebab: string;
67
- appNamePascal: string;
68
- appNameCamel: string;
69
- appNameLower: string;
70
-
71
- // Package path (e.g., "com/example/myapp")
72
- packagePath: string;
73
-
74
- // Date and version info
75
- year: string;
76
- generatorVersion: string;
77
-
78
- // Native C++ config (optional)
79
- nativeCpp?: NativeCppConfig;
80
- }
81
-
82
- // Generation options
83
- export interface GenerationOptions {
84
- overwrite: boolean;
85
- skipInstall: boolean;
86
- dryRun: boolean;
87
- verbose: boolean;
88
- }
89
-
90
- // Generation result
91
- export interface GenerationResult {
92
- success: boolean;
93
- projectPath: string;
94
- generatedFiles: string[];
95
- skippedFiles: string[];
96
- errors: Array<{
97
- file?: string;
98
- message: string;
99
- code?: string;
100
- }>;
101
- warnings: string[];
102
- duration: number;
103
- }
104
-
105
- // File to be generated
106
- export interface GeneratedFile {
107
- path: string;
108
- content: string;
109
- overwrite?: boolean;
110
- }
111
-
112
- // Validation result
113
- export interface ValidationResult {
114
- valid: boolean;
115
- errors: string[];
116
- warnings: string[];
117
- }
118
-
119
- // Directory structure definition
120
- export interface DirectorySpec {
121
- path: string;
122
- description?: string;
123
- }
124
-
125
- // Template metadata
126
- export interface TemplateMetadata {
127
- id: TemplateType;
128
- name: string;
129
- description: string;
130
- keywords: string[];
131
- features: string[];
132
- language: LanguageType;
133
- uiFramework: UiFrameworkType;
134
- codePreview?: string;
135
- }
136
-
137
- // CLI command options
138
- export interface NewCommandOptions {
139
- name?: string;
140
- template?: string;
141
- packageName?: string;
142
- directory?: string;
143
- minSdk?: number;
144
- targetSdk?: number;
145
- force?: boolean;
146
- skipInstall?: boolean;
147
- git?: boolean;
148
- kotlin?: boolean;
149
- verbose?: boolean;
150
- }
151
-
152
- export interface InitCommandOptions {
153
- force: boolean;
154
- template?: string;
155
- }
156
-
157
- export interface InfoCommandOptions {
158
- template?: string;
159
- json: boolean;
160
- }
161
-
162
- export interface ListCommandOptions {
163
- json: boolean;
164
- }
165
-
166
- // Default options
167
- export const DEFAULT_GENERATION_OPTIONS: GenerationOptions = {
168
- overwrite: false,
169
- skipInstall: false,
170
- dryRun: false,
171
- verbose: false
172
- };
173
-
174
- export const DEFAULT_PROJECT_FEATURES: ProjectFeatures = {
175
- git: true,
176
- readme: true,
177
- androidX: true,
178
- kotlinDsl: true,
179
- adaptiveIcon: true,
180
- material3: true,
181
- viewBinding: true,
182
- dataBinding: false,
183
- jetpackCompose: false
184
- };