@simplysm/sd-cli 11.0.9 → 11.0.11
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/dist/build-cluster.js +25 -36
- package/dist/build-cluster.js.map +1 -1
- package/dist/build-tools/SdCliCordova.js +5 -5
- package/dist/build-tools/SdCliCordova.js.map +1 -1
- package/dist/build-tools/SdCliNgRoutesFileGenerator.d.ts +4 -0
- package/dist/build-tools/SdCliNgRoutesFileGenerator.js +64 -0
- package/dist/build-tools/SdCliNgRoutesFileGenerator.js.map +1 -0
- package/dist/build-tools/SdLinter.js +8 -1
- package/dist/build-tools/SdLinter.js.map +1 -1
- package/dist/build-tools/SdNgBundler.d.ts +18 -8
- package/dist/build-tools/SdNgBundler.js +286 -213
- package/dist/build-tools/SdNgBundler.js.map +1 -1
- package/dist/build-tools/SdTsBundler.d.ts +6 -5
- package/dist/build-tools/SdTsBundler.js +78 -80
- package/dist/build-tools/SdTsBundler.js.map +1 -1
- package/dist/build-tools/SdTsCompiler.d.ts +1 -0
- package/dist/build-tools/SdTsCompiler.js +5 -1
- package/dist/build-tools/SdTsCompiler.js.map +1 -1
- package/dist/builders/SdCliClientBuilder.js +51 -36
- package/dist/builders/SdCliClientBuilder.js.map +1 -1
- package/dist/builders/SdCliServerBuilder.d.ts +6 -2
- package/dist/builders/SdCliServerBuilder.js +107 -141
- package/dist/builders/SdCliServerBuilder.js.map +1 -1
- package/dist/builders/SdCliTsLibBuilder.d.ts +6 -3
- package/dist/builders/SdCliTsLibBuilder.js +42 -45
- package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
- package/dist/commons.d.ts +0 -2
- package/dist/entry/SdCliElectron.js +3 -3
- package/dist/entry/SdCliElectron.js.map +1 -1
- package/dist/entry/SdCliProject.d.ts +0 -3
- package/dist/entry/SdCliProject.js +10 -33
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/sd-cli.js +3 -21
- package/dist/sd-cli.js.map +1 -1
- package/dist/utils/SdMemoryLoadResultCache.d.ts +9 -0
- package/dist/utils/SdMemoryLoadResultCache.js +39 -0
- package/dist/utils/SdMemoryLoadResultCache.js.map +1 -0
- package/dist/utils/SdSourceFileCache.d.ts +5 -0
- package/dist/utils/SdSourceFileCache.js +9 -0
- package/dist/utils/SdSourceFileCache.js.map +1 -0
- package/package.json +17 -17
- package/src/build-cluster.ts +26 -36
- package/src/build-tools/SdCliCordova.ts +5 -5
- package/src/build-tools/SdCliNgRoutesFileGenerator.ts +80 -0
- package/src/build-tools/SdLinter.ts +12 -1
- package/src/build-tools/SdNgBundler.ts +431 -333
- package/src/build-tools/SdTsBundler.ts +86 -86
- package/src/build-tools/SdTsCompiler.ts +6 -1
- package/src/builders/SdCliClientBuilder.ts +62 -43
- package/src/builders/SdCliServerBuilder.ts +64 -63
- package/src/builders/SdCliTsLibBuilder.ts +58 -50
- package/src/commons.ts +1 -2
- package/src/entry/SdCliElectron.ts +3 -3
- package/src/entry/SdCliProject.ts +12 -41
- package/src/index.ts +3 -0
- package/src/sd-cli.ts +3 -21
- package/src/utils/SdMemoryLoadResultCache.ts +44 -0
- package/src/utils/SdSourceFileCache.ts +6 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import {FsUtil, PathUtil, SdFsWatcher} from "@simplysm/sd-core-node";
|
|
3
|
+
import {StringUtil} from "@simplysm/sd-core-common";
|
|
4
|
+
|
|
5
|
+
export class SdCliNgRoutesFileGenerator {
|
|
6
|
+
public static async watchAsync(pkgPath: string): Promise<void> {
|
|
7
|
+
const routesFilePath = path.resolve(pkgPath, "src/routes.ts");
|
|
8
|
+
let cache = FsUtil.exists(routesFilePath) ? FsUtil.readFile(routesFilePath) : undefined;
|
|
9
|
+
|
|
10
|
+
SdFsWatcher
|
|
11
|
+
.watch([path.resolve(pkgPath, "src")])
|
|
12
|
+
.onChange({}, async () => {
|
|
13
|
+
cache = await this.runAsync(pkgPath, cache);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
cache = await this.runAsync(pkgPath, cache);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public static async runAsync(pkgPath: string, cache?: string): Promise<string> {
|
|
20
|
+
const appDirPath = path.resolve(pkgPath, "src/app");
|
|
21
|
+
const routesFilePath = path.resolve(pkgPath, "src/routes.ts");
|
|
22
|
+
|
|
23
|
+
// 내부 파일들 import
|
|
24
|
+
const result: TInfo = new Map();
|
|
25
|
+
const filePaths = await FsUtil.globAsync(path.resolve(appDirPath, "**/*Page.ts"));
|
|
26
|
+
for (const filePath of filePaths.orderBy()) {
|
|
27
|
+
const relModulePath = PathUtil.posix(path.relative(appDirPath, filePath)).slice(0, -3);
|
|
28
|
+
const codes = relModulePath.slice(0, -4).split("/").map(item => StringUtil.toKebabCase(item));
|
|
29
|
+
|
|
30
|
+
let cursorItem!: { relModulePath?: string; children: TInfo };
|
|
31
|
+
let cursor = result;
|
|
32
|
+
|
|
33
|
+
for (const code of codes) {
|
|
34
|
+
cursorItem = cursor.getOrCreate(code, {children: new Map()});
|
|
35
|
+
cursor = cursorItem.children;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
cursorItem.relModulePath = relModulePath;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
const fn = (currInfo: TInfo, indent: number): string => {
|
|
43
|
+
const indentStr = new Array(indent).fill(" ").join("");
|
|
44
|
+
|
|
45
|
+
let cont = "";
|
|
46
|
+
for (const [key, val] of currInfo) {
|
|
47
|
+
cont += indentStr + "{\n";
|
|
48
|
+
cont += indentStr + ` path: "${key}",\n`;
|
|
49
|
+
if (val.relModulePath != null) {
|
|
50
|
+
cont += indentStr + ` loadComponent: () => import("./app/${val.relModulePath}").then((m) => m.${path.basename(val.relModulePath)}),\n`;
|
|
51
|
+
cont += indentStr + ` canDeactivate: [sdCanDeactivateGuard],\n`;
|
|
52
|
+
}
|
|
53
|
+
if (val.children.size > 0) {
|
|
54
|
+
cont += indentStr + ` children: [\n`;
|
|
55
|
+
cont += fn(val.children, indent + 4) + "\n";
|
|
56
|
+
cont += indentStr + ` ]\n`;
|
|
57
|
+
}
|
|
58
|
+
cont += indentStr + "},\n";
|
|
59
|
+
}
|
|
60
|
+
return cont.trimEnd();
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const content = `
|
|
64
|
+
import {sdCanDeactivateGuard} from "@simplysm/sd-angular";
|
|
65
|
+
import {Routes} from "@angular/router";
|
|
66
|
+
|
|
67
|
+
export const routes: Routes = [
|
|
68
|
+
${fn(result, 2)}
|
|
69
|
+
];`.trim();
|
|
70
|
+
if (content.trim() !== cache?.trim()) {
|
|
71
|
+
await FsUtil.writeFileAsync(routesFilePath, content);
|
|
72
|
+
}
|
|
73
|
+
return content;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
type TInfo = Map<string, {
|
|
78
|
+
relModulePath?: string;
|
|
79
|
+
children: TInfo
|
|
80
|
+
}>;
|
|
@@ -5,6 +5,17 @@ import path from "path";
|
|
|
5
5
|
|
|
6
6
|
export class SdLinter {
|
|
7
7
|
public static async lintAsync(filePaths: string[], programOrPkgPath?: ts.Program | string): Promise<ISdCliPackageBuildResult[]> {
|
|
8
|
+
const sourceFilePaths = filePaths.filter((item) =>
|
|
9
|
+
(!item.endsWith(".d.ts") && item.endsWith(".ts")) ||
|
|
10
|
+
item.endsWith(".js") ||
|
|
11
|
+
item.endsWith(".cjs") ||
|
|
12
|
+
item.endsWith(".mjs")
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
if (sourceFilePaths.length === 0) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
|
|
8
19
|
const linter = new ESLint(programOrPkgPath !== null ? {
|
|
9
20
|
overrideConfig: {
|
|
10
21
|
overrides: [
|
|
@@ -37,7 +48,7 @@ export class SdLinter {
|
|
|
37
48
|
}
|
|
38
49
|
} : undefined);
|
|
39
50
|
|
|
40
|
-
const lintResults = await linter.lintFiles(
|
|
51
|
+
const lintResults = await linter.lintFiles(sourceFilePaths);
|
|
41
52
|
|
|
42
53
|
return lintResults.mapMany((lintResult) => lintResult.messages.map((msg) => ({
|
|
43
54
|
filePath: lintResult.filePath,
|