@simplysm/sd-cli 10.0.4 → 10.0.22
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 +1 -1
- package/dist/SdLinter.d.ts +5 -0
- package/dist/SdLinter.js.map +1 -0
- package/dist/SdLinter.mjs +37 -0
- package/dist/SdTsIncrementalBuilder.d.ts +16 -0
- package/dist/SdTsIncrementalBuilder.js.map +1 -0
- package/dist/SdTsIncrementalBuilder.mjs +54 -0
- package/dist/build-cluster.js.map +1 -1
- package/dist/build-cluster.mjs +124 -0
- package/dist/builders/SdCliClientBuilder.d.ts +13 -0
- package/dist/builders/SdCliClientBuilder.js.map +1 -0
- package/dist/builders/SdCliClientBuilder.mjs +167 -0
- package/dist/builders/SdCliJsLibLinter.d.ts +3 -7
- package/dist/builders/SdCliJsLibLinter.js.map +1 -1
- package/dist/builders/{SdCliJsLibLinter.js → SdCliJsLibLinter.mjs} +8 -17
- package/dist/builders/SdCliServerBuilder.d.ts +14 -0
- package/dist/builders/SdCliServerBuilder.js.map +1 -0
- package/dist/builders/SdCliServerBuilder.mjs +171 -0
- package/dist/builders/SdCliTsLibBuilder.d.ts +3 -10
- package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
- package/dist/builders/SdCliTsLibBuilder.mjs +75 -0
- package/dist/commons.d.ts +28 -2
- package/dist/entry/SdCliLocalUpdate.d.ts +7 -0
- package/dist/entry/SdCliLocalUpdate.js.map +1 -0
- package/dist/entry/SdCliLocalUpdate.mjs +55 -0
- package/dist/entry/SdCliProject.d.ts +1 -0
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/entry/{SdCliProject.js → SdCliProject.mjs} +94 -10
- package/dist/sd-cli.js.map +1 -1
- package/dist/{sd-cli.js → sd-cli.mjs} +16 -0
- package/dist/sd-core-common/src/decorators/NotifyPropertyChange.d.ts +20 -0
- package/dist/sd-core-common/src/decorators/NotifyPropertyChange.js.map +1 -0
- package/dist/sd-core-common/src/decorators/NotifyPropertyChange.mjs +12 -0
- package/dist/sd-core-common/src/decorators/PropertyGetSetDecoratorBase.d.ts +43 -0
- package/dist/sd-core-common/src/decorators/PropertyGetSetDecoratorBase.js.map +1 -0
- package/dist/sd-core-common/src/decorators/PropertyGetSetDecoratorBase.mjs +54 -0
- package/dist/sd-core-common/src/decorators/PropertyValidate.d.ts +16 -0
- package/dist/sd-core-common/src/decorators/PropertyValidate.js.map +1 -0
- package/dist/sd-core-common/src/decorators/PropertyValidate.mjs +26 -0
- package/dist/sd-core-common/src/decorators/decorator-return-types.d.ts +14 -0
- package/dist/sd-core-common/src/decorators/decorator-return-types.js.map +1 -0
- package/dist/sd-core-common/src/decorators/decorator-return-types.mjs +2 -0
- package/dist/sd-core-common/src/errors/ArgumentError.d.ts +10 -0
- package/dist/sd-core-common/src/errors/ArgumentError.js.map +1 -0
- package/dist/sd-core-common/src/errors/ArgumentError.mjs +13 -0
- package/dist/sd-core-common/src/errors/NeverEntryError.d.ts +10 -0
- package/dist/sd-core-common/src/errors/NeverEntryError.js.map +1 -0
- package/dist/sd-core-common/src/errors/NeverEntryError.mjs +13 -0
- package/dist/sd-core-common/src/errors/NotImplementError.d.ts +10 -0
- package/dist/sd-core-common/src/errors/NotImplementError.js.map +1 -0
- package/dist/sd-core-common/src/errors/NotImplementError.mjs +13 -0
- package/dist/sd-core-common/src/errors/SdError.d.ts +23 -0
- package/dist/sd-core-common/src/errors/SdError.js.map +1 -0
- package/dist/sd-core-common/src/errors/SdError.mjs +40 -0
- package/dist/sd-core-common/src/errors/TimeoutError.d.ts +11 -0
- package/dist/sd-core-common/src/errors/TimeoutError.js.map +1 -0
- package/dist/sd-core-common/src/errors/TimeoutError.mjs +16 -0
- package/dist/sd-core-common/src/extensions/ArrayExtension.d.ts +147 -0
- package/dist/sd-core-common/src/extensions/ArrayExtension.js.map +1 -0
- package/dist/sd-core-common/src/extensions/ArrayExtension.mjs +448 -0
- package/dist/sd-core-common/src/extensions/MapExtension.d.ts +4 -0
- package/dist/sd-core-common/src/extensions/MapExtension.js.map +1 -0
- package/dist/sd-core-common/src/extensions/MapExtension.mjs +15 -0
- package/dist/sd-core-common/src/extensions/SetExtension.d.ts +3 -0
- package/dist/sd-core-common/src/extensions/SetExtension.js.map +1 -0
- package/dist/sd-core-common/src/extensions/SetExtension.mjs +10 -0
- package/dist/sd-core-common/src/index.d.ts +32 -0
- package/dist/sd-core-common/src/index.js.map +1 -0
- package/dist/sd-core-common/src/index.mjs +33 -0
- package/dist/sd-core-common/src/types/DateOnly.d.ts +135 -0
- package/dist/sd-core-common/src/types/DateOnly.js.map +1 -0
- package/dist/sd-core-common/src/types/DateOnly.mjs +220 -0
- package/dist/sd-core-common/src/types/DateTime.d.ts +42 -0
- package/dist/sd-core-common/src/types/DateTime.js.map +1 -0
- package/dist/sd-core-common/src/types/DateTime.mjs +156 -0
- package/dist/sd-core-common/src/types/DeepPartial.d.ts +3 -0
- package/dist/sd-core-common/src/types/DeepPartial.js.map +1 -0
- package/dist/sd-core-common/src/types/DeepPartial.mjs +2 -0
- package/dist/sd-core-common/src/types/ObjectSet.d.ts +4 -0
- package/dist/sd-core-common/src/types/ObjectSet.js.map +1 -0
- package/dist/sd-core-common/src/types/ObjectSet.mjs +18 -0
- package/dist/sd-core-common/src/types/Time.d.ts +27 -0
- package/dist/sd-core-common/src/types/Time.js.map +1 -0
- package/dist/sd-core-common/src/types/Time.mjs +108 -0
- package/dist/sd-core-common/src/types/Type.d.ts +7 -0
- package/dist/sd-core-common/src/types/Type.js.map +1 -0
- package/dist/sd-core-common/src/types/Type.mjs +2 -0
- package/dist/sd-core-common/src/types/UnwrappedType.d.ts +1 -0
- package/dist/sd-core-common/src/types/UnwrappedType.js.map +1 -0
- package/dist/sd-core-common/src/types/UnwrappedType.mjs +2 -0
- package/dist/sd-core-common/src/types/Uuid.d.ts +8 -0
- package/dist/sd-core-common/src/types/Uuid.js.map +1 -0
- package/dist/sd-core-common/src/types/Uuid.mjs +26 -0
- package/dist/sd-core-common/src/types/WrappedType.d.ts +1 -0
- package/dist/sd-core-common/src/types/WrappedType.js.map +1 -0
- package/dist/sd-core-common/src/types/WrappedType.mjs +2 -0
- package/dist/sd-core-common/src/utils/DateTimeFormatUtil.d.ts +12 -0
- package/dist/sd-core-common/src/utils/DateTimeFormatUtil.js.map +1 -0
- package/dist/sd-core-common/src/utils/DateTimeFormatUtil.mjs +67 -0
- package/dist/sd-core-common/src/utils/FunctionQueue.d.ts +8 -0
- package/dist/sd-core-common/src/utils/FunctionQueue.js.map +1 -0
- package/dist/sd-core-common/src/utils/FunctionQueue.mjs +46 -0
- package/dist/sd-core-common/src/utils/FunctionUtil.d.ts +6 -0
- package/dist/sd-core-common/src/utils/FunctionUtil.js.map +1 -0
- package/dist/sd-core-common/src/utils/FunctionUtil.mjs +31 -0
- package/dist/sd-core-common/src/utils/JsonConvert.d.ts +8 -0
- package/dist/sd-core-common/src/utils/JsonConvert.js.map +1 -0
- package/dist/sd-core-common/src/utils/JsonConvert.mjs +78 -0
- package/dist/sd-core-common/src/utils/MathUtil.d.ts +3 -0
- package/dist/sd-core-common/src/utils/MathUtil.js.map +1 -0
- package/dist/sd-core-common/src/utils/MathUtil.mjs +6 -0
- package/dist/sd-core-common/src/utils/NumberUtil.d.ts +6 -0
- package/dist/sd-core-common/src/utils/NumberUtil.js.map +1 -0
- package/dist/sd-core-common/src/utils/NumberUtil.mjs +32 -0
- package/dist/sd-core-common/src/utils/ObjectUtil.d.ts +80 -0
- package/dist/sd-core-common/src/utils/ObjectUtil.js.map +1 -0
- package/dist/sd-core-common/src/utils/ObjectUtil.mjs +452 -0
- package/dist/sd-core-common/src/utils/SdSyncEventEmitter.d.ts +6 -0
- package/dist/sd-core-common/src/utils/SdSyncEventEmitter.js.map +1 -0
- package/dist/sd-core-common/src/utils/SdSyncEventEmitter.mjs +27 -0
- package/dist/sd-core-common/src/utils/StringUtil.d.ts +8 -0
- package/dist/sd-core-common/src/utils/StringUtil.js.map +1 -0
- package/dist/sd-core-common/src/utils/StringUtil.mjs +77 -0
- package/dist/sd-core-common/src/utils/Wait.d.ts +4 -0
- package/dist/sd-core-common/src/utils/Wait.js.map +1 -0
- package/dist/sd-core-common/src/utils/Wait.mjs +23 -0
- package/dist/sd-core-node/src/index.d.ts +6 -0
- package/dist/sd-core-node/src/index.js.map +1 -0
- package/dist/sd-core-node/src/index.mjs +7 -0
- package/dist/sd-core-node/src/utils/FsUtil.d.ts +44 -0
- package/dist/sd-core-node/src/utils/FsUtil.js.map +1 -0
- package/dist/sd-core-node/src/utils/FsUtil.mjs +493 -0
- package/dist/sd-core-node/src/utils/Logger.d.ts +91 -0
- package/dist/sd-core-node/src/utils/Logger.js.map +1 -0
- package/dist/sd-core-node/src/utils/Logger.mjs +185 -0
- package/dist/sd-core-node/src/utils/PathUtil.d.ts +6 -0
- package/dist/sd-core-node/src/utils/PathUtil.js.map +1 -0
- package/dist/sd-core-node/src/utils/PathUtil.mjs +24 -0
- package/dist/sd-core-node/src/utils/SdFsWatcher.d.ts +15 -0
- package/dist/sd-core-node/src/utils/SdFsWatcher.js.map +1 -0
- package/dist/sd-core-node/src/utils/SdFsWatcher.mjs +43 -0
- package/dist/sd-core-node/src/utils/SdProcess.d.ts +5 -0
- package/dist/sd-core-node/src/utils/SdProcess.js.map +1 -0
- package/dist/sd-core-node/src/utils/SdProcess.mjs +36 -0
- package/dist/sd-orm-common/src/CaseQueryHelper.d.ts +12 -0
- package/dist/sd-orm-common/src/CaseQueryHelper.js.map +1 -0
- package/dist/sd-orm-common/src/CaseQueryHelper.mjs +19 -0
- package/dist/sd-orm-common/src/CaseWhenQueryHelper.d.ts +12 -0
- package/dist/sd-orm-common/src/CaseWhenQueryHelper.js.map +1 -0
- package/dist/sd-orm-common/src/CaseWhenQueryHelper.mjs +20 -0
- package/dist/sd-orm-common/src/DbContext.d.ts +81 -0
- package/dist/sd-orm-common/src/DbContext.js.map +1 -0
- package/dist/sd-orm-common/src/DbContext.mjs +635 -0
- package/dist/sd-orm-common/src/IDbConnection.d.ts +15 -0
- package/dist/sd-orm-common/src/IDbConnection.js.map +1 -0
- package/dist/sd-orm-common/src/IDbConnection.mjs +2 -0
- package/dist/sd-orm-common/src/IDbContextExecutor.d.ts +17 -0
- package/dist/sd-orm-common/src/IDbContextExecutor.js.map +1 -0
- package/dist/sd-orm-common/src/IDbContextExecutor.mjs +2 -0
- package/dist/sd-orm-common/src/IDbMigration.d.ts +4 -0
- package/dist/sd-orm-common/src/IDbMigration.js.map +1 -0
- package/dist/sd-orm-common/src/IDbMigration.mjs +2 -0
- package/dist/sd-orm-common/src/QueryBuilder.d.ts +48 -0
- package/dist/sd-orm-common/src/QueryBuilder.js.map +1 -0
- package/dist/sd-orm-common/src/QueryBuilder.mjs +1022 -0
- package/dist/sd-orm-common/src/QueryHelper.d.ts +75 -0
- package/dist/sd-orm-common/src/QueryHelper.js.map +1 -0
- package/dist/sd-orm-common/src/QueryHelper.mjs +627 -0
- package/dist/sd-orm-common/src/QueryUnit.d.ts +10 -0
- package/dist/sd-orm-common/src/QueryUnit.js.map +1 -0
- package/dist/sd-orm-common/src/QueryUnit.mjs +16 -0
- package/dist/sd-orm-common/src/Queryable.d.ts +105 -0
- package/dist/sd-orm-common/src/Queryable.js.map +1 -0
- package/dist/sd-orm-common/src/Queryable.mjs +1375 -0
- package/dist/sd-orm-common/src/SdOrmDataType.d.ts +21 -0
- package/dist/sd-orm-common/src/SdOrmDataType.js.map +1 -0
- package/dist/sd-orm-common/src/SdOrmDataType.mjs +2 -0
- package/dist/sd-orm-common/src/commons.d.ts +400 -0
- package/dist/sd-orm-common/src/commons.js.map +1 -0
- package/dist/sd-orm-common/src/commons.mjs +8 -0
- package/dist/sd-orm-common/src/decorators.d.ts +29 -0
- package/dist/sd-orm-common/src/decorators.js.map +1 -0
- package/dist/sd-orm-common/src/decorators.mjs +89 -0
- package/dist/sd-orm-common/src/index.d.ts +17 -0
- package/dist/sd-orm-common/src/index.js.map +1 -0
- package/dist/sd-orm-common/src/index.mjs +18 -0
- package/dist/sd-orm-common/src/models/SystemMigration.d.ts +3 -0
- package/dist/sd-orm-common/src/models/SystemMigration.js.map +1 -0
- package/dist/sd-orm-common/src/models/SystemMigration.mjs +13 -0
- package/dist/sd-orm-common/src/utils/DbDefinitionUtil.d.ts +14 -0
- package/dist/sd-orm-common/src/utils/DbDefinitionUtil.js.map +1 -0
- package/dist/sd-orm-common/src/utils/DbDefinitionUtil.mjs +66 -0
- package/dist/sd-orm-common/src/utils/SdOrmUtil.d.ts +8 -0
- package/dist/sd-orm-common/src/utils/SdOrmUtil.js.map +1 -0
- package/dist/sd-orm-common/src/utils/SdOrmUtil.mjs +248 -0
- package/dist/sd-orm-node/src/DbConnectionFactory.d.ts +4 -0
- package/dist/sd-orm-node/src/DbConnectionFactory.js.map +1 -0
- package/dist/sd-orm-node/src/DbConnectionFactory.mjs +17 -0
- package/dist/sd-orm-node/src/NodeDbContextExecutor.d.ts +19 -0
- package/dist/sd-orm-node/src/NodeDbContextExecutor.js.map +1 -0
- package/dist/sd-orm-node/src/NodeDbContextExecutor.mjs +71 -0
- package/dist/sd-orm-node/src/SdOrm.d.ts +10 -0
- package/dist/sd-orm-node/src/SdOrm.js.map +1 -0
- package/dist/sd-orm-node/src/SdOrm.mjs +25 -0
- package/dist/sd-orm-node/src/index.d.ts +4 -0
- package/dist/sd-orm-node/src/index.js.map +1 -0
- package/dist/sd-orm-node/src/index.mjs +5 -0
- package/dist/sd-orm-node-mssql/src/MssqlDbConnection.d.ts +25 -0
- package/dist/sd-orm-node-mssql/src/MssqlDbConnection.js.map +1 -0
- package/dist/sd-orm-node-mssql/src/MssqlDbConnection.mjs +321 -0
- package/dist/sd-orm-node-mssql/src/index.d.ts +2 -0
- package/dist/sd-orm-node-mssql/src/index.js.map +1 -0
- package/dist/sd-orm-node-mssql/src/index.mjs +3 -0
- package/dist/sd-orm-node-mysql/src/MysqlDbConnection.d.ts +22 -0
- package/dist/sd-orm-node-mysql/src/MysqlDbConnection.js.map +1 -0
- package/dist/sd-orm-node-mysql/src/MysqlDbConnection.mjs +200 -0
- package/dist/sd-orm-node-mysql/src/index.d.ts +2 -0
- package/dist/sd-orm-node-mysql/src/index.js.map +1 -0
- package/dist/sd-orm-node-mysql/src/index.mjs +3 -0
- package/dist/sd-orm-node-sqlite/src/SqliteDbConnection.d.ts +22 -0
- package/dist/sd-orm-node-sqlite/src/SqliteDbConnection.js.map +1 -0
- package/dist/sd-orm-node-sqlite/src/SqliteDbConnection.mjs +172 -0
- package/dist/sd-orm-node-sqlite/src/index.d.ts +2 -0
- package/dist/sd-orm-node-sqlite/src/index.js.map +1 -0
- package/dist/sd-orm-node-sqlite/src/index.mjs +3 -0
- package/dist/sd-service-common/src/commons-orm.d.ts +4 -0
- package/dist/sd-service-common/src/commons-orm.js.map +1 -0
- package/dist/sd-service-common/src/commons-orm.mjs +2 -0
- package/dist/sd-service-common/src/commons-smtp.d.ts +29 -0
- package/dist/sd-service-common/src/commons-smtp.js.map +1 -0
- package/dist/sd-service-common/src/commons-smtp.mjs +2 -0
- package/dist/sd-service-common/src/commons.d.ts +57 -0
- package/dist/sd-service-common/src/commons.js.map +1 -0
- package/dist/sd-service-common/src/commons.mjs +3 -0
- package/dist/sd-service-common/src/index.d.ts +3 -0
- package/dist/sd-service-common/src/index.js.map +1 -0
- package/dist/sd-service-common/src/index.mjs +4 -0
- package/dist/sd-service-server/src/ApiServiceError.d.ts +12 -0
- package/dist/sd-service-server/src/ApiServiceError.js.map +1 -0
- package/dist/sd-service-server/src/ApiServiceError.mjs +15 -0
- package/dist/sd-service-server/src/SdServiceServer.d.ts +39 -0
- package/dist/sd-service-server/src/SdServiceServer.js.map +1 -0
- package/dist/sd-service-server/src/SdServiceServer.mjs +513 -0
- package/dist/sd-service-server/src/commons.d.ts +23 -0
- package/dist/sd-service-server/src/commons.js.map +1 -0
- package/dist/sd-service-server/src/commons.mjs +3 -0
- package/dist/sd-service-server/src/index.d.ts +8 -0
- package/dist/sd-service-server/src/index.js.map +1 -0
- package/dist/sd-service-server/src/index.mjs +9 -0
- package/dist/sd-service-server/src/services/SdAutoUpdateService.d.ts +4 -0
- package/dist/sd-service-server/src/services/SdAutoUpdateService.js.map +1 -0
- package/dist/sd-service-server/src/services/SdAutoUpdateService.mjs +20 -0
- package/dist/sd-service-server/src/services/SdCryptoService.d.ts +7 -0
- package/dist/sd-service-server/src/services/SdCryptoService.js.map +1 -0
- package/dist/sd-service-server/src/services/SdCryptoService.mjs +39 -0
- package/dist/sd-service-server/src/services/SdOrmService.d.ts +22 -0
- package/dist/sd-service-server/src/services/SdOrmService.js.map +1 -0
- package/dist/sd-service-server/src/services/SdOrmService.mjs +115 -0
- package/dist/sd-service-server/src/services/SdSmtpClientService.d.ts +6 -0
- package/dist/sd-service-server/src/services/SdSmtpClientService.js.map +1 -0
- package/dist/sd-service-server/src/services/SdSmtpClientService.mjs +44 -0
- package/dist/sd-service-server/src/utils/SdServiceServerConfigUtil.d.ts +4 -0
- package/dist/sd-service-server/src/utils/SdServiceServerConfigUtil.js.map +1 -0
- package/dist/sd-service-server/src/utils/SdServiceServerConfigUtil.mjs +36 -0
- package/dist/server-worker.d.ts +1 -0
- package/dist/server-worker.js.map +1 -0
- package/dist/server-worker.mjs +36 -0
- package/package.json +12 -5
- package/src/SdLinter.ts +41 -0
- package/src/SdTsIncrementalBuilder.ts +75 -0
- package/src/build-cluster.ts +69 -18
- package/src/builders/SdCliClientBuilder.ts +189 -0
- package/src/builders/SdCliJsLibLinter.ts +11 -23
- package/src/builders/SdCliServerBuilder.ts +191 -0
- package/src/builders/SdCliTsLibBuilder.ts +33 -202
- package/src/commons.ts +33 -2
- package/src/entry/SdCliLocalUpdate.ts +70 -0
- package/src/entry/SdCliProject.ts +133 -17
- package/src/sd-cli.ts +20 -0
- package/src/server-worker.ts +45 -0
- package/tsconfig.json +1 -10
- package/dist/build-cluster.js +0 -75
- package/dist/builders/SdCliTsLibBuilder.js +0 -205
- /package/dist/{commons.js → commons.mjs} +0 -0
- /package/dist/utils/{SdCliBuildResultUtil.js → SdCliBuildResultUtil.mjs} +0 -0
- /package/dist/utils/{SdCliConfigUtil.js → SdCliConfigUtil.mjs} +0 -0
|
@@ -1,265 +1,96 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { FsUtil, Logger, PathUtil, SdFsWatcher } from "@simplysm/sd-core-node";
|
|
1
|
+
import { FsUtil, Logger, SdFsWatcher } from "@simplysm/sd-core-node";
|
|
3
2
|
import path from "path";
|
|
4
|
-
import {
|
|
5
|
-
import { SdCliBuildResultUtil } from "../utils/SdCliBuildResultUtil";
|
|
3
|
+
import { ISdCliBuilderResult } from "../commons";
|
|
6
4
|
import { EventEmitter } from "events";
|
|
7
|
-
import { ESLint } from "eslint";
|
|
8
5
|
import { FunctionQueue } from "@simplysm/sd-core-common";
|
|
6
|
+
import { SdTsIncrementalBuilder } from "../SdTsIncrementalBuilder";
|
|
7
|
+
import { SdLinter } from "../SdLinter";
|
|
9
8
|
|
|
10
9
|
export class SdCliTsLibBuilder extends EventEmitter {
|
|
11
10
|
private readonly _logger = Logger.get(["simplysm", "sd-cli", "SdCliTsLibBuilder"]);
|
|
12
|
-
private readonly _pkgName: string;
|
|
13
|
-
private readonly _writeFileCache = new Map<string, string>();
|
|
14
11
|
|
|
15
12
|
public constructor(private readonly _pkgPath: string) {
|
|
16
13
|
super();
|
|
17
|
-
this._pkgName = path.basename(_pkgPath);
|
|
18
14
|
}
|
|
19
15
|
|
|
20
16
|
public override on(event: "change", listener: () => void): this;
|
|
21
|
-
public override on(event: "complete", listener: (result:
|
|
17
|
+
public override on(event: "complete", listener: (result: ISdCliBuilderResult) => void): this;
|
|
22
18
|
public override on(event: string | symbol, listener: (...args: any[]) => void): this {
|
|
23
19
|
super.on(event, listener);
|
|
24
20
|
return this;
|
|
25
21
|
}
|
|
26
22
|
|
|
27
|
-
public async buildAsync(): Promise<
|
|
23
|
+
public async buildAsync(): Promise<ISdCliBuilderResult> {
|
|
28
24
|
this._debug("빌드 준비...");
|
|
29
|
-
|
|
30
|
-
const srcGlobPath = path.resolve(this._pkgPath, "src/**/*.ts");
|
|
31
|
-
|
|
32
|
-
const parsedTsConfig = ts.parseJsonConfigFileContent(
|
|
33
|
-
await FsUtil.readJsonAsync(path.resolve(this._pkgPath, "tsconfig.json")),
|
|
34
|
-
ts.sys,
|
|
35
|
-
this._pkgPath,
|
|
36
|
-
{
|
|
37
|
-
outDir: path.resolve(this._pkgPath, "dist"),
|
|
38
|
-
incremental: true,
|
|
39
|
-
tsBuildInfoFile: path.resolve(this._pkgPath, ".cache/tsbuildinfo.json"),
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
const host = ts.createIncrementalCompilerHost(parsedTsConfig.options, ts.sys);
|
|
25
|
+
const sdTsProgram = await SdTsIncrementalBuilder.createAsync(this._pkgPath, true);
|
|
44
26
|
|
|
45
27
|
this._debug("dist 초기화...");
|
|
46
28
|
await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
|
|
47
29
|
|
|
48
|
-
this._debug("
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
rootNames: srcFilePaths,
|
|
52
|
-
options: parsedTsConfig.options,
|
|
53
|
-
host: host
|
|
54
|
-
});
|
|
30
|
+
this._debug("BUILD...");
|
|
31
|
+
const buildResult = await sdTsProgram.buildAsync();
|
|
32
|
+
|
|
55
33
|
|
|
56
34
|
this._debug("LINT...");
|
|
57
|
-
const lintResults = await
|
|
35
|
+
const lintResults = await SdLinter.lintAsync(buildResult.affectedFilePaths, sdTsProgram.builderProgram!.getProgram());
|
|
58
36
|
|
|
59
37
|
this._debug(`빌드 완료`);
|
|
60
|
-
return
|
|
38
|
+
return {
|
|
39
|
+
affectedFilePaths: buildResult.affectedFilePaths,
|
|
40
|
+
buildResults: [...buildResult.results, ...lintResults]
|
|
41
|
+
};
|
|
61
42
|
}
|
|
62
43
|
|
|
63
44
|
public async watchAsync(): Promise<void> {
|
|
64
|
-
this.emit("change");
|
|
65
45
|
this._debug("빌드 준비...");
|
|
66
|
-
|
|
67
|
-
const srcGlobPath = path.resolve(this._pkgPath, "src/**/*.ts");
|
|
68
|
-
|
|
69
|
-
const parsedTsConfig = ts.parseJsonConfigFileContent(
|
|
70
|
-
await FsUtil.readJsonAsync(path.resolve(this._pkgPath, "tsconfig.json")),
|
|
71
|
-
ts.sys,
|
|
72
|
-
this._pkgPath,
|
|
73
|
-
{
|
|
74
|
-
outDir: path.resolve(this._pkgPath, "dist"),
|
|
75
|
-
incremental: true,
|
|
76
|
-
tsBuildInfoFile: path.resolve(this._pkgPath, ".cache/tsbuildinfo.json"),
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
const host = ts.createIncrementalCompilerHost(parsedTsConfig.options, ts.sys);
|
|
46
|
+
const sdTsProgram = await SdTsIncrementalBuilder.createAsync(this._pkgPath, true);
|
|
81
47
|
|
|
82
48
|
this._debug("dist 초기화...");
|
|
83
49
|
await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
|
|
84
50
|
|
|
85
|
-
this.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
options: parsedTsConfig.options,
|
|
90
|
-
host: host
|
|
91
|
-
});
|
|
51
|
+
this.emit("change");
|
|
52
|
+
|
|
53
|
+
this._debug("BUILD...");
|
|
54
|
+
const buildResult = await sdTsProgram.buildAsync();
|
|
92
55
|
|
|
93
56
|
this._debug("LINT...");
|
|
94
|
-
const lintResults = await
|
|
57
|
+
const lintResults = await SdLinter.lintAsync(buildResult.affectedFilePaths, sdTsProgram.builderProgram!.getProgram());
|
|
95
58
|
|
|
96
59
|
this._debug(`빌드 완료`);
|
|
97
60
|
this.emit("complete", {
|
|
98
|
-
affectedFilePaths:
|
|
99
|
-
buildResults: [...
|
|
61
|
+
affectedFilePaths: buildResult.affectedFilePaths,
|
|
62
|
+
buildResults: [...buildResult.results, ...lintResults]
|
|
100
63
|
});
|
|
101
64
|
|
|
65
|
+
this._debug("WATCH...");
|
|
102
66
|
const fnQ = new FunctionQueue();
|
|
103
67
|
SdFsWatcher
|
|
104
68
|
.watch([
|
|
105
|
-
...
|
|
106
|
-
|
|
69
|
+
...sdTsProgram.builderProgram!.getSourceFiles().map((item) => item.fileName),
|
|
70
|
+
path.resolve(this._pkgPath, "src/**/*.{ts,tsx}")
|
|
107
71
|
])
|
|
108
72
|
.onChange({
|
|
109
73
|
delay: 100
|
|
110
74
|
}, () => {
|
|
111
75
|
fnQ.runLast(async () => {
|
|
112
76
|
this.emit("change");
|
|
113
|
-
this._debug(`빌드...`);
|
|
114
77
|
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
rootNames: await FsUtil.globAsync(srcGlobPath),
|
|
118
|
-
options: parsedTsConfig.options,
|
|
119
|
-
host: host
|
|
120
|
-
});
|
|
121
|
-
const watchAffectedSrcFilePaths = watchResult.affectedFileNames.map((item) => path.resolve(item)).filter((item) => watchSrcFilePaths.includes(item));
|
|
78
|
+
this._debug(`BUILD...`);
|
|
79
|
+
const watchBuildResult = await sdTsProgram.buildAsync();
|
|
122
80
|
|
|
123
|
-
this._debug(
|
|
124
|
-
const watchLintResults = await
|
|
81
|
+
this._debug(`LINT...`);
|
|
82
|
+
const watchLintResults = await SdLinter.lintAsync(watchBuildResult.affectedFilePaths, sdTsProgram.builderProgram!.getProgram());
|
|
125
83
|
|
|
126
84
|
this._debug(`빌드 완료`);
|
|
127
85
|
this.emit("complete", {
|
|
128
|
-
affectedFilePaths:
|
|
129
|
-
buildResults: [...
|
|
86
|
+
affectedFilePaths: watchBuildResult.affectedFilePaths,
|
|
87
|
+
buildResults: [...watchBuildResult.results, ...watchLintResults]
|
|
130
88
|
});
|
|
131
89
|
});
|
|
132
90
|
});
|
|
133
91
|
}
|
|
134
92
|
|
|
135
|
-
private _emitIncrementalProgram(opt: {
|
|
136
|
-
rootNames: string[];
|
|
137
|
-
options: ts.CompilerOptions;
|
|
138
|
-
host: ts.CompilerHost;
|
|
139
|
-
}): {
|
|
140
|
-
program: ts.SemanticDiagnosticsBuilderProgram;
|
|
141
|
-
buildResults: ISdCliPackageBuildResult[];
|
|
142
|
-
affectedFileNames: string[];
|
|
143
|
-
} {
|
|
144
|
-
const program = ts.createIncrementalProgram({
|
|
145
|
-
rootNames: opt.rootNames,
|
|
146
|
-
options: opt.options,
|
|
147
|
-
host: opt.host,
|
|
148
|
-
createProgram: ts.createSemanticDiagnosticsBuilderProgram
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
const diagnostics: ts.Diagnostic[] = [];
|
|
152
|
-
const affectedFileNames: string[] = [];
|
|
153
|
-
|
|
154
|
-
diagnostics.push(
|
|
155
|
-
...program.getOptionsDiagnostics(),
|
|
156
|
-
...program.getGlobalDiagnostics(),
|
|
157
|
-
);
|
|
158
|
-
|
|
159
|
-
while (true) {
|
|
160
|
-
const semanticResult = program.getSemanticDiagnosticsOfNextAffectedFile(undefined, (sourceFile) => {
|
|
161
|
-
return !opt.rootNames.includes(path.resolve(sourceFile.fileName));
|
|
162
|
-
});
|
|
163
|
-
if (!semanticResult) break;
|
|
164
|
-
diagnostics.push(...semanticResult.result);
|
|
165
|
-
|
|
166
|
-
/*const result = program.emitNextAffectedFile((filePath, data, writeByteOrderMark) => {
|
|
167
|
-
if (this._writeFileCache.get(filePath) !== data) {
|
|
168
|
-
ts.sys.writeFile(filePath, data, writeByteOrderMark);
|
|
169
|
-
}
|
|
170
|
-
this._writeFileCache.set(filePath, data);
|
|
171
|
-
});
|
|
172
|
-
if (!result) break;*/
|
|
173
|
-
|
|
174
|
-
if ("fileName" in semanticResult.affected) {
|
|
175
|
-
const emitResult = program.emit(program.getSourceFile(semanticResult.affected.fileName), (filePath, data, writeByteOrderMark) => {
|
|
176
|
-
let realFilePath = filePath;
|
|
177
|
-
if (PathUtil.isChildPath(realFilePath, path.resolve(this._pkgPath, "dist", this._pkgName, "src"))) {
|
|
178
|
-
realFilePath = path.resolve(this._pkgPath, "dist", path.relative(path.resolve(this._pkgPath, "dist", this._pkgName, "src"), realFilePath));
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (this._writeFileCache.get(realFilePath) !== data) {
|
|
182
|
-
ts.sys.writeFile(realFilePath, data, writeByteOrderMark);
|
|
183
|
-
}
|
|
184
|
-
this._writeFileCache.set(realFilePath, data);
|
|
185
|
-
});
|
|
186
|
-
diagnostics.push(...emitResult.diagnostics);
|
|
187
|
-
|
|
188
|
-
affectedFileNames.push(semanticResult.affected.fileName);
|
|
189
|
-
diagnostics.push(...program.getSyntacticDiagnostics(semanticResult.affected));
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
const buildResults = diagnostics.map((item) => SdCliBuildResultUtil.convertFromTsDiag(item));
|
|
194
|
-
|
|
195
|
-
return {
|
|
196
|
-
program,
|
|
197
|
-
buildResults,
|
|
198
|
-
affectedFileNames
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/*private readonly _linter = new ESLint({
|
|
203
|
-
overrideConfig: {
|
|
204
|
-
overrides: [
|
|
205
|
-
{
|
|
206
|
-
files: ["*.ts"],
|
|
207
|
-
parserOptions: {
|
|
208
|
-
tsconfigRootDir: this._pkgPath,
|
|
209
|
-
project: "tsconfig.json"
|
|
210
|
-
},
|
|
211
|
-
settings: {
|
|
212
|
-
"import/resolver": {
|
|
213
|
-
"typescript": {
|
|
214
|
-
project: path.resolve(this._pkgPath, "tsconfig.json")
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
]
|
|
220
|
-
}
|
|
221
|
-
});*/
|
|
222
|
-
|
|
223
|
-
private async _lintAsync(program: ts.Program, srcFilePaths: string[]): Promise<ISdCliPackageBuildResult[]> {
|
|
224
|
-
const linter = new ESLint({
|
|
225
|
-
overrideConfig: {
|
|
226
|
-
overrides: [
|
|
227
|
-
{
|
|
228
|
-
files: ["*.ts"],
|
|
229
|
-
parserOptions: {
|
|
230
|
-
programs: [program],
|
|
231
|
-
tsconfigRootDir: null,
|
|
232
|
-
project: null,
|
|
233
|
-
// tsconfigRootDir: this._pkgPath,
|
|
234
|
-
// project: "tsconfig.json"
|
|
235
|
-
},
|
|
236
|
-
settings: {
|
|
237
|
-
"import/resolver": {
|
|
238
|
-
"typescript": {
|
|
239
|
-
programs: [program],
|
|
240
|
-
project: null,
|
|
241
|
-
// project: path.resolve(this._pkgPath, "tsconfig.json"),
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
]
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
const lintResults = await linter.lintFiles(srcFilePaths);
|
|
251
|
-
|
|
252
|
-
return lintResults.mapMany((lintResult) => lintResult.messages.map((msg) => ({
|
|
253
|
-
filePath: lintResult.filePath,
|
|
254
|
-
line: msg.line,
|
|
255
|
-
char: msg.column,
|
|
256
|
-
code: msg.ruleId ?? undefined,
|
|
257
|
-
severity: msg.severity === 1 ? "warning" as const : "error" as const,
|
|
258
|
-
message: msg.message
|
|
259
|
-
})));
|
|
260
|
-
}
|
|
261
|
-
|
|
262
93
|
private _debug(msg: string): void {
|
|
263
|
-
this._logger.debug(`[${this.
|
|
94
|
+
this._logger.debug(`[${path.basename(this._pkgPath)}] ${msg}`);
|
|
264
95
|
}
|
|
265
96
|
}
|
package/src/commons.ts
CHANGED
|
@@ -10,6 +10,24 @@ export interface INpmConfig {
|
|
|
10
10
|
peerDependenciesMeta?: Record<string, { optional?: boolean }>;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
export interface ISdCliBuildClusterReqMessage {
|
|
14
|
+
cmd: "watch" | "build";
|
|
15
|
+
pkgPath: string;
|
|
16
|
+
pkgConf: TSdCliPackageConfig
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ISdCliBuildClusterResMessage {
|
|
20
|
+
req: ISdCliBuildClusterReqMessage;
|
|
21
|
+
type: "change" | "complete" | "ready";
|
|
22
|
+
result?: ISdCliBuilderResult;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ISdCliBuilderResult {
|
|
26
|
+
port?: number;
|
|
27
|
+
affectedFilePaths: string[];
|
|
28
|
+
buildResults: ISdCliPackageBuildResult[];
|
|
29
|
+
}
|
|
30
|
+
|
|
13
31
|
export interface ISdCliPackageBuildResult {
|
|
14
32
|
filePath: string | undefined;
|
|
15
33
|
line: number | undefined;
|
|
@@ -21,11 +39,24 @@ export interface ISdCliPackageBuildResult {
|
|
|
21
39
|
|
|
22
40
|
export interface ISdCliConfig {
|
|
23
41
|
packages: Record<string, TSdCliPackageConfig | undefined>;
|
|
42
|
+
localUpdates?: Record<string, string>;
|
|
24
43
|
}
|
|
25
44
|
|
|
26
|
-
export type TSdCliPackageConfig = ISdCliLibPackageConfig;
|
|
45
|
+
export type TSdCliPackageConfig = ISdCliLibPackageConfig | ISdCliServerPackageConfig | ISdCliClientPackageConfig;
|
|
27
46
|
|
|
28
47
|
export interface ISdCliLibPackageConfig {
|
|
29
48
|
type: "library";
|
|
30
|
-
publish
|
|
49
|
+
publish?: "npm";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface ISdCliServerPackageConfig {
|
|
53
|
+
type: "server";
|
|
54
|
+
externals?: string[];
|
|
55
|
+
publish?: any;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface ISdCliClientPackageConfig {
|
|
59
|
+
type: "client";
|
|
60
|
+
server?: string;
|
|
61
|
+
publish?: any;
|
|
31
62
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { FsUtil, Logger } from "@simplysm/sd-core-node";
|
|
3
|
+
import { SdCliConfigUtil } from "../utils/SdCliConfigUtil";
|
|
4
|
+
|
|
5
|
+
export class SdCliLocalUpdate {
|
|
6
|
+
public static async runAsync(opt: { rootPath: string; confFileRelPath: string; }): Promise<void> {
|
|
7
|
+
const logger = Logger.get(["simplysm", "sd-cli", "SdCliLocalUpdate", "runAsync"]);
|
|
8
|
+
|
|
9
|
+
logger.debug("프로젝트 설정 가져오기...");
|
|
10
|
+
const conf = await SdCliConfigUtil.loadConfigAsync(path.resolve(opt.rootPath, opt.confFileRelPath), false);
|
|
11
|
+
if (!conf.localUpdates) return;
|
|
12
|
+
|
|
13
|
+
logger.debug("로컬 업데이트 구성...");
|
|
14
|
+
const updatePathInfos = await this._getUpdatePathInfosAsync(opt.rootPath, conf.localUpdates);
|
|
15
|
+
logger.debug("로컬 업데이트 구성 완료", updatePathInfos);
|
|
16
|
+
|
|
17
|
+
logger.log("로컬 라이브러리 업데이트 시작...");
|
|
18
|
+
for (const updatePathInfo of updatePathInfos) {
|
|
19
|
+
if (!FsUtil.exists(updatePathInfo.source)) {
|
|
20
|
+
logger.warn(`소스경로를 찾을 수 없어 무시됩니다(${updatePathInfo.source})`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 소스경로에서 대상경로로 파일 복사
|
|
25
|
+
await FsUtil.copyAsync(updatePathInfo.source, updatePathInfo.target, (src) => {
|
|
26
|
+
return !src.includes("node_modules") && !src.endsWith("package.json");
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
logger.info("로컬 라이브러리 업데이트 완료");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private static async _getUpdatePathInfosAsync(rootPath: string, record: Record<string, string>): Promise<IUpdatePathInfo[]> {
|
|
33
|
+
const result: IUpdatePathInfo[] = [];
|
|
34
|
+
for (const pkgGlobPath of Object.keys(record)) {
|
|
35
|
+
// "node_modules'에서 로컬업데이트 설정에 맞는 패키지를 "glob"하여 대상 패키지경로 목록 가져오기
|
|
36
|
+
const targetPaths = [
|
|
37
|
+
...await FsUtil.globAsync(path.resolve(rootPath, "node_modules", pkgGlobPath)),
|
|
38
|
+
...await FsUtil.globAsync(path.resolve(rootPath, "**", "node_modules", pkgGlobPath))
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
result.push(
|
|
42
|
+
...targetPaths
|
|
43
|
+
.map((targetPath) => {
|
|
44
|
+
// 대상의 명칭 추출
|
|
45
|
+
const regexpText = pkgGlobPath.replace(/[\\/.*]/g, (item) => (
|
|
46
|
+
item === "/" ? "[\\\\\\/]"
|
|
47
|
+
: item === "." ? "\\."
|
|
48
|
+
: item === "*" ? "(.*)"
|
|
49
|
+
: item
|
|
50
|
+
));
|
|
51
|
+
const targetNameMatch = new RegExp(regexpText).exec(targetPath);
|
|
52
|
+
if (!targetNameMatch || typeof targetNameMatch[1] === "undefined") return undefined;
|
|
53
|
+
const targetName = targetNameMatch[1];
|
|
54
|
+
|
|
55
|
+
// 가져올 소스 경로 추출
|
|
56
|
+
const sourcePath = path.resolve(record[pkgGlobPath].replace(/\*/g, targetName));
|
|
57
|
+
return { source: sourcePath, target: targetPath };
|
|
58
|
+
})
|
|
59
|
+
.filterExists()
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
interface IUpdatePathInfo {
|
|
68
|
+
source: string;
|
|
69
|
+
target: string;
|
|
70
|
+
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { FsUtil, Logger, SdProcess } from "@simplysm/sd-core-node";
|
|
3
3
|
import { SdCliConfigUtil } from "../utils/SdCliConfigUtil";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
INpmConfig,
|
|
6
|
+
ISdCliBuildClusterReqMessage,
|
|
7
|
+
ISdCliBuildClusterResMessage,
|
|
8
|
+
ISdCliPackageBuildResult,
|
|
9
|
+
TSdCliPackageConfig
|
|
10
|
+
} from "../commons";
|
|
5
11
|
import cp from "child_process";
|
|
6
12
|
import { fileURLToPath } from "url";
|
|
7
13
|
import { SdCliBuildResultUtil } from "../utils/SdCliBuildResultUtil";
|
|
@@ -36,7 +42,18 @@ export class SdCliProject {
|
|
|
36
42
|
logger.debug("빌드 프로세스 이벤트 준비...");
|
|
37
43
|
const resultCache = new Map<string, ISdCliPackageBuildResult[]>();
|
|
38
44
|
let busyCount = 0;
|
|
39
|
-
|
|
45
|
+
const serverInfoMap = new Map<string, {
|
|
46
|
+
// server
|
|
47
|
+
pkgPath?: string; // persist
|
|
48
|
+
worker?: cp.ChildProcess; // persist
|
|
49
|
+
port?: number;
|
|
50
|
+
hasChanges: boolean;
|
|
51
|
+
|
|
52
|
+
//client
|
|
53
|
+
pathProxy: Record<string, number | undefined>; // persist
|
|
54
|
+
changeFilePaths: string[];
|
|
55
|
+
}>();
|
|
56
|
+
cluster.on("message", (message: ISdCliBuildClusterResMessage) => {
|
|
40
57
|
if (message.type === "change") {
|
|
41
58
|
if (busyCount === 0) {
|
|
42
59
|
logger.log("빌드를 시작합니다...");
|
|
@@ -44,18 +61,74 @@ export class SdCliProject {
|
|
|
44
61
|
busyCount++;
|
|
45
62
|
}
|
|
46
63
|
else if (message.type === "complete") {
|
|
47
|
-
for (const affectedFilePath of message.result
|
|
64
|
+
for (const affectedFilePath of message.result!.affectedFilePaths) {
|
|
48
65
|
resultCache.delete(affectedFilePath);
|
|
49
66
|
}
|
|
50
67
|
|
|
51
|
-
for (const buildResult of message.result
|
|
68
|
+
for (const buildResult of message.result!.buildResults) {
|
|
52
69
|
const cacheItem = resultCache.getOrCreate(buildResult.filePath ?? "none", []);
|
|
53
70
|
cacheItem.push(buildResult);
|
|
54
71
|
}
|
|
55
72
|
|
|
56
|
-
|
|
73
|
+
if (message.req.pkgConf.type === "server") {
|
|
74
|
+
const pkgName = path.basename(message.req.pkgPath);
|
|
75
|
+
const serverInfo = serverInfoMap.getOrCreate(pkgName, {
|
|
76
|
+
hasChanges: false,
|
|
77
|
+
pathProxy: {},
|
|
78
|
+
changeFilePaths: []
|
|
79
|
+
});
|
|
80
|
+
serverInfo.pkgPath = message.req.pkgPath;
|
|
81
|
+
serverInfo.hasChanges = true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (message.req.pkgConf.type === "client" && message.req.pkgConf.server !== undefined) {
|
|
85
|
+
const pkgName = path.basename(message.req.pkgPath);
|
|
86
|
+
const serverInfo = serverInfoMap.getOrCreate(message.req.pkgConf.server, {
|
|
87
|
+
hasChanges: false,
|
|
88
|
+
pathProxy: {},
|
|
89
|
+
changeFilePaths: []
|
|
90
|
+
});
|
|
91
|
+
serverInfo.pathProxy[pkgName] = message.result!.port;
|
|
92
|
+
serverInfo.changeFilePaths.push(...message.result!.affectedFilePaths);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
setTimeout(async () => {
|
|
57
96
|
busyCount--;
|
|
58
97
|
if (busyCount === 0) {
|
|
98
|
+
for (const serverPkgName of serverInfoMap.keys()) {
|
|
99
|
+
const serverInfo = serverInfoMap.get(serverPkgName)!;
|
|
100
|
+
if (serverInfo.pkgPath !== undefined && serverInfo.hasChanges) {
|
|
101
|
+
logger.debug("서버 재시작...");
|
|
102
|
+
try {
|
|
103
|
+
const restartServerResult = await this._restartServerAsync(serverInfo.pkgPath, serverInfo.worker);
|
|
104
|
+
serverInfo.worker = restartServerResult.worker;
|
|
105
|
+
serverInfo.port = restartServerResult.port;
|
|
106
|
+
serverInfo.hasChanges = false;
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
logger.error(err);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (serverInfo.worker) {
|
|
114
|
+
logger.debug("클라이언트 설정...");
|
|
115
|
+
serverInfo.worker.send({
|
|
116
|
+
type: "setPathProxy",
|
|
117
|
+
pathProxy: serverInfo.pathProxy
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const clientPaths: string[] = [];
|
|
123
|
+
for (const serverInfo of serverInfoMap.values()) {
|
|
124
|
+
for (const proxyPath of Object.keys(serverInfo.pathProxy)) {
|
|
125
|
+
clientPaths.push(`http://localhost:${serverInfo.port}/${proxyPath}/`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (clientPaths.length > 0) {
|
|
129
|
+
logger.info("클라이언트 개발 서버 접속 주소\n" + clientPaths.join("\n"));
|
|
130
|
+
}
|
|
131
|
+
|
|
59
132
|
const buildResults = Array.from(resultCache.values()).mapMany();
|
|
60
133
|
this._logging(buildResults, logger);
|
|
61
134
|
}
|
|
@@ -68,7 +141,7 @@ export class SdCliProject {
|
|
|
68
141
|
logger.log("빌드를 시작합니다...");
|
|
69
142
|
|
|
70
143
|
await pkgPaths.parallelAsync(async (pkgPath) => {
|
|
71
|
-
await this._runCommandAsync(cluster, "watch", pkgPath);
|
|
144
|
+
await this._runCommandAsync(cluster, "watch", pkgPath, projConf.packages[path.basename(pkgPath)]!);
|
|
72
145
|
});
|
|
73
146
|
|
|
74
147
|
busyCount--;
|
|
@@ -108,7 +181,7 @@ export class SdCliProject {
|
|
|
108
181
|
logger.debug("빌드 프로세스 명령 전달...");
|
|
109
182
|
const results = (
|
|
110
183
|
await pkgPaths.parallelAsync(async (pkgPath) => {
|
|
111
|
-
return await this._runCommandAsync(cluster, "build", pkgPath);
|
|
184
|
+
return await this._runCommandAsync(cluster, "build", pkgPath, projConf.packages[path.basename(pkgPath)]!);
|
|
112
185
|
})
|
|
113
186
|
).mapMany();
|
|
114
187
|
|
|
@@ -165,7 +238,7 @@ export class SdCliProject {
|
|
|
165
238
|
logger.debug("빌드 프로세스 명령 전달...");
|
|
166
239
|
const results = (
|
|
167
240
|
await pkgPaths.parallelAsync(async (pkgPath) => {
|
|
168
|
-
return await this._runCommandAsync(cluster, "build", pkgPath);
|
|
241
|
+
return await this._runCommandAsync(cluster, "build", pkgPath, projConf.packages[path.basename(pkgPath)]!);
|
|
169
242
|
})
|
|
170
243
|
).mapMany();
|
|
171
244
|
|
|
@@ -325,27 +398,70 @@ export class SdCliProject {
|
|
|
325
398
|
});
|
|
326
399
|
}
|
|
327
400
|
|
|
328
|
-
private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "watch", pkgPath: string): Promise<void>;
|
|
329
|
-
private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "build", pkgPath: string): Promise<ISdCliPackageBuildResult[]>;
|
|
330
|
-
private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "watch" | "build", pkgPath: string): Promise<ISdCliPackageBuildResult[] | void> {
|
|
331
|
-
await new Promise<ISdCliPackageBuildResult[] | void>((resolve) => {
|
|
332
|
-
const cb = (message): void => {
|
|
333
|
-
if (cmd === "watch" && message.type === "ready" && message.cmd === cmd && message.pkgPath === pkgPath) {
|
|
401
|
+
private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "watch", pkgPath: string, pkgConf: TSdCliPackageConfig): Promise<void>;
|
|
402
|
+
private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "build", pkgPath: string, pkgConf: TSdCliPackageConfig): Promise<ISdCliPackageBuildResult[]>;
|
|
403
|
+
private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "watch" | "build", pkgPath: string, pkgConf: TSdCliPackageConfig): Promise<ISdCliPackageBuildResult[] | void> {
|
|
404
|
+
return await new Promise<ISdCliPackageBuildResult[] | void>((resolve) => {
|
|
405
|
+
const cb = (message: ISdCliBuildClusterResMessage): void => {
|
|
406
|
+
if (cmd === "watch" && message.type === "ready" && message.req.cmd === cmd && message.req.pkgPath === pkgPath) {
|
|
334
407
|
cluster.off("message", cb);
|
|
335
408
|
resolve();
|
|
336
409
|
}
|
|
337
|
-
else if (cmd === "build" && message.type === "complete" && message.cmd === cmd && message.pkgPath === pkgPath) {
|
|
410
|
+
else if (cmd === "build" && message.type === "complete" && message.req.cmd === cmd && message.req.pkgPath === pkgPath) {
|
|
338
411
|
cluster.off("message", cb);
|
|
339
|
-
resolve(message.result);
|
|
412
|
+
resolve(message.result?.buildResults);
|
|
340
413
|
}
|
|
341
414
|
};
|
|
342
415
|
cluster.on("message", cb);
|
|
343
416
|
|
|
344
|
-
cluster.send({ cmd, pkgPath });
|
|
417
|
+
cluster.send({ cmd, pkgPath, pkgConf } as ISdCliBuildClusterReqMessage);
|
|
345
418
|
});
|
|
346
419
|
}
|
|
347
420
|
|
|
348
421
|
private static _closeCluster(cluster: cp.ChildProcess): void {
|
|
349
422
|
cluster.kill("SIGKILL");
|
|
350
423
|
}
|
|
424
|
+
|
|
425
|
+
private static async _restartServerAsync(pkgPath: string, prevServerProcess?: cp.ChildProcess): Promise<{ worker: cp.ChildProcess, port: number }> {
|
|
426
|
+
const logger = Logger.get(["simplysm", "sd-cli", "SdCliProject", "_restartServerAsync"]);
|
|
427
|
+
|
|
428
|
+
if (prevServerProcess) {
|
|
429
|
+
prevServerProcess.kill("SIGKILL");
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return await new Promise<{ worker: cp.ChildProcess, port: number }>(async (resolve, reject) => {
|
|
433
|
+
const worker = cp.fork(
|
|
434
|
+
fileURLToPath(await import.meta.resolve!("../server-worker")),
|
|
435
|
+
[pkgPath],
|
|
436
|
+
{
|
|
437
|
+
stdio: ["pipe", "pipe", "pipe", "ipc"],
|
|
438
|
+
env: process.env
|
|
439
|
+
}
|
|
440
|
+
);
|
|
441
|
+
|
|
442
|
+
worker.stdout!.pipe(process.stdout);
|
|
443
|
+
worker.stderr!.pipe(process.stderr);
|
|
444
|
+
|
|
445
|
+
worker.on("exit", (code) => {
|
|
446
|
+
if (code != null && code !== 0) {
|
|
447
|
+
const err = new Error(`오류와 함께 닫힘 (${code})`);
|
|
448
|
+
logger.error(err);
|
|
449
|
+
reject(err);
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
worker.on("error", (err) => {
|
|
455
|
+
logger.error(err);
|
|
456
|
+
reject(err);
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
worker.on("message", (message: any) => {
|
|
460
|
+
if ("port" in message) {
|
|
461
|
+
logger.debug("서버가 시작되었습니다.");
|
|
462
|
+
resolve({ worker, port: message.port });
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
});
|
|
466
|
+
}
|
|
351
467
|
}
|
package/src/sd-cli.ts
CHANGED
|
@@ -3,7 +3,9 @@ import { hideBin } from "yargs/helpers";
|
|
|
3
3
|
import { SdCliProject } from "./entry/SdCliProject";
|
|
4
4
|
import { Logger, LoggerSeverity } from "@simplysm/sd-core-node";
|
|
5
5
|
import { EventEmitter } from "events";
|
|
6
|
+
import { SdCliLocalUpdate } from "./entry/SdCliLocalUpdate";
|
|
6
7
|
|
|
8
|
+
Error.stackTraceLimit = Infinity;
|
|
7
9
|
EventEmitter.defaultMaxListeners = 0;
|
|
8
10
|
|
|
9
11
|
const argv = (
|
|
@@ -85,6 +87,17 @@ const argv = (
|
|
|
85
87
|
}
|
|
86
88
|
})
|
|
87
89
|
)
|
|
90
|
+
.command(
|
|
91
|
+
"local-update",
|
|
92
|
+
"로컬 라이브러리 업데이트를 수행합니다.",
|
|
93
|
+
(cmd) => cmd.version(false).hide("help").hide("debug")
|
|
94
|
+
.options({
|
|
95
|
+
config: {
|
|
96
|
+
type: "string",
|
|
97
|
+
describe: "simplysm.json 파일 경로"
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
)
|
|
88
101
|
.parseAsync()
|
|
89
102
|
) as any;
|
|
90
103
|
|
|
@@ -130,6 +143,13 @@ else if (argv._[0] === "publish") {
|
|
|
130
143
|
pkgNames: argv.packages ?? []
|
|
131
144
|
});
|
|
132
145
|
}
|
|
146
|
+
else if (argv._[0] === "local-update") {
|
|
147
|
+
await SdCliLocalUpdate
|
|
148
|
+
.runAsync({
|
|
149
|
+
rootPath: process.cwd(),
|
|
150
|
+
confFileRelPath: argv.config ?? "simplysm.json"
|
|
151
|
+
});
|
|
152
|
+
}
|
|
133
153
|
else {
|
|
134
154
|
throw new Error(`명령어가 잘못 되었습니다.\n\t${argv._[0]}\n`);
|
|
135
155
|
}
|