@common-stack/rollup-vite-utils 8.0.1-alpha.0 → 8.0.1-alpha.2

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.
@@ -1,10 +1,25 @@
1
1
  'use strict';var fs=require('fs'),path=require('path'),commonPaths=require('./commonPaths.cjs'),computeModules=require('./computeModules.cjs');/**
2
2
  * Recursively traverse an object (or array), replacing string placeholders
3
3
  * based on the replacements map. Returns a new object/array with substitutions.
4
+ * Modified here to "spread" discovered schemas / documents if they occur in an array.
4
5
  */
5
6
  function fillPlaceholders(input, placeholders) {
6
7
  if (Array.isArray(input)) {
7
- return input.map((el) => fillPlaceholders(el, placeholders));
8
+ const result = [];
9
+ for (const el of input) {
10
+ const filled = fillPlaceholders(el, placeholders);
11
+ // If the original element is the placeholder and its substitution is an array,
12
+ // spread the array's contents instead of inserting it as a nested array.
13
+ if (typeof el === 'string' &&
14
+ (el === '%discoveredSchemas%' || el === '%discoveredDocuments%') &&
15
+ Array.isArray(filled)) {
16
+ result.push(...filled);
17
+ }
18
+ else {
19
+ result.push(filled);
20
+ }
21
+ }
22
+ return result;
8
23
  }
9
24
  if (input && typeof input === 'object') {
10
25
  const resultObj = {};
@@ -78,4 +93,4 @@ export default config;
78
93
  `.trimStart();
79
94
  fs.writeFileSync(OUTPUT_FILE, codegenFileContents);
80
95
  console.log(`Generated codegen config at: ${OUTPUT_FILE}`);
81
- }exports.generateCodegenConfig=generateCodegenConfig;//# sourceMappingURL=generateCodegenConfig.cjs.map
96
+ }exports.fillPlaceholders=fillPlaceholders;exports.generateCodegenConfig=generateCodegenConfig;//# sourceMappingURL=generateCodegenConfig.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"generateCodegenConfig.cjs","sources":["../../../src/tools/codegen/generateCodegenConfig.ts"],"sourcesContent":[null],"names":["computeModules","pathsConfig"],"mappings":"+IAMA;;;AAGG;AACH,SAAS,gBAAgB,CAAC,KAAK,EAAE,YAAY,EAAA;AAC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AAa,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;AACnD,IAAA,OAAO,CAAC,GAAG,CAAC,gCAAgC,WAAW,CAAA,CAAE,CAAC,CAAC;AAC/D"}
1
+ {"version":3,"file":"generateCodegenConfig.cjs","sources":["../../../src/tools/codegen/generateCodegenConfig.ts"],"sourcesContent":[null],"names":["computeModules","pathsConfig"],"mappings":"+IAMA;;;;AAIG;AACa,SAAA,gBAAgB,CAC5B,KAAU,EACV,YAIC,EAAA;AAED,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACtB,MAAM,MAAM,GAAU,EAAE,CAAC;AACzB,QAAA,KAAK,MAAM,EAAE,IAAI,KAAK,EAAE;YACpB,MAAM,MAAM,GAAG,gBAAgB,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;;;YAGlD,IACI,OAAO,EAAE,KAAK,QAAQ;AACtB,iBAAC,EAAE,KAAK,qBAAqB,IAAI,EAAE,KAAK,uBAAuB,CAAC;AAChE,gBAAA,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EACvB;AACE,gBAAA,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;aAC1B;iBAAM;AACH,gBAAA,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACvB;SACJ;AACD,QAAA,OAAO,MAAM,CAAC;KACjB;AACD,IAAA,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QACpC,MAAM,SAAS,GAAwB,EAAE,CAAC;AAC1C,QAAA,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAC5C,SAAS,CAAC,GAAG,CAAC,GAAG,gBAAgB,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;SACxD;AACD,QAAA,OAAO,SAAS,CAAC;KACpB;AACD,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;;AAE3B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CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;;IAG3G,IAAI,CAAC,eAAe,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;AACjD,QAAA,OAAO,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;KAC5F;;;AAID,IAAA,MAAM,UAAU,GAAG,cAAc,CAAC,UAAU,IAAI,EAAE,CAAC;;AAGnD,IAAA,MAAM,eAAe,GAAG;AACpB,QAAA,iBAAiB,EAAE,eAAe;AAClC,QAAA,mBAAmB,EAAE,YAAY;AACjC,QAAA,aAAa,EAAE,cAAc,CAAC,UAAU,IAAI,qDAAqD;KACpG,CAAC;;IAGF,MAAM,WAAW,GAAG,gBAAgB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;;;;;;AAQlE,IAAA,MAAM,mBAAmB,GAAG,CAAA;;iBAEf,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;;;CAGpD,CAAC,SAAS,EAAE,CAAC;AAEV,IAAA,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;AACnD,IAAA,OAAO,CAAC,GAAG,CAAC,gCAAgC,WAAW,CAAA,CAAE,CAAC,CAAC;AAC/D"}
@@ -1,3 +1,13 @@
1
+ /**
2
+ * Recursively traverse an object (or array), replacing string placeholders
3
+ * based on the replacements map. Returns a new object/array with substitutions.
4
+ * Modified here to "spread" discovered schemas / documents if they occur in an array.
5
+ */
6
+ export declare function fillPlaceholders(input: any, placeholders: {
7
+ discoveredSchemas: string[];
8
+ discoveredDocuments: string[];
9
+ primarySchema: string;
10
+ }): any;
1
11
  /**
2
12
  * Generates the "codegen.ts" file based on discovered modules.
3
13
  * We read placeholders (%discoveredSchemas%, %discoveredDocuments%, etc.)
@@ -1,10 +1,25 @@
1
1
  import fs__default from'fs';import path__default from'path';import {pathsConfig}from'./commonPaths.js';import {computeModules}from'./computeModules.js';/**
2
2
  * Recursively traverse an object (or array), replacing string placeholders
3
3
  * based on the replacements map. Returns a new object/array with substitutions.
4
+ * Modified here to "spread" discovered schemas / documents if they occur in an array.
4
5
  */
5
6
  function fillPlaceholders(input, placeholders) {
6
7
  if (Array.isArray(input)) {
7
- return input.map((el) => fillPlaceholders(el, placeholders));
8
+ const result = [];
9
+ for (const el of input) {
10
+ const filled = fillPlaceholders(el, placeholders);
11
+ // If the original element is the placeholder and its substitution is an array,
12
+ // spread the array's contents instead of inserting it as a nested array.
13
+ if (typeof el === 'string' &&
14
+ (el === '%discoveredSchemas%' || el === '%discoveredDocuments%') &&
15
+ Array.isArray(filled)) {
16
+ result.push(...filled);
17
+ }
18
+ else {
19
+ result.push(filled);
20
+ }
21
+ }
22
+ return result;
8
23
  }
9
24
  if (input && typeof input === 'object') {
10
25
  const resultObj = {};
@@ -78,4 +93,4 @@ export default config;
78
93
  `.trimStart();
79
94
  fs__default.writeFileSync(OUTPUT_FILE, codegenFileContents);
80
95
  console.log(`Generated codegen config at: ${OUTPUT_FILE}`);
81
- }export{generateCodegenConfig};//# sourceMappingURL=generateCodegenConfig.js.map
96
+ }export{fillPlaceholders,generateCodegenConfig};//# sourceMappingURL=generateCodegenConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generateCodegenConfig.js","sources":["../../../src/tools/codegen/generateCodegenConfig.ts"],"sourcesContent":[null],"names":["path","fs"],"mappings":"wJAMA;;;AAGG;AACH,SAAS,gBAAgB,CAAC,KAAK,EAAE,YAAY,EAAA;AACzC,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACtB,QAAA,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,gBAAgB,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC,CAAC;KAChE;AACD,IAAA,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QACpC,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,QAAA,K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,GAAG;AACpB,QAAA,iBAAiB,EAAE,eAAe;AAClC,QAAA,mBAAmB,EAAE,YAAY;AACjC,QAAA,aAAa,EAAE,cAAc,CAAC,UAAU,IAAI,qDAAqD;KACpG,CAAC;;IAGF,MAAM,WAAW,GAAG,gBAAgB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;;;;;;AAQlE,IAAA,MAAM,mBAAmB,GAAG,CAAA;;iBAEf,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;;;CAGpD,CAAC,SAAS,EAAE,CAAC;AAEV,IAAAC,WAAE,CAAC,aAAa,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;AACnD,IAAA,OAAO,CAAC,GAAG,CAAC,gCAAgC,WAAW,CAAA,CAAE,CAAC,CAAC;AAC/D"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Module Path Parser and Stringifier
3
+ *
4
+ * Universal Module Path Format:
5
+ * For modules with a particular variant:
6
+ * <moduleBase>/<variant>/${libDir}
7
+ * For independent modules:
8
+ * <moduleBase>/${libDir}
9
+ *
10
+ * This module provides two functions:
11
+ * - parseModulePath: parses a module path string into its components.
12
+ * - stringifyModulePath: converts the components back into a module path string.
13
+ */
14
+ export interface ModulePathParts {
15
+ /**
16
+ * The base part of the module path, for example:
17
+ * "packages-modules/account-api" or "node_modules/@container-stack/file-info-server"
18
+ */
19
+ moduleBase: string;
20
+ /**
21
+ * The resource variant, for example: "client", "core", "browser", "server".
22
+ * This is optional, as independent modules do not include a variant.
23
+ */
24
+ variant?: string;
25
+ /**
26
+ * This is the library directory token or its resolved value.
27
+ * In our configuration it is typically the placeholder "${libDir}".
28
+ */
29
+ libDir: string;
30
+ }
31
+ /**
32
+ * Parses a module path string into its constituent parts.
33
+ *
34
+ * The function will try to match one of two patterns:
35
+ *
36
+ * 1. <moduleBase>/<variant>/<libDir>
37
+ * 2. <moduleBase>/<libDir>
38
+ *
39
+ * If neither pattern matches, the function returns null.
40
+ *
41
+ * @param modulePath - The module path string to parse.
42
+ * @returns An object containing the parsed parts, or null if parsing fails.
43
+ */
44
+ export declare function parseModulePath(modulePath: string): ModulePathParts | null;
45
+ /**
46
+ * Converts the provided ModulePathParts object back to a module path string.
47
+ *
48
+ * If the variant is provided, the format will be:
49
+ * <moduleBase>/<variant>/<libDir>
50
+ * Otherwise, it is considered an independent module and formatted as:
51
+ * <moduleBase>/<libDir>
52
+ *
53
+ * @param parts - The ModulePathParts object.
54
+ * @returns The combined module path string.
55
+ */
56
+ export declare function stringifyModulePath(parts: ModulePathParts): string;
@@ -1,65 +1,236 @@
1
- 'use strict';var child_process=require('child_process'),fs=require('fs'),path=require('path'),commonPaths=require('./commonPaths.cjs');/**
2
- * For each discovered module, if "cdecode.common" is found in
3
- * the package.json, copy the specified files into the common package.
1
+ 'use strict';var child_process=require('child_process'),fs=require('fs'),path=require('path'),replaceInFile=require('replace-in-file'),commonPaths=require('./commonPaths.cjs');/* eslint-disable no-template-curly-in-string */
2
+ /* eslint-disable no-continue */
3
+ /* eslint-disable default-param-last */
4
+ /* eslint-disable @typescript-eslint/no-explicit-any */
5
+ /* eslint-disable guard-for-in */
6
+ /**
7
+ * For each discovered module (package), if its package.json defines cdecode.common then this
8
+ * function copies resource files (for keys such as "modules", "services", "repositories", and "enums")
9
+ * from the package's template directory into the common package.
4
10
  *
5
- * Provide optional cdecodePaths = { repoRoot, commonPackagePath } to override
6
- * the defaults in commonPaths.mjs.
11
+ * The new behavior is as follows:
12
+ *
13
+ * 1. The module path provided (for example "packages-modules/user-auth0/core/src")
14
+ * is trimmed (removing any trailing "/src" or "/lib") so that package.json is read from the package root.
15
+ *
16
+ * 2. For keys other than "enums", each resource file (after flattening its full path to just its basename)
17
+ * is copied into the common folder for that key (for example, "common/src/services") and then modified so that
18
+ * a comment is prepended indicating the originating package.
19
+ *
20
+ * 3. For "enums", files with the same flattened name are aggregated across packages.
21
+ * A single merged file is created in "common/src/enums" by wrapping all enum member definitions within
22
+ * an enum declaration, and each contribution is preceded by a comment (e.g. "// from package: user-auth0-core").
23
+ *
24
+ * 4. Finally, the global top-level index (common/src/index.ts) is appended with export statements for each folder type.
25
+ *
26
+ * Note: We no longer create an additional module (package) directory in the destination.
7
27
  */
8
- function performCopyOperations(modules, cdecodePaths = {}) {
28
+ function performCopyOperations(modules, cdecodePaths = {}, options) {
9
29
  let { repoRoot, commonPackagePath } = cdecodePaths;
10
- // Fallback to internal pathsConfig if not provided by user
11
30
  if (!repoRoot) {
12
31
  repoRoot = commonPaths.pathsConfig.repoRoot;
13
32
  }
14
33
  if (!commonPackagePath) {
15
- // e.g. "packages/common"
34
+ // For example, "packages/common"
16
35
  commonPackagePath = path.join(commonPaths.pathsConfig.repoRoot, 'packages/common');
17
36
  }
18
- let shouldAddExport = false;
19
- for (const modulesObj of modules) {
20
- // modulesObj = { client, core, browser, server, independent }
21
- for (const moduleName of Object.values(modulesObj)) {
37
+ // Use the provided commandRunner or default to execSync.
38
+ const commandRunner = options?.commandRunner || ((cmd) => child_process.execSync(cmd));
39
+ // Track which resource folders are processed.
40
+ const processedFolders = {};
41
+ // Object to collect enum contributions.
42
+ // Key is the flattened destination file name (e.g. "auth-error.ts"),
43
+ // value is an array with the source file and package name.
44
+ const aggregatedEnums = {};
45
+ // Object to collect constant contributions.
46
+ // Key is the flattened destination file name (e.g. "TYPES.ts"),
47
+ // value is an object with an array of contributions.
48
+ const aggregatedConstants = {};
49
+ // Process each module (package) definition.
50
+ for (const moduleObj of modules) {
51
+ // moduleObj is expected to be an object like { server: 'packages-modules/user-auth0/core/src' }
52
+ for (const modulePathVal of Object.values(moduleObj)) {
53
+ let trimmedModulePath = modulePathVal;
54
+ let inferredLibDir = 'src'; // default
55
+ if (modulePathVal.endsWith(`${path.sep}src`)) {
56
+ inferredLibDir = 'src';
57
+ trimmedModulePath = path.dirname(modulePathVal);
58
+ }
59
+ else if (modulePathVal.endsWith(`${path.sep}lib`)) {
60
+ inferredLibDir = 'lib';
61
+ trimmedModulePath = path.dirname(modulePathVal);
62
+ }
22
63
  try {
23
- const modulePath = path.join(repoRoot, moduleName, '../');
24
- const pkgJsonFilePath = path.join(modulePath, 'package.json');
25
- if (!fs.existsSync(pkgJsonFilePath)) {
64
+ // Read package.json from the package root.
65
+ const pkgJsonFilePath = path.join(repoRoot, trimmedModulePath, 'package.json');
66
+ if (!fs.existsSync(pkgJsonFilePath))
26
67
  continue;
27
- }
28
- const pkgJsonBuffer = fs.readFileSync(pkgJsonFilePath, 'utf-8');
29
- const pkgJson = JSON.parse(pkgJsonBuffer);
30
- // If cdecode.common is present, copy the specified modules
31
- if (pkgJson.cdecode?.common) {
32
- const pkgName = (pkgJson.name || '').split('/')[1] || pkgJson.name;
33
- const { modules: resourceList } = pkgJson.cdecode.common;
34
- const directoryPath = path.join(commonPackagePath, `src/modules/${pkgName}`);
35
- child_process.execSync(`mkdir -p ${directoryPath}`);
36
- // Copy each file or folder
37
- resourceList.forEach((moduleFile) => {
38
- child_process.execSync(`cp -r ${path.join(modulePath, moduleFile)} ${directoryPath}`);
68
+ const pkgJson = JSON.parse(fs.readFileSync(pkgJsonFilePath, 'utf-8'));
69
+ if (!pkgJson.cdecode?.common)
70
+ continue;
71
+ // For a scoped package like "@org/user-auth0-core", use the part after the slash.
72
+ const pkgNameFull = pkgJson.name || '';
73
+ const pkgName = pkgNameFull.split('/')[1] || pkgNameFull;
74
+ // Source base: package root (for resolving declared resource paths).
75
+ const sourceBase = path.join(repoRoot, trimmedModulePath);
76
+ for (const folderType of ['modules', 'services', 'repositories', 'enums', 'constants']) {
77
+ const resourceList = pkgJson.cdecode.common[folderType] || [];
78
+ if (resourceList.length === 0)
79
+ continue;
80
+ // Mark folder as processed.
81
+ processedFolders[folderType] = true;
82
+ // Determine destination folder.
83
+ // For non-enums, files are copied into common/src/<folderType>
84
+ // For enums, files are aggregated into common/src/enums.
85
+ let destFolder;
86
+ if (folderType === 'enums') {
87
+ destFolder = path.join(commonPackagePath, 'src', 'enums');
88
+ }
89
+ else if (folderType === 'constants') {
90
+ destFolder = path.join(commonPackagePath, 'src', 'constants');
91
+ }
92
+ else {
93
+ destFolder = path.join(commonPackagePath, 'src', folderType);
94
+ }
95
+ commandRunner(`mkdir -p ${destFolder}`);
96
+ resourceList.forEach((file) => {
97
+ // Flatten the resource file name (ignore any intermediate directories)
98
+ // and remove the ".ts.template" suffix.
99
+ const destFileName = path.basename(file).replace(/\.ts\.template$/, '.ts');
100
+ // When processing each resource (using the value from package.json, e.g. "./${libDir}/templates/...")
101
+ const resolvedTemplatePath = file.replace('${libDir}', inferredLibDir);
102
+ const sourceFile = path.join(sourceBase, resolvedTemplatePath);
103
+ if (folderType === 'enums') {
104
+ // For enums, collect each file (with package name) for later aggregation.
105
+ if (!aggregatedEnums[destFileName]) {
106
+ aggregatedEnums[destFileName] = { contributions: [] };
107
+ }
108
+ aggregatedEnums[destFileName].contributions.push({ pkgName, sourceFile });
109
+ }
110
+ else if (folderType === 'constants') {
111
+ // For constants, collect for aggregation.
112
+ if (!aggregatedConstants[destFileName]) {
113
+ aggregatedConstants[destFileName] = { contributions: [] };
114
+ }
115
+ aggregatedConstants[destFileName].contributions.push({ pkgName, sourceFile });
116
+ }
117
+ else {
118
+ // For non-enums, copy the file and then prepend a comment indicating its origin.
119
+ const destFile = path.join(destFolder, destFileName);
120
+ commandRunner(`cp -r ${sourceFile} ${destFile}`);
121
+ // Prepend a comment to indicate the package origin.
122
+ commandRunner(`(echo "// from package: ${pkgName}" && cat ${destFile}) > ${destFile}.tmp && mv ${destFile}.tmp ${destFile}`);
123
+ // Append an export statement to the folder's index.
124
+ commandRunner(`echo "export * from './${destFileName.replace('.ts', '')}';" >> ${path.join(destFolder, 'index.ts')}`);
125
+ // Replace any import from "common" (or from "common/lib/generated/generated-model" or "common/lib/generated/generated-model.js")
126
+ // with the relative path using a single regex.
127
+ try {
128
+ replaceInFile.replaceInFileSync({
129
+ files: destFile,
130
+ from: /from\s+['"]common(?:\/lib\/generated\/generated-model(?:\.js)?)?['"]/g,
131
+ to: "from '../generated/generated-models'",
132
+ });
133
+ }
134
+ catch (error) {
135
+ console.error(`Error replacing import in file ${destFile}:`, error);
136
+ }
137
+ // If this is a service file, instead of creating a separate augmentation file,
138
+ // append the augmentation boilerplate directly to the service file.
139
+ if (folderType === 'services') {
140
+ const serviceBaseName = destFileName.replace('.ts', '');
141
+ const propertyName = serviceBaseName.charAt(0).toLowerCase() + serviceBaseName.slice(1);
142
+ 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
+ `;
152
+ // Append the augmentation content directly to the service file.
153
+ fs.appendFileSync(destFile, augmentationContent, 'utf8');
154
+ }
155
+ }
39
156
  });
40
- // Create an index.ts that re-exports each file
41
- const getFileNameWithoutExt = (filePath) => {
42
- const justFile = path.basename(filePath);
43
- return path.basename(justFile, path.extname(justFile));
44
- };
45
- const exports = resourceList
46
- .map((file) => `export * from './${getFileNameWithoutExt(file)}';`)
47
- .join('\n');
48
- // Write index.ts
49
- child_process.execSync(`echo "${exports.replace(/"/g, '\\"')}" > ${path.join(directoryPath, 'index.ts')}`);
50
- // Write an index.ts in the parent folder, referencing the new module folder
51
- child_process.execSync(`echo "export * from './${pkgName}';" > ${path.join(directoryPath, '../', 'index.ts')}`);
52
- shouldAddExport = true;
53
157
  }
54
158
  }
55
- catch (e) {
56
- console.error(`Error copying modules for: ${moduleName}`, e);
57
- // you can decide to continue or break
159
+ catch (err) {
160
+ console.error(`Error processing module: ${modulePathVal}`, err);
58
161
  }
59
162
  }
60
163
  }
61
- // If we've added at least one module export, update the top-level index
62
- if (shouldAddExport) {
63
- child_process.execSync(`echo "export * from './modules';" >> ${path.join(commonPackagePath, 'src', 'index.ts')}`);
164
+ // ----- Enum Aggregation Step -----
165
+ // Ensure the enums destination folder is created if it was processed.
166
+ const enumDestFolder = path.join(commonPackagePath, 'src', 'enums');
167
+ if (processedFolders.enums) {
168
+ commandRunner(`mkdir -p ${enumDestFolder}`);
169
+ if (Object.keys(aggregatedEnums).length > 0) {
170
+ for (const destFileName in aggregatedEnums) {
171
+ const aggregatedFile = path.join(enumDestFolder, destFileName);
172
+ const { contributions } = aggregatedEnums[destFileName];
173
+ // Read the first contribution's file content to extract the proper enum name.
174
+ const firstContribution = contributions[0];
175
+ const fileContent = fs.readFileSync(firstContribution.sourceFile, 'utf8');
176
+ const match = fileContent.match(/export\s+enum\s+(\w+)/);
177
+ const enumName = match ? match[1] : destFileName.replace('.ts', '');
178
+ // Start the aggregated file with the correct enum declaration.
179
+ commandRunner(`echo "export enum ${enumName} {" > ${aggregatedFile}`);
180
+ for (const contribution of contributions) {
181
+ commandRunner(`echo " // from package: ${contribution.pkgName}" >> ${aggregatedFile}`);
182
+ // Extract only the enum inner content (between "{" and "}") using two sed commands.
183
+ commandRunner(`sed -n '/{/,/}/p' ${contribution.sourceFile} | sed '1d;$d' >> ${aggregatedFile}`);
184
+ }
185
+ // Close the enum declaration.
186
+ commandRunner(`echo "}" >> ${aggregatedFile}`);
187
+ // Append an export statement to the enums index.
188
+ commandRunner(`echo "export * from './${enumName}';" >> ${path.join(enumDestFolder, 'index.ts')}`);
189
+ }
190
+ }
191
+ else {
192
+ // No enums were aggregated, but still create an empty index file.
193
+ fs.writeFileSync(path.join(enumDestFolder, 'index.ts'), '', 'utf8');
194
+ }
195
+ }
196
+ // ----- Constants Aggregation Step -----
197
+ const constantsDestFolder = path.join(commonPackagePath, 'src', 'constants');
198
+ if (processedFolders.constants) {
199
+ commandRunner(`mkdir -p ${constantsDestFolder}`);
200
+ if (Object.keys(aggregatedConstants).length > 0) {
201
+ for (const destFileName in aggregatedConstants) {
202
+ const aggregatedFile = path.join(constantsDestFolder, destFileName);
203
+ const { contributions } = aggregatedConstants[destFileName];
204
+ // Read the first contribution's file content to extract the constant name.
205
+ const firstContribution = contributions[0];
206
+ const fileContent = fs.readFileSync(firstContribution.sourceFile, 'utf8');
207
+ const match = fileContent.match(/export\s+const\s+(\w+)\s*=/);
208
+ const constName = match ? match[1] : destFileName.replace('.ts', '');
209
+ // Start the aggregated file with the proper constant declaration.
210
+ commandRunner(`echo "export const ${constName} = {" > ${aggregatedFile}`);
211
+ for (const contribution of contributions) {
212
+ commandRunner(`echo " // from package: ${contribution.pkgName}" >> ${aggregatedFile}`);
213
+ // Extract only the inner part of the object literal (using sed to get content between { and }).
214
+ commandRunner(`sed -n '/{/,/}/p' ${contribution.sourceFile} | sed '1d;$d' >> ${aggregatedFile}`);
215
+ }
216
+ // Close the object literal.
217
+ commandRunner(`echo "};" >> ${aggregatedFile}`);
218
+ // Append an export statement to the constants index.
219
+ commandRunner(`echo "export * from './${constName}';" >> ${path.join(constantsDestFolder, 'index.ts')}`);
220
+ }
221
+ }
222
+ else {
223
+ // No constants were aggregated; still create an empty index.
224
+ fs.writeFileSync(path.join(constantsDestFolder, 'index.ts'), '', 'utf8');
225
+ }
226
+ }
227
+ // ----- Global Index Update -----
228
+ // Append export statements for each folder type that was processed.
229
+ const globalIndexFile = path.join(commonPackagePath, 'src', 'index.ts');
230
+ const folderTypes = ['modules', 'services', 'repositories', 'enums', 'constants'];
231
+ for (const folderKey of folderTypes) {
232
+ if (processedFolders[folderKey]) {
233
+ commandRunner(`echo "export * from './${folderKey}';" >> ${globalIndexFile}`);
234
+ }
64
235
  }
65
236
  }exports.performCopyOperations=performCopyOperations;//# sourceMappingURL=performCopyOperations.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"performCopyOperations.cjs","sources":["../../../src/tools/codegen/performCopyOperations.ts"],"sourcesContent":[null],"names":["pathsConfig","execSync"],"mappings":"uIAKA;;;;;;AAMG;SACa,qBAAqB,CAAC,OAAO,EAAE,eAAe,EAAS,EAAA;AACnE,IAAA,IAAI,EAAE,QAAQ,EAAE,iBAAiB,EAAE,GAAG,YAAY,CAA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,eAAe,EAAE;AACjB,QAAAA,sBAAQ,CAAC,CAAA,qCAAA,EAAwC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAA,CAAE,CAAC,CAAC;KACvG;AACL"}
1
+ {"version":3,"file":"performCopyOperations.cjs","sources":["../../../src/tools/codegen/performCopyOperations.ts"],"sourcesContent":[null],"names":["pathsConfig","execSync","replaceInFileSync"],"mappings":"gLAAA;AACA;AACA;AACA;AACA;AAYA;;;;;;;;;;;;;;;;;;;;;AAqBG;AACG,SAAU,qBAAqB,CAAC,OAAY,EAAE,YAAe,GAAA,EAAS,EAAE,OAAqB,EAAA;AAC/F,IAAA,IAAI,EAAE,QAAQ,EAAE,iBAAiB,EAAE,GAAG,YAAY,CAAC;IAEnD,IAAI,CAAC,QAAQ,EAAE;AACX,QAAA,QAAQ,GAAGA,uBAAW,CAAC,QAAQ,CAAC;KACnC;IACD,IAAI,CAAC,iBAAiB,EAAE;;QAEpB,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAACA,uBAAW,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;KAC1E;;AAGD,IAAA,MAAM,aAAa,GAAG,OAAO,EAAE,aAAa,KAAK,CAAC,GAAW,KAAKC,sBAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;;IAGjF,MAAM,gBAAgB,GAA+B,EAAE,CAAC;;;;IAKxD,MAAM,eAAe,GAEjB,EAAE,CAAC;;;;IAKP,MAAM,mBAAmB,GAErB,EAAE,CAAC;;AAGP,IAAA,KAAK,MAAM,SAAS,IAAI,OAAO,EAAE;;QAE7B,KAAK,MAAM,aAAa,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAa,EAAE;YAC9D,IAAI,iBAAiB,GAAG,aAAa,CAAC;AACtC,YAAA,IAAI,cAAc,GAAG,KAAK,CAAC;YAC3B,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAA,EAAG,IAAI,CAAC,GAAG,CAAA,GAA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AAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;AACxE,IAAA,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;AAClF,IAAA,KAAK,MAAM,SAAS,IAAI,WAAW,EAAE;AACjC,QAAA,IAAI,gBAAgB,CAAC,SAAS,CAAC,EAAE;AAC7B,YAAA,aAAa,CAAC,CAA0B,uBAAA,EAAA,SAAS,UAAU,eAAe,CAAA,CAAE,CAAC,CAAC;SACjF;KACJ;AACL"}
@@ -1,8 +1,27 @@
1
+ export interface CopyOptions {
2
+ /** Overrides the default execSync command runner */
3
+ commandRunner?: (command: string) => void;
4
+ }
1
5
  /**
2
- * For each discovered module, if "cdecode.common" is found in
3
- * the package.json, copy the specified files into the common package.
6
+ * For each discovered module (package), if its package.json defines cdecode.common then this
7
+ * function copies resource files (for keys such as "modules", "services", "repositories", and "enums")
8
+ * from the package's template directory into the common package.
4
9
  *
5
- * Provide optional cdecodePaths = { repoRoot, commonPackagePath } to override
6
- * the defaults in commonPaths.mjs.
10
+ * The new behavior is as follows:
11
+ *
12
+ * 1. The module path provided (for example "packages-modules/user-auth0/core/src")
13
+ * is trimmed (removing any trailing "/src" or "/lib") so that package.json is read from the package root.
14
+ *
15
+ * 2. For keys other than "enums", each resource file (after flattening its full path to just its basename)
16
+ * is copied into the common folder for that key (for example, "common/src/services") and then modified so that
17
+ * a comment is prepended indicating the originating package.
18
+ *
19
+ * 3. For "enums", files with the same flattened name are aggregated across packages.
20
+ * A single merged file is created in "common/src/enums" by wrapping all enum member definitions within
21
+ * an enum declaration, and each contribution is preceded by a comment (e.g. "// from package: user-auth0-core").
22
+ *
23
+ * 4. Finally, the global top-level index (common/src/index.ts) is appended with export statements for each folder type.
24
+ *
25
+ * Note: We no longer create an additional module (package) directory in the destination.
7
26
  */
8
- export declare function performCopyOperations(modules: any, cdecodePaths?: any): void;
27
+ export declare function performCopyOperations(modules: any, cdecodePaths?: any, options?: CopyOptions): void;