@ng-openapi/http-resource 0.1.0 → 0.1.1-pr-107-fix-pathless-spec-service-index-ae0aa36.0

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 (3) hide show
  1. package/index.cjs +19 -7
  2. package/index.js +19 -7
  3. package/package.json +1 -1
package/index.cjs CHANGED
@@ -3016,6 +3016,16 @@ function joinRequestOptionEntries(entries) {
3016
3016
  }
3017
3017
  __name(joinRequestOptionEntries, "joinRequestOptionEntries");
3018
3018
 
3019
+ // ../../shared/src/utils/project.utils.ts
3020
+ function listGeneratedFileNames(project, directoryPath, suffix) {
3021
+ const directory = project.getDirectory(directoryPath);
3022
+ if (!directory) {
3023
+ return [];
3024
+ }
3025
+ return directory.getSourceFiles().map((file) => file.getBaseName()).filter((baseName) => baseName.endsWith(suffix)).map((baseName) => baseName.slice(0, -suffix.length)).sort();
3026
+ }
3027
+ __name(listGeneratedFileNames, "listGeneratedFileNames");
3028
+
3019
3029
  // ../../shared/src/utils/functions/token-names.ts
3020
3030
  function getClientContextTokenName(clientName = "default") {
3021
3031
  const clientSuffix = clientName.toUpperCase().replace(/[^A-Z0-9]/g, "_");
@@ -3326,7 +3336,6 @@ var HttpResourceMethodGenerator = class {
3326
3336
  };
3327
3337
 
3328
3338
  // src/lib/http-resource-index.generator.ts
3329
- var fs = __toESM(require("fs"), 1);
3330
3339
  var path = __toESM(require("path"), 1);
3331
3340
  var HttpResourceIndexGenerator = class {
3332
3341
  static {
@@ -3337,20 +3346,23 @@ var HttpResourceIndexGenerator = class {
3337
3346
  this.project = project;
3338
3347
  }
3339
3348
  generateIndex(outputRoot) {
3340
- const servicesDir = path.join(outputRoot, "resources");
3341
- const indexPath = path.join(servicesDir, "index.ts");
3349
+ const resourcesDir = path.join(outputRoot, "resources");
3350
+ const resourceFiles = listGeneratedFileNames(this.project, resourcesDir, ".resource.ts");
3351
+ if (resourceFiles.length === 0) {
3352
+ return;
3353
+ }
3354
+ const indexPath = path.join(resourcesDir, "index.ts");
3342
3355
  const sourceFile = this.project.createSourceFile(indexPath, "", {
3343
3356
  overwrite: true
3344
3357
  });
3345
3358
  sourceFile.insertText(0, SERVICE_INDEX_GENERATOR_HEADER_COMMENT);
3346
- const serviceFiles = fs.readdirSync(servicesDir).filter((file) => file.endsWith(".resource.ts")).map((file) => file.replace(".resource.ts", ""));
3347
- serviceFiles.forEach((serviceName) => {
3348
- const className = pascalCase(serviceName) + "Resource";
3359
+ resourceFiles.forEach((resourceName) => {
3360
+ const className = pascalCase(resourceName) + "Resource";
3349
3361
  sourceFile.addExportDeclaration({
3350
3362
  namedExports: [
3351
3363
  className
3352
3364
  ],
3353
- moduleSpecifier: `./${serviceName}.resource`
3365
+ moduleSpecifier: `./${resourceName}.resource`
3354
3366
  });
3355
3367
  });
3356
3368
  sourceFile.formatText();
package/index.js CHANGED
@@ -2982,6 +2982,16 @@ function joinRequestOptionEntries(entries) {
2982
2982
  }
2983
2983
  __name(joinRequestOptionEntries, "joinRequestOptionEntries");
2984
2984
 
2985
+ // ../../shared/src/utils/project.utils.ts
2986
+ function listGeneratedFileNames(project, directoryPath, suffix) {
2987
+ const directory = project.getDirectory(directoryPath);
2988
+ if (!directory) {
2989
+ return [];
2990
+ }
2991
+ return directory.getSourceFiles().map((file) => file.getBaseName()).filter((baseName) => baseName.endsWith(suffix)).map((baseName) => baseName.slice(0, -suffix.length)).sort();
2992
+ }
2993
+ __name(listGeneratedFileNames, "listGeneratedFileNames");
2994
+
2985
2995
  // ../../shared/src/utils/functions/token-names.ts
2986
2996
  function getClientContextTokenName(clientName = "default") {
2987
2997
  const clientSuffix = clientName.toUpperCase().replace(/[^A-Z0-9]/g, "_");
@@ -3292,7 +3302,6 @@ var HttpResourceMethodGenerator = class {
3292
3302
  };
3293
3303
 
3294
3304
  // src/lib/http-resource-index.generator.ts
3295
- import * as fs from "fs";
3296
3305
  import * as path from "path";
3297
3306
  var HttpResourceIndexGenerator = class {
3298
3307
  static {
@@ -3303,20 +3312,23 @@ var HttpResourceIndexGenerator = class {
3303
3312
  this.project = project;
3304
3313
  }
3305
3314
  generateIndex(outputRoot) {
3306
- const servicesDir = path.join(outputRoot, "resources");
3307
- const indexPath = path.join(servicesDir, "index.ts");
3315
+ const resourcesDir = path.join(outputRoot, "resources");
3316
+ const resourceFiles = listGeneratedFileNames(this.project, resourcesDir, ".resource.ts");
3317
+ if (resourceFiles.length === 0) {
3318
+ return;
3319
+ }
3320
+ const indexPath = path.join(resourcesDir, "index.ts");
3308
3321
  const sourceFile = this.project.createSourceFile(indexPath, "", {
3309
3322
  overwrite: true
3310
3323
  });
3311
3324
  sourceFile.insertText(0, SERVICE_INDEX_GENERATOR_HEADER_COMMENT);
3312
- const serviceFiles = fs.readdirSync(servicesDir).filter((file) => file.endsWith(".resource.ts")).map((file) => file.replace(".resource.ts", ""));
3313
- serviceFiles.forEach((serviceName) => {
3314
- const className = pascalCase(serviceName) + "Resource";
3325
+ resourceFiles.forEach((resourceName) => {
3326
+ const className = pascalCase(resourceName) + "Resource";
3315
3327
  sourceFile.addExportDeclaration({
3316
3328
  namedExports: [
3317
3329
  className
3318
3330
  ],
3319
- moduleSpecifier: `./${serviceName}.resource`
3331
+ moduleSpecifier: `./${resourceName}.resource`
3320
3332
  });
3321
3333
  });
3322
3334
  sourceFile.formatText();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-openapi/http-resource",
3
- "version": "0.1.0",
3
+ "version": "0.1.1-pr-107-fix-pathless-spec-service-index-ae0aa36.0",
4
4
  "description": "HTTP Resource plugin for ng-openapi - Angular HTTP utilities with caching and state management",
5
5
  "keywords": [
6
6
  "angular",