fix: expand brownfield project detection to cover Android, Kotlin, Gradle, and 15+ additional ecosystems
The code/package detection in cmdInitNewProject only recognized 7 file extensions and 5 package files, missing Android (Kotlin + Gradle), Flutter (Dart + pubspec.yaml), C/C++, C#, Ruby, PHP, Scala, and others. This caused new-project to treat brownfield projects in those ecosystems as greenfield, skipping the codebase mapping step. Added 18 code extensions and 11 package/build files to the detection lists. Fixes #1325 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1022,6 +1022,88 @@ describe('cmdInitNewProject', () => {
|
||||
const output = JSON.parse(result.output);
|
||||
assert.strictEqual(output.planning_exists, true);
|
||||
});
|
||||
|
||||
test('brownfield with Kotlin files detected (Android project)', () => {
|
||||
const srcDir = path.join(tmpDir, 'app', 'src', 'main');
|
||||
fs.mkdirSync(srcDir, { recursive: true });
|
||||
fs.writeFileSync(path.join(srcDir, 'MainActivity.kt'), 'class MainActivity');
|
||||
|
||||
const result = runGsdTools('init new-project', tmpDir);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
|
||||
const output = JSON.parse(result.output);
|
||||
assert.strictEqual(output.has_existing_code, true);
|
||||
assert.strictEqual(output.is_brownfield, true);
|
||||
});
|
||||
|
||||
test('brownfield with build.gradle detected (Android/Gradle project)', () => {
|
||||
fs.writeFileSync(path.join(tmpDir, 'build.gradle'), 'apply plugin: "com.android.application"');
|
||||
|
||||
const result = runGsdTools('init new-project', tmpDir);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
|
||||
const output = JSON.parse(result.output);
|
||||
assert.strictEqual(output.has_package_file, true);
|
||||
assert.strictEqual(output.is_brownfield, true);
|
||||
assert.strictEqual(output.needs_codebase_map, true);
|
||||
});
|
||||
|
||||
test('brownfield with build.gradle.kts detected (Kotlin DSL)', () => {
|
||||
fs.writeFileSync(path.join(tmpDir, 'build.gradle.kts'), 'plugins { id("com.android.application") }');
|
||||
|
||||
const result = runGsdTools('init new-project', tmpDir);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
|
||||
const output = JSON.parse(result.output);
|
||||
assert.strictEqual(output.has_package_file, true);
|
||||
assert.strictEqual(output.is_brownfield, true);
|
||||
});
|
||||
|
||||
test('brownfield with pom.xml detected (Maven project)', () => {
|
||||
fs.writeFileSync(path.join(tmpDir, 'pom.xml'), '<project></project>');
|
||||
|
||||
const result = runGsdTools('init new-project', tmpDir);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
|
||||
const output = JSON.parse(result.output);
|
||||
assert.strictEqual(output.has_package_file, true);
|
||||
assert.strictEqual(output.is_brownfield, true);
|
||||
});
|
||||
|
||||
test('brownfield with pubspec.yaml detected (Flutter/Dart project)', () => {
|
||||
fs.writeFileSync(path.join(tmpDir, 'pubspec.yaml'), 'name: my_app');
|
||||
|
||||
const result = runGsdTools('init new-project', tmpDir);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
|
||||
const output = JSON.parse(result.output);
|
||||
assert.strictEqual(output.has_package_file, true);
|
||||
assert.strictEqual(output.is_brownfield, true);
|
||||
});
|
||||
|
||||
test('brownfield with Dart files detected', () => {
|
||||
const libDir = path.join(tmpDir, 'lib');
|
||||
fs.mkdirSync(libDir, { recursive: true });
|
||||
fs.writeFileSync(path.join(libDir, 'main.dart'), 'void main() {}');
|
||||
|
||||
const result = runGsdTools('init new-project', tmpDir);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
|
||||
const output = JSON.parse(result.output);
|
||||
assert.strictEqual(output.has_existing_code, true);
|
||||
assert.strictEqual(output.is_brownfield, true);
|
||||
});
|
||||
|
||||
test('brownfield with C++ files detected', () => {
|
||||
fs.writeFileSync(path.join(tmpDir, 'main.cpp'), 'int main() { return 0; }');
|
||||
|
||||
const result = runGsdTools('init new-project', tmpDir);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
|
||||
const output = JSON.parse(result.output);
|
||||
assert.strictEqual(output.has_existing_code, true);
|
||||
assert.strictEqual(output.is_brownfield, true);
|
||||
});
|
||||
});
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user