@xfilecom/xframe 0.1.35 → 0.1.36
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/bin/xframe.js +12 -10
- package/defaults.json +2 -2
- package/package.json +1 -1
- package/template/apps/api/src/main.ts +53 -13
- package/template/web/admin/tsconfig.json +1 -2
- package/template/web/admin/vite.config.ts +0 -7
- package/template/web/client/tsconfig.json +1 -2
- package/template/web/client/vite.config.ts +0 -7
- package/template/web/shared/README.md +4 -5
package/bin/xframe.js
CHANGED
|
@@ -442,10 +442,9 @@ function executeDbPull(cwd) {
|
|
|
442
442
|
return false;
|
|
443
443
|
}
|
|
444
444
|
|
|
445
|
-
/**
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
445
|
+
/**
|
|
446
|
+
* 구 스캐폴드 tsconfig 의 paths.@xfilecom/front-core 제거 → 설치된 패키지(node_modules) 기준 해석.
|
|
447
|
+
*/
|
|
449
448
|
function patchWebTsconfigFrontCorePath(targetRoot) {
|
|
450
449
|
for (const sub of ['client', 'admin']) {
|
|
451
450
|
const p = path.join(targetRoot, 'web', sub, 'tsconfig.json');
|
|
@@ -456,17 +455,20 @@ function patchWebTsconfigFrontCorePath(targetRoot) {
|
|
|
456
455
|
} catch {
|
|
457
456
|
continue;
|
|
458
457
|
}
|
|
459
|
-
const
|
|
460
|
-
if (
|
|
461
|
-
|
|
462
|
-
|
|
458
|
+
const paths = j?.compilerOptions?.paths;
|
|
459
|
+
if (!paths || !Object.prototype.hasOwnProperty.call(paths, '@xfilecom/front-core')) {
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
delete paths['@xfilecom/front-core'];
|
|
463
|
+
if (Object.keys(paths).length === 0) {
|
|
464
|
+
delete j.compilerOptions.paths;
|
|
463
465
|
}
|
|
466
|
+
fs.writeFileSync(p, `${JSON.stringify(j, null, 2)}\n`, 'utf8');
|
|
464
467
|
}
|
|
465
468
|
}
|
|
466
469
|
|
|
467
470
|
/**
|
|
468
|
-
* Vite
|
|
469
|
-
* `tokens.css` 같은 서브패스가 exports 를 타지 못해 깨짐 → alias 제거 후 npm 기본 해석.
|
|
471
|
+
* 구 템플릿 Vite 의 @xfilecom/front-core → 소스 디렉터리 alias 제거(npm 패키지·exports 사용).
|
|
470
472
|
*/
|
|
471
473
|
function patchWebViteFrontCoreAlias(targetRoot) {
|
|
472
474
|
for (const sub of ['client', 'admin']) {
|
package/defaults.json
CHANGED
package/package.json
CHANGED
|
@@ -5,7 +5,21 @@ import type { INestApplication } from '@nestjs/common';
|
|
|
5
5
|
import { AppModule } from './app.module';
|
|
6
6
|
import { appConfig } from './config.loader';
|
|
7
7
|
|
|
8
|
-
function
|
|
8
|
+
function parsePositivePort(v: string | number | undefined): number | undefined {
|
|
9
|
+
const n = typeof v === 'number' ? v : Number(v);
|
|
10
|
+
return Number.isFinite(n) && n > 0 ? n : undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** `PORT`(syncEnvKeys) → `server.port`(YAML) → 기본값 */
|
|
14
|
+
function resolveListenPort(): number {
|
|
15
|
+
return (
|
|
16
|
+
parsePositivePort(process.env.PORT) ??
|
|
17
|
+
parsePositivePort(appConfig.server?.port) ??
|
|
18
|
+
3000
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function applyCorsFromConfig(app: INestApplication): void {
|
|
9
23
|
const cors = appConfig.cors;
|
|
10
24
|
if (cors?.enabled === false) {
|
|
11
25
|
return;
|
|
@@ -19,26 +33,52 @@ function applyCors(app: INestApplication): void {
|
|
|
19
33
|
app.enableCors({ origin: origin === true, credentials });
|
|
20
34
|
}
|
|
21
35
|
|
|
22
|
-
function
|
|
36
|
+
function applyHttpFromConfig(app: INestApplication): void {
|
|
23
37
|
const prefix = appConfig.http?.globalPrefix;
|
|
24
38
|
if (prefix != null && String(prefix).trim() !== '') {
|
|
25
39
|
app.setGlobalPrefix(String(prefix).replace(/^\/+|\/+$/g, ''));
|
|
26
40
|
}
|
|
27
41
|
}
|
|
28
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Nest 인스턴스에 직접 걸 수 있는 설정만 반영합니다.
|
|
45
|
+
* - DB 연결·JWT·인터셉터 등: `config.loader`의 syncEnvKeys + `AppModule`(CoreModule)
|
|
46
|
+
*/
|
|
47
|
+
function applyNestAppFromConfig(app: INestApplication): void {
|
|
48
|
+
applyCorsFromConfig(app);
|
|
49
|
+
applyHttpFromConfig(app);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function logStartupFromConfig(port: number): void {
|
|
53
|
+
const base = appConfig.http?.publicBaseUrl?.replace(/\/$/, '');
|
|
54
|
+
const pfx = appConfig.http?.globalPrefix
|
|
55
|
+
? `/${String(appConfig.http.globalPrefix).replace(/^\/+|\/+$/g, '')}`
|
|
56
|
+
: '';
|
|
57
|
+
const env =
|
|
58
|
+
process.env.APP_ENV ??
|
|
59
|
+
appConfig.app?.env ??
|
|
60
|
+
process.env.NODE_ENV ??
|
|
61
|
+
'development';
|
|
62
|
+
const dbOn = appConfig.core?.database?.auto === true;
|
|
63
|
+
const dbHost = appConfig.database?.host;
|
|
64
|
+
const dbName = appConfig.database?.name;
|
|
65
|
+
const jwtGuard = appConfig.core?.guards?.jwt === true;
|
|
66
|
+
const sqlEp = appConfig.core?.sqlEndpoint?.enabled === true;
|
|
67
|
+
// eslint-disable-next-line no-console
|
|
68
|
+
console.log(
|
|
69
|
+
`[api] listen :${port} env=${env}` +
|
|
70
|
+
(base ? ` public=${base}${pfx}` : '') +
|
|
71
|
+
` cors=${appConfig.cors?.enabled !== false ? 'on' : 'off'}` +
|
|
72
|
+
` db=${dbOn ? 'auto' : 'off'}${dbHost ? `@${dbHost}` : ''}${dbName ? `/${dbName}` : ''}` +
|
|
73
|
+
` jwtGuard=${jwtGuard} sqlEndpoint=${sqlEp}`,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
29
77
|
async function bootstrap() {
|
|
30
78
|
const app = await NestFactory.create(AppModule);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const port = Number(process.env.PORT) || 3000;
|
|
34
|
-
const base = appConfig.http?.publicBaseUrl?.replace(/\/$/, '');
|
|
79
|
+
applyNestAppFromConfig(app);
|
|
80
|
+
const port = resolveListenPort();
|
|
35
81
|
await app.listen(port);
|
|
36
|
-
|
|
37
|
-
const pfx = appConfig.http?.globalPrefix
|
|
38
|
-
? `/${String(appConfig.http.globalPrefix).replace(/^\/+|\/+$/g, '')}`
|
|
39
|
-
: '';
|
|
40
|
-
// eslint-disable-next-line no-console
|
|
41
|
-
console.log(`Listening ${base}${pfx} (port ${port})`);
|
|
42
|
-
}
|
|
82
|
+
logStartupFromConfig(port);
|
|
43
83
|
}
|
|
44
84
|
bootstrap();
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
"paths": {
|
|
11
11
|
"__WEB_SHARED_WORKSPACE__": ["../shared/src/index.ts"],
|
|
12
12
|
"__WEB_SHARED_WORKSPACE__/*": ["../shared/src/*"],
|
|
13
|
-
"@shared/*": ["../../shared/*"]
|
|
14
|
-
"@xfilecom/front-core": ["../../../../front-core/src/index.ts"]
|
|
13
|
+
"@shared/*": ["../../shared/*"]
|
|
15
14
|
},
|
|
16
15
|
"allowImportingTsExtensions": true,
|
|
17
16
|
"resolveJsonModule": true,
|
|
@@ -7,12 +7,6 @@ import react from '@vitejs/plugin-react';
|
|
|
7
7
|
|
|
8
8
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* xframe 레포 안 템플릿: …/packages/xframe/packages/front-core/src
|
|
12
|
-
* (`npx @xfilecom/xframe <dir>` 생성 시 CLI 가 front-core alias·const 를 제거 → npm exports 로 해석)
|
|
13
|
-
*/
|
|
14
|
-
const frontCoreSrc = path.resolve(__dirname, '../../../..', 'front-core', 'src');
|
|
15
|
-
|
|
16
10
|
const webSharedSrc = path.resolve(__dirname, '../shared/src');
|
|
17
11
|
const rootSharedSrc = path.resolve(__dirname, '../../shared');
|
|
18
12
|
|
|
@@ -70,7 +64,6 @@ export default defineConfig(({ mode }) => {
|
|
|
70
64
|
plugins: [react()],
|
|
71
65
|
resolve: {
|
|
72
66
|
alias: {
|
|
73
|
-
'@xfilecom/front-core': frontCoreSrc,
|
|
74
67
|
'@shared': rootSharedSrc,
|
|
75
68
|
'__WEB_SHARED_WORKSPACE__': webSharedSrc,
|
|
76
69
|
},
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
"paths": {
|
|
11
11
|
"__WEB_SHARED_WORKSPACE__": ["../shared/src/index.ts"],
|
|
12
12
|
"__WEB_SHARED_WORKSPACE__/*": ["../shared/src/*"],
|
|
13
|
-
"@shared/*": ["../../shared/*"]
|
|
14
|
-
"@xfilecom/front-core": ["../../../../front-core/src/index.ts"]
|
|
13
|
+
"@shared/*": ["../../shared/*"]
|
|
15
14
|
},
|
|
16
15
|
"allowImportingTsExtensions": true,
|
|
17
16
|
"resolveJsonModule": true,
|
|
@@ -7,12 +7,6 @@ import react from '@vitejs/plugin-react';
|
|
|
7
7
|
|
|
8
8
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* xframe 레포 안 템플릿: …/packages/xframe/packages/front-core/src
|
|
12
|
-
* (`npx @xfilecom/xframe <dir>` 생성 시 CLI 가 front-core alias·const 를 제거 → npm exports 로 해석)
|
|
13
|
-
*/
|
|
14
|
-
const frontCoreSrc = path.resolve(__dirname, '../../../..', 'front-core', 'src');
|
|
15
|
-
|
|
16
10
|
/** file:../shared 복사본이 아닌 워크스페이스 web/shared/src (플레이스홀더 패키지 이름과 동일 키) */
|
|
17
11
|
const webSharedSrc = path.resolve(__dirname, '../shared/src');
|
|
18
12
|
|
|
@@ -73,7 +67,6 @@ export default defineConfig(({ mode }) => {
|
|
|
73
67
|
plugins: [react()],
|
|
74
68
|
resolve: {
|
|
75
69
|
alias: {
|
|
76
|
-
'@xfilecom/front-core': frontCoreSrc,
|
|
77
70
|
'@shared': rootSharedSrc,
|
|
78
71
|
'__WEB_SHARED_WORKSPACE__': webSharedSrc,
|
|
79
72
|
},
|
|
@@ -24,16 +24,15 @@ import { Shell } from '__WEB_SHARED_WORKSPACE__';
|
|
|
24
24
|
|
|
25
25
|
새 파일을 앱에서 가져오려면 `package.json`의 **`exports`**에 서브패스를 추가하세요.
|
|
26
26
|
|
|
27
|
-
## `@xfilecom/front-core
|
|
27
|
+
## `@xfilecom/front-core`
|
|
28
28
|
|
|
29
|
-
`web/client`·`web/admin
|
|
29
|
+
`web/client`·`web/admin`·`web/shared`는 **`package.json` 의존성 + `node_modules`** 로 해석합니다(`tsconfig`·Vite에 `paths`/alias로 소스 경로를 강제하지 않음). 서브패스(`tokens.css` 등)는 패키지 `exports`를 따릅니다.
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
로컬에서 코어 소스를 쓰려면 **`npm link @xfilecom/front-core`** 또는 `package.json`의 `file:../front-core` / `workspace:` 등으로 **설치 위치**를 바꾸는 방식을 권장합니다.
|
|
32
32
|
|
|
33
33
|
### `web/shared/tsconfig.json`에는 `paths`로 front-core를 붙이지 마세요
|
|
34
34
|
|
|
35
|
-
`rootDir
|
|
36
|
-
`web/shared` 패키지 타입체크는 **`node_modules`의 `@xfilecom/front-core`**에 맡기고, 로컬 소스 번들은 위 **Vite alias**(client/admin)만 사용하면 됩니다.
|
|
35
|
+
`rootDir` 밖 소스를 끌어오면 `tsc`·에디터가 깨지기 쉽습니다. 타입은 **`node_modules/@xfilecom/front-core`**에 맡깁니다.
|
|
37
36
|
|
|
38
37
|
### `web/shared` CSS·TS가 수정해도 반영되지 않을 때
|
|
39
38
|
|