@common-stack/rollup-vite-utils 6.0.8-alpha.52 → 6.0.8-alpha.54
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.
- package/lib/tools/codegen/performCopyOperations.cjs +158 -46
- package/lib/tools/codegen/performCopyOperations.cjs.map +1 -1
- package/lib/tools/codegen/performCopyOperations.d.ts +24 -5
- package/lib/tools/codegen/performCopyOperations.js +158 -46
- package/lib/tools/codegen/performCopyOperations.js.map +1 -1
- package/lib/tools/codegen/performCopyOperations.test.d.ts +1 -0
- package/lib/tools/codegen/templates/common/src/apollo-context.ts.template +8 -1
- package/lib/tools/codegen/templates/common/tsconfig.json.template +1 -3
- package/package.json +2 -2
|
@@ -1,65 +1,177 @@
|
|
|
1
|
-
'use strict';var child_process=require('child_process'),fs=require('fs'),path=require('path'),commonPaths=require('./commonPaths.cjs')
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
'use strict';var child_process=require('child_process'),fs=require('fs'),path=require('path'),commonPaths=require('./commonPaths.cjs');/* eslint-disable no-continue */
|
|
2
|
+
/* eslint-disable default-param-last */
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
|
+
/* eslint-disable guard-for-in */
|
|
5
|
+
/**
|
|
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.
|
|
4
9
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
-
function performCopyOperations(modules, cdecodePaths = {}) {
|
|
27
|
+
function performCopyOperations(modules, cdecodePaths = {}, options) {
|
|
9
28
|
let { repoRoot, commonPackagePath } = cdecodePaths;
|
|
10
|
-
// Fallback to internal pathsConfig if not provided by user
|
|
11
29
|
if (!repoRoot) {
|
|
12
30
|
repoRoot = commonPaths.pathsConfig.repoRoot;
|
|
13
31
|
}
|
|
14
32
|
if (!commonPackagePath) {
|
|
15
|
-
//
|
|
33
|
+
// For example, "packages/common"
|
|
16
34
|
commonPackagePath = path.join(commonPaths.pathsConfig.repoRoot, 'packages/common');
|
|
17
35
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
36
|
+
// Use the provided commandRunner or default to execSync.
|
|
37
|
+
const commandRunner = options?.commandRunner || ((cmd) => child_process.execSync(cmd));
|
|
38
|
+
// Track which resource folders are processed.
|
|
39
|
+
const processedFolders = {};
|
|
40
|
+
// Object to collect enum contributions.
|
|
41
|
+
// Key is the flattened destination file name (e.g. "auth-error.ts"),
|
|
42
|
+
// value is an array with the source file and package name.
|
|
43
|
+
const aggregatedEnums = {};
|
|
44
|
+
// Process each module (package) definition.
|
|
45
|
+
for (const moduleObj of modules) {
|
|
46
|
+
// moduleObj is expected to be an object like { server: 'packages-modules/user-auth0/core/src' }
|
|
47
|
+
for (const modulePathVal of Object.values(moduleObj)) {
|
|
22
48
|
try {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
|
|
49
|
+
// Trim a trailing "/src" or "/lib" from the provided module path.
|
|
50
|
+
let trimmedModulePath = modulePathVal;
|
|
51
|
+
if (trimmedModulePath.endsWith(`${path.sep}src`) || trimmedModulePath.endsWith(`${path.sep}lib`)) {
|
|
52
|
+
trimmedModulePath = path.dirname(trimmedModulePath);
|
|
27
53
|
}
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
54
|
+
// Read package.json from the package root.
|
|
55
|
+
const pkgJsonFilePath = path.join(repoRoot, trimmedModulePath, 'package.json');
|
|
56
|
+
if (!fs.existsSync(pkgJsonFilePath))
|
|
57
|
+
continue;
|
|
58
|
+
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonFilePath, 'utf-8'));
|
|
59
|
+
if (!pkgJson.cdecode?.common)
|
|
60
|
+
continue;
|
|
61
|
+
// For a scoped package like "@org/user-auth0-core", use the part after the slash.
|
|
62
|
+
const pkgNameFull = pkgJson.name || '';
|
|
63
|
+
const pkgName = pkgNameFull.split('/')[1] || pkgNameFull;
|
|
64
|
+
// Source base: package root (for resolving declared resource paths).
|
|
65
|
+
const sourceBase = path.join(repoRoot, trimmedModulePath);
|
|
66
|
+
for (const folderType of ['modules', 'services', 'repository', 'enums']) {
|
|
67
|
+
const resourceList = pkgJson.cdecode.common[folderType] || [];
|
|
68
|
+
if (resourceList.length === 0)
|
|
69
|
+
continue;
|
|
70
|
+
// Mark folder as processed.
|
|
71
|
+
processedFolders[folderType] = true;
|
|
72
|
+
// Determine destination folder.
|
|
73
|
+
// For non-enums, files are copied into common/src/<folderType>
|
|
74
|
+
// For enums, files are aggregated into common/src/enums.
|
|
75
|
+
let destFolder;
|
|
76
|
+
if (folderType === 'enums') {
|
|
77
|
+
destFolder = path.join(commonPackagePath, 'src', 'enums');
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
destFolder = path.join(commonPackagePath, 'src', folderType);
|
|
81
|
+
}
|
|
82
|
+
commandRunner(`mkdir -p ${destFolder}`);
|
|
83
|
+
resourceList.forEach((file) => {
|
|
84
|
+
// Flatten the resource file name (ignore any intermediate directories)
|
|
85
|
+
// and remove the ".ts.template" suffix.
|
|
86
|
+
const destFileName = path.basename(file).replace(/\.ts\.template$/, '.ts');
|
|
87
|
+
// Resolve the source file relative to the package root.
|
|
88
|
+
const sourceFile = path.join(sourceBase, file);
|
|
89
|
+
if (folderType === 'enums') {
|
|
90
|
+
// For enums, collect each file (with package name) for later aggregation.
|
|
91
|
+
if (!aggregatedEnums[destFileName]) {
|
|
92
|
+
aggregatedEnums[destFileName] = { contributions: [] };
|
|
93
|
+
}
|
|
94
|
+
aggregatedEnums[destFileName].contributions.push({ pkgName, sourceFile });
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// For non-enums, copy the file and then prepend a comment indicating its origin.
|
|
98
|
+
const destFile = path.join(destFolder, destFileName);
|
|
99
|
+
commandRunner(`cp -r ${sourceFile} ${destFile}`);
|
|
100
|
+
// Prepend a comment to indicate the package origin.
|
|
101
|
+
commandRunner(`(echo "// from package: ${pkgName}" && cat ${destFile}) > ${destFile}.tmp && mv ${destFile}.tmp ${destFile}`);
|
|
102
|
+
// Append an export statement to the folder's index.
|
|
103
|
+
commandRunner(`echo "export * from './${destFileName.replace('.ts', '')}';" >> ${path.join(destFolder, 'index.ts')}`);
|
|
104
|
+
// Replace any import from "common" with the relative path to generated models.
|
|
105
|
+
commandRunner(`sed -i '' "s/from ['\\"]common['\\"]/from '..\\/generated\\/generated-models'/g" ${destFile}`);
|
|
106
|
+
// If this is a service file, append the augmentation code directly to the service file.
|
|
107
|
+
if (folderType === 'services') {
|
|
108
|
+
const serviceBaseName = destFileName.replace('.ts', '');
|
|
109
|
+
const propertyName = serviceBaseName.charAt(0).toLowerCase() + serviceBaseName.slice(1);
|
|
110
|
+
const augmentationContent = `
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* This augments the ServerContext interface from the central apollo-context.
|
|
114
|
+
* Through declaration merging, the ${propertyName} service will be added to the ServerContext.
|
|
115
|
+
*/
|
|
116
|
+
declare module '../apollo-context' {
|
|
117
|
+
export interface ServerContext {
|
|
118
|
+
${propertyName}: I${serviceBaseName};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
// Read the current content of the service file.
|
|
123
|
+
const currentServiceContent = fs.readFileSync(destFile, 'utf8');
|
|
124
|
+
// Append the augmentation content to the service file.
|
|
125
|
+
fs.writeFileSync(destFile, currentServiceContent + augmentationContent, 'utf8');
|
|
126
|
+
}
|
|
127
|
+
}
|
|
39
128
|
});
|
|
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
129
|
}
|
|
54
130
|
}
|
|
55
|
-
catch (
|
|
56
|
-
console.error(`Error
|
|
57
|
-
// you can decide to continue or break
|
|
131
|
+
catch (err) {
|
|
132
|
+
console.error(`Error processing module: ${modulePathVal}`, err);
|
|
58
133
|
}
|
|
59
134
|
}
|
|
60
135
|
}
|
|
61
|
-
//
|
|
62
|
-
if
|
|
63
|
-
|
|
136
|
+
// ----- Enum Aggregation Step -----
|
|
137
|
+
// Ensure the enums destination folder is created if it was processed.
|
|
138
|
+
const enumDestFolder = path.join(commonPackagePath, 'src', 'enums');
|
|
139
|
+
if (processedFolders['enums']) {
|
|
140
|
+
commandRunner(`mkdir -p ${enumDestFolder}`);
|
|
141
|
+
if (Object.keys(aggregatedEnums).length > 0) {
|
|
142
|
+
for (const destFileName in aggregatedEnums) {
|
|
143
|
+
const aggregatedFile = path.join(enumDestFolder, destFileName);
|
|
144
|
+
const contributions = aggregatedEnums[destFileName].contributions;
|
|
145
|
+
// Read the first contribution's file content to extract the proper enum name.
|
|
146
|
+
const firstContribution = contributions[0];
|
|
147
|
+
const fileContent = fs.readFileSync(firstContribution.sourceFile, 'utf8');
|
|
148
|
+
const match = fileContent.match(/export\s+enum\s+(\w+)/);
|
|
149
|
+
const enumName = match ? match[1] : destFileName.replace('.ts', '');
|
|
150
|
+
// Start the aggregated file with the correct enum declaration.
|
|
151
|
+
commandRunner(`echo "export enum ${enumName} {" > ${aggregatedFile}`);
|
|
152
|
+
for (const contribution of contributions) {
|
|
153
|
+
commandRunner(`echo " // from package: ${contribution.pkgName}" >> ${aggregatedFile}`);
|
|
154
|
+
// Extract only the enum inner content (between "{" and "}") using two sed commands.
|
|
155
|
+
commandRunner(`sed -n '/{/,/}/p' ${contribution.sourceFile} | sed '1d;$d' >> ${aggregatedFile}`);
|
|
156
|
+
}
|
|
157
|
+
// Close the enum declaration.
|
|
158
|
+
commandRunner(`echo "}" >> ${aggregatedFile}`);
|
|
159
|
+
// Append an export statement to the enums index.
|
|
160
|
+
commandRunner(`echo "export * from './${enumName}';" >> ${path.join(enumDestFolder, 'index.ts')}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
// No enums were aggregated, but still create an empty index file.
|
|
165
|
+
fs.writeFileSync(path.join(enumDestFolder, 'index.ts'), '', 'utf8');
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// ----- Global Index Update -----
|
|
169
|
+
// Append export statements for each folder type that was processed.
|
|
170
|
+
const globalIndexFile = path.join(commonPackagePath, 'src', 'index.ts');
|
|
171
|
+
const folderTypes = ['modules', 'services', 'repository', 'enums'];
|
|
172
|
+
for (const folderKey of folderTypes) {
|
|
173
|
+
if (processedFolders[folderKey]) {
|
|
174
|
+
commandRunner(`echo "export * from './${folderKey}';" >> ${globalIndexFile}`);
|
|
175
|
+
}
|
|
64
176
|
}
|
|
65
177
|
}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":"
|
|
1
|
+
{"version":3,"file":"performCopyOperations.cjs","sources":["../../../src/tools/codegen/performCopyOperations.ts"],"sourcesContent":[null],"names":["pathsConfig","execSync"],"mappings":"uIAAA;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;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;;AAGP,IAAA,KAAK,MAAM,SAAS,IAA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OAAA,EAAU,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,CAAA,CAAE,CAAC,CAAC;aACtG;SACJ;aAAM;;AAEH,YAAA,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;SACvE;KACJ;;;AAID,IAAA,MAAM,eAAe,GAAG,IAAI,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"}
|
|
@@ -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
|
|
3
|
-
*
|
|
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.
|
|
4
9
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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;
|
|
@@ -1,65 +1,177 @@
|
|
|
1
|
-
import {execSync}from'child_process';import fs__default from'fs';import path__default from'path';import {pathsConfig}from'./commonPaths.js'
|
|
2
|
-
|
|
3
|
-
|
|
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 */
|
|
2
|
+
/* eslint-disable default-param-last */
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
|
+
/* eslint-disable guard-for-in */
|
|
5
|
+
/**
|
|
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.
|
|
4
9
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
-
function performCopyOperations(modules, cdecodePaths = {}) {
|
|
27
|
+
function performCopyOperations(modules, cdecodePaths = {}, options) {
|
|
9
28
|
let { repoRoot, commonPackagePath } = cdecodePaths;
|
|
10
|
-
// Fallback to internal pathsConfig if not provided by user
|
|
11
29
|
if (!repoRoot) {
|
|
12
30
|
repoRoot = pathsConfig.repoRoot;
|
|
13
31
|
}
|
|
14
32
|
if (!commonPackagePath) {
|
|
15
|
-
//
|
|
33
|
+
// For example, "packages/common"
|
|
16
34
|
commonPackagePath = path__default.join(pathsConfig.repoRoot, 'packages/common');
|
|
17
35
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
36
|
+
// Use the provided commandRunner or default to execSync.
|
|
37
|
+
const commandRunner = options?.commandRunner || ((cmd) => execSync(cmd));
|
|
38
|
+
// Track which resource folders are processed.
|
|
39
|
+
const processedFolders = {};
|
|
40
|
+
// Object to collect enum contributions.
|
|
41
|
+
// Key is the flattened destination file name (e.g. "auth-error.ts"),
|
|
42
|
+
// value is an array with the source file and package name.
|
|
43
|
+
const aggregatedEnums = {};
|
|
44
|
+
// Process each module (package) definition.
|
|
45
|
+
for (const moduleObj of modules) {
|
|
46
|
+
// moduleObj is expected to be an object like { server: 'packages-modules/user-auth0/core/src' }
|
|
47
|
+
for (const modulePathVal of Object.values(moduleObj)) {
|
|
22
48
|
try {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (
|
|
26
|
-
|
|
49
|
+
// Trim a trailing "/src" or "/lib" from the provided module path.
|
|
50
|
+
let trimmedModulePath = modulePathVal;
|
|
51
|
+
if (trimmedModulePath.endsWith(`${path__default.sep}src`) || trimmedModulePath.endsWith(`${path__default.sep}lib`)) {
|
|
52
|
+
trimmedModulePath = path__default.dirname(trimmedModulePath);
|
|
27
53
|
}
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
54
|
+
// Read package.json from the package root.
|
|
55
|
+
const pkgJsonFilePath = path__default.join(repoRoot, trimmedModulePath, 'package.json');
|
|
56
|
+
if (!fs__default.existsSync(pkgJsonFilePath))
|
|
57
|
+
continue;
|
|
58
|
+
const pkgJson = JSON.parse(fs__default.readFileSync(pkgJsonFilePath, 'utf-8'));
|
|
59
|
+
if (!pkgJson.cdecode?.common)
|
|
60
|
+
continue;
|
|
61
|
+
// For a scoped package like "@org/user-auth0-core", use the part after the slash.
|
|
62
|
+
const pkgNameFull = pkgJson.name || '';
|
|
63
|
+
const pkgName = pkgNameFull.split('/')[1] || pkgNameFull;
|
|
64
|
+
// Source base: package root (for resolving declared resource paths).
|
|
65
|
+
const sourceBase = path__default.join(repoRoot, trimmedModulePath);
|
|
66
|
+
for (const folderType of ['modules', 'services', 'repository', 'enums']) {
|
|
67
|
+
const resourceList = pkgJson.cdecode.common[folderType] || [];
|
|
68
|
+
if (resourceList.length === 0)
|
|
69
|
+
continue;
|
|
70
|
+
// Mark folder as processed.
|
|
71
|
+
processedFolders[folderType] = true;
|
|
72
|
+
// Determine destination folder.
|
|
73
|
+
// For non-enums, files are copied into common/src/<folderType>
|
|
74
|
+
// For enums, files are aggregated into common/src/enums.
|
|
75
|
+
let destFolder;
|
|
76
|
+
if (folderType === 'enums') {
|
|
77
|
+
destFolder = path__default.join(commonPackagePath, 'src', 'enums');
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
destFolder = path__default.join(commonPackagePath, 'src', folderType);
|
|
81
|
+
}
|
|
82
|
+
commandRunner(`mkdir -p ${destFolder}`);
|
|
83
|
+
resourceList.forEach((file) => {
|
|
84
|
+
// Flatten the resource file name (ignore any intermediate directories)
|
|
85
|
+
// and remove the ".ts.template" suffix.
|
|
86
|
+
const destFileName = path__default.basename(file).replace(/\.ts\.template$/, '.ts');
|
|
87
|
+
// Resolve the source file relative to the package root.
|
|
88
|
+
const sourceFile = path__default.join(sourceBase, file);
|
|
89
|
+
if (folderType === 'enums') {
|
|
90
|
+
// For enums, collect each file (with package name) for later aggregation.
|
|
91
|
+
if (!aggregatedEnums[destFileName]) {
|
|
92
|
+
aggregatedEnums[destFileName] = { contributions: [] };
|
|
93
|
+
}
|
|
94
|
+
aggregatedEnums[destFileName].contributions.push({ pkgName, sourceFile });
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// For non-enums, copy the file and then prepend a comment indicating its origin.
|
|
98
|
+
const destFile = path__default.join(destFolder, destFileName);
|
|
99
|
+
commandRunner(`cp -r ${sourceFile} ${destFile}`);
|
|
100
|
+
// Prepend a comment to indicate the package origin.
|
|
101
|
+
commandRunner(`(echo "// from package: ${pkgName}" && cat ${destFile}) > ${destFile}.tmp && mv ${destFile}.tmp ${destFile}`);
|
|
102
|
+
// Append an export statement to the folder's index.
|
|
103
|
+
commandRunner(`echo "export * from './${destFileName.replace('.ts', '')}';" >> ${path__default.join(destFolder, 'index.ts')}`);
|
|
104
|
+
// Replace any import from "common" with the relative path to generated models.
|
|
105
|
+
commandRunner(`sed -i '' "s/from ['\\"]common['\\"]/from '..\\/generated\\/generated-models'/g" ${destFile}`);
|
|
106
|
+
// If this is a service file, append the augmentation code directly to the service file.
|
|
107
|
+
if (folderType === 'services') {
|
|
108
|
+
const serviceBaseName = destFileName.replace('.ts', '');
|
|
109
|
+
const propertyName = serviceBaseName.charAt(0).toLowerCase() + serviceBaseName.slice(1);
|
|
110
|
+
const augmentationContent = `
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* This augments the ServerContext interface from the central apollo-context.
|
|
114
|
+
* Through declaration merging, the ${propertyName} service will be added to the ServerContext.
|
|
115
|
+
*/
|
|
116
|
+
declare module '../apollo-context' {
|
|
117
|
+
export interface ServerContext {
|
|
118
|
+
${propertyName}: I${serviceBaseName};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
// Read the current content of the service file.
|
|
123
|
+
const currentServiceContent = fs__default.readFileSync(destFile, 'utf8');
|
|
124
|
+
// Append the augmentation content to the service file.
|
|
125
|
+
fs__default.writeFileSync(destFile, currentServiceContent + augmentationContent, 'utf8');
|
|
126
|
+
}
|
|
127
|
+
}
|
|
39
128
|
});
|
|
40
|
-
// Create an index.ts that re-exports each file
|
|
41
|
-
const getFileNameWithoutExt = (filePath) => {
|
|
42
|
-
const justFile = path__default.basename(filePath);
|
|
43
|
-
return path__default.basename(justFile, path__default.extname(justFile));
|
|
44
|
-
};
|
|
45
|
-
const exports = resourceList
|
|
46
|
-
.map((file) => `export * from './${getFileNameWithoutExt(file)}';`)
|
|
47
|
-
.join('\n');
|
|
48
|
-
// Write index.ts
|
|
49
|
-
execSync(`echo "${exports.replace(/"/g, '\\"')}" > ${path__default.join(directoryPath, 'index.ts')}`);
|
|
50
|
-
// Write an index.ts in the parent folder, referencing the new module folder
|
|
51
|
-
execSync(`echo "export * from './${pkgName}';" > ${path__default.join(directoryPath, '../', 'index.ts')}`);
|
|
52
|
-
shouldAddExport = true;
|
|
53
129
|
}
|
|
54
130
|
}
|
|
55
|
-
catch (
|
|
56
|
-
console.error(`Error
|
|
57
|
-
// you can decide to continue or break
|
|
131
|
+
catch (err) {
|
|
132
|
+
console.error(`Error processing module: ${modulePathVal}`, err);
|
|
58
133
|
}
|
|
59
134
|
}
|
|
60
135
|
}
|
|
61
|
-
//
|
|
62
|
-
if
|
|
63
|
-
|
|
136
|
+
// ----- Enum Aggregation Step -----
|
|
137
|
+
// Ensure the enums destination folder is created if it was processed.
|
|
138
|
+
const enumDestFolder = path__default.join(commonPackagePath, 'src', 'enums');
|
|
139
|
+
if (processedFolders['enums']) {
|
|
140
|
+
commandRunner(`mkdir -p ${enumDestFolder}`);
|
|
141
|
+
if (Object.keys(aggregatedEnums).length > 0) {
|
|
142
|
+
for (const destFileName in aggregatedEnums) {
|
|
143
|
+
const aggregatedFile = path__default.join(enumDestFolder, destFileName);
|
|
144
|
+
const contributions = aggregatedEnums[destFileName].contributions;
|
|
145
|
+
// Read the first contribution's file content to extract the proper enum name.
|
|
146
|
+
const firstContribution = contributions[0];
|
|
147
|
+
const fileContent = fs__default.readFileSync(firstContribution.sourceFile, 'utf8');
|
|
148
|
+
const match = fileContent.match(/export\s+enum\s+(\w+)/);
|
|
149
|
+
const enumName = match ? match[1] : destFileName.replace('.ts', '');
|
|
150
|
+
// Start the aggregated file with the correct enum declaration.
|
|
151
|
+
commandRunner(`echo "export enum ${enumName} {" > ${aggregatedFile}`);
|
|
152
|
+
for (const contribution of contributions) {
|
|
153
|
+
commandRunner(`echo " // from package: ${contribution.pkgName}" >> ${aggregatedFile}`);
|
|
154
|
+
// Extract only the enum inner content (between "{" and "}") using two sed commands.
|
|
155
|
+
commandRunner(`sed -n '/{/,/}/p' ${contribution.sourceFile} | sed '1d;$d' >> ${aggregatedFile}`);
|
|
156
|
+
}
|
|
157
|
+
// Close the enum declaration.
|
|
158
|
+
commandRunner(`echo "}" >> ${aggregatedFile}`);
|
|
159
|
+
// Append an export statement to the enums index.
|
|
160
|
+
commandRunner(`echo "export * from './${enumName}';" >> ${path__default.join(enumDestFolder, 'index.ts')}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
// No enums were aggregated, but still create an empty index file.
|
|
165
|
+
fs__default.writeFileSync(path__default.join(enumDestFolder, 'index.ts'), '', 'utf8');
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// ----- Global Index Update -----
|
|
169
|
+
// Append export statements for each folder type that was processed.
|
|
170
|
+
const globalIndexFile = path__default.join(commonPackagePath, 'src', 'index.ts');
|
|
171
|
+
const folderTypes = ['modules', 'services', 'repository', 'enums'];
|
|
172
|
+
for (const folderKey of folderTypes) {
|
|
173
|
+
if (processedFolders[folderKey]) {
|
|
174
|
+
commandRunner(`echo "export * from './${folderKey}';" >> ${globalIndexFile}`);
|
|
175
|
+
}
|
|
64
176
|
}
|
|
65
177
|
}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":"
|
|
1
|
+
{"version":3,"file":"performCopyOperations.js","sources":["../../../src/tools/codegen/performCopyOperations.ts"],"sourcesContent":[null],"names":["path","fs"],"mappings":"4IAAA;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;AACX,QAAA,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC;KACnC;IACD,IAAI,CAAC,iBAAiB,EAAE;;QAEpB,iBAAiB,GAAGA,aAAI,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;KAC1E;;AAGD,IAAA,MAAM,aAAa,GAAG,OAAO,EAAE,aAAa,KAAK,CAAC,GAAW,KAAK,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;;IAGjF,MAAM,gBAAgB,GAA+B,EAAE,CAAC;;;;IAKxD,MAAM,eAAe,GAEjB,EAAE,CAAC;;AAGP,IAAA,KAAK,MAAM,SAAS,IAAI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A0B,QAAQ,CAAA,OAAA,EAAUD,aAAI,CAAC,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,CAAA,CAAE,CAAC,CAAC;aACtG;SACJ;aAAM;;AAEH,YAAAC,WAAE,CAAC,aAAa,CAACD,aAAI,CAAC,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;SACvE;KACJ;;;AAID,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -42,7 +42,14 @@ export interface IHttpMiddlewareContext {
|
|
|
42
42
|
};
|
|
43
43
|
res: express.Response;
|
|
44
44
|
}
|
|
45
|
-
|
|
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", "
|
|
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.
|
|
3
|
+
"version": "6.0.8-alpha.54",
|
|
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": "
|
|
60
|
+
"gitHead": "51ae82926e64ca89370dc7c447853befea00c3fa",
|
|
61
61
|
"typescript": {
|
|
62
62
|
"definition": "lib/index.d.ts"
|
|
63
63
|
}
|