@common-stack/rollup-vite-utils 6.0.8-alpha.54 → 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.
- package/lib/tools/codegen/modulePathParser.d.ts +56 -0
- package/lib/tools/codegen/performCopyOperations.cjs +22 -18
- package/lib/tools/codegen/performCopyOperations.cjs.map +1 -1
- package/lib/tools/codegen/performCopyOperations.js +22 -18
- package/lib/tools/codegen/performCopyOperations.js.map +1 -1
- package/package.json +2 -2
|
@@ -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,4 +1,5 @@
|
|
|
1
|
-
'use strict';var child_process=require('child_process'),fs=require('fs'),path=require('path'),commonPaths=require('./commonPaths.cjs');/* eslint-disable no-
|
|
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 */
|
|
@@ -45,12 +46,17 @@ function performCopyOperations(modules, cdecodePaths = {}, options) {
|
|
|
45
46
|
for (const moduleObj of modules) {
|
|
46
47
|
// moduleObj is expected to be an object like { server: 'packages-modules/user-auth0/core/src' }
|
|
47
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
|
+
}
|
|
48
59
|
try {
|
|
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);
|
|
53
|
-
}
|
|
54
60
|
// Read package.json from the package root.
|
|
55
61
|
const pkgJsonFilePath = path.join(repoRoot, trimmedModulePath, 'package.json');
|
|
56
62
|
if (!fs.existsSync(pkgJsonFilePath))
|
|
@@ -84,8 +90,9 @@ function performCopyOperations(modules, cdecodePaths = {}, options) {
|
|
|
84
90
|
// Flatten the resource file name (ignore any intermediate directories)
|
|
85
91
|
// and remove the ".ts.template" suffix.
|
|
86
92
|
const destFileName = path.basename(file).replace(/\.ts\.template$/, '.ts');
|
|
87
|
-
//
|
|
88
|
-
const
|
|
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);
|
|
89
96
|
if (folderType === 'enums') {
|
|
90
97
|
// For enums, collect each file (with package name) for later aggregation.
|
|
91
98
|
if (!aggregatedEnums[destFileName]) {
|
|
@@ -102,16 +109,15 @@ function performCopyOperations(modules, cdecodePaths = {}, options) {
|
|
|
102
109
|
// Append an export statement to the folder's index.
|
|
103
110
|
commandRunner(`echo "export * from './${destFileName.replace('.ts', '')}';" >> ${path.join(destFolder, 'index.ts')}`);
|
|
104
111
|
// Replace any import from "common" with the relative path to generated models.
|
|
112
|
+
// Use BSD‑compatible sed syntax.
|
|
105
113
|
commandRunner(`sed -i '' "s/from ['\\"]common['\\"]/from '..\\/generated\\/generated-models'/g" ${destFile}`);
|
|
106
|
-
// If this is a service file,
|
|
114
|
+
// If this is a service file, auto generate the augmentation boilerplate.
|
|
107
115
|
if (folderType === 'services') {
|
|
108
116
|
const serviceBaseName = destFileName.replace('.ts', '');
|
|
109
117
|
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.
|
|
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.
|
|
115
121
|
*/
|
|
116
122
|
declare module '../apollo-context' {
|
|
117
123
|
export interface ServerContext {
|
|
@@ -119,10 +125,8 @@ declare module '../apollo-context' {
|
|
|
119
125
|
}
|
|
120
126
|
}
|
|
121
127
|
`;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
// Append the augmentation content to the service file.
|
|
125
|
-
fs.writeFileSync(destFile, currentServiceContent + augmentationContent, 'utf8');
|
|
128
|
+
const augmentationFilePath = path.join(destFolder, `${serviceBaseName}.augment.d.ts`);
|
|
129
|
+
fs.writeFileSync(augmentationFilePath, augmentationContent, 'utf8');
|
|
126
130
|
}
|
|
127
131
|
}
|
|
128
132
|
});
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;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,IAAI,OAAO,EAAE;;QAE7B,KAAK,MAAM,aAAa,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAa,EAAE;
|
|
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;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,CAA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AAA,aAAa,CAAC,CAAqB,kBAAA,EAAA,QAAQ,SAAS,cAAc,CAAA,CAAE,CAAC,CAAC;AACtE,gBAAA,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;oBACtC,aAAa,CAAC,4BAA4B,YAAY,CAAC,OAAO,CAAQ,KAAA,EAAA,cAAc,CAAE,CAAA,CAAC,CAAC;;oBAExF,aAAa,CAAC,qBAAqB,YAAY,CAAC,UAAU,CAAqB,kBAAA,EAAA,cAAc,CAAE,CAAA,CAAC,CAAC;iBACpG;;AAED,gBAAA,aAAa,CAAC,CAAA,YAAA,EAAe,cAAc,CAAA,CAAE,CAAC,CAAC;;AAE/C,gBAAA,aAAa,CAAC,CAAA,uBAAA,EAA0B,QAAQ,CAAA,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,4 +1,5 @@
|
|
|
1
|
-
import {execSync}from'child_process';import fs__default from'fs';import path__default from'path';import {pathsConfig}from'./commonPaths.js';/* eslint-disable no-
|
|
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 */
|
|
@@ -45,12 +46,17 @@ function performCopyOperations(modules, cdecodePaths = {}, options) {
|
|
|
45
46
|
for (const moduleObj of modules) {
|
|
46
47
|
// moduleObj is expected to be an object like { server: 'packages-modules/user-auth0/core/src' }
|
|
47
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
|
+
}
|
|
48
59
|
try {
|
|
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);
|
|
53
|
-
}
|
|
54
60
|
// Read package.json from the package root.
|
|
55
61
|
const pkgJsonFilePath = path__default.join(repoRoot, trimmedModulePath, 'package.json');
|
|
56
62
|
if (!fs__default.existsSync(pkgJsonFilePath))
|
|
@@ -84,8 +90,9 @@ function performCopyOperations(modules, cdecodePaths = {}, options) {
|
|
|
84
90
|
// Flatten the resource file name (ignore any intermediate directories)
|
|
85
91
|
// and remove the ".ts.template" suffix.
|
|
86
92
|
const destFileName = path__default.basename(file).replace(/\.ts\.template$/, '.ts');
|
|
87
|
-
//
|
|
88
|
-
const
|
|
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);
|
|
89
96
|
if (folderType === 'enums') {
|
|
90
97
|
// For enums, collect each file (with package name) for later aggregation.
|
|
91
98
|
if (!aggregatedEnums[destFileName]) {
|
|
@@ -102,16 +109,15 @@ function performCopyOperations(modules, cdecodePaths = {}, options) {
|
|
|
102
109
|
// Append an export statement to the folder's index.
|
|
103
110
|
commandRunner(`echo "export * from './${destFileName.replace('.ts', '')}';" >> ${path__default.join(destFolder, 'index.ts')}`);
|
|
104
111
|
// Replace any import from "common" with the relative path to generated models.
|
|
112
|
+
// Use BSD‑compatible sed syntax.
|
|
105
113
|
commandRunner(`sed -i '' "s/from ['\\"]common['\\"]/from '..\\/generated\\/generated-models'/g" ${destFile}`);
|
|
106
|
-
// If this is a service file,
|
|
114
|
+
// If this is a service file, auto generate the augmentation boilerplate.
|
|
107
115
|
if (folderType === 'services') {
|
|
108
116
|
const serviceBaseName = destFileName.replace('.ts', '');
|
|
109
117
|
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.
|
|
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.
|
|
115
121
|
*/
|
|
116
122
|
declare module '../apollo-context' {
|
|
117
123
|
export interface ServerContext {
|
|
@@ -119,10 +125,8 @@ declare module '../apollo-context' {
|
|
|
119
125
|
}
|
|
120
126
|
}
|
|
121
127
|
`;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
// Append the augmentation content to the service file.
|
|
125
|
-
fs__default.writeFileSync(destFile, currentServiceContent + augmentationContent, 'utf8');
|
|
128
|
+
const augmentationFilePath = path__default.join(destFolder, `${serviceBaseName}.augment.d.ts`);
|
|
129
|
+
fs__default.writeFileSync(augmentationFilePath, augmentationContent, 'utf8');
|
|
126
130
|
}
|
|
127
131
|
}
|
|
128
132
|
});
|
|
@@ -1 +1 @@
|
|
|
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,OAAO,EAAE;;QAE7B,KAAK,MAAM,aAAa,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAa,EAAE;
|
|
1
|
+
{"version":3,"file":"performCopyOperations.js","sources":["../../../src/tools/codegen/performCopyOperations.ts"],"sourcesContent":[null],"names":["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AAA,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"}
|
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.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": "
|
|
60
|
+
"gitHead": "d6163f7cb4ec0abb8159d4fac97305af6557a765",
|
|
61
61
|
"typescript": {
|
|
62
62
|
"definition": "lib/index.d.ts"
|
|
63
63
|
}
|