@simplysm/sd-cli 12.16.42 → 12.16.51

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.
@@ -23,7 +23,6 @@ export declare class SdTsCompiler {
23
23
  private _lintAsync;
24
24
  private _buildGlobalStyleAsync;
25
25
  private _build;
26
- private _convertOutputToReal;
27
26
  private _removeOutputDevModeLine;
28
27
  private _debug;
29
28
  }
@@ -12,6 +12,7 @@ import { SdDepAnalyzer } from "./SdDepAnalyzer";
12
12
  import { FlatESLint } from "eslint/use-at-your-own-risk";
13
13
  import { SdStyleBundler } from "./SdStyleBundler";
14
14
  import { ScopePathSet } from "./ScopePathSet";
15
+ import { convertOutputToReal } from "./convertOutputToReal";
15
16
  export class SdTsCompiler {
16
17
  constructor(_opt, _forBundle) {
17
18
  this._opt = _opt;
@@ -376,7 +377,7 @@ export class SdTsCompiler {
376
377
  }
377
378
  const emitFileInfoCaches = this._emittedFilesCacheMap.getOrCreate(PathUtils.norm(sourceFile.fileName), []);
378
379
  if (PathUtils.isChildPath(sourceFile.fileName, this._opt.pkgPath)) {
379
- const real = this._convertOutputToReal(fileName, prepareResult.tsconfig.distPath, text);
380
+ const real = convertOutputToReal(fileName, prepareResult.tsconfig.distPath, this._opt.pkgPath, text);
380
381
  emitFileInfoCaches.push({
381
382
  outAbsPath: real.filePath,
382
383
  text: this._removeOutputDevModeLine(real.text),
@@ -396,21 +397,6 @@ export class SdTsCompiler {
396
397
  diagnostics,
397
398
  };
398
399
  }
399
- _convertOutputToReal(filePath, distPath, text) {
400
- let realFilePath = PathUtils.norm(filePath);
401
- let realText = text;
402
- const srcRelBasePath = path.resolve(distPath, path.basename(this._opt.pkgPath), "src");
403
- if (PathUtils.isChildPath(realFilePath, srcRelBasePath)) {
404
- realFilePath = PathUtils.norm(distPath, path.relative(srcRelBasePath, realFilePath));
405
- // source map 위치 정확히 찾아가기
406
- if (filePath.endsWith(".js.map")) {
407
- const sourceMapContents = JSON.parse(realText);
408
- sourceMapContents.sources[0] = sourceMapContents.sources[0].slice(6); // remove "../../"
409
- realText = JSON.stringify(sourceMapContents);
410
- }
411
- }
412
- return { filePath: realFilePath, text: realText };
413
- }
414
400
  _removeOutputDevModeLine(str) {
415
401
  return str.replace(/\(\(\) => \{ \(typeof ngDevMode === "undefined" \|\| ngDevMode\) && i0.ɵsetClassDebugInfo\(.*, \{ className: ".*", filePath: ".*", lineNumber: [0-9]* }\); }\)\(\);/, "");
416
402
  }
@@ -0,0 +1,5 @@
1
+ import { TNormPath } from "@simplysm/sd-core-node";
2
+ export declare function convertOutputToReal(filePath: string, distPath: TNormPath, pkgPath: TNormPath, text: string): {
3
+ filePath: TNormPath;
4
+ text: string;
5
+ };
@@ -0,0 +1,32 @@
1
+ import path from "path";
2
+ import { PathUtils } from "@simplysm/sd-core-node";
3
+ export function convertOutputToReal(filePath, distPath, pkgPath, text) {
4
+ let realFilePath = PathUtils.norm(filePath);
5
+ let realText = text;
6
+ // 패턴 1: dist/<패키지명>/src/ (commonSourceDirectory가 packages/)
7
+ const pkgNameSrcPath = PathUtils.norm(path.resolve(distPath, path.basename(pkgPath), "src"));
8
+ // 패턴 2: dist/src/ (commonSourceDirectory가 패키지 루트)
9
+ const directSrcPath = PathUtils.norm(path.resolve(distPath, "src"));
10
+ let matchedBasePath;
11
+ if (PathUtils.isChildPath(realFilePath, pkgNameSrcPath)) {
12
+ matchedBasePath = pkgNameSrcPath;
13
+ }
14
+ else if (PathUtils.isChildPath(realFilePath, directSrcPath)) {
15
+ matchedBasePath = directSrcPath;
16
+ }
17
+ if (matchedBasePath != null) {
18
+ const newFilePath = PathUtils.norm(distPath, path.relative(matchedBasePath, realFilePath));
19
+ // source map 보정: matchedBasePath와 distPath 간 depth 차이만큼 "../" 제거
20
+ if (filePath.endsWith(".js.map")) {
21
+ const depthDiff = path.relative(distPath, matchedBasePath).split(path.sep).length;
22
+ if (depthDiff > 0) {
23
+ const sourceMapContents = JSON.parse(realText);
24
+ const prefixToRemove = "../".repeat(depthDiff);
25
+ sourceMapContents.sources[0] = sourceMapContents.sources[0].slice(prefixToRemove.length);
26
+ realText = JSON.stringify(sourceMapContents);
27
+ }
28
+ }
29
+ realFilePath = newFilePath;
30
+ }
31
+ return { filePath: realFilePath, text: realText };
32
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/sd-cli",
3
- "version": "12.16.42",
3
+ "version": "12.16.51",
4
4
  "description": "심플리즘 패키지 - CLI",
5
5
  "author": "김석래",
6
6
  "repository": {
@@ -17,10 +17,10 @@
17
17
  "@angular/compiler-cli": "^20.3.18",
18
18
  "@anthropic-ai/sdk": "^0.78.0",
19
19
  "@electron/rebuild": "^4.0.3",
20
- "@simplysm/sd-core-common": "12.16.42",
21
- "@simplysm/sd-core-node": "12.16.42",
22
- "@simplysm/sd-service-server": "12.16.42",
23
- "@simplysm/sd-storage": "12.16.42",
20
+ "@simplysm/sd-core-common": "12.16.51",
21
+ "@simplysm/sd-core-node": "12.16.51",
22
+ "@simplysm/sd-service-server": "12.16.51",
23
+ "@simplysm/sd-storage": "12.16.51",
24
24
  "abortcontroller-polyfill": "^1.7.8",
25
25
  "browserslist": "^4.28.1",
26
26
  "cordova": "^13.0.0",
@@ -15,6 +15,7 @@ import { SdStyleBundler } from "./SdStyleBundler";
15
15
  import { ISdTsCompilerOptions } from "../types/build/ISdTsCompilerOptions";
16
16
  import { ISdTsCompilerResult } from "../types/build/ISdTsCompilerResult";
17
17
  import { ScopePathSet } from "./ScopePathSet";
18
+ import { convertOutputToReal } from "./convertOutputToReal";
18
19
 
19
20
  export class SdTsCompiler {
20
21
  private readonly _logger = SdLogger.get(["simplysm", "sd-cli", "SdTsCompiler"]);
@@ -562,9 +563,10 @@ export class SdTsCompiler {
562
563
  );
563
564
 
564
565
  if (PathUtils.isChildPath(sourceFile.fileName, this._opt.pkgPath)) {
565
- const real = this._convertOutputToReal(
566
+ const real = convertOutputToReal(
566
567
  fileName,
567
568
  prepareResult.tsconfig.distPath,
569
+ this._opt.pkgPath,
568
570
  text,
569
571
  );
570
572
 
@@ -594,26 +596,6 @@ export class SdTsCompiler {
594
596
  };
595
597
  }
596
598
 
597
- private _convertOutputToReal(filePath: string, distPath: string, text: string) {
598
- let realFilePath = PathUtils.norm(filePath);
599
- let realText = text;
600
-
601
- const srcRelBasePath = path.resolve(distPath, path.basename(this._opt.pkgPath), "src");
602
-
603
- if (PathUtils.isChildPath(realFilePath, srcRelBasePath)) {
604
- realFilePath = PathUtils.norm(distPath, path.relative(srcRelBasePath, realFilePath));
605
-
606
- // source map 위치 정확히 찾아가기
607
- if (filePath.endsWith(".js.map")) {
608
- const sourceMapContents = JSON.parse(realText);
609
- sourceMapContents.sources[0] = sourceMapContents.sources[0].slice(6); // remove "../../"
610
- realText = JSON.stringify(sourceMapContents);
611
- }
612
- }
613
-
614
- return { filePath: realFilePath, text: realText };
615
- }
616
-
617
599
  private _removeOutputDevModeLine(str: string) {
618
600
  return str.replace(
619
601
  /\(\(\) => \{ \(typeof ngDevMode === "undefined" \|\| ngDevMode\) && i0.ɵsetClassDebugInfo\(.*, \{ className: ".*", filePath: ".*", lineNumber: [0-9]* }\); }\)\(\);/,
@@ -629,7 +611,7 @@ export class SdTsCompiler {
629
611
  interface ITsConfigInfo {
630
612
  fileNames: string[];
631
613
  options: ts.CompilerOptions;
632
- distPath: string;
614
+ distPath: TNormPath;
633
615
  }
634
616
 
635
617
  interface IPrepareResult {
@@ -0,0 +1,45 @@
1
+ import path from "path";
2
+ import { PathUtils, TNormPath } from "@simplysm/sd-core-node";
3
+
4
+ export function convertOutputToReal(
5
+ filePath: string,
6
+ distPath: TNormPath,
7
+ pkgPath: TNormPath,
8
+ text: string,
9
+ ): { filePath: TNormPath; text: string } {
10
+ let realFilePath = PathUtils.norm(filePath);
11
+ let realText = text;
12
+
13
+ // 패턴 1: dist/<패키지명>/src/ (commonSourceDirectory가 packages/)
14
+ const pkgNameSrcPath = PathUtils.norm(path.resolve(distPath, path.basename(pkgPath), "src"));
15
+ // 패턴 2: dist/src/ (commonSourceDirectory가 패키지 루트)
16
+ const directSrcPath = PathUtils.norm(path.resolve(distPath, "src"));
17
+
18
+ let matchedBasePath: TNormPath | undefined;
19
+
20
+ if (PathUtils.isChildPath(realFilePath, pkgNameSrcPath)) {
21
+ matchedBasePath = pkgNameSrcPath;
22
+ } else if (PathUtils.isChildPath(realFilePath, directSrcPath)) {
23
+ matchedBasePath = directSrcPath;
24
+ }
25
+
26
+ if (matchedBasePath != null) {
27
+ const newFilePath = PathUtils.norm(distPath, path.relative(matchedBasePath, realFilePath));
28
+
29
+ // source map 보정: matchedBasePath와 distPath 간 depth 차이만큼 "../" 제거
30
+ if (filePath.endsWith(".js.map")) {
31
+ const depthDiff = path.relative(distPath, matchedBasePath).split(path.sep).length;
32
+
33
+ if (depthDiff > 0) {
34
+ const sourceMapContents = JSON.parse(realText);
35
+ const prefixToRemove = "../".repeat(depthDiff);
36
+ sourceMapContents.sources[0] = sourceMapContents.sources[0].slice(prefixToRemove.length);
37
+ realText = JSON.stringify(sourceMapContents);
38
+ }
39
+ }
40
+
41
+ realFilePath = newFilePath;
42
+ }
43
+
44
+ return { filePath: realFilePath, text: realText };
45
+ }
@@ -0,0 +1,67 @@
1
+ import "@simplysm/sd-core-common";
2
+ import { PathUtils, TNormPath } from "@simplysm/sd-core-node";
3
+ import { describe, expect, it } from "vitest";
4
+ import { convertOutputToReal } from "../../src/ts-compiler/convertOutputToReal";
5
+
6
+ describe("convertOutputToReal", () => {
7
+ // Case: commonSourceDirectory가 packages/ → 출력이 dist/<패키지명>/src/
8
+ it("dist/<패키지명>/src/ 패턴을 dist/로 보정한다", () => {
9
+ const pkgPath = PathUtils.norm("/repo/packages/sd-excel") as TNormPath;
10
+ const distPath = PathUtils.norm("/repo/packages/sd-excel/dist") as TNormPath;
11
+ const filePath = PathUtils.norm("/repo/packages/sd-excel/dist/sd-excel/src/index.js") as TNormPath;
12
+
13
+ const result = convertOutputToReal(filePath, distPath, pkgPath, "export default {};");
14
+
15
+ expect(result.filePath).toBe(PathUtils.norm("/repo/packages/sd-excel/dist/index.js"));
16
+ });
17
+
18
+ // Case: commonSourceDirectory가 패키지 루트 → 출력이 dist/src/
19
+ it("dist/src/ 패턴을 dist/로 보정한다", () => {
20
+ const pkgPath = PathUtils.norm("/repo/packages/capacitor-plugin-intent") as TNormPath;
21
+ const distPath = PathUtils.norm("/repo/packages/capacitor-plugin-intent/dist") as TNormPath;
22
+ const filePath = PathUtils.norm("/repo/packages/capacitor-plugin-intent/dist/src/index.js") as TNormPath;
23
+
24
+ const result = convertOutputToReal(filePath, distPath, pkgPath, "export default {};");
25
+
26
+ expect(result.filePath).toBe(PathUtils.norm("/repo/packages/capacitor-plugin-intent/dist/index.js"));
27
+ });
28
+
29
+ it("dist/src/ 중첩 경로도 보정한다", () => {
30
+ const pkgPath = PathUtils.norm("/repo/packages/capacitor-plugin-intent") as TNormPath;
31
+ const distPath = PathUtils.norm("/repo/packages/capacitor-plugin-intent/dist") as TNormPath;
32
+ const filePath = PathUtils.norm("/repo/packages/capacitor-plugin-intent/dist/src/web/IntentWeb.js") as TNormPath;
33
+
34
+ const result = convertOutputToReal(filePath, distPath, pkgPath, "export default {};");
35
+
36
+ expect(result.filePath).toBe(PathUtils.norm("/repo/packages/capacitor-plugin-intent/dist/web/IntentWeb.js"));
37
+ });
38
+
39
+ // source map 보정
40
+ // dist/sd-excel/src/ → dist/ (2단계 위로 이동)
41
+ // sources: "../../../src/index.ts" → depth가 2 줄어 "../" 2개 제거 → "../src/index.ts"
42
+ it("dist/<패키지명>/src/ 패턴의 source map을 보정한다", () => {
43
+ const pkgPath = PathUtils.norm("/repo/packages/sd-excel") as TNormPath;
44
+ const distPath = PathUtils.norm("/repo/packages/sd-excel/dist") as TNormPath;
45
+ const filePath = PathUtils.norm("/repo/packages/sd-excel/dist/sd-excel/src/index.js.map") as TNormPath;
46
+ const sourceMap = JSON.stringify({ sources: ["../../../src/index.ts"] });
47
+
48
+ const result = convertOutputToReal(filePath, distPath, pkgPath, sourceMap);
49
+
50
+ const parsed = JSON.parse(result.text);
51
+ expect(parsed.sources[0]).toBe("../src/index.ts");
52
+ });
53
+
54
+ // dist/src/ → dist/ (1단계 위로 이동)
55
+ // sources: "../../src/index.ts" → depth가 1 줄어 "../" 1개 제거 → "../src/index.ts"
56
+ it("dist/src/ 패턴의 source map을 보정한다", () => {
57
+ const pkgPath = PathUtils.norm("/repo/packages/capacitor-plugin-intent") as TNormPath;
58
+ const distPath = PathUtils.norm("/repo/packages/capacitor-plugin-intent/dist") as TNormPath;
59
+ const filePath = PathUtils.norm("/repo/packages/capacitor-plugin-intent/dist/src/index.js.map") as TNormPath;
60
+ const sourceMap = JSON.stringify({ sources: ["../../src/index.ts"] });
61
+
62
+ const result = convertOutputToReal(filePath, distPath, pkgPath, sourceMap);
63
+
64
+ const parsed = JSON.parse(result.text);
65
+ expect(parsed.sources[0]).toBe("../src/index.ts");
66
+ });
67
+ });
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "lib": ["ES2021"],
5
- "outDir": "./dist"
6
- },
7
- "exclude": ["dist", "node_modules"]
8
- }
package/vitest.config.js DELETED
@@ -1,12 +0,0 @@
1
- import { defineConfig } from "vitest/config";
2
-
3
- export default defineConfig({
4
- resolve: {
5
- tsconfigPaths: true,
6
- },
7
- test: {
8
- globals: true,
9
- environment: "node",
10
- include: ["tests/**/*.spec.ts"],
11
- },
12
- });