Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/atxp/src/create-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,14 @@ async function cloneTemplate(template: string, projectPath: string): Promise<voi
return new Promise((resolve, reject) => {
console.log(chalk.blue('Downloading template from GitHub...'));

const git = spawn('git', ['clone', templateConfig.url, projectPath], {
const git = spawn('git', [
'clone',
'--depth', '1', // Shallow clone - only latest commit
'--single-branch', // Only clone the default branch
'--branch', 'main', // Explicitly target main branch
templateConfig.url,
projectPath
], {
stdio: 'inherit'
});

Expand Down
53 changes: 53 additions & 0 deletions packages/atxp/src/git-optimization.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { describe, it, expect } from 'vitest';

describe('Git optimization', () => {
it('should use shallow clone parameters for demo repository', () => {
// This test documents the expected git clone parameters for optimal performance
const expectedCloneArgs = [
'clone',
'--depth', '1', // Shallow clone - only latest commit
'--single-branch', // Only clone the default branch
'--branch', 'main', // Explicitly target main branch
'DEMO_REPO_URL',
'demoDir'
];

expect(expectedCloneArgs).toContain('--depth');
expect(expectedCloneArgs).toContain('1');
expect(expectedCloneArgs).toContain('--single-branch');
expect(expectedCloneArgs).toContain('--branch');
expect(expectedCloneArgs).toContain('main');
});

it('should use shallow clone parameters for project templates', () => {
// This test documents the expected git clone parameters for project creation
const expectedCloneArgs = [
'clone',
'--depth', '1', // Shallow clone - only latest commit
'--single-branch', // Only clone the default branch
'--branch', 'main', // Explicitly target main branch
'templateUrl',
'projectPath'
];

expect(expectedCloneArgs).toContain('--depth');
expect(expectedCloneArgs).toContain('1');
expect(expectedCloneArgs).toContain('--single-branch');
expect(expectedCloneArgs).toContain('--branch');
expect(expectedCloneArgs).toContain('main');
});

it('should use optimized pull parameters for demo updates', () => {
// This test documents the expected git pull parameters for updates
const expectedPullArgs = [
'pull',
'--depth', '1', // Keep shallow history during pull
'origin', 'main' // Explicitly pull from main branch
];

expect(expectedPullArgs).toContain('--depth');
expect(expectedPullArgs).toContain('1');
expect(expectedPullArgs).toContain('origin');
expect(expectedPullArgs).toContain('main');
});
});
15 changes: 13 additions & 2 deletions packages/atxp/src/run-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ export async function runDemo(options: DemoOptions): Promise<void> {

async function cloneDemoRepo(demoDir: string, isVerbose: boolean): Promise<void> {
return new Promise((resolve, reject) => {
const git = spawn('git', ['clone', DEMO_REPO_URL, demoDir], {
const git = spawn('git', [
'clone',
'--depth', '1', // Shallow clone - only latest commit
'--single-branch', // Only clone the default branch
'--branch', 'main', // Explicitly target main branch
DEMO_REPO_URL,
demoDir
], {
stdio: isVerbose ? 'inherit' : 'pipe'
});

Expand All @@ -64,7 +71,11 @@ async function cloneDemoRepo(demoDir: string, isVerbose: boolean): Promise<void>

async function updateDemoRepo(demoDir: string, isVerbose: boolean): Promise<void> {
return new Promise((resolve, _reject) => {
const git = spawn('git', ['pull'], {
const git = spawn('git', [
'pull',
'--depth', '1', // Keep shallow history during pull
'origin', 'main' // Explicitly pull from main branch
], {
cwd: demoDir,
stdio: isVerbose ? 'inherit' : 'pipe'
});
Expand Down