@simplysm/sd-cli 12.5.15 → 12.5.16

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.
Files changed (41) hide show
  1. package/dist/build-tools/SdCliIndexFileGenerator.js +2 -2
  2. package/dist/build-tools/SdCliIndexFileGenerator.js.map +1 -1
  3. package/dist/build-tools/SdLinter.d.ts +1 -1
  4. package/dist/build-tools/SdLinter.js +27 -23
  5. package/dist/build-tools/SdLinter.js.map +1 -1
  6. package/dist/build-tools/SdTsCompiler.d.ts +7 -1
  7. package/dist/build-tools/SdTsCompiler.js +32 -20
  8. package/dist/build-tools/SdTsCompiler.js.map +1 -1
  9. package/dist/build-tools/SdTsLibBundler.js +7 -1
  10. package/dist/build-tools/SdTsLibBundler.js.map +1 -1
  11. package/dist/builders/SdCliClientBuilder.js +1 -1
  12. package/dist/builders/SdCliClientBuilder.js.map +1 -1
  13. package/dist/builders/SdCliJsLibLinter.js +3 -3
  14. package/dist/builders/SdCliJsLibLinter.js.map +1 -1
  15. package/dist/builders/SdCliServerBuilder.js +42 -43
  16. package/dist/builders/SdCliServerBuilder.js.map +1 -1
  17. package/dist/builders/SdCliTsLibBuilder.js +4 -2
  18. package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
  19. package/dist/bundle-plugins/sdNgPlugin.js +6 -1
  20. package/dist/bundle-plugins/sdNgPlugin.js.map +1 -1
  21. package/dist/bundle-plugins/sdServerPlugin.js +20 -5
  22. package/dist/bundle-plugins/sdServerPlugin.js.map +1 -1
  23. package/dist/entry/SdCliElectron.js +5 -5
  24. package/dist/entry/SdCliElectron.js.map +1 -1
  25. package/dist/entry/SdCliProject.js +4 -2
  26. package/dist/entry/SdCliProject.js.map +1 -1
  27. package/eslint.config.js +1 -0
  28. package/lib/postinstall.js +1 -1
  29. package/package.json +6 -6
  30. package/src/build-tools/SdCliIndexFileGenerator.ts +2 -2
  31. package/src/build-tools/SdLinter.ts +30 -29
  32. package/src/build-tools/SdTsCompiler.ts +34 -15
  33. package/src/build-tools/SdTsLibBundler.ts +7 -1
  34. package/src/builders/SdCliClientBuilder.ts +2 -1
  35. package/src/builders/SdCliJsLibLinter.ts +3 -3
  36. package/src/builders/SdCliServerBuilder.ts +110 -88
  37. package/src/builders/SdCliTsLibBuilder.ts +3 -3
  38. package/src/bundle-plugins/sdNgPlugin.ts +6 -1
  39. package/src/bundle-plugins/sdServerPlugin.ts +29 -13
  40. package/src/entry/SdCliElectron.ts +5 -5
  41. package/src/entry/SdCliProject.ts +4 -2
@@ -1,5 +1,5 @@
1
1
  import {fileURLToPath} from "url";
2
- import * as fs from "node:fs";
2
+ import fs from "node:fs";
3
3
 
4
4
  const filePath = fileURLToPath(import.meta.resolve("@angular/build/package.json"));
5
5
  const contents = JSON.parse(fs.readFileSync(filePath).toString());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/sd-cli",
3
- "version": "12.5.15",
3
+ "version": "12.5.16",
4
4
  "description": "심플리즘 패키지 - CLI",
5
5
  "author": "김석래",
6
6
  "repository": {
@@ -24,11 +24,11 @@
24
24
  "@angular/compiler": "^18.2.5",
25
25
  "@angular/compiler-cli": "^18.2.5",
26
26
  "@electron/rebuild": "^3.6.0",
27
- "@simplysm/sd-core-common": "12.5.15",
28
- "@simplysm/sd-core-node": "12.5.15",
29
- "@simplysm/sd-service-server": "12.5.15",
30
- "@simplysm/sd-storage": "12.5.15",
31
- "@simplysm/ts-transformer-keys": "12.5.15",
27
+ "@simplysm/sd-core-common": "12.5.16",
28
+ "@simplysm/sd-core-node": "12.5.16",
29
+ "@simplysm/sd-service-server": "12.5.16",
30
+ "@simplysm/sd-storage": "12.5.16",
31
+ "@simplysm/ts-transformer-keys": "12.5.16",
32
32
  "browserslist": "^4.23.3",
33
33
  "cordova": "^12.0.0",
34
34
  "css-has-pseudo": "^7.0.0",
@@ -29,7 +29,7 @@ export class SdCliIndexFileGenerator {
29
29
  const filePaths = await this._getFilePathsAsync(pkgPath);
30
30
  for (const filePath of filePaths.orderBy()) {
31
31
  const requirePath = PathUtil.posix(path.relative(path.dirname(indexFilePath), filePath))
32
- .replace(/\.tsx?$/, "")
32
+ .replace(/\.ts$/, "")
33
33
  .replace(/\/index$/, "");
34
34
 
35
35
  const sourceTsFileContent = await FsUtil.readFileAsync(filePath);
@@ -53,7 +53,7 @@ export class SdCliIndexFileGenerator {
53
53
  const tsconfig = await FsUtil.readJsonAsync(path.resolve(pkgPath, "tsconfig.json"));
54
54
  const entryFilePaths: string[] = tsconfig.files?.map((item) => path.resolve(pkgPath, item)) ?? [];
55
55
 
56
- return (await FsUtil.globAsync(path.resolve(pkgPath, "src/**/*{.ts,.tsx}"), { nodir: true })).filter(
56
+ return (await FsUtil.globAsync(path.resolve(pkgPath, "src/**/*.ts"), { nodir: true })).filter(
57
57
  (item) => !entryFilePaths.includes(item) && item !== indexFilePath && !item.endsWith(".d.ts"),
58
58
  );
59
59
  }
@@ -1,45 +1,46 @@
1
1
  import { ISdCliPackageBuildResult } from "../commons";
2
2
  import { ESLint } from "eslint";
3
3
  import ts from "typescript";
4
- import { FsUtil } from "@simplysm/sd-core-node";
4
+ import { FsUtil, PathUtil } from "@simplysm/sd-core-node";
5
+ import path from "path";
5
6
 
6
7
  export abstract class SdLinter {
7
8
  static async lintAsync(
8
- fileSet: Iterable<string>,
9
- tsProgram: ts.Program | undefined
9
+ cwd: string,
10
+ fileSet: Set<string>,
11
+ tsProgram: ts.Program | undefined,
10
12
  ): Promise<ISdCliPackageBuildResult[]> {
13
+ const isTsPackage = FsUtil.exists(path.resolve(cwd, "tsconfig.json"));
14
+
11
15
  const lintFilePaths = Array.from(fileSet)
12
- .filter(
13
- (item) =>
14
- (!item.endsWith(".d.ts") && item.endsWith(".ts")) ||
15
- item.endsWith(".tsx") ||
16
- item.endsWith(".js")
17
- )
16
+ .filter((item) => PathUtil.isChildPath(item, cwd))
17
+ .filter((item) => (isTsPackage && !item.endsWith(".d.ts") && item.endsWith(".ts")) || item.endsWith(".js"))
18
18
  .filter((item) => FsUtil.exists(item));
19
19
 
20
20
  if (lintFilePaths.length === 0) {
21
21
  return [];
22
22
  }
23
23
 
24
- const linter = new ESLint(
25
- tsProgram != null
24
+ const linter = new ESLint({
25
+ cwd,
26
+ cache: false,
27
+ ...(isTsPackage && tsProgram
26
28
  ? {
27
- cache: false,
28
- overrideConfig: [
29
- {
30
- files: ["**/*.ts", "**/*.tsx"],
31
- languageOptions: {
32
- parserOptions: {
33
- programs: [tsProgram],
34
- project: null,
35
- tsconfigRootDir: null
36
- }
37
- }
38
- }
39
- ]
40
- }
41
- : undefined
42
- );
29
+ overrideConfig: [
30
+ {
31
+ files: ["**/*.ts"],
32
+ languageOptions: {
33
+ parserOptions: {
34
+ programs: [tsProgram],
35
+ project: null,
36
+ tsconfigRootDir: null,
37
+ },
38
+ },
39
+ },
40
+ ],
41
+ }
42
+ : {}),
43
+ });
43
44
 
44
45
  const lintResults = await linter.lintFiles(lintFilePaths);
45
46
 
@@ -51,8 +52,8 @@ export abstract class SdLinter {
51
52
  code: msg.messageId,
52
53
  severity: msg.severity === 1 ? ("warning" as const) : ("error" as const),
53
54
  message: msg.message + (msg.ruleId != null ? ` (${msg.ruleId})` : ``),
54
- type: "lint" as const
55
- }))
55
+ type: "lint" as const,
56
+ })),
56
57
  );
57
58
  }
58
59
  }
@@ -44,23 +44,32 @@ export class SdTsCompiler {
44
44
  readonly #distPath: string;
45
45
  readonly #globalStyleFilePath?: string;
46
46
 
47
- constructor(pkgPath: string, additionalOptions: CompilerOptions, isDevMode: boolean, globalStyleFilePath?: string) {
48
- this.#pkgPath = pkgPath;
49
- this.#globalStyleFilePath = globalStyleFilePath != null ? path.normalize(globalStyleFilePath) : undefined;
47
+ readonly #isForBundle: boolean;
48
+
49
+ constructor(opt: {
50
+ pkgPath: string;
51
+ additionalOptions: CompilerOptions;
52
+ isForBundle: boolean;
53
+ isDevMode: boolean;
54
+ globalStyleFilePath?: string;
55
+ }) {
56
+ this.#pkgPath = opt.pkgPath;
57
+ this.#globalStyleFilePath = opt.globalStyleFilePath != null ? path.normalize(opt.globalStyleFilePath) : undefined;
58
+ this.#isForBundle = opt.isForBundle;
50
59
 
51
60
  this.#debug("초기화...");
52
61
 
53
62
  //-- isForAngular / parsedTsConfig
54
63
 
55
- const tsconfigPath = path.resolve(pkgPath, "tsconfig.json");
64
+ const tsconfigPath = path.resolve(opt.pkgPath, "tsconfig.json");
56
65
  const tsconfig = FsUtil.readJson(tsconfigPath);
57
66
  this.#isForAngular = Boolean(tsconfig.angularCompilerOptions);
58
- this.#parsedTsconfig = ts.parseJsonConfigFileContent(tsconfig, ts.sys, pkgPath, {
67
+ this.#parsedTsconfig = ts.parseJsonConfigFileContent(tsconfig, ts.sys, opt.pkgPath, {
59
68
  ...tsconfig.angularCompilerOptions,
60
- ...additionalOptions,
69
+ ...opt.additionalOptions,
61
70
  });
62
71
 
63
- this.#distPath = this.#parsedTsconfig.options.outDir ?? path.resolve(pkgPath, "dist");
72
+ this.#distPath = this.#parsedTsconfig.options.outDir ?? path.resolve(opt.pkgPath, "dist");
64
73
 
65
74
  //-- compilerHost
66
75
 
@@ -99,8 +108,8 @@ export class SdTsCompiler {
99
108
  //-- stylesheetBundler
100
109
  this.#stylesheetBundler = new ComponentStylesheetBundler(
101
110
  {
102
- workspaceRoot: pkgPath,
103
- optimization: !isDevMode,
111
+ workspaceRoot: opt.pkgPath,
112
+ optimization: !opt.isDevMode,
104
113
  inlineFonts: true,
105
114
  preserveSymlinks: false,
106
115
  sourcemap: "inline", //conf.dev ? 'inline' : false,
@@ -118,7 +127,7 @@ export class SdTsCompiler {
118
127
  basePath: ".cache",
119
128
  },
120
129
  },
121
- isDevMode,
130
+ opt.isDevMode,
122
131
  );
123
132
 
124
133
  //-- compilerHost
@@ -381,6 +390,10 @@ export class SdTsCompiler {
381
390
  continue;
382
391
  }
383
392
 
393
+ if (!PathUtil.isChildPath(affectedFile, this.#pkgPath)) {
394
+ continue;
395
+ }
396
+
384
397
  diagnostics.push(
385
398
  ...this.#program.getSyntacticDiagnostics(affectedSourceFile),
386
399
  ...this.#program.getSemanticDiagnostics(affectedSourceFile),
@@ -411,8 +424,8 @@ export class SdTsCompiler {
411
424
  (transformers.before ??= []).push(transformKeys(this.#program));
412
425
 
413
426
  // affected에 새로 추가된 파일은 포함되지 않는 현상이 있어 getSourceFiles로 바꿈
414
- // -> 너무 느려져서 다시 돌림. 포함안되는 현상은 getAllDep 문제인가?
415
- for (const affectedFile of affectedFileSet) {
427
+ // 비교해보니, 딱히 getSourceFiles라서 느려지는것 같지는 않음
428
+ /*for (const affectedFile of affectedFileSet) {
416
429
  if (this.#emittedFilesCacheMap.has(affectedFile)) {
417
430
  continue;
418
431
  }
@@ -420,10 +433,9 @@ export class SdTsCompiler {
420
433
  const sf = this.#program.getSourceFile(affectedFile);
421
434
  if (!sf) {
422
435
  continue;
423
- }
424
-
425
- // for (const sf of sourceFileSet) {
436
+ }*/
426
437
 
438
+ for (const sf of sourceFileSet) {
427
439
  if (this.#emittedFilesCacheMap.has(path.normalize(sf.fileName))) {
428
440
  continue;
429
441
  }
@@ -436,6 +448,13 @@ export class SdTsCompiler {
436
448
  continue;
437
449
  }
438
450
 
451
+ // esbuild를 통해 bundle로 묶어야 하는놈들은 모든 output이 있어야 함.
452
+ if (!this.#isForBundle) {
453
+ if (!PathUtil.isChildPath(sf.fileName, this.#pkgPath)) {
454
+ continue;
455
+ }
456
+ }
457
+
439
458
  this.#debug(`emit for`, sf.fileName);
440
459
  this.#program.emit(
441
460
  sf,
@@ -12,7 +12,13 @@ export class SdTsLibBundler {
12
12
 
13
13
  public constructor(pkgPath: string, dev: boolean) {
14
14
  this.#pkgPath = pkgPath;
15
- this.#compiler = new SdTsCompiler(pkgPath, { declaration: true }, dev, path.resolve(pkgPath, "src/styles.scss"));
15
+ this.#compiler = new SdTsCompiler({
16
+ pkgPath,
17
+ additionalOptions: { declaration: true },
18
+ isDevMode: dev,
19
+ globalStyleFilePath: path.resolve(pkgPath, "src/styles.scss"),
20
+ isForBundle: false,
21
+ });
16
22
  }
17
23
 
18
24
  public markChanges(modifiedFileSet: Set<string>): void {
@@ -169,7 +169,8 @@ export class SdCliClientBuilder extends EventEmitter {
169
169
  // });
170
170
  // const pkgFilePaths = filePaths.filter(item => PathUtil.isChildPath(item, this._pkgPath));
171
171
  const lintResults = await SdLinter.lintAsync(
172
- Array.from(affectedFileSet).filter((item) => PathUtil.isChildPath(item, this._pkgPath)),
172
+ this._pkgPath,
173
+ affectedFileSet,
173
174
  firstProgram,
174
175
  );
175
176
 
@@ -24,7 +24,7 @@ export class SdCliJsLibLinter extends EventEmitter {
24
24
  this._debug("LINT...");
25
25
  const srcGlobPath = path.resolve(this._pkgPath, "src/**/*.js");
26
26
  const srcFilePaths = await FsUtil.globAsync(srcGlobPath);
27
- const lintResults = await SdLinter.lintAsync(srcFilePaths, undefined);
27
+ const lintResults = await SdLinter.lintAsync(this._pkgPath, new Set(srcFilePaths), undefined);
28
28
 
29
29
  this._debug(`LINT 완료`);
30
30
  return {
@@ -38,7 +38,7 @@ export class SdCliJsLibLinter extends EventEmitter {
38
38
  this._debug("LINT...");
39
39
  const srcGlobPath = path.resolve(this._pkgPath, "src/**/*.js");
40
40
  const srcFilePaths = await FsUtil.globAsync(srcGlobPath);
41
- const lintResults = await SdLinter.lintAsync(srcFilePaths, undefined);
41
+ const lintResults = await SdLinter.lintAsync(this._pkgPath, new Set(srcFilePaths), undefined);
42
42
 
43
43
  this._debug(`LINT 완료`);
44
44
  this.emit("complete", {
@@ -56,7 +56,7 @@ export class SdCliJsLibLinter extends EventEmitter {
56
56
 
57
57
  this.emit("change");
58
58
  this._debug("LINT...");
59
- const watchLintResults = await SdLinter.lintAsync(watchFilePaths, undefined);
59
+ const watchLintResults = await SdLinter.lintAsync(this._pkgPath, new Set(watchFilePaths), undefined);
60
60
 
61
61
  this._debug(`LINT 완료`);
62
62
  this.emit("complete", {