@common-stack/rollup-vite-utils 6.0.8-alpha.53 → 6.0.8-alpha.55

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.
@@ -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,36 +1,29 @@
1
- 'use strict';var child_process=require('child_process'),fs=require('fs'),path=require('path'),commonPaths=require('./commonPaths.cjs');/* eslint-disable no-continue */
1
+ 'use strict';var child_process=require('child_process'),fs=require('fs'),path=require('path'),commonPaths=require('./commonPaths.cjs');/* eslint-disable no-template-curly-in-string */
2
+ /* eslint-disable no-continue */
2
3
  /* eslint-disable default-param-last */
3
4
  /* eslint-disable @typescript-eslint/no-explicit-any */
4
5
  /* eslint-disable guard-for-in */
5
6
  /**
6
- * For each discovered module, if "cdecode.common" is defined in its package.json,
7
- * copy the files specified under the keys "modules", "services", "repository", and "enums"
8
- * from the package's template folder into the common package.
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", "repository", and "enums")
9
+ * from the package's template directory into the common package.
9
10
  *
10
- * For files with the .ts.template extension, the ".template" suffix is removed
11
- * upon copy so that the destination file is a plain .ts file.
11
+ * The new behavior is as follows:
12
12
  *
13
- * Each of these keys is processed into its own destination folder:
14
- * common/src/modules/<pkgName>
15
- * • common/src/services/<pkgName>
16
- * • common/src/repository/<pkgName>
17
- * • common/src/enums/<pkgName>
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.
18
15
  *
19
- * An index.ts file is created in each subfolder to re-export the files,
20
- * and a top-level index file is updated so that the common code (for example,
21
- * the ApolloContext file) can import the services, repository types, or enums.
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.
22
19
  *
23
- * For folder type "enums", after copying the files per package, an aggregation step
24
- * groups files by their base file name (e.g. ErrorMessage.ts) and then generates a merged file.
25
- * The merged file will be created in common/src/enums/ and wrap all enum members in a single
26
- * export—for example:
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").
27
23
  *
28
- * export enum ErrorMessage {
29
- * // contents from package1
30
- * // contents from package2
31
- * }
24
+ * 4. Finally, the global top-level index (common/src/index.ts) is appended with export statements for each folder type.
32
25
  *
33
- * The `options.commandRunner` allows injecting a custom command runner for testability.
26
+ * Note: We no longer create an additional module (package) directory in the destination.
34
27
  */
35
28
  function performCopyOperations(modules, cdecodePaths = {}, options) {
36
29
  let { repoRoot, commonPackagePath } = cdecodePaths;
@@ -43,112 +36,146 @@ function performCopyOperations(modules, cdecodePaths = {}, options) {
43
36
  }
44
37
  // Use the provided commandRunner or default to execSync.
45
38
  const commandRunner = options?.commandRunner || ((cmd) => child_process.execSync(cmd));
46
- // Define the folder types we want to process.
47
- const folderTypes = ['modules', 'services', 'repository', 'enums'];
48
- // Track whether we have added any export for each folder type.
49
- const shouldAddExportFlag = {
50
- modules: false,
51
- services: false,
52
- repository: false,
53
- enums: false,
54
- };
55
- // For enums we want to merge files across packages.
56
- // We'll accumulate a list of destination file paths (already renamed to .ts)
57
- // keyed by their base file name (e.g. "ErrorMessage.ts").
58
- const enumAggregation = {};
59
- // Helper: compute final destination file name.
60
- const getDestinationFileName = (file) => {
61
- if (file.endsWith('.ts.template')) {
62
- return file.replace(/\.ts\.template$/, '.ts');
63
- }
64
- return file;
65
- };
66
- // Helper: compute export name for index generation.
67
- const getExportName = (file) => {
68
- const destFileName = getDestinationFileName(file);
69
- // Remove the .ts extension from the file name.
70
- return path.basename(destFileName, '.ts');
71
- };
72
- for (const modulesObj of modules) {
73
- // modulesObj is expected to be an object like { server, client, etc. }
74
- for (const moduleName of Object.values(modulesObj)) {
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
+ // Process each module (package) definition.
46
+ for (const moduleObj of modules) {
47
+ // moduleObj is expected to be an object like { server: 'packages-modules/user-auth0/core/src' }
48
+ for (const modulePathVal of Object.values(moduleObj)) {
49
+ let trimmedModulePath = modulePathVal;
50
+ let inferredLibDir = 'src'; // default
51
+ if (modulePathVal.endsWith(`${path.sep}src`)) {
52
+ inferredLibDir = 'src';
53
+ trimmedModulePath = path.dirname(modulePathVal);
54
+ }
55
+ else if (modulePathVal.endsWith(`${path.sep}lib`)) {
56
+ inferredLibDir = 'lib';
57
+ trimmedModulePath = path.dirname(modulePathVal);
58
+ }
75
59
  try {
76
- // Read package.json from the package directory.
77
- const pkgJsonFilePath = path.join(repoRoot, moduleName, 'package.json');
78
- if (!fs.existsSync(pkgJsonFilePath)) {
60
+ // Read package.json from the package root.
61
+ const pkgJsonFilePath = path.join(repoRoot, trimmedModulePath, 'package.json');
62
+ if (!fs.existsSync(pkgJsonFilePath))
79
63
  continue;
80
- }
81
- const pkgJsonBuffer = fs.readFileSync(pkgJsonFilePath, 'utf-8');
82
- const pkgJson = JSON.parse(pkgJsonBuffer);
83
- // If the package uses cdecode.common then process for each folder type.
84
- if (pkgJson.cdecode?.common) {
85
- // Use the package name (falling back to the whole name if expected format is not met)
86
- const pkgName = (pkgJson.name || '').split('/')[1] || pkgJson.name;
87
- // Compute the source base for template files.
88
- // (Assumes that the template files live one directory above the package folder.)
89
- const sourceBase = path.join(repoRoot, moduleName, '../');
90
- for (const folderType of folderTypes) {
91
- const resourceList = pkgJson.cdecode.common[folderType];
92
- if (!resourceList)
93
- continue;
94
- // Destination folder (for example, common/src/modules/dummy-package)
95
- const directoryPath = path.join(commonPackagePath, 'src', folderType, pkgName);
96
- commandRunner(`mkdir -p ${directoryPath}`);
97
- // Copy and rename (if needed) each file.
98
- resourceList.forEach((file) => {
99
- const sourceFile = path.join(sourceBase, file);
100
- const destFileName = getDestinationFileName(file);
101
- const destination = path.join(directoryPath, destFileName);
102
- commandRunner(`cp -r ${sourceFile} ${destination}`);
103
- // For enums, accumulate the destination file for aggregation.
104
- if (folderType === 'enums') {
105
- if (!enumAggregation[destFileName]) {
106
- enumAggregation[destFileName] = [];
107
- }
108
- enumAggregation[destFileName].push(destination);
109
- }
110
- });
111
- // Generate index.ts in the destination folder that re-exports each file.
112
- const exportsContent = resourceList
113
- .map((file) => `export * from './${getExportName(file)}';`)
114
- .join('\n');
115
- commandRunner(`echo "${exportsContent.replace(/"/g, '\\"')}" > ${path.join(directoryPath, 'index.ts')}`);
116
- // Create (or overwrite) an index.ts in the parent folder of the destination;
117
- // this index re-exports the package folder so that later an aggregator can import all packages.
118
- commandRunner(`echo "export * from './${pkgName}';" > ${path.join(directoryPath, '../', 'index.ts')}`);
119
- shouldAddExportFlag[folderType] = true;
64
+ const pkgJson = JSON.parse(fs.readFileSync(pkgJsonFilePath, 'utf-8'));
65
+ if (!pkgJson.cdecode?.common)
66
+ continue;
67
+ // For a scoped package like "@org/user-auth0-core", use the part after the slash.
68
+ const pkgNameFull = pkgJson.name || '';
69
+ const pkgName = pkgNameFull.split('/')[1] || pkgNameFull;
70
+ // Source base: package root (for resolving declared resource paths).
71
+ const sourceBase = path.join(repoRoot, trimmedModulePath);
72
+ for (const folderType of ['modules', 'services', 'repository', 'enums']) {
73
+ const resourceList = pkgJson.cdecode.common[folderType] || [];
74
+ if (resourceList.length === 0)
75
+ continue;
76
+ // Mark folder as processed.
77
+ processedFolders[folderType] = true;
78
+ // Determine destination folder.
79
+ // For non-enums, files are copied into common/src/<folderType>
80
+ // For enums, files are aggregated into common/src/enums.
81
+ let destFolder;
82
+ if (folderType === 'enums') {
83
+ destFolder = path.join(commonPackagePath, 'src', 'enums');
120
84
  }
85
+ else {
86
+ destFolder = path.join(commonPackagePath, 'src', folderType);
87
+ }
88
+ commandRunner(`mkdir -p ${destFolder}`);
89
+ resourceList.forEach((file) => {
90
+ // Flatten the resource file name (ignore any intermediate directories)
91
+ // and remove the ".ts.template" suffix.
92
+ const destFileName = path.basename(file).replace(/\.ts\.template$/, '.ts');
93
+ // When processing each resource (using the value from package.json, e.g. "./${libDir}/templates/...")
94
+ const resolvedTemplatePath = file.replace('${libDir}', inferredLibDir);
95
+ const sourceFile = path.join(sourceBase, resolvedTemplatePath);
96
+ if (folderType === 'enums') {
97
+ // For enums, collect each file (with package name) for later aggregation.
98
+ if (!aggregatedEnums[destFileName]) {
99
+ aggregatedEnums[destFileName] = { contributions: [] };
100
+ }
101
+ aggregatedEnums[destFileName].contributions.push({ pkgName, sourceFile });
102
+ }
103
+ else {
104
+ // For non-enums, copy the file and then prepend a comment indicating its origin.
105
+ const destFile = path.join(destFolder, destFileName);
106
+ commandRunner(`cp -r ${sourceFile} ${destFile}`);
107
+ // Prepend a comment to indicate the package origin.
108
+ commandRunner(`(echo "// from package: ${pkgName}" && cat ${destFile}) > ${destFile}.tmp && mv ${destFile}.tmp ${destFile}`);
109
+ // Append an export statement to the folder's index.
110
+ commandRunner(`echo "export * from './${destFileName.replace('.ts', '')}';" >> ${path.join(destFolder, 'index.ts')}`);
111
+ // Replace any import from "common" with the relative path to generated models.
112
+ // Use BSD‑compatible sed syntax.
113
+ commandRunner(`sed -i '' "s/from ['\\"]common['\\"]/from '..\\/generated\\/generated-models'/g" ${destFile}`);
114
+ // If this is a service file, auto generate the augmentation boilerplate.
115
+ if (folderType === 'services') {
116
+ const serviceBaseName = destFileName.replace('.ts', '');
117
+ const propertyName = serviceBaseName.charAt(0).toLowerCase() + serviceBaseName.slice(1);
118
+ const augmentationContent = `/**
119
+ * This file augments the ServerContext interface from the central apollo-context.
120
+ * Through declaration merging, the ${propertyName} will be added to the ServerContext.
121
+ */
122
+ declare module '../apollo-context' {
123
+ export interface ServerContext {
124
+ ${propertyName}: I${serviceBaseName};
125
+ }
126
+ }
127
+ `;
128
+ const augmentationFilePath = path.join(destFolder, `${serviceBaseName}.augment.d.ts`);
129
+ fs.writeFileSync(augmentationFilePath, augmentationContent, 'utf8');
130
+ }
131
+ }
132
+ });
121
133
  }
122
134
  }
123
- catch (e) {
124
- console.error(`Error processing module: ${moduleName}`, e);
135
+ catch (err) {
136
+ console.error(`Error processing module: ${modulePathVal}`, err);
125
137
  }
126
138
  }
127
139
  }
128
- // For each folder type where any export was added, update the top-level index.
129
- // For example, append "export * from './modules';" to common/src/index.ts.
130
- for (const folderType of folderTypes) {
131
- if (shouldAddExportFlag[folderType]) {
132
- commandRunner(`echo "export * from './${folderType}';" >> ${path.join(commonPackagePath, 'src', 'index.ts')}`);
140
+ // ----- Enum Aggregation Step -----
141
+ // Ensure the enums destination folder is created if it was processed.
142
+ const enumDestFolder = path.join(commonPackagePath, 'src', 'enums');
143
+ if (processedFolders['enums']) {
144
+ commandRunner(`mkdir -p ${enumDestFolder}`);
145
+ if (Object.keys(aggregatedEnums).length > 0) {
146
+ for (const destFileName in aggregatedEnums) {
147
+ const aggregatedFile = path.join(enumDestFolder, destFileName);
148
+ const contributions = aggregatedEnums[destFileName].contributions;
149
+ // Read the first contribution's file content to extract the proper enum name.
150
+ const firstContribution = contributions[0];
151
+ const fileContent = fs.readFileSync(firstContribution.sourceFile, 'utf8');
152
+ const match = fileContent.match(/export\s+enum\s+(\w+)/);
153
+ const enumName = match ? match[1] : destFileName.replace('.ts', '');
154
+ // Start the aggregated file with the correct enum declaration.
155
+ commandRunner(`echo "export enum ${enumName} {" > ${aggregatedFile}`);
156
+ for (const contribution of contributions) {
157
+ commandRunner(`echo " // from package: ${contribution.pkgName}" >> ${aggregatedFile}`);
158
+ // Extract only the enum inner content (between "{" and "}") using two sed commands.
159
+ commandRunner(`sed -n '/{/,/}/p' ${contribution.sourceFile} | sed '1d;$d' >> ${aggregatedFile}`);
160
+ }
161
+ // Close the enum declaration.
162
+ commandRunner(`echo "}" >> ${aggregatedFile}`);
163
+ // Append an export statement to the enums index.
164
+ commandRunner(`echo "export * from './${enumName}';" >> ${path.join(enumDestFolder, 'index.ts')}`);
165
+ }
166
+ }
167
+ else {
168
+ // No enums were aggregated, but still create an empty index file.
169
+ fs.writeFileSync(path.join(enumDestFolder, 'index.ts'), '', 'utf8');
133
170
  }
134
171
  }
135
- // ----- Enum Aggregation Step -----
136
- // For enums, we want to merge definitions from all packages into a single file per enum type.
137
- // The aggregated file will be placed in common/src/enums/<EnumFileName>.
138
- if (Object.keys(enumAggregation).length > 0) {
139
- const enumsTargetDir = path.join(commonPackagePath, 'src', 'enums');
140
- commandRunner(`mkdir -p ${enumsTargetDir}`);
141
- for (const destFileName in enumAggregation) {
142
- const baseName = path.basename(destFileName, '.ts'); // e.g., "ErrorMessage"
143
- const aggregatedFile = path.join(enumsTargetDir, destFileName);
144
- // Begin the aggregated file with the enum header.
145
- commandRunner(`echo "export enum ${baseName} {" > ${aggregatedFile}`);
146
- // Append the contents (enum members) from each package's file.
147
- enumAggregation[destFileName].forEach((filePath) => {
148
- commandRunner(`cat ${filePath} >> ${aggregatedFile}`);
149
- });
150
- // Close the enum definition.
151
- commandRunner(`echo "}" >> ${aggregatedFile}`);
172
+ // ----- Global Index Update -----
173
+ // Append export statements for each folder type that was processed.
174
+ const globalIndexFile = path.join(commonPackagePath, 'src', 'index.ts');
175
+ const folderTypes = ['modules', 'services', 'repository', 'enums'];
176
+ for (const folderKey of folderTypes) {
177
+ if (processedFolders[folderKey]) {
178
+ commandRunner(`echo "export * from './${folderKey}';" >> ${globalIndexFile}`);
152
179
  }
153
180
  }
154
181
  }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":"uIAAA;AACA;AACA;AACA;AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BG;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,GA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,EAAE,UAAU,CAAC,CAAA,CAAE,CAClG,CAAC;SACL;KACJ;;;;IAKD,IAAI,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;AACzC,QAAA,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACpE,QAAA,aAAa,CAAC,CAAA,SAAA,EAAY,cAAc,CAAA,CAAE,CAAC,CAAC;AAE5C,QAAA,KAAK,MAAM,YAAY,IAAI,eAAe,EAAE;AACxC,YAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;YACpD,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;;AAE/D,YAAA,aAAa,CAAC,CAAqB,kBAAA,EAAA,QAAQ,SAAS,cAAc,CAAA,CAAE,CAAC,CAAC;;YAEtE,eAAe,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,KAAI;AAC/C,gBAAA,aAAa,CAAC,CAAO,IAAA,EAAA,QAAQ,OAAO,cAAc,CAAA,CAAE,CAAC,CAAC;AAC1D,aAAC,CAAC,CAAC;;AAEH,YAAA,aAAa,CAAC,CAAA,YAAA,EAAe,cAAc,CAAA,CAAE,CAAC,CAAC;SAClD;KACJ;AACL"}
1
+ {"version":3,"file":"performCopyOperations.cjs","sources":["../../../src/tools/codegen/performCopyOperations.ts"],"sourcesContent":[null],"names":["pathsConfig","execSync"],"mappings":"uIAAA;AACA;AACA;AACA;AACA;AAWA;;;;;;;;;;;;;;;;;;;;;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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;AAC7B,YAAA,aAAa,CAAC,CAA0B,uBAAA,EAAA,SAAS,UAAU,eAAe,CAAA,CAAE,CAAC,CAAC;SACjF;KACJ;AACL"}
@@ -3,33 +3,25 @@ export interface CopyOptions {
3
3
  commandRunner?: (command: string) => void;
4
4
  }
5
5
  /**
6
- * For each discovered module, if "cdecode.common" is defined in its package.json,
7
- * copy the files specified under the keys "modules", "services", "repository", and "enums"
8
- * from the package's template folder 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", "repository", and "enums")
8
+ * from the package's template directory into the common package.
9
9
  *
10
- * For files with the .ts.template extension, the ".template" suffix is removed
11
- * upon copy so that the destination file is a plain .ts file.
10
+ * The new behavior is as follows:
12
11
  *
13
- * Each of these keys is processed into its own destination folder:
14
- * common/src/modules/<pkgName>
15
- * • common/src/services/<pkgName>
16
- * • common/src/repository/<pkgName>
17
- * • common/src/enums/<pkgName>
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.
18
14
  *
19
- * An index.ts file is created in each subfolder to re-export the files,
20
- * and a top-level index file is updated so that the common code (for example,
21
- * the ApolloContext file) can import the services, repository types, or enums.
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.
22
18
  *
23
- * For folder type "enums", after copying the files per package, an aggregation step
24
- * groups files by their base file name (e.g. ErrorMessage.ts) and then generates a merged file.
25
- * The merged file will be created in common/src/enums/ and wrap all enum members in a single
26
- * export—for example:
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").
27
22
  *
28
- * export enum ErrorMessage {
29
- * // contents from package1
30
- * // contents from package2
31
- * }
23
+ * 4. Finally, the global top-level index (common/src/index.ts) is appended with export statements for each folder type.
32
24
  *
33
- * The `options.commandRunner` allows injecting a custom command runner for testability.
25
+ * Note: We no longer create an additional module (package) directory in the destination.
34
26
  */
35
27
  export declare function performCopyOperations(modules: any, cdecodePaths?: any, options?: CopyOptions): void;
@@ -1,36 +1,29 @@
1
- import {execSync}from'child_process';import fs__default from'fs';import path__default from'path';import {pathsConfig}from'./commonPaths.js';/* eslint-disable no-continue */
1
+ import {execSync}from'child_process';import fs__default from'fs';import path__default from'path';import {pathsConfig}from'./commonPaths.js';/* eslint-disable no-template-curly-in-string */
2
+ /* eslint-disable no-continue */
2
3
  /* eslint-disable default-param-last */
3
4
  /* eslint-disable @typescript-eslint/no-explicit-any */
4
5
  /* eslint-disable guard-for-in */
5
6
  /**
6
- * For each discovered module, if "cdecode.common" is defined in its package.json,
7
- * copy the files specified under the keys "modules", "services", "repository", and "enums"
8
- * from the package's template folder into the common package.
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", "repository", and "enums")
9
+ * from the package's template directory into the common package.
9
10
  *
10
- * For files with the .ts.template extension, the ".template" suffix is removed
11
- * upon copy so that the destination file is a plain .ts file.
11
+ * The new behavior is as follows:
12
12
  *
13
- * Each of these keys is processed into its own destination folder:
14
- * common/src/modules/<pkgName>
15
- * • common/src/services/<pkgName>
16
- * • common/src/repository/<pkgName>
17
- * • common/src/enums/<pkgName>
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.
18
15
  *
19
- * An index.ts file is created in each subfolder to re-export the files,
20
- * and a top-level index file is updated so that the common code (for example,
21
- * the ApolloContext file) can import the services, repository types, or enums.
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.
22
19
  *
23
- * For folder type "enums", after copying the files per package, an aggregation step
24
- * groups files by their base file name (e.g. ErrorMessage.ts) and then generates a merged file.
25
- * The merged file will be created in common/src/enums/ and wrap all enum members in a single
26
- * export—for example:
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").
27
23
  *
28
- * export enum ErrorMessage {
29
- * // contents from package1
30
- * // contents from package2
31
- * }
24
+ * 4. Finally, the global top-level index (common/src/index.ts) is appended with export statements for each folder type.
32
25
  *
33
- * The `options.commandRunner` allows injecting a custom command runner for testability.
26
+ * Note: We no longer create an additional module (package) directory in the destination.
34
27
  */
35
28
  function performCopyOperations(modules, cdecodePaths = {}, options) {
36
29
  let { repoRoot, commonPackagePath } = cdecodePaths;
@@ -43,112 +36,146 @@ function performCopyOperations(modules, cdecodePaths = {}, options) {
43
36
  }
44
37
  // Use the provided commandRunner or default to execSync.
45
38
  const commandRunner = options?.commandRunner || ((cmd) => execSync(cmd));
46
- // Define the folder types we want to process.
47
- const folderTypes = ['modules', 'services', 'repository', 'enums'];
48
- // Track whether we have added any export for each folder type.
49
- const shouldAddExportFlag = {
50
- modules: false,
51
- services: false,
52
- repository: false,
53
- enums: false,
54
- };
55
- // For enums we want to merge files across packages.
56
- // We'll accumulate a list of destination file paths (already renamed to .ts)
57
- // keyed by their base file name (e.g. "ErrorMessage.ts").
58
- const enumAggregation = {};
59
- // Helper: compute final destination file name.
60
- const getDestinationFileName = (file) => {
61
- if (file.endsWith('.ts.template')) {
62
- return file.replace(/\.ts\.template$/, '.ts');
63
- }
64
- return file;
65
- };
66
- // Helper: compute export name for index generation.
67
- const getExportName = (file) => {
68
- const destFileName = getDestinationFileName(file);
69
- // Remove the .ts extension from the file name.
70
- return path__default.basename(destFileName, '.ts');
71
- };
72
- for (const modulesObj of modules) {
73
- // modulesObj is expected to be an object like { server, client, etc. }
74
- for (const moduleName of Object.values(modulesObj)) {
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
+ // Process each module (package) definition.
46
+ for (const moduleObj of modules) {
47
+ // moduleObj is expected to be an object like { server: 'packages-modules/user-auth0/core/src' }
48
+ for (const modulePathVal of Object.values(moduleObj)) {
49
+ let trimmedModulePath = modulePathVal;
50
+ let inferredLibDir = 'src'; // default
51
+ if (modulePathVal.endsWith(`${path__default.sep}src`)) {
52
+ inferredLibDir = 'src';
53
+ trimmedModulePath = path__default.dirname(modulePathVal);
54
+ }
55
+ else if (modulePathVal.endsWith(`${path__default.sep}lib`)) {
56
+ inferredLibDir = 'lib';
57
+ trimmedModulePath = path__default.dirname(modulePathVal);
58
+ }
75
59
  try {
76
- // Read package.json from the package directory.
77
- const pkgJsonFilePath = path__default.join(repoRoot, moduleName, 'package.json');
78
- if (!fs__default.existsSync(pkgJsonFilePath)) {
60
+ // Read package.json from the package root.
61
+ const pkgJsonFilePath = path__default.join(repoRoot, trimmedModulePath, 'package.json');
62
+ if (!fs__default.existsSync(pkgJsonFilePath))
79
63
  continue;
80
- }
81
- const pkgJsonBuffer = fs__default.readFileSync(pkgJsonFilePath, 'utf-8');
82
- const pkgJson = JSON.parse(pkgJsonBuffer);
83
- // If the package uses cdecode.common then process for each folder type.
84
- if (pkgJson.cdecode?.common) {
85
- // Use the package name (falling back to the whole name if expected format is not met)
86
- const pkgName = (pkgJson.name || '').split('/')[1] || pkgJson.name;
87
- // Compute the source base for template files.
88
- // (Assumes that the template files live one directory above the package folder.)
89
- const sourceBase = path__default.join(repoRoot, moduleName, '../');
90
- for (const folderType of folderTypes) {
91
- const resourceList = pkgJson.cdecode.common[folderType];
92
- if (!resourceList)
93
- continue;
94
- // Destination folder (for example, common/src/modules/dummy-package)
95
- const directoryPath = path__default.join(commonPackagePath, 'src', folderType, pkgName);
96
- commandRunner(`mkdir -p ${directoryPath}`);
97
- // Copy and rename (if needed) each file.
98
- resourceList.forEach((file) => {
99
- const sourceFile = path__default.join(sourceBase, file);
100
- const destFileName = getDestinationFileName(file);
101
- const destination = path__default.join(directoryPath, destFileName);
102
- commandRunner(`cp -r ${sourceFile} ${destination}`);
103
- // For enums, accumulate the destination file for aggregation.
104
- if (folderType === 'enums') {
105
- if (!enumAggregation[destFileName]) {
106
- enumAggregation[destFileName] = [];
107
- }
108
- enumAggregation[destFileName].push(destination);
109
- }
110
- });
111
- // Generate index.ts in the destination folder that re-exports each file.
112
- const exportsContent = resourceList
113
- .map((file) => `export * from './${getExportName(file)}';`)
114
- .join('\n');
115
- commandRunner(`echo "${exportsContent.replace(/"/g, '\\"')}" > ${path__default.join(directoryPath, 'index.ts')}`);
116
- // Create (or overwrite) an index.ts in the parent folder of the destination;
117
- // this index re-exports the package folder so that later an aggregator can import all packages.
118
- commandRunner(`echo "export * from './${pkgName}';" > ${path__default.join(directoryPath, '../', 'index.ts')}`);
119
- shouldAddExportFlag[folderType] = true;
64
+ const pkgJson = JSON.parse(fs__default.readFileSync(pkgJsonFilePath, 'utf-8'));
65
+ if (!pkgJson.cdecode?.common)
66
+ continue;
67
+ // For a scoped package like "@org/user-auth0-core", use the part after the slash.
68
+ const pkgNameFull = pkgJson.name || '';
69
+ const pkgName = pkgNameFull.split('/')[1] || pkgNameFull;
70
+ // Source base: package root (for resolving declared resource paths).
71
+ const sourceBase = path__default.join(repoRoot, trimmedModulePath);
72
+ for (const folderType of ['modules', 'services', 'repository', 'enums']) {
73
+ const resourceList = pkgJson.cdecode.common[folderType] || [];
74
+ if (resourceList.length === 0)
75
+ continue;
76
+ // Mark folder as processed.
77
+ processedFolders[folderType] = true;
78
+ // Determine destination folder.
79
+ // For non-enums, files are copied into common/src/<folderType>
80
+ // For enums, files are aggregated into common/src/enums.
81
+ let destFolder;
82
+ if (folderType === 'enums') {
83
+ destFolder = path__default.join(commonPackagePath, 'src', 'enums');
120
84
  }
85
+ else {
86
+ destFolder = path__default.join(commonPackagePath, 'src', folderType);
87
+ }
88
+ commandRunner(`mkdir -p ${destFolder}`);
89
+ resourceList.forEach((file) => {
90
+ // Flatten the resource file name (ignore any intermediate directories)
91
+ // and remove the ".ts.template" suffix.
92
+ const destFileName = path__default.basename(file).replace(/\.ts\.template$/, '.ts');
93
+ // When processing each resource (using the value from package.json, e.g. "./${libDir}/templates/...")
94
+ const resolvedTemplatePath = file.replace('${libDir}', inferredLibDir);
95
+ const sourceFile = path__default.join(sourceBase, resolvedTemplatePath);
96
+ if (folderType === 'enums') {
97
+ // For enums, collect each file (with package name) for later aggregation.
98
+ if (!aggregatedEnums[destFileName]) {
99
+ aggregatedEnums[destFileName] = { contributions: [] };
100
+ }
101
+ aggregatedEnums[destFileName].contributions.push({ pkgName, sourceFile });
102
+ }
103
+ else {
104
+ // For non-enums, copy the file and then prepend a comment indicating its origin.
105
+ const destFile = path__default.join(destFolder, destFileName);
106
+ commandRunner(`cp -r ${sourceFile} ${destFile}`);
107
+ // Prepend a comment to indicate the package origin.
108
+ commandRunner(`(echo "// from package: ${pkgName}" && cat ${destFile}) > ${destFile}.tmp && mv ${destFile}.tmp ${destFile}`);
109
+ // Append an export statement to the folder's index.
110
+ commandRunner(`echo "export * from './${destFileName.replace('.ts', '')}';" >> ${path__default.join(destFolder, 'index.ts')}`);
111
+ // Replace any import from "common" with the relative path to generated models.
112
+ // Use BSD‑compatible sed syntax.
113
+ commandRunner(`sed -i '' "s/from ['\\"]common['\\"]/from '..\\/generated\\/generated-models'/g" ${destFile}`);
114
+ // If this is a service file, auto generate the augmentation boilerplate.
115
+ if (folderType === 'services') {
116
+ const serviceBaseName = destFileName.replace('.ts', '');
117
+ const propertyName = serviceBaseName.charAt(0).toLowerCase() + serviceBaseName.slice(1);
118
+ const augmentationContent = `/**
119
+ * This file augments the ServerContext interface from the central apollo-context.
120
+ * Through declaration merging, the ${propertyName} will be added to the ServerContext.
121
+ */
122
+ declare module '../apollo-context' {
123
+ export interface ServerContext {
124
+ ${propertyName}: I${serviceBaseName};
125
+ }
126
+ }
127
+ `;
128
+ const augmentationFilePath = path__default.join(destFolder, `${serviceBaseName}.augment.d.ts`);
129
+ fs__default.writeFileSync(augmentationFilePath, augmentationContent, 'utf8');
130
+ }
131
+ }
132
+ });
121
133
  }
122
134
  }
123
- catch (e) {
124
- console.error(`Error processing module: ${moduleName}`, e);
135
+ catch (err) {
136
+ console.error(`Error processing module: ${modulePathVal}`, err);
125
137
  }
126
138
  }
127
139
  }
128
- // For each folder type where any export was added, update the top-level index.
129
- // For example, append "export * from './modules';" to common/src/index.ts.
130
- for (const folderType of folderTypes) {
131
- if (shouldAddExportFlag[folderType]) {
132
- commandRunner(`echo "export * from './${folderType}';" >> ${path__default.join(commonPackagePath, 'src', 'index.ts')}`);
140
+ // ----- Enum Aggregation Step -----
141
+ // Ensure the enums destination folder is created if it was processed.
142
+ const enumDestFolder = path__default.join(commonPackagePath, 'src', 'enums');
143
+ if (processedFolders['enums']) {
144
+ commandRunner(`mkdir -p ${enumDestFolder}`);
145
+ if (Object.keys(aggregatedEnums).length > 0) {
146
+ for (const destFileName in aggregatedEnums) {
147
+ const aggregatedFile = path__default.join(enumDestFolder, destFileName);
148
+ const contributions = aggregatedEnums[destFileName].contributions;
149
+ // Read the first contribution's file content to extract the proper enum name.
150
+ const firstContribution = contributions[0];
151
+ const fileContent = fs__default.readFileSync(firstContribution.sourceFile, 'utf8');
152
+ const match = fileContent.match(/export\s+enum\s+(\w+)/);
153
+ const enumName = match ? match[1] : destFileName.replace('.ts', '');
154
+ // Start the aggregated file with the correct enum declaration.
155
+ commandRunner(`echo "export enum ${enumName} {" > ${aggregatedFile}`);
156
+ for (const contribution of contributions) {
157
+ commandRunner(`echo " // from package: ${contribution.pkgName}" >> ${aggregatedFile}`);
158
+ // Extract only the enum inner content (between "{" and "}") using two sed commands.
159
+ commandRunner(`sed -n '/{/,/}/p' ${contribution.sourceFile} | sed '1d;$d' >> ${aggregatedFile}`);
160
+ }
161
+ // Close the enum declaration.
162
+ commandRunner(`echo "}" >> ${aggregatedFile}`);
163
+ // Append an export statement to the enums index.
164
+ commandRunner(`echo "export * from './${enumName}';" >> ${path__default.join(enumDestFolder, 'index.ts')}`);
165
+ }
166
+ }
167
+ else {
168
+ // No enums were aggregated, but still create an empty index file.
169
+ fs__default.writeFileSync(path__default.join(enumDestFolder, 'index.ts'), '', 'utf8');
133
170
  }
134
171
  }
135
- // ----- Enum Aggregation Step -----
136
- // For enums, we want to merge definitions from all packages into a single file per enum type.
137
- // The aggregated file will be placed in common/src/enums/<EnumFileName>.
138
- if (Object.keys(enumAggregation).length > 0) {
139
- const enumsTargetDir = path__default.join(commonPackagePath, 'src', 'enums');
140
- commandRunner(`mkdir -p ${enumsTargetDir}`);
141
- for (const destFileName in enumAggregation) {
142
- const baseName = path__default.basename(destFileName, '.ts'); // e.g., "ErrorMessage"
143
- const aggregatedFile = path__default.join(enumsTargetDir, destFileName);
144
- // Begin the aggregated file with the enum header.
145
- commandRunner(`echo "export enum ${baseName} {" > ${aggregatedFile}`);
146
- // Append the contents (enum members) from each package's file.
147
- enumAggregation[destFileName].forEach((filePath) => {
148
- commandRunner(`cat ${filePath} >> ${aggregatedFile}`);
149
- });
150
- // Close the enum definition.
151
- commandRunner(`echo "}" >> ${aggregatedFile}`);
172
+ // ----- Global Index Update -----
173
+ // Append export statements for each folder type that was processed.
174
+ const globalIndexFile = path__default.join(commonPackagePath, 'src', 'index.ts');
175
+ const folderTypes = ['modules', 'services', 'repository', 'enums'];
176
+ for (const folderKey of folderTypes) {
177
+ if (processedFolders[folderKey]) {
178
+ commandRunner(`echo "export * from './${folderKey}';" >> ${globalIndexFile}`);
152
179
  }
153
180
  }
154
181
  }export{performCopyOperations};//# sourceMappingURL=performCopyOperations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"performCopyOperations.js","sources":["../../../src/tools/codegen/performCopyOperations.ts"],"sourcesContent":[null],"names":["path","fs"],"mappings":"4IAAA;AACA;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IAAA,MAAM,eAAe,GAAGA,aAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;IACxE,MAAM,WAAW,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;AACnE,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"}
@@ -42,7 +42,14 @@ export interface IHttpMiddlewareContext {
42
42
  };
43
43
  res: express.Response;
44
44
  }
45
- export interface ServerContext extends IHttpMiddlewareContext {
45
+
46
+ export type IGraphQLContext = {
47
+ /**
48
+ * current ip of the user fetched from the request
49
+ */
50
+ userIp: string;
51
+ };
52
+ export interface ServerContext extends IHttpMiddlewareContext, IGraphQLContext {
46
53
  accessRoleService: any;
47
54
  user?: IIAuth0Token;
48
55
  userContext?: IUserContext;
@@ -1,8 +1,6 @@
1
1
  {
2
2
  "extends": "../../tsconfig.json",
3
3
  "compilerOptions": {
4
- "target": "es2017",
5
- "lib": ["es2017"],
6
4
  "resolveJsonModule": true,
7
5
  "allowSyntheticDefaultImports": true,
8
6
  "experimentalDecorators": true,
@@ -14,5 +12,5 @@
14
12
  "skipLibCheck": true
15
13
  },
16
14
  "include": ["src"],
17
- "exclude": ["../../../node_modules", "node_modules", "lib", "lib", "webpack.config.js", "rollup.config.mjs"]
15
+ "exclude": ["../../../node_modules", "node_modules", "lib", "rollup.config.mjs"]
18
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@common-stack/rollup-vite-utils",
3
- "version": "6.0.8-alpha.53",
3
+ "version": "6.0.8-alpha.55",
4
4
  "description": "Client Module for react app",
5
5
  "homepage": "https://github.com/cdmbase/fullstack-pro#readme",
6
6
  "bugs": {
@@ -57,7 +57,7 @@
57
57
  "publishConfig": {
58
58
  "access": "public"
59
59
  },
60
- "gitHead": "96cdaea57d3640f35908dbc138dde2a57635614e",
60
+ "gitHead": "d6163f7cb4ec0abb8159d4fac97305af6557a765",
61
61
  "typescript": {
62
62
  "definition": "lib/index.d.ts"
63
63
  }