tycono 0.1.82 → 0.1.83
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.
- package/package.json +1 -1
- package/src/api/src/services/company-config.ts +10 -0
- package/src/api/src/services/git-save.ts +24 -13
- package/src/api/src/services/scaffold.ts +10 -0
- package/src/web/dist/assets/{index-D8WK-f75.js → index-BOH9XJbW.js} +24 -24
- package/src/web/dist/assets/{preview-app-Cu2HapST.js → preview-app-DbMjPbJZ.js} +1 -1
- package/src/web/dist/index.html +1 -1
- package/templates/teams/startup.json +1 -1
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* AKB 디렉토리의 영구 설정을 읽고 쓴다.
|
|
5
5
|
* scaffold 시 생성되고, 서버 시작 시 로드된다.
|
|
6
6
|
*/
|
|
7
|
+
import { execSync } from 'node:child_process';
|
|
7
8
|
import fs from 'node:fs';
|
|
8
9
|
import path from 'node:path';
|
|
9
10
|
|
|
@@ -61,6 +62,15 @@ export function resolveCodeRoot(companyRoot: string): string {
|
|
|
61
62
|
fs.mkdirSync(autoCodeRoot, { recursive: true });
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
// Auto-init git if not already a repo
|
|
66
|
+
const gitDir = path.join(autoCodeRoot, '.git');
|
|
67
|
+
if (!fs.existsSync(gitDir)) {
|
|
68
|
+
try {
|
|
69
|
+
execSync('git init', { cwd: autoCodeRoot, stdio: 'pipe' });
|
|
70
|
+
execSync('git commit --allow-empty -m "Initial commit by Tycono"', { cwd: autoCodeRoot, stdio: 'pipe' });
|
|
71
|
+
} catch { /* ignore — git may not be installed */ }
|
|
72
|
+
}
|
|
73
|
+
|
|
64
74
|
// Persist so it's stable across restarts
|
|
65
75
|
writeConfig(companyRoot, { ...config, codeRoot: autoCodeRoot });
|
|
66
76
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { execSync } from 'node:child_process';
|
|
17
17
|
import { readFileSync } from 'node:fs';
|
|
18
|
-
import { join } from 'node:path';
|
|
18
|
+
import { join, resolve } from 'node:path';
|
|
19
19
|
import { resolveCodeRoot } from './company-config.js';
|
|
20
20
|
|
|
21
21
|
export type RepoType = 'akb' | 'code';
|
|
@@ -132,11 +132,18 @@ function isGitAvailable(): boolean {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
/** Check if directory is a git repository */
|
|
135
|
+
/** Check if directory is (or is inside) a git repository */
|
|
136
136
|
function isGitRepo(root: string): boolean {
|
|
137
137
|
return run('git rev-parse --is-inside-work-tree', root) === 'true';
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
/** Check if directory is the root of its own git repository (has .git here) */
|
|
141
|
+
function isGitRoot(root: string): boolean {
|
|
142
|
+
const toplevel = run('git rev-parse --show-toplevel', root);
|
|
143
|
+
if (!toplevel) return false;
|
|
144
|
+
return resolve(toplevel) === resolve(root);
|
|
145
|
+
}
|
|
146
|
+
|
|
140
147
|
/**
|
|
141
148
|
* Initialize a new git repository
|
|
142
149
|
* @param root - AKB repository root (COMPANY_ROOT)
|
|
@@ -149,7 +156,7 @@ export function gitInit(root: string, repo: RepoType = 'akb'): { ok: boolean; me
|
|
|
149
156
|
|
|
150
157
|
const repoRoot = resolveRepoRoot(root, repo);
|
|
151
158
|
|
|
152
|
-
if (
|
|
159
|
+
if (isGitRoot(repoRoot)) {
|
|
153
160
|
return { ok: true, message: 'Already a git repository' };
|
|
154
161
|
}
|
|
155
162
|
try {
|
|
@@ -170,7 +177,7 @@ export function gitInit(root: string, repo: RepoType = 'akb'): { ok: boolean; me
|
|
|
170
177
|
export function getGitStatus(root: string, repo: RepoType = 'akb'): GitStatus {
|
|
171
178
|
const repoRoot = resolveRepoRoot(root, repo);
|
|
172
179
|
|
|
173
|
-
if (!
|
|
180
|
+
if (!isGitRoot(repoRoot)) {
|
|
174
181
|
return {
|
|
175
182
|
dirty: false,
|
|
176
183
|
modified: [],
|
|
@@ -244,7 +251,7 @@ export function getGitStatus(root: string, repo: RepoType = 'akb'): GitStatus {
|
|
|
244
251
|
export function gitSave(root: string, message?: string, repo: RepoType = 'akb'): SaveResult {
|
|
245
252
|
const repoRoot = resolveRepoRoot(root, repo);
|
|
246
253
|
|
|
247
|
-
if (!
|
|
254
|
+
if (!isGitRoot(repoRoot)) {
|
|
248
255
|
throw new Error('Not a git repository. Run "git init" first.');
|
|
249
256
|
}
|
|
250
257
|
|
|
@@ -297,7 +304,7 @@ export function gitSave(root: string, message?: string, repo: RepoType = 'akb'):
|
|
|
297
304
|
export function gitHistory(root: string, limit = 20, repo: RepoType = 'akb'): CommitInfo[] {
|
|
298
305
|
const repoRoot = resolveRepoRoot(root, repo);
|
|
299
306
|
|
|
300
|
-
if (!
|
|
307
|
+
if (!isGitRoot(repoRoot)) return [];
|
|
301
308
|
|
|
302
309
|
const log = run(`git log --format=%H%n%h%n%s%n%aI -n ${limit}`, repoRoot);
|
|
303
310
|
if (!log) return [];
|
|
@@ -327,7 +334,7 @@ export function gitHistory(root: string, limit = 20, repo: RepoType = 'akb'): Co
|
|
|
327
334
|
export function gitRestore(root: string, sha: string, paths?: string[], repo: RepoType = 'akb'): RestoreResult {
|
|
328
335
|
const repoRoot = resolveRepoRoot(root, repo);
|
|
329
336
|
|
|
330
|
-
if (!
|
|
337
|
+
if (!isGitRoot(repoRoot)) {
|
|
331
338
|
throw new Error('Not a git repository');
|
|
332
339
|
}
|
|
333
340
|
|
|
@@ -366,7 +373,7 @@ export function gitRestore(root: string, sha: string, paths?: string[], repo: Re
|
|
|
366
373
|
export function gitFetchStatus(root: string, repo: RepoType = 'akb'): SyncStatus {
|
|
367
374
|
const repoRoot = resolveRepoRoot(root, repo);
|
|
368
375
|
|
|
369
|
-
if (!
|
|
376
|
+
if (!isGitRoot(repoRoot)) {
|
|
370
377
|
return { ahead: 0, behind: 0, branch: '', remote: '', hasRemote: false };
|
|
371
378
|
}
|
|
372
379
|
|
|
@@ -406,7 +413,7 @@ export function gitFetchStatus(root: string, repo: RepoType = 'akb'): SyncStatus
|
|
|
406
413
|
export function gitPull(root: string, repo: RepoType = 'akb'): PullResult {
|
|
407
414
|
const repoRoot = resolveRepoRoot(root, repo);
|
|
408
415
|
|
|
409
|
-
if (!
|
|
416
|
+
if (!isGitRoot(repoRoot)) {
|
|
410
417
|
return { status: 'error', message: 'Not a git repository' };
|
|
411
418
|
}
|
|
412
419
|
|
|
@@ -517,7 +524,7 @@ export function githubStatus(root: string, repo: RepoType = 'akb'): GitHubStatus
|
|
|
517
524
|
let remoteUrl: string | undefined;
|
|
518
525
|
try {
|
|
519
526
|
const repoRoot = resolveRepoRoot(root, repo);
|
|
520
|
-
if (
|
|
527
|
+
if (isGitRoot(repoRoot)) {
|
|
521
528
|
remoteUrl = run('git remote get-url origin', repoRoot) || undefined;
|
|
522
529
|
hasRemote = !!remoteUrl;
|
|
523
530
|
}
|
|
@@ -539,8 +546,12 @@ export function githubCreateRepo(
|
|
|
539
546
|
): GitHubCreateResult {
|
|
540
547
|
const repoRoot = resolveRepoRoot(root, repo);
|
|
541
548
|
|
|
542
|
-
if (
|
|
543
|
-
|
|
549
|
+
// Auto-init git if not a proper git root (e.g. fresh init, or nested inside parent repo)
|
|
550
|
+
if (!isGitRoot(repoRoot)) {
|
|
551
|
+
const initResult = gitInit(root, repo);
|
|
552
|
+
if (!initResult.ok) {
|
|
553
|
+
return { ok: false, message: initResult.message };
|
|
554
|
+
}
|
|
544
555
|
}
|
|
545
556
|
|
|
546
557
|
// Check gh + auth
|
|
@@ -585,7 +596,7 @@ export function githubCreateRepo(
|
|
|
585
596
|
export function gitAddRemote(root: string, url: string, repo: RepoType = 'akb'): { ok: boolean; message: string } {
|
|
586
597
|
const repoRoot = resolveRepoRoot(root, repo);
|
|
587
598
|
|
|
588
|
-
if (!
|
|
599
|
+
if (!isGitRoot(repoRoot)) {
|
|
589
600
|
return { ok: false, message: 'Not a git repository' };
|
|
590
601
|
}
|
|
591
602
|
|
|
@@ -449,6 +449,16 @@ export function scaffold(config: ScaffoldConfig): string[] {
|
|
|
449
449
|
fs.writeFileSync(knowledgeMd, content);
|
|
450
450
|
}
|
|
451
451
|
|
|
452
|
+
// Auto-init git for AKB
|
|
453
|
+
const gitDir = path.join(root, '.git');
|
|
454
|
+
if (!fs.existsSync(gitDir)) {
|
|
455
|
+
try {
|
|
456
|
+
execSync('git init', { cwd: root, stdio: 'pipe' });
|
|
457
|
+
execSync('git add -A', { cwd: root, stdio: 'pipe' });
|
|
458
|
+
execSync('git commit -m "Initial commit by Tycono"', { cwd: root, stdio: 'pipe' });
|
|
459
|
+
} catch { /* ignore — git may not be installed */ }
|
|
460
|
+
}
|
|
461
|
+
|
|
452
462
|
return created;
|
|
453
463
|
}
|
|
454
464
|
|