@simplysm/sd-cli 6.4.3 → 7.0.6
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/.eslintrc.cjs +11 -0
- package/dist/bin/sd-cli.d.ts +1 -0
- package/dist/bin/sd-cli.mjs +60 -0
- package/dist/build-tool/SdCliCacheCompilerHost.d.ts +10 -0
- package/dist/build-tool/SdCliCacheCompilerHost.mjs +44 -0
- package/dist/build-tool/SdCliNgCacheCompilerHost.d.ts +11 -0
- package/dist/build-tool/SdCliNgCacheCompilerHost.mjs +36 -0
- package/dist/build-tool/SdCliPackageLinter.d.ts +8 -0
- package/dist/build-tool/SdCliPackageLinter.mjs +41 -0
- package/dist/builder/SdCliJsLibBuilder.d.ts +14 -0
- package/dist/builder/SdCliJsLibBuilder.mjs +50 -0
- package/dist/builder/SdCliTsLibBuilder.d.ts +27 -0
- package/dist/builder/SdCliTsLibBuilder.mjs +226 -0
- package/dist/commons.d.ts +43 -0
- package/dist/commons.mjs +2 -0
- package/dist/entry-points/SdCliWorkspace.d.ts +17 -0
- package/dist/entry-points/SdCliWorkspace.mjs +186 -0
- package/dist/packages/SdCliPackage.d.ts +19 -0
- package/dist/packages/SdCliPackage.mjs +89 -0
- package/dist/utils/SdBuildResultUtil.d.ts +6 -0
- package/dist/utils/SdBuildResultUtil.mjs +38 -0
- package/lib/ts-node-esm-paths.mjs +15 -0
- package/package.json +27 -58
- package/src/bin/sd-cli.ts +54 -220
- package/src/build-tool/SdCliCacheCompilerHost.ts +71 -0
- package/src/build-tool/SdCliNgCacheCompilerHost.ts +50 -0
- package/src/build-tool/SdCliPackageLinter.ts +54 -0
- package/src/builder/SdCliJsLibBuilder.ts +66 -0
- package/src/builder/SdCliTsLibBuilder.ts +335 -0
- package/src/commons.ts +15 -124
- package/src/entry-points/SdCliWorkspace.ts +222 -0
- package/src/packages/SdCliPackage.ts +111 -0
- package/src/utils/SdBuildResultUtil.ts +43 -0
- package/tsconfig-build.json +9 -0
- package/tsconfig.json +7 -18
- package/.eslintrc.js +0 -19
- package/dist-node/bin/sd-cli.js +0 -197
- package/dist-node/bin/sd-cli.js.map +0 -1
- package/dist-node/build-tools/SdCliCordova.js +0 -144
- package/dist-node/build-tools/SdCliCordova.js.map +0 -1
- package/dist-node/build-tools/SdCliIndexFileGenerator.js +0 -51
- package/dist-node/build-tools/SdCliIndexFileGenerator.js.map +0 -1
- package/dist-node/build-tools/SdCliNgModuleFilesGenerator.js +0 -675
- package/dist-node/build-tools/SdCliNgModuleFilesGenerator.js.map +0 -1
- package/dist-node/build-tools/metadata/SdAotMetadataReader.js +0 -274
- package/dist-node/build-tools/metadata/SdAotMetadataReader.js.map +0 -1
- package/dist-node/build-tools/metadata/SdIvyMetadataReader.js +0 -124
- package/dist-node/build-tools/metadata/SdIvyMetadataReader.js.map +0 -1
- package/dist-node/build-tools/metadata/SdMetadataError.js +0 -13
- package/dist-node/build-tools/metadata/SdMetadataError.js.map +0 -1
- package/dist-node/build-tools/metadata/SdMyMetadataReader.js +0 -321
- package/dist-node/build-tools/metadata/SdMyMetadataReader.js.map +0 -1
- package/dist-node/builders/SdCliJavascriptLinter.js +0 -65
- package/dist-node/builders/SdCliJavascriptLinter.js.map +0 -1
- package/dist-node/builders/SdCliNgClientBuilder.js +0 -637
- package/dist-node/builders/SdCliNgClientBuilder.js.map +0 -1
- package/dist-node/builders/SdCliNgLibraryBuilder.js +0 -217
- package/dist-node/builders/SdCliNgLibraryBuilder.js.map +0 -1
- package/dist-node/builders/SdCliPublisher.js +0 -129
- package/dist-node/builders/SdCliPublisher.js.map +0 -1
- package/dist-node/builders/SdCliServerBuilder.js +0 -452
- package/dist-node/builders/SdCliServerBuilder.js.map +0 -1
- package/dist-node/builders/SdCliTypescriptBuilder.js +0 -347
- package/dist-node/builders/SdCliTypescriptBuilder.js.map +0 -1
- package/dist-node/commons.js +0 -3
- package/dist-node/commons.js.map +0 -1
- package/dist-node/entry-points/SdCliLocalUpdater.js +0 -88
- package/dist-node/entry-points/SdCliLocalUpdater.js.map +0 -1
- package/dist-node/entry-points/SdCliPrepare.js +0 -56
- package/dist-node/entry-points/SdCliPrepare.js.map +0 -1
- package/dist-node/entry-points/SdCliProject.js +0 -302
- package/dist-node/entry-points/SdCliProject.js.map +0 -1
- package/dist-node/packages/SdCliClientPackage.js +0 -91
- package/dist-node/packages/SdCliClientPackage.js.map +0 -1
- package/dist-node/packages/SdCliLibraryPackage.js +0 -99
- package/dist-node/packages/SdCliLibraryPackage.js.map +0 -1
- package/dist-node/packages/SdCliPackageBase.js +0 -33
- package/dist-node/packages/SdCliPackageBase.js.map +0 -1
- package/dist-node/packages/SdCliServerPackage.js +0 -69
- package/dist-node/packages/SdCliServerPackage.js.map +0 -1
- package/dist-node/packages/SdCliUnknownPackage.js +0 -15
- package/dist-node/packages/SdCliUnknownPackage.js.map +0 -1
- package/dist-node/utils/SdCliFileCrypto.js +0 -76
- package/dist-node/utils/SdCliFileCrypto.js.map +0 -1
- package/dist-node/utils/SdProjectConfigUtil.js +0 -62
- package/dist-node/utils/SdProjectConfigUtil.js.map +0 -1
- package/dist-node/utils/SdTsDiagnosticUtil.js +0 -45
- package/dist-node/utils/SdTsDiagnosticUtil.js.map +0 -1
- package/dist-node/utils/SdWebpackUtil.js +0 -63
- package/dist-node/utils/SdWebpackUtil.js.map +0 -1
- package/dist-node/workers/client-ng-gen-worker.js +0 -57
- package/dist-node/workers/client-ng-gen-worker.js.map +0 -1
- package/dist-node/workers/lib-build-worker.js +0 -88
- package/dist-node/workers/lib-build-worker.js.map +0 -1
- package/dist-types/bin/sd-cli.d.ts +0 -3
- package/dist-types/bin/sd-cli.d.ts.map +0 -1
- package/dist-types/build-tools/SdCliCordova.d.ts +0 -15
- package/dist-types/build-tools/SdCliCordova.d.ts.map +0 -1
- package/dist-types/build-tools/SdCliIndexFileGenerator.d.ts +0 -13
- package/dist-types/build-tools/SdCliIndexFileGenerator.d.ts.map +0 -1
- package/dist-types/build-tools/SdCliNgModuleFilesGenerator.d.ts +0 -43
- package/dist-types/build-tools/SdCliNgModuleFilesGenerator.d.ts.map +0 -1
- package/dist-types/build-tools/metadata/SdAotMetadataReader.d.ts +0 -58
- package/dist-types/build-tools/metadata/SdAotMetadataReader.d.ts.map +0 -1
- package/dist-types/build-tools/metadata/SdIvyMetadataReader.d.ts +0 -43
- package/dist-types/build-tools/metadata/SdIvyMetadataReader.d.ts.map +0 -1
- package/dist-types/build-tools/metadata/SdMetadataError.d.ts +0 -7
- package/dist-types/build-tools/metadata/SdMetadataError.d.ts.map +0 -1
- package/dist-types/build-tools/metadata/SdMyMetadataReader.d.ts +0 -59
- package/dist-types/build-tools/metadata/SdMyMetadataReader.d.ts.map +0 -1
- package/dist-types/builders/SdCliJavascriptLinter.d.ts +0 -14
- package/dist-types/builders/SdCliJavascriptLinter.d.ts.map +0 -1
- package/dist-types/builders/SdCliNgClientBuilder.d.ts +0 -29
- package/dist-types/builders/SdCliNgClientBuilder.d.ts.map +0 -1
- package/dist-types/builders/SdCliNgLibraryBuilder.d.ts +0 -30
- package/dist-types/builders/SdCliNgLibraryBuilder.d.ts.map +0 -1
- package/dist-types/builders/SdCliPublisher.d.ts +0 -9
- package/dist-types/builders/SdCliPublisher.d.ts.map +0 -1
- package/dist-types/builders/SdCliServerBuilder.d.ts +0 -31
- package/dist-types/builders/SdCliServerBuilder.d.ts.map +0 -1
- package/dist-types/builders/SdCliTypescriptBuilder.d.ts +0 -56
- package/dist-types/builders/SdCliTypescriptBuilder.d.ts.map +0 -1
- package/dist-types/commons.d.ts +0 -134
- package/dist-types/commons.d.ts.map +0 -1
- package/dist-types/entry-points/SdCliLocalUpdater.d.ts +0 -12
- package/dist-types/entry-points/SdCliLocalUpdater.d.ts.map +0 -1
- package/dist-types/entry-points/SdCliPrepare.d.ts +0 -6
- package/dist-types/entry-points/SdCliPrepare.d.ts.map +0 -1
- package/dist-types/entry-points/SdCliProject.d.ts +0 -32
- package/dist-types/entry-points/SdCliProject.d.ts.map +0 -1
- package/dist-types/packages/SdCliClientPackage.d.ts +0 -17
- package/dist-types/packages/SdCliClientPackage.d.ts.map +0 -1
- package/dist-types/packages/SdCliLibraryPackage.d.ts +0 -20
- package/dist-types/packages/SdCliLibraryPackage.d.ts.map +0 -1
- package/dist-types/packages/SdCliPackageBase.d.ts +0 -11
- package/dist-types/packages/SdCliPackageBase.d.ts.map +0 -1
- package/dist-types/packages/SdCliServerPackage.d.ts +0 -16
- package/dist-types/packages/SdCliServerPackage.d.ts.map +0 -1
- package/dist-types/packages/SdCliUnknownPackage.d.ts +0 -9
- package/dist-types/packages/SdCliUnknownPackage.d.ts.map +0 -1
- package/dist-types/utils/SdCliFileCrypto.d.ts +0 -8
- package/dist-types/utils/SdCliFileCrypto.d.ts.map +0 -1
- package/dist-types/utils/SdProjectConfigUtil.d.ts +0 -7
- package/dist-types/utils/SdProjectConfigUtil.d.ts.map +0 -1
- package/dist-types/utils/SdTsDiagnosticUtil.d.ts +0 -6
- package/dist-types/utils/SdTsDiagnosticUtil.d.ts.map +0 -1
- package/dist-types/utils/SdWebpackUtil.d.ts +0 -7
- package/dist-types/utils/SdWebpackUtil.d.ts.map +0 -1
- package/dist-types/workers/client-ng-gen-worker.d.ts +0 -2
- package/dist-types/workers/client-ng-gen-worker.d.ts.map +0 -1
- package/dist-types/workers/lib-build-worker.d.ts +0 -2
- package/dist-types/workers/lib-build-worker.d.ts.map +0 -1
- package/schema/schema.json +0 -447
- package/sd-tsconfig.node.json +0 -18
- package/src/build-tools/SdCliCordova.ts +0 -240
- package/src/build-tools/SdCliIndexFileGenerator.ts +0 -61
- package/src/build-tools/SdCliNgModuleFilesGenerator.ts +0 -894
- package/src/build-tools/metadata/SdAotMetadataReader.ts +0 -374
- package/src/build-tools/metadata/SdIvyMetadataReader.ts +0 -183
- package/src/build-tools/metadata/SdMetadataError.ts +0 -7
- package/src/build-tools/metadata/SdMyMetadataReader.ts +0 -407
- package/src/builders/SdCliJavascriptLinter.ts +0 -81
- package/src/builders/SdCliNgClientBuilder.ts +0 -794
- package/src/builders/SdCliNgLibraryBuilder.ts +0 -301
- package/src/builders/SdCliPublisher.ts +0 -144
- package/src/builders/SdCliServerBuilder.ts +0 -555
- package/src/builders/SdCliTypescriptBuilder.ts +0 -552
- package/src/entry-points/SdCliLocalUpdater.ts +0 -114
- package/src/entry-points/SdCliPrepare.ts +0 -104
- package/src/entry-points/SdCliProject.ts +0 -405
- package/src/packages/SdCliClientPackage.ts +0 -111
- package/src/packages/SdCliLibraryPackage.ts +0 -118
- package/src/packages/SdCliPackageBase.ts +0 -34
- package/src/packages/SdCliServerPackage.ts +0 -85
- package/src/packages/SdCliUnknownPackage.ts +0 -14
- package/src/utils/SdCliFileCrypto.ts +0 -87
- package/src/utils/SdCliUtils.ts +0 -56
- package/src/utils/SdProjectConfigUtil.ts +0 -145
- package/src/utils/SdTsDiagnosticUtil.ts +0 -46
- package/src/utils/SdWebpackUtil.ts +0 -71
- package/src/workers/client-ng-gen-worker.ts +0 -63
- package/src/workers/lib-build-worker.ts +0 -97
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import * as ts from "typescript";
|
|
2
|
-
import { ISdAutoIndexConfig, ISdPackageBuildResult } from "../commons";
|
|
3
|
-
import * as path from "path";
|
|
4
|
-
import { SdTsDiagnosticUtil } from "../utils/SdTsDiagnosticUtil";
|
|
5
|
-
import { NgccProcessingCache } from "ng-packagr/lib/ng-package/ngcc-cache";
|
|
6
|
-
import { NgccProcessor } from "ng-packagr/lib/ngc/ngcc-processor";
|
|
7
|
-
import { EntryPointNode } from "ng-packagr/lib/ng-package/nodes";
|
|
8
|
-
import { ngccTransformCompilerHost } from "ng-packagr/lib/ts/ngcc-transform-compiler-host";
|
|
9
|
-
import { MetadataCollector, NgtscProgram } from "@angular/compiler-cli";
|
|
10
|
-
import { ITsBuildFileCache, ITsGenResult, SdCliTypescriptBuilder } from "./SdCliTypescriptBuilder";
|
|
11
|
-
import { NgCompiler } from "@angular/compiler-cli/src/ngtsc/core";
|
|
12
|
-
import { NeverEntryError, StringUtil } from "@simplysm/sd-core-common";
|
|
13
|
-
import { PathUtil } from "@simplysm/sd-core-node";
|
|
14
|
-
import * as os from "os";
|
|
15
|
-
import * as nodeSass from "node-sass";
|
|
16
|
-
import { SdCliNgModuleFilesGenerator } from "../build-tools/SdCliNgModuleFilesGenerator";
|
|
17
|
-
import { OptimizeFor } from "@angular/compiler-cli/src/ngtsc/typecheck/api";
|
|
18
|
-
import { ModuleMetadata } from "@angular/compiler-cli/src/metadata/schema";
|
|
19
|
-
|
|
20
|
-
export class SdCliNgLibraryBuilder extends SdCliTypescriptBuilder {
|
|
21
|
-
protected _ngProgram?: NgtscProgram;
|
|
22
|
-
protected _ngCompiler?: NgCompiler;
|
|
23
|
-
private readonly _ngccProcessingCache = new NgccProcessingCache();
|
|
24
|
-
|
|
25
|
-
private readonly _moduleFilesGenerator = new SdCliNgModuleFilesGenerator(this.rootPath);
|
|
26
|
-
|
|
27
|
-
protected override readonly _fileCache = new Map<string, (ITsBuildFileCache & { scssDependencies?: string[] })>();
|
|
28
|
-
|
|
29
|
-
public constructor(public rootPath: string,
|
|
30
|
-
public tsconfigFilePath: string,
|
|
31
|
-
skipProcesses: ("emit" | "check" | "lint" | "genIndex" | "genNgModule")[],
|
|
32
|
-
public autoIndexConfig: ISdAutoIndexConfig | undefined) {
|
|
33
|
-
super(rootPath, tsconfigFilePath, skipProcesses as ("emit" | "check" | "lint" | "genIndex")[], autoIndexConfig);
|
|
34
|
-
this.skipProcesses = skipProcesses;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
protected override async _runProgramAsync(dirtyFilePaths: string[]): Promise<ISdPackageBuildResult[]> {
|
|
38
|
-
this._logger.debug("빌드", dirtyFilePaths);
|
|
39
|
-
|
|
40
|
-
if (!this._ngCompiler) throw new NeverEntryError();
|
|
41
|
-
if (!this._builder) throw new NeverEntryError();
|
|
42
|
-
|
|
43
|
-
const diagnostics: ts.Diagnostic[] = [];
|
|
44
|
-
|
|
45
|
-
if (!this.skipProcesses.includes("check")) {
|
|
46
|
-
diagnostics.push(
|
|
47
|
-
...this._ngCompiler.getOptionDiagnostics(),
|
|
48
|
-
...this._builder.getOptionsDiagnostics(),
|
|
49
|
-
...this._builder.getGlobalDiagnostics()
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
await this._ngCompiler.analyzeAsync();
|
|
53
|
-
|
|
54
|
-
for (const sourceFile of this._builder.getSourceFiles()) {
|
|
55
|
-
if (this._ngCompiler.ignoreForDiagnostics.has(sourceFile)) continue;
|
|
56
|
-
if (sourceFile.isDeclarationFile) continue;
|
|
57
|
-
|
|
58
|
-
diagnostics.push(
|
|
59
|
-
...this._builder.getSyntacticDiagnostics(sourceFile),
|
|
60
|
-
...this._builder.getSemanticDiagnostics(sourceFile),
|
|
61
|
-
...this._ngCompiler.getDiagnosticsForFile(sourceFile, OptimizeFor.WholeProgram)
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (!this.skipProcesses.includes("emit")) {
|
|
67
|
-
const transformers = this._ngCompiler.prepareEmit().transformers;
|
|
68
|
-
|
|
69
|
-
for (const filePath of dirtyFilePaths) {
|
|
70
|
-
const sourceFile = this._builder.getSourceFile(filePath);
|
|
71
|
-
if (!sourceFile) continue;
|
|
72
|
-
if (this._ngCompiler.ignoreForEmit.has(sourceFile)) continue;
|
|
73
|
-
if (sourceFile.isDeclarationFile) continue;
|
|
74
|
-
|
|
75
|
-
this._builder.emit(sourceFile, undefined, undefined, undefined, transformers);
|
|
76
|
-
|
|
77
|
-
if (this._program!.getCompilerOptions().declaration) {
|
|
78
|
-
if (sourceFile.fileName.endsWith(".ts") && !sourceFile.fileName.endsWith(".d.ts")) {
|
|
79
|
-
const metadata = this._getMetadata(sourceFile);
|
|
80
|
-
if (metadata) {
|
|
81
|
-
this._writeMetadataFile(sourceFile, metadata);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const result = diagnostics.map((item) => SdTsDiagnosticUtil.convertDiagnosticsToResult(item)).filterExists();
|
|
89
|
-
|
|
90
|
-
this._logger.debug("빌드 결과", result);
|
|
91
|
-
|
|
92
|
-
return result;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
private _writeMetadataFile(sourceFile: ts.SourceFile, metadata: ModuleMetadata): void {
|
|
96
|
-
const metadataText = JSON.stringify({
|
|
97
|
-
...metadata,
|
|
98
|
-
importAs: this.npmConfig.name
|
|
99
|
-
});
|
|
100
|
-
const outFileName = path.resolve(
|
|
101
|
-
this._program!.getCompilerOptions().declarationDir!,
|
|
102
|
-
path.relative(path.resolve(this.rootPath, "src"), sourceFile.fileName)
|
|
103
|
-
).replace(/\.ts$/, ".sd-metadata.json");
|
|
104
|
-
this._cacheCompilerHost!.writeFile(outFileName, metadataText, false, undefined, [sourceFile]);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
private _getMetadata(sourceFile: ts.SourceFile): ModuleMetadata | undefined {
|
|
108
|
-
return new MetadataCollector().getMetadata(sourceFile, false);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
public override getParsedTsconfig(): ts.ParsedCommandLine {
|
|
112
|
-
return ts.parseJsonConfigFileContent(this._tsconfig, ts.sys, this.rootPath, this._tsconfig.angularCompilerOptions);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
public override configProgram(parsedTsconfig: ts.ParsedCommandLine): void {
|
|
116
|
-
this._ngProgram = new NgtscProgram(
|
|
117
|
-
parsedTsconfig.fileNames,
|
|
118
|
-
parsedTsconfig.options,
|
|
119
|
-
this._cacheCompilerHost!,
|
|
120
|
-
this._ngProgram
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
this._ngCompiler = this._ngProgram.compiler;
|
|
124
|
-
this._program = this._ngProgram.getTsProgram();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
public override getSemanticDiagnosticsOfNextAffectedFiles(): string[] | undefined {
|
|
128
|
-
const builder = this._builder as ts.SemanticDiagnosticsBuilderProgram;
|
|
129
|
-
const affectedFilePaths: string[] = [];
|
|
130
|
-
const result = builder.getSemanticDiagnosticsOfNextAffectedFile(undefined, (sourceFile) => {
|
|
131
|
-
if (this._ngCompiler!.ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith(".ngtypecheck.ts")) {
|
|
132
|
-
const originalFilename = sourceFile.fileName.slice(0, -15) + ".ts";
|
|
133
|
-
const originalSourceFile = builder.getSourceFile(originalFilename);
|
|
134
|
-
if (originalSourceFile) {
|
|
135
|
-
affectedFilePaths.push(originalSourceFile.fileName);
|
|
136
|
-
}
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
return false;
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
if (result && "fileName" in result.affected) {
|
|
143
|
-
affectedFilePaths.push(result.affected.fileName);
|
|
144
|
-
return affectedFilePaths.distinct();
|
|
145
|
-
}
|
|
146
|
-
if (!result) {
|
|
147
|
-
return undefined;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return [];
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
protected override _deleteFileCaches(filePaths: string[]): void {
|
|
154
|
-
super._deleteFileCaches(filePaths);
|
|
155
|
-
this._moduleFilesGenerator.deleteFileCaches(filePaths);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
public async generateAdditionalFilesAsync(dirtyFilePaths: string[], watch: boolean): Promise<ITsGenResult> {
|
|
159
|
-
const result: ITsGenResult = { dirtyFilePaths: [], result: [] };
|
|
160
|
-
|
|
161
|
-
// index.ts 파일 생성
|
|
162
|
-
const genIndexResult = await super._generateIndexFileAsync(watch);
|
|
163
|
-
result.result.push(...genIndexResult.result);
|
|
164
|
-
result.dirtyFilePaths.push(...genIndexResult.dirtyFilePaths);
|
|
165
|
-
|
|
166
|
-
// Angular Module 및 RoutingModule 생성
|
|
167
|
-
const genModuleResult = await this._generateModuleFilesAsync(
|
|
168
|
-
[...dirtyFilePaths, ...genIndexResult.dirtyFilePaths].distinct(),
|
|
169
|
-
watch
|
|
170
|
-
);
|
|
171
|
-
result.result.push(...genModuleResult.result);
|
|
172
|
-
result.dirtyFilePaths.push(...genModuleResult.dirtyFilePaths);
|
|
173
|
-
|
|
174
|
-
// 'Angular Module 및 RoutingModule 생성'중에 변경사항이 있다면, index.ts 다시 생성
|
|
175
|
-
if (genModuleResult.dirtyFilePaths.length > 0) {
|
|
176
|
-
const newGenIndexResult = await super._generateIndexFileAsync(watch);
|
|
177
|
-
result.result.push(...newGenIndexResult.result);
|
|
178
|
-
result.dirtyFilePaths.push(...newGenIndexResult.dirtyFilePaths);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return {
|
|
182
|
-
dirtyFilePaths: result.dirtyFilePaths.distinct(),
|
|
183
|
-
result: result.result.distinct()
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
private async _generateModuleFilesAsync(dirtyFilePaths: string[], watch: boolean): Promise<ITsGenResult> {
|
|
188
|
-
this._logger.debug("Angular Module, RoutingModule 생성", dirtyFilePaths);
|
|
189
|
-
|
|
190
|
-
const result: ITsGenResult = { dirtyFilePaths: [], result: [] };
|
|
191
|
-
if (this.skipProcesses.includes("genNgModule")) return result;
|
|
192
|
-
|
|
193
|
-
const reloadResult = await this._moduleFilesGenerator.reloadSourceFilesAsync(
|
|
194
|
-
dirtyFilePaths,
|
|
195
|
-
this._cacheCompilerHost!,
|
|
196
|
-
this._moduleResolutionCache!,
|
|
197
|
-
this._ngProgram!
|
|
198
|
-
);
|
|
199
|
-
result.result.push(...reloadResult.result);
|
|
200
|
-
|
|
201
|
-
if (!reloadResult.changed) return result;
|
|
202
|
-
|
|
203
|
-
const generateResult = await this._moduleFilesGenerator.generateAsync();
|
|
204
|
-
result.result.push(...generateResult.result);
|
|
205
|
-
if (generateResult.changedFilePaths.length > 0) {
|
|
206
|
-
const reloadChangedProgramResult = await this.reloadChangedProgramAsync(generateResult.changedFilePaths, watch);
|
|
207
|
-
result.dirtyFilePaths = reloadChangedProgramResult.dirtyFilePaths;
|
|
208
|
-
result.result.push(...reloadChangedProgramResult.result);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
this._logger.debug("Angular Module, RoutingModule 생성 결과", result);
|
|
212
|
-
|
|
213
|
-
return result;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
protected override async _createCacheCompilerHostAsync(parsedTsconfig: ts.ParsedCommandLine, moduleResolutionCache: ts.ModuleResolutionCache): Promise<ts.CompilerHost> {
|
|
217
|
-
const tsCacheCompilerHost = await super._createCacheCompilerHostAsync(parsedTsconfig, moduleResolutionCache);
|
|
218
|
-
|
|
219
|
-
const ngccProcessor = new NgccProcessor(
|
|
220
|
-
this._ngccProcessingCache,
|
|
221
|
-
this.tsconfigFilePath,
|
|
222
|
-
parsedTsconfig.options,
|
|
223
|
-
parsedTsconfig.fileNames.map((item) => ({ url: item }) as EntryPointNode)
|
|
224
|
-
);
|
|
225
|
-
|
|
226
|
-
await ngccProcessor.process();
|
|
227
|
-
|
|
228
|
-
const ngCompilerHost = ngccTransformCompilerHost(
|
|
229
|
-
tsCacheCompilerHost,
|
|
230
|
-
parsedTsconfig.options,
|
|
231
|
-
ngccProcessor,
|
|
232
|
-
moduleResolutionCache
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
const resultCompilerHost = { ...ngCompilerHost };
|
|
236
|
-
|
|
237
|
-
resultCompilerHost.getSourceFile = (fileName: string, languageVersion: ts.ScriptTarget) => {
|
|
238
|
-
const cache = this._fileCache.getOrCreate(PathUtil.posix(fileName), {});
|
|
239
|
-
if (!cache.sourceFile) {
|
|
240
|
-
const orgContent = ngCompilerHost.readFile.call(resultCompilerHost, fileName);
|
|
241
|
-
if (StringUtil.isNullOrEmpty(orgContent)) {
|
|
242
|
-
cache.sourceFile = undefined;
|
|
243
|
-
cache.scssDependencies = undefined;
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
const scssResult = this._replaceScssToCss(fileName, orgContent);
|
|
247
|
-
cache.sourceFile = ts.createSourceFile(fileName, scssResult.content, languageVersion);
|
|
248
|
-
cache.scssDependencies = scssResult.dependencies;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
return cache.sourceFile;
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
return resultCompilerHost;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
private _replaceScssToCss(filePath: string, content: string): { content: string; dependencies: string[] } {
|
|
258
|
-
const scssRegex = /\/\* *language=SCSS *\*\/ *[`"'](((?!['"`]\)?[\],][,;]?[\r\n\\])(.|\r|\n))*)['"`]/;
|
|
259
|
-
|
|
260
|
-
const matches = content.match(new RegExp(scssRegex, "gi"));
|
|
261
|
-
if (!matches) {
|
|
262
|
-
return { content, dependencies: [] };
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
try {
|
|
266
|
-
const results = matches.map((match) => nodeSass.renderSync({
|
|
267
|
-
file: filePath,
|
|
268
|
-
data: scssRegex.exec(match)?.[1],
|
|
269
|
-
precision: 8,
|
|
270
|
-
includePaths: [],
|
|
271
|
-
outputStyle: "expanded",
|
|
272
|
-
sourceMapEmbed: false,
|
|
273
|
-
sourceMap: false
|
|
274
|
-
}));
|
|
275
|
-
|
|
276
|
-
const deps = results.mapMany((result) => result.stats.includedFiles).map((item) => path.resolve(item));
|
|
277
|
-
|
|
278
|
-
let i = 0;
|
|
279
|
-
const newContent = content.replace(new RegExp(scssRegex, "gi"), () => {
|
|
280
|
-
let result = "`" + results[i].css.toString() + "`";
|
|
281
|
-
const prev = matches[i];
|
|
282
|
-
|
|
283
|
-
const diffCount = Array.from(prev).filter((item) => item === "\n").length
|
|
284
|
-
- Array.from(result).filter((item) => item === "\n").length;
|
|
285
|
-
|
|
286
|
-
for (let j = 0; j < diffCount; j++) {
|
|
287
|
-
result += os.EOL;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
i += 1;
|
|
291
|
-
return result;
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
return { content: newContent, dependencies: deps };
|
|
295
|
-
}
|
|
296
|
-
catch (err) {
|
|
297
|
-
this._logger.error(filePath, err);
|
|
298
|
-
return { content, dependencies: [] };
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { ISdFtpPublishConfig, TSdPublishConfig } from "../commons";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import { NumberUtil, StringUtil } from "@simplysm/sd-core-common";
|
|
4
|
-
import { FsUtil, PathUtil } from "@simplysm/sd-core-node";
|
|
5
|
-
import { SdFtpStorage, SdSFtpStorage } from "@simplysm/sd-storage";
|
|
6
|
-
import * as msRestNodeAuth from "@azure/ms-rest-nodeauth";
|
|
7
|
-
import { WebSiteManagementClient } from "@azure/arm-appservice";
|
|
8
|
-
import * as xml2js from "xml2js";
|
|
9
|
-
import * as URL from "url";
|
|
10
|
-
|
|
11
|
-
export class SdCliPublisher {
|
|
12
|
-
public constructor(private readonly _config: TSdPublishConfig,
|
|
13
|
-
private readonly _distPath: string,
|
|
14
|
-
private readonly _version?: string) {
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
public async runAsync(): Promise<void> {
|
|
18
|
-
if (this._config.type === "sftp") {
|
|
19
|
-
const publishConfig = this._config;
|
|
20
|
-
const sftp = new SdSFtpStorage();
|
|
21
|
-
await sftp.connectAsync({
|
|
22
|
-
host: publishConfig.host,
|
|
23
|
-
port: publishConfig.port,
|
|
24
|
-
username: publishConfig.username,
|
|
25
|
-
password: publishConfig.password
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
try {
|
|
29
|
-
// 결과 파일 업로드
|
|
30
|
-
await sftp.uploadDirAsync(this._distPath, publishConfig.path);
|
|
31
|
-
await sftp.closeAsync();
|
|
32
|
-
}
|
|
33
|
-
catch (err) {
|
|
34
|
-
try {
|
|
35
|
-
await sftp.closeAsync();
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
38
|
-
}
|
|
39
|
-
throw err;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
else if (this._config.type === "local-directory") {
|
|
43
|
-
const targetRootPath = this._config.path.replace(/%([^%]*)%/g, (item) => {
|
|
44
|
-
const envName = item.replace(/%/g, "");
|
|
45
|
-
if (!StringUtil.isNullOrEmpty(this._version) && envName === "SD_VERSION") {
|
|
46
|
-
return this._version;
|
|
47
|
-
}
|
|
48
|
-
return process.env[envName] ?? item;
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const filePaths = await FsUtil.globAsync(path.resolve(this._distPath, "**", "*"), { dot: true, nodir: true });
|
|
52
|
-
|
|
53
|
-
await filePaths.parallelAsync(async (filePath) => {
|
|
54
|
-
const relativeFilePath = path.relative(this._distPath, filePath);
|
|
55
|
-
const targetPath = PathUtil.posix(targetRootPath, relativeFilePath);
|
|
56
|
-
|
|
57
|
-
await FsUtil.copyAsync(filePath, targetPath);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
else if (this._config.type === "ftp") {
|
|
61
|
-
const publishConfig = this._config;
|
|
62
|
-
const ftp = new SdFtpStorage();
|
|
63
|
-
await ftp.connectAsync({
|
|
64
|
-
host: publishConfig.host,
|
|
65
|
-
port: publishConfig.port,
|
|
66
|
-
username: publishConfig.username,
|
|
67
|
-
password: publishConfig.password,
|
|
68
|
-
secure: publishConfig.secure
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
try {
|
|
72
|
-
// 결과 파일 업로드
|
|
73
|
-
await ftp.uploadDirAsync(this._distPath, publishConfig.path);
|
|
74
|
-
|
|
75
|
-
await ftp.closeAsync();
|
|
76
|
-
}
|
|
77
|
-
catch (err) {
|
|
78
|
-
try {
|
|
79
|
-
await ftp.closeAsync();
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
}
|
|
83
|
-
throw err;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
87
|
-
else if (this._config.type === "azure-app-service") {
|
|
88
|
-
const creds = await msRestNodeAuth.loginWithUsernamePassword(this._config.username, this._config.password);
|
|
89
|
-
const client = new WebSiteManagementClient(creds, this._config.subscriptionId);
|
|
90
|
-
|
|
91
|
-
await client.webApps.stop(this._config.resourceGroupName, this._config.serviceName);
|
|
92
|
-
|
|
93
|
-
try {
|
|
94
|
-
const webappFtpXmlStream = await client.webApps.listPublishingProfileXmlWithSecrets(this._config.resourceGroupName, this._config.serviceName, {
|
|
95
|
-
format: "Ftp"
|
|
96
|
-
});
|
|
97
|
-
const xmlObj = await xml2js.parseStringPromise(webappFtpXmlStream.readableStreamBody!.read());
|
|
98
|
-
const xmlFtpConfig = xmlObj.publishData.publishProfile.find((item: any) => item.$.publishMethod === "FTP")!.$;
|
|
99
|
-
|
|
100
|
-
const urlObj = URL.parse(xmlFtpConfig.publishUrl, false);
|
|
101
|
-
|
|
102
|
-
const ftpConfig: ISdFtpPublishConfig = {
|
|
103
|
-
type: "ftp",
|
|
104
|
-
host: urlObj.host!,
|
|
105
|
-
port: NumberUtil.parseInt(urlObj.port),
|
|
106
|
-
path: this._config.path.startsWith("/") ? this._config.path : path.join(urlObj.pathname ?? "", this._config.path),
|
|
107
|
-
username: xmlFtpConfig.userName,
|
|
108
|
-
password: xmlFtpConfig.userPWD,
|
|
109
|
-
secure: true
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const ftp = new SdFtpStorage();
|
|
113
|
-
await ftp.connectAsync({
|
|
114
|
-
host: ftpConfig.host,
|
|
115
|
-
port: ftpConfig.port,
|
|
116
|
-
username: ftpConfig.username,
|
|
117
|
-
password: ftpConfig.password,
|
|
118
|
-
secure: ftpConfig.secure
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
try {
|
|
122
|
-
// 결과 파일 업로드
|
|
123
|
-
await ftp.uploadDirAsync(this._distPath, ftpConfig.path);
|
|
124
|
-
|
|
125
|
-
await ftp.closeAsync();
|
|
126
|
-
}
|
|
127
|
-
catch (err) {
|
|
128
|
-
try {
|
|
129
|
-
await ftp.closeAsync();
|
|
130
|
-
}
|
|
131
|
-
catch {
|
|
132
|
-
}
|
|
133
|
-
throw err;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
await client.webApps.start(this._config.resourceGroupName, this._config.serviceName);
|
|
137
|
-
}
|
|
138
|
-
catch (err) {
|
|
139
|
-
await client.webApps.start(this._config.resourceGroupName, this._config.serviceName);
|
|
140
|
-
throw err;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|