tycono 0.1.85 → 0.1.87
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/routes/save.ts +2 -2
- package/src/api/src/services/company-config.ts +18 -19
- package/src/web/dist/assets/{index-CTm8Yl0c.js → index-LekO2AHi.js} +27 -27
- package/src/web/dist/assets/{preview-app-BbdOsoe0.js → preview-app-COzv8nuC.js} +1 -1
- package/src/web/dist/index.html +1 -1
package/package.json
CHANGED
|
@@ -51,9 +51,9 @@ saveRouter.get('/history', (req: Request, res: Response, next: NextFunction) =>
|
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
// POST /api/save/init — initialize git repo
|
|
54
|
-
saveRouter.post('/init', (
|
|
54
|
+
saveRouter.post('/init', (req: Request, res: Response, next: NextFunction) => {
|
|
55
55
|
try {
|
|
56
|
-
const result = gitInit(COMPANY_ROOT);
|
|
56
|
+
const result = gitInit(COMPANY_ROOT, getRepo(req));
|
|
57
57
|
if (!result.ok) {
|
|
58
58
|
res.status(500).json({ error: result.message });
|
|
59
59
|
return;
|
|
@@ -52,29 +52,28 @@ function configPath(companyRoot: string): string {
|
|
|
52
52
|
*/
|
|
53
53
|
export function resolveCodeRoot(companyRoot: string): string {
|
|
54
54
|
const config = readConfig(companyRoot);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (
|
|
55
|
+
const codeRoot = config.codeRoot ?? (() => {
|
|
56
|
+
// Auto-generate: ../{folder-name}-code/
|
|
57
|
+
const dirName = path.basename(companyRoot);
|
|
58
|
+
const auto = path.join(path.dirname(companyRoot), `${dirName}-code`);
|
|
59
|
+
if (!fs.existsSync(auto)) {
|
|
60
|
+
fs.mkdirSync(auto, { recursive: true });
|
|
61
|
+
}
|
|
62
|
+
// Persist so it's stable across restarts
|
|
63
|
+
writeConfig(companyRoot, { ...config, codeRoot: auto });
|
|
64
|
+
return auto;
|
|
65
|
+
})();
|
|
66
|
+
|
|
67
|
+
// Auto-init git if not already a repo (even if codeRoot was already configured)
|
|
68
|
+
const gitDir = path.join(codeRoot, '.git');
|
|
69
|
+
if (fs.existsSync(codeRoot) && !fs.existsSync(gitDir)) {
|
|
68
70
|
try {
|
|
69
|
-
execSync('git init', { cwd:
|
|
70
|
-
execSync('git commit --allow-empty -m "Initial commit by Tycono"', { cwd:
|
|
71
|
+
execSync('git init', { cwd: codeRoot, stdio: 'pipe' });
|
|
72
|
+
execSync('git commit --allow-empty -m "Initial commit by Tycono"', { cwd: codeRoot, stdio: 'pipe' });
|
|
71
73
|
} catch { /* ignore — git may not be installed */ }
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
|
|
75
|
-
writeConfig(companyRoot, { ...config, codeRoot: autoCodeRoot });
|
|
76
|
-
|
|
77
|
-
return autoCodeRoot;
|
|
76
|
+
return codeRoot;
|
|
78
77
|
}
|
|
79
78
|
|
|
80
79
|
/** Read config from .tycono/config.json. Returns defaults if missing. */
|