@common-stack/generate-plugin 6.0.2-alpha.9 → 6.0.6-alpha.1
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/CHANGELOG.md +80 -20
- package/lib/generators/add-backend/files/config.json +0 -1
- package/lib/generators/add-backend/files/package.json +2 -35
- package/lib/generators/add-backend/files/src/api/root-schema.graphqls +19 -0
- package/lib/generators/add-backend/files/src/config/env-config.ts.template +2 -24
- package/lib/generators/add-backend/files/src/service.ts.template +4 -5
- package/lib/generators/add-backend/files/tsconfig.json +6 -12
- package/lib/generators/add-backend/files/webpack.config.js +8 -0
- package/lib/generators/add-backend/files/webpack.config.mjs +7 -0
- package/lib/generators/add-browser-package/files/package.json +1 -1
- package/lib/generators/add-frontend/templates/Dockerfile +1 -1
- package/lib/generators/add-frontend/templates/package.json +2 -2
- package/lib/generators/add-frontend/templates/vite.config.ts.template +2 -2
- package/lib/generators/add-fullstack/files/lint-staged.config.js +0 -2
- package/lib/generators/add-fullstack/files/package.json +5 -6
- package/lib/generators/add-fullstack/files/rollup.config.base.mjs +7 -2
- package/lib/generators/add-fullstack/files/tools/deploy-cli/updateLernaVersion.js +24 -5
- package/lib/generators/add-fullstack/files/tsconfig.json +2 -2
- package/lib/generators/add-moleculer/files/Dockerfile +1 -1
- package/lib/generators/add-moleculer/files/package.json +5 -5
- package/lib/generators/add-server-package/files/package.json +3 -3
- package/package.json +3 -3
- package/src/generators/add-fullstack/files/.husky/pre-commit +1 -0
- package/src/generators/add-fullstack/files/CHANGELOG.md +18 -10
- package/src/generators/add-fullstack/files/lint-staged.config.js +0 -2
- package/src/generators/add-fullstack/files/package.json +6 -7
- package/src/generators/add-fullstack/files/rollup.config.base.mjs +7 -2
- package/src/generators/add-fullstack/files/tools/deploy-cli/updateLernaVersion.js +24 -5
- package/src/generators/add-fullstack/files/tsconfig.json +2 -2
- package/src/generators/add-moleculer/files/CHANGELOG.md +4 -0
- package/src/generators/add-moleculer/files/Dockerfile +1 -1
- package/src/generators/add-moleculer/files/package.json +6 -6
- package/lib/generators/add-backend/files/CHANGELOG.md +0 -196
- package/lib/generators/add-backend/files/generated-schema.graphql +0 -235
- package/lib/generators/add-browser-package/files/CHANGELOG.md +0 -3119
- package/lib/generators/add-core-package/files/CHANGELOG.md +0 -1076
- package/lib/generators/add-fullstack/files/tools/rollup/rollupPluginGenerateJson.mjs +0 -48
- package/lib/generators/add-fullstack/files/tools/rollup/rollupPluginModifyLibFiles.mjs +0 -410
- package/lib/generators/add-fullstack/files/typings/graphql.d.ts.template +0 -72
- package/lib/generators/add-moleculer/files/draft.toml +0 -61
- package/src/generators/add-fullstack/files/tools/rollup/rollupPluginGenerateJson.mjs +0 -48
- package/src/generators/add-fullstack/files/tools/rollup/rollupPluginModifyLibFiles.mjs +0 -410
- package/src/generators/add-fullstack/files/typings/graphql.d.ts.template +0 -72
- package/src/generators/add-moleculer/files/.draft-tasks.toml +0 -0
- package/src/generators/add-moleculer/files/draft.toml +0 -61
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { promisify } from 'util';
|
|
2
|
-
import glob from 'glob';
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
|
|
6
|
-
const globPromise = promisify(glob.glob); // Make sure to call .glob here
|
|
7
|
-
|
|
8
|
-
export default function generateJsonFromSpecificFiles(options = {}) {
|
|
9
|
-
const {
|
|
10
|
-
pattern = '**/**/compute.js', // Pattern to match files
|
|
11
|
-
dist = 'lib', // Default output directory
|
|
12
|
-
outputFile = 'routes.json', // Output filename
|
|
13
|
-
} = options;
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
name: 'aggregate-compute-routes',
|
|
17
|
-
async writeBundle() { // Changed from generateBundle to writeBundle
|
|
18
|
-
const files = await globPromise(path.join(dist, pattern), { absolute: true }); // Ensure paths are absolute
|
|
19
|
-
let allFilteredRoutes = [];
|
|
20
|
-
|
|
21
|
-
for (const file of files) {
|
|
22
|
-
try {
|
|
23
|
-
// Dynamically import the JS file assuming it exports filteredRoutes
|
|
24
|
-
const module = await import(file); // file is already absolute
|
|
25
|
-
if (module.filteredRoutes) {
|
|
26
|
-
const newRoutes = module.filteredRoutes.map((filteredRoute) => {
|
|
27
|
-
let routConfig = Object.values(filteredRoute)[0];
|
|
28
|
-
return { [routConfig.path]: routConfig };
|
|
29
|
-
});
|
|
30
|
-
allFilteredRoutes.push(...newRoutes);
|
|
31
|
-
}
|
|
32
|
-
} catch (error) {
|
|
33
|
-
this.warn(`Error importing ${file}: ${error}`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Ensure the dist directory exists
|
|
38
|
-
if (!fs.existsSync(dist)) {
|
|
39
|
-
fs.mkdirSync(dist, { recursive: true });
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Specify the output file path and write the aggregated filteredRoutes to a JSON file
|
|
43
|
-
const outputPath = path.join(dist, outputFile);
|
|
44
|
-
fs.writeFileSync(outputPath, JSON.stringify(allFilteredRoutes, null, 2), 'utf8');
|
|
45
|
-
console.log(`Aggregated filtered routes have been written to ${outputPath}`);
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
}
|
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { parse } from '@babel/parser';
|
|
4
|
-
import traverse from '@babel/traverse';
|
|
5
|
-
import generate from '@babel/generator';
|
|
6
|
-
import * as t from '@babel/types';
|
|
7
|
-
import { promisify } from 'util';
|
|
8
|
-
import glob from 'glob';
|
|
9
|
-
import { createFilter } from '@rollup/pluginutils';
|
|
10
|
-
const globPromise = promisify(glob.glob); // Make sure to call .glob here
|
|
11
|
-
|
|
12
|
-
function findPackageJson(directory) {
|
|
13
|
-
let currentDir = directory;
|
|
14
|
-
while (currentDir && currentDir !== path.parse(currentDir).root) {
|
|
15
|
-
const packageJsonPath = path.join(currentDir, 'package.json');
|
|
16
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
17
|
-
return packageJsonPath;
|
|
18
|
-
}
|
|
19
|
-
currentDir = path.dirname(currentDir);
|
|
20
|
-
}
|
|
21
|
-
throw new Error(`No package.json found in path ${directory}`);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const RouteModule = {
|
|
25
|
-
action: 'action',
|
|
26
|
-
hasAction: 'hasAction',
|
|
27
|
-
clientAction: 'clientAction',
|
|
28
|
-
hasClientAction: 'hasClientAction',
|
|
29
|
-
clientLoader: 'clientLoader',
|
|
30
|
-
hasClientLoader: 'hasClientLoader',
|
|
31
|
-
Component: 'default', // default export
|
|
32
|
-
hasComponent: 'hasComponent',
|
|
33
|
-
ErrorBoundary: 'ErrorBoundary',
|
|
34
|
-
hasErrorBoundary: 'hasErrorBoundary',
|
|
35
|
-
handle: 'handle',
|
|
36
|
-
hasHandle: 'hasHandle',
|
|
37
|
-
headers: 'headers',
|
|
38
|
-
hasHeaders: 'hasHeaders',
|
|
39
|
-
HydrateFallback: 'HydrateFallback',
|
|
40
|
-
hasHydrateFallback: 'hasHydrateFallback',
|
|
41
|
-
links: 'links',
|
|
42
|
-
hasLinks: 'hasLinks',
|
|
43
|
-
loader: 'loader',
|
|
44
|
-
hasLoader: 'hasLoader',
|
|
45
|
-
meta: 'meta',
|
|
46
|
-
hasMeta: 'hasMeta',
|
|
47
|
-
shouldRevalidate: 'shouldRevalidate',
|
|
48
|
-
hasShouldRevalidate: 'hasShouldRevalidate',
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
function modifyDeferReturn(filePath, loaderName) {
|
|
53
|
-
const fileContent = fs.readFileSync(filePath, 'utf8');
|
|
54
|
-
const ast = parse(fileContent, {
|
|
55
|
-
sourceType: 'module',
|
|
56
|
-
plugins: ['typescript', 'jsx'],
|
|
57
|
-
});
|
|
58
|
-
console.log('---MODIFY LOADER -- filepath', filePath, '---loaderName', loaderName);
|
|
59
|
-
let modified = false; // flag to check if changes were made
|
|
60
|
-
|
|
61
|
-
let deferKeys = [];
|
|
62
|
-
traverse.default(ast, {
|
|
63
|
-
// Handle all function types
|
|
64
|
-
'FunctionDeclaration|ArrowFunctionExpression|FunctionExpression'(path) {
|
|
65
|
-
// Check if this function is the loader by comparing the names or context
|
|
66
|
-
let functionName = path.node.id ? path.node.id.name : null;
|
|
67
|
-
if (!functionName && path.parent && path.parent.id) {
|
|
68
|
-
functionName = path.parent.id.name; // For functions assigned to variables
|
|
69
|
-
}
|
|
70
|
-
// Match by function name or check if it's a default export or a direct export
|
|
71
|
-
if (
|
|
72
|
-
functionName === loaderName ||
|
|
73
|
-
path.parent.type === 'ExportDefaultDeclaration' ||
|
|
74
|
-
(path.parent.type === 'ExportNamedDeclaration' && path.parent.declaration === path.node)
|
|
75
|
-
) {
|
|
76
|
-
// Traverse into the function body to look for ReturnStatement using defer
|
|
77
|
-
path.traverse({
|
|
78
|
-
ReturnStatement(returnPath) {
|
|
79
|
-
if (
|
|
80
|
-
returnPath.node.argument &&
|
|
81
|
-
returnPath.node.argument.type === 'CallExpression' &&
|
|
82
|
-
returnPath.node.argument.callee.name === 'defer'
|
|
83
|
-
) {
|
|
84
|
-
// Check if the first argument of defer is an object with properties to unwrap
|
|
85
|
-
if (
|
|
86
|
-
returnPath.node.argument.arguments.length > 0 &&
|
|
87
|
-
returnPath.node.argument.arguments[0].type === 'ObjectExpression' &&
|
|
88
|
-
returnPath.node.argument.arguments[0].properties.length > 0
|
|
89
|
-
) {
|
|
90
|
-
const properties = returnPath.node.argument.arguments[0].properties;
|
|
91
|
-
const valuesArray = properties.map(prop => prop.value); // Map properties to their values
|
|
92
|
-
|
|
93
|
-
properties.forEach((prop) => {
|
|
94
|
-
deferKeys.push(prop.key.name);
|
|
95
|
-
});
|
|
96
|
-
// Simplify the return statement to return the first property's value of the object
|
|
97
|
-
returnPath.node.argument = t.arrayExpression(valuesArray);
|
|
98
|
-
|
|
99
|
-
modified = true; // mark as modified
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
if (modified) {
|
|
109
|
-
const output = generate.default(ast, {}, fileContent);
|
|
110
|
-
fs.writeFileSync(filePath, output.code);
|
|
111
|
-
console.log(`Loader modified: ${filePath}`);
|
|
112
|
-
} else {
|
|
113
|
-
console.log(`No modifications made to: ${filePath}`);
|
|
114
|
-
}
|
|
115
|
-
return deferKeys;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export default function modifyLibFilesPlugin(options = {}) {
|
|
119
|
-
// Create a filter to only include the desired files
|
|
120
|
-
const filter = createFilter(options.include, options.exclude);
|
|
121
|
-
const dist = options.outputDir || './lib'; // Default output directory
|
|
122
|
-
const pattern = '**/**/compute.js'; // Pattern to match files
|
|
123
|
-
|
|
124
|
-
return {
|
|
125
|
-
name: 'modify-lib-files',
|
|
126
|
-
|
|
127
|
-
async writeBundle(outputOptions) {
|
|
128
|
-
const currentWorkingDir = process.cwd();
|
|
129
|
-
// Assuming you want to modify specific files, list them here
|
|
130
|
-
const filesToModify = await globPromise(path.join(dist, pattern), { absolute: true }); // Ensure paths are absolute
|
|
131
|
-
filesToModify.forEach((filePath) => {
|
|
132
|
-
if (!filter(filePath)) return; // Skip files that do not match the filter
|
|
133
|
-
|
|
134
|
-
// Read the file content
|
|
135
|
-
const code = fs.readFileSync(filePath, 'utf8');
|
|
136
|
-
// Parse the code to an AST
|
|
137
|
-
const ast = parse(code, {
|
|
138
|
-
sourceType: 'module',
|
|
139
|
-
plugins: ['js', 'dynamicImport'], // Adjust plugins as necessary
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
// Traverse and modify the AST as needed
|
|
143
|
-
let modified = false;
|
|
144
|
-
traverse.default(ast, {
|
|
145
|
-
enter(astroPath) {
|
|
146
|
-
// Adjust this part to target the specific objects and properties in your AST
|
|
147
|
-
if (
|
|
148
|
-
astroPath.isObjectProperty() &&
|
|
149
|
-
(astroPath.node.key.name === 'component' || astroPath.node.key.name === 'dialog')
|
|
150
|
-
) {
|
|
151
|
-
const importDeclaration = astroPath.node.value;
|
|
152
|
-
const propName = astroPath.node.key.name;
|
|
153
|
-
|
|
154
|
-
if (
|
|
155
|
-
importDeclaration.type === 'ArrowFunctionExpression' &&
|
|
156
|
-
importDeclaration.body.type === 'CallExpression' &&
|
|
157
|
-
importDeclaration.body.callee.type === 'Import'
|
|
158
|
-
) {
|
|
159
|
-
const importArg = importDeclaration.body.arguments[0];
|
|
160
|
-
|
|
161
|
-
// Ensure we're dealing with a string literal import path
|
|
162
|
-
if (importArg.type === 'StringLiteral') {
|
|
163
|
-
let importPath = importArg.value;
|
|
164
|
-
let hasLoader = false;
|
|
165
|
-
let hasAction = false;
|
|
166
|
-
let hasClientLoader = false;
|
|
167
|
-
let hasClientAction = false;
|
|
168
|
-
let hasComponent = false;
|
|
169
|
-
let hasErrorBoundary = false;
|
|
170
|
-
let hasLinks = false;
|
|
171
|
-
let hasMeta = false;
|
|
172
|
-
let hasHydrateFallback = false;
|
|
173
|
-
let hasShouldRevalidate = false;
|
|
174
|
-
let hasHandle = false;
|
|
175
|
-
let hasHeaders = false;
|
|
176
|
-
let deferKeys = [];
|
|
177
|
-
const fullPath = path.resolve(path.dirname(filePath), importPath);
|
|
178
|
-
if (astroPath.node.key.name === 'component' && fs.existsSync(fullPath)) {
|
|
179
|
-
const importedFileCode = fs.readFileSync(fullPath, 'utf8');
|
|
180
|
-
const importedAst = parse(importedFileCode, {
|
|
181
|
-
sourceType: 'module',
|
|
182
|
-
plugins: ['typescript', 'jsx'],
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
traverse.default(importedAst, {
|
|
186
|
-
ExportNamedDeclaration(namedPath) {
|
|
187
|
-
namedPath.node.specifiers.forEach((specifier) => {
|
|
188
|
-
if (specifier.exported.name === RouteModule.loader) {
|
|
189
|
-
hasLoader = true;
|
|
190
|
-
let fullPathToLoader;
|
|
191
|
-
if (namedPath.node.source) {
|
|
192
|
-
// Handle re-exported loaders
|
|
193
|
-
const loaderSourcePath = namedPath.node.source.value; // Path of the module
|
|
194
|
-
fullPathToLoader = path.resolve(
|
|
195
|
-
path.dirname(fullPath),
|
|
196
|
-
loaderSourcePath,
|
|
197
|
-
);
|
|
198
|
-
} else {
|
|
199
|
-
fullPathToLoader = fullPath;
|
|
200
|
-
}
|
|
201
|
-
deferKeys = modifyDeferReturn(
|
|
202
|
-
fullPathToLoader,
|
|
203
|
-
specifier.local.name,
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
if (specifier.exported.name === RouteModule.action) {
|
|
207
|
-
hasAction = true;
|
|
208
|
-
}
|
|
209
|
-
if (specifier.exported.name === RouteModule.Component) {
|
|
210
|
-
hasComponent = true;
|
|
211
|
-
}
|
|
212
|
-
if (specifier.exported.name === RouteModule.ErrorBoundary) {
|
|
213
|
-
hasErrorBoundary = true;
|
|
214
|
-
}
|
|
215
|
-
if (specifier.exported.name === RouteModule.clientLoader) {
|
|
216
|
-
hasClientLoader = true;
|
|
217
|
-
}
|
|
218
|
-
if (specifier.exported.name === RouteModule.clientAction) {
|
|
219
|
-
hasClientAction = true;
|
|
220
|
-
}
|
|
221
|
-
if (specifier.exported.name === RouteModule.headers) {
|
|
222
|
-
hasHeaders = true;
|
|
223
|
-
}
|
|
224
|
-
if (specifier.exported.name === RouteModule.links) {
|
|
225
|
-
hasLinks = true;
|
|
226
|
-
}
|
|
227
|
-
if (specifier.exported.name === RouteModule.meta) {
|
|
228
|
-
hasMeta = true;
|
|
229
|
-
}
|
|
230
|
-
if (specifier.exported.name === RouteModule.shouldRevalidate) {
|
|
231
|
-
hasShouldRevalidate = true;
|
|
232
|
-
}
|
|
233
|
-
if (specifier.exported.name === RouteModule.HydrateFallback) {
|
|
234
|
-
hasHydrateFallback = true;
|
|
235
|
-
}
|
|
236
|
-
if (specifier.exported.name === RouteModule.handle) {
|
|
237
|
-
hasHandle = true;
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
},
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
const packageJsonPath = findPackageJson(
|
|
244
|
-
path.dirname(path.resolve(process.cwd(), dist)),
|
|
245
|
-
);
|
|
246
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
247
|
-
const relativePath = path.relative(path.dirname(packageJsonPath), fullPath);
|
|
248
|
-
const normalizedImportPath = relativePath.replace(/\\/g, '/'); // Normalize path for Windows
|
|
249
|
-
|
|
250
|
-
const newImportPath = `${packageJson.name}/${normalizedImportPath}`;
|
|
251
|
-
|
|
252
|
-
// Create a new `file` property
|
|
253
|
-
const fileProperty = t.objectProperty(
|
|
254
|
-
t.identifier(`${propName}Path`),
|
|
255
|
-
t.stringLiteral(newImportPath),
|
|
256
|
-
);
|
|
257
|
-
|
|
258
|
-
// Get the parent object expression to add the new property
|
|
259
|
-
const parentObject = astroPath.findParent((p) => p.isObjectExpression());
|
|
260
|
-
if (parentObject) {
|
|
261
|
-
// remove component
|
|
262
|
-
astroPath.remove();
|
|
263
|
-
parentObject.node.properties.push(fileProperty);
|
|
264
|
-
if (hasLoader) {
|
|
265
|
-
parentObject.node.properties.push(
|
|
266
|
-
t.objectProperty(t.identifier(RouteModule.hasLoader), t.booleanLiteral(true)),
|
|
267
|
-
);
|
|
268
|
-
}
|
|
269
|
-
if (hasAction) {
|
|
270
|
-
parentObject.node.properties.push(
|
|
271
|
-
t.objectProperty(t.identifier(RouteModule.hasAction), t.booleanLiteral(true)),
|
|
272
|
-
);
|
|
273
|
-
}
|
|
274
|
-
if (hasClientLoader) {
|
|
275
|
-
parentObject.node.properties.push(
|
|
276
|
-
t.objectProperty(t.identifier(RouteModule.hasClientLoader), t.booleanLiteral(true)),
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
if (hasClientAction) {
|
|
280
|
-
parentObject.node.properties.push(
|
|
281
|
-
t.objectProperty(t.identifier(RouteModule.hasClientAction), t.booleanLiteral(true)),
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
if (hasComponent) {
|
|
285
|
-
parentObject.node.properties.push(
|
|
286
|
-
t.objectProperty(t.identifier(RouteModule.hasComponent), t.booleanLiteral(true)),
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
if (hasErrorBoundary) {
|
|
290
|
-
parentObject.node.properties.push(
|
|
291
|
-
t.objectProperty(t.identifier(RouteModule.hasErrorBoundary), t.booleanLiteral(true)),
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
if (hasHeaders) {
|
|
295
|
-
parentObject.node.properties.push(
|
|
296
|
-
t.objectProperty(t.identifier(RouteModule.hasHeaders), t.booleanLiteral(true)),
|
|
297
|
-
);
|
|
298
|
-
}
|
|
299
|
-
if (hasHydrateFallback) {
|
|
300
|
-
parentObject.node.properties.push(
|
|
301
|
-
t.objectProperty(t.identifier(RouteModule.hasHydrateFallback), t.booleanLiteral(true)),
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
if (hasMeta) {
|
|
305
|
-
parentObject.node.properties.push(
|
|
306
|
-
t.objectProperty(t.identifier(RouteModule.hasMeta), t.booleanLiteral(true)),
|
|
307
|
-
);
|
|
308
|
-
}
|
|
309
|
-
if (hasLinks) {
|
|
310
|
-
parentObject.node.properties.push(
|
|
311
|
-
t.objectProperty(t.identifier(RouteModule.hasLinks), t.booleanLiteral(true)),
|
|
312
|
-
);
|
|
313
|
-
}
|
|
314
|
-
if (hasHandle) {
|
|
315
|
-
parentObject.node.properties.push(
|
|
316
|
-
t.objectProperty(t.identifier(RouteModule.hasHandle), t.booleanLiteral(true)),
|
|
317
|
-
);
|
|
318
|
-
}
|
|
319
|
-
if (hasShouldRevalidate) {
|
|
320
|
-
parentObject.node.properties.push(
|
|
321
|
-
t.objectProperty(t.identifier(RouteModule.hasShouldRevalidate), t.booleanLiteral(true)),
|
|
322
|
-
);
|
|
323
|
-
}
|
|
324
|
-
if (deferKeys.length > 0) {
|
|
325
|
-
const deferKeysArrayExpression = t.arrayExpression(
|
|
326
|
-
deferKeys.map(key => t.stringLiteral(key))
|
|
327
|
-
);
|
|
328
|
-
parentObject.node.properties.push(
|
|
329
|
-
t.objectProperty(
|
|
330
|
-
t.identifier('loaderDeferKeys'),
|
|
331
|
-
deferKeysArrayExpression,
|
|
332
|
-
),
|
|
333
|
-
);
|
|
334
|
-
}
|
|
335
|
-
modified = true; // Mark as modified
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
} else if (
|
|
340
|
-
astroPath.node.key &&
|
|
341
|
-
astroPath.node.key.name === 'wrappers' &&
|
|
342
|
-
astroPath.node.value.type === 'ArrayExpression'
|
|
343
|
-
) {
|
|
344
|
-
const parentObjectExpression = astroPath.findParent((p) => p.isObjectExpression());
|
|
345
|
-
const wrapperPaths = [];
|
|
346
|
-
astroPath.node.value.elements.forEach((element, index) => {
|
|
347
|
-
if (element.type === 'CallExpression' && element.callee.type === 'Import') {
|
|
348
|
-
const importArg = element.arguments[0];
|
|
349
|
-
if (importArg && importArg.type === 'StringLiteral') {
|
|
350
|
-
const importPath = importArg.value;
|
|
351
|
-
const fullPath = path.resolve(path.dirname(filePath), importPath);
|
|
352
|
-
const packageJsonPath = findPackageJson(
|
|
353
|
-
path.dirname(path.resolve(process.cwd(), dist)),
|
|
354
|
-
);
|
|
355
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
356
|
-
const relativePath = path.relative(path.dirname(packageJsonPath), fullPath);
|
|
357
|
-
const normalizedImportPath = `${packageJson.name}/${relativePath.replace(
|
|
358
|
-
/\\/g,
|
|
359
|
-
'/',
|
|
360
|
-
)}`;
|
|
361
|
-
// Modify the import path directly
|
|
362
|
-
element.arguments[0] = t.stringLiteral(normalizedImportPath);
|
|
363
|
-
|
|
364
|
-
wrapperPaths.push(normalizedImportPath);
|
|
365
|
-
|
|
366
|
-
if (wrapperPaths.length > 0) {
|
|
367
|
-
// Construct an array expression for the wrapper paths
|
|
368
|
-
const wrapperPathsArrayExpression = t.arrayExpression(
|
|
369
|
-
wrapperPaths.map((path) => t.stringLiteral(path)),
|
|
370
|
-
);
|
|
371
|
-
// Create an object property AST node for `wrapperPaths`
|
|
372
|
-
const wrapperPathsProperty = t.objectProperty(
|
|
373
|
-
t.identifier('wrapperPaths'), // Property key
|
|
374
|
-
wrapperPathsArrayExpression, // Property value
|
|
375
|
-
);
|
|
376
|
-
astroPath.remove();
|
|
377
|
-
// Ensure the parent object expression exists and has properties
|
|
378
|
-
if (
|
|
379
|
-
parentObjectExpression &&
|
|
380
|
-
parentObjectExpression.node &&
|
|
381
|
-
parentObjectExpression.node.properties
|
|
382
|
-
) {
|
|
383
|
-
// Push the new property into the parent object's properties array
|
|
384
|
-
parentObjectExpression.node.properties.push(wrapperPathsProperty);
|
|
385
|
-
modified = true; // Mark as modified
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
},
|
|
393
|
-
});
|
|
394
|
-
// If AST was modified, regenerate code
|
|
395
|
-
if (modified) {
|
|
396
|
-
const output = generate.default(
|
|
397
|
-
ast,
|
|
398
|
-
{
|
|
399
|
-
/* options */
|
|
400
|
-
},
|
|
401
|
-
code,
|
|
402
|
-
);
|
|
403
|
-
fs.writeFileSync(filePath, output.code); // This line actually writes the changes
|
|
404
|
-
}
|
|
405
|
-
// This plugin doesn't modify the code, so return null
|
|
406
|
-
return null;
|
|
407
|
-
});
|
|
408
|
-
},
|
|
409
|
-
};
|
|
410
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
declare module '*/AddCounter.client.gql' {
|
|
3
|
-
import { DocumentNode } from 'graphql';
|
|
4
|
-
const defaultDocument: DocumentNode;
|
|
5
|
-
export const addCounterState: DocumentNode;
|
|
6
|
-
|
|
7
|
-
export default defaultDocument;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
declare module '*/AddCounter.gql' {
|
|
12
|
-
import { DocumentNode } from 'graphql';
|
|
13
|
-
const defaultDocument: DocumentNode;
|
|
14
|
-
export const addCounter: DocumentNode;
|
|
15
|
-
|
|
16
|
-
export default defaultDocument;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
declare module '*/AddCounter_WS.gql' {
|
|
21
|
-
import { DocumentNode } from 'graphql';
|
|
22
|
-
const defaultDocument: DocumentNode;
|
|
23
|
-
export const AddCounter_WS: DocumentNode;
|
|
24
|
-
|
|
25
|
-
export default defaultDocument;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
declare module '*/SyncCachedCounter.gql' {
|
|
30
|
-
import { DocumentNode } from 'graphql';
|
|
31
|
-
const defaultDocument: DocumentNode;
|
|
32
|
-
export const SyncCachedCounter: DocumentNode;
|
|
33
|
-
|
|
34
|
-
export default defaultDocument;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
declare module '*/CounterCacheQuery_WS.gql' {
|
|
39
|
-
import { DocumentNode } from 'graphql';
|
|
40
|
-
const defaultDocument: DocumentNode;
|
|
41
|
-
export const counterCacheQuery: DocumentNode;
|
|
42
|
-
|
|
43
|
-
export default defaultDocument;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
declare module '*/CounterQuery.client.gql' {
|
|
48
|
-
import { DocumentNode } from 'graphql';
|
|
49
|
-
const defaultDocument: DocumentNode;
|
|
50
|
-
export const CounterState: DocumentNode;
|
|
51
|
-
|
|
52
|
-
export default defaultDocument;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
declare module '*/CounterQuery.gql' {
|
|
57
|
-
import { DocumentNode } from 'graphql';
|
|
58
|
-
const defaultDocument: DocumentNode;
|
|
59
|
-
export const counterQuery: DocumentNode;
|
|
60
|
-
|
|
61
|
-
export default defaultDocument;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
declare module '*/CounterSubscription.gql' {
|
|
66
|
-
import { DocumentNode } from 'graphql';
|
|
67
|
-
const defaultDocument: DocumentNode;
|
|
68
|
-
export const onCounterUpdated: DocumentNode;
|
|
69
|
-
|
|
70
|
-
export default defaultDocument;
|
|
71
|
-
}
|
|
72
|
-
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
[environments]
|
|
2
|
-
[environments.development]
|
|
3
|
-
name = "activity-server"
|
|
4
|
-
namespace = "adminide"
|
|
5
|
-
wait = true
|
|
6
|
-
watch = false
|
|
7
|
-
watch-delay = 2
|
|
8
|
-
auto-connect = false
|
|
9
|
-
dockerfile = "Dockerfile"
|
|
10
|
-
set = ["env.LOG_LEVEL=trace",
|
|
11
|
-
"env.HEMERA_LOG_LEVEL=trace",
|
|
12
|
-
"env.CONNECTION_ID=v1",
|
|
13
|
-
"env.NATS_URL=nats://adminide-idestack-nats.adminide.svc.cluster.local:4222",
|
|
14
|
-
"env.NATS_USER=ruser",
|
|
15
|
-
"env.NATS_PW=T0pS3cr3t",
|
|
16
|
-
"env.REDIS_URL=redis://adminide-idestack-redis.adminide.svc.cluster.local:6379",
|
|
17
|
-
"env.MONGO_URL=mongodb://adminide-idestack-mongodb.adminide.svc.cluster.local:27017/idestack",
|
|
18
|
-
"env.ZIPKIN_URL=adminide-idestack-zipkin.adminide.svc.cluster.local",
|
|
19
|
-
"env.ZIPKIN_PORT=9411",
|
|
20
|
-
]
|
|
21
|
-
chart = ""
|
|
22
|
-
[environments.staging]
|
|
23
|
-
name = "activity-server"
|
|
24
|
-
namespace = "adminide"
|
|
25
|
-
wait = true
|
|
26
|
-
watch = false
|
|
27
|
-
watch-delay = 2
|
|
28
|
-
auto-connect = false
|
|
29
|
-
dockerfile = "Dockerfile"
|
|
30
|
-
set = ["env.LOG_LEVEL=info",
|
|
31
|
-
"env.HEMERA_LOG_LEVEL=info",
|
|
32
|
-
"env.CONNECTION_ID=v1",
|
|
33
|
-
"env.NATS_URL=nats://adminide-idestack-nats.adminide.svc.cluster.local:4222",
|
|
34
|
-
"env.NATS_USER=ruser",
|
|
35
|
-
"env.NATS_PW=T0pS3cr3t",
|
|
36
|
-
"env.REDIS_URL=redis://adminide-idestack-redis.adminide.svc.cluster.local:6379",
|
|
37
|
-
"env.MONGO_URL=mongodb://adminide-idestack-mongodb.adminide.svc.cluster.local:27017/idestack",
|
|
38
|
-
"env.ZIPKIN_URL=adminide-idestack-zipkin.adminide.svc.cluster.local",
|
|
39
|
-
"env.ZIPKIN_PORT=9411",
|
|
40
|
-
]
|
|
41
|
-
chart = ""
|
|
42
|
-
[environments.production]
|
|
43
|
-
name = "activity-server"
|
|
44
|
-
namespace = "adminide"
|
|
45
|
-
wait = true
|
|
46
|
-
watch = false
|
|
47
|
-
watch-delay = 2
|
|
48
|
-
auto-connect = false
|
|
49
|
-
dockerfile = "Dockerfile"
|
|
50
|
-
set = ["env.LOG_LEVEL=info",
|
|
51
|
-
"env.HEMERA_LOG_LEVEL=info",
|
|
52
|
-
"env.CONNECTION_ID=v1",
|
|
53
|
-
"env.NATS_URL=nats://adminide-idestack-nats.adminide.svc.cluster.local:4222",
|
|
54
|
-
"env.NATS_USER=ruser",
|
|
55
|
-
"env.NATS_PW=T0pS3cr3t",
|
|
56
|
-
"env.REDIS_URL=redis://adminide-idestack-redis.adminide.svc.cluster.local:6379",
|
|
57
|
-
"env.MONGO_URL=mongodb://adminide-idestack-mongodb.adminide.svc.cluster.local:27017/idestack",
|
|
58
|
-
"env.ZIPKIN_URL=adminide-idestack-zipkin.adminide.svc.cluster.local",
|
|
59
|
-
"env.ZIPKIN_PORT=9411",
|
|
60
|
-
]
|
|
61
|
-
chart = ""
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { promisify } from 'util';
|
|
2
|
-
import glob from 'glob';
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
|
|
6
|
-
const globPromise = promisify(glob.glob); // Make sure to call .glob here
|
|
7
|
-
|
|
8
|
-
export default function generateJsonFromSpecificFiles(options = {}) {
|
|
9
|
-
const {
|
|
10
|
-
pattern = '**/**/compute.js', // Pattern to match files
|
|
11
|
-
dist = 'lib', // Default output directory
|
|
12
|
-
outputFile = 'routes.json', // Output filename
|
|
13
|
-
} = options;
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
name: 'aggregate-compute-routes',
|
|
17
|
-
async writeBundle() { // Changed from generateBundle to writeBundle
|
|
18
|
-
const files = await globPromise(path.join(dist, pattern), { absolute: true }); // Ensure paths are absolute
|
|
19
|
-
let allFilteredRoutes = [];
|
|
20
|
-
|
|
21
|
-
for (const file of files) {
|
|
22
|
-
try {
|
|
23
|
-
// Dynamically import the JS file assuming it exports filteredRoutes
|
|
24
|
-
const module = await import(file); // file is already absolute
|
|
25
|
-
if (module.filteredRoutes) {
|
|
26
|
-
const newRoutes = module.filteredRoutes.map((filteredRoute) => {
|
|
27
|
-
let routConfig = Object.values(filteredRoute)[0];
|
|
28
|
-
return { [routConfig.path]: routConfig };
|
|
29
|
-
});
|
|
30
|
-
allFilteredRoutes.push(...newRoutes);
|
|
31
|
-
}
|
|
32
|
-
} catch (error) {
|
|
33
|
-
this.warn(`Error importing ${file}: ${error}`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Ensure the dist directory exists
|
|
38
|
-
if (!fs.existsSync(dist)) {
|
|
39
|
-
fs.mkdirSync(dist, { recursive: true });
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Specify the output file path and write the aggregated filteredRoutes to a JSON file
|
|
43
|
-
const outputPath = path.join(dist, outputFile);
|
|
44
|
-
fs.writeFileSync(outputPath, JSON.stringify(allFilteredRoutes, null, 2), 'utf8');
|
|
45
|
-
console.log(`Aggregated filtered routes have been written to ${outputPath}`);
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
}
|