@common-stack/rollup-vite-utils 7.1.1-alpha.3 → 7.1.1-alpha.32

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 (53) hide show
  1. package/lib/preStartup/configLoader/configLoader.cjs +135 -2
  2. package/lib/preStartup/configLoader/configLoader.cjs.map +1 -1
  3. package/lib/preStartup/configLoader/configLoader.js +135 -2
  4. package/lib/preStartup/configLoader/configLoader.js.map +1 -1
  5. package/lib/preStartup/configLoader/index.cjs +1 -1
  6. package/lib/preStartup/configLoader/index.cjs.map +1 -1
  7. package/lib/preStartup/configLoader/index.js +1 -1
  8. package/lib/preStartup/configLoader/index.js.map +1 -1
  9. package/lib/rollup/rollupPluginGenerateJson.cjs +27 -0
  10. package/lib/rollup/rollupPluginGenerateJson.cjs.map +1 -1
  11. package/lib/rollup/rollupPluginGenerateJson.d.ts +10 -0
  12. package/lib/rollup/rollupPluginGenerateJson.js +27 -0
  13. package/lib/rollup/rollupPluginGenerateJson.js.map +1 -1
  14. package/lib/tools/codegen/performCopyOperations.cjs +65 -17
  15. package/lib/tools/codegen/performCopyOperations.cjs.map +1 -1
  16. package/lib/tools/codegen/performCopyOperations.js +65 -17
  17. package/lib/tools/codegen/performCopyOperations.js.map +1 -1
  18. package/lib/tools/codegen/readModules.cjs +40 -2
  19. package/lib/tools/codegen/readModules.cjs.map +1 -1
  20. package/lib/tools/codegen/readModules.js +40 -2
  21. package/lib/tools/codegen/readModules.js.map +1 -1
  22. package/lib/tools/codegen/setupCommonPackage.cjs +14 -5
  23. package/lib/tools/codegen/setupCommonPackage.cjs.map +1 -1
  24. package/lib/tools/codegen/setupCommonPackage.d.ts +1 -1
  25. package/lib/tools/codegen/setupCommonPackage.js +14 -5
  26. package/lib/tools/codegen/setupCommonPackage.js.map +1 -1
  27. package/lib/tools/codegen/templates/common/src/apollo-context.ts.template +1 -16
  28. package/lib/tools/codegen/templates/common/src/client-context.ts.template +19 -0
  29. package/lib/tools/codegen/templates/common/src/core/disposable.ts.template +93 -0
  30. package/lib/tools/codegen/templates/common/src/core/event.test.ts +16 -0
  31. package/lib/tools/codegen/templates/common/src/core/event.ts.template +326 -0
  32. package/lib/tools/codegen/templates/common/src/core/index.ts.template +3 -0
  33. package/lib/tools/codegen/templates/common/src/core/types.ts.template +1 -0
  34. package/lib/tools/codegen/templates/common/src/index.server.ts.template +2 -1
  35. package/lib/tools/codegen/templates/common/src/index.ts.template +1 -0
  36. package/lib/vite-wrappers/generators/clientLoaderGenerator.cjs +11 -3
  37. package/lib/vite-wrappers/generators/clientLoaderGenerator.cjs.map +1 -1
  38. package/lib/vite-wrappers/generators/clientLoaderGenerator.js +11 -3
  39. package/lib/vite-wrappers/generators/clientLoaderGenerator.js.map +1 -1
  40. package/lib/vite-wrappers/generators/utils/resourceParams.cjs +24 -5
  41. package/lib/vite-wrappers/generators/utils/resourceParams.cjs.map +1 -1
  42. package/lib/vite-wrappers/generators/utils/resourceParams.d.ts +10 -4
  43. package/lib/vite-wrappers/generators/utils/resourceParams.js +24 -5
  44. package/lib/vite-wrappers/generators/utils/resourceParams.js.map +1 -1
  45. package/lib/vite-wrappers/json-wrappers.cjs +28 -0
  46. package/lib/vite-wrappers/json-wrappers.cjs.map +1 -1
  47. package/lib/vite-wrappers/json-wrappers.js +28 -0
  48. package/lib/vite-wrappers/json-wrappers.js.map +1 -1
  49. package/lib/vite-wrappers/wrapperComponent.cjs +1 -1
  50. package/lib/vite-wrappers/wrapperComponent.cjs.map +1 -1
  51. package/lib/vite-wrappers/wrapperComponent.js +1 -1
  52. package/lib/vite-wrappers/wrapperComponent.js.map +1 -1
  53. package/package.json +4 -4
@@ -1,4 +1,4 @@
1
- 'use strict';var copyIfVersionChanged=require('../copyIfVersionChanged.cjs');function resolvePath(config, path) {
1
+ 'use strict';var fs=require('fs-extra'),path=require('path'),glob=require('glob'),copyIfVersionChanged=require('../copyIfVersionChanged.cjs'),utils=require('../../utils/utils.cjs');require('fs'),require('ajv');function resolvePath(config, path) {
2
2
  if (typeof path === 'string' && path.startsWith('$.')) {
3
3
  const parts = path.split('.').slice(1); // Remove the leading '$.'
4
4
  if (parts[0] === 'env') {
@@ -42,14 +42,147 @@ function resolveConfigPaths(config) {
42
42
  copyOperations: config.copyOperations.map((op) => ({
43
43
  ...op,
44
44
  destPath: resolvePath(config, op.destPath),
45
+ sourcePath: op.sourcePath ? resolvePath(config, op.sourcePath) : undefined,
45
46
  })),
46
47
  };
47
48
  }
49
+ /**
50
+ * Copies a specific file or folder from a package to a destination
51
+ * @param packageName - Package name containing the source files
52
+ * @param sourcePath - Specific path within the package to copy (relative to package's lib directory)
53
+ * @param destPath - Destination path to copy files to
54
+ * @param appDir - Application directory path
55
+ * @param useSymlink - Whether to create a symbolic link instead of copying
56
+ */
57
+ async function copySpecificPath(packageName, sourcePath, destPath, appDir, useSymlink = false) {
58
+ const initialDir = process.cwd();
59
+ const srcPackageDir = utils.findPackageDir(initialDir, packageName);
60
+ if (!srcPackageDir) {
61
+ console.error(`Failed to find package directory for ${packageName}`);
62
+ return;
63
+ }
64
+ // Construct full source path base
65
+ const baseSourcePath = path.join(srcPackageDir, 'lib');
66
+ const fullSourcePathPattern = path.join(baseSourcePath, sourcePath);
67
+ // Check if the sourcePath contains glob patterns
68
+ const hasGlobPattern = /[*?[\]{}!()]/.test(sourcePath);
69
+ if (hasGlobPattern) {
70
+ // Use glob to find matching files
71
+ try {
72
+ const matchingFiles = await glob.glob(fullSourcePathPattern, { nodir: true });
73
+ if (matchingFiles.length === 0) {
74
+ console.error(`No files found matching pattern: ${fullSourcePathPattern}`);
75
+ return;
76
+ }
77
+ // Ensure destination directory exists
78
+ const fullDestDir = path.resolve(appDir, destPath);
79
+ await fs.ensureDir(fullDestDir);
80
+ // Copy each matching file
81
+ for (const filePath of matchingFiles) {
82
+ const fileName = path.basename(filePath);
83
+ const fileDestPath = path.join(fullDestDir, fileName);
84
+ // Remove existing file if it exists
85
+ if (await fs.pathExists(fileDestPath)) {
86
+ await fs.remove(fileDestPath);
87
+ }
88
+ if (useSymlink) {
89
+ await fs.ensureSymlink(filePath, fileDestPath);
90
+ console.log(`Created symlink from ${filePath} to ${fileDestPath}`);
91
+ }
92
+ else {
93
+ await fs.copy(filePath, fileDestPath, { overwrite: true });
94
+ console.log(`Copied file from ${filePath} to ${fileDestPath}`);
95
+ }
96
+ }
97
+ return;
98
+ }
99
+ catch (err) {
100
+ console.error(`Error copying files matching pattern ${sourcePath}:`, err);
101
+ return;
102
+ }
103
+ }
104
+ // For non-glob patterns, proceed with direct file/folder handling
105
+ const fullSourcePath = path.join(baseSourcePath, sourcePath);
106
+ // Get stats of the source to determine if it's a file or directory
107
+ let stats;
108
+ try {
109
+ // Check if source exists
110
+ if (!(await fs.pathExists(fullSourcePath))) {
111
+ console.error(`Source path ${fullSourcePath} does not exist`);
112
+ return;
113
+ }
114
+ stats = await fs.stat(fullSourcePath);
115
+ }
116
+ catch (err) {
117
+ console.error(`Error accessing source path ${fullSourcePath}:`, err);
118
+ return;
119
+ }
120
+ // Construct destination path based on whether source is a file or directory
121
+ let fullDestPath = path.resolve(appDir, destPath);
122
+ // If the source is a file and the destination appears to be a directory,
123
+ // append the source filename to the destination path
124
+ if (!stats.isDirectory()) {
125
+ const sourceFileName = path.basename(sourcePath);
126
+ // If destPath ends with '/' or looks like a directory
127
+ if (destPath.endsWith('/') || destPath.endsWith('\\')) {
128
+ fullDestPath = path.join(fullDestPath, sourceFileName);
129
+ }
130
+ else {
131
+ // Check if destPath exists and is a directory
132
+ try {
133
+ if ((await fs.pathExists(fullDestPath)) && (await fs.stat(fullDestPath)).isDirectory()) {
134
+ fullDestPath = path.join(fullDestPath, sourceFileName);
135
+ }
136
+ }
137
+ catch (err) {
138
+ // If error, assume it's not a directory
139
+ }
140
+ }
141
+ }
142
+ try {
143
+ // Ensure the destination directory exists
144
+ await fs.ensureDir(path.dirname(fullDestPath));
145
+ if (useSymlink) {
146
+ // Remove existing destination if it exists
147
+ if (await fs.pathExists(fullDestPath)) {
148
+ await fs.remove(fullDestPath);
149
+ }
150
+ // Create symlink
151
+ await fs.ensureSymlink(fullSourcePath, fullDestPath);
152
+ console.log(`Created symlink from ${fullSourcePath} to ${fullDestPath}`);
153
+ }
154
+ else {
155
+ // Remove existing destination if it exists
156
+ if (await fs.pathExists(fullDestPath)) {
157
+ await fs.remove(fullDestPath);
158
+ }
159
+ // Copy file or directory
160
+ if (stats.isDirectory()) {
161
+ await fs.copy(fullSourcePath, fullDestPath, { overwrite: true });
162
+ console.log(`Copied directory from ${fullSourcePath} to ${fullDestPath}`);
163
+ }
164
+ else {
165
+ await fs.copy(fullSourcePath, fullDestPath, { overwrite: true });
166
+ console.log(`Copied file from ${fullSourcePath} to ${fullDestPath}`);
167
+ }
168
+ }
169
+ }
170
+ catch (err) {
171
+ console.error(`Error copying specific path ${sourcePath} from ${packageName}:`, err);
172
+ }
173
+ }
48
174
  async function performCopyOperations(config) {
49
175
  const resolvedConfig = resolveConfigPaths(config);
50
176
  for (const operation of resolvedConfig.copyOperations) {
51
177
  try {
52
- await copyIfVersionChanged.copyIfVersionChanged(operation.packageName, resolvedConfig.commonPaths.appPath, operation.destPath, operation.generateModule, operation.symbolicLink, resolvedConfig.modules, resolvedConfig.copyOperations);
178
+ if (operation.sourcePath) {
179
+ // If sourcePath is provided, use the specific copy functionality
180
+ await copySpecificPath(operation.packageName, operation.sourcePath, operation.destPath, resolvedConfig.commonPaths.appPath, operation.symbolicLink);
181
+ }
182
+ else {
183
+ // Use the existing copyIfVersionChanged for entire package
184
+ await copyIfVersionChanged.copyIfVersionChanged(operation.packageName, resolvedConfig.commonPaths.appPath, operation.destPath, operation.generateModule, operation.symbolicLink, resolvedConfig.modules, resolvedConfig.copyOperations);
185
+ }
53
186
  console.log(`Copy operation for ${operation.packageName} completed successfully.`);
54
187
  }
55
188
  catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"configLoader.cjs","sources":["../../../src/preStartup/configLoader/configLoader.ts"],"sour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C,WAAW,CAA0B,wBAAA,CAAA,CAAC,CAAC;SACtF;QAAC,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,CAA6B,0BAAA,EAAA,SAAS,CAAC,WAAW,CAAG,CAAA,CAAA,EAAE,GAAG,CAAC,CAAC;SAC7E;KACJ;AACL"}
1
+ {"version":3,"file":"configLoader.cjs","sources":["../../../src/preStartup/configLoader/configLoader.ts"],"sourcesContent":[null],"names":["findPackageDir","glob","copyIfVersionChanged"],"mappings":"kNAMgB,SAAA,WAAW,CAAC,MAAM,EAAE,IAAI,EAAA;AACpC,IAAA,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;AACnD,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEvC,QAAA,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE;AACpB,YAAA,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAErC,YAAA,IAAI,CAAC,QAAQ,IAAI,CAAC,YAAY,EAAE;AAC5B,gBAAA,MAAM,IAAI,KAAK,CAAC,wBAAwB,MAAM,CAAA,gBAAA,CAAkB,CAAC,CAAC;aACrE;AAED,YAAA,MAAM,aAAa,GAAG,QAAQ,IAAI,YAAY,CAAC;AAE/C,YAAA,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE;AACpB,gBAAA,IAAI;AACA,oBAAA,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC;AACnC,oBAAA,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,UAAU,EAAE;wBACzB,OAAO,GAAG,CA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EACtB,cAAc,CAAC,OAAO,EACtB,cAAc,CAAC,cAAc,CAChC,CAAC;aACL;YACD,OAAO,CAAC,GAAG,CAAC,CAAA,mBAAA,EAAsB,SAAS,CAAC,WAAW,CAA0B,wBAAA,CAAA,CAAC,CAAC;SACtF;QAAC,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,CAA6B,0BAAA,EAAA,SAAS,CAAC,WAAW,CAAG,CAAA,CAAA,EAAE,GAAG,CAAC,CAAC;SAC7E;KACJ;AACL"}
@@ -1,4 +1,4 @@
1
- import {copyIfVersionChanged}from'../copyIfVersionChanged.js';function resolvePath(config, path) {
1
+ import fs from'fs-extra';import path__default from'path';import {glob}from'glob';import {copyIfVersionChanged}from'../copyIfVersionChanged.js';import {findPackageDir}from'../../utils/utils.js';import'fs';import'ajv';function resolvePath(config, path) {
2
2
  if (typeof path === 'string' && path.startsWith('$.')) {
3
3
  const parts = path.split('.').slice(1); // Remove the leading '$.'
4
4
  if (parts[0] === 'env') {
@@ -42,14 +42,147 @@ function resolveConfigPaths(config) {
42
42
  copyOperations: config.copyOperations.map((op) => ({
43
43
  ...op,
44
44
  destPath: resolvePath(config, op.destPath),
45
+ sourcePath: op.sourcePath ? resolvePath(config, op.sourcePath) : undefined,
45
46
  })),
46
47
  };
47
48
  }
49
+ /**
50
+ * Copies a specific file or folder from a package to a destination
51
+ * @param packageName - Package name containing the source files
52
+ * @param sourcePath - Specific path within the package to copy (relative to package's lib directory)
53
+ * @param destPath - Destination path to copy files to
54
+ * @param appDir - Application directory path
55
+ * @param useSymlink - Whether to create a symbolic link instead of copying
56
+ */
57
+ async function copySpecificPath(packageName, sourcePath, destPath, appDir, useSymlink = false) {
58
+ const initialDir = process.cwd();
59
+ const srcPackageDir = findPackageDir(initialDir, packageName);
60
+ if (!srcPackageDir) {
61
+ console.error(`Failed to find package directory for ${packageName}`);
62
+ return;
63
+ }
64
+ // Construct full source path base
65
+ const baseSourcePath = path__default.join(srcPackageDir, 'lib');
66
+ const fullSourcePathPattern = path__default.join(baseSourcePath, sourcePath);
67
+ // Check if the sourcePath contains glob patterns
68
+ const hasGlobPattern = /[*?[\]{}!()]/.test(sourcePath);
69
+ if (hasGlobPattern) {
70
+ // Use glob to find matching files
71
+ try {
72
+ const matchingFiles = await glob(fullSourcePathPattern, { nodir: true });
73
+ if (matchingFiles.length === 0) {
74
+ console.error(`No files found matching pattern: ${fullSourcePathPattern}`);
75
+ return;
76
+ }
77
+ // Ensure destination directory exists
78
+ const fullDestDir = path__default.resolve(appDir, destPath);
79
+ await fs.ensureDir(fullDestDir);
80
+ // Copy each matching file
81
+ for (const filePath of matchingFiles) {
82
+ const fileName = path__default.basename(filePath);
83
+ const fileDestPath = path__default.join(fullDestDir, fileName);
84
+ // Remove existing file if it exists
85
+ if (await fs.pathExists(fileDestPath)) {
86
+ await fs.remove(fileDestPath);
87
+ }
88
+ if (useSymlink) {
89
+ await fs.ensureSymlink(filePath, fileDestPath);
90
+ console.log(`Created symlink from ${filePath} to ${fileDestPath}`);
91
+ }
92
+ else {
93
+ await fs.copy(filePath, fileDestPath, { overwrite: true });
94
+ console.log(`Copied file from ${filePath} to ${fileDestPath}`);
95
+ }
96
+ }
97
+ return;
98
+ }
99
+ catch (err) {
100
+ console.error(`Error copying files matching pattern ${sourcePath}:`, err);
101
+ return;
102
+ }
103
+ }
104
+ // For non-glob patterns, proceed with direct file/folder handling
105
+ const fullSourcePath = path__default.join(baseSourcePath, sourcePath);
106
+ // Get stats of the source to determine if it's a file or directory
107
+ let stats;
108
+ try {
109
+ // Check if source exists
110
+ if (!(await fs.pathExists(fullSourcePath))) {
111
+ console.error(`Source path ${fullSourcePath} does not exist`);
112
+ return;
113
+ }
114
+ stats = await fs.stat(fullSourcePath);
115
+ }
116
+ catch (err) {
117
+ console.error(`Error accessing source path ${fullSourcePath}:`, err);
118
+ return;
119
+ }
120
+ // Construct destination path based on whether source is a file or directory
121
+ let fullDestPath = path__default.resolve(appDir, destPath);
122
+ // If the source is a file and the destination appears to be a directory,
123
+ // append the source filename to the destination path
124
+ if (!stats.isDirectory()) {
125
+ const sourceFileName = path__default.basename(sourcePath);
126
+ // If destPath ends with '/' or looks like a directory
127
+ if (destPath.endsWith('/') || destPath.endsWith('\\')) {
128
+ fullDestPath = path__default.join(fullDestPath, sourceFileName);
129
+ }
130
+ else {
131
+ // Check if destPath exists and is a directory
132
+ try {
133
+ if ((await fs.pathExists(fullDestPath)) && (await fs.stat(fullDestPath)).isDirectory()) {
134
+ fullDestPath = path__default.join(fullDestPath, sourceFileName);
135
+ }
136
+ }
137
+ catch (err) {
138
+ // If error, assume it's not a directory
139
+ }
140
+ }
141
+ }
142
+ try {
143
+ // Ensure the destination directory exists
144
+ await fs.ensureDir(path__default.dirname(fullDestPath));
145
+ if (useSymlink) {
146
+ // Remove existing destination if it exists
147
+ if (await fs.pathExists(fullDestPath)) {
148
+ await fs.remove(fullDestPath);
149
+ }
150
+ // Create symlink
151
+ await fs.ensureSymlink(fullSourcePath, fullDestPath);
152
+ console.log(`Created symlink from ${fullSourcePath} to ${fullDestPath}`);
153
+ }
154
+ else {
155
+ // Remove existing destination if it exists
156
+ if (await fs.pathExists(fullDestPath)) {
157
+ await fs.remove(fullDestPath);
158
+ }
159
+ // Copy file or directory
160
+ if (stats.isDirectory()) {
161
+ await fs.copy(fullSourcePath, fullDestPath, { overwrite: true });
162
+ console.log(`Copied directory from ${fullSourcePath} to ${fullDestPath}`);
163
+ }
164
+ else {
165
+ await fs.copy(fullSourcePath, fullDestPath, { overwrite: true });
166
+ console.log(`Copied file from ${fullSourcePath} to ${fullDestPath}`);
167
+ }
168
+ }
169
+ }
170
+ catch (err) {
171
+ console.error(`Error copying specific path ${sourcePath} from ${packageName}:`, err);
172
+ }
173
+ }
48
174
  async function performCopyOperations(config) {
49
175
  const resolvedConfig = resolveConfigPaths(config);
50
176
  for (const operation of resolvedConfig.copyOperations) {
51
177
  try {
52
- await copyIfVersionChanged(operation.packageName, resolvedConfig.commonPaths.appPath, operation.destPath, operation.generateModule, operation.symbolicLink, resolvedConfig.modules, resolvedConfig.copyOperations);
178
+ if (operation.sourcePath) {
179
+ // If sourcePath is provided, use the specific copy functionality
180
+ await copySpecificPath(operation.packageName, operation.sourcePath, operation.destPath, resolvedConfig.commonPaths.appPath, operation.symbolicLink);
181
+ }
182
+ else {
183
+ // Use the existing copyIfVersionChanged for entire package
184
+ await copyIfVersionChanged(operation.packageName, resolvedConfig.commonPaths.appPath, operation.destPath, operation.generateModule, operation.symbolicLink, resolvedConfig.modules, resolvedConfig.copyOperations);
185
+ }
53
186
  console.log(`Copy operation for ${operation.packageName} completed successfully.`);
54
187
  }
55
188
  catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"configLoader.js","sources":["../../../src/preStartup/configLoader/configLoader.ts"],"sourcesContent":[null],"names":[],"mappings":"8DAEgB,SAAA,WAAW,CAAC,MAAM,EAAE,IAAI,EAAA;AACpC,IAAA,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;AACnD,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEvC,QAAA,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE;AACpB,YAAA,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAErC,YAAA,IAAI,CAAC,QAAQ,IAAI,CAAC,YAAY,EAAE;AAC5B,gBAAA,MAAM,IAAI,KAAK,CAAC,wBAAwB,MAAM,CAAA,gBAAA,CAAkB,CAAC,CAAC;aACrE;AAED,YAAA,MAAM,aAAa,GAAG,QAAQ,IAAI,YAAY,CAAC;AAE/C,YAAA,IAAI,KAA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AC;KACN,CAAC;AACN,CAAC;AAEM,eAAe,qBAAqB,CAAC,MAAM,EAAA;AAC9C,IAAA,MAAM,cAAc,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAClD,IAAA,KAAK,MAAM,SAAS,IAAI,cAAc,CAAC,cAAc,EAAE;AACnD,QAAA,IAAI;AACA,YAAA,MAAM,oBAAoB,CACtB,SAAS,CAAC,WAAW,EACrB,cAAc,CAAC,WAAW,CAAC,OAAO,EAClC,SAAS,CAAC,QAAQ,EAClB,SAAS,CAAC,cAAc,EACxB,SAAS,CAAC,YAAY,EACtB,cAAc,CAAC,OAAO,EACtB,cAAc,CAAC,cAAc,CAChC,CAAC;YACF,OAAO,CAAC,GAAG,CAAC,CAAA,mBAAA,EAAsB,SAAS,CAAC,WAAW,CAA0B,wBAAA,CAAA,CAAC,CAAC;SACtF;QAAC,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,CAA6B,0BAAA,EAAA,SAAS,CAAC,WAAW,CAAG,CAAA,CAAA,EAAE,GAAG,CAAC,CAAC;SAC7E;KACJ;AACL"}
1
+ {"version":3,"file":"configLoader.js","sources":["../../../src/preStartup/configLoader/configLoader.ts"],"sourcesContent":[null],"names":["path"],"mappings":"wNAMgB,SAAA,WAAW,CAAC,MAAM,EAAE,IAAI,EAAA;AACpC,IAAA,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;AACnD,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEvC,QAAA,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE;AACpB,YAAA,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnD,MAAM,QAAQ,GAAG,OAAO,CAAC,GA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C;AAClD,IAAA,KAAK,MAAM,SAAS,IAAI,cAAc,CAAC,cAAc,EAAE;AACnD,QAAA,IAAI;AACA,YAAA,IAAI,SAAS,CAAC,UAAU,EAAE;;gBAEtB,MAAM,gBAAgB,CAClB,SAAS,CAAC,WAAW,EACrB,SAAS,CAAC,UAAU,EACpB,SAAS,CAAC,QAAQ,EAClB,cAAc,CAAC,WAAW,CAAC,OAAO,EAClC,SAAS,CAAC,YAAY,CACzB,CAAC;aACL;iBAAM;;AAEH,gBAAA,MAAM,oBAAoB,CACtB,SAAS,CAAC,WAAW,EACrB,cAAc,CAAC,WAAW,CAAC,OAAO,EAClC,SAAS,CAAC,QAAQ,EAClB,SAAS,CAAC,cAAc,EACxB,SAAS,CAAC,YAAY,EACtB,cAAc,CAAC,OAAO,EACtB,cAAc,CAAC,cAAc,CAChC,CAAC;aACL;YACD,OAAO,CAAC,GAAG,CAAC,CAAA,mBAAA,EAAsB,SAAS,CAAC,WAAW,CAA0B,wBAAA,CAAA,CAAC,CAAC;SACtF;QAAC,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,CAA6B,0BAAA,EAAA,SAAS,CAAC,WAAW,CAAG,CAAA,CAAA,EAAE,GAAG,CAAC,CAAC;SAC7E;KACJ;AACL"}
@@ -1 +1 @@
1
- 'use strict';var node=require('@remix-run/node');require('fs-extra'),require('path'),require('semver'),require('fs'),require('ajv'),require('dotenv-esm');node.installGlobals();//# sourceMappingURL=index.cjs.map
1
+ 'use strict';var node=require('@remix-run/node');require('fs-extra'),require('path'),require('glob'),require('semver'),require('fs'),require('ajv'),require('dotenv-esm');node.installGlobals();//# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/preStartup/configLoader/index.ts"],"sourcesContent":[null],"names":["installGlobals"],"mappings":"0JAKAA,mBAAc,EAAE"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../src/preStartup/configLoader/index.ts"],"sourcesContent":[null],"names":["installGlobals"],"mappings":"0KAKAA,mBAAc,EAAE"}
@@ -1 +1 @@
1
- import {installGlobals}from'@remix-run/node';import'fs-extra';import'path';import'semver';import'fs';import'ajv';import'dotenv-esm';installGlobals();//# sourceMappingURL=index.js.map
1
+ import {installGlobals}from'@remix-run/node';import'fs-extra';import'path';import'glob';import'semver';import'fs';import'ajv';import'dotenv-esm';installGlobals();//# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/preStartup/configLoader/index.ts"],"sourcesContent":[null],"names":[],"mappings":"oIAKA,cAAc,EAAE"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/preStartup/configLoader/index.ts"],"sourcesContent":[null],"names":[],"mappings":"iJAKA,cAAc,EAAE"}
@@ -25,6 +25,33 @@
25
25
  this.warn(`Error importing ${file}: ${error}`);
26
26
  }
27
27
  }
28
+ // Apply route overrides if specified in settings
29
+ if (options.settings?.overrideRoutes && allFilteredRoutes.length > 0) {
30
+ const routeOverrides = Array.isArray(options.settings.overrideRoutes)
31
+ ? options.settings.overrideRoutes
32
+ : [options.settings.overrideRoutes];
33
+ // Create a new array to store updated routes
34
+ const updatedRoutes = [...allFilteredRoutes];
35
+ // Process each route override
36
+ for (const override of routeOverrides) {
37
+ const { oldRoute, newRoute } = override;
38
+ // Find all route entries with the oldRoute path
39
+ updatedRoutes.forEach((routeEntry, index) => {
40
+ const routeKey = Object.keys(routeEntry)[0];
41
+ const routeConfig = routeEntry[routeKey];
42
+ // If this entry has the old route path, update it
43
+ if (routeKey === oldRoute) {
44
+ // Create a new route entry with the updated path
45
+ const updatedConfig = { ...routeConfig, path: newRoute };
46
+ updatedRoutes[index] = { [newRoute]: updatedConfig };
47
+ console.log(`Overriding route: ${oldRoute} -> ${newRoute}`);
48
+ }
49
+ });
50
+ }
51
+ // Replace the original array with the updated one
52
+ allFilteredRoutes.length = 0;
53
+ allFilteredRoutes.push(...updatedRoutes);
54
+ }
28
55
  // Ensure the dist directory exists
29
56
  if (!fs.existsSync(dist)) {
30
57
  fs.mkdirSync(dist, { recursive: true });
@@ -1 +1 @@
1
- {"version":3,"file":"rollupPluginGenerateJson.cjs","sources":["../../src/rollup/rollupPluginGenerateJson.ts"],"sourcesContent":[null],"names":["glob"],"mappings":"qIAWc,SAAU,6BAA6B,CAAC,UAA+B,EAAE,EAAA;AACnF,IAAA,MAAM,EACF,OAAO,GAAG,kBAAkB;IAC5B,IAAI,GAAG,KAAK;IACZ,UAAU,GAAG,aAAa;AAC7B,MAAA,GAAG,OAAO,CAAC;IAEZ,OAAO;AACH,QAAA,IAAI,EAAE,0BAA0B;AAChC,QAAA,MAAM,WAAW,GAAA;;YAEb,MAAM,KAAK,GAAa,MAAMA,SAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;YACjF,MAAM,iBAAiB,GAAyB,EAAE,CAAC;AACnD,YAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;AACtB,gBAAA,IAAI;;oBAEA,MAAM,MAAM,GAAuC,MAAM,OAAO,IAAI,CAAC,CAAC;AACtE,oBAAA,IAAI,MAAM,CAAC,cAAc,EAAE;wBACvB,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,aAAa,KAAI;4BAC1D,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;4BACnD,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,GAAG,UAAU,EAAE,CAAC;AAC7C,yBAAC,CAAC,CAAC;AACH,wBAAA,iBAAiB,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;qBACxC;iBACJ;gBAAC,OAAO,KAAK,EAAE;oBACZ,IAAI,CAAC,IAAI,CAAC,CAAA,gBAAA,EAAmB,IAAI,CAAK,EAAA,EAAA,KAAK,CAAE,CAAA,CAAC,CAAC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AQ,EAAE,CAAC;4BACzD,aAAa,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,QAAQ,GAAG,aAAa,EAAE,CAAC;4BAErD,OAAO,CAAC,GAAG,CAAC,CAAA,kBAAA,EAAqB,QAAQ,CAAO,IAAA,EAAA,QAAQ,CAAE,CAAA,CAAC,CAAC;yBAC/D;AACL,qBAAC,CAAC,CAAC;iBACN;;AAGD,gBAAA,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC;AAC7B,gBAAA,iBAAiB,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;aAC5C;;YAGD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;gBACtB,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;aAC3C;;YAED,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAC/C,YAAA,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACjF,YAAA,OAAO,CAAC,GAAG,CAAC,mDAAmD,UAAU,CAAA,CAAE,CAAC,CAAC;SAChF;KACJ,CAAC;AACN"}
@@ -2,6 +2,16 @@ interface GenerateJsonOptions {
2
2
  pattern?: string;
3
3
  dist?: string;
4
4
  outputFile?: string;
5
+ settings?: {
6
+ overrideRoutes?: {
7
+ oldRoute: string;
8
+ newRoute: string;
9
+ } | Array<{
10
+ oldRoute: string;
11
+ newRoute: string;
12
+ }>;
13
+ [key: string]: unknown;
14
+ };
5
15
  }
6
16
  export default function generateJsonFromSpecificFiles(options?: GenerateJsonOptions): {
7
17
  name: string;
@@ -25,6 +25,33 @@ import {glob}from'glob';import fs__default from'fs';import path__default from'pa
25
25
  this.warn(`Error importing ${file}: ${error}`);
26
26
  }
27
27
  }
28
+ // Apply route overrides if specified in settings
29
+ if (options.settings?.overrideRoutes && allFilteredRoutes.length > 0) {
30
+ const routeOverrides = Array.isArray(options.settings.overrideRoutes)
31
+ ? options.settings.overrideRoutes
32
+ : [options.settings.overrideRoutes];
33
+ // Create a new array to store updated routes
34
+ const updatedRoutes = [...allFilteredRoutes];
35
+ // Process each route override
36
+ for (const override of routeOverrides) {
37
+ const { oldRoute, newRoute } = override;
38
+ // Find all route entries with the oldRoute path
39
+ updatedRoutes.forEach((routeEntry, index) => {
40
+ const routeKey = Object.keys(routeEntry)[0];
41
+ const routeConfig = routeEntry[routeKey];
42
+ // If this entry has the old route path, update it
43
+ if (routeKey === oldRoute) {
44
+ // Create a new route entry with the updated path
45
+ const updatedConfig = { ...routeConfig, path: newRoute };
46
+ updatedRoutes[index] = { [newRoute]: updatedConfig };
47
+ console.log(`Overriding route: ${oldRoute} -> ${newRoute}`);
48
+ }
49
+ });
50
+ }
51
+ // Replace the original array with the updated one
52
+ allFilteredRoutes.length = 0;
53
+ allFilteredRoutes.push(...updatedRoutes);
54
+ }
28
55
  // Ensure the dist directory exists
29
56
  if (!fs__default.existsSync(dist)) {
30
57
  fs__default.mkdirSync(dist, { recursive: true });
@@ -1 +1 @@
1
- {"version":3,"file":"rollupPluginGenerateJson.js","sources":["../../src/rollup/rollupPluginGenerateJson.ts"],"sourcesContent":[null],"names":["path","fs"],"mappings":"oFAWc,SAAU,6BAA6B,CAAC,UAA+B,EAAE,EAAA;AACnF,IAAA,MAAM,EACF,OAAO,GAAG,kBAAkB;IAC5B,IAAI,GAAG,KAAK;IACZ,UAAU,GAAG,aAAa;AAC7B,MAAA,GAAG,OAAO,CAAC;IAEZ,OAAO;AACH,QAAA,IAAI,EAAE,0BAA0B;AAChC,QAAA,MAAM,WAAW,GAAA;;YAEb,MAAM,KAAK,GAAa,MAAM,IAAI,CAACA,aAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,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UAAU,GAAGD,aAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAC/C,YAAAC,WAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACjF,YAAA,OAAO,CAAC,GAAG,CAAC,mDAAmD,UAAU,CAAA,CAAE,CAAC,CAAC;SAChF;KACJ,CAAC;AACN"}
@@ -27,6 +27,29 @@
27
27
  */
28
28
  function performCopyOperations(modules, cdecodePaths = {}, options) {
29
29
  let { repoRoot, commonPackagePath } = cdecodePaths;
30
+ // Use the provided commandRunner or default to execSync.
31
+ const commandRunner = options?.commandRunner || ((cmd) => child_process.execSync(cmd));
32
+ // Track which files have been added to index.ts files
33
+ const indexExports = new Map();
34
+ // When adding to an index.ts file, check if the export already exists
35
+ function addToIndex(indexPath, exportName) {
36
+ // Initialize tracking for this index file if needed
37
+ if (!indexExports.has(indexPath)) {
38
+ indexExports.set(indexPath, new Set());
39
+ // Create the index file if it doesn't exist
40
+ if (!fs.existsSync(indexPath)) {
41
+ commandRunner(`touch ${indexPath}`);
42
+ }
43
+ }
44
+ // Check if this export already exists in the index
45
+ const exportsForIndex = indexExports.get(indexPath);
46
+ if (!exportsForIndex.has(exportName)) {
47
+ // Add to tracking
48
+ exportsForIndex.add(exportName);
49
+ // Add to index file
50
+ commandRunner(`echo "${exportName}" >> ${indexPath}`);
51
+ }
52
+ }
30
53
  if (!repoRoot) {
31
54
  repoRoot = commonPaths.pathsConfig.repoRoot;
32
55
  }
@@ -34,8 +57,6 @@ function performCopyOperations(modules, cdecodePaths = {}, options) {
34
57
  // For example, "packages/common"
35
58
  commonPackagePath = path.join(commonPaths.pathsConfig.repoRoot, 'packages/common');
36
59
  }
37
- // Use the provided commandRunner or default to execSync.
38
- const commandRunner = options?.commandRunner || ((cmd) => child_process.execSync(cmd));
39
60
  // Track which resource folders are processed.
40
61
  const processedFolders = {};
41
62
  // Object to collect enum contributions.
@@ -121,7 +142,7 @@ function performCopyOperations(modules, cdecodePaths = {}, options) {
121
142
  // Prepend a comment to indicate the package origin.
122
143
  commandRunner(`(echo "// from package: ${pkgName}" && cat ${destFile}) > ${destFile}.tmp && mv ${destFile}.tmp ${destFile}`);
123
144
  // Append an export statement to the folder's index.
124
- commandRunner(`echo "export * from './${destFileName.replace('.ts', '')}';" >> ${path.join(destFolder, 'index.ts')}`);
145
+ addToIndex(path.join(destFolder, 'index.ts'), `export * from './${destFileName.replace('.ts', '')}';`);
125
146
  // Replace any import from "common" (or from "common/lib/generated/generated-model" or "common/lib/generated/generated-model.js")
126
147
  // with the relative path using a single regex.
127
148
  try {
@@ -140,15 +161,33 @@ function performCopyOperations(modules, cdecodePaths = {}, options) {
140
161
  const serviceBaseName = destFileName.replace('.ts', '');
141
162
  const propertyName = serviceBaseName.charAt(0).toLowerCase() + serviceBaseName.slice(1);
142
163
  const augmentationContent = `\n/**
143
- * This file augments the ServerContext interface from the central apollo-context.
144
- * Through declaration merging, the ${propertyName} will be added to the ServerContext.
145
- */
146
- declare module '../apollo-context' {
147
- export interface ServerContext {
148
- ${propertyName}: I${serviceBaseName};
149
- }
150
- }
151
- `;
164
+ * This file augments the ServerContext interface from the central apollo-context.
165
+ * Through declaration merging, the ${propertyName} will be added to the ServerContext.
166
+ */
167
+ declare module '../apollo-context' {
168
+ export interface ServerContext {
169
+ ${propertyName}: I${serviceBaseName};
170
+ }
171
+ }
172
+ `;
173
+ // Append the augmentation content directly to the service file.
174
+ fs.appendFileSync(destFile, augmentationContent, 'utf8');
175
+ }
176
+ // If this is a service file, instead of creating a separate augmentation file,
177
+ // append the augmentation boilerplate directly to the service file.
178
+ if (folderType === 'clients') {
179
+ const serviceBaseName = destFileName.replace('.ts', '');
180
+ const propertyName = serviceBaseName.charAt(0).toLowerCase() + serviceBaseName.slice(1);
181
+ const augmentationContent = `\n/**
182
+ * This file augments the ClientContext interface from the central apollo-context.
183
+ * Through declaration merging, the ${propertyName} will be added to the ServerContext.
184
+ */
185
+ declare module '../client-context' {
186
+ export interface ClientContext {
187
+ ${propertyName}: I${serviceBaseName};
188
+ }
189
+ }
190
+ `;
152
191
  // Append the augmentation content directly to the service file.
153
192
  fs.appendFileSync(destFile, augmentationContent, 'utf8');
154
193
  }
@@ -185,7 +224,7 @@ declare module '../apollo-context' {
185
224
  // Close the enum declaration.
186
225
  commandRunner(`echo "}" >> ${aggregatedFile}`);
187
226
  // Append an export statement to the enums index.
188
- commandRunner(`echo "export * from './${enumName}';" >> ${path.join(enumDestFolder, 'index.ts')}`);
227
+ addToIndex(path.join(enumDestFolder, 'index.ts'), `export * from './${enumName}';`);
189
228
  }
190
229
  }
191
230
  else {
@@ -216,7 +255,7 @@ declare module '../apollo-context' {
216
255
  // Close the object literal.
217
256
  commandRunner(`echo "};" >> ${aggregatedFile}`);
218
257
  // Append an export statement to the constants index.
219
- commandRunner(`echo "export * from './${constName}';" >> ${path.join(constantsDestFolder, 'index.ts')}`);
258
+ addToIndex(path.join(constantsDestFolder, 'index.ts'), `export * from './${constName}';`);
220
259
  }
221
260
  }
222
261
  else {
@@ -231,7 +270,7 @@ declare module '../apollo-context' {
231
270
  if (processedFolders[folderKey]) {
232
271
  // For services/repositories use index.server.ts; others use index.ts.
233
272
  const globalIndexFileName = folderKey === 'services' || folderKey === 'repositories' ? 'index.server.ts' : 'index.ts';
234
- commandRunner(`echo "export * from './${folderKey}';" >> ${path.join(commonPackagePath, 'src', globalIndexFileName)}`);
273
+ addToIndex(path.join(commonPackagePath, 'src', globalIndexFileName), `export * from './${folderKey}';`);
235
274
  }
236
275
  }
237
276
  // Now, handle constants specially.
@@ -240,12 +279,21 @@ declare module '../apollo-context' {
240
279
  // commandRunner(
241
280
  // `echo "export * from './constants/index';" >> ${path.join(commonPackagePath, 'src', 'index.ts')}`,
242
281
  // );
243
- commandRunner(`echo "export * from './constants';" >> ${path.join(commonPackagePath, 'src', 'index.ts')}`);
282
+ addToIndex(path.join(commonPackagePath, 'src', 'index.ts'), `export * from './constants';`);
244
283
  // Global server index should export from constants/index.server
245
284
  // commandRunner(
246
285
  // `echo "export * from './constants/index.server';" >> ${path.join(commonPackagePath, 'src', 'index.server.ts')}`,
247
286
  // );
248
- commandRunner(`echo "export * from './constants';" >> ${path.join(commonPackagePath, 'src', 'index.server.ts')}`);
287
+ addToIndex(path.join(commonPackagePath, 'src', 'index.server.ts'), `export * from './constants';`);
288
+ }
289
+ console.log('.....processedFolders', JSON.stringify(processedFolders, null, 2));
290
+ if (processedFolders.enums) {
291
+ // commandRunner(`echo "export * from './enums';" >> ${path.join(commonPackagePath, 'src', 'index.ts')}`);
292
+ commandRunner(`echo "export * from './enums';" >> ${path.join(commonPackagePath, 'src', 'index.server.ts')}`);
293
+ }
294
+ if (processedFolders.modules) {
295
+ // commandRunner(`echo "export * from './modules';" >> ${path.join(commonPackagePath, 'src', 'index.ts')}`);
296
+ commandRunner(`echo "export * from './modules';" >> ${path.join(commonPackagePath, 'src', 'index.server.ts')}`);
249
297
  }
250
298
  const filePath = path.join(commonPackagePath, 'src', 'apollo-context.ts');
251
299
  // Check if the file exists