@clazic/urban 0.2.20 → 0.2.21

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clazic/urban",
3
- "version": "0.2.20",
3
+ "version": "0.2.21",
4
4
  "description": "도시계획연구 보고서 자동 수집·지식베이스 데몬",
5
5
  "type": "module",
6
6
  "engines": {
@@ -1,21 +1,15 @@
1
1
  #!/usr/bin/env node
2
- // postinstall: graphify 설치 → urban 자동 설정 → 데몬 등록 + 시작
2
+ // postinstall: urban 자동 설정 → poppler 설치 → 데몬 등록 + 시작
3
3
  // 모든 단계는 실패해도 설치 자체를 중단하지 않음 (exit 0 보장)
4
4
  import { existsSync, mkdirSync, writeFileSync } from 'fs';
5
5
  import { homedir } from 'os';
6
- import { join, dirname } from 'path';
7
- import { fileURLToPath } from 'url';
8
-
9
- const __dirname = dirname(fileURLToPath(import.meta.url));
6
+ import { join } from 'path';
10
7
 
11
8
  try {
12
- // ── 1. graphify 설치 (선택 기능, 실패 무시) ─────────────────────────────────
13
- await import('./setup-graphify.js').catch(() => {});
14
-
15
- // ── 2. poppler 설치 (Windows, 선택 기능, 실패 무시) ───────────────────────────
9
+ // ── 1. poppler 설치 (Windows, 선택 기능, 실패 무시) ───────────────────────────
16
10
  await import('./setup-poppler.js').catch(() => {});
17
11
 
18
- // ── 3. urban 자동 설정 (기본값으로 .env 생성) ─────────────────────────────────
12
+ // ── 2. urban 자동 설정 (기본값으로 .env 생성) ─────────────────────────────────
19
13
  const URBAN_HOME = process.env.URBAN_HOME ?? join(homedir(), '.urban');
20
14
  const URBAN_PORT = process.env.URBAN_PORT ?? '7777';
21
15
 
@@ -35,7 +29,7 @@ try {
35
29
  console.log(`[urban] 설정 파일 이미 존재: ${envPath}`);
36
30
  }
37
31
 
38
- // ── 4. 데몬 등록 + 시작 ───────────────────────────────────────────────────────
32
+ // ── 3. 데몬 등록 + 시작 ───────────────────────────────────────────────────────
39
33
  try {
40
34
  const { installDaemon, startDaemon } = await import('../src/install/daemon.js');
41
35
  const installResult = await installDaemon();
@@ -1,107 +0,0 @@
1
- #!/usr/bin/env node
2
- // postinstall: uv 설치 확인 → graphifyy 가상환경 구성 + 터미널용 symlink 생성
3
- import { execSync, spawnSync } from 'child_process';
4
- import { existsSync, mkdirSync, symlinkSync, unlinkSync, writeFileSync } from 'fs';
5
- import { homedir } from 'os';
6
- import { join } from 'path';
7
-
8
- const isWin = process.platform === 'win32';
9
- const PYTHON_VERSION = '3.12';
10
- const uvEnvDir = join(homedir(), '.urban', '.venv');
11
- const pythonBin = join(uvEnvDir, isWin ? 'Scripts/python.exe' : 'bin/python');
12
- const graphifyBin = join(uvEnvDir, isWin ? 'Scripts/graphify.exe' : 'bin/graphify');
13
- const localBin = join(homedir(), '.local', 'bin');
14
- const symlinkTarget = join(localBin, isWin ? 'graphify.cmd' : 'graphify');
15
-
16
- function findUv() {
17
- try { execSync(isWin ? 'where uv' : 'which uv', { stdio: 'ignore' }); return 'uv'; } catch {}
18
- const candidates = isWin
19
- ? [join(homedir(), '.local', 'bin', 'uv.exe'), join(homedir(), '.cargo', 'bin', 'uv.exe')]
20
- : [join(homedir(), '.local', 'bin', 'uv'), join(homedir(), '.cargo', 'bin', 'uv')];
21
- return candidates.find(p => existsSync(p)) ?? null;
22
- }
23
-
24
- function installUv() {
25
- console.log('[urban] uv 설치 중...');
26
- if (isWin) {
27
- execSync('powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"', { stdio: 'inherit' });
28
- } else {
29
- execSync('curl -LsSf https://astral.sh/uv/install.sh | sh', { stdio: 'inherit' });
30
- }
31
- return findUv();
32
- }
33
-
34
- // uv 자체 관리 Python 경로 반환 (없으면 자동 설치)
35
- function ensureUvPython(uv) {
36
- console.log(`[urban] uv Python ${PYTHON_VERSION} 준비 중...`);
37
- spawnSync(uv, ['python', 'install', PYTHON_VERSION], { stdio: 'inherit', shell: isWin });
38
- const result = spawnSync(uv, ['python', 'find', PYTHON_VERSION], { stdio: 'pipe', shell: isWin, encoding: 'utf8' });
39
- const path = result.stdout?.trim();
40
- if (!path) throw new Error(`uv python find ${PYTHON_VERSION} 실패`);
41
- console.log(`[urban] uv Python 경로: ${path}`);
42
- return path;
43
- }
44
-
45
- function run(cmd, args, opts = {}) {
46
- const r = spawnSync(cmd, args, { stdio: 'inherit', shell: isWin, ...opts });
47
- if (r.status !== 0) throw new Error(`${cmd} ${args.join(' ')} 실패 (exit ${r.status})`);
48
- }
49
-
50
- // 터미널 어디서나 실행 가능하도록 symlink(Unix) 또는 .cmd 래퍼(Windows) 생성
51
- function createSymlink() {
52
- mkdirSync(localBin, { recursive: true });
53
-
54
- if (isWin) {
55
- const wrapper = `@echo off\n"${graphifyBin}" %*\n`;
56
- writeFileSync(symlinkTarget, wrapper);
57
- console.log('[urban] graphify 래퍼 생성 →', symlinkTarget);
58
- } else {
59
- try { unlinkSync(symlinkTarget); } catch {}
60
- symlinkSync(graphifyBin, symlinkTarget);
61
- console.log('[urban] graphify symlink 생성 →', symlinkTarget);
62
- }
63
-
64
- // ~/.local/bin 이 PATH에 없으면 안내
65
- const pathDirs = (process.env.PATH ?? '').split(isWin ? ';' : ':');
66
- if (!pathDirs.includes(localBin)) {
67
- console.warn(`[urban] ⚠️ ${localBin} 이 PATH에 없습니다.`);
68
- if (isWin) {
69
- console.warn(` setx PATH "%PATH%;${localBin}"`);
70
- } else {
71
- const rc = process.env.SHELL?.includes('zsh') ? '~/.zshrc' : '~/.bashrc';
72
- console.warn(` ${rc} 에 추가: export PATH="$HOME/.local/bin:$PATH"`);
73
- }
74
- }
75
- }
76
-
77
- if (process.env.URBAN_SKIP_GRAPHIFY === '1') {
78
- console.log('[urban] URBAN_SKIP_GRAPHIFY=1 — graphify 설치 건너뜀');
79
- process.exit(0);
80
- }
81
-
82
- try {
83
- let uv = findUv();
84
- if (!uv) uv = installUv();
85
- if (!uv) throw new Error('uv 설치 실패 — https://docs.astral.sh/uv/getting-started/installation 참고');
86
-
87
- if (existsSync(pythonBin)) {
88
- console.log('[urban] graphify 환경이 이미 존재합니다:', uvEnvDir);
89
- createSymlink();
90
- process.exit(0);
91
- }
92
-
93
- // uv 자체 관리 Python 사용 (Homebrew·시스템 Python 무시)
94
- const uvPython = ensureUvPython(uv);
95
-
96
- console.log('[urban] graphify 가상환경 생성 중...');
97
- run(uv, ['venv', uvEnvDir, '--python', uvPython]);
98
-
99
- console.log('[urban] graphifyy 설치 중...');
100
- run(uv, ['pip', 'install', '--python', pythonBin, 'graphifyy']);
101
-
102
- console.log('[urban] graphify 설치 완료 →', uvEnvDir);
103
- createSymlink();
104
- } catch (err) {
105
- console.warn('[urban] graphify 설치 실패 (선택 기능이므로 계속):', err.message);
106
- process.exit(0);
107
- }