@simplysm/sd-cli 7.0.81 → 7.0.146

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.
@@ -80,9 +80,33 @@ export class SdCliWorkspace {
80
80
  if (pkg.config.type === "client") {
81
81
  const middlewares = (await pkg.watchAsync()) as NextHandleFunction[];
82
82
 
83
- const serverInfo = this._serverInfoMap.getOrCreate(pkg.config.server, { middlewares: [], clientInfos: [] });
84
- serverInfo.middlewares.push(...middlewares);
85
- serverInfo.clientInfos.push({ pkgKey: pkg.name.split("/").last()! });
83
+ if (typeof pkg.config.server === "string") {
84
+ const serverInfo = this._serverInfoMap.getOrCreate(pkg.config.server, { middlewares: [], clientInfos: [] });
85
+ serverInfo.middlewares.push(...middlewares);
86
+ serverInfo.clientInfos.push({
87
+ pkgKey: pkg.name.split("/").last()!,
88
+ platforms: pkg.config.builder ? Object.keys(pkg.config.builder) : ["web"],
89
+ cordovaTargets: pkg.config.builder?.cordova?.target ? Object.keys(pkg.config.builder.cordova.target) : ["browser"]
90
+ });
91
+ }
92
+ else { // DEV SERVER
93
+ const serverInfo = this._serverInfoMap.getOrCreate("_", { middlewares: [], clientInfos: [] });
94
+ if (serverInfo.server === undefined) {
95
+ const server = new SdServiceServer({
96
+ rootPath: process.cwd(),
97
+ services: [],
98
+ port: pkg.config.server.port
99
+ });
100
+ await server.listenAsync();
101
+ serverInfo.server = server;
102
+ serverInfo.server.devMiddlewares = middlewares;
103
+ serverInfo.clientInfos.push({
104
+ pkgKey: pkg.name.split("/").last()!,
105
+ platforms: pkg.config.builder ? Object.keys(pkg.config.builder) : ["web"],
106
+ cordovaTargets: pkg.config.builder?.cordova?.target ? Object.keys(pkg.config.builder.cordova.target) : ["browser"]
107
+ });
108
+ }
109
+ }
86
110
  }
87
111
  else {
88
112
  await pkg.watchAsync();
@@ -345,11 +369,28 @@ export class SdCliWorkspace {
345
369
  const portStr = serverInfo.server.options.port.toString();
346
370
 
347
371
  for (const clientInfo of serverInfo.clientInfos) {
348
- clientHrefs.push(`${protocolStr}://localhost:${portStr}/${clientInfo.pkgKey}/`);
372
+ for (const platform of clientInfo.platforms) {
373
+ if (platform === "web") {
374
+ clientHrefs.push(`${protocolStr}://localhost:${portStr}/${clientInfo.pkgKey}/`);
375
+ }
376
+ else if (platform === "electron") {
377
+ clientHrefs.push(`sd-cli run-electron ${clientInfo.pkgKey} http://localhost:${portStr}`);
378
+ }
379
+ else if (platform === "cordova") {
380
+ for (const target of clientInfo.cordovaTargets) {
381
+ if (target === "browser") {
382
+ clientHrefs.push(`${protocolStr}://localhost:${portStr}/${clientInfo.pkgKey}/${platform}/`);
383
+ }
384
+ else {
385
+ clientHrefs.push(`sd-cli run-cordova ${clientInfo.pkgKey} http://[IP]:${portStr}`);
386
+ }
387
+ }
388
+ }
389
+ }
349
390
  }
350
391
  }
351
392
  if (clientHrefs.length > 0) {
352
- this._logger.log(`오픈된 클라이언트: ${clientHrefs.join(", ")}`);
393
+ this._logger.log(`오픈된 클라이언트:\n${clientHrefs.join("\n")}`);
353
394
  }
354
395
  }
355
396
  }
@@ -357,5 +398,5 @@ export class SdCliWorkspace {
357
398
  interface IServerInfo {
358
399
  server?: SdServiceServer;
359
400
  middlewares: NextHandleFunction[];
360
- clientInfos: { pkgKey: string }[];
401
+ clientInfos: { pkgKey: string; platforms: string[]; cordovaTargets: string[] }[];
361
402
  }
package/src/index.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export * from "./build-tool/SdCliCacheCompilerHost";
2
2
  export * from "./build-tool/SdCliCordova";
3
+ export * from "./build-tool/SdCliElectron";
4
+ export * from "./build-tool/SdCliGithubApi";
3
5
  export * from "./build-tool/SdCliIndexFileGenerator";
4
6
  export * from "./build-tool/SdCliNgCacheCompilerHost";
5
7
  export * from "./build-tool/SdCliPackageLinter";
@@ -46,7 +46,7 @@ export class SdCliBbFileMetadata {
46
46
 
47
47
  public constructor(public readonly filePath: string) {
48
48
  let realFilePath: string | undefined;
49
- for (const ext of ["", ".mjs", ".cjs", ".js"]) {
49
+ for (const ext of ["", ".mjs", ".cjs", ".js"/*, "/index.mjs", "/index.cjs", "/index.js"*/]) {
50
50
  if (FsUtil.exists(filePath + ext) && !FsUtil.stat(filePath + ext).isDirectory()) {
51
51
  realFilePath = filePath + ext;
52
52
  break;
@@ -144,7 +144,10 @@ export class SdCliBbRootMetadata {
144
144
 
145
145
  const entryFilePath = npmConfig["es2015"] ?? npmConfig["browser"] ?? npmConfig["module"] ?? npmConfig["main"] ?? npmConfig["default"];
146
146
  if (typeof entryFilePath === "string") {
147
- entryMap.set(npmConfig.name, path.resolve(ngDepPath, entryFilePath));
147
+ const realPath = this._getRealFilePath(path.resolve(ngDepPath, entryFilePath));
148
+ if (realPath != null) {
149
+ entryMap.set(npmConfig.name, realPath);
150
+ }
148
151
  }
149
152
 
150
153
  if (npmConfig.exports) {
@@ -168,7 +171,10 @@ export class SdCliBbRootMetadata {
168
171
  const exportPath = path.resolve(ngDepPath, expEntryFilePath);
169
172
  const exportResult = this._getGlobExportResult(PathUtil.posix(npmConfig.name, exportKey), exportPath);
170
173
  for (const exportResultItem of exportResult) {
171
- entryMap.set(exportResultItem.name, exportResultItem.target);
174
+ const realPath = this._getRealFilePath(exportResultItem.target);
175
+ if (realPath != null) {
176
+ entryMap.set(exportResultItem.name, realPath);
177
+ }
172
178
  }
173
179
  }
174
180
  }
@@ -178,6 +184,28 @@ export class SdCliBbRootMetadata {
178
184
  return entryMap;
179
185
  }
180
186
 
187
+ private _getRealFilePath(itemPath: string): string | undefined {
188
+ if (!FsUtil.exists(itemPath)) {
189
+ for (const ext of [".mjs", ".cjs", ".js"]) {
190
+ if (FsUtil.exists(itemPath + ext)) {
191
+ return itemPath + ext;
192
+ }
193
+ }
194
+ }
195
+ else if (FsUtil.stat(itemPath).isFile()) {
196
+ return itemPath;
197
+ }
198
+ else {
199
+ for (const fileName of ["index.mjs", "index.cjs", "index.js"]) {
200
+ if (FsUtil.exists(path.resolve(itemPath, fileName))) {
201
+ return path.resolve(itemPath, fileName);
202
+ }
203
+ }
204
+ }
205
+
206
+ return undefined;
207
+ }
208
+
181
209
  private _getGlobExportResult(globName: string, globTarget: string): { name: string; target: string }[] {
182
210
  if (globName.includes("*") && globTarget.includes("*")) {
183
211
  const result: { name: string; target: string }[] = [];
@@ -11,6 +11,7 @@ import { SdCliClientBuilder } from "../builder/SdCliClientBuilder";
11
11
  import { NextHandleFunction } from "connect";
12
12
  import { SdStorage } from "@simplysm/sd-storage";
13
13
  import ts from "typescript";
14
+ import { SdCliGithubApi } from "../build-tool/SdCliGithubApi";
14
15
 
15
16
  export class SdCliPackage extends EventEmitter {
16
17
  private readonly _npmConfig: INpmConfig;
@@ -96,7 +97,23 @@ export class SdCliPackage extends EventEmitter {
96
97
  }
97
98
  }
98
99
  else {
99
- if (this.config.publish.type === "ftp" || this.config.publish.type === "ftps" || this.config.publish.type === "sftp") {
100
+ if (this.config.publish.type === "github") {
101
+ const repoUrl = typeof this._npmConfig.repository === "string" ? this._npmConfig.repository : this._npmConfig.repository.url;
102
+ const repoOwner = repoUrl.split("/").slice(-2)[0];
103
+ const repoName = repoUrl.split("/").slice(-2)[1].replace(/\..*/g, "");
104
+
105
+ const github = new SdCliGithubApi(
106
+ this.config.publish.apiKey,
107
+ repoOwner,
108
+ repoName
109
+ );
110
+
111
+ await github.uploadAsync(this._npmConfig.version, this.config.publish.files.map((item) => ({
112
+ buffer: FsUtil.readFileBuffer(path.resolve(this.rootPath, "dist", item.from)),
113
+ name: item.to
114
+ })));
115
+ }
116
+ else if (this.config.publish.type === "ftp" || this.config.publish.type === "ftps" || this.config.publish.type === "sftp") {
100
117
  const tsconfigPath = path.resolve(this.rootPath, "tsconfig-build.json");
101
118
  const tsconfig = FsUtil.readJson(tsconfigPath);
102
119
  const parsedTsconfig = ts.parseJsonConfigFileContent(tsconfig, ts.sys, this.rootPath, tsconfig.angularCompilerOptions);
package/tsconfig.json CHANGED
@@ -19,6 +19,9 @@
19
19
  "@simplysm/sd-service-server": [
20
20
  "../sd-service-server/src/index.ts"
21
21
  ],
22
+ "@simplysm/sd-orm-common": [
23
+ "../sd-orm-common/src/index.ts"
24
+ ],
22
25
  "@simplysm/sd-storage": [
23
26
  "../sd-storage/src/index.ts"
24
27
  ]